@tinkoff/user-agent 0.8.189 → 0.8.208
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/parse-user-agent-header/parseUserAgentHeader.es.js +3 -1
- package/lib/parse-user-agent-header/parseUserAgentHeader.js +3 -1
- package/lib/parse-user-agent-header/utils/normalizeOSVersion.d.ts +21 -0
- package/lib/parse-user-agent-header/utils/normalizeOSVersion.es.js +32 -0
- package/lib/parse-user-agent-header/utils/normalizeOSVersion.js +36 -0
- package/package.json +2 -2
|
@@ -5,12 +5,13 @@ import { getMobileOs } from '../utils/getMobileOs.es.js';
|
|
|
5
5
|
import { toLowerName } from './utils/toLowerName.es.js';
|
|
6
6
|
import { DeviceType } from '../constants.es.js';
|
|
7
7
|
import { mergeExtensions } from './utils/mergeExtensions.es.js';
|
|
8
|
+
import { normalizeOSVersion } from './utils/normalizeOSVersion.es.js';
|
|
8
9
|
|
|
9
10
|
const parseUserAgentHeader = (userAgent, extensions) => {
|
|
10
11
|
const { ua, ...result } = new UAParser(userAgent, {
|
|
11
12
|
...mergeExtensions(extensions || []),
|
|
12
13
|
}).getResult();
|
|
13
|
-
const { browser,
|
|
14
|
+
const { browser, engine, os } = result;
|
|
14
15
|
const browserName = toLowerName(browser);
|
|
15
16
|
const engineName = toLowerName(engine);
|
|
16
17
|
if (browserName === 'opera mobi') {
|
|
@@ -18,6 +19,7 @@ const parseUserAgentHeader = (userAgent, extensions) => {
|
|
|
18
19
|
}
|
|
19
20
|
return {
|
|
20
21
|
...result,
|
|
22
|
+
os: normalizeOSVersion({ os, browser }),
|
|
21
23
|
mobileOS: getMobileOs(os.name),
|
|
22
24
|
sameSiteNoneCompatible: isSameSiteNoneCompatible(result),
|
|
23
25
|
browser: {
|
|
@@ -9,12 +9,13 @@ var getMobileOs = require('../utils/getMobileOs.js');
|
|
|
9
9
|
var toLowerName = require('./utils/toLowerName.js');
|
|
10
10
|
var constants = require('../constants.js');
|
|
11
11
|
var mergeExtensions = require('./utils/mergeExtensions.js');
|
|
12
|
+
var normalizeOSVersion = require('./utils/normalizeOSVersion.js');
|
|
12
13
|
|
|
13
14
|
const parseUserAgentHeader = (userAgent, extensions) => {
|
|
14
15
|
const { ua, ...result } = new uaParserJs.UAParser(userAgent, {
|
|
15
16
|
...mergeExtensions.mergeExtensions(extensions || []),
|
|
16
17
|
}).getResult();
|
|
17
|
-
const { browser,
|
|
18
|
+
const { browser, engine, os } = result;
|
|
18
19
|
const browserName = toLowerName.toLowerName(browser);
|
|
19
20
|
const engineName = toLowerName.toLowerName(engine);
|
|
20
21
|
if (browserName === 'opera mobi') {
|
|
@@ -22,6 +23,7 @@ const parseUserAgentHeader = (userAgent, extensions) => {
|
|
|
22
23
|
}
|
|
23
24
|
return {
|
|
24
25
|
...result,
|
|
26
|
+
os: normalizeOSVersion.normalizeOSVersion({ os, browser }),
|
|
25
27
|
mobileOS: getMobileOs.getMobileOs(os.name),
|
|
26
28
|
sameSiteNoneCompatible: isSameSiteNoneCompatible.isSameSiteNoneCompatible(result),
|
|
27
29
|
browser: {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://webkit.org/blog/17333/webkit-features-in-safari-26-0/#update-to-ua-string
|
|
3
|
+
*
|
|
4
|
+
* iOS version normalization workaround for Safari ≥ 26.
|
|
5
|
+
*
|
|
6
|
+
* Starting from iOS 26, WebKit freezes the OS version in the User-Agent
|
|
7
|
+
* string at 18.6, making it unreliable for detecting the real iOS version.
|
|
8
|
+
*
|
|
9
|
+
* To address this, we derive the actual iOS version from the Safari version
|
|
10
|
+
* (Version/X.Y in the UA), since Safari’s major version is aligned with the
|
|
11
|
+
* iOS major version (e.g., Safari 26 → iOS 26).
|
|
12
|
+
*
|
|
13
|
+
* This function adjusts the parsed UA result by replacing the incorrect
|
|
14
|
+
* iOS version with the inferred one when necessary.
|
|
15
|
+
*/
|
|
16
|
+
import type { IBrowser, IOS } from 'ua-parser-js';
|
|
17
|
+
export declare const normalizeOSVersion: ({ os, browser }: {
|
|
18
|
+
os: IOS;
|
|
19
|
+
browser: IBrowser;
|
|
20
|
+
}) => IOS;
|
|
21
|
+
//# sourceMappingURL=normalizeOSVersion.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://webkit.org/blog/17333/webkit-features-in-safari-26-0/#update-to-ua-string
|
|
3
|
+
*
|
|
4
|
+
* iOS version normalization workaround for Safari ≥ 26.
|
|
5
|
+
*
|
|
6
|
+
* Starting from iOS 26, WebKit freezes the OS version in the User-Agent
|
|
7
|
+
* string at 18.6, making it unreliable for detecting the real iOS version.
|
|
8
|
+
*
|
|
9
|
+
* To address this, we derive the actual iOS version from the Safari version
|
|
10
|
+
* (Version/X.Y in the UA), since Safari’s major version is aligned with the
|
|
11
|
+
* iOS major version (e.g., Safari 26 → iOS 26).
|
|
12
|
+
*
|
|
13
|
+
* This function adjusts the parsed UA result by replacing the incorrect
|
|
14
|
+
* iOS version with the inferred one when necessary.
|
|
15
|
+
*/
|
|
16
|
+
const normalizeOSVersion = ({ os, browser }) => {
|
|
17
|
+
if (browser.name?.toLowerCase() === 'mobile safari') {
|
|
18
|
+
const safariVersion = parseFloat(browser.version || '0');
|
|
19
|
+
if (safariVersion >= 26) {
|
|
20
|
+
return {
|
|
21
|
+
name: os.name,
|
|
22
|
+
version: `${safariVersion}`,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
name: os.name,
|
|
28
|
+
version: os.version,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { normalizeOSVersion };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* https://webkit.org/blog/17333/webkit-features-in-safari-26-0/#update-to-ua-string
|
|
7
|
+
*
|
|
8
|
+
* iOS version normalization workaround for Safari ≥ 26.
|
|
9
|
+
*
|
|
10
|
+
* Starting from iOS 26, WebKit freezes the OS version in the User-Agent
|
|
11
|
+
* string at 18.6, making it unreliable for detecting the real iOS version.
|
|
12
|
+
*
|
|
13
|
+
* To address this, we derive the actual iOS version from the Safari version
|
|
14
|
+
* (Version/X.Y in the UA), since Safari’s major version is aligned with the
|
|
15
|
+
* iOS major version (e.g., Safari 26 → iOS 26).
|
|
16
|
+
*
|
|
17
|
+
* This function adjusts the parsed UA result by replacing the incorrect
|
|
18
|
+
* iOS version with the inferred one when necessary.
|
|
19
|
+
*/
|
|
20
|
+
const normalizeOSVersion = ({ os, browser }) => {
|
|
21
|
+
if (browser.name?.toLowerCase() === 'mobile safari') {
|
|
22
|
+
const safariVersion = parseFloat(browser.version || '0');
|
|
23
|
+
if (safariVersion >= 26) {
|
|
24
|
+
return {
|
|
25
|
+
name: os.name,
|
|
26
|
+
version: `${safariVersion}`,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
name: os.name,
|
|
32
|
+
version: os.version,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.normalizeOSVersion = normalizeOSVersion;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinkoff/user-agent",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.208",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.es.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"user-agent-data-types": "^0.3.1"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@tramvai/cli": "6.
|
|
32
|
+
"@tramvai/cli": "6.80.6",
|
|
33
33
|
"@types/ua-parser-js": "^0.7.33"
|
|
34
34
|
},
|
|
35
35
|
"license": "Apache-2.0"
|