diff --git a/package-lock.json b/package-lock.json index dff4a27a..a028fa22 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2947,9 +2947,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001538", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001538.tgz", - "integrity": "sha512-HWJnhnID+0YMtGlzcp3T9drmBJUVDchPJ08tpUGFLs9CYlwWPH2uLgpHn8fND5pCgXVtnGS3H4QR9XLMHVNkHw==", + "version": "1.0.30001690", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001690.tgz", + "integrity": "sha512-5ExiE3qQN6oF8Clf8ifIDcMRCRE/dMGcETG/XGMD8/XiXm6HXQgQTh1yZYLXXpSOsEUlJm1Xr7kGULZTuGtP/w==", "funding": [ { "type": "opencollective", @@ -2963,7 +2963,8 @@ "type": "github", "url": "https://github.com/sponsors/ai" } - ] + ], + "license": "CC-BY-4.0" }, "node_modules/chalk": { "version": "4.1.2", @@ -11865,9 +11866,9 @@ "peer": true }, "caniuse-lite": { - "version": "1.0.30001538", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001538.tgz", - "integrity": "sha512-HWJnhnID+0YMtGlzcp3T9drmBJUVDchPJ08tpUGFLs9CYlwWPH2uLgpHn8fND5pCgXVtnGS3H4QR9XLMHVNkHw==" + "version": "1.0.30001690", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001690.tgz", + "integrity": "sha512-5ExiE3qQN6oF8Clf8ifIDcMRCRE/dMGcETG/XGMD8/XiXm6HXQgQTh1yZYLXXpSOsEUlJm1Xr7kGULZTuGtP/w==" }, "chalk": { "version": "4.1.2", diff --git a/packages/fingerprint-generator/src/data_files/fingerprint-network-definition.zip b/packages/fingerprint-generator/src/data_files/fingerprint-network-definition.zip index 054eef41..478a5201 100644 Binary files a/packages/fingerprint-generator/src/data_files/fingerprint-network-definition.zip and b/packages/fingerprint-generator/src/data_files/fingerprint-network-definition.zip differ diff --git a/packages/generator-networks-creator/src/generator-networks-creator.ts b/packages/generator-networks-creator/src/generator-networks-creator.ts index a954a22c..b245cd5b 100755 --- a/packages/generator-networks-creator/src/generator-networks-creator.ts +++ b/packages/generator-networks-creator/src/generator-networks-creator.ts @@ -133,9 +133,10 @@ export class GeneratorNetworksCreator { edgios: 'edge', } as Record; - const unsupportedBrowsers = /opr|yabrowser|SamsungBrowser|UCBrowser|vivaldi/ig; - const edge = /(edg(a|ios|e)?)\/([0-9.]*)/ig; - const supportedBrowsers = /(firefox|fxios|chrome|crios|safari)\/([0-9.]*)/ig; + const unsupportedBrowsers = /opr|yabrowser|SamsungBrowser|UCBrowser|vivaldi/i; + const edge = /(edg(a|ios|e)?)\/([0-9.]*)/i; + const safari = /Version\/([\d.]+)( Mobile\/[a-z0-9]+)? Safari/i; + const supportedBrowsers = /(firefox|fxios|chrome|crios|safari)\/([0-9.]*)/i; if (unsupportedBrowsers.test(userAgent)) { return missingValueDatasetToken; @@ -144,7 +145,14 @@ export class GeneratorNetworksCreator { if (edge.test(userAgent)) { const match = userAgent.match(edge)![0].split('/'); return `edge/${match[1]}`; - } if (supportedBrowsers.test(userAgent)) { + } + + if (safari.test(userAgent)) { + const match = userAgent.match(safari); + return `safari/${match![1]}`; + } + + if (supportedBrowsers.test(userAgent)) { const match = userAgent.match(supportedBrowsers)![0].split('/'); return `${canonicalNames[match[0].toLowerCase()]}/${match[1]}`; } diff --git a/packages/header-generator/src/data_files/browser-helper-file.json b/packages/header-generator/src/data_files/browser-helper-file.json index 29b97e29..5aae6d65 100644 --- a/packages/header-generator/src/data_files/browser-helper-file.json +++ b/packages/header-generator/src/data_files/browser-helper-file.json @@ -1 +1 @@ -["chrome/128.0.0.0|2","chrome/130.0.0.0|2","chrome/120.0.0.0|2","edge/130.0.0.0|2","chrome/129.0.0.0|2","safari/605.1.15|2","chrome/124.0.0.0|2","*MISSING_VALUE*|2","chrome/126.0.0.0|2","safari/604.1|2","firefox/132.0|2","chrome/109.0.0.0|2","chrome/130.0.6723.78|2","firefox/66.0|2","chrome/130.0.6723.90|2","firefox/131.0|2","chrome/132.0.0.0|2","chrome/130.0.0.0|1","chrome/130.0.6723.37|2","chrome/116.0.0.0|2","chrome/122.0.0.0|2","chrome/123.0.0.0|2","chrome/131.0.0.0|2","chrome/127.0.0.0|2","chrome/104.0.5112.79|2","edge/129.0.0.0|2","chrome/94.0.4606.114|2","chrome/129.0.0.0|1","firefox/128.0|2","chrome/126.0.6478.806|2","chrome/121.0.0.0|2","chrome/112.0.5615.213|2","chrome/79.0.3945.117|1","chrome/113.0.0.0|2","chrome/118.0.0.0|2","chrome/117.0.0.0|2","chrome/115.0.0.0|2","chrome/79.0.3945.79|2","chrome/125.0.6422.26|2","safari/605.1.15|1","edge/130.0.0.0|1","chrome/114.0.0.0|2","firefox/130.0|2","chrome/119.0.0.0|2","chrome/105.0.0.0|2","chrome/130.0.6723.86|2","chrome/129.0.6668.46|2","firefox/133.0|2","chrome/93.0.4577.100|2","firefox/118.0|2","chrome/125.0.0.0|2","chrome/106.0.0.0|1","chrome/106.0.0.0|2","firefox/131.0|1","chrome/125.0.6422.80|2","safari/604.1|1","firefox/129.0|2","edge/120.0.0.0|2","firefox/124.0|2","firefox/125.0|2","edge/128.0.0.0|2","chrome/130.0.6723.58|2","firefox/113.0|2","edge/131.0.0.0|2","edge/92.0.902.67|2","chrome/112.0.0.0|2","chrome/94.0.4606.71|2","chrome/90.0.4430.216|2","*MISSING_VALUE*|1","chrome/88.0.4324.150|2","firefox/134.0|2","chrome/92.0.4515.107|2","chrome/94.0.4590.2|2","chrome/108.0.0.0|2","chrome/90.0.4430.93|2","chrome/83.0.4103.116|2","chrome/121.0.0.0|1","edge/129.0.2792.92|2","edge/129.0.0.0|1","chrome/97.0.4692.99|2","chrome/101.0.4951.15|2","chrome/129.0.6668.100|2","chrome/128.0.0.0|1","firefox/115.0|2","chrome/103.0.0.0|2","edge/130.0.2849.57|2","chrome/110.0.0.0|2","firefox/129.1|2","chrome/122.0.6261.171|2","chrome/127.0.6533.17|2","chrome/128.0.6613.34|2","chrome/128.0.6613.92|2","chrome/109.0.5414.120|2","edge/126.0.0.0|2","chrome/122.0.6261.112|2","firefox/117.0|2","chrome/126.0.6478.153|2","chrome/103.0.5060.129|2","edge/122.0.0.0|2","firefox/128.0|1","firefox/127.0|2","chrome/118.0.5993.220|2","firefox/95.0|2","chrome/124.0.6367.71|2","edge/114.0.1823.51|2","chrome/107.0.0.0|2","chrome/110.0.5481.153|2","firefox/131.4|2","firefox/126.0|2","chrome/111.0.0.0|2","chrome/92.0.4515.131|2","edge/128.0.0.0|1","edge/126.0.2592.106|2","chrome/100.0.4896.58|2","chrome/129.0.6668.69|2","chrome/91.0.4472.124|2","chrome/86.0.4240.75|2","safari/600.1.4|2","chrome/88.0.4324.182|2","edge/124.0.2478.64|2","edge/109.0.1518.140|2","chrome/109.0.0.0|1","chrome/127.0.6533.107|2","firefox/122.0|2","edge/130.0.2849.52|2","safari/602.1|2","chrome/59.0.3071.125|2","edge/127.0.0.0|2","chrome/132.0.0.0|1","chrome/127.0.0.0|1","chrome/128.0.6613.146|2","chrome/95.0.4638.69|2","chrome/128.0.6613.98|2","firefox/123.0|2","chrome/75.0.3770.156|2","chrome/124.0.6315.2|2","edge/100.0.1185.36|2","firefox/129|2","chrome/91.0.4472.114|2","chrome/91.0.4472.120|2","chrome/87.0.4280.141|2","chrome/122.0.6261.95|2","chrome/130.0.6723.58|1","chrome/120.0.6099.119|2","chrome/74.0.3729.136|2","firefox/114.0|2","chrome/108.0.5359.112|2","chrome/60.0.4574.1295|2","chrome/98.0.4758.87|2","chrome/128.0.6613.551|2","chrome/129.0.6668.102|2","chrome/115.0.5790.24|2","chrome/85.0.4183.101|2","edge/127.0.0.0|1","firefox/131|2","chrome/63.0.3239.111|2","edge/130.0.2849.46|2","chrome/91.0.4472.101|2","chrome/119.0.6045.193|2","edge/124.0.0.0|2","chrome/87.0.4280.101|2","chrome/127.0.6533.122|2","chrome/89.0.4389.130|2","chrome/130.0.6723.24|2","chrome/99.0.4844.88|2","chrome/116.0.5845.177|2","chrome/79.0.3945.88|2","chrome/123.0.6312.52|2","edge/125.0.0.0|2","chrome/120.0.6099.101|2","edge/121.0.0.0|2","chrome/131.0.6778.14|2","chrome/130.0.6723.73|2","firefox/131.1|2","chrome/56.0.2237.1637|2","chrome/129.0.6668.82|2","chrome/94.0.4606.61|2","chrome/130.0.6723.60|2","chrome/91.0.4472.164|2"] \ No newline at end of file +["chrome/131.0.0.0|2","chrome/131.0.6778.154|2","chrome/120.0.0.0|2","chrome/128.0.0.0|2","safari/18.2|2","safari/18.0|2","chrome/131.0.6778.134|2","firefox/133.0|2","safari/17.6|2","chrome/122.0.0.0|2","chrome/124.0.0.0|2","*MISSING_VALUE*|2","chrome/130.0.0.0|2","chrome/131.0.6778.33|2","chrome/131.0.0.0|1","edge/132.0.0.0|2","edge/131.0.0.0|2","safari/16.6|2","safari/15.6.6|2","chrome/133.0.0.0|2","chrome/63.0.3239.111|2","safari/16.3|2","chrome/127.0.0.0|2","chrome/126.0.0.0|2","safari/18.0.1|2","safari/18.1.1|2","safari/18.1|2","safari/18.3|2","edge/131.0.0.0|1","chrome/131.0.6778.135|2","firefox/128.0|2","firefox/119.0|2","safari/16.0|2","edge/131.0.2903.125|2","chrome/120.0.6099.193|2","chrome/125.0.0.0|2","chrome/96.0.4664.104|2","chrome/123.0.0.0|2","safari/17.5|2","chrome/120.0.0.0|1","edge/129.0.0.0|2","firefox/127.0|2","chrome/119.0.0.0|2","safari/17.5|1","chrome/109.0.0.0|2","safari/604.1|2","chrome/129.0.0.0|2","safari/17.4.1|2","chrome/125.0.6422.26|2","chrome/121.0.0.0|2","chrome/117.0.0.0|2","chrome/114.0.0.0|2","firefox/132.0|2","edge/124.0.0.0|2","chrome/115.0.0.0|2","safari/17.1|2","chrome/130.0.0.0|1","safari/17.1.1|2","firefox/126.0|2","chrome/132.0.0.0|2","chrome/130.0.6723.103|2","chrome/116.0.0.0|2","chrome/113.0.0.0|2","chrome/99.0.4844.88|2","chrome/57.0.2987.110|2","safari/17.2|2","chrome/87.0.4280.141|2","chrome/114.0.5735.196|2","safari/17.3|2","safari/17.2.1|2","chrome/104.0.5112.88|2","chrome/107.0.5304.66|2","chrome/131.0.6778.136|2","edge/126.0.0.0|2","firefox/115.0|2","chrome/126.0.0.0|1","chrome/91.0.4472.124|2","firefox/133.4|2","safari/16.1|2","chrome/131.0.6778.73|2","safari/17.3.1|1","safari/17.4|2","chrome/121.0.0.0|1","safari/17.0|2","safari/17.3.1|2","chrome/90.0.4430.93|2","chrome/118.0.0.0|2","chrome/111.0.0.0|2","chrome/123.0.6312.118|2","safari/17.1.2|2","chrome/103.0.0.0|2","chrome/72.0.3626.121|2","chrome/75.0.3770.156|2","firefox/134.0|2","chrome/44.0.6226.1030|2","chrome/88.0.4324.182|2","safari/17.8|2","edge/123.0.0.0|2","chrome/131.0.6778.200|2","safari/16.4|2","safari/14.1.1|2","chrome/131.0.6778.131|2","chrome/120.0.6099.119|2","chrome/104.0.0.0|2","firefox/133.0|1","chrome/79.0.3945.117|1","safari/16.6.1|2","chrome/131.0.6778.139|1","chrome/92.0.4515.131|2","chrome/112.0.0.0|2","chrome/94.0.4590.2|2","safari/11.0|2","firefox/130.0|2","edge/130.0.0.0|2","chrome/122.0.6261.95|2","firefox/129.0|2","chrome/91.0.4472.120|2","edge/131.0.2903.112|2","chrome/108.0.0.0|2","safari/16.5.2|2","safari/17.8.1|2","edge/133.0.0.0|2","safari/15.6.1|2","chrome/115.0.5790.130|2","chrome/107.0.0.0|2","safari/15.6|2","firefox/135.0|2","chrome/131.0.6778.103|2","edge/127.0.0.0|2","chrome/94.0.4606.114|2","chrome/128.0.6613.186|2","chrome/131.0.6778.41|2","safari/16.2|2","*MISSING_VALUE*|1","safari/8613.1.17.0.8|2","safari/16.5|2","firefox/131.0|2","safari/15.4|2","chrome/119.0.6045.193|2","chrome/130.0.6723.142|2","chrome/57.0.1716.1704|2","chrome/121.0.6167.171|2","chrome/86.0.4240.198|2","firefox/133|2","firefox/109.0|2","safari/17.7|2","chrome/59.0.3071.125|2","safari/10.0|2","chrome/92.0.4515.107|2","edge/122.0.0.0|2","firefox/96.0|2","chrome/110.0.0.0|2","chrome/126.0.6478.61|2","chrome/129.0.6668.101|2","chrome/112.0.5615.213|2","edge/119.0.0.0|2","chrome/131.0.6628.82|2","chrome/118.0.5993.220|2","chrome/109.0.5414.118|2","safari/605.1.15|2","safari/17.6.1|2","chrome/117.0.5938.104|2","firefox/120.0|2","chrome/127.0.6533.0|2","safari/18.2|1","safari/16.5.1|2","chrome/131.0.6778.140|2","chrome/43.0.6549.1152|2","chrome/126.0.6478.188|2","chrome/121.0.6167.66|2","chrome/98.0.4758.102|2","chrome/123.0.6312.52|2","safari/17.7.1|2","chrome/70.0.3538.110|2","safari/15.5|2","chrome/124.0.6367.111|2","chrome/126.0.6478.153|2","chrome/83.0.4103.101|2","edge/128.0.0.0|2","chrome/105.0.0.0|2","firefox/110.0|2","edge/109.0.1518.140|2","safari/16.4.1|2","firefox/128.0|1","chrome/109.0.5414.120|2","chrome/124.0.0.0|1","edge/18.17763|2","edge/113.0.1774.57|2","safari/16.6|1","edge/124.0.2478.64|2"] \ No newline at end of file diff --git a/packages/header-generator/src/data_files/header-network-definition.zip b/packages/header-generator/src/data_files/header-network-definition.zip index d8fce0d3..6d5a0a83 100644 Binary files a/packages/header-generator/src/data_files/header-network-definition.zip and b/packages/header-generator/src/data_files/header-network-definition.zip differ diff --git a/packages/header-generator/src/data_files/input-network-definition.zip b/packages/header-generator/src/data_files/input-network-definition.zip index af7a6c0f..0fd3e6d4 100644 Binary files a/packages/header-generator/src/data_files/input-network-definition.zip and b/packages/header-generator/src/data_files/input-network-definition.zip differ diff --git a/packages/header-generator/src/header-generator.ts b/packages/header-generator/src/header-generator.ts index d3e30a7f..d0b5bea4 100644 --- a/packages/header-generator/src/header-generator.ts +++ b/packages/header-generator/src/header-generator.ts @@ -117,6 +117,8 @@ export interface HeaderGeneratorOptions { httpVersion: HttpVersion; /** * If true, the generator will throw an error if it cannot generate headers based on the input. + * + * By default (strict: false), the generator will try to relax some requirements and generate headers based on the relaxed input. */ strict: boolean; } @@ -380,8 +382,10 @@ export class HeaderGenerator { for (const browser of browsers) { for (const browserOption of this.uniqueBrowsers) { if (browser.name === browserOption.name) { - if ((!browser.minVersion || this._browserVersionIsLesserOrEquals([browser.minVersion], browserOption.version)) - && (!browser.maxVersion || this._browserVersionIsLesserOrEquals(browserOption.version, [browser.maxVersion])) + const browserMajorVersion = browserOption.version[0]; + + if ((!browser.minVersion || browser.minVersion <= browserMajorVersion) + && (!browser.maxVersion || browser.maxVersion >= browserMajorVersion) && browser.httpVersion === browserOption.httpVersion) { browserHttpOptions.push(browserOption.completeString); } @@ -510,8 +514,4 @@ export class HeaderGenerator { return (this.headersOrder as Record)[browser] ?? []; } - - private _browserVersionIsLesserOrEquals(browserVersionL: number[], browserVersionR: number[]) { - return browserVersionL[0] <= browserVersionR[0]; - } } diff --git a/test/generator-networks-creator/generator-networks-creator.test.ts b/test/generator-networks-creator/generator-networks-creator.test.ts index 7795f508..72923dcb 100644 --- a/test/generator-networks-creator/generator-networks-creator.test.ts +++ b/test/generator-networks-creator/generator-networks-creator.test.ts @@ -86,19 +86,19 @@ describe('Processing browser data', () => { }, { userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Mobile/15E148 Safari/604.1", - expectedBrowser: "safari/604.1", + expectedBrowser: "safari/16.5", expectedOS: "ios", expectedDeviceType: "mobile" }, { userAgent: "Mozilla/5.0 (iPad; CPU OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Mobile/15E148 Safari/604.1", - expectedBrowser: "safari/604.1", + expectedBrowser: "safari/16.5", expectedOS: "ios", expectedDeviceType: "mobile" }, { userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 13_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Safari/605.1.15", - expectedBrowser: "safari/605.1.15", + expectedBrowser: "safari/16.5", expectedOS: "macos", expectedDeviceType: "desktop" },