@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
@@ -0,0 +1,28 @@
1
+ import { accept as acceptValue, defaultLimits } from '@astrale-os/kernel-dsl/value';
2
+ import { accept } from '../codec.js';
3
+ import { decode as decodeMessagePack } from './msgpack.js';
4
+ /** @deprecated Read-only: Hosts older than beta.127 serve this; current Hosts serve `installation.MEDIA_TYPE`. */
5
+ export const MEDIA_TYPE = 'application/vnd.astrale.schema-installation.v1+msgpack';
6
+ /**
7
+ * Decode version-one (MessagePack) installation evidence into the canonical result.
8
+ *
9
+ * @deprecated Read-only; use `installation.decode` with `installation.MEDIA_TYPE`.
10
+ */
11
+ export async function decode(bytes, maximumBytes) {
12
+ if (!(bytes instanceof Uint8Array) ||
13
+ !Number.isSafeInteger(maximumBytes) ||
14
+ maximumBytes < 1 ||
15
+ bytes.byteLength > maximumBytes) {
16
+ throw new TypeError('Schema installation evidence is invalid or exceeds its bound.');
17
+ }
18
+ let value;
19
+ try {
20
+ value = acceptValue(decodeMessagePack(bytes, defaultLimits.maxDepth), {
21
+ limits: { maxBytes: maximumBytes },
22
+ });
23
+ }
24
+ catch (cause) {
25
+ throw new TypeError('Schema installation evidence is malformed.', { cause });
26
+ }
27
+ return accept(value);
28
+ }
@@ -0,0 +1,10 @@
1
+ import type { introspection } from '@astrale-os/kernel-core/schema';
2
+ import type { Limits, ResultFor } from '../introspection/result.js';
3
+ /** @deprecated Read-only: Hosts older than beta.127 serve this; current Hosts serve `introspection.MEDIA_TYPE`. */
4
+ export declare const MEDIA_TYPE: 'application/vnd.astrale.schema-introspection.v2+msgpack';
5
+ /**
6
+ * Decode version-two (MessagePack) introspection evidence into the canonical result.
7
+ *
8
+ * @deprecated Read-only; use `introspection.decode` with `introspection.MEDIA_TYPE`.
9
+ */
10
+ export declare function decode<Input extends introspection.Introspection>(input: Input, bytes: Uint8Array, limits: Limits): Promise<ResultFor<Input>>;
@@ -0,0 +1,70 @@
1
+ import { accept as acceptValue, defaultLimits } from '@astrale-os/kernel-dsl/value';
2
+ import { acceptEvidence, admitLimits, admitRequest } from '../introspection/codec.js';
3
+ import { decode as decodeMessagePack } from './msgpack.js';
4
+ /** @deprecated Read-only: Hosts older than beta.127 serve this; current Hosts serve `introspection.MEDIA_TYPE`. */
5
+ export const MEDIA_TYPE = 'application/vnd.astrale.schema-introspection.v2+msgpack';
6
+ const utf8 = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true });
7
+ /**
8
+ * Decode version-two (MessagePack) introspection evidence into the canonical result.
9
+ *
10
+ * @deprecated Read-only; use `introspection.decode` with `introspection.MEDIA_TYPE`.
11
+ */
12
+ export async function decode(input, bytes, limits) {
13
+ const request = admitRequest(input);
14
+ if (!(bytes instanceof Uint8Array))
15
+ invalid('Schema introspection evidence must be binary.');
16
+ admitLimits(request, limits);
17
+ // Version two carried the Bundle as raw bytes: no escaping allowance.
18
+ const maximumEvidenceBytes = limits.maximumPublicationBytes +
19
+ (request.kind === 'bundle' ? limits.maximumBundleBytes : 0) +
20
+ 4_096;
21
+ if (bytes.byteLength > maximumEvidenceBytes) {
22
+ invalid('Schema introspection evidence exceeds its declared bounds.');
23
+ }
24
+ let wire;
25
+ try {
26
+ wire = decodeMessagePack(bytes, defaultLimits.maxDepth);
27
+ }
28
+ catch (cause) {
29
+ throw new TypeError('Schema introspection evidence is malformed.', { cause });
30
+ }
31
+ if (request.kind === 'bundle')
32
+ wire = bundleAsText(wire);
33
+ let decoded;
34
+ try {
35
+ decoded = acceptValue(wire, {
36
+ limits: {
37
+ maxBytes: maximumEvidenceBytes,
38
+ ...(request.kind === 'bundle' ? { maxStringBytes: limits.maximumBundleBytes } : {}),
39
+ },
40
+ });
41
+ }
42
+ catch (cause) {
43
+ throw new TypeError('Schema introspection evidence is malformed.', { cause });
44
+ }
45
+ return acceptEvidence(request, decoded, limits);
46
+ }
47
+ /**
48
+ * Version two carried the Bundle as the UTF-8 bytes of its canonical JSON; the current wire value
49
+ * carries that JSON as text. Translate only that field; every other check stays canonical.
50
+ */
51
+ function bundleAsText(wire) {
52
+ if (wire === null || typeof wire !== 'object' || Array.isArray(wire))
53
+ return wire;
54
+ if (!Object.hasOwn(wire, 'bundle'))
55
+ return wire;
56
+ const { bundle } = wire;
57
+ if (!(bundle instanceof Uint8Array))
58
+ invalid('Bundle evidence is invalid or exceeds its bound.');
59
+ let text;
60
+ try {
61
+ text = utf8.decode(bundle);
62
+ }
63
+ catch (cause) {
64
+ throw new TypeError('Installed Domain Bundle is invalid.', { cause });
65
+ }
66
+ return { ...wire, bundle: text };
67
+ }
68
+ function invalid(message) {
69
+ throw new TypeError(message);
70
+ }
@@ -0,0 +1 @@
1
+ export declare function decode(bytes: Uint8Array, maximumDepth: number): unknown;
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Frozen, read-only MessagePack decoder for the schema evidence of Hosts older than beta.127.
3
+ *
4
+ * It reads the families that msgpackr 2.0.5 `pack` (`useRecords: false`) wrote for that evidence:
5
+ * nil, booleans, integers, floats, strings, binary, arrays and string-keyed maps. Extension types
6
+ * (msgpackr records and `undefined`, timestamps, structured clones) never occur in it and are
7
+ * rejected, as are truncated input, trailing bytes, invalid UTF-8, non-string or duplicate map keys,
8
+ * integers outside the safe range, and nesting deeper than `maximumDepth`. It never encodes.
9
+ */
10
+ const utf8 = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true });
11
+ export function decode(bytes, maximumDepth) {
12
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
13
+ let position = 0;
14
+ const take = (length) => {
15
+ if (length > bytes.byteLength - position)
16
+ malformed('is truncated');
17
+ const start = position;
18
+ position += length;
19
+ return start;
20
+ };
21
+ const u8 = () => bytes[take(1)];
22
+ const u16 = () => view.getUint16(take(2));
23
+ const u32 = () => view.getUint32(take(4));
24
+ const text = (length) => {
25
+ const start = take(length);
26
+ return utf8.decode(bytes.subarray(start, start + length));
27
+ };
28
+ const binary = (length) => {
29
+ const start = take(length);
30
+ return bytes.slice(start, start + length);
31
+ };
32
+ const entries = (count, width) => {
33
+ // Every entry occupies at least one byte per item: refuse counts the input cannot hold.
34
+ if (count * width > bytes.byteLength - position)
35
+ malformed('declares more entries than it holds');
36
+ };
37
+ const nested = (depth) => {
38
+ if (depth >= maximumDepth)
39
+ malformed(`nests deeper than ${maximumDepth} containers`);
40
+ return depth + 1;
41
+ };
42
+ const array = (count, depth) => {
43
+ entries(count, 1);
44
+ const output = [];
45
+ for (let index = 0; index < count; index += 1)
46
+ output.push(value(depth));
47
+ return output;
48
+ };
49
+ const map = (count, depth) => {
50
+ entries(count, 2);
51
+ const output = {};
52
+ for (let index = 0; index < count; index += 1) {
53
+ const key = value(depth);
54
+ if (typeof key !== 'string')
55
+ malformed('has a non-string map key');
56
+ if (Object.hasOwn(output, key))
57
+ malformed('has a duplicate map key');
58
+ Object.defineProperty(output, key, {
59
+ value: value(depth),
60
+ enumerable: true,
61
+ writable: true,
62
+ configurable: true,
63
+ });
64
+ }
65
+ return output;
66
+ };
67
+ const integer = (input) => {
68
+ const output = Number(input);
69
+ if (!Number.isSafeInteger(output))
70
+ malformed('holds an integer outside the safe range');
71
+ return output;
72
+ };
73
+ function value(depth) {
74
+ const head = u8();
75
+ if (head <= 0x7f)
76
+ return head;
77
+ if (head >= 0xe0)
78
+ return head - 0x100;
79
+ if (head <= 0x8f)
80
+ return map(head & 0x0f, nested(depth));
81
+ if (head <= 0x9f)
82
+ return array(head & 0x0f, nested(depth));
83
+ if (head <= 0xbf)
84
+ return text(head & 0x1f);
85
+ switch (head) {
86
+ case 0xc0:
87
+ return null;
88
+ case 0xc2:
89
+ return false;
90
+ case 0xc3:
91
+ return true;
92
+ case 0xc4:
93
+ return binary(u8());
94
+ case 0xc5:
95
+ return binary(u16());
96
+ case 0xc6:
97
+ return binary(u32());
98
+ case 0xca:
99
+ return view.getFloat32(take(4));
100
+ case 0xcb:
101
+ return view.getFloat64(take(8));
102
+ case 0xcc:
103
+ return u8();
104
+ case 0xcd:
105
+ return u16();
106
+ case 0xce:
107
+ return u32();
108
+ case 0xcf:
109
+ return integer(view.getBigUint64(take(8)));
110
+ case 0xd0:
111
+ return view.getInt8(take(1));
112
+ case 0xd1:
113
+ return view.getInt16(take(2));
114
+ case 0xd2:
115
+ return view.getInt32(take(4));
116
+ case 0xd3:
117
+ return integer(view.getBigInt64(take(8)));
118
+ case 0xd9:
119
+ return text(u8());
120
+ case 0xda:
121
+ return text(u16());
122
+ case 0xdb:
123
+ return text(u32());
124
+ case 0xdc:
125
+ return array(u16(), nested(depth));
126
+ case 0xdd:
127
+ return array(u32(), nested(depth));
128
+ case 0xde:
129
+ return map(u16(), nested(depth));
130
+ case 0xdf:
131
+ return map(u32(), nested(depth));
132
+ default:
133
+ return malformed(`uses the unsupported type 0x${head.toString(16)}`);
134
+ }
135
+ }
136
+ const output = value(0);
137
+ if (position !== bytes.byteLength)
138
+ malformed('has trailing bytes');
139
+ return output;
140
+ }
141
+ function malformed(reason) {
142
+ throw new TypeError(`MessagePack evidence ${reason}.`);
143
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrale-os/kernel-protocol",
3
- "version": "0.5.0-beta.66",
3
+ "version": "0.5.0-beta.68",
4
4
  "description": "Portable Astrale invocation, publication, installation, routing, and issuer protocols",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -47,6 +47,10 @@
47
47
  "types": "./dist/issuer/paths.d.ts",
48
48
  "import": "./dist/issuer/paths.js"
49
49
  },
50
+ "./issuer/workflow-engine": {
51
+ "types": "./dist/issuer/workflow-engine.d.ts",
52
+ "import": "./dist/issuer/workflow-engine.js"
53
+ },
50
54
  "./invocation": {
51
55
  "types": "./dist/invocation/index.d.ts",
52
56
  "import": "./dist/invocation/index.js"
@@ -60,40 +64,60 @@
60
64
  "import": "./dist/artifact/index.js"
61
65
  },
62
66
  "./publication": {
63
- "types": "./dist/publication/index.d.ts",
64
- "import": "./dist/publication/index.js"
67
+ "types": "./dist/release/legacy/index.d.ts",
68
+ "import": "./dist/release/legacy/index.js"
65
69
  },
66
70
  "./publication/publication": {
67
- "types": "./dist/publication/publication.d.ts",
68
- "import": "./dist/publication/publication.js"
71
+ "types": "./dist/release/legacy/publication.d.ts",
72
+ "import": "./dist/release/legacy/publication.js"
69
73
  },
70
74
  "./publication/reference": {
71
- "types": "./dist/publication/reference.d.ts",
72
- "import": "./dist/publication/reference.js"
75
+ "types": "./dist/release/legacy/reference.d.ts",
76
+ "import": "./dist/release/legacy/reference.js"
73
77
  },
74
78
  "./publication/requirements": {
75
- "types": "./dist/publication/requirements.d.ts",
76
- "import": "./dist/publication/requirements.js"
79
+ "types": "./dist/release/legacy/requirements.d.ts",
80
+ "import": "./dist/release/legacy/requirements.js"
77
81
  },
78
82
  "./publication/legacy-requirements": {
79
- "types": "./dist/publication/legacy-requirements.d.ts",
80
- "import": "./dist/publication/legacy-requirements.js"
81
- },
82
- "./publication/delivery": {
83
- "types": "./dist/publication/delivery/index.d.ts",
84
- "import": "./dist/publication/delivery/index.js"
83
+ "types": "./dist/release/legacy/profiles.d.ts",
84
+ "import": "./dist/release/legacy/profiles.js"
85
85
  },
86
86
  "./publication/bundle": {
87
- "types": "./dist/publication/bundle.d.ts",
88
- "import": "./dist/publication/bundle.js"
87
+ "types": "./dist/release/legacy/bundle.d.ts",
88
+ "import": "./dist/release/legacy/bundle.js"
89
89
  },
90
90
  "./publication/bundle-evidence": {
91
- "types": "./dist/publication/bundle-evidence.d.ts",
92
- "import": "./dist/publication/bundle-evidence.js"
91
+ "types": "./dist/release/legacy/bundle-evidence.d.ts",
92
+ "import": "./dist/release/legacy/bundle-evidence.js"
93
+ },
94
+ "./release": {
95
+ "types": "./dist/release/index.d.ts",
96
+ "import": "./dist/release/index.js"
97
+ },
98
+ "./release/bundle": {
99
+ "types": "./dist/release/bundle.d.ts",
100
+ "import": "./dist/release/bundle.js"
101
+ },
102
+ "./release/bundle-evidence": {
103
+ "types": "./dist/release/bundle-evidence.d.ts",
104
+ "import": "./dist/release/bundle-evidence.js"
105
+ },
106
+ "./release/delivery": {
107
+ "types": "./dist/release/delivery/index.d.ts",
108
+ "import": "./dist/release/delivery/index.js"
93
109
  },
94
- "./publication/delivery-declaration": {
95
- "types": "./dist/publication/delivery-declaration.d.ts",
96
- "import": "./dist/publication/delivery-declaration.js"
110
+ "./release/delivery-declaration": {
111
+ "types": "./dist/release/delivery-declaration.d.ts",
112
+ "import": "./dist/release/delivery-declaration.js"
113
+ },
114
+ "./release/legacy": {
115
+ "types": "./dist/release/legacy/index.d.ts",
116
+ "import": "./dist/release/legacy/index.js"
117
+ },
118
+ "./release/requirements": {
119
+ "types": "./dist/release/requirements.d.ts",
120
+ "import": "./dist/release/requirements.js"
97
121
  },
98
122
  "./routes": {
99
123
  "types": "./dist/routes/index.d.ts",
@@ -103,6 +127,10 @@
103
127
  "types": "./dist/schema/index.d.ts",
104
128
  "import": "./dist/schema/index.js"
105
129
  },
130
+ "./schema/installation/legacy": {
131
+ "types": "./dist/schema/installation/legacy/index.d.ts",
132
+ "import": "./dist/schema/installation/legacy/index.js"
133
+ },
106
134
  "./routes/admission": {
107
135
  "types": "./dist/routes/admission.d.ts",
108
136
  "import": "./dist/routes/admission.js"
@@ -119,9 +147,13 @@
119
147
  "types": "./dist/routes/placement.d.ts",
120
148
  "import": "./dist/routes/placement.js"
121
149
  },
122
- "./routes/release-unavailable": {
123
- "types": "./dist/routes/release-unavailable.d.ts",
124
- "import": "./dist/routes/release-unavailable.js"
150
+ "./routes/deployment-retired": {
151
+ "types": "./dist/routes/deployment-retired.d.ts",
152
+ "import": "./dist/routes/deployment-retired.js"
153
+ },
154
+ "./routes/legacy": {
155
+ "types": "./dist/routes/legacy/index.d.ts",
156
+ "import": "./dist/routes/legacy/index.js"
125
157
  },
126
158
  "./routes/routing": {
127
159
  "types": "./dist/routes/routing.d.ts",
@@ -137,24 +169,15 @@
137
169
  "access": "public"
138
170
  },
139
171
  "dependencies": {
140
- "@astrale-os/kernel-core": "0.9.0-beta.60",
141
- "@astrale-os/kernel-dsl": "0.2.0-beta.43",
172
+ "@astrale-os/kernel-core": "0.9.0-beta.62",
173
+ "@astrale-os/kernel-dsl": "0.2.0-beta.44",
142
174
  "@noble/hashes": "2.3.0"
143
175
  },
144
176
  "devDependencies": {
145
177
  "@astrale/typescript-config": "npm:@jsr/astrale__typescript-config@~1.1.0",
146
- "msgpackr": "^2.0.5",
147
178
  "typescript": "7.0.2",
148
179
  "vitest": "^5.0.1"
149
180
  },
150
- "peerDependencies": {
151
- "msgpackr": "^2.0.5"
152
- },
153
- "peerDependenciesMeta": {
154
- "msgpackr": {
155
- "optional": true
156
- }
157
- },
158
181
  "scripts": {
159
182
  "build": "tsc",
160
183
  "clean": "rm -rf dist",
@@ -1,4 +0,0 @@
1
- import type { Codec } from './codec.js';
2
- export declare function loadMsgpack(): Promise<Codec>;
3
- /** Package-private canonical identity check used by Protocol binding selection. */
4
- export declare function isMsgpackCodec(input: Codec): boolean;
@@ -1,53 +0,0 @@
1
- import { accept as acceptValue, BoundaryError } from '@astrale-os/kernel-dsl/value';
2
- import { DecodeError } from './codec.js';
3
- import { CONTENT_TYPE_MSGPACK } from './media-types.js';
4
- let library = null;
5
- export async function loadMsgpack() {
6
- if (library === null) {
7
- // `as string` keeps TypeScript from pulling msgpackr's declarations, which assume
8
- // `@types/node`, into consumer programs. The assertion is erased on emit, so bundlers
9
- // still see literal specifiers; a variable would leave them unresolvable.
10
- const [packing, unpacking] = await Promise.all([
11
- import('msgpackr/pack'),
12
- import('msgpackr'),
13
- ]);
14
- library = Object.freeze({ pack: packing.pack, unpack: unpacking.unpack });
15
- }
16
- return MSGPACK;
17
- }
18
- const MSGPACK = Object.freeze({
19
- name: 'msgpack',
20
- contentType: CONTENT_TYPE_MSGPACK,
21
- binary: true,
22
- encode(data) {
23
- if (library === null)
24
- throw new Error('MsgPack codec is not loaded');
25
- return new Uint8Array(library.pack(acceptValue(data)));
26
- },
27
- decode(input) {
28
- if (library === null)
29
- throw new Error('MsgPack codec is not loaded');
30
- if (typeof input === 'string')
31
- throw new TypeError('MsgPack requires a binary envelope');
32
- let decoded;
33
- try {
34
- decoded = library.unpack(input);
35
- }
36
- catch (cause) {
37
- throw new DecodeError('MsgPack envelope is malformed.', { cause });
38
- }
39
- try {
40
- return acceptValue(decoded);
41
- }
42
- catch (cause) {
43
- if (cause instanceof BoundaryError) {
44
- throw new DecodeError('MsgPack envelope is not a portable value.', { cause });
45
- }
46
- throw cause;
47
- }
48
- },
49
- });
50
- /** Package-private canonical identity check used by Protocol binding selection. */
51
- export function isMsgpackCodec(input) {
52
- return input === MSGPACK;
53
- }
@@ -1,13 +0,0 @@
1
- import { absoluteHttpUrl, absoluteUrl, exact, record } from '../content.js';
2
- export function acceptInvocationEndpoints(input) {
3
- const value = record(input, 'PUBLICATION_BINDING_INVALID', 'Invocation endpoints are invalid.');
4
- exact(value, ['http', 'websocket'], 'PUBLICATION_BINDING_INVALID');
5
- const http = absoluteHttpUrl(value.http, true, 'PUBLICATION_BINDING_INVALID');
6
- const websocket = value.websocket === undefined
7
- ? undefined
8
- : absoluteUrl(value.websocket, ['ws:', 'wss:'], true, 'PUBLICATION_BINDING_INVALID');
9
- return Object.freeze({
10
- http,
11
- ...(websocket === undefined ? {} : { websocket }),
12
- });
13
- }
@@ -1,4 +0,0 @@
1
- import * as dslBundle from '@astrale-os/kernel-dsl/v1/bundle';
2
- import type { Publication } from './publication.js';
3
- export declare function acceptBundle(input: Publication, artifact: unknown): dslBundle.Bundle;
4
- export declare function decodeBundle(input: Publication, bytes: Uint8Array): dslBundle.Bundle;
@@ -1,3 +0,0 @@
1
- import type { Publication } from './publication.js';
2
- /** Verify exact artifact bytes without decoding an authored Schema Bundle. */
3
- export declare function verifyBundleBytes(publication: Publication, bytes: Uint8Array): void;
@@ -1,13 +0,0 @@
1
- import { fail } from './error.js';
2
- import { sha256Hex } from './etag.js';
3
- /** Verify exact artifact bytes without decoding an authored Schema Bundle. */
4
- export function verifyBundleBytes(publication, bytes) {
5
- if (!(bytes instanceof Uint8Array)) {
6
- fail('PUBLICATION_INVALID', 'Bundle artifact bytes are invalid.');
7
- }
8
- const descriptor = publication.schema.bundle;
9
- if (bytes.byteLength !== descriptor.ref.size ||
10
- `sha256:${sha256Hex(bytes)}` !== descriptor.ref.digest) {
11
- fail('PUBLICATION_INVALID', 'Bundle artifact does not match its descriptor.');
12
- }
13
- }
@@ -1,10 +0,0 @@
1
- import type { PublicationErrorCode } from './error.js';
2
- import type { Publication } from './publication.js';
3
- export type Content = Omit<Publication, 'etag'>;
4
- export declare function record(input: unknown, code: PublicationErrorCode, message: string): Record<string, unknown>;
5
- export declare function exact(value: Record<string, unknown>, allowed: readonly string[], code: PublicationErrorCode): void;
6
- export declare function array(input: unknown, code: PublicationErrorCode): readonly unknown[];
7
- export declare function unique(values: readonly string[], code: PublicationErrorCode, label: string): void;
8
- export declare function deepFreeze<T>(value: T): T;
9
- export declare function absoluteHttpUrl(input: unknown, allowSearch: boolean, code: PublicationErrorCode, allowTemplate?: boolean): string;
10
- export declare function absoluteUrl(input: unknown, protocols: readonly string[], allowSearch: boolean, code: PublicationErrorCode, allowTemplate?: boolean): string;
@@ -1,9 +0,0 @@
1
- import type { Publication } from '../publication.js';
2
- import type { Attestation } from './attestation.js';
3
- export interface Delivery {
4
- readonly format: 'astrale.domain.delivery';
5
- readonly version: 1;
6
- readonly publication: Publication;
7
- readonly attestation: Attestation;
8
- }
9
- export declare function accept(input: unknown): Delivery;
@@ -1,4 +0,0 @@
1
- export const PURPOSE = 'astrale.domain.delivery.v1';
2
- export const NONCE_MIN_LENGTH = 16;
3
- export const NONCE_MAX_LENGTH = 256;
4
- export const ATTESTATION_MAX_BYTES = 16_384;
@@ -1,15 +0,0 @@
1
- import { type IssuerId } from '@astrale-os/kernel-core/auth/issuer';
2
- import type { Etag } from '../etag.js';
3
- export interface Request {
4
- readonly version: 1;
5
- readonly kernel: IssuerId;
6
- readonly nonce: string;
7
- readonly etag: Etag;
8
- }
9
- /** Exact bearer credential admitted by a Delivery transport boundary. */
10
- export interface Token {
11
- readonly kind: 'bearer';
12
- readonly token: string;
13
- }
14
- /** Admit the exact request representation accepted by a Delivery transport boundary. */
15
- export declare function acceptRequest(input: unknown): Request;
@@ -1,22 +0,0 @@
1
- import { absoluteHttpUrl, exact, record } from './content.js';
2
- import { fail } from './error.js';
3
- export function admitEndpoint(input, publicUrl) {
4
- if (input === undefined)
5
- return undefined;
6
- const value = record(input, 'PUBLICATION_INVALID', 'Delivery endpoint is invalid.');
7
- exact(value, ['href', 'method', 'authentication'], 'PUBLICATION_INVALID');
8
- const href = absoluteHttpUrl(value.href, true, 'PUBLICATION_INVALID');
9
- if (new URL(href).origin !== new URL(publicUrl).origin || value.method !== 'POST') {
10
- fail('PUBLICATION_INVALID', 'Delivery endpoint must be same-origin POST.');
11
- }
12
- const authentication = record(value.authentication, 'PUBLICATION_INVALID', 'Delivery authentication is invalid.');
13
- exact(authentication, ['kind'], 'PUBLICATION_INVALID');
14
- if (authentication.kind !== 'public' && authentication.kind !== 'bearer') {
15
- fail('PUBLICATION_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
- }
@@ -1,7 +0,0 @@
1
- export type PublicationErrorCode = 'PUBLICATION_INVALID' | 'PUBLICATION_ETAG_MISMATCH' | 'PUBLICATION_BINDING_INVALID' | 'PUBLICATION_ROUTE_INVALID' | 'PUBLICATION_VIEW_INVALID';
2
- export declare class PublicationError extends Error {
3
- readonly code: PublicationErrorCode;
4
- readonly name = "PublicationError";
5
- constructor(code: PublicationErrorCode, message: string, options?: ErrorOptions);
6
- }
7
- export declare function fail(code: PublicationErrorCode, message: string, cause?: unknown): never;
@@ -1,11 +0,0 @@
1
- export class PublicationError extends Error {
2
- code;
3
- name = 'PublicationError';
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 PublicationError(code, message, cause === undefined ? undefined : { cause });
11
- }
@@ -1,6 +0,0 @@
1
- import type { Content } from './content.js';
2
- export type Sha256Digest = `sha256:${string}`;
3
- export type Etag = Sha256Digest;
4
- export declare function admitDigest(input: unknown): Sha256Digest;
5
- export declare function computeEtag(input: Content): Etag;
6
- export declare function sha256Hex(input: Uint8Array): string;
@@ -1,17 +0,0 @@
1
- export { MEDIA_TYPE, LEGACY_MEDIA_TYPE, mediaType, PATH, url, seal, accept, encode, type Publication, } from './publication.js';
2
- export { acceptBundle, decodeBundle } from './bundle-admission.js';
3
- export { BUNDLE_MEDIA_TYPE, bundleUrl, describeBundle, type BundleDescriptor } from './bundle.js';
4
- export { verifyBundleBytes } from './bundle-evidence.js';
5
- export type { Content } from './content.js';
6
- export type { Declaration, DeliveryDeclaration } from './declaration.js';
7
- export { placeDelivery } from './delivery-declaration.js';
8
- export type { Etag, Sha256Digest } from './etag.js';
9
- export { PublicationError, type PublicationErrorCode } from './error.js';
10
- export * as delivery from './delivery/index.js';
11
- export type { Authentication as DeliveryAuthentication, Endpoint as DeliveryEndpoint, } from './delivery-endpoint.js';
12
- export type { Manifest } from './manifest.js';
13
- export { ClassOperationOrder, admitRequirements, validateRequirements, type CapabilityAuthorityRequirements, type CoreCapabilityRequirement, type CapabilityRequirements, type ClassCapabilityRequirement, type ClassOperation, type NonEmpty, type PublicationRequirements, } from './requirements.js';
14
- export { acceptReference, compareReference, compareReferences, matchesReference, reference, type PublicationRef, type PublicationReferenceRelation, } from './reference.js';
15
- export type { BodyPick, CredentialSource, HttpMethod, HttpRoute, HttpRouteDeclaration, RouteBody, RouteHeaders, SingleCredentialSource, } from './route.js';
16
- export type { Schema } from './schema.js';
17
- export { acceptInvocationEndpoints, type CallableBinding, type IframeRequirements, type InvocationEndpoints, type ViewBinding, } from './bindings/index.js';
@@ -1,12 +0,0 @@
1
- import type { PublicationRequirements } from './requirements.js';
2
- /** Read the retired v2 wire coordinate without exposing it in canonical requirements. */
3
- export declare function decodeLegacyRequirements(input: unknown): PublicationRequirements;
4
- /** Preserve immutable v2 bytes and the historical installation-target digest vocabulary. */
5
- export declare function encodeLegacyRequirements(input: PublicationRequirements): Readonly<{
6
- capabilities: Readonly<{
7
- functions?: import("./requirements.js").NonEmpty<import("@astrale-os/kernel-dsl/v1").Key.Callable>;
8
- classes?: import("./requirements.js").NonEmpty<import("./requirements.js").ClassCapabilityRequirement>;
9
- authority?: import("./requirements.js").CapabilityAuthorityRequirements;
10
- profiles?: import("./requirements.js").NonEmpty<import("./requirements.js").CoreCapabilityRequirement> | undefined;
11
- }>;
12
- }>;