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

device

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

device - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

.travis.yml

74

index.js

@@ -1,11 +0,65 @@

var express_device = require('express-device');
module.exports = {
useragent_is: function (ua, options) {
if (!ua) {
// No user agent.
return;
}
if (typeof ua !== 'string') {
throw new Error('User agent must be a string');
}
options = options || {};
options.unknownDeviceType = options.unknownDeviceType || 'phone';
var deviceParser = new express_device.Parser();
deviceParser.user_agent = function() {
return this.ua_string;
};
module.exports.useragent_is = function (ua) {
deviceParser.ua_string = ua;
return deviceParser.get_type();
};
// overwrite Flipboard user agent otherwise it's detected as a desktop
if( ua.match(/FlipboardProxy/i) )
ua = 'FlipboardProxy/1.1; http://flipboard.com/browserproxy';
if( ua.match(/Applebot/i) )
ua = 'Applebot/0.1; http://www.apple.com/go/applebot';
if (ua.match(/GoogleTV|SmartTV|Internet TV|NetCast|NETTV|AppleTV|boxee|Kylo|Roku|DLNADOC|hbbtv|CE\-HTML/i)) {
// if user agent is a smart TV - http://goo.gl/FocDk
return 'tv';
} else if (ua.match(/Xbox|PLAYSTATION 3|Wii/i)) {
// if user agent is a TV Based Gaming Console
return 'tv';
} else if (ua.match(/iP(a|ro)d/i) || (ua.match(/tablet/i) && !ua.match(/RX-34/i)) || ua.match(/FOLIO/i)) {
// if user agent is a Tablet
return 'tablet';
} else if (ua.match(/Linux/i) && ua.match(/Android/i) && !ua.match(/Fennec|mobi|HTC Magic|HTCX06HT|Nexus One|SC-02B|fone 945/i)) {
// if user agent is an Android Tablet
return 'tablet';
} else if (ua.match(/Kindle/i) || (ua.match(/Mac OS/i) && ua.match(/Silk/i)) || (ua.match(/AppleWebKit/i) && ua.match(/Silk/i) && !ua.match(/Playstation Vita/i))) {
// if user agent is a Kindle or Kindle Fire
return 'tablet';
} else if (ua.match(/GT-P10|SC-01C|SHW-M180S|SGH-T849|SCH-I800|SHW-M180L|SPH-P100|SGH-I987|zt180|HTC( Flyer|_Flyer)|Sprint ATP51|ViewPad7|pandigital(sprnova|nova)|Ideos S7|Dell Streak 7|Advent Vega|A101IT|A70BHT|MID7015|Next2|nook/i) || (ua.match(/MB511/i) && ua.match(/RUTEM/i))) {
// if user agent is a pre Android 3.0 Tablet
return 'tablet';
} else if (ua.match(/BOLT|Fennec|Iris|Maemo|Minimo|Mobi|mowser|NetFront|Novarra|Prism|RX-34|Skyfire|Tear|XV6875|XV6975|Google Wireless Transcoder/i)) {
// if user agent is unique phone User Agent
return 'phone';
} else if (ua.match(/Opera/i) && ua.match(/Windows NT 5/i) && ua.match(/HTC|Xda|Mini|Vario|SAMSUNG\-GT\-i8000|SAMSUNG\-SGH\-i9/i)) {
// if user agent is an odd Opera User Agent - http://goo.gl/nK90K
return 'phone';
} else if ((ua.match(/Windows (NT|XP|ME|9)/) && !ua.match(/Phone/i)) && !ua.match(/Bot|Spider|ia_archiver|NewsGator/i) || ua.match(/Win( ?9|NT)/i)) {
// if user agent is Windows Desktop
return 'desktop';
} else if (ua.match(/Macintosh|PowerPC/i) && !ua.match(/Silk/i)) {
// if agent is Mac Desktop
return 'desktop';
} else if (ua.match(/Linux/i) && ua.match(/X11/i) && !ua.match(/Charlotte/i)) {
// if user agent is a Linux Desktop
return 'desktop';
} else if (ua.match(/CrOS/)) {
// if user agent is a Chrome Book
return 'desktop';
} else if (ua.match(/Solaris|SunOS|BSD/i)) {
// if user agent is a Solaris, SunOS, BSD Desktop
return 'desktop';
} else if (ua.match(/Mozilla\/5\.0 \(\)|jack|Applebot|FlipboardProxy|Go 1.1 package|HTMLParser|simplereach|python-requests|ShowyouBot|MetaURI|nineconnections|(^Java\/[0-9._]*)|Commons-HttpClient|InAGist|HTTP-Java-Client|curl|Bot|B-O-T|Crawler|Spider|Spyder|Yahoo|ia_archiver|Covario-IDS|findlinks|DataparkSearch|larbin|Mediapartners-Google|NG-Search|Snappy|Teoma|Jeeves|Charlotte|NewsGator|TinEye|Cerberian|SearchSight|Zao|Scrubby|Qseero|PycURL|Pompos|oegp|SBIder|yoogliFetchAgent|yacy|webcollage|VYU2|voyager|updated|truwoGPS|StackRambler|Sqworm|silk|semanticdiscovery|ScoutJet|Nymesis|NetResearchServer|MVAClient|mogimogi|Mnogosearch|Arachmo|Accoona|holmes|htdig|ichiro|webis|LinkWalker|lwp-trivial|facebookexternalhit/i) && !ua.match(/phone|Playstation/i)) {
// if user agent is a BOT/Crawler/Spider
return 'bot';
} else {
// Otherwise assume it is a phone Device
return options.unknownDeviceType;
}
}
}

13

package.json
{
"name": "device",
"version": "0.1.0",
"version": "0.2.0",
"description": "Browser detection library based on express-device, but without the express part",

@@ -19,8 +19,11 @@ "main": "index.js",

],
"dependencies": {
"express-device" : ">= 0.2.0"
"scripts": {
"test": "mocha test/"
},
"dependencies": {},
"author": "Jimmy Bergman <jimmy@sigint.se>",
"license": "MIT"
"license": "MIT",
"devDependencies": {
"mocha": "^2.3.1"
}
}

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