Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

51degrees

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

51degrees - npm Package Compare versions

Comparing version 1.3.4 to 1.3.7

properties/enterprise.json

87

index.js

@@ -30,2 +30,3 @@ /*

var path = require('path');
var debug = require('debug')('51degrees');
var TrieParser = require('./build/Release/trie.node').TrieParser;

@@ -57,4 +58,7 @@ var PatternParser = require('./build/Release/pattern.node').PatternParser;

if (typeof filename !== 'string')
throw new Error('data filename required');
if (typeof filename !== 'string') {
var err = new Error('failed to read file: ' + filename);
err.code = 'DB_NOT_FOUND';
throw err;
}

@@ -70,2 +74,13 @@ if (filename === 'pattern' || filename === 'trie')

// parse database type by extname
// .trie -> trie
// .dat -> pattern
//
// but we support shortcut for pattern database file like:
// new Parser('51degrees-lite')
// will be parsed to '51degrees-lite.data' and treated as
// pattern database.
//
// if anyother extname, will throw error
//
var extname = path.extname(filename);

@@ -82,3 +97,5 @@ if (extname === '.trie') {

} else {
throw new Error('could not find data file: ' + filename);
var err = new Error('failed to read file: ' + filename);
err.code = 'DB_NOT_FOUND';
throw err;
}

@@ -89,3 +106,5 @@ }

var res = this._parser.parse(userAgent);
if (!res) return undefined;
if (!res)
throw new Error('Critical error. Number of profiles for this match is 0. Please notify support');
// set `method` that user set in constructor
res.method = this.method;

@@ -99,55 +118,7 @@ return res;

exports.Parser = Parser;
exports.ALL_PROPERTIES = [
'AnimationTiming',
'BlobBuilder',
'Canvas',
'CssBackground',
'CssBorderImage',
'CssCanvas',
'CssColor',
'CssColumn',
'CssFlexbox',
'CssFont',
'CssImages',
'CssMediaQueries',
'CssMinMax',
'CssOverflow',
'CssPosition',
'CssText',
'CssTransforms',
'CssTransitions',
'CssUI',
'DataSet',
'DataUrl',
'DeviceOrientation',
'FileReader',
'FileSaver',
'FileWriter',
'FormData',
'Fullscreen',
'GeoLocation',
'History',
'Html5',
'Html-Media-Capture',
'Id',
'Iframe',
'IndexedDB',
'IsMobile',
'Json',
'LayoutEngine',
'Masking',
'PostMessage',
'Progress',
'Prompts',
'ScreenPixelsHeight',
'ScreenPixelsWidth',
'Selector',
'Svg',
'TouchEvents',
'Track',
'Video',
'Viewport',
'WebWorkers',
'Xhr2'
];
module.exports = {
'Parser' : Parser,
'ALL_PROPERTIES' : require('./properties/lite.json'),
'ALL_PREMIUM_PROPERTIES' : require('./properties/premium.json'),
'ALL_ENTERPRISE_PROPERTIES' : require('./properties/enterprise.json')
};
{
"name": "51degrees",
"version": "1.3.4",
"version": "1.3.7",
"description": "51degrees c-sdk native bindings for nodejs",

@@ -27,2 +27,3 @@ "main": "index.js",

"csv": "^0.4.0",
"debug": "^2.1.0",
"microtime": "^1.0.1",

@@ -29,0 +30,0 @@ "tape": "^2.14.0"

51degrees.node
==============
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/yorkie/51degrees.node?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

@@ -12,3 +13,3 @@ 51degrees c-sdk native bindings for nodejs, it helps you detect devices from `userAgent` in high performance.

-------------- | ------------
[![Build status](https://ci.appveyor.com/api/projects/status/m1nwwmospqiipyeu?svg=true)](https://ci.appveyor.com/project/yorkie/51degrees-node) | [![Build Status](https://travis-ci.org/yorkie/51degrees.node.svg?branch=master)](https://travis-ci.org/yorkie/51degrees.node)
[![Build status](https://ci.appveyor.com/api/projects/status/m1nwwmospqiipyeu?svg=true)](https://ci.appveyor.com/project/yorkie/51degrees-node) | [![Build Status](https://travis-ci.org/51Degreesmobi/51degrees.node.svg?branch=master)](https://travis-ci.org/51Degreesmobi/51degrees.node)

@@ -15,0 +16,0 @@

@@ -29,6 +29,20 @@ /*

var test = require('tape');
var crypto = require('crypto');
var fs = require('fs');
var path = require('path');
var Parser = require('./index').Parser;
var properties = require('./index').ALL_PROPERTIES;
var userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.94 Safari/537.36';
var ua_src = fs.readFileSync(path.join(__dirname, './benchmark/ua.txt'));
var ua_array = (ua_src + '').split('\n');
test('constructor arguments valid', function(t) {
try {
new Parser('51Degrees-Lite.1');
} catch (e) {
t.equal(e.code, 'DB_NOT_FOUND');
t.end();
}
});
test('pattern', function(t) {

@@ -44,2 +58,12 @@ var parser = new Parser('51Degrees-Lite.dat', properties);

test('trie', function(t) {
var parser = new Parser('51Degrees-Lite.trie', properties);
var ret = parser.parse(userAgent);
properties.forEach(function(property) {
t.ok(typeof ret[property] !== undefined, property + '> ok');
});
t.equal(ret.method, 'trie');
t.end();
});
test('pattern overflow', function(t) {

@@ -60,10 +84,47 @@ var ua = new Buffer(1000);

test('trie', function(t) {
var parser = new Parser('51Degrees-Lite.trie', properties);
var ret = parser.parse(userAgent);
properties.forEach(function(property) {
t.ok(typeof ret[property] !== undefined, property + '> ok');
test('empty userAgent', function(t) {
var r;
var psr1 = new Parser('51Degrees-Lite', properties);
r = psr1.parse('');
t.equal(r.method, 'pattern');
var psr2 = new Parser('51Degrees-Lite.trie', properties);
r = psr2.parse('');
t.equal(r.method, 'trie');
t.end();
});
test('random userAgent', function(t) {
var r;
var ua = crypto.pseudoRandomBytes(10);
var psr1 = new Parser('51Degrees-Lite', properties);
r = psr1.parse(ua);
t.equal(r.method, 'pattern');
var psr2 = new Parser('51Degrees-Lite.trie', properties);
r = psr2.parse(ua);
t.equal(r.method, 'trie');
t.end();
});
test('memory leak at pattern', function(t) {
var cp1 = process.memoryUsage().rss / 1024 / 1024;
var psr1 = new Parser('51Degrees-Lite', properties);
ua_array.forEach(function(ua) {
psr1.parse(ua);
});
t.equal(ret.method, 'trie');
var cp2 = process.memoryUsage().rss / 1024 / 1024;
t.ok(cp2 - cp1 <= 100, 'no memory leak at pattern');
t.end();
});
test('memory leak at trie', function(t) {
var cp1 = process.memoryUsage().rss / 1024 / 1024;
var psr1 = new Parser('51Degrees-Lite.trie', properties);
ua_array.forEach(function(ua) {
psr1.parse(ua);
});
var cp2 = process.memoryUsage().rss / 1024 / 1024;
t.ok(cp2 - cp1 <= 100, 'no memory leak at trie');
t.end();
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc