@sixb/core 0.0.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 (1582) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +470 -0
  3. package/dist/actions/builders/define-action.d.ts +7 -0
  4. package/dist/actions/builders/define-action.d.ts.map +1 -0
  5. package/dist/actions/builders/params.d.ts +23 -0
  6. package/dist/actions/builders/params.d.ts.map +1 -0
  7. package/dist/actions/builders.d.ts +3 -0
  8. package/dist/actions/builders.d.ts.map +1 -0
  9. package/dist/actions/commit-edits.d.ts +54 -0
  10. package/dist/actions/commit-edits.d.ts.map +1 -0
  11. package/dist/actions/errors.d.ts +9 -0
  12. package/dist/actions/errors.d.ts.map +1 -0
  13. package/dist/actions/index.d.ts +14 -0
  14. package/dist/actions/index.d.ts.map +1 -0
  15. package/dist/actions/index.js +73 -0
  16. package/dist/actions/index.js.map +9 -0
  17. package/dist/actions/read-facade.d.ts +56 -0
  18. package/dist/actions/read-facade.d.ts.map +1 -0
  19. package/dist/actions/registry.d.ts +17 -0
  20. package/dist/actions/registry.d.ts.map +1 -0
  21. package/dist/actions/request.d.ts +37 -0
  22. package/dist/actions/request.d.ts.map +1 -0
  23. package/dist/actions/run-id.d.ts +3 -0
  24. package/dist/actions/run-id.d.ts.map +1 -0
  25. package/dist/actions/runtime.d.ts +11 -0
  26. package/dist/actions/runtime.d.ts.map +1 -0
  27. package/dist/actions/types/context.d.ts +147 -0
  28. package/dist/actions/types/context.d.ts.map +1 -0
  29. package/dist/actions/types/definitions.d.ts +67 -0
  30. package/dist/actions/types/definitions.d.ts.map +1 -0
  31. package/dist/actions/types/handlers.d.ts +19 -0
  32. package/dist/actions/types/handlers.d.ts.map +1 -0
  33. package/dist/actions/types/params.d.ts +45 -0
  34. package/dist/actions/types/params.d.ts.map +1 -0
  35. package/dist/actions/types.d.ts +5 -0
  36. package/dist/actions/types.d.ts.map +1 -0
  37. package/dist/actions/validation.d.ts +33 -0
  38. package/dist/actions/validation.d.ts.map +1 -0
  39. package/dist/actions/validators.d.ts +8 -0
  40. package/dist/actions/validators.d.ts.map +1 -0
  41. package/dist/actions/worker.d.ts +3 -0
  42. package/dist/actions/worker.d.ts.map +1 -0
  43. package/dist/actions/worker.js +324 -0
  44. package/dist/actions/worker.js.map +11 -0
  45. package/dist/agents/adapters.d.ts +185 -0
  46. package/dist/agents/adapters.d.ts.map +1 -0
  47. package/dist/agents/api-gateway.d.ts +21 -0
  48. package/dist/agents/api-gateway.d.ts.map +1 -0
  49. package/dist/agents/builders.d.ts +10 -0
  50. package/dist/agents/builders.d.ts.map +1 -0
  51. package/dist/agents/context-model.d.ts +4 -0
  52. package/dist/agents/context-model.d.ts.map +1 -0
  53. package/dist/agents/context-resolution.d.ts +5 -0
  54. package/dist/agents/context-resolution.d.ts.map +1 -0
  55. package/dist/agents/context.d.ts +57 -0
  56. package/dist/agents/context.d.ts.map +1 -0
  57. package/dist/agents/context.js +23 -0
  58. package/dist/agents/context.js.map +9 -0
  59. package/dist/agents/dispatch.d.ts +36 -0
  60. package/dist/agents/dispatch.d.ts.map +1 -0
  61. package/dist/agents/errors.d.ts +27 -0
  62. package/dist/agents/errors.d.ts.map +1 -0
  63. package/dist/agents/ids.d.ts +11 -0
  64. package/dist/agents/ids.d.ts.map +1 -0
  65. package/dist/agents/index.d.ts +24 -0
  66. package/dist/agents/index.d.ts.map +1 -0
  67. package/dist/agents/index.js +121 -0
  68. package/dist/agents/index.js.map +9 -0
  69. package/dist/agents/message.d.ts +78 -0
  70. package/dist/agents/message.d.ts.map +1 -0
  71. package/dist/agents/prompt.d.ts +15 -0
  72. package/dist/agents/prompt.d.ts.map +1 -0
  73. package/dist/agents/request.d.ts +42 -0
  74. package/dist/agents/request.d.ts.map +1 -0
  75. package/dist/agents/runtime.d.ts +41 -0
  76. package/dist/agents/runtime.d.ts.map +1 -0
  77. package/dist/agents/streams.d.ts +72 -0
  78. package/dist/agents/streams.d.ts.map +1 -0
  79. package/dist/agents/streams.js +32 -0
  80. package/dist/agents/streams.js.map +9 -0
  81. package/dist/agents/types.d.ts +52 -0
  82. package/dist/agents/types.d.ts.map +1 -0
  83. package/dist/agents/validation.d.ts +10 -0
  84. package/dist/agents/validation.d.ts.map +1 -0
  85. package/dist/auth/access-tokens.d.ts +19 -0
  86. package/dist/auth/access-tokens.d.ts.map +1 -0
  87. package/dist/auth/audience.d.ts +8 -0
  88. package/dist/auth/audience.d.ts.map +1 -0
  89. package/dist/auth/cookies.d.ts +50 -0
  90. package/dist/auth/cookies.d.ts.map +1 -0
  91. package/dist/auth/csrf.d.ts +8 -0
  92. package/dist/auth/csrf.d.ts.map +1 -0
  93. package/dist/auth/errors.d.ts +7 -0
  94. package/dist/auth/errors.d.ts.map +1 -0
  95. package/dist/auth/index.d.ts +15 -0
  96. package/dist/auth/index.d.ts.map +1 -0
  97. package/dist/auth/index.js +101 -0
  98. package/dist/auth/index.js.map +9 -0
  99. package/dist/auth/runtime.d.ts +129 -0
  100. package/dist/auth/runtime.d.ts.map +1 -0
  101. package/dist/auth/session-cache.d.ts +44 -0
  102. package/dist/auth/session-cache.d.ts.map +1 -0
  103. package/dist/auth/sessions.d.ts +16 -0
  104. package/dist/auth/sessions.d.ts.map +1 -0
  105. package/dist/auth/strategy.d.ts +11 -0
  106. package/dist/auth/strategy.d.ts.map +1 -0
  107. package/dist/auth/strategy.js +14 -0
  108. package/dist/auth/strategy.js.map +9 -0
  109. package/dist/auth/types.d.ts +460 -0
  110. package/dist/auth/types.d.ts.map +1 -0
  111. package/dist/auth/validation.d.ts +26 -0
  112. package/dist/auth/validation.d.ts.map +1 -0
  113. package/dist/authorization/application-access.d.ts +18 -0
  114. package/dist/authorization/application-access.d.ts.map +1 -0
  115. package/dist/authorization/decision.d.ts +104 -0
  116. package/dist/authorization/decision.d.ts.map +1 -0
  117. package/dist/authorization/errors.d.ts +10 -0
  118. package/dist/authorization/errors.d.ts.map +1 -0
  119. package/dist/authorization/event-visibility.d.ts +16 -0
  120. package/dist/authorization/event-visibility.d.ts.map +1 -0
  121. package/dist/authorization/grant-kinds.d.ts +48 -0
  122. package/dist/authorization/grant-kinds.d.ts.map +1 -0
  123. package/dist/authorization/index.d.ts +11 -0
  124. package/dist/authorization/index.d.ts.map +1 -0
  125. package/dist/authorization/index.js +48 -0
  126. package/dist/authorization/index.js.map +9 -0
  127. package/dist/authorization/resolve.d.ts +28 -0
  128. package/dist/authorization/resolve.d.ts.map +1 -0
  129. package/dist/authorization/run-visibility.d.ts +15 -0
  130. package/dist/authorization/run-visibility.d.ts.map +1 -0
  131. package/dist/authorization/types.d.ts +46 -0
  132. package/dist/authorization/types.d.ts.map +1 -0
  133. package/dist/blob-storage/browser.d.ts +14 -0
  134. package/dist/blob-storage/browser.d.ts.map +1 -0
  135. package/dist/blob-storage/browser.js +22 -0
  136. package/dist/blob-storage/browser.js.map +9 -0
  137. package/dist/blob-storage/constants.d.ts +10 -0
  138. package/dist/blob-storage/constants.d.ts.map +1 -0
  139. package/dist/blob-storage/derive.d.ts +4 -0
  140. package/dist/blob-storage/derive.d.ts.map +1 -0
  141. package/dist/blob-storage/errors.d.ts +7 -0
  142. package/dist/blob-storage/errors.d.ts.map +1 -0
  143. package/dist/blob-storage/in-memory.d.ts +10 -0
  144. package/dist/blob-storage/in-memory.d.ts.map +1 -0
  145. package/dist/blob-storage/index.d.ts +8 -0
  146. package/dist/blob-storage/index.d.ts.map +1 -0
  147. package/dist/blob-storage/index.js +44 -0
  148. package/dist/blob-storage/index.js.map +9 -0
  149. package/dist/blob-storage/types.d.ts +126 -0
  150. package/dist/blob-storage/types.d.ts.map +1 -0
  151. package/dist/blob-storage/utils.d.ts +9 -0
  152. package/dist/blob-storage/utils.d.ts.map +1 -0
  153. package/dist/blob-storage/validation.d.ts +6 -0
  154. package/dist/blob-storage/validation.d.ts.map +1 -0
  155. package/dist/bootstrap/discovery.d.ts +34 -0
  156. package/dist/bootstrap/discovery.d.ts.map +1 -0
  157. package/dist/bootstrap/index.d.ts +4 -0
  158. package/dist/bootstrap/index.d.ts.map +1 -0
  159. package/dist/bootstrap/index.js +80 -0
  160. package/dist/bootstrap/index.js.map +9 -0
  161. package/dist/bootstrap/ontology-type-manifest.d.ts +22 -0
  162. package/dist/bootstrap/ontology-type-manifest.d.ts.map +1 -0
  163. package/dist/broker/errors.d.ts +12 -0
  164. package/dist/broker/errors.d.ts.map +1 -0
  165. package/dist/broker/in-memory.d.ts +53 -0
  166. package/dist/broker/in-memory.d.ts.map +1 -0
  167. package/dist/broker/index.d.ts +5 -0
  168. package/dist/broker/index.d.ts.map +1 -0
  169. package/dist/broker/index.js +15 -0
  170. package/dist/broker/index.js.map +9 -0
  171. package/dist/broker/types.d.ts +119 -0
  172. package/dist/broker/types.d.ts.map +1 -0
  173. package/dist/chunk-04b07a9q.js +89 -0
  174. package/dist/chunk-04b07a9q.js.map +10 -0
  175. package/dist/chunk-0fygrz37.js +354 -0
  176. package/dist/chunk-0fygrz37.js.map +17 -0
  177. package/dist/chunk-0psb6kdw.js +989 -0
  178. package/dist/chunk-0psb6kdw.js.map +15 -0
  179. package/dist/chunk-1evzqhks.js +76 -0
  180. package/dist/chunk-1evzqhks.js.map +10 -0
  181. package/dist/chunk-1vffvydj.js +109 -0
  182. package/dist/chunk-1vffvydj.js.map +10 -0
  183. package/dist/chunk-2ab72m2h.js +59 -0
  184. package/dist/chunk-2ab72m2h.js.map +10 -0
  185. package/dist/chunk-2gpr6jsz.js +1968 -0
  186. package/dist/chunk-2gpr6jsz.js.map +13 -0
  187. package/dist/chunk-2s6sydsh.js +368 -0
  188. package/dist/chunk-2s6sydsh.js.map +12 -0
  189. package/dist/chunk-45tw90k7.js +72 -0
  190. package/dist/chunk-45tw90k7.js.map +11 -0
  191. package/dist/chunk-4pycxcj3.js +35 -0
  192. package/dist/chunk-4pycxcj3.js.map +11 -0
  193. package/dist/chunk-50kv63vj.js +523 -0
  194. package/dist/chunk-50kv63vj.js.map +12 -0
  195. package/dist/chunk-51fjndv0.js +17 -0
  196. package/dist/chunk-51fjndv0.js.map +11 -0
  197. package/dist/chunk-590dejbp.js +49 -0
  198. package/dist/chunk-590dejbp.js.map +10 -0
  199. package/dist/chunk-5yny9z0e.js +60 -0
  200. package/dist/chunk-5yny9z0e.js.map +10 -0
  201. package/dist/chunk-6wetht33.js +89 -0
  202. package/dist/chunk-6wetht33.js.map +10 -0
  203. package/dist/chunk-74drx9gd.js +362 -0
  204. package/dist/chunk-74drx9gd.js.map +11 -0
  205. package/dist/chunk-867jxh7c.js +1156 -0
  206. package/dist/chunk-867jxh7c.js.map +19 -0
  207. package/dist/chunk-88ppkr54.js +257 -0
  208. package/dist/chunk-88ppkr54.js.map +12 -0
  209. package/dist/chunk-8r8cw2xw.js +373 -0
  210. package/dist/chunk-8r8cw2xw.js.map +11 -0
  211. package/dist/chunk-8ydjhh27.js +95 -0
  212. package/dist/chunk-8ydjhh27.js.map +11 -0
  213. package/dist/chunk-9dzba0f2.js +43 -0
  214. package/dist/chunk-9dzba0f2.js.map +10 -0
  215. package/dist/chunk-aebzcsxr.js +5272 -0
  216. package/dist/chunk-aebzcsxr.js.map +48 -0
  217. package/dist/chunk-b49dgvsj.js +49 -0
  218. package/dist/chunk-b49dgvsj.js.map +10 -0
  219. package/dist/chunk-btpe64e4.js +554 -0
  220. package/dist/chunk-btpe64e4.js.map +13 -0
  221. package/dist/chunk-c3zd880g.js +629 -0
  222. package/dist/chunk-c3zd880g.js.map +14 -0
  223. package/dist/chunk-dcgrzj1t.js +2954 -0
  224. package/dist/chunk-dcgrzj1t.js.map +36 -0
  225. package/dist/chunk-dhmj53mx.js +501 -0
  226. package/dist/chunk-dhmj53mx.js.map +16 -0
  227. package/dist/chunk-dktq02ne.js +16 -0
  228. package/dist/chunk-dktq02ne.js.map +10 -0
  229. package/dist/chunk-f2b5e2gf.js +141 -0
  230. package/dist/chunk-f2b5e2gf.js.map +11 -0
  231. package/dist/chunk-gqdd7508.js +273 -0
  232. package/dist/chunk-gqdd7508.js.map +11 -0
  233. package/dist/chunk-hsv43v58.js +1390 -0
  234. package/dist/chunk-hsv43v58.js.map +21 -0
  235. package/dist/chunk-jdwx7vzs.js +454 -0
  236. package/dist/chunk-jdwx7vzs.js.map +14 -0
  237. package/dist/chunk-k25jm1x5.js +102 -0
  238. package/dist/chunk-k25jm1x5.js.map +10 -0
  239. package/dist/chunk-k41ajtz7.js +352 -0
  240. package/dist/chunk-k41ajtz7.js.map +13 -0
  241. package/dist/chunk-k6j72mtt.js +9 -0
  242. package/dist/chunk-k6j72mtt.js.map +10 -0
  243. package/dist/chunk-mx84y05q.js +426 -0
  244. package/dist/chunk-mx84y05q.js.map +11 -0
  245. package/dist/chunk-nvamz5dv.js +819 -0
  246. package/dist/chunk-nvamz5dv.js.map +21 -0
  247. package/dist/chunk-p6r5g77m.js +113 -0
  248. package/dist/chunk-p6r5g77m.js.map +10 -0
  249. package/dist/chunk-pv1yad91.js +1165 -0
  250. package/dist/chunk-pv1yad91.js.map +27 -0
  251. package/dist/chunk-q4qzq0ea.js +832 -0
  252. package/dist/chunk-q4qzq0ea.js.map +14 -0
  253. package/dist/chunk-r65yscvk.js +187 -0
  254. package/dist/chunk-r65yscvk.js.map +11 -0
  255. package/dist/chunk-ry24jbr1.js +50 -0
  256. package/dist/chunk-ry24jbr1.js.map +10 -0
  257. package/dist/chunk-t358gywy.js +991 -0
  258. package/dist/chunk-t358gywy.js.map +34 -0
  259. package/dist/chunk-t72dvahb.js +167 -0
  260. package/dist/chunk-t72dvahb.js.map +12 -0
  261. package/dist/chunk-tsk2bxs3.js +1254 -0
  262. package/dist/chunk-tsk2bxs3.js.map +17 -0
  263. package/dist/chunk-v5c085yp.js +49 -0
  264. package/dist/chunk-v5c085yp.js.map +10 -0
  265. package/dist/chunk-vj723r3p.js +146 -0
  266. package/dist/chunk-vj723r3p.js.map +12 -0
  267. package/dist/chunk-wj01s5hr.js +363 -0
  268. package/dist/chunk-wj01s5hr.js.map +11 -0
  269. package/dist/chunk-wxhdnwh4.js +37 -0
  270. package/dist/chunk-wxhdnwh4.js.map +10 -0
  271. package/dist/chunk-xqbtf4wn.js +170 -0
  272. package/dist/chunk-xqbtf4wn.js.map +10 -0
  273. package/dist/chunk-xwnf87e1.js +324 -0
  274. package/dist/chunk-xwnf87e1.js.map +13 -0
  275. package/dist/chunk-xz5g49bp.js +239 -0
  276. package/dist/chunk-xz5g49bp.js.map +11 -0
  277. package/dist/chunk-y64skrwp.js +19 -0
  278. package/dist/chunk-y64skrwp.js.map +9 -0
  279. package/dist/chunk-ya6brh8a.js +136 -0
  280. package/dist/chunk-ya6brh8a.js.map +11 -0
  281. package/dist/chunk-yt8wphsx.js +12 -0
  282. package/dist/chunk-yt8wphsx.js.map +10 -0
  283. package/dist/chunk-yvef9xwc.js +3842 -0
  284. package/dist/chunk-yvef9xwc.js.map +44 -0
  285. package/dist/chunk-yxss87qa.js +821 -0
  286. package/dist/chunk-yxss87qa.js.map +14 -0
  287. package/dist/connectors/builders.d.ts +10 -0
  288. package/dist/connectors/builders.d.ts.map +1 -0
  289. package/dist/connectors/errors.d.ts +14 -0
  290. package/dist/connectors/errors.d.ts.map +1 -0
  291. package/dist/connectors/index.d.ts +5 -0
  292. package/dist/connectors/index.d.ts.map +1 -0
  293. package/dist/connectors/runtime.d.ts +13 -0
  294. package/dist/connectors/runtime.d.ts.map +1 -0
  295. package/dist/connectors/types.d.ts +39 -0
  296. package/dist/connectors/types.d.ts.map +1 -0
  297. package/dist/datasets/builders.d.ts +54 -0
  298. package/dist/datasets/builders.d.ts.map +1 -0
  299. package/dist/datasets/errors.d.ts +4 -0
  300. package/dist/datasets/errors.d.ts.map +1 -0
  301. package/dist/datasets/index.d.ts +5 -0
  302. package/dist/datasets/index.d.ts.map +1 -0
  303. package/dist/datasets/types.d.ts +23 -0
  304. package/dist/datasets/types.d.ts.map +1 -0
  305. package/dist/datasets/validation.d.ts +8 -0
  306. package/dist/datasets/validation.d.ts.map +1 -0
  307. package/dist/edits/errors.d.ts +4 -0
  308. package/dist/edits/errors.d.ts.map +1 -0
  309. package/dist/edits/index.d.ts +4 -0
  310. package/dist/edits/index.d.ts.map +1 -0
  311. package/dist/edits/index.js +14 -0
  312. package/dist/edits/index.js.map +9 -0
  313. package/dist/edits/normalize.d.ts +14 -0
  314. package/dist/edits/normalize.d.ts.map +1 -0
  315. package/dist/edits/properties.d.ts +25 -0
  316. package/dist/edits/properties.d.ts.map +1 -0
  317. package/dist/edits/recorder.d.ts +4 -0
  318. package/dist/edits/recorder.d.ts.map +1 -0
  319. package/dist/edits/types.d.ts +159 -0
  320. package/dist/edits/types.d.ts.map +1 -0
  321. package/dist/error-reporting/capability.d.ts +57 -0
  322. package/dist/error-reporting/capability.d.ts.map +1 -0
  323. package/dist/error-reporting/internal.d.ts +4 -0
  324. package/dist/error-reporting/internal.d.ts.map +1 -0
  325. package/dist/error-reporting/internal.js +24 -0
  326. package/dist/error-reporting/internal.js.map +9 -0
  327. package/dist/error-reporting/normalize.d.ts +3 -0
  328. package/dist/error-reporting/normalize.d.ts.map +1 -0
  329. package/dist/error-reporting/reporter.d.ts +10 -0
  330. package/dist/error-reporting/reporter.d.ts.map +1 -0
  331. package/dist/error-reporting/types.d.ts +112 -0
  332. package/dist/error-reporting/types.d.ts.map +1 -0
  333. package/dist/events/definitions.d.ts +76 -0
  334. package/dist/events/definitions.d.ts.map +1 -0
  335. package/dist/events/envelope.d.ts +56 -0
  336. package/dist/events/envelope.d.ts.map +1 -0
  337. package/dist/events/errors.d.ts +8 -0
  338. package/dist/events/errors.d.ts.map +1 -0
  339. package/dist/events/index.d.ts +11 -0
  340. package/dist/events/index.d.ts.map +1 -0
  341. package/dist/events/index.js +68 -0
  342. package/dist/events/index.js.map +9 -0
  343. package/dist/events/outbox-dispatcher.d.ts +82 -0
  344. package/dist/events/outbox-dispatcher.d.ts.map +1 -0
  345. package/dist/events/property-changes.d.ts +16 -0
  346. package/dist/events/property-changes.d.ts.map +1 -0
  347. package/dist/events/runtime.d.ts +87 -0
  348. package/dist/events/runtime.d.ts.map +1 -0
  349. package/dist/events/scope.d.ts +25 -0
  350. package/dist/events/scope.d.ts.map +1 -0
  351. package/dist/events/scope.js +10 -0
  352. package/dist/events/scope.js.map +9 -0
  353. package/dist/events/selectors/builder.d.ts +64 -0
  354. package/dist/events/selectors/builder.d.ts.map +1 -0
  355. package/dist/events/selectors/index.d.ts +5 -0
  356. package/dist/events/selectors/index.d.ts.map +1 -0
  357. package/dist/events/selectors/index.js +15 -0
  358. package/dist/events/selectors/index.js.map +9 -0
  359. package/dist/events/selectors/predicate.d.ts +5 -0
  360. package/dist/events/selectors/predicate.d.ts.map +1 -0
  361. package/dist/events/selectors/types.d.ts +141 -0
  362. package/dist/events/selectors/types.d.ts.map +1 -0
  363. package/dist/events/toStoredEvent.d.ts +10 -0
  364. package/dist/events/toStoredEvent.d.ts.map +1 -0
  365. package/dist/events/types/actions.d.ts +39 -0
  366. package/dist/events/types/actions.d.ts.map +1 -0
  367. package/dist/events/types/datasets.d.ts +20 -0
  368. package/dist/events/types/datasets.d.ts.map +1 -0
  369. package/dist/events/types/index.d.ts +137 -0
  370. package/dist/events/types/index.d.ts.map +1 -0
  371. package/dist/events/types/links.d.ts +37 -0
  372. package/dist/events/types/links.d.ts.map +1 -0
  373. package/dist/events/types/objects.d.ts +33 -0
  374. package/dist/events/types/objects.d.ts.map +1 -0
  375. package/dist/events/types/pipelines.d.ts +59 -0
  376. package/dist/events/types/pipelines.d.ts.map +1 -0
  377. package/dist/events/types/rules.d.ts +28 -0
  378. package/dist/events/types/rules.d.ts.map +1 -0
  379. package/dist/events/types/schedules.d.ts +14 -0
  380. package/dist/events/types/schedules.d.ts.map +1 -0
  381. package/dist/events/types/syncs.d.ts +25 -0
  382. package/dist/events/types/syncs.d.ts.map +1 -0
  383. package/dist/events/types/telemetry.d.ts +17 -0
  384. package/dist/events/types/telemetry.d.ts.map +1 -0
  385. package/dist/events/types/workflows.d.ts +150 -0
  386. package/dist/events/types/workflows.d.ts.map +1 -0
  387. package/dist/http/api-routes.d.ts +24 -0
  388. package/dist/http/api-routes.d.ts.map +1 -0
  389. package/dist/http/index.d.ts +4 -0
  390. package/dist/http/index.d.ts.map +1 -0
  391. package/dist/http/index.js +16 -0
  392. package/dist/http/index.js.map +9 -0
  393. package/dist/http/route-pattern.d.ts +14 -0
  394. package/dist/http/route-pattern.d.ts.map +1 -0
  395. package/dist/index.d.ts +70 -0
  396. package/dist/index.d.ts.map +1 -0
  397. package/dist/index.js +430 -0
  398. package/dist/index.js.map +9 -0
  399. package/dist/json.d.ts +14 -0
  400. package/dist/json.d.ts.map +1 -0
  401. package/dist/lake-storage/definition-updates.d.ts +40 -0
  402. package/dist/lake-storage/definition-updates.d.ts.map +1 -0
  403. package/dist/lake-storage/errors.d.ts +7 -0
  404. package/dist/lake-storage/errors.d.ts.map +1 -0
  405. package/dist/lake-storage/in-memory.d.ts +25 -0
  406. package/dist/lake-storage/in-memory.d.ts.map +1 -0
  407. package/dist/lake-storage/index.d.ts +9 -0
  408. package/dist/lake-storage/index.d.ts.map +1 -0
  409. package/dist/lake-storage/index.js +24 -0
  410. package/dist/lake-storage/index.js.map +9 -0
  411. package/dist/lake-storage/sql-transforms.d.ts +45 -0
  412. package/dist/lake-storage/sql-transforms.d.ts.map +1 -0
  413. package/dist/lake-storage/types.d.ts +114 -0
  414. package/dist/lake-storage/types.d.ts.map +1 -0
  415. package/dist/logging/console-logger.d.ts +17 -0
  416. package/dist/logging/console-logger.d.ts.map +1 -0
  417. package/dist/logging/index.d.ts +5 -0
  418. package/dist/logging/index.d.ts.map +1 -0
  419. package/dist/logging/index.js +45 -0
  420. package/dist/logging/index.js.map +9 -0
  421. package/dist/logging/record.d.ts +10 -0
  422. package/dist/logging/record.d.ts.map +1 -0
  423. package/dist/logging/run-logger.d.ts +61 -0
  424. package/dist/logging/run-logger.d.ts.map +1 -0
  425. package/dist/logging/runtime.d.ts +87 -0
  426. package/dist/logging/runtime.d.ts.map +1 -0
  427. package/dist/logging/stream.d.ts +24 -0
  428. package/dist/logging/stream.d.ts.map +1 -0
  429. package/dist/logging/types.d.ts +82 -0
  430. package/dist/logging/types.d.ts.map +1 -0
  431. package/dist/logging/types.js +27 -0
  432. package/dist/logging/types.js.map +9 -0
  433. package/dist/maintenance/index.d.ts +3 -0
  434. package/dist/maintenance/index.d.ts.map +1 -0
  435. package/dist/maintenance/ontology-maintenance.d.ts +48 -0
  436. package/dist/maintenance/ontology-maintenance.d.ts.map +1 -0
  437. package/dist/maintenance/types.d.ts +53 -0
  438. package/dist/maintenance/types.d.ts.map +1 -0
  439. package/dist/materialization/dataset-watermark.d.ts +5 -0
  440. package/dist/materialization/dataset-watermark.d.ts.map +1 -0
  441. package/dist/materialization/errors.d.ts +37 -0
  442. package/dist/materialization/errors.d.ts.map +1 -0
  443. package/dist/materialization/events.d.ts +57 -0
  444. package/dist/materialization/events.d.ts.map +1 -0
  445. package/dist/materialization/identity.d.ts +8 -0
  446. package/dist/materialization/identity.d.ts.map +1 -0
  447. package/dist/materialization/index.d.ts +13 -0
  448. package/dist/materialization/index.d.ts.map +1 -0
  449. package/dist/materialization/index.js +56 -0
  450. package/dist/materialization/index.js.map +9 -0
  451. package/dist/materialization/model.d.ts +342 -0
  452. package/dist/materialization/model.d.ts.map +1 -0
  453. package/dist/materialization/refs.d.ts +24 -0
  454. package/dist/materialization/refs.d.ts.map +1 -0
  455. package/dist/materializer/context.d.ts +34 -0
  456. package/dist/materializer/context.d.ts.map +1 -0
  457. package/dist/materializer/edits/apply.d.ts +35 -0
  458. package/dist/materializer/edits/apply.d.ts.map +1 -0
  459. package/dist/materializer/edits/commit.d.ts +4 -0
  460. package/dist/materializer/edits/commit.d.ts.map +1 -0
  461. package/dist/materializer/edits/execution-units.d.ts +14 -0
  462. package/dist/materializer/edits/execution-units.d.ts.map +1 -0
  463. package/dist/materializer/edits/load-state.d.ts +6 -0
  464. package/dist/materializer/edits/load-state.d.ts.map +1 -0
  465. package/dist/materializer/edits/operations.d.ts +32 -0
  466. package/dist/materializer/edits/operations.d.ts.map +1 -0
  467. package/dist/materializer/edits/plan.d.ts +18 -0
  468. package/dist/materializer/edits/plan.d.ts.map +1 -0
  469. package/dist/materializer/edits/read-set.d.ts +8 -0
  470. package/dist/materializer/edits/read-set.d.ts.map +1 -0
  471. package/dist/materializer/edits/working-state.d.ts +30 -0
  472. package/dist/materializer/edits/working-state.d.ts.map +1 -0
  473. package/dist/materializer/effective/build-events.d.ts +26 -0
  474. package/dist/materializer/effective/build-events.d.ts.map +1 -0
  475. package/dist/materializer/effective/diff.d.ts +15 -0
  476. package/dist/materializer/effective/diff.d.ts.map +1 -0
  477. package/dist/materializer/effective/load-state.d.ts +7 -0
  478. package/dist/materializer/effective/load-state.d.ts.map +1 -0
  479. package/dist/materializer/effective/resolve.d.ts +26 -0
  480. package/dist/materializer/effective/resolve.d.ts.map +1 -0
  481. package/dist/materializer/effective/validate.d.ts +11 -0
  482. package/dist/materializer/effective/validate.d.ts.map +1 -0
  483. package/dist/materializer/execution/commit-lifecycle.d.ts +8 -0
  484. package/dist/materializer/execution/commit-lifecycle.d.ts.map +1 -0
  485. package/dist/materializer/execution/plan-stream.d.ts +8 -0
  486. package/dist/materializer/execution/plan-stream.d.ts.map +1 -0
  487. package/dist/materializer/execution/run-correlation.d.ts +19 -0
  488. package/dist/materializer/execution/run-correlation.d.ts.map +1 -0
  489. package/dist/materializer/execution/work-executor.d.ts +13 -0
  490. package/dist/materializer/execution/work-executor.d.ts.map +1 -0
  491. package/dist/materializer/execution/work-records.d.ts +15 -0
  492. package/dist/materializer/execution/work-records.d.ts.map +1 -0
  493. package/dist/materializer/index.d.ts +15 -0
  494. package/dist/materializer/index.d.ts.map +1 -0
  495. package/dist/materializer/index.js +134 -0
  496. package/dist/materializer/index.js.map +9 -0
  497. package/dist/materializer/materializer.d.ts +27 -0
  498. package/dist/materializer/materializer.d.ts.map +1 -0
  499. package/dist/materializer/projections/entry-validator.d.ts +8 -0
  500. package/dist/materializer/projections/entry-validator.d.ts.map +1 -0
  501. package/dist/materializer/projections/finish-run.d.ts +4 -0
  502. package/dist/materializer/projections/finish-run.d.ts.map +1 -0
  503. package/dist/materializer/projections/replace.d.ts +4 -0
  504. package/dist/materializer/projections/replace.d.ts.map +1 -0
  505. package/dist/materializer/projections/replacement-plan.d.ts +14 -0
  506. package/dist/materializer/projections/replacement-plan.d.ts.map +1 -0
  507. package/dist/materializer/projections/source-materialization.d.ts +27 -0
  508. package/dist/materializer/projections/source-materialization.d.ts.map +1 -0
  509. package/dist/materializer/shared/abort.d.ts +2 -0
  510. package/dist/materializer/shared/abort.d.ts.map +1 -0
  511. package/dist/materializer/shared/batching.d.ts +11 -0
  512. package/dist/materializer/shared/batching.d.ts.map +1 -0
  513. package/dist/materializer/shared/chunking.d.ts +6 -0
  514. package/dist/materializer/shared/chunking.d.ts.map +1 -0
  515. package/dist/materializer/shared/identity.d.ts +38 -0
  516. package/dist/materializer/shared/identity.d.ts.map +1 -0
  517. package/dist/materializer/shared/normalize.d.ts +10 -0
  518. package/dist/materializer/shared/normalize.d.ts.map +1 -0
  519. package/dist/materializer/shared/projection-run.d.ts +19 -0
  520. package/dist/materializer/shared/projection-run.d.ts.map +1 -0
  521. package/dist/materializer/telemetry/append.d.ts +4 -0
  522. package/dist/materializer/telemetry/append.d.ts.map +1 -0
  523. package/dist/materializer/telemetry/plan.d.ts +12 -0
  524. package/dist/materializer/telemetry/plan.d.ts.map +1 -0
  525. package/dist/objects/action/errors.d.ts +39 -0
  526. package/dist/objects/action/errors.d.ts.map +1 -0
  527. package/dist/objects/action/index.d.ts +4 -0
  528. package/dist/objects/action/index.d.ts.map +1 -0
  529. package/dist/objects/action/request.d.ts +23 -0
  530. package/dist/objects/action/request.d.ts.map +1 -0
  531. package/dist/objects/context/index.d.ts +3 -0
  532. package/dist/objects/context/index.d.ts.map +1 -0
  533. package/dist/objects/context/resolve.d.ts +27 -0
  534. package/dist/objects/context/resolve.d.ts.map +1 -0
  535. package/dist/objects/context/types.d.ts +28 -0
  536. package/dist/objects/context/types.d.ts.map +1 -0
  537. package/dist/objects/contexts.d.ts +45 -0
  538. package/dist/objects/contexts.d.ts.map +1 -0
  539. package/dist/objects/errors.d.ts +8 -0
  540. package/dist/objects/errors.d.ts.map +1 -0
  541. package/dist/objects/helpers.d.ts +7 -0
  542. package/dist/objects/helpers.d.ts.map +1 -0
  543. package/dist/objects/index.d.ts +18 -0
  544. package/dist/objects/index.d.ts.map +1 -0
  545. package/dist/objects/index.js +71 -0
  546. package/dist/objects/index.js.map +9 -0
  547. package/dist/objects/link/authorization.d.ts +25 -0
  548. package/dist/objects/link/authorization.d.ts.map +1 -0
  549. package/dist/objects/link/endpoints.d.ts +28 -0
  550. package/dist/objects/link/endpoints.d.ts.map +1 -0
  551. package/dist/objects/link/index.d.ts +4 -0
  552. package/dist/objects/link/index.d.ts.map +1 -0
  553. package/dist/objects/link/remove.d.ts +8 -0
  554. package/dist/objects/link/remove.d.ts.map +1 -0
  555. package/dist/objects/link/upsert-batch.d.ts +11 -0
  556. package/dist/objects/link/upsert-batch.d.ts.map +1 -0
  557. package/dist/objects/link/upsert.d.ts +12 -0
  558. package/dist/objects/link/upsert.d.ts.map +1 -0
  559. package/dist/objects/materializer-adapter.d.ts +114 -0
  560. package/dist/objects/materializer-adapter.d.ts.map +1 -0
  561. package/dist/objects/object/delete.d.ts +17 -0
  562. package/dist/objects/object/delete.d.ts.map +1 -0
  563. package/dist/objects/object/index.d.ts +4 -0
  564. package/dist/objects/object/index.d.ts.map +1 -0
  565. package/dist/objects/object/upsert-batch.d.ts +7 -0
  566. package/dist/objects/object/upsert-batch.d.ts.map +1 -0
  567. package/dist/objects/object/upsert.d.ts +7 -0
  568. package/dist/objects/object/upsert.d.ts.map +1 -0
  569. package/dist/objects/query/errors.d.ts +23 -0
  570. package/dist/objects/query/errors.d.ts.map +1 -0
  571. package/dist/objects/query/executor.d.ts +63 -0
  572. package/dist/objects/query/executor.d.ts.map +1 -0
  573. package/dist/objects/query/explain-format.d.ts +10 -0
  574. package/dist/objects/query/explain-format.d.ts.map +1 -0
  575. package/dist/objects/query/explain.d.ts +26 -0
  576. package/dist/objects/query/explain.d.ts.map +1 -0
  577. package/dist/objects/query/index.d.ts +14 -0
  578. package/dist/objects/query/index.d.ts.map +1 -0
  579. package/dist/objects/query/index.js +54 -0
  580. package/dist/objects/query/index.js.map +9 -0
  581. package/dist/objects/query/ir.d.ts +166 -0
  582. package/dist/objects/query/ir.d.ts.map +1 -0
  583. package/dist/objects/query/normalize.d.ts +12 -0
  584. package/dist/objects/query/normalize.d.ts.map +1 -0
  585. package/dist/objects/query/planner.d.ts +32 -0
  586. package/dist/objects/query/planner.d.ts.map +1 -0
  587. package/dist/objects/query/scalar-values.d.ts +6 -0
  588. package/dist/objects/query/scalar-values.d.ts.map +1 -0
  589. package/dist/objects/query/validate.d.ts +23 -0
  590. package/dist/objects/query/validate.d.ts.map +1 -0
  591. package/dist/objects/runtime-batch.d.ts +29 -0
  592. package/dist/objects/runtime-batch.d.ts.map +1 -0
  593. package/dist/objects/sdk/index.d.ts +3 -0
  594. package/dist/objects/sdk/index.d.ts.map +1 -0
  595. package/dist/objects/sdk/object-handle.d.ts +6 -0
  596. package/dist/objects/sdk/object-handle.d.ts.map +1 -0
  597. package/dist/objects/sdk/object-set.d.ts +14 -0
  598. package/dist/objects/sdk/object-set.d.ts.map +1 -0
  599. package/dist/objects/sdk/query-builder.d.ts +20 -0
  600. package/dist/objects/sdk/query-builder.d.ts.map +1 -0
  601. package/dist/objects/sdk/query-executor.d.ts +51 -0
  602. package/dist/objects/sdk/query-executor.d.ts.map +1 -0
  603. package/dist/objects/sdk/runtime-query-executor.d.ts +16 -0
  604. package/dist/objects/sdk/runtime-query-executor.d.ts.map +1 -0
  605. package/dist/objects/sdk/telemetry-channel.d.ts +6 -0
  606. package/dist/objects/sdk/telemetry-channel.d.ts.map +1 -0
  607. package/dist/objects/sdk/where.d.ts +15 -0
  608. package/dist/objects/sdk/where.d.ts.map +1 -0
  609. package/dist/objects/service/action-service.d.ts +12 -0
  610. package/dist/objects/service/action-service.d.ts.map +1 -0
  611. package/dist/objects/service/index.d.ts +7 -0
  612. package/dist/objects/service/index.d.ts.map +1 -0
  613. package/dist/objects/service/link-service.d.ts +26 -0
  614. package/dist/objects/service/link-service.d.ts.map +1 -0
  615. package/dist/objects/service/list-service.d.ts +24 -0
  616. package/dist/objects/service/list-service.d.ts.map +1 -0
  617. package/dist/objects/service/object-service.d.ts +12 -0
  618. package/dist/objects/service/object-service.d.ts.map +1 -0
  619. package/dist/objects/service/telemetry-service.d.ts +12 -0
  620. package/dist/objects/service/telemetry-service.d.ts.map +1 -0
  621. package/dist/objects/telemetry/append-batch.d.ts +10 -0
  622. package/dist/objects/telemetry/append-batch.d.ts.map +1 -0
  623. package/dist/objects/telemetry/history.d.ts +8 -0
  624. package/dist/objects/telemetry/history.d.ts.map +1 -0
  625. package/dist/objects/telemetry/index.d.ts +5 -0
  626. package/dist/objects/telemetry/index.d.ts.map +1 -0
  627. package/dist/objects/telemetry/write-batch.d.ts +8 -0
  628. package/dist/objects/telemetry/write-batch.d.ts.map +1 -0
  629. package/dist/ontology/builders.d.ts +323 -0
  630. package/dist/ontology/builders.d.ts.map +1 -0
  631. package/dist/ontology/decimal.d.ts +28 -0
  632. package/dist/ontology/decimal.d.ts.map +1 -0
  633. package/dist/ontology/errors.d.ts +20 -0
  634. package/dist/ontology/errors.d.ts.map +1 -0
  635. package/dist/ontology/index.d.ts +23 -0
  636. package/dist/ontology/index.d.ts.map +1 -0
  637. package/dist/ontology/index.js +120 -0
  638. package/dist/ontology/index.js.map +9 -0
  639. package/dist/ontology/inference/index.d.ts +112 -0
  640. package/dist/ontology/inference/index.d.ts.map +1 -0
  641. package/dist/ontology/internal.d.ts +4 -0
  642. package/dist/ontology/internal.d.ts.map +1 -0
  643. package/dist/ontology/internal.js +118 -0
  644. package/dist/ontology/internal.js.map +10 -0
  645. package/dist/ontology/json-schema.d.ts +9 -0
  646. package/dist/ontology/json-schema.d.ts.map +1 -0
  647. package/dist/ontology/refs.d.ts +16 -0
  648. package/dist/ontology/refs.d.ts.map +1 -0
  649. package/dist/ontology/registry.d.ts +82 -0
  650. package/dist/ontology/registry.d.ts.map +1 -0
  651. package/dist/ontology/tokens.d.ts +54 -0
  652. package/dist/ontology/tokens.d.ts.map +1 -0
  653. package/dist/ontology/types.d.ts +402 -0
  654. package/dist/ontology/types.d.ts.map +1 -0
  655. package/dist/ontology/units/index.d.ts +74 -0
  656. package/dist/ontology/units/index.d.ts.map +1 -0
  657. package/dist/ontology/units/quantitative-types.d.ts +1605 -0
  658. package/dist/ontology/units/quantitative-types.d.ts.map +1 -0
  659. package/dist/ontology/units/types.d.ts +26 -0
  660. package/dist/ontology/units/types.d.ts.map +1 -0
  661. package/dist/ontology/validation/index.d.ts +7 -0
  662. package/dist/ontology/validation/index.d.ts.map +1 -0
  663. package/dist/ontology/validation/links.d.ts +18 -0
  664. package/dist/ontology/validation/links.d.ts.map +1 -0
  665. package/dist/ontology/validation/normalize.d.ts +21 -0
  666. package/dist/ontology/validation/normalize.d.ts.map +1 -0
  667. package/dist/ontology/validation/properties.d.ts +19 -0
  668. package/dist/ontology/validation/properties.d.ts.map +1 -0
  669. package/dist/ontology/validation/query.d.ts +3 -0
  670. package/dist/ontology/validation/query.d.ts.map +1 -0
  671. package/dist/ontology/validation/schema.d.ts +7 -0
  672. package/dist/ontology/validation/schema.d.ts.map +1 -0
  673. package/dist/ontology/validation/telemetry.d.ts +7 -0
  674. package/dist/ontology/validation/telemetry.d.ts.map +1 -0
  675. package/dist/pipelines/builders.d.ts +14 -0
  676. package/dist/pipelines/builders.d.ts.map +1 -0
  677. package/dist/pipelines/errors.d.ts +4 -0
  678. package/dist/pipelines/errors.d.ts.map +1 -0
  679. package/dist/pipelines/index.d.ts +7 -0
  680. package/dist/pipelines/index.d.ts.map +1 -0
  681. package/dist/pipelines/request.d.ts +31 -0
  682. package/dist/pipelines/request.d.ts.map +1 -0
  683. package/dist/pipelines/types.d.ts +84 -0
  684. package/dist/pipelines/types.d.ts.map +1 -0
  685. package/dist/predicates/builders.d.ts +24 -0
  686. package/dist/predicates/builders.d.ts.map +1 -0
  687. package/dist/predicates/evaluate.d.ts +8 -0
  688. package/dist/predicates/evaluate.d.ts.map +1 -0
  689. package/dist/predicates/index.d.ts +5 -0
  690. package/dist/predicates/index.d.ts.map +1 -0
  691. package/dist/predicates/types.d.ts +69 -0
  692. package/dist/predicates/types.d.ts.map +1 -0
  693. package/dist/predicates/validation.d.ts +15 -0
  694. package/dist/predicates/validation.d.ts.map +1 -0
  695. package/dist/projections/builders.d.ts +212 -0
  696. package/dist/projections/builders.d.ts.map +1 -0
  697. package/dist/projections/errors.d.ts +4 -0
  698. package/dist/projections/errors.d.ts.map +1 -0
  699. package/dist/projections/index.d.ts +5 -0
  700. package/dist/projections/index.d.ts.map +1 -0
  701. package/dist/projections/internal.d.ts +24 -0
  702. package/dist/projections/internal.d.ts.map +1 -0
  703. package/dist/projections/internal.js +26 -0
  704. package/dist/projections/internal.js.map +9 -0
  705. package/dist/projections/ownership.d.ts +9 -0
  706. package/dist/projections/ownership.d.ts.map +1 -0
  707. package/dist/projections/registry.d.ts +30 -0
  708. package/dist/projections/registry.d.ts.map +1 -0
  709. package/dist/projections/revision.d.ts +7 -0
  710. package/dist/projections/revision.d.ts.map +1 -0
  711. package/dist/projections/types.d.ts +153 -0
  712. package/dist/projections/types.d.ts.map +1 -0
  713. package/dist/projections/validation.d.ts +97 -0
  714. package/dist/projections/validation.d.ts.map +1 -0
  715. package/dist/provider-scope.d.ts +12 -0
  716. package/dist/provider-scope.d.ts.map +1 -0
  717. package/dist/query.d.ts +17 -0
  718. package/dist/query.d.ts.map +1 -0
  719. package/dist/query.js +21 -0
  720. package/dist/query.js.map +9 -0
  721. package/dist/queues/errors.d.ts +7 -0
  722. package/dist/queues/errors.d.ts.map +1 -0
  723. package/dist/queues/in-memory.d.ts +73 -0
  724. package/dist/queues/in-memory.d.ts.map +1 -0
  725. package/dist/queues/index.d.ts +5 -0
  726. package/dist/queues/index.d.ts.map +1 -0
  727. package/dist/queues/index.js +12 -0
  728. package/dist/queues/index.js.map +9 -0
  729. package/dist/queues/types.d.ts +182 -0
  730. package/dist/queues/types.d.ts.map +1 -0
  731. package/dist/rules/builders.d.ts +10 -0
  732. package/dist/rules/builders.d.ts.map +1 -0
  733. package/dist/rules/dependencies.d.ts +9 -0
  734. package/dist/rules/dependencies.d.ts.map +1 -0
  735. package/dist/rules/errors.d.ts +11 -0
  736. package/dist/rules/errors.d.ts.map +1 -0
  737. package/dist/rules/index.d.ts +6 -0
  738. package/dist/rules/index.d.ts.map +1 -0
  739. package/dist/rules/internal.d.ts +9 -0
  740. package/dist/rules/internal.d.ts.map +1 -0
  741. package/dist/rules/internal.js +10 -0
  742. package/dist/rules/internal.js.map +9 -0
  743. package/dist/rules/types.d.ts +72 -0
  744. package/dist/rules/types.d.ts.map +1 -0
  745. package/dist/rules/validation.d.ts +23 -0
  746. package/dist/rules/validation.d.ts.map +1 -0
  747. package/dist/runtime/create.d.ts +68 -0
  748. package/dist/runtime/create.d.ts.map +1 -0
  749. package/dist/runtime/errors.d.ts +9 -0
  750. package/dist/runtime/errors.d.ts.map +1 -0
  751. package/dist/runtime/index.d.ts +26 -0
  752. package/dist/runtime/index.d.ts.map +1 -0
  753. package/dist/runtime/internal.d.ts +3 -0
  754. package/dist/runtime/internal.d.ts.map +1 -0
  755. package/dist/runtime/internal.js +16 -0
  756. package/dist/runtime/internal.js.map +9 -0
  757. package/dist/runtime/ontology-mutations.d.ts +16 -0
  758. package/dist/runtime/ontology-mutations.d.ts.map +1 -0
  759. package/dist/runtime/scoped.d.ts +158 -0
  760. package/dist/runtime/scoped.d.ts.map +1 -0
  761. package/dist/runtime/sixb.d.ts +226 -0
  762. package/dist/runtime/sixb.d.ts.map +1 -0
  763. package/dist/runtime/storage-readiness.d.ts +20 -0
  764. package/dist/runtime/storage-readiness.d.ts.map +1 -0
  765. package/dist/runtime/types.d.ts +840 -0
  766. package/dist/runtime/types.d.ts.map +1 -0
  767. package/dist/sandboxes/errors.d.ts +20 -0
  768. package/dist/sandboxes/errors.d.ts.map +1 -0
  769. package/dist/sandboxes/exec.d.ts +17 -0
  770. package/dist/sandboxes/exec.d.ts.map +1 -0
  771. package/dist/sandboxes/index.d.ts +5 -0
  772. package/dist/sandboxes/index.d.ts.map +1 -0
  773. package/dist/sandboxes/index.js +18 -0
  774. package/dist/sandboxes/index.js.map +9 -0
  775. package/dist/sandboxes/sandbox.d.ts +110 -0
  776. package/dist/sandboxes/sandbox.d.ts.map +1 -0
  777. package/dist/scheduler/errors.d.ts +7 -0
  778. package/dist/scheduler/errors.d.ts.map +1 -0
  779. package/dist/scheduler/index.d.ts +4 -0
  780. package/dist/scheduler/index.d.ts.map +1 -0
  781. package/dist/scheduler/index.js +18 -0
  782. package/dist/scheduler/index.js.map +9 -0
  783. package/dist/scheduler/runtime.d.ts +32 -0
  784. package/dist/scheduler/runtime.d.ts.map +1 -0
  785. package/dist/schedules/builders.d.ts +4 -0
  786. package/dist/schedules/builders.d.ts.map +1 -0
  787. package/dist/schedules/cron.d.ts +14 -0
  788. package/dist/schedules/cron.d.ts.map +1 -0
  789. package/dist/schedules/errors.d.ts +7 -0
  790. package/dist/schedules/errors.d.ts.map +1 -0
  791. package/dist/schedules/index.d.ts +12 -0
  792. package/dist/schedules/index.d.ts.map +1 -0
  793. package/dist/schedules/index.js +37 -0
  794. package/dist/schedules/index.js.map +9 -0
  795. package/dist/schedules/next-occurrence.d.ts +11 -0
  796. package/dist/schedules/next-occurrence.d.ts.map +1 -0
  797. package/dist/schedules/runtime.d.ts +17 -0
  798. package/dist/schedules/runtime.d.ts.map +1 -0
  799. package/dist/schedules/types.d.ts +99 -0
  800. package/dist/schedules/types.d.ts.map +1 -0
  801. package/dist/schedules/validation.d.ts +13 -0
  802. package/dist/schedules/validation.d.ts.map +1 -0
  803. package/dist/security/applications.d.ts +15 -0
  804. package/dist/security/applications.d.ts.map +1 -0
  805. package/dist/security/builders.d.ts +20 -0
  806. package/dist/security/builders.d.ts.map +1 -0
  807. package/dist/security/errors.d.ts +4 -0
  808. package/dist/security/errors.d.ts.map +1 -0
  809. package/dist/security/every.d.ts +68 -0
  810. package/dist/security/every.d.ts.map +1 -0
  811. package/dist/security/grants.d.ts +40 -0
  812. package/dist/security/grants.d.ts.map +1 -0
  813. package/dist/security/index.d.ts +12 -0
  814. package/dist/security/index.d.ts.map +1 -0
  815. package/dist/security/membership-policies.d.ts +17 -0
  816. package/dist/security/membership-policies.d.ts.map +1 -0
  817. package/dist/security/runtime.d.ts +16 -0
  818. package/dist/security/runtime.d.ts.map +1 -0
  819. package/dist/security/types.d.ts +133 -0
  820. package/dist/security/types.d.ts.map +1 -0
  821. package/dist/security/validation.d.ts +36 -0
  822. package/dist/security/validation.d.ts.map +1 -0
  823. package/dist/storage/action-runs/errors.d.ts +10 -0
  824. package/dist/storage/action-runs/errors.d.ts.map +1 -0
  825. package/dist/storage/action-runs/idempotency.d.ts +10 -0
  826. package/dist/storage/action-runs/idempotency.d.ts.map +1 -0
  827. package/dist/storage/action-runs/in-memory.d.ts +28 -0
  828. package/dist/storage/action-runs/in-memory.d.ts.map +1 -0
  829. package/dist/storage/action-runs/index.d.ts +6 -0
  830. package/dist/storage/action-runs/index.d.ts.map +1 -0
  831. package/dist/storage/action-runs/types.d.ts +138 -0
  832. package/dist/storage/action-runs/types.d.ts.map +1 -0
  833. package/dist/storage/agents/errors.d.ts +11 -0
  834. package/dist/storage/agents/errors.d.ts.map +1 -0
  835. package/dist/storage/agents/in-memory.d.ts +70 -0
  836. package/dist/storage/agents/in-memory.d.ts.map +1 -0
  837. package/dist/storage/agents/index.d.ts +7 -0
  838. package/dist/storage/agents/index.d.ts.map +1 -0
  839. package/dist/storage/agents/types.d.ts +295 -0
  840. package/dist/storage/agents/types.d.ts.map +1 -0
  841. package/dist/storage/auth/errors.d.ts +10 -0
  842. package/dist/storage/auth/errors.d.ts.map +1 -0
  843. package/dist/storage/auth/in-memory/access-tokens.d.ts +32 -0
  844. package/dist/storage/auth/in-memory/access-tokens.d.ts.map +1 -0
  845. package/dist/storage/auth/in-memory/auth-storage.d.ts +36 -0
  846. package/dist/storage/auth/in-memory/auth-storage.d.ts.map +1 -0
  847. package/dist/storage/auth/in-memory/group-memberships.d.ts +21 -0
  848. package/dist/storage/auth/in-memory/group-memberships.d.ts.map +1 -0
  849. package/dist/storage/auth/in-memory/identities.d.ts +17 -0
  850. package/dist/storage/auth/in-memory/identities.d.ts.map +1 -0
  851. package/dist/storage/auth/in-memory/index.d.ts +2 -0
  852. package/dist/storage/auth/in-memory/index.d.ts.map +1 -0
  853. package/dist/storage/auth/in-memory/invitations.d.ts +28 -0
  854. package/dist/storage/auth/in-memory/invitations.d.ts.map +1 -0
  855. package/dist/storage/auth/in-memory/magic-links.d.ts +28 -0
  856. package/dist/storage/auth/in-memory/magic-links.d.ts.map +1 -0
  857. package/dist/storage/auth/in-memory/oidc-attempts.d.ts +18 -0
  858. package/dist/storage/auth/in-memory/oidc-attempts.d.ts.map +1 -0
  859. package/dist/storage/auth/in-memory/service-account-group-memberships.d.ts +17 -0
  860. package/dist/storage/auth/in-memory/service-account-group-memberships.d.ts.map +1 -0
  861. package/dist/storage/auth/in-memory/service-accounts.d.ts +14 -0
  862. package/dist/storage/auth/in-memory/service-accounts.d.ts.map +1 -0
  863. package/dist/storage/auth/in-memory/sessions.d.ts +55 -0
  864. package/dist/storage/auth/in-memory/sessions.d.ts.map +1 -0
  865. package/dist/storage/auth/in-memory/shared.d.ts +71 -0
  866. package/dist/storage/auth/in-memory/shared.d.ts.map +1 -0
  867. package/dist/storage/auth/in-memory/users.d.ts +19 -0
  868. package/dist/storage/auth/in-memory/users.d.ts.map +1 -0
  869. package/dist/storage/auth/in-memory.d.ts +2 -0
  870. package/dist/storage/auth/in-memory.d.ts.map +1 -0
  871. package/dist/storage/auth/index.d.ts +5 -0
  872. package/dist/storage/auth/index.d.ts.map +1 -0
  873. package/dist/storage/auth/types.d.ts +584 -0
  874. package/dist/storage/auth/types.d.ts.map +1 -0
  875. package/dist/storage/errors.d.ts +27 -0
  876. package/dist/storage/errors.d.ts.map +1 -0
  877. package/dist/storage/file-upload-sessions/errors.d.ts +15 -0
  878. package/dist/storage/file-upload-sessions/errors.d.ts.map +1 -0
  879. package/dist/storage/file-upload-sessions/in-memory.d.ts +27 -0
  880. package/dist/storage/file-upload-sessions/in-memory.d.ts.map +1 -0
  881. package/dist/storage/file-upload-sessions/index.d.ts +6 -0
  882. package/dist/storage/file-upload-sessions/index.d.ts.map +1 -0
  883. package/dist/storage/file-upload-sessions/types.d.ts +53 -0
  884. package/dist/storage/file-upload-sessions/types.d.ts.map +1 -0
  885. package/dist/storage/file-upload-sessions/utils.d.ts +11 -0
  886. package/dist/storage/file-upload-sessions/utils.d.ts.map +1 -0
  887. package/dist/storage/in-memory/index.d.ts +105 -0
  888. package/dist/storage/in-memory/index.d.ts.map +1 -0
  889. package/dist/storage/in-memory/testing.d.ts +8 -0
  890. package/dist/storage/in-memory/testing.d.ts.map +1 -0
  891. package/dist/storage/index.d.ts +44 -0
  892. package/dist/storage/index.d.ts.map +1 -0
  893. package/dist/storage/index.js +144 -0
  894. package/dist/storage/index.js.map +9 -0
  895. package/dist/storage/migrations/check-schema.d.ts +19 -0
  896. package/dist/storage/migrations/check-schema.d.ts.map +1 -0
  897. package/dist/storage/migrations/index.d.ts +5 -0
  898. package/dist/storage/migrations/index.d.ts.map +1 -0
  899. package/dist/storage/migrations/migrate-storage.d.ts +6 -0
  900. package/dist/storage/migrations/migrate-storage.d.ts.map +1 -0
  901. package/dist/storage/migrations/migration-set.d.ts +27 -0
  902. package/dist/storage/migrations/migration-set.d.ts.map +1 -0
  903. package/dist/storage/migrations/types.d.ts +115 -0
  904. package/dist/storage/migrations/types.d.ts.map +1 -0
  905. package/dist/storage/objects/in-memory.d.ts +126 -0
  906. package/dist/storage/objects/in-memory.d.ts.map +1 -0
  907. package/dist/storage/objects/index.d.ts +2 -0
  908. package/dist/storage/objects/index.d.ts.map +1 -0
  909. package/dist/storage/objects/types.d.ts +222 -0
  910. package/dist/storage/objects/types.d.ts.map +1 -0
  911. package/dist/storage/ontology/commits.d.ts +117 -0
  912. package/dist/storage/ontology/commits.d.ts.map +1 -0
  913. package/dist/storage/ontology/in-memory/commits.d.ts +12 -0
  914. package/dist/storage/ontology/in-memory/commits.d.ts.map +1 -0
  915. package/dist/storage/ontology/in-memory/index.d.ts +36 -0
  916. package/dist/storage/ontology/in-memory/index.d.ts.map +1 -0
  917. package/dist/storage/ontology/in-memory/materializations-finalization.d.ts +5 -0
  918. package/dist/storage/ontology/in-memory/materializations-finalization.d.ts.map +1 -0
  919. package/dist/storage/ontology/in-memory/materializations-state.d.ts +20 -0
  920. package/dist/storage/ontology/in-memory/materializations-state.d.ts.map +1 -0
  921. package/dist/storage/ontology/in-memory/materializations-work.d.ts +6 -0
  922. package/dist/storage/ontology/in-memory/materializations-work.d.ts.map +1 -0
  923. package/dist/storage/ontology/in-memory/materializations.d.ts +101 -0
  924. package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -0
  925. package/dist/storage/ontology/in-memory/outbox.d.ts +19 -0
  926. package/dist/storage/ontology/in-memory/outbox.d.ts.map +1 -0
  927. package/dist/storage/ontology/in-memory/shared-state.d.ts +48 -0
  928. package/dist/storage/ontology/in-memory/shared-state.d.ts.map +1 -0
  929. package/dist/storage/ontology/in-memory/sources.d.ts +23 -0
  930. package/dist/storage/ontology/in-memory/sources.d.ts.map +1 -0
  931. package/dist/storage/ontology/in-memory/testing.d.ts +11 -0
  932. package/dist/storage/ontology/in-memory/testing.d.ts.map +1 -0
  933. package/dist/storage/ontology/index.d.ts +16 -0
  934. package/dist/storage/ontology/index.d.ts.map +1 -0
  935. package/dist/storage/ontology/materializations.d.ts +333 -0
  936. package/dist/storage/ontology/materializations.d.ts.map +1 -0
  937. package/dist/storage/ontology/outbox.d.ts +66 -0
  938. package/dist/storage/ontology/outbox.d.ts.map +1 -0
  939. package/dist/storage/ontology/provider-header-validation.d.ts +4 -0
  940. package/dist/storage/ontology/provider-header-validation.d.ts.map +1 -0
  941. package/dist/storage/ontology/provider-validation.d.ts +6 -0
  942. package/dist/storage/ontology/provider-validation.d.ts.map +1 -0
  943. package/dist/storage/ontology/provider-work.d.ts +12 -0
  944. package/dist/storage/ontology/provider-work.d.ts.map +1 -0
  945. package/dist/storage/ontology/provider.d.ts +191 -0
  946. package/dist/storage/ontology/provider.d.ts.map +1 -0
  947. package/dist/storage/ontology/provider.js +115 -0
  948. package/dist/storage/ontology/provider.js.map +9 -0
  949. package/dist/storage/ontology/sources.d.ts +151 -0
  950. package/dist/storage/ontology/sources.d.ts.map +1 -0
  951. package/dist/storage/operation-scope.d.ts +32 -0
  952. package/dist/storage/operation-scope.d.ts.map +1 -0
  953. package/dist/storage/operation-scope.js +22 -0
  954. package/dist/storage/operation-scope.js.map +9 -0
  955. package/dist/storage/pagination.d.ts +11 -0
  956. package/dist/storage/pagination.d.ts.map +1 -0
  957. package/dist/storage/pipeline-runs/errors.d.ts +7 -0
  958. package/dist/storage/pipeline-runs/errors.d.ts.map +1 -0
  959. package/dist/storage/pipeline-runs/in-memory.d.ts +26 -0
  960. package/dist/storage/pipeline-runs/in-memory.d.ts.map +1 -0
  961. package/dist/storage/pipeline-runs/index.d.ts +4 -0
  962. package/dist/storage/pipeline-runs/index.d.ts.map +1 -0
  963. package/dist/storage/pipeline-runs/types.d.ts +133 -0
  964. package/dist/storage/pipeline-runs/types.d.ts.map +1 -0
  965. package/dist/storage/projection-runs/errors.d.ts +9 -0
  966. package/dist/storage/projection-runs/errors.d.ts.map +1 -0
  967. package/dist/storage/projection-runs/in-memory.d.ts +42 -0
  968. package/dist/storage/projection-runs/in-memory.d.ts.map +1 -0
  969. package/dist/storage/projection-runs/index.d.ts +5 -0
  970. package/dist/storage/projection-runs/index.d.ts.map +1 -0
  971. package/dist/storage/projection-runs/lifecycle.d.ts +93 -0
  972. package/dist/storage/projection-runs/lifecycle.d.ts.map +1 -0
  973. package/dist/storage/projection-runs/lifecycle.js +64 -0
  974. package/dist/storage/projection-runs/lifecycle.js.map +9 -0
  975. package/dist/storage/projection-runs/types.d.ts +175 -0
  976. package/dist/storage/projection-runs/types.d.ts.map +1 -0
  977. package/dist/storage/rules/in-memory.d.ts +26 -0
  978. package/dist/storage/rules/in-memory.d.ts.map +1 -0
  979. package/dist/storage/rules/index.d.ts +3 -0
  980. package/dist/storage/rules/index.d.ts.map +1 -0
  981. package/dist/storage/rules/types.d.ts +60 -0
  982. package/dist/storage/rules/types.d.ts.map +1 -0
  983. package/dist/storage/run-listing.d.ts +36 -0
  984. package/dist/storage/run-listing.d.ts.map +1 -0
  985. package/dist/storage/sync-runs/errors.d.ts +8 -0
  986. package/dist/storage/sync-runs/errors.d.ts.map +1 -0
  987. package/dist/storage/sync-runs/in-memory.d.ts +16 -0
  988. package/dist/storage/sync-runs/in-memory.d.ts.map +1 -0
  989. package/dist/storage/sync-runs/index.d.ts +4 -0
  990. package/dist/storage/sync-runs/index.d.ts.map +1 -0
  991. package/dist/storage/sync-runs/types.d.ts +85 -0
  992. package/dist/storage/sync-runs/types.d.ts.map +1 -0
  993. package/dist/storage/timeseries/index.d.ts +2 -0
  994. package/dist/storage/timeseries/index.d.ts.map +1 -0
  995. package/dist/storage/timeseries/store.d.ts +46 -0
  996. package/dist/storage/timeseries/store.d.ts.map +1 -0
  997. package/dist/storage/timeseries/types.d.ts +50 -0
  998. package/dist/storage/timeseries/types.d.ts.map +1 -0
  999. package/dist/storage/transaction.d.ts +4 -0
  1000. package/dist/storage/transaction.d.ts.map +1 -0
  1001. package/dist/storage/types.d.ts +78 -0
  1002. package/dist/storage/types.d.ts.map +1 -0
  1003. package/dist/storage/webhook-deliveries/in-memory.d.ts +18 -0
  1004. package/dist/storage/webhook-deliveries/in-memory.d.ts.map +1 -0
  1005. package/dist/storage/webhook-deliveries/index.d.ts +3 -0
  1006. package/dist/storage/webhook-deliveries/index.d.ts.map +1 -0
  1007. package/dist/storage/webhook-deliveries/types.d.ts +43 -0
  1008. package/dist/storage/webhook-deliveries/types.d.ts.map +1 -0
  1009. package/dist/storage/webhook-runs/errors.d.ts +7 -0
  1010. package/dist/storage/webhook-runs/errors.d.ts.map +1 -0
  1011. package/dist/storage/webhook-runs/in-memory.d.ts +16 -0
  1012. package/dist/storage/webhook-runs/in-memory.d.ts.map +1 -0
  1013. package/dist/storage/webhook-runs/index.d.ts +4 -0
  1014. package/dist/storage/webhook-runs/index.d.ts.map +1 -0
  1015. package/dist/storage/webhook-runs/types.d.ts +66 -0
  1016. package/dist/storage/webhook-runs/types.d.ts.map +1 -0
  1017. package/dist/storage/workflow-interventions/errors.d.ts +7 -0
  1018. package/dist/storage/workflow-interventions/errors.d.ts.map +1 -0
  1019. package/dist/storage/workflow-interventions/in-memory.d.ts +18 -0
  1020. package/dist/storage/workflow-interventions/in-memory.d.ts.map +1 -0
  1021. package/dist/storage/workflow-interventions/index.d.ts +4 -0
  1022. package/dist/storage/workflow-interventions/index.d.ts.map +1 -0
  1023. package/dist/storage/workflow-interventions/types.d.ts +94 -0
  1024. package/dist/storage/workflow-interventions/types.d.ts.map +1 -0
  1025. package/dist/storage/workflow-runs/errors.d.ts +7 -0
  1026. package/dist/storage/workflow-runs/errors.d.ts.map +1 -0
  1027. package/dist/storage/workflow-runs/in-memory.d.ts +83 -0
  1028. package/dist/storage/workflow-runs/in-memory.d.ts.map +1 -0
  1029. package/dist/storage/workflow-runs/index.d.ts +4 -0
  1030. package/dist/storage/workflow-runs/index.d.ts.map +1 -0
  1031. package/dist/storage/workflow-runs/types.d.ts +305 -0
  1032. package/dist/storage/workflow-runs/types.d.ts.map +1 -0
  1033. package/dist/syncs/builders.d.ts +9 -0
  1034. package/dist/syncs/builders.d.ts.map +1 -0
  1035. package/dist/syncs/errors.d.ts +4 -0
  1036. package/dist/syncs/errors.d.ts.map +1 -0
  1037. package/dist/syncs/index.d.ts +7 -0
  1038. package/dist/syncs/index.d.ts.map +1 -0
  1039. package/dist/syncs/request.d.ts +41 -0
  1040. package/dist/syncs/request.d.ts.map +1 -0
  1041. package/dist/syncs/types.d.ts +76 -0
  1042. package/dist/syncs/types.d.ts.map +1 -0
  1043. package/dist/testing/agent-storage-contract.d.ts +16 -0
  1044. package/dist/testing/agent-storage-contract.d.ts.map +1 -0
  1045. package/dist/testing/auth-storage-contract.d.ts +16 -0
  1046. package/dist/testing/auth-storage-contract.d.ts.map +1 -0
  1047. package/dist/testing/blob-storage-contract.d.ts +10 -0
  1048. package/dist/testing/blob-storage-contract.d.ts.map +1 -0
  1049. package/dist/testing/broker-contract.d.ts +39 -0
  1050. package/dist/testing/broker-contract.d.ts.map +1 -0
  1051. package/dist/testing/effective-storage-contract.d.ts +7 -0
  1052. package/dist/testing/effective-storage-contract.d.ts.map +1 -0
  1053. package/dist/testing/index.d.ts +15 -0
  1054. package/dist/testing/index.d.ts.map +1 -0
  1055. package/dist/testing/index.js +7000 -0
  1056. package/dist/testing/index.js.map +24 -0
  1057. package/dist/testing/lake-storage-contract.d.ts +29 -0
  1058. package/dist/testing/lake-storage-contract.d.ts.map +1 -0
  1059. package/dist/testing/materialization-failure-contract.d.ts +26 -0
  1060. package/dist/testing/materialization-failure-contract.d.ts.map +1 -0
  1061. package/dist/testing/materializer-fixture.d.ts +35 -0
  1062. package/dist/testing/materializer-fixture.d.ts.map +1 -0
  1063. package/dist/testing/materializer-storage-contract.d.ts +7 -0
  1064. package/dist/testing/materializer-storage-contract.d.ts.map +1 -0
  1065. package/dist/testing/object-query-contract.d.ts +21 -0
  1066. package/dist/testing/object-query-contract.d.ts.map +1 -0
  1067. package/dist/testing/ontology-contract-fixture.d.ts +33 -0
  1068. package/dist/testing/ontology-contract-fixture.d.ts.map +1 -0
  1069. package/dist/testing/ontology-storage-contract.d.ts +21 -0
  1070. package/dist/testing/ontology-storage-contract.d.ts.map +1 -0
  1071. package/dist/testing/projection-run-storage-contract.d.ts +10 -0
  1072. package/dist/testing/projection-run-storage-contract.d.ts.map +1 -0
  1073. package/dist/testing/queues-contract.d.ts +31 -0
  1074. package/dist/testing/queues-contract.d.ts.map +1 -0
  1075. package/dist/testing/sandboxes-contract.d.ts +31 -0
  1076. package/dist/testing/sandboxes-contract.d.ts.map +1 -0
  1077. package/dist/tsconfig.json +5 -0
  1078. package/dist/webhooks/builders.d.ts +41 -0
  1079. package/dist/webhooks/builders.d.ts.map +1 -0
  1080. package/dist/webhooks/connector.d.ts +10 -0
  1081. package/dist/webhooks/connector.d.ts.map +1 -0
  1082. package/dist/webhooks/errors.d.ts +4 -0
  1083. package/dist/webhooks/errors.d.ts.map +1 -0
  1084. package/dist/webhooks/index.d.ts +9 -0
  1085. package/dist/webhooks/index.d.ts.map +1 -0
  1086. package/dist/webhooks/registry.d.ts +7 -0
  1087. package/dist/webhooks/registry.d.ts.map +1 -0
  1088. package/dist/webhooks/types.d.ts +79 -0
  1089. package/dist/webhooks/types.d.ts.map +1 -0
  1090. package/dist/webhooks/unverified.d.ts +57 -0
  1091. package/dist/webhooks/unverified.d.ts.map +1 -0
  1092. package/dist/workers/errors.d.ts +17 -0
  1093. package/dist/workers/errors.d.ts.map +1 -0
  1094. package/dist/workers/index.d.ts +7 -0
  1095. package/dist/workers/index.d.ts.map +1 -0
  1096. package/dist/workers/index.js +506 -0
  1097. package/dist/workers/index.js.map +13 -0
  1098. package/dist/workers/queue-delivery.d.ts +38 -0
  1099. package/dist/workers/queue-delivery.d.ts.map +1 -0
  1100. package/dist/workers/queue-worker.d.ts +30 -0
  1101. package/dist/workers/queue-worker.d.ts.map +1 -0
  1102. package/dist/workers/worker.d.ts +14 -0
  1103. package/dist/workers/worker.d.ts.map +1 -0
  1104. package/dist/workflows/builders.d.ts +27 -0
  1105. package/dist/workflows/builders.d.ts.map +1 -0
  1106. package/dist/workflows/errors.d.ts +11 -0
  1107. package/dist/workflows/errors.d.ts.map +1 -0
  1108. package/dist/workflows/index.d.ts +9 -0
  1109. package/dist/workflows/index.d.ts.map +1 -0
  1110. package/dist/workflows/index.js +108 -0
  1111. package/dist/workflows/index.js.map +9 -0
  1112. package/dist/workflows/request.d.ts +29 -0
  1113. package/dist/workflows/request.d.ts.map +1 -0
  1114. package/dist/workflows/runtime.d.ts +33 -0
  1115. package/dist/workflows/runtime.d.ts.map +1 -0
  1116. package/dist/workflows/snapshot.d.ts +55 -0
  1117. package/dist/workflows/snapshot.d.ts.map +1 -0
  1118. package/dist/workflows/types.d.ts +288 -0
  1119. package/dist/workflows/types.d.ts.map +1 -0
  1120. package/dist/workflows/validation.d.ts +66 -0
  1121. package/dist/workflows/validation.d.ts.map +1 -0
  1122. package/package.json +312 -0
  1123. package/src/actions/builders/define-action.ts +243 -0
  1124. package/src/actions/builders/params.ts +48 -0
  1125. package/src/actions/builders.ts +2 -0
  1126. package/src/actions/commit-edits.ts +110 -0
  1127. package/src/actions/errors.ts +15 -0
  1128. package/src/actions/index.ts +75 -0
  1129. package/src/actions/read-facade.ts +224 -0
  1130. package/src/actions/registry.ts +135 -0
  1131. package/src/actions/request.ts +407 -0
  1132. package/src/actions/run-id.ts +17 -0
  1133. package/src/actions/runtime.ts +31 -0
  1134. package/src/actions/types/context.ts +224 -0
  1135. package/src/actions/types/definitions.ts +181 -0
  1136. package/src/actions/types/handlers.ts +68 -0
  1137. package/src/actions/types/params.ts +82 -0
  1138. package/src/actions/types.ts +4 -0
  1139. package/src/actions/validation.ts +186 -0
  1140. package/src/actions/validators.ts +56 -0
  1141. package/src/actions/worker.ts +2 -0
  1142. package/src/agents/adapters.ts +647 -0
  1143. package/src/agents/api-gateway.ts +57 -0
  1144. package/src/agents/builders.ts +46 -0
  1145. package/src/agents/context-model.ts +41 -0
  1146. package/src/agents/context-resolution.ts +43 -0
  1147. package/src/agents/context.ts +185 -0
  1148. package/src/agents/dispatch.ts +107 -0
  1149. package/src/agents/errors.ts +40 -0
  1150. package/src/agents/ids.ts +24 -0
  1151. package/src/agents/index.ts +122 -0
  1152. package/src/agents/message.ts +91 -0
  1153. package/src/agents/prompt.ts +45 -0
  1154. package/src/agents/request.ts +198 -0
  1155. package/src/agents/runtime.ts +124 -0
  1156. package/src/agents/streams.ts +194 -0
  1157. package/src/agents/types.ts +70 -0
  1158. package/src/agents/validation.ts +151 -0
  1159. package/src/auth/access-tokens.ts +125 -0
  1160. package/src/auth/audience.ts +28 -0
  1161. package/src/auth/cookies.ts +263 -0
  1162. package/src/auth/csrf.ts +41 -0
  1163. package/src/auth/errors.ts +19 -0
  1164. package/src/auth/index.ts +149 -0
  1165. package/src/auth/runtime.ts +1642 -0
  1166. package/src/auth/session-cache.ts +112 -0
  1167. package/src/auth/sessions.ts +55 -0
  1168. package/src/auth/strategy.ts +46 -0
  1169. package/src/auth/types.ts +573 -0
  1170. package/src/auth/validation.ts +241 -0
  1171. package/src/authorization/application-access.ts +34 -0
  1172. package/src/authorization/decision.ts +215 -0
  1173. package/src/authorization/errors.ts +12 -0
  1174. package/src/authorization/event-visibility.ts +99 -0
  1175. package/src/authorization/grant-kinds.ts +149 -0
  1176. package/src/authorization/index.ts +24 -0
  1177. package/src/authorization/resolve.ts +101 -0
  1178. package/src/authorization/run-visibility.ts +78 -0
  1179. package/src/authorization/types.ts +52 -0
  1180. package/src/blob-storage/browser.ts +28 -0
  1181. package/src/blob-storage/constants.ts +9 -0
  1182. package/src/blob-storage/derive.ts +13 -0
  1183. package/src/blob-storage/errors.ts +6 -0
  1184. package/src/blob-storage/in-memory.ts +74 -0
  1185. package/src/blob-storage/index.ts +37 -0
  1186. package/src/blob-storage/types.ts +143 -0
  1187. package/src/blob-storage/utils.ts +126 -0
  1188. package/src/blob-storage/validation.ts +58 -0
  1189. package/src/bootstrap/discovery.ts +507 -0
  1190. package/src/bootstrap/index.ts +26 -0
  1191. package/src/bootstrap/ontology-type-manifest.ts +316 -0
  1192. package/src/broker/errors.ts +15 -0
  1193. package/src/broker/in-memory.ts +511 -0
  1194. package/src/broker/index.ts +12 -0
  1195. package/src/broker/types.ts +129 -0
  1196. package/src/connectors/builders.ts +33 -0
  1197. package/src/connectors/errors.ts +15 -0
  1198. package/src/connectors/index.ts +9 -0
  1199. package/src/connectors/runtime.ts +100 -0
  1200. package/src/connectors/types.ts +64 -0
  1201. package/src/datasets/builders.ts +233 -0
  1202. package/src/datasets/errors.ts +3 -0
  1203. package/src/datasets/index.ts +13 -0
  1204. package/src/datasets/types.ts +52 -0
  1205. package/src/datasets/validation.ts +251 -0
  1206. package/src/edits/errors.ts +6 -0
  1207. package/src/edits/index.ts +24 -0
  1208. package/src/edits/normalize.ts +87 -0
  1209. package/src/edits/properties.ts +153 -0
  1210. package/src/edits/recorder.ts +312 -0
  1211. package/src/edits/types.ts +275 -0
  1212. package/src/error-reporting/capability.ts +160 -0
  1213. package/src/error-reporting/internal.ts +13 -0
  1214. package/src/error-reporting/normalize.ts +35 -0
  1215. package/src/error-reporting/reporter.ts +65 -0
  1216. package/src/error-reporting/types.ts +125 -0
  1217. package/src/events/definitions.ts +241 -0
  1218. package/src/events/envelope.ts +68 -0
  1219. package/src/events/errors.ts +7 -0
  1220. package/src/events/index.ts +167 -0
  1221. package/src/events/outbox-dispatcher.ts +534 -0
  1222. package/src/events/property-changes.ts +9 -0
  1223. package/src/events/runtime.ts +401 -0
  1224. package/src/events/scope.ts +71 -0
  1225. package/src/events/selectors/builder.ts +531 -0
  1226. package/src/events/selectors/index.ts +42 -0
  1227. package/src/events/selectors/predicate.ts +91 -0
  1228. package/src/events/selectors/types.ts +258 -0
  1229. package/src/events/toStoredEvent.ts +35 -0
  1230. package/src/events/types/actions.ts +42 -0
  1231. package/src/events/types/datasets.ts +21 -0
  1232. package/src/events/types/index.ts +206 -0
  1233. package/src/events/types/links.ts +42 -0
  1234. package/src/events/types/objects.ts +38 -0
  1235. package/src/events/types/pipelines.ts +67 -0
  1236. package/src/events/types/rules.ts +31 -0
  1237. package/src/events/types/schedules.ts +15 -0
  1238. package/src/events/types/syncs.ts +27 -0
  1239. package/src/events/types/telemetry.ts +19 -0
  1240. package/src/events/types/workflows.ts +172 -0
  1241. package/src/http/api-routes.ts +384 -0
  1242. package/src/http/index.ts +3 -0
  1243. package/src/http/route-pattern.ts +37 -0
  1244. package/src/index.ts +916 -0
  1245. package/src/json.ts +137 -0
  1246. package/src/lake-storage/definition-updates.ts +263 -0
  1247. package/src/lake-storage/errors.ts +6 -0
  1248. package/src/lake-storage/in-memory.ts +348 -0
  1249. package/src/lake-storage/index.ts +48 -0
  1250. package/src/lake-storage/sql-transforms.ts +67 -0
  1251. package/src/lake-storage/types.ts +135 -0
  1252. package/src/logging/console-logger.ts +63 -0
  1253. package/src/logging/index.ts +43 -0
  1254. package/src/logging/record.ts +126 -0
  1255. package/src/logging/run-logger.ts +350 -0
  1256. package/src/logging/runtime.ts +341 -0
  1257. package/src/logging/stream.ts +38 -0
  1258. package/src/logging/types.ts +156 -0
  1259. package/src/maintenance/index.ts +9 -0
  1260. package/src/maintenance/ontology-maintenance.ts +351 -0
  1261. package/src/maintenance/types.ts +57 -0
  1262. package/src/materialization/dataset-watermark.ts +52 -0
  1263. package/src/materialization/errors.ts +73 -0
  1264. package/src/materialization/events.ts +92 -0
  1265. package/src/materialization/identity.ts +36 -0
  1266. package/src/materialization/index.ts +75 -0
  1267. package/src/materialization/model.ts +394 -0
  1268. package/src/materialization/refs.ts +134 -0
  1269. package/src/materializer/README.md +130 -0
  1270. package/src/materializer/context.ts +75 -0
  1271. package/src/materializer/edits/apply.ts +241 -0
  1272. package/src/materializer/edits/commit.ts +311 -0
  1273. package/src/materializer/edits/execution-units.ts +32 -0
  1274. package/src/materializer/edits/load-state.ts +148 -0
  1275. package/src/materializer/edits/operations.ts +298 -0
  1276. package/src/materializer/edits/plan.ts +192 -0
  1277. package/src/materializer/edits/read-set.ts +79 -0
  1278. package/src/materializer/edits/working-state.ts +171 -0
  1279. package/src/materializer/effective/build-events.ts +197 -0
  1280. package/src/materializer/effective/diff.ts +169 -0
  1281. package/src/materializer/effective/load-state.ts +75 -0
  1282. package/src/materializer/effective/resolve.ts +96 -0
  1283. package/src/materializer/effective/validate.ts +180 -0
  1284. package/src/materializer/execution/commit-lifecycle.ts +57 -0
  1285. package/src/materializer/execution/plan-stream.ts +97 -0
  1286. package/src/materializer/execution/run-correlation.ts +73 -0
  1287. package/src/materializer/execution/work-executor.ts +143 -0
  1288. package/src/materializer/execution/work-records.ts +186 -0
  1289. package/src/materializer/index.ts +109 -0
  1290. package/src/materializer/materializer.ts +64 -0
  1291. package/src/materializer/projections/entry-validator.ts +162 -0
  1292. package/src/materializer/projections/finish-run.ts +194 -0
  1293. package/src/materializer/projections/replace.ts +447 -0
  1294. package/src/materializer/projections/replacement-plan.ts +376 -0
  1295. package/src/materializer/projections/source-materialization.ts +99 -0
  1296. package/src/materializer/shared/abort.ts +7 -0
  1297. package/src/materializer/shared/batching.ts +32 -0
  1298. package/src/materializer/shared/chunking.ts +27 -0
  1299. package/src/materializer/shared/identity.ts +141 -0
  1300. package/src/materializer/shared/normalize.ts +527 -0
  1301. package/src/materializer/shared/projection-run.ts +61 -0
  1302. package/src/materializer/telemetry/append.ts +503 -0
  1303. package/src/materializer/telemetry/plan.ts +363 -0
  1304. package/src/objects/action/errors.ts +56 -0
  1305. package/src/objects/action/index.ts +3 -0
  1306. package/src/objects/action/request.ts +63 -0
  1307. package/src/objects/context/index.ts +6 -0
  1308. package/src/objects/context/resolve.ts +51 -0
  1309. package/src/objects/context/types.ts +31 -0
  1310. package/src/objects/contexts.ts +64 -0
  1311. package/src/objects/errors.ts +7 -0
  1312. package/src/objects/helpers.ts +18 -0
  1313. package/src/objects/index.ts +26 -0
  1314. package/src/objects/link/authorization.ts +26 -0
  1315. package/src/objects/link/endpoints.ts +66 -0
  1316. package/src/objects/link/index.ts +3 -0
  1317. package/src/objects/link/remove.ts +42 -0
  1318. package/src/objects/link/upsert-batch.ts +80 -0
  1319. package/src/objects/link/upsert.ts +56 -0
  1320. package/src/objects/materializer-adapter.ts +307 -0
  1321. package/src/objects/object/delete.ts +47 -0
  1322. package/src/objects/object/index.ts +3 -0
  1323. package/src/objects/object/upsert-batch.ts +57 -0
  1324. package/src/objects/object/upsert.ts +38 -0
  1325. package/src/objects/query/errors.ts +55 -0
  1326. package/src/objects/query/executor.ts +1345 -0
  1327. package/src/objects/query/explain-format.ts +34 -0
  1328. package/src/objects/query/explain.ts +215 -0
  1329. package/src/objects/query/index.ts +77 -0
  1330. package/src/objects/query/ir.ts +211 -0
  1331. package/src/objects/query/normalize.ts +245 -0
  1332. package/src/objects/query/planner.ts +538 -0
  1333. package/src/objects/query/scalar-values.ts +100 -0
  1334. package/src/objects/query/validate.ts +1276 -0
  1335. package/src/objects/runtime-batch.ts +105 -0
  1336. package/src/objects/sdk/index.ts +2 -0
  1337. package/src/objects/sdk/object-handle.ts +139 -0
  1338. package/src/objects/sdk/object-set.ts +224 -0
  1339. package/src/objects/sdk/query-builder.ts +386 -0
  1340. package/src/objects/sdk/query-executor.ts +62 -0
  1341. package/src/objects/sdk/runtime-query-executor.ts +88 -0
  1342. package/src/objects/sdk/telemetry-channel.ts +81 -0
  1343. package/src/objects/sdk/where.ts +87 -0
  1344. package/src/objects/service/action-service.ts +40 -0
  1345. package/src/objects/service/index.ts +6 -0
  1346. package/src/objects/service/link-service.ts +74 -0
  1347. package/src/objects/service/list-service.ts +89 -0
  1348. package/src/objects/service/object-service.ts +28 -0
  1349. package/src/objects/service/telemetry-service.ts +17 -0
  1350. package/src/objects/telemetry/append-batch.ts +74 -0
  1351. package/src/objects/telemetry/history.ts +32 -0
  1352. package/src/objects/telemetry/index.ts +4 -0
  1353. package/src/objects/telemetry/write-batch.ts +52 -0
  1354. package/src/ontology/builders.ts +695 -0
  1355. package/src/ontology/decimal.ts +120 -0
  1356. package/src/ontology/errors.ts +25 -0
  1357. package/src/ontology/index.ts +80 -0
  1358. package/src/ontology/inference/index.ts +215 -0
  1359. package/src/ontology/internal.ts +3 -0
  1360. package/src/ontology/json-schema.ts +123 -0
  1361. package/src/ontology/refs.ts +80 -0
  1362. package/src/ontology/registry.ts +417 -0
  1363. package/src/ontology/tokens.ts +113 -0
  1364. package/src/ontology/types.ts +436 -0
  1365. package/src/ontology/units/index.ts +115 -0
  1366. package/src/ontology/units/quantitative-types.ts +608 -0
  1367. package/src/ontology/units/types.ts +27 -0
  1368. package/src/ontology/validation/index.ts +36 -0
  1369. package/src/ontology/validation/links.ts +126 -0
  1370. package/src/ontology/validation/normalize.ts +215 -0
  1371. package/src/ontology/validation/properties.ts +235 -0
  1372. package/src/ontology/validation/query.ts +300 -0
  1373. package/src/ontology/validation/schema.ts +174 -0
  1374. package/src/ontology/validation/telemetry.ts +53 -0
  1375. package/src/pipelines/builders.ts +155 -0
  1376. package/src/pipelines/errors.ts +3 -0
  1377. package/src/pipelines/index.ts +26 -0
  1378. package/src/pipelines/request.ts +71 -0
  1379. package/src/pipelines/types.ts +199 -0
  1380. package/src/predicates/builders.ts +152 -0
  1381. package/src/predicates/evaluate.ts +107 -0
  1382. package/src/predicates/index.ts +28 -0
  1383. package/src/predicates/types.ts +124 -0
  1384. package/src/predicates/validation.ts +152 -0
  1385. package/src/projections/builders.ts +770 -0
  1386. package/src/projections/errors.ts +3 -0
  1387. package/src/projections/index.ts +32 -0
  1388. package/src/projections/internal.ts +75 -0
  1389. package/src/projections/ownership.ts +134 -0
  1390. package/src/projections/registry.ts +269 -0
  1391. package/src/projections/revision.ts +245 -0
  1392. package/src/projections/types.ts +165 -0
  1393. package/src/projections/validation.ts +531 -0
  1394. package/src/provider-scope.ts +11 -0
  1395. package/src/query.ts +75 -0
  1396. package/src/queues/errors.ts +6 -0
  1397. package/src/queues/in-memory.ts +364 -0
  1398. package/src/queues/index.ts +23 -0
  1399. package/src/queues/types.ts +230 -0
  1400. package/src/rules/builders.ts +126 -0
  1401. package/src/rules/dependencies.ts +76 -0
  1402. package/src/rules/errors.ts +11 -0
  1403. package/src/rules/index.ts +30 -0
  1404. package/src/rules/internal.ts +8 -0
  1405. package/src/rules/types.ts +113 -0
  1406. package/src/rules/validation.ts +153 -0
  1407. package/src/runtime/create.ts +163 -0
  1408. package/src/runtime/errors.ts +8 -0
  1409. package/src/runtime/index.ts +67 -0
  1410. package/src/runtime/internal.ts +7 -0
  1411. package/src/runtime/ontology-mutations.ts +90 -0
  1412. package/src/runtime/scoped.ts +436 -0
  1413. package/src/runtime/sixb.ts +822 -0
  1414. package/src/runtime/storage-readiness.ts +91 -0
  1415. package/src/runtime/types.ts +1401 -0
  1416. package/src/sandboxes/errors.ts +22 -0
  1417. package/src/sandboxes/exec.ts +102 -0
  1418. package/src/sandboxes/index.ts +19 -0
  1419. package/src/sandboxes/sandbox.ts +124 -0
  1420. package/src/scheduler/errors.ts +7 -0
  1421. package/src/scheduler/index.ts +3 -0
  1422. package/src/scheduler/runtime.ts +174 -0
  1423. package/src/schedules/builders.ts +257 -0
  1424. package/src/schedules/cron.ts +166 -0
  1425. package/src/schedules/errors.ts +7 -0
  1426. package/src/schedules/index.ts +44 -0
  1427. package/src/schedules/next-occurrence.ts +217 -0
  1428. package/src/schedules/runtime.ts +241 -0
  1429. package/src/schedules/types.ts +212 -0
  1430. package/src/schedules/validation.ts +398 -0
  1431. package/src/security/applications.ts +11 -0
  1432. package/src/security/builders.ts +128 -0
  1433. package/src/security/errors.ts +3 -0
  1434. package/src/security/every.ts +108 -0
  1435. package/src/security/grants.ts +215 -0
  1436. package/src/security/index.ts +51 -0
  1437. package/src/security/membership-policies.ts +101 -0
  1438. package/src/security/runtime.ts +101 -0
  1439. package/src/security/types.ts +156 -0
  1440. package/src/security/validation.ts +430 -0
  1441. package/src/storage/action-runs/errors.ts +13 -0
  1442. package/src/storage/action-runs/idempotency.ts +68 -0
  1443. package/src/storage/action-runs/in-memory.ts +420 -0
  1444. package/src/storage/action-runs/index.ts +31 -0
  1445. package/src/storage/action-runs/types.ts +169 -0
  1446. package/src/storage/agents/errors.ts +22 -0
  1447. package/src/storage/agents/in-memory.ts +498 -0
  1448. package/src/storage/agents/index.ts +42 -0
  1449. package/src/storage/agents/types.ts +348 -0
  1450. package/src/storage/auth/errors.ts +40 -0
  1451. package/src/storage/auth/in-memory/access-tokens.ts +123 -0
  1452. package/src/storage/auth/in-memory/auth-storage.ts +559 -0
  1453. package/src/storage/auth/in-memory/group-memberships.ts +46 -0
  1454. package/src/storage/auth/in-memory/identities.ts +66 -0
  1455. package/src/storage/auth/in-memory/index.ts +1 -0
  1456. package/src/storage/auth/in-memory/invitations.ts +165 -0
  1457. package/src/storage/auth/in-memory/magic-links.ts +98 -0
  1458. package/src/storage/auth/in-memory/oidc-attempts.ts +75 -0
  1459. package/src/storage/auth/in-memory/service-account-group-memberships.ts +102 -0
  1460. package/src/storage/auth/in-memory/service-accounts.ts +80 -0
  1461. package/src/storage/auth/in-memory/sessions.ts +177 -0
  1462. package/src/storage/auth/in-memory/shared.ts +602 -0
  1463. package/src/storage/auth/in-memory/users.ts +139 -0
  1464. package/src/storage/auth/in-memory.ts +1 -0
  1465. package/src/storage/auth/index.ts +58 -0
  1466. package/src/storage/auth/types.ts +639 -0
  1467. package/src/storage/errors.ts +45 -0
  1468. package/src/storage/file-upload-sessions/errors.ts +24 -0
  1469. package/src/storage/file-upload-sessions/in-memory.ts +161 -0
  1470. package/src/storage/file-upload-sessions/index.ts +19 -0
  1471. package/src/storage/file-upload-sessions/types.ts +61 -0
  1472. package/src/storage/file-upload-sessions/utils.ts +49 -0
  1473. package/src/storage/in-memory/index.ts +297 -0
  1474. package/src/storage/in-memory/testing.ts +21 -0
  1475. package/src/storage/index.ts +489 -0
  1476. package/src/storage/migrations/check-schema.ts +49 -0
  1477. package/src/storage/migrations/index.ts +23 -0
  1478. package/src/storage/migrations/migrate-storage.ts +24 -0
  1479. package/src/storage/migrations/migration-set.ts +270 -0
  1480. package/src/storage/migrations/types.ts +129 -0
  1481. package/src/storage/objects/in-memory.ts +1154 -0
  1482. package/src/storage/objects/index.ts +24 -0
  1483. package/src/storage/objects/types.ts +244 -0
  1484. package/src/storage/ontology/commits.ts +132 -0
  1485. package/src/storage/ontology/in-memory/commits.ts +122 -0
  1486. package/src/storage/ontology/in-memory/index.ts +94 -0
  1487. package/src/storage/ontology/in-memory/materializations-finalization.ts +484 -0
  1488. package/src/storage/ontology/in-memory/materializations-state.ts +183 -0
  1489. package/src/storage/ontology/in-memory/materializations-work.ts +62 -0
  1490. package/src/storage/ontology/in-memory/materializations.ts +1192 -0
  1491. package/src/storage/ontology/in-memory/outbox.ts +227 -0
  1492. package/src/storage/ontology/in-memory/shared-state.ts +161 -0
  1493. package/src/storage/ontology/in-memory/sources.ts +566 -0
  1494. package/src/storage/ontology/in-memory/testing.ts +29 -0
  1495. package/src/storage/ontology/index.ts +119 -0
  1496. package/src/storage/ontology/materializations.ts +414 -0
  1497. package/src/storage/ontology/outbox.ts +79 -0
  1498. package/src/storage/ontology/provider-header-validation.ts +173 -0
  1499. package/src/storage/ontology/provider-validation.ts +36 -0
  1500. package/src/storage/ontology/provider-work.ts +330 -0
  1501. package/src/storage/ontology/provider.ts +852 -0
  1502. package/src/storage/ontology/sources.ts +195 -0
  1503. package/src/storage/operation-scope.ts +248 -0
  1504. package/src/storage/pagination.ts +23 -0
  1505. package/src/storage/pipeline-runs/errors.ts +6 -0
  1506. package/src/storage/pipeline-runs/in-memory.ts +307 -0
  1507. package/src/storage/pipeline-runs/index.ts +19 -0
  1508. package/src/storage/pipeline-runs/types.ts +148 -0
  1509. package/src/storage/projection-runs/errors.ts +15 -0
  1510. package/src/storage/projection-runs/in-memory.ts +321 -0
  1511. package/src/storage/projection-runs/index.ts +36 -0
  1512. package/src/storage/projection-runs/lifecycle.ts +793 -0
  1513. package/src/storage/projection-runs/types.ts +254 -0
  1514. package/src/storage/rules/in-memory.ts +191 -0
  1515. package/src/storage/rules/index.ts +12 -0
  1516. package/src/storage/rules/types.ts +80 -0
  1517. package/src/storage/run-listing.ts +107 -0
  1518. package/src/storage/sync-runs/errors.ts +7 -0
  1519. package/src/storage/sync-runs/in-memory.ts +181 -0
  1520. package/src/storage/sync-runs/index.ts +14 -0
  1521. package/src/storage/sync-runs/types.ts +93 -0
  1522. package/src/storage/timeseries/index.ts +7 -0
  1523. package/src/storage/timeseries/store.ts +214 -0
  1524. package/src/storage/timeseries/types.ts +57 -0
  1525. package/src/storage/transaction.ts +56 -0
  1526. package/src/storage/types.ts +299 -0
  1527. package/src/storage/webhook-deliveries/in-memory.ts +108 -0
  1528. package/src/storage/webhook-deliveries/index.ts +9 -0
  1529. package/src/storage/webhook-deliveries/types.ts +41 -0
  1530. package/src/storage/webhook-runs/errors.ts +6 -0
  1531. package/src/storage/webhook-runs/in-memory.ts +131 -0
  1532. package/src/storage/webhook-runs/index.ts +12 -0
  1533. package/src/storage/webhook-runs/types.ts +69 -0
  1534. package/src/storage/workflow-interventions/errors.ts +6 -0
  1535. package/src/storage/workflow-interventions/in-memory.ts +192 -0
  1536. package/src/storage/workflow-interventions/index.ts +14 -0
  1537. package/src/storage/workflow-interventions/types.ts +100 -0
  1538. package/src/storage/workflow-runs/errors.ts +6 -0
  1539. package/src/storage/workflow-runs/in-memory.ts +777 -0
  1540. package/src/storage/workflow-runs/index.ts +45 -0
  1541. package/src/storage/workflow-runs/types.ts +344 -0
  1542. package/src/syncs/builders.ts +101 -0
  1543. package/src/syncs/errors.ts +3 -0
  1544. package/src/syncs/index.ts +22 -0
  1545. package/src/syncs/request.ts +91 -0
  1546. package/src/syncs/types.ts +136 -0
  1547. package/src/testing/agent-storage-contract.ts +824 -0
  1548. package/src/testing/auth-storage-contract.ts +1932 -0
  1549. package/src/testing/blob-storage-contract.ts +108 -0
  1550. package/src/testing/broker-contract.ts +819 -0
  1551. package/src/testing/effective-storage-contract.ts +182 -0
  1552. package/src/testing/index.ts +65 -0
  1553. package/src/testing/lake-storage-contract.ts +699 -0
  1554. package/src/testing/materialization-failure-contract.ts +66 -0
  1555. package/src/testing/materializer-fixture.ts +119 -0
  1556. package/src/testing/materializer-storage-contract.ts +389 -0
  1557. package/src/testing/object-query-contract.ts +1205 -0
  1558. package/src/testing/ontology-contract-fixture.ts +192 -0
  1559. package/src/testing/ontology-storage-contract.ts +922 -0
  1560. package/src/testing/projection-run-storage-contract.ts +372 -0
  1561. package/src/testing/queues-contract.ts +634 -0
  1562. package/src/testing/sandboxes-contract.ts +404 -0
  1563. package/src/webhooks/builders.ts +154 -0
  1564. package/src/webhooks/connector.ts +19 -0
  1565. package/src/webhooks/errors.ts +3 -0
  1566. package/src/webhooks/index.ts +25 -0
  1567. package/src/webhooks/registry.ts +127 -0
  1568. package/src/webhooks/types.ts +98 -0
  1569. package/src/webhooks/unverified.ts +82 -0
  1570. package/src/workers/errors.ts +25 -0
  1571. package/src/workers/index.ts +6 -0
  1572. package/src/workers/queue-delivery.ts +309 -0
  1573. package/src/workers/queue-worker.ts +260 -0
  1574. package/src/workers/worker.ts +87 -0
  1575. package/src/workflows/builders.ts +471 -0
  1576. package/src/workflows/errors.ts +13 -0
  1577. package/src/workflows/index.ts +94 -0
  1578. package/src/workflows/request.ts +161 -0
  1579. package/src/workflows/runtime.ts +68 -0
  1580. package/src/workflows/snapshot.ts +383 -0
  1581. package/src/workflows/types.ts +781 -0
  1582. package/src/workflows/validation.ts +572 -0
@@ -0,0 +1,2954 @@
1
+ // @bun
2
+ import {
3
+ AuthRuntimeError,
4
+ assertNonEmpty,
5
+ getCookie,
6
+ isInvitationDeliveryAuthStrategy,
7
+ normalizePagination,
8
+ resolveAuthConfig,
9
+ resolveAuthCookieOptionsForAudience,
10
+ resolveAuthSessionAudience,
11
+ resolveInvitationExpiresAt,
12
+ sanitizeReturnTo
13
+ } from "./chunk-xwnf87e1.js";
14
+ import {
15
+ GRANT_KINDS,
16
+ canAccessApplication,
17
+ grantKindOf,
18
+ resolveAuthorizationContext
19
+ } from "./chunk-0fygrz37.js";
20
+
21
+ // src/auth/access-tokens.ts
22
+ import { createHash, randomBytes, randomUUID } from "crypto";
23
+ var PERSONAL_ACCESS_TOKEN_PREFIX = "sixb_pat";
24
+ var SERVICE_ACCOUNT_ACCESS_TOKEN_PREFIX = "sixb_sat";
25
+ var ACCESS_TOKEN_ID_PATTERN = /^tok_[A-Za-z0-9_-]+$/;
26
+ var ACCESS_TOKEN_SECRET_PATTERN = /^[A-Za-z0-9_-]{32,}$/;
27
+ function generateAccessTokenSecret() {
28
+ return randomBytes(32).toString("base64url");
29
+ }
30
+ function hashAccessTokenSecret(secret) {
31
+ return createHash("sha256").update(secret).digest("hex");
32
+ }
33
+ function formatAccessTokenValue(kind, tokenId, tokenSecret) {
34
+ const prefix = accessTokenPrefixForKind(kind);
35
+ if (!ACCESS_TOKEN_ID_PATTERN.test(tokenId)) {
36
+ throw new Error("[Sixb] Access token ids must start with 'tok_' and be URL-safe.");
37
+ }
38
+ if (!ACCESS_TOKEN_SECRET_PATTERN.test(tokenSecret)) {
39
+ throw new Error("[Sixb] Access token secrets must be at least 32 URL-safe characters.");
40
+ }
41
+ return `${prefix}_${tokenId}.${tokenSecret}`;
42
+ }
43
+ function parseAccessTokenValue(value) {
44
+ if (!value) {
45
+ return null;
46
+ }
47
+ const firstDot = value.indexOf(".");
48
+ if (firstDot <= 0 || firstDot !== value.lastIndexOf(".") || firstDot === value.length - 1) {
49
+ return null;
50
+ }
51
+ const tokenLabel = value.slice(0, firstDot);
52
+ const tokenSecret = value.slice(firstDot + 1);
53
+ const kind = accessTokenKindFromLabel(tokenLabel);
54
+ if (!kind || !ACCESS_TOKEN_SECRET_PATTERN.test(tokenSecret)) {
55
+ return null;
56
+ }
57
+ const tokenId = tokenLabel.slice(`${accessTokenPrefixForKind(kind)}_`.length);
58
+ if (!ACCESS_TOKEN_ID_PATTERN.test(tokenId)) {
59
+ return null;
60
+ }
61
+ return { kind, tokenId, tokenSecret };
62
+ }
63
+ function getBearerAccessTokenValue(request) {
64
+ const header = request.headers.get("authorization");
65
+ if (!header) {
66
+ return null;
67
+ }
68
+ const [scheme, token, extra] = header.trim().split(/\s+/);
69
+ if (scheme?.toLowerCase() !== "bearer" || !token || extra) {
70
+ return null;
71
+ }
72
+ return token;
73
+ }
74
+ function createAccessTokenCredential(kind, tokenId = `tok_${randomUUID()}`) {
75
+ const tokenSecret = generateAccessTokenSecret();
76
+ return {
77
+ kind,
78
+ tokenId,
79
+ tokenSecret,
80
+ tokenHash: hashAccessTokenSecret(tokenSecret),
81
+ tokenValue: formatAccessTokenValue(kind, tokenId, tokenSecret)
82
+ };
83
+ }
84
+ function accessTokenPrefixForKind(kind) {
85
+ switch (kind) {
86
+ case "personal":
87
+ return PERSONAL_ACCESS_TOKEN_PREFIX;
88
+ case "serviceAccount":
89
+ return SERVICE_ACCOUNT_ACCESS_TOKEN_PREFIX;
90
+ }
91
+ }
92
+ function accessTokenKindFromLabel(label) {
93
+ if (label.startsWith(`${PERSONAL_ACCESS_TOKEN_PREFIX}_`)) {
94
+ return "personal";
95
+ }
96
+ if (label.startsWith(`${SERVICE_ACCOUNT_ACCESS_TOKEN_PREFIX}_`)) {
97
+ return "serviceAccount";
98
+ }
99
+ return null;
100
+ }
101
+ // src/auth/csrf.ts
102
+ import { randomBytes as randomBytes2, timingSafeEqual } from "crypto";
103
+ var CSRF_HEADER_NAME = "x-sixb-csrf";
104
+ function generateCsrfToken() {
105
+ return randomBytes2(32).toString("base64url");
106
+ }
107
+ function isCsrfExemptMethod(method) {
108
+ const normalized = method.toUpperCase();
109
+ return normalized === "GET" || normalized === "HEAD" || normalized === "OPTIONS";
110
+ }
111
+ function verifyDoubleSubmitCsrf(request, options) {
112
+ if (isCsrfExemptMethod(request.method)) {
113
+ return true;
114
+ }
115
+ const cookieValue = getCookie(request, options.cookieName);
116
+ const headerValue = request.headers.get(options.headerName ?? CSRF_HEADER_NAME);
117
+ if (!cookieValue || !headerValue) {
118
+ return false;
119
+ }
120
+ return safeEqual(cookieValue, headerValue);
121
+ }
122
+ function safeEqual(left, right) {
123
+ const leftBytes = Buffer.from(left);
124
+ const rightBytes = Buffer.from(right);
125
+ if (leftBytes.length !== rightBytes.length) {
126
+ return false;
127
+ }
128
+ return timingSafeEqual(leftBytes, rightBytes);
129
+ }
130
+ // src/auth/runtime.ts
131
+ import { randomUUID as randomUUID3 } from "crypto";
132
+
133
+ // src/security/applications.ts
134
+ var applications = {
135
+ atlas: { kind: "application", id: "atlas", label: "Atlas" },
136
+ app: { kind: "application", id: "app", label: "Custom app" }
137
+ };
138
+ var APPLICATION_IDS = new Set(Object.values(applications).map((application) => application.id));
139
+ // src/security/errors.ts
140
+ class SecurityValidationError extends Error {
141
+ name = "SecurityValidationError";
142
+ }
143
+
144
+ // src/security/membership-policies.ts
145
+ var MEMBERSHIP_OPERATIONS = ["invite", "assignGroups", "suspend"];
146
+ function resolveMembershipPolicyScope(input) {
147
+ const callerGroups = new Set(input.callerGroupIds);
148
+ const policyIds = [];
149
+ const operations = createEmptyOperationScopes();
150
+ for (const policy of input.membershipPolicies) {
151
+ if (!policy.grantedToGroupIds.some((groupId) => callerGroups.has(groupId))) {
152
+ continue;
153
+ }
154
+ policyIds.push(policy.id);
155
+ for (const operation of policy.can) {
156
+ operations[operation].policyIds.push(policy.id);
157
+ for (const groupId of policy.scopeGroupIds) {
158
+ operations[operation].groupIds.add(groupId);
159
+ }
160
+ }
161
+ }
162
+ return {
163
+ policyIds,
164
+ operations: {
165
+ invite: freezeOperationScope(operations.invite),
166
+ assignGroups: freezeOperationScope(operations.assignGroups),
167
+ suspend: freezeOperationScope(operations.suspend)
168
+ }
169
+ };
170
+ }
171
+ function canPerformMembershipOperation(scope, operation, groupIds) {
172
+ const operationScope = scope.operations[operation];
173
+ if (operationScope.policyIds.length === 0) {
174
+ return false;
175
+ }
176
+ if (groupIds.length === 0) {
177
+ return true;
178
+ }
179
+ return groupIds.every((groupId) => operationScope.groupIds.has(groupId));
180
+ }
181
+ function missingMembershipGroupIds(scope, operation, groupIds) {
182
+ if (groupIds.length === 0) {
183
+ return [];
184
+ }
185
+ const operationScope = scope.operations[operation];
186
+ return groupIds.filter((groupId) => !operationScope.groupIds.has(groupId));
187
+ }
188
+ function createEmptyOperationScopes() {
189
+ return {
190
+ invite: { policyIds: [], groupIds: new Set },
191
+ assignGroups: { policyIds: [], groupIds: new Set },
192
+ suspend: { policyIds: [], groupIds: new Set }
193
+ };
194
+ }
195
+ function freezeOperationScope(input) {
196
+ return {
197
+ policyIds: [...input.policyIds],
198
+ groupIds: new Set(input.groupIds)
199
+ };
200
+ }
201
+ function isMembershipOperation(value) {
202
+ return MEMBERSHIP_OPERATIONS.includes(value);
203
+ }
204
+
205
+ // src/security/validation.ts
206
+ var GRANT_CAPABILITIES = Object.keys({
207
+ access: true,
208
+ view: true,
209
+ edit: true,
210
+ append: true,
211
+ apply: true,
212
+ run: true,
213
+ observe: true
214
+ });
215
+ function formatAlternatives(values) {
216
+ const quoted = values.map((value) => `'${value}'`);
217
+ const last = quoted.at(-1);
218
+ return quoted.length < 2 ? last ?? "" : `${quoted.slice(0, -1).join(", ")}, or ${last}`;
219
+ }
220
+ function isRecord(value) {
221
+ return typeof value === "object" && value !== null && !Array.isArray(value);
222
+ }
223
+ function assertNonEmptyString(value, field, createError = (message) => new SecurityValidationError(message)) {
224
+ if (typeof value !== "string" || value.trim().length === 0) {
225
+ throw createError(`[Sixb] ${field} must not be empty.`);
226
+ }
227
+ }
228
+ function assertOptionalString(value, field, createError = (message) => new SecurityValidationError(message)) {
229
+ if (value === undefined) {
230
+ return;
231
+ }
232
+ if (typeof value !== "string") {
233
+ throw createError(`[Sixb] ${field} must be a string.`);
234
+ }
235
+ }
236
+ function assertStringArray(value, field, createError) {
237
+ if (!Array.isArray(value)) {
238
+ throw createError(`[Sixb] ${field} must be an array of group ids.`);
239
+ }
240
+ for (const item of value) {
241
+ assertNonEmptyString(item, `${field} item`, createError);
242
+ }
243
+ }
244
+ function assertMembershipOperationArray(value, field, createError) {
245
+ if (!Array.isArray(value)) {
246
+ throw createError(`[Sixb] ${field} must be an array of membership operations.`);
247
+ }
248
+ for (const item of value) {
249
+ if (!isMembershipOperation(item)) {
250
+ throw createError(`[Sixb] ${field} must contain only membership operations: invite, assignGroups, suspend.`);
251
+ }
252
+ }
253
+ }
254
+ function assertNoDuplicateIds(ids, field) {
255
+ const seen = new Set;
256
+ for (const id of ids) {
257
+ if (seen.has(id)) {
258
+ throw new SecurityValidationError(`[Sixb] ${field} contains duplicate group id '${id}'.`);
259
+ }
260
+ seen.add(id);
261
+ }
262
+ }
263
+ function assertNoDuplicateOperations(operations, field) {
264
+ const seen = new Set;
265
+ for (const operation of operations) {
266
+ if (seen.has(operation)) {
267
+ throw new SecurityValidationError(`[Sixb] ${field} contains duplicate operation '${operation}'.`);
268
+ }
269
+ seen.add(operation);
270
+ }
271
+ }
272
+ function assertGroupDefinition(value, createError = (message) => new SecurityValidationError(message)) {
273
+ if (!isRecord(value)) {
274
+ throw createError("[Sixb] Group definition must be an object.");
275
+ }
276
+ if (value.kind !== "group") {
277
+ throw createError("[Sixb] Group definition kind must be 'group'.");
278
+ }
279
+ assertNonEmptyString(value.id, "Group id", createError);
280
+ assertOptionalString(value.label, `Group '${value.id}' label`, createError);
281
+ assertOptionalString(value.description, `Group '${value.id}' description`, createError);
282
+ }
283
+ function isGroupDefinition(value) {
284
+ try {
285
+ assertGroupDefinition(value, (message) => new Error(message));
286
+ return true;
287
+ } catch {
288
+ return false;
289
+ }
290
+ }
291
+ function assertMembershipPolicyDefinition(value, createError = (message) => new SecurityValidationError(message)) {
292
+ if (!isRecord(value)) {
293
+ throw createError("[Sixb] Membership policy definition must be an object.");
294
+ }
295
+ if (value.kind !== "membershipPolicy") {
296
+ throw createError("[Sixb] Membership policy definition kind must be 'membershipPolicy'.");
297
+ }
298
+ assertNonEmptyString(value.id, "Membership policy id", createError);
299
+ assertStringArray(value.grantedToGroupIds, `Membership policy '${value.id}' grantedTo`, createError);
300
+ assertStringArray(value.scopeGroupIds, `Membership policy '${value.id}' scope`, createError);
301
+ assertMembershipOperationArray(value.can, `Membership policy '${value.id}' can`, createError);
302
+ }
303
+ function isMembershipPolicyDefinition(value) {
304
+ try {
305
+ assertMembershipPolicyDefinition(value, (message) => new Error(message));
306
+ return true;
307
+ } catch {
308
+ return false;
309
+ }
310
+ }
311
+ function assertGrantDefinition(value, field, createError = (message) => new SecurityValidationError(message)) {
312
+ if (!isRecord(value) || value.kind !== "grant") {
313
+ throw createError(`[Sixb] ${field} must contain only grant definitions from 'can'.`);
314
+ }
315
+ if (!GRANT_CAPABILITIES.includes(value.capability)) {
316
+ throw createError(`[Sixb] ${field} grant capability must be ${formatAlternatives(GRANT_CAPABILITIES)}.`);
317
+ }
318
+ if (value.capability === "access" && value.target !== "application") {
319
+ throw createError(`[Sixb] ${field} access grant target must be 'application'.`);
320
+ }
321
+ if (value.capability === "view" && value.target !== "object" && value.target !== "dataset") {
322
+ throw createError(`[Sixb] ${field} view grant target must be 'object' or 'dataset'.`);
323
+ }
324
+ if (value.capability === "run" && value.target !== "workflow" && value.target !== "sync" && value.target !== "pipeline" && value.target !== "agent") {
325
+ throw createError(`[Sixb] ${field} run grant target must be 'workflow', 'sync', 'pipeline', or 'agent'.`);
326
+ }
327
+ if (value.capability === "observe" && value.target !== "logs") {
328
+ throw createError(`[Sixb] ${field} observe grant target must be 'logs'.`);
329
+ }
330
+ assertSelection(value.selection, field, createError);
331
+ }
332
+ function assertSelection(value, field, createError) {
333
+ if (!isRecord(value) || typeof value.all !== "boolean") {
334
+ throw createError(`[Sixb] ${field} grant must carry a selection from 'can' or a scope.`);
335
+ }
336
+ const ids = value.all ? value.except : value.ids;
337
+ if (!Array.isArray(ids)) {
338
+ throw createError(`[Sixb] ${field} grant selection must list ids.`);
339
+ }
340
+ for (const id of ids) {
341
+ assertNonEmptyString(id, `${field} grant selection id`, createError);
342
+ }
343
+ }
344
+ function assertRoleDefinition(value, createError = (message) => new SecurityValidationError(message)) {
345
+ if (!isRecord(value)) {
346
+ throw createError("[Sixb] Role definition must be an object.");
347
+ }
348
+ if (value.kind !== "role") {
349
+ throw createError("[Sixb] Role definition kind must be 'role'.");
350
+ }
351
+ assertNonEmptyString(value.id, "Role id", createError);
352
+ assertOptionalString(value.label, `Role '${value.id}' label`, createError);
353
+ assertOptionalString(value.description, `Role '${value.id}' description`, createError);
354
+ assertStringArray(value.grantedToGroupIds, `Role '${value.id}' grantedTo`, createError);
355
+ if (!Array.isArray(value.grants)) {
356
+ throw createError(`[Sixb] Role '${value.id}' grants must be an array.`);
357
+ }
358
+ for (const grant of value.grants) {
359
+ assertGrantDefinition(grant, `Role '${value.id}' grants`, createError);
360
+ }
361
+ }
362
+ function isRoleDefinition(value) {
363
+ try {
364
+ assertRoleDefinition(value, (message) => new Error(message));
365
+ return true;
366
+ } catch {
367
+ return false;
368
+ }
369
+ }
370
+ function validateSecurityDefinitionsAtStartup(input) {
371
+ const groupsById = new Map;
372
+ const rolesById = new Map;
373
+ const membershipPoliciesById = new Map;
374
+ for (const group of input.groups) {
375
+ assertGroupDefinition(group);
376
+ if (groupsById.has(group.id)) {
377
+ throw new SecurityValidationError(`[Sixb] Duplicate group id: ${group.id}`);
378
+ }
379
+ groupsById.set(group.id, group);
380
+ }
381
+ for (const role of input.roles ?? []) {
382
+ assertRoleDefinition(role);
383
+ if (rolesById.has(role.id)) {
384
+ throw new SecurityValidationError(`[Sixb] Duplicate role id: ${role.id}`);
385
+ }
386
+ if (role.grantedToGroupIds.length === 0) {
387
+ throw new SecurityValidationError(`[Sixb] Role '${role.id}' must be granted to at least one group.`);
388
+ }
389
+ if (role.grants.length === 0) {
390
+ throw new SecurityValidationError(`[Sixb] Role '${role.id}' must declare at least one grant.`);
391
+ }
392
+ assertNoDuplicateIds(role.grantedToGroupIds, `Role '${role.id}' grantedTo`);
393
+ for (const groupId of role.grantedToGroupIds) {
394
+ if (!groupsById.has(groupId)) {
395
+ throw new SecurityValidationError(`[Sixb] Role '${role.id}' grantedTo references unknown group '${groupId}'. Add it to 'security/groups/' or pass it to createSixb({ groups }).`);
396
+ }
397
+ }
398
+ for (const grant of role.grants) {
399
+ assertGrantReferences(role.id, grant, input);
400
+ }
401
+ rolesById.set(role.id, role);
402
+ }
403
+ for (const policy of input.membershipPolicies) {
404
+ assertMembershipPolicyDefinition(policy);
405
+ if (membershipPoliciesById.has(policy.id)) {
406
+ throw new SecurityValidationError(`[Sixb] Duplicate membership policy id: ${policy.id}`);
407
+ }
408
+ if (policy.grantedToGroupIds.length === 0) {
409
+ throw new SecurityValidationError(`[Sixb] Membership policy '${policy.id}' must grant membership authority to at least one group.`);
410
+ }
411
+ if (policy.can.length === 0) {
412
+ throw new SecurityValidationError(`[Sixb] Membership policy '${policy.id}' must declare at least one operation.`);
413
+ }
414
+ assertNoDuplicateIds(policy.grantedToGroupIds, `Membership policy '${policy.id}' grantedTo`);
415
+ assertNoDuplicateIds(policy.scopeGroupIds, `Membership policy '${policy.id}' scope`);
416
+ assertNoDuplicateOperations(policy.can, `Membership policy '${policy.id}' can`);
417
+ for (const groupId of policy.grantedToGroupIds) {
418
+ if (!groupsById.has(groupId)) {
419
+ throw new SecurityValidationError(`[Sixb] Membership policy '${policy.id}' grantedTo references unknown group '${groupId}'. Add it to 'security/groups/' or pass it to createSixb({ groups }).`);
420
+ }
421
+ }
422
+ for (const groupId of policy.scopeGroupIds) {
423
+ if (!groupsById.has(groupId)) {
424
+ throw new SecurityValidationError(`[Sixb] Membership policy '${policy.id}' scope references unknown group '${groupId}'. Add it to 'security/groups/' or pass it to createSixb({ groups }).`);
425
+ }
426
+ }
427
+ membershipPoliciesById.set(policy.id, policy);
428
+ }
429
+ return {
430
+ groups: [...groupsById.values()],
431
+ groupsById,
432
+ roles: [...rolesById.values()],
433
+ rolesById,
434
+ membershipPolicies: [...membershipPoliciesById.values()],
435
+ membershipPoliciesById
436
+ };
437
+ }
438
+ function assertGrantReferences(roleId, grant, registered) {
439
+ const spec = GRANT_KINDS[grantKindOf(grant)];
440
+ const universe = registered[spec.universeKey];
441
+ if (!universe) {
442
+ return;
443
+ }
444
+ const ids = grant.selection.all ? grant.selection.except : grant.selection.ids;
445
+ for (const id of ids) {
446
+ if (!universe.has(id)) {
447
+ throw new SecurityValidationError(`[Sixb] Role '${roleId}' grants ${grant.capability} on unknown ${spec.subject} '${id}'. ${spec.fix}`);
448
+ }
449
+ }
450
+ }
451
+
452
+ // src/security/builders.ts
453
+ var MEMBERSHIP_OPERATIONS2 = new Set(["invite", "assignGroups", "suspend"]);
454
+ function assertNonEmptyArray(value, field) {
455
+ if (value.length === 0) {
456
+ throw new SecurityValidationError(`[Sixb] ${field} must not be empty.`);
457
+ }
458
+ }
459
+ function groupIdsFrom(groups, field) {
460
+ return groups.map((group) => {
461
+ if (!isRecord(group) || group.kind !== "group") {
462
+ throw new SecurityValidationError(`[Sixb] ${field} must contain only group definitions.`);
463
+ }
464
+ assertNonEmptyString(group.id, `${field} group id`);
465
+ return group.id;
466
+ });
467
+ }
468
+ function membershipOperationsFrom(operations, field) {
469
+ return operations.map((operation) => {
470
+ if (!MEMBERSHIP_OPERATIONS2.has(operation)) {
471
+ throw new SecurityValidationError(`[Sixb] ${field} must contain only membership operations: invite, assignGroups, suspend.`);
472
+ }
473
+ return operation;
474
+ });
475
+ }
476
+ function defineGroup(id, options = {}) {
477
+ assertNonEmptyString(id, "Group id");
478
+ assertOptionalString(options.label, `Group '${id}' label`);
479
+ assertOptionalString(options.description, `Group '${id}' description`);
480
+ return {
481
+ kind: "group",
482
+ id,
483
+ ...options.label !== undefined ? { label: options.label } : {},
484
+ ...options.description !== undefined ? { description: options.description } : {}
485
+ };
486
+ }
487
+ function defineRole(id, options) {
488
+ assertNonEmptyString(id, "Role id");
489
+ assertOptionalString(options.label, `Role '${id}' label`);
490
+ assertOptionalString(options.description, `Role '${id}' description`);
491
+ assertNonEmptyArray(options.grantedTo, `Role '${id}' grantedTo`);
492
+ const grantedToGroupIds = groupIdsFrom(options.grantedTo, `Role '${id}' grantedTo`);
493
+ for (const grant of options.grants) {
494
+ assertGrantDefinition(grant, `Role '${id}' grants`);
495
+ }
496
+ if (options.grants.length === 0) {
497
+ throw new SecurityValidationError(`[Sixb] Role '${id}' grants must not be empty.`);
498
+ }
499
+ return {
500
+ kind: "role",
501
+ id,
502
+ ...options.label !== undefined ? { label: options.label } : {},
503
+ ...options.description !== undefined ? { description: options.description } : {},
504
+ grantedToGroupIds,
505
+ grants: options.grants
506
+ };
507
+ }
508
+ function defineMembershipPolicy(id, options) {
509
+ assertNonEmptyString(id, "Membership policy id");
510
+ assertNonEmptyArray(options.grantedTo, `Membership policy '${id}' grantedTo`);
511
+ assertNonEmptyArray(options.can, `Membership policy '${id}' can`);
512
+ return {
513
+ kind: "membershipPolicy",
514
+ id,
515
+ grantedToGroupIds: groupIdsFrom(options.grantedTo, `Membership policy '${id}' grantedTo`),
516
+ scopeGroupIds: groupIdsFrom(options.scope, `Membership policy '${id}' scope`),
517
+ can: membershipOperationsFrom(options.can, `Membership policy '${id}' can`)
518
+ };
519
+ }
520
+ // src/security/every.ts
521
+ var BREADTH_TARGETS = [
522
+ "object",
523
+ "dataset",
524
+ "action",
525
+ "workflow",
526
+ "sync",
527
+ "pipeline",
528
+ "agent",
529
+ "application"
530
+ ];
531
+ function isBreadthSelector(value) {
532
+ if (typeof value !== "object" || value === null)
533
+ return false;
534
+ const candidate = value;
535
+ return typeof candidate.target === "string" && BREADTH_TARGETS.includes(candidate.target) && candidate.selection?.all === true;
536
+ }
537
+ function definitionIdOf(item, label) {
538
+ if (typeof item?.id !== "string" || !item.id.trim()) {
539
+ throw new SecurityValidationError(`[Sixb] ${label} requires definitions with a non-empty id.`);
540
+ }
541
+ return item.id;
542
+ }
543
+ function all(target, except = []) {
544
+ return {
545
+ target,
546
+ selection: { all: true, except },
547
+ except(items) {
548
+ return all(target, [
549
+ ...except,
550
+ ...items.map((item) => definitionIdOf(item, `every.${target}() except`))
551
+ ]);
552
+ }
553
+ };
554
+ }
555
+ var every = {
556
+ object: () => all("object"),
557
+ dataset: () => all("dataset"),
558
+ action: () => all("action"),
559
+ workflow: () => all("workflow"),
560
+ sync: () => all("sync"),
561
+ pipeline: () => all("pipeline"),
562
+ agent: () => all("agent"),
563
+ application: () => all("application")
564
+ };
565
+ // src/security/grants.ts
566
+ var VIEW_TARGETS = ["object", "dataset"];
567
+ var RUN_TARGETS = ["workflow", "sync", "pipeline", "agent"];
568
+ var TARGET_BY_DEFINITION_KIND = {
569
+ dataset: "dataset",
570
+ sync: "sync",
571
+ pipeline: "pipeline",
572
+ agent: "agent",
573
+ workflow: "workflow",
574
+ application: "application"
575
+ };
576
+ var UNDISCRIMINATED_TARGETS = ["object", "action"];
577
+ function targetOfDefinition(item, label, allowedTargets) {
578
+ const kind = item?.kind;
579
+ const discriminated = typeof kind === "string" ? TARGET_BY_DEFINITION_KIND[kind] : undefined;
580
+ if (discriminated) {
581
+ if (!isAllowedTarget(discriminated, allowedTargets)) {
582
+ throw new SecurityValidationError(`[Sixb] ${label} accepts ${allowedTargets.join(" or ")} definitions, but received one targeting ${discriminated}.`);
583
+ }
584
+ return discriminated;
585
+ }
586
+ const candidates = allowedTargets.filter((target) => UNDISCRIMINATED_TARGETS.includes(target));
587
+ const only = candidates.length === 1 ? candidates[0] : undefined;
588
+ if (only)
589
+ return only;
590
+ throw new SecurityValidationError(`[Sixb] ${label} accepts ${allowedTargets.join(" or ")} definitions, but received one Sixb could not classify.`);
591
+ }
592
+ function isAllowedTarget(target, allowedTargets) {
593
+ return allowedTargets.includes(target);
594
+ }
595
+ function resolveGrant(input, label, allowedTargets) {
596
+ if (isBreadthSelector(input)) {
597
+ if (!isAllowedTarget(input.target, allowedTargets)) {
598
+ throw new SecurityValidationError(`[Sixb] ${label} accepts ${allowedTargets.join(" or ")} selectors, but received every.${input.target}().`);
599
+ }
600
+ return { target: input.target, selection: input.selection };
601
+ }
602
+ const items = Array.isArray(input) ? input : [input];
603
+ let target;
604
+ for (const item of items) {
605
+ const itemTarget = targetOfDefinition(item, label, allowedTargets);
606
+ if (target === undefined) {
607
+ target = itemTarget;
608
+ continue;
609
+ }
610
+ if (itemTarget !== target) {
611
+ throw new SecurityValidationError(`[Sixb] ${label} requires one target per grant, but received both ${target} and ${itemTarget} definitions. Use one grant each.`);
612
+ }
613
+ }
614
+ if (target === undefined) {
615
+ throw new SecurityValidationError(`[Sixb] ${label} requires at least one definition.`);
616
+ }
617
+ const ids = [...new Set(items.map((item) => definitionIdOf(item, label)))];
618
+ return { target, selection: { all: false, ids } };
619
+ }
620
+ function access(input) {
621
+ const { selection } = resolveGrant(input, "can.access", ["application"]);
622
+ return { kind: "grant", capability: "access", target: "application", selection };
623
+ }
624
+ function view(input) {
625
+ const { target, selection } = resolveGrant(input, "can.view", VIEW_TARGETS);
626
+ return { kind: "grant", capability: "view", target, selection };
627
+ }
628
+ function edit(input) {
629
+ return {
630
+ kind: "grant",
631
+ capability: "edit",
632
+ selection: resolveGrant(input, "can.edit", ["object"]).selection
633
+ };
634
+ }
635
+ function append(input) {
636
+ return {
637
+ kind: "grant",
638
+ capability: "append",
639
+ selection: resolveGrant(input, "can.append", ["object"]).selection
640
+ };
641
+ }
642
+ function apply(input) {
643
+ return {
644
+ kind: "grant",
645
+ capability: "apply",
646
+ selection: resolveGrant(input, "can.apply", ["action"]).selection
647
+ };
648
+ }
649
+ function run(input) {
650
+ const { target, selection } = resolveGrant(input, "can.run", RUN_TARGETS);
651
+ return { kind: "grant", capability: "run", target, selection };
652
+ }
653
+ function observe(target) {
654
+ return {
655
+ kind: "grant",
656
+ capability: "observe",
657
+ target,
658
+ selection: { all: false, ids: [target] }
659
+ };
660
+ }
661
+ var can = {
662
+ access,
663
+ view,
664
+ edit,
665
+ append,
666
+ apply,
667
+ run,
668
+ observe
669
+ };
670
+ // src/storage/auth/errors.ts
671
+ class AuthStorageError extends Error {
672
+ code;
673
+ name = "AuthStorageError";
674
+ constructor(code, message) {
675
+ super(message);
676
+ this.code = code;
677
+ }
678
+ }
679
+ // src/storage/auth/in-memory/shared.ts
680
+ function createAuthStorageState() {
681
+ return {
682
+ users: new Map,
683
+ identities: new Map,
684
+ serviceAccounts: new Map,
685
+ serviceAccountGroupMemberships: new Map,
686
+ sessions: new Map,
687
+ accessTokens: new Map,
688
+ invitations: new Map,
689
+ groupMemberships: new Map,
690
+ magicLinks: new Map,
691
+ oidcAuthorizationAttempts: new Map
692
+ };
693
+ }
694
+ function scopedKey(...parts) {
695
+ return JSON.stringify(parts);
696
+ }
697
+ function userKey(projectId, id) {
698
+ return scopedKey(projectId, id);
699
+ }
700
+ function identityKey(projectId, strategyId, subject) {
701
+ return scopedKey(projectId, strategyId, subject);
702
+ }
703
+ function serviceAccountKey(projectId, id) {
704
+ return scopedKey(projectId, id);
705
+ }
706
+ function serviceAccountGroupMembershipKey(projectId, serviceAccountId, groupId) {
707
+ return scopedKey(projectId, serviceAccountId, groupId);
708
+ }
709
+ function sessionKey(projectId, id) {
710
+ return scopedKey(projectId, id);
711
+ }
712
+ function accessTokenKey(projectId, id) {
713
+ return scopedKey(projectId, id);
714
+ }
715
+ function invitationKey(projectId, id) {
716
+ return scopedKey(projectId, id);
717
+ }
718
+ function groupMembershipKey(projectId, userId, groupId) {
719
+ return scopedKey(projectId, userId, groupId);
720
+ }
721
+ function magicLinkKey(projectId, id) {
722
+ return scopedKey(projectId, id);
723
+ }
724
+ function oidcAttemptKey(projectId, id) {
725
+ return scopedKey(projectId, id);
726
+ }
727
+ function cloneRecord(record) {
728
+ return structuredClone(record);
729
+ }
730
+ function cloneOptionalRecord(record) {
731
+ return record ? cloneRecord(record) : null;
732
+ }
733
+ function cloneDate(value) {
734
+ return new Date(value);
735
+ }
736
+ function dateOrNow(value) {
737
+ return value ? cloneDate(value) : new Date;
738
+ }
739
+ function assertNonEmpty2(value, label) {
740
+ const normalized = value.trim();
741
+ if (!normalized) {
742
+ throw new AuthStorageError("invalid_input", `[Sixb] ${label} must be a non-empty string.`);
743
+ }
744
+ return normalized;
745
+ }
746
+ function normalizeEmail(email) {
747
+ return assertNonEmpty2(email, "Email").toLowerCase();
748
+ }
749
+ function normalizeGroupIds(groupIds) {
750
+ return [...new Set((groupIds ?? []).map((groupId) => assertNonEmpty2(groupId, "Group id")))];
751
+ }
752
+ function normalizeOptionalGroupIds(groupIds) {
753
+ return groupIds === undefined ? undefined : normalizeGroupIds(groupIds);
754
+ }
755
+ function normalizeClaims(claims) {
756
+ return claims ? cloneRecord(claims) : undefined;
757
+ }
758
+ function compareByCreatedAt(a, b, order) {
759
+ const delta = a.createdAt.getTime() - b.createdAt.getTime();
760
+ if (delta !== 0) {
761
+ return order === "asc" ? delta : -delta;
762
+ }
763
+ return order === "asc" ? a.id.localeCompare(b.id) : b.id.localeCompare(a.id);
764
+ }
765
+ function isActiveSession(session, now) {
766
+ return !session.revokedAt && session.expiresAt > now && (!session.absoluteExpiresAt || session.absoluteExpiresAt > now);
767
+ }
768
+ function isActiveAccessToken(token, now) {
769
+ return !token.revokedAt && token.expiresAt > now;
770
+ }
771
+ function isActiveInvitation(invitation, now) {
772
+ return invitation.status === "pending" && invitation.expiresAt > now;
773
+ }
774
+ function isActiveMagicLink(link, now) {
775
+ return !link.consumedAt && !link.revokedAt && link.expiresAt > now;
776
+ }
777
+ function getUserByEmail(state, projectId, email) {
778
+ const normalizedEmail = normalizeEmail(email);
779
+ for (const user of state.users.values()) {
780
+ if (user.projectId === projectId && user.email === normalizedEmail) {
781
+ return user;
782
+ }
783
+ }
784
+ return null;
785
+ }
786
+ function getActiveInvitationByEmail(state, projectId, email, now) {
787
+ const normalizedEmail = normalizeEmail(email);
788
+ const invitations = [...state.invitations.values()].filter((invitation) => invitation.projectId === projectId).filter((invitation) => invitation.email === normalizedEmail).filter((invitation) => isActiveInvitation(invitation, now)).sort((a, b) => compareByCreatedAt(a, b, "desc"));
789
+ return invitations[0] ?? null;
790
+ }
791
+ function revokeActiveSessionsForUser(state, projectId, userId, revokedAt, audience) {
792
+ const revoked = [];
793
+ for (const [key, session] of state.sessions) {
794
+ if (session.projectId !== projectId || session.userId !== userId) {
795
+ continue;
796
+ }
797
+ if (audience !== undefined && session.audience !== audience) {
798
+ continue;
799
+ }
800
+ if (!isActiveSession(session, revokedAt)) {
801
+ continue;
802
+ }
803
+ const next = {
804
+ ...session,
805
+ revokedAt: cloneDate(revokedAt)
806
+ };
807
+ state.sessions.set(key, cloneRecord(next));
808
+ revoked.push(next);
809
+ }
810
+ return revoked;
811
+ }
812
+ function revokeActiveMagicLinksForEmail(state, projectId, email, revokedAt) {
813
+ const normalizedEmail = normalizeEmail(email);
814
+ const revoked = [];
815
+ for (const [key, link] of state.magicLinks) {
816
+ if (link.projectId !== projectId || link.email !== normalizedEmail) {
817
+ continue;
818
+ }
819
+ if (!isActiveMagicLink(link, revokedAt)) {
820
+ continue;
821
+ }
822
+ const next = {
823
+ ...link,
824
+ revokedAt: cloneDate(revokedAt)
825
+ };
826
+ state.magicLinks.set(key, cloneRecord(next));
827
+ revoked.push(next);
828
+ }
829
+ return revoked;
830
+ }
831
+ function assertSessionIdAvailable(state, projectId, sessionId) {
832
+ if (state.sessions.has(sessionKey(projectId, sessionId))) {
833
+ throw new AuthStorageError("duplicate_session", `[Sixb] Session '${sessionId}' already exists for project '${projectId}'.`);
834
+ }
835
+ }
836
+ function validateCompleteSessionInput(state, projectId, session) {
837
+ const sessionId = assertNonEmpty2(session.id, "Session id");
838
+ assertNonEmpty2(session.audience, "Session audience");
839
+ assertNonEmpty2(session.tokenHash, "Session token hash");
840
+ assertSessionIdAvailable(state, projectId, sessionId);
841
+ }
842
+ function createSessionRecord(state, input) {
843
+ const id = assertNonEmpty2(input.id, "Session id");
844
+ const projectId = assertNonEmpty2(input.projectId, "Project id");
845
+ const userId = assertNonEmpty2(input.userId, "User id");
846
+ const strategyId = assertNonEmpty2(input.strategyId, "Strategy id");
847
+ const audience = resolveAuthSessionAudience(input.audience);
848
+ const tokenHash = assertNonEmpty2(input.tokenHash, "Session token hash");
849
+ assertSessionIdAvailable(state, projectId, id);
850
+ const session = {
851
+ id,
852
+ projectId,
853
+ userId,
854
+ strategyId,
855
+ audience,
856
+ tokenHash,
857
+ createdAt: cloneDate(input.createdAt),
858
+ expiresAt: cloneDate(input.expiresAt),
859
+ absoluteExpiresAt: input.absoluteExpiresAt ? cloneDate(input.absoluteExpiresAt) : undefined,
860
+ userAgent: input.userAgent,
861
+ ipAddress: input.ipAddress
862
+ };
863
+ state.sessions.set(sessionKey(projectId, id), cloneRecord(session));
864
+ return session;
865
+ }
866
+ function createServiceAccountRecord(state, input) {
867
+ const id = assertNonEmpty2(input.id, "Service account id");
868
+ const projectId = assertNonEmpty2(input.projectId, "Project id");
869
+ const name = assertNonEmpty2(input.name, "Service account name");
870
+ const key = serviceAccountKey(projectId, id);
871
+ if (state.serviceAccounts.has(key)) {
872
+ throw new AuthStorageError("duplicate_service_account", `[Sixb] Service account '${id}' already exists for project '${projectId}'.`);
873
+ }
874
+ const createdAt = dateOrNow(input.createdAt);
875
+ const serviceAccount = {
876
+ id,
877
+ projectId,
878
+ name,
879
+ description: input.description,
880
+ status: input.status ?? "active",
881
+ createdByPrincipal: input.createdByPrincipal,
882
+ createdBySessionId: input.createdBySessionId,
883
+ createdAt,
884
+ updatedAt: input.updatedAt ? cloneDate(input.updatedAt) : cloneDate(createdAt)
885
+ };
886
+ state.serviceAccounts.set(key, cloneRecord(serviceAccount));
887
+ return serviceAccount;
888
+ }
889
+ function upsertServiceAccountGroupMembershipRecord(state, input) {
890
+ const projectId = assertNonEmpty2(input.projectId, "Project id");
891
+ const serviceAccountId = assertNonEmpty2(input.serviceAccountId, "Service account id");
892
+ const groupId = assertNonEmpty2(input.groupId, "Group id");
893
+ if (!state.serviceAccounts.has(serviceAccountKey(projectId, serviceAccountId))) {
894
+ throw new AuthStorageError("missing_service_account", `[Sixb] Service account '${serviceAccountId}' not found for project '${projectId}'.`);
895
+ }
896
+ const key = serviceAccountGroupMembershipKey(projectId, serviceAccountId, groupId);
897
+ const existing = state.serviceAccountGroupMemberships.get(key);
898
+ if (existing) {
899
+ return existing;
900
+ }
901
+ const membership = {
902
+ projectId,
903
+ serviceAccountId,
904
+ groupId,
905
+ source: input.source,
906
+ createdAt: dateOrNow(input.createdAt)
907
+ };
908
+ state.serviceAccountGroupMemberships.set(key, cloneRecord(membership));
909
+ return membership;
910
+ }
911
+ function createAccessTokenRecord(state, input) {
912
+ const id = assertNonEmpty2(input.id, "Access token id");
913
+ const projectId = assertNonEmpty2(input.projectId, "Project id");
914
+ const name = assertNonEmpty2(input.name, "Access token name");
915
+ const subjectId = assertNonEmpty2(input.subjectId, "Access token subject id");
916
+ const tokenHash = assertNonEmpty2(input.tokenHash, "Access token hash");
917
+ assertAccessTokenSubject(input.kind, input.subjectType);
918
+ assertAccessTokenSubjectExists(state, projectId, input.subjectType, subjectId);
919
+ const key = accessTokenKey(projectId, id);
920
+ if (state.accessTokens.has(key)) {
921
+ throw new AuthStorageError("duplicate_access_token", `[Sixb] Access token '${id}' already exists for project '${projectId}'.`);
922
+ }
923
+ const token = {
924
+ id,
925
+ projectId,
926
+ name,
927
+ kind: input.kind,
928
+ subjectType: input.subjectType,
929
+ subjectId,
930
+ tokenHash,
931
+ groupIds: normalizeOptionalGroupIds(input.groupIds),
932
+ createdByPrincipal: input.createdByPrincipal,
933
+ createdBySessionId: input.createdBySessionId,
934
+ createdAt: cloneDate(input.createdAt),
935
+ expiresAt: cloneDate(input.expiresAt)
936
+ };
937
+ state.accessTokens.set(key, cloneRecord(token));
938
+ return token;
939
+ }
940
+ function upsertGroupMembershipRecord(state, input) {
941
+ const projectId = assertNonEmpty2(input.projectId, "Project id");
942
+ const userId = assertNonEmpty2(input.userId, "User id");
943
+ const groupId = assertNonEmpty2(input.groupId, "Group id");
944
+ if (!state.users.has(userKey(projectId, userId))) {
945
+ throw new AuthStorageError("missing_user", `[Sixb] User '${userId}' not found for project '${projectId}'.`);
946
+ }
947
+ const key = groupMembershipKey(projectId, userId, groupId);
948
+ const existing = state.groupMemberships.get(key);
949
+ if (existing) {
950
+ return existing;
951
+ }
952
+ const membership = {
953
+ projectId,
954
+ userId,
955
+ groupId,
956
+ source: input.source,
957
+ createdAt: dateOrNow(input.createdAt)
958
+ };
959
+ state.groupMemberships.set(key, cloneRecord(membership));
960
+ return membership;
961
+ }
962
+ function removeGroupMembershipRecord(state, params) {
963
+ const projectId = assertNonEmpty2(params.projectId, "Project id");
964
+ const userId = assertNonEmpty2(params.userId, "User id");
965
+ const groupId = assertNonEmpty2(params.groupId, "Group id");
966
+ const key = groupMembershipKey(projectId, userId, groupId);
967
+ const existing = state.groupMemberships.get(key);
968
+ if (!existing) {
969
+ return null;
970
+ }
971
+ state.groupMemberships.delete(key);
972
+ return existing;
973
+ }
974
+ function assertAccessTokenSubject(kind, subjectType) {
975
+ if (kind === "personal" && subjectType === "user" || kind === "serviceAccount" && subjectType === "serviceAccount") {
976
+ return;
977
+ }
978
+ throw new AuthStorageError("invalid_input", `[Sixb] Access token kind '${kind}' cannot target subject type '${subjectType}'.`);
979
+ }
980
+ function assertAccessTokenSubjectExists(state, projectId, subjectType, subjectId) {
981
+ if (subjectType === "user") {
982
+ if (state.users.has(userKey(projectId, subjectId)))
983
+ return;
984
+ throw new AuthStorageError("missing_user", `[Sixb] User '${subjectId}' not found for project '${projectId}'.`);
985
+ }
986
+ if (state.serviceAccounts.has(serviceAccountKey(projectId, subjectId)))
987
+ return;
988
+ throw new AuthStorageError("missing_service_account", `[Sixb] Service account '${subjectId}' not found for project '${projectId}'.`);
989
+ }
990
+ function consumeMagicLinkRecord(state, params) {
991
+ const projectId = assertNonEmpty2(params.projectId, "Project id");
992
+ const id = assertNonEmpty2(params.id, "Magic link id");
993
+ const tokenHash = assertNonEmpty2(params.tokenHash, "Magic link token hash");
994
+ const key = magicLinkKey(projectId, id);
995
+ const existing = state.magicLinks.get(key);
996
+ if (!existing) {
997
+ throw new AuthStorageError("missing_magic_link", `[Sixb] Magic link '${id}' not found for project '${projectId}'.`);
998
+ }
999
+ if (existing.tokenHash !== tokenHash || existing.consumedAt || existing.revokedAt) {
1000
+ throw new AuthStorageError("invalid_magic_link", `[Sixb] Magic link '${id}' is not valid for project '${projectId}'.`);
1001
+ }
1002
+ if (existing.expiresAt <= params.consumedAt) {
1003
+ throw new AuthStorageError("expired_magic_link", `[Sixb] Magic link '${id}' is expired for project '${projectId}'.`);
1004
+ }
1005
+ const consumed = {
1006
+ ...existing,
1007
+ consumedAt: cloneDate(params.consumedAt)
1008
+ };
1009
+ state.magicLinks.set(key, cloneRecord(consumed));
1010
+ return consumed;
1011
+ }
1012
+ function consumeOidcAttemptRecord(state, params) {
1013
+ const projectId = assertNonEmpty2(params.projectId, "Project id");
1014
+ const id = assertNonEmpty2(params.id, "OIDC authorization attempt id");
1015
+ const stateHash = assertNonEmpty2(params.stateHash, "OIDC state hash");
1016
+ const key = oidcAttemptKey(projectId, id);
1017
+ const existing = state.oidcAuthorizationAttempts.get(key);
1018
+ if (!existing) {
1019
+ throw new AuthStorageError("missing_oidc_attempt", `[Sixb] OIDC authorization attempt '${id}' not found for project '${projectId}'.`);
1020
+ }
1021
+ if (existing.stateHash !== stateHash || existing.consumedAt) {
1022
+ throw new AuthStorageError("invalid_oidc_attempt", `[Sixb] OIDC authorization attempt '${id}' is not valid for project '${projectId}'.`);
1023
+ }
1024
+ if (existing.expiresAt <= params.consumedAt) {
1025
+ throw new AuthStorageError("expired_oidc_attempt", `[Sixb] OIDC authorization attempt '${id}' is expired for project '${projectId}'.`);
1026
+ }
1027
+ const consumed = {
1028
+ ...existing,
1029
+ consumedAt: cloneDate(params.consumedAt)
1030
+ };
1031
+ state.oidcAuthorizationAttempts.set(key, cloneRecord(consumed));
1032
+ return consumed;
1033
+ }
1034
+
1035
+ // src/storage/auth/in-memory/access-tokens.ts
1036
+ class InMemoryAuthAccessTokenStore {
1037
+ state;
1038
+ constructor(state) {
1039
+ this.state = state;
1040
+ }
1041
+ async create(input) {
1042
+ return cloneRecord(createAccessTokenRecord(this.state, input));
1043
+ }
1044
+ async getById(params) {
1045
+ const record = this.state.accessTokens.get(accessTokenKey(params.projectId, params.id)) ?? null;
1046
+ return cloneOptionalRecord(record);
1047
+ }
1048
+ async list(input) {
1049
+ const order = input.order ?? "asc";
1050
+ const offset = input.offset ?? 0;
1051
+ const rows = [...this.state.accessTokens.values()].filter((token) => token.projectId === input.projectId).filter((token) => input.kind === undefined || token.kind === input.kind).filter((token) => input.subjectType === undefined || token.subjectType === input.subjectType).filter((token) => input.subjectId === undefined || token.subjectId === input.subjectId).filter((token) => input.includeRevoked || !token.revokedAt).sort((a, b) => compareByCreatedAt(a, b, order));
1052
+ const page = rows.slice(offset, input.limit === undefined ? undefined : offset + input.limit);
1053
+ return {
1054
+ accessTokens: page.map(cloneRecord),
1055
+ hasMore: input.limit === undefined ? false : offset + input.limit < rows.length,
1056
+ total: rows.length
1057
+ };
1058
+ }
1059
+ async findValidByTokenHash(params) {
1060
+ const token = this.state.accessTokens.get(accessTokenKey(params.projectId, params.id));
1061
+ if (!token || token.kind !== params.kind || token.tokenHash !== params.tokenHash || !isActiveAccessToken(token, params.now)) {
1062
+ return null;
1063
+ }
1064
+ return cloneRecord(token);
1065
+ }
1066
+ async revoke(params) {
1067
+ const key = accessTokenKey(params.projectId, params.id);
1068
+ const existing = this.state.accessTokens.get(key);
1069
+ if (!existing) {
1070
+ throw new AuthStorageError("missing_access_token", `[Sixb] Access token '${params.id}' not found for project '${params.projectId}'.`);
1071
+ }
1072
+ const next = {
1073
+ ...existing,
1074
+ revokedAt: cloneDate(params.revokedAt)
1075
+ };
1076
+ this.state.accessTokens.set(key, cloneRecord(next));
1077
+ return cloneRecord(next);
1078
+ }
1079
+ async touch(params) {
1080
+ const key = accessTokenKey(params.projectId, params.id);
1081
+ const existing = this.state.accessTokens.get(key);
1082
+ if (!existing) {
1083
+ throw new AuthStorageError("missing_access_token", `[Sixb] Access token '${params.id}' not found for project '${params.projectId}'.`);
1084
+ }
1085
+ const next = {
1086
+ ...existing,
1087
+ lastUsedAt: cloneDate(params.lastUsedAt),
1088
+ lastUsedUserAgent: params.userAgent ?? existing.lastUsedUserAgent,
1089
+ lastUsedIpAddress: params.ipAddress ?? existing.lastUsedIpAddress
1090
+ };
1091
+ this.state.accessTokens.set(key, cloneRecord(next));
1092
+ return cloneRecord(next);
1093
+ }
1094
+ }
1095
+
1096
+ // src/storage/auth/in-memory/group-memberships.ts
1097
+ class InMemoryAuthGroupMembershipStore {
1098
+ state;
1099
+ constructor(state) {
1100
+ this.state = state;
1101
+ }
1102
+ async upsert(input) {
1103
+ return cloneRecord(upsertGroupMembershipRecord(this.state, input));
1104
+ }
1105
+ async remove(params) {
1106
+ const removed = removeGroupMembershipRecord(this.state, params);
1107
+ return removed ? cloneRecord(removed) : null;
1108
+ }
1109
+ async listForUser(params) {
1110
+ return [...this.state.groupMemberships.values()].filter((membership) => membership.projectId === params.projectId).filter((membership) => membership.userId === params.userId).sort((a, b) => a.groupId.localeCompare(b.groupId)).map(cloneRecord);
1111
+ }
1112
+ async listForGroup(params) {
1113
+ return [...this.state.groupMemberships.values()].filter((membership) => membership.projectId === params.projectId).filter((membership) => membership.groupId === params.groupId).sort((a, b) => a.userId.localeCompare(b.userId)).map(cloneRecord);
1114
+ }
1115
+ }
1116
+
1117
+ // src/storage/auth/in-memory/identities.ts
1118
+ class InMemoryAuthUserIdentityStore {
1119
+ state;
1120
+ constructor(state) {
1121
+ this.state = state;
1122
+ }
1123
+ async upsert(input) {
1124
+ const projectId = assertNonEmpty2(input.projectId, "Project id");
1125
+ const strategyId = assertNonEmpty2(input.strategyId, "Strategy id");
1126
+ const subject = assertNonEmpty2(input.subject, "Subject");
1127
+ const userId = assertNonEmpty2(input.userId, "User id");
1128
+ const key = identityKey(projectId, strategyId, subject);
1129
+ const existing = this.state.identities.get(key);
1130
+ const createdAt = existing?.createdAt ?? dateOrNow(input.createdAt);
1131
+ const identity = {
1132
+ projectId,
1133
+ strategyId,
1134
+ subject,
1135
+ userId,
1136
+ claims: normalizeClaims(input.claims),
1137
+ createdAt,
1138
+ updatedAt: input.updatedAt ? new Date(input.updatedAt) : existing ? new Date : createdAt
1139
+ };
1140
+ this.state.identities.set(key, cloneRecord(identity));
1141
+ return cloneRecord(identity);
1142
+ }
1143
+ async getBySubject(params) {
1144
+ const record = this.state.identities.get(identityKey(params.projectId, params.strategyId, params.subject)) ?? null;
1145
+ return cloneOptionalRecord(record);
1146
+ }
1147
+ async listForUser(params) {
1148
+ return [...this.state.identities.values()].filter((identity) => identity.projectId === params.projectId).filter((identity) => identity.userId === params.userId).sort((a, b) => {
1149
+ const delta = a.createdAt.getTime() - b.createdAt.getTime();
1150
+ if (delta !== 0)
1151
+ return delta;
1152
+ return `${a.strategyId}:${a.subject}`.localeCompare(`${b.strategyId}:${b.subject}`);
1153
+ }).map(cloneRecord);
1154
+ }
1155
+ }
1156
+
1157
+ // src/storage/pagination.ts
1158
+ function paginate(values, input) {
1159
+ const offset = input.offset ?? 0;
1160
+ const limit = input.limit ?? values.length;
1161
+ const total = values.length;
1162
+ const page = values.slice(offset, offset + limit);
1163
+ return {
1164
+ page,
1165
+ total,
1166
+ hasMore: offset + page.length < total
1167
+ };
1168
+ }
1169
+
1170
+ // src/storage/auth/in-memory/invitations.ts
1171
+ class InMemoryAuthInvitationStore {
1172
+ state;
1173
+ constructor(state) {
1174
+ this.state = state;
1175
+ }
1176
+ async createOrUpdateActive(input) {
1177
+ const id = assertNonEmpty2(input.id, "Invitation id");
1178
+ const projectId = assertNonEmpty2(input.projectId, "Project id");
1179
+ const email = normalizeEmail(input.email);
1180
+ const groupIds = normalizeGroupIds(input.groupIds);
1181
+ const now = dateOrNow(input.updatedAt ?? input.createdAt);
1182
+ const existingActive = getActiveInvitationByEmail(this.state, projectId, email, now);
1183
+ if (existingActive) {
1184
+ const next = {
1185
+ ...existingActive,
1186
+ groupIds,
1187
+ createdByPrincipal: input.createdByPrincipal,
1188
+ createdBySessionId: input.createdBySessionId,
1189
+ expiresAt: cloneDate(input.expiresAt),
1190
+ updatedAt: now
1191
+ };
1192
+ this.state.invitations.set(invitationKey(projectId, existingActive.id), cloneRecord(next));
1193
+ return cloneRecord(next);
1194
+ }
1195
+ const key = invitationKey(projectId, id);
1196
+ if (this.state.invitations.has(key)) {
1197
+ throw new AuthStorageError("duplicate_invitation", `[Sixb] Invitation '${id}' already exists but is not active for project '${projectId}'.`);
1198
+ }
1199
+ const invitation = {
1200
+ id,
1201
+ projectId,
1202
+ email,
1203
+ groupIds,
1204
+ status: "pending",
1205
+ createdByPrincipal: input.createdByPrincipal,
1206
+ createdBySessionId: input.createdBySessionId,
1207
+ createdAt: dateOrNow(input.createdAt),
1208
+ updatedAt: now,
1209
+ expiresAt: cloneDate(input.expiresAt)
1210
+ };
1211
+ this.state.invitations.set(key, cloneRecord(invitation));
1212
+ return cloneRecord(invitation);
1213
+ }
1214
+ async getById(params) {
1215
+ const record = this.state.invitations.get(invitationKey(params.projectId, params.id)) ?? null;
1216
+ return cloneOptionalRecord(record);
1217
+ }
1218
+ async getActiveByEmail(params) {
1219
+ return cloneOptionalRecord(getActiveInvitationByEmail(this.state, params.projectId, params.email, params.now));
1220
+ }
1221
+ async list(input) {
1222
+ if (input.statuses?.length === 0 || input.groupIds?.length === 0) {
1223
+ return { invitations: [], hasMore: false, total: 0 };
1224
+ }
1225
+ const statuses = input.statuses ? new Set(input.statuses) : null;
1226
+ const groupIds = input.groupIds ? new Set(input.groupIds) : null;
1227
+ const email = input.email ? normalizeEmail(input.email) : null;
1228
+ const order = input.order ?? "desc";
1229
+ const invitations = [...this.state.invitations.values()].filter((invitation) => invitation.projectId === input.projectId).filter((invitation) => email ? invitation.email === email : true).filter((invitation) => statuses ? statuses.has(invitation.status) : true).filter((invitation) => groupIds ? invitation.groupIds.some((groupId) => groupIds.has(groupId)) : true).sort((a, b) => compareByCreatedAt(a, b, order));
1230
+ const page = paginate(invitations, input);
1231
+ return {
1232
+ invitations: page.page.map(cloneRecord),
1233
+ hasMore: page.hasMore,
1234
+ total: page.total
1235
+ };
1236
+ }
1237
+ async accept(params) {
1238
+ const key = invitationKey(params.projectId, params.id);
1239
+ const existing = this.state.invitations.get(key);
1240
+ if (!existing) {
1241
+ throw new AuthStorageError("missing_invitation", `[Sixb] Invitation '${params.id}' not found for project '${params.projectId}'.`);
1242
+ }
1243
+ const next = {
1244
+ ...existing,
1245
+ status: "accepted",
1246
+ acceptedAt: cloneDate(params.acceptedAt),
1247
+ updatedAt: cloneDate(params.acceptedAt)
1248
+ };
1249
+ this.state.invitations.set(key, cloneRecord(next));
1250
+ return cloneRecord(next);
1251
+ }
1252
+ async revoke(params) {
1253
+ const key = invitationKey(params.projectId, params.id);
1254
+ const existing = this.state.invitations.get(key);
1255
+ if (!existing) {
1256
+ throw new AuthStorageError("missing_invitation", `[Sixb] Invitation '${params.id}' not found for project '${params.projectId}'.`);
1257
+ }
1258
+ const next = {
1259
+ ...existing,
1260
+ status: "revoked",
1261
+ revokedAt: cloneDate(params.revokedAt),
1262
+ updatedAt: cloneDate(params.revokedAt)
1263
+ };
1264
+ this.state.invitations.set(key, cloneRecord(next));
1265
+ return cloneRecord(next);
1266
+ }
1267
+ }
1268
+
1269
+ // src/storage/auth/in-memory/magic-links.ts
1270
+ class InMemoryAuthMagicLinkStore {
1271
+ state;
1272
+ constructor(state) {
1273
+ this.state = state;
1274
+ }
1275
+ async create(input) {
1276
+ const id = assertNonEmpty2(input.id, "Magic link id");
1277
+ const projectId = assertNonEmpty2(input.projectId, "Project id");
1278
+ const strategyId = assertNonEmpty2(input.strategyId, "Strategy id");
1279
+ const audience = resolveAuthSessionAudience(input.audience);
1280
+ const email = normalizeEmail(input.email);
1281
+ const tokenHash = assertNonEmpty2(input.tokenHash, "Magic link token hash");
1282
+ const key = magicLinkKey(projectId, id);
1283
+ if (this.state.magicLinks.has(key)) {
1284
+ throw new AuthStorageError("duplicate_magic_link", `[Sixb] Magic link '${id}' already exists for project '${projectId}'.`);
1285
+ }
1286
+ revokeActiveMagicLinksForEmail(this.state, projectId, email, input.createdAt);
1287
+ const link = {
1288
+ id,
1289
+ projectId,
1290
+ strategyId,
1291
+ audience,
1292
+ email,
1293
+ tokenHash,
1294
+ returnTo: input.returnTo,
1295
+ createdAt: cloneDate(input.createdAt),
1296
+ expiresAt: cloneDate(input.expiresAt)
1297
+ };
1298
+ this.state.magicLinks.set(key, cloneRecord(link));
1299
+ return cloneRecord(link);
1300
+ }
1301
+ async getById(params) {
1302
+ const record = this.state.magicLinks.get(magicLinkKey(params.projectId, params.id)) ?? null;
1303
+ return cloneOptionalRecord(record);
1304
+ }
1305
+ async getActiveByEmail(params) {
1306
+ const email = normalizeEmail(params.email);
1307
+ const links = [...this.state.magicLinks.values()].filter((link) => link.projectId === params.projectId).filter((link) => link.email === email).filter((link) => isActiveMagicLink(link, params.now)).sort((a, b) => compareByCreatedAt(a, b, "desc"));
1308
+ return cloneOptionalRecord(links[0] ?? null);
1309
+ }
1310
+ async consume(params) {
1311
+ return cloneRecord(consumeMagicLinkRecord(this.state, params));
1312
+ }
1313
+ async revokeActiveForEmail(params) {
1314
+ return revokeActiveMagicLinksForEmail(this.state, params.projectId, params.email, params.revokedAt).map(cloneRecord);
1315
+ }
1316
+ }
1317
+
1318
+ // src/storage/auth/in-memory/oidc-attempts.ts
1319
+ class InMemoryAuthOidcAuthorizationAttemptStore {
1320
+ state;
1321
+ constructor(state) {
1322
+ this.state = state;
1323
+ }
1324
+ async create(input) {
1325
+ const id = assertNonEmpty2(input.id, "OIDC authorization attempt id");
1326
+ const projectId = assertNonEmpty2(input.projectId, "Project id");
1327
+ const strategyId = assertNonEmpty2(input.strategyId, "Strategy id");
1328
+ const audience = resolveAuthSessionAudience(input.audience);
1329
+ const stateHash = assertNonEmpty2(input.stateHash, "OIDC state hash");
1330
+ const nonceHash = assertNonEmpty2(input.nonceHash, "OIDC nonce hash");
1331
+ const codeVerifier = assertNonEmpty2(input.codeVerifier, "OIDC code verifier");
1332
+ const key = oidcAttemptKey(projectId, id);
1333
+ if (this.state.oidcAuthorizationAttempts.has(key)) {
1334
+ throw new AuthStorageError("duplicate_oidc_attempt", `[Sixb] OIDC authorization attempt '${id}' already exists for project '${projectId}'.`);
1335
+ }
1336
+ const attempt = {
1337
+ id,
1338
+ projectId,
1339
+ strategyId,
1340
+ audience,
1341
+ stateHash,
1342
+ nonceHash,
1343
+ codeVerifier,
1344
+ returnTo: input.returnTo,
1345
+ createdAt: cloneDate(input.createdAt),
1346
+ expiresAt: cloneDate(input.expiresAt)
1347
+ };
1348
+ this.state.oidcAuthorizationAttempts.set(key, cloneRecord(attempt));
1349
+ return cloneRecord(attempt);
1350
+ }
1351
+ async getById(params) {
1352
+ const record = this.state.oidcAuthorizationAttempts.get(oidcAttemptKey(params.projectId, params.id)) ?? null;
1353
+ return cloneOptionalRecord(record);
1354
+ }
1355
+ async consume(params) {
1356
+ return cloneRecord(consumeOidcAttemptRecord(this.state, params));
1357
+ }
1358
+ }
1359
+
1360
+ // src/storage/auth/in-memory/service-account-group-memberships.ts
1361
+ class InMemoryAuthServiceAccountGroupMembershipStore {
1362
+ state;
1363
+ constructor(state) {
1364
+ this.state = state;
1365
+ }
1366
+ async upsert(input) {
1367
+ return cloneRecord(upsertServiceAccountGroupMembershipRecord(this.state, input));
1368
+ }
1369
+ async reconcileForServiceAccount(input) {
1370
+ const projectId = assertNonEmpty2(input.projectId, "Project id");
1371
+ const serviceAccountId = assertNonEmpty2(input.serviceAccountId, "Service account id");
1372
+ if (!this.state.serviceAccounts.has(serviceAccountKey(projectId, serviceAccountId))) {
1373
+ throw new AuthStorageError("missing_service_account", `[Sixb] Service account '${serviceAccountId}' not found for project '${projectId}'.`);
1374
+ }
1375
+ const groupIds = normalizeGroupIds(input.groupIds);
1376
+ const desired = new Set(groupIds);
1377
+ for (const [key, membership] of this.state.serviceAccountGroupMemberships) {
1378
+ if (membership.projectId === projectId && membership.serviceAccountId === serviceAccountId && membership.source === input.source && !desired.has(membership.groupId)) {
1379
+ this.state.serviceAccountGroupMemberships.delete(key);
1380
+ }
1381
+ }
1382
+ const updatedAt = dateOrNow(input.updatedAt);
1383
+ for (const groupId of groupIds) {
1384
+ const key = serviceAccountGroupMembershipKey(projectId, serviceAccountId, groupId);
1385
+ const existing = this.state.serviceAccountGroupMemberships.get(key);
1386
+ if (existing) {
1387
+ this.state.serviceAccountGroupMemberships.set(key, cloneRecord({ ...existing, source: input.source }));
1388
+ continue;
1389
+ }
1390
+ this.state.serviceAccountGroupMemberships.set(key, cloneRecord({
1391
+ projectId,
1392
+ serviceAccountId,
1393
+ groupId,
1394
+ source: input.source,
1395
+ createdAt: updatedAt
1396
+ }));
1397
+ }
1398
+ return this.listForServiceAccount({ projectId, serviceAccountId });
1399
+ }
1400
+ async listForServiceAccount(params) {
1401
+ return [...this.state.serviceAccountGroupMemberships.values()].filter((membership) => membership.projectId === params.projectId).filter((membership) => membership.serviceAccountId === params.serviceAccountId).sort((a, b) => a.groupId.localeCompare(b.groupId)).map(cloneRecord);
1402
+ }
1403
+ async listForGroup(params) {
1404
+ return [...this.state.serviceAccountGroupMemberships.values()].filter((membership) => membership.projectId === params.projectId).filter((membership) => membership.groupId === params.groupId).sort((a, b) => a.serviceAccountId.localeCompare(b.serviceAccountId)).map(cloneRecord);
1405
+ }
1406
+ }
1407
+
1408
+ // src/storage/auth/in-memory/service-accounts.ts
1409
+ class InMemoryAuthServiceAccountStore {
1410
+ state;
1411
+ constructor(state) {
1412
+ this.state = state;
1413
+ }
1414
+ async create(input) {
1415
+ return cloneRecord(createServiceAccountRecord(this.state, input));
1416
+ }
1417
+ async getById(params) {
1418
+ const record = this.state.serviceAccounts.get(serviceAccountKey(params.projectId, params.id)) ?? null;
1419
+ return cloneOptionalRecord(record);
1420
+ }
1421
+ async update(input) {
1422
+ const projectId = assertNonEmpty2(input.projectId, "Project id");
1423
+ const id = assertNonEmpty2(input.id, "Service account id");
1424
+ const key = serviceAccountKey(projectId, id);
1425
+ const existing = this.state.serviceAccounts.get(key);
1426
+ if (!existing) {
1427
+ throw new AuthStorageError("missing_service_account", `[Sixb] Service account '${id}' not found for project '${projectId}'.`);
1428
+ }
1429
+ const next = {
1430
+ ...existing,
1431
+ name: input.name === undefined ? existing.name : assertNonEmpty2(input.name, "Service account name"),
1432
+ description: input.description === undefined ? existing.description : input.description,
1433
+ status: input.status ?? existing.status,
1434
+ updatedAt: input.updatedAt ? cloneDate(input.updatedAt) : new Date
1435
+ };
1436
+ this.state.serviceAccounts.set(key, cloneRecord(next));
1437
+ return cloneRecord(next);
1438
+ }
1439
+ async list(input) {
1440
+ const statuses = input.statuses ? new Set(input.statuses) : null;
1441
+ const order = input.order ?? "asc";
1442
+ const offset = input.offset ?? 0;
1443
+ const rows = [...this.state.serviceAccounts.values()].filter((serviceAccount) => serviceAccount.projectId === input.projectId).filter((serviceAccount) => !statuses || statuses.has(serviceAccount.status)).sort((a, b) => compareByCreatedAt(a, b, order));
1444
+ const page = rows.slice(offset, input.limit === undefined ? undefined : offset + input.limit);
1445
+ return {
1446
+ serviceAccounts: page.map(cloneRecord),
1447
+ hasMore: input.limit === undefined ? false : offset + input.limit < rows.length,
1448
+ total: rows.length
1449
+ };
1450
+ }
1451
+ }
1452
+
1453
+ // src/storage/auth/in-memory/sessions.ts
1454
+ class InMemoryAuthSessionStore {
1455
+ state;
1456
+ constructor(state) {
1457
+ this.state = state;
1458
+ }
1459
+ async create(input) {
1460
+ return cloneRecord(createSessionRecord(this.state, input));
1461
+ }
1462
+ async getById(params) {
1463
+ const record = this.state.sessions.get(sessionKey(params.projectId, params.id)) ?? null;
1464
+ return cloneOptionalRecord(record);
1465
+ }
1466
+ async getActiveByUserId(params) {
1467
+ const sessions = [...this.state.sessions.values()].filter((session) => session.projectId === params.projectId).filter((session) => session.userId === params.userId).filter((session) => session.audience === params.audience).filter((session) => isActiveSession(session, params.now)).sort((a, b) => compareByCreatedAt(a, b, "desc"));
1468
+ return cloneOptionalRecord(sessions[0] ?? null);
1469
+ }
1470
+ async listActiveByUserId(params) {
1471
+ return [...this.state.sessions.values()].filter((session) => session.projectId === params.projectId).filter((session) => session.userId === params.userId).filter((session) => isActiveSession(session, params.now)).sort((a, b) => {
1472
+ const activity = (b.lastSeenAt ?? b.createdAt).getTime() - (a.lastSeenAt ?? a.createdAt).getTime();
1473
+ if (activity !== 0)
1474
+ return activity;
1475
+ const created = b.createdAt.getTime() - a.createdAt.getTime();
1476
+ return created !== 0 ? created : b.id.localeCompare(a.id);
1477
+ }).map(cloneRecord);
1478
+ }
1479
+ async findValidByTokenHash(params) {
1480
+ const session = this.state.sessions.get(sessionKey(params.projectId, params.id));
1481
+ if (!session || session.audience !== params.audience || session.tokenHash !== params.tokenHash || !isActiveSession(session, params.now)) {
1482
+ return null;
1483
+ }
1484
+ return cloneRecord(session);
1485
+ }
1486
+ async renewIfValid(params) {
1487
+ const key = sessionKey(params.projectId, params.id);
1488
+ const session = this.state.sessions.get(key);
1489
+ if (!session || session.audience !== params.audience || session.tokenHash !== params.tokenHash || !isActiveSession(session, params.now)) {
1490
+ return null;
1491
+ }
1492
+ const requestedExpiresAt = session.absoluteExpiresAt ? new Date(Math.min(params.expiresAt.getTime(), session.absoluteExpiresAt.getTime())) : params.expiresAt;
1493
+ const next = {
1494
+ ...session,
1495
+ expiresAt: new Date(Math.max(session.expiresAt.getTime(), requestedExpiresAt.getTime())),
1496
+ lastSeenAt: cloneDate(params.now)
1497
+ };
1498
+ this.state.sessions.set(key, cloneRecord(next));
1499
+ return cloneRecord(next);
1500
+ }
1501
+ async revoke(params) {
1502
+ const key = sessionKey(params.projectId, params.id);
1503
+ const existing = this.state.sessions.get(key);
1504
+ if (!existing) {
1505
+ throw new AuthStorageError("missing_session", `[Sixb] Session '${params.id}' not found for project '${params.projectId}'.`);
1506
+ }
1507
+ const next = {
1508
+ ...existing,
1509
+ revokedAt: cloneDate(params.revokedAt)
1510
+ };
1511
+ this.state.sessions.set(key, cloneRecord(next));
1512
+ return cloneRecord(next);
1513
+ }
1514
+ async revokeActiveForUser(params) {
1515
+ return revokeActiveSessionsForUser(this.state, params.projectId, params.userId, params.revokedAt, params.audience).map(cloneRecord);
1516
+ }
1517
+ async touch(params) {
1518
+ const key = sessionKey(params.projectId, params.id);
1519
+ const existing = this.state.sessions.get(key);
1520
+ if (!existing) {
1521
+ throw new AuthStorageError("missing_session", `[Sixb] Session '${params.id}' not found for project '${params.projectId}'.`);
1522
+ }
1523
+ const next = {
1524
+ ...existing,
1525
+ lastSeenAt: cloneDate(params.lastSeenAt)
1526
+ };
1527
+ this.state.sessions.set(key, cloneRecord(next));
1528
+ return cloneRecord(next);
1529
+ }
1530
+ }
1531
+
1532
+ // src/storage/auth/in-memory/users.ts
1533
+ class InMemoryAuthUserStore {
1534
+ state;
1535
+ constructor(state) {
1536
+ this.state = state;
1537
+ }
1538
+ async create(input) {
1539
+ const id = assertNonEmpty2(input.id, "User id");
1540
+ const projectId = assertNonEmpty2(input.projectId, "Project id");
1541
+ const email = normalizeEmail(input.email);
1542
+ const key = userKey(projectId, id);
1543
+ if (this.state.users.has(key)) {
1544
+ throw new AuthStorageError("duplicate_user", `[Sixb] User '${id}' already exists for project '${projectId}'.`);
1545
+ }
1546
+ if (getUserByEmail(this.state, projectId, email)) {
1547
+ throw new AuthStorageError("duplicate_user", `[Sixb] User email '${email}' already exists for project '${projectId}'.`);
1548
+ }
1549
+ const createdAt = dateOrNow(input.createdAt);
1550
+ const user = {
1551
+ id,
1552
+ projectId,
1553
+ email,
1554
+ displayName: input.displayName,
1555
+ avatarUrl: input.avatarUrl,
1556
+ status: input.status ?? "active",
1557
+ createdAt,
1558
+ updatedAt: input.updatedAt ? cloneDate(input.updatedAt) : cloneDate(createdAt)
1559
+ };
1560
+ this.state.users.set(key, cloneRecord(user));
1561
+ return cloneRecord(user);
1562
+ }
1563
+ async getById(params) {
1564
+ const record = this.state.users.get(userKey(params.projectId, params.id)) ?? null;
1565
+ return cloneOptionalRecord(record);
1566
+ }
1567
+ async getByEmail(params) {
1568
+ return cloneOptionalRecord(getUserByEmail(this.state, params.projectId, params.email));
1569
+ }
1570
+ async updateProfile(input) {
1571
+ const key = userKey(input.projectId, input.id);
1572
+ const existing = this.state.users.get(key);
1573
+ if (!existing) {
1574
+ throw new AuthStorageError("missing_user", `[Sixb] User '${input.id}' not found for project '${input.projectId}'.`);
1575
+ }
1576
+ const next = {
1577
+ ...existing,
1578
+ displayName: input.displayName,
1579
+ avatarUrl: input.avatarUrl,
1580
+ updatedAt: dateOrNow(input.updatedAt)
1581
+ };
1582
+ this.state.users.set(key, cloneRecord(next));
1583
+ return cloneRecord(next);
1584
+ }
1585
+ async updateStatus(input) {
1586
+ const key = userKey(input.projectId, input.id);
1587
+ const existing = this.state.users.get(key);
1588
+ if (!existing) {
1589
+ throw new AuthStorageError("missing_user", `[Sixb] User '${input.id}' not found for project '${input.projectId}'.`);
1590
+ }
1591
+ const next = {
1592
+ ...existing,
1593
+ status: input.status,
1594
+ updatedAt: dateOrNow(input.updatedAt)
1595
+ };
1596
+ this.state.users.set(key, cloneRecord(next));
1597
+ return cloneRecord(next);
1598
+ }
1599
+ async list(input) {
1600
+ if (input.statuses?.length === 0) {
1601
+ return { users: [], hasMore: false, total: 0 };
1602
+ }
1603
+ const statuses = input.statuses ? new Set(input.statuses) : null;
1604
+ const order = input.order ?? "desc";
1605
+ const rows = [...this.state.users.values()].filter((user) => user.projectId === input.projectId).filter((user) => statuses ? statuses.has(user.status) : true).sort((a, b) => compareByCreatedAt(a, b, order));
1606
+ const page = paginate(rows, input);
1607
+ return {
1608
+ users: page.page.map(cloneRecord),
1609
+ hasMore: page.hasMore,
1610
+ total: page.total
1611
+ };
1612
+ }
1613
+ }
1614
+
1615
+ // src/storage/auth/in-memory/auth-storage.ts
1616
+ class InMemoryAuthStorage {
1617
+ state = createAuthStorageState();
1618
+ users = new InMemoryAuthUserStore(this.state);
1619
+ identities = new InMemoryAuthUserIdentityStore(this.state);
1620
+ serviceAccounts = new InMemoryAuthServiceAccountStore(this.state);
1621
+ serviceAccountGroupMemberships = new InMemoryAuthServiceAccountGroupMembershipStore(this.state);
1622
+ sessions = new InMemoryAuthSessionStore(this.state);
1623
+ accessTokens = new InMemoryAuthAccessTokenStore(this.state);
1624
+ invitations = new InMemoryAuthInvitationStore(this.state);
1625
+ groupMemberships = new InMemoryAuthGroupMembershipStore(this.state);
1626
+ magicLinks = new InMemoryAuthMagicLinkStore(this.state);
1627
+ oidcAuthorizationAttempts = new InMemoryAuthOidcAuthorizationAttemptStore(this.state);
1628
+ snapshot() {
1629
+ return {
1630
+ users: structuredClone(this.state.users),
1631
+ identities: structuredClone(this.state.identities),
1632
+ serviceAccounts: structuredClone(this.state.serviceAccounts),
1633
+ serviceAccountGroupMemberships: structuredClone(this.state.serviceAccountGroupMemberships),
1634
+ sessions: structuredClone(this.state.sessions),
1635
+ accessTokens: structuredClone(this.state.accessTokens),
1636
+ invitations: structuredClone(this.state.invitations),
1637
+ groupMemberships: structuredClone(this.state.groupMemberships),
1638
+ magicLinks: structuredClone(this.state.magicLinks),
1639
+ oidcAuthorizationAttempts: structuredClone(this.state.oidcAuthorizationAttempts)
1640
+ };
1641
+ }
1642
+ restore(snapshot) {
1643
+ restoreMap(this.state.users, snapshot.users);
1644
+ restoreMap(this.state.identities, snapshot.identities);
1645
+ restoreMap(this.state.serviceAccounts, snapshot.serviceAccounts);
1646
+ restoreMap(this.state.serviceAccountGroupMemberships, snapshot.serviceAccountGroupMemberships);
1647
+ restoreMap(this.state.sessions, snapshot.sessions);
1648
+ restoreMap(this.state.accessTokens, snapshot.accessTokens);
1649
+ restoreMap(this.state.invitations, snapshot.invitations);
1650
+ restoreMap(this.state.groupMemberships, snapshot.groupMemberships);
1651
+ restoreMap(this.state.magicLinks, snapshot.magicLinks);
1652
+ restoreMap(this.state.oidcAuthorizationAttempts, snapshot.oidcAuthorizationAttempts);
1653
+ }
1654
+ async completeMagicLinkSignIn(input) {
1655
+ const projectId = assertNonEmpty2(input.projectId, "Project id");
1656
+ const completedAt = cloneDate(input.completedAt);
1657
+ const magicLink = this.state.magicLinks.get(magicLinkKey(projectId, input.magicLinkId));
1658
+ if (!magicLink) {
1659
+ throw new AuthStorageError("missing_magic_link", `[Sixb] Magic link '${input.magicLinkId}' not found for project '${projectId}'.`);
1660
+ }
1661
+ if (magicLink.tokenHash !== input.tokenHash || magicLink.consumedAt || magicLink.revokedAt) {
1662
+ throw new AuthStorageError("invalid_magic_link", `[Sixb] Magic link '${input.magicLinkId}' is not valid for project '${projectId}'.`);
1663
+ }
1664
+ if (magicLink.expiresAt <= completedAt) {
1665
+ throw new AuthStorageError("expired_magic_link", `[Sixb] Magic link '${input.magicLinkId}' is expired for project '${projectId}'.`);
1666
+ }
1667
+ const existingUser = getUserByEmail(this.state, projectId, magicLink.email);
1668
+ const activeInvitation = getActiveInvitationByEmail(this.state, projectId, magicLink.email, completedAt);
1669
+ const shouldCreateUser = !existingUser;
1670
+ const manualGroupIds = normalizeGroupIds(input.manualGroupIds);
1671
+ if (existingUser?.status === "suspended") {
1672
+ consumeMagicLinkRecord(this.state, {
1673
+ projectId,
1674
+ id: input.magicLinkId,
1675
+ tokenHash: input.tokenHash,
1676
+ consumedAt: completedAt
1677
+ });
1678
+ throw new AuthStorageError("suspended_user", `[Sixb] User '${existingUser.id}' is suspended for project '${projectId}'.`);
1679
+ }
1680
+ if (shouldCreateUser && !activeInvitation && !input.allowUserCreationWithoutInvitation) {
1681
+ consumeMagicLinkRecord(this.state, {
1682
+ projectId,
1683
+ id: input.magicLinkId,
1684
+ tokenHash: input.tokenHash,
1685
+ consumedAt: completedAt
1686
+ });
1687
+ throw new AuthStorageError("user_creation_not_allowed", `[Sixb] Magic link '${input.magicLinkId}' cannot create a user for project '${projectId}'.`);
1688
+ }
1689
+ if (shouldCreateUser && !activeInvitation && input.allowUserCreationWithoutInvitation && input.requireNoActiveUsersForUserCreation && hasActiveUsers(this.state, projectId)) {
1690
+ consumeMagicLinkRecord(this.state, {
1691
+ projectId,
1692
+ id: input.magicLinkId,
1693
+ tokenHash: input.tokenHash,
1694
+ consumedAt: completedAt
1695
+ });
1696
+ throw new AuthStorageError("user_creation_not_allowed", `[Sixb] Magic link '${input.magicLinkId}' cannot create a user for project '${projectId}'.`);
1697
+ }
1698
+ validateCompleteSessionInput(this.state, projectId, input.session);
1699
+ assertSignInSessionAudience(projectId, input.session.audience, magicLink.audience);
1700
+ let newUserId;
1701
+ if (shouldCreateUser) {
1702
+ newUserId = assertNonEmpty2(input.newUserId, "User id");
1703
+ if (this.state.users.has(userKey(projectId, newUserId))) {
1704
+ throw new AuthStorageError("duplicate_user", `[Sixb] User '${newUserId}' already exists for project '${projectId}'.`);
1705
+ }
1706
+ }
1707
+ consumeMagicLinkRecord(this.state, {
1708
+ projectId,
1709
+ id: input.magicLinkId,
1710
+ tokenHash: input.tokenHash,
1711
+ consumedAt: completedAt
1712
+ });
1713
+ let user = existingUser;
1714
+ if (!user) {
1715
+ user = {
1716
+ id: newUserId ?? assertNonEmpty2(input.newUserId, "User id"),
1717
+ projectId,
1718
+ email: magicLink.email,
1719
+ displayName: input.newUserDisplayName,
1720
+ avatarUrl: input.newUserAvatarUrl,
1721
+ status: "active",
1722
+ createdAt: completedAt,
1723
+ updatedAt: completedAt
1724
+ };
1725
+ this.state.users.set(userKey(projectId, user.id), cloneRecord(user));
1726
+ }
1727
+ const invitation = this.acceptInvitationAndApplyGroups({
1728
+ activeInvitation,
1729
+ completedAt,
1730
+ projectId,
1731
+ user
1732
+ });
1733
+ const memberships = this.applyManualGroups({
1734
+ completedAt,
1735
+ groupIds: manualGroupIds,
1736
+ projectId,
1737
+ userId: user.id,
1738
+ existing: invitation.memberships
1739
+ });
1740
+ const session = this.createSignInSession({
1741
+ projectId,
1742
+ strategyId: magicLink.strategyId,
1743
+ session: input.session,
1744
+ userId: user.id
1745
+ });
1746
+ return {
1747
+ user: cloneRecord(user),
1748
+ session: cloneRecord(session),
1749
+ invitation: invitation.invitation ? cloneRecord(invitation.invitation) : undefined,
1750
+ groupMemberships: memberships.map(cloneRecord)
1751
+ };
1752
+ }
1753
+ async completeOidcSignIn(input) {
1754
+ const projectId = assertNonEmpty2(input.projectId, "Project id");
1755
+ const completedAt = cloneDate(input.completedAt);
1756
+ const attempt = this.state.oidcAuthorizationAttempts.get(oidcAttemptKey(projectId, input.oidcAuthorizationAttemptId));
1757
+ if (!attempt) {
1758
+ throw new AuthStorageError("missing_oidc_attempt", `[Sixb] OIDC authorization attempt '${input.oidcAuthorizationAttemptId}' not found for project '${projectId}'.`);
1759
+ }
1760
+ if (attempt.stateHash !== input.stateHash || attempt.consumedAt) {
1761
+ throw new AuthStorageError("invalid_oidc_attempt", `[Sixb] OIDC authorization attempt '${input.oidcAuthorizationAttemptId}' is not valid for project '${projectId}'.`);
1762
+ }
1763
+ if (attempt.expiresAt <= completedAt) {
1764
+ throw new AuthStorageError("expired_oidc_attempt", `[Sixb] OIDC authorization attempt '${input.oidcAuthorizationAttemptId}' is expired for project '${projectId}'.`);
1765
+ }
1766
+ const subject = assertNonEmpty2(input.subject, "Subject");
1767
+ const email = normalizeEmail(input.email);
1768
+ const claims = normalizeClaims(input.claims);
1769
+ const identity = this.state.identities.get(identityKey(projectId, attempt.strategyId, subject));
1770
+ const activeInvitation = identity ? null : getActiveInvitationByEmail(this.state, projectId, email, completedAt);
1771
+ let user = identity ? this.state.users.get(userKey(projectId, identity.userId)) ?? null : getUserByEmail(this.state, projectId, email);
1772
+ const shouldCreateUser = !identity && !user;
1773
+ const manualGroupIds = normalizeGroupIds(input.manualGroupIds);
1774
+ if (identity && !user) {
1775
+ this.consumeOidcAttempt(input, completedAt, projectId);
1776
+ throw new AuthStorageError("missing_user", `[Sixb] User '${identity.userId}' not found for linked OIDC identity.`);
1777
+ }
1778
+ if (!identity && user && (!input.autoLinkByVerifiedEmail || !input.emailVerified)) {
1779
+ this.consumeOidcAttempt(input, completedAt, projectId);
1780
+ throw new AuthStorageError("email_link_not_allowed", `[Sixb] OIDC identity cannot auto-link to user '${user.id}' for project '${projectId}'.`);
1781
+ }
1782
+ if (user?.status === "suspended") {
1783
+ this.consumeOidcAttempt(input, completedAt, projectId);
1784
+ throw new AuthStorageError("suspended_user", `[Sixb] User '${user.id}' is suspended for project '${projectId}'.`);
1785
+ }
1786
+ if (shouldCreateUser && !input.emailVerified) {
1787
+ this.consumeOidcAttempt(input, completedAt, projectId);
1788
+ throw new AuthStorageError("user_creation_not_allowed", `[Sixb] OIDC authorization attempt '${input.oidcAuthorizationAttemptId}' cannot create a user for project '${projectId}'.`);
1789
+ }
1790
+ if (shouldCreateUser && !activeInvitation && !input.allowUserCreationWithoutInvitation) {
1791
+ this.consumeOidcAttempt(input, completedAt, projectId);
1792
+ throw new AuthStorageError("user_creation_not_allowed", `[Sixb] OIDC authorization attempt '${input.oidcAuthorizationAttemptId}' cannot create a user for project '${projectId}'.`);
1793
+ }
1794
+ if (shouldCreateUser && !activeInvitation && input.allowUserCreationWithoutInvitation && input.requireNoActiveUsersForUserCreation && hasActiveUsers(this.state, projectId)) {
1795
+ this.consumeOidcAttempt(input, completedAt, projectId);
1796
+ throw new AuthStorageError("user_creation_not_allowed", `[Sixb] OIDC authorization attempt '${input.oidcAuthorizationAttemptId}' cannot create a user for project '${projectId}'.`);
1797
+ }
1798
+ validateCompleteSessionInput(this.state, projectId, input.session);
1799
+ assertSignInSessionAudience(projectId, input.session.audience, attempt.audience);
1800
+ let newUserId;
1801
+ if (shouldCreateUser) {
1802
+ newUserId = assertNonEmpty2(input.newUserId, "User id");
1803
+ if (this.state.users.has(userKey(projectId, newUserId))) {
1804
+ throw new AuthStorageError("duplicate_user", `[Sixb] User '${newUserId}' already exists for project '${projectId}'.`);
1805
+ }
1806
+ }
1807
+ this.consumeOidcAttempt(input, completedAt, projectId);
1808
+ if (!user) {
1809
+ user = {
1810
+ id: newUserId ?? assertNonEmpty2(input.newUserId, "User id"),
1811
+ projectId,
1812
+ email,
1813
+ displayName: input.displayName,
1814
+ avatarUrl: input.avatarUrl,
1815
+ status: "active",
1816
+ createdAt: completedAt,
1817
+ updatedAt: completedAt
1818
+ };
1819
+ this.state.users.set(userKey(projectId, user.id), cloneRecord(user));
1820
+ }
1821
+ const invitation = this.acceptInvitationAndApplyGroups({
1822
+ activeInvitation,
1823
+ completedAt,
1824
+ projectId,
1825
+ user
1826
+ });
1827
+ const memberships = this.applyManualGroups({
1828
+ completedAt,
1829
+ groupIds: manualGroupIds,
1830
+ projectId,
1831
+ userId: user.id,
1832
+ existing: invitation.memberships
1833
+ });
1834
+ const nextIdentity = {
1835
+ projectId,
1836
+ strategyId: attempt.strategyId,
1837
+ subject,
1838
+ userId: user.id,
1839
+ claims,
1840
+ createdAt: identity?.createdAt ?? completedAt,
1841
+ updatedAt: completedAt
1842
+ };
1843
+ this.state.identities.set(identityKey(projectId, attempt.strategyId, subject), cloneRecord(nextIdentity));
1844
+ const session = this.createSignInSession({
1845
+ projectId,
1846
+ strategyId: attempt.strategyId,
1847
+ session: input.session,
1848
+ userId: user.id
1849
+ });
1850
+ return {
1851
+ user: cloneRecord(user),
1852
+ session: cloneRecord(session),
1853
+ identity: cloneRecord(nextIdentity),
1854
+ invitation: invitation.invitation ? cloneRecord(invitation.invitation) : undefined,
1855
+ groupMemberships: memberships.map(cloneRecord)
1856
+ };
1857
+ }
1858
+ async suspendUserAndRevokeSessions(input) {
1859
+ const key = userKey(input.projectId, input.userId);
1860
+ const existing = this.state.users.get(key);
1861
+ if (!existing) {
1862
+ throw new AuthStorageError("missing_user", `[Sixb] User '${input.userId}' not found for project '${input.projectId}'.`);
1863
+ }
1864
+ const next = {
1865
+ ...existing,
1866
+ status: "suspended",
1867
+ updatedAt: cloneDate(input.suspendedAt)
1868
+ };
1869
+ this.state.users.set(key, cloneRecord(next));
1870
+ revokeActiveSessionsForUser(this.state, input.projectId, input.userId, input.suspendedAt);
1871
+ return cloneRecord(next);
1872
+ }
1873
+ acceptInvitationAndApplyGroups(input) {
1874
+ if (!input.activeInvitation) {
1875
+ return { memberships: [] };
1876
+ }
1877
+ const invitation = {
1878
+ ...input.activeInvitation,
1879
+ status: "accepted",
1880
+ acceptedAt: input.completedAt,
1881
+ updatedAt: input.completedAt
1882
+ };
1883
+ this.state.invitations.set(invitationKey(input.projectId, invitation.id), cloneRecord(invitation));
1884
+ const memberships = input.activeInvitation.groupIds.map((groupId) => upsertGroupMembershipRecord(this.state, {
1885
+ projectId: input.projectId,
1886
+ userId: input.user.id,
1887
+ groupId,
1888
+ source: "invitation",
1889
+ createdAt: input.completedAt
1890
+ }));
1891
+ return { invitation, memberships };
1892
+ }
1893
+ applyManualGroups(input) {
1894
+ const memberships = [...input.existing];
1895
+ for (const groupId of input.groupIds) {
1896
+ memberships.push(upsertGroupMembershipRecord(this.state, {
1897
+ projectId: input.projectId,
1898
+ userId: input.userId,
1899
+ groupId,
1900
+ source: "manual",
1901
+ createdAt: input.completedAt
1902
+ }));
1903
+ }
1904
+ return memberships;
1905
+ }
1906
+ createSignInSession(input) {
1907
+ return createSessionRecord(this.state, {
1908
+ id: input.session.id,
1909
+ projectId: input.projectId,
1910
+ userId: input.userId,
1911
+ strategyId: input.strategyId,
1912
+ audience: input.session.audience,
1913
+ tokenHash: input.session.tokenHash,
1914
+ createdAt: input.session.createdAt,
1915
+ expiresAt: input.session.expiresAt,
1916
+ absoluteExpiresAt: input.session.absoluteExpiresAt,
1917
+ userAgent: input.session.userAgent,
1918
+ ipAddress: input.session.ipAddress
1919
+ });
1920
+ }
1921
+ consumeOidcAttempt(input, completedAt, projectId) {
1922
+ consumeOidcAttemptRecord(this.state, {
1923
+ projectId,
1924
+ id: input.oidcAuthorizationAttemptId,
1925
+ stateHash: input.stateHash,
1926
+ consumedAt: completedAt
1927
+ });
1928
+ }
1929
+ }
1930
+ function restoreMap(target, snapshot) {
1931
+ target.clear();
1932
+ for (const [key, value] of structuredClone(snapshot)) {
1933
+ target.set(key, value);
1934
+ }
1935
+ }
1936
+ function hasActiveUsers(state, projectId) {
1937
+ for (const user of state.users.values()) {
1938
+ if (user.projectId === projectId && user.status === "active") {
1939
+ return true;
1940
+ }
1941
+ }
1942
+ return false;
1943
+ }
1944
+ function assertSignInSessionAudience(projectId, sessionAudience, storedAudience) {
1945
+ if (sessionAudience === storedAudience) {
1946
+ return;
1947
+ }
1948
+ throw new AuthStorageError("invalid_input", `[Sixb] Sign-in session audience '${sessionAudience}' does not match stored auth audience '${storedAudience}' for project '${projectId}'.`);
1949
+ }
1950
+ // src/auth/session-cache.ts
1951
+ class SessionCache {
1952
+ ttlMs;
1953
+ maxEntries;
1954
+ entries = new Map;
1955
+ constructor(ttlMs, maxEntries = 4096) {
1956
+ this.ttlMs = ttlMs;
1957
+ this.maxEntries = maxEntries;
1958
+ }
1959
+ get(input) {
1960
+ const entry = this.entries.get(input.sessionId);
1961
+ if (!entry) {
1962
+ return;
1963
+ }
1964
+ if (entry.expiresAtMs <= input.nowMs || entry.tokenHash !== input.tokenHash || entry.audience !== input.audience) {
1965
+ this.entries.delete(input.sessionId);
1966
+ return;
1967
+ }
1968
+ return entry.session;
1969
+ }
1970
+ set(input) {
1971
+ const expiresAtMs = Math.min(input.nowMs + this.ttlMs, input.sessionExpiresAtMs, input.sessionAbsoluteExpiresAtMs ?? Number.POSITIVE_INFINITY);
1972
+ if (expiresAtMs <= input.nowMs) {
1973
+ return;
1974
+ }
1975
+ this.entries.delete(input.sessionId);
1976
+ this.entries.set(input.sessionId, {
1977
+ tokenHash: input.tokenHash,
1978
+ audience: input.audience,
1979
+ session: input.session,
1980
+ expiresAtMs
1981
+ });
1982
+ if (this.entries.size > this.maxEntries) {
1983
+ const oldest = this.entries.keys().next().value;
1984
+ if (oldest !== undefined) {
1985
+ this.entries.delete(oldest);
1986
+ }
1987
+ }
1988
+ }
1989
+ invalidate(sessionId) {
1990
+ this.entries.delete(sessionId);
1991
+ }
1992
+ invalidateUser(userId) {
1993
+ for (const [sessionId, entry] of this.entries) {
1994
+ if (entry.session.user.id === userId) {
1995
+ this.entries.delete(sessionId);
1996
+ }
1997
+ }
1998
+ }
1999
+ clear() {
2000
+ this.entries.clear();
2001
+ }
2002
+ }
2003
+
2004
+ // src/auth/sessions.ts
2005
+ import { createHash as createHash2, randomBytes as randomBytes3, randomUUID as randomUUID2 } from "crypto";
2006
+ function generateSessionSecret() {
2007
+ return randomBytes3(32).toString("base64url");
2008
+ }
2009
+ function hashSessionSecret(secret) {
2010
+ return createHash2("sha256").update(secret).digest("hex");
2011
+ }
2012
+ function formatSessionCookieValue(sessionId, sessionSecret) {
2013
+ if (!sessionId || !sessionSecret || sessionId.includes(".") || sessionSecret.includes(".")) {
2014
+ throw new Error("[Sixb] Session cookie values must be non-empty and must not contain '.'.");
2015
+ }
2016
+ return `${sessionId}.${sessionSecret}`;
2017
+ }
2018
+ function parseSessionCookieValue(value) {
2019
+ if (!value) {
2020
+ return null;
2021
+ }
2022
+ const firstDot = value.indexOf(".");
2023
+ if (firstDot <= 0 || firstDot !== value.lastIndexOf(".") || firstDot === value.length - 1) {
2024
+ return null;
2025
+ }
2026
+ return {
2027
+ sessionId: value.slice(0, firstDot),
2028
+ sessionSecret: value.slice(firstDot + 1)
2029
+ };
2030
+ }
2031
+ function createSessionCredential(sessionId = `ses_${randomUUID2()}`) {
2032
+ const sessionSecret = generateSessionSecret();
2033
+ return {
2034
+ sessionId,
2035
+ sessionSecret,
2036
+ tokenHash: hashSessionSecret(sessionSecret),
2037
+ cookieValue: formatSessionCookieValue(sessionId, sessionSecret)
2038
+ };
2039
+ }
2040
+
2041
+ // src/auth/runtime.ts
2042
+ var SESSION_TOUCH_INTERVAL_MS = 60000;
2043
+ var ACCESS_TOKEN_TOUCH_INTERVAL_MS = 60000;
2044
+
2045
+ class AuthRuntime {
2046
+ projectId;
2047
+ storage;
2048
+ security;
2049
+ config;
2050
+ sessionCache;
2051
+ constructor(options) {
2052
+ this.projectId = options.projectId;
2053
+ this.storage = options.storage;
2054
+ this.security = options.security;
2055
+ this.config = resolveAuthConfig(options.config);
2056
+ this.sessionCache = this.config.session.cacheTtlMs > 0 ? new SessionCache(this.config.session.cacheTtlMs) : null;
2057
+ if (this.isEnabled() && !this.storage.auth) {
2058
+ throw new AuthRuntimeError("auth_storage_missing", "[Sixb] Auth is enabled but storage.auth is not configured.");
2059
+ }
2060
+ }
2061
+ isEnabled() {
2062
+ const strategy = this.config.strategy;
2063
+ return strategy !== null && strategy.kind !== "disabled" && strategy.disabled !== true;
2064
+ }
2065
+ getStrategy() {
2066
+ return this.config.strategy;
2067
+ }
2068
+ createSessionDeadlines(now) {
2069
+ const absoluteTimeoutMs = this.config.session.absoluteTimeoutMs;
2070
+ return {
2071
+ expiresAt: new Date(now.getTime() + this.config.session.idleTimeoutMs),
2072
+ ...absoluteTimeoutMs === undefined ? {} : { absoluteExpiresAt: new Date(now.getTime() + absoluteTimeoutMs) }
2073
+ };
2074
+ }
2075
+ getCookieOptions(options = {}) {
2076
+ return resolveAuthCookieOptionsForAudience(this.config.cookies, options.audience);
2077
+ }
2078
+ assertCanServeHttp(params) {
2079
+ const strategy = this.config.strategy;
2080
+ if (!strategy) {
2081
+ if (params.production) {
2082
+ throw new AuthRuntimeError("production_auth_required", "[SixbServer] Auth is required in production. Configure auth or use an explicit disabled auth strategy.");
2083
+ }
2084
+ return;
2085
+ }
2086
+ if (params.production && strategy.developmentOnly) {
2087
+ throw new AuthRuntimeError("production_auth_required", `[SixbServer] Auth strategy '${strategy.id}' is development-only and cannot be used in production.`);
2088
+ }
2089
+ if (params.production && (strategy.kind === "disabled" || strategy.disabled === true) && strategy.allowDisabledInProduction !== true) {
2090
+ throw new AuthRuntimeError("production_auth_required", "[SixbServer] Disabled auth in production requires allowDisabledInProduction: true.");
2091
+ }
2092
+ }
2093
+ async getSession(request, options = {}) {
2094
+ if (!this.isEnabled()) {
2095
+ return { authenticated: false, reason: "auth_disabled" };
2096
+ }
2097
+ const audience = resolveAuthSessionAudience(options.audience);
2098
+ const credentialSource = options.credentialSource ?? "session";
2099
+ if (credentialSource !== "session") {
2100
+ const authorizationHeader = request.headers.get("authorization");
2101
+ const tokenValue = getBearerAccessTokenValue(request);
2102
+ if (tokenValue) {
2103
+ return this.resolveAccessTokenSession(request, tokenValue);
2104
+ }
2105
+ if (authorizationHeader) {
2106
+ return { authenticated: false, reason: "invalid_access_token" };
2107
+ }
2108
+ if (credentialSource === "accessToken") {
2109
+ return { authenticated: false, reason: "missing_access_token" };
2110
+ }
2111
+ }
2112
+ return this.resolveCookieSession(request, audience, options.sessionActivity);
2113
+ }
2114
+ async resolveCookieSession(request, audience, activity) {
2115
+ const cookieOptions = this.getCookieOptions({ audience });
2116
+ const cookieValue = getCookie(request, cookieOptions.sessionCookieName);
2117
+ if (!cookieValue) {
2118
+ return { authenticated: false, reason: "missing_cookie" };
2119
+ }
2120
+ const parts = parseSessionCookieValue(cookieValue);
2121
+ if (!parts) {
2122
+ return { authenticated: false, reason: "invalid_cookie" };
2123
+ }
2124
+ const tokenHash = hashSessionSecret(parts.sessionSecret);
2125
+ const nowMs = Date.now();
2126
+ const cached = this.sessionCache?.get({
2127
+ sessionId: parts.sessionId,
2128
+ tokenHash,
2129
+ audience,
2130
+ nowMs
2131
+ });
2132
+ if (cached) {
2133
+ if (activity !== "foreground" || !this.canRenewSession(cached.session, nowMs)) {
2134
+ return cached;
2135
+ }
2136
+ this.sessionCache?.invalidate(parts.sessionId);
2137
+ }
2138
+ const storage = this.requireAuthStorage();
2139
+ const now = new Date(nowMs);
2140
+ let session = await storage.sessions.findValidByTokenHash({
2141
+ projectId: this.projectId,
2142
+ id: parts.sessionId,
2143
+ audience,
2144
+ tokenHash,
2145
+ now
2146
+ });
2147
+ if (!session) {
2148
+ return { authenticated: false, reason: "invalid_session" };
2149
+ }
2150
+ let sessionRenewed = false;
2151
+ if (activity === "foreground" && this.canRenewSession(session, nowMs)) {
2152
+ const renewed = await storage.sessions.renewIfValid({
2153
+ projectId: this.projectId,
2154
+ id: parts.sessionId,
2155
+ audience,
2156
+ tokenHash,
2157
+ now,
2158
+ expiresAt: this.getRenewedSessionExpiresAt(session, nowMs)
2159
+ });
2160
+ if (!renewed) {
2161
+ this.sessionCache?.invalidate(parts.sessionId);
2162
+ return { authenticated: false, reason: "invalid_session" };
2163
+ }
2164
+ session = renewed;
2165
+ sessionRenewed = true;
2166
+ }
2167
+ const user = await storage.users.getById({
2168
+ projectId: this.projectId,
2169
+ id: session.userId
2170
+ });
2171
+ if (!user) {
2172
+ return { authenticated: false, reason: "missing_user" };
2173
+ }
2174
+ if (user.status === "suspended") {
2175
+ return { authenticated: false, reason: "suspended_user" };
2176
+ }
2177
+ const memberships = await storage.groupMemberships.listForUser({
2178
+ projectId: this.projectId,
2179
+ userId: user.id
2180
+ });
2181
+ if (!sessionRenewed) {
2182
+ await this.touchSessionLastSeen(storage, session, now);
2183
+ }
2184
+ const result = {
2185
+ authenticated: true,
2186
+ credentialSource: "session",
2187
+ principal: { type: "user", id: user.id },
2188
+ user,
2189
+ session,
2190
+ groupIds: memberships.map((membership) => membership.groupId)
2191
+ };
2192
+ this.sessionCache?.set({
2193
+ sessionId: parts.sessionId,
2194
+ tokenHash,
2195
+ audience,
2196
+ session: result,
2197
+ nowMs,
2198
+ sessionExpiresAtMs: session.expiresAt.getTime(),
2199
+ sessionAbsoluteExpiresAtMs: session.absoluteExpiresAt?.getTime()
2200
+ });
2201
+ return sessionRenewed ? { ...result, sessionRenewed: true } : result;
2202
+ }
2203
+ canRenewSession(session, nowMs) {
2204
+ if (session.expiresAt.getTime() - nowMs > this.config.session.renewalWindowMs) {
2205
+ return false;
2206
+ }
2207
+ return this.getRenewedSessionExpiresAt(session, nowMs).getTime() > session.expiresAt.getTime();
2208
+ }
2209
+ getRenewedSessionExpiresAt(session, nowMs) {
2210
+ const idleExpiresAtMs = nowMs + this.config.session.idleTimeoutMs;
2211
+ return new Date(session.absoluteExpiresAt ? Math.min(idleExpiresAtMs, session.absoluteExpiresAt.getTime()) : idleExpiresAtMs);
2212
+ }
2213
+ async resolveAccessTokenSession(request, tokenValue) {
2214
+ const parts = parseAccessTokenValue(tokenValue);
2215
+ if (!parts) {
2216
+ return { authenticated: false, reason: "invalid_access_token" };
2217
+ }
2218
+ const storage = this.requireAuthStorage();
2219
+ const now = new Date;
2220
+ const accessToken = await storage.accessTokens.findValidByTokenHash({
2221
+ projectId: this.projectId,
2222
+ id: parts.tokenId,
2223
+ kind: parts.kind,
2224
+ tokenHash: hashAccessTokenSecret(parts.tokenSecret),
2225
+ now
2226
+ });
2227
+ if (!accessToken) {
2228
+ return { authenticated: false, reason: "invalid_access_token" };
2229
+ }
2230
+ await this.touchAccessTokenLastUsed(storage, accessToken, request, now);
2231
+ if (accessToken.subjectType === "user") {
2232
+ const user = await storage.users.getById({
2233
+ projectId: this.projectId,
2234
+ id: accessToken.subjectId
2235
+ });
2236
+ if (!user) {
2237
+ return { authenticated: false, reason: "missing_user" };
2238
+ }
2239
+ if (user.status === "suspended") {
2240
+ return { authenticated: false, reason: "suspended_user" };
2241
+ }
2242
+ const memberships2 = await storage.groupMemberships.listForUser({
2243
+ projectId: this.projectId,
2244
+ userId: user.id
2245
+ });
2246
+ return {
2247
+ authenticated: true,
2248
+ credentialSource: "accessToken",
2249
+ principal: { type: "user", id: user.id },
2250
+ user,
2251
+ accessToken,
2252
+ groupIds: constrainTokenGroupIds(memberships2.map((membership) => membership.groupId), accessToken)
2253
+ };
2254
+ }
2255
+ const serviceAccount = await storage.serviceAccounts.getById({
2256
+ projectId: this.projectId,
2257
+ id: accessToken.subjectId
2258
+ });
2259
+ if (!serviceAccount) {
2260
+ return { authenticated: false, reason: "missing_service_account" };
2261
+ }
2262
+ if (serviceAccount.status === "suspended") {
2263
+ return { authenticated: false, reason: "suspended_service_account" };
2264
+ }
2265
+ const memberships = await storage.serviceAccountGroupMemberships.listForServiceAccount({
2266
+ projectId: this.projectId,
2267
+ serviceAccountId: serviceAccount.id
2268
+ });
2269
+ return {
2270
+ authenticated: true,
2271
+ credentialSource: "accessToken",
2272
+ principal: { type: "serviceAccount", id: serviceAccount.id },
2273
+ serviceAccount,
2274
+ accessToken,
2275
+ groupIds: constrainTokenGroupIds(memberships.map((membership) => membership.groupId), accessToken)
2276
+ };
2277
+ }
2278
+ invalidateSession(sessionId) {
2279
+ this.sessionCache?.invalidate(sessionId);
2280
+ }
2281
+ async touchSessionLastSeen(storage, session, now) {
2282
+ const lastSeen = session.lastSeenAt?.getTime() ?? 0;
2283
+ if (now.getTime() - lastSeen < SESSION_TOUCH_INTERVAL_MS) {
2284
+ return;
2285
+ }
2286
+ try {
2287
+ await storage.sessions.touch({ projectId: this.projectId, id: session.id, lastSeenAt: now });
2288
+ } catch {}
2289
+ }
2290
+ async touchAccessTokenLastUsed(storage, accessToken, request, now) {
2291
+ const lastUsed = accessToken.lastUsedAt?.getTime() ?? 0;
2292
+ if (now.getTime() - lastUsed < ACCESS_TOKEN_TOUCH_INTERVAL_MS) {
2293
+ return;
2294
+ }
2295
+ try {
2296
+ await storage.accessTokens.touch({
2297
+ projectId: this.projectId,
2298
+ id: accessToken.id,
2299
+ lastUsedAt: now,
2300
+ userAgent: request.headers.get("user-agent")?.trim() || undefined,
2301
+ ipAddress: resolveRequestIpAddress(request)
2302
+ });
2303
+ } catch {}
2304
+ }
2305
+ async requirePrincipal(request, options = {}) {
2306
+ const session = await this.getSession(request, options);
2307
+ if (!session.authenticated) {
2308
+ throw new AuthRuntimeError("authentication_required", "[Sixb] Authentication is required.");
2309
+ }
2310
+ return session.principal;
2311
+ }
2312
+ async requireUser(request, options = {}) {
2313
+ const session = await this.getSession(request, { ...options, credentialSource: "session" });
2314
+ if (!session.authenticated) {
2315
+ throw new AuthRuntimeError("authentication_required", "[Sixb] Authentication is required.");
2316
+ }
2317
+ return session;
2318
+ }
2319
+ async requireUserRequest(request, options = {}) {
2320
+ const session = await this.getSession(request, { ...options, credentialSource: "any" });
2321
+ if (!session.authenticated) {
2322
+ throw new AuthRuntimeError("authentication_required", "[Sixb] Authentication is required.");
2323
+ }
2324
+ if (!isAuthenticatedUserRequestSession(session)) {
2325
+ throw new AuthRuntimeError("authorization_denied", "[Sixb] User authentication is required.");
2326
+ }
2327
+ return session;
2328
+ }
2329
+ async createSecurityContext(request, options = {}) {
2330
+ const session = await this.requireUser(request, options);
2331
+ return {
2332
+ principal: session.principal,
2333
+ sessionId: session.session.id,
2334
+ projectId: this.projectId,
2335
+ correlationId: resolveCorrelationId(request)
2336
+ };
2337
+ }
2338
+ async createAuthorizationContext(request, options = {}) {
2339
+ const session = await this.getSession(request, options);
2340
+ if (!session.authenticated) {
2341
+ throw new AuthRuntimeError("authentication_required", "[Sixb] Authentication is required.");
2342
+ }
2343
+ return this.contextFromSession(session);
2344
+ }
2345
+ contextFromSession(session) {
2346
+ return resolveAuthorizationContext({
2347
+ principal: session.principal,
2348
+ sessionId: session.credentialSource === "session" ? session.session.id : undefined,
2349
+ groupIds: session.groupIds,
2350
+ roles: this.security.listResolvedRoles()
2351
+ });
2352
+ }
2353
+ async listPersonalAccessTokens(request, options = {}) {
2354
+ const session = await this.requireUserRequest(request, options);
2355
+ const storage = this.requireAuthStorage();
2356
+ const result = await storage.accessTokens.list({
2357
+ projectId: this.projectId,
2358
+ kind: "personal",
2359
+ subjectType: "user",
2360
+ subjectId: session.user.id,
2361
+ includeRevoked: true,
2362
+ order: "desc",
2363
+ limit: 100
2364
+ });
2365
+ return { accessTokens: result.accessTokens };
2366
+ }
2367
+ async createPersonalAccessToken(request, input, options = {}) {
2368
+ const session = await this.requireUserRequest(request, options);
2369
+ const storage = this.requireAuthStorage();
2370
+ const groupIds = constrainRequestedGroupIds(input.groupIds, session.groupIds, {
2371
+ subject: "personal access token"
2372
+ });
2373
+ const credential = createAccessTokenCredential("personal");
2374
+ const accessToken = await storage.accessTokens.create({
2375
+ id: credential.tokenId,
2376
+ projectId: this.projectId,
2377
+ name: input.name,
2378
+ kind: "personal",
2379
+ subjectType: "user",
2380
+ subjectId: session.user.id,
2381
+ tokenHash: credential.tokenHash,
2382
+ groupIds,
2383
+ createdByPrincipal: session.principal,
2384
+ createdBySessionId: session.credentialSource === "session" ? session.session.id : undefined,
2385
+ createdAt: new Date,
2386
+ expiresAt: input.expiresAt
2387
+ });
2388
+ return { accessToken, tokenValue: credential.tokenValue };
2389
+ }
2390
+ async revokePersonalAccessToken(request, input, options = {}) {
2391
+ const session = await this.requireUserRequest(request, options);
2392
+ const storage = this.requireAuthStorage();
2393
+ const token = await storage.accessTokens.getById({
2394
+ projectId: this.projectId,
2395
+ id: input.tokenId
2396
+ });
2397
+ if (!token || token.kind !== "personal" || token.subjectType !== "user" || token.subjectId !== session.user.id) {
2398
+ throw missingAccessTokenError(input.tokenId, this.projectId);
2399
+ }
2400
+ const accessToken = await storage.accessTokens.revoke({
2401
+ projectId: this.projectId,
2402
+ id: input.tokenId,
2403
+ revokedAt: new Date
2404
+ });
2405
+ return { accessToken };
2406
+ }
2407
+ async listServiceAccounts(request, options = {}) {
2408
+ const session = await this.requireUserRequest(request, options);
2409
+ const storage = this.requireAuthStorage();
2410
+ const result = await storage.serviceAccounts.list({
2411
+ projectId: this.projectId,
2412
+ order: "desc",
2413
+ limit: 100
2414
+ });
2415
+ const withGroups = await Promise.all(result.serviceAccounts.map(async (serviceAccount) => ({
2416
+ serviceAccount,
2417
+ groupIds: await this.listServiceAccountGroupIds(storage, serviceAccount.id)
2418
+ })));
2419
+ return {
2420
+ serviceAccounts: withGroups.filter(({ groupIds }) => callerCanManageServiceAccount(session.groupIds, groupIds))
2421
+ };
2422
+ }
2423
+ async createServiceAccount(request, input, options = {}) {
2424
+ const session = await this.requireUserRequest(request, options);
2425
+ const storage = this.requireAuthStorage();
2426
+ const groupIds = constrainRequestedGroupIds(input.groupIds, session.groupIds, {
2427
+ subject: "service account"
2428
+ }) ?? [];
2429
+ const now = new Date;
2430
+ const serviceAccount = await storage.serviceAccounts.create({
2431
+ id: input.id ?? `svc_${randomUUID3()}`,
2432
+ projectId: this.projectId,
2433
+ name: input.name,
2434
+ description: input.description,
2435
+ createdByPrincipal: session.principal,
2436
+ createdBySessionId: session.credentialSource === "session" ? session.session.id : undefined,
2437
+ createdAt: now,
2438
+ updatedAt: now
2439
+ });
2440
+ const groupMemberships = [];
2441
+ for (const groupId of groupIds) {
2442
+ groupMemberships.push(await storage.serviceAccountGroupMemberships.upsert({
2443
+ projectId: this.projectId,
2444
+ serviceAccountId: serviceAccount.id,
2445
+ groupId,
2446
+ source: "manual",
2447
+ createdAt: now
2448
+ }));
2449
+ }
2450
+ return { serviceAccount, groupMemberships };
2451
+ }
2452
+ async disableServiceAccount(request, input, options = {}) {
2453
+ const session = await this.requireUserRequest(request, options);
2454
+ const storage = this.requireAuthStorage();
2455
+ const { serviceAccount, groupIds } = await this.requireManageableServiceAccount(storage, session.groupIds, input.serviceAccountId);
2456
+ const updated = await storage.serviceAccounts.update({
2457
+ projectId: this.projectId,
2458
+ id: serviceAccount.id,
2459
+ status: "suspended",
2460
+ updatedAt: new Date
2461
+ });
2462
+ return { serviceAccount: updated, groupIds };
2463
+ }
2464
+ async listServiceAccountAccessTokens(request, input, options = {}) {
2465
+ const session = await this.requireUserRequest(request, options);
2466
+ const storage = this.requireAuthStorage();
2467
+ const { serviceAccount } = await this.requireManageableServiceAccount(storage, session.groupIds, input.serviceAccountId);
2468
+ const result = await storage.accessTokens.list({
2469
+ projectId: this.projectId,
2470
+ kind: "serviceAccount",
2471
+ subjectType: "serviceAccount",
2472
+ subjectId: serviceAccount.id,
2473
+ includeRevoked: true,
2474
+ order: "desc",
2475
+ limit: 100
2476
+ });
2477
+ return { serviceAccount, accessTokens: result.accessTokens };
2478
+ }
2479
+ async createServiceAccountAccessToken(request, input, options = {}) {
2480
+ const session = await this.requireUserRequest(request, options);
2481
+ const storage = this.requireAuthStorage();
2482
+ const { serviceAccount, groupIds: serviceAccountGroupIds } = await this.requireManageableServiceAccount(storage, session.groupIds, input.serviceAccountId);
2483
+ if (serviceAccount.status === "suspended") {
2484
+ throw new AuthStorageError("suspended_service_account", `[Sixb] Service account '${input.serviceAccountId}' is suspended for project '${this.projectId}'.`);
2485
+ }
2486
+ const groupIds = constrainRequestedGroupIds(input.groupIds, serviceAccountGroupIds, {
2487
+ subject: "service account token"
2488
+ });
2489
+ const credential = createAccessTokenCredential("serviceAccount");
2490
+ const accessToken = await storage.accessTokens.create({
2491
+ id: credential.tokenId,
2492
+ projectId: this.projectId,
2493
+ name: input.name,
2494
+ kind: "serviceAccount",
2495
+ subjectType: "serviceAccount",
2496
+ subjectId: serviceAccount.id,
2497
+ tokenHash: credential.tokenHash,
2498
+ groupIds,
2499
+ createdByPrincipal: session.principal,
2500
+ createdBySessionId: session.credentialSource === "session" ? session.session.id : undefined,
2501
+ createdAt: new Date,
2502
+ expiresAt: input.expiresAt
2503
+ });
2504
+ return { accessToken, tokenValue: credential.tokenValue, serviceAccount };
2505
+ }
2506
+ async revokeServiceAccountAccessToken(request, input, options = {}) {
2507
+ const session = await this.requireUserRequest(request, options);
2508
+ const storage = this.requireAuthStorage();
2509
+ const { serviceAccount } = await this.requireManageableServiceAccount(storage, session.groupIds, input.serviceAccountId);
2510
+ const token = await storage.accessTokens.getById({
2511
+ projectId: this.projectId,
2512
+ id: input.tokenId
2513
+ });
2514
+ if (!token || token.kind !== "serviceAccount" || token.subjectType !== "serviceAccount" || token.subjectId !== serviceAccount.id) {
2515
+ throw missingAccessTokenError(input.tokenId, this.projectId);
2516
+ }
2517
+ const accessToken = await storage.accessTokens.revoke({
2518
+ projectId: this.projectId,
2519
+ id: input.tokenId,
2520
+ revokedAt: new Date
2521
+ });
2522
+ return { serviceAccount, accessToken };
2523
+ }
2524
+ async requireManageableServiceAccount(storage, callerGroupIds, serviceAccountId) {
2525
+ const serviceAccount = await storage.serviceAccounts.getById({
2526
+ projectId: this.projectId,
2527
+ id: serviceAccountId
2528
+ });
2529
+ const groupIds = serviceAccount ? await this.listServiceAccountGroupIds(storage, serviceAccountId) : [];
2530
+ if (!serviceAccount || !callerCanManageServiceAccount(callerGroupIds, groupIds)) {
2531
+ throw new AuthStorageError("missing_service_account", `[Sixb] Service account '${serviceAccountId}' not found for project '${this.projectId}'.`);
2532
+ }
2533
+ return { serviceAccount, groupIds };
2534
+ }
2535
+ async listServiceAccountGroupIds(storage, serviceAccountId) {
2536
+ const memberships = await storage.serviceAccountGroupMemberships.listForServiceAccount({
2537
+ projectId: this.projectId,
2538
+ serviceAccountId
2539
+ });
2540
+ return memberships.map((membership) => membership.groupId);
2541
+ }
2542
+ async getInvitationOptions(request, options = {}) {
2543
+ const session = await this.requireUser(request, options);
2544
+ const scope = this.resolveMembershipPolicyScopeForUser(session.groupIds);
2545
+ const inviteScope = scope.operations.invite;
2546
+ const groups = this.scopedGroupOptions(inviteScope.groupIds);
2547
+ const hasInviteMembershipPolicy = inviteScope.policyIds.length > 0;
2548
+ return {
2549
+ groups,
2550
+ canInviteWithoutGroups: hasInviteMembershipPolicy,
2551
+ capabilities: {
2552
+ createInvitation: this.resolveCreateInvitationCapability({
2553
+ canInvite: hasInviteMembershipPolicy
2554
+ })
2555
+ }
2556
+ };
2557
+ }
2558
+ getMembershipCapabilities(input) {
2559
+ return membershipCapabilities(this.resolveMembershipPolicyScopeForUser(groupIdsOf(input.callerGroups)));
2560
+ }
2561
+ async getMembershipOptions(request, options = {}) {
2562
+ const session = await this.requireUser(request, options);
2563
+ const scope = this.resolveMembershipPolicyScopeForUser(session.groupIds);
2564
+ return {
2565
+ groups: this.scopedGroupOptions(scope.operations.assignGroups.groupIds),
2566
+ capabilities: membershipCapabilities(scope).holds
2567
+ };
2568
+ }
2569
+ async listMembers(request, input = {}, options = {}) {
2570
+ const session = await this.requireUser(request, options);
2571
+ const storage = this.requireAuthStorage();
2572
+ const scope = this.resolveMembershipPolicyScopeForUser(session.groupIds);
2573
+ const { limit, offset } = normalizePagination(input);
2574
+ const result = await storage.users.list({ projectId: this.projectId, order: input.order });
2575
+ const members = [];
2576
+ for (const user of result.users) {
2577
+ const groupIds = (await storage.groupMemberships.listForUser({ projectId: this.projectId, userId: user.id })).map((membership) => membership.groupId);
2578
+ const canAssignGroups = canPerformMembershipOperation(scope, "assignGroups", groupIds);
2579
+ const canSuspendScope = canPerformMembershipOperation(scope, "suspend", groupIds);
2580
+ if (!canAssignGroups && !canSuspendScope) {
2581
+ continue;
2582
+ }
2583
+ const isSelf = user.id === session.user.id;
2584
+ members.push({
2585
+ user,
2586
+ groupIds,
2587
+ capabilities: {
2588
+ assignGroups: canAssignGroups,
2589
+ suspend: canSuspendScope && !isSelf && user.status === "active",
2590
+ reactivate: canSuspendScope && user.status === "suspended"
2591
+ }
2592
+ });
2593
+ }
2594
+ const page = paginate(members, { limit, offset });
2595
+ return { members: page.page, hasMore: page.hasMore, total: page.total };
2596
+ }
2597
+ async updateMemberGroups(request, input, options = {}) {
2598
+ const session = await this.requireUser(request, options);
2599
+ const storage = this.requireAuthStorage();
2600
+ const scope = this.resolveMembershipPolicyScopeForUser(session.groupIds);
2601
+ const userId = assertNonEmpty(input.userId, "User id");
2602
+ const { user, groupIds: currentGroupIds } = await this.requireManageableMember(storage, scope, "assignGroups", userId);
2603
+ const requestedGroupIds = this.resolveMemberGroupIds(input.groupIds);
2604
+ const missing = missingMembershipGroupIds(scope, "assignGroups", requestedGroupIds);
2605
+ if (missing.length > 0) {
2606
+ throw new AuthRuntimeError("authorization_denied", `[Sixb] The current user is not allowed to assign group(s): ${missing.join(", ")}.`);
2607
+ }
2608
+ const current = new Set(currentGroupIds);
2609
+ const requested = new Set(requestedGroupIds);
2610
+ const additions = requestedGroupIds.filter((groupId) => !current.has(groupId));
2611
+ const removals = currentGroupIds.filter((groupId) => !requested.has(groupId));
2612
+ if (user.id === session.user.id && removals.length > 0) {
2613
+ throw new AuthRuntimeError("authorization_denied", "[Sixb] The current user cannot remove their own groups.");
2614
+ }
2615
+ const now = new Date;
2616
+ for (const groupId of additions) {
2617
+ await storage.groupMemberships.upsert({
2618
+ projectId: this.projectId,
2619
+ userId: user.id,
2620
+ groupId,
2621
+ source: "manual",
2622
+ createdAt: now
2623
+ });
2624
+ }
2625
+ for (const groupId of removals) {
2626
+ await storage.groupMemberships.remove({
2627
+ projectId: this.projectId,
2628
+ userId: user.id,
2629
+ groupId
2630
+ });
2631
+ }
2632
+ this.invalidateUserSessions(user.id);
2633
+ const groupIds = (await storage.groupMemberships.listForUser({ projectId: this.projectId, userId: user.id })).map((membership) => membership.groupId);
2634
+ return { user, groupIds };
2635
+ }
2636
+ async suspendMember(request, input, options = {}) {
2637
+ const session = await this.requireUser(request, options);
2638
+ const storage = this.requireAuthStorage();
2639
+ const scope = this.resolveMembershipPolicyScopeForUser(session.groupIds);
2640
+ const userId = assertNonEmpty(input.userId, "User id");
2641
+ const { user, groupIds } = await this.requireManageableMember(storage, scope, "suspend", userId);
2642
+ if (user.id === session.user.id) {
2643
+ throw new AuthRuntimeError("authorization_denied", "[Sixb] The current user cannot suspend themselves.");
2644
+ }
2645
+ const suspended = await storage.suspendUserAndRevokeSessions({
2646
+ projectId: this.projectId,
2647
+ userId: user.id,
2648
+ suspendedAt: new Date
2649
+ });
2650
+ this.invalidateUserSessions(user.id);
2651
+ return { user: suspended, groupIds };
2652
+ }
2653
+ async reactivateMember(request, input, options = {}) {
2654
+ const session = await this.requireUser(request, options);
2655
+ const storage = this.requireAuthStorage();
2656
+ const scope = this.resolveMembershipPolicyScopeForUser(session.groupIds);
2657
+ const userId = assertNonEmpty(input.userId, "User id");
2658
+ const { user, groupIds } = await this.requireManageableMember(storage, scope, "suspend", userId);
2659
+ const reactivated = await storage.users.updateStatus({
2660
+ projectId: this.projectId,
2661
+ id: user.id,
2662
+ status: "active",
2663
+ updatedAt: new Date
2664
+ });
2665
+ return { user: reactivated, groupIds };
2666
+ }
2667
+ invalidateUserSessions(userId) {
2668
+ this.sessionCache?.invalidateUser(userId);
2669
+ }
2670
+ scopedGroupOptions(groupIds) {
2671
+ return this.security.listGroups().filter((group) => groupIds.has(group.id)).map((group) => ({
2672
+ id: group.id,
2673
+ ...group.label !== undefined ? { label: group.label } : {},
2674
+ ...group.description !== undefined ? { description: group.description } : {}
2675
+ }));
2676
+ }
2677
+ async requireManageableMember(storage, scope, operation, userId) {
2678
+ const user = await storage.users.getById({ projectId: this.projectId, id: userId });
2679
+ const groupIds = user ? (await storage.groupMemberships.listForUser({ projectId: this.projectId, userId })).map((membership) => membership.groupId) : [];
2680
+ if (!user || !canPerformMembershipOperation(scope, operation, groupIds)) {
2681
+ throw new AuthStorageError("missing_user", `[Sixb] User '${userId}' not found for project '${this.projectId}'.`);
2682
+ }
2683
+ return { user, groupIds };
2684
+ }
2685
+ resolveMemberGroupIds(input) {
2686
+ const groupIds = [...new Set(input.map((groupId) => assertNonEmpty(groupId, "Group id")))];
2687
+ for (const groupId of groupIds) {
2688
+ if (!this.security.getGroupById(groupId)) {
2689
+ throw new AuthRuntimeError("invalid_auth_input", `[Sixb] Unknown group '${groupId}'. Add it to 'security/groups/' or pass it to createSixb({ groups }).`);
2690
+ }
2691
+ }
2692
+ return groupIds;
2693
+ }
2694
+ async invite(request, input, options = {}) {
2695
+ const session = await this.requireUser(request, options);
2696
+ const authStorage = this.requireAuthStorage();
2697
+ const now = new Date;
2698
+ const groupIds = this.resolveInviteGroupIds(input);
2699
+ this.assertCanManageInvitationGroups(session.groupIds, groupIds);
2700
+ const strategy = this.getStrategy();
2701
+ if (!isInvitationDeliveryAuthStrategy(strategy)) {
2702
+ throw new AuthRuntimeError("invalid_auth_config", "[Sixb] The active auth strategy does not support invitations.");
2703
+ }
2704
+ await this.assertCanInviteRecipient(strategy, authStorage, input.email, now);
2705
+ const deliveryAudience = resolveAuthSessionAudience(options.delivery?.audience ?? options.audience);
2706
+ this.assertInvitationApplicationAccess(groupIds, deliveryAudience);
2707
+ const invitation = await authStorage.invitations.createOrUpdateActive({
2708
+ id: `inv_${randomUUID3()}`,
2709
+ projectId: this.projectId,
2710
+ email: input.email,
2711
+ groupIds,
2712
+ createdByPrincipal: session.principal,
2713
+ createdBySessionId: session.session.id,
2714
+ createdAt: now,
2715
+ updatedAt: now,
2716
+ expiresAt: resolveInvitationExpiresAt(input.expiresAt, now)
2717
+ });
2718
+ let delivery;
2719
+ try {
2720
+ delivery = await strategy.deliverInvitation({
2721
+ projectId: this.projectId,
2722
+ authStorage,
2723
+ invitation,
2724
+ audience: deliveryAudience,
2725
+ returnTo: options.delivery?.returnTo ?? sanitizeReturnTo(input.returnTo),
2726
+ requestOrigin: options.delivery?.requestOrigin ?? new URL(request.url).origin,
2727
+ now
2728
+ });
2729
+ } catch (error) {
2730
+ await this.revokeInvitationAfterDeliveryFailure(authStorage, invitation, now);
2731
+ throw error;
2732
+ }
2733
+ if (delivery.status === "not_supported") {
2734
+ return { invitation, delivery };
2735
+ }
2736
+ if (delivery.status !== "sent") {
2737
+ await this.revokeInvitationAfterDeliveryFailure(authStorage, invitation, now);
2738
+ throw this.createInvitationDeliveryError(delivery.status);
2739
+ }
2740
+ return { invitation, delivery };
2741
+ }
2742
+ async listInvitations(request, input = {}, options = {}) {
2743
+ const session = await this.requireUser(request, options);
2744
+ const authStorage = this.requireAuthStorage();
2745
+ const { limit, offset } = normalizePagination(input);
2746
+ const result = await authStorage.invitations.list({
2747
+ projectId: this.projectId,
2748
+ email: input.email,
2749
+ statuses: input.statuses,
2750
+ order: input.order
2751
+ });
2752
+ const scope = this.resolveMembershipPolicyScopeForUser(session.groupIds);
2753
+ const manageable = result.invitations.filter((invitation) => canPerformMembershipOperation(scope, "invite", invitation.groupIds));
2754
+ const page = paginate(manageable, { limit, offset });
2755
+ return {
2756
+ invitations: page.page,
2757
+ hasMore: page.hasMore,
2758
+ total: page.total
2759
+ };
2760
+ }
2761
+ async revokeInvitation(request, input, options = {}) {
2762
+ const session = await this.requireUser(request, options);
2763
+ const authStorage = this.requireAuthStorage();
2764
+ const invitationId = assertNonEmpty(input.invitationId, "Invitation id");
2765
+ const invitation = await authStorage.invitations.getById({
2766
+ projectId: this.projectId,
2767
+ id: invitationId
2768
+ });
2769
+ if (!invitation) {
2770
+ throw new AuthStorageError("missing_invitation", `[Sixb] Invitation '${invitationId}' not found for project '${this.projectId}'.`);
2771
+ }
2772
+ this.assertCanManageInvitationGroups(session.groupIds, invitation.groupIds);
2773
+ if (invitation.status !== "pending") {
2774
+ throw new AuthRuntimeError("invalid_auth_input", `[Sixb] Invitation '${invitationId}' is already ${invitation.status} and cannot be revoked.`);
2775
+ }
2776
+ return {
2777
+ invitation: await authStorage.invitations.revoke({
2778
+ projectId: this.projectId,
2779
+ id: invitation.id,
2780
+ revokedAt: new Date
2781
+ })
2782
+ };
2783
+ }
2784
+ requireAuthStorage() {
2785
+ if (!this.storage.auth) {
2786
+ throw new AuthRuntimeError("auth_storage_missing", "[Sixb] Auth is enabled but storage.auth is not configured.");
2787
+ }
2788
+ return this.storage.auth;
2789
+ }
2790
+ resolveInviteGroupIds(input) {
2791
+ if (input.groups && input.groupIds) {
2792
+ throw new AuthRuntimeError("invalid_auth_input", "[Sixb] Invitation input cannot provide both groups and groupIds.");
2793
+ }
2794
+ const rawGroupIds = input.groupIds ?? input.groups?.map((group) => assertNonEmpty(group.id, "Group id")) ?? [];
2795
+ const groupIds = [...new Set(rawGroupIds.map((groupId) => assertNonEmpty(groupId, "Group id")))];
2796
+ for (const groupId of groupIds) {
2797
+ if (!this.security.getGroupById(groupId)) {
2798
+ throw new AuthRuntimeError("invalid_auth_input", `[Sixb] Unknown invitation group '${groupId}'. Add it to 'security/groups/' or pass it to createSixb({ groups }).`);
2799
+ }
2800
+ }
2801
+ return groupIds;
2802
+ }
2803
+ resolveMembershipPolicyScopeForUser(callerGroupIds) {
2804
+ return resolveMembershipPolicyScope({
2805
+ membershipPolicies: this.security.listMembershipPolicies(),
2806
+ callerGroupIds
2807
+ });
2808
+ }
2809
+ resolveCreateInvitationCapability(input) {
2810
+ if (!isInvitationDeliveryAuthStrategy(this.getStrategy())) {
2811
+ return { state: "disabled", reason: "invitation_delivery_not_supported" };
2812
+ }
2813
+ if (!input.canInvite) {
2814
+ return { state: "disabled", reason: "missing_membership_policy" };
2815
+ }
2816
+ return { state: "enabled" };
2817
+ }
2818
+ assertInvitationApplicationAccess(groupIds, audience) {
2819
+ const roles = this.security.listResolvedRoles();
2820
+ const authorization = resolveAuthorizationContext({
2821
+ principal: { type: "user", id: "invited-user" },
2822
+ groupIds,
2823
+ roles
2824
+ });
2825
+ if (canAccessApplication(authorization, roles, audience))
2826
+ return;
2827
+ throw new AuthRuntimeError("authorization_denied", `[Sixb] Invitation groups do not grant access to application '${audience}'.`);
2828
+ }
2829
+ async assertCanInviteRecipient(strategy, authStorage, email, now) {
2830
+ if (!strategy.validateInvitationRecipient) {
2831
+ return;
2832
+ }
2833
+ const result = await strategy.validateInvitationRecipient({
2834
+ projectId: this.projectId,
2835
+ authStorage,
2836
+ email,
2837
+ now
2838
+ });
2839
+ if (result.status === "allowed") {
2840
+ return;
2841
+ }
2842
+ throw createInvitationRecipientError(result.status, result.email ?? email);
2843
+ }
2844
+ async revokeInvitationAfterDeliveryFailure(authStorage, invitation, failedAt) {
2845
+ await authStorage.invitations.revoke({
2846
+ projectId: this.projectId,
2847
+ id: invitation.id,
2848
+ revokedAt: failedAt
2849
+ });
2850
+ }
2851
+ createInvitationDeliveryError(status) {
2852
+ if (status === "rate_limited") {
2853
+ return new AuthRuntimeError("rate_limited", "[Sixb] Invitation delivery is rate limited. Try again later.");
2854
+ }
2855
+ return new AuthRuntimeError("invalid_auth_input", "[Sixb] Invitation delivery was skipped by the active auth strategy.");
2856
+ }
2857
+ assertCanManageInvitationGroups(callerGroupIds, groupIds) {
2858
+ const scope = this.resolveMembershipPolicyScopeForUser(callerGroupIds);
2859
+ if (canPerformMembershipOperation(scope, "invite", groupIds)) {
2860
+ return;
2861
+ }
2862
+ if (groupIds.length === 0) {
2863
+ throw new AuthRuntimeError("authorization_denied", "[Sixb] The current user is not allowed to create or manage invitations without groups.");
2864
+ }
2865
+ const missing = missingMembershipGroupIds(scope, "invite", groupIds);
2866
+ throw new AuthRuntimeError("authorization_denied", `[Sixb] The current user is not allowed to create or manage invitations for group(s): ${missing.join(", ")}.`);
2867
+ }
2868
+ }
2869
+ function resolveCorrelationId(request) {
2870
+ return request.headers.get("x-correlation-id") ?? request.headers.get("x-request-id") ?? randomUUID3();
2871
+ }
2872
+ function isAuthenticatedUserRequestSession(session) {
2873
+ return session.principal.type === "user";
2874
+ }
2875
+ function resolveRequestIpAddress(request) {
2876
+ return request.headers.get("x-forwarded-for")?.split(",")[0]?.trim() || request.headers.get("x-real-ip")?.trim() || undefined;
2877
+ }
2878
+ function constrainTokenGroupIds(principalGroupIds, accessToken) {
2879
+ if (accessToken.groupIds === undefined) {
2880
+ return principalGroupIds;
2881
+ }
2882
+ const allowed = new Set(accessToken.groupIds);
2883
+ return principalGroupIds.filter((groupId) => allowed.has(groupId));
2884
+ }
2885
+ function callerCanManageServiceAccount(callerGroupIds, serviceAccountGroupIds) {
2886
+ const callerGroups = new Set(callerGroupIds);
2887
+ return serviceAccountGroupIds.every((groupId) => callerGroups.has(groupId));
2888
+ }
2889
+ function missingAccessTokenError(tokenId, projectId) {
2890
+ return new AuthStorageError("missing_access_token", `[Sixb] Access token '${tokenId}' not found for project '${projectId}'.`);
2891
+ }
2892
+ function constrainRequestedGroupIds(input, allowedGroupIds, options) {
2893
+ const groupIds = normalizeRequestedGroupIds(input);
2894
+ if (!groupIds) {
2895
+ return;
2896
+ }
2897
+ const allowed = new Set(allowedGroupIds);
2898
+ for (const groupId of groupIds) {
2899
+ if (!allowed.has(groupId)) {
2900
+ throw new AuthRuntimeError("authorization_denied", `[Sixb] Group '${groupId}' cannot be assigned to this ${options.subject}.`);
2901
+ }
2902
+ }
2903
+ return groupIds;
2904
+ }
2905
+ function normalizeRequestedGroupIds(input) {
2906
+ if (input === undefined) {
2907
+ return null;
2908
+ }
2909
+ const groupIds = [];
2910
+ for (const raw of input) {
2911
+ const groupId = raw.trim();
2912
+ if (!groupId) {
2913
+ throw new AuthRuntimeError("invalid_auth_input", "[Sixb] Group ids cannot be empty when creating auth credentials.");
2914
+ }
2915
+ if (!groupIds.includes(groupId)) {
2916
+ groupIds.push(groupId);
2917
+ }
2918
+ }
2919
+ return groupIds;
2920
+ }
2921
+ function createInvitationRecipientError(status, email) {
2922
+ if (status === "rate_limited") {
2923
+ return new AuthRuntimeError("rate_limited", "[Sixb] Invitation delivery is rate limited. Try again later.");
2924
+ }
2925
+ if (status === "invalid_email") {
2926
+ return new AuthRuntimeError("invalid_auth_input", "[Sixb] Invitation email is invalid.");
2927
+ }
2928
+ if (status === "disallowed_domain") {
2929
+ return new AuthRuntimeError("invalid_auth_input", `[Sixb] Invitation email '${email}' is not allowed by the active auth strategy.`);
2930
+ }
2931
+ return new AuthRuntimeError("invalid_auth_input", `[Sixb] Invitation email '${email}' belongs to a suspended user.`);
2932
+ }
2933
+ function membershipCapabilities(scope) {
2934
+ return {
2935
+ holds: {
2936
+ invite: scope.operations.invite.policyIds.length > 0,
2937
+ assignGroups: scope.operations.assignGroups.policyIds.length > 0,
2938
+ suspend: scope.operations.suspend.policyIds.length > 0
2939
+ },
2940
+ assignableGroupIds: [...scope.operations.assignGroups.groupIds],
2941
+ covers: (operation, memberGroups) => canPerformMembershipOperation(scope, operation, groupIdsOf(memberGroups))
2942
+ };
2943
+ }
2944
+ function groupIdsOf(groups) {
2945
+ return groups.map((group) => typeof group === "string" ? group : group.id);
2946
+ }
2947
+ // src/auth/types.ts
2948
+ var SYSTEM_PRINCIPAL = { type: "system", id: "system" };
2949
+ function principalsEqual(left, right) {
2950
+ return left.type === right.type && left.id === right.id;
2951
+ }
2952
+ export { PERSONAL_ACCESS_TOKEN_PREFIX, SERVICE_ACCOUNT_ACCESS_TOKEN_PREFIX, generateAccessTokenSecret, hashAccessTokenSecret, formatAccessTokenValue, parseAccessTokenValue, getBearerAccessTokenValue, createAccessTokenCredential, CSRF_HEADER_NAME, generateCsrfToken, isCsrfExemptMethod, verifyDoubleSubmitCsrf, applications, APPLICATION_IDS, SecurityValidationError, isGroupDefinition, isMembershipPolicyDefinition, isRoleDefinition, validateSecurityDefinitionsAtStartup, defineGroup, defineRole, defineMembershipPolicy, every, can, AuthStorageError, paginate, InMemoryAuthStorage, generateSessionSecret, hashSessionSecret, formatSessionCookieValue, parseSessionCookieValue, createSessionCredential, AuthRuntime, SYSTEM_PRINCIPAL, principalsEqual };
2953
+
2954
+ //# debugId=76194AFCF3E3EC0564756E2164756E21