@astrale-os/kernel-client 0.6.0-beta.8 → 0.6.0-beta.80
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 +25 -10
- package/dist/auth/auth.js +5 -7
- package/dist/auth/authorization.d.ts +6 -4
- package/dist/auth/authorization.js +25 -6
- package/dist/auth/credential.d.ts +11 -2
- package/dist/auth/credential.js +6 -3
- package/dist/auth/identity.d.ts +6 -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 +8 -2
- package/dist/client/client.d.ts +4 -3
- package/dist/client/client.js +13 -3
- package/dist/client/credential.d.ts +4 -3
- package/dist/client/credential.js +7 -3
- package/dist/client/index.d.ts +1 -2
- package/dist/client/index.js +1 -2
- package/dist/client/request.d.ts +10 -4
- package/dist/client/request.js +33 -6
- package/dist/client/result.d.ts +3 -4
- package/dist/client/result.js +3 -1
- package/dist/client/routing-control.d.ts +0 -1
- package/dist/client/routing-control.js +0 -1
- package/dist/errors/client-error.d.ts +0 -1
- package/dist/errors/client-error.js +2 -1
- package/dist/errors/exchange-error.d.ts +19 -0
- package/dist/errors/exchange-error.js +9 -0
- package/dist/errors/index.d.ts +8 -7
- package/dist/errors/index.js +8 -7
- 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/response-error.d.ts +0 -1
- package/dist/errors/response-error.js +0 -1
- package/dist/errors/session-error.d.ts +9 -0
- package/dist/errors/session-error.js +9 -0
- package/dist/errors/stale-route-error.d.ts +0 -1
- package/dist/errors/stale-route-error.js +0 -1
- package/dist/errors/transport-error.d.ts +18 -6
- package/dist/errors/transport-error.js +11 -7
- package/dist/graph/domain/binding.d.ts +22 -0
- package/dist/graph/domain/binding.js +123 -0
- package/dist/graph/domain/domain.typecheck.d.ts +1 -0
- package/dist/graph/domain/domain.typecheck.js +147 -0
- package/dist/graph/domain/index.d.ts +3 -0
- package/dist/graph/domain/index.js +1 -0
- package/dist/graph/domain/model.d.ts +18 -0
- package/dist/graph/domain/model.js +1 -0
- package/dist/graph/domain/page.d.ts +23 -0
- package/dist/graph/domain/page.js +42 -0
- package/dist/graph/domain/project.d.ts +8 -0
- package/dist/graph/domain/project.js +124 -0
- package/dist/graph/domain/provenance.d.ts +6 -0
- package/dist/graph/domain/provenance.js +11 -0
- package/dist/graph/errors.d.ts +2 -3
- package/dist/graph/errors.js +1 -2
- package/dist/graph/expectation.d.ts +3 -0
- package/dist/graph/expectation.js +6 -0
- package/dist/graph/graph.d.ts +12 -8
- package/dist/graph/graph.js +0 -1
- package/dist/graph/index.d.ts +2 -2
- package/dist/graph/index.js +1 -1
- package/dist/graph/mutation.d.ts +2 -4
- package/dist/graph/mutation.js +10 -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 +4 -5
- package/dist/graph/page/neighbors.js +7 -7
- package/dist/graph/page/page.d.ts +5 -2
- package/dist/graph/page/page.js +0 -1
- package/dist/graph/page-contract.d.ts +1 -2
- package/dist/graph/page-contract.js +0 -1
- package/dist/graph/provenance.d.ts +14 -0
- package/dist/graph/provenance.js +42 -0
- package/dist/graph/query.d.ts +3 -1
- package/dist/graph/query.js +33 -13
- package/dist/graph/read.d.ts +3 -4
- package/dist/graph/read.js +6 -5
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- 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 +0 -1
- package/dist/pacer/index.js +0 -1
- 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 +0 -1
- package/dist/pacer/retry/index.js +0 -1
- package/dist/pacer/retry/retry.d.ts +0 -1
- package/dist/pacer/retry/retry.js +0 -1
- 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 +0 -1
- package/dist/schema/contracts.d.ts +6 -16
- package/dist/schema/contracts.js +0 -1
- package/dist/schema/index.d.ts +2 -3
- package/dist/schema/index.js +1 -2
- package/dist/schema/introspection.d.ts +1 -2
- package/dist/schema/introspection.js +9 -2
- package/dist/schema/operation.d.ts +0 -1
- package/dist/schema/operation.js +2 -3
- package/dist/schema/schema.d.ts +13 -10
- package/dist/schema/schema.js +83 -11
- package/dist/session/admission.d.ts +6 -0
- package/dist/session/admission.js +59 -0
- package/dist/session/bound.d.ts +48 -0
- package/dist/session/bound.js +110 -0
- package/dist/session/content.d.ts +27 -0
- package/dist/session/content.js +158 -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 +0 -1
- package/dist/session/context/index.js +0 -1
- package/dist/session/context/limits.d.ts +0 -1
- package/dist/session/context/limits.js +0 -1
- package/dist/session/context/operation.d.ts +5 -2
- package/dist/session/context/operation.js +19 -17
- package/dist/session/context/policy.d.ts +0 -1
- package/dist/session/context/policy.js +0 -1
- package/dist/session/credential/index.d.ts +1 -0
- package/dist/session/credential/index.js +1 -0
- package/dist/session/credential/limits.d.ts +12 -0
- package/dist/session/credential/limits.js +12 -0
- package/dist/session/credential/provider.d.ts +56 -0
- package/dist/session/credential/provider.js +236 -0
- package/dist/session/discovery/bundle.d.ts +5 -2
- package/dist/session/discovery/bundle.js +34 -15
- package/dist/session/discovery/discovery.d.ts +4 -2
- package/dist/session/discovery/discovery.js +34 -6
- package/dist/session/discovery/index.d.ts +3 -1
- package/dist/session/discovery/index.js +1 -1
- package/dist/session/discovery/publication.d.ts +0 -1
- package/dist/session/discovery/publication.js +4 -4
- package/dist/session/discovery/snapshot.d.ts +0 -1
- package/dist/session/discovery/snapshot.js +0 -1
- package/dist/session/discovery/transport.d.ts +6 -0
- package/dist/session/discovery/transport.js +13 -0
- package/dist/session/exchange/domain.d.ts +27 -0
- package/dist/session/exchange/domain.js +63 -0
- package/dist/session/exchange/exchange.d.ts +54 -0
- package/dist/session/exchange/exchange.js +58 -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 +29 -0
- package/dist/session/exchange/options.js +57 -0
- package/dist/session/exchange/presentation.d.ts +18 -0
- package/dist/session/exchange/presentation.js +73 -0
- package/dist/session/exchange/source.d.ts +32 -0
- package/dist/session/exchange/source.js +78 -0
- package/dist/session/execution.d.ts +65 -0
- package/dist/session/execution.js +34 -0
- package/dist/session/index.d.ts +9 -4
- package/dist/session/index.js +4 -1
- package/dist/session/reference.d.ts +40 -12
- package/dist/session/reference.js +56 -14
- package/dist/session/routing/auth.d.ts +10 -1
- package/dist/session/routing/auth.js +8 -2
- package/dist/session/routing/cache.d.ts +27 -8
- package/dist/session/routing/cache.js +218 -25
- package/dist/session/routing/dispatch.d.ts +15 -8
- package/dist/session/routing/dispatch.js +121 -48
- package/dist/session/routing/envelope.d.ts +2 -1
- package/dist/session/routing/envelope.js +14 -10
- package/dist/session/routing/index.d.ts +3 -5
- package/dist/session/routing/index.js +2 -3
- package/dist/session/routing/request.d.ts +9 -1
- package/dist/session/routing/request.js +17 -1
- package/dist/session/session.d.ts +41 -8
- package/dist/session/session.js +129 -41
- package/dist/session/session.typecheck.d.ts +0 -1
- package/dist/session/session.typecheck.js +172 -3
- package/dist/session/views/catalog.d.ts +0 -1
- package/dist/session/views/catalog.js +14 -5
- package/dist/session/views/index.d.ts +0 -1
- package/dist/session/views/index.js +0 -1
- package/dist/session/views/resolve.d.ts +0 -1
- package/dist/session/views/resolve.js +0 -1
- package/dist/store/entity-index.d.ts +0 -1
- package/dist/store/entity-index.js +0 -1
- 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 +38 -15
- 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 +4 -2
- 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 +3 -9
- package/dist/transport/auto/decision.d.ts +0 -1
- package/dist/transport/auto/decision.js +0 -1
- package/dist/transport/auto/fallback.d.ts +2 -2
- package/dist/transport/auto/fallback.js +10 -11
- 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 -1
- package/dist/transport/auto/transport.js +5 -6
- 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 +7 -0
- package/dist/transport/failure.js +9 -0
- package/dist/transport/http/byte-stream.d.ts +18 -0
- package/dist/transport/http/byte-stream.js +94 -0
- package/dist/transport/http/index.d.ts +0 -1
- package/dist/transport/http/index.js +0 -1
- package/dist/transport/http/response.d.ts +0 -1
- package/dist/transport/http/response.js +0 -1
- package/dist/transport/http/stream.d.ts +0 -1
- package/dist/transport/http/stream.js +7 -7
- package/dist/transport/http/transport.d.ts +3 -1
- package/dist/transport/http/transport.js +87 -30
- package/dist/transport/index.d.ts +0 -1
- package/dist/transport/index.js +0 -1
- package/dist/transport/transport.d.ts +0 -1
- package/dist/transport/transport.js +0 -1
- package/dist/transport/websocket/connection.d.ts +0 -1
- package/dist/transport/websocket/connection.js +16 -26
- package/dist/transport/websocket/exchange.d.ts +0 -1
- package/dist/transport/websocket/exchange.js +5 -9
- 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 -1
- package/dist/transport/websocket/transport.js +7 -20
- package/package.json +12 -14
- 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/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/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/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/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.map +0 -1
- 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/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/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
|
@@ -1,39 +1,51 @@
|
|
|
1
|
+
import { invocation } from '@astrale-os/kernel-protocol';
|
|
1
2
|
import { DEFAULT_MAXIMUM_ROUTES } from '../context/index.js';
|
|
2
|
-
|
|
3
|
+
const DESTINATION_CREDENTIAL_REFRESH_SKEW_MS = 5_000;
|
|
4
|
+
/** Confidential warm routing state owned by exactly one ClientSession. */
|
|
3
5
|
export class RouteCache {
|
|
4
6
|
maximumAgeMs;
|
|
5
7
|
maximumSize;
|
|
6
8
|
entries = new Map();
|
|
7
|
-
|
|
9
|
+
keyTokens = new Map();
|
|
10
|
+
store;
|
|
11
|
+
constructor(maximumAgeMs, maximumSize = DEFAULT_MAXIMUM_ROUTES, store) {
|
|
8
12
|
this.maximumAgeMs = maximumAgeMs;
|
|
9
13
|
this.maximumSize = maximumSize;
|
|
14
|
+
this.store = store === undefined ? undefined : captureSessionRouteStore(store);
|
|
15
|
+
this.restore();
|
|
10
16
|
}
|
|
11
|
-
async key(source, call, auth
|
|
17
|
+
async key(source, call, auth) {
|
|
12
18
|
const credential = auth.credential === undefined ? 'anonymous' : await digestText(auth.credential);
|
|
13
19
|
const delegate = auth.delegate === undefined ? 'anonymous' : await digestText(canonicalDelegate(auth.delegate));
|
|
14
|
-
return JSON.stringify([
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
expected === undefined ? null : [expected.origin, expected.revision],
|
|
20
|
-
]);
|
|
21
|
-
}
|
|
22
|
-
get(key, now = Date.now()) {
|
|
23
|
-
const entry = this.entries.get(key);
|
|
24
|
-
if (entry === undefined)
|
|
20
|
+
return JSON.stringify([source, call.target, credential, delegate]);
|
|
21
|
+
}
|
|
22
|
+
async get(key, sourceCredential, now = Date.now()) {
|
|
23
|
+
const cached = this.entries.get(key);
|
|
24
|
+
if (cached === undefined)
|
|
25
25
|
return undefined;
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const token = this.keyTokens.get(key);
|
|
27
|
+
if (cached.learned.expiresAt <= now) {
|
|
28
|
+
this.invalidate(key);
|
|
28
29
|
return undefined;
|
|
29
30
|
}
|
|
31
|
+
if (cached.integrity !== undefined) {
|
|
32
|
+
const matches = sourceCredential !== undefined &&
|
|
33
|
+
(await matchesIntegrity(sourceCredential, key, cached.sealed ?? cached.learned, cached.integrity));
|
|
34
|
+
if (this.keyTokens.get(key) !== token || this.entries.get(key) !== cached) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
if (!matches) {
|
|
38
|
+
this.invalidate(key);
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
30
42
|
this.entries.delete(key);
|
|
31
|
-
this.entries.set(key,
|
|
32
|
-
return
|
|
43
|
+
this.entries.set(key, cached);
|
|
44
|
+
return cached.learned;
|
|
33
45
|
}
|
|
34
|
-
learn(key, route, credential, now = Date.now()) {
|
|
46
|
+
async learn(key, route, credential, sourceCredential, now = Date.now()) {
|
|
35
47
|
const credentialExpiry = credential === undefined ? undefined : jwtExpiry(credential);
|
|
36
|
-
const expiresAt = Math.min(now + this.maximumAgeMs, credentialExpiry
|
|
48
|
+
const expiresAt = Math.min(now + this.maximumAgeMs, refreshBoundary(credentialExpiry));
|
|
37
49
|
const entry = Object.freeze({
|
|
38
50
|
route,
|
|
39
51
|
...(credential === undefined ? {} : { credential }),
|
|
@@ -44,22 +56,203 @@ export class RouteCache {
|
|
|
44
56
|
return entry;
|
|
45
57
|
if (expiresAt <= now)
|
|
46
58
|
return entry;
|
|
59
|
+
const token = this.reserve(key);
|
|
60
|
+
let integrity;
|
|
61
|
+
if (this.store !== undefined && sourceCredential !== undefined) {
|
|
62
|
+
try {
|
|
63
|
+
integrity = await routeIntegrity(sourceCredential, key, entry);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
// Integrity support is a persistence optimization; the learned route remains usable in memory.
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (this.keyTokens.get(key) !== token) {
|
|
70
|
+
return entry;
|
|
71
|
+
}
|
|
47
72
|
this.entries.delete(key);
|
|
48
73
|
while (this.entries.size >= this.maximumSize) {
|
|
49
74
|
const oldest = this.entries.keys().next().value;
|
|
50
75
|
if (oldest === undefined)
|
|
51
76
|
break;
|
|
52
77
|
this.entries.delete(oldest);
|
|
78
|
+
this.keyTokens.delete(oldest);
|
|
53
79
|
}
|
|
54
|
-
this.entries.set(key,
|
|
80
|
+
this.entries.set(key, Object.freeze({
|
|
81
|
+
learned: entry,
|
|
82
|
+
...(integrity === undefined ? {} : { sealed: entry, integrity }),
|
|
83
|
+
}));
|
|
84
|
+
this.persist();
|
|
55
85
|
return entry;
|
|
56
86
|
}
|
|
57
87
|
delete(key) {
|
|
58
|
-
this.
|
|
88
|
+
this.invalidate(key);
|
|
59
89
|
}
|
|
90
|
+
/** Clear this Session's memory without deleting caller-owned persistent state. */
|
|
60
91
|
clear() {
|
|
92
|
+
this.keyTokens.clear();
|
|
61
93
|
this.entries.clear();
|
|
62
94
|
}
|
|
95
|
+
invalidate(key) {
|
|
96
|
+
this.keyTokens.delete(key);
|
|
97
|
+
if (this.entries.delete(key))
|
|
98
|
+
this.persist();
|
|
99
|
+
}
|
|
100
|
+
reserve(key) {
|
|
101
|
+
const token = Object.freeze({});
|
|
102
|
+
this.keyTokens.set(key, token);
|
|
103
|
+
return token;
|
|
104
|
+
}
|
|
105
|
+
restore(now = Date.now()) {
|
|
106
|
+
if (this.store === undefined)
|
|
107
|
+
return;
|
|
108
|
+
try {
|
|
109
|
+
this.restoreInput(this.store.read(), now);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
this.keyTokens.clear();
|
|
113
|
+
this.entries.clear();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
restoreInput(input, now) {
|
|
117
|
+
if (input === undefined)
|
|
118
|
+
return;
|
|
119
|
+
if (typeof input !== 'object' || input === null || Array.isArray(input))
|
|
120
|
+
return;
|
|
121
|
+
const artifact = input;
|
|
122
|
+
if (artifact.version !== 1 ||
|
|
123
|
+
typeof artifact.entries !== 'object' ||
|
|
124
|
+
artifact.entries === null ||
|
|
125
|
+
Array.isArray(artifact.entries)) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
let count = 0;
|
|
129
|
+
for (const key in artifact.entries) {
|
|
130
|
+
if (!Object.hasOwn(artifact.entries, key))
|
|
131
|
+
continue;
|
|
132
|
+
count += 1;
|
|
133
|
+
if (count > this.maximumSize) {
|
|
134
|
+
this.keyTokens.clear();
|
|
135
|
+
this.entries.clear();
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const value = Reflect.get(artifact.entries, key);
|
|
139
|
+
const entry = admitStoredEntry(value, now, this.maximumAgeMs);
|
|
140
|
+
if (entry === undefined)
|
|
141
|
+
continue;
|
|
142
|
+
this.reserve(key);
|
|
143
|
+
this.entries.set(key, entry);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
persist() {
|
|
147
|
+
if (this.store === undefined)
|
|
148
|
+
return;
|
|
149
|
+
const entries = Object.fromEntries([...this.entries].flatMap(([key, cached]) => cached.integrity === undefined
|
|
150
|
+
? []
|
|
151
|
+
: [
|
|
152
|
+
[
|
|
153
|
+
key,
|
|
154
|
+
Object.freeze({
|
|
155
|
+
...(cached.sealed ?? cached.learned),
|
|
156
|
+
integrity: cached.integrity,
|
|
157
|
+
}),
|
|
158
|
+
],
|
|
159
|
+
]));
|
|
160
|
+
try {
|
|
161
|
+
this.store.write(Object.freeze({ version: 1, entries: Object.freeze(entries) }));
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
// A cache-store outage must not turn a valid invocation into a product failure.
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function captureSessionRouteStore(input) {
|
|
169
|
+
if (input === null ||
|
|
170
|
+
typeof input !== 'object' ||
|
|
171
|
+
typeof input.read !== 'function' ||
|
|
172
|
+
typeof input.write !== 'function') {
|
|
173
|
+
throw new TypeError('Session route store capability is invalid.');
|
|
174
|
+
}
|
|
175
|
+
const read = input.read;
|
|
176
|
+
const write = input.write;
|
|
177
|
+
return Object.freeze({
|
|
178
|
+
read: () => read.call(input),
|
|
179
|
+
write: (artifact) => write.call(input, artifact),
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function admitStoredEntry(input, now, maximumAgeMs) {
|
|
183
|
+
try {
|
|
184
|
+
if (typeof input !== 'object' || input === null || Array.isArray(input))
|
|
185
|
+
return undefined;
|
|
186
|
+
const value = input;
|
|
187
|
+
if ((value.credential !== undefined && typeof value.credential !== 'string') ||
|
|
188
|
+
typeof value.expiresAt !== 'number' ||
|
|
189
|
+
!Number.isSafeInteger(value.expiresAt) ||
|
|
190
|
+
typeof value.integrity !== 'string' ||
|
|
191
|
+
!/^[A-Za-z0-9_-]{43}$/u.test(value.integrity)) {
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
const credentialExpiry = value.credential === undefined ? undefined : jwtExpiry(value.credential);
|
|
195
|
+
if (value.credential !== undefined && credentialExpiry === undefined)
|
|
196
|
+
return undefined;
|
|
197
|
+
const sealed = Object.freeze({
|
|
198
|
+
route: invocation.acceptRoute(value.route),
|
|
199
|
+
...(value.credential === undefined ? {} : { credential: value.credential }),
|
|
200
|
+
expiresAt: value.expiresAt,
|
|
201
|
+
});
|
|
202
|
+
const expiresAt = Math.min(value.expiresAt, now + maximumAgeMs, refreshBoundary(credentialExpiry));
|
|
203
|
+
if (expiresAt <= now)
|
|
204
|
+
return undefined;
|
|
205
|
+
return Object.freeze({
|
|
206
|
+
learned: Object.freeze({
|
|
207
|
+
route: sealed.route,
|
|
208
|
+
...(sealed.credential === undefined ? {} : { credential: sealed.credential }),
|
|
209
|
+
expiresAt,
|
|
210
|
+
}),
|
|
211
|
+
sealed,
|
|
212
|
+
integrity: value.integrity,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
return undefined;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function refreshBoundary(credentialExpiry) {
|
|
220
|
+
return credentialExpiry === undefined
|
|
221
|
+
? Number.POSITIVE_INFINITY
|
|
222
|
+
: credentialExpiry - DESTINATION_CREDENTIAL_REFRESH_SKEW_MS;
|
|
223
|
+
}
|
|
224
|
+
async function routeIntegrity(sourceCredential, key, learned) {
|
|
225
|
+
const webCrypto = typeof crypto === 'undefined' ? undefined : crypto;
|
|
226
|
+
if (webCrypto?.subtle === undefined) {
|
|
227
|
+
throw new TypeError('Persistent Session route integrity requires Web Crypto HMAC support.');
|
|
228
|
+
}
|
|
229
|
+
const algorithm = Object.freeze({ name: 'HMAC', hash: 'SHA-256' });
|
|
230
|
+
const cryptographicKey = await webCrypto.subtle.importKey('raw', new TextEncoder().encode(sourceCredential), algorithm, false, ['sign']);
|
|
231
|
+
const signature = await webCrypto.subtle.sign(algorithm, cryptographicKey, new TextEncoder().encode(integrityMaterial(key, learned)));
|
|
232
|
+
return encodeBase64Url(new Uint8Array(signature));
|
|
233
|
+
}
|
|
234
|
+
async function matchesIntegrity(sourceCredential, key, learned, expected) {
|
|
235
|
+
try {
|
|
236
|
+
return (await routeIntegrity(sourceCredential, key, learned)) === expected;
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
function integrityMaterial(key, learned) {
|
|
243
|
+
return JSON.stringify({
|
|
244
|
+
version: 1,
|
|
245
|
+
key,
|
|
246
|
+
route: learned.route,
|
|
247
|
+
...(learned.credential === undefined ? {} : { credential: learned.credential }),
|
|
248
|
+
expiresAt: learned.expiresAt,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
function encodeBase64Url(input) {
|
|
252
|
+
let binary = '';
|
|
253
|
+
for (const byte of input)
|
|
254
|
+
binary += String.fromCharCode(byte);
|
|
255
|
+
return globalThis.btoa(binary).replace(/\+/gu, '-').replace(/\//gu, '_').replace(/=+$/gu, '');
|
|
63
256
|
}
|
|
64
257
|
function canonicalDelegate(input) {
|
|
65
258
|
return JSON.stringify({
|
|
@@ -83,10 +276,11 @@ function canonicalExpr(input) {
|
|
|
83
276
|
return { kind: input.kind, operands: input.operands.map(canonicalExpr) };
|
|
84
277
|
}
|
|
85
278
|
async function digestText(input) {
|
|
86
|
-
|
|
279
|
+
const webCrypto = typeof crypto === 'undefined' ? undefined : crypto;
|
|
280
|
+
if (webCrypto?.subtle === undefined) {
|
|
87
281
|
throw new TypeError('Session route caching requires Web Crypto SHA-256 support.');
|
|
88
282
|
}
|
|
89
|
-
const bytes = await
|
|
283
|
+
const bytes = await webCrypto.subtle.digest('SHA-256', new TextEncoder().encode(input));
|
|
90
284
|
return [...new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
91
285
|
}
|
|
92
286
|
function jwtExpiry(input) {
|
|
@@ -113,4 +307,3 @@ function decodeBase64(input) {
|
|
|
113
307
|
}
|
|
114
308
|
throw new TypeError('Session route caching requires base64 decoding support.');
|
|
115
309
|
}
|
|
116
|
-
//# sourceMappingURL=cache.js.map
|
|
@@ -1,35 +1,42 @@
|
|
|
1
1
|
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Result } from '../../client/index.js';
|
|
3
|
+
import type { Fetch } from '../../transport/http/index.js';
|
|
3
4
|
import type { SessionOperation, SessionPolicy } from '../context/index.js';
|
|
4
|
-
import type {
|
|
5
|
-
import type { SessionAuth } from './auth.js';
|
|
5
|
+
import type { AuthExchange, SessionAuth } from './auth.js';
|
|
6
6
|
import type { RouteCache } from './cache.js';
|
|
7
7
|
import type { ClientPoolCapability } from './envelope.js';
|
|
8
|
-
import type { SchemaExpectation } from './expectation.js';
|
|
9
8
|
import type { SessionEnvelopeTransport, SessionRequestOptions } from './request.js';
|
|
9
|
+
import { acceptCall } from '../../client/index.js';
|
|
10
10
|
export interface SessionDispatcherOptions {
|
|
11
11
|
readonly kernel: IssuerId;
|
|
12
12
|
readonly sourceEndpoint: string;
|
|
13
13
|
readonly pool: ClientPoolCapability;
|
|
14
14
|
readonly websocketAvailable: boolean;
|
|
15
15
|
readonly auth?: SessionAuth;
|
|
16
|
+
readonly exchange?: AuthExchange;
|
|
16
17
|
readonly cache: RouteCache;
|
|
17
18
|
readonly policy: Readonly<SessionPolicy>;
|
|
18
19
|
readonly envelopeTransport: SessionEnvelopeTransport;
|
|
19
|
-
readonly discovery: SessionDiscovery;
|
|
20
20
|
readonly requireOpen: () => void;
|
|
21
|
+
readonly streamingHttp: {
|
|
22
|
+
readonly fetch: Fetch;
|
|
23
|
+
readonly maximumResponseBytes: number;
|
|
24
|
+
readonly timeoutMs: number;
|
|
25
|
+
};
|
|
21
26
|
}
|
|
22
27
|
export declare class SessionDispatcher {
|
|
23
28
|
private readonly state;
|
|
24
29
|
constructor(state: SessionDispatcherOptions);
|
|
25
|
-
dispatch(input:
|
|
30
|
+
dispatch(input: Parameters<typeof acceptCall>[0], options: SessionRequestOptions, operation: SessionOperation): Promise<Result>;
|
|
31
|
+
/** Reuse Session authority and route recovery while forcing HTTP for streaming calls. */
|
|
32
|
+
dispatchHttp(input: Parameters<typeof acceptCall>[0], options: SessionRequestOptions, operation: SessionOperation, body?: Blob): Promise<Result>;
|
|
33
|
+
private dispatchWith;
|
|
26
34
|
private dispatchSource;
|
|
27
35
|
private followSource;
|
|
28
36
|
private dispatchDestinationWithRecovery;
|
|
29
37
|
private dispatchDestination;
|
|
30
|
-
private
|
|
38
|
+
private streamingClientFor;
|
|
31
39
|
}
|
|
32
40
|
export declare function requireResultKind<Kind extends 'value' | 'stream' | 'binary'>(expected: Kind, result: Result): Extract<Result, {
|
|
33
41
|
kind: Kind;
|
|
34
42
|
}>;
|
|
35
|
-
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -1,61 +1,88 @@
|
|
|
1
|
+
import { Key } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
1
2
|
import * as invocationProtocol from '@astrale-os/kernel-protocol/invocation';
|
|
2
|
-
import { acceptCall, dispatchTrace, isAdmittedMissError, isAdmittedStaleRouteError, } from '../../client/index.js';
|
|
3
|
+
import { acceptCall, Client, dispatchTrace, isAdmittedMissError, isAdmittedStaleRouteError, } from '../../client/index.js';
|
|
3
4
|
import { ClientError, ResponseError } from '../../errors/index.js';
|
|
4
5
|
import { runSessionOperation, sessionTransportOptions, allowEndpoint } from '../context/index.js';
|
|
5
6
|
import { resolveAuth } from './auth.js';
|
|
6
|
-
import { selectEnvelope } from './envelope.js';
|
|
7
|
+
import { selectEnvelope, selectEnvelopeTarget } from './envelope.js';
|
|
7
8
|
export class SessionDispatcher {
|
|
8
9
|
state;
|
|
9
10
|
constructor(state) {
|
|
10
11
|
this.state = state;
|
|
11
12
|
}
|
|
12
|
-
async dispatch(input, options, operation
|
|
13
|
+
async dispatch(input, options, operation) {
|
|
14
|
+
return this.dispatchWith(input, options, operation);
|
|
15
|
+
}
|
|
16
|
+
/** Reuse Session authority and route recovery while forcing HTTP for streaming calls. */
|
|
17
|
+
async dispatchHttp(input, options, operation, body) {
|
|
18
|
+
return this.dispatchWith(input, options, operation, { body });
|
|
19
|
+
}
|
|
20
|
+
async dispatchWith(input, options, operation, streaming) {
|
|
13
21
|
this.state.requireOpen();
|
|
14
22
|
const call = acceptCall(input);
|
|
15
23
|
// Authority is resolved before warm lookup so changed credentials or delegation cannot reuse a
|
|
16
|
-
// carrier minted for a different caller partition.
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
24
|
+
// carrier minted for a different caller partition. An exchanged credential is its own partition.
|
|
25
|
+
const resolved = await resolveAuth(this.state.auth, call, operation);
|
|
26
|
+
const auth = this.state.exchange === undefined
|
|
27
|
+
? resolved
|
|
28
|
+
: await this.state.exchange.resolve(call, resolved, operation);
|
|
29
|
+
const source = this.state.kernel;
|
|
30
|
+
const cacheKey = await this.state.cache.key(source, call, auth);
|
|
20
31
|
const dispatch = Object.freeze({
|
|
21
32
|
call,
|
|
22
33
|
auth,
|
|
23
34
|
source,
|
|
24
35
|
cacheKey,
|
|
25
|
-
...(expected === undefined ? {} : { expected }),
|
|
26
36
|
});
|
|
27
|
-
|
|
37
|
+
let learned = await this.state.cache.get(cacheKey, auth.credential);
|
|
28
38
|
if (learned !== undefined) {
|
|
29
|
-
|
|
39
|
+
try {
|
|
40
|
+
requireCachedRoute(learned, source, call.target, streaming === undefined ? this.state.envelopeTransport : 'http', this.state.websocketAvailable, this.state.policy);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
this.state.cache.delete(cacheKey);
|
|
44
|
+
learned = undefined;
|
|
45
|
+
}
|
|
30
46
|
}
|
|
31
|
-
|
|
32
|
-
|
|
47
|
+
if (learned !== undefined) {
|
|
48
|
+
return this.dispatchDestinationWithRecovery(learned, dispatch, options, operation, undefined, streaming);
|
|
49
|
+
}
|
|
50
|
+
const result = await this.dispatchSource(dispatch, undefined, options, operation, streaming);
|
|
51
|
+
return this.followSource(result, dispatch, options, operation, streaming);
|
|
33
52
|
}
|
|
34
|
-
async dispatchSource(state, routing, options, operation) {
|
|
53
|
+
async dispatchSource(state, routing, options, operation, streaming) {
|
|
35
54
|
this.state.requireOpen();
|
|
36
55
|
allowEndpoint(this.state.sourceEndpoint, this.state.policy);
|
|
37
|
-
const client =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
56
|
+
const client = streaming === undefined
|
|
57
|
+
? this.state.pool.clientFor(Object.freeze({ transport: 'http', url: this.state.sourceEndpoint }))
|
|
58
|
+
: this.streamingClientFor(this.state.sourceEndpoint);
|
|
59
|
+
return runSessionOperation(operation, () => streaming?.body === undefined
|
|
60
|
+
? authenticated(client, state.auth.credential).dispatch(state.call, {
|
|
61
|
+
...sessionTransportOptions(operation, options.idempotencyKey),
|
|
62
|
+
...(state.auth.delegate === undefined ? {} : { delegate: state.auth.delegate }),
|
|
63
|
+
...(routing === undefined ? {} : { routing }),
|
|
64
|
+
})
|
|
65
|
+
: authenticated(client, state.auth.credential).dispatch(state.call, {
|
|
66
|
+
...sessionTransportOptions(operation),
|
|
67
|
+
...(state.auth.delegate === undefined ? {} : { delegate: state.auth.delegate }),
|
|
68
|
+
...(routing === undefined ? {} : { routing }),
|
|
69
|
+
body: streaming.body,
|
|
70
|
+
}));
|
|
44
71
|
}
|
|
45
|
-
async followSource(result, state, options, operation) {
|
|
72
|
+
async followSource(result, state, options, operation, streaming) {
|
|
46
73
|
if (result.kind !== 'redirect')
|
|
47
74
|
return result;
|
|
48
75
|
const redirect = result.redirect;
|
|
49
|
-
if (redirect.route.via.issuer !== state.source
|
|
76
|
+
if (redirect.route.via.issuer !== state.source) {
|
|
50
77
|
throw new ClientError('Redirect issuer differs from the session-pinned source Kernel identity.');
|
|
51
78
|
}
|
|
52
|
-
|
|
53
|
-
const learned = this.state.cache.learn(state.cacheKey, redirect.route, redirect.credential);
|
|
54
|
-
return this.dispatchDestinationWithRecovery(learned, state, options, operation, redirect.trace);
|
|
79
|
+
requireTargetPublication(redirect.route, state.call.target);
|
|
80
|
+
const learned = await this.state.cache.learn(state.cacheKey, redirect.route, redirect.credential, state.auth.credential);
|
|
81
|
+
return this.dispatchDestinationWithRecovery(learned, state, options, operation, redirect.trace, streaming);
|
|
55
82
|
}
|
|
56
|
-
async dispatchDestinationWithRecovery(learned, state, options, operation, trace) {
|
|
83
|
+
async dispatchDestinationWithRecovery(learned, state, options, operation, trace, streaming) {
|
|
57
84
|
try {
|
|
58
|
-
return await this.dispatchDestination(learned, state.call, options, operation, state.
|
|
85
|
+
return await this.dispatchDestination(learned, state.call, options, operation, state.source, trace, streaming);
|
|
59
86
|
}
|
|
60
87
|
catch (cause) {
|
|
61
88
|
const stale = isAdmittedStaleRouteError(cause);
|
|
@@ -75,36 +102,79 @@ export class SessionDispatcher {
|
|
|
75
102
|
stale: learned.route.via.publication.etag,
|
|
76
103
|
})
|
|
77
104
|
: undefined;
|
|
78
|
-
const refreshed = await this.dispatchSource(state, routing, options, operation);
|
|
79
|
-
return this.followSource(refreshed, state, options, operation);
|
|
105
|
+
const refreshed = await this.dispatchSource(state, routing, options, operation, streaming);
|
|
106
|
+
return this.followSource(refreshed, state, options, operation, streaming);
|
|
80
107
|
}
|
|
81
108
|
}
|
|
82
|
-
async dispatchDestination(learned, call, options, operation,
|
|
83
|
-
if (learned.route.via.issuer !==
|
|
109
|
+
async dispatchDestination(learned, call, options, operation, source, trace, streaming) {
|
|
110
|
+
if (learned.route.via.issuer !== source) {
|
|
84
111
|
throw new ClientError('Learned route issuer differs from the session-pinned source Kernel.');
|
|
85
112
|
}
|
|
86
|
-
|
|
87
|
-
const
|
|
113
|
+
requireTargetPublication(learned.route, call.target);
|
|
114
|
+
const destination = streaming === undefined
|
|
115
|
+
? undefined
|
|
116
|
+
: selectEnvelopeTarget(learned.route.endpoint, 'http', this.state.websocketAvailable, this.state.policy);
|
|
117
|
+
const client = streaming === undefined
|
|
118
|
+
? selectEnvelope(learned.route.endpoint, this.state.envelopeTransport, this.state.websocketAvailable, this.state.pool, this.state.policy).client
|
|
119
|
+
: destination?.transport === 'http'
|
|
120
|
+
? this.streamingClientFor(destination.url)
|
|
121
|
+
: invalidStreamingDestination();
|
|
88
122
|
const requestOptions = {
|
|
89
123
|
...sessionTransportOptions(operation, options.idempotencyKey),
|
|
90
124
|
routing: learned.route.via,
|
|
91
125
|
};
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
:
|
|
126
|
+
const binaryRequestOptions = {
|
|
127
|
+
...sessionTransportOptions(operation),
|
|
128
|
+
routing: learned.route.via,
|
|
129
|
+
};
|
|
130
|
+
// The source has admitted this fingerprint against the exact Publication carried by Via.
|
|
131
|
+
// Pin that revision at the destination so existing Workers can execute the same admitted
|
|
132
|
+
// callable without understanding the newer fingerprint Target representation. The cache
|
|
133
|
+
// remains partitioned by the original fingerprint, and stale recovery re-admits it at source.
|
|
134
|
+
const destinationCall = typeof call.target !== 'string' && call.target.fingerprint !== undefined
|
|
135
|
+
? {
|
|
136
|
+
...call,
|
|
137
|
+
target: invocationProtocol.Target({
|
|
138
|
+
callable: call.target.callable,
|
|
139
|
+
revision: learned.route.via.publication.revision,
|
|
140
|
+
...(call.target.instance === undefined ? {} : { instance: call.target.instance }),
|
|
141
|
+
}),
|
|
142
|
+
}
|
|
143
|
+
: call;
|
|
144
|
+
const result = await runSessionOperation(operation, () => streaming?.body !== undefined
|
|
145
|
+
? trace === undefined
|
|
146
|
+
? authenticated(client, learned.credential).dispatch(destinationCall, {
|
|
147
|
+
...binaryRequestOptions,
|
|
148
|
+
body: streaming.body,
|
|
149
|
+
})
|
|
150
|
+
: dispatchTrace(client, learned.credential, destinationCall, { ...binaryRequestOptions, body: streaming.body }, trace)
|
|
151
|
+
: trace === undefined
|
|
152
|
+
? authenticated(client, learned.credential).dispatch(destinationCall, requestOptions)
|
|
153
|
+
: dispatchTrace(client, learned.credential, destinationCall, requestOptions, trace));
|
|
95
154
|
if (result.kind === 'redirect') {
|
|
96
155
|
throw new ClientError('A destination redirect is invalid; only the source Kernel may redirect.');
|
|
97
156
|
}
|
|
98
157
|
return result;
|
|
99
158
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
159
|
+
streamingClientFor(url) {
|
|
160
|
+
return new Client({
|
|
161
|
+
url,
|
|
162
|
+
fetch: this.state.streamingHttp.fetch,
|
|
163
|
+
timeoutMs: this.state.streamingHttp.timeoutMs,
|
|
164
|
+
maximumResponseBytes: this.state.streamingHttp.maximumResponseBytes,
|
|
165
|
+
});
|
|
106
166
|
}
|
|
107
167
|
}
|
|
168
|
+
function invalidStreamingDestination() {
|
|
169
|
+
throw new ClientError('Streaming route has no HTTP endpoint.');
|
|
170
|
+
}
|
|
171
|
+
function requireCachedRoute(learned, source, target, envelopeTransport, websocketAvailable, policy) {
|
|
172
|
+
if (learned.route.via.issuer !== source) {
|
|
173
|
+
throw new ClientError('Learned route issuer differs from the session-pinned source Kernel.');
|
|
174
|
+
}
|
|
175
|
+
requireTargetPublication(learned.route, target);
|
|
176
|
+
selectEnvelopeTarget(learned.route.endpoint, envelopeTransport, websocketAvailable, policy);
|
|
177
|
+
}
|
|
108
178
|
function isRouteCompatibilityConflict(input) {
|
|
109
179
|
if (!(input instanceof ResponseError))
|
|
110
180
|
return false;
|
|
@@ -113,15 +183,16 @@ function isRouteCompatibilityConflict(input) {
|
|
|
113
183
|
message: input.message,
|
|
114
184
|
...(input.data === undefined ? {} : { data: input.data }),
|
|
115
185
|
});
|
|
116
|
-
return (failure?.data.code === invocationProtocol.
|
|
117
|
-
failure?.data.code === invocationProtocol.
|
|
186
|
+
return (failure?.data.code === invocationProtocol.SCHEMA_REVISION_MISMATCH ||
|
|
187
|
+
failure?.data.code === invocationProtocol.CALLABLE_FINGERPRINT_MISMATCH ||
|
|
118
188
|
failure?.data.code === invocationProtocol.SERVICE_TRUST_REQUIRED);
|
|
119
189
|
}
|
|
120
|
-
function
|
|
121
|
-
if (
|
|
190
|
+
function requireTargetPublication(route, target) {
|
|
191
|
+
if (typeof target === 'string')
|
|
122
192
|
return;
|
|
123
193
|
const actual = route.via.publication;
|
|
124
|
-
if (actual.origin !==
|
|
194
|
+
if (actual.origin !== Key.origin(target.callable) ||
|
|
195
|
+
(target.revision !== undefined && actual.revision !== target.revision)) {
|
|
125
196
|
throw new ClientError('Resolved route does not match the expected Schema revision.');
|
|
126
197
|
}
|
|
127
198
|
}
|
|
@@ -130,9 +201,11 @@ export function requireResultKind(expected, result) {
|
|
|
130
201
|
return result;
|
|
131
202
|
if (result.kind === 'stream')
|
|
132
203
|
void result.stream.cancel(`Expected ${expected} result.`);
|
|
204
|
+
if (result.kind === 'binary' && !(result.value.body instanceof Uint8Array)) {
|
|
205
|
+
void result.value.body[Symbol.asyncIterator]().return?.();
|
|
206
|
+
}
|
|
133
207
|
throw new ClientError(`Function returned ${result.kind}; ${expected} was required.`);
|
|
134
208
|
}
|
|
135
209
|
function authenticated(client, credential) {
|
|
136
210
|
return credential === undefined ? client : client.as(credential);
|
|
137
211
|
}
|
|
138
|
-
//# sourceMappingURL=dispatch.js.map
|
|
@@ -11,4 +11,5 @@ export interface EnvelopeSelection {
|
|
|
11
11
|
readonly destination: ClientTarget;
|
|
12
12
|
}
|
|
13
13
|
export declare function selectEnvelope(endpoints: publication.InvocationEndpoints, preference: SessionEnvelopeTransport, websocketAvailable: boolean, pool: ClientPoolCapability, policy: Readonly<SessionPolicy>): EnvelopeSelection;
|
|
14
|
-
|
|
14
|
+
/** Resolve and admit one route endpoint without acquiring a transport Client. */
|
|
15
|
+
export declare function selectEnvelopeTarget(endpoints: publication.InvocationEndpoints, preference: SessionEnvelopeTransport, websocketAvailable: boolean, policy: Readonly<SessionPolicy>): ClientTarget;
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { ClientError } from '../../errors/index.js';
|
|
2
2
|
import { allowEndpoint } from '../context/index.js';
|
|
3
3
|
export function selectEnvelope(endpoints, preference, websocketAvailable, pool, policy) {
|
|
4
|
+
const destination = selectEnvelopeTarget(endpoints, preference, websocketAvailable, policy);
|
|
5
|
+
const client = pool.clientFor(destination);
|
|
6
|
+
if (client === null ||
|
|
7
|
+
typeof client !== 'object' ||
|
|
8
|
+
typeof client.dispatch !== 'function' ||
|
|
9
|
+
typeof client.as !== 'function' ||
|
|
10
|
+
typeof client.close !== 'function') {
|
|
11
|
+
throw new TypeError('Session client pool capability returned an invalid Client.');
|
|
12
|
+
}
|
|
13
|
+
return Object.freeze({ client, destination });
|
|
14
|
+
}
|
|
15
|
+
/** Resolve and admit one route endpoint without acquiring a transport Client. */
|
|
16
|
+
export function selectEnvelopeTarget(endpoints, preference, websocketAvailable, policy) {
|
|
4
17
|
let destination;
|
|
5
18
|
if (preference === 'websocket') {
|
|
6
19
|
if (endpoints.websocket === undefined) {
|
|
@@ -23,14 +36,5 @@ export function selectEnvelope(endpoints, preference, websocketAvailable, pool,
|
|
|
23
36
|
allowEndpoint(endpoints.http, policy);
|
|
24
37
|
destination = Object.freeze({ transport: 'http', url: endpoints.http });
|
|
25
38
|
}
|
|
26
|
-
|
|
27
|
-
if (client === null ||
|
|
28
|
-
typeof client !== 'object' ||
|
|
29
|
-
typeof client.dispatch !== 'function' ||
|
|
30
|
-
typeof client.as !== 'function' ||
|
|
31
|
-
typeof client.close !== 'function') {
|
|
32
|
-
throw new TypeError('Session client pool capability returned an invalid Client.');
|
|
33
|
-
}
|
|
34
|
-
return Object.freeze({ client, destination });
|
|
39
|
+
return destination;
|
|
35
40
|
}
|
|
36
|
-
//# sourceMappingURL=envelope.js.map
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
export { admitSessionAuth, resolveAuth, type Auth, type EffectiveAuth, type SessionAuth, } from './auth.js';
|
|
2
|
-
export type
|
|
3
|
-
export { RouteCache, type LearnedRoute } from './cache.js';
|
|
1
|
+
export { admitSessionAuth, resolveAuth, type Auth, type AuthExchange, type EffectiveAuth, type SessionAuth, } from './auth.js';
|
|
2
|
+
export { RouteCache, type LearnedRoute, type PersistedRoute, type SessionRouteArtifact, type SessionRouteStore, } from './cache.js';
|
|
4
3
|
export { requireResultKind, SessionDispatcher, type SessionDispatcherOptions } from './dispatch.js';
|
|
5
4
|
export { type ClientPoolCapability, type EnvelopeSelection } from './envelope.js';
|
|
6
|
-
export { admitEnvelopeTransport, admitRequestOptions, type SessionEnvelopeTransport, type SessionRequestOptions, } from './request.js';
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
5
|
+
export { admitEnvelopeTransport, admitInvocationOptions, admitRequestOptions, type SessionEnvelopeTransport, type SessionRequestOptions, type SessionRequestOptionsWithBody, } from './request.js';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { admitSessionAuth, resolveAuth, } from './auth.js';
|
|
2
|
-
export { RouteCache } from './cache.js';
|
|
2
|
+
export { RouteCache, } from './cache.js';
|
|
3
3
|
export { requireResultKind, SessionDispatcher } from './dispatch.js';
|
|
4
4
|
export {} from './envelope.js';
|
|
5
|
-
export { admitEnvelopeTransport, admitRequestOptions, } from './request.js';
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
5
|
+
export { admitEnvelopeTransport, admitInvocationOptions, admitRequestOptions, } from './request.js';
|