@web-auto/camo 0.1.26 → 0.2.1

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.
Files changed (117) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +586 -586
  3. package/bin/browser-service.mjs +11 -11
  4. package/bin/camo.mjs +22 -22
  5. package/package.json +48 -48
  6. package/scripts/build.mjs +19 -19
  7. package/scripts/bump-version.mjs +34 -34
  8. package/scripts/check-file-size.mjs +80 -80
  9. package/scripts/file-size-policy.json +12 -2
  10. package/scripts/install.mjs +76 -76
  11. package/scripts/release.sh +54 -54
  12. package/src/autoscript/action-providers/index.mjs +6 -6
  13. package/src/autoscript/impact-engine.mjs +78 -78
  14. package/src/autoscript/runtime.mjs +1017 -1017
  15. package/src/autoscript/schema.mjs +376 -376
  16. package/src/cli.mjs +405 -405
  17. package/src/commands/attach.mjs +141 -141
  18. package/src/commands/autoscript.mjs +1011 -1011
  19. package/src/commands/browser.mjs +1255 -1257
  20. package/src/commands/container.mjs +401 -401
  21. package/src/commands/cookies.mjs +69 -69
  22. package/src/commands/create.mjs +98 -98
  23. package/src/commands/devtools.mjs +349 -349
  24. package/src/commands/events.mjs +152 -152
  25. package/src/commands/highlight-mode.mjs +24 -24
  26. package/src/commands/init.mjs +68 -68
  27. package/src/commands/lifecycle.mjs +275 -275
  28. package/src/commands/mouse.mjs +45 -45
  29. package/src/commands/profile.mjs +46 -46
  30. package/src/commands/record.mjs +115 -115
  31. package/src/commands/system.mjs +14 -14
  32. package/src/commands/window.mjs +123 -123
  33. package/src/container/change-notifier.mjs +362 -362
  34. package/src/container/element-filter.mjs +143 -143
  35. package/src/container/index.mjs +3 -3
  36. package/src/container/runtime-core/checkpoint.mjs +209 -209
  37. package/src/container/runtime-core/index.mjs +21 -21
  38. package/src/container/runtime-core/operations/index.mjs +774 -774
  39. package/src/container/runtime-core/operations/selector-scripts.mjs +277 -277
  40. package/src/container/runtime-core/operations/tab-pool.mjs +746 -746
  41. package/src/container/runtime-core/operations/viewport.mjs +189 -189
  42. package/src/container/runtime-core/search.mjs +190 -190
  43. package/src/container/runtime-core/subscription.mjs +224 -224
  44. package/src/container/runtime-core/utils.mjs +94 -94
  45. package/src/container/runtime-core/validation.mjs +127 -184
  46. package/src/container/runtime-core.mjs +1 -1
  47. package/src/container/subscription-registry.mjs +459 -459
  48. package/src/core/actions.mjs +561 -561
  49. package/src/core/browser.mjs +266 -266
  50. package/src/core/index.mjs +52 -52
  51. package/src/core/utils.mjs +91 -91
  52. package/src/events/daemon-entry.mjs +33 -33
  53. package/src/events/daemon.mjs +80 -80
  54. package/src/events/progress-log.mjs +109 -109
  55. package/src/events/ws-server.mjs +239 -239
  56. package/src/lib/client.mjs +200 -200
  57. package/src/lifecycle/cleanup.mjs +83 -83
  58. package/src/lifecycle/lock.mjs +126 -126
  59. package/src/lifecycle/session-registry.mjs +279 -279
  60. package/src/lifecycle/session-view.mjs +76 -76
  61. package/src/lifecycle/session-watchdog.mjs +281 -281
  62. package/src/services/browser-service/index.js +671 -674
  63. package/src/services/browser-service/internal/BrowserSession.input.test.js +389 -389
  64. package/src/services/browser-service/internal/BrowserSession.js +325 -336
  65. package/src/services/browser-service/internal/ElementRegistry.js +60 -60
  66. package/src/services/browser-service/internal/ProfileLock.js +84 -84
  67. package/src/services/browser-service/internal/SessionManager.js +184 -184
  68. package/src/services/browser-service/internal/SessionManager.test.js +39 -39
  69. package/src/services/browser-service/internal/browser-session/cookies.js +144 -144
  70. package/src/services/browser-service/internal/browser-session/input-ops.js +222 -219
  71. package/src/services/browser-service/internal/browser-session/input-pipeline.js +144 -144
  72. package/src/services/browser-service/internal/browser-session/logging.js +46 -46
  73. package/src/services/browser-service/internal/browser-session/navigation.js +38 -38
  74. package/src/services/browser-service/internal/browser-session/page-hooks.js +442 -442
  75. package/src/services/browser-service/internal/browser-session/page-management.js +302 -336
  76. package/src/services/browser-service/internal/browser-session/page-management.test.js +148 -148
  77. package/src/services/browser-service/internal/browser-session/recording.js +198 -198
  78. package/src/services/browser-service/internal/browser-session/runtime-events.js +61 -61
  79. package/src/services/browser-service/internal/browser-session/session-core.js +84 -84
  80. package/src/services/browser-service/internal/browser-session/session-state.js +38 -38
  81. package/src/services/browser-service/internal/browser-session/types.js +14 -14
  82. package/src/services/browser-service/internal/browser-session/utils.js +95 -95
  83. package/src/services/browser-service/internal/browser-session/viewport-manager.js +46 -46
  84. package/src/services/browser-service/internal/browser-session/viewport.js +215 -215
  85. package/src/services/browser-service/internal/container-matcher.js +851 -851
  86. package/src/services/browser-service/internal/container-registry.js +182 -182
  87. package/src/services/browser-service/internal/engine-manager.js +259 -259
  88. package/src/services/browser-service/internal/fingerprint.js +203 -203
  89. package/src/services/browser-service/internal/heartbeat.js +137 -137
  90. package/src/services/browser-service/internal/logging.js +46 -46
  91. package/src/services/browser-service/internal/page-runtime/runtime.js +1317 -1317
  92. package/src/services/browser-service/internal/pageRuntime.js +28 -28
  93. package/src/services/browser-service/internal/runtimeInjector.js +31 -31
  94. package/src/services/browser-service/internal/service-process-logger.js +140 -140
  95. package/src/services/browser-service/internal/state-bus.js +45 -45
  96. package/src/services/browser-service/internal/storage-paths.js +42 -42
  97. package/src/services/browser-service/internal/ws-server.js +1194 -1194
  98. package/src/services/browser-service/internal/ws-server.test.js +58 -58
  99. package/src/services/browser-service/server.mjs +6 -6
  100. package/src/services/controller/cli-bridge.js +93 -93
  101. package/src/services/controller/container-index.js +50 -50
  102. package/src/services/controller/container-storage.js +36 -36
  103. package/src/services/controller/controller-actions.js +207 -207
  104. package/src/services/controller/controller.js +1138 -1138
  105. package/src/services/controller/selectors.js +54 -54
  106. package/src/services/controller/transport.js +125 -125
  107. package/src/utils/args.mjs +26 -26
  108. package/src/utils/browser-service.mjs +544 -544
  109. package/src/utils/command-log.mjs +64 -64
  110. package/src/utils/config.mjs +214 -214
  111. package/src/utils/fingerprint.mjs +181 -181
  112. package/src/utils/help.mjs +216 -216
  113. package/src/utils/js-policy.mjs +13 -13
  114. package/src/utils/ws-client.mjs +30 -30
  115. package/src/container/runtime-core/operations/tab-pool.mjs.bak +0 -762
  116. package/src/container/runtime-core/operations/tab-pool.mjs.syntax-error +0 -762
  117. package/src/services/browser-service/index.js.bak +0 -671
@@ -1,181 +1,181 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import os from 'node:os';
4
- import https from 'node:https';
5
- import { execSync } from 'node:child_process';
6
- import { CONFIG_DIR, ensureDir } from './config.mjs';
7
-
8
- const GEOIP_DIR = path.join(CONFIG_DIR, 'geoip');
9
- const GEOIP_MMDB = path.join(GEOIP_DIR, 'GeoLite2-City.mmdb');
10
-
11
- // GeoIP regions mapping
12
- export const GEOIP_REGIONS = {
13
- 'us': { country: 'United States', timezone: 'America/New_York', locale: 'en-US', city: 'New York' },
14
- 'us-west': { country: 'United States', timezone: 'America/Los_Angeles', locale: 'en-US', city: 'Los Angeles' },
15
- 'uk': { country: 'United Kingdom', timezone: 'Europe/London', locale: 'en-GB', city: 'London' },
16
- 'de': { country: 'Germany', timezone: 'Europe/Berlin', locale: 'de-DE', city: 'Berlin' },
17
- 'fr': { country: 'France', timezone: 'Europe/Paris', locale: 'fr-FR', city: 'Paris' },
18
- 'jp': { country: 'Japan', timezone: 'Asia/Tokyo', locale: 'ja-JP', city: 'Tokyo' },
19
- 'sg': { country: 'Singapore', timezone: 'Asia/Singapore', locale: 'en-SG', city: 'Singapore' },
20
- 'au': { country: 'Australia', timezone: 'Australia/Sydney', locale: 'en-AU', city: 'Sydney' },
21
- 'br': { country: 'Brazil', timezone: 'America/Sao_Paulo', locale: 'pt-BR', city: 'Sao Paulo' },
22
- 'in': { country: 'India', timezone: 'Asia/Kolkata', locale: 'en-IN', city: 'Mumbai' },
23
- 'hk': { country: 'Hong Kong', timezone: 'Asia/Hong_Kong', locale: 'zh-HK', city: 'Hong Kong' },
24
- 'tw': { country: 'Taiwan', timezone: 'Asia/Taipei', locale: 'zh-TW', city: 'Taipei' },
25
- };
26
-
27
- // OS options for fingerprint
28
- export const OS_OPTIONS = {
29
- 'mac': { platform: 'darwin', os: 'Macintosh', osVersion: '14.0', cpuCores: 8, memory: 16 },
30
- 'mac-m1': { platform: 'darwin', os: 'Macintosh', osVersion: '14.0', cpuCores: 8, memory: 16, arch: 'arm64' },
31
- 'mac-intel': { platform: 'darwin', os: 'Macintosh', osVersion: '14.0', cpuCores: 8, memory: 16, arch: 'x64' },
32
- 'windows': { platform: 'win32', os: 'Windows', osVersion: '11', cpuCores: 8, memory: 16 },
33
- 'windows-10': { platform: 'win32', os: 'Windows', osVersion: '10', cpuCores: 4, memory: 8 },
34
- 'linux': { platform: 'linux', os: 'Linux', osVersion: 'Ubuntu 22.04', cpuCores: 4, memory: 8 },
35
- };
36
-
37
- export function hasGeoIP() {
38
- return fs.existsSync(GEOIP_MMDB);
39
- }
40
-
41
- export function getGeoIPPath() {
42
- return GEOIP_MMDB;
43
- }
44
-
45
- export async function downloadGeoIP(progressCb = console.log) {
46
- ensureDir(GEOIP_DIR);
47
-
48
- if (hasGeoIP()) {
49
- progressCb('GeoIP database already exists.');
50
- return GEOIP_MMDB;
51
- }
52
-
53
- progressCb('Downloading GeoLite2-City database...');
54
-
55
- // Use MaxMind's public GeoLite2 database
56
- const url = 'https://git.io/GeoLite2-City.mmdb';
57
-
58
- return new Promise((resolve, reject) => {
59
- const file = fs.createWriteStream(GEOIP_MMDB + '.tmp');
60
-
61
- https.get(url, (response) => {
62
- if (response.statusCode === 302 || response.statusCode === 301) {
63
- // Follow redirect
64
- const locUrl = response.headers.location;
65
- https.get(locUrl, (resp) => {
66
- const total = parseInt(resp.headers['content-length'], 10);
67
- let downloaded = 0;
68
-
69
- resp.on('data', (chunk) => {
70
- downloaded += chunk.length;
71
- if (total) {
72
- const pct = Math.floor((downloaded / total) * 100);
73
- if (pct % 10 === 0) {
74
- progressCb(`Downloading GeoIP: ${pct}%`);
75
- }
76
- }
77
- });
78
-
79
- resp.pipe(file);
80
- file.on('finish', () => {
81
- file.close();
82
- fs.renameSync(GEOIP_MMDB + '.tmp', GEOIP_MMDB);
83
- progressCb('GeoIP database downloaded successfully.');
84
- resolve(GEOIP_MMDB);
85
- });
86
- }).on('error', (err) => {
87
- fs.unlinkSync(GEOIP_MMDB + '.tmp');
88
- reject(new Error(`Failed to download GeoIP: ${err.message}`));
89
- });
90
- } else {
91
- response.pipe(file);
92
- file.on('finish', () => {
93
- file.close();
94
- fs.renameSync(GEOIP_MMDB + '.tmp', GEOIP_MMDB);
95
- progressCb('GeoIP database downloaded successfully.');
96
- resolve(GEOIP_MMDB);
97
- });
98
- }
99
- }).on('error', (err) => {
100
- fs.unlinkSync(GEOIP_MMDB + '.tmp');
101
- reject(new Error(`Failed to download GeoIP: ${err.message}`));
102
- });
103
- });
104
- }
105
-
106
- export function generateFingerprint(options = {}) {
107
- const osKey = options.os || 'mac';
108
- const regionKey = options.region || 'us';
109
-
110
- const osConfig = OS_OPTIONS[osKey] || OS_OPTIONS['mac'];
111
- const regionConfig = GEOIP_REGIONS[regionKey] || GEOIP_REGIONS['us'];
112
-
113
- const screenResolutions = [
114
- { width: 1920, height: 1080 },
115
- { width: 2560, height: 1440 },
116
- { width: 1440, height: 900 },
117
- { width: 1366, height: 768 },
118
- { width: 1536, height: 864 },
119
- ];
120
-
121
- const webGLRenderers = {
122
- 'mac': ['Apple M1', 'Apple M2', 'Intel Iris Plus Graphics'],
123
- 'mac-m1': ['Apple M1', 'Apple M2'],
124
- 'mac-intel': ['Intel Iris Plus Graphics', 'Intel UHD Graphics 630'],
125
- 'windows': ['NVIDIA GeForce RTX 3080', 'NVIDIA GeForce RTX 3070', 'AMD Radeon RX 6800'],
126
- 'windows-10': ['NVIDIA GeForce GTX 1660', 'AMD Radeon RX 580'],
127
- 'linux': ['NVIDIA GeForce RTX 3060', 'AMD Radeon RX 6600', 'Mesa Intel Graphics'],
128
- };
129
-
130
- const screen = screenResolutions[Math.floor(Math.random() * screenResolutions.length)];
131
- const webglRenderer = (webGLRenderers[osKey] || webGLRenderers['mac'])[Math.floor(Math.random() * (webGLRenderers[osKey] || webGLRenderers['mac']).length)];
132
-
133
- return {
134
- os: osConfig.os,
135
- osVersion: osConfig.osVersion,
136
- platform: osConfig.platform,
137
- arch: osConfig.arch || (osConfig.platform === 'darwin' ? 'arm64' : 'x64'),
138
- cpuCores: osConfig.cpuCores,
139
- memory: osConfig.memory,
140
- timezone: regionConfig.timezone,
141
- locale: regionConfig.locale,
142
- country: regionConfig.country,
143
- city: regionConfig.city,
144
- screen,
145
- webgl: {
146
- vendor: 'Google Inc. (Apple)',
147
- renderer: webglRenderer,
148
- },
149
- userAgent: buildUserAgent(osConfig, regionConfig),
150
- };
151
- }
152
-
153
- function buildUserAgent(osConfig, regionConfig) {
154
- const chromeVersion = '120.0.0.0';
155
-
156
- if (osConfig.platform === 'darwin') {
157
- return `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${chromeVersion} Safari/537.36`;
158
- } else if (osConfig.platform === 'win32') {
159
- return `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${chromeVersion} Safari/537.36`;
160
- } else {
161
- return `Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${chromeVersion} Safari/537.36`;
162
- }
163
- }
164
-
165
- export function listAvailableRegions() {
166
- return Object.entries(GEOIP_REGIONS).map(([key, config]) => ({
167
- key,
168
- country: config.country,
169
- city: config.city,
170
- timezone: config.timezone,
171
- }));
172
- }
173
-
174
- export function listAvailableOS() {
175
- return Object.entries(OS_OPTIONS).map(([key, config]) => ({
176
- key,
177
- os: config.os,
178
- osVersion: config.osVersion,
179
- platform: config.platform,
180
- }));
181
- }
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import os from 'node:os';
4
+ import https from 'node:https';
5
+ import { execSync } from 'node:child_process';
6
+ import { CONFIG_DIR, ensureDir } from './config.mjs';
7
+
8
+ const GEOIP_DIR = path.join(CONFIG_DIR, 'geoip');
9
+ const GEOIP_MMDB = path.join(GEOIP_DIR, 'GeoLite2-City.mmdb');
10
+
11
+ // GeoIP regions mapping
12
+ export const GEOIP_REGIONS = {
13
+ 'us': { country: 'United States', timezone: 'America/New_York', locale: 'en-US', city: 'New York' },
14
+ 'us-west': { country: 'United States', timezone: 'America/Los_Angeles', locale: 'en-US', city: 'Los Angeles' },
15
+ 'uk': { country: 'United Kingdom', timezone: 'Europe/London', locale: 'en-GB', city: 'London' },
16
+ 'de': { country: 'Germany', timezone: 'Europe/Berlin', locale: 'de-DE', city: 'Berlin' },
17
+ 'fr': { country: 'France', timezone: 'Europe/Paris', locale: 'fr-FR', city: 'Paris' },
18
+ 'jp': { country: 'Japan', timezone: 'Asia/Tokyo', locale: 'ja-JP', city: 'Tokyo' },
19
+ 'sg': { country: 'Singapore', timezone: 'Asia/Singapore', locale: 'en-SG', city: 'Singapore' },
20
+ 'au': { country: 'Australia', timezone: 'Australia/Sydney', locale: 'en-AU', city: 'Sydney' },
21
+ 'br': { country: 'Brazil', timezone: 'America/Sao_Paulo', locale: 'pt-BR', city: 'Sao Paulo' },
22
+ 'in': { country: 'India', timezone: 'Asia/Kolkata', locale: 'en-IN', city: 'Mumbai' },
23
+ 'hk': { country: 'Hong Kong', timezone: 'Asia/Hong_Kong', locale: 'zh-HK', city: 'Hong Kong' },
24
+ 'tw': { country: 'Taiwan', timezone: 'Asia/Taipei', locale: 'zh-TW', city: 'Taipei' },
25
+ };
26
+
27
+ // OS options for fingerprint
28
+ export const OS_OPTIONS = {
29
+ 'mac': { platform: 'darwin', os: 'Macintosh', osVersion: '14.0', cpuCores: 8, memory: 16 },
30
+ 'mac-m1': { platform: 'darwin', os: 'Macintosh', osVersion: '14.0', cpuCores: 8, memory: 16, arch: 'arm64' },
31
+ 'mac-intel': { platform: 'darwin', os: 'Macintosh', osVersion: '14.0', cpuCores: 8, memory: 16, arch: 'x64' },
32
+ 'windows': { platform: 'win32', os: 'Windows', osVersion: '11', cpuCores: 8, memory: 16 },
33
+ 'windows-10': { platform: 'win32', os: 'Windows', osVersion: '10', cpuCores: 4, memory: 8 },
34
+ 'linux': { platform: 'linux', os: 'Linux', osVersion: 'Ubuntu 22.04', cpuCores: 4, memory: 8 },
35
+ };
36
+
37
+ export function hasGeoIP() {
38
+ return fs.existsSync(GEOIP_MMDB);
39
+ }
40
+
41
+ export function getGeoIPPath() {
42
+ return GEOIP_MMDB;
43
+ }
44
+
45
+ export async function downloadGeoIP(progressCb = console.log) {
46
+ ensureDir(GEOIP_DIR);
47
+
48
+ if (hasGeoIP()) {
49
+ progressCb('GeoIP database already exists.');
50
+ return GEOIP_MMDB;
51
+ }
52
+
53
+ progressCb('Downloading GeoLite2-City database...');
54
+
55
+ // Use MaxMind's public GeoLite2 database
56
+ const url = 'https://git.io/GeoLite2-City.mmdb';
57
+
58
+ return new Promise((resolve, reject) => {
59
+ const file = fs.createWriteStream(GEOIP_MMDB + '.tmp');
60
+
61
+ https.get(url, (response) => {
62
+ if (response.statusCode === 302 || response.statusCode === 301) {
63
+ // Follow redirect
64
+ const locUrl = response.headers.location;
65
+ https.get(locUrl, (resp) => {
66
+ const total = parseInt(resp.headers['content-length'], 10);
67
+ let downloaded = 0;
68
+
69
+ resp.on('data', (chunk) => {
70
+ downloaded += chunk.length;
71
+ if (total) {
72
+ const pct = Math.floor((downloaded / total) * 100);
73
+ if (pct % 10 === 0) {
74
+ progressCb(`Downloading GeoIP: ${pct}%`);
75
+ }
76
+ }
77
+ });
78
+
79
+ resp.pipe(file);
80
+ file.on('finish', () => {
81
+ file.close();
82
+ fs.renameSync(GEOIP_MMDB + '.tmp', GEOIP_MMDB);
83
+ progressCb('GeoIP database downloaded successfully.');
84
+ resolve(GEOIP_MMDB);
85
+ });
86
+ }).on('error', (err) => {
87
+ fs.unlinkSync(GEOIP_MMDB + '.tmp');
88
+ reject(new Error(`Failed to download GeoIP: ${err.message}`));
89
+ });
90
+ } else {
91
+ response.pipe(file);
92
+ file.on('finish', () => {
93
+ file.close();
94
+ fs.renameSync(GEOIP_MMDB + '.tmp', GEOIP_MMDB);
95
+ progressCb('GeoIP database downloaded successfully.');
96
+ resolve(GEOIP_MMDB);
97
+ });
98
+ }
99
+ }).on('error', (err) => {
100
+ fs.unlinkSync(GEOIP_MMDB + '.tmp');
101
+ reject(new Error(`Failed to download GeoIP: ${err.message}`));
102
+ });
103
+ });
104
+ }
105
+
106
+ export function generateFingerprint(options = {}) {
107
+ const osKey = options.os || 'mac';
108
+ const regionKey = options.region || 'us';
109
+
110
+ const osConfig = OS_OPTIONS[osKey] || OS_OPTIONS['mac'];
111
+ const regionConfig = GEOIP_REGIONS[regionKey] || GEOIP_REGIONS['us'];
112
+
113
+ const screenResolutions = [
114
+ { width: 1920, height: 1080 },
115
+ { width: 2560, height: 1440 },
116
+ { width: 1440, height: 900 },
117
+ { width: 1366, height: 768 },
118
+ { width: 1536, height: 864 },
119
+ ];
120
+
121
+ const webGLRenderers = {
122
+ 'mac': ['Apple M1', 'Apple M2', 'Intel Iris Plus Graphics'],
123
+ 'mac-m1': ['Apple M1', 'Apple M2'],
124
+ 'mac-intel': ['Intel Iris Plus Graphics', 'Intel UHD Graphics 630'],
125
+ 'windows': ['NVIDIA GeForce RTX 3080', 'NVIDIA GeForce RTX 3070', 'AMD Radeon RX 6800'],
126
+ 'windows-10': ['NVIDIA GeForce GTX 1660', 'AMD Radeon RX 580'],
127
+ 'linux': ['NVIDIA GeForce RTX 3060', 'AMD Radeon RX 6600', 'Mesa Intel Graphics'],
128
+ };
129
+
130
+ const screen = screenResolutions[Math.floor(Math.random() * screenResolutions.length)];
131
+ const webglRenderer = (webGLRenderers[osKey] || webGLRenderers['mac'])[Math.floor(Math.random() * (webGLRenderers[osKey] || webGLRenderers['mac']).length)];
132
+
133
+ return {
134
+ os: osConfig.os,
135
+ osVersion: osConfig.osVersion,
136
+ platform: osConfig.platform,
137
+ arch: osConfig.arch || (osConfig.platform === 'darwin' ? 'arm64' : 'x64'),
138
+ cpuCores: osConfig.cpuCores,
139
+ memory: osConfig.memory,
140
+ timezone: regionConfig.timezone,
141
+ locale: regionConfig.locale,
142
+ country: regionConfig.country,
143
+ city: regionConfig.city,
144
+ screen,
145
+ webgl: {
146
+ vendor: 'Google Inc. (Apple)',
147
+ renderer: webglRenderer,
148
+ },
149
+ userAgent: buildUserAgent(osConfig, regionConfig),
150
+ };
151
+ }
152
+
153
+ function buildUserAgent(osConfig, regionConfig) {
154
+ const chromeVersion = '120.0.0.0';
155
+
156
+ if (osConfig.platform === 'darwin') {
157
+ return `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${chromeVersion} Safari/537.36`;
158
+ } else if (osConfig.platform === 'win32') {
159
+ return `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${chromeVersion} Safari/537.36`;
160
+ } else {
161
+ return `Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${chromeVersion} Safari/537.36`;
162
+ }
163
+ }
164
+
165
+ export function listAvailableRegions() {
166
+ return Object.entries(GEOIP_REGIONS).map(([key, config]) => ({
167
+ key,
168
+ country: config.country,
169
+ city: config.city,
170
+ timezone: config.timezone,
171
+ }));
172
+ }
173
+
174
+ export function listAvailableOS() {
175
+ return Object.entries(OS_OPTIONS).map(([key, config]) => ({
176
+ key,
177
+ os: config.os,
178
+ osVersion: config.osVersion,
179
+ platform: config.platform,
180
+ }));
181
+ }