@powerhousedao/switchboard 6.2.3 → 6.3.0-dev.10
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/.tsbuild/test/ai-gateway.test.d.ts +2 -0
- package/.tsbuild/test/ai-gateway.test.d.ts.map +1 -0
- package/.tsbuild/test/attachments/reserve-metadata-parity.test.d.ts +2 -0
- package/.tsbuild/test/attachments/reserve-metadata-parity.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-auth-config.test.d.ts +2 -0
- package/.tsbuild/test/boot-auth-config.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-desktop-auth.test.d.ts +2 -0
- package/.tsbuild/test/boot-desktop-auth.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-env-isolation.test.d.ts +2 -0
- package/.tsbuild/test/boot-env-isolation.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-helpers.d.ts +5 -0
- package/.tsbuild/test/boot-helpers.d.ts.map +1 -0
- package/.tsbuild/test/boot-inspection-enabled.test.d.ts +2 -0
- package/.tsbuild/test/boot-inspection-enabled.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-mcp-auth.test.d.ts +2 -0
- package/.tsbuild/test/boot-mcp-auth.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-port-zero.test.d.ts +2 -0
- package/.tsbuild/test/boot-port-zero.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-preconditions.test.d.ts +2 -0
- package/.tsbuild/test/boot-preconditions.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-privacy.test.d.ts +2 -0
- package/.tsbuild/test/boot-privacy.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-ready-drives.test.d.ts +2 -0
- package/.tsbuild/test/boot-ready-drives.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-undo-v3-flag.test.d.ts +2 -0
- package/.tsbuild/test/boot-undo-v3-flag.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-workflow-singleton-conflict.test.d.ts +2 -0
- package/.tsbuild/test/boot-workflow-singleton-conflict.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-workflow-singleton-retry.test.d.ts +2 -0
- package/.tsbuild/test/boot-workflow-singleton-retry.test.d.ts.map +1 -0
- package/.tsbuild/test/config-from-env.test.d.ts +2 -0
- package/.tsbuild/test/config-from-env.test.d.ts.map +1 -0
- package/.tsbuild/test/config-merge.test.d.ts +2 -0
- package/.tsbuild/test/config-merge.test.d.ts.map +1 -0
- package/.tsbuild/test/config-schema.test.d.ts +2 -0
- package/.tsbuild/test/config-schema.test.d.ts.map +1 -0
- package/.tsbuild/test/default-composition.test.d.ts +2 -0
- package/.tsbuild/test/default-composition.test.d.ts.map +1 -0
- package/.tsbuild/test/default-drive-protocol-versions.test.d.ts +2 -0
- package/.tsbuild/test/default-drive-protocol-versions.test.d.ts.map +1 -0
- package/.tsbuild/test/default-drive-slug.test.d.ts +2 -0
- package/.tsbuild/test/default-drive-slug.test.d.ts.map +1 -0
- package/.tsbuild/test/delegated-publish.test.d.ts +2 -0
- package/.tsbuild/test/delegated-publish.test.d.ts.map +1 -0
- package/.tsbuild/test/durable-node-fs-pg16.test.d.ts +2 -0
- package/.tsbuild/test/durable-node-fs-pg16.test.d.ts.map +1 -0
- package/.tsbuild/test/fixtures/mixed-subgraphs/subgraphs/greetings/index.d.ts +13 -0
- package/.tsbuild/test/fixtures/mixed-subgraphs/subgraphs/greetings/index.d.ts.map +1 -0
- package/.tsbuild/test/fixtures/mixed-subgraphs/subgraphs/index.d.ts +3 -0
- package/.tsbuild/test/fixtures/mixed-subgraphs/subgraphs/index.d.ts.map +1 -0
- package/.tsbuild/test/fixtures/mixed-subgraphs/subgraphs/tally/index.d.ts +7 -0
- package/.tsbuild/test/fixtures/mixed-subgraphs/subgraphs/tally/index.d.ts.map +1 -0
- package/.tsbuild/test/inspection-throttle.test.d.ts +2 -0
- package/.tsbuild/test/inspection-throttle.test.d.ts.map +1 -0
- package/.tsbuild/test/keyframe-reclaim-store.test.d.ts +2 -0
- package/.tsbuild/test/keyframe-reclaim-store.test.d.ts.map +1 -0
- package/.tsbuild/test/observability-signals.test.d.ts +2 -0
- package/.tsbuild/test/observability-signals.test.d.ts.map +1 -0
- package/.tsbuild/test/permissions-backfill.test.d.ts +2 -0
- package/.tsbuild/test/permissions-backfill.test.d.ts.map +1 -0
- package/.tsbuild/test/pglite-preflight.test.d.ts +2 -0
- package/.tsbuild/test/pglite-preflight.test.d.ts.map +1 -0
- package/.tsbuild/test/pglite-storage-dirs.test.d.ts +2 -0
- package/.tsbuild/test/pglite-storage-dirs.test.d.ts.map +1 -0
- package/.tsbuild/test/pglite-store.test.d.ts +2 -0
- package/.tsbuild/test/pglite-store.test.d.ts.map +1 -0
- package/.tsbuild/test/plugin-config-schemas.test.d.ts +2 -0
- package/.tsbuild/test/plugin-config-schemas.test.d.ts.map +1 -0
- package/.tsbuild/test/plugin-presence.test.d.ts +2 -0
- package/.tsbuild/test/plugin-presence.test.d.ts.map +1 -0
- package/.tsbuild/test/port-probe.test.d.ts +2 -0
- package/.tsbuild/test/port-probe.test.d.ts.map +1 -0
- package/.tsbuild/test/processor-timing-log.test.d.ts +2 -0
- package/.tsbuild/test/processor-timing-log.test.d.ts.map +1 -0
- package/.tsbuild/test/renown-storage-path.test.d.ts +2 -0
- package/.tsbuild/test/renown-storage-path.test.d.ts.map +1 -0
- package/.tsbuild/test/served-schemas-mixed-package.test.d.ts +2 -0
- package/.tsbuild/test/served-schemas-mixed-package.test.d.ts.map +1 -0
- package/.tsbuild/test/served-schemas.test.d.ts +2 -0
- package/.tsbuild/test/served-schemas.test.d.ts.map +1 -0
- package/.tsbuild/test/shutdown.test.d.ts +2 -0
- package/.tsbuild/test/shutdown.test.d.ts.map +1 -0
- package/.tsbuild/test/snapshot-writer.d.ts +18 -0
- package/.tsbuild/test/snapshot-writer.d.ts.map +1 -0
- package/.tsbuild/test/store-lock.test.d.ts +2 -0
- package/.tsbuild/test/store-lock.test.d.ts.map +1 -0
- package/.tsbuild/test/two-switchboards.test.d.ts +2 -0
- package/.tsbuild/test/two-switchboards.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/oauth-apps-config.test.d.ts +2 -0
- package/.tsbuild/test/workflow/oauth-apps-config.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/runtime-host.test.d.ts +2 -0
- package/.tsbuild/test/workflow/runtime-host.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/waitpoint-routes.test.d.ts +2 -0
- package/.tsbuild/test/workflow/waitpoint-routes.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/waitpoint-runtime.test.d.ts +2 -0
- package/.tsbuild/test/workflow/waitpoint-runtime.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow-reactor-access.test.d.ts +2 -0
- package/.tsbuild/test/workflow-reactor-access.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow-reactor-enforcement.test.d.ts +2 -0
- package/.tsbuild/test/workflow-reactor-enforcement.test.d.ts.map +1 -0
- package/.tsbuild/test/workflows-plugin-config.test.d.ts +2 -0
- package/.tsbuild/test/workflows-plugin-config.test.d.ts.map +1 -0
- package/.tsbuild/tsconfig.tsbuildinfo +1 -1
- package/Auth.md +108 -2
- package/CHANGELOG.md +1122 -2
- package/README.md +69 -24
- package/dist/boot.d.mts +46 -0
- package/dist/boot.d.mts.map +1 -0
- package/dist/boot.mjs +67 -0
- package/dist/boot.mjs.map +1 -0
- package/dist/config/from-env.d.mts +15 -0
- package/dist/config/from-env.d.mts.map +1 -0
- package/dist/config/from-env.mjs +4 -0
- package/dist/config/schema.d.mts +3 -0
- package/dist/config/schema.mjs +4 -0
- package/dist/from-env-DKK_wPrO.mjs +497 -0
- package/dist/from-env-DKK_wPrO.mjs.map +1 -0
- package/dist/index.d.mts +1 -2
- package/dist/index.mjs +40 -219
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-VW52B8KD.mjs +32 -0
- package/dist/mcp-VW52B8KD.mjs.map +1 -0
- package/dist/migrate.mjs +5 -4
- package/dist/migrate.mjs.map +1 -1
- package/dist/observability-CldagyT_.mjs +224 -0
- package/dist/observability-CldagyT_.mjs.map +1 -0
- package/dist/observability.d.mts +30 -0
- package/dist/observability.d.mts.map +1 -0
- package/dist/observability.mjs +4 -0
- package/dist/plugin-host-tTjDTNz0.d.mts +46 -0
- package/dist/plugin-host-tTjDTNz0.d.mts.map +1 -0
- package/dist/plugins/ai.d.mts +37 -0
- package/dist/plugins/ai.d.mts.map +1 -0
- package/dist/plugins/ai.mjs +400 -0
- package/dist/plugins/ai.mjs.map +1 -0
- package/dist/plugins/attachments.d.mts +33 -0
- package/dist/plugins/attachments.d.mts.map +1 -0
- package/dist/plugins/attachments.mjs +4 -0
- package/dist/plugins/mcp.d.mts +31 -0
- package/dist/plugins/mcp.d.mts.map +1 -0
- package/dist/plugins/mcp.mjs +4 -0
- package/dist/plugins/privacy.d.mts +22 -0
- package/dist/plugins/privacy.d.mts.map +1 -0
- package/dist/plugins/privacy.mjs +4 -0
- package/dist/plugins/workflows.d.mts +80 -0
- package/dist/plugins/workflows.d.mts.map +1 -0
- package/dist/plugins/workflows.mjs +4 -0
- package/dist/postgres-url-DTDhBjXX.mjs +11 -0
- package/dist/postgres-url-DTDhBjXX.mjs.map +1 -0
- package/dist/privacy-HQnhqf2H.mjs +91 -0
- package/dist/privacy-HQnhqf2H.mjs.map +1 -0
- package/dist/privacy-UodgY0i_.mjs +44 -0
- package/dist/privacy-UodgY0i_.mjs.map +1 -0
- package/dist/renown-layers-DmbWLt46.mjs +42 -0
- package/dist/renown-layers-DmbWLt46.mjs.map +1 -0
- package/dist/schema-BJ-OFAox.mjs +359 -0
- package/dist/schema-BJ-OFAox.mjs.map +1 -0
- package/dist/schema-w1lShimw.d.mts +258 -0
- package/dist/schema-w1lShimw.d.mts.map +1 -0
- package/dist/server-BS-PFzoK.mjs +2752 -0
- package/dist/server-BS-PFzoK.mjs.map +1 -0
- package/dist/server.d.mts +94 -228
- package/dist/server.d.mts.map +1 -1
- package/dist/server.mjs +5 -4
- package/dist/types-Bk4T4D9F.d.mts +318 -0
- package/dist/types-Bk4T4D9F.d.mts.map +1 -0
- package/dist/utils-Cm0TE6dP.mjs +148 -0
- package/dist/utils-Cm0TE6dP.mjs.map +1 -0
- package/dist/utils.d.mts +29 -3
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.mjs +5 -4
- package/dist/worker-pool-gyxJnCxA.mjs +304 -0
- package/dist/worker-pool-gyxJnCxA.mjs.map +1 -0
- package/dist/workflow-runtime-CF5pc8mt.d.mts +33 -0
- package/dist/workflow-runtime-CF5pc8mt.d.mts.map +1 -0
- package/dist/workflows-mdYUh3Us.mjs +1947 -0
- package/dist/workflows-mdYUh3Us.mjs.map +1 -0
- package/package.json +86 -24
- package/scripts/install-packages.sh +0 -0
- package/test/ai-gateway.test.ts +612 -0
- package/test/attachment-reference-read-model.test.ts +28 -20
- package/test/attachments/byte-grants.test.ts +4 -1
- package/test/attachments/download-target.test.ts +36 -20
- package/test/attachments/index.test.ts +13 -1
- package/test/attachments/reserve-metadata-parity.test.ts +96 -0
- package/test/attachments/routes-integration.test.ts +1 -0
- package/test/attachments/routes.test.ts +132 -12
- package/test/attachments/service-config.test.ts +28 -16
- package/test/boot-auth-config.test.ts +146 -0
- package/test/boot-create-signature-policy.test.ts +15 -13
- package/test/boot-desktop-auth.test.ts +278 -0
- package/test/boot-env-isolation.test.ts +26 -0
- package/test/boot-helpers.ts +19 -0
- package/test/boot-inspection-enabled.test.ts +140 -0
- package/test/boot-mcp-auth.test.ts +449 -0
- package/test/boot-mcp-enabled.test.ts +27 -27
- package/test/boot-port-zero.test.ts +101 -0
- package/test/boot-preconditions.test.ts +213 -0
- package/test/boot-privacy.test.ts +232 -0
- package/test/boot-ready-drives.test.ts +141 -0
- package/test/boot-undo-v3-flag.test.ts +120 -0
- package/test/boot-unsupported-stored-documents.test.ts +23 -19
- package/test/boot-without-renown.test.ts +11 -9
- package/test/boot-without-require-signatures.test.ts +12 -10
- package/test/boot-worker-trust-policy.test.ts +11 -10
- package/test/boot-workflow-singleton-conflict.test.ts +109 -0
- package/test/boot-workflow-singleton-retry.test.ts +122 -0
- package/test/config-from-env.test.ts +968 -0
- package/test/config-merge.test.ts +351 -0
- package/test/config-schema.test.ts +183 -0
- package/test/default-composition.test.ts +290 -0
- package/test/default-drive-protocol-versions.test.ts +79 -0
- package/test/default-drive-slug.test.ts +265 -0
- package/test/delegated-publish.test.ts +435 -0
- package/test/durable-node-fs-pg16.test.ts +80 -0
- package/test/fatal-shutdown.test.ts +104 -1
- package/test/fixtures/mixed-subgraphs/subgraphs/greetings/index.ts +16 -0
- package/test/fixtures/mixed-subgraphs/subgraphs/index.ts +3 -0
- package/test/fixtures/mixed-subgraphs/subgraphs/tally/index.ts +73 -0
- package/test/goldens/packages.graphql +797 -0
- package/test/goldens/privacy.graphql +853 -0
- package/test/goldens/reactor-drive-nodes.graphql +827 -0
- package/test/goldens/resolvers.json +327 -0
- package/test/goldens/supergraph.graphql +5918 -0
- package/test/goldens/workflow-runtime.graphql +1548 -0
- package/test/inspection-throttle.test.ts +23 -0
- package/test/keyframe-reclaim-store.test.ts +156 -0
- package/test/observability-signals.test.ts +131 -0
- package/test/permissions-backfill.test.ts +486 -0
- package/test/pglite-dialect.test.ts +237 -2
- package/test/pglite-preflight.test.ts +313 -0
- package/test/pglite-storage-dirs.test.ts +113 -0
- package/test/pglite-store.test.ts +441 -0
- package/test/pglite-version.test.ts +9 -1
- package/test/plugin-config-schemas.test.ts +83 -0
- package/test/plugin-presence.test.ts +262 -0
- package/test/port-probe.test.ts +45 -0
- package/test/processor-timing-log.test.ts +109 -0
- package/test/reactor-feature-flags.test.ts +20 -0
- package/test/redact-webhook-path.test.ts +9 -0
- package/test/renown-storage-path.test.ts +40 -0
- package/test/renown-trust-policy.test.ts +7 -9
- package/test/served-schemas-mixed-package.test.ts +251 -0
- package/test/served-schemas.test.ts +134 -0
- package/test/shutdown.test.ts +278 -0
- package/test/snapshot-writer.ts +94 -0
- package/test/store-lock.test.ts +65 -0
- package/test/two-switchboards.test.ts +146 -0
- package/test/worker-pool.test.ts +27 -1
- package/test/workflow/oauth-apps-config.test.ts +66 -0
- package/test/workflow/oauth.test.ts +82 -10
- package/test/workflow/resolvers.test.ts +230 -38
- package/test/workflow/runtime-host.test.ts +19 -0
- package/test/workflow/waitpoint-routes.test.ts +306 -0
- package/test/workflow/waitpoint-runtime.test.ts +204 -0
- package/test/workflow/webhook-trigger-test.test.ts +8 -0
- package/test/workflow-reactor-access.test.ts +384 -0
- package/test/workflow-reactor-enforcement.test.ts +808 -0
- package/test/workflow-read-gate.test.ts +128 -60
- package/test/workflow-runtime.test.ts +1005 -237
- package/test/workflows-plugin-config.test.ts +77 -0
- package/tsconfig.json +5 -2
- package/tsdown.config.ts +12 -0
- package/vitest.config.ts +66 -1
- package/.tsbuild/test/mcp-flag.test.d.ts +0 -2
- package/.tsbuild/test/mcp-flag.test.d.ts.map +0 -1
- package/dist/server-sQoWp21G.mjs +0 -2939
- package/dist/server-sQoWp21G.mjs.map +0 -1
- package/dist/utils-uaBlzyjS.mjs +0 -86
- package/dist/utils-uaBlzyjS.mjs.map +0 -1
- package/test/mcp-flag.test.ts +0 -56
package/Auth.md
CHANGED
|
@@ -315,6 +315,64 @@ over exempting one that also serves something else. Note what this switch does
|
|
|
315
315
|
adapter (`/health`, `/ready`, `/explorer`, `/d/:drive`) and package HTTP routes,
|
|
316
316
|
which declare their own `auth` per route.
|
|
317
317
|
|
|
318
|
+
##### Admitting only licence holders (`ACCESS=licensed`)
|
|
319
|
+
|
|
320
|
+
A switchboard that Vetra runs as a shared instance of an app admits only its
|
|
321
|
+
`ADMINS` and the callers holding a live licence of the instance's plan. Vetra
|
|
322
|
+
answers the licence question; the switchboard asks it.
|
|
323
|
+
|
|
324
|
+
| Variable | Meaning |
|
|
325
|
+
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
326
|
+
| `ACCESS` | `open` (the default): nothing below applies. `licensed`: admit only `ADMINS` and licence holders. Any other value (including `members`) refuses to boot. Case-insensitive. |
|
|
327
|
+
| `VETRA_GATE_URL` | Vetra's gate, `…/api/@powerhousedao/vetra-cloud-package/apps/gate/check`. Must be `https` (`http` only on `localhost`/`127.0.0.1`). |
|
|
328
|
+
| `VETRA_GATE_TOKEN` | The instance's gate token (`vgt_…`), sent as `Authorization: Bearer`. A secret: it is never logged. |
|
|
329
|
+
| `VETRA_APP_ID` | Sent as `x-vetra-app-id`; informational. |
|
|
330
|
+
| `ACCESS_GATE_GRACE_MS` | How long Vetra's last "yes" for a caller still admits them while Vetra is unreachable. Default `86400000` (24 h). |
|
|
331
|
+
|
|
332
|
+
`ACCESS=licensed` without `VETRA_GATE_URL` and `VETRA_GATE_TOKEN`, or together
|
|
333
|
+
with `SKIP_CREDENTIAL_VERIFICATION`, refuses to boot: the host never runs
|
|
334
|
+
admitting everybody or nobody by accident.
|
|
335
|
+
|
|
336
|
+
What `licensed` implies:
|
|
337
|
+
|
|
338
|
+
- Identity resolution and the require-authenticated-caller floor are on:
|
|
339
|
+
anonymous callers get a `401`, drive discovery (`/d/:drive`) included.
|
|
340
|
+
`/health`, `/ready` and package routes declared `auth: "public"` stay open.
|
|
341
|
+
- A verified caller in `ADMINS` is admitted without asking Vetra. Anyone else
|
|
342
|
+
is admitted only when Vetra allows them; otherwise HTTP answers `403
|
|
343
|
+
{"error": "No licence for this app"}` and a WebSocket connection is refused.
|
|
344
|
+
Open WebSockets are re-checked every `WS_CREDENTIAL_RECHECK_INTERVAL_MS` and
|
|
345
|
+
closed once the licence lapsed.
|
|
346
|
+
- The document policy is `OPEN` among admitted callers (`DOCUMENT_PERMISSIONS`
|
|
347
|
+
when enabled), never `ADMIN_ONLY`, which would refuse a licensee every
|
|
348
|
+
document. `auth_enabled` still reports `true`.
|
|
349
|
+
|
|
350
|
+
The contract with Vetra:
|
|
351
|
+
|
|
352
|
+
```
|
|
353
|
+
POST <VETRA_GATE_URL>
|
|
354
|
+
Authorization: Bearer <VETRA_GATE_TOKEN>
|
|
355
|
+
{ "address": "0x<40 hex, lower case>" }
|
|
356
|
+
|
|
357
|
+
200 { "allowed": true|false, "reason": "admin"|"licence"|"member"|"none", "until": ISO|null, "ttlSeconds": n }
|
|
358
|
+
400, 401 the request or the token is refused
|
|
359
|
+
429, 5xx Vetra is unavailable
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Caching and outages:
|
|
363
|
+
|
|
364
|
+
- Each answer, allowed or not, is kept per address for its `ttlSeconds`
|
|
365
|
+
(clamped to 1–300 s; 60 s when absent). Concurrent checks of one address
|
|
366
|
+
share one request. At most 10,000 addresses are kept; the oldest go first.
|
|
367
|
+
- Vetra unreachable (network error, 5 s timeout, `429`, `5xx`, any other
|
|
368
|
+
status, an unreadable body): a caller Vetra allowed within
|
|
369
|
+
`ACCESS_GATE_GRACE_MS` stays admitted; a caller never seen, or last refused,
|
|
370
|
+
is refused. A failing Vetra is asked at most once per address every 5 s.
|
|
371
|
+
- `401` (bad or revoked token) and `400` are never answered from grace: every
|
|
372
|
+
non-admin is refused and an error is logged, so a revoked token is final.
|
|
373
|
+
- The grace store is in memory: a restart while Vetra is down admits only
|
|
374
|
+
`ADMINS` until Vetra answers again.
|
|
375
|
+
|
|
318
376
|
#### Configuration File Method
|
|
319
377
|
|
|
320
378
|
```json
|
|
@@ -360,8 +418,10 @@ for verification — but `url` still applies to this switchboard's own identity
|
|
|
360
418
|
Either way the credential's EIP-712 proof is re-verified and expiry and
|
|
361
419
|
delegation binding are re-checked, so a locally stored credential is held to the
|
|
362
420
|
same standard as a remote one. Successful checks are cached per identity for
|
|
363
|
-
`CREDENTIAL_VERIFICATION_CACHE_TTL_MS
|
|
364
|
-
|
|
421
|
+
`CREDENTIAL_VERIFICATION_CACHE_TTL_MS`. The default depends on the source: `0`
|
|
422
|
+
(no cache) for `self`, where the check is an in-process read-model query, and
|
|
423
|
+
60s for `remote`, where revocation lags by up to that TTL per replica. Setting
|
|
424
|
+
the env var overrides either default.
|
|
365
425
|
|
|
366
426
|
`self` requires a loaded package that provides the `renown-read-model` subgraph
|
|
367
427
|
(`@powerhousedao/renown-package`). Startup fails if none does, rather than booting
|
|
@@ -375,6 +435,52 @@ the generic `GraphQLManager.executeSubgraphQuery` plus an injectable
|
|
|
375
435
|
sets `source: "self"` without injecting a verifier is refused at boot rather
|
|
376
436
|
than silently verified against a remote Renown.
|
|
377
437
|
|
|
438
|
+
#### Revoking a Credential From a Package
|
|
439
|
+
|
|
440
|
+
A package that revokes credentials (for example a `revokeCredential` mutation)
|
|
441
|
+
should evict the host's cached check as soon as the revocation is stored, so the
|
|
442
|
+
credential is refused on the next request instead of after the cache TTL.
|
|
443
|
+
Every subgraph receives the invalidator as `SubgraphArgs.credentials`, and
|
|
444
|
+
`BaseSubgraph` exposes it as `this.credentials`:
|
|
445
|
+
|
|
446
|
+
```ts
|
|
447
|
+
class RenownAuthSubgraph extends BaseSubgraph {
|
|
448
|
+
resolvers = {
|
|
449
|
+
Mutation: {
|
|
450
|
+
revokeCredential: async (_: unknown, { id }: { id: string }) => {
|
|
451
|
+
const vc = await this.store.revoke(id); // persist first
|
|
452
|
+
// Evicts cached checks for this identity and re-verifies its open
|
|
453
|
+
// WebSocket connections. chainId and appDid narrow the eviction;
|
|
454
|
+
// pass only the address to drop every app key of that address.
|
|
455
|
+
this.credentials.invalidateCredential(
|
|
456
|
+
vc.address,
|
|
457
|
+
vc.chainId,
|
|
458
|
+
vc.appDid, // the did:key the credential delegates to
|
|
459
|
+
);
|
|
460
|
+
return true;
|
|
461
|
+
},
|
|
462
|
+
},
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
The call is synchronous, returns the number of evicted entries and is a no-op on
|
|
468
|
+
a host without authentication. It is local to the process: other replicas keep
|
|
469
|
+
their cache until its TTL lapses, which is why `source: "self"` defaults to no
|
|
470
|
+
cache.
|
|
471
|
+
|
|
472
|
+
Open WebSocket connections are authenticated once, at connect. Their credentials
|
|
473
|
+
are re-verified every `WS_CREDENTIAL_RECHECK_INTERVAL_MS` (default `60000`; `0`
|
|
474
|
+
turns the periodic sweep off) and immediately for the identity named by an
|
|
475
|
+
`invalidateCredential` call. A connection whose credential no longer verifies is
|
|
476
|
+
closed with code `4403` and reason `credential-revoked`. A re-check that fails
|
|
477
|
+
because the verifier is unreachable keeps the connection open. SSE subscription
|
|
478
|
+
streams are not re-checked.
|
|
479
|
+
|
|
480
|
+
A package built against an older `reactor-api` sees `this.credentials` as
|
|
481
|
+
`undefined`; call it as `this.credentials?.invalidateCredential(...)` when the
|
|
482
|
+
package must support such hosts.
|
|
483
|
+
|
|
378
484
|
#### The Switchboard's Own Identity
|
|
379
485
|
|
|
380
486
|
Separately from verifying incoming credentials, a switchboard has its own
|