@astrale-os/kernel-client 0.6.0-beta.8 → 0.6.0-beta.81
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
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { createAuth } from '../auth/auth.js';
|
|
2
|
+
import { call as createCall, } from '../client/index.js';
|
|
3
|
+
import { createGraph } from '../graph/index.js';
|
|
4
|
+
/** Capture one Session into the ordinary graph, auth, and invocation Kernel journey. */
|
|
5
|
+
export function bindSession(source, controls) {
|
|
6
|
+
if (source === null || typeof source !== 'object')
|
|
7
|
+
invalid();
|
|
8
|
+
const admittedControls = admitControls(controls);
|
|
9
|
+
const dispatchSource = capture(source, 'dispatch');
|
|
10
|
+
const admitSource = capture(source.auth, 'admit');
|
|
11
|
+
const callSource = capture(source, 'call');
|
|
12
|
+
const invokeSource = capture(source, 'invoke');
|
|
13
|
+
const streamSource = capture(source, 'stream');
|
|
14
|
+
const binarySource = capture(source, 'binary');
|
|
15
|
+
const contentSource = source.content === undefined ? unavailableContent : source.content;
|
|
16
|
+
if (contentSource === null || typeof contentSource !== 'object')
|
|
17
|
+
invalid();
|
|
18
|
+
const uploadSource = capture(contentSource, 'upload');
|
|
19
|
+
const downloadSource = capture(contentSource, 'download');
|
|
20
|
+
const viewsForSource = capture(source, 'viewsFor');
|
|
21
|
+
const schemaSource = captureSchema(source.schema);
|
|
22
|
+
const dispatch = ((input, options) => dispatchSource(input, requestOptions(options, admittedControls)));
|
|
23
|
+
const admit = (input, options) => admitSource(input, mergeOptions(options, admittedControls));
|
|
24
|
+
const call = ((input, options) => callSource(input, requestOptions(options, admittedControls)));
|
|
25
|
+
const invoke = ((reference, input, options) => invokeSource(reference, input, requestOptions(options, admittedControls)));
|
|
26
|
+
const stream = (input, options) => streamSource(input, requestOptions(options, admittedControls));
|
|
27
|
+
const binary = (input, options) => binarySource(input, requestOptions(options, admittedControls));
|
|
28
|
+
const upload = (input, options) => uploadSource(input, mergeOptions(options, admittedControls));
|
|
29
|
+
const download = (location, options) => downloadSource(location, controlOptions(options, admittedControls));
|
|
30
|
+
const content = Object.freeze({ upload, download });
|
|
31
|
+
const viewsFor = (target, options) => viewsForSource(target, controlOptions(options, admittedControls));
|
|
32
|
+
const install = (request, options) => schemaSource.install(request, controlOptions(options, admittedControls));
|
|
33
|
+
const uninstall = (request, options) => schemaSource.uninstall(request, controlOptions(options, admittedControls));
|
|
34
|
+
const inspect = (origin, options) => schemaSource.inspect(origin, controlOptions(options, admittedControls));
|
|
35
|
+
const bundle = (origin, options) => schemaSource.bundle(origin, controlOptions(options, admittedControls));
|
|
36
|
+
const dependencies = (origin, options) => schemaSource.dependencies(origin, controlOptions(options, admittedControls));
|
|
37
|
+
const schema = Object.freeze({ install, uninstall, inspect, bundle, dependencies });
|
|
38
|
+
const graph = createGraph(call);
|
|
39
|
+
const auth = createAuth((target, input, options) => call(createCall(target, input), options), admit);
|
|
40
|
+
return Object.freeze({
|
|
41
|
+
...graph,
|
|
42
|
+
kernel: source.kernel,
|
|
43
|
+
auth,
|
|
44
|
+
schema,
|
|
45
|
+
dispatch,
|
|
46
|
+
call,
|
|
47
|
+
invoke,
|
|
48
|
+
stream,
|
|
49
|
+
binary,
|
|
50
|
+
content,
|
|
51
|
+
viewsFor,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const unavailableContent = Object.freeze({
|
|
55
|
+
upload: (() => {
|
|
56
|
+
throw new TypeError('Content transfer is unavailable from this bound Session source.');
|
|
57
|
+
}),
|
|
58
|
+
download: () => {
|
|
59
|
+
throw new TypeError('Content transfer is unavailable from this bound Session source.');
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
function admitControls(input) {
|
|
63
|
+
if (input === undefined)
|
|
64
|
+
return undefined;
|
|
65
|
+
if (input === null ||
|
|
66
|
+
typeof input !== 'object' ||
|
|
67
|
+
!(input.signal instanceof AbortSignal) ||
|
|
68
|
+
!Number.isFinite(input.deadline)) {
|
|
69
|
+
invalid();
|
|
70
|
+
}
|
|
71
|
+
return Object.freeze({ signal: input.signal, deadline: input.deadline });
|
|
72
|
+
}
|
|
73
|
+
function requestOptions(options, controls) {
|
|
74
|
+
return mergeOptions(options, controls);
|
|
75
|
+
}
|
|
76
|
+
function controlOptions(options, controls) {
|
|
77
|
+
return mergeOptions(options, controls);
|
|
78
|
+
}
|
|
79
|
+
function mergeOptions(options, controls) {
|
|
80
|
+
if (controls === undefined)
|
|
81
|
+
return options;
|
|
82
|
+
if (options?.signal !== undefined && options.signal !== controls.signal) {
|
|
83
|
+
throw new TypeError('Bound ClientSession cancellation cannot be replaced.');
|
|
84
|
+
}
|
|
85
|
+
if (controls.signal.aborted)
|
|
86
|
+
throw controls.signal.reason ?? new Error('Invocation cancelled.');
|
|
87
|
+
const remaining = Math.max(1, Math.ceil(controls.deadline - Date.now()));
|
|
88
|
+
const timeoutMs = options?.timeoutMs === undefined ? remaining : Math.min(options.timeoutMs, remaining);
|
|
89
|
+
return Object.freeze({ ...options, signal: controls.signal, timeoutMs });
|
|
90
|
+
}
|
|
91
|
+
function capture(source, key) {
|
|
92
|
+
const value = source[key];
|
|
93
|
+
if (typeof value !== 'function')
|
|
94
|
+
invalid();
|
|
95
|
+
return value.bind(source);
|
|
96
|
+
}
|
|
97
|
+
function captureSchema(input) {
|
|
98
|
+
if (input === null || typeof input !== 'object')
|
|
99
|
+
invalid();
|
|
100
|
+
return Object.freeze({
|
|
101
|
+
install: capture(input, 'install'),
|
|
102
|
+
uninstall: capture(input, 'uninstall'),
|
|
103
|
+
inspect: capture(input, 'inspect'),
|
|
104
|
+
bundle: capture(input, 'bundle'),
|
|
105
|
+
dependencies: capture(input, 'dependencies'),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function invalid() {
|
|
109
|
+
throw new TypeError('Bound ClientSession source is invalid.');
|
|
110
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { schema } from '@astrale-os/kernel-dsl/v1';
|
|
2
|
+
import type { Ref } from '@astrale-os/kernel-protocol/artifact';
|
|
3
|
+
import { Path } from '@astrale-os/kernel-core/path';
|
|
4
|
+
import type { Binary, Input, Result } from '../client/index.js';
|
|
5
|
+
import type { SessionControlOptions, SessionOperation } from './context/index.js';
|
|
6
|
+
export interface ContentLocation {
|
|
7
|
+
readonly node: string;
|
|
8
|
+
readonly property: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ContentUploadOptions extends SessionControlOptions {
|
|
11
|
+
readonly mediaType: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ContentUploadResult {
|
|
14
|
+
readonly receipt: schema.values.BlobReceipt;
|
|
15
|
+
readonly ref: Ref;
|
|
16
|
+
readonly expiresAt: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ContentApi {
|
|
19
|
+
upload(source: Blob | Uint8Array, options: ContentUploadOptions): Promise<ContentUploadResult>;
|
|
20
|
+
download(location: ContentLocation, options?: SessionControlOptions): Promise<Binary>;
|
|
21
|
+
}
|
|
22
|
+
export interface ContentSessionDependencies {
|
|
23
|
+
readonly operation: (options: SessionControlOptions) => SessionOperation;
|
|
24
|
+
readonly dispatch: (target: Path, input: Input, operation: SessionOperation, body?: Blob) => Promise<Result>;
|
|
25
|
+
}
|
|
26
|
+
/** Transfer immutable content over the authenticated Session routing conversation. */
|
|
27
|
+
export declare function createContentApi(dependencies: ContentSessionDependencies): ContentApi;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { NodeId } from '@astrale-os/kernel-core/graph/node';
|
|
2
|
+
import { Path } from '@astrale-os/kernel-core/path';
|
|
3
|
+
import { download, upload } from '@astrale-os/kernel-core/schema/kernel/syscalls/references';
|
|
4
|
+
import { PropertyKey } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
5
|
+
import * as artifact from '@astrale-os/kernel-protocol/artifact';
|
|
6
|
+
import { CODES } from '@astrale-os/kernel-protocol/errors';
|
|
7
|
+
import { ClientError, ProtocolError, ResponseError, TransportError } from '../errors/index.js';
|
|
8
|
+
import { admitControlOptions, runSessionOperation } from './context/index.js';
|
|
9
|
+
import { requireResultKind } from './routing/index.js';
|
|
10
|
+
const UPLOAD = Path.project(upload);
|
|
11
|
+
const DOWNLOAD = Path.project(download);
|
|
12
|
+
const CONTENT_TIMEOUT_MS = 30 * 60 * 1_000;
|
|
13
|
+
const MAXIMUM_ATTEMPTS = 3;
|
|
14
|
+
/** Transfer immutable content over the authenticated Session routing conversation. */
|
|
15
|
+
export function createContentApi(dependencies) {
|
|
16
|
+
async function upload(source, options) {
|
|
17
|
+
const body = admitBody(source);
|
|
18
|
+
const mediaType = admitMediaType(options?.mediaType);
|
|
19
|
+
const operation = dependencies.operation(contentControls(options));
|
|
20
|
+
let last;
|
|
21
|
+
for (let attempt = 0; attempt < MAXIMUM_ATTEMPTS; attempt++) {
|
|
22
|
+
try {
|
|
23
|
+
const result = await dependencies.dispatch(UPLOAD, { mediaType }, operation, body);
|
|
24
|
+
return uploadResult(requireResultKind('value', result).value);
|
|
25
|
+
}
|
|
26
|
+
catch (cause) {
|
|
27
|
+
last = cause;
|
|
28
|
+
if (!retryable(cause) || attempt + 1 === MAXIMUM_ATTEMPTS || operation.signal.aborted) {
|
|
29
|
+
throw cause;
|
|
30
|
+
}
|
|
31
|
+
await runSessionOperation(operation, (signal) => delay(200 * 2 ** attempt, signal));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
throw last;
|
|
35
|
+
}
|
|
36
|
+
async function download(location, options) {
|
|
37
|
+
const operation = dependencies.operation(contentControls(options));
|
|
38
|
+
const result = await dependencies.dispatch(DOWNLOAD, admitLocation(location), operation);
|
|
39
|
+
return verifiedDownload(requireResultKind('binary', result).value);
|
|
40
|
+
}
|
|
41
|
+
return Object.freeze({ upload, download });
|
|
42
|
+
}
|
|
43
|
+
function admitLocation(input) {
|
|
44
|
+
if (input === null || typeof input !== 'object' || Array.isArray(input)) {
|
|
45
|
+
throw new TypeError('Content location is invalid.');
|
|
46
|
+
}
|
|
47
|
+
return Object.freeze({ node: NodeId(input.node), property: PropertyKey(input.property) });
|
|
48
|
+
}
|
|
49
|
+
function admitBody(input) {
|
|
50
|
+
if (typeof Blob !== 'undefined' && input instanceof Blob)
|
|
51
|
+
return input;
|
|
52
|
+
if (input instanceof Uint8Array) {
|
|
53
|
+
// Blob snapshots an ArrayBuffer view; a SharedArrayBuffer view needs an owned copy.
|
|
54
|
+
const bytes = input.buffer instanceof ArrayBuffer
|
|
55
|
+
? input
|
|
56
|
+
: new Uint8Array(input);
|
|
57
|
+
return new Blob([bytes]);
|
|
58
|
+
}
|
|
59
|
+
throw new TypeError('Content upload source must be a Blob, File, or Uint8Array.');
|
|
60
|
+
}
|
|
61
|
+
function admitMediaType(input) {
|
|
62
|
+
if (typeof input !== 'string')
|
|
63
|
+
throw new TypeError('Content upload mediaType is required.');
|
|
64
|
+
return artifact.identify(new Uint8Array(), input).mediaType;
|
|
65
|
+
}
|
|
66
|
+
function contentControls(input) {
|
|
67
|
+
const controls = admitControlOptions(input);
|
|
68
|
+
return Object.freeze({ ...controls, timeoutMs: controls.timeoutMs ?? CONTENT_TIMEOUT_MS });
|
|
69
|
+
}
|
|
70
|
+
function uploadResult(input) {
|
|
71
|
+
if (input === null || typeof input !== 'object' || Array.isArray(input)) {
|
|
72
|
+
throw new ClientError('Content upload returned an invalid receipt.');
|
|
73
|
+
}
|
|
74
|
+
const value = input;
|
|
75
|
+
if (typeof value.receipt !== 'string' ||
|
|
76
|
+
value.receipt.length === 0 ||
|
|
77
|
+
typeof value.expiresAt !== 'string' ||
|
|
78
|
+
!Number.isFinite(Date.parse(value.expiresAt))) {
|
|
79
|
+
throw new ClientError('Content upload returned an invalid receipt.');
|
|
80
|
+
}
|
|
81
|
+
let ref;
|
|
82
|
+
try {
|
|
83
|
+
ref = artifact.accept(value.ref);
|
|
84
|
+
}
|
|
85
|
+
catch (cause) {
|
|
86
|
+
throw new ClientError('Content upload returned an invalid Ref.', { cause });
|
|
87
|
+
}
|
|
88
|
+
return Object.freeze({
|
|
89
|
+
receipt: value.receipt,
|
|
90
|
+
ref,
|
|
91
|
+
expiresAt: value.expiresAt,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function retryable(cause) {
|
|
95
|
+
return ((cause instanceof TransportError && cause.context.kind === 'invocation') ||
|
|
96
|
+
(cause instanceof ResponseError &&
|
|
97
|
+
(cause.reason?.code === 'BLOB_UNAVAILABLE' ||
|
|
98
|
+
cause.code === CODES.CANCELLED ||
|
|
99
|
+
cause.code === CODES.DEADLINE_EXCEEDED ||
|
|
100
|
+
cause.code === CODES.OUTCOME_UNKNOWN)));
|
|
101
|
+
}
|
|
102
|
+
function delay(ms, signal) {
|
|
103
|
+
return new Promise((resolve, reject) => {
|
|
104
|
+
if (signal.aborted)
|
|
105
|
+
return reject(signal.reason);
|
|
106
|
+
const timer = setTimeout(() => {
|
|
107
|
+
signal.removeEventListener('abort', abort);
|
|
108
|
+
resolve();
|
|
109
|
+
}, ms);
|
|
110
|
+
const abort = () => {
|
|
111
|
+
clearTimeout(timer);
|
|
112
|
+
reject(signal.reason);
|
|
113
|
+
};
|
|
114
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
async function verifiedDownload(input) {
|
|
118
|
+
const raw = input.headers?.['x-astrale-blob-size'];
|
|
119
|
+
if (raw === undefined || !/^(?:0|[1-9][0-9]*)$/u.test(raw)) {
|
|
120
|
+
await cancelBinary(input);
|
|
121
|
+
throw new ProtocolError('Content download omitted its exact content size.');
|
|
122
|
+
}
|
|
123
|
+
const expected = Number(raw);
|
|
124
|
+
if (!Number.isSafeInteger(expected)) {
|
|
125
|
+
await cancelBinary(input);
|
|
126
|
+
throw new ProtocolError('Content download content size is invalid.');
|
|
127
|
+
}
|
|
128
|
+
if (input.body instanceof Uint8Array) {
|
|
129
|
+
if (input.body.byteLength !== expected) {
|
|
130
|
+
throw new ProtocolError('Content download ended before its exact content size.');
|
|
131
|
+
}
|
|
132
|
+
return input;
|
|
133
|
+
}
|
|
134
|
+
return Object.freeze({ ...input, body: exactContentBytes(input.body, expected) });
|
|
135
|
+
}
|
|
136
|
+
async function cancelBinary(input) {
|
|
137
|
+
if (input.body instanceof Uint8Array)
|
|
138
|
+
return;
|
|
139
|
+
try {
|
|
140
|
+
await input.body[Symbol.asyncIterator]().return?.();
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
// Preserve the admission error after the response stream has been closed.
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async function* exactContentBytes(body, expected) {
|
|
147
|
+
let received = 0;
|
|
148
|
+
for await (const bytes of body) {
|
|
149
|
+
received += bytes.byteLength;
|
|
150
|
+
if (received > expected) {
|
|
151
|
+
throw new ProtocolError('Content download exceeded its exact content size.');
|
|
152
|
+
}
|
|
153
|
+
yield bytes;
|
|
154
|
+
}
|
|
155
|
+
if (received !== expected) {
|
|
156
|
+
throw new ProtocolError('Content download ended before its exact content size.');
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -2,4 +2,3 @@ export { admitControlOptions, type SessionControlOptions } from './control.js';
|
|
|
2
2
|
export { DEFAULT_MAXIMUM_BUNDLE_BYTES, DEFAULT_MAXIMUM_PUBLICATION_BYTES, DEFAULT_MAXIMUM_RESPONSE_BYTES, DEFAULT_MAXIMUM_ROUTES, DEFAULT_TIMEOUT_MS, platformDuration, positive, } from './limits.js';
|
|
3
3
|
export { createSessionOperation, runSessionOperation, sessionTransportOptions, type SessionOperation, } from './operation.js';
|
|
4
4
|
export { admitKernel, admitPolicy, allowEndpoint, kernelInvocationEndpoint, type SessionPolicy, } from './policy.js';
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -2,4 +2,3 @@ export { admitControlOptions } from './control.js';
|
|
|
2
2
|
export { DEFAULT_MAXIMUM_BUNDLE_BYTES, DEFAULT_MAXIMUM_PUBLICATION_BYTES, DEFAULT_MAXIMUM_RESPONSE_BYTES, DEFAULT_MAXIMUM_ROUTES, DEFAULT_TIMEOUT_MS, platformDuration, positive, } from './limits.js';
|
|
3
3
|
export { createSessionOperation, runSessionOperation, sessionTransportOptions, } from './operation.js';
|
|
4
4
|
export { admitKernel, admitPolicy, allowEndpoint, kernelInvocationEndpoint, } from './policy.js';
|
|
5
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -5,4 +5,3 @@ export declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
|
5
5
|
export declare const DEFAULT_MAXIMUM_ROUTES = 256;
|
|
6
6
|
export declare function positive(input: number, label: string): number;
|
|
7
7
|
export declare function platformDuration(input: number, label: string): number;
|
|
8
|
-
//# sourceMappingURL=limits.d.ts.map
|
|
@@ -13,8 +13,11 @@ export declare function createSessionOperation(lifecycle: AbortSignal, input: {
|
|
|
13
13
|
readonly idempotencyKey?: RequestOptions['idempotencyKey'];
|
|
14
14
|
} | undefined, defaultTimeoutMs: number): SessionOperation;
|
|
15
15
|
export declare function remainingSessionTime(operation: SessionOperation): number;
|
|
16
|
-
export declare function sessionTransportOptions(operation: SessionOperation
|
|
16
|
+
export declare function sessionTransportOptions(operation: SessionOperation): {
|
|
17
|
+
readonly signal: AbortSignal;
|
|
18
|
+
readonly timeoutMs: number;
|
|
19
|
+
};
|
|
20
|
+
export declare function sessionTransportOptions(operation: SessionOperation, idempotencyKey: RequestOptions['idempotencyKey']): RequestOptions;
|
|
17
21
|
/** Settle independently of a caller capability that ignores its supplied AbortSignal. */
|
|
18
22
|
export declare function runSessionOperation<Result>(operation: SessionOperation, task: (signal: AbortSignal) => Result | PromiseLike<Result>): Promise<Result>;
|
|
19
23
|
export declare function requireSessionOperation(operation: SessionOperation): void;
|
|
20
|
-
//# sourceMappingURL=operation.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SessionError } from '../../errors/index.js';
|
|
2
2
|
/** Create one total wall-clock budget for a complete public Client Session operation. */
|
|
3
3
|
export function createSessionOperation(lifecycle, input, defaultTimeoutMs) {
|
|
4
4
|
const timeoutMs = input?.timeoutMs ?? defaultTimeoutMs;
|
|
@@ -22,7 +22,7 @@ export function remainingSessionTime(operation) {
|
|
|
22
22
|
requireSessionOperation(operation);
|
|
23
23
|
const remaining = operation.deadline - Date.now();
|
|
24
24
|
if (remaining < 1)
|
|
25
|
-
throw new
|
|
25
|
+
throw new SessionError('Session operation timed out.', { failure: 'timeout' });
|
|
26
26
|
return remaining;
|
|
27
27
|
}
|
|
28
28
|
export function sessionTransportOptions(operation, idempotencyKey) {
|
|
@@ -33,13 +33,8 @@ export function sessionTransportOptions(operation, idempotencyKey) {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
/** Settle independently of a caller capability that ignores its supplied AbortSignal. */
|
|
36
|
-
export function runSessionOperation(operation, task) {
|
|
37
|
-
|
|
38
|
-
requireSessionOperation(operation);
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
return Promise.reject(error);
|
|
42
|
-
}
|
|
36
|
+
export async function runSessionOperation(operation, task) {
|
|
37
|
+
requireSessionOperation(operation);
|
|
43
38
|
let abort;
|
|
44
39
|
const interrupted = new Promise((_resolve, reject) => {
|
|
45
40
|
abort = () => reject(sessionInterruption(operation.signal.reason));
|
|
@@ -49,9 +44,14 @@ export function runSessionOperation(operation, task) {
|
|
|
49
44
|
requireSessionOperation(operation);
|
|
50
45
|
return task(operation.signal);
|
|
51
46
|
});
|
|
52
|
-
return Promise.race([execution, interrupted])
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
return Promise.race([execution, interrupted])
|
|
48
|
+
.catch((cause) => {
|
|
49
|
+
if (operation.signal.aborted)
|
|
50
|
+
throw sessionInterruption(operation.signal.reason);
|
|
51
|
+
throw cause;
|
|
52
|
+
})
|
|
53
|
+
.finally(() => {
|
|
54
|
+
operation.signal.removeEventListener('abort', abort);
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
export function requireSessionOperation(operation) {
|
|
@@ -60,11 +60,13 @@ export function requireSessionOperation(operation) {
|
|
|
60
60
|
throw sessionInterruption(operation.signal.reason);
|
|
61
61
|
}
|
|
62
62
|
function sessionInterruption(reason) {
|
|
63
|
+
if (reason instanceof SessionError)
|
|
64
|
+
return reason;
|
|
63
65
|
if (reason instanceof DOMException && reason.name === 'TimeoutError') {
|
|
64
|
-
return new
|
|
66
|
+
return new SessionError('Session operation timed out.', { cause: reason, failure: 'timeout' });
|
|
65
67
|
}
|
|
66
|
-
return
|
|
67
|
-
|
|
68
|
-
:
|
|
68
|
+
return new SessionError('Session operation was cancelled.', {
|
|
69
|
+
cause: reason,
|
|
70
|
+
failure: 'cancelled',
|
|
71
|
+
});
|
|
69
72
|
}
|
|
70
|
-
//# sourceMappingURL=operation.js.map
|
|
@@ -9,4 +9,3 @@ export declare function admitKernel(input: string, insecure: boolean): IssuerId;
|
|
|
9
9
|
export declare function kernelInvocationEndpoint(input: IssuerId): string;
|
|
10
10
|
export declare function websocketEndpoint(input: string, insecure: boolean): string;
|
|
11
11
|
export declare function allowEndpoint(url: string, policy: Readonly<SessionPolicy>): void;
|
|
12
|
-
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createSessionCredentialProvider, delegationCoverageMs, type SessionCredential, type SessionCredentialProvider, type SessionCredentialProviderOptions, type SessionCredentialState, } from './provider.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createSessionCredentialProvider, delegationCoverageMs, } from './provider.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settlement allowance added to the declared delegation TTL to form the refresh threshold. It
|
|
3
|
+
* matches the destination-credential skew routing already applies to a warm entry, so a credential
|
|
4
|
+
* served here cannot expire between admission and delivery.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SETTLEMENT_SKEW_MS = 5000;
|
|
7
|
+
/** Total budget for one mint, matching the default Session operation budget. */
|
|
8
|
+
export declare const MINT_TIMEOUT_MS = 30000;
|
|
9
|
+
/** Bounded backoff between anticipation attempts after a failed mint. */
|
|
10
|
+
export declare const BACKOFF_MS: readonly [1000, 2000, 4000];
|
|
11
|
+
/** Steady retry interval once the bounded backoff is exhausted. */
|
|
12
|
+
export declare const RETRY_INTERVAL_MS = 4000;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settlement allowance added to the declared delegation TTL to form the refresh threshold. It
|
|
3
|
+
* matches the destination-credential skew routing already applies to a warm entry, so a credential
|
|
4
|
+
* served here cannot expire between admission and delivery.
|
|
5
|
+
*/
|
|
6
|
+
export const SETTLEMENT_SKEW_MS = 5_000;
|
|
7
|
+
/** Total budget for one mint, matching the default Session operation budget. */
|
|
8
|
+
export const MINT_TIMEOUT_MS = 30_000;
|
|
9
|
+
/** Bounded backoff between anticipation attempts after a failed mint. */
|
|
10
|
+
export const BACKOFF_MS = [1_000, 2_000, 4_000];
|
|
11
|
+
/** Steady retry interval once the bounded backoff is exhausted. */
|
|
12
|
+
export const RETRY_INTERVAL_MS = 4_000;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { SessionAuth } from '../routing/index.js';
|
|
2
|
+
/** One source credential and the exact instant it stops being accepted. */
|
|
3
|
+
export interface SessionCredential {
|
|
4
|
+
readonly credential: string;
|
|
5
|
+
/** Absolute Unix time in milliseconds. */
|
|
6
|
+
readonly expiresAt: number;
|
|
7
|
+
}
|
|
8
|
+
/** Observable lifecycle of the single credential one provider owns. */
|
|
9
|
+
export type SessionCredentialState = {
|
|
10
|
+
readonly status: 'empty';
|
|
11
|
+
} | {
|
|
12
|
+
readonly status: 'valid';
|
|
13
|
+
readonly credential: SessionCredential;
|
|
14
|
+
} | {
|
|
15
|
+
readonly status: 'refreshing';
|
|
16
|
+
readonly credential?: SessionCredential;
|
|
17
|
+
} | {
|
|
18
|
+
readonly status: 'degraded';
|
|
19
|
+
readonly credential: SessionCredential;
|
|
20
|
+
readonly error: unknown;
|
|
21
|
+
} | {
|
|
22
|
+
readonly status: 'expired';
|
|
23
|
+
readonly error: unknown;
|
|
24
|
+
};
|
|
25
|
+
export interface SessionCredentialProviderOptions {
|
|
26
|
+
/** Delegation TTL every served credential must still cover; also the SessionAuth TTL. */
|
|
27
|
+
readonly ttlSeconds: number;
|
|
28
|
+
/** Acquire one fresh credential; the supplied signal is owned by the provider. */
|
|
29
|
+
mint(signal: AbortSignal): Promise<SessionCredential>;
|
|
30
|
+
/** Caller-held credential admitted as the initial entry; it need only be unexpired. */
|
|
31
|
+
readonly initial?: SessionCredential;
|
|
32
|
+
readonly onChange?: (state: SessionCredentialState) => void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Caller-owned source credential with a derived refresh threshold and shared minting.
|
|
36
|
+
*
|
|
37
|
+
* The provider is a SessionAuth, so a ClientSession consumes it directly. Anticipation is opt-in:
|
|
38
|
+
* an ephemeral process or a request-scoped worker never holds a pending timer it did not ask for.
|
|
39
|
+
*/
|
|
40
|
+
export interface SessionCredentialProvider extends SessionAuth {
|
|
41
|
+
state(): SessionCredentialState;
|
|
42
|
+
/** Serve a credential that still covers the delegation TTL; concurrent callers share one mint. */
|
|
43
|
+
acquire(signal?: AbortSignal): Promise<SessionCredential>;
|
|
44
|
+
/** Mint regardless of the current credential, joining a mint already in flight. */
|
|
45
|
+
refresh(signal?: AbortSignal): Promise<SessionCredential>;
|
|
46
|
+
/** Begin anticipating expiry: threshold timer, bounded backoff, and an expiry watchdog. */
|
|
47
|
+
start(): void;
|
|
48
|
+
/** Stop anticipating; a mint already in flight still settles. */
|
|
49
|
+
stop(): void;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Remaining lifetime a credential must exceed to carry a delegation of `ttlSeconds`: the TTL itself
|
|
53
|
+
* plus the settlement skew, so it cannot expire between admission and delivery.
|
|
54
|
+
*/
|
|
55
|
+
export declare function delegationCoverageMs(ttlSeconds: number): number;
|
|
56
|
+
export declare function createSessionCredentialProvider(options: SessionCredentialProviderOptions): SessionCredentialProvider;
|