@astrale-os/kernel-client 0.6.0-beta.1 → 0.6.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/auth.d.ts +1 -2
- package/dist/auth/auth.js +0 -1
- package/dist/auth/authorization.d.ts +2 -3
- package/dist/auth/authorization.js +3 -4
- package/dist/auth/credential.d.ts +2 -3
- package/dist/auth/credential.js +5 -6
- package/dist/auth/identity.d.ts +2 -3
- package/dist/auth/identity.js +4 -5
- package/dist/auth/index.d.ts +1 -2
- package/dist/auth/index.js +0 -1
- package/dist/auth/provision.d.ts +0 -1
- package/dist/auth/provision.js +2 -3
- package/dist/client/admission.d.ts +0 -1
- package/dist/client/admission.js +0 -1
- package/dist/client/client.d.ts +7 -5
- package/dist/client/client.js +13 -5
- package/dist/client/credential.d.ts +4 -5
- package/dist/client/credential.js +0 -1
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +1 -2
- package/dist/client/request.d.ts +6 -4
- package/dist/client/request.js +20 -3
- package/dist/client/result.d.ts +35 -5
- package/dist/client/result.js +3 -4
- package/dist/client/routing-control.d.ts +3 -4
- package/dist/client/routing-control.js +4 -5
- package/dist/errors/client-error.d.ts +0 -1
- package/dist/errors/client-error.js +2 -1
- package/dist/errors/index.d.ts +7 -7
- package/dist/errors/index.js +7 -7
- package/dist/errors/miss-error.d.ts +3 -2
- package/dist/errors/miss-error.js +3 -2
- package/dist/errors/protocol-error.d.ts +6 -2
- package/dist/errors/protocol-error.js +2 -1
- package/dist/errors/response-error.d.ts +4 -3
- package/dist/errors/response-error.js +4 -3
- 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 +3 -3
- package/dist/errors/stale-route-error.js +3 -2
- package/dist/errors/transport-error.d.ts +20 -5
- package/dist/errors/transport-error.js +11 -5
- 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 +139 -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 +120 -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 +2 -2
- package/dist/graph/graph.d.ts +9 -9
- package/dist/graph/graph.js +0 -1
- package/dist/graph/index.d.ts +2 -1
- package/dist/graph/index.js +1 -1
- package/dist/graph/mutation.d.ts +0 -1
- package/dist/graph/mutation.js +2 -3
- 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 +6 -7
- package/dist/graph/page/page.d.ts +6 -3
- package/dist/graph/page/page.js +0 -1
- package/dist/graph/page-contract.d.ts +13 -0
- package/dist/graph/page-contract.js +1 -0
- package/dist/graph/provenance.d.ts +12 -0
- package/dist/graph/provenance.js +37 -0
- package/dist/graph/query.d.ts +1 -2
- package/dist/graph/query.js +25 -13
- package/dist/graph/read.d.ts +3 -4
- package/dist/graph/read.js +1 -2
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -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 +12 -0
- package/dist/schema/admission.js +17 -0
- package/dist/schema/contracts.d.ts +12 -0
- package/dist/schema/contracts.js +1 -0
- package/dist/schema/index.d.ts +3 -0
- package/dist/schema/index.js +2 -0
- package/dist/schema/introspection.d.ts +5 -0
- package/dist/schema/introspection.js +15 -0
- package/dist/schema/operation.d.ts +5 -0
- package/dist/schema/operation.js +9 -0
- package/dist/schema/schema.d.ts +19 -0
- package/dist/schema/schema.js +43 -0
- package/dist/session/bound.d.ts +44 -0
- package/dist/session/bound.js +75 -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 +1 -2
- package/dist/session/context/index.js +1 -2
- package/dist/session/context/limits.d.ts +0 -1
- package/dist/session/context/limits.js +0 -1
- package/dist/session/context/operation.d.ts +0 -1
- package/dist/session/context/operation.js +19 -17
- package/dist/session/context/policy.d.ts +3 -2
- package/dist/session/context/policy.js +12 -6
- package/dist/session/discovery/bundle.d.ts +0 -1
- package/dist/session/discovery/bundle.js +11 -11
- package/dist/session/discovery/discovery.d.ts +3 -11
- package/dist/session/discovery/discovery.js +6 -20
- package/dist/session/discovery/index.d.ts +3 -7
- package/dist/session/discovery/index.js +2 -2
- package/dist/session/discovery/publication.d.ts +7 -6
- package/dist/session/discovery/publication.js +25 -26
- package/dist/session/discovery/snapshot.d.ts +3 -3
- package/dist/session/discovery/snapshot.js +2 -3
- package/dist/session/discovery/transport.d.ts +6 -0
- package/dist/session/discovery/transport.js +13 -0
- package/dist/session/index.d.ts +6 -2
- package/dist/session/index.js +3 -2
- package/dist/session/reference.d.ts +36 -0
- package/dist/session/reference.js +74 -0
- package/dist/session/routing/auth.d.ts +1 -2
- package/dist/session/routing/auth.js +2 -6
- package/dist/session/routing/cache.d.ts +2 -2
- package/dist/session/routing/cache.js +9 -4
- package/dist/session/routing/dispatch.d.ts +6 -7
- package/dist/session/routing/dispatch.js +54 -18
- package/dist/session/routing/envelope.d.ts +0 -1
- package/dist/session/routing/envelope.js +0 -1
- package/dist/session/routing/expectation.d.ts +6 -0
- package/dist/session/routing/expectation.js +1 -0
- package/dist/session/routing/index.d.ts +1 -1
- package/dist/session/routing/index.js +0 -1
- package/dist/session/routing/request.d.ts +1 -2
- package/dist/session/routing/request.js +1 -2
- package/dist/session/session.d.ts +26 -15
- package/dist/session/session.js +87 -13
- package/dist/session/session.typecheck.d.ts +0 -1
- package/dist/session/session.typecheck.js +23 -2
- package/dist/session/views/catalog.d.ts +2 -3
- package/dist/session/views/catalog.js +14 -7
- package/dist/session/views/index.d.ts +0 -1
- package/dist/session/views/index.js +0 -1
- package/dist/session/views/resolve.d.ts +1 -3
- package/dist/session/views/resolve.js +4 -3
- 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 +1 -2
- package/dist/store/memory.js +0 -1
- package/dist/store/mutation.d.ts +0 -1
- package/dist/store/mutation.js +0 -1
- 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 +1 -2
- package/dist/store/query-key.js +0 -1
- package/dist/store/shape.d.ts +1 -2
- package/dist/store/shape.js +0 -1
- package/dist/store/store.d.ts +1 -2
- package/dist/store/store.js +0 -1
- package/dist/store/store.typecheck.d.ts +0 -1
- package/dist/store/store.typecheck.js +3 -4
- package/dist/transport/auto/decision.d.ts +0 -1
- package/dist/transport/auto/decision.js +0 -1
- package/dist/transport/auto/fallback.d.ts +0 -1
- package/dist/transport/auto/fallback.js +8 -10
- 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 +0 -1
- 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/index.d.ts +0 -1
- package/dist/transport/http/index.js +0 -1
- package/dist/transport/http/response.d.ts +2 -2
- package/dist/transport/http/response.js +2 -2
- package/dist/transport/http/stream.d.ts +6 -5
- package/dist/transport/http/stream.js +29 -12
- package/dist/transport/http/transport.d.ts +0 -1
- package/dist/transport/http/transport.js +46 -36
- package/dist/transport/index.d.ts +0 -1
- package/dist/transport/index.js +0 -1
- package/dist/transport/transport.d.ts +7 -2
- package/dist/transport/transport.js +0 -1
- package/dist/transport/websocket/connection.d.ts +3 -3
- package/dist/transport/websocket/connection.js +21 -34
- package/dist/transport/websocket/exchange.d.ts +7 -7
- package/dist/transport/websocket/exchange.js +50 -38
- 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 +9 -21
- package/package.json +25 -16
- 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.map +0 -1
- 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/domain/binding.d.ts +0 -25
- package/dist/domain/binding.d.ts.map +0 -1
- package/dist/domain/binding.js +0 -50
- package/dist/domain/binding.js.map +0 -1
- package/dist/domain/callable.d.ts +0 -23
- package/dist/domain/callable.d.ts.map +0 -1
- package/dist/domain/callable.js +0 -66
- package/dist/domain/callable.js.map +0 -1
- package/dist/domain/domain.typecheck.d.ts +0 -2
- package/dist/domain/domain.typecheck.d.ts.map +0 -1
- package/dist/domain/domain.typecheck.js +0 -69
- package/dist/domain/domain.typecheck.js.map +0 -1
- package/dist/domain/index.d.ts +0 -4
- package/dist/domain/index.d.ts.map +0 -1
- package/dist/domain/index.js +0 -2
- package/dist/domain/index.js.map +0 -1
- package/dist/domain/node.d.ts +0 -10
- package/dist/domain/node.d.ts.map +0 -1
- package/dist/domain/node.js +0 -6
- package/dist/domain/node.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/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/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/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/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,22 +1,23 @@
|
|
|
1
|
+
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
1
2
|
import type { publication } from '@astrale-os/kernel-protocol';
|
|
2
3
|
import type { Fetch } from '../../transport/http/index.js';
|
|
3
4
|
import type { SessionOperation } from '../context/index.js';
|
|
4
5
|
import { type SessionPolicy } from '../context/index.js';
|
|
5
6
|
export interface PublicationDiscoveryOptions {
|
|
7
|
+
readonly kernel: IssuerId;
|
|
6
8
|
readonly fetch: Fetch;
|
|
7
9
|
readonly policy: Readonly<SessionPolicy>;
|
|
8
10
|
readonly maximumBytes: number;
|
|
9
11
|
}
|
|
10
12
|
export declare class PublicationDiscovery {
|
|
11
13
|
private readonly options;
|
|
12
|
-
private
|
|
14
|
+
private publication;
|
|
15
|
+
private revision;
|
|
13
16
|
constructor(options: PublicationDiscoveryOptions);
|
|
14
|
-
current(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
invalidate(url?: string): void;
|
|
17
|
+
current(): publication.Publication | undefined;
|
|
18
|
+
revalidate(operation: SessionOperation): Promise<publication.Publication>;
|
|
19
|
+
invalidate(): void;
|
|
18
20
|
private fetch;
|
|
19
21
|
}
|
|
20
22
|
export declare function boundedResponse(response: Response, maximum: number, signal: AbortSignal): Promise<Uint8Array>;
|
|
21
23
|
export declare function requireExactResponse(response: Response, expected: string, label: string): void;
|
|
22
|
-
//# sourceMappingURL=publication.d.ts.map
|
|
@@ -1,39 +1,36 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as codecs from '@astrale-os/kernel-protocol/codecs';
|
|
2
|
+
import * as publicationCodec from '@astrale-os/kernel-protocol/publication/publication';
|
|
2
3
|
import { ClientError } from '../../errors/index.js';
|
|
3
|
-
import { allowEndpoint
|
|
4
|
+
import { allowEndpoint } from '../context/index.js';
|
|
5
|
+
import { runAcquisition } from './transport.js';
|
|
4
6
|
export class PublicationDiscovery {
|
|
5
7
|
options;
|
|
6
|
-
|
|
8
|
+
publication;
|
|
9
|
+
revision = 0;
|
|
7
10
|
constructor(options) {
|
|
8
11
|
this.options = options;
|
|
9
12
|
}
|
|
10
|
-
current(
|
|
11
|
-
return this.
|
|
13
|
+
current() {
|
|
14
|
+
return this.publication;
|
|
12
15
|
}
|
|
13
|
-
async
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const discovered = await this.fetch(origin, operation, previous);
|
|
20
|
-
const current = this.publications.get(origin);
|
|
21
|
-
if (current !== previous)
|
|
22
|
-
return current ?? this.revalidate(origin, operation);
|
|
16
|
+
async revalidate(operation) {
|
|
17
|
+
const revision = this.revision;
|
|
18
|
+
const previous = this.publication;
|
|
19
|
+
const discovered = await this.fetch(operation, previous);
|
|
20
|
+
if (revision !== this.revision)
|
|
21
|
+
return this.revalidate(operation);
|
|
23
22
|
const retained = previous?.etag === discovered.etag ? previous : discovered;
|
|
24
|
-
this.
|
|
23
|
+
this.publication = retained;
|
|
25
24
|
return retained;
|
|
26
25
|
}
|
|
27
|
-
invalidate(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
else
|
|
31
|
-
this.publications.delete(new URL(url).origin);
|
|
26
|
+
invalidate() {
|
|
27
|
+
this.revision += 1;
|
|
28
|
+
this.publication = undefined;
|
|
32
29
|
}
|
|
33
|
-
async fetch(
|
|
34
|
-
const url =
|
|
30
|
+
async fetch(operation, previous) {
|
|
31
|
+
const url = publicationCodec.url(this.options.kernel);
|
|
35
32
|
allowEndpoint(url, this.options.policy);
|
|
36
|
-
const response = await
|
|
33
|
+
const response = await runAcquisition(operation, 'publication', 'unknown', 'Kernel Publication could not be retrieved.', (signal) => this.options.fetch(url, {
|
|
37
34
|
headers: {
|
|
38
35
|
accept: 'application/json',
|
|
39
36
|
...(previous === undefined ? {} : { 'if-none-match': `"${previous.etag}"` }),
|
|
@@ -55,8 +52,11 @@ export class PublicationDiscovery {
|
|
|
55
52
|
if (!response.ok) {
|
|
56
53
|
throw new ClientError(`Publication discovery returned HTTP ${response.status}.`);
|
|
57
54
|
}
|
|
58
|
-
const body = await
|
|
55
|
+
const body = await runAcquisition(operation, 'publication', 'receive', 'Kernel Publication response could not be read.', (signal) => boundedResponse(response, this.options.maximumBytes, signal));
|
|
59
56
|
const admitted = publicationCodec.accept(codecs.json.decode(body));
|
|
57
|
+
if (admitted.identity.issuer !== this.options.kernel) {
|
|
58
|
+
throw new ClientError('Publication issuer differs from the requested Kernel issuer.');
|
|
59
|
+
}
|
|
60
60
|
const etag = response.headers.get('etag');
|
|
61
61
|
if (etag !== null && etag !== `"${admitted.etag}"`) {
|
|
62
62
|
throw new ClientError('Publication response ETag differs from its canonical content.');
|
|
@@ -121,4 +121,3 @@ function join(parts, length) {
|
|
|
121
121
|
}
|
|
122
122
|
return output;
|
|
123
123
|
}
|
|
124
|
-
//# sourceMappingURL=publication.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
1
2
|
import type { bundle } from '@astrale-os/kernel-dsl/v1';
|
|
2
3
|
import type { publication } from '@astrale-os/kernel-protocol';
|
|
3
4
|
import type { ViewCatalog } from '../views/index.js';
|
|
4
5
|
/** Coherent public observation acquired through one Client Session at one Publication ETag. */
|
|
5
6
|
export interface SessionSnapshot {
|
|
6
|
-
readonly
|
|
7
|
+
readonly kernel: IssuerId;
|
|
7
8
|
readonly publication: publication.Publication;
|
|
8
9
|
readonly bundle: bundle.Bundle;
|
|
9
10
|
readonly views: ViewCatalog;
|
|
10
11
|
}
|
|
11
|
-
export declare function createSessionSnapshot(
|
|
12
|
-
//# sourceMappingURL=snapshot.d.ts.map
|
|
12
|
+
export declare function createSessionSnapshot(kernel: IssuerId, publication: publication.Publication, artifact: bundle.Bundle, views: ViewCatalog): SessionSnapshot;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export function createSessionSnapshot(
|
|
2
|
-
return Object.freeze({
|
|
1
|
+
export function createSessionSnapshot(kernel, publication, artifact, views) {
|
|
2
|
+
return Object.freeze({ kernel, publication, bundle: artifact, views });
|
|
3
3
|
}
|
|
4
|
-
//# sourceMappingURL=snapshot.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TransportPhase } from '../../errors/index.js';
|
|
2
|
+
import type { SessionOperation } from '../context/index.js';
|
|
3
|
+
type AcquisitionResource = 'publication' | 'bundle';
|
|
4
|
+
/** Normalize only unknown failures from one injected acquisition capability. */
|
|
5
|
+
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 {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ClientError, TransportError } from '../../errors/index.js';
|
|
2
|
+
import { runSessionOperation } from '../context/index.js';
|
|
3
|
+
/** Normalize only unknown failures from one injected acquisition capability. */
|
|
4
|
+
export async function runAcquisition(operation, resource, phase, message, task) {
|
|
5
|
+
try {
|
|
6
|
+
return await runSessionOperation(operation, task);
|
|
7
|
+
}
|
|
8
|
+
catch (cause) {
|
|
9
|
+
if (cause instanceof ClientError)
|
|
10
|
+
throw cause;
|
|
11
|
+
throw TransportError.acquisition(message, { cause, phase, resource });
|
|
12
|
+
}
|
|
13
|
+
}
|
package/dist/session/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export type { SessionControlOptions, SessionPolicy } from './context/index.js';
|
|
2
|
+
export { bindSession, type BoundClientSession, type BoundSessionControls, type BoundSessionSource, } from './bound.js';
|
|
3
|
+
export type { ReadyInstallation } from '../schema/index.js';
|
|
2
4
|
export type { SessionSnapshot } from './discovery/index.js';
|
|
3
5
|
export type { Auth, SessionAuth, SessionEnvelopeTransport, SessionRequestOptions, } from './routing/index.js';
|
|
4
|
-
export { ClientSession, type ClientSessionOptions } from './session.js';
|
|
6
|
+
export { ClientSession, connect, type ClientSessionOptions, type ConnectOptions, } from './session.js';
|
|
7
|
+
export type { CallableReference, InputOfReference, InstanceCallableReference, OutputOfReference, } from './reference.js';
|
|
8
|
+
export { reference } from './reference.js';
|
|
5
9
|
export type { ResolvedView, ViewCatalog } from './views/index.js';
|
|
6
|
-
|
|
10
|
+
export type { DomainBinding } from '../graph/domain/index.js';
|
package/dist/session/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
1
|
+
export { bindSession, } from './bound.js';
|
|
2
|
+
export { ClientSession, connect, } from './session.js';
|
|
3
|
+
export { reference } from './reference.js';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Path as PathValue, PathLike } from '@astrale-os/kernel-core/path';
|
|
2
|
+
import type { CallableInputOf, CallableOutputOf, CallableResultOf, Domain, MethodInheritance, ResolvedFunction, ResolvedMethod } from '@astrale-os/kernel-dsl/v1';
|
|
3
|
+
import type { Revision } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
4
|
+
import { type Key as KeyType } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
5
|
+
import type { Binary, Input, Result } from '../client/index.js';
|
|
6
|
+
declare const REFERENCE_INPUT: unique symbol;
|
|
7
|
+
declare const REFERENCE_OUTPUT: unique symbol;
|
|
8
|
+
export interface CallableReference<InputValue extends Input = Input, Output = unknown> {
|
|
9
|
+
readonly origin: KeyType.Origin;
|
|
10
|
+
readonly revision: Revision;
|
|
11
|
+
readonly callable: KeyType.Callable;
|
|
12
|
+
readonly target: PathValue;
|
|
13
|
+
readonly outputMode: Exclude<Result['kind'], 'redirect'>;
|
|
14
|
+
readonly [REFERENCE_INPUT]?: InputValue;
|
|
15
|
+
readonly [REFERENCE_OUTPUT]?: Output;
|
|
16
|
+
}
|
|
17
|
+
export interface InstanceCallableReference<InputValue extends Input = Input, Output = unknown> {
|
|
18
|
+
(receiver: PathLike): CallableReference<InputValue, Output>;
|
|
19
|
+
readonly origin: KeyType.Origin;
|
|
20
|
+
readonly revision: Revision;
|
|
21
|
+
readonly callable: KeyType.Callable;
|
|
22
|
+
readonly outputMode: Exclude<Result['kind'], 'redirect'>;
|
|
23
|
+
}
|
|
24
|
+
export type InputOfReference<Reference extends CallableReference> = Reference extends CallableReference<infer InputValue, unknown> ? InputValue : never;
|
|
25
|
+
export type OutputOfReference<Reference extends CallableReference> = Reference extends CallableReference<infer _Input, infer Output> ? Output : never;
|
|
26
|
+
type ReferenceInput<Callable> = unknown extends CallableInputOf<Callable> ? Input : Extract<CallableInputOf<Callable>, Input>;
|
|
27
|
+
type ReferenceOutput<Callable> = unknown extends CallableOutputOf<Callable> ? unknown : CallableResultOf<Callable, Binary>;
|
|
28
|
+
type ExecutableMethodInheritance = Exclude<MethodInheritance, 'abstract'>;
|
|
29
|
+
type ExecutableStaticMethod = ResolvedMethod<unknown, unknown, true, ExecutableMethodInheritance>;
|
|
30
|
+
type ExecutableInstanceMethod = ResolvedMethod<unknown, unknown, false, ExecutableMethodInheritance>;
|
|
31
|
+
/** Project one exact resolved Function or static Method into a typed Client reference. */
|
|
32
|
+
export declare function reference<const Callable extends ResolvedFunction | ExecutableStaticMethod>(domain: Pick<Domain, 'origin' | 'revision'>, callable: Callable): CallableReference<ReferenceInput<Callable>, ReferenceOutput<Callable>>;
|
|
33
|
+
/** Project one exact resolved instance Method into a receiver-bound typed Client reference. */
|
|
34
|
+
export declare function reference<const Callable extends ExecutableInstanceMethod>(domain: Pick<Domain, 'origin' | 'revision'>, callable: Callable): InstanceCallableReference<ReferenceInput<Callable>, ReferenceOutput<Callable>>;
|
|
35
|
+
export declare function admitReference(input: CallableReference): CallableReference;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Path } from '@astrale-os/kernel-core/path';
|
|
2
|
+
import { callableAddress, Key, patterns, } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
3
|
+
export function reference(domain, callable) {
|
|
4
|
+
if ('owner' in callable && callable.inheritance === 'abstract')
|
|
5
|
+
invalid();
|
|
6
|
+
const common = Object.freeze({
|
|
7
|
+
origin: domain.origin,
|
|
8
|
+
revision: domain.revision,
|
|
9
|
+
callable: callable.key,
|
|
10
|
+
outputMode: callable.output.mode,
|
|
11
|
+
});
|
|
12
|
+
if ('owner' in callable && !callable.static) {
|
|
13
|
+
const bind = (receiver) => admitReference({
|
|
14
|
+
...common,
|
|
15
|
+
target: Path.instanceMethod(Path.from(receiver), callable.name),
|
|
16
|
+
});
|
|
17
|
+
return Object.assign(bind, common);
|
|
18
|
+
}
|
|
19
|
+
const target = 'owner' in callable
|
|
20
|
+
? Path.staticMethod(Path.project(callable.owner.ref), callable.name)
|
|
21
|
+
: Path.project(callable.ref);
|
|
22
|
+
return admitReference({ ...common, target });
|
|
23
|
+
}
|
|
24
|
+
export function admitReference(input) {
|
|
25
|
+
if (input === null || typeof input !== 'object')
|
|
26
|
+
invalid();
|
|
27
|
+
if (typeof input.origin !== 'string' ||
|
|
28
|
+
!patterns.origin.test(input.origin) ||
|
|
29
|
+
typeof input.revision !== 'string' ||
|
|
30
|
+
!patterns.revision.test(input.revision) ||
|
|
31
|
+
typeof input.callable !== 'string' ||
|
|
32
|
+
!Key.is(input.callable) ||
|
|
33
|
+
Key.origin(input.callable) !== input.origin ||
|
|
34
|
+
!['value', 'stream', 'binary'].includes(input.outputMode))
|
|
35
|
+
invalid();
|
|
36
|
+
const target = Path.from(input.target);
|
|
37
|
+
if (!matchesCallable(target, input.callable))
|
|
38
|
+
invalid();
|
|
39
|
+
return Object.freeze({
|
|
40
|
+
origin: input.origin,
|
|
41
|
+
revision: input.revision,
|
|
42
|
+
callable: input.callable,
|
|
43
|
+
target,
|
|
44
|
+
outputMode: input.outputMode,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function matchesCallable(target, callable) {
|
|
48
|
+
const coordinate = callableAddress(callable);
|
|
49
|
+
const { anchor, steps } = target.ast;
|
|
50
|
+
const last = steps.at(-1);
|
|
51
|
+
if (coordinate.kind === 'method') {
|
|
52
|
+
if (last?.kind !== 'method' || last.name !== coordinate.name)
|
|
53
|
+
return false;
|
|
54
|
+
if (last.dispatch === 'instance')
|
|
55
|
+
return true;
|
|
56
|
+
const owner = steps.at(-2);
|
|
57
|
+
return (anchor.kind === 'domain' &&
|
|
58
|
+
anchor.origin === Key.origin(callable) &&
|
|
59
|
+
steps.length === 2 &&
|
|
60
|
+
owner?.kind === 'projection' &&
|
|
61
|
+
owner.projection.kind === 'class' &&
|
|
62
|
+
owner.projection.name === coordinate.owner.name);
|
|
63
|
+
}
|
|
64
|
+
const projection = steps[0];
|
|
65
|
+
return (anchor.kind === 'domain' &&
|
|
66
|
+
anchor.origin === Key.origin(callable) &&
|
|
67
|
+
steps.length === 1 &&
|
|
68
|
+
projection?.kind === 'projection' &&
|
|
69
|
+
projection.projection.kind === 'function' &&
|
|
70
|
+
projection.projection.name === coordinate.name);
|
|
71
|
+
}
|
|
72
|
+
function invalid() {
|
|
73
|
+
throw new TypeError('Callable reference is invalid.');
|
|
74
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as invocation from '@astrale-os/kernel-protocol/invocation';
|
|
2
2
|
import type { SessionOperation } from '../context/index.js';
|
|
3
3
|
export interface Auth {
|
|
4
4
|
readonly credential?: string;
|
|
@@ -16,4 +16,3 @@ export interface EffectiveAuth {
|
|
|
16
16
|
}
|
|
17
17
|
export declare function admitSessionAuth(input: SessionAuth | undefined): SessionAuth | undefined;
|
|
18
18
|
export declare function resolveAuth(resolver: SessionAuth | undefined, call: invocation.Call, operation: SessionOperation): Promise<EffectiveAuth>;
|
|
19
|
-
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
2
2
|
import { ClientError } from '../../errors/index.js';
|
|
3
3
|
import { runSessionOperation } from '../context/index.js';
|
|
4
4
|
export function admitSessionAuth(input) {
|
|
@@ -33,11 +33,7 @@ export async function resolveAuth(resolver, call, operation) {
|
|
|
33
33
|
if (credential === undefined)
|
|
34
34
|
return Object.freeze({});
|
|
35
35
|
const delegate = input.delegate === undefined
|
|
36
|
-
? protocol.acceptDelegate({
|
|
37
|
-
ttlSeconds: resolver.ttlSeconds,
|
|
38
|
-
delegation: { kind: 'identity', self: true },
|
|
39
|
-
})
|
|
36
|
+
? protocol.acceptDelegate({ ttlSeconds: resolver.ttlSeconds })
|
|
40
37
|
: protocol.acceptDelegate(input.delegate);
|
|
41
38
|
return Object.freeze({ credential, delegate });
|
|
42
39
|
}
|
|
43
|
-
//# sourceMappingURL=auth.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { invocation } from '@astrale-os/kernel-protocol';
|
|
2
2
|
import type { EffectiveAuth } from './auth.js';
|
|
3
|
+
import type { SchemaExpectation } from './expectation.js';
|
|
3
4
|
export interface LearnedRoute {
|
|
4
5
|
readonly route: invocation.Route;
|
|
5
6
|
readonly credential?: string;
|
|
@@ -11,10 +12,9 @@ export declare class RouteCache {
|
|
|
11
12
|
private readonly maximumSize;
|
|
12
13
|
private readonly entries;
|
|
13
14
|
constructor(maximumAgeMs: number, maximumSize?: number);
|
|
14
|
-
key(source: string, call: invocation.Call, auth: EffectiveAuth): Promise<string>;
|
|
15
|
+
key(source: string, call: invocation.Call, auth: EffectiveAuth, expected?: SchemaExpectation): Promise<string>;
|
|
15
16
|
get(key: string, now?: number): LearnedRoute | undefined;
|
|
16
17
|
learn(key: string, route: invocation.Route, credential: string | undefined, now?: number): LearnedRoute;
|
|
17
18
|
delete(key: string): void;
|
|
18
19
|
clear(): void;
|
|
19
20
|
}
|
|
20
|
-
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -8,10 +8,16 @@ export class RouteCache {
|
|
|
8
8
|
this.maximumAgeMs = maximumAgeMs;
|
|
9
9
|
this.maximumSize = maximumSize;
|
|
10
10
|
}
|
|
11
|
-
async key(source, call, auth) {
|
|
11
|
+
async key(source, call, auth, expected) {
|
|
12
12
|
const credential = auth.credential === undefined ? 'anonymous' : await digestText(auth.credential);
|
|
13
13
|
const delegate = auth.delegate === undefined ? 'anonymous' : await digestText(canonicalDelegate(auth.delegate));
|
|
14
|
-
return JSON.stringify([
|
|
14
|
+
return JSON.stringify([
|
|
15
|
+
source,
|
|
16
|
+
call.target,
|
|
17
|
+
credential,
|
|
18
|
+
delegate,
|
|
19
|
+
expected === undefined ? null : [expected.origin, expected.revision],
|
|
20
|
+
]);
|
|
15
21
|
}
|
|
16
22
|
get(key, now = Date.now()) {
|
|
17
23
|
const entry = this.entries.get(key);
|
|
@@ -58,7 +64,7 @@ export class RouteCache {
|
|
|
58
64
|
function canonicalDelegate(input) {
|
|
59
65
|
return JSON.stringify({
|
|
60
66
|
ttlSeconds: input.ttlSeconds,
|
|
61
|
-
|
|
67
|
+
...(input.attenuation === undefined ? {} : { attenuation: canonicalExpr(input.attenuation) }),
|
|
62
68
|
});
|
|
63
69
|
}
|
|
64
70
|
function canonicalExpr(input) {
|
|
@@ -107,4 +113,3 @@ function decodeBase64(input) {
|
|
|
107
113
|
}
|
|
108
114
|
throw new TypeError('Session route caching requires base64 decoding support.');
|
|
109
115
|
}
|
|
110
|
-
//# sourceMappingURL=cache.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { IssuerId } from '@astrale-os/kernel-core/auth';
|
|
2
|
-
import type { Result } from '
|
|
3
|
-
import type { Call } from '../../client/index.js';
|
|
1
|
+
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
2
|
+
import type { Call, Result } from '../../client/index.js';
|
|
4
3
|
import type { SessionOperation, SessionPolicy } from '../context/index.js';
|
|
5
4
|
import type { SessionDiscovery } from '../discovery/index.js';
|
|
6
5
|
import type { SessionAuth } from './auth.js';
|
|
7
6
|
import type { RouteCache } from './cache.js';
|
|
8
7
|
import type { ClientPoolCapability } from './envelope.js';
|
|
8
|
+
import type { SchemaExpectation } from './expectation.js';
|
|
9
9
|
import type { SessionEnvelopeTransport, SessionRequestOptions } from './request.js';
|
|
10
10
|
export interface SessionDispatcherOptions {
|
|
11
|
-
readonly
|
|
12
|
-
readonly
|
|
11
|
+
readonly kernel: IssuerId;
|
|
12
|
+
readonly sourceEndpoint: string;
|
|
13
13
|
readonly pool: ClientPoolCapability;
|
|
14
14
|
readonly websocketAvailable: boolean;
|
|
15
15
|
readonly auth?: SessionAuth;
|
|
@@ -22,7 +22,7 @@ export interface SessionDispatcherOptions {
|
|
|
22
22
|
export declare class SessionDispatcher {
|
|
23
23
|
private readonly state;
|
|
24
24
|
constructor(state: SessionDispatcherOptions);
|
|
25
|
-
dispatch(input: Call, options: SessionRequestOptions, operation: SessionOperation): Promise<Result>;
|
|
25
|
+
dispatch(input: Call, options: SessionRequestOptions, operation: SessionOperation, expected?: SchemaExpectation): Promise<Result>;
|
|
26
26
|
private dispatchSource;
|
|
27
27
|
private followSource;
|
|
28
28
|
private dispatchDestinationWithRecovery;
|
|
@@ -32,4 +32,3 @@ export declare class SessionDispatcher {
|
|
|
32
32
|
export declare function requireResultKind<Kind extends 'value' | 'stream' | 'binary'>(expected: Kind, result: Result): Extract<Result, {
|
|
33
33
|
kind: Kind;
|
|
34
34
|
}>;
|
|
35
|
-
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as invocationProtocol from '@astrale-os/kernel-protocol/invocation';
|
|
2
|
+
import { acceptCall, dispatchTrace, isAdmittedMissError, isAdmittedStaleRouteError, } from '../../client/index.js';
|
|
3
|
+
import { ClientError, ResponseError } from '../../errors/index.js';
|
|
3
4
|
import { runSessionOperation, sessionTransportOptions, allowEndpoint } from '../context/index.js';
|
|
4
5
|
import { resolveAuth } from './auth.js';
|
|
5
6
|
import { selectEnvelope } from './envelope.js';
|
|
@@ -8,15 +9,21 @@ export class SessionDispatcher {
|
|
|
8
9
|
constructor(state) {
|
|
9
10
|
this.state = state;
|
|
10
11
|
}
|
|
11
|
-
async dispatch(input, options, operation) {
|
|
12
|
+
async dispatch(input, options, operation, expected) {
|
|
12
13
|
this.state.requireOpen();
|
|
13
14
|
const call = acceptCall(input);
|
|
14
15
|
// Authority is resolved before warm lookup so changed credentials or delegation cannot reuse a
|
|
15
16
|
// carrier minted for a different caller partition.
|
|
16
17
|
const auth = await resolveAuth(this.state.auth, call, operation);
|
|
17
18
|
const source = await this.sourceKernel(operation);
|
|
18
|
-
const cacheKey = await this.state.cache.key(source.issuer, call, auth);
|
|
19
|
-
const dispatch = Object.freeze({
|
|
19
|
+
const cacheKey = await this.state.cache.key(source.issuer, call, auth, expected);
|
|
20
|
+
const dispatch = Object.freeze({
|
|
21
|
+
call,
|
|
22
|
+
auth,
|
|
23
|
+
source,
|
|
24
|
+
cacheKey,
|
|
25
|
+
...(expected === undefined ? {} : { expected }),
|
|
26
|
+
});
|
|
20
27
|
const learned = this.state.cache.get(cacheKey);
|
|
21
28
|
if (learned !== undefined) {
|
|
22
29
|
return this.dispatchDestinationWithRecovery(learned, dispatch, options, operation);
|
|
@@ -26,12 +33,13 @@ export class SessionDispatcher {
|
|
|
26
33
|
}
|
|
27
34
|
async dispatchSource(state, routing, options, operation) {
|
|
28
35
|
this.state.requireOpen();
|
|
29
|
-
allowEndpoint(this.state.
|
|
30
|
-
const client = this.state.pool.clientFor(Object.freeze({ transport: 'http', url: this.state.
|
|
36
|
+
allowEndpoint(this.state.sourceEndpoint, this.state.policy);
|
|
37
|
+
const client = this.state.pool.clientFor(Object.freeze({ transport: 'http', url: this.state.sourceEndpoint }));
|
|
31
38
|
return runSessionOperation(operation, () => authenticated(client, state.auth.credential).dispatch(state.call, {
|
|
32
39
|
...sessionTransportOptions(operation, options.idempotencyKey),
|
|
33
40
|
...(state.auth.delegate === undefined ? {} : { delegate: state.auth.delegate }),
|
|
34
41
|
...(routing === undefined ? {} : { routing }),
|
|
42
|
+
...(state.expected === undefined ? {} : { schema: { revision: state.expected.revision } }),
|
|
35
43
|
}));
|
|
36
44
|
}
|
|
37
45
|
async followSource(result, state, options, operation) {
|
|
@@ -41,16 +49,21 @@ export class SessionDispatcher {
|
|
|
41
49
|
if (redirect.route.via.issuer !== state.source.issuer) {
|
|
42
50
|
throw new ClientError('Redirect issuer differs from the session-pinned source Kernel identity.');
|
|
43
51
|
}
|
|
52
|
+
requireExpectedPublication(redirect.route, state.expected);
|
|
44
53
|
const learned = this.state.cache.learn(state.cacheKey, redirect.route, redirect.credential);
|
|
45
|
-
return this.dispatchDestinationWithRecovery(learned, state, options, operation);
|
|
54
|
+
return this.dispatchDestinationWithRecovery(learned, state, options, operation, redirect.trace);
|
|
46
55
|
}
|
|
47
|
-
async dispatchDestinationWithRecovery(learned, state, options, operation) {
|
|
56
|
+
async dispatchDestinationWithRecovery(learned, state, options, operation, trace) {
|
|
48
57
|
try {
|
|
49
|
-
return await this.dispatchDestination(learned, state.call, options, operation);
|
|
58
|
+
return await this.dispatchDestination(learned, state.call, options, operation, state.expected, trace);
|
|
50
59
|
}
|
|
51
60
|
catch (cause) {
|
|
52
61
|
const stale = isAdmittedStaleRouteError(cause);
|
|
53
62
|
const miss = isAdmittedMissError(cause);
|
|
63
|
+
if (isRouteCompatibilityConflict(cause)) {
|
|
64
|
+
this.state.cache.delete(state.cacheKey);
|
|
65
|
+
throw cause;
|
|
66
|
+
}
|
|
54
67
|
if (!stale && !miss)
|
|
55
68
|
throw cause;
|
|
56
69
|
this.state.cache.delete(state.cacheKey);
|
|
@@ -66,26 +79,50 @@ export class SessionDispatcher {
|
|
|
66
79
|
return this.followSource(refreshed, state, options, operation);
|
|
67
80
|
}
|
|
68
81
|
}
|
|
69
|
-
async dispatchDestination(learned, call, options, operation) {
|
|
82
|
+
async dispatchDestination(learned, call, options, operation, expected, trace) {
|
|
70
83
|
if (learned.route.via.issuer !== (await this.sourceKernel(operation)).issuer) {
|
|
71
84
|
throw new ClientError('Learned route issuer differs from the session-pinned source Kernel.');
|
|
72
85
|
}
|
|
86
|
+
requireExpectedPublication(learned.route, expected);
|
|
73
87
|
const envelope = selectEnvelope(learned.route.endpoint, this.state.envelopeTransport, this.state.websocketAvailable, this.state.pool, this.state.policy);
|
|
74
|
-
const
|
|
88
|
+
const requestOptions = {
|
|
75
89
|
...sessionTransportOptions(operation, options.idempotencyKey),
|
|
76
90
|
routing: learned.route.via,
|
|
77
|
-
}
|
|
91
|
+
};
|
|
92
|
+
const result = await runSessionOperation(operation, () => trace === undefined
|
|
93
|
+
? authenticated(envelope.client, learned.credential).dispatch(call, requestOptions)
|
|
94
|
+
: dispatchTrace(envelope.client, learned.credential, call, requestOptions, trace));
|
|
78
95
|
if (result.kind === 'redirect') {
|
|
79
96
|
throw new ClientError('A destination redirect is invalid; only the source Kernel may redirect.');
|
|
80
97
|
}
|
|
81
98
|
return result;
|
|
82
99
|
}
|
|
83
100
|
async sourceKernel(operation) {
|
|
84
|
-
|
|
85
|
-
|
|
101
|
+
const snapshot = await this.state.discovery.snapshot(operation);
|
|
102
|
+
if (snapshot.kernel !== this.state.kernel) {
|
|
103
|
+
throw new ClientError('Session discovery returned another Kernel identity.');
|
|
86
104
|
}
|
|
87
|
-
|
|
88
|
-
|
|
105
|
+
return Object.freeze({ issuer: snapshot.publication.identity.issuer });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function isRouteCompatibilityConflict(input) {
|
|
109
|
+
if (!(input instanceof ResponseError))
|
|
110
|
+
return false;
|
|
111
|
+
const failure = invocationProtocol.serviceErrorOf({
|
|
112
|
+
code: input.code,
|
|
113
|
+
message: input.message,
|
|
114
|
+
...(input.data === undefined ? {} : { data: input.data }),
|
|
115
|
+
});
|
|
116
|
+
return (failure?.data.code === invocationProtocol.SCHEMA_UPGRADE_REQUIRED ||
|
|
117
|
+
failure?.data.code === invocationProtocol.SCHEMA_REVISION_MISMATCH ||
|
|
118
|
+
failure?.data.code === invocationProtocol.SERVICE_TRUST_REQUIRED);
|
|
119
|
+
}
|
|
120
|
+
function requireExpectedPublication(route, expected) {
|
|
121
|
+
if (expected === undefined)
|
|
122
|
+
return;
|
|
123
|
+
const actual = route.via.publication;
|
|
124
|
+
if (actual.origin !== expected.origin || actual.revision !== expected.revision) {
|
|
125
|
+
throw new ClientError('Resolved route does not match the expected Schema revision.');
|
|
89
126
|
}
|
|
90
127
|
}
|
|
91
128
|
export function requireResultKind(expected, result) {
|
|
@@ -98,4 +135,3 @@ export function requireResultKind(expected, result) {
|
|
|
98
135
|
function authenticated(client, credential) {
|
|
99
136
|
return credential === undefined ? client : client.as(credential);
|
|
100
137
|
}
|
|
101
|
-
//# sourceMappingURL=dispatch.js.map
|
|
@@ -11,4 +11,3 @@ 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
|
-
//# sourceMappingURL=envelope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { admitSessionAuth, resolveAuth, type Auth, type EffectiveAuth, type SessionAuth, } from './auth.js';
|
|
2
|
+
export type { SchemaExpectation } from './expectation.js';
|
|
2
3
|
export { RouteCache, type LearnedRoute } from './cache.js';
|
|
3
4
|
export { requireResultKind, SessionDispatcher, type SessionDispatcherOptions } from './dispatch.js';
|
|
4
5
|
export { type ClientPoolCapability, type EnvelopeSelection } from './envelope.js';
|
|
5
6
|
export { admitEnvelopeTransport, admitRequestOptions, type SessionEnvelopeTransport, type SessionRequestOptions, } from './request.js';
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as invocation from '@astrale-os/kernel-protocol/invocation';
|
|
2
2
|
import type { SessionControlOptions } from '../context/index.js';
|
|
3
3
|
export type SessionEnvelopeTransport = 'auto' | 'http' | 'websocket';
|
|
4
4
|
export interface SessionRequestOptions extends SessionControlOptions {
|
|
@@ -6,4 +6,3 @@ export interface SessionRequestOptions extends SessionControlOptions {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function admitRequestOptions(input?: SessionRequestOptions): Readonly<SessionRequestOptions>;
|
|
8
8
|
export declare function admitEnvelopeTransport(input: SessionEnvelopeTransport): SessionEnvelopeTransport;
|
|
9
|
-
//# sourceMappingURL=request.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as invocationProtocol from '@astrale-os/kernel-protocol/invocation';
|
|
2
2
|
import { admitControlOptions } from '../context/index.js';
|
|
3
3
|
export function admitRequestOptions(input = {}) {
|
|
4
4
|
if (input === null || typeof input !== 'object' || Array.isArray(input)) {
|
|
@@ -23,4 +23,3 @@ export function admitEnvelopeTransport(input) {
|
|
|
23
23
|
}
|
|
24
24
|
return input;
|
|
25
25
|
}
|
|
26
|
-
//# sourceMappingURL=request.js.map
|