@astrale-os/kernel-protocol 0.5.0-beta.67 → 0.5.0-beta.69
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/codecs/index.d.ts +1 -2
- package/dist/codecs/index.js +1 -2
- package/dist/codecs/media-types.d.ts +0 -1
- package/dist/codecs/media-types.js +0 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/invocation/admission.d.ts +2 -2
- package/dist/invocation/admission.js +5 -5
- package/dist/invocation/binding-codecs.d.ts +1 -1
- package/dist/invocation/binding-codecs.js +1 -6
- package/dist/invocation/http/negotiation.js +3 -10
- package/dist/invocation/index.d.ts +5 -2
- package/dist/invocation/index.js +4 -2
- package/dist/invocation/legacy/index.d.ts +29 -0
- package/dist/invocation/legacy/index.js +28 -0
- package/dist/invocation/legacy/route.d.ts +14 -0
- package/dist/invocation/legacy/route.js +25 -0
- package/dist/invocation/legacy/via.d.ts +30 -0
- package/dist/invocation/legacy/via.js +15 -0
- package/dist/invocation/redirect.d.ts +15 -12
- package/dist/invocation/redirect.js +9 -21
- package/dist/invocation/request.js +2 -2
- package/dist/invocation/routing.d.ts +19 -5
- package/dist/invocation/routing.js +50 -20
- package/dist/invocation/schema.d.ts +3 -8
- package/dist/invocation/schema.js +3 -10
- package/dist/invocation/service-reason.d.ts +13 -13
- package/dist/invocation/service-reason.js +13 -12
- package/dist/invocation/stale-route.d.ts +1 -1
- package/dist/invocation/target.d.ts +3 -0
- package/dist/invocation/target.js +8 -1
- package/dist/invocation/websocket/index.d.ts +1 -1
- package/dist/invocation/websocket/index.js +1 -1
- package/dist/invocation/websocket/subprotocol.d.ts +1 -2
- package/dist/invocation/websocket/subprotocol.js +3 -4
- package/dist/issuer/claims.d.ts +7 -0
- package/dist/issuer/claims.js +7 -0
- package/dist/issuer/index.d.ts +2 -0
- package/dist/issuer/index.js +2 -0
- package/dist/issuer/paths.d.ts +2 -0
- package/dist/issuer/paths.js +1 -0
- package/dist/issuer/workflow-engine.d.ts +18 -0
- package/dist/issuer/workflow-engine.js +59 -0
- package/dist/{publication → release}/bindings/callable.js +6 -6
- package/dist/release/bindings/invocation.js +13 -0
- package/dist/{publication → release}/bindings/view.d.ts +1 -1
- package/dist/{publication → release}/bindings/view.js +10 -10
- package/dist/release/build.d.ts +6 -0
- package/dist/release/build.js +7 -0
- package/dist/release/bundle-admission.d.ts +21 -0
- package/dist/{publication → release}/bundle-admission.js +18 -18
- package/dist/{publication → release}/bundle-descriptor.js +6 -6
- package/dist/release/bundle-evidence.d.ts +3 -0
- package/dist/release/bundle-evidence.js +13 -0
- package/dist/{publication → release}/bundle.d.ts +2 -2
- package/dist/{publication → release}/bundle.js +9 -9
- package/dist/{publication → release}/delivery/attestation.d.ts +1 -0
- package/dist/release/delivery/claims.d.ts +21 -0
- package/dist/release/delivery/claims.js +68 -0
- package/dist/release/delivery/delivery.d.ts +11 -0
- package/dist/release/delivery/delivery.js +24 -0
- package/dist/{publication → release}/delivery/error.d.ts +2 -0
- package/dist/{publication → release}/delivery/error.js +1 -0
- package/dist/{publication → release}/delivery/index.d.ts +6 -1
- package/dist/{publication → release}/delivery/index.js +5 -0
- package/dist/{publication → release}/delivery/limits.d.ts +2 -1
- package/dist/release/delivery/limits.js +5 -0
- package/dist/release/delivery/request.d.ts +21 -0
- package/dist/release/delivery/request.js +60 -0
- package/dist/{publication → release}/delivery-declaration.js +4 -4
- package/dist/release/delivery-endpoint.js +22 -0
- package/dist/release/digest.d.ts +13 -0
- package/dist/{publication/etag.js → release/digest.js} +1 -10
- package/dist/release/error.d.ts +7 -0
- package/dist/release/error.js +11 -0
- package/dist/release/index.d.ts +21 -0
- package/dist/release/index.js +14 -0
- package/dist/release/issuer.d.ts +5 -0
- package/dist/release/issuer.js +34 -0
- package/dist/release/legacy/bindings.d.ts +14 -0
- package/dist/release/legacy/bindings.js +11 -0
- package/dist/release/legacy/bundle-admission.d.ts +6 -0
- package/dist/release/legacy/bundle-admission.js +10 -0
- package/dist/release/legacy/bundle-evidence.d.ts +8 -0
- package/dist/release/legacy/bundle-evidence.js +11 -0
- package/dist/release/legacy/bundle.d.ts +24 -0
- package/dist/release/legacy/bundle.js +31 -0
- package/dist/release/legacy/delivery/attestation.d.ts +6 -0
- package/dist/release/legacy/delivery/attestation.js +1 -0
- package/dist/{publication → release/legacy}/delivery/claims.d.ts +9 -0
- package/dist/{publication → release/legacy}/delivery/claims.js +7 -2
- package/dist/release/legacy/delivery/delivery.d.ts +18 -0
- package/dist/{publication → release/legacy}/delivery/delivery.js +6 -2
- package/dist/release/legacy/delivery/error.d.ts +16 -0
- package/dist/release/legacy/delivery/error.js +6 -0
- package/dist/release/legacy/delivery/index.d.ts +13 -0
- package/dist/release/legacy/delivery/index.js +13 -0
- package/dist/release/legacy/delivery/limits.d.ts +21 -0
- package/dist/release/legacy/delivery/limits.js +22 -0
- package/dist/release/legacy/delivery/request.d.ts +26 -0
- package/dist/{publication → release/legacy}/delivery/request.js +8 -3
- package/dist/release/legacy/delivery-declaration.d.ts +9 -0
- package/dist/release/legacy/delivery-declaration.js +11 -0
- package/dist/release/legacy/error.d.ts +26 -0
- package/dist/release/legacy/error.js +114 -0
- package/dist/release/legacy/etag.d.ts +12 -0
- package/dist/release/legacy/etag.js +14 -0
- package/dist/release/legacy/index.d.ts +75 -0
- package/dist/{publication → release/legacy}/index.js +7 -2
- package/dist/release/legacy/profiles.d.ts +23 -0
- package/dist/release/legacy/profiles.js +36 -0
- package/dist/release/legacy/projection.d.ts +13 -0
- package/dist/release/legacy/projection.js +25 -0
- package/dist/release/legacy/publication.d.ts +90 -0
- package/dist/release/legacy/publication.js +124 -0
- package/dist/release/legacy/reference.d.ts +47 -0
- package/dist/{publication → release/legacy}/reference.js +27 -3
- package/dist/release/legacy/requirements.d.ts +30 -0
- package/dist/release/legacy/requirements.js +20 -0
- package/dist/{publication → release}/manifest.js +6 -6
- package/dist/release/reference.d.ts +26 -0
- package/dist/release/reference.js +70 -0
- package/dist/release/release.d.ts +60 -0
- package/dist/release/release.js +123 -0
- package/dist/{publication → release}/requirements.d.ts +11 -4
- package/dist/{publication → release}/requirements.js +58 -39
- package/dist/{publication → release}/route.js +24 -24
- package/dist/{publication → release}/schema.js +4 -4
- package/dist/release/served.d.ts +26 -0
- package/dist/release/served.js +65 -0
- package/dist/release/shape.d.ts +8 -0
- package/dist/routes/admission.d.ts +1 -1
- package/dist/routes/admission.js +7 -85
- package/dist/routes/binding.d.ts +3 -3
- package/dist/routes/binding.js +10 -19
- package/dist/routes/compiler.d.ts +2 -2
- package/dist/routes/compiler.js +3 -2
- package/dist/routes/credential.d.ts +12 -1
- package/dist/routes/credential.js +11 -3
- package/dist/routes/decode.d.ts +5 -2
- package/dist/routes/decode.js +19 -6
- package/dist/routes/deployment-retired.d.ts +30 -0
- package/dist/routes/deployment-retired.js +96 -0
- package/dist/routes/encode.js +7 -6
- package/dist/routes/entries.d.ts +23 -0
- package/dist/routes/entries.js +150 -0
- package/dist/routes/evidence.d.ts +3 -3
- package/dist/routes/evidence.js +7 -34
- package/dist/routes/header.d.ts +9 -0
- package/dist/routes/header.js +34 -0
- package/dist/routes/index.d.ts +5 -2
- package/dist/routes/index.js +5 -2
- package/dist/routes/legacy/index.d.ts +29 -0
- package/dist/routes/legacy/index.js +29 -0
- package/dist/routes/legacy/routing.d.ts +24 -0
- package/dist/routes/legacy/routing.js +45 -0
- package/dist/routes/legacy/table.d.ts +34 -0
- package/dist/routes/legacy/table.js +50 -0
- package/dist/routes/mapping.d.ts +1 -1
- package/dist/routes/mapping.js +4 -4
- package/dist/routes/match.d.ts +1 -1
- package/dist/routes/placement.d.ts +2 -2
- package/dist/routes/plan.d.ts +1 -1
- package/dist/routes/request.d.ts +5 -3
- package/dist/routes/reservation.d.ts +4 -2
- package/dist/routes/reservation.js +4 -3
- package/dist/routes/routing.d.ts +30 -6
- package/dist/routes/routing.js +34 -49
- package/dist/routes/select.d.ts +1 -1
- package/dist/routes/table.d.ts +3 -2
- package/dist/routes/target.d.ts +5 -0
- package/dist/routes/target.js +16 -0
- package/dist/runtime/artifact.d.ts +2 -2
- package/dist/runtime/artifact.js +2 -2
- package/dist/schema/installation/codec.d.ts +6 -1
- package/dist/schema/installation/codec.js +10 -7
- package/dist/schema/installation/introspection/codec.d.ts +11 -2
- package/dist/schema/installation/introspection/codec.js +184 -47
- package/dist/schema/installation/introspection/index.d.ts +1 -1
- package/dist/schema/installation/introspection/result.d.ts +61 -1
- package/dist/schema/installation/legacy/index.d.ts +39 -0
- package/dist/schema/installation/legacy/index.js +39 -0
- package/dist/schema/installation/legacy/installation.d.ts +9 -0
- package/dist/schema/installation/legacy/installation.js +28 -0
- package/dist/schema/installation/legacy/introspection.d.ts +10 -0
- package/dist/schema/installation/legacy/introspection.js +70 -0
- package/dist/schema/installation/legacy/msgpack.d.ts +1 -0
- package/dist/schema/installation/legacy/msgpack.js +143 -0
- package/package.json +63 -36
- package/dist/codecs/msgpack.d.ts +0 -4
- package/dist/codecs/msgpack.js +0 -53
- package/dist/publication/bindings/invocation.js +0 -13
- package/dist/publication/bundle-admission.d.ts +0 -4
- package/dist/publication/bundle-evidence.d.ts +0 -3
- package/dist/publication/bundle-evidence.js +0 -13
- package/dist/publication/content.d.ts +0 -10
- package/dist/publication/delivery/delivery.d.ts +0 -9
- package/dist/publication/delivery/limits.js +0 -4
- package/dist/publication/delivery/request.d.ts +0 -15
- package/dist/publication/delivery-endpoint.js +0 -22
- package/dist/publication/error.d.ts +0 -7
- package/dist/publication/error.js +0 -11
- package/dist/publication/etag.d.ts +0 -6
- package/dist/publication/index.d.ts +0 -17
- package/dist/publication/legacy-requirements.d.ts +0 -12
- package/dist/publication/legacy-requirements.js +0 -23
- package/dist/publication/publication.d.ts +0 -38
- package/dist/publication/publication.js +0 -146
- package/dist/publication/reference.d.ts +0 -17
- package/dist/routes/release-unavailable.d.ts +0 -8
- package/dist/routes/release-unavailable.js +0 -32
- /package/dist/{publication → release}/bindings/callable.d.ts +0 -0
- /package/dist/{publication → release}/bindings/index.d.ts +0 -0
- /package/dist/{publication → release}/bindings/index.js +0 -0
- /package/dist/{publication → release}/bindings/invocation.d.ts +0 -0
- /package/dist/{publication → release}/bundle-descriptor.d.ts +0 -0
- /package/dist/{publication → release}/declaration.d.ts +0 -0
- /package/dist/{publication → release}/declaration.js +0 -0
- /package/dist/{publication → release}/delivery/attestation.js +0 -0
- /package/dist/{publication → release}/delivery-declaration.d.ts +0 -0
- /package/dist/{publication → release}/delivery-endpoint.d.ts +0 -0
- /package/dist/{publication → release}/manifest.d.ts +0 -0
- /package/dist/{publication → release}/route.d.ts +0 -0
- /package/dist/{publication → release}/schema.d.ts +0 -0
- /package/dist/{publication/content.js → release/shape.js} +0 -0
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import { patterns } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
2
1
|
import { digest, exactFields, invalid, portableObject } from './admission.js';
|
|
3
|
-
const FIELDS = new Set(['target', '
|
|
2
|
+
const FIELDS = new Set(['target', 'fingerprint']);
|
|
4
3
|
export function acceptSchemaTarget(input) {
|
|
5
4
|
const object = portableObject(input, 'schema target');
|
|
6
5
|
exactFields(object, FIELDS, 'schema target');
|
|
7
6
|
if ([...FIELDS].filter((field) => Object.hasOwn(object, field)).length !== 1) {
|
|
8
|
-
invalid('schema target must contain exactly one of target
|
|
7
|
+
invalid('schema target must contain exactly one of target or fingerprint');
|
|
9
8
|
}
|
|
10
9
|
if (Object.hasOwn(object, 'target')) {
|
|
11
10
|
return Object.freeze({ target: digest(object.target, 'schema target.target') });
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
return Object.freeze({ fingerprint: digest(object.fingerprint, 'schema target.fingerprint') });
|
|
15
|
-
}
|
|
16
|
-
if (typeof object.revision !== 'string' || !patterns.revision.test(object.revision)) {
|
|
17
|
-
invalid('schema target.revision must be a Schema revision');
|
|
18
|
-
}
|
|
19
|
-
return Object.freeze({ revision: object.revision });
|
|
12
|
+
return Object.freeze({ fingerprint: digest(object.fingerprint, 'schema target.fingerprint') });
|
|
20
13
|
}
|
|
@@ -3,20 +3,14 @@ import type { Revision } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
|
3
3
|
import type { Object as ValueObject } from '@astrale-os/kernel-dsl/value';
|
|
4
4
|
import { Key } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
5
5
|
import type { ErrorPayload, ErrorReason } from '../errors/index.js';
|
|
6
|
-
import type { Sha256Digest } from '../
|
|
6
|
+
import type { ReleaseDigest, Sha256Digest } from '../release/digest.js';
|
|
7
7
|
import { CODES } from '../errors/index.js';
|
|
8
|
-
/** @deprecated Emitted only for the deprecated revision pin; fingerprint pins report CALLABLE_FINGERPRINT_MISMATCH. */
|
|
9
|
-
export declare const SCHEMA_REVISION_MISMATCH: 'SCHEMA_REVISION_MISMATCH';
|
|
10
8
|
export declare const CALLABLE_FINGERPRINT_MISMATCH: 'CALLABLE_FINGERPRINT_MISMATCH';
|
|
11
9
|
export declare const SERVICE_TRUST_REQUIRED: 'SERVICE_TRUST_REQUIRED';
|
|
12
10
|
export declare const SERVICE_UNAVAILABLE: 'SERVICE_UNAVAILABLE';
|
|
13
11
|
export declare const SERVICE_CANDIDATE_INVALID: 'SERVICE_CANDIDATE_INVALID';
|
|
14
|
-
/**
|
|
15
|
-
export
|
|
16
|
-
readonly origin: Key.Origin;
|
|
17
|
-
readonly expectedRevision: Revision;
|
|
18
|
-
readonly installedRevision: Revision;
|
|
19
|
-
};
|
|
12
|
+
/** A deployment answers that it no longer serves: it runs no other code in its place. */
|
|
13
|
+
export declare const DEPLOYMENT_RETIRED: 'DEPLOYMENT_RETIRED';
|
|
20
14
|
export type CallableFingerprintMismatchDetails = ValueObject & {
|
|
21
15
|
readonly origin: Key.Origin;
|
|
22
16
|
readonly callable: Key.Callable;
|
|
@@ -35,19 +29,25 @@ export type ServiceUnavailableDetails = ValueObject & {
|
|
|
35
29
|
export type ServiceCandidateInvalidDetails = ValueObject & {
|
|
36
30
|
readonly origin: Key.Origin;
|
|
37
31
|
};
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
export type DeploymentRetiredDetails = ValueObject & {
|
|
33
|
+
readonly deployment: IssuerId;
|
|
34
|
+
readonly release?: ReleaseDigest;
|
|
35
|
+
};
|
|
40
36
|
export type CallableFingerprintMismatchReason = ErrorReason<typeof CALLABLE_FINGERPRINT_MISMATCH, CallableFingerprintMismatchDetails>;
|
|
41
37
|
export type ServiceTrustRequiredReason = ErrorReason<typeof SERVICE_TRUST_REQUIRED, ServiceTrustRequiredDetails>;
|
|
42
38
|
export type ServiceUnavailableReason = ErrorReason<typeof SERVICE_UNAVAILABLE, ServiceUnavailableDetails>;
|
|
43
39
|
export type ServiceCandidateInvalidReason = ErrorReason<typeof SERVICE_CANDIDATE_INVALID, ServiceCandidateInvalidDetails>;
|
|
44
|
-
export type
|
|
40
|
+
export type DeploymentRetiredReason = ErrorReason<typeof DEPLOYMENT_RETIRED, DeploymentRetiredDetails>;
|
|
41
|
+
export type ServiceReason = CallableFingerprintMismatchReason | ServiceTrustRequiredReason | ServiceUnavailableReason | ServiceCandidateInvalidReason | DeploymentRetiredReason;
|
|
45
42
|
export type ServiceErrorPayload = (Omit<ErrorPayload, 'code' | 'data'> & {
|
|
46
43
|
readonly code: typeof CODES.CONFLICT;
|
|
47
|
-
readonly data:
|
|
44
|
+
readonly data: CallableFingerprintMismatchReason | ServiceTrustRequiredReason;
|
|
48
45
|
}) | (Omit<ErrorPayload, 'code' | 'data'> & {
|
|
49
46
|
readonly code: typeof CODES.BACKEND_UNAVAILABLE;
|
|
50
47
|
readonly data: ServiceUnavailableReason | ServiceCandidateInvalidReason;
|
|
48
|
+
}) | (Omit<ErrorPayload, 'code' | 'data'> & {
|
|
49
|
+
readonly code: typeof CODES.NOT_FOUND;
|
|
50
|
+
readonly data: DeploymentRetiredReason;
|
|
51
51
|
});
|
|
52
52
|
/** Recognize only exact outer-code, reason-code, and detail-shape combinations. */
|
|
53
53
|
export declare function serviceErrorOf(input: ErrorPayload): ServiceErrorPayload | undefined;
|
|
@@ -2,22 +2,18 @@ import { AuthValueError } from '@astrale-os/kernel-core/auth/error';
|
|
|
2
2
|
import { accept as acceptIssuer } from '@astrale-os/kernel-core/auth/issuer';
|
|
3
3
|
import { Key, patterns } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
4
4
|
import { CODES, reasonOf } from '../errors/index.js';
|
|
5
|
-
/** @deprecated Emitted only for the deprecated revision pin; fingerprint pins report CALLABLE_FINGERPRINT_MISMATCH. */
|
|
6
|
-
export const SCHEMA_REVISION_MISMATCH = 'SCHEMA_REVISION_MISMATCH';
|
|
7
5
|
export const CALLABLE_FINGERPRINT_MISMATCH = 'CALLABLE_FINGERPRINT_MISMATCH';
|
|
8
6
|
export const SERVICE_TRUST_REQUIRED = 'SERVICE_TRUST_REQUIRED';
|
|
9
7
|
export const SERVICE_UNAVAILABLE = 'SERVICE_UNAVAILABLE';
|
|
10
8
|
export const SERVICE_CANDIDATE_INVALID = 'SERVICE_CANDIDATE_INVALID';
|
|
9
|
+
/** A deployment answers that it no longer serves: it runs no other code in its place. */
|
|
10
|
+
export const DEPLOYMENT_RETIRED = 'DEPLOYMENT_RETIRED';
|
|
11
11
|
/** Recognize only exact outer-code, reason-code, and detail-shape combinations. */
|
|
12
12
|
export function serviceErrorOf(input) {
|
|
13
13
|
const reason = reasonOf(input.data);
|
|
14
14
|
if (reason === undefined)
|
|
15
15
|
return undefined;
|
|
16
16
|
switch (reason.code) {
|
|
17
|
-
case SCHEMA_REVISION_MISMATCH:
|
|
18
|
-
return input.code === CODES.CONFLICT && schemaRevisionMismatchDetails(reason.details)
|
|
19
|
-
? input
|
|
20
|
-
: undefined;
|
|
21
17
|
case CALLABLE_FINGERPRINT_MISMATCH:
|
|
22
18
|
return input.code === CODES.CONFLICT && callableFingerprintMismatchDetails(reason.details)
|
|
23
19
|
? input
|
|
@@ -34,16 +30,14 @@ export function serviceErrorOf(input) {
|
|
|
34
30
|
return input.code === CODES.BACKEND_UNAVAILABLE && candidateInvalidDetails(reason.details)
|
|
35
31
|
? input
|
|
36
32
|
: undefined;
|
|
33
|
+
case DEPLOYMENT_RETIRED:
|
|
34
|
+
return input.code === CODES.NOT_FOUND && deploymentRetiredDetails(reason.details)
|
|
35
|
+
? input
|
|
36
|
+
: undefined;
|
|
37
37
|
default:
|
|
38
38
|
return undefined;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
function schemaRevisionMismatchDetails(input) {
|
|
42
|
-
return (exact(input, ['origin', 'expectedRevision', 'installedRevision']) &&
|
|
43
|
-
isOrigin(input.origin) &&
|
|
44
|
-
isRevision(input.expectedRevision) &&
|
|
45
|
-
isRevision(input.installedRevision));
|
|
46
|
-
}
|
|
47
41
|
function callableFingerprintMismatchDetails(input) {
|
|
48
42
|
return (exact(input, ['origin', 'callable', 'expectedFingerprint', 'installedFingerprint']) &&
|
|
49
43
|
isOrigin(input.origin) &&
|
|
@@ -65,6 +59,13 @@ function serviceUnavailableDetails(input) {
|
|
|
65
59
|
function candidateInvalidDetails(input) {
|
|
66
60
|
return exact(input, ['origin']) && isOrigin(input.origin);
|
|
67
61
|
}
|
|
62
|
+
function deploymentRetiredDetails(input) {
|
|
63
|
+
return Object.hasOwn(input, 'release')
|
|
64
|
+
? exact(input, ['deployment', 'release']) &&
|
|
65
|
+
isIssuer(input.deployment) &&
|
|
66
|
+
isDigest(input.release)
|
|
67
|
+
: exact(input, ['deployment']) && isIssuer(input.deployment);
|
|
68
|
+
}
|
|
68
69
|
function exact(input, fields) {
|
|
69
70
|
return (Object.keys(input).length === fields.length &&
|
|
70
71
|
fields.every((field) => Object.hasOwn(input, field)));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Etag } from '../
|
|
1
|
+
import type { Etag } from '../release/legacy/etag.js';
|
|
2
2
|
import type { RequestId } from './correlation.js';
|
|
3
3
|
import type { InvocationId } from './identity.js';
|
|
4
4
|
/** Reserved pre-handler routing control; never an application ErrorResponse. */
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { Value } from '@astrale-os/kernel-dsl/value';
|
|
1
2
|
import { type Call } from '@astrale-os/kernel-core/callable';
|
|
2
3
|
export { Target, targetPath, type Call } from '@astrale-os/kernel-core/callable';
|
|
3
4
|
export declare function acceptCall(input: unknown): Call;
|
|
5
|
+
/** Package-private: consume the detached portable subtree captured by request admission. */
|
|
6
|
+
export declare function callFromSnapshot(input: Value): Call;
|
|
@@ -4,7 +4,14 @@ import { exactFields, invalid, nodePath, portableObject, required } from './admi
|
|
|
4
4
|
export { Target, targetPath } from '@astrale-os/kernel-core/callable';
|
|
5
5
|
const CALL_FIELDS = new Set(['target', 'input']);
|
|
6
6
|
export function acceptCall(input) {
|
|
7
|
-
|
|
7
|
+
return callFromSnapshot(portableObject(input, 'call'));
|
|
8
|
+
}
|
|
9
|
+
/** Package-private: consume the detached portable subtree captured by request admission. */
|
|
10
|
+
export function callFromSnapshot(input) {
|
|
11
|
+
if (input === null || typeof input !== 'object' || Array.isArray(input)) {
|
|
12
|
+
invalid('call must be an object');
|
|
13
|
+
}
|
|
14
|
+
const object = input;
|
|
8
15
|
exactFields(object, CALL_FIELDS, 'call');
|
|
9
16
|
required(object, ['target', 'input'], 'call');
|
|
10
17
|
return Object.freeze({
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { decodeBinary, encodeBinary } from './binary.js';
|
|
2
|
-
export { JSON_SUBPROTOCOL,
|
|
2
|
+
export { JSON_SUBPROTOCOL, selectSubprotocol, subprotocolFor, type Subprotocol, type SubprotocolSelection, } from './subprotocol.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { decodeBinary, encodeBinary } from './binary.js';
|
|
2
|
-
export { JSON_SUBPROTOCOL,
|
|
2
|
+
export { JSON_SUBPROTOCOL, selectSubprotocol, subprotocolFor, } from './subprotocol.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Codec } from '../../codecs/index.js';
|
|
2
2
|
export declare const JSON_SUBPROTOCOL: 'astrale.invocation.v2.json';
|
|
3
|
-
export
|
|
4
|
-
export type Subprotocol = typeof JSON_SUBPROTOCOL | typeof MSGPACK_SUBPROTOCOL;
|
|
3
|
+
export type Subprotocol = typeof JSON_SUBPROTOCOL;
|
|
5
4
|
export interface SubprotocolSelection {
|
|
6
5
|
readonly subprotocol: Subprotocol;
|
|
7
6
|
readonly codec: Codec;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { admitSupportedCodecs, codecProfile } from '../binding-codecs.js';
|
|
2
2
|
export const JSON_SUBPROTOCOL = 'astrale.invocation.v2.json';
|
|
3
|
-
export const MSGPACK_SUBPROTOCOL = 'astrale.invocation.v2.msgpack';
|
|
4
3
|
const TOKEN = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/u;
|
|
5
4
|
export function subprotocolFor(codec) {
|
|
6
|
-
|
|
7
|
-
if (profile === undefined)
|
|
5
|
+
if (codecProfile(codec) === undefined) {
|
|
8
6
|
throw new TypeError('codec is not a canonical Invocation codec.');
|
|
9
|
-
|
|
7
|
+
}
|
|
8
|
+
return JSON_SUBPROTOCOL;
|
|
10
9
|
}
|
|
11
10
|
export function selectSubprotocol(offered, supported) {
|
|
12
11
|
const admitted = admitSupportedCodecs(supported);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Private JWT claim of the self credential a durable step's Domain signs for the Kernel: the id of
|
|
3
|
+
* the Execution the step belongs to. After a consented issuer change, the Kernel accepts the
|
|
4
|
+
* replaced issuer past its window only for a credential naming an unfinished run of its Domain
|
|
5
|
+
* that was in flight at that change.
|
|
6
|
+
*/
|
|
7
|
+
export declare const EXECUTION_CLAIM = "execution";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Private JWT claim of the self credential a durable step's Domain signs for the Kernel: the id of
|
|
3
|
+
* the Execution the step belongs to. After a consented issuer change, the Kernel accepts the
|
|
4
|
+
* replaced issuer past its window only for a credential naming an unfinished run of its Domain
|
|
5
|
+
* that was in flight at that change.
|
|
6
|
+
*/
|
|
7
|
+
export const EXECUTION_CLAIM = 'execution';
|
package/dist/issuer/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export { EXECUTION_CLAIM } from './claims.js';
|
|
1
2
|
export { acceptConfiguration, configuration, type Configuration, type ConfigurationOptions, } from './configuration.js';
|
|
2
3
|
export { DiscoveryError, type DiscoveryErrorCode } from './error.js';
|
|
3
4
|
export { hosted } from './hosted.js';
|
|
4
5
|
export { acceptKeySet, keySet, type KeySet } from './key-set.js';
|
|
5
6
|
export { paths, type Paths } from './paths.js';
|
|
7
|
+
export { acceptWorkflowEngine, acceptWorkflowEngineIdentityKey, workflowEngine, type WorkflowEngine, } from './workflow-engine.js';
|
|
6
8
|
export * as exchange from './exchange.js';
|
package/dist/issuer/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export { EXECUTION_CLAIM } from './claims.js';
|
|
1
2
|
export { acceptConfiguration, configuration, } from './configuration.js';
|
|
2
3
|
export { DiscoveryError } from './error.js';
|
|
3
4
|
export { hosted } from './hosted.js';
|
|
4
5
|
export { acceptKeySet, keySet } from './key-set.js';
|
|
5
6
|
export { paths } from './paths.js';
|
|
7
|
+
export { acceptWorkflowEngine, acceptWorkflowEngineIdentityKey, workflowEngine, } from './workflow-engine.js';
|
|
6
8
|
export * as exchange from './exchange.js';
|
package/dist/issuer/paths.d.ts
CHANGED
|
@@ -2,5 +2,7 @@ export interface Paths {
|
|
|
2
2
|
readonly configuration: string;
|
|
3
3
|
readonly keys: string;
|
|
4
4
|
readonly tokenExchange: string;
|
|
5
|
+
/** Where Domains discover the workflow engine of a Kernel that drives one. */
|
|
6
|
+
readonly workflowEngine: string;
|
|
5
7
|
}
|
|
6
8
|
export declare function paths(issuer: string): Paths;
|
package/dist/issuer/paths.js
CHANGED
|
@@ -6,5 +6,6 @@ export function paths(issuer) {
|
|
|
6
6
|
configuration: `${pathname}/.well-known/openid-configuration`,
|
|
7
7
|
keys: `${pathname}/.well-known/jwks.json`,
|
|
8
8
|
tokenExchange: `${pathname}/.well-known/astrale/token`,
|
|
9
|
+
workflowEngine: `${pathname}/.well-known/astrale/workflow-engine.json`,
|
|
9
10
|
});
|
|
10
11
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
|
|
2
|
+
/**
|
|
3
|
+
* The workflow engine a Kernel drives, as Domains discover it at
|
|
4
|
+
* `<issuer>/.well-known/astrale/workflow-engine.json`: the engine signs every request to a Domain with
|
|
5
|
+
* one of these Restate request identity keys. Several keys let the Host rotate without a gap.
|
|
6
|
+
*/
|
|
7
|
+
export interface WorkflowEngine {
|
|
8
|
+
readonly issuer: IssuerId;
|
|
9
|
+
readonly identity_keys: readonly [string, ...string[]];
|
|
10
|
+
}
|
|
11
|
+
/** Admit one Restate request identity key without imposing a key-set policy. */
|
|
12
|
+
export declare function acceptWorkflowEngineIdentityKey(input: unknown): string;
|
|
13
|
+
export declare function workflowEngine(issuer: string, identityKeys: readonly string[]): WorkflowEngine;
|
|
14
|
+
/**
|
|
15
|
+
* Admit a discovered engine for the expected issuer. Unlike issuer configuration, unknown fields are
|
|
16
|
+
* ignored: the Kernel may add some without breaking deployed Domains.
|
|
17
|
+
*/
|
|
18
|
+
export declare function acceptWorkflowEngine(input: unknown, expectedIssuer?: string): WorkflowEngine;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { fail } from './error.js';
|
|
2
|
+
import { acceptIssuer } from './url.js';
|
|
3
|
+
/** Restate's `publickeyv1_` id: base58btc of a raw Ed25519 public key. */
|
|
4
|
+
const IDENTITY_KEY = /^publickeyv1_[1-9A-HJ-NP-Za-km-z]{32,64}$/u;
|
|
5
|
+
const BASE58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
6
|
+
const MAXIMUM_IDENTITY_KEYS = 8;
|
|
7
|
+
/** Admit one Restate request identity key without imposing a key-set policy. */
|
|
8
|
+
export function acceptWorkflowEngineIdentityKey(input) {
|
|
9
|
+
if (typeof input !== 'string' || !IDENTITY_KEY.test(input) || decodedKeyBytes(input) !== 32) {
|
|
10
|
+
fail('ISSUER_DISCOVERY_INVALID', 'Workflow engine identity keys are invalid.');
|
|
11
|
+
}
|
|
12
|
+
return input;
|
|
13
|
+
}
|
|
14
|
+
export function workflowEngine(issuer, identityKeys) {
|
|
15
|
+
return Object.freeze({
|
|
16
|
+
issuer: acceptIssuer(issuer),
|
|
17
|
+
identity_keys: acceptIdentityKeys(identityKeys),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Admit a discovered engine for the expected issuer. Unlike issuer configuration, unknown fields are
|
|
22
|
+
* ignored: the Kernel may add some without breaking deployed Domains.
|
|
23
|
+
*/
|
|
24
|
+
export function acceptWorkflowEngine(input, expectedIssuer) {
|
|
25
|
+
if (input === null || typeof input !== 'object' || Array.isArray(input)) {
|
|
26
|
+
fail('ISSUER_DISCOVERY_INVALID', 'Workflow engine discovery is invalid.');
|
|
27
|
+
}
|
|
28
|
+
const value = input;
|
|
29
|
+
const admitted = acceptIssuer(value.issuer);
|
|
30
|
+
if (expectedIssuer !== undefined && admitted !== acceptIssuer(expectedIssuer)) {
|
|
31
|
+
fail('ISSUER_DISCOVERY_MISMATCH', 'Workflow engine discovery does not match the issuer.');
|
|
32
|
+
}
|
|
33
|
+
return Object.freeze({ issuer: admitted, identity_keys: acceptIdentityKeys(value.identity_keys) });
|
|
34
|
+
}
|
|
35
|
+
function acceptIdentityKeys(input) {
|
|
36
|
+
if (!Array.isArray(input) ||
|
|
37
|
+
input.length === 0 ||
|
|
38
|
+
input.length > MAXIMUM_IDENTITY_KEYS ||
|
|
39
|
+
new Set(input).size !== input.length) {
|
|
40
|
+
fail('ISSUER_DISCOVERY_INVALID', 'Workflow engine identity keys are invalid.');
|
|
41
|
+
}
|
|
42
|
+
return Object.freeze(Array.from(input, acceptWorkflowEngineIdentityKey));
|
|
43
|
+
}
|
|
44
|
+
/** Base58 leading '1' digits represent zero bytes omitted by the integer value. */
|
|
45
|
+
function decodedKeyBytes(key) {
|
|
46
|
+
const encoded = key.slice('publickeyv1_'.length);
|
|
47
|
+
let value = 0n;
|
|
48
|
+
for (const digit of encoded)
|
|
49
|
+
value = value * 58n + BigInt(BASE58.indexOf(digit));
|
|
50
|
+
let bytes = 0;
|
|
51
|
+
for (; value > 0n; value >>= 8n)
|
|
52
|
+
bytes++;
|
|
53
|
+
for (const digit of encoded) {
|
|
54
|
+
if (digit !== '1')
|
|
55
|
+
break;
|
|
56
|
+
bytes++;
|
|
57
|
+
}
|
|
58
|
+
return bytes;
|
|
59
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { callableAddress, Key } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
2
|
-
import { exact, record } from '../content.js';
|
|
3
2
|
import { fail } from '../error.js';
|
|
3
|
+
import { exact, record } from '../shape.js';
|
|
4
4
|
import { acceptInvocationEndpoints } from './invocation.js';
|
|
5
5
|
export function admitCallableBinding(input, origin) {
|
|
6
|
-
const value = record(input, '
|
|
7
|
-
exact(value, ['callable', 'endpoint'], '
|
|
6
|
+
const value = record(input, 'RELEASE_BINDING_INVALID', 'Callable binding is invalid.');
|
|
7
|
+
exact(value, ['callable', 'endpoint'], 'RELEASE_BINDING_INVALID');
|
|
8
8
|
return Object.freeze({
|
|
9
9
|
callable: admitCallableKey(value.callable, origin),
|
|
10
10
|
endpoint: acceptInvocationEndpoints(value.endpoint),
|
|
@@ -17,18 +17,18 @@ export function admitCallableKey(input, origin) {
|
|
|
17
17
|
}
|
|
18
18
|
catch (cause) {
|
|
19
19
|
if (cause instanceof TypeError) {
|
|
20
|
-
return fail('
|
|
20
|
+
return fail('RELEASE_BINDING_INVALID', 'Callable key is invalid.', cause);
|
|
21
21
|
}
|
|
22
22
|
throw cause;
|
|
23
23
|
}
|
|
24
24
|
if (Key.origin(callable) !== origin) {
|
|
25
|
-
fail('
|
|
25
|
+
fail('RELEASE_BINDING_INVALID', 'Binding must name one callable owned by the root Domain.');
|
|
26
26
|
}
|
|
27
27
|
try {
|
|
28
28
|
callableAddress(callable);
|
|
29
29
|
}
|
|
30
30
|
catch (cause) {
|
|
31
|
-
return fail('
|
|
31
|
+
return fail('RELEASE_BINDING_INVALID', 'Binding must name one callable owned by the root Domain.', cause);
|
|
32
32
|
}
|
|
33
33
|
return callable;
|
|
34
34
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { absoluteHttpUrl, absoluteUrl, exact, record } from '../shape.js';
|
|
2
|
+
export function acceptInvocationEndpoints(input) {
|
|
3
|
+
const value = record(input, 'RELEASE_BINDING_INVALID', 'Invocation endpoints are invalid.');
|
|
4
|
+
exact(value, ['http', 'websocket'], 'RELEASE_BINDING_INVALID');
|
|
5
|
+
const http = absoluteHttpUrl(value.http, true, 'RELEASE_BINDING_INVALID');
|
|
6
|
+
const websocket = value.websocket === undefined
|
|
7
|
+
? undefined
|
|
8
|
+
: absoluteUrl(value.websocket, ['ws:', 'wss:'], true, 'RELEASE_BINDING_INVALID');
|
|
9
|
+
return Object.freeze({
|
|
10
|
+
http,
|
|
11
|
+
...(websocket === undefined ? {} : { websocket }),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -12,5 +12,5 @@ export interface IframeRequirements {
|
|
|
12
12
|
readonly allow?: readonly string[];
|
|
13
13
|
}
|
|
14
14
|
export declare function admitViewBinding(input: unknown, origin: string): ViewBinding;
|
|
15
|
-
/** Authoring-only normalization used before a
|
|
15
|
+
/** Authoring-only normalization used before a release document is sealed. */
|
|
16
16
|
export declare function canonicalizeViewBinding(input: unknown, origin: string): ViewBinding;
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { acceptViewHostRequirements, } from '@astrale-os/kernel-core/schema/kernel/syscalls/view-resolution';
|
|
2
2
|
import { Key } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
3
|
-
import { absoluteHttpUrl, exact, record } from '../content.js';
|
|
4
3
|
import { fail } from '../error.js';
|
|
4
|
+
import { absoluteHttpUrl, exact, record } from '../shape.js';
|
|
5
5
|
const TOKEN = /^[a-z][a-z0-9-]*$/u;
|
|
6
6
|
export function admitViewBinding(input, origin) {
|
|
7
7
|
return readViewBinding(input, origin, false);
|
|
8
8
|
}
|
|
9
|
-
/** Authoring-only normalization used before a
|
|
9
|
+
/** Authoring-only normalization used before a release document is sealed. */
|
|
10
10
|
export function canonicalizeViewBinding(input, origin) {
|
|
11
11
|
return readViewBinding(input, origin, true);
|
|
12
12
|
}
|
|
13
13
|
function readViewBinding(input, origin, canonicalize) {
|
|
14
|
-
const value = record(input, '
|
|
15
|
-
exact(value, ['view', 'href', 'handshake', 'iframe', 'host'], '
|
|
14
|
+
const value = record(input, 'RELEASE_VIEW_INVALID', 'Release View binding is invalid.');
|
|
15
|
+
exact(value, ['view', 'href', 'handshake', 'iframe', 'host'], 'RELEASE_VIEW_INVALID');
|
|
16
16
|
let view;
|
|
17
17
|
try {
|
|
18
18
|
view = Key(String(value.view));
|
|
19
19
|
}
|
|
20
20
|
catch (cause) {
|
|
21
21
|
if (cause instanceof TypeError) {
|
|
22
|
-
return fail('
|
|
22
|
+
return fail('RELEASE_VIEW_INVALID', 'View key is invalid.', cause);
|
|
23
23
|
}
|
|
24
24
|
throw cause;
|
|
25
25
|
}
|
|
26
26
|
if (Key.origin(view) !== origin || !view.slice(view.indexOf(':') + 1).startsWith('view.')) {
|
|
27
|
-
fail('
|
|
27
|
+
fail('RELEASE_VIEW_INVALID', 'View binding must name a root View.');
|
|
28
28
|
}
|
|
29
29
|
if (value.handshake !== 'shell' && value.handshake !== 'none') {
|
|
30
|
-
fail('
|
|
30
|
+
fail('RELEASE_VIEW_INVALID', 'View handshake is invalid.');
|
|
31
31
|
}
|
|
32
32
|
const iframe = admitIframeRequirements(dataValue(value, 'iframe'), value.handshake, canonicalize);
|
|
33
33
|
let host;
|
|
@@ -36,12 +36,12 @@ function readViewBinding(input, origin, canonicalize) {
|
|
|
36
36
|
}
|
|
37
37
|
catch (cause) {
|
|
38
38
|
if (cause instanceof TypeError)
|
|
39
|
-
return fail('
|
|
39
|
+
return fail('RELEASE_VIEW_INVALID', 'View host requirements are invalid.', cause);
|
|
40
40
|
throw cause;
|
|
41
41
|
}
|
|
42
42
|
return Object.freeze({
|
|
43
43
|
view,
|
|
44
|
-
href: absoluteHttpUrl(value.href, true, '
|
|
44
|
+
href: absoluteHttpUrl(value.href, true, 'RELEASE_VIEW_INVALID'),
|
|
45
45
|
handshake: value.handshake,
|
|
46
46
|
...(iframe === undefined ? {} : { iframe }),
|
|
47
47
|
...(host === undefined ? {} : { host }),
|
|
@@ -144,5 +144,5 @@ function assertRelationships(sandbox) {
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
function invalid() {
|
|
147
|
-
return fail('
|
|
147
|
+
return fail('RELEASE_VIEW_INVALID', 'View iframe requirements are invalid.');
|
|
148
148
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { admitDigest } from './digest.js';
|
|
2
|
+
import { exact, record } from './shape.js';
|
|
3
|
+
export function admitBuild(input) {
|
|
4
|
+
const value = record(input, 'RELEASE_INVALID', 'Release build is invalid.');
|
|
5
|
+
exact(value, ['digest'], 'RELEASE_INVALID');
|
|
6
|
+
return Object.freeze({ digest: admitDigest(value.digest) });
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Key } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
2
|
+
import * as dslBundle from '@astrale-os/kernel-dsl/v1/bundle';
|
|
3
|
+
import type { CallableBinding, ViewBinding } from './bindings/index.js';
|
|
4
|
+
import type { Manifest } from './manifest.js';
|
|
5
|
+
import type { Requirements } from './requirements.js';
|
|
6
|
+
import type { HttpRoute } from './route.js';
|
|
7
|
+
import type { Schema } from './schema.js';
|
|
8
|
+
/** The served release content one external Schema Bundle must exactly match. */
|
|
9
|
+
export interface ServedRelease {
|
|
10
|
+
readonly origin: Key.Origin;
|
|
11
|
+
readonly schema: Schema;
|
|
12
|
+
readonly requirements: Requirements;
|
|
13
|
+
readonly manifest?: Manifest;
|
|
14
|
+
readonly bindings: {
|
|
15
|
+
readonly callables: readonly CallableBinding[];
|
|
16
|
+
readonly views: readonly ViewBinding[];
|
|
17
|
+
};
|
|
18
|
+
readonly routes: readonly HttpRoute[];
|
|
19
|
+
}
|
|
20
|
+
export declare function acceptBundle(input: ServedRelease, artifact: unknown): dslBundle.Bundle;
|
|
21
|
+
export declare function decodeBundle(input: ServedRelease, bytes: Uint8Array): dslBundle.Bundle;
|
|
@@ -16,32 +16,32 @@ export function decodeBundle(input, bytes) {
|
|
|
16
16
|
validateInventory(input, decoded);
|
|
17
17
|
return decoded;
|
|
18
18
|
}
|
|
19
|
-
function validateInventory(
|
|
19
|
+
function validateInventory(release, bundle) {
|
|
20
20
|
const root = bundle.root;
|
|
21
|
-
if (root.origin !==
|
|
22
|
-
fail('
|
|
21
|
+
if (root.origin !== release.origin || revision(root) !== release.schema.revision) {
|
|
22
|
+
fail('RELEASE_INVALID', 'Bundle root does not match the release schema.');
|
|
23
23
|
}
|
|
24
|
-
validateRequirements(root, bundle.closure,
|
|
24
|
+
validateRequirements(root, bundle.closure, release.requirements);
|
|
25
25
|
const callables = concreteCallables(root);
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
[...callables].some((key) => !
|
|
29
|
-
fail('
|
|
26
|
+
const boundCallables = new Set(release.bindings.callables.map(({ callable }) => callable));
|
|
27
|
+
if (boundCallables.size !== callables.size ||
|
|
28
|
+
[...callables].some((key) => !boundCallables.has(key))) {
|
|
29
|
+
fail('RELEASE_BINDING_INVALID', 'Callable bindings must exhaust the root Domain.');
|
|
30
30
|
}
|
|
31
31
|
const views = new Set(Object.keys(root.views).map((name) => Key.of({ origin: root.origin, kind: 'view', name })));
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
34
|
-
fail('
|
|
32
|
+
const boundViews = new Set(release.bindings.views.map(({ view }) => view));
|
|
33
|
+
if (boundViews.size !== views.size || [...views].some((key) => !boundViews.has(key))) {
|
|
34
|
+
fail('RELEASE_VIEW_INVALID', 'View bindings must exhaust the root Domain.');
|
|
35
35
|
}
|
|
36
|
-
if (
|
|
37
|
-
(
|
|
38
|
-
|
|
39
|
-
root.views[
|
|
40
|
-
fail('
|
|
36
|
+
if (release.manifest?.entrypoint !== undefined &&
|
|
37
|
+
(release.manifest.entrypoint.origin !== root.origin ||
|
|
38
|
+
release.manifest.entrypoint.kind !== 'view' ||
|
|
39
|
+
root.views[release.manifest.entrypoint.name] === undefined)) {
|
|
40
|
+
fail('RELEASE_INVALID', 'Manifest entrypoint does not exist in the root schema.');
|
|
41
41
|
}
|
|
42
|
-
for (const route of
|
|
42
|
+
for (const route of release.routes) {
|
|
43
43
|
if (!callables.has(route.callable)) {
|
|
44
|
-
fail('
|
|
44
|
+
fail('RELEASE_ROUTE_INVALID', `Route ${route.name} names an unknown callable.`);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import * as artifact from '../artifact/index.js';
|
|
2
|
-
import { absoluteHttpUrl, exact, record } from './content.js';
|
|
3
2
|
import { fail } from './error.js';
|
|
3
|
+
import { absoluteHttpUrl, exact, record } from './shape.js';
|
|
4
4
|
export const BUNDLE_MEDIA_TYPE = 'application/vnd.astrale.domain-bundle+json;v=1';
|
|
5
5
|
export function admitBundleDescriptor(input) {
|
|
6
|
-
const value = record(input, '
|
|
7
|
-
exact(value, ['href', 'ref'], '
|
|
6
|
+
const value = record(input, 'RELEASE_INVALID', 'Bundle descriptor is invalid.');
|
|
7
|
+
exact(value, ['href', 'ref'], 'RELEASE_INVALID');
|
|
8
8
|
const ref = artifact.accept(value.ref);
|
|
9
9
|
if (ref.mediaType !== BUNDLE_MEDIA_TYPE) {
|
|
10
|
-
fail('
|
|
10
|
+
fail('RELEASE_INVALID', 'Bundle media type is unsupported.');
|
|
11
11
|
}
|
|
12
12
|
if (ref.size < 1) {
|
|
13
|
-
fail('
|
|
13
|
+
fail('RELEASE_INVALID', 'Bundle size is invalid.');
|
|
14
14
|
}
|
|
15
15
|
return Object.freeze({
|
|
16
|
-
href: absoluteHttpUrl(value.href, true, '
|
|
16
|
+
href: absoluteHttpUrl(value.href, true, 'RELEASE_INVALID'),
|
|
17
17
|
ref: Object.freeze({ ...ref, mediaType: BUNDLE_MEDIA_TYPE }),
|
|
18
18
|
});
|
|
19
19
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { sha256Hex } from './digest.js';
|
|
2
|
+
import { fail } from './error.js';
|
|
3
|
+
/** Verify exact artifact bytes without decoding an authored Schema Bundle. */
|
|
4
|
+
export function verifyBundleBytes(release, bytes) {
|
|
5
|
+
if (!(bytes instanceof Uint8Array)) {
|
|
6
|
+
fail('RELEASE_INVALID', 'Bundle artifact bytes are invalid.');
|
|
7
|
+
}
|
|
8
|
+
const descriptor = release.schema.bundle;
|
|
9
|
+
if (bytes.byteLength !== descriptor.ref.size ||
|
|
10
|
+
`sha256:${sha256Hex(bytes)}` !== descriptor.ref.digest) {
|
|
11
|
+
fail('RELEASE_INVALID', 'Bundle artifact does not match its descriptor.');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as bundle from '@astrale-os/kernel-dsl/v1/bundle/transport';
|
|
2
|
+
import type { ServedRelease } from './bundle-admission.js';
|
|
2
3
|
import type { BundleDescriptor } from './bundle-descriptor.js';
|
|
3
|
-
import type { Publication } from './publication.js';
|
|
4
4
|
import * as artifact from '../artifact/index.js';
|
|
5
5
|
import { verifyBundleBytes } from './bundle-evidence.js';
|
|
6
6
|
/** Resolve immutable bundle bytes beneath the exact serving issuer. */
|
|
7
7
|
export declare function bundleUrl(issuer: string, ref: artifact.Ref): string;
|
|
8
8
|
export declare function describeBundle(input: bundle.Bundle, href: string): BundleDescriptor;
|
|
9
9
|
export declare function acceptBundleValue(input: unknown): bundle.Bundle;
|
|
10
|
-
export declare function decodeBundleValue(
|
|
10
|
+
export declare function decodeBundleValue(release: Pick<ServedRelease, 'schema'>, bytes: Uint8Array): bundle.Bundle;
|
|
11
11
|
export { verifyBundleBytes };
|
|
12
12
|
export { admitBundleDescriptor, BUNDLE_MEDIA_TYPE, type BundleDescriptor, } from './bundle-descriptor.js';
|