@astrale-os/kernel-server 0.4.16 → 0.5.0-beta.1

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 (305) hide show
  1. package/dist/capture.d.ts +3 -0
  2. package/dist/capture.d.ts.map +1 -0
  3. package/dist/capture.js +10 -0
  4. package/dist/capture.js.map +1 -0
  5. package/dist/cors/cors.d.ts +22 -0
  6. package/dist/cors/cors.d.ts.map +1 -0
  7. package/dist/cors/cors.js +136 -0
  8. package/dist/cors/cors.js.map +1 -0
  9. package/dist/cors/index.d.ts +3 -0
  10. package/dist/cors/index.d.ts.map +1 -0
  11. package/dist/cors/index.js +2 -0
  12. package/dist/cors/index.js.map +1 -0
  13. package/dist/cors/types.d.ts +12 -0
  14. package/dist/cors/types.d.ts.map +1 -0
  15. package/dist/cors/types.js +2 -0
  16. package/dist/cors/types.js.map +1 -0
  17. package/dist/errors/availability.d.ts +11 -0
  18. package/dist/errors/availability.d.ts.map +1 -0
  19. package/dist/errors/availability.js +15 -0
  20. package/dist/errors/availability.js.map +1 -0
  21. package/dist/errors/classify.d.ts +4 -0
  22. package/dist/errors/classify.d.ts.map +1 -0
  23. package/dist/errors/classify.js +254 -0
  24. package/dist/errors/classify.js.map +1 -0
  25. package/dist/errors/index.d.ts +5 -0
  26. package/dist/errors/index.d.ts.map +1 -0
  27. package/dist/errors/index.js +5 -0
  28. package/dist/errors/index.js.map +1 -0
  29. package/dist/errors/request-body.d.ts +8 -0
  30. package/dist/errors/request-body.d.ts.map +1 -0
  31. package/dist/errors/request-body.js +15 -0
  32. package/dist/errors/request-body.js.map +1 -0
  33. package/dist/errors/response-body.d.ts +5 -0
  34. package/dist/errors/response-body.d.ts.map +1 -0
  35. package/dist/errors/response-body.js +9 -0
  36. package/dist/errors/response-body.js.map +1 -0
  37. package/dist/index.d.ts +4 -11
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +3 -18
  40. package/dist/index.js.map +1 -1
  41. package/dist/installation/handler.d.ts +10 -0
  42. package/dist/installation/handler.d.ts.map +1 -0
  43. package/dist/installation/handler.js +126 -0
  44. package/dist/installation/handler.js.map +1 -0
  45. package/dist/installation/index.d.ts +3 -0
  46. package/dist/installation/index.d.ts.map +1 -0
  47. package/dist/installation/index.js +2 -0
  48. package/dist/installation/index.js.map +1 -0
  49. package/dist/installation/types.d.ts +12 -0
  50. package/dist/installation/types.d.ts.map +1 -0
  51. package/dist/installation/types.js +2 -0
  52. package/dist/installation/types.js.map +1 -0
  53. package/dist/invocation/context.d.ts +7 -0
  54. package/dist/invocation/context.d.ts.map +1 -0
  55. package/dist/invocation/context.js +62 -0
  56. package/dist/invocation/context.js.map +1 -0
  57. package/dist/invocation/index.d.ts +2 -2
  58. package/dist/invocation/index.d.ts.map +1 -1
  59. package/dist/invocation/index.js +1 -2
  60. package/dist/invocation/index.js.map +1 -1
  61. package/dist/invocation/types.d.ts +34 -0
  62. package/dist/invocation/types.d.ts.map +1 -0
  63. package/dist/invocation/types.js +2 -0
  64. package/dist/invocation/types.js.map +1 -0
  65. package/dist/issuer/index.d.ts +3 -0
  66. package/dist/issuer/index.d.ts.map +1 -0
  67. package/dist/issuer/index.js +2 -0
  68. package/dist/issuer/index.js.map +1 -0
  69. package/dist/issuer/routes.d.ts +13 -0
  70. package/dist/issuer/routes.d.ts.map +1 -0
  71. package/dist/issuer/routes.js +138 -0
  72. package/dist/issuer/routes.js.map +1 -0
  73. package/dist/issuer/types.d.ts +11 -0
  74. package/dist/issuer/types.d.ts.map +1 -0
  75. package/dist/issuer/types.js +2 -0
  76. package/dist/issuer/types.js.map +1 -0
  77. package/dist/lifecycle/active.d.ts +40 -0
  78. package/dist/lifecycle/active.d.ts.map +1 -0
  79. package/dist/lifecycle/active.js +200 -0
  80. package/dist/lifecycle/active.js.map +1 -0
  81. package/dist/lifecycle/index.d.ts +2 -0
  82. package/dist/lifecycle/index.d.ts.map +1 -0
  83. package/dist/lifecycle/index.js +2 -0
  84. package/dist/lifecycle/index.js.map +1 -0
  85. package/dist/publication/index.d.ts +3 -0
  86. package/dist/publication/index.d.ts.map +1 -0
  87. package/dist/publication/index.js +2 -0
  88. package/dist/publication/index.js.map +1 -0
  89. package/dist/publication/snapshot.d.ts +14 -0
  90. package/dist/publication/snapshot.d.ts.map +1 -0
  91. package/dist/publication/snapshot.js +30 -0
  92. package/dist/publication/snapshot.js.map +1 -0
  93. package/dist/publication/types.d.ts +19 -0
  94. package/dist/publication/types.d.ts.map +1 -0
  95. package/dist/publication/types.js +2 -0
  96. package/dist/publication/types.js.map +1 -0
  97. package/dist/routes/index.d.ts +2 -0
  98. package/dist/routes/index.d.ts.map +1 -0
  99. package/dist/routes/index.js +2 -0
  100. package/dist/routes/index.js.map +1 -0
  101. package/dist/routes/routes.d.ts +24 -0
  102. package/dist/routes/routes.d.ts.map +1 -0
  103. package/dist/routes/routes.js +438 -0
  104. package/dist/routes/routes.js.map +1 -0
  105. package/dist/server.d.ts +5 -0
  106. package/dist/server.d.ts.map +1 -0
  107. package/dist/server.js +226 -0
  108. package/dist/server.js.map +1 -0
  109. package/dist/transport/body.d.ts +5 -0
  110. package/dist/transport/body.d.ts.map +1 -0
  111. package/dist/transport/body.js +51 -0
  112. package/dist/transport/body.js.map +1 -0
  113. package/dist/transport/codecs.d.ts +5 -0
  114. package/dist/transport/codecs.d.ts.map +1 -0
  115. package/dist/transport/codecs.js +6 -0
  116. package/dist/transport/codecs.js.map +1 -0
  117. package/dist/transport/credential.d.ts +11 -0
  118. package/dist/transport/credential.d.ts.map +1 -0
  119. package/dist/transport/credential.js +29 -0
  120. package/dist/transport/credential.js.map +1 -0
  121. package/dist/transport/http/handler.d.ts +16 -0
  122. package/dist/transport/http/handler.d.ts.map +1 -0
  123. package/dist/transport/http/handler.js +170 -0
  124. package/dist/transport/http/handler.js.map +1 -0
  125. package/dist/transport/http/index.d.ts +3 -0
  126. package/dist/transport/http/index.d.ts.map +1 -0
  127. package/dist/transport/http/index.js +3 -0
  128. package/dist/transport/http/index.js.map +1 -0
  129. package/dist/transport/http/render.d.ts +29 -0
  130. package/dist/transport/http/render.d.ts.map +1 -0
  131. package/dist/transport/http/render.js +277 -0
  132. package/dist/transport/http/render.js.map +1 -0
  133. package/dist/transport/index.d.ts +10 -0
  134. package/dist/transport/index.d.ts.map +1 -0
  135. package/dist/transport/index.js +9 -0
  136. package/dist/transport/index.js.map +1 -0
  137. package/dist/transport/router.d.ts +5 -0
  138. package/dist/transport/router.d.ts.map +1 -0
  139. package/dist/transport/router.js +5 -0
  140. package/dist/transport/router.js.map +1 -0
  141. package/dist/transport/stream-error.d.ts +4 -0
  142. package/dist/transport/stream-error.d.ts.map +1 -0
  143. package/dist/transport/stream-error.js +14 -0
  144. package/dist/transport/stream-error.js.map +1 -0
  145. package/dist/transport/types.d.ts +29 -0
  146. package/dist/transport/types.d.ts.map +1 -0
  147. package/dist/transport/types.js +2 -0
  148. package/dist/transport/types.js.map +1 -0
  149. package/dist/transport/websocket/index.d.ts +3 -0
  150. package/dist/transport/websocket/index.d.ts.map +1 -0
  151. package/dist/transport/websocket/index.js +3 -0
  152. package/dist/transport/websocket/index.js.map +1 -0
  153. package/dist/transport/websocket/session.d.ts +19 -0
  154. package/dist/transport/websocket/session.d.ts.map +1 -0
  155. package/dist/transport/websocket/session.js +328 -0
  156. package/dist/transport/websocket/session.js.map +1 -0
  157. package/dist/transport/websocket/upgrade.d.ts +19 -0
  158. package/dist/transport/websocket/upgrade.d.ts.map +1 -0
  159. package/dist/transport/websocket/upgrade.js +46 -0
  160. package/dist/transport/websocket/upgrade.js.map +1 -0
  161. package/dist/types.d.ts +62 -0
  162. package/dist/types.d.ts.map +1 -0
  163. package/dist/types.js +2 -0
  164. package/dist/types.js.map +1 -0
  165. package/package.json +9 -11
  166. package/dist/app/create.d.ts +0 -48
  167. package/dist/app/create.d.ts.map +0 -1
  168. package/dist/app/create.js +0 -108
  169. package/dist/app/create.js.map +0 -1
  170. package/dist/app/index.d.ts +0 -4
  171. package/dist/app/index.d.ts.map +0 -1
  172. package/dist/app/index.js +0 -4
  173. package/dist/app/index.js.map +0 -1
  174. package/dist/app/multiplexed.d.ts +0 -53
  175. package/dist/app/multiplexed.d.ts.map +0 -1
  176. package/dist/app/multiplexed.js +0 -64
  177. package/dist/app/multiplexed.js.map +0 -1
  178. package/dist/app/ws-upgrade.d.ts +0 -34
  179. package/dist/app/ws-upgrade.d.ts.map +0 -1
  180. package/dist/app/ws-upgrade.js +0 -94
  181. package/dist/app/ws-upgrade.js.map +0 -1
  182. package/dist/capabilities/contract.d.ts +0 -8
  183. package/dist/capabilities/contract.d.ts.map +0 -1
  184. package/dist/capabilities/contract.js +0 -2
  185. package/dist/capabilities/contract.js.map +0 -1
  186. package/dist/capabilities/defer.d.ts +0 -4
  187. package/dist/capabilities/defer.d.ts.map +0 -1
  188. package/dist/capabilities/defer.js +0 -2
  189. package/dist/capabilities/defer.js.map +0 -1
  190. package/dist/capabilities/hono.d.ts +0 -8
  191. package/dist/capabilities/hono.d.ts.map +0 -1
  192. package/dist/capabilities/hono.js +0 -13
  193. package/dist/capabilities/hono.js.map +0 -1
  194. package/dist/capabilities/index.d.ts +0 -6
  195. package/dist/capabilities/index.d.ts.map +0 -1
  196. package/dist/capabilities/index.js +0 -3
  197. package/dist/capabilities/index.js.map +0 -1
  198. package/dist/capabilities/lifecycle.d.ts +0 -17
  199. package/dist/capabilities/lifecycle.d.ts.map +0 -1
  200. package/dist/capabilities/lifecycle.js +0 -37
  201. package/dist/capabilities/lifecycle.js.map +0 -1
  202. package/dist/capabilities/sleep.d.ts +0 -4
  203. package/dist/capabilities/sleep.d.ts.map +0 -1
  204. package/dist/capabilities/sleep.js +0 -8
  205. package/dist/capabilities/sleep.js.map +0 -1
  206. package/dist/cors.d.ts +0 -21
  207. package/dist/cors.d.ts.map +0 -1
  208. package/dist/cors.js +0 -17
  209. package/dist/cors.js.map +0 -1
  210. package/dist/envelope/batch.d.ts +0 -13
  211. package/dist/envelope/batch.d.ts.map +0 -1
  212. package/dist/envelope/batch.js +0 -96
  213. package/dist/envelope/batch.js.map +0 -1
  214. package/dist/envelope/codec.d.ts +0 -26
  215. package/dist/envelope/codec.d.ts.map +0 -1
  216. package/dist/envelope/codec.js +0 -52
  217. package/dist/envelope/codec.js.map +0 -1
  218. package/dist/envelope/credential.d.ts +0 -20
  219. package/dist/envelope/credential.d.ts.map +0 -1
  220. package/dist/envelope/credential.js +0 -32
  221. package/dist/envelope/credential.js.map +0 -1
  222. package/dist/envelope/http.d.ts +0 -31
  223. package/dist/envelope/http.d.ts.map +0 -1
  224. package/dist/envelope/http.js +0 -132
  225. package/dist/envelope/http.js.map +0 -1
  226. package/dist/envelope/sse.d.ts +0 -11
  227. package/dist/envelope/sse.d.ts.map +0 -1
  228. package/dist/envelope/sse.js +0 -73
  229. package/dist/envelope/sse.js.map +0 -1
  230. package/dist/envelope/ws.d.ts +0 -35
  231. package/dist/envelope/ws.d.ts.map +0 -1
  232. package/dist/envelope/ws.js +0 -142
  233. package/dist/envelope/ws.js.map +0 -1
  234. package/dist/invocation/dispatch.d.ts +0 -32
  235. package/dist/invocation/dispatch.d.ts.map +0 -1
  236. package/dist/invocation/dispatch.js +0 -68
  237. package/dist/invocation/dispatch.js.map +0 -1
  238. package/dist/invocation/dispatcher.d.ts +0 -19
  239. package/dist/invocation/dispatcher.d.ts.map +0 -1
  240. package/dist/invocation/dispatcher.js +0 -9
  241. package/dist/invocation/dispatcher.js.map +0 -1
  242. package/dist/jwks/discovery.d.ts +0 -40
  243. package/dist/jwks/discovery.d.ts.map +0 -1
  244. package/dist/jwks/discovery.js +0 -113
  245. package/dist/jwks/discovery.js.map +0 -1
  246. package/dist/jwks/index.d.ts +0 -3
  247. package/dist/jwks/index.d.ts.map +0 -1
  248. package/dist/jwks/index.js +0 -3
  249. package/dist/jwks/index.js.map +0 -1
  250. package/dist/jwks/issuers.d.ts +0 -47
  251. package/dist/jwks/issuers.d.ts.map +0 -1
  252. package/dist/jwks/issuers.js +0 -76
  253. package/dist/jwks/issuers.js.map +0 -1
  254. package/dist/jwks/keys.d.ts +0 -44
  255. package/dist/jwks/keys.d.ts.map +0 -1
  256. package/dist/jwks/keys.js +0 -56
  257. package/dist/jwks/keys.js.map +0 -1
  258. package/dist/plan/host-params.d.ts +0 -13
  259. package/dist/plan/host-params.d.ts.map +0 -1
  260. package/dist/plan/host-params.js +0 -23
  261. package/dist/plan/host-params.js.map +0 -1
  262. package/dist/plan/host.d.ts +0 -24
  263. package/dist/plan/host.d.ts.map +0 -1
  264. package/dist/plan/host.js +0 -24
  265. package/dist/plan/host.js.map +0 -1
  266. package/dist/plan/index.d.ts +0 -4
  267. package/dist/plan/index.d.ts.map +0 -1
  268. package/dist/plan/index.js +0 -4
  269. package/dist/plan/index.js.map +0 -1
  270. package/dist/plan/walk.d.ts +0 -51
  271. package/dist/plan/walk.d.ts.map +0 -1
  272. package/dist/plan/walk.js +0 -110
  273. package/dist/plan/walk.js.map +0 -1
  274. package/dist/render/binary.d.ts +0 -19
  275. package/dist/render/binary.d.ts.map +0 -1
  276. package/dist/render/binary.js +0 -33
  277. package/dist/render/binary.js.map +0 -1
  278. package/dist/render/body.d.ts +0 -10
  279. package/dist/render/body.d.ts.map +0 -1
  280. package/dist/render/body.js +0 -17
  281. package/dist/render/body.js.map +0 -1
  282. package/dist/render/index.d.ts +0 -3
  283. package/dist/render/index.d.ts.map +0 -1
  284. package/dist/render/index.js +0 -3
  285. package/dist/render/index.js.map +0 -1
  286. package/dist/routed/credential.d.ts +0 -10
  287. package/dist/routed/credential.d.ts.map +0 -1
  288. package/dist/routed/credential.js +0 -55
  289. package/dist/routed/credential.js.map +0 -1
  290. package/dist/routed/handler.d.ts +0 -38
  291. package/dist/routed/handler.d.ts.map +0 -1
  292. package/dist/routed/handler.js +0 -123
  293. package/dist/routed/handler.js.map +0 -1
  294. package/dist/routed/index.d.ts +0 -5
  295. package/dist/routed/index.d.ts.map +0 -1
  296. package/dist/routed/index.js +0 -5
  297. package/dist/routed/index.js.map +0 -1
  298. package/dist/routed/params.d.ts +0 -40
  299. package/dist/routed/params.d.ts.map +0 -1
  300. package/dist/routed/params.js +0 -146
  301. package/dist/routed/params.js.map +0 -1
  302. package/dist/routed/stream.d.ts +0 -21
  303. package/dist/routed/stream.d.ts.map +0 -1
  304. package/dist/routed/stream.js +0 -69
  305. package/dist/routed/stream.js.map +0 -1
@@ -1,142 +0,0 @@
1
- /**
2
- * Kernel envelope WS connection — universal RPC envelope over WebSockets.
3
- *
4
- * Each frame is a kernel envelope. Codec is fixed for the lifetime of the
5
- * connection (negotiated at upgrade via `?codec=`). Stream responses use
6
- * kernel stream framing (`{stream:{id,index,data}}`). Per-message credentials
7
- * live in the top-level `creds` field.
8
- *
9
- * Binary output mode is partially supported: small Uint8Array bodies are
10
- * delivered as a single stream chunk + end frame; ReadableStream bodies are
11
- * marked TODO and rejected with INTERNAL_ERROR for now.
12
- */
13
- import { KERNEL_ERROR_CODES, classifyError, decodeKernelRequest, encodeKernelError, encodeKernelRedirect, encodeKernelResponse, encodeStreamChunk, encodeStreamEnd, encodeStreamError, isBinaryResult, } from '@astrale-os/kernel-api';
14
- import { dispatchInvocation } from '../invocation/index.js';
15
- const WS_OPEN = 1;
16
- // ─── Connection ─────────────────────────────────────────────────────────────
17
- export class KernelWsConnection {
18
- ws;
19
- codec;
20
- dispatcher;
21
- host;
22
- constructor(ws, codec, dispatcher, host) {
23
- this.ws = ws;
24
- this.codec = codec;
25
- this.dispatcher = dispatcher;
26
- this.host = host;
27
- }
28
- start() {
29
- /* no-op — protocol-level ping handled by transport */
30
- }
31
- handleMessage(data) {
32
- this.processMessage(data).catch((err) => {
33
- // oxlint-disable-next-line no-console
34
- console.error('[ws] message handler crashed:', err);
35
- });
36
- }
37
- async processMessage(data) {
38
- // 1. Decode codec frame
39
- let raw;
40
- try {
41
- const input = typeof data === 'string' ? data : data instanceof Uint8Array ? data : new Uint8Array(data);
42
- raw = this.codec.decode(input);
43
- }
44
- catch {
45
- this.sendFrame(encodeKernelError(null, {
46
- code: KERNEL_ERROR_CODES.PARSE_ERROR,
47
- message: 'Parse error',
48
- }));
49
- return;
50
- }
51
- // 2. Decode envelope
52
- let request;
53
- try {
54
- request = decodeKernelRequest(raw);
55
- }
56
- catch (e) {
57
- this.sendFrame(encodeKernelError(null, {
58
- code: KERNEL_ERROR_CODES.INVALID_REQUEST,
59
- message: e instanceof Error ? e.message : 'Invalid request',
60
- }));
61
- return;
62
- }
63
- // 3. Credential — fixed `creds` top-level field on each frame.
64
- const cred = request.creds ?? '';
65
- // 4. Dispatch
66
- const isAck = request.id === undefined;
67
- const result = await dispatchInvocation(this.dispatcher, {
68
- path: request.method,
69
- credential: cred,
70
- params: request.params,
71
- ...(request.self === undefined ? {} : { self: request.self }),
72
- }, isAck ? { ack: true } : { id: request.id }, this.host);
73
- // 5. Send result
74
- switch (result.kind) {
75
- case 'ack':
76
- return;
77
- case 'success': {
78
- if (isBinaryResult(result.data)) {
79
- // Binary output over WS: only handle Uint8Array bodies inline.
80
- // ReadableStream / AsyncIterable bodies require duplex framing — TODO.
81
- const br = result.data;
82
- if (br.body instanceof Uint8Array) {
83
- // Frame as a stream chunk + end so the client knows it's the full body.
84
- // Use the kernel stream id semantics: id from request, single chunk.
85
- this.sendFrame(encodeStreamChunk(result.id, 0, {
86
- _binary: true,
87
- contentType: br.contentType,
88
- bytes: Array.from(br.body),
89
- }));
90
- this.sendFrame(encodeStreamEnd(result.id));
91
- }
92
- else {
93
- this.sendFrame(encodeKernelError(result.id, {
94
- code: KERNEL_ERROR_CODES.INTERNAL_ERROR,
95
- message: 'Streaming binary bodies over WS are not yet supported',
96
- }));
97
- }
98
- return;
99
- }
100
- this.sendFrame(encodeKernelResponse(result.id, result.data));
101
- return;
102
- }
103
- case 'error':
104
- this.sendFrame(encodeKernelError(result.id, result.error));
105
- return;
106
- case 'redirect':
107
- this.sendFrame(encodeKernelRedirect(result.id, result.redirection));
108
- return;
109
- case 'stream':
110
- await this.sendStream(result.id, result.generator);
111
- return;
112
- }
113
- }
114
- async sendStream(id, generator) {
115
- try {
116
- let index = 0;
117
- for await (const chunk of generator) {
118
- if (this.ws.readyState !== WS_OPEN)
119
- return;
120
- this.sendFrame(encodeStreamChunk(id, index++, chunk));
121
- }
122
- this.sendFrame(encodeStreamEnd(id));
123
- }
124
- catch (err) {
125
- const error = classifyError(err);
126
- this.sendFrame(encodeStreamError(id, error));
127
- }
128
- }
129
- sendFrame(obj) {
130
- if (this.ws.readyState !== WS_OPEN)
131
- return;
132
- this.ws.send(this.codec.encode(obj));
133
- }
134
- handleClose() {
135
- /* future: cancel in-flight dispatches */
136
- }
137
- handleError(error) {
138
- // oxlint-disable-next-line no-console
139
- console.error('[ws] connection error:', error.message);
140
- }
141
- }
142
- //# sourceMappingURL=ws.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ws.js","sourceRoot":"","sources":["../../envelope/ws.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,cAAc,GACf,MAAM,wBAAwB,CAAA;AAK/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAU3D,MAAM,OAAO,GAAG,CAAC,CAAA;AAEjB,+EAA+E;AAE/E,MAAM,OAAO,kBAAkB;IAEV,EAAE;IACF,KAAK;IACL,UAAU;IACV,IAAI;IAJvB,YACmB,EAAiB,EACjB,KAAY,EACZ,UAAsB,EACtB,IAAqB;kBAHrB,EAAE;qBACF,KAAK;0BACL,UAAU;oBACV,IAAI;IACpB,CAAC;IAEJ,KAAK;QACH,sDAAsD;IACxD,CAAC;IAED,aAAa,CAAC,IAAuC;QACnD,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACtC,sCAAs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,CAAC,GAAY;QAC5B,IAAI,IAAI,CAAC,EAAE,CAAC,UAAU,KAAK,OAAO;YAAE,OAAM;QAC1C,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;IACtC,CAAC;IAED,WAAW;QACT,yCAAyC;IAC3C,CAAC;IAED,WAAW,CAAC,KAAY;QACtB,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;IACxD,CAAC;CACF"}
@@ -1,32 +0,0 @@
1
- import type { CallRedirection, DispatchResult, KernelErrorPayload, RequestId } from '@astrale-os/kernel-api';
2
- import type { CapabilityHost } from '../capabilities/index.js';
3
- import type { Invocation, Dispatcher } from './dispatcher.js';
4
- export type InvocationResponse = {
5
- kind: 'success';
6
- id: RequestId;
7
- data: unknown;
8
- } | {
9
- kind: 'error';
10
- id: RequestId;
11
- error: KernelErrorPayload;
12
- } | {
13
- kind: 'stream';
14
- id: RequestId;
15
- generator: AsyncGenerator<unknown>;
16
- } | {
17
- kind: 'redirect';
18
- id: RequestId;
19
- redirection: CallRedirection;
20
- } | {
21
- kind: 'ack';
22
- };
23
- export type InvocationReply = {
24
- ack: true;
25
- } | {
26
- id: RequestId;
27
- };
28
- /** Execute one invocation with unconditional, host-adapted capabilities. */
29
- export declare function executeInvocation(dispatcher: Dispatcher, invocation: Invocation, host?: CapabilityHost): Promise<DispatchResult>;
30
- /** Add request correlation, acknowledgement, and error classification. */
31
- export declare function dispatchInvocation(dispatcher: Dispatcher, invocation: Invocation, reply: InvocationReply, host?: CapabilityHost): Promise<InvocationResponse>;
32
- //# sourceMappingURL=dispatch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../invocation/dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,SAAS,EACV,MAAM,wBAAwB,CAAA;AAI/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAI7D,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GACjD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,GAC3D;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,cAAc,CAAC,OAAO,CAAC,CAAA;CAAE,GACrE;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,eAAe,CAAA;CAAE,GACjE;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAAA;AAEnB,MAAM,MAAM,eAAe,GAAG;IAAE,GAAG,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,SAAS,CAAA;CAAE,CAAA;AAE/D,4EAA4E;AAC5E,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CAAC,cAAc,CAAC,CAgBzB;AAED,0EAA0E;AAC1E,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,eAAe,EACtB,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CAAC,kBAAkB,CAAC,CA+B7B"}
@@ -1,68 +0,0 @@
1
- import { classifyError } from '@astrale-os/kernel-api';
2
- import { createCapabilityLifecycle } from '../capabilities/index.js';
3
- /** Execute one invocation with unconditional, host-adapted capabilities. */
4
- export async function executeInvocation(dispatcher, invocation, host) {
5
- const lifecycle = createCapabilityLifecycle(host);
6
- try {
7
- const result = await dispatcher.invoke(invocation, lifecycle.capabilities);
8
- if (result.kind === 'stream') {
9
- return {
10
- kind: 'stream',
11
- generator: settleStream(result.generator, lifecycle.settle),
12
- };
13
- }
14
- await lifecycle.settle();
15
- return result;
16
- }
17
- catch (error) {
18
- await lifecycle.settle();
19
- throw error;
20
- }
21
- }
22
- /** Add request correlation, acknowledgement, and error classification. */
23
- export async function dispatchInvocation(dispatcher, invocation, reply, host) {
24
- if ('ack' in reply) {
25
- const lifecycle = createCapabilityLifecycle(host);
26
- const background = Promise.resolve().then(async () => {
27
- try {
28
- await dispatcher.invoke(invocation, lifecycle.capabilities);
29
- }
30
- catch (error) {
31
- // There is no response channel for acknowledged invocations.
32
- // oxlint-disable-next-line no-console
33
- console.error(`[invocation] Ack-mode error (${pathToString(invocation.path)}):`, error);
34
- }
35
- finally {
36
- await lifecycle.settle();
37
- }
38
- });
39
- host?.register(background);
40
- return { kind: 'ack' };
41
- }
42
- try {
43
- const result = await executeInvocation(dispatcher, invocation, host);
44
- switch (result.kind) {
45
- case 'value':
46
- return { kind: 'success', id: reply.id, data: result.value };
47
- case 'stream':
48
- return { kind: 'stream', id: reply.id, generator: result.generator };
49
- case 'redirect':
50
- return { kind: 'redirect', id: reply.id, redirection: result.redirection };
51
- }
52
- }
53
- catch (error) {
54
- return { kind: 'error', id: reply.id, error: classifyError(error) };
55
- }
56
- }
57
- async function* settleStream(generator, settle) {
58
- try {
59
- yield* generator;
60
- }
61
- finally {
62
- await settle();
63
- }
64
- }
65
- function pathToString(path) {
66
- return typeof path === 'string' ? path : path.raw;
67
- }
68
- //# sourceMappingURL=dispatch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../invocation/dispatch.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAA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,CAAC,IAAwB;IAC5C,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAA;AACnD,CAAC"}
@@ -1,19 +0,0 @@
1
- import type { DispatchResult, KernelAPI } from '@astrale-os/kernel-api';
2
- import type { CredentialInput, Path } from '@astrale-os/kernel-core';
3
- import type { Capabilities } from '../capabilities/index.js';
4
- /** Accepts canonical strings and any Path implementation exposing its raw form. */
5
- export type InvocationPath = string | Pick<Path, 'raw'>;
6
- /** A transport-neutral call entering a hosted Astrale dispatcher. */
7
- export type Invocation = {
8
- path: InvocationPath;
9
- credential: CredentialInput;
10
- params: unknown;
11
- self?: string;
12
- };
13
- /** The sole invocation contract required by kernel-server transports. */
14
- export type Dispatcher = {
15
- invoke(invocation: Invocation, caps: Capabilities): Promise<DispatchResult>;
16
- };
17
- /** Adapt a canonical kernel dispatcher to the narrower hosting contract. */
18
- export declare function kernelDispatcher(kernel: Pick<KernelAPI, 'dispatch'>): Dispatcher;
19
- //# sourceMappingURL=dispatcher.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../invocation/dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAA;AAEpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAE5D,mFAAmF;AACnF,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AAEvD,qEAAqE;AACrE,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,cAAc,CAAA;IACpB,UAAU,EAAE,eAAe,CAAA;IAC3B,MAAM,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED,yEAAyE;AACzE,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;CAC5E,CAAA;AAED,4EAA4E;AAC5E,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,UAAU,CAMhF"}
@@ -1,9 +0,0 @@
1
- /** Adapt a canonical kernel dispatcher to the narrower hosting contract. */
2
- export function kernelDispatcher(kernel) {
3
- return {
4
- invoke({ path, credential, params, self }) {
5
- return kernel.dispatch(typeof path === 'string' ? path : path.raw, credential, params, self);
6
- },
7
- };
8
- }
9
- //# sourceMappingURL=dispatcher.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../invocation/dispatcher.ts"],"names":[],"mappings":"AAqBA,4EAA4E;AAC5E,MAAM,UAAU,gBAAgB,CAAC,MAAmC;IAClE,OAAO;QACL,MAAM,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE;YACvC,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;QAC9F,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -1,40 +0,0 @@
1
- /**
2
- * OIDC discovery-document construction — the `issuer`/`jwks_uri` pair and the
3
- * reachable-URL derivation behind it. Shared by `mountJwks`,
4
- * `mountInstanceJwks`, and the issuer-registry mounts.
5
- *
6
- * Identity vs reachability — the two published fields are intentionally
7
- * asymmetric, and that asymmetry is load-bearing:
8
- * • `issuer` is the IDENTITY claim, published VERBATIM. OIDC Discovery /
9
- * RFC 8414 require it to equal the issuer used to build the discovery URL
10
- * and the `iss` claim the kernel signs into tokens. Normalizing it would
11
- * break token validation whenever the configured issuer is non-canonical
12
- * (a bare slug, odd casing, …) — so it is never rewritten here.
13
- * • `jwks_uri` is a REACHABILITY concern: it must be a fetchable absolute URL.
14
- * It is derived from the canonical issuer URL when that is usable, else from
15
- * the request's externally-reachable origin (proxy headers). A bare-slug or
16
- * port-0 issuer is a valid identity but an unfetchable URL — hence the
17
- * divergence. (Regression coverage: M-19, host `jwks-keys.test.ts`.)
18
- *
19
- * Edge-topology contract — KEEP IN SYNC with kernel/host/network/Caddyfile:
20
- * In the Caddy-only edge the host kernel is mounted publicly under
21
- * `/kernel/{slug}` (the issuer carries that path) but served internally at the
22
- * stripped path (`/` for the host, `/{id}` for children). `jwks_uri` is built
23
- * from the ISSUER's path, never the request path, so the edge only strips the
24
- * prefix on the way IN — no response-body rewrite. If a future edge stops
25
- * stripping `/kernel/{slug}`, or a kernel is mounted at a different public
26
- * path, the issuer's path and that edge rule must move together.
27
- */
28
- export interface DiscoveryDoc {
29
- issuer: string;
30
- jwks_uri: string;
31
- subject_types_supported: string[];
32
- id_token_signing_alg_values_supported: string[];
33
- }
34
- /**
35
- * Build the OIDC discovery document served at `/.well-known/openid-configuration`.
36
- * `issuer` is echoed verbatim (identity); `jwks_uri` is derived to be reachable.
37
- * See the file header for why the two diverge.
38
- */
39
- export declare function discoveryDoc(req: Request, issuer: string, signingAlgorithm: string): DiscoveryDoc;
40
- //# sourceMappingURL=discovery.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../jwks/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,uBAAuB,EAAE,MAAM,EAAE,CAAA;IACjC,qCAAqC,EAAE,MAAM,EAAE,CAAA;CAChD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,YAAY,CAOjG"}
@@ -1,113 +0,0 @@
1
- /**
2
- * OIDC discovery-document construction — the `issuer`/`jwks_uri` pair and the
3
- * reachable-URL derivation behind it. Shared by `mountJwks`,
4
- * `mountInstanceJwks`, and the issuer-registry mounts.
5
- *
6
- * Identity vs reachability — the two published fields are intentionally
7
- * asymmetric, and that asymmetry is load-bearing:
8
- * • `issuer` is the IDENTITY claim, published VERBATIM. OIDC Discovery /
9
- * RFC 8414 require it to equal the issuer used to build the discovery URL
10
- * and the `iss` claim the kernel signs into tokens. Normalizing it would
11
- * break token validation whenever the configured issuer is non-canonical
12
- * (a bare slug, odd casing, …) — so it is never rewritten here.
13
- * • `jwks_uri` is a REACHABILITY concern: it must be a fetchable absolute URL.
14
- * It is derived from the canonical issuer URL when that is usable, else from
15
- * the request's externally-reachable origin (proxy headers). A bare-slug or
16
- * port-0 issuer is a valid identity but an unfetchable URL — hence the
17
- * divergence. (Regression coverage: M-19, host `jwks-keys.test.ts`.)
18
- *
19
- * Edge-topology contract — KEEP IN SYNC with kernel/host/network/Caddyfile:
20
- * In the Caddy-only edge the host kernel is mounted publicly under
21
- * `/kernel/{slug}` (the issuer carries that path) but served internally at the
22
- * stripped path (`/` for the host, `/{id}` for children). `jwks_uri` is built
23
- * from the ISSUER's path, never the request path, so the edge only strips the
24
- * prefix on the way IN — no response-body rewrite. If a future edge stops
25
- * stripping `/kernel/{slug}`, or a kernel is mounted at a different public
26
- * path, the issuer's path and that edge rule must move together.
27
- */
28
- import { normalizeIssuerId } from '@astrale-os/kernel-core';
29
- /**
30
- * Build the OIDC discovery document served at `/.well-known/openid-configuration`.
31
- * `issuer` is echoed verbatim (identity); `jwks_uri` is derived to be reachable.
32
- * See the file header for why the two diverge.
33
- */
34
- export function discoveryDoc(req, issuer, signingAlgorithm) {
35
- return {
36
- issuer,
37
- jwks_uri: jwksUriFor(req, issuer),
38
- subject_types_supported: ['public'],
39
- id_token_signing_alg_values_supported: [signingAlgorithm],
40
- };
41
- }
42
- // Public URL of a discovery document's sibling `jwks.json`. Three cases, in
43
- // priority order:
44
- // 1. `issuer` is a usable http(s) URL WITH a path → that path is this
45
- // kernel/instance's full public mount (e.g. `…/kernel/host`). jwks lives
46
- // directly under it (`{issuer}/.well-known/jwks.json`) — the OIDC invariant
47
- // that needs no proxy body-rewrite.
48
- // 2. `issuer` is a usable http(s) URL but origin-only → the public mount path
49
- // comes from the request path (kernel reached at its canonical origin).
50
- // 3. `issuer` is a bare slug / non-URL / port-0 fixture → fall back to the
51
- // request's externally-reachable origin (proxy headers) plus its own path.
52
- function jwksUriFor(req, issuer) {
53
- const requestJwksPath = new URL(req.url).pathname.replace(/\/openid-configuration$/, '/jwks.json');
54
- const canonical = canonicalIssuerUrl(issuer);
55
- if (!canonical) {
56
- return `${externalOriginFromRequest(req)}${requestJwksPath}`;
57
- }
58
- if (canonical.pathname && canonical.pathname !== '/') {
59
- return `${canonical.origin}${canonical.pathname.replace(/\/+$/, '')}/.well-known/jwks.json`;
60
- }
61
- return `${canonical.origin}${requestJwksPath}`;
62
- }
63
- // Parse `issuer` into its canonical http(s) URL, or null when it is not a
64
- // verifier-reachable origin: a bare slug (no scheme), a non-http(s) scheme, or
65
- // the `:0` placeholder port that test/dev fixtures use as a non-canonical stand-in.
66
- function canonicalIssuerUrl(issuer) {
67
- try {
68
- const u = new URL(normalizeIssuerId(issuer));
69
- if (!u.host)
70
- return null;
71
- if (u.protocol !== 'http:' && u.protocol !== 'https:')
72
- return null;
73
- if (u.port === '0')
74
- return null;
75
- return u;
76
- }
77
- catch {
78
- return null;
79
- }
80
- }
81
- // Externally-reachable origin of the request. Reverse proxies commonly
82
- // terminate TLS and rewrite Host to an internal hostname; prefer the forwarding
83
- // headers (X-Forwarded-* then RFC 7239 Forwarded) before the request URL, so
84
- // discovery never publishes an unreachable jwks_uri.
85
- function externalOriginFromRequest(req) {
86
- const xfHost = firstHeaderValue(req.headers.get('x-forwarded-host'));
87
- if (xfHost) {
88
- const proto = (firstHeaderValue(req.headers.get('x-forwarded-proto')) ?? 'https').toLowerCase();
89
- return `${proto}://${xfHost.toLowerCase()}`;
90
- }
91
- const fwd = firstHeaderValue(req.headers.get('forwarded'));
92
- if (fwd) {
93
- const map = {};
94
- for (const part of fwd.split(';')) {
95
- const [k, v] = part.split('=');
96
- if (k && v)
97
- map[k.trim().toLowerCase()] = stripQuotes(v.trim());
98
- }
99
- if (map.host) {
100
- const proto = (map.proto ?? 'https').toLowerCase();
101
- return `${proto}://${map.host.toLowerCase()}`;
102
- }
103
- }
104
- return new URL(req.url).origin;
105
- }
106
- function firstHeaderValue(value) {
107
- const first = value?.split(',')[0]?.trim();
108
- return first ? stripQuotes(first) : null;
109
- }
110
- function stripQuotes(value) {
111
- return value.replace(/^"|"$/g, '');
112
- }
113
- //# sourceMappingURL=discovery.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../jwks/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAS3D;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,GAAY,EAAE,MAAc,EAAE,gBAAwB;IACjF,OAAO;QACL,MAAM;QACN,QAAQ,EAAE,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;QACjC,uBAAuB,EAAE,CAAC,QAAQ,CAAC;QACnC,qCAAqC,EAAE,CAAC,gBAAgB,CAAC;KAC1D,CAAA;AACH,CAAC;AAED,4EAA4E;AAC5E,kBAAkB;AAClB,wEAAwE;AACxE,8EAA8E;AAC9E,iFAAiF;AACjF,yCAAyC;AACzC,gFAAgF;AAChF,6EAA6E;AAC7E,6EAA6E;AAC7E,gFAAgF;AAChF,SAAS,UAAU,CAAC,GAAY,EAAE,MAAc;IAC9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,IAAI,EAAE,CAAA;IAC1C,OAAO,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAC1C,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;AACpC,CAAC"}
@@ -1,3 +0,0 @@
1
- export { mountJwks, mountInstanceJwks, type JwksKeys, type MultiplexedJwks, type JwksConfig, type InstanceJwksConfig, } from './keys.js';
2
- export { mountIssuerRegistry, mountInstanceIssuerRegistry, type IssuerRegistryConfig, type InstanceIssuerRegistryConfig, } from './issuers.js';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../jwks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAA;AAElB,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,GAClC,MAAM,cAAc,CAAA"}
@@ -1,3 +0,0 @@
1
- export { mountJwks, mountInstanceJwks, } from './keys.js';
2
- export { mountIssuerRegistry, mountInstanceIssuerRegistry, } from './issuers.js';
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../jwks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,iBAAiB,GAKlB,MAAM,WAAW,CAAA;AAElB,OAAO,EACL,mBAAmB,EACnB,2BAA2B,GAG5B,MAAM,cAAc,CAAA"}
@@ -1,47 +0,0 @@
1
- /**
2
- * Issuer Registry — kernel-specific convention for hosting external issuers' keys.
3
- *
4
- * The kernel allows external identities to publish their public keys via
5
- * `Authentication.publishIssuer()`. Those issuers get stable URLs of the form
6
- * `{kernel}/iss/{issId}`, and their JWKS is served at
7
- * `{kernel}/iss/{issId}/.well-known/jwks.json`.
8
- *
9
- * This is NOT standard OIDC — it's a kernel-specific trust model. Only kernels
10
- * with an issuer store should mount these routes. Generic services that just
11
- * sign their own JWTs don't need this.
12
- */
13
- import type { Hono } from 'hono';
14
- import { type CorsConfig } from '../cors.js';
15
- export type IssuerRegistryConfig = {
16
- /** Base issuer URL — registered issuer URLs are constructed as `${issuer}/iss/{issId}`. */
17
- issuer: string;
18
- /** Load a registered external issuer's keys. Empty array if unknown. */
19
- loadKeys: (issuerId: string) => Promise<Record<string, unknown>[]>;
20
- /** Signing algorithm (used in openid-configuration). Defaults to 'ES256'. */
21
- signingAlgorithm?: string;
22
- cors?: CorsConfig;
23
- };
24
- /**
25
- * Mount issuer registry endpoints — kernel-specific convention for hosting
26
- * externally-registered issuers' keys.
27
- *
28
- * - GET /iss/:issId/.well-known/openid-configuration → external issuer discovery
29
- * - GET /iss/:issId/.well-known/jwks.json → external issuer keys
30
- */
31
- export declare function mountIssuerRegistry(app: Hono, config: IssuerRegistryConfig): void;
32
- export type InstanceIssuerRegistryConfig = {
33
- /** Resolve the instance's base issuer URL. Return null if unknown. */
34
- resolveIssuer: (instanceId: string) => string | null;
35
- /** Load a registered external issuer's keys for an instance. */
36
- loadKeys: (instanceId: string, issuerId: string) => Promise<Record<string, unknown>[]>;
37
- signingAlgorithm?: string;
38
- cors?: CorsConfig;
39
- };
40
- /**
41
- * Mount per-instance issuer registry endpoints (multiplexed kernel-specific).
42
- *
43
- * - GET /:id/iss/:issId/.well-known/openid-configuration
44
- * - GET /:id/iss/:issId/.well-known/jwks.json
45
- */
46
- export declare function mountInstanceIssuerRegistry(app: Hono, instancePrefix: string, config: InstanceIssuerRegistryConfig): void;
47
- //# sourceMappingURL=issuers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"issuers.d.ts","sourceRoot":"","sources":["../../jwks/issuers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAEhC,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AAK9D,MAAM,MAAM,oBAAoB,GAAG;IACjC,2FAA2F;IAC3F,MAAM,EAAE,MAAM,CAAA;IACd,wEAAwE;IACxE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;IAClE,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAoBjF;AAID,MAAM,MAAM,4BAA4B,GAAG;IACzC,sEAAsE;IACtE,aAAa,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAA;IACpD,gEAAgE;IAChE,QAAQ,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;IACtF,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,IAAI,EACT,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,4BAA4B,GACnC,IAAI,CAyBN"}
@@ -1,76 +0,0 @@
1
- /**
2
- * Issuer Registry — kernel-specific convention for hosting external issuers' keys.
3
- *
4
- * The kernel allows external identities to publish their public keys via
5
- * `Authentication.publishIssuer()`. Those issuers get stable URLs of the form
6
- * `{kernel}/iss/{issId}`, and their JWKS is served at
7
- * `{kernel}/iss/{issId}/.well-known/jwks.json`.
8
- *
9
- * This is NOT standard OIDC — it's a kernel-specific trust model. Only kernels
10
- * with an issuer store should mount these routes. Generic services that just
11
- * sign their own JWTs don't need this.
12
- */
13
- import { buildCorsHeaders } from '../cors.js';
14
- import { discoveryDoc } from './discovery.js';
15
- /**
16
- * Mount issuer registry endpoints — kernel-specific convention for hosting
17
- * externally-registered issuers' keys.
18
- *
19
- * - GET /iss/:issId/.well-known/openid-configuration → external issuer discovery
20
- * - GET /iss/:issId/.well-known/jwks.json → external issuer keys
21
- */
22
- export function mountIssuerRegistry(app, config) {
23
- const corsHeaders = buildCorsHeaders(config.cors ?? { origin: '*' });
24
- const headers = { 'cache-control': 'no-cache', ...corsHeaders };
25
- const alg = config.signingAlgorithm ?? 'ES256';
26
- app.get('/iss/:issId/.well-known/openid-configuration', (c) => {
27
- const issId = c.req.param('issId');
28
- const issuerUrl = `${config.issuer}/iss/${issId}`;
29
- return c.json(discoveryDoc(c.req.raw, issuerUrl, alg), 200, headers);
30
- });
31
- app.get('/iss/:issId/.well-known/jwks.json', async (c) => {
32
- const issId = c.req.param('issId');
33
- const issuerUrl = `${config.issuer}/iss/${issId}`;
34
- const keys = await config.loadKeys(issuerUrl);
35
- if (keys.length === 0) {
36
- return c.json({ error: 'Issuer not found' }, 404, headers);
37
- }
38
- return c.json({ keys }, 200, headers);
39
- });
40
- }
41
- /**
42
- * Mount per-instance issuer registry endpoints (multiplexed kernel-specific).
43
- *
44
- * - GET /:id/iss/:issId/.well-known/openid-configuration
45
- * - GET /:id/iss/:issId/.well-known/jwks.json
46
- */
47
- export function mountInstanceIssuerRegistry(app, instancePrefix, config) {
48
- const corsHeaders = buildCorsHeaders(config.cors ?? { origin: '*' });
49
- const headers = { 'cache-control': 'no-cache', ...corsHeaders };
50
- const alg = config.signingAlgorithm ?? 'ES256';
51
- app.get(`${instancePrefix}/iss/:issId/.well-known/openid-configuration`, (c) => {
52
- const id = c.req.param('id');
53
- const issId = c.req.param('issId');
54
- if (!id || !issId)
55
- return c.json({ error: 'Instance not found' }, 404, headers);
56
- const issuer = config.resolveIssuer(id);
57
- if (!issuer)
58
- return c.json({ error: 'Instance not found' }, 404, headers);
59
- const issuerUrl = `${issuer}/iss/${issId}`;
60
- return c.json(discoveryDoc(c.req.raw, issuerUrl, alg), 200, headers);
61
- });
62
- app.get(`${instancePrefix}/iss/:issId/.well-known/jwks.json`, async (c) => {
63
- const id = c.req.param('id');
64
- const issId = c.req.param('issId');
65
- if (!id || !issId)
66
- return c.json({ error: 'Instance not found' }, 404, headers);
67
- const issuer = config.resolveIssuer(id);
68
- if (!issuer)
69
- return c.json({ error: 'Instance not found' }, 404, headers);
70
- const keys = await config.loadKeys(id, `${issuer}/iss/${issId}`);
71
- if (keys.length === 0)
72
- return c.json({ error: 'Issuer not found' }, 404, headers);
73
- return c.json({ keys }, 200, headers);
74
- });
75
- }
76
- //# sourceMappingURL=issuers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"issuers.js","sourceRoot":"","sources":["../../jwks/issuers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,gBAAgB,EAAmB,MAAM,YAAY,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAc7C;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAS,EAAE,MAA4B;IACzE,MAAM,WAAW,GAAG,gBAAgB,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;IACpE,MAAM,OAAO,GAAG,EAAE,eAAe,EAAE,UAAU,EAAE,GAAG,WAAW,EAAE,CAAA;IAC/D,MAAM,GAAG,GAAG,MAAM,CAAC,gBAAgB,IAAI,OAAO,CAAA;IAE9C,GAAG,CAAC,GAAG,CAAC,8CAA8C,EAAE,CAAC,CAAC,EAAE,EAAE;QAC5D,MAAM,KAAK,GAAG,CAAC,CAAC,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