@jshookmcp/jshook 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (311) hide show
  1. package/README.md +19 -4
  2. package/README.zh.md +19 -4
  3. package/dist/AntiCheatDetector-B-mz4DK_.mjs +1 -0
  4. package/dist/{BrowserSessionCoordinator-QIt3tetp.mjs → BrowserSessionCoordinator-Cdic8FsH.mjs} +1 -1
  5. package/dist/CodeAnalyzerDataFlow-a-NkwcaG.mjs +2 -0
  6. package/dist/CodeInjector-B099WO6x.mjs +1 -0
  7. package/dist/ConsoleMonitor-BZRqrBH-.mjs +306 -0
  8. package/dist/CpuEngine-BC8jayy9.mjs +1 -0
  9. package/dist/DartAotExecutor-B7WVTKsd.mjs +1 -0
  10. package/dist/DartAotLoader-BxdhW-K2.mjs +2 -0
  11. package/dist/DarwinAPI-DzojdfjF.mjs +1 -0
  12. package/dist/{DetailedDataManager-Z77fDl9Z.mjs → DetailedDataManager-Dgh402Gp.mjs} +2 -2
  13. package/dist/ExecutionSandbox-QbWQmzuC.mjs +45 -0
  14. package/dist/ExtensionManager.tools-D3h818Xs.mjs +1 -0
  15. package/dist/FingerprintManager-D9Zlr6be.mjs +1 -0
  16. package/dist/HardwareBreakpoint-C_lJ22bj.mjs +1 -0
  17. package/dist/HeapAnalyzer-bJbLvzp6.mjs +1 -0
  18. package/dist/HookPatternScanner-yx4vJ9sd.mjs +1 -0
  19. package/dist/InstrumentationSession-Cv1wikLA.mjs +1 -0
  20. package/dist/IntegrityScanner-BB7sw-SA.mjs +1 -0
  21. package/dist/JScramblerDeobfuscator-NVR5VatT.mjs +1 -0
  22. package/dist/MCPServer.activation.ttl-C2wOCMLV.mjs +1 -0
  23. package/dist/MCPServer.search.helpers-DlassAew.mjs +2 -0
  24. package/dist/MemoryController-CCsGuGJS.mjs +2 -0
  25. package/dist/{MemoryScanSession-zfoVZJB0.mjs → MemoryScanSession-BZ2A9Ph1.mjs} +1 -1
  26. package/dist/MemoryScanner-DAxsq7Sx.mjs +1 -0
  27. package/dist/NativeMemoryManager.impl-BIJzXMqH.mjs +1 -0
  28. package/dist/{NativeMemoryManager.utils-Bu8srMEF.mjs → NativeMemoryManager.utils-CMoul2an.mjs} +1 -1
  29. package/dist/PEAnalyzer-CB_kaTis.mjs +1 -0
  30. package/dist/PackerDeobfuscator-BpwGjxDL.mjs +7 -0
  31. package/dist/PointerChainEngine-B6SYv6ZM.mjs +1 -0
  32. package/dist/ProcessRegistry-C5W1Tkn9.mjs +1 -0
  33. package/dist/QuickJSSandbox-CIde-jzG.mjs +299 -0
  34. package/dist/{ResponseBuilder-nPXl_khE.mjs → ResponseBuilder-BLicSCjn.mjs} +1 -1
  35. package/dist/ReverseEvidenceGraph-DJzk0GQz.mjs +2 -0
  36. package/dist/ServerRuntimeState-DGXNv8Ji.mjs +1 -0
  37. package/dist/Speedhack-MGoeq1ZS.mjs +1 -0
  38. package/dist/StructureAnalyzer-CCTWAXR3.mjs +2 -0
  39. package/dist/ToolHandlerMap-C40EmuLT.mjs +1 -0
  40. package/dist/{ToolProbe-DQiREmNp.mjs → ToolProbe-B02GC3ZY.mjs} +1 -1
  41. package/dist/ToolRegistry-CzqQxFqf.mjs +1 -0
  42. package/dist/{ToolRouter.policy-UKBlFlbh.mjs → ToolRouter.policy-Bgb3S8jc.mjs} +2 -2
  43. package/dist/TraceRecorder-BfeCTQUj.mjs +407 -0
  44. package/dist/VMDeobfuscator-BHtkV850.mjs +1 -0
  45. package/dist/Win32API-G7QPyckq.mjs +1 -0
  46. package/dist/{Win32Debug-DwF8mQGm.mjs → Win32Debug-6yzmtv5b.mjs} +1 -1
  47. package/dist/allocation-track-CiI-CnaI.mjs +1 -0
  48. package/dist/analysis-CojUzwX-.mjs +27 -0
  49. package/dist/{antidebug-CsnpOR9z.mjs → antidebug-CgU84TE1.mjs} +1 -1
  50. package/dist/apk-DrPBsOq8.mjs +1 -0
  51. package/dist/artifactRetention-Bk6fW2uF.mjs +1 -0
  52. package/dist/artifacts-Bx9GLx4J.mjs +1 -0
  53. package/dist/ast-bridge-BlOrmVAv.mjs +1 -0
  54. package/dist/ast-utils-B9E5k_v1.mjs +1 -0
  55. package/dist/binary-instrument-DiE1BP0x.mjs +12 -0
  56. package/dist/boringssl-inspector-C6M3sOga.mjs +2 -0
  57. package/dist/browser-QDUu5ML9.mjs +29 -0
  58. package/dist/{canvas-396ieNv5.mjs → canvas-g5kmLdY-.mjs} +1098 -24
  59. package/dist/{capabilities-L1ax5EHS.mjs → capabilities-DwzyxL2w.mjs} +1 -1
  60. package/dist/cdp-session-Dy4OwMOP.mjs +1 -0
  61. package/dist/collector-Cld4i-E4.mjs +1 -0
  62. package/dist/config-5ODJ3Aj0.mjs +3 -0
  63. package/dist/constants-nvsLpSri.mjs +1 -0
  64. package/dist/coordination-C6y2gM9O.mjs +98 -0
  65. package/dist/coverage-and-block--cWjjEe5.mjs +1 -0
  66. package/dist/dart-inspector-D4IKxZ6u.mjs +0 -0
  67. package/dist/debugger-C2SpiXoO.mjs +1 -0
  68. package/dist/definitions-0mtilYzG.mjs +1 -0
  69. package/dist/definitions-9csunmeX.mjs +1 -0
  70. package/dist/definitions-B11MudW_.mjs +1 -0
  71. package/dist/definitions-BKpRDjcI.mjs +1 -0
  72. package/dist/definitions-BXE3H4re.mjs +1 -0
  73. package/dist/definitions-BlPHe5DX.mjs +1 -0
  74. package/dist/definitions-Bob4XMxI.mjs +27 -0
  75. package/dist/definitions-BpIQN2nm.mjs +1 -0
  76. package/dist/{definitions-Ym8niHDb.mjs → definitions-BvolWeSu.mjs} +1 -1
  77. package/dist/definitions-C-6j3Ejl.mjs +1 -0
  78. package/dist/definitions-C-AdFfFu.mjs +1 -0
  79. package/dist/definitions-CArdw_9T.mjs +1 -0
  80. package/dist/definitions-CCvIcRrT.mjs +1 -0
  81. package/dist/definitions-CJPE5PIl.mjs +1 -0
  82. package/dist/definitions-CbqeW06u.mjs +1 -0
  83. package/dist/definitions-Cexmkypg.mjs +1 -0
  84. package/dist/definitions-D1dxl8qt.mjs +1 -0
  85. package/dist/definitions-D3uT-ZbU.mjs +1 -0
  86. package/dist/definitions-DtOY5iUc.mjs +1 -0
  87. package/dist/{definitions-Cv5r8xwq.mjs → definitions-DvrYdDCJ2.mjs} +1 -1
  88. package/dist/definitions-ihxOqOC4.mjs +1 -0
  89. package/dist/deopt-trace-qnAcC931.mjs +17 -0
  90. package/dist/disasm-DoxSucGp.mjs +1 -0
  91. package/dist/dumpsys-parser-Du-5ruEe.mjs +2 -0
  92. package/dist/encoding-UMtwgy4M.mjs +2 -0
  93. package/dist/ensure-browser-core-BP70x0TB.mjs +285 -0
  94. package/dist/factory-BeND77hf.mjs +2 -0
  95. package/dist/graphql-CF7QKJME.mjs +68 -0
  96. package/dist/grpc-raw-Dp7ps2sv.mjs +1 -0
  97. package/dist/handlers--qCl9vNv.mjs +1 -0
  98. package/dist/handlers-BHIu1LqA.mjs +1 -0
  99. package/dist/{handlers-DB6xVVWq.mjs → handlers-BQ4K8Jbr.mjs} +1 -1
  100. package/dist/handlers-BxQv-wtf.mjs +8 -0
  101. package/dist/handlers-ByYG27-5.mjs +1 -0
  102. package/dist/handlers-C0I9-BtX.mjs +5 -0
  103. package/dist/{handlers-CWKBBjai.mjs → handlers-CL0Iokmw.mjs} +1 -1
  104. package/dist/handlers-CNbhIdSK.mjs +4 -0
  105. package/dist/handlers-CnTTSJFs.mjs +109 -0
  106. package/dist/handlers-CoDx6akJ2.mjs +49 -0
  107. package/dist/{handlers-BbLxNbbT.mjs → handlers-DASJI0Pn.mjs} +1 -1
  108. package/dist/handlers-DRKMaA-_.mjs +74 -0
  109. package/dist/handlers-Dalu0olz.mjs +2 -0
  110. package/dist/handlers-KY0g31ny.mjs +9 -0
  111. package/dist/handlers-oGo60aVv.mjs +1 -0
  112. package/dist/handlers.impl-BTXLw6Qc.mjs +1 -0
  113. package/dist/heap-sampling-BqdiU-5j.mjs +1 -0
  114. package/dist/{hooks-DPouiS7I.mjs → hooks-COK3t5rT.mjs} +51 -32
  115. package/dist/index.mjs +11 -11
  116. package/dist/logger-BGCcd-jJ.mjs +1 -0
  117. package/dist/macro-nUYUjKNZ.mjs +2 -0
  118. package/dist/maintenance-CfnE7ZKU.mjs +4 -0
  119. package/dist/manifest-7EOTUc0D.mjs +1 -0
  120. package/dist/manifest-B5ujuQmf.mjs +1 -0
  121. package/dist/manifest-BErXl3zn.mjs +1 -0
  122. package/dist/manifest-BKA-mD3J.mjs +1 -0
  123. package/dist/manifest-BUXj23bX.mjs +1 -0
  124. package/dist/manifest-BfXt9cau.mjs +1 -0
  125. package/dist/manifest-Bx-tpURK.mjs +1 -0
  126. package/dist/manifest-C0owVAdq.mjs +1 -0
  127. package/dist/manifest-C5XqYc9o.mjs +1 -0
  128. package/dist/manifest-CVKzLjsA.mjs +1 -0
  129. package/dist/manifest-CaeFjdhj.mjs +1 -0
  130. package/dist/manifest-CegBgip0.mjs +1 -0
  131. package/dist/manifest-CoJHqlgS.mjs +1 -0
  132. package/dist/manifest-D0dbtDqd.mjs +1 -0
  133. package/dist/manifest-D5Gr8ujd.mjs +12 -0
  134. package/dist/manifest-D82z-5og.mjs +1 -0
  135. package/dist/manifest-DA2afIwh.mjs +1 -0
  136. package/dist/manifest-DAbiFP5o.mjs +1 -0
  137. package/dist/manifest-DEY0s1O72.mjs +1 -0
  138. package/dist/manifest-DTOqNqiA.mjs +1 -0
  139. package/dist/manifest-DZ6ELNgX.mjs +1 -0
  140. package/dist/manifest-DjHkjddT.mjs +1 -0
  141. package/dist/manifest-DocA_itf2.mjs +1 -0
  142. package/dist/manifest-Dpnhvfq0.mjs +1 -0
  143. package/dist/manifest-DucPMG_a.mjs +1 -0
  144. package/dist/manifest-Dw5yYEac.mjs +1 -0
  145. package/dist/manifest-Ic_Cg66S.mjs +1 -0
  146. package/dist/manifest-JHaG6GMN.mjs +1 -0
  147. package/dist/manifest-QdkIzmYM.mjs +1 -0
  148. package/dist/manifest-YZqaCe25.mjs +1 -0
  149. package/dist/manifest-f0lUeXwq.mjs +1 -0
  150. package/dist/manifest-h-Ebisf8.mjs +1 -0
  151. package/dist/manifest-oOfTymBS.mjs +1 -0
  152. package/dist/manifest-qXqrO6KC.mjs +2 -0
  153. package/dist/mapsParser-DrJoeC0c.mjs +1 -0
  154. package/dist/modules-CC_ADmwi.mjs +333 -0
  155. package/dist/mojo-ipc-kVztXYw-.mjs +140 -0
  156. package/dist/native-D9ouskXO.mjs +961 -0
  157. package/dist/native-bridge-Dzd7hYoq.mjs +1 -0
  158. package/dist/network-C5Y-S87J.mjs +7 -0
  159. package/dist/one-gadget-CiWFE17F.mjs +1 -0
  160. package/dist/outputPaths-CHtELDyi.mjs +1 -0
  161. package/dist/parse-args-B6dwWc9k.mjs +1 -0
  162. package/dist/platform-BIXgJaM3.mjs +94 -0
  163. package/dist/process-aDIfLC0v.mjs +6 -0
  164. package/dist/proxy-DsHsQ1I4.mjs +2 -0
  165. package/dist/registry-7h8jJ9y9.mjs +1 -0
  166. package/dist/{registry-xB8Wgmyj.mjs → registry-DJDnkQW2.mjs} +1 -1
  167. package/dist/response-R8ghbZSb.mjs +1 -0
  168. package/dist/retry-policy-DtYv0kDi.mjs +1 -0
  169. package/dist/reverseEngineeringConfig-BhZLOa3C.mjs +1 -0
  170. package/dist/safeOutput-Dt4mfjXA.mjs +1 -0
  171. package/dist/{search-defaults-CJik67or.mjs → search-defaults-BBRJNAzC.mjs} +1 -1
  172. package/dist/server/search/EmbeddingWorker.d.mts +1 -0
  173. package/dist/server/search/EmbeddingWorker.mjs +1 -0
  174. package/dist/shared-BKtWZDGN.mjs +1 -0
  175. package/dist/sourcemap-2VIeVeKw.mjs +3 -0
  176. package/dist/streaming-DkpE3GGU.mjs +15 -0
  177. package/dist/syscall-DGZoYM_U.mjs +1 -0
  178. package/dist/transform-BJqsBC_-.mjs +105 -0
  179. package/dist/turbofan-graph-CbGHNVtl.mjs +1 -0
  180. package/dist/turbofan-inspect--NdCuYXi.mjs +23 -0
  181. package/dist/types-CWSvzmIh.mjs +1 -0
  182. package/dist/v8-inspector-CTJo08-K.mjs +297 -0
  183. package/dist/wasm-DX4Qm2Vs.mjs +235 -0
  184. package/dist/weakrefs-inspect-CnhaF-rN.mjs +57 -0
  185. package/dist/webgpu-D4-DxbxZ.mjs +6 -0
  186. package/dist/workflow-DHktRNF2.mjs +108 -0
  187. package/package.json +33 -27
  188. package/dist/AntiCheatDetector-CUpZBh5O.mjs +0 -1
  189. package/dist/CodeInjector-Btj9upnf.mjs +0 -1
  190. package/dist/ConsoleMonitor-DIjN5Afa.mjs +0 -306
  191. package/dist/DarwinAPI-BuMPGzHm.mjs +0 -1
  192. package/dist/ExtensionManager.tools-CIGOWViz.mjs +0 -1
  193. package/dist/FingerprintManager-BkDSsjjP.mjs +0 -1
  194. package/dist/HardwareBreakpoint-DMAMcPyB.mjs +0 -1
  195. package/dist/HeapAnalyzer-Yj348FYt.mjs +0 -1
  196. package/dist/InstrumentationSession-c5qZyp7d.mjs +0 -1
  197. package/dist/MCPServer.activation.ttl-CEGNBycZ.mjs +0 -1
  198. package/dist/MCPServer.search.helpers-Cs1JpKbu.mjs +0 -1
  199. package/dist/MemoryController-DjtgiING.mjs +0 -2
  200. package/dist/MemoryScanner-Dxd657li.mjs +0 -1
  201. package/dist/PEAnalyzer-CMu9Ua9T.mjs +0 -1
  202. package/dist/PointerChainEngine-CaSC1Mry.mjs +0 -1
  203. package/dist/ProcessRegistry-D5y1yuP2.mjs +0 -1
  204. package/dist/ReverseEvidenceGraph-BksOpsPs.mjs +0 -2
  205. package/dist/ServerRuntimeState-CgqBBwfd.mjs +0 -1
  206. package/dist/Speedhack-pwXTHxOY.mjs +0 -1
  207. package/dist/StructureAnalyzer-BseGzsSl.mjs +0 -2
  208. package/dist/ToolCatalog-DgmQXdsm.mjs +0 -1
  209. package/dist/ToolHandlerMap-7HWoIgQO.mjs +0 -1
  210. package/dist/ToolRegistry-eMZEBiR1.mjs +0 -1
  211. package/dist/TraceRecorder-B5ktv3nP.mjs +0 -272
  212. package/dist/VersionDetector-CmPJmaJg.mjs +0 -1
  213. package/dist/Win32API-DoP3MMHS.mjs +0 -1
  214. package/dist/WorkflowEngine-CldHG5b4.mjs +0 -1
  215. package/dist/analysis-C-ln0Brh.mjs +0 -6
  216. package/dist/artifactRetention-DkYKLOvi.mjs +0 -1
  217. package/dist/artifacts-D-4pSS_N.mjs +0 -1
  218. package/dist/binary-instrument-BeZ224mZ.mjs +0 -9
  219. package/dist/boringssl-inspector-ZOCkaipa.mjs +0 -2
  220. package/dist/browser-BUaB25bk.mjs +0 -11
  221. package/dist/collector-CB2syQEg.mjs +0 -1
  222. package/dist/constants-DMv3svps.mjs +0 -2
  223. package/dist/coordination-Dbohmj6D.mjs +0 -1
  224. package/dist/dart-inspector-LhEqRITQ.mjs +0 -0
  225. package/dist/debugger-CLzkObIO.mjs +0 -1
  226. package/dist/definitions-0hxnrDU72.mjs +0 -1
  227. package/dist/definitions-B3a9QC2t.mjs +0 -1
  228. package/dist/definitions-BOvju5t2.mjs +0 -1
  229. package/dist/definitions-CXj_cEVt.mjs +0 -1
  230. package/dist/definitions-Co6AvTjH.mjs +0 -1
  231. package/dist/definitions-DBYSxChX.mjs +0 -1
  232. package/dist/definitions-D_dTDX9B.mjs +0 -1
  233. package/dist/definitions-Db9t2ddh.mjs +0 -1
  234. package/dist/definitions-DbN2CjI2.mjs +0 -1
  235. package/dist/definitions-DlmmHmZc.mjs +0 -1
  236. package/dist/definitions-DnYpoGig.mjs +0 -1
  237. package/dist/definitions-DtZ6Ktx2.mjs +0 -1
  238. package/dist/definitions-DuIPS8gq.mjs +0 -1
  239. package/dist/definitions-DywfwPMb.mjs +0 -1
  240. package/dist/definitions-EGmqr85H.mjs +0 -1
  241. package/dist/definitions-Fetw_Cge.mjs +0 -26
  242. package/dist/definitions-LdkeuOeA.mjs +0 -1
  243. package/dist/definitions-cnG6tj17.mjs +0 -1
  244. package/dist/encoding-B4xZWErf.mjs +0 -2
  245. package/dist/ensure-browser-core-JHwDo5ql.mjs +0 -285
  246. package/dist/factory-BxNdBiZa.mjs +0 -1
  247. package/dist/graphql-GBWsZ9xC.mjs +0 -62
  248. package/dist/handlers-5nzR8B0a.mjs +0 -5
  249. package/dist/handlers-6iNsXOVT.mjs +0 -7
  250. package/dist/handlers-BZ8n6Hvf.mjs +0 -1
  251. package/dist/handlers-BbS4hssc.mjs +0 -4
  252. package/dist/handlers-CIKOP4aI.mjs +0 -2
  253. package/dist/handlers-Cmb6SoRC.mjs +0 -1
  254. package/dist/handlers-CrJsKnEI.mjs +0 -1
  255. package/dist/handlers-DOOCWUNR.mjs +0 -31
  256. package/dist/handlers-Z_B5aVaU.mjs +0 -54
  257. package/dist/handlers-gVscChvl.mjs +0 -1
  258. package/dist/handlers-xFvI9P_y.mjs +0 -1
  259. package/dist/handlers.impl-BsFTW6SD.mjs +0 -1
  260. package/dist/logger-CCikqqvj.mjs +0 -1
  261. package/dist/macro-p8kuJVcm.mjs +0 -2
  262. package/dist/maintenance-DAqADb6Z.mjs +0 -302
  263. package/dist/manifest-4lmM6MZR.mjs +0 -1
  264. package/dist/manifest-AxaxRSt6.mjs +0 -2
  265. package/dist/manifest-BIqRE1Qz.mjs +0 -1
  266. package/dist/manifest-Box-jWfr.mjs +0 -1
  267. package/dist/manifest-Bp33di0Q.mjs +0 -1
  268. package/dist/manifest-BvRX4nRP.mjs +0 -1
  269. package/dist/manifest-C6KoB1XE.mjs +0 -1
  270. package/dist/manifest-C7TdXCWY.mjs +0 -1
  271. package/dist/manifest-CM-n64K0.mjs +0 -1
  272. package/dist/manifest-CUokxCUN.mjs +0 -1
  273. package/dist/manifest-CWJS45iO.mjs +0 -1
  274. package/dist/manifest-Cdxdgo-D.mjs +0 -1
  275. package/dist/manifest-Cf6SmamD.mjs +0 -1
  276. package/dist/manifest-Cgxu2qdv.mjs +0 -1
  277. package/dist/manifest-CowGSURa2.mjs +0 -1
  278. package/dist/manifest-CsGIrh34.mjs +0 -1
  279. package/dist/manifest-CvDpVToN.mjs +0 -1
  280. package/dist/manifest-D8TL9RLE.mjs +0 -1
  281. package/dist/manifest-DIhtCBe6.mjs +0 -1
  282. package/dist/manifest-DJbruNOg.mjs +0 -1
  283. package/dist/manifest-DLGtZH-0.mjs +0 -1
  284. package/dist/manifest-DXHdPt2T.mjs +0 -1
  285. package/dist/manifest-Dg5ScOyW.mjs +0 -1
  286. package/dist/manifest-DzGoTS0R.mjs +0 -1
  287. package/dist/manifest-G2H52LKz.mjs +0 -131
  288. package/dist/manifest-P0Futrgb.mjs +0 -1
  289. package/dist/manifest-Qw7xgvjv.mjs +0 -1
  290. package/dist/manifest-W3qvVrP2.mjs +0 -1
  291. package/dist/manifest-dG6MuR1U.mjs +0 -1
  292. package/dist/manifest-nWXtgq5Y2.mjs +0 -1
  293. package/dist/manifest-vp1upSSq.mjs +0 -1
  294. package/dist/modules-DO3jXCgj.mjs +0 -333
  295. package/dist/mojo-ipc-Be-ccWrc.mjs +0 -9
  296. package/dist/native-g095qhpK.mjs +0 -961
  297. package/dist/network-Dvxm7eEI.mjs +0 -7
  298. package/dist/outputPaths-D2ddHrOJ.mjs +0 -2
  299. package/dist/parse-args-ngRrvF9e.mjs +0 -1
  300. package/dist/platform-DjWbuiF8.mjs +0 -93
  301. package/dist/process-Dq5I-KZW.mjs +0 -2
  302. package/dist/proxy-DPNgM7TE.mjs +0 -2
  303. package/dist/renderer-pid-7jbTR8f5.mjs +0 -1
  304. package/dist/response-B1RuVVfD.mjs +0 -1
  305. package/dist/sourcemap-DqEW15Ao.mjs +0 -1
  306. package/dist/streaming-Dbk4eStJ.mjs +0 -1
  307. package/dist/transform-D-peM3aO.mjs +0 -103
  308. package/dist/wasm-CZajRaad.mjs +0 -174
  309. package/dist/webcrack-phEfVt5y.mjs +0 -46
  310. package/dist/workflow-wkXb3x-U.mjs +0 -101
  311. /package/dist/{chunk-88NL7fhV.mjs → rolldown-runtime-88NL7fhV.mjs} +0 -0
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  English | [中文](./README.zh.md)
10
10
 
11
- An MCP server that gives AI agents **402 tools across 36 domains** for JavaScript analysis and security research — browser automation, CDP debugging, network interception, JS hooks, LLM-powered code analysis, process/memory forensics, WASM reverse engineering, source-map reconstruction, AST transforms, and composite workflows in a single server.
11
+ An MCP server that gives AI agents **600+ tools across 34 domains** for JavaScript analysis and security research — browser automation, CDP debugging, network interception, JS hooks, LLM-powered code analysis, process/memory forensics, WASM reverse engineering, source-map reconstruction, AST transforms, and composite workflows in a single server.
12
12
 
13
13
  ## Quick Links
14
14
 
@@ -34,6 +34,21 @@ No global install needed — add to your MCP client config and you're ready:
34
34
 
35
35
  *(Windows: use `npx.cmd` absolute path if `npx` is not found)*
36
36
 
37
+ ### Share one daemon across multiple agents
38
+
39
+ The default stdio configuration starts one full jshook process per MCP host. To share the
40
+ embedding model, browser runtime, and caches, start one local Streamable HTTP daemon:
41
+
42
+ ```bash
43
+ pnpm build
44
+ pnpm daemon
45
+ ```
46
+
47
+ Then point every MCP client at `http://127.0.0.1:3000/mcp` using its HTTP/URL server
48
+ configuration. Each client receives its own MCP session and response route while heavyweight
49
+ runtime resources remain in one process. Keep the default loopback bind; set `MCP_AUTH_TOKEN`
50
+ before exposing the endpoint beyond localhost.
51
+
37
52
  ## 🌟 Highlights
38
53
 
39
54
  - 🤖 **AI-Driven Analysis** — LLM-powered deobfuscation, crypto detection, AST comprehension
@@ -65,9 +80,9 @@ No global install needed — add to your MCP client config and you're ready:
65
80
  The built-in surface below is generated from the runtime registry and checked in CI.
66
81
 
67
82
  <!-- metadata-sync:start -->
68
- - Package version: `0.3.3`
69
- - Built-in Tools: `451`
70
- - Domains: `adb-bridge`, `binary-instrument`, `boringssl-inspector`, `browser`, `canvas`, `coordination`, `core`, `cross-domain`, `dart-inspector`, `debugger`, `encoding`, `extension-registry`, `graphql`, `instrumentation`, `maintenance`, `memory`, `mojo-ipc`, `native-emulator`, `network`, `platform`, `process`, `protocol-analysis`, `proxy`, `sourcemap`, `streaming`, `syscall-hook`, `trace`, `transform`, `v8-inspector`, `wasm`, `workflow`
83
+ - Package version: `0.3.4`
84
+ - Built-in Tools: `636`
85
+ - Domains: `adb-bridge`, `binary-instrument`, `boringssl-inspector`, `browser`, `canvas`, `coordination`, `core`, `cross-domain`, `dart-inspector`, `debugger`, `encoding`, `exploit-dev`, `extension-registry`, `graphql`, `instrumentation`, `maintenance`, `memory`, `mojo-ipc`, `native-bridge`, `native-emulator`, `network`, `platform`, `process`, `protocol-analysis`, `proxy`, `sourcemap`, `streaming`, `syscall-hook`, `trace`, `transform`, `v8-inspector`, `wasm`, `webgpu`, `workflow`
71
86
  - Note: this snapshot is generated from the runtime registry; do not edit the counts by hand.
72
87
  <!-- metadata-sync:end -->
73
88
 
package/README.zh.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  [English](./README.md) | 中文
10
10
 
11
- 为 AI 赋予 **36 个技术域、402 个原子工具** 的 JavaScript 分析与安全研究 MCP 服务器——浏览器自动化、CDP 调试、网络拦截、JS Hook、LLM 代码分析、进程/内存取证、WASM 逆向、Source Map 重建、AST 变换与复合工作流,一应俱全。
11
+ 为 AI 赋予 **34 个技术域、600+ 个原子工具** 的 JavaScript 分析与安全研究 MCP 服务器——浏览器自动化、CDP 调试、网络拦截、JS Hook、LLM 代码分析、进程/内存取证、WASM 逆向、Source Map 重建、AST 变换与复合工作流,一应俱全。
12
12
 
13
13
  ## 快速导航
14
14
 
@@ -34,6 +34,21 @@
34
34
 
35
35
  *(Windows 用户:若找不到 `npx`,请使用 `npx.cmd` 绝对路径)*
36
36
 
37
+ ### 多个 Agent 共用一个本地进程
38
+
39
+ 默认 stdio 配置会让每个 MCP 宿主启动一份完整的 jshook。若要共享 embedding 模型、
40
+ 浏览器运行时和缓存,可以启动一个本地 Streamable HTTP daemon:
41
+
42
+ ```bash
43
+ pnpm build
44
+ pnpm daemon
45
+ ```
46
+
47
+ 然后在各 MCP 客户端的 HTTP/URL server 配置中统一指向
48
+ `http://127.0.0.1:3000/mcp`。每个客户端拥有独立的 MCP 会话和响应路由,重量级运行时
49
+ 资源只保留一份。建议保持默认的本机回环监听;如需对外暴露,必须先设置
50
+ `MCP_AUTH_TOKEN`。
51
+
37
52
  ## 🌟 核心亮点
38
53
 
39
54
  - 🤖 **AI 智能分析** — LLM 驱动的 JS 反混淆、加密识别、AST 深度理解
@@ -65,9 +80,9 @@
65
80
  下面的内置能力快照由运行时 registry 动态生成,并在 CI 中校验。
66
81
 
67
82
  <!-- metadata-sync:start -->
68
- - 包版本:`0.3.3`
69
- - 内置工具数:`451`
70
- - 域列表:`adb-bridge`, `binary-instrument`, `boringssl-inspector`, `browser`, `canvas`, `coordination`, `core`, `cross-domain`, `dart-inspector`, `debugger`, `encoding`, `extension-registry`, `graphql`, `instrumentation`, `maintenance`, `memory`, `mojo-ipc`, `native-emulator`, `network`, `platform`, `process`, `protocol-analysis`, `proxy`, `sourcemap`, `streaming`, `syscall-hook`, `trace`, `transform`, `v8-inspector`, `wasm`, `workflow`
83
+ - 包版本:`0.3.4`
84
+ - 内置工具数:`636`
85
+ - 域列表:`adb-bridge`, `binary-instrument`, `boringssl-inspector`, `browser`, `canvas`, `coordination`, `core`, `cross-domain`, `dart-inspector`, `debugger`, `encoding`, `exploit-dev`, `extension-registry`, `graphql`, `instrumentation`, `maintenance`, `memory`, `mojo-ipc`, `native-bridge`, `native-emulator`, `network`, `platform`, `process`, `protocol-analysis`, `proxy`, `sourcemap`, `streaming`, `syscall-hook`, `trace`, `transform`, `v8-inspector`, `wasm`, `webgpu`, `workflow`
71
86
  - 说明:以上数据由运行时 registry 动态生成,不要手改计数。
72
87
  <!-- metadata-sync:end -->
73
88
 
@@ -0,0 +1 @@
1
+ import{t as e}from"./logger-BGCcd-jJ.mjs";import{_ as t,a as n,d as r,i,n as a,p as o,s,t as c,w as l}from"./Win32API-G7QPyckq.mjs";import{t as u}from"./PEAnalyzer-CB_kaTis.mjs";import{promises as d}from"node:fs";import{createHash as f}from"node:crypto";const p=[{dll:`kernel32.dll`,funcs:[{name:`IsDebuggerPresent`,mechanism:`anti_debug_api`,confidence:`high`,bypass:`Hook IsDebuggerPresent to return 0, or patch PEB.BeingDebugged field`},{name:`CheckRemoteDebuggerPresent`,mechanism:`anti_debug_api`,confidence:`high`,bypass:`Hook CheckRemoteDebuggerPresent to set output to FALSE and return TRUE`},{name:`OutputDebugStringA`,mechanism:`exception_based`,confidence:`low`,bypass:`May be used for anti-debug timing — monitor for exception handler abuse`},{name:`GetTickCount`,mechanism:`timing_check`,confidence:`low`,bypass:`Hook GetTickCount to return consistent delta values`},{name:`GetTickCount64`,mechanism:`timing_check`,confidence:`low`,bypass:`Hook GetTickCount64 to return consistent delta values`},{name:`QueryPerformanceCounter`,mechanism:`timing_check`,confidence:`medium`,bypass:`Hook QPC to filter out debugging time deltas`}]},{dll:`ntdll.dll`,funcs:[{name:`NtQueryInformationProcess`,mechanism:`ntquery_debug`,confidence:`high`,bypass:`Hook NtQueryInformationProcess: return 0 for ProcessDebugPort (7), ProcessDebugObjectHandle (30), ProcessDebugFlags (31)`},{name:`NtSetInformationThread`,mechanism:`thread_hiding`,confidence:`medium`,bypass:`Hook NtSetInformationThread: intercept ThreadHideFromDebugger (0x11) calls`},{name:`NtClose`,mechanism:`exception_based`,confidence:`low`,bypass:`NtClose with invalid handle detects debugger via exception — hook to suppress`},{name:`RtlGetNtGlobalFlags`,mechanism:`heap_flags`,confidence:`medium`,bypass:`Clear NtGlobalFlag (FLG_HEAP_*) in PEB at offset 0xBC (x64)`}]}],m=[`GetThreadContext`,`SetThreadContext`],h={guardPageMaxRegions:2e4,guardPageTimeoutMs:2e3,integrityMaxModules:32,integrityMaxSections:128,integrityMaxBytes:16*1024*1024,integrityMaxSectionBytes:2*1024*1024,integrityTimeoutMs:3e3,timingMaxModules:8,timingMaxBytes:4*1024*1024,timingTimeoutMs:2e3},g=/^(kernel32|ntdll|kernelbase|win32u|user32|gdi32|advapi32|msvcrt|ucrtbase|shell32|ole32|combase|msvcp)/i;var _=class{peAnalyzer=new u;options;constructor(e={}){this.options={...h,...e}}async detect(t){let n=[],r=l(t);try{let i=this.enumerateModules(r);for(let r of i)try{let e=await this.peAnalyzer.parseImports(t,r.base);for(let t of e){let e=t.dllName.toLowerCase();for(let i of p)if(e.includes(i.dll.toLowerCase().replace(`.dll`,``)))for(let e of i.funcs)t.functions.some(t=>t.name===e.name)&&n.push({mechanism:e.mechanism,confidence:e.confidence,location:`import:${e.name}`,moduleName:r.name,details:`${r.name} imports ${e.name} from ${t.dllName}`,bypassSuggestion:e.bypass});for(let e of t.functions)m.includes(e.name)&&n.push({mechanism:`hardware_breakpoint`,confidence:`medium`,location:`import:${e.name}`,moduleName:r.name,details:`${r.name} imports ${e.name} — may check debug registers for hardware breakpoints`,bypassSuggestion:`Hook GetThreadContext to zero out DR0-DR3 and DR6/DR7 before returning`})}}catch(t){e.debug(`Import scan skipped for ${r.name}: ${t}`)}}finally{c(r)}return n.push(...await this.scanTimingInstructions(t)),n}async scanTimingInstructions(t){let n=[],r=l(t),i=Date.now(),a=0;try{let s=this.enumerateModules(r).filter(e=>!g.test(e.name)).slice(0,this.options.timingMaxModules);for(let c of s){if(this.isTimedOut(i,this.options.timingTimeoutMs))break;try{let e=await this.peAnalyzer.listSections(t,c.base),i=0;for(let t of e){if(!t.isExecutable)continue;let e=parseInt(t.virtualAddress,16),s=Math.min(t.virtualSize,this.options.timingMaxBytes);if(s<=0)continue;if(a+s>this.options.timingMaxBytes)break;let l=o(r,BigInt(c.base)+BigInt(e),s);a+=s;for(let r=0;r<l.length-1;r+=1){if(l[r]!==15)continue;let a=l[r+1]===249,o=l[r+1]===49;if(!a&&!o)continue;let s=BigInt(c.base)+BigInt(e)+BigInt(r);if(n.push({mechanism:`timing_check`,confidence:`low`,location:`0x${s.toString(16)}`,moduleName:c.name,details:`${a?`RDTSCP`:`RDTSC`} instruction in ${t.name} of ${c.name} — may be a timing-based anti-debug check or legitimate performance measurement.`,bypassSuggestion:`RDTSC/RDTSCP timing can be trapped via a VEH or hypervisor RDTSC interception. Verify the surrounding code before patching — may be benign performance instrumentation.`}),i+=1,i>=8)break}if(i>=8)break}}catch(t){e.debug(`Timing instruction scan skipped for ${c.name}: ${t}`)}}}finally{c(r)}return n}async findGuardPages(e){return(await this.scanGuardPages(e)).guardPages}async scanGuardPages(e){let n=[],i=l(e),a=Date.now(),o={scannedRegions:0,queryFailures:0,durationMs:0,timedOut:!1,truncated:!1,maxRegions:this.options.guardPageMaxRegions,timeoutMs:this.options.guardPageTimeoutMs};try{let e=this.enumerateModules(i),s=0n;for(;s<140737488355327n;){if(this.isTimedOut(a,o.timeoutMs)){o.timedOut=!0,o.truncated=!0;break}if(o.scannedRegions>=o.maxRegions){o.truncated=!0;break}try{let a=t(i,s);if(!a.success)break;let c=a.info,l=c.BaseAddress+c.RegionSize;if(o.scannedRegions+=1,(c.Protect&r.GUARD)!==0){let t=null;for(let n of e){let e=BigInt(n.base);if(c.BaseAddress>=e&&c.BaseAddress<e+BigInt(n.size)){t=n.name;break}}n.push({address:`0x${c.BaseAddress.toString(16)}`,size:Number(c.RegionSize),moduleName:t,nearbySymbol:null})}if(c.RegionSize<=0n||l<=s||l<=c.BaseAddress){o.truncated=!0;break}s=l}catch{o.queryFailures+=1,s+=4096n}}}finally{o.durationMs=Date.now()-a,c(i)}return{guardPages:n,stats:o}}async checkIntegrity(e,t){return(await this.scanIntegrity(e,t)).sections}async scanIntegrity(t,n){let r=[],i=l(t),a=Date.now(),s={scannedModules:0,scannedSections:0,hashedBytes:0,skippedModules:0,skippedSections:0,durationMs:0,timedOut:!1,truncated:!1,maxModules:this.options.integrityMaxModules,maxSections:this.options.integrityMaxSections,maxBytes:this.options.integrityMaxBytes,timeoutMs:this.options.integrityTimeoutMs},u=!1;try{let c=this.enumerateModules(i),l=n?c.filter(e=>e.name.toLowerCase().includes(n.toLowerCase())):c;for(let n of l){if(this.shouldStopIntegrityScan(s,a)){this.isTimedOut(a,s.timeoutMs)&&(s.timedOut=!0),s.truncated=!0;break}s.scannedModules+=1;try{let e=await d.readFile(n.path),c=await this.peAnalyzer.listSections(t,n.base);for(let t of c){if(this.shouldStopIntegrityScan(s,a)){this.isTimedOut(a,s.timeoutMs)&&(s.timedOut=!0),s.truncated=!0,u=!0;break}let c=t.isReadable&&!t.isWritable&&!t.isExecutable;if(!t.isExecutable&&!c)continue;let l=parseInt(t.virtualAddress,16),d=Math.min(t.virtualSize,t.rawSize);if(d<=0)continue;if(d>this.options.integrityMaxSectionBytes){s.skippedSections+=1;continue}if(s.hashedBytes+d>s.maxBytes){s.truncated=!0,u=!0;break}let p=o(i,BigInt(n.base)+BigInt(l),d),m=this.rvaToFileOffset(e,l);if(m<0||m+d>e.length)continue;let h=e.subarray(m,m+d),g=f(`sha256`).update(p).digest(`hex`),_=f(`sha256`).update(h).digest(`hex`);r.push({sectionName:t.name,moduleName:n.name,diskHash:_,memoryHash:g,isModified:g!==_}),s.scannedSections+=1,s.hashedBytes+=d}}catch(t){s.skippedModules+=1,e.debug(`Integrity check skipped for ${n.name}: ${t}`)}if(u)break}}finally{s.durationMs=Date.now()-a,c(i)}return{sections:r,stats:s}}enumerateModules(t){let r=[];try{let{modules:e,count:o}=a(t);for(let a=0;a<o;a++){let o=e[a],c=i(t,o),l=s(t,o),u=n(t,o)??c;l.success&&r.push({name:c,base:`0x${l.info.lpBaseOfDll.toString(16)}`,path:u,size:l.info.SizeOfImage})}}catch(t){e.debug(`Module enumeration failed: ${t}`)}return r}rvaToFileOffset(e,t){let n=e.readUInt32LE(60),r=e.readUInt16LE(n+6),i=e.readUInt16LE(n+20),a=n+24+i;for(let n=0;n<r;n++){let r=a+n*40;if(r+40>e.length)break;let i=e.readUInt32LE(r+12),o=e.readUInt32LE(r+8),s=e.readUInt32LE(r+20);if(t>=i&&t<i+o)return s+(t-i)}return-1}isTimedOut(e,t){return Date.now()-e>=t}shouldStopIntegrityScan(e,t){return this.isTimedOut(t,e.timeoutMs)||e.scannedModules>=e.maxModules||e.scannedSections>=e.maxSections||e.hashedBytes>=e.maxBytes}};const v=new _;export{_ as AntiCheatDetector,v as antiCheatDetector};
@@ -1 +1 @@
1
- import{t as e}from"./logger-CCikqqvj.mjs";import{AsyncLocalStorage as t}from"node:async_hooks";let n=0;var r=class{pageIdByHandle=new WeakMap;tabsById=new Map;aliasToPageId=new Map;currentPageId=null;sharedContext=new Map;upsertPage(e,t){let n=this.pageIdByHandle.get(e),r=n?this.tabsById.get(n)?.meta:null,i=typeof t.index==`number`&&Number.isFinite(t.index)?t.index:r?.index??0;return this.registerPage(e,{index:i,url:t.url,title:t.title})}registerPage(t,r){let i=t,a=this.pageIdByHandle.get(i);if(a){let e=this.tabsById.get(a);return e?(e.meta=r,e.stale=!1):this.tabsById.set(a,{page:t,meta:r,stale:!1}),a}n+=1;let o=`tab-${n}`;return this.pageIdByHandle.set(i,o),this.tabsById.set(o,{page:t,meta:r,stale:!1}),e.debug(`[TabRegistry] Registered page ${o} (index=${r.index}, url=${r.url})`),o}reconcilePages(t,n){let r=new Set;for(let e=0;e<t.length;e++){let i=t[e],a=n[e]??{index:e,url:``,title:``},o=this.registerPage(i,{...a,index:e});r.add(o)}let i=[];for(let[t,n]of this.tabsById)r.has(t)||(n.stale?i.push(t):(n.stale=!0,e.debug(`[TabRegistry] Page ${t} marked stale`)));for(let t of i)this.tabsById.delete(t),e.debug(`[TabRegistry] Page ${t} pruned (was already stale)`);return this.currentPageId&&!r.has(this.currentPageId)&&(e.debug(`[TabRegistry] Current page ${this.currentPageId} is stale, clearing`),this.currentPageId=null),this.listTabs()}bindAlias(e,t){return this.tabsById.has(t)?(this.aliasToPageId.set(e,t),!0):!1}bindAliasByIndex(e,t){for(let[n,r]of this.tabsById)if(r.meta.index===t&&!r.stale)return this.aliasToPageId.set(e,n),n;return null}unbindAlias(e){return this.aliasToPageId.delete(e)}resolveAlias(e){let t=this.aliasToPageId.get(e);if(!t)return null;let n=this.tabsById.get(t);return!n||n.stale?null:t}getPageById(e){let t=this.tabsById.get(e);return!t||t.stale?null:t.page}getTabById(e){let t=this.tabsById.get(e);if(!t)return null;let n=this.getAliasesForPageId(e);return{pageId:e,index:t.meta.index,url:t.meta.url,title:t.meta.title,page:t.page,aliases:n,stale:t.stale}}getTabByIndex(e){for(let[t,n]of this.tabsById)if(n.meta.index===e&&!n.stale)return this.getTabById(t);return null}findTab(e){for(let[t]of this.tabsById){let n=this.getTabById(t);if(n&&e(n))return n}return null}setCurrentPageId(e){let t=this.tabsById.get(e);return!t||t.stale?!1:(this.currentPageId=e,!0)}setCurrentByIndex(e){let t=this.getTabByIndex(e);return t&&(this.currentPageId=t.pageId),t}getCurrentPageId(){return this.currentPageId}getCurrentPage(){return this.currentPageId?this.getPageById(this.currentPageId):null}getCurrentTabInfo(e){let t=[],n=[];for(let[e,r]of this.aliasToPageId){let i=this.tabsById.get(r),a=!i||i.stale;t.push({alias:e,pageId:r,index:i?.meta.index??null,stale:a}),a&&n.push(e)}let r=this.currentPageId?this.tabsById.get(this.currentPageId):null,i=r&&!r.stale?r:null;return{driver:e,currentPageId:i?this.currentPageId:null,currentIndex:i?.meta.index??null,url:i?.meta.url??null,title:i?.meta.title??null,aliases:t,staleAliases:n}}getContextMeta(){let e=this.currentPageId?this.tabsById.get(this.currentPageId):null,t=e&&!e.stale?e:null;return{url:t?.meta.url??null,title:t?.meta.title??null,tabIndex:t?.meta.index??null,pageId:t?this.currentPageId:null}}listTabs(){let e=[];for(let[t,n]of this.tabsById)if(!n.stale){let r=this.getAliasesForPageId(t);e.push({pageId:t,index:n.meta.index,url:n.meta.url,title:n.meta.title,page:n.page,aliases:r,stale:!1})}return e.toSorted((e,t)=>e.index-t.index)}listAllTabs(){let e=[];for(let[t,n]of this.tabsById){let r=this.getAliasesForPageId(t);e.push({pageId:t,index:n.meta.index,url:n.meta.url,title:n.meta.title,page:n.page,aliases:r,stale:n.stale})}return e.toSorted((e,t)=>e.index-t.index)}setSharedContext(e,t){this.sharedContext.set(e,t)}getSharedContext(e){return{value:this.sharedContext.get(e)??null,found:this.sharedContext.has(e)}}getSharedContextMap(){let e={};return this.sharedContext.forEach((t,n)=>{e[n]=t}),e}clear(){this.tabsById.clear(),this.aliasToPageId.clear(),this.sharedContext.clear(),this.currentPageId=null}getAliasesForPageId(e){let t=[];for(let[n,r]of this.aliasToPageId)r===e&&t.push(n);return t}};function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){try{return JSON.parse(e)}catch{return null}}function o(e){if(!i(e)||!Array.isArray(e.content)||e.content.length===0)return null;let t=e.content[0];if(!i(t)||typeof t.text!=`string`)return null;let n=a(t.text);return i(n)?{currentTabIndex:typeof n.selectedIndex==`number`&&Number.isFinite(n.selectedIndex)?n.selectedIndex:typeof n.currentIndex==`number`&&Number.isFinite(n.currentIndex)?n.currentIndex:null,currentPageId:typeof n.selectedPageId==`string`?n.selectedPageId:null,currentTargetId:typeof n.targetId==`string`?n.targetId:null,lastToolName:typeof n.toolName==`string`?n.toolName:null,lastTouchedAt:new Date().toISOString()}:null}var s=class{getCollector;executionContext=new t;sessions=new Map;lastActiveSessionId=null;executionQueue=Promise.resolve();constructor(e){this.getCollector=e}normalizeSessionId(e){return typeof e!=`string`||e.trim().length===0?`default`:e}getCurrentSessionId(){return this.executionContext.getStore()?.sessionId??null}getOrCreateSession(e){let t=this.normalizeSessionId(e),n=this.sessions.get(t);return n||(n={tabRegistry:new r,currentTabIndex:null,currentPageId:null,currentTargetId:null,lastToolName:null,lastTouchedAt:null},this.sessions.set(t,n)),n}getTabRegistry(e){return this.getOrCreateSession(e).tabRegistry}noteToolResult(e,t,n){let r=this.getOrCreateSession(e);n?.currentTabIndex!==void 0&&(r.currentTabIndex=n.currentTabIndex??null),n?.currentPageId!==void 0&&(r.currentPageId=n.currentPageId??null),n?.currentTargetId!==void 0&&(r.currentTargetId=n.currentTargetId??null),r.lastToolName=t,r.lastTouchedAt=new Date().toISOString(),this.lastActiveSessionId=this.normalizeSessionId(e)}getSnapshot(e){let t=this.getOrCreateSession(e);return{currentTabIndex:t.currentTabIndex,currentPageId:t.currentPageId,currentTargetId:t.currentTargetId,lastToolName:t.lastToolName,lastTouchedAt:t.lastTouchedAt}}async restoreSessionContext(t){let n=this.normalizeSessionId(t),r=this.getOrCreateSession(n),i=this.getCollector();if(!i){this.lastActiveSessionId=n;return}if(this.lastActiveSessionId===n||r.currentTabIndex===null&&r.currentTargetId===null){this.lastActiveSessionId=n;return}if(typeof r.currentTabIndex==`number`)try{await i.selectPage(r.currentTabIndex)}catch(t){e.warn(`[browser-session] Failed to restore page index ${r.currentTabIndex} for session ${n}: ${t instanceof Error?t.message:String(t)}`)}if(r.currentTargetId)try{await i.attachCdpTarget(r.currentTargetId)}catch(t){e.warn(`[browser-session] Failed to restore target ${r.currentTargetId} for session ${n}: ${t instanceof Error?t.message:String(t)}`)}this.lastActiveSessionId=n}async runExclusive(e,t){let n=this.normalizeSessionId(e);if(this.executionContext.getStore()?.sessionId===n)return await t();let r=this.executionQueue,i,a=new Promise(e=>{i=e});this.executionQueue=r.then(()=>a),await r;try{return await this.executionContext.run({sessionId:n},t)}finally{i()}}};export{o as n,r,s as t};
1
+ import{t as e}from"./logger-BGCcd-jJ.mjs";import{AsyncLocalStorage as t}from"node:async_hooks";let n=0;var r=class{pageIdByHandle=new WeakMap;tabsById=new Map;aliasToPageId=new Map;currentPageId=null;sharedContext=new Map;upsertPage(e,t){let n=this.pageIdByHandle.get(e),r=n?this.tabsById.get(n)?.meta:null,i=typeof t.index==`number`&&Number.isFinite(t.index)?t.index:r?.index??0;return this.registerPage(e,{index:i,url:t.url,title:t.title})}registerPage(t,r){let i=t,a=this.pageIdByHandle.get(i);if(a){let e=this.tabsById.get(a);return e?(e.meta=r,e.stale=!1):this.tabsById.set(a,{page:t,meta:r,stale:!1}),a}n+=1;let o=`tab-${n}`;return this.pageIdByHandle.set(i,o),this.tabsById.set(o,{page:t,meta:r,stale:!1}),e.debug(`[TabRegistry] Registered page ${o} (index=${r.index}, url=${r.url})`),o}reconcilePages(t,n){let r=new Set;for(let e=0;e<t.length;e++){let i=t[e],a=n[e]??{index:e,url:``,title:``},o=this.registerPage(i,{...a,index:e});r.add(o)}let i=[];for(let[t,n]of this.tabsById)r.has(t)||(n.stale?i.push(t):(n.stale=!0,e.debug(`[TabRegistry] Page ${t} marked stale`)));for(let t of i)this.tabsById.delete(t),e.debug(`[TabRegistry] Page ${t} pruned (was already stale)`);return this.currentPageId&&!r.has(this.currentPageId)&&(e.debug(`[TabRegistry] Current page ${this.currentPageId} is stale, clearing`),this.currentPageId=null),this.listTabs()}bindAlias(e,t){return this.tabsById.has(t)?(this.aliasToPageId.set(e,t),!0):!1}bindAliasByIndex(e,t){for(let[n,r]of this.tabsById)if(r.meta.index===t&&!r.stale)return this.aliasToPageId.set(e,n),n;return null}unbindAlias(e){return this.aliasToPageId.delete(e)}resolveAlias(e){let t=this.aliasToPageId.get(e);if(!t)return null;let n=this.tabsById.get(t);return!n||n.stale?null:t}getPageById(e){let t=this.tabsById.get(e);return!t||t.stale?null:t.page}getTabById(e){let t=this.tabsById.get(e);if(!t)return null;let n=this.getAliasesForPageId(e);return{pageId:e,index:t.meta.index,url:t.meta.url,title:t.meta.title,page:t.page,aliases:n,stale:t.stale}}getTabByIndex(e){for(let[t,n]of this.tabsById)if(n.meta.index===e&&!n.stale)return this.getTabById(t);return null}findTab(e){for(let[t]of this.tabsById){let n=this.getTabById(t);if(n&&e(n))return n}return null}setCurrentPageId(e){let t=this.tabsById.get(e);return!t||t.stale?!1:(this.currentPageId=e,!0)}setCurrentByIndex(e){let t=this.getTabByIndex(e);return t&&(this.currentPageId=t.pageId),t}getCurrentPageId(){return this.currentPageId}getCurrentPage(){return this.currentPageId?this.getPageById(this.currentPageId):null}getCurrentTabInfo(e){let t=[],n=[];for(let[e,r]of this.aliasToPageId){let i=this.tabsById.get(r),a=!i||i.stale;t.push({alias:e,pageId:r,index:i?.meta.index??null,stale:a}),a&&n.push(e)}let r=this.currentPageId?this.tabsById.get(this.currentPageId):null,i=r&&!r.stale?r:null;return{driver:e,currentPageId:i?this.currentPageId:null,currentIndex:i?.meta.index??null,url:i?.meta.url??null,title:i?.meta.title??null,aliases:t,staleAliases:n}}getContextMeta(){let e=this.currentPageId?this.tabsById.get(this.currentPageId):null,t=e&&!e.stale?e:null;return{url:t?.meta.url??null,title:t?.meta.title??null,tabIndex:t?.meta.index??null,pageId:t?this.currentPageId:null}}listTabs(){let e=[];for(let[t,n]of this.tabsById)if(!n.stale){let r=this.getAliasesForPageId(t);e.push({pageId:t,index:n.meta.index,url:n.meta.url,title:n.meta.title,page:n.page,aliases:r,stale:!1})}return e.toSorted((e,t)=>e.index-t.index)}listAllTabs(){let e=[];for(let[t,n]of this.tabsById){let r=this.getAliasesForPageId(t);e.push({pageId:t,index:n.meta.index,url:n.meta.url,title:n.meta.title,page:n.page,aliases:r,stale:n.stale})}return e.toSorted((e,t)=>e.index-t.index)}setSharedContext(e,t){this.sharedContext.set(e,t)}getSharedContext(e){return{value:this.sharedContext.get(e)??null,found:this.sharedContext.has(e)}}getSharedContextMap(){let e={};return this.sharedContext.forEach((t,n)=>{e[n]=t}),e}clear(){this.tabsById.clear(),this.aliasToPageId.clear(),this.sharedContext.clear(),this.currentPageId=null}getAliasesForPageId(e){let t=[];for(let[n,r]of this.aliasToPageId)r===e&&t.push(n);return t}};function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){try{return JSON.parse(e)}catch{return null}}function o(e){if(!i(e)||!Array.isArray(e.content)||e.content.length===0)return null;let t=e.content[0];if(!i(t)||typeof t.text!=`string`)return null;let n=a(t.text);return i(n)?{currentTabIndex:typeof n.selectedIndex==`number`&&Number.isFinite(n.selectedIndex)?n.selectedIndex:typeof n.currentIndex==`number`&&Number.isFinite(n.currentIndex)?n.currentIndex:null,currentPageId:typeof n.selectedPageId==`string`?n.selectedPageId:null,currentTargetId:typeof n.targetId==`string`?n.targetId:null,lastToolName:typeof n.toolName==`string`?n.toolName:null,lastTouchedAt:new Date().toISOString()}:null}var s=class{getCollector;executionContext=new t;sessions=new Map;lastActiveSessionId=null;executionQueue=Promise.resolve();constructor(e){this.getCollector=e}normalizeSessionId(e){return typeof e!=`string`||e.trim().length===0?`default`:e}getCurrentSessionId(){return this.executionContext.getStore()?.sessionId??null}getOrCreateSession(e){let t=this.normalizeSessionId(e),n=this.sessions.get(t);return n||(n={tabRegistry:new r,currentTabIndex:null,currentPageId:null,currentTargetId:null,lastToolName:null,lastTouchedAt:null},this.sessions.set(t,n)),n}getTabRegistry(e){return this.getOrCreateSession(e).tabRegistry}noteToolResult(e,t,n){let r=this.getOrCreateSession(e);n?.currentTabIndex!==void 0&&(r.currentTabIndex=n.currentTabIndex??null),n?.currentPageId!==void 0&&(r.currentPageId=n.currentPageId??null),n?.currentTargetId!==void 0&&(r.currentTargetId=n.currentTargetId??null),r.lastToolName=t,r.lastTouchedAt=new Date().toISOString(),this.lastActiveSessionId=this.normalizeSessionId(e)}getSnapshot(e){let t=this.getOrCreateSession(e);return{currentTabIndex:t.currentTabIndex,currentPageId:t.currentPageId,currentTargetId:t.currentTargetId,lastToolName:t.lastToolName,lastTouchedAt:t.lastTouchedAt}}dropSession(e){let t=this.normalizeSessionId(e);return this.lastActiveSessionId===t&&(this.lastActiveSessionId=null),this.sessions.delete(t)}async restoreSessionContext(t){let n=this.normalizeSessionId(t),r=this.getOrCreateSession(n),i=this.getCollector();if(!i){this.lastActiveSessionId=n;return}if(this.lastActiveSessionId===n||r.currentTabIndex===null&&r.currentTargetId===null){this.lastActiveSessionId=n;return}if(typeof r.currentTabIndex==`number`)try{await i.selectPage(r.currentTabIndex)}catch(t){e.warn(`[browser-session] Failed to restore page index ${r.currentTabIndex} for session ${n}: ${t instanceof Error?t.message:String(t)}`)}if(r.currentTargetId)try{await i.attachCdpTarget(r.currentTargetId)}catch(t){e.warn(`[browser-session] Failed to restore target ${r.currentTargetId} for session ${n}: ${t instanceof Error?t.message:String(t)}`)}this.lastActiveSessionId=n}async runExclusive(e,t){let n=this.normalizeSessionId(e);if(this.executionContext.getStore()?.sessionId===n)return await t();let r=this.executionQueue,i,a=new Promise(e=>{i=e});this.executionQueue=r.then(()=>a),await r;try{return await this.executionContext.run({sessionId:n},t)}finally{i()}}};export{o as n,r,s as t};
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./logger-BGCcd-jJ.mjs";import{ht as t,mt as n}from"./constants-nvsLpSri.mjs";import{t as r}from"./ExecutionSandbox-QbWQmzuC.mjs";import i from"node:path";import{readdir as a,rm as o,stat as s}from"node:fs/promises";import*as c from"@babel/parser";import l from"@babel/traverse";import u from"@babel/generator";import*as d from"@babel/types";const f={jsx:!0,mangle:!1,unminify:!0,unpack:!0};function p(e){return{jsx:e.jsx??f.jsx,mangle:e.mangle??f.mangle,unminify:e.unminify??f.unminify,unpack:e.unpack??f.unpack}}function m(){let[e=`0`,t=`0`]=process.versions.node.split(`.`),n=Number.parseInt(e,10),r=Number.parseInt(t,10);return!Number.isFinite(n)||!Number.isFinite(r)?!1:n===22?r>=12:n===24}function h(e,t){let n=t.target===`path`?e.path:e.code,r=t.matchType??`includes`;if(r===`exact`)return n===t.pattern;if(r===`regex`)try{return new RegExp(t.pattern,`m`).test(n)}catch{return!1}return n.includes(t.pattern)}function g(e,t){let n=new Map;if(!t||t.length===0)return n;for(let r of e.modules.values())for(let e of t)if(!(!e.path||!e.pattern)&&h(r,e)){r.path!==e.path&&(n.set(r.id,{fromPath:r.path}),r.path=e.path);break}return n}function _(e,t,n){let r=t.maxBundleModules??100,i=Array.from(e.modules.values()).toSorted((e,t)=>e.isEntry===t.isEntry?e.path.localeCompare(t.path):e.isEntry?-1:1).slice(0,r).map(e=>({id:e.id,path:e.path,isEntry:e.isEntry,size:e.code.length,code:t.includeModuleCode?e.code:void 0,mappedPathFrom:n.get(e.id)?.fromPath}));return{type:e.type,entryId:e.entryId,moduleCount:e.modules.size,truncated:e.modules.size>r,mappingsApplied:n.size,modules:i}}async function v(e,t=e){let n=await a(t,{withFileTypes:!0}),r=[];for(let a of n){let n=i.join(t,a.name);if(a.isDirectory()){r.push(...await v(e,n));continue}if(!a.isFile())continue;let o=await s(n);r.push({path:i.relative(e,n).replace(/\\/g,`/`),size:o.size,type:`file`})}return r.toSorted((e,t)=>e.path.localeCompare(t.path))}async function y(t,n){let r=p(n);if(!m()){let n=`webcrack requires Node.js 22.12+ or 24.x; current runtime is ${process.versions.node}`;return e.warn(n),{applied:!1,code:t,optionsUsed:r,reason:n}}try{let{webcrack:e}=await import(`webcrack`),a=await e(t,{jsx:r.jsx,unpack:r.unpack,deobfuscate:!0,unminify:r.unminify,mangle:r.mangle}),s=a.bundle?g(a.bundle,n.mappings):new Map,c,l;if(typeof n.outputDir==`string`&&n.outputDir.trim().length>0){c=i.resolve(n.outputDir);let e=process.cwd(),t=i.relative(e,c);if(i.isAbsolute(t)||t.startsWith(`..`)||c===`/`||c===i.parse(c).root)throw Error(`outputDir must resolve to a path within the project root. Got: ${c}`);n.forceOutput&&await o(c,{recursive:!0,force:!0}),await a.save(c),l=await v(c)}return{applied:!0,code:a.code,bundle:a.bundle?_(a.bundle,{includeModuleCode:n.includeModuleCode,maxBundleModules:n.maxBundleModules},s):void 0,savedTo:c,savedArtifacts:l,optionsUsed:r}}catch(n){let i=n instanceof Error?n.message:String(n);return e.warn(`webcrack execution failed, falling back to legacy pipeline`,n),{applied:!1,code:t,optionsUsed:r,reason:i}}}async function b(e,t,n,r){let i=[],a=[];return n===`obfuscator.io`?x(e,t,r,i,a):n===`jsfuck`?S(e,t,i):n===`jjencode`?C(e,t,i):w(e,t,r,i,a)}async function x(t,n,r,i,a){let o=n,s=.5;try{let c=n.match(/var\s+(_0x[a-f0-9]+)\s*=\s*(\[.*?\]);/s);if(c){let n=c[1],r=c[2];e.info(` : ${n}`);try{let i=await t.sandbox.execute({code:`return ${r||`[]`};`,timeoutMs:3e3}),a=i.ok?i.output:void 0;if(Array.isArray(a)){e.info(`String array detected, ${a.length} strings found`);let t=RegExp(`${n}\\[(\\d+)\\]`,`g`);o=o.replace(t,(e,t)=>{let n=parseInt(t,10);return n<a.length?JSON.stringify(a[n]):e}),s+=.2}}catch(e){i.push(`: ${e}`),a.push({location:`String Array`,reason:``,suggestion:``})}}return o=o.replace(/\(function\s*\(_0x[a-f0-9]+,\s*_0x[a-f0-9]+\)\s*\{[\s\S]*?\}\(_0x[a-f0-9]+,\s*0x[a-f0-9]+\)\);?/g,``),r&&(o=o.replace(/\(function\s*\(\)\s*\{([\s\S]*)\}\(\)\);?/g,`$1`),s+=.1),o=o.replace(/0x([0-9a-f]+)/gi,(e,t)=>String(parseInt(t,16))),o=o.replace(/;\s*;/g,`;`),o=o.replace(/\{\s*\}/g,`{}`),i.push(`obfuscator.io detected, may need special handling`),{code:o,confidence:Math.min(s,1),warnings:i,unresolvedParts:a.length>0?a:void 0}}catch(e){return i.push(`obfuscator.io: ${e}`),{code:n,confidence:.2,warnings:i,unresolvedParts:a}}}async function S(t,n,r){try{e.info(`JSFuck detected, attempting deobfuscation...`);try{if(n.length>1e5)return r.push(`JSFuck code detected, file too large to process directly.`),r.push(`Consider using an online JSFuck decoder tool.`),{code:n,confidence:.1,warnings:r};let i=await t.sandbox.execute({code:`return ${n};`,timeoutMs:5e3}),a=i.ok?i.output:void 0;return typeof a==`string`?(e.info(` JSFuck`),{code:a,confidence:.9,warnings:[`JSFuck`]}):(r.push(`JSFuck`),{code:n,confidence:.2,warnings:r})}catch(e){return r.push(`JSFuck: ${e}`),r.push(`Consider using an online JSFuck decoder tool.`),{code:n,confidence:.1,warnings:r}}}catch(e){return r.push(`JSFuck: ${e}`),{code:n,confidence:.1,warnings:r}}}async function C(t,n,r){try{e.info(`JJEncode detected, attempting deobfuscation...`);try{let i=n.split(`
2
+ `).filter(e=>e.trim());if((i.length>0?i[i.length-1]:``)?.includes(`$$$$`)){let r=await t.sandbox.execute({code:`${n}; return $$$$()`,timeoutMs:5e3}),i=r.ok?r.output:void 0;if(typeof i==`string`)return e.info(` JJEncode`),{code:i,confidence:.9,warnings:[`JJEncode`]}}let a=await t.sandbox.execute({code:n,timeoutMs:5e3});return a.ok||e.warn(`JJEncode sandbox execution failed:`,a.error),r.push(`JJEncode deobfuscation may be incomplete`),r.push(`Result may still contain JJEncode fragments`),{code:n,confidence:.2,warnings:r}}catch(e){return r.push(`JJEncode: ${e}`),r.push(`Result may contain evaluation artifacts`),{code:n,confidence:.1,warnings:r}}}catch(e){return r.push(`JJEncode: ${e}`),{code:n,confidence:.1,warnings:r}}}async function w(e,t,n,r,i){return r.push(`AI-assisted deobfuscation removed, using fallback directly.`),T(t,n,r,i)}function T(e,t,n,r){let i=e,a=.3;try{return i=i.replace(/if\s*\([^)]*\)\s*\{\s*\}/g,``),i=i.replace(/!!\s*\(/g,`Boolean(`),i=i.replace(/""\s*\+\s*/g,``),t&&(i=i.replace(/debugger;?/g,``),a+=.1,i=i.replace(/\?\s*([^:]+)\s*:\s*\1/g,`$1`),a+=.05),n.push(`Analysis incomplete, partial results may be returned`),n.push(`For better results, configure an LLM API key`),r.push({location:`Custom VM`,reason:`VM`,suggestion:`VM protection detected, LLM-assisted analysis recommended`}),{code:i,confidence:a,warnings:n,unresolvedParts:r.length>0?r:void 0}}catch(t){return n.push(`: ${t}`),{code:e,confidence:.1,warnings:n,unresolvedParts:r}}}var E=class{sandbox=new r;async deobfuscate(r){let i=Date.now(),{code:a,aggressive:o=!1,extractInstructions:s=!1,timeout:c=n,maxIterations:l=t}=r;e.info(` JSVMP...`);try{let t=this.detectJSVMP(a);if(!t)return e.info(`JSVMP`),{isJSVMP:!1,deobfuscatedCode:a,confidence:0,warnings:[`JSVMP`]};e.info(`JSVMP analysis complete, complexity: ${t.complexity}`),e.info(` : ${t.instructionCount}`);let n=this.identifyVMType(a,t);e.info(` : ${n}`);let r;s&&(e.info(` ...`),r=this.extractInstructions(a,t),e.info(` ${r.length} `)),e.info(` ...`);let u=await this.restoreCode(a,t,n,o,c,l),d=Date.now()-i,f={isJSVMP:!0,vmType:n,vmFeatures:t,instructions:r,deobfuscatedCode:u.code,confidence:u.confidence,warnings:u.warnings,unresolvedParts:u.unresolvedParts,stats:{originalSize:a.length,deobfuscatedSize:u.code.length,reductionRate:1-u.code.length/a.length,processingTime:d}};return e.info(`JSVMP deobfuscation complete in ${d}ms`),e.info(` : ${(f.confidence*100).toFixed(1)}%`),f}catch(t){return e.error(`JSVMP`,t),{isJSVMP:!1,deobfuscatedCode:a,confidence:0,warnings:[`: ${t}`]}}}detectJSVMP(t){try{let n=c.parse(t,{sourceType:`unambiguous`,plugins:[`jsx`,`typescript`],errorRecovery:!0}),r=!1,i=!1,a=!1,o=0,s=``,u=0,f=!1,p=!1,m=!1,h=!1;if(l(n,{SwitchStatement(e){let t=e.node.cases.length;t>10&&(r=!0,t>u&&(u=t,o=t,s=`Line ${e.node.loc?.start.line||0}`))},ArrayExpression(e){e.node.elements.length>50&&(i=!0)},UpdateExpression(e){if(e.node.operator===`++`||e.node.operator===`--`){let t=e.node.argument;d.isIdentifier(t)&&t.name.length<=3&&(a=!0)}},CallExpression(e){if(d.isIdentifier(e.node.callee,{name:`parseInt`})&&e.node.arguments.length>=2){let t=e.node.arguments[0];d.isBinaryExpression(t)&&t.operator===`+`&&(h=!0,f=!0)}d.isMemberExpression(e.node.callee)&&d.isIdentifier(e.node.callee.property,{name:`apply`})&&(p=!0)},WhileStatement(e){(d.isBooleanLiteral(e.node.test,{value:!0})||d.isNumericLiteral(e.node.test,{value:1}))&&(m=!0)},ForStatement(e){e.node.test||(m=!0)}}),r&&(i||a)&&(p||m||h)){let t=o>100?`high`:o>50?`medium`:`low`;return e.info(` JSVMP:`),e.info(` - Switch: ${r} (${u} cases)`),e.info(` - : ${i}`),e.info(` - : ${a}`),e.info(` - : ${f}`),e.info(` - Apply: ${p}`),e.info(` - : ${m}`),e.info(` - : ${h}`),{instructionCount:o,interpreterLocation:s,complexity:t,hasSwitch:r,hasInstructionArray:i,hasProgramCounter:a}}return null}catch(n){return e.warn(`JSVMP analysis failed`,n),this.detectJSVMPWithRegex(t)}}detectJSVMPWithRegex(t){let n=(t.match(/switch\s*\(/g)?.length||0)>0,r=/parseInt\s*\(\s*["']?\s*\+\s*\w+\[/g.test(t),i=/\.apply\s*\(/g.test(t),a=/while\s*\(\s*(true|1)\s*\)/g.test(t);return n&&(r||i||a)?(e.info(` JSVMP`),{instructionCount:0,interpreterLocation:`Unknown`,complexity:`medium`,hasSwitch:!0,hasInstructionArray:r,hasProgramCounter:i}):null}identifyVMType(e,t){return e.includes(`_0x`)&&e.includes(`function(_0x`)?`obfuscator.io`:/^\s*\[\s*\]\s*\[\s*\(/.test(e)?`jsfuck`:e.includes(`$=~[];`)?`jjencode`:`custom`}extractInstructions(t,n){let r=[];try{l(c.parse(t,{sourceType:`unambiguous`,plugins:[`jsx`,`typescript`]}),{SwitchStatement:e=>{e.node.cases.length===n.instructionCount&&e.node.cases.forEach((e,t)=>{let n=e.test&&(d.isNumericLiteral(e.test)||d.isStringLiteral(e.test))?e.test.value:t,i=this.inferInstructionType(e);r.push({opcode:n,name:`INST_${n}`,type:i,description:`Instruction ${n}`})})}})}catch(t){e.warn(``,t)}return r}inferInstructionType(e){let t=u(e).code,n=e.consequent,r=!1,i=!1,a=!1,o=!1,s=!1;for(let e of n){if(d.isExpressionStatement(e)){let t=e.expression;d.isAssignmentExpression(t)&&(r=!0),d.isMemberExpression(t)&&d.isNumericLiteral(t.property)&&(i=!0),d.isCallExpression(t)&&(a=!0),d.isBinaryExpression(t)&&[`+`,`-`,`*`,`/`,`%`,`**`].includes(t.operator)&&(o=!0)}(d.isIfStatement(e)||d.isWhileStatement(e)||d.isBreakStatement(e)||d.isContinueStatement(e)||d.isReturnStatement(e))&&(s=!0)}return(t.includes(`push`)||t.includes(`.push(`))&&(i||t.includes(`[`))?`load`:r&&!o&&!a?`store`:o||t.match(/[+\-*/%]/)?`arithmetic`:s||t.includes(`break`)||t.includes(`continue`)?`control`:a||t.includes(`.apply(`)||t.includes(`.call(`)?`call`:`unknown`}async restoreCode(e,t,n,r,i,a){return this.restoreCustomVMBasic,b({sandbox:this.sandbox},e,n,r)}restoreCustomVMBasic(e,t,n,r){return T(e,t,n,r)}};function D(e){let t=[],n=e;for(;d.isMemberExpression(n);)d.isIdentifier(n.property)&&t.unshift(n.property.name),n=n.object;return d.isIdentifier(n)&&t.unshift(n.name),t.join(`.`)}function O(e,t){let{callee:n}=e;if(d.isIdentifier(n))return t.has(n.name);if(d.isMemberExpression(n)){let e=D(n);return t.has(e)}return!1}function k(t,n){let r=[];Array.isArray(n.securityRisks)&&n.securityRisks.forEach(e=>{if(typeof e==`object`&&e){let t=e;r.push({type:t.type||`other`,severity:t.severity||`low`,location:{file:`current`,line:t.location?.line||0},description:t.description||``,recommendation:t.recommendation||``})}});try{l(c.parse(t,{sourceType:`module`,plugins:[`jsx`,`typescript`]}),{AssignmentExpression(e){let t=e.node.left,n=e.node.loc?.start.line||0;if(d.isMemberExpression(t)&&d.isIdentifier(t.property)){let i=t.property.name;[`innerHTML`,`outerHTML`,`insertAdjacentHTML`].includes(i)&&r.push({type:`xss`,severity:`high`,location:{file:`current`,line:n},description:`Potential XSS vulnerability: Direct assignment to ${i} without sanitization`,recommendation:`Use textContent for plain text, or DOMPurify.sanitize() for HTML content`}),i===`write`&&d.isIdentifier(t.object)&&t.object.name===`document`&&r.push({type:`xss`,severity:`high`,location:{file:`current`,line:n},description:`Dangerous use of document.write() which can lead to XSS`,recommendation:`Use modern DOM manipulation methods instead`});let a=D(t);if((i===`__proto__`||/(^|\.)constructor\.prototype(\.|$)/.test(a))&&r.push({type:`prototype-pollution`,severity:`high`,location:{file:`current`,line:n},description:`Potential prototype pollution: assignment to ${a}`,recommendation:`Avoid __proto__/constructor.prototype assignment; use Object.create(null) or Map for untrusted keys`}),/^location\.(href|assign|replace)$/i.test(a)){let t=e.node.right;!d.isStringLiteral(t)&&!d.isNumericLiteral(t)&&r.push({type:`open-redirect`,severity:`high`,location:{file:`current`,line:n},description:`Potential open redirect: ${a} assigned a non-literal value`,recommendation:`Validate redirect targets against an allowlist of trusted origins`})}}},CallExpression(e){let t=e.node.callee,n=e.node.loc?.start.line||0;if(d.isIdentifier(t)&&(t.name===`eval`&&r.push({type:`other`,severity:`critical`,location:{file:`current`,line:n},description:`Critical: Use of eval() allows arbitrary code execution`,recommendation:`Refactor to avoid eval(). Use JSON.parse() for data, or proper function calls`}),t.name===`Function`&&r.push({type:`other`,severity:`critical`,location:{file:`current`,line:n},description:`Critical: Function constructor allows code injection`,recommendation:`Use regular function declarations or arrow functions`}),[`setTimeout`,`setInterval`].includes(t.name))){let i=e.node.arguments[0];(d.isStringLiteral(i)||d.isIdentifier(i)&&i.name!==`function`)&&r.push({type:`other`,severity:`medium`,location:{file:`current`,line:n},description:`${t.name}() with string argument can lead to code injection`,recommendation:`Use ${t.name}() with function reference instead of string`})}if(d.isMemberExpression(t)&&d.isIdentifier(t.property)){let i=t.property.name;if([`query`,`execute`,`exec`,`run`].includes(i)){let t=e.node.arguments[0];(d.isBinaryExpression(t)||d.isTemplateLiteral(t))&&r.push({type:`sql-injection`,severity:`critical`,location:{file:`current`,line:n},description:`Potential SQL injection: Query built with string concatenation`,recommendation:`Use parameterized queries or prepared statements`})}}let i=new Set([`merge`,`extend`,`deepCopy`,`deepMerge`,`defaults`,`assign`]);if(d.isIdentifier(t)&&i.has(t.name)&&e.node.arguments.length>=2&&r.push({type:`prototype-pollution`,severity:`medium`,location:{file:`current`,line:n},description:`Potential prototype pollution: ${t.name}() merges untrusted data`,recommendation:`Use a merge that blocks __proto__/constructor keys, or Object.create(null)`}),d.isMemberExpression(t)&&D(t)===`Object.assign`&&e.node.arguments.length>=2){let t=e.node.arguments[0];d.isObjectExpression(t)&&t.properties.length===0&&r.push({type:`prototype-pollution`,severity:`medium`,location:{file:`current`,line:n},description:`Potential prototype pollution: Object.assign({}, untrusted) copies __proto__`,recommendation:`Use Object.create(null) as the target or sanitize source keys`})}let a=new Set([`fetch`,`axios`,`request`]),o=new Set([`get`,`post`,`put`,`delete`,`request`,`open`]),s=new Set([`http`,`https`,`axios`,`xhr`]),c=e.node.arguments[0];c!==void 0&&!d.isStringLiteral(c)&&!d.isNumericLiteral(c)&&(d.isIdentifier(t)&&a.has(t.name)||d.isMemberExpression(t)&&d.isIdentifier(t.property)&&o.has(t.property.name)&&d.isIdentifier(t.object)&&s.has(t.object.name))&&r.push({type:`ssrf`,severity:`high`,location:{file:`current`,line:n},description:`Potential SSRF: network request with a non-literal URL argument`,recommendation:`Validate the URL against an allowlist of trusted hosts before requesting`});let l=new Set([`readFile`,`writeFile`,`readFileSync`,`writeFileSync`,`createReadStream`,`createWriteStream`,`unlink`,`open`]),u=/^(path|file|dir|name|filename|userInput|req|query|params|input)/i;if(d.isMemberExpression(t)&&d.isIdentifier(t.property)&&l.has(t.property.name)||d.isIdentifier(t)&&(t.name===`join`||t.name===`resolve`)){for(let t of e.node.arguments)if(d.isIdentifier(t)&&u.test(t.name)){r.push({type:`path-traversal`,severity:`high`,location:{file:`current`,line:n},description:`Potential path traversal: filesystem call with user-input-named arg "${t.name}"`,recommendation:`Normalize and confine paths to a trusted base directory (path.resolve + prefix check)`});break}}},MemberExpression(e){let t=e.node.object,n=e.node.property,i=e.node.loc?.start.line||0;if(d.isIdentifier(t)&&t.name===`Math`&&d.isIdentifier(n)&&n.name===`random`){let t=e.parent;(d.isCallExpression(t)||d.isBinaryExpression(t))&&r.push({type:`other`,severity:`medium`,location:{file:`current`,line:i},description:`Math.random() is not cryptographically secure`,recommendation:`Use crypto.getRandomValues() or crypto.randomBytes() for security-sensitive operations`})}},VariableDeclarator(e){let t=e.node.id,n=e.node.init,i=e.node.loc?.start.line||0;if(d.isIdentifier(t)&&d.isStringLiteral(n)){let e=t.name.toLowerCase(),a=n.value;for(let{pattern:t,type:n}of[{pattern:/(password|passwd|pwd)/i,type:`password`},{pattern:/(api[_-]?key|apikey)/i,type:`API key`},{pattern:/(secret|token|auth)/i,type:`secret`},{pattern:/(private[_-]?key|privatekey)/i,type:`private key`}])if(t.test(e)&&a.length>8){r.push({type:`other`,severity:`critical`,location:{file:`current`,line:i},description:`Hardcoded ${n} detected in source code`,recommendation:`Store ${n} in environment variables or secure configuration`});break}}}})}catch(t){e.warn(`Static security analysis failed`,t)}return r.filter((e,t,n)=>t===n.findIndex(t=>t.type===e.type&&t.location.line===e.location.line))}const A=new Set([`fetch`,`ajax`,`get`,`post`,`request`,`axios`]);function j(e){let t=e.loc?.start.line??0;if(d.isMemberExpression(e)&&d.isIdentifier(e.property)){let n=e.object,r=e.property.name;if(d.isIdentifier(n)){if(n.name===`location`&&[`href`,`search`,`hash`,`pathname`].includes(r))return{sourceType:`user_input`,sourceLine:t};if(n.name===`document`&&r===`cookie`||n.name===`localStorage`||n.name===`sessionStorage`)return{sourceType:`storage`,sourceLine:t};if(n.name===`window`&&r===`name`)return{sourceType:`user_input`,sourceLine:t};if((n.name===`event`||n.name===`message`)&&r===`data`)return{sourceType:`network`,sourceLine:t}}}if(d.isCallExpression(e)){let n=e.callee;if(d.isMemberExpression(n)&&d.isIdentifier(n.property)&&A.has(n.property.name))return{sourceType:`network`,sourceLine:t}}return null}function M(e){return d.isIdentifier(e.callee)?e.callee.name:null}function N(){return{params:new Set,source:null}}function P(e,t){t.params.forEach(t=>e.params.add(t)),!e.source&&t.source&&(e.source=t.source)}function F(e,t){let n={params:new Set(e.params),source:e.source};return P(n,t),n}function I(e,t){if(!e)return N();if(d.isIdentifier(e))return t.local.get(e.name)??N();let n=j(e);if(n)return{params:new Set,source:n};if(d.isMemberExpression(e))return I(e.object,t);if(d.isBinaryExpression(e))return F(d.isExpression(e.left)?I(e.left,t):N(),I(e.right,t));if(d.isCallExpression(e)){if(t.checkSanitizer(e,t.sanitizers))return N();let n=e.arguments.map(e=>d.isExpression(e)?I(e,t):N()),r=M(e);if(r&&t.summaries.has(r)){let e=t.summaries.get(r),i={params:new Set,source:e.returnsSource};return e.taintedParamIndices.forEach(e=>{let t=n[e];t&&P(i,t)}),i}let i=N();for(let e of n)P(i,e);return i}return N()}function L(e,t,n){if(d.isVariableDeclaration(e)){for(let n of e.declarations)d.isIdentifier(n.id)&&n.init&&t.local.set(n.id.name,I(n.init,t));return}if(d.isExpressionStatement(e)&&d.isAssignmentExpression(e.expression)){let{left:n,right:r}=e.expression;if(d.isIdentifier(n)){let e=t.local.get(n.name)??N();t.local.set(n.name,F(e,I(r,t)))}return}if(d.isReturnStatement(e)){e.argument&&P(n,I(e.argument,t));return}if(d.isIfStatement(e)){L(e.consequent,t,n),e.alternate&&L(e.alternate,t,n);return}if(d.isBlockStatement(e)){for(let r of e.body)L(r,t,n);return}if(d.isForStatement(e)||d.isForInStatement(e)||d.isForOfStatement(e)||d.isWhileStatement(e)||d.isDoWhileStatement(e)){e.body&&L(e.body,t,n);return}d.isTryStatement(e)&&(e.block&&L(e.block,t,n),e.handler?.body&&L(e.handler.body,t,n),e.finalizer&&L(e.finalizer,t,n))}function R(e,t,n,r){let i=new Map;e.params.forEach((e,t)=>{e&&i.set(e,{params:new Set([t]),source:null})});let a={local:i,summaries:t,sanitizers:n,checkSanitizer:r},o=N();if(d.isBlockStatement(e.body))for(let t of e.body.body)L(t,a,o);else P(o,I(e.body,a));return o}function z(e,t){if(e.taintedParamIndices.size!==t.taintedParamIndices.size)return!1;for(let n of e.taintedParamIndices)if(!t.taintedParamIndices.has(n))return!1;return!!e.returnsSource==!!t.returnsSource}function B(e,t,n){let r=new Map,i=(e,t)=>{if(r.has(e))return;let n=t.params.map(e=>d.isIdentifier(e)?e.name:null);r.set(e,{params:n,body:t.body})};l(e,{FunctionDeclaration(e){e.node.id&&i(e.node.id.name,e.node)},VariableDeclarator(e){let t=e.node.init;d.isIdentifier(e.node.id)&&(d.isFunctionExpression(t)||d.isArrowFunctionExpression(t))&&i(e.node.id.name,t)},AssignmentExpression(e){let{left:t,right:n}=e.node;d.isIdentifier(t)&&(d.isFunctionExpression(n)||d.isArrowFunctionExpression(n))&&i(t.name,n)}});let a=new Map;for(let e of r.keys())a.set(e,{taintedParamIndices:new Set,returnsSource:null});let o=Math.min(Math.max(r.size,8),64);for(let e=0;e<o;e+=1){let e=!1;for(let[i,o]of r){let r=R(o,a,t,n),s={taintedParamIndices:r.params,returnsSource:r.source};z(a.get(i),s)||(a.set(i,s),e=!0)}if(!e)break}return a}function V(e){return e===`user_input`||e===`storage`||e===`network`||e===`other`?e:e===`url`?`user_input`:`other`}async function H(t){let n={nodes:[],edges:[]},r=[],i=[],a=[],o=new Map,s=[],u=new Set(`encodeURIComponent,encodeURI,escape,decodeURIComponent,decodeURI,htmlentities,htmlspecialchars,escapeHtml,escapeHTML,he.encode,he.escape,validator.escape,validator.unescape,validator.stripLow,validator.blacklist,validator.whitelist,validator.trim,validator.isEmail,validator.isURL,validator.isInt,DOMPurify.sanitize,DOMPurify.addHook,crypto.encrypt,crypto.hash,crypto.createHash,crypto.createHmac,CryptoJS.AES.encrypt,CryptoJS.SHA256,CryptoJS.MD5,bcrypt.hash,bcrypt.compare,btoa,atob,Buffer.from,db.prepare,db.query,mysql.escape,pg.query,xss,sanitizeHtml,parseInt,parseFloat,Number,String,JSON.stringify,JSON.parse,String.prototype.replace,String.prototype.trim,Array.prototype.filter,Array.prototype.map,Math.max,Math.min,Math.floor,Math.ceil,Math.round,Math.abs,Math.trunc,Math.sign,Math.sqrt,Math.pow,Math.log,Math.exp,Math.random,Math.hypot,Math.fround,Number.prototype.toString,Number.prototype.toFixed,Number.prototype.toPrecision`.split(`,`));try{let f=c.parse(t,{sourceType:`module`,plugins:[`jsx`,`typescript`]});l(f,{CallExpression(e){let t=e.node.callee,c=e.node.loc?.start.line||0;if(d.isMemberExpression(t)&&d.isIdentifier(t.property)){let i=t.property.name;if([`fetch`,`ajax`,`get`,`post`,`request`,`axios`].includes(i)){let t=`source-network-${c}`;r.push({type:`network`,location:{file:`current`,line:c}}),n.nodes.push({id:t,name:`${i}()`,type:`source`,location:{file:`current`,line:c}});let a=e.parent;d.isVariableDeclarator(a)&&d.isIdentifier(a.id)&&o.set(a.id.name,{sourceType:`user_input`,sourceLine:c})}else if([`querySelector`,`getElementById`,`getElementsByClassName`,`getElementsByTagName`].includes(i)){let e=`source-dom-${c}`;r.push({type:`user_input`,location:{file:`current`,line:c}}),n.nodes.push({id:e,name:`${i}()`,type:`source`,location:{file:`current`,line:c}})}}if(d.isIdentifier(t)){let r=t.name;if([`eval`,`Function`,`setTimeout`,`setInterval`].includes(r)){let t=`sink-eval-${c}`;i.push({type:`eval`,location:{file:`current`,line:c}}),n.nodes.push({id:t,name:`${r}()`,type:`sink`,location:{file:`current`,line:c}}),U(e.node.arguments,o,a,r,c),s.push({args:e.node.arguments,sinkType:`eval`,line:c})}}if(d.isMemberExpression(t)&&d.isIdentifier(t.property)){let r=t.property.name;if([`write`,`writeln`].includes(r)&&d.isIdentifier(t.object)&&t.object.name===`document`){let t=`sink-document-write-${c}`;i.push({type:`xss`,location:{file:`current`,line:c}}),n.nodes.push({id:t,name:`document.${r}()`,type:`sink`,location:{file:`current`,line:c}}),U(e.node.arguments,o,a,r,c),s.push({args:e.node.arguments,sinkType:`xss`,line:c})}if([`query`,`execute`,`exec`,`run`].includes(r)){let t=`sink-sql-${c}`;i.push({type:`sql-injection`,location:{file:`current`,line:c}}),n.nodes.push({id:t,name:`${r}() (SQL)`,type:`sink`,location:{file:`current`,line:c}}),U(e.node.arguments,o,a,r,c),s.push({args:e.node.arguments,sinkType:`sql-injection`,line:c})}if([`exec`,`spawn`,`execSync`,`spawnSync`].includes(r)){let t=`sink-command-${c}`;i.push({type:`other`,location:{file:`current`,line:c}}),n.nodes.push({id:t,name:`${r}() (Command)`,type:`sink`,location:{file:`current`,line:c}}),U(e.node.arguments,o,a,r,c),s.push({args:e.node.arguments,sinkType:`other`,line:c})}if([`readFile`,`writeFile`,`readFileSync`,`writeFileSync`,`open`].includes(r)){let t=`sink-file-${c}`;i.push({type:`other`,location:{file:`current`,line:c}}),n.nodes.push({id:t,name:`${r}() (File)`,type:`sink`,location:{file:`current`,line:c}}),U(e.node.arguments,o,a,r,c),s.push({args:e.node.arguments,sinkType:`other`,line:c})}}},MemberExpression(e){let t=e.node.object,i=e.node.property,a=e.node.loc?.start.line||0;if(d.isIdentifier(t)&&t.name===`location`&&d.isIdentifier(i)&&[`href`,`search`,`hash`,`pathname`].includes(i.name)){let t=`source-url-${a}`;r.push({type:`user_input`,location:{file:`current`,line:a}}),n.nodes.push({id:t,name:`location.${i.name}`,type:`source`,location:{file:`current`,line:a}});let s=e.parent;d.isVariableDeclarator(s)&&d.isIdentifier(s.id)&&o.set(s.id.name,{sourceType:`user_input`,sourceLine:a})}if(d.isIdentifier(t)&&t.name===`document`&&d.isIdentifier(i)&&i.name===`cookie`){let e=`source-cookie-${a}`;r.push({type:`storage`,location:{file:`current`,line:a}}),n.nodes.push({id:e,name:`document.cookie`,type:`source`,location:{file:`current`,line:a}})}if(d.isIdentifier(t)&&[`localStorage`,`sessionStorage`].includes(t.name)){let e=`source-storage-${a}`;r.push({type:`storage`,location:{file:`current`,line:a}}),n.nodes.push({id:e,name:`${t.name}.getItem()`,type:`source`,location:{file:`current`,line:a}})}if(d.isIdentifier(t)&&t.name===`window`&&d.isIdentifier(i)&&i.name===`name`){let e=`source-window-name-${a}`;r.push({type:`user_input`,location:{file:`current`,line:a}}),n.nodes.push({id:e,name:`window.name`,type:`source`,location:{file:`current`,line:a}})}if(d.isIdentifier(t)&&t.name===`event`&&d.isIdentifier(i)&&i.name===`data`){let e=`source-postmessage-${a}`;r.push({type:`network`,location:{file:`current`,line:a}}),n.nodes.push({id:e,name:`event.data (postMessage)`,type:`source`,location:{file:`current`,line:a}})}if(d.isIdentifier(t)&&t.name===`message`&&d.isIdentifier(i)&&i.name===`data`){let e=`source-websocket-${a}`;r.push({type:`network`,location:{file:`current`,line:a}}),n.nodes.push({id:e,name:`WebSocket message.data`,type:`source`,location:{file:`current`,line:a}})}},AssignmentExpression(e){let t=e.node.left,r=e.node.right,c=e.node.loc?.start.line||0;if(d.isMemberExpression(t)&&d.isIdentifier(t.property)){let e=t.property.name;if([`innerHTML`,`outerHTML`].includes(e)){let t=`sink-dom-${c}`;if(i.push({type:`xss`,location:{file:`current`,line:c}}),n.nodes.push({id:t,name:e,type:`sink`,location:{file:`current`,line:c}}),s.push({args:[r],sinkType:`xss`,line:c}),d.isIdentifier(r)&&o.has(r.name)){let e=o.get(r.name);a.push({source:{type:e.sourceType,location:{file:`current`,line:e.sourceLine}},sink:{type:`xss`,location:{file:`current`,line:c}},path:[{file:`current`,line:e.sourceLine},{file:`current`,line:c}]})}}}}}),l(f,{VariableDeclarator(t){let n=t.node.id,r=t.node.init;if(d.isIdentifier(n)&&r){if(d.isCallExpression(r)&&O(r,u)){let t=r.arguments[0];if(d.isIdentifier(t)&&o.has(t.name)){e.debug(`Taint cleaned by sanitizer: ${t.name} -> ${n.name}`);return}}if(d.isIdentifier(r)&&o.has(r.name)){let e=o.get(r.name);o.set(n.name,e)}else if(d.isBinaryExpression(r)){let e=d.isIdentifier(r.left)&&o.has(r.left.name),t=d.isIdentifier(r.right)&&o.has(r.right.name);if(e||t){let t=e?o.get(r.left.name):o.get(r.right.name);o.set(n.name,t)}}}},AssignmentExpression(e){let t=e.node.left,n=e.node.right;if(d.isIdentifier(t)&&d.isIdentifier(n)&&o.has(n.name)){let e=o.get(n.name);o.set(t.name,e)}}});let p=B(f,u,O),m=e=>{if(!e)return null;if(d.isIdentifier(e))return o.get(e.name)??null;let t=j(e);if(t)return t;if(d.isMemberExpression(e))return m(e.object);if(d.isBinaryExpression(e))return(d.isExpression(e.left)?m(e.left):null)??m(e.right);if(d.isCallExpression(e)){if(O(e,u))return null;let t=e.arguments.map(e=>d.isExpression(e)?m(e):null),n=M(e);if(n&&p.has(n)){let e=p.get(n);for(let n of e.taintedParamIndices){let e=t[n];if(e)return e}return e.returnsSource}for(let e of t)if(e)return e}return null},h=!0,g=0;for(;h&&g<100;)h=!1,g+=1,l(f,{Function(e){e.skip()},VariableDeclarator(e){let t=e.node.id;if(d.isIdentifier(t)&&!o.has(t.name)&&e.node.init){let n=m(e.node.init);n&&(o.set(t.name,n),h=!0)}},AssignmentExpression(e){let t=e.node.left;if(d.isIdentifier(t)&&!o.has(t.name)){let n=m(e.node.right);n&&(o.set(t.name,n),h=!0)}}});let _=new Set(a.map(e=>`${e.source.location.line}->${e.sink.location.line}:${e.sink.type}`));for(let e of s)for(let t of e.args){if(!d.isIdentifier(t)||!o.has(t.name))continue;let n=o.get(t.name),r=`${n.sourceLine}->${e.line}:${e.sinkType}`;_.has(r)||(_.add(r),a.push({source:{type:V(n.sourceType),location:{file:`current`,line:n.sourceLine}},sink:{type:e.sinkType,location:{file:`current`,line:e.line}},path:[{file:`current`,line:n.sourceLine},{file:`current`,line:e.line}]}))}}catch(t){e.warn(`Data flow analysis failed`,t)}return{graph:n,sources:r,sinks:i,taintPaths:a}}function U(e,t,n,r,i){e.forEach(e=>{if(d.isIdentifier(e)&&t.has(e.name)){let r=t.get(e.name);n.push({source:{type:r.sourceType,location:{file:`current`,line:r.sourceLine}},sink:{type:`eval`,location:{file:`current`,line:i}},path:[{file:`current`,line:r.sourceLine},{file:`current`,line:i}]})}})}export{y as i,k as n,E as r,H as t};
@@ -0,0 +1 @@
1
+ import{lr as e}from"./constants-nvsLpSri.mjs";import{t}from"./ToolError-g3rjWzhx.mjs";import{_ as n,d as r,g as i,h as a,l as o,m as s,p as c,t as l,w as u,y as d}from"./Win32API-G7QPyckq.mjs";import{n as f}from"./NativeMemoryManager.utils-CMoul2an.mjs";import{t as p}from"./NativeMemoryManager.impl-BIJzXMqH.mjs";import{FlushInstructionCache as m}from"./Win32Debug-6yzmtv5b.mjs";import{randomUUID as h}from"node:crypto";var g=class{patches=new Map;async patchBytes(e,t,n){let a=BigInt(t.startsWith(`0x`)?t:`0x${t}`),o=Buffer.from(n),s=u(e,!0);try{let t=c(s,a,o.length),{success:l,oldProtect:u}=i(s,a,o.length,r.EXECUTE_READWRITE);d(s,a,o),m(s,a,o.length),l&&i(s,a,o.length,u);let f={id:h(),pid:e,address:`0x${a.toString(16).toUpperCase()}`,originalBytes:Array.from(t),patchBytes:n,isApplied:!0,timestamp:Date.now()};return this.patches.set(f.id,f),f}finally{l(s)}}async unpatch(e){let t=this.patches.get(e);if(!t?.isApplied)return!1;let n=BigInt(t.address),a=Buffer.from(t.originalBytes),o=u(t.pid,!0);try{let{oldProtect:e}=i(o,n,a.length,r.EXECUTE_READWRITE);return d(o,n,a),m(o,n,a.length),i(o,n,a.length,e),t.isApplied=!1,!0}finally{l(o)}}async nopBytes(e,t,n){let r=Array.from({length:n},()=>144);return this.patchBytes(e,t,r)}async findCodeCaves(t,r){let i=r??e,a=[],o=u(t,!1);try{let e=await p.enumerateModules(t);if(!e.success||!e.modules)return a;for(let t of e.modules){let e=BigInt(t.baseAddress.startsWith(`0x`)?t.baseAddress:`0x${t.baseAddress}`),r=e,s=e+BigInt(t.size);for(;r<s;){let{success:e,info:s}=n(o,r);if(!e||s.RegionSize===0n)break;let l=Number(s.RegionSize);if(f(s.Protect)&&l>0)try{let e=c(o,s.BaseAddress,Math.min(l,4*1024*1024)),n=-1;for(let r=0;r<e.length;r++){let o=e[r];if(o===0||o===204)n===-1&&(n=r);else if(n!==-1){let e=r-n;if(e>=i){let r=s.BaseAddress+BigInt(n);a.push({address:`0x${r.toString(16).toUpperCase()}`,size:e,module:t.name,section:`.text`})}n=-1}}if(n!==-1){let r=e.length-n;if(r>=i){let e=s.BaseAddress+BigInt(n);a.push({address:`0x${e.toString(16).toUpperCase()}`,size:r,module:t.name,section:`.text`})}}}catch{}r=s.BaseAddress+s.RegionSize}}}finally{l(o)}return a.toSorted((e,t)=>t.size-e.size)}async allocateRemote(e,n){let i=u(e,!0);try{let e=s(i,0n,n,o.COMMIT|o.RESERVE,r.EXECUTE_READWRITE);if(e===0n)throw new t(`RUNTIME`,`VirtualAllocEx failed`);return`0x${e.toString(16).toUpperCase()}`}finally{l(i)}}async freeRemote(e,t,n){let r=BigInt(t.startsWith(`0x`)?t:`0x${t}`),i=u(e,!0);try{return a(i,r,0,o.RELEASE)}finally{l(i)}}listPatches(){return Array.from(this.patches.values())}};const _=new g;export{g as CodeInjector,_ as codeInjector};
@@ -0,0 +1,306 @@
1
+ import{t as e}from"./logger-BGCcd-jJ.mjs";import{_ as t,v as n}from"./ensure-browser-core-BP70x0TB.mjs";import{randomUUID as r}from"node:crypto";function i(e){return Array.isArray(e)}function a(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.xhrCleared==`number`&&typeof t.fetchCleared==`number`}function o(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.xhrReset==`boolean`&&typeof t.fetchReset==`boolean`}function s(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.url==`function`&&typeof t.method==`function`&&typeof t.headers==`function`&&typeof t.postData==`function`&&typeof t.resourceType==`function`}function c(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.request==`function`&&typeof t.url==`function`&&typeof t.status==`function`&&typeof t.statusText==`function`&&typeof t.headers==`function`}function l(e){if(typeof e!=`string`)return;let t=e.trim().toLowerCase();if(t===`http/1.0`||t===`1.0`)return`1.0`;if(t===`http/1.1`||t===`1.1`)return`1.1`;if(t===`http/2`||t===`2`||t===`2.0`||t===`h2`)return`h2`;if(t===`http/3`||t===`3`||t===`3.0`||t===`h3`)return`h3`}function u(e){return l(typeof e.httpVersion==`function`?e.httpVersion():void 0)||l(typeof e.protocol==`function`?e.protocol():void 0)}var d=class{cache=new Map;maxEntries;constructor(e=200){this.maxEntries=e}setMaxEntries(e){this.maxEntries=e}set(t,n,r,i,a){if(a>1048576){e.debug(`[PW-BodyCache] Skipping oversized body for ${t} (${a} bytes)`);return}if(this.cache.size>=this.maxEntries){let e=this.cache.keys().next().value;e&&this.cache.delete(e)}this.cache.set(t,{body:n,base64Encoded:r}),e.debug(`[PW-BodyCache] Cached body for ${t} (${a} bytes)`)}get(t){let n=this.cache.get(t);return n?(this.cache.delete(t),this.cache.set(t,n),e.debug(`[PW-BodyCache] Cache hit for ${t}`),n):(e.warn(`getResponseBody: no cached body for ${t} in Playwright mode`),null)}clear(){this.cache.clear()}get size(){return this.cache.size}};function f(e){return/^(text\/|application\/(json|javascript|xml|x-www-form-urlencoded))/i.test(e)}async function p(e,t){if(!e.evaluate)throw Error(`Playwright page.evaluate is not available`);return e.evaluate(t)}async function m(e,t){if(!e.evaluateOnNewDocument)throw Error(`Playwright page.evaluateOnNewDocument is not available`);return e.evaluateOnNewDocument(t)}async function h(e,t){let n=`
2
+ (function() {
3
+ if (window.__xhrInterceptorInjected) return;
4
+ window.__xhrInterceptorInjected = true;
5
+ const maxRecords = 500;
6
+ const OrigXHR = window.__pwOriginalXMLHttpRequest || window.XMLHttpRequest;
7
+ window.__pwOriginalXMLHttpRequest = OrigXHR;
8
+ if (!window.__xhrRequests) window.__xhrRequests = [];
9
+ window.XMLHttpRequest = function() {
10
+ const xhr = new OrigXHR();
11
+ const origOpen = xhr.open.bind(xhr);
12
+ const origSend = xhr.send.bind(xhr);
13
+ xhr.open = function(method, url, ...rest) {
14
+ xhr.__hookMeta = { method, url, timestamp: Date.now() };
15
+ return origOpen(method, url, ...rest);
16
+ };
17
+ xhr.send = function(body) {
18
+ xhr.addEventListener('load', function() {
19
+ window.__xhrRequests.push({
20
+ ...xhr.__hookMeta, body: body ? String(body).slice(0, 2048) : null,
21
+ status: xhr.status, response: xhr.responseText.slice(0, 2048),
22
+ });
23
+ if (window.__xhrRequests.length > maxRecords) {
24
+ window.__xhrRequests.splice(0, window.__xhrRequests.length - maxRecords);
25
+ }
26
+ });
27
+ return origSend(body);
28
+ };
29
+ return xhr;
30
+ };
31
+ console.log('[PlaywrightXHR] XHR interceptor injected');
32
+ })();
33
+ `;t?.persistent?await m(e,n):await p(e,n)}async function g(e,t){let n=`
34
+ (function() {
35
+ if (window.__fetchInterceptorInjected) return;
36
+ window.__fetchInterceptorInjected = true;
37
+ const maxRecords = 500;
38
+ const origFetch = window.__pwOriginalFetch || window.fetch;
39
+ window.__pwOriginalFetch = origFetch;
40
+ if (!window.__fetchRequests) window.__fetchRequests = [];
41
+ const normalizeHeaders = (value) => {
42
+ if (!value) return {};
43
+ try {
44
+ if (typeof Headers !== 'undefined' && value instanceof Headers) {
45
+ return Object.fromEntries(value.entries());
46
+ }
47
+ } catch {}
48
+ if (Array.isArray(value)) {
49
+ try {
50
+ return Object.fromEntries(value);
51
+ } catch {
52
+ return {};
53
+ }
54
+ }
55
+ return typeof value === 'object' ? value : {};
56
+ };
57
+ window.fetch = function(...args) {
58
+ const [resource, opts = {}] = args;
59
+ const requestLike = resource && typeof resource === 'object' ? resource : null;
60
+ const url =
61
+ typeof resource === 'string'
62
+ ? resource
63
+ : typeof resource?.url === 'string'
64
+ ? resource.url
65
+ : String(resource);
66
+ const method = opts?.method || requestLike?.method || 'GET';
67
+ const headers = normalizeHeaders(opts?.headers || requestLike?.headers);
68
+ const bodySource = opts?.body;
69
+ const body =
70
+ bodySource === undefined || bodySource === null
71
+ ? null
72
+ : String(bodySource).slice(0, 2048);
73
+ const entry = {
74
+ url,
75
+ method,
76
+ headers,
77
+ body,
78
+ timestamp: Date.now(),
79
+ response: null,
80
+ status: 0,
81
+ };
82
+ return origFetch.apply(this, args).then(res => {
83
+ entry.status = res.status;
84
+ return res.clone().text().then(
85
+ (text) => {
86
+ entry.response = text.slice(0, 2048);
87
+ return res;
88
+ },
89
+ () => {
90
+ entry.response = '[Unable to read response]';
91
+ return res;
92
+ },
93
+ ).then((response) => {
94
+ window.__fetchRequests.push(entry);
95
+ if (window.__fetchRequests.length > maxRecords) {
96
+ window.__fetchRequests.splice(0, window.__fetchRequests.length - maxRecords);
97
+ }
98
+ // Auto-persist compact summary so data survives context compression
99
+ try {
100
+ const s = { url: entry.url, method: entry.method, status: entry.status, ts: entry.timestamp };
101
+ const prev = JSON.parse(localStorage.getItem('__capturedAPIs') || '[]');
102
+ prev.push(s);
103
+ if (prev.length > 500) prev.splice(0, prev.length - 500);
104
+ localStorage.setItem('__capturedAPIs', JSON.stringify(prev));
105
+ } catch(e) {}
106
+ return response;
107
+ });
108
+ });
109
+ };
110
+ console.log('[PlaywrightFetch] Fetch interceptor injected');
111
+ })();
112
+ `;t?.persistent?await m(e,n):await p(e,n)}async function ee(e){try{let t=await p(e,()=>window.__xhrRequests??[]);return i(t)?t:[]}catch{return[]}}async function te(e){try{let t=await p(e,()=>window.__fetchRequests??[]);return i(t)?t:[]}catch{return[]}}async function ne(e){try{let t=await p(e,()=>{let e=window,t=e.__xhrRequests,n=e.__fetchRequests,r=Array.isArray(t)?t.length:0,i=Array.isArray(n)?n.length:0;return Array.isArray(t)&&(t.length=0),Array.isArray(n)&&(n.length=0),{xhrCleared:r,fetchCleared:i}});return a(t)?t:{xhrCleared:0,fetchCleared:0}}catch{return{xhrCleared:0,fetchCleared:0}}}async function _(e){try{let t=await p(e,()=>{let e=window,t=!1,n=!1;return e.__pwOriginalXMLHttpRequest&&(e.XMLHttpRequest=e.__pwOriginalXMLHttpRequest,t=!0),e.__pwOriginalFetch&&(e.fetch=e.__pwOriginalFetch,n=!0),Array.isArray(e.__xhrRequests)&&(e.__xhrRequests.length=0),Array.isArray(e.__fetchRequests)&&(e.__fetchRequests.length=0),e.__xhrInterceptorInjected=!1,e.__fetchInterceptorInjected=!1,{xhrReset:t,fetchReset:n}});return o(t)?t:{xhrReset:!1,fetchReset:!1}}catch{return{xhrReset:!1,fetchReset:!1}}}var v=class{page;networkEnabled=!1;requests=new Map;responses=new Map;MAX_NETWORK_RECORDS=500;requestCounter=0;responseBodyCache;set MAX_BODY_CACHE_ENTRIES(e){this.responseBodyCache.setMaxEntries(e)}requestIdMap=new WeakMap;boundOnRequest=null;boundOnResponse=null;constructor(e){this.page=e,this.responseBodyCache=new d(200)}setPage(e){if(this.page===e)return;let t=this.page,n=this.networkEnabled,r=this.boundOnRequest,i=this.boundOnResponse;if(n&&t&&r)try{t.off(`request`,r)}catch{}if(n&&t&&i)try{t.off(`response`,i)}catch{}if(this.page=e,!n||!this.page){this.page||(this.networkEnabled=!1);return}r&&this.page.on(`request`,r),i&&this.page.on(`response`,i)}getPageOrThrow(){if(!this.page)throw Error(`Playwright page not initialized`);return this.page}async evaluateInPage(e){let t=this.getPageOrThrow();if(!t.evaluate)throw Error(`Playwright page.evaluate is not available`);return t.evaluate(e)}async enable(){if(this.networkEnabled){e.warn(`PlaywrightNetworkMonitor already enabled`);return}this.boundOnRequest=e=>{if(!s(e))return;let t=`pw-${++this.requestCounter}`;this.requestIdMap.set(e,t);let n={requestId:t,url:e.url(),method:e.method(),headers:e.headers(),postData:e.postData()??void 0,timestamp:Date.now(),type:e.resourceType()};if(this.requests.set(t,n),this.requests.size>this.MAX_NETWORK_RECORDS){let e=this.requests.keys().next().value;e&&this.requests.delete(e)}},this.boundOnResponse=t=>{if(!c(t))return;let n=t.request(),r=`pw-res-${Date.now()}-${Math.random()}`,i=s(n)?this.requestIdMap.get(n)??r:r,a=u(t),o=this.requests.get(i);o&&a&&(o.httpVersion=a);let l={requestId:i,url:t.url(),status:t.status(),statusText:t.statusText(),headers:t.headers(),mimeType:t.headers()[`content-type`]??`unknown`,timestamp:Date.now()};if(this.responses.set(i,l),this.responses.size>this.MAX_NETWORK_RECORDS){let e=this.responses.keys().next().value;e&&this.responses.delete(e)}if(typeof t.body==`function`){let n=i;t.body().then(e=>{f(l.mimeType)?this.responseBodyCache.set(n,e.toString(`utf-8`),!1,l.mimeType,e.length):this.responseBodyCache.set(n,e.toString(`base64`),!0,l.mimeType,e.length)}).catch(t=>{e.debug(`[PW-BodyCache] Could not capture body for ${n}: ${t instanceof Error?t.message:String(t)}`)})}};let t=this.getPageOrThrow();t.on(`request`,this.boundOnRequest),t.on(`response`,this.boundOnResponse),this.networkEnabled=!0,e.info(`PlaywrightNetworkMonitor enabled`)}async disable(){let t=this.getPageOrThrow();if(this.boundOnRequest){try{t.off(`request`,this.boundOnRequest)}catch{}this.boundOnRequest=null}if(this.boundOnResponse){try{t.off(`response`,this.boundOnResponse)}catch{}this.boundOnResponse=null}this.networkEnabled=!1,e.info(`PlaywrightNetworkMonitor disabled`)}isEnabled(){return this.networkEnabled}getRequests(e){let t=Array.from(this.requests.values());return e?.url&&(t=t.filter(t=>t.url.includes(e.url))),e?.method&&(t=t.filter(t=>t.method.toUpperCase()===e.method.toUpperCase())),e?.limit&&(t=t.slice(-e.limit)),t}getResponses(e){let t=Array.from(this.responses.values());return e?.url&&(t=t.filter(t=>t.url.includes(e.url))),e?.status&&(t=t.filter(t=>t.status===e.status)),e?.limit&&(t=t.slice(-e.limit)),t}getStatus(){return{enabled:this.networkEnabled,requestCount:this.requests.size,responseCount:this.responses.size,listenerCount:this.networkEnabled?2:0,cdpSessionActive:!1}}getActivity(e){return{request:this.requests.get(e),response:this.responses.get(e)}}clearRecords(){this.requests.clear(),this.responses.clear(),this.responseBodyCache.clear()}getStats(){let e=Array.from(this.requests.values()),t=Array.from(this.responses.values()),n={};e.forEach(e=>{n[e.method]=(n[e.method]||0)+1});let r={};t.forEach(e=>{r[e.status]=(r[e.status]||0)+1});let i={};return e.forEach(e=>{let t=e.type||`unknown`;i[t]=(i[t]||0)+1}),{totalRequests:e.length,totalResponses:t.length,byMethod:n,byStatus:r,byType:i}}async getResponseBody(e){return this.responseBodyCache.get(e)}async injectScript(e){await this.evaluateInPage(e)}async injectXHRInterceptor(e){await h(this.getPageOrThrow(),e)}async injectFetchInterceptor(e){await g(this.getPageOrThrow(),e)}async getXHRRequests(){return ee(this.getPageOrThrow())}async getFetchRequests(){return te(this.getPageOrThrow())}async clearInjectedBuffers(){return ne(this.getPageOrThrow())}async resetInjectedInterceptors(){return _(this.getPageOrThrow())}async getAllJavaScriptResponses(){return Array.from(this.responses.values()).filter(e=>e.mimeType.includes(`javascript`))}},y=class{cdpSession;rules=new Map;enabled=!1;eventHandler=null;compiledPatterns=new Map;constructor(e){this.cdpSession=e}async enable(t){let n=[];for(let e of t){let t=this.createRule(e);this.rules.set(t.id,t),this.compiledPatterns.set(t.id,this.compilePattern(t)),n.push(t)}return await this.applyRules(),this.eventHandler||(this.eventHandler=e=>{this.handleRequestPaused(e)},this.cdpSession.on(`Fetch.requestPaused`,this.eventHandler)),this.enabled=!0,e.info(`FetchInterceptor enabled with ${this.rules.size} rule(s)`),n}async disable(){let t=this.rules.size;if(this.eventHandler){try{this.cdpSession.off(`Fetch.requestPaused`,this.eventHandler)}catch{}this.eventHandler=null}try{await this.cdpSession.send(`Fetch.disable`)}catch(t){e.warn(`Fetch.disable failed:`,t)}return this.rules.clear(),this.compiledPatterns.clear(),this.enabled=!1,e.info(`FetchInterceptor disabled, removed ${t} rule(s)`),{removedRules:t}}async removeRule(e){let t=this.rules.delete(e);return this.compiledPatterns.delete(e),t&&(this.rules.size===0?await this.disable():await this.applyRules()),t}listRules(){let e=Array.from(this.rules.values());return{enabled:this.enabled,rules:e,totalHits:e.reduce((e,t)=>e+t.hitCount,0)}}isEnabled(){return this.enabled}createRule(e){let t=[];if(e.responseHeaders)for(let[n,r]of Object.entries(e.responseHeaders))t.push({name:n,value:r});return{id:r().slice(0,8),urlPattern:e.urlPattern,urlPatternType:e.urlPatternType??`glob`,stage:e.stage??`Response`,interceptAction:e.interceptAction??`fulfill`,responseCode:e.responseCode??200,responseHeaders:t,responseBody:e.responseBody??``,hitCount:0,createdAt:Date.now()}}compilePattern(e){if(e.urlPatternType===`regex`)try{return new RegExp(e.urlPattern,`i`)}catch{return new RegExp(e.urlPattern.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),`i`)}let t=e.urlPattern.replace(/[.+?^${}()|[\]\\]/g,`\\$&`).replace(/\*\*/g,`⟨GLOBSTAR⟩`).replace(/\*/g,`[^/]*`).replace(/⟨GLOBSTAR⟩/g,`.*`);return new RegExp(t,`i`)}async applyRules(){let t=[];for(let e of this.rules.values())t.push({urlPattern:e.urlPatternType===`glob`?e.urlPattern:`*`,requestStage:e.stage});if(t.length!==0)try{try{await this.cdpSession.send(`Fetch.disable`)}catch{}await this.cdpSession.send(`Fetch.enable`,{patterns:t.length>0?t:[{urlPattern:`*`,requestStage:`Response`}],handleAuthRequests:!1})}catch(t){throw e.error(`Failed to apply Fetch interception rules:`,t),t}}async handleRequestPaused(t){let n=t.request.url;for(let[r,i]of this.rules){let a=this.compiledPatterns.get(r);if(a&&a.test(n)&&(i.hitCount++,e.info(`[FetchInterceptor] Rule "${i.urlPattern}" matched: ${n}`),await this.applyMatchedRule(i,t,n)))return}await this.continueOriginalRequest(t,n)}async applyMatchedRule(t,n,r){try{switch(t.interceptAction){case`continue`:return await this.continuePausedRequest(n),!0;case`abort`:return await this.cdpSession.send(`Fetch.failRequest`,{requestId:n.requestId,errorReason:`Failed`}),!0;case`fulfill`:return await this.cdpSession.send(`Fetch.fulfillRequest`,{requestId:n.requestId,responseCode:t.responseCode,responseHeaders:this.buildFulfillHeaders(t),body:Buffer.from(t.responseBody,`utf-8`).toString(`base64`)}),!0}}catch(n){return e.error(`[FetchInterceptor] ${t.interceptAction} failed for ${r}:`,n),!1}}buildFulfillHeaders(e){let t=[...e.responseHeaders];return t.some(e=>e.name.toLowerCase()===`content-type`)||(e.responseBody.startsWith(`{`)||e.responseBody.startsWith(`[`)?t.push({name:`Content-Type`,value:`application/json`}):t.push({name:`Content-Type`,value:`text/plain`})),t.some(e=>e.name.toLowerCase()===`access-control-allow-origin`)||t.push({name:`Access-Control-Allow-Origin`,value:`*`}),t}async continuePausedRequest(e){if(e.responseStatusCode!==void 0){await this.cdpSession.send(`Fetch.continueResponse`,{requestId:e.requestId});return}await this.cdpSession.send(`Fetch.continueRequest`,{requestId:e.requestId})}async continueOriginalRequest(t,n){try{await this.continuePausedRequest(t)}catch(t){e.warn(`[FetchInterceptor] continue failed for ${n}:`,t)}}};function b(e){return e}function x(t,n){let r=b(t);if(r.contextSwitchPending)return[];let i=r.messages;n?.type&&(i=i.filter(e=>e.type===n.type));let a=n?.since;return a!==void 0&&(i=i.filter(e=>e.timestamp>=a)),n?.limit&&(i=i.slice(-n.limit)),e.debug(`getLogs: ${i.length} messages`),i}function S(t){let n=b(t);n.messages=[],e.info(`Console logs cleared`)}function C(e){let t=b(e);if(t.contextSwitchPending)return{totalMessages:0,byType:{}};let n={};for(let e of t.messages)n[e.type]=(n[e.type]||0)+1;return{totalMessages:t.messages.length,byType:n}}function w(e,t){let n=b(e);if(n.contextSwitchPending)return[];let r=n.exceptions;t?.url&&(r=r.filter(e=>e.url?.includes(t.url)));let i=t?.since;return i!==void 0&&(r=r.filter(e=>e.timestamp>=i)),t?.limit&&(r=r.slice(-t.limit)),r}function T(t){let n=b(t);n.exceptions=[],e.info(`Exceptions cleared`)}function E(e){return e}function D(e){return e.contextSwitchPending===!0}function O(e){let t=E(e);return D(t)?!1:(t.networkMonitor?.isEnabled()??!1)||(t.playwrightNetworkMonitor?.isEnabled()??!1)}function k(e){let t=E(e);return D(t)?{enabled:!1,requestCount:0,responseCount:0,listenerCount:0,cdpSessionActive:!1}:t.playwrightNetworkMonitor?t.playwrightNetworkMonitor.getStatus():t.networkMonitor?t.networkMonitor.getStatus():{enabled:!1,requestCount:0,responseCount:0,listenerCount:0,cdpSessionActive:t.cdpSession!==null}}function A(e,t){let n=E(e);return D(n)?[]:n.playwrightNetworkMonitor?n.playwrightNetworkMonitor.getRequests(t):n.networkMonitor?.getRequests(t)??[]}function j(e,t){let n=E(e);return D(n)?[]:n.playwrightNetworkMonitor?n.playwrightNetworkMonitor.getResponses(t):n.networkMonitor?.getResponses(t)??[]}function M(e,t){let n=E(e);return D(n)?{}:n.playwrightNetworkMonitor?n.playwrightNetworkMonitor.getActivity(t):n.networkMonitor?.getActivity(t)??{}}async function N(t,n){let r=E(t);return D(r)?null:r.playwrightNetworkMonitor?r.playwrightNetworkMonitor.getResponseBody(n):r.networkMonitor?r.networkMonitor.getResponseBody(n):(e.error(`Network monitoring is not enabled. Call enable() with enableNetwork: true first.`),null)}async function P(e){let t=E(e);return D(t)?[]:t.playwrightNetworkMonitor?t.playwrightNetworkMonitor.getAllJavaScriptResponses():t.networkMonitor?t.networkMonitor.getAllJavaScriptResponses():[]}function F(e){let t=E(e);t.networkMonitor?.clearRecords(),t.playwrightNetworkMonitor?.clearRecords()}async function I(e){let t=E(e);if(t.playwrightNetworkMonitor)return{...await t.playwrightNetworkMonitor.clearInjectedBuffers(),dynamicScriptsCleared:0};let n=t.networkMonitor?await t.networkMonitor.clearInjectedBuffers():{xhrCleared:0,fetchCleared:0},r=await t.clearDynamicScriptBuffer();return{...n,...r}}async function re(e){let t=E(e);if(t.playwrightNetworkMonitor)return{...await t.playwrightNetworkMonitor.resetInjectedInterceptors(),scriptMonitorReset:!1};let n=t.networkMonitor?await t.networkMonitor.resetInjectedInterceptors():{xhrReset:!1,fetchReset:!1},r=await t.resetDynamicScriptMonitoring();return{...n,...r}}function L(e){let t=E(e);return D(t)?{totalRequests:0,totalResponses:0,byMethod:{},byStatus:{},byType:{}}:t.playwrightNetworkMonitor?t.playwrightNetworkMonitor.getStats():t.networkMonitor?.getStats()??{totalRequests:0,totalResponses:0,byMethod:{},byStatus:{},byType:{}}}async function R(e,t){let r=E(e);if(D(r))throw new n(`Network monitoring is not enabled. Call enable() with enableNetwork: true first.`);if(r.playwrightNetworkMonitor)return r.playwrightNetworkMonitor.injectXHRInterceptor(t);if(!r.networkMonitor)throw new n(`Network monitoring is not enabled. Call enable() with enableNetwork: true first.`);return r.networkMonitor.injectXHRInterceptor(t)}async function z(e,t){let r=E(e);if(D(r))throw new n(`Network monitoring is not enabled. Call enable() with enableNetwork: true first.`);if(r.playwrightNetworkMonitor)return r.playwrightNetworkMonitor.injectFetchInterceptor(t);if(!r.networkMonitor)throw new n(`Network monitoring is not enabled. Call enable() with enableNetwork: true first.`);return r.networkMonitor.injectFetchInterceptor(t)}async function B(e){let t=E(e);return D(t)?[]:t.playwrightNetworkMonitor?t.playwrightNetworkMonitor.getXHRRequests():t.networkMonitor?t.networkMonitor.getXHRRequests():[]}async function V(e){let t=E(e);return D(t)?[]:t.playwrightNetworkMonitor?t.playwrightNetworkMonitor.getFetchRequests():t.networkMonitor?t.networkMonitor.getFetchRequests():[]}async function H(t,n){let r=t;if(await r.ensureSession(),!r.cdpSession)throw Error(`CDP session not available after reconnect attempt`);if(r.objectCache.has(n)){let e=r.objectCache.get(n);if(e!==void 0)return e}try{let t=await r.cdpSession.send(`Runtime.getProperties`,{objectId:n,ownProperties:!0,accessorPropertiesOnly:!1,generatePreview:!0}),i={};for(let e of t.result){if(!e.value)continue;let t=e.value;i[e.name]={value:r.extractValue(t),type:t.type,objectId:t.objectId,description:t.description}}if(!r.objectCache.has(n))for(;r.objectCache.size>=r.MAX_OBJECT_CACHE_SIZE;){let e=r.objectCache.keys().next().value;if(e===void 0)break;r.objectCache.delete(e)}return r.objectCache.set(n,i),e.info(`Object inspected: ${n}`,{propertyCount:Object.keys(i).length}),i}catch(t){throw e.error(`Failed to inspect object:`,t),t}}function U(t){t.objectCache.clear(),e.info(`Object cache cleared`)}function W(e){return e}async function G(t,r){let i=W(t);if(await i.ensureSession(),!i.cdpSession)throw new n(`CDP session not available after reconnect attempt`);let a=`
113
+ (function() {
114
+ if (window.__dynamicScriptMonitorInstalled) {
115
+ console.log('[ScriptMonitor] Already installed');
116
+ return;
117
+ }
118
+ window.__dynamicScriptMonitorInstalled = true;
119
+
120
+ const maxRecords = ${i.MAX_INJECTED_DYNAMIC_SCRIPTS};
121
+ if (!window.__dynamicScripts) {
122
+ window.__dynamicScripts = [];
123
+ }
124
+ const dynamicScripts = window.__dynamicScripts;
125
+ const state = window.__dynamicScriptMonitorState || {};
126
+ if (!state.originalCreateElement) state.originalCreateElement = document.createElement;
127
+ if (!state.originalEval) state.originalEval = window.eval;
128
+ if (!state.originalFunction) state.originalFunction = window.Function;
129
+ window.__dynamicScriptMonitorState = state;
130
+
131
+ const observer = new MutationObserver((mutations) => {
132
+ mutations.forEach((mutation) => {
133
+ mutation.addedNodes.forEach((node) => {
134
+ if (node.nodeName === 'SCRIPT') {
135
+ const script = node;
136
+ const info = {
137
+ type: 'dynamic',
138
+ src: script.src || '(inline)',
139
+ content: script.src ? null : script.textContent,
140
+ timestamp: Date.now(),
141
+ async: script.async,
142
+ defer: script.defer,
143
+ };
144
+
145
+ dynamicScripts.push(info);
146
+ if (dynamicScripts.length > maxRecords) {
147
+ dynamicScripts.splice(0, dynamicScripts.length - maxRecords);
148
+ }
149
+ console.log('[ScriptMonitor] Dynamic script added:', info);
150
+ }
151
+ });
152
+ });
153
+ });
154
+
155
+ observer.observe(document.documentElement, {
156
+ childList: true,
157
+ subtree: true,
158
+ });
159
+ state.observer = observer;
160
+
161
+ const originalCreateElement = state.originalCreateElement;
162
+ document.createElement = function(tagName) {
163
+ const element = originalCreateElement.call(document, tagName);
164
+
165
+ if (tagName.toLowerCase() === 'script') {
166
+ console.log('[ScriptMonitor] Script element created via createElement');
167
+
168
+ const originalSetAttribute = element.setAttribute;
169
+ element.setAttribute = function(name, value) {
170
+ if (name === 'src') {
171
+ console.log('[ScriptMonitor] Script src set to:', value);
172
+ }
173
+ return originalSetAttribute.call(element, name, value);
174
+ };
175
+ }
176
+
177
+ return element;
178
+ };
179
+
180
+ const originalEval = state.originalEval;
181
+ window.eval = function(code) {
182
+ console.log('[ScriptMonitor] eval() called with code:',
183
+ typeof code === 'string' ? code.substring(0, 100) + '...' : code);
184
+ return originalEval.call(window, code);
185
+ };
186
+
187
+ const originalFunction = state.originalFunction;
188
+ window.Function = function(...args) {
189
+ console.log('[ScriptMonitor] Function() constructor called with args:', args);
190
+ return originalFunction.apply(this, args);
191
+ };
192
+
193
+ window.__getDynamicScripts = function() {
194
+ return dynamicScripts;
195
+ };
196
+
197
+ console.log('[ScriptMonitor] Dynamic script monitoring enabled');
198
+ })();
199
+ `;r?.persistent?(await i.cdpSession.send(`Page.addScriptToEvaluateOnNewDocument`,{source:a}),e.info(`Dynamic script monitoring enabled (persistent)`)):(await i.cdpSession.send(`Runtime.evaluate`,{expression:a}),e.info(`Dynamic script monitoring enabled`))}async function K(t){let n=W(t);if(!n.cdpSession)return{dynamicScriptsCleared:0};try{let e=(await n.cdpSession.send(`Runtime.evaluate`,{expression:`
200
+ (() => {
201
+ const store = Array.isArray(window.__dynamicScripts)
202
+ ? window.__dynamicScripts
203
+ : (typeof window.__getDynamicScripts === 'function'
204
+ ? window.__getDynamicScripts()
205
+ : null);
206
+ const dynamicScriptsCleared = Array.isArray(store) ? store.length : 0;
207
+ if (Array.isArray(store)) {
208
+ store.length = 0;
209
+ }
210
+ return { dynamicScriptsCleared };
211
+ })()
212
+ `,returnByValue:!0})).result?.value;return typeof e==`object`&&e&&`dynamicScriptsCleared`in e&&typeof e.dynamicScriptsCleared==`number`?e:{dynamicScriptsCleared:0}}catch(t){return e.error(`Failed to clear dynamic script buffer:`,t),{dynamicScriptsCleared:0}}}async function q(t){let n=W(t);if(!n.cdpSession)return{scriptMonitorReset:!1};try{let e=(await n.cdpSession.send(`Runtime.evaluate`,{expression:`
213
+ (() => {
214
+ const state = window.__dynamicScriptMonitorState;
215
+ let scriptMonitorReset = false;
216
+
217
+ try {
218
+ if (state && state.observer && typeof state.observer.disconnect === 'function') {
219
+ state.observer.disconnect();
220
+ state.observer = null;
221
+ scriptMonitorReset = true;
222
+ }
223
+ } catch (_) {}
224
+
225
+ try {
226
+ if (state && state.originalCreateElement) {
227
+ document.createElement = state.originalCreateElement;
228
+ scriptMonitorReset = true;
229
+ }
230
+ } catch (_) {}
231
+
232
+ try {
233
+ if (state && state.originalEval) {
234
+ window.eval = state.originalEval;
235
+ scriptMonitorReset = true;
236
+ }
237
+ } catch (_) {}
238
+
239
+ try {
240
+ if (state && state.originalFunction) {
241
+ window.Function = state.originalFunction;
242
+ scriptMonitorReset = true;
243
+ }
244
+ } catch (_) {}
245
+
246
+ if (Array.isArray(window.__dynamicScripts)) {
247
+ window.__dynamicScripts.length = 0;
248
+ }
249
+ delete window.__getDynamicScripts;
250
+ window.__dynamicScriptMonitorInstalled = false;
251
+
252
+ return { scriptMonitorReset };
253
+ })()
254
+ `,returnByValue:!0})).result?.value;return typeof e==`object`&&e&&`scriptMonitorReset`in e&&typeof e.scriptMonitorReset==`boolean`?e:{scriptMonitorReset:!1}}catch(t){return e.error(`Failed to reset dynamic script monitoring:`,t),{scriptMonitorReset:!1}}}async function J(t){let r=W(t);if(!r.cdpSession)throw new n(`CDP session not initialized`);try{let e=(await r.cdpSession.send(`Runtime.evaluate`,{expression:`window.__getDynamicScripts ? window.__getDynamicScripts() : []`,returnByValue:!0})).result?.value;return Array.isArray(e)?e:[]}catch(t){return e.error(`Failed to get dynamic scripts:`,t),[]}}async function Y(t,r,i){let a=W(t);if(!a.cdpSession)throw new n(`CDP session not initialized`);let o=`
255
+ (function() {
256
+ const originalFunc = window.${r};
257
+ if (typeof originalFunc !== 'function') {
258
+ console.error('[Tracer] ${r} is not a function');
259
+ return;
260
+ }
261
+
262
+ window.${r} = new Proxy(originalFunc, {
263
+ apply: function(target, thisArg, args) {
264
+ console.log('[Tracer] ${r} called with args:', args);
265
+ const startTime = performance.now();
266
+
267
+ try {
268
+ const result = target.apply(thisArg, args);
269
+ const endTime = performance.now();
270
+ console.log('[Tracer] ${r} returned:', result, 'Time:', (endTime - startTime).toFixed(2), 'ms');
271
+ return result;
272
+ } catch (error) {
273
+ console.error('[Tracer] ${r} threw error:', error);
274
+ throw error;
275
+ }
276
+ }
277
+ });
278
+
279
+ console.log('[Tracer] ${r} is now being traced');
280
+ })();
281
+ `;i?.persistent?(await a.cdpSession.send(`Page.addScriptToEvaluateOnNewDocument`,{source:o}),e.info(`Function tracer injected for: ${r} (persistent)`)):(await a.cdpSession.send(`Runtime.evaluate`,{expression:o}),e.info(`Function tracer injected for: ${r}`))}async function X(t,r,i,a){let o=W(t);if(!o.cdpSession)throw new n(`CDP session not initialized`);let s=`
282
+ (function() {
283
+ const obj = ${r};
284
+ if (!obj) {
285
+ console.error('[Watcher] Object not found: ${r}');
286
+ return;
287
+ }
288
+
289
+ let value = obj.${i};
290
+
291
+ Object.defineProperty(obj, '${i}', {
292
+ get: function() {
293
+ console.log('[Watcher] ${r}.${i} accessed, value:', value);
294
+ return value;
295
+ },
296
+ set: function(newValue) {
297
+ console.log('[Watcher] ${r}.${i} changed from', value, 'to', newValue);
298
+ value = newValue;
299
+ },
300
+ enumerable: true,
301
+ configurable: true
302
+ });
303
+
304
+ console.log('[Watcher] Property watcher installed for ${r}.${i}');
305
+ })();
306
+ `;a?.persistent?(await o.cdpSession.send(`Page.addScriptToEvaluateOnNewDocument`,{source:s}),e.info(`Property watcher injected for: ${r}.${i} (persistent)`)):(await o.cdpSession.send(`Runtime.evaluate`,{expression:s}),e.info(`Property watcher injected for: ${r}.${i}`))}function Z(e){return e}async function ie(n,r,i,a){let o=Z(n);o.cdpSession=r,o.usingManagedTargetSession=i,o.lastEnableOptions={...a},o.cdpSession.on(`disconnected`,()=>{e.warn(`ConsoleMonitor CDP session disconnected`),o.cdpSession=null,o.networkMonitor=null,o.usingManagedTargetSession=!1}),await $(o.cdpSession,`Runtime.enable`,{},5e3),await $(o.cdpSession,`Console.enable`,{},5e3),o.cdpSession.on(`Runtime.consoleAPICalled`,t=>{let n=t.stackTrace?.callFrames?.map(e=>({functionName:e.functionName||`(anonymous)`,url:e.url,lineNumber:e.lineNumber,columnNumber:e.columnNumber}))||[],r={type:t.type,text:t.args.map(e=>o.formatRemoteObject(e)).join(` `),args:t.args.map(e=>o.extractValue(e)),timestamp:t.timestamp,stackTrace:n,url:n[0]?.url,lineNumber:n[0]?.lineNumber,columnNumber:n[0]?.columnNumber};o.messages.push(r),o.messages.length>o.MAX_MESSAGES&&(o.messages=o.messages.slice(-Math.floor(o.MAX_MESSAGES/2))),e.debug(`Console ${t.type}: ${r.text}`)}),o.cdpSession.on(`Console.messageAdded`,e=>{let t=e.message,n={type:t.level||`log`,text:t.text,timestamp:Date.now(),url:t.url,lineNumber:t.line,columnNumber:t.column};o.messages.push(n),o.messages.length>o.MAX_MESSAGES&&(o.messages=o.messages.slice(-Math.floor(o.MAX_MESSAGES/2)))}),a?.enableExceptions!==!1&&o.cdpSession.on(`Runtime.exceptionThrown`,t=>{let n=t.exceptionDetails,r=n.stackTrace?.callFrames?.map(e=>({functionName:e.functionName||`(anonymous)`,url:e.url,lineNumber:e.lineNumber,columnNumber:e.columnNumber}))||[],i={text:n.exception?.description||n.text,exceptionId:n.exceptionId,timestamp:Date.now(),stackTrace:r,url:n.url,lineNumber:n.lineNumber,columnNumber:n.columnNumber,scriptId:n.scriptId};o.exceptions.push(i),o.exceptions.length>o.MAX_EXCEPTIONS&&(o.exceptions=o.exceptions.slice(-Math.floor(o.MAX_EXCEPTIONS/2))),e.error(`Exception thrown: ${i.text}`,{url:i.url,line:i.lineNumber})}),a?.enableNetwork&&(o.networkMonitor=o.getManagedTargetNetworkMonitor?.()??new t(o.cdpSession),await o.networkMonitor.enable()),e.info(`ConsoleMonitor enabled`,{network:a?.enableNetwork||!1,exceptions:a?.enableExceptions!==!1})}async function Q(t,n){let r=Z(t);if(r.playwrightConsoleHandler){n?.enableNetwork&&!r.playwrightNetworkMonitor&&(r.playwrightNetworkMonitor=new v(r.playwrightPage),await r.playwrightNetworkMonitor.enable(),e.info(`Network monitoring added to existing ConsoleMonitor Playwright session`));return}let i=r.playwrightPage;r.playwrightConsoleHandler=e=>{let t={type:e.type()||`log`,text:e.text(),timestamp:Date.now()};r.messages.push(t),r.messages.length>r.MAX_MESSAGES&&(r.messages=r.messages.slice(-Math.floor(r.MAX_MESSAGES/2)))},i.on(`console`,r.playwrightConsoleHandler),n?.enableExceptions!==!1&&(r.playwrightErrorHandler=e=>{let t={text:e.message,exceptionId:Date.now(),timestamp:Date.now()};r.exceptions.push(t),r.exceptions.length>r.MAX_EXCEPTIONS&&(r.exceptions=r.exceptions.slice(-Math.floor(r.MAX_EXCEPTIONS/2)))},i.on(`pageerror`,r.playwrightErrorHandler)),n?.enableNetwork&&(r.playwrightNetworkMonitor=new v(r.playwrightPage),await r.playwrightNetworkMonitor.enable()),e.info(`ConsoleMonitor enabled (Playwright/camoufox mode)`,{network:n?.enableNetwork||!1})}async function ae(t){let n=Z(t);if(n.playwrightPage){let e=n.playwrightPage;if(n.playwrightConsoleHandler){try{e.off(`console`,n.playwrightConsoleHandler)}catch{}n.playwrightConsoleHandler=null}if(n.playwrightErrorHandler){try{e.off(`pageerror`,n.playwrightErrorHandler)}catch{}n.playwrightErrorHandler=null}}if(n.playwrightNetworkMonitor&&=(await n.playwrightNetworkMonitor.disable(),null),n.cdpSession){n.networkMonitor&&=(await n.networkMonitor.disable(),null);try{await n.cdpSession.send(`Console.disable`)}catch(t){e.warn(`Failed to disable Console domain:`,t)}try{await n.cdpSession.send(`Runtime.disable`)}catch(t){e.warn(`Failed to disable Runtime domain:`,t)}if(n.usingManagedTargetSession)e.debug(`ConsoleMonitor released managed target session without detaching target`);else try{await n.cdpSession.detach()}catch(t){e.warn(`Failed to detach ConsoleMonitor CDP session:`,t)}n.cdpSession=null,n.usingManagedTargetSession=!1,e.info(`ConsoleMonitor disabled`)}}async function $(e,t,n,r=3e4){return Promise.race([e.send(t,n),new Promise((e,n)=>setTimeout(()=>n(Error(`CDP ${t} timed out after ${r}ms`)),r))])}var oe=class{collector;cdpSession=null;networkMonitor=null;fetchInterceptor=null;playwrightNetworkMonitor=null;playwrightPage=null;usingManagedTargetSession=!1;contextSwitchPending=!1;playwrightConsoleHandler=null;playwrightErrorHandler=null;messages=[];MAX_MESSAGES=1e3;exceptions=[];MAX_EXCEPTIONS=500;MAX_INJECTED_DYNAMIC_SCRIPTS=500;MAX_OBJECT_CACHE_SIZE=1e3;objectCache=new Map;initPromise;lastEnableOptions={};constructor(e){this.collector=e,this.touchSplitMembersForTypeCheck()}touchSplitMembersForTypeCheck(){this.MAX_INJECTED_DYNAMIC_SCRIPTS,this.MAX_OBJECT_CACHE_SIZE,this.clearDynamicScriptBuffer,this.resetDynamicScriptMonitoring,this.usingManagedTargetSession,this.playwrightErrorHandler,this.messages,this.MAX_MESSAGES,this.exceptions,this.MAX_EXCEPTIONS,this.formatRemoteObject,this.extractValue}setPlaywrightPage(e){this.playwrightPage=e,this.playwrightNetworkMonitor?.setPage(e)}clearPlaywrightPage(){this.playwrightPage=null,this.contextSwitchPending=!1,this.playwrightConsoleHandler=null,this.playwrightErrorHandler=null,this.playwrightNetworkMonitor?.setPage(null),this.playwrightNetworkMonitor=null}getManagedTargetSession(){return this.collector.getAttachedTargetSession?.()??null}getManagedTargetNetworkMonitor(){return this.collector.getBrowserTargetSessionManager?.()??null}async createCdpSession(){let e=this.getManagedTargetSession();if(e)return{session:e,managed:!0};let t=await this.collector.getActivePage();return{session:await Promise.race([t.createCDPSession(),new Promise((e,t)=>setTimeout(()=>t(Error(`cdp_session_timeout`)),500))]),managed:!1}}markContextChanged(){!this.cdpSession&&!this.playwrightPage&&!this.networkMonitor&&!this.playwrightNetworkMonitor&&!this.fetchInterceptor||(this.contextSwitchPending=!0,this.clearLogs(),this.clearExceptions(),this.networkMonitor?.persistsAcrossContextSwitches?.()||this.clearNetworkRecords(),this.clearObjectCache(),e.info(`ConsoleMonitor marked stale after active context switch`))}async enable(e){if(this.contextSwitchPending&&await this.disable(),this.initPromise){await this.initPromise,await this.applyPostEnableOptions(e);return}this.initPromise=this.doEnable(e);try{await this.initPromise}finally{this.initPromise=void 0}}async doEnable(n){if(this.playwrightPage)return this.lastEnableOptions={...n},Q(this,n);if(this.cdpSession){n?.enableNetwork&&!this.networkMonitor&&(this.networkMonitor=this.getManagedTargetNetworkMonitor()??new t(this.cdpSession),await this.networkMonitor.enable(),e.info(`Network monitoring added to existing ConsoleMonitor session`));return}let{session:r,managed:i}=await this.createCdpSession();await ie(this,r,i,n)}async applyPostEnableOptions(n){if(n?.enableNetwork){if(this.lastEnableOptions={...this.lastEnableOptions,...n},this.playwrightPage&&this.playwrightConsoleHandler&&!this.playwrightNetworkMonitor){await Q(this,n);return}this.cdpSession&&!this.networkMonitor&&(this.networkMonitor=this.getManagedTargetNetworkMonitor()??new t(this.cdpSession),await this.networkMonitor.enable(),e.info(`Network monitoring added to existing ConsoleMonitor session`))}}async disable(){try{this.cdpSession&&this.fetchInterceptor&&(await this.fetchInterceptor.disable(),this.fetchInterceptor=null),await ae(this)}finally{this.fetchInterceptor=null,this.initPromise=void 0,this.contextSwitchPending=!1,this.objectCache.clear()}}async ensureSession(){if(this.contextSwitchPending){e.info(`ConsoleMonitor context switched, rebinding on demand...`);let t={...this.lastEnableOptions};await this.disable(),await this.enable(t);return}if(!this.cdpSession&&!this.playwrightPage){e.info(`ConsoleMonitor CDP session lost, reinitializing...`),await this.enable(this.lastEnableOptions);return}if(this.cdpSession)try{await Promise.race([this.cdpSession.send(`Runtime.evaluate`,{expression:`1`,returnByValue:!0}),new Promise((e,t)=>setTimeout(()=>t(Error(`session_unreachable`)),3e3))]);return}catch{e.warn(`ConsoleMonitor CDP session unresponsive (zombie), reinitializing...`),this.cdpSession=null,this.networkMonitor=null,this.fetchInterceptor=null,this.usingManagedTargetSession=!1,await this.enable(this.lastEnableOptions)}}isSessionActive(){return!this.contextSwitchPending&&(this.cdpSession!==null||this.playwrightPage!==null)}getLogs(e){return x(this,e)}async execute(t){await this.ensureSession();try{let n=await $(this.cdpSession,`Runtime.evaluate`,{expression:t,returnByValue:!0});if(n.exceptionDetails)throw e.error(`Console execute error:`,n.exceptionDetails),Error(n.exceptionDetails.text);return e.info(`Console expression executed`),n.result.value}catch(t){throw e.error(`Console execute failed:`,t),t}}clearLogs(){S(this)}getStats(){return C(this)}async close(){try{await this.disable()}finally{this.initPromise=void 0,this.objectCache.clear()}}isNetworkEnabled(){return O(this)}getNetworkStatus(){return k(this)}getNetworkRequests(e){return A(this,e)}getNetworkResponses(e){return j(this,e)}getNetworkActivity(e){return M(this,e)}async getResponseBody(e){return N(this,e)}async getAllJavaScriptResponses(){return P(this)}clearNetworkRecords(){F(this)}async clearInjectedBuffers(){return I(this)}async resetInjectedInterceptors(){return re(this)}getNetworkStats(){return L(this)}async injectXHRInterceptor(e){return R(this,e)}async injectFetchInterceptor(e){return z(this,e)}async getXHRRequests(){return B(this)}async getFetchRequests(){return V(this)}getExceptions(e){return w(this,e)}clearExceptions(){T(this)}async inspectObject(e){return H(this,e)}clearObjectCache(){U(this)}async enableDynamicScriptMonitoring(e){return G(this,e)}async clearDynamicScriptBuffer(){return K(this)}async resetDynamicScriptMonitoring(){return q(this)}async getDynamicScripts(){return J(this)}async injectFunctionTracer(e,t){return Y(this,e,t)}async injectPropertyWatcher(e,t,n){return X(this,e,t,n)}async enableFetchIntercept(e){if(await this.ensureSession(),!this.cdpSession)throw Error(`No CDP session available for Fetch interception`);return this.fetchInterceptor||=new y(this.cdpSession),this.fetchInterceptor.enable(e)}async disableFetchIntercept(){if(!this.fetchInterceptor)return{removedRules:0};let e=await this.fetchInterceptor.disable();return this.fetchInterceptor=null,e}async removeFetchInterceptRule(e){if(!this.fetchInterceptor)return!1;let t=await this.fetchInterceptor.removeRule(e);return this.fetchInterceptor.isEnabled()||(this.fetchInterceptor=null),t}getFetchInterceptStatus(){return this.fetchInterceptor?this.fetchInterceptor.listRules():{enabled:!1,rules:[],totalHits:0}}formatRemoteObject(e){return e.value===void 0?e.description?e.description:e.type===`undefined`?`undefined`:e.type===`object`&&e.subtype===`null`?`null`:`[${e.type}]`:String(e.value)}extractValue(e){if(e.value!==void 0)return e.value;if(e.type!==`undefined`)return e.type===`object`&&e.subtype===`null`?null:e.objectId?{__objectId:e.objectId,__type:e.type,__description:e.description}:e.description||`[${e.type}]`}};export{oe as ConsoleMonitor};