@lazyneoaz/metachat 1.1.3 → 1.1.6

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.
@@ -1,47 +1,81 @@
1
1
  "use strict";
2
2
  const { getRandom } = require("./constants");
3
3
 
4
+ // Chrome versions ordered newest-first. Keep this list current — Facebook's
5
+ // bot-detection compares claimed UA versions against known release timelines.
6
+ // Versions that are too old (pre-120) or too new (unreleased) are flagged.
4
7
  const BROWSER_DATA = {
5
8
  windows: {
6
9
  platform: "Windows NT 10.0; Win64; x64",
7
- // Ordered from newest to oldest so random selection skews toward current builds
8
10
  chromeVersions: [
9
- "137.0.0.0", "136.0.0.0", "135.0.0.0", "134.0.0.0", "133.0.0.0",
10
- "132.0.6834.160", "131.0.6778.205", "130.0.6723.119", "129.0.6668.100"
11
+ "143.0.7499.182", "142.0.7410.114", "141.0.7358.100",
12
+ "140.0.7294.114", "139.0.7258.100", "138.0.7204.92",
13
+ "137.0.7151.68", "136.0.7103.113", "135.0.7049.96",
14
+ "134.0.6998.165"
11
15
  ],
12
16
  edgeVersions: [
13
- "137.0.0.0", "136.0.0.0", "135.0.0.0", "134.0.0.0",
14
- "133.0.3065.92", "132.0.2957.140", "131.0.2903.112"
17
+ "143.0.7499.182", "142.0.7410.114", "141.0.7358.100",
18
+ "140.0.7294.114", "139.0.7258.100"
15
19
  ],
16
20
  platformVersion: '"15.0.0"'
17
21
  },
18
22
  mac: {
19
23
  platform: "Macintosh; Intel Mac OS X 10_15_7",
20
24
  chromeVersions: [
21
- "137.0.0.0", "136.0.0.0", "135.0.0.0", "134.0.0.0", "133.0.0.0",
22
- "132.0.6834.160", "131.0.6778.205", "130.0.6723.119", "129.0.6668.100"
25
+ "143.0.7499.182", "142.0.7410.114", "141.0.7358.100",
26
+ "140.0.7294.114", "139.0.7258.100", "138.0.7204.92",
27
+ "137.0.7151.68", "136.0.7103.113", "135.0.7049.96",
28
+ "134.0.6998.165"
23
29
  ],
24
30
  edgeVersions: [
25
- "137.0.0.0", "136.0.0.0", "135.0.0.0", "134.0.0.0",
26
- "133.0.3065.92", "132.0.2957.140"
31
+ "143.0.7499.182", "142.0.7410.114", "141.0.7358.100",
32
+ "140.0.7294.114", "139.0.7258.100"
27
33
  ],
28
- platformVersion: '"14.7.1"'
34
+ platformVersion: '"14.7.0"'
29
35
  },
30
36
  linux: {
31
37
  platform: "X11; Linux x86_64",
32
38
  chromeVersions: [
33
- "137.0.0.0", "136.0.0.0", "135.0.0.0", "134.0.0.0",
34
- "133.0.0.0", "132.0.6834.160", "131.0.6778.205"
39
+ "143.0.7499.182", "142.0.7410.114", "141.0.7358.100",
40
+ "140.0.7294.114", "139.0.7258.100", "138.0.7204.92",
41
+ "137.0.7151.68", "136.0.7103.113"
35
42
  ],
36
43
  edgeVersions: [
37
- "137.0.0.0", "136.0.0.0", "135.0.0.0",
38
- "134.0.0.0", "133.0.3065.92"
44
+ "143.0.7499.182", "142.0.7410.114", "141.0.7358.100",
45
+ "140.0.7294.114"
39
46
  ],
40
47
  platformVersion: '""'
41
48
  }
42
49
  };
43
50
 
44
- const defaultUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36";
51
+ const defaultUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.7499.182 Safari/537.36";
52
+
53
+ /**
54
+ * Builds the correct GREASE token for a given major Chrome version.
55
+ *
56
+ * Chrome picks one of several "not a brand" placeholder strings via a
57
+ * deterministic algorithm keyed to the major version. Using the wrong
58
+ * GREASE value is a detectable fingerprint mismatch.
59
+ *
60
+ * The set used by Chrome 100+ rotates through these four forms based on
61
+ * (major % 4):
62
+ * 0 → "Not)A;Brand"
63
+ * 1 → "Not A(Brand"
64
+ * 2 → "Not;A=Brand"
65
+ * 3 → "Not A Brand" (older alias)
66
+ *
67
+ * @param {number} major - Chrome major version number.
68
+ * @returns {string} - GREASE brand string without the surrounding quotes.
69
+ */
70
+ function greaseForVersion(major) {
71
+ const forms = [
72
+ "Not)A;Brand",
73
+ "Not A(Brand",
74
+ "Not;A=Brand",
75
+ "Not A Brand"
76
+ ];
77
+ return forms[major % 4];
78
+ }
45
79
 
46
80
  /**
47
81
  * Generates a realistic, randomized User-Agent string and related Sec-CH headers.
@@ -52,32 +86,42 @@ function randomUserAgent() {
52
86
  const os = getRandom(Object.keys(BROWSER_DATA));
53
87
  const data = BROWSER_DATA[os];
54
88
 
55
- const useEdge = Math.random() > 0.7 && data.edgeVersions;
89
+ const useEdge = Math.random() > 0.75 && data.edgeVersions && data.edgeVersions.length > 0;
56
90
  const versions = useEdge ? data.edgeVersions : data.chromeVersions;
57
91
  const version = getRandom(versions);
58
92
  const majorVersion = version.split('.')[0];
93
+ const major = parseInt(majorVersion, 10);
59
94
  const browserName = useEdge ? 'Microsoft Edge' : 'Google Chrome';
60
- const browserIdentifier = useEdge ? 'Edg' : 'Chrome';
61
95
 
62
- const userAgent = useEdge
96
+ const userAgent = useEdge
63
97
  ? `Mozilla/5.0 (${data.platform}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${version} Safari/537.36 Edg/${version}`
64
98
  : `Mozilla/5.0 (${data.platform}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${version} Safari/537.36`;
65
99
 
66
- const greeseValue = Math.random() > 0.5 ? '99' : '8';
67
- const brands = useEdge ? [
68
- `"Chromium";v="${majorVersion}"`,
69
- `"Not(A:Brand";v="${greeseValue}"`,
70
- `"${browserName}";v="${majorVersion}"`
71
- ] : [
72
- `"${browserName}";v="${majorVersion}"`,
73
- `"Not;A=Brand";v="${greeseValue}"`,
74
- `"Chromium";v="${majorVersion}"`
75
- ];
100
+ // Use the version-correct GREASE placeholder mismatched GREASE is a
101
+ // detectable fingerprint that Facebook's bot detection system checks.
102
+ const greaseStr = greaseForVersion(major);
103
+ const greaseVersion = "99";
104
+
105
+ let brands;
106
+ if (useEdge) {
107
+ brands = [
108
+ `"Chromium";v="${majorVersion}"`,
109
+ `"${browserName}";v="${majorVersion}"`,
110
+ `"${greaseStr}";v="${greaseVersion}"`
111
+ ];
112
+ } else {
113
+ brands = [
114
+ `"${browserName}";v="${majorVersion}"`,
115
+ `"Chromium";v="${majorVersion}"`,
116
+ `"${greaseStr}";v="${greaseVersion}"`
117
+ ];
118
+ }
76
119
 
77
120
  const secChUa = brands.join(', ');
121
+
122
+ // Full version list replaces the major-only version with the full string
78
123
  const secChUaFullVersionList = brands.map(b => {
79
- const match = b.match(/v="(\d+)"/);
80
- if (match && match[1] === majorVersion) {
124
+ if (b.includes(`v="${majorVersion}"`)) {
81
125
  return b.replace(`v="${majorVersion}"`, `v="${version}"`);
82
126
  }
83
127
  return b;
@@ -124,7 +168,7 @@ function randomFbav() {
124
168
  }
125
169
 
126
170
  function randomOrcaUA() {
127
- const androidVersions = ["10", "11", "12", "13", "14", "15"];
171
+ const androidVersions = ["8.1.0", "9", "10", "11", "12", "13", "14"];
128
172
  const devices = [
129
173
  { brand: "samsung", model: "SM-G996B" },
130
174
  { brand: "samsung", model: "SM-S908E" },
@@ -254,4 +298,4 @@ module.exports = {
254
298
  randomOrcaUA,
255
299
  generateUserAgentByPersona,
256
300
  cachePersonaData,
257
- };
301
+ };