@astrale-os/kernel-server 0.4.17 → 0.5.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/capture.d.ts +2 -0
- package/dist/capture.js +9 -0
- package/dist/cors/cors.d.ts +21 -0
- package/dist/cors/cors.js +135 -0
- package/dist/cors/index.d.ts +2 -0
- package/dist/cors/index.js +1 -0
- package/dist/cors/types.d.ts +11 -0
- package/dist/cors/types.js +1 -0
- package/dist/errors/availability.d.ts +10 -0
- package/dist/errors/availability.js +14 -0
- package/dist/errors/classify.d.ts +3 -0
- package/dist/errors/classify.js +41 -0
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.js +4 -0
- package/dist/errors/request-body.d.ts +7 -0
- package/dist/errors/request-body.js +14 -0
- package/dist/errors/response-body.d.ts +4 -0
- package/dist/errors/response-body.js +8 -0
- package/dist/index.d.ts +5 -12
- package/dist/index.js +4 -19
- package/dist/invocation/context.d.ts +6 -0
- package/dist/invocation/context.js +60 -0
- package/dist/invocation/identity.d.ts +9 -0
- package/dist/invocation/identity.js +11 -0
- package/dist/invocation/index.d.ts +4 -3
- package/dist/invocation/index.js +3 -3
- package/dist/invocation/publication-route.d.ts +13 -0
- package/dist/invocation/publication-route.js +44 -0
- package/dist/invocation/types.d.ts +62 -0
- package/dist/invocation/types.js +1 -0
- package/dist/issuer/exchange.d.ts +12 -0
- package/dist/issuer/exchange.js +136 -0
- package/dist/issuer/index.d.ts +3 -0
- package/dist/issuer/index.js +1 -0
- package/dist/issuer/routes.d.ts +13 -0
- package/dist/issuer/routes.js +149 -0
- package/dist/issuer/types.d.ts +11 -0
- package/dist/issuer/types.js +1 -0
- package/dist/lifecycle/active.d.ts +39 -0
- package/dist/lifecycle/active.js +199 -0
- package/dist/lifecycle/index.d.ts +1 -0
- package/dist/lifecycle/index.js +1 -0
- package/dist/publication/delivery/handler.d.ts +9 -0
- package/dist/publication/delivery/handler.js +127 -0
- package/dist/publication/delivery/index.d.ts +2 -0
- package/dist/publication/delivery/index.js +1 -0
- package/dist/publication/delivery/types.d.ts +11 -0
- package/dist/publication/delivery/types.js +1 -0
- package/dist/publication/index.d.ts +3 -0
- package/dist/publication/index.js +2 -0
- package/dist/publication/snapshot.d.ts +16 -0
- package/dist/publication/snapshot.js +37 -0
- package/dist/publication/table.d.ts +4 -0
- package/dist/publication/table.js +16 -0
- package/dist/publication/types.d.ts +22 -0
- package/dist/publication/types.js +1 -0
- package/dist/routes/index.d.ts +1 -0
- package/dist/routes/index.js +1 -0
- package/dist/routes/routes.d.ts +25 -0
- package/dist/routes/routes.js +448 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.js +266 -0
- package/dist/transport/body.d.ts +4 -0
- package/dist/transport/body.js +50 -0
- package/dist/transport/codecs.d.ts +4 -0
- package/dist/transport/codecs.js +5 -0
- package/dist/transport/credential.d.ts +10 -0
- package/dist/transport/credential.js +28 -0
- package/dist/transport/http/handler.d.ts +17 -0
- package/dist/transport/http/handler.js +180 -0
- package/dist/transport/http/index.d.ts +2 -0
- package/dist/transport/http/index.js +2 -0
- package/dist/transport/http/render.d.ts +31 -0
- package/dist/transport/http/render.js +288 -0
- package/dist/transport/index.d.ts +9 -0
- package/dist/transport/index.js +8 -0
- package/dist/transport/router.d.ts +4 -0
- package/dist/transport/router.js +4 -0
- package/dist/transport/stream-error.d.ts +3 -0
- package/dist/transport/stream-error.js +13 -0
- package/dist/transport/types.d.ts +28 -0
- package/dist/transport/types.js +1 -0
- package/dist/transport/websocket/index.d.ts +2 -0
- package/dist/transport/websocket/index.js +2 -0
- package/dist/transport/websocket/session.d.ts +20 -0
- package/dist/transport/websocket/session.js +335 -0
- package/dist/transport/websocket/upgrade.d.ts +20 -0
- package/dist/transport/websocket/upgrade.js +46 -0
- package/dist/types.d.ts +65 -0
- package/dist/types.js +1 -0
- package/package.json +24 -14
- package/dist/app/create.d.ts +0 -48
- package/dist/app/create.d.ts.map +0 -1
- package/dist/app/create.js +0 -108
- package/dist/app/create.js.map +0 -1
- package/dist/app/index.d.ts +0 -4
- package/dist/app/index.d.ts.map +0 -1
- package/dist/app/index.js +0 -4
- package/dist/app/index.js.map +0 -1
- package/dist/app/multiplexed.d.ts +0 -53
- package/dist/app/multiplexed.d.ts.map +0 -1
- package/dist/app/multiplexed.js +0 -64
- package/dist/app/multiplexed.js.map +0 -1
- package/dist/app/ws-upgrade.d.ts +0 -34
- package/dist/app/ws-upgrade.d.ts.map +0 -1
- package/dist/app/ws-upgrade.js +0 -94
- package/dist/app/ws-upgrade.js.map +0 -1
- package/dist/capabilities/contract.d.ts +0 -8
- package/dist/capabilities/contract.d.ts.map +0 -1
- package/dist/capabilities/contract.js +0 -2
- package/dist/capabilities/contract.js.map +0 -1
- package/dist/capabilities/defer.d.ts +0 -4
- package/dist/capabilities/defer.d.ts.map +0 -1
- package/dist/capabilities/defer.js +0 -2
- package/dist/capabilities/defer.js.map +0 -1
- package/dist/capabilities/hono.d.ts +0 -8
- package/dist/capabilities/hono.d.ts.map +0 -1
- package/dist/capabilities/hono.js +0 -13
- package/dist/capabilities/hono.js.map +0 -1
- package/dist/capabilities/index.d.ts +0 -6
- package/dist/capabilities/index.d.ts.map +0 -1
- package/dist/capabilities/index.js +0 -3
- package/dist/capabilities/index.js.map +0 -1
- package/dist/capabilities/lifecycle.d.ts +0 -17
- package/dist/capabilities/lifecycle.d.ts.map +0 -1
- package/dist/capabilities/lifecycle.js +0 -37
- package/dist/capabilities/lifecycle.js.map +0 -1
- package/dist/capabilities/sleep.d.ts +0 -4
- package/dist/capabilities/sleep.d.ts.map +0 -1
- package/dist/capabilities/sleep.js +0 -8
- package/dist/capabilities/sleep.js.map +0 -1
- package/dist/cors.d.ts +0 -21
- package/dist/cors.d.ts.map +0 -1
- package/dist/cors.js +0 -17
- package/dist/cors.js.map +0 -1
- package/dist/envelope/batch.d.ts +0 -13
- package/dist/envelope/batch.d.ts.map +0 -1
- package/dist/envelope/batch.js +0 -96
- package/dist/envelope/batch.js.map +0 -1
- package/dist/envelope/codec.d.ts +0 -26
- package/dist/envelope/codec.d.ts.map +0 -1
- package/dist/envelope/codec.js +0 -52
- package/dist/envelope/codec.js.map +0 -1
- package/dist/envelope/credential.d.ts +0 -20
- package/dist/envelope/credential.d.ts.map +0 -1
- package/dist/envelope/credential.js +0 -32
- package/dist/envelope/credential.js.map +0 -1
- package/dist/envelope/http.d.ts +0 -31
- package/dist/envelope/http.d.ts.map +0 -1
- package/dist/envelope/http.js +0 -132
- package/dist/envelope/http.js.map +0 -1
- package/dist/envelope/sse.d.ts +0 -11
- package/dist/envelope/sse.d.ts.map +0 -1
- package/dist/envelope/sse.js +0 -73
- package/dist/envelope/sse.js.map +0 -1
- package/dist/envelope/ws.d.ts +0 -35
- package/dist/envelope/ws.d.ts.map +0 -1
- package/dist/envelope/ws.js +0 -142
- package/dist/envelope/ws.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/invocation/dispatch.d.ts +0 -32
- package/dist/invocation/dispatch.d.ts.map +0 -1
- package/dist/invocation/dispatch.js +0 -68
- package/dist/invocation/dispatch.js.map +0 -1
- package/dist/invocation/dispatcher.d.ts +0 -19
- package/dist/invocation/dispatcher.d.ts.map +0 -1
- package/dist/invocation/dispatcher.js +0 -9
- package/dist/invocation/dispatcher.js.map +0 -1
- package/dist/invocation/index.d.ts.map +0 -1
- package/dist/invocation/index.js.map +0 -1
- package/dist/jwks/discovery.d.ts +0 -40
- package/dist/jwks/discovery.d.ts.map +0 -1
- package/dist/jwks/discovery.js +0 -113
- package/dist/jwks/discovery.js.map +0 -1
- package/dist/jwks/index.d.ts +0 -3
- package/dist/jwks/index.d.ts.map +0 -1
- package/dist/jwks/index.js +0 -3
- package/dist/jwks/index.js.map +0 -1
- package/dist/jwks/issuers.d.ts +0 -47
- package/dist/jwks/issuers.d.ts.map +0 -1
- package/dist/jwks/issuers.js +0 -76
- package/dist/jwks/issuers.js.map +0 -1
- package/dist/jwks/keys.d.ts +0 -44
- package/dist/jwks/keys.d.ts.map +0 -1
- package/dist/jwks/keys.js +0 -56
- package/dist/jwks/keys.js.map +0 -1
- package/dist/plan/host-params.d.ts +0 -13
- package/dist/plan/host-params.d.ts.map +0 -1
- package/dist/plan/host-params.js +0 -23
- package/dist/plan/host-params.js.map +0 -1
- package/dist/plan/host.d.ts +0 -24
- package/dist/plan/host.d.ts.map +0 -1
- package/dist/plan/host.js +0 -24
- package/dist/plan/host.js.map +0 -1
- package/dist/plan/index.d.ts +0 -4
- package/dist/plan/index.d.ts.map +0 -1
- package/dist/plan/index.js +0 -4
- package/dist/plan/index.js.map +0 -1
- package/dist/plan/walk.d.ts +0 -51
- package/dist/plan/walk.d.ts.map +0 -1
- package/dist/plan/walk.js +0 -110
- package/dist/plan/walk.js.map +0 -1
- package/dist/render/binary.d.ts +0 -19
- package/dist/render/binary.d.ts.map +0 -1
- package/dist/render/binary.js +0 -33
- package/dist/render/binary.js.map +0 -1
- package/dist/render/body.d.ts +0 -10
- package/dist/render/body.d.ts.map +0 -1
- package/dist/render/body.js +0 -17
- package/dist/render/body.js.map +0 -1
- package/dist/render/index.d.ts +0 -3
- package/dist/render/index.d.ts.map +0 -1
- package/dist/render/index.js +0 -3
- package/dist/render/index.js.map +0 -1
- package/dist/routed/credential.d.ts +0 -10
- package/dist/routed/credential.d.ts.map +0 -1
- package/dist/routed/credential.js +0 -55
- package/dist/routed/credential.js.map +0 -1
- package/dist/routed/handler.d.ts +0 -38
- package/dist/routed/handler.d.ts.map +0 -1
- package/dist/routed/handler.js +0 -123
- package/dist/routed/handler.js.map +0 -1
- package/dist/routed/index.d.ts +0 -5
- package/dist/routed/index.d.ts.map +0 -1
- package/dist/routed/index.js +0 -5
- package/dist/routed/index.js.map +0 -1
- package/dist/routed/params.d.ts +0 -40
- package/dist/routed/params.d.ts.map +0 -1
- package/dist/routed/params.js +0 -146
- package/dist/routed/params.js.map +0 -1
- package/dist/routed/stream.d.ts +0 -21
- package/dist/routed/stream.d.ts.map +0 -1
- package/dist/routed/stream.js +0 -69
- package/dist/routed/stream.js.map +0 -1
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import * as codecs from '@astrale-os/kernel-protocol/codecs';
|
|
2
|
+
import * as protocolPublication from '@astrale-os/kernel-protocol/publication';
|
|
3
|
+
import { DeliveryUnavailableError } from '../../errors/index.js';
|
|
4
|
+
import { RequestBodyInvalidError, RequestBodyTooLargeError } from '../../errors/index.js';
|
|
5
|
+
import { readBoundedBody } from '../../transport/index.js';
|
|
6
|
+
const delivery = protocolPublication.delivery;
|
|
7
|
+
/** Serve one delivery request against the exact Publication snapshot that selected its URL. */
|
|
8
|
+
export async function handleDelivery(request, snapshot, provider, active, limits, cors) {
|
|
9
|
+
if (request.method !== 'POST') {
|
|
10
|
+
return response({ error: 'Delivery requires POST.' }, 405, cors);
|
|
11
|
+
}
|
|
12
|
+
if (provider === undefined) {
|
|
13
|
+
return response({ error: 'Delivery is unavailable.' }, 503, cors);
|
|
14
|
+
}
|
|
15
|
+
const advertised = snapshot.publication.delivery;
|
|
16
|
+
if (advertised === undefined) {
|
|
17
|
+
return response({ error: 'Delivery is unavailable.' }, 404, cors);
|
|
18
|
+
}
|
|
19
|
+
const operation = active.begin(limits.invocationTimeoutMs, request.signal);
|
|
20
|
+
if (operation === undefined)
|
|
21
|
+
return response({ error: 'Server is draining.' }, 503, cors);
|
|
22
|
+
try {
|
|
23
|
+
const authorization = request.headers.get('authorization');
|
|
24
|
+
const token = bearer(authorization);
|
|
25
|
+
if (advertised.authentication.kind === 'bearer' && token === undefined) {
|
|
26
|
+
return response({ error: 'Bearer authentication is required.' }, 401, cors);
|
|
27
|
+
}
|
|
28
|
+
if (advertised.authentication.kind === 'public' && authorization !== null) {
|
|
29
|
+
return response({ error: 'This delivery endpoint is public.' }, 400, cors);
|
|
30
|
+
}
|
|
31
|
+
let body;
|
|
32
|
+
try {
|
|
33
|
+
body = await readBoundedBody(request, limits.maximumDeliveryBytes, operation.signal);
|
|
34
|
+
}
|
|
35
|
+
catch (cause) {
|
|
36
|
+
if (cause instanceof RequestBodyTooLargeError) {
|
|
37
|
+
return response({ error: 'Delivery request is too large.' }, 413, cors);
|
|
38
|
+
}
|
|
39
|
+
if (cause instanceof RequestBodyInvalidError) {
|
|
40
|
+
return response({ error: 'Delivery request is invalid.' }, 400, cors);
|
|
41
|
+
}
|
|
42
|
+
if (operation.signal.aborted) {
|
|
43
|
+
return response({ error: 'Delivery request was cancelled.' }, 503, cors);
|
|
44
|
+
}
|
|
45
|
+
throw cause;
|
|
46
|
+
}
|
|
47
|
+
let decoded;
|
|
48
|
+
try {
|
|
49
|
+
decoded = codecs.json.decode(body);
|
|
50
|
+
}
|
|
51
|
+
catch (cause) {
|
|
52
|
+
if (cause instanceof codecs.DecodeError) {
|
|
53
|
+
return response({ error: 'Delivery request is invalid.' }, 400, cors);
|
|
54
|
+
}
|
|
55
|
+
throw cause;
|
|
56
|
+
}
|
|
57
|
+
let input;
|
|
58
|
+
try {
|
|
59
|
+
input = delivery.acceptRequest(decoded);
|
|
60
|
+
}
|
|
61
|
+
catch (cause) {
|
|
62
|
+
if (cause instanceof delivery.Error && cause.code === 'DELIVERY_REQUEST_INVALID') {
|
|
63
|
+
return response({ error: 'Delivery request is invalid.' }, 400, cors);
|
|
64
|
+
}
|
|
65
|
+
throw cause;
|
|
66
|
+
}
|
|
67
|
+
if (input.etag !== snapshot.publication.etag) {
|
|
68
|
+
return response({ error: 'Publication ETag differs from request.' }, 409, cors);
|
|
69
|
+
}
|
|
70
|
+
let candidate;
|
|
71
|
+
try {
|
|
72
|
+
candidate = await provider.create(input, {
|
|
73
|
+
...(token === undefined ? {} : { token: Object.freeze({ kind: 'bearer', token }) }),
|
|
74
|
+
signal: operation.signal,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
catch (cause) {
|
|
78
|
+
if (cause instanceof DeliveryUnavailableError) {
|
|
79
|
+
return response({ error: 'Delivery provider is unavailable.' }, 503, cors);
|
|
80
|
+
}
|
|
81
|
+
throw cause;
|
|
82
|
+
}
|
|
83
|
+
let created;
|
|
84
|
+
try {
|
|
85
|
+
created = delivery.accept(candidate);
|
|
86
|
+
}
|
|
87
|
+
catch (cause) {
|
|
88
|
+
if (cause instanceof delivery.Error) {
|
|
89
|
+
return response({ error: 'Delivery provider returned an invalid response.' }, 500, cors);
|
|
90
|
+
}
|
|
91
|
+
throw cause;
|
|
92
|
+
}
|
|
93
|
+
if (created.publication.etag !== snapshot.publication.etag) {
|
|
94
|
+
return response({ error: 'Delivery provider returned a different Publication.' }, 500, cors);
|
|
95
|
+
}
|
|
96
|
+
const encoded = codecs.json.encode(created);
|
|
97
|
+
if (encodedSize(encoded) > limits.maximumDeliveryBytes) {
|
|
98
|
+
return response({ error: 'Delivery response exceeds its serving limit.' }, 500, cors);
|
|
99
|
+
}
|
|
100
|
+
return new Response(encodedBody(encoded), {
|
|
101
|
+
headers: { ...cors, 'content-type': 'application/json' },
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
operation.settle();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function bearer(input) {
|
|
109
|
+
if (input === null)
|
|
110
|
+
return undefined;
|
|
111
|
+
return /^Bearer[ \t]+([^\s]+)$/iu.exec(input.trim())?.[1];
|
|
112
|
+
}
|
|
113
|
+
function response(body, status, cors) {
|
|
114
|
+
return new Response(encodedBody(codecs.json.encode(body)), {
|
|
115
|
+
status,
|
|
116
|
+
headers: { ...cors, 'content-type': 'application/json' },
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function encodedBody(input) {
|
|
120
|
+
return typeof input === 'string' ? input : toBody(input);
|
|
121
|
+
}
|
|
122
|
+
function encodedSize(input) {
|
|
123
|
+
return typeof input === 'string' ? new TextEncoder().encode(input).byteLength : input.byteLength;
|
|
124
|
+
}
|
|
125
|
+
function toBody(input) {
|
|
126
|
+
return input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength);
|
|
127
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { handleDelivery } from './handler.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as publication from '@astrale-os/kernel-protocol/publication';
|
|
2
|
+
export interface Context {
|
|
3
|
+
/** Omitted for a public endpoint; otherwise the exact admitted retrieval credential. */
|
|
4
|
+
readonly token?: publication.delivery.Token;
|
|
5
|
+
readonly signal: AbortSignal;
|
|
6
|
+
}
|
|
7
|
+
/** Provider-owned retrieval, construction, and attestation signing. */
|
|
8
|
+
export interface Provider {
|
|
9
|
+
/** Throw DeliveryUnavailableError only for an expected dependency outage. */
|
|
10
|
+
create(request: publication.delivery.Request, context: Context): Promise<publication.delivery.Delivery>;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { preparePublicationSnapshot, readPreparedPublicationSnapshot, type PreparedPublicationSnapshot, } from './snapshot.js';
|
|
2
|
+
export type { PublicationSnapshot, PublicationSnapshotInput, PublicationSource } from './types.js';
|
|
3
|
+
export * as delivery from './delivery/index.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Domain } from '@astrale-os/kernel-dsl/v1';
|
|
2
|
+
import type * as publication from '@astrale-os/kernel-protocol/publication';
|
|
3
|
+
import type * as routes from '@astrale-os/kernel-protocol/routes';
|
|
4
|
+
import type { PublicationSnapshot, PublicationSnapshotInput } from './types.js';
|
|
5
|
+
export interface PreparedPublicationSnapshot {
|
|
6
|
+
readonly snapshot: PublicationSnapshot;
|
|
7
|
+
readonly publication: publication.Publication;
|
|
8
|
+
readonly publicationBytes: Uint8Array;
|
|
9
|
+
readonly bundle: Uint8Array;
|
|
10
|
+
readonly table: routes.Table;
|
|
11
|
+
readonly domain: Domain;
|
|
12
|
+
}
|
|
13
|
+
/** Admit and detach one revision-coherent serving snapshot before publication. */
|
|
14
|
+
export declare function preparePublicationSnapshot(input: PublicationSnapshotInput): PublicationSnapshot;
|
|
15
|
+
/** Internal proof that a PublicationSource returned a Server-prepared snapshot without cloning it. */
|
|
16
|
+
export declare function readPreparedPublicationSnapshot(input: unknown): PreparedPublicationSnapshot | undefined;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { verifyBundleBytes } from '@astrale-os/kernel-protocol/publication/bundle-evidence';
|
|
2
|
+
import { accept as acceptPublication, encode as encodePublication, } from '@astrale-os/kernel-protocol/publication/publication';
|
|
3
|
+
import { admitTable } from './table.js';
|
|
4
|
+
const snapshots = new WeakMap();
|
|
5
|
+
/** Admit and detach one revision-coherent serving snapshot before publication. */
|
|
6
|
+
export function preparePublicationSnapshot(input) {
|
|
7
|
+
if (input === null || typeof input !== 'object' || !(input.bundle instanceof Uint8Array)) {
|
|
8
|
+
throw new TypeError('Publication snapshot input is invalid.');
|
|
9
|
+
}
|
|
10
|
+
const admittedPublication = acceptPublication(input.publication);
|
|
11
|
+
const bundleBytes = new Uint8Array(input.bundle);
|
|
12
|
+
verifyBundleBytes(admittedPublication, bundleBytes);
|
|
13
|
+
const domain = input.domain;
|
|
14
|
+
if (domain.origin !== admittedPublication.origin ||
|
|
15
|
+
domain.revision !== admittedPublication.schema.revision) {
|
|
16
|
+
throw new TypeError('Publication snapshot Domain identity differs from its Publication.');
|
|
17
|
+
}
|
|
18
|
+
const table = admitTable(admittedPublication, input.table, domain);
|
|
19
|
+
const publicationBytes = encodePublication(admittedPublication);
|
|
20
|
+
const snapshot = Object.freeze({ publication: admittedPublication });
|
|
21
|
+
const prepared = Object.freeze({
|
|
22
|
+
snapshot,
|
|
23
|
+
publication: admittedPublication,
|
|
24
|
+
publicationBytes,
|
|
25
|
+
bundle: bundleBytes,
|
|
26
|
+
table,
|
|
27
|
+
domain,
|
|
28
|
+
});
|
|
29
|
+
snapshots.set(snapshot, prepared);
|
|
30
|
+
return snapshot;
|
|
31
|
+
}
|
|
32
|
+
/** Internal proof that a PublicationSource returned a Server-prepared snapshot without cloning it. */
|
|
33
|
+
export function readPreparedPublicationSnapshot(input) {
|
|
34
|
+
if (input === null || typeof input !== 'object')
|
|
35
|
+
return undefined;
|
|
36
|
+
return snapshots.get(input);
|
|
37
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Domain } from '@astrale-os/kernel-dsl/v1';
|
|
2
|
+
import type * as publication from '@astrale-os/kernel-protocol/publication';
|
|
3
|
+
import type * as routes from '@astrale-os/kernel-protocol/routes';
|
|
4
|
+
export declare function admitTable(deployed: publication.Publication, input: routes.Table | undefined, domain: Domain): routes.Table;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { reference } from '@astrale-os/kernel-protocol/publication/reference';
|
|
2
|
+
import { acceptTable } from '@astrale-os/kernel-protocol/routes/admission';
|
|
3
|
+
import { verifyTable } from '@astrale-os/kernel-protocol/routes/evidence';
|
|
4
|
+
export function admitTable(deployed, input, domain) {
|
|
5
|
+
if (input === undefined) {
|
|
6
|
+
if (deployed.routes.length !== 0) {
|
|
7
|
+
throw new TypeError('A Publication with native routes requires a Route Table.');
|
|
8
|
+
}
|
|
9
|
+
return verifyTable(Object.freeze({
|
|
10
|
+
publication: reference(deployed),
|
|
11
|
+
entries: Object.freeze([]),
|
|
12
|
+
}), deployed, domain);
|
|
13
|
+
}
|
|
14
|
+
const table = acceptTable(input);
|
|
15
|
+
return verifyTable(table, deployed, domain);
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Domain } from '@astrale-os/kernel-dsl/v1';
|
|
2
|
+
import type * as publication from '@astrale-os/kernel-protocol/publication';
|
|
3
|
+
import type * as routes from '@astrale-os/kernel-protocol/routes';
|
|
4
|
+
declare const PUBLICATION_SNAPSHOT: unique symbol;
|
|
5
|
+
export interface PublicationSnapshotInput {
|
|
6
|
+
readonly publication: publication.Publication;
|
|
7
|
+
/** Exact artifact served at Publication.schema.bundle.href. */
|
|
8
|
+
readonly bundle: Uint8Array;
|
|
9
|
+
readonly table?: routes.Table;
|
|
10
|
+
readonly domain: Domain;
|
|
11
|
+
}
|
|
12
|
+
/** Immutable admitted serving identity; bundle and compiled routes remain Server-private. */
|
|
13
|
+
export interface PublicationSnapshot {
|
|
14
|
+
readonly publication: publication.Publication;
|
|
15
|
+
readonly [PUBLICATION_SNAPSHOT]: true;
|
|
16
|
+
}
|
|
17
|
+
/** Atomically readable source swapped only after a complete snapshot is prepared. */
|
|
18
|
+
export interface PublicationSource {
|
|
19
|
+
/** Undefined until the first revision-coherent snapshot is ready. */
|
|
20
|
+
current(): PublicationSnapshot | undefined;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { currentPublicationSnapshot, mountRoutes, type RouteLimits, type RouteReservation, } from './routes.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { currentPublicationSnapshot, mountRoutes, } from './routes.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CorsPolicy } from '../cors/index.js';
|
|
2
|
+
import type { NextInvocationId } from '../invocation/index.js';
|
|
3
|
+
import type { ActiveOperations } from '../lifecycle/index.js';
|
|
4
|
+
import type { Provider as DeliveryProvider } from '../publication/delivery/index.js';
|
|
5
|
+
import type { PublicationSource } from '../publication/index.js';
|
|
6
|
+
import { type ApplicationHost, type Handler } from '../invocation/index.js';
|
|
7
|
+
import { type PreparedPublicationSnapshot } from '../publication/index.js';
|
|
8
|
+
import { type ServerRouter } from '../transport/router.js';
|
|
9
|
+
export interface RouteLimits {
|
|
10
|
+
readonly maximumRequestBytes: number;
|
|
11
|
+
readonly maximumPublicationBytes: number;
|
|
12
|
+
readonly maximumBundleBytes: number;
|
|
13
|
+
readonly maximumDeliveryBytes: number;
|
|
14
|
+
readonly invocationTimeoutMs: number;
|
|
15
|
+
}
|
|
16
|
+
export interface RouteReservation {
|
|
17
|
+
readonly path: string;
|
|
18
|
+
readonly methods: readonly string[];
|
|
19
|
+
}
|
|
20
|
+
export declare function mountRoutes(app: ServerRouter, source: PublicationSource, deliveryProvider: DeliveryProvider | undefined, handler: Handler, active: ActiveOperations, nextInvocation: NextInvocationId, limits: RouteLimits, cors: CorsPolicy, hostFor: (request: Request) => ApplicationHost | undefined, reservations: readonly RouteReservation[], externalIssuer?: string): void;
|
|
21
|
+
export declare function currentPublicationSnapshot(source: PublicationSource, limits: Pick<RouteLimits, 'maximumPublicationBytes' | 'maximumBundleBytes'>, serving?: {
|
|
22
|
+
readonly origin: string;
|
|
23
|
+
readonly issuer?: string;
|
|
24
|
+
readonly reservations: readonly RouteReservation[];
|
|
25
|
+
}): PreparedPublicationSnapshot | undefined;
|