@xkwdstore/agent 2.1.5 → 2.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.
- package/CHANGELOG.md +163 -130
- package/README.md +281 -280
- package/package.json +43 -43
- package/scripts/install-machine-agent.ps1 +385 -385
- package/src/brokerConnectionSupervisor.js +319 -319
- package/src/brokerHealth.js +113 -113
- package/src/brokerWorkerBridge.js +377 -377
- package/src/browserConnectivity.js +1461 -1461
- package/src/browserIsolation.js +26 -1
- package/src/browserLaunch.js +136 -136
- package/src/cli.js +1290 -1290
- package/src/cookieInjection.js +255 -255
- package/src/index.js +7 -0
- package/src/proxyCapability.js +481 -481
- package/src/sessionAuth.js +439 -439
- package/src/sessionHandler.js +3 -0
- package/src/worker.js +707 -703
package/src/browserIsolation.js
CHANGED
|
@@ -171,10 +171,25 @@ function proxyRequiredForSession({ proxyStr, networkMode } = {}) {
|
|
|
171
171
|
* the DNS pin. Supplied even when the server is passed out-of-band via the
|
|
172
172
|
* Playwright proxy option, so the DNS pin is always present for a proxied
|
|
173
173
|
* session.
|
|
174
|
+
* @param {boolean} [opts.proxyAuthenticated] — the proxy requires credentials
|
|
175
|
+
* (Basic/407). Chromium's HTTP/2 over an AUTHENTICATED HTTP CONNECT proxy
|
|
176
|
+
* never completes a document request against Google's properties: the CONNECT
|
|
177
|
+
* succeeds, TLS 1.3 + ALPN h2 negotiate and the certificate validates, then the
|
|
178
|
+
* main-frame stream is opened and no HEADERS/DATA ever arrives, so the tab sits
|
|
179
|
+
* on `about:blank` until the caller's timeout. Reproduced on every production
|
|
180
|
+
* proxy tested, on system Chrome AND Playwright's bundled Chromium, with
|
|
181
|
+
* `--disable-quic`, EncryptedClientHello/Alps disabled, and after a warm 407
|
|
182
|
+
* challenge — while the same proxy carries a complete Google h2 response
|
|
183
|
+
* (status 200, 91 KB) to a Node http2 client. HTTP/1.1 through the same
|
|
184
|
+
* authenticated proxy loads every Google endpoint in ~1.5 s. This is a
|
|
185
|
+
* transport-negotiation defect, not a security control: pinning HTTP/1.1 for
|
|
186
|
+
* the authenticated-proxy case only keeps TLS verification, certificate
|
|
187
|
+
* pinning, DNS pinning, QUIC/WebRTC suppression and proxy routing intact. h2
|
|
188
|
+
* is preserved for direct sessions and for proxies that need no credentials.
|
|
174
189
|
* @param {string[]} [opts.baseArgs]
|
|
175
190
|
* @returns {string[]} the full sanitized arg list
|
|
176
191
|
*/
|
|
177
|
-
function buildLaunchArgs({ requireProxy, proxyServerUrl, proxyHostForDns, baseArgs } = {}) {
|
|
192
|
+
function buildLaunchArgs({ requireProxy, proxyServerUrl, proxyHostForDns, proxyAuthenticated, baseArgs } = {}) {
|
|
178
193
|
const args = Array.isArray(baseArgs) ? baseArgs.slice() : [
|
|
179
194
|
'--force-webrtc-ip-handling-policy=disable_non_proxied_udp',
|
|
180
195
|
'--no-first-run',
|
|
@@ -199,6 +214,16 @@ function buildLaunchArgs({ requireProxy, proxyServerUrl, proxyHostForDns, baseAr
|
|
|
199
214
|
// QUIC is disabled per-launch for a proxy-required session.
|
|
200
215
|
args.push('--disable-quic');
|
|
201
216
|
args.push('--force-webrtc-ip-handling-policy=disable_non_proxied_udp');
|
|
217
|
+
// HTTP/2 through an AUTHENTICATED HTTP CONNECT proxy stalls on Google's
|
|
218
|
+
// properties (see the JSDoc above): the tunnel and TLS succeed, then the
|
|
219
|
+
// main-frame h2 stream never returns HEADERS. Pin HTTP/1.1 for exactly this
|
|
220
|
+
// case. This changes no security control — TLS/cert validation, certificate
|
|
221
|
+
// pinning, DNS pinning, QUIC/WebRTC suppression and proxy routing are all
|
|
222
|
+
// unchanged — and h2 stays available for direct sessions and for proxies
|
|
223
|
+
// that accept CONNECT without credentials.
|
|
224
|
+
if (proxyAuthenticated === true) {
|
|
225
|
+
args.push('--disable-http2');
|
|
226
|
+
}
|
|
202
227
|
}
|
|
203
228
|
return sanitizeLaunchArgs(args, { enforce: true });
|
|
204
229
|
}
|
package/src/browserLaunch.js
CHANGED
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The ONE shared Chromium launch-options builder (2.1.5).
|
|
5
|
-
*
|
|
6
|
-
* Every runtime (machine worker, broker/direct session handler, legacy CLI)
|
|
7
|
-
* must launch the browser through this function so a browser configuration
|
|
8
|
-
* change applies consistently to existing AND newly created profiles:
|
|
9
|
-
*
|
|
10
|
-
* - `resolveChromiumPath()` still chooses the executable (system Chrome first,
|
|
11
|
-
* Playwright's bundled Chromium as fallback) — profiles are untouched.
|
|
12
|
-
* - Playwright silently injects `--disable-extensions` into every launch. For a
|
|
13
|
-
* Google Chrome / Edge executable we drop ONLY that default switch, so the
|
|
14
|
-
* extension subsystem (and the Chrome Web Store) stays available. This does
|
|
15
|
-
* NOT enable unpacked extension loading: branded Google Chrome (verified on
|
|
16
|
-
* 157.0.8103.80) logs
|
|
17
|
-
* "`--load-extension` is not allowed in Google Chrome, ignoring."
|
|
18
|
-
* "`--disable-extensions-except` is not allowed in Google Chrome, ignoring."
|
|
19
|
-
* so unbundled extensions only load on a Chromium/Chrome-for-Testing build.
|
|
20
|
-
* `describeBrowser()` reports that capability explicitly so no feature
|
|
21
|
-
* depends on a silent assumption.
|
|
22
|
-
* - NetLog capture is opt-in (`XKWDSTORE_NETLOG_DIR`) and never written into
|
|
23
|
-
* a profile directory; capture files are sanitized before an operator sees
|
|
24
|
-
* them (see browserConnectivity.sanitizeNetlogFile).
|
|
25
|
-
*
|
|
26
|
-
* This module deliberately contains no secrets and performs no I/O.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
const path = require('path');
|
|
30
|
-
const connectivity = require('./browserConnectivity');
|
|
31
|
-
|
|
32
|
-
/** Playwright default switches that must NOT apply to a managed Chrome. */
|
|
33
|
-
const PLAYWRIGHT_DEFAULT_ARGS_TO_DROP = Object.freeze(['--disable-extensions']);
|
|
34
|
-
|
|
35
|
-
const CHROME_EXECUTABLE_BASENAMES = Object.freeze([
|
|
36
|
-
'chrome.exe',
|
|
37
|
-
'msedge.exe',
|
|
38
|
-
'google-chrome',
|
|
39
|
-
'google-chrome-stable',
|
|
40
|
-
'chrome',
|
|
41
|
-
]);
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Classify the browser distribution from its executable path.
|
|
45
|
-
* @returns {'chrome'|'edge'|'chromium'|'unknown'}
|
|
46
|
-
*/
|
|
47
|
-
function browserFamily(executablePath) {
|
|
48
|
-
if (!executablePath || typeof executablePath !== 'string') return 'unknown';
|
|
49
|
-
const base = path.basename(executablePath).toLowerCase();
|
|
50
|
-
const norm = executablePath.replace(/\\/g, '/').toLowerCase();
|
|
51
|
-
if (base === 'chrome.exe' || base === 'chrome' || base === 'google-chrome' || base === 'google-chrome-stable') {
|
|
52
|
-
// A Playwright-managed Chromium build lives under a ms-playwright folder.
|
|
53
|
-
if (/ms-playwright|playwright[\\/]/i.test(norm)) return 'chromium';
|
|
54
|
-
return 'chrome';
|
|
55
|
-
}
|
|
56
|
-
if (base === 'msedge.exe' || base === 'msedge') return 'edge';
|
|
57
|
-
if (/chromium/.test(base)) return 'chromium';
|
|
58
|
-
return 'unknown';
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** True for a distribution that has a working Chrome Web Store. */
|
|
62
|
-
function supportsChromeWebStore(executablePath) {
|
|
63
|
-
const family = browserFamily(executablePath);
|
|
64
|
-
return family === 'chrome' || family === 'edge';
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Build the Playwright launch options for a managed session.
|
|
69
|
-
*
|
|
70
|
-
* @param {object} o
|
|
71
|
-
* @param {string} [o.chromePath] absolute executable path (system Chrome first)
|
|
72
|
-
* @param {boolean} [o.headless=false]
|
|
73
|
-
* @param {string[]} [o.args] already-sanitized Chromium args
|
|
74
|
-
* @param {object|null} [o.proxy] Playwright proxy option ({server,username,password})
|
|
75
|
-
* @param {string|null} [o.netlogPath] explicit NetLog destination
|
|
76
|
-
* @param {boolean} [o.captureNetlog] resolve the NetLog path from the environment
|
|
77
|
-
* @param {object} [o.viewport]
|
|
78
|
-
* @param {boolean} [o.noDefaultViewport=true]
|
|
79
|
-
* @returns {object} options accepted by chromium.launchPersistentContext
|
|
80
|
-
*/
|
|
81
|
-
function buildChromiumLaunchOptions(o = {}) {
|
|
82
|
-
const args = Array.isArray(o.args) ? o.args.slice() : [];
|
|
83
|
-
const options = {
|
|
84
|
-
executablePath: o.chromePath || undefined,
|
|
85
|
-
headless: o.headless === true,
|
|
86
|
-
args,
|
|
87
|
-
noDefaultViewport: o.noDefaultViewport !== false,
|
|
88
|
-
};
|
|
89
|
-
if (o.viewport) {
|
|
90
|
-
options.viewport = o.viewport;
|
|
91
|
-
options.noDefaultViewport = false;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (supportsChromeWebStore(o.chromePath)) {
|
|
95
|
-
options.ignoreDefaultArgs = PLAYWRIGHT_DEFAULT_ARGS_TO_DROP.slice();
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (o.proxy && o.proxy.server) options.proxy = o.proxy;
|
|
99
|
-
|
|
100
|
-
const netlogPath = o.netlogPath || (o.captureNetlog === true ? connectivity.resolveNetlogPath() : null);
|
|
101
|
-
if (netlogPath) {
|
|
102
|
-
args.push(...connectivity.netlogLaunchArgs(netlogPath));
|
|
103
|
-
options.netlogPath = netlogPath;
|
|
104
|
-
}
|
|
105
|
-
return options;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* A sanitized, non-secret description of the browser distribution for reports
|
|
110
|
-
* and `getStatus` responses.
|
|
111
|
-
*/
|
|
112
|
-
function describeBrowser(executablePath) {
|
|
113
|
-
const family = browserFamily(executablePath);
|
|
114
|
-
const branded = family === 'chrome' || family === 'edge';
|
|
115
|
-
return {
|
|
116
|
-
executablePath: executablePath || null,
|
|
117
|
-
family,
|
|
118
|
-
chromeWebStore: supportsChromeWebStore(executablePath),
|
|
119
|
-
extensionSubsystemEnabled: branded,
|
|
120
|
-
// Unpacked (--load-extension) loading: branded Chrome/Edge IGNORE the switch
|
|
121
|
-
// (verified on Chrome 157 and 158: extension_service.cc "not allowed in Google
|
|
122
|
-
// Chrome, ignoring"). Only a Chromium / Chrome-for-Testing build honours it.
|
|
123
|
-
unpackedExtensionLoading: family === 'chromium',
|
|
124
|
-
webStoreInstall: branded ? 'human-confirmation-required' : 'unsupported',
|
|
125
|
-
droppedPlaywrightDefaults: branded ? PLAYWRIGHT_DEFAULT_ARGS_TO_DROP.slice() : [],
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
module.exports = {
|
|
130
|
-
PLAYWRIGHT_DEFAULT_ARGS_TO_DROP,
|
|
131
|
-
CHROME_EXECUTABLE_BASENAMES,
|
|
132
|
-
browserFamily,
|
|
133
|
-
supportsChromeWebStore,
|
|
134
|
-
buildChromiumLaunchOptions,
|
|
135
|
-
describeBrowser,
|
|
136
|
-
};
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The ONE shared Chromium launch-options builder (2.1.5).
|
|
5
|
+
*
|
|
6
|
+
* Every runtime (machine worker, broker/direct session handler, legacy CLI)
|
|
7
|
+
* must launch the browser through this function so a browser configuration
|
|
8
|
+
* change applies consistently to existing AND newly created profiles:
|
|
9
|
+
*
|
|
10
|
+
* - `resolveChromiumPath()` still chooses the executable (system Chrome first,
|
|
11
|
+
* Playwright's bundled Chromium as fallback) — profiles are untouched.
|
|
12
|
+
* - Playwright silently injects `--disable-extensions` into every launch. For a
|
|
13
|
+
* Google Chrome / Edge executable we drop ONLY that default switch, so the
|
|
14
|
+
* extension subsystem (and the Chrome Web Store) stays available. This does
|
|
15
|
+
* NOT enable unpacked extension loading: branded Google Chrome (verified on
|
|
16
|
+
* 157.0.8103.80) logs
|
|
17
|
+
* "`--load-extension` is not allowed in Google Chrome, ignoring."
|
|
18
|
+
* "`--disable-extensions-except` is not allowed in Google Chrome, ignoring."
|
|
19
|
+
* so unbundled extensions only load on a Chromium/Chrome-for-Testing build.
|
|
20
|
+
* `describeBrowser()` reports that capability explicitly so no feature
|
|
21
|
+
* depends on a silent assumption.
|
|
22
|
+
* - NetLog capture is opt-in (`XKWDSTORE_NETLOG_DIR`) and never written into
|
|
23
|
+
* a profile directory; capture files are sanitized before an operator sees
|
|
24
|
+
* them (see browserConnectivity.sanitizeNetlogFile).
|
|
25
|
+
*
|
|
26
|
+
* This module deliberately contains no secrets and performs no I/O.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
const path = require('path');
|
|
30
|
+
const connectivity = require('./browserConnectivity');
|
|
31
|
+
|
|
32
|
+
/** Playwright default switches that must NOT apply to a managed Chrome. */
|
|
33
|
+
const PLAYWRIGHT_DEFAULT_ARGS_TO_DROP = Object.freeze(['--disable-extensions']);
|
|
34
|
+
|
|
35
|
+
const CHROME_EXECUTABLE_BASENAMES = Object.freeze([
|
|
36
|
+
'chrome.exe',
|
|
37
|
+
'msedge.exe',
|
|
38
|
+
'google-chrome',
|
|
39
|
+
'google-chrome-stable',
|
|
40
|
+
'chrome',
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Classify the browser distribution from its executable path.
|
|
45
|
+
* @returns {'chrome'|'edge'|'chromium'|'unknown'}
|
|
46
|
+
*/
|
|
47
|
+
function browserFamily(executablePath) {
|
|
48
|
+
if (!executablePath || typeof executablePath !== 'string') return 'unknown';
|
|
49
|
+
const base = path.basename(executablePath).toLowerCase();
|
|
50
|
+
const norm = executablePath.replace(/\\/g, '/').toLowerCase();
|
|
51
|
+
if (base === 'chrome.exe' || base === 'chrome' || base === 'google-chrome' || base === 'google-chrome-stable') {
|
|
52
|
+
// A Playwright-managed Chromium build lives under a ms-playwright folder.
|
|
53
|
+
if (/ms-playwright|playwright[\\/]/i.test(norm)) return 'chromium';
|
|
54
|
+
return 'chrome';
|
|
55
|
+
}
|
|
56
|
+
if (base === 'msedge.exe' || base === 'msedge') return 'edge';
|
|
57
|
+
if (/chromium/.test(base)) return 'chromium';
|
|
58
|
+
return 'unknown';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** True for a distribution that has a working Chrome Web Store. */
|
|
62
|
+
function supportsChromeWebStore(executablePath) {
|
|
63
|
+
const family = browserFamily(executablePath);
|
|
64
|
+
return family === 'chrome' || family === 'edge';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Build the Playwright launch options for a managed session.
|
|
69
|
+
*
|
|
70
|
+
* @param {object} o
|
|
71
|
+
* @param {string} [o.chromePath] absolute executable path (system Chrome first)
|
|
72
|
+
* @param {boolean} [o.headless=false]
|
|
73
|
+
* @param {string[]} [o.args] already-sanitized Chromium args
|
|
74
|
+
* @param {object|null} [o.proxy] Playwright proxy option ({server,username,password})
|
|
75
|
+
* @param {string|null} [o.netlogPath] explicit NetLog destination
|
|
76
|
+
* @param {boolean} [o.captureNetlog] resolve the NetLog path from the environment
|
|
77
|
+
* @param {object} [o.viewport]
|
|
78
|
+
* @param {boolean} [o.noDefaultViewport=true]
|
|
79
|
+
* @returns {object} options accepted by chromium.launchPersistentContext
|
|
80
|
+
*/
|
|
81
|
+
function buildChromiumLaunchOptions(o = {}) {
|
|
82
|
+
const args = Array.isArray(o.args) ? o.args.slice() : [];
|
|
83
|
+
const options = {
|
|
84
|
+
executablePath: o.chromePath || undefined,
|
|
85
|
+
headless: o.headless === true,
|
|
86
|
+
args,
|
|
87
|
+
noDefaultViewport: o.noDefaultViewport !== false,
|
|
88
|
+
};
|
|
89
|
+
if (o.viewport) {
|
|
90
|
+
options.viewport = o.viewport;
|
|
91
|
+
options.noDefaultViewport = false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (supportsChromeWebStore(o.chromePath)) {
|
|
95
|
+
options.ignoreDefaultArgs = PLAYWRIGHT_DEFAULT_ARGS_TO_DROP.slice();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (o.proxy && o.proxy.server) options.proxy = o.proxy;
|
|
99
|
+
|
|
100
|
+
const netlogPath = o.netlogPath || (o.captureNetlog === true ? connectivity.resolveNetlogPath() : null);
|
|
101
|
+
if (netlogPath) {
|
|
102
|
+
args.push(...connectivity.netlogLaunchArgs(netlogPath));
|
|
103
|
+
options.netlogPath = netlogPath;
|
|
104
|
+
}
|
|
105
|
+
return options;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A sanitized, non-secret description of the browser distribution for reports
|
|
110
|
+
* and `getStatus` responses.
|
|
111
|
+
*/
|
|
112
|
+
function describeBrowser(executablePath) {
|
|
113
|
+
const family = browserFamily(executablePath);
|
|
114
|
+
const branded = family === 'chrome' || family === 'edge';
|
|
115
|
+
return {
|
|
116
|
+
executablePath: executablePath || null,
|
|
117
|
+
family,
|
|
118
|
+
chromeWebStore: supportsChromeWebStore(executablePath),
|
|
119
|
+
extensionSubsystemEnabled: branded,
|
|
120
|
+
// Unpacked (--load-extension) loading: branded Chrome/Edge IGNORE the switch
|
|
121
|
+
// (verified on Chrome 157 and 158: extension_service.cc "not allowed in Google
|
|
122
|
+
// Chrome, ignoring"). Only a Chromium / Chrome-for-Testing build honours it.
|
|
123
|
+
unpackedExtensionLoading: family === 'chromium',
|
|
124
|
+
webStoreInstall: branded ? 'human-confirmation-required' : 'unsupported',
|
|
125
|
+
droppedPlaywrightDefaults: branded ? PLAYWRIGHT_DEFAULT_ARGS_TO_DROP.slice() : [],
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
module.exports = {
|
|
130
|
+
PLAYWRIGHT_DEFAULT_ARGS_TO_DROP,
|
|
131
|
+
CHROME_EXECUTABLE_BASENAMES,
|
|
132
|
+
browserFamily,
|
|
133
|
+
supportsChromeWebStore,
|
|
134
|
+
buildChromiumLaunchOptions,
|
|
135
|
+
describeBrowser,
|
|
136
|
+
};
|