Compare commits

...

5 Commits

Author SHA1 Message Date
Faisal Salman
a486f28732 Bump version 1.0.34 (mirror of v0.7.34) 2023-03-05 20:52:38 +07:00
Faisal Salman
3218051f07 Bump version 0.7.34 2023-03-05 20:46:16 +07:00
Faisal Salman
551ad88474 Add new device: Apple Watch, new os: watchOS
(cherry picked from commit 18730452f2)
2023-03-04 22:45:23 +07:00
Faisal Salman
097f736c4d Fix #387 #554 - Detect iPadOS 13
https://stackoverflow.com/questions/9038625/detect-if-device-is-ios
(cherry picked from commit 5ea9f0ec16)
2023-03-04 22:43:28 +07:00
Faisal Salman
73c25771dc Fix #498 - Detect Brave Browser by checking navigator.brave
https://github.com/brave/brave-browser/issues/10165#issuecomment-641128278
(cherry picked from commit 03b0a5afa6)
2023-03-04 22:42:39 +07:00
11 changed files with 147 additions and 39 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "ua-parser-js", "name": "ua-parser-js",
"version": "0.7.33", "version": "1.0.34",
"authors": [ "authors": [
"Faisal Salman <f@faisalman.com>" "Faisal Salman <f@faisalman.com>"
], ],

View File

@@ -4,24 +4,21 @@
Version 1.0.x is basically the equivalent of version 0.7.x. See [#536](https://github.com/faisalman/ua-parser-js/issues/536) for the reason behind this confusion. Version 1.0.x is basically the equivalent of version 0.7.x. See [#536](https://github.com/faisalman/ua-parser-js/issues/536) for the reason behind this confusion.
## Version 0.7.30 / 1.0.1 ## Version 0.7.34 / 1.0.34
- Fix Sharp Mobile detected as Huawei Tablet
- Fix IE8 bug
- Add new devices : Kobo e-Reader, Apple Watch, and some new SmartTV devices
- Add new OS : watchOS
- Improve browser detection : Kakao, Naver, Brave
- Improve device detection : Oculus, iPad
- Improve OS detection : Chrome OS
- Using navigator.userAgentData as fallback for device.type & os.name
- Add new browser : Obigo, UP.Browser, Klar ## Version 0.7.33 / 1.0.33
- Add new device : Oculus, Roku
- Add new OS: Maemo, HP-UX, Android-x86, Deepin, elementary OS, GhostBSD, Linspire, Manjaro, Sabayon
- Improve detection for Sony Xperia 1ii, LG Android TV, and some more devices
- Improve detection for ARM64 CPU
- Improve detection for Windows Mobile, Netscape, Mac on PowerPC
- Categorize PDA as mobile
- Fix Sharp devices misjudged as Huawei
- Fix trailing comma for ES3 compatibility
- Some code refactor
## Version 0.7.31 / 1.0.2 - Add new browser : Cobalt
- Identify Macintosh as an Apple device
- Fix OPPO Reno A5 incorrect detection - Fix ReDoS vulnerability
- Fix TypeError Bug
- Use AST to extract regexes and verify them with safe-regex
## Version 0.7.32 / 1.0.32 ## Version 0.7.32 / 1.0.32
@@ -38,11 +35,24 @@ Version 1.0.x is basically the equivalent of version 0.7.x. See [#536](https://g
- Fix included commas in Safari / Mobile Safari version - Fix included commas in Safari / Mobile Safari version
- Increase UA_MAX_LENGTH to 350 - Increase UA_MAX_LENGTH to 350
## Version 0.7.33 / 1.0.33 ## Version 0.7.31 / 1.0.2
- Add new browser : Cobalt - Fix OPPO Reno A5 incorrect detection
- Identify Macintosh as an Apple device - Fix TypeError Bug
- Fix ReDoS vulnerability - Use AST to extract regexes and verify them with safe-regex
## Version 0.7.30 / 1.0.1
- Add new browser : Obigo, UP.Browser, Klar
- Add new device : Oculus, Roku
- Add new OS: Maemo, HP-UX, Android-x86, Deepin, elementary OS, GhostBSD, Linspire, Manjaro, Sabayon
- Improve detection for Sony Xperia 1ii, LG Android TV, and some more devices
- Improve detection for ARM64 CPU
- Improve detection for Windows Mobile, Netscape, Mac on PowerPC
- Categorize PDA as mobile
- Fix Sharp devices misjudged as Huawei
- Fix trailing comma for ES3 compatibility
- Some code refactor
# Version 0.8 # Version 0.8

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

19
images/51degrees.svg Normal file
View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 23.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 161.93 86.82" style="enable-background:new 0 0 161.93 86.82;" xml:space="preserve">
<style type="text/css">
.st0{fill:#232628;}
.st1{fill:#E62E3A;}
.st2{fill:none;}
</style>
<g>
<path class="st0" d="M116.93,0.68H103.5V17.5h13.43c15.24,0,25.53,10.53,25.53,25.53v0.24c0,15-10.28,25.29-25.53,25.29H103.5
v16.82h13.43c26.62,0,45-18.51,45-42.34v-0.24C161.93,18.95,143.54,0.68,116.93,0.68"/>
<path class="st1" d="M8.11,0.68h52.02v16.33H24.07l-0.97,14.64c3.39-0.85,6.41-1.45,11.13-1.45c16.7,0,29.64,7.99,29.64,27.22
c0,18.03-12.7,29.4-32.18,29.4c-13.55,0-23.47-4.84-31.7-12.7l11.25-13.43c6.41,5.81,12.7,9.19,20.2,9.19
c8.71,0,14.15-4.23,14.15-11.86c0-7.38-5.93-11.61-15-11.61c-5.32,0-10.16,1.45-14.16,3.15L5.69,42.42L8.11,0.68z"/>
<polygon class="st1" points="86.14,0 98.84,0 98.84,85.29 80.45,85.29 80.45,18.87 65.69,22.5 61.82,7.26 "/>
</g>
<rect x="144.06" y="110.12" class="st2" width="566.93" height="113.39"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -1,6 +1,6 @@
Package.describe({ Package.describe({
name: 'faisalman:ua-parser-js', name: 'faisalman:ua-parser-js',
version: '0.7.33', version: '1.0.34',
summary: 'Lightweight JavaScript-based user-agent string parser', summary: 'Lightweight JavaScript-based user-agent string parser',
git: 'https://github.com/faisalman/ua-parser-js.git', git: 'https://github.com/faisalman/ua-parser-js.git',
documentation: 'readme.md' documentation: 'readme.md'

View File

@@ -1,7 +1,7 @@
{ {
"title": "UAParser.js", "title": "UAParser.js",
"name": "ua-parser-js", "name": "ua-parser-js",
"version": "0.7.33", "version": "1.0.34",
"author": "Faisal Salman <f@faisalman.com> (http://faisalman.com)", "author": "Faisal Salman <f@faisalman.com> (http://faisalman.com)",
"description": "Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data. Supports browser & node.js environment", "description": "Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data. Supports browser & node.js environment",
"keywords": [ "keywords": [

View File

@@ -18,6 +18,30 @@ JavaScript library to detect Browser, Engine, OS, CPU, and Device type/model fro
* Demo : https://faisalman.github.io/ua-parser-js * Demo : https://faisalman.github.io/ua-parser-js
* Source : https://github.com/faisalman/ua-parser-js * Source : https://github.com/faisalman/ua-parser-js
***
### From Our Sponsors:
<table>
<thead>
</thead>
<tbody>
<tr>
<td align="center" width="200px" rowspan="3"><a href="https://www.npmjs.com/package/@51degrees/ua-parser-js"><img src="images/51degrees.svg" alt="51degrees" width="75%" height="75%" ></a></td>
<td align="left" width="400px"><a href="https://www.npmjs.com/package/@51degrees/ua-parser-js">@51degrees/ua-parser-js</a></td>
</tr>
<tr>
<td><br/><p>UAParser.js has been upgraded to detect comprehensive device data based on the User-Agent and User-Agent Client Hints.</p><p>This package supports all device types including Apple and Android devices and can be used either in a browser (client-side) or Node.js environment (server-side).</p><p>Visit <a href="https://www.npmjs.com/package/@51degrees/ua-parser-js">↗ 51Degrees <u>UAParser</u></a> to get started.</p>
</td>
</tr>
<tr>
<td>
<p>On 6 March, well be hosting a demonstration of the 51Degrees UAParser. Register your place for the webinar <a href="https://event.webinarjam.com/register/36/6k2gqu5p">↗ here</a>.</p></td>
</tr>
</tbody>
</table>
---
# Documentation # Documentation
### UAParser([user-agent][,extensions]) ### UAParser([user-agent][,extensions])
typeof `user-agent` "string". typeof `user-agent` "string".
@@ -144,7 +168,7 @@ Linpus, Linspire,Linux, Mac OS, Maemo, Mageia, Mandriva, Manjaro, MeeGo, Minix,
Mint, Morph OS, NetBSD, NetRange, NetTV, Nintendo, OpenBSD, OpenVMS, OS/2, Palm, Mint, Morph OS, NetBSD, NetRange, NetTV, Nintendo, OpenBSD, OpenVMS, OS/2, Palm,
PC-BSD, PCLinuxOS, Plan9, PlayStation, QNX, Raspbian, RedHat, RIM Tablet OS, PC-BSD, PCLinuxOS, Plan9, PlayStation, QNX, Raspbian, RedHat, RIM Tablet OS,
RISC OS, Sabayon, Sailfish, Series40, Slackware, Solaris, SUSE, Symbian, Tizen, RISC OS, Sabayon, Sailfish, Series40, Slackware, Solaris, SUSE, Symbian, Tizen,
Ubuntu, Unix, VectorLinux, Viera, WebOS, Windows [Phone/Mobile], Zenwalk, ... Ubuntu, Unix, VectorLinux, Viera, watchOS, WebOS, Windows [Phone/Mobile], Zenwalk, ...
# 'os.version' determined dynamically # 'os.version' determined dynamically
``` ```
@@ -312,9 +336,10 @@ console.log(myParser.setUA(myUA).getBrowser()); // {name: "MyBrowser", version:
# Development # Development
## Sponsors ## Backers & Sponsors
<a href="https://opencollective.com/ua-parser-js"><img src="https://opencollective.com/ua-parser-js/tiers/backers.svg?avatarHeight=64" height="80"/></a> <a href="https://opencollective.com/ua-parser-js"><img src="https://opencollective.com/ua-parser-js/tiers/sponsors.svg?avatarHeight=64" height="80"/></a> <a href="https://opencollective.com/ua-parser-js"><img src="https://opencollective.com/ua-parser-js/organizations.svg?avatarHeight=64"></a>
<a href="https://opencollective.com/ua-parser-js"><img src="https://opencollective.com/ua-parser-js/individuals.svg?avatarHeight=64"></a>
<a href="https://www.paypal.me/faisalman/"><img src="https://cdn.rawgit.com/twolfson/paypal-github-button/1.0.0/dist/button.svg" height="40"></a> <a href="https://www.paypal.me/faisalman/"><img src="https://cdn.rawgit.com/twolfson/paypal-github-button/1.0.0/dist/button.svg" height="40"></a>

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
/* UAParser.js v0.7.33 /* UAParser.js v1.0.34
Copyright © 2012-2021 Faisal Salman <f@faisalman.com> Copyright © 2012-2021 Faisal Salman <f@faisalman.com>
MIT License *//* MIT License *//*
Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data. Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data.
@@ -17,7 +17,7 @@
///////////// /////////////
var LIBVERSION = '0.7.33', var LIBVERSION = '1.0.34',
EMPTY = '', EMPTY = '',
UNKNOWN = '?', UNKNOWN = '?',
FUNC_TYPE = 'function', FUNC_TYPE = 'function',
@@ -59,7 +59,9 @@
VIERA = 'Viera', VIERA = 'Viera',
XIAOMI = 'Xiaomi', XIAOMI = 'Xiaomi',
ZEBRA = 'Zebra', ZEBRA = 'Zebra',
FACEBOOK = 'Facebook'; FACEBOOK = 'Facebook',
CHROMIUM_OS = 'Chromium OS',
MAC_OS = 'Mac OS';
/////////// ///////////
// Helper // Helper
@@ -648,6 +650,8 @@
/((pebble))app/i // Pebble /((pebble))app/i // Pebble
], [VENDOR, MODEL, [TYPE, WEARABLE]], [ ], [VENDOR, MODEL, [TYPE, WEARABLE]], [
/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i // Apple Watch
], [MODEL, [VENDOR, APPLE], [TYPE, WEARABLE]], [
/droid.+; (glass) \d/i // Google Glass /droid.+; (glass) \d/i // Google Glass
], [MODEL, [VENDOR, GOOGLE], [TYPE, WEARABLE]], [ ], [MODEL, [VENDOR, GOOGLE], [TYPE, WEARABLE]], [
/droid.+; (wt63?0{2,3})\)/i /droid.+; (wt63?0{2,3})\)/i
@@ -715,7 +719,7 @@
], [[VERSION, /_/g, '.'], [NAME, 'iOS']], [ ], [[VERSION, /_/g, '.'], [NAME, 'iOS']], [
/(mac os x) ?([\w\. ]*)/i, /(mac os x) ?([\w\. ]*)/i,
/(macintosh|mac_powerpc\b)(?!.+haiku)/i // Mac OS /(macintosh|mac_powerpc\b)(?!.+haiku)/i // Mac OS
], [[NAME, 'Mac OS'], [VERSION, /_/g, '.']], [ ], [[NAME, MAC_OS], [VERSION, /_/g, '.']], [
// Mobile OSes // Mobile OSes
/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i // Android-x86/HarmonyOS /droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i // Android-x86/HarmonyOS
@@ -734,12 +738,14 @@
/web0s;.+rt(tv)/i, /web0s;.+rt(tv)/i,
/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i // WebOS /\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i // WebOS
], [VERSION, [NAME, 'webOS']], [ ], [VERSION, [NAME, 'webOS']], [
/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i // watchOS
], [VERSION, [NAME, 'watchOS']], [
// Google Chromecast // Google Chromecast
/crkey\/([\d\.]+)/i // Google Chromecast /crkey\/([\d\.]+)/i // Google Chromecast
], [VERSION, [NAME, CHROME+'cast']], [ ], [VERSION, [NAME, CHROME+'cast']], [
/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i // Chromium OS /(cros) [\w]+(?:\)| ([\w\.]+)\b)/i // Chromium OS
], [[NAME, 'Chromium OS'], VERSION],[ ], [[NAME, CHROMIUM_OS], VERSION],[
// Smart TVs // Smart TVs
/panasonic;(viera)/i, // Panasonic Viera /panasonic;(viera)/i, // Panasonic Viera
@@ -786,8 +792,9 @@
return new UAParser(ua, extensions).getResult(); return new UAParser(ua, extensions).getResult();
} }
var _ua = ua || ((typeof window !== UNDEF_TYPE && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY); var _navigator = (typeof window !== UNDEF_TYPE && window.navigator) ? window.navigator : undefined;
var _uach = (typeof window !== UNDEF_TYPE && window.navigator && window.navigator.userAgentData) ? window.navigator.userAgentData : undefined; var _ua = ua || ((_navigator && _navigator.userAgent) ? _navigator.userAgent : EMPTY);
var _uach = (_navigator && _navigator.userAgentData) ? _navigator.userAgentData : undefined;
var _rgxmap = extensions ? extend(regexes, extensions) : regexes; var _rgxmap = extensions ? extend(regexes, extensions) : regexes;
this.getBrowser = function () { this.getBrowser = function () {
@@ -795,7 +802,11 @@
_browser[NAME] = undefined; _browser[NAME] = undefined;
_browser[VERSION] = undefined; _browser[VERSION] = undefined;
rgxMapper.call(_browser, _ua, _rgxmap.browser); rgxMapper.call(_browser, _ua, _rgxmap.browser);
_browser.major = majorize(_browser.version); _browser[MAJOR] = majorize(_browser[VERSION]);
// Brave-specific detection
if (_navigator && _navigator.brave && typeof _navigator.brave.isBrave == FUNC_TYPE) {
_browser[NAME] = 'Brave';
}
return _browser; return _browser;
}; };
this.getCPU = function () { this.getCPU = function () {
@@ -813,6 +824,11 @@
if (!_device[TYPE] && _uach && _uach.mobile) { if (!_device[TYPE] && _uach && _uach.mobile) {
_device[TYPE] = MOBILE; _device[TYPE] = MOBILE;
} }
// iPadOS-specific detection: identified as Mac, but has some iOS-only properties
if (_device[MODEL] == 'Macintosh' && _navigator && typeof _navigator.standalone !== UNDEF_TYPE && _navigator.maxTouchPoints && _navigator.maxTouchPoints > 2) {
_device[MODEL] = 'iPad';
_device[TYPE] = TABLET;
}
return _device; return _device;
}; };
this.getEngine = function () { this.getEngine = function () {
@@ -828,7 +844,9 @@
_os[VERSION] = undefined; _os[VERSION] = undefined;
rgxMapper.call(_os, _ua, _rgxmap.os); rgxMapper.call(_os, _ua, _rgxmap.os);
if (!_os[NAME] && _uach && _uach.platform != 'Unknown') { if (!_os[NAME] && _uach && _uach.platform != 'Unknown') {
_os[NAME] = _uach.platform.replace(/chrome/i, 'Chromium').replace(/mac/i, 'Mac '); _os[NAME] = _uach.platform
.replace(/chrome os/i, CHROMIUM_OS)
.replace(/macos/i, MAC_OS); // backward compatibility
} }
return _os; return _os;
}; };

View File

@@ -763,6 +763,15 @@
"type": "undefined" "type": "undefined"
} }
}, },
{
"desc": "Apple Watch",
"ua": "atc/1.0 watchOS/7.3.3 model/Watch4,2 hwp/t8006 build/18S830 (6; dt:191)",
"expect": {
"vendor": "Apple",
"model": "watch",
"type": "wearable"
}
},
{ {
"desc": "iPad using UCBrowser", "desc": "iPad using UCBrowser",
"ua": "Mozilla/5.0 (iPad; U; CPU OS 11_2 like Mac OS X; zh-CN; iPad5,3) AppleWebKit/534.46 (KHTML, like Gecko) UCBrowser/3.0.1.776 U3/ Mobile/10A403 Safari/7543.48.3", "ua": "Mozilla/5.0 (iPad; U; CPU OS 11_2 like Mac OS X; zh-CN; iPad5,3) AppleWebKit/534.46 (KHTML, like Gecko) UCBrowser/3.0.1.776 U3/ Mobile/10A403 Safari/7543.48.3",

View File

@@ -764,6 +764,33 @@
"version" : "undefined" "version" : "undefined"
} }
}, },
{
"desc" : "watchOS",
"ua" : "server-bag [Watch OS,8.4,19S546,Watch3,4]",
"expect" :
{
"name" : "watchOS",
"version" : "8.4"
}
},
{
"desc" : "watchOS",
"ua" : "atc/1.0 watchOS/7.4.1 model/Watch3,3 hwp/t8004 build/18T201 (6; dt:155)",
"expect" :
{
"name" : "watchOS",
"version" : "7.4.1"
}
},
{
"desc" : "watchOS",
"ua" : "Watch4,3/5.3.8 (16U680)",
"expect" :
{
"name" : "watchOS",
"version" : "5.3.8"
}
},
{ {
"desc" : "Mac OS on PowerPC", "desc" : "Mac OS on PowerPC",
"ua" : "Mozilla/4.0 (compatible; MSIE 5.0b1; Mac_PowerPC)", "ua" : "Mozilla/4.0 (compatible; MSIE 5.0b1; Mac_PowerPC)",