@astrale-os/kernel-client 0.6.0-beta.9 → 0.6.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/dist/auth/auth.d.ts +22 -10
- package/dist/auth/auth.js +5 -7
- package/dist/auth/authorization.d.ts +4 -2
- package/dist/auth/authorization.js +25 -6
- package/dist/auth/credential.d.ts +7 -4
- package/dist/auth/credential.js +6 -3
- package/dist/auth/identity.d.ts +7 -9
- package/dist/auth/identity.js +0 -1
- package/dist/auth/index.d.ts +4 -5
- package/dist/auth/index.js +2 -4
- package/dist/auth/register.d.ts +24 -0
- package/dist/auth/register.js +10 -0
- package/dist/client/admission.d.ts +4 -2
- package/dist/client/admission.js +9 -11
- package/dist/client/client.d.ts +4 -3
- package/dist/client/client.js +16 -4
- package/dist/client/credential.d.ts +5 -3
- package/dist/client/credential.js +7 -3
- package/dist/client/index.d.ts +3 -4
- package/dist/client/index.js +2 -3
- package/dist/client/request.d.ts +11 -4
- package/dist/client/request.js +50 -6
- package/dist/client/result.d.ts +7 -5
- package/dist/client/result.js +13 -5
- package/dist/client/routing-control.d.ts +11 -4
- package/dist/client/routing-control.js +18 -4
- package/dist/errors/client-error.d.ts +0 -1
- package/dist/errors/client-error.js +0 -1
- package/dist/errors/exchange-error.d.ts +19 -0
- package/dist/errors/exchange-error.js +9 -0
- package/dist/errors/index.d.ts +2 -1
- package/dist/errors/index.js +2 -1
- package/dist/errors/miss-error.d.ts +0 -1
- package/dist/errors/miss-error.js +0 -1
- package/dist/errors/protocol-error.d.ts +0 -1
- package/dist/errors/protocol-error.js +0 -1
- package/dist/errors/refusal.d.ts +12 -0
- package/dist/errors/refusal.js +40 -0
- package/dist/errors/response-error.d.ts +0 -1
- package/dist/errors/response-error.js +0 -1
- package/dist/errors/session-error.d.ts +0 -1
- package/dist/errors/session-error.js +0 -1
- package/dist/errors/stale-route-error.d.ts +4 -4
- package/dist/errors/stale-route-error.js +5 -5
- package/dist/errors/transport-error.d.ts +3 -3
- package/dist/errors/transport-error.js +0 -1
- package/dist/graph/domain/binding.d.ts +0 -1
- package/dist/graph/domain/binding.js +4 -1
- package/dist/graph/domain/domain.typecheck.d.ts +0 -1
- package/dist/graph/domain/domain.typecheck.js +21 -1
- package/dist/graph/domain/index.d.ts +0 -1
- package/dist/graph/domain/index.js +0 -1
- package/dist/graph/domain/model.d.ts +0 -1
- package/dist/graph/domain/model.js +0 -1
- package/dist/graph/domain/page.d.ts +0 -1
- package/dist/graph/domain/page.js +0 -1
- package/dist/graph/domain/project.d.ts +0 -1
- package/dist/graph/domain/project.js +10 -7
- package/dist/graph/domain/provenance.d.ts +0 -1
- package/dist/graph/domain/provenance.js +0 -1
- package/dist/graph/errors.d.ts +0 -1
- package/dist/graph/errors.js +1 -3
- package/dist/graph/expectation.d.ts +3 -0
- package/dist/graph/expectation.js +6 -0
- package/dist/graph/graph.d.ts +6 -3
- package/dist/graph/graph.js +0 -1
- package/dist/graph/index.d.ts +2 -3
- package/dist/graph/index.js +1 -2
- package/dist/graph/mutation.d.ts +2 -4
- package/dist/graph/mutation.js +12 -2
- package/dist/graph/page/index.d.ts +0 -1
- package/dist/graph/page/index.js +0 -1
- package/dist/graph/page/neighbors.d.ts +0 -1
- package/dist/graph/page/neighbors.js +2 -2
- package/dist/graph/page/page.d.ts +0 -1
- package/dist/graph/page/page.js +0 -1
- package/dist/graph/page-contract.d.ts +6 -1
- package/dist/graph/page-contract.js +0 -1
- package/dist/graph/provenance.d.ts +2 -1
- package/dist/graph/provenance.js +5 -1
- package/dist/graph/query.d.ts +3 -1
- package/dist/graph/query.js +25 -10
- package/dist/graph/read.d.ts +0 -1
- package/dist/graph/read.js +6 -5
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/pacer/batcher/batcher.d.ts +0 -1
- package/dist/pacer/batcher/batcher.js +0 -1
- package/dist/pacer/batcher/defaults.d.ts +0 -1
- package/dist/pacer/batcher/defaults.js +0 -1
- package/dist/pacer/batcher/index.d.ts +0 -1
- package/dist/pacer/batcher/index.js +0 -1
- package/dist/pacer/index.d.ts +1 -2
- package/dist/pacer/index.js +1 -2
- package/dist/pacer/limiter/defaults.d.ts +0 -1
- package/dist/pacer/limiter/defaults.js +0 -1
- package/dist/pacer/limiter/index.d.ts +0 -1
- package/dist/pacer/limiter/index.js +0 -1
- package/dist/pacer/limiter/limiter.d.ts +0 -1
- package/dist/pacer/limiter/limiter.js +0 -1
- package/dist/pacer/queue/defaults.d.ts +0 -1
- package/dist/pacer/queue/defaults.js +0 -1
- package/dist/pacer/queue/index.d.ts +0 -1
- package/dist/pacer/queue/index.js +0 -1
- package/dist/pacer/queue/queue.d.ts +0 -1
- package/dist/pacer/queue/queue.js +0 -1
- package/dist/pacer/retry/defaults.d.ts +0 -1
- package/dist/pacer/retry/defaults.js +0 -1
- package/dist/pacer/retry/index.d.ts +1 -1
- package/dist/pacer/retry/index.js +1 -1
- package/dist/pacer/retry/refusals.d.ts +7 -0
- package/dist/pacer/retry/refusals.js +10 -0
- package/dist/pacer/retry/retry.d.ts +2 -1
- package/dist/pacer/retry/retry.js +33 -2
- package/dist/pool/index.d.ts +0 -1
- package/dist/pool/index.js +0 -1
- package/dist/pool/pool.d.ts +0 -1
- package/dist/pool/pool.js +0 -1
- package/dist/pool/target.d.ts +0 -1
- package/dist/pool/target.js +0 -1
- package/dist/schema/admission.d.ts +1 -2
- package/dist/schema/admission.js +2 -3
- package/dist/schema/contracts.d.ts +97 -5
- package/dist/schema/contracts.js +0 -1
- package/dist/schema/index.d.ts +3 -3
- package/dist/schema/index.js +1 -2
- package/dist/schema/installation.d.ts +104 -0
- package/dist/schema/installation.js +144 -0
- package/dist/schema/introspection.d.ts +0 -1
- package/dist/schema/introspection.js +10 -3
- package/dist/schema/operation.d.ts +0 -1
- package/dist/schema/operation.js +1 -2
- package/dist/schema/schema.d.ts +32 -11
- package/dist/schema/schema.js +94 -19
- package/dist/session/admission.d.ts +6 -0
- package/dist/session/admission.js +52 -0
- package/dist/session/bound.d.ts +17 -14
- package/dist/session/bound.js +96 -10
- package/dist/session/content/api.d.ts +45 -0
- package/dist/session/content/api.js +28 -0
- package/dist/session/content/batch.d.ts +5 -0
- package/dist/session/content/batch.js +93 -0
- package/dist/session/content/index.d.ts +1 -0
- package/dist/session/content/index.js +1 -0
- package/dist/session/content/input.d.ts +9 -0
- package/dist/session/content/input.js +33 -0
- package/dist/session/content/parts.d.ts +36 -0
- package/dist/session/content/parts.js +154 -0
- package/dist/session/content/retry.d.ts +3 -0
- package/dist/session/content/retry.js +41 -0
- package/dist/session/content/wire.d.ts +12 -0
- package/dist/session/content/wire.js +60 -0
- package/dist/session/context/control.d.ts +0 -1
- package/dist/session/context/control.js +0 -1
- package/dist/session/context/index.d.ts +2 -3
- package/dist/session/context/index.js +2 -3
- package/dist/session/context/limits.d.ts +1 -2
- package/dist/session/context/limits.js +1 -2
- package/dist/session/context/operation.d.ts +5 -3
- package/dist/session/context/operation.js +1 -2
- package/dist/session/context/policy.d.ts +0 -2
- package/dist/session/context/policy.js +0 -17
- package/dist/session/credential/credentials.d.ts +65 -0
- package/dist/session/credential/credentials.js +296 -0
- package/dist/session/credential/index.d.ts +1 -0
- package/dist/session/credential/index.js +1 -0
- package/dist/session/credential/limits.d.ts +14 -0
- package/dist/session/credential/limits.js +14 -0
- package/dist/session/discovery/bundle.d.ts +9 -5
- package/dist/session/discovery/bundle.js +43 -26
- package/dist/session/discovery/discovery.d.ts +12 -5
- package/dist/session/discovery/discovery.js +42 -13
- package/dist/session/discovery/index.d.ts +6 -2
- package/dist/session/discovery/index.js +4 -8
- package/dist/session/discovery/release.d.ts +30 -0
- package/dist/session/discovery/release.js +81 -0
- package/dist/session/discovery/response.d.ts +3 -0
- package/dist/session/discovery/response.js +59 -0
- package/dist/session/discovery/snapshot.d.ts +4 -5
- package/dist/session/discovery/snapshot.js +2 -3
- package/dist/session/discovery/transport.d.ts +1 -4
- package/dist/session/discovery/transport.js +0 -1
- package/dist/session/exchange/domain.d.ts +27 -0
- package/dist/session/exchange/domain.js +63 -0
- package/dist/session/exchange/exchange.d.ts +48 -0
- package/dist/session/exchange/exchange.js +54 -0
- package/dist/session/exchange/index.d.ts +5 -0
- package/dist/session/exchange/index.js +5 -0
- package/dist/session/exchange/issuer.d.ts +18 -0
- package/dist/session/exchange/issuer.js +149 -0
- package/dist/session/exchange/limits.d.ts +10 -0
- package/dist/session/exchange/limits.js +10 -0
- package/dist/session/exchange/options.d.ts +37 -0
- package/dist/session/exchange/options.js +65 -0
- package/dist/session/exchange/presentation.d.ts +19 -0
- package/dist/session/exchange/presentation.js +72 -0
- package/dist/session/exchange/source.d.ts +33 -0
- package/dist/session/exchange/source.js +78 -0
- package/dist/session/execution.d.ts +88 -0
- package/dist/session/execution.js +34 -0
- package/dist/session/index.d.ts +9 -6
- package/dist/session/index.js +3 -2
- package/dist/session/options.d.ts +65 -0
- package/dist/session/options.js +132 -0
- package/dist/session/reference.d.ts +38 -19
- package/dist/session/reference.js +34 -12
- package/dist/session/routing/auth.d.ts +10 -1
- package/dist/session/routing/auth.js +8 -2
- package/dist/session/routing/cache.d.ts +21 -7
- package/dist/session/routing/cache.js +103 -73
- package/dist/session/routing/dispatch.d.ts +19 -11
- package/dist/session/routing/dispatch.js +115 -89
- package/dist/session/routing/envelope.d.ts +4 -3
- package/dist/session/routing/envelope.js +14 -10
- package/dist/session/routing/expiry.d.ts +4 -0
- package/dist/session/routing/expiry.js +32 -0
- package/dist/session/routing/index.d.ts +5 -5
- package/dist/session/routing/index.js +4 -3
- package/dist/session/routing/integrity.d.ts +7 -0
- package/dist/session/routing/integrity.js +44 -0
- package/dist/session/routing/recovery.d.ts +16 -0
- package/dist/session/routing/recovery.js +41 -0
- package/dist/session/routing/request.d.ts +13 -1
- package/dist/session/routing/request.js +28 -2
- package/dist/session/routing/result.d.ts +5 -0
- package/dist/session/routing/result.js +16 -0
- package/dist/session/routing/store.d.ts +23 -0
- package/dist/session/routing/store.js +99 -0
- package/dist/session/session.d.ts +37 -33
- package/dist/session/session.js +134 -157
- package/dist/session/session.typecheck.d.ts +0 -1
- package/dist/session/session.typecheck.js +183 -5
- package/dist/session/views/catalog.d.ts +9 -6
- package/dist/session/views/catalog.js +29 -23
- package/dist/session/views/index.d.ts +1 -2
- package/dist/session/views/index.js +1 -2
- package/dist/session/views/resolve.d.ts +6 -5
- package/dist/session/views/resolve.js +14 -7
- package/dist/store/entity-index.d.ts +1 -3
- package/dist/store/entity-index.js +0 -4
- package/dist/store/index.d.ts +0 -1
- package/dist/store/index.js +0 -1
- package/dist/store/memory.d.ts +2 -2
- package/dist/store/memory.js +60 -18
- package/dist/store/mutation.d.ts +1 -2
- package/dist/store/mutation.js +6 -4
- package/dist/store/observe.d.ts +0 -1
- package/dist/store/observe.js +0 -1
- package/dist/store/optimistic.d.ts +0 -1
- package/dist/store/optimistic.js +0 -1
- package/dist/store/query-key.d.ts +2 -2
- package/dist/store/query-key.js +7 -3
- package/dist/store/shape.d.ts +6 -3
- package/dist/store/shape.js +4 -2
- package/dist/store/store.d.ts +2 -4
- package/dist/store/store.js +6 -5
- package/dist/store/store.typecheck.d.ts +0 -1
- package/dist/store/store.typecheck.js +0 -6
- package/dist/transport/auto/decision.d.ts +3 -3
- package/dist/transport/auto/decision.js +0 -1
- package/dist/transport/auto/fallback.d.ts +2 -2
- package/dist/transport/auto/fallback.js +2 -2
- package/dist/transport/auto/index.d.ts +0 -1
- package/dist/transport/auto/index.js +0 -1
- package/dist/transport/auto/transport.d.ts +0 -2
- package/dist/transport/auto/transport.js +0 -3
- package/dist/transport/auto/warning.d.ts +0 -1
- package/dist/transport/auto/warning.js +5 -3
- package/dist/transport/deadline.d.ts +0 -1
- package/dist/transport/deadline.js +0 -1
- package/dist/transport/failure.d.ts +0 -1
- package/dist/transport/failure.js +0 -1
- package/dist/transport/http/admission.d.ts +5 -0
- package/dist/transport/http/admission.js +104 -0
- package/dist/transport/http/binary.d.ts +5 -0
- package/dist/transport/http/binary.js +70 -0
- package/dist/transport/http/byte-stream.d.ts +18 -0
- package/dist/transport/http/byte-stream.js +94 -0
- package/dist/transport/http/configuration.d.ts +24 -0
- package/dist/transport/http/configuration.js +116 -0
- package/dist/transport/http/index.d.ts +2 -2
- package/dist/transport/http/index.js +0 -1
- package/dist/transport/http/response.d.ts +8 -2
- package/dist/transport/http/response.js +11 -7
- package/dist/transport/http/retired.d.ts +8 -0
- package/dist/transport/http/retired.js +28 -0
- package/dist/transport/http/stream.d.ts +0 -1
- package/dist/transport/http/stream.js +0 -1
- package/dist/transport/http/transport.d.ts +4 -18
- package/dist/transport/http/transport.js +48 -252
- package/dist/transport/index.d.ts +1 -2
- package/dist/transport/index.js +0 -1
- package/dist/transport/transport.d.ts +20 -3
- package/dist/transport/transport.js +0 -1
- package/dist/transport/websocket/connection.d.ts +2 -2
- package/dist/transport/websocket/connection.js +5 -3
- package/dist/transport/websocket/exchange.d.ts +0 -1
- package/dist/transport/websocket/exchange.js +8 -1
- package/dist/transport/websocket/index.d.ts +0 -1
- package/dist/transport/websocket/index.js +0 -1
- package/dist/transport/websocket/transport.d.ts +0 -4
- package/dist/transport/websocket/transport.js +2 -18
- package/package.json +12 -15
- package/dist/auth/auth.d.ts.map +0 -1
- package/dist/auth/auth.js.map +0 -1
- package/dist/auth/authorization.d.ts.map +0 -1
- package/dist/auth/authorization.js.map +0 -1
- package/dist/auth/credential.d.ts.map +0 -1
- package/dist/auth/credential.js.map +0 -1
- package/dist/auth/identity.d.ts.map +0 -1
- package/dist/auth/identity.js.map +0 -1
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/provision.d.ts +0 -9
- package/dist/auth/provision.d.ts.map +0 -1
- package/dist/auth/provision.js +0 -11
- package/dist/auth/provision.js.map +0 -1
- package/dist/client/admission.d.ts.map +0 -1
- package/dist/client/admission.js.map +0 -1
- package/dist/client/client.d.ts.map +0 -1
- package/dist/client/client.js.map +0 -1
- package/dist/client/credential.d.ts.map +0 -1
- package/dist/client/credential.js.map +0 -1
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js.map +0 -1
- package/dist/client/request.d.ts.map +0 -1
- package/dist/client/request.js.map +0 -1
- package/dist/client/result.d.ts.map +0 -1
- package/dist/client/result.js.map +0 -1
- package/dist/client/routing-control.d.ts.map +0 -1
- package/dist/client/routing-control.js.map +0 -1
- package/dist/errors/client-error.d.ts.map +0 -1
- package/dist/errors/client-error.js.map +0 -1
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js.map +0 -1
- package/dist/errors/miss-error.d.ts.map +0 -1
- package/dist/errors/miss-error.js.map +0 -1
- package/dist/errors/protocol-error.d.ts.map +0 -1
- package/dist/errors/protocol-error.js.map +0 -1
- package/dist/errors/response-error.d.ts.map +0 -1
- package/dist/errors/response-error.js.map +0 -1
- package/dist/errors/session-error.d.ts.map +0 -1
- package/dist/errors/session-error.js.map +0 -1
- package/dist/errors/stale-route-error.d.ts.map +0 -1
- package/dist/errors/stale-route-error.js.map +0 -1
- package/dist/errors/transport-error.d.ts.map +0 -1
- package/dist/errors/transport-error.js.map +0 -1
- package/dist/graph/domain/binding.d.ts.map +0 -1
- package/dist/graph/domain/binding.js.map +0 -1
- package/dist/graph/domain/domain.typecheck.d.ts.map +0 -1
- package/dist/graph/domain/domain.typecheck.js.map +0 -1
- package/dist/graph/domain/index.d.ts.map +0 -1
- package/dist/graph/domain/index.js.map +0 -1
- package/dist/graph/domain/model.d.ts.map +0 -1
- package/dist/graph/domain/model.js.map +0 -1
- package/dist/graph/domain/page.d.ts.map +0 -1
- package/dist/graph/domain/page.js.map +0 -1
- package/dist/graph/domain/project.d.ts.map +0 -1
- package/dist/graph/domain/project.js.map +0 -1
- package/dist/graph/domain/provenance.d.ts.map +0 -1
- package/dist/graph/domain/provenance.js.map +0 -1
- package/dist/graph/errors.d.ts.map +0 -1
- package/dist/graph/errors.js.map +0 -1
- package/dist/graph/graph.d.ts.map +0 -1
- package/dist/graph/graph.js.map +0 -1
- package/dist/graph/index.d.ts.map +0 -1
- package/dist/graph/index.js.map +0 -1
- package/dist/graph/mutation.d.ts.map +0 -1
- package/dist/graph/mutation.js.map +0 -1
- package/dist/graph/page/index.d.ts.map +0 -1
- package/dist/graph/page/index.js.map +0 -1
- package/dist/graph/page/neighbors.d.ts.map +0 -1
- package/dist/graph/page/neighbors.js.map +0 -1
- package/dist/graph/page/page.d.ts.map +0 -1
- package/dist/graph/page/page.js.map +0 -1
- package/dist/graph/page-contract.d.ts.map +0 -1
- package/dist/graph/page-contract.js.map +0 -1
- package/dist/graph/provenance.d.ts.map +0 -1
- package/dist/graph/provenance.js.map +0 -1
- package/dist/graph/query.d.ts.map +0 -1
- package/dist/graph/query.js.map +0 -1
- package/dist/graph/read.d.ts.map +0 -1
- package/dist/graph/read.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/pacer/batcher/batcher.d.ts.map +0 -1
- package/dist/pacer/batcher/batcher.js.map +0 -1
- package/dist/pacer/batcher/defaults.d.ts.map +0 -1
- package/dist/pacer/batcher/defaults.js.map +0 -1
- package/dist/pacer/batcher/index.d.ts.map +0 -1
- package/dist/pacer/batcher/index.js.map +0 -1
- package/dist/pacer/index.d.ts.map +0 -1
- package/dist/pacer/index.js.map +0 -1
- package/dist/pacer/limiter/defaults.d.ts.map +0 -1
- package/dist/pacer/limiter/defaults.js.map +0 -1
- package/dist/pacer/limiter/index.d.ts.map +0 -1
- package/dist/pacer/limiter/index.js.map +0 -1
- package/dist/pacer/limiter/limiter.d.ts.map +0 -1
- package/dist/pacer/limiter/limiter.js.map +0 -1
- package/dist/pacer/queue/defaults.d.ts.map +0 -1
- package/dist/pacer/queue/defaults.js.map +0 -1
- package/dist/pacer/queue/index.d.ts.map +0 -1
- package/dist/pacer/queue/index.js.map +0 -1
- package/dist/pacer/queue/queue.d.ts.map +0 -1
- package/dist/pacer/queue/queue.js.map +0 -1
- package/dist/pacer/retry/defaults.d.ts.map +0 -1
- package/dist/pacer/retry/defaults.js.map +0 -1
- package/dist/pacer/retry/index.d.ts.map +0 -1
- package/dist/pacer/retry/index.js.map +0 -1
- package/dist/pacer/retry/retry.d.ts.map +0 -1
- package/dist/pacer/retry/retry.js.map +0 -1
- package/dist/pool/index.d.ts.map +0 -1
- package/dist/pool/index.js.map +0 -1
- package/dist/pool/pool.d.ts.map +0 -1
- package/dist/pool/pool.js.map +0 -1
- package/dist/pool/target.d.ts.map +0 -1
- package/dist/pool/target.js.map +0 -1
- package/dist/schema/admission.d.ts.map +0 -1
- package/dist/schema/admission.js.map +0 -1
- package/dist/schema/contracts.d.ts.map +0 -1
- package/dist/schema/contracts.js.map +0 -1
- package/dist/schema/index.d.ts.map +0 -1
- package/dist/schema/index.js.map +0 -1
- package/dist/schema/introspection.d.ts.map +0 -1
- package/dist/schema/introspection.js.map +0 -1
- package/dist/schema/operation.d.ts.map +0 -1
- package/dist/schema/operation.js.map +0 -1
- package/dist/schema/schema.d.ts.map +0 -1
- package/dist/schema/schema.js.map +0 -1
- package/dist/session/bound.d.ts.map +0 -1
- package/dist/session/bound.js.map +0 -1
- package/dist/session/context/control.d.ts.map +0 -1
- package/dist/session/context/control.js.map +0 -1
- package/dist/session/context/index.d.ts.map +0 -1
- package/dist/session/context/index.js.map +0 -1
- package/dist/session/context/limits.d.ts.map +0 -1
- package/dist/session/context/limits.js.map +0 -1
- package/dist/session/context/operation.d.ts.map +0 -1
- package/dist/session/context/operation.js.map +0 -1
- package/dist/session/context/policy.d.ts.map +0 -1
- package/dist/session/context/policy.js.map +0 -1
- package/dist/session/discovery/bundle.d.ts.map +0 -1
- package/dist/session/discovery/bundle.js.map +0 -1
- package/dist/session/discovery/discovery.d.ts.map +0 -1
- package/dist/session/discovery/discovery.js.map +0 -1
- package/dist/session/discovery/index.d.ts.map +0 -1
- package/dist/session/discovery/index.js.map +0 -1
- package/dist/session/discovery/publication.d.ts +0 -24
- package/dist/session/discovery/publication.d.ts.map +0 -1
- package/dist/session/discovery/publication.js +0 -124
- package/dist/session/discovery/publication.js.map +0 -1
- package/dist/session/discovery/snapshot.d.ts.map +0 -1
- package/dist/session/discovery/snapshot.js.map +0 -1
- package/dist/session/discovery/transport.d.ts.map +0 -1
- package/dist/session/discovery/transport.js.map +0 -1
- package/dist/session/index.d.ts.map +0 -1
- package/dist/session/index.js.map +0 -1
- package/dist/session/reference.d.ts.map +0 -1
- package/dist/session/reference.js.map +0 -1
- package/dist/session/routing/auth.d.ts.map +0 -1
- package/dist/session/routing/auth.js.map +0 -1
- package/dist/session/routing/cache.d.ts.map +0 -1
- package/dist/session/routing/cache.js.map +0 -1
- package/dist/session/routing/dispatch.d.ts.map +0 -1
- package/dist/session/routing/dispatch.js.map +0 -1
- package/dist/session/routing/envelope.d.ts.map +0 -1
- package/dist/session/routing/envelope.js.map +0 -1
- package/dist/session/routing/expectation.d.ts +0 -7
- package/dist/session/routing/expectation.d.ts.map +0 -1
- package/dist/session/routing/expectation.js +0 -2
- package/dist/session/routing/expectation.js.map +0 -1
- package/dist/session/routing/index.d.ts.map +0 -1
- package/dist/session/routing/index.js.map +0 -1
- package/dist/session/routing/request.d.ts.map +0 -1
- package/dist/session/routing/request.js.map +0 -1
- package/dist/session/session.d.ts.map +0 -1
- package/dist/session/session.js.map +0 -1
- package/dist/session/session.typecheck.d.ts.map +0 -1
- package/dist/session/session.typecheck.js.map +0 -1
- package/dist/session/views/catalog.d.ts.map +0 -1
- package/dist/session/views/catalog.js.map +0 -1
- package/dist/session/views/index.d.ts.map +0 -1
- package/dist/session/views/index.js.map +0 -1
- package/dist/session/views/resolve.d.ts.map +0 -1
- package/dist/session/views/resolve.js.map +0 -1
- package/dist/store/entity-index.d.ts.map +0 -1
- package/dist/store/entity-index.js.map +0 -1
- package/dist/store/index.d.ts.map +0 -1
- package/dist/store/index.js.map +0 -1
- package/dist/store/memory.d.ts.map +0 -1
- package/dist/store/memory.js.map +0 -1
- package/dist/store/mutation.d.ts.map +0 -1
- package/dist/store/mutation.js.map +0 -1
- package/dist/store/observe.d.ts.map +0 -1
- package/dist/store/observe.js.map +0 -1
- package/dist/store/optimistic.d.ts.map +0 -1
- package/dist/store/optimistic.js.map +0 -1
- package/dist/store/query-key.d.ts.map +0 -1
- package/dist/store/query-key.js.map +0 -1
- package/dist/store/shape.d.ts.map +0 -1
- package/dist/store/shape.js.map +0 -1
- package/dist/store/store.d.ts.map +0 -1
- package/dist/store/store.js.map +0 -1
- package/dist/store/store.typecheck.d.ts.map +0 -1
- package/dist/store/store.typecheck.js.map +0 -1
- package/dist/transport/auto/decision.d.ts.map +0 -1
- package/dist/transport/auto/decision.js.map +0 -1
- package/dist/transport/auto/fallback.d.ts.map +0 -1
- package/dist/transport/auto/fallback.js.map +0 -1
- package/dist/transport/auto/index.d.ts.map +0 -1
- package/dist/transport/auto/index.js.map +0 -1
- package/dist/transport/auto/transport.d.ts.map +0 -1
- package/dist/transport/auto/transport.js.map +0 -1
- package/dist/transport/auto/warning.d.ts.map +0 -1
- package/dist/transport/auto/warning.js.map +0 -1
- package/dist/transport/deadline.d.ts.map +0 -1
- package/dist/transport/deadline.js.map +0 -1
- package/dist/transport/failure.d.ts.map +0 -1
- package/dist/transport/failure.js.map +0 -1
- package/dist/transport/http/index.d.ts.map +0 -1
- package/dist/transport/http/index.js.map +0 -1
- package/dist/transport/http/response.d.ts.map +0 -1
- package/dist/transport/http/response.js.map +0 -1
- package/dist/transport/http/stream.d.ts.map +0 -1
- package/dist/transport/http/stream.js.map +0 -1
- package/dist/transport/http/transport.d.ts.map +0 -1
- package/dist/transport/http/transport.js.map +0 -1
- package/dist/transport/index.d.ts.map +0 -1
- package/dist/transport/index.js.map +0 -1
- package/dist/transport/transport.d.ts.map +0 -1
- package/dist/transport/transport.js.map +0 -1
- package/dist/transport/websocket/connection.d.ts.map +0 -1
- package/dist/transport/websocket/connection.js.map +0 -1
- package/dist/transport/websocket/exchange.d.ts.map +0 -1
- package/dist/transport/websocket/exchange.js.map +0 -1
- package/dist/transport/websocket/index.d.ts.map +0 -1
- package/dist/transport/websocket/index.js.map +0 -1
- package/dist/transport/websocket/transport.d.ts.map +0 -1
- package/dist/transport/websocket/transport.js.map +0 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as codecs from '@astrale-os/kernel-protocol/codecs';
|
|
2
|
+
import * as releaseCodec from '@astrale-os/kernel-protocol/release';
|
|
3
|
+
import { ClientError } from '../../errors/index.js';
|
|
4
|
+
import { allowEndpoint } from '../context/index.js';
|
|
5
|
+
import { boundedResponse, requireExactResponse } from './response.js';
|
|
6
|
+
import { runAcquisition } from './transport.js';
|
|
7
|
+
/**
|
|
8
|
+
* Conditionally revalidate by release digest. Only an exact 404 means absence;
|
|
9
|
+
* all other unsuccessful responses and Fetch failures remain errors.
|
|
10
|
+
*/
|
|
11
|
+
export class ReleaseDiscovery {
|
|
12
|
+
options;
|
|
13
|
+
release;
|
|
14
|
+
revision = 0;
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.options = options;
|
|
17
|
+
}
|
|
18
|
+
/** The release admitted since construction, the last `invalidate()` or the last 404, if any. */
|
|
19
|
+
current() {
|
|
20
|
+
return this.release;
|
|
21
|
+
}
|
|
22
|
+
/** Revalidate the intrinsic release; an absent release is a discovery error. */
|
|
23
|
+
async revalidate(operation) {
|
|
24
|
+
const revision = this.revision;
|
|
25
|
+
const previous = this.release;
|
|
26
|
+
const discovered = await this.fetch(operation, previous);
|
|
27
|
+
if (revision !== this.revision)
|
|
28
|
+
return this.revalidate(operation);
|
|
29
|
+
const retained = previous?.digest === discovered.digest ? previous : discovered;
|
|
30
|
+
this.release = retained;
|
|
31
|
+
return retained;
|
|
32
|
+
}
|
|
33
|
+
invalidate() {
|
|
34
|
+
this.revision += 1;
|
|
35
|
+
this.release = undefined;
|
|
36
|
+
}
|
|
37
|
+
async fetch(operation, previous) {
|
|
38
|
+
const url = releaseCodec.url(this.options.kernel);
|
|
39
|
+
allowEndpoint(url, this.options.policy);
|
|
40
|
+
const response = await runAcquisition(operation, 'release', 'unknown', 'Kernel release could not be retrieved.', (signal) => this.options.fetch(url, {
|
|
41
|
+
headers: {
|
|
42
|
+
accept: releaseCodec.MEDIA_TYPE,
|
|
43
|
+
...(previous === undefined ? {} : { 'if-none-match': `"${previous.digest}"` }),
|
|
44
|
+
},
|
|
45
|
+
redirect: 'manual',
|
|
46
|
+
signal,
|
|
47
|
+
}));
|
|
48
|
+
requireExactResponse(response, url, 'Release discovery');
|
|
49
|
+
if (response.status === 404) {
|
|
50
|
+
// Cleanup must not hold discovery open on an injected body cancellation.
|
|
51
|
+
void response.body?.cancel().catch(() => undefined);
|
|
52
|
+
throw new ClientError('Release discovery returned HTTP 404.');
|
|
53
|
+
}
|
|
54
|
+
if (response.status === 304) {
|
|
55
|
+
if (previous === undefined) {
|
|
56
|
+
throw new ClientError('Release discovery returned an unexpected not-modified response.');
|
|
57
|
+
}
|
|
58
|
+
const etag = response.headers.get('etag');
|
|
59
|
+
if (etag !== null && etag !== `"${previous.digest}"`) {
|
|
60
|
+
throw new ClientError('Release not-modified ETag differs from the retained release digest.');
|
|
61
|
+
}
|
|
62
|
+
return previous;
|
|
63
|
+
}
|
|
64
|
+
if (!response.ok) {
|
|
65
|
+
throw new ClientError(`Release discovery returned HTTP ${response.status}.`);
|
|
66
|
+
}
|
|
67
|
+
if (response.headers.get('content-type') !== releaseCodec.MEDIA_TYPE) {
|
|
68
|
+
throw new ClientError('Release response media type differs from the DomainRelease v4 media type.');
|
|
69
|
+
}
|
|
70
|
+
const body = await runAcquisition(operation, 'release', 'receive', 'Kernel release response could not be read.', (signal) => boundedResponse(response, this.options.maximumBytes, signal));
|
|
71
|
+
const admitted = releaseCodec.accept(codecs.json.decode(body));
|
|
72
|
+
if (admitted.identity.issuer !== this.options.kernel) {
|
|
73
|
+
throw new ClientError('Release issuer differs from the requested Kernel issuer.');
|
|
74
|
+
}
|
|
75
|
+
const etag = response.headers.get('etag');
|
|
76
|
+
if (etag !== null && etag !== `"${admitted.digest}"`) {
|
|
77
|
+
throw new ClientError('Release response ETag differs from its release digest.');
|
|
78
|
+
}
|
|
79
|
+
return admitted;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Read external bytes within one Session operation's byte and lifetime bounds. */
|
|
2
|
+
export declare function boundedResponse(response: Response, maximum: number, signal: AbortSignal): Promise<Uint8Array>;
|
|
3
|
+
export declare function requireExactResponse(response: Response, expected: string, label: string): void;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ClientError } from '../../errors/index.js';
|
|
2
|
+
/** Read external bytes within one Session operation's byte and lifetime bounds. */
|
|
3
|
+
export async function boundedResponse(response, maximum, signal) {
|
|
4
|
+
const declared = response.headers.get('content-length');
|
|
5
|
+
if (declared !== null) {
|
|
6
|
+
const length = Number(declared);
|
|
7
|
+
if (!Number.isSafeInteger(length) || length < 0) {
|
|
8
|
+
throw new ClientError('Response Content-Length is invalid.');
|
|
9
|
+
}
|
|
10
|
+
if (length > maximum)
|
|
11
|
+
throw new ClientError('Response exceeds its byte limit.');
|
|
12
|
+
}
|
|
13
|
+
if (response.body === null)
|
|
14
|
+
return new Uint8Array();
|
|
15
|
+
const reader = response.body.getReader();
|
|
16
|
+
const chunks = [];
|
|
17
|
+
let total = 0;
|
|
18
|
+
const abort = () => void reader.cancel(signal.reason).catch(() => undefined);
|
|
19
|
+
if (signal.aborted)
|
|
20
|
+
abort();
|
|
21
|
+
else
|
|
22
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
23
|
+
try {
|
|
24
|
+
while (true) {
|
|
25
|
+
if (signal.aborted)
|
|
26
|
+
throw signal.reason;
|
|
27
|
+
const next = await reader.read();
|
|
28
|
+
if (next.done)
|
|
29
|
+
break;
|
|
30
|
+
total += next.value.byteLength;
|
|
31
|
+
if (total > maximum) {
|
|
32
|
+
await reader.cancel('response exceeds byte limit').catch(() => undefined);
|
|
33
|
+
throw new ClientError('Response exceeds its byte limit.');
|
|
34
|
+
}
|
|
35
|
+
chunks.push(next.value);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
signal.removeEventListener('abort', abort);
|
|
40
|
+
reader.releaseLock();
|
|
41
|
+
}
|
|
42
|
+
return join(chunks, total);
|
|
43
|
+
}
|
|
44
|
+
export function requireExactResponse(response, expected, label) {
|
|
45
|
+
if (response.redirected || response.url !== expected) {
|
|
46
|
+
throw new ClientError(`${label} did not return the exact requested URL.`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function join(parts, length) {
|
|
50
|
+
if (parts.length === 1)
|
|
51
|
+
return new Uint8Array(parts[0]);
|
|
52
|
+
const output = new Uint8Array(length);
|
|
53
|
+
let offset = 0;
|
|
54
|
+
for (const part of parts) {
|
|
55
|
+
output.set(part, offset);
|
|
56
|
+
offset += part.byteLength;
|
|
57
|
+
}
|
|
58
|
+
return output;
|
|
59
|
+
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
2
2
|
import type { bundle } from '@astrale-os/kernel-dsl/v1';
|
|
3
|
-
import type { publication } from '@astrale-os/kernel-protocol';
|
|
4
3
|
import type { ViewCatalog } from '../views/index.js';
|
|
5
|
-
|
|
4
|
+
import type { IntrinsicRelease } from './release.js';
|
|
5
|
+
/** Coherent public observation acquired through one Client Session at one intrinsic release. */
|
|
6
6
|
export interface SessionSnapshot {
|
|
7
7
|
readonly kernel: IssuerId;
|
|
8
|
-
readonly
|
|
8
|
+
readonly release: IntrinsicRelease;
|
|
9
9
|
readonly bundle: bundle.Bundle;
|
|
10
10
|
readonly views: ViewCatalog;
|
|
11
11
|
}
|
|
12
|
-
export declare function createSessionSnapshot(kernel: IssuerId,
|
|
13
|
-
//# sourceMappingURL=snapshot.d.ts.map
|
|
12
|
+
export declare function createSessionSnapshot(kernel: IssuerId, release: IntrinsicRelease, artifact: bundle.Bundle, views: ViewCatalog): SessionSnapshot;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export function createSessionSnapshot(kernel,
|
|
2
|
-
return Object.freeze({ kernel,
|
|
1
|
+
export function createSessionSnapshot(kernel, release, artifact, views) {
|
|
2
|
+
return Object.freeze({ kernel, release, bundle: artifact, views });
|
|
3
3
|
}
|
|
4
|
-
//# sourceMappingURL=snapshot.js.map
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type { TransportPhase } from '../../errors/index.js';
|
|
1
|
+
import type { AcquisitionResource, TransportPhase } from '../../errors/index.js';
|
|
2
2
|
import type { SessionOperation } from '../context/index.js';
|
|
3
|
-
type AcquisitionResource = 'publication' | 'bundle';
|
|
4
3
|
/** Normalize only unknown failures from one injected acquisition capability. */
|
|
5
4
|
export declare function runAcquisition<Result>(operation: SessionOperation, resource: AcquisitionResource, phase: Extract<TransportPhase, 'receive' | 'unknown'>, message: string, task: (signal: AbortSignal) => Result | PromiseLike<Result>): Promise<Result>;
|
|
6
|
-
export {};
|
|
7
|
-
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
2
|
+
import type { invocation } from '@astrale-os/kernel-protocol';
|
|
3
|
+
import { Path } from '@astrale-os/kernel-core/path';
|
|
4
|
+
import { Key } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
5
|
+
import type { SessionOperation } from '../context/index.js';
|
|
6
|
+
import type { EffectiveAuth } from '../routing/index.js';
|
|
7
|
+
import type { ExchangeDependencies } from './exchange.js';
|
|
8
|
+
/** Installed issuers of the Domains one Session reaches. */
|
|
9
|
+
export interface Installations {
|
|
10
|
+
issuerOf(origin: Key.Origin, source: EffectiveAuth, operation: SessionOperation): Promise<IssuerId | undefined>;
|
|
11
|
+
clear(): void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The origin of the Domain whose declaration a Call executes, or undefined when the target names no
|
|
15
|
+
* Domain. An instance Method belongs to its qualified Class, never to its receiver's Domain.
|
|
16
|
+
*/
|
|
17
|
+
export declare function declaringOrigin(target: invocation.Call['target']): Key.Origin | undefined;
|
|
18
|
+
export declare function callableOrigin(path: Path): Key.Origin | undefined;
|
|
19
|
+
export declare function isKernelOrigin(origin: Key.Origin): boolean;
|
|
20
|
+
/** The installed remote issuer of one Domain, read as the source caller; undefined when local. */
|
|
21
|
+
export declare function installedIssuer(dependencies: Pick<ExchangeDependencies, 'kernel' | 'source' | 'limits'>, origin: Key.Origin, source: EffectiveAuth, operation: SessionOperation): Promise<IssuerId | undefined>;
|
|
22
|
+
/**
|
|
23
|
+
* Remember each origin's installed issuer for the Session route age. The issuer is installation
|
|
24
|
+
* state, not authority, so one inspection serves every source credential; concurrent readers share
|
|
25
|
+
* it while each keeps its own cancellation and deadline.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createInstallations(dependencies: ExchangeDependencies): Installations;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { targetPath } from '@astrale-os/kernel-core/callable';
|
|
2
|
+
import { Path } from '@astrale-os/kernel-core/path';
|
|
3
|
+
import { identity } from '@astrale-os/kernel-core/schema/kernel/syscalls/references';
|
|
4
|
+
import { Key } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
5
|
+
import { createSchema } from '../../schema/index.js';
|
|
6
|
+
import { runSessionOperation } from '../context/index.js';
|
|
7
|
+
import { sourceCaller } from './source.js';
|
|
8
|
+
const KERNEL_ORIGIN = identity.whoami.owner.origin;
|
|
9
|
+
/**
|
|
10
|
+
* The origin of the Domain whose declaration a Call executes, or undefined when the target names no
|
|
11
|
+
* Domain. An instance Method belongs to its qualified Class, never to its receiver's Domain.
|
|
12
|
+
*/
|
|
13
|
+
export function declaringOrigin(target) {
|
|
14
|
+
return callableOrigin(Path.parse(targetPath(target)));
|
|
15
|
+
}
|
|
16
|
+
export function callableOrigin(path) {
|
|
17
|
+
const last = path.ast.steps.at(-1);
|
|
18
|
+
if (last?.kind === 'method' && last.dispatch === 'instance')
|
|
19
|
+
return Key.origin(last.class);
|
|
20
|
+
return path.ast.anchor.kind === 'domain' ? path.ast.anchor.origin : undefined;
|
|
21
|
+
}
|
|
22
|
+
export function isKernelOrigin(origin) {
|
|
23
|
+
return origin === KERNEL_ORIGIN;
|
|
24
|
+
}
|
|
25
|
+
/** The installed remote issuer of one Domain, read as the source caller; undefined when local. */
|
|
26
|
+
export async function installedIssuer(dependencies, origin, source, operation) {
|
|
27
|
+
const caller = sourceCaller(dependencies, source, operation);
|
|
28
|
+
const domain = await createSchema(caller.dispatch, dependencies.limits).inspect(origin);
|
|
29
|
+
const remote = domain.release;
|
|
30
|
+
return remote === null || remote.identity.issuer === dependencies.kernel
|
|
31
|
+
? undefined
|
|
32
|
+
: remote.identity.issuer;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Remember each origin's installed issuer for the Session route age. The issuer is installation
|
|
36
|
+
* state, not authority, so one inspection serves every source credential; concurrent readers share
|
|
37
|
+
* it while each keeps its own cancellation and deadline.
|
|
38
|
+
*/
|
|
39
|
+
export function createInstallations(dependencies) {
|
|
40
|
+
/** An inspection in flight never expires; a settled one lives for the route age. */
|
|
41
|
+
const entries = new Map();
|
|
42
|
+
return Object.freeze({
|
|
43
|
+
issuerOf(origin, source, operation) {
|
|
44
|
+
const held = entries.get(origin);
|
|
45
|
+
const { issuer } = held === undefined || held.expiresAt <= Date.now() ? inspect(origin, source) : held;
|
|
46
|
+
return runSessionOperation(operation, () => issuer);
|
|
47
|
+
},
|
|
48
|
+
clear: () => entries.clear(),
|
|
49
|
+
});
|
|
50
|
+
function inspect(origin, source) {
|
|
51
|
+
const issuer = installedIssuer(dependencies, origin, source, dependencies.operation());
|
|
52
|
+
const entry = { issuer, expiresAt: Infinity };
|
|
53
|
+
entries.set(origin, entry);
|
|
54
|
+
// Both reactions are attached, so a rejection that reaches no waiter is never unhandled.
|
|
55
|
+
issuer.then(() => {
|
|
56
|
+
entry.expiresAt = Date.now() + dependencies.policy.maximumRouteAgeMs;
|
|
57
|
+
}, () => {
|
|
58
|
+
if (entries.get(origin) === entry)
|
|
59
|
+
entries.delete(origin);
|
|
60
|
+
});
|
|
61
|
+
return entry;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { MintedCredential } from '@astrale-os/kernel-core/auth';
|
|
2
|
+
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
3
|
+
import type { Client } from '../../client/index.js';
|
|
4
|
+
import type { SchemaOptions } from '../../schema/schema.js';
|
|
5
|
+
import type { Fetch } from '../../transport/http/index.js';
|
|
6
|
+
import type { SessionOperation, SessionPolicy } from '../context/index.js';
|
|
7
|
+
import type { SessionCredential } from '../credential/index.js';
|
|
8
|
+
import type { EffectiveAuth, SessionAuth } from '../routing/index.js';
|
|
9
|
+
import type { ExchangeRequest } from './options.js';
|
|
10
|
+
/** Everything an exchange reaches: the Session's source Kernel and authority, and the Domain legs. */
|
|
11
|
+
export interface ExchangeDependencies {
|
|
12
|
+
readonly kernel: IssuerId;
|
|
13
|
+
/** Unauthenticated Client for the source Kernel invocation endpoint. */
|
|
14
|
+
readonly source: () => Client;
|
|
15
|
+
/** The Session's source authority, when the Session has one. */
|
|
16
|
+
readonly auth?: SessionAuth;
|
|
17
|
+
readonly fetch: Fetch;
|
|
18
|
+
readonly policy: Readonly<SessionPolicy>;
|
|
19
|
+
readonly limits: SchemaOptions;
|
|
20
|
+
readonly maximumResponseBytes: number;
|
|
21
|
+
/** Open one operation for work shared by several Calls; it fails once the Session closes. */
|
|
22
|
+
readonly operation: (signal?: AbortSignal) => SessionOperation;
|
|
23
|
+
}
|
|
24
|
+
/** One Domain-issued Kernel credential and the delegation the Domain exchanged for it. */
|
|
25
|
+
export interface DomainCredential extends SessionCredential {
|
|
26
|
+
readonly delegation: MintedCredential;
|
|
27
|
+
}
|
|
28
|
+
export interface DomainExchangeRequest {
|
|
29
|
+
readonly issuer: IssuerId;
|
|
30
|
+
/** Requested delegation lifetime; the source credential's remaining lifetime bounds it. */
|
|
31
|
+
readonly ttlSeconds: number;
|
|
32
|
+
/**
|
|
33
|
+
* Lifetime the returned credential must exceed. A source that bounds the delegation within it is
|
|
34
|
+
* exhausted rather than exchanged.
|
|
35
|
+
*/
|
|
36
|
+
readonly coverageMs?: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Delegate the source caller to one Domain issuer and redeem that delegation at the issuer's
|
|
40
|
+
* advertised endpoint for the Domain's credential to the source Kernel.
|
|
41
|
+
*/
|
|
42
|
+
export declare function exchangeDomainCredential(dependencies: ExchangeDependencies, source: EffectiveAuth, request: DomainExchangeRequest, operation: SessionOperation): Promise<DomainCredential>;
|
|
43
|
+
/**
|
|
44
|
+
* One Domain credential for a named Domain issuer, as `session.exchange` returns it. When the
|
|
45
|
+
* request asks for more than the Session delegation, the credential covers that delegation, and the
|
|
46
|
+
* source is renewed once if the current one can no longer feed it.
|
|
47
|
+
*/
|
|
48
|
+
export declare function acquireDomainCredential(dependencies: ExchangeDependencies, request: ExchangeRequest, operation: SessionOperation): Promise<SessionCredential>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { credentialApi, IDENTITY_DELEGATE_PATH } from '../../auth/credential.js';
|
|
2
|
+
import { identityApi } from '../../auth/identity.js';
|
|
3
|
+
import { delegationCoverageMs } from '../credential/index.js';
|
|
4
|
+
import { resolveAuth } from '../routing/index.js';
|
|
5
|
+
import { redeem, tokenEndpoint } from './issuer.js';
|
|
6
|
+
import { delegationTtl, isAuthority, renewing, sourceCaller, sourceExhausted } from './source.js';
|
|
7
|
+
/**
|
|
8
|
+
* Delegate the source caller to one Domain issuer and redeem that delegation at the issuer's
|
|
9
|
+
* advertised endpoint for the Domain's credential to the source Kernel.
|
|
10
|
+
*/
|
|
11
|
+
export async function exchangeDomainCredential(dependencies, source, request, operation) {
|
|
12
|
+
const caller = sourceCaller(dependencies, source, operation);
|
|
13
|
+
const [endpoint, principal] = await Promise.all([
|
|
14
|
+
tokenEndpoint(dependencies, request.issuer, operation),
|
|
15
|
+
identityApi(caller.call)
|
|
16
|
+
.whoami()
|
|
17
|
+
.then(({ id }) => id),
|
|
18
|
+
]);
|
|
19
|
+
const ttlSeconds = delegationTtl(source.credential, request.ttlSeconds, request.coverageMs);
|
|
20
|
+
const delegation = await credentialApi(caller.call).delegate(principal, {
|
|
21
|
+
audience: request.issuer,
|
|
22
|
+
ttlSeconds,
|
|
23
|
+
});
|
|
24
|
+
const credential = await redeem(dependencies, request.issuer, endpoint, delegation, operation);
|
|
25
|
+
// A Domain credential never outlives its source, so only a fresher source can lengthen it.
|
|
26
|
+
const bySource = ttlSeconds < request.ttlSeconds;
|
|
27
|
+
if (bySource && credential.expiresAt - Date.now() <= (request.coverageMs ?? 0)) {
|
|
28
|
+
throw sourceExhausted();
|
|
29
|
+
}
|
|
30
|
+
return Object.freeze({ ...credential, delegation });
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* One Domain credential for a named Domain issuer, as `session.exchange` returns it. When the
|
|
34
|
+
* request asks for more than the Session delegation, the credential covers that delegation, and the
|
|
35
|
+
* source is renewed once if the current one can no longer feed it.
|
|
36
|
+
*/
|
|
37
|
+
export async function acquireDomainCredential(dependencies, request, operation) {
|
|
38
|
+
const { auth } = dependencies;
|
|
39
|
+
const call = {
|
|
40
|
+
target: IDENTITY_DELEGATE_PATH,
|
|
41
|
+
input: { audience: request.issuer, ttlSeconds: request.ttlSeconds },
|
|
42
|
+
};
|
|
43
|
+
const coverageMs = auth === undefined ? 0 : delegationCoverageMs(auth.ttlSeconds);
|
|
44
|
+
const exchange = (source) => exchangeDomainCredential(dependencies, source, {
|
|
45
|
+
issuer: request.issuer,
|
|
46
|
+
ttlSeconds: request.ttlSeconds,
|
|
47
|
+
...(request.ttlSeconds * 1_000 > coverageMs ? { coverageMs } : {}),
|
|
48
|
+
}, operation);
|
|
49
|
+
const source = await resolveAuth(auth, call, operation);
|
|
50
|
+
const exchanged = auth === undefined || !isAuthority(source)
|
|
51
|
+
? await exchange(source)
|
|
52
|
+
: await renewing(auth, call, source, operation, exchange);
|
|
53
|
+
return Object.freeze({ credential: exchanged.credential, expiresAt: exchanged.expiresAt });
|
|
54
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { callableOrigin, installedIssuer } from './domain.js';
|
|
2
|
+
export { acquireDomainCredential, exchangeDomainCredential, type DomainCredential, type DomainExchangeRequest, type ExchangeDependencies, } from './exchange.js';
|
|
3
|
+
export { admitExchangeOptions, admitExchangeRequest, type ExchangeRequest, type SessionExchangeOptions, type SessionExchangeRequest, } from './options.js';
|
|
4
|
+
export { createSessionExchange, type SessionExchange } from './presentation.js';
|
|
5
|
+
export { isAuthority } from './source.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { callableOrigin, installedIssuer } from './domain.js';
|
|
2
|
+
export { acquireDomainCredential, exchangeDomainCredential, } from './exchange.js';
|
|
3
|
+
export { admitExchangeOptions, admitExchangeRequest, } from './options.js';
|
|
4
|
+
export { createSessionExchange } from './presentation.js';
|
|
5
|
+
export { isAuthority } from './source.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MintedCredential } from '@astrale-os/kernel-core/auth';
|
|
2
|
+
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
3
|
+
import type { SessionOperation } from '../context/index.js';
|
|
4
|
+
import type { SessionCredential } from '../credential/index.js';
|
|
5
|
+
import type { ExchangeDependencies } from './exchange.js';
|
|
6
|
+
type IssuerDependencies = Pick<ExchangeDependencies, 'kernel' | 'fetch' | 'policy' | 'maximumResponseBytes'>;
|
|
7
|
+
/**
|
|
8
|
+
* The token exchange endpoint a Domain issuer advertises. Endpoint policy applies here, so a denied
|
|
9
|
+
* endpoint is never returned and no delegation is minted for it.
|
|
10
|
+
*/
|
|
11
|
+
export declare function tokenEndpoint(dependencies: IssuerDependencies, domain: IssuerId, operation: SessionOperation): Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Present a delegation at a Domain's token endpoint and admit the returned credential as provider
|
|
14
|
+
* evidence: it must be the exchange representation served with `Cache-Control: no-store`, its
|
|
15
|
+
* issuer that Domain, its audience the source Kernel, and its signed expiry the reported one.
|
|
16
|
+
*/
|
|
17
|
+
export declare function redeem(dependencies: IssuerDependencies, domain: IssuerId, endpoint: string, delegation: MintedCredential, operation: SessionOperation): Promise<SessionCredential>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { inspect } from '@astrale-os/kernel-core/auth/credential';
|
|
2
|
+
import { codecs, issuer } from '@astrale-os/kernel-protocol';
|
|
3
|
+
import { ProtocolError } from '@astrale-os/kernel-protocol/errors';
|
|
4
|
+
import { ClientError, ExchangeError, SessionError } from '../../errors/index.js';
|
|
5
|
+
import { allowEndpoint, runSessionOperation } from '../context/index.js';
|
|
6
|
+
import { boundedResponse, requireExactResponse } from '../discovery/index.js';
|
|
7
|
+
const DISCOVERY = Object.freeze({ name: 'discovery', invalid: 'discovery' });
|
|
8
|
+
const TOKEN_EXCHANGE = Object.freeze({ name: 'token exchange', invalid: 'invalid-response' });
|
|
9
|
+
/**
|
|
10
|
+
* The token exchange endpoint a Domain issuer advertises. Endpoint policy applies here, so a denied
|
|
11
|
+
* endpoint is never returned and no delegation is minted for it.
|
|
12
|
+
*/
|
|
13
|
+
export async function tokenEndpoint(dependencies, domain, operation) {
|
|
14
|
+
const configuration = await fetchAdmitted(dependencies, DISCOVERY, new URL(issuer.paths(domain).configuration, domain).href, operation, (body) => issuer.acceptConfiguration(body, domain));
|
|
15
|
+
const endpoint = configuration.token_exchange_endpoint;
|
|
16
|
+
if (endpoint === undefined) {
|
|
17
|
+
throw new ExchangeError('The installed Domain does not advertise token exchange.', {
|
|
18
|
+
failure: 'unsupported',
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
allowEndpoint(endpoint, dependencies.policy);
|
|
22
|
+
return endpoint;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Present a delegation at a Domain's token endpoint and admit the returned credential as provider
|
|
26
|
+
* evidence: it must be the exchange representation served with `Cache-Control: no-store`, its
|
|
27
|
+
* issuer that Domain, its audience the source Kernel, and its signed expiry the reported one.
|
|
28
|
+
*/
|
|
29
|
+
export async function redeem(dependencies, domain, endpoint, delegation, operation) {
|
|
30
|
+
const exchanged = await fetchAdmitted(dependencies, TOKEN_EXCHANGE, endpoint, operation, (body, headers) => {
|
|
31
|
+
requireCredentialHeaders(headers);
|
|
32
|
+
return issuer.exchange.acceptResponse(body);
|
|
33
|
+
}, delegation);
|
|
34
|
+
let claims;
|
|
35
|
+
try {
|
|
36
|
+
claims = inspect(exchanged.token);
|
|
37
|
+
}
|
|
38
|
+
catch (cause) {
|
|
39
|
+
throw invalidResponse('Domain token exchange returned an invalid credential.', cause);
|
|
40
|
+
}
|
|
41
|
+
if (claims.iss !== domain ||
|
|
42
|
+
claims.aud !== dependencies.kernel ||
|
|
43
|
+
claims.claims.exp !== exchanged.expiresAt) {
|
|
44
|
+
throw invalidResponse('Domain token exchange returned an inconsistent credential.');
|
|
45
|
+
}
|
|
46
|
+
const expiresAt = exchanged.expiresAt * 1_000;
|
|
47
|
+
if (expiresAt <= Date.now()) {
|
|
48
|
+
throw invalidResponse('Domain token exchange returned an expired credential.');
|
|
49
|
+
}
|
|
50
|
+
return Object.freeze({ credential: exchanged.token, expiresAt });
|
|
51
|
+
}
|
|
52
|
+
/** Fetch one issuer leg and admit its JSON body; every failure names the leg that caused it. */
|
|
53
|
+
async function fetchAdmitted(dependencies, leg, url, operation, admit, credential) {
|
|
54
|
+
allowEndpoint(url, dependencies.policy);
|
|
55
|
+
return runSessionOperation(operation, async (signal) => {
|
|
56
|
+
const init = {
|
|
57
|
+
method: credential === undefined ? 'GET' : 'POST',
|
|
58
|
+
headers: {
|
|
59
|
+
accept: credential === undefined ? 'application/json' : issuer.exchange.MEDIA_TYPE,
|
|
60
|
+
...(credential === undefined ? {} : { authorization: `Bearer ${credential}` }),
|
|
61
|
+
},
|
|
62
|
+
credentials: 'omit',
|
|
63
|
+
cache: 'no-store',
|
|
64
|
+
referrerPolicy: 'no-referrer',
|
|
65
|
+
redirect: 'manual',
|
|
66
|
+
signal,
|
|
67
|
+
};
|
|
68
|
+
let response;
|
|
69
|
+
try {
|
|
70
|
+
response = await dependencies.fetch(url, init);
|
|
71
|
+
}
|
|
72
|
+
catch (cause) {
|
|
73
|
+
if (signal.aborted)
|
|
74
|
+
throw cause;
|
|
75
|
+
throw new ExchangeError(`Domain ${leg.name} could not be reached.`, {
|
|
76
|
+
failure: 'unavailable',
|
|
77
|
+
cause,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
requireExactResponse(response, url, 'Domain token exchange');
|
|
82
|
+
if (!response.ok)
|
|
83
|
+
throw await refusal(response, leg, signal);
|
|
84
|
+
return admit(codecs.json.decode(await boundedResponse(response, dependencies.maximumResponseBytes, signal)), response.headers);
|
|
85
|
+
}
|
|
86
|
+
catch (cause) {
|
|
87
|
+
throw signal.aborted ? cause : unadmitted(cause, leg);
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
// Also release unread bodies rejected by URL, status, or declared-size validation.
|
|
91
|
+
void response.body?.cancel().catch(() => undefined);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
async function refusal(response, leg, signal) {
|
|
95
|
+
const status = `Domain ${leg.name} returned HTTP ${response.status}.`;
|
|
96
|
+
const refused = leg === TOKEN_EXCHANGE ? await domainError(response, signal) : undefined;
|
|
97
|
+
return refused === undefined
|
|
98
|
+
? new ExchangeError(status, { failure: leg.invalid })
|
|
99
|
+
: new ExchangeError(`${status} ${refused.payload.code}: ${refused.message}`, {
|
|
100
|
+
failure: 'rejected',
|
|
101
|
+
cause: refused,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
async function domainError(response, signal) {
|
|
105
|
+
try {
|
|
106
|
+
const body = await boundedResponse(response, dependencies.maximumResponseBytes, signal);
|
|
107
|
+
return new ProtocolError(issuer.exchange.acceptErrorResponse(codecs.json.decode(body)).error);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Report evidence the leg could not admit under that leg's failure. Validation failures of the
|
|
116
|
+
* representation (type, syntax, response shape) become exchange failures; anything else, including
|
|
117
|
+
* Session interruption and unknown defects, keeps its own identity.
|
|
118
|
+
*/
|
|
119
|
+
function unadmitted(cause, leg) {
|
|
120
|
+
if (cause instanceof ExchangeError || cause instanceof SessionError)
|
|
121
|
+
return cause;
|
|
122
|
+
if (cause instanceof ClientError || cause instanceof TypeError || cause instanceof SyntaxError) {
|
|
123
|
+
return new ExchangeError(`Domain ${leg.name} returned an invalid response.`, {
|
|
124
|
+
failure: leg.invalid,
|
|
125
|
+
cause,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return cause;
|
|
129
|
+
}
|
|
130
|
+
/** A credential is served as the exchange representation and never stored by an HTTP cache. */
|
|
131
|
+
function requireCredentialHeaders(headers) {
|
|
132
|
+
const mediaType = headers.get('content-type')?.split(';', 1)[0].trim().toLowerCase();
|
|
133
|
+
if (mediaType !== issuer.exchange.MEDIA_TYPE) {
|
|
134
|
+
throw invalidResponse('Domain token exchange returned an unsupported Content-Type.');
|
|
135
|
+
}
|
|
136
|
+
const directives = headers
|
|
137
|
+
.get('cache-control')
|
|
138
|
+
?.split(',')
|
|
139
|
+
.map((directive) => directive.trim().toLowerCase()) ?? [];
|
|
140
|
+
if (!directives.includes('no-store')) {
|
|
141
|
+
throw invalidResponse('Domain token exchange response is missing Cache-Control: no-store.');
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function invalidResponse(message, cause) {
|
|
145
|
+
return new ExchangeError(message, {
|
|
146
|
+
failure: 'invalid-response',
|
|
147
|
+
...(cause === undefined ? {} : { cause }),
|
|
148
|
+
});
|
|
149
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegation lifetime requested for each Domain credential when the caller names none. Short enough
|
|
3
|
+
* that a leaked Domain credential is worth little, long enough that a script re-exchanges each
|
|
4
|
+
* Domain a few times an hour rather than once per call.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_EXCHANGE_TTL_SECONDS: number;
|
|
7
|
+
/** Lifetime kept below the source credential, which the Kernel refuses to let a delegation reach. */
|
|
8
|
+
export declare const ISSUANCE_MARGIN_SECONDS = 5;
|
|
9
|
+
/** Source credentials whose Domain credentials one Session retains at once. */
|
|
10
|
+
export declare const MAXIMUM_EXCHANGE_SOURCES = 8;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegation lifetime requested for each Domain credential when the caller names none. Short enough
|
|
3
|
+
* that a leaked Domain credential is worth little, long enough that a script re-exchanges each
|
|
4
|
+
* Domain a few times an hour rather than once per call.
|
|
5
|
+
*/
|
|
6
|
+
export const DEFAULT_EXCHANGE_TTL_SECONDS = 5 * 60;
|
|
7
|
+
/** Lifetime kept below the source credential, which the Kernel refuses to let a delegation reach. */
|
|
8
|
+
export const ISSUANCE_MARGIN_SECONDS = 5;
|
|
9
|
+
/** Source credentials whose Domain credentials one Session retains at once. */
|
|
10
|
+
export const MAXIMUM_EXCHANGE_SOURCES = 8;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
2
|
+
import type { SessionControlOptions } from '../context/index.js';
|
|
3
|
+
import type { SessionAuth } from '../routing/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Choose how authenticated Calls to remote Domains present the Session's source authority: `auto`
|
|
6
|
+
* exchanges through each callable's declaring Domain; `source` keeps the source credential.
|
|
7
|
+
*/
|
|
8
|
+
export type SessionExchangeOptions = {
|
|
9
|
+
readonly mode: 'auto';
|
|
10
|
+
/**
|
|
11
|
+
* Delegation lifetime requested for each Domain credential. The source credential's remaining
|
|
12
|
+
* lifetime and the Domain's own ceiling may shorten it.
|
|
13
|
+
*/
|
|
14
|
+
readonly ttlSeconds?: number;
|
|
15
|
+
} | {
|
|
16
|
+
readonly mode: 'source';
|
|
17
|
+
};
|
|
18
|
+
/** One explicit exchange through a named Domain issuer. */
|
|
19
|
+
export interface SessionExchangeRequest extends SessionControlOptions {
|
|
20
|
+
/** Requested delegation lifetime; the source credential and the Domain may shorten it. */
|
|
21
|
+
readonly ttlSeconds?: number;
|
|
22
|
+
}
|
|
23
|
+
/** An admitted explicit exchange. */
|
|
24
|
+
export interface ExchangeRequest {
|
|
25
|
+
readonly issuer: IssuerId;
|
|
26
|
+
readonly ttlSeconds: number;
|
|
27
|
+
readonly control: Readonly<SessionControlOptions>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Admit exchange options against the Session auth they extend. Every Domain credential must still
|
|
31
|
+
* cover the Session delegation, so a request that could never cover it is rejected.
|
|
32
|
+
*/
|
|
33
|
+
export declare function admitExchangeOptions(input: SessionExchangeOptions | undefined, auth: SessionAuth | undefined): Readonly<{
|
|
34
|
+
ttlSeconds: number;
|
|
35
|
+
}> | undefined;
|
|
36
|
+
/** Admit an explicit exchange: the canonical absolute issuer URL of the named Domain and its lifetime. */
|
|
37
|
+
export declare function admitExchangeRequest(domain: string, input: SessionExchangeRequest | undefined): ExchangeRequest;
|