@azx-pbc/axiom-runtime 0.0.0-stage → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +714 -2
- package/dist/cache/index.d.ts +191 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +361 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/canonical/jcs.d.ts +78 -0
- package/dist/canonical/jcs.d.ts.map +1 -0
- package/dist/canonical/jcs.js +500 -0
- package/dist/canonical/jcs.js.map +1 -0
- package/dist/canonical/restricted-json.d.ts +7 -0
- package/dist/canonical/restricted-json.d.ts.map +1 -0
- package/dist/canonical/restricted-json.js +318 -0
- package/dist/canonical/restricted-json.js.map +1 -0
- package/dist/canonical/restricted-value.d.ts +59 -0
- package/dist/canonical/restricted-value.d.ts.map +1 -0
- package/dist/canonical/restricted-value.js +156 -0
- package/dist/canonical/restricted-value.js.map +1 -0
- package/dist/canonical/restricted.d.ts +85 -0
- package/dist/canonical/restricted.d.ts.map +1 -0
- package/dist/canonical/restricted.js +163 -0
- package/dist/canonical/restricted.js.map +1 -0
- package/dist/canonical/signature.d.ts +38 -0
- package/dist/canonical/signature.d.ts.map +1 -0
- package/dist/canonical/signature.js +47 -0
- package/dist/canonical/signature.js.map +1 -0
- package/dist/eval/access/delivery.d.ts +63 -0
- package/dist/eval/access/delivery.d.ts.map +1 -0
- package/dist/eval/access/delivery.js +98 -0
- package/dist/eval/access/delivery.js.map +1 -0
- package/dist/eval/access/overlay.d.ts +72 -0
- package/dist/eval/access/overlay.d.ts.map +1 -0
- package/dist/eval/access/overlay.js +402 -0
- package/dist/eval/access/overlay.js.map +1 -0
- package/dist/eval/access/projection.d.ts +159 -0
- package/dist/eval/access/projection.d.ts.map +1 -0
- package/dist/eval/access/projection.js +211 -0
- package/dist/eval/access/projection.js.map +1 -0
- package/dist/eval/access/window.d.ts +128 -0
- package/dist/eval/access/window.d.ts.map +1 -0
- package/dist/eval/access/window.js +254 -0
- package/dist/eval/access/window.js.map +1 -0
- package/dist/eval/access/write.d.ts +113 -0
- package/dist/eval/access/write.d.ts.map +1 -0
- package/dist/eval/access/write.js +119 -0
- package/dist/eval/access/write.js.map +1 -0
- package/dist/eval/addressing.d.ts +131 -0
- package/dist/eval/addressing.d.ts.map +1 -0
- package/dist/eval/addressing.js +270 -0
- package/dist/eval/addressing.js.map +1 -0
- package/dist/eval/budget.d.ts +143 -0
- package/dist/eval/budget.d.ts.map +1 -0
- package/dist/eval/budget.js +387 -0
- package/dist/eval/budget.js.map +1 -0
- package/dist/eval/computed.d.ts +46 -0
- package/dist/eval/computed.d.ts.map +1 -0
- package/dist/eval/computed.js +89 -0
- package/dist/eval/computed.js.map +1 -0
- package/dist/eval/denials.d.ts +64 -0
- package/dist/eval/denials.d.ts.map +1 -0
- package/dist/eval/denials.js +87 -0
- package/dist/eval/denials.js.map +1 -0
- package/dist/eval/engine/cancellation.d.ts +12 -0
- package/dist/eval/engine/cancellation.d.ts.map +1 -0
- package/dist/eval/engine/cancellation.js +56 -0
- package/dist/eval/engine/cancellation.js.map +1 -0
- package/dist/eval/engine/delta.d.ts +104 -0
- package/dist/eval/engine/delta.d.ts.map +1 -0
- package/dist/eval/engine/delta.js +466 -0
- package/dist/eval/engine/delta.js.map +1 -0
- package/dist/eval/engine/deps.d.ts +136 -0
- package/dist/eval/engine/deps.d.ts.map +1 -0
- package/dist/eval/engine/deps.js +345 -0
- package/dist/eval/engine/deps.js.map +1 -0
- package/dist/eval/engine/identity.d.ts +128 -0
- package/dist/eval/engine/identity.d.ts.map +1 -0
- package/dist/eval/engine/identity.js +398 -0
- package/dist/eval/engine/identity.js.map +1 -0
- package/dist/eval/engine/index.d.ts +200 -0
- package/dist/eval/engine/index.d.ts.map +1 -0
- package/dist/eval/engine/index.js +1242 -0
- package/dist/eval/engine/index.js.map +1 -0
- package/dist/eval/engine/measurement.d.ts +23 -0
- package/dist/eval/engine/measurement.d.ts.map +1 -0
- package/dist/eval/engine/measurement.js +42 -0
- package/dist/eval/engine/measurement.js.map +1 -0
- package/dist/eval/engine/naive.d.ts +19 -0
- package/dist/eval/engine/naive.d.ts.map +1 -0
- package/dist/eval/engine/naive.js +59 -0
- package/dist/eval/engine/naive.js.map +1 -0
- package/dist/eval/engine/ops.d.ts +214 -0
- package/dist/eval/engine/ops.d.ts.map +1 -0
- package/dist/eval/engine/ops.js +1422 -0
- package/dist/eval/engine/ops.js.map +1 -0
- package/dist/eval/engine/patches.d.ts +40 -0
- package/dist/eval/engine/patches.d.ts.map +1 -0
- package/dist/eval/engine/patches.js +125 -0
- package/dist/eval/engine/patches.js.map +1 -0
- package/dist/eval/engine/ports.d.ts +71 -0
- package/dist/eval/engine/ports.d.ts.map +1 -0
- package/dist/eval/engine/ports.js +2 -0
- package/dist/eval/engine/ports.js.map +1 -0
- package/dist/eval/engine/session.d.ts +116 -0
- package/dist/eval/engine/session.d.ts.map +1 -0
- package/dist/eval/engine/session.js +653 -0
- package/dist/eval/engine/session.js.map +1 -0
- package/dist/eval/engine/snapshot.d.ts +97 -0
- package/dist/eval/engine/snapshot.d.ts.map +1 -0
- package/dist/eval/engine/snapshot.js +221 -0
- package/dist/eval/engine/snapshot.js.map +1 -0
- package/dist/eval/engine/subscriptions.d.ts +47 -0
- package/dist/eval/engine/subscriptions.d.ts.map +1 -0
- package/dist/eval/engine/subscriptions.js +103 -0
- package/dist/eval/engine/subscriptions.js.map +1 -0
- package/dist/eval/engine/trace.d.ts +77 -0
- package/dist/eval/engine/trace.d.ts.map +1 -0
- package/dist/eval/engine/trace.js +140 -0
- package/dist/eval/engine/trace.js.map +1 -0
- package/dist/eval/error-diagnostic.d.ts +26 -0
- package/dist/eval/error-diagnostic.d.ts.map +1 -0
- package/dist/eval/error-diagnostic.js +63 -0
- package/dist/eval/error-diagnostic.js.map +1 -0
- package/dist/eval/evaluate-expr.d.ts +44 -0
- package/dist/eval/evaluate-expr.d.ts.map +1 -0
- package/dist/eval/evaluate-expr.js +149 -0
- package/dist/eval/evaluate-expr.js.map +1 -0
- package/dist/eval/evaluate.d.ts +282 -0
- package/dist/eval/evaluate.d.ts.map +1 -0
- package/dist/eval/evaluate.js +391 -0
- package/dist/eval/evaluate.js.map +1 -0
- package/dist/eval/evolution/relocate.d.ts +72 -0
- package/dist/eval/evolution/relocate.d.ts.map +1 -0
- package/dist/eval/evolution/relocate.js +427 -0
- package/dist/eval/evolution/relocate.js.map +1 -0
- package/dist/eval/evolution/select.d.ts +11 -0
- package/dist/eval/evolution/select.d.ts.map +1 -0
- package/dist/eval/evolution/select.js +53 -0
- package/dist/eval/evolution/select.js.map +1 -0
- package/dist/eval/evolution/upcast.d.ts +13 -0
- package/dist/eval/evolution/upcast.d.ts.map +1 -0
- package/dist/eval/evolution/upcast.js +88 -0
- package/dist/eval/evolution/upcast.js.map +1 -0
- package/dist/eval/expr/aggregates.d.ts +75 -0
- package/dist/eval/expr/aggregates.d.ts.map +1 -0
- package/dist/eval/expr/aggregates.js +991 -0
- package/dist/eval/expr/aggregates.js.map +1 -0
- package/dist/eval/expr/arithmetic.d.ts +26 -0
- package/dist/eval/expr/arithmetic.d.ts.map +1 -0
- package/dist/eval/expr/arithmetic.js +387 -0
- package/dist/eval/expr/arithmetic.js.map +1 -0
- package/dist/eval/expr/between.d.ts +17 -0
- package/dist/eval/expr/between.d.ts.map +1 -0
- package/dist/eval/expr/between.js +46 -0
- package/dist/eval/expr/between.js.map +1 -0
- package/dist/eval/expr/binder.d.ts +96 -0
- package/dist/eval/expr/binder.d.ts.map +1 -0
- package/dist/eval/expr/binder.js +253 -0
- package/dist/eval/expr/binder.js.map +1 -0
- package/dist/eval/expr/call-dispatch.d.ts +28 -0
- package/dist/eval/expr/call-dispatch.d.ts.map +1 -0
- package/dist/eval/expr/call-dispatch.js +114 -0
- package/dist/eval/expr/call-dispatch.js.map +1 -0
- package/dist/eval/expr/collections.d.ts +20 -0
- package/dist/eval/expr/collections.d.ts.map +1 -0
- package/dist/eval/expr/collections.js +66 -0
- package/dist/eval/expr/collections.js.map +1 -0
- package/dist/eval/expr/compare.d.ts +36 -0
- package/dist/eval/expr/compare.d.ts.map +1 -0
- package/dist/eval/expr/compare.js +115 -0
- package/dist/eval/expr/compare.js.map +1 -0
- package/dist/eval/expr/datasets.d.ts +28 -0
- package/dist/eval/expr/datasets.d.ts.map +1 -0
- package/dist/eval/expr/datasets.js +304 -0
- package/dist/eval/expr/datasets.js.map +1 -0
- package/dist/eval/expr/digest.d.ts +23 -0
- package/dist/eval/expr/digest.d.ts.map +1 -0
- package/dist/eval/expr/digest.js +89 -0
- package/dist/eval/expr/digest.js.map +1 -0
- package/dist/eval/expr/domains.d.ts +19 -0
- package/dist/eval/expr/domains.d.ts.map +1 -0
- package/dist/eval/expr/domains.js +18 -0
- package/dist/eval/expr/domains.js.map +1 -0
- package/dist/eval/expr/host.d.ts +152 -0
- package/dist/eval/expr/host.d.ts.map +1 -0
- package/dist/eval/expr/host.js +36 -0
- package/dist/eval/expr/host.js.map +1 -0
- package/dist/eval/expr/lists.d.ts +24 -0
- package/dist/eval/expr/lists.d.ts.map +1 -0
- package/dist/eval/expr/lists.js +155 -0
- package/dist/eval/expr/lists.js.map +1 -0
- package/dist/eval/expr/member.d.ts +15 -0
- package/dist/eval/expr/member.d.ts.map +1 -0
- package/dist/eval/expr/member.js +32 -0
- package/dist/eval/expr/member.js.map +1 -0
- package/dist/eval/expr/money-ops.d.ts +10 -0
- package/dist/eval/expr/money-ops.d.ts.map +1 -0
- package/dist/eval/expr/money-ops.js +17 -0
- package/dist/eval/expr/money-ops.js.map +1 -0
- package/dist/eval/expr/operands.d.ts +27 -0
- package/dist/eval/expr/operands.d.ts.map +1 -0
- package/dist/eval/expr/operands.js +167 -0
- package/dist/eval/expr/operands.js.map +1 -0
- package/dist/eval/expr/presence.d.ts +27 -0
- package/dist/eval/expr/presence.d.ts.map +1 -0
- package/dist/eval/expr/presence.js +140 -0
- package/dist/eval/expr/presence.js.map +1 -0
- package/dist/eval/expr/records.d.ts +22 -0
- package/dist/eval/expr/records.d.ts.map +1 -0
- package/dist/eval/expr/records.js +101 -0
- package/dist/eval/expr/records.js.map +1 -0
- package/dist/eval/expr/rule-refs.d.ts +25 -0
- package/dist/eval/expr/rule-refs.d.ts.map +1 -0
- package/dist/eval/expr/rule-refs.js +60 -0
- package/dist/eval/expr/rule-refs.js.map +1 -0
- package/dist/eval/expr/sequences.d.ts +26 -0
- package/dist/eval/expr/sequences.d.ts.map +1 -0
- package/dist/eval/expr/sequences.js +151 -0
- package/dist/eval/expr/sequences.js.map +1 -0
- package/dist/eval/expr/value.d.ts +99 -0
- package/dist/eval/expr/value.d.ts.map +1 -0
- package/dist/eval/expr/value.js +14 -0
- package/dist/eval/expr/value.js.map +1 -0
- package/dist/eval/expression.d.ts +142 -0
- package/dist/eval/expression.d.ts.map +1 -0
- package/dist/eval/expression.js +446 -0
- package/dist/eval/expression.js.map +1 -0
- package/dist/eval/firing.d.ts +68 -0
- package/dist/eval/firing.d.ts.map +1 -0
- package/dist/eval/firing.js +222 -0
- package/dist/eval/firing.js.map +1 -0
- package/dist/eval/gate.d.ts +110 -0
- package/dist/eval/gate.d.ts.map +1 -0
- package/dist/eval/gate.js +278 -0
- package/dist/eval/gate.js.map +1 -0
- package/dist/eval/layout-visibility.d.ts +18 -0
- package/dist/eval/layout-visibility.d.ts.map +1 -0
- package/dist/eval/layout-visibility.js +61 -0
- package/dist/eval/layout-visibility.js.map +1 -0
- package/dist/eval/option-availability.d.ts +26 -0
- package/dist/eval/option-availability.d.ts.map +1 -0
- package/dist/eval/option-availability.js +580 -0
- package/dist/eval/option-availability.js.map +1 -0
- package/dist/eval/options-boundary.d.ts +15 -0
- package/dist/eval/options-boundary.d.ts.map +1 -0
- package/dist/eval/options-boundary.js +40 -0
- package/dist/eval/options-boundary.js.map +1 -0
- package/dist/eval/options.d.ts +99 -0
- package/dist/eval/options.d.ts.map +1 -0
- package/dist/eval/options.js +96 -0
- package/dist/eval/options.js.map +1 -0
- package/dist/eval/overrides.d.ts +116 -0
- package/dist/eval/overrides.d.ts.map +1 -0
- package/dist/eval/overrides.js +176 -0
- package/dist/eval/overrides.js.map +1 -0
- package/dist/eval/paths.d.ts +25 -0
- package/dist/eval/paths.d.ts.map +1 -0
- package/dist/eval/paths.js +47 -0
- package/dist/eval/paths.js.map +1 -0
- package/dist/eval/presentation-reads.d.ts +20 -0
- package/dist/eval/presentation-reads.d.ts.map +1 -0
- package/dist/eval/presentation-reads.js +2 -0
- package/dist/eval/presentation-reads.js.map +1 -0
- package/dist/eval/presentation.d.ts +122 -0
- package/dist/eval/presentation.d.ts.map +1 -0
- package/dist/eval/presentation.js +255 -0
- package/dist/eval/presentation.js.map +1 -0
- package/dist/eval/reader/context-value.d.ts +41 -0
- package/dist/eval/reader/context-value.d.ts.map +1 -0
- package/dist/eval/reader/context-value.js +129 -0
- package/dist/eval/reader/context-value.js.map +1 -0
- package/dist/eval/reader/covered.d.ts +53 -0
- package/dist/eval/reader/covered.d.ts.map +1 -0
- package/dist/eval/reader/covered.js +139 -0
- package/dist/eval/reader/covered.js.map +1 -0
- package/dist/eval/reader/declarations.d.ts +182 -0
- package/dist/eval/reader/declarations.d.ts.map +1 -0
- package/dist/eval/reader/declarations.js +153 -0
- package/dist/eval/reader/declarations.js.map +1 -0
- package/dist/eval/reader/member-access.d.ts +87 -0
- package/dist/eval/reader/member-access.d.ts.map +1 -0
- package/dist/eval/reader/member-access.js +212 -0
- package/dist/eval/reader/member-access.js.map +1 -0
- package/dist/eval/reader/memo.d.ts +34 -0
- package/dist/eval/reader/memo.d.ts.map +1 -0
- package/dist/eval/reader/memo.js +67 -0
- package/dist/eval/reader/memo.js.map +1 -0
- package/dist/eval/reader/overlay.d.ts +74 -0
- package/dist/eval/reader/overlay.d.ts.map +1 -0
- package/dist/eval/reader/overlay.js +365 -0
- package/dist/eval/reader/overlay.js.map +1 -0
- package/dist/eval/reader/questions.d.ts +37 -0
- package/dist/eval/reader/questions.d.ts.map +1 -0
- package/dist/eval/reader/questions.js +78 -0
- package/dist/eval/reader/questions.js.map +1 -0
- package/dist/eval/reader/resolve.d.ts +84 -0
- package/dist/eval/reader/resolve.d.ts.map +1 -0
- package/dist/eval/reader/resolve.js +310 -0
- package/dist/eval/reader/resolve.js.map +1 -0
- package/dist/eval/reader/value-read.d.ts +50 -0
- package/dist/eval/reader/value-read.d.ts.map +1 -0
- package/dist/eval/reader/value-read.js +133 -0
- package/dist/eval/reader/value-read.js.map +1 -0
- package/dist/eval/reader/withheld.d.ts +48 -0
- package/dist/eval/reader/withheld.d.ts.map +1 -0
- package/dist/eval/reader/withheld.js +108 -0
- package/dist/eval/reader/withheld.js.map +1 -0
- package/dist/eval/reader-paths.d.ts +24 -0
- package/dist/eval/reader-paths.d.ts.map +1 -0
- package/dist/eval/reader-paths.js +23 -0
- package/dist/eval/reader-paths.js.map +1 -0
- package/dist/eval/reader.d.ts +281 -0
- package/dist/eval/reader.d.ts.map +1 -0
- package/dist/eval/reader.js +560 -0
- package/dist/eval/reader.js.map +1 -0
- package/dist/eval/receipt.d.ts +37 -0
- package/dist/eval/receipt.d.ts.map +1 -0
- package/dist/eval/receipt.js +222 -0
- package/dist/eval/receipt.js.map +1 -0
- package/dist/eval/report/assemble.d.ts +84 -0
- package/dist/eval/report/assemble.d.ts.map +1 -0
- package/dist/eval/report/assemble.js +277 -0
- package/dist/eval/report/assemble.js.map +1 -0
- package/dist/eval/report/fold.d.ts +18 -0
- package/dist/eval/report/fold.d.ts.map +1 -0
- package/dist/eval/report/fold.js +58 -0
- package/dist/eval/report/fold.js.map +1 -0
- package/dist/eval/rule/alternatives.d.ts +23 -0
- package/dist/eval/rule/alternatives.d.ts.map +1 -0
- package/dist/eval/rule/alternatives.js +46 -0
- package/dist/eval/rule/alternatives.js.map +1 -0
- package/dist/eval/rule/behaviour.d.ts +47 -0
- package/dist/eval/rule/behaviour.d.ts.map +1 -0
- package/dist/eval/rule/behaviour.js +249 -0
- package/dist/eval/rule/behaviour.js.map +1 -0
- package/dist/eval/rule/compute.d.ts +46 -0
- package/dist/eval/rule/compute.d.ts.map +1 -0
- package/dist/eval/rule/compute.js +158 -0
- package/dist/eval/rule/compute.js.map +1 -0
- package/dist/eval/rule/create-state.d.ts +42 -0
- package/dist/eval/rule/create-state.d.ts.map +1 -0
- package/dist/eval/rule/create-state.js +134 -0
- package/dist/eval/rule/create-state.js.map +1 -0
- package/dist/eval/rule/diagnostics.d.ts +24 -0
- package/dist/eval/rule/diagnostics.d.ts.map +1 -0
- package/dist/eval/rule/diagnostics.js +45 -0
- package/dist/eval/rule/diagnostics.js.map +1 -0
- package/dist/eval/rule/execution.d.ts +24 -0
- package/dist/eval/rule/execution.d.ts.map +1 -0
- package/dist/eval/rule/execution.js +495 -0
- package/dist/eval/rule/execution.js.map +1 -0
- package/dist/eval/rule/gate.d.ts +12 -0
- package/dist/eval/rule/gate.d.ts.map +1 -0
- package/dist/eval/rule/gate.js +34 -0
- package/dist/eval/rule/gate.js.map +1 -0
- package/dist/eval/rule/item.d.ts +11 -0
- package/dist/eval/rule/item.d.ts.map +1 -0
- package/dist/eval/rule/item.js +265 -0
- package/dist/eval/rule/item.js.map +1 -0
- package/dist/eval/rule/prepare.d.ts +64 -0
- package/dist/eval/rule/prepare.d.ts.map +1 -0
- package/dist/eval/rule/prepare.js +131 -0
- package/dist/eval/rule/prepare.js.map +1 -0
- package/dist/eval/rule/result.d.ts +97 -0
- package/dist/eval/rule/result.d.ts.map +1 -0
- package/dist/eval/rule/result.js +347 -0
- package/dist/eval/rule/result.js.map +1 -0
- package/dist/eval/rule/runner.d.ts +128 -0
- package/dist/eval/rule/runner.d.ts.map +1 -0
- package/dist/eval/rule/runner.js +296 -0
- package/dist/eval/rule/runner.js.map +1 -0
- package/dist/eval/rule/screen.d.ts +32 -0
- package/dist/eval/rule/screen.d.ts.map +1 -0
- package/dist/eval/rule/screen.js +73 -0
- package/dist/eval/rule/screen.js.map +1 -0
- package/dist/eval/rule/state.d.ts +137 -0
- package/dist/eval/rule/state.d.ts.map +1 -0
- package/dist/eval/rule/state.js +2 -0
- package/dist/eval/rule/state.js.map +1 -0
- package/dist/eval/rule/steps.d.ts +44 -0
- package/dist/eval/rule/steps.d.ts.map +1 -0
- package/dist/eval/rule/steps.js +367 -0
- package/dist/eval/rule/steps.js.map +1 -0
- package/dist/eval/rule/visibility.d.ts +18 -0
- package/dist/eval/rule/visibility.d.ts.map +1 -0
- package/dist/eval/rule/visibility.js +79 -0
- package/dist/eval/rule/visibility.js.map +1 -0
- package/dist/eval/seal.d.ts +74 -0
- package/dist/eval/seal.d.ts.map +1 -0
- package/dist/eval/seal.js +154 -0
- package/dist/eval/seal.js.map +1 -0
- package/dist/eval/signature-coverage.d.ts +19 -0
- package/dist/eval/signature-coverage.d.ts.map +1 -0
- package/dist/eval/signature-coverage.js +160 -0
- package/dist/eval/signature-coverage.js.map +1 -0
- package/dist/eval/state/derive.d.ts +72 -0
- package/dist/eval/state/derive.d.ts.map +1 -0
- package/dist/eval/state/derive.js +61 -0
- package/dist/eval/state/derive.js.map +1 -0
- package/dist/eval/state/describe.d.ts +18 -0
- package/dist/eval/state/describe.d.ts.map +1 -0
- package/dist/eval/state/describe.js +19 -0
- package/dist/eval/state/describe.js.map +1 -0
- package/dist/eval/state/field-state.d.ts +471 -0
- package/dist/eval/state/field-state.d.ts.map +1 -0
- package/dist/eval/state/field-state.js +1604 -0
- package/dist/eval/state/field-state.js.map +1 -0
- package/dist/eval/state/measurement.d.ts +136 -0
- package/dist/eval/state/measurement.d.ts.map +1 -0
- package/dist/eval/state/measurement.js +209 -0
- package/dist/eval/state/measurement.js.map +1 -0
- package/dist/eval/state/options.d.ts +21 -0
- package/dist/eval/state/options.d.ts.map +1 -0
- package/dist/eval/state/options.js +3 -0
- package/dist/eval/state/options.js.map +1 -0
- package/dist/eval/state/readiness.d.ts +400 -0
- package/dist/eval/state/readiness.d.ts.map +1 -0
- package/dist/eval/state/readiness.js +1067 -0
- package/dist/eval/state/readiness.js.map +1 -0
- package/dist/eval/state/snapshot.d.ts +130 -0
- package/dist/eval/state/snapshot.d.ts.map +1 -0
- package/dist/eval/state/snapshot.js +35 -0
- package/dist/eval/state/snapshot.js.map +1 -0
- package/dist/eval/state/unavailable-options.d.ts +54 -0
- package/dist/eval/state/unavailable-options.d.ts.map +1 -0
- package/dist/eval/state/unavailable-options.js +82 -0
- package/dist/eval/state/unavailable-options.js.map +1 -0
- package/dist/eval/state/value-state.d.ts +38 -0
- package/dist/eval/state/value-state.d.ts.map +1 -0
- package/dist/eval/state/value-state.js +52 -0
- package/dist/eval/state/value-state.js.map +1 -0
- package/dist/eval/submission/admission.d.ts +50 -0
- package/dist/eval/submission/admission.d.ts.map +1 -0
- package/dist/eval/submission/admission.js +174 -0
- package/dist/eval/submission/admission.js.map +1 -0
- package/dist/eval/submission/authority.d.ts +71 -0
- package/dist/eval/submission/authority.d.ts.map +1 -0
- package/dist/eval/submission/authority.js +118 -0
- package/dist/eval/submission/authority.js.map +1 -0
- package/dist/eval/submission/datasets.d.ts +28 -0
- package/dist/eval/submission/datasets.d.ts.map +1 -0
- package/dist/eval/submission/datasets.js +109 -0
- package/dist/eval/submission/datasets.js.map +1 -0
- package/dist/eval/submission/index.d.ts +15 -0
- package/dist/eval/submission/index.d.ts.map +1 -0
- package/dist/eval/submission/index.js +13 -0
- package/dist/eval/submission/index.js.map +1 -0
- package/dist/eval/submission/refusals.d.ts +103 -0
- package/dist/eval/submission/refusals.d.ts.map +1 -0
- package/dist/eval/submission/refusals.js +15 -0
- package/dist/eval/submission/refusals.js.map +1 -0
- package/dist/eval/submission/signatures.d.ts +7 -0
- package/dist/eval/submission/signatures.d.ts.map +1 -0
- package/dist/eval/submission/signatures.js +215 -0
- package/dist/eval/submission/signatures.js.map +1 -0
- package/dist/eval/submission/writes.d.ts +51 -0
- package/dist/eval/submission/writes.d.ts.map +1 -0
- package/dist/eval/submission/writes.js +203 -0
- package/dist/eval/submission/writes.js.map +1 -0
- package/dist/eval/submission.d.ts +53 -0
- package/dist/eval/submission.d.ts.map +1 -0
- package/dist/eval/submission.js +521 -0
- package/dist/eval/submission.js.map +1 -0
- package/dist/eval/suggestions-to-engine.d.ts +18 -0
- package/dist/eval/suggestions-to-engine.d.ts.map +1 -0
- package/dist/eval/suggestions-to-engine.js +40 -0
- package/dist/eval/suggestions-to-engine.js.map +1 -0
- package/dist/eval/suggestions.d.ts +17 -0
- package/dist/eval/suggestions.d.ts.map +1 -0
- package/dist/eval/suggestions.js +314 -0
- package/dist/eval/suggestions.js.map +1 -0
- package/dist/eval/undecided.d.ts +64 -0
- package/dist/eval/undecided.d.ts.map +1 -0
- package/dist/eval/undecided.js +101 -0
- package/dist/eval/undecided.js.map +1 -0
- package/dist/eval/verdict.d.ts +66 -0
- package/dist/eval/verdict.d.ts.map +1 -0
- package/dist/eval/verdict.js +106 -0
- package/dist/eval/verdict.js.map +1 -0
- package/dist/eval/verify-signature.d.ts +78 -0
- package/dist/eval/verify-signature.d.ts.map +1 -0
- package/dist/eval/verify-signature.js +185 -0
- package/dist/eval/verify-signature.js.map +1 -0
- package/dist/eval/version-dispatch.d.ts +38 -0
- package/dist/eval/version-dispatch.d.ts.map +1 -0
- package/dist/eval/version-dispatch.js +61 -0
- package/dist/eval/version-dispatch.js.map +1 -0
- package/dist/eval/visibility.d.ts +33 -0
- package/dist/eval/visibility.d.ts.map +1 -0
- package/dist/eval/visibility.js +83 -0
- package/dist/eval/visibility.js.map +1 -0
- package/dist/evaluate.d.ts +24 -0
- package/dist/evaluate.d.ts.map +1 -0
- package/dist/evaluate.js +18 -0
- package/dist/evaluate.js.map +1 -0
- package/dist/expr/builtin-docs.d.ts +51 -0
- package/dist/expr/builtin-docs.d.ts.map +1 -0
- package/dist/expr/builtin-docs.js +874 -0
- package/dist/expr/builtin-docs.js.map +1 -0
- package/dist/expr/builtins.d.ts +50 -0
- package/dist/expr/builtins.d.ts.map +1 -0
- package/dist/expr/builtins.js +966 -0
- package/dist/expr/builtins.js.map +1 -0
- package/dist/expr/decimal-precision.d.ts +39 -0
- package/dist/expr/decimal-precision.d.ts.map +1 -0
- package/dist/expr/decimal-precision.js +62 -0
- package/dist/expr/decimal-precision.js.map +1 -0
- package/dist/expr/decimal.d.ts +172 -0
- package/dist/expr/decimal.d.ts.map +1 -0
- package/dist/expr/decimal.js +782 -0
- package/dist/expr/decimal.js.map +1 -0
- package/dist/expr/deprecations.d.ts +34 -0
- package/dist/expr/deprecations.d.ts.map +1 -0
- package/dist/expr/deprecations.js +17 -0
- package/dist/expr/deprecations.js.map +1 -0
- package/dist/expr/diagnostics.d.ts +21 -0
- package/dist/expr/diagnostics.d.ts.map +1 -0
- package/dist/expr/diagnostics.js +231 -0
- package/dist/expr/diagnostics.js.map +1 -0
- package/dist/expr/direction.d.ts +30 -0
- package/dist/expr/direction.d.ts.map +1 -0
- package/dist/expr/direction.js +77 -0
- package/dist/expr/direction.js.map +1 -0
- package/dist/expr/example-expression.d.ts +62 -0
- package/dist/expr/example-expression.d.ts.map +1 -0
- package/dist/expr/example-expression.js +670 -0
- package/dist/expr/example-expression.js.map +1 -0
- package/dist/expr/instant.d.ts +49 -0
- package/dist/expr/instant.d.ts.map +1 -0
- package/dist/expr/instant.js +111 -0
- package/dist/expr/instant.js.map +1 -0
- package/dist/expr/logic.d.ts +17 -0
- package/dist/expr/logic.d.ts.map +1 -0
- package/dist/expr/logic.js +65 -0
- package/dist/expr/logic.js.map +1 -0
- package/dist/expr/messages.d.ts +45 -0
- package/dist/expr/messages.d.ts.map +1 -0
- package/dist/expr/messages.js +280 -0
- package/dist/expr/messages.js.map +1 -0
- package/dist/expr/money.d.ts +38 -0
- package/dist/expr/money.d.ts.map +1 -0
- package/dist/expr/money.js +127 -0
- package/dist/expr/money.js.map +1 -0
- package/dist/expr/ordering.d.ts +56 -0
- package/dist/expr/ordering.d.ts.map +1 -0
- package/dist/expr/ordering.js +167 -0
- package/dist/expr/ordering.js.map +1 -0
- package/dist/expr/pattern.d.ts +44 -0
- package/dist/expr/pattern.d.ts.map +1 -0
- package/dist/expr/pattern.js +458 -0
- package/dist/expr/pattern.js.map +1 -0
- package/dist/expr/plain-date.d.ts +90 -0
- package/dist/expr/plain-date.d.ts.map +1 -0
- package/dist/expr/plain-date.js +230 -0
- package/dist/expr/plain-date.js.map +1 -0
- package/dist/expr/plural-categories.d.ts +8 -0
- package/dist/expr/plural-categories.d.ts.map +1 -0
- package/dist/expr/plural-categories.js +15 -0
- package/dist/expr/plural-categories.js.map +1 -0
- package/dist/expr/plural-keys.d.ts +39 -0
- package/dist/expr/plural-keys.d.ts.map +1 -0
- package/dist/expr/plural-keys.js +46 -0
- package/dist/expr/plural-keys.js.map +1 -0
- package/dist/expr/plural.d.ts +33 -0
- package/dist/expr/plural.d.ts.map +1 -0
- package/dist/expr/plural.js +50 -0
- package/dist/expr/plural.js.map +1 -0
- package/dist/expr/quantity.d.ts +31 -0
- package/dist/expr/quantity.d.ts.map +1 -0
- package/dist/expr/quantity.js +83 -0
- package/dist/expr/quantity.js.map +1 -0
- package/dist/expr/reduce.d.ts +50 -0
- package/dist/expr/reduce.d.ts.map +1 -0
- package/dist/expr/reduce.js +236 -0
- package/dist/expr/reduce.js.map +1 -0
- package/dist/expr/regex.d.ts +108 -0
- package/dist/expr/regex.d.ts.map +1 -0
- package/dist/expr/regex.js +1210 -0
- package/dist/expr/regex.js.map +1 -0
- package/dist/expr/select-locale.d.ts +67 -0
- package/dist/expr/select-locale.d.ts.map +1 -0
- package/dist/expr/select-locale.js +219 -0
- package/dist/expr/select-locale.js.map +1 -0
- package/dist/expr/sequences.d.ts +123 -0
- package/dist/expr/sequences.d.ts.map +1 -0
- package/dist/expr/sequences.js +234 -0
- package/dist/expr/sequences.js.map +1 -0
- package/dist/expr/strings.d.ts +50 -0
- package/dist/expr/strings.d.ts.map +1 -0
- package/dist/expr/strings.js +184 -0
- package/dist/expr/strings.js.map +1 -0
- package/dist/expr/validation.d.ts +32 -0
- package/dist/expr/validation.d.ts.map +1 -0
- package/dist/expr/validation.js +182 -0
- package/dist/expr/validation.js.map +1 -0
- package/dist/graph/freeze.d.ts +4 -0
- package/dist/graph/freeze.d.ts.map +1 -0
- package/dist/graph/freeze.js +52 -0
- package/dist/graph/freeze.js.map +1 -0
- package/dist/graph/index.d.ts +15 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +13 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/inspect.d.ts +76 -0
- package/dist/graph/inspect.d.ts.map +1 -0
- package/dist/graph/inspect.js +263 -0
- package/dist/graph/inspect.js.map +1 -0
- package/dist/graph/read-walk.d.ts +101 -0
- package/dist/graph/read-walk.d.ts.map +1 -0
- package/dist/graph/read-walk.js +358 -0
- package/dist/graph/read-walk.js.map +1 -0
- package/dist/graph/record-index.d.ts +24 -0
- package/dist/graph/record-index.d.ts.map +1 -0
- package/dist/graph/record-index.js +35 -0
- package/dist/graph/record-index.js.map +1 -0
- package/dist/index.d.ts +104 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +139 -0
- package/dist/index.js.map +1 -0
- package/dist/lookup/digest.d.ts +51 -0
- package/dist/lookup/digest.d.ts.map +1 -0
- package/dist/lookup/digest.js +46 -0
- package/dist/lookup/digest.js.map +1 -0
- package/dist/lookup/index.d.ts +28 -0
- package/dist/lookup/index.d.ts.map +1 -0
- package/dist/lookup/index.js +27 -0
- package/dist/lookup/index.js.map +1 -0
- package/dist/lookup/install.d.ts +48 -0
- package/dist/lookup/install.d.ts.map +1 -0
- package/dist/lookup/install.js +315 -0
- package/dist/lookup/install.js.map +1 -0
- package/dist/lookup/pass.d.ts +55 -0
- package/dist/lookup/pass.d.ts.map +1 -0
- package/dist/lookup/pass.js +212 -0
- package/dist/lookup/pass.js.map +1 -0
- package/dist/lookup/pins.d.ts +34 -0
- package/dist/lookup/pins.d.ts.map +1 -0
- package/dist/lookup/pins.js +39 -0
- package/dist/lookup/pins.js.map +1 -0
- package/dist/lookup/provenance.d.ts +23 -0
- package/dist/lookup/provenance.d.ts.map +1 -0
- package/dist/lookup/provenance.js +78 -0
- package/dist/lookup/provenance.js.map +1 -0
- package/dist/lookup/readiness.d.ts +13 -0
- package/dist/lookup/readiness.d.ts.map +1 -0
- package/dist/lookup/readiness.js +57 -0
- package/dist/lookup/readiness.js.map +1 -0
- package/dist/lookup/resolve.d.ts +24 -0
- package/dist/lookup/resolve.d.ts.map +1 -0
- package/dist/lookup/resolve.js +201 -0
- package/dist/lookup/resolve.js.map +1 -0
- package/dist/lookup/store.d.ts +41 -0
- package/dist/lookup/store.d.ts.map +1 -0
- package/dist/lookup/store.js +74 -0
- package/dist/lookup/store.js.map +1 -0
- package/dist/model/access.d.ts +200 -0
- package/dist/model/access.d.ts.map +1 -0
- package/dist/model/access.js +125 -0
- package/dist/model/access.js.map +1 -0
- package/dist/model/artifact-members.d.ts +3 -0
- package/dist/model/artifact-members.d.ts.map +1 -0
- package/dist/model/artifact-members.js +38 -0
- package/dist/model/artifact-members.js.map +1 -0
- package/dist/model/composition.d.ts +47 -0
- package/dist/model/composition.d.ts.map +1 -0
- package/dist/model/composition.js +66 -0
- package/dist/model/composition.js.map +1 -0
- package/dist/model/domain.d.ts +51 -0
- package/dist/model/domain.d.ts.map +1 -0
- package/dist/model/domain.js +75 -0
- package/dist/model/domain.js.map +1 -0
- package/dist/model/duration.d.ts +31 -0
- package/dist/model/duration.d.ts.map +1 -0
- package/dist/model/duration.js +136 -0
- package/dist/model/duration.js.map +1 -0
- package/dist/model/errors.d.ts +58 -0
- package/dist/model/errors.d.ts.map +1 -0
- package/dist/model/errors.js +81 -0
- package/dist/model/errors.js.map +1 -0
- package/dist/model/evolution.d.ts +177 -0
- package/dist/model/evolution.d.ts.map +1 -0
- package/dist/model/evolution.js +5 -0
- package/dist/model/evolution.js.map +1 -0
- package/dist/model/expr-children.d.ts +15 -0
- package/dist/model/expr-children.d.ts.map +1 -0
- package/dist/model/expr-children.js +45 -0
- package/dist/model/expr-children.js.map +1 -0
- package/dist/model/guards.d.ts +9 -0
- package/dist/model/guards.d.ts.map +1 -0
- package/dist/model/guards.js +11 -0
- package/dist/model/guards.js.map +1 -0
- package/dist/model/input.d.ts +42 -0
- package/dist/model/input.d.ts.map +1 -0
- package/dist/model/input.js +26 -0
- package/dist/model/input.js.map +1 -0
- package/dist/model/integer.d.ts +14 -0
- package/dist/model/integer.d.ts.map +1 -0
- package/dist/model/integer.js +16 -0
- package/dist/model/integer.js.map +1 -0
- package/dist/model/intrinsic.d.ts +18 -0
- package/dist/model/intrinsic.d.ts.map +1 -0
- package/dist/model/intrinsic.js +21 -0
- package/dist/model/intrinsic.js.map +1 -0
- package/dist/model/layout.d.ts +129 -0
- package/dist/model/layout.d.ts.map +1 -0
- package/dist/model/layout.js +2 -0
- package/dist/model/layout.js.map +1 -0
- package/dist/model/media.d.ts +33 -0
- package/dist/model/media.d.ts.map +1 -0
- package/dist/model/media.js +86 -0
- package/dist/model/media.js.map +1 -0
- package/dist/model/members.generated.d.ts +11 -0
- package/dist/model/members.generated.d.ts.map +1 -0
- package/dist/model/members.generated.js +71 -0
- package/dist/model/members.generated.js.map +1 -0
- package/dist/model/row-address.d.ts +27 -0
- package/dist/model/row-address.d.ts.map +1 -0
- package/dist/model/row-address.js +146 -0
- package/dist/model/row-address.js.map +1 -0
- package/dist/model/schema.d.ts +108 -0
- package/dist/model/schema.d.ts.map +1 -0
- package/dist/model/schema.js +2 -0
- package/dist/model/schema.js.map +1 -0
- package/dist/model/shape.d.ts +193 -0
- package/dist/model/shape.d.ts.map +1 -0
- package/dist/model/shape.js +2 -0
- package/dist/model/shape.js.map +1 -0
- package/dist/model/time.d.ts +61 -0
- package/dist/model/time.d.ts.map +1 -0
- package/dist/model/time.js +110 -0
- package/dist/model/time.js.map +1 -0
- package/dist/model/types.d.ts +1329 -0
- package/dist/model/types.d.ts.map +1 -0
- package/dist/model/types.js +424 -0
- package/dist/model/types.js.map +1 -0
- package/dist/model/values.d.ts +91 -0
- package/dist/model/values.d.ts.map +1 -0
- package/dist/model/values.js +195 -0
- package/dist/model/values.js.map +1 -0
- package/dist/model/wire.d.ts +356 -0
- package/dist/model/wire.d.ts.map +1 -0
- package/dist/model/wire.js +1504 -0
- package/dist/model/wire.js.map +1 -0
- package/dist/offline/index.d.ts +374 -0
- package/dist/offline/index.d.ts.map +1 -0
- package/dist/offline/index.js +422 -0
- package/dist/offline/index.js.map +1 -0
- package/dist/testing.d.ts +30 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +42 -0
- package/dist/testing.js.map +1 -0
- package/dist/version.d.ts +30 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +116 -0
- package/dist/version.js.map +1 -0
- package/package.json +98 -3
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A canonical plain copy of `value`: every profile violation is refused with the path and
|
|
3
|
+
* the offending class of value, and the copy is a plain
|
|
4
|
+
* tree that hashing and reporting can consume without a second walk. Callers that read
|
|
5
|
+
* untrusted values use this as the single implementation of the restricted profile.
|
|
6
|
+
*/
|
|
7
|
+
export declare function copyRestricted(value: unknown, path?: string): unknown;
|
|
8
|
+
/** The number of restricted canonicalisations since the process started. */
|
|
9
|
+
export declare function restrictedCanonicalizations(): number;
|
|
10
|
+
/**
|
|
11
|
+
* RFC 8785 text for a value that already satisfies the restricted profile, or a
|
|
12
|
+
* refusal naming the path and the offending class of value.
|
|
13
|
+
*/
|
|
14
|
+
export declare function canonicalizeRestricted(value: unknown): string;
|
|
15
|
+
/**
|
|
16
|
+
* RFC 8785 text for a value the engine itself built.
|
|
17
|
+
*
|
|
18
|
+
* This is the trusted entry, and `canonicalizeRestricted` above stays the profile's only
|
|
19
|
+
* parser and validator: the caller promises the work is already done.
|
|
20
|
+
*
|
|
21
|
+
* The caller promises all of:
|
|
22
|
+
*
|
|
23
|
+
* - every leaf is a canonical wire value — no `undefined`, no `-0`, no NaN, no non-integer
|
|
24
|
+
* or unsafe integer, no `BigInt`, no function, no symbol;
|
|
25
|
+
* - every object is a plain object carrying only enumerable own data members, so no
|
|
26
|
+
* accessor, no symbol key, no callable `toJSON`, no class instance, no `Decimal`;
|
|
27
|
+
* - every array is dense and carries no property other than its indices and `length`;
|
|
28
|
+
* - the tree is acyclic;
|
|
29
|
+
* - no string or member name holds an unpaired surrogate.
|
|
30
|
+
*
|
|
31
|
+
* Each promise is kept by a different authority before a report is assembled: the wire
|
|
32
|
+
* reader copies and validates every record value it hands out, a writer's result is
|
|
33
|
+
* rendered against its target declaration before the overlay holds it, and the artifact's
|
|
34
|
+
* own identifiers were checked by the compiler. `test/fuzz/restricted-json.test.ts` proves the
|
|
35
|
+
* bytes are the ones `canonicalizeRestricted` produces for every generated wire value, and
|
|
36
|
+
* `test/corpus/vector-parity.test.ts` proves them against the shipped vectors.
|
|
37
|
+
*/
|
|
38
|
+
export declare function canonicalizeOwned(value: unknown): string;
|
|
39
|
+
/** Lower-case hexadecimal SHA-256 of raw bytes. */
|
|
40
|
+
export declare function sha256HexOfBytes(bytes: Uint8Array): string;
|
|
41
|
+
/**
|
|
42
|
+
* Lower-case hexadecimal SHA-256 of `text`'s UTF-8 bytes. A lone surrogate has no UTF-8
|
|
43
|
+
* encoding — the encoder would substitute a replacement character, making two distinct
|
|
44
|
+
* strings hash alike — so it is refused rather than encoded.
|
|
45
|
+
*/
|
|
46
|
+
export declare function sha256Hex(text: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* The UTF-8 bytes of a string, for a caller holding text and a byte contract.
|
|
49
|
+
*
|
|
50
|
+
* `verifyArtifactHash` checks bytes, and a client's only copy of an artifact is usually text.
|
|
51
|
+
* The runtime ships its own encoder rather than reading a platform `TextEncoder`, because the
|
|
52
|
+
* Hermes build the bindings target is not required to provide one.
|
|
53
|
+
*/
|
|
54
|
+
export declare function utf8BytesOf(text: string): Uint8Array;
|
|
55
|
+
/**
|
|
56
|
+
* Lower-case hexadecimal SHA-256 of a value's restricted canonical form.
|
|
57
|
+
*
|
|
58
|
+
* The encoding reads the text directly rather than through `sha256Hex`, which scans for an
|
|
59
|
+
* unpaired surrogate: `canonicalizeRestricted` refused one at every string leaf and every member
|
|
60
|
+
* name (`checkedString`) before the text existed, so the scan would re-walk text the copy just
|
|
61
|
+
* proved clean. The refusal path is unchanged — a value carrying one never reaches this line —
|
|
62
|
+
* and `canonicalHashOwned` hashes its text the same way for the same reason. `sha256Hex` stays
|
|
63
|
+
* the entry for text a caller has not already held to the profile.
|
|
64
|
+
*/
|
|
65
|
+
export declare function canonicalHash(value: unknown): string;
|
|
66
|
+
/**
|
|
67
|
+
* Lower-case hexadecimal SHA-256 of an owned value's canonical form, for a value that keeps
|
|
68
|
+
* every promise `canonicalizeOwned` states.
|
|
69
|
+
*
|
|
70
|
+
* `sha256Hex` scans the text for an unpaired surrogate because the UTF-8 encoder would
|
|
71
|
+
* substitute a replacement character and two distinct values would hash alike. An owned
|
|
72
|
+
* value has no such string — the wire reader refuses one at the boundary — so the scan is
|
|
73
|
+
* a second walk over bytes that were just checked, and this entry hashes them directly.
|
|
74
|
+
*/
|
|
75
|
+
export declare function canonicalHashOwned(value: unknown): string;
|
|
76
|
+
export { parseRestrictedJson } from './restricted-json.js';
|
|
77
|
+
export * from './restricted-value.js';
|
|
78
|
+
//# sourceMappingURL=jcs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jcs.d.ts","sourceRoot":"","sources":["../../src/canonical/jcs.ts"],"names":[],"mappings":"AA6QA;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,SAAM,GAAG,OAAO,CAElE;AAiID,4EAA4E;AAC5E,wBAAgB,2BAA2B,IAAI,MAAM,CAEpD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAO7D;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAWxD;AAgHD,mDAAmD;AACnD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAE1D;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAU9C;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAUpD;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEzD;AAED,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
import { sha256 } from '@noble/hashes/sha2.js';
|
|
2
|
+
import { bytesToHex } from '@noble/hashes/utils.js';
|
|
3
|
+
import { Decimal } from 'decimal.js';
|
|
4
|
+
import { AxiomError } from '../model/errors.js';
|
|
5
|
+
import { isSafeInteger } from '../model/integer.js';
|
|
6
|
+
import { MAX_NESTING_DEPTH, closeList, describePrototype, emptyList, hasUnpairedSurrogate, objectShapeViolation, prototypeOf, setOwn, tooDeep, } from './restricted.js';
|
|
7
|
+
/**
|
|
8
|
+
* Restricted canonical JSON, `spec/semantics/canonical-v1.md` section 1.
|
|
9
|
+
*
|
|
10
|
+
* The profile is closed: a value outside it is refused with the path and the class of
|
|
11
|
+
* value found, never repaired. A silent coercion would produce a hash that no
|
|
12
|
+
* independent implementation could reproduce.
|
|
13
|
+
*/
|
|
14
|
+
function refuse(path, kind, remedy) {
|
|
15
|
+
throw new AxiomError('ENGINE_ERROR', `restricted JSON refuses ${kind}`, path, `restricted JSON refuses ${kind}; ${remedy}`);
|
|
16
|
+
}
|
|
17
|
+
function refuseDepth(path) {
|
|
18
|
+
const kind = `nesting deeper than ${String(MAX_NESTING_DEPTH)} levels`;
|
|
19
|
+
throw new AxiomError('ENGINE_ERROR', `restricted JSON refuses ${kind}`, path, `restricted JSON refuses ${kind}; flatten the value so nesting stays within ${String(MAX_NESTING_DEPTH)} levels`);
|
|
20
|
+
}
|
|
21
|
+
/** An own property that cannot be represented as a JSON member or a JSON element. */
|
|
22
|
+
function checkObjectShape(value, path) {
|
|
23
|
+
const violation = objectShapeViolation(value);
|
|
24
|
+
if (violation !== undefined)
|
|
25
|
+
refuse(path, violation, 'carry members as enumerable data under string names and without a callable toJSON; the profile admits data records only');
|
|
26
|
+
return Object.getOwnPropertyNames(value);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A record to fill. A `plain` copy is an ordinary object, because the caller that stores it
|
|
30
|
+
* reads it far more often than the walk writes it and `Object.create(null)` would leave it in
|
|
31
|
+
* dictionary mode; `setOwn` makes that fill safe. A `shielded` record is the serialiser's
|
|
32
|
+
* input and carries no prototype at all, so no inherited member can reach the serialiser.
|
|
33
|
+
*/
|
|
34
|
+
function emptyRecord(shape) {
|
|
35
|
+
// `Object.create(null)` is the one expression the standard library types as `any`; the
|
|
36
|
+
// assertion records the record it builds rather than widening the copy's type.
|
|
37
|
+
return shape === 'shielded' ? Object.create(null) : {};
|
|
38
|
+
}
|
|
39
|
+
/** Whether the value wraps a primitive rather than carrying a plain record. */
|
|
40
|
+
function isBoxedPrimitive(value) {
|
|
41
|
+
return (value instanceof String ||
|
|
42
|
+
value instanceof Number ||
|
|
43
|
+
value instanceof Boolean ||
|
|
44
|
+
value instanceof Symbol ||
|
|
45
|
+
value instanceof BigInt);
|
|
46
|
+
}
|
|
47
|
+
function checkedString(value, path) {
|
|
48
|
+
// A lone surrogate has no UTF-8 encoding, so hashing it would hash replacement
|
|
49
|
+
// characters and two distinct values would collide.
|
|
50
|
+
if (hasUnpairedSurrogate(value))
|
|
51
|
+
refuse(path, 'a string with an unpaired surrogate', 'state the string with paired surrogates or escape the lone unit; the profile admits only strings with UTF-8 form');
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
function isArrayValue(value) {
|
|
55
|
+
return Array.isArray(value);
|
|
56
|
+
}
|
|
57
|
+
function ownValue(value, key) {
|
|
58
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
59
|
+
return descriptor === undefined ? undefined : descriptor.value;
|
|
60
|
+
}
|
|
61
|
+
function copyArray(value, path, seen, depth, shape) {
|
|
62
|
+
// The bound counts containers, so it is checked where one is opened. Counting values
|
|
63
|
+
// instead would admit an empty innermost container the profile refuses.
|
|
64
|
+
if (tooDeep(depth + 1))
|
|
65
|
+
refuseDepth(path);
|
|
66
|
+
// An `Array` subclass carries a prototype whose behaviour a canonical form would not
|
|
67
|
+
// preserve, so it is refused like any other non-plain object.
|
|
68
|
+
if (Reflect.getPrototypeOf(value) !== Array.prototype)
|
|
69
|
+
refuse(path, 'an Array subclass', 'use a plain array; the profile admits dense arrays with the ordinary prototype and no extra members');
|
|
70
|
+
const names = checkObjectShape(value, path);
|
|
71
|
+
const copy = emptyList();
|
|
72
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
73
|
+
const childPath = `${path}[${String(index)}]`;
|
|
74
|
+
if (!Object.hasOwn(value, index))
|
|
75
|
+
refuse(childPath, 'a sparse array', 'state every index from 0 to length minus 1; the profile admits dense arrays only');
|
|
76
|
+
copy[index] = copyValue(value[index], childPath, seen, depth + 1, shape);
|
|
77
|
+
}
|
|
78
|
+
if (names.length !== value.length + 1)
|
|
79
|
+
refuse(path, 'a non-index array property', 'carry only indices and length on an array; the profile admits no extra array members');
|
|
80
|
+
closeList(copy, shape);
|
|
81
|
+
return copy;
|
|
82
|
+
}
|
|
83
|
+
function copyRecord(value, path, seen, depth, shape) {
|
|
84
|
+
if (tooDeep(depth + 1))
|
|
85
|
+
refuseDepth(path);
|
|
86
|
+
if (value instanceof Decimal)
|
|
87
|
+
refuse(path, 'a Decimal instance', 'carry a decimal as a string, such as "1.5"; the profile admits strings, not class instances');
|
|
88
|
+
if (isBoxedPrimitive(value))
|
|
89
|
+
refuse(path, 'a boxed primitive', 'carry the primitive value itself; the profile admits strings, booleans and safe integers, not wrappers');
|
|
90
|
+
// Refuse a custom prototype before reading any of its property behaviour.
|
|
91
|
+
const prototype = prototypeOf(value);
|
|
92
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
93
|
+
refuse(path, describePrototype(value), 'use a plain object or one with no prototype; the profile admits records with Object.prototype or no prototype only');
|
|
94
|
+
}
|
|
95
|
+
const copy = emptyRecord(shape);
|
|
96
|
+
for (const key of checkObjectShape(value, path)) {
|
|
97
|
+
const childPath = `${path}.${key}`;
|
|
98
|
+
setOwn(copy, checkedString(key, childPath), copyValue(ownValue(value, key), childPath, seen, depth + 1, shape));
|
|
99
|
+
}
|
|
100
|
+
return copy;
|
|
101
|
+
}
|
|
102
|
+
function copyValue(value, path, seen, depth, shape) {
|
|
103
|
+
switch (typeof value) {
|
|
104
|
+
case 'string':
|
|
105
|
+
return checkedString(value, path);
|
|
106
|
+
case 'boolean':
|
|
107
|
+
return value;
|
|
108
|
+
case 'number':
|
|
109
|
+
if (Object.is(value, -0))
|
|
110
|
+
refuse(path, 'negative zero', 'write 0 instead; the profile admits the integer 0, never negative zero');
|
|
111
|
+
if (!Number.isFinite(value))
|
|
112
|
+
refuse(path, 'NaN or Infinity', 'state a safe integer or omit the member; the profile admits finite integers only');
|
|
113
|
+
if (!Number.isInteger(value)) {
|
|
114
|
+
// The repair, not only the fact: a host that serialises a decimal as a JSON number hits
|
|
115
|
+
// this on its first document, and the answer is to carry it as a string. The clause
|
|
116
|
+
// stays in the message because the submission boundary reports the message verbatim;
|
|
117
|
+
// the detail adds the admitted set beside it.
|
|
118
|
+
refuse(path, 'a non-integer number — carry a decimal as a string, such as "1.5"', 'the profile admits safe integers, and decimal text only as strings');
|
|
119
|
+
}
|
|
120
|
+
if (!isSafeInteger(value))
|
|
121
|
+
refuse(path, 'an unsafe integer', 'keep the integer inside -(2^53 - 1)..(2^53 - 1); the profile admits safe integers only');
|
|
122
|
+
return value;
|
|
123
|
+
case 'bigint':
|
|
124
|
+
return refuse(path, 'BigInt', 'carry the value as a string or a safe integer; the profile admits no BigInt values');
|
|
125
|
+
case 'undefined':
|
|
126
|
+
return refuse(path, 'undefined', 'omit the member or state null; the profile admits null, never undefined');
|
|
127
|
+
case 'function':
|
|
128
|
+
return refuse(path, 'a function', 'omit the member; the profile admits data only, never functions');
|
|
129
|
+
case 'symbol':
|
|
130
|
+
return refuse(path, 'a symbol', 'use a string instead; the profile admits strings, never symbols');
|
|
131
|
+
case 'object': {
|
|
132
|
+
if (value === null)
|
|
133
|
+
return null;
|
|
134
|
+
if (seen.has(value))
|
|
135
|
+
refuse(path, 'a cycle', 'repeat the shared subtree at each place or omit the repeated member; the profile admits trees, never cycles');
|
|
136
|
+
// One ancestor set with backtracking: copying the set per node would make the walk
|
|
137
|
+
// O(nodes x depth) and allocate a set at every level of a nested record.
|
|
138
|
+
seen.add(value);
|
|
139
|
+
const copy = isArrayValue(value)
|
|
140
|
+
? copyArray(value, path, seen, depth, shape)
|
|
141
|
+
: copyRecord(value, path, seen, depth, shape);
|
|
142
|
+
seen.delete(value);
|
|
143
|
+
return copy;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* A canonical plain copy of `value`: every profile violation is refused with the path and
|
|
149
|
+
* the offending class of value, and the copy is a plain
|
|
150
|
+
* tree that hashing and reporting can consume without a second walk. Callers that read
|
|
151
|
+
* untrusted values use this as the single implementation of the restricted profile.
|
|
152
|
+
*/
|
|
153
|
+
export function copyRestricted(value, path = '$') {
|
|
154
|
+
return copyValue(value, path, new Set(), 0, 'plain');
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The copy the serialiser is handed: the same tree, built on containers with no prototype.
|
|
158
|
+
*
|
|
159
|
+
* The serialiser below reads only own members and array indices, so a host that assigned
|
|
160
|
+
* `Object.prototype.toJSON`, `Array.prototype.toJSON` or any other inherited name cannot
|
|
161
|
+
* replace a container in the document: records carry no prototype at all, and an array is read
|
|
162
|
+
* by index and `length`, so nothing on its prototype contributes to the text. The bytes the
|
|
163
|
+
* engine commits to are a function of the copied data alone. The copy a caller receives keeps
|
|
164
|
+
* its ordinary prototypes, because it is a value rather than a serialisation input.
|
|
165
|
+
*/
|
|
166
|
+
function shieldedCopy(value) {
|
|
167
|
+
return copyValue(value, '$', new Set(), 0, 'shielded');
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* RFC 8785 text for one shielded value, or `undefined` for a value with no JSON form.
|
|
171
|
+
*
|
|
172
|
+
* The tree the copy built is already restricted: `null`, booleans, safe integers, strings with
|
|
173
|
+
* no unpaired surrogate, dense arrays and records with own enumerable members. So the
|
|
174
|
+
* serializer can be small and total over that tree, and — this is the point — it never reads a
|
|
175
|
+
* prototype method: array elements are read by index, record members by `Object.keys`, and
|
|
176
|
+
* strings and numbers by the platform's JSON-safe spellings.
|
|
177
|
+
*
|
|
178
|
+
* This is hand-rolled for two constraints the adopted `canonicalize` library could not meet.
|
|
179
|
+
* Its 5.x line calls `String.prototype.isWellFormed`, an ES2024 method the ES2023 / Hermes V1
|
|
180
|
+
* target does not provide. Its 4.x line reads `toJSON` through the prototype chain and calls
|
|
181
|
+
* `Array.prototype.map`, so an inherited name on a container — the exact ambient dependence the
|
|
182
|
+
* shielded copy exists to exclude — could decide the bytes. A hard floor and the shield are both
|
|
183
|
+
* non-negotiable, so the serializer lives here and the dependency is gone; `canonical.test.ts`
|
|
184
|
+
* pins the bytes from vectors the serializer did not produce.
|
|
185
|
+
*
|
|
186
|
+
* A number is written with `String`, which is the same ECMAScript number-to-string RFC 8785
|
|
187
|
+
* names; every non-integer, unsafe integer, `-0`, NaN and infinity was refused by the copy.
|
|
188
|
+
* A string is written with `JSON.stringify`, which is the RFC's own quote rule and escapes
|
|
189
|
+
* control characters without escaping non-ASCII. `Object.keys(...).sort()` orders by UTF-16
|
|
190
|
+
* code unit, the order JCS requires, and the copy has already refused a non-index array
|
|
191
|
+
* property and a sparse array.
|
|
192
|
+
*/
|
|
193
|
+
function serializeShielded(value, path) {
|
|
194
|
+
if (value === null)
|
|
195
|
+
return 'null';
|
|
196
|
+
switch (typeof value) {
|
|
197
|
+
case 'string':
|
|
198
|
+
return JSON.stringify(value);
|
|
199
|
+
case 'number':
|
|
200
|
+
return String(value);
|
|
201
|
+
case 'boolean':
|
|
202
|
+
return value ? 'true' : 'false';
|
|
203
|
+
case 'object':
|
|
204
|
+
return isArrayValue(value) ? serializeList(value, path) : serializeRecord(value, path);
|
|
205
|
+
default:
|
|
206
|
+
// A value the trusted copy passed through unchanged: no JSON form, refused by the
|
|
207
|
+
// caller with the path that reached it.
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function serializeList(items, path) {
|
|
212
|
+
let text = '[';
|
|
213
|
+
for (let index = 0; index < items.length; index += 1) {
|
|
214
|
+
if (index > 0)
|
|
215
|
+
text += ',';
|
|
216
|
+
const at = `${path}[${String(index)}]`;
|
|
217
|
+
const element = serializeShielded(items[index], at);
|
|
218
|
+
if (element === undefined)
|
|
219
|
+
throw brokenPromise(at, items[index]);
|
|
220
|
+
text += element;
|
|
221
|
+
}
|
|
222
|
+
return `${text}]`;
|
|
223
|
+
}
|
|
224
|
+
function serializeRecord(record, path) {
|
|
225
|
+
const names = Object.keys(record).sort();
|
|
226
|
+
let text = '{';
|
|
227
|
+
let first = true;
|
|
228
|
+
for (const name of names) {
|
|
229
|
+
const member = Reflect.get(record, name);
|
|
230
|
+
const at = `${path}.${name}`;
|
|
231
|
+
const spelled = serializeShielded(member, at);
|
|
232
|
+
if (spelled === undefined)
|
|
233
|
+
throw brokenPromise(at, member);
|
|
234
|
+
text += first ? '' : ',';
|
|
235
|
+
first = false;
|
|
236
|
+
text += JSON.stringify(name);
|
|
237
|
+
text += ':';
|
|
238
|
+
text += spelled;
|
|
239
|
+
}
|
|
240
|
+
return `${text}}`;
|
|
241
|
+
}
|
|
242
|
+
/** The class of an owned value with no JSON form, named without quoting the value. */
|
|
243
|
+
function refusedKind(value) {
|
|
244
|
+
switch (typeof value) {
|
|
245
|
+
case 'undefined':
|
|
246
|
+
return 'undefined';
|
|
247
|
+
case 'function':
|
|
248
|
+
return 'a function';
|
|
249
|
+
case 'symbol':
|
|
250
|
+
return 'a symbol';
|
|
251
|
+
case 'bigint':
|
|
252
|
+
return 'a BigInt value';
|
|
253
|
+
case 'object':
|
|
254
|
+
return 'an unserializable object';
|
|
255
|
+
default:
|
|
256
|
+
return `type ${typeof value}`;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* A nested value with no JSON form. The owned entry's promise is broken here: the refusal
|
|
261
|
+
* names the member path that carried the value and the class the caller promised never to
|
|
262
|
+
* hold, so a host finds the member that broke the promise instead of searching from `$`.
|
|
263
|
+
*/
|
|
264
|
+
function brokenPromise(path, value) {
|
|
265
|
+
return new AxiomError('ENGINE_ERROR', `owned value carries ${refusedKind(value)}, which has no canonical form; the caller promised canonical wire values only`, path);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* The restricted canonicalisations this process has performed.
|
|
269
|
+
*
|
|
270
|
+
* A measurement hook, never an input: no decision reads it. It exists so a benchmark can state
|
|
271
|
+
* the canonical work one evaluation performs — and fail a count gate when a cache regresses —
|
|
272
|
+
* instead of asserting a wall-clock duration, which is not a property of the code. Its reader is
|
|
273
|
+
* published on `@azx-pbc/axiom-runtime/testing`; the host doors state no counter.
|
|
274
|
+
*/
|
|
275
|
+
let canonicalisationCount = 0;
|
|
276
|
+
/** The number of restricted canonicalisations since the process started. */
|
|
277
|
+
export function restrictedCanonicalizations() {
|
|
278
|
+
return canonicalisationCount;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* RFC 8785 text for a value that already satisfies the restricted profile, or a
|
|
282
|
+
* refusal naming the path and the offending class of value.
|
|
283
|
+
*/
|
|
284
|
+
export function canonicalizeRestricted(value) {
|
|
285
|
+
const text = serializeShielded(shieldedCopy(value), '$');
|
|
286
|
+
if (text === undefined) {
|
|
287
|
+
throw brokenPromise('$', value);
|
|
288
|
+
}
|
|
289
|
+
canonicalisationCount += 1;
|
|
290
|
+
return text;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* RFC 8785 text for a value the engine itself built.
|
|
294
|
+
*
|
|
295
|
+
* This is the trusted entry, and `canonicalizeRestricted` above stays the profile's only
|
|
296
|
+
* parser and validator: the caller promises the work is already done.
|
|
297
|
+
*
|
|
298
|
+
* The caller promises all of:
|
|
299
|
+
*
|
|
300
|
+
* - every leaf is a canonical wire value — no `undefined`, no `-0`, no NaN, no non-integer
|
|
301
|
+
* or unsafe integer, no `BigInt`, no function, no symbol;
|
|
302
|
+
* - every object is a plain object carrying only enumerable own data members, so no
|
|
303
|
+
* accessor, no symbol key, no callable `toJSON`, no class instance, no `Decimal`;
|
|
304
|
+
* - every array is dense and carries no property other than its indices and `length`;
|
|
305
|
+
* - the tree is acyclic;
|
|
306
|
+
* - no string or member name holds an unpaired surrogate.
|
|
307
|
+
*
|
|
308
|
+
* Each promise is kept by a different authority before a report is assembled: the wire
|
|
309
|
+
* reader copies and validates every record value it hands out, a writer's result is
|
|
310
|
+
* rendered against its target declaration before the overlay holds it, and the artifact's
|
|
311
|
+
* own identifiers were checked by the compiler. `test/fuzz/restricted-json.test.ts` proves the
|
|
312
|
+
* bytes are the ones `canonicalizeRestricted` produces for every generated wire value, and
|
|
313
|
+
* `test/corpus/vector-parity.test.ts` proves them against the shipped vectors.
|
|
314
|
+
*/
|
|
315
|
+
export function canonicalizeOwned(value) {
|
|
316
|
+
// One RFC 8785 implementation serves both entries, so the trusted path cannot drift from
|
|
317
|
+
// the untrusted one, and both hand it a shielded copy. This entry skips the profile's
|
|
318
|
+
// *checks*, which the promise above has already discharged — not the shield.
|
|
319
|
+
const text = serializeShielded(shieldedOwnedCopy(value), '$');
|
|
320
|
+
// `undefined` is the one input the trusted copy passes through unchanged, and a promise that
|
|
321
|
+
// was broken is refused at the member path that carried it rather than at no place at all.
|
|
322
|
+
if (text === undefined) {
|
|
323
|
+
throw brokenPromise('$', value);
|
|
324
|
+
}
|
|
325
|
+
return text;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* The serialiser input for a value the engine owns: the same tree on prototype-less
|
|
329
|
+
* containers, copied without the profile's checks that `canonicalizeOwned`'s caller has
|
|
330
|
+
* already discharged.
|
|
331
|
+
*
|
|
332
|
+
* It still copies for the reason `shieldedCopy` states: a host-installed
|
|
333
|
+
* `Object.prototype.toJSON` (or any other inherited name) must not decide a report's bytes, so
|
|
334
|
+
* an uncopied report body would serialise to whatever that member returned, and two different
|
|
335
|
+
* bodies would seal with one `reportHash`.
|
|
336
|
+
*
|
|
337
|
+
* Own enumerable members are the only ones visited (`Object.keys`), and each is read after
|
|
338
|
+
* its own key is in hand, so an inherited member is never reached and the promise above
|
|
339
|
+
* already excludes an accessor.
|
|
340
|
+
*/
|
|
341
|
+
function shieldedOwnedCopy(value) {
|
|
342
|
+
if (value === null || typeof value !== 'object')
|
|
343
|
+
return value;
|
|
344
|
+
if (isArrayValue(value)) {
|
|
345
|
+
const items = emptyList();
|
|
346
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
347
|
+
items[index] = shieldedOwnedCopy(value[index]);
|
|
348
|
+
}
|
|
349
|
+
return items;
|
|
350
|
+
}
|
|
351
|
+
// An engine value with own enumerable members is a record, and each read below is by that
|
|
352
|
+
// own key, so no inherited member is reached.
|
|
353
|
+
const record = value;
|
|
354
|
+
const copy = emptyRecord('shielded');
|
|
355
|
+
for (const key of Object.keys(record)) {
|
|
356
|
+
setOwn(copy, key, shieldedOwnedCopy(record[key]));
|
|
357
|
+
}
|
|
358
|
+
return copy;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Encodes a UTF-16 string into UTF-8 bytes per RFC 3629 without reading a platform `TextEncoder`.
|
|
362
|
+
*
|
|
363
|
+
* Callers validate surrogate pairing before invoking this helper; if an unpaired surrogate still
|
|
364
|
+
* reaches it, U+FFFD is emitted to match RFC 3629. Two passes avoid over-allocating or copying
|
|
365
|
+
* buffers, and pure-ASCII strings take a direct single-byte loop.
|
|
366
|
+
*/
|
|
367
|
+
function encodeUtf8(text) {
|
|
368
|
+
const length = text.length;
|
|
369
|
+
let byteLength = 0;
|
|
370
|
+
for (let index = 0; index < length; index += 1) {
|
|
371
|
+
const unit = text.charCodeAt(index);
|
|
372
|
+
if (unit < 0x80) {
|
|
373
|
+
byteLength += 1;
|
|
374
|
+
}
|
|
375
|
+
else if (unit < 0x800) {
|
|
376
|
+
byteLength += 2;
|
|
377
|
+
}
|
|
378
|
+
else if (unit >= 0xd800 && unit <= 0xdbff) {
|
|
379
|
+
const next = index + 1 < length ? text.charCodeAt(index + 1) : 0;
|
|
380
|
+
if (next >= 0xdc00 && next <= 0xdfff) {
|
|
381
|
+
byteLength += 4;
|
|
382
|
+
index += 1;
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
byteLength += 3;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
byteLength += 3;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
const out = new Uint8Array(byteLength);
|
|
393
|
+
// Every non-ASCII code unit adds at least one extra byte, so equality proves pure ASCII.
|
|
394
|
+
if (byteLength === length) {
|
|
395
|
+
for (let index = 0; index < length; index += 1) {
|
|
396
|
+
out[index] = text.charCodeAt(index);
|
|
397
|
+
}
|
|
398
|
+
return out;
|
|
399
|
+
}
|
|
400
|
+
let offset = 0;
|
|
401
|
+
for (let index = 0; index < length; index += 1) {
|
|
402
|
+
const unit = text.charCodeAt(index);
|
|
403
|
+
if (unit < 0x80) {
|
|
404
|
+
out[offset] = unit;
|
|
405
|
+
offset += 1;
|
|
406
|
+
}
|
|
407
|
+
else if (unit < 0x800) {
|
|
408
|
+
out[offset] = 0xc0 | (unit >> 6);
|
|
409
|
+
out[offset + 1] = 0x80 | (unit & 0x3f);
|
|
410
|
+
offset += 2;
|
|
411
|
+
}
|
|
412
|
+
else if (unit >= 0xd800 && unit <= 0xdbff) {
|
|
413
|
+
const next = index + 1 < length ? text.charCodeAt(index + 1) : 0;
|
|
414
|
+
if (next >= 0xdc00 && next <= 0xdfff) {
|
|
415
|
+
const codePoint = 0x10000 + ((unit - 0xd800) << 10) + (next - 0xdc00);
|
|
416
|
+
out[offset] = 0xf0 | (codePoint >> 18);
|
|
417
|
+
out[offset + 1] = 0x80 | ((codePoint >> 12) & 0x3f);
|
|
418
|
+
out[offset + 2] = 0x80 | ((codePoint >> 6) & 0x3f);
|
|
419
|
+
out[offset + 3] = 0x80 | (codePoint & 0x3f);
|
|
420
|
+
offset += 4;
|
|
421
|
+
index += 1;
|
|
422
|
+
}
|
|
423
|
+
else {
|
|
424
|
+
out[offset] = 0xef;
|
|
425
|
+
out[offset + 1] = 0xbf;
|
|
426
|
+
out[offset + 2] = 0xbd;
|
|
427
|
+
offset += 3;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
else if (unit >= 0xdc00 && unit <= 0xdfff) {
|
|
431
|
+
out[offset] = 0xef;
|
|
432
|
+
out[offset + 1] = 0xbf;
|
|
433
|
+
out[offset + 2] = 0xbd;
|
|
434
|
+
offset += 3;
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
out[offset] = 0xe0 | (unit >> 12);
|
|
438
|
+
out[offset + 1] = 0x80 | ((unit >> 6) & 0x3f);
|
|
439
|
+
out[offset + 2] = 0x80 | (unit & 0x3f);
|
|
440
|
+
offset += 3;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
return out;
|
|
444
|
+
}
|
|
445
|
+
/** Lower-case hexadecimal SHA-256 of raw bytes. */
|
|
446
|
+
export function sha256HexOfBytes(bytes) {
|
|
447
|
+
return bytesToHex(sha256(bytes));
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Lower-case hexadecimal SHA-256 of `text`'s UTF-8 bytes. A lone surrogate has no UTF-8
|
|
451
|
+
* encoding — the encoder would substitute a replacement character, making two distinct
|
|
452
|
+
* strings hash alike — so it is refused rather than encoded.
|
|
453
|
+
*/
|
|
454
|
+
export function sha256Hex(text) {
|
|
455
|
+
if (hasUnpairedSurrogate(text)) {
|
|
456
|
+
throw new AxiomError('ENGINE_ERROR', 'a string with an unpaired surrogate has no UTF-8 form', '', 'a string with an unpaired surrogate has no UTF-8 form; pair the surrogate or escape the unit so the text has UTF-8 form');
|
|
457
|
+
}
|
|
458
|
+
return sha256HexOfBytes(encodeUtf8(text));
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* The UTF-8 bytes of a string, for a caller holding text and a byte contract.
|
|
462
|
+
*
|
|
463
|
+
* `verifyArtifactHash` checks bytes, and a client's only copy of an artifact is usually text.
|
|
464
|
+
* The runtime ships its own encoder rather than reading a platform `TextEncoder`, because the
|
|
465
|
+
* Hermes build the bindings target is not required to provide one.
|
|
466
|
+
*/
|
|
467
|
+
export function utf8BytesOf(text) {
|
|
468
|
+
if (hasUnpairedSurrogate(text)) {
|
|
469
|
+
throw new AxiomError('ENGINE_ERROR', 'a string with an unpaired surrogate has no UTF-8 form', '', 'a string with an unpaired surrogate has no UTF-8 form; pair the surrogate or escape the unit so the text has UTF-8 form');
|
|
470
|
+
}
|
|
471
|
+
return encodeUtf8(text);
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Lower-case hexadecimal SHA-256 of a value's restricted canonical form.
|
|
475
|
+
*
|
|
476
|
+
* The encoding reads the text directly rather than through `sha256Hex`, which scans for an
|
|
477
|
+
* unpaired surrogate: `canonicalizeRestricted` refused one at every string leaf and every member
|
|
478
|
+
* name (`checkedString`) before the text existed, so the scan would re-walk text the copy just
|
|
479
|
+
* proved clean. The refusal path is unchanged — a value carrying one never reaches this line —
|
|
480
|
+
* and `canonicalHashOwned` hashes its text the same way for the same reason. `sha256Hex` stays
|
|
481
|
+
* the entry for text a caller has not already held to the profile.
|
|
482
|
+
*/
|
|
483
|
+
export function canonicalHash(value) {
|
|
484
|
+
return sha256HexOfBytes(encodeUtf8(canonicalizeRestricted(value)));
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Lower-case hexadecimal SHA-256 of an owned value's canonical form, for a value that keeps
|
|
488
|
+
* every promise `canonicalizeOwned` states.
|
|
489
|
+
*
|
|
490
|
+
* `sha256Hex` scans the text for an unpaired surrogate because the UTF-8 encoder would
|
|
491
|
+
* substitute a replacement character and two distinct values would hash alike. An owned
|
|
492
|
+
* value has no such string — the wire reader refuses one at the boundary — so the scan is
|
|
493
|
+
* a second walk over bytes that were just checked, and this entry hashes them directly.
|
|
494
|
+
*/
|
|
495
|
+
export function canonicalHashOwned(value) {
|
|
496
|
+
return sha256HexOfBytes(encodeUtf8(canonicalizeOwned(value)));
|
|
497
|
+
}
|
|
498
|
+
export { parseRestrictedJson } from './restricted-json.js';
|
|
499
|
+
export * from './restricted-value.js';
|
|
500
|
+
//# sourceMappingURL=jcs.js.map
|