@vforsh/argus-watcher 0.1.9 → 0.1.11
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/buffer/RealtimeNetBuffer.d.ts +31 -0
- package/dist/buffer/RealtimeNetBuffer.d.ts.map +1 -0
- package/dist/buffer/RealtimeNetBuffer.js +190 -0
- package/dist/buffer/RealtimeNetBuffer.js.map +1 -0
- 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 +35 -0
- package/dist/cdp/dom/selector.d.ts.map +1 -1
- package/dist/cdp/dom/selector.js +118 -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 +5 -1
- package/dist/cdp/editor.d.ts.map +1 -1
- package/dist/cdp/editor.js +99 -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/eval.d.ts +1 -0
- package/dist/cdp/eval.d.ts.map +1 -1
- package/dist/cdp/eval.js +77 -29
- package/dist/cdp/eval.js.map +1 -1
- 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 +9 -8
- package/dist/cdp/mouse.d.ts.map +1 -1
- package/dist/cdp/mouse.js +41 -39
- 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 +6 -0
- package/dist/cdp/networkCapture.d.ts.map +1 -1
- package/dist/cdp/networkCapture.js +315 -35
- package/dist/cdp/networkCapture.js.map +1 -1
- package/dist/cdp/networkRealtimeCapture.d.ts +23 -0
- package/dist/cdp/networkRealtimeCapture.d.ts.map +1 -0
- package/dist/cdp/networkRealtimeCapture.js +161 -0
- package/dist/cdp/networkRealtimeCapture.js.map +1 -0
- 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 +121 -22
- 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 +1 -0
- package/dist/cdp/watcher.d.ts.map +1 -1
- package/dist/cdp/watcher.js +5 -1
- package/dist/cdp/watcher.js.map +1 -1
- 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 +23 -3
- package/dist/events.d.ts.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/defineDomTargetRoute.d.ts +50 -0
- package/dist/http/routes/defineDomTargetRoute.d.ts.map +1 -0
- package/dist/http/routes/defineDomTargetRoute.js +45 -0
- package/dist/http/routes/defineDomTargetRoute.js.map +1 -0
- package/dist/http/routes/defineRoute.d.ts +30 -0
- package/dist/http/routes/defineRoute.d.ts.map +1 -0
- package/dist/http/routes/defineRoute.js +41 -0
- package/dist/http/routes/defineRoute.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/getExtensionTabs.d.ts +3 -0
- package/dist/http/routes/getExtensionTabs.d.ts.map +1 -0
- package/dist/http/routes/getExtensionTabs.js +22 -0
- package/dist/http/routes/getExtensionTabs.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/getNetSse.d.ts +3 -0
- package/dist/http/routes/getNetSse.d.ts.map +1 -0
- package/dist/http/routes/getNetSse.js +23 -0
- package/dist/http/routes/getNetSse.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/getNetWebSocketConnection.d.ts +3 -0
- package/dist/http/routes/getNetWebSocketConnection.d.ts.map +1 -0
- package/dist/http/routes/getNetWebSocketConnection.js +20 -0
- package/dist/http/routes/getNetWebSocketConnection.js.map +1 -0
- package/dist/http/routes/getNetWebSockets.d.ts +3 -0
- package/dist/http/routes/getNetWebSockets.d.ts.map +1 -0
- package/dist/http/routes/getNetWebSockets.js +23 -0
- package/dist/http/routes/getNetWebSockets.js.map +1 -0
- package/dist/http/routes/getStatus.js +2 -0
- package/dist/http/routes/getStatus.js.map +1 -1
- package/dist/http/routes/index.d.ts +2 -8
- package/dist/http/routes/index.d.ts.map +1 -1
- package/dist/http/routes/index.js +45 -6
- package/dist/http/routes/index.js.map +1 -1
- 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 +161 -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/postCodeEdit.d.ts +3 -0
- package/dist/http/routes/postCodeEdit.d.ts.map +1 -0
- package/dist/http/routes/postCodeEdit.js +26 -0
- package/dist/http/routes/postCodeEdit.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 +2 -2
- package/dist/http/routes/postDomClick.d.ts.map +1 -1
- package/dist/http/routes/postDomClick.js +47 -61
- 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 +19 -9
- package/dist/http/routes/postDomFill.js.map +1 -1
- package/dist/http/routes/postDomFocus.d.ts +1 -2
- package/dist/http/routes/postDomFocus.d.ts.map +1 -1
- package/dist/http/routes/postDomFocus.js +11 -28
- package/dist/http/routes/postDomFocus.js.map +1 -1
- package/dist/http/routes/postDomHover.d.ts +1 -2
- package/dist/http/routes/postDomHover.d.ts.map +1 -1
- package/dist/http/routes/postDomHover.js +11 -28
- 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 +1 -1
- 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 +1 -1
- package/dist/http/routes/postDomScrollTo.js.map +1 -1
- package/dist/http/routes/postEval.d.ts.map +1 -1
- package/dist/http/routes/postEval.js +13 -0
- package/dist/http/routes/postEval.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 +15 -0
- package/dist/http/routes/postNetClear.js.map +1 -0
- package/dist/http/routes/postScreenshot.d.ts.map +1 -1
- package/dist/http/routes/postScreenshot.js +35 -1
- package/dist/http/routes/postScreenshot.js.map +1 -1
- 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/postVisibility.d.ts +3 -0
- package/dist/http/routes/postVisibility.d.ts.map +1 -0
- package/dist/http/routes/postVisibility.js +29 -0
- package/dist/http/routes/postVisibility.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 +36 -10
- 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/watcherServices.d.ts.map +1 -1
- package/dist/runtime/watcherServices.js +16 -4
- package/dist/runtime/watcherServices.js.map +1 -1
- package/dist/runtime/watcherSetup.d.ts +4 -0
- package/dist/runtime/watcherSetup.d.ts.map +1 -1
- package/dist/runtime/watcherSetup.js +5 -0
- package/dist/runtime/watcherSetup.js.map +1 -1
- 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-delegating-session.d.ts +15 -2
- package/dist/sources/extension-delegating-session.d.ts.map +1 -1
- package/dist/sources/extension-delegating-session.js +16 -4
- package/dist/sources/extension-delegating-session.js.map +1 -1
- package/dist/sources/extension-frame-runtime.d.ts.map +1 -1
- package/dist/sources/extension-frame-runtime.js +35 -6
- package/dist/sources/extension-frame-runtime.js.map +1 -1
- package/dist/sources/extension-frame-state.d.ts +21 -2
- package/dist/sources/extension-frame-state.d.ts.map +1 -1
- package/dist/sources/extension-frame-state.js +63 -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 +204 -50
- package/dist/sources/extension-source.js.map +1 -1
- package/dist/sources/types.d.ts +29 -1
- package/dist/sources/types.d.ts.map +1 -1
- package/dist/startWatcherRuntime.d.ts.map +1 -1
- package/dist/startWatcherRuntime.js +72 -2
- package/dist/startWatcherRuntime.js.map +1 -1
- package/dist/visibility/VisibilityController.d.ts +27 -0
- package/dist/visibility/VisibilityController.d.ts.map +1 -0
- package/dist/visibility/VisibilityController.js +48 -0
- package/dist/visibility/VisibilityController.js.map +1 -0
- package/package.json +2 -2
- 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.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CAAC,kBAAkB;KAC1C,CAAC;CACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { DomNodeHandle } from '../../cdp/dom/selector.js';
|
|
2
|
+
import type { WatcherRouteDefinition } from './defineRoute.js';
|
|
3
|
+
import type { RouteContext } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Body shape required by `defineDomTargetRoute`. Routes that need extra fields
|
|
6
|
+
* (e.g. `wait`, `value`) extend this type.
|
|
7
|
+
*/
|
|
8
|
+
export type DomTargetRequestBody = {
|
|
9
|
+
selector?: string;
|
|
10
|
+
ref?: string;
|
|
11
|
+
all?: boolean;
|
|
12
|
+
text?: string;
|
|
13
|
+
};
|
|
14
|
+
type DomTargetRouteInput<TBody extends DomTargetRequestBody, TExtra extends object> = {
|
|
15
|
+
method?: 'POST';
|
|
16
|
+
path: string;
|
|
17
|
+
/** Endpoint label used by `emitRequest`. */
|
|
18
|
+
endpoint: string;
|
|
19
|
+
/**
|
|
20
|
+
* Verb used in the "Selector matched N elements; pass all=true to {action}…"
|
|
21
|
+
* error message returned when the request matches more than one node and
|
|
22
|
+
* `all` is false.
|
|
23
|
+
*/
|
|
24
|
+
action: string;
|
|
25
|
+
/**
|
|
26
|
+
* Run the DOM action against the resolved handles. Receives both the
|
|
27
|
+
* "filtered" handles (subject to `text`/`all`) and `allHandles` for routes
|
|
28
|
+
* that want to report total matches separately. Returns the action-specific
|
|
29
|
+
* fields that go alongside `{ ok, matches }` in the response.
|
|
30
|
+
*
|
|
31
|
+
* Called even when `allHandles` is empty (downstream actions are no-ops on
|
|
32
|
+
* empty arrays) so the route response shape stays consistent.
|
|
33
|
+
*/
|
|
34
|
+
run: (input: {
|
|
35
|
+
handles: DomNodeHandle[];
|
|
36
|
+
allHandles: DomNodeHandle[];
|
|
37
|
+
payload: TBody;
|
|
38
|
+
ctx: RouteContext;
|
|
39
|
+
}) => Promise<TExtra> | TExtra;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Build a `WatcherRouteDefinition` for routes that resolve an element target
|
|
43
|
+
* (selector/ref + text/all) and perform a DOM action.
|
|
44
|
+
*
|
|
45
|
+
* Centralizes the body-parse → emit → resolve → handle multiple/missing
|
|
46
|
+
* → run → respond pipeline shared by hover/focus and similar routes.
|
|
47
|
+
*/
|
|
48
|
+
export declare const defineDomTargetRoute: <TBody extends DomTargetRequestBody, TExtra extends object>(input: DomTargetRouteInput<TBody, TExtra>) => WatcherRouteDefinition;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=defineDomTargetRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineDomTargetRoute.d.ts","sourceRoot":"","sources":["../../../src/http/routes/defineDomTargetRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAM9C;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,mBAAmB,CAAC,KAAK,SAAS,oBAAoB,EAAE,MAAM,SAAS,MAAM,IAAI;IACrF,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;;;;;;OAQG;IACH,GAAG,EAAE,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,aAAa,EAAE,CAAC;QAAC,UAAU,EAAE,aAAa,EAAE,CAAC;QAAC,OAAO,EAAE,KAAK,CAAC;QAAC,GAAG,EAAE,YAAY,CAAA;KAAE,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;CACtI,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,KAAK,SAAS,oBAAoB,EAAE,MAAM,SAAS,MAAM,EAC7F,OAAO,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,KACvC,sBAiCD,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { resolveElementTargets } from '../../cdp/dom/selector.js';
|
|
2
|
+
import { respondError, respondJson } from '../httpUtils.js';
|
|
3
|
+
import { readDomTargetPayload, respondMissingElementRef, respondMultipleMatches, respondTargetResolutionError } from './domSelectorRoute.js';
|
|
4
|
+
import { emitRequest } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Build a `WatcherRouteDefinition` for routes that resolve an element target
|
|
7
|
+
* (selector/ref + text/all) and perform a DOM action.
|
|
8
|
+
*
|
|
9
|
+
* Centralizes the body-parse → emit → resolve → handle multiple/missing
|
|
10
|
+
* → run → respond pipeline shared by hover/focus and similar routes.
|
|
11
|
+
*/
|
|
12
|
+
export const defineDomTargetRoute = (input) => ({
|
|
13
|
+
method: input.method ?? 'POST',
|
|
14
|
+
path: input.path,
|
|
15
|
+
handler: async (req, res, _url, ctx) => {
|
|
16
|
+
const parsed = await readDomTargetPayload(req, res);
|
|
17
|
+
if (!parsed)
|
|
18
|
+
return;
|
|
19
|
+
const { payload, all } = parsed;
|
|
20
|
+
emitRequest(ctx, res, input.endpoint);
|
|
21
|
+
try {
|
|
22
|
+
const resolved = await resolveElementTargets(ctx.cdpSession, ctx.elementRefs, {
|
|
23
|
+
selector: payload.selector,
|
|
24
|
+
ref: payload.ref,
|
|
25
|
+
all,
|
|
26
|
+
text: payload.text,
|
|
27
|
+
});
|
|
28
|
+
if (resolved.missingRef && payload.ref) {
|
|
29
|
+
return respondMissingElementRef(res, payload.ref);
|
|
30
|
+
}
|
|
31
|
+
const { allHandles, handles } = resolved;
|
|
32
|
+
if (!all && allHandles.length > 1) {
|
|
33
|
+
return respondMultipleMatches(res, allHandles.length, input.action);
|
|
34
|
+
}
|
|
35
|
+
const extra = await input.run({ handles, allHandles, payload, ctx });
|
|
36
|
+
respondJson(res, { ok: true, matches: allHandles.length, ...extra });
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
if (respondTargetResolutionError(res, error))
|
|
40
|
+
return;
|
|
41
|
+
respondError(res, error);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=defineDomTargetRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineDomTargetRoute.js","sourceRoot":"","sources":["../../../src/http/routes/defineDomTargetRoute.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAA;AAC5I,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAoCxC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CACnC,KAAyC,EAChB,EAAE,CAAC,CAAC;IAC7B,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,MAAM;IAC9B,IAAI,EAAE,KAAK,CAAC,IAAI;IAChB,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QACtC,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAQ,GAAG,EAAE,GAAG,CAAC,CAAA;QAC1D,IAAI,CAAC,MAAM;YAAE,OAAM;QAEnB,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,MA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
+
import type { HttpRequestEventMetadata } from '../server.js';
|
|
3
|
+
import type { ProtocolSchema } from '@vforsh/argus-core';
|
|
4
|
+
import type { RouteContext, RouteHandler } from './types.js';
|
|
5
|
+
export type WatcherRouteDefinition = {
|
|
6
|
+
method: 'GET' | 'POST';
|
|
7
|
+
path: string;
|
|
8
|
+
handler: RouteHandler;
|
|
9
|
+
extensionOnly?: boolean;
|
|
10
|
+
};
|
|
11
|
+
type JsonRouteInput<TBody, TResponse extends object> = {
|
|
12
|
+
method: 'GET' | 'POST';
|
|
13
|
+
path: string;
|
|
14
|
+
bodySchema?: ProtocolSchema<TBody>;
|
|
15
|
+
endpoint?: HttpRequestEventMetadata['endpoint'];
|
|
16
|
+
extensionOnly?: boolean;
|
|
17
|
+
handle: (input: JsonRouteHandlerInput<TBody>) => Promise<TResponse | void> | TResponse | void;
|
|
18
|
+
handleError?: (res: http.ServerResponse, error: unknown) => boolean | void;
|
|
19
|
+
};
|
|
20
|
+
export type JsonRouteHandlerInput<TBody> = {
|
|
21
|
+
req: http.IncomingMessage;
|
|
22
|
+
res: http.ServerResponse;
|
|
23
|
+
url: URL;
|
|
24
|
+
ctx: RouteContext;
|
|
25
|
+
body: TBody;
|
|
26
|
+
};
|
|
27
|
+
/** Build a JSON route with common body parsing, schema validation, event emission, and error handling. */
|
|
28
|
+
export declare const defineJsonRoute: <TBody = undefined, TResponse extends object = object>(input: JsonRouteInput<TBody, TResponse>) => WatcherRouteDefinition;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=defineRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineRoute.d.ts","sourceRoot":"","sources":["../../../src/http/routes/defineRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAA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
import { formatProtocolValidationIssues } from '@vforsh/argus-core';
|
|
2
|
+
import { readJsonBody, respondError, respondInvalidBody, respondJson } from '../httpUtils.js';
|
|
3
|
+
import { emitRequest } from './types.js';
|
|
4
|
+
/** Build a JSON route with common body parsing, schema validation, event emission, and error handling. */
|
|
5
|
+
export const defineJsonRoute = (input) => ({
|
|
6
|
+
method: input.method,
|
|
7
|
+
path: input.path,
|
|
8
|
+
extensionOnly: input.extensionOnly,
|
|
9
|
+
handler: async (req, res, url, ctx) => {
|
|
10
|
+
const rawBody = input.bodySchema ? await readJsonBody(req, res) : undefined;
|
|
11
|
+
if (input.bodySchema && rawBody == null) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const parsedBody = input.bodySchema?.parse(rawBody);
|
|
15
|
+
if (parsedBody && !parsedBody.ok) {
|
|
16
|
+
return respondInvalidBody(res, formatProtocolValidationIssues(parsedBody.issues));
|
|
17
|
+
}
|
|
18
|
+
if (input.endpoint) {
|
|
19
|
+
emitRequest(ctx, res, input.endpoint);
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const response = await input.handle({
|
|
23
|
+
req,
|
|
24
|
+
res,
|
|
25
|
+
url,
|
|
26
|
+
ctx,
|
|
27
|
+
body: parsedBody?.value,
|
|
28
|
+
});
|
|
29
|
+
if (response) {
|
|
30
|
+
respondJson(res, response);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (input.handleError?.(res, error)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
respondError(res, error);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=defineRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineRoute.js","sourceRoot":"","sources":["../../../src/http/routes/defineRoute.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAA;AACnE,OA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EAAE,QAAQ,CAAC,CAAA;YAC3B,CAAC;QACF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC;gBACrC,OAAM;YACP,CAAC;YACD,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACzB,CAAC;IACF,CAAC;CACD,CAAC,CAAA"}
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import type http from 'node:http';
|
|
2
2
|
type SelectorPayload = {
|
|
3
3
|
selector?: unknown;
|
|
4
|
+
ref?: unknown;
|
|
4
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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,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,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CAAA;IAC7E,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAA;IACb,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,mEAAmE,CAAA;IAC7I,WAAW,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;IAC7E,OAAO,IAAI,CAAA;AACZ,CAAC,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getExtensionTabs.d.ts","sourceRoot":"","sources":["../../../src/http/routes/getExtensionTabs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAI9C,eAAO,MAAM,MAAM,EAAE,YAmBpB,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { emitRequest } from './types.js';
|
|
2
|
+
import { normalizeQueryValue, respondError, respondJson } from '../httpUtils.js';
|
|
3
|
+
export const handle = async (_req, res, url, ctx) => {
|
|
4
|
+
if (!ctx.sourceHandle?.listTabs) {
|
|
5
|
+
return respondJson(res, { ok: false, error: { message: 'Not available', code: 'not_available' } }, 400);
|
|
6
|
+
}
|
|
7
|
+
emitRequest(ctx, res, 'tabs', {
|
|
8
|
+
url: url.searchParams.get('url') ?? undefined,
|
|
9
|
+
title: url.searchParams.get('title') ?? undefined,
|
|
10
|
+
});
|
|
11
|
+
try {
|
|
12
|
+
const tabs = await ctx.sourceHandle.listTabs({
|
|
13
|
+
url: normalizeQueryValue(url.searchParams.get('url')),
|
|
14
|
+
title: normalizeQueryValue(url.searchParams.get('title')),
|
|
15
|
+
});
|
|
16
|
+
respondJson(res, { ok: true, tabs });
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
respondError(res, error);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=getExtensionTabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getExtensionTabs.js","sourceRoot":"","sources":["../../../src/http/routes/getExtensionTabs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,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,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,EAAE,CAAC;QACjC,OAAO,WAAW,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;IACxG,CAAC;IAED,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE;QAC7B,GAAG,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,SAAS;QAC7C,KAAK,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,SAAS;KACjD,CAAC,CAAA;IAEF,IAAI,CAAC;QACJ,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC;YAC5C,GAAG,EAAE,mBAAmB,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACrD,KAAK,EAAE,mBAAmB,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;SACzD,CAAC,CAAA;QACF,WAAW,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAkC,CAAC,CAAA;IACrE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IACzB,CAAC;AACF,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":["../../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AAE,GAAG,CAAC,CAAA;IACvI,CAAC;IAED,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,sBAAsB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;IAEnE,MAAM,QAAQ,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
|