@astrale-os/kernel-server 0.5.0-beta.6 → 0.5.0-beta.61
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 +0 -1
- package/dist/capture.js +0 -1
- package/dist/cors/cors.d.ts +0 -1
- package/dist/cors/cors.js +2 -1
- package/dist/cors/index.d.ts +0 -1
- package/dist/cors/index.js +0 -1
- package/dist/cors/types.d.ts +0 -1
- package/dist/cors/types.js +0 -1
- package/dist/errors/availability.d.ts +0 -1
- package/dist/errors/availability.js +0 -1
- package/dist/errors/classify.d.ts +0 -1
- package/dist/errors/classify.js +0 -1
- package/dist/errors/index.d.ts +0 -1
- package/dist/errors/index.js +0 -1
- package/dist/errors/request-body.d.ts +0 -1
- package/dist/errors/request-body.js +0 -1
- package/dist/errors/response-body.d.ts +0 -1
- package/dist/errors/response-body.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/invocation/context.d.ts +1 -2
- package/dist/invocation/context.js +0 -1
- package/dist/invocation/identity.d.ts +1 -2
- package/dist/invocation/identity.js +1 -2
- package/dist/invocation/index.d.ts +0 -1
- package/dist/invocation/index.js +0 -1
- package/dist/invocation/publication-route.d.ts +1 -4
- package/dist/invocation/publication-route.js +2 -12
- package/dist/invocation/types.d.ts +3 -4
- package/dist/invocation/types.js +0 -1
- package/dist/issuer/exchange.d.ts +0 -1
- package/dist/issuer/exchange.js +9 -1
- package/dist/issuer/index.d.ts +0 -1
- package/dist/issuer/index.js +0 -1
- package/dist/issuer/routes.d.ts +0 -1
- package/dist/issuer/routes.js +0 -1
- package/dist/issuer/types.d.ts +0 -1
- package/dist/issuer/types.js +0 -1
- package/dist/lifecycle/active.d.ts +2 -1
- package/dist/lifecycle/active.js +5 -3
- package/dist/lifecycle/index.d.ts +0 -1
- package/dist/lifecycle/index.js +0 -1
- package/dist/publication/delivery/handler.d.ts +0 -1
- package/dist/publication/delivery/handler.js +2 -2
- package/dist/publication/delivery/index.d.ts +0 -1
- package/dist/publication/delivery/index.js +0 -1
- package/dist/publication/delivery/types.d.ts +1 -2
- package/dist/publication/delivery/types.js +0 -1
- package/dist/publication/index.d.ts +0 -1
- package/dist/publication/index.js +0 -1
- package/dist/publication/snapshot.d.ts +4 -4
- package/dist/publication/snapshot.js +15 -8
- package/dist/publication/table.d.ts +4 -4
- package/dist/publication/table.js +3 -4
- package/dist/publication/types.d.ts +4 -5
- package/dist/publication/types.js +0 -1
- package/dist/routes/index.d.ts +0 -1
- package/dist/routes/index.js +0 -1
- package/dist/routes/routes.d.ts +1 -2
- package/dist/routes/routes.js +106 -14
- package/dist/server.d.ts +0 -1
- package/dist/server.js +18 -4
- package/dist/transport/body.d.ts +0 -1
- package/dist/transport/body.js +0 -1
- package/dist/transport/codecs.d.ts +0 -1
- package/dist/transport/codecs.js +0 -1
- package/dist/transport/credential.d.ts +0 -1
- package/dist/transport/credential.js +0 -1
- package/dist/transport/http/handler.d.ts +0 -1
- package/dist/transport/http/handler.js +3 -3
- package/dist/transport/http/index.d.ts +0 -1
- package/dist/transport/http/index.js +0 -1
- package/dist/transport/http/render.d.ts +5 -4
- package/dist/transport/http/render.js +77 -2
- package/dist/transport/index.d.ts +0 -1
- package/dist/transport/index.js +0 -1
- package/dist/transport/router.d.ts +0 -1
- package/dist/transport/router.js +0 -1
- package/dist/transport/stream-error.d.ts +0 -1
- package/dist/transport/stream-error.js +0 -1
- package/dist/transport/types.d.ts +1 -2
- package/dist/transport/types.js +0 -1
- package/dist/transport/websocket/index.d.ts +0 -1
- package/dist/transport/websocket/index.js +0 -1
- package/dist/transport/websocket/session.d.ts +0 -1
- package/dist/transport/websocket/session.js +12 -2
- package/dist/transport/websocket/upgrade.d.ts +0 -1
- package/dist/transport/websocket/upgrade.js +0 -1
- package/dist/types.d.ts +3 -2
- package/dist/types.js +0 -1
- package/package.json +10 -12
- package/dist/capture.d.ts.map +0 -1
- package/dist/capture.js.map +0 -1
- package/dist/cors/cors.d.ts.map +0 -1
- package/dist/cors/cors.js.map +0 -1
- package/dist/cors/index.d.ts.map +0 -1
- package/dist/cors/index.js.map +0 -1
- package/dist/cors/types.d.ts.map +0 -1
- package/dist/cors/types.js.map +0 -1
- package/dist/errors/availability.d.ts.map +0 -1
- package/dist/errors/availability.js.map +0 -1
- package/dist/errors/classify.d.ts.map +0 -1
- package/dist/errors/classify.js.map +0 -1
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js.map +0 -1
- package/dist/errors/request-body.d.ts.map +0 -1
- package/dist/errors/request-body.js.map +0 -1
- package/dist/errors/response-body.d.ts.map +0 -1
- package/dist/errors/response-body.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/invocation/context.d.ts.map +0 -1
- package/dist/invocation/context.js.map +0 -1
- package/dist/invocation/identity.d.ts.map +0 -1
- package/dist/invocation/identity.js.map +0 -1
- package/dist/invocation/index.d.ts.map +0 -1
- package/dist/invocation/index.js.map +0 -1
- package/dist/invocation/publication-route.d.ts.map +0 -1
- package/dist/invocation/publication-route.js.map +0 -1
- package/dist/invocation/types.d.ts.map +0 -1
- package/dist/invocation/types.js.map +0 -1
- package/dist/issuer/exchange.d.ts.map +0 -1
- package/dist/issuer/exchange.js.map +0 -1
- package/dist/issuer/index.d.ts.map +0 -1
- package/dist/issuer/index.js.map +0 -1
- package/dist/issuer/routes.d.ts.map +0 -1
- package/dist/issuer/routes.js.map +0 -1
- package/dist/issuer/types.d.ts.map +0 -1
- package/dist/issuer/types.js.map +0 -1
- package/dist/lifecycle/active.d.ts.map +0 -1
- package/dist/lifecycle/active.js.map +0 -1
- package/dist/lifecycle/index.d.ts.map +0 -1
- package/dist/lifecycle/index.js.map +0 -1
- package/dist/publication/delivery/handler.d.ts.map +0 -1
- package/dist/publication/delivery/handler.js.map +0 -1
- package/dist/publication/delivery/index.d.ts.map +0 -1
- package/dist/publication/delivery/index.js.map +0 -1
- package/dist/publication/delivery/types.d.ts.map +0 -1
- package/dist/publication/delivery/types.js.map +0 -1
- package/dist/publication/index.d.ts.map +0 -1
- package/dist/publication/index.js.map +0 -1
- package/dist/publication/snapshot.d.ts.map +0 -1
- package/dist/publication/snapshot.js.map +0 -1
- package/dist/publication/table.d.ts.map +0 -1
- package/dist/publication/table.js.map +0 -1
- package/dist/publication/types.d.ts.map +0 -1
- package/dist/publication/types.js.map +0 -1
- package/dist/publication/validator.d.ts +0 -4
- package/dist/publication/validator.d.ts.map +0 -1
- package/dist/publication/validator.js +0 -17
- package/dist/publication/validator.js.map +0 -1
- package/dist/routes/index.d.ts.map +0 -1
- package/dist/routes/index.js.map +0 -1
- package/dist/routes/routes.d.ts.map +0 -1
- package/dist/routes/routes.js.map +0 -1
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/transport/body.d.ts.map +0 -1
- package/dist/transport/body.js.map +0 -1
- package/dist/transport/codecs.d.ts.map +0 -1
- package/dist/transport/codecs.js.map +0 -1
- package/dist/transport/credential.d.ts.map +0 -1
- package/dist/transport/credential.js.map +0 -1
- package/dist/transport/http/handler.d.ts.map +0 -1
- package/dist/transport/http/handler.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/render.d.ts.map +0 -1
- package/dist/transport/http/render.js.map +0 -1
- package/dist/transport/index.d.ts.map +0 -1
- package/dist/transport/index.js.map +0 -1
- package/dist/transport/router.d.ts.map +0 -1
- package/dist/transport/router.js.map +0 -1
- package/dist/transport/stream-error.d.ts.map +0 -1
- package/dist/transport/stream-error.js.map +0 -1
- package/dist/transport/types.d.ts.map +0 -1
- package/dist/transport/types.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/session.d.ts.map +0 -1
- package/dist/transport/websocket/session.js.map +0 -1
- package/dist/transport/websocket/upgrade.d.ts.map +0 -1
- package/dist/transport/websocket/upgrade.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
package/dist/capture.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
/** Capture one receiver-bound method while preserving the capability's exact method type. */
|
|
2
2
|
export declare function captureMethod<Receiver extends object, Name extends keyof Receiver>(input: Receiver, name: Name, invalidMessage: string): Receiver[Name];
|
|
3
|
-
//# sourceMappingURL=capture.d.ts.map
|
package/dist/capture.js
CHANGED
package/dist/cors/cors.d.ts
CHANGED
package/dist/cors/cors.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Request-aware CORS admission shared by every Server-owned HTTP surface. */
|
|
2
2
|
const TOKEN = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/u;
|
|
3
|
+
const PREFLIGHT_MAX_AGE_SECONDS = 24 * 60 * 60;
|
|
3
4
|
/** Admit one immutable policy. `false` delegates the complete concern to an outer application. */
|
|
4
5
|
export function prepareCors(input) {
|
|
5
6
|
if (input === false)
|
|
@@ -64,6 +65,7 @@ export function prepareCors(input) {
|
|
|
64
65
|
const allowedHeaders = requestedHeaders.length > 0 ? requestedHeaders : [...routeHeaders];
|
|
65
66
|
const output = new Headers(response(request));
|
|
66
67
|
output.set('access-control-allow-methods', [...allowedMethods, 'OPTIONS'].join(', '));
|
|
68
|
+
output.set('access-control-max-age', String(PREFLIGHT_MAX_AGE_SECONDS));
|
|
67
69
|
if (allowedHeaders.length > 0) {
|
|
68
70
|
output.set('access-control-allow-headers', allowedHeaders.join(', '));
|
|
69
71
|
}
|
|
@@ -133,4 +135,3 @@ function appendVary(headers, value) {
|
|
|
133
135
|
names.add(value);
|
|
134
136
|
headers.set('vary', [...names].join(', '));
|
|
135
137
|
}
|
|
136
|
-
//# sourceMappingURL=cors.js.map
|
package/dist/cors/index.d.ts
CHANGED
package/dist/cors/index.js
CHANGED
package/dist/cors/types.d.ts
CHANGED
package/dist/cors/types.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import * as errors from '@astrale-os/kernel-protocol/errors';
|
|
2
2
|
/** Convert only errors owned by an admitted Server or Protocol boundary into safe public data. */
|
|
3
3
|
export declare function classifyError(input: unknown): errors.ErrorPayload;
|
|
4
|
-
//# sourceMappingURL=classify.d.ts.map
|
package/dist/errors/classify.js
CHANGED
package/dist/errors/index.d.ts
CHANGED
|
@@ -2,4 +2,3 @@ export { DeliveryUnavailableError, IssuerKeysUnavailableError } from './availabi
|
|
|
2
2
|
export { classifyError } from './classify.js';
|
|
3
3
|
export { RequestBodyInvalidError, RequestBodyTooLargeError } from './request-body.js';
|
|
4
4
|
export { ResponseBodyTooLargeError } from './response-body.js';
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/errors/index.js
CHANGED
|
@@ -2,4 +2,3 @@ export { DeliveryUnavailableError, IssuerKeysUnavailableError } from './availabi
|
|
|
2
2
|
export { classifyError } from './classify.js';
|
|
3
3
|
export { RequestBodyInvalidError, RequestBodyTooLargeError } from './request-body.js';
|
|
4
4
|
export { ResponseBodyTooLargeError } from './response-body.js';
|
|
5
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,3 @@ export { DeliveryUnavailableError, IssuerKeysUnavailableError } from './errors/i
|
|
|
3
3
|
export { preparePublicationSnapshot } from './publication/index.js';
|
|
4
4
|
export * as publication from './publication/index.js';
|
|
5
5
|
export type { Application, ApplicationHost, CorsConfig, ExecutionControl, Handler, HandlerRequest, HandlerResult, HandlerStream, HealthProbe, InvocationContext, InvocationSource, RequestBackground, RequestEvidence, RequestSleep, Issuer, exchange, PreparedServer, PublicationSnapshot, PublicationSnapshotInput, PublicationSource, Server, ServerCloseOptions, ServerConfig, ServerLimits, ServerOptions, WebSocketAdapter, WebSocketHandlers, WebSocketLike, WebSocketUpgradeOptions, } from './types.js';
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -2,4 +2,3 @@ export { createServer, prepareServer } from './server.js';
|
|
|
2
2
|
export { DeliveryUnavailableError, IssuerKeysUnavailableError } from './errors/index.js';
|
|
3
3
|
export { preparePublicationSnapshot } from './publication/index.js';
|
|
4
4
|
export * as publication from './publication/index.js';
|
|
5
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
2
2
|
import type { ActiveOperation, ActiveOperations } from '../lifecycle/index.js';
|
|
3
3
|
import type { ApplicationHost, InvocationContext } from './types.js';
|
|
4
4
|
export declare function invocationContext(assigned: protocol.InvocationId, operation: ActiveOperation, active: ActiveOperations, host?: ApplicationHost, requestBody?: Uint8Array, idempotencyKey?: protocol.IdempotencyKey): InvocationContext;
|
|
5
5
|
/** Default non-durable timer used when the application host supplies no timer capability. */
|
|
6
6
|
export declare function defaultSleep(durationMs: number): Promise<void>;
|
|
7
|
-
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IssuerId } from '@astrale-os/kernel-core/auth';
|
|
2
|
-
import type
|
|
2
|
+
import type * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
3
3
|
/** Injected source-owned identity allocator captured before Server readiness. */
|
|
4
4
|
export interface InvocationSource {
|
|
5
5
|
readonly source: IssuerId;
|
|
@@ -7,4 +7,3 @@ export interface InvocationSource {
|
|
|
7
7
|
}
|
|
8
8
|
export type NextInvocationId = () => protocol.InvocationId;
|
|
9
9
|
export declare function captureInvocationSource(input: InvocationSource): NextInvocationId;
|
|
10
|
-
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { issuer } from '@astrale-os/kernel-core/auth';
|
|
2
|
-
import
|
|
2
|
+
import * as protocolInvocation from '@astrale-os/kernel-protocol/invocation';
|
|
3
3
|
import { captureMethod } from '../capture.js';
|
|
4
4
|
export function captureInvocationSource(input) {
|
|
5
5
|
if (input === null || typeof input !== 'object') {
|
|
@@ -9,4 +9,3 @@ export function captureInvocationSource(input) {
|
|
|
9
9
|
const next = captureMethod(input, 'next', 'Server Invocation source is invalid.');
|
|
10
10
|
return () => protocolInvocation.acceptInvocationId({ source, id: next() });
|
|
11
11
|
}
|
|
12
|
-
//# sourceMappingURL=identity.js.map
|
|
@@ -2,4 +2,3 @@ export { defaultSleep, invocationContext } from './context.js';
|
|
|
2
2
|
export { captureInvocationSource, type InvocationSource, type NextInvocationId, } from './identity.js';
|
|
3
3
|
export { publicationRouteDecision, type PublicationRouteDecision } from './publication-route.js';
|
|
4
4
|
export type { ApplicationHost, ExecutionControl, Handler, HandlerRequest, HandlerResult, HandlerStream, InvocationContext, RequestBackground, RequestEvidence, RequestSleep, } from './types.js';
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/invocation/index.js
CHANGED
|
@@ -2,13 +2,10 @@ import type { ErrorPayload } from '@astrale-os/kernel-protocol/errors';
|
|
|
2
2
|
import type { Publication } from '@astrale-os/kernel-protocol/publication/publication';
|
|
3
3
|
import type { PublicationRef } from '@astrale-os/kernel-protocol/publication/reference';
|
|
4
4
|
export type PublicationRouteDecision = {
|
|
5
|
-
readonly kind: '
|
|
6
|
-
} | {
|
|
7
|
-
readonly kind: 'same-schema';
|
|
5
|
+
readonly kind: 'admitted';
|
|
8
6
|
} | {
|
|
9
7
|
readonly kind: 'rejected';
|
|
10
8
|
readonly error: ErrorPayload;
|
|
11
9
|
};
|
|
12
10
|
/** Compare untrusted installed routing evidence with the one captured serving Publication. */
|
|
13
11
|
export declare function publicationRouteDecision(current: Publication, installed: PublicationRef): PublicationRouteDecision;
|
|
14
|
-
//# sourceMappingURL=publication-route.d.ts.map
|
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import { CODES } from '@astrale-os/kernel-protocol/errors';
|
|
2
|
-
import {
|
|
2
|
+
import { SERVICE_TRUST_REQUIRED } from '@astrale-os/kernel-protocol/invocation/service-reason';
|
|
3
3
|
import { compareReference } from '@astrale-os/kernel-protocol/publication/reference';
|
|
4
4
|
/** Compare untrusted installed routing evidence with the one captured serving Publication. */
|
|
5
5
|
export function publicationRouteDecision(current, installed) {
|
|
6
6
|
switch (compareReference(current, installed)) {
|
|
7
7
|
case 'exact':
|
|
8
|
-
return Object.freeze({ kind: 'exact' });
|
|
9
8
|
case 'same-schema':
|
|
10
|
-
return Object.freeze({ kind: 'same-schema' });
|
|
11
9
|
case 'schema-drift':
|
|
12
|
-
return
|
|
13
|
-
code: SCHEMA_UPGRADE_REQUIRED,
|
|
14
|
-
details: Object.freeze({
|
|
15
|
-
origin: installed.origin,
|
|
16
|
-
installedRevision: installed.revision,
|
|
17
|
-
candidateRevision: current.schema.revision,
|
|
18
|
-
}),
|
|
19
|
-
}));
|
|
10
|
+
return Object.freeze({ kind: 'admitted' });
|
|
20
11
|
case 'identity-drift':
|
|
21
12
|
return rejected('Installed Domain Service identity requires explicit trust.', Object.freeze({
|
|
22
13
|
code: SERVICE_TRUST_REQUIRED,
|
|
@@ -42,4 +33,3 @@ function rejected(message, data) {
|
|
|
42
33
|
error: Object.freeze({ code: CODES.CONFLICT, message, data }),
|
|
43
34
|
});
|
|
44
35
|
}
|
|
45
|
-
//# sourceMappingURL=publication-route.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CredentialInput } from '@astrale-os/kernel-core/auth';
|
|
2
|
-
import type { CallableResult } from '@astrale-os/kernel-core/
|
|
2
|
+
import type { CallableResult } from '@astrale-os/kernel-core/callable';
|
|
3
3
|
import type { Value } from '@astrale-os/kernel-dsl/value';
|
|
4
|
-
import type
|
|
4
|
+
import type * as protocol from '@astrale-os/kernel-protocol/invocation';
|
|
5
5
|
import type { PublicationSnapshot } from '../publication/index.js';
|
|
6
6
|
/** Optional platform retention and timer adaptation for one Fetch invocation. */
|
|
7
7
|
export interface ApplicationHost {
|
|
@@ -49,7 +49,7 @@ export interface HandlerRequest {
|
|
|
49
49
|
readonly credential?: CredentialInput;
|
|
50
50
|
/** Source-only effective delegation forwarded unchanged to Runtime. */
|
|
51
51
|
readonly delegate?: protocol.Delegate;
|
|
52
|
-
/** Destination routing witness forwarded after
|
|
52
|
+
/** Destination routing witness forwarded after same-origin, same-identity Server admission. */
|
|
53
53
|
readonly via?: protocol.Via;
|
|
54
54
|
/** Source-only local-target or remote-revision Schema Registration precondition. */
|
|
55
55
|
readonly schema?: protocol.SchemaTarget;
|
|
@@ -60,4 +60,3 @@ export interface HandlerRequest {
|
|
|
60
60
|
export interface Handler {
|
|
61
61
|
dispatch(request: HandlerRequest): Promise<HandlerResult>;
|
|
62
62
|
}
|
|
63
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/invocation/types.js
CHANGED
|
@@ -10,4 +10,3 @@ export interface Provider {
|
|
|
10
10
|
}
|
|
11
11
|
export declare function capture(input: Provider): Provider;
|
|
12
12
|
export declare function mount(app: ServerRouter, issuer: string, provider: Provider, cors: CorsPolicy, active: ActiveOperations, timeoutMs: number): void;
|
|
13
|
-
//# sourceMappingURL=exchange.d.ts.map
|
package/dist/issuer/exchange.js
CHANGED
|
@@ -60,6 +60,11 @@ export function mount(app, issuer, provider, cors, active, timeoutMs) {
|
|
|
60
60
|
}
|
|
61
61
|
throw cause;
|
|
62
62
|
}
|
|
63
|
+
if (operation.timedOut) {
|
|
64
|
+
return respond(error('DEADLINE_EXCEEDED', 'Token-exchange deadline elapsed.'));
|
|
65
|
+
}
|
|
66
|
+
if (operation.signal.aborted)
|
|
67
|
+
throw operation.signal.reason;
|
|
63
68
|
let output;
|
|
64
69
|
try {
|
|
65
70
|
output = await provider.exchange(admitted, { signal: operation.signal });
|
|
@@ -68,6 +73,8 @@ export function mount(app, issuer, provider, cors, active, timeoutMs) {
|
|
|
68
73
|
if (operation.timedOut) {
|
|
69
74
|
return respond(error('DEADLINE_EXCEEDED', 'Token-exchange deadline elapsed.'));
|
|
70
75
|
}
|
|
76
|
+
if (operation.signal.aborted)
|
|
77
|
+
throw operation.signal.reason;
|
|
71
78
|
if (cause instanceof errors.ProtocolError && PROVIDER_CODES.has(cause.payload.code)) {
|
|
72
79
|
return respond(exchangeProtocol.acceptErrorResponse({ error: cause.payload }));
|
|
73
80
|
}
|
|
@@ -76,6 +83,8 @@ export function mount(app, issuer, provider, cors, active, timeoutMs) {
|
|
|
76
83
|
if (operation.timedOut) {
|
|
77
84
|
return respond(error('DEADLINE_EXCEEDED', 'Token-exchange deadline elapsed.'));
|
|
78
85
|
}
|
|
86
|
+
if (operation.signal.aborted)
|
|
87
|
+
throw operation.signal.reason;
|
|
79
88
|
const response = exchangeProtocol.acceptResponse(output);
|
|
80
89
|
if (inspectCredential(response.token).claims.exp !== response.expiresAt) {
|
|
81
90
|
throw new TypeError('Token-exchange provider returned inconsistent expiry evidence.');
|
|
@@ -134,4 +143,3 @@ function json(value, status, request, cors, extra) {
|
|
|
134
143
|
}
|
|
135
144
|
return new Response(JSON.stringify(value), { status, headers });
|
|
136
145
|
}
|
|
137
|
-
//# sourceMappingURL=exchange.js.map
|
package/dist/issuer/index.d.ts
CHANGED
package/dist/issuer/index.js
CHANGED
package/dist/issuer/routes.d.ts
CHANGED
|
@@ -11,4 +11,3 @@ export declare function issuerRouteReservations(input: Issuer, tokenExchange?: b
|
|
|
11
11
|
export declare function mountIssuer(app: ServerRouter, input: Issuer, cors: CorsPolicy, active: ActiveOperations, timeoutMs: number, tokenExchange?: Provider): void;
|
|
12
12
|
/** Admit static discovery configuration before Runtime Boot performs any durable work. */
|
|
13
13
|
export declare function admitIssuer(input: Issuer): Issuer;
|
|
14
|
-
//# sourceMappingURL=routes.d.ts.map
|
package/dist/issuer/routes.js
CHANGED
package/dist/issuer/types.d.ts
CHANGED
package/dist/issuer/types.js
CHANGED
|
@@ -26,6 +26,8 @@ export declare class ActiveOperations {
|
|
|
26
26
|
private changed;
|
|
27
27
|
constructor(maximumConcurrentOperations: number);
|
|
28
28
|
get isAccepting(): boolean;
|
|
29
|
+
/** Whether a newly arriving operation can be admitted without semantic dispatch. */
|
|
30
|
+
get isAvailable(): boolean;
|
|
29
31
|
begin(timeoutMs: number, externalSignal?: AbortSignal): ActiveOperation | undefined;
|
|
30
32
|
attachSocket(socket: ActiveSocket): boolean;
|
|
31
33
|
detachSocket(socket: ActiveSocket): void;
|
|
@@ -37,4 +39,3 @@ export declare class ActiveOperations {
|
|
|
37
39
|
private closeSockets;
|
|
38
40
|
}
|
|
39
41
|
export {};
|
|
40
|
-
//# sourceMappingURL=active.d.ts.map
|
package/dist/lifecycle/active.js
CHANGED
|
@@ -13,10 +13,13 @@ export class ActiveOperations {
|
|
|
13
13
|
get isAccepting() {
|
|
14
14
|
return this.accepting;
|
|
15
15
|
}
|
|
16
|
+
/** Whether a newly arriving operation can be admitted without semantic dispatch. */
|
|
17
|
+
get isAvailable() {
|
|
18
|
+
return this.accepting && this.operations.size < this.maximumConcurrentOperations;
|
|
19
|
+
}
|
|
16
20
|
begin(timeoutMs, externalSignal) {
|
|
17
|
-
if (!this.
|
|
21
|
+
if (!this.isAvailable)
|
|
18
22
|
return undefined;
|
|
19
|
-
}
|
|
20
23
|
const operation = new Operation(Date.now() + timeoutMs, () => {
|
|
21
24
|
this.operations.delete(operation);
|
|
22
25
|
this.changed?.();
|
|
@@ -197,4 +200,3 @@ async function settleCancellation(cancel, reason) {
|
|
|
197
200
|
function abortReason(signal) {
|
|
198
201
|
return signal.reason instanceof Error ? signal.reason.message : 'operation cancelled';
|
|
199
202
|
}
|
|
200
|
-
//# sourceMappingURL=active.js.map
|
package/dist/lifecycle/index.js
CHANGED
|
@@ -7,4 +7,3 @@ export interface Limits {
|
|
|
7
7
|
}
|
|
8
8
|
/** Serve one delivery request against the exact Publication snapshot that selected its URL. */
|
|
9
9
|
export declare function handleDelivery(request: Request, snapshot: PreparedPublicationSnapshot, provider: Provider | undefined, active: ActiveOperations, limits: Limits, cors: Readonly<Record<string, string>>): Promise<Response>;
|
|
10
|
-
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as codecs from '@astrale-os/kernel-protocol/codecs';
|
|
2
|
+
import * as protocolPublication from '@astrale-os/kernel-protocol/publication';
|
|
2
3
|
import { DeliveryUnavailableError } from '../../errors/index.js';
|
|
3
4
|
import { RequestBodyInvalidError, RequestBodyTooLargeError } from '../../errors/index.js';
|
|
4
5
|
import { readBoundedBody } from '../../transport/index.js';
|
|
@@ -124,4 +125,3 @@ function encodedSize(input) {
|
|
|
124
125
|
function toBody(input) {
|
|
125
126
|
return input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength);
|
|
126
127
|
}
|
|
127
|
-
//# sourceMappingURL=handler.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type * as publication from '@astrale-os/kernel-protocol/publication';
|
|
2
2
|
export interface Context {
|
|
3
3
|
/** Omitted for a public endpoint; otherwise the exact admitted retrieval credential. */
|
|
4
4
|
readonly token?: publication.delivery.Token;
|
|
@@ -9,4 +9,3 @@ export interface Provider {
|
|
|
9
9
|
/** Throw DeliveryUnavailableError only for an expected dependency outage. */
|
|
10
10
|
create(request: publication.delivery.Request, context: Context): Promise<publication.delivery.Delivery>;
|
|
11
11
|
}
|
|
12
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { preparePublicationSnapshot, readPreparedPublicationSnapshot, type PreparedPublicationSnapshot, } from './snapshot.js';
|
|
2
2
|
export type { PublicationSnapshot, PublicationSnapshotInput, PublicationSource } from './types.js';
|
|
3
3
|
export * as delivery from './delivery/index.js';
|
|
4
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type
|
|
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';
|
|
3
4
|
import type { PublicationSnapshot, PublicationSnapshotInput } from './types.js';
|
|
4
5
|
export interface PreparedPublicationSnapshot {
|
|
5
6
|
readonly snapshot: PublicationSnapshot;
|
|
@@ -7,10 +8,9 @@ export interface PreparedPublicationSnapshot {
|
|
|
7
8
|
readonly publicationBytes: Uint8Array;
|
|
8
9
|
readonly bundle: Uint8Array;
|
|
9
10
|
readonly table: routes.Table;
|
|
10
|
-
readonly
|
|
11
|
+
readonly domain: Domain;
|
|
11
12
|
}
|
|
12
13
|
/** Admit and detach one revision-coherent serving snapshot before publication. */
|
|
13
14
|
export declare function preparePublicationSnapshot(input: PublicationSnapshotInput): PublicationSnapshot;
|
|
14
15
|
/** Internal proof that a PublicationSource returned a Server-prepared snapshot without cloning it. */
|
|
15
16
|
export declare function readPreparedPublicationSnapshot(input: unknown): PreparedPublicationSnapshot | undefined;
|
|
16
|
-
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { bundleUrl } from '@astrale-os/kernel-protocol/publication';
|
|
1
2
|
import { verifyBundleBytes } from '@astrale-os/kernel-protocol/publication/bundle-evidence';
|
|
2
3
|
import { accept as acceptPublication, encode as encodePublication, } from '@astrale-os/kernel-protocol/publication/publication';
|
|
3
4
|
import { admitTable } from './table.js';
|
|
4
|
-
import { captureValidator } from './validator.js';
|
|
5
5
|
const snapshots = new WeakMap();
|
|
6
6
|
/** Admit and detach one revision-coherent serving snapshot before publication. */
|
|
7
7
|
export function preparePublicationSnapshot(input) {
|
|
@@ -11,12 +11,20 @@ export function preparePublicationSnapshot(input) {
|
|
|
11
11
|
const admittedPublication = acceptPublication(input.publication);
|
|
12
12
|
const bundleBytes = new Uint8Array(input.bundle);
|
|
13
13
|
verifyBundleBytes(admittedPublication, bundleBytes);
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
throw new TypeError('Publication snapshot
|
|
14
|
+
const domain = input.domain;
|
|
15
|
+
if (domain.origin !== admittedPublication.origin ||
|
|
16
|
+
domain.revision !== admittedPublication.schema.revision) {
|
|
17
|
+
throw new TypeError('Publication snapshot Domain identity differs from its Publication.');
|
|
18
|
+
}
|
|
19
|
+
const table = admitTable(admittedPublication, input.table, domain);
|
|
20
|
+
const addressed = new URL(bundleUrl(admittedPublication.identity.issuer, admittedPublication.schema.bundle.ref));
|
|
21
|
+
const addressedDirectory = addressed.pathname.slice(0, addressed.pathname.lastIndexOf('/') + 1);
|
|
22
|
+
const servingBundle = new URL(admittedPublication.schema.bundle.href);
|
|
23
|
+
if (servingBundle.origin === addressed.origin &&
|
|
24
|
+
servingBundle.pathname.startsWith(addressedDirectory) &&
|
|
25
|
+
servingBundle.href !== addressed.href) {
|
|
26
|
+
throw new TypeError('Publication bundle URL differs from its artifact digest.');
|
|
18
27
|
}
|
|
19
|
-
const table = admitTable(admittedPublication, input.table, validator);
|
|
20
28
|
const publicationBytes = encodePublication(admittedPublication);
|
|
21
29
|
const snapshot = Object.freeze({ publication: admittedPublication });
|
|
22
30
|
const prepared = Object.freeze({
|
|
@@ -25,7 +33,7 @@ export function preparePublicationSnapshot(input) {
|
|
|
25
33
|
publicationBytes,
|
|
26
34
|
bundle: bundleBytes,
|
|
27
35
|
table,
|
|
28
|
-
|
|
36
|
+
domain,
|
|
29
37
|
});
|
|
30
38
|
snapshots.set(snapshot, prepared);
|
|
31
39
|
return snapshot;
|
|
@@ -36,4 +44,3 @@ export function readPreparedPublicationSnapshot(input) {
|
|
|
36
44
|
return undefined;
|
|
37
45
|
return snapshots.get(input);
|
|
38
46
|
}
|
|
39
|
-
//# sourceMappingURL=snapshot.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type
|
|
3
|
-
|
|
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;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { reference } from '@astrale-os/kernel-protocol/publication/reference';
|
|
2
2
|
import { acceptTable } from '@astrale-os/kernel-protocol/routes/admission';
|
|
3
3
|
import { verifyTable } from '@astrale-os/kernel-protocol/routes/evidence';
|
|
4
|
-
export function admitTable(deployed, input,
|
|
4
|
+
export function admitTable(deployed, input, domain) {
|
|
5
5
|
if (input === undefined) {
|
|
6
6
|
if (deployed.routes.length !== 0) {
|
|
7
7
|
throw new TypeError('A Publication with native routes requires a Route Table.');
|
|
@@ -9,9 +9,8 @@ export function admitTable(deployed, input, validator) {
|
|
|
9
9
|
return verifyTable(Object.freeze({
|
|
10
10
|
publication: reference(deployed),
|
|
11
11
|
entries: Object.freeze([]),
|
|
12
|
-
}), deployed,
|
|
12
|
+
}), deployed, domain);
|
|
13
13
|
}
|
|
14
14
|
const table = acceptTable(input);
|
|
15
|
-
return verifyTable(table, deployed,
|
|
15
|
+
return verifyTable(table, deployed, domain);
|
|
16
16
|
}
|
|
17
|
-
//# sourceMappingURL=table.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
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
4
|
declare const PUBLICATION_SNAPSHOT: unique symbol;
|
|
5
5
|
export interface PublicationSnapshotInput {
|
|
6
6
|
readonly publication: publication.Publication;
|
|
7
7
|
/** Exact artifact served at Publication.schema.bundle.href. */
|
|
8
8
|
readonly bundle: Uint8Array;
|
|
9
9
|
readonly table?: routes.Table;
|
|
10
|
-
readonly
|
|
10
|
+
readonly domain: Domain;
|
|
11
11
|
}
|
|
12
12
|
/** Immutable admitted serving identity; bundle and compiled routes remain Server-private. */
|
|
13
13
|
export interface PublicationSnapshot {
|
|
@@ -20,4 +20,3 @@ export interface PublicationSource {
|
|
|
20
20
|
current(): PublicationSnapshot | undefined;
|
|
21
21
|
}
|
|
22
22
|
export {};
|
|
23
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/routes/index.d.ts
CHANGED
package/dist/routes/index.js
CHANGED
package/dist/routes/routes.d.ts
CHANGED
|
@@ -17,10 +17,9 @@ export interface RouteReservation {
|
|
|
17
17
|
readonly path: string;
|
|
18
18
|
readonly methods: readonly string[];
|
|
19
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;
|
|
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, publicOrigin?: string): void;
|
|
21
21
|
export declare function currentPublicationSnapshot(source: PublicationSource, limits: Pick<RouteLimits, 'maximumPublicationBytes' | 'maximumBundleBytes'>, serving?: {
|
|
22
22
|
readonly origin: string;
|
|
23
23
|
readonly issuer?: string;
|
|
24
24
|
readonly reservations: readonly RouteReservation[];
|
|
25
25
|
}): PreparedPublicationSnapshot | undefined;
|
|
26
|
-
//# sourceMappingURL=routes.d.ts.map
|