@mostra/protocol 0.0.0-stage → 0.1.0
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 +202 -0
- package/README.md +38 -2
- package/dist/actions.d.ts +273 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +154 -0
- package/dist/actions.js.map +1 -0
- package/dist/artifact.d.ts +113 -0
- package/dist/artifact.d.ts.map +1 -0
- package/dist/artifact.js +79 -0
- package/dist/artifact.js.map +1 -0
- package/dist/bridge.d.ts +295 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/bridge.js +343 -0
- package/dist/bridge.js.map +1 -0
- package/dist/browser.d.ts +195 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +156 -0
- package/dist/browser.js.map +1 -0
- package/dist/bundle.d.ts +155 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +130 -0
- package/dist/bundle.js.map +1 -0
- package/dist/canonical.d.ts +23 -0
- package/dist/canonical.d.ts.map +1 -0
- package/dist/canonical.js +45 -0
- package/dist/canonical.js.map +1 -0
- package/dist/capability.d.ts +38 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/capability.js +61 -0
- package/dist/capability.js.map +1 -0
- package/dist/diagnostics/codes/a11y.d.ts +8 -0
- package/dist/diagnostics/codes/a11y.d.ts.map +1 -0
- package/dist/diagnostics/codes/a11y.js +30 -0
- package/dist/diagnostics/codes/a11y.js.map +1 -0
- package/dist/diagnostics/codes/action.d.ts +8 -0
- package/dist/diagnostics/codes/action.d.ts.map +1 -0
- package/dist/diagnostics/codes/action.js +110 -0
- package/dist/diagnostics/codes/action.js.map +1 -0
- package/dist/diagnostics/codes/artifact.d.ts +8 -0
- package/dist/diagnostics/codes/artifact.d.ts.map +1 -0
- package/dist/diagnostics/codes/artifact.js +121 -0
- package/dist/diagnostics/codes/artifact.js.map +1 -0
- package/dist/diagnostics/codes/build.d.ts +8 -0
- package/dist/diagnostics/codes/build.d.ts.map +1 -0
- package/dist/diagnostics/codes/build.js +55 -0
- package/dist/diagnostics/codes/build.js.map +1 -0
- package/dist/diagnostics/codes/cli.d.ts +8 -0
- package/dist/diagnostics/codes/cli.d.ts.map +1 -0
- package/dist/diagnostics/codes/cli.js +44 -0
- package/dist/diagnostics/codes/cli.js.map +1 -0
- package/dist/diagnostics/codes/console.d.ts +8 -0
- package/dist/diagnostics/codes/console.d.ts.map +1 -0
- package/dist/diagnostics/codes/console.js +30 -0
- package/dist/diagnostics/codes/console.js.map +1 -0
- package/dist/diagnostics/codes/dep.d.ts +8 -0
- package/dist/diagnostics/codes/dep.d.ts.map +1 -0
- package/dist/diagnostics/codes/dep.js +88 -0
- package/dist/diagnostics/codes/dep.js.map +1 -0
- package/dist/diagnostics/codes/env.d.ts +8 -0
- package/dist/diagnostics/codes/env.d.ts.map +1 -0
- package/dist/diagnostics/codes/env.js +132 -0
- package/dist/diagnostics/codes/env.js.map +1 -0
- package/dist/diagnostics/codes/field.d.ts +8 -0
- package/dist/diagnostics/codes/field.d.ts.map +1 -0
- package/dist/diagnostics/codes/field.js +99 -0
- package/dist/diagnostics/codes/field.js.map +1 -0
- package/dist/diagnostics/codes/home.d.ts +8 -0
- package/dist/diagnostics/codes/home.d.ts.map +1 -0
- package/dist/diagnostics/codes/home.js +132 -0
- package/dist/diagnostics/codes/home.js.map +1 -0
- package/dist/diagnostics/codes/host.d.ts +8 -0
- package/dist/diagnostics/codes/host.d.ts.map +1 -0
- package/dist/diagnostics/codes/host.js +176 -0
- package/dist/diagnostics/codes/host.js.map +1 -0
- package/dist/diagnostics/codes/hygiene.d.ts +8 -0
- package/dist/diagnostics/codes/hygiene.d.ts.map +1 -0
- package/dist/diagnostics/codes/hygiene.js +154 -0
- package/dist/diagnostics/codes/hygiene.js.map +1 -0
- package/dist/diagnostics/codes/index.d.ts +51 -0
- package/dist/diagnostics/codes/index.d.ts.map +1 -0
- package/dist/diagnostics/codes/index.js +72 -0
- package/dist/diagnostics/codes/index.js.map +1 -0
- package/dist/diagnostics/codes/live.d.ts +8 -0
- package/dist/diagnostics/codes/live.d.ts.map +1 -0
- package/dist/diagnostics/codes/live.js +30 -0
- package/dist/diagnostics/codes/live.js.map +1 -0
- package/dist/diagnostics/codes/manifest.d.ts +8 -0
- package/dist/diagnostics/codes/manifest.d.ts.map +1 -0
- package/dist/diagnostics/codes/manifest.js +44 -0
- package/dist/diagnostics/codes/manifest.js.map +1 -0
- package/dist/diagnostics/codes/network.d.ts +8 -0
- package/dist/diagnostics/codes/network.d.ts.map +1 -0
- package/dist/diagnostics/codes/network.js +30 -0
- package/dist/diagnostics/codes/network.js.map +1 -0
- package/dist/diagnostics/codes/platform.d.ts +8 -0
- package/dist/diagnostics/codes/platform.d.ts.map +1 -0
- package/dist/diagnostics/codes/platform.js +18 -0
- package/dist/diagnostics/codes/platform.js.map +1 -0
- package/dist/diagnostics/codes/publish.d.ts +8 -0
- package/dist/diagnostics/codes/publish.d.ts.map +1 -0
- package/dist/diagnostics/codes/publish.js +44 -0
- package/dist/diagnostics/codes/publish.js.map +1 -0
- package/dist/diagnostics/codes/regression.d.ts +8 -0
- package/dist/diagnostics/codes/regression.d.ts.map +1 -0
- package/dist/diagnostics/codes/regression.js +77 -0
- package/dist/diagnostics/codes/regression.js.map +1 -0
- package/dist/diagnostics/codes/runtime.d.ts +8 -0
- package/dist/diagnostics/codes/runtime.d.ts.map +1 -0
- package/dist/diagnostics/codes/runtime.js +66 -0
- package/dist/diagnostics/codes/runtime.js.map +1 -0
- package/dist/diagnostics/codes/secret.d.ts +8 -0
- package/dist/diagnostics/codes/secret.d.ts.map +1 -0
- package/dist/diagnostics/codes/secret.js +18 -0
- package/dist/diagnostics/codes/secret.js.map +1 -0
- package/dist/diagnostics/codes/smoke.d.ts +8 -0
- package/dist/diagnostics/codes/smoke.d.ts.map +1 -0
- package/dist/diagnostics/codes/smoke.js +30 -0
- package/dist/diagnostics/codes/smoke.js.map +1 -0
- package/dist/diagnostics/codes/submit.d.ts +8 -0
- package/dist/diagnostics/codes/submit.d.ts.map +1 -0
- package/dist/diagnostics/codes/submit.js +99 -0
- package/dist/diagnostics/codes/submit.js.map +1 -0
- package/dist/diagnostics/codes/target.d.ts +8 -0
- package/dist/diagnostics/codes/target.d.ts.map +1 -0
- package/dist/diagnostics/codes/target.js +18 -0
- package/dist/diagnostics/codes/target.js.map +1 -0
- package/dist/diagnostics/codes/type.d.ts +8 -0
- package/dist/diagnostics/codes/type.d.ts.map +1 -0
- package/dist/diagnostics/codes/type.js +30 -0
- package/dist/diagnostics/codes/type.js.map +1 -0
- package/dist/diagnostics/codes/verify.d.ts +8 -0
- package/dist/diagnostics/codes/verify.d.ts.map +1 -0
- package/dist/diagnostics/codes/verify.js +99 -0
- package/dist/diagnostics/codes/verify.js.map +1 -0
- package/dist/diagnostics/diagnostic.d.ts +79 -0
- package/dist/diagnostics/diagnostic.d.ts.map +1 -0
- package/dist/diagnostics/diagnostic.js +131 -0
- package/dist/diagnostics/diagnostic.js.map +1 -0
- package/dist/diagnostics/spec.d.ts +49 -0
- package/dist/diagnostics/spec.d.ts.map +1 -0
- package/dist/diagnostics/spec.js +31 -0
- package/dist/diagnostics/spec.js.map +1 -0
- package/dist/hygiene.d.ts +66 -0
- package/dist/hygiene.d.ts.map +1 -0
- package/dist/hygiene.js +134 -0
- package/dist/hygiene.js.map +1 -0
- package/dist/ids.d.ts +119 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +135 -0
- package/dist/ids.js.map +1 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.js +86 -0
- package/dist/interaction.d.ts +391 -0
- package/dist/interaction.d.ts.map +1 -0
- package/dist/interaction.js +306 -0
- package/dist/interaction.js.map +1 -0
- package/dist/manifest.d.ts +97 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +101 -0
- package/dist/manifest.js.map +1 -0
- package/dist/method.d.ts +26 -0
- package/dist/method.d.ts.map +1 -0
- package/dist/method.js +10 -0
- package/dist/method.js.map +1 -0
- package/dist/methods/artifact/create.d.ts +29 -0
- package/dist/methods/artifact/create.d.ts.map +1 -0
- package/dist/methods/artifact/create.js +31 -0
- package/dist/methods/artifact/create.js.map +1 -0
- package/dist/methods/artifact/get.d.ts +17 -0
- package/dist/methods/artifact/get.d.ts.map +1 -0
- package/dist/methods/artifact/get.js +21 -0
- package/dist/methods/artifact/get.js.map +1 -0
- package/dist/methods/artifact/list.d.ts +22 -0
- package/dist/methods/artifact/list.d.ts.map +1 -0
- package/dist/methods/artifact/list.js +19 -0
- package/dist/methods/artifact/list.js.map +1 -0
- package/dist/methods/artifact/publish.d.ts +28 -0
- package/dist/methods/artifact/publish.d.ts.map +1 -0
- package/dist/methods/artifact/publish.js +28 -0
- package/dist/methods/artifact/publish.js.map +1 -0
- package/dist/methods/artifact/verify.d.ts +29 -0
- package/dist/methods/artifact/verify.d.ts.map +1 -0
- package/dist/methods/artifact/verify.js +27 -0
- package/dist/methods/artifact/verify.js.map +1 -0
- package/dist/methods/deps/add.d.ts +43 -0
- package/dist/methods/deps/add.d.ts.map +1 -0
- package/dist/methods/deps/add.js +40 -0
- package/dist/methods/deps/add.js.map +1 -0
- package/dist/methods/dev/start.d.ts +52 -0
- package/dist/methods/dev/start.d.ts.map +1 -0
- package/dist/methods/dev/start.js +56 -0
- package/dist/methods/dev/start.js.map +1 -0
- package/dist/methods/dev/stop.d.ts +16 -0
- package/dist/methods/dev/stop.d.ts.map +1 -0
- package/dist/methods/dev/stop.js +21 -0
- package/dist/methods/dev/stop.js.map +1 -0
- package/dist/methods/events/ack.d.ts +20 -0
- package/dist/methods/events/ack.d.ts.map +1 -0
- package/dist/methods/events/ack.js +26 -0
- package/dist/methods/events/ack.js.map +1 -0
- package/dist/methods/events/read.d.ts +40 -0
- package/dist/methods/events/read.d.ts.map +1 -0
- package/dist/methods/events/read.js +35 -0
- package/dist/methods/events/read.js.map +1 -0
- package/dist/methods/events/subscribe.d.ts +54 -0
- package/dist/methods/events/subscribe.d.ts.map +1 -0
- package/dist/methods/events/subscribe.js +44 -0
- package/dist/methods/events/subscribe.js.map +1 -0
- package/dist/methods/events/unsubscribe.d.ts +16 -0
- package/dist/methods/events/unsubscribe.d.ts.map +1 -0
- package/dist/methods/events/unsubscribe.js +21 -0
- package/dist/methods/events/unsubscribe.js.map +1 -0
- package/dist/methods/gc/run.d.ts +76 -0
- package/dist/methods/gc/run.d.ts.map +1 -0
- package/dist/methods/gc/run.js +56 -0
- package/dist/methods/gc/run.js.map +1 -0
- package/dist/methods/index.d.ts +6 -0
- package/dist/methods/index.d.ts.map +1 -0
- package/dist/methods/index.js +78 -0
- package/dist/methods/index.js.map +1 -0
- package/dist/methods/instance/check.d.ts +30 -0
- package/dist/methods/instance/check.d.ts.map +1 -0
- package/dist/methods/instance/check.js +34 -0
- package/dist/methods/instance/check.js.map +1 -0
- package/dist/methods/instance/status.d.ts +102 -0
- package/dist/methods/instance/status.d.ts.map +1 -0
- package/dist/methods/instance/status.js +83 -0
- package/dist/methods/instance/status.js.map +1 -0
- package/dist/methods/live/push.d.ts +28 -0
- package/dist/methods/live/push.d.ts.map +1 -0
- package/dist/methods/live/push.js +35 -0
- package/dist/methods/live/push.js.map +1 -0
- package/dist/methods/mostra/initialize.d.ts +143 -0
- package/dist/methods/mostra/initialize.d.ts.map +1 -0
- package/dist/methods/mostra/initialize.js +97 -0
- package/dist/methods/mostra/initialize.js.map +1 -0
- package/dist/methods/mostra/shutdown.d.ts +14 -0
- package/dist/methods/mostra/shutdown.d.ts.map +1 -0
- package/dist/methods/mostra/shutdown.js +22 -0
- package/dist/methods/mostra/shutdown.js.map +1 -0
- package/dist/methods/port/drafts-mirror.d.ts +30 -0
- package/dist/methods/port/drafts-mirror.d.ts.map +1 -0
- package/dist/methods/port/drafts-mirror.js +33 -0
- package/dist/methods/port/drafts-mirror.js.map +1 -0
- package/dist/methods/port/secrets-get.d.ts +19 -0
- package/dist/methods/port/secrets-get.d.ts.map +1 -0
- package/dist/methods/port/secrets-get.js +31 -0
- package/dist/methods/port/secrets-get.js.map +1 -0
- package/dist/methods/port/submissions-deliver.d.ts +38 -0
- package/dist/methods/port/submissions-deliver.d.ts.map +1 -0
- package/dist/methods/port/submissions-deliver.js +38 -0
- package/dist/methods/port/submissions-deliver.js.map +1 -0
- package/dist/methods/port/trusted-controls-activated.d.ts +27 -0
- package/dist/methods/port/trusted-controls-activated.d.ts.map +1 -0
- package/dist/methods/port/trusted-controls-activated.js +33 -0
- package/dist/methods/port/trusted-controls-activated.js.map +1 -0
- package/dist/methods/port/trusted-controls-policy.d.ts +21 -0
- package/dist/methods/port/trusted-controls-policy.d.ts.map +1 -0
- package/dist/methods/port/trusted-controls-policy.js +27 -0
- package/dist/methods/port/trusted-controls-policy.js.map +1 -0
- package/dist/methods/results/get.d.ts +32 -0
- package/dist/methods/results/get.d.ts.map +1 -0
- package/dist/methods/results/get.js +36 -0
- package/dist/methods/results/get.js.map +1 -0
- package/dist/methods/secret/delete.d.ts +22 -0
- package/dist/methods/secret/delete.d.ts.map +1 -0
- package/dist/methods/secret/delete.js +32 -0
- package/dist/methods/secret/delete.js.map +1 -0
- package/dist/methods/secret/list.d.ts +21 -0
- package/dist/methods/secret/list.d.ts.map +1 -0
- package/dist/methods/secret/list.js +29 -0
- package/dist/methods/secret/list.js.map +1 -0
- package/dist/methods/secret/set.d.ts +37 -0
- package/dist/methods/secret/set.d.ts.map +1 -0
- package/dist/methods/secret/set.js +41 -0
- package/dist/methods/secret/set.js.map +1 -0
- package/dist/methods/state/get.d.ts +25 -0
- package/dist/methods/state/get.d.ts.map +1 -0
- package/dist/methods/state/get.js +29 -0
- package/dist/methods/state/get.js.map +1 -0
- package/dist/methods/state/patch.d.ts +32 -0
- package/dist/methods/state/patch.d.ts.map +1 -0
- package/dist/methods/state/patch.js +29 -0
- package/dist/methods/state/patch.js.map +1 -0
- package/dist/methods/view/default.d.ts +19 -0
- package/dist/methods/view/default.d.ts.map +1 -0
- package/dist/methods/view/default.js +23 -0
- package/dist/methods/view/default.js.map +1 -0
- package/dist/methods/view/launch.d.ts +27 -0
- package/dist/methods/view/launch.d.ts.map +1 -0
- package/dist/methods/view/launch.js +30 -0
- package/dist/methods/view/launch.js.map +1 -0
- package/dist/methods/view/revoke.d.ts +19 -0
- package/dist/methods/view/revoke.d.ts.map +1 -0
- package/dist/methods/view/revoke.js +26 -0
- package/dist/methods/view/revoke.js.map +1 -0
- package/dist/methods/view/rotate.d.ts +21 -0
- package/dist/methods/view/rotate.d.ts.map +1 -0
- package/dist/methods/view/rotate.js +27 -0
- package/dist/methods/view/rotate.js.map +1 -0
- package/dist/methods/view/url.d.ts +52 -0
- package/dist/methods/view/url.d.ts.map +1 -0
- package/dist/methods/view/url.js +43 -0
- package/dist/methods/view/url.js.map +1 -0
- package/dist/methods/wait/wait.d.ts +37 -0
- package/dist/methods/wait/wait.d.ts.map +1 -0
- package/dist/methods/wait/wait.js +39 -0
- package/dist/methods/wait/wait.js.map +1 -0
- package/dist/revision.d.ts +43 -0
- package/dist/revision.d.ts.map +1 -0
- package/dist/revision.js +69 -0
- package/dist/revision.js.map +1 -0
- package/dist/rpc/error.d.ts +47 -0
- package/dist/rpc/error.d.ts.map +1 -0
- package/dist/rpc/error.js +77 -0
- package/dist/rpc/error.js.map +1 -0
- package/dist/rpc/lines.d.ts +30 -0
- package/dist/rpc/lines.d.ts.map +1 -0
- package/dist/rpc/lines.js +63 -0
- package/dist/rpc/lines.js.map +1 -0
- package/dist/rpc/messages.d.ts +92 -0
- package/dist/rpc/messages.d.ts.map +1 -0
- package/dist/rpc/messages.js +133 -0
- package/dist/rpc/messages.js.map +1 -0
- package/dist/rpc/peer.d.ts +81 -0
- package/dist/rpc/peer.d.ts.map +1 -0
- package/dist/rpc/peer.js +208 -0
- package/dist/rpc/peer.js.map +1 -0
- package/dist/serializer.d.ts +178 -0
- package/dist/serializer.d.ts.map +1 -0
- package/dist/serializer.js +929 -0
- package/dist/serializer.js.map +1 -0
- package/dist/verify.d.ts +254 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +243 -0
- package/dist/verify.js.map +1 -0
- package/dist/view.d.ts +103 -0
- package/dist/view.d.ts.map +1 -0
- package/dist/view.js +110 -0
- package/dist/view.js.map +1 -0
- package/dist/wire-registry.js +11 -0
- package/dist/wire-registry.js.map +1 -0
- package/dist/worker.d.ts +249 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +158 -0
- package/dist/worker.js.map +1 -0
- package/package.json +114 -3
- package/schemas/protocol.draft-07.json +5120 -0
- package/schemas/protocol.schema.json +4964 -0
- package/src/actions.ts +418 -0
- package/src/artifact.ts +187 -0
- package/src/bridge.ts +618 -0
- package/src/browser.ts +374 -0
- package/src/bundle.ts +264 -0
- package/src/canonical.ts +49 -0
- package/src/capability.ts +92 -0
- package/src/diagnostics/codes/a11y.ts +41 -0
- package/src/diagnostics/codes/action.ts +125 -0
- package/src/diagnostics/codes/artifact.ts +137 -0
- package/src/diagnostics/codes/build.ts +65 -0
- package/src/diagnostics/codes/cli.ts +53 -0
- package/src/diagnostics/codes/console.ts +41 -0
- package/src/diagnostics/codes/dep.ts +101 -0
- package/src/diagnostics/codes/env.ts +149 -0
- package/src/diagnostics/codes/field.ts +113 -0
- package/src/diagnostics/codes/home.ts +150 -0
- package/src/diagnostics/codes/host.ts +197 -0
- package/src/diagnostics/codes/hygiene.ts +175 -0
- package/src/diagnostics/codes/index.ts +142 -0
- package/src/diagnostics/codes/live.ts +41 -0
- package/src/diagnostics/codes/manifest.ts +53 -0
- package/src/diagnostics/codes/network.ts +41 -0
- package/src/diagnostics/codes/platform.ts +30 -0
- package/src/diagnostics/codes/publish.ts +53 -0
- package/src/diagnostics/codes/regression.ts +89 -0
- package/src/diagnostics/codes/runtime.ts +77 -0
- package/src/diagnostics/codes/secret.ts +29 -0
- package/src/diagnostics/codes/smoke.ts +41 -0
- package/src/diagnostics/codes/submit.ts +113 -0
- package/src/diagnostics/codes/target.ts +29 -0
- package/src/diagnostics/codes/type.ts +41 -0
- package/src/diagnostics/codes/verify.ts +113 -0
- package/src/diagnostics/diagnostic.ts +240 -0
- package/src/diagnostics/spec.ts +90 -0
- package/src/hygiene.ts +224 -0
- package/src/ids.ts +279 -0
- package/src/index.ts +576 -0
- package/src/interaction.ts +728 -0
- package/src/manifest.ts +206 -0
- package/src/method.ts +42 -0
- package/src/methods/artifact/create.ts +56 -0
- package/src/methods/artifact/get.ts +30 -0
- package/src/methods/artifact/list.ts +42 -0
- package/src/methods/artifact/publish.ts +46 -0
- package/src/methods/artifact/verify.ts +46 -0
- package/src/methods/deps/add.ts +72 -0
- package/src/methods/dev/start.ts +84 -0
- package/src/methods/dev/stop.ts +32 -0
- package/src/methods/events/ack.ts +41 -0
- package/src/methods/events/read.ts +67 -0
- package/src/methods/events/subscribe.ts +91 -0
- package/src/methods/events/unsubscribe.ts +35 -0
- package/src/methods/gc/run.ts +125 -0
- package/src/methods/index.ts +81 -0
- package/src/methods/instance/check.ts +61 -0
- package/src/methods/instance/status.ts +172 -0
- package/src/methods/live/push.ts +54 -0
- package/src/methods/mostra/initialize.ts +249 -0
- package/src/methods/mostra/shutdown.ts +31 -0
- package/src/methods/port/drafts-mirror.ts +52 -0
- package/src/methods/port/secrets-get.ts +40 -0
- package/src/methods/port/submissions-deliver.ts +70 -0
- package/src/methods/port/trusted-controls-activated.ts +51 -0
- package/src/methods/port/trusted-controls-policy.ts +38 -0
- package/src/methods/results/get.ts +59 -0
- package/src/methods/secret/delete.ts +43 -0
- package/src/methods/secret/list.ts +40 -0
- package/src/methods/secret/set.ts +69 -0
- package/src/methods/state/get.ts +44 -0
- package/src/methods/state/patch.ts +51 -0
- package/src/methods/view/default.ts +32 -0
- package/src/methods/view/launch.ts +47 -0
- package/src/methods/view/revoke.ts +39 -0
- package/src/methods/view/rotate.ts +37 -0
- package/src/methods/view/url.ts +84 -0
- package/src/methods/wait/wait.ts +58 -0
- package/src/revision.ts +101 -0
- package/src/rpc/error.ts +107 -0
- package/src/rpc/lines.ts +70 -0
- package/src/rpc/messages.ts +188 -0
- package/src/rpc/peer.ts +341 -0
- package/src/serializer.ts +1217 -0
- package/src/timers.d.ts +8 -0
- package/src/verify.ts +458 -0
- package/src/view.ts +200 -0
- package/src/web-crypto.d.ts +9 -0
- package/src/web-platform.d.ts +35 -0
- package/src/wire-registry.ts +14 -0
- package/src/worker.ts +374 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { SECRET_NAME_PATTERN } from "../../actions.ts";
|
|
3
|
+
import { ArtifactRef } from "../../artifact.ts";
|
|
4
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
5
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
6
|
+
|
|
7
|
+
/** The params of `secret/delete` (INTERFACES §6). */
|
|
8
|
+
export interface SecretDeleteParams {
|
|
9
|
+
/** The secret's name. */
|
|
10
|
+
readonly name: string;
|
|
11
|
+
/** The artifact whose own secret to delete; absent: the home's shared one. */
|
|
12
|
+
readonly artifact?: ArtifactRef;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** The result of `secret/delete`. */
|
|
16
|
+
export interface SecretDeleteResult {
|
|
17
|
+
/** Whether a secret was there to delete. */
|
|
18
|
+
readonly deleted: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const params: z.ZodType<SecretDeleteParams> = z
|
|
22
|
+
.object({ name: z.string().regex(SECRET_NAME_PATTERN), artifact: ArtifactRef.exactOptional() })
|
|
23
|
+
.register(wireRegistry, { id: "SecretDeleteParams", description: "The secret to delete." });
|
|
24
|
+
|
|
25
|
+
const result: z.ZodType<SecretDeleteResult> = z
|
|
26
|
+
.object({ deleted: z.boolean() })
|
|
27
|
+
.register(wireRegistry, {
|
|
28
|
+
id: "SecretDeleteResult",
|
|
29
|
+
description: "Whether a secret was deleted.",
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* `secret/delete`: removes a secret from the home's store. Deleting one that isn't there succeeds
|
|
34
|
+
* with `deleted: false`, so the method is idempotent and takes no `requestId`.
|
|
35
|
+
*/
|
|
36
|
+
export const secretDeleteMethod: MethodDefinition<SecretDeleteParams, SecretDeleteResult> =
|
|
37
|
+
defineMethod({
|
|
38
|
+
method: "secret/delete",
|
|
39
|
+
direction: "client-to-instance",
|
|
40
|
+
mutating: false,
|
|
41
|
+
params,
|
|
42
|
+
result,
|
|
43
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { ArtifactRef } from "../../artifact.ts";
|
|
3
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
4
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
5
|
+
import { SecretEntry } from "./set.ts";
|
|
6
|
+
|
|
7
|
+
/** The params of `secret/list` (INTERFACES §6). */
|
|
8
|
+
export interface SecretListParams {
|
|
9
|
+
/** Also list this artifact's own secrets; the home's shared ones are always listed. */
|
|
10
|
+
readonly artifact?: ArtifactRef;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** The result of `secret/list`: names and scopes, never values. */
|
|
14
|
+
export interface SecretListResult {
|
|
15
|
+
/** The secrets, home ones first. */
|
|
16
|
+
readonly secrets: readonly SecretEntry[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const params: z.ZodType<SecretListParams> = z
|
|
20
|
+
.object({ artifact: ArtifactRef.exactOptional() })
|
|
21
|
+
.register(wireRegistry, {
|
|
22
|
+
id: "SecretListParams",
|
|
23
|
+
description: "The artifact whose secrets to list.",
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const result: z.ZodType<SecretListResult> = z
|
|
27
|
+
.object({ secrets: z.array(SecretEntry).readonly() })
|
|
28
|
+
.register(wireRegistry, { id: "SecretListResult", description: "Secrets by name and scope." });
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* `secret/list`: the names of the home's shared secrets, and of an artifact's own when one is
|
|
32
|
+
* named, with their scopes; a value is never returned (D44).
|
|
33
|
+
*/
|
|
34
|
+
export const secretListMethod: MethodDefinition<SecretListParams, SecretListResult> = defineMethod({
|
|
35
|
+
method: "secret/list",
|
|
36
|
+
direction: "client-to-instance",
|
|
37
|
+
mutating: false,
|
|
38
|
+
params,
|
|
39
|
+
result,
|
|
40
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { SECRET_NAME_PATTERN, SECRET_VALUE_MAX } from "../../actions.ts";
|
|
3
|
+
import { ArtifactRef } from "../../artifact.ts";
|
|
4
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
5
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
6
|
+
|
|
7
|
+
/** The params of `secret/set` (INTERFACES §6, D44). */
|
|
8
|
+
export interface SecretSetParams {
|
|
9
|
+
/** Letters, digits, `_`, `.` and `-`, starting with a letter or `_`, at most 128 characters. */
|
|
10
|
+
readonly name: string;
|
|
11
|
+
/** The value, at most 64 KiB of UTF-8. Never returned by any method. */
|
|
12
|
+
readonly value: string;
|
|
13
|
+
/** The artifact the secret belongs to; absent: shared by every artifact of the home. */
|
|
14
|
+
readonly artifact?: ArtifactRef;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Where a secret lives. */
|
|
18
|
+
export interface SecretEntry {
|
|
19
|
+
/** The secret's name. */
|
|
20
|
+
readonly name: string;
|
|
21
|
+
/** `artifact` for one artifact's secret, `home` for one every artifact shares. */
|
|
22
|
+
readonly scope: "artifact" | "home";
|
|
23
|
+
/** The artifact, for `scope: "artifact"`. */
|
|
24
|
+
readonly artifactId?: string;
|
|
25
|
+
/** When it was last set. */
|
|
26
|
+
readonly updatedAt: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The Zod schema of the `SecretEntry` type. */
|
|
30
|
+
export const SecretEntry: z.ZodType<SecretEntry> = z
|
|
31
|
+
.object({
|
|
32
|
+
name: z.string(),
|
|
33
|
+
scope: z.enum(["artifact", "home"]),
|
|
34
|
+
artifactId: z.string().exactOptional(),
|
|
35
|
+
updatedAt: z.string(),
|
|
36
|
+
})
|
|
37
|
+
.register(wireRegistry, {
|
|
38
|
+
id: "SecretEntry",
|
|
39
|
+
description: "A secret's name, scope and when it was set; never its value.",
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
/** The result of `secret/set`: the secret, without its value. */
|
|
43
|
+
export type SecretSetResult = SecretEntry;
|
|
44
|
+
|
|
45
|
+
const params: z.ZodType<SecretSetParams> = z
|
|
46
|
+
.object({
|
|
47
|
+
name: z.string().regex(SECRET_NAME_PATTERN),
|
|
48
|
+
// Characters here; the instance also refuses more than 64 KiB of UTF-8.
|
|
49
|
+
value: z.string().min(1).max(SECRET_VALUE_MAX),
|
|
50
|
+
artifact: ArtifactRef.exactOptional(),
|
|
51
|
+
})
|
|
52
|
+
.register(wireRegistry, {
|
|
53
|
+
id: "SecretSetParams",
|
|
54
|
+
description: "A secret's name, value and optional artifact scope.",
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* `secret/set`: stores a named secret in the home's owner-only store (D44), for one artifact or
|
|
59
|
+
* for every artifact of the home; server code reads it with `secret(name)`. Setting it again
|
|
60
|
+
* replaces the value. Setting is idempotent by nature, so it takes no `requestId`: the ledger
|
|
61
|
+
* never records anything derived from a secret's value.
|
|
62
|
+
*/
|
|
63
|
+
export const secretSetMethod: MethodDefinition<SecretSetParams, SecretSetResult> = defineMethod({
|
|
64
|
+
method: "secret/set",
|
|
65
|
+
direction: "client-to-instance",
|
|
66
|
+
mutating: false,
|
|
67
|
+
params,
|
|
68
|
+
result: SecretEntry,
|
|
69
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { ArtifactRef } from "../../artifact.ts";
|
|
3
|
+
import { DocumentRevision, FieldState } from "../../interaction.ts";
|
|
4
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
5
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
6
|
+
|
|
7
|
+
/** The params of `state/get` (INTERFACES §6, D63). */
|
|
8
|
+
export interface StateGetParams {
|
|
9
|
+
/** The artifact whose shared state to read. */
|
|
10
|
+
readonly artifact: ArtifactRef;
|
|
11
|
+
/** Only these field IDs; absent: every field. */
|
|
12
|
+
readonly ids?: readonly string[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** The result of `state/get`: the artifact state's revision and its fields by ID. */
|
|
16
|
+
export interface StateGetResult {
|
|
17
|
+
/** The state's revision; pass it as `baseRevision` to `state/patch` for compare-and-set. */
|
|
18
|
+
readonly revision: DocumentRevision;
|
|
19
|
+
/** The fields by ID. */
|
|
20
|
+
readonly fields: Readonly<Record<string, FieldState>>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const params: z.ZodType<StateGetParams> = z
|
|
24
|
+
.object({
|
|
25
|
+
artifact: ArtifactRef,
|
|
26
|
+
ids: z.array(z.string().min(1).max(256)).max(10_000).readonly().exactOptional(),
|
|
27
|
+
})
|
|
28
|
+
.register(wireRegistry, { id: "StateGetParams" });
|
|
29
|
+
|
|
30
|
+
const result: z.ZodType<StateGetResult> = z
|
|
31
|
+
.object({ revision: DocumentRevision, fields: z.record(z.string(), FieldState) })
|
|
32
|
+
.register(wireRegistry, { id: "StateGetResult" });
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* `state/get`: reads an artifact's shared state (its artifact-scoped fields, D63) with each
|
|
36
|
+
* field's value, revision and last writer.
|
|
37
|
+
*/
|
|
38
|
+
export const stateGetMethod: MethodDefinition<StateGetParams, StateGetResult> = defineMethod({
|
|
39
|
+
method: "state/get",
|
|
40
|
+
direction: "client-to-instance",
|
|
41
|
+
mutating: false,
|
|
42
|
+
params,
|
|
43
|
+
result,
|
|
44
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { ArtifactRef } from "../../artifact.ts";
|
|
3
|
+
import { MutationId } from "../../ids.ts";
|
|
4
|
+
import { DocumentRevision, FieldOp, MutationResult } from "../../interaction.ts";
|
|
5
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
6
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
7
|
+
|
|
8
|
+
/** The params of `state/patch` (INTERFACES §6, D63, D106). */
|
|
9
|
+
export interface StatePatchParams {
|
|
10
|
+
/** The artifact whose shared state to write. */
|
|
11
|
+
readonly artifact: ArtifactRef;
|
|
12
|
+
/** The field changes, applied together under one revision. */
|
|
13
|
+
readonly ops: readonly FieldOp[];
|
|
14
|
+
/**
|
|
15
|
+
* The state revision the caller last read. A field changed after it is a conflict and keeps its
|
|
16
|
+
* value; the other ops apply. Absent: every op applies, whatever changed in between.
|
|
17
|
+
*/
|
|
18
|
+
readonly baseRevision?: DocumentRevision;
|
|
19
|
+
/**
|
|
20
|
+
* The change's ID, the idempotency key of this method (H-03): a retry with the same ID and
|
|
21
|
+
* contents returns the recorded result.
|
|
22
|
+
*/
|
|
23
|
+
readonly mutationId: string;
|
|
24
|
+
/** Who writes: `agent` (the default) or `host`, recorded as each field's last writer. */
|
|
25
|
+
readonly as?: "agent" | "host";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The result of `state/patch`. */
|
|
29
|
+
export type StatePatchResult = MutationResult;
|
|
30
|
+
|
|
31
|
+
const params: z.ZodType<StatePatchParams> = z
|
|
32
|
+
.object({
|
|
33
|
+
artifact: ArtifactRef,
|
|
34
|
+
ops: z.array(FieldOp).min(1).max(1000).readonly(),
|
|
35
|
+
baseRevision: DocumentRevision.exactOptional(),
|
|
36
|
+
mutationId: MutationId.schema,
|
|
37
|
+
as: z.enum(["agent", "host"]).exactOptional(),
|
|
38
|
+
})
|
|
39
|
+
.register(wireRegistry, { id: "StatePatchParams" });
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* `state/patch`: writes an artifact's shared state with compare-and-set and per-field conflicts,
|
|
43
|
+
* through the same path as viewers' edits (D63). Changes append `state.changed`.
|
|
44
|
+
*/
|
|
45
|
+
export const statePatchMethod: MethodDefinition<StatePatchParams, StatePatchResult> = defineMethod({
|
|
46
|
+
method: "state/patch",
|
|
47
|
+
direction: "client-to-instance",
|
|
48
|
+
mutating: true,
|
|
49
|
+
params,
|
|
50
|
+
result: MutationResult,
|
|
51
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { ArtifactRef } from "../../artifact.ts";
|
|
3
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
4
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
5
|
+
import { CapabilityLink } from "./url.ts";
|
|
6
|
+
|
|
7
|
+
/** The params of `view/default` (INTERFACES §6, D140). */
|
|
8
|
+
export interface ViewDefaultParams {
|
|
9
|
+
/** The artifact whose default link to return. */
|
|
10
|
+
readonly artifact: ArtifactRef;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** The result of `view/default`: the artifact's default link (D97 item 3). */
|
|
14
|
+
export type ViewDefaultResult = CapabilityLink;
|
|
15
|
+
|
|
16
|
+
const params: z.ZodType<ViewDefaultParams> = z
|
|
17
|
+
.object({ artifact: ArtifactRef })
|
|
18
|
+
.register(wireRegistry, { id: "ViewDefaultParams" });
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* `view/default`: the artifact's default link, the one every publish receipt carries (D97 item
|
|
22
|
+
* 3), without minting a new token. When the default link was revoked, it mints a new default (the
|
|
23
|
+
* old token stays revoked). `view/url` always mints a separate link.
|
|
24
|
+
*/
|
|
25
|
+
export const viewDefaultMethod: MethodDefinition<ViewDefaultParams, ViewDefaultResult> =
|
|
26
|
+
defineMethod({
|
|
27
|
+
method: "view/default",
|
|
28
|
+
direction: "client-to-instance",
|
|
29
|
+
mutating: true,
|
|
30
|
+
params,
|
|
31
|
+
result: CapabilityLink,
|
|
32
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { TokenId } from "../../ids.ts";
|
|
3
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
4
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
5
|
+
|
|
6
|
+
/** The params of `view/launch` (INTERFACES §6, D140 item 15). */
|
|
7
|
+
export interface ViewLaunchParams {
|
|
8
|
+
/** The link whose session the launch URL opens: a `CapabilityLink.tokenId`. */
|
|
9
|
+
readonly tokenId: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** The result of `view/launch`. */
|
|
13
|
+
export interface ViewLaunchResult {
|
|
14
|
+
/**
|
|
15
|
+
* `http://<url host>:<shell port>/a/<artifactId>[/v/<number>]#l=<ticket>`: a URL to hand a
|
|
16
|
+
* browser on its command line. The shell exchanges the single-use ticket for the session the
|
|
17
|
+
* link would give; the link's secret is never in it.
|
|
18
|
+
*/
|
|
19
|
+
readonly url: string;
|
|
20
|
+
/** When the ticket stops working, 60 s after it was minted (RFC 3339, UTC). */
|
|
21
|
+
readonly expiresAt: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const params: z.ZodType<ViewLaunchParams> = z
|
|
25
|
+
.object({ tokenId: TokenId.schema })
|
|
26
|
+
.register(wireRegistry, { id: "ViewLaunchParams" });
|
|
27
|
+
|
|
28
|
+
const result: z.ZodType<ViewLaunchResult> = z
|
|
29
|
+
.object({ url: z.string().min(1), expiresAt: z.iso.datetime() })
|
|
30
|
+
.register(wireRegistry, {
|
|
31
|
+
id: "ViewLaunchResult",
|
|
32
|
+
description: "A one-time launch URL for a browser.",
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* `view/launch`: a one-time launch URL for a link (D140 item 15), so a browser opens it without
|
|
37
|
+
* the link's secret on a command line other local users can read. The ticket is single-use,
|
|
38
|
+
* lives 60 s and carries 130 bits, like a frame ticket; it is never recorded, so the method takes
|
|
39
|
+
* no `requestId`. A revoked or expired link is `MOSTRA_HYGIENE_TOKEN_REVOKED`.
|
|
40
|
+
*/
|
|
41
|
+
export const viewLaunchMethod: MethodDefinition<ViewLaunchParams, ViewLaunchResult> = defineMethod({
|
|
42
|
+
method: "view/launch",
|
|
43
|
+
direction: "client-to-instance",
|
|
44
|
+
mutating: true,
|
|
45
|
+
params,
|
|
46
|
+
result,
|
|
47
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { TokenId } from "../../ids.ts";
|
|
3
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
4
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
5
|
+
|
|
6
|
+
/** The params of `view/revoke` (INTERFACES §6, D97). */
|
|
7
|
+
export interface ViewRevokeParams {
|
|
8
|
+
/** The token whose link stops working. */
|
|
9
|
+
readonly tokenId: string;
|
|
10
|
+
/** Makes retries idempotent: a repeated `requestId` returns the recorded result (H-03). */
|
|
11
|
+
readonly requestId?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** The result of `view/revoke`. */
|
|
15
|
+
export type ViewRevokeResult = Record<string, never>;
|
|
16
|
+
|
|
17
|
+
const params: z.ZodType<ViewRevokeParams> = z
|
|
18
|
+
.object({
|
|
19
|
+
tokenId: TokenId.schema,
|
|
20
|
+
requestId: z.string().min(1).exactOptional(),
|
|
21
|
+
})
|
|
22
|
+
.register(wireRegistry, { id: "ViewRevokeParams" });
|
|
23
|
+
|
|
24
|
+
const result: z.ZodType<ViewRevokeResult> = z
|
|
25
|
+
.object({})
|
|
26
|
+
.register(wireRegistry, { id: "ViewRevokeResult" });
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* `view/revoke`: ends a capability link and every session opened with it; both answer 410 from
|
|
30
|
+
* then on (HY-03). Revoking a revoked token succeeds; an unknown token is
|
|
31
|
+
* `MOSTRA_HYGIENE_TOKEN_INVALID`.
|
|
32
|
+
*/
|
|
33
|
+
export const viewRevokeMethod: MethodDefinition<ViewRevokeParams, ViewRevokeResult> = defineMethod({
|
|
34
|
+
method: "view/revoke",
|
|
35
|
+
direction: "client-to-instance",
|
|
36
|
+
mutating: true,
|
|
37
|
+
params,
|
|
38
|
+
result,
|
|
39
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { TokenId } from "../../ids.ts";
|
|
3
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
4
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
5
|
+
import { CapabilityLink } from "./url.ts";
|
|
6
|
+
|
|
7
|
+
/** The params of `view/rotate` (D97). */
|
|
8
|
+
export interface ViewRotateParams {
|
|
9
|
+
/** The token to replace. */
|
|
10
|
+
readonly tokenId: string;
|
|
11
|
+
/** Makes retries idempotent: a repeated `requestId` returns the same new link (H-03). */
|
|
12
|
+
readonly requestId?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** The result of `view/rotate`: the new link. */
|
|
16
|
+
export type ViewRotateResult = CapabilityLink;
|
|
17
|
+
|
|
18
|
+
const params: z.ZodType<ViewRotateParams> = z
|
|
19
|
+
.object({
|
|
20
|
+
tokenId: TokenId.schema,
|
|
21
|
+
requestId: z.string().min(1).exactOptional(),
|
|
22
|
+
})
|
|
23
|
+
.register(wireRegistry, { id: "ViewRotateParams" });
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* `view/rotate`: replaces a capability link in one step. The new link has the same artifact,
|
|
27
|
+
* scopes and expiry; the old one and its sessions answer 410 from then on. Rotating the artifact's
|
|
28
|
+
* default link makes the new one its default. A revoked or expired token can't be rotated
|
|
29
|
+
* (`MOSTRA_HYGIENE_TOKEN_REVOKED`).
|
|
30
|
+
*/
|
|
31
|
+
export const viewRotateMethod: MethodDefinition<ViewRotateParams, ViewRotateResult> = defineMethod({
|
|
32
|
+
method: "view/rotate",
|
|
33
|
+
direction: "client-to-instance",
|
|
34
|
+
mutating: true,
|
|
35
|
+
params,
|
|
36
|
+
result: CapabilityLink,
|
|
37
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { ArtifactRef } from "../../artifact.ts";
|
|
3
|
+
import { CapabilityScope, Duration } from "../../capability.ts";
|
|
4
|
+
import { TokenId, VersionId } from "../../ids.ts";
|
|
5
|
+
import { Viewer, ViewerSpec } from "../../interaction.ts";
|
|
6
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
7
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
8
|
+
|
|
9
|
+
/** The params of `view/url` (INTERFACES §6, D97). */
|
|
10
|
+
export interface ViewUrlParams {
|
|
11
|
+
/** The artifact the link opens. */
|
|
12
|
+
readonly artifact: ArtifactRef;
|
|
13
|
+
/**
|
|
14
|
+
* The version the link opens, by number or ID. Without it the link opens the artifact's latest
|
|
15
|
+
* version whenever it is used.
|
|
16
|
+
*/
|
|
17
|
+
readonly version?: number | string;
|
|
18
|
+
/** What the link allows (D97). Default: every scope. `view` is always included. */
|
|
19
|
+
readonly scopes?: readonly CapabilityScope[];
|
|
20
|
+
/** How long the link works, such as `24h` or `7d`. Default: until it is revoked (D63). */
|
|
21
|
+
readonly ttl?: Duration;
|
|
22
|
+
/**
|
|
23
|
+
* The person the link acts for (D104): its sessions draft, submit and sign as that viewer, so
|
|
24
|
+
* `once` per-viewer gives each person one submission. Absent: the home's local user.
|
|
25
|
+
*/
|
|
26
|
+
readonly viewer?: ViewerSpec;
|
|
27
|
+
/** Makes retries idempotent: a repeated `requestId` returns the same link (H-03). */
|
|
28
|
+
readonly requestId?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** A capability link: what `view/url` and `view/rotate` return. */
|
|
32
|
+
export interface CapabilityLink {
|
|
33
|
+
/** The capability URL. Holding it is the authorization (D06); share it like a password. */
|
|
34
|
+
readonly url: string;
|
|
35
|
+
/** The token's ID, for `view/rotate` and `view/revoke`. Never a secret. */
|
|
36
|
+
readonly tokenId: string;
|
|
37
|
+
/** The scopes the link carries, `view` included. */
|
|
38
|
+
readonly scopes: readonly CapabilityScope[];
|
|
39
|
+
/** When the link stops working; absent when it works until revoked. */
|
|
40
|
+
readonly expiresAt?: string;
|
|
41
|
+
/** The viewer the link acts for, when it was minted with one (D104). */
|
|
42
|
+
readonly viewer?: Viewer;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The result of `view/url`. */
|
|
46
|
+
export type ViewUrlResult = CapabilityLink;
|
|
47
|
+
|
|
48
|
+
/** The Zod schema of the `CapabilityLink` type. */
|
|
49
|
+
export const CapabilityLink: z.ZodType<CapabilityLink> = z
|
|
50
|
+
.object({
|
|
51
|
+
url: z.string().min(1),
|
|
52
|
+
tokenId: TokenId.schema,
|
|
53
|
+
scopes: z.array(CapabilityScope).readonly(),
|
|
54
|
+
expiresAt: z.iso.datetime().exactOptional(),
|
|
55
|
+
viewer: Viewer.exactOptional(),
|
|
56
|
+
})
|
|
57
|
+
.register(wireRegistry, {
|
|
58
|
+
id: "CapabilityLink",
|
|
59
|
+
description: "A capability URL with its token ID, scopes and expiry.",
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const params: z.ZodType<ViewUrlParams> = z
|
|
63
|
+
.object({
|
|
64
|
+
artifact: ArtifactRef,
|
|
65
|
+
version: z.union([z.int().min(1), VersionId.schema]).exactOptional(),
|
|
66
|
+
scopes: z.array(CapabilityScope).min(1).readonly().exactOptional(),
|
|
67
|
+
ttl: Duration.exactOptional(),
|
|
68
|
+
viewer: ViewerSpec.exactOptional(),
|
|
69
|
+
requestId: z.string().min(1).exactOptional(),
|
|
70
|
+
})
|
|
71
|
+
.register(wireRegistry, { id: "ViewUrlParams" });
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* `view/url`: mints a new capability link to an artifact, with the scopes and lifetime asked for.
|
|
75
|
+
* Each call mints a separate token that `view/revoke` ends on its own; the artifact's default link
|
|
76
|
+
* is the publish receipt's `url`.
|
|
77
|
+
*/
|
|
78
|
+
export const viewUrlMethod: MethodDefinition<ViewUrlParams, ViewUrlResult> = defineMethod({
|
|
79
|
+
method: "view/url",
|
|
80
|
+
direction: "client-to-instance",
|
|
81
|
+
mutating: true,
|
|
82
|
+
params,
|
|
83
|
+
result: CapabilityLink,
|
|
84
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { ArtifactRef } from "../../artifact.ts";
|
|
3
|
+
import { Cursor } from "../../ids.ts";
|
|
4
|
+
import { EventRecord, WaitCondition } from "../../interaction.ts";
|
|
5
|
+
import { defineMethod, type MethodDefinition } from "../../method.ts";
|
|
6
|
+
import { wireRegistry } from "../../wire-registry.ts";
|
|
7
|
+
|
|
8
|
+
/** The longest `wait`, in milliseconds: the longest timer JavaScript keeps (about 24.8 days). */
|
|
9
|
+
export const WAIT_MAX_MS = 2_147_483_647;
|
|
10
|
+
|
|
11
|
+
/** The params of `wait` (INTERFACES §6, ARCHITECTURE §6, D103). */
|
|
12
|
+
export interface WaitParams {
|
|
13
|
+
/** The artifact to wait on. */
|
|
14
|
+
readonly artifact: ArtifactRef;
|
|
15
|
+
/** `submitted`, `signal:<name>`, `state:<fieldId>` or `event:<type>`. */
|
|
16
|
+
readonly until: WaitCondition;
|
|
17
|
+
/**
|
|
18
|
+
* Wait for what happens after this cursor (edge-triggered conditions, and `submitted` under
|
|
19
|
+
* `epochs`). Default: the cursor of the artifact's latest publish.
|
|
20
|
+
*/
|
|
21
|
+
readonly after?: string;
|
|
22
|
+
/** How long to block, in milliseconds; 0 checks once. */
|
|
23
|
+
readonly timeoutMs: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The result of `wait`. */
|
|
27
|
+
export type WaitResult =
|
|
28
|
+
| { readonly status: "satisfied"; readonly event: EventRecord; readonly cursor: string }
|
|
29
|
+
| { readonly status: "still_waiting"; readonly cursor: string };
|
|
30
|
+
|
|
31
|
+
const params: z.ZodType<WaitParams> = z
|
|
32
|
+
.object({
|
|
33
|
+
artifact: ArtifactRef,
|
|
34
|
+
until: WaitCondition,
|
|
35
|
+
after: Cursor.schema.exactOptional(),
|
|
36
|
+
timeoutMs: z.int().min(0).max(WAIT_MAX_MS),
|
|
37
|
+
})
|
|
38
|
+
.register(wireRegistry, { id: "WaitParams" });
|
|
39
|
+
|
|
40
|
+
const result: z.ZodType<WaitResult> = z
|
|
41
|
+
.discriminatedUnion("status", [
|
|
42
|
+
z.object({ status: z.literal("satisfied"), event: EventRecord, cursor: Cursor.schema }),
|
|
43
|
+
z.object({ status: z.literal("still_waiting"), cursor: Cursor.schema }),
|
|
44
|
+
])
|
|
45
|
+
.register(wireRegistry, { id: "WaitResult" });
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* `wait`: blocks until a condition holds or the timeout passes (IN-10). `satisfied` carries the
|
|
49
|
+
* event that met it; `still_waiting` carries the newest cursor examined, so a later wait from it
|
|
50
|
+
* misses nothing.
|
|
51
|
+
*/
|
|
52
|
+
export const waitMethod: MethodDefinition<WaitParams, WaitResult> = defineMethod({
|
|
53
|
+
method: "wait",
|
|
54
|
+
direction: "client-to-instance",
|
|
55
|
+
mutating: false,
|
|
56
|
+
params,
|
|
57
|
+
result,
|
|
58
|
+
});
|
package/src/revision.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dated protocol revisions and their negotiation (INTERFACES §1, STANDARDS versioning, D59).
|
|
3
|
+
*
|
|
4
|
+
* The host protocol and the browser protocol each carry a revision named by a date
|
|
5
|
+
* (`2026-10-10`). A revision only changes additively. A breaking change needs a new revision, and
|
|
6
|
+
* the old one stays supported for at least 12 months.
|
|
7
|
+
*/
|
|
8
|
+
import * as z from "zod";
|
|
9
|
+
import { type CreateDiagnosticOptions, createDiagnostic } from "./diagnostics/codes/index.ts";
|
|
10
|
+
import type { Diagnostic } from "./diagnostics/diagnostic.ts";
|
|
11
|
+
import { wireRegistry } from "./wire-registry.ts";
|
|
12
|
+
|
|
13
|
+
/** A protocol revision: a calendar date in `YYYY-MM-DD` form. */
|
|
14
|
+
export type Revision = string & { readonly __mostraRevision: true };
|
|
15
|
+
|
|
16
|
+
const PATTERN = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
|
|
17
|
+
|
|
18
|
+
function isRevision(value: unknown): value is Revision {
|
|
19
|
+
if (typeof value !== "string" || !PATTERN.test(value)) return false;
|
|
20
|
+
const date = new Date(`${value}T00:00:00Z`);
|
|
21
|
+
return !Number.isNaN(date.getTime()) && date.toISOString().startsWith(value);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Protocol revisions. */
|
|
25
|
+
export const Revision: {
|
|
26
|
+
/** The textual form. `is` and `parse` also reject impossible dates such as `2026-02-30`. */
|
|
27
|
+
readonly pattern: RegExp;
|
|
28
|
+
readonly schema: z.ZodType<Revision, string>;
|
|
29
|
+
is(value: unknown): value is Revision;
|
|
30
|
+
/** @throws TypeError when `value` is not a real calendar date in `YYYY-MM-DD` form. */
|
|
31
|
+
parse(value: string): Revision;
|
|
32
|
+
/** Orders revisions by date: negative when `a` is older than `b`. */
|
|
33
|
+
compare(a: Revision, b: Revision): number;
|
|
34
|
+
} = {
|
|
35
|
+
pattern: PATTERN,
|
|
36
|
+
// z.iso.date() checks calendar validity in its emitted pattern, so the published JSON Schema
|
|
37
|
+
// rejects 2026-02-30 just as `parse` does.
|
|
38
|
+
schema: z.iso.date().register(wireRegistry, {
|
|
39
|
+
id: "Revision",
|
|
40
|
+
description: "Protocol revision: a calendar date in YYYY-MM-DD form.",
|
|
41
|
+
}) as unknown as z.ZodType<Revision, string>,
|
|
42
|
+
is: isRevision,
|
|
43
|
+
parse(value: string): Revision {
|
|
44
|
+
if (isRevision(value)) return value;
|
|
45
|
+
throw new TypeError("Expected a protocol revision: a calendar date in YYYY-MM-DD form.");
|
|
46
|
+
},
|
|
47
|
+
compare(a: Revision, b: Revision): number {
|
|
48
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The host protocol revisions this package's schemas describe, newest first. A runtime built on
|
|
54
|
+
* this package supports exactly these.
|
|
55
|
+
*/
|
|
56
|
+
export const HOST_PROTOCOL_REVISIONS: readonly Revision[] = [Revision.parse("2026-10-10")];
|
|
57
|
+
|
|
58
|
+
/** The outcome of {@link negotiateRevision}. */
|
|
59
|
+
export type RevisionNegotiation =
|
|
60
|
+
| { readonly ok: true; readonly revision: Revision }
|
|
61
|
+
| { readonly ok: false; readonly diagnostic: Diagnostic };
|
|
62
|
+
|
|
63
|
+
const LISTED = 8;
|
|
64
|
+
|
|
65
|
+
function list(revisions: readonly string[]): string {
|
|
66
|
+
const shown = revisions.slice(0, LISTED).join(", ");
|
|
67
|
+
return revisions.length > LISTED ? `${shown} and ${revisions.length - LISTED} more` : shown;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Picks the newest host protocol revision that both sides support. When there is none, returns
|
|
72
|
+
* the refusal diagnostic `MOSTRA_HOST_REVISION_UNSUPPORTED`, which the instance sends back as the
|
|
73
|
+
* error of `mostra/initialize`.
|
|
74
|
+
*
|
|
75
|
+
* Offered entries that are not revisions never match, and the message lists only well-formed
|
|
76
|
+
* ones, so a malformed offer can't inject text into the diagnostic.
|
|
77
|
+
*/
|
|
78
|
+
export function negotiateRevision(
|
|
79
|
+
offered: readonly string[],
|
|
80
|
+
supported: readonly Revision[] = HOST_PROTOCOL_REVISIONS,
|
|
81
|
+
options: CreateDiagnosticOptions = {},
|
|
82
|
+
): RevisionNegotiation {
|
|
83
|
+
const offeredRevisions = [...new Set(offered.filter(isRevision))].sort(Revision.compare);
|
|
84
|
+
const common = offeredRevisions.filter((revision) => supported.includes(revision));
|
|
85
|
+
const newest = common.at(-1);
|
|
86
|
+
if (newest !== undefined) return { ok: true, revision: newest };
|
|
87
|
+
|
|
88
|
+
const supportedList = [...supported].sort(Revision.compare).reverse();
|
|
89
|
+
const offeredText =
|
|
90
|
+
offeredRevisions.length > 0
|
|
91
|
+
? `The client offered host protocol revisions ${list(offeredRevisions.reverse())}`
|
|
92
|
+
: "The client offered no valid host protocol revision";
|
|
93
|
+
return {
|
|
94
|
+
ok: false,
|
|
95
|
+
diagnostic: createDiagnostic(
|
|
96
|
+
"MOSTRA_HOST_REVISION_UNSUPPORTED",
|
|
97
|
+
{ message: `${offeredText}; this instance supports ${list(supportedList)}.` },
|
|
98
|
+
options,
|
|
99
|
+
),
|
|
100
|
+
};
|
|
101
|
+
}
|