@sentropic/cluster-mesh 0.25.0 → 0.27.0

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 (555) hide show
  1. package/dist/comments/storage-schema.d.ts +1 -1
  2. package/dist/comments/transport-contracts.d.ts +1 -1
  3. package/dist/compile/contract/diagnostics.d.ts +9 -0
  4. package/dist/compile/contract/diagnostics.d.ts.map +1 -0
  5. package/dist/compile/contract/diagnostics.js +82 -0
  6. package/dist/compile/contract/diagnostics.js.map +1 -0
  7. package/dist/compile/contract/encoding.d.ts +12 -0
  8. package/dist/compile/contract/encoding.d.ts.map +1 -0
  9. package/dist/compile/contract/encoding.js +95 -0
  10. package/dist/compile/contract/encoding.js.map +1 -0
  11. package/dist/compile/contract/index.d.ts +9 -0
  12. package/dist/compile/contract/index.d.ts.map +1 -0
  13. package/dist/compile/contract/index.js +9 -0
  14. package/dist/compile/contract/index.js.map +1 -0
  15. package/dist/compile/contract/json.d.ts +3 -0
  16. package/dist/compile/contract/json.d.ts.map +1 -0
  17. package/dist/compile/contract/json.js +75 -0
  18. package/dist/compile/contract/json.js.map +1 -0
  19. package/dist/compile/contract/output.d.ts +5 -0
  20. package/dist/compile/contract/output.d.ts.map +1 -0
  21. package/dist/compile/contract/output.js +57 -0
  22. package/dist/compile/contract/output.js.map +1 -0
  23. package/dist/compile/contract/recipe.d.ts +5 -0
  24. package/dist/compile/contract/recipe.d.ts.map +1 -0
  25. package/dist/compile/contract/recipe.js +86 -0
  26. package/dist/compile/contract/recipe.js.map +1 -0
  27. package/dist/compile/contract/schema.d.ts +26 -0
  28. package/dist/compile/contract/schema.d.ts.map +1 -0
  29. package/dist/compile/contract/schema.js +92 -0
  30. package/dist/compile/contract/schema.js.map +1 -0
  31. package/dist/compile/contract/types.d.ts +166 -0
  32. package/dist/compile/contract/types.d.ts.map +1 -0
  33. package/dist/compile/contract/types.js +21 -0
  34. package/dist/compile/contract/types.js.map +1 -0
  35. package/dist/compile/contract/vectors.d.ts +38 -0
  36. package/dist/compile/contract/vectors.d.ts.map +1 -0
  37. package/dist/compile/contract/vectors.js +29 -0
  38. package/dist/compile/contract/vectors.js.map +1 -0
  39. package/dist/forge/contracts.d.ts +60 -0
  40. package/dist/forge/contracts.d.ts.map +1 -0
  41. package/dist/forge/contracts.js +19 -0
  42. package/dist/forge/contracts.js.map +1 -0
  43. package/dist/forge/custody.d.ts +7 -0
  44. package/dist/forge/custody.d.ts.map +1 -0
  45. package/dist/forge/custody.js +76 -0
  46. package/dist/forge/custody.js.map +1 -0
  47. package/dist/forge/enrollment.d.ts +151 -0
  48. package/dist/forge/enrollment.d.ts.map +1 -0
  49. package/dist/forge/enrollment.js +98 -0
  50. package/dist/forge/enrollment.js.map +1 -0
  51. package/dist/forge/github-api.d.ts +6 -0
  52. package/dist/forge/github-api.d.ts.map +1 -0
  53. package/dist/forge/github-api.js +131 -0
  54. package/dist/forge/github-api.js.map +1 -0
  55. package/dist/forge/hono.d.ts +14 -0
  56. package/dist/forge/hono.d.ts.map +1 -0
  57. package/dist/forge/hono.js +141 -0
  58. package/dist/forge/hono.js.map +1 -0
  59. package/dist/forge/lifecycle.d.ts +108 -0
  60. package/dist/forge/lifecycle.d.ts.map +1 -0
  61. package/dist/forge/lifecycle.js +160 -0
  62. package/dist/forge/lifecycle.js.map +1 -0
  63. package/dist/forge/records.d.ts +70 -0
  64. package/dist/forge/records.d.ts.map +1 -0
  65. package/dist/forge/records.js +2 -0
  66. package/dist/forge/records.js.map +1 -0
  67. package/dist/forge/rotation.d.ts +46 -0
  68. package/dist/forge/rotation.d.ts.map +1 -0
  69. package/dist/forge/rotation.js +62 -0
  70. package/dist/forge/rotation.js.map +1 -0
  71. package/dist/identity/auth-abort.d.ts +9 -0
  72. package/dist/identity/auth-abort.d.ts.map +1 -0
  73. package/dist/identity/auth-abort.js +59 -0
  74. package/dist/identity/auth-abort.js.map +1 -0
  75. package/dist/identity/auth-binding.d.ts +3 -0
  76. package/dist/identity/auth-binding.d.ts.map +1 -0
  77. package/dist/identity/auth-binding.js +87 -0
  78. package/dist/identity/auth-binding.js.map +1 -0
  79. package/dist/identity/auth-boundary.d.ts +11 -0
  80. package/dist/identity/auth-boundary.d.ts.map +1 -0
  81. package/dist/identity/auth-boundary.js +73 -0
  82. package/dist/identity/auth-boundary.js.map +1 -0
  83. package/dist/identity/auth-completion.d.ts +9 -0
  84. package/dist/identity/auth-completion.d.ts.map +1 -0
  85. package/dist/identity/auth-completion.js +24 -0
  86. package/dist/identity/auth-completion.js.map +1 -0
  87. package/dist/identity/auth-credentials.d.ts +5 -0
  88. package/dist/identity/auth-credentials.d.ts.map +1 -0
  89. package/dist/identity/auth-credentials.js +82 -0
  90. package/dist/identity/auth-credentials.js.map +1 -0
  91. package/dist/identity/auth-email.d.ts +8 -0
  92. package/dist/identity/auth-email.d.ts.map +1 -0
  93. package/dist/identity/auth-email.js +104 -0
  94. package/dist/identity/auth-email.js.map +1 -0
  95. package/dist/identity/auth-hono.d.ts +5 -0
  96. package/dist/identity/auth-hono.d.ts.map +1 -0
  97. package/dist/identity/auth-hono.js +10 -0
  98. package/dist/identity/auth-hono.js.map +1 -0
  99. package/dist/identity/auth-proofs.d.ts +11 -0
  100. package/dist/identity/auth-proofs.d.ts.map +1 -0
  101. package/dist/identity/auth-proofs.js +107 -0
  102. package/dist/identity/auth-proofs.js.map +1 -0
  103. package/dist/identity/auth-service-tenant.d.ts +4 -0
  104. package/dist/identity/auth-service-tenant.d.ts.map +1 -0
  105. package/dist/identity/auth-service-tenant.js +54 -0
  106. package/dist/identity/auth-service-tenant.js.map +1 -0
  107. package/dist/identity/auth-sessions.d.ts +8 -0
  108. package/dist/identity/auth-sessions.d.ts.map +1 -0
  109. package/dist/identity/auth-sessions.js +141 -0
  110. package/dist/identity/auth-sessions.js.map +1 -0
  111. package/dist/identity/auth-social.d.ts +4 -0
  112. package/dist/identity/auth-social.d.ts.map +1 -0
  113. package/dist/identity/auth-social.js +82 -0
  114. package/dist/identity/auth-social.js.map +1 -0
  115. package/dist/identity/auth-users.d.ts +9 -0
  116. package/dist/identity/auth-users.d.ts.map +1 -0
  117. package/dist/identity/auth-users.js +116 -0
  118. package/dist/identity/auth-users.js.map +1 -0
  119. package/dist/identity/auth-webauthn.d.ts +22 -0
  120. package/dist/identity/auth-webauthn.d.ts.map +1 -0
  121. package/dist/identity/auth-webauthn.js +108 -0
  122. package/dist/identity/auth-webauthn.js.map +1 -0
  123. package/dist/identity/cascade.d.ts +12 -0
  124. package/dist/identity/cascade.d.ts.map +1 -0
  125. package/dist/identity/cascade.js +19 -0
  126. package/dist/identity/cascade.js.map +1 -0
  127. package/dist/identity/connector-custody.d.ts +85 -0
  128. package/dist/identity/connector-custody.d.ts.map +1 -0
  129. package/dist/identity/connector-custody.js +288 -0
  130. package/dist/identity/connector-custody.js.map +1 -0
  131. package/dist/identity/conversation.d.ts +50 -0
  132. package/dist/identity/conversation.d.ts.map +1 -0
  133. package/dist/identity/conversation.js +102 -0
  134. package/dist/identity/conversation.js.map +1 -0
  135. package/dist/identity/custody-crypto.d.ts +37 -0
  136. package/dist/identity/custody-crypto.d.ts.map +1 -0
  137. package/dist/identity/custody-crypto.js +173 -0
  138. package/dist/identity/custody-crypto.js.map +1 -0
  139. package/dist/identity/decision.d.ts +28 -0
  140. package/dist/identity/decision.d.ts.map +1 -0
  141. package/dist/identity/decision.js +97 -0
  142. package/dist/identity/decision.js.map +1 -0
  143. package/dist/identity/index.d.ts +9 -0
  144. package/dist/identity/index.d.ts.map +1 -0
  145. package/dist/identity/index.js +13 -0
  146. package/dist/identity/index.js.map +1 -0
  147. package/dist/identity/ledger.d.ts +120 -0
  148. package/dist/identity/ledger.d.ts.map +1 -0
  149. package/dist/identity/ledger.js +226 -0
  150. package/dist/identity/ledger.js.map +1 -0
  151. package/dist/identity/postgres.d.ts +13 -0
  152. package/dist/identity/postgres.d.ts.map +1 -0
  153. package/dist/identity/postgres.js +207 -0
  154. package/dist/identity/postgres.js.map +1 -0
  155. package/dist/identity/sqlite.d.ts +14 -0
  156. package/dist/identity/sqlite.d.ts.map +1 -0
  157. package/dist/identity/sqlite.js +193 -0
  158. package/dist/identity/sqlite.js.map +1 -0
  159. package/dist/identity-contracts/accounts.d.ts.map +1 -1
  160. package/dist/identity-contracts/accounts.js +4 -3
  161. package/dist/identity-contracts/accounts.js.map +1 -1
  162. package/dist/identity-contracts/boundary-resolution.d.ts +31 -0
  163. package/dist/identity-contracts/boundary-resolution.d.ts.map +1 -0
  164. package/dist/identity-contracts/boundary-resolution.js +56 -0
  165. package/dist/identity-contracts/boundary-resolution.js.map +1 -0
  166. package/dist/identity-contracts/composition-descriptors.d.ts +17 -0
  167. package/dist/identity-contracts/composition-descriptors.d.ts.map +1 -0
  168. package/dist/identity-contracts/composition-descriptors.js +77 -0
  169. package/dist/identity-contracts/composition-descriptors.js.map +1 -0
  170. package/dist/identity-contracts/custody-auth.d.ts +122 -0
  171. package/dist/identity-contracts/custody-auth.d.ts.map +1 -0
  172. package/dist/identity-contracts/custody-auth.js +2 -0
  173. package/dist/identity-contracts/custody-auth.js.map +1 -0
  174. package/dist/identity-contracts/custody-descriptors.d.ts +18 -0
  175. package/dist/identity-contracts/custody-descriptors.d.ts.map +1 -0
  176. package/dist/identity-contracts/custody-descriptors.js +83 -0
  177. package/dist/identity-contracts/custody-descriptors.js.map +1 -0
  178. package/dist/identity-contracts/custody-errors.d.ts +21 -0
  179. package/dist/identity-contracts/custody-errors.d.ts.map +1 -0
  180. package/dist/identity-contracts/custody-errors.js +80 -0
  181. package/dist/identity-contracts/custody-errors.js.map +1 -0
  182. package/dist/identity-contracts/custody-operations.d.ts +79 -0
  183. package/dist/identity-contracts/custody-operations.d.ts.map +1 -0
  184. package/dist/identity-contracts/custody-operations.js +2 -0
  185. package/dist/identity-contracts/custody-operations.js.map +1 -0
  186. package/dist/identity-contracts/custody.d.ts +587 -0
  187. package/dist/identity-contracts/custody.d.ts.map +1 -0
  188. package/dist/identity-contracts/custody.js +7 -0
  189. package/dist/identity-contracts/custody.js.map +1 -0
  190. package/dist/identity-contracts/doubles.d.ts +11 -2
  191. package/dist/identity-contracts/doubles.d.ts.map +1 -1
  192. package/dist/identity-contracts/doubles.js +20 -0
  193. package/dist/identity-contracts/doubles.js.map +1 -1
  194. package/dist/identity-contracts/index.d.ts +10 -0
  195. package/dist/identity-contracts/index.d.ts.map +1 -1
  196. package/dist/identity-contracts/index.js +10 -0
  197. package/dist/identity-contracts/index.js.map +1 -1
  198. package/dist/identity-contracts/oauth-reads.d.ts +42 -0
  199. package/dist/identity-contracts/oauth-reads.d.ts.map +1 -0
  200. package/dist/identity-contracts/oauth-reads.js +38 -0
  201. package/dist/identity-contracts/oauth-reads.js.map +1 -0
  202. package/dist/identity-contracts/replica-sync.d.ts +89 -0
  203. package/dist/identity-contracts/replica-sync.d.ts.map +1 -0
  204. package/dist/identity-contracts/replica-sync.js +7 -0
  205. package/dist/identity-contracts/replica-sync.js.map +1 -0
  206. package/dist/identity-contracts/service-tenancy.d.ts +43 -0
  207. package/dist/identity-contracts/service-tenancy.d.ts.map +1 -0
  208. package/dist/identity-contracts/service-tenancy.js +75 -0
  209. package/dist/identity-contracts/service-tenancy.js.map +1 -0
  210. package/dist/identity-contracts/workspace-deletion.d.ts +56 -0
  211. package/dist/identity-contracts/workspace-deletion.d.ts.map +1 -0
  212. package/dist/identity-contracts/workspace-deletion.js +7 -0
  213. package/dist/identity-contracts/workspace-deletion.js.map +1 -0
  214. package/dist/identity-stores/index.d.ts +4 -0
  215. package/dist/identity-stores/index.d.ts.map +1 -0
  216. package/dist/identity-stores/index.js +7 -0
  217. package/dist/identity-stores/index.js.map +1 -0
  218. package/dist/identity-stores/tenancy-postgres.d.ts +23 -0
  219. package/dist/identity-stores/tenancy-postgres.d.ts.map +1 -0
  220. package/dist/identity-stores/tenancy-postgres.js +294 -0
  221. package/dist/identity-stores/tenancy-postgres.js.map +1 -0
  222. package/dist/identity-stores/tenancy-schema.d.ts +11 -0
  223. package/dist/identity-stores/tenancy-schema.d.ts.map +1 -0
  224. package/dist/identity-stores/tenancy-schema.js +74 -0
  225. package/dist/identity-stores/tenancy-schema.js.map +1 -0
  226. package/dist/identity-stores/tenancy-sqlite.d.ts +24 -0
  227. package/dist/identity-stores/tenancy-sqlite.d.ts.map +1 -0
  228. package/dist/identity-stores/tenancy-sqlite.js +288 -0
  229. package/dist/identity-stores/tenancy-sqlite.js.map +1 -0
  230. package/dist/index.d.ts +17 -0
  231. package/dist/index.d.ts.map +1 -1
  232. package/dist/index.js +16 -0
  233. package/dist/index.js.map +1 -1
  234. package/dist/loaders/notifications/index.d.ts +5 -0
  235. package/dist/loaders/notifications/index.d.ts.map +1 -0
  236. package/dist/loaders/notifications/index.js +6 -0
  237. package/dist/loaders/notifications/index.js.map +1 -0
  238. package/dist/mcp/stateful-preflight.d.ts +1 -1
  239. package/dist/messaging/email-port.d.ts +49 -0
  240. package/dist/messaging/email-port.d.ts.map +1 -0
  241. package/dist/messaging/email-port.js +92 -0
  242. package/dist/messaging/email-port.js.map +1 -0
  243. package/dist/messaging/index.d.ts +1 -0
  244. package/dist/messaging/index.d.ts.map +1 -1
  245. package/dist/messaging/index.js +1 -0
  246. package/dist/messaging/index.js.map +1 -1
  247. package/dist/modules/catalog.d.ts +5 -4
  248. package/dist/modules/catalog.d.ts.map +1 -1
  249. package/dist/modules/catalog.js +10 -5
  250. package/dist/modules/catalog.js.map +1 -1
  251. package/dist/modules/contracts.d.ts +1 -1
  252. package/dist/modules/contracts.d.ts.map +1 -1
  253. package/dist/modules/contracts.js +1 -0
  254. package/dist/modules/contracts.js.map +1 -1
  255. package/dist/notifications/incident-policy.d.ts +6 -0
  256. package/dist/notifications/incident-policy.d.ts.map +1 -0
  257. package/dist/notifications/incident-policy.js +119 -0
  258. package/dist/notifications/incident-policy.js.map +1 -0
  259. package/dist/notifications/incident-schedule.d.ts +14 -0
  260. package/dist/notifications/incident-schedule.d.ts.map +1 -0
  261. package/dist/notifications/incident-schedule.js +36 -0
  262. package/dist/notifications/incident-schedule.js.map +1 -0
  263. package/dist/notifications/incident-state.d.ts +72 -0
  264. package/dist/notifications/incident-state.d.ts.map +1 -0
  265. package/dist/notifications/incident-state.js +72 -0
  266. package/dist/notifications/incident-state.js.map +1 -0
  267. package/dist/notifications/index.d.ts +9 -0
  268. package/dist/notifications/index.d.ts.map +1 -0
  269. package/dist/notifications/index.js +9 -0
  270. package/dist/notifications/index.js.map +1 -0
  271. package/dist/notifications/ops-job-failure-contract.d.ts +19 -0
  272. package/dist/notifications/ops-job-failure-contract.d.ts.map +1 -0
  273. package/dist/notifications/ops-job-failure-contract.js +183 -0
  274. package/dist/notifications/ops-job-failure-contract.js.map +1 -0
  275. package/dist/notifications/ops-job-failure-types.d.ts +81 -0
  276. package/dist/notifications/ops-job-failure-types.d.ts.map +1 -0
  277. package/dist/notifications/ops-job-failure-types.js +73 -0
  278. package/dist/notifications/ops-job-failure-types.js.map +1 -0
  279. package/dist/notifications/recipients-http.d.ts +66 -0
  280. package/dist/notifications/recipients-http.d.ts.map +1 -0
  281. package/dist/notifications/recipients-http.js +148 -0
  282. package/dist/notifications/recipients-http.js.map +1 -0
  283. package/dist/notifications/recipients.d.ts +50 -0
  284. package/dist/notifications/recipients.d.ts.map +1 -0
  285. package/dist/notifications/recipients.js +59 -0
  286. package/dist/notifications/recipients.js.map +1 -0
  287. package/dist/prompts/registry.d.ts +55 -0
  288. package/dist/prompts/registry.d.ts.map +1 -0
  289. package/dist/prompts/registry.js +76 -0
  290. package/dist/prompts/registry.js.map +1 -0
  291. package/dist/remote/assembly-contract.d.ts +96 -0
  292. package/dist/remote/assembly-contract.d.ts.map +1 -0
  293. package/dist/remote/assembly-contract.js +150 -0
  294. package/dist/remote/assembly-contract.js.map +1 -0
  295. package/dist/remote/contract-receipt.d.ts +36 -0
  296. package/dist/remote/contract-receipt.d.ts.map +1 -0
  297. package/dist/remote/contract-receipt.js +109 -0
  298. package/dist/remote/contract-receipt.js.map +1 -0
  299. package/dist/remote/credit-baseline.d.ts +60 -0
  300. package/dist/remote/credit-baseline.d.ts.map +1 -0
  301. package/dist/remote/credit-baseline.js +117 -0
  302. package/dist/remote/credit-baseline.js.map +1 -0
  303. package/dist/runtime/heavy-phase-queue.d.ts +101 -0
  304. package/dist/runtime/heavy-phase-queue.d.ts.map +1 -0
  305. package/dist/runtime/heavy-phase-queue.js +129 -0
  306. package/dist/runtime/heavy-phase-queue.js.map +1 -0
  307. package/dist/sessions/content-policy.d.ts +55 -0
  308. package/dist/sessions/content-policy.d.ts.map +1 -0
  309. package/dist/sessions/content-policy.js +133 -0
  310. package/dist/sessions/content-policy.js.map +1 -0
  311. package/dist/sessions/registry-admin.d.ts +19 -0
  312. package/dist/sessions/registry-admin.d.ts.map +1 -0
  313. package/dist/sessions/registry-admin.js +42 -0
  314. package/dist/sessions/registry-admin.js.map +1 -0
  315. package/dist/sessions/registry-freshness.d.ts +8 -0
  316. package/dist/sessions/registry-freshness.d.ts.map +1 -0
  317. package/dist/sessions/registry-freshness.js +108 -0
  318. package/dist/sessions/registry-freshness.js.map +1 -0
  319. package/dist/sessions/registry-ingest.d.ts +5 -0
  320. package/dist/sessions/registry-ingest.d.ts.map +1 -0
  321. package/dist/sessions/registry-ingest.js +113 -0
  322. package/dist/sessions/registry-ingest.js.map +1 -0
  323. package/dist/sessions/registry-publish.d.ts +18 -0
  324. package/dist/sessions/registry-publish.d.ts.map +1 -0
  325. package/dist/sessions/registry-publish.js +134 -0
  326. package/dist/sessions/registry-publish.js.map +1 -0
  327. package/dist/sessions/registry-store.d.ts +51 -0
  328. package/dist/sessions/registry-store.d.ts.map +1 -0
  329. package/dist/sessions/registry-store.js +134 -0
  330. package/dist/sessions/registry-store.js.map +1 -0
  331. package/dist/sessions/registry-types.d.ts +180 -0
  332. package/dist/sessions/registry-types.d.ts.map +1 -0
  333. package/dist/sessions/registry-types.js +32 -0
  334. package/dist/sessions/registry-types.js.map +1 -0
  335. package/dist/sessions/registry.d.ts +45 -0
  336. package/dist/sessions/registry.d.ts.map +1 -0
  337. package/dist/sessions/registry.js +74 -0
  338. package/dist/sessions/registry.js.map +1 -0
  339. package/dist/sessions/relay-bind.d.ts +38 -0
  340. package/dist/sessions/relay-bind.d.ts.map +1 -0
  341. package/dist/sessions/relay-bind.js +74 -0
  342. package/dist/sessions/relay-bind.js.map +1 -0
  343. package/dist/sessions/relay-brand.d.ts +2 -0
  344. package/dist/sessions/relay-brand.d.ts.map +1 -0
  345. package/dist/sessions/relay-brand.js +7 -0
  346. package/dist/sessions/relay-brand.js.map +1 -0
  347. package/dist/sessions/relay-capsule.d.ts +50 -0
  348. package/dist/sessions/relay-capsule.d.ts.map +1 -0
  349. package/dist/sessions/relay-capsule.js +72 -0
  350. package/dist/sessions/relay-capsule.js.map +1 -0
  351. package/dist/sessions/relay-chain-failure.d.ts +25 -0
  352. package/dist/sessions/relay-chain-failure.d.ts.map +1 -0
  353. package/dist/sessions/relay-chain-failure.js +23 -0
  354. package/dist/sessions/relay-chain-failure.js.map +1 -0
  355. package/dist/sessions/relay-chain.d.ts +74 -0
  356. package/dist/sessions/relay-chain.d.ts.map +1 -0
  357. package/dist/sessions/relay-chain.js +71 -0
  358. package/dist/sessions/relay-chain.js.map +1 -0
  359. package/dist/sessions/relay-composition.d.ts +8 -0
  360. package/dist/sessions/relay-composition.d.ts.map +1 -0
  361. package/dist/sessions/relay-composition.js +65 -0
  362. package/dist/sessions/relay-composition.js.map +1 -0
  363. package/dist/sessions/relay-credit.d.ts +40 -0
  364. package/dist/sessions/relay-credit.d.ts.map +1 -0
  365. package/dist/sessions/relay-credit.js +68 -0
  366. package/dist/sessions/relay-credit.js.map +1 -0
  367. package/dist/sessions/relay-engine.d.ts +19 -0
  368. package/dist/sessions/relay-engine.d.ts.map +1 -0
  369. package/dist/sessions/relay-engine.js +34 -0
  370. package/dist/sessions/relay-engine.js.map +1 -0
  371. package/dist/sessions/relay-frames.d.ts +28 -0
  372. package/dist/sessions/relay-frames.d.ts.map +1 -0
  373. package/dist/sessions/relay-frames.js +72 -0
  374. package/dist/sessions/relay-frames.js.map +1 -0
  375. package/dist/sessions/relay-lane-client.d.ts +7 -0
  376. package/dist/sessions/relay-lane-client.d.ts.map +1 -0
  377. package/dist/sessions/relay-lane-client.js +137 -0
  378. package/dist/sessions/relay-lane-client.js.map +1 -0
  379. package/dist/sessions/relay-lane-lease.d.ts +20 -0
  380. package/dist/sessions/relay-lane-lease.d.ts.map +1 -0
  381. package/dist/sessions/relay-lane-lease.js +74 -0
  382. package/dist/sessions/relay-lane-lease.js.map +1 -0
  383. package/dist/sessions/relay-lane-record.d.ts +28 -0
  384. package/dist/sessions/relay-lane-record.d.ts.map +1 -0
  385. package/dist/sessions/relay-lane-record.js +28 -0
  386. package/dist/sessions/relay-lane-record.js.map +1 -0
  387. package/dist/sessions/relay-lane-stream.d.ts +13 -0
  388. package/dist/sessions/relay-lane-stream.d.ts.map +1 -0
  389. package/dist/sessions/relay-lane-stream.js +148 -0
  390. package/dist/sessions/relay-lane-stream.js.map +1 -0
  391. package/dist/sessions/relay-routes.d.ts +368 -0
  392. package/dist/sessions/relay-routes.d.ts.map +1 -0
  393. package/dist/sessions/relay-routes.js +46 -0
  394. package/dist/sessions/relay-routes.js.map +1 -0
  395. package/dist/sessions/relay-skeleton.d.ts +4 -0
  396. package/dist/sessions/relay-skeleton.d.ts.map +1 -0
  397. package/dist/sessions/relay-skeleton.js +85 -0
  398. package/dist/sessions/relay-skeleton.js.map +1 -0
  399. package/dist/sessions/relay-types.d.ts +107 -0
  400. package/dist/sessions/relay-types.d.ts.map +1 -0
  401. package/dist/sessions/relay-types.js +2 -0
  402. package/dist/sessions/relay-types.js.map +1 -0
  403. package/dist/sessions/relay-validate.d.ts +8 -0
  404. package/dist/sessions/relay-validate.d.ts.map +1 -0
  405. package/dist/sessions/relay-validate.js +169 -0
  406. package/dist/sessions/relay-validate.js.map +1 -0
  407. package/dist/sessions/relay-wire.d.ts +8 -0
  408. package/dist/sessions/relay-wire.d.ts.map +1 -0
  409. package/dist/sessions/relay-wire.js +37 -0
  410. package/dist/sessions/relay-wire.js.map +1 -0
  411. package/dist/sessions/relay-wiring.d.ts +26 -0
  412. package/dist/sessions/relay-wiring.d.ts.map +1 -0
  413. package/dist/sessions/relay-wiring.js +13 -0
  414. package/dist/sessions/relay-wiring.js.map +1 -0
  415. package/dist/sessions/relay.d.ts +11 -0
  416. package/dist/sessions/relay.d.ts.map +1 -0
  417. package/dist/sessions/relay.js +71 -0
  418. package/dist/sessions/relay.js.map +1 -0
  419. package/dist/storage/artifact-blob.d.ts +50 -0
  420. package/dist/storage/artifact-blob.d.ts.map +1 -0
  421. package/dist/storage/artifact-blob.js +2 -0
  422. package/dist/storage/artifact-blob.js.map +1 -0
  423. package/dist/storage/descriptor.d.ts +1 -1
  424. package/dist/storage/errors.d.ts +1 -1
  425. package/dist/storage/identity/atomic-deletion.d.ts +4 -0
  426. package/dist/storage/identity/atomic-deletion.d.ts.map +1 -0
  427. package/dist/storage/identity/atomic-deletion.js +235 -0
  428. package/dist/storage/identity/atomic-deletion.js.map +1 -0
  429. package/dist/storage/identity/custody-composition.d.ts +9 -0
  430. package/dist/storage/identity/custody-composition.d.ts.map +1 -0
  431. package/dist/storage/identity/custody-composition.js +31 -0
  432. package/dist/storage/identity/custody-composition.js.map +1 -0
  433. package/dist/storage/identity/custody-delivery-record.d.ts +4 -0
  434. package/dist/storage/identity/custody-delivery-record.d.ts.map +1 -0
  435. package/dist/storage/identity/custody-delivery-record.js +11 -0
  436. package/dist/storage/identity/custody-delivery-record.js.map +1 -0
  437. package/dist/storage/identity/custody-host.d.ts +16 -0
  438. package/dist/storage/identity/custody-host.d.ts.map +1 -0
  439. package/dist/storage/identity/custody-host.js +5 -0
  440. package/dist/storage/identity/custody-host.js.map +1 -0
  441. package/dist/storage/identity/custody-import-deliveries.d.ts +6 -0
  442. package/dist/storage/identity/custody-import-deliveries.d.ts.map +1 -0
  443. package/dist/storage/identity/custody-import-deliveries.js +46 -0
  444. package/dist/storage/identity/custody-import-deliveries.js.map +1 -0
  445. package/dist/storage/identity/custody-import.d.ts +4 -0
  446. package/dist/storage/identity/custody-import.d.ts.map +1 -0
  447. package/dist/storage/identity/custody-import.js +364 -0
  448. package/dist/storage/identity/custody-import.js.map +1 -0
  449. package/dist/storage/identity/custody-journal-postgres.d.ts +125 -0
  450. package/dist/storage/identity/custody-journal-postgres.d.ts.map +1 -0
  451. package/dist/storage/identity/custody-journal-postgres.js +428 -0
  452. package/dist/storage/identity/custody-journal-postgres.js.map +1 -0
  453. package/dist/storage/identity/custody-journal-sqlite.d.ts +121 -0
  454. package/dist/storage/identity/custody-journal-sqlite.d.ts.map +1 -0
  455. package/dist/storage/identity/custody-journal-sqlite.js +345 -0
  456. package/dist/storage/identity/custody-journal-sqlite.js.map +1 -0
  457. package/dist/storage/identity/custody-lifecycle.d.ts +4 -0
  458. package/dist/storage/identity/custody-lifecycle.d.ts.map +1 -0
  459. package/dist/storage/identity/custody-lifecycle.js +42 -0
  460. package/dist/storage/identity/custody-lifecycle.js.map +1 -0
  461. package/dist/storage/identity/custody-postgres.d.ts +96 -0
  462. package/dist/storage/identity/custody-postgres.d.ts.map +1 -0
  463. package/dist/storage/identity/custody-postgres.js +726 -0
  464. package/dist/storage/identity/custody-postgres.js.map +1 -0
  465. package/dist/storage/identity/custody-records.d.ts +17 -0
  466. package/dist/storage/identity/custody-records.d.ts.map +1 -0
  467. package/dist/storage/identity/custody-records.js +260 -0
  468. package/dist/storage/identity/custody-records.js.map +1 -0
  469. package/dist/storage/identity/custody-shared.d.ts +28 -0
  470. package/dist/storage/identity/custody-shared.d.ts.map +1 -0
  471. package/dist/storage/identity/custody-shared.js +24 -0
  472. package/dist/storage/identity/custody-shared.js.map +1 -0
  473. package/dist/storage/identity/custody-sqlite.d.ts +93 -0
  474. package/dist/storage/identity/custody-sqlite.d.ts.map +1 -0
  475. package/dist/storage/identity/custody-sqlite.js +568 -0
  476. package/dist/storage/identity/custody-sqlite.js.map +1 -0
  477. package/dist/storage/identity/custody-tombstone-record.d.ts +3 -0
  478. package/dist/storage/identity/custody-tombstone-record.d.ts.map +1 -0
  479. package/dist/storage/identity/custody-tombstone-record.js +8 -0
  480. package/dist/storage/identity/custody-tombstone-record.js.map +1 -0
  481. package/dist/storage/identity/custody-transaction-guards.d.ts +16 -0
  482. package/dist/storage/identity/custody-transaction-guards.d.ts.map +1 -0
  483. package/dist/storage/identity/custody-transaction-guards.js +64 -0
  484. package/dist/storage/identity/custody-transaction-guards.js.map +1 -0
  485. package/dist/storage/identity/custody-transaction-ports.d.ts +9 -0
  486. package/dist/storage/identity/custody-transaction-ports.d.ts.map +1 -0
  487. package/dist/storage/identity/custody-transaction-ports.js +106 -0
  488. package/dist/storage/identity/custody-transaction-ports.js.map +1 -0
  489. package/dist/storage/identity/deletion-planes.d.ts +10 -0
  490. package/dist/storage/identity/deletion-planes.d.ts.map +1 -0
  491. package/dist/storage/identity/deletion-planes.js +54 -0
  492. package/dist/storage/identity/deletion-planes.js.map +1 -0
  493. package/dist/storage/identity/index.d.ts +18 -0
  494. package/dist/storage/identity/index.d.ts.map +1 -0
  495. package/dist/storage/identity/index.js +22 -0
  496. package/dist/storage/identity/index.js.map +1 -0
  497. package/dist/storage/identity/postgres.d.ts +16 -0
  498. package/dist/storage/identity/postgres.d.ts.map +1 -0
  499. package/dist/storage/identity/postgres.js +345 -0
  500. package/dist/storage/identity/postgres.js.map +1 -0
  501. package/dist/storage/identity/records.d.ts +12 -0
  502. package/dist/storage/identity/records.d.ts.map +1 -0
  503. package/dist/storage/identity/records.js +84 -0
  504. package/dist/storage/identity/records.js.map +1 -0
  505. package/dist/storage/identity/replica-sync.d.ts +4 -0
  506. package/dist/storage/identity/replica-sync.d.ts.map +1 -0
  507. package/dist/storage/identity/replica-sync.js +402 -0
  508. package/dist/storage/identity/replica-sync.js.map +1 -0
  509. package/dist/storage/identity/schema.d.ts +13 -0
  510. package/dist/storage/identity/schema.d.ts.map +1 -0
  511. package/dist/storage/identity/schema.js +418 -0
  512. package/dist/storage/identity/schema.js.map +1 -0
  513. package/dist/storage/identity/sqlite-schema.d.ts +4 -0
  514. package/dist/storage/identity/sqlite-schema.d.ts.map +1 -0
  515. package/dist/storage/identity/sqlite-schema.js +17 -0
  516. package/dist/storage/identity/sqlite-schema.js.map +1 -0
  517. package/dist/storage/identity/sqlite.d.ts +25 -0
  518. package/dist/storage/identity/sqlite.d.ts.map +1 -0
  519. package/dist/storage/identity/sqlite.js +233 -0
  520. package/dist/storage/identity/sqlite.js.map +1 -0
  521. package/dist/storage/identity/stores.d.ts +10 -0
  522. package/dist/storage/identity/stores.d.ts.map +1 -0
  523. package/dist/storage/identity/stores.js +5 -0
  524. package/dist/storage/identity/stores.js.map +1 -0
  525. package/dist/storage/identity/wiring.d.ts +20 -0
  526. package/dist/storage/identity/wiring.d.ts.map +1 -0
  527. package/dist/storage/identity/wiring.js +26 -0
  528. package/dist/storage/identity/wiring.js.map +1 -0
  529. package/dist/storage/identity/workspace-deletion.d.ts +3 -0
  530. package/dist/storage/identity/workspace-deletion.d.ts.map +1 -0
  531. package/dist/storage/identity/workspace-deletion.js +100 -0
  532. package/dist/storage/identity/workspace-deletion.js.map +1 -0
  533. package/dist/storage/index.d.ts +1 -0
  534. package/dist/storage/index.d.ts.map +1 -1
  535. package/dist/storage/postgres/journal.d.ts +1 -1
  536. package/dist/storage/postgres/profiles.d.ts +2 -2
  537. package/dist/storage/postgres/scope.d.ts +1 -1
  538. package/dist/storage/root-facade.d.ts +1 -1
  539. package/dist/storage/root-journal.d.ts +1 -1
  540. package/dist/storage/root-profiles.d.ts +1 -1
  541. package/package.json +56 -4
  542. package/ui/AdminUsersScreen.svelte +197 -0
  543. package/ui/AdminUsersScreen.svelte.d.ts +4 -0
  544. package/ui/LoginScreen.svelte +15 -0
  545. package/ui/LoginScreen.svelte.d.ts +4 -0
  546. package/ui/MembershipDecisionsScreen.svelte +76 -0
  547. package/ui/MembershipDecisionsScreen.svelte.d.ts +4 -0
  548. package/ui/RegistrationScreen.svelte +15 -0
  549. package/ui/RegistrationScreen.svelte.d.ts +4 -0
  550. package/ui/WorkspaceMembersScreen.svelte +86 -0
  551. package/ui/WorkspaceMembersScreen.svelte.d.ts +4 -0
  552. package/ui/auth-flow.ts +44 -0
  553. package/ui/management-ports.ts +36 -0
  554. package/ui/management-transport.ts +29 -0
  555. package/contracts/engram-memory-neutral-contract-v1.d.ts +0 -367
@@ -0,0 +1,568 @@
1
+ import { IdentityCustodyErrorV1 } from '../../identity-contracts/custody-errors.js';
2
+ import { composeIdentityTransaction } from './custody-composition.js';
3
+ import { identityTransactionGuard, requireIdentityRunOptions, rebindIdentityTransactionHost } from './custody-transaction-guards.js';
4
+ import { subjectLifecycle } from './custody-lifecycle.js';
5
+ import { decodeSession } from './records.js';
6
+ import { InvitationError, ProofVerificationError } from '../../identity-contracts/errors.js';
7
+ import { identitySchemaStatements, identityTable } from './schema.js';
8
+ import { applySqliteIdentityCoreSchema } from './sqlite.js';
9
+ import { identityCustodySchemaAssetV1, isSocialRaceRetry, } from './custody-shared.js';
10
+ import { SqliteCustodyJournal } from './custody-journal-sqlite.js';
11
+ import { decodeAccountProfile, decodeBoundSession, decodeDigestInvitation, decodeEmailTicket, decodeSingleUseProof, decodeSocialLink, decodeWebAuthnCredential, } from './custody-records.js';
12
+ export const SQLITE_CUSTODY_DEADLINE_MS = 5000;
13
+ export const sqliteCustodyTable = (table) => identityTable('sqlite', null, table);
14
+ const isUniqueViolation = (error) => {
15
+ const message = error instanceof Error ? error.message : String(error);
16
+ return message.includes('UNIQUE constraint failed');
17
+ };
18
+ export const requireSqliteWriteOptions = (options) => {
19
+ if (options.mode !== 'write') {
20
+ throw new IdentityCustodyErrorV1('identity_transaction_unbound');
21
+ }
22
+ if (!Number.isInteger(options.deadlineMs) || options.deadlineMs <= 0) {
23
+ throw new IdentityCustodyErrorV1('identity_material_invalid');
24
+ }
25
+ };
26
+ const toBool = (value) => (value ? 1 : 0);
27
+ /** Transaction-scoped custody bundle over one SQLite connection. */
28
+ export class SqliteCustodyTx {
29
+ connection;
30
+ subjects;
31
+ profiles;
32
+ credentials;
33
+ singleUseProofs;
34
+ emailTickets;
35
+ invitations;
36
+ sessions;
37
+ social;
38
+ constructor(connection) {
39
+ this.connection = connection;
40
+ this.subjects = subjectLifecycle({ profile: 'sqlite', raw: connection, stores: this, journal: new SqliteCustodyJournal(connection) });
41
+ this.profiles = {
42
+ find: (userId) => this.one(decodeAccountProfile, `SELECT * FROM "identity_account_profiles" WHERE "user_id" = ?`, [userId]),
43
+ put: async (record) => {
44
+ connection
45
+ .prepare(`INSERT INTO "identity_account_profiles" ("user_id","email_verified","display_name","approval_due_at","approved_at","approved_by_user_id","disabled_at","disabled_reason","legacy_account_status") VALUES (?,?,?,?,?,?,?,?,?)
46
+ ON CONFLICT("user_id") DO UPDATE SET "email_verified" = excluded."email_verified", "display_name" = excluded."display_name", "approval_due_at" = excluded."approval_due_at", "approved_at" = excluded."approved_at", "approved_by_user_id" = excluded."approved_by_user_id", "disabled_at" = excluded."disabled_at", "disabled_reason" = excluded."disabled_reason", "legacy_account_status" = excluded."legacy_account_status"`)
47
+ .run(record.userId, toBool(record.emailVerified), record.displayName, record.approvalDueAt, record.approvedAt, record.approvedByUserId, record.disabledAt, record.disabledReason, record.legacyAccountStatus);
48
+ },
49
+ };
50
+ this.credentials = {
51
+ insert: async (record) => {
52
+ try {
53
+ connection
54
+ .prepare(`INSERT INTO "identity_webauthn_credentials" ("proof_id","user_id","credential_id","public_key_cose","counter","revision","rp_id","device_name","transports_json","uv","device_type","backed_up","created_at","last_used_at","revoked_at") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`)
55
+ .run(record.proofId, record.userId, record.credentialId, record.publicKeyCose, record.counter, record.revision, record.rpId, record.deviceName, record.transports === null ? null : JSON.stringify(record.transports), toBool(record.uv), record.deviceType, record.backedUp === null ? null : toBool(record.backedUp), record.createdAt, record.lastUsedAt, record.revokedAt);
56
+ }
57
+ catch (error) {
58
+ if (isUniqueViolation(error))
59
+ throw new IdentityCustodyErrorV1('webauthn_credential_conflict');
60
+ throw error;
61
+ }
62
+ },
63
+ findById: (proofId) => this.one(decodeWebAuthnCredential, `SELECT * FROM "identity_webauthn_credentials" WHERE "proof_id" = ?`, [proofId]),
64
+ findByCredentialId: (credentialId) => this.one(decodeWebAuthnCredential, `SELECT * FROM "identity_webauthn_credentials" WHERE "credential_id" = ?`, [credentialId]),
65
+ listForUser: (userId) => this.all(decodeWebAuthnCredential, `SELECT * FROM "identity_webauthn_credentials" WHERE "user_id" = ? ORDER BY "created_at", "proof_id"`, [userId]),
66
+ compareAndSwapCounter: (input) => this.casCounter(input),
67
+ rename: async (proofId, userId, deviceName) => {
68
+ const changed = this.changes(`UPDATE "identity_webauthn_credentials" SET "device_name" = ?, "revision" = "revision" + 1 WHERE "proof_id" = ? AND "user_id" = ? AND "revoked_at" IS NULL`, [deviceName, proofId, userId]);
69
+ if (changed === 0)
70
+ throw new IdentityCustodyErrorV1('identity_material_invalid');
71
+ },
72
+ revoke: async (proofId, userId, at) => {
73
+ const current = await this.one(decodeWebAuthnCredential, `SELECT * FROM "identity_webauthn_credentials" WHERE "proof_id" = ?`, [proofId]);
74
+ if (!current || current.userId !== userId)
75
+ throw new IdentityCustodyErrorV1('identity_material_missing');
76
+ if (current.revokedAt !== null)
77
+ return;
78
+ connection.prepare(`UPDATE "identity_webauthn_credentials" SET "revoked_at" = ?, "revision" = "revision" + 1 WHERE "proof_id" = ? AND "user_id" = ?`).run(at, proofId, userId);
79
+ },
80
+ };
81
+ this.singleUseProofs = {
82
+ insert: (record) => this.insertProof(record),
83
+ find: (key) => this.findProof(key),
84
+ findChallenge: (challenge, purpose) => this.findChallengeRow(challenge, purpose),
85
+ findLatestEmailCode: (email, candidates, now) => this.findLatestEmailCodeRow(email, candidates, now),
86
+ findMagicLink: (tokenHash) => this.findMagicLinkRow(tokenHash),
87
+ countEmailCodes: async (email, since) => {
88
+ const row = connection.prepare(`SELECT COUNT(*) AS "count" FROM "identity_single_use_proofs" WHERE "kind" = 'email_code' AND "email" = ? AND "created_at" >= ?`).get(email, since);
89
+ return Number(row['count'] ?? 0);
90
+ },
91
+ consume: (input) => this.consumeProof(input),
92
+ revoke: async (key, expectedRevision, at) => {
93
+ const changed = this.changes(`UPDATE "identity_single_use_proofs" SET "state" = 'revoked', "revoked_at" = ?, "revision" = "revision" + 1 WHERE "kind" = ? AND "proof_id" = ? AND "state" = 'pending' AND "revision" = ?`, [at, key.kind, key.proofId, expectedRevision]);
94
+ if (changed === 0)
95
+ throw new IdentityCustodyErrorV1('proof_state_conflict');
96
+ },
97
+ purgeExpired: async (now) => {
98
+ this.changes(`DELETE FROM "identity_email_registration_tickets" WHERE "expires_at" < ?`, [now]);
99
+ return this.changes(`DELETE FROM "identity_single_use_proofs" AS proof WHERE "expires_at" < ? AND "state" != 'pending'
100
+ AND NOT ("kind" = 'magic_link' AND "state" = 'consumed' AND "user_id" IS NOT NULL)
101
+ AND NOT EXISTS (SELECT 1 FROM "identity_email_registration_tickets" AS ticket
102
+ WHERE ticket."code_kind" = proof."kind" AND ticket."code_proof_id" = proof."proof_id")`, [now]);
103
+ },
104
+ };
105
+ this.emailTickets = {
106
+ findByTokenHash: (tokenHash) => this.one(decodeEmailTicket, `SELECT * FROM "identity_email_registration_tickets" WHERE "token_hash" = ?`, [tokenHash]),
107
+ importTicket: async (record) => {
108
+ try {
109
+ connection.prepare(`INSERT INTO "identity_email_registration_tickets" ("code_kind","code_proof_id","email","token_hash","user_id","state","revision","created_at","expires_at","consumed_at","revoked_at") VALUES ('email_code',?,?,?,?,?,?,?,?,?,?)`).run(record.codeProofId, record.email, record.tokenHash, record.userId, record.state, record.revision, record.createdAt, record.expiresAt, record.consumedAt, record.revokedAt);
110
+ }
111
+ catch (error) {
112
+ if (isUniqueViolation(error))
113
+ throw new IdentityCustodyErrorV1('identity_record_conflict');
114
+ throw error;
115
+ }
116
+ },
117
+ exchangeCode: (input) => this.exchangeCode(input),
118
+ consume: (input) => this.consumeTicket(input),
119
+ revoke: async (codeProofId, expectedRevision, at) => {
120
+ const changed = this.changes(`UPDATE "identity_email_registration_tickets" SET "state" = 'revoked', "revoked_at" = ?, "revision" = "revision" + 1 WHERE "code_proof_id" = ? AND "state" = 'pending' AND "revision" = ?`, [at, codeProofId, expectedRevision]);
121
+ if (changed === 0)
122
+ throw new IdentityCustodyErrorV1('proof_state_conflict');
123
+ },
124
+ };
125
+ this.invitations = {
126
+ insert: async (record) => {
127
+ try {
128
+ connection
129
+ .prepare(`INSERT INTO "identity_invitation_digests" ("invitation_id","email","tenant_id","workspace_id","client_id","token_hash","status","expires_at","created_at","consumed_at","consumed_by_user_id","revision") VALUES (?,?,?,?,?,?,?,?,?,?,?,?)`)
130
+ .run(record.invitationId, record.email, record.tenantId, record.workspaceId, record.clientId, record.tokenHash, record.status, record.expiresAt, record.createdAt, record.consumedAt, record.consumedByUserId, record.revision);
131
+ }
132
+ catch (error) {
133
+ if (isUniqueViolation(error))
134
+ throw new IdentityCustodyErrorV1('identity_record_conflict');
135
+ throw error;
136
+ }
137
+ },
138
+ findById: (invitationId) => this.one(decodeDigestInvitation, `SELECT * FROM "identity_invitation_digests" WHERE "invitation_id" = ?`, [invitationId]),
139
+ findByDigest: (tokenHash) => this.one(decodeDigestInvitation, `SELECT * FROM "identity_invitation_digests" WHERE "token_hash" = ?`, [tokenHash]),
140
+ consumeByDigest: (input) => this.consumeInvitation(input),
141
+ revoke: async (invitationId, expectedRevision, at) => {
142
+ void at;
143
+ const changed = this.changes(`UPDATE "identity_invitation_digests" SET "status" = 'revoked', "revision" = "revision" + 1 WHERE "invitation_id" = ? AND "status" = 'pending' AND "revision" = ?`, [invitationId, expectedRevision]);
144
+ if (changed === 0)
145
+ throw new IdentityCustodyErrorV1('proof_state_conflict');
146
+ },
147
+ };
148
+ this.sessions = {
149
+ insert: (record) => this.insertBoundSession(record),
150
+ findById: (sessionId) => this.findBoundSession(sessionId),
151
+ findBySessionTokenHash: (hash) => this.findBoundSessionByHash('session_token_hash', hash),
152
+ findByRefreshTokenHash: (hash) => this.findBoundSessionByHash('refresh_token_hash', hash),
153
+ rotate: (input) => this.rotateBoundSession(input),
154
+ touchActivity: async (sessionId, at) => {
155
+ connection.prepare(`UPDATE "identity_login_token_bindings" SET "last_activity_at" = ? WHERE "session_id" = ?`).run(at, sessionId);
156
+ },
157
+ revoke: (sessionId, at) => this.revokeBoundSession(sessionId, at),
158
+ revokeAllForUser: async (userId, at) => {
159
+ const rows = connection.prepare(`SELECT "session_id" FROM "identity_login_sessions" WHERE "user_id" = ? AND "status" = 'active'`).all(userId);
160
+ let revoked = 0;
161
+ for (const row of rows) {
162
+ await this.revokeBoundSession(String(row['session_id']), at);
163
+ revoked += 1;
164
+ }
165
+ return revoked;
166
+ },
167
+ listForUser: (userId) => this.listBoundSessions(userId),
168
+ };
169
+ this.social = {
170
+ insert: async (record) => {
171
+ try {
172
+ connection
173
+ .prepare(`INSERT INTO "identity_social_links" ("proof_id","user_id","provider","provider_subject","provider_tenant","email_at_link","email_verified_by_provider","linked_at","last_login_at","revoked_at","revision") VALUES (?,?,?,?,?,?,?,?,?,?,?)`)
174
+ .run(record.proofId, record.userId, record.provider, record.providerSubject, record.providerTenant, record.emailAtLink, toBool(record.emailVerifiedByProvider), record.linkedAt, record.lastLoginAt, record.revokedAt, record.revision);
175
+ }
176
+ catch (error) {
177
+ if (isUniqueViolation(error))
178
+ throw new IdentityCustodyErrorV1('social_subject_conflict');
179
+ throw error;
180
+ }
181
+ },
182
+ findById: (proofId) => this.one(decodeSocialLink, `SELECT * FROM "identity_social_links" WHERE "proof_id" = ?`, [proofId]),
183
+ findBySubject: (provider, providerSubject) => this.one(decodeSocialLink, `SELECT * FROM "identity_social_links" WHERE "provider" = ? AND "provider_subject" = ?`, [provider, providerSubject]),
184
+ listForUser: (userId) => this.all(decodeSocialLink, `SELECT * FROM "identity_social_links" WHERE "user_id" = ? ORDER BY "linked_at", "proof_id"`, [userId]),
185
+ touchLogin: async (proofId, expectedRevision, at) => {
186
+ const changed = this.changes(`UPDATE "identity_social_links" SET "last_login_at" = ?, "revision" = "revision" + 1 WHERE "proof_id" = ? AND "revoked_at" IS NULL AND "revision" = ?`, [at, proofId, expectedRevision]);
187
+ if (changed === 0)
188
+ throw new IdentityCustodyErrorV1('proof_state_conflict');
189
+ },
190
+ unlink: async (proofId, userId, expectedRevision, at) => {
191
+ void at;
192
+ const changed = this.changes(`DELETE FROM "identity_social_links" WHERE "proof_id" = ? AND "user_id" = ? AND "revision" = ?`, [proofId, userId, expectedRevision]);
193
+ if (changed === 0)
194
+ throw new IdentityCustodyErrorV1('proof_state_conflict');
195
+ },
196
+ };
197
+ }
198
+ one = async (decode, sql, values) => {
199
+ const row = this.connection.prepare(sql).get(...values);
200
+ return row === undefined ? null : decode(row);
201
+ };
202
+ all = async (decode, sql, values) => this.connection.prepare(sql).all(...values).map(decode);
203
+ changes = (sql, values) => Number(this.connection.prepare(sql).run(...values).changes);
204
+ casCounter = async (input) => {
205
+ if (![input.expectedCounter, input.newCounter].every((value) => Number.isInteger(value) && value >= 0 && value <= 4294967295)
206
+ || !Number.isSafeInteger(input.expectedRevision) || input.expectedRevision < 0 || input.expectedRevision === Number.MAX_SAFE_INTEGER
207
+ || !input.proofId || !input.userId || !Number.isFinite(Date.parse(input.at))) {
208
+ throw new IdentityCustodyErrorV1('identity_material_invalid');
209
+ }
210
+ if ((input.newCounter !== 0 || input.expectedCounter !== 0) && input.newCounter <= input.expectedCounter) {
211
+ const snapshot = await this.one(decodeWebAuthnCredential, `SELECT * FROM "identity_webauthn_credentials" WHERE "proof_id" = ?`, [input.proofId]);
212
+ if (snapshot && snapshot.userId === input.userId && snapshot.revokedAt === null && snapshot.revision === input.expectedRevision && snapshot.counter === input.expectedCounter) {
213
+ throw new IdentityCustodyErrorV1('webauthn_counter_rejected');
214
+ }
215
+ }
216
+ const updated = await this.one(decodeWebAuthnCredential, `UPDATE "identity_webauthn_credentials" SET "counter" = ?, "last_used_at" = ?, "revision" = "revision" + 1
217
+ WHERE "proof_id" = ? AND "user_id" = ? AND "revoked_at" IS NULL AND "revision" = ? AND "counter" = ? RETURNING *`, [input.newCounter, input.at, input.proofId, input.userId, input.expectedRevision, input.expectedCounter]);
218
+ if (updated)
219
+ return updated;
220
+ const current = await this.one(decodeWebAuthnCredential, `SELECT * FROM "identity_webauthn_credentials" WHERE "proof_id" = ?`, [input.proofId]);
221
+ if (!current)
222
+ throw new ProofVerificationError('not_found');
223
+ if (current.userId !== input.userId)
224
+ throw new IdentityCustodyErrorV1('proof_binding_mismatch');
225
+ if (current.revokedAt !== null)
226
+ throw new ProofVerificationError('revoked');
227
+ throw new IdentityCustodyErrorV1('webauthn_credential_stale');
228
+ };
229
+ proofColumns = '"kind","proof_id","user_id","state","revision","created_at","expires_at","consumed_at","revoked_at","challenge","challenge_purpose","rp_id","allowed_origins_json","user_verification","email","secret_digest","digest_algorithm","digest_key_ref"';
230
+ proofValues = (record) => {
231
+ const base = [record.kind, record.proofId, record.userId, record.state, record.revision, record.createdAt, record.expiresAt, record.consumedAt, record.revokedAt];
232
+ if (record.kind === 'webauthn_challenge') {
233
+ return [...base, record.challenge, record.purpose, record.rpId, JSON.stringify(record.allowedOrigins), record.userVerification, null, null, null, null];
234
+ }
235
+ if (record.kind === 'email_code') {
236
+ return [...base, null, null, null, null, null, record.email, record.codeDigest.value, record.codeDigest.algorithm, record.codeDigest.algorithm === 'hmac-sha256' ? record.codeDigest.keyRef : null];
237
+ }
238
+ return [...base, null, null, null, null, null, record.email, record.tokenHash, 'sha256', null];
239
+ };
240
+ insertProof = async (record) => {
241
+ try {
242
+ this.connection.prepare(`INSERT INTO "identity_single_use_proofs" (${this.proofColumns}) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`).run(...this.proofValues(record));
243
+ }
244
+ catch (error) {
245
+ if (isUniqueViolation(error))
246
+ throw new IdentityCustodyErrorV1('identity_record_conflict');
247
+ throw error;
248
+ }
249
+ };
250
+ findProof = (key) => this.one(decodeSingleUseProof, `SELECT ${this.proofColumns} FROM "identity_single_use_proofs" WHERE "kind" = ? AND "proof_id" = ?`, [key.kind, key.proofId]);
251
+ findChallengeRow = (challenge, purpose) => this.one(decodeSingleUseProof, `SELECT ${this.proofColumns} FROM "identity_single_use_proofs" WHERE "kind" = 'webauthn_challenge' AND "challenge" = ? AND "challenge_purpose" = ?`, [challenge, purpose]).then((row) => (row && row.kind === 'webauthn_challenge' ? row : null));
252
+ findLatestEmailCodeRow = async (email, candidates, now) => {
253
+ const rows = await this.all(decodeSingleUseProof, `SELECT ${this.proofColumns} FROM "identity_single_use_proofs" WHERE "kind" = 'email_code' AND "email" = ? AND "state" = 'pending' AND "expires_at" > ? ORDER BY "created_at" DESC, "proof_id" DESC`, [email, now]);
254
+ for (const row of rows) {
255
+ if (row.kind !== 'email_code')
256
+ continue;
257
+ for (const candidate of candidates) {
258
+ const keyRef = candidate.algorithm === 'hmac-sha256' ? (candidate.keyRef ?? null) : null;
259
+ const rowKeyRef = row.codeDigest.algorithm === 'hmac-sha256' ? row.codeDigest.keyRef : null;
260
+ if (row.codeDigest.algorithm === candidate.algorithm && rowKeyRef === keyRef && row.codeDigest.value === candidate.value) {
261
+ return row;
262
+ }
263
+ }
264
+ }
265
+ return null;
266
+ };
267
+ findMagicLinkRow = (tokenHash) => this.one(decodeSingleUseProof, `SELECT ${this.proofColumns} FROM "identity_single_use_proofs" WHERE "kind" = 'magic_link' AND "secret_digest" = ?`, [tokenHash]).then((row) => (row && row.kind === 'magic_link' ? row : null));
268
+ consumeProof = async (input) => {
269
+ const current = await this.findProof(input.key);
270
+ if (!current || current.state !== 'pending')
271
+ throw new IdentityCustodyErrorV1('proof_state_conflict');
272
+ if (current.userId !== input.expectedUserId)
273
+ throw new IdentityCustodyErrorV1('proof_binding_mismatch');
274
+ if (current.revision !== input.expectedRevision)
275
+ throw new IdentityCustodyErrorV1('proof_state_conflict');
276
+ if (!(current.expiresAt > input.at))
277
+ throw new IdentityCustodyErrorV1('proof_state_conflict');
278
+ if (input.bindUserId !== null && current.userId !== null && current.userId !== input.bindUserId) {
279
+ throw new IdentityCustodyErrorV1('proof_binding_mismatch');
280
+ }
281
+ if (input.match.kind !== current.kind)
282
+ throw new IdentityCustodyErrorV1('proof_binding_mismatch');
283
+ if (input.match.kind === 'webauthn_challenge' && current.kind === 'webauthn_challenge') {
284
+ if (input.match.challenge !== current.challenge || input.match.purpose !== current.purpose || input.match.rpId !== current.rpId) {
285
+ throw new IdentityCustodyErrorV1('proof_binding_mismatch');
286
+ }
287
+ }
288
+ else if (input.match.kind === 'email_code' && current.kind === 'email_code') {
289
+ if (input.match.email !== current.email)
290
+ throw new IdentityCustodyErrorV1('proof_binding_mismatch');
291
+ const rowKeyRef = current.codeDigest.algorithm === 'hmac-sha256' ? current.codeDigest.keyRef : null;
292
+ const matchKeyRef = input.match.digest.algorithm === 'hmac-sha256' ? input.match.digest.keyRef : null;
293
+ if (input.match.digest.algorithm !== current.codeDigest.algorithm || matchKeyRef !== rowKeyRef || input.match.digest.value !== current.codeDigest.value) {
294
+ throw new IdentityCustodyErrorV1('proof_binding_mismatch');
295
+ }
296
+ }
297
+ else if (input.match.kind === 'magic_link' && current.kind === 'magic_link') {
298
+ if (input.match.email !== current.email || input.match.tokenHash !== current.tokenHash) {
299
+ throw new IdentityCustodyErrorV1('proof_binding_mismatch');
300
+ }
301
+ }
302
+ else {
303
+ throw new IdentityCustodyErrorV1('proof_binding_mismatch');
304
+ }
305
+ const boundUserId = input.bindUserId ?? current.userId;
306
+ const updated = await this.one(decodeSingleUseProof, `UPDATE "identity_single_use_proofs" SET "state" = 'consumed', "consumed_at" = ?, "user_id" = ?, "revision" = "revision" + 1
307
+ WHERE "kind" = ? AND "proof_id" = ? AND "state" = 'pending' AND "revision" = ? RETURNING ${this.proofColumns}`, [input.at, boundUserId, input.key.kind, input.key.proofId, input.expectedRevision]);
308
+ if (!updated)
309
+ throw new IdentityCustodyErrorV1('proof_state_conflict');
310
+ return updated;
311
+ };
312
+ exchangeCode = async (input) => {
313
+ const consumed = await this.consumeProof({
314
+ key: { kind: 'email_code', proofId: input.codeProofId },
315
+ expectedRevision: input.expectedRevision,
316
+ expectedUserId: null,
317
+ match: { kind: 'email_code', email: input.email, digest: input.digest },
318
+ bindUserId: null,
319
+ at: input.at,
320
+ });
321
+ if (consumed.kind !== 'email_code')
322
+ throw new IdentityCustodyErrorV1('proof_binding_mismatch');
323
+ try {
324
+ this.connection.prepare(`INSERT INTO "identity_email_registration_tickets" ("code_kind","code_proof_id","email","token_hash","user_id","state","revision","created_at","expires_at","consumed_at","revoked_at") VALUES ('email_code',?,?,?,?,'pending',?,?,?,?,?)`).run(input.ticket.codeProofId, input.ticket.email, input.ticket.tokenHash, input.ticket.userId, input.ticket.revision, input.ticket.createdAt, input.ticket.expiresAt, input.ticket.consumedAt, input.ticket.revokedAt);
325
+ }
326
+ catch (error) {
327
+ if (isUniqueViolation(error))
328
+ throw new IdentityCustodyErrorV1('identity_record_conflict');
329
+ throw error;
330
+ }
331
+ const stored = await this.one(decodeEmailTicket, `SELECT * FROM "identity_email_registration_tickets" WHERE "code_proof_id" = ?`, [input.ticket.codeProofId]);
332
+ if (!stored)
333
+ throw new IdentityCustodyErrorV1('identity_material_missing');
334
+ return stored;
335
+ };
336
+ consumeTicket = async (input) => {
337
+ const updated = await this.one(decodeEmailTicket, `UPDATE "identity_email_registration_tickets" SET "state" = 'consumed', "consumed_at" = ?, "user_id" = ?, "revision" = "revision" + 1
338
+ WHERE "token_hash" = ? AND "email" = ? AND "state" = 'pending' AND "revision" = ? AND "expires_at" > ? RETURNING *`, [input.at, input.bindUserId, input.tokenHash, input.email, input.expectedRevision, input.at]);
339
+ if (!updated)
340
+ throw new IdentityCustodyErrorV1('proof_state_conflict');
341
+ return updated;
342
+ };
343
+ consumeInvitation = async (input) => {
344
+ const updated = await this.one(decodeDigestInvitation, `UPDATE "identity_invitation_digests" SET "status" = 'consumed', "consumed_at" = ?, "consumed_by_user_id" = ?, "revision" = "revision" + 1
345
+ WHERE "token_hash" = ? AND "email" = ? AND "status" = 'pending' AND "revision" = ? AND "expires_at" > ?
346
+ AND ("client_id" IS NULL OR "client_id" = ?) RETURNING *`, [input.at, input.userId, input.tokenHash, input.email, input.expectedRevision, input.at, input.clientId]);
347
+ if (!updated)
348
+ throw new InvitationError('consumed');
349
+ return updated;
350
+ };
351
+ baseSessionColumns = '"session_id","user_id","status","mfa_state","created_at","expires_at","revoked_at","refresh_count"';
352
+ readBoundSession = async (where, values) => {
353
+ const binding = await this.one(decodeBoundSession, `SELECT * FROM "identity_login_token_bindings" WHERE ${where}`, values);
354
+ if (!binding)
355
+ return null;
356
+ const base = await this.one(decodeSession, `SELECT ${this.baseSessionColumns} FROM "identity_login_sessions" WHERE "session_id" = ?`, [binding.sessionId]);
357
+ if (!base)
358
+ throw new IdentityCustodyErrorV1('identity_material_missing');
359
+ return { ...binding, userId: base.userId, createdAt: base.createdAt, expiresAt: base.expiresAt, revokedAt: base.revokedAt ?? null };
360
+ };
361
+ insertBoundSession = async (record) => {
362
+ if (record.refreshTokenHash !== null && record.refreshTokenHash === record.sessionTokenHash) {
363
+ throw new IdentityCustodyErrorV1('identity_material_invalid');
364
+ }
365
+ try {
366
+ this.connection.prepare(`INSERT INTO "identity_login_sessions" (${this.baseSessionColumns}) VALUES (?,?, 'active',?,?,?,NULL,?)`).run(record.sessionId, record.userId, record.login.mfaVerified ? 'step_up' : 'none', record.createdAt, record.expiresAt, record.rotationVersion);
367
+ }
368
+ catch (error) {
369
+ if (isUniqueViolation(error))
370
+ throw new IdentityCustodyErrorV1('identity_record_conflict');
371
+ throw error;
372
+ }
373
+ try {
374
+ this.connection.prepare(`INSERT INTO "identity_login_token_bindings" ("session_id","session_token_hash","refresh_token_hash","mfa_verified","auth_time","session_version","rotation_version","device_name","ip_address","user_agent","last_activity_at") VALUES (?,?,?,?,?,?,?,?,?,?,?)`).run(record.sessionId, record.sessionTokenHash, record.refreshTokenHash, toBool(record.login.mfaVerified), record.login.authTime, record.login.sessionVersion, record.rotationVersion, record.deviceName, record.ipAddress, record.userAgent, record.lastActivityAt);
375
+ }
376
+ catch (error) {
377
+ if (isUniqueViolation(error))
378
+ throw new IdentityCustodyErrorV1('identity_record_conflict');
379
+ throw error;
380
+ }
381
+ };
382
+ findBoundSession = (sessionId) => this.readBoundSession('"session_id" = ?', [sessionId]);
383
+ findBoundSessionByHash = (column, hash) => this.readBoundSession(`"${column}" = ?`, [hash]);
384
+ listBoundSessions = async (userId) => {
385
+ const ids = this.connection.prepare(`SELECT "session_id" FROM "identity_login_sessions" WHERE "user_id" = ? ORDER BY "created_at", "session_id"`).all(userId);
386
+ const out = [];
387
+ for (const row of ids) {
388
+ const found = await this.findBoundSession(String(row['session_id']));
389
+ if (found)
390
+ out.push(found);
391
+ }
392
+ return out;
393
+ };
394
+ rotateBoundSession = async (input) => {
395
+ if (input.nextRefreshTokenHash === input.nextSessionTokenHash) {
396
+ throw new IdentityCustodyErrorV1('identity_material_invalid');
397
+ }
398
+ if (!(input.nextExpiresAt > input.at))
399
+ throw new IdentityCustodyErrorV1('identity_material_invalid');
400
+ if (input.expectedRotationVersion < 0 || !Number.isSafeInteger(input.expectedRotationVersion)) {
401
+ throw new IdentityCustodyErrorV1('identity_material_invalid');
402
+ }
403
+ const current = await this.findBoundSession(input.sessionId);
404
+ if (!current || current.userId !== input.userId)
405
+ throw new IdentityCustodyErrorV1('login_binding_mismatch');
406
+ if (current.refreshTokenHash === null || current.refreshTokenHash !== input.expectedRefreshTokenHash) {
407
+ throw new IdentityCustodyErrorV1('login_refresh_conflict');
408
+ }
409
+ if (current.rotationVersion !== input.expectedRotationVersion)
410
+ throw new IdentityCustodyErrorV1('login_refresh_conflict');
411
+ if (current.revokedAt !== null)
412
+ throw new IdentityCustodyErrorV1('login_binding_mismatch');
413
+ if (!(current.expiresAt > input.at))
414
+ throw new IdentityCustodyErrorV1('login_binding_mismatch');
415
+ if (current.login.mfaVerified !== input.verifiedLogin.mfaVerified || current.login.authTime !== input.verifiedLogin.authTime || current.login.sessionVersion !== input.verifiedLogin.sessionVersion) {
416
+ throw new IdentityCustodyErrorV1('login_binding_mismatch');
417
+ }
418
+ const updated = await this.one(decodeBoundSession, `UPDATE "identity_login_token_bindings" SET "session_token_hash" = ?, "refresh_token_hash" = ?, "rotation_version" = "rotation_version" + 1, "last_activity_at" = ?
419
+ WHERE "session_id" = ? AND "refresh_token_hash" = ? AND "rotation_version" = ?
420
+ AND "mfa_verified" = ? AND "auth_time" = ? AND "session_version" = ? RETURNING *`, [input.nextSessionTokenHash, input.nextRefreshTokenHash, input.at, input.sessionId, input.expectedRefreshTokenHash, input.expectedRotationVersion, toBool(input.verifiedLogin.mfaVerified), input.verifiedLogin.authTime, input.verifiedLogin.sessionVersion]);
421
+ if (!updated)
422
+ throw new IdentityCustodyErrorV1('login_refresh_conflict');
423
+ this.changes(`UPDATE "identity_login_sessions" SET "expires_at" = ?, "refresh_count" = "refresh_count" + 1 WHERE "session_id" = ? AND "status" = 'active'`, [input.nextExpiresAt, input.sessionId]);
424
+ const reread = await this.findBoundSession(input.sessionId);
425
+ if (!reread)
426
+ throw new IdentityCustodyErrorV1('identity_material_missing');
427
+ return reread;
428
+ };
429
+ revokeBoundSession = async (sessionId, at) => {
430
+ this.changes(`UPDATE "identity_login_sessions" SET "status" = 'revoked', "revoked_at" = ? WHERE "session_id" = ?`, [at, sessionId]);
431
+ };
432
+ }
433
+ let sqliteCustodyTxCounter = 0;
434
+ const nextSqliteCustodyTxId = () => {
435
+ sqliteCustodyTxCounter += 1;
436
+ return `custody-sqlite-${Date.now().toString(36)}-${sqliteCustodyTxCounter}`;
437
+ };
438
+ /**
439
+ * Combined custody handle: the transaction-scoped stores plus the deletion
440
+ * journal/outbox over the same connection. One object joins every callback.
441
+ */
442
+ export class SqliteCustodyHandle extends SqliteCustodyTx {
443
+ journal;
444
+ constructor(connection) {
445
+ super(connection);
446
+ this.journal = new SqliteCustodyJournal(connection);
447
+ }
448
+ get stores() {
449
+ return this;
450
+ }
451
+ get profile() {
452
+ return 'sqlite';
453
+ }
454
+ get raw() {
455
+ return this.connection;
456
+ }
457
+ }
458
+ /** Host-owned exclusive unit of work over one SQLite connection. */
459
+ export const createSqliteIdentityUnitOfWorkV1 = (input) => {
460
+ const run = async (options, operation) => {
461
+ requireIdentityRunOptions(options);
462
+ const readOnly = options.mode === 'read';
463
+ const deadline = Date.now() + options.deadlineMs;
464
+ let attempt = 0;
465
+ for (;;) {
466
+ attempt += 1;
467
+ try {
468
+ return await input.host.runExclusiveTransaction({ readOnly, deadlineMs: Math.max(1, deadline - Date.now()) }, async (binding) => {
469
+ if (binding.readOnly !== readOnly)
470
+ throw new IdentityCustodyErrorV1('identity_transaction_unbound');
471
+ const guard = identityTransactionGuard(readOnly, deadline);
472
+ const handle = new SqliteCustodyHandle(guard.sqlite(binding.connection));
473
+ try {
474
+ const result = await operation(rebindIdentityTransactionHost(composeIdentityTransaction({ host: handle, transactionId: binding.transactionId, readOnly, check: guard.check }), binding.hostTransaction));
475
+ guard.check();
476
+ return result;
477
+ }
478
+ finally {
479
+ guard.close();
480
+ }
481
+ });
482
+ }
483
+ catch (error) {
484
+ if (attempt < options.maxAttempts && Date.now() < deadline && isSocialRaceRetry(error))
485
+ continue;
486
+ if (isSocialRaceRetry(error))
487
+ throw new IdentityCustodyErrorV1(error.finalCode);
488
+ throw error;
489
+ }
490
+ }
491
+ };
492
+ return {
493
+ profile: 'sqlite',
494
+ run,
495
+ };
496
+ };
497
+ const sqliteTransactionQueues = new WeakMap();
498
+ export const createSqliteIdentityHostV1 = (options) => {
499
+ if (options.applySchema !== false) {
500
+ applySqliteIdentityCoreSchema(options.connection);
501
+ }
502
+ return {
503
+ runExclusiveTransaction: async (runOptions, operation) => {
504
+ const prior = sqliteTransactionQueues.get(options.connection) ?? Promise.resolve();
505
+ let release;
506
+ sqliteTransactionQueues.set(options.connection, new Promise((resolve) => { release = resolve; }));
507
+ await prior;
508
+ const deadline = Date.now() + runOptions.deadlineMs;
509
+ const guard = identityTransactionGuard(runOptions.readOnly, deadline);
510
+ try {
511
+ options.connection.exec(runOptions.readOnly ? 'BEGIN' : 'BEGIN IMMEDIATE');
512
+ const result = await operation({
513
+ transactionId: nextSqliteCustodyTxId(),
514
+ hostTransaction: new SqliteCustodyHandle(guard.sqlite(options.connection)),
515
+ connection: guard.sqlite(options.connection),
516
+ readOnly: runOptions.readOnly,
517
+ });
518
+ if (Date.now() >= deadline)
519
+ throw new IdentityCustodyErrorV1('identity_transaction_unbound');
520
+ options.connection.exec('COMMIT');
521
+ return result;
522
+ }
523
+ catch (error) {
524
+ try {
525
+ options.connection.exec('ROLLBACK');
526
+ }
527
+ catch { /* Preserve the original failure. */ }
528
+ throw error;
529
+ }
530
+ finally {
531
+ guard.close();
532
+ release();
533
+ }
534
+ },
535
+ };
536
+ };
537
+ /** Standalone per-method custody stores for direct store tests. */
538
+ export const createSqliteCustodyStores = (options) => {
539
+ const tx = new SqliteCustodyTx(options.connection);
540
+ applySqliteIdentityCoreSchema(options.connection);
541
+ return tx;
542
+ };
543
+ /** Applies the custody asset on the caller's active binding; never begins or commits. */
544
+ export const applySqliteIdentityCustodySchemaV1 = async (input) => {
545
+ const asset = identityCustodySchemaAssetV1('sqlite');
546
+ if (asset.assetSha256 !== input.expectedAssetSha256)
547
+ throw new IdentityCustodyErrorV1('identity_contract_unavailable');
548
+ for (const ddl of identitySchemaStatements('sqlite', ''))
549
+ input.binding.connection.exec(ddl);
550
+ const existing = input.binding.connection.prepare(`SELECT * FROM "identity_custody_schema_versions" WHERE "migration_id" = 'A2.0b/1'`).get();
551
+ if (existing) {
552
+ if (existing['asset_sha256'] !== asset.assetSha256 || existing['contract_version'] !== '1.1.0') {
553
+ throw new IdentityCustodyErrorV1('identity_contract_unavailable');
554
+ }
555
+ return { migrationId: 'A2.0b/1', contractVersion: '1.1.0', profile: 'sqlite', assetSha256: asset.assetSha256, appliedAt: String(existing['applied_at']) };
556
+ }
557
+ input.binding.connection.prepare(`INSERT INTO "identity_custody_schema_versions" ("migration_id","contract_version","asset_sha256","applied_at") VALUES ('A2.0b/1','1.1.0',?,?)`).run(asset.assetSha256, input.appliedAt);
558
+ return { migrationId: 'A2.0b/1', contractVersion: '1.1.0', profile: 'sqlite', assetSha256: asset.assetSha256, appliedAt: input.appliedAt };
559
+ };
560
+ export const bindSqliteIdentityTransactionV1 = (input) => rebindIdentityTransactionHost(composeIdentityTransaction({
561
+ host: new SqliteCustodyHandle(input.binding.connection),
562
+ transactionId: input.binding.transactionId, readOnly: input.binding.readOnly,
563
+ check: (write) => { if (write && input.binding.readOnly)
564
+ throw new IdentityCustodyErrorV1('identity_transaction_unbound'); },
565
+ }), input.binding.hostTransaction);
566
+ /** V1 factory name for the standalone SQLite custody stores. */
567
+ export const createSqliteIdentityCustodyStoresV1 = createSqliteCustodyStores;
568
+ //# sourceMappingURL=custody-sqlite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custody-sqlite.js","sourceRoot":"","sources":["../../../src/storage/identity/custody-sqlite.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACpF,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AACrI,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC7F,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAA0B,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EACL,4BAA4B,EAC5B,iBAAiB,GAGl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