@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 @@
|
|
|
1
|
+
{"version":3,"file":"window.d.ts","sourceRoot":"","sources":["../../../src/eval/access/window.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,KAAK,EAAoB,gBAAgB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAc1F,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAIlE;;;;;;;;;;;;;;GAcG;AAEH,sEAAsE;AACtE,MAAM,WAAW,YAAY;IAC3B,8FAA8F;IAC9F,QAAQ,CAAC,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/C,2FAA2F;IAC3F,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,+DAA+D;IAC/D,SAAS,CAAC,GAAG,EAAE,QAAQ,GAAG,WAAW,CAAC;IACtC,6FAA6F;IAC7F,OAAO,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC;IAChC,qFAAqF;IACrF,KAA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,254 @@
|
|
|
1
|
+
import { AxiomError } from '../../model/errors.js';
|
|
2
|
+
import { compareCodePoints } from '../../expr/strings.js';
|
|
3
|
+
import { asAccessVersion, toAccessOverlay } from '../../model/access.js';
|
|
4
|
+
import { arrayFieldIds, fieldKey, fieldRefKeys, permitsReadOf, projectAccess, redactionKey, resolveProjectedAccess, stillRedacted, } from './projection.js';
|
|
5
|
+
import { redactedFieldIds } from '../reader/member-access.js';
|
|
6
|
+
import { toFieldRef } from '../../model/wire.js';
|
|
7
|
+
import { deliveryOf, enclosingDelivery, statedAccess, targetAccessOf } from './delivery.js';
|
|
8
|
+
import { permitsUserWrite } from './write.js';
|
|
9
|
+
import { accessFor, projectAccessEntries, resolveOverlay, ruleReadFor } from './overlay.js';
|
|
10
|
+
/**
|
|
11
|
+
* The redactions a host stated, split into the declarations it named and the rows it named, with
|
|
12
|
+
* the declarations a row-scoped redaction lands on.
|
|
13
|
+
*
|
|
14
|
+
* A declaration named without a row is inherited by every descendant, because a member is delivered
|
|
15
|
+
* inside its container's value. A row of an array is read as the whole declaration: the client may
|
|
16
|
+
* not receive a list the server holds part of, and a row it cannot read is one it cannot address.
|
|
17
|
+
* Every other row-scoped redaction is matched by `fieldKey`, so the integer `1` and the text `"1"`
|
|
18
|
+
* stay two rows.
|
|
19
|
+
*/
|
|
20
|
+
function redactionOf(fields, refs) {
|
|
21
|
+
const declarations = new Set();
|
|
22
|
+
const rows = new Set();
|
|
23
|
+
const rowFields = new Set();
|
|
24
|
+
// The same array set and the same key rule the session-write resolution reads, so "this is one
|
|
25
|
+
// payload the host withheld" cannot mean two things in one evaluation.
|
|
26
|
+
const arrays = arrayFieldIds(fields);
|
|
27
|
+
for (const [index, ref] of (refs ?? []).entries()) {
|
|
28
|
+
const checked = toFieldRef(ref, `$.redacted[${String(index)}]`);
|
|
29
|
+
const key = redactionKey(arrays, checked);
|
|
30
|
+
if (key === checked.fieldId) {
|
|
31
|
+
declarations.add(checked.fieldId);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
rows.add(key);
|
|
35
|
+
rowFields.add(checked.fieldId);
|
|
36
|
+
}
|
|
37
|
+
return { declarations, rows, rowFields };
|
|
38
|
+
}
|
|
39
|
+
const DECLARATION_TREES = new WeakMap();
|
|
40
|
+
function declarationTreeOf(fields) {
|
|
41
|
+
const cached = DECLARATION_TREES.get(fields);
|
|
42
|
+
if (cached !== undefined)
|
|
43
|
+
return cached;
|
|
44
|
+
const enclosing = new Map();
|
|
45
|
+
const children = new Map();
|
|
46
|
+
const visit = (members, ancestors) => {
|
|
47
|
+
for (const field of members) {
|
|
48
|
+
const chain = [...ancestors, field.fieldId];
|
|
49
|
+
enclosing.set(field.fieldId, chain);
|
|
50
|
+
const declared = field.fields ?? [];
|
|
51
|
+
if (declared.length > 0)
|
|
52
|
+
children.set(field.fieldId, declared.map((m) => m.fieldId));
|
|
53
|
+
visit(declared, chain);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
visit(fields, []);
|
|
57
|
+
const tree = { enclosing, children };
|
|
58
|
+
DECLARATION_TREES.set(fields, tree);
|
|
59
|
+
return tree;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Resolves one evaluation's access answer.
|
|
63
|
+
*
|
|
64
|
+
* A call that supplies an overlay and a flattened projection is refused before either is
|
|
65
|
+
* read, and a caller-declared `env.accessVersion` that disagrees with the overlay is refused
|
|
66
|
+
* for the same reason: the overlay is the authority, and a report that stated a version its
|
|
67
|
+
* overlay never had would defeat the server's staleness check.
|
|
68
|
+
*/
|
|
69
|
+
export function createAccessWindow(fields, input, env, overlayPath = '$.overlay') {
|
|
70
|
+
if (input.overlay !== undefined && input.access !== undefined) {
|
|
71
|
+
throw new AxiomError('ENGINE_ERROR', 'an evaluation supplies either an access overlay or a flattened access projection, never both', '$.access');
|
|
72
|
+
}
|
|
73
|
+
const sessionWriteKeys = fieldRefKeys(input.sessionWrites, '$.sessionWrites');
|
|
74
|
+
// The overlay is untrusted host input, so it crosses the same boundary parser whether it
|
|
75
|
+
// arrived through `toEvaluationInput` or a caller assembled the typed object itself.
|
|
76
|
+
const parsed = input.overlay === undefined ? undefined : toAccessOverlay(input.overlay, overlayPath);
|
|
77
|
+
// The row-match check reads the artifact's declarations, so it runs after the overlay's own
|
|
78
|
+
// shape has been read; the path names where the caller supplied the overlay, which is
|
|
79
|
+
// `authority.overlay` for a submission.
|
|
80
|
+
const overlay = parsed === undefined ? undefined : resolveOverlay(fields, parsed, overlayPath);
|
|
81
|
+
if (overlay !== undefined &&
|
|
82
|
+
env.accessVersion !== undefined &&
|
|
83
|
+
env.accessVersion !== overlay.version) {
|
|
84
|
+
throw new AxiomError('ENGINE_ERROR', `env.accessVersion ${String(env.accessVersion)} disagrees with the overlay's ${String(overlay.version)}`, '$.accessVersion');
|
|
85
|
+
}
|
|
86
|
+
const projection = overlay?.entries ?? projectAccess(input.access);
|
|
87
|
+
const tree = declarationTreeOf(fields);
|
|
88
|
+
// A redaction names a declaration or one row of one. An array named per row is read as the
|
|
89
|
+
// whole declaration, because a list the server holds part of is not one this device may receive.
|
|
90
|
+
// Resolve the session's own writes here too: this public door accepts the same `EvaluationInput`
|
|
91
|
+
// as evaluation, so a direct window cannot disagree with the form about a written redaction.
|
|
92
|
+
const redaction = redactionOf(fields, stillRedacted(fields, input.redacted ?? [], input.sessionWrites));
|
|
93
|
+
const redacted = redactedFieldIds(fields, redaction.declarations);
|
|
94
|
+
// Every declaration a row-scoped redaction lands on, and every declaration that carries one: a
|
|
95
|
+
// container holding a row the server holds is not a value this device was given.
|
|
96
|
+
const rowRedacted = new Set();
|
|
97
|
+
for (const fieldId of redaction.rowFields) {
|
|
98
|
+
for (const id of tree.enclosing.get(fieldId) ?? [fieldId])
|
|
99
|
+
rowRedacted.add(id);
|
|
100
|
+
}
|
|
101
|
+
const maskLifted = overlay?.allowMaskedRead ?? new Set();
|
|
102
|
+
// The caller's version is the third place the report's one host-supplied leaf enters, so it
|
|
103
|
+
// crosses the same bound as the overlay and the request reader (`asAccessVersion`). Without
|
|
104
|
+
// it a direct `evaluate()` caller could seal `1.5` or `'1'`, and `'1'` hashes like `1`.
|
|
105
|
+
const version = overlay === undefined ? asAccessVersion(env.accessVersion ?? 0) : overlay.version;
|
|
106
|
+
const resolve = (ref) => overlay === undefined
|
|
107
|
+
? resolveProjectedAccess(projection, ref, sessionWriteKeys)
|
|
108
|
+
: accessFor(overlay, ref, sessionWriteKeys);
|
|
109
|
+
/** The delivery answer one resolved access state states for one reference. */
|
|
110
|
+
const answerOf = (ref, access) =>
|
|
111
|
+
// A host may hold one row of a member rather than the whole declaration, so the redaction is
|
|
112
|
+
// asked per reference (`[ACCESS-3.1.2]`).
|
|
113
|
+
deliveryOf(access, isRedacted(ref), sessionWriteKeys.has(fieldKey(ref)));
|
|
114
|
+
/** Whether one reference is redacted: its declaration, an ancestor, or this very row. */
|
|
115
|
+
const isRedacted = (ref) => {
|
|
116
|
+
if (redacted.has(ref.fieldId))
|
|
117
|
+
return true;
|
|
118
|
+
const rowKey = ref.rowKey;
|
|
119
|
+
if (rowKey === undefined)
|
|
120
|
+
return false;
|
|
121
|
+
return (tree.enclosing.get(ref.fieldId) ?? [ref.fieldId]).some((fieldId) => redaction.rows.has(fieldKey({ fieldId, rowKey })));
|
|
122
|
+
};
|
|
123
|
+
/** The own-level field-wide access a declaration states, before a per-row entry narrows it. */
|
|
124
|
+
const ownAccess = (fieldId) => projection.entries.get(fieldKey({ fieldId })) ?? resolve({ fieldId });
|
|
125
|
+
const ownAnswer = (fieldId) => {
|
|
126
|
+
const entry = projection.entries.get(fieldKey({ fieldId }));
|
|
127
|
+
if (entry !== undefined) {
|
|
128
|
+
return deliveryOf(entry, redacted.has(fieldId), sessionWriteKeys.has(fieldKey({ fieldId })));
|
|
129
|
+
}
|
|
130
|
+
// A projection that states only rows has no field-wide answer to read, so the own answer
|
|
131
|
+
// fails closed exactly as `resolveProjectedAccess` does for the same reference.
|
|
132
|
+
return answerOf({ fieldId }, resolve({ fieldId }));
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Whether one declaration states its own value as a payload.
|
|
136
|
+
*
|
|
137
|
+
* The payload answer is the folded one — a row rule (a template, or an exact row) that withholds
|
|
138
|
+
* one row withholds the list that carries it — and a container holding a row the server holds is
|
|
139
|
+
* not a value this device was given even when every access answer would deliver
|
|
140
|
+
* (`[ACCESS-3.1.2]`). A row *element* is a different question, asked per row by the derivation.
|
|
141
|
+
*/
|
|
142
|
+
const payloadDelivers = (fieldId) => {
|
|
143
|
+
if (!answerOf({ fieldId }, resolve({ fieldId })).deliverable)
|
|
144
|
+
return false;
|
|
145
|
+
return !(tree.children.has(fieldId) && rowRedacted.has(fieldId));
|
|
146
|
+
};
|
|
147
|
+
/** Whether one declaration and every member it carries deliver, memoised for one evaluation. */
|
|
148
|
+
const subtreeMemo = new Map();
|
|
149
|
+
const deliversSubtree = (fieldId, ownDelivers) => {
|
|
150
|
+
const cached = subtreeMemo.get(fieldId);
|
|
151
|
+
if (cached !== undefined)
|
|
152
|
+
return cached;
|
|
153
|
+
const delivered = ownDelivers &&
|
|
154
|
+
(tree.children.get(fieldId) ?? []).every((id) => deliversSubtree(id, answerOf({ fieldId: id }, resolve({ fieldId: id })).deliverable));
|
|
155
|
+
subtreeMemo.set(fieldId, delivered);
|
|
156
|
+
return delivered;
|
|
157
|
+
};
|
|
158
|
+
return {
|
|
159
|
+
sessionWriteKeys,
|
|
160
|
+
version,
|
|
161
|
+
accessFor: resolve,
|
|
162
|
+
mayRead(ref) {
|
|
163
|
+
if (overlay !== undefined)
|
|
164
|
+
return ruleReadFor(overlay, ref, sessionWriteKeys);
|
|
165
|
+
const access = resolve(ref);
|
|
166
|
+
return permitsReadOf(access, fieldKey(ref), sessionWriteKeys);
|
|
167
|
+
},
|
|
168
|
+
field(ref) {
|
|
169
|
+
const access = resolve(ref);
|
|
170
|
+
return {
|
|
171
|
+
access,
|
|
172
|
+
readable: permitsReadOf(access, fieldKey(ref), sessionWriteKeys),
|
|
173
|
+
writable: permitsUserWrite(access),
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
snapshotAccess() {
|
|
177
|
+
return { access: projection, sessionWrites: sessionWriteKeys };
|
|
178
|
+
},
|
|
179
|
+
reportEntries(refs) {
|
|
180
|
+
if (overlay !== undefined)
|
|
181
|
+
return projectAccessEntries(overlay, refs, sessionWriteKeys);
|
|
182
|
+
return projectedReportEntries(projection, refs, sessionWriteKeys);
|
|
183
|
+
},
|
|
184
|
+
redactedFields() {
|
|
185
|
+
return redacted;
|
|
186
|
+
},
|
|
187
|
+
isRedacted(ref) {
|
|
188
|
+
return isRedacted(ref);
|
|
189
|
+
},
|
|
190
|
+
hiddenRow(fieldId) {
|
|
191
|
+
if (projection.rowDefaults?.get(fieldId) === 'hidden')
|
|
192
|
+
return true;
|
|
193
|
+
return (projection.rowEntries.get(fieldId) ?? []).some((row) => row.access === 'hidden');
|
|
194
|
+
},
|
|
195
|
+
mayReadOwn(fieldId) {
|
|
196
|
+
const own = ownAccess(fieldId);
|
|
197
|
+
if (own === 'masked' || own === 'hidden')
|
|
198
|
+
return maskLifted.has(fieldId);
|
|
199
|
+
return permitsReadOf(own, fieldId, sessionWriteKeys);
|
|
200
|
+
},
|
|
201
|
+
ownAccess(fieldId) {
|
|
202
|
+
return ownAccess(fieldId);
|
|
203
|
+
},
|
|
204
|
+
delivery(ref) {
|
|
205
|
+
return answerOf(ref, resolve(ref));
|
|
206
|
+
},
|
|
207
|
+
ownDelivery(fieldId) {
|
|
208
|
+
// No row answer narrows this declaration, so the folded answer *is* its own. A projection
|
|
209
|
+
// that states only rows has no field-wide answer to read, so the own answer reads the
|
|
210
|
+
// entry the resolution states and fails closed when it states none.
|
|
211
|
+
return projection.rowEntries.has(fieldId)
|
|
212
|
+
? ownAnswer(fieldId)
|
|
213
|
+
: answerOf({ fieldId }, resolve({ fieldId }));
|
|
214
|
+
},
|
|
215
|
+
enclosingDelivery(ref) {
|
|
216
|
+
return enclosingDelivery(ref, tree.enclosing.get(ref.fieldId), (at) => answerOf(at, resolve(at)));
|
|
217
|
+
},
|
|
218
|
+
enclosingDelivers(ref) {
|
|
219
|
+
return enclosingDelivery(ref, tree.enclosing.get(ref.fieldId), (at) => answerOf(at, resolve(at))).deliverable;
|
|
220
|
+
},
|
|
221
|
+
subtreeDelivers(fieldId) {
|
|
222
|
+
return deliversSubtree(fieldId, payloadDelivers(fieldId));
|
|
223
|
+
},
|
|
224
|
+
target(ref) {
|
|
225
|
+
return (targetAccessOf(ref, tree.enclosing.get(ref.fieldId), resolve, isRedacted) ?? 'withheld');
|
|
226
|
+
},
|
|
227
|
+
mayFill(ref) {
|
|
228
|
+
const answer = targetAccessOf(ref, tree.enclosing.get(ref.fieldId), resolve, isRedacted);
|
|
229
|
+
if (answer === undefined || answer === 'withheld')
|
|
230
|
+
return false;
|
|
231
|
+
if (answer === 'writable')
|
|
232
|
+
return true;
|
|
233
|
+
// The meet is `read_only`, so a user write is refused. It answers a requirement only when
|
|
234
|
+
// a declaration carrying the value stated it: the default is not a claim about ownership.
|
|
235
|
+
const chain = tree.enclosing.get(ref.fieldId) ?? [];
|
|
236
|
+
return !chain.some((fieldId) => statedAccess(projection, ref.rowKey === undefined ? { fieldId } : { fieldId, rowKey: ref.rowKey }));
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* A flat projection's report entries, deduplicated by declaration and sorted in code-point
|
|
242
|
+
* order. A host that resolves its own per-reference access gets the same per-declaration
|
|
243
|
+
* report answer as a host that supplies an overlay.
|
|
244
|
+
*/
|
|
245
|
+
function projectedReportEntries(projection, refs, sessionWrites) {
|
|
246
|
+
const byField = new Map();
|
|
247
|
+
for (const ref of refs) {
|
|
248
|
+
byField.set(ref.fieldId, resolveProjectedAccess(projection, { fieldId: ref.fieldId }, sessionWrites));
|
|
249
|
+
}
|
|
250
|
+
return [...byField.entries()]
|
|
251
|
+
.sort((left, right) => compareCodePoints(left[0], right[0]))
|
|
252
|
+
.map(([fieldId, access]) => ({ fieldId, access }));
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=window.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"window.js","sourceRoot":"","sources":["../../../src/eval/access/window.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIzE,OAAO,EACL,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,sBAAsB,EACtB,aAAa,GACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAsH5F;;;;;;;;;GASG;AACH,SAAS,WAAW,CAClB,MAAgC,EAChC,IAAqC;IAMrC,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;IACvC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IACpC,+FAA+F;IAC/F,uEAAuE;IACvE,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACrC,KAAK,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,EA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,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CACzE,CACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,sBAAsB,CAC7B,UAA4B,EAC5B,IAAyB,EACzB,aAAkC;IAElC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC/C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CACT,GAAG,CAAC,OAAO,EACX,sBAAsB,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,EAAE,aAAa,CAAC,CAC5E,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;SAC1B,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3D,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AACvD,CAAC","sourcesContent":["import { AxiomError } from '../../model/errors.js';\nimport { compareCodePoints } from '../../expr/strings.js';\nimport { asAccessVersion, toAccessOverlay } from '../../model/access.js';\nimport type { EvaluationEnv, EvaluationInput } from '../../model/access.js';\nimport type { CompiledField, FieldAccess, FieldRef, ReportAccessEntry } from '../../model/types.js';\nimport type { AccessProjection, FieldAccessState, SnapshotAccess } from './projection.js';\nimport {\n arrayFieldIds,\n fieldKey,\n fieldRefKeys,\n permitsReadOf,\n projectAccess,\n redactionKey,\n resolveProjectedAccess,\n stillRedacted,\n} from './projection.js';\nimport { redactedFieldIds } from '../reader/member-access.js';\nimport { toFieldRef } from '../../model/wire.js';\nimport { deliveryOf, enclosingDelivery, statedAccess, targetAccessOf } from './delivery.js';\nimport type { DeliveryAnswer, TargetAccess } from './delivery.js';\nimport { permitsUserWrite } from './write.js';\nimport { accessFor, projectAccessEntries, resolveOverlay, ruleReadFor } from './overlay.js';\n\n/**\n * One evaluation's access answer, resolved once.\n *\n * The window is the only place a read asks \"may I see this\": the reader, a gate's input\n * hash, the submission projection and a UI binding all consume the same resolved overlay,\n * so a report, a delivered control and an exported value cannot answer differently about\n * one field. A caller that supplies both an overlay and a flattened projection is refused\n * here rather than resolved by precedence, because one of the two is then a stale answer.\n *\n * It is also the one delivery projection (`[ACCESS-1.3.4]`): whether a binding's value may be\n * stated, why it may not, whether an alternative may name it and whether a declaration and every\n * declaration with it deliver. Those questions were answered separately in the field derivation,\n * the report's writer path, the target filter of an alternative and the session's identity\n * guard, and separate answers are how a value gets stated by one surface and withheld by another.\n */\n\n/** The answer every access question of one evaluation is asked of. */\nexport interface AccessWindow {\n /** The keys of the values written in this session, so a `write_only` read is decided once. */\n readonly sessionWriteKeys: ReadonlySet<string>;\n /** The version the report states: the overlay's, or the caller's when it supplied none. */\n readonly version: number;\n /** The effective access of one reference, `[ACCESS-2.1.4]`. */\n accessFor(ref: FieldRef): FieldAccess;\n /** Whether a *rule* may read one reference; `allowMaskedRead` applies here and only here. */\n mayRead(ref: FieldRef): boolean;\n /** The delivery answer a UI binding renders: access, readability and writability. */\n field(ref: FieldRef): FieldAccessState;\n /** The projection and session writes a submission reads, so the two cannot disagree. */\n snapshotAccess(): SnapshotAccess;\n /** The report's per-declaration projection over the references an evaluation considered. */\n reportEntries(refs: readonly FieldRef[]): readonly ReportAccessEntry[];\n /**\n * Every redacted declaration and every descendant whose read that redaction refuses.\n *\n * It is the field-wide answer: a declaration named here states `redacted` at every row. A host\n * that names one row asks {@link isRedacted} with that row's reference.\n */\n redactedFields(): ReadonlySet<string>;\n /**\n * Whether one reference is redacted: its declaration, an ancestor of it, or this very row.\n *\n * A row-scoped redaction of an array is read as the whole declaration, because a list the\n * server holds part of is not one this device may receive.\n */\n isRedacted(ref: FieldRef): boolean;\n /**\n * Whether any row of one container is answered `hidden`.\n *\n * A hidden row takes the container's own row set off screen, so the container's folded answer\n * decides its access; a merely `masked` row leaves the control shown with one value withheld.\n */\n hiddenRow(fieldId: string): boolean;\n /**\n * Whether a *rule* may read a declaration's own value, before a per-row entry narrows it.\n *\n * A container's own read is asked this way: a row-exact restriction withholds that row and not\n * the list, and the row walk decides each row against its own entry (`[ACCESS-1.3.1]`).\n */\n mayReadOwn(fieldId: string): boolean;\n /**\n * The delivery answer for one binding's own declaration at its field-wide reference.\n *\n * A per-row entry that withholds one row folds into this answer, so a container carrying a\n * row the device may not read is `hidden` here exactly as `[ACCESS-2.1.4]` resolves it.\n */\n delivery(ref: FieldRef): DeliveryAnswer;\n /**\n * The delivery answer at a declaration's own field-wide level, before a per-row entry narrows\n * it. Row identity is what this separates from the folded answer: a container whose only\n * withheld value is one row's still delivers the rows the device may name, and each row states\n * its own value as withheld (`[ACCESS-1.3.1]`).\n */\n ownDelivery(fieldId: string): DeliveryAnswer;\n /**\n * The effective access at a declaration's own field-wide level, before a per-row entry narrows\n * it. A member of an array is judged per row, so its field-level answer is the one the host\n * stated for the column rather than the fold over its rows.\n */\n ownAccess(fieldId: string): FieldAccess;\n /**\n * The delivery answer for one binding and every declaration enclosing it, `[ACCESS-1.3.4]`.\n *\n * A member is delivered inside its container's payload, so one withheld declaration above it\n * withholds the member with it. The reason is the strongest the chain states, so a caller that\n * must explain a withholding names one reason instead of re-deriving it.\n */\n enclosingDelivery(ref: FieldRef): DeliveryAnswer;\n /** Whether every declaration carrying one binding's value delivers it. */\n enclosingDelivers(ref: FieldRef): boolean;\n /**\n * Whether one declaration and every member it carries deliver, as one payload.\n *\n * A container is delivered as one value, so a member the answer withholds withholds the\n * container with it (`[ACCESS-1.3.4]`).\n */\n subtreeDelivers(fieldId: string): boolean;\n /**\n * Whether an alternative may name one binding, `RULES-6.1.3`, `RULES-7.1.4`.\n *\n * `withheld` is the report's own refusal to offer a stub, so the answer is the meet over the\n * declarations carrying the target and never one declaration alone.\n */\n target(ref: FieldRef): TargetAccess;\n /**\n * Whether a respondent may fill one binding, or the host stated no access answer for it.\n *\n * `read_only` is the fail-closed default (`[ACCESS-2.1.2]`): the right answer to \"may this\n * device write\" and the wrong answer to \"who supplies this value\". A host that stated nothing\n * about a binding has not said the backend owns it, so a required gap there is still the\n * respondent's; a *stated* `read_only` says the value can only arrive from the tier that holds\n * it, and a mask or a hide says it is not the respondent's to set at all.\n */\n mayFill(ref: FieldRef): boolean;\n}\n\n/**\n * The redactions a host stated, split into the declarations it named and the rows it named, with\n * the declarations a row-scoped redaction lands on.\n *\n * A declaration named without a row is inherited by every descendant, because a member is delivered\n * inside its container's value. A row of an array is read as the whole declaration: the client may\n * not receive a list the server holds part of, and a row it cannot read is one it cannot address.\n * Every other row-scoped redaction is matched by `fieldKey`, so the integer `1` and the text `\"1\"`\n * stay two rows.\n */\nfunction redactionOf(\n fields: readonly CompiledField[],\n refs: readonly FieldRef[] | undefined,\n): {\n readonly declarations: ReadonlySet<string>;\n readonly rows: ReadonlySet<string>;\n readonly rowFields: ReadonlySet<string>;\n} {\n const declarations = new Set<string>();\n const rows = new Set<string>();\n const rowFields = new Set<string>();\n // The same array set and the same key rule the session-write resolution reads, so \"this is one\n // payload the host withheld\" cannot mean two things in one evaluation.\n const arrays = arrayFieldIds(fields);\n for (const [index, ref] of (refs ?? []).entries()) {\n const checked = toFieldRef(ref, `$.redacted[${String(index)}]`);\n const key = redactionKey(arrays, checked);\n if (key === checked.fieldId) {\n declarations.add(checked.fieldId);\n continue;\n }\n rows.add(key);\n rowFields.add(checked.fieldId);\n }\n return { declarations, rows, rowFields };\n}\n\n/**\n * The declarations enclosing each field, itself last, and the declarations each one carries.\n *\n * Building it once per artifact is what makes an enclosing or subtree question a map hit: the\n * derivation asks it per field it walks and the write path asks it per suggestion target, and\n * walking the declaration tree for each was the fields times their nesting.\n */\ninterface DeclarationTree {\n readonly enclosing: ReadonlyMap<string, readonly string[]>;\n /** The declarations one declaration carries directly, in declaration order. */\n readonly children: ReadonlyMap<string, readonly string[]>;\n}\n\nconst DECLARATION_TREES: WeakMap<readonly CompiledField[], DeclarationTree> = new WeakMap();\n\nfunction declarationTreeOf(fields: readonly CompiledField[]): DeclarationTree {\n const cached = DECLARATION_TREES.get(fields);\n if (cached !== undefined) return cached;\n const enclosing = new Map<string, string[]>();\n const children = new Map<string, readonly string[]>();\n const visit = (members: readonly CompiledField[], ancestors: readonly string[]): void => {\n for (const field of members) {\n const chain = [...ancestors, field.fieldId];\n enclosing.set(field.fieldId, chain);\n const declared = field.fields ?? [];\n if (declared.length > 0)\n children.set(\n field.fieldId,\n declared.map((m) => m.fieldId),\n );\n visit(declared, chain);\n }\n };\n visit(fields, []);\n const tree: DeclarationTree = { enclosing, children };\n DECLARATION_TREES.set(fields, tree);\n return tree;\n}\n\n/**\n * Resolves one evaluation's access answer.\n *\n * A call that supplies an overlay and a flattened projection is refused before either is\n * read, and a caller-declared `env.accessVersion` that disagrees with the overlay is refused\n * for the same reason: the overlay is the authority, and a report that stated a version its\n * overlay never had would defeat the server's staleness check.\n */\nexport function createAccessWindow(\n fields: readonly CompiledField[],\n input: EvaluationInput,\n env: EvaluationEnv,\n overlayPath = '$.overlay',\n): AccessWindow {\n if (input.overlay !== undefined && input.access !== undefined) {\n throw new AxiomError(\n 'ENGINE_ERROR',\n 'an evaluation supplies either an access overlay or a flattened access projection, never both',\n '$.access',\n );\n }\n const sessionWriteKeys = fieldRefKeys(input.sessionWrites, '$.sessionWrites');\n // The overlay is untrusted host input, so it crosses the same boundary parser whether it\n // arrived through `toEvaluationInput` or a caller assembled the typed object itself.\n const parsed =\n input.overlay === undefined ? undefined : toAccessOverlay(input.overlay, overlayPath);\n // The row-match check reads the artifact's declarations, so it runs after the overlay's own\n // shape has been read; the path names where the caller supplied the overlay, which is\n // `authority.overlay` for a submission.\n const overlay = parsed === undefined ? undefined : resolveOverlay(fields, parsed, overlayPath);\n if (\n overlay !== undefined &&\n env.accessVersion !== undefined &&\n env.accessVersion !== overlay.version\n ) {\n throw new AxiomError(\n 'ENGINE_ERROR',\n `env.accessVersion ${String(env.accessVersion)} disagrees with the overlay's ${String(overlay.version)}`,\n '$.accessVersion',\n );\n }\n const projection = overlay?.entries ?? projectAccess(input.access);\n const tree = declarationTreeOf(fields);\n // A redaction names a declaration or one row of one. An array named per row is read as the\n // whole declaration, because a list the server holds part of is not one this device may receive.\n // Resolve the session's own writes here too: this public door accepts the same `EvaluationInput`\n // as evaluation, so a direct window cannot disagree with the form about a written redaction.\n const redaction = redactionOf(\n fields,\n stillRedacted(fields, input.redacted ?? [], input.sessionWrites),\n );\n const redacted = redactedFieldIds(fields, redaction.declarations);\n // Every declaration a row-scoped redaction lands on, and every declaration that carries one: a\n // container holding a row the server holds is not a value this device was given.\n const rowRedacted = new Set<string>();\n for (const fieldId of redaction.rowFields) {\n for (const id of tree.enclosing.get(fieldId) ?? [fieldId]) rowRedacted.add(id);\n }\n const maskLifted: ReadonlySet<string> = overlay?.allowMaskedRead ?? new Set();\n // The caller's version is the third place the report's one host-supplied leaf enters, so it\n // crosses the same bound as the overlay and the request reader (`asAccessVersion`). Without\n // it a direct `evaluate()` caller could seal `1.5` or `'1'`, and `'1'` hashes like `1`.\n const version = overlay === undefined ? asAccessVersion(env.accessVersion ?? 0) : overlay.version;\n const resolve = (ref: FieldRef): FieldAccess =>\n overlay === undefined\n ? resolveProjectedAccess(projection, ref, sessionWriteKeys)\n : accessFor(overlay, ref, sessionWriteKeys);\n /** The delivery answer one resolved access state states for one reference. */\n const answerOf = (ref: FieldRef, access: FieldAccess): DeliveryAnswer =>\n // A host may hold one row of a member rather than the whole declaration, so the redaction is\n // asked per reference (`[ACCESS-3.1.2]`).\n deliveryOf(access, isRedacted(ref), sessionWriteKeys.has(fieldKey(ref)));\n /** Whether one reference is redacted: its declaration, an ancestor, or this very row. */\n const isRedacted = (ref: FieldRef): boolean => {\n if (redacted.has(ref.fieldId)) return true;\n const rowKey = ref.rowKey;\n if (rowKey === undefined) return false;\n return (tree.enclosing.get(ref.fieldId) ?? [ref.fieldId]).some((fieldId) =>\n redaction.rows.has(fieldKey({ fieldId, rowKey })),\n );\n };\n /** The own-level field-wide access a declaration states, before a per-row entry narrows it. */\n const ownAccess = (fieldId: string): FieldAccess =>\n projection.entries.get(fieldKey({ fieldId })) ?? resolve({ fieldId });\n const ownAnswer = (fieldId: string): DeliveryAnswer => {\n const entry = projection.entries.get(fieldKey({ fieldId }));\n if (entry !== undefined) {\n return deliveryOf(entry, redacted.has(fieldId), sessionWriteKeys.has(fieldKey({ fieldId })));\n }\n // A projection that states only rows has no field-wide answer to read, so the own answer\n // fails closed exactly as `resolveProjectedAccess` does for the same reference.\n return answerOf({ fieldId }, resolve({ fieldId }));\n };\n /**\n * Whether one declaration states its own value as a payload.\n *\n * The payload answer is the folded one — a row rule (a template, or an exact row) that withholds\n * one row withholds the list that carries it — and a container holding a row the server holds is\n * not a value this device was given even when every access answer would deliver\n * (`[ACCESS-3.1.2]`). A row *element* is a different question, asked per row by the derivation.\n */\n const payloadDelivers = (fieldId: string): boolean => {\n if (!answerOf({ fieldId }, resolve({ fieldId })).deliverable) return false;\n return !(tree.children.has(fieldId) && rowRedacted.has(fieldId));\n };\n /** Whether one declaration and every member it carries deliver, memoised for one evaluation. */\n const subtreeMemo = new Map<string, boolean>();\n const deliversSubtree = (fieldId: string, ownDelivers: boolean): boolean => {\n const cached = subtreeMemo.get(fieldId);\n if (cached !== undefined) return cached;\n const delivered =\n ownDelivers &&\n (tree.children.get(fieldId) ?? []).every((id) =>\n deliversSubtree(id, answerOf({ fieldId: id }, resolve({ fieldId: id })).deliverable),\n );\n subtreeMemo.set(fieldId, delivered);\n return delivered;\n };\n return {\n sessionWriteKeys,\n version,\n accessFor: resolve,\n mayRead(ref) {\n if (overlay !== undefined) return ruleReadFor(overlay, ref, sessionWriteKeys);\n const access = resolve(ref);\n return permitsReadOf(access, fieldKey(ref), sessionWriteKeys);\n },\n field(ref) {\n const access = resolve(ref);\n return {\n access,\n readable: permitsReadOf(access, fieldKey(ref), sessionWriteKeys),\n writable: permitsUserWrite(access),\n };\n },\n snapshotAccess() {\n return { access: projection, sessionWrites: sessionWriteKeys };\n },\n reportEntries(refs) {\n if (overlay !== undefined) return projectAccessEntries(overlay, refs, sessionWriteKeys);\n return projectedReportEntries(projection, refs, sessionWriteKeys);\n },\n redactedFields() {\n return redacted;\n },\n isRedacted(ref) {\n return isRedacted(ref);\n },\n hiddenRow(fieldId) {\n if (projection.rowDefaults?.get(fieldId) === 'hidden') return true;\n return (projection.rowEntries.get(fieldId) ?? []).some((row) => row.access === 'hidden');\n },\n mayReadOwn(fieldId) {\n const own = ownAccess(fieldId);\n if (own === 'masked' || own === 'hidden') return maskLifted.has(fieldId);\n return permitsReadOf(own, fieldId, sessionWriteKeys);\n },\n ownAccess(fieldId) {\n return ownAccess(fieldId);\n },\n delivery(ref) {\n return answerOf(ref, resolve(ref));\n },\n ownDelivery(fieldId) {\n // No row answer narrows this declaration, so the folded answer *is* its own. A projection\n // that states only rows has no field-wide answer to read, so the own answer reads the\n // entry the resolution states and fails closed when it states none.\n return projection.rowEntries.has(fieldId)\n ? ownAnswer(fieldId)\n : answerOf({ fieldId }, resolve({ fieldId }));\n },\n enclosingDelivery(ref) {\n return enclosingDelivery(ref, tree.enclosing.get(ref.fieldId), (at) =>\n answerOf(at, resolve(at)),\n );\n },\n enclosingDelivers(ref) {\n return enclosingDelivery(ref, tree.enclosing.get(ref.fieldId), (at) =>\n answerOf(at, resolve(at)),\n ).deliverable;\n },\n subtreeDelivers(fieldId) {\n return deliversSubtree(fieldId, payloadDelivers(fieldId));\n },\n target(ref) {\n return (\n targetAccessOf(ref, tree.enclosing.get(ref.fieldId), resolve, isRedacted) ?? 'withheld'\n );\n },\n mayFill(ref) {\n const answer = targetAccessOf(ref, tree.enclosing.get(ref.fieldId), resolve, isRedacted);\n if (answer === undefined || answer === 'withheld') return false;\n if (answer === 'writable') return true;\n // The meet is `read_only`, so a user write is refused. It answers a requirement only when\n // a declaration carrying the value stated it: the default is not a claim about ownership.\n const chain = tree.enclosing.get(ref.fieldId) ?? [];\n return !chain.some((fieldId) =>\n statedAccess(\n projection,\n ref.rowKey === undefined ? { fieldId } : { fieldId, rowKey: ref.rowKey },\n ),\n );\n },\n };\n}\n\n/**\n * A flat projection's report entries, deduplicated by declaration and sorted in code-point\n * order. A host that resolves its own per-reference access gets the same per-declaration\n * report answer as a host that supplies an overlay.\n */\nfunction projectedReportEntries(\n projection: AccessProjection,\n refs: readonly FieldRef[],\n sessionWrites: ReadonlySet<string>,\n): readonly ReportAccessEntry[] {\n const byField = new Map<string, FieldAccess>();\n for (const ref of refs) {\n byField.set(\n ref.fieldId,\n resolveProjectedAccess(projection, { fieldId: ref.fieldId }, sessionWrites),\n );\n }\n return [...byField.entries()]\n .sort((left, right) => compareCodePoints(left[0], right[0]))\n .map(([fieldId, access]) => ({ fieldId, access }));\n}\n"]}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { FieldAccess, FieldRef, Primitive } from '../../model/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The write predicate of `spec/semantics/access-v1.md` section 1.2, and the structured
|
|
4
|
+
* refusal every writer answers with.
|
|
5
|
+
*
|
|
6
|
+
* A write is judged by a closed set of facts, and never by the value being written: who
|
|
7
|
+
* issued it (`[ACCESS-1.1.2]`), the resolved access of the reference, whether the control's
|
|
8
|
+
* `enabled` rules currently pass, the field's primitive, whether the reference addresses a
|
|
9
|
+
* row, and whether the write changes a held value. Keeping the decision here is what stops
|
|
10
|
+
* a UI that renders one answer from guarding with another — the one predicate serves the
|
|
11
|
+
* engine, the React bindings and a host's own ingestion.
|
|
12
|
+
*/
|
|
13
|
+
/** Who issued a write, `[ACCESS-1.1.2]`. */
|
|
14
|
+
export type WriteOrigin = 'user' | 'system' | 'hydrate' | 'sync';
|
|
15
|
+
/**
|
|
16
|
+
* The four reasons a write is refused, `[ACCESS-1.2.4]`, as the tuple a caller names each by.
|
|
17
|
+
*
|
|
18
|
+
* - `ACCESS_DENIED` — the reference's access does not permit the write, a `user` write targets
|
|
19
|
+
* `signature_ref` regardless of overlay, or a `user` write names a value a writer owns
|
|
20
|
+
* (`[ACCESS-1.2.4]`, `RULES-2.1.7`).
|
|
21
|
+
* - `DISABLED` — access permits a write, but an `enabled` rule currently shuts the
|
|
22
|
+
* control off.
|
|
23
|
+
* - `ROW_UNADDRESSABLE` — the value exists once per row and the reference names no row.
|
|
24
|
+
* - `INVALID_VALUE` — the value is outside its declaration, or data ingestion would change a
|
|
25
|
+
* value it may only confirm (`[ACCESS-1.2.3]`).
|
|
26
|
+
*/
|
|
27
|
+
export declare const WRITE_REFUSAL_CODES: readonly ['ACCESS_DENIED', 'DISABLED', 'ROW_UNADDRESSABLE', 'INVALID_VALUE'];
|
|
28
|
+
/** The four reasons a write is refused, derived from the tuple above. */
|
|
29
|
+
export type WriteRefusalCode = (typeof WRITE_REFUSAL_CODES)[number];
|
|
30
|
+
/**
|
|
31
|
+
* The repair a refused write names, keyed by the closed code union.
|
|
32
|
+
*
|
|
33
|
+
* A refusal says why this device will not keep the value; without an action beside it a host
|
|
34
|
+
* can only show the code. The sentence never states the value, its length or a property
|
|
35
|
+
* derived from it (`[ACCESS-1.3.4]`), so it is as safe to log as the refusal itself.
|
|
36
|
+
*/
|
|
37
|
+
export declare const WRITE_REFUSAL_REPAIRS: Readonly<Record<WriteRefusalCode, string>>;
|
|
38
|
+
/** The repair row for one write refusal, total over the closed union. */
|
|
39
|
+
export declare function writeRefusalRepair(code: WriteRefusalCode): string;
|
|
40
|
+
/**
|
|
41
|
+
* A refused write: the code, the origin and the reference it named.
|
|
42
|
+
*
|
|
43
|
+
* A refusal never spells the value, its length or a property derived from it
|
|
44
|
+
* (`[ACCESS-1.3.4]`), so it is safe to put in a log or a diagnostic. It exists so this
|
|
45
|
+
* device's control and the refusal agree; it is not authorisation, because a client that
|
|
46
|
+
* ignores it can still submit (`[ACCESS-7.1.1]`, `[ACCESS-7.1.3]`).
|
|
47
|
+
*/
|
|
48
|
+
export interface WriteRefusal {
|
|
49
|
+
readonly outcome: 'refused';
|
|
50
|
+
readonly code: WriteRefusalCode;
|
|
51
|
+
readonly origin: WriteOrigin;
|
|
52
|
+
readonly fieldId: string;
|
|
53
|
+
readonly rowKey?: FieldRef['rowKey'];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Everything the predicate judges a write against. The caller resolves these once — the
|
|
57
|
+
* access state and the `enabled` answer are the same ones the control was rendered with.
|
|
58
|
+
*/
|
|
59
|
+
export interface WriteRequest {
|
|
60
|
+
readonly ref: FieldRef;
|
|
61
|
+
readonly origin: WriteOrigin;
|
|
62
|
+
readonly access: FieldAccess;
|
|
63
|
+
/** Whether every declared `enabled` rule for the field currently passes. */
|
|
64
|
+
readonly enabled: boolean;
|
|
65
|
+
readonly primitive: Primitive;
|
|
66
|
+
/**
|
|
67
|
+
* Whether the field's value exists once per row, so only a row-keyed reference can
|
|
68
|
+
* address it.
|
|
69
|
+
*/
|
|
70
|
+
readonly item: boolean;
|
|
71
|
+
/** Whether the write would change the value the session already holds. */
|
|
72
|
+
readonly changed: boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Whether a write is permitted: `undefined` when it is, the refusal when it is not.
|
|
76
|
+
*
|
|
77
|
+
* `system` writes are allowed on any addressable reference. `hydrate` and `sync` writes are
|
|
78
|
+
* ingestion rather than user intent, so the user guards do not reject them — but they may
|
|
79
|
+
* only confirm a value the session already holds (`[ACCESS-1.2.3]`). A `user` write is
|
|
80
|
+
* denied on a `signature_ref` regardless of overlay and on any access that withholds the
|
|
81
|
+
* write, and disabled when an `enabled` rule fails. The host still validates and authorises
|
|
82
|
+
* every write itself (`[ACCESS-7.1.3]`).
|
|
83
|
+
*
|
|
84
|
+
* A value a writer owns is refused by the session before this predicate is asked
|
|
85
|
+
* (`eval/engine/ops.ts`), because ownership is the session's fact rather than an access
|
|
86
|
+
* answer: the refusal names the same `ACCESS_DENIED`, so a host reads one code for "this
|
|
87
|
+
* session will not keep what you typed" (`[ACCESS-1.2.4]`, `RULES-2.1.7`).
|
|
88
|
+
*/
|
|
89
|
+
export declare function checkWrite(request: WriteRequest): WriteRefusal | undefined;
|
|
90
|
+
/** Whether an access state lets a user write at all, `[ACCESS-1.2.1]`. */
|
|
91
|
+
export declare function permitsUserWrite(access: FieldAccess): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* A write the session refused. The error carries the structured refusal, so a handler that
|
|
94
|
+
* catches it can branch on the code instead of parsing a message.
|
|
95
|
+
*
|
|
96
|
+
* The setter keeps its `(value) => void` shape, so it is still passed directly to a
|
|
97
|
+
* control's change handler; a refusal surfaces as this error rather than a silent no-op
|
|
98
|
+
* that would leave the control reporting a change the session never applied.
|
|
99
|
+
*/
|
|
100
|
+
export declare class WriteRefusedError extends Error {
|
|
101
|
+
readonly refusal: WriteRefusal;
|
|
102
|
+
readonly code: WriteRefusalCode;
|
|
103
|
+
readonly fieldId: string;
|
|
104
|
+
/**
|
|
105
|
+
* `options.cause` carries the boundary parse that refused a value, when there was one.
|
|
106
|
+
*
|
|
107
|
+
* The refusal's own shape never spells the value, so the diagnostic — a path and the
|
|
108
|
+
* declaration that rejected it — stays attached rather than being discarded on the way to a
|
|
109
|
+
* caller that branches on the code.
|
|
110
|
+
*/
|
|
111
|
+
constructor(refusal: WriteRefusal, options?: ErrorOptions);
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=write.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../src/eval/access/write.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE7E;;;;;;;;;;GAUG;AAEH,4CAA4C;AAC5C,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG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,CAsB1E;AAED,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAE7D;AAaD;;;;;;;GAOG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;;;;;OAMG;IACH,YAAY,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,YAAY,EASxD;CACF"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { assertNever } from '../../model/errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* The four reasons a write is refused, `[ACCESS-1.2.4]`, as the tuple a caller names each by.
|
|
4
|
+
*
|
|
5
|
+
* - `ACCESS_DENIED` — the reference's access does not permit the write, a `user` write targets
|
|
6
|
+
* `signature_ref` regardless of overlay, or a `user` write names a value a writer owns
|
|
7
|
+
* (`[ACCESS-1.2.4]`, `RULES-2.1.7`).
|
|
8
|
+
* - `DISABLED` — access permits a write, but an `enabled` rule currently shuts the
|
|
9
|
+
* control off.
|
|
10
|
+
* - `ROW_UNADDRESSABLE` — the value exists once per row and the reference names no row.
|
|
11
|
+
* - `INVALID_VALUE` — the value is outside its declaration, or data ingestion would change a
|
|
12
|
+
* value it may only confirm (`[ACCESS-1.2.3]`).
|
|
13
|
+
*/
|
|
14
|
+
export const WRITE_REFUSAL_CODES = [
|
|
15
|
+
'ACCESS_DENIED',
|
|
16
|
+
'DISABLED',
|
|
17
|
+
'ROW_UNADDRESSABLE',
|
|
18
|
+
'INVALID_VALUE',
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* The repair a refused write names, keyed by the closed code union.
|
|
22
|
+
*
|
|
23
|
+
* A refusal says why this device will not keep the value; without an action beside it a host
|
|
24
|
+
* can only show the code. The sentence never states the value, its length or a property
|
|
25
|
+
* derived from it (`[ACCESS-1.3.4]`), so it is as safe to log as the refusal itself.
|
|
26
|
+
*/
|
|
27
|
+
export const WRITE_REFUSAL_REPAIRS = {
|
|
28
|
+
ACCESS_DENIED: 'Write a field the access overlay permits; a user write cannot target a `signature_ref` or a value a writer owns.',
|
|
29
|
+
DISABLED: 'Enable the control first; one of its `enabled` rules currently fails.',
|
|
30
|
+
ROW_UNADDRESSABLE: 'Name the row with `rowKey`; the value exists once per row.',
|
|
31
|
+
INVALID_VALUE: "Write a value the field's `primitive` admits; a `hydrate` or `sync` write may only confirm the value already held.",
|
|
32
|
+
};
|
|
33
|
+
/** The repair row for one write refusal, total over the closed union. */
|
|
34
|
+
export function writeRefusalRepair(code) {
|
|
35
|
+
return WRITE_REFUSAL_REPAIRS[code];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether a write is permitted: `undefined` when it is, the refusal when it is not.
|
|
39
|
+
*
|
|
40
|
+
* `system` writes are allowed on any addressable reference. `hydrate` and `sync` writes are
|
|
41
|
+
* ingestion rather than user intent, so the user guards do not reject them — but they may
|
|
42
|
+
* only confirm a value the session already holds (`[ACCESS-1.2.3]`). A `user` write is
|
|
43
|
+
* denied on a `signature_ref` regardless of overlay and on any access that withholds the
|
|
44
|
+
* write, and disabled when an `enabled` rule fails. The host still validates and authorises
|
|
45
|
+
* every write itself (`[ACCESS-7.1.3]`).
|
|
46
|
+
*
|
|
47
|
+
* A value a writer owns is refused by the session before this predicate is asked
|
|
48
|
+
* (`eval/engine/ops.ts`), because ownership is the session's fact rather than an access
|
|
49
|
+
* answer: the refusal names the same `ACCESS_DENIED`, so a host reads one code for "this
|
|
50
|
+
* session will not keep what you typed" (`[ACCESS-1.2.4]`, `RULES-2.1.7`).
|
|
51
|
+
*/
|
|
52
|
+
export function checkWrite(request) {
|
|
53
|
+
// An unaddressed item has no value to judge: the refusal is about the reference, so it
|
|
54
|
+
// precedes every origin rule.
|
|
55
|
+
if (request.item && request.ref.rowKey === undefined) {
|
|
56
|
+
return refused(request, 'ROW_UNADDRESSABLE');
|
|
57
|
+
}
|
|
58
|
+
switch (request.origin) {
|
|
59
|
+
case 'system':
|
|
60
|
+
return undefined;
|
|
61
|
+
case 'hydrate':
|
|
62
|
+
case 'sync':
|
|
63
|
+
return request.changed ? refused(request, 'INVALID_VALUE') : undefined;
|
|
64
|
+
case 'user':
|
|
65
|
+
// Only the host's system-origin capture ceremony may write a signature, so no
|
|
66
|
+
// overlay can grant it to a user.
|
|
67
|
+
if (request.primitive === 'signature_ref')
|
|
68
|
+
return refused(request, 'ACCESS_DENIED');
|
|
69
|
+
if (!permitsUserWrite(request.access))
|
|
70
|
+
return refused(request, 'ACCESS_DENIED');
|
|
71
|
+
if (!request.enabled)
|
|
72
|
+
return refused(request, 'DISABLED');
|
|
73
|
+
return undefined;
|
|
74
|
+
default:
|
|
75
|
+
return assertNever(request.origin);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** Whether an access state lets a user write at all, `[ACCESS-1.2.1]`. */
|
|
79
|
+
export function permitsUserWrite(access) {
|
|
80
|
+
return access === 'read_write' || access === 'write_only';
|
|
81
|
+
}
|
|
82
|
+
/** Builds the refusal for one request, keeping the row key only when the reference has one. */
|
|
83
|
+
function refused(request, code) {
|
|
84
|
+
return {
|
|
85
|
+
outcome: 'refused',
|
|
86
|
+
code,
|
|
87
|
+
origin: request.origin,
|
|
88
|
+
fieldId: request.ref.fieldId,
|
|
89
|
+
...(request.ref.rowKey === undefined ? {} : { rowKey: request.ref.rowKey }),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* A write the session refused. The error carries the structured refusal, so a handler that
|
|
94
|
+
* catches it can branch on the code instead of parsing a message.
|
|
95
|
+
*
|
|
96
|
+
* The setter keeps its `(value) => void` shape, so it is still passed directly to a
|
|
97
|
+
* control's change handler; a refusal surfaces as this error rather than a silent no-op
|
|
98
|
+
* that would leave the control reporting a change the session never applied.
|
|
99
|
+
*/
|
|
100
|
+
export class WriteRefusedError extends Error {
|
|
101
|
+
refusal;
|
|
102
|
+
code;
|
|
103
|
+
fieldId;
|
|
104
|
+
/**
|
|
105
|
+
* `options.cause` carries the boundary parse that refused a value, when there was one.
|
|
106
|
+
*
|
|
107
|
+
* The refusal's own shape never spells the value, so the diagnostic — a path and the
|
|
108
|
+
* declaration that rejected it — stays attached rather than being discarded on the way to a
|
|
109
|
+
* caller that branches on the code.
|
|
110
|
+
*/
|
|
111
|
+
constructor(refusal, options) {
|
|
112
|
+
super(`a ${refusal.origin} write to ${JSON.stringify(refusal.fieldId)} was refused with ${refusal.code}; ${writeRefusalRepair(refusal.code)}`, options);
|
|
113
|
+
this.name = 'WriteRefusedError';
|
|
114
|
+
this.refusal = refusal;
|
|
115
|
+
this.code = refusal.code;
|
|
116
|
+
this.fieldId = refusal.fieldId;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=write.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write.js","sourceRoot":"","sources":["../../../src/eval/access/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAkBpD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,eAAe;IACf,UAAU;IACV,mBAAmB;IACnB,eAAe;CACP,CAAC;AAKX;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA+C;IAC/E,aAAa,EACX,kHAAkH;IACpH,QAAQ,EAAE,uEAAuE;IACjF,iBAAiB,EAAE,4DAA4D;IAC/E,aAAa,EACX,oHAAoH;CACvH,CAAC;AAEF,yEAAyE;AACzE,MAAM,UAAU,kBAAkB,CAAC,IAAsB;IACvD,OAAO,qBAAqB,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC;AAsCD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,UAAU,CAAC,OAAqB;IAC9C,uFAAuF;IAC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M,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;KAC5E,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IACjC,OAAO,CAAe;IACtB,IAAI,CAAmB;IACvB,OAAO,CAAS;IAEzB;;;;;;OAMG;IACH,YAAY,OAAqB,EAAE,OAAsB;QACvD,KAAK,CACH,KAAK,OAAO,CAAC,MAAM,aAAa,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,qBAAqB,OAAO,CAAC,IAAI,KAAK,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EACvI,OAAO,CACR,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IACjC,CAAC;CACF","sourcesContent":["import { assertNever } from '../../model/errors.js';\nimport type { FieldAccess, FieldRef, Primitive } from '../../model/types.js';\n\n/**\n * The write predicate of `spec/semantics/access-v1.md` section 1.2, and the structured\n * refusal every writer answers with.\n *\n * A write is judged by a closed set of facts, and never by the value being written: who\n * issued it (`[ACCESS-1.1.2]`), the resolved access of the reference, whether the control's\n * `enabled` rules currently pass, the field's primitive, whether the reference addresses a\n * row, and whether the write changes a held value. Keeping the decision here is what stops\n * a UI that renders one answer from guarding with another — the one predicate serves the\n * engine, the React bindings and a host's own ingestion.\n */\n\n/** Who issued a write, `[ACCESS-1.1.2]`. */\nexport type WriteOrigin = 'user' | 'system' | 'hydrate' | 'sync';\n\n/**\n * The four reasons a write is refused, `[ACCESS-1.2.4]`, as the tuple a caller names each by.\n *\n * - `ACCESS_DENIED` — the reference's access does not permit the write, a `user` write targets\n * `signature_ref` regardless of overlay, or a `user` write names a value a writer owns\n * (`[ACCESS-1.2.4]`, `RULES-2.1.7`).\n * - `DISABLED` — access permits a write, but an `enabled` rule currently shuts the\n * control off.\n * - `ROW_UNADDRESSABLE` — the value exists once per row and the reference names no row.\n * - `INVALID_VALUE` — the value is outside its declaration, or data ingestion would change a\n * value it may only confirm (`[ACCESS-1.2.3]`).\n */\nexport const WRITE_REFUSAL_CODES = [\n 'ACCESS_DENIED',\n 'DISABLED',\n 'ROW_UNADDRESSABLE',\n 'INVALID_VALUE',\n] as const;\n\n/** The four reasons a write is refused, derived from the tuple above. */\nexport type WriteRefusalCode = (typeof WRITE_REFUSAL_CODES)[number];\n\n/**\n * The repair a refused write names, keyed by the closed code union.\n *\n * A refusal says why this device will not keep the value; without an action beside it a host\n * can only show the code. The sentence never states the value, its length or a property\n * derived from it (`[ACCESS-1.3.4]`), so it is as safe to log as the refusal itself.\n */\nexport const WRITE_REFUSAL_REPAIRS: Readonly<Record<WriteRefusalCode, string>> = {\n ACCESS_DENIED:\n 'Write a field the access overlay permits; a user write cannot target a `signature_ref` or a value a writer owns.',\n DISABLED: 'Enable the control first; one of its `enabled` rules currently fails.',\n ROW_UNADDRESSABLE: 'Name the row with `rowKey`; the value exists once per row.',\n INVALID_VALUE:\n \"Write a value the field's `primitive` admits; a `hydrate` or `sync` write may only confirm the value already held.\",\n};\n\n/** The repair row for one write refusal, total over the closed union. */\nexport function writeRefusalRepair(code: WriteRefusalCode): string {\n return WRITE_REFUSAL_REPAIRS[code];\n}\n\n/**\n * A refused write: the code, the origin and the reference it named.\n *\n * A refusal never spells the value, its length or a property derived from it\n * (`[ACCESS-1.3.4]`), so it is safe to put in a log or a diagnostic. It exists so this\n * device's control and the refusal agree; it is not authorisation, because a client that\n * ignores it can still submit (`[ACCESS-7.1.1]`, `[ACCESS-7.1.3]`).\n */\nexport interface WriteRefusal {\n readonly outcome: 'refused';\n readonly code: WriteRefusalCode;\n readonly origin: WriteOrigin;\n readonly fieldId: string;\n readonly rowKey?: FieldRef['rowKey'];\n}\n\n/**\n * Everything the predicate judges a write against. The caller resolves these once — the\n * access state and the `enabled` answer are the same ones the control was rendered with.\n */\nexport interface WriteRequest {\n readonly ref: FieldRef;\n readonly origin: WriteOrigin;\n readonly access: FieldAccess;\n /** Whether every declared `enabled` rule for the field currently passes. */\n readonly enabled: boolean;\n readonly primitive: Primitive;\n /**\n * Whether the field's value exists once per row, so only a row-keyed reference can\n * address it.\n */\n readonly item: boolean;\n /** Whether the write would change the value the session already holds. */\n readonly changed: boolean;\n}\n\n/**\n * Whether a write is permitted: `undefined` when it is, the refusal when it is not.\n *\n * `system` writes are allowed on any addressable reference. `hydrate` and `sync` writes are\n * ingestion rather than user intent, so the user guards do not reject them — but they may\n * only confirm a value the session already holds (`[ACCESS-1.2.3]`). A `user` write is\n * denied on a `signature_ref` regardless of overlay and on any access that withholds the\n * write, and disabled when an `enabled` rule fails. The host still validates and authorises\n * every write itself (`[ACCESS-7.1.3]`).\n *\n * A value a writer owns is refused by the session before this predicate is asked\n * (`eval/engine/ops.ts`), because ownership is the session's fact rather than an access\n * answer: the refusal names the same `ACCESS_DENIED`, so a host reads one code for \"this\n * session will not keep what you typed\" (`[ACCESS-1.2.4]`, `RULES-2.1.7`).\n */\nexport function checkWrite(request: WriteRequest): WriteRefusal | undefined {\n // An unaddressed item has no value to judge: the refusal is about the reference, so it\n // precedes every origin rule.\n if (request.item && request.ref.rowKey === undefined) {\n return refused(request, 'ROW_UNADDRESSABLE');\n }\n switch (request.origin) {\n case 'system':\n return undefined;\n case 'hydrate':\n case 'sync':\n return request.changed ? refused(request, 'INVALID_VALUE') : undefined;\n case 'user':\n // Only the host's system-origin capture ceremony may write a signature, so no\n // overlay can grant it to a user.\n if (request.primitive === 'signature_ref') return refused(request, 'ACCESS_DENIED');\n if (!permitsUserWrite(request.access)) return refused(request, 'ACCESS_DENIED');\n if (!request.enabled) return refused(request, 'DISABLED');\n return undefined;\n default:\n return assertNever(request.origin);\n }\n}\n\n/** Whether an access state lets a user write at all, `[ACCESS-1.2.1]`. */\nexport function permitsUserWrite(access: FieldAccess): boolean {\n return access === 'read_write' || access === 'write_only';\n}\n\n/** Builds the refusal for one request, keeping the row key only when the reference has one. */\nfunction refused(request: WriteRequest, code: WriteRefusalCode): WriteRefusal {\n return {\n outcome: 'refused',\n code,\n origin: request.origin,\n fieldId: request.ref.fieldId,\n ...(request.ref.rowKey === undefined ? {} : { rowKey: request.ref.rowKey }),\n };\n}\n\n/**\n * A write the session refused. The error carries the structured refusal, so a handler that\n * catches it can branch on the code instead of parsing a message.\n *\n * The setter keeps its `(value) => void` shape, so it is still passed directly to a\n * control's change handler; a refusal surfaces as this error rather than a silent no-op\n * that would leave the control reporting a change the session never applied.\n */\nexport class WriteRefusedError extends Error {\n readonly refusal: WriteRefusal;\n readonly code: WriteRefusalCode;\n readonly fieldId: string;\n\n /**\n * `options.cause` carries the boundary parse that refused a value, when there was one.\n *\n * The refusal's own shape never spells the value, so the diagnostic — a path and the\n * declaration that rejected it — stays attached rather than being discarded on the way to a\n * caller that branches on the code.\n */\n constructor(refusal: WriteRefusal, options?: ErrorOptions) {\n super(\n `a ${refusal.origin} write to ${JSON.stringify(refusal.fieldId)} was refused with ${refusal.code}; ${writeRefusalRepair(refusal.code)}`,\n options,\n );\n this.name = 'WriteRefusedError';\n this.refusal = refusal;\n this.code = refusal.code;\n this.fieldId = refusal.fieldId;\n }\n}\n"]}
|