@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
@@ -0,0 +1,9 @@
1
+ export class ResponseBodyTooLargeError extends Error {
2
+ maximumBytes;
3
+ constructor(maximumBytes) {
4
+ super(`Server response exceeds maximumResponseBytes (${maximumBytes}).`);
5
+ this.maximumBytes = maximumBytes;
6
+ this.name = 'ResponseBodyTooLargeError';
7
+ }
8
+ }
9
+ //# sourceMappingURL=response-body.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-body.js","sourceRoot":"","sources":["../../errors/response-body.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAC7B,YAAY;IAAjC,YAAqB,YAAoB;QACvC,KAAK,CAAC,iDAAiD,YAAY,IAAI,CAAC,CAAA;4BADrD,YAAY;QAE/B,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAA;IACzC,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -1,12 +1,5 @@
1
- export { createKernelApp, type KernelAppConfig, type WsAdapter } from './app/create.js';
2
- export { createMultiplexedKernelApp, type MultiplexedKernelAppConfig, type DispatcherResolver, } from './app/multiplexed.js';
3
- export { walkDomain, type ServerHost, type MountedFunction, type MountedRoute, type MountPlan, } from './plan/index.js';
4
- export { buildCorsHeaders, type CorsConfig } from './cors.js';
5
- export { createKernelDispatcher, type KernelDispatcherOptions } from './envelope/http.js';
6
- export { KernelWsConnection, type WebSocketLike } from './envelope/ws.js';
7
- export { createCapabilityLifecycle, honoCapabilityHost, type CapabilityHost, type CapabilityLifecycle, type Defer, type DeferredTask, type Capabilities, type Sleep, } from './capabilities/index.js';
8
- export { dispatchInvocation, executeInvocation, kernelDispatcher, type Invocation, type InvocationPath, type InvocationReply, type InvocationResponse, type Dispatcher, } from './invocation/index.js';
9
- export { createRouteHandler, type RouteHandlerConfig } from './routed/index.js';
10
- export { mountJwks, mountInstanceJwks, mountIssuerRegistry, mountInstanceIssuerRegistry, type JwksKeys, type MultiplexedJwks, type JwksConfig, type InstanceJwksConfig, type IssuerRegistryConfig, type InstanceIssuerRegistryConfig, } from './jwks/index.js';
11
- export { classifyError } from '@astrale-os/kernel-api';
1
+ export { createServer, prepareServer } from './server.js';
2
+ export { InstallationUnavailableError, IssuerKeysUnavailableError } from './errors/index.js';
3
+ export { preparePublicationSnapshot } from './publication/index.js';
4
+ export type { Application, ApplicationHost, CorsConfig, Handler, HandlerRequest, HealthProbe, InstallationContext, InstallationProvider, InvocationContext, Issuer, PreparedServer, PublicationSnapshot, PublicationSnapshotInput, PublicationSource, Server, ServerCloseOptions, ServerConfig, ServerLimits, ServerOptions, WebSocketAdapter, WebSocketHandlers, WebSocketLike, WebSocketUpgradeOptions, } from './types.js';
12
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,KAAK,eAAe,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACvF,OAAO,EACL,0BAA0B,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,GACxB,MAAM,sBAAsB,CAAA;AAI7B,OAAO,EACL,UAAU,EACV,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,SAAS,GACf,MAAM,iBAAiB,CAAA;AAIxB,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAA;AAI7D,OAAO,EAAE,sBAAsB,EAAE,KAAK,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AACzF,OAAO,EAAE,kBAAkB,EAAE,KAAK,aAAa,E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aAAa,EACb,uBAAuB,GACxB,MAAM,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -1,19 +1,4 @@
1
- // ─── App entry points ─────────────────────────────────────────────────────────
2
- export { createKernelApp } from './app/create.js';
3
- export { createMultiplexedKernelApp, } from './app/multiplexed.js';
4
- // ─── Plan ────────────────────────────────────────────────────────────────────
5
- export { walkDomain, } from './plan/index.js';
6
- // ─── Cross-cutting ───────────────────────────────────────────────────────────
7
- export { buildCorsHeaders } from './cors.js';
8
- // ─── Kernel envelope dispatcher ──────────────────────────────────────────────
9
- export { createKernelDispatcher } from './envelope/http.js';
10
- export { KernelWsConnection } from './envelope/ws.js';
11
- export { createCapabilityLifecycle, honoCapabilityHost, } from './capabilities/index.js';
12
- export { dispatchInvocation, executeInvocation, kernelDispatcher, } from './invocation/index.js';
13
- // ─── Routed HTTP handler (per-route) ─────────────────────────────────────────
14
- export { createRouteHandler } from './routed/index.js';
15
- // ─── JWKS (OIDC Discovery + JSON Web Key Set) ───────────────────────────────
16
- export { mountJwks, mountInstanceJwks, mountIssuerRegistry, mountInstanceIssuerRegistry, } from './jwks/index.js';
17
- // ─── Dispatch (for custom integrations) ──────────────────────────────────────
18
- export { classifyError } from '@astrale-os/kernel-api';
1
+ export { createServer, prepareServer } from './server.js';
2
+ export { InstallationUnavailableError, IssuerKeysUnavailableError } from './errors/index.js';
3
+ export { preparePublicationSnapshot } from './publication/index.js';
19
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,iFAAiF;AAEjF,OAAO,EAAE,eAAe,EAAwC,MAAM,iBAAiB,CAAA;AACvF,OAAO,EACL,0BAA0B,GAG3B,MAAM,sBAAsB,CAAA;AAE7B,gFAAgF;AAEhF,OAAO,EACL,UAAU,GAKX,MAAM,iBAAiB,CAAA;AAExB,gFAAgF;AAEhF,OAAO,EAAE,gBAAgB,EAAmB,MAAM,WAAW,CAAA;AAE7D,gFAAgF;AAEhF,OAAO,EAAE,sBAAsB,EAAgC,MAAM,oBAAoB,CAAA;AACzF,OAAO,EAAE,kBAAkB,EAAsB,MAAM,kBAAkB,CAAA;AACzE,OAAO,EACL,yBAAyB,EACzB,kBAAkB,GAOnB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,GAMjB,MAAM,uBAAuB,CAAA;AAE9B,gFAAgF;AAEhF,OAAO,EAAE,kBAAkB,EAA2B,MAAM,mBAAmB,CAAA;AAE/E,+EAA+E;AAE/E,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,GAO5B,MAAM,iBAAiB,CAAA;AAExB,gFAAgF;AAEhF,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAA;AAC5F,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAA"}
@@ -0,0 +1,10 @@
1
+ import type { ActiveOperations } from '../lifecycle/index.js';
2
+ import type { PreparedPublicationSnapshot } from '../publication/index.js';
3
+ import type { InstallationProvider } from './types.js';
4
+ export interface InstallationLimits {
5
+ readonly maximumInstallationBytes: number;
6
+ readonly invocationTimeoutMs: number;
7
+ }
8
+ /** Serve one installation request against the exact Publication snapshot that selected its URL. */
9
+ export declare function handleInstallation(request: Request, snapshot: PreparedPublicationSnapshot, provider: InstallationProvider | undefined, active: ActiveOperations, limits: InstallationLimits, cors: Readonly<Record<string, string>>): Promise<Response>;
10
+ //# sourceMappingURL=handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../installation/handler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAA;AAC1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAMtD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,wBAAwB,EAAE,MAAM,CAAA;IACzC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAA;CACrC;AAED,mGAAmG;AACnG,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,2BAA2B,EACrC,QAAQ,EAAE,oBAAoB,GAAG,SAAS,EAC1C,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACrC,OAAO,CAAC,QAAQ,CAAC,CAsGnB"}
@@ -0,0 +1,126 @@
1
+ import { codecs, installation } from '@astrale-os/kernel-protocol';
2
+ import { InstallationUnavailableError } from '../errors/index.js';
3
+ import { RequestBodyInvalidError, RequestBodyTooLargeError } from '../errors/index.js';
4
+ import { readBoundedBody } from '../transport/index.js';
5
+ /** Serve one installation request against the exact Publication snapshot that selected its URL. */
6
+ export async function handleInstallation(request, snapshot, provider, active, limits, cors) {
7
+ if (request.method !== 'POST') {
8
+ return response({ error: 'Installation requires POST.' }, 405, cors);
9
+ }
10
+ if (provider === undefined) {
11
+ return response({ error: 'Installation is unavailable.' }, 503, cors);
12
+ }
13
+ const advertised = snapshot.publication.installation;
14
+ if (advertised === undefined) {
15
+ return response({ error: 'Installation is unavailable.' }, 404, cors);
16
+ }
17
+ const operation = active.begin(limits.invocationTimeoutMs, request.signal);
18
+ if (operation === undefined)
19
+ return response({ error: 'Server is draining.' }, 503, cors);
20
+ try {
21
+ const authorization = request.headers.get('authorization');
22
+ const token = bearer(authorization);
23
+ if (advertised.authentication.kind === 'bearer' && token === undefined) {
24
+ return response({ error: 'Bearer authentication is required.' }, 401, cors);
25
+ }
26
+ if (advertised.authentication.kind === 'public' && authorization !== null) {
27
+ return response({ error: 'This installation endpoint is public.' }, 400, cors);
28
+ }
29
+ let body;
30
+ try {
31
+ body = await readBoundedBody(request, limits.maximumInstallationBytes, operation.signal);
32
+ }
33
+ catch (cause) {
34
+ if (cause instanceof RequestBodyTooLargeError) {
35
+ return response({ error: 'Installation request is too large.' }, 413, cors);
36
+ }
37
+ if (cause instanceof RequestBodyInvalidError) {
38
+ return response({ error: 'Installation request is invalid.' }, 400, cors);
39
+ }
40
+ if (operation.signal.aborted) {
41
+ return response({ error: 'Installation request was cancelled.' }, 503, cors);
42
+ }
43
+ throw cause;
44
+ }
45
+ let decoded;
46
+ try {
47
+ decoded = codecs.json.decode(body);
48
+ }
49
+ catch (cause) {
50
+ if (cause instanceof codecs.DecodeError) {
51
+ return response({ error: 'Installation request is invalid.' }, 400, cors);
52
+ }
53
+ throw cause;
54
+ }
55
+ let input;
56
+ try {
57
+ input = installation.acceptRequest(decoded);
58
+ }
59
+ catch (cause) {
60
+ if (cause instanceof installation.Error && cause.code === 'INSTALLATION_REQUEST_INVALID') {
61
+ return response({ error: 'Installation request is invalid.' }, 400, cors);
62
+ }
63
+ throw cause;
64
+ }
65
+ if (input.etag !== snapshot.publication.etag) {
66
+ return response({ error: 'Publication ETag differs from request.' }, 409, cors);
67
+ }
68
+ let candidate;
69
+ try {
70
+ candidate = await provider.create(input, {
71
+ ...(token === undefined ? {} : { token: Object.freeze({ kind: 'bearer', token }) }),
72
+ signal: operation.signal,
73
+ });
74
+ }
75
+ catch (cause) {
76
+ if (cause instanceof InstallationUnavailableError) {
77
+ return response({ error: 'Installation provider is unavailable.' }, 503, cors);
78
+ }
79
+ throw cause;
80
+ }
81
+ let created;
82
+ try {
83
+ created = installation.accept(candidate);
84
+ }
85
+ catch (cause) {
86
+ if (cause instanceof installation.Error) {
87
+ return response({ error: 'Installation provider returned an invalid response.' }, 500, cors);
88
+ }
89
+ throw cause;
90
+ }
91
+ if (created.publication.etag !== snapshot.publication.etag) {
92
+ return response({ error: 'Installation provider returned a different Publication.' }, 500, cors);
93
+ }
94
+ const encoded = codecs.json.encode(created);
95
+ if (encodedSize(encoded) > limits.maximumInstallationBytes) {
96
+ return response({ error: 'Installation response exceeds its serving limit.' }, 500, cors);
97
+ }
98
+ return new Response(encodedBody(encoded), {
99
+ headers: { ...cors, 'content-type': 'application/json' },
100
+ });
101
+ }
102
+ finally {
103
+ operation.settle();
104
+ }
105
+ }
106
+ function bearer(input) {
107
+ if (input === null)
108
+ return undefined;
109
+ return /^Bearer[ \t]+([^\s]+)$/iu.exec(input.trim())?.[1];
110
+ }
111
+ function response(body, status, cors) {
112
+ return new Response(encodedBody(codecs.json.encode(body)), {
113
+ status,
114
+ headers: { ...cors, 'content-type': 'application/json' },
115
+ });
116
+ }
117
+ function encodedBody(input) {
118
+ return typeof input === 'string' ? input : toBody(input);
119
+ }
120
+ function encodedSize(input) {
121
+ return typeof input === 'string' ? new TextEncoder().encode(input).byteLength : input.byteLength;
122
+ }
123
+ function toBody(input) {
124
+ return input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength);
125
+ }
126
+ //# sourceMappingURL=handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../installation/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAMlE,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAA;AACjE,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAOvD,mGAAmG;AACnG,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAAgB,EAChB,QAAqC,EACrC,QAA0C,EAC1C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AAE,cAAc,EAAE,kBAAkB,EAAE;KACzD,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,KAA0B;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC1D,CAAC;AAED,SAAS,WAAW,CAAC,KAA0B;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAA;AAClG,CAAC;AAED,SAAS,MAAM,CAAC,KAAiB;IAC/B,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAgB,CAAA;AACjG,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { handleInstallation, type InstallationLimits } from './handler.js';
2
+ export type { InstallationContext, InstallationProvider } from './types.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../installation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAC1E,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { handleInstallation } from './handler.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../installation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAA2B,MAAM,cAAc,CAAA"}
@@ -0,0 +1,12 @@
1
+ import type { installation } from '@astrale-os/kernel-protocol';
2
+ export interface InstallationContext {
3
+ /** Omitted for a public endpoint; otherwise the exact admitted retrieval credential. */
4
+ readonly token?: installation.InstallationToken;
5
+ readonly signal: AbortSignal;
6
+ }
7
+ /** Provider-owned retrieval, construction, and attestation signing. */
8
+ export interface InstallationProvider {
9
+ /** Throw InstallationUnavailableError only for an expected dependency outage. */
10
+ create(request: installation.Request, context: InstallationContext): Promise<installation.Installation>;
11
+ }
12
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../installation/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAE/D,MAAM,WAAW,mBAAmB;IAClC,wFAAwF;IACxF,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC,iBAAiB,CAAA;IAC/C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;CAC7B;AAED,uEAAuE;AACvE,MAAM,WAAW,oBAAoB;IACnC,iFAAiF;IACjF,MAAM,CACJ,OAAO,EAAE,YAAY,CAAC,OAAO,EAC7B,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,CAAA;CACtC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../installation/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import type { invocation as protocol } from '@astrale-os/kernel-protocol';
2
+ import type { ActiveOperation, ActiveOperations } from '../lifecycle/index.js';
3
+ import type { ApplicationHost, InvocationContext } from './types.js';
4
+ export declare function invocationContext(operation: ActiveOperation, active: ActiveOperations, host?: ApplicationHost, requestBody?: Uint8Array, idempotencyKey?: protocol.IdempotencyKey, refresh?: InvocationContext['refresh'], delegate?: InvocationContext['delegate']): InvocationContext;
5
+ /** Default non-durable timer used when the application host supplies no timer capability. */
6
+ export declare function defaultSleep(durationMs: number): Promise<void>;
7
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../invocation/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,IAAI,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAEzE,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEpE,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,eAAe,EAC1B,MAAM,EAAE,gBAAgB,EACxB,IAAI,CAAC,EAAE,eAAe,EACtB,WAAW,CAAC,EAAE,UAAU,EACxB,cAAc,CAAC,EAAE,QAAQ,CAAC,cAAc,EACxC,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC,EACtC,QAAQ,CAAC,EAAE,iBAAiB,CAAC,UAAU,CAAC,GACvC,iBAAiB,CAcnB;AAED,6FAA6F;AAC7F,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpE"}
@@ -0,0 +1,62 @@
1
+ export function invocationContext(operation, active, host, requestBody, idempotencyKey, refresh, delegate) {
2
+ const body = requestBody?.slice();
3
+ return Object.freeze({
4
+ execution: Object.freeze({ deadline: operation.deadline, signal: operation.signal }),
5
+ background: (task) => active.background(task, host?.waitUntil),
6
+ sleep: async (durationMs) => {
7
+ await interruptibleSleep(sleepDuration(durationMs), operation.signal, host?.sleep);
8
+ },
9
+ ...(idempotencyKey === undefined ? {} : { idempotencyKey }),
10
+ ...(refresh === undefined ? {} : { refresh }),
11
+ ...(delegate === undefined ? {} : { delegate }),
12
+ ...(body === undefined ? {} : { request: Object.freeze({ body: () => body.slice() }) }),
13
+ });
14
+ }
15
+ /** Default non-durable timer used when the application host supplies no timer capability. */
16
+ export async function defaultSleep(durationMs) {
17
+ await new Promise((resolve) => setTimeout(resolve, sleepDuration(durationMs)));
18
+ }
19
+ async function interruptibleSleep(durationMs, signal, sleep) {
20
+ if (signal.aborted)
21
+ throw abortCause(signal);
22
+ if (sleep === undefined) {
23
+ await new Promise((resolve, reject) => {
24
+ const timer = setTimeout(() => finish(resolve), durationMs);
25
+ const abort = () => {
26
+ clearTimeout(timer);
27
+ finish(() => reject(abortCause(signal)));
28
+ };
29
+ const finish = (settle) => {
30
+ signal.removeEventListener('abort', abort);
31
+ settle();
32
+ };
33
+ signal.addEventListener('abort', abort, { once: true });
34
+ });
35
+ return;
36
+ }
37
+ await new Promise((resolve, reject) => {
38
+ let settled = false;
39
+ const finish = (settle) => {
40
+ if (settled)
41
+ return;
42
+ settled = true;
43
+ signal.removeEventListener('abort', abort);
44
+ settle();
45
+ };
46
+ const abort = () => finish(() => reject(abortCause(signal)));
47
+ signal.addEventListener('abort', abort, { once: true });
48
+ Promise.resolve()
49
+ .then(() => sleep(durationMs))
50
+ .then(() => finish(resolve), (cause) => finish(() => reject(cause)));
51
+ });
52
+ }
53
+ function abortCause(signal) {
54
+ return signal.reason instanceof Error ? signal.reason : new Error('Invocation was cancelled.');
55
+ }
56
+ function sleepDuration(input) {
57
+ if (!Number.isFinite(input) || input < 0 || input > 2_147_483_647) {
58
+ throw new RangeError('Sleep duration must be finite, non-negative, and within timer range.');
59
+ }
60
+ return input;
61
+ }
62
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../invocation/context.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,iBAAiB,CAC/B,SAA0B,EAC1B,MAAwB,EACxB,IAAsB,EACtB,WAAwB,EACxB,cAAwC,EACxC,OAAsC,EACtC,QAAwC;IAExC,MAAM,IAAI,GAAG,WAAW,EAAE,KAAK,EAAE,CAAA;IACjC,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EA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AE,CAAC,CAAA;QACvD,OAAO,CAAC,OAAO,EAAE;aACd,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;aAC7B,IAAI,CACH,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EACrB,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CACvC,CAAA;IACL,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,MAAmB;IACrC,OAAO,MAAM,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;AAChG,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,aAAa,EAAE,CAAC;QAClE,MAAM,IAAI,UAAU,CAAC,sEAAsE,CAAC,CAAA;IAC9F,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -1,3 +1,3 @@
1
- export { dispatchInvocation, executeInvocation, type InvocationReply, type InvocationResponse, } from './dispatch.js';
2
- export { kernelDispatcher, type Invocation, type InvocationPath, type Dispatcher, } from './dispatcher.js';
1
+ export { defaultSleep, invocationContext } from './context.js';
2
+ export type { ApplicationHost, Handler, HandlerRequest, InvocationContext } from './types.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../invocation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,kBAAkB,GACxB,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,gBAAgB,EAChB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,UAAU,GAChB,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../invocation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAC9D,YAAY,EAAE,eAAe,EAAE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA"}
@@ -1,3 +1,2 @@
1
- export { dispatchInvocation, executeInvocation, } from './dispatch.js';
2
- export { kernelDispatcher, } from './dispatcher.js';
1
+ export { defaultSleep, invocationContext } from './context.js';
3
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../invocation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,GAGlB,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,gBAAgB,GAIjB,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../invocation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,34 @@
1
+ import type { CredentialInput } from '@astrale-os/kernel-core/auth';
2
+ import type { InboundRequestOptions, RequestBackground, RequestSleep } from '@astrale-os/kernel-ports';
3
+ import type { Call, Result } from '@astrale-os/kernel-ports/functions';
4
+ import type { invocation as protocol } from '@astrale-os/kernel-protocol';
5
+ import type { PublicationSnapshot } from '../publication/index.js';
6
+ /** Optional platform retention and timer adaptation for one Fetch invocation. */
7
+ export interface ApplicationHost {
8
+ waitUntil(promise: Promise<unknown>): void;
9
+ readonly sleep?: (durationMs: number) => Promise<void>;
10
+ }
11
+ /** Immutable lifetime and execution conveniences for one admitted dispatch. */
12
+ export interface InvocationContext extends InboundRequestOptions {
13
+ readonly background: RequestBackground;
14
+ /** Rejects promptly when execution is cancelled or reaches its deadline. */
15
+ readonly sleep: RequestSleep;
16
+ }
17
+ /** Ready semantic capability invoked by canonical and advertised transport routes. */
18
+ export interface HandlerRequest {
19
+ readonly call: Call;
20
+ readonly credential?: CredentialInput;
21
+ /** Source-only effective delegation forwarded unchanged to Runtime. */
22
+ readonly delegate?: protocol.Delegate;
23
+ /** Destination routing witness forwarded to a remote adapter after Server matching. */
24
+ readonly via?: protocol.Via;
25
+ /** Exact Server-pinned serving generation for a Publication-backed request. */
26
+ readonly publication?: PublicationSnapshot;
27
+ readonly context: InvocationContext;
28
+ }
29
+ export interface Handler {
30
+ dispatch(request: HandlerRequest): Promise<Result | {
31
+ readonly kind: 'miss';
32
+ }>;
33
+ }
34
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../invocation/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AACnE,OAAO,KAAK,EACV,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,EACb,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,IAAI,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAEzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAElE,iFAAiF;AACjF,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAA;IAC1C,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACvD;AAED,+EAA+E;AAC/E,MAAM,WAAW,iBAAkB,SAAQ,qBAAqB;IAC9D,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAA;IACtC,4EAA4E;IAC5E,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAA;CAC7B;AAED,sFAAsF;AACtF,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,QAAQ,CAAC,UAAU,CAAC,EAAE,eAAe,CAAA;IACrC,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAA;IACrC,uFAAuF;IACvF,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAA;IAC3B,+EAA+E;IAC/E,QAAQ,CAAC,WAAW,CAAC,EAAE,mBAAmB,CAAA;IAC1C,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAA;CACpC;AAED,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,GAAG;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC/E"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../invocation/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export { admitIssuer, issuerRouteReservations, mountIssuer, type IssuerRouteReservation, } from './routes.js';
2
+ export type { Issuer } from './types.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../issuer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,WAAW,EACX,KAAK,sBAAsB,GAC5B,MAAM,aAAa,CAAA;AACpB,YAAY,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { admitIssuer, issuerRouteReservations, mountIssuer, } from './routes.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../issuer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,WAAW,GAEZ,MAAM,aAAa,CAAA"}
@@ -0,0 +1,13 @@
1
+ import type { CorsPolicy } from '../cors/index.js';
2
+ import type { ActiveOperations } from '../lifecycle/index.js';
3
+ import type { ServerRouter } from '../transport/index.js';
4
+ import type { Issuer } from './types.js';
5
+ export interface IssuerRouteReservation {
6
+ readonly path: string;
7
+ readonly methods: readonly string[];
8
+ }
9
+ export declare function issuerRouteReservations(input: Issuer): readonly IssuerRouteReservation[];
10
+ export declare function mountIssuer(app: ServerRouter, input: Issuer, cors: CorsPolicy, active: ActiveOperations, timeoutMs: number): void;
11
+ /** Admit static discovery configuration before Runtime Boot performs any durable work. */
12
+ export declare function admitIssuer(input: Issuer): Issuer;
13
+ //# sourceMappingURL=routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../issuer/routes.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAIxC,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;CACpC;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,sBAAsB,EAAE,CAoBxF;AAED,wBAAgB,WAAW,CACzB,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,MAAM,GAChB,IAAI,CAoIN;AAWD,0FAA0F;AAC1F,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAyBjD"}
@@ -0,0 +1,138 @@
1
+ import { issuer as issuerDiscovery } from '@astrale-os/kernel-protocol';
2
+ import { IssuerKeysUnavailableError } from '../errors/index.js';
3
+ export function issuerRouteReservations(input) {
4
+ const paths = issuerDiscovery.paths(input.issuer);
5
+ const reservations = [
6
+ Object.freeze({ path: paths.configuration, methods: Object.freeze(['GET']) }),
7
+ Object.freeze({ path: paths.keys, methods: Object.freeze(['GET']) }),
8
+ ];
9
+ if (input.loadIssuerPublicKeys !== undefined) {
10
+ const base = new URL(input.issuer).pathname.replace(/\/+$/u, '');
11
+ reservations.push(Object.freeze({
12
+ path: `${base}/iss/{thumbprint}/.well-known/openid-configuration`,
13
+ methods: Object.freeze(['GET']),
14
+ }), Object.freeze({
15
+ path: `${base}/iss/{thumbprint}/.well-known/jwks.json`,
16
+ methods: Object.freeze(['GET']),
17
+ }));
18
+ }
19
+ return Object.freeze(reservations);
20
+ }
21
+ export function mountIssuer(app, input, cors, active, timeoutMs) {
22
+ const issuer = input.issuer;
23
+ const paths = issuerDiscovery.paths(issuer);
24
+ const headers = (request) => ({
25
+ ...cors.response(request),
26
+ 'cache-control': 'no-cache',
27
+ });
28
+ const algorithm = input.signingAlgorithm ?? 'ES256';
29
+ const configuration = issuerDiscovery.configuration(issuer, [algorithm]);
30
+ app.get(paths.configuration, (context) => context.json(configuration, 200, headers(context.req.raw)));
31
+ if (cors.enabled) {
32
+ app.options(paths.configuration, (context) => cors.preflight(context.req.raw, { methods: ['GET'] }));
33
+ app.options(paths.keys, (context) => cors.preflight(context.req.raw, { methods: ['GET'] }));
34
+ }
35
+ app.get(paths.keys, async (context) => {
36
+ const operation = active.begin(timeoutMs, context.req.raw.signal);
37
+ if (operation === undefined) {
38
+ return context.json({ error: 'Issuer is unavailable while draining.' }, 503, headers(context.req.raw));
39
+ }
40
+ try {
41
+ const keys = await input.loadPublicKeys(operation.signal);
42
+ return context.json(issuerDiscovery.keySet(keys, [algorithm]), 200, headers(context.req.raw));
43
+ }
44
+ catch (cause) {
45
+ if (operation.signal.aborted || cause instanceof IssuerKeysUnavailableError) {
46
+ return context.json({ error: 'Issuer keys are unavailable.' }, 503, headers(context.req.raw));
47
+ }
48
+ throw cause;
49
+ }
50
+ finally {
51
+ operation.settle();
52
+ }
53
+ });
54
+ const loadIssuerPublicKeys = input.loadIssuerPublicKeys;
55
+ if (loadIssuerPublicKeys !== undefined) {
56
+ const base = new URL(issuer).pathname.replace(/\/+$/, '');
57
+ if (cors.enabled) {
58
+ app.options(`${base}/iss/:thumbprint/.well-known/openid-configuration`, (context) => cors.preflight(context.req.raw, { methods: ['GET'] }));
59
+ app.options(`${base}/iss/:thumbprint/.well-known/jwks.json`, (context) => cors.preflight(context.req.raw, { methods: ['GET'] }));
60
+ }
61
+ app.get(`${base}/iss/:thumbprint/.well-known/openid-configuration`, async (context) => {
62
+ const hostedIssuer = issuerDiscovery.hosted(issuer, context.req.param('thumbprint'));
63
+ if (hostedIssuer === undefined)
64
+ return context.json({ error: 'Issuer not found.' }, 404, headers(context.req.raw));
65
+ const operation = active.begin(timeoutMs, context.req.raw.signal);
66
+ if (operation === undefined) {
67
+ return context.json({ error: 'Issuer is unavailable while draining.' }, 503, headers(context.req.raw));
68
+ }
69
+ try {
70
+ const keys = await hostedKeys(loadIssuerPublicKeys, hostedIssuer, operation.signal, algorithm);
71
+ if (keys.length === 0)
72
+ return context.json({ error: 'Issuer not found.' }, 404, headers(context.req.raw));
73
+ return context.json(issuerDiscovery.configuration(hostedIssuer, [algorithm]), 200, headers(context.req.raw));
74
+ }
75
+ catch (cause) {
76
+ if (operation.signal.aborted || cause instanceof IssuerKeysUnavailableError) {
77
+ return context.json({ error: 'Issuer keys are unavailable.' }, 503, headers(context.req.raw));
78
+ }
79
+ throw cause;
80
+ }
81
+ finally {
82
+ operation.settle();
83
+ }
84
+ });
85
+ app.get(`${base}/iss/:thumbprint/.well-known/jwks.json`, async (context) => {
86
+ const hostedIssuer = issuerDiscovery.hosted(issuer, context.req.param('thumbprint'));
87
+ if (hostedIssuer === undefined)
88
+ return context.json({ error: 'Issuer not found.' }, 404, headers(context.req.raw));
89
+ const operation = active.begin(timeoutMs, context.req.raw.signal);
90
+ if (operation === undefined) {
91
+ return context.json({ error: 'Issuer is unavailable while draining.' }, 503, headers(context.req.raw));
92
+ }
93
+ try {
94
+ const keys = await hostedKeys(loadIssuerPublicKeys, hostedIssuer, operation.signal, algorithm);
95
+ if (keys.length === 0)
96
+ return context.json({ error: 'Issuer not found.' }, 404, headers(context.req.raw));
97
+ return context.json({ keys }, 200, headers(context.req.raw));
98
+ }
99
+ catch (cause) {
100
+ if (operation.signal.aborted || cause instanceof IssuerKeysUnavailableError) {
101
+ return context.json({ error: 'Issuer keys are unavailable.' }, 503, headers(context.req.raw));
102
+ }
103
+ throw cause;
104
+ }
105
+ finally {
106
+ operation.settle();
107
+ }
108
+ });
109
+ }
110
+ }
111
+ async function hostedKeys(load, issuer, signal, algorithm) {
112
+ return issuerDiscovery.keySet(await load(issuer, signal), [algorithm]).keys;
113
+ }
114
+ /** Admit static discovery configuration before Runtime Boot performs any durable work. */
115
+ export function admitIssuer(input) {
116
+ const signingAlgorithm = input.signingAlgorithm ?? 'ES256';
117
+ const issuer = issuerDiscovery.configuration(input.issuer, [signingAlgorithm]).issuer;
118
+ if (typeof input.loadPublicKeys !== 'function') {
119
+ throw new TypeError('Issuer public-key loader is invalid.');
120
+ }
121
+ if (input.loadIssuerPublicKeys !== undefined &&
122
+ typeof input.loadIssuerPublicKeys !== 'function') {
123
+ throw new TypeError('Hosted issuer discovery loader is invalid.');
124
+ }
125
+ const loadPublicKeys = input.loadPublicKeys;
126
+ const loadIssuerPublicKeys = input.loadIssuerPublicKeys;
127
+ return Object.freeze({
128
+ issuer,
129
+ signingAlgorithm,
130
+ loadPublicKeys: (signal) => loadPublicKeys.call(input, signal),
131
+ ...(loadIssuerPublicKeys === undefined
132
+ ? {}
133
+ : {
134
+ loadIssuerPublicKeys: (hostedIssuer, signal) => loadIssuerPublicKeys.call(input, hostedIssuer, signal),
135
+ }),
136
+ });
137
+ }
138
+ //# sourceMappingURL=routes.js.map