@workflow/core 5.0.0-beta.4 → 5.0.0-beta.41

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 (322) hide show
  1. package/dist/attribute-changes.d.ts +7 -0
  2. package/dist/attribute-changes.d.ts.map +1 -0
  3. package/dist/attribute-changes.js +25 -0
  4. package/dist/capabilities.d.ts +33 -1
  5. package/dist/capabilities.d.ts.map +1 -1
  6. package/dist/capabilities.js +71 -4
  7. package/dist/capture-stack.d.ts +16 -0
  8. package/dist/capture-stack.d.ts.map +1 -0
  9. package/dist/capture-stack.js +21 -0
  10. package/dist/class-serialization.d.ts +32 -0
  11. package/dist/class-serialization.d.ts.map +1 -1
  12. package/dist/class-serialization.js +37 -1
  13. package/dist/classify-error.d.ts +26 -3
  14. package/dist/classify-error.d.ts.map +1 -1
  15. package/dist/classify-error.js +109 -6
  16. package/dist/context-errors.d.ts +27 -0
  17. package/dist/context-errors.d.ts.map +1 -0
  18. package/dist/context-errors.js +101 -0
  19. package/dist/context-violation-error.d.ts +97 -0
  20. package/dist/context-violation-error.d.ts.map +1 -0
  21. package/dist/context-violation-error.js +149 -0
  22. package/dist/create-hook.d.ts +62 -4
  23. package/dist/create-hook.d.ts.map +1 -1
  24. package/dist/create-hook.js +4 -3
  25. package/dist/define-hook.d.ts.map +1 -1
  26. package/dist/define-hook.js +20 -5
  27. package/dist/describe-error.d.ts +70 -0
  28. package/dist/describe-error.d.ts.map +1 -0
  29. package/dist/describe-error.js +189 -0
  30. package/dist/encryption.d.ts +37 -3
  31. package/dist/encryption.d.ts.map +1 -1
  32. package/dist/encryption.js +97 -31
  33. package/dist/events-consumer.d.ts +147 -1
  34. package/dist/events-consumer.d.ts.map +1 -1
  35. package/dist/events-consumer.js +444 -43
  36. package/dist/flushable-stream.d.ts +65 -10
  37. package/dist/flushable-stream.d.ts.map +1 -1
  38. package/dist/flushable-stream.js +131 -18
  39. package/dist/global.d.ts +37 -1
  40. package/dist/global.d.ts.map +1 -1
  41. package/dist/global.js +21 -3
  42. package/dist/index.d.ts +1 -0
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +2 -1
  45. package/dist/log-format.d.ts +25 -0
  46. package/dist/log-format.d.ts.map +1 -0
  47. package/dist/log-format.js +250 -0
  48. package/dist/logger.d.ts +29 -30
  49. package/dist/logger.d.ts.map +1 -1
  50. package/dist/logger.js +82 -32
  51. package/dist/private.d.ts +246 -8
  52. package/dist/private.d.ts.map +1 -1
  53. package/dist/private.js +345 -9
  54. package/dist/replay-payload-cache.d.ts +68 -0
  55. package/dist/replay-payload-cache.d.ts.map +1 -0
  56. package/dist/replay-payload-cache.js +160 -0
  57. package/dist/runtime/compute-instance.d.ts +12 -0
  58. package/dist/runtime/compute-instance.d.ts.map +1 -0
  59. package/dist/runtime/compute-instance.js +13 -0
  60. package/dist/runtime/constants.d.ts +251 -0
  61. package/dist/runtime/constants.d.ts.map +1 -1
  62. package/dist/runtime/constants.js +425 -16
  63. package/dist/runtime/count-step-started-events.d.ts +52 -0
  64. package/dist/runtime/count-step-started-events.d.ts.map +1 -0
  65. package/dist/runtime/count-step-started-events.js +72 -0
  66. package/dist/runtime/deployment-guard.d.ts +99 -0
  67. package/dist/runtime/deployment-guard.d.ts.map +1 -0
  68. package/dist/runtime/deployment-guard.js +154 -0
  69. package/dist/runtime/get-port-lazy.d.ts +25 -0
  70. package/dist/runtime/get-port-lazy.d.ts.map +1 -0
  71. package/dist/runtime/get-port-lazy.js +92 -0
  72. package/dist/runtime/get-world-lazy.d.ts +23 -0
  73. package/dist/runtime/get-world-lazy.d.ts.map +1 -0
  74. package/dist/runtime/get-world-lazy.js +46 -0
  75. package/dist/runtime/helpers.d.ts +327 -10
  76. package/dist/runtime/helpers.d.ts.map +1 -1
  77. package/dist/runtime/helpers.js +586 -40
  78. package/dist/runtime/quickjs-assets.generated.d.ts +14 -0
  79. package/dist/runtime/quickjs-assets.generated.d.ts.map +1 -0
  80. package/dist/runtime/quickjs-assets.generated.js +30 -0
  81. package/dist/runtime/quickjs-entrypoint.d.ts +124 -0
  82. package/dist/runtime/quickjs-entrypoint.d.ts.map +1 -0
  83. package/dist/runtime/quickjs-entrypoint.js +1437 -0
  84. package/dist/runtime/quickjs-runtime.d.ts +228 -0
  85. package/dist/runtime/quickjs-runtime.d.ts.map +1 -0
  86. package/dist/runtime/quickjs-runtime.js +2372 -0
  87. package/dist/runtime/quickjs-serde.d.ts +107 -0
  88. package/dist/runtime/quickjs-serde.d.ts.map +1 -0
  89. package/dist/runtime/quickjs-serde.js +2098 -0
  90. package/dist/runtime/replay-budget.d.ts +89 -0
  91. package/dist/runtime/replay-budget.d.ts.map +1 -0
  92. package/dist/runtime/replay-budget.js +139 -0
  93. package/dist/runtime/replay-recovery-reporter.d.ts +36 -0
  94. package/dist/runtime/replay-recovery-reporter.d.ts.map +1 -0
  95. package/dist/runtime/replay-recovery-reporter.js +64 -0
  96. package/dist/runtime/resume-hook.d.ts +27 -4
  97. package/dist/runtime/resume-hook.d.ts.map +1 -1
  98. package/dist/runtime/resume-hook.js +452 -76
  99. package/dist/runtime/run-id-time.d.ts +19 -0
  100. package/dist/runtime/run-id-time.d.ts.map +1 -0
  101. package/dist/runtime/run-id-time.js +42 -0
  102. package/dist/runtime/run.d.ts +8 -2
  103. package/dist/runtime/run.d.ts.map +1 -1
  104. package/dist/runtime/run.js +62 -15
  105. package/dist/runtime/runs.d.ts +54 -3
  106. package/dist/runtime/runs.d.ts.map +1 -1
  107. package/dist/runtime/runs.js +119 -13
  108. package/dist/runtime/start.d.ts +70 -1
  109. package/dist/runtime/start.d.ts.map +1 -1
  110. package/dist/runtime/start.js +313 -60
  111. package/dist/runtime/step-executor.d.ts +177 -0
  112. package/dist/runtime/step-executor.d.ts.map +1 -0
  113. package/dist/runtime/step-executor.js +946 -0
  114. package/dist/runtime/step-latency.d.ts +197 -0
  115. package/dist/runtime/step-latency.d.ts.map +1 -0
  116. package/dist/runtime/step-latency.js +207 -0
  117. package/dist/runtime/step-ownership.d.ts +72 -0
  118. package/dist/runtime/step-ownership.d.ts.map +1 -0
  119. package/dist/runtime/step-ownership.js +114 -0
  120. package/dist/runtime/step-single-flight.d.ts +12 -0
  121. package/dist/runtime/step-single-flight.d.ts.map +1 -0
  122. package/dist/runtime/step-single-flight.js +69 -0
  123. package/dist/runtime/suspension-handler.d.ts +109 -7
  124. package/dist/runtime/suspension-handler.d.ts.map +1 -1
  125. package/dist/runtime/suspension-handler.js +486 -140
  126. package/dist/runtime/vm-mode.d.ts +44 -0
  127. package/dist/runtime/vm-mode.d.ts.map +1 -0
  128. package/dist/runtime/vm-mode.js +62 -0
  129. package/dist/runtime/vm-serde-bundle.generated.d.ts +14 -0
  130. package/dist/runtime/vm-serde-bundle.generated.d.ts.map +1 -0
  131. package/dist/runtime/vm-serde-bundle.generated.js +16 -0
  132. package/dist/runtime/wait-continuation.d.ts +84 -0
  133. package/dist/runtime/wait-continuation.d.ts.map +1 -0
  134. package/dist/runtime/wait-continuation.js +105 -0
  135. package/dist/runtime/wait-until.d.ts +18 -0
  136. package/dist/runtime/wait-until.d.ts.map +1 -0
  137. package/dist/runtime/wait-until.js +42 -0
  138. package/dist/runtime/world-compatibility.d.ts +20 -0
  139. package/dist/runtime/world-compatibility.d.ts.map +1 -0
  140. package/dist/runtime/world-compatibility.js +32 -0
  141. package/dist/runtime/world-init.d.ts +50 -0
  142. package/dist/runtime/world-init.d.ts.map +1 -0
  143. package/dist/runtime/world-init.js +50 -0
  144. package/dist/runtime/world.d.ts +14 -2
  145. package/dist/runtime/world.d.ts.map +1 -1
  146. package/dist/runtime/world.js +101 -26
  147. package/dist/runtime.d.ts +17 -12
  148. package/dist/runtime.d.ts.map +1 -1
  149. package/dist/runtime.js +3135 -328
  150. package/dist/schemas.d.ts +1 -1
  151. package/dist/schemas.d.ts.map +1 -1
  152. package/dist/schemas.js +1 -1
  153. package/dist/sealed-box.d.ts +167 -0
  154. package/dist/sealed-box.d.ts.map +1 -0
  155. package/dist/sealed-box.js +571 -0
  156. package/dist/serialization/client.d.ts +17 -0
  157. package/dist/serialization/client.d.ts.map +1 -0
  158. package/dist/serialization/client.js +48 -0
  159. package/dist/serialization/codec-devalue-vm.d.ts +16 -0
  160. package/dist/serialization/codec-devalue-vm.d.ts.map +1 -0
  161. package/dist/serialization/codec-devalue-vm.js +148 -0
  162. package/dist/serialization/codec-devalue.d.ts +14 -0
  163. package/dist/serialization/codec-devalue.d.ts.map +1 -0
  164. package/dist/serialization/codec-devalue.js +105 -0
  165. package/dist/serialization/codec.d.ts +125 -0
  166. package/dist/serialization/codec.d.ts.map +1 -0
  167. package/dist/serialization/codec.js +17 -0
  168. package/dist/serialization/compression.d.ts +104 -0
  169. package/dist/serialization/compression.d.ts.map +1 -0
  170. package/dist/serialization/compression.js +260 -0
  171. package/dist/serialization/encryption.d.ts +134 -0
  172. package/dist/serialization/encryption.d.ts.map +1 -0
  173. package/dist/serialization/encryption.js +186 -0
  174. package/dist/serialization/errors.d.ts +34 -0
  175. package/dist/serialization/errors.d.ts.map +1 -0
  176. package/dist/serialization/errors.js +59 -0
  177. package/dist/serialization/format.d.ts +60 -0
  178. package/dist/serialization/format.d.ts.map +1 -0
  179. package/dist/serialization/format.js +97 -0
  180. package/dist/serialization/hardened.d.ts +155 -0
  181. package/dist/serialization/hardened.d.ts.map +1 -0
  182. package/dist/serialization/hardened.js +523 -0
  183. package/dist/serialization/index.d.ts +20 -0
  184. package/dist/serialization/index.d.ts.map +1 -0
  185. package/dist/serialization/index.js +22 -0
  186. package/dist/serialization/reducers/class-vm.d.ts +20 -0
  187. package/dist/serialization/reducers/class-vm.d.ts.map +1 -0
  188. package/dist/serialization/reducers/class-vm.js +77 -0
  189. package/dist/serialization/reducers/class.d.ts +11 -0
  190. package/dist/serialization/reducers/class.d.ts.map +1 -0
  191. package/dist/serialization/reducers/class.js +73 -0
  192. package/dist/serialization/reducers/common-vm.d.ts +15 -0
  193. package/dist/serialization/reducers/common-vm.d.ts.map +1 -0
  194. package/dist/serialization/reducers/common-vm.js +579 -0
  195. package/dist/serialization/reducers/common.d.ts +16 -0
  196. package/dist/serialization/reducers/common.d.ts.map +1 -0
  197. package/dist/serialization/reducers/common.js +478 -0
  198. package/dist/serialization/reducers/step-function-vm.d.ts +44 -0
  199. package/dist/serialization/reducers/step-function-vm.d.ts.map +1 -0
  200. package/dist/serialization/reducers/step-function-vm.js +97 -0
  201. package/dist/serialization/reducers/step-function.d.ts +35 -0
  202. package/dist/serialization/reducers/step-function.d.ts.map +1 -0
  203. package/dist/serialization/reducers/step-function.js +104 -0
  204. package/dist/serialization/step.d.ts +17 -0
  205. package/dist/serialization/step.d.ts.map +1 -0
  206. package/dist/serialization/step.js +48 -0
  207. package/dist/serialization/types.d.ts +273 -0
  208. package/dist/serialization/types.d.ts.map +1 -0
  209. package/dist/serialization/types.js +35 -0
  210. package/dist/serialization/workflow-vm.d.ts +29 -0
  211. package/dist/serialization/workflow-vm.d.ts.map +1 -0
  212. package/dist/serialization/workflow-vm.js +71 -0
  213. package/dist/serialization/workflow.d.ts +29 -0
  214. package/dist/serialization/workflow.d.ts.map +1 -0
  215. package/dist/serialization/workflow.js +54 -0
  216. package/dist/serialization-format.d.ts +60 -4
  217. package/dist/serialization-format.d.ts.map +1 -1
  218. package/dist/serialization-format.js +276 -56
  219. package/dist/serialization.d.ts +374 -221
  220. package/dist/serialization.d.ts.map +1 -1
  221. package/dist/serialization.js +2300 -783
  222. package/dist/set-attributes.d.ts +13 -0
  223. package/dist/set-attributes.d.ts.map +1 -0
  224. package/dist/set-attributes.js +60 -0
  225. package/dist/sleep.d.ts.map +1 -1
  226. package/dist/sleep.js +3 -2
  227. package/dist/source-map.d.ts +25 -0
  228. package/dist/source-map.d.ts.map +1 -1
  229. package/dist/source-map.js +148 -10
  230. package/dist/step/context-storage.d.ts +61 -2
  231. package/dist/step/context-storage.d.ts.map +1 -1
  232. package/dist/step/context-storage.js +7 -5
  233. package/dist/step/get-closure-vars.d.ts.map +1 -1
  234. package/dist/step/get-closure-vars.js +3 -2
  235. package/dist/step/get-step-metadata.d.ts.map +1 -1
  236. package/dist/step/get-step-metadata.js +3 -2
  237. package/dist/step/get-workflow-metadata.d.ts.map +1 -1
  238. package/dist/step/get-workflow-metadata.js +3 -2
  239. package/dist/step/writable-stream.d.ts.map +1 -1
  240. package/dist/step/writable-stream.js +71 -7
  241. package/dist/step.d.ts.map +1 -1
  242. package/dist/step.js +225 -29
  243. package/dist/symbols.d.ts +54 -0
  244. package/dist/symbols.d.ts.map +1 -1
  245. package/dist/symbols.js +55 -1
  246. package/dist/telemetry/semantic-conventions.d.ts +265 -2
  247. package/dist/telemetry/semantic-conventions.d.ts.map +1 -1
  248. package/dist/telemetry/semantic-conventions.js +190 -1
  249. package/dist/telemetry.d.ts +73 -0
  250. package/dist/telemetry.d.ts.map +1 -1
  251. package/dist/telemetry.js +153 -16
  252. package/dist/types.d.ts +6 -0
  253. package/dist/types.d.ts.map +1 -1
  254. package/dist/types.js +23 -1
  255. package/dist/util.d.ts +16 -6
  256. package/dist/util.d.ts.map +1 -1
  257. package/dist/util.js +25 -16
  258. package/dist/version.d.ts +1 -1
  259. package/dist/version.d.ts.map +1 -1
  260. package/dist/version.js +2 -2
  261. package/dist/vm/index.d.ts.map +1 -1
  262. package/dist/vm/index.js +85 -14
  263. package/dist/vm/script-cache.d.ts +28 -0
  264. package/dist/vm/script-cache.d.ts.map +1 -0
  265. package/dist/vm/script-cache.js +140 -0
  266. package/dist/workflow/abort-controller.d.ts +65 -0
  267. package/dist/workflow/abort-controller.d.ts.map +1 -0
  268. package/dist/workflow/abort-controller.js +312 -0
  269. package/dist/workflow/attribute-dispatcher.d.ts +6 -0
  270. package/dist/workflow/attribute-dispatcher.d.ts.map +1 -0
  271. package/dist/workflow/attribute-dispatcher.js +48 -0
  272. package/dist/workflow/create-hook.d.ts.map +1 -1
  273. package/dist/workflow/create-hook.js +25 -3
  274. package/dist/workflow/define-hook.d.ts +1 -1
  275. package/dist/workflow/define-hook.d.ts.map +1 -1
  276. package/dist/workflow/define-hook.js +8 -4
  277. package/dist/workflow/get-workflow-metadata.d.ts.map +1 -1
  278. package/dist/workflow/get-workflow-metadata.js +14 -3
  279. package/dist/workflow/hook.d.ts.map +1 -1
  280. package/dist/workflow/hook.js +302 -36
  281. package/dist/workflow/index.d.ts +1 -0
  282. package/dist/workflow/index.d.ts.map +1 -1
  283. package/dist/workflow/index.js +5 -3
  284. package/dist/workflow/set-attributes.d.ts +68 -0
  285. package/dist/workflow/set-attributes.d.ts.map +1 -0
  286. package/dist/workflow/set-attributes.js +60 -0
  287. package/dist/workflow/sleep.d.ts.map +1 -1
  288. package/dist/workflow/sleep.js +57 -8
  289. package/dist/workflow/world-init-stub.d.ts +15 -0
  290. package/dist/workflow/world-init-stub.d.ts.map +1 -0
  291. package/dist/workflow/world-init-stub.js +15 -0
  292. package/dist/workflow.d.ts +79 -3
  293. package/dist/workflow.d.ts.map +1 -1
  294. package/dist/workflow.js +831 -553
  295. package/docs/api-reference/create-hook.mdx +79 -0
  296. package/docs/api-reference/create-webhook.mdx +1 -0
  297. package/docs/api-reference/define-hook.mdx +26 -24
  298. package/docs/api-reference/fatal-error.mdx +29 -7
  299. package/docs/api-reference/fetch.mdx +8 -4
  300. package/docs/api-reference/index.mdx +3 -0
  301. package/docs/api-reference/set-attributes.mdx +61 -0
  302. package/docs/api-reference/sleep.mdx +1 -1
  303. package/docs/foundations/cancellation.mdx +459 -0
  304. package/docs/foundations/errors-and-retries.mdx +7 -3
  305. package/docs/foundations/hooks.mdx +29 -0
  306. package/docs/foundations/idempotency.mdx +243 -11
  307. package/docs/foundations/index.mdx +1 -23
  308. package/docs/foundations/meta.json +3 -1
  309. package/docs/foundations/serialization.mdx +77 -41
  310. package/docs/foundations/starting-workflows.mdx +79 -2
  311. package/docs/foundations/streaming.mdx +14 -23
  312. package/docs/foundations/versioning.mdx +263 -0
  313. package/docs/how-it-works/cancellation.mdx +287 -0
  314. package/docs/how-it-works/code-transform.mdx +21 -17
  315. package/docs/how-it-works/encryption.mdx +5 -5
  316. package/docs/how-it-works/event-sourcing.mdx +17 -9
  317. package/docs/how-it-works/framework-integrations.mdx +96 -337
  318. package/docs/how-it-works/meta.json +2 -1
  319. package/package.json +31 -13
  320. package/dist/runtime/step-handler.d.ts +0 -2
  321. package/dist/runtime/step-handler.d.ts.map +0 -1
  322. package/dist/runtime/step-handler.js +0 -678
@@ -0,0 +1,155 @@
1
+ /**
2
+ * Hardened introspection for serializing values that may originate inside a
3
+ * workflow VM (`node:vm`) sandbox realm.
4
+ *
5
+ * Serialization runs on the host, but the values it inspects were
6
+ * constructed by workflow code — so a naive dynamic operation like
7
+ * `value.toISOString()`, `Array.from(map)`, or `Object.prototype.toString`
8
+ * dispatches into the sandbox realm and executes workflow code (patched
9
+ * prototype methods, getters, proxy traps, `Symbol.toStringTag` accessors).
10
+ * That is a determinism hazard: serialization happens exactly once per
11
+ * payload (never again on replay), so any workflow-visible side effect it
12
+ * triggers exists only on the live execution path and diverges from replay.
13
+ *
14
+ * This module makes serialization side-effect free wherever the data allows
15
+ * it, and *observable* where it does not:
16
+ *
17
+ * - **Classification** uses engine-level brand checks (`node:util` `types`,
18
+ * internal-slot probes) instead of `instanceof` / `Object.prototype.toString`
19
+ * — immune to `Symbol.hasInstance`, `Symbol.toStringTag`, and reassigned
20
+ * globals.
21
+ * - **Extraction** goes through intrinsics captured at module load (host
22
+ * boot, before any workflow code runs). Internal slots are realm-agnostic,
23
+ * so host intrinsics read VM-realm objects without touching the sandbox's
24
+ * (patchable) prototypes.
25
+ * - **Property access** reads through descriptors, so plain data never
26
+ * invokes anything. Where workflow code *must* run because the data itself
27
+ * lives behind it — getters, proxies, custom `[WORKFLOW_SERIALIZE]`
28
+ * methods, `toString()` on toStringTag-branded objects (e.g. Temporal
29
+ * polyfills) — the execution is preserved for compatibility and recorded
30
+ * in the active {@link GuestCodeStats} sink, so callers (e.g. a retained-VM
31
+ * gate) can react.
32
+ *
33
+ * **Recording is not prevention.** For the recorded cases the determinism
34
+ * hazard is still live: a getter that calls `Math.random()` advances the
35
+ * run's seeded PRNG during serialization, and because serialization happens
36
+ * exactly once and is never replayed, every subsequent draw — including the
37
+ * correlation ids derived from that stream — shifts relative to replay. The
38
+ * report is the only trace of that; acting on it (warning, demoting a
39
+ * retained VM to replay) is left to the caller.
40
+ *
41
+ * The recorder is ambient module state, set for the duration of a
42
+ * synchronous `stringify` call via {@link withGuestCodeStats}. devalue's
43
+ * `stringify` is fully synchronous, so this is safe without async context.
44
+ */
45
+ import type { StringifyOperations } from 'devalue';
46
+ /**
47
+ * A single instance of workflow (guest) code executing during serialization.
48
+ */
49
+ export interface GuestCodeExecution {
50
+ /**
51
+ * What forced the execution:
52
+ * - `getter`: an accessor property was invoked to read data
53
+ * - `proxy`: a proxy was introspected, firing its traps. Note this also
54
+ * implies a **shape change**: brand checks answer "not that type" for a
55
+ * proxy, so a proxied `Map` serializes as a plain object rather than as a
56
+ * `Map`, and this report is the only evidence of it. (Such values were
57
+ * never serializable before — the internal-slot reads in the previous
58
+ * implementation threw on them — so the shape change replaces a crash,
59
+ * but it is silent.)
60
+ * - `method`: a workflow-defined function was invoked (e.g. a custom
61
+ * `[WORKFLOW_SERIALIZE]` serializer, `toString()` on a
62
+ * `Symbol.toStringTag`-branded object, a duck-typed `getTime()`, or a
63
+ * `__closureVarsFn` this package did not generate)
64
+ */
65
+ kind: 'getter' | 'proxy' | 'method';
66
+ /** Best-effort context: the property key, method name, or tag involved. */
67
+ detail?: string;
68
+ }
69
+ /**
70
+ * Mutable sink recording every workflow-code execution serialization could
71
+ * not avoid. Pass via `CodecOptions.guestCodeStats`; consumers that retain
72
+ * the VM across steps can use a non-empty `executions` array as a signal
73
+ * that the VM state may have been perturbed by serialization.
74
+ */
75
+ export interface GuestCodeStats {
76
+ executions: GuestCodeExecution[];
77
+ }
78
+ /**
79
+ * Runs `fn` (synchronously) with `stats` as the active guest-code sink.
80
+ * Nested calls stack correctly; a `null`/`undefined` sink disables
81
+ * recording without disabling hardening.
82
+ */
83
+ export declare function withGuestCodeStats<T>(stats: GuestCodeStats | undefined, fn: () => T): T;
84
+ /** Marks a function as having been passed to `useStep`. */
85
+ export declare function markUseStepClosureFn<T extends object>(fn: T): T;
86
+ /** Whether `fn` was marked by {@link markUseStepClosureFn}. */
87
+ export declare function isUseStepClosureFn(fn: unknown): boolean;
88
+ export declare function recordGuestCode(kind: GuestCodeExecution['kind'], detail?: string): void;
89
+ /** `Date.prototype.getDate`, for invalid-date checks. */
90
+ export declare const dateGetDate: (thisArg: unknown) => number;
91
+ /** `Date.prototype.getTime`. */
92
+ export declare const dateGetTime: (thisArg: unknown) => number;
93
+ /** `Date.prototype.toISOString`. */
94
+ export declare const dateToISOString: (thisArg: unknown) => string;
95
+ /** `RegExp.prototype.source` getter. */
96
+ export declare const regExpSource: (value: unknown) => string;
97
+ /** `RegExp.prototype.flags` getter. */
98
+ export declare const regExpFlags: (value: unknown) => string;
99
+ /** `ArrayBuffer.prototype.byteLength` getter (internal slot read). */
100
+ export declare const arrayBufferByteLength: (value: unknown) => number;
101
+ /**
102
+ * Reads `value[key]` with `[[Get]]` semantics, but through descriptors:
103
+ * plain data properties never invoke anything; accessor properties are
104
+ * invoked (the data lives behind them) and recorded; proxies fall back to
105
+ * a plain read (their traps are the only access path) and are recorded.
106
+ */
107
+ export declare function readProperty(value: unknown, key: PropertyKey): unknown;
108
+ /**
109
+ * `key in value` semantics without firing proxy traps for ordinary
110
+ * objects. Proxies fall back to the `in` operator and are recorded.
111
+ */
112
+ export declare function hasProperty(value: unknown, key: PropertyKey): boolean;
113
+ /**
114
+ * `value instanceof C` semantics for a known `C.prototype`, without
115
+ * consulting `Symbol.hasInstance` (which workflow code can define). Used
116
+ * for host classes that are injected into the sandbox (Headers, URL,
117
+ * URLSearchParams, DOMException), where the instances — from any realm the
118
+ * host handed the class to — carry the host prototype in their chain.
119
+ *
120
+ * Proxies are walked rather than rejected: `Reflect.getPrototypeOf` fires
121
+ * the proxy's `getPrototypeOf` trap, matching `instanceof` semantics, and
122
+ * real values depend on that — Next.js hands the runtime a proxied
123
+ * `NextRequest`, and answering "not a Request" for it would silently break
124
+ * webhooks. The traps are guest-observable, so the proxy is recorded.
125
+ */
126
+ export declare function isInstanceOfPrototype(value: unknown, prototype: object | undefined): boolean;
127
+ /** `URL.prototype.href` getter. */
128
+ export declare function urlHref(value: URL): string;
129
+ /** `URLSearchParams.prototype.toString` — returns `''` iff empty. */
130
+ export declare function urlSearchParamsToString(value: URLSearchParams): string;
131
+ /**
132
+ * Iterates a Headers instance through the captured host iterator, so the
133
+ * iterator object — and its `next` — are host-realm.
134
+ */
135
+ export declare function headersToEntries(value: Headers): [string, string][];
136
+ /**
137
+ * Iterates a genuine Map's entries entirely through host intrinsics: the
138
+ * iterator object is created by the host `Map.prototype.entries`, so its
139
+ * realm — and therefore its `next` — is the host's, not the sandbox's.
140
+ */
141
+ export declare function mapToEntries(value: Map<unknown, unknown>): [unknown, unknown][];
142
+ /** See {@link mapToEntries}. */
143
+ export declare function setToValues(value: Set<unknown>): unknown[];
144
+ /**
145
+ * The bytes of an `ArrayBufferView`, read via internal-slot getters —
146
+ * own-property shadowing and prototype patches cannot change which bytes
147
+ * are serialized.
148
+ */
149
+ export declare function viewInfo(value: ArrayBufferView): {
150
+ buffer: ArrayBufferLike;
151
+ byteOffset: number;
152
+ byteLength: number;
153
+ };
154
+ export declare const hardenedStringifyOperations: Partial<StringifyOperations>;
155
+ //# sourceMappingURL=hardened.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hardened.d.ts","sourceRoot":"","sources":["../../src/serialization/hardened.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAKnD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;;;;;;;OAcG;IACH,IAAI,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