@astrale-os/kernel-server 0.5.0-beta.4 → 0.5.0-beta.41
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 +1 -2
- package/dist/errors/classify.js +1 -2
- 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 +6 -7
- package/dist/invocation/publication-route.js +8 -16
- package/dist/invocation/types.d.ts +3 -4
- package/dist/invocation/types.js +0 -1
- package/dist/issuer/exchange.d.ts +2 -3
- package/dist/issuer/exchange.js +22 -12
- 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 +14 -12
- package/dist/issuer/types.d.ts +2 -2
- 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 +5 -3
- package/dist/publication/snapshot.js +14 -7
- package/dist/publication/table.d.ts +4 -0
- package/dist/publication/table.js +16 -0
- package/dist/publication/types.d.ts +5 -2
- 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 +88 -24
- package/dist/server.d.ts +0 -1
- package/dist/server.js +7 -6
- package/dist/transport/body.d.ts +0 -1
- package/dist/transport/body.js +0 -1
- package/dist/transport/codecs.d.ts +1 -2
- package/dist/transport/codecs.js +1 -2
- package/dist/transport/credential.d.ts +1 -2
- package/dist/transport/credential.js +1 -2
- package/dist/transport/http/handler.d.ts +0 -1
- package/dist/transport/http/handler.js +3 -2
- package/dist/transport/http/index.d.ts +0 -1
- package/dist/transport/http/index.js +0 -1
- package/dist/transport/http/render.d.ts +12 -9
- package/dist/transport/http/render.js +75 -5
- 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 +2 -3
- package/dist/transport/stream-error.js +3 -4
- 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 +2 -3
- package/dist/transport/websocket/session.js +14 -3
- package/dist/transport/websocket/upgrade.d.ts +0 -1
- package/dist/transport/websocket/upgrade.js +1 -2
- package/dist/types.d.ts +1 -2
- package/dist/types.js +0 -1
- package/package.json +23 -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/types.d.ts.map +0 -1
- package/dist/publication/types.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
|
-
import
|
|
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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PathError } from '@astrale-os/kernel-core/path';
|
|
2
|
-
import
|
|
2
|
+
import * as errors from '@astrale-os/kernel-protocol/errors';
|
|
3
3
|
import { RequestBodyTooLargeError } from './request-body.js';
|
|
4
4
|
import { ResponseBodyTooLargeError } from './response-body.js';
|
|
5
5
|
/** Convert only errors owned by an admitted Server or Protocol boundary into safe public data. */
|
|
@@ -39,4 +39,3 @@ function reportInternal(input) {
|
|
|
39
39
|
code: stableCode(input),
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
//# sourceMappingURL=classify.js.map
|
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
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ErrorPayload } from '@astrale-os/kernel-protocol/errors';
|
|
2
|
+
import type { Publication } from '@astrale-os/kernel-protocol/publication/publication';
|
|
3
|
+
import type { PublicationRef } from '@astrale-os/kernel-protocol/publication/reference';
|
|
2
4
|
export type PublicationRouteDecision = {
|
|
3
|
-
readonly kind: '
|
|
4
|
-
} | {
|
|
5
|
-
readonly kind: 'same-schema';
|
|
5
|
+
readonly kind: 'admitted';
|
|
6
6
|
} | {
|
|
7
7
|
readonly kind: 'rejected';
|
|
8
|
-
readonly error:
|
|
8
|
+
readonly error: ErrorPayload;
|
|
9
9
|
};
|
|
10
10
|
/** Compare untrusted installed routing evidence with the one captured serving Publication. */
|
|
11
|
-
export declare function publicationRouteDecision(current:
|
|
12
|
-
//# sourceMappingURL=publication-route.d.ts.map
|
|
11
|
+
export declare function publicationRouteDecision(current: Publication, installed: PublicationRef): PublicationRouteDecision;
|
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CODES } from '@astrale-os/kernel-protocol/errors';
|
|
2
|
+
import { SERVICE_TRUST_REQUIRED } from '@astrale-os/kernel-protocol/invocation/service-reason';
|
|
3
|
+
import { compareReference } from '@astrale-os/kernel-protocol/publication/reference';
|
|
2
4
|
/** Compare untrusted installed routing evidence with the one captured serving Publication. */
|
|
3
5
|
export function publicationRouteDecision(current, installed) {
|
|
4
|
-
switch (
|
|
6
|
+
switch (compareReference(current, installed)) {
|
|
5
7
|
case 'exact':
|
|
6
|
-
return Object.freeze({ kind: 'exact' });
|
|
7
8
|
case 'same-schema':
|
|
8
|
-
return Object.freeze({ kind: 'same-schema' });
|
|
9
9
|
case 'schema-drift':
|
|
10
|
-
return
|
|
11
|
-
code: invocation.SCHEMA_UPGRADE_REQUIRED,
|
|
12
|
-
details: Object.freeze({
|
|
13
|
-
origin: installed.origin,
|
|
14
|
-
installedRevision: installed.revision,
|
|
15
|
-
candidateRevision: current.schema.revision,
|
|
16
|
-
}),
|
|
17
|
-
}));
|
|
10
|
+
return Object.freeze({ kind: 'admitted' });
|
|
18
11
|
case 'identity-drift':
|
|
19
12
|
return rejected('Installed Domain Service identity requires explicit trust.', Object.freeze({
|
|
20
|
-
code:
|
|
13
|
+
code: SERVICE_TRUST_REQUIRED,
|
|
21
14
|
details: Object.freeze({
|
|
22
15
|
origin: installed.origin,
|
|
23
16
|
installedIssuer: installed.identity.issuer,
|
|
@@ -28,7 +21,7 @@ export function publicationRouteDecision(current, installed) {
|
|
|
28
21
|
return Object.freeze({
|
|
29
22
|
kind: 'rejected',
|
|
30
23
|
error: Object.freeze({
|
|
31
|
-
code:
|
|
24
|
+
code: CODES.INVALID_REQUEST,
|
|
32
25
|
message: 'Routed Publication origin differs from the served Domain.',
|
|
33
26
|
}),
|
|
34
27
|
});
|
|
@@ -37,7 +30,6 @@ export function publicationRouteDecision(current, installed) {
|
|
|
37
30
|
function rejected(message, data) {
|
|
38
31
|
return Object.freeze({
|
|
39
32
|
kind: 'rejected',
|
|
40
|
-
error: Object.freeze({ code:
|
|
33
|
+
error: Object.freeze({ code: CODES.CONFLICT, message, data }),
|
|
41
34
|
});
|
|
42
35
|
}
|
|
43
|
-
//# 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as exchangeProtocol from '@astrale-os/kernel-protocol/issuer/exchange';
|
|
2
2
|
import type { CorsPolicy } from '../cors/index.js';
|
|
3
3
|
import type { ActiveOperations } from '../lifecycle/index.js';
|
|
4
4
|
import type { ServerRouter } from '../transport/index.js';
|
|
@@ -6,8 +6,7 @@ export interface Context {
|
|
|
6
6
|
readonly signal: AbortSignal;
|
|
7
7
|
}
|
|
8
8
|
export interface Provider {
|
|
9
|
-
exchange(request:
|
|
9
|
+
exchange(request: exchangeProtocol.Request, context: Context): Promise<exchangeProtocol.Response>;
|
|
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
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { inspect as inspectCredential } from '@astrale-os/kernel-core/auth/credential';
|
|
2
|
+
import * as errors from '@astrale-os/kernel-protocol/errors';
|
|
3
|
+
import * as exchangeProtocol from '@astrale-os/kernel-protocol/issuer/exchange';
|
|
4
|
+
import { paths as issuerPaths } from '@astrale-os/kernel-protocol/issuer/paths';
|
|
3
5
|
const PROVIDER_CODES = new Set([
|
|
4
6
|
errors.CODES.AUTH_INVALID,
|
|
5
7
|
errors.CODES.AUTH_EXPIRED,
|
|
@@ -16,7 +18,7 @@ export function capture(input) {
|
|
|
16
18
|
});
|
|
17
19
|
}
|
|
18
20
|
export function mount(app, issuer, provider, cors, active, timeoutMs) {
|
|
19
|
-
const path =
|
|
21
|
+
const path = issuerPaths(issuer).tokenExchange;
|
|
20
22
|
if (cors.enabled) {
|
|
21
23
|
app.options(path, (context) => cors.preflight(context.req.raw, { methods: ['POST'], headers: ['authorization', 'accept'] }));
|
|
22
24
|
}
|
|
@@ -25,7 +27,7 @@ export function mount(app, issuer, provider, cors, active, timeoutMs) {
|
|
|
25
27
|
const respond = (payload, extra) => json(payload, errors.httpStatusOf(payload.error), request, cors, extra);
|
|
26
28
|
let admitted;
|
|
27
29
|
try {
|
|
28
|
-
admitted =
|
|
30
|
+
admitted = exchangeProtocol.acceptHttpRequest({
|
|
29
31
|
method: request.method,
|
|
30
32
|
url: request.url,
|
|
31
33
|
authorization: request.headers.get('authorization'),
|
|
@@ -34,7 +36,7 @@ export function mount(app, issuer, provider, cors, active, timeoutMs) {
|
|
|
34
36
|
}
|
|
35
37
|
catch (cause) {
|
|
36
38
|
if (cause instanceof errors.ProtocolError) {
|
|
37
|
-
return respond(
|
|
39
|
+
return respond(exchangeProtocol.acceptErrorResponse({ error: cause.payload }), cause.payload.code === errors.CODES.METHOD_NOT_ALLOWED ? { allow: 'POST' } : undefined);
|
|
38
40
|
}
|
|
39
41
|
throw cause;
|
|
40
42
|
}
|
|
@@ -54,10 +56,15 @@ export function mount(app, issuer, provider, cors, active, timeoutMs) {
|
|
|
54
56
|
return respond(error('DEADLINE_EXCEEDED', 'Token-exchange deadline elapsed.'));
|
|
55
57
|
}
|
|
56
58
|
if (cause instanceof errors.ProtocolError) {
|
|
57
|
-
return respond(
|
|
59
|
+
return respond(exchangeProtocol.acceptErrorResponse({ error: cause.payload }));
|
|
58
60
|
}
|
|
59
61
|
throw cause;
|
|
60
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;
|
|
61
68
|
let output;
|
|
62
69
|
try {
|
|
63
70
|
output = await provider.exchange(admitted, { signal: operation.signal });
|
|
@@ -66,16 +73,20 @@ export function mount(app, issuer, provider, cors, active, timeoutMs) {
|
|
|
66
73
|
if (operation.timedOut) {
|
|
67
74
|
return respond(error('DEADLINE_EXCEEDED', 'Token-exchange deadline elapsed.'));
|
|
68
75
|
}
|
|
76
|
+
if (operation.signal.aborted)
|
|
77
|
+
throw operation.signal.reason;
|
|
69
78
|
if (cause instanceof errors.ProtocolError && PROVIDER_CODES.has(cause.payload.code)) {
|
|
70
|
-
return respond(
|
|
79
|
+
return respond(exchangeProtocol.acceptErrorResponse({ error: cause.payload }));
|
|
71
80
|
}
|
|
72
81
|
throw cause;
|
|
73
82
|
}
|
|
74
83
|
if (operation.timedOut) {
|
|
75
84
|
return respond(error('DEADLINE_EXCEEDED', 'Token-exchange deadline elapsed.'));
|
|
76
85
|
}
|
|
77
|
-
|
|
78
|
-
|
|
86
|
+
if (operation.signal.aborted)
|
|
87
|
+
throw operation.signal.reason;
|
|
88
|
+
const response = exchangeProtocol.acceptResponse(output);
|
|
89
|
+
if (inspectCredential(response.token).claims.exp !== response.expiresAt) {
|
|
79
90
|
throw new TypeError('Token-exchange provider returned inconsistent expiry evidence.');
|
|
80
91
|
}
|
|
81
92
|
return json(response, 200, request, cors);
|
|
@@ -118,12 +129,12 @@ function invalidRequest() {
|
|
|
118
129
|
});
|
|
119
130
|
}
|
|
120
131
|
function error(code, message) {
|
|
121
|
-
return
|
|
132
|
+
return exchangeProtocol.acceptErrorResponse({
|
|
122
133
|
error: { code: errors.CODES[code], message },
|
|
123
134
|
});
|
|
124
135
|
}
|
|
125
136
|
function json(value, status, request, cors, extra) {
|
|
126
|
-
const headers = new Headers(
|
|
137
|
+
const headers = new Headers(exchangeProtocol.responseHeaders());
|
|
127
138
|
for (const [name, value] of Object.entries(cors.response(request)))
|
|
128
139
|
headers.set(name, value);
|
|
129
140
|
if (extra !== undefined) {
|
|
@@ -132,4 +143,3 @@ function json(value, status, request, cors, extra) {
|
|
|
132
143
|
}
|
|
133
144
|
return new Response(JSON.stringify(value), { status, headers });
|
|
134
145
|
}
|
|
135
|
-
//# 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
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { configuration } from '@astrale-os/kernel-protocol/issuer/configuration';
|
|
2
|
+
import { hosted } from '@astrale-os/kernel-protocol/issuer/hosted';
|
|
3
|
+
import { keySet } from '@astrale-os/kernel-protocol/issuer/key-set';
|
|
4
|
+
import { paths as issuerPaths } from '@astrale-os/kernel-protocol/issuer/paths';
|
|
2
5
|
import { IssuerKeysUnavailableError } from '../errors/index.js';
|
|
3
6
|
import { mount } from './exchange.js';
|
|
4
7
|
export function issuerRouteReservations(input, tokenExchange = false) {
|
|
5
|
-
const paths =
|
|
8
|
+
const paths = issuerPaths(input.issuer);
|
|
6
9
|
const reservations = [
|
|
7
10
|
Object.freeze({ path: paths.configuration, methods: Object.freeze(['GET']) }),
|
|
8
11
|
Object.freeze({ path: paths.keys, methods: Object.freeze(['GET']) }),
|
|
@@ -24,16 +27,16 @@ export function issuerRouteReservations(input, tokenExchange = false) {
|
|
|
24
27
|
}
|
|
25
28
|
export function mountIssuer(app, input, cors, active, timeoutMs, tokenExchange) {
|
|
26
29
|
const issuer = input.issuer;
|
|
27
|
-
const paths =
|
|
30
|
+
const paths = issuerPaths(issuer);
|
|
28
31
|
const headers = (request) => ({
|
|
29
32
|
...cors.response(request),
|
|
30
33
|
'cache-control': 'no-cache',
|
|
31
34
|
});
|
|
32
35
|
const algorithm = input.signingAlgorithm ?? 'ES256';
|
|
33
|
-
const
|
|
36
|
+
const discovery = configuration(issuer, [algorithm], {
|
|
34
37
|
tokenExchange: tokenExchange !== undefined,
|
|
35
38
|
});
|
|
36
|
-
app.get(paths.configuration, (context) => context.json(
|
|
39
|
+
app.get(paths.configuration, (context) => context.json(discovery, 200, headers(context.req.raw)));
|
|
37
40
|
if (cors.enabled) {
|
|
38
41
|
app.options(paths.configuration, (context) => cors.preflight(context.req.raw, { methods: ['GET'] }));
|
|
39
42
|
app.options(paths.keys, (context) => cors.preflight(context.req.raw, { methods: ['GET'] }));
|
|
@@ -45,7 +48,7 @@ export function mountIssuer(app, input, cors, active, timeoutMs, tokenExchange)
|
|
|
45
48
|
}
|
|
46
49
|
try {
|
|
47
50
|
const keys = await input.loadPublicKeys(operation.signal);
|
|
48
|
-
return context.json(
|
|
51
|
+
return context.json(keySet(keys, [algorithm]), 200, headers(context.req.raw));
|
|
49
52
|
}
|
|
50
53
|
catch (cause) {
|
|
51
54
|
if (operation.signal.aborted || cause instanceof IssuerKeysUnavailableError) {
|
|
@@ -68,7 +71,7 @@ export function mountIssuer(app, input, cors, active, timeoutMs, tokenExchange)
|
|
|
68
71
|
app.options(`${base}/iss/:thumbprint/.well-known/jwks.json`, (context) => cors.preflight(context.req.raw, { methods: ['GET'] }));
|
|
69
72
|
}
|
|
70
73
|
app.get(`${base}/iss/:thumbprint/.well-known/openid-configuration`, async (context) => {
|
|
71
|
-
const hostedIssuer =
|
|
74
|
+
const hostedIssuer = hosted(issuer, context.req.param('thumbprint'));
|
|
72
75
|
if (hostedIssuer === undefined)
|
|
73
76
|
return context.json({ error: 'Issuer not found.' }, 404, headers(context.req.raw));
|
|
74
77
|
const operation = active.begin(timeoutMs, context.req.raw.signal);
|
|
@@ -79,7 +82,7 @@ export function mountIssuer(app, input, cors, active, timeoutMs, tokenExchange)
|
|
|
79
82
|
const keys = await hostedKeys(loadIssuerPublicKeys, hostedIssuer, operation.signal, algorithm);
|
|
80
83
|
if (keys.length === 0)
|
|
81
84
|
return context.json({ error: 'Issuer not found.' }, 404, headers(context.req.raw));
|
|
82
|
-
return context.json(
|
|
85
|
+
return context.json(configuration(hostedIssuer, [algorithm]), 200, headers(context.req.raw));
|
|
83
86
|
}
|
|
84
87
|
catch (cause) {
|
|
85
88
|
if (operation.signal.aborted || cause instanceof IssuerKeysUnavailableError) {
|
|
@@ -92,7 +95,7 @@ export function mountIssuer(app, input, cors, active, timeoutMs, tokenExchange)
|
|
|
92
95
|
}
|
|
93
96
|
});
|
|
94
97
|
app.get(`${base}/iss/:thumbprint/.well-known/jwks.json`, async (context) => {
|
|
95
|
-
const hostedIssuer =
|
|
98
|
+
const hostedIssuer = hosted(issuer, context.req.param('thumbprint'));
|
|
96
99
|
if (hostedIssuer === undefined)
|
|
97
100
|
return context.json({ error: 'Issuer not found.' }, 404, headers(context.req.raw));
|
|
98
101
|
const operation = active.begin(timeoutMs, context.req.raw.signal);
|
|
@@ -118,12 +121,12 @@ export function mountIssuer(app, input, cors, active, timeoutMs, tokenExchange)
|
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
async function hostedKeys(load, issuer, signal, algorithm) {
|
|
121
|
-
return
|
|
124
|
+
return keySet(await load(issuer, signal), [algorithm]).keys;
|
|
122
125
|
}
|
|
123
126
|
/** Admit static discovery configuration before Runtime Boot performs any durable work. */
|
|
124
127
|
export function admitIssuer(input) {
|
|
125
128
|
const signingAlgorithm = input.signingAlgorithm ?? 'ES256';
|
|
126
|
-
const issuer =
|
|
129
|
+
const issuer = configuration(input.issuer, [signingAlgorithm]).issuer;
|
|
127
130
|
if (typeof input.loadPublicKeys !== 'function') {
|
|
128
131
|
throw new TypeError('Issuer public-key loader is invalid.');
|
|
129
132
|
}
|
|
@@ -144,4 +147,3 @@ export function admitIssuer(input) {
|
|
|
144
147
|
}),
|
|
145
148
|
});
|
|
146
149
|
}
|
|
147
|
-
//# sourceMappingURL=routes.js.map
|
package/dist/issuer/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { IssuerId
|
|
1
|
+
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
2
|
+
import type { JsonWebKey } from '@astrale-os/kernel-core/auth/jwk';
|
|
2
3
|
/** Public issuer material; Server never receives private signing material. */
|
|
3
4
|
export interface Issuer {
|
|
4
5
|
readonly issuer: IssuerId;
|
|
@@ -8,4 +9,3 @@ export interface Issuer {
|
|
|
8
9
|
/** Optional hosted-key discovery for issuers below `<issuer>/iss/:thumbprint`. */
|
|
9
10
|
readonly loadIssuerPublicKeys?: (issuer: IssuerId, signal: AbortSignal) => Promise<readonly JsonWebKey[]>;
|
|
10
11
|
}
|
|
11
|
-
//# sourceMappingURL=types.d.ts.map
|
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
|