@astrale-os/kernel-client 0.6.0-beta.9 → 1.0.0-beta.2

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 (533) hide show
  1. package/dist/auth/auth.d.ts +22 -10
  2. package/dist/auth/auth.js +5 -7
  3. package/dist/auth/authorization.d.ts +4 -2
  4. package/dist/auth/authorization.js +25 -6
  5. package/dist/auth/credential.d.ts +7 -4
  6. package/dist/auth/credential.js +6 -3
  7. package/dist/auth/identity.d.ts +7 -9
  8. package/dist/auth/identity.js +0 -1
  9. package/dist/auth/index.d.ts +4 -5
  10. package/dist/auth/index.js +2 -4
  11. package/dist/auth/register.d.ts +24 -0
  12. package/dist/auth/register.js +10 -0
  13. package/dist/client/admission.d.ts +4 -2
  14. package/dist/client/admission.js +9 -11
  15. package/dist/client/client.d.ts +4 -3
  16. package/dist/client/client.js +16 -4
  17. package/dist/client/credential.d.ts +5 -3
  18. package/dist/client/credential.js +7 -3
  19. package/dist/client/index.d.ts +2 -3
  20. package/dist/client/index.js +2 -3
  21. package/dist/client/request.d.ts +10 -4
  22. package/dist/client/request.js +33 -6
  23. package/dist/client/result.d.ts +3 -4
  24. package/dist/client/result.js +3 -1
  25. package/dist/client/routing-control.d.ts +11 -4
  26. package/dist/client/routing-control.js +18 -4
  27. package/dist/errors/client-error.d.ts +0 -1
  28. package/dist/errors/client-error.js +0 -1
  29. package/dist/errors/exchange-error.d.ts +19 -0
  30. package/dist/errors/exchange-error.js +9 -0
  31. package/dist/errors/index.d.ts +1 -1
  32. package/dist/errors/index.js +1 -1
  33. package/dist/errors/miss-error.d.ts +0 -1
  34. package/dist/errors/miss-error.js +0 -1
  35. package/dist/errors/protocol-error.d.ts +0 -1
  36. package/dist/errors/protocol-error.js +0 -1
  37. package/dist/errors/response-error.d.ts +0 -1
  38. package/dist/errors/response-error.js +0 -1
  39. package/dist/errors/session-error.d.ts +0 -1
  40. package/dist/errors/session-error.js +0 -1
  41. package/dist/errors/stale-route-error.d.ts +4 -4
  42. package/dist/errors/stale-route-error.js +5 -5
  43. package/dist/errors/transport-error.d.ts +3 -3
  44. package/dist/errors/transport-error.js +0 -1
  45. package/dist/graph/domain/binding.d.ts +0 -1
  46. package/dist/graph/domain/binding.js +0 -1
  47. package/dist/graph/domain/domain.typecheck.d.ts +0 -1
  48. package/dist/graph/domain/domain.typecheck.js +21 -1
  49. package/dist/graph/domain/index.d.ts +0 -1
  50. package/dist/graph/domain/index.js +0 -1
  51. package/dist/graph/domain/model.d.ts +0 -1
  52. package/dist/graph/domain/model.js +0 -1
  53. package/dist/graph/domain/page.d.ts +0 -1
  54. package/dist/graph/domain/page.js +0 -1
  55. package/dist/graph/domain/project.d.ts +0 -1
  56. package/dist/graph/domain/project.js +10 -7
  57. package/dist/graph/domain/provenance.d.ts +0 -1
  58. package/dist/graph/domain/provenance.js +0 -1
  59. package/dist/graph/errors.d.ts +0 -1
  60. package/dist/graph/errors.js +1 -3
  61. package/dist/graph/expectation.d.ts +3 -0
  62. package/dist/graph/expectation.js +6 -0
  63. package/dist/graph/graph.d.ts +6 -3
  64. package/dist/graph/graph.js +0 -1
  65. package/dist/graph/index.d.ts +2 -3
  66. package/dist/graph/index.js +1 -2
  67. package/dist/graph/mutation.d.ts +2 -4
  68. package/dist/graph/mutation.js +12 -2
  69. package/dist/graph/page/index.d.ts +0 -1
  70. package/dist/graph/page/index.js +0 -1
  71. package/dist/graph/page/neighbors.d.ts +0 -1
  72. package/dist/graph/page/neighbors.js +2 -2
  73. package/dist/graph/page/page.d.ts +0 -1
  74. package/dist/graph/page/page.js +0 -1
  75. package/dist/graph/page-contract.d.ts +0 -1
  76. package/dist/graph/page-contract.js +0 -1
  77. package/dist/graph/provenance.d.ts +2 -1
  78. package/dist/graph/provenance.js +5 -1
  79. package/dist/graph/query.d.ts +3 -1
  80. package/dist/graph/query.js +15 -8
  81. package/dist/graph/read.d.ts +0 -1
  82. package/dist/graph/read.js +6 -5
  83. package/dist/index.d.ts +3 -3
  84. package/dist/index.js +1 -1
  85. package/dist/pacer/batcher/batcher.d.ts +0 -1
  86. package/dist/pacer/batcher/batcher.js +0 -1
  87. package/dist/pacer/batcher/defaults.d.ts +0 -1
  88. package/dist/pacer/batcher/defaults.js +0 -1
  89. package/dist/pacer/batcher/index.d.ts +0 -1
  90. package/dist/pacer/batcher/index.js +0 -1
  91. package/dist/pacer/index.d.ts +0 -1
  92. package/dist/pacer/index.js +0 -1
  93. package/dist/pacer/limiter/defaults.d.ts +0 -1
  94. package/dist/pacer/limiter/defaults.js +0 -1
  95. package/dist/pacer/limiter/index.d.ts +0 -1
  96. package/dist/pacer/limiter/index.js +0 -1
  97. package/dist/pacer/limiter/limiter.d.ts +0 -1
  98. package/dist/pacer/limiter/limiter.js +0 -1
  99. package/dist/pacer/queue/defaults.d.ts +0 -1
  100. package/dist/pacer/queue/defaults.js +0 -1
  101. package/dist/pacer/queue/index.d.ts +0 -1
  102. package/dist/pacer/queue/index.js +0 -1
  103. package/dist/pacer/queue/queue.d.ts +0 -1
  104. package/dist/pacer/queue/queue.js +0 -1
  105. package/dist/pacer/retry/defaults.d.ts +0 -1
  106. package/dist/pacer/retry/defaults.js +0 -1
  107. package/dist/pacer/retry/index.d.ts +0 -1
  108. package/dist/pacer/retry/index.js +0 -1
  109. package/dist/pacer/retry/retry.d.ts +0 -1
  110. package/dist/pacer/retry/retry.js +0 -1
  111. package/dist/pool/index.d.ts +0 -1
  112. package/dist/pool/index.js +0 -1
  113. package/dist/pool/pool.d.ts +0 -1
  114. package/dist/pool/pool.js +0 -1
  115. package/dist/pool/target.d.ts +0 -1
  116. package/dist/pool/target.js +0 -1
  117. package/dist/schema/admission.d.ts +0 -1
  118. package/dist/schema/admission.js +0 -1
  119. package/dist/schema/contracts.d.ts +3 -4
  120. package/dist/schema/contracts.js +0 -1
  121. package/dist/schema/index.d.ts +2 -3
  122. package/dist/schema/index.js +1 -2
  123. package/dist/schema/introspection.d.ts +0 -1
  124. package/dist/schema/introspection.js +10 -3
  125. package/dist/schema/operation.d.ts +0 -1
  126. package/dist/schema/operation.js +1 -2
  127. package/dist/schema/schema.d.ts +16 -10
  128. package/dist/schema/schema.js +92 -13
  129. package/dist/session/admission.d.ts +6 -0
  130. package/dist/session/admission.js +52 -0
  131. package/dist/session/bound.d.ts +17 -14
  132. package/dist/session/bound.js +54 -10
  133. package/dist/session/content/api.d.ts +45 -0
  134. package/dist/session/content/api.js +28 -0
  135. package/dist/session/content/batch.d.ts +5 -0
  136. package/dist/session/content/batch.js +93 -0
  137. package/dist/session/content/index.d.ts +1 -0
  138. package/dist/session/content/index.js +1 -0
  139. package/dist/session/content/input.d.ts +9 -0
  140. package/dist/session/content/input.js +33 -0
  141. package/dist/session/content/parts.d.ts +36 -0
  142. package/dist/session/content/parts.js +154 -0
  143. package/dist/session/content/retry.d.ts +3 -0
  144. package/dist/session/content/retry.js +41 -0
  145. package/dist/session/content/wire.d.ts +12 -0
  146. package/dist/session/content/wire.js +60 -0
  147. package/dist/session/context/control.d.ts +0 -1
  148. package/dist/session/context/control.js +0 -1
  149. package/dist/session/context/index.d.ts +2 -3
  150. package/dist/session/context/index.js +2 -3
  151. package/dist/session/context/limits.d.ts +1 -2
  152. package/dist/session/context/limits.js +1 -2
  153. package/dist/session/context/operation.d.ts +5 -3
  154. package/dist/session/context/operation.js +1 -2
  155. package/dist/session/context/policy.d.ts +0 -2
  156. package/dist/session/context/policy.js +0 -17
  157. package/dist/session/credential/credentials.d.ts +65 -0
  158. package/dist/session/credential/credentials.js +296 -0
  159. package/dist/session/credential/index.d.ts +1 -0
  160. package/dist/session/credential/index.js +1 -0
  161. package/dist/session/credential/limits.d.ts +14 -0
  162. package/dist/session/credential/limits.js +14 -0
  163. package/dist/session/discovery/bundle.d.ts +9 -5
  164. package/dist/session/discovery/bundle.js +43 -26
  165. package/dist/session/discovery/discovery.d.ts +12 -5
  166. package/dist/session/discovery/discovery.js +42 -13
  167. package/dist/session/discovery/index.d.ts +6 -2
  168. package/dist/session/discovery/index.js +4 -8
  169. package/dist/session/discovery/release.d.ts +30 -0
  170. package/dist/session/discovery/release.js +81 -0
  171. package/dist/session/discovery/response.d.ts +3 -0
  172. package/dist/session/discovery/response.js +59 -0
  173. package/dist/session/discovery/snapshot.d.ts +4 -5
  174. package/dist/session/discovery/snapshot.js +2 -3
  175. package/dist/session/discovery/transport.d.ts +1 -4
  176. package/dist/session/discovery/transport.js +0 -1
  177. package/dist/session/exchange/domain.d.ts +27 -0
  178. package/dist/session/exchange/domain.js +63 -0
  179. package/dist/session/exchange/exchange.d.ts +48 -0
  180. package/dist/session/exchange/exchange.js +54 -0
  181. package/dist/session/exchange/index.d.ts +5 -0
  182. package/dist/session/exchange/index.js +5 -0
  183. package/dist/session/exchange/issuer.d.ts +18 -0
  184. package/dist/session/exchange/issuer.js +149 -0
  185. package/dist/session/exchange/limits.d.ts +10 -0
  186. package/dist/session/exchange/limits.js +10 -0
  187. package/dist/session/exchange/options.d.ts +37 -0
  188. package/dist/session/exchange/options.js +65 -0
  189. package/dist/session/exchange/presentation.d.ts +19 -0
  190. package/dist/session/exchange/presentation.js +72 -0
  191. package/dist/session/exchange/source.d.ts +33 -0
  192. package/dist/session/exchange/source.js +78 -0
  193. package/dist/session/execution.d.ts +65 -0
  194. package/dist/session/execution.js +34 -0
  195. package/dist/session/index.d.ts +9 -6
  196. package/dist/session/index.js +3 -2
  197. package/dist/session/options.d.ts +65 -0
  198. package/dist/session/options.js +132 -0
  199. package/dist/session/reference.d.ts +35 -20
  200. package/dist/session/reference.js +28 -11
  201. package/dist/session/routing/auth.d.ts +10 -1
  202. package/dist/session/routing/auth.js +8 -2
  203. package/dist/session/routing/cache.d.ts +21 -7
  204. package/dist/session/routing/cache.js +103 -73
  205. package/dist/session/routing/dispatch.d.ts +19 -11
  206. package/dist/session/routing/dispatch.js +113 -89
  207. package/dist/session/routing/envelope.d.ts +4 -3
  208. package/dist/session/routing/envelope.js +14 -10
  209. package/dist/session/routing/expiry.d.ts +4 -0
  210. package/dist/session/routing/expiry.js +32 -0
  211. package/dist/session/routing/index.d.ts +5 -5
  212. package/dist/session/routing/index.js +4 -3
  213. package/dist/session/routing/integrity.d.ts +7 -0
  214. package/dist/session/routing/integrity.js +44 -0
  215. package/dist/session/routing/recovery.d.ts +16 -0
  216. package/dist/session/routing/recovery.js +41 -0
  217. package/dist/session/routing/request.d.ts +9 -1
  218. package/dist/session/routing/request.js +17 -1
  219. package/dist/session/routing/result.d.ts +5 -0
  220. package/dist/session/routing/result.js +12 -0
  221. package/dist/session/routing/store.d.ts +23 -0
  222. package/dist/session/routing/store.js +99 -0
  223. package/dist/session/session.d.ts +37 -33
  224. package/dist/session/session.js +126 -152
  225. package/dist/session/session.typecheck.d.ts +0 -1
  226. package/dist/session/session.typecheck.js +183 -5
  227. package/dist/session/views/catalog.d.ts +9 -6
  228. package/dist/session/views/catalog.js +29 -23
  229. package/dist/session/views/index.d.ts +1 -2
  230. package/dist/session/views/index.js +1 -2
  231. package/dist/session/views/resolve.d.ts +6 -5
  232. package/dist/session/views/resolve.js +14 -7
  233. package/dist/store/entity-index.d.ts +1 -3
  234. package/dist/store/entity-index.js +0 -4
  235. package/dist/store/index.d.ts +0 -1
  236. package/dist/store/index.js +0 -1
  237. package/dist/store/memory.d.ts +2 -2
  238. package/dist/store/memory.js +40 -17
  239. package/dist/store/mutation.d.ts +1 -2
  240. package/dist/store/mutation.js +6 -4
  241. package/dist/store/observe.d.ts +0 -1
  242. package/dist/store/observe.js +0 -1
  243. package/dist/store/optimistic.d.ts +0 -1
  244. package/dist/store/optimistic.js +0 -1
  245. package/dist/store/query-key.d.ts +2 -2
  246. package/dist/store/query-key.js +7 -3
  247. package/dist/store/shape.d.ts +6 -3
  248. package/dist/store/shape.js +4 -2
  249. package/dist/store/store.d.ts +2 -4
  250. package/dist/store/store.js +6 -5
  251. package/dist/store/store.typecheck.d.ts +0 -1
  252. package/dist/store/store.typecheck.js +0 -6
  253. package/dist/transport/auto/decision.d.ts +3 -3
  254. package/dist/transport/auto/decision.js +0 -1
  255. package/dist/transport/auto/fallback.d.ts +2 -2
  256. package/dist/transport/auto/fallback.js +2 -2
  257. package/dist/transport/auto/index.d.ts +0 -1
  258. package/dist/transport/auto/index.js +0 -1
  259. package/dist/transport/auto/transport.d.ts +0 -2
  260. package/dist/transport/auto/transport.js +0 -3
  261. package/dist/transport/auto/warning.d.ts +0 -1
  262. package/dist/transport/auto/warning.js +5 -3
  263. package/dist/transport/deadline.d.ts +0 -1
  264. package/dist/transport/deadline.js +0 -1
  265. package/dist/transport/failure.d.ts +0 -1
  266. package/dist/transport/failure.js +0 -1
  267. package/dist/transport/http/admission.d.ts +5 -0
  268. package/dist/transport/http/admission.js +101 -0
  269. package/dist/transport/http/binary.d.ts +5 -0
  270. package/dist/transport/http/binary.js +70 -0
  271. package/dist/transport/http/byte-stream.d.ts +18 -0
  272. package/dist/transport/http/byte-stream.js +94 -0
  273. package/dist/transport/http/configuration.d.ts +24 -0
  274. package/dist/transport/http/configuration.js +116 -0
  275. package/dist/transport/http/index.d.ts +2 -2
  276. package/dist/transport/http/index.js +0 -1
  277. package/dist/transport/http/response.d.ts +8 -2
  278. package/dist/transport/http/response.js +11 -7
  279. package/dist/transport/http/retired.d.ts +8 -0
  280. package/dist/transport/http/retired.js +28 -0
  281. package/dist/transport/http/stream.d.ts +0 -1
  282. package/dist/transport/http/stream.js +0 -1
  283. package/dist/transport/http/transport.d.ts +4 -18
  284. package/dist/transport/http/transport.js +48 -252
  285. package/dist/transport/index.d.ts +1 -2
  286. package/dist/transport/index.js +0 -1
  287. package/dist/transport/transport.d.ts +10 -3
  288. package/dist/transport/transport.js +0 -1
  289. package/dist/transport/websocket/connection.d.ts +2 -2
  290. package/dist/transport/websocket/connection.js +5 -3
  291. package/dist/transport/websocket/exchange.d.ts +0 -1
  292. package/dist/transport/websocket/exchange.js +0 -1
  293. package/dist/transport/websocket/index.d.ts +0 -1
  294. package/dist/transport/websocket/index.js +0 -1
  295. package/dist/transport/websocket/transport.d.ts +0 -4
  296. package/dist/transport/websocket/transport.js +2 -18
  297. package/package.json +12 -15
  298. package/dist/auth/auth.d.ts.map +0 -1
  299. package/dist/auth/auth.js.map +0 -1
  300. package/dist/auth/authorization.d.ts.map +0 -1
  301. package/dist/auth/authorization.js.map +0 -1
  302. package/dist/auth/credential.d.ts.map +0 -1
  303. package/dist/auth/credential.js.map +0 -1
  304. package/dist/auth/identity.d.ts.map +0 -1
  305. package/dist/auth/identity.js.map +0 -1
  306. package/dist/auth/index.d.ts.map +0 -1
  307. package/dist/auth/index.js.map +0 -1
  308. package/dist/auth/provision.d.ts +0 -9
  309. package/dist/auth/provision.d.ts.map +0 -1
  310. package/dist/auth/provision.js +0 -11
  311. package/dist/auth/provision.js.map +0 -1
  312. package/dist/client/admission.d.ts.map +0 -1
  313. package/dist/client/admission.js.map +0 -1
  314. package/dist/client/client.d.ts.map +0 -1
  315. package/dist/client/client.js.map +0 -1
  316. package/dist/client/credential.d.ts.map +0 -1
  317. package/dist/client/credential.js.map +0 -1
  318. package/dist/client/index.d.ts.map +0 -1
  319. package/dist/client/index.js.map +0 -1
  320. package/dist/client/request.d.ts.map +0 -1
  321. package/dist/client/request.js.map +0 -1
  322. package/dist/client/result.d.ts.map +0 -1
  323. package/dist/client/result.js.map +0 -1
  324. package/dist/client/routing-control.d.ts.map +0 -1
  325. package/dist/client/routing-control.js.map +0 -1
  326. package/dist/errors/client-error.d.ts.map +0 -1
  327. package/dist/errors/client-error.js.map +0 -1
  328. package/dist/errors/index.d.ts.map +0 -1
  329. package/dist/errors/index.js.map +0 -1
  330. package/dist/errors/miss-error.d.ts.map +0 -1
  331. package/dist/errors/miss-error.js.map +0 -1
  332. package/dist/errors/protocol-error.d.ts.map +0 -1
  333. package/dist/errors/protocol-error.js.map +0 -1
  334. package/dist/errors/response-error.d.ts.map +0 -1
  335. package/dist/errors/response-error.js.map +0 -1
  336. package/dist/errors/session-error.d.ts.map +0 -1
  337. package/dist/errors/session-error.js.map +0 -1
  338. package/dist/errors/stale-route-error.d.ts.map +0 -1
  339. package/dist/errors/stale-route-error.js.map +0 -1
  340. package/dist/errors/transport-error.d.ts.map +0 -1
  341. package/dist/errors/transport-error.js.map +0 -1
  342. package/dist/graph/domain/binding.d.ts.map +0 -1
  343. package/dist/graph/domain/binding.js.map +0 -1
  344. package/dist/graph/domain/domain.typecheck.d.ts.map +0 -1
  345. package/dist/graph/domain/domain.typecheck.js.map +0 -1
  346. package/dist/graph/domain/index.d.ts.map +0 -1
  347. package/dist/graph/domain/index.js.map +0 -1
  348. package/dist/graph/domain/model.d.ts.map +0 -1
  349. package/dist/graph/domain/model.js.map +0 -1
  350. package/dist/graph/domain/page.d.ts.map +0 -1
  351. package/dist/graph/domain/page.js.map +0 -1
  352. package/dist/graph/domain/project.d.ts.map +0 -1
  353. package/dist/graph/domain/project.js.map +0 -1
  354. package/dist/graph/domain/provenance.d.ts.map +0 -1
  355. package/dist/graph/domain/provenance.js.map +0 -1
  356. package/dist/graph/errors.d.ts.map +0 -1
  357. package/dist/graph/errors.js.map +0 -1
  358. package/dist/graph/graph.d.ts.map +0 -1
  359. package/dist/graph/graph.js.map +0 -1
  360. package/dist/graph/index.d.ts.map +0 -1
  361. package/dist/graph/index.js.map +0 -1
  362. package/dist/graph/mutation.d.ts.map +0 -1
  363. package/dist/graph/mutation.js.map +0 -1
  364. package/dist/graph/page/index.d.ts.map +0 -1
  365. package/dist/graph/page/index.js.map +0 -1
  366. package/dist/graph/page/neighbors.d.ts.map +0 -1
  367. package/dist/graph/page/neighbors.js.map +0 -1
  368. package/dist/graph/page/page.d.ts.map +0 -1
  369. package/dist/graph/page/page.js.map +0 -1
  370. package/dist/graph/page-contract.d.ts.map +0 -1
  371. package/dist/graph/page-contract.js.map +0 -1
  372. package/dist/graph/provenance.d.ts.map +0 -1
  373. package/dist/graph/provenance.js.map +0 -1
  374. package/dist/graph/query.d.ts.map +0 -1
  375. package/dist/graph/query.js.map +0 -1
  376. package/dist/graph/read.d.ts.map +0 -1
  377. package/dist/graph/read.js.map +0 -1
  378. package/dist/index.d.ts.map +0 -1
  379. package/dist/index.js.map +0 -1
  380. package/dist/pacer/batcher/batcher.d.ts.map +0 -1
  381. package/dist/pacer/batcher/batcher.js.map +0 -1
  382. package/dist/pacer/batcher/defaults.d.ts.map +0 -1
  383. package/dist/pacer/batcher/defaults.js.map +0 -1
  384. package/dist/pacer/batcher/index.d.ts.map +0 -1
  385. package/dist/pacer/batcher/index.js.map +0 -1
  386. package/dist/pacer/index.d.ts.map +0 -1
  387. package/dist/pacer/index.js.map +0 -1
  388. package/dist/pacer/limiter/defaults.d.ts.map +0 -1
  389. package/dist/pacer/limiter/defaults.js.map +0 -1
  390. package/dist/pacer/limiter/index.d.ts.map +0 -1
  391. package/dist/pacer/limiter/index.js.map +0 -1
  392. package/dist/pacer/limiter/limiter.d.ts.map +0 -1
  393. package/dist/pacer/limiter/limiter.js.map +0 -1
  394. package/dist/pacer/queue/defaults.d.ts.map +0 -1
  395. package/dist/pacer/queue/defaults.js.map +0 -1
  396. package/dist/pacer/queue/index.d.ts.map +0 -1
  397. package/dist/pacer/queue/index.js.map +0 -1
  398. package/dist/pacer/queue/queue.d.ts.map +0 -1
  399. package/dist/pacer/queue/queue.js.map +0 -1
  400. package/dist/pacer/retry/defaults.d.ts.map +0 -1
  401. package/dist/pacer/retry/defaults.js.map +0 -1
  402. package/dist/pacer/retry/index.d.ts.map +0 -1
  403. package/dist/pacer/retry/index.js.map +0 -1
  404. package/dist/pacer/retry/retry.d.ts.map +0 -1
  405. package/dist/pacer/retry/retry.js.map +0 -1
  406. package/dist/pool/index.d.ts.map +0 -1
  407. package/dist/pool/index.js.map +0 -1
  408. package/dist/pool/pool.d.ts.map +0 -1
  409. package/dist/pool/pool.js.map +0 -1
  410. package/dist/pool/target.d.ts.map +0 -1
  411. package/dist/pool/target.js.map +0 -1
  412. package/dist/schema/admission.d.ts.map +0 -1
  413. package/dist/schema/admission.js.map +0 -1
  414. package/dist/schema/contracts.d.ts.map +0 -1
  415. package/dist/schema/contracts.js.map +0 -1
  416. package/dist/schema/index.d.ts.map +0 -1
  417. package/dist/schema/index.js.map +0 -1
  418. package/dist/schema/introspection.d.ts.map +0 -1
  419. package/dist/schema/introspection.js.map +0 -1
  420. package/dist/schema/operation.d.ts.map +0 -1
  421. package/dist/schema/operation.js.map +0 -1
  422. package/dist/schema/schema.d.ts.map +0 -1
  423. package/dist/schema/schema.js.map +0 -1
  424. package/dist/session/bound.d.ts.map +0 -1
  425. package/dist/session/bound.js.map +0 -1
  426. package/dist/session/context/control.d.ts.map +0 -1
  427. package/dist/session/context/control.js.map +0 -1
  428. package/dist/session/context/index.d.ts.map +0 -1
  429. package/dist/session/context/index.js.map +0 -1
  430. package/dist/session/context/limits.d.ts.map +0 -1
  431. package/dist/session/context/limits.js.map +0 -1
  432. package/dist/session/context/operation.d.ts.map +0 -1
  433. package/dist/session/context/operation.js.map +0 -1
  434. package/dist/session/context/policy.d.ts.map +0 -1
  435. package/dist/session/context/policy.js.map +0 -1
  436. package/dist/session/discovery/bundle.d.ts.map +0 -1
  437. package/dist/session/discovery/bundle.js.map +0 -1
  438. package/dist/session/discovery/discovery.d.ts.map +0 -1
  439. package/dist/session/discovery/discovery.js.map +0 -1
  440. package/dist/session/discovery/index.d.ts.map +0 -1
  441. package/dist/session/discovery/index.js.map +0 -1
  442. package/dist/session/discovery/publication.d.ts +0 -24
  443. package/dist/session/discovery/publication.d.ts.map +0 -1
  444. package/dist/session/discovery/publication.js +0 -124
  445. package/dist/session/discovery/publication.js.map +0 -1
  446. package/dist/session/discovery/snapshot.d.ts.map +0 -1
  447. package/dist/session/discovery/snapshot.js.map +0 -1
  448. package/dist/session/discovery/transport.d.ts.map +0 -1
  449. package/dist/session/discovery/transport.js.map +0 -1
  450. package/dist/session/index.d.ts.map +0 -1
  451. package/dist/session/index.js.map +0 -1
  452. package/dist/session/reference.d.ts.map +0 -1
  453. package/dist/session/reference.js.map +0 -1
  454. package/dist/session/routing/auth.d.ts.map +0 -1
  455. package/dist/session/routing/auth.js.map +0 -1
  456. package/dist/session/routing/cache.d.ts.map +0 -1
  457. package/dist/session/routing/cache.js.map +0 -1
  458. package/dist/session/routing/dispatch.d.ts.map +0 -1
  459. package/dist/session/routing/dispatch.js.map +0 -1
  460. package/dist/session/routing/envelope.d.ts.map +0 -1
  461. package/dist/session/routing/envelope.js.map +0 -1
  462. package/dist/session/routing/expectation.d.ts +0 -7
  463. package/dist/session/routing/expectation.d.ts.map +0 -1
  464. package/dist/session/routing/expectation.js +0 -2
  465. package/dist/session/routing/expectation.js.map +0 -1
  466. package/dist/session/routing/index.d.ts.map +0 -1
  467. package/dist/session/routing/index.js.map +0 -1
  468. package/dist/session/routing/request.d.ts.map +0 -1
  469. package/dist/session/routing/request.js.map +0 -1
  470. package/dist/session/session.d.ts.map +0 -1
  471. package/dist/session/session.js.map +0 -1
  472. package/dist/session/session.typecheck.d.ts.map +0 -1
  473. package/dist/session/session.typecheck.js.map +0 -1
  474. package/dist/session/views/catalog.d.ts.map +0 -1
  475. package/dist/session/views/catalog.js.map +0 -1
  476. package/dist/session/views/index.d.ts.map +0 -1
  477. package/dist/session/views/index.js.map +0 -1
  478. package/dist/session/views/resolve.d.ts.map +0 -1
  479. package/dist/session/views/resolve.js.map +0 -1
  480. package/dist/store/entity-index.d.ts.map +0 -1
  481. package/dist/store/entity-index.js.map +0 -1
  482. package/dist/store/index.d.ts.map +0 -1
  483. package/dist/store/index.js.map +0 -1
  484. package/dist/store/memory.d.ts.map +0 -1
  485. package/dist/store/memory.js.map +0 -1
  486. package/dist/store/mutation.d.ts.map +0 -1
  487. package/dist/store/mutation.js.map +0 -1
  488. package/dist/store/observe.d.ts.map +0 -1
  489. package/dist/store/observe.js.map +0 -1
  490. package/dist/store/optimistic.d.ts.map +0 -1
  491. package/dist/store/optimistic.js.map +0 -1
  492. package/dist/store/query-key.d.ts.map +0 -1
  493. package/dist/store/query-key.js.map +0 -1
  494. package/dist/store/shape.d.ts.map +0 -1
  495. package/dist/store/shape.js.map +0 -1
  496. package/dist/store/store.d.ts.map +0 -1
  497. package/dist/store/store.js.map +0 -1
  498. package/dist/store/store.typecheck.d.ts.map +0 -1
  499. package/dist/store/store.typecheck.js.map +0 -1
  500. package/dist/transport/auto/decision.d.ts.map +0 -1
  501. package/dist/transport/auto/decision.js.map +0 -1
  502. package/dist/transport/auto/fallback.d.ts.map +0 -1
  503. package/dist/transport/auto/fallback.js.map +0 -1
  504. package/dist/transport/auto/index.d.ts.map +0 -1
  505. package/dist/transport/auto/index.js.map +0 -1
  506. package/dist/transport/auto/transport.d.ts.map +0 -1
  507. package/dist/transport/auto/transport.js.map +0 -1
  508. package/dist/transport/auto/warning.d.ts.map +0 -1
  509. package/dist/transport/auto/warning.js.map +0 -1
  510. package/dist/transport/deadline.d.ts.map +0 -1
  511. package/dist/transport/deadline.js.map +0 -1
  512. package/dist/transport/failure.d.ts.map +0 -1
  513. package/dist/transport/failure.js.map +0 -1
  514. package/dist/transport/http/index.d.ts.map +0 -1
  515. package/dist/transport/http/index.js.map +0 -1
  516. package/dist/transport/http/response.d.ts.map +0 -1
  517. package/dist/transport/http/response.js.map +0 -1
  518. package/dist/transport/http/stream.d.ts.map +0 -1
  519. package/dist/transport/http/stream.js.map +0 -1
  520. package/dist/transport/http/transport.d.ts.map +0 -1
  521. package/dist/transport/http/transport.js.map +0 -1
  522. package/dist/transport/index.d.ts.map +0 -1
  523. package/dist/transport/index.js.map +0 -1
  524. package/dist/transport/transport.d.ts.map +0 -1
  525. package/dist/transport/transport.js.map +0 -1
  526. package/dist/transport/websocket/connection.d.ts.map +0 -1
  527. package/dist/transport/websocket/connection.js.map +0 -1
  528. package/dist/transport/websocket/exchange.d.ts.map +0 -1
  529. package/dist/transport/websocket/exchange.js.map +0 -1
  530. package/dist/transport/websocket/index.d.ts.map +0 -1
  531. package/dist/transport/websocket/index.js.map +0 -1
  532. package/dist/transport/websocket/transport.d.ts.map +0 -1
  533. package/dist/transport/websocket/transport.js.map +0 -1
@@ -0,0 +1,60 @@
1
+ import { Path } from '@astrale-os/kernel-core/path';
2
+ import { download, upload } from '@astrale-os/kernel-core/schema/kernel/syscalls/references';
3
+ import * as artifact from '@astrale-os/kernel-protocol/artifact';
4
+ import { ClientError, ProtocolError } from '../../errors/index.js';
5
+ export const UPLOAD = Path.project(upload);
6
+ export const DOWNLOAD = Path.project(download);
7
+ const REJECTIONS = [
8
+ 'BLOB_NOT_FOUND',
9
+ 'BLOB_UNAVAILABLE',
10
+ 'BLOB_INTEGRITY',
11
+ ];
12
+ export function decodeUploadResult(input) {
13
+ if (input === null || typeof input !== 'object' || Array.isArray(input)) {
14
+ throw new ClientError('Content upload returned an invalid receipt.');
15
+ }
16
+ const value = input;
17
+ if (typeof value.receipt !== 'string' ||
18
+ value.receipt.length === 0 ||
19
+ typeof value.expiresAt !== 'string' ||
20
+ !Number.isFinite(Date.parse(value.expiresAt))) {
21
+ throw new ClientError('Content upload returned an invalid receipt.');
22
+ }
23
+ let ref;
24
+ try {
25
+ ref = artifact.accept(value.ref);
26
+ }
27
+ catch (cause) {
28
+ throw new ClientError('Content upload returned an invalid Ref.', { cause });
29
+ }
30
+ return Object.freeze({
31
+ receipt: value.receipt,
32
+ ref,
33
+ expiresAt: value.expiresAt,
34
+ });
35
+ }
36
+ /** The rejection a code names, or `undefined` when it names none. */
37
+ export function decodeRejection(code) {
38
+ return REJECTIONS.find((candidate) => candidate === code);
39
+ }
40
+ /** A download whose exact size is declared; anything else is closed and refused. */
41
+ export async function decodeDownload(input) {
42
+ // The HTTP transport sets `length` only from an admitted declared length, and its byte stream
43
+ // enforces that exact count through the final read.
44
+ if (input.body instanceof Uint8Array || !('length' in input) || input.length === undefined) {
45
+ await cancelBinary(input);
46
+ throw new ProtocolError('Content download omitted its exact content size.');
47
+ }
48
+ return input;
49
+ }
50
+ /** Close a streamed body nobody will read. */
51
+ export async function cancelBinary(input) {
52
+ if (input.body instanceof Uint8Array)
53
+ return;
54
+ try {
55
+ await input.body[Symbol.asyncIterator]().return?.();
56
+ }
57
+ catch {
58
+ // Preserve the admission error after the response stream has been closed.
59
+ }
60
+ }
@@ -3,4 +3,3 @@ export interface SessionControlOptions {
3
3
  readonly timeoutMs?: number;
4
4
  }
5
5
  export declare function admitControlOptions(input: SessionControlOptions | undefined): Readonly<SessionControlOptions>;
6
- //# sourceMappingURL=control.d.ts.map
@@ -15,4 +15,3 @@ export function admitControlOptions(input) {
15
15
  : { timeoutMs: platformDuration(input.timeoutMs, 'timeoutMs') }),
16
16
  });
17
17
  }
18
- //# sourceMappingURL=control.js.map
@@ -1,5 +1,4 @@
1
1
  export { admitControlOptions, type SessionControlOptions } from './control.js';
2
- export { DEFAULT_MAXIMUM_BUNDLE_BYTES, DEFAULT_MAXIMUM_PUBLICATION_BYTES, DEFAULT_MAXIMUM_RESPONSE_BYTES, DEFAULT_MAXIMUM_ROUTES, DEFAULT_TIMEOUT_MS, platformDuration, positive, } from './limits.js';
3
- export { createSessionOperation, runSessionOperation, sessionTransportOptions, type SessionOperation, } from './operation.js';
2
+ export { DEFAULT_MAXIMUM_BUNDLE_BYTES, DEFAULT_MAXIMUM_RELEASE_BYTES, DEFAULT_MAXIMUM_RESPONSE_BYTES, DEFAULT_MAXIMUM_ROUTES, DEFAULT_TIMEOUT_MS, platformDuration, positive, } from './limits.js';
3
+ export { createSessionOperation, remainingSessionTime, runSessionOperation, sessionTransportOptions, type SessionOperation, } from './operation.js';
4
4
  export { admitKernel, admitPolicy, allowEndpoint, kernelInvocationEndpoint, type SessionPolicy, } from './policy.js';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,4 @@
1
1
  export { admitControlOptions } from './control.js';
2
- export { DEFAULT_MAXIMUM_BUNDLE_BYTES, DEFAULT_MAXIMUM_PUBLICATION_BYTES, DEFAULT_MAXIMUM_RESPONSE_BYTES, DEFAULT_MAXIMUM_ROUTES, DEFAULT_TIMEOUT_MS, platformDuration, positive, } from './limits.js';
3
- export { createSessionOperation, runSessionOperation, sessionTransportOptions, } from './operation.js';
2
+ export { DEFAULT_MAXIMUM_BUNDLE_BYTES, DEFAULT_MAXIMUM_RELEASE_BYTES, DEFAULT_MAXIMUM_RESPONSE_BYTES, DEFAULT_MAXIMUM_ROUTES, DEFAULT_TIMEOUT_MS, platformDuration, positive, } from './limits.js';
3
+ export { createSessionOperation, remainingSessionTime, runSessionOperation, sessionTransportOptions, } from './operation.js';
4
4
  export { admitKernel, admitPolicy, allowEndpoint, kernelInvocationEndpoint, } from './policy.js';
5
- //# sourceMappingURL=index.js.map
@@ -1,8 +1,7 @@
1
- export declare const DEFAULT_MAXIMUM_PUBLICATION_BYTES: number;
1
+ export declare const DEFAULT_MAXIMUM_RELEASE_BYTES: number;
2
2
  export declare const DEFAULT_MAXIMUM_BUNDLE_BYTES: number;
3
3
  export declare const DEFAULT_MAXIMUM_RESPONSE_BYTES: number;
4
4
  export declare const DEFAULT_TIMEOUT_MS = 30000;
5
5
  export declare const DEFAULT_MAXIMUM_ROUTES = 256;
6
6
  export declare function positive(input: number, label: string): number;
7
7
  export declare function platformDuration(input: number, label: string): number;
8
- //# sourceMappingURL=limits.d.ts.map
@@ -1,4 +1,4 @@
1
- export const DEFAULT_MAXIMUM_PUBLICATION_BYTES = 1024 * 1024;
1
+ export const DEFAULT_MAXIMUM_RELEASE_BYTES = 1024 * 1024;
2
2
  export const DEFAULT_MAXIMUM_BUNDLE_BYTES = 16 * 1024 * 1024;
3
3
  export const DEFAULT_MAXIMUM_RESPONSE_BYTES = 16 * 1024 * 1024;
4
4
  export const DEFAULT_TIMEOUT_MS = 30_000;
@@ -16,4 +16,3 @@ export function platformDuration(input, label) {
16
16
  }
17
17
  return admitted;
18
18
  }
19
- //# sourceMappingURL=limits.js.map
@@ -13,8 +13,10 @@ export declare function createSessionOperation(lifecycle: AbortSignal, input: {
13
13
  readonly idempotencyKey?: RequestOptions['idempotencyKey'];
14
14
  } | undefined, defaultTimeoutMs: number): SessionOperation;
15
15
  export declare function remainingSessionTime(operation: SessionOperation): number;
16
- export declare function sessionTransportOptions(operation: SessionOperation, idempotencyKey?: RequestOptions['idempotencyKey']): RequestOptions;
16
+ export declare function sessionTransportOptions(operation: SessionOperation): {
17
+ readonly signal: AbortSignal;
18
+ readonly timeoutMs: number;
19
+ };
20
+ export declare function sessionTransportOptions(operation: SessionOperation, idempotencyKey: RequestOptions['idempotencyKey']): RequestOptions;
17
21
  /** Settle independently of a caller capability that ignores its supplied AbortSignal. */
18
22
  export declare function runSessionOperation<Result>(operation: SessionOperation, task: (signal: AbortSignal) => Result | PromiseLike<Result>): Promise<Result>;
19
- export declare function requireSessionOperation(operation: SessionOperation): void;
20
- //# sourceMappingURL=operation.d.ts.map
@@ -54,7 +54,7 @@ export async function runSessionOperation(operation, task) {
54
54
  operation.signal.removeEventListener('abort', abort);
55
55
  });
56
56
  }
57
- export function requireSessionOperation(operation) {
57
+ function requireSessionOperation(operation) {
58
58
  if (!operation.signal.aborted)
59
59
  return;
60
60
  throw sessionInterruption(operation.signal.reason);
@@ -70,4 +70,3 @@ function sessionInterruption(reason) {
70
70
  failure: 'cancelled',
71
71
  });
72
72
  }
73
- //# sourceMappingURL=operation.js.map
@@ -7,6 +7,4 @@ export interface SessionPolicy {
7
7
  export declare function admitPolicy(input: SessionPolicy): Readonly<SessionPolicy>;
8
8
  export declare function admitKernel(input: string, insecure: boolean): IssuerId;
9
9
  export declare function kernelInvocationEndpoint(input: IssuerId): string;
10
- export declare function websocketEndpoint(input: string, insecure: boolean): string;
11
10
  export declare function allowEndpoint(url: string, policy: Readonly<SessionPolicy>): void;
12
- //# sourceMappingURL=policy.d.ts.map
@@ -39,22 +39,6 @@ export function admitKernel(input, insecure) {
39
39
  export function kernelInvocationEndpoint(input) {
40
40
  return `${input}/invoke`;
41
41
  }
42
- export function websocketEndpoint(input, insecure) {
43
- let url;
44
- try {
45
- url = new URL(input);
46
- }
47
- catch (cause) {
48
- throw new TypeError('Session WebSocket endpoint is invalid.', { cause });
49
- }
50
- if (url.username !== '' ||
51
- url.password !== '' ||
52
- url.hash !== '' ||
53
- (url.protocol !== 'wss:' && !(insecure && url.protocol === 'ws:'))) {
54
- throw new TypeError('Session WebSocket endpoint is invalid.');
55
- }
56
- return url.toString();
57
- }
58
42
  export function allowEndpoint(url, policy) {
59
43
  const parsed = new URL(url);
60
44
  if (parsed.protocol !== 'https:' && parsed.protocol !== 'wss:') {
@@ -67,4 +51,3 @@ export function allowEndpoint(url, policy) {
67
51
  throw new ClientError('Endpoint is denied by Session policy.');
68
52
  }
69
53
  }
70
- //# sourceMappingURL=policy.js.map
@@ -0,0 +1,65 @@
1
+ import type { SessionAuth } from '../routing/index.js';
2
+ /** One source credential and the exact instant it stops being accepted. */
3
+ export interface SessionCredential {
4
+ readonly credential: string;
5
+ /** Absolute Unix time in milliseconds. */
6
+ readonly expiresAt: number;
7
+ }
8
+ /** Observable lifecycle of the single credential one Credentials owns. */
9
+ export type CredentialsState = {
10
+ readonly status: 'empty';
11
+ } | {
12
+ readonly status: 'valid';
13
+ readonly credential: SessionCredential;
14
+ } | {
15
+ readonly status: 'refreshing';
16
+ readonly credential?: SessionCredential;
17
+ } | {
18
+ readonly status: 'degraded';
19
+ readonly credential: SessionCredential;
20
+ readonly error: unknown;
21
+ } | {
22
+ readonly status: 'expired';
23
+ readonly error: unknown;
24
+ };
25
+ /**
26
+ * Acquire one fresh credential: a compact JWT, whose `exp` claim is its expiry, or an explicit
27
+ * credential and expiry. The supplied signal is owned by Credentials.
28
+ */
29
+ export type CredentialsMint = (signal: AbortSignal) => string | SessionCredential | PromiseLike<string | SessionCredential>;
30
+ export interface CredentialsOptions {
31
+ /** Delegation TTL every served credential must still cover; also the SessionAuth TTL. */
32
+ readonly ttlSeconds?: number;
33
+ /** Renew the credential. Without it, the initial credential is served until it stops covering. */
34
+ readonly mint?: CredentialsMint;
35
+ /** Caller-held credential admitted as the initial entry; it need only be unexpired. */
36
+ readonly initial?: string | SessionCredential;
37
+ readonly onChange?: (state: CredentialsState) => void;
38
+ }
39
+ /**
40
+ * Caller-owned source credential with a derived refresh threshold and shared minting.
41
+ *
42
+ * Credentials is a SessionAuth, so a ClientSession consumes it directly. Anticipation is opt-in:
43
+ * an ephemeral process or a request-scoped worker never holds a pending timer it did not ask for.
44
+ */
45
+ export interface Credentials extends SessionAuth {
46
+ state(): CredentialsState;
47
+ /** Serve a credential that still covers the delegation TTL; concurrent callers share one mint. */
48
+ acquire(signal?: AbortSignal): Promise<SessionCredential>;
49
+ /** Mint regardless of the current credential, joining a mint already in flight. */
50
+ refresh(signal?: AbortSignal): Promise<SessionCredential>;
51
+ /** Begin anticipating expiry: threshold timer, bounded backoff, and an expiry watchdog. */
52
+ start(): void;
53
+ /** Stop anticipating; a mint already in flight still settles. */
54
+ stop(): void;
55
+ }
56
+ /**
57
+ * Remaining lifetime a credential must exceed to carry a delegation of `ttlSeconds`: the TTL itself
58
+ * plus the settlement skew, so it cannot expire between admission and delivery.
59
+ */
60
+ export declare function delegationCoverageMs(ttlSeconds: number): number;
61
+ /**
62
+ * Hold one source credential for a Session: a fixed credential, a mint that renews it on demand,
63
+ * or options that also seed it, observe it, or change the delegation TTL it must cover.
64
+ */
65
+ export declare function credentials(source: string | CredentialsMint | CredentialsOptions): Credentials;
@@ -0,0 +1,296 @@
1
+ import { inspect } from '@astrale-os/kernel-core/auth/credential';
2
+ import { ClientError } from '../../errors/index.js';
3
+ import { BACKOFF_MS, DEFAULT_TTL_SECONDS, MINT_TIMEOUT_MS, RETRY_INTERVAL_MS, SETTLEMENT_SKEW_MS, } from './limits.js';
4
+ /**
5
+ * Remaining lifetime a credential must exceed to carry a delegation of `ttlSeconds`: the TTL itself
6
+ * plus the settlement skew, so it cannot expire between admission and delivery.
7
+ */
8
+ export function delegationCoverageMs(ttlSeconds) {
9
+ return ttlSeconds * 1_000 + SETTLEMENT_SKEW_MS;
10
+ }
11
+ /**
12
+ * Hold one source credential for a Session: a fixed credential, a mint that renews it on demand,
13
+ * or options that also seed it, observe it, or change the delegation TTL it must cover.
14
+ */
15
+ export function credentials(source) {
16
+ const options = admitSource(source);
17
+ if (options.mint !== undefined && typeof options.mint !== 'function') {
18
+ throw new TypeError('Session credential mint capability is invalid.');
19
+ }
20
+ if (options.mint === undefined && options.initial === undefined) {
21
+ throw new TypeError('Session credentials need a mint or an initial credential.');
22
+ }
23
+ const ttlSeconds = options.ttlSeconds ?? DEFAULT_TTL_SECONDS;
24
+ if (!Number.isSafeInteger(ttlSeconds) || ttlSeconds < 1) {
25
+ throw new TypeError('Session credential ttlSeconds must be a positive safe integer.');
26
+ }
27
+ if (options.onChange !== undefined && typeof options.onChange !== 'function') {
28
+ throw new TypeError('Session credential change observer is invalid.');
29
+ }
30
+ const mint = options.mint?.bind(options);
31
+ const notify = options.onChange?.bind(options);
32
+ // The threshold is the coverage the caller already declared, never a separate guessed constant.
33
+ const marginMs = delegationCoverageMs(ttlSeconds);
34
+ let current = options.initial === undefined ? undefined : admitInitial(options.initial);
35
+ let state = Object.freeze(current === undefined
36
+ ? { status: 'empty' }
37
+ : { status: 'valid', credential: current });
38
+ let inflight;
39
+ let controller;
40
+ let waiting = 0;
41
+ let anticipating = false;
42
+ let refreshTimer;
43
+ let expiryTimer;
44
+ let attempt = 0;
45
+ return Object.freeze({
46
+ ttlSeconds,
47
+ state: () => state,
48
+ acquire,
49
+ refresh,
50
+ start,
51
+ stop,
52
+ resolve,
53
+ });
54
+ async function resolve(_call, signal) {
55
+ return { credential: (await acquire(signal)).credential };
56
+ }
57
+ function acquire(signal) {
58
+ if (current !== undefined && covers(current))
59
+ return Promise.resolve(current);
60
+ return share(signal);
61
+ }
62
+ function refresh(signal) {
63
+ return share(signal);
64
+ }
65
+ function start() {
66
+ anticipating = true;
67
+ attempt = 0;
68
+ schedule();
69
+ }
70
+ function stop() {
71
+ anticipating = false;
72
+ clearTimers();
73
+ }
74
+ /** Join the mint in flight, or begin one, while following only this caller's cancellation. */
75
+ function share(signal) {
76
+ if (signal?.aborted === true)
77
+ return Promise.reject(signal.reason);
78
+ const pending = inflight ?? begin();
79
+ if (signal === undefined)
80
+ return pending;
81
+ waiting += 1;
82
+ let settled = false;
83
+ return new Promise((complete, fail) => {
84
+ const leave = () => {
85
+ if (settled)
86
+ return;
87
+ settled = true;
88
+ waiting -= 1;
89
+ signal.removeEventListener('abort', cancel);
90
+ // Nobody is waiting and nobody is anticipating: the mint has no beneficiary left.
91
+ if (waiting === 0 && !anticipating)
92
+ controller?.abort(signal.reason);
93
+ };
94
+ const cancel = () => {
95
+ const reason = signal.reason;
96
+ leave();
97
+ fail(reason);
98
+ };
99
+ signal.addEventListener('abort', cancel, { once: true });
100
+ pending.then((credential) => {
101
+ if (settled)
102
+ return;
103
+ settled = true;
104
+ waiting -= 1;
105
+ signal.removeEventListener('abort', cancel);
106
+ complete(credential);
107
+ }, (error) => {
108
+ if (settled)
109
+ return;
110
+ settled = true;
111
+ waiting -= 1;
112
+ signal.removeEventListener('abort', cancel);
113
+ fail(error);
114
+ });
115
+ });
116
+ }
117
+ function begin() {
118
+ if (mint === undefined) {
119
+ const error = new ClientError('Session credential needs renewal, but no mint was supplied.');
120
+ settleFailure(error);
121
+ return Promise.reject(error);
122
+ }
123
+ const renew = mint;
124
+ publish({ status: 'refreshing', ...(current === undefined ? {} : { credential: current }) });
125
+ const owned = new AbortController();
126
+ controller = owned;
127
+ const signal = AbortSignal.any([owned.signal, AbortSignal.timeout(MINT_TIMEOUT_MS)]);
128
+ const pending = (async () => {
129
+ try {
130
+ const minted = admitMinted(await renew(signal));
131
+ current = minted;
132
+ attempt = 0;
133
+ publish({ status: 'valid', credential: minted });
134
+ if (anticipating)
135
+ schedule();
136
+ return minted;
137
+ }
138
+ catch (error) {
139
+ settleFailure(error);
140
+ throw error;
141
+ }
142
+ finally {
143
+ inflight = undefined;
144
+ controller = undefined;
145
+ }
146
+ })();
147
+ inflight = pending;
148
+ // A rejection reaches every waiter; keep an unattached one from surfacing as unhandled.
149
+ pending.catch(() => undefined);
150
+ return pending;
151
+ }
152
+ function settleFailure(error) {
153
+ if (current !== undefined && current.expiresAt > Date.now()) {
154
+ publish({ status: 'degraded', credential: current, error });
155
+ }
156
+ else {
157
+ current = undefined;
158
+ publish({ status: 'expired', error });
159
+ }
160
+ if (anticipating)
161
+ retry();
162
+ }
163
+ /** Arm the threshold refresh and the expiry watchdog for the credential now held. */
164
+ function schedule() {
165
+ clearTimers();
166
+ if (!anticipating)
167
+ return;
168
+ if (current === undefined) {
169
+ void share().catch(() => undefined);
170
+ return;
171
+ }
172
+ // The threshold itself, with no extra lead: chained providers sharing this rule must not
173
+ // cascade into a mint loop, and the settlement skew already covers the round trip.
174
+ armRefresh(clamp(current.expiresAt - marginMs - Date.now()));
175
+ armExpiry(current);
176
+ }
177
+ function retry() {
178
+ if (refreshTimer !== undefined)
179
+ return;
180
+ if (current !== undefined)
181
+ armExpiry(current);
182
+ // Without a mint nothing can replace the held credential; only its expiry remains to report.
183
+ if (mint === undefined)
184
+ return;
185
+ const backoff = BACKOFF_MS[attempt];
186
+ attempt = Math.min(attempt + 1, BACKOFF_MS.length);
187
+ armRefresh(backoff ?? RETRY_INTERVAL_MS);
188
+ }
189
+ function armRefresh(delay) {
190
+ refreshTimer = setTimeout(() => {
191
+ refreshTimer = undefined;
192
+ void share().catch(() => undefined);
193
+ }, delay);
194
+ }
195
+ function armExpiry(credential) {
196
+ if (expiryTimer !== undefined)
197
+ clearTimeout(expiryTimer);
198
+ expiryTimer = setTimeout(() => {
199
+ expiryTimer = undefined;
200
+ if (!anticipating || current !== credential)
201
+ return;
202
+ current = undefined;
203
+ publish({ status: 'expired', error: new ClientError('Session credential expired.') });
204
+ }, clamp(credential.expiresAt - Date.now()));
205
+ }
206
+ function clearTimers() {
207
+ if (refreshTimer !== undefined)
208
+ clearTimeout(refreshTimer);
209
+ if (expiryTimer !== undefined)
210
+ clearTimeout(expiryTimer);
211
+ refreshTimer = undefined;
212
+ expiryTimer = undefined;
213
+ }
214
+ function covers(credential) {
215
+ return credential.expiresAt - Date.now() > marginMs;
216
+ }
217
+ function publish(next) {
218
+ state = Object.freeze(next);
219
+ notify?.(state);
220
+ }
221
+ function admitMinted(input) {
222
+ if (typeof input === 'string') {
223
+ const credential = fromCompactJwt(input);
224
+ if (credential === undefined) {
225
+ throw new ClientError('Minted session credential carries no expiry; return { credential, expiresAt }.');
226
+ }
227
+ return admitCovering(credential);
228
+ }
229
+ const credential = admitShape(input);
230
+ if (credential === undefined)
231
+ throw new ClientError('Minted session credential is invalid.');
232
+ return admitCovering(credential);
233
+ }
234
+ function admitCovering(credential) {
235
+ if (!covers(credential)) {
236
+ throw new ClientError('Minted session credential cannot cover the delegation TTL.');
237
+ }
238
+ return credential;
239
+ }
240
+ }
241
+ /** A bare credential is fixed, a function mints; anything else must already be options. */
242
+ function admitSource(source) {
243
+ if (source === undefined || source === null || source === '') {
244
+ throw new TypeError('Session credential is missing.');
245
+ }
246
+ if (typeof source === 'string')
247
+ return { initial: source };
248
+ if (typeof source === 'function')
249
+ return { mint: source };
250
+ if (typeof source !== 'object')
251
+ throw new TypeError('Session credentials source is invalid.');
252
+ return source;
253
+ }
254
+ function admitInitial(input) {
255
+ const credential = typeof input === 'string' ? fromCompactJwt(input) : admitShape(input);
256
+ if (credential === undefined) {
257
+ throw new TypeError(typeof input === 'string'
258
+ ? 'Session credential carries no expiry; supply { credential, expiresAt }.'
259
+ : 'Initial session credential is invalid.');
260
+ }
261
+ if (credential.expiresAt <= Date.now()) {
262
+ throw new TypeError('Initial session credential has expired.');
263
+ }
264
+ return credential;
265
+ }
266
+ /** Read the expiry a compact JWT declares; an opaque or expiry-less credential yields none. */
267
+ function fromCompactJwt(input) {
268
+ if (input.length === 0)
269
+ return undefined;
270
+ let exp;
271
+ try {
272
+ exp = inspect(input).claims.exp;
273
+ }
274
+ catch {
275
+ return undefined;
276
+ }
277
+ if (typeof exp !== 'number' || !Number.isSafeInteger(exp) || exp < 1)
278
+ return undefined;
279
+ if (!Number.isSafeInteger(exp * 1_000))
280
+ return undefined;
281
+ return Object.freeze({ credential: input, expiresAt: exp * 1_000 });
282
+ }
283
+ function admitShape(input) {
284
+ if (input === null ||
285
+ typeof input !== 'object' ||
286
+ typeof input.credential !== 'string' ||
287
+ input.credential.length === 0 ||
288
+ !Number.isSafeInteger(input.expiresAt)) {
289
+ return undefined;
290
+ }
291
+ return Object.freeze({ credential: input.credential, expiresAt: input.expiresAt });
292
+ }
293
+ /** Keep every scheduled delay inside the platform timer range. */
294
+ function clamp(delay) {
295
+ return Math.min(Math.max(delay, 0), 2_147_483_647);
296
+ }
@@ -0,0 +1 @@
1
+ export { credentials, delegationCoverageMs, type Credentials, type CredentialsMint, type CredentialsOptions, type CredentialsState, type SessionCredential, } from './credentials.js';
@@ -0,0 +1 @@
1
+ export { credentials, delegationCoverageMs, } from './credentials.js';
@@ -0,0 +1,14 @@
1
+ /** Delegation TTL a Credentials serves when its caller declares none. */
2
+ export declare const DEFAULT_TTL_SECONDS = 60;
3
+ /**
4
+ * Settlement allowance added to the declared delegation TTL to form the refresh threshold. It
5
+ * matches the destination-credential skew routing already applies to a warm entry, so a credential
6
+ * served here cannot expire between admission and delivery.
7
+ */
8
+ export declare const SETTLEMENT_SKEW_MS = 5000;
9
+ /** Total budget for one mint, matching the default Session operation budget. */
10
+ export declare const MINT_TIMEOUT_MS = 30000;
11
+ /** Bounded backoff between anticipation attempts after a failed mint. */
12
+ export declare const BACKOFF_MS: readonly [1000, 2000, 4000];
13
+ /** Steady retry interval once the bounded backoff is exhausted. */
14
+ export declare const RETRY_INTERVAL_MS = 4000;
@@ -0,0 +1,14 @@
1
+ /** Delegation TTL a Credentials serves when its caller declares none. */
2
+ export const DEFAULT_TTL_SECONDS = 60;
3
+ /**
4
+ * Settlement allowance added to the declared delegation TTL to form the refresh threshold. It
5
+ * matches the destination-credential skew routing already applies to a warm entry, so a credential
6
+ * served here cannot expire between admission and delivery.
7
+ */
8
+ export const SETTLEMENT_SKEW_MS = 5_000;
9
+ /** Total budget for one mint, matching the default Session operation budget. */
10
+ export const MINT_TIMEOUT_MS = 30_000;
11
+ /** Bounded backoff between anticipation attempts after a failed mint. */
12
+ export const BACKOFF_MS = [1_000, 2_000, 4_000];
13
+ /** Steady retry interval once the bounded backoff is exhausted. */
14
+ export const RETRY_INTERVAL_MS = 4_000;
@@ -1,18 +1,22 @@
1
1
  import type { bundle } from '@astrale-os/kernel-dsl/v1';
2
- import type { publication } from '@astrale-os/kernel-protocol';
2
+ import type { DomainRelease } from '@astrale-os/kernel-protocol/release';
3
3
  import type { Fetch } from '../../transport/http/index.js';
4
4
  import type { SessionOperation, SessionPolicy } from '../context/index.js';
5
- export interface BundleDiscoveryOptions {
5
+ import { ClientError } from '../../errors/index.js';
6
+ interface BundleDiscoveryOptions {
6
7
  readonly fetch: Fetch;
7
8
  readonly policy: Readonly<SessionPolicy>;
8
9
  readonly maximumBytes: number;
9
10
  }
11
+ /** Internal evidence that a selected immutable artifact is no longer served. */
12
+ export declare class BundleUnavailableError extends ClientError {
13
+ }
10
14
  export declare class BundleDiscovery {
11
15
  private readonly options;
12
- private readonly bundles;
16
+ private retained?;
13
17
  constructor(options: BundleDiscoveryOptions);
14
- get(publication: publication.Publication, operation: SessionOperation): Promise<bundle.Bundle>;
18
+ get(release: DomainRelease, operation: SessionOperation): Promise<bundle.Bundle>;
15
19
  clear(): void;
16
20
  private fetch;
17
21
  }
18
- //# sourceMappingURL=bundle.d.ts.map
22
+ export {};