@ixo/decision-oracle 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +794 -2
- package/dist/act.d.ts +87 -0
- package/dist/act.d.ts.map +1 -0
- package/dist/act.js +20 -0
- package/dist/act.js.map +1 -0
- package/dist/app.d.ts +22 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +128 -0
- package/dist/app.js.map +1 -0
- package/dist/c2pa.wasm +0 -0
- package/dist/cli/commands/api.d.ts +50 -0
- package/dist/cli/commands/api.d.ts.map +1 -0
- package/dist/cli/commands/api.js +737 -0
- package/dist/cli/commands/api.js.map +1 -0
- package/dist/cli/commands/create-collection.d.ts +40 -0
- package/dist/cli/commands/create-collection.d.ts.map +1 -0
- package/dist/cli/commands/create-collection.js +318 -0
- package/dist/cli/commands/create-collection.js.map +1 -0
- package/dist/cli/commands/create-deed.d.ts +31 -0
- package/dist/cli/commands/create-deed.d.ts.map +1 -0
- package/dist/cli/commands/create-deed.js +208 -0
- package/dist/cli/commands/create-deed.js.map +1 -0
- package/dist/cli/commands/delegation.d.ts +26 -0
- package/dist/cli/commands/delegation.d.ts.map +1 -0
- package/dist/cli/commands/delegation.js +162 -0
- package/dist/cli/commands/delegation.js.map +1 -0
- package/dist/cli/commands/derive.d.ts +22 -0
- package/dist/cli/commands/derive.d.ts.map +1 -0
- package/dist/cli/commands/derive.js +53 -0
- package/dist/cli/commands/derive.js.map +1 -0
- package/dist/cli/commands/engine.d.ts +25 -0
- package/dist/cli/commands/engine.d.ts.map +1 -0
- package/dist/cli/commands/engine.js +107 -0
- package/dist/cli/commands/engine.js.map +1 -0
- package/dist/cli/commands/erase.d.ts +17 -0
- package/dist/cli/commands/erase.d.ts.map +1 -0
- package/dist/cli/commands/erase.js +117 -0
- package/dist/cli/commands/erase.js.map +1 -0
- package/dist/cli/commands/facts-run.d.ts +30 -0
- package/dist/cli/commands/facts-run.d.ts.map +1 -0
- package/dist/cli/commands/facts-run.js +409 -0
- package/dist/cli/commands/facts-run.js.map +1 -0
- package/dist/cli/commands/facts-scaffold.d.ts +22 -0
- package/dist/cli/commands/facts-scaffold.d.ts.map +1 -0
- package/dist/cli/commands/facts-scaffold.js +208 -0
- package/dist/cli/commands/facts-scaffold.js.map +1 -0
- package/dist/cli/commands/init.d.ts +18 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +34 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/login.d.ts +9 -0
- package/dist/cli/commands/login.d.ts.map +1 -0
- package/dist/cli/commands/login.js +16 -0
- package/dist/cli/commands/login.js.map +1 -0
- package/dist/cli/commands/logout.d.ts +10 -0
- package/dist/cli/commands/logout.d.ts.map +1 -0
- package/dist/cli/commands/logout.js +28 -0
- package/dist/cli/commands/logout.js.map +1 -0
- package/dist/cli/commands/manifest.d.ts +12 -0
- package/dist/cli/commands/manifest.d.ts.map +1 -0
- package/dist/cli/commands/manifest.js +48 -0
- package/dist/cli/commands/manifest.js.map +1 -0
- package/dist/cli/commands/oracle-init.d.ts +48 -0
- package/dist/cli/commands/oracle-init.d.ts.map +1 -0
- package/dist/cli/commands/oracle-init.js +1122 -0
- package/dist/cli/commands/oracle-init.js.map +1 -0
- package/dist/cli/commands/org.d.ts +28 -0
- package/dist/cli/commands/org.d.ts.map +1 -0
- package/dist/cli/commands/org.js +309 -0
- package/dist/cli/commands/org.js.map +1 -0
- package/dist/cli/commands/protocol-review.d.ts +20 -0
- package/dist/cli/commands/protocol-review.d.ts.map +1 -0
- package/dist/cli/commands/protocol-review.js +162 -0
- package/dist/cli/commands/protocol-review.js.map +1 -0
- package/dist/cli/commands/publish-protocol.d.ts +43 -0
- package/dist/cli/commands/publish-protocol.d.ts.map +1 -0
- package/dist/cli/commands/publish-protocol.js +345 -0
- package/dist/cli/commands/publish-protocol.js.map +1 -0
- package/dist/cli/commands/register.d.ts +16 -0
- package/dist/cli/commands/register.d.ts.map +1 -0
- package/dist/cli/commands/register.js +54 -0
- package/dist/cli/commands/register.js.map +1 -0
- package/dist/cli/commands/relink.d.ts +11 -0
- package/dist/cli/commands/relink.d.ts.map +1 -0
- package/dist/cli/commands/relink.js +36 -0
- package/dist/cli/commands/relink.js.map +1 -0
- package/dist/cli/commands/rubric-fetch-form.d.ts +16 -0
- package/dist/cli/commands/rubric-fetch-form.d.ts.map +1 -0
- package/dist/cli/commands/rubric-fetch-form.js +83 -0
- package/dist/cli/commands/rubric-fetch-form.js.map +1 -0
- package/dist/cli/commands/rubric-validate.d.ts +72 -0
- package/dist/cli/commands/rubric-validate.d.ts.map +1 -0
- package/dist/cli/commands/rubric-validate.js +163 -0
- package/dist/cli/commands/rubric-validate.js.map +1 -0
- package/dist/cli/commands/scan.d.ts +13 -0
- package/dist/cli/commands/scan.d.ts.map +1 -0
- package/dist/cli/commands/scan.js +39 -0
- package/dist/cli/commands/scan.js.map +1 -0
- package/dist/cli/commands/skills.d.ts +11 -0
- package/dist/cli/commands/skills.d.ts.map +1 -0
- package/dist/cli/commands/skills.js +19 -0
- package/dist/cli/commands/skills.js.map +1 -0
- package/dist/cli/commands/submit-claim.d.ts +25 -0
- package/dist/cli/commands/submit-claim.d.ts.map +1 -0
- package/dist/cli/commands/submit-claim.js +155 -0
- package/dist/cli/commands/submit-claim.js.map +1 -0
- package/dist/cli/index.d.ts +15 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +206 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/lib/agent-card-schema.d.ts +8 -0
- package/dist/cli/lib/agent-card-schema.d.ts.map +1 -0
- package/dist/cli/lib/agent-card-schema.js +169 -0
- package/dist/cli/lib/agent-card-schema.js.map +1 -0
- package/dist/cli/lib/ai-rest.d.ts +12 -0
- package/dist/cli/lib/ai-rest.d.ts.map +1 -0
- package/dist/cli/lib/ai-rest.js +36 -0
- package/dist/cli/lib/ai-rest.js.map +1 -0
- package/dist/cli/lib/args.d.ts +33 -0
- package/dist/cli/lib/args.d.ts.map +1 -0
- package/dist/cli/lib/args.js +24 -0
- package/dist/cli/lib/args.js.map +1 -0
- package/dist/cli/lib/authhub.d.ts +7 -0
- package/dist/cli/lib/authhub.d.ts.map +1 -0
- package/dist/cli/lib/authhub.js +210 -0
- package/dist/cli/lib/authhub.js.map +1 -0
- package/dist/cli/lib/chain.d.ts +264 -0
- package/dist/cli/lib/chain.d.ts.map +1 -0
- package/dist/cli/lib/chain.js +584 -0
- package/dist/cli/lib/chain.js.map +1 -0
- package/dist/cli/lib/devvars.d.ts +59 -0
- package/dist/cli/lib/devvars.d.ts.map +1 -0
- package/dist/cli/lib/devvars.js +206 -0
- package/dist/cli/lib/devvars.js.map +1 -0
- package/dist/cli/lib/engine.d.ts +54 -0
- package/dist/cli/lib/engine.d.ts.map +1 -0
- package/dist/cli/lib/engine.js +112 -0
- package/dist/cli/lib/engine.js.map +1 -0
- package/dist/cli/lib/identity-cards.d.ts +188 -0
- package/dist/cli/lib/identity-cards.d.ts.map +1 -0
- package/dist/cli/lib/identity-cards.js +261 -0
- package/dist/cli/lib/identity-cards.js.map +1 -0
- package/dist/cli/lib/matrix-account.d.ts +79 -0
- package/dist/cli/lib/matrix-account.d.ts.map +1 -0
- package/dist/cli/lib/matrix-account.js +228 -0
- package/dist/cli/lib/matrix-account.js.map +1 -0
- package/dist/cli/lib/oracle-account.d.ts +108 -0
- package/dist/cli/lib/oracle-account.d.ts.map +1 -0
- package/dist/cli/lib/oracle-account.js +207 -0
- package/dist/cli/lib/oracle-account.js.map +1 -0
- package/dist/cli/lib/project.d.ts +22 -0
- package/dist/cli/lib/project.d.ts.map +1 -0
- package/dist/cli/lib/project.js +62 -0
- package/dist/cli/lib/project.js.map +1 -0
- package/dist/cli/lib/session.d.ts +109 -0
- package/dist/cli/lib/session.d.ts.map +1 -0
- package/dist/cli/lib/session.js +354 -0
- package/dist/cli/lib/session.js.map +1 -0
- package/dist/cli/lib/workorder.d.ts +57 -0
- package/dist/cli/lib/workorder.d.ts.map +1 -0
- package/dist/cli/lib/workorder.js +101 -0
- package/dist/cli/lib/workorder.js.map +1 -0
- package/dist/config.d.ts +221 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +431 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +88 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +9 -0
- package/dist/context.js.map +1 -0
- package/dist/contracts/api.d.ts +3367 -0
- package/dist/contracts/api.d.ts.map +1 -0
- package/dist/contracts/api.js +1303 -0
- package/dist/contracts/api.js.map +1 -0
- package/dist/contracts/capabilities.d.ts +126 -0
- package/dist/contracts/capabilities.d.ts.map +1 -0
- package/dist/contracts/capabilities.js +164 -0
- package/dist/contracts/capabilities.js.map +1 -0
- package/dist/contracts/claim-source.d.ts +98 -0
- package/dist/contracts/claim-source.d.ts.map +1 -0
- package/dist/contracts/claim-source.js +17 -0
- package/dist/contracts/claim-source.js.map +1 -0
- package/dist/contracts/errors.d.ts +150 -0
- package/dist/contracts/errors.d.ts.map +1 -0
- package/dist/contracts/errors.js +121 -0
- package/dist/contracts/errors.js.map +1 -0
- package/dist/contracts/index.d.ts +15 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +11 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/payment-gate.d.ts +129 -0
- package/dist/contracts/payment-gate.d.ts.map +1 -0
- package/dist/contracts/payment-gate.js +24 -0
- package/dist/contracts/payment-gate.js.map +1 -0
- package/dist/contracts/start-api-claim.d.ts +90 -0
- package/dist/contracts/start-api-claim.d.ts.map +1 -0
- package/dist/contracts/start-api-claim.js +22 -0
- package/dist/contracts/start-api-claim.js.map +1 -0
- package/dist/contracts/webhooks.d.ts +1487 -0
- package/dist/contracts/webhooks.d.ts.map +1 -0
- package/dist/contracts/webhooks.js +71 -0
- package/dist/contracts/webhooks.js.map +1 -0
- package/dist/contracts/work-order.d.ts +29 -0
- package/dist/contracts/work-order.d.ts.map +1 -0
- package/dist/contracts/work-order.js +12 -0
- package/dist/contracts/work-order.js.map +1 -0
- package/dist/cron/ai-cost.d.ts +29 -0
- package/dist/cron/ai-cost.d.ts.map +1 -0
- package/dist/cron/ai-cost.js +80 -0
- package/dist/cron/ai-cost.js.map +1 -0
- package/dist/cron/api-lane.d.ts +39 -0
- package/dist/cron/api-lane.d.ts.map +1 -0
- package/dist/cron/api-lane.js +203 -0
- package/dist/cron/api-lane.js.map +1 -0
- package/dist/cron/backlog.d.ts +50 -0
- package/dist/cron/backlog.d.ts.map +1 -0
- package/dist/cron/backlog.js +115 -0
- package/dist/cron/backlog.js.map +1 -0
- package/dist/cron/billing.d.ts +11 -0
- package/dist/cron/billing.d.ts.map +1 -0
- package/dist/cron/billing.js +69 -0
- package/dist/cron/billing.js.map +1 -0
- package/dist/cron/collection.d.ts +50 -0
- package/dist/cron/collection.d.ts.map +1 -0
- package/dist/cron/collection.js +118 -0
- package/dist/cron/collection.js.map +1 -0
- package/dist/cron/funding.d.ts +16 -0
- package/dist/cron/funding.d.ts.map +1 -0
- package/dist/cron/funding.js +262 -0
- package/dist/cron/funding.js.map +1 -0
- package/dist/cron/payer-billing.d.ts +38 -0
- package/dist/cron/payer-billing.d.ts.map +1 -0
- package/dist/cron/payer-billing.js +119 -0
- package/dist/cron/payer-billing.js.map +1 -0
- package/dist/cron/scan.d.ts +43 -0
- package/dist/cron/scan.d.ts.map +1 -0
- package/dist/cron/scan.js +250 -0
- package/dist/cron/scan.js.map +1 -0
- package/dist/db/client.d.ts +14 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +14 -0
- package/dist/db/client.js.map +1 -0
- package/dist/db/index.d.ts +7 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +7 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/schema.d.ts +6738 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +1433 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/define-oracle.d.ts +32 -0
- package/dist/define-oracle.d.ts.map +1 -0
- package/dist/define-oracle.js +80 -0
- package/dist/define-oracle.js.map +1 -0
- package/dist/dev-oracle.d.ts +9 -0
- package/dist/dev-oracle.d.ts.map +1 -0
- package/dist/dev-oracle.js +19 -0
- package/dist/dev-oracle.js.map +1 -0
- package/dist/dev-worker.d.ts +10 -0
- package/dist/dev-worker.d.ts.map +1 -0
- package/dist/dev-worker.js +12 -0
- package/dist/dev-worker.js.map +1 -0
- package/dist/env.d.ts +146 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +10 -0
- package/dist/env.js.map +1 -0
- package/dist/facts/exif.d.ts +43 -0
- package/dist/facts/exif.d.ts.map +1 -0
- package/dist/facts/exif.js +224 -0
- package/dist/facts/exif.js.map +1 -0
- package/dist/facts/fact.d.ts +62 -0
- package/dist/facts/fact.d.ts.map +1 -0
- package/dist/facts/fact.js +105 -0
- package/dist/facts/fact.js.map +1 -0
- package/dist/facts/geo.d.ts +55 -0
- package/dist/facts/geo.d.ts.map +1 -0
- package/dist/facts/geo.js +267 -0
- package/dist/facts/geo.js.map +1 -0
- package/dist/facts/index.d.ts +31 -0
- package/dist/facts/index.d.ts.map +1 -0
- package/dist/facts/index.js +27 -0
- package/dist/facts/index.js.map +1 -0
- package/dist/facts/linked-doc.d.ts +60 -0
- package/dist/facts/linked-doc.d.ts.map +1 -0
- package/dist/facts/linked-doc.js +101 -0
- package/dist/facts/linked-doc.js.map +1 -0
- package/dist/facts/types.d.ts +278 -0
- package/dist/facts/types.d.ts.map +1 -0
- package/dist/facts/types.js +19 -0
- package/dist/facts/types.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api-lane/accept.d.ts +29 -0
- package/dist/lib/api-lane/accept.d.ts.map +1 -0
- package/dist/lib/api-lane/accept.js +218 -0
- package/dist/lib/api-lane/accept.js.map +1 -0
- package/dist/lib/api-lane/claim-list.d.ts +44 -0
- package/dist/lib/api-lane/claim-list.d.ts.map +1 -0
- package/dist/lib/api-lane/claim-list.js +92 -0
- package/dist/lib/api-lane/claim-list.js.map +1 -0
- package/dist/lib/api-lane/company.d.ts +56 -0
- package/dist/lib/api-lane/company.d.ts.map +1 -0
- package/dist/lib/api-lane/company.js +103 -0
- package/dist/lib/api-lane/company.js.map +1 -0
- package/dist/lib/api-lane/events.d.ts +21 -0
- package/dist/lib/api-lane/events.d.ts.map +1 -0
- package/dist/lib/api-lane/events.js +111 -0
- package/dist/lib/api-lane/events.js.map +1 -0
- package/dist/lib/api-lane/ids.d.ts +39 -0
- package/dist/lib/api-lane/ids.d.ts.map +1 -0
- package/dist/lib/api-lane/ids.js +78 -0
- package/dist/lib/api-lane/ids.js.map +1 -0
- package/dist/lib/api-lane/index.d.ts +16 -0
- package/dist/lib/api-lane/index.d.ts.map +1 -0
- package/dist/lib/api-lane/index.js +16 -0
- package/dist/lib/api-lane/index.js.map +1 -0
- package/dist/lib/api-lane/linked.d.ts +264 -0
- package/dist/lib/api-lane/linked.d.ts.map +1 -0
- package/dist/lib/api-lane/linked.js +272 -0
- package/dist/lib/api-lane/linked.js.map +1 -0
- package/dist/lib/api-lane/media-type.d.ts +15 -0
- package/dist/lib/api-lane/media-type.d.ts.map +1 -0
- package/dist/lib/api-lane/media-type.js +73 -0
- package/dist/lib/api-lane/media-type.js.map +1 -0
- package/dist/lib/api-lane/member-emails.d.ts +83 -0
- package/dist/lib/api-lane/member-emails.d.ts.map +1 -0
- package/dist/lib/api-lane/member-emails.js +213 -0
- package/dist/lib/api-lane/member-emails.js.map +1 -0
- package/dist/lib/api-lane/members.d.ts +42 -0
- package/dist/lib/api-lane/members.d.ts.map +1 -0
- package/dist/lib/api-lane/members.js +75 -0
- package/dist/lib/api-lane/members.js.map +1 -0
- package/dist/lib/api-lane/notify.d.ts +47 -0
- package/dist/lib/api-lane/notify.d.ts.map +1 -0
- package/dist/lib/api-lane/notify.js +240 -0
- package/dist/lib/api-lane/notify.js.map +1 -0
- package/dist/lib/api-lane/pause.d.ts +41 -0
- package/dist/lib/api-lane/pause.d.ts.map +1 -0
- package/dist/lib/api-lane/pause.js +155 -0
- package/dist/lib/api-lane/pause.js.map +1 -0
- package/dist/lib/api-lane/record.d.ts +76 -0
- package/dist/lib/api-lane/record.d.ts.map +1 -0
- package/dist/lib/api-lane/record.js +337 -0
- package/dist/lib/api-lane/record.js.map +1 -0
- package/dist/lib/api-lane/retention.d.ts +43 -0
- package/dist/lib/api-lane/retention.d.ts.map +1 -0
- package/dist/lib/api-lane/retention.js +176 -0
- package/dist/lib/api-lane/retention.js.map +1 -0
- package/dist/lib/api-lane/review.d.ts +76 -0
- package/dist/lib/api-lane/review.d.ts.map +1 -0
- package/dist/lib/api-lane/review.js +355 -0
- package/dist/lib/api-lane/review.js.map +1 -0
- package/dist/lib/api-lane/reviewers.d.ts +109 -0
- package/dist/lib/api-lane/reviewers.d.ts.map +1 -0
- package/dist/lib/api-lane/reviewers.js +755 -0
- package/dist/lib/api-lane/reviewers.js.map +1 -0
- package/dist/lib/api-lane/source-delete.d.ts +16 -0
- package/dist/lib/api-lane/source-delete.d.ts.map +1 -0
- package/dist/lib/api-lane/source-delete.js +50 -0
- package/dist/lib/api-lane/source-delete.js.map +1 -0
- package/dist/lib/api-lane/source.d.ts +19 -0
- package/dist/lib/api-lane/source.d.ts.map +1 -0
- package/dist/lib/api-lane/source.js +226 -0
- package/dist/lib/api-lane/source.js.map +1 -0
- package/dist/lib/api-lane/submitter.d.ts +22 -0
- package/dist/lib/api-lane/submitter.d.ts.map +1 -0
- package/dist/lib/api-lane/submitter.js +34 -0
- package/dist/lib/api-lane/submitter.js.map +1 -0
- package/dist/lib/api-lane/timeline.d.ts +20 -0
- package/dist/lib/api-lane/timeline.d.ts.map +1 -0
- package/dist/lib/api-lane/timeline.js +23 -0
- package/dist/lib/api-lane/timeline.js.map +1 -0
- package/dist/lib/api-lane/webhook-crypto.d.ts +44 -0
- package/dist/lib/api-lane/webhook-crypto.d.ts.map +1 -0
- package/dist/lib/api-lane/webhook-crypto.js +103 -0
- package/dist/lib/api-lane/webhook-crypto.js.map +1 -0
- package/dist/lib/api-lane/webhooks.d.ts +117 -0
- package/dist/lib/api-lane/webhooks.d.ts.map +1 -0
- package/dist/lib/api-lane/webhooks.js +503 -0
- package/dist/lib/api-lane/webhooks.js.map +1 -0
- package/dist/lib/archive.d.ts +64 -0
- package/dist/lib/archive.d.ts.map +1 -0
- package/dist/lib/archive.js +305 -0
- package/dist/lib/archive.js.map +1 -0
- package/dist/lib/bech32.d.ts +8 -0
- package/dist/lib/bech32.d.ts.map +1 -0
- package/dist/lib/bech32.js +39 -0
- package/dist/lib/bech32.js.map +1 -0
- package/dist/lib/claim-erase.d.ts +22 -0
- package/dist/lib/claim-erase.d.ts.map +1 -0
- package/dist/lib/claim-erase.js +44 -0
- package/dist/lib/claim-erase.js.map +1 -0
- package/dist/lib/cursor.d.ts +11 -0
- package/dist/lib/cursor.d.ts.map +1 -0
- package/dist/lib/cursor.js +20 -0
- package/dist/lib/cursor.js.map +1 -0
- package/dist/lib/email/send.d.ts +43 -0
- package/dist/lib/email/send.d.ts.map +1 -0
- package/dist/lib/email/send.js +71 -0
- package/dist/lib/email/send.js.map +1 -0
- package/dist/lib/email/template.d.ts +217 -0
- package/dist/lib/email/template.d.ts.map +1 -0
- package/dist/lib/email/template.js +713 -0
- package/dist/lib/email/template.js.map +1 -0
- package/dist/lib/engine/adr36.d.ts +56 -0
- package/dist/lib/engine/adr36.d.ts.map +1 -0
- package/dist/lib/engine/adr36.js +76 -0
- package/dist/lib/engine/adr36.js.map +1 -0
- package/dist/lib/engine/client.d.ts +162 -0
- package/dist/lib/engine/client.d.ts.map +1 -0
- package/dist/lib/engine/client.js +473 -0
- package/dist/lib/engine/client.js.map +1 -0
- package/dist/lib/engine/types.d.ts +1356 -0
- package/dist/lib/engine/types.d.ts.map +1 -0
- package/dist/lib/engine/types.js +562 -0
- package/dist/lib/engine/types.js.map +1 -0
- package/dist/lib/errors.d.ts +73 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +96 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/facts/builder.d.ts +88 -0
- package/dist/lib/facts/builder.d.ts.map +1 -0
- package/dist/lib/facts/builder.js +239 -0
- package/dist/lib/facts/builder.js.map +1 -0
- package/dist/lib/facts/ctx.d.ts +34 -0
- package/dist/lib/facts/ctx.d.ts.map +1 -0
- package/dist/lib/facts/ctx.js +51 -0
- package/dist/lib/facts/ctx.js.map +1 -0
- package/dist/lib/facts/expected.d.ts +23 -0
- package/dist/lib/facts/expected.d.ts.map +1 -0
- package/dist/lib/facts/expected.js +16 -0
- package/dist/lib/facts/expected.js.map +1 -0
- package/dist/lib/facts/fact-cache.d.ts +469 -0
- package/dist/lib/facts/fact-cache.d.ts.map +1 -0
- package/dist/lib/facts/fact-cache.js +52 -0
- package/dist/lib/facts/fact-cache.js.map +1 -0
- package/dist/lib/facts/factset.d.ts +608 -0
- package/dist/lib/facts/factset.d.ts.map +1 -0
- package/dist/lib/facts/factset.js +226 -0
- package/dist/lib/facts/factset.js.map +1 -0
- package/dist/lib/facts/producer.d.ts +190 -0
- package/dist/lib/facts/producer.d.ts.map +1 -0
- package/dist/lib/facts/producer.js +15 -0
- package/dist/lib/facts/producer.js.map +1 -0
- package/dist/lib/facts/runner.d.ts +111 -0
- package/dist/lib/facts/runner.d.ts.map +1 -0
- package/dist/lib/facts/runner.js +438 -0
- package/dist/lib/facts/runner.js.map +1 -0
- package/dist/lib/facts/stock/ai-check.d.ts +100 -0
- package/dist/lib/facts/stock/ai-check.d.ts.map +1 -0
- package/dist/lib/facts/stock/ai-check.js +526 -0
- package/dist/lib/facts/stock/ai-check.js.map +1 -0
- package/dist/lib/facts/stock/ai-inputs.d.ts +104 -0
- package/dist/lib/facts/stock/ai-inputs.d.ts.map +1 -0
- package/dist/lib/facts/stock/ai-inputs.js +332 -0
- package/dist/lib/facts/stock/ai-inputs.js.map +1 -0
- package/dist/lib/facts/stock/ai-provider.d.ts +105 -0
- package/dist/lib/facts/stock/ai-provider.d.ts.map +1 -0
- package/dist/lib/facts/stock/ai-provider.js +250 -0
- package/dist/lib/facts/stock/ai-provider.js.map +1 -0
- package/dist/lib/facts/stock/ai-unique.d.ts +85 -0
- package/dist/lib/facts/stock/ai-unique.d.ts.map +1 -0
- package/dist/lib/facts/stock/ai-unique.js +208 -0
- package/dist/lib/facts/stock/ai-unique.js.map +1 -0
- package/dist/lib/facts/stock/archive.d.ts +63 -0
- package/dist/lib/facts/stock/archive.d.ts.map +1 -0
- package/dist/lib/facts/stock/archive.js +349 -0
- package/dist/lib/facts/stock/archive.js.map +1 -0
- package/dist/lib/facts/stock/c2pa-trust-list.d.ts +16 -0
- package/dist/lib/facts/stock/c2pa-trust-list.d.ts.map +1 -0
- package/dist/lib/facts/stock/c2pa-trust-list.js +637 -0
- package/dist/lib/facts/stock/c2pa-trust-list.js.map +1 -0
- package/dist/lib/facts/stock/c2pa.d.ts +56 -0
- package/dist/lib/facts/stock/c2pa.d.ts.map +1 -0
- package/dist/lib/facts/stock/c2pa.js +234 -0
- package/dist/lib/facts/stock/c2pa.js.map +1 -0
- package/dist/lib/facts/stock/call.d.ts +91 -0
- package/dist/lib/facts/stock/call.d.ts.map +1 -0
- package/dist/lib/facts/stock/call.js +281 -0
- package/dist/lib/facts/stock/call.js.map +1 -0
- package/dist/lib/facts/stock/capability.d.ts +39 -0
- package/dist/lib/facts/stock/capability.d.ts.map +1 -0
- package/dist/lib/facts/stock/capability.js +59 -0
- package/dist/lib/facts/stock/capability.js.map +1 -0
- package/dist/lib/facts/stock/ext-source.d.ts +51 -0
- package/dist/lib/facts/stock/ext-source.d.ts.map +1 -0
- package/dist/lib/facts/stock/ext-source.js +201 -0
- package/dist/lib/facts/stock/ext-source.js.map +1 -0
- package/dist/lib/facts/stock/frequency-fact.d.ts +59 -0
- package/dist/lib/facts/stock/frequency-fact.d.ts.map +1 -0
- package/dist/lib/facts/stock/frequency-fact.js +86 -0
- package/dist/lib/facts/stock/frequency-fact.js.map +1 -0
- package/dist/lib/facts/stock/frequency.d.ts +32 -0
- package/dist/lib/facts/stock/frequency.d.ts.map +1 -0
- package/dist/lib/facts/stock/frequency.js +48 -0
- package/dist/lib/facts/stock/frequency.js.map +1 -0
- package/dist/lib/facts/stock/index.d.ts +27 -0
- package/dist/lib/facts/stock/index.d.ts.map +1 -0
- package/dist/lib/facts/stock/index.js +28 -0
- package/dist/lib/facts/stock/index.js.map +1 -0
- package/dist/lib/facts/stock/normalize.d.ts +45 -0
- package/dist/lib/facts/stock/normalize.d.ts.map +1 -0
- package/dist/lib/facts/stock/normalize.js +135 -0
- package/dist/lib/facts/stock/normalize.js.map +1 -0
- package/dist/lib/facts/stock/phash.d.ts +55 -0
- package/dist/lib/facts/stock/phash.d.ts.map +1 -0
- package/dist/lib/facts/stock/phash.js +256 -0
- package/dist/lib/facts/stock/phash.js.map +1 -0
- package/dist/lib/facts/stock/rule-defaults.d.ts +72 -0
- package/dist/lib/facts/stock/rule-defaults.d.ts.map +1 -0
- package/dist/lib/facts/stock/rule-defaults.js +55 -0
- package/dist/lib/facts/stock/rule-defaults.js.map +1 -0
- package/dist/lib/facts/stock/send.d.ts +52 -0
- package/dist/lib/facts/stock/send.d.ts.map +1 -0
- package/dist/lib/facts/stock/send.js +148 -0
- package/dist/lib/facts/stock/send.js.map +1 -0
- package/dist/lib/facts/stock/unique-score.d.ts +138 -0
- package/dist/lib/facts/stock/unique-score.d.ts.map +1 -0
- package/dist/lib/facts/stock/unique-score.js +257 -0
- package/dist/lib/facts/stock/unique-score.js.map +1 -0
- package/dist/lib/facts/stock/unique-store.d.ts +420 -0
- package/dist/lib/facts/stock/unique-store.d.ts.map +1 -0
- package/dist/lib/facts/stock/unique-store.js +328 -0
- package/dist/lib/facts/stock/unique-store.js.map +1 -0
- package/dist/lib/facts/stock/unique.d.ts +35 -0
- package/dist/lib/facts/stock/unique.d.ts.map +1 -0
- package/dist/lib/facts/stock/unique.js +327 -0
- package/dist/lib/facts/stock/unique.js.map +1 -0
- package/dist/lib/facts/tools.d.ts +57 -0
- package/dist/lib/facts/tools.d.ts.map +1 -0
- package/dist/lib/facts/tools.js +325 -0
- package/dist/lib/facts/tools.js.map +1 -0
- package/dist/lib/facts/validate.d.ts +33 -0
- package/dist/lib/facts/validate.d.ts.map +1 -0
- package/dist/lib/facts/validate.js +137 -0
- package/dist/lib/facts/validate.js.map +1 -0
- package/dist/lib/hash.d.ts +44 -0
- package/dist/lib/hash.d.ts.map +1 -0
- package/dist/lib/hash.js +80 -0
- package/dist/lib/hash.js.map +1 -0
- package/dist/lib/http/client.d.ts +113 -0
- package/dist/lib/http/client.d.ts.map +1 -0
- package/dist/lib/http/client.js +330 -0
- package/dist/lib/http/client.js.map +1 -0
- package/dist/lib/ids.d.ts +17 -0
- package/dist/lib/ids.d.ts.map +1 -0
- package/dist/lib/ids.js +26 -0
- package/dist/lib/ids.js.map +1 -0
- package/dist/lib/ixo/attachments.d.ts +116 -0
- package/dist/lib/ixo/attachments.d.ts.map +1 -0
- package/dist/lib/ixo/attachments.js +290 -0
- package/dist/lib/ixo/attachments.js.map +1 -0
- package/dist/lib/ixo/authz.d.ts +40 -0
- package/dist/lib/ixo/authz.d.ts.map +1 -0
- package/dist/lib/ixo/authz.js +113 -0
- package/dist/lib/ixo/authz.js.map +1 -0
- package/dist/lib/ixo/blocksync/index.d.ts +90 -0
- package/dist/lib/ixo/blocksync/index.d.ts.map +1 -0
- package/dist/lib/ixo/blocksync/index.js +251 -0
- package/dist/lib/ixo/blocksync/index.js.map +1 -0
- package/dist/lib/ixo/blocksync/queries.d.ts +15 -0
- package/dist/lib/ixo/blocksync/queries.d.ts.map +1 -0
- package/dist/lib/ixo/blocksync/queries.js +144 -0
- package/dist/lib/ixo/blocksync/queries.js.map +1 -0
- package/dist/lib/ixo/blocksync/types.d.ts +184 -0
- package/dist/lib/ixo/blocksync/types.d.ts.map +1 -0
- package/dist/lib/ixo/blocksync/types.js +108 -0
- package/dist/lib/ixo/blocksync/types.js.map +1 -0
- package/dist/lib/ixo/cellnode.d.ts +35 -0
- package/dist/lib/ixo/cellnode.d.ts.map +1 -0
- package/dist/lib/ixo/cellnode.js +43 -0
- package/dist/lib/ixo/cellnode.js.map +1 -0
- package/dist/lib/ixo/chain-write.d.ts +130 -0
- package/dist/lib/ixo/chain-write.d.ts.map +1 -0
- package/dist/lib/ixo/chain-write.js +460 -0
- package/dist/lib/ixo/chain-write.js.map +1 -0
- package/dist/lib/ixo/chain.d.ts +1046 -0
- package/dist/lib/ixo/chain.d.ts.map +1 -0
- package/dist/lib/ixo/chain.js +279 -0
- package/dist/lib/ixo/chain.js.map +1 -0
- package/dist/lib/ixo/claim-bot.d.ts +49 -0
- package/dist/lib/ixo/claim-bot.d.ts.map +1 -0
- package/dist/lib/ixo/claim-bot.js +141 -0
- package/dist/lib/ixo/claim-bot.js.map +1 -0
- package/dist/lib/ixo/delegation-verify.d.ts +44 -0
- package/dist/lib/ixo/delegation-verify.d.ts.map +1 -0
- package/dist/lib/ixo/delegation-verify.js +101 -0
- package/dist/lib/ixo/delegation-verify.js.map +1 -0
- package/dist/lib/ixo/did.d.ts +13 -0
- package/dist/lib/ixo/did.d.ts.map +1 -0
- package/dist/lib/ixo/did.js +85 -0
- package/dist/lib/ixo/did.js.map +1 -0
- package/dist/lib/ixo/grant-chain.d.ts +55 -0
- package/dist/lib/ixo/grant-chain.d.ts.map +1 -0
- package/dist/lib/ixo/grant-chain.js +185 -0
- package/dist/lib/ixo/grant-chain.js.map +1 -0
- package/dist/lib/ixo/identity.d.ts +32 -0
- package/dist/lib/ixo/identity.d.ts.map +1 -0
- package/dist/lib/ixo/identity.js +104 -0
- package/dist/lib/ixo/identity.js.map +1 -0
- package/dist/lib/ixo/index.d.ts +118 -0
- package/dist/lib/ixo/index.d.ts.map +1 -0
- package/dist/lib/ixo/index.js +395 -0
- package/dist/lib/ixo/index.js.map +1 -0
- package/dist/lib/ixo/payment.d.ts +104 -0
- package/dist/lib/ixo/payment.d.ts.map +1 -0
- package/dist/lib/ixo/payment.js +136 -0
- package/dist/lib/ixo/payment.js.map +1 -0
- package/dist/lib/ixo/ucan-store.d.ts +30 -0
- package/dist/lib/ixo/ucan-store.d.ts.map +1 -0
- package/dist/lib/ixo/ucan-store.js +134 -0
- package/dist/lib/ixo/ucan-store.js.map +1 -0
- package/dist/lib/ixo/ucan.d.ts +96 -0
- package/dist/lib/ixo/ucan.d.ts.map +1 -0
- package/dist/lib/ixo/ucan.js +216 -0
- package/dist/lib/ixo/ucan.js.map +1 -0
- package/dist/lib/ixo/verified-read.d.ts +43 -0
- package/dist/lib/ixo/verified-read.d.ts.map +1 -0
- package/dist/lib/ixo/verified-read.js +73 -0
- package/dist/lib/ixo/verified-read.js.map +1 -0
- package/dist/lib/ixo/vfs.d.ts +27 -0
- package/dist/lib/ixo/vfs.d.ts.map +1 -0
- package/dist/lib/ixo/vfs.js +42 -0
- package/dist/lib/ixo/vfs.js.map +1 -0
- package/dist/lib/ixo/web-did.d.ts +7 -0
- package/dist/lib/ixo/web-did.d.ts.map +1 -0
- package/dist/lib/ixo/web-did.js +9 -0
- package/dist/lib/ixo/web-did.js.map +1 -0
- package/dist/lib/logger.d.ts +34 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +126 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/matrix/api.d.ts +57 -0
- package/dist/lib/matrix/api.d.ts.map +1 -0
- package/dist/lib/matrix/api.js +58 -0
- package/dist/lib/matrix/api.js.map +1 -0
- package/dist/lib/matrix/client.d.ts +41 -0
- package/dist/lib/matrix/client.d.ts.map +1 -0
- package/dist/lib/matrix/client.js +104 -0
- package/dist/lib/matrix/client.js.map +1 -0
- package/dist/lib/matrix/deliver.d.ts +224 -0
- package/dist/lib/matrix/deliver.d.ts.map +1 -0
- package/dist/lib/matrix/deliver.js +788 -0
- package/dist/lib/matrix/deliver.js.map +1 -0
- package/dist/lib/matrix/events.d.ts +114 -0
- package/dist/lib/matrix/events.d.ts.map +1 -0
- package/dist/lib/matrix/events.js +143 -0
- package/dist/lib/matrix/events.js.map +1 -0
- package/dist/lib/matrix/mxid.d.ts +24 -0
- package/dist/lib/matrix/mxid.d.ts.map +1 -0
- package/dist/lib/matrix/mxid.js +47 -0
- package/dist/lib/matrix/mxid.js.map +1 -0
- package/dist/lib/metrics.d.ts +105 -0
- package/dist/lib/metrics.d.ts.map +1 -0
- package/dist/lib/metrics.js +204 -0
- package/dist/lib/metrics.js.map +1 -0
- package/dist/lib/oauth/approvals.d.ts +160 -0
- package/dist/lib/oauth/approvals.d.ts.map +1 -0
- package/dist/lib/oauth/approvals.js +273 -0
- package/dist/lib/oauth/approvals.js.map +1 -0
- package/dist/lib/oauth/standing.d.ts +152 -0
- package/dist/lib/oauth/standing.d.ts.map +1 -0
- package/dist/lib/oauth/standing.js +299 -0
- package/dist/lib/oauth/standing.js.map +1 -0
- package/dist/lib/oauth/token.d.ts +60 -0
- package/dist/lib/oauth/token.d.ts.map +1 -0
- package/dist/lib/oauth/token.js +129 -0
- package/dist/lib/oauth/token.js.map +1 -0
- package/dist/lib/payments/extend.d.ts +42 -0
- package/dist/lib/payments/extend.d.ts.map +1 -0
- package/dist/lib/payments/extend.js +98 -0
- package/dist/lib/payments/extend.js.map +1 -0
- package/dist/lib/payments/facilitator.d.ts +220 -0
- package/dist/lib/payments/facilitator.d.ts.map +1 -0
- package/dist/lib/payments/facilitator.js +451 -0
- package/dist/lib/payments/facilitator.js.map +1 -0
- package/dist/lib/payments/gate.d.ts +207 -0
- package/dist/lib/payments/gate.d.ts.map +1 -0
- package/dist/lib/payments/gate.js +481 -0
- package/dist/lib/payments/gate.js.map +1 -0
- package/dist/lib/payments/header-seal.d.ts +33 -0
- package/dist/lib/payments/header-seal.d.ts.map +1 -0
- package/dist/lib/payments/header-seal.js +76 -0
- package/dist/lib/payments/header-seal.js.map +1 -0
- package/dist/lib/payments/index.d.ts +12 -0
- package/dist/lib/payments/index.d.ts.map +1 -0
- package/dist/lib/payments/index.js +11 -0
- package/dist/lib/payments/index.js.map +1 -0
- package/dist/lib/payments/price.d.ts +25 -0
- package/dist/lib/payments/price.d.ts.map +1 -0
- package/dist/lib/payments/price.js +43 -0
- package/dist/lib/payments/price.js.map +1 -0
- package/dist/lib/payments/reconcile.d.ts +77 -0
- package/dist/lib/payments/reconcile.d.ts.map +1 -0
- package/dist/lib/payments/reconcile.js +317 -0
- package/dist/lib/payments/reconcile.js.map +1 -0
- package/dist/lib/payments/refund.d.ts +34 -0
- package/dist/lib/payments/refund.d.ts.map +1 -0
- package/dist/lib/payments/refund.js +123 -0
- package/dist/lib/payments/refund.js.map +1 -0
- package/dist/lib/payments/review-billing.d.ts +222 -0
- package/dist/lib/payments/review-billing.d.ts.map +1 -0
- package/dist/lib/payments/review-billing.js +609 -0
- package/dist/lib/payments/review-billing.js.map +1 -0
- package/dist/lib/payments/settle.d.ts +44 -0
- package/dist/lib/payments/settle.d.ts.map +1 -0
- package/dist/lib/payments/settle.js +306 -0
- package/dist/lib/payments/settle.js.map +1 -0
- package/dist/lib/payments/terms.d.ts +27 -0
- package/dist/lib/payments/terms.d.ts.map +1 -0
- package/dist/lib/payments/terms.js +21 -0
- package/dist/lib/payments/terms.js.map +1 -0
- package/dist/lib/payouts.d.ts +20 -0
- package/dist/lib/payouts.d.ts.map +1 -0
- package/dist/lib/payouts.js +30 -0
- package/dist/lib/payouts.js.map +1 -0
- package/dist/lib/readiness.d.ts +42 -0
- package/dist/lib/readiness.d.ts.map +1 -0
- package/dist/lib/readiness.js +130 -0
- package/dist/lib/readiness.js.map +1 -0
- package/dist/lib/redact.d.ts +23 -0
- package/dist/lib/redact.d.ts.map +1 -0
- package/dist/lib/redact.js +67 -0
- package/dist/lib/redact.js.map +1 -0
- package/dist/lib/register.d.ts +85 -0
- package/dist/lib/register.d.ts.map +1 -0
- package/dist/lib/register.js +390 -0
- package/dist/lib/register.js.map +1 -0
- package/dist/lib/review/attestation.d.ts +92 -0
- package/dist/lib/review/attestation.d.ts.map +1 -0
- package/dist/lib/review/attestation.js +264 -0
- package/dist/lib/review/attestation.js.map +1 -0
- package/dist/lib/review/reviewer-grant.d.ts +146 -0
- package/dist/lib/review/reviewer-grant.d.ts.map +1 -0
- package/dist/lib/review/reviewer-grant.js +359 -0
- package/dist/lib/review/reviewer-grant.js.map +1 -0
- package/dist/lib/review/tasks.d.ts +18 -0
- package/dist/lib/review/tasks.d.ts.map +1 -0
- package/dist/lib/review/tasks.js +36 -0
- package/dist/lib/review/tasks.js.map +1 -0
- package/dist/lib/sentry.d.ts +89 -0
- package/dist/lib/sentry.d.ts.map +1 -0
- package/dist/lib/sentry.js +284 -0
- package/dist/lib/sentry.js.map +1 -0
- package/dist/lib/spans.d.ts +14 -0
- package/dist/lib/spans.d.ts.map +1 -0
- package/dist/lib/spans.js +28 -0
- package/dist/lib/spans.js.map +1 -0
- package/dist/lib/tracing.d.ts +31 -0
- package/dist/lib/tracing.d.ts.map +1 -0
- package/dist/lib/tracing.js +66 -0
- package/dist/lib/tracing.js.map +1 -0
- package/dist/lib/ttl-cache.d.ts +26 -0
- package/dist/lib/ttl-cache.d.ts.map +1 -0
- package/dist/lib/ttl-cache.js +61 -0
- package/dist/lib/ttl-cache.js.map +1 -0
- package/dist/lib/validator.d.ts +19 -0
- package/dist/lib/validator.d.ts.map +1 -0
- package/dist/lib/validator.js +32 -0
- package/dist/lib/validator.js.map +1 -0
- package/dist/lib/work-order/form.d.ts +40 -0
- package/dist/lib/work-order/form.d.ts.map +1 -0
- package/dist/lib/work-order/form.js +316 -0
- package/dist/lib/work-order/form.js.map +1 -0
- package/dist/lib/work-order/index.d.ts +20 -0
- package/dist/lib/work-order/index.d.ts.map +1 -0
- package/dist/lib/work-order/index.js +66 -0
- package/dist/lib/work-order/index.js.map +1 -0
- package/dist/middleware/api/audit.d.ts +9 -0
- package/dist/middleware/api/audit.d.ts.map +1 -0
- package/dist/middleware/api/audit.js +38 -0
- package/dist/middleware/api/audit.js.map +1 -0
- package/dist/middleware/api/auth.d.ts +29 -0
- package/dist/middleware/api/auth.d.ts.map +1 -0
- package/dist/middleware/api/auth.js +105 -0
- package/dist/middleware/api/auth.js.map +1 -0
- package/dist/middleware/api/console.d.ts +92 -0
- package/dist/middleware/api/console.d.ts.map +1 -0
- package/dist/middleware/api/console.js +446 -0
- package/dist/middleware/api/console.js.map +1 -0
- package/dist/middleware/api/errors.d.ts +48 -0
- package/dist/middleware/api/errors.d.ts.map +1 -0
- package/dist/middleware/api/errors.js +133 -0
- package/dist/middleware/api/errors.js.map +1 -0
- package/dist/middleware/api/idempotency.d.ts +23 -0
- package/dist/middleware/api/idempotency.d.ts.map +1 -0
- package/dist/middleware/api/idempotency.js +158 -0
- package/dist/middleware/api/idempotency.js.map +1 -0
- package/dist/middleware/api/keys.d.ts +14 -0
- package/dist/middleware/api/keys.d.ts.map +1 -0
- package/dist/middleware/api/keys.js +66 -0
- package/dist/middleware/api/keys.js.map +1 -0
- package/dist/middleware/api/membership.d.ts +32 -0
- package/dist/middleware/api/membership.d.ts.map +1 -0
- package/dist/middleware/api/membership.js +48 -0
- package/dist/middleware/api/membership.js.map +1 -0
- package/dist/middleware/api/oauth.d.ts +28 -0
- package/dist/middleware/api/oauth.d.ts.map +1 -0
- package/dist/middleware/api/oauth.js +109 -0
- package/dist/middleware/api/oauth.js.map +1 -0
- package/dist/middleware/api/rate-limit.d.ts +23 -0
- package/dist/middleware/api/rate-limit.d.ts.map +1 -0
- package/dist/middleware/api/rate-limit.js +70 -0
- package/dist/middleware/api/rate-limit.js.map +1 -0
- package/dist/middleware/api/types.d.ts +92 -0
- package/dist/middleware/api/types.d.ts.map +1 -0
- package/dist/middleware/api/types.js +7 -0
- package/dist/middleware/api/types.js.map +1 -0
- package/dist/middleware/api/wait.d.ts +21 -0
- package/dist/middleware/api/wait.d.ts.map +1 -0
- package/dist/middleware/api/wait.js +85 -0
- package/dist/middleware/api/wait.js.map +1 -0
- package/dist/middleware/capability.d.ts +32 -0
- package/dist/middleware/capability.d.ts.map +1 -0
- package/dist/middleware/capability.js +113 -0
- package/dist/middleware/capability.js.map +1 -0
- package/dist/middleware/database.d.ts +14 -0
- package/dist/middleware/database.d.ts.map +1 -0
- package/dist/middleware/database.js +18 -0
- package/dist/middleware/database.js.map +1 -0
- package/dist/middleware/error-handler.d.ts +13 -0
- package/dist/middleware/error-handler.d.ts.map +1 -0
- package/dist/middleware/error-handler.js +127 -0
- package/dist/middleware/error-handler.js.map +1 -0
- package/dist/middleware/observability.d.ts +32 -0
- package/dist/middleware/observability.d.ts.map +1 -0
- package/dist/middleware/observability.js +134 -0
- package/dist/middleware/observability.js.map +1 -0
- package/dist/middleware/rate-limit.d.ts +16 -0
- package/dist/middleware/rate-limit.d.ts.map +1 -0
- package/dist/middleware/rate-limit.js +56 -0
- package/dist/middleware/rate-limit.js.map +1 -0
- package/dist/middleware/ucan-auth.d.ts +39 -0
- package/dist/middleware/ucan-auth.d.ts.map +1 -0
- package/dist/middleware/ucan-auth.js +278 -0
- package/dist/middleware/ucan-auth.js.map +1 -0
- package/dist/networks.d.ts +34 -0
- package/dist/networks.d.ts.map +1 -0
- package/dist/networks.js +49 -0
- package/dist/networks.js.map +1 -0
- package/dist/oracle.d.ts +193 -0
- package/dist/oracle.d.ts.map +1 -0
- package/dist/oracle.js +245 -0
- package/dist/oracle.js.map +1 -0
- package/dist/routes/health.d.ts +16 -0
- package/dist/routes/health.d.ts.map +1 -0
- package/dist/routes/health.js +29 -0
- package/dist/routes/health.js.map +1 -0
- package/dist/routes/v1/admin.d.ts +18 -0
- package/dist/routes/v1/admin.d.ts.map +1 -0
- package/dist/routes/v1/admin.js +101 -0
- package/dist/routes/v1/admin.js.map +1 -0
- package/dist/routes/v1/api/admin-claims.d.ts +14 -0
- package/dist/routes/v1/api/admin-claims.d.ts.map +1 -0
- package/dist/routes/v1/api/admin-claims.js +82 -0
- package/dist/routes/v1/api/admin-claims.js.map +1 -0
- package/dist/routes/v1/api/admin-facilitator.d.ts +20 -0
- package/dist/routes/v1/api/admin-facilitator.d.ts.map +1 -0
- package/dist/routes/v1/api/admin-facilitator.js +64 -0
- package/dist/routes/v1/api/admin-facilitator.js.map +1 -0
- package/dist/routes/v1/api/admin.d.ts +9 -0
- package/dist/routes/v1/api/admin.d.ts.map +1 -0
- package/dist/routes/v1/api/admin.js +110 -0
- package/dist/routes/v1/api/admin.js.map +1 -0
- package/dist/routes/v1/api/audit.d.ts +8 -0
- package/dist/routes/v1/api/audit.d.ts.map +1 -0
- package/dist/routes/v1/api/audit.js +56 -0
- package/dist/routes/v1/api/audit.js.map +1 -0
- package/dist/routes/v1/api/batch.d.ts +17 -0
- package/dist/routes/v1/api/batch.d.ts.map +1 -0
- package/dist/routes/v1/api/batch.js +192 -0
- package/dist/routes/v1/api/batch.js.map +1 -0
- package/dist/routes/v1/api/claims-read.d.ts +43 -0
- package/dist/routes/v1/api/claims-read.d.ts.map +1 -0
- package/dist/routes/v1/api/claims-read.js +123 -0
- package/dist/routes/v1/api/claims-read.js.map +1 -0
- package/dist/routes/v1/api/claims.d.ts +131 -0
- package/dist/routes/v1/api/claims.d.ts.map +1 -0
- package/dist/routes/v1/api/claims.js +407 -0
- package/dist/routes/v1/api/claims.js.map +1 -0
- package/dist/routes/v1/api/collections-link.d.ts +14 -0
- package/dist/routes/v1/api/collections-link.d.ts.map +1 -0
- package/dist/routes/v1/api/collections-link.js +97 -0
- package/dist/routes/v1/api/collections-link.js.map +1 -0
- package/dist/routes/v1/api/export.d.ts +48 -0
- package/dist/routes/v1/api/export.d.ts.map +1 -0
- package/dist/routes/v1/api/export.js +251 -0
- package/dist/routes/v1/api/export.js.map +1 -0
- package/dist/routes/v1/api/index.d.ts +16 -0
- package/dist/routes/v1/api/index.d.ts.map +1 -0
- package/dist/routes/v1/api/index.js +68 -0
- package/dist/routes/v1/api/index.js.map +1 -0
- package/dist/routes/v1/api/keys.d.ts +9 -0
- package/dist/routes/v1/api/keys.d.ts.map +1 -0
- package/dist/routes/v1/api/keys.js +95 -0
- package/dist/routes/v1/api/keys.js.map +1 -0
- package/dist/routes/v1/api/me.d.ts +21 -0
- package/dist/routes/v1/api/me.d.ts.map +1 -0
- package/dist/routes/v1/api/me.js +122 -0
- package/dist/routes/v1/api/me.js.map +1 -0
- package/dist/routes/v1/api/members.d.ts +17 -0
- package/dist/routes/v1/api/members.d.ts.map +1 -0
- package/dist/routes/v1/api/members.js +406 -0
- package/dist/routes/v1/api/members.js.map +1 -0
- package/dist/routes/v1/api/meta.d.ts +12 -0
- package/dist/routes/v1/api/meta.d.ts.map +1 -0
- package/dist/routes/v1/api/meta.js +59 -0
- package/dist/routes/v1/api/meta.js.map +1 -0
- package/dist/routes/v1/api/openapi.gen.d.ts +2 -0
- package/dist/routes/v1/api/openapi.gen.d.ts.map +1 -0
- package/dist/routes/v1/api/openapi.gen.js +7 -0
- package/dist/routes/v1/api/openapi.gen.js.map +1 -0
- package/dist/routes/v1/api/protocols.d.ts +22 -0
- package/dist/routes/v1/api/protocols.d.ts.map +1 -0
- package/dist/routes/v1/api/protocols.js +153 -0
- package/dist/routes/v1/api/protocols.js.map +1 -0
- package/dist/routes/v1/api/review-billing.d.ts +18 -0
- package/dist/routes/v1/api/review-billing.d.ts.map +1 -0
- package/dist/routes/v1/api/review-billing.js +196 -0
- package/dist/routes/v1/api/review-billing.js.map +1 -0
- package/dist/routes/v1/api/review.d.ts +30 -0
- package/dist/routes/v1/api/review.d.ts.map +1 -0
- package/dist/routes/v1/api/review.js +302 -0
- package/dist/routes/v1/api/review.js.map +1 -0
- package/dist/routes/v1/api/sources.d.ts +10 -0
- package/dist/routes/v1/api/sources.d.ts.map +1 -0
- package/dist/routes/v1/api/sources.js +293 -0
- package/dist/routes/v1/api/sources.js.map +1 -0
- package/dist/routes/v1/api/uploads.d.ts +37 -0
- package/dist/routes/v1/api/uploads.d.ts.map +1 -0
- package/dist/routes/v1/api/uploads.js +414 -0
- package/dist/routes/v1/api/uploads.js.map +1 -0
- package/dist/routes/v1/api/views.d.ts +18 -0
- package/dist/routes/v1/api/views.d.ts.map +1 -0
- package/dist/routes/v1/api/views.js +95 -0
- package/dist/routes/v1/api/views.js.map +1 -0
- package/dist/routes/v1/api/webhooks.d.ts +14 -0
- package/dist/routes/v1/api/webhooks.d.ts.map +1 -0
- package/dist/routes/v1/api/webhooks.js +282 -0
- package/dist/routes/v1/api/webhooks.js.map +1 -0
- package/dist/routes/v1/api/work-orders.d.ts +45 -0
- package/dist/routes/v1/api/work-orders.d.ts.map +1 -0
- package/dist/routes/v1/api/work-orders.js +171 -0
- package/dist/routes/v1/api/work-orders.js.map +1 -0
- package/dist/routes/v1/claims.d.ts +21 -0
- package/dist/routes/v1/claims.d.ts.map +1 -0
- package/dist/routes/v1/claims.js +153 -0
- package/dist/routes/v1/claims.js.map +1 -0
- package/dist/routes/v1/collections.d.ts +45 -0
- package/dist/routes/v1/collections.d.ts.map +1 -0
- package/dist/routes/v1/collections.js +201 -0
- package/dist/routes/v1/collections.js.map +1 -0
- package/dist/routes/v1/index.d.ts +13 -0
- package/dist/routes/v1/index.d.ts.map +1 -0
- package/dist/routes/v1/index.js +41 -0
- package/dist/routes/v1/index.js.map +1 -0
- package/dist/routes/v1/info.d.ts +14 -0
- package/dist/routes/v1/info.d.ts.map +1 -0
- package/dist/routes/v1/info.js +75 -0
- package/dist/routes/v1/info.js.map +1 -0
- package/dist/routes/v1/mcp/index.d.ts +33 -0
- package/dist/routes/v1/mcp/index.d.ts.map +1 -0
- package/dist/routes/v1/mcp/index.js +252 -0
- package/dist/routes/v1/mcp/index.js.map +1 -0
- package/dist/routes/v1/mcp/oauth.d.ts +27 -0
- package/dist/routes/v1/mcp/oauth.d.ts.map +1 -0
- package/dist/routes/v1/mcp/oauth.js +500 -0
- package/dist/routes/v1/mcp/oauth.js.map +1 -0
- package/dist/routes/v1/mcp/tools.d.ts +71 -0
- package/dist/routes/v1/mcp/tools.d.ts.map +1 -0
- package/dist/routes/v1/mcp/tools.js +432 -0
- package/dist/routes/v1/mcp/tools.js.map +1 -0
- package/dist/routes/v1/mcp/ui.d.ts +45 -0
- package/dist/routes/v1/mcp/ui.d.ts.map +1 -0
- package/dist/routes/v1/mcp/ui.js +454 -0
- package/dist/routes/v1/mcp/ui.js.map +1 -0
- package/dist/routes/v1/oauth.d.ts +29 -0
- package/dist/routes/v1/oauth.d.ts.map +1 -0
- package/dist/routes/v1/oauth.js +256 -0
- package/dist/routes/v1/oauth.js.map +1 -0
- package/dist/routes/v1/reviewers.d.ts +22 -0
- package/dist/routes/v1/reviewers.d.ts.map +1 -0
- package/dist/routes/v1/reviewers.js +165 -0
- package/dist/routes/v1/reviewers.js.map +1 -0
- package/dist/routes/v1/reviews.d.ts +38 -0
- package/dist/routes/v1/reviews.d.ts.map +1 -0
- package/dist/routes/v1/reviews.js +234 -0
- package/dist/routes/v1/reviews.js.map +1 -0
- package/dist/routes/v1/shared.d.ts +586 -0
- package/dist/routes/v1/shared.d.ts.map +1 -0
- package/dist/routes/v1/shared.js +229 -0
- package/dist/routes/v1/shared.js.map +1 -0
- package/dist/routes/well-known.d.ts +15 -0
- package/dist/routes/well-known.d.ts.map +1 -0
- package/dist/routes/well-known.js +35 -0
- package/dist/routes/well-known.js.map +1 -0
- package/dist/runtime.d.ts +100 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +144 -0
- package/dist/runtime.js.map +1 -0
- package/dist/testing/fake-tools.d.ts +104 -0
- package/dist/testing/fake-tools.d.ts.map +1 -0
- package/dist/testing/fake-tools.js +213 -0
- package/dist/testing/fake-tools.js.map +1 -0
- package/dist/testing/index.d.ts +54 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +104 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/samples.d.ts +70 -0
- package/dist/testing/samples.d.ts.map +1 -0
- package/dist/testing/samples.js +92 -0
- package/dist/testing/samples.js.map +1 -0
- package/dist/workflows/claim-ingest.d.ts +250 -0
- package/dist/workflows/claim-ingest.d.ts.map +1 -0
- package/dist/workflows/claim-ingest.js +1020 -0
- package/dist/workflows/claim-ingest.js.map +1 -0
- package/dist/workflows/claim-source.d.ts +25 -0
- package/dist/workflows/claim-source.d.ts.map +1 -0
- package/dist/workflows/claim-source.js +107 -0
- package/dist/workflows/claim-source.js.map +1 -0
- package/dist/workflows/review-complete.d.ts +82 -0
- package/dist/workflows/review-complete.d.ts.map +1 -0
- package/dist/workflows/review-complete.js +455 -0
- package/dist/workflows/review-complete.js.map +1 -0
- package/dist/workflows/steps.d.ts +125 -0
- package/dist/workflows/steps.d.ts.map +1 -0
- package/dist/workflows/steps.js +325 -0
- package/dist/workflows/steps.js.map +1 -0
- package/docs/api.md +2595 -0
- package/docs/guide.md +1525 -0
- package/migrations/0000_init.sql +108 -0
- package/migrations/0001_review_attestation.sql +1 -0
- package/migrations/0002_decisions_facts.sql +1 -0
- package/migrations/0003_api_lane.sql +171 -0
- package/migrations/0004_api_v1_1.sql +19 -0
- package/migrations/0005_member_notify.sql +3 -0
- package/migrations/0006_source_collections.sql +16 -0
- package/migrations/0007_api_settlement.sql +27 -0
- package/migrations/0008_review_extend.sql +1 -0
- package/migrations/0009_card_refunds.sql +4 -0
- package/migrations/0010_even_scorpion.sql +16 -0
- package/migrations/0011_mcp_oauth.sql +27 -0
- package/migrations/0012_mcp_standing.sql +21 -0
- package/migrations/0013_unknown_krista_starr.sql +2 -0
- package/migrations/0014_last_carnage.sql +14 -0
- package/migrations/0015_company_authority.sql +26 -0
- package/migrations/0016_owner_only_links.sql +6 -0
- package/migrations/0017_organisations.sql +35 -0
- package/migrations/0018_remove_app_signed.sql +4 -0
- package/migrations/0019_submitted_via.sql +2 -0
- package/migrations/0020_drop_decision_to_pay.sql +4 -0
- package/migrations/0021_manual_erase.sql +25 -0
- package/migrations/0022_errored_facts.sql +1 -0
- package/migrations/0023_review_billing.sql +20 -0
- package/migrations/0024_pending_task_details.sql +1 -0
- package/migrations/meta/0000_snapshot.json +707 -0
- package/migrations/meta/0001_snapshot.json +714 -0
- package/migrations/meta/0002_snapshot.json +721 -0
- package/migrations/meta/0003_snapshot.json +1845 -0
- package/migrations/meta/0004_snapshot.json +1969 -0
- package/migrations/meta/0005_snapshot.json +1991 -0
- package/migrations/meta/0006_snapshot.json +2097 -0
- package/migrations/meta/0007_snapshot.json +2128 -0
- package/migrations/meta/0008_snapshot.json +2133 -0
- package/migrations/meta/0009_snapshot.json +2161 -0
- package/migrations/meta/0010_snapshot.json +2265 -0
- package/migrations/meta/0011_snapshot.json +2448 -0
- package/migrations/meta/0012_snapshot.json +2577 -0
- package/migrations/meta/0013_snapshot.json +2594 -0
- package/migrations/meta/0014_snapshot.json +2602 -0
- package/migrations/meta/0015_snapshot.json +2778 -0
- package/migrations/meta/0016_snapshot.json +2778 -0
- package/migrations/meta/0017_snapshot.json +2792 -0
- package/migrations/meta/0018_snapshot.json +2778 -0
- package/migrations/meta/0019_snapshot.json +2792 -0
- package/migrations/meta/0020_snapshot.json +2785 -0
- package/migrations/meta/0021_snapshot.json +2762 -0
- package/migrations/meta/0022_snapshot.json +2769 -0
- package/migrations/meta/0023_snapshot.json +2900 -0
- package/migrations/meta/0024_snapshot.json +2907 -0
- package/migrations/meta/_journal.json +181 -0
- package/openapi/decision-api.yaml +12204 -0
- package/package.json +121 -4
- package/skills/README.md +19 -0
- package/skills/add-openhands-support/SKILL.md +113 -0
- package/skills/create-collection/SKILL.md +199 -0
- package/skills/create-collection/reference/claims-stack.md +106 -0
- package/skills/create-collection/reference/collection.md +111 -0
- package/skills/create-oracle/SKILL.md +400 -0
- package/skills/create-rubric/SKILL.md +130 -0
- package/skills/create-rubric/reference/format-cheatsheet.md +186 -0
- package/skills/create-rubric/templates/claim-form.example.json +60 -0
- package/skills/decision-api-client/SKILL.md +236 -0
- package/skills/decision-api-oracle/SKILL.md +336 -0
- package/skills/publish-protocol/SKILL.md +151 -0
- package/skills/publish-protocol/reference/publishing.md +116 -0
- package/skills/reference/engine-contract.md +222 -0
- package/skills/write-facts/SKILL.md +221 -0
- package/skills/write-facts/reference/examples/http-vendor.ts +88 -0
- package/skills/write-facts/reference/examples/price-matches-agreement.ts +67 -0
- package/skills/write-facts/reference/facts-api.md +232 -0
- package/templates/project/.dev.vars.example +93 -0
- package/templates/project/.editorconfig +9 -0
- package/templates/project/CLAUDE.md +45 -0
- package/templates/project/README.md +199 -0
- package/templates/project/biome.json +37 -0
- package/templates/project/gitignore +29 -0
- package/templates/project/package.json +32 -0
- package/templates/project/src/facts/index.ts +19 -0
- package/templates/project/src/index.ts +25 -0
- package/templates/project/test/api-lane.test.ts +57 -0
- package/templates/project/test/facts.test.ts +14 -0
- package/templates/project/tsconfig.json +25 -0
- package/templates/project/vitest.config.ts +13 -0
- package/templates/project/wrangler.jsonc +446 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `access(…)` — the one gate in front of every `/v1/api` route (go-prod spec §3.1, §3.4, §4.1). It
|
|
3
|
+
* names the caller and checks it against what the route declares, the same declaration the OpenAPI
|
|
4
|
+
* carries as `x-required-scope` / `x-capability` (the snapshot test holds the two together):
|
|
5
|
+
*
|
|
6
|
+
* - an API key (`Bearer eo_…`) — its scopes; `403 SCOPE` without the route's, and on a console-only
|
|
7
|
+
* route (`scope: "none"`);
|
|
8
|
+
* - a console member (`X-Auth-Type: ucan` + `X-Source-Id`) — the grant's capabilities, checked
|
|
9
|
+
* against the ROUTE's capability; `403 FORBIDDEN` without it (`console.ts` verifies the chain,
|
|
10
|
+
* and that the invocation signs this route's `op` action, `API_ACTIONS`);
|
|
11
|
+
* - an AI app over OAuth (S7) — only on `/v1/mcp`'s in-process calls, never from a header
|
|
12
|
+
* (`oauth.ts`): the user's live standing on the source AND the token's scopes;
|
|
13
|
+
* - `public` routes answer anyone and narrow to the source when a credential comes along;
|
|
14
|
+
* - `account` routes take a signed-in account with no source yet; `operator` an `ORACLE_ADMIN_DIDS`
|
|
15
|
+
* invoker.
|
|
16
|
+
*
|
|
17
|
+
* Authentication failures are `401`; everything valid-but-not-allowed `403`; a source that is not
|
|
18
|
+
* the caller's is `404`, never `403` (§14). `nb.protocols` narrowing is per claim, so the routes
|
|
19
|
+
* that touch one apply it (`reachesProtocol`).
|
|
20
|
+
*/
|
|
21
|
+
import { Capability, covers } from "../../contracts/index.js";
|
|
22
|
+
import { accountCaller, memberCaller, operatorCaller } from "./console.js";
|
|
23
|
+
import { ApiError } from "./errors.js";
|
|
24
|
+
import { isApiKey, keyCaller } from "./keys.js";
|
|
25
|
+
import { oauthCaller } from "./oauth.js";
|
|
26
|
+
import { limitCaller } from "./rate-limit.js";
|
|
27
|
+
export function access(spec) {
|
|
28
|
+
const mw = async (c, next) => {
|
|
29
|
+
c.set("caller", await callerFor(c, spec));
|
|
30
|
+
await next();
|
|
31
|
+
};
|
|
32
|
+
return Object.assign(mw, { access: spec });
|
|
33
|
+
}
|
|
34
|
+
async function callerFor(c, spec) {
|
|
35
|
+
// Only the MCP handler's in-process mark makes an OAuth caller (`oauth.ts`); its bearer is unread.
|
|
36
|
+
const oauth = c.get("oauth");
|
|
37
|
+
if (oauth)
|
|
38
|
+
return oauthCaller(c, spec, oauth);
|
|
39
|
+
const token = bearer(c);
|
|
40
|
+
switch (spec.capability) {
|
|
41
|
+
case "account":
|
|
42
|
+
return accountCaller(c, requireUcan(c, token), spec.op);
|
|
43
|
+
case "operator":
|
|
44
|
+
return operatorCaller(c, requireUcan(c, token), spec.op);
|
|
45
|
+
case "public":
|
|
46
|
+
if (!token)
|
|
47
|
+
return { kind: "anonymous" };
|
|
48
|
+
return sourceCaller(c, spec, token);
|
|
49
|
+
default:
|
|
50
|
+
if (!token)
|
|
51
|
+
throw new ApiError("UNAUTHORIZED", "This request has no API key. Send it in the Authorization header as `Bearer <key>`; create a key in the console (Keys).");
|
|
52
|
+
return sourceCaller(c, spec, token);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function sourceCaller(c, spec, token) {
|
|
56
|
+
const caller = isApiKey(token)
|
|
57
|
+
? await keyCaller(await c.var.db(), c.get("config"), token, (p) => c.executionCtx.waitUntil(p))
|
|
58
|
+
: await memberCaller(c, requireUcan(c, token), sourceIdOf(c), spec.op);
|
|
59
|
+
// Counted once authenticated, BEFORE the route's own check: a caller hammering a route it may
|
|
60
|
+
// not use is still spending its source's budget.
|
|
61
|
+
await limitCaller(c, caller);
|
|
62
|
+
if (caller.kind === "key") {
|
|
63
|
+
const { scope } = spec;
|
|
64
|
+
if (scope === "none") {
|
|
65
|
+
throw new ApiError("SCOPE", "This can only be done from the Decision Console, not with an API key. Sign in to the console to do it.");
|
|
66
|
+
}
|
|
67
|
+
if (scope !== null && !caller.key.scopes.includes(scope)) {
|
|
68
|
+
throw new ApiError("SCOPE", `This API key doesn't have the ${scope} permission. Create a key with it in the console (Keys) or ask the source's owner.`, { required: scope });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
const cap = spec.capability;
|
|
73
|
+
// `sourceCaller` is reached only for a capability route or a `public` one.
|
|
74
|
+
if (cap !== null && isCapability(cap) && !covers(caller.capabilities, cap)) {
|
|
75
|
+
throw new ApiError("FORBIDDEN", `Your role on this source doesn't allow this (it needs the ${cap} permission). Ask the source's owner for a role that includes it.`, { required: cap });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return caller;
|
|
79
|
+
}
|
|
80
|
+
function sourceIdOf(c) {
|
|
81
|
+
const sourceId = c.req.header("X-Source-Id");
|
|
82
|
+
if (!sourceId)
|
|
83
|
+
throw new ApiError("UNAUTHORIZED", "This console request doesn't say which source it is for. Pick a source in the console and try again (developers: send its id in the X-Source-Id header).");
|
|
84
|
+
return sourceId;
|
|
85
|
+
}
|
|
86
|
+
const isCapability = (v) => Capability.safeParse(v).success;
|
|
87
|
+
function bearer(c) {
|
|
88
|
+
const h = c.req.header("Authorization");
|
|
89
|
+
return h?.startsWith("Bearer ") ? h.slice(7).trim() || null : null;
|
|
90
|
+
}
|
|
91
|
+
function requireUcan(c, token) {
|
|
92
|
+
if (!token || c.req.header("X-Auth-Type") !== "ucan") {
|
|
93
|
+
throw new ApiError("UNAUTHORIZED", "This needs a Decision Console sign-in, not an API key. Sign in to the console and try again (developers: send a signed UCAN with the header X-Auth-Type: ucan).");
|
|
94
|
+
}
|
|
95
|
+
return token;
|
|
96
|
+
}
|
|
97
|
+
/** The caller of a source-scoped route — `access()` guarantees one. */
|
|
98
|
+
export function sourceOf(c) {
|
|
99
|
+
const caller = c.get("caller");
|
|
100
|
+
if (caller.kind !== "key" && caller.kind !== "member" && caller.kind !== "oauth") {
|
|
101
|
+
throw new ApiError("UNAUTHORIZED", "This needs an API key or a console sign-in on a source.");
|
|
102
|
+
}
|
|
103
|
+
return caller;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/middleware/api/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAK3C,MAAM,UAAU,MAAM,CAAC,IAAY;IACjC,MAAM,EAAE,GAA8B,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;QACtD,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;QAC1C,MAAM,IAAI,EAAE,CAAC;IACf,CAAC,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7C,CAAC;AAED,KAAK,UAAU,SAAS,CAAC,CAAa,EAAE,IAAY;IAClD,mGAAmG;IACnG,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,IAAI,KAAK;QAAE,OAAO,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACxB,QAAQ,IAAI,CAAC,UAAU,EAAE,CAAC;QACxB,KAAK,SAAS;YACZ,OAAO,aAAa,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QAC1D,KAAK,UAAU;YACb,OAAO,cAAc,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QAC3D,KAAK,QAAQ;YACX,IAAI,CAAC,KAAK;gBAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;YACzC,OAAO,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QACtC;YACE,IAAI,CAAC,KAAK;gBACR,MAAM,IAAI,QAAQ,CAChB,cAAc,EACd,yHAAyH,CAC1H,CAAC;YACJ,OAAO,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;AACH,CAAC;AAED,KAAK,UAAU,YAAY,CAAC,CAAa,EAAE,IAAY,EAAE,KAAa;IACpE,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC;QAC5B,CAAC,CAAC,MAAM,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC/F,CAAC,CAAC,MAAM,YAAY,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACzE,8FAA8F;IAC9F,iDAAiD;IACjD,MAAM,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAE7B,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QAC1B,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QACvB,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;YACrB,MAAM,IAAI,QAAQ,CAChB,OAAO,EACP,wGAAwG,CACzG,CAAC;QACJ,CAAC;QACD,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACzD,MAAM,IAAI,QAAQ,CAChB,OAAO,EACP,iCAAiC,KAAK,oFAAoF,EAC1H,EAAE,QAAQ,EAAE,KAAK,EAAE,CACpB,CAAC;QACJ,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC;QAC5B,2EAA2E;QAC3E,IAAI,GAAG,KAAK,IAAI,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,GAAG,CAAC,EAAE,CAAC;YAC3E,MAAM,IAAI,QAAQ,CAChB,WAAW,EACX,6DAA6D,GAAG,mEAAmE,EACnI,EAAE,QAAQ,EAAE,GAAG,EAAE,CAClB,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,UAAU,CAAC,CAAa;IAC/B,MAAM,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAC7C,IAAI,CAAC,QAAQ;QACX,MAAM,IAAI,QAAQ,CAChB,cAAc,EACd,0JAA0J,CAC3J,CAAC;IACJ,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,YAAY,GAAG,CAAC,CAAS,EAAmB,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AAErF,SAAS,MAAM,CAAC,CAAa;IAC3B,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IACxC,OAAO,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AACrE,CAAC;AAED,SAAS,WAAW,CAAC,CAAa,EAAE,KAAoB;IACtD,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,MAAM,EAAE,CAAC;QACrD,MAAM,IAAI,QAAQ,CAChB,cAAc,EACd,iKAAiK,CAClK,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,QAAQ,CAAC,CAAa;IACpC,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC/B,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QACjF,MAAM,IAAI,QAAQ,CAAC,cAAc,EAAE,yDAAyD,CAAC,CAAC;IAChG,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Decision Console's credential on `/v1/api` (go-prod spec §3.1, §3.4): a UCAN invocation the
|
|
3
|
+
* signed-in account signs DIRECTLY with its `did:ixo` key, addressed to this oracle's did:web, with
|
|
4
|
+
* ONE capability `{ with: <resource>, can: <the route's action> }` — `oracleResource` for
|
|
5
|
+
* account/operator routes, `sourceResource` (+ `X-Source-Id`) for a source's routes, carrying the
|
|
6
|
+
* member's role grant as its proof unless the invoker is a controller of the source's organisation. The action is the route's
|
|
7
|
+
* `API_ACTIONS` entry (CLAUDE.md "Capabilities: one action per route"): it says what the token is
|
|
8
|
+
* FOR; what the member may do is the grant's capability, checked by `auth.ts`. Any other `can`, the
|
|
9
|
+
* legacy `*` included, is 403.
|
|
10
|
+
*
|
|
11
|
+
* Not `@ixo/ucan`'s `validator.validate`: ucanto's `claim()` matches `can` by exact string, so it
|
|
12
|
+
* cannot say that `source/*` covers `claims/read`. This file walks the chain itself — at most two
|
|
13
|
+
* grant links (controller → member, or controller → co-owner holding `source/*` → member), one proof per link,
|
|
14
|
+
* every signature checked against a key the issuer's DID resolves to (`lib/ixo/grant-chain.ts`,
|
|
15
|
+
* shared with the chain lane's reviewer grants).
|
|
16
|
+
*
|
|
17
|
+
* Two halves, cached differently:
|
|
18
|
+
* - the SIGNED STRUCTURE (parse, audience, signatures, links chaining) is a pure function of the
|
|
19
|
+
* token: cached per sha256(token) in L1 + KV until the invocation's `exp` (at most 600 s), a
|
|
20
|
+
* deterministic failure negative-cached 30 s in L1 (401), resolver trouble never cached (503) —
|
|
21
|
+
* as ucan-auth;
|
|
22
|
+
* - the POLICY (source, roots, times, revocations, member row) runs on EVERY request, so a revoke
|
|
23
|
+
* is effective at once however warm the cache is. The roots are the organisation entity's
|
|
24
|
+
* CURRENT controllers, read live (`sourceRoots`, D1/D10) — there is no personal root.
|
|
25
|
+
*
|
|
26
|
+
* A grant is identified by its CANONICAL CID — sha2-256 over its UCAN re-encoded as DAG-CBOR —
|
|
27
|
+
* and a delegation filed under any other CID is refused: ucanto's CAR decode never checks a
|
|
28
|
+
* block's hash, so the presented CID is attacker-chosen. And a member's leaf must BE their stored
|
|
29
|
+
* grant (`api_members.delegationCid`), a co-owner's link the co-owner's own live stored grant: the
|
|
30
|
+
* revocation list is a second line, never the only one.
|
|
31
|
+
*
|
|
32
|
+
* `verifyGrant` is the same chain code over an uploaded grant CAR (`PUT /members/:id/delegation`);
|
|
33
|
+
* there every refusal is the uploader's mistake, so `400 VALIDATION`.
|
|
34
|
+
*/
|
|
35
|
+
import { type ApiOp, Capability, type MemberRole } from "../../contracts/capabilities.js";
|
|
36
|
+
import type { Database } from "../../db/client.js";
|
|
37
|
+
import { type ApiSource } from "../../db/schema.js";
|
|
38
|
+
import type { BlocksyncDeps } from "../../lib/ixo/blocksync/types.js";
|
|
39
|
+
import type { AccountCaller, ApiContext, MemberCaller, OperatorCaller } from "./types.js";
|
|
40
|
+
export { setDidResolverForTests } from "../../lib/ixo/grant-chain.js";
|
|
41
|
+
/** The Blocksync deps a request reads the roots with. */
|
|
42
|
+
export declare const chainOf: (c: Pick<ApiContext, "get">) => BlocksyncDeps;
|
|
43
|
+
/**
|
|
44
|
+
* A console member on `sourceId` (§3.4). Anyone who is neither one of the source's roots nor has a
|
|
45
|
+
* member row on it ⇒ 404, whatever they present (§14: never 403 across sources, so a sourceId
|
|
46
|
+
* cannot be probed); a root invoking as itself ⇒ `source/*`; a member ⇒ the chain's effective
|
|
47
|
+
* grant, provided its leaf IS their stored grant, it is rooted at a root (directly, or through a
|
|
48
|
+
* co-owner whose own stored grant is live), unexpired and unrevoked — else 403. The roots are the
|
|
49
|
+
* organisation entity's current controllers (D10): a controller invoking with no proof needs no
|
|
50
|
+
* member row (G13). A former controller with no row is a stranger: 404.
|
|
51
|
+
*/
|
|
52
|
+
export declare function memberCaller(c: ApiContext, token: string, sourceId: string, op: ApiOp): Promise<MemberCaller>;
|
|
53
|
+
/**
|
|
54
|
+
* What `did` may do on `source` NOW by its STORED grant — the OAuth caller's reading (S7), the same
|
|
55
|
+
* policy `memberCaller` applies to a presented chain: a root holds `source/*`; anyone else needs
|
|
56
|
+
* an accepted, unrevoked, unexpired member row whose stored grant (its canonical CID the row's)
|
|
57
|
+
* is rooted at a root directly or through a co-owner who is live now, with no link revoked.
|
|
58
|
+
* The CAR was verified when it was uploaded (`verifyGrant`), so only its links are read here, not
|
|
59
|
+
* its signatures. `roots` are the source's (`sourceRoots`, read live by the caller, who may share
|
|
60
|
+
* one read across a request's sources of one organisation). Null = no standing (the caller answers
|
|
61
|
+
* 404).
|
|
62
|
+
*/
|
|
63
|
+
export declare function storedGrant(db: Database, roots: readonly string[], oracleDid: string, source: ApiSource, did: string, now?: number): Promise<{
|
|
64
|
+
role: MemberRole;
|
|
65
|
+
capabilities: Capability[];
|
|
66
|
+
protocols: string[] | null;
|
|
67
|
+
} | null>;
|
|
68
|
+
/** A signed-in IXO account invoking as itself on `oracleResource` — no grant, no source. */
|
|
69
|
+
export declare function accountCaller(c: ApiContext, token: string, op: ApiOp): Promise<AccountCaller>;
|
|
70
|
+
/** An account invocation from one of `ORACLE_ADMIN_DIDS`. */
|
|
71
|
+
export declare function operatorCaller(c: ApiContext, token: string, op: ApiOp): Promise<OperatorCaller>;
|
|
72
|
+
export interface VerifiedGrant {
|
|
73
|
+
cid: string;
|
|
74
|
+
capabilities: Capability[];
|
|
75
|
+
protocols: string[] | null;
|
|
76
|
+
expiresAt: Date | null;
|
|
77
|
+
/** The CAR as uploaded. */
|
|
78
|
+
delegation: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* An uploaded role grant (`PUT /members/:memberId/delegation`, §3.4 step 3): to `memberDid`, rooted
|
|
82
|
+
* at a root — a current controller of the organisation — (or a co-owner holding
|
|
83
|
+
* `source/*`), over this source's resource, capabilities
|
|
84
|
+
* EXACTLY `role`'s preset, unexpired, no link revoked. Any refusal ⇒ `400 VALIDATION`; resolver
|
|
85
|
+
* trouble ⇒ 503.
|
|
86
|
+
*/
|
|
87
|
+
export declare function verifyGrant(c: ApiContext, delegation: string, target: {
|
|
88
|
+
source: ApiSource;
|
|
89
|
+
memberDid: string;
|
|
90
|
+
role: MemberRole;
|
|
91
|
+
}): Promise<VerifiedGrant>;
|
|
92
|
+
//# sourceMappingURL=console.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../../src/middleware/api/console.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAMH,OAAO,EAEL,KAAK,KAAK,EACV,UAAU,EACV,KAAK,UAAU,EAMhB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,KAAK,SAAS,EAAc,MAAM,iBAAiB,CAAC;AAG7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAenE,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAmCvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAoJnE,yDAAyD;AACzD,eAAO,MAAM,OAAO,MAAO,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,KAAG,aAGnD,CAAC;AA+DH;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAChC,CAAC,EAAE,UAAU,EACb,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,KAAK,GACR,OAAO,CAAC,YAAY,CAAC,CA4FvB;AAKD;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAC/B,EAAE,EAAE,QAAQ,EACZ,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,SAAS,EACjB,GAAG,EAAE,MAAM,EACX,GAAG,SAAgC,GAClC,OAAO,CAAC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,YAAY,EAAE,UAAU,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,CAAC,CAwB9F;AAED,4FAA4F;AAC5F,wBAAsB,aAAa,CACjC,CAAC,EAAE,UAAU,EACb,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,KAAK,GACR,OAAO,CAAC,aAAa,CAAC,CAwBxB;AAED,6DAA6D;AAC7D,wBAAsB,cAAc,CAClC,CAAC,EAAE,UAAU,EACb,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,KAAK,GACR,OAAO,CAAC,cAAc,CAAC,CASzB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,UAAU,EAAE,CAAC;IAC3B,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,2BAA2B;IAC3B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,CAAC,EAAE,UAAU,EACb,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GACjE,OAAO,CAAC,aAAa,CAAC,CAsDxB"}
|
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Decision Console's credential on `/v1/api` (go-prod spec §3.1, §3.4): a UCAN invocation the
|
|
3
|
+
* signed-in account signs DIRECTLY with its `did:ixo` key, addressed to this oracle's did:web, with
|
|
4
|
+
* ONE capability `{ with: <resource>, can: <the route's action> }` — `oracleResource` for
|
|
5
|
+
* account/operator routes, `sourceResource` (+ `X-Source-Id`) for a source's routes, carrying the
|
|
6
|
+
* member's role grant as its proof unless the invoker is a controller of the source's organisation. The action is the route's
|
|
7
|
+
* `API_ACTIONS` entry (CLAUDE.md "Capabilities: one action per route"): it says what the token is
|
|
8
|
+
* FOR; what the member may do is the grant's capability, checked by `auth.ts`. Any other `can`, the
|
|
9
|
+
* legacy `*` included, is 403.
|
|
10
|
+
*
|
|
11
|
+
* Not `@ixo/ucan`'s `validator.validate`: ucanto's `claim()` matches `can` by exact string, so it
|
|
12
|
+
* cannot say that `source/*` covers `claims/read`. This file walks the chain itself — at most two
|
|
13
|
+
* grant links (controller → member, or controller → co-owner holding `source/*` → member), one proof per link,
|
|
14
|
+
* every signature checked against a key the issuer's DID resolves to (`lib/ixo/grant-chain.ts`,
|
|
15
|
+
* shared with the chain lane's reviewer grants).
|
|
16
|
+
*
|
|
17
|
+
* Two halves, cached differently:
|
|
18
|
+
* - the SIGNED STRUCTURE (parse, audience, signatures, links chaining) is a pure function of the
|
|
19
|
+
* token: cached per sha256(token) in L1 + KV until the invocation's `exp` (at most 600 s), a
|
|
20
|
+
* deterministic failure negative-cached 30 s in L1 (401), resolver trouble never cached (503) —
|
|
21
|
+
* as ucan-auth;
|
|
22
|
+
* - the POLICY (source, roots, times, revocations, member row) runs on EVERY request, so a revoke
|
|
23
|
+
* is effective at once however warm the cache is. The roots are the organisation entity's
|
|
24
|
+
* CURRENT controllers, read live (`sourceRoots`, D1/D10) — there is no personal root.
|
|
25
|
+
*
|
|
26
|
+
* A grant is identified by its CANONICAL CID — sha2-256 over its UCAN re-encoded as DAG-CBOR —
|
|
27
|
+
* and a delegation filed under any other CID is refused: ucanto's CAR decode never checks a
|
|
28
|
+
* block's hash, so the presented CID is attacker-chosen. And a member's leaf must BE their stored
|
|
29
|
+
* grant (`api_members.delegationCid`), a co-owner's link the co-owner's own live stored grant: the
|
|
30
|
+
* revocation list is a second line, never the only one.
|
|
31
|
+
*
|
|
32
|
+
* `verifyGrant` is the same chain code over an uploaded grant CAR (`PUT /members/:id/delegation`);
|
|
33
|
+
* there every refusal is the uploader's mistake, so `400 VALIDATION`.
|
|
34
|
+
*/
|
|
35
|
+
import { eq } from "drizzle-orm";
|
|
36
|
+
import { AccountDid } from "../../contracts/api.js";
|
|
37
|
+
import { API_ACTIONS, Capability, oracleResource, PROTOCOL_SCOPED, ROLE_CAPABILITIES, roleOf, sourceResource, } from "../../contracts/capabilities.js";
|
|
38
|
+
import { apiSources } from "../../db/schema.js";
|
|
39
|
+
import { sourceRoots } from "../../lib/api-lane/company.js";
|
|
40
|
+
import { sha256Hex } from "../../lib/hash.js";
|
|
41
|
+
import { decode, finite, Invalid, proofsOf as proofsUnder, Refused, summarize, verifyChain, } from "../../lib/ixo/grant-chain.js";
|
|
42
|
+
import { oracleWebDid } from "../../lib/ixo/ucan.js";
|
|
43
|
+
import { REVIEWER_GRANT_MAX_SEC } from "../../lib/review/reviewer-grant.js";
|
|
44
|
+
import { ApiError, assertLinkedFor } from "./errors.js";
|
|
45
|
+
import { anyRevoked, coOwnerLive, memberRow } from "./membership.js";
|
|
46
|
+
/** Grant links in a chain, the invocation not counted (§3.4: "chains are at most two links"). */
|
|
47
|
+
const MAX_LINKS = 2;
|
|
48
|
+
/** Client clock drift allowed on the invocation's own `exp`/`nbf` (seconds). */
|
|
49
|
+
const SKEW_SEC = 30;
|
|
50
|
+
/** Deterministic-invalid tokens are negative-cached this long (as ucan-auth). */
|
|
51
|
+
const NEGATIVE_TTL_SEC = 30;
|
|
52
|
+
/** An invocation's longest life (§3.1, §14 "short-lived UCANs"); the console signs 120 s. */
|
|
53
|
+
const MAX_LIFETIME_SEC = 600;
|
|
54
|
+
/** L1 entries past this trigger a sweep of the expired ones (garbage tokens each add one). */
|
|
55
|
+
const L1_MAX = 10_000;
|
|
56
|
+
const KV_PREFIX = "api-ucan:";
|
|
57
|
+
/** A chain deeper than MAX_LINKS: the grant must come (more) directly from the owner. */
|
|
58
|
+
const passedOnTooFar = `it is passed on through more than ${MAX_LINKS} grants — an admin of the organisation (or a co-owner) must grant it directly`;
|
|
59
|
+
const proofsOf = (top) => proofsUnder(top, { max: MAX_LINKS, message: passedOnTooFar });
|
|
60
|
+
// Where the console tests install their DID resolver (it belongs to the chain code it fakes).
|
|
61
|
+
export { setDidResolverForTests } from "../../lib/ixo/grant-chain.js";
|
|
62
|
+
const l1 = new Map();
|
|
63
|
+
function remember(key, entry, now) {
|
|
64
|
+
l1.set(key, entry);
|
|
65
|
+
if (l1.size > L1_MAX) {
|
|
66
|
+
for (const [k, v] of l1)
|
|
67
|
+
if (v.exp <= now)
|
|
68
|
+
l1.delete(k);
|
|
69
|
+
// A flood of fresh garbage outlives the sweep: dropping the lot only costs re-verification.
|
|
70
|
+
if (l1.size > L1_MAX)
|
|
71
|
+
l1.clear();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** The 403's message: the request is signed, but the access it carries does not reach. */
|
|
75
|
+
const accessRefused = (reason) => `Your access to this source could not be confirmed: ${reason}.`;
|
|
76
|
+
/** The 401's message: what was wrong with the signed request, in words a console can show. */
|
|
77
|
+
const signInRefused = (reason) => `This request's sign-in could not be verified: ${reason}.`;
|
|
78
|
+
async function verifiedInvocation(c, token) {
|
|
79
|
+
const now = Math.floor(Date.now() / 1000);
|
|
80
|
+
const key = await sha256Hex(token);
|
|
81
|
+
const hit = l1.get(key);
|
|
82
|
+
if (hit && hit.exp > now) {
|
|
83
|
+
// The reason is cached with the refusal: a console retries, and a bare "invalid" on the second
|
|
84
|
+
// try leaves nobody able to tell what to fix.
|
|
85
|
+
if ("invalid" in hit)
|
|
86
|
+
throw new ApiError("UNAUTHORIZED", signInRefused(hit.invalid));
|
|
87
|
+
return hit.verified;
|
|
88
|
+
}
|
|
89
|
+
if (hit)
|
|
90
|
+
l1.delete(key);
|
|
91
|
+
const l2 = await c.env.CACHE_KV.get(`${KV_PREFIX}${key}`, "json").catch(() => null);
|
|
92
|
+
if (l2 && l2.exp > now) {
|
|
93
|
+
remember(key, { exp: Math.min(l2.exp, now + MAX_LIFETIME_SEC), verified: l2 }, now);
|
|
94
|
+
return l2;
|
|
95
|
+
}
|
|
96
|
+
const config = c.get("config");
|
|
97
|
+
let verified;
|
|
98
|
+
try {
|
|
99
|
+
verified = await verifyInvocation(config, token);
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
if (!(err instanceof Invalid))
|
|
103
|
+
throw err;
|
|
104
|
+
remember(key, { exp: now + NEGATIVE_TTL_SEC, invalid: err.message }, now);
|
|
105
|
+
c.get("logger").warn("api.ucan.invalid", { reason: err.message });
|
|
106
|
+
throw new ApiError("UNAUTHORIZED", signInRefused(err.message));
|
|
107
|
+
}
|
|
108
|
+
// Capped at the longest life a token may have: a far-future `exp` is refused by `checkWindow`
|
|
109
|
+
// until its last MAX_LIFETIME_SEC, and its verified entry must not sit in L1/KV meanwhile.
|
|
110
|
+
const ttl = Math.min(verified.exp - now, MAX_LIFETIME_SEC);
|
|
111
|
+
remember(key, { exp: now + ttl, verified }, now);
|
|
112
|
+
if (ttl > 0) {
|
|
113
|
+
// KV's floor is 60 s; the `exp` inside the value is what a read trusts.
|
|
114
|
+
await c.env.CACHE_KV.put(`${KV_PREFIX}${key}`, JSON.stringify(verified), {
|
|
115
|
+
expirationTtl: Math.max(60, ttl),
|
|
116
|
+
}).catch(() => { });
|
|
117
|
+
}
|
|
118
|
+
return verified;
|
|
119
|
+
}
|
|
120
|
+
async function verifyInvocation(config, token) {
|
|
121
|
+
const inv = await decode(token);
|
|
122
|
+
const audience = oracleWebDid(config);
|
|
123
|
+
if (inv.audience.did() !== audience) {
|
|
124
|
+
throw new Invalid(`it was signed for ${inv.audience.did()}, but this oracle is ${audience} — use the id from /.well-known/did.json`);
|
|
125
|
+
}
|
|
126
|
+
const [cap, ...rest] = inv.capabilities;
|
|
127
|
+
if (!cap || rest.length > 0 || !cap.can) {
|
|
128
|
+
throw new Invalid('it must carry exactly one capability: { with: "<resource>", can: "<the route\'s action>" }');
|
|
129
|
+
}
|
|
130
|
+
const exp = finite(inv.expiration);
|
|
131
|
+
if (exp === null)
|
|
132
|
+
throw new Invalid(`it has no expiry — give it one of at most ${MAX_LIFETIME_SEC} s`);
|
|
133
|
+
// A too-deep chain is refused before anything is resolved.
|
|
134
|
+
let proofs;
|
|
135
|
+
try {
|
|
136
|
+
proofs = await proofsOf(inv);
|
|
137
|
+
}
|
|
138
|
+
catch (err) {
|
|
139
|
+
if (err instanceof Refused)
|
|
140
|
+
throw new ApiError("FORBIDDEN", accessRefused(err.message));
|
|
141
|
+
throw err;
|
|
142
|
+
}
|
|
143
|
+
await verifyChain(config, [...proofs, inv]);
|
|
144
|
+
return {
|
|
145
|
+
invoker: inv.issuer.did(),
|
|
146
|
+
resource: cap.with,
|
|
147
|
+
can: cap.can,
|
|
148
|
+
exp,
|
|
149
|
+
nbf: finite(inv.notBefore),
|
|
150
|
+
links: await Promise.all(proofs.map(summarize)),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/** The invocation's own window — an authentication fact, so 401. */
|
|
154
|
+
function checkWindow(v, now) {
|
|
155
|
+
if (v.exp + SKEW_SEC < now)
|
|
156
|
+
throw new ApiError("UNAUTHORIZED", signInRefused("it has expired — sign a fresh request (and check the device clock)"));
|
|
157
|
+
// UCAN invocations carry no issued-at, so `exp - now` alone would accept a far-future token once
|
|
158
|
+
// it is within its last MAX_LIFETIME_SEC; a stated `nbf` bounds the whole window as well.
|
|
159
|
+
if (v.exp - now > MAX_LIFETIME_SEC || (v.nbf !== null && v.exp - v.nbf > MAX_LIFETIME_SEC)) {
|
|
160
|
+
throw new ApiError("UNAUTHORIZED", signInRefused(`it is valid for too long — at most ${MAX_LIFETIME_SEC} s`));
|
|
161
|
+
}
|
|
162
|
+
if (v.nbf !== null && v.nbf - SKEW_SEC > now) {
|
|
163
|
+
throw new ApiError("UNAUTHORIZED", signInRefused("it is not valid yet — check the device clock"));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* The invocation's `can` must be the route's action. Anything else — another route's action, `*`, or
|
|
168
|
+
* none (a cache entry from before actions) — is 403: the token is genuine, just not for this call.
|
|
169
|
+
*/
|
|
170
|
+
function checkAction(v, op) {
|
|
171
|
+
const action = API_ACTIONS[op];
|
|
172
|
+
if (v.can === action)
|
|
173
|
+
return;
|
|
174
|
+
throw new ApiError("FORBIDDEN", `This request was signed for "${v.can ?? "*"}", but this route takes "${action}". Reload the console and try again.`);
|
|
175
|
+
}
|
|
176
|
+
/** The Blocksync deps a request reads the roots with. */
|
|
177
|
+
export const chainOf = (c) => ({
|
|
178
|
+
config: c.get("config"),
|
|
179
|
+
trace: c.get("trace"),
|
|
180
|
+
});
|
|
181
|
+
/**
|
|
182
|
+
* What a chain grants over `resource`, rooted at one of the source's `roots` (§3.4, D1). Every capability of every link
|
|
183
|
+
* must be over exactly `resource`, so a grant for another source proves nothing here. A two-link
|
|
184
|
+
* chain's middle issuer must hold `source/*` from a root, so the leaf's capabilities are the
|
|
185
|
+
* effective ones (the intersection with `source/*` is the leaf itself). Unknown `can` values grant
|
|
186
|
+
* nothing.
|
|
187
|
+
*/
|
|
188
|
+
function grantOf(links, roots, resource, now) {
|
|
189
|
+
const root = links[0];
|
|
190
|
+
const leaf = links.at(-1);
|
|
191
|
+
if (!root || !leaf)
|
|
192
|
+
throw new Refused("no access grant was sent");
|
|
193
|
+
if (!roots.includes(root.issuer))
|
|
194
|
+
throw new Refused("the access was not granted by a current admin (controller) of the source's organisation");
|
|
195
|
+
for (const link of links) {
|
|
196
|
+
if (link.exp !== null && link.exp < now)
|
|
197
|
+
throw new Refused("the access grant has expired — an admin of the organisation must invite you again");
|
|
198
|
+
if (link.nbf !== null && link.nbf > now)
|
|
199
|
+
throw new Refused("the access grant has not started yet — check the device clock");
|
|
200
|
+
if (link.caps.some((cap) => cap.with !== resource)) {
|
|
201
|
+
throw new Refused("the access grant is for a different source");
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const known = (link) => link.caps.flatMap((cap) => {
|
|
205
|
+
const can = Capability.safeParse(cap.can);
|
|
206
|
+
return can.success ? [{ can: can.data, protocols: cap.protocols }] : [];
|
|
207
|
+
});
|
|
208
|
+
if (links.length === 2 && !known(root).some((cap) => cap.can === "source/*")) {
|
|
209
|
+
throw new Refused("the person who granted this access is not a co-owner of this source");
|
|
210
|
+
}
|
|
211
|
+
const capabilities = [...new Set(known(leaf).map((cap) => cap.can))];
|
|
212
|
+
if (capabilities.length === 0)
|
|
213
|
+
throw new Refused("the access grant gives no permissions this oracle knows");
|
|
214
|
+
// Per link: the union of the protocols its claims/* caps name — ANY cap that names some narrows the
|
|
215
|
+
// link (a grant never comes out wider than what was signed: a `claims/submit` limited to one
|
|
216
|
+
// protocol beside an unlimited `claims/read` still limits submitting); along the chain: the
|
|
217
|
+
// intersection of the links that narrow.
|
|
218
|
+
let protocols = null;
|
|
219
|
+
for (const link of links) {
|
|
220
|
+
const scoped = known(link).filter((cap) => PROTOCOL_SCOPED.includes(cap.can));
|
|
221
|
+
if (scoped.every((cap) => !cap.protocols))
|
|
222
|
+
continue;
|
|
223
|
+
const union = [...new Set(scoped.flatMap((cap) => cap.protocols ?? []))];
|
|
224
|
+
protocols = protocols === null ? union : protocols.filter((p) => union.includes(p));
|
|
225
|
+
}
|
|
226
|
+
const exps = links.map((l) => l.exp).filter((e) => e !== null);
|
|
227
|
+
return {
|
|
228
|
+
capabilities,
|
|
229
|
+
protocols,
|
|
230
|
+
exp: exps.length > 0 ? Math.min(...exps) : null,
|
|
231
|
+
leafCans: leaf.caps.map((cap) => cap.can),
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
// --- the callers -------------------------------------------------------------------------------
|
|
235
|
+
/**
|
|
236
|
+
* A console member on `sourceId` (§3.4). Anyone who is neither one of the source's roots nor has a
|
|
237
|
+
* member row on it ⇒ 404, whatever they present (§14: never 403 across sources, so a sourceId
|
|
238
|
+
* cannot be probed); a root invoking as itself ⇒ `source/*`; a member ⇒ the chain's effective
|
|
239
|
+
* grant, provided its leaf IS their stored grant, it is rooted at a root (directly, or through a
|
|
240
|
+
* co-owner whose own stored grant is live), unexpired and unrevoked — else 403. The roots are the
|
|
241
|
+
* organisation entity's current controllers (D10): a controller invoking with no proof needs no
|
|
242
|
+
* member row (G13). A former controller with no row is a stranger: 404.
|
|
243
|
+
*/
|
|
244
|
+
export async function memberCaller(c, token, sourceId, op) {
|
|
245
|
+
const v = await verifiedInvocation(c, token);
|
|
246
|
+
const now = Math.floor(Date.now() / 1000);
|
|
247
|
+
checkWindow(v, now);
|
|
248
|
+
const db = await c.var.db();
|
|
249
|
+
// Both reads at once: a missing source and a source the caller is not in answer the same 404,
|
|
250
|
+
// and must not take measurably different times either (§14).
|
|
251
|
+
const [source, row] = await Promise.all([
|
|
252
|
+
db.query.apiSources.findFirst({ where: eq(apiSources.sourceId, sourceId) }),
|
|
253
|
+
memberRow(db, sourceId, v.invoker),
|
|
254
|
+
]);
|
|
255
|
+
const roots = source ? await sourceRoots(chainOf(c), source) : [];
|
|
256
|
+
const isRoot = roots.includes(v.invoker);
|
|
257
|
+
if (!source || (!isRoot && !row))
|
|
258
|
+
throw new ApiError("NOT_FOUND",
|
|
259
|
+
// The id is not echoed: the message is logged, and a pending source's id never is.
|
|
260
|
+
"This source was not found, or you are not a member of it. Check that you are signed in with the right account.");
|
|
261
|
+
const resource = sourceResource(oracleWebDid(c.get("config")), sourceId);
|
|
262
|
+
if (v.resource !== resource)
|
|
263
|
+
throw new ApiError("FORBIDDEN", "This request was signed for a different source than the one it names. Reload the console and try again.");
|
|
264
|
+
// After the 404: a non-member learns nothing about the source from the action's refusal.
|
|
265
|
+
checkAction(v, op);
|
|
266
|
+
// D10: once, here, for every console route — the few a source that is not linked still answers
|
|
267
|
+
// (lists, me, the sync and the ways out) are the helper's.
|
|
268
|
+
assertLinkedFor(source, op);
|
|
269
|
+
if (isRoot && v.links.length === 0) {
|
|
270
|
+
return {
|
|
271
|
+
kind: "member",
|
|
272
|
+
source,
|
|
273
|
+
did: v.invoker,
|
|
274
|
+
controller: true,
|
|
275
|
+
memberId: row?.memberId ?? null,
|
|
276
|
+
role: "owner",
|
|
277
|
+
capabilities: ["source/*"],
|
|
278
|
+
protocols: null,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
if (!row?.acceptedAt)
|
|
282
|
+
throw new ApiError("FORBIDDEN", "You were invited to this source but haven't accepted the invitation yet. Open the invitation link to accept it, then try again.");
|
|
283
|
+
if (row.revokedAt)
|
|
284
|
+
throw new ApiError("FORBIDDEN", "You're no longer a member of this source — ask an admin of its organisation to invite you again.");
|
|
285
|
+
if (v.links.length === 0)
|
|
286
|
+
throw new ApiError("FORBIDDEN", "This request didn't include your access to this source. Reload the console so it picks up your access, then try again.");
|
|
287
|
+
// The schema's rule: a member without a stored grant can call nothing.
|
|
288
|
+
if (!row.delegationCid || v.links.at(-1)?.cid !== row.delegationCid) {
|
|
289
|
+
throw new ApiError("FORBIDDEN", "Your access to this source has changed since you signed in. Reload the console to pick up your current access.");
|
|
290
|
+
}
|
|
291
|
+
let grant;
|
|
292
|
+
try {
|
|
293
|
+
grant = grantOf(v.links, roots, resource, now);
|
|
294
|
+
if (!(await coOwnerLive(db, sourceId, v.links, now)))
|
|
295
|
+
throw new Refused(coOwnerGone);
|
|
296
|
+
}
|
|
297
|
+
catch (err) {
|
|
298
|
+
if (err instanceof Refused)
|
|
299
|
+
throw new ApiError("FORBIDDEN", accessRefused(err.message));
|
|
300
|
+
throw err;
|
|
301
|
+
}
|
|
302
|
+
if (await anyRevoked(db, sourceId, v.links)) {
|
|
303
|
+
throw new ApiError("FORBIDDEN", "Your access to this source has been revoked — ask an admin of its organisation to invite you again.");
|
|
304
|
+
}
|
|
305
|
+
return {
|
|
306
|
+
kind: "member",
|
|
307
|
+
source,
|
|
308
|
+
did: v.invoker,
|
|
309
|
+
controller: false,
|
|
310
|
+
memberId: row.memberId,
|
|
311
|
+
role: row.role,
|
|
312
|
+
capabilities: grant.capabilities,
|
|
313
|
+
protocols: grant.protocols,
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
const coOwnerGone = "the co-owner who granted this access no longer has owner access — an admin of the organisation must invite you again";
|
|
317
|
+
/**
|
|
318
|
+
* What `did` may do on `source` NOW by its STORED grant — the OAuth caller's reading (S7), the same
|
|
319
|
+
* policy `memberCaller` applies to a presented chain: a root holds `source/*`; anyone else needs
|
|
320
|
+
* an accepted, unrevoked, unexpired member row whose stored grant (its canonical CID the row's)
|
|
321
|
+
* is rooted at a root directly or through a co-owner who is live now, with no link revoked.
|
|
322
|
+
* The CAR was verified when it was uploaded (`verifyGrant`), so only its links are read here, not
|
|
323
|
+
* its signatures. `roots` are the source's (`sourceRoots`, read live by the caller, who may share
|
|
324
|
+
* one read across a request's sources of one organisation). Null = no standing (the caller answers
|
|
325
|
+
* 404).
|
|
326
|
+
*/
|
|
327
|
+
export async function storedGrant(db, roots, oracleDid, source, did, now = Math.floor(Date.now() / 1000)) {
|
|
328
|
+
if (roots.includes(did))
|
|
329
|
+
return { role: "owner", capabilities: ["source/*"], protocols: null };
|
|
330
|
+
const row = await memberRow(db, source.sourceId, did);
|
|
331
|
+
if (!row?.acceptedAt || row.revokedAt || !row.delegation || !row.delegationCid)
|
|
332
|
+
return null;
|
|
333
|
+
if (row.expiresAt && row.expiresAt.getTime() <= now * 1000)
|
|
334
|
+
return null;
|
|
335
|
+
let links;
|
|
336
|
+
try {
|
|
337
|
+
const leaf = await decode(row.delegation);
|
|
338
|
+
links = await Promise.all([...(await proofsOf(leaf)), leaf].map(summarize));
|
|
339
|
+
}
|
|
340
|
+
catch (err) {
|
|
341
|
+
if (err instanceof Invalid || err instanceof Refused)
|
|
342
|
+
return null;
|
|
343
|
+
throw err;
|
|
344
|
+
}
|
|
345
|
+
if (links.at(-1)?.cid !== row.delegationCid)
|
|
346
|
+
return null;
|
|
347
|
+
let grant;
|
|
348
|
+
try {
|
|
349
|
+
grant = grantOf(links, roots, sourceResource(oracleDid, source.sourceId), now);
|
|
350
|
+
}
|
|
351
|
+
catch (err) {
|
|
352
|
+
if (err instanceof Refused)
|
|
353
|
+
return null;
|
|
354
|
+
throw err;
|
|
355
|
+
}
|
|
356
|
+
if (!(await coOwnerLive(db, source.sourceId, links, now)))
|
|
357
|
+
return null;
|
|
358
|
+
if (await anyRevoked(db, source.sourceId, links))
|
|
359
|
+
return null;
|
|
360
|
+
return { role: row.role, capabilities: grant.capabilities, protocols: grant.protocols };
|
|
361
|
+
}
|
|
362
|
+
/** A signed-in IXO account invoking as itself on `oracleResource` — no grant, no source. */
|
|
363
|
+
export async function accountCaller(c, token, op) {
|
|
364
|
+
const v = await verifiedInvocation(c, token);
|
|
365
|
+
checkWindow(v, Math.floor(Date.now() / 1000));
|
|
366
|
+
if (v.links.length > 0) {
|
|
367
|
+
throw new ApiError("FORBIDDEN", "Account requests are signed by your own account alone, without a source's access attached. Reload the console and try again.");
|
|
368
|
+
}
|
|
369
|
+
const expected = oracleResource(oracleWebDid(c.get("config")));
|
|
370
|
+
if (v.resource !== expected) {
|
|
371
|
+
throw new ApiError("FORBIDDEN", `This request was signed for ${v.resource}, but account requests must be signed for ${expected}. Reload the console and try again.`);
|
|
372
|
+
}
|
|
373
|
+
checkAction(v, op);
|
|
374
|
+
if (!AccountDid.safeParse(v.invoker).success) {
|
|
375
|
+
throw new ApiError("FORBIDDEN", `Only IXO accounts (did:ixo:…) can do this, and ${v.invoker} is not one. Sign in to the console with your IXO account.`);
|
|
376
|
+
}
|
|
377
|
+
return { kind: "account", did: v.invoker };
|
|
378
|
+
}
|
|
379
|
+
/** An account invocation from one of `ORACLE_ADMIN_DIDS`. */
|
|
380
|
+
export async function operatorCaller(c, token, op) {
|
|
381
|
+
const { did } = await accountCaller(c, token, op);
|
|
382
|
+
if (!c.get("config").ORACLE_ADMIN_DIDS.includes(did)) {
|
|
383
|
+
throw new ApiError("FORBIDDEN", "Only this oracle's operators can do this, and your account is not one of them.");
|
|
384
|
+
}
|
|
385
|
+
return { kind: "operator", did };
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* An uploaded role grant (`PUT /members/:memberId/delegation`, §3.4 step 3): to `memberDid`, rooted
|
|
389
|
+
* at a root — a current controller of the organisation — (or a co-owner holding
|
|
390
|
+
* `source/*`), over this source's resource, capabilities
|
|
391
|
+
* EXACTLY `role`'s preset, unexpired, no link revoked. Any refusal ⇒ `400 VALIDATION`; resolver
|
|
392
|
+
* trouble ⇒ 503.
|
|
393
|
+
*/
|
|
394
|
+
export async function verifyGrant(c, delegation, target) {
|
|
395
|
+
const { source } = target;
|
|
396
|
+
const config = c.get("config");
|
|
397
|
+
const resource = sourceResource(oracleWebDid(config), source.sourceId);
|
|
398
|
+
const now = Math.floor(Date.now() / 1000);
|
|
399
|
+
try {
|
|
400
|
+
const leaf = await decode(delegation);
|
|
401
|
+
if (leaf.audience.did() !== target.memberDid) {
|
|
402
|
+
throw new Refused("it is issued to a different account than this member's");
|
|
403
|
+
}
|
|
404
|
+
const chain = [...(await proofsOf(leaf)), leaf];
|
|
405
|
+
if (chain.length > MAX_LINKS)
|
|
406
|
+
throw new Refused(passedOnTooFar);
|
|
407
|
+
await verifyChain(config, chain);
|
|
408
|
+
const links = await Promise.all(chain.map(summarize));
|
|
409
|
+
const grant = grantOf(links, await sourceRoots(chainOf(c), source), resource, now);
|
|
410
|
+
const unknown = grant.leafCans.filter((can) => !Capability.safeParse(can).success);
|
|
411
|
+
if (unknown.length > 0 || roleOf(grant.capabilities) !== target.role) {
|
|
412
|
+
throw new Refused(`it must give exactly the ${target.role} role's permissions (${ROLE_CAPABILITIES[target.role].join(", ")})`);
|
|
413
|
+
}
|
|
414
|
+
// A grant that reviews is the first link of every answer's `reviewerGrant`, which the engine
|
|
415
|
+
// holds to its window (lib/review/reviewer-grant.ts `parseMemberReviewGrant`): refuse one that
|
|
416
|
+
// could never stand there now, not at the member's first answer.
|
|
417
|
+
const leafLink = links.at(-1);
|
|
418
|
+
if (leafLink.caps.some((cap) => cap.can === "claims/review") &&
|
|
419
|
+
(leafLink.nbf === null ||
|
|
420
|
+
leafLink.exp === null ||
|
|
421
|
+
leafLink.exp - leafLink.nbf > REVIEWER_GRANT_MAX_SEC)) {
|
|
422
|
+
throw new Refused(`reviewer grants last at most ${REVIEWER_GRANT_MAX_SEC / 86_400} days, with a start (nbf) and an end (exp) — re-grant this role with a window of 30 days or less`);
|
|
423
|
+
}
|
|
424
|
+
const db = await c.var.db();
|
|
425
|
+
if (!(await coOwnerLive(db, source.sourceId, links, now)))
|
|
426
|
+
throw new Refused(coOwnerGone);
|
|
427
|
+
if (await anyRevoked(db, source.sourceId, links)) {
|
|
428
|
+
throw new Refused("it (or the grant it builds on) has been revoked");
|
|
429
|
+
}
|
|
430
|
+
return {
|
|
431
|
+
// Canonical (`summarize`): what the row stores, `memberCaller` binds and a revoke lists.
|
|
432
|
+
cid: links.at(-1).cid,
|
|
433
|
+
capabilities: grant.capabilities,
|
|
434
|
+
protocols: grant.protocols,
|
|
435
|
+
expiresAt: grant.exp === null ? null : new Date(grant.exp * 1000),
|
|
436
|
+
delegation,
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
catch (err) {
|
|
440
|
+
if (err instanceof Invalid || err instanceof Refused) {
|
|
441
|
+
throw new ApiError("VALIDATION", `This role grant can't be accepted: ${err.message}.`);
|
|
442
|
+
}
|
|
443
|
+
throw err;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
//# sourceMappingURL=console.js.map
|