@opendatalabs/personal-server-ts-core 0.0.1-canary.052d47e → 0.0.1-canary.05cdd81
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/dist/additions/budget.d.ts +34 -0
- package/dist/additions/budget.d.ts.map +1 -0
- package/dist/additions/budget.js +144 -0
- package/dist/additions/budget.js.map +1 -0
- package/dist/additions/durable.d.ts +94 -0
- package/dist/additions/durable.d.ts.map +1 -0
- package/dist/additions/durable.js +823 -0
- package/dist/additions/durable.js.map +1 -0
- package/dist/additions/first-added.d.ts +204 -0
- package/dist/additions/first-added.d.ts.map +1 -0
- package/dist/additions/first-added.js +598 -0
- package/dist/additions/first-added.js.map +1 -0
- package/dist/additions/index.d.ts +9 -0
- package/dist/additions/index.d.ts.map +1 -0
- package/dist/additions/index.js +9 -0
- package/dist/additions/index.js.map +1 -0
- package/dist/additions/ledger-store.d.ts +69 -0
- package/dist/additions/ledger-store.d.ts.map +1 -0
- package/dist/additions/ledger-store.js +407 -0
- package/dist/additions/ledger-store.js.map +1 -0
- package/dist/additions/record-rules.d.ts +54 -0
- package/dist/additions/record-rules.d.ts.map +1 -0
- package/dist/additions/record-rules.js +198 -0
- package/dist/additions/record-rules.js.map +1 -0
- package/dist/additions/scope-lock.d.ts +14 -0
- package/dist/additions/scope-lock.d.ts.map +1 -0
- package/dist/additions/scope-lock.js +32 -0
- package/dist/additions/scope-lock.js.map +1 -0
- package/dist/additions/summary.d.ts +143 -0
- package/dist/additions/summary.d.ts.map +1 -0
- package/dist/additions/summary.js +279 -0
- package/dist/additions/summary.js.map +1 -0
- package/dist/additions/version-inventory.d.ts +86 -0
- package/dist/additions/version-inventory.d.ts.map +1 -0
- package/dist/additions/version-inventory.js +244 -0
- package/dist/additions/version-inventory.js.map +1 -0
- package/dist/api/account-storage-mode.d.ts +77 -0
- package/dist/api/account-storage-mode.d.ts.map +1 -0
- package/dist/api/account-storage-mode.js +72 -0
- package/dist/api/account-storage-mode.js.map +1 -0
- package/dist/api/index.d.ts +320 -10
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1758 -181
- package/dist/api/index.js.map +1 -1
- package/dist/api/legacy-write-gate.d.ts +51 -0
- package/dist/api/legacy-write-gate.d.ts.map +1 -0
- package/dist/api/legacy-write-gate.js +88 -0
- package/dist/api/legacy-write-gate.js.map +1 -0
- package/dist/api/oura-collection-requirements.d.ts +16 -0
- package/dist/api/oura-collection-requirements.d.ts.map +1 -0
- package/dist/api/oura-collection-requirements.js +70 -0
- package/dist/api/oura-collection-requirements.js.map +1 -0
- package/dist/api/owner-connector-delete.d.ts +79 -0
- package/dist/api/owner-connector-delete.d.ts.map +1 -0
- package/dist/api/owner-connector-delete.js +109 -0
- package/dist/api/owner-connector-delete.js.map +1 -0
- package/dist/api/raw-envelope.d.ts +3 -0
- package/dist/api/raw-envelope.d.ts.map +1 -0
- package/dist/api/raw-envelope.js +215 -0
- package/dist/api/raw-envelope.js.map +1 -0
- package/dist/api/scope-upload-batches.d.ts +18 -0
- package/dist/api/scope-upload-batches.d.ts.map +1 -0
- package/dist/api/scope-upload-batches.js +71 -0
- package/dist/api/scope-upload-batches.js.map +1 -0
- package/dist/api/scope-uploads.d.ts +112 -0
- package/dist/api/scope-uploads.d.ts.map +1 -0
- package/dist/api/scope-uploads.js +369 -0
- package/dist/api/scope-uploads.js.map +1 -0
- package/dist/api/switched-delete-refusal.d.ts +16 -0
- package/dist/api/switched-delete-refusal.d.ts.map +1 -0
- package/dist/api/switched-delete-refusal.js +30 -0
- package/dist/api/switched-delete-refusal.js.map +1 -0
- package/dist/auth/index.d.ts +3 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +3 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/proof-id.d.ts +8 -0
- package/dist/auth/proof-id.d.ts.map +1 -0
- package/dist/auth/proof-id.js +29 -0
- package/dist/auth/proof-id.js.map +1 -0
- package/dist/auth/request.d.ts +24 -0
- package/dist/auth/request.d.ts.map +1 -1
- package/dist/auth/request.js +99 -4
- package/dist/auth/request.js.map +1 -1
- package/dist/client.d.ts +78 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -0
- package/dist/client.js.map +1 -1
- package/dist/contracts/auth-device.d.ts +10 -0
- package/dist/contracts/auth-device.d.ts.map +1 -1
- package/dist/contracts/auth-device.js +2 -0
- package/dist/contracts/auth-device.js.map +1 -1
- package/dist/contracts/data.d.ts +102 -8
- package/dist/contracts/data.d.ts.map +1 -1
- package/dist/contracts/data.js +326 -47
- package/dist/contracts/data.js.map +1 -1
- package/dist/contracts/grants.d.ts.map +1 -1
- package/dist/contracts/grants.js +7 -0
- package/dist/contracts/grants.js.map +1 -1
- package/dist/contracts/index.d.ts +4 -2
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +3 -1
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/oura-collection-requirements.d.ts +17 -0
- package/dist/contracts/oura-collection-requirements.d.ts.map +1 -0
- package/dist/contracts/oura-collection-requirements.js +49 -0
- package/dist/contracts/oura-collection-requirements.js.map +1 -0
- package/dist/contracts/sync.d.ts +9 -1
- package/dist/contracts/sync.d.ts.map +1 -1
- package/dist/contracts/sync.js +7 -2
- package/dist/contracts/sync.js.map +1 -1
- package/dist/derivatives/answer-shape.d.ts +83 -0
- package/dist/derivatives/answer-shape.d.ts.map +1 -0
- package/dist/derivatives/answer-shape.js +320 -0
- package/dist/derivatives/answer-shape.js.map +1 -0
- package/dist/derivatives/api.d.ts +1 -1
- package/dist/derivatives/api.d.ts.map +1 -1
- package/dist/derivatives/api.js +8 -0
- package/dist/derivatives/api.js.map +1 -1
- package/dist/derivatives/compute.d.ts +9 -3
- package/dist/derivatives/compute.d.ts.map +1 -1
- package/dist/derivatives/compute.js +87 -6
- package/dist/derivatives/compute.js.map +1 -1
- package/dist/derivatives/index.d.ts +2 -1
- package/dist/derivatives/index.d.ts.map +1 -1
- package/dist/derivatives/index.js +2 -1
- package/dist/derivatives/index.js.map +1 -1
- package/dist/derivatives/prompt.d.ts +35 -0
- package/dist/derivatives/prompt.d.ts.map +1 -1
- package/dist/derivatives/prompt.js +96 -8
- package/dist/derivatives/prompt.js.map +1 -1
- package/dist/derivatives/registration.d.ts +6 -9
- package/dist/derivatives/registration.d.ts.map +1 -1
- package/dist/derivatives/registration.js +14 -6
- package/dist/derivatives/registration.js.map +1 -1
- package/dist/derivatives/scheduler.d.ts +39 -9
- package/dist/derivatives/scheduler.d.ts.map +1 -1
- package/dist/derivatives/scheduler.js +99 -8
- package/dist/derivatives/scheduler.js.map +1 -1
- package/dist/derivatives/store.d.ts.map +1 -1
- package/dist/derivatives/store.js +2 -0
- package/dist/derivatives/store.js.map +1 -1
- package/dist/derivatives/types.d.ts +13 -3
- package/dist/derivatives/types.d.ts.map +1 -1
- package/dist/derivatives/types.js +2 -0
- package/dist/derivatives/types.js.map +1 -1
- package/dist/errors/pdpp-catalog.d.ts +36 -0
- package/dist/errors/pdpp-catalog.d.ts.map +1 -0
- package/dist/errors/pdpp-catalog.js +92 -0
- package/dist/errors/pdpp-catalog.js.map +1 -0
- package/dist/grants/index.d.ts +2 -0
- package/dist/grants/index.d.ts.map +1 -1
- package/dist/grants/index.js +4 -0
- package/dist/grants/index.js.map +1 -1
- package/dist/grants/pdpp-binding-store.d.ts +89 -0
- package/dist/grants/pdpp-binding-store.d.ts.map +1 -0
- package/dist/grants/pdpp-binding-store.js +112 -0
- package/dist/grants/pdpp-binding-store.js.map +1 -0
- package/dist/grants/pdpp-binding.d.ts +169 -0
- package/dist/grants/pdpp-binding.d.ts.map +1 -0
- package/dist/grants/pdpp-binding.js +236 -0
- package/dist/grants/pdpp-binding.js.map +1 -0
- package/dist/keys/index.d.ts +1 -0
- package/dist/keys/index.d.ts.map +1 -1
- package/dist/keys/index.js +1 -0
- package/dist/keys/index.js.map +1 -1
- package/dist/keys/owner-master-key.d.ts +37 -0
- package/dist/keys/owner-master-key.d.ts.map +1 -0
- package/dist/keys/owner-master-key.js +45 -0
- package/dist/keys/owner-master-key.js.map +1 -0
- package/dist/legacy-projection/bindings.d.ts +31 -0
- package/dist/legacy-projection/bindings.d.ts.map +1 -0
- package/dist/legacy-projection/bindings.js +4512 -0
- package/dist/legacy-projection/bindings.js.map +1 -0
- package/dist/legacy-projection/claude-source-record.d.ts +22 -0
- package/dist/legacy-projection/claude-source-record.d.ts.map +1 -0
- package/dist/legacy-projection/claude-source-record.js +360 -0
- package/dist/legacy-projection/claude-source-record.js.map +1 -0
- package/dist/legacy-projection/declared-text.d.ts +41 -0
- package/dist/legacy-projection/declared-text.d.ts.map +1 -0
- package/dist/legacy-projection/declared-text.js +199 -0
- package/dist/legacy-projection/declared-text.js.map +1 -0
- package/dist/legacy-projection/erase-connector.d.ts +18 -0
- package/dist/legacy-projection/erase-connector.d.ts.map +1 -0
- package/dist/legacy-projection/erase-connector.js +29 -0
- package/dist/legacy-projection/erase-connector.js.map +1 -0
- package/dist/legacy-projection/github-browser-bindings.d.ts +3 -0
- package/dist/legacy-projection/github-browser-bindings.d.ts.map +1 -0
- package/dist/legacy-projection/github-browser-bindings.js +212 -0
- package/dist/legacy-projection/github-browser-bindings.js.map +1 -0
- package/dist/legacy-projection/github-legacy-fields.d.ts +6 -0
- package/dist/legacy-projection/github-legacy-fields.d.ts.map +1 -0
- package/dist/legacy-projection/github-legacy-fields.js +202 -0
- package/dist/legacy-projection/github-legacy-fields.js.map +1 -0
- package/dist/legacy-projection/index.d.ts +48 -0
- package/dist/legacy-projection/index.d.ts.map +1 -0
- package/dist/legacy-projection/index.js +255 -0
- package/dist/legacy-projection/index.js.map +1 -0
- package/dist/legacy-projection/meta-040-bindings.d.ts +3 -0
- package/dist/legacy-projection/meta-040-bindings.d.ts.map +1 -0
- package/dist/legacy-projection/meta-040-bindings.js +112 -0
- package/dist/legacy-projection/meta-040-bindings.js.map +1 -0
- package/dist/legacy-projection/oura-browser-bindings.d.ts +5 -0
- package/dist/legacy-projection/oura-browser-bindings.d.ts.map +1 -0
- package/dist/legacy-projection/oura-browser-bindings.js +141 -0
- package/dist/legacy-projection/oura-browser-bindings.js.map +1 -0
- package/dist/legacy-projection/provenance.d.ts +57 -0
- package/dist/legacy-projection/provenance.d.ts.map +1 -0
- package/dist/legacy-projection/provenance.js +2 -0
- package/dist/legacy-projection/provenance.js.map +1 -0
- package/dist/legacy-projection/strava-browser-bindings.d.ts +3 -0
- package/dist/legacy-projection/strava-browser-bindings.d.ts.map +1 -0
- package/dist/legacy-projection/strava-browser-bindings.js +32 -0
- package/dist/legacy-projection/strava-browser-bindings.js.map +1 -0
- package/dist/legacy-projection/test-debris.d.ts +2 -0
- package/dist/legacy-projection/test-debris.d.ts.map +1 -0
- package/dist/legacy-projection/test-debris.js +49 -0
- package/dist/legacy-projection/test-debris.js.map +1 -0
- package/dist/legacy-projection/types.d.ts +235 -0
- package/dist/legacy-projection/types.d.ts.map +1 -0
- package/dist/legacy-projection/types.js +2 -0
- package/dist/legacy-projection/types.js.map +1 -0
- package/dist/lineage/gateway.d.ts +3 -1
- package/dist/lineage/gateway.d.ts.map +1 -1
- package/dist/lineage/gateway.js +2 -1
- package/dist/lineage/gateway.js.map +1 -1
- package/dist/localdb/apply.d.ts +13 -0
- package/dist/localdb/apply.d.ts.map +1 -0
- package/dist/localdb/apply.js +565 -0
- package/dist/localdb/apply.js.map +1 -0
- package/dist/localdb/batch-commit.d.ts +67 -0
- package/dist/localdb/batch-commit.d.ts.map +1 -0
- package/dist/localdb/batch-commit.js +121 -0
- package/dist/localdb/batch-commit.js.map +1 -0
- package/dist/localdb/blobs.d.ts +71 -0
- package/dist/localdb/blobs.d.ts.map +1 -0
- package/dist/localdb/blobs.js +306 -0
- package/dist/localdb/blobs.js.map +1 -0
- package/dist/localdb/bootstrap.d.ts +20 -0
- package/dist/localdb/bootstrap.d.ts.map +1 -0
- package/dist/localdb/bootstrap.js +157 -0
- package/dist/localdb/bootstrap.js.map +1 -0
- package/dist/localdb/connection-link.d.ts +12 -0
- package/dist/localdb/connection-link.d.ts.map +1 -0
- package/dist/localdb/connection-link.js +72 -0
- package/dist/localdb/connection-link.js.map +1 -0
- package/dist/localdb/cycle.d.ts +32 -0
- package/dist/localdb/cycle.d.ts.map +1 -0
- package/dist/localdb/cycle.js +46 -0
- package/dist/localdb/cycle.js.map +1 -0
- package/dist/localdb/delete-batch.d.ts +51 -0
- package/dist/localdb/delete-batch.d.ts.map +1 -0
- package/dist/localdb/delete-batch.js +132 -0
- package/dist/localdb/delete-batch.js.map +1 -0
- package/dist/localdb/delete.d.ts +81 -0
- package/dist/localdb/delete.d.ts.map +1 -0
- package/dist/localdb/delete.js +736 -0
- package/dist/localdb/delete.js.map +1 -0
- package/dist/localdb/deps.d.ts +54 -0
- package/dist/localdb/deps.d.ts.map +1 -0
- package/dist/localdb/deps.js +10 -0
- package/dist/localdb/deps.js.map +1 -0
- package/dist/localdb/driver.d.ts +67 -0
- package/dist/localdb/driver.d.ts.map +1 -0
- package/dist/localdb/driver.js +3 -0
- package/dist/localdb/driver.js.map +1 -0
- package/dist/localdb/encode.d.ts +217 -0
- package/dist/localdb/encode.d.ts.map +1 -0
- package/dist/localdb/encode.js +502 -0
- package/dist/localdb/encode.js.map +1 -0
- package/dist/localdb/fence.d.ts +31 -0
- package/dist/localdb/fence.d.ts.map +1 -0
- package/dist/localdb/fence.js +69 -0
- package/dist/localdb/fence.js.map +1 -0
- package/dist/localdb/history.d.ts +74 -0
- package/dist/localdb/history.d.ts.map +1 -0
- package/dist/localdb/history.js +266 -0
- package/dist/localdb/history.js.map +1 -0
- package/dist/localdb/import-fingerprint.d.ts +8 -0
- package/dist/localdb/import-fingerprint.d.ts.map +1 -0
- package/dist/localdb/import-fingerprint.js +35 -0
- package/dist/localdb/import-fingerprint.js.map +1 -0
- package/dist/localdb/import-ledger.d.ts +27 -0
- package/dist/localdb/import-ledger.d.ts.map +1 -0
- package/dist/localdb/import-ledger.js +197 -0
- package/dist/localdb/import-ledger.js.map +1 -0
- package/dist/localdb/import-readback.d.ts +8 -0
- package/dist/localdb/import-readback.d.ts.map +1 -0
- package/dist/localdb/import-readback.js +69 -0
- package/dist/localdb/import-readback.js.map +1 -0
- package/dist/localdb/import-snapshot.d.ts +21 -0
- package/dist/localdb/import-snapshot.d.ts.map +1 -0
- package/dist/localdb/import-snapshot.js +94 -0
- package/dist/localdb/import-snapshot.js.map +1 -0
- package/dist/localdb/index.d.ts +39 -0
- package/dist/localdb/index.d.ts.map +1 -0
- package/dist/localdb/index.js +36 -0
- package/dist/localdb/index.js.map +1 -0
- package/dist/localdb/legacy-import-types.d.ts +110 -0
- package/dist/localdb/legacy-import-types.d.ts.map +1 -0
- package/dist/localdb/legacy-import-types.js +2 -0
- package/dist/localdb/legacy-import-types.js.map +1 -0
- package/dist/localdb/legacy-import.d.ts +36 -0
- package/dist/localdb/legacy-import.d.ts.map +1 -0
- package/dist/localdb/legacy-import.js +288 -0
- package/dist/localdb/legacy-import.js.map +1 -0
- package/dist/localdb/legacy-retire.d.ts +26 -0
- package/dist/localdb/legacy-retire.d.ts.map +1 -0
- package/dist/localdb/legacy-retire.js +93 -0
- package/dist/localdb/legacy-retire.js.map +1 -0
- package/dist/localdb/lifetime-boundary.d.ts +49 -0
- package/dist/localdb/lifetime-boundary.d.ts.map +1 -0
- package/dist/localdb/lifetime-boundary.js +74 -0
- package/dist/localdb/lifetime-boundary.js.map +1 -0
- package/dist/localdb/listing.d.ts +51 -0
- package/dist/localdb/listing.d.ts.map +1 -0
- package/dist/localdb/listing.js +231 -0
- package/dist/localdb/listing.js.map +1 -0
- package/dist/localdb/merge.d.ts +95 -0
- package/dist/localdb/merge.d.ts.map +1 -0
- package/dist/localdb/merge.js +282 -0
- package/dist/localdb/merge.js.map +1 -0
- package/dist/localdb/migrate.d.ts +10 -0
- package/dist/localdb/migrate.d.ts.map +1 -0
- package/dist/localdb/migrate.js +27 -0
- package/dist/localdb/migrate.js.map +1 -0
- package/dist/localdb/name.d.ts +3 -0
- package/dist/localdb/name.d.ts.map +1 -0
- package/dist/localdb/name.js +8 -0
- package/dist/localdb/name.js.map +1 -0
- package/dist/localdb/older-versions.d.ts +49 -0
- package/dist/localdb/older-versions.d.ts.map +1 -0
- package/dist/localdb/older-versions.js +172 -0
- package/dist/localdb/older-versions.js.map +1 -0
- package/dist/localdb/open.d.ts +19 -0
- package/dist/localdb/open.d.ts.map +1 -0
- package/dist/localdb/open.js +46 -0
- package/dist/localdb/open.js.map +1 -0
- package/dist/localdb/part-layout.d.ts +74 -0
- package/dist/localdb/part-layout.d.ts.map +1 -0
- package/dist/localdb/part-layout.js +203 -0
- package/dist/localdb/part-layout.js.map +1 -0
- package/dist/localdb/publish-meter.d.ts +45 -0
- package/dist/localdb/publish-meter.d.ts.map +1 -0
- package/dist/localdb/publish-meter.js +62 -0
- package/dist/localdb/publish-meter.js.map +1 -0
- package/dist/localdb/publish.d.ts +47 -0
- package/dist/localdb/publish.d.ts.map +1 -0
- package/dist/localdb/publish.js +2100 -0
- package/dist/localdb/publish.js.map +1 -0
- package/dist/localdb/purge.d.ts +23 -0
- package/dist/localdb/purge.d.ts.map +1 -0
- package/dist/localdb/purge.js +75 -0
- package/dist/localdb/purge.js.map +1 -0
- package/dist/localdb/query.d.ts +69 -0
- package/dist/localdb/query.d.ts.map +1 -0
- package/dist/localdb/query.js +306 -0
- package/dist/localdb/query.js.map +1 -0
- package/dist/localdb/queue.d.ts +10 -0
- package/dist/localdb/queue.d.ts.map +1 -0
- package/dist/localdb/queue.js +31 -0
- package/dist/localdb/queue.js.map +1 -0
- package/dist/localdb/read-selection.d.ts +103 -0
- package/dist/localdb/read-selection.d.ts.map +1 -0
- package/dist/localdb/read-selection.js +141 -0
- package/dist/localdb/read-selection.js.map +1 -0
- package/dist/localdb/registry-view.d.ts +65 -0
- package/dist/localdb/registry-view.d.ts.map +1 -0
- package/dist/localdb/registry-view.js +73 -0
- package/dist/localdb/registry-view.js.map +1 -0
- package/dist/localdb/replace.d.ts +33 -0
- package/dist/localdb/replace.d.ts.map +1 -0
- package/dist/localdb/replace.js +22 -0
- package/dist/localdb/replace.js.map +1 -0
- package/dist/localdb/requirements.d.ts +35 -0
- package/dist/localdb/requirements.d.ts.map +1 -0
- package/dist/localdb/requirements.js +66 -0
- package/dist/localdb/requirements.js.map +1 -0
- package/dist/localdb/resolve.d.ts +43 -0
- package/dist/localdb/resolve.d.ts.map +1 -0
- package/dist/localdb/resolve.js +265 -0
- package/dist/localdb/resolve.js.map +1 -0
- package/dist/localdb/run-end.d.ts +19 -0
- package/dist/localdb/run-end.d.ts.map +1 -0
- package/dist/localdb/run-end.js +283 -0
- package/dist/localdb/run-end.js.map +1 -0
- package/dist/localdb/run-intake.d.ts +16 -0
- package/dist/localdb/run-intake.d.ts.map +1 -0
- package/dist/localdb/run-intake.js +441 -0
- package/dist/localdb/run-intake.js.map +1 -0
- package/dist/localdb/run-receipts.d.ts +19 -0
- package/dist/localdb/run-receipts.d.ts.map +1 -0
- package/dist/localdb/run-receipts.js +151 -0
- package/dist/localdb/run-receipts.js.map +1 -0
- package/dist/localdb/schema.d.ts +7 -0
- package/dist/localdb/schema.d.ts.map +1 -0
- package/dist/localdb/schema.js +312 -0
- package/dist/localdb/schema.js.map +1 -0
- package/dist/localdb/seed.d.ts +39 -0
- package/dist/localdb/seed.d.ts.map +1 -0
- package/dist/localdb/seed.js +188 -0
- package/dist/localdb/seed.js.map +1 -0
- package/dist/localdb/slot.d.ts +9 -0
- package/dist/localdb/slot.d.ts.map +1 -0
- package/dist/localdb/slot.js +15 -0
- package/dist/localdb/slot.js.map +1 -0
- package/dist/localdb/sync.d.ts +53 -0
- package/dist/localdb/sync.d.ts.map +1 -0
- package/dist/localdb/sync.js +211 -0
- package/dist/localdb/sync.js.map +1 -0
- package/dist/localdb/transfer-memory.d.ts +17 -0
- package/dist/localdb/transfer-memory.d.ts.map +1 -0
- package/dist/localdb/transfer-memory.js +17 -0
- package/dist/localdb/transfer-memory.js.map +1 -0
- package/dist/localdb/unwrite.d.ts +22 -0
- package/dist/localdb/unwrite.d.ts.map +1 -0
- package/dist/localdb/unwrite.js +46 -0
- package/dist/localdb/unwrite.js.map +1 -0
- package/dist/localdb/upload-wave.d.ts +34 -0
- package/dist/localdb/upload-wave.d.ts.map +1 -0
- package/dist/localdb/upload-wave.js +30 -0
- package/dist/localdb/upload-wave.js.map +1 -0
- package/dist/localdb/verified-heads.d.ts +13 -0
- package/dist/localdb/verified-heads.d.ts.map +1 -0
- package/dist/localdb/verified-heads.js +56 -0
- package/dist/localdb/verified-heads.js.map +1 -0
- package/dist/localdb/view-changes.d.ts +58 -0
- package/dist/localdb/view-changes.d.ts.map +1 -0
- package/dist/localdb/view-changes.js +174 -0
- package/dist/localdb/view-changes.js.map +1 -0
- package/dist/mcp/approval-url.d.ts +100 -0
- package/dist/mcp/approval-url.d.ts.map +1 -0
- package/dist/mcp/approval-url.js +171 -0
- package/dist/mcp/approval-url.js.map +1 -0
- package/dist/mcp/connection-api.d.ts +239 -3
- package/dist/mcp/connection-api.d.ts.map +1 -1
- package/dist/mcp/connection-api.js +792 -27
- package/dist/mcp/connection-api.js.map +1 -1
- package/dist/mcp/grant-registration.d.ts +15 -0
- package/dist/mcp/grant-registration.d.ts.map +1 -0
- package/dist/mcp/grant-registration.js +44 -0
- package/dist/mcp/grant-registration.js.map +1 -0
- package/dist/mcp/grantee.d.ts +1 -1
- package/dist/mcp/grantee.d.ts.map +1 -1
- package/dist/mcp/index.d.ts +5 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +5 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/oauth-redirect.d.ts +14 -0
- package/dist/mcp/oauth-redirect.d.ts.map +1 -0
- package/dist/mcp/oauth-redirect.js +51 -0
- package/dist/mcp/oauth-redirect.js.map +1 -0
- package/dist/mcp/read-client.d.ts +27 -3
- package/dist/mcp/read-client.d.ts.map +1 -1
- package/dist/mcp/read-client.js +325 -19
- package/dist/mcp/read-client.js.map +1 -1
- package/dist/mcp/resources.d.ts +3 -1
- package/dist/mcp/resources.d.ts.map +1 -1
- package/dist/mcp/resources.js +14 -2
- package/dist/mcp/resources.js.map +1 -1
- package/dist/mcp/server.d.ts +47 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +219 -17
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/session.d.ts +3 -1
- package/dist/mcp/session.d.ts.map +1 -1
- package/dist/mcp/session.js +58 -11
- package/dist/mcp/session.js.map +1 -1
- package/dist/mcp/store.d.ts +23 -1
- package/dist/mcp/store.d.ts.map +1 -1
- package/dist/mcp/store.js +102 -1
- package/dist/mcp/store.js.map +1 -1
- package/dist/mcp/token-expiry.d.ts +48 -0
- package/dist/mcp/token-expiry.d.ts.map +1 -0
- package/dist/mcp/token-expiry.js +69 -0
- package/dist/mcp/token-expiry.js.map +1 -0
- package/dist/mcp/tools.d.ts +154 -3
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +660 -39
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/types.d.ts +105 -4
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/mcp/types.js +13 -1
- package/dist/mcp/types.js.map +1 -1
- package/dist/mcp/write-client.d.ts +81 -0
- package/dist/mcp/write-client.d.ts.map +1 -0
- package/dist/mcp/write-client.js +140 -0
- package/dist/mcp/write-client.js.map +1 -0
- package/dist/oura/history-policy.d.ts +12 -0
- package/dist/oura/history-policy.d.ts.map +1 -0
- package/dist/oura/history-policy.js +54 -0
- package/dist/oura/history-policy.js.map +1 -0
- package/dist/oura/index.d.ts +51 -0
- package/dist/oura/index.d.ts.map +1 -0
- package/dist/oura/index.js +330 -0
- package/dist/oura/index.js.map +1 -0
- package/dist/payment/own-app.d.ts +8 -0
- package/dist/payment/own-app.d.ts.map +1 -0
- package/dist/payment/own-app.js +47 -0
- package/dist/payment/own-app.js.map +1 -0
- package/dist/pdpp/approval.d.ts +271 -0
- package/dist/pdpp/approval.d.ts.map +1 -0
- package/dist/pdpp/approval.js +486 -0
- package/dist/pdpp/approval.js.map +1 -0
- package/dist/pdpp/client-identity.d.ts +88 -0
- package/dist/pdpp/client-identity.d.ts.map +1 -0
- package/dist/pdpp/client-identity.js +196 -0
- package/dist/pdpp/client-identity.js.map +1 -0
- package/dist/pdpp/client-metadata.d.ts +95 -0
- package/dist/pdpp/client-metadata.d.ts.map +1 -0
- package/dist/pdpp/client-metadata.js +96 -0
- package/dist/pdpp/client-metadata.js.map +1 -0
- package/dist/pdpp/commitments.d.ts +75 -0
- package/dist/pdpp/commitments.d.ts.map +1 -0
- package/dist/pdpp/commitments.js +113 -0
- package/dist/pdpp/commitments.js.map +1 -0
- package/dist/pdpp/declaration-limits.d.ts +7 -0
- package/dist/pdpp/declaration-limits.d.ts.map +1 -0
- package/dist/pdpp/declaration-limits.js +7 -0
- package/dist/pdpp/declaration-limits.js.map +1 -0
- package/dist/pdpp/declaration.d.ts +119 -0
- package/dist/pdpp/declaration.d.ts.map +1 -0
- package/dist/pdpp/declaration.js +837 -0
- package/dist/pdpp/declaration.js.map +1 -0
- package/dist/pdpp/index.d.ts +38 -0
- package/dist/pdpp/index.d.ts.map +1 -0
- package/dist/pdpp/index.js +24 -0
- package/dist/pdpp/index.js.map +1 -0
- package/dist/pdpp/issuance.d.ts +126 -0
- package/dist/pdpp/issuance.d.ts.map +1 -0
- package/dist/pdpp/issuance.js +184 -0
- package/dist/pdpp/issuance.js.map +1 -0
- package/dist/pdpp/pkce.d.ts +53 -0
- package/dist/pdpp/pkce.d.ts.map +1 -0
- package/dist/pdpp/pkce.js +109 -0
- package/dist/pdpp/pkce.js.map +1 -0
- package/dist/pdpp/redirect.d.ts +60 -0
- package/dist/pdpp/redirect.d.ts.map +1 -0
- package/dist/pdpp/redirect.js +125 -0
- package/dist/pdpp/redirect.js.map +1 -0
- package/dist/pdpp/resolve.d.ts +120 -0
- package/dist/pdpp/resolve.d.ts.map +1 -0
- package/dist/pdpp/resolve.js +491 -0
- package/dist/pdpp/resolve.js.map +1 -0
- package/dist/pdpp/review.d.ts +280 -0
- package/dist/pdpp/review.d.ts.map +1 -0
- package/dist/pdpp/review.js +205 -0
- package/dist/pdpp/review.js.map +1 -0
- package/dist/pdpp/selection.d.ts +79 -0
- package/dist/pdpp/selection.d.ts.map +1 -0
- package/dist/pdpp/selection.js +493 -0
- package/dist/pdpp/selection.js.map +1 -0
- package/dist/pdpp/store.d.ts +228 -0
- package/dist/pdpp/store.d.ts.map +1 -0
- package/dist/pdpp/store.js +542 -0
- package/dist/pdpp/store.js.map +1 -0
- package/dist/pdpp/time.d.ts +39 -0
- package/dist/pdpp/time.d.ts.map +1 -0
- package/dist/pdpp/time.js +173 -0
- package/dist/pdpp/time.js.map +1 -0
- package/dist/pdpp/tokens.d.ts +181 -0
- package/dist/pdpp/tokens.d.ts.map +1 -0
- package/dist/pdpp/tokens.js +421 -0
- package/dist/pdpp/tokens.js.map +1 -0
- package/dist/pdpp/types.d.ts +457 -0
- package/dist/pdpp/types.d.ts.map +1 -0
- package/dist/pdpp/types.js +68 -0
- package/dist/pdpp/types.js.map +1 -0
- package/dist/pdpp-version.d.ts +28 -0
- package/dist/pdpp-version.d.ts.map +1 -0
- package/dist/pdpp-version.js +28 -0
- package/dist/pdpp-version.js.map +1 -0
- package/dist/policy/data-read.d.ts +52 -1
- package/dist/policy/data-read.d.ts.map +1 -1
- package/dist/policy/data-read.js +157 -3
- package/dist/policy/data-read.js.map +1 -1
- package/dist/policy/data-write.d.ts.map +1 -1
- package/dist/policy/data-write.js +18 -1
- package/dist/policy/data-write.js.map +1 -1
- package/dist/policy/index.d.ts +2 -1
- package/dist/policy/index.d.ts.map +1 -1
- package/dist/policy/index.js +2 -1
- package/dist/policy/index.js.map +1 -1
- package/dist/policy/reserved-scopes.d.ts +10 -0
- package/dist/policy/reserved-scopes.d.ts.map +1 -0
- package/dist/policy/reserved-scopes.js +19 -0
- package/dist/policy/reserved-scopes.js.map +1 -0
- package/dist/ports/index.d.ts +323 -10
- package/dist/ports/index.d.ts.map +1 -1
- package/dist/ports/index.js.map +1 -1
- package/dist/ports/pdpp-auth.d.ts +119 -0
- package/dist/ports/pdpp-auth.d.ts.map +1 -0
- package/dist/ports/pdpp-auth.js +46 -0
- package/dist/ports/pdpp-auth.js.map +1 -0
- package/dist/ports/pdpp-auth.test-utils.d.ts +9 -0
- package/dist/ports/pdpp-auth.test-utils.d.ts.map +1 -0
- package/dist/ports/pdpp-auth.test-utils.js +18 -0
- package/dist/ports/pdpp-auth.test-utils.js.map +1 -0
- package/dist/publication/publish.d.ts +137 -0
- package/dist/publication/publish.d.ts.map +1 -0
- package/dist/publication/publish.js +278 -0
- package/dist/publication/publish.js.map +1 -0
- package/dist/replication/completion.d.ts +20 -0
- package/dist/replication/completion.d.ts.map +1 -0
- package/dist/replication/completion.js +73 -0
- package/dist/replication/completion.js.map +1 -0
- package/dist/replication/coordinator-state.d.ts +29 -0
- package/dist/replication/coordinator-state.d.ts.map +1 -0
- package/dist/replication/coordinator-state.js +88 -0
- package/dist/replication/coordinator-state.js.map +1 -0
- package/dist/replication/coordinator-state.test-utils.d.ts +32 -0
- package/dist/replication/coordinator-state.test-utils.d.ts.map +1 -0
- package/dist/replication/coordinator-state.test-utils.js +113 -0
- package/dist/replication/coordinator-state.test-utils.js.map +1 -0
- package/dist/replication/coordinator.d.ts +264 -0
- package/dist/replication/coordinator.d.ts.map +1 -0
- package/dist/replication/coordinator.js +499 -0
- package/dist/replication/coordinator.js.map +1 -0
- package/dist/replication/copies.d.ts +126 -0
- package/dist/replication/copies.d.ts.map +1 -0
- package/dist/replication/copies.js +437 -0
- package/dist/replication/copies.js.map +1 -0
- package/dist/replication/copy-promotion.d.ts +132 -0
- package/dist/replication/copy-promotion.d.ts.map +1 -0
- package/dist/replication/copy-promotion.js +126 -0
- package/dist/replication/copy-promotion.js.map +1 -0
- package/dist/replication/door.d.ts +33 -0
- package/dist/replication/door.d.ts.map +1 -0
- package/dist/replication/door.js +10 -0
- package/dist/replication/door.js.map +1 -0
- package/dist/replication/dpv2.d.ts +141 -0
- package/dist/replication/dpv2.d.ts.map +1 -0
- package/dist/replication/dpv2.js +320 -0
- package/dist/replication/dpv2.js.map +1 -0
- package/dist/replication/effects.d.ts +68 -0
- package/dist/replication/effects.d.ts.map +1 -0
- package/dist/replication/effects.js +89 -0
- package/dist/replication/effects.js.map +1 -0
- package/dist/replication/engine.d.ts +378 -0
- package/dist/replication/engine.d.ts.map +1 -0
- package/dist/replication/engine.js +3197 -0
- package/dist/replication/engine.js.map +1 -0
- package/dist/replication/envelope.d.ts +481 -0
- package/dist/replication/envelope.d.ts.map +1 -0
- package/dist/replication/envelope.js +192 -0
- package/dist/replication/envelope.js.map +1 -0
- package/dist/replication/evidence.d.ts +118 -0
- package/dist/replication/evidence.d.ts.map +1 -0
- package/dist/replication/evidence.js +198 -0
- package/dist/replication/evidence.js.map +1 -0
- package/dist/replication/finality.d.ts +16 -0
- package/dist/replication/finality.d.ts.map +1 -0
- package/dist/replication/finality.js +11 -0
- package/dist/replication/finality.js.map +1 -0
- package/dist/replication/fixtures.d.ts +16 -0
- package/dist/replication/fixtures.d.ts.map +1 -0
- package/dist/replication/fixtures.js +47 -0
- package/dist/replication/fixtures.js.map +1 -0
- package/dist/replication/host-config.d.ts +52 -0
- package/dist/replication/host-config.d.ts.map +1 -0
- package/dist/replication/host-config.js +111 -0
- package/dist/replication/host-config.js.map +1 -0
- package/dist/replication/host-driver.d.ts +95 -0
- package/dist/replication/host-driver.d.ts.map +1 -0
- package/dist/replication/host-driver.js +202 -0
- package/dist/replication/host-driver.js.map +1 -0
- package/dist/replication/host-ports.d.ts +48 -0
- package/dist/replication/host-ports.d.ts.map +1 -0
- package/dist/replication/host-ports.js +69 -0
- package/dist/replication/host-ports.js.map +1 -0
- package/dist/replication/identity.d.ts +13 -0
- package/dist/replication/identity.d.ts.map +1 -0
- package/dist/replication/identity.js +22 -0
- package/dist/replication/identity.js.map +1 -0
- package/dist/replication/limits.d.ts +124 -0
- package/dist/replication/limits.d.ts.map +1 -0
- package/dist/replication/limits.js +182 -0
- package/dist/replication/limits.js.map +1 -0
- package/dist/replication/merge-plan.d.ts +92 -0
- package/dist/replication/merge-plan.d.ts.map +1 -0
- package/dist/replication/merge-plan.js +229 -0
- package/dist/replication/merge-plan.js.map +1 -0
- package/dist/replication/namespace.d.ts +4 -0
- package/dist/replication/namespace.d.ts.map +1 -0
- package/dist/replication/namespace.js +7 -0
- package/dist/replication/namespace.js.map +1 -0
- package/dist/replication/outcome.d.ts +178 -0
- package/dist/replication/outcome.d.ts.map +1 -0
- package/dist/replication/outcome.js +83 -0
- package/dist/replication/outcome.js.map +1 -0
- package/dist/replication/payload.d.ts +39 -0
- package/dist/replication/payload.d.ts.map +1 -0
- package/dist/replication/payload.js +137 -0
- package/dist/replication/payload.js.map +1 -0
- package/dist/replication/preparation.d.ts +42 -0
- package/dist/replication/preparation.d.ts.map +1 -0
- package/dist/replication/preparation.js +118 -0
- package/dist/replication/preparation.js.map +1 -0
- package/dist/replication/rebaseline.d.ts +33 -0
- package/dist/replication/rebaseline.d.ts.map +1 -0
- package/dist/replication/rebaseline.js +40 -0
- package/dist/replication/rebaseline.js.map +1 -0
- package/dist/replication/rebinding.d.ts +43 -0
- package/dist/replication/rebinding.d.ts.map +1 -0
- package/dist/replication/rebinding.js +52 -0
- package/dist/replication/rebinding.js.map +1 -0
- package/dist/replication/receive.d.ts +57 -0
- package/dist/replication/receive.d.ts.map +1 -0
- package/dist/replication/receive.js +114 -0
- package/dist/replication/receive.js.map +1 -0
- package/dist/replication/record-reducer.d.ts +16 -0
- package/dist/replication/record-reducer.d.ts.map +1 -0
- package/dist/replication/record-reducer.js +52 -0
- package/dist/replication/record-reducer.js.map +1 -0
- package/dist/replication/revision.d.ts +24 -0
- package/dist/replication/revision.d.ts.map +1 -0
- package/dist/replication/revision.js +35 -0
- package/dist/replication/revision.js.map +1 -0
- package/dist/replication/roster.d.ts +53 -0
- package/dist/replication/roster.d.ts.map +1 -0
- package/dist/replication/roster.js +115 -0
- package/dist/replication/roster.js.map +1 -0
- package/dist/replication/schedule.d.ts +73 -0
- package/dist/replication/schedule.d.ts.map +1 -0
- package/dist/replication/schedule.js +182 -0
- package/dist/replication/schedule.js.map +1 -0
- package/dist/replication/stream.d.ts +73 -0
- package/dist/replication/stream.d.ts.map +1 -0
- package/dist/replication/stream.js +542 -0
- package/dist/replication/stream.js.map +1 -0
- package/dist/replication/transport.d.ts +236 -0
- package/dist/replication/transport.d.ts.map +1 -0
- package/dist/replication/transport.js +440 -0
- package/dist/replication/transport.js.map +1 -0
- package/dist/replication/visibility-engine.d.ts +337 -0
- package/dist/replication/visibility-engine.d.ts.map +1 -0
- package/dist/replication/visibility-engine.js +602 -0
- package/dist/replication/visibility-engine.js.map +1 -0
- package/dist/replication/visibility-policy.d.ts +26 -0
- package/dist/replication/visibility-policy.d.ts.map +1 -0
- package/dist/replication/visibility-policy.js +33 -0
- package/dist/replication/visibility-policy.js.map +1 -0
- package/dist/replication/writer-identity-store.d.ts +100 -0
- package/dist/replication/writer-identity-store.d.ts.map +1 -0
- package/dist/replication/writer-identity-store.js +218 -0
- package/dist/replication/writer-identity-store.js.map +1 -0
- package/dist/replication/writer-identity.d.ts +252 -0
- package/dist/replication/writer-identity.d.ts.map +1 -0
- package/dist/replication/writer-identity.js +281 -0
- package/dist/replication/writer-identity.js.map +1 -0
- package/dist/replication/writer-identity.test-utils.d.ts +24 -0
- package/dist/replication/writer-identity.test-utils.d.ts.map +1 -0
- package/dist/replication/writer-identity.test-utils.js +86 -0
- package/dist/replication/writer-identity.test-utils.js.map +1 -0
- package/dist/schemas/server-config.d.ts +81 -0
- package/dist/schemas/server-config.d.ts.map +1 -1
- package/dist/schemas/server-config.js +179 -0
- package/dist/schemas/server-config.js.map +1 -1
- package/dist/signing/request-signer.d.ts +2 -0
- package/dist/signing/request-signer.d.ts.map +1 -1
- package/dist/signing/request-signer.js +1 -0
- package/dist/signing/request-signer.js.map +1 -1
- package/dist/storage/adapters/index.d.ts +3 -1
- package/dist/storage/adapters/index.d.ts.map +1 -1
- package/dist/storage/adapters/index.js +2 -0
- package/dist/storage/adapters/index.js.map +1 -1
- package/dist/storage/adapters/interface.d.ts +33 -3
- package/dist/storage/adapters/interface.d.ts.map +1 -1
- package/dist/storage/adapters/interface.js +13 -1
- package/dist/storage/adapters/interface.js.map +1 -1
- package/dist/storage/adapters/rate-limit-policy.d.ts +66 -0
- package/dist/storage/adapters/rate-limit-policy.d.ts.map +1 -0
- package/dist/storage/adapters/rate-limit-policy.js +103 -0
- package/dist/storage/adapters/rate-limit-policy.js.map +1 -0
- package/dist/storage/adapters/sdk.d.ts +9 -1
- package/dist/storage/adapters/sdk.d.ts.map +1 -1
- package/dist/storage/adapters/sdk.js +32 -8
- package/dist/storage/adapters/sdk.js.map +1 -1
- package/dist/storage/adapters/throttle.d.ts +30 -0
- package/dist/storage/adapters/throttle.d.ts.map +1 -0
- package/dist/storage/adapters/throttle.js +94 -0
- package/dist/storage/adapters/throttle.js.map +1 -0
- package/dist/storage/adapters/vana-audience.d.ts +27 -0
- package/dist/storage/adapters/vana-audience.d.ts.map +1 -0
- package/dist/storage/adapters/vana-audience.js +99 -0
- package/dist/storage/adapters/vana-audience.js.map +1 -0
- package/dist/storage/adapters/vana.d.ts +5 -3
- package/dist/storage/adapters/vana.d.ts.map +1 -1
- package/dist/storage/adapters/vana.js +128 -18
- package/dist/storage/adapters/vana.js.map +1 -1
- package/dist/storage/blocks/cursor.d.ts +5 -1
- package/dist/storage/blocks/cursor.d.ts.map +1 -1
- package/dist/storage/blocks/cursor.js +13 -1
- package/dist/storage/blocks/cursor.js.map +1 -1
- package/dist/storage/blocks/page.d.ts +18 -0
- package/dist/storage/blocks/page.d.ts.map +1 -0
- package/dist/storage/blocks/page.js +113 -0
- package/dist/storage/blocks/page.js.map +1 -0
- package/dist/storage/canonical-legacy-projection.d.ts +262 -0
- package/dist/storage/canonical-legacy-projection.d.ts.map +1 -0
- package/dist/storage/canonical-legacy-projection.js +759 -0
- package/dist/storage/canonical-legacy-projection.js.map +1 -0
- package/dist/storage/hierarchy/paths.d.ts.map +1 -1
- package/dist/storage/hierarchy/paths.js +9 -2
- package/dist/storage/hierarchy/paths.js.map +1 -1
- package/dist/storage/index/manager.d.ts +46 -5
- package/dist/storage/index/manager.d.ts.map +1 -1
- package/dist/storage/index/schema.d.ts +1 -1
- package/dist/storage/index/schema.js +1 -1
- package/dist/storage/index/types.d.ts +7 -1
- package/dist/storage/index/types.d.ts.map +1 -1
- package/dist/storage/legacy-projection.d.ts +88 -0
- package/dist/storage/legacy-projection.d.ts.map +1 -0
- package/dist/storage/legacy-projection.js +755 -0
- package/dist/storage/legacy-projection.js.map +1 -0
- package/dist/storage/legacy-scope-coverage-exceptions.d.ts +13 -0
- package/dist/storage/legacy-scope-coverage-exceptions.d.ts.map +1 -0
- package/dist/storage/legacy-scope-coverage-exceptions.js +14 -0
- package/dist/storage/legacy-scope-coverage-exceptions.js.map +1 -0
- package/dist/storage/legacy-scope-coverage.d.ts +53 -0
- package/dist/storage/legacy-scope-coverage.d.ts.map +1 -0
- package/dist/storage/legacy-scope-coverage.js +416 -0
- package/dist/storage/legacy-scope-coverage.js.map +1 -0
- package/dist/storage/legacy-scope-entity-keys.d.ts +17 -0
- package/dist/storage/legacy-scope-entity-keys.d.ts.map +1 -0
- package/dist/storage/legacy-scope-entity-keys.js +109 -0
- package/dist/storage/legacy-scope-entity-keys.js.map +1 -0
- package/dist/storage/legacy-scope-view.d.ts +201 -0
- package/dist/storage/legacy-scope-view.d.ts.map +1 -0
- package/dist/storage/legacy-scope-view.js +1044 -0
- package/dist/storage/legacy-scope-view.js.map +1 -0
- package/dist/storage/legacy-write-seal.d.ts +73 -0
- package/dist/storage/legacy-write-seal.d.ts.map +1 -0
- package/dist/storage/legacy-write-seal.js +71 -0
- package/dist/storage/legacy-write-seal.js.map +1 -0
- package/dist/storage/pdpp-records/completion.d.ts +91 -0
- package/dist/storage/pdpp-records/completion.d.ts.map +1 -0
- package/dist/storage/pdpp-records/completion.js +170 -0
- package/dist/storage/pdpp-records/completion.js.map +1 -0
- package/dist/storage/pdpp-records/cursor.d.ts +86 -0
- package/dist/storage/pdpp-records/cursor.d.ts.map +1 -0
- package/dist/storage/pdpp-records/cursor.js +56 -0
- package/dist/storage/pdpp-records/cursor.js.map +1 -0
- package/dist/storage/pdpp-records/declaration-witness.d.ts +58 -0
- package/dist/storage/pdpp-records/declaration-witness.d.ts.map +1 -0
- package/dist/storage/pdpp-records/declaration-witness.js +230 -0
- package/dist/storage/pdpp-records/declaration-witness.js.map +1 -0
- package/dist/storage/pdpp-records/enforcement.d.ts +39 -0
- package/dist/storage/pdpp-records/enforcement.d.ts.map +1 -0
- package/dist/storage/pdpp-records/enforcement.js +143 -0
- package/dist/storage/pdpp-records/enforcement.js.map +1 -0
- package/dist/storage/pdpp-records/index.d.ts +7 -0
- package/dist/storage/pdpp-records/index.d.ts.map +1 -0
- package/dist/storage/pdpp-records/index.js +6 -0
- package/dist/storage/pdpp-records/index.js.map +1 -0
- package/dist/storage/pdpp-records/ingest-plan.d.ts +39 -0
- package/dist/storage/pdpp-records/ingest-plan.d.ts.map +1 -0
- package/dist/storage/pdpp-records/ingest-plan.js +103 -0
- package/dist/storage/pdpp-records/ingest-plan.js.map +1 -0
- package/dist/storage/pdpp-records/interface.d.ts +111 -0
- package/dist/storage/pdpp-records/interface.d.ts.map +1 -0
- package/dist/storage/pdpp-records/interface.js +2 -0
- package/dist/storage/pdpp-records/interface.js.map +1 -0
- package/dist/storage/pdpp-records/list-page.d.ts +35 -0
- package/dist/storage/pdpp-records/list-page.d.ts.map +1 -0
- package/dist/storage/pdpp-records/list-page.js +106 -0
- package/dist/storage/pdpp-records/list-page.js.map +1 -0
- package/dist/storage/pdpp-records/memory-store.d.ts +9 -0
- package/dist/storage/pdpp-records/memory-store.d.ts.map +1 -0
- package/dist/storage/pdpp-records/memory-store.js +462 -0
- package/dist/storage/pdpp-records/memory-store.js.map +1 -0
- package/dist/storage/pdpp-records/portable.d.ts +12 -0
- package/dist/storage/pdpp-records/portable.d.ts.map +1 -0
- package/dist/storage/pdpp-records/portable.js +11 -0
- package/dist/storage/pdpp-records/portable.js.map +1 -0
- package/dist/storage/pdpp-records/read-port.d.ts +44 -0
- package/dist/storage/pdpp-records/read-port.d.ts.map +1 -0
- package/dist/storage/pdpp-records/read-port.js +22 -0
- package/dist/storage/pdpp-records/read-port.js.map +1 -0
- package/dist/storage/pdpp-records/record-key.d.ts +52 -0
- package/dist/storage/pdpp-records/record-key.d.ts.map +1 -0
- package/dist/storage/pdpp-records/record-key.js +97 -0
- package/dist/storage/pdpp-records/record-key.js.map +1 -0
- package/dist/storage/pdpp-records/replication-journal.d.ts +20 -0
- package/dist/storage/pdpp-records/replication-journal.d.ts.map +1 -0
- package/dist/storage/pdpp-records/replication-journal.js +2 -0
- package/dist/storage/pdpp-records/replication-journal.js.map +1 -0
- package/dist/storage/pdpp-records/schema.d.ts +41 -0
- package/dist/storage/pdpp-records/schema.d.ts.map +1 -0
- package/dist/storage/pdpp-records/schema.js +153 -0
- package/dist/storage/pdpp-records/schema.js.map +1 -0
- package/dist/storage/pdpp-records/stream-declaration.d.ts +86 -0
- package/dist/storage/pdpp-records/stream-declaration.d.ts.map +1 -0
- package/dist/storage/pdpp-records/stream-declaration.js +48 -0
- package/dist/storage/pdpp-records/stream-declaration.js.map +1 -0
- package/dist/storage/pdpp-records/sync-selection.d.ts +4 -0
- package/dist/storage/pdpp-records/sync-selection.d.ts.map +1 -0
- package/dist/storage/pdpp-records/sync-selection.js +37 -0
- package/dist/storage/pdpp-records/sync-selection.js.map +1 -0
- package/dist/storage/pdpp-records/types.d.ts +204 -0
- package/dist/storage/pdpp-records/types.d.ts.map +1 -0
- package/dist/storage/pdpp-records/types.js +38 -0
- package/dist/storage/pdpp-records/types.js.map +1 -0
- package/dist/stream-sync/artifacts.d.ts +38 -0
- package/dist/stream-sync/artifacts.d.ts.map +1 -0
- package/dist/stream-sync/artifacts.js +141 -0
- package/dist/stream-sync/artifacts.js.map +1 -0
- package/dist/stream-sync/blobs.d.ts +18 -0
- package/dist/stream-sync/blobs.d.ts.map +1 -0
- package/dist/stream-sync/blobs.js +83 -0
- package/dist/stream-sync/blobs.js.map +1 -0
- package/dist/stream-sync/crypto-port.d.ts +20 -0
- package/dist/stream-sync/crypto-port.d.ts.map +1 -0
- package/dist/stream-sync/crypto-port.js +19 -0
- package/dist/stream-sync/crypto-port.js.map +1 -0
- package/dist/stream-sync/crypto.d.ts +27 -0
- package/dist/stream-sync/crypto.d.ts.map +1 -0
- package/dist/stream-sync/crypto.js +67 -0
- package/dist/stream-sync/crypto.js.map +1 -0
- package/dist/stream-sync/delete-metadata.d.ts +23 -0
- package/dist/stream-sync/delete-metadata.d.ts.map +1 -0
- package/dist/stream-sync/delete-metadata.js +40 -0
- package/dist/stream-sync/delete-metadata.js.map +1 -0
- package/dist/stream-sync/index.d.ts +13 -0
- package/dist/stream-sync/index.d.ts.map +1 -0
- package/dist/stream-sync/index.js +13 -0
- package/dist/stream-sync/index.js.map +1 -0
- package/dist/stream-sync/intake.d.ts +185 -0
- package/dist/stream-sync/intake.d.ts.map +1 -0
- package/dist/stream-sync/intake.js +36 -0
- package/dist/stream-sync/intake.js.map +1 -0
- package/dist/stream-sync/memory-registry.d.ts +58 -0
- package/dist/stream-sync/memory-registry.d.ts.map +1 -0
- package/dist/stream-sync/memory-registry.js +119 -0
- package/dist/stream-sync/memory-registry.js.map +1 -0
- package/dist/stream-sync/ports.d.ts +363 -0
- package/dist/stream-sync/ports.d.ts.map +1 -0
- package/dist/stream-sync/ports.js +68 -0
- package/dist/stream-sync/ports.js.map +1 -0
- package/dist/stream-sync/publish-plan.d.ts +157 -0
- package/dist/stream-sync/publish-plan.d.ts.map +1 -0
- package/dist/stream-sync/publish-plan.js +217 -0
- package/dist/stream-sync/publish-plan.js.map +1 -0
- package/dist/stream-sync/registry.d.ts +24 -0
- package/dist/stream-sync/registry.d.ts.map +1 -0
- package/dist/stream-sync/registry.js +389 -0
- package/dist/stream-sync/registry.js.map +1 -0
- package/dist/stream-sync/scope-routing.d.ts +17 -0
- package/dist/stream-sync/scope-routing.d.ts.map +1 -0
- package/dist/stream-sync/scope-routing.js +24 -0
- package/dist/stream-sync/scope-routing.js.map +1 -0
- package/dist/stream-sync/seed-staging.d.ts +85 -0
- package/dist/stream-sync/seed-staging.d.ts.map +1 -0
- package/dist/stream-sync/seed-staging.js +325 -0
- package/dist/stream-sync/seed-staging.js.map +1 -0
- package/dist/stream-sync/send-gate.d.ts +149 -0
- package/dist/stream-sync/send-gate.d.ts.map +1 -0
- package/dist/stream-sync/send-gate.js +382 -0
- package/dist/stream-sync/send-gate.js.map +1 -0
- package/dist/stream-sync/storage-retry.d.ts +210 -0
- package/dist/stream-sync/storage-retry.d.ts.map +1 -0
- package/dist/stream-sync/storage-retry.js +314 -0
- package/dist/stream-sync/storage-retry.js.map +1 -0
- package/dist/stream-sync/stream-aead.d.ts +33 -0
- package/dist/stream-sync/stream-aead.d.ts.map +1 -0
- package/dist/stream-sync/stream-aead.js +183 -0
- package/dist/stream-sync/stream-aead.js.map +1 -0
- package/dist/stream-sync-read/index.d.ts +4 -0
- package/dist/stream-sync-read/index.d.ts.map +1 -0
- package/dist/stream-sync-read/index.js +3 -0
- package/dist/stream-sync-read/index.js.map +1 -0
- package/dist/stream-sync-read/routing.d.ts +27 -0
- package/dist/stream-sync-read/routing.d.ts.map +1 -0
- package/dist/stream-sync-read/routing.js +49 -0
- package/dist/stream-sync-read/routing.js.map +1 -0
- package/dist/stream-sync-read/service.d.ts +196 -0
- package/dist/stream-sync-read/service.d.ts.map +1 -0
- package/dist/stream-sync-read/service.js +17 -0
- package/dist/stream-sync-read/service.js.map +1 -0
- package/dist/sync/account-mode/authority.d.ts +56 -0
- package/dist/sync/account-mode/authority.d.ts.map +1 -0
- package/dist/sync/account-mode/authority.js +145 -0
- package/dist/sync/account-mode/authority.js.map +1 -0
- package/dist/sync/account-mode/evidence-wire.d.ts +23 -0
- package/dist/sync/account-mode/evidence-wire.d.ts.map +1 -0
- package/dist/sync/account-mode/evidence-wire.js +37 -0
- package/dist/sync/account-mode/evidence-wire.js.map +1 -0
- package/dist/sync/account-mode/import-waker.d.ts +36 -0
- package/dist/sync/account-mode/import-waker.d.ts.map +1 -0
- package/dist/sync/account-mode/import-waker.js +55 -0
- package/dist/sync/account-mode/import-waker.js.map +1 -0
- package/dist/sync/account-mode/index.d.ts +10 -0
- package/dist/sync/account-mode/index.d.ts.map +1 -0
- package/dist/sync/account-mode/index.js +10 -0
- package/dist/sync/account-mode/index.js.map +1 -0
- package/dist/sync/account-mode/port.d.ts +11 -0
- package/dist/sync/account-mode/port.d.ts.map +1 -0
- package/dist/sync/account-mode/port.js +21 -0
- package/dist/sync/account-mode/port.js.map +1 -0
- package/dist/sync/account-mode/record.d.ts +52 -0
- package/dist/sync/account-mode/record.d.ts.map +1 -0
- package/dist/sync/account-mode/record.js +60 -0
- package/dist/sync/account-mode/record.js.map +1 -0
- package/dist/sync/account-mode/rw-lock.d.ts +14 -0
- package/dist/sync/account-mode/rw-lock.d.ts.map +1 -0
- package/dist/sync/account-mode/rw-lock.js +59 -0
- package/dist/sync/account-mode/rw-lock.js.map +1 -0
- package/dist/sync/cancellable-gateway.d.ts +25 -0
- package/dist/sync/cancellable-gateway.d.ts.map +1 -0
- package/dist/sync/cancellable-gateway.js +64 -0
- package/dist/sync/cancellable-gateway.js.map +1 -0
- package/dist/sync/data-point-feed.d.ts +3 -0
- package/dist/sync/data-point-feed.d.ts.map +1 -1
- package/dist/sync/data-point-feed.js +20 -1
- package/dist/sync/data-point-feed.js.map +1 -1
- package/dist/sync/delete-data-port.d.ts +19 -0
- package/dist/sync/delete-data-port.d.ts.map +1 -1
- package/dist/sync/delete-data-port.js +42 -9
- package/dist/sync/delete-data-port.js.map +1 -1
- package/dist/sync/engine/change-probe.d.ts +42 -0
- package/dist/sync/engine/change-probe.d.ts.map +1 -0
- package/dist/sync/engine/change-probe.js +79 -0
- package/dist/sync/engine/change-probe.js.map +1 -0
- package/dist/sync/engine/change-push.d.ts +53 -0
- package/dist/sync/engine/change-push.d.ts.map +1 -0
- package/dist/sync/engine/change-push.js +153 -0
- package/dist/sync/engine/change-push.js.map +1 -0
- package/dist/sync/engine/sync-manager.d.ts +181 -2
- package/dist/sync/engine/sync-manager.d.ts.map +1 -1
- package/dist/sync/engine/sync-manager.js +642 -19
- package/dist/sync/engine/sync-manager.js.map +1 -1
- package/dist/sync/index.d.ts +11 -3
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +11 -1
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/pdpp-import.d.ts +202 -0
- package/dist/sync/pdpp-import.d.ts.map +1 -0
- package/dist/sync/pdpp-import.js +466 -0
- package/dist/sync/pdpp-import.js.map +1 -0
- package/dist/sync/pending-blob-deletions.d.ts +18 -2
- package/dist/sync/pending-blob-deletions.d.ts.map +1 -1
- package/dist/sync/pending-blob-deletions.js +97 -23
- package/dist/sync/pending-blob-deletions.js.map +1 -1
- package/dist/sync/scope-deletions.d.ts +12 -0
- package/dist/sync/scope-deletions.d.ts.map +1 -1
- package/dist/sync/scope-deletions.js +99 -25
- package/dist/sync/scope-deletions.js.map +1 -1
- package/dist/sync/tombstone-finality.d.ts +36 -0
- package/dist/sync/tombstone-finality.d.ts.map +1 -0
- package/dist/sync/tombstone-finality.js +142 -0
- package/dist/sync/tombstone-finality.js.map +1 -0
- package/dist/sync/tombstone-resubmits.d.ts +61 -0
- package/dist/sync/tombstone-resubmits.d.ts.map +1 -0
- package/dist/sync/tombstone-resubmits.js +85 -0
- package/dist/sync/tombstone-resubmits.js.map +1 -0
- package/dist/sync/types.d.ts +26 -0
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/sync/upload-attempts.d.ts +218 -0
- package/dist/sync/upload-attempts.d.ts.map +1 -0
- package/dist/sync/upload-attempts.js +500 -0
- package/dist/sync/upload-attempts.js.map +1 -0
- package/dist/sync/upload-state.d.ts +163 -0
- package/dist/sync/upload-state.d.ts.map +1 -0
- package/dist/sync/upload-state.js +239 -0
- package/dist/sync/upload-state.js.map +1 -0
- package/dist/sync/workers/delete.d.ts +63 -6
- package/dist/sync/workers/delete.d.ts.map +1 -1
- package/dist/sync/workers/delete.js +621 -168
- package/dist/sync/workers/delete.js.map +1 -1
- package/dist/sync/workers/download.d.ts +27 -1
- package/dist/sync/workers/download.d.ts.map +1 -1
- package/dist/sync/workers/download.js +368 -27
- package/dist/sync/workers/download.js.map +1 -1
- package/dist/sync/workers/lost-data-points.d.ts +38 -0
- package/dist/sync/workers/lost-data-points.d.ts.map +1 -0
- package/dist/sync/workers/lost-data-points.js +72 -0
- package/dist/sync/workers/lost-data-points.js.map +1 -0
- package/dist/sync/workers/upload.d.ts +97 -8
- package/dist/sync/workers/upload.d.ts.map +1 -1
- package/dist/sync/workers/upload.js +498 -277
- package/dist/sync/workers/upload.js.map +1 -1
- package/dist/test-support/memory-oracle.calibration.d.ts +16 -0
- package/dist/test-support/memory-oracle.calibration.d.ts.map +1 -0
- package/dist/test-support/memory-oracle.calibration.js +43 -0
- package/dist/test-support/memory-oracle.calibration.js.map +1 -0
- package/dist/test-support/memory-oracle.d.ts +82 -0
- package/dist/test-support/memory-oracle.d.ts.map +1 -0
- package/dist/test-support/memory-oracle.js +104 -0
- package/dist/test-support/memory-oracle.js.map +1 -0
- package/dist/test-utils/account-mode.d.ts +36 -0
- package/dist/test-utils/account-mode.d.ts.map +1 -0
- package/dist/test-utils/account-mode.js +77 -0
- package/dist/test-utils/account-mode.js.map +1 -0
- package/dist/test-utils/index.d.ts +2 -0
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/index.js +2 -0
- package/dist/test-utils/index.js.map +1 -1
- package/dist/test-utils/legacy-write-seal.d.ts +16 -0
- package/dist/test-utils/legacy-write-seal.d.ts.map +1 -0
- package/dist/test-utils/legacy-write-seal.js +20 -0
- package/dist/test-utils/legacy-write-seal.js.map +1 -0
- package/dist/test-utils/live-grants.d.ts +24 -0
- package/dist/test-utils/live-grants.d.ts.map +1 -0
- package/dist/test-utils/live-grants.js +6 -0
- package/dist/test-utils/live-grants.js.map +1 -0
- package/dist/test-utils/memory-storage.d.ts +18 -2
- package/dist/test-utils/memory-storage.d.ts.map +1 -1
- package/dist/test-utils/memory-storage.js +156 -42
- package/dist/test-utils/memory-storage.js.map +1 -1
- package/dist/write/attribution.d.ts.map +1 -1
- package/dist/write/attribution.js +8 -4
- package/dist/write/attribution.js.map +1 -1
- package/dist/write/route.d.ts.map +1 -1
- package/dist/write/route.js +9 -10
- package/dist/write/route.js.map +1 -1
- package/dist/write/session.d.ts.map +1 -1
- package/dist/write/session.js +13 -0
- package/dist/write/session.js.map +1 -1
- package/dist-test/localdb/conformance.d.ts +13 -0
- package/dist-test/localdb/conformance.d.ts.map +1 -0
- package/dist-test/localdb/conformance.js +292 -0
- package/dist-test/localdb/conformance.js.map +1 -0
- package/dist-test/tsconfig.tsbuildinfo +1 -0
- package/package.json +131 -5
|
@@ -7,18 +7,86 @@
|
|
|
7
7
|
* POST /v1/mcp/connections/:id/approve
|
|
8
8
|
* DELETE /v1/mcp/connections/:id
|
|
9
9
|
*
|
|
10
|
+
* plus the server-signed answer to an MCP client's `request_scope_access`:
|
|
11
|
+
*
|
|
12
|
+
* POST /v1/mcp/connections/:id/scope-request/approve
|
|
13
|
+
* POST /v1/mcp/connections/:id/scope-request/deny
|
|
14
|
+
* PUT /v1/mcp/connections/:id/access (opt-in owner narrowing)
|
|
15
|
+
*
|
|
16
|
+
* and one read that is NOT owner-signed, because the owner's page needs it
|
|
17
|
+
* before it asks for any signature:
|
|
18
|
+
*
|
|
19
|
+
* GET /v1/mcp/connections/:id/scope-request
|
|
20
|
+
* (header `X-Vana-Scope-Request-Token`, from the approval link)
|
|
21
|
+
*
|
|
10
22
|
* These endpoints DO NOT read user data. They only manage connection records
|
|
11
23
|
* — create the per-connection grantee/token, store grant ids after the user
|
|
12
24
|
* approves them, and mark connections revoked.
|
|
13
25
|
*/
|
|
26
|
+
import { McpGrantRegistrationError } from "./grant-registration.js";
|
|
14
27
|
import { generateMcpGrantee } from "./grantee.js";
|
|
28
|
+
import { mcpConnectionStateView } from "./store.js";
|
|
15
29
|
import { createGrantContract } from "../contracts/index.js";
|
|
30
|
+
import { isWriteScopeEntry, WRITE_SCOPE_PREFIX } from "../policy/data-write.js";
|
|
31
|
+
import { isMemoryScope, isSystemScope } from "../policy/reserved-scopes.js";
|
|
32
|
+
import { isPhysicalScope, streamReadScope, } from "../stream-sync-read/routing.js";
|
|
33
|
+
import { ScopeSchema, } from "@opendatalabs/vana-sdk/browser";
|
|
16
34
|
import { appUrlFromOAuthRedirectUri, ensureMcpGranteeRegistered, McpGranteeRegistrationError, } from "./builder-registration.js";
|
|
35
|
+
import { MCP_SCOPE_ACCESS_REQUEST_LIMIT } from "./types.js";
|
|
36
|
+
import { isAllowedOAuthRedirectUri } from "./oauth-redirect.js";
|
|
37
|
+
import { isMcpRefreshExpired, MCP_TOKEN_TTL_MS, mcpRefreshExpiry, mcpTokenExpiry, } from "./token-expiry.js";
|
|
17
38
|
const TOKEN_BYTES = 32;
|
|
18
39
|
const OAUTH_AUTHORIZATION_TTL_MS = 10 * 60 * 1000;
|
|
40
|
+
const pendingOAuthReplacements = new WeakMap();
|
|
41
|
+
/**
|
|
42
|
+
* Default lifetime of a grant the server signs itself for an MCP connection
|
|
43
|
+
* (OAuth approve, or a scope-request approve with no live grant to inherit
|
|
44
|
+
* an expiry from): 0, a perpetual grant, as before this option existed.
|
|
45
|
+
* Hosts opt into a dated grant with `mcpGrantTtlSeconds`, for example
|
|
46
|
+
* 365 * 24 * 60 * 60 for one year from signing.
|
|
47
|
+
*/
|
|
48
|
+
export const DEFAULT_MCP_GRANT_TTL_SECONDS = 0;
|
|
49
|
+
/**
|
|
50
|
+
* Unix-seconds expiry for a freshly signed MCP grant, or undefined for a
|
|
51
|
+
* perpetual one (ttl 0).
|
|
52
|
+
*/
|
|
53
|
+
export function mcpGrantDefaultExpiry(ttlSeconds, now) {
|
|
54
|
+
const ttl = ttlSeconds ?? DEFAULT_MCP_GRANT_TTL_SECONDS;
|
|
55
|
+
if (!Number.isFinite(ttl) || ttl < 0) {
|
|
56
|
+
throw new RangeError(`mcpGrantTtlSeconds must be a non-negative number, got ${ttlSeconds}`);
|
|
57
|
+
}
|
|
58
|
+
if (ttl === 0)
|
|
59
|
+
return undefined;
|
|
60
|
+
return Math.floor(nowMs(now) / 1000) + Math.floor(ttl);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Request header carrying the scope-request read token. The token travels in
|
|
64
|
+
* the approval link's URL fragment, so the page reads it client-side and
|
|
65
|
+
* sends it here; it never reaches a web server log or a Referer.
|
|
66
|
+
*/
|
|
67
|
+
export const MCP_SCOPE_REQUEST_TOKEN_HEADER = "X-Vana-Scope-Request-Token";
|
|
68
|
+
/**
|
|
69
|
+
* errorCode for every failed token read: unknown connection, nothing
|
|
70
|
+
* pending, wrong, missing or expired token. One answer for all of them, so
|
|
71
|
+
* the route does not reveal which connections or requests exist.
|
|
72
|
+
*/
|
|
73
|
+
export const MCP_SCOPE_REQUEST_NOT_FOUND = "MCP_SCOPE_REQUEST_NOT_FOUND";
|
|
74
|
+
/** How long an approval link can load its request without a signature. */
|
|
75
|
+
export const MCP_SCOPE_REQUEST_READ_TOKEN_TTL_MS = 24 * 60 * 60 * 1000;
|
|
76
|
+
/** 32 random bytes encode to 43 base64url chars; anything far longer is junk. */
|
|
77
|
+
const MAX_READ_TOKEN_CHARS = 128;
|
|
78
|
+
/** Store patch that drops every refresh token a connection still answers to. */
|
|
79
|
+
const CLEARED_REFRESH_FAMILY = {
|
|
80
|
+
refreshTokenHash: undefined,
|
|
81
|
+
previousRefreshTokenHash: undefined,
|
|
82
|
+
refreshExpiresAt: undefined,
|
|
83
|
+
};
|
|
19
84
|
function nowIso(now) {
|
|
20
85
|
return (now ? now() : new Date()).toISOString();
|
|
21
86
|
}
|
|
87
|
+
function nowMs(now) {
|
|
88
|
+
return (now ? now() : new Date()).getTime();
|
|
89
|
+
}
|
|
22
90
|
function randomBytes(byteLength) {
|
|
23
91
|
const bytes = new Uint8Array(byteLength);
|
|
24
92
|
globalThis.crypto.getRandomValues(bytes);
|
|
@@ -48,6 +116,11 @@ function randomToken() {
|
|
|
48
116
|
return bytesToBase64Url(randomBytes(TOKEN_BYTES));
|
|
49
117
|
}
|
|
50
118
|
export async function createMcpConnection(input, options) {
|
|
119
|
+
const { record, output } = await buildMcpConnection(input, options);
|
|
120
|
+
await options.store.create(record);
|
|
121
|
+
return output;
|
|
122
|
+
}
|
|
123
|
+
async function buildMcpConnection(input, options) {
|
|
51
124
|
const grantee = generateMcpGrantee();
|
|
52
125
|
const token = randomToken();
|
|
53
126
|
const tokenHash = await hashConnectionToken(token);
|
|
@@ -60,17 +133,22 @@ export async function createMcpConnection(input, options) {
|
|
|
60
133
|
granteePublicKey: grantee.key.publicKey,
|
|
61
134
|
encryptedGranteePrivateKey: grantee.key.encryptedPrivateKey,
|
|
62
135
|
tokenHash,
|
|
136
|
+
tokenExpiresAt: mcpTokenExpiry(nowMs(options.now)),
|
|
63
137
|
status: "pending",
|
|
64
138
|
grants: [],
|
|
65
139
|
createdAt,
|
|
140
|
+
...(input.ingress ? { ingress: input.ingress } : {}),
|
|
141
|
+
...(input.clientId ? { clientId: input.clientId } : {}),
|
|
66
142
|
};
|
|
67
|
-
await options.store.create(record);
|
|
68
143
|
return {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
144
|
+
record,
|
|
145
|
+
output: {
|
|
146
|
+
connectionId: id,
|
|
147
|
+
granteeAddress: grantee.key.address,
|
|
148
|
+
connectionToken: token,
|
|
149
|
+
mcpUrl: buildMcpUrl(options.publicOrigin, token),
|
|
150
|
+
createdAt,
|
|
151
|
+
},
|
|
74
152
|
};
|
|
75
153
|
}
|
|
76
154
|
export function buildMcpUrl(publicOrigin, token) {
|
|
@@ -91,6 +169,13 @@ export function buildMcpProtectedResourceMetadataUrl(publicOrigin) {
|
|
|
91
169
|
: publicOrigin;
|
|
92
170
|
return `${base}/.well-known/oauth-protected-resource/mcp`;
|
|
93
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* errorCode for an unknown connection id on the single-connection and
|
|
174
|
+
* scope-request routes. Distinct from the generic `NOT_FOUND` a server
|
|
175
|
+
* answers for a route it does not have, so a caller (Vana Web) can tell
|
|
176
|
+
* "this request is gone" from "this server predates the route".
|
|
177
|
+
*/
|
|
178
|
+
export const MCP_CONNECTION_NOT_FOUND = "MCP_CONNECTION_NOT_FOUND";
|
|
94
179
|
export class McpConnectionNotFoundError extends Error {
|
|
95
180
|
connectionId;
|
|
96
181
|
constructor(connectionId) {
|
|
@@ -110,25 +195,534 @@ export class McpConnectionStateError extends Error {
|
|
|
110
195
|
}
|
|
111
196
|
}
|
|
112
197
|
export async function approveMcpConnection(input, options) {
|
|
113
|
-
const existing = await options.store.getById(input.connectionId);
|
|
114
|
-
if (!existing)
|
|
115
|
-
throw new McpConnectionNotFoundError(input.connectionId);
|
|
116
|
-
if (existing.status === "revoked") {
|
|
117
|
-
throw new McpConnectionStateError(input.connectionId, existing.status, "pending or approved");
|
|
118
|
-
}
|
|
119
198
|
if (!input.grants.length) {
|
|
120
199
|
throw new Error("approveMcpConnection requires at least one grant; the consent flow must mint grants first");
|
|
121
200
|
}
|
|
201
|
+
assertStorableScopes(input.grants.flatMap((grant) => grant.scopes ?? []));
|
|
122
202
|
const approvedAt = nowIso(options.now);
|
|
123
|
-
const updated = await options.store.
|
|
124
|
-
status
|
|
125
|
-
|
|
126
|
-
|
|
203
|
+
const updated = await options.store.mutate(input.connectionId, (existing) => {
|
|
204
|
+
if (existing.status === "revoked") {
|
|
205
|
+
throw new McpConnectionStateError(input.connectionId, existing.status, "pending or approved");
|
|
206
|
+
}
|
|
207
|
+
const pendingRequest = existing.scopeAccessRequest;
|
|
208
|
+
const remainingRequestScopes = pendingRequest?.scopes.filter((scope) => !input.grants.some((grant) => grantCoversScope(grant, scope)));
|
|
209
|
+
// A narrowed request is a different request: its old link stops loading
|
|
210
|
+
// it (the read token is dropped) and the page falls back to a signed read.
|
|
211
|
+
return {
|
|
212
|
+
...existing,
|
|
213
|
+
status: "approved",
|
|
214
|
+
grants: input.grants,
|
|
215
|
+
approvedAt,
|
|
216
|
+
scopeAccessRequest: pendingRequest &&
|
|
217
|
+
remainingRequestScopes &&
|
|
218
|
+
remainingRequestScopes.length > 0
|
|
219
|
+
? {
|
|
220
|
+
...toMcpScopeAccessRequestView(pendingRequest),
|
|
221
|
+
scopes: remainingRequestScopes,
|
|
222
|
+
}
|
|
223
|
+
: undefined,
|
|
224
|
+
};
|
|
225
|
+
});
|
|
226
|
+
if (!updated)
|
|
227
|
+
throw new McpConnectionNotFoundError(input.connectionId);
|
|
228
|
+
return updated;
|
|
229
|
+
}
|
|
230
|
+
function grantCoversScope(grant, scope) {
|
|
231
|
+
// A `write:` request is covered only by the same exact write entry: not by
|
|
232
|
+
// a read wildcard such as `*`, and not by a write wildcard, which `remember`
|
|
233
|
+
// ignores (the agent must still be able to ask for the exact grant).
|
|
234
|
+
if (isWriteScopeEntry(scope))
|
|
235
|
+
return grant.scopes.includes(scope);
|
|
236
|
+
return grant.scopes.some((granted) => granted === "*" ||
|
|
237
|
+
granted === scope ||
|
|
238
|
+
(granted.endsWith(".*") && scope.startsWith(granted.slice(0, -1))));
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* The stored grants, cut down to what the gateway says is live now. The
|
|
242
|
+
* gateway keeps one grant id per (owner, grantee) and a re-registration
|
|
243
|
+
* replaces its scopes under the same id, so a live id says nothing about
|
|
244
|
+
* which scopes still stand. A scope survives only when both the record and
|
|
245
|
+
* the gateway name it (a wildcard on one side covers a narrower scope on the
|
|
246
|
+
* other); a scope only the gateway names is never added; a grant left with no
|
|
247
|
+
* scope, or not live, is dropped.
|
|
248
|
+
*/
|
|
249
|
+
export function narrowGrants(stored, live) {
|
|
250
|
+
const current = new Map(live.map((grant) => [grant.grantId, grant.scopes]));
|
|
251
|
+
return stored.flatMap((grant) => {
|
|
252
|
+
const gateway = current.get(grant.grantId);
|
|
253
|
+
if (!gateway)
|
|
254
|
+
return [];
|
|
255
|
+
const scopes = Array.from(new Set([
|
|
256
|
+
...grant.scopes.filter((scope) => grantCoversScope({ ...grant, scopes: gateway }, scope)),
|
|
257
|
+
...gateway.filter((scope) => grantCoversScope(grant, scope)),
|
|
258
|
+
]));
|
|
259
|
+
return scopes.length > 0 ? [{ ...grant, scopes }] : [];
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
export async function requestMcpScopeAccess(input, options) {
|
|
263
|
+
const requestedAt = nowIso(options.now);
|
|
264
|
+
const readToken = randomToken();
|
|
265
|
+
const readTokenHash = await hashConnectionToken(readToken);
|
|
266
|
+
const readTokenExpiresAt = new Date(nowMs(options.now) + MCP_SCOPE_REQUEST_READ_TOKEN_TTL_MS).toISOString();
|
|
267
|
+
const inputScopes = Array.from(new Set(input.scopes.map((scope) => scope.trim()).filter(Boolean))).sort();
|
|
268
|
+
let storedGrantIds = new Set();
|
|
269
|
+
const updated = await options.store.mutate(input.connectionId, (existing) => {
|
|
270
|
+
storedGrantIds = new Set(existing.grants.map((grant) => grant.grantId));
|
|
271
|
+
if (existing.status !== "approved") {
|
|
272
|
+
throw new McpConnectionStateError(input.connectionId, existing.status, "approved");
|
|
273
|
+
}
|
|
274
|
+
const scopes = Array.from(new Set([...(existing.scopeAccessRequest?.scopes ?? []), ...inputScopes]
|
|
275
|
+
.map((scope) => scope.trim())
|
|
276
|
+
.filter((scope) => scope.length > 0 &&
|
|
277
|
+
!(input.liveGrants ?? existing.grants).some((grant) => grantCoversScope(grant, scope))))).sort();
|
|
278
|
+
if (scopes.length === 0)
|
|
279
|
+
return existing;
|
|
280
|
+
if (scopes.length > MCP_SCOPE_ACCESS_REQUEST_LIMIT)
|
|
281
|
+
return existing;
|
|
282
|
+
const reason = input.reason?.trim() || existing.scopeAccessRequest?.reason;
|
|
283
|
+
const request = {
|
|
284
|
+
scopes,
|
|
285
|
+
...(reason ? { reason } : {}),
|
|
286
|
+
requestedAt,
|
|
287
|
+
readTokenHash,
|
|
288
|
+
readTokenExpiresAt,
|
|
289
|
+
};
|
|
290
|
+
return { ...existing, scopeAccessRequest: request };
|
|
291
|
+
});
|
|
292
|
+
if (!updated)
|
|
293
|
+
throw new McpConnectionNotFoundError(input.connectionId);
|
|
294
|
+
const missingInputScopes = inputScopes.filter((scope) => !(input.liveGrants ?? updated.grants).some((grant) => grantCoversScope(grant, scope)));
|
|
295
|
+
// Grants the caller found dead stay out of the answer, so it does not call
|
|
296
|
+
// them granted; a grant added while the request was written still counts.
|
|
297
|
+
const liveById = input.liveGrants
|
|
298
|
+
? new Map(input.liveGrants.map((grant) => [grant.grantId, grant]))
|
|
299
|
+
: undefined;
|
|
300
|
+
return {
|
|
301
|
+
connection: liveById
|
|
302
|
+
? {
|
|
303
|
+
...updated,
|
|
304
|
+
grants: updated.grants.flatMap((grant) => {
|
|
305
|
+
if (!storedGrantIds.has(grant.grantId))
|
|
306
|
+
return [grant];
|
|
307
|
+
const live = liveById.get(grant.grantId);
|
|
308
|
+
return live ? [live] : [];
|
|
309
|
+
}),
|
|
310
|
+
}
|
|
311
|
+
: updated,
|
|
312
|
+
requestRecorded: missingInputScopes.length > 0 &&
|
|
313
|
+
missingInputScopes.every((scope) => updated.scopeAccessRequest?.scopes.includes(scope)),
|
|
314
|
+
...(updated.scopeAccessRequest?.readTokenHash === readTokenHash
|
|
315
|
+
? { readToken }
|
|
316
|
+
: {}),
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
/** Constant-time equality for two hex digests of the same algorithm. */
|
|
320
|
+
function digestsEqual(a, b) {
|
|
321
|
+
let diff = a.length ^ b.length;
|
|
322
|
+
const length = Math.max(a.length, b.length);
|
|
323
|
+
for (let i = 0; i < length; i += 1) {
|
|
324
|
+
diff |= (a.charCodeAt(i) | 0) ^ (b.charCodeAt(i) | 0);
|
|
325
|
+
}
|
|
326
|
+
return diff === 0;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Load one pending scope request with the read token from its approval link.
|
|
330
|
+
* Returns null for an unknown or non-approved connection, no pending request,
|
|
331
|
+
* a request without a token, a wrong or missing token, or an expired one, so
|
|
332
|
+
* a caller can answer all of them the same way.
|
|
333
|
+
*/
|
|
334
|
+
export async function readMcpScopeRequestWithToken(input, options) {
|
|
335
|
+
const token = input.token?.trim() ?? "";
|
|
336
|
+
if (!token || token.length > MAX_READ_TOKEN_CHARS || !input.connectionId) {
|
|
337
|
+
return null;
|
|
338
|
+
}
|
|
339
|
+
const presentedHash = await hashConnectionToken(token);
|
|
340
|
+
const record = await options.store.getById(input.connectionId);
|
|
341
|
+
const request = record?.scopeAccessRequest;
|
|
342
|
+
if (!record || record.status !== "approved" || !request)
|
|
343
|
+
return null;
|
|
344
|
+
if (!request.readTokenHash || !request.readTokenExpiresAt)
|
|
345
|
+
return null;
|
|
346
|
+
if (!digestsEqual(presentedHash, request.readTokenHash))
|
|
347
|
+
return null;
|
|
348
|
+
const expiresAt = Date.parse(request.readTokenExpiresAt);
|
|
349
|
+
if (!Number.isFinite(expiresAt) || expiresAt <= nowMs(options.now)) {
|
|
350
|
+
return null;
|
|
351
|
+
}
|
|
352
|
+
if (request.scopes.length === 0)
|
|
353
|
+
return null;
|
|
354
|
+
const liveGrants = narrowGrants(record.grants, await liveMcpGrants(record, options.gateway, options.now));
|
|
355
|
+
return {
|
|
356
|
+
id: record.id,
|
|
357
|
+
displayName: record.displayName,
|
|
358
|
+
scopeAccessRequest: toMcpScopeAccessRequestView(request),
|
|
359
|
+
grantedScopes: sortedUnique(liveGrants.flatMap((grant) => grant.scopes)),
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
/** A scope-request answer the owner cannot give in the connection's state. */
|
|
363
|
+
export class McpScopeRequestError extends Error {
|
|
364
|
+
code;
|
|
365
|
+
status;
|
|
366
|
+
body;
|
|
367
|
+
constructor(code, message, status = 400, body) {
|
|
368
|
+
super(message);
|
|
369
|
+
this.code = code;
|
|
370
|
+
this.status = status;
|
|
371
|
+
this.body = body;
|
|
372
|
+
this.name = "McpScopeRequestError";
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Owner approves (part of) a pending `request_scope_access` without an
|
|
377
|
+
* external signer: the server signs the grant itself, as the OAuth approve
|
|
378
|
+
* path does.
|
|
379
|
+
*
|
|
380
|
+
* The gateway keeps ONE grant per (owner, grantee) and a new registration
|
|
381
|
+
* replaces its scopes, so the grant is re-signed over the scopes the
|
|
382
|
+
* connection still holds (see `retainedScopes`) plus the approved ones.
|
|
383
|
+
* Signing only the new scopes would silently revoke the old ones.
|
|
384
|
+
*/
|
|
385
|
+
export async function approveMcpScopeAccessRequest(input, options) {
|
|
386
|
+
const connection = await options.store.getById(input.connectionId);
|
|
387
|
+
if (!connection)
|
|
388
|
+
throw new McpConnectionNotFoundError(input.connectionId);
|
|
389
|
+
const pending = requirePendingScopeRequest(connection);
|
|
390
|
+
const approvedScopes = parseApprovedScopes(input.scopes, pending);
|
|
391
|
+
const live = await readLiveGrantState(connection, options.gateway, options.now);
|
|
392
|
+
// Keep only what reads serve (record AND gateway), as edit does. A scope on
|
|
393
|
+
// the gateway but not in the record is a write whose local commit was lost;
|
|
394
|
+
// the owner may have denied it since (deny is local and does not touch the
|
|
395
|
+
// gateway), so it is never re-signed. Reads never serve it meanwhile.
|
|
396
|
+
const grantedScopes = sortedUnique([
|
|
397
|
+
...retainedScopes(connection, live),
|
|
398
|
+
...approvedScopes,
|
|
399
|
+
]);
|
|
400
|
+
const decidedAt = nowIso(options.now);
|
|
401
|
+
const deniedScopes = pending.scopes.filter((scope) => !approvedScopes.includes(scope));
|
|
402
|
+
const { connection: updated, grantId } = await writeConnectionGrantScopes(connection, grantedScopes, options, live, (latest) => ({
|
|
403
|
+
...latest,
|
|
404
|
+
scopeAccessRequest: undefined,
|
|
405
|
+
scopeAccessDecision: {
|
|
406
|
+
decision: "approved",
|
|
407
|
+
approvedScopes,
|
|
408
|
+
deniedScopes,
|
|
409
|
+
requestedAt: pending.requestedAt,
|
|
410
|
+
decidedAt,
|
|
411
|
+
},
|
|
412
|
+
}));
|
|
413
|
+
return {
|
|
414
|
+
connection: updated,
|
|
415
|
+
grantId,
|
|
416
|
+
grantedScopes,
|
|
417
|
+
approvedScopes,
|
|
418
|
+
deniedScopes,
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Scopes a replacement grant may keep: exactly what reads serve now
|
|
423
|
+
* (`narrowGrants`: the record and the live gateway grant must both cover a
|
|
424
|
+
* scope, wildcards included). Neither side alone is enough: the record can lag
|
|
425
|
+
* a lost commit, and the gateway can hold a scope the owner has since denied.
|
|
426
|
+
*/
|
|
427
|
+
function retainedScopes(connection, live) {
|
|
428
|
+
if (live.expiry.kind === "none")
|
|
429
|
+
return [];
|
|
430
|
+
return sortedUnique(narrowGrants(connection.grants, live.grants).flatMap((grant) => grant.scopes));
|
|
431
|
+
}
|
|
432
|
+
/** Register exact scopes, then commit only over the record version read before signing. */
|
|
433
|
+
async function writeConnectionGrantScopes(connection, exactScopes, options, liveState, finish = (record) => record) {
|
|
434
|
+
// Approve and edit pass the snapshot their scopes came from, so the version
|
|
435
|
+
// and expiry signed match it (never a newer re-read).
|
|
436
|
+
const live = liveState ??
|
|
437
|
+
(await readLiveGrantState(connection, options.gateway, options.now));
|
|
438
|
+
// Approve and edit sign record ∩ live gateway plus the approved scopes; the
|
|
439
|
+
// whole array must still be storable, before any gateway call or store write.
|
|
440
|
+
try {
|
|
441
|
+
assertStorableScopes(exactScopes);
|
|
442
|
+
}
|
|
443
|
+
catch (err) {
|
|
444
|
+
if (err instanceof McpInvalidScopeError) {
|
|
445
|
+
throw new McpScopeRequestError("INVALID_SCOPE", err.message, 400);
|
|
446
|
+
}
|
|
447
|
+
throw err;
|
|
448
|
+
}
|
|
449
|
+
// Keep the live grant's expiry so approval never extends it (a perpetual
|
|
450
|
+
// live grant stays perpetual). Only a connection with no live grant gets
|
|
451
|
+
// the default lifetime from now.
|
|
452
|
+
const expiresAt = live.expiry.kind === "inherit"
|
|
453
|
+
? live.expiry.expiresAt
|
|
454
|
+
: mcpGrantDefaultExpiry(options.grantTtlSeconds, options.now);
|
|
455
|
+
let grantResult;
|
|
456
|
+
try {
|
|
457
|
+
grantResult = await createGrantContract({
|
|
458
|
+
gateway: options.gateway,
|
|
459
|
+
serverOwner: options.serverOwner,
|
|
460
|
+
serverSigner: options.serverSigner,
|
|
461
|
+
body: {
|
|
462
|
+
granteeAddress: connection.granteeAddress,
|
|
463
|
+
scopes: exactScopes,
|
|
464
|
+
grantVersion: live.nextGrantVersion,
|
|
465
|
+
...(expiresAt !== undefined ? { expiresAt } : {}),
|
|
466
|
+
},
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
catch (err) {
|
|
470
|
+
throw new McpScopeRequestError(err instanceof McpGrantRegistrationError && err.retryable
|
|
471
|
+
? "RETRY"
|
|
472
|
+
: "GRANT_CREATION_FAILED", err instanceof Error ? err.message : String(err), err instanceof McpGrantRegistrationError && err.retryable ? 409 : 502);
|
|
473
|
+
}
|
|
474
|
+
if (!grantResult.ok) {
|
|
475
|
+
throw new McpScopeRequestError(grantResult.status === 409 ? "RETRY" : "GRANT_CREATION_FAILED", extractGrantErrorMessage(grantResult.body), grantResult.status >= 500 ? 502 : grantResult.status === 409 ? 409 : 400, grantResult.body);
|
|
476
|
+
}
|
|
477
|
+
const grantId = grantResult.body.grantId;
|
|
478
|
+
if (!grantId) {
|
|
479
|
+
throw new McpScopeRequestError("GRANT_CREATION_FAILED", "Gateway did not return a grant id.", 502, grantResult.body);
|
|
480
|
+
}
|
|
481
|
+
const updated = await options.store.mutate(connection.id, (latest) => {
|
|
482
|
+
if ((latest.revision ?? 0) !== (connection.revision ?? 0) ||
|
|
483
|
+
mcpConnectionStateView(latest) !== mcpConnectionStateView(connection)) {
|
|
484
|
+
throw new McpScopeRequestError("CONCURRENT_UPDATE", "The connection changed during the grant write; retry.", 409);
|
|
485
|
+
}
|
|
486
|
+
return finish({ ...latest, grants: [{ grantId, scopes: exactScopes }] });
|
|
487
|
+
});
|
|
488
|
+
if (!updated)
|
|
489
|
+
throw new McpConnectionNotFoundError(connection.id);
|
|
490
|
+
return { connection: updated, grantId };
|
|
491
|
+
}
|
|
492
|
+
/** Owner replaces an approved connection's access with a non-empty subset. */
|
|
493
|
+
export async function editMcpConnectionAccess(input, options) {
|
|
494
|
+
const connection = await options.store.getById(input.connectionId);
|
|
495
|
+
if (!connection)
|
|
496
|
+
throw new McpConnectionNotFoundError(input.connectionId);
|
|
497
|
+
if (connection.status !== "approved") {
|
|
498
|
+
throw new McpConnectionStateError(connection.id, connection.status, "approved");
|
|
499
|
+
}
|
|
500
|
+
if (!Array.isArray(input.scopes) ||
|
|
501
|
+
input.scopes.length === 0 ||
|
|
502
|
+
!input.scopes.every((scope) => typeof scope === "string" && scope.length > 0)) {
|
|
503
|
+
throw new McpScopeRequestError("INVALID_SCOPE", "Provide a non-empty scopes array. Use Disconnect to remove all access.");
|
|
504
|
+
}
|
|
505
|
+
const scopes = sortedUnique(input.scopes);
|
|
506
|
+
const stored = sortedUnique(connection.grants.flatMap((grant) => grant.scopes));
|
|
507
|
+
if (scopes.some((scope) => !stored.includes(scope))) {
|
|
508
|
+
throw new McpScopeRequestError("INVALID_SCOPE", "Edits may only remove stored scopes. Request access to add a scope.");
|
|
509
|
+
}
|
|
510
|
+
if (JSON.stringify(scopes) === JSON.stringify(stored))
|
|
511
|
+
return connection;
|
|
512
|
+
// The stored grant can lag the gateway (a gateway write accepted, the local
|
|
513
|
+
// commit lost). Judge the edit against the gateway's scopes at the version
|
|
514
|
+
// the write will advance past: the gateway's version check then guarantees
|
|
515
|
+
// nothing lands in between, so an edit can never re-sign a removed scope.
|
|
516
|
+
const live = await readLiveGrantState(connection, options.gateway, options.now);
|
|
517
|
+
const effective = retainedScopes(connection, live);
|
|
518
|
+
if (scopes.some((scope) => !effective.includes(scope))) {
|
|
519
|
+
throw new McpScopeRequestError("RETRY", "The connection's access changed on the gateway. Refresh and try again.", 409);
|
|
520
|
+
}
|
|
521
|
+
return (await writeConnectionGrantScopes(connection, scopes, options, live))
|
|
522
|
+
.connection;
|
|
523
|
+
}
|
|
524
|
+
/** Owner declines the pending request; the decision stays for the client. */
|
|
525
|
+
export async function denyMcpScopeAccessRequest(input, options) {
|
|
526
|
+
const decidedAt = nowIso(options.now);
|
|
527
|
+
const updated = await options.store.mutate(input.connectionId, (latest) => {
|
|
528
|
+
const pending = requirePendingScopeRequest(latest);
|
|
529
|
+
const decision = {
|
|
530
|
+
decision: "denied",
|
|
531
|
+
approvedScopes: [],
|
|
532
|
+
deniedScopes: pending.scopes,
|
|
533
|
+
requestedAt: pending.requestedAt,
|
|
534
|
+
decidedAt,
|
|
535
|
+
};
|
|
536
|
+
return {
|
|
537
|
+
...latest,
|
|
538
|
+
scopeAccessRequest: undefined,
|
|
539
|
+
scopeAccessDecision: decision,
|
|
540
|
+
};
|
|
127
541
|
});
|
|
128
542
|
if (!updated)
|
|
129
543
|
throw new McpConnectionNotFoundError(input.connectionId);
|
|
130
544
|
return updated;
|
|
131
545
|
}
|
|
546
|
+
function requirePendingScopeRequest(connection) {
|
|
547
|
+
if (connection.status !== "approved") {
|
|
548
|
+
throw new McpConnectionStateError(connection.id, connection.status, "approved");
|
|
549
|
+
}
|
|
550
|
+
const pending = connection.scopeAccessRequest;
|
|
551
|
+
if (!pending || pending.scopes.length === 0) {
|
|
552
|
+
throw new McpScopeRequestError("NO_PENDING_REQUEST", `mcp connection ${connection.id} has no pending scope request`, 409);
|
|
553
|
+
}
|
|
554
|
+
return pending;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* A scope the owner may approve on a connection: a read scope the SDK accepts,
|
|
558
|
+
* or `write:` plus one concrete agent-memory scope (`memory.<app>`, never a
|
|
559
|
+
* wildcard). MCP clients only ever write memories.
|
|
560
|
+
*/
|
|
561
|
+
function isApprovableScope(scope) {
|
|
562
|
+
if (isPhysicalScope(scope))
|
|
563
|
+
return false;
|
|
564
|
+
if (!isWriteScopeEntry(scope)) {
|
|
565
|
+
return (ScopeSchema.safeParse(scope).success || streamReadScope(scope) === scope);
|
|
566
|
+
}
|
|
567
|
+
const target = scope.slice(WRITE_SCOPE_PREFIX.length);
|
|
568
|
+
return (!target.includes("*") &&
|
|
569
|
+
!isSystemScope(target) &&
|
|
570
|
+
isMemoryScope(target) &&
|
|
571
|
+
ScopeSchema.safeParse(target).success);
|
|
572
|
+
}
|
|
573
|
+
function parseApprovedScopes(value, pending) {
|
|
574
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
575
|
+
throw new McpScopeRequestError("SCOPES_REQUIRED", "Approve requires a non-empty scopes array; use deny to decline all.");
|
|
576
|
+
}
|
|
577
|
+
const scopes = [];
|
|
578
|
+
for (const raw of value) {
|
|
579
|
+
const scope = typeof raw === "string" ? raw.trim() : "";
|
|
580
|
+
if (!isApprovableScope(scope)) {
|
|
581
|
+
throw new McpScopeRequestError("INVALID_SCOPE", `Invalid scope: ${JSON.stringify(raw)}`);
|
|
582
|
+
}
|
|
583
|
+
if (!pending.scopes.includes(scope)) {
|
|
584
|
+
throw new McpScopeRequestError("SCOPE_NOT_REQUESTED", `Scope ${scope} is not part of the pending request`);
|
|
585
|
+
}
|
|
586
|
+
if (!scopes.includes(scope))
|
|
587
|
+
scopes.push(scope);
|
|
588
|
+
}
|
|
589
|
+
return scopes.sort();
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* Read what the gateway holds for this connection's grantee: the scopes the
|
|
593
|
+
* replacement grant must keep, the version counter it must advance past, and
|
|
594
|
+
* the expiry it must not outlive. A revoked grant contributes its version but
|
|
595
|
+
* no scopes, so approval never resurrects access the owner already pulled.
|
|
596
|
+
*/
|
|
597
|
+
async function readLiveGrantState(connection, gateway, now) {
|
|
598
|
+
const grantIds = sortedUnique(connection.grants.map((grant) => grant.grantId));
|
|
599
|
+
let maxVersion = 0n;
|
|
600
|
+
let anyLive = false;
|
|
601
|
+
let anyPerpetual = false;
|
|
602
|
+
let expiresAt;
|
|
603
|
+
const looked = [];
|
|
604
|
+
for (const grantId of grantIds) {
|
|
605
|
+
let live;
|
|
606
|
+
try {
|
|
607
|
+
live = await gateway.getGrant(grantId);
|
|
608
|
+
}
|
|
609
|
+
catch (err) {
|
|
610
|
+
throw new McpScopeRequestError("GATEWAY_UNAVAILABLE", `Could not read grant ${grantId}: ${err instanceof Error ? err.message : String(err)}`, 502);
|
|
611
|
+
}
|
|
612
|
+
if (!live)
|
|
613
|
+
continue;
|
|
614
|
+
const version = parseUint(live.grantVersion);
|
|
615
|
+
if (version !== null && version > maxVersion)
|
|
616
|
+
maxVersion = version;
|
|
617
|
+
looked.push({ grantId, live });
|
|
618
|
+
}
|
|
619
|
+
// One clock reading after ALL the lookups: a grant that expired while a
|
|
620
|
+
// later lookup ran must not pass its scopes on. Only a grant that is live
|
|
621
|
+
// now does; a revoked, expired or missing one counts as never granted.
|
|
622
|
+
const nowSeconds = Math.floor(nowMs(now) / 1000);
|
|
623
|
+
const liveGrants = [];
|
|
624
|
+
for (const { grantId, live } of looked) {
|
|
625
|
+
if (live.revokedAt || isGrantExpired(live, nowSeconds))
|
|
626
|
+
continue;
|
|
627
|
+
const liveExpiry = parseExpirySeconds(live.expiresAt);
|
|
628
|
+
liveGrants.push({ grantId, scopes: [...live.scopes] });
|
|
629
|
+
anyLive = true;
|
|
630
|
+
if (liveExpiry === undefined) {
|
|
631
|
+
anyPerpetual = true;
|
|
632
|
+
}
|
|
633
|
+
else {
|
|
634
|
+
expiresAt =
|
|
635
|
+
expiresAt === undefined ? liveExpiry : Math.max(expiresAt, liveExpiry);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return {
|
|
639
|
+
grants: liveGrants,
|
|
640
|
+
nextGrantVersion: (maxVersion + 1n).toString(),
|
|
641
|
+
expiry: !anyLive
|
|
642
|
+
? { kind: "none" }
|
|
643
|
+
: anyPerpetual
|
|
644
|
+
? { kind: "inherit" }
|
|
645
|
+
: { kind: "inherit", expiresAt },
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
function parseUint(value) {
|
|
649
|
+
if (typeof value !== "string" || !/^\d+$/u.test(value))
|
|
650
|
+
return null;
|
|
651
|
+
return BigInt(value);
|
|
652
|
+
}
|
|
653
|
+
/** Parsed as already expired: anything we cannot read is never "perpetual". */
|
|
654
|
+
const EXPIRED_AT_SECONDS = 0;
|
|
655
|
+
/** Unix seconds above this (year 5138) are really milliseconds. */
|
|
656
|
+
const MAX_UNIX_SECONDS = 1e11;
|
|
657
|
+
const ISO_DATE_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})$/u;
|
|
658
|
+
/**
|
|
659
|
+
* The gateway's expiry (data-gateway lib/grants.ts: `expiresAt` is an ISO 8601
|
|
660
|
+
* string or null; the uint256 form is unix seconds, "0" meaning no expiry), as
|
|
661
|
+
* unix seconds. `undefined` is perpetual and only null, undefined or "0" give
|
|
662
|
+
* it. Anything unreadable fails closed as already expired.
|
|
663
|
+
*/
|
|
664
|
+
function parseExpirySeconds(value) {
|
|
665
|
+
if (value === null || value === undefined)
|
|
666
|
+
return undefined;
|
|
667
|
+
if (typeof value !== "string")
|
|
668
|
+
return EXPIRED_AT_SECONDS;
|
|
669
|
+
if (/^\d+$/u.test(value)) {
|
|
670
|
+
const seconds = Number(value);
|
|
671
|
+
if (seconds === 0)
|
|
672
|
+
return undefined;
|
|
673
|
+
return Number.isFinite(seconds) && seconds <= MAX_UNIX_SECONDS
|
|
674
|
+
? seconds
|
|
675
|
+
: EXPIRED_AT_SECONDS;
|
|
676
|
+
}
|
|
677
|
+
const ms = ISO_DATE_TIME.test(value) ? Date.parse(value) : Number.NaN;
|
|
678
|
+
return Number.isFinite(ms) ? Math.floor(ms / 1000) : EXPIRED_AT_SECONDS;
|
|
679
|
+
}
|
|
680
|
+
/** The one expiry rule: the gateway's `expired` flag, or `expiresAt` reached. */
|
|
681
|
+
export function isGrantExpired(grant, nowSeconds) {
|
|
682
|
+
const expiresAt = parseExpirySeconds(grant.expiresAt);
|
|
683
|
+
return (Boolean(grant.expired) ||
|
|
684
|
+
(expiresAt !== undefined && expiresAt <= nowSeconds));
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* The connection's grants that are still live at the gateway (present, not
|
|
688
|
+
* revoked, not expired), each with the scopes the gateway holds for it now.
|
|
689
|
+
* Looked up in parallel, one `getGrant` per grant. Not approved, no grants, or
|
|
690
|
+
* any failed lookup gives none, so callers fail closed. A connection token
|
|
691
|
+
* outlives its grants, so a feature that reveals data must check this first
|
|
692
|
+
* and cut the stored scopes down with `narrowGrants`.
|
|
693
|
+
*/
|
|
694
|
+
export async function liveMcpGrants(connection, gateway, now = () => new Date()) {
|
|
695
|
+
const grantIds = sortedUnique(connection.grants.map((grant) => grant.grantId));
|
|
696
|
+
if (connection.status !== "approved")
|
|
697
|
+
return [];
|
|
698
|
+
// No gateway means no authority to say a grant still stands: no grants.
|
|
699
|
+
if (!gateway)
|
|
700
|
+
return [];
|
|
701
|
+
try {
|
|
702
|
+
const looked = await Promise.all(grantIds.map(async (grantId) => ({
|
|
703
|
+
grantId,
|
|
704
|
+
live: await gateway.getGrant(grantId),
|
|
705
|
+
})));
|
|
706
|
+
// One clock reading after ALL the lookups: a grant that expired while a
|
|
707
|
+
// later lookup ran is not live.
|
|
708
|
+
const nowSeconds = Math.floor(now().getTime() / 1000);
|
|
709
|
+
return looked.flatMap(({ grantId, live }) => !live || live.revokedAt || isGrantExpired(live, nowSeconds)
|
|
710
|
+
? []
|
|
711
|
+
: [{ grantId, scopes: [...live.scopes] }]);
|
|
712
|
+
}
|
|
713
|
+
catch {
|
|
714
|
+
return [];
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
/** True when the connection has grants and every one is live. */
|
|
718
|
+
export async function areMcpConnectionGrantsLive(connection, gateway, now = () => new Date()) {
|
|
719
|
+
const live = await liveMcpGrants(connection, gateway, now);
|
|
720
|
+
return (live.length > 0 &&
|
|
721
|
+
live.length === sortedUnique(connection.grants.map((g) => g.grantId)).length);
|
|
722
|
+
}
|
|
723
|
+
function sortedUnique(values) {
|
|
724
|
+
return Array.from(new Set(values)).sort();
|
|
725
|
+
}
|
|
132
726
|
export async function revokeMcpConnection(connectionId, options) {
|
|
133
727
|
const existing = await options.store.getById(connectionId);
|
|
134
728
|
if (!existing)
|
|
@@ -136,14 +730,25 @@ export async function revokeMcpConnection(connectionId, options) {
|
|
|
136
730
|
if (existing.status === "revoked")
|
|
137
731
|
return existing;
|
|
138
732
|
const revokedAt = nowIso(options.now);
|
|
733
|
+
// The refresh token outlives the access token by weeks, so a revoke that
|
|
734
|
+
// left it in place would hand the holder a fresh bearer minutes later.
|
|
139
735
|
const updated = await options.store.update(connectionId, {
|
|
140
736
|
status: "revoked",
|
|
141
737
|
revokedAt,
|
|
738
|
+
...CLEARED_REFRESH_FAMILY,
|
|
142
739
|
});
|
|
143
740
|
if (!updated)
|
|
144
741
|
throw new McpConnectionNotFoundError(connectionId);
|
|
145
742
|
return updated;
|
|
146
743
|
}
|
|
744
|
+
/** A scope request without its read token, for anything that leaves the server. */
|
|
745
|
+
export function toMcpScopeAccessRequestView(request) {
|
|
746
|
+
return {
|
|
747
|
+
scopes: request.scopes,
|
|
748
|
+
...(request.reason !== undefined ? { reason: request.reason } : {}),
|
|
749
|
+
requestedAt: request.requestedAt,
|
|
750
|
+
};
|
|
751
|
+
}
|
|
147
752
|
export function toMcpConnectionView(record) {
|
|
148
753
|
return {
|
|
149
754
|
id: record.id,
|
|
@@ -151,16 +756,30 @@ export function toMcpConnectionView(record) {
|
|
|
151
756
|
granteeAddress: record.granteeAddress,
|
|
152
757
|
status: record.status,
|
|
153
758
|
grants: record.grants,
|
|
759
|
+
grantedScopes: sortedUnique(record.grants.flatMap((grant) => grant.scopes)),
|
|
760
|
+
scopeAccessRequest: record.scopeAccessRequest
|
|
761
|
+
? toMcpScopeAccessRequestView(record.scopeAccessRequest)
|
|
762
|
+
: undefined,
|
|
763
|
+
scopeAccessDecision: record.scopeAccessDecision,
|
|
154
764
|
createdAt: record.createdAt,
|
|
155
765
|
approvedAt: record.approvedAt,
|
|
156
766
|
revokedAt: record.revokedAt,
|
|
157
767
|
lastUsedAt: record.lastUsedAt,
|
|
158
768
|
};
|
|
159
769
|
}
|
|
770
|
+
/** One connection as the owner sees it; throws when the id is unknown. */
|
|
771
|
+
export async function getMcpConnectionView(connectionId, store) {
|
|
772
|
+
const record = await store.getById(connectionId);
|
|
773
|
+
if (!record)
|
|
774
|
+
throw new McpConnectionNotFoundError(connectionId);
|
|
775
|
+
return toMcpConnectionView(record);
|
|
776
|
+
}
|
|
160
777
|
export async function listMcpConnectionViews(store) {
|
|
161
778
|
const records = await store.list();
|
|
162
779
|
return records.map(toMcpConnectionView);
|
|
163
780
|
}
|
|
781
|
+
/** Connection label when the client never told this server its name. */
|
|
782
|
+
const DEFAULT_MCP_CLIENT_NAME = "MCP client";
|
|
164
783
|
export class McpOAuthAuthorizationError extends Error {
|
|
165
784
|
code;
|
|
166
785
|
status;
|
|
@@ -173,6 +792,27 @@ export class McpOAuthAuthorizationError extends Error {
|
|
|
173
792
|
this.name = "McpOAuthAuthorizationError";
|
|
174
793
|
}
|
|
175
794
|
}
|
|
795
|
+
/** A scope no grant may store. A 400 on every route that stores scopes. */
|
|
796
|
+
export class McpInvalidScopeError extends McpOAuthAuthorizationError {
|
|
797
|
+
constructor(scope) {
|
|
798
|
+
super("invalid_scope", `Invalid scope: ${JSON.stringify(scope)}`);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* The one check for scopes about to be stored on a connection, whichever
|
|
803
|
+
* route they arrive by. A read entry must name something (never blank or a
|
|
804
|
+
* bare "*"); a `write:` entry must be one concrete memory scope.
|
|
805
|
+
*/
|
|
806
|
+
export function assertStorableScopes(scopes) {
|
|
807
|
+
for (const scope of scopes) {
|
|
808
|
+
const bad = typeof scope !== "string" ||
|
|
809
|
+
scope.trim() === "" ||
|
|
810
|
+
scope === "*" ||
|
|
811
|
+
(isWriteScopeEntry(scope) && !isApprovableScope(scope));
|
|
812
|
+
if (bad)
|
|
813
|
+
throw new McpInvalidScopeError(scope);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
176
816
|
export async function createMcpOAuthAuthorization(input, options) {
|
|
177
817
|
if (!input.clientId.trim()) {
|
|
178
818
|
throw new McpOAuthAuthorizationError("invalid_client", "client_id is required");
|
|
@@ -180,6 +820,9 @@ export async function createMcpOAuthAuthorization(input, options) {
|
|
|
180
820
|
if (!input.redirectUri.trim()) {
|
|
181
821
|
throw new McpOAuthAuthorizationError("invalid_request", "redirect_uri is required");
|
|
182
822
|
}
|
|
823
|
+
if (!isAllowedOAuthRedirectUri(input.redirectUri)) {
|
|
824
|
+
throw new McpOAuthAuthorizationError("invalid_request", "redirect_uri is not an allowed redirect URI");
|
|
825
|
+
}
|
|
183
826
|
if (!input.codeChallenge.trim()) {
|
|
184
827
|
throw new McpOAuthAuthorizationError("invalid_request", "code_challenge is required");
|
|
185
828
|
}
|
|
@@ -188,15 +831,21 @@ export async function createMcpOAuthAuthorization(input, options) {
|
|
|
188
831
|
}
|
|
189
832
|
const now = options.now ? options.now() : new Date();
|
|
190
833
|
const expiresAt = new Date(now.getTime() + OAUTH_AUTHORIZATION_TTL_MS).toISOString();
|
|
191
|
-
const
|
|
192
|
-
|
|
834
|
+
const { record: connection, output: created } = await buildMcpConnection({
|
|
835
|
+
displayName: input.clientName ?? DEFAULT_MCP_CLIENT_NAME,
|
|
836
|
+
ingress: input.ingress,
|
|
837
|
+
clientId: input.clientId,
|
|
838
|
+
}, {
|
|
193
839
|
publicOrigin: options.publicOrigin,
|
|
194
840
|
now: () => now,
|
|
195
841
|
});
|
|
842
|
+
await replacePendingOAuthConnections(options.connectionStore, input.clientId, now.getTime() - OAUTH_AUTHORIZATION_TTL_MS, connection);
|
|
196
843
|
const authorizationId = randomId();
|
|
197
844
|
const record = {
|
|
198
845
|
id: authorizationId,
|
|
199
846
|
clientId: input.clientId,
|
|
847
|
+
...(input.clientName ? { clientName: input.clientName } : {}),
|
|
848
|
+
...(input.clientUri ? { clientUri: input.clientUri } : {}),
|
|
200
849
|
redirectUri: input.redirectUri,
|
|
201
850
|
codeChallenge: input.codeChallenge,
|
|
202
851
|
codeChallengeMethod: "S256",
|
|
@@ -216,10 +865,45 @@ export async function createMcpOAuthAuthorization(input, options) {
|
|
|
216
865
|
expiresAt,
|
|
217
866
|
};
|
|
218
867
|
}
|
|
868
|
+
async function replacePendingOAuthConnections(store, clientId, expiredBefore, replacement) {
|
|
869
|
+
if (store.replacePendingOAuthConnections) {
|
|
870
|
+
await store.replacePendingOAuthConnections(clientId, expiredBefore, replacement);
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
const previous = pendingOAuthReplacements.get(store) ?? Promise.resolve();
|
|
874
|
+
const operation = previous.then(async () => {
|
|
875
|
+
for (const connection of await store.list()) {
|
|
876
|
+
const expired = Date.parse(connection.createdAt) <= expiredBefore;
|
|
877
|
+
if (connection.status !== "pending" ||
|
|
878
|
+
!connection.clientId ||
|
|
879
|
+
(connection.clientId !== clientId && !expired)) {
|
|
880
|
+
continue;
|
|
881
|
+
}
|
|
882
|
+
await store.mutate(connection.id, (latest) => latest.status === "pending"
|
|
883
|
+
? {
|
|
884
|
+
...latest,
|
|
885
|
+
status: "revoked",
|
|
886
|
+
revokedAt: replacement.createdAt,
|
|
887
|
+
}
|
|
888
|
+
: latest);
|
|
889
|
+
}
|
|
890
|
+
await store.create(replacement);
|
|
891
|
+
});
|
|
892
|
+
pendingOAuthReplacements.set(store, operation.then(() => undefined, () => undefined));
|
|
893
|
+
await operation;
|
|
894
|
+
}
|
|
895
|
+
/** A superseded or removed authorization has a revoked connection; refuse it. */
|
|
896
|
+
function requireLive(connection) {
|
|
897
|
+
if (connection?.status !== "revoked")
|
|
898
|
+
return;
|
|
899
|
+
throw new McpOAuthAuthorizationError("invalid_state", "MCP OAuth authorization was superseded or removed; connect again");
|
|
900
|
+
}
|
|
219
901
|
export function toMcpOAuthAuthorizationView(record) {
|
|
220
902
|
return {
|
|
221
903
|
id: record.id,
|
|
222
904
|
clientId: record.clientId,
|
|
905
|
+
...(record.clientName ? { clientName: record.clientName } : {}),
|
|
906
|
+
...(record.clientUri ? { clientUri: record.clientUri } : {}),
|
|
223
907
|
redirectUri: record.redirectUri,
|
|
224
908
|
...(record.scope ? { scope: record.scope } : {}),
|
|
225
909
|
...(record.state ? { state: record.state } : {}),
|
|
@@ -245,6 +929,7 @@ export async function approveMcpOAuthAuthorization(input, options) {
|
|
|
245
929
|
if (input.grants.length === 0) {
|
|
246
930
|
throw new McpOAuthAuthorizationError("grants_required", "Approve requires at least one grant");
|
|
247
931
|
}
|
|
932
|
+
requireLive(await options.connectionStore.getById(record.connectionId));
|
|
248
933
|
await approveMcpConnection({ connectionId: record.connectionId, grants: input.grants }, { store: options.connectionStore, now: options.now });
|
|
249
934
|
const authorizationCode = randomToken();
|
|
250
935
|
const authorizationCodeHash = await hashMcpOAuthAuthorizationCode(authorizationCode);
|
|
@@ -269,10 +954,16 @@ export async function approveMcpOAuthAuthorizationWithScopes(input, options) {
|
|
|
269
954
|
if (!Array.isArray(input.scopes) || input.scopes.length === 0) {
|
|
270
955
|
throw new McpOAuthAuthorizationError("scopes_required", "Approve requires at least one scope");
|
|
271
956
|
}
|
|
957
|
+
// Read entries are signed as before. A `write:` entry follows the same rule
|
|
958
|
+
// as a scope-request approval: one concrete scope, never a wildcard, since
|
|
959
|
+
// `remember` makes a write grant on this connection usable.
|
|
960
|
+
// A bare "*" or an empty entry names no source; it must never be stored.
|
|
961
|
+
assertStorableScopes(input.scopes);
|
|
272
962
|
const connection = await options.connectionStore.getById(record.connectionId);
|
|
273
963
|
if (!connection) {
|
|
274
964
|
throw new McpOAuthAuthorizationError("connection_not_found", `mcp connection ${record.connectionId} not found`, 404);
|
|
275
965
|
}
|
|
966
|
+
requireLive(connection);
|
|
276
967
|
try {
|
|
277
968
|
await ensureMcpGranteeRegistered({
|
|
278
969
|
connection,
|
|
@@ -289,6 +980,8 @@ export async function approveMcpOAuthAuthorizationWithScopes(input, options) {
|
|
|
289
980
|
}
|
|
290
981
|
throw err;
|
|
291
982
|
}
|
|
983
|
+
const expiresAt = input.expiresAt ??
|
|
984
|
+
mcpGrantDefaultExpiry(options.grantTtlSeconds, options.now);
|
|
292
985
|
const grantResult = await createGrantContract({
|
|
293
986
|
gateway: options.gateway,
|
|
294
987
|
serverOwner: options.serverOwner,
|
|
@@ -296,7 +989,7 @@ export async function approveMcpOAuthAuthorizationWithScopes(input, options) {
|
|
|
296
989
|
body: {
|
|
297
990
|
granteeAddress: connection.granteeAddress,
|
|
298
991
|
scopes: input.scopes,
|
|
299
|
-
...(
|
|
992
|
+
...(expiresAt !== undefined ? { expiresAt } : {}),
|
|
300
993
|
...(input.nonce !== undefined ? { nonce: input.nonce } : {}),
|
|
301
994
|
},
|
|
302
995
|
});
|
|
@@ -309,7 +1002,12 @@ export async function approveMcpOAuthAuthorizationWithScopes(input, options) {
|
|
|
309
1002
|
}
|
|
310
1003
|
return approveMcpOAuthAuthorization({
|
|
311
1004
|
authorizationId: input.authorizationId,
|
|
312
|
-
grants: [
|
|
1005
|
+
grants: [
|
|
1006
|
+
{
|
|
1007
|
+
grantId,
|
|
1008
|
+
scopes: input.scopes,
|
|
1009
|
+
},
|
|
1010
|
+
],
|
|
313
1011
|
}, options);
|
|
314
1012
|
}
|
|
315
1013
|
export async function redeemMcpOAuthAuthorizationCode(input, options) {
|
|
@@ -337,12 +1035,12 @@ export async function redeemMcpOAuthAuthorizationCode(input, options) {
|
|
|
337
1035
|
}))) {
|
|
338
1036
|
throw new McpOAuthAuthorizationError("invalid_grant", "PKCE verification failed");
|
|
339
1037
|
}
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
});
|
|
345
|
-
if (!
|
|
1038
|
+
const issued = await issueMcpTokenPair({
|
|
1039
|
+
connectionId: record.connectionId,
|
|
1040
|
+
clientId: record.clientId,
|
|
1041
|
+
issuedAtMs: nowMs(options.now),
|
|
1042
|
+
}, options.connectionStore);
|
|
1043
|
+
if (!issued) {
|
|
346
1044
|
throw new McpOAuthAuthorizationError("invalid_grant", "MCP connection for authorization no longer exists");
|
|
347
1045
|
}
|
|
348
1046
|
await options.authorizationStore.update(record.id, {
|
|
@@ -350,10 +1048,77 @@ export async function redeemMcpOAuthAuthorizationCode(input, options) {
|
|
|
350
1048
|
redeemedAt: (options.now ? options.now() : new Date()).toISOString(),
|
|
351
1049
|
});
|
|
352
1050
|
return {
|
|
353
|
-
|
|
1051
|
+
...issued,
|
|
354
1052
|
...(record.scope ? { scope: record.scope } : {}),
|
|
355
1053
|
};
|
|
356
1054
|
}
|
|
1055
|
+
/**
|
|
1056
|
+
* RFC 6749 §6 refresh grant with RFC 9700 §4.14.2 rotation: every exchange
|
|
1057
|
+
* mints a new pair and retires the presented refresh token, so the MCP client
|
|
1058
|
+
* renews silently instead of re-consenting once an hour.
|
|
1059
|
+
*/
|
|
1060
|
+
export async function refreshMcpOAuthToken(input, options) {
|
|
1061
|
+
const presentedHash = await hashMcpRefreshToken(input.refreshToken);
|
|
1062
|
+
const connection = await options.connectionStore.getByRefreshTokenHash(presentedHash);
|
|
1063
|
+
if (!connection) {
|
|
1064
|
+
throw new McpOAuthAuthorizationError("invalid_grant", "Unknown MCP refresh token");
|
|
1065
|
+
}
|
|
1066
|
+
// Reuse detection. A rotated-out token still matching means two holders have
|
|
1067
|
+
// the family — the legitimate client and a thief — and we cannot tell which
|
|
1068
|
+
// one is calling, so the whole family dies. The access token keeps its own
|
|
1069
|
+
// expiry: cutting it short would only punish the client that behaved.
|
|
1070
|
+
if (connection.refreshTokenHash !== presentedHash) {
|
|
1071
|
+
await options.connectionStore.update(connection.id, CLEARED_REFRESH_FAMILY);
|
|
1072
|
+
throw new McpOAuthAuthorizationError("invalid_grant", "MCP refresh token was already rotated; the refresh family is revoked");
|
|
1073
|
+
}
|
|
1074
|
+
if (connection.status !== "approved") {
|
|
1075
|
+
throw new McpOAuthAuthorizationError("invalid_grant", "MCP connection is not approved");
|
|
1076
|
+
}
|
|
1077
|
+
if (connection.clientId !== input.clientId) {
|
|
1078
|
+
throw new McpOAuthAuthorizationError("invalid_grant", "client_id does not match the issued refresh token");
|
|
1079
|
+
}
|
|
1080
|
+
if (isMcpRefreshExpired(connection, nowMs(options.now))) {
|
|
1081
|
+
throw new McpOAuthAuthorizationError("invalid_grant", "MCP refresh token expired");
|
|
1082
|
+
}
|
|
1083
|
+
const issued = await issueMcpTokenPair({
|
|
1084
|
+
connectionId: connection.id,
|
|
1085
|
+
clientId: input.clientId,
|
|
1086
|
+
issuedAtMs: nowMs(options.now),
|
|
1087
|
+
retiredRefreshHash: presentedHash,
|
|
1088
|
+
}, options.connectionStore);
|
|
1089
|
+
if (!issued) {
|
|
1090
|
+
throw new McpOAuthAuthorizationError("invalid_grant", "MCP connection no longer exists");
|
|
1091
|
+
}
|
|
1092
|
+
return issued;
|
|
1093
|
+
}
|
|
1094
|
+
/**
|
|
1095
|
+
* Mint one access/refresh pair. The rotation is a single store `update`, so a
|
|
1096
|
+
* concurrent refresh either sees the old pair or the new one — never a
|
|
1097
|
+
* connection with the old refresh already dead and no new one issued.
|
|
1098
|
+
*/
|
|
1099
|
+
async function issueMcpTokenPair(input, store) {
|
|
1100
|
+
const accessToken = randomToken();
|
|
1101
|
+
const refreshToken = randomToken();
|
|
1102
|
+
const updated = await store.update(input.connectionId, {
|
|
1103
|
+
clientId: input.clientId,
|
|
1104
|
+
tokenHash: await hashConnectionToken(accessToken),
|
|
1105
|
+
tokenExpiresAt: mcpTokenExpiry(input.issuedAtMs),
|
|
1106
|
+
refreshTokenHash: await hashMcpRefreshToken(refreshToken),
|
|
1107
|
+
previousRefreshTokenHash: input.retiredRefreshHash,
|
|
1108
|
+
refreshExpiresAt: mcpRefreshExpiry(input.issuedAtMs),
|
|
1109
|
+
});
|
|
1110
|
+
if (!updated)
|
|
1111
|
+
return null;
|
|
1112
|
+
return {
|
|
1113
|
+
accessToken,
|
|
1114
|
+
refreshToken,
|
|
1115
|
+
expiresIn: Math.floor(MCP_TOKEN_TTL_MS / 1000),
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
/** Domain-separated so a refresh token can never resolve as a bearer. */
|
|
1119
|
+
async function hashMcpRefreshToken(token) {
|
|
1120
|
+
return hashConnectionToken(`mcp-oauth-refresh:${token}`);
|
|
1121
|
+
}
|
|
357
1122
|
async function hashMcpOAuthAuthorizationCode(code) {
|
|
358
1123
|
return hashConnectionToken(`mcp-oauth-code:${code}`);
|
|
359
1124
|
}
|