@azx-pbc/axiom-runtime 0.0.0-stage → 0.0.1
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 +1207 -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,156 @@
|
|
|
1
|
+
import { isSafeInteger } from '../model/integer.js';
|
|
2
|
+
import { INTEGER_TEXT_PATTERN } from '../model/types.js';
|
|
3
|
+
import { MAX_NESTING_DEPTH, describePrototype, hasUnpairedSurrogate, memberPath, objectShapeViolation, tooDeep, } from './restricted.js';
|
|
4
|
+
/**
|
|
5
|
+
* Why a number handed over as a value is outside the profile, or `undefined` when it is inside.
|
|
6
|
+
*
|
|
7
|
+
* The spelling is not available here, so a float is named by its shortest JavaScript spelling.
|
|
8
|
+
* The text reader uses `restrictedNumberTextRefusal` instead, which names the spelling the
|
|
9
|
+
* document actually wrote; the reason and the message shape are the same.
|
|
10
|
+
*/
|
|
11
|
+
export function restrictedNumberViolation(value) {
|
|
12
|
+
if (Object.is(value, -0))
|
|
13
|
+
return { reason: 'negative_zero', detail: 'negative zero' };
|
|
14
|
+
if (!Number.isFinite(value) || !Number.isInteger(value)) {
|
|
15
|
+
return {
|
|
16
|
+
reason: 'integer',
|
|
17
|
+
detail: `not a canonical JSON integer: ${JSON.stringify(String(value))}`,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
if (!isSafeInteger(value))
|
|
21
|
+
return { reason: 'unsafe_integer', detail: 'unsafe integer' };
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Why a numeric spelling is outside the profile, or `undefined` when it is inside.
|
|
26
|
+
*
|
|
27
|
+
* This is the one implementation of the profile's number rule: the JSON reader hands it the
|
|
28
|
+
* token it scanned, and the YAML front door hands it the source text of a plain numeric scalar,
|
|
29
|
+
* so a document cannot be refused for `1e3` on one path and admitted on the other.
|
|
30
|
+
*/
|
|
31
|
+
export function restrictedNumberTextRefusal(text) {
|
|
32
|
+
if (text === '-0')
|
|
33
|
+
return { reason: 'negative_zero', detail: 'negative zero' };
|
|
34
|
+
if (!INTEGER_TEXT_PATTERN.test(text)) {
|
|
35
|
+
return { reason: 'integer', detail: `not a canonical JSON integer: ${JSON.stringify(text)}` };
|
|
36
|
+
}
|
|
37
|
+
// The spelling is a canonical integer, so anything outside the safe range is an unsafe
|
|
38
|
+
// integer — including a token long enough to overflow to `Infinity`. Routing that through
|
|
39
|
+
// `restrictedNumberViolation` would report it as a non-integer, because a double cannot tell
|
|
40
|
+
// an overflowed integer from a document that wrote `1e400`: the spelling is the fact, so it
|
|
41
|
+
// decides which refusal the document earned.
|
|
42
|
+
const value = Number(text);
|
|
43
|
+
if (!isSafeInteger(value))
|
|
44
|
+
return { reason: 'unsafe_integer', detail: 'unsafe integer' };
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
function refuse(path, reason, detail) {
|
|
48
|
+
return { path, reason, detail };
|
|
49
|
+
}
|
|
50
|
+
/** Whether a value is an array whose prototype is the ordinary one. */
|
|
51
|
+
function isPlainArray(value) {
|
|
52
|
+
return Array.isArray(value) && Reflect.getPrototypeOf(value) === Array.prototype;
|
|
53
|
+
}
|
|
54
|
+
function walkArray(value, path, ancestors, depth) {
|
|
55
|
+
if (!isPlainArray(value))
|
|
56
|
+
return refuse(path, 'non_json_value', 'an Array subclass');
|
|
57
|
+
// A symbol key, an accessor, a non-enumerable member other than `length`, or an own callable
|
|
58
|
+
// `toJSON` has no canonical JSON spelling, so arrays share the same shape check as records and
|
|
59
|
+
// `copyRestricted` before any element is read.
|
|
60
|
+
const shape = objectShapeViolation(value);
|
|
61
|
+
if (shape !== undefined)
|
|
62
|
+
return refuse(path, 'non_json_value', shape);
|
|
63
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
64
|
+
const childPath = `${path}[${String(index)}]`;
|
|
65
|
+
if (!Object.hasOwn(value, index))
|
|
66
|
+
return refuse(childPath, 'non_json_value', 'a sparse array');
|
|
67
|
+
const refusal = walkValue(value[index], childPath, ancestors, depth + 1);
|
|
68
|
+
if (refusal !== undefined)
|
|
69
|
+
return refusal;
|
|
70
|
+
}
|
|
71
|
+
// The one non-enumerable member an array may carry is its own `length`; any other name is a
|
|
72
|
+
// member a JSON list cannot express.
|
|
73
|
+
if (Object.getOwnPropertyNames(value).length !== value.length + 1) {
|
|
74
|
+
return refuse(path, 'non_json_value', 'a non-index array property');
|
|
75
|
+
}
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
function walkRecord(value, path, ancestors, depth) {
|
|
79
|
+
const prototype = Reflect.getPrototypeOf(value);
|
|
80
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
81
|
+
return refuse(path, 'non_json_value', describePrototype(value));
|
|
82
|
+
}
|
|
83
|
+
// A symbol key, an accessor, a non-enumerable member or an own callable `toJSON` has no
|
|
84
|
+
// canonical JSON spelling, so the object is refused before any of its behaviour is read.
|
|
85
|
+
const shape = objectShapeViolation(value);
|
|
86
|
+
if (shape !== undefined)
|
|
87
|
+
return refuse(path, 'non_json_value', shape);
|
|
88
|
+
for (const key of Object.keys(value)) {
|
|
89
|
+
const childPath = memberPath(path, key);
|
|
90
|
+
if (hasUnpairedSurrogate(key)) {
|
|
91
|
+
return refuse(childPath, 'unpaired_surrogate', 'string carries an unpaired surrogate');
|
|
92
|
+
}
|
|
93
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
94
|
+
if (descriptor === undefined || !('value' in descriptor)) {
|
|
95
|
+
return refuse(childPath, 'non_json_value', 'an accessor property');
|
|
96
|
+
}
|
|
97
|
+
const refusal = walkValue(descriptor.value, childPath, ancestors, depth + 1);
|
|
98
|
+
if (refusal !== undefined)
|
|
99
|
+
return refusal;
|
|
100
|
+
}
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
function walkValue(value, path, ancestors, depth) {
|
|
104
|
+
switch (typeof value) {
|
|
105
|
+
case 'string':
|
|
106
|
+
return hasUnpairedSurrogate(value)
|
|
107
|
+
? refuse(path, 'unpaired_surrogate', 'string carries an unpaired surrogate')
|
|
108
|
+
: undefined;
|
|
109
|
+
case 'boolean':
|
|
110
|
+
return undefined;
|
|
111
|
+
case 'number': {
|
|
112
|
+
const numberRefusal = restrictedNumberViolation(value);
|
|
113
|
+
return numberRefusal === undefined
|
|
114
|
+
? undefined
|
|
115
|
+
: refuse(path, numberRefusal.reason, numberRefusal.detail);
|
|
116
|
+
}
|
|
117
|
+
case 'bigint':
|
|
118
|
+
return refuse(path, 'non_json_value', 'a BigInt value');
|
|
119
|
+
case 'undefined':
|
|
120
|
+
return refuse(path, 'non_json_value', 'undefined');
|
|
121
|
+
case 'function':
|
|
122
|
+
return refuse(path, 'non_json_value', 'a function');
|
|
123
|
+
case 'symbol':
|
|
124
|
+
return refuse(path, 'non_json_value', 'a symbol');
|
|
125
|
+
case 'object': {
|
|
126
|
+
if (value === null)
|
|
127
|
+
return undefined;
|
|
128
|
+
if (ancestors.has(value)) {
|
|
129
|
+
return refuse(path, 'cycle', 'an alias that constructs a cycle');
|
|
130
|
+
}
|
|
131
|
+
// The bound counts containers, so it is checked where one is opened, exactly as the text
|
|
132
|
+
// reader and the canonical copier check it.
|
|
133
|
+
if (tooDeep(depth + 1)) {
|
|
134
|
+
return refuse(path, 'nesting', `nesting deeper than ${String(MAX_NESTING_DEPTH)} levels`);
|
|
135
|
+
}
|
|
136
|
+
ancestors.add(value);
|
|
137
|
+
const refusal = Array.isArray(value)
|
|
138
|
+
? walkArray(value, path, ancestors, depth)
|
|
139
|
+
: walkRecord(value, path, ancestors, depth);
|
|
140
|
+
ancestors.delete(value);
|
|
141
|
+
return refusal;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* The first reason a plain JavaScript value is outside the restricted profile, or `undefined`
|
|
147
|
+
* when the profile admits it.
|
|
148
|
+
*
|
|
149
|
+
* The walk is total over `unknown` and never throws for a value it refuses. It keeps an ancestor
|
|
150
|
+
* set rather than a visited set, so one value reached twice through two aliases is an ordinary
|
|
151
|
+
* shared subtree while a value reached from itself is the cycle it is.
|
|
152
|
+
*/
|
|
153
|
+
export function restrictedValueRefusal(value) {
|
|
154
|
+
return walkValue(value, '$', new Set(), 0);
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=restricted-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restricted-value.js","sourceRoot":"","sources":["../../src/canonical/restricted-value.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,UAAU,EACV,oBAAoB,EACpB,OAAO,GACR,MAAM,iBAAiB,CAAC;AA0BzB;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAa;IACrD,IAAI,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;IACtF,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACxD,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,iCAAiC,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,GAAG,CAAC,KAAK,CAAC,CAAC;YACrB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;gBAClC,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC;gBAC1C,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;YAC9C,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACxB,OAAO,OAAO,CAAC;QACjB,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACnD,OAAO,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import type { JsonIngestReason } from '../model/errors.js';\nimport { isSafeInteger } from '../model/integer.js';\nimport { INTEGER_TEXT_PATTERN } from '../model/types.js';\nimport {\n MAX_NESTING_DEPTH,\n describePrototype,\n hasUnpairedSurrogate,\n memberPath,\n objectShapeViolation,\n tooDeep,\n} from './restricted.js';\n\n/**\n * The value-level half of the restricted JSON profile.\n *\n * The text reader in `restricted-json.ts` refuses a document while it is still bytes; this walk\n * refuses a document that arrived as a value — a YAML front door resolves its anchors, aliases\n * and tags into a plain tree before asking here. The two share these predicates, so a rule that\n * is added to one cannot be missing from the other: what the text reader can only state from a\n * spelling (a float written `1.0`) is classified from the spelling by\n * `restrictedNumberTextRefusal`, and everything a plain JavaScript value can answer — `-0`, an\n * unsafe integer, a cycle, a string with no UTF-8 encoding — is answered here.\n */\n\n/** The reasons a number falls outside the profile's integer-only number domain. */\nexport type RestrictedNumberReason = Extract<\n JsonIngestReason,\n 'negative_zero' | 'integer' | 'unsafe_integer'\n>;\n\n/** One number's refusal, stated without a path: the caller knows where it found the value. */\nexport interface RestrictedNumberRefusal {\n readonly reason: RestrictedNumberReason;\n readonly detail: string;\n}\n\n/**\n * Why a number handed over as a value is outside the profile, or `undefined` when it is inside.\n *\n * The spelling is not available here, so a float is named by its shortest JavaScript spelling.\n * The text reader uses `restrictedNumberTextRefusal` instead, which names the spelling the\n * document actually wrote; the reason and the message shape are the same.\n */\nexport function restrictedNumberViolation(value: number): RestrictedNumberRefusal | undefined {\n if (Object.is(value, -0)) return { reason: 'negative_zero', detail: 'negative zero' };\n if (!Number.isFinite(value) || !Number.isInteger(value)) {\n return {\n reason: 'integer',\n detail: `not a canonical JSON integer: ${JSON.stringify(String(value))}`,\n };\n }\n if (!isSafeInteger(value)) return { reason: 'unsafe_integer', detail: 'unsafe integer' };\n return undefined;\n}\n\n/**\n * Why a numeric spelling is outside the profile, or `undefined` when it is inside.\n *\n * This is the one implementation of the profile's number rule: the JSON reader hands it the\n * token it scanned, and the YAML front door hands it the source text of a plain numeric scalar,\n * so a document cannot be refused for `1e3` on one path and admitted on the other.\n */\nexport function restrictedNumberTextRefusal(text: string): RestrictedNumberRefusal | undefined {\n if (text === '-0') return { reason: 'negative_zero', detail: 'negative zero' };\n if (!INTEGER_TEXT_PATTERN.test(text)) {\n return { reason: 'integer', detail: `not a canonical JSON integer: ${JSON.stringify(text)}` };\n }\n // The spelling is a canonical integer, so anything outside the safe range is an unsafe\n // integer — including a token long enough to overflow to `Infinity`. Routing that through\n // `restrictedNumberViolation` would report it as a non-integer, because a double cannot tell\n // an overflowed integer from a document that wrote `1e400`: the spelling is the fact, so it\n // decides which refusal the document earned.\n const value = Number(text);\n if (!isSafeInteger(value)) return { reason: 'unsafe_integer', detail: 'unsafe integer' };\n return undefined;\n}\n\n/**\n * Why a value cannot be ingested, by the class of value found.\n *\n * `cycle` and `non_json_value` belong to the value walk: a text reader cannot construct either,\n * while a YAML document can reach both through an alias and a tag.\n */\nexport type RestrictedValueReason =\n | RestrictedNumberReason\n | 'unpaired_surrogate'\n | 'nesting'\n | 'cycle'\n | 'non_json_value';\n\n/** One reason a plain value is outside the profile, with the path the walk reached it by. */\nexport interface RestrictedValueRefusal {\n /** The path in the same `$.a.b[0]` notation every compiler diagnostic states. */\n readonly path: string;\n readonly reason: RestrictedValueReason;\n readonly detail: string;\n}\n\nfunction refuse(\n path: string,\n reason: RestrictedValueReason,\n detail: string,\n): RestrictedValueRefusal {\n return { path, reason, detail };\n}\n\n/** Whether a value is an array whose prototype is the ordinary one. */\nfunction isPlainArray(value: object): value is readonly unknown[] {\n return Array.isArray(value) && Reflect.getPrototypeOf(value) === Array.prototype;\n}\n\nfunction walkArray(\n value: readonly unknown[],\n path: string,\n ancestors: Set<object>,\n depth: number,\n): RestrictedValueRefusal | undefined {\n if (!isPlainArray(value)) return refuse(path, 'non_json_value', 'an Array subclass');\n // A symbol key, an accessor, a non-enumerable member other than `length`, or an own callable\n // `toJSON` has no canonical JSON spelling, so arrays share the same shape check as records and\n // `copyRestricted` before any element is read.\n const shape = objectShapeViolation(value);\n if (shape !== undefined) return refuse(path, 'non_json_value', shape);\n for (let index = 0; index < value.length; index += 1) {\n const childPath = `${path}[${String(index)}]`;\n if (!Object.hasOwn(value, index)) return refuse(childPath, 'non_json_value', 'a sparse array');\n const refusal = walkValue(value[index], childPath, ancestors, depth + 1);\n if (refusal !== undefined) return refusal;\n }\n // The one non-enumerable member an array may carry is its own `length`; any other name is a\n // member a JSON list cannot express.\n if (Object.getOwnPropertyNames(value).length !== value.length + 1) {\n return refuse(path, 'non_json_value', 'a non-index array property');\n }\n return undefined;\n}\n\nfunction walkRecord(\n value: object,\n path: string,\n ancestors: Set<object>,\n depth: number,\n): RestrictedValueRefusal | undefined {\n const prototype = Reflect.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n return refuse(path, 'non_json_value', describePrototype(value));\n }\n // A symbol key, an accessor, a non-enumerable member or an own callable `toJSON` has no\n // canonical JSON spelling, so the object is refused before any of its behaviour is read.\n const shape = objectShapeViolation(value);\n if (shape !== undefined) return refuse(path, 'non_json_value', shape);\n for (const key of Object.keys(value)) {\n const childPath = memberPath(path, key);\n if (hasUnpairedSurrogate(key)) {\n return refuse(childPath, 'unpaired_surrogate', 'string carries an unpaired surrogate');\n }\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (descriptor === undefined || !('value' in descriptor)) {\n return refuse(childPath, 'non_json_value', 'an accessor property');\n }\n const refusal = walkValue(descriptor.value, childPath, ancestors, depth + 1);\n if (refusal !== undefined) return refusal;\n }\n return undefined;\n}\n\nfunction walkValue(\n value: unknown,\n path: string,\n ancestors: Set<object>,\n depth: number,\n): RestrictedValueRefusal | undefined {\n switch (typeof value) {\n case 'string':\n return hasUnpairedSurrogate(value)\n ? refuse(path, 'unpaired_surrogate', 'string carries an unpaired surrogate')\n : undefined;\n case 'boolean':\n return undefined;\n case 'number': {\n const numberRefusal = restrictedNumberViolation(value);\n return numberRefusal === undefined\n ? undefined\n : refuse(path, numberRefusal.reason, numberRefusal.detail);\n }\n case 'bigint':\n return refuse(path, 'non_json_value', 'a BigInt value');\n case 'undefined':\n return refuse(path, 'non_json_value', 'undefined');\n case 'function':\n return refuse(path, 'non_json_value', 'a function');\n case 'symbol':\n return refuse(path, 'non_json_value', 'a symbol');\n case 'object': {\n if (value === null) return undefined;\n if (ancestors.has(value)) {\n return refuse(path, 'cycle', 'an alias that constructs a cycle');\n }\n // The bound counts containers, so it is checked where one is opened, exactly as the text\n // reader and the canonical copier check it.\n if (tooDeep(depth + 1)) {\n return refuse(path, 'nesting', `nesting deeper than ${String(MAX_NESTING_DEPTH)} levels`);\n }\n ancestors.add(value);\n const refusal = Array.isArray(value)\n ? walkArray(value, path, ancestors, depth)\n : walkRecord(value, path, ancestors, depth);\n ancestors.delete(value);\n return refusal;\n }\n }\n}\n\n/**\n * The first reason a plain JavaScript value is outside the restricted profile, or `undefined`\n * when the profile admits it.\n *\n * The walk is total over `unknown` and never throws for a value it refuses. It keeps an ancestor\n * set rather than a visited set, so one value reached twice through two aliases is an ordinary\n * shared subtree while a value reached from itself is the cycle it is.\n */\nexport function restrictedValueRefusal(value: unknown): RestrictedValueRefusal | undefined {\n return walkValue(value, '$', new Set(), 0);\n}\n"]}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Primitives shared by the restricted-JSON reader and the defensive copy.
|
|
3
|
+
*
|
|
4
|
+
* The reader and the copy are both recursive over untrusted input, so they share one nesting
|
|
5
|
+
* bound, one surrogate check and one safe member assignment. Keeping them here means the two
|
|
6
|
+
* walks cannot disagree about what the profile admits.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The deepest container nesting the restricted profile admits. Both the text reader and
|
|
10
|
+
* the defensive copy are recursive, so untrusted input has to be bounded before either
|
|
11
|
+
* walk reaches the call stack's limit: refusing a 100k-deep hostile document must be a
|
|
12
|
+
* structured refusal, never a `RangeError` an operator cannot report.
|
|
13
|
+
*
|
|
14
|
+
* The bound is set from the deepest document the contracts call legal, not from the depth
|
|
15
|
+
* an author is likely to type. The expression budget permits a compiled expression 32 nodes
|
|
16
|
+
* deep, and every node spends two JSON levels (the node object and its `args` list) inside a rule
|
|
17
|
+
* or gate-item wrapper, so the deepest legal document sits near 66 levels. A tighter bound
|
|
18
|
+
* would refuse a legal document and blame the reader; 128 clears that budget with headroom
|
|
19
|
+
* while still stopping hostile input a few dozen frames in, far below the stack limit.
|
|
20
|
+
*/
|
|
21
|
+
export declare const MAX_NESTING_DEPTH = 128;
|
|
22
|
+
export declare function tooDeep(depth: number): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* One object member step appended to `parent` in injective document-path notation:
|
|
25
|
+
* `.name` when the member is an identifier and `["name"]` otherwise, so a dotted, numeric
|
|
26
|
+
* or quoted member name never collides with nesting or an array index.
|
|
27
|
+
*/
|
|
28
|
+
export declare function memberPath(parent: string, member: string): string;
|
|
29
|
+
export declare function hasUnpairedSurrogate(text: string): boolean;
|
|
30
|
+
/** The prototype of `value`, or `null` when it has none. */
|
|
31
|
+
export declare function prototypeOf(value: object): object | null;
|
|
32
|
+
/**
|
|
33
|
+
* The class of a non-plain object, by its constructor's name, so a value walk names what it
|
|
34
|
+
* found rather than only that it was not a record. `Date`, `Decimal` and a boxed primitive all
|
|
35
|
+
* answer here; the canonical copier and the ingestion walk print the same words for one value.
|
|
36
|
+
*/
|
|
37
|
+
export declare function describePrototype(value: object): string;
|
|
38
|
+
/**
|
|
39
|
+
* The class of value a restricted-profile object may not carry, by kind, or `undefined` when
|
|
40
|
+
* it carries none. `copyRestricted` and `isWireValue` both ask this one function, so the
|
|
41
|
+
* pre-flight a caller uses and the copier that decides the profile cannot disagree.
|
|
42
|
+
*
|
|
43
|
+
* A symbol key, an accessor, a non-enumerable member and an own callable `toJSON` are all
|
|
44
|
+
* outside the profile: each would either vanish from the canonical text or make it depend on
|
|
45
|
+
* code rather than on data, and a hash no independent implementation can reproduce is not a
|
|
46
|
+
* commitment. `CANON-1.1.3` names the `toJSON` *method* — the member every JSON writer
|
|
47
|
+
* invokes — so a data member that merely happens to be called `toJSON` is an ordinary string
|
|
48
|
+
* key (`CANON-1.1.2`) and hashes as one. An array's own `length` is the one non-enumerable
|
|
49
|
+
* member the profile admits.
|
|
50
|
+
*
|
|
51
|
+
* Only own members decide the verdict. A plain object inherits from `Object.prototype` or
|
|
52
|
+
* from nothing, so an inherited `toJSON` or accessor can only be one a host installed on
|
|
53
|
+
* `Object.prototype`, and the answer must not change with ambient mutation. The serialiser's
|
|
54
|
+
* input is copied onto prototype-less containers for the same reason
|
|
55
|
+
* (`canonicalizeRestricted`), because `canonicalize` unwraps a callable `toJSON` it finds
|
|
56
|
+
* through the prototype chain.
|
|
57
|
+
*/
|
|
58
|
+
export declare function objectShapeViolation(value: object): string | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Writes an own data property while a container is being filled.
|
|
61
|
+
*
|
|
62
|
+
* An assignment is routed through the prototype chain: a host that installed a setter, a
|
|
63
|
+
* non-writable data property or the `__proto__` accessor under the same name on
|
|
64
|
+
* `Object.prototype` would absorb the write, so the value the engine stored would not carry
|
|
65
|
+
* the bytes it hashed. `key in target` is exactly that check; when the name is free, a plain
|
|
66
|
+
* assignment creates the own enumerable data property the profile requires without restating
|
|
67
|
+
* its flags once per member of every report. Lists are filled prototype-less (`emptyList`),
|
|
68
|
+
* so their elements never consult a prototype at all.
|
|
69
|
+
*/
|
|
70
|
+
export declare function setOwn(target: Record<string, unknown>, key: string, value: unknown): void;
|
|
71
|
+
/** How a container ends up: with its ordinary prototype, or carrying none at all. */
|
|
72
|
+
export type ContainerShape = 'plain' | 'shielded';
|
|
73
|
+
/**
|
|
74
|
+
* A list to fill. It carries no prototype until `closeList`, so an element store creates an
|
|
75
|
+
* own element even when a host installed a setter under that index name on `Object.prototype`:
|
|
76
|
+
* along the ordinary chain the store would be absorbed while `length` still counted the index,
|
|
77
|
+
* leaving a hole in the stored bytes that the hashed ones do not have.
|
|
78
|
+
*
|
|
79
|
+
* Filling this way is also cheaper than `push`, which re-reads `length` and consults the
|
|
80
|
+
* prototype chain for every element.
|
|
81
|
+
*/
|
|
82
|
+
export declare function emptyList(): unknown[];
|
|
83
|
+
/** Gives a filled list the prototype its shape requires; a shielded list keeps none. */
|
|
84
|
+
export declare function closeList(items: unknown[], shape: ContainerShape): void;
|
|
85
|
+
//# sourceMappingURL=restricted.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restricted.d.ts","sourceRoot":"","sources":["../../src/canonical/restricted.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE9C;AAKD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAIjE;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAY1D;AAED,4DAA4D;AAC5D,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGxD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CASvD;AAuBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKtE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAWzF;AAED,qFAAqF;AACrF,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,UAAU,CAAC;AAElD;;;;;;;;GAQG;AACH,wBAAgB,SAAS,IAAI,OAAO,EAAE,CAIrC;AAED,wFAAwF;AACxF,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI,CAEvE"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Primitives shared by the restricted-JSON reader and the defensive copy.
|
|
3
|
+
*
|
|
4
|
+
* The reader and the copy are both recursive over untrusted input, so they share one nesting
|
|
5
|
+
* bound, one surrogate check and one safe member assignment. Keeping them here means the two
|
|
6
|
+
* walks cannot disagree about what the profile admits.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The deepest container nesting the restricted profile admits. Both the text reader and
|
|
10
|
+
* the defensive copy are recursive, so untrusted input has to be bounded before either
|
|
11
|
+
* walk reaches the call stack's limit: refusing a 100k-deep hostile document must be a
|
|
12
|
+
* structured refusal, never a `RangeError` an operator cannot report.
|
|
13
|
+
*
|
|
14
|
+
* The bound is set from the deepest document the contracts call legal, not from the depth
|
|
15
|
+
* an author is likely to type. The expression budget permits a compiled expression 32 nodes
|
|
16
|
+
* deep, and every node spends two JSON levels (the node object and its `args` list) inside a rule
|
|
17
|
+
* or gate-item wrapper, so the deepest legal document sits near 66 levels. A tighter bound
|
|
18
|
+
* would refuse a legal document and blame the reader; 128 clears that budget with headroom
|
|
19
|
+
* while still stopping hostile input a few dozen frames in, far below the stack limit.
|
|
20
|
+
*/
|
|
21
|
+
export const MAX_NESTING_DEPTH = 128;
|
|
22
|
+
export function tooDeep(depth) {
|
|
23
|
+
return depth > MAX_NESTING_DEPTH;
|
|
24
|
+
}
|
|
25
|
+
/** An identifier step that a document path renders dotted rather than bracket-quoted. */
|
|
26
|
+
const IDENTIFIER_MEMBER = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
27
|
+
/**
|
|
28
|
+
* One object member step appended to `parent` in injective document-path notation:
|
|
29
|
+
* `.name` when the member is an identifier and `["name"]` otherwise, so a dotted, numeric
|
|
30
|
+
* or quoted member name never collides with nesting or an array index.
|
|
31
|
+
*/
|
|
32
|
+
export function memberPath(parent, member) {
|
|
33
|
+
return IDENTIFIER_MEMBER.test(member)
|
|
34
|
+
? `${parent}.${member}`
|
|
35
|
+
: `${parent}[${JSON.stringify(member)}]`;
|
|
36
|
+
}
|
|
37
|
+
export function hasUnpairedSurrogate(text) {
|
|
38
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
39
|
+
const unit = text.charCodeAt(index);
|
|
40
|
+
if (unit >= 0xd800 && unit <= 0xdbff) {
|
|
41
|
+
const next = text.charCodeAt(index + 1);
|
|
42
|
+
if (!(next >= 0xdc00 && next <= 0xdfff))
|
|
43
|
+
return true;
|
|
44
|
+
index += 1;
|
|
45
|
+
}
|
|
46
|
+
else if (unit >= 0xdc00 && unit <= 0xdfff) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
/** The prototype of `value`, or `null` when it has none. */
|
|
53
|
+
export function prototypeOf(value) {
|
|
54
|
+
const prototype = Reflect.getPrototypeOf(value);
|
|
55
|
+
return typeof prototype === 'object' && prototype !== null ? prototype : null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The class of a non-plain object, by its constructor's name, so a value walk names what it
|
|
59
|
+
* found rather than only that it was not a record. `Date`, `Decimal` and a boxed primitive all
|
|
60
|
+
* answer here; the canonical copier and the ingestion walk print the same words for one value.
|
|
61
|
+
*/
|
|
62
|
+
export function describePrototype(value) {
|
|
63
|
+
const prototype = prototypeOf(value);
|
|
64
|
+
if (prototype !== null) {
|
|
65
|
+
const constructor = Reflect.getOwnPropertyDescriptor(prototype, 'constructor')?.value;
|
|
66
|
+
if (typeof constructor === 'function' && constructor.name !== '') {
|
|
67
|
+
return `an instance of ${constructor.name}`;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return 'an object with a non-plain prototype';
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The own-property class a restricted-profile object may not carry, or `undefined` when it
|
|
74
|
+
* carries none: a symbol key, an accessor or a non-enumerable member. `objectShapeViolation`
|
|
75
|
+
* asks it, so the one object rule has one statement of these three classes.
|
|
76
|
+
*/
|
|
77
|
+
function ownPropertyViolation(value) {
|
|
78
|
+
if (Object.getOwnPropertySymbols(value).length > 0)
|
|
79
|
+
return 'a symbol key';
|
|
80
|
+
const isArray = Array.isArray(value);
|
|
81
|
+
for (const name of Object.getOwnPropertyNames(value)) {
|
|
82
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, name);
|
|
83
|
+
if (descriptor === undefined)
|
|
84
|
+
continue;
|
|
85
|
+
if (descriptor.get !== undefined || descriptor.set !== undefined) {
|
|
86
|
+
return `an accessor property (${name})`;
|
|
87
|
+
}
|
|
88
|
+
if (descriptor.enumerable !== true && !(isArray && name === 'length')) {
|
|
89
|
+
return `a non-enumerable property (${name})`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The class of value a restricted-profile object may not carry, by kind, or `undefined` when
|
|
96
|
+
* it carries none. `copyRestricted` and `isWireValue` both ask this one function, so the
|
|
97
|
+
* pre-flight a caller uses and the copier that decides the profile cannot disagree.
|
|
98
|
+
*
|
|
99
|
+
* A symbol key, an accessor, a non-enumerable member and an own callable `toJSON` are all
|
|
100
|
+
* outside the profile: each would either vanish from the canonical text or make it depend on
|
|
101
|
+
* code rather than on data, and a hash no independent implementation can reproduce is not a
|
|
102
|
+
* commitment. `CANON-1.1.3` names the `toJSON` *method* — the member every JSON writer
|
|
103
|
+
* invokes — so a data member that merely happens to be called `toJSON` is an ordinary string
|
|
104
|
+
* key (`CANON-1.1.2`) and hashes as one. An array's own `length` is the one non-enumerable
|
|
105
|
+
* member the profile admits.
|
|
106
|
+
*
|
|
107
|
+
* Only own members decide the verdict. A plain object inherits from `Object.prototype` or
|
|
108
|
+
* from nothing, so an inherited `toJSON` or accessor can only be one a host installed on
|
|
109
|
+
* `Object.prototype`, and the answer must not change with ambient mutation. The serialiser's
|
|
110
|
+
* input is copied onto prototype-less containers for the same reason
|
|
111
|
+
* (`canonicalizeRestricted`), because `canonicalize` unwraps a callable `toJSON` it finds
|
|
112
|
+
* through the prototype chain.
|
|
113
|
+
*/
|
|
114
|
+
export function objectShapeViolation(value) {
|
|
115
|
+
const own = ownPropertyViolation(value);
|
|
116
|
+
if (own !== undefined)
|
|
117
|
+
return own;
|
|
118
|
+
const toJSON = Object.getOwnPropertyDescriptor(value, 'toJSON');
|
|
119
|
+
return toJSON !== undefined && typeof toJSON.value === 'function' ? 'a toJSON method' : undefined;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Writes an own data property while a container is being filled.
|
|
123
|
+
*
|
|
124
|
+
* An assignment is routed through the prototype chain: a host that installed a setter, a
|
|
125
|
+
* non-writable data property or the `__proto__` accessor under the same name on
|
|
126
|
+
* `Object.prototype` would absorb the write, so the value the engine stored would not carry
|
|
127
|
+
* the bytes it hashed. `key in target` is exactly that check; when the name is free, a plain
|
|
128
|
+
* assignment creates the own enumerable data property the profile requires without restating
|
|
129
|
+
* its flags once per member of every report. Lists are filled prototype-less (`emptyList`),
|
|
130
|
+
* so their elements never consult a prototype at all.
|
|
131
|
+
*/
|
|
132
|
+
export function setOwn(target, key, value) {
|
|
133
|
+
if (key in target) {
|
|
134
|
+
Object.defineProperty(target, key, {
|
|
135
|
+
value,
|
|
136
|
+
enumerable: true,
|
|
137
|
+
writable: true,
|
|
138
|
+
configurable: true,
|
|
139
|
+
});
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
target[key] = value;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* A list to fill. It carries no prototype until `closeList`, so an element store creates an
|
|
146
|
+
* own element even when a host installed a setter under that index name on `Object.prototype`:
|
|
147
|
+
* along the ordinary chain the store would be absorbed while `length` still counted the index,
|
|
148
|
+
* leaving a hole in the stored bytes that the hashed ones do not have.
|
|
149
|
+
*
|
|
150
|
+
* Filling this way is also cheaper than `push`, which re-reads `length` and consults the
|
|
151
|
+
* prototype chain for every element.
|
|
152
|
+
*/
|
|
153
|
+
export function emptyList() {
|
|
154
|
+
const items = [];
|
|
155
|
+
Object.setPrototypeOf(items, null);
|
|
156
|
+
return items;
|
|
157
|
+
}
|
|
158
|
+
/** Gives a filled list the prototype its shape requires; a shielded list keeps none. */
|
|
159
|
+
export function closeList(items, shape) {
|
|
160
|
+
if (shape === 'plain')
|
|
161
|
+
Object.setPrototypeOf(items, Array.prototype);
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=restricted.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restricted.js","sourceRoot":"","sources":["../../src/canonical/restricted.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAErC,MAAM,UAAU,OAAO,CAAC,KAAa;IACnC,OAAO,KAAK,GAAG,iBAAiB,CAAC;AAC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AAoB,CAAC,KAAa;IAChD,MAAM,GAAG,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IACxC,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,GAAG,CAAC;IAClC,MAAM,MAAM,GAAG,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAChE,OAAO,MAAM,KAAK,SAAS,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC;AACpG,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,MAAM,CAAC,MAA+B,EAAE,GAAW,EAAE,KAAc;IACjF,IAAI,GAAG,IAAI,MAAM,EAAE,CAAC;QAClB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE;YACjC,KAAK;YACL,UAAU,EAAE,IAAI;YAChB,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IACD,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AACtB,CAAC;AAKD;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS;IACvB,MAAM,KAAK,GAAc,EAAE,CAAC;IAC5B,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACnC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,SAAS,CAAC,KAAgB,EAAE,KAAqB;IAC/D,IAAI,KAAK,KAAK,OAAO;QAAE,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;AACvE,CAAC","sourcesContent":["/**\n * Primitives shared by the restricted-JSON reader and the defensive copy.\n *\n * The reader and the copy are both recursive over untrusted input, so they share one nesting\n * bound, one surrogate check and one safe member assignment. Keeping them here means the two\n * walks cannot disagree about what the profile admits.\n */\n\n/**\n * The deepest container nesting the restricted profile admits. Both the text reader and\n * the defensive copy are recursive, so untrusted input has to be bounded before either\n * walk reaches the call stack's limit: refusing a 100k-deep hostile document must be a\n * structured refusal, never a `RangeError` an operator cannot report.\n *\n * The bound is set from the deepest document the contracts call legal, not from the depth\n * an author is likely to type. The expression budget permits a compiled expression 32 nodes\n * deep, and every node spends two JSON levels (the node object and its `args` list) inside a rule\n * or gate-item wrapper, so the deepest legal document sits near 66 levels. A tighter bound\n * would refuse a legal document and blame the reader; 128 clears that budget with headroom\n * while still stopping hostile input a few dozen frames in, far below the stack limit.\n */\nexport const MAX_NESTING_DEPTH = 128;\n\nexport function tooDeep(depth: number): boolean {\n return depth > MAX_NESTING_DEPTH;\n}\n\n/** An identifier step that a document path renders dotted rather than bracket-quoted. */\nconst IDENTIFIER_MEMBER = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\n/**\n * One object member step appended to `parent` in injective document-path notation:\n * `.name` when the member is an identifier and `[\"name\"]` otherwise, so a dotted, numeric\n * or quoted member name never collides with nesting or an array index.\n */\nexport function memberPath(parent: string, member: string): string {\n return IDENTIFIER_MEMBER.test(member)\n ? `${parent}.${member}`\n : `${parent}[${JSON.stringify(member)}]`;\n}\n\nexport function hasUnpairedSurrogate(text: string): boolean {\n for (let index = 0; index < text.length; index += 1) {\n const unit = text.charCodeAt(index);\n if (unit >= 0xd800 && unit <= 0xdbff) {\n const next = text.charCodeAt(index + 1);\n if (!(next >= 0xdc00 && next <= 0xdfff)) return true;\n index += 1;\n } else if (unit >= 0xdc00 && unit <= 0xdfff) {\n return true;\n }\n }\n return false;\n}\n\n/** The prototype of `value`, or `null` when it has none. */\nexport function prototypeOf(value: object): object | null {\n const prototype: unknown = Reflect.getPrototypeOf(value);\n return typeof prototype === 'object' && prototype !== null ? prototype : null;\n}\n\n/**\n * The class of a non-plain object, by its constructor's name, so a value walk names what it\n * found rather than only that it was not a record. `Date`, `Decimal` and a boxed primitive all\n * answer here; the canonical copier and the ingestion walk print the same words for one value.\n */\nexport function describePrototype(value: object): string {\n const prototype = prototypeOf(value);\n if (prototype !== null) {\n const constructor: unknown = Reflect.getOwnPropertyDescriptor(prototype, 'constructor')?.value;\n if (typeof constructor === 'function' && constructor.name !== '') {\n return `an instance of ${constructor.name}`;\n }\n }\n return 'an object with a non-plain prototype';\n}\n\n/**\n * The own-property class a restricted-profile object may not carry, or `undefined` when it\n * carries none: a symbol key, an accessor or a non-enumerable member. `objectShapeViolation`\n * asks it, so the one object rule has one statement of these three classes.\n */\nfunction ownPropertyViolation(value: object): string | undefined {\n if (Object.getOwnPropertySymbols(value).length > 0) return 'a symbol key';\n const isArray = Array.isArray(value);\n for (const name of Object.getOwnPropertyNames(value)) {\n const descriptor = Object.getOwnPropertyDescriptor(value, name);\n if (descriptor === undefined) continue;\n if (descriptor.get !== undefined || descriptor.set !== undefined) {\n return `an accessor property (${name})`;\n }\n if (descriptor.enumerable !== true && !(isArray && name === 'length')) {\n return `a non-enumerable property (${name})`;\n }\n }\n return undefined;\n}\n\n/**\n * The class of value a restricted-profile object may not carry, by kind, or `undefined` when\n * it carries none. `copyRestricted` and `isWireValue` both ask this one function, so the\n * pre-flight a caller uses and the copier that decides the profile cannot disagree.\n *\n * A symbol key, an accessor, a non-enumerable member and an own callable `toJSON` are all\n * outside the profile: each would either vanish from the canonical text or make it depend on\n * code rather than on data, and a hash no independent implementation can reproduce is not a\n * commitment. `CANON-1.1.3` names the `toJSON` *method* — the member every JSON writer\n * invokes — so a data member that merely happens to be called `toJSON` is an ordinary string\n * key (`CANON-1.1.2`) and hashes as one. An array's own `length` is the one non-enumerable\n * member the profile admits.\n *\n * Only own members decide the verdict. A plain object inherits from `Object.prototype` or\n * from nothing, so an inherited `toJSON` or accessor can only be one a host installed on\n * `Object.prototype`, and the answer must not change with ambient mutation. The serialiser's\n * input is copied onto prototype-less containers for the same reason\n * (`canonicalizeRestricted`), because `canonicalize` unwraps a callable `toJSON` it finds\n * through the prototype chain.\n */\nexport function objectShapeViolation(value: object): string | undefined {\n const own = ownPropertyViolation(value);\n if (own !== undefined) return own;\n const toJSON = Object.getOwnPropertyDescriptor(value, 'toJSON');\n return toJSON !== undefined && typeof toJSON.value === 'function' ? 'a toJSON method' : undefined;\n}\n\n/**\n * Writes an own data property while a container is being filled.\n *\n * An assignment is routed through the prototype chain: a host that installed a setter, a\n * non-writable data property or the `__proto__` accessor under the same name on\n * `Object.prototype` would absorb the write, so the value the engine stored would not carry\n * the bytes it hashed. `key in target` is exactly that check; when the name is free, a plain\n * assignment creates the own enumerable data property the profile requires without restating\n * its flags once per member of every report. Lists are filled prototype-less (`emptyList`),\n * so their elements never consult a prototype at all.\n */\nexport function setOwn(target: Record<string, unknown>, key: string, value: unknown): void {\n if (key in target) {\n Object.defineProperty(target, key, {\n value,\n enumerable: true,\n writable: true,\n configurable: true,\n });\n return;\n }\n target[key] = value;\n}\n\n/** How a container ends up: with its ordinary prototype, or carrying none at all. */\nexport type ContainerShape = 'plain' | 'shielded';\n\n/**\n * A list to fill. It carries no prototype until `closeList`, so an element store creates an\n * own element even when a host installed a setter under that index name on `Object.prototype`:\n * along the ordinary chain the store would be absorbed while `length` still counted the index,\n * leaving a hole in the stored bytes that the hashed ones do not have.\n *\n * Filling this way is also cheaper than `push`, which re-reads `length` and consults the\n * prototype chain for every element.\n */\nexport function emptyList(): unknown[] {\n const items: unknown[] = [];\n Object.setPrototypeOf(items, null);\n return items;\n}\n\n/** Gives a filled list the prototype its shape requires; a shielded list keeps none. */\nexport function closeList(items: unknown[], shape: ContainerShape): void {\n if (shape === 'plain') Object.setPrototypeOf(items, Array.prototype);\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { FieldRef, WireValue } from '../model/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Signature digests, `spec/semantics/canonical-v1.md` section 4.
|
|
4
|
+
*
|
|
5
|
+
* A signature binds the values it covers, not only their names. One
|
|
6
|
+
* binding is computed here so the `digest` expression, a host preparing a signature and a
|
|
7
|
+
* verifier recomputing a seven-year-old one all produce the same bytes from the same
|
|
8
|
+
* targets; a second implementation of the formula is a signature that verifies on one
|
|
9
|
+
* target and not another.
|
|
10
|
+
*/
|
|
11
|
+
/** One covered target paired with the canonical value it currently holds. */
|
|
12
|
+
export interface CoveredValue {
|
|
13
|
+
readonly target: FieldRef;
|
|
14
|
+
readonly value: WireValue;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The digest a `signature_ref` carries and the value
|
|
18
|
+
* `digest(coveredTargets, schemaVersion)` returns are one value, so a signer storing it and
|
|
19
|
+
* a verifier recomputing it compare the same bytes.
|
|
20
|
+
*
|
|
21
|
+
* The canonical object's member is spelled `dataHash` while carrying the *value* binding, not
|
|
22
|
+
* the digest the field exposes. That member name is part of the hashed bytes, so a stored
|
|
23
|
+
* digest is only reproduced by keeping it.
|
|
24
|
+
*
|
|
25
|
+
* Order is part of the binding, so the caller must hand the targets in the order the
|
|
26
|
+
* signature declares them; reordering, inserting or removing an *uncovered* row changes
|
|
27
|
+
* nothing because no array position takes part.
|
|
28
|
+
*/
|
|
29
|
+
export declare function signatureBinding(covered: readonly CoveredValue[], schemaVersion: number): string;
|
|
30
|
+
/**
|
|
31
|
+
* Whether two lowercase-hex digests are the same.
|
|
32
|
+
*
|
|
33
|
+
* The comparison reads every digit instead of returning at the first difference, so its
|
|
34
|
+
* duration does not report how much of a forged digest was right. The shape check runs
|
|
35
|
+
* first because a value that is not a SHA-256 digest is not a secret: it names itself.
|
|
36
|
+
*/
|
|
37
|
+
export declare function digestsMatch(left: string, right: string): boolean;
|
|
38
|
+
//# sourceMappingURL=signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../src/canonical/signature.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG7D;;;;;;;;GAQG;AAEH,6EAA6E;AAC7E,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC3B;AASD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAQhG;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAOjE"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { SHA256_HEX_PATTERN } from '../model/types.js';
|
|
2
|
+
import { canonicalHash } from './jcs.js';
|
|
3
|
+
/** A target in its canonical wire form: `rowKey` is absent, never `undefined`. */
|
|
4
|
+
function targetForm(target) {
|
|
5
|
+
return target.rowKey === undefined
|
|
6
|
+
? { fieldId: target.fieldId }
|
|
7
|
+
: { fieldId: target.fieldId, rowKey: target.rowKey };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The digest a `signature_ref` carries and the value
|
|
11
|
+
* `digest(coveredTargets, schemaVersion)` returns are one value, so a signer storing it and
|
|
12
|
+
* a verifier recomputing it compare the same bytes.
|
|
13
|
+
*
|
|
14
|
+
* The canonical object's member is spelled `dataHash` while carrying the *value* binding, not
|
|
15
|
+
* the digest the field exposes. That member name is part of the hashed bytes, so a stored
|
|
16
|
+
* digest is only reproduced by keeping it.
|
|
17
|
+
*
|
|
18
|
+
* Order is part of the binding, so the caller must hand the targets in the order the
|
|
19
|
+
* signature declares them; reordering, inserting or removing an *uncovered* row changes
|
|
20
|
+
* nothing because no array position takes part.
|
|
21
|
+
*/
|
|
22
|
+
export function signatureBinding(covered, schemaVersion) {
|
|
23
|
+
const coveredTargets = covered.map(({ target }) => targetForm(target));
|
|
24
|
+
const values = covered.map(({ target, value }) => ({
|
|
25
|
+
...targetForm(target),
|
|
26
|
+
valueDigest: canonicalHash(value),
|
|
27
|
+
}));
|
|
28
|
+
const valueBinding = canonicalHash(values);
|
|
29
|
+
return canonicalHash({ coveredTargets, dataHash: valueBinding, schemaVersion });
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Whether two lowercase-hex digests are the same.
|
|
33
|
+
*
|
|
34
|
+
* The comparison reads every digit instead of returning at the first difference, so its
|
|
35
|
+
* duration does not report how much of a forged digest was right. The shape check runs
|
|
36
|
+
* first because a value that is not a SHA-256 digest is not a secret: it names itself.
|
|
37
|
+
*/
|
|
38
|
+
export function digestsMatch(left, right) {
|
|
39
|
+
if (!SHA256_HEX_PATTERN.test(left) || !SHA256_HEX_PATTERN.test(right))
|
|
40
|
+
return false;
|
|
41
|
+
let difference = 0;
|
|
42
|
+
for (let index = 0; index < left.length; index += 1) {
|
|
43
|
+
difference |= left.charCodeAt(index) ^ right.charCodeAt(index);
|
|
44
|
+
}
|
|
45
|
+
return difference === 0;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=signature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature.js","sourceRoot":"","sources":["../../src/canonical/signature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAkBzC,kFAAkF;AAClF,SAAS,UAAU,CAAC,MAAgB;IAClC,OAAO,MAAM,CAAC,MAAM,KAAK,SAAS;QAChC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE;QAC7B,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;AACzD,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAgC,EAAE,aAAqB;IACtF,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IACvE,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QACjD,GAAG,UAAU,CAAC,MAAM,CAAC;QACrB,WAAW,EAAE,aAAa,CAAC,KAAK,CAAC;KAClC,CAAC,CAAC,CAAC;IACJ,MAAM,YAAY,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAC3C,OAAO,aAAa,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC,CAAC;AAClF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,KAAa;IACtD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACpF,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACpD,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,UAAU,KAAK,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import { SHA256_HEX_PATTERN } from '../model/types.js';\nimport type { FieldRef, WireValue } from '../model/types.js';\nimport { canonicalHash } from './jcs.js';\n\n/**\n * Signature digests, `spec/semantics/canonical-v1.md` section 4.\n *\n * A signature binds the values it covers, not only their names. One\n * binding is computed here so the `digest` expression, a host preparing a signature and a\n * verifier recomputing a seven-year-old one all produce the same bytes from the same\n * targets; a second implementation of the formula is a signature that verifies on one\n * target and not another.\n */\n\n/** One covered target paired with the canonical value it currently holds. */\nexport interface CoveredValue {\n readonly target: FieldRef;\n readonly value: WireValue;\n}\n\n/** A target in its canonical wire form: `rowKey` is absent, never `undefined`. */\nfunction targetForm(target: FieldRef): FieldRef {\n return target.rowKey === undefined\n ? { fieldId: target.fieldId }\n : { fieldId: target.fieldId, rowKey: target.rowKey };\n}\n\n/**\n * The digest a `signature_ref` carries and the value\n * `digest(coveredTargets, schemaVersion)` returns are one value, so a signer storing it and\n * a verifier recomputing it compare the same bytes.\n *\n * The canonical object's member is spelled `dataHash` while carrying the *value* binding, not\n * the digest the field exposes. That member name is part of the hashed bytes, so a stored\n * digest is only reproduced by keeping it.\n *\n * Order is part of the binding, so the caller must hand the targets in the order the\n * signature declares them; reordering, inserting or removing an *uncovered* row changes\n * nothing because no array position takes part.\n */\nexport function signatureBinding(covered: readonly CoveredValue[], schemaVersion: number): string {\n const coveredTargets = covered.map(({ target }) => targetForm(target));\n const values = covered.map(({ target, value }) => ({\n ...targetForm(target),\n valueDigest: canonicalHash(value),\n }));\n const valueBinding = canonicalHash(values);\n return canonicalHash({ coveredTargets, dataHash: valueBinding, schemaVersion });\n}\n\n/**\n * Whether two lowercase-hex digests are the same.\n *\n * The comparison reads every digit instead of returning at the first difference, so its\n * duration does not report how much of a forged digest was right. The shape check runs\n * first because a value that is not a SHA-256 digest is not a secret: it names itself.\n */\nexport function digestsMatch(left: string, right: string): boolean {\n if (!SHA256_HEX_PATTERN.test(left) || !SHA256_HEX_PATTERN.test(right)) return false;\n let difference = 0;\n for (let index = 0; index < left.length; index += 1) {\n difference |= left.charCodeAt(index) ^ right.charCodeAt(index);\n }\n return difference === 0;\n}\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { FieldAccess, FieldRef } from '../../model/types.js';
|
|
2
|
+
import type { AccessProjection } from './projection.js';
|
|
3
|
+
/**
|
|
4
|
+
* One binding's delivery answer: whether its value may be stated, and the one reason it may not.
|
|
5
|
+
*
|
|
6
|
+
* Every consumer that used to classify access for itself asks this instead — a report stating a
|
|
7
|
+
* writer's value, a derived field's value state, an alternative's target and the derived
|
|
8
|
+
* requirements a respondent is held to. The reason is a single closed set so those consumers
|
|
9
|
+
* cannot each invent a different reading of the same overlay (`[ACCESS-1.3.4]`).
|
|
10
|
+
*
|
|
11
|
+
* `masked` is the one state two readers disagree about, and legitimately: `allowMaskedRead` lifts
|
|
12
|
+
* it for an expression and never for delivery (`[ACCESS-1.3.3]`). `written` is the `write_only`
|
|
13
|
+
* value this session wrote, which reads back as a value while a stored one never does
|
|
14
|
+
* (`[ACCESS-1.3.1]`).
|
|
15
|
+
*/
|
|
16
|
+
type DeliveryReason = 'read_write' | 'read_only' | 'write_only' | 'written' | 'masked' | 'hidden' | 'redacted';
|
|
17
|
+
/** What one binding's access answer permits, and the reason it permits or withholds it. */
|
|
18
|
+
export interface DeliveryAnswer {
|
|
19
|
+
readonly reason: DeliveryReason;
|
|
20
|
+
/** Whether the value may be stated to this device: a report, a painted control, a payload. */
|
|
21
|
+
readonly deliverable: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** The delivery answer one resolved access state states, with the two inputs access does not own. */
|
|
24
|
+
export declare function deliveryOf(access: FieldAccess, redacted: boolean, sessionWritten: boolean): DeliveryAnswer;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the host stated an access answer for one reference, rather than the fail-closed default.
|
|
27
|
+
*
|
|
28
|
+
* The default is `read_only` (`[ACCESS-2.1.2]`), which answers "may this device write" and says
|
|
29
|
+
* nothing about who supplies the value. A flat projection states exactly the entries it holds; an
|
|
30
|
+
* overlay states a reference when a rule matched it, and a template states every row of the array
|
|
31
|
+
* it names.
|
|
32
|
+
*/
|
|
33
|
+
export declare function statedAccess(projection: AccessProjection, ref: FieldRef): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether an alternative may name one binding, `RULES-6.1.3`, `RULES-7.1.4`.
|
|
36
|
+
*
|
|
37
|
+
* The access of every declaration enclosing the target meets, so a member of a record the answer
|
|
38
|
+
* hides is not writable because its own entry says `read_write`. A target the artifact does not
|
|
39
|
+
* declare, or one no single declaration path answers, is withheld rather than offered against a
|
|
40
|
+
* binding no host can address: the refusal is a report policy, and the write guard stays
|
|
41
|
+
* authoritative at apply.
|
|
42
|
+
*
|
|
43
|
+
* `read_only` and `write_only` meet to `hidden`, which is why the answer is the meet and never
|
|
44
|
+
* each declaration alone: a disabled stub for that pair would cross the same boundary.
|
|
45
|
+
*/
|
|
46
|
+
export type TargetAccess = 'writable' | 'read_only' | 'withheld';
|
|
47
|
+
/** The answer for one target, or `undefined` when the answer cannot name its declarations. */
|
|
48
|
+
export declare function targetAccessOf(ref: FieldRef, enclosing: readonly string[] | undefined, accessFor: (ref: FieldRef) => FieldAccess, redacted: (ref: FieldRef) => boolean): TargetAccess | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* The delivery answer for one binding and every declaration enclosing it, `[ACCESS-1.3.4]`.
|
|
51
|
+
*
|
|
52
|
+
* Delivery is per reference, and a read of a member is refused when any declaration carrying its
|
|
53
|
+
* value withholds it: a member of a record is delivered inside that record's payload, so one
|
|
54
|
+
* withheld ancestor withholds the member with it. The answer states the strongest reason the chain
|
|
55
|
+
* gives, because a caller that must explain a withholding needs the one that outranks the rest.
|
|
56
|
+
*
|
|
57
|
+
* The conjunction is deliberate where the write answer above is the meet: a stored `write_only`
|
|
58
|
+
* value this session wrote reads back even beneath a `read_only` record, because the session's own
|
|
59
|
+
* write is what made it readable.
|
|
60
|
+
*/
|
|
61
|
+
export declare function enclosingDelivery(ref: FieldRef, enclosing: readonly string[] | undefined, answerFor: (ref: FieldRef) => DeliveryAnswer): DeliveryAnswer;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=delivery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delivery.d.ts","sourceRoot":"","sources":["../../../src/eval/access/delivery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE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