@apifuse/provider-sdk 2.2.0-beta.5 → 2.2.0-beta.51

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 (368) hide show
  1. package/AUTHORING.md +537 -33
  2. package/CHANGELOG.md +205 -1
  3. package/README.md +83 -22
  4. package/SUBMISSION.md +2 -2
  5. package/bin/apifuse-check.ts +165 -11
  6. package/bin/apifuse-dev.ts +57 -13
  7. package/bin/apifuse-migrate-operation-declaration.ts +55 -0
  8. package/bin/apifuse-migrate-shape.ts +202 -0
  9. package/bin/apifuse-pack-check.ts +22 -2
  10. package/bin/apifuse-pack-smoke.ts +57 -2
  11. package/bin/apifuse-pack-types.ts +357 -38
  12. package/bin/apifuse-perf.ts +14 -13
  13. package/bin/apifuse-record.ts +709 -72
  14. package/bin/apifuse-submit-check.ts +2344 -324
  15. package/bin/apifuse-sync-assets.ts +117 -0
  16. package/bin/submit-check-delimited-text.ts +50 -0
  17. package/dist/auth-turn/index.d.ts +3 -3
  18. package/dist/auth-turn/index.js +1 -1
  19. package/dist/auth.d.ts +14 -0
  20. package/dist/auth.js +67 -0
  21. package/dist/ceremonies/index.d.ts +16 -0
  22. package/dist/ceremonies/index.js +141 -36
  23. package/dist/cli/commands.d.ts +1 -1
  24. package/dist/cli/commands.js +27 -0
  25. package/dist/cli/create.d.ts +4 -1
  26. package/dist/cli/create.js +42 -37
  27. package/dist/cli/migrate-operation-declaration.d.ts +59 -0
  28. package/dist/cli/migrate-operation-declaration.js +1249 -0
  29. package/dist/cli/migrate-operation-shape.d.ts +44 -0
  30. package/dist/cli/migrate-operation-shape.js +113 -0
  31. package/dist/cli/migrate-provider-shape.d.ts +52 -0
  32. package/dist/cli/migrate-provider-shape.js +578 -0
  33. package/dist/cli/prompt-assets.d.ts +80 -0
  34. package/dist/cli/prompt-assets.js +743 -0
  35. package/dist/cli/templates/provider/AGENTS.md.tpl +17 -8
  36. package/dist/cli/templates/provider/Dockerfile.tpl +1 -1
  37. package/dist/cli/templates/provider/README.md.tpl +5 -5
  38. package/dist/cli/templates/provider/index.ts.tpl +6 -3
  39. package/dist/cli/templates/provider/operations/ping.ts.tpl +4 -1
  40. package/dist/cli/templates/provider/provider.json.tpl +6 -0
  41. package/dist/config/loader.d.ts +179 -16
  42. package/dist/config/loader.js +435 -127
  43. package/dist/contract-serialization.js +4 -8
  44. package/dist/contract-types.d.ts +12 -5
  45. package/dist/contract.js +24 -10
  46. package/dist/declaration-validation.d.ts +33 -0
  47. package/dist/declaration-validation.js +266 -0
  48. package/dist/define.d.ts +66 -29
  49. package/dist/define.js +778 -69
  50. package/dist/dev.d.ts +3 -0
  51. package/dist/dev.js +1 -1
  52. package/dist/engine.d.ts +78 -0
  53. package/dist/engine.js +133 -0
  54. package/dist/error-observability.d.ts +7 -0
  55. package/dist/error-observability.js +61 -0
  56. package/dist/error-resolution.d.ts +4 -0
  57. package/dist/error-resolution.js +122 -0
  58. package/dist/errors.d.ts +33 -0
  59. package/dist/errors.js +40 -0
  60. package/dist/fixture-sanitization.d.ts +28 -0
  61. package/dist/fixture-sanitization.js +227 -0
  62. package/dist/health-scenario.d.ts +1842 -0
  63. package/dist/health-scenario.js +624 -0
  64. package/dist/index.d.ts +21 -10
  65. package/dist/index.js +12 -7
  66. package/dist/lint.d.ts +23 -11
  67. package/dist/lint.js +572 -69
  68. package/dist/native-address.d.ts +43 -0
  69. package/dist/native-address.js +281 -0
  70. package/dist/native-egress-policy.d.ts +31 -0
  71. package/dist/native-egress-policy.js +288 -0
  72. package/dist/observability.d.ts +5 -2
  73. package/dist/observability.js +48 -1
  74. package/dist/provider.d.ts +10 -2
  75. package/dist/provider.js +4 -1
  76. package/dist/runtime/auth-flow.d.ts +5 -1
  77. package/dist/runtime/auth-flow.js +6 -0
  78. package/dist/runtime/browser.d.ts +1 -0
  79. package/dist/runtime/browser.js +492 -49
  80. package/dist/runtime/cache.d.ts +1 -0
  81. package/dist/runtime/cache.js +169 -15
  82. package/dist/runtime/choice-wordlist.d.ts +9 -0
  83. package/dist/runtime/choice-wordlist.js +138 -0
  84. package/dist/runtime/choice.d.ts +13 -1
  85. package/dist/runtime/choice.js +490 -102
  86. package/dist/runtime/chrome149-header-order.d.ts +58 -0
  87. package/dist/runtime/chrome149-header-order.js +289 -0
  88. package/dist/runtime/env.js +12 -0
  89. package/dist/runtime/executor.d.ts +3 -2
  90. package/dist/runtime/executor.js +26 -25
  91. package/dist/runtime/http.d.ts +1 -0
  92. package/dist/runtime/http.js +515 -53
  93. package/dist/runtime/insights.js +2 -2
  94. package/dist/runtime/instrumentation.d.ts +2 -2
  95. package/dist/runtime/instrumentation.js +366 -8
  96. package/dist/runtime/native-network-errors.d.ts +33 -0
  97. package/dist/runtime/native-network-errors.js +69 -0
  98. package/dist/runtime/native-network.d.ts +96 -0
  99. package/dist/runtime/native-network.js +1232 -0
  100. package/dist/runtime/ocr.d.ts +29 -0
  101. package/dist/runtime/ocr.js +440 -0
  102. package/dist/runtime/otlp.d.ts +71 -2
  103. package/dist/runtime/otlp.js +397 -16
  104. package/dist/runtime/proxy-errors.js +6 -2
  105. package/dist/runtime/proxy-nodemaven.d.ts +56 -0
  106. package/dist/runtime/proxy-nodemaven.js +146 -0
  107. package/dist/runtime/proxy-telemetry.d.ts +80 -1
  108. package/dist/runtime/proxy-telemetry.js +154 -47
  109. package/dist/runtime/redirects.d.ts +29 -0
  110. package/dist/runtime/redirects.js +36 -0
  111. package/dist/runtime/redis.d.ts +1 -1
  112. package/dist/runtime/redis.js +4 -2
  113. package/dist/runtime/request-options.d.ts +68 -1
  114. package/dist/runtime/request-options.js +548 -0
  115. package/dist/runtime/resolver-config.d.ts +6 -0
  116. package/dist/runtime/resolver-config.js +6 -0
  117. package/dist/runtime/resolver-public.d.ts +1 -0
  118. package/dist/runtime/resolver-public.js +1 -0
  119. package/dist/runtime/resolver-shared.d.ts +14 -0
  120. package/dist/runtime/resolver-shared.js +12 -0
  121. package/dist/runtime/resolver-vendors/bindings.d.ts +48 -0
  122. package/dist/runtime/resolver-vendors/bindings.js +40 -0
  123. package/dist/runtime/resolver-vendors/browser.d.ts +22 -0
  124. package/dist/runtime/resolver-vendors/browser.js +377 -0
  125. package/dist/runtime/resolver-vendors/capsolver.d.ts +22 -0
  126. package/dist/runtime/resolver-vendors/capsolver.js +531 -0
  127. package/dist/runtime/resolver-vendors/hosts.d.ts +2 -0
  128. package/dist/runtime/resolver-vendors/hosts.js +33 -0
  129. package/dist/runtime/resolver-vendors/twocaptcha.d.ts +24 -0
  130. package/dist/runtime/resolver-vendors/twocaptcha.js +408 -0
  131. package/dist/runtime/resolver-vendors/types.d.ts +94 -0
  132. package/dist/runtime/resolver-vendors/types.js +96 -0
  133. package/dist/runtime/resolver.d.ts +72 -0
  134. package/dist/runtime/resolver.js +771 -0
  135. package/dist/runtime/secrets.d.ts +27 -0
  136. package/dist/runtime/secrets.js +51 -0
  137. package/dist/runtime/state.d.ts +3 -0
  138. package/dist/runtime/state.js +277 -71
  139. package/dist/runtime/stealth-cookies.d.ts +20 -0
  140. package/dist/runtime/stealth-cookies.js +111 -0
  141. package/dist/runtime/stealth.d.ts +41 -5
  142. package/dist/runtime/stealth.js +997 -291
  143. package/dist/runtime/stt.js +1 -12
  144. package/dist/runtime/timeout.d.ts +5 -0
  145. package/dist/runtime/timeout.js +12 -0
  146. package/dist/runtime/trace-config.d.ts +12 -0
  147. package/dist/runtime/trace-config.js +62 -0
  148. package/dist/runtime/trace.d.ts +5 -0
  149. package/dist/runtime/trace.js +43 -10
  150. package/dist/serve.d.ts +1 -1
  151. package/dist/serve.js +1 -1
  152. package/dist/server/error-observability.d.ts +1 -0
  153. package/dist/server/error-observability.js +1 -0
  154. package/dist/server/index.d.ts +5 -2
  155. package/dist/server/index.js +2 -2
  156. package/dist/server/self-test-input-tokens.d.ts +2 -1
  157. package/dist/server/self-test-input-tokens.js +18 -14
  158. package/dist/server/self-test.d.ts +14 -3
  159. package/dist/server/self-test.js +129 -58
  160. package/dist/server/serve-implementation.d.ts +230 -0
  161. package/dist/server/serve-implementation.js +2265 -0
  162. package/dist/server/serve.d.ts +1 -70
  163. package/dist/server/serve.js +1 -1131
  164. package/dist/server/trace-output.d.ts +6 -0
  165. package/dist/server/trace-output.js +79 -0
  166. package/dist/server/types.d.ts +30 -5
  167. package/dist/server/types.js +13 -1
  168. package/dist/stateful/errors.d.ts +19 -0
  169. package/dist/stateful/errors.js +24 -0
  170. package/dist/stateful/http-provider-event-emitter.d.ts +40 -0
  171. package/dist/stateful/http-provider-event-emitter.js +237 -0
  172. package/dist/stateful/http-session-owner-registry.d.ts +44 -0
  173. package/dist/stateful/http-session-owner-registry.js +210 -0
  174. package/dist/stateful/index.d.ts +18 -0
  175. package/dist/stateful/index.js +18 -0
  176. package/dist/stateful/provider-event-delivery-failures.d.ts +32 -0
  177. package/dist/stateful/provider-event-delivery-failures.js +43 -0
  178. package/dist/stateful/provider-event-pipeline-metrics.d.ts +46 -0
  179. package/dist/stateful/provider-event-pipeline-metrics.js +48 -0
  180. package/dist/stateful/provider-event-pipeline.d.ts +50 -0
  181. package/dist/stateful/provider-event-pipeline.js +1 -0
  182. package/dist/stateful/provider-events.d.ts +101 -0
  183. package/dist/stateful/provider-events.js +289 -0
  184. package/dist/stateful/session-key.d.ts +15 -0
  185. package/dist/stateful/session-key.js +86 -0
  186. package/dist/stateful/stateful-provider-adapter-context.d.ts +5 -0
  187. package/dist/stateful/stateful-provider-adapter-context.js +42 -0
  188. package/dist/stateful/stateful-provider-adapter-metrics.d.ts +15 -0
  189. package/dist/stateful/stateful-provider-adapter-metrics.js +21 -0
  190. package/dist/stateful/stateful-provider-adapter.d.ts +98 -0
  191. package/dist/stateful/stateful-provider-adapter.js +287 -0
  192. package/dist/stateful/stateful-provider-observability.d.ts +62 -0
  193. package/dist/stateful/stateful-provider-observability.js +161 -0
  194. package/dist/stateful/stateful-provider-owner-forwarder.d.ts +41 -0
  195. package/dist/stateful/stateful-provider-owner-forwarder.js +215 -0
  196. package/dist/stateful/stateful-provider-runtime-context.d.ts +32 -0
  197. package/dist/stateful/stateful-provider-runtime-context.js +60 -0
  198. package/dist/stateful/stateful-provider-runtime-executor.d.ts +34 -0
  199. package/dist/stateful/stateful-provider-runtime-executor.js +52 -0
  200. package/dist/stateful/stateful-provider-session-routing.d.ts +67 -0
  201. package/dist/stateful/stateful-provider-session-routing.js +345 -0
  202. package/dist/stateful/stateful-provider-session-runtime.d.ts +98 -0
  203. package/dist/stateful/stateful-provider-session-runtime.js +245 -0
  204. package/dist/stateful-signing.d.ts +18 -0
  205. package/dist/stateful-signing.js +27 -0
  206. package/dist/stealth/profiles.d.ts +9 -4
  207. package/dist/stealth/profiles.js +160 -211
  208. package/dist/stream-evidence.d.ts +74 -0
  209. package/dist/stream-evidence.js +785 -0
  210. package/dist/stream.js +7 -1
  211. package/dist/testing/index.d.ts +2 -1
  212. package/dist/testing/index.js +2 -1
  213. package/dist/testing/run.d.ts +32 -2
  214. package/dist/testing/run.js +489 -21
  215. package/dist/trace-sanitization.d.ts +5 -0
  216. package/dist/trace-sanitization.js +45 -0
  217. package/dist/types.d.ts +673 -131
  218. package/dist/types.js +1 -0
  219. package/package.json +45 -5
  220. package/src/auth-turn/index.ts +1 -1
  221. package/src/auth.ts +118 -0
  222. package/src/ceremonies/index.ts +189 -46
  223. package/src/cli/__tests__/fixtures/migrate-operation-declaration/approval-override.ts.txt +6 -0
  224. package/src/cli/__tests__/fixtures/migrate-operation-declaration/codemod-syntax.ts.txt +3 -0
  225. package/src/cli/__tests__/fixtures/migrate-operation-declaration/connection-precedence.ts.txt +10 -0
  226. package/src/cli/__tests__/fixtures/migrate-operation-declaration/docs-conflict.ts.txt +8 -0
  227. package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-hoisted-array-spread.ts.txt +15 -0
  228. package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-imported-array-spread.ts.txt +9 -0
  229. package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-map.ts.txt +5 -0
  230. package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-mixed-array-spread.ts.txt +24 -0
  231. package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-operation.ts.txt +16 -0
  232. package/src/cli/__tests__/fixtures/migrate-operation-declaration/factory-map.ts.txt +3 -0
  233. package/src/cli/__tests__/fixtures/migrate-operation-declaration/hoist-all.ts.txt +31 -0
  234. package/src/cli/__tests__/fixtures/migrate-operation-declaration/hoisted-const.ts.txt +11 -0
  235. package/src/cli/__tests__/fixtures/migrate-operation-declaration/imported-spread.ts.txt +11 -0
  236. package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-map.ts.txt +11 -0
  237. package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-spread-cast-tail.ts.txt +21 -0
  238. package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-spread-ekitan.ts.txt +11 -0
  239. package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-spread-override.ts.txt +14 -0
  240. package/src/cli/__tests__/fixtures/migrate-operation-declaration/missing-english-locale.ts.txt +7 -0
  241. package/src/cli/__tests__/fixtures/migrate-operation-declaration/no-safety.ts.txt +6 -0
  242. package/src/cli/__tests__/fixtures/migrate-operation-declaration/non-literal.ts.txt +7 -0
  243. package/src/cli/__tests__/fixtures/migrate-operation-declaration/redundant-approval.ts.txt +6 -0
  244. package/src/cli/__tests__/fixtures/migrate-operation-declaration/safety-conflict.ts.txt +7 -0
  245. package/src/cli/__tests__/fixtures/migrate-operation-declaration/stream.ts.txt +7 -0
  246. package/src/cli/__tests__/fixtures/migrate-operation-declaration/tool-router-spread.ts.txt +15 -0
  247. package/src/cli/__tests__/fixtures/migrate-operation-declaration/unparseable.ts.txt +4 -0
  248. package/src/cli/__tests__/fixtures/migrate-operation-declaration/verbatim-template.ts.txt +12 -0
  249. package/src/cli/commands.ts +33 -0
  250. package/src/cli/create.ts +50 -37
  251. package/src/cli/migrate-operation-declaration.ts +1751 -0
  252. package/src/cli/migrate-operation-shape.ts +184 -0
  253. package/src/cli/migrate-provider-shape.ts +772 -0
  254. package/src/cli/prompt-assets.ts +865 -0
  255. package/src/cli/templates/provider/AGENTS.md.tpl +17 -8
  256. package/src/cli/templates/provider/Dockerfile.tpl +1 -1
  257. package/src/cli/templates/provider/README.md.tpl +5 -5
  258. package/src/cli/templates/provider/index.ts.tpl +6 -3
  259. package/src/cli/templates/provider/operations/ping.ts.tpl +4 -1
  260. package/src/cli/templates/provider/provider.json.tpl +6 -0
  261. package/src/config/loader.ts +690 -163
  262. package/src/contract-serialization.ts +5 -7
  263. package/src/contract-types.ts +12 -5
  264. package/src/contract.ts +24 -10
  265. package/src/declaration-validation.ts +330 -0
  266. package/src/define.ts +1048 -131
  267. package/src/dev.ts +4 -1
  268. package/src/engine.ts +279 -0
  269. package/src/error-observability.ts +64 -0
  270. package/src/error-resolution.ts +127 -0
  271. package/src/errors.ts +68 -0
  272. package/src/fixture-sanitization.ts +264 -0
  273. package/src/health-scenario.ts +875 -0
  274. package/src/index.ts +220 -13
  275. package/src/lint.ts +698 -90
  276. package/src/native-address.ts +340 -0
  277. package/src/native-egress-policy.ts +358 -0
  278. package/src/observability.ts +51 -1
  279. package/src/provider.ts +161 -3
  280. package/src/runtime/auth-flow.ts +12 -0
  281. package/src/runtime/browser.ts +661 -63
  282. package/src/runtime/cache.ts +189 -14
  283. package/src/runtime/choice-wordlist.ts +145 -0
  284. package/src/runtime/choice.ts +631 -120
  285. package/src/runtime/chrome149-header-order.ts +330 -0
  286. package/src/runtime/env.ts +13 -0
  287. package/src/runtime/executor.ts +43 -31
  288. package/src/runtime/http.ts +641 -61
  289. package/src/runtime/insights.ts +2 -2
  290. package/src/runtime/instrumentation.ts +520 -15
  291. package/src/runtime/native-network-errors.ts +99 -0
  292. package/src/runtime/native-network.ts +1605 -0
  293. package/src/runtime/ocr.ts +523 -0
  294. package/src/runtime/otlp.ts +467 -21
  295. package/src/runtime/proxy-errors.ts +12 -4
  296. package/src/runtime/proxy-nodemaven.ts +221 -0
  297. package/src/runtime/proxy-telemetry.ts +244 -75
  298. package/src/runtime/redirects.ts +66 -0
  299. package/src/runtime/redis.ts +7 -2
  300. package/src/runtime/request-options.ts +680 -1
  301. package/src/runtime/resolver-config.ts +6 -0
  302. package/src/runtime/resolver-public.ts +23 -0
  303. package/src/runtime/resolver-shared.ts +33 -0
  304. package/src/runtime/resolver-vendors/bindings.ts +56 -0
  305. package/src/runtime/resolver-vendors/browser.ts +533 -0
  306. package/src/runtime/resolver-vendors/capsolver.ts +707 -0
  307. package/src/runtime/resolver-vendors/hosts.ts +38 -0
  308. package/src/runtime/resolver-vendors/twocaptcha.ts +540 -0
  309. package/src/runtime/resolver-vendors/types.ts +212 -0
  310. package/src/runtime/resolver.ts +1157 -0
  311. package/src/runtime/secrets.ts +64 -0
  312. package/src/runtime/state.ts +394 -77
  313. package/src/runtime/stealth-cookies.ts +132 -0
  314. package/src/runtime/stealth.ts +1280 -336
  315. package/src/runtime/stt.ts +1 -19
  316. package/src/runtime/timeout.ts +18 -0
  317. package/src/runtime/trace-config.ts +78 -0
  318. package/src/runtime/trace.ts +57 -17
  319. package/src/serve.ts +6 -1
  320. package/src/server/error-observability.ts +1 -0
  321. package/src/server/index.ts +34 -2
  322. package/src/server/self-test-input-tokens.ts +29 -14
  323. package/src/server/self-test.ts +191 -68
  324. package/src/server/serve-implementation.ts +3378 -0
  325. package/src/server/serve.ts +1 -1632
  326. package/src/server/trace-output.ts +129 -0
  327. package/src/server/types.ts +13 -1
  328. package/src/stateful/README.md +146 -0
  329. package/src/stateful/errors.ts +35 -0
  330. package/src/stateful/http-provider-event-emitter.ts +314 -0
  331. package/src/stateful/http-session-owner-registry.ts +306 -0
  332. package/src/stateful/index.ts +18 -0
  333. package/src/stateful/provider-event-delivery-failures.ts +80 -0
  334. package/src/stateful/provider-event-pipeline-metrics.ts +95 -0
  335. package/src/stateful/provider-event-pipeline.ts +61 -0
  336. package/src/stateful/provider-events.ts +462 -0
  337. package/src/stateful/session-key.ts +111 -0
  338. package/src/stateful/stateful-provider-adapter-context.ts +59 -0
  339. package/src/stateful/stateful-provider-adapter-metrics.ts +48 -0
  340. package/src/stateful/stateful-provider-adapter.ts +562 -0
  341. package/src/stateful/stateful-provider-observability.ts +261 -0
  342. package/src/stateful/stateful-provider-owner-forwarder.ts +287 -0
  343. package/src/stateful/stateful-provider-runtime-context.ts +92 -0
  344. package/src/stateful/stateful-provider-runtime-executor.ts +96 -0
  345. package/src/stateful/stateful-provider-session-routing.ts +546 -0
  346. package/src/stateful/stateful-provider-session-runtime.ts +403 -0
  347. package/src/stateful-signing.ts +46 -0
  348. package/src/stealth/profiles.ts +202 -231
  349. package/src/stream-evidence.ts +988 -0
  350. package/src/stream.ts +8 -1
  351. package/src/testing/index.ts +10 -1
  352. package/src/testing/run.ts +658 -15
  353. package/src/trace-sanitization.ts +63 -0
  354. package/src/types.ts +788 -174
  355. package/dist/cli/templates/provider/CLAUDE.md.tpl +0 -1
  356. package/src/cli/templates/provider/CLAUDE.md.tpl +0 -1
  357. /package/dist/cli/templates/provider/{skills → .agents/skills}/fixtures-and-recording/SKILL.md.tpl +0 -0
  358. /package/dist/cli/templates/provider/{skills → .agents/skills}/health-checks-and-fail-closed/SKILL.md.tpl +0 -0
  359. /package/dist/cli/templates/provider/{skills → .agents/skills}/normalization-standards/SKILL.md.tpl +0 -0
  360. /package/dist/cli/templates/provider/{skills → .agents/skills}/pagination-and-counts/SKILL.md.tpl +0 -0
  361. /package/dist/cli/templates/provider/{skills → .agents/skills}/upstream-contract-verification/SKILL.md.tpl +0 -0
  362. /package/dist/cli/templates/provider/{skills → .agents/skills}/upstream-notes/README.md.tpl +0 -0
  363. /package/src/cli/templates/provider/{skills → .agents/skills}/fixtures-and-recording/SKILL.md.tpl +0 -0
  364. /package/src/cli/templates/provider/{skills → .agents/skills}/health-checks-and-fail-closed/SKILL.md.tpl +0 -0
  365. /package/src/cli/templates/provider/{skills → .agents/skills}/normalization-standards/SKILL.md.tpl +0 -0
  366. /package/src/cli/templates/provider/{skills → .agents/skills}/pagination-and-counts/SKILL.md.tpl +0 -0
  367. /package/src/cli/templates/provider/{skills → .agents/skills}/upstream-contract-verification/SKILL.md.tpl +0 -0
  368. /package/src/cli/templates/provider/{skills → .agents/skills}/upstream-notes/README.md.tpl +0 -0
@@ -0,0 +1,18 @@
1
+ export declare const STATEFUL_SIGNATURE_HEADER = "x-apifuse-stateful-signature";
2
+ export declare const STATEFUL_TIMESTAMP_HEADER = "x-apifuse-stateful-timestamp";
3
+ export declare const STATEFUL_NONCE_HEADER = "x-apifuse-stateful-nonce";
4
+ export type StatefulSigningInput = {
5
+ readonly secret: string;
6
+ readonly timestamp: string;
7
+ readonly rawBody: string;
8
+ readonly method: string;
9
+ readonly path: string;
10
+ readonly nonce: string;
11
+ };
12
+ export declare function signStatefulRequestBody(input: StatefulSigningInput): string;
13
+ export declare function verifyStatefulRequestSignature(input: StatefulSigningInput & {
14
+ readonly signature: string;
15
+ }): boolean;
16
+ export declare function statefulSignedHeaders(input: Omit<StatefulSigningInput, "nonce"> & {
17
+ readonly nonce?: string;
18
+ }): Record<string, string>;
@@ -0,0 +1,27 @@
1
+ import { createHmac, randomUUID, timingSafeEqual } from "node:crypto";
2
+ export const STATEFUL_SIGNATURE_HEADER = "x-apifuse-stateful-signature";
3
+ export const STATEFUL_TIMESTAMP_HEADER = "x-apifuse-stateful-timestamp";
4
+ export const STATEFUL_NONCE_HEADER = "x-apifuse-stateful-nonce";
5
+ export function signStatefulRequestBody(input) {
6
+ return `v1=${createHmac("sha256", input.secret)
7
+ .update(`v1:${input.method.toUpperCase()}:${input.path}:${input.timestamp}:${input.nonce}.${input.rawBody}`)
8
+ .digest("hex")}`;
9
+ }
10
+ export function verifyStatefulRequestSignature(input) {
11
+ return safeEqualAscii(input.signature, signStatefulRequestBody(input));
12
+ }
13
+ export function statefulSignedHeaders(input) {
14
+ const nonce = input.nonce ?? randomUUID();
15
+ return {
16
+ [STATEFUL_SIGNATURE_HEADER]: signStatefulRequestBody({ ...input, nonce }),
17
+ [STATEFUL_TIMESTAMP_HEADER]: input.timestamp,
18
+ [STATEFUL_NONCE_HEADER]: nonce,
19
+ };
20
+ }
21
+ function safeEqualAscii(actual, expected) {
22
+ const actualBytes = Buffer.from(actual);
23
+ const expectedBytes = Buffer.from(expected);
24
+ if (actualBytes.byteLength !== expectedBytes.byteLength)
25
+ return false;
26
+ return timingSafeEqual(actualBytes, expectedBytes);
27
+ }
@@ -1,4 +1,9 @@
1
- import type { StealthProfile } from "../types.js";
2
- export declare function generateLayer2Headers(profile: StealthProfile): Record<string, string>;
3
- export declare function getStealthProfile(name: string): StealthProfile;
4
- export declare function listStealthProfiles(): string[];
1
+ import type { StealthProfile, StealthProfileDescriptor, StealthProfileSelection } from "../types.js";
2
+ export declare const DEFAULT_STEALTH_BROWSER: "chrome";
3
+ export declare const DEFAULT_STEALTH_OS: "macos";
4
+ /** Internal detector used to keep version-pinned string failures actionable. */
5
+ export declare function getVersionPinnedStealthReplacement(name: string): string | undefined;
6
+ /** Resolve omitted axes and validate that the resulting pair is supported. */
7
+ export declare function resolveStealthProfileSelection(selection: StealthProfileSelection | undefined, base?: StealthProfileDescriptor): StealthProfileDescriptor;
8
+ export declare function getStealthProfile(selection?: StealthProfileSelection): StealthProfile;
9
+ export declare function listStealthProfiles(): StealthProfileDescriptor[];
@@ -1,49 +1,13 @@
1
+ import { createRequire } from "node:module";
1
2
  import { SDKError } from "../errors.js";
2
- const CHROMIUM_HEADER_ORDER = [
3
- ":method",
4
- ":authority",
5
- ":scheme",
6
- ":path",
7
- "user-agent",
8
- "accept",
9
- "accept-encoding",
10
- "accept-language",
11
- "cache-control",
12
- "pragma",
13
- "cookie",
14
- "sec-ch-ua",
15
- "sec-ch-ua-mobile",
16
- "sec-ch-ua-platform",
17
- ];
18
- const FIREFOX_HEADER_ORDER = [
19
- ":method",
20
- ":path",
21
- ":authority",
22
- ":scheme",
23
- "user-agent",
24
- "accept",
25
- "accept-language",
26
- "accept-encoding",
27
- "referer",
28
- "cookie",
29
- "upgrade-insecure-requests",
30
- "sec-fetch-dest",
31
- "sec-fetch-mode",
32
- "sec-fetch-site",
33
- "sec-fetch-user",
34
- ];
35
- const SAFARI_HEADER_ORDER = [
36
- ":method",
37
- ":scheme",
38
- ":path",
39
- ":authority",
40
- "accept",
41
- "user-agent",
42
- "accept-language",
43
- "accept-encoding",
44
- "cookie",
45
- "upgrade-insecure-requests",
46
- ];
3
+ const requireModule = createRequire(import.meta.url);
4
+ let wreqProfileApi;
5
+ function getWreqProfileApi() {
6
+ wreqProfileApi ??= requireModule("wreq-js");
7
+ return wreqProfileApi;
8
+ }
9
+ export const DEFAULT_STEALTH_BROWSER = "chrome";
10
+ export const DEFAULT_STEALTH_OS = "macos";
47
11
  const CHROMIUM_H2_SETTINGS = {
48
12
  HEADER_TABLE_SIZE: 65536,
49
13
  ENABLE_PUSH: 0,
@@ -57,7 +21,7 @@ const FIREFOX_H2_SETTINGS = {
57
21
  MAX_HEADER_LIST_SIZE: 65536,
58
22
  };
59
23
  const SAFARI_H2_SETTINGS = {
60
- HEADER_TABLE_SIZE: 4096,
24
+ // Safari 17 also sends a connection-level WINDOW_UPDATE increment of 10485760.
61
25
  ENABLE_PUSH: 0,
62
26
  INITIAL_WINDOW_SIZE: 4194304,
63
27
  MAX_CONCURRENT_STREAMS: 100,
@@ -65,186 +29,171 @@ const SAFARI_H2_SETTINGS = {
65
29
  const CHROMIUM_JA3 = "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513-65037,29-23-24,0";
66
30
  const FIREFOX_JA3 = "771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-28-27-43-45-51,29-23-24-25,0";
67
31
  const SAFARI_JA3 = "771,4865-4866-4867-49196-49195-52393-49200-49199-49188-49192-159-158-107-103-57-51-157-156-61-60-53-47-255,0-23-65281-10-11-16-5-13-18-51-45-43-27,29-23-24-25,0";
68
- function createProfile(name, definition) {
69
- return {
70
- name,
71
- platform: definition.platform,
72
- version: definition.version,
73
- userAgent: definition.userAgent,
74
- tlsClientIdentifier: definition.tlsClientIdentifier,
75
- ja3: definition.ja3,
76
- ja4: definition.ja4,
77
- h2Settings: definition.h2Settings ? { ...definition.h2Settings } : undefined,
78
- headerOrder: definition.headerOrder ? [...definition.headerOrder] : undefined,
79
- };
32
+ const SUPPORTED_STEALTH_PROFILES = [
33
+ { browser: "chrome", os: "windows" },
34
+ { browser: "chrome", os: "macos" },
35
+ { browser: "chrome", os: "linux" },
36
+ { browser: "firefox", os: "windows" },
37
+ { browser: "firefox", os: "macos" },
38
+ { browser: "firefox", os: "linux" },
39
+ { browser: "safari", os: "macos" },
40
+ { browser: "safari", os: "ios" },
41
+ ];
42
+ const DESKTOP_OSES = new Set(["windows", "macos", "linux"]);
43
+ function structuredReplacement(browser, os) {
44
+ return `stealth: { browser: "${browser}", os: "${os}" }`;
80
45
  }
81
- function extractBrowserMajorVersion(profile) {
82
- const chromeVersion = profile.userAgent.match(/Chrome\/(\d+)/)?.[1];
83
- if (chromeVersion) {
84
- return chromeVersion;
46
+ /** Internal detector used to keep version-pinned string failures actionable. */
47
+ export function getVersionPinnedStealthReplacement(name) {
48
+ if (/^(?:chrome|chromium|edge)[-_]\d/i.test(name)) {
49
+ return structuredReplacement("chrome", DEFAULT_STEALTH_OS);
85
50
  }
86
- const identifierVersion = profile.tlsClientIdentifier?.match(/(\d+)(?!.*\d)/)?.[1];
87
- if (identifierVersion) {
88
- return identifierVersion;
51
+ if (/^firefox[-_]\d/i.test(name)) {
52
+ return structuredReplacement("firefox", DEFAULT_STEALTH_OS);
89
53
  }
90
- return profile.version.split(".")[0] ?? profile.version;
54
+ if (/^(?:ios[-_]safari|safari[-_](?:ios|ipad))[-_]\d/i.test(name)) {
55
+ return structuredReplacement("safari", "ios");
56
+ }
57
+ if (/^safari[-_]\d/i.test(name)) {
58
+ return structuredReplacement("safari", DEFAULT_STEALTH_OS);
59
+ }
60
+ return undefined;
61
+ }
62
+ function rejectStringSelection(name) {
63
+ const replacement = getVersionPinnedStealthReplacement(name);
64
+ if (replacement) {
65
+ throw new SDKError(`Stealth profile "${name}" pins a browser version and is not supported. Use ${replacement}.`, { code: "STEALTH_VERSION_PIN_UNSUPPORTED" });
66
+ }
67
+ throw new SDKError(`Stealth profile names are no longer supported: "${name}". Use structured browser/os options.`, { code: "STEALTH_PROFILE_NAME_UNSUPPORTED" });
91
68
  }
92
- function toPlatformHeaderValue(platform) {
93
- switch (platform) {
94
- case "macos":
95
- return '"macOS"';
96
- case "windows":
97
- return '"Windows"';
98
- case "linux":
99
- return '"Linux"';
100
- case "android":
101
- return '"Android"';
102
- case "ios":
103
- return '"iOS"';
69
+ function assertSupportedDescriptor(browser, os) {
70
+ const supported = (browser === "chrome" && DESKTOP_OSES.has(os)) ||
71
+ (browser === "firefox" && DESKTOP_OSES.has(os)) ||
72
+ (browser === "safari" && (os === "macos" || os === "ios"));
73
+ if (!supported) {
74
+ throw new SDKError(`Unsupported stealth browser/OS combination: ${browser}/${os}. ` +
75
+ "Chrome and Firefox support windows, macos, and linux; Safari supports macos and ios.", { code: "STEALTH_PROFILE_UNAVAILABLE" });
104
76
  }
105
77
  }
106
- export function generateLayer2Headers(profile) {
107
- const headers = {
108
- "Accept-Language": "ko-KR,ko;q=0.9,en-US;q=0.8",
78
+ /** Resolve omitted axes and validate that the resulting pair is supported. */
79
+ export function resolveStealthProfileSelection(selection, base) {
80
+ if (typeof selection === "string")
81
+ rejectStringSelection(selection);
82
+ if (selection !== undefined && (typeof selection !== "object" || selection === null)) {
83
+ throw new SDKError("Stealth profile selection must use structured browser/os options.");
84
+ }
85
+ const unsafeSelection = selection;
86
+ if (unsafeSelection && "profile" in unsafeSelection) {
87
+ if (typeof unsafeSelection.profile === "string")
88
+ rejectStringSelection(unsafeSelection.profile);
89
+ throw new SDKError("stealth.profile is no longer supported. Use stealth.browser and stealth.os.", { code: "STEALTH_PROFILE_NAME_UNSUPPORTED" });
90
+ }
91
+ const browser = unsafeSelection?.browser ?? base?.browser ?? DEFAULT_STEALTH_BROWSER;
92
+ if (browser !== "chrome" && browser !== "firefox" && browser !== "safari") {
93
+ throw new SDKError(`Unsupported stealth browser: ${String(browser)}`);
94
+ }
95
+ const browserChanged = base !== undefined && unsafeSelection?.browser !== undefined && browser !== base.browser;
96
+ const os = unsafeSelection?.os ?? (browserChanged ? DEFAULT_STEALTH_OS : base?.os) ?? DEFAULT_STEALTH_OS;
97
+ if (os !== "windows" && os !== "macos" && os !== "linux" && os !== "ios") {
98
+ throw new SDKError(`Unsupported stealth OS: ${String(os)}`);
99
+ }
100
+ assertSupportedDescriptor(browser, os);
101
+ return { browser, os };
102
+ }
103
+ /** Resolve the newest Chromium build exposed by the exactly pinned wreq-js package. */
104
+ function resolveLatestChromiumProfile() {
105
+ const { getProfiles } = getWreqProfileApi();
106
+ let newest;
107
+ for (const name of getProfiles()) {
108
+ const match = /^chrome_(\d+)$/.exec(name);
109
+ if (!match)
110
+ continue;
111
+ const version = Number(match[1]);
112
+ if (!newest || version > newest.version)
113
+ newest = { name, version };
114
+ }
115
+ if (!newest) {
116
+ throw new SDKError("wreq-js exposes no chrome_<version> emulation profile.", {
117
+ code: "STEALTH_PROFILE_UNAVAILABLE",
118
+ });
119
+ }
120
+ return { wreqName: newest.name, version: `${newest.version}.0.0.0` };
121
+ }
122
+ /** Read the identity wreq itself emits so the accessor and transport cannot diverge. */
123
+ function emulationUserAgent(profile, os) {
124
+ for (const [name, value] of getWreqProfileApi().getEmulationHeaders(profile, os)) {
125
+ if (String(name).toLowerCase() === "user-agent")
126
+ return String(value);
127
+ }
128
+ throw new SDKError(`wreq-js profile ${profile} exposes no user-agent header.`, {
129
+ code: "STEALTH_PROFILE_UNAVAILABLE",
130
+ });
131
+ }
132
+ function createProfile(descriptor, definition) {
133
+ return {
134
+ ...descriptor,
135
+ ...definition,
136
+ h2Settings: definition.h2Settings ? { ...definition.h2Settings } : undefined,
109
137
  };
110
- const identifier = profile.tlsClientIdentifier?.toLowerCase() ?? "";
111
- const majorVersion = extractBrowserMajorVersion(profile);
112
- if (identifier.startsWith("chrome_") || identifier.startsWith("edge_")) {
113
- const isEdge = identifier.startsWith("edge_") || /\bEdg\//.test(profile.userAgent);
114
- headers["Sec-Ch-Ua"] = isEdge
115
- ? `"Chromium";v="${majorVersion}", "Microsoft Edge";v="${majorVersion}", "Not)A;Brand";v="99"`
116
- : `"Chromium";v="${majorVersion}", "Google Chrome";v="${majorVersion}", "Not)A;Brand";v="99"`;
117
- headers["Sec-Ch-Ua-Platform"] = toPlatformHeaderValue(profile.platform);
118
- headers["Sec-Ch-Ua-Mobile"] =
119
- profile.platform === "android" || profile.platform === "ios" ? "?1" : "?0";
138
+ }
139
+ function profileKey(descriptor) {
140
+ return `${descriptor.browser}:${descriptor.os}`;
141
+ }
142
+ let stealthProfileCatalog;
143
+ function getStealthProfileCatalog() {
144
+ if (stealthProfileCatalog)
145
+ return stealthProfileCatalog;
146
+ const latestChrome = resolveLatestChromiumProfile();
147
+ const definitions = {
148
+ chrome: {
149
+ version: latestChrome.version,
150
+ tlsClientIdentifier: latestChrome.wreqName,
151
+ ja3: CHROMIUM_JA3,
152
+ h2Settings: CHROMIUM_H2_SETTINGS,
153
+ },
154
+ firefox: {
155
+ version: "147.0",
156
+ tlsClientIdentifier: "firefox_147",
157
+ ja3: FIREFOX_JA3,
158
+ h2Settings: FIREFOX_H2_SETTINGS,
159
+ },
160
+ safari: {
161
+ version: "17.0",
162
+ tlsClientIdentifier: "safari_17.0",
163
+ ja3: SAFARI_JA3,
164
+ h2Settings: SAFARI_H2_SETTINGS,
165
+ },
166
+ };
167
+ stealthProfileCatalog = new Map();
168
+ for (const descriptor of SUPPORTED_STEALTH_PROFILES) {
169
+ const isMobileSafari = descriptor.browser === "safari" && descriptor.os === "ios";
170
+ const definition = isMobileSafari
171
+ ? {
172
+ version: "26.0",
173
+ tlsClientIdentifier: "safari_ios_26",
174
+ ja3: SAFARI_JA3,
175
+ h2Settings: SAFARI_H2_SETTINGS,
176
+ }
177
+ : definitions[descriptor.browser];
178
+ const wreqName = definition.tlsClientIdentifier;
179
+ stealthProfileCatalog.set(profileKey(descriptor), createProfile(descriptor, {
180
+ ...definition,
181
+ userAgent: emulationUserAgent(wreqName, descriptor.os),
182
+ }));
120
183
  }
121
- return headers;
184
+ return stealthProfileCatalog;
122
185
  }
123
- const STEALTH_PROFILE_ALIASES = {
124
- "chrome-desktop": "chrome-146",
125
- };
126
- const STEALTH_PROFILES = {
127
- "chrome-146": createProfile("chrome-146", {
128
- platform: "macos",
129
- version: "146.0.0.0",
130
- userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36",
131
- tlsClientIdentifier: "chrome_146",
132
- ja3: CHROMIUM_JA3,
133
- h2Settings: CHROMIUM_H2_SETTINGS,
134
- headerOrder: CHROMIUM_HEADER_ORDER,
135
- }),
136
- "firefox-147": createProfile("firefox-147", {
137
- platform: "macos",
138
- version: "147.0",
139
- userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:147.0) Gecko/20100101 Firefox/147.0",
140
- tlsClientIdentifier: "firefox_147",
141
- ja3: FIREFOX_JA3,
142
- h2Settings: FIREFOX_H2_SETTINGS,
143
- headerOrder: FIREFOX_HEADER_ORDER,
144
- }),
145
- "firefox-135": createProfile("firefox-135", {
146
- platform: "macos",
147
- version: "135.0",
148
- userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0",
149
- tlsClientIdentifier: "firefox_135",
150
- ja3: FIREFOX_JA3,
151
- h2Settings: FIREFOX_H2_SETTINGS,
152
- headerOrder: FIREFOX_HEADER_ORDER,
153
- }),
154
- "firefox-133": createProfile("firefox-133", {
155
- platform: "macos",
156
- version: "133.0",
157
- userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:133.0) Gecko/20100101 Firefox/133.0",
158
- tlsClientIdentifier: "firefox_133",
159
- ja3: FIREFOX_JA3,
160
- h2Settings: FIREFOX_H2_SETTINGS,
161
- headerOrder: FIREFOX_HEADER_ORDER,
162
- }),
163
- "firefox-132": createProfile("firefox-132", {
164
- platform: "macos",
165
- version: "132.0",
166
- userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:132.0) Gecko/20100101 Firefox/132.0",
167
- tlsClientIdentifier: "firefox_132",
168
- ja3: FIREFOX_JA3,
169
- h2Settings: FIREFOX_H2_SETTINGS,
170
- headerOrder: FIREFOX_HEADER_ORDER,
171
- }),
172
- "safari-16": createProfile("safari-16", {
173
- platform: "macos",
174
- version: "16.0",
175
- userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15",
176
- tlsClientIdentifier: "safari_16_0",
177
- ja3: SAFARI_JA3,
178
- h2Settings: SAFARI_H2_SETTINGS,
179
- headerOrder: SAFARI_HEADER_ORDER,
180
- }),
181
- "safari-15": createProfile("safari-15", {
182
- platform: "macos",
183
- version: "15.6.1",
184
- userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.1 Safari/605.1.15",
185
- tlsClientIdentifier: "safari_15_6_1",
186
- ja3: SAFARI_JA3,
187
- h2Settings: SAFARI_H2_SETTINGS,
188
- headerOrder: SAFARI_HEADER_ORDER,
189
- }),
190
- "ios-safari-26": createProfile("ios-safari-26", {
191
- platform: "ios",
192
- version: "26.0",
193
- userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 26_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",
194
- tlsClientIdentifier: "safari_ios_26_0",
195
- ja3: SAFARI_JA3,
196
- h2Settings: SAFARI_H2_SETTINGS,
197
- headerOrder: SAFARI_HEADER_ORDER,
198
- }),
199
- "ios-safari-18": createProfile("ios-safari-18", {
200
- platform: "ios",
201
- version: "18.0",
202
- userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1",
203
- tlsClientIdentifier: "safari_ios_18_0",
204
- ja3: SAFARI_JA3,
205
- h2Settings: SAFARI_H2_SETTINGS,
206
- headerOrder: SAFARI_HEADER_ORDER,
207
- }),
208
- "ios-safari-17": createProfile("ios-safari-17", {
209
- platform: "ios",
210
- version: "17.0",
211
- userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1",
212
- tlsClientIdentifier: "safari_ios_17_0",
213
- ja3: SAFARI_JA3,
214
- h2Settings: SAFARI_H2_SETTINGS,
215
- headerOrder: SAFARI_HEADER_ORDER,
216
- }),
217
- "generic-desktop": createProfile("generic-desktop", {
218
- platform: "macos",
219
- version: "146.0.0.0",
220
- userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36",
221
- tlsClientIdentifier: "chrome_146",
222
- ja3: CHROMIUM_JA3,
223
- h2Settings: CHROMIUM_H2_SETTINGS,
224
- headerOrder: CHROMIUM_HEADER_ORDER,
225
- }),
226
- "generic-mobile": createProfile("generic-mobile", {
227
- platform: "ios",
228
- version: "26.0",
229
- userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 26_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",
230
- tlsClientIdentifier: "safari_ios_26_0",
231
- ja3: SAFARI_JA3,
232
- h2Settings: SAFARI_H2_SETTINGS,
233
- headerOrder: SAFARI_HEADER_ORDER,
234
- }),
235
- };
236
- export function getStealthProfile(name) {
237
- const canonicalName = STEALTH_PROFILE_ALIASES[name] ?? name;
238
- const profile = STEALTH_PROFILES[canonicalName];
186
+ export function getStealthProfile(selection = {}) {
187
+ const descriptor = resolveStealthProfileSelection(selection);
188
+ const profile = getStealthProfileCatalog().get(profileKey(descriptor));
239
189
  if (!profile) {
240
- throw new SDKError(`Unknown stealth profile: ${name}`);
190
+ throw new SDKError(`Unknown stealth profile: ${descriptor.browser}/${descriptor.os}`);
241
191
  }
242
192
  return {
243
193
  ...profile,
244
194
  h2Settings: profile.h2Settings ? { ...profile.h2Settings } : undefined,
245
- headerOrder: profile.headerOrder ? [...profile.headerOrder] : undefined,
246
195
  };
247
196
  }
248
197
  export function listStealthProfiles() {
249
- return [...Object.keys(STEALTH_PROFILES), ...Object.keys(STEALTH_PROFILE_ALIASES)];
198
+ return SUPPORTED_STEALTH_PROFILES.map((profile) => ({ ...profile }));
250
199
  }
@@ -0,0 +1,74 @@
1
+ import { type JsonValue } from "./contract-json.js";
2
+ import type { HttpStreamResponse } from "./types.js";
3
+ export declare const STREAM_PREVIEW_BYTES = 4096;
4
+ export declare const STREAM_FINALIZE_TIMEOUT_MS = 30000;
5
+ declare const STREAM_EVIDENCE_HEADER_NAMES: readonly ["content-disposition", "content-length", "content-type"];
6
+ type StreamEvidenceHeaderName = (typeof STREAM_EVIDENCE_HEADER_NAMES)[number];
7
+ export type StreamEvidenceHeaders = Partial<Record<StreamEvidenceHeaderName, string>>;
8
+ export interface StreamEvidenceRequest {
9
+ ordinal: number;
10
+ method: string;
11
+ path: string;
12
+ }
13
+ declare const STREAM_EVIDENCE_REDACTION_REASONS: readonly ["high-entropy-token", "malformed-json", "pem-private-key", "sanitized-preview-too-large", "sanitizer-output-invalid", "sensitive-delimited-column", "textual-xml", "truncated-form", "truncated-json", "undecodable-text"];
14
+ export type StreamEvidenceRedactionReason = (typeof STREAM_EVIDENCE_REDACTION_REASONS)[number];
15
+ export interface StreamEvidenceRecord {
16
+ __apifuse_stream__: true;
17
+ status: number;
18
+ ok: boolean;
19
+ headers: StreamEvidenceHeaders;
20
+ body_sha256: string;
21
+ body_bytes: number;
22
+ body_preview_base64: string;
23
+ request?: StreamEvidenceRequest;
24
+ preview_sanitized?: true;
25
+ preview_redaction_reason?: StreamEvidenceRedactionReason;
26
+ }
27
+ export type StreamEvidenceReplayResponse = HttpStreamResponse & {
28
+ evidence_only: true;
29
+ body_sha256: string;
30
+ body_bytes: number;
31
+ preview_sanitized?: true;
32
+ preview_redaction_reason?: StreamEvidenceRedactionReason;
33
+ };
34
+ export interface StreamEvidenceCapture {
35
+ response: HttpStreamResponse;
36
+ getEvidence(): Promise<StreamEvidenceRecord>;
37
+ }
38
+ export type StreamCaptureGroupItem = {
39
+ kind: "stream";
40
+ evidence: StreamEvidenceRecord;
41
+ } | {
42
+ kind: "response";
43
+ value: JsonValue;
44
+ };
45
+ export interface StreamCaptureGroup {
46
+ items: StreamCaptureGroupItem[];
47
+ }
48
+ export interface StreamCaptureEnvelope {
49
+ __apifuse_capture__: true;
50
+ items: StreamCaptureGroupItem[];
51
+ }
52
+ export type StreamEvidenceCaptureOptions = {
53
+ requestUrl: string;
54
+ sanitizeFixture?: (value: JsonValue) => JsonValue;
55
+ request?: StreamEvidenceRequest;
56
+ finalizeTimeoutMs?: number;
57
+ };
58
+ export declare function parseStreamEvidenceRecord(value: unknown): StreamEvidenceRecord;
59
+ export declare function isStreamEvidenceRecord(value: unknown): value is StreamEvidenceRecord;
60
+ export declare function findStreamEvidenceRecord(value: unknown): StreamEvidenceRecord | undefined;
61
+ /**
62
+ * Selects every stream captured by the latest recording invocation, in stream call order.
63
+ * Evidence without request ordinals uses the legacy latest-record-only behavior.
64
+ */
65
+ export declare function findStreamEvidenceRecords(value: unknown): StreamEvidenceRecord[];
66
+ /** Returns a tagged latest mixed response group used by evidence-only snapshot replay. */
67
+ export declare function findStreamCaptureGroup(value: unknown): StreamCaptureGroup | undefined;
68
+ /** Creates a discriminated invocation envelope so ordinary arrays cannot mimic capture timelines. */
69
+ export declare function createStreamCaptureEnvelope(items: StreamCaptureGroupItem[]): StreamCaptureEnvelope;
70
+ export declare function isStreamEvidenceReplayResponse(response: HttpStreamResponse): response is StreamEvidenceReplayResponse;
71
+ export declare function captureStreamEvidence(response: HttpStreamResponse, options: StreamEvidenceCaptureOptions): StreamEvidenceCapture;
72
+ export declare function replayStreamEvidence(evidence: StreamEvidenceRecord): StreamEvidenceReplayResponse;
73
+ export declare function hasStreamEvidenceMarker(value: unknown): boolean;
74
+ export {};