@vforsh/argus-watcher 0.1.8 → 0.1.10
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/README.md +5 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/buffer/NetBuffer.d.ts +35 -11
- package/dist/buffer/NetBuffer.d.ts.map +1 -1
- package/dist/buffer/NetBuffer.js +64 -55
- package/dist/buffer/NetBuffer.js.map +1 -1
- package/dist/cdp/accessibility.d.ts +12 -1
- package/dist/cdp/accessibility.d.ts.map +1 -1
- package/dist/cdp/accessibility.js +88 -45
- package/dist/cdp/accessibility.js.map +1 -1
- package/dist/cdp/auth.d.ts +31 -1
- package/dist/cdp/auth.d.ts.map +1 -1
- package/dist/cdp/auth.js +299 -10
- package/dist/cdp/auth.js.map +1 -1
- package/dist/cdp/authState.d.ts +9 -0
- package/dist/cdp/authState.d.ts.map +1 -0
- package/dist/cdp/authState.js +44 -0
- package/dist/cdp/authState.js.map +1 -0
- package/dist/cdp/browserCookies.d.ts +8 -0
- package/dist/cdp/browserCookies.d.ts.map +1 -0
- package/dist/cdp/browserCookies.js +160 -0
- package/dist/cdp/browserCookies.js.map +1 -0
- package/dist/cdp/dom/fill.d.ts +2 -1
- package/dist/cdp/dom/fill.d.ts.map +1 -1
- package/dist/cdp/dom/fill.js +7 -7
- package/dist/cdp/dom/fill.js.map +1 -1
- package/dist/cdp/dom/info.d.ts +4 -2
- package/dist/cdp/dom/info.d.ts.map +1 -1
- package/dist/cdp/dom/info.js +20 -11
- package/dist/cdp/dom/info.js.map +1 -1
- package/dist/cdp/dom/selector.d.ts +45 -0
- package/dist/cdp/dom/selector.d.ts.map +1 -1
- package/dist/cdp/dom/selector.js +130 -25
- package/dist/cdp/dom/selector.js.map +1 -1
- package/dist/cdp/dom/types.d.ts +1 -0
- package/dist/cdp/dom/types.d.ts.map +1 -1
- package/dist/cdp/editor.d.ts.map +1 -1
- package/dist/cdp/editor.js +55 -3
- package/dist/cdp/editor.js.map +1 -1
- package/dist/cdp/elementRefs.d.ts +15 -0
- package/dist/cdp/elementRefs.d.ts.map +1 -0
- package/dist/cdp/elementRefs.js +30 -0
- package/dist/cdp/elementRefs.js.map +1 -0
- package/dist/cdp/locate.d.ts +7 -0
- package/dist/cdp/locate.d.ts.map +1 -0
- package/dist/cdp/locate.js +68 -0
- package/dist/cdp/locate.js.map +1 -0
- package/dist/cdp/mouse.d.ts +8 -7
- package/dist/cdp/mouse.d.ts.map +1 -1
- package/dist/cdp/mouse.js +42 -49
- package/dist/cdp/mouse.js.map +1 -1
- package/dist/cdp/networkBody.d.ts +19 -0
- package/dist/cdp/networkBody.d.ts.map +1 -0
- package/dist/cdp/networkBody.js +70 -0
- package/dist/cdp/networkBody.js.map +1 -0
- package/dist/cdp/networkCapture.d.ts +4 -0
- package/dist/cdp/networkCapture.d.ts.map +1 -1
- package/dist/cdp/networkCapture.js +307 -35
- package/dist/cdp/networkCapture.js.map +1 -1
- package/dist/cdp/pageIndicator.d.ts +1 -1
- package/dist/cdp/pageIndicator.d.ts.map +1 -1
- package/dist/cdp/redaction.d.ts +4 -0
- package/dist/cdp/redaction.d.ts.map +1 -1
- package/dist/cdp/redaction.js +37 -1
- package/dist/cdp/redaction.js.map +1 -1
- package/dist/cdp/screenshot.d.ts +1 -0
- package/dist/cdp/screenshot.d.ts.map +1 -1
- package/dist/cdp/screenshot.js +66 -15
- package/dist/cdp/screenshot.js.map +1 -1
- package/dist/cdp/storage.d.ts +8 -0
- package/dist/cdp/storage.d.ts.map +1 -0
- package/dist/cdp/storage.js +70 -0
- package/dist/cdp/storage.js.map +1 -0
- package/dist/cdp/watcher.d.ts +4 -21
- package/dist/cdp/watcher.d.ts.map +1 -1
- package/dist/cdp/watcher.js +7 -279
- package/dist/cdp/watcher.js.map +1 -1
- package/dist/cdp/watcherEvents.d.ts +18 -0
- package/dist/cdp/watcherEvents.d.ts.map +1 -0
- package/dist/cdp/watcherEvents.js +169 -0
- package/dist/cdp/watcherEvents.js.map +1 -0
- package/dist/cdp/watcherTargets.d.ts +18 -0
- package/dist/cdp/watcherTargets.d.ts.map +1 -0
- package/dist/cdp/watcherTargets.js +95 -0
- package/dist/cdp/watcherTargets.js.map +1 -0
- package/dist/dialogs/DialogTracker.d.ts +13 -0
- package/dist/dialogs/DialogTracker.d.ts.map +1 -0
- package/dist/dialogs/DialogTracker.js +22 -0
- package/dist/dialogs/DialogTracker.js.map +1 -0
- package/dist/events.d.ts +7 -2
- package/dist/events.d.ts.map +1 -1
- package/dist/http/router.d.ts.map +1 -1
- package/dist/http/router.js +3 -77
- package/dist/http/router.js.map +1 -1
- package/dist/http/routes/authCookies.d.ts +11 -0
- package/dist/http/routes/authCookies.d.ts.map +1 -0
- package/dist/http/routes/authCookies.js +142 -0
- package/dist/http/routes/authCookies.js.map +1 -0
- package/dist/http/routes/domSelectorRoute.d.ts +8 -0
- package/dist/http/routes/domSelectorRoute.d.ts.map +1 -1
- package/dist/http/routes/domSelectorRoute.js +28 -3
- package/dist/http/routes/domSelectorRoute.js.map +1 -1
- package/dist/http/routes/getAuthState.d.ts +3 -0
- package/dist/http/routes/getAuthState.d.ts.map +1 -0
- package/dist/http/routes/getAuthState.js +24 -0
- package/dist/http/routes/getAuthState.js.map +1 -0
- package/dist/http/routes/getDialog.d.ts +3 -0
- package/dist/http/routes/getDialog.d.ts.map +1 -0
- package/dist/http/routes/getDialog.js +11 -0
- package/dist/http/routes/getDialog.js.map +1 -0
- package/dist/http/routes/getNet.d.ts.map +1 -1
- package/dist/http/routes/getNet.js +14 -8
- package/dist/http/routes/getNet.js.map +1 -1
- package/dist/http/routes/getNetRequest.d.ts +3 -0
- package/dist/http/routes/getNetRequest.d.ts.map +1 -0
- package/dist/http/routes/getNetRequest.js +23 -0
- package/dist/http/routes/getNetRequest.js.map +1 -0
- package/dist/http/routes/getNetRequestBody.d.ts +3 -0
- package/dist/http/routes/getNetRequestBody.d.ts.map +1 -0
- package/dist/http/routes/getNetRequestBody.js +80 -0
- package/dist/http/routes/getNetRequestBody.js.map +1 -0
- package/dist/http/routes/getNetRequests.d.ts +3 -0
- package/dist/http/routes/getNetRequests.d.ts.map +1 -0
- package/dist/http/routes/getNetRequests.js +23 -0
- package/dist/http/routes/getNetRequests.js.map +1 -0
- package/dist/http/routes/getNetTail.d.ts.map +1 -1
- package/dist/http/routes/getNetTail.js +44 -9
- package/dist/http/routes/getNetTail.js.map +1 -1
- package/dist/http/routes/getStatus.js +1 -0
- package/dist/http/routes/getStatus.js.map +1 -1
- package/dist/http/routes/index.d.ts +9 -0
- package/dist/http/routes/index.d.ts.map +1 -0
- package/dist/http/routes/index.js +105 -0
- package/dist/http/routes/index.js.map +1 -0
- package/dist/http/routes/netFilters.d.ts +29 -0
- package/dist/http/routes/netFilters.d.ts.map +1 -0
- package/dist/http/routes/netFilters.js +160 -0
- package/dist/http/routes/netFilters.js.map +1 -0
- package/dist/http/routes/netRequestLookup.d.ts +14 -0
- package/dist/http/routes/netRequestLookup.d.ts.map +1 -0
- package/dist/http/routes/netRequestLookup.js +39 -0
- package/dist/http/routes/netRequestLookup.js.map +1 -0
- package/dist/http/routes/postAuthStateLoad.d.ts +3 -0
- package/dist/http/routes/postAuthStateLoad.d.ts.map +1 -0
- package/dist/http/routes/postAuthStateLoad.js +37 -0
- package/dist/http/routes/postAuthStateLoad.js.map +1 -0
- package/dist/http/routes/postDialog.d.ts +3 -0
- package/dist/http/routes/postDialog.d.ts.map +1 -0
- package/dist/http/routes/postDialog.js +39 -0
- package/dist/http/routes/postDialog.js.map +1 -0
- package/dist/http/routes/postDomClick.d.ts.map +1 -1
- package/dist/http/routes/postDomClick.js +39 -27
- package/dist/http/routes/postDomClick.js.map +1 -1
- package/dist/http/routes/postDomFill.d.ts.map +1 -1
- package/dist/http/routes/postDomFill.js +23 -27
- package/dist/http/routes/postDomFill.js.map +1 -1
- package/dist/http/routes/postDomFocus.d.ts.map +1 -1
- package/dist/http/routes/postDomFocus.js +22 -9
- package/dist/http/routes/postDomFocus.js.map +1 -1
- package/dist/http/routes/postDomHover.d.ts.map +1 -1
- package/dist/http/routes/postDomHover.js +22 -9
- package/dist/http/routes/postDomHover.js.map +1 -1
- package/dist/http/routes/postDomInfo.d.ts.map +1 -1
- package/dist/http/routes/postDomInfo.js +7 -3
- package/dist/http/routes/postDomInfo.js.map +1 -1
- package/dist/http/routes/postDomScroll.d.ts.map +1 -1
- package/dist/http/routes/postDomScroll.js +3 -8
- package/dist/http/routes/postDomScroll.js.map +1 -1
- package/dist/http/routes/postDomScrollTo.d.ts.map +1 -1
- package/dist/http/routes/postDomScrollTo.js +3 -8
- package/dist/http/routes/postDomScrollTo.js.map +1 -1
- package/dist/http/routes/postDomSetFile.d.ts.map +1 -1
- package/dist/http/routes/postDomSetFile.js +9 -23
- package/dist/http/routes/postDomSetFile.js.map +1 -1
- package/dist/http/routes/postLocate.d.ts +5 -0
- package/dist/http/routes/postLocate.d.ts.map +1 -0
- package/dist/http/routes/postLocate.js +67 -0
- package/dist/http/routes/postLocate.js.map +1 -0
- package/dist/http/routes/postNetClear.d.ts +3 -0
- package/dist/http/routes/postNetClear.d.ts.map +1 -0
- package/dist/http/routes/postNetClear.js +14 -0
- package/dist/http/routes/postNetClear.js.map +1 -0
- package/dist/http/routes/postSnapshot.d.ts.map +1 -1
- package/dist/http/routes/postSnapshot.js +1 -1
- package/dist/http/routes/postSnapshot.js.map +1 -1
- package/dist/http/routes/postStorageLocal.d.ts +1 -2
- package/dist/http/routes/postStorageLocal.d.ts.map +1 -1
- package/dist/http/routes/postStorageLocal.js +2 -30
- package/dist/http/routes/postStorageLocal.js.map +1 -1
- package/dist/http/routes/postStorageSession.d.ts +2 -0
- package/dist/http/routes/postStorageSession.d.ts.map +1 -0
- package/dist/http/routes/postStorageSession.js +3 -0
- package/dist/http/routes/postStorageSession.js.map +1 -0
- package/dist/http/routes/storage.d.ts +5 -0
- package/dist/http/routes/storage.d.ts.map +1 -0
- package/dist/http/routes/storage.js +43 -0
- package/dist/http/routes/storage.js.map +1 -0
- package/dist/http/server.d.ts +27 -3
- package/dist/http/server.d.ts.map +1 -1
- package/dist/http/server.js.map +1 -1
- package/dist/native-messaging/session-manager.d.ts +14 -1
- package/dist/native-messaging/session-manager.d.ts.map +1 -1
- package/dist/native-messaging/session-manager.js +56 -23
- package/dist/native-messaging/session-manager.js.map +1 -1
- package/dist/native-messaging/types.d.ts +28 -2
- package/dist/native-messaging/types.d.ts.map +1 -1
- package/dist/net/filtering.d.ts +32 -0
- package/dist/net/filtering.d.ts.map +1 -0
- package/dist/net/filtering.js +144 -0
- package/dist/net/filtering.js.map +1 -0
- package/dist/runtime/watcherInject.d.ts +15 -0
- package/dist/runtime/watcherInject.d.ts.map +1 -0
- package/dist/runtime/watcherInject.js +21 -0
- package/dist/runtime/watcherInject.js.map +1 -0
- package/dist/runtime/watcherServices.d.ts +32 -0
- package/dist/runtime/watcherServices.d.ts.map +1 -0
- package/dist/runtime/watcherServices.js +68 -0
- package/dist/runtime/watcherServices.js.map +1 -0
- package/dist/runtime/watcherSetup.d.ts +35 -0
- package/dist/runtime/watcherSetup.d.ts.map +1 -0
- package/dist/runtime/watcherSetup.js +96 -0
- package/dist/runtime/watcherSetup.js.map +1 -0
- package/dist/sources/cdp-source.d.ts.map +1 -1
- package/dist/sources/cdp-source.js +13 -0
- package/dist/sources/cdp-source.js.map +1 -1
- package/dist/sources/extension-frame-runtime.d.ts +11 -0
- package/dist/sources/extension-frame-runtime.d.ts.map +1 -0
- package/dist/sources/extension-frame-runtime.js +150 -0
- package/dist/sources/extension-frame-runtime.js.map +1 -0
- package/dist/sources/extension-frame-state.d.ts +3 -2
- package/dist/sources/extension-frame-state.d.ts.map +1 -1
- package/dist/sources/extension-frame-state.js +29 -8
- package/dist/sources/extension-frame-state.js.map +1 -1
- package/dist/sources/extension-session-events.d.ts.map +1 -1
- package/dist/sources/extension-session-events.js +4 -2
- package/dist/sources/extension-session-events.js.map +1 -1
- package/dist/sources/extension-source.d.ts.map +1 -1
- package/dist/sources/extension-source.js +134 -140
- package/dist/sources/extension-source.js.map +1 -1
- package/dist/sources/types.d.ts +15 -1
- package/dist/sources/types.d.ts.map +1 -1
- package/dist/startWatcherRuntime.d.ts.map +1 -1
- package/dist/startWatcherRuntime.js +78 -177
- package/dist/startWatcherRuntime.js.map +1 -1
- package/package.json +1 -1
- package/dist/cdp/storageLocal.d.ts +0 -8
- package/dist/cdp/storageLocal.d.ts.map +0 -1
- package/dist/cdp/storageLocal.js +0 -70
- package/dist/cdp/storageLocal.js.map +0 -1
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { normalizeCookieDomainFilter, normalizeCookieSameSite, } from '@vforsh/argus-core';
|
|
2
|
+
import { emitRequest } from './types.js';
|
|
3
|
+
import { clearAuthCookies, deleteAuthCookie, inspectAuthCookie, setAuthCookie } from '../../cdp/auth.js';
|
|
4
|
+
import { readJsonBody, respondError, respondInvalidBody, respondJson } from '../httpUtils.js';
|
|
5
|
+
const CLEAR_SCOPES = new Set(['origin', 'site', 'domain', 'browserContext']);
|
|
6
|
+
export const validateCookieGetPayload = (payload) => {
|
|
7
|
+
const identityError = validateCookieIdentityPayload(payload);
|
|
8
|
+
if (identityError) {
|
|
9
|
+
return identityError;
|
|
10
|
+
}
|
|
11
|
+
if (payload.includeValue != null && typeof payload.includeValue !== 'boolean') {
|
|
12
|
+
return 'includeValue must be a boolean';
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
};
|
|
16
|
+
export const validateCookieDeletePayload = (payload) => validateCookieIdentityPayload(payload);
|
|
17
|
+
export const validateCookieSetPayload = (payload) => {
|
|
18
|
+
if (!payload.cookie || typeof payload.cookie !== 'object') {
|
|
19
|
+
return 'cookie is required';
|
|
20
|
+
}
|
|
21
|
+
const identityError = validateCookieIdentityPayload(payload.cookie);
|
|
22
|
+
if (identityError) {
|
|
23
|
+
return identityError;
|
|
24
|
+
}
|
|
25
|
+
if (typeof payload.cookie.value !== 'string') {
|
|
26
|
+
return 'cookie.value must be a string';
|
|
27
|
+
}
|
|
28
|
+
if (typeof payload.cookie.secure !== 'boolean') {
|
|
29
|
+
return 'cookie.secure must be a boolean';
|
|
30
|
+
}
|
|
31
|
+
if (typeof payload.cookie.httpOnly !== 'boolean') {
|
|
32
|
+
return 'cookie.httpOnly must be a boolean';
|
|
33
|
+
}
|
|
34
|
+
if (typeof payload.cookie.session !== 'boolean') {
|
|
35
|
+
return 'cookie.session must be a boolean';
|
|
36
|
+
}
|
|
37
|
+
if (payload.cookie.expires !== null && (typeof payload.cookie.expires !== 'number' || !Number.isFinite(payload.cookie.expires))) {
|
|
38
|
+
return 'cookie.expires must be a finite number or null';
|
|
39
|
+
}
|
|
40
|
+
if (payload.cookie.sameSite !== null && payload.cookie.sameSite !== undefined && typeof payload.cookie.sameSite !== 'string') {
|
|
41
|
+
return 'cookie.sameSite must be a string or null';
|
|
42
|
+
}
|
|
43
|
+
if (payload.cookie.sameSite && !normalizeCookieSameSite(payload.cookie.sameSite)) {
|
|
44
|
+
return 'cookie.sameSite must be one of: Strict, Lax, None';
|
|
45
|
+
}
|
|
46
|
+
if (payload.cookie.session && payload.cookie.expires != null) {
|
|
47
|
+
return 'cookie.expires must be null when cookie.session is true';
|
|
48
|
+
}
|
|
49
|
+
if (!payload.cookie.session && payload.cookie.expires == null) {
|
|
50
|
+
return 'cookie.expires is required when cookie.session is false';
|
|
51
|
+
}
|
|
52
|
+
if (normalizeCookieSameSite(payload.cookie.sameSite) === 'None' && !payload.cookie.secure) {
|
|
53
|
+
return 'cookie.secure must be true when cookie.sameSite is None';
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
};
|
|
57
|
+
export const validateCookieClearPayload = (payload) => {
|
|
58
|
+
if (!CLEAR_SCOPES.has(payload.scope)) {
|
|
59
|
+
return 'scope must be one of: origin, site, domain, browserContext';
|
|
60
|
+
}
|
|
61
|
+
if (payload.scope === 'domain' && !normalizeCookieDomainFilter(payload.domain)) {
|
|
62
|
+
return 'domain is required when scope is "domain"';
|
|
63
|
+
}
|
|
64
|
+
if (payload.scope !== 'domain' && payload.domain != null && typeof payload.domain !== 'string') {
|
|
65
|
+
return 'domain must be a string when provided';
|
|
66
|
+
}
|
|
67
|
+
if (payload.sessionOnly != null && typeof payload.sessionOnly !== 'boolean') {
|
|
68
|
+
return 'sessionOnly must be a boolean';
|
|
69
|
+
}
|
|
70
|
+
if (payload.authOnly != null && typeof payload.authOnly !== 'boolean') {
|
|
71
|
+
return 'authOnly must be a boolean';
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
};
|
|
75
|
+
const createAuthCookieRoute = (options) => {
|
|
76
|
+
return async (req, res, _url, ctx) => {
|
|
77
|
+
const payload = await readJsonBody(req, res);
|
|
78
|
+
if (!payload) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const validationError = options.validate(payload);
|
|
82
|
+
if (validationError) {
|
|
83
|
+
respondInvalidBody(res, validationError);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
emitRequest(ctx, res, options.endpoint);
|
|
87
|
+
try {
|
|
88
|
+
respondJson(res, await options.run(payload, ctx));
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
respondError(res, error);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
const validateCookieIdentityPayload = (payload) => {
|
|
96
|
+
if (typeof payload.name !== 'string' || payload.name.trim() === '') {
|
|
97
|
+
return 'name is required';
|
|
98
|
+
}
|
|
99
|
+
if (typeof payload.domain !== 'string' || payload.domain.trim() === '') {
|
|
100
|
+
return 'domain is required';
|
|
101
|
+
}
|
|
102
|
+
if (typeof payload.path !== 'string' || payload.path.trim() === '') {
|
|
103
|
+
return 'path is required';
|
|
104
|
+
}
|
|
105
|
+
if (!payload.path.startsWith('/')) {
|
|
106
|
+
return 'path must start with "/"';
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
};
|
|
110
|
+
export const handleCookieGet = createAuthCookieRoute({
|
|
111
|
+
endpoint: 'auth/cookies/get',
|
|
112
|
+
validate: validateCookieGetPayload,
|
|
113
|
+
run: (payload, ctx) => inspectAuthCookie(ctx.cdpSession, {
|
|
114
|
+
...payload,
|
|
115
|
+
readBrowserCookies: ctx.readBrowserCookies,
|
|
116
|
+
}),
|
|
117
|
+
});
|
|
118
|
+
export const handleCookieSet = createAuthCookieRoute({
|
|
119
|
+
endpoint: 'auth/cookies/set',
|
|
120
|
+
validate: validateCookieSetPayload,
|
|
121
|
+
run: (payload, ctx) => setAuthCookie(ctx.cdpSession, {
|
|
122
|
+
...payload,
|
|
123
|
+
readBrowserCookies: ctx.readBrowserCookies,
|
|
124
|
+
}),
|
|
125
|
+
});
|
|
126
|
+
export const handleCookieDelete = createAuthCookieRoute({
|
|
127
|
+
endpoint: 'auth/cookies/delete',
|
|
128
|
+
validate: validateCookieDeletePayload,
|
|
129
|
+
run: (payload, ctx) => deleteAuthCookie(ctx.cdpSession, {
|
|
130
|
+
...payload,
|
|
131
|
+
readBrowserCookies: ctx.readBrowserCookies,
|
|
132
|
+
}),
|
|
133
|
+
});
|
|
134
|
+
export const handleCookieClear = createAuthCookieRoute({
|
|
135
|
+
endpoint: 'auth/cookies/clear',
|
|
136
|
+
validate: validateCookieClearPayload,
|
|
137
|
+
run: (payload, ctx) => clearAuthCookies(ctx.cdpSession, {
|
|
138
|
+
...payload,
|
|
139
|
+
readBrowserCookies: ctx.readBrowserCookies,
|
|
140
|
+
}),
|
|
141
|
+
});
|
|
142
|
+
//# sourceMappingURL=authCookies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authCookies.js","sourceRoot":"","sources":["../../../src/http/routes/authCookies.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,2BAA2B,EAC3B,uBAAuB,GAUvB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,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
5
|
all?: unknown;
|
|
5
6
|
};
|
|
6
7
|
/**
|
|
7
8
|
* Shared parser for DOM routes that require a selector and optional `all` toggle.
|
|
8
9
|
* Keeps route modules focused on the actual DOM operation.
|
|
9
10
|
*/
|
|
11
|
+
export declare const readDomTargetPayload: <T extends SelectorPayload>(req: http.IncomingMessage, res: http.ServerResponse) => Promise<{
|
|
12
|
+
payload: T;
|
|
13
|
+
all: boolean;
|
|
14
|
+
} | null>;
|
|
15
|
+
/** Backwards-compatible alias used by selector-only routes while they migrate to ref support. */
|
|
10
16
|
export declare const readDomSelectorPayload: <T extends SelectorPayload>(req: http.IncomingMessage, res: http.ServerResponse) => Promise<{
|
|
11
17
|
payload: T;
|
|
12
18
|
all: boolean;
|
|
13
19
|
} | null>;
|
|
14
20
|
export declare const respondMultipleMatches: (res: http.ServerResponse, matches: number, action: string) => void;
|
|
21
|
+
export declare const respondMissingElementRef: (res: http.ServerResponse, ref: string) => void;
|
|
22
|
+
export declare const respondTargetResolutionError: (res: http.ServerResponse, error: unknown) => boolean;
|
|
15
23
|
export {};
|
|
16
24
|
//# sourceMappingURL=domSelectorRoute.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domSelectorRoute.d.ts","sourceRoot":"","sources":["../../../src/http/routes/domSelectorRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAGjC,KAAK,eAAe,GAAG;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,GAAG,CAAC,EAAE,OAAO,CAAA;CACb,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"domSelectorRoute.d.ts","sourceRoot":"","sources":["../../../src/http/routes/domSelectorRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAGjC,KAAK,eAAe,GAAG;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,GAAG,CAAC,EAAE,OAAO,CAAA;CACb,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAU,CAAC,SAAS,eAAe,EACnE,KAAK,IAAI,CAAC,eAAe,EACzB,KAAK,IAAI,CAAC,cAAc,KACtB,OAAO,CAAC;IAAE,OAAO,EAAE,CAAC,CAAC;IAAC,GAAG,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAoB7C,CAAA;AAED,iGAAiG;AACjG,eAAO,MAAM,sBAAsB,GA1BQ,CAAC,SAAS,eAAe,OAC9D,IAAI,CAAC,eAAe,OACpB,IAAI,CAAC,cAAc,KACtB,OAAO,CAAC;IAAE,OAAO,EAAE,CAAC,CAAC;IAAC,GAAG,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAuBY,CAAA;AAE1D,eAAO,MAAM,sBAAsB,GAAI,KAAK,IAAI,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,QAAQ,MAAM,KAAG,IAYlG,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAI,KAAK,IAAI,CAAC,cAAc,EAAE,KAAK,MAAM,KAAG,IAYhF,CAAA;AAED,eAAO,MAAM,4BAA4B,GAAI,KAAK,IAAI,CAAC,cAAc,EAAE,OAAO,OAAO,KAAG,OAavF,CAAA"}
|
|
@@ -3,13 +3,15 @@ import { respondInvalidBody, respondJson, readJsonBody } from '../httpUtils.js';
|
|
|
3
3
|
* Shared parser for DOM routes that require a selector and optional `all` toggle.
|
|
4
4
|
* Keeps route modules focused on the actual DOM operation.
|
|
5
5
|
*/
|
|
6
|
-
export const
|
|
6
|
+
export const readDomTargetPayload = async (req, res) => {
|
|
7
7
|
const payload = await readJsonBody(req, res);
|
|
8
8
|
if (!payload) {
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const hasSelector = typeof payload.selector === 'string' && payload.selector.trim() !== '';
|
|
12
|
+
const hasRef = typeof payload.ref === 'string' && payload.ref.trim() !== '';
|
|
13
|
+
if (hasSelector === hasRef) {
|
|
14
|
+
respondInvalidBody(res, 'Exactly one of selector or ref is required');
|
|
13
15
|
return null;
|
|
14
16
|
}
|
|
15
17
|
const all = payload.all ?? false;
|
|
@@ -19,6 +21,8 @@ export const readDomSelectorPayload = async (req, res) => {
|
|
|
19
21
|
}
|
|
20
22
|
return { payload, all };
|
|
21
23
|
};
|
|
24
|
+
/** Backwards-compatible alias used by selector-only routes while they migrate to ref support. */
|
|
25
|
+
export const readDomSelectorPayload = readDomTargetPayload;
|
|
22
26
|
export const respondMultipleMatches = (res, matches, action) => {
|
|
23
27
|
respondJson(res, {
|
|
24
28
|
ok: false,
|
|
@@ -28,4 +32,25 @@ export const respondMultipleMatches = (res, matches, action) => {
|
|
|
28
32
|
},
|
|
29
33
|
}, 400);
|
|
30
34
|
};
|
|
35
|
+
export const respondMissingElementRef = (res, ref) => {
|
|
36
|
+
respondJson(res, {
|
|
37
|
+
ok: false,
|
|
38
|
+
error: {
|
|
39
|
+
message: `Unknown or stale element ref: ${ref}. Run argus snapshot or locate again.`,
|
|
40
|
+
code: 'invalid_ref',
|
|
41
|
+
},
|
|
42
|
+
}, 400);
|
|
43
|
+
};
|
|
44
|
+
export const respondTargetResolutionError = (res, error) => {
|
|
45
|
+
if (!error || typeof error !== 'object') {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
const code = 'code' in error ? error.code : undefined;
|
|
49
|
+
if (code !== 'invalid_ref') {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
const message = error instanceof Error && error.message ? error.message : 'Unknown or stale element ref. Run argus snapshot or locate again.';
|
|
53
|
+
respondJson(res, { ok: false, error: { message, code: 'invalid_ref' } }, 400);
|
|
54
|
+
return true;
|
|
55
|
+
};
|
|
31
56
|
//# sourceMappingURL=domSelectorRoute.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domSelectorRoute.js","sourceRoot":"","sources":["../../../src/http/routes/domSelectorRoute.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"domSelectorRoute.js","sourceRoot":"","sources":["../../../src/http/routes/domSelectorRoute.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAQ/E;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EACxC,GAAyB,EACzB,GAAwB,EACuB,EAAE;IACjD,MAAM,OAAO,GAAG,MAAM,YAAY,CAAI,GAAG,EAAE,GAAG,CAAC,CAAA;IAC/C,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,MAAM,WAAW,GAAG,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,CAAA;IAC1F,MAAM,MAAM,GAAG,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,CAAA;IAC3E,IAAI,WAAW,KAAK,MAAM,EAAE,CAAC;QAC5B,kBAAkB,CAAC,GAAG,EAAE,4CAA4C,CAAC,CAAA;QACrE,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,KAAK,CAAA;IAChC,IAAI,OAAO,GAAG,KAAK,SAAS,EAAE,CAAC;QAC9B,kBAAkB,CAAC,GAAG,EAAE,uBAAuB,CAAC,CAAA;QAChD,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAA;AACxB,CAAC,CAAA;AAED,iGAAiG;AACjG,MAAM,CAAC,MAAM,sBAAsB,GAAG,oB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C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAuthState.d.ts","sourceRoot":"","sources":["../../../src/http/routes/getAuthState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAK9C,eAAO,MAAM,MAAM,EAAE,YAoBpB,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { emitRequest } from './types.js';
|
|
2
|
+
import { inspectAuthState } from '../../cdp/auth.js';
|
|
3
|
+
import { normalizeQueryValue, respondError, respondJson } from '../httpUtils.js';
|
|
4
|
+
export const handle = async (_req, res, url, ctx) => {
|
|
5
|
+
const domain = normalizeQueryValue(url.searchParams.get('domain'));
|
|
6
|
+
emitRequest(ctx, res, 'auth/state', { domain });
|
|
7
|
+
try {
|
|
8
|
+
const watcher = ctx.getWatcher();
|
|
9
|
+
const response = await inspectAuthState(ctx.cdpSession, {
|
|
10
|
+
domain: domain ?? undefined,
|
|
11
|
+
readBrowserCookies: ctx.readBrowserCookies,
|
|
12
|
+
metadata: {
|
|
13
|
+
exportedAt: new Date().toISOString(),
|
|
14
|
+
watcherId: watcher.id,
|
|
15
|
+
watcherSource: watcher.source ?? null,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
respondJson(res, response);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
respondError(res, error);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=getAuthState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAuthState.js","sourceRoot":"","sources":["../../../src/http/routes/getAuthState.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAEhF,MAAM,CAAC,MAAM,MAAM,GAAiB,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;IACjE,MAAM,MAAM,GAAG,mBAAmB,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;IAElE,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;IAE/C,IAAI,CAAC;QACJ,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAE,CAAA;QAChC,MAAM,QAAQ,GAAsB,MAAM,gBAAgB,CAAC,GAAG,CAAC,UAAU,EAAE;YAC1E,MAAM,EAAE,MAAM,IAAI,SAAS;YAC3B,kBAAkB,EAAE,GAAG,CAAC,kBAAkB;YAC1C,QAAQ,EAAE;gBACT,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACpC,SAAS,EAAE,OAAO,CAAC,EAAE;gBACrB,aAAa,EAAE,OAAO,CAAC,MAAM,IAAI,IAAI;aACrC;SACD,CAAC,CAAA;QACF,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IACzB,CAAC;AACF,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDialog.d.ts","sourceRoot":"","sources":["../../../src/http/routes/getDialog.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAI9C,eAAO,MAAM,MAAM,EAAE,YASpB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { emitRequest } from './types.js';
|
|
2
|
+
import { respondJson } from '../httpUtils.js';
|
|
3
|
+
export const handle = (_req, res, _url, ctx) => {
|
|
4
|
+
emitRequest(ctx, res, 'dialog/status');
|
|
5
|
+
const response = {
|
|
6
|
+
ok: true,
|
|
7
|
+
dialog: ctx.getDialog(),
|
|
8
|
+
};
|
|
9
|
+
respondJson(res, response);
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=getDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDialog.js","sourceRoot":"","sources":["../../../src/http/routes/getDialog.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE7C,MAAM,CAAC,MAAM,MAAM,GAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;IAC5D,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,eAAe,CAAC,CAAA;IAEtC,MAAM,QAAQ,GAAyB;QACtC,EAAE,EAAE,IAAI;QACR,MAAM,EAAE,GAAG,CAAC,SAAS,EAAE;KACvB,CAAA;IAED,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;AAC3B,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNet.d.ts","sourceRoot":"","sources":["../../../src/http/routes/getNet.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"getNet.d.ts","sourceRoot":"","sources":["../../../src/http/routes/getNet.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAK9C,eAAO,MAAM,MAAM,EAAE,YAqBpB,CAAA"}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { emitRequest } from './types.js';
|
|
2
|
-
import {
|
|
2
|
+
import { parseNetRequestFilters, toNetRequestEventQuery } from './netFilters.js';
|
|
3
|
+
import { respondJson, clampNumber } from '../httpUtils.js';
|
|
3
4
|
export const handle = (_req, res, url, ctx) => {
|
|
4
5
|
if (!ctx.netBuffer) {
|
|
5
6
|
return respondJson(res, { ok: false, error: { code: 'net_disabled', message: 'Network capture is disabled for this watcher' } }, 400);
|
|
6
7
|
}
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const filters = parseNetRequestFilters(url.searchParams, {
|
|
9
|
+
after: clampNumber(url.searchParams.get('after'), 0),
|
|
10
|
+
limit: clampNumber(url.searchParams.get('limit'), 500, 1, 5000),
|
|
11
|
+
sinceTs: clampNumber(url.searchParams.get('sinceTs'), undefined),
|
|
12
|
+
context: ctx.getNetFilterContext?.() ?? null,
|
|
13
|
+
});
|
|
14
|
+
if (filters.error || !filters.value) {
|
|
15
|
+
return respondJson(res, { ok: false, error: { code: 'invalid_net_filter', message: filters.error ?? 'Invalid network filter' } }, 400);
|
|
16
|
+
}
|
|
17
|
+
emitRequest(ctx, res, 'net', toNetRequestEventQuery(filters.value));
|
|
18
|
+
const requests = ctx.netBuffer.listAfter(filters.value.after, filters.value, filters.value.limit);
|
|
19
|
+
const nextAfter = requests.length > 0 ? (requests[requests.length - 1]?.id ?? filters.value.after) : filters.value.after;
|
|
14
20
|
const response = { ok: true, requests, nextAfter };
|
|
15
21
|
respondJson(res, response);
|
|
16
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNet.js","sourceRoot":"","sources":["../../../src/http/routes/getNet.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"getNet.js","sourceRoot":"","sources":["../../../src/http/routes/getNet.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAChF,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AQ,GAAG,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACjG,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAA;IACxH,MAAM,QAAQ,GAAgB,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAA;IAC/D,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;AAC3B,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNetRequest.d.ts","sourceRoot":"","sources":["../../../src/http/routes/getNetRequest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAK9C,eAAO,MAAM,MAAM,EAAE,YAsBpB,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { emitRequest } from './types.js';
|
|
2
|
+
import { respondJson } from '../httpUtils.js';
|
|
3
|
+
import { parseNetRequestLookup, resolveNetRequestLookup } from './netRequestLookup.js';
|
|
4
|
+
export const handle = (_req, res, url, ctx) => {
|
|
5
|
+
if (!ctx.netBuffer) {
|
|
6
|
+
return respondJson(res, { ok: false, error: { code: 'net_disabled', message: 'Network capture is disabled for this watcher' } }, 400);
|
|
7
|
+
}
|
|
8
|
+
const lookup = parseNetRequestLookup(url.searchParams);
|
|
9
|
+
if (!lookup) {
|
|
10
|
+
return respondJson(res, { ok: false, error: { code: 'invalid_request', message: 'Either id or requestId is required' } }, 400);
|
|
11
|
+
}
|
|
12
|
+
emitRequest(ctx, res, 'net/request', {
|
|
13
|
+
id: lookup.id,
|
|
14
|
+
requestId: lookup.requestId,
|
|
15
|
+
});
|
|
16
|
+
const request = resolveNetRequestLookup(ctx.netBuffer, lookup);
|
|
17
|
+
if (!request) {
|
|
18
|
+
return respondJson(res, { ok: false, error: { code: 'not_found', message: 'Network request not found' } }, 404);
|
|
19
|
+
}
|
|
20
|
+
const response = { ok: true, request };
|
|
21
|
+
respondJson(res, response);
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=getNetRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNetRequest.js","sourceRoot":"","sources":["../../../src/http/routes/getNetRequest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAEtF,MAAM,CAAC,MAAM,MAAM,GAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;IAC3D,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;QACpB,OAAO,WAAW,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,8CAA8C,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;IACtI,CAAC;IAED,MAAM,MAAM,GAAG,qBAAqB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IACtD,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,OAAO,WAAW,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,oCAAoC,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;IAC/H,CAAC;IAED,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,aAAa,EAAE;QACpC,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,SAAS,EAAE,MAAM,CAAC,SAAS;KAC3B,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,uBAAuB,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;IAC9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,OAAO,WAAW,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,2BAA2B,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;IAChH,CAAC;IAED,MAAM,QAAQ,GAAuB,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;IAC1D,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;AAC3B,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNetRequestBody.d.ts","sourceRoot":"","sources":["../../../src/http/routes/getNetRequestBody.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgB,YAAY,EAAE,MAAM,YAAY,CAAA;AAM5D,eAAO,MAAM,MAAM,EAAE,YA4DpB,CAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { emitRequest } from './types.js';
|
|
2
|
+
import { respondError, respondJson } from '../httpUtils.js';
|
|
3
|
+
import { normalizeNetBodyError, readNetworkBody } from '../../cdp/networkBody.js';
|
|
4
|
+
import { parseNetRequestLookup, resolveNetRequestLookupRecord } from './netRequestLookup.js';
|
|
5
|
+
export const handle = async (_req, res, url, ctx) => {
|
|
6
|
+
if (!ctx.netBuffer) {
|
|
7
|
+
return respondJson(res, { ok: false, error: { code: 'net_disabled', message: 'Network capture is disabled for this watcher' } }, 400);
|
|
8
|
+
}
|
|
9
|
+
const lookup = parseNetRequestLookup(url.searchParams);
|
|
10
|
+
if (!lookup) {
|
|
11
|
+
return respondJson(res, { ok: false, error: { code: 'invalid_request', message: 'Either id or requestId is required' } }, 400);
|
|
12
|
+
}
|
|
13
|
+
const part = parseBodyPart(url.searchParams.get('part'));
|
|
14
|
+
if (!part) {
|
|
15
|
+
return respondJson(res, { ok: false, error: { code: 'invalid_request', message: 'part must be "request" or "response"' } }, 400);
|
|
16
|
+
}
|
|
17
|
+
emitRequest(ctx, res, 'net/request/body', {
|
|
18
|
+
id: lookup.id,
|
|
19
|
+
requestId: lookup.requestId,
|
|
20
|
+
part,
|
|
21
|
+
});
|
|
22
|
+
const record = resolveNetRequestLookupRecord(ctx.netBuffer, lookup);
|
|
23
|
+
if (!record) {
|
|
24
|
+
return respondJson(res, { ok: false, error: { code: 'not_found', message: 'Network request not found' } }, 404);
|
|
25
|
+
}
|
|
26
|
+
const { detail: request, bodySessionId } = record;
|
|
27
|
+
if (!request.body[part]) {
|
|
28
|
+
return respondJson(res, { ok: false, error: { code: 'body_not_available', message: `${capitalizePart(part)} body not available for this request` } }, 404);
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const body = await readNetworkBody({
|
|
32
|
+
session: ctx.pageCdpSession,
|
|
33
|
+
request,
|
|
34
|
+
sessionId: resolveBodySessionId(ctx, request.frameId, bodySessionId),
|
|
35
|
+
part,
|
|
36
|
+
});
|
|
37
|
+
const response = {
|
|
38
|
+
ok: true,
|
|
39
|
+
id: request.id,
|
|
40
|
+
requestId: request.requestId,
|
|
41
|
+
part,
|
|
42
|
+
mimeType: body.mimeType,
|
|
43
|
+
body: body.body,
|
|
44
|
+
base64Encoded: body.base64Encoded,
|
|
45
|
+
};
|
|
46
|
+
respondJson(res, response);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
const normalizedError = normalizeNetBodyError(error, part);
|
|
50
|
+
if (normalizedError.code === 'body_not_available') {
|
|
51
|
+
return respondJson(res, { ok: false, error: { code: 'body_not_available', message: normalizedError.message } }, 404);
|
|
52
|
+
}
|
|
53
|
+
respondError(res, normalizedError);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const parseBodyPart = (value) => {
|
|
57
|
+
if (!value || value === 'response') {
|
|
58
|
+
return 'response';
|
|
59
|
+
}
|
|
60
|
+
if (value === 'request') {
|
|
61
|
+
return 'request';
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
};
|
|
65
|
+
const capitalizePart = (part) => `${part.slice(0, 1).toUpperCase()}${part.slice(1)}`;
|
|
66
|
+
/**
|
|
67
|
+
* Network events in extension mode should carry the child-session id that owns the request,
|
|
68
|
+
* but older buffered records or transient bridge gaps can miss it. Fall back to the extension
|
|
69
|
+
* source's frame map before giving up so iframe body reads stay stable after reloads.
|
|
70
|
+
*/
|
|
71
|
+
const resolveBodySessionId = (ctx, frameId, storedSessionId) => {
|
|
72
|
+
if (storedSessionId) {
|
|
73
|
+
return storedSessionId;
|
|
74
|
+
}
|
|
75
|
+
if (!frameId) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
return ctx.sourceHandle?.getFrameSessionId?.(frameId) ?? null;
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=getNetRequestBody.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNetRequestBody.js","sourceRoot":"","sources":["../../../src/http/routes/getNetRequestBody.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AACjF,OAAO,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAA;AAE5F,MAAM,CAAC,MAAM,MAAM,GAAiB,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;IACjE,IAAI,CAAC,GAAG,CAA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;QACD,YAAY,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA;IACnC,CAAC;AACF,CAAC,CAAA;AAED,MAAM,aAAa,GAAG,CAAC,KAAoB,EAA6B,EAAE;IACzE,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,UAAU,EAAE,CAAC;QACpC,OAAO,UAAU,CAAA;IAClB,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,SAAS,CAAA;IACjB,CAAC;IACD,OAAO,IAAI,CAAA;AACZ,CAAC,CAAA;AAED,MAAM,cAAc,GAAG,CAAC,IAAwB,EAAU,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;AAEhH;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,CAAC,GAAiB,EAAE,OAAsB,EAAE,eAA8B,EAAiB,EAAE;IACzH,IAAI,eAAe,EAAE,CAAC;QACrB,OAAO,eAAe,CAAA;IACvB,CAAC;IAED,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,OAAO,GAAG,CAAC,YAAY,EAAE,iBAAiB,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,CAAA;AAC9D,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNetRequests.d.ts","sourceRoot":"","sources":["../../../src/http/routes/getNetRequests.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAK9C,eAAO,MAAM,MAAM,EAAE,YAqBpB,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { emitRequest } from './types.js';
|
|
2
|
+
import { parseNetRequestFilters, toNetRequestEventQuery } from './netFilters.js';
|
|
3
|
+
import { respondJson, clampNumber } from '../httpUtils.js';
|
|
4
|
+
export const handle = (_req, res, url, ctx) => {
|
|
5
|
+
if (!ctx.netBuffer) {
|
|
6
|
+
return respondJson(res, { ok: false, error: { code: 'net_disabled', message: 'Network capture is disabled for this watcher' } }, 400);
|
|
7
|
+
}
|
|
8
|
+
const filters = parseNetRequestFilters(url.searchParams, {
|
|
9
|
+
after: clampNumber(url.searchParams.get('after'), 0),
|
|
10
|
+
limit: clampNumber(url.searchParams.get('limit'), 500, 1, 5000),
|
|
11
|
+
sinceTs: clampNumber(url.searchParams.get('sinceTs'), undefined),
|
|
12
|
+
context: ctx.getNetFilterContext?.() ?? null,
|
|
13
|
+
});
|
|
14
|
+
if (filters.error || !filters.value) {
|
|
15
|
+
return respondJson(res, { ok: false, error: { code: 'invalid_net_filter', message: filters.error ?? 'Invalid network filter' } }, 400);
|
|
16
|
+
}
|
|
17
|
+
emitRequest(ctx, res, 'net/requests', toNetRequestEventQuery(filters.value));
|
|
18
|
+
const requests = ctx.netBuffer.listDetailsAfter(filters.value.after, filters.value, filters.value.limit);
|
|
19
|
+
const nextAfter = requests.length > 0 ? (requests[requests.length - 1]?.id ?? filters.value.after) : filters.value.after;
|
|
20
|
+
const response = { ok: true, requests, nextAfter };
|
|
21
|
+
respondJson(res, response);
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=getNetRequests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNetRequests.js","sourceRoot":"","sources":["../../../src/http/routes/getNetRequests.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAChF,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE1D,MAAM,CAAC,MAAM,MAAM,GAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;IAC3D,IAAI,CAAC,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,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAA;IACxH,MAAM,QAAQ,GAAwB,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAA;IACvE,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;AAC3B,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNetTail.d.ts","sourceRoot":"","sources":["../../../src/http/routes/getNetTail.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"getNetTail.d.ts","sourceRoot":"","sources":["../../../src/http/routes/getNetTail.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAM9C,eAAO,MAAM,MAAM,EAAE,YAiBpB,CAAA"}
|
|
@@ -1,18 +1,53 @@
|
|
|
1
1
|
import { emitRequest } from './types.js';
|
|
2
|
-
import {
|
|
2
|
+
import { parseNetRequestFilters, toNetRequestEventQuery } from './netFilters.js';
|
|
3
|
+
import { respondJson, clampNumber } from '../httpUtils.js';
|
|
3
4
|
export const handle = async (_req, res, url, ctx) => {
|
|
4
5
|
if (!ctx.netBuffer) {
|
|
5
6
|
return respondJson(res, { ok: false, error: { code: 'net_disabled', message: 'Network capture is disabled for this watcher' } }, 400);
|
|
6
7
|
}
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
emitRequest(ctx, res, 'net/tail',
|
|
13
|
-
const requests = await ctx.netBuffer.
|
|
14
|
-
const nextAfter = requests.length > 0 ? (requests[requests.length - 1]?.id ?? after) : after;
|
|
8
|
+
const parsed = parseTailRequest(url, ctx);
|
|
9
|
+
if (parsed.error || !parsed.value) {
|
|
10
|
+
return respondJson(res, { ok: false, error: { code: 'invalid_net_filter', message: parsed.error ?? 'Invalid network filter' } }, 400);
|
|
11
|
+
}
|
|
12
|
+
const { filters, timeoutMs } = parsed.value;
|
|
13
|
+
emitRequest(ctx, res, 'net/tail', toNetRequestEventQuery(filters, { timeoutMs }));
|
|
14
|
+
const requests = await pollNetBuffer(ctx.netBuffer, filters.after, filters, filters.limit, timeoutMs);
|
|
15
|
+
const nextAfter = requests.length > 0 ? (requests[requests.length - 1]?.id ?? filters.after) : filters.after;
|
|
15
16
|
const response = { ok: true, requests, nextAfter, timedOut: requests.length === 0 };
|
|
16
17
|
respondJson(res, response);
|
|
17
18
|
};
|
|
19
|
+
const parseTailRequest = (url, ctx) => {
|
|
20
|
+
const filters = parseNetRequestFilters(url.searchParams, {
|
|
21
|
+
after: clampNumber(url.searchParams.get('after'), 0),
|
|
22
|
+
limit: clampNumber(url.searchParams.get('limit'), 500, 1, 5000),
|
|
23
|
+
sinceTs: clampNumber(url.searchParams.get('sinceTs'), undefined),
|
|
24
|
+
context: ctx.getNetFilterContext?.() ?? null,
|
|
25
|
+
});
|
|
26
|
+
if (filters.error || !filters.value) {
|
|
27
|
+
return { error: filters.error ?? 'Invalid network filter' };
|
|
28
|
+
}
|
|
29
|
+
const timeoutMs = clampNumber(url.searchParams.get('timeoutMs'), 25_000, 1000, 120_000);
|
|
30
|
+
return { value: { filters: filters.value, timeoutMs } };
|
|
31
|
+
};
|
|
32
|
+
const NET_TAIL_POLL_INTERVAL_MS = 100;
|
|
33
|
+
/**
|
|
34
|
+
* Poll the in-memory buffer until matching requests appear or the timeout expires.
|
|
35
|
+
* This is intentionally boring: network tail has one caller and simple polling proved
|
|
36
|
+
* more reliable than waiter bookkeeping during extension-driven reloads.
|
|
37
|
+
*/
|
|
38
|
+
const pollNetBuffer = async (buffer, after, filters, limit, timeoutMs) => {
|
|
39
|
+
const deadline = Date.now() + timeoutMs;
|
|
40
|
+
while (true) {
|
|
41
|
+
const requests = buffer.listAfter(after, filters, limit);
|
|
42
|
+
if (requests.length > 0) {
|
|
43
|
+
return requests;
|
|
44
|
+
}
|
|
45
|
+
const remainingMs = deadline - Date.now();
|
|
46
|
+
if (remainingMs <= 0) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
await delay(Math.min(NET_TAIL_POLL_INTERVAL_MS, remainingMs));
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const delay = (timeoutMs) => new Promise((resolve) => setTimeout(resolve, timeoutMs));
|
|
18
53
|
//# sourceMappingURL=getNetTail.js.map
|