octoparse-cli 0.1.14

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 (278) hide show
  1. package/README.md +271 -0
  2. package/RUNTIME_SECURITY_NOTICE.txt +41 -0
  3. package/SECURITY.md +24 -0
  4. package/dist/cli/args.js +34 -0
  5. package/dist/cli/help.js +214 -0
  6. package/dist/cli/output.js +39 -0
  7. package/dist/commands/auth.js +283 -0
  8. package/dist/commands/capabilities.js +118 -0
  9. package/dist/commands/cloud.js +241 -0
  10. package/dist/commands/data.js +220 -0
  11. package/dist/commands/doctor.js +73 -0
  12. package/dist/commands/env.js +63 -0
  13. package/dist/commands/local.js +251 -0
  14. package/dist/commands/run.js +622 -0
  15. package/dist/commands/runs.js +171 -0
  16. package/dist/commands/task.js +101 -0
  17. package/dist/index.js +133 -0
  18. package/dist/runtime/account-capabilities.js +71 -0
  19. package/dist/runtime/api-client.js +290 -0
  20. package/dist/runtime/artifacts.js +33 -0
  21. package/dist/runtime/auth.js +94 -0
  22. package/dist/runtime/bridge-hub.js +173 -0
  23. package/dist/runtime/client-headers.js +23 -0
  24. package/dist/runtime/cloud-data.js +75 -0
  25. package/dist/runtime/config.js +48 -0
  26. package/dist/runtime/data-exporter.js +267 -0
  27. package/dist/runtime/engine-host.js +449 -0
  28. package/dist/runtime/local-runs.js +92 -0
  29. package/dist/runtime/naming.js +13 -0
  30. package/dist/runtime/run-control.js +363 -0
  31. package/dist/runtime/run-services.js +380 -0
  32. package/dist/runtime/security-notice.js +78 -0
  33. package/dist/runtime/task-definition-provider.js +282 -0
  34. package/dist/types.js +4 -0
  35. package/examples/minimal-task.json +6 -0
  36. package/examples/navigate-example-task.json +6 -0
  37. package/node_modules/@octopus/bpmn/index.js +3 -0
  38. package/node_modules/@octopus/bpmn/lib/Context.js +245 -0
  39. package/node_modules/@octopus/bpmn/lib/Definition.js +258 -0
  40. package/node_modules/@octopus/bpmn/lib/Engine.js +275 -0
  41. package/node_modules/@octopus/bpmn/lib/PrematureStopError.js +7 -0
  42. package/node_modules/@octopus/bpmn/lib/activities/Activity.js +202 -0
  43. package/node_modules/@octopus/bpmn/lib/activities/BaseProcess.js +308 -0
  44. package/node_modules/@octopus/bpmn/lib/activities/BaseTask.js +145 -0
  45. package/node_modules/@octopus/bpmn/lib/activities/BoundaryEvent.js +12 -0
  46. package/node_modules/@octopus/bpmn/lib/activities/Dummy.js +10 -0
  47. package/node_modules/@octopus/bpmn/lib/activities/EventDefinition.js +99 -0
  48. package/node_modules/@octopus/bpmn/lib/activities/Flow.js +52 -0
  49. package/node_modules/@octopus/bpmn/lib/activities/Form.js +67 -0
  50. package/node_modules/@octopus/bpmn/lib/activities/InputOutput.js +53 -0
  51. package/node_modules/@octopus/bpmn/lib/activities/IntermediateCatchEvent.js +12 -0
  52. package/node_modules/@octopus/bpmn/lib/activities/MessageFlow.js +19 -0
  53. package/node_modules/@octopus/bpmn/lib/activities/MultiInstanceLoopCharacteristics.js +160 -0
  54. package/node_modules/@octopus/bpmn/lib/activities/Properties.js +27 -0
  55. package/node_modules/@octopus/bpmn/lib/activities/SequenceFlow.js +56 -0
  56. package/node_modules/@octopus/bpmn/lib/activities/ServiceConnector.js +71 -0
  57. package/node_modules/@octopus/bpmn/lib/context-helper.js +198 -0
  58. package/node_modules/@octopus/bpmn/lib/events/EndEvent.js +22 -0
  59. package/node_modules/@octopus/bpmn/lib/events/ErrorEvent.js +41 -0
  60. package/node_modules/@octopus/bpmn/lib/events/MessageEvent.js +19 -0
  61. package/node_modules/@octopus/bpmn/lib/events/StartEvent.js +55 -0
  62. package/node_modules/@octopus/bpmn/lib/events/TimerEvent.js +75 -0
  63. package/node_modules/@octopus/bpmn/lib/expressions.js +41 -0
  64. package/node_modules/@octopus/bpmn/lib/gateways/ExclusiveGateway.js +86 -0
  65. package/node_modules/@octopus/bpmn/lib/gateways/InclusiveGateway.js +56 -0
  66. package/node_modules/@octopus/bpmn/lib/gateways/ParallelGateway.js +195 -0
  67. package/node_modules/@octopus/bpmn/lib/getPropertyValue.js +83 -0
  68. package/node_modules/@octopus/bpmn/lib/index.js +6 -0
  69. package/node_modules/@octopus/bpmn/lib/mapper.js +55 -0
  70. package/node_modules/@octopus/bpmn/lib/parameter.js +119 -0
  71. package/node_modules/@octopus/bpmn/lib/script-helper.js +45 -0
  72. package/node_modules/@octopus/bpmn/lib/tasks/ManualTask.js +31 -0
  73. package/node_modules/@octopus/bpmn/lib/tasks/ReceiveTask.js +31 -0
  74. package/node_modules/@octopus/bpmn/lib/tasks/ScriptTask.js +35 -0
  75. package/node_modules/@octopus/bpmn/lib/tasks/SendTask.js +16 -0
  76. package/node_modules/@octopus/bpmn/lib/tasks/ServiceTask.js +68 -0
  77. package/node_modules/@octopus/bpmn/lib/tasks/SubProcess.js +17 -0
  78. package/node_modules/@octopus/bpmn/lib/tasks/Task.js +16 -0
  79. package/node_modules/@octopus/bpmn/lib/tasks/UserTask.js +47 -0
  80. package/node_modules/@octopus/bpmn/lib/transformer.js +13 -0
  81. package/node_modules/@octopus/bpmn/lib/validation.js +111 -0
  82. package/node_modules/@octopus/bpmn/package.json +17 -0
  83. package/node_modules/@octopus/bpmn/types/bpmn.d.ts +85 -0
  84. package/node_modules/@octopus/engine/README.md +370 -0
  85. package/node_modules/@octopus/engine/dist/actions/BackPreWebPageAction.d.ts +4 -0
  86. package/node_modules/@octopus/engine/dist/actions/BackPreWebPageAction.js +1 -0
  87. package/node_modules/@octopus/engine/dist/actions/BaseAction.d.ts +339 -0
  88. package/node_modules/@octopus/engine/dist/actions/BaseAction.js +1559 -0
  89. package/node_modules/@octopus/engine/dist/actions/BranchAction.d.ts +9 -0
  90. package/node_modules/@octopus/engine/dist/actions/BranchAction.js +1 -0
  91. package/node_modules/@octopus/engine/dist/actions/ClickAction.d.ts +22 -0
  92. package/node_modules/@octopus/engine/dist/actions/ClickAction.js +1 -0
  93. package/node_modules/@octopus/engine/dist/actions/ConditionAction.d.ts +4 -0
  94. package/node_modules/@octopus/engine/dist/actions/ConditionAction.js +1 -0
  95. package/node_modules/@octopus/engine/dist/actions/EmptyAction.d.ts +4 -0
  96. package/node_modules/@octopus/engine/dist/actions/EmptyAction.js +12 -0
  97. package/node_modules/@octopus/engine/dist/actions/EnterCaptchaAction.d.ts +28 -0
  98. package/node_modules/@octopus/engine/dist/actions/EnterCaptchaAction.js +1 -0
  99. package/node_modules/@octopus/engine/dist/actions/EnterTextAction.d.ts +20 -0
  100. package/node_modules/@octopus/engine/dist/actions/EnterTextAction.js +1 -0
  101. package/node_modules/@octopus/engine/dist/actions/ExtractDataAction.d.ts +40 -0
  102. package/node_modules/@octopus/engine/dist/actions/ExtractDataAction.js +1 -0
  103. package/node_modules/@octopus/engine/dist/actions/LoopAction.d.ts +41 -0
  104. package/node_modules/@octopus/engine/dist/actions/LoopAction.js +526 -0
  105. package/node_modules/@octopus/engine/dist/actions/LoopStartAction.d.ts +47 -0
  106. package/node_modules/@octopus/engine/dist/actions/LoopStartAction.js +607 -0
  107. package/node_modules/@octopus/engine/dist/actions/MouseOverAction.d.ts +8 -0
  108. package/node_modules/@octopus/engine/dist/actions/MouseOverAction.js +34 -0
  109. package/node_modules/@octopus/engine/dist/actions/NavigateAction.d.ts +38 -0
  110. package/node_modules/@octopus/engine/dist/actions/NavigateAction.js +535 -0
  111. package/node_modules/@octopus/engine/dist/actions/SwitchComboAction.d.ts +13 -0
  112. package/node_modules/@octopus/engine/dist/actions/SwitchComboAction.js +69 -0
  113. package/node_modules/@octopus/engine/dist/browser.d.ts +17 -0
  114. package/node_modules/@octopus/engine/dist/browser.js +157 -0
  115. package/node_modules/@octopus/engine/dist/browserProxy.d.ts +90 -0
  116. package/node_modules/@octopus/engine/dist/browserProxy.js +1 -0
  117. package/node_modules/@octopus/engine/dist/configs/BaseConfig.d.ts +20 -0
  118. package/node_modules/@octopus/engine/dist/configs/BaseConfig.js +88 -0
  119. package/node_modules/@octopus/engine/dist/configs/BranchConfig.d.ts +7 -0
  120. package/node_modules/@octopus/engine/dist/configs/BranchConfig.js +1 -0
  121. package/node_modules/@octopus/engine/dist/configs/ClickConfig.d.ts +36 -0
  122. package/node_modules/@octopus/engine/dist/configs/ClickConfig.js +65 -0
  123. package/node_modules/@octopus/engine/dist/configs/EnterCaptchaConfig.d.ts +19 -0
  124. package/node_modules/@octopus/engine/dist/configs/EnterCaptchaConfig.js +25 -0
  125. package/node_modules/@octopus/engine/dist/configs/EnterTextConfig.d.ts +24 -0
  126. package/node_modules/@octopus/engine/dist/configs/EnterTextConfig.js +36 -0
  127. package/node_modules/@octopus/engine/dist/configs/ExtractDataConfig.d.ts +12 -0
  128. package/node_modules/@octopus/engine/dist/configs/ExtractDataConfig.js +1 -0
  129. package/node_modules/@octopus/engine/dist/configs/LoopConfig.d.ts +25 -0
  130. package/node_modules/@octopus/engine/dist/configs/LoopConfig.js +40 -0
  131. package/node_modules/@octopus/engine/dist/configs/LoopStartConfig.d.ts +4 -0
  132. package/node_modules/@octopus/engine/dist/configs/LoopStartConfig.js +12 -0
  133. package/node_modules/@octopus/engine/dist/configs/MouseOverConfig.d.ts +8 -0
  134. package/node_modules/@octopus/engine/dist/configs/MouseOverConfig.js +15 -0
  135. package/node_modules/@octopus/engine/dist/configs/NavigateConfig.d.ts +41 -0
  136. package/node_modules/@octopus/engine/dist/configs/NavigateConfig.js +121 -0
  137. package/node_modules/@octopus/engine/dist/configs/SwitchComboConfig.d.ts +8 -0
  138. package/node_modules/@octopus/engine/dist/configs/SwitchComboConfig.js +15 -0
  139. package/node_modules/@octopus/engine/dist/enums/index.d.ts +419 -0
  140. package/node_modules/@octopus/engine/dist/enums/index.js +314 -0
  141. package/node_modules/@octopus/engine/dist/extension/BrowserWebSocketTransport-D_zAGZMQ.js +1 -0
  142. package/node_modules/@octopus/engine/dist/extension/LaunchOptions-DxvePrV4.js +6 -0
  143. package/node_modules/@octopus/engine/dist/extension/NodeWebSocketTransport-BTgRVB7Z.js +6 -0
  144. package/node_modules/@octopus/engine/dist/extension/background.js +396 -0
  145. package/node_modules/@octopus/engine/dist/extension/bidi-C_GIZ8Uz.js +131 -0
  146. package/node_modules/@octopus/engine/dist/extension/manifest.json +27 -0
  147. package/node_modules/@octopus/engine/dist/extension/src/content/anti-detection.js +1 -0
  148. package/node_modules/@octopus/engine/dist/extension-bridge/BaseExtensionBridge.d.ts +21 -0
  149. package/node_modules/@octopus/engine/dist/extension-bridge/BaseExtensionBridge.js +117 -0
  150. package/node_modules/@octopus/engine/dist/extension-bridge/SessionExtensionBridge.d.ts +17 -0
  151. package/node_modules/@octopus/engine/dist/extension-bridge/SessionExtensionBridge.js +29 -0
  152. package/node_modules/@octopus/engine/dist/extension-bridge/index.d.ts +2 -0
  153. package/node_modules/@octopus/engine/dist/extension-bridge/index.js +5 -0
  154. package/node_modules/@octopus/engine/dist/extension-bridge/types.d.ts +159 -0
  155. package/node_modules/@octopus/engine/dist/extension-bridge/types.js +5 -0
  156. package/node_modules/@octopus/engine/dist/extensions/ublock-origin/uBlock0.chromium.tar.xz +0 -0
  157. package/node_modules/@octopus/engine/dist/extensions/ublock-origin-lite/uBOLite.chromium.tar.xz +0 -0
  158. package/node_modules/@octopus/engine/dist/index.d.ts +169 -0
  159. package/node_modules/@octopus/engine/dist/index.js +1 -0
  160. package/node_modules/@octopus/engine/dist/models/actionItem.d.ts +16 -0
  161. package/node_modules/@octopus/engine/dist/models/actionItem.js +15 -0
  162. package/node_modules/@octopus/engine/dist/models/conditionCheckArgs.d.ts +11 -0
  163. package/node_modules/@octopus/engine/dist/models/conditionCheckArgs.js +11 -0
  164. package/node_modules/@octopus/engine/dist/models/customizeCookie.d.ts +14 -0
  165. package/node_modules/@octopus/engine/dist/models/customizeCookie.js +6 -0
  166. package/node_modules/@octopus/engine/dist/models/downloadFileConfig.d.ts +17 -0
  167. package/node_modules/@octopus/engine/dist/models/downloadFileConfig.js +26 -0
  168. package/node_modules/@octopus/engine/dist/models/elementNotFoundArgs.d.ts +8 -0
  169. package/node_modules/@octopus/engine/dist/models/elementNotFoundArgs.js +12 -0
  170. package/node_modules/@octopus/engine/dist/models/elementNotFoundError.d.ts +2 -0
  171. package/node_modules/@octopus/engine/dist/models/elementNotFoundError.js +6 -0
  172. package/node_modules/@octopus/engine/dist/models/extractItem.d.ts +37 -0
  173. package/node_modules/@octopus/engine/dist/models/extractItem.js +35 -0
  174. package/node_modules/@octopus/engine/dist/models/extractTemplate.d.ts +11 -0
  175. package/node_modules/@octopus/engine/dist/models/extractTemplate.js +48 -0
  176. package/node_modules/@octopus/engine/dist/models/extractTextItem.d.ts +10 -0
  177. package/node_modules/@octopus/engine/dist/models/extractTextItem.js +17 -0
  178. package/node_modules/@octopus/engine/dist/models/globalConfig.d.ts +5 -0
  179. package/node_modules/@octopus/engine/dist/models/globalConfig.js +1 -0
  180. package/node_modules/@octopus/engine/dist/models/httpHeader.d.ts +4 -0
  181. package/node_modules/@octopus/engine/dist/models/httpHeader.js +10 -0
  182. package/node_modules/@octopus/engine/dist/models/operation.d.ts +27 -0
  183. package/node_modules/@octopus/engine/dist/models/operation.js +242 -0
  184. package/node_modules/@octopus/engine/dist/models/retryCondition.d.ts +7 -0
  185. package/node_modules/@octopus/engine/dist/models/retryCondition.js +10 -0
  186. package/node_modules/@octopus/engine/dist/models/task.d.ts +89 -0
  187. package/node_modules/@octopus/engine/dist/models/task.js +120 -0
  188. package/node_modules/@octopus/engine/dist/models/trigger.d.ts +66 -0
  189. package/node_modules/@octopus/engine/dist/models/trigger.js +117 -0
  190. package/node_modules/@octopus/engine/dist/package.json +26 -0
  191. package/node_modules/@octopus/engine/dist/public-types.d.ts +13 -0
  192. package/node_modules/@octopus/engine/dist/public-types.js +2 -0
  193. package/node_modules/@octopus/engine/dist/settings.d.ts +41 -0
  194. package/node_modules/@octopus/engine/dist/settings.js +20 -0
  195. package/node_modules/@octopus/engine/dist/solvers/captcha/ClickCaptchaSolver.d.ts +6 -0
  196. package/node_modules/@octopus/engine/dist/solvers/captcha/ClickCaptchaSolver.js +1 -0
  197. package/node_modules/@octopus/engine/dist/solvers/captcha/HCaptchaSolver.d.ts +4 -0
  198. package/node_modules/@octopus/engine/dist/solvers/captcha/HCaptchaSolver.js +73 -0
  199. package/node_modules/@octopus/engine/dist/solvers/captcha/ImageCaptchaSolver.d.ts +2 -0
  200. package/node_modules/@octopus/engine/dist/solvers/captcha/ImageCaptchaSolver.js +74 -0
  201. package/node_modules/@octopus/engine/dist/solvers/captcha/RecaptchaSolver.d.ts +9 -0
  202. package/node_modules/@octopus/engine/dist/solvers/captcha/RecaptchaSolver.js +371 -0
  203. package/node_modules/@octopus/engine/dist/solvers/captcha/SliderCaptchaSolver.d.ts +6 -0
  204. package/node_modules/@octopus/engine/dist/solvers/captcha/SliderCaptchaSolver.js +184 -0
  205. package/node_modules/@octopus/engine/dist/solvers/captcha/SlidingTrajectory.d.ts +50 -0
  206. package/node_modules/@octopus/engine/dist/solvers/captcha/SlidingTrajectory.js +125 -0
  207. package/node_modules/@octopus/engine/dist/solvers/captcha/types.d.ts +68 -0
  208. package/node_modules/@octopus/engine/dist/solvers/captcha/types.js +34 -0
  209. package/node_modules/@octopus/engine/dist/solvers/captcha/utils.d.ts +2 -0
  210. package/node_modules/@octopus/engine/dist/solvers/captcha/utils.js +15 -0
  211. package/node_modules/@octopus/engine/dist/translator/actionFactory.d.ts +6 -0
  212. package/node_modules/@octopus/engine/dist/translator/actionFactory.js +1 -0
  213. package/node_modules/@octopus/engine/dist/translator/activityTypeEnum.d.ts +22 -0
  214. package/node_modules/@octopus/engine/dist/translator/activityTypeEnum.js +1 -0
  215. package/node_modules/@octopus/engine/dist/translator/backPreWebPageAction.d.ts +5 -0
  216. package/node_modules/@octopus/engine/dist/translator/backPreWebPageAction.js +1 -0
  217. package/node_modules/@octopus/engine/dist/translator/baseAction.d.ts +31 -0
  218. package/node_modules/@octopus/engine/dist/translator/baseAction.js +1 -0
  219. package/node_modules/@octopus/engine/dist/translator/breakActivity.d.ts +5 -0
  220. package/node_modules/@octopus/engine/dist/translator/breakActivity.js +1 -0
  221. package/node_modules/@octopus/engine/dist/translator/clickAction.d.ts +5 -0
  222. package/node_modules/@octopus/engine/dist/translator/clickAction.js +1 -0
  223. package/node_modules/@octopus/engine/dist/translator/completeWF.d.ts +5 -0
  224. package/node_modules/@octopus/engine/dist/translator/completeWF.js +1 -0
  225. package/node_modules/@octopus/engine/dist/translator/conditionAction.d.ts +6 -0
  226. package/node_modules/@octopus/engine/dist/translator/conditionAction.js +1 -0
  227. package/node_modules/@octopus/engine/dist/translator/emptyAction.d.ts +5 -0
  228. package/node_modules/@octopus/engine/dist/translator/emptyAction.js +1 -0
  229. package/node_modules/@octopus/engine/dist/translator/enterCapachaAction.d.ts +5 -0
  230. package/node_modules/@octopus/engine/dist/translator/enterCapachaAction.js +1 -0
  231. package/node_modules/@octopus/engine/dist/translator/enterTextAction.d.ts +5 -0
  232. package/node_modules/@octopus/engine/dist/translator/enterTextAction.js +1 -0
  233. package/node_modules/@octopus/engine/dist/translator/extractDataAction.d.ts +13 -0
  234. package/node_modules/@octopus/engine/dist/translator/extractDataAction.js +1 -0
  235. package/node_modules/@octopus/engine/dist/translator/loopAction.d.ts +5 -0
  236. package/node_modules/@octopus/engine/dist/translator/loopAction.js +1 -0
  237. package/node_modules/@octopus/engine/dist/translator/mouseOverAction.d.ts +5 -0
  238. package/node_modules/@octopus/engine/dist/translator/mouseOverAction.js +19 -0
  239. package/node_modules/@octopus/engine/dist/translator/navigateAction.d.ts +5 -0
  240. package/node_modules/@octopus/engine/dist/translator/navigateAction.js +117 -0
  241. package/node_modules/@octopus/engine/dist/translator/rootAction.d.ts +6 -0
  242. package/node_modules/@octopus/engine/dist/translator/rootAction.js +80 -0
  243. package/node_modules/@octopus/engine/dist/translator/switchCombo2Action.d.ts +5 -0
  244. package/node_modules/@octopus/engine/dist/translator/switchCombo2Action.js +19 -0
  245. package/node_modules/@octopus/engine/dist/translator/translator.d.ts +1 -0
  246. package/node_modules/@octopus/engine/dist/translator/translator.js +36 -0
  247. package/node_modules/@octopus/engine/dist/type.d.ts +25 -0
  248. package/node_modules/@octopus/engine/dist/type.js +2 -0
  249. package/node_modules/@octopus/engine/dist/types/browser.d.ts +191 -0
  250. package/node_modules/@octopus/engine/dist/types/browser.js +1 -0
  251. package/node_modules/@octopus/engine/dist/types/browserManager.d.ts +41 -0
  252. package/node_modules/@octopus/engine/dist/types/browserManager.js +1 -0
  253. package/node_modules/@octopus/engine/dist/types/index.d.ts +40 -0
  254. package/node_modules/@octopus/engine/dist/types/index.js +2 -0
  255. package/node_modules/@octopus/engine/dist/types/plugin.d.ts +29 -0
  256. package/node_modules/@octopus/engine/dist/types/plugin.js +2 -0
  257. package/node_modules/@octopus/engine/dist/utils/AsyncEmitter.d.ts +15 -0
  258. package/node_modules/@octopus/engine/dist/utils/AsyncEmitter.js +1 -0
  259. package/node_modules/@octopus/engine/dist/utils/DataStore.d.ts +58 -0
  260. package/node_modules/@octopus/engine/dist/utils/DataStore.js +1 -0
  261. package/node_modules/@octopus/engine/dist/utils/DateTimeFormatHelper.d.ts +22 -0
  262. package/node_modules/@octopus/engine/dist/utils/DateTimeFormatHelper.js +173 -0
  263. package/node_modules/@octopus/engine/dist/utils/FileDownloader.d.ts +108 -0
  264. package/node_modules/@octopus/engine/dist/utils/FileDownloader.js +1 -0
  265. package/node_modules/@octopus/engine/dist/utils/HttpRequester.d.ts +43 -0
  266. package/node_modules/@octopus/engine/dist/utils/HttpRequester.js +174 -0
  267. package/node_modules/@octopus/engine/dist/utils/JsonParser.d.ts +95 -0
  268. package/node_modules/@octopus/engine/dist/utils/JsonParser.js +439 -0
  269. package/node_modules/@octopus/engine/dist/utils/Operations.d.ts +27 -0
  270. package/node_modules/@octopus/engine/dist/utils/Operations.js +115 -0
  271. package/node_modules/@octopus/engine/dist/utils/index.d.ts +28 -0
  272. package/node_modules/@octopus/engine/dist/utils/index.js +356 -0
  273. package/node_modules/@octopus/engine/package.json +58 -0
  274. package/package.json +79 -0
  275. package/schemas/capabilities-v1.schema.json +234 -0
  276. package/schemas/detached-bootstrap-v1.schema.json +42 -0
  277. package/schemas/json-envelope-v1.schema.json +39 -0
  278. package/schemas/run-event-v1.schema.json +47 -0
@@ -0,0 +1,13 @@
1
+ import { RunnerStatus } from './enums';
2
+ export type { default as BaseAction } from './actions/BaseAction';
3
+ export type { Command, CommandResponse, ExtensionBridgeLike, ExtensionEvent, ExtensionRegistrationMessage, ExtensionRuntimeConfig } from './extension-bridge';
4
+ /** == 这里是给 engine 做 [event]: [payload] 和 给 调用方(octopus)做二次类型 统一的,尽量避免自行重复定义类型。 == */
5
+ export interface WorkflowStoppedEventMessage {
6
+ taskId: string;
7
+ data: {
8
+ status: RunnerStatus;
9
+ };
10
+ }
11
+ export interface WorkflowStopEventMessage {
12
+ taskId: string;
13
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,41 @@
1
+ import type BaseAction from '@/actions/BaseAction';
2
+ import type { IpProxyFromType, UserAgentSwitchType, CookieClearType } from '@/enums';
3
+ type ActionWrapper = (action: BaseAction) => BaseAction;
4
+ export declare class WorkflowSetting {
5
+ /** 是否在任务设置界面显示自动跳过无效的循环点击选项 */
6
+ showJumpInvalidClickSetting: boolean;
7
+ /** 多少次后开始判断无效循环点击 */
8
+ repeatPageLoopCount: number;
9
+ /** 连续判断多少次循环点击才选无效 */
10
+ continuousJudgeCount: number;
11
+ actionWrapper: ActionWrapper | null;
12
+ constructor(options?: {
13
+ actionWrapper?: ActionWrapper;
14
+ });
15
+ }
16
+ export declare class BrokerSettings {
17
+ ipProxySettings: {
18
+ ipProxyFromType: IpProxyFromType;
19
+ strongIpProxySettings: {
20
+ period: number;
21
+ areaId: number;
22
+ };
23
+ customIpProxySettings: {
24
+ switchPeriod: number;
25
+ proxies: string[];
26
+ };
27
+ };
28
+ userAgentSwitchSettings: {
29
+ switchType: UserAgentSwitchType;
30
+ customPeriod: number;
31
+ userAgents: string[];
32
+ };
33
+ cookieClearSettings: {
34
+ clearType: CookieClearType;
35
+ customPeriod: number;
36
+ };
37
+ captchaSettings: {
38
+ isAutoCloudflare: boolean;
39
+ };
40
+ }
41
+ export {};
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BrokerSettings = exports.WorkflowSetting = void 0;
4
+ class WorkflowSetting {
5
+ constructor(options) {
6
+ /** 是否在任务设置界面显示自动跳过无效的循环点击选项 */
7
+ this.showJumpInvalidClickSetting = true;
8
+ /** 多少次后开始判断无效循环点击 */
9
+ this.repeatPageLoopCount = 50;
10
+ /** 连续判断多少次循环点击才选无效 */
11
+ this.continuousJudgeCount = 5;
12
+ this.actionWrapper = null;
13
+ const { actionWrapper } = options || {};
14
+ actionWrapper && (this.actionWrapper = actionWrapper);
15
+ }
16
+ }
17
+ exports.WorkflowSetting = WorkflowSetting;
18
+ class BrokerSettings {
19
+ }
20
+ exports.BrokerSettings = BrokerSettings;
@@ -0,0 +1,6 @@
1
+ import type { ICaptchaContext } from './types';
2
+ /**
3
+ * 点选验证码求解
4
+ * 流程:截图主图和提示图 → 识别点击坐标 → 依次点击 → 提交
5
+ */
6
+ export declare function solveClickCaptcha(ctx: ICaptchaContext): Promise<void>;
@@ -0,0 +1 @@
1
+ 'use strict';Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports['solveClickCaptcha']=solveClickCaptcha;const Operations_1=require('../../utils/Operations'),enums_1=require('../../enums'),utils_1=require('./utils');async function solveClickCaptcha(_0x23768f){if(!_0x23768f['config']['imageXPath'])return;do{try{_0x23768f['retryTimes']>0x0&&_0x23768f['log'](enums_1['LogKey']['EnterCapacha']['Error']['Retry'],_0x23768f['name'],_0x23768f['retryTimes']);const _0x13987c=await(0x0,Operations_1['getElement'])(_0x23768f['config']['imageXPath'],_0x23768f['page']);if(!_0x13987c){_0x23768f['error'](enums_1['LogKey']['EnterCapacha']['Error']['ImageNotFound'],_0x23768f['config']['caption']);break;}const _0x2e5d63=_0x23768f['config']['subImgXPath']?await(0x0,Operations_1['getElement'])(_0x23768f['config']['subImgXPath'],_0x23768f['page']):null;if(_0x23768f['config']['subImgXPath']&&!_0x2e5d63){const _0x5e077c=_0x23768f['config']['capachaType']===enums_1['LocalCaptchaType']['Silder']?enums_1['LogKey']['EnterCapacha']['Error']['HuaKuaiImageNotFound']:enums_1['LogKey']['EnterCapacha']['Error']['TipImageNotFound'];_0x23768f['error'](_0x5e077c,_0x23768f['config']['caption']);break;}await(0x0,Operations_1['processElement'])(_0x23768f['config']['imageXPath'],_0x23768f['page'],'$eval',_0x4c3964=>{return _0x4c3964['scrollIntoView']({'behavior':'auto','block':'center','inline':'nearest'});}),await _0x23768f['sleep'](0x3e8),await _0x23768f['checkPause']();const _0x4932e9=await(0x0,Operations_1['getElement'])(_0x23768f['config']['imageXPath'],_0x23768f['page']);if(!_0x4932e9){_0x23768f['error'](enums_1['LogKey']['EnterCapacha']['Error']['ClickArea'],_0x23768f['config']['caption']);break;}const _0xf00b5b=await _0x4932e9['screenshot']({'encoding':'base64'});let _0x2be8d3='';if(_0x23768f['config']['subImgXPath']){const _0x5d2f1e=await(0x0,Operations_1['getElement'])(_0x23768f['config']['subImgXPath'],_0x23768f['page']);_0x5d2f1e&&(_0x2be8d3=await _0x5d2f1e['screenshot']({'encoding':'base64'}));}const {clickArea:clickArea=[],status:_0x489b66,isAvailable:_0x6966b3}=await _0x23768f['getCaptchaToken']({'image':_0xf00b5b,'image2':_0x2be8d3,'captchaType':enums_1['LocalCaptchaType']['Click']});if(!_0x6966b3){_0x23768f['isCaptchaSuccess']=!![];break;}if(!clickArea['length']){_0x23768f['isCaptchaSuccess']=![],_0x23768f['error'](enums_1['LogKey']['EnterCapacha']['Error']['ClickArea'],_0x23768f['config']['caption'],_0x489b66);continue;}await executeClickEvent(_0x23768f,clickArea,_0x4932e9);if(_0x23768f['config']['submitXPath']&&_0x23768f['config']['submitXPath']['AbsXpath']){const _0x30c0dd=await(0x0,Operations_1['queryElement'])(_0x23768f['config']['submitXPath'],_0x23768f['page']);_0x30c0dd&&await _0x30c0dd['click']();}const {ajaxLoad:_0x2ec2d6,ajaxTimeout:_0x337597}=_0x23768f['config'];_0x2ec2d6&&_0x337597>0x0?await _0x23768f['sleep'](_0x337597):await _0x23768f['sleep'](0x7d0),await _0x23768f['capachaSuccess']()?_0x23768f['isCaptchaSuccess']=!![]:_0x23768f['isCaptchaSuccess']=![];}catch(_0x39168d){await _0x23768f['checkPause'](),_0x23768f['error'](enums_1['LogKey']['EnterCapacha']['Error']['ClickArea'],_0x23768f['config']['caption']),console['log']('click\x20captcha\x20error',_0x39168d);}finally{await _0x23768f['checkPause'](),_0x23768f['retryTimes']+=0x1;}}while(!_0x23768f['isCaptchaSuccess']&&_0x23768f['retryTimes']<=_0x23768f['config']['capachaMaxRetry']);}async function executeClickEvent(_0x5583cb,_0xd137a7,_0x4ef6bd){const _0x3b9d20=await _0x4ef6bd['boundingBox']();if(!_0x3b9d20)return;let _0x1d81f9=0x1;try{_0x1d81f9=await _0x5583cb['page']['evaluate'](()=>window['devicePixelRatio']||0x1);}catch{_0x1d81f9=0x1;}for(const _0x2fa75d of _0xd137a7){const [_0x22c599,_0x26f67c]=_0x2fa75d['split'](','),_0x572e60=_0x3b9d20['x']+Number(_0x22c599)/_0x1d81f9,_0xfc36=_0x3b9d20['y']+Number(_0x26f67c)/_0x1d81f9;await _0x5583cb['page']['mouse']['move'](_0x572e60,_0xfc36),await _0x5583cb['page']['mouse']['down'](),await _0x5583cb['page']['mouse']['up'](),await _0x5583cb['sleep']((0x0,utils_1['getRandomInt'])(0x12c,0x3e8));}}
@@ -0,0 +1,4 @@
1
+ import { Page } from 'puppeteer-core';
2
+ export declare function extractHCaptchaSiteKey(page: Page): Promise<string>;
3
+ export declare function injectHCaptchaToken(page: Page, token: string): Promise<void>;
4
+ export declare function triggerHCaptchaCallback(page: Page, token: string): Promise<void>;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractHCaptchaSiteKey = extractHCaptchaSiteKey;
4
+ exports.injectHCaptchaToken = injectHCaptchaToken;
5
+ exports.triggerHCaptchaCallback = triggerHCaptchaCallback;
6
+ // ======================== hCaptcha 密钥提取 ========================
7
+ async function extractHCaptchaSiteKey(page) {
8
+ const key = await page.evaluate(() => {
9
+ let key = '';
10
+ try {
11
+ const result = document.evaluate('//*[contains(@src,"hcaptcha")]', document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE);
12
+ if (result) {
13
+ let node = result.iterateNext();
14
+ while (node) {
15
+ const { src } = node;
16
+ if (src) {
17
+ const regExp = /(^|&|#)sitekey=([^&]*)(&|$)/;
18
+ const result = src.match(regExp);
19
+ if (result && result[2]) {
20
+ key = result[2];
21
+ break;
22
+ }
23
+ }
24
+ node = result.iterateNext();
25
+ }
26
+ }
27
+ }
28
+ catch (error) {
29
+ console.error(error);
30
+ }
31
+ return key;
32
+ });
33
+ return key;
34
+ }
35
+ // ======================== hCaptcha Token 注入 ========================
36
+ async function injectHCaptchaToken(page, token) {
37
+ if (!token)
38
+ return;
39
+ await page.evaluate((token) => {
40
+ const element = document.getElementsByName('h-captcha-response')[0];
41
+ if (element) {
42
+ element.innerHTML = token;
43
+ }
44
+ const element2 = document.getElementsByName('g-recaptcha-response')[0];
45
+ if (element2) {
46
+ element2.innerHTML = token;
47
+ }
48
+ }, token);
49
+ }
50
+ // ======================== hCaptcha 回调触发 ========================
51
+ async function triggerHCaptchaCallback(page, token) {
52
+ if (!token)
53
+ return;
54
+ /** hcaptcha 第三方已经不提供解决方案,功能暂时废弃 */
55
+ await page.evaluate(`
56
+ ((response) => {
57
+ for (const ele of document.querySelectorAll("iframe[data-hcaptcha-widget-id]")) {
58
+ const id = ele.attributes["data-hcaptcha-widget-id"].value;
59
+ const data = JSON.stringify({
60
+ source: "hcaptcha",
61
+ label: "challenge-closed",
62
+ id,
63
+ contents: {
64
+ event: "challenge-passed",
65
+ response,
66
+ expiration: 120
67
+ }
68
+ });
69
+ window.dispatchEvent(new MessageEvent('message', {data}))
70
+ }
71
+ })(${token});
72
+ `);
73
+ }
@@ -0,0 +1,2 @@
1
+ import type { ICaptchaContext } from './types';
2
+ export declare function solveImageCaptcha(ctx: ICaptchaContext): Promise<void>;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.solveImageCaptcha = solveImageCaptcha;
4
+ const Operations_1 = require("../../utils/Operations");
5
+ const enums_1 = require("../../enums");
6
+ async function solveImageCaptcha(ctx) {
7
+ if (!ctx.config.imageXPath || !ctx.config.inputXPath) {
8
+ return;
9
+ }
10
+ do {
11
+ try {
12
+ if (ctx.retryTimes > 0) {
13
+ ctx.log(enums_1.LogKey.EnterCapacha.Error.Retry, ctx.name, ctx.retryTimes);
14
+ }
15
+ // 找不到验证码相关目标元素就退出,不重试,遵循之前的逻辑
16
+ const inputXPathIsExist = await (0, Operations_1.getElement)(ctx.config.inputXPath, ctx.page);
17
+ if (!inputXPathIsExist) {
18
+ break;
19
+ }
20
+ const imageXPathIsExist = await (0, Operations_1.getElement)(ctx.config.imageXPath, ctx.page);
21
+ if (!imageXPathIsExist) {
22
+ break;
23
+ }
24
+ await (0, Operations_1.processElement)(ctx.config.imageXPath, ctx.page, '$eval', (ele) => {
25
+ return ele.scrollIntoView({
26
+ behavior: 'auto',
27
+ block: 'center',
28
+ inline: 'nearest',
29
+ });
30
+ });
31
+ await ctx.sleep(1 * 1000);
32
+ const codeElement = await (0, Operations_1.getElement)(ctx.config.imageXPath, ctx.page);
33
+ if (codeElement) {
34
+ const image = await codeElement.screenshot({
35
+ encoding: 'base64',
36
+ });
37
+ // 获取得到image code
38
+ const url = ctx.page.url();
39
+ const token = await ctx.getCaptchaToken({
40
+ image,
41
+ url,
42
+ captchaType: enums_1.LocalCaptchaType.TextInput,
43
+ });
44
+ const clickLocator = ctx.page.locator(`::-p-xpath(${ctx.config.submitXPath.AbsXpath})`);
45
+ await ctx.page.locator(`::-p-xpath(${ctx.config.inputXPath.AbsXpath})`).fill(token);
46
+ await Promise.allSettled([ctx.page.waitForNetworkIdle({ concurrency: 6 }), clickLocator.click()]);
47
+ // 判断是否需要失败重试
48
+ if (!(await ctx.capachaSuccess())) {
49
+ const locator = ctx.page.locator(`::-p-xpath(${ctx.config.imageXPath.AbsXpath})`);
50
+ await Promise.allSettled([ctx.page.waitForNetworkIdle({ concurrency: 6 }), locator.click()]);
51
+ ctx.isCaptchaSuccess = false;
52
+ }
53
+ else {
54
+ ctx.isCaptchaSuccess = true;
55
+ }
56
+ const { ajaxLoad, ajaxTimeout } = ctx.config;
57
+ if (!(ajaxLoad && ajaxTimeout > 0)) {
58
+ await ctx.sleep(4000);
59
+ }
60
+ }
61
+ else {
62
+ break;
63
+ }
64
+ }
65
+ catch (error) {
66
+ await ctx.checkPause();
67
+ console.log('captcha error', error);
68
+ }
69
+ finally {
70
+ await ctx.checkPause();
71
+ ctx.retryTimes += 1;
72
+ }
73
+ } while (!ctx.isCaptchaSuccess && ctx.retryTimes <= ctx.config.capachaMaxRetry);
74
+ }
@@ -0,0 +1,9 @@
1
+ import { Page } from 'puppeteer-core';
2
+ export declare function extractReCaptchaSiteKey(page: Page): Promise<string>;
3
+ export declare function extractReCaptchav3SiteKey(page: Page): Promise<{
4
+ key: string;
5
+ action: string;
6
+ }>;
7
+ export declare function injectReCaptchaToken(page: Page, token: string): Promise<void>;
8
+ export declare function injectReCaptchaV3Token(page: Page, token: string): Promise<void>;
9
+ export declare function triggerReCaptchaCallback(page: Page, token: string): Promise<void>;
@@ -0,0 +1,371 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractReCaptchaSiteKey = extractReCaptchaSiteKey;
4
+ exports.extractReCaptchav3SiteKey = extractReCaptchav3SiteKey;
5
+ exports.injectReCaptchaToken = injectReCaptchaToken;
6
+ exports.injectReCaptchaV3Token = injectReCaptchaV3Token;
7
+ exports.triggerReCaptchaCallback = triggerReCaptchaCallback;
8
+ // ======================== reCAPTCHA V2 密钥提取 ========================
9
+ async function extractReCaptchaSiteKey(page) {
10
+ // 先尝试常规方式获取
11
+ let key = await extractReCaptchaKeyFromPage(page);
12
+ // 如果常规方式失败,尝试从iframe获取
13
+ if (!key) {
14
+ key = await extractReCaptchaKeyFromIframes(page);
15
+ }
16
+ return key;
17
+ }
18
+ async function extractReCaptchaKeyFromPage(page) {
19
+ const key = await page.evaluate(() => {
20
+ let key = '';
21
+ let element = document.getElementById('g-recaptcha-response');
22
+ while (element) {
23
+ element = element.parentElement;
24
+ if (!element) {
25
+ break;
26
+ }
27
+ key = element.getAttribute('data-sitekey');
28
+ if (key) {
29
+ break;
30
+ }
31
+ }
32
+ // 找不到key, 从src上获取
33
+ if (!key) {
34
+ try {
35
+ const result = document.evaluate('//*[contains(@src,"recaptcha")]', document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE);
36
+ if (result) {
37
+ let node = result.iterateNext();
38
+ while (node) {
39
+ const { src } = node;
40
+ if (src) {
41
+ const regExp = /(^|&|#)k=([^&]*)(&|$)/;
42
+ const match = src.match(regExp);
43
+ if (match && match[2]) {
44
+ key = match[2];
45
+ break;
46
+ }
47
+ }
48
+ node = result.iterateNext();
49
+ }
50
+ }
51
+ }
52
+ catch (error) {
53
+ // 可以选择打印错误
54
+ // console.error(error);
55
+ }
56
+ }
57
+ return key;
58
+ });
59
+ return key;
60
+ }
61
+ async function extractReCaptchaKeyFromIframes(page) {
62
+ const sitekey = await page.evaluate(`
63
+ new Promise((resolve, reject) => {
64
+ function findRecaptchaClientsInIframe(iframeDocument) {
65
+ const iframes = iframeDocument.getElementsByTagName("iframe");
66
+ for (const iframe of iframes) {
67
+ const iframeWindow = iframe.contentWindow;
68
+ if (typeof iframeWindow.___grecaptcha_cfg !== "undefined") {
69
+ for (let [cid, client] of Object.entries(iframeWindow.___grecaptcha_cfg.clients)) {
70
+ const data = { id: cid, version: cid >= 10000 ? "V3" : "V2" };
71
+ const objects = Object.entries(client).filter(
72
+ ([_, value]) => value && typeof value === "object"
73
+ );
74
+ for (const [toplevelKey, toplevel] of objects) {
75
+ const found = Object.entries(toplevel).find(
76
+ ([_, value]) =>
77
+ value &&
78
+ typeof value === "object" &&
79
+ "sitekey" in value &&
80
+ "size" in value
81
+ );
82
+ if (typeof toplevel === "object" && toplevel instanceof HTMLElement && toplevel["tagName"] === "DIV") {
83
+ data.pageurl = toplevel.baseURI;
84
+ }
85
+ if (found) {
86
+ const [sublevelKey, sublevel] = found;
87
+ data.sitekey = sublevel.sitekey;
88
+ if (data.sitekey) {
89
+ return data.sitekey;
90
+ }
91
+ }
92
+ }
93
+ }
94
+ } else {
95
+ const sitekey = findRecaptchaClientsInIframe(iframeWindow.document);
96
+ return sitekey
97
+ }
98
+ }
99
+ return '';
100
+ }
101
+ if (typeof ___grecaptcha_cfg !== "undefined") {
102
+ for (let [cid, client] of Object.entries(___grecaptcha_cfg.clients)) {
103
+ const data = { id: cid, version: cid >= 10000 ? "V3" : "V2" };
104
+ const objects = Object.entries(client).filter(
105
+ ([_, value]) => value && typeof value === "object"
106
+ );
107
+ for (let [toplevelKey, toplevel] of objects) {
108
+ const found = Object.entries(toplevel).find(
109
+ ([_, value]) =>
110
+ value &&
111
+ typeof value === "object" &&
112
+ "sitekey" in value &&
113
+ "size" in value
114
+ );
115
+ if (typeof toplevel === "object" && toplevel instanceof HTMLElement && toplevel["tagName"] === "DIV") {
116
+ data.pageurl = toplevel.baseURI;
117
+ }
118
+ if (found) {
119
+ const [sublevelKey, sublevel] = found;
120
+ data.sitekey = sublevel.sitekey;
121
+ if (data.sitekey) {
122
+ resolve(data.sitekey);
123
+ }
124
+ }
125
+ }
126
+ }
127
+ } else {
128
+ const sitekey = findRecaptchaClientsInIframe(document);
129
+ resolve(sitekey);
130
+ }
131
+ })`);
132
+ return sitekey;
133
+ }
134
+ // ======================== reCAPTCHA V3 密钥提取 ========================
135
+ async function extractReCaptchav3SiteKey(page) {
136
+ let key = '';
137
+ let action = 'verify';
138
+ // 检查iframe是否可以访问的函数
139
+ const canAccessIframe = async (frame) => {
140
+ try {
141
+ // 尝试执行简单的代码来检查是否可以访问
142
+ await frame.evaluate(() => document.title);
143
+ return true;
144
+ }
145
+ catch (error) {
146
+ return false;
147
+ }
148
+ };
149
+ // 在指定frame中查找reCAPTCHA key
150
+ const findIFramesKeyInFrame = async (frame) => {
151
+ try {
152
+ // 检查当前frame是否可以访问
153
+ if (!(await canAccessIframe(frame))) {
154
+ return '';
155
+ }
156
+ // 检查frame标题
157
+ const frameTitle = await frame
158
+ .evaluate(() => {
159
+ return document.title || (document.querySelector('iframe[title="reCAPTCHA"]') ? 'reCAPTCHA' : '');
160
+ })
161
+ .catch(() => '');
162
+ // 如果是reCAPTCHA frame,在当前frame中查找
163
+ const foundKey = await frame
164
+ .evaluate(() => {
165
+ try {
166
+ // 查找含有recaptcha的script或iframe
167
+ const result = document.evaluate('//*[contains(@src,"recaptcha")]', document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE);
168
+ if (result) {
169
+ let node = result.iterateNext();
170
+ while (node) {
171
+ const src = node.getAttribute('src') || '';
172
+ if (src) {
173
+ const regExp = /(^|&|#)k=([^&]*)(&|$)/;
174
+ const match = src.match(regExp);
175
+ if (match && match[2]) {
176
+ return match[2];
177
+ }
178
+ }
179
+ node = result.iterateNext();
180
+ }
181
+ }
182
+ return '';
183
+ }
184
+ catch (error) {
185
+ return '';
186
+ }
187
+ })
188
+ .catch(() => '');
189
+ if (foundKey) {
190
+ return foundKey;
191
+ }
192
+ return '';
193
+ }
194
+ catch (error) {
195
+ return '';
196
+ }
197
+ };
198
+ try {
199
+ // 获取所有frames
200
+ const frames = page.frames();
201
+ key = await findIFramesKeyInFrame(page.mainFrame());
202
+ // 如果主页面没找到,检查所有子frames
203
+ if (!key) {
204
+ for (const frame of frames) {
205
+ if (frame === page.mainFrame())
206
+ continue;
207
+ const frameKey = await findIFramesKeyInFrame(frame);
208
+ if (frameKey) {
209
+ key = frameKey;
210
+ break;
211
+ }
212
+ }
213
+ }
214
+ }
215
+ catch (error) {
216
+ console.error('extractReCaptchav3SiteKey总体错误:', error);
217
+ }
218
+ const result = { key: key || '', action };
219
+ return result;
220
+ }
221
+ // ======================== reCAPTCHA Token 注入 ========================
222
+ async function injectReCaptchaToken(page, token) {
223
+ if (!token)
224
+ return;
225
+ await page.evaluate((token) => {
226
+ try {
227
+ const elements = [];
228
+ const result = document.evaluate('//*[contains(@id,"g-recaptcha-response")]', document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE);
229
+ if (result) {
230
+ let node = result.iterateNext();
231
+ while (node) {
232
+ elements.push(node);
233
+ node = result.iterateNext();
234
+ }
235
+ }
236
+ elements.forEach(function (el) {
237
+ el.innerHTML = token;
238
+ });
239
+ }
240
+ catch (error) {
241
+ console.error(error);
242
+ }
243
+ }, token);
244
+ }
245
+ async function injectReCaptchaV3Token(page, token) {
246
+ if (!token)
247
+ return;
248
+ await page.evaluate((token) => {
249
+ if (token) {
250
+ try {
251
+ /** 找到iframe 属性为title
252
+ * 找不到准确的iframe,这里调整
253
+ */
254
+ const iframes = document.getElementsByTagName('iframe');
255
+ for (const iframe of Array.from(iframes)) {
256
+ if (iframe.title === 'reCAPTCHA') {
257
+ const iframeDocument = iframe.contentWindow.document;
258
+ const elements = [];
259
+ const result = iframeDocument.evaluate('//*[contains(@id,"recaptcha-token")]', iframeDocument, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE);
260
+ if (result) {
261
+ let node = result.iterateNext();
262
+ // eslint-disable-next-line max-depth
263
+ while (node) {
264
+ elements.push(node);
265
+ node = result.iterateNext();
266
+ }
267
+ }
268
+ elements.forEach((el) => {
269
+ el.value = token;
270
+ });
271
+ }
272
+ continue;
273
+ }
274
+ }
275
+ catch (error) {
276
+ console.error(error);
277
+ }
278
+ }
279
+ }, token);
280
+ }
281
+ // ======================== reCAPTCHA 回调触发 ========================
282
+ async function triggerReCaptchaCallback(page, token) {
283
+ await page.evaluate(`
284
+ (() => {
285
+ function findRecaptchaClientsInIframe(iframeDocument) {
286
+ const iframes = iframeDocument.getElementsByTagName("iframe");
287
+ for (const iframe of iframes) {
288
+ const iframeWindow = iframe.contentWindow;
289
+ if (typeof iframeWindow.___grecaptcha_cfg !== "undefined" && iframeWindow.___grecaptcha_cfg.clients) {
290
+ for (let [cid, client] of Object.entries(iframeWindow.___grecaptcha_cfg.clients)) {
291
+ const data = { id: cid, version: cid >= 10000 ? "V3" : "V2" };
292
+ const objects = Object.entries(client).filter(
293
+ ([_, value]) => value && typeof value === "object"
294
+ );
295
+ for (const [toplevelKey, toplevel] of objects) {
296
+ const found = Object.entries(toplevel).find(
297
+ ([_, value]) =>
298
+ value &&
299
+ typeof value === "object" &&
300
+ "sitekey" in value &&
301
+ "size" in value
302
+ );
303
+ if (typeof toplevel === "object" && toplevel instanceof HTMLElement && toplevel["tagName"] === "DIV") {
304
+ data.pageurl = toplevel.baseURI;
305
+ }
306
+ if (found) {
307
+ const [sublevelKey, sublevel] = found;
308
+ data.sitekey = sublevel.sitekey;
309
+ const callbackKey = data.version === "V2" ? "callback" : "promise-callback";
310
+ const callback = sublevel[callbackKey];
311
+ if (!callback) {
312
+ data.callback = null;
313
+ data.function = null;
314
+ } else {
315
+ if (typeof callback === "function") {
316
+ callback("${token}");
317
+ } else if (typeof callback === "string") {
318
+ iframeWindow.eval(callback)("${token}");
319
+ }
320
+ return;
321
+ }
322
+ }
323
+ }
324
+ }
325
+ } else if(iframeWindow) {
326
+ return findRecaptchaClientsInIframe(iframeWindow.document);
327
+ }
328
+ }
329
+ }
330
+ if (typeof ___grecaptcha_cfg !== "undefined" && ___grecaptcha_cfg.clients) {
331
+ for (let [cid, client] of Object.entries(___grecaptcha_cfg.clients)) {
332
+ const data = { id: cid, version: cid >= 10000 ? "V3" : "V2" };
333
+ const objects = Object.entries(client).filter(
334
+ ([_, value]) => value && typeof value === "object"
335
+ );
336
+ for (let [toplevelKey, toplevel] of objects) {
337
+ const found = Object.entries(toplevel).find(
338
+ ([_, value]) =>
339
+ value &&
340
+ typeof value === "object" &&
341
+ "sitekey" in value &&
342
+ "size" in value
343
+ );
344
+ if (typeof toplevel === "object" && toplevel instanceof HTMLElement && toplevel["tagName"] === "DIV") {
345
+ data.pageurl = toplevel.baseURI;
346
+ }
347
+ if (found) {
348
+ const [sublevelKey, sublevel] = found;
349
+ data.sitekey = sublevel.sitekey;
350
+ const callbackKey = data.version === "V2" ? "callback" : "promise-callback";
351
+ const callback = sublevel[callbackKey];
352
+ if (!callback) {
353
+ data.callback = null;
354
+ data.function = null;
355
+ } else {
356
+ if (typeof callback === "function") {
357
+ callback("${token}");
358
+ } else if (typeof callback === "string") {
359
+ eval(callback)("${token}");
360
+ }
361
+ return;
362
+ }
363
+ }
364
+ }
365
+ }
366
+ } else {
367
+ findRecaptchaClientsInIframe(document);
368
+ }
369
+ })()
370
+ `);
371
+ }
@@ -0,0 +1,6 @@
1
+ import type { ICaptchaContext } from './types';
2
+ /**
3
+ * 滑块验证码求解
4
+ * 流程:截图 → 识别滑动距离 → 模拟人类滑动轨迹
5
+ */
6
+ export declare function solveSliderCaptcha(ctx: ICaptchaContext): Promise<void>;