@jshookmcp/jshook 0.2.9 → 0.3.0
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 +2 -2
- package/README.zh.md +2 -2
- package/dist/{AntiCheatDetector-BNk-EoBt.mjs → AntiCheatDetector-CqGDXmfc.mjs} +159 -53
- package/dist/{CodeInjector-Cq8q01kp.mjs → CodeInjector-BdjRfNx7.mjs} +5 -5
- package/dist/{ConsoleMonitor-CPVQW1Y-.mjs → ConsoleMonitor-DykL3IAw.mjs} +85 -17
- package/dist/{DetailedDataManager-BQQcxh64.mjs → DetailedDataManager-HT49OrvF.mjs} +1 -1
- package/dist/{ExtensionManager-CWYgw0YW.mjs → ExtensionManager-BDMsY2Dz.mjs} +15 -8
- package/dist/{HardwareBreakpoint-B9gZCdFP.mjs → HardwareBreakpoint-Cc2AFq1Y.mjs} +3 -3
- package/dist/{HeapAnalyzer-BLDH0dCv.mjs → HeapAnalyzer-DruMgsgj.mjs} +20 -20
- package/dist/{HookGeneratorBuilders.core.generators.storage-CtcdK78Q.mjs → HookGeneratorBuilders.core.generators.storage-CTbB4Lcx.mjs} +1 -74
- package/dist/{InstrumentationSession-CvPC7Jwy.mjs → InstrumentationSession-DLH0vd-z.mjs} +2 -2
- package/dist/{MemoryController-CbVdCIJF.mjs → MemoryController-CMtviNW_.mjs} +3 -3
- package/dist/{MemoryScanSession-BsDZbLYm.mjs → MemoryScanSession-ITgb_NMi.mjs} +2 -2
- package/dist/{MemoryScanner-Bcpml6II.mjs → MemoryScanner-CiL7Z3ey.mjs} +12 -9
- package/dist/{NativeMemoryManager.impl-dZtA1ZGn.mjs → NativeMemoryManager.impl-D9Lkovvn.mjs} +13 -10
- package/dist/{NativeMemoryManager.utils-B-FjA2mJ.mjs → NativeMemoryManager.utils-BBlAixF5.mjs} +1 -1
- package/dist/{PEAnalyzer-D1lzJ_VG.mjs → PEAnalyzer-DMQ44gen.mjs} +15 -15
- package/dist/{PageController-Bqm2kZ_X.mjs → PageController-BPJNqqBN.mjs} +18 -4
- package/dist/{PointerChainEngine-BOhyVsjx.mjs → PointerChainEngine-K7wN8Z-w.mjs} +10 -7
- package/dist/ProcessRegistry-zGg12QbE.mjs +74 -0
- package/dist/{ResponseBuilder-D3iFYx2N.mjs → ResponseBuilder-CJXWmWNw.mjs} +10 -10
- package/dist/{ScriptManager-aHHq0X7U.mjs → ScriptManager-ZuWD-0Jg.mjs} +195 -192
- package/dist/{Speedhack-CqdIFlQl.mjs → Speedhack-D-z0umeT.mjs} +2 -2
- package/dist/{StructureAnalyzer-DhFaPvRO.mjs → StructureAnalyzer-Cav5AVSL.mjs} +9 -6
- package/dist/{ToolCatalog-C0JGZoOm.mjs → ToolCatalog-5OJdMiF0.mjs} +81 -81
- package/dist/{ToolProbe-oC7aPrkv.mjs → ToolProbe-DbCFGyrg.mjs} +1 -1
- package/dist/{ToolRegistry-BjaF4oNz.mjs → ToolRegistry-B9krbTtI.mjs} +51 -2
- package/dist/{ToolRouter.policy-BWV67ZK-.mjs → ToolRouter.policy-BGDAGyeH.mjs} +60 -20
- package/dist/TraceRecorder-B41Z5XBj.mjs +1286 -0
- package/dist/{Win32API-CePkipZY.mjs → Win32API-C2kjj0ze.mjs} +18 -12
- package/dist/{Win32Debug-BvKs-gxc.mjs → Win32Debug-CKrGOTpo.mjs} +2 -2
- package/dist/{WorkflowEngine-CuvkZtWu.mjs → WorkflowEngine-DJ6M4opp.mjs} +226 -255
- package/dist/analysis-BHeJW2Nb.mjs +1234 -0
- package/dist/{antidebug-CqDTB_uk.mjs → antidebug-BRKeyt27.mjs} +3 -3
- package/dist/{artifactRetention-CFEprwPw.mjs → artifactRetention-CPXkUJXp.mjs} +13 -6
- package/dist/{artifacts-Bk2-_uPq.mjs → artifacts-DkfosXH3.mjs} +1 -1
- package/dist/authorization-schema-DRqyJMSk.mjs +31 -0
- package/dist/{binary-instrument-CXfpx6fT.mjs → binary-instrument--V3MAhJ4.mjs} +19 -27
- package/dist/bind-helpers-ClV34xdn.mjs +42 -0
- package/dist/{boringssl-inspector-BH2D3VKc.mjs → boringssl-inspector-Bo_LOLaS.mjs} +1 -1
- package/dist/{browser-BpOr5PEx.mjs → browser-Dx3_S2cG.mjs} +324 -37
- package/dist/capabilities-CcHlvWgK.mjs +33 -0
- package/dist/{constants-B0OANIBL.mjs → constants-CDZLOoVv.mjs} +18 -3
- package/dist/{coordination-qUbyF8KU.mjs → coordination-DgItD9DL.mjs} +2 -2
- package/dist/{debugger-gnKxRSN0.mjs → debugger-RS3RSAqs.mjs} +30 -13
- package/dist/definitions-BEoYofW5.mjs +47 -0
- package/dist/{definitions-bAhHQJq9.mjs → definitions-BRaefg3u.mjs} +11 -5
- package/dist/{definitions-DVGfrn7y.mjs → definitions-BbkvZkiv.mjs} +2 -2
- package/dist/definitions-BtWSHJ3o.mjs +17 -0
- package/dist/{definitions-BMfYXoNC.mjs → definitions-C1gCHO0i.mjs} +1 -1
- package/dist/{definitions-C1UvM5Iy.mjs → definitions-CDOg_b-l.mjs} +14 -2
- package/dist/definitions-CVPD9hzZ.mjs +54 -0
- package/dist/{definitions-Cke7zEb8.mjs → definitions-Cea8Lgl7.mjs} +1 -1
- package/dist/definitions-DAgIyjxM.mjs +10 -0
- package/dist/{definitions-B4rAvHNZ.mjs → definitions-DJA27nsL.mjs} +12 -9
- package/dist/{definitions-ClJLzsJQ.mjs → definitions-DKPFU3LW.mjs} +1 -1
- package/dist/{definitions-D3VsGcvz.mjs → definitions-DPRpZQ96.mjs} +7 -7
- package/dist/{definitions-B18eyf0B.mjs → definitions-DUE5gmdn.mjs} +1 -1
- package/dist/definitions-DYVjOtxa.mjs +26 -0
- package/dist/{definitions-BB_4jnmy.mjs → definitions-DcYLVLCo.mjs} +1 -1
- package/dist/{definitions-Beid2EB3.mjs → definitions-Pp5LI2H4.mjs} +1 -1
- package/dist/definitions-j9KdHVNR.mjs +14 -0
- package/dist/definitions-uzkjBwa7.mjs +258 -0
- package/dist/{definitions-Cq-zroAU.mjs → definitions-va-AnLuQ.mjs} +4 -4
- package/dist/{encoding-Bvz5jLRv.mjs → encoding-DJeqHmpd.mjs} +18 -4
- package/dist/{evidence-graph-bridge-C_fv9PuC.mjs → evidence-graph-bridge-DcYizFk2.mjs} +1 -0
- package/dist/{factory-DxlGh9Xf.mjs → factory-C90tBff6.mjs} +6 -6
- package/dist/flat-target-session-Dgax2Cy3.mjs +29 -0
- package/dist/{graphql-DYWzJ29s.mjs → graphql-CoHrhweh.mjs} +205 -34
- package/dist/{handlers-C67ktuRN.mjs → handlers-4jmR0nMs.mjs} +220 -32
- package/dist/{handlers-DlCJN4Td.mjs → handlers-BAHPxcch.mjs} +122 -90
- package/dist/{handlers-9sAbfIg-.mjs → handlers-BOs9b907.mjs} +849 -801
- package/dist/{handlers-DxGIq15_2.mjs → handlers-BWXEy6ef.mjs} +16 -16
- package/dist/{handlers-tB9Mp9ZK.mjs → handlers-Bndn6QvE.mjs} +31 -4
- package/dist/{handlers-CTsDAO6p.mjs → handlers-BqC4bD4s.mjs} +1 -1
- package/dist/{handlers-C87g8oCe.mjs → handlers-BtYq60bM2.mjs} +1 -1
- package/dist/{handlers-DeLOCd5m.mjs → handlers-BzgcB4iv.mjs} +17 -17
- package/dist/{handlers-Cgyg6c0U.mjs → handlers-CRyRWj2b.mjs} +237 -23
- package/dist/{handlers-U6L4xhuF.mjs → handlers-CVv2H1uq.mjs} +24 -17
- package/dist/{handlers-tiy7EIBp.mjs → handlers-Dl5a7JS4.mjs} +3 -3
- package/dist/{handlers-D6j6yka7.mjs → handlers-Dx2d7jt7.mjs} +1893 -1480
- package/dist/{handlers-Bl8zkwz1.mjs → handlers-Dz9PYsCa.mjs} +95 -6
- package/dist/handlers-HujRKC3b.mjs +661 -0
- package/dist/{handlers.impl-DS0d9fUw.mjs → handlers.impl-XWXkQfyi.mjs} +70 -24
- package/dist/{hooks-CzCWByww.mjs → hooks-B1B8NRHL.mjs} +3 -3
- package/dist/index.mjs +154 -144
- package/dist/{maintenance-P7ePRXQC.mjs → maintenance-PRMkLVRW.mjs} +35 -30
- package/dist/manifest-67Bok-Si.mjs +58 -0
- package/dist/{manifest-B3QVVeBS.mjs → manifest-6lNTMZAB2.mjs} +33 -28
- package/dist/manifest-B2duEHiH.mjs +90 -0
- package/dist/manifest-B6EY9Vm8.mjs +57 -0
- package/dist/{manifest-gZ4s_UtG.mjs → manifest-B6nKSbyY.mjs} +32 -33
- package/dist/{manifest-2ToTpjv8.mjs → manifest-BL8AQNPF.mjs} +31 -31
- package/dist/{manifest-DzwvxPJX.mjs → manifest-BSZvJJmV.mjs} +23 -14
- package/dist/{manifest-Sc_0JQ13.mjs → manifest-BU7qzUyX.mjs} +23 -23
- package/dist/{manifest-CT7zZBV1.mjs → manifest-Bl62e8WK.mjs} +24 -23
- package/dist/manifest-Bo5cXjdt.mjs +82 -0
- package/dist/manifest-BpS4gtUK.mjs +1347 -0
- package/dist/manifest-Bv65_e2W.mjs +101 -0
- package/dist/manifest-BytNIF4Z.mjs +117 -0
- package/dist/{manifest-BqrQ4Tpj.mjs → manifest-C-xtsjS3.mjs} +23 -23
- package/dist/{manifest-NXctwWQq.mjs → manifest-CDYl7OhA.mjs} +36 -38
- package/dist/manifest-CRZ3xmkD.mjs +61 -0
- package/dist/manifest-CoW6u4Tp.mjs +132 -0
- package/dist/manifest-Cq5zN_8A.mjs +50 -0
- package/dist/{manifest-CAhOuvSl.mjs → manifest-D7YZM_2e.mjs} +75 -85
- package/dist/{manifest-DCyjf4n2.mjs → manifest-DE_VrAeQ.mjs} +27 -7
- package/dist/manifest-DGsXSCpT.mjs +39 -0
- package/dist/{manifest-BB2J8IMJ.mjs → manifest-DJ2vfEuW.mjs} +48 -41
- package/dist/{manifest-3g71z6Bg.mjs → manifest-DPXDYhEu.mjs} +26 -25
- package/dist/manifest-Dd4fQb0a.mjs +322 -0
- package/dist/{manifest-CXsRWjjI.mjs → manifest-Deq6opGg.mjs} +95 -96
- package/dist/{manifest-C9RT5nk32.mjs → manifest-DfJTafJK.mjs} +14 -11
- package/dist/manifest-DgOdgN_j.mjs +50 -0
- package/dist/{manifest-BmtZzQiQ2.mjs → manifest-DlbMW4v4.mjs} +17 -15
- package/dist/{manifest-DrbmZcFl2.mjs → manifest-DmVfbH0w.mjs} +212 -91
- package/dist/manifest-Dog6Ddjr.mjs +109 -0
- package/dist/manifest-DvgU5FWb.mjs +58 -0
- package/dist/manifest-HsfDBs7j.mjs +50 -0
- package/dist/manifest-I8oQHvCG.mjs +186 -0
- package/dist/manifest-NvH_a-av.mjs +786 -0
- package/dist/{manifest-Dh8WBmEW.mjs → manifest-cEJU1v0Z.mjs} +24 -24
- package/dist/manifest-wOl5XLB12.mjs +112 -0
- package/dist/{modules-C184v-S9.mjs → modules-tZozf0LQ.mjs} +130 -860
- package/dist/{mojo-ipc-B_H61Afw.mjs → mojo-ipc-DXNEXEqb.mjs} +141 -26
- package/dist/{network-671Cw6hV.mjs → network-CPVvwvFg.mjs} +1329 -823
- package/dist/{outputPaths-B1uGmrWZ.mjs → outputPaths-um7lCRY3.mjs} +4 -8
- package/dist/{platform-WmNn8Sxb.mjs → platform-CYeFoTWp.mjs} +101 -10
- package/dist/{process-QcbIy5Zq.mjs → process-BTbgcVc6.mjs} +251 -346
- package/dist/{proxy-DqNs0bAd.mjs → proxy-r8YN6nP1.mjs} +30 -8
- package/dist/{registry-D-6e18lB.mjs → registry-Bl8ZQW61.mjs} +3 -3
- package/dist/{response-BQVP-xUn.mjs → response-CWhh2aLo.mjs} +7 -1
- package/dist/{shared-state-board-DV-dpHFJ.mjs → shared-state-board-BoZnSoj-.mjs} +2 -2
- package/dist/{sourcemap-Dq8ez8vS.mjs → sourcemap-BIDHUVXy.mjs} +350 -66
- package/dist/{streaming-BUQ0VJsg.mjs → streaming-Dal6utPp.mjs} +13 -13
- package/dist/{tool-builder-DCbIC5Eo.mjs → tool-builder-BHJp32mV.mjs} +1 -1
- package/dist/{transform-CiYJfNX0.mjs → transform-DRVgGG90.mjs} +18 -14
- package/dist/wasm-BYx5UOeG.mjs +1044 -0
- package/dist/webcrack-Be0_FccV.mjs +747 -0
- package/dist/{workflow-f3xJOcjx.mjs → workflow-BpuKEtvn.mjs} +8 -8
- package/package.json +76 -43
- package/dist/TraceRecorder-DgxyVbdQ.mjs +0 -519
- package/dist/analysis-CL9uACt9.mjs +0 -463
- package/dist/bind-helpers-xFfRF-qm.mjs +0 -22
- package/dist/definitions-6M-eejaT.mjs +0 -53
- package/dist/definitions-B3QdlrHv.mjs +0 -34
- package/dist/definitions-CXEI7QC72.mjs +0 -216
- package/dist/definitions-C_4r7Fo-2.mjs +0 -14
- package/dist/definitions-CkFDALoa.mjs +0 -26
- package/dist/definitions-Cy3Sl6gV.mjs +0 -34
- package/dist/definitions-LKpC3-nL.mjs +0 -9
- package/dist/handlers-DdFzXLvF.mjs +0 -446
- package/dist/manifest-82baTv4U.mjs +0 -45
- package/dist/manifest-BKbgbSiY.mjs +0 -60
- package/dist/manifest-Bcf-TJzH.mjs +0 -848
- package/dist/manifest-Bnd7kqEY.mjs +0 -55
- package/dist/manifest-BqQX6OQC2.mjs +0 -65
- package/dist/manifest-Br4RPFt5.mjs +0 -370
- package/dist/manifest-C5qDjysN.mjs +0 -107
- package/dist/manifest-CBYWCUBJ.mjs +0 -51
- package/dist/manifest-CFADCRa1.mjs +0 -37
- package/dist/manifest-CQVhavRF.mjs +0 -114
- package/dist/manifest-CV12bcrF.mjs +0 -121
- package/dist/manifest-CZLUCfG02.mjs +0 -95
- package/dist/manifest-D6phHKFd.mjs +0 -131
- package/dist/manifest-DHsnKgP6.mjs +0 -60
- package/dist/manifest-Df_dliIe.mjs +0 -55
- package/dist/manifest-DhKRAT8_.mjs +0 -92
- package/dist/manifest-DlpTj4ic2.mjs +0 -193
- package/dist/manifest-DuwHjUa5.mjs +0 -70
- package/dist/manifest-qSleDqdO.mjs +0 -1023
- package/dist/wasm-DQTnHDs4.mjs +0 -531
- /package/dist/{CacheAdapters-CDe5WPSV.mjs → CacheAdapters-jJFy20G-.mjs} +0 -0
- /package/dist/{DarwinAPI-BNPxu0RH.mjs → DarwinAPI-ETyy0xyo.mjs} +0 -0
- /package/dist/{EventBus-DgPmwpeu.mjs → EventBus-DFKvADm3.mjs} +0 -0
- /package/dist/{EvidenceGraphBridge-SFesNera.mjs → EvidenceGraphBridge-318Oi0Lf.mjs} +0 -0
- /package/dist/{FingerprintManager-gzWtkKuf.mjs → FingerprintManager-BN4UQWnX.mjs} +0 -0
- /package/dist/{PrerequisiteError-Dl33Svkz.mjs → PrerequisiteError-TuyZIs6n.mjs} +0 -0
- /package/dist/{ReverseEvidenceGraph-Dlsk94LC.mjs → ReverseEvidenceGraph-C02-gXOh.mjs} +0 -0
- /package/dist/{StealthVerifier-Bo4T3bz8.mjs → StealthVerifier-BWmPgQsv.mjs} +0 -0
- /package/dist/{VersionDetector-CwVLVdDM.mjs → VersionDetector-K3V4vGsw.mjs} +0 -0
- /package/dist/{betterSqlite3-0pqusHHH.mjs → betterSqlite3-DLSBZodi.mjs} +0 -0
- /package/dist/{concurrency-Bt0yv1kJ.mjs → concurrency-Drev_Vz9.mjs} +0 -0
- /package/dist/{formatAddress-DVkj9kpI.mjs → formatAddress-nnMvEohD.mjs} +0 -0
- /package/dist/{parse-args-BlRjqlkL.mjs → parse-args-B4cY5Vx5.mjs} +0 -0
- /package/dist/{ssrf-policy-ZaUfvhq7.mjs → ssrf-policy-Dsqd-DTX.mjs} +0 -0
- /package/dist/{types-CPhOReNX.mjs → types-DDBWs9UP.mjs} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as argString, i as argObject, t as argBool } from "./parse-args-
|
|
3
|
-
import { s as evaluateWithTimeout } from "./PageController-
|
|
4
|
-
import { c as isSsrfTarget } from "./ssrf-policy-
|
|
5
|
-
import "./definitions-
|
|
1
|
+
import { at as GRAPHQL_MAX_SCHEMA_CHARS, it as GRAPHQL_MAX_QUERY_CHARS, nt as GRAPHQL_MAX_GRAPH_NODES, rt as GRAPHQL_MAX_PREVIEW_CHARS, tt as GRAPHQL_MAX_GRAPH_EDGES } from "./constants-CDZLOoVv.mjs";
|
|
2
|
+
import { a as argString, i as argObject, t as argBool } from "./parse-args-B4cY5Vx5.mjs";
|
|
3
|
+
import { s as evaluateWithTimeout } from "./PageController-BPJNqqBN.mjs";
|
|
4
|
+
import { c as isSsrfTarget } from "./ssrf-policy-Dsqd-DTX.mjs";
|
|
5
|
+
import "./definitions-Pp5LI2H4.mjs";
|
|
6
6
|
//#region src/server/domains/graphql/handlers/shared.ts
|
|
7
7
|
function toResponse(payload) {
|
|
8
8
|
return { content: [{
|
|
@@ -60,17 +60,31 @@ function normalizeHeaders(value) {
|
|
|
60
60
|
}
|
|
61
61
|
return headers;
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
function parseEndpoint(endpoint) {
|
|
64
64
|
let parsedEndpoint;
|
|
65
65
|
try {
|
|
66
66
|
parsedEndpoint = new URL(endpoint);
|
|
67
67
|
} catch {
|
|
68
|
-
return `Invalid endpoint URL: ${endpoint}
|
|
68
|
+
return { error: `Invalid endpoint URL: ${endpoint}` };
|
|
69
69
|
}
|
|
70
|
-
if (parsedEndpoint.protocol !== "http:" && parsedEndpoint.protocol !== "https:") return `Unsupported endpoint protocol: ${parsedEndpoint.protocol} — only http/https allowed
|
|
71
|
-
|
|
70
|
+
if (parsedEndpoint.protocol !== "http:" && parsedEndpoint.protocol !== "https:") return { error: `Unsupported endpoint protocol: ${parsedEndpoint.protocol} — only http/https allowed` };
|
|
71
|
+
return { parsedEndpoint };
|
|
72
|
+
}
|
|
73
|
+
async function validateExternalEndpoint(endpoint) {
|
|
74
|
+
const parsed = parseEndpoint(endpoint);
|
|
75
|
+
if ("error" in parsed) return parsed.error;
|
|
76
|
+
if (await isSsrfTarget(parsed.parsedEndpoint.toString())) return `Blocked: endpoint "${endpoint}" resolves to a private/reserved address`;
|
|
72
77
|
return null;
|
|
73
78
|
}
|
|
79
|
+
async function validateBrowserEndpoint(endpoint, currentPageUrl) {
|
|
80
|
+
const parsed = parseEndpoint(endpoint);
|
|
81
|
+
if ("error" in parsed) return parsed.error;
|
|
82
|
+
if (!await isSsrfTarget(parsed.parsedEndpoint.toString())) return null;
|
|
83
|
+
if (typeof currentPageUrl === "string" && currentPageUrl.length > 0) try {
|
|
84
|
+
if (new URL(currentPageUrl).origin === parsed.parsedEndpoint.origin) return null;
|
|
85
|
+
} catch {}
|
|
86
|
+
return `Blocked: endpoint "${endpoint}" resolves to a private/reserved address`;
|
|
87
|
+
}
|
|
74
88
|
function createPreview(text, maxChars) {
|
|
75
89
|
if (text.length <= maxChars) return {
|
|
76
90
|
preview: text,
|
|
@@ -476,11 +490,16 @@ var IntrospectionHandlers = class {
|
|
|
476
490
|
try {
|
|
477
491
|
const endpoint = argString(args, "endpoint")?.trim();
|
|
478
492
|
if (!endpoint) return toError("Missing required argument: endpoint");
|
|
493
|
+
const headers = normalizeHeaders(args.headers);
|
|
494
|
+
if (argBool(args, "useBrowser", true)) {
|
|
495
|
+
const page = await this.collector.getActivePage();
|
|
496
|
+
const endpointValidationError = await validateBrowserEndpoint(endpoint, typeof page.url === "function" ? page.url() : null);
|
|
497
|
+
if (endpointValidationError) return toError(endpointValidationError);
|
|
498
|
+
return await this.introspectViaBrowser(page, endpoint, headers);
|
|
499
|
+
}
|
|
479
500
|
const endpointValidationError = await validateExternalEndpoint(endpoint);
|
|
480
501
|
if (endpointValidationError) return toError(endpointValidationError);
|
|
481
|
-
|
|
482
|
-
if (!argBool(args, "useBrowser", true)) return await this.introspectViaNode(endpoint, headers);
|
|
483
|
-
return await this.introspectViaBrowser(endpoint, headers);
|
|
502
|
+
return await this.introspectViaNode(endpoint, headers);
|
|
484
503
|
} catch (error) {
|
|
485
504
|
return toError(error);
|
|
486
505
|
}
|
|
@@ -555,8 +574,8 @@ var IntrospectionHandlers = class {
|
|
|
555
574
|
if (jsonRecord && Array.isArray(jsonRecord.errors)) payload.errors = jsonRecord.errors;
|
|
556
575
|
return toResponse(payload);
|
|
557
576
|
}
|
|
558
|
-
async introspectViaBrowser(endpoint, headers) {
|
|
559
|
-
const browserResult = await evaluateWithTimeout(
|
|
577
|
+
async introspectViaBrowser(page, endpoint, headers) {
|
|
578
|
+
const browserResult = await evaluateWithTimeout(page, async (input) => {
|
|
560
579
|
const requestHeaders = {
|
|
561
580
|
"content-type": "application/json",
|
|
562
581
|
...input.headers
|
|
@@ -653,14 +672,131 @@ var IntrospectionHandlers = class {
|
|
|
653
672
|
};
|
|
654
673
|
//#endregion
|
|
655
674
|
//#region src/server/domains/graphql/handlers/extract.ts
|
|
675
|
+
function isRecord(value) {
|
|
676
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
677
|
+
}
|
|
678
|
+
function appendGraphQLPayload(extracted, payload, metadata) {
|
|
679
|
+
if (!payload) return;
|
|
680
|
+
const queryRaw = payload.query;
|
|
681
|
+
if (typeof queryRaw !== "string" || queryRaw.trim().length === 0) return;
|
|
682
|
+
const operationNameRaw = payload.operationName;
|
|
683
|
+
const operationName = typeof operationNameRaw === "string" && operationNameRaw.trim().length > 0 ? operationNameRaw : queryRaw.match(/^\s*(query|mutation|subscription)\s+([A-Za-z0-9_]+)/)?.[2] ?? null;
|
|
684
|
+
extracted.push({
|
|
685
|
+
source: metadata.source,
|
|
686
|
+
url: metadata.url,
|
|
687
|
+
method: metadata.method,
|
|
688
|
+
operationName,
|
|
689
|
+
query: queryRaw,
|
|
690
|
+
variables: payload.variables ?? null,
|
|
691
|
+
timestamp: metadata.timestamp,
|
|
692
|
+
contentType: metadata.contentType
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
function parseBodyStringToPayload(rawBody) {
|
|
696
|
+
const trimmed = rawBody.trim();
|
|
697
|
+
if (!trimmed) return null;
|
|
698
|
+
try {
|
|
699
|
+
const parsed = JSON.parse(trimmed);
|
|
700
|
+
if (isRecord(parsed)) return parsed;
|
|
701
|
+
} catch {}
|
|
702
|
+
if (trimmed.includes("query=")) try {
|
|
703
|
+
const params = new URLSearchParams(trimmed);
|
|
704
|
+
const query = params.get("query");
|
|
705
|
+
if (query) {
|
|
706
|
+
const operationName = params.get("operationName");
|
|
707
|
+
const variablesRaw = params.get("variables");
|
|
708
|
+
let variables = null;
|
|
709
|
+
if (variablesRaw) try {
|
|
710
|
+
variables = JSON.parse(variablesRaw);
|
|
711
|
+
} catch {
|
|
712
|
+
variables = variablesRaw;
|
|
713
|
+
}
|
|
714
|
+
return {
|
|
715
|
+
query,
|
|
716
|
+
operationName,
|
|
717
|
+
variables
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
} catch {}
|
|
721
|
+
if (trimmed.startsWith("query ") || trimmed.startsWith("mutation ") || trimmed.startsWith("subscription ")) return { query: trimmed };
|
|
722
|
+
return null;
|
|
723
|
+
}
|
|
724
|
+
function getRequestHeaders(record) {
|
|
725
|
+
if (isRecord(record.headers)) return record.headers;
|
|
726
|
+
if (isRecord(record.requestHeaders)) return record.requestHeaders;
|
|
727
|
+
return {};
|
|
728
|
+
}
|
|
729
|
+
function getContentType(record) {
|
|
730
|
+
const headers = getRequestHeaders(record);
|
|
731
|
+
for (const [key, value] of Object.entries(headers)) if (key.toLowerCase() === "content-type") return typeof value === "string" ? value.toLowerCase() : String(value).toLowerCase();
|
|
732
|
+
return "";
|
|
733
|
+
}
|
|
734
|
+
function getBodyCandidates(record) {
|
|
735
|
+
const candidates = [record.body, record.postData];
|
|
736
|
+
if (isRecord(record.options)) candidates.push(record.options.body);
|
|
737
|
+
if (isRecord(record.request)) candidates.push(record.request.postData);
|
|
738
|
+
return candidates;
|
|
739
|
+
}
|
|
740
|
+
function extractQueriesFromRecords(records, source) {
|
|
741
|
+
const state = {
|
|
742
|
+
scannedRecords: 0,
|
|
743
|
+
extracted: []
|
|
744
|
+
};
|
|
745
|
+
if (!Array.isArray(records)) return state;
|
|
746
|
+
for (const item of records) {
|
|
747
|
+
if (!isRecord(item)) continue;
|
|
748
|
+
state.scannedRecords += 1;
|
|
749
|
+
const url = typeof item.url === "string" ? item.url : "";
|
|
750
|
+
const method = typeof item.method === "string" ? item.method : "POST";
|
|
751
|
+
const timestamp = typeof item.timestamp === "number" ? item.timestamp : null;
|
|
752
|
+
const contentType = getContentType(item);
|
|
753
|
+
for (const bodyCandidate of getBodyCandidates(item)) {
|
|
754
|
+
let payload = null;
|
|
755
|
+
if (isRecord(bodyCandidate)) payload = bodyCandidate;
|
|
756
|
+
else if (typeof bodyCandidate === "string") payload = parseBodyStringToPayload(bodyCandidate);
|
|
757
|
+
appendGraphQLPayload(state.extracted, payload, {
|
|
758
|
+
source,
|
|
759
|
+
url,
|
|
760
|
+
method,
|
|
761
|
+
timestamp,
|
|
762
|
+
contentType
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
if (contentType.includes("application/graphql") && typeof item.body === "string") appendGraphQLPayload(state.extracted, {
|
|
766
|
+
query: item.body,
|
|
767
|
+
variables: null,
|
|
768
|
+
operationName: null
|
|
769
|
+
}, {
|
|
770
|
+
source,
|
|
771
|
+
url,
|
|
772
|
+
method,
|
|
773
|
+
timestamp,
|
|
774
|
+
contentType
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
return state;
|
|
778
|
+
}
|
|
779
|
+
function dedupeExtractedQueries(items) {
|
|
780
|
+
const sorted = items.toSorted((left, right) => (right.timestamp ?? 0) - (left.timestamp ?? 0));
|
|
781
|
+
const deduped = [];
|
|
782
|
+
const seen = /* @__PURE__ */ new Set();
|
|
783
|
+
for (const item of sorted) {
|
|
784
|
+
const key = `${item.url}|${item.operationName ?? ""}|${item.query}|${JSON.stringify(item.variables)}`;
|
|
785
|
+
if (seen.has(key)) continue;
|
|
786
|
+
seen.add(key);
|
|
787
|
+
deduped.push(item);
|
|
788
|
+
}
|
|
789
|
+
return deduped;
|
|
790
|
+
}
|
|
656
791
|
var ExtractHandlers = class {
|
|
657
|
-
|
|
658
|
-
|
|
792
|
+
deps;
|
|
793
|
+
constructor(deps) {
|
|
794
|
+
this.deps = "collector" in deps ? deps : { collector: deps };
|
|
659
795
|
}
|
|
660
796
|
async handleGraphqlExtractQueries(args) {
|
|
661
797
|
try {
|
|
662
798
|
const limit = parseClampedNumber(args, "limit", 50, 1, 200);
|
|
663
|
-
const
|
|
799
|
+
const pageExtraction = await evaluateWithTimeout(await this.deps.collector.getActivePage(), (maxItems) => {
|
|
664
800
|
const globalScope = window;
|
|
665
801
|
const extracted = [];
|
|
666
802
|
let scannedRecords = 0;
|
|
@@ -751,8 +887,10 @@ var ExtractHandlers = class {
|
|
|
751
887
|
if (!Array.isArray(value)) return;
|
|
752
888
|
for (const item of value) if (item && typeof item === "object") processRequestRecord(item, source);
|
|
753
889
|
};
|
|
754
|
-
|
|
755
|
-
|
|
890
|
+
const fetchRequests = Array.isArray(globalScope.__fetchRequests) ? globalScope.__fetchRequests : typeof globalScope.__getFetchRequests === "function" ? globalScope.__getFetchRequests() : void 0;
|
|
891
|
+
const xhrRequests = Array.isArray(globalScope.__xhrRequests) ? globalScope.__xhrRequests : typeof globalScope.__getXHRRequests === "function" ? globalScope.__getXHRRequests() : void 0;
|
|
892
|
+
processArray(fetchRequests, "window.__fetchRequests");
|
|
893
|
+
processArray(xhrRequests, "window.__xhrRequests");
|
|
756
894
|
processArray(globalScope.__networkRequests, "window.__networkRequests");
|
|
757
895
|
const aiHooks = globalScope.__aiHooks;
|
|
758
896
|
if (aiHooks && typeof aiHooks === "object") for (const [hookName, hookRecords] of Object.entries(aiHooks)) {
|
|
@@ -775,7 +913,31 @@ var ExtractHandlers = class {
|
|
|
775
913
|
extracted: deduped.slice(0, maxItems)
|
|
776
914
|
};
|
|
777
915
|
}, limit);
|
|
778
|
-
|
|
916
|
+
let scannedRecords = pageExtraction.scannedRecords;
|
|
917
|
+
const combinedExtracted = [...pageExtraction.extracted];
|
|
918
|
+
if (this.deps.consoleMonitor) {
|
|
919
|
+
const fetchRequestsPromise = typeof this.deps.consoleMonitor.getFetchRequests === "function" ? this.deps.consoleMonitor.getFetchRequests().catch(() => []) : Promise.resolve([]);
|
|
920
|
+
const xhrRequestsPromise = typeof this.deps.consoleMonitor.getXHRRequests === "function" ? this.deps.consoleMonitor.getXHRRequests().catch(() => []) : Promise.resolve([]);
|
|
921
|
+
const [fetchRequests, xhrRequests] = await Promise.all([fetchRequestsPromise, xhrRequestsPromise]);
|
|
922
|
+
let networkRequests = [];
|
|
923
|
+
try {
|
|
924
|
+
networkRequests = typeof this.deps.consoleMonitor.getNetworkRequests === "function" ? this.deps.consoleMonitor.getNetworkRequests({ limit: 500 }) : [];
|
|
925
|
+
} catch {
|
|
926
|
+
networkRequests = [];
|
|
927
|
+
}
|
|
928
|
+
const fallbackExtractions = [
|
|
929
|
+
extractQueriesFromRecords(fetchRequests, "consoleMonitor.fetchRequests"),
|
|
930
|
+
extractQueriesFromRecords(xhrRequests, "consoleMonitor.xhrRequests"),
|
|
931
|
+
extractQueriesFromRecords(networkRequests, "consoleMonitor.networkRequests")
|
|
932
|
+
];
|
|
933
|
+
for (const fallback of fallbackExtractions) {
|
|
934
|
+
scannedRecords += fallback.scannedRecords;
|
|
935
|
+
combinedExtracted.push(...fallback.extracted);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
const dedupedExtracted = dedupeExtractedQueries(combinedExtracted);
|
|
939
|
+
const totalExtracted = Math.max(pageExtraction.totalExtracted, dedupedExtracted.length);
|
|
940
|
+
const queries = dedupedExtracted.slice(0, limit).map((item, index) => {
|
|
779
941
|
const queryPreview = createPreview(item.query, GRAPHQL_MAX_QUERY_CHARS);
|
|
780
942
|
const variablesPreview = serializeForPreview(item.variables, GRAPHQL_MAX_PREVIEW_CHARS);
|
|
781
943
|
const normalized = {
|
|
@@ -802,8 +964,8 @@ var ExtractHandlers = class {
|
|
|
802
964
|
success: true,
|
|
803
965
|
limit,
|
|
804
966
|
stats: {
|
|
805
|
-
scannedRecords
|
|
806
|
-
totalExtracted
|
|
967
|
+
scannedRecords,
|
|
968
|
+
totalExtracted,
|
|
807
969
|
returned: queries.length
|
|
808
970
|
},
|
|
809
971
|
queries
|
|
@@ -825,14 +987,19 @@ var ReplayHandlers = class {
|
|
|
825
987
|
const query = argString(args, "query");
|
|
826
988
|
if (!endpoint) return toError("Missing required argument: endpoint");
|
|
827
989
|
if (typeof query !== "string" || query.trim().length === 0) return toError("Missing required argument: query");
|
|
828
|
-
const endpointValidationError = await validateExternalEndpoint(endpoint);
|
|
829
|
-
if (endpointValidationError) return toError(endpointValidationError);
|
|
830
990
|
const variables = argObject(args, "variables") ?? {};
|
|
831
991
|
const operationNameRaw = argString(args, "operationName");
|
|
832
992
|
const operationName = operationNameRaw && operationNameRaw.trim().length > 0 ? operationNameRaw.trim() : null;
|
|
833
993
|
const headers = normalizeHeaders(args.headers);
|
|
834
|
-
if (
|
|
835
|
-
|
|
994
|
+
if (argBool(args, "useBrowser", true)) {
|
|
995
|
+
const page = await this.collector.getActivePage();
|
|
996
|
+
const endpointValidationError = await validateBrowserEndpoint(endpoint, typeof page.url === "function" ? page.url() : null);
|
|
997
|
+
if (endpointValidationError) return toError(endpointValidationError);
|
|
998
|
+
return await this.replayViaBrowser(page, endpoint, query, variables, operationName, headers);
|
|
999
|
+
}
|
|
1000
|
+
const endpointValidationError = await validateExternalEndpoint(endpoint);
|
|
1001
|
+
if (endpointValidationError) return toError(endpointValidationError);
|
|
1002
|
+
return await this.replayViaNode(endpoint, query, variables, operationName, headers);
|
|
836
1003
|
} catch (error) {
|
|
837
1004
|
return toError(error);
|
|
838
1005
|
}
|
|
@@ -885,8 +1052,8 @@ var ReplayHandlers = class {
|
|
|
885
1052
|
responseText = "";
|
|
886
1053
|
return toResponse(buildReplayPayloadFromJson(responseJson, endpoint, operationName, response.ok, response.status, response.statusText, responseHeaders));
|
|
887
1054
|
}
|
|
888
|
-
async replayViaBrowser(endpoint, query, variables, operationName, headers) {
|
|
889
|
-
const browserResult = await evaluateWithTimeout(
|
|
1055
|
+
async replayViaBrowser(page, endpoint, query, variables, operationName, headers) {
|
|
1056
|
+
const browserResult = await evaluateWithTimeout(page, async (input) => {
|
|
890
1057
|
const requestHeaders = {
|
|
891
1058
|
"content-type": "application/json",
|
|
892
1059
|
...input.headers
|
|
@@ -993,18 +1160,22 @@ function buildReplayPayloadFromJson(responseJson, endpoint, operationName, ok, s
|
|
|
993
1160
|
}
|
|
994
1161
|
//#endregion
|
|
995
1162
|
//#region src/server/domains/graphql/handlers.impl.ts
|
|
1163
|
+
function normalizeDependencies(deps) {
|
|
1164
|
+
return "collector" in deps ? deps : { collector: deps };
|
|
1165
|
+
}
|
|
996
1166
|
var GraphQLToolHandlers = class {
|
|
997
1167
|
callGraph;
|
|
998
1168
|
scriptReplace;
|
|
999
1169
|
introspection;
|
|
1000
1170
|
extract;
|
|
1001
1171
|
replay;
|
|
1002
|
-
constructor(
|
|
1003
|
-
|
|
1004
|
-
this.
|
|
1005
|
-
this.
|
|
1006
|
-
this.
|
|
1007
|
-
this.
|
|
1172
|
+
constructor(deps) {
|
|
1173
|
+
const normalized = normalizeDependencies(deps);
|
|
1174
|
+
this.callGraph = new CallGraphHandlers(normalized.collector);
|
|
1175
|
+
this.scriptReplace = new ScriptReplaceHandlers(normalized.collector);
|
|
1176
|
+
this.introspection = new IntrospectionHandlers(normalized.collector);
|
|
1177
|
+
this.extract = new ExtractHandlers(normalized);
|
|
1178
|
+
this.replay = new ReplayHandlers(normalized.collector);
|
|
1008
1179
|
}
|
|
1009
1180
|
async handleCallGraphAnalyze(args) {
|
|
1010
1181
|
return this.callGraph.handleCallGraphAnalyze(args);
|