@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
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as portable from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
/** Admit one value result through its Core-owned syscall contract. */
|
|
3
|
+
export function acceptOutput(contract, input) {
|
|
4
|
+
const value = portable.accept(input);
|
|
5
|
+
const parsed = contract.safeParse(value);
|
|
6
|
+
if (!parsed.success)
|
|
7
|
+
throw new TypeError('Kernel returned an invalid Schema result.');
|
|
8
|
+
return freeze(parsed.data);
|
|
9
|
+
}
|
|
10
|
+
function freeze(input) {
|
|
11
|
+
if (input !== null && typeof input === 'object' && !Object.isFrozen(input)) {
|
|
12
|
+
for (const value of Object.values(input))
|
|
13
|
+
freeze(value);
|
|
14
|
+
Object.freeze(input);
|
|
15
|
+
}
|
|
16
|
+
return input;
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { installation } from '@astrale-os/kernel-core/schema';
|
|
2
|
+
import type { DesiredInstallation as CoreDesiredInstallation, InstallInput, InstallOutput, UninstallInput, UninstallOutput } from '@astrale-os/kernel-core/schema/kernel/syscalls/contracts';
|
|
3
|
+
export type OperationId = installation.OperationId;
|
|
4
|
+
/** Canonical caller input accepted by the Kernel install syscall. */
|
|
5
|
+
export type DesiredInstallation = CoreDesiredInstallation;
|
|
6
|
+
export type InstallRequest = InstallInput;
|
|
7
|
+
/** Admitted terminal install receipt returned by the Kernel. */
|
|
8
|
+
export type InstallReceipt = InstallOutput;
|
|
9
|
+
/** Canonical caller input accepted by the Kernel uninstall syscall. */
|
|
10
|
+
export type UninstallRequest = UninstallInput;
|
|
11
|
+
/** Admitted terminal uninstall receipt returned by the Kernel. */
|
|
12
|
+
export type UninstallReceipt = UninstallOutput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createSchema, type SchemaApi, type SchemaCall, type SchemaOptions, type ReadyInstallation, } from './schema.js';
|
|
2
|
+
export { acceptOperationId, createOperationId } from './operation.js';
|
|
3
|
+
export type { DesiredInstallation, InstallReceipt, InstallRequest, OperationId, UninstallReceipt, UninstallRequest, } from './contracts.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { introspection as language } from '@astrale-os/kernel-core/schema';
|
|
2
|
+
import type * as protocol from '@astrale-os/kernel-protocol/schema';
|
|
3
|
+
import type { RequestOptions } from '../transport/index.js';
|
|
4
|
+
import type { SchemaCall, SchemaOptions } from './schema.js';
|
|
5
|
+
export declare function introspect<InputType extends language.Introspection>(invoke: SchemaCall, limits: SchemaOptions, request: InputType, options?: RequestOptions): Promise<protocol.installation.introspection.ResultFor<InputType>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Path } from '@astrale-os/kernel-core/path';
|
|
2
|
+
import { introspect as introspectRef } from '@astrale-os/kernel-core/schema/kernel/syscalls/references';
|
|
3
|
+
import * as schema from '@astrale-os/kernel-protocol/schema';
|
|
4
|
+
import { call } from '../client/index.js';
|
|
5
|
+
const INTROSPECT_PATH = Path.project(introspectRef).raw;
|
|
6
|
+
export async function introspect(invoke, limits, request, options) {
|
|
7
|
+
const result = await invoke(call(INTROSPECT_PATH, request), options);
|
|
8
|
+
if (result.kind !== 'binary') {
|
|
9
|
+
throw new TypeError('Schema introspection returned a non-binary result.');
|
|
10
|
+
}
|
|
11
|
+
if (result.value.mediaType !== schema.installation.introspection.MEDIA_TYPE) {
|
|
12
|
+
throw new TypeError('Schema introspection returned an unsupported media type.');
|
|
13
|
+
}
|
|
14
|
+
return schema.installation.introspection.decode(request, result.value.body, limits);
|
|
15
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { OperationId } from './contracts.js';
|
|
2
|
+
/** Accept one canonical lowercase RFC 9562 UUIDv4 operation identity. */
|
|
3
|
+
export declare function acceptOperationId(input: unknown): OperationId;
|
|
4
|
+
/** Allocate one cryptographically generated operation identity for a new lifecycle request. */
|
|
5
|
+
export declare function createOperationId(): OperationId;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as installation from '@astrale-os/kernel-core/schema/installation';
|
|
2
|
+
/** Accept one canonical lowercase RFC 9562 UUIDv4 operation identity. */
|
|
3
|
+
export function acceptOperationId(input) {
|
|
4
|
+
return installation.acceptOperationId(input);
|
|
5
|
+
}
|
|
6
|
+
/** Allocate one cryptographically generated operation identity for a new lifecycle request. */
|
|
7
|
+
export function createOperationId() {
|
|
8
|
+
return acceptOperationId(globalThis.crypto.randomUUID());
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { introspection } from '@astrale-os/kernel-core/schema';
|
|
2
|
+
import type * as protocolSchema from '@astrale-os/kernel-protocol/schema';
|
|
3
|
+
import type { Call, Result } from '../client/index.js';
|
|
4
|
+
import type { RequestOptions } from '../transport/index.js';
|
|
5
|
+
import type { InstallReceipt, InstallRequest, UninstallReceipt, UninstallRequest } from './contracts.js';
|
|
6
|
+
export type SchemaCall = (call: Call, options?: RequestOptions) => Promise<Result>;
|
|
7
|
+
export interface SchemaOptions extends protocolSchema.installation.introspection.Limits {
|
|
8
|
+
}
|
|
9
|
+
export type ReadyInstallation = protocolSchema.installation.introspection.Installation & {
|
|
10
|
+
readonly state: 'ready';
|
|
11
|
+
readonly readiness: protocolSchema.installation.introspection.Digest;
|
|
12
|
+
};
|
|
13
|
+
export interface SchemaApi {
|
|
14
|
+
install(request: InstallRequest, options?: RequestOptions): Promise<InstallReceipt>;
|
|
15
|
+
uninstall(request: UninstallRequest, options?: RequestOptions): Promise<UninstallReceipt>;
|
|
16
|
+
introspect<Input extends introspection.Introspection>(request: Input, options?: RequestOptions): Promise<protocolSchema.installation.introspection.ResultFor<Input>>;
|
|
17
|
+
}
|
|
18
|
+
/** Bind the canonical Schema lifecycle syscalls to one caller-scoped value-call capability. */
|
|
19
|
+
export declare function createSchema(call: SchemaCall, limits: SchemaOptions): SchemaApi;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Path } from '@astrale-os/kernel-core/path';
|
|
2
|
+
import { installOutput, uninstallOutput, } from '@astrale-os/kernel-core/schema/kernel/syscalls/contracts';
|
|
3
|
+
import { install, uninstall } from '@astrale-os/kernel-core/schema/kernel/syscalls/references';
|
|
4
|
+
import { call as invocation } from '../client/index.js';
|
|
5
|
+
import { acceptOutput } from './admission.js';
|
|
6
|
+
import { introspect as inspect } from './introspection.js';
|
|
7
|
+
const INSTALL_PATH = Path.project(install).raw;
|
|
8
|
+
const UNINSTALL_PATH = Path.project(uninstall).raw;
|
|
9
|
+
/** Bind the canonical Schema lifecycle syscalls to one caller-scoped value-call capability. */
|
|
10
|
+
export function createSchema(call, limits) {
|
|
11
|
+
if (typeof call !== 'function')
|
|
12
|
+
throw new TypeError('Schema call capability is invalid.');
|
|
13
|
+
const admittedLimits = admitLimits(limits);
|
|
14
|
+
return Object.freeze({
|
|
15
|
+
async install(request, options) {
|
|
16
|
+
const output = value(await call(invocation(INSTALL_PATH, request), options));
|
|
17
|
+
return acceptOutput(installOutput, output);
|
|
18
|
+
},
|
|
19
|
+
async uninstall(request, options) {
|
|
20
|
+
const output = value(await call(invocation(UNINSTALL_PATH, request), options));
|
|
21
|
+
return acceptOutput(uninstallOutput, output);
|
|
22
|
+
},
|
|
23
|
+
async introspect(request, options) {
|
|
24
|
+
return inspect(call, admittedLimits, request, options);
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function value(result) {
|
|
29
|
+
if (result.kind !== 'value')
|
|
30
|
+
throw new TypeError('Schema syscall returned a non-value result.');
|
|
31
|
+
return result.value;
|
|
32
|
+
}
|
|
33
|
+
function admitLimits(input) {
|
|
34
|
+
if (input === null ||
|
|
35
|
+
typeof input !== 'object' ||
|
|
36
|
+
!Number.isSafeInteger(input.maximumPublicationBytes) ||
|
|
37
|
+
input.maximumPublicationBytes < 1 ||
|
|
38
|
+
!Number.isSafeInteger(input.maximumBundleBytes) ||
|
|
39
|
+
input.maximumBundleBytes < 1) {
|
|
40
|
+
throw new TypeError('Schema introspection limits are invalid.');
|
|
41
|
+
}
|
|
42
|
+
return Object.freeze({ ...input });
|
|
43
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { IssuerId } from '@astrale-os/kernel-core/auth';
|
|
2
|
+
import type { ReadyInstallation } from '../schema/index.js';
|
|
3
|
+
import type { SessionControlOptions } from './context/index.js';
|
|
4
|
+
import type { CallableReference, InputOfReference, OutputOfReference } from './reference.js';
|
|
5
|
+
import type { SessionRequestOptions } from './routing/index.js';
|
|
6
|
+
import type { ViewCatalog } from './views/index.js';
|
|
7
|
+
import { type AuthApi } from '../auth/index.js';
|
|
8
|
+
import { type Binary, type Call, type Input, type Result, type Stream } from '../client/index.js';
|
|
9
|
+
import { type GraphApi } from '../graph/index.js';
|
|
10
|
+
/** Exact live Session surface captured by one credential-bound Kernel view. */
|
|
11
|
+
export interface BoundSessionSource {
|
|
12
|
+
readonly kernel: IssuerId;
|
|
13
|
+
dispatch(call: Call, options?: SessionRequestOptions): Promise<Result>;
|
|
14
|
+
call(call: Call, options?: SessionRequestOptions): Promise<Input>;
|
|
15
|
+
invoke<const Reference extends CallableReference>(reference: Reference, input: InputOfReference<Reference>, options?: SessionRequestOptions): Promise<OutputOfReference<Reference>>;
|
|
16
|
+
stream(call: Call, options?: SessionRequestOptions): Promise<Stream>;
|
|
17
|
+
binary(call: Call, options?: SessionRequestOptions): Promise<Binary>;
|
|
18
|
+
installation(origin: string, options?: SessionControlOptions): Promise<ReadyInstallation>;
|
|
19
|
+
viewsFor(target: Parameters<import('./session.js').ClientSession['viewsFor']>[0], options?: SessionControlOptions): Promise<ViewCatalog>;
|
|
20
|
+
}
|
|
21
|
+
export interface BoundSessionControls {
|
|
22
|
+
readonly signal: AbortSignal;
|
|
23
|
+
/** Absolute Unix time in milliseconds. */
|
|
24
|
+
readonly deadline: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Credential-bound Kernel operations over one caller-owned ClientSession.
|
|
28
|
+
*
|
|
29
|
+
* The view owns no credential, transport, route cache, or lifecycle. Its source Session owns all of
|
|
30
|
+
* those concerns and closing that Session invalidates every operation exposed here.
|
|
31
|
+
*/
|
|
32
|
+
export interface BoundClientSession extends GraphApi {
|
|
33
|
+
readonly kernel: IssuerId;
|
|
34
|
+
readonly auth: AuthApi;
|
|
35
|
+
dispatch(call: Call, options?: SessionRequestOptions): Promise<Result>;
|
|
36
|
+
call(call: Call, options?: SessionRequestOptions): Promise<Input>;
|
|
37
|
+
invoke<const Reference extends CallableReference>(reference: Reference, input: InputOfReference<Reference>, options?: SessionRequestOptions): Promise<OutputOfReference<Reference>>;
|
|
38
|
+
stream(call: Call, options?: SessionRequestOptions): Promise<Stream>;
|
|
39
|
+
binary(call: Call, options?: SessionRequestOptions): Promise<Binary>;
|
|
40
|
+
installation(origin: string, options?: SessionControlOptions): Promise<ReadyInstallation>;
|
|
41
|
+
viewsFor: BoundSessionSource['viewsFor'];
|
|
42
|
+
}
|
|
43
|
+
/** Capture one Session into the ordinary graph, auth, and invocation Kernel journey. */
|
|
44
|
+
export declare function bindSession(source: BoundSessionSource, controls?: BoundSessionControls): BoundClientSession;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { createAuth } from '../auth/index.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 callSource = capture(source, 'call');
|
|
11
|
+
const invokeSource = capture(source, 'invoke');
|
|
12
|
+
const streamSource = capture(source, 'stream');
|
|
13
|
+
const binarySource = capture(source, 'binary');
|
|
14
|
+
const installationSource = capture(source, 'installation');
|
|
15
|
+
const viewsForSource = capture(source, 'viewsFor');
|
|
16
|
+
const dispatch = (input, options) => dispatchSource(input, requestOptions(options, admittedControls));
|
|
17
|
+
const call = (input, options) => callSource(input, requestOptions(options, admittedControls));
|
|
18
|
+
const invoke = (reference, input, options) => invokeSource(reference, input, requestOptions(options, admittedControls));
|
|
19
|
+
const stream = (input, options) => streamSource(input, requestOptions(options, admittedControls));
|
|
20
|
+
const binary = (input, options) => binarySource(input, requestOptions(options, admittedControls));
|
|
21
|
+
const installation = (origin, options) => installationSource(origin, controlOptions(options, admittedControls));
|
|
22
|
+
const viewsFor = (target, options) => viewsForSource(target, controlOptions(options, admittedControls));
|
|
23
|
+
const graph = createGraph(call);
|
|
24
|
+
const auth = createAuth((target, input, options) => call(createCall(target, input), options));
|
|
25
|
+
return Object.freeze({
|
|
26
|
+
...graph,
|
|
27
|
+
kernel: source.kernel,
|
|
28
|
+
auth,
|
|
29
|
+
dispatch,
|
|
30
|
+
call,
|
|
31
|
+
invoke,
|
|
32
|
+
stream,
|
|
33
|
+
binary,
|
|
34
|
+
installation,
|
|
35
|
+
viewsFor,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function admitControls(input) {
|
|
39
|
+
if (input === undefined)
|
|
40
|
+
return undefined;
|
|
41
|
+
if (input === null ||
|
|
42
|
+
typeof input !== 'object' ||
|
|
43
|
+
!(input.signal instanceof AbortSignal) ||
|
|
44
|
+
!Number.isFinite(input.deadline)) {
|
|
45
|
+
invalid();
|
|
46
|
+
}
|
|
47
|
+
return Object.freeze({ signal: input.signal, deadline: input.deadline });
|
|
48
|
+
}
|
|
49
|
+
function requestOptions(options, controls) {
|
|
50
|
+
return mergeOptions(options, controls);
|
|
51
|
+
}
|
|
52
|
+
function controlOptions(options, controls) {
|
|
53
|
+
return mergeOptions(options, controls);
|
|
54
|
+
}
|
|
55
|
+
function mergeOptions(options, controls) {
|
|
56
|
+
if (controls === undefined)
|
|
57
|
+
return options;
|
|
58
|
+
if (options?.signal !== undefined && options.signal !== controls.signal) {
|
|
59
|
+
throw new TypeError('Bound ClientSession cancellation cannot be replaced.');
|
|
60
|
+
}
|
|
61
|
+
if (controls.signal.aborted)
|
|
62
|
+
throw controls.signal.reason ?? new Error('Invocation cancelled.');
|
|
63
|
+
const remaining = Math.max(1, Math.ceil(controls.deadline - Date.now()));
|
|
64
|
+
const timeoutMs = options?.timeoutMs === undefined ? remaining : Math.min(options.timeoutMs, remaining);
|
|
65
|
+
return Object.freeze({ ...options, signal: controls.signal, timeoutMs });
|
|
66
|
+
}
|
|
67
|
+
function capture(source, key) {
|
|
68
|
+
const value = source[key];
|
|
69
|
+
if (typeof value !== 'function')
|
|
70
|
+
invalid();
|
|
71
|
+
return value.bind(source);
|
|
72
|
+
}
|
|
73
|
+
function invalid() {
|
|
74
|
+
throw new TypeError('Bound ClientSession source is invalid.');
|
|
75
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
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
|
-
export { admitPolicy, allowEndpoint,
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
4
|
+
export { admitKernel, admitPolicy, allowEndpoint, kernelInvocationEndpoint, type SessionPolicy, } from './policy.js';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
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
|
-
export { admitPolicy, allowEndpoint,
|
|
5
|
-
//# sourceMappingURL=index.js.map
|
|
4
|
+
export { admitKernel, admitPolicy, allowEndpoint, kernelInvocationEndpoint, } from './policy.js';
|
|
@@ -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
|
|
@@ -17,4 +17,3 @@ export declare function sessionTransportOptions(operation: SessionOperation, ide
|
|
|
17
17
|
/** Settle independently of a caller capability that ignores its supplied AbortSignal. */
|
|
18
18
|
export declare function runSessionOperation<Result>(operation: SessionOperation, task: (signal: AbortSignal) => Result | PromiseLike<Result>): Promise<Result>;
|
|
19
19
|
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
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { type IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
1
2
|
export interface SessionPolicy {
|
|
2
3
|
readonly maximumRouteAgeMs: number;
|
|
3
4
|
readonly allowEndpoint?: (url: string) => boolean;
|
|
4
5
|
readonly allowInsecureHttp?: boolean;
|
|
5
6
|
}
|
|
6
7
|
export declare function admitPolicy(input: SessionPolicy): Readonly<SessionPolicy>;
|
|
7
|
-
export declare function
|
|
8
|
+
export declare function admitKernel(input: string, insecure: boolean): IssuerId;
|
|
9
|
+
export declare function kernelInvocationEndpoint(input: IssuerId): string;
|
|
8
10
|
export declare function websocketEndpoint(input: string, insecure: boolean): string;
|
|
9
11
|
export declare function allowEndpoint(url: string, policy: Readonly<SessionPolicy>): void;
|
|
10
|
-
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { accept as acceptIssuer } from '@astrale-os/kernel-core/auth/issuer';
|
|
1
2
|
import { ClientError } from '../../errors/index.js';
|
|
2
3
|
import { positive } from './limits.js';
|
|
3
4
|
export function admitPolicy(input) {
|
|
@@ -16,21 +17,27 @@ export function admitPolicy(input) {
|
|
|
16
17
|
...(input.allowInsecureHttp === true ? { allowInsecureHttp: true } : {}),
|
|
17
18
|
});
|
|
18
19
|
}
|
|
19
|
-
export function
|
|
20
|
+
export function admitKernel(input, insecure) {
|
|
20
21
|
let url;
|
|
22
|
+
let admitted;
|
|
21
23
|
try {
|
|
22
|
-
|
|
24
|
+
admitted = acceptIssuer(input);
|
|
25
|
+
url = new URL(admitted);
|
|
23
26
|
}
|
|
24
27
|
catch (cause) {
|
|
25
|
-
throw new TypeError('Session
|
|
28
|
+
throw new TypeError('Session Kernel issuer is invalid.', { cause });
|
|
26
29
|
}
|
|
27
30
|
if (url.username !== '' ||
|
|
28
31
|
url.password !== '' ||
|
|
29
32
|
url.hash !== '' ||
|
|
33
|
+
url.search !== '' ||
|
|
30
34
|
(url.protocol !== 'https:' && !(insecure && url.protocol === 'http:'))) {
|
|
31
|
-
throw new TypeError('Session
|
|
35
|
+
throw new TypeError('Session Kernel issuer is invalid.');
|
|
32
36
|
}
|
|
33
|
-
return
|
|
37
|
+
return admitted;
|
|
38
|
+
}
|
|
39
|
+
export function kernelInvocationEndpoint(input) {
|
|
40
|
+
return `${input}/invoke`;
|
|
34
41
|
}
|
|
35
42
|
export function websocketEndpoint(input, insecure) {
|
|
36
43
|
let url;
|
|
@@ -60,4 +67,3 @@ export function allowEndpoint(url, policy) {
|
|
|
60
67
|
throw new ClientError('Endpoint is denied by Session policy.');
|
|
61
68
|
}
|
|
62
69
|
}
|
|
63
|
-
//# sourceMappingURL=policy.js.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { decodeBundleValue } from '@astrale-os/kernel-protocol/publication/bundle';
|
|
2
2
|
import { ClientError } from '../../errors/index.js';
|
|
3
|
-
import { allowEndpoint
|
|
3
|
+
import { allowEndpoint } from '../context/index.js';
|
|
4
4
|
import { boundedResponse, requireExactResponse } from './publication.js';
|
|
5
|
+
import { runAcquisition } from './transport.js';
|
|
5
6
|
export class BundleDiscovery {
|
|
6
7
|
options;
|
|
7
8
|
bundles = new Map();
|
|
@@ -22,34 +23,33 @@ export class BundleDiscovery {
|
|
|
22
23
|
this.bundles.clear();
|
|
23
24
|
}
|
|
24
25
|
async fetch(publication, operation) {
|
|
25
|
-
if (publication.schema.bundle.size > this.options.maximumBytes) {
|
|
26
|
+
if (publication.schema.bundle.ref.size > this.options.maximumBytes) {
|
|
26
27
|
throw new ClientError('Bundle artifact exceeds its byte limit.');
|
|
27
28
|
}
|
|
28
29
|
const href = publication.schema.bundle.href;
|
|
29
30
|
allowEndpoint(href, this.options.policy);
|
|
30
|
-
const response = await
|
|
31
|
-
headers: { accept: publication.schema.bundle.mediaType },
|
|
31
|
+
const response = await runAcquisition(operation, 'bundle', 'unknown', 'Kernel bundle could not be retrieved.', (signal) => this.options.fetch(href, {
|
|
32
|
+
headers: { accept: publication.schema.bundle.ref.mediaType },
|
|
32
33
|
redirect: 'manual',
|
|
33
34
|
signal,
|
|
34
35
|
}));
|
|
35
36
|
requireExactResponse(response, href, 'Bundle retrieval');
|
|
36
37
|
if (!response.ok)
|
|
37
38
|
throw new ClientError(`Bundle retrieval returned HTTP ${response.status}.`);
|
|
38
|
-
if (response.headers.get('content-type') !== publication.schema.bundle.mediaType) {
|
|
39
|
+
if (response.headers.get('content-type') !== publication.schema.bundle.ref.mediaType) {
|
|
39
40
|
throw new ClientError('Bundle artifact media type differs from its descriptor.');
|
|
40
41
|
}
|
|
41
42
|
const etag = response.headers.get('etag');
|
|
42
|
-
if (etag !== null && etag !== `"${publication.schema.bundle.digest}"`) {
|
|
43
|
+
if (etag !== null && etag !== `"${publication.schema.bundle.ref.digest}"`) {
|
|
43
44
|
throw new ClientError('Bundle response ETag differs from its descriptor.');
|
|
44
45
|
}
|
|
45
|
-
const bytes = await
|
|
46
|
-
if (bytes.byteLength !== publication.schema.bundle.size) {
|
|
46
|
+
const bytes = await runAcquisition(operation, 'bundle', 'receive', 'Kernel bundle response could not be read.', (signal) => boundedResponse(response, publication.schema.bundle.ref.size, signal));
|
|
47
|
+
if (bytes.byteLength !== publication.schema.bundle.ref.size) {
|
|
47
48
|
throw new ClientError('Bundle artifact size differs from its descriptor.');
|
|
48
49
|
}
|
|
49
|
-
return
|
|
50
|
+
return decodeBundleValue(publication, bytes);
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
function bundleKey(publication) {
|
|
53
54
|
return `${new URL(publication.schema.bundle.href).origin}\u0000${publication.etag}`;
|
|
54
55
|
}
|
|
55
|
-
//# sourceMappingURL=bundle.js.map
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { publication } from '@astrale-os/kernel-protocol';
|
|
1
|
+
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
3
2
|
import type { SessionOperation, SessionPolicy } from '../context/index.js';
|
|
4
3
|
import type { BundleDiscovery } from './bundle.js';
|
|
5
4
|
import type { PublicationDiscovery } from './publication.js';
|
|
6
5
|
import type { SessionSnapshot } from './snapshot.js';
|
|
7
|
-
export interface DiscoveredSource {
|
|
8
|
-
readonly publication: publication.Publication;
|
|
9
|
-
readonly bundle: bundle.Bundle;
|
|
10
|
-
}
|
|
11
6
|
export declare class SessionDiscovery {
|
|
12
|
-
readonly
|
|
7
|
+
readonly kernel: IssuerId;
|
|
13
8
|
private readonly policy;
|
|
14
9
|
private readonly publications;
|
|
15
10
|
private readonly bundles;
|
|
@@ -17,11 +12,8 @@ export declare class SessionDiscovery {
|
|
|
17
12
|
private readonly acquisitionOperation;
|
|
18
13
|
private retained?;
|
|
19
14
|
private flight?;
|
|
20
|
-
constructor(
|
|
15
|
+
constructor(kernel: IssuerId, policy: Readonly<SessionPolicy>, publications: PublicationDiscovery, bundles: BundleDiscovery, requireOpen: () => void, acquisitionOperation: () => SessionOperation);
|
|
21
16
|
snapshot(operation: SessionOperation): Promise<SessionSnapshot>;
|
|
22
|
-
discover(url: string, operation: SessionOperation): Promise<DiscoveredSource>;
|
|
23
|
-
invalidate(url: string): void;
|
|
24
17
|
clear(): void;
|
|
25
18
|
private acquireSnapshot;
|
|
26
19
|
}
|
|
27
|
-
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -2,7 +2,7 @@ import { runSessionOperation } from '../context/index.js';
|
|
|
2
2
|
import { rootViewCatalog } from '../views/index.js';
|
|
3
3
|
import { createSessionSnapshot } from './snapshot.js';
|
|
4
4
|
export class SessionDiscovery {
|
|
5
|
-
|
|
5
|
+
kernel;
|
|
6
6
|
policy;
|
|
7
7
|
publications;
|
|
8
8
|
bundles;
|
|
@@ -10,8 +10,8 @@ export class SessionDiscovery {
|
|
|
10
10
|
acquisitionOperation;
|
|
11
11
|
retained;
|
|
12
12
|
flight;
|
|
13
|
-
constructor(
|
|
14
|
-
this.
|
|
13
|
+
constructor(kernel, policy, publications, bundles, requireOpen, acquisitionOperation) {
|
|
14
|
+
this.kernel = kernel;
|
|
15
15
|
this.policy = policy;
|
|
16
16
|
this.publications = publications;
|
|
17
17
|
this.bundles = bundles;
|
|
@@ -33,27 +33,14 @@ export class SessionDiscovery {
|
|
|
33
33
|
.catch(() => undefined);
|
|
34
34
|
return runSessionOperation(operation, () => flight);
|
|
35
35
|
}
|
|
36
|
-
async discover(url, operation) {
|
|
37
|
-
this.requireOpen();
|
|
38
|
-
const publication = await this.publications.get(url, operation);
|
|
39
|
-
const artifact = await this.bundles.get(publication, operation);
|
|
40
|
-
this.requireOpen();
|
|
41
|
-
return Object.freeze({ publication, bundle: artifact });
|
|
42
|
-
}
|
|
43
|
-
invalidate(url) {
|
|
44
|
-
this.publications.invalidate(url);
|
|
45
|
-
this.bundles.clear();
|
|
46
|
-
if (new URL(url).origin === new URL(this.url).origin)
|
|
47
|
-
this.retained = undefined;
|
|
48
|
-
}
|
|
49
36
|
clear() {
|
|
50
37
|
this.publications.invalidate();
|
|
51
38
|
this.bundles.clear();
|
|
52
39
|
this.retained = undefined;
|
|
53
40
|
}
|
|
54
41
|
async acquireSnapshot(operation) {
|
|
55
|
-
const previous = this.publications.current(
|
|
56
|
-
const publication = await this.publications.revalidate(
|
|
42
|
+
const previous = this.publications.current();
|
|
43
|
+
const publication = await this.publications.revalidate(operation);
|
|
57
44
|
if (previous !== undefined && previous.etag !== publication.etag)
|
|
58
45
|
this.bundles.clear();
|
|
59
46
|
const artifact = await this.bundles.get(publication, operation);
|
|
@@ -61,9 +48,8 @@ export class SessionDiscovery {
|
|
|
61
48
|
if (this.retained?.publication.etag === publication.etag)
|
|
62
49
|
return this.retained;
|
|
63
50
|
const views = rootViewCatalog(publication, artifact, this.policy);
|
|
64
|
-
const snapshot = createSessionSnapshot(this.
|
|
51
|
+
const snapshot = createSessionSnapshot(this.kernel, publication, artifact, views);
|
|
65
52
|
this.retained = snapshot;
|
|
66
53
|
return snapshot;
|
|
67
54
|
}
|
|
68
55
|
}
|
|
69
|
-
//# sourceMappingURL=discovery.js.map
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
+
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
1
2
|
import type { Fetch } from '../../transport/http/index.js';
|
|
2
3
|
import type { SessionOperation, SessionPolicy } from '../context/index.js';
|
|
3
|
-
import type { DiscoveredSource } from './discovery.js';
|
|
4
4
|
import type { SessionSnapshot } from './snapshot.js';
|
|
5
|
-
export type { DiscoveredSource } from './discovery.js';
|
|
6
5
|
export type { SessionSnapshot } from './snapshot.js';
|
|
7
6
|
export interface SessionDiscovery {
|
|
8
|
-
readonly
|
|
7
|
+
readonly kernel: IssuerId;
|
|
9
8
|
snapshot(operation: SessionOperation): Promise<SessionSnapshot>;
|
|
10
|
-
discover(url: string, operation: SessionOperation): Promise<DiscoveredSource>;
|
|
11
|
-
invalidate(url: string): void;
|
|
12
9
|
clear(): void;
|
|
13
10
|
}
|
|
14
11
|
export interface SessionDiscoveryOptions {
|
|
15
|
-
readonly
|
|
12
|
+
readonly kernel: IssuerId;
|
|
16
13
|
readonly fetch: Fetch;
|
|
17
14
|
readonly policy: Readonly<SessionPolicy>;
|
|
18
15
|
readonly maximumPublicationBytes: number;
|
|
@@ -21,4 +18,3 @@ export interface SessionDiscoveryOptions {
|
|
|
21
18
|
readonly acquisitionOperation: () => SessionOperation;
|
|
22
19
|
}
|
|
23
20
|
export declare function createSessionDiscovery(options: SessionDiscoveryOptions): SessionDiscovery;
|
|
24
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -2,7 +2,8 @@ import { BundleDiscovery } from './bundle.js';
|
|
|
2
2
|
import { SessionDiscovery as SessionDiscoveryImplementation } from './discovery.js';
|
|
3
3
|
import { PublicationDiscovery } from './publication.js';
|
|
4
4
|
export function createSessionDiscovery(options) {
|
|
5
|
-
return new SessionDiscoveryImplementation(options.
|
|
5
|
+
return new SessionDiscoveryImplementation(options.kernel, options.policy, new PublicationDiscovery({
|
|
6
|
+
kernel: options.kernel,
|
|
6
7
|
fetch: options.fetch,
|
|
7
8
|
policy: options.policy,
|
|
8
9
|
maximumBytes: options.maximumPublicationBytes,
|
|
@@ -12,4 +13,3 @@ export function createSessionDiscovery(options) {
|
|
|
12
13
|
maximumBytes: options.maximumBundleBytes,
|
|
13
14
|
}), options.requireOpen, options.acquisitionOperation);
|
|
14
15
|
}
|
|
15
|
-
//# sourceMappingURL=index.js.map
|