@intentic/sandbox-contract 1.431.0 → 1.433.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/README.md +25 -3
- package/dist/briefs/agent-ask.d.ts +10 -0
- package/dist/briefs/agent-ask.d.ts.map +1 -0
- package/dist/briefs/agent-ask.js +2 -0
- package/dist/briefs/agent-ask.js.map +1 -0
- package/dist/{chores/extension-update.d.ts → briefs/extension-update-brief.d.ts} +1 -1
- package/dist/briefs/extension-update-brief.d.ts.map +1 -0
- package/dist/{chores/extension-update.js → briefs/extension-update-brief.js} +2 -2
- package/dist/briefs/extension-update-brief.js.map +1 -0
- package/dist/chores/digest.d.ts.map +1 -1
- package/dist/chores/digest.js.map +1 -1
- package/dist/chores/index.d.ts +2 -2
- package/dist/chores/index.d.ts.map +1 -1
- package/dist/chores/index.js +1 -1
- package/dist/chores/index.js.map +1 -1
- package/dist/chores/prompt.d.ts +1 -9
- package/dist/chores/prompt.d.ts.map +1 -1
- package/dist/chores/prompt.js +1 -1
- package/dist/chores/prompt.js.map +1 -1
- package/dist/chores/stack.d.ts.map +1 -1
- package/dist/chores/stack.js.map +1 -1
- package/dist/chores/verdict.d.ts.map +1 -1
- package/dist/chores/verdict.js.map +1 -1
- package/dist/chores/workspace-scope.d.ts +1 -3
- package/dist/chores/workspace-scope.d.ts.map +1 -1
- package/dist/chores/workspace-scope.js +1 -3
- package/dist/chores/workspace-scope.js.map +1 -1
- package/dist/contracts/agent.contract.d.ts +1049 -12
- package/dist/contracts/agent.contract.d.ts.map +1 -1
- package/dist/contracts/agents.contract.d.ts +358 -4
- package/dist/contracts/agents.contract.d.ts.map +1 -1
- package/dist/contracts/approvals.contract.d.ts +35 -0
- package/dist/contracts/approvals.contract.d.ts.map +1 -1
- package/dist/contracts/approvals.contract.js +13 -3
- package/dist/contracts/approvals.contract.js.map +1 -1
- package/dist/contracts/automations.contract.d.ts +60 -8
- package/dist/contracts/automations.contract.d.ts.map +1 -1
- package/dist/contracts/capabilities.contract.d.ts +40 -0
- package/dist/contracts/capabilities.contract.d.ts.map +1 -1
- package/dist/contracts/capabilities.contract.js +21 -0
- package/dist/contracts/capabilities.contract.js.map +1 -1
- package/dist/contracts/ci.contract.d.ts +222 -95
- package/dist/contracts/ci.contract.d.ts.map +1 -1
- package/dist/contracts/ci.contract.js +87 -26
- package/dist/contracts/ci.contract.js.map +1 -1
- package/dist/contracts/device-stacks.contract.d.ts +129 -0
- package/dist/contracts/device-stacks.contract.d.ts.map +1 -0
- package/dist/contracts/device-stacks.contract.js +66 -0
- package/dist/contracts/device-stacks.contract.js.map +1 -0
- package/dist/contracts/device.contract.d.ts +47 -0
- package/dist/contracts/device.contract.d.ts.map +1 -1
- package/dist/contracts/extensions.contract.d.ts +607 -0
- package/dist/contracts/extensions.contract.d.ts.map +1 -1
- package/dist/contracts/extensions.contract.js +10 -1
- package/dist/contracts/extensions.contract.js.map +1 -1
- package/dist/contracts/needs.contract.d.ts +887 -18
- package/dist/contracts/needs.contract.d.ts.map +1 -1
- package/dist/contracts/offload.contract.d.ts +21 -0
- package/dist/contracts/offload.contract.d.ts.map +1 -1
- package/dist/contracts/runner.contract.d.ts +653 -40
- package/dist/contracts/runner.contract.d.ts.map +1 -1
- package/dist/contracts/seal.contract.d.ts +20 -0
- package/dist/contracts/seal.contract.d.ts.map +1 -1
- package/dist/contracts/secrets.contract.d.ts +15 -0
- package/dist/contracts/secrets.contract.d.ts.map +1 -1
- package/dist/contracts/secrets.contract.js +21 -1
- package/dist/contracts/secrets.contract.js.map +1 -1
- package/dist/contracts/sessions.contract.d.ts +133 -2
- package/dist/contracts/sessions.contract.d.ts.map +1 -1
- package/dist/contracts/settings.contract.d.ts +73 -42
- package/dist/contracts/settings.contract.d.ts.map +1 -1
- package/dist/contracts/settings.contract.js +18 -0
- package/dist/contracts/settings.contract.js.map +1 -1
- package/dist/contracts/stack-grants.contract.d.ts +440 -0
- package/dist/contracts/stack-grants.contract.d.ts.map +1 -0
- package/dist/contracts/stack-grants.contract.js +46 -0
- package/dist/contracts/stack-grants.contract.js.map +1 -0
- package/dist/contracts/system.contract.d.ts +191 -69
- package/dist/contracts/system.contract.d.ts.map +1 -1
- package/dist/contracts/system.contract.js +12 -42
- package/dist/contracts/system.contract.js.map +1 -1
- package/dist/contracts/workspace.contract.d.ts +0 -55
- package/dist/contracts/workspace.contract.d.ts.map +1 -1
- package/dist/contracts/workspace.contract.js +0 -19
- package/dist/contracts/workspace.contract.js.map +1 -1
- package/dist/events/agent-events.d.ts +509 -8
- package/dist/events/agent-events.d.ts.map +1 -1
- package/dist/events/agent-transcript.d.ts +133 -2
- package/dist/events/agent-transcript.d.ts.map +1 -1
- package/dist/events/agent-words.d.ts.map +1 -1
- package/dist/events/agent-words.js +2 -1
- package/dist/events/agent-words.js.map +1 -1
- package/dist/events/child-news.d.ts +32 -0
- package/dist/events/child-news.d.ts.map +1 -0
- package/dist/events/child-news.js +171 -0
- package/dist/events/child-news.js.map +1 -0
- package/dist/events/prompt-origins.d.ts +42 -0
- package/dist/events/prompt-origins.d.ts.map +1 -1
- package/dist/events/prompt-origins.js +28 -0
- package/dist/events/prompt-origins.js.map +1 -1
- package/dist/events/requests.d.ts +14 -0
- package/dist/events/requests.d.ts.map +1 -1
- package/dist/events/requests.js +12 -0
- package/dist/events/requests.js.map +1 -1
- package/dist/events/system-events.d.ts +16 -0
- package/dist/events/system-events.d.ts.map +1 -1
- package/dist/events/transcript.d.ts +669 -10
- package/dist/events/transcript.d.ts.map +1 -1
- package/dist/events/transcript.js +2 -1
- package/dist/events/transcript.js.map +1 -1
- package/dist/ids/conversation-ids.d.ts.map +1 -1
- package/dist/ids/conversation-ids.js.map +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist/models/model-roles.d.ts +91 -37
- package/dist/models/model-roles.d.ts.map +1 -1
- package/dist/models/model-roles.js +106 -35
- package/dist/models/model-roles.js.map +1 -1
- package/dist/models/model-setups.d.ts +10 -8
- package/dist/models/model-setups.d.ts.map +1 -1
- package/dist/models/model-setups.js +15 -15
- package/dist/models/model-setups.js.map +1 -1
- package/dist/policy/approvals-execution.d.ts +5 -2
- package/dist/policy/approvals-execution.d.ts.map +1 -1
- package/dist/policy/approvals-execution.js +3 -4
- package/dist/policy/approvals-execution.js.map +1 -1
- package/dist/policy/batch-runs.d.ts +1 -1
- package/dist/policy/batch-runs.d.ts.map +1 -1
- package/dist/policy/batch-runs.js +2 -1
- package/dist/policy/batch-runs.js.map +1 -1
- package/dist/policy/message-limits.d.ts.map +1 -1
- package/dist/policy/message-limits.js.map +1 -1
- package/dist/policy/org-locks.d.ts +1 -1
- package/dist/policy/org-locks.d.ts.map +1 -1
- package/dist/policy/org-locks.js +1 -0
- package/dist/policy/org-locks.js.map +1 -1
- package/dist/policy/shell/workspace-root-exclude.d.ts +4 -0
- package/dist/policy/shell/workspace-root-exclude.d.ts.map +1 -0
- package/dist/policy/shell/workspace-root-exclude.js +4 -0
- package/dist/policy/shell/workspace-root-exclude.js.map +1 -0
- package/dist/protocol/doors/listener-protocol.d.ts +7 -0
- package/dist/protocol/doors/listener-protocol.d.ts.map +1 -1
- package/dist/protocol/doors/listener-protocol.js +1 -0
- package/dist/protocol/doors/listener-protocol.js.map +1 -1
- package/dist/protocol/doors/webext-links.d.ts.map +1 -1
- package/dist/protocol/doors/webext-links.js.map +1 -1
- package/dist/protocol/raw/extension-protocol.d.ts +634 -0
- package/dist/protocol/raw/extension-protocol.d.ts.map +1 -1
- package/dist/protocol/raw/extension-protocol.js +292 -0
- package/dist/protocol/raw/extension-protocol.js.map +1 -1
- package/dist/protocol/raw/raw-json-routes.d.ts +3034 -0
- package/dist/protocol/raw/raw-json-routes.d.ts.map +1 -1
- package/dist/protocol/raw/raw-json-routes.js +39 -0
- package/dist/protocol/raw/raw-json-routes.js.map +1 -1
- package/dist/protocol/raw/raw-routes.d.ts +260 -1
- package/dist/protocol/raw/raw-routes.d.ts.map +1 -1
- package/dist/protocol/raw/raw-routes.js +57 -1
- package/dist/protocol/raw/raw-routes.js.map +1 -1
- package/dist/protocol/s2s/address.d.ts +53 -0
- package/dist/protocol/s2s/address.d.ts.map +1 -0
- package/dist/protocol/s2s/address.js +111 -0
- package/dist/protocol/s2s/address.js.map +1 -0
- package/dist/protocol/s2s/attestation.d.ts +41 -0
- package/dist/protocol/s2s/attestation.d.ts.map +1 -0
- package/dist/protocol/s2s/attestation.js +96 -0
- package/dist/protocol/s2s/attestation.js.map +1 -0
- package/dist/protocol/s2s/canonical.d.ts +10 -0
- package/dist/protocol/s2s/canonical.d.ts.map +1 -0
- package/dist/protocol/s2s/canonical.js +94 -0
- package/dist/protocol/s2s/canonical.js.map +1 -0
- package/dist/protocol/s2s/envelope.d.ts +40 -0
- package/dist/protocol/s2s/envelope.d.ts.map +1 -0
- package/dist/protocol/s2s/envelope.js +116 -0
- package/dist/protocol/s2s/envelope.js.map +1 -0
- package/dist/protocol/s2s/extension-sign.d.ts +21 -0
- package/dist/protocol/s2s/extension-sign.d.ts.map +1 -0
- package/dist/protocol/s2s/extension-sign.js +41 -0
- package/dist/protocol/s2s/extension-sign.js.map +1 -0
- package/dist/protocol/s2s/identity-doc.d.ts +50 -0
- package/dist/protocol/s2s/identity-doc.d.ts.map +1 -0
- package/dist/protocol/s2s/identity-doc.js +89 -0
- package/dist/protocol/s2s/identity-doc.js.map +1 -0
- package/dist/protocol/s2s/index.d.ts +12 -0
- package/dist/protocol/s2s/index.d.ts.map +1 -0
- package/dist/protocol/s2s/index.js +12 -0
- package/dist/protocol/s2s/index.js.map +1 -0
- package/dist/protocol/s2s/kem.d.ts +15 -0
- package/dist/protocol/s2s/kem.d.ts.map +1 -0
- package/dist/protocol/s2s/kem.js +34 -0
- package/dist/protocol/s2s/kem.js.map +1 -0
- package/dist/protocol/s2s/keys.d.ts +34 -0
- package/dist/protocol/s2s/keys.d.ts.map +1 -0
- package/dist/protocol/s2s/keys.js +81 -0
- package/dist/protocol/s2s/keys.js.map +1 -0
- package/dist/protocol/s2s/passkey-cosign.d.ts +44 -0
- package/dist/protocol/s2s/passkey-cosign.d.ts.map +1 -0
- package/dist/protocol/s2s/passkey-cosign.js +139 -0
- package/dist/protocol/s2s/passkey-cosign.js.map +1 -0
- package/dist/protocol/s2s/session.d.ts +61 -0
- package/dist/protocol/s2s/session.d.ts.map +1 -0
- package/dist/protocol/s2s/session.js +98 -0
- package/dist/protocol/s2s/session.js.map +1 -0
- package/dist/protocol/s2s/sign.d.ts +12 -0
- package/dist/protocol/s2s/sign.d.ts.map +1 -0
- package/dist/protocol/s2s/sign.js +33 -0
- package/dist/protocol/s2s/sign.js.map +1 -0
- package/dist/schemas/activity.d.ts.map +1 -1
- package/dist/schemas/activity.js.map +1 -1
- package/dist/schemas/agent.d.ts +4 -0
- package/dist/schemas/agent.d.ts.map +1 -1
- package/dist/schemas/agent.js +4 -2
- package/dist/schemas/agent.js.map +1 -1
- package/dist/schemas/agents-list.d.ts +8 -0
- package/dist/schemas/agents-list.d.ts.map +1 -1
- package/dist/schemas/agents.d.ts +16 -0
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/approvals.d.ts +100 -0
- package/dist/schemas/approvals.d.ts.map +1 -1
- package/dist/schemas/approvals.js +21 -0
- package/dist/schemas/approvals.js.map +1 -1
- package/dist/schemas/automations.d.ts +89 -27
- package/dist/schemas/automations.d.ts.map +1 -1
- package/dist/schemas/automations.js +15 -33
- package/dist/schemas/automations.js.map +1 -1
- package/dist/schemas/capabilities.d.ts +1 -0
- package/dist/schemas/capabilities.d.ts.map +1 -1
- package/dist/schemas/ci-deployments.d.ts +30 -0
- package/dist/schemas/ci-deployments.d.ts.map +1 -0
- package/dist/schemas/ci-deployments.js +18 -0
- package/dist/schemas/ci-deployments.js.map +1 -0
- package/dist/schemas/ci.d.ts +348 -21
- package/dist/schemas/ci.d.ts.map +1 -1
- package/dist/schemas/ci.js +110 -19
- package/dist/schemas/ci.js.map +1 -1
- package/dist/schemas/command-admission.d.ts +6 -0
- package/dist/schemas/command-admission.d.ts.map +1 -1
- package/dist/schemas/command-admission.js +2 -1
- package/dist/schemas/command-admission.js.map +1 -1
- package/dist/schemas/command-run.d.ts +29 -0
- package/dist/schemas/command-run.d.ts.map +1 -0
- package/dist/schemas/command-run.js +20 -0
- package/dist/schemas/command-run.js.map +1 -0
- package/dist/schemas/contact-need.d.ts +50 -0
- package/dist/schemas/contact-need.d.ts.map +1 -0
- package/dist/schemas/contact-need.js +19 -0
- package/dist/schemas/contact-need.js.map +1 -0
- package/dist/schemas/contacts-settings.d.ts +5 -0
- package/dist/schemas/contacts-settings.d.ts.map +1 -0
- package/dist/schemas/contacts-settings.js +11 -0
- package/dist/schemas/contacts-settings.js.map +1 -0
- package/dist/schemas/data-protection.d.ts +15 -2
- package/dist/schemas/data-protection.d.ts.map +1 -1
- package/dist/schemas/data-protection.js +15 -23
- package/dist/schemas/data-protection.js.map +1 -1
- package/dist/schemas/device-stacks.d.ts +131 -0
- package/dist/schemas/device-stacks.d.ts.map +1 -1
- package/dist/schemas/device-stacks.js +81 -0
- package/dist/schemas/device-stacks.js.map +1 -1
- package/dist/schemas/devices.d.ts +73 -0
- package/dist/schemas/devices.d.ts.map +1 -1
- package/dist/schemas/devices.js +6 -2
- package/dist/schemas/devices.js.map +1 -1
- package/dist/schemas/extension-updates.d.ts +1192 -0
- package/dist/schemas/extension-updates.d.ts.map +1 -1
- package/dist/schemas/extension-updates.js +18 -4
- package/dist/schemas/extension-updates.js.map +1 -1
- package/dist/schemas/host-power.d.ts +22 -0
- package/dist/schemas/host-power.d.ts.map +1 -1
- package/dist/schemas/host-power.js +55 -0
- package/dist/schemas/host-power.js.map +1 -1
- package/dist/schemas/hosts.d.ts +226 -0
- package/dist/schemas/hosts.d.ts.map +1 -1
- package/dist/schemas/hosts.js +24 -0
- package/dist/schemas/hosts.js.map +1 -1
- package/dist/schemas/issues.d.ts +37 -249
- package/dist/schemas/issues.d.ts.map +1 -1
- package/dist/schemas/issues.js +10 -43
- package/dist/schemas/issues.js.map +1 -1
- package/dist/schemas/links.d.ts +8 -0
- package/dist/schemas/links.d.ts.map +1 -1
- package/dist/schemas/links.js +4 -0
- package/dist/schemas/links.js.map +1 -1
- package/dist/schemas/maintenance.d.ts.map +1 -1
- package/dist/schemas/maintenance.js.map +1 -1
- package/dist/schemas/metrics.d.ts +25 -0
- package/dist/schemas/metrics.d.ts.map +1 -1
- package/dist/schemas/metrics.js +18 -0
- package/dist/schemas/metrics.js.map +1 -1
- package/dist/schemas/need-kinds.d.ts +20 -0
- package/dist/schemas/need-kinds.d.ts.map +1 -0
- package/dist/schemas/need-kinds.js +7 -0
- package/dist/schemas/need-kinds.js.map +1 -0
- package/dist/schemas/needs.d.ts +666 -30
- package/dist/schemas/needs.d.ts.map +1 -1
- package/dist/schemas/needs.js +29 -6
- package/dist/schemas/needs.js.map +1 -1
- package/dist/schemas/offload.d.ts +52 -0
- package/dist/schemas/offload.d.ts.map +1 -1
- package/dist/schemas/offload.js +12 -0
- package/dist/schemas/offload.js.map +1 -1
- package/dist/schemas/outward-action.d.ts +39 -0
- package/dist/schemas/outward-action.d.ts.map +1 -0
- package/dist/schemas/outward-action.js +40 -0
- package/dist/schemas/outward-action.js.map +1 -0
- package/dist/schemas/providers/plan-limits.d.ts +1 -0
- package/dist/schemas/providers/plan-limits.d.ts.map +1 -1
- package/dist/schemas/providers/plan-limits.js +1 -0
- package/dist/schemas/providers/plan-limits.js.map +1 -1
- package/dist/schemas/redirect-need.d.ts +15 -0
- package/dist/schemas/redirect-need.d.ts.map +1 -0
- package/dist/schemas/redirect-need.js +14 -0
- package/dist/schemas/redirect-need.js.map +1 -0
- package/dist/schemas/s2s-identity.d.ts +521 -0
- package/dist/schemas/s2s-identity.d.ts.map +1 -0
- package/dist/schemas/s2s-identity.js +208 -0
- package/dist/schemas/s2s-identity.js.map +1 -0
- package/dist/schemas/s2s-views.d.ts +2127 -0
- package/dist/schemas/s2s-views.d.ts.map +1 -0
- package/dist/schemas/s2s-views.js +217 -0
- package/dist/schemas/s2s-views.js.map +1 -0
- package/dist/schemas/s2s-wire.d.ts +1616 -0
- package/dist/schemas/s2s-wire.d.ts.map +1 -0
- package/dist/schemas/s2s-wire.js +276 -0
- package/dist/schemas/s2s-wire.js.map +1 -0
- package/dist/schemas/s2s.d.ts +5 -0
- package/dist/schemas/s2s.d.ts.map +1 -0
- package/dist/schemas/s2s.js +5 -0
- package/dist/schemas/s2s.js.map +1 -0
- package/dist/schemas/secrets.d.ts +17 -0
- package/dist/schemas/secrets.d.ts.map +1 -1
- package/dist/schemas/secrets.js +12 -5
- package/dist/schemas/secrets.js.map +1 -1
- package/dist/schemas/settings-history.d.ts +1 -1
- package/dist/schemas/settings-history.d.ts.map +1 -1
- package/dist/schemas/settings-history.js +5 -4
- package/dist/schemas/settings-history.js.map +1 -1
- package/dist/schemas/settings-savings.d.ts +58 -0
- package/dist/schemas/settings-savings.d.ts.map +1 -1
- package/dist/schemas/settings-savings.js +22 -0
- package/dist/schemas/settings-savings.js.map +1 -1
- package/dist/schemas/settings.d.ts +18 -42
- package/dist/schemas/settings.d.ts.map +1 -1
- package/dist/schemas/settings.js +7 -6
- package/dist/schemas/settings.js.map +1 -1
- package/dist/schemas/stack-grants.d.ts +60 -0
- package/dist/schemas/stack-grants.d.ts.map +1 -0
- package/dist/schemas/stack-grants.js +33 -0
- package/dist/schemas/stack-grants.js.map +1 -0
- package/dist/schemas/terminal.d.ts +2 -0
- package/dist/schemas/terminal.d.ts.map +1 -1
- package/dist/schemas/terminal.js +4 -0
- package/dist/schemas/terminal.js.map +1 -1
- package/dist/schemas/vpn.d.ts +4 -0
- package/dist/schemas/vpn.d.ts.map +1 -1
- package/dist/schemas/vpn.js +9 -0
- package/dist/schemas/vpn.js.map +1 -1
- package/dist/schemas/watch-sources.d.ts +72 -0
- package/dist/schemas/watch-sources.d.ts.map +1 -0
- package/dist/schemas/watch-sources.js +88 -0
- package/dist/schemas/watch-sources.js.map +1 -0
- package/dist/schemas/workspace/workspace-search.d.ts.map +1 -1
- package/dist/schemas/workspace/workspace-search.js +1 -1
- package/dist/schemas/workspace/workspace-search.js.map +1 -1
- package/dist/schemas/wsl-memory.d.ts +76 -0
- package/dist/schemas/wsl-memory.d.ts.map +1 -0
- package/dist/schemas/wsl-memory.js +36 -0
- package/dist/schemas/wsl-memory.js.map +1 -0
- package/dist/state/auth-state.d.ts.map +1 -1
- package/dist/state/auth-state.js +8 -0
- package/dist/state/auth-state.js.map +1 -1
- package/dist/state/definition.d.ts +22 -8
- package/dist/state/definition.d.ts.map +1 -1
- package/dist/state/workspace-state.d.ts +8 -3
- package/dist/state/workspace-state.d.ts.map +1 -1
- package/dist/state/workspace-state.js +8 -3
- package/dist/state/workspace-state.js.map +1 -1
- package/package.json +20 -5
- package/src/briefs/agent-ask.ts +23 -0
- package/src/{chores/extension-update.ts → briefs/extension-update-brief.ts} +3 -2
- package/src/chores/digest.ts +1 -0
- package/src/chores/index.ts +13 -2
- package/src/chores/prompt.ts +3 -18
- package/src/chores/stack.ts +1 -0
- package/src/chores/verdict.ts +1 -0
- package/src/chores/workspace-scope.ts +3 -8
- package/src/contracts/approvals.contract.ts +24 -3
- package/src/contracts/capabilities.contract.ts +24 -0
- package/src/contracts/ci.contract.ts +119 -37
- package/src/contracts/device-stacks.contract.ts +97 -0
- package/src/contracts/extensions.contract.ts +11 -0
- package/src/contracts/secrets.contract.ts +27 -0
- package/src/contracts/settings.contract.ts +24 -0
- package/src/contracts/stack-grants.contract.ts +51 -0
- package/src/contracts/system.contract.ts +16 -59
- package/src/contracts/workspace.contract.ts +0 -22
- package/src/events/agent-words.ts +3 -1
- package/src/events/child-news.test.ts +91 -0
- package/src/events/child-news.ts +269 -0
- package/src/events/prompt-origins.ts +35 -0
- package/src/events/requests.ts +18 -0
- package/src/events/transcript.ts +10 -1
- package/src/ids/conversation-ids.test.ts +22 -3
- package/src/ids/conversation-ids.ts +5 -7
- package/src/index.ts +3 -6
- package/src/models/model-roles.test.ts +61 -4
- package/src/models/model-roles.ts +153 -49
- package/src/models/model-setups.ts +49 -26
- package/src/policy/approvals-execution.ts +11 -6
- package/src/policy/batch-runs.ts +2 -2
- package/src/policy/message-limits.ts +8 -4
- package/src/policy/org-locks.ts +1 -0
- package/src/policy/shell/workspace-root-exclude.ts +11 -0
- package/src/protocol/doors/listener-protocol.ts +14 -0
- package/src/protocol/doors/webext-links.ts +3 -1
- package/src/protocol/ingress-contract.fixture.json +6 -1
- package/src/protocol/raw/extension-protocol.ts +513 -2
- package/src/protocol/raw/raw-json-routes.ts +85 -0
- package/src/protocol/raw/raw-routes.ts +111 -7
- package/src/protocol/s2s/address.test.ts +157 -0
- package/src/protocol/s2s/address.ts +193 -0
- package/src/protocol/s2s/attestation.test.ts +262 -0
- package/src/protocol/s2s/attestation.ts +173 -0
- package/src/protocol/s2s/canonical.test.ts +70 -0
- package/src/protocol/s2s/canonical.ts +119 -0
- package/src/protocol/s2s/envelope.test.ts +162 -0
- package/src/protocol/s2s/envelope.ts +194 -0
- package/src/protocol/s2s/extension-sign.test.ts +117 -0
- package/src/protocol/s2s/extension-sign.ts +76 -0
- package/src/protocol/s2s/identity-doc.test.ts +187 -0
- package/src/protocol/s2s/identity-doc.ts +169 -0
- package/src/protocol/s2s/index.ts +15 -0
- package/src/protocol/s2s/kem.ts +62 -0
- package/src/protocol/s2s/keys.test.ts +76 -0
- package/src/protocol/s2s/keys.ts +155 -0
- package/src/protocol/s2s/passkey-cosign.test.ts +98 -0
- package/src/protocol/s2s/passkey-cosign.testing.ts +86 -0
- package/src/protocol/s2s/passkey-cosign.ts +192 -0
- package/src/protocol/s2s/s2s.testing.ts +22 -0
- package/src/protocol/s2s/session.test.ts +133 -0
- package/src/protocol/s2s/session.ts +179 -0
- package/src/protocol/s2s/sign.test.ts +66 -0
- package/src/protocol/s2s/sign.ts +53 -0
- package/src/schemas/activity.ts +2 -1
- package/src/schemas/agent.test.ts +3 -0
- package/src/schemas/agent.ts +10 -4
- package/src/schemas/approvals.ts +41 -0
- package/src/schemas/automations.ts +26 -41
- package/src/schemas/ci-deployments.ts +26 -0
- package/src/schemas/ci.ts +185 -45
- package/src/schemas/command-admission.ts +4 -1
- package/src/schemas/command-run.ts +44 -0
- package/src/schemas/contact-need.ts +26 -0
- package/src/schemas/contacts-settings.ts +16 -0
- package/src/schemas/data-protection.ts +28 -34
- package/src/schemas/device-stacks.ts +162 -3
- package/src/schemas/devices.ts +13 -2
- package/src/schemas/extension-updates.ts +27 -7
- package/src/schemas/host-power.test.ts +53 -0
- package/src/schemas/host-power.ts +96 -2
- package/src/schemas/hosts.test.ts +32 -0
- package/src/schemas/hosts.ts +62 -0
- package/src/schemas/issues.ts +30 -86
- package/src/schemas/links.ts +4 -0
- package/src/schemas/maintenance.ts +4 -3
- package/src/schemas/metrics.ts +35 -0
- package/src/schemas/need-kinds.ts +13 -0
- package/src/schemas/needs.ts +44 -16
- package/src/schemas/offload.ts +31 -0
- package/src/schemas/outward-action.ts +47 -0
- package/src/schemas/providers/plan-limits.ts +1 -0
- package/src/schemas/redirect-need.ts +19 -0
- package/src/schemas/s2s-identity.ts +329 -0
- package/src/schemas/s2s-views.ts +326 -0
- package/src/schemas/s2s-wire.ts +401 -0
- package/src/schemas/s2s.test.ts +175 -0
- package/src/schemas/s2s.ts +9 -0
- package/src/schemas/secrets.ts +23 -5
- package/src/schemas/settings-history.ts +10 -5
- package/src/schemas/settings-savings.ts +29 -0
- package/src/schemas/settings.test.ts +23 -23
- package/src/schemas/settings.ts +12 -12
- package/src/schemas/stack-grants.ts +59 -0
- package/src/schemas/terminal.ts +6 -0
- package/src/schemas/version-seam.test.ts +13 -1
- package/src/schemas/vpn.ts +13 -0
- package/src/schemas/watch-sources.ts +127 -0
- package/src/schemas/workspace/workspace-search.ts +5 -2
- package/src/schemas/wsl-memory.ts +59 -0
- package/src/state/auth-state.ts +17 -0
- package/src/state/workspace-state.ts +18 -18
- package/src/text/embed.ts +2 -2
- package/dist/chores/extension-update.d.ts.map +0 -1
- package/dist/chores/extension-update.js.map +0 -1
- package/dist/contracts/chores.contract.d.ts +0 -213
- package/dist/contracts/chores.contract.d.ts.map +0 -1
- package/dist/contracts/chores.contract.js +0 -32
- package/dist/contracts/chores.contract.js.map +0 -1
- package/dist/contracts/issues.contract.d.ts +0 -106
- package/dist/contracts/issues.contract.d.ts.map +0 -1
- package/dist/contracts/issues.contract.js +0 -50
- package/dist/contracts/issues.contract.js.map +0 -1
- package/src/chores/chores.test.ts +0 -24
- package/src/chores/digest.test.ts +0 -27
- package/src/chores/probes.integration.test.ts +0 -494
- package/src/chores/stack.test.ts +0 -140
- package/src/chores/verdict.test.ts +0 -761
- package/src/contracts/chores.contract.ts +0 -39
- package/src/contracts/issues.contract.ts +0 -53
|
@@ -98,6 +98,47 @@ import {
|
|
|
98
98
|
AccountSendSchema,
|
|
99
99
|
IssueAcceptedSchema,
|
|
100
100
|
} from "../../schemas/issues.js";
|
|
101
|
+
import {
|
|
102
|
+
S2sAttestationAcceptSchema,
|
|
103
|
+
S2sAttestationAskSchema,
|
|
104
|
+
S2sAttestationIssueSchema,
|
|
105
|
+
S2sAttestationsSchema,
|
|
106
|
+
S2sCallSealedSchema,
|
|
107
|
+
S2sContactAcceptInputSchema,
|
|
108
|
+
S2sContactAddSchema,
|
|
109
|
+
S2sContactBootstrapAnswerSchema,
|
|
110
|
+
S2sContactBootstrapRequestSchema,
|
|
111
|
+
S2sContactChangeSchema,
|
|
112
|
+
S2sContactSchema,
|
|
113
|
+
S2sContactsListSchema,
|
|
114
|
+
S2sContactTaskDecisionSchema,
|
|
115
|
+
S2sContactTaskSchema,
|
|
116
|
+
S2sContactTasksSchema,
|
|
117
|
+
S2sDomainInputSchema,
|
|
118
|
+
S2sEnvelopeSchema,
|
|
119
|
+
S2sInboxAcceptedSchema,
|
|
120
|
+
S2sLinkUpgradeAnswerSchema,
|
|
121
|
+
S2sLinkUpgradeRequestSchema,
|
|
122
|
+
S2sMeSchema,
|
|
123
|
+
S2sMessageSendOutcomeSchema,
|
|
124
|
+
S2sMessageSendSchema,
|
|
125
|
+
S2sOutboxSchema,
|
|
126
|
+
S2sPairedSchema,
|
|
127
|
+
S2sPairingAnswerSchema,
|
|
128
|
+
S2sPairingRequestSchema,
|
|
129
|
+
S2sPairingUpgradeAnswerSchema,
|
|
130
|
+
S2sPairingUpgradeRequestSchema,
|
|
131
|
+
S2sRecoverInputSchema,
|
|
132
|
+
S2sRecoveryMintedSchema,
|
|
133
|
+
S2sSessionAnswerSchema,
|
|
134
|
+
S2sSessionOpenSchema,
|
|
135
|
+
S2sTakenSchema,
|
|
136
|
+
S2sTakeSchema,
|
|
137
|
+
S2sThreadSchema,
|
|
138
|
+
S2sThreadsListSchema,
|
|
139
|
+
S2sTrustKeySchema,
|
|
140
|
+
SandboxIdentitySchema,
|
|
141
|
+
} from "../../schemas/s2s.js";
|
|
101
142
|
import { UploadManifestSchema, UploadSkipSchema } from "../../schemas/workspace/workspace-upload.js";
|
|
102
143
|
import {
|
|
103
144
|
ArrivalAbandonedSchema,
|
|
@@ -260,6 +301,50 @@ export const RAW_JSON_ROUTES = {
|
|
|
260
301
|
"POST /link/operate/exec/{id}/stop": { output: LinkExecStatusSchema },
|
|
261
302
|
"POST /link/operate/read": { input: LinkReadSchema, output: LinkReadAnswerSchema },
|
|
262
303
|
"POST /link/operate/write": { input: LinkWriteSchema, output: LinkWriteAnswerSchema },
|
|
304
|
+
// Sandbox-to-sandbox (schemas/s2s.ts): the doors another daemon calls; a call's input and answer are sealed, its
|
|
305
|
+
// method's own shapes inside (S2S_CALLS). A message's file (`GET /s2s/messages/{id}/files/{name}`) answers its bytes.
|
|
306
|
+
"GET /s2s/identity": { output: SandboxIdentitySchema },
|
|
307
|
+
"POST /s2s/inbox": { input: S2sEnvelopeSchema, output: S2sInboxAcceptedSchema },
|
|
308
|
+
"POST /s2s/session": { input: S2sSessionOpenSchema, output: S2sSessionAnswerSchema },
|
|
309
|
+
"POST /s2s/call/{method}": { input: S2sCallSealedSchema, output: S2sCallSealedSchema },
|
|
310
|
+
"POST /link/upgrade": { input: S2sLinkUpgradeRequestSchema, output: S2sLinkUpgradeAnswerSchema },
|
|
311
|
+
"POST /account/pairings/upgrade": { input: S2sPairingUpgradeRequestSchema, output: S2sPairingUpgradeAnswerSchema },
|
|
312
|
+
"POST /account/contact-bootstrap": { input: S2sContactBootstrapRequestSchema, output: S2sContactBootstrapAnswerSchema },
|
|
313
|
+
// The Messages tab's Identity section: every write answers the identity after it, but the recovery key, said once.
|
|
314
|
+
"GET /s2s/me": { output: S2sMeSchema },
|
|
315
|
+
"POST /s2s/me/domains": { input: S2sDomainInputSchema, output: S2sMeSchema },
|
|
316
|
+
"DELETE /s2s/me/domains/{domain}": { output: S2sMeSchema },
|
|
317
|
+
"POST /s2s/me/domains/{domain}/check": { output: S2sMeSchema },
|
|
318
|
+
"POST /s2s/me/rotate": { output: S2sMeSchema },
|
|
319
|
+
"POST /s2s/me/recovery": { output: S2sRecoveryMintedSchema },
|
|
320
|
+
"POST /s2s/me/recover": { input: S2sRecoverInputSchema, output: S2sMeSchema },
|
|
321
|
+
// Attestations: the list after each change; asking and issuing answer as a message's send does.
|
|
322
|
+
"GET /s2s/me/attestations": { output: S2sAttestationsSchema },
|
|
323
|
+
"POST /s2s/me/attestations": { input: S2sAttestationAcceptSchema, output: S2sAttestationsSchema },
|
|
324
|
+
"DELETE /s2s/me/attestations/{id}": { output: S2sAttestationsSchema },
|
|
325
|
+
"POST /s2s/me/attestations/ask": { input: S2sAttestationAskSchema, output: S2sMessageSendOutcomeSchema },
|
|
326
|
+
"POST /s2s/attestations/issue": { input: S2sAttestationIssueSchema, output: S2sMessageSendOutcomeSchema },
|
|
327
|
+
// Contacts: every write answers the contact after it.
|
|
328
|
+
"GET /s2s/contacts": { output: S2sContactsListSchema },
|
|
329
|
+
"POST /s2s/contacts/paired": { input: S2sPairedSchema, output: S2sContactSchema },
|
|
330
|
+
"POST /s2s/contacts": { input: S2sContactAddSchema, output: S2sContactSchema },
|
|
331
|
+
"POST /s2s/contacts/{id}": { input: S2sContactChangeSchema, output: S2sContactSchema },
|
|
332
|
+
"DELETE /s2s/contacts/{id}": { output: OkSchema },
|
|
333
|
+
"POST /s2s/contacts/{id}/accept": { input: S2sContactAcceptInputSchema, output: S2sContactSchema },
|
|
334
|
+
"POST /s2s/contacts/{id}/block": { output: S2sContactSchema },
|
|
335
|
+
"POST /s2s/contacts/{id}/trust-key": { input: S2sTrustKeySchema, output: S2sContactSchema },
|
|
336
|
+
"GET /s2s/tasks": { output: S2sContactTasksSchema },
|
|
337
|
+
"POST /s2s/contacts/{id}/tasks/{request}": { input: S2sContactTaskDecisionSchema, output: S2sContactTaskSchema },
|
|
338
|
+
"GET /s2s/contacts/{id}/tasks/{request}/watch": { output: LinkTaskStatusSchema },
|
|
339
|
+
"GET /s2s/outbox": { output: S2sOutboxSchema },
|
|
340
|
+
"POST /s2s/pairings": { input: S2sPairingRequestSchema, output: S2sPairingAnswerSchema },
|
|
341
|
+
// The inbox.
|
|
342
|
+
"GET /s2s/threads": { output: S2sThreadsListSchema },
|
|
343
|
+
"GET /s2s/threads/{id}": { output: S2sThreadSchema },
|
|
344
|
+
"DELETE /s2s/threads/{id}": { output: OkSchema },
|
|
345
|
+
"POST /s2s/threads/{id}/read": { output: OkSchema },
|
|
346
|
+
"POST /s2s/messages": { input: S2sMessageSendSchema, output: S2sMessageSendOutcomeSchema },
|
|
347
|
+
"POST /s2s/messages/{id}/take": { input: S2sTakeSchema, output: S2sTakenSchema },
|
|
263
348
|
"POST /diagnostics": { input: DiagnosticsAskSchema, output: DiagnosticsAnswerSchema },
|
|
264
349
|
"GET /fleet/{handle}/bundle": { output: ConversationBundleSchema },
|
|
265
350
|
"GET /system/control/tokens": { output: ControlTokensListSchema },
|
|
@@ -81,19 +81,25 @@ export const RAW_ROUTES = {
|
|
|
81
81
|
"POST /automations/{id}/fire": { auth: "door" },
|
|
82
82
|
// The release gate a pipeline runner waits on, gated by the workflow's minted gate token.
|
|
83
83
|
"POST /workflows/{id}/gate": { auth: "door" },
|
|
84
|
-
// The Visitor chat
|
|
84
|
+
// The Visitor chat's public paths before 2026-11-26, in customers' pages (the snippet's script) and in a widget loaded
|
|
85
|
+
// before the update: forwarded, translated, to the visitor-chat extension's own door below
|
|
86
|
+
// (extensions/backend/moved-doors.routes.ts), whose protections apply as they do there. Which sites loaded the widget
|
|
87
|
+
// left with it, for the extension's own install panel.
|
|
85
88
|
"GET /webchat/widget.js": { auth: "door", embedded: true },
|
|
86
89
|
"GET /webchat/{id}/config": { auth: "door", embedded: true },
|
|
87
90
|
"GET /webchat/{id}/challenge": { auth: "door", embedded: true },
|
|
88
91
|
"POST /webchat/{id}/message": { auth: "door", embedded: true },
|
|
89
92
|
"GET /webchat/{id}/messages": { auth: "door", embedded: true },
|
|
90
|
-
//
|
|
91
|
-
|
|
92
|
-
// The bug intake, the other anonymous door: gated by origin allowlist or ingest key, rate window and daily ceiling.
|
|
93
|
+
// The bug intake's public paths before 2026-11-26, out in customers' pages and apps: forwarded, translated, to the issues
|
|
94
|
+
// extension's own door below (extensions/backend/moved-doors.routes.ts), whose protections apply as they do there.
|
|
93
95
|
"GET /intake/sdk.js": { auth: "door", embedded: true },
|
|
94
96
|
"GET /intake/{id}/config": { auth: "door", embedded: true },
|
|
95
97
|
"GET /intake/{id}/challenge": { auth: "door", embedded: true },
|
|
96
98
|
"POST /intake/{id}/report": { auth: "door", embedded: true },
|
|
99
|
+
// (2026-11-26) An extension's public doors (`contributes.publicRoutes`), anyone's to call: gated in the handler by the
|
|
100
|
+
// route's own declaration (size, rate window, daily ceiling, an automation's allowlist or key, proof of work, a
|
|
101
|
+
// provider's signature) before the backend hears of it, and embedded, so a page elsewhere may call one.
|
|
102
|
+
"ALL /door/*": { auth: "door", embedded: true },
|
|
97
103
|
// The roster is for whoever runs people and access (Full access, or the People & access right) to read and change;
|
|
98
104
|
// giving up one's own grant is every tier's. Reading it is floored here as well as in its handler (members.routes.ts),
|
|
99
105
|
// so the editor knows before asking; what someone below Full access may change is the handler's (peopleChangeRefusal).
|
|
@@ -229,13 +235,47 @@ export const RAW_ROUTES = {
|
|
|
229
235
|
// A person in the channel pressing Stop on a turn that channel started; the handler asks the automation's own
|
|
230
236
|
// sender rules whether that person may.
|
|
231
237
|
"POST /listeners/{provider}/stop": { panel: false, control: "never" },
|
|
238
|
+
// (2026-11-26) Who a stranger who signed in is (a Google ID token verified against a site's own client id, and whether
|
|
239
|
+
// that address is the owner's or a member's), for a listener anyone on the internet reaches: the extension that owns
|
|
240
|
+
// it, declaring the route in `permissions.daemon`, checked in the handler too. The Visitor chat's.
|
|
241
|
+
"POST /listeners/{provider}/identity": { panel: false, control: "never" },
|
|
232
242
|
// What an extension's own code asks about itself (extension-protocol.ts): its settings with their secrets, and its
|
|
233
243
|
// event stream. Every extension token reaches both undeclared, and each answers only about the extension asking, so
|
|
234
244
|
// no other credential reaches them; the handler resolves the caller from its token again.
|
|
235
245
|
"GET /extension/settings": { floor: "maintainer", panel: false, control: "never" },
|
|
236
246
|
"GET /extension/events": { floor: "maintainer", panel: false, control: "never", stream: true },
|
|
247
|
+
// (2026-11-26) The two doors an extension's declared `permissions` open beside them: holding work in flight for as
|
|
248
|
+
// long as its stream stays open (`work`), and running one command under a workload class (`exec`). Reached the same
|
|
249
|
+
// way, by every extension token undeclared in `permissions.daemon`, and each checks its own declaration.
|
|
250
|
+
"POST /extension/work/hold": { floor: "maintainer", panel: false, control: "never", stream: true },
|
|
251
|
+
"POST /extension/exec": { floor: "maintainer", panel: false, control: "never" },
|
|
252
|
+
// (2026-11-26) The doors an agent tool's call opens onto the turn that made it (`permissions.turn`): the turn's own
|
|
253
|
+
// signed-in browser for an account it holds, the owner's browser it holds, and a background job in its conversation.
|
|
254
|
+
// Reached the same way, each answering only a ticket the daemon minted for that extension's own call or job.
|
|
255
|
+
"POST /extension/turn/browser": { floor: "maintainer", panel: false, control: "never" },
|
|
256
|
+
"POST /extension/turn/owner-browser": { floor: "maintainer", panel: false, control: "never" },
|
|
257
|
+
"POST /extension/jobs": { floor: "maintainer", panel: false, control: "never", stream: true },
|
|
258
|
+
"POST /extension/jobs/{id}": { floor: "maintainer", panel: false, control: "never" },
|
|
259
|
+
// (2026-11-26) A row in the activity feed, written as the calling extension's own. Reached the same way, undeclared.
|
|
260
|
+
"POST /extension/activity": { floor: "maintainer", panel: false, control: "never" },
|
|
261
|
+
// (2026-11-27) Hosted sleep as an extension's own code meets it (extension-protocol.ts): the public URL of one of its
|
|
262
|
+
// `wakes` routes with its wake secret, what this boot follows, and the before-sleep watch it answers ready on.
|
|
263
|
+
// Reached the same way, undeclared, each answering only about the extension asking.
|
|
264
|
+
"POST /extension/sleep/wake-url": { floor: "maintainer", panel: false, control: "never" },
|
|
265
|
+
"GET /extension/sleep/boot": { floor: "maintainer", panel: false, control: "never" },
|
|
266
|
+
"POST /extension/sleep/watch": { floor: "maintainer", panel: false, control: "never", stream: true },
|
|
267
|
+
"POST /extension/sleep/ready": { floor: "maintainer", panel: false, control: "never" },
|
|
268
|
+
// (2026-11-27) What the platform's sleep watch heard for the extension's own connections while the sandbox slept.
|
|
269
|
+
"POST /extension/sleep/heard": { floor: "maintainer", panel: false, control: "never" },
|
|
270
|
+
// (2026-11-28) This sandbox's public identity document, and a signature as this sandbox over a record of the calling
|
|
271
|
+
// extension's own (`permissions.identity`). Reached the same way, undeclared; the sign door checks its declaration.
|
|
272
|
+
"GET /extension/identity": { floor: "maintainer", panel: false, control: "never" },
|
|
273
|
+
"POST /extension/identity/sign": { floor: "maintainer", panel: false, control: "never" },
|
|
237
274
|
// The CI webhook receiver, gated by the per-sandbox webhook secret.
|
|
238
275
|
"POST /ci/webhook/{host}": { auth: "door" },
|
|
276
|
+
// (2026-11-25) What the forges said, as it is heard, for a program (schemas/ci.ts CiFeedEventSchema): Server-Sent
|
|
277
|
+
// Events. An extension reaches it by declaring it in `permissions.daemon`; no agent or panel token does.
|
|
278
|
+
"GET /ci/feed": { floor: "maintainer", panel: false, control: "never", stream: true },
|
|
239
279
|
// Where an MCP server's authorization server sends the browser back (capabilities/mcp-oauth/): gated by the state of
|
|
240
280
|
// a sign-in this daemon started, and worth nothing without the PKCE verifier only the daemon holds.
|
|
241
281
|
"GET /oauth/mcp/callback": { auth: "door", control: "never" },
|
|
@@ -278,6 +318,11 @@ export const RAW_ROUTES = {
|
|
|
278
318
|
// extension cards' endpoints), by server name: the handler checks the conversation's mount bearer the turn's tool
|
|
279
319
|
// config carries, and that the running turn mounted that name.
|
|
280
320
|
"ALL /mcp/{mount}": { auth: "door", control: "never" },
|
|
321
|
+
// (2026-11-26) The same server, for the turn's own shell: a card's CLI calling the tools its extension's backend serves
|
|
322
|
+
// for that card (the IMAP and Microsoft 365 commands, whose credentials stay in the backend). One JSON-RPC message per
|
|
323
|
+
// request; the conversation it names is believed only with its turn's proof, and must have a live turn that mounted
|
|
324
|
+
// that card's tools (the extensions' card-tools.routes.ts).
|
|
325
|
+
"POST /tools/{mount}": { agent: true, control: "never" },
|
|
281
326
|
// A connected browser's credential doors, on its durable token: a sign-in moves in (`session`) or out (`lend`).
|
|
282
327
|
"POST /system/webext/session": { auth: "door", control: "never" },
|
|
283
328
|
"POST /system/webext/lend": { auth: "door", control: "never" },
|
|
@@ -360,9 +405,10 @@ export const RAW_ROUTES = {
|
|
|
360
405
|
"POST /account/routes/secret": { floor: "viewer", panel: false, control: "never" },
|
|
361
406
|
"GET /account/routes": { floor: "viewer", control: "never" },
|
|
362
407
|
// Routing as a person, a drop (schemas/account-routes.ts): another sandbox the person is in handing a note and files
|
|
363
|
-
// into this one
|
|
364
|
-
//
|
|
365
|
-
//
|
|
408
|
+
// into this one, admitted in the handler by a drop pass beside the person's pairing (admit-route.ts); it starts no
|
|
409
|
+
// turn, and lands as a message in its sender's thread (2026-11-27). The sending side, for `sandboxes send` on the
|
|
410
|
+
// agent's PATH. The old inbox, which nothing files into since: each drop shown to the people it names and to
|
|
411
|
+
// maintainers, the handler cutting the list.
|
|
366
412
|
"POST /account/drop": { auth: "door", control: "never", lane: "bulk" },
|
|
367
413
|
"POST /account/drops": { agent: true, control: "never" },
|
|
368
414
|
"GET /account/inbox": { floor: "viewer", agent: true, control: "never" },
|
|
@@ -401,6 +447,64 @@ export const RAW_ROUTES = {
|
|
|
401
447
|
"POST /link/operate/exec/{id}/stop": { auth: "door", control: "never" },
|
|
402
448
|
"POST /link/operate/read": { auth: "door", control: "never" },
|
|
403
449
|
"POST /link/operate/write": { auth: "door", control: "never" },
|
|
450
|
+
// SANDBOX-TO-SANDBOX (schemas/s2s.ts, docs/architecture/messages.md). The doors another daemon calls: this one's
|
|
451
|
+
// public identity (no credential: answering at all says it speaks s2s/1), the inbox each signed envelope is admitted
|
|
452
|
+
// at, call sessions and calls, and the one-time upgrades an existing link, route pairing or report pass vouches for.
|
|
453
|
+
"GET /s2s/identity": { auth: "door", control: "never" },
|
|
454
|
+
"POST /s2s/inbox": { auth: "door", control: "never", lane: "bulk" },
|
|
455
|
+
"POST /s2s/session": { auth: "door", control: "never" },
|
|
456
|
+
"POST /s2s/call/{method}": { auth: "door", control: "never" },
|
|
457
|
+
"POST /link/upgrade": { auth: "door", control: "never" },
|
|
458
|
+
"POST /account/pairings/upgrade": { auth: "door", control: "never" },
|
|
459
|
+
"POST /account/contact-bootstrap": { auth: "door", control: "never" },
|
|
460
|
+
// This sandbox's identity: its own domains and their checks, rotation, and the recovery key, which is the owner's alone.
|
|
461
|
+
"GET /s2s/me": { floor: "maintainer", control: "never" },
|
|
462
|
+
"POST /s2s/me/domains": { panel: false, control: "never" },
|
|
463
|
+
"DELETE /s2s/me/domains/{domain}": { panel: false, control: "never" },
|
|
464
|
+
"POST /s2s/me/domains/{domain}/check": { control: "never" },
|
|
465
|
+
"POST /s2s/me/rotate": { panel: false, control: "never" },
|
|
466
|
+
"POST /s2s/me/recovery": { floor: "owner", panel: false, control: "never" },
|
|
467
|
+
"POST /s2s/me/recover": { floor: "owner", panel: false, control: "never" },
|
|
468
|
+
// (2026-11-28) Attestations: what other sandboxes vouched for and this one carries in its document, listed, added from
|
|
469
|
+
// the contact's message and removed by the owner or a maintainer; asking a contact to vouch for this sandbox, and
|
|
470
|
+
// vouching for one, both the sandbox speaking as itself. No agent token: an agent never signs or adds one.
|
|
471
|
+
"GET /s2s/me/attestations": { floor: "maintainer", control: "never" },
|
|
472
|
+
"POST /s2s/me/attestations": { panel: false, control: "never" },
|
|
473
|
+
"DELETE /s2s/me/attestations/{id}": { panel: false, control: "never" },
|
|
474
|
+
"POST /s2s/me/attestations/ask": { panel: false, control: "never" },
|
|
475
|
+
"POST /s2s/attestations/issue": { panel: false, control: "never" },
|
|
476
|
+
// Contacts: a sandbox-scoped one is the owner's or a maintainer's to make, accept, re-grant and block. A person-scoped
|
|
477
|
+
// one is that person's own (a viewer's too), so listing, pairing back, removing and trusting a new key floor at the
|
|
478
|
+
// viewer and the handler holds a person to their own. `paired` first: it would otherwise read as a contact's id. The
|
|
479
|
+
// `messages` command lists the contacts and the outbox with its turn proof: the handler cuts both to the contacts that
|
|
480
|
+
// turn may use, as it cuts a person's to their own.
|
|
481
|
+
"GET /s2s/contacts": { floor: "viewer", agent: true, control: "never" },
|
|
482
|
+
"POST /s2s/contacts/paired": { floor: "viewer", panel: false, control: "never" },
|
|
483
|
+
"POST /s2s/contacts": { panel: false, control: "never" },
|
|
484
|
+
"POST /s2s/contacts/{id}": { panel: false, control: "never" },
|
|
485
|
+
"DELETE /s2s/contacts/{id}": { floor: "viewer", panel: false, control: "never" },
|
|
486
|
+
"POST /s2s/contacts/{id}/accept": { panel: false, control: "never" },
|
|
487
|
+
"POST /s2s/contacts/{id}/block": { panel: false, control: "never" },
|
|
488
|
+
"POST /s2s/contacts/{id}/trust-key": { floor: "viewer", panel: false, control: "never" },
|
|
489
|
+
// The tasks contacts handed this sandbox (cut to the contacts the reader may use), and the owner's or a maintainer's
|
|
490
|
+
// Allow or Decline for one that waits on them: what a link's task waiting on Access ▸ Programs was.
|
|
491
|
+
"GET /s2s/tasks": { control: "never" },
|
|
492
|
+
"POST /s2s/contacts/{id}/tasks/{request}": { panel: false, control: "never" },
|
|
493
|
+
// A task this sandbox handed a contact, its live status asked of that contact (`task.watch`), for whoever may use the
|
|
494
|
+
// contact (the handler holds a person to their own, as the contacts' list does).
|
|
495
|
+
"GET /s2s/contacts/{id}/tasks/{request}/watch": { floor: "viewer", control: "never" },
|
|
496
|
+
"GET /s2s/outbox": { floor: "viewer", agent: true, control: "never" },
|
|
497
|
+
// A signed-in person's side: pairing with a sandbox they are also in, and the inbox, each thread shown to the people it
|
|
498
|
+
// is for and to maintainers (the handler cuts the list); the `messages` command reads and sends with its turn proof.
|
|
499
|
+
// Taking files writes into the workspace, so it is the collaborator's.
|
|
500
|
+
"POST /s2s/pairings": { floor: "viewer", panel: false, control: "never" },
|
|
501
|
+
"GET /s2s/threads": { floor: "viewer", agent: true, control: "never" },
|
|
502
|
+
"GET /s2s/threads/{id}": { floor: "viewer", agent: true, control: "never" },
|
|
503
|
+
"DELETE /s2s/threads/{id}": { floor: "viewer", control: "never" },
|
|
504
|
+
"POST /s2s/threads/{id}/read": { floor: "viewer", control: "never" },
|
|
505
|
+
"POST /s2s/messages": { floor: "viewer", agent: true, control: "never" },
|
|
506
|
+
"GET /s2s/messages/{id}/files/{name}": { floor: "viewer", agent: true, control: "never", lane: "bulk" },
|
|
507
|
+
"POST /s2s/messages/{id}/take": { floor: "collaborator", agent: true, control: "never" },
|
|
404
508
|
"POST /system/control/tokens": { panel: false, control: "never" },
|
|
405
509
|
"GET /system/control/tokens": { floor: "maintainer", panel: false, control: "never" },
|
|
406
510
|
"DELETE /system/control/tokens/{id}": { panel: false, control: "never" },
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type { SandboxIdentity } from "../../schemas/s2s-identity.js";
|
|
2
|
+
import {
|
|
3
|
+
type AddressIo,
|
|
4
|
+
type FetchedIdentity,
|
|
5
|
+
formatTxtRecord,
|
|
6
|
+
normalizeAddress,
|
|
7
|
+
normalizeDomain,
|
|
8
|
+
parseTxtRecord,
|
|
9
|
+
resolveAddress,
|
|
10
|
+
type TxtAnswer,
|
|
11
|
+
txtLookupOf,
|
|
12
|
+
txtRecordName,
|
|
13
|
+
} from "./address.js";
|
|
14
|
+
import { signIdentity } from "./identity-doc.js";
|
|
15
|
+
import { keySetFor } from "./s2s.testing.js";
|
|
16
|
+
|
|
17
|
+
const NOW = 1_800_000_000_000;
|
|
18
|
+
const HOST = `0123456789ab.sandbox.example`;
|
|
19
|
+
const DOMAIN = `ops.acme.example`;
|
|
20
|
+
const keys = keySetFor(`ops`);
|
|
21
|
+
const other = keySetFor(`other`);
|
|
22
|
+
const FP = keys.fingerprint;
|
|
23
|
+
const document = signIdentity({ sandbox: `0123456789ab`, name: `ops`, host: HOST, domains: [DOMAIN], issuedAt: NOW }, keys);
|
|
24
|
+
|
|
25
|
+
// One fake per seam: the DNS answers and the identities served, by name and host; anything else is missing or down.
|
|
26
|
+
const io = (txt: Readonly<Record<string, TxtAnswer>>, served: Readonly<Record<string, FetchedIdentity>>): AddressIo & { readonly asked: string[] } => {
|
|
27
|
+
const asked: string[] = [];
|
|
28
|
+
return {
|
|
29
|
+
asked,
|
|
30
|
+
resolveTxt: async (name) => {
|
|
31
|
+
asked.push(`txt ${name}`);
|
|
32
|
+
return txt[name] ?? { kind: `missing` };
|
|
33
|
+
},
|
|
34
|
+
fetchIdentity: async (host) => {
|
|
35
|
+
asked.push(`get ${host}`);
|
|
36
|
+
return served[host] ?? { ok: false, error: `connection refused` };
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const serving = (doc: SandboxIdentity): FetchedIdentity => ({ ok: true, body: JSON.parse(JSON.stringify(doc)) });
|
|
41
|
+
const record = (value: string): TxtAnswer => ({ kind: `records`, records: [[value]] });
|
|
42
|
+
|
|
43
|
+
describe("an address", () => {
|
|
44
|
+
it("is normalized to lowercase punycode with no scheme, path, trailing dot or default port", () => {
|
|
45
|
+
expect(normalizeAddress(` HTTPS://Ops.Acme.Example./s2s/identity `)).toBe(`ops.acme.example`);
|
|
46
|
+
expect(normalizeAddress(`bücher.example`)).toBe(`xn--bcher-kva.example`);
|
|
47
|
+
expect(normalizeAddress(`ops.acme.example:443`)).toBe(`ops.acme.example`);
|
|
48
|
+
expect(normalizeAddress(`localhost:8443`)).toBe(`localhost:8443`);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("is refused when it is no host", () => {
|
|
52
|
+
for (const raw of [``, `ops`, `ada@ops.example`, `-bad.example`, `under_score.example`, `ops..example`, `http://`]) {
|
|
53
|
+
expect(normalizeAddress(raw)).toBeUndefined();
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("is a domain only without a port and not localhost", () => {
|
|
58
|
+
expect(normalizeDomain(`Ops.Acme.Example`)).toBe(`ops.acme.example`);
|
|
59
|
+
expect(normalizeDomain(`ops.acme.example:8443`)).toBeUndefined();
|
|
60
|
+
expect(normalizeDomain(`localhost`)).toBeUndefined();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe("a TXT record", () => {
|
|
65
|
+
it("is published under _intentic and reads back as it was written", () => {
|
|
66
|
+
expect(txtRecordName(DOMAIN)).toBe(`_intentic.ops.acme.example`);
|
|
67
|
+
const value = formatTxtRecord({ fingerprint: FP, host: HOST });
|
|
68
|
+
expect(value).toBe(`v=isk1 fp=${FP} host=${HOST}`);
|
|
69
|
+
expect(parseTxtRecord(value)).toEqual({ fingerprint: FP, host: HOST });
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("reads in any order, with any whitespace and case in keys and the fingerprint, skipping words it does not know", () => {
|
|
73
|
+
expect(parseTxtRecord(` HOST=${HOST.toUpperCase()}\tnote=hi FP=${FP.toUpperCase()} V=isk1 `)).toEqual({ fingerprint: FP, host: HOST });
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("does not read without its version, fingerprint or host, with one twice, or with a word that is no pair", () => {
|
|
77
|
+
for (const value of [
|
|
78
|
+
`fp=${FP} host=${HOST}`,
|
|
79
|
+
`v=isk2 fp=${FP} host=${HOST}`,
|
|
80
|
+
`v=isk1 host=${HOST}`,
|
|
81
|
+
`v=isk1 fp=${FP}`,
|
|
82
|
+
`v=isk1 fp=isk1:short host=${HOST}`,
|
|
83
|
+
`v=isk1 fp=${FP} host=not_a_host`,
|
|
84
|
+
`v=isk1 fp=${FP} fp=${other.fingerprint} host=${HOST}`,
|
|
85
|
+
`v=isk1 fp=${FP} host=${HOST} stray`,
|
|
86
|
+
`v=isk1 =x fp=${FP} host=${HOST}`,
|
|
87
|
+
]) {
|
|
88
|
+
expect(parseTxtRecord(value)).toBeUndefined();
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("is looked up from DNS chunks: joined, others' records ignored, agreeing copies one, disagreeing ones a conflict", () => {
|
|
93
|
+
const value = formatTxtRecord({ fingerprint: FP, host: HOST });
|
|
94
|
+
expect(txtLookupOf([[`v=spf1 -all`], [value.slice(0, 20), value.slice(20)]])).toEqual({ kind: `record`, record: { fingerprint: FP, host: HOST } });
|
|
95
|
+
expect(txtLookupOf([[`v=spf1 -all`]])).toEqual({ kind: `none` });
|
|
96
|
+
expect(txtLookupOf([[value], [value]])).toEqual({ kind: `record`, record: { fingerprint: FP, host: HOST } });
|
|
97
|
+
expect(txtLookupOf([[value], [formatTxtRecord({ fingerprint: other.fingerprint, host: HOST })]])).toEqual({ kind: `conflict` });
|
|
98
|
+
expect(txtLookupOf([[value], [`v=isk1 fp=broken`]])).toEqual({ kind: `invalid` });
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe("resolving an address", () => {
|
|
103
|
+
it("takes a host with no record as itself, and checks the document it serves", async () => {
|
|
104
|
+
const fake = io({}, { [HOST]: serving(document) });
|
|
105
|
+
expect(await resolveAddress(HOST, fake)).toEqual({ ok: true, address: HOST, host: HOST, document, txt: undefined });
|
|
106
|
+
expect(fake.asked).toEqual([`txt _intentic.${HOST}`, `get ${HOST}`]);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("follows a domain's record to its host, and checks the key and that the document lists the domain", async () => {
|
|
110
|
+
const fake = io({ [`_intentic.${DOMAIN}`]: record(formatTxtRecord({ fingerprint: FP, host: HOST })) }, { [HOST]: serving(document) });
|
|
111
|
+
expect(await resolveAddress(`https://${DOMAIN.toUpperCase()}`, fake)).toEqual({ ok: true, address: DOMAIN, host: HOST, document, txt: { fingerprint: FP, host: HOST } });
|
|
112
|
+
expect(fake.asked).toEqual([`txt _intentic.${DOMAIN}`, `get ${HOST}`]);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("looks up no record for a host with a port", async () => {
|
|
116
|
+
const fake = io({}, { "localhost:8443": serving(signIdentity({ sandbox: `l`, name: `l`, host: `localhost:8443`, domains: [], issuedAt: NOW }, keys)) });
|
|
117
|
+
expect((await resolveAddress(`localhost:8443`, fake)).ok).toBe(true);
|
|
118
|
+
expect(fake.asked).toEqual([`get localhost:8443`]);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("refuses a record naming another key than the one served", async () => {
|
|
122
|
+
const fake = io({ [`_intentic.${DOMAIN}`]: record(formatTxtRecord({ fingerprint: other.fingerprint, host: HOST })) }, { [HOST]: serving(document) });
|
|
123
|
+
expect(await resolveAddress(DOMAIN, fake)).toMatchObject({ ok: false, code: `fingerprint` });
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("refuses a domain the document does not list, and a document of another host", async () => {
|
|
127
|
+
const unlisted = signIdentity({ sandbox: `0123456789ab`, name: `ops`, host: HOST, domains: [], issuedAt: NOW }, keys);
|
|
128
|
+
const fake = io({ [`_intentic.${DOMAIN}`]: record(formatTxtRecord({ fingerprint: FP, host: HOST })) }, { [HOST]: serving(unlisted) });
|
|
129
|
+
expect(await resolveAddress(DOMAIN, fake)).toMatchObject({ ok: false, code: `domain` });
|
|
130
|
+
expect(await resolveAddress(`elsewhere.example`, io({}, { "elsewhere.example": serving(document) }))).toMatchObject({ ok: false, code: `host` });
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("refuses a document that does not verify, or is none at all", async () => {
|
|
134
|
+
expect(await resolveAddress(HOST, io({}, { [HOST]: serving({ ...document, name: `forged` }) }))).toMatchObject({ ok: false, code: `signature` });
|
|
135
|
+
expect(await resolveAddress(HOST, io({}, { [HOST]: { ok: true, body: { hello: `world` } } }))).toMatchObject({ ok: false, code: `malformed` });
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it("tells a daemon from before (401) from one that does not answer", async () => {
|
|
139
|
+
expect(await resolveAddress(HOST, io({}, { [HOST]: { ok: false, status: 401, error: `unauthorized` } }))).toMatchObject({ ok: false, code: `too_old` });
|
|
140
|
+
expect(await resolveAddress(HOST, io({}, {}))).toEqual({ ok: false, code: `unreachable`, message: `${HOST} did not answer: connection refused` });
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it("refuses when the lookup fails, or the record is broken or contradicts itself", async () => {
|
|
144
|
+
expect(await resolveAddress(DOMAIN, io({ [`_intentic.${DOMAIN}`]: { kind: `failed`, error: `SERVFAIL` } }, {}))).toEqual({
|
|
145
|
+
ok: false,
|
|
146
|
+
code: `dns`,
|
|
147
|
+
message: `looking up _intentic.${DOMAIN} failed: SERVFAIL`,
|
|
148
|
+
});
|
|
149
|
+
expect(await resolveAddress(DOMAIN, io({ [`_intentic.${DOMAIN}`]: record(`v=isk1 fp=nope`) }, {}))).toMatchObject({ ok: false, code: `txt` });
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it("refuses what is no address before asking anything", async () => {
|
|
153
|
+
const fake = io({}, {});
|
|
154
|
+
expect(await resolveAddress(`not an address`, fake)).toMatchObject({ ok: false, code: `invalid_address` });
|
|
155
|
+
expect(fake.asked).toEqual([]);
|
|
156
|
+
});
|
|
157
|
+
});
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import type { JsonValue } from "@intentic/base/json";
|
|
2
|
+
import {
|
|
3
|
+
S2S_TXT_LABEL,
|
|
4
|
+
S2sAddressSchema,
|
|
5
|
+
S2sDomainSchema,
|
|
6
|
+
S2sFingerprintSchema,
|
|
7
|
+
type S2sTxtRecord,
|
|
8
|
+
type SandboxIdentity,
|
|
9
|
+
SandboxIdentitySchema,
|
|
10
|
+
} from "../../schemas/s2s-identity.js";
|
|
11
|
+
import { speaksS2s, verifyIdentity } from "./identity-doc.js";
|
|
12
|
+
|
|
13
|
+
// ADDRESSES (docs/architecture/messages.md, "Addresses"): a contact is addressed by its sandbox host or by an own domain
|
|
14
|
+
// whose TXT record, `_intentic.<domain>` = `v=isk1 fp=<fingerprint> host=<host>`, says which key speaks for it and
|
|
15
|
+
// where. Resolving one takes its I/O as arguments (a DNS lookup, an HTTPS fetch), so every path is testable.
|
|
16
|
+
|
|
17
|
+
// The TXT record's version word.
|
|
18
|
+
const TXT_VERSION = "isk1";
|
|
19
|
+
|
|
20
|
+
// An address as a person or a document wrote it, in the one spelling this protocol compares: lowercase, punycode, no
|
|
21
|
+
// scheme, path, credentials or trailing dot, and no port 443. Undefined for anything that is no host.
|
|
22
|
+
export const normalizeAddress = (raw: string): string | undefined => {
|
|
23
|
+
const text = raw.trim().replace(/^https?:\/\//iu, "").split("/")[0] ?? "";
|
|
24
|
+
if (text === "" || text.includes("@")) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
let host: string;
|
|
28
|
+
try {
|
|
29
|
+
const url = new URL(`https://${text}`);
|
|
30
|
+
host = `${url.hostname.replace(/\.$/u, "")}${url.port === "" ? "" : `:${url.port}`}`;
|
|
31
|
+
} catch {
|
|
32
|
+
// allow(silent-catch): the URL parser refusing it is the answer: it is no host.
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
return S2sAddressSchema.safeParse(host).success ? host : undefined;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// An own domain: an address with no port that is not localhost.
|
|
39
|
+
export const normalizeDomain = (raw: string): string | undefined => {
|
|
40
|
+
const address = normalizeAddress(raw);
|
|
41
|
+
return address !== undefined && S2sDomainSchema.safeParse(address).success ? address : undefined;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// Where a domain's record is published.
|
|
45
|
+
export const txtRecordName = (domain: string): string => `${S2S_TXT_LABEL}.${domain}`;
|
|
46
|
+
|
|
47
|
+
// The record's value, as the Identity section shows it to publish.
|
|
48
|
+
export const formatTxtRecord = ({ fingerprint, host }: S2sTxtRecord): string => `v=${TXT_VERSION} fp=${fingerprint} host=${host}`;
|
|
49
|
+
|
|
50
|
+
// One record's value, or undefined when it is not one of ours or does not read: `key=value` words in any order,
|
|
51
|
+
// separated by whitespace, `v=isk1` among them, a fingerprint and a host. A word this build does not know is skipped,
|
|
52
|
+
// for a later version's sake; a word twice, or one without `=`, spoils the record.
|
|
53
|
+
export const parseTxtRecord = (text: string): S2sTxtRecord | undefined => {
|
|
54
|
+
const fields = new Map<string, string>();
|
|
55
|
+
for (const word of text.trim().split(/\s+/u)) {
|
|
56
|
+
const at = word.indexOf("=");
|
|
57
|
+
if (at <= 0 || fields.has(word.slice(0, at).toLowerCase())) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
fields.set(word.slice(0, at).toLowerCase(), word.slice(at + 1));
|
|
61
|
+
}
|
|
62
|
+
if (fields.get("v") !== TXT_VERSION) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
const fingerprint = fields.get("fp")?.toLowerCase();
|
|
66
|
+
const host = normalizeAddress(fields.get("host") ?? "");
|
|
67
|
+
return fingerprint !== undefined && S2sFingerprintSchema.safeParse(fingerprint).success && host !== undefined ? { fingerprint, host } : undefined;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const isOurs = (text: string): boolean => /(?:^|\s)v=isk1(?:\s|$)/iu.test(text.trim());
|
|
71
|
+
|
|
72
|
+
// What a domain's TXT records say. `none`: no record of ours. `record`: one, or several that agree. `invalid`: one of ours
|
|
73
|
+
// does not read. `conflict`: ours name two different keys or hosts. Each record arrives as DNS chunks, joined first.
|
|
74
|
+
export type TxtLookup =
|
|
75
|
+
| { readonly kind: "none" }
|
|
76
|
+
| { readonly kind: "record"; readonly record: S2sTxtRecord }
|
|
77
|
+
| { readonly kind: "invalid" | "conflict" };
|
|
78
|
+
|
|
79
|
+
export const txtLookupOf = (records: readonly (readonly string[])[]): TxtLookup => {
|
|
80
|
+
const ours = records.map((chunks) => chunks.join("")).filter(isOurs);
|
|
81
|
+
if (ours.length === 0) {
|
|
82
|
+
return { kind: "none" };
|
|
83
|
+
}
|
|
84
|
+
const parsed = ours.map(parseTxtRecord);
|
|
85
|
+
const [first] = parsed;
|
|
86
|
+
if (first === undefined || parsed.some((record) => record === undefined)) {
|
|
87
|
+
return { kind: "invalid" };
|
|
88
|
+
}
|
|
89
|
+
return parsed.every((record) => record?.fingerprint === first.fingerprint && record.host === first.host) ? { kind: "record", record: first } : { kind: "conflict" };
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// The DNS error codes that mean the name has no record, not that the lookup failed (node:dns resolveTxt).
|
|
93
|
+
export const TXT_MISSING_CODES: readonly string[] = ["ENOTFOUND", "ENODATA"];
|
|
94
|
+
|
|
95
|
+
// The lookup, as the caller's resolver answered it: the records, none at all, or a failure in words.
|
|
96
|
+
export type TxtAnswer =
|
|
97
|
+
| { readonly kind: "records"; readonly records: readonly (readonly string[])[] }
|
|
98
|
+
| { readonly kind: "missing" }
|
|
99
|
+
| { readonly kind: "failed"; readonly error: string };
|
|
100
|
+
|
|
101
|
+
// GET https://<host>/s2s/identity, as the caller fetched it: the JSON it answered, or the status and why not.
|
|
102
|
+
export type FetchedIdentity =
|
|
103
|
+
| { readonly ok: true; readonly body: JsonValue }
|
|
104
|
+
| { readonly ok: false; readonly status?: number | undefined; readonly error: string };
|
|
105
|
+
|
|
106
|
+
export interface AddressIo {
|
|
107
|
+
readonly resolveTxt: (name: string) => Promise<TxtAnswer>;
|
|
108
|
+
readonly fetchIdentity: (host: string) => Promise<FetchedIdentity>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Why an address did not resolve. invalid_address: no host. dns: the lookup failed. txt: its record does not read or
|
|
112
|
+
// names two keys. unreachable: the host did not answer. too_old: it answers but speaks no s2s/1 (401 is what a daemon
|
|
113
|
+
// from before answers this door). malformed: what it answered is no identity document. signature: the document does not
|
|
114
|
+
// verify. fingerprint: its key is not the one the record names. host: it is another host's document. domain: the
|
|
115
|
+
// document does not list the domain it was resolved for.
|
|
116
|
+
export const RESOLVE_REFUSALS = ["invalid_address", "dns", "txt", "unreachable", "too_old", "malformed", "signature", "fingerprint", "host", "domain"] as const;
|
|
117
|
+
export type ResolveRefusal = (typeof RESOLVE_REFUSALS)[number];
|
|
118
|
+
|
|
119
|
+
export type ResolvedAddress =
|
|
120
|
+
| {
|
|
121
|
+
readonly ok: true;
|
|
122
|
+
// The address as normalized: what a contact is filed under.
|
|
123
|
+
readonly address: string;
|
|
124
|
+
// Where /s2s/* answers for it.
|
|
125
|
+
readonly host: string;
|
|
126
|
+
readonly document: SandboxIdentity;
|
|
127
|
+
// The domain's record, when it had one.
|
|
128
|
+
readonly txt?: S2sTxtRecord | undefined;
|
|
129
|
+
}
|
|
130
|
+
| { readonly ok: false; readonly code: ResolveRefusal; readonly message: string };
|
|
131
|
+
|
|
132
|
+
const refused = (code: ResolveRefusal, message: string): ResolvedAddress => ({ ok: false, code, message });
|
|
133
|
+
|
|
134
|
+
// A host with a port, or localhost, can be no domain, so it has no record to look up.
|
|
135
|
+
const mayHaveRecord = (address: string): boolean => S2sDomainSchema.safeParse(address).success;
|
|
136
|
+
|
|
137
|
+
const recordFor = async (address: string, io: AddressIo): Promise<S2sTxtRecord | ResolvedAddress | undefined> => {
|
|
138
|
+
if (!mayHaveRecord(address)) {
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
const answer = await io.resolveTxt(txtRecordName(address));
|
|
142
|
+
if (answer.kind === "failed") {
|
|
143
|
+
return refused("dns", `looking up ${txtRecordName(address)} failed: ${answer.error}`);
|
|
144
|
+
}
|
|
145
|
+
const lookup = answer.kind === "missing" ? ({ kind: "none" } as const) : txtLookupOf(answer.records);
|
|
146
|
+
if (lookup.kind === "invalid" || lookup.kind === "conflict") {
|
|
147
|
+
return refused("txt", `${txtRecordName(address)} ${lookup.kind === "invalid" ? "holds a record that does not read" : "names two different keys"}`);
|
|
148
|
+
}
|
|
149
|
+
return lookup.kind === "record" ? lookup.record : undefined;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const documentProblem = (document: SandboxIdentity, address: string, host: string, txt: S2sTxtRecord | undefined): ResolvedAddress | undefined => {
|
|
153
|
+
const check = verifyIdentity(document);
|
|
154
|
+
if (!check.ok) {
|
|
155
|
+
return refused("signature", `${host} serves an identity that does not verify: ${check.reason}`);
|
|
156
|
+
}
|
|
157
|
+
if (!speaksS2s(document)) {
|
|
158
|
+
return refused("too_old", `${host} does not speak s2s/1`);
|
|
159
|
+
}
|
|
160
|
+
if (normalizeAddress(document.host) !== host) {
|
|
161
|
+
return refused("host", `${host} serves the identity of ${document.host}`);
|
|
162
|
+
}
|
|
163
|
+
if (txt !== undefined && document.fingerprint !== txt.fingerprint) {
|
|
164
|
+
return refused("fingerprint", `${host} serves key ${document.fingerprint}, not the ${txt.fingerprint} that ${txtRecordName(address)} names`);
|
|
165
|
+
}
|
|
166
|
+
if (address !== host && !document.domains.includes(address)) {
|
|
167
|
+
return refused("domain", `${host} does not list ${address} among its own domains`);
|
|
168
|
+
}
|
|
169
|
+
return undefined;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// Resolves an address to a verified identity: its record, when it has one, names the host and the key; without one the
|
|
173
|
+
// address is the host. The document must verify, be that host's, carry the record's key, and list the domain.
|
|
174
|
+
export const resolveAddress = async (raw: string, io: AddressIo): Promise<ResolvedAddress> => {
|
|
175
|
+
const address = normalizeAddress(raw);
|
|
176
|
+
if (address === undefined) {
|
|
177
|
+
return refused("invalid_address", `"${raw.slice(0, 80)}" is no sandbox host or domain`);
|
|
178
|
+
}
|
|
179
|
+
const record = await recordFor(address, io);
|
|
180
|
+
if (record !== undefined && "ok" in record) {
|
|
181
|
+
return record;
|
|
182
|
+
}
|
|
183
|
+
const host = record?.host ?? address;
|
|
184
|
+
const fetched = await io.fetchIdentity(host);
|
|
185
|
+
if (!fetched.ok) {
|
|
186
|
+
return fetched.status === 401 ? refused("too_old", `${host} answers no s2s/1: its daemon is from before it`) : refused("unreachable", `${host} did not answer: ${fetched.error}`);
|
|
187
|
+
}
|
|
188
|
+
const parsed = SandboxIdentitySchema.safeParse(fetched.body);
|
|
189
|
+
if (!parsed.success) {
|
|
190
|
+
return refused("malformed", `${host} answered something that is no identity document`);
|
|
191
|
+
}
|
|
192
|
+
return documentProblem(parsed.data, address, host, record) ?? { ok: true, address, host, document: parsed.data, txt: record };
|
|
193
|
+
};
|