@astrale-os/kernel-protocol 0.5.0-beta.66 → 0.5.0-beta.68

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.
Files changed (221) hide show
  1. package/dist/codecs/index.d.ts +1 -2
  2. package/dist/codecs/index.js +1 -2
  3. package/dist/codecs/media-types.d.ts +0 -1
  4. package/dist/codecs/media-types.js +0 -1
  5. package/dist/index.d.ts +3 -1
  6. package/dist/index.js +3 -1
  7. package/dist/invocation/admission.d.ts +2 -2
  8. package/dist/invocation/admission.js +5 -5
  9. package/dist/invocation/binding-codecs.d.ts +1 -1
  10. package/dist/invocation/binding-codecs.js +1 -6
  11. package/dist/invocation/http/negotiation.js +3 -10
  12. package/dist/invocation/index.d.ts +5 -2
  13. package/dist/invocation/index.js +4 -2
  14. package/dist/invocation/legacy/index.d.ts +29 -0
  15. package/dist/invocation/legacy/index.js +28 -0
  16. package/dist/invocation/legacy/route.d.ts +14 -0
  17. package/dist/invocation/legacy/route.js +25 -0
  18. package/dist/invocation/legacy/via.d.ts +30 -0
  19. package/dist/invocation/legacy/via.js +15 -0
  20. package/dist/invocation/redirect.d.ts +15 -12
  21. package/dist/invocation/redirect.js +9 -21
  22. package/dist/invocation/request.js +2 -2
  23. package/dist/invocation/routing.d.ts +19 -5
  24. package/dist/invocation/routing.js +50 -20
  25. package/dist/invocation/schema.d.ts +3 -8
  26. package/dist/invocation/schema.js +3 -10
  27. package/dist/invocation/service-reason.d.ts +13 -13
  28. package/dist/invocation/service-reason.js +13 -12
  29. package/dist/invocation/stale-route.d.ts +1 -1
  30. package/dist/invocation/target.d.ts +3 -0
  31. package/dist/invocation/target.js +8 -1
  32. package/dist/invocation/websocket/index.d.ts +1 -1
  33. package/dist/invocation/websocket/index.js +1 -1
  34. package/dist/invocation/websocket/subprotocol.d.ts +1 -2
  35. package/dist/invocation/websocket/subprotocol.js +3 -4
  36. package/dist/issuer/index.d.ts +1 -0
  37. package/dist/issuer/index.js +1 -0
  38. package/dist/issuer/paths.d.ts +2 -0
  39. package/dist/issuer/paths.js +1 -0
  40. package/dist/issuer/workflow-engine.d.ts +18 -0
  41. package/dist/issuer/workflow-engine.js +59 -0
  42. package/dist/{publication → release}/bindings/callable.js +6 -6
  43. package/dist/release/bindings/invocation.js +13 -0
  44. package/dist/{publication → release}/bindings/view.d.ts +1 -1
  45. package/dist/{publication → release}/bindings/view.js +10 -10
  46. package/dist/release/build.d.ts +6 -0
  47. package/dist/release/build.js +7 -0
  48. package/dist/release/bundle-admission.d.ts +21 -0
  49. package/dist/{publication → release}/bundle-admission.js +18 -18
  50. package/dist/{publication → release}/bundle-descriptor.js +6 -6
  51. package/dist/release/bundle-evidence.d.ts +3 -0
  52. package/dist/release/bundle-evidence.js +13 -0
  53. package/dist/{publication → release}/bundle.d.ts +2 -2
  54. package/dist/{publication → release}/bundle.js +9 -9
  55. package/dist/{publication → release}/delivery/attestation.d.ts +1 -0
  56. package/dist/release/delivery/claims.d.ts +21 -0
  57. package/dist/release/delivery/claims.js +68 -0
  58. package/dist/release/delivery/delivery.d.ts +11 -0
  59. package/dist/release/delivery/delivery.js +24 -0
  60. package/dist/{publication → release}/delivery/error.d.ts +2 -0
  61. package/dist/{publication → release}/delivery/error.js +1 -0
  62. package/dist/{publication → release}/delivery/index.d.ts +6 -1
  63. package/dist/{publication → release}/delivery/index.js +5 -0
  64. package/dist/{publication → release}/delivery/limits.d.ts +2 -1
  65. package/dist/release/delivery/limits.js +5 -0
  66. package/dist/release/delivery/request.d.ts +21 -0
  67. package/dist/release/delivery/request.js +60 -0
  68. package/dist/{publication → release}/delivery-declaration.js +4 -4
  69. package/dist/release/delivery-endpoint.js +22 -0
  70. package/dist/release/digest.d.ts +13 -0
  71. package/dist/{publication/etag.js → release/digest.js} +1 -10
  72. package/dist/release/error.d.ts +7 -0
  73. package/dist/release/error.js +11 -0
  74. package/dist/release/index.d.ts +21 -0
  75. package/dist/release/index.js +14 -0
  76. package/dist/release/issuer.d.ts +5 -0
  77. package/dist/release/issuer.js +34 -0
  78. package/dist/release/legacy/bindings.d.ts +14 -0
  79. package/dist/release/legacy/bindings.js +11 -0
  80. package/dist/release/legacy/bundle-admission.d.ts +6 -0
  81. package/dist/release/legacy/bundle-admission.js +10 -0
  82. package/dist/release/legacy/bundle-evidence.d.ts +8 -0
  83. package/dist/release/legacy/bundle-evidence.js +11 -0
  84. package/dist/release/legacy/bundle.d.ts +24 -0
  85. package/dist/release/legacy/bundle.js +31 -0
  86. package/dist/release/legacy/delivery/attestation.d.ts +6 -0
  87. package/dist/release/legacy/delivery/attestation.js +1 -0
  88. package/dist/{publication → release/legacy}/delivery/claims.d.ts +9 -0
  89. package/dist/{publication → release/legacy}/delivery/claims.js +7 -2
  90. package/dist/release/legacy/delivery/delivery.d.ts +18 -0
  91. package/dist/{publication → release/legacy}/delivery/delivery.js +6 -2
  92. package/dist/release/legacy/delivery/error.d.ts +16 -0
  93. package/dist/release/legacy/delivery/error.js +6 -0
  94. package/dist/release/legacy/delivery/index.d.ts +13 -0
  95. package/dist/release/legacy/delivery/index.js +13 -0
  96. package/dist/release/legacy/delivery/limits.d.ts +21 -0
  97. package/dist/release/legacy/delivery/limits.js +22 -0
  98. package/dist/release/legacy/delivery/request.d.ts +26 -0
  99. package/dist/{publication → release/legacy}/delivery/request.js +8 -3
  100. package/dist/release/legacy/delivery-declaration.d.ts +9 -0
  101. package/dist/release/legacy/delivery-declaration.js +11 -0
  102. package/dist/release/legacy/error.d.ts +26 -0
  103. package/dist/release/legacy/error.js +114 -0
  104. package/dist/release/legacy/etag.d.ts +12 -0
  105. package/dist/release/legacy/etag.js +14 -0
  106. package/dist/release/legacy/index.d.ts +72 -0
  107. package/dist/{publication → release/legacy}/index.js +7 -2
  108. package/dist/release/legacy/profiles.d.ts +23 -0
  109. package/dist/release/legacy/profiles.js +36 -0
  110. package/dist/release/legacy/projection.d.ts +13 -0
  111. package/dist/release/legacy/projection.js +25 -0
  112. package/dist/release/legacy/publication.d.ts +90 -0
  113. package/dist/release/legacy/publication.js +124 -0
  114. package/dist/release/legacy/reference.d.ts +47 -0
  115. package/dist/{publication → release/legacy}/reference.js +27 -3
  116. package/dist/release/legacy/requirements.d.ts +30 -0
  117. package/dist/release/legacy/requirements.js +20 -0
  118. package/dist/{publication → release}/manifest.js +6 -6
  119. package/dist/release/reference.d.ts +26 -0
  120. package/dist/release/reference.js +70 -0
  121. package/dist/release/release.d.ts +60 -0
  122. package/dist/release/release.js +123 -0
  123. package/dist/{publication → release}/requirements.d.ts +11 -4
  124. package/dist/{publication → release}/requirements.js +58 -39
  125. package/dist/{publication → release}/route.js +24 -24
  126. package/dist/{publication → release}/schema.js +4 -4
  127. package/dist/release/served.d.ts +26 -0
  128. package/dist/release/served.js +65 -0
  129. package/dist/release/shape.d.ts +8 -0
  130. package/dist/routes/admission.d.ts +1 -1
  131. package/dist/routes/admission.js +7 -85
  132. package/dist/routes/binding.d.ts +3 -3
  133. package/dist/routes/binding.js +10 -19
  134. package/dist/routes/compiler.d.ts +2 -2
  135. package/dist/routes/compiler.js +3 -2
  136. package/dist/routes/credential.d.ts +1 -1
  137. package/dist/routes/decode.d.ts +5 -2
  138. package/dist/routes/decode.js +15 -4
  139. package/dist/routes/deployment-retired.d.ts +30 -0
  140. package/dist/routes/deployment-retired.js +96 -0
  141. package/dist/routes/encode.js +7 -6
  142. package/dist/routes/entries.d.ts +23 -0
  143. package/dist/routes/entries.js +150 -0
  144. package/dist/routes/evidence.d.ts +3 -3
  145. package/dist/routes/evidence.js +7 -34
  146. package/dist/routes/header.d.ts +9 -0
  147. package/dist/routes/header.js +34 -0
  148. package/dist/routes/index.d.ts +5 -2
  149. package/dist/routes/index.js +5 -2
  150. package/dist/routes/legacy/index.d.ts +29 -0
  151. package/dist/routes/legacy/index.js +29 -0
  152. package/dist/routes/legacy/routing.d.ts +24 -0
  153. package/dist/routes/legacy/routing.js +45 -0
  154. package/dist/routes/legacy/table.d.ts +34 -0
  155. package/dist/routes/legacy/table.js +50 -0
  156. package/dist/routes/mapping.d.ts +1 -1
  157. package/dist/routes/mapping.js +4 -4
  158. package/dist/routes/match.d.ts +1 -1
  159. package/dist/routes/placement.d.ts +2 -2
  160. package/dist/routes/plan.d.ts +1 -1
  161. package/dist/routes/request.d.ts +3 -3
  162. package/dist/routes/reservation.d.ts +4 -2
  163. package/dist/routes/reservation.js +4 -3
  164. package/dist/routes/routing.d.ts +30 -6
  165. package/dist/routes/routing.js +34 -49
  166. package/dist/routes/select.d.ts +1 -1
  167. package/dist/routes/table.d.ts +3 -2
  168. package/dist/routes/target.d.ts +5 -0
  169. package/dist/routes/target.js +16 -0
  170. package/dist/runtime/artifact.d.ts +2 -2
  171. package/dist/runtime/artifact.js +2 -2
  172. package/dist/schema/installation/codec.d.ts +6 -1
  173. package/dist/schema/installation/codec.js +10 -7
  174. package/dist/schema/installation/introspection/codec.d.ts +11 -2
  175. package/dist/schema/installation/introspection/codec.js +59 -41
  176. package/dist/schema/installation/introspection/result.d.ts +8 -1
  177. package/dist/schema/installation/legacy/index.d.ts +39 -0
  178. package/dist/schema/installation/legacy/index.js +39 -0
  179. package/dist/schema/installation/legacy/installation.d.ts +9 -0
  180. package/dist/schema/installation/legacy/installation.js +28 -0
  181. package/dist/schema/installation/legacy/introspection.d.ts +10 -0
  182. package/dist/schema/installation/legacy/introspection.js +70 -0
  183. package/dist/schema/installation/legacy/msgpack.d.ts +1 -0
  184. package/dist/schema/installation/legacy/msgpack.js +143 -0
  185. package/package.json +59 -36
  186. package/dist/codecs/msgpack.d.ts +0 -4
  187. package/dist/codecs/msgpack.js +0 -53
  188. package/dist/publication/bindings/invocation.js +0 -13
  189. package/dist/publication/bundle-admission.d.ts +0 -4
  190. package/dist/publication/bundle-evidence.d.ts +0 -3
  191. package/dist/publication/bundle-evidence.js +0 -13
  192. package/dist/publication/content.d.ts +0 -10
  193. package/dist/publication/delivery/delivery.d.ts +0 -9
  194. package/dist/publication/delivery/limits.js +0 -4
  195. package/dist/publication/delivery/request.d.ts +0 -15
  196. package/dist/publication/delivery-endpoint.js +0 -22
  197. package/dist/publication/error.d.ts +0 -7
  198. package/dist/publication/error.js +0 -11
  199. package/dist/publication/etag.d.ts +0 -6
  200. package/dist/publication/index.d.ts +0 -17
  201. package/dist/publication/legacy-requirements.d.ts +0 -12
  202. package/dist/publication/legacy-requirements.js +0 -23
  203. package/dist/publication/publication.d.ts +0 -38
  204. package/dist/publication/publication.js +0 -146
  205. package/dist/publication/reference.d.ts +0 -17
  206. package/dist/routes/release-unavailable.d.ts +0 -8
  207. package/dist/routes/release-unavailable.js +0 -32
  208. /package/dist/{publication → release}/bindings/callable.d.ts +0 -0
  209. /package/dist/{publication → release}/bindings/index.d.ts +0 -0
  210. /package/dist/{publication → release}/bindings/index.js +0 -0
  211. /package/dist/{publication → release}/bindings/invocation.d.ts +0 -0
  212. /package/dist/{publication → release}/bundle-descriptor.d.ts +0 -0
  213. /package/dist/{publication → release}/declaration.d.ts +0 -0
  214. /package/dist/{publication → release}/declaration.js +0 -0
  215. /package/dist/{publication → release}/delivery/attestation.js +0 -0
  216. /package/dist/{publication → release}/delivery-declaration.d.ts +0 -0
  217. /package/dist/{publication → release}/delivery-endpoint.d.ts +0 -0
  218. /package/dist/{publication → release}/manifest.d.ts +0 -0
  219. /package/dist/{publication → release}/route.d.ts +0 -0
  220. /package/dist/{publication → release}/schema.d.ts +0 -0
  221. /package/dist/{publication/content.js → release/shape.js} +0 -0
@@ -2,18 +2,18 @@ import * as bundle from '@astrale-os/kernel-dsl/v1/bundle/transport';
2
2
  import * as artifact from '../artifact/index.js';
3
3
  import { BUNDLE_MEDIA_TYPE } from './bundle-descriptor.js';
4
4
  import { verifyBundleBytes } from './bundle-evidence.js';
5
- import { absoluteHttpUrl } from './content.js';
6
5
  import { fail } from './error.js';
7
- import { url as publicationUrl } from './publication.js';
6
+ import { servedUrl } from './issuer.js';
7
+ import { absoluteHttpUrl } from './shape.js';
8
8
  /** Resolve immutable bundle bytes beneath the exact serving issuer. */
9
9
  export function bundleUrl(issuer, ref) {
10
10
  const digest = ref.digest.slice('sha256:'.length);
11
- return `${publicationUrl(issuer).slice(0, -'domain.json'.length)}bundles/sha256/${digest}.json`;
11
+ return servedUrl(issuer, `/.well-known/astrale/bundles/sha256/${digest}.json`);
12
12
  }
13
13
  export function describeBundle(input, href) {
14
14
  const bytes = bundle.encode(input);
15
15
  return Object.freeze({
16
- href: absoluteHttpUrl(href, true, 'PUBLICATION_INVALID'),
16
+ href: absoluteHttpUrl(href, true, 'RELEASE_INVALID'),
17
17
  ref: Object.freeze({
18
18
  ...artifact.identify(bytes, BUNDLE_MEDIA_TYPE),
19
19
  mediaType: BUNDLE_MEDIA_TYPE,
@@ -26,22 +26,22 @@ export function acceptBundleValue(input) {
26
26
  }
27
27
  catch (cause) {
28
28
  if (cause instanceof bundle.Error) {
29
- return fail('PUBLICATION_INVALID', 'Publication bundle is invalid.', cause);
29
+ return fail('RELEASE_INVALID', 'Release bundle is invalid.', cause);
30
30
  }
31
31
  throw cause;
32
32
  }
33
33
  }
34
- export function decodeBundleValue(publication, bytes) {
34
+ export function decodeBundleValue(release, bytes) {
35
35
  if (!(bytes instanceof Uint8Array)) {
36
- fail('PUBLICATION_INVALID', 'Bundle artifact bytes are invalid.');
36
+ fail('RELEASE_INVALID', 'Bundle artifact bytes are invalid.');
37
37
  }
38
- verifyBundleBytes(publication, bytes);
38
+ verifyBundleBytes(release, bytes);
39
39
  try {
40
40
  return bundle.decode(bytes);
41
41
  }
42
42
  catch (cause) {
43
43
  if (cause instanceof bundle.Error) {
44
- return fail('PUBLICATION_INVALID', 'Bundle artifact cannot be decoded.', cause);
44
+ return fail('RELEASE_INVALID', 'Bundle artifact cannot be decoded.', cause);
45
45
  }
46
46
  throw cause;
47
47
  }
@@ -1,4 +1,5 @@
1
1
  declare const ATTESTATION: unique symbol;
2
+ /** Opaque, bounded attestation text a Delivery carries; Core Auth verifies it. */
2
3
  export type Attestation = string & {
3
4
  readonly [ATTESTATION]: true;
4
5
  };
@@ -0,0 +1,21 @@
1
+ import type { Subject } from '@astrale-os/kernel-core/auth/identity';
2
+ import type { Revision } from '@astrale-os/kernel-dsl/v1/addressing';
3
+ import { type IssuerId } from '@astrale-os/kernel-core/auth/issuer';
4
+ import type { ReleaseDigest } from '../digest.js';
5
+ import { PURPOSE } from './limits.js';
6
+ /**
7
+ * What a verified Delivery v2 attestation asserts: the serving Domain identity delivers the release
8
+ * with this digest and schema revision to the requesting Kernel, for its challenge nonce.
9
+ */
10
+ export interface Claims {
11
+ readonly purpose: typeof PURPOSE;
12
+ readonly iss: IssuerId;
13
+ readonly sub: Subject;
14
+ readonly aud: IssuerId;
15
+ readonly nonce: string;
16
+ readonly release: ReleaseDigest;
17
+ readonly schemaRevision: Revision;
18
+ readonly exp: number;
19
+ }
20
+ /** Admit the claims of an attestation Core Auth already verified. */
21
+ export declare function acceptClaims(input: unknown): Claims;
@@ -0,0 +1,68 @@
1
+ import { AuthValueError } from '@astrale-os/kernel-core/auth/error';
2
+ import { accept as acceptIssuerId } from '@astrale-os/kernel-core/auth/issuer';
3
+ import { patterns } from '@astrale-os/kernel-dsl/v1/addressing';
4
+ import { deepFreeze } from '../shape.js';
5
+ import { fail } from './error.js';
6
+ import { NONCE_MAX_LENGTH, NONCE_MIN_LENGTH, PURPOSE } from './limits.js';
7
+ const FIELDS = [
8
+ 'purpose',
9
+ 'iss',
10
+ 'sub',
11
+ 'aud',
12
+ 'nonce',
13
+ 'release',
14
+ 'schemaRevision',
15
+ 'exp',
16
+ ];
17
+ /** Admit the claims of an attestation Core Auth already verified. */
18
+ export function acceptClaims(input) {
19
+ if (input === null || typeof input !== 'object' || Array.isArray(input)) {
20
+ fail('DELIVERY_CLAIMS_INVALID', 'Expected delivery claims.');
21
+ }
22
+ const value = input;
23
+ if (Object.keys(value).some((field) => !FIELDS.includes(field))) {
24
+ fail('DELIVERY_CLAIMS_INVALID', 'Delivery claims contain unknown fields.');
25
+ }
26
+ if (value.purpose !== PURPOSE ||
27
+ typeof value.sub !== 'string' ||
28
+ value.sub.length === 0 ||
29
+ typeof value.nonce !== 'string' ||
30
+ value.nonce.length < NONCE_MIN_LENGTH ||
31
+ value.nonce.length > NONCE_MAX_LENGTH ||
32
+ typeof value.exp !== 'number' ||
33
+ !Number.isSafeInteger(value.exp)) {
34
+ fail('DELIVERY_CLAIMS_INVALID', 'Delivery claims are invalid.');
35
+ }
36
+ const iss = acceptIssuer(value.iss);
37
+ const aud = acceptIssuer(value.aud);
38
+ if (typeof value.release !== 'string' || !/^sha256:[0-9a-f]{64}$/u.test(value.release)) {
39
+ fail('DELIVERY_CLAIMS_INVALID', 'Delivery claims release digest is invalid.');
40
+ }
41
+ if (typeof value.schemaRevision !== 'string' || !patterns.revision.test(value.schemaRevision)) {
42
+ fail('DELIVERY_CLAIMS_INVALID', 'Schema revision is invalid.');
43
+ }
44
+ return deepFreeze({
45
+ purpose: PURPOSE,
46
+ iss,
47
+ sub: value.sub,
48
+ aud,
49
+ nonce: value.nonce,
50
+ release: value.release,
51
+ schemaRevision: value.schemaRevision,
52
+ exp: value.exp,
53
+ });
54
+ }
55
+ function acceptIssuer(input) {
56
+ if (typeof input !== 'string') {
57
+ fail('DELIVERY_CLAIMS_INVALID', 'Delivery claims issuer is invalid.');
58
+ }
59
+ try {
60
+ return acceptIssuerId(input);
61
+ }
62
+ catch (cause) {
63
+ if (cause instanceof AuthValueError) {
64
+ return fail('DELIVERY_CLAIMS_INVALID', 'Delivery claims issuer is invalid.', cause);
65
+ }
66
+ throw cause;
67
+ }
68
+ }
@@ -0,0 +1,11 @@
1
+ import type { DomainRelease } from '../release.js';
2
+ import type { Attestation } from './attestation.js';
3
+ /** The challenge-bound envelope carrying the exact `DomainRelease` a Kernel asked for. */
4
+ export interface Delivery {
5
+ readonly format: 'astrale.domain.delivery';
6
+ readonly version: 2;
7
+ readonly release: DomainRelease;
8
+ readonly attestation: Attestation;
9
+ }
10
+ /** Admit one Delivery v2 envelope: its release is admitted whole, its attestation stays opaque. */
11
+ export declare function accept(input: unknown): Delivery;
@@ -0,0 +1,24 @@
1
+ import { accept as acceptRelease } from '../release.js';
2
+ import { deepFreeze } from '../shape.js';
3
+ import { acceptAttestation } from './attestation.js';
4
+ import { fail } from './error.js';
5
+ /** Admit one Delivery v2 envelope: its release is admitted whole, its attestation stays opaque. */
6
+ export function accept(input) {
7
+ if (input === null || typeof input !== 'object' || Array.isArray(input)) {
8
+ fail('DELIVERY_INVALID', 'Expected a Delivery object.');
9
+ }
10
+ const value = input;
11
+ const expected = new Set(['format', 'version', 'release', 'attestation']);
12
+ if (Object.keys(value).some((field) => !expected.has(field))) {
13
+ fail('DELIVERY_INVALID', 'Delivery contains unknown fields.');
14
+ }
15
+ if (value.format !== 'astrale.domain.delivery' || value.version !== 2) {
16
+ fail('DELIVERY_INVALID', 'Unsupported Delivery format or version.');
17
+ }
18
+ return deepFreeze({
19
+ format: 'astrale.domain.delivery',
20
+ version: 2,
21
+ release: acceptRelease(value.release),
22
+ attestation: acceptAttestation(value.attestation),
23
+ });
24
+ }
@@ -1,4 +1,6 @@
1
+ /** Failure code of a Delivery request, envelope, or claims set, whatever its version. */
1
2
  export type DeliveryErrorCode = 'DELIVERY_INVALID' | 'DELIVERY_REQUEST_INVALID' | 'DELIVERY_CLAIMS_INVALID';
3
+ /** Reported by every Delivery decoder, v1 and v2. */
2
4
  export declare class DeliveryError extends Error {
3
5
  readonly code: DeliveryErrorCode;
4
6
  readonly name = "DeliveryError";
@@ -1,3 +1,4 @@
1
+ /** Reported by every Delivery decoder, v1 and v2. */
1
2
  export class DeliveryError extends Error {
2
3
  code;
3
4
  name = 'DeliveryError';
@@ -1,6 +1,11 @@
1
+ /**
2
+ * Delivery v2: the challenge-bound envelope carrying the exact `DomainRelease` a Kernel fetched at
3
+ * `release.json`, bound to its release digest. `acceptRequest` also admits the deprecated v1 request,
4
+ * discriminated by its `version`.
5
+ */
1
6
  export { type Attestation } from './attestation.js';
2
7
  export { acceptClaims, type Claims } from './claims.js';
3
8
  export { DeliveryError as Error, type DeliveryErrorCode as ErrorCode } from './error.js';
4
9
  export { accept, type Delivery } from './delivery.js';
5
10
  export { ATTESTATION_MAX_BYTES, NONCE_MAX_LENGTH, NONCE_MIN_LENGTH, PURPOSE } from './limits.js';
6
- export { acceptRequest, type Token, type Request } from './request.js';
11
+ export { acceptRequest, type Request, type Token } from './request.js';
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Delivery v2: the challenge-bound envelope carrying the exact `DomainRelease` a Kernel fetched at
3
+ * `release.json`, bound to its release digest. `acceptRequest` also admits the deprecated v1 request,
4
+ * discriminated by its `version`.
5
+ */
1
6
  export {} from './attestation.js';
2
7
  export { acceptClaims } from './claims.js';
3
8
  export { DeliveryError as Error } from './error.js';
@@ -1,4 +1,5 @@
1
- export declare const PURPOSE: 'astrale.domain.delivery.v1';
1
+ /** Purpose of Delivery v2 attestations, which bind a release digest. */
2
+ export declare const PURPOSE: 'astrale.domain.delivery.v2';
2
3
  export declare const NONCE_MIN_LENGTH = 16;
3
4
  export declare const NONCE_MAX_LENGTH = 256;
4
5
  export declare const ATTESTATION_MAX_BYTES = 16384;
@@ -0,0 +1,5 @@
1
+ /** Purpose of Delivery v2 attestations, which bind a release digest. */
2
+ export const PURPOSE = 'astrale.domain.delivery.v2';
3
+ export const NONCE_MIN_LENGTH = 16;
4
+ export const NONCE_MAX_LENGTH = 256;
5
+ export const ATTESTATION_MAX_BYTES = 16_384;
@@ -0,0 +1,21 @@
1
+ import { type IssuerId } from '@astrale-os/kernel-core/auth/issuer';
2
+ import type { ReleaseDigest } from '../digest.js';
3
+ import { type Request as PublicationRequest } from '../legacy/delivery/request.js';
4
+ /** Exact bearer credential admitted by a Delivery transport boundary; never inside a document. */
5
+ export interface Token {
6
+ readonly kind: 'bearer';
7
+ readonly token: string;
8
+ }
9
+ /** A requesting Kernel's challenge for the one exact release it fetched at `release.json`. */
10
+ export interface Request {
11
+ readonly version: 2;
12
+ readonly kernel: IssuerId;
13
+ readonly nonce: string;
14
+ readonly release: ReleaseDigest;
15
+ }
16
+ /**
17
+ * Admit the exact request representation accepted by a Delivery transport boundary. The request's
18
+ * own `version` selects the Delivery version: 2 names a release digest, and the deprecated 1 names
19
+ * the ETag of a v2/v3 Publication fetched at `domain.json`.
20
+ */
21
+ export declare function acceptRequest(input: unknown): Request | PublicationRequest;
@@ -0,0 +1,60 @@
1
+ import { AuthValueError } from '@astrale-os/kernel-core/auth/error';
2
+ import { accept as acceptIssuer } from '@astrale-os/kernel-core/auth/issuer';
3
+ import { acceptRequest as acceptPublicationRequest, } from '../legacy/delivery/request.js';
4
+ import { fail } from './error.js';
5
+ import { NONCE_MAX_LENGTH, NONCE_MIN_LENGTH } from './limits.js';
6
+ const FIELDS = ['version', 'kernel', 'nonce', 'release'];
7
+ /**
8
+ * Admit the exact request representation accepted by a Delivery transport boundary. The request's
9
+ * own `version` selects the Delivery version: 2 names a release digest, and the deprecated 1 names
10
+ * the ETag of a v2/v3 Publication fetched at `domain.json`.
11
+ */
12
+ export function acceptRequest(input) {
13
+ if (input === null || typeof input !== 'object' || Array.isArray(input)) {
14
+ fail('DELIVERY_REQUEST_INVALID', 'Expected a Delivery request.');
15
+ }
16
+ const version = Object.getOwnPropertyDescriptor(input, 'version');
17
+ if (version !== undefined && 'value' in version && version.value === 1) {
18
+ return acceptPublicationRequest(input);
19
+ }
20
+ const value = {};
21
+ const fields = Reflect.ownKeys(input);
22
+ if (fields.length !== FIELDS.length) {
23
+ fail('DELIVERY_REQUEST_INVALID', 'Delivery request is invalid.');
24
+ }
25
+ for (const field of fields) {
26
+ if (typeof field !== 'string' || !FIELDS.includes(field)) {
27
+ fail('DELIVERY_REQUEST_INVALID', 'Delivery request is invalid.');
28
+ }
29
+ const descriptor = Object.getOwnPropertyDescriptor(input, field);
30
+ if (descriptor === undefined || !descriptor.enumerable || !('value' in descriptor)) {
31
+ fail('DELIVERY_REQUEST_INVALID', 'Delivery request is invalid.');
32
+ }
33
+ value[field] = descriptor.value;
34
+ }
35
+ if (value.version !== 2 ||
36
+ typeof value.kernel !== 'string' ||
37
+ typeof value.nonce !== 'string' ||
38
+ value.nonce.length < NONCE_MIN_LENGTH ||
39
+ value.nonce.length > NONCE_MAX_LENGTH ||
40
+ typeof value.release !== 'string' ||
41
+ !/^sha256:[0-9a-f]{64}$/u.test(value.release)) {
42
+ fail('DELIVERY_REQUEST_INVALID', 'Delivery request is invalid.');
43
+ }
44
+ let kernel;
45
+ try {
46
+ kernel = acceptIssuer(value.kernel);
47
+ }
48
+ catch (cause) {
49
+ if (cause instanceof AuthValueError) {
50
+ return fail('DELIVERY_REQUEST_INVALID', 'Delivery request issuer is invalid.', cause);
51
+ }
52
+ throw cause;
53
+ }
54
+ return Object.freeze({
55
+ version: 2,
56
+ kernel,
57
+ nonce: value.nonce,
58
+ release: value.release,
59
+ });
60
+ }
@@ -3,23 +3,23 @@ import { fail } from './error.js';
3
3
  /** Place one provider-neutral Delivery declaration beneath an exact serving issuer. */
4
4
  export function placeDelivery(input, issuer, bundleHref) {
5
5
  if (input === null || typeof input !== 'object' || Array.isArray(input)) {
6
- fail('PUBLICATION_INVALID', 'Delivery declaration is invalid.');
6
+ fail('RELEASE_INVALID', 'Delivery declaration is invalid.');
7
7
  }
8
8
  if (Reflect.ownKeys(input).some((key) => key !== 'path' && key !== 'authentication') ||
9
9
  typeof input.path !== 'string' ||
10
10
  !input.path.startsWith('/')) {
11
- fail('PUBLICATION_INVALID', 'Delivery declaration is invalid.');
11
+ fail('RELEASE_INVALID', 'Delivery declaration is invalid.');
12
12
  }
13
13
  let href;
14
14
  try {
15
15
  const url = new URL(input.path, issuer);
16
16
  if (url.origin !== new URL(issuer).origin || url.search !== '' || url.hash !== '') {
17
- fail('PUBLICATION_INVALID', 'Delivery declaration must be one relative path.');
17
+ fail('RELEASE_INVALID', 'Delivery declaration must be one relative path.');
18
18
  }
19
19
  href = url.href;
20
20
  }
21
21
  catch (cause) {
22
- return fail('PUBLICATION_INVALID', 'Delivery declaration path is invalid.', cause);
22
+ return fail('RELEASE_INVALID', 'Delivery declaration path is invalid.', cause);
23
23
  }
24
24
  return admitEndpoint({ href, method: 'POST', authentication: input.authentication }, bundleHref);
25
25
  }
@@ -0,0 +1,22 @@
1
+ import { fail } from './error.js';
2
+ import { absoluteHttpUrl, exact, record } from './shape.js';
3
+ export function admitEndpoint(input, publicUrl) {
4
+ if (input === undefined)
5
+ return undefined;
6
+ const value = record(input, 'RELEASE_INVALID', 'Delivery endpoint is invalid.');
7
+ exact(value, ['href', 'method', 'authentication'], 'RELEASE_INVALID');
8
+ const href = absoluteHttpUrl(value.href, true, 'RELEASE_INVALID');
9
+ if (new URL(href).origin !== new URL(publicUrl).origin || value.method !== 'POST') {
10
+ fail('RELEASE_INVALID', 'Delivery endpoint must be same-origin POST.');
11
+ }
12
+ const authentication = record(value.authentication, 'RELEASE_INVALID', 'Delivery authentication is invalid.');
13
+ exact(authentication, ['kind'], 'RELEASE_INVALID');
14
+ if (authentication.kind !== 'public' && authentication.kind !== 'bearer') {
15
+ fail('RELEASE_INVALID', 'Delivery authentication kind is invalid.');
16
+ }
17
+ return Object.freeze({
18
+ href,
19
+ method: 'POST',
20
+ authentication: Object.freeze({ kind: authentication.kind }),
21
+ });
22
+ }
@@ -0,0 +1,13 @@
1
+ export type Sha256Digest = `sha256:${string}`;
2
+ /**
3
+ * Digest of one canonical `DomainRelease`: its build, its addresses and issuer, and through the
4
+ * address the variables frozen at deploy. One per deployment.
5
+ */
6
+ export type ReleaseDigest = Sha256Digest;
7
+ /**
8
+ * Hash of the bytes one build produced (modules, assets, schema, requirements). An address, key or
9
+ * secret never enters those bytes, so the same build has the same digest in every environment.
10
+ */
11
+ export type BuildDigest = Sha256Digest;
12
+ export declare function admitDigest(input: unknown): Sha256Digest;
13
+ export declare function sha256Hex(input: Uint8Array): string;
@@ -1,20 +1,11 @@
1
- import * as portable from '@astrale-os/kernel-dsl/value';
2
1
  import { fail } from './error.js';
3
- import { encodeLegacyRequirements } from './legacy-requirements.js';
4
2
  const DIGEST = /^sha256:[0-9a-f]{64}$/u;
5
3
  export function admitDigest(input) {
6
4
  if (typeof input !== 'string' || !DIGEST.test(input)) {
7
- fail('PUBLICATION_INVALID', 'Digest is invalid.');
5
+ fail('RELEASE_INVALID', 'Digest is invalid.');
8
6
  }
9
7
  return input;
10
8
  }
11
- export function computeEtag(input) {
12
- const wire = input.version === 2
13
- ? { ...input, requirements: encodeLegacyRequirements(input.requirements) }
14
- : input;
15
- const bytes = portable.json.encode(wire);
16
- return `sha256:${sha256Hex(bytes)}`;
17
- }
18
9
  export function sha256Hex(input) {
19
10
  const bitLength = input.length * 8;
20
11
  const paddedLength = Math.ceil((input.length + 9) / 64) * 64;
@@ -0,0 +1,7 @@
1
+ export type ReleaseErrorCode = 'RELEASE_INVALID' | 'RELEASE_DIGEST_MISMATCH' | 'RELEASE_BINDING_INVALID' | 'RELEASE_ROUTE_INVALID' | 'RELEASE_VIEW_INVALID';
2
+ export declare class ReleaseError extends Error {
3
+ readonly code: ReleaseErrorCode;
4
+ readonly name = "ReleaseError";
5
+ constructor(code: ReleaseErrorCode, message: string, options?: ErrorOptions);
6
+ }
7
+ export declare function fail(code: ReleaseErrorCode, message: string, cause?: unknown): never;
@@ -0,0 +1,11 @@
1
+ export class ReleaseError extends Error {
2
+ code;
3
+ name = 'ReleaseError';
4
+ constructor(code, message, options) {
5
+ super(message, options);
6
+ this.code = code;
7
+ }
8
+ }
9
+ export function fail(code, message, cause) {
10
+ throw new ReleaseError(code, message, cause === undefined ? undefined : { cause });
11
+ }
@@ -0,0 +1,21 @@
1
+ export { MEDIA_TYPE, PATH, accept, digestOf, encode, seal, url, type Content, type DomainRelease, } from './release.js';
2
+ export type { Build } from './build.js';
3
+ export { acceptReference, compareReferences, matchesReference, reference, type ReleaseRef, type ReleaseReferenceRelation, } from './reference.js';
4
+ export { acceptBundle, decodeBundle, type ServedRelease } from './bundle-admission.js';
5
+ export { BUNDLE_MEDIA_TYPE, bundleUrl, describeBundle, type BundleDescriptor } from './bundle.js';
6
+ export { verifyBundleBytes } from './bundle-evidence.js';
7
+ export type { Declaration, DeliveryDeclaration } from './declaration.js';
8
+ export { placeDelivery } from './delivery-declaration.js';
9
+ export type { Authentication as DeliveryAuthentication, Endpoint as DeliveryEndpoint, } from './delivery-endpoint.js';
10
+ export type { BuildDigest, ReleaseDigest, Sha256Digest } from './digest.js';
11
+ export { ReleaseError, type ReleaseErrorCode } from './error.js';
12
+ export type { Manifest } from './manifest.js';
13
+ export { ClassOperationOrder, admitRequirements, capabilityKeys, validateRequirements, type CapabilityAuthorityRequirements, type CoreCapabilityRequirement, type CapabilityRequirements, type ClassCapabilityRequirement, type ClassOperation, type NonEmpty, type Requirements, } from './requirements.js';
14
+ export type { BodyPick, CredentialSource, HttpMethod, HttpRoute, HttpRouteDeclaration, RouteBody, RouteHeaders, SingleCredentialSource, } from './route.js';
15
+ export type { Schema } from './schema.js';
16
+ export { acceptInvocationEndpoints, type CallableBinding, type IframeRequirements, type InvocationEndpoints, type ViewBinding, } from './bindings/index.js';
17
+ export * as delivery from './delivery/index.js';
18
+ /**
19
+ * @deprecated Publication v2/v3 compatibility surface; use `DomainRelease` v4 from this module.
20
+ */
21
+ export * as legacy from './legacy/index.js';
@@ -0,0 +1,14 @@
1
+ export { MEDIA_TYPE, PATH, accept, digestOf, encode, seal, url, } from './release.js';
2
+ export { acceptReference, compareReferences, matchesReference, reference, } from './reference.js';
3
+ export { acceptBundle, decodeBundle } from './bundle-admission.js';
4
+ export { BUNDLE_MEDIA_TYPE, bundleUrl, describeBundle } from './bundle.js';
5
+ export { verifyBundleBytes } from './bundle-evidence.js';
6
+ export { placeDelivery } from './delivery-declaration.js';
7
+ export { ReleaseError } from './error.js';
8
+ export { ClassOperationOrder, admitRequirements, capabilityKeys, validateRequirements, } from './requirements.js';
9
+ export { acceptInvocationEndpoints, } from './bindings/index.js';
10
+ export * as delivery from './delivery/index.js';
11
+ /**
12
+ * @deprecated Publication v2/v3 compatibility surface; use `DomainRelease` v4 from this module.
13
+ */
14
+ export * as legacy from './legacy/index.js';
@@ -0,0 +1,5 @@
1
+ import { type IssuerId } from '@astrale-os/kernel-core/auth/issuer';
2
+ /** Admit the exact serving issuer a served release document names. */
3
+ export declare function admitIssuer(input: unknown): IssuerId;
4
+ /** Resolve one served path beneath one exact HTTP(S) serving issuer, keeping its complete path. */
5
+ export declare function servedUrl(issuer: string, path: `/${string}`): string;
@@ -0,0 +1,34 @@
1
+ import { AuthValueError } from '@astrale-os/kernel-core/auth/error';
2
+ import { accept as acceptIssuerId } from '@astrale-os/kernel-core/auth/issuer';
3
+ import { fail } from './error.js';
4
+ /** Admit the exact serving issuer a served release document names. */
5
+ export function admitIssuer(input) {
6
+ try {
7
+ return acceptIssuerId(String(input));
8
+ }
9
+ catch (cause) {
10
+ if (cause instanceof AuthValueError) {
11
+ return fail('RELEASE_INVALID', 'Release issuer is invalid.', cause);
12
+ }
13
+ throw cause;
14
+ }
15
+ }
16
+ /** Resolve one served path beneath one exact HTTP(S) serving issuer, keeping its complete path. */
17
+ export function servedUrl(issuer, path) {
18
+ const admitted = admitIssuer(issuer);
19
+ let value;
20
+ try {
21
+ value = new URL(admitted);
22
+ }
23
+ catch (cause) {
24
+ return fail('RELEASE_INVALID', 'Release issuer is not an HTTP(S) URL.', cause);
25
+ }
26
+ if ((value.protocol !== 'https:' && value.protocol !== 'http:') ||
27
+ value.username !== '' ||
28
+ value.password !== '' ||
29
+ value.search !== '' ||
30
+ value.hash !== '') {
31
+ fail('RELEASE_INVALID', 'Release issuer is not an HTTP(S) URL.');
32
+ }
33
+ return `${admitted.replace(/\/+$/u, '')}${path}`;
34
+ }
@@ -0,0 +1,14 @@
1
+ import * as bindings from '../bindings/index.js';
2
+ /** @deprecated Use `CallableBinding` from `@astrale-os/kernel-protocol/release`. */
3
+ export type CallableBinding = bindings.CallableBinding;
4
+ /** @deprecated Use `ViewBinding` from `@astrale-os/kernel-protocol/release`. */
5
+ export type ViewBinding = bindings.ViewBinding;
6
+ /** @deprecated Use `InvocationEndpoints` from `@astrale-os/kernel-protocol/release`. */
7
+ export type InvocationEndpoints = bindings.InvocationEndpoints;
8
+ /**
9
+ * Admit the complete HTTP/WebSocket endpoint pair shared by Publication and redirect routing.
10
+ *
11
+ * @deprecated Use `acceptInvocationEndpoints` from `@astrale-os/kernel-protocol/release`, which
12
+ * reports `ReleaseError`.
13
+ */
14
+ export declare function acceptInvocationEndpoints(input: unknown): InvocationEndpoints;
@@ -0,0 +1,11 @@
1
+ import * as bindings from '../bindings/index.js';
2
+ import { withPublicationError } from './error.js';
3
+ /**
4
+ * Admit the complete HTTP/WebSocket endpoint pair shared by Publication and redirect routing.
5
+ *
6
+ * @deprecated Use `acceptInvocationEndpoints` from `@astrale-os/kernel-protocol/release`, which
7
+ * reports `ReleaseError`.
8
+ */
9
+ export function acceptInvocationEndpoints(input) {
10
+ return withPublicationError(() => bindings.acceptInvocationEndpoints(input));
11
+ }
@@ -0,0 +1,6 @@
1
+ import type * as dslBundle from '@astrale-os/kernel-dsl/v1/bundle';
2
+ import type { Publication } from './publication.js';
3
+ /** @deprecated Use `acceptBundle` from `@astrale-os/kernel-protocol/release`, which reports `ReleaseError`. */
4
+ export declare function acceptBundle(input: Publication, artifact: unknown): dslBundle.Bundle;
5
+ /** @deprecated Use `decodeBundle` from `@astrale-os/kernel-protocol/release`, which reports `ReleaseError`. */
6
+ export declare function decodeBundle(input: Publication, bytes: Uint8Array): dslBundle.Bundle;
@@ -0,0 +1,10 @@
1
+ import * as admission from '../bundle-admission.js';
2
+ import { withPublicationError } from './error.js';
3
+ /** @deprecated Use `acceptBundle` from `@astrale-os/kernel-protocol/release`, which reports `ReleaseError`. */
4
+ export function acceptBundle(input, artifact) {
5
+ return withPublicationError(() => admission.acceptBundle(input, artifact));
6
+ }
7
+ /** @deprecated Use `decodeBundle` from `@astrale-os/kernel-protocol/release`, which reports `ReleaseError`. */
8
+ export function decodeBundle(input, bytes) {
9
+ return withPublicationError(() => admission.decodeBundle(input, bytes));
10
+ }
@@ -0,0 +1,8 @@
1
+ import type { Publication } from './publication.js';
2
+ /**
3
+ * Verify exact artifact bytes without decoding an authored Schema Bundle.
4
+ *
5
+ * @deprecated Use `verifyBundleBytes` from `@astrale-os/kernel-protocol/release/bundle-evidence`,
6
+ * which reports `ReleaseError`.
7
+ */
8
+ export declare function verifyBundleBytes(publication: Publication, bytes: Uint8Array): void;
@@ -0,0 +1,11 @@
1
+ import * as evidence from '../bundle-evidence.js';
2
+ import { withPublicationError } from './error.js';
3
+ /**
4
+ * Verify exact artifact bytes without decoding an authored Schema Bundle.
5
+ *
6
+ * @deprecated Use `verifyBundleBytes` from `@astrale-os/kernel-protocol/release/bundle-evidence`,
7
+ * which reports `ReleaseError`.
8
+ */
9
+ export function verifyBundleBytes(publication, bytes) {
10
+ withPublicationError(() => evidence.verifyBundleBytes(publication, bytes));
11
+ }
@@ -0,0 +1,24 @@
1
+ import type * as transport from '@astrale-os/kernel-dsl/v1/bundle/transport';
2
+ import type * as artifact from '../../artifact/index.js';
3
+ import type { Publication } from './publication.js';
4
+ import * as descriptor from '../bundle-descriptor.js';
5
+ export { verifyBundleBytes } from './bundle-evidence.js';
6
+ /** @deprecated Use `BUNDLE_MEDIA_TYPE` from `@astrale-os/kernel-protocol/release/bundle`. */
7
+ export declare const BUNDLE_MEDIA_TYPE: "application/vnd.astrale.domain-bundle+json;v=1";
8
+ /** @deprecated Use `BundleDescriptor` from `@astrale-os/kernel-protocol/release/bundle`. */
9
+ export type BundleDescriptor = descriptor.BundleDescriptor;
10
+ /**
11
+ * Resolve immutable bundle bytes beneath the exact serving issuer.
12
+ *
13
+ * @deprecated Use `bundleUrl` from `@astrale-os/kernel-protocol/release/bundle`, which reports
14
+ * `ReleaseError`.
15
+ */
16
+ export declare function bundleUrl(issuer: string, ref: artifact.Ref): string;
17
+ /** @deprecated Use `describeBundle` from `@astrale-os/kernel-protocol/release/bundle`. */
18
+ export declare function describeBundle(input: transport.Bundle, href: string): BundleDescriptor;
19
+ /** @deprecated Use `acceptBundleValue` from `@astrale-os/kernel-protocol/release/bundle`. */
20
+ export declare function acceptBundleValue(input: unknown): transport.Bundle;
21
+ /** @deprecated Use `decodeBundleValue` from `@astrale-os/kernel-protocol/release/bundle`. */
22
+ export declare function decodeBundleValue(publication: Publication, bytes: Uint8Array): transport.Bundle;
23
+ /** @deprecated Use `admitBundleDescriptor` from `@astrale-os/kernel-protocol/release/bundle`. */
24
+ export declare function admitBundleDescriptor(input: unknown): BundleDescriptor;