@softistx/janus 0.0.0-stage → 0.73.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 (911) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2928 -2
  3. package/dist/auth/api-keys/authenticate-key.d.ts +21 -0
  4. package/dist/auth/api-keys/authenticate-key.d.ts.map +1 -0
  5. package/dist/auth/api-keys/bound.d.ts +11 -0
  6. package/dist/auth/api-keys/bound.d.ts.map +1 -0
  7. package/dist/auth/api-keys/count.d.ts +8 -0
  8. package/dist/auth/api-keys/count.d.ts.map +1 -0
  9. package/dist/auth/api-keys/create/checks.d.ts +42 -0
  10. package/dist/auth/api-keys/create/checks.d.ts.map +1 -0
  11. package/dist/auth/api-keys/create/index.d.ts +10 -0
  12. package/dist/auth/api-keys/create/index.d.ts.map +1 -0
  13. package/dist/auth/api-keys/events.d.ts +22 -0
  14. package/dist/auth/api-keys/events.d.ts.map +1 -0
  15. package/dist/auth/api-keys/expiry.d.ts +11 -0
  16. package/dist/auth/api-keys/expiry.d.ts.map +1 -0
  17. package/dist/auth/api-keys/flows.d.ts +13 -0
  18. package/dist/auth/api-keys/flows.d.ts.map +1 -0
  19. package/dist/auth/api-keys/index.d.ts +11 -0
  20. package/dist/auth/api-keys/index.d.ts.map +1 -0
  21. package/dist/auth/api-keys/read.d.ts +10 -0
  22. package/dist/auth/api-keys/read.d.ts.map +1 -0
  23. package/dist/auth/api-keys/shape.d.ts +24 -0
  24. package/dist/auth/api-keys/shape.d.ts.map +1 -0
  25. package/dist/auth/api-keys/to-api-key.d.ts +8 -0
  26. package/dist/auth/api-keys/to-api-key.d.ts.map +1 -0
  27. package/dist/auth/api-keys/token.d.ts +23 -0
  28. package/dist/auth/api-keys/token.d.ts.map +1 -0
  29. package/dist/auth/api-keys/user-bound.d.ts +10 -0
  30. package/dist/auth/api-keys/user-bound.d.ts.map +1 -0
  31. package/dist/auth/at.d.ts +9 -0
  32. package/dist/auth/at.d.ts.map +1 -0
  33. package/dist/auth/avatar/any-type.d.ts +13 -0
  34. package/dist/auth/avatar/any-type.d.ts.map +1 -0
  35. package/dist/auth/avatar/flows.d.ts +7 -0
  36. package/dist/auth/avatar/flows.d.ts.map +1 -0
  37. package/dist/auth/avatar/id.d.ts +10 -0
  38. package/dist/auth/avatar/id.d.ts.map +1 -0
  39. package/dist/auth/avatar/index.d.ts +7 -0
  40. package/dist/auth/avatar/index.d.ts.map +1 -0
  41. package/dist/auth/avatar/remove.d.ts +10 -0
  42. package/dist/auth/avatar/remove.d.ts.map +1 -0
  43. package/dist/auth/avatar/set.d.ts +12 -0
  44. package/dist/auth/avatar/set.d.ts.map +1 -0
  45. package/dist/auth/concurrency-limit.d.ts +13 -0
  46. package/dist/auth/concurrency-limit.d.ts.map +1 -0
  47. package/dist/auth/config/api-keys-config.d.ts +33 -0
  48. package/dist/auth/config/api-keys-config.d.ts.map +1 -0
  49. package/dist/auth/config/hasher.d.ts +22 -0
  50. package/dist/auth/config/hasher.d.ts.map +1 -0
  51. package/dist/auth/config/index.d.ts +24 -0
  52. package/dist/auth/config/index.d.ts.map +1 -0
  53. package/dist/auth/config/invitations-config.d.ts +74 -0
  54. package/dist/auth/config/invitations-config.d.ts.map +1 -0
  55. package/dist/auth/config/janus-config.d.ts +233 -0
  56. package/dist/auth/config/janus-config.d.ts.map +1 -0
  57. package/dist/auth/config/magic-link-config.d.ts +6 -0
  58. package/dist/auth/config/magic-link-config.d.ts.map +1 -0
  59. package/dist/auth/config/names.d.ts +9 -0
  60. package/dist/auth/config/names.d.ts.map +1 -0
  61. package/dist/auth/config/normalize.d.ts +26 -0
  62. package/dist/auth/config/normalize.d.ts.map +1 -0
  63. package/dist/auth/config/passkeys-config.d.ts +49 -0
  64. package/dist/auth/config/passkeys-config.d.ts.map +1 -0
  65. package/dist/auth/config/password-config.d.ts +22 -0
  66. package/dist/auth/config/password-config.d.ts.map +1 -0
  67. package/dist/auth/config/reserved.d.ts +14 -0
  68. package/dist/auth/config/reserved.d.ts.map +1 -0
  69. package/dist/auth/config/resolve-api-keys.d.ts +5 -0
  70. package/dist/auth/config/resolve-api-keys.d.ts.map +1 -0
  71. package/dist/auth/config/resolve-config.d.ts +9 -0
  72. package/dist/auth/config/resolve-config.d.ts.map +1 -0
  73. package/dist/auth/config/resolve-cookie.d.ts +5 -0
  74. package/dist/auth/config/resolve-cookie.d.ts.map +1 -0
  75. package/dist/auth/config/resolve-devices.d.ts +5 -0
  76. package/dist/auth/config/resolve-devices.d.ts.map +1 -0
  77. package/dist/auth/config/resolve-invitation-types.d.ts +5 -0
  78. package/dist/auth/config/resolve-invitation-types.d.ts.map +1 -0
  79. package/dist/auth/config/resolve-invitations.d.ts +5 -0
  80. package/dist/auth/config/resolve-invitations.d.ts.map +1 -0
  81. package/dist/auth/config/resolve-magic-link.d.ts +4 -0
  82. package/dist/auth/config/resolve-magic-link.d.ts.map +1 -0
  83. package/dist/auth/config/resolve-passkeys.d.ts +5 -0
  84. package/dist/auth/config/resolve-passkeys.d.ts.map +1 -0
  85. package/dist/auth/config/resolve-second-factor.d.ts +5 -0
  86. package/dist/auth/config/resolve-second-factor.d.ts.map +1 -0
  87. package/dist/auth/config/resolve-social.d.ts +17 -0
  88. package/dist/auth/config/resolve-social.d.ts.map +1 -0
  89. package/dist/auth/config/resolve-throttle.d.ts +37 -0
  90. package/dist/auth/config/resolve-throttle.d.ts.map +1 -0
  91. package/dist/auth/config/resolve-type.d.ts +6 -0
  92. package/dist/auth/config/resolve-type.d.ts.map +1 -0
  93. package/dist/auth/config/resolved-config.d.ts +126 -0
  94. package/dist/auth/config/resolved-config.d.ts.map +1 -0
  95. package/dist/auth/config/social-config.d.ts +154 -0
  96. package/dist/auth/config/social-config.d.ts.map +1 -0
  97. package/dist/auth/config/user-type.d.ts +79 -0
  98. package/dist/auth/config/user-type.d.ts.map +1 -0
  99. package/dist/auth/config/warn-throttle-window.d.ts +14 -0
  100. package/dist/auth/config/warn-throttle-window.d.ts.map +1 -0
  101. package/dist/auth/context/create-context.d.ts +31 -0
  102. package/dist/auth/context/create-context.d.ts.map +1 -0
  103. package/dist/auth/context/index.d.ts +17 -0
  104. package/dist/auth/context/index.d.ts.map +1 -0
  105. package/dist/auth/context/logins.d.ts +28 -0
  106. package/dist/auth/context/logins.d.ts.map +1 -0
  107. package/dist/auth/context/password.d.ts +34 -0
  108. package/dist/auth/context/password.d.ts.map +1 -0
  109. package/dist/auth/context/records.d.ts +27 -0
  110. package/dist/auth/context/records.d.ts.map +1 -0
  111. package/dist/auth/context/user.d.ts +21 -0
  112. package/dist/auth/context/user.d.ts.map +1 -0
  113. package/dist/auth/context/validate-fields.d.ts +12 -0
  114. package/dist/auth/context/validate-fields.d.ts.map +1 -0
  115. package/dist/auth/counter-key.d.ts +20 -0
  116. package/dist/auth/counter-key.d.ts.map +1 -0
  117. package/dist/auth/derived-keys.d.ts +9 -0
  118. package/dist/auth/derived-keys.d.ts.map +1 -0
  119. package/dist/auth/devices/cookie.d.ts +56 -0
  120. package/dist/auth/devices/cookie.d.ts.map +1 -0
  121. package/dist/auth/devices/hint.d.ts +42 -0
  122. package/dist/auth/devices/hint.d.ts.map +1 -0
  123. package/dist/auth/devices/index.d.ts +11 -0
  124. package/dist/auth/devices/index.d.ts.map +1 -0
  125. package/dist/auth/devices/report.d.ts +11 -0
  126. package/dist/auth/devices/report.d.ts.map +1 -0
  127. package/dist/auth/devices/token.d.ts +13 -0
  128. package/dist/auth/devices/token.d.ts.map +1 -0
  129. package/dist/auth/email-flows/any-type-change-email.d.ts +18 -0
  130. package/dist/auth/email-flows/any-type-change-email.d.ts.map +1 -0
  131. package/dist/auth/email-flows/any-type-reset-password.d.ts +19 -0
  132. package/dist/auth/email-flows/any-type-reset-password.d.ts.map +1 -0
  133. package/dist/auth/email-flows/any-type-verify-email.d.ts +18 -0
  134. package/dist/auth/email-flows/any-type-verify-email.d.ts.map +1 -0
  135. package/dist/auth/email-flows/change-email-token.d.ts +47 -0
  136. package/dist/auth/email-flows/change-email-token.d.ts.map +1 -0
  137. package/dist/auth/email-flows/change-email.d.ts +17 -0
  138. package/dist/auth/email-flows/change-email.d.ts.map +1 -0
  139. package/dist/auth/email-flows/confirm-reset.d.ts +16 -0
  140. package/dist/auth/email-flows/confirm-reset.d.ts.map +1 -0
  141. package/dist/auth/email-flows/email-token.d.ts +30 -0
  142. package/dist/auth/email-flows/email-token.d.ts.map +1 -0
  143. package/dist/auth/email-flows/flows.d.ts +13 -0
  144. package/dist/auth/email-flows/flows.d.ts.map +1 -0
  145. package/dist/auth/email-flows/index.d.ts +10 -0
  146. package/dist/auth/email-flows/index.d.ts.map +1 -0
  147. package/dist/auth/email-flows/owner-of.d.ts +17 -0
  148. package/dist/auth/email-flows/owner-of.d.ts.map +1 -0
  149. package/dist/auth/email-flows/prove-first.d.ts +45 -0
  150. package/dist/auth/email-flows/prove-first.d.ts.map +1 -0
  151. package/dist/auth/email-flows/reset-password.d.ts +17 -0
  152. package/dist/auth/email-flows/reset-password.d.ts.map +1 -0
  153. package/dist/auth/email-flows/set-email-verified.d.ts +19 -0
  154. package/dist/auth/email-flows/set-email-verified.d.ts.map +1 -0
  155. package/dist/auth/email-flows/verify-email.d.ts +25 -0
  156. package/dist/auth/email-flows/verify-email.d.ts.map +1 -0
  157. package/dist/auth/email-sign-in.d.ts +51 -0
  158. package/dist/auth/email-sign-in.d.ts.map +1 -0
  159. package/dist/auth/events.d.ts +166 -0
  160. package/dist/auth/events.d.ts.map +1 -0
  161. package/dist/auth/first-proof.d.ts +43 -0
  162. package/dist/auth/first-proof.d.ts.map +1 -0
  163. package/dist/auth/hashers.d.ts +52 -0
  164. package/dist/auth/hashers.d.ts.map +1 -0
  165. package/dist/auth/index.d.ts +22 -0
  166. package/dist/auth/index.d.ts.map +1 -0
  167. package/dist/auth/invitations/accept.d.ts +10 -0
  168. package/dist/auth/invitations/accept.d.ts.map +1 -0
  169. package/dist/auth/invitations/change-pending.d.ts +17 -0
  170. package/dist/auth/invitations/change-pending.d.ts.map +1 -0
  171. package/dist/auth/invitations/claim.d.ts +31 -0
  172. package/dist/auth/invitations/claim.d.ts.map +1 -0
  173. package/dist/auth/invitations/events.d.ts +46 -0
  174. package/dist/auth/invitations/events.d.ts.map +1 -0
  175. package/dist/auth/invitations/find-invitee.d.ts +20 -0
  176. package/dist/auth/invitations/find-invitee.d.ts.map +1 -0
  177. package/dist/auth/invitations/find-pending.d.ts +5 -0
  178. package/dist/auth/invitations/find-pending.d.ts.map +1 -0
  179. package/dist/auth/invitations/flows.d.ts +7 -0
  180. package/dist/auth/invitations/flows.d.ts.map +1 -0
  181. package/dist/auth/invitations/history-input.d.ts +29 -0
  182. package/dist/auth/invitations/history-input.d.ts.map +1 -0
  183. package/dist/auth/invitations/history.d.ts +10 -0
  184. package/dist/auth/invitations/history.d.ts.map +1 -0
  185. package/dist/auth/invitations/index.d.ts +11 -0
  186. package/dist/auth/invitations/index.d.ts.map +1 -0
  187. package/dist/auth/invitations/input.d.ts +30 -0
  188. package/dist/auth/invitations/input.d.ts.map +1 -0
  189. package/dist/auth/invitations/invited-type.d.ts +22 -0
  190. package/dist/auth/invitations/invited-type.d.ts.map +1 -0
  191. package/dist/auth/invitations/invitee.d.ts +11 -0
  192. package/dist/auth/invitations/invitee.d.ts.map +1 -0
  193. package/dist/auth/invitations/issue.d.ts +9 -0
  194. package/dist/auth/invitations/issue.d.ts.map +1 -0
  195. package/dist/auth/invitations/limit.d.ts +7 -0
  196. package/dist/auth/invitations/limit.d.ts.map +1 -0
  197. package/dist/auth/invitations/password-invitee.d.ts +18 -0
  198. package/dist/auth/invitations/password-invitee.d.ts.map +1 -0
  199. package/dist/auth/invitations/passwordless-invitee.d.ts +13 -0
  200. package/dist/auth/invitations/passwordless-invitee.d.ts.map +1 -0
  201. package/dist/auth/invitations/preview.d.ts +8 -0
  202. package/dist/auth/invitations/preview.d.ts.map +1 -0
  203. package/dist/auth/invitations/read.d.ts +10 -0
  204. package/dist/auth/invitations/read.d.ts.map +1 -0
  205. package/dist/auth/invitations/resend.d.ts +12 -0
  206. package/dist/auth/invitations/resend.d.ts.map +1 -0
  207. package/dist/auth/invitations/to-invitation.d.ts +11 -0
  208. package/dist/auth/invitations/to-invitation.d.ts.map +1 -0
  209. package/dist/auth/invitations/write.d.ts +17 -0
  210. package/dist/auth/invitations/write.d.ts.map +1 -0
  211. package/dist/auth/issuers/cache.d.ts +21 -0
  212. package/dist/auth/issuers/cache.d.ts.map +1 -0
  213. package/dist/auth/issuers/create.d.ts +18 -0
  214. package/dist/auth/issuers/create.d.ts.map +1 -0
  215. package/dist/auth/issuers/index.d.ts +3 -0
  216. package/dist/auth/issuers/index.d.ts.map +1 -0
  217. package/dist/auth/issuers/types.d.ts +45 -0
  218. package/dist/auth/issuers/types.d.ts.map +1 -0
  219. package/dist/auth/janus.d.ts +39 -0
  220. package/dist/auth/janus.d.ts.map +1 -0
  221. package/dist/auth/magic-link.d.ts +25 -0
  222. package/dist/auth/magic-link.d.ts.map +1 -0
  223. package/dist/auth/mail-requests.d.ts +55 -0
  224. package/dist/auth/mail-requests.d.ts.map +1 -0
  225. package/dist/auth/one-time/codes.d.ts +46 -0
  226. package/dist/auth/one-time/codes.d.ts.map +1 -0
  227. package/dist/auth/one-time/index.d.ts +15 -0
  228. package/dist/auth/one-time/index.d.ts.map +1 -0
  229. package/dist/auth/one-time/issue.d.ts +45 -0
  230. package/dist/auth/one-time/issue.d.ts.map +1 -0
  231. package/dist/auth/one-time/refusals.d.ts +26 -0
  232. package/dist/auth/one-time/refusals.d.ts.map +1 -0
  233. package/dist/auth/one-time/spend.d.ts +24 -0
  234. package/dist/auth/one-time/spend.d.ts.map +1 -0
  235. package/dist/auth/one-time/window.d.ts +50 -0
  236. package/dist/auth/one-time/window.d.ts.map +1 -0
  237. package/dist/auth/outage.d.ts +66 -0
  238. package/dist/auth/outage.d.ts.map +1 -0
  239. package/dist/auth/parse-sealing-keys.d.ts +26 -0
  240. package/dist/auth/parse-sealing-keys.d.ts.map +1 -0
  241. package/dist/auth/passkeys/assert.d.ts +51 -0
  242. package/dist/auth/passkeys/assert.d.ts.map +1 -0
  243. package/dist/auth/passkeys/assertion-options.d.ts +9 -0
  244. package/dist/auth/passkeys/assertion-options.d.ts.map +1 -0
  245. package/dist/auth/passkeys/challenge.d.ts +19 -0
  246. package/dist/auth/passkeys/challenge.d.ts.map +1 -0
  247. package/dist/auth/passkeys/commit.d.ts +33 -0
  248. package/dist/auth/passkeys/commit.d.ts.map +1 -0
  249. package/dist/auth/passkeys/flows.d.ts +13 -0
  250. package/dist/auth/passkeys/flows.d.ts.map +1 -0
  251. package/dist/auth/passkeys/index.d.ts +12 -0
  252. package/dist/auth/passkeys/index.d.ts.map +1 -0
  253. package/dist/auth/passkeys/manage.d.ts +11 -0
  254. package/dist/auth/passkeys/manage.d.ts.map +1 -0
  255. package/dist/auth/passkeys/name.d.ts +4 -0
  256. package/dist/auth/passkeys/name.d.ts.map +1 -0
  257. package/dist/auth/passkeys/register.d.ts +20 -0
  258. package/dist/auth/passkeys/register.d.ts.map +1 -0
  259. package/dist/auth/passkeys/registration-options.d.ts +22 -0
  260. package/dist/auth/passkeys/registration-options.d.ts.map +1 -0
  261. package/dist/auth/passkeys/remove-all.d.ts +26 -0
  262. package/dist/auth/passkeys/remove-all.d.ts.map +1 -0
  263. package/dist/auth/passkeys/sign-in-options.d.ts +12 -0
  264. package/dist/auth/passkeys/sign-in-options.d.ts.map +1 -0
  265. package/dist/auth/passkeys/sign-in.d.ts +21 -0
  266. package/dist/auth/passkeys/sign-in.d.ts.map +1 -0
  267. package/dist/auth/passkeys/verifier.d.ts +113 -0
  268. package/dist/auth/passkeys/verifier.d.ts.map +1 -0
  269. package/dist/auth/passkeys/view.d.ts +5 -0
  270. package/dist/auth/passkeys/view.d.ts.map +1 -0
  271. package/dist/auth/passkeys/wiring.d.ts +24 -0
  272. package/dist/auth/passkeys/wiring.d.ts.map +1 -0
  273. package/dist/auth/password-written.d.ts +55 -0
  274. package/dist/auth/password-written.d.ts.map +1 -0
  275. package/dist/auth/port/assert-api-keys.d.ts +21 -0
  276. package/dist/auth/port/assert-api-keys.d.ts.map +1 -0
  277. package/dist/auth/port/assert-invitations.d.ts +15 -0
  278. package/dist/auth/port/assert-invitations.d.ts.map +1 -0
  279. package/dist/auth/port/assert-stores.d.ts +16 -0
  280. package/dist/auth/port/assert-stores.d.ts.map +1 -0
  281. package/dist/auth/port/memory/api-keys/capabilities.d.ts +8 -0
  282. package/dist/auth/port/memory/api-keys/capabilities.d.ts.map +1 -0
  283. package/dist/auth/port/memory/api-keys/index.d.ts +13 -0
  284. package/dist/auth/port/memory/api-keys/index.d.ts.map +1 -0
  285. package/dist/auth/port/memory/api-keys/pages.d.ts +7 -0
  286. package/dist/auth/port/memory/api-keys/pages.d.ts.map +1 -0
  287. package/dist/auth/port/memory/copy.d.ts +6 -0
  288. package/dist/auth/port/memory/copy.d.ts.map +1 -0
  289. package/dist/auth/port/memory/index.d.ts +10 -0
  290. package/dist/auth/port/memory/index.d.ts.map +1 -0
  291. package/dist/auth/port/memory/invitations-pending.d.ts +6 -0
  292. package/dist/auth/port/memory/invitations-pending.d.ts.map +1 -0
  293. package/dist/auth/port/memory/invitations.d.ts +12 -0
  294. package/dist/auth/port/memory/invitations.d.ts.map +1 -0
  295. package/dist/auth/port/memory/passkeys.d.ts +9 -0
  296. package/dist/auth/port/memory/passkeys.d.ts.map +1 -0
  297. package/dist/auth/port/memory/sessions.d.ts +4 -0
  298. package/dist/auth/port/memory/sessions.d.ts.map +1 -0
  299. package/dist/auth/port/memory/social-links.d.ts +10 -0
  300. package/dist/auth/port/memory/social-links.d.ts.map +1 -0
  301. package/dist/auth/port/memory/stores.d.ts +26 -0
  302. package/dist/auth/port/memory/stores.d.ts.map +1 -0
  303. package/dist/auth/port/memory/tokens.d.ts +4 -0
  304. package/dist/auth/port/memory/tokens.d.ts.map +1 -0
  305. package/dist/auth/port/memory/user-index.d.ts +20 -0
  306. package/dist/auth/port/memory/user-index.d.ts.map +1 -0
  307. package/dist/auth/port/memory/user-update.d.ts +10 -0
  308. package/dist/auth/port/memory/user-update.d.ts.map +1 -0
  309. package/dist/auth/port/memory/users.d.ts +4 -0
  310. package/dist/auth/port/memory/users.d.ts.map +1 -0
  311. package/dist/auth/port/types/api-keys.d.ts +199 -0
  312. package/dist/auth/port/types/api-keys.d.ts.map +1 -0
  313. package/dist/auth/port/types/credentials.d.ts +46 -0
  314. package/dist/auth/port/types/credentials.d.ts.map +1 -0
  315. package/dist/auth/port/types/index.d.ts +75 -0
  316. package/dist/auth/port/types/index.d.ts.map +1 -0
  317. package/dist/auth/port/types/invitations/index.d.ts +15 -0
  318. package/dist/auth/port/types/invitations/index.d.ts.map +1 -0
  319. package/dist/auth/port/types/invitations/page.d.ts +52 -0
  320. package/dist/auth/port/types/invitations/page.d.ts.map +1 -0
  321. package/dist/auth/port/types/invitations/records.d.ts +101 -0
  322. package/dist/auth/port/types/invitations/records.d.ts.map +1 -0
  323. package/dist/auth/port/types/invitations/store.d.ts +82 -0
  324. package/dist/auth/port/types/invitations/store.d.ts.map +1 -0
  325. package/dist/auth/port/types/json.d.ts +27 -0
  326. package/dist/auth/port/types/json.d.ts.map +1 -0
  327. package/dist/auth/port/types/passkeys.d.ts +94 -0
  328. package/dist/auth/port/types/passkeys.d.ts.map +1 -0
  329. package/dist/auth/port/types/sessions.d.ts +142 -0
  330. package/dist/auth/port/types/sessions.d.ts.map +1 -0
  331. package/dist/auth/port/types/social-links.d.ts +64 -0
  332. package/dist/auth/port/types/social-links.d.ts.map +1 -0
  333. package/dist/auth/port/types/stores.d.ts +48 -0
  334. package/dist/auth/port/types/stores.d.ts.map +1 -0
  335. package/dist/auth/port/types/tokens.d.ts +168 -0
  336. package/dist/auth/port/types/tokens.d.ts.map +1 -0
  337. package/dist/auth/port/types/users.d.ts +260 -0
  338. package/dist/auth/port/types/users.d.ts.map +1 -0
  339. package/dist/auth/prepared.d.ts +21 -0
  340. package/dist/auth/prepared.d.ts.map +1 -0
  341. package/dist/auth/proven-sign-in.d.ts +22 -0
  342. package/dist/auth/proven-sign-in.d.ts.map +1 -0
  343. package/dist/auth/sealer-for.d.ts +44 -0
  344. package/dist/auth/sealer-for.d.ts.map +1 -0
  345. package/dist/auth/sealing.d.ts +36 -0
  346. package/dist/auth/sealing.d.ts.map +1 -0
  347. package/dist/auth/second-factor/activate.d.ts +9 -0
  348. package/dist/auth/second-factor/activate.d.ts.map +1 -0
  349. package/dist/auth/second-factor/app-code-attempts.d.ts +47 -0
  350. package/dist/auth/second-factor/app-code-attempts.d.ts.map +1 -0
  351. package/dist/auth/second-factor/challenge.d.ts +15 -0
  352. package/dist/auth/second-factor/challenge.d.ts.map +1 -0
  353. package/dist/auth/second-factor/codes-left.d.ts +14 -0
  354. package/dist/auth/second-factor/codes-left.d.ts.map +1 -0
  355. package/dist/auth/second-factor/disable.d.ts +10 -0
  356. package/dist/auth/second-factor/disable.d.ts.map +1 -0
  357. package/dist/auth/second-factor/enroll.d.ts +6 -0
  358. package/dist/auth/second-factor/enroll.d.ts.map +1 -0
  359. package/dist/auth/second-factor/factor.d.ts +33 -0
  360. package/dist/auth/second-factor/factor.d.ts.map +1 -0
  361. package/dist/auth/second-factor/flows.d.ts +36 -0
  362. package/dist/auth/second-factor/flows.d.ts.map +1 -0
  363. package/dist/auth/second-factor/lifecycle.d.ts +14 -0
  364. package/dist/auth/second-factor/lifecycle.d.ts.map +1 -0
  365. package/dist/auth/second-factor/passkey-confirm.d.ts +21 -0
  366. package/dist/auth/second-factor/passkey-confirm.d.ts.map +1 -0
  367. package/dist/auth/second-factor/recovery-codes.d.ts +36 -0
  368. package/dist/auth/second-factor/recovery-codes.d.ts.map +1 -0
  369. package/dist/auth/second-factor/recovery.d.ts +20 -0
  370. package/dist/auth/second-factor/recovery.d.ts.map +1 -0
  371. package/dist/auth/second-factor/redeem.d.ts +42 -0
  372. package/dist/auth/second-factor/redeem.d.ts.map +1 -0
  373. package/dist/auth/second-factor/refusal.d.ts +6 -0
  374. package/dist/auth/second-factor/refusal.d.ts.map +1 -0
  375. package/dist/auth/second-factor/regenerate.d.ts +12 -0
  376. package/dist/auth/second-factor/regenerate.d.ts.map +1 -0
  377. package/dist/auth/second-factor/reseal.d.ts +17 -0
  378. package/dist/auth/second-factor/reseal.d.ts.map +1 -0
  379. package/dist/auth/second-factor/spend-recovery-code.d.ts +15 -0
  380. package/dist/auth/second-factor/spend-recovery-code.d.ts.map +1 -0
  381. package/dist/auth/secrets.d.ts +17 -0
  382. package/dist/auth/secrets.d.ts.map +1 -0
  383. package/dist/auth/sessions/amr.d.ts +36 -0
  384. package/dist/auth/sessions/amr.d.ts.map +1 -0
  385. package/dist/auth/sessions/authenticate.d.ts +12 -0
  386. package/dist/auth/sessions/authenticate.d.ts.map +1 -0
  387. package/dist/auth/sessions/collect-expired.d.ts +15 -0
  388. package/dist/auth/sessions/collect-expired.d.ts.map +1 -0
  389. package/dist/auth/sessions/cookie.d.ts +9 -0
  390. package/dist/auth/sessions/cookie.d.ts.map +1 -0
  391. package/dist/auth/sessions/fresh.d.ts +35 -0
  392. package/dist/auth/sessions/fresh.d.ts.map +1 -0
  393. package/dist/auth/sessions/index.d.ts +12 -0
  394. package/dist/auth/sessions/index.d.ts.map +1 -0
  395. package/dist/auth/sessions/open-session.d.ts +22 -0
  396. package/dist/auth/sessions/open-session.d.ts.map +1 -0
  397. package/dist/auth/sessions/presented-token.d.ts +25 -0
  398. package/dist/auth/sessions/presented-token.d.ts.map +1 -0
  399. package/dist/auth/sessions/shared-api.d.ts +17 -0
  400. package/dist/auth/sessions/shared-api.d.ts.map +1 -0
  401. package/dist/auth/sessions/standing.d.ts +32 -0
  402. package/dist/auth/sessions/standing.d.ts.map +1 -0
  403. package/dist/auth/shared-api.d.ts +139 -0
  404. package/dist/auth/shared-api.d.ts.map +1 -0
  405. package/dist/auth/sign-in-attempts.d.ts +45 -0
  406. package/dist/auth/sign-in-attempts.d.ts.map +1 -0
  407. package/dist/auth/sign-in-code.d.ts +26 -0
  408. package/dist/auth/sign-in-code.d.ts.map +1 -0
  409. package/dist/auth/social/attach.d.ts +31 -0
  410. package/dist/auth/social/attach.d.ts.map +1 -0
  411. package/dist/auth/social/begin.d.ts +30 -0
  412. package/dist/auth/social/begin.d.ts.map +1 -0
  413. package/dist/auth/social/complete-link.d.ts +17 -0
  414. package/dist/auth/social/complete-link.d.ts.map +1 -0
  415. package/dist/auth/social/complete.d.ts +54 -0
  416. package/dist/auth/social/complete.d.ts.map +1 -0
  417. package/dist/auth/social/cookie.d.ts +16 -0
  418. package/dist/auth/social/cookie.d.ts.map +1 -0
  419. package/dist/auth/social/find-provider.d.ts +23 -0
  420. package/dist/auth/social/find-provider.d.ts.map +1 -0
  421. package/dist/auth/social/finish.d.ts +60 -0
  422. package/dist/auth/social/finish.d.ts.map +1 -0
  423. package/dist/auth/social/flow-cookie-value.d.ts +26 -0
  424. package/dist/auth/social/flow-cookie-value.d.ts.map +1 -0
  425. package/dist/auth/social/flow-secret.d.ts +40 -0
  426. package/dist/auth/social/flow-secret.d.ts.map +1 -0
  427. package/dist/auth/social/index.d.ts +19 -0
  428. package/dist/auth/social/index.d.ts.map +1 -0
  429. package/dist/auth/social/link-holder.d.ts +33 -0
  430. package/dist/auth/social/link-holder.d.ts.map +1 -0
  431. package/dist/auth/social/provider-call.d.ts +31 -0
  432. package/dist/auth/social/provider-call.d.ts.map +1 -0
  433. package/dist/auth/social/redeem.d.ts +45 -0
  434. package/dist/auth/social/redeem.d.ts.map +1 -0
  435. package/dist/auth/social/return-to.d.ts +18 -0
  436. package/dist/auth/social/return-to.d.ts.map +1 -0
  437. package/dist/auth/social/sign-in.d.ts +41 -0
  438. package/dist/auth/social/sign-in.d.ts.map +1 -0
  439. package/dist/auth/social/sign-up.d.ts +37 -0
  440. package/dist/auth/social/sign-up.d.ts.map +1 -0
  441. package/dist/auth/social/start.d.ts +21 -0
  442. package/dist/auth/social/start.d.ts.map +1 -0
  443. package/dist/auth/social/step-up-proof.d.ts +26 -0
  444. package/dist/auth/social/step-up-proof.d.ts.map +1 -0
  445. package/dist/auth/social/step-up-request.d.ts +28 -0
  446. package/dist/auth/social/step-up-request.d.ts.map +1 -0
  447. package/dist/auth/social/step-up.d.ts +19 -0
  448. package/dist/auth/social/step-up.d.ts.map +1 -0
  449. package/dist/auth/social/types-of.d.ts +12 -0
  450. package/dist/auth/social/types-of.d.ts.map +1 -0
  451. package/dist/auth/social/unlink.d.ts +16 -0
  452. package/dist/auth/social/unlink.d.ts.map +1 -0
  453. package/dist/auth/social/wiring.d.ts +10 -0
  454. package/dist/auth/social/wiring.d.ts.map +1 -0
  455. package/dist/auth/standard-schema.d.ts +41 -0
  456. package/dist/auth/standard-schema.d.ts.map +1 -0
  457. package/dist/auth/step-up/codes.d.ts +35 -0
  458. package/dist/auth/step-up/codes.d.ts.map +1 -0
  459. package/dist/auth/step-up/flows.d.ts +18 -0
  460. package/dist/auth/step-up/flows.d.ts.map +1 -0
  461. package/dist/auth/step-up/open.d.ts +23 -0
  462. package/dist/auth/step-up/open.d.ts.map +1 -0
  463. package/dist/auth/step-up/passkey.d.ts +31 -0
  464. package/dist/auth/step-up/passkey.d.ts.map +1 -0
  465. package/dist/auth/step-up/request.d.ts +15 -0
  466. package/dist/auth/step-up/request.d.ts.map +1 -0
  467. package/dist/auth/step-up/spend.d.ts +4 -0
  468. package/dist/auth/step-up/spend.d.ts.map +1 -0
  469. package/dist/auth/totp.d.ts +36 -0
  470. package/dist/auth/totp.d.ts.map +1 -0
  471. package/dist/auth/types/api-keys-of.d.ts +19 -0
  472. package/dist/auth/types/api-keys-of.d.ts.map +1 -0
  473. package/dist/auth/types/api-keys.d.ts +164 -0
  474. package/dist/auth/types/api-keys.d.ts.map +1 -0
  475. package/dist/auth/types/avatar.d.ts +72 -0
  476. package/dist/auth/types/avatar.d.ts.map +1 -0
  477. package/dist/auth/types/change-email.d.ts +82 -0
  478. package/dist/auth/types/change-email.d.ts.map +1 -0
  479. package/dist/auth/types/checks.d.ts +147 -0
  480. package/dist/auth/types/checks.d.ts.map +1 -0
  481. package/dist/auth/types/email-flows.d.ts +117 -0
  482. package/dist/auth/types/email-flows.d.ts.map +1 -0
  483. package/dist/auth/types/find-by-email.d.ts +31 -0
  484. package/dist/auth/types/find-by-email.d.ts.map +1 -0
  485. package/dist/auth/types/find-or-create.d.ts +59 -0
  486. package/dist/auth/types/find-or-create.d.ts.map +1 -0
  487. package/dist/auth/types/index.d.ts +38 -0
  488. package/dist/auth/types/index.d.ts.map +1 -0
  489. package/dist/auth/types/inference.d.ts +62 -0
  490. package/dist/auth/types/inference.d.ts.map +1 -0
  491. package/dist/auth/types/invitations/api.d.ts +203 -0
  492. package/dist/auth/types/invitations/api.d.ts.map +1 -0
  493. package/dist/auth/types/invitations/history.d.ts +87 -0
  494. package/dist/auth/types/invitations/history.d.ts.map +1 -0
  495. package/dist/auth/types/invitations/index.d.ts +10 -0
  496. package/dist/auth/types/invitations/index.d.ts.map +1 -0
  497. package/dist/auth/types/invitations/invitation.d.ts +76 -0
  498. package/dist/auth/types/invitations/invitation.d.ts.map +1 -0
  499. package/dist/auth/types/invitations/issue-type.d.ts +15 -0
  500. package/dist/auth/types/invitations/issue-type.d.ts.map +1 -0
  501. package/dist/auth/types/invitations-of.d.ts +26 -0
  502. package/dist/auth/types/invitations-of.d.ts.map +1 -0
  503. package/dist/auth/types/janus.d.ts +51 -0
  504. package/dist/auth/types/janus.d.ts.map +1 -0
  505. package/dist/auth/types/magic-link.d.ts +69 -0
  506. package/dist/auth/types/magic-link.d.ts.map +1 -0
  507. package/dist/auth/types/passkeys.d.ts +183 -0
  508. package/dist/auth/types/passkeys.d.ts.map +1 -0
  509. package/dist/auth/types/password.d.ts +113 -0
  510. package/dist/auth/types/password.d.ts.map +1 -0
  511. package/dist/auth/types/prepared.d.ts +68 -0
  512. package/dist/auth/types/prepared.d.ts.map +1 -0
  513. package/dist/auth/types/proven-sign-in.d.ts +43 -0
  514. package/dist/auth/types/proven-sign-in.d.ts.map +1 -0
  515. package/dist/auth/types/reset-password.d.ts +46 -0
  516. package/dist/auth/types/reset-password.d.ts.map +1 -0
  517. package/dist/auth/types/second-factor.d.ts +164 -0
  518. package/dist/auth/types/second-factor.d.ts.map +1 -0
  519. package/dist/auth/types/session.d.ts +68 -0
  520. package/dist/auth/types/session.d.ts.map +1 -0
  521. package/dist/auth/types/shared-api.d.ts +96 -0
  522. package/dist/auth/types/shared-api.d.ts.map +1 -0
  523. package/dist/auth/types/sign-in.d.ts +102 -0
  524. package/dist/auth/types/sign-in.d.ts.map +1 -0
  525. package/dist/auth/types/social-flow.d.ts +28 -0
  526. package/dist/auth/types/social-flow.d.ts.map +1 -0
  527. package/dist/auth/types/social-step-up.d.ts +38 -0
  528. package/dist/auth/types/social-step-up.d.ts.map +1 -0
  529. package/dist/auth/types/social.d.ts +193 -0
  530. package/dist/auth/types/social.d.ts.map +1 -0
  531. package/dist/auth/types/step-up.d.ts +133 -0
  532. package/dist/auth/types/step-up.d.ts.map +1 -0
  533. package/dist/auth/types/type-api.d.ts +29 -0
  534. package/dist/auth/types/type-api.d.ts.map +1 -0
  535. package/dist/auth/types/user-type.d.ts +106 -0
  536. package/dist/auth/types/user-type.d.ts.map +1 -0
  537. package/dist/auth/types/user.d.ts +62 -0
  538. package/dist/auth/types/user.d.ts.map +1 -0
  539. package/dist/auth/types/verify-email.d.ts +190 -0
  540. package/dist/auth/types/verify-email.d.ts.map +1 -0
  541. package/dist/auth/users/any-type-api.d.ts +6 -0
  542. package/dist/auth/users/any-type-api.d.ts.map +1 -0
  543. package/dist/auth/users/by-login.d.ts +10 -0
  544. package/dist/auth/users/by-login.d.ts.map +1 -0
  545. package/dist/auth/users/change-password.d.ts +26 -0
  546. package/dist/auth/users/change-password.d.ts.map +1 -0
  547. package/dist/auth/users/delete.d.ts +10 -0
  548. package/dist/auth/users/delete.d.ts.map +1 -0
  549. package/dist/auth/users/email-move-guard.d.ts +20 -0
  550. package/dist/auth/users/email-move-guard.d.ts.map +1 -0
  551. package/dist/auth/users/email-prefix.d.ts +23 -0
  552. package/dist/auth/users/email-prefix.d.ts.map +1 -0
  553. package/dist/auth/users/fields-patch.d.ts +21 -0
  554. package/dist/auth/users/fields-patch.d.ts.map +1 -0
  555. package/dist/auth/users/find-by-email.d.ts +11 -0
  556. package/dist/auth/users/find-by-email.d.ts.map +1 -0
  557. package/dist/auth/users/find-many.d.ts +29 -0
  558. package/dist/auth/users/find-many.d.ts.map +1 -0
  559. package/dist/auth/users/find-or-create.d.ts +12 -0
  560. package/dist/auth/users/find-or-create.d.ts.map +1 -0
  561. package/dist/auth/users/flow-types.d.ts +15 -0
  562. package/dist/auth/users/flow-types.d.ts.map +1 -0
  563. package/dist/auth/users/index.d.ts +9 -0
  564. package/dist/auth/users/index.d.ts.map +1 -0
  565. package/dist/auth/users/insert.d.ts +15 -0
  566. package/dist/auth/users/insert.d.ts.map +1 -0
  567. package/dist/auth/users/name-prefix.d.ts +19 -0
  568. package/dist/auth/users/name-prefix.d.ts.map +1 -0
  569. package/dist/auth/users/password-flows.d.ts +11 -0
  570. package/dist/auth/users/password-flows.d.ts.map +1 -0
  571. package/dist/auth/users/record-flows.d.ts +11 -0
  572. package/dist/auth/users/record-flows.d.ts.map +1 -0
  573. package/dist/auth/users/sign-in.d.ts +24 -0
  574. package/dist/auth/users/sign-in.d.ts.map +1 -0
  575. package/dist/auth/users/sign-up.d.ts +13 -0
  576. package/dist/auth/users/sign-up.d.ts.map +1 -0
  577. package/dist/auth/users/type-api.d.ts +10 -0
  578. package/dist/auth/users/type-api.d.ts.map +1 -0
  579. package/dist/auth/users/update.d.ts +16 -0
  580. package/dist/auth/users/update.d.ts.map +1 -0
  581. package/dist/background/background.d.ts +22 -0
  582. package/dist/background/background.d.ts.map +1 -0
  583. package/dist/chunks/index-2ttdcz7n.js +354 -0
  584. package/dist/chunks/index-2ttdcz7n.js.map +16 -0
  585. package/dist/chunks/index-5dxynm32.js +85 -0
  586. package/dist/chunks/index-5dxynm32.js.map +10 -0
  587. package/dist/chunks/index-ftz0ne6j.js +127 -0
  588. package/dist/chunks/index-ftz0ne6j.js.map +11 -0
  589. package/dist/chunks/index-k6y18nx9.js +724 -0
  590. package/dist/chunks/index-k6y18nx9.js.map +24 -0
  591. package/dist/chunks/index-n8jxmxeg.js +64 -0
  592. package/dist/chunks/index-n8jxmxeg.js.map +11 -0
  593. package/dist/conformance/api-keys/cases/bound.d.ts +3 -0
  594. package/dist/conformance/api-keys/cases/bound.d.ts.map +1 -0
  595. package/dist/conformance/api-keys/cases/expiry.d.ts +3 -0
  596. package/dist/conformance/api-keys/cases/expiry.d.ts.map +1 -0
  597. package/dist/conformance/api-keys/cases/index.d.ts +4 -0
  598. package/dist/conformance/api-keys/cases/index.d.ts.map +1 -0
  599. package/dist/conformance/api-keys/cases/insert.d.ts +3 -0
  600. package/dist/conformance/api-keys/cases/insert.d.ts.map +1 -0
  601. package/dist/conformance/api-keys/cases/outage.d.ts +3 -0
  602. package/dist/conformance/api-keys/cases/outage.d.ts.map +1 -0
  603. package/dist/conformance/api-keys/cases/revoke.d.ts +3 -0
  604. package/dist/conformance/api-keys/cases/revoke.d.ts.map +1 -0
  605. package/dist/conformance/api-keys/cases/touch.d.ts +3 -0
  606. package/dist/conformance/api-keys/cases/touch.d.ts.map +1 -0
  607. package/dist/conformance/api-keys/cases/user-bound.d.ts +3 -0
  608. package/dist/conformance/api-keys/cases/user-bound.d.ts.map +1 -0
  609. package/dist/conformance/api-keys/describe.d.ts +20 -0
  610. package/dist/conformance/api-keys/describe.d.ts.map +1 -0
  611. package/dist/conformance/api-keys/fixtures.d.ts +4 -0
  612. package/dist/conformance/api-keys/fixtures.d.ts.map +1 -0
  613. package/dist/conformance/api-keys/index.d.ts +18 -0
  614. package/dist/conformance/api-keys/index.d.ts.map +1 -0
  615. package/dist/conformance/api-keys/reference.d.ts +4 -0
  616. package/dist/conformance/api-keys/reference.d.ts.map +1 -0
  617. package/dist/conformance/api-keys/types.d.ts +42 -0
  618. package/dist/conformance/api-keys/types.d.ts.map +1 -0
  619. package/dist/conformance/assert.d.ts +40 -0
  620. package/dist/conformance/assert.d.ts.map +1 -0
  621. package/dist/conformance/cases/outage.d.ts +3 -0
  622. package/dist/conformance/cases/outage.d.ts.map +1 -0
  623. package/dist/conformance/cases/outage.passkeys.d.ts +12 -0
  624. package/dist/conformance/cases/outage.passkeys.d.ts.map +1 -0
  625. package/dist/conformance/cases/passkeys/deletion.d.ts +4 -0
  626. package/dist/conformance/cases/passkeys/deletion.d.ts.map +1 -0
  627. package/dist/conformance/cases/passkeys/index.d.ts +8 -0
  628. package/dist/conformance/cases/passkeys/index.d.ts.map +1 -0
  629. package/dist/conformance/cases/passkeys/inserts.d.ts +4 -0
  630. package/dist/conformance/cases/passkeys/inserts.d.ts.map +1 -0
  631. package/dist/conformance/cases/passkeys/reads.d.ts +4 -0
  632. package/dist/conformance/cases/passkeys/reads.d.ts.map +1 -0
  633. package/dist/conformance/cases/passkeys/uses.d.ts +4 -0
  634. package/dist/conformance/cases/passkeys/uses.d.ts.map +1 -0
  635. package/dist/conformance/cases/sessions/deletion.d.ts +4 -0
  636. package/dist/conformance/cases/sessions/deletion.d.ts.map +1 -0
  637. package/dist/conformance/cases/sessions/extension.d.ts +4 -0
  638. package/dist/conformance/cases/sessions/extension.d.ts.map +1 -0
  639. package/dist/conformance/cases/sessions/index.d.ts +4 -0
  640. package/dist/conformance/cases/sessions/index.d.ts.map +1 -0
  641. package/dist/conformance/cases/sessions/inserts.d.ts +4 -0
  642. package/dist/conformance/cases/sessions/inserts.d.ts.map +1 -0
  643. package/dist/conformance/cases/sessions/list.d.ts +4 -0
  644. package/dist/conformance/cases/sessions/list.d.ts.map +1 -0
  645. package/dist/conformance/cases/sessions/reads.d.ts +4 -0
  646. package/dist/conformance/cases/sessions/reads.d.ts.map +1 -0
  647. package/dist/conformance/cases/sessions/reauthentication.d.ts +4 -0
  648. package/dist/conformance/cases/sessions/reauthentication.d.ts.map +1 -0
  649. package/dist/conformance/cases/sessions/revocation.d.ts +4 -0
  650. package/dist/conformance/cases/sessions/revocation.d.ts.map +1 -0
  651. package/dist/conformance/cases/social-links/deletion.d.ts +4 -0
  652. package/dist/conformance/cases/social-links/deletion.d.ts.map +1 -0
  653. package/dist/conformance/cases/social-links/index.d.ts +8 -0
  654. package/dist/conformance/cases/social-links/index.d.ts.map +1 -0
  655. package/dist/conformance/cases/social-links/inserts.d.ts +4 -0
  656. package/dist/conformance/cases/social-links/inserts.d.ts.map +1 -0
  657. package/dist/conformance/cases/social-links/reads.d.ts +4 -0
  658. package/dist/conformance/cases/social-links/reads.d.ts.map +1 -0
  659. package/dist/conformance/cases/tokens/attempts.d.ts +7 -0
  660. package/dist/conformance/cases/tokens/attempts.d.ts.map +1 -0
  661. package/dist/conformance/cases/tokens/change-email.d.ts +8 -0
  662. package/dist/conformance/cases/tokens/change-email.d.ts.map +1 -0
  663. package/dist/conformance/cases/tokens/deletion.d.ts +4 -0
  664. package/dist/conformance/cases/tokens/deletion.d.ts.map +1 -0
  665. package/dist/conformance/cases/tokens/index.d.ts +4 -0
  666. package/dist/conformance/cases/tokens/index.d.ts.map +1 -0
  667. package/dist/conformance/cases/tokens/inserts.d.ts +7 -0
  668. package/dist/conformance/cases/tokens/inserts.d.ts.map +1 -0
  669. package/dist/conformance/cases/tokens/kinds.d.ts +7 -0
  670. package/dist/conformance/cases/tokens/kinds.d.ts.map +1 -0
  671. package/dist/conformance/cases/tokens/redemption.d.ts +7 -0
  672. package/dist/conformance/cases/tokens/redemption.d.ts.map +1 -0
  673. package/dist/conformance/cases/tokens/social-flow.d.ts +8 -0
  674. package/dist/conformance/cases/tokens/social-flow.d.ts.map +1 -0
  675. package/dist/conformance/cases/tokens/spending.d.ts +7 -0
  676. package/dist/conformance/cases/tokens/spending.d.ts.map +1 -0
  677. package/dist/conformance/cases/users/avatar.d.ts +8 -0
  678. package/dist/conformance/cases/users/avatar.d.ts.map +1 -0
  679. package/dist/conformance/cases/users/batch.d.ts +8 -0
  680. package/dist/conformance/cases/users/batch.d.ts.map +1 -0
  681. package/dist/conformance/cases/users/deletion.d.ts +4 -0
  682. package/dist/conformance/cases/users/deletion.d.ts.map +1 -0
  683. package/dist/conformance/cases/users/index.d.ts +4 -0
  684. package/dist/conformance/cases/users/index.d.ts.map +1 -0
  685. package/dist/conformance/cases/users/inserts.d.ts +4 -0
  686. package/dist/conformance/cases/users/inserts.d.ts.map +1 -0
  687. package/dist/conformance/cases/users/listing.d.ts +4 -0
  688. package/dist/conformance/cases/users/listing.d.ts.map +1 -0
  689. package/dist/conformance/cases/users/patches.d.ts +7 -0
  690. package/dist/conformance/cases/users/patches.d.ts.map +1 -0
  691. package/dist/conformance/cases/users/reads.d.ts +7 -0
  692. package/dist/conformance/cases/users/reads.d.ts.map +1 -0
  693. package/dist/conformance/cases/users/second-factor.d.ts +16 -0
  694. package/dist/conformance/cases/users/second-factor.d.ts.map +1 -0
  695. package/dist/conformance/cases/users/versions.d.ts +7 -0
  696. package/dist/conformance/cases/users/versions.d.ts.map +1 -0
  697. package/dist/conformance/describe.d.ts +82 -0
  698. package/dist/conformance/describe.d.ts.map +1 -0
  699. package/dist/conformance/fixtures.d.ts +31 -0
  700. package/dist/conformance/fixtures.d.ts.map +1 -0
  701. package/dist/conformance/index.d.ts +46 -0
  702. package/dist/conformance/index.d.ts.map +1 -0
  703. package/dist/conformance/index.js +4411 -0
  704. package/dist/conformance/index.js.map +86 -0
  705. package/dist/conformance/invitations/cases/actors.d.ts +3 -0
  706. package/dist/conformance/invitations/cases/actors.d.ts.map +1 -0
  707. package/dist/conformance/invitations/cases/find-pending.d.ts +3 -0
  708. package/dist/conformance/invitations/cases/find-pending.d.ts.map +1 -0
  709. package/dist/conformance/invitations/cases/imported.d.ts +3 -0
  710. package/dist/conformance/invitations/cases/imported.d.ts.map +1 -0
  711. package/dist/conformance/invitations/cases/index.d.ts +4 -0
  712. package/dist/conformance/invitations/cases/index.d.ts.map +1 -0
  713. package/dist/conformance/invitations/cases/insert.d.ts +3 -0
  714. package/dist/conformance/invitations/cases/insert.d.ts.map +1 -0
  715. package/dist/conformance/invitations/cases/list-lapsed.d.ts +3 -0
  716. package/dist/conformance/invitations/cases/list-lapsed.d.ts.map +1 -0
  717. package/dist/conformance/invitations/cases/list-status.d.ts +3 -0
  718. package/dist/conformance/invitations/cases/list-status.d.ts.map +1 -0
  719. package/dist/conformance/invitations/cases/list.d.ts +3 -0
  720. package/dist/conformance/invitations/cases/list.d.ts.map +1 -0
  721. package/dist/conformance/invitations/cases/outage.d.ts +3 -0
  722. package/dist/conformance/invitations/cases/outage.d.ts.map +1 -0
  723. package/dist/conformance/invitations/cases/scope.d.ts +3 -0
  724. package/dist/conformance/invitations/cases/scope.d.ts.map +1 -0
  725. package/dist/conformance/invitations/cases/update.d.ts +3 -0
  726. package/dist/conformance/invitations/cases/update.d.ts.map +1 -0
  727. package/dist/conformance/invitations/describe.d.ts +20 -0
  728. package/dist/conformance/invitations/describe.d.ts.map +1 -0
  729. package/dist/conformance/invitations/fixtures.d.ts +4 -0
  730. package/dist/conformance/invitations/fixtures.d.ts.map +1 -0
  731. package/dist/conformance/invitations/index.d.ts +18 -0
  732. package/dist/conformance/invitations/index.d.ts.map +1 -0
  733. package/dist/conformance/invitations/reference.d.ts +4 -0
  734. package/dist/conformance/invitations/reference.d.ts.map +1 -0
  735. package/dist/conformance/invitations/types.d.ts +34 -0
  736. package/dist/conformance/invitations/types.d.ts.map +1 -0
  737. package/dist/conformance/reference.d.ts +13 -0
  738. package/dist/conformance/reference.d.ts.map +1 -0
  739. package/dist/conformance/relations/cases/deletion.d.ts +4 -0
  740. package/dist/conformance/relations/cases/deletion.d.ts.map +1 -0
  741. package/dist/conformance/relations/cases/holders.d.ts +9 -0
  742. package/dist/conformance/relations/cases/holders.d.ts.map +1 -0
  743. package/dist/conformance/relations/cases/index.d.ts +4 -0
  744. package/dist/conformance/relations/cases/index.d.ts.map +1 -0
  745. package/dist/conformance/relations/cases/outage.d.ts +3 -0
  746. package/dist/conformance/relations/cases/outage.d.ts.map +1 -0
  747. package/dist/conformance/relations/cases/reads.d.ts +8 -0
  748. package/dist/conformance/relations/cases/reads.d.ts.map +1 -0
  749. package/dist/conformance/relations/cases/traversal.d.ts +7 -0
  750. package/dist/conformance/relations/cases/traversal.d.ts.map +1 -0
  751. package/dist/conformance/relations/cases/writes.d.ts +4 -0
  752. package/dist/conformance/relations/cases/writes.d.ts.map +1 -0
  753. package/dist/conformance/relations/describe.d.ts +20 -0
  754. package/dist/conformance/relations/describe.d.ts.map +1 -0
  755. package/dist/conformance/relations/fixtures.d.ts +8 -0
  756. package/dist/conformance/relations/fixtures.d.ts.map +1 -0
  757. package/dist/conformance/relations/index.d.ts +18 -0
  758. package/dist/conformance/relations/index.d.ts.map +1 -0
  759. package/dist/conformance/relations/reference.d.ts +4 -0
  760. package/dist/conformance/relations/reference.d.ts.map +1 -0
  761. package/dist/conformance/relations/types.d.ts +34 -0
  762. package/dist/conformance/relations/types.d.ts.map +1 -0
  763. package/dist/conformance/types.d.ts +79 -0
  764. package/dist/conformance/types.d.ts.map +1 -0
  765. package/dist/errors/janus-error/base.d.ts +47 -0
  766. package/dist/errors/janus-error/base.d.ts.map +1 -0
  767. package/dist/errors/janus-error/codes.credentials.d.ts +36 -0
  768. package/dist/errors/janus-error/codes.credentials.d.ts.map +1 -0
  769. package/dist/errors/janus-error/codes.d.ts +23 -0
  770. package/dist/errors/janus-error/codes.d.ts.map +1 -0
  771. package/dist/errors/janus-error/codes.invitations.d.ts +52 -0
  772. package/dist/errors/janus-error/codes.invitations.d.ts.map +1 -0
  773. package/dist/errors/janus-error/codes.one-time.d.ts +63 -0
  774. package/dist/errors/janus-error/codes.one-time.d.ts.map +1 -0
  775. package/dist/errors/janus-error/codes.records.d.ts +86 -0
  776. package/dist/errors/janus-error/codes.records.d.ts.map +1 -0
  777. package/dist/errors/janus-error/codes.social.d.ts +88 -0
  778. package/dist/errors/janus-error/codes.social.d.ts.map +1 -0
  779. package/dist/errors/janus-error/index.d.ts +17 -0
  780. package/dist/errors/janus-error/index.d.ts.map +1 -0
  781. package/dist/errors/janus-error/options.d.ts +105 -0
  782. package/dist/errors/janus-error/options.d.ts.map +1 -0
  783. package/dist/errors/janus-error/refusals.d.ts +151 -0
  784. package/dist/errors/janus-error/refusals.d.ts.map +1 -0
  785. package/dist/errors/janus-error/status.d.ts +21 -0
  786. package/dist/errors/janus-error/status.d.ts.map +1 -0
  787. package/dist/errors/janus-error/store.d.ts +36 -0
  788. package/dist/errors/janus-error/store.d.ts.map +1 -0
  789. package/dist/ids/derived.d.ts +25 -0
  790. package/dist/ids/derived.d.ts.map +1 -0
  791. package/dist/ids/id.d.ts +55 -0
  792. package/dist/ids/id.d.ts.map +1 -0
  793. package/dist/index.d.ts +32 -0
  794. package/dist/index.d.ts.map +1 -0
  795. package/dist/index.js +6933 -0
  796. package/dist/index.js.map +208 -0
  797. package/dist/pagination/cursor-page.d.ts +53 -0
  798. package/dist/pagination/cursor-page.d.ts.map +1 -0
  799. package/dist/permissions/bound-model.d.ts +10 -0
  800. package/dist/permissions/bound-model.d.ts.map +1 -0
  801. package/dist/permissions/can.d.ts +13 -0
  802. package/dist/permissions/can.d.ts.map +1 -0
  803. package/dist/permissions/engine.d.ts +49 -0
  804. package/dist/permissions/engine.d.ts.map +1 -0
  805. package/dist/permissions/holders.d.ts +12 -0
  806. package/dist/permissions/holders.d.ts.map +1 -0
  807. package/dist/permissions/index.d.ts +36 -0
  808. package/dist/permissions/index.d.ts.map +1 -0
  809. package/dist/permissions/index.js +924 -0
  810. package/dist/permissions/index.js.map +28 -0
  811. package/dist/permissions/input.d.ts +43 -0
  812. package/dist/permissions/input.d.ts.map +1 -0
  813. package/dist/permissions/list.d.ts +16 -0
  814. package/dist/permissions/list.d.ts.map +1 -0
  815. package/dist/permissions/model/can.d.ts +41 -0
  816. package/dist/permissions/model/can.d.ts.map +1 -0
  817. package/dist/permissions/model/config.d.ts +36 -0
  818. package/dist/permissions/model/config.d.ts.map +1 -0
  819. package/dist/permissions/model/constraint.d.ts +37 -0
  820. package/dist/permissions/model/constraint.d.ts.map +1 -0
  821. package/dist/permissions/model/ctx.d.ts +23 -0
  822. package/dist/permissions/model/ctx.d.ts.map +1 -0
  823. package/dist/permissions/model/define.d.ts +78 -0
  824. package/dist/permissions/model/define.d.ts.map +1 -0
  825. package/dist/permissions/model/from-field.d.ts +31 -0
  826. package/dist/permissions/model/from-field.d.ts.map +1 -0
  827. package/dist/permissions/model/grant.d.ts +81 -0
  828. package/dist/permissions/model/grant.d.ts.map +1 -0
  829. package/dist/permissions/model/list.d.ts +48 -0
  830. package/dist/permissions/model/list.d.ts.map +1 -0
  831. package/dist/permissions/model/names.d.ts +51 -0
  832. package/dist/permissions/model/names.d.ts.map +1 -0
  833. package/dist/permissions/model/permissions.d.ts +48 -0
  834. package/dist/permissions/model/permissions.d.ts.map +1 -0
  835. package/dist/permissions/model/refs.d.ts +36 -0
  836. package/dist/permissions/model/refs.d.ts.map +1 -0
  837. package/dist/permissions/model/refusal.d.ts +13 -0
  838. package/dist/permissions/model/refusal.d.ts.map +1 -0
  839. package/dist/permissions/model/unions.d.ts +3 -0
  840. package/dist/permissions/model/unions.d.ts.map +1 -0
  841. package/dist/permissions/model/when.d.ts +16 -0
  842. package/dist/permissions/model/when.d.ts.map +1 -0
  843. package/dist/permissions/port/holders.d.ts +38 -0
  844. package/dist/permissions/port/holders.d.ts.map +1 -0
  845. package/dist/permissions/port/memory.d.ts +17 -0
  846. package/dist/permissions/port/memory.d.ts.map +1 -0
  847. package/dist/permissions/port/types.d.ts +101 -0
  848. package/dist/permissions/port/types.d.ts.map +1 -0
  849. package/dist/permissions/replace.d.ts +25 -0
  850. package/dist/permissions/replace.d.ts.map +1 -0
  851. package/dist/permissions/resolve/declared-names.d.ts +24 -0
  852. package/dist/permissions/resolve/declared-names.d.ts.map +1 -0
  853. package/dist/permissions/resolve/refuse-data-beyond-root.d.ts +11 -0
  854. package/dist/permissions/resolve/refuse-data-beyond-root.d.ts.map +1 -0
  855. package/dist/permissions/resolve/refuse-loops.d.ts +10 -0
  856. package/dist/permissions/resolve/refuse-loops.d.ts.map +1 -0
  857. package/dist/permissions/resolve/resolve-model.d.ts +13 -0
  858. package/dist/permissions/resolve/resolve-model.d.ts.map +1 -0
  859. package/dist/permissions/resolve/resolve-relation.d.ts +9 -0
  860. package/dist/permissions/resolve/resolve-relation.d.ts.map +1 -0
  861. package/dist/permissions/resolve/resolve-rule.d.ts +12 -0
  862. package/dist/permissions/resolve/resolve-rule.d.ts.map +1 -0
  863. package/dist/permissions/resolve/resolved.d.ts +52 -0
  864. package/dist/permissions/resolve/resolved.d.ts.map +1 -0
  865. package/dist/permissions/resolve/step.d.ts +4 -0
  866. package/dist/permissions/resolve/step.d.ts.map +1 -0
  867. package/dist/permissions/reverse.d.ts +53 -0
  868. package/dist/permissions/reverse.d.ts.map +1 -0
  869. package/dist/permissions/walk.d.ts +29 -0
  870. package/dist/permissions/walk.d.ts.map +1 -0
  871. package/dist/stores/guard.d.ts +24 -0
  872. package/dist/stores/guard.d.ts.map +1 -0
  873. package/dist/stores/storable.d.ts +15 -0
  874. package/dist/stores/storable.d.ts.map +1 -0
  875. package/dist/subjects/notation.d.ts +39 -0
  876. package/dist/subjects/notation.d.ts.map +1 -0
  877. package/dist/subjects/subject.d.ts +128 -0
  878. package/dist/subjects/subject.d.ts.map +1 -0
  879. package/dist/testing/index.d.ts +12 -0
  880. package/dist/testing/index.d.ts.map +1 -0
  881. package/dist/testing/index.js +26 -0
  882. package/dist/testing/index.js.map +10 -0
  883. package/dist/time/clock.d.ts +31 -0
  884. package/dist/time/clock.d.ts.map +1 -0
  885. package/dist/time/duration.d.ts +23 -0
  886. package/dist/time/duration.d.ts.map +1 -0
  887. package/docs/README.md +46 -0
  888. package/docs/guide/adapters.md +858 -0
  889. package/docs/guide/api-keys.md +316 -0
  890. package/docs/guide/avatars.md +334 -0
  891. package/docs/guide/devices.md +441 -0
  892. package/docs/guide/email-flows.md +880 -0
  893. package/docs/guide/errors.md +180 -0
  894. package/docs/guide/events.md +467 -0
  895. package/docs/guide/invitations.md +465 -0
  896. package/docs/guide/issuers.md +107 -0
  897. package/docs/guide/magic-link.md +580 -0
  898. package/docs/guide/migrating-invitations.md +142 -0
  899. package/docs/guide/passkeys.md +425 -0
  900. package/docs/guide/passwords.md +325 -0
  901. package/docs/guide/permissions.md +719 -0
  902. package/docs/guide/second-factor.md +1124 -0
  903. package/docs/guide/sessions.md +521 -0
  904. package/docs/guide/sign-in-code.md +631 -0
  905. package/docs/guide/social.md +639 -0
  906. package/docs/guide/step-up.md +262 -0
  907. package/docs/guide/users.md +557 -0
  908. package/docs/guide/vocabulary.md +316 -0
  909. package/docs/roadmap.md +101 -0
  910. package/docs/troubleshooting.md +3305 -0
  911. package/package.json +77 -5
@@ -0,0 +1,4411 @@
1
+ import {
2
+ mintId2,
3
+ createMemoryApiKeys2,
4
+ createMemoryInvitations2,
5
+ createMemoryStores2
6
+ } from "../chunks/index-k6y18nx9.js";
7
+ import {
8
+ JanusError2,
9
+ InvalidCursorError2,
10
+ StoreFailure2,
11
+ StoreConflict2,
12
+ NotFoundError2,
13
+ formatSubject2
14
+ } from "../chunks/index-2ttdcz7n.js";
15
+ import {
16
+ holderCursor2,
17
+ createMemoryRelations2
18
+ } from "../chunks/index-ftz0ne6j.js";
19
+
20
+ // src/conformance/assert.ts
21
+ function equal(actual, expected, what) {
22
+ const difference = differ(actual, expected, "");
23
+ if (difference !== null) {
24
+ throw new Error(`${what}
25
+ at ${difference.path || "(root)"}: expected ${show(difference.expected)}, got ${show(difference.actual)}`);
26
+ }
27
+ }
28
+ function isNull(actual, what) {
29
+ if (actual !== null) {
30
+ throw new Error(`${what}
31
+ expected null, got ${actual === undefined ? "undefined — an absence is null; undefined is a store that forgot to answer" : show(actual)}`);
32
+ }
33
+ }
34
+ function ok(condition, what) {
35
+ if (!condition)
36
+ throw new Error(what);
37
+ }
38
+ function rejects(promise, what) {
39
+ return promise.then((answer) => {
40
+ throw new Error(`${what}
41
+ expected a rejection, got ${show(answer)}`);
42
+ }, (error) => error);
43
+ }
44
+ function isOurs(error, cls, name, what) {
45
+ if (error instanceof cls)
46
+ return;
47
+ if (error?.name === name) {
48
+ throw new Error(`${what}
49
+ the error is named ${name} but is not @softistx/janus's ${name}: two copies of @softistx/janus are installed. The adapter must list it as a peer dependency, never a dependency`);
50
+ }
51
+ throw new Error(`${what}
52
+ expected ${name}, got ${show(error)}`);
53
+ }
54
+ function differ(actual, expected, path) {
55
+ if (expected instanceof Date || actual instanceof Date) {
56
+ return actual instanceof Date && expected instanceof Date && actual.getTime() === expected.getTime() ? null : { path, expected, actual };
57
+ }
58
+ if (Array.isArray(expected) || Array.isArray(actual)) {
59
+ if (!Array.isArray(expected) || !Array.isArray(actual)) {
60
+ return { path, expected, actual };
61
+ }
62
+ if (expected.length !== actual.length) {
63
+ return {
64
+ path: `${path}.length`,
65
+ expected: expected.length,
66
+ actual: actual.length
67
+ };
68
+ }
69
+ for (let i = 0;i < expected.length; i += 1) {
70
+ const inner = differ(actual[i], expected[i], `${path}[${i}]`);
71
+ if (inner !== null)
72
+ return inner;
73
+ }
74
+ return null;
75
+ }
76
+ if (typeof expected === "object" && expected !== null && typeof actual === "object" && actual !== null) {
77
+ const keys = new Set([...Object.keys(expected), ...Object.keys(actual)]);
78
+ for (const key of keys) {
79
+ const inner = differ(actual[key], expected[key], path === "" ? key : `${path}.${key}`);
80
+ if (inner !== null)
81
+ return inner;
82
+ }
83
+ return null;
84
+ }
85
+ return Object.is(actual, expected) ? null : { path, expected, actual };
86
+ }
87
+ function show(value) {
88
+ if (value instanceof Error)
89
+ return `${value.name}: ${value.message}`;
90
+ if (value instanceof Date)
91
+ return value.toISOString();
92
+ if (value === undefined)
93
+ return "undefined";
94
+ if (typeof value === "string")
95
+ return JSON.stringify(value);
96
+ try {
97
+ const json = JSON.stringify(value);
98
+ return json.length > 200 ? `${json.slice(0, 200)}…` : json;
99
+ } catch {
100
+ return String(value);
101
+ }
102
+ }
103
+
104
+ // src/conformance/api-keys/fixtures.ts
105
+ function apiKey(overrides = {}) {
106
+ return {
107
+ id: mintId2(),
108
+ userId: mintId2(),
109
+ name: "ci",
110
+ secretHash: "a".repeat(64),
111
+ createdAt: new Date("2026-01-01T00:00:00.000Z"),
112
+ expiresAt: new Date("2027-01-01T00:00:00.000Z"),
113
+ lastUsedAt: null,
114
+ revokedAt: null,
115
+ ...overrides
116
+ };
117
+ }
118
+
119
+ // src/conformance/api-keys/cases/bound.ts
120
+ var group = "apiKeys";
121
+ var needs = "bound";
122
+ var at = (iso) => new Date(iso);
123
+ var bound = (store) => store;
124
+ var workspace = (id) => ({ type: "workspace", id });
125
+ var apiKeyBoundCases = [
126
+ {
127
+ id: "apiKeys.bound.insert",
128
+ group,
129
+ needs,
130
+ name: "a store with the bound capability answers scopes and bound verbatim",
131
+ async run({ store }) {
132
+ const key = apiKey({
133
+ scopes: ["mcp:read", "mcp:write"],
134
+ bound: workspace("w1")
135
+ });
136
+ await store.insertApiKey(key);
137
+ equal(await store.findApiKey(key.id), key, "findApiKey: the scopes and the bound object as written");
138
+ const unscoped = apiKey();
139
+ await store.insertApiKey(unscoped);
140
+ equal(await store.findApiKey(unscoped.id), unscoped, "findApiKey: a key without scopes or bound is answered without them");
141
+ }
142
+ },
143
+ {
144
+ id: "apiKeys.bound.list",
145
+ group,
146
+ needs,
147
+ name: "listBoundApiKeys pages the keys bound to one object in id order, whoever holds them and whatever their state",
148
+ async run({ store }) {
149
+ const s = bound(store);
150
+ const ids = [mintId2(), mintId2(), mintId2()].sort();
151
+ const [a, b, c] = ids;
152
+ await store.insertApiKey(apiKey({ id: c, bound: workspace("w1") }));
153
+ await store.insertApiKey(apiKey({ id: a, bound: workspace("w1") }));
154
+ await store.insertApiKey(apiKey({ id: b, bound: workspace("w1") }));
155
+ await store.revokeApiKey(b, at("2026-03-01T00:00:00.000Z"));
156
+ await store.insertApiKey(apiKey({ bound: workspace("w2") }));
157
+ await store.insertApiKey(apiKey({ bound: { type: "account", id: "w1" } }));
158
+ await store.insertApiKey(apiKey());
159
+ const first = await s.listBoundApiKeys(workspace("w1"), {
160
+ first: 2,
161
+ after: null
162
+ });
163
+ equal(first.items.map((key) => key.id), [a, b], "listBoundApiKeys: the first page, revoked keys included");
164
+ equal(first.nextCursor, b, "listBoundApiKeys: nextCursor is the last id");
165
+ const second = await s.listBoundApiKeys(workspace("w1"), {
166
+ first: 2,
167
+ after: first.nextCursor
168
+ });
169
+ equal(second.items.map((key) => key.id), [c], "listBoundApiKeys: the second page");
170
+ equal(second.nextCursor, null, "listBoundApiKeys: no cursor on the last page");
171
+ equal(await s.listBoundApiKeys(workspace("nothing"), {
172
+ first: 10,
173
+ after: null
174
+ }), { items: [], nextCursor: null }, "listBoundApiKeys: an object without keys has an empty page, never null");
175
+ }
176
+ },
177
+ {
178
+ id: "apiKeys.bound.revoke",
179
+ group,
180
+ needs,
181
+ name: "revokeBoundApiKeys revokes one user’s standing keys bound to one object, keeps earlier revokedAt, and counts what it revoked",
182
+ async run({ store }) {
183
+ const s = bound(store);
184
+ const userId = mintId2();
185
+ const mine = [
186
+ apiKey({ userId, bound: workspace("w1") }),
187
+ apiKey({ userId, bound: workspace("w1") })
188
+ ];
189
+ const already = apiKey({ userId, bound: workspace("w1") });
190
+ const elsewhere = apiKey({ userId, bound: workspace("w2") });
191
+ const unbound = apiKey({ userId });
192
+ const theirs = apiKey({ bound: workspace("w1") });
193
+ for (const key of [...mine, already, elsewhere, unbound, theirs]) {
194
+ await store.insertApiKey(key);
195
+ }
196
+ const earlier = at("2026-05-01T00:00:00.000Z");
197
+ const now = at("2026-06-01T00:00:00.000Z");
198
+ await store.revokeApiKey(already.id, earlier);
199
+ equal(await s.revokeBoundApiKeys(userId, workspace("w1"), now), 2, "revokeBoundApiKeys: counts the keys it revoked, not the ones already revoked");
200
+ equal((await store.findApiKey(mine[0]?.id ?? ""))?.revokedAt, now, "revokeBoundApiKeys: a standing key is revoked at the instant given");
201
+ equal((await store.findApiKey(already.id))?.revokedAt, earlier, "revokeBoundApiKeys: an earlier revokedAt is kept");
202
+ for (const [key, what] of [
203
+ [elsewhere, "a key bound to another object"],
204
+ [unbound, "an unbound key"],
205
+ [theirs, "another user’s key"]
206
+ ]) {
207
+ equal((await store.findApiKey(key.id))?.revokedAt, null, `revokeBoundApiKeys: ${what} stands`);
208
+ }
209
+ equal(await s.revokeBoundApiKeys(userId, workspace("w1"), now), 0, "revokeBoundApiKeys replayed answers 0, not a failure");
210
+ }
211
+ }
212
+ ];
213
+
214
+ // src/conformance/api-keys/cases/expiry.ts
215
+ var group2 = "apiKeys";
216
+ var needs2 = "expiryNotice";
217
+ var at2 = (iso) => new Date(iso);
218
+ var expiry = (store) => store;
219
+ var now = at2("2026-06-01T00:00:00.000Z");
220
+ var before = at2("2026-06-08T00:00:00.000Z");
221
+ var apiKeyExpiryCases = [
222
+ {
223
+ id: "apiKeys.expiring",
224
+ group: group2,
225
+ needs: needs2,
226
+ name: "listExpiringApiKeys pages the standing keys lapsing after now and by before, not yet notified, in id order",
227
+ async run({ store }) {
228
+ const s = expiry(store);
229
+ const ids = [mintId2(), mintId2(), mintId2()].sort();
230
+ const [a, b, c] = ids;
231
+ await store.insertApiKey(apiKey({ id: c, expiresAt: before }));
232
+ await store.insertApiKey(apiKey({ id: a, expiresAt: at2("2026-06-01T00:00:00.001Z") }));
233
+ await store.insertApiKey(apiKey({ id: b, expiresAt: at2("2026-06-03T00:00:00.000Z") }));
234
+ await store.insertApiKey(apiKey({ expiresAt: now }));
235
+ await store.insertApiKey(apiKey({ expiresAt: at2("2026-06-08T00:00:00.001Z") }));
236
+ const revoked = apiKey({ expiresAt: at2("2026-06-02T00:00:00.000Z") });
237
+ await store.insertApiKey(revoked);
238
+ await store.revokeApiKey(revoked.id, at2("2026-05-01T00:00:00.000Z"));
239
+ await store.insertApiKey(apiKey({
240
+ expiresAt: at2("2026-06-02T00:00:00.000Z"),
241
+ expiryNotifiedAt: at2("2026-05-25T00:00:00.000Z")
242
+ }));
243
+ const first = await s.listExpiringApiKeys({
244
+ now,
245
+ before,
246
+ first: 2,
247
+ after: null
248
+ });
249
+ equal(first.items.map((key) => key.id), [a, b], "listExpiringApiKeys: the first page");
250
+ equal(first.nextCursor, b, "listExpiringApiKeys: nextCursor is the last id");
251
+ const second = await s.listExpiringApiKeys({
252
+ now,
253
+ before,
254
+ first: 2,
255
+ after: first.nextCursor
256
+ });
257
+ equal(second.items.map((key) => key.id), [c], "listExpiringApiKeys: the second page, a key lapsing at before included");
258
+ equal(second.nextCursor, null, "listExpiringApiKeys: no cursor on the last page");
259
+ }
260
+ },
261
+ {
262
+ id: "apiKeys.expiryNotified",
263
+ group: group2,
264
+ needs: needs2,
265
+ name: "markApiKeyExpiryNotified writes once, keeps the first instant, and drops the key from listExpiringApiKeys",
266
+ async run({ store }) {
267
+ const s = expiry(store);
268
+ const key = apiKey({ expiresAt: at2("2026-06-03T00:00:00.000Z") });
269
+ await store.insertApiKey(key);
270
+ const first = at2("2026-05-30T00:00:00.000Z");
271
+ equal(await s.markApiKeyExpiryNotified(key.id, first), true, "markApiKeyExpiryNotified: a key not yet notified is written");
272
+ equal(await s.markApiKeyExpiryNotified(key.id, now), false, "markApiKeyExpiryNotified: a key already notified is left alone");
273
+ equal((await store.findApiKey(key.id))?.expiryNotifiedAt, first, "markApiKeyExpiryNotified: the first instant is kept");
274
+ equal((await s.listExpiringApiKeys({ now, before, first: 10, after: null })).items, [], "listExpiringApiKeys: a notified key is left out");
275
+ equal(await s.markApiKeyExpiryNotified(mintId2(), now), false, "markApiKeyExpiryNotified: an unknown key is false, not a failure");
276
+ }
277
+ },
278
+ {
279
+ id: "apiKeys.expiryNotified.concurrent",
280
+ group: group2,
281
+ needs: needs2,
282
+ name: "markApiKeyExpiryNotified lets exactly one of concurrent calls win",
283
+ async run({ store }) {
284
+ const s = expiry(store);
285
+ const key = apiKey();
286
+ await store.insertApiKey(key);
287
+ const answers = await Promise.all(Array.from({ length: 8 }, () => s.markApiKeyExpiryNotified(key.id, now)));
288
+ equal(answers.filter(Boolean).length, 1, "markApiKeyExpiryNotified: exactly one concurrent call answers true");
289
+ }
290
+ }
291
+ ];
292
+
293
+ // src/conformance/api-keys/cases/insert.ts
294
+ var group3 = "apiKeys";
295
+ var at3 = (iso) => new Date(iso);
296
+ var apiKeyInsertCases = [
297
+ {
298
+ id: "apiKeys.insert",
299
+ group: group3,
300
+ name: "insertApiKey stores a key that findApiKey answers verbatim, and null for an unknown id",
301
+ async run({ store }) {
302
+ const key = apiKey({ lastUsedAt: at3("2026-02-01T00:00:00.000Z") });
303
+ await store.insertApiKey(key);
304
+ equal(await store.findApiKey(key.id), key, "findApiKey: the key as written");
305
+ isNull(await store.findApiKey(mintId2()), "findApiKey: an unknown id is null, not undefined");
306
+ }
307
+ },
308
+ {
309
+ id: "apiKeys.insert.idempotent",
310
+ group: group3,
311
+ name: "insertApiKey is idempotent by id: a retry writes nothing and does not throw",
312
+ async run({ store }) {
313
+ const key = apiKey();
314
+ await store.insertApiKey(key);
315
+ await store.revokeApiKey(key.id, at3("2026-03-01T00:00:00.000Z"));
316
+ await store.insertApiKey({
317
+ ...key,
318
+ name: "replayed",
319
+ secretHash: "b".repeat(64)
320
+ });
321
+ equal(await store.findApiKey(key.id), { ...key, revokedAt: at3("2026-03-01T00:00:00.000Z") }, "insertApiKey replayed should leave the stored key untouched");
322
+ }
323
+ },
324
+ {
325
+ id: "apiKeys.list",
326
+ group: group3,
327
+ name: "listUserApiKeys pages one user’s keys in id order with a cursor, whatever their state, and leaves other users’ out",
328
+ async run({ store }) {
329
+ const userId = mintId2();
330
+ const ids = [mintId2(), mintId2(), mintId2()].sort();
331
+ const [a, b, c] = ids;
332
+ await store.insertApiKey(apiKey({ id: c, userId }));
333
+ await store.insertApiKey(apiKey({ id: a, userId }));
334
+ await store.insertApiKey(apiKey({ id: b, userId }));
335
+ await store.insertApiKey(apiKey({ userId: mintId2() }));
336
+ await store.revokeApiKey(b, at3("2026-03-01T00:00:00.000Z"));
337
+ const first = await store.listUserApiKeys(userId, {
338
+ first: 2,
339
+ after: null
340
+ });
341
+ equal(first.items.map((key) => key.id), [a, b], "listUserApiKeys: the first page, revoked keys included");
342
+ equal(first.nextCursor, b, "listUserApiKeys: nextCursor is the last id");
343
+ const second = await store.listUserApiKeys(userId, {
344
+ first: 2,
345
+ after: first.nextCursor
346
+ });
347
+ equal(second.items.map((key) => key.id), [c], "listUserApiKeys: the last page");
348
+ equal(second.nextCursor, null, "listUserApiKeys: the last page ends with null");
349
+ const exact = await store.listUserApiKeys(userId, {
350
+ first: 3,
351
+ after: null
352
+ });
353
+ equal(exact.nextCursor, null, "listUserApiKeys: a page that ends exactly has no cursor");
354
+ equal(await store.listUserApiKeys(userId, { first: 5, after: c }), { items: [], nextCursor: null }, "listUserApiKeys: past the end is an empty page");
355
+ equal(await store.listUserApiKeys(mintId2(), { first: 5, after: null }), { items: [], nextCursor: null }, "listUserApiKeys: a user without keys has an empty page, never null");
356
+ }
357
+ },
358
+ {
359
+ id: "apiKeys.list.after-unknown",
360
+ group: group3,
361
+ name: "listUserApiKeys with an after that names no stored key answers the keys past it in id order",
362
+ async run({ store }) {
363
+ const userId = mintId2();
364
+ const [a, b, c] = [mintId2(), mintId2(), mintId2()].sort();
365
+ await store.insertApiKey(apiKey({ id: a, userId }));
366
+ await store.insertApiKey(apiKey({ id: c, userId }));
367
+ const page = await store.listUserApiKeys(userId, {
368
+ first: 5,
369
+ after: b
370
+ });
371
+ equal(page.items.map((key) => key.id), [c], "listUserApiKeys: a cursor naming no stored key still pages past it");
372
+ equal(page.nextCursor, null, "listUserApiKeys: and ends with null");
373
+ }
374
+ },
375
+ {
376
+ id: "apiKeys.lapsed",
377
+ group: group3,
378
+ name: "a lapsed key is still found and listed: expiry is the core’s to read, not the store’s",
379
+ async run({ store }) {
380
+ const userId = mintId2();
381
+ const key = apiKey({
382
+ userId,
383
+ createdAt: at3("2020-01-01T00:00:00.000Z"),
384
+ expiresAt: at3("2020-02-01T00:00:00.000Z")
385
+ });
386
+ await store.insertApiKey(key);
387
+ equal(await store.findApiKey(key.id), key, "findApiKey: a lapsed key is answered as written");
388
+ equal((await store.listUserApiKeys(userId, { first: 5, after: null })).items, [key], "listUserApiKeys: a lapsed key is listed");
389
+ }
390
+ }
391
+ ];
392
+
393
+ // src/conformance/api-keys/cases/revoke.ts
394
+ var group4 = "apiKeys";
395
+ var at4 = (iso) => new Date(iso);
396
+ var apiKeyRevokeCases = [
397
+ {
398
+ id: "apiKeys.revoke",
399
+ group: group4,
400
+ name: "revokeApiKey answers whether the key exists and keeps the first revokedAt",
401
+ async run({ store }) {
402
+ const key = apiKey();
403
+ await store.insertApiKey(key);
404
+ const first = at4("2026-05-01T00:00:00.000Z");
405
+ equal(await store.revokeApiKey(key.id, first), true, "revokeApiKey: a standing key");
406
+ equal(await store.revokeApiKey(key.id, at4("2026-06-01T00:00:00.000Z")), true, "revokeApiKey: a key already revoked still exists");
407
+ equal((await store.findApiKey(key.id))?.revokedAt, first, "revokeApiKey: the first revokedAt is kept");
408
+ equal(await store.revokeApiKey(mintId2(), first), false, "revokeApiKey: an unknown key is false, not a failure");
409
+ }
410
+ },
411
+ {
412
+ id: "apiKeys.revokeUser",
413
+ group: group4,
414
+ name: "revokeUserApiKeys revokes only that user’s standing keys, keeps earlier revokedAt, and counts what this call revoked",
415
+ async run({ store }) {
416
+ const userId = mintId2();
417
+ const already = apiKey({ userId });
418
+ const standing = [apiKey({ userId }), apiKey({ userId })];
419
+ const other = apiKey();
420
+ for (const key of [already, ...standing, other])
421
+ await store.insertApiKey(key);
422
+ const earlier = at4("2026-05-01T00:00:00.000Z");
423
+ await store.revokeApiKey(already.id, earlier);
424
+ equal(await store.revokeUserApiKeys(userId, at4("2026-06-01T00:00:00.000Z")), 2, "revokeUserApiKeys: counts the keys it revoked, not the ones already revoked");
425
+ equal((await store.findApiKey(already.id))?.revokedAt, earlier, "revokeUserApiKeys: an earlier revokedAt is kept");
426
+ equal((await store.findApiKey(standing[0]?.id ?? ""))?.revokedAt, at4("2026-06-01T00:00:00.000Z"), "revokeUserApiKeys: a standing key is revoked at the instant given");
427
+ equal((await store.findApiKey(other.id))?.revokedAt, null, "revokeUserApiKeys: another user’s key stands");
428
+ equal(await store.revokeUserApiKeys(userId, at4("2026-07-01T00:00:00.000Z")), 0, "revokeUserApiKeys replayed answers 0, not a failure");
429
+ }
430
+ },
431
+ {
432
+ id: "apiKeys.deleteUser",
433
+ group: group4,
434
+ name: "deleteUserApiKeys deletes every key of that user, revoked or not, and counts them",
435
+ async run({ store }) {
436
+ const userId = mintId2();
437
+ const keys = [apiKey({ userId }), apiKey({ userId })];
438
+ const other = apiKey();
439
+ for (const key of [...keys, other])
440
+ await store.insertApiKey(key);
441
+ await store.revokeApiKey(keys[0]?.id ?? "", at4("2026-05-01T00:00:00.000Z"));
442
+ equal(await store.deleteUserApiKeys(userId), 2, "deleteUserApiKeys: how many it deleted");
443
+ isNull(await store.findApiKey(keys[1]?.id ?? ""), "deleteUserApiKeys: the key is gone");
444
+ equal((await store.findApiKey(other.id))?.id, other.id, "deleteUserApiKeys: another user’s key stays");
445
+ equal(await store.deleteUserApiKeys(userId), 0, "deleteUserApiKeys replayed answers 0, not a failure");
446
+ }
447
+ },
448
+ {
449
+ id: "apiKeys.deleteExpired",
450
+ group: group4,
451
+ name: "deleteExpiredApiKeys deletes the keys whose expiresAt is at or before the instant, and counts them",
452
+ async run({ store }) {
453
+ if (store.deleteExpiredApiKeys === undefined)
454
+ return;
455
+ const before = at4("2026-08-01T00:00:00.000Z");
456
+ const lapsed = apiKey({ expiresAt: before });
457
+ const older = apiKey({ expiresAt: at4("2026-07-01T00:00:00.000Z") });
458
+ const live = apiKey({ expiresAt: at4("2026-08-01T00:00:00.001Z") });
459
+ for (const key of [lapsed, older, live])
460
+ await store.insertApiKey(key);
461
+ equal(await store.deleteExpiredApiKeys(before), 2, "deleteExpiredApiKeys: how many it deleted");
462
+ isNull(await store.findApiKey(lapsed.id), "deleteExpiredApiKeys: a lapsed key is gone");
463
+ equal((await store.findApiKey(live.id))?.id, live.id, "deleteExpiredApiKeys: a live key stays");
464
+ }
465
+ }
466
+ ];
467
+
468
+ // src/conformance/api-keys/cases/touch.ts
469
+ var group5 = "apiKeys";
470
+ var at5 = (iso) => new Date(iso);
471
+ var apiKeyTouchCases = [
472
+ {
473
+ id: "apiKeys.touch",
474
+ group: group5,
475
+ name: "touchApiKey writes lastUsedAt only for a key never used or used before staleBefore, and answers whether it wrote",
476
+ async run({ store }) {
477
+ const key = apiKey();
478
+ await store.insertApiKey(key);
479
+ const t1 = at5("2026-04-01T12:00:00.000Z");
480
+ const t2 = at5("2026-04-01T12:30:00.000Z");
481
+ const t3 = at5("2026-04-01T13:30:00.000Z");
482
+ equal(await store.touchApiKey(key.id, t1, at5("2026-04-01T11:00:00.000Z")), true, "touchApiKey: a key never used is written");
483
+ equal((await store.findApiKey(key.id))?.lastUsedAt, t1, "touchApiKey: lastUsedAt is the instant given");
484
+ equal(await store.touchApiKey(key.id, t2, at5("2026-04-01T11:30:00.000Z")), false, "touchApiKey: a key used at or after staleBefore is left alone");
485
+ equal((await store.findApiKey(key.id))?.lastUsedAt, t1, "touchApiKey: a refused touch changes nothing");
486
+ equal(await store.touchApiKey(key.id, t3, at5("2026-04-01T12:30:00.000Z")), true, "touchApiKey: a key last used before staleBefore is written");
487
+ equal(await store.touchApiKey(key.id, at5("2026-04-01T14:00:00.000Z"), t3), false, "touchApiKey: a key last used exactly at staleBefore is left alone");
488
+ equal((await store.findApiKey(key.id))?.lastUsedAt, t3, "touchApiKey: a key used exactly at staleBefore keeps its lastUsedAt");
489
+ equal(await store.touchApiKey(mintId2(), t3, t3), false, "touchApiKey: an unknown key is false, not a failure");
490
+ }
491
+ },
492
+ {
493
+ id: "apiKeys.touch.concurrent",
494
+ group: group5,
495
+ name: "touchApiKey: of concurrent calls on a stale key exactly one answers true",
496
+ async run({ store }) {
497
+ const key = apiKey();
498
+ await store.insertApiKey(key);
499
+ const at1 = at5("2026-04-01T12:00:00.000Z");
500
+ const stale = at5("2026-04-01T11:00:00.000Z");
501
+ const results = await Promise.all(Array.from({ length: 10 }, () => store.touchApiKey(key.id, at1, stale)));
502
+ equal(results.filter(Boolean).length, 1, "touchApiKey: exactly one of ten concurrent calls should have written");
503
+ }
504
+ },
505
+ {
506
+ id: "apiKeys.touch.revoked",
507
+ group: group5,
508
+ name: "touchApiKey never writes a revoked key",
509
+ async run({ store }) {
510
+ const key = apiKey();
511
+ await store.insertApiKey(key);
512
+ await store.revokeApiKey(key.id, at5("2026-04-01T00:00:00.000Z"));
513
+ equal(await store.touchApiKey(key.id, at5("2026-04-02T00:00:00.000Z"), at5("2026-04-03T00:00:00.000Z")), false, "touchApiKey: a revoked key is false");
514
+ equal((await store.findApiKey(key.id))?.lastUsedAt, null, "touchApiKey: a revoked key stays unused");
515
+ }
516
+ }
517
+ ];
518
+
519
+ // src/conformance/api-keys/cases/user-bound.ts
520
+ var group6 = "apiKeys";
521
+ var needs3 = ["bound", "userBound"];
522
+ var at6 = (iso) => new Date(iso);
523
+ var userBound = (store) => store;
524
+ var workspace2 = (id) => ({ type: "workspace", id });
525
+ var apiKeyUserBoundCases = [
526
+ {
527
+ id: "apiKeys.userBound.list",
528
+ group: group6,
529
+ needs: needs3,
530
+ name: "listUserBoundApiKeys pages one user’s keys bound to one object in id order, whatever their state",
531
+ async run({ store }) {
532
+ const s = userBound(store);
533
+ const userId = mintId2();
534
+ const [a, b, c] = [mintId2(), mintId2(), mintId2()].sort();
535
+ await store.insertApiKey(apiKey({ id: c, userId, bound: workspace2("w1") }));
536
+ await store.insertApiKey(apiKey({
537
+ id: a,
538
+ userId,
539
+ bound: workspace2("w1"),
540
+ expiresAt: at6("2020-01-01T00:00:00.000Z")
541
+ }));
542
+ await store.insertApiKey(apiKey({ id: b, userId, bound: workspace2("w1") }));
543
+ await store.revokeApiKey(b, at6("2026-03-01T00:00:00.000Z"));
544
+ await store.insertApiKey(apiKey({ userId, bound: workspace2("w2") }));
545
+ await store.insertApiKey(apiKey({ userId, bound: { type: "account", id: "w1" } }));
546
+ await store.insertApiKey(apiKey({ userId }));
547
+ await store.insertApiKey(apiKey({ bound: workspace2("w1") }));
548
+ const first = await s.listUserBoundApiKeys(userId, workspace2("w1"), {
549
+ first: 2,
550
+ after: null
551
+ });
552
+ equal(first.items.map((key) => key.id), [a, b], "listUserBoundApiKeys: the first page, revoked and lapsed keys included, no other user’s key");
553
+ equal(first.nextCursor, b, "listUserBoundApiKeys: nextCursor is the last id");
554
+ const second = await s.listUserBoundApiKeys(userId, workspace2("w1"), {
555
+ first: 2,
556
+ after: first.nextCursor
557
+ });
558
+ equal(second.items.map((key) => key.id), [c], "listUserBoundApiKeys: the second page");
559
+ equal(second.nextCursor, null, "listUserBoundApiKeys: no cursor on the last page");
560
+ }
561
+ },
562
+ {
563
+ id: "apiKeys.userBound.unbound",
564
+ group: group6,
565
+ needs: needs3,
566
+ name: "listUserBoundApiKeys with null pages only the user’s unbound keys",
567
+ async run({ store }) {
568
+ const s = userBound(store);
569
+ const userId = mintId2();
570
+ const [a, b, c] = [mintId2(), mintId2(), mintId2()].sort();
571
+ await store.insertApiKey(apiKey({ id: c, userId }));
572
+ await store.insertApiKey(apiKey({ id: a, userId }));
573
+ await store.insertApiKey(apiKey({ id: b, userId }));
574
+ await store.insertApiKey(apiKey({ userId, bound: workspace2("w1") }));
575
+ await store.insertApiKey(apiKey());
576
+ const first = await s.listUserBoundApiKeys(userId, null, {
577
+ first: 2,
578
+ after: null
579
+ });
580
+ equal(first.items.map((key) => key.id), [a, b], "listUserBoundApiKeys(null): the user’s unbound keys only, in id order");
581
+ equal(first.nextCursor, b, "listUserBoundApiKeys(null): nextCursor");
582
+ const second = await s.listUserBoundApiKeys(userId, null, {
583
+ first: 2,
584
+ after: first.nextCursor
585
+ });
586
+ equal([second.items.map((key) => key.id), second.nextCursor], [[c], null], "listUserBoundApiKeys(null): the second page");
587
+ }
588
+ },
589
+ {
590
+ id: "apiKeys.userBound.none",
591
+ group: group6,
592
+ needs: needs3,
593
+ name: "listUserBoundApiKeys answers an empty page, never null, for nothing bound and for an unknown cursor",
594
+ async run({ store }) {
595
+ const s = userBound(store);
596
+ const userId = mintId2();
597
+ const key = apiKey({ userId, bound: workspace2("w1") });
598
+ await store.insertApiKey(key);
599
+ const empty = { items: [], nextCursor: null };
600
+ equal(await s.listUserBoundApiKeys(userId, workspace2("nothing"), {
601
+ first: 10,
602
+ after: null
603
+ }), empty, "listUserBoundApiKeys: an object the user has no key for");
604
+ equal(await s.listUserBoundApiKeys(mintId2(), workspace2("w1"), {
605
+ first: 10,
606
+ after: null
607
+ }), empty, "listUserBoundApiKeys: a user without keys");
608
+ equal(await s.listUserBoundApiKeys(userId, null, {
609
+ first: 10,
610
+ after: null
611
+ }), empty, "listUserBoundApiKeys(null): a user with bound keys only");
612
+ const unknown = await s.listUserBoundApiKeys(userId, workspace2("w1"), {
613
+ first: 10,
614
+ after: "00000000-0000-7000-8000-000000000000"
615
+ });
616
+ equal(unknown.items.map((found) => found.id), [key.id], "listUserBoundApiKeys: an after naming no stored key still pages");
617
+ }
618
+ }
619
+ ];
620
+
621
+ // src/conformance/api-keys/cases/index.ts
622
+ var apiKeyStoreCases = [
623
+ ...apiKeyInsertCases,
624
+ ...apiKeyTouchCases,
625
+ ...apiKeyRevokeCases,
626
+ ...apiKeyBoundCases,
627
+ ...apiKeyUserBoundCases,
628
+ ...apiKeyExpiryCases
629
+ ];
630
+ // src/conformance/api-keys/cases/outage.ts
631
+ var seeded = apiKey({ id: "00000000-0000-7000-8000-000000000001" });
632
+ var boundTo = { type: "workspace", id: "w1" };
633
+ var seededBound = { ...seeded, bound: boundTo };
634
+ var when = new Date("2026-09-01T00:00:00.000Z");
635
+ function outage(method, call, after, capability) {
636
+ const seed = capability === "bound" || capability === "userBound" ? seededBound : seeded;
637
+ return {
638
+ id: `outage.${method}`,
639
+ group: "outage",
640
+ name: `apiKeys.${method} rejects when the store cannot answer — never null, false, 0 or an empty page`,
641
+ needs: capability === undefined ? "faults" : ["faults", capability],
642
+ async run({ store, faults }) {
643
+ await store.insertApiKey(seed);
644
+ await faults?.fail(method);
645
+ const error = await rejects(call(store), `apiKeys.${method} under an outage should reject`);
646
+ if (error instanceof JanusError2 || error?.name === "StoreFailure") {
647
+ isOurs(error, StoreFailure2, "StoreFailure", `apiKeys.${method} under an outage`);
648
+ }
649
+ ok(error?.code !== "NOT_FOUND", `apiKeys.${method} under an outage rejected with NOT_FOUND: an outage is never an absence`);
650
+ await after?.(store);
651
+ }
652
+ };
653
+ }
654
+ function optional(apiKeyCase) {
655
+ const method = apiKeyCase.id.slice("outage.".length);
656
+ return {
657
+ ...apiKeyCase,
658
+ async run(context) {
659
+ if (context.store[method] === undefined)
660
+ return;
661
+ await apiKeyCase.run(context);
662
+ }
663
+ };
664
+ }
665
+ var unrevoked = async (store) => equal((await store.findApiKey(seeded.id))?.revokedAt, null, "a rejected revocation should have changed nothing");
666
+ var apiKeyOutageCases = [
667
+ outage("insertApiKey", (store) => store.insertApiKey(apiKey())),
668
+ outage("findApiKey", (store) => store.findApiKey(seeded.id)),
669
+ outage("listUserApiKeys", (store) => store.listUserApiKeys(seeded.userId, { first: 10, after: null })),
670
+ outage("touchApiKey", (store) => store.touchApiKey(seeded.id, when, when)),
671
+ outage("revokeApiKey", (store) => store.revokeApiKey(seeded.id, when), unrevoked),
672
+ outage("revokeUserApiKeys", (store) => store.revokeUserApiKeys(seeded.userId, when), unrevoked),
673
+ outage("deleteUserApiKeys", (store) => store.deleteUserApiKeys(seeded.userId), async (store) => equal((await store.findApiKey(seeded.id))?.id, seeded.id, "a rejected deletion should have deleted nothing")),
674
+ optional(outage("deleteExpiredApiKeys", (store) => store.deleteExpiredApiKeys(new Date("2100-01-01T00:00:00.000Z")))),
675
+ outage("listBoundApiKeys", (store) => present(store.listBoundApiKeys)(boundTo, { first: 10, after: null }), undefined, "bound"),
676
+ outage("revokeBoundApiKeys", (store) => present(store.revokeBoundApiKeys)(seeded.userId, boundTo, when), unrevoked, "bound"),
677
+ outage("listUserBoundApiKeys", (store) => present(store.listUserBoundApiKeys)(seeded.userId, boundTo, {
678
+ first: 10,
679
+ after: null
680
+ }), undefined, "userBound"),
681
+ outage("listExpiringApiKeys", (store) => present(store.listExpiringApiKeys)({
682
+ now: when,
683
+ before: new Date("2100-01-01T00:00:00.000Z"),
684
+ first: 10,
685
+ after: null
686
+ }), undefined, "expiryNotice"),
687
+ outage("markApiKeyExpiryNotified", (store) => present(store.markApiKeyExpiryNotified)(seeded.id, when), async (store) => equal((await store.findApiKey(seeded.id))?.expiryNotifiedAt, undefined, "a rejected notice should have recorded nothing"), "expiryNotice")
688
+ ];
689
+ function present(method) {
690
+ return method;
691
+ }
692
+ // src/conformance/fixtures.ts
693
+ var at7 = (iso) => new Date(iso);
694
+ var fresh = () => `user-${mintId2()}@example.test`;
695
+ function userRecord(overrides = {}) {
696
+ const email = fresh();
697
+ return {
698
+ id: mintId2(),
699
+ type: "user",
700
+ schemaVersion: "1",
701
+ active: true,
702
+ fields: { email, name: { first: "Ada", last: "Lovelace" } },
703
+ logins: [email],
704
+ password: {
705
+ hash: "$scrypt$ln=17,r=8,p=1$c2FsdA==$a2V5",
706
+ updatedAt: at7("2026-01-01T00:00:00.000Z")
707
+ },
708
+ secondFactor: null,
709
+ avatar: null,
710
+ emailVerifiedAt: null,
711
+ version: 0,
712
+ createdAt: at7("2026-01-01T00:00:00.000Z"),
713
+ updatedAt: at7("2026-01-01T00:00:00.000Z"),
714
+ ...overrides
715
+ };
716
+ }
717
+ function sessionRecord(overrides = {}) {
718
+ return {
719
+ id: mintId2(),
720
+ tokenHash: hexOf(mintId2()),
721
+ userId: mintId2(),
722
+ authenticatedAt: at7("2026-01-01T00:00:00.000Z"),
723
+ expiresAt: at7("2099-01-01T00:00:00.000Z"),
724
+ revokedAt: null,
725
+ createdAt: at7("2026-01-01T00:00:00.000Z"),
726
+ ...overrides
727
+ };
728
+ }
729
+ function tokenRecord(overrides = {}) {
730
+ return {
731
+ tokenHash: hexOf(mintId2()),
732
+ kind: "resetPassword",
733
+ userId: mintId2(),
734
+ address: fresh(),
735
+ codeHash: null,
736
+ attempts: 0,
737
+ expiresAt: at7("2099-01-01T00:00:00.000Z"),
738
+ spentAt: null,
739
+ createdAt: at7("2026-01-01T00:00:00.000Z"),
740
+ ...overrides
741
+ };
742
+ }
743
+ function socialLinkRecord(overrides = {}) {
744
+ return {
745
+ provider: "google",
746
+ accountId: `acct-${mintId2()}`,
747
+ userId: mintId2(),
748
+ email: fresh(),
749
+ createdAt: at7("2026-01-01T00:00:00.000Z"),
750
+ ...overrides
751
+ };
752
+ }
753
+ function socialLinksOf(stores) {
754
+ if (stores.socialLinks === undefined) {
755
+ throw new Error('this case needs stores.socialLinks: declare needs: "socialLinks"');
756
+ }
757
+ return stores.socialLinks;
758
+ }
759
+ function passkeyRecord(overrides = {}) {
760
+ return {
761
+ credentialId: `cred-${mintId2()}`,
762
+ userId: mintId2(),
763
+ publicKey: "pQECAyYgASFYIEdA_-Zq0wFfX3k8w1x2yq9uZ7Jm",
764
+ counter: 0,
765
+ transports: ["internal", "hybrid"],
766
+ aaguid: "00000000-0000-0000-0000-000000000000",
767
+ backupEligible: true,
768
+ backedUp: false,
769
+ name: "Laptop",
770
+ createdAt: at7("2026-01-01T00:00:00.000Z"),
771
+ lastUsedAt: null,
772
+ ...overrides
773
+ };
774
+ }
775
+ function passkeysOf(stores) {
776
+ if (stores.passkeys === undefined) {
777
+ throw new Error('this case needs stores.passkeys: declare needs: "passkeys"');
778
+ }
779
+ return stores.passkeys;
780
+ }
781
+ function hexOf(seed) {
782
+ return seed.replace(/-/g, "").padEnd(64, "0").slice(0, 64);
783
+ }
784
+
785
+ // src/conformance/cases/outage.passkeys.ts
786
+ function passkeyOutageCases(outage, userId, now) {
787
+ const passkey = passkeyRecord({ userId });
788
+ const seed = async ({ stores }) => {
789
+ await passkeysOf(stores).insertPasskey(passkey);
790
+ };
791
+ const passkeyOutage = (method, call) => ({
792
+ ...outage("passkeys", method, ({ stores }) => call(passkeysOf(stores)), seed),
793
+ needs: ["faults", "passkeys"]
794
+ });
795
+ return [
796
+ passkeyOutage("insertPasskey", (passkeys) => passkeys.insertPasskey(passkey)),
797
+ passkeyOutage("findPasskey", (passkeys) => passkeys.findPasskey(passkey.credentialId)),
798
+ passkeyOutage("listUserPasskeys", (passkeys) => passkeys.listUserPasskeys(userId)),
799
+ passkeyOutage("recordPasskeyUse", (passkeys) => passkeys.recordPasskeyUse(userId, passkey.credentialId, { counter: 1, backedUp: false, lastUsedAt: now }, passkey.counter)),
800
+ passkeyOutage("renamePasskey", (passkeys) => passkeys.renamePasskey(userId, passkey.credentialId, "Phone")),
801
+ passkeyOutage("deletePasskey", (passkeys) => passkeys.deletePasskey(userId, passkey.credentialId)),
802
+ passkeyOutage("deleteUserPasskeys", (passkeys) => passkeys.deleteUserPasskeys(userId))
803
+ ];
804
+ }
805
+
806
+ // src/conformance/cases/outage.ts
807
+ function outage2(slot, method, call, seed) {
808
+ return {
809
+ id: `outage.${method}`,
810
+ group: "outage",
811
+ name: `${slot}.${method} rejects when the store cannot answer — never null, false, 0 or an empty page`,
812
+ needs: "faults",
813
+ async run(context) {
814
+ await seed(context);
815
+ await context.faults?.fail(slot, method);
816
+ const error = await rejects(call(context), `${slot}.${method} under an outage should reject: answering an absence turns an outage into a silent lockout`);
817
+ if (error instanceof JanusError2 || error?.name === "StoreFailure") {
818
+ isOurs(error, StoreFailure2, "StoreFailure", `${slot}.${method} under an outage`);
819
+ }
820
+ ok(error?.code !== "NOT_FOUND", `${slot}.${method} under an outage rejected with NOT_FOUND: an outage is never an absence`);
821
+ }
822
+ };
823
+ }
824
+ var user = userRecord();
825
+ var session = sessionRecord({ userId: user.id });
826
+ var token = tokenRecord({ userId: user.id });
827
+ var link = socialLinkRecord({ userId: user.id });
828
+ var now2 = at7("2026-02-01T00:00:00.000Z");
829
+ var seed = async ({ stores }) => {
830
+ await stores.users.insertUser(user);
831
+ await stores.sessions.insertSession(session);
832
+ await stores.tokens.insertToken(token);
833
+ };
834
+ var seedLink = async ({ stores }) => {
835
+ await socialLinksOf(stores).insertSocialLink(link);
836
+ };
837
+ var socialLinkOutage = (method, call) => ({
838
+ ...outage2("socialLinks", method, ({ stores }) => call(socialLinksOf(stores)), seedLink),
839
+ needs: ["faults", "socialLinks"]
840
+ });
841
+ var outageCases = [
842
+ outage2("users", "findUser", ({ stores }) => stores.users.findUser(user.id), seed),
843
+ {
844
+ ...outage2("users", "findUsers", async ({ stores }) => stores.users.findUsers?.call(stores.users, [user.id]), seed),
845
+ needs: ["faults", "findUsers"]
846
+ },
847
+ outage2("users", "findUserByLogin", ({ stores }) => stores.users.findUserByLogin(user.type, user.logins[0] ?? ""), seed),
848
+ outage2("users", "listUsers", ({ stores }) => stores.users.listUsers({ type: user.type, after: null, limit: 10 }), seed),
849
+ outage2("users", "countUsers", ({ stores }) => stores.users.countUsers({ type: user.type }), seed),
850
+ outage2("sessions", "findSessionByTokenHash", ({ stores }) => stores.sessions.findSessionByTokenHash(session.tokenHash), seed),
851
+ outage2("sessions", "extendSession", ({ stores }) => stores.sessions.extendSession(session.id, at7("2099-06-01T00:00:00.000Z")), seed),
852
+ outage2("sessions", "reauthenticateSession", ({ stores }) => stores.sessions.reauthenticateSession(session.id, now2), seed),
853
+ outage2("sessions", "revokeSession", ({ stores }) => stores.sessions.revokeSession(session.id, now2), seed),
854
+ outage2("sessions", "revokeUserSessions", ({ stores }) => stores.sessions.revokeUserSessions(user.id, now2), seed),
855
+ outage2("tokens", "consumeToken", ({ stores }) => stores.tokens.consumeToken(token.tokenHash, "resetPassword", now2), seed),
856
+ outage2("tokens", "countAttempt", ({ stores }) => stores.tokens.countAttempt(token.tokenHash, "resetPassword"), seed),
857
+ outage2("tokens", "spendUserTokens", ({ stores }) => stores.tokens.spendUserTokens(user.id, "resetPassword", now2), seed),
858
+ outage2("users", "deleteUser", ({ stores }) => stores.users.deleteUser(user.id), seed),
859
+ outage2("sessions", "deleteUserSessions", ({ stores }) => stores.sessions.deleteUserSessions(user.id), seed),
860
+ outage2("tokens", "deleteUserTokens", ({ stores }) => stores.tokens.deleteUserTokens(user.id), seed),
861
+ {
862
+ ...outage2("tokens", "deleteExpiredTokens", async ({ stores }) => stores.tokens.deleteExpiredTokens?.call(stores.tokens, now2), seed),
863
+ needs: ["faults", "deleteExpiredTokens"]
864
+ },
865
+ socialLinkOutage("insertSocialLink", (links) => links.insertSocialLink(link)),
866
+ socialLinkOutage("findSocialLink", (links) => links.findSocialLink(link.provider, link.accountId)),
867
+ socialLinkOutage("listUserSocialLinks", (links) => links.listUserSocialLinks(user.id)),
868
+ socialLinkOutage("deleteSocialLink", (links) => links.deleteSocialLink(user.id, link.provider, link.accountId)),
869
+ socialLinkOutage("deleteUserSocialLinks", (links) => links.deleteUserSocialLinks(user.id)),
870
+ ...passkeyOutageCases(outage2, user.id, now2)
871
+ ];
872
+
873
+ // src/conformance/cases/passkeys/deletion.ts
874
+ var group7 = "passkeys";
875
+ var needs4 = "passkeys";
876
+ var passkeyDeletionCases = [
877
+ {
878
+ id: "passkeys.renameOwner",
879
+ group: group7,
880
+ needs: needs4,
881
+ name: "renames a passkey only for its owner: true and the name changed, false for another user or an unknown credential",
882
+ async run({ stores }) {
883
+ const passkeys = passkeysOf(stores);
884
+ const record = passkeyRecord({ counter: 3 });
885
+ await passkeys.insertPasskey(record);
886
+ const { userId, credentialId } = record;
887
+ ok(await passkeys.renamePasskey(mintId2(), credentialId, "Stolen") === false, "renamePasskey by another user should answer false");
888
+ equal(await passkeys.findPasskey(credentialId), record, "renamePasskey by another user should keep the name");
889
+ ok(await passkeys.renamePasskey(userId, credentialId, "Phone \uD83D\uDE00") === true, "renamePasskey by the owner should answer true");
890
+ equal(await passkeys.findPasskey(credentialId), { ...record, name: "Phone \uD83D\uDE00" }, "renamePasskey should change the name and nothing else");
891
+ ok(await passkeys.renamePasskey(userId, `${credentialId}-x`, "Y") === false, "renamePasskey of an unknown credential should answer false");
892
+ }
893
+ },
894
+ {
895
+ id: "passkeys.deleteOwner",
896
+ group: group7,
897
+ needs: needs4,
898
+ name: "deletes a passkey only for its owner: a wrong owner is false and keeps it, a repeat is false",
899
+ async run({ stores }) {
900
+ const passkeys = passkeysOf(stores);
901
+ const record = passkeyRecord();
902
+ await passkeys.insertPasskey(record);
903
+ const { userId, credentialId } = record;
904
+ ok(await passkeys.deletePasskey(mintId2(), credentialId) === false, "deletePasskey by another user should answer false");
905
+ equal(await passkeys.findPasskey(credentialId), record, "deletePasskey by another user should keep the passkey");
906
+ ok(await passkeys.deletePasskey(userId, credentialId) === true, "deletePasskey by the owner should answer true");
907
+ isNull(await passkeys.findPasskey(credentialId), "findPasskey after deletePasskey");
908
+ ok(await passkeys.deletePasskey(userId, credentialId) === false, "deletePasskey repeated should answer false");
909
+ ok(await passkeys.deletePasskey(userId, `${credentialId}-x`) === false, "deletePasskey of an unknown credential should answer false");
910
+ }
911
+ },
912
+ {
913
+ id: "passkeys.deleteUser",
914
+ group: group7,
915
+ needs: needs4,
916
+ name: "deletes every passkey of one user and counts them, 0 for a user with none, and leaves other users’ passkeys",
917
+ async run({ stores }) {
918
+ const passkeys = passkeysOf(stores);
919
+ const userId = mintId2();
920
+ const own = [
921
+ passkeyRecord({ userId }),
922
+ passkeyRecord({ userId }),
923
+ passkeyRecord({ userId })
924
+ ];
925
+ const stranger = passkeyRecord();
926
+ for (const record of [...own, stranger]) {
927
+ await passkeys.insertPasskey(record);
928
+ }
929
+ equal(await passkeys.deleteUserPasskeys(userId), 3, "deleteUserPasskeys should answer how many it deleted");
930
+ for (const record of own) {
931
+ isNull(await passkeys.findPasskey(record.credentialId), "findPasskey after deleteUserPasskeys");
932
+ }
933
+ equal(await passkeys.findPasskey(stranger.credentialId), stranger, "deleteUserPasskeys should not touch another user");
934
+ equal(await passkeys.deleteUserPasskeys(userId), 0, "deleteUserPasskeys for a user with none answers 0, not a failure");
935
+ }
936
+ }
937
+ ];
938
+
939
+ // src/conformance/cases/passkeys/inserts.ts
940
+ var group8 = "passkeys";
941
+ var needs5 = "passkeys";
942
+ var passkeyInsertCases = [
943
+ {
944
+ id: "passkeys.insertIdempotent",
945
+ group: group8,
946
+ needs: needs5,
947
+ name: "answers the stored record when the same user inserts the same credential again, and writes nothing",
948
+ async run({ stores }) {
949
+ const passkeys = passkeysOf(stores);
950
+ const first = passkeyRecord();
951
+ await passkeys.insertPasskey(first);
952
+ const again = { ...first, name: "Changed", counter: 9 };
953
+ equal(await passkeys.insertPasskey(again), first, "insertPasskey of a credential its user already holds should answer the stored record, not the new one");
954
+ equal(await passkeys.findPasskey(first.credentialId), first, "insertPasskey of a credential already held should not write");
955
+ }
956
+ },
957
+ {
958
+ id: "passkeys.insertTaken",
959
+ group: group8,
960
+ needs: needs5,
961
+ name: "answers the holder’s record, and writes nothing, when another user inserts a held credential",
962
+ async run({ stores }) {
963
+ const passkeys = passkeysOf(stores);
964
+ const holder = passkeyRecord();
965
+ await passkeys.insertPasskey(holder);
966
+ const rival = passkeyRecord({
967
+ credentialId: holder.credentialId,
968
+ userId: mintId2()
969
+ });
970
+ equal(await passkeys.insertPasskey(rival), holder, "insertPasskey of another user’s credential should answer the holder’s record: the core compares userId to learn it lost");
971
+ equal(await passkeys.findPasskey(holder.credentialId), holder, "insertPasskey of another user’s credential should not replace the holder");
972
+ equal(await passkeys.listUserPasskeys(rival.userId), [], "insertPasskey of another user’s credential should leave the rival with no passkey");
973
+ }
974
+ },
975
+ {
976
+ id: "passkeys.insertConcurrent",
977
+ group: group8,
978
+ needs: needs5,
979
+ name: "stores one record when twenty users insert one credential at once, and answers all of them that record",
980
+ async run({ stores }) {
981
+ const passkeys = passkeysOf(stores);
982
+ const base = passkeyRecord();
983
+ const attempts = Array.from({ length: 20 }, () => ({
984
+ ...base,
985
+ userId: mintId2()
986
+ }));
987
+ const answers = await Promise.all(attempts.map((record) => passkeys.insertPasskey(record)));
988
+ const stored = await passkeys.findPasskey(base.credentialId);
989
+ ok(stored !== null && attempts.some((a) => a.userId === stored.userId), "one of the twenty inserts should be the stored record");
990
+ for (const answer of answers) {
991
+ equal(answer, stored, "every concurrent insertPasskey should answer the one stored record: a unique key, never a read then a write");
992
+ }
993
+ let held = 0;
994
+ for (const record of attempts) {
995
+ held += (await passkeys.listUserPasskeys(record.userId)).length;
996
+ }
997
+ equal(held, 1, "exactly one of the twenty users should hold the passkey");
998
+ }
999
+ }
1000
+ ];
1001
+
1002
+ // src/conformance/cases/passkeys/reads.ts
1003
+ var group9 = "passkeys";
1004
+ var needs6 = "passkeys";
1005
+ var passkeyReadCases = [
1006
+ {
1007
+ id: "passkeys.findVerbatim",
1008
+ group: group9,
1009
+ needs: needs6,
1010
+ name: "answers a stored passkey verbatim by its credential id, and null for an unknown one",
1011
+ async run({ stores }) {
1012
+ const passkeys = passkeysOf(stores);
1013
+ const record = passkeyRecord({
1014
+ transports: [],
1015
+ lastUsedAt: new Date("2026-01-05T10:20:30.456Z"),
1016
+ createdAt: new Date("2026-01-04T10:20:30.123Z")
1017
+ });
1018
+ equal(await passkeys.insertPasskey(record), record, "insertPasskey should answer the record as written: empty transports kept, dates to the millisecond");
1019
+ equal(await passkeys.findPasskey(record.credentialId), record, "findPasskey should answer the stored record verbatim");
1020
+ isNull(await passkeys.findPasskey(`${record.credentialId}-x`), "findPasskey for an unknown credential id");
1021
+ }
1022
+ },
1023
+ {
1024
+ id: "passkeys.bytesRoundTrip",
1025
+ group: group9,
1026
+ needs: needs6,
1027
+ name: "round-trips the public key byte for byte, and compares credential ids case-sensitively",
1028
+ async run({ stores }) {
1029
+ const passkeys = passkeysOf(stores);
1030
+ const tag = mintId2();
1031
+ const key = "pQECAyYgASFYIEdA_-Zq0wFfX3k8w1x2yq9uZ7JmAbC-_zZ09";
1032
+ const lower = passkeyRecord({
1033
+ credentialId: `abc-${tag}`,
1034
+ publicKey: key
1035
+ });
1036
+ const upper = passkeyRecord({
1037
+ credentialId: `ABC-${tag}`,
1038
+ publicKey: key.toUpperCase(),
1039
+ userId: mintId2()
1040
+ });
1041
+ const named = passkeyRecord({
1042
+ name: "Clé de Ada 日本 \uD83D\uDE00",
1043
+ publicKey: `${key}${key}`
1044
+ });
1045
+ for (const record of [lower, upper, named]) {
1046
+ equal(await passkeys.insertPasskey(record), record, `insertPasskey of "${record.credentialId}" should write a credential of its own: case is a difference`);
1047
+ }
1048
+ for (const record of [lower, upper, named]) {
1049
+ equal(await passkeys.findPasskey(record.credentialId), record, `findPasskey of "${record.credentialId}" should answer it as written, public key included`);
1050
+ }
1051
+ }
1052
+ },
1053
+ {
1054
+ id: "passkeys.listIsolation",
1055
+ group: group9,
1056
+ needs: needs6,
1057
+ name: "lists one user’s passkeys and only theirs, and an empty list — never null — for a user with none",
1058
+ async run({ stores }) {
1059
+ const passkeys = passkeysOf(stores);
1060
+ const userId = mintId2();
1061
+ const own = [
1062
+ passkeyRecord({ userId, name: "a" }),
1063
+ passkeyRecord({ userId, name: "b" })
1064
+ ];
1065
+ const stranger = passkeyRecord();
1066
+ for (const record of [...own, stranger]) {
1067
+ await passkeys.insertPasskey(record);
1068
+ }
1069
+ const listed = [...await passkeys.listUserPasskeys(userId)].sort((a, b) => a.name.localeCompare(b.name));
1070
+ equal(listed, own, "listUserPasskeys should answer the user’s own passkeys, verbatim, and no one else’s");
1071
+ equal(await passkeys.listUserPasskeys(mintId2()), [], "listUserPasskeys for a user with none answers [], not null");
1072
+ }
1073
+ }
1074
+ ];
1075
+
1076
+ // src/conformance/cases/passkeys/uses.ts
1077
+ var group10 = "passkeys";
1078
+ var needs7 = "passkeys";
1079
+ var usedAt = new Date("2026-03-01T08:09:10.111Z");
1080
+ var passkeyUseCases = [
1081
+ {
1082
+ id: "passkeys.useConditional",
1083
+ group: group10,
1084
+ needs: needs7,
1085
+ name: "records a use only if the counter is still ifCounter: the updated record is answered, a stale counter is null and writes nothing",
1086
+ async run({ stores }) {
1087
+ const passkeys = passkeysOf(stores);
1088
+ const record = passkeyRecord({ counter: 4, backedUp: false });
1089
+ await passkeys.insertPasskey(record);
1090
+ const { userId, credentialId } = record;
1091
+ const updated = await passkeys.recordPasskeyUse(userId, credentialId, { counter: 7, backedUp: true, lastUsedAt: usedAt }, 4);
1092
+ const expected = {
1093
+ ...record,
1094
+ counter: 7,
1095
+ backedUp: true,
1096
+ lastUsedAt: usedAt
1097
+ };
1098
+ equal(updated, expected, "recordPasskeyUse with the matching counter should answer the updated record");
1099
+ equal(await passkeys.findPasskey(credentialId), expected, "recordPasskeyUse should have written counter, backedUp and lastUsedAt, and nothing else");
1100
+ isNull(await passkeys.recordPasskeyUse(userId, credentialId, { counter: 9, backedUp: false, lastUsedAt: new Date(0) }, 4), "recordPasskeyUse with a counter that no longer matches");
1101
+ equal(await passkeys.findPasskey(credentialId), expected, "recordPasskeyUse with a stale counter should write nothing");
1102
+ }
1103
+ },
1104
+ {
1105
+ id: "passkeys.useOwnerAndUnknown",
1106
+ group: group10,
1107
+ needs: needs7,
1108
+ name: "answers null, and writes nothing, for a use by another user or of an unknown credential",
1109
+ async run({ stores }) {
1110
+ const passkeys = passkeysOf(stores);
1111
+ const record = passkeyRecord({ counter: 2 });
1112
+ await passkeys.insertPasskey(record);
1113
+ const use = { counter: 3, backedUp: false, lastUsedAt: usedAt };
1114
+ isNull(await passkeys.recordPasskeyUse(mintId2(), record.credentialId, use, 2), "recordPasskeyUse by another user");
1115
+ isNull(await passkeys.recordPasskeyUse(record.userId, `${record.credentialId}-unknown`, use, 2), "recordPasskeyUse of an unknown credential");
1116
+ equal(await passkeys.findPasskey(record.credentialId), record, "a refused recordPasskeyUse should leave the passkey whole");
1117
+ }
1118
+ },
1119
+ {
1120
+ id: "passkeys.useConcurrent",
1121
+ group: group10,
1122
+ needs: needs7,
1123
+ name: "lets one of twenty concurrent uses that read the same counter pass, and answers null to the others",
1124
+ async run({ stores }) {
1125
+ const passkeys = passkeysOf(stores);
1126
+ const record = passkeyRecord({ counter: 10 });
1127
+ await passkeys.insertPasskey(record);
1128
+ const answers = await Promise.all(Array.from({ length: 20 }, (_, index) => passkeys.recordPasskeyUse(record.userId, record.credentialId, {
1129
+ counter: 11 + index,
1130
+ backedUp: false,
1131
+ lastUsedAt: usedAt
1132
+ }, 10)));
1133
+ const winners = answers.filter((answer) => answer !== null);
1134
+ equal(winners.length, 1, "exactly one concurrent recordPasskeyUse should pass: a conditional write, never a read then a write");
1135
+ const stored = await passkeys.findPasskey(record.credentialId);
1136
+ ok(stored !== null && stored.counter === winners[0]?.counter, "the stored counter should be the winner’s");
1137
+ }
1138
+ }
1139
+ ];
1140
+
1141
+ // src/conformance/cases/passkeys/index.ts
1142
+ var passkeyStoreCases = [
1143
+ ...passkeyReadCases,
1144
+ ...passkeyInsertCases,
1145
+ ...passkeyUseCases,
1146
+ ...passkeyDeletionCases
1147
+ ];
1148
+
1149
+ // src/conformance/cases/sessions/deletion.ts
1150
+ var group11 = "sessions";
1151
+ var sessionDeletionCases = [
1152
+ {
1153
+ id: "sessions.deleteUser",
1154
+ group: group11,
1155
+ name: "deletes every session of one user — standing, revoked or lapsed — and counts them",
1156
+ async run({ stores }) {
1157
+ const userId = mintId2();
1158
+ const lapsed = sessionRecord({
1159
+ userId,
1160
+ expiresAt: at7("2026-01-02T00:00:00.000Z")
1161
+ });
1162
+ const records = [
1163
+ sessionRecord({ userId }),
1164
+ sessionRecord({ userId, revokedAt: at7("2026-01-02T00:00:00.000Z") }),
1165
+ lapsed
1166
+ ];
1167
+ const stranger = sessionRecord();
1168
+ for (const record of [...records, stranger]) {
1169
+ await stores.sessions.insertSession(record);
1170
+ }
1171
+ const lapsedHeld = await stores.sessions.findSessionByTokenHash(lapsed.tokenHash) !== null;
1172
+ const expected = lapsedHeld ? 3 : 2;
1173
+ const deleted = await stores.sessions.deleteUserSessions(userId);
1174
+ ok(deleted === expected, `deleteUserSessions: how many it deleted, revoked and lapsed ones included — ${String(expected)}, as the lapsed one is ${lapsedHeld ? "still held" : "already expired"}; got ${String(deleted)}`);
1175
+ for (const record of records) {
1176
+ isNull(await stores.sessions.findSessionByTokenHash(record.tokenHash), "findSessionByTokenHash after deleteUserSessions");
1177
+ }
1178
+ equal(await stores.sessions.findSessionByTokenHash(stranger.tokenHash), stranger, "deleteUserSessions should not touch another user");
1179
+ equal(await stores.sessions.deleteUserSessions(userId), 0, "deleteUserSessions for a user with none answers 0, not a failure");
1180
+ }
1181
+ },
1182
+ {
1183
+ id: "sessions.deleteExpired",
1184
+ group: group11,
1185
+ name: "deletes sessions whose expiry is at or before the instant, and only those",
1186
+ needs: "deleteExpiredSessions",
1187
+ async run({ stores }) {
1188
+ const collect = stores.sessions.deleteExpiredSessions;
1189
+ ok(collect !== undefined, "deleteExpiredSessions should be present");
1190
+ const lapsed = sessionRecord({
1191
+ expiresAt: at7("2026-01-10T00:00:00.000Z")
1192
+ });
1193
+ const living = sessionRecord({
1194
+ expiresAt: at7("2026-01-10T00:00:00.001Z")
1195
+ });
1196
+ await stores.sessions.insertSession(lapsed);
1197
+ await stores.sessions.insertSession(living);
1198
+ equal(await collect?.call(stores.sessions, at7("2026-01-10T00:00:00.000Z")), 1, "deleteExpiredSessions: how many it deleted");
1199
+ isNull(await stores.sessions.findSessionByTokenHash(lapsed.tokenHash), "findSessionByTokenHash after deleteExpiredSessions");
1200
+ equal(await stores.sessions.findSessionByTokenHash(living.tokenHash), living, "deleteExpiredSessions should keep a session one millisecond short of lapsing");
1201
+ }
1202
+ }
1203
+ ];
1204
+
1205
+ // src/conformance/cases/sessions/extension.ts
1206
+ var group12 = "sessions";
1207
+ var sessionExtensionCases = [
1208
+ {
1209
+ id: "sessions.extend",
1210
+ group: group12,
1211
+ name: "extends a standing session, and never brings back a revoked one",
1212
+ async run({ stores }) {
1213
+ const standing = sessionRecord();
1214
+ const revoked = sessionRecord({
1215
+ revokedAt: at7("2026-01-02T00:00:00.000Z")
1216
+ });
1217
+ await stores.sessions.insertSession(standing);
1218
+ await stores.sessions.insertSession(revoked);
1219
+ const later = at7("2099-06-01T00:00:00.000Z");
1220
+ equal(await stores.sessions.extendSession(standing.id, later), { ...standing, expiresAt: later }, "extendSession should answer the session with its new expiresAt");
1221
+ isNull(await stores.sessions.extendSession(revoked.id, later), "extendSession on a revoked session — an extension racing a revocation must never bring it back");
1222
+ equal(await stores.sessions.findSessionByTokenHash(revoked.tokenHash), revoked, "extendSession refused on a revoked session should have written nothing");
1223
+ isNull(await stores.sessions.extendSession(mintId2(), later), "extendSession on an unknown session");
1224
+ }
1225
+ },
1226
+ {
1227
+ id: "sessions.extendLastUsed",
1228
+ group: group12,
1229
+ name: "writes lastUsedAt with the extension when given, and keeps device and lastUsedAt otherwise",
1230
+ async run({ stores }) {
1231
+ const first = at7("2026-01-01T00:00:00.000Z");
1232
+ const record = sessionRecord({
1233
+ device: "Firefox on Linux",
1234
+ lastUsedAt: first
1235
+ });
1236
+ const old = sessionRecord();
1237
+ await stores.sessions.insertSession(record);
1238
+ await stores.sessions.insertSession(old);
1239
+ const later = at7("2099-06-01T00:00:00.000Z");
1240
+ const used = at7("2026-02-01T00:00:00.000Z");
1241
+ equal(await stores.sessions.findSessionByTokenHash(record.tokenHash), record, "device and lastUsedAt should be stored and read back");
1242
+ equal(await stores.sessions.extendSession(record.id, later), { ...record, expiresAt: later }, "extendSession without lastUsedAt should leave device and lastUsedAt as they were");
1243
+ equal(await stores.sessions.extendSession(record.id, later, used), { ...record, expiresAt: later, lastUsedAt: used }, "extendSession with lastUsedAt should write it and keep device");
1244
+ equal(await stores.sessions.extendSession(old.id, later, used), { ...old, expiresAt: later, lastUsedAt: used }, "a record written without device or lastUsedAt should take lastUsedAt on extension");
1245
+ }
1246
+ }
1247
+ ];
1248
+
1249
+ // src/conformance/cases/sessions/inserts.ts
1250
+ var group13 = "sessions";
1251
+ var sessionInsertCases = [
1252
+ {
1253
+ id: "sessions.idempotentInsert",
1254
+ group: group13,
1255
+ name: "is idempotent under retry: inserting an existing session id writes nothing",
1256
+ async run({ stores }) {
1257
+ const record = sessionRecord();
1258
+ await stores.sessions.insertSession(record);
1259
+ await stores.sessions.insertSession({
1260
+ ...record,
1261
+ expiresAt: new Date("2099-06-01T00:00:00.000Z")
1262
+ });
1263
+ equal(await stores.sessions.findSessionByTokenHash(record.tokenHash), record, "insertSession retried with the same id should write nothing");
1264
+ }
1265
+ }
1266
+ ];
1267
+
1268
+ // src/conformance/cases/sessions/list.ts
1269
+ var group14 = "sessions";
1270
+ var sessionListCases = [
1271
+ {
1272
+ id: "sessions.listUser",
1273
+ group: group14,
1274
+ name: "lists the standing sessions of one user: not revoked, not lapsed at the instant, not another user",
1275
+ needs: "listUserSessions",
1276
+ async run({ stores }) {
1277
+ const list = stores.sessions.listUserSessions?.bind(stores.sessions);
1278
+ if (list === undefined) {
1279
+ throw new Error("listUserSessions should be present");
1280
+ }
1281
+ const userId = mintId2();
1282
+ const standing = sessionRecord({
1283
+ userId,
1284
+ device: "Safari on iOS",
1285
+ lastUsedAt: at7("2026-01-05T00:00:00.000Z")
1286
+ });
1287
+ const plain = sessionRecord({ userId });
1288
+ const revoked = sessionRecord({
1289
+ userId,
1290
+ revokedAt: at7("2026-01-02T00:00:00.000Z")
1291
+ });
1292
+ const lapsed = sessionRecord({
1293
+ userId,
1294
+ expiresAt: at7("2026-01-10T00:00:00.000Z")
1295
+ });
1296
+ const edge = sessionRecord({
1297
+ userId,
1298
+ expiresAt: at7("2026-01-15T00:00:00.000Z")
1299
+ });
1300
+ const stranger = sessionRecord();
1301
+ for (const record of [standing, plain, revoked, lapsed, edge, stranger]) {
1302
+ await stores.sessions.insertSession(record);
1303
+ }
1304
+ const listed = await list(userId, at7("2026-01-15T00:00:00.000Z"));
1305
+ equal([...listed].sort((a, b) => a.id.localeCompare(b.id)), [standing, plain].sort((a, b) => a.id.localeCompare(b.id)), "listUserSessions: only the standing sessions of the user, records verbatim (an expiresAt equal to now has lapsed)");
1306
+ equal(await list(mintId2(), at7("2026-01-15T00:00:00.000Z")), [], "listUserSessions for a user with none answers [], not a failure");
1307
+ }
1308
+ }
1309
+ ];
1310
+
1311
+ // src/conformance/cases/sessions/reads.ts
1312
+ var group15 = "sessions";
1313
+ var sessionReadCases = [
1314
+ {
1315
+ id: "sessions.verbatim",
1316
+ group: group15,
1317
+ name: "answers a stored session verbatim — revoked or lapsed — or null once lapsed, and never a changed record",
1318
+ async run({ stores }) {
1319
+ const standing = sessionRecord();
1320
+ const revoked = sessionRecord({
1321
+ revokedAt: at7("2026-01-02T00:00:00.000Z")
1322
+ });
1323
+ const lapsed = sessionRecord({
1324
+ expiresAt: at7("2020-01-01T00:00:00.000Z")
1325
+ });
1326
+ for (const record of [standing, revoked, lapsed]) {
1327
+ await stores.sessions.insertSession(record);
1328
+ }
1329
+ equal(await stores.sessions.findSessionByTokenHash(standing.tokenHash), standing, "findSessionByTokenHash for a standing session");
1330
+ equal(await stores.sessions.findSessionByTokenHash(revoked.tokenHash), revoked, "findSessionByTokenHash for a revoked session should answer it verbatim — revocation is the core’s to read");
1331
+ const found = await stores.sessions.findSessionByTokenHash(lapsed.tokenHash);
1332
+ if (found !== null) {
1333
+ equal(found, lapsed, "findSessionByTokenHash for a lapsed session should answer it verbatim, or null");
1334
+ }
1335
+ isNull(await stores.sessions.findSessionByTokenHash("f".repeat(64)), "findSessionByTokenHash for an unknown hash");
1336
+ }
1337
+ }
1338
+ ];
1339
+
1340
+ // src/conformance/cases/sessions/reauthentication.ts
1341
+ var group16 = "sessions";
1342
+ var sessionReauthenticationCases = [
1343
+ {
1344
+ id: "sessions.reauthenticate",
1345
+ group: group16,
1346
+ name: "moves authenticatedAt on a standing session, and never brings back a revoked one",
1347
+ async run({ stores }) {
1348
+ const standing = sessionRecord();
1349
+ const revoked = sessionRecord({
1350
+ revokedAt: at7("2026-01-02T00:00:00.000Z")
1351
+ });
1352
+ await stores.sessions.insertSession(standing);
1353
+ await stores.sessions.insertSession(revoked);
1354
+ const now = at7("2026-02-01T00:00:00.000Z");
1355
+ equal(await stores.sessions.reauthenticateSession(standing.id, now), { ...standing, authenticatedAt: now }, "reauthenticateSession should answer the session with its new authenticatedAt, and every other field as it was");
1356
+ equal(await stores.sessions.findSessionByTokenHash(standing.tokenHash), { ...standing, authenticatedAt: now }, "reauthenticateSession should have written authenticatedAt, and read back the same");
1357
+ isNull(await stores.sessions.reauthenticateSession(revoked.id, now), "reauthenticateSession on a revoked session — a confirmation racing a revocation must never bring it back");
1358
+ equal(await stores.sessions.findSessionByTokenHash(revoked.tokenHash), revoked, "reauthenticateSession refused on a revoked session should have written nothing");
1359
+ isNull(await stores.sessions.reauthenticateSession(mintId2(), now), "reauthenticateSession on an unknown session");
1360
+ }
1361
+ },
1362
+ {
1363
+ id: "sessions.amr",
1364
+ group: group16,
1365
+ name: "keeps the methods a session proved, and replaces them only when a step-up gives them",
1366
+ async run({ stores }) {
1367
+ const record = sessionRecord({ amr: ["hwk", "user"] });
1368
+ await stores.sessions.insertSession(record);
1369
+ equal((await stores.sessions.findSessionByTokenHash(record.tokenHash))?.amr, ["hwk", "user"], "insertSession should have written amr, and read it back in order");
1370
+ const now = at7("2026-02-01T00:00:00.000Z");
1371
+ equal((await stores.sessions.reauthenticateSession(record.id, now))?.amr, ["hwk", "user"], "reauthenticateSession without amr should leave amr as it was");
1372
+ equal((await stores.sessions.reauthenticateSession(record.id, now, [
1373
+ "hwk",
1374
+ "user",
1375
+ "otp",
1376
+ "mfa"
1377
+ ]))?.amr, ["hwk", "user", "otp", "mfa"], "reauthenticateSession with amr should replace it");
1378
+ equal((await stores.sessions.findSessionByTokenHash(record.tokenHash))?.amr, ["hwk", "user", "otp", "mfa"], "the replaced amr should read back the same");
1379
+ const legacy = sessionRecord();
1380
+ await stores.sessions.insertSession(legacy);
1381
+ equal((await stores.sessions.findSessionByTokenHash(legacy.tokenHash))?.amr ?? [], [], "a session written without amr reads as none");
1382
+ }
1383
+ },
1384
+ {
1385
+ id: "sessions.reauthenticateRace",
1386
+ group: group16,
1387
+ name: "never brings back a session whose revocation races its confirmation",
1388
+ async run({ stores }) {
1389
+ const now = at7("2026-02-01T00:00:00.000Z");
1390
+ for (let round = 0;round < 10; round += 1) {
1391
+ const record = sessionRecord();
1392
+ await stores.sessions.insertSession(record);
1393
+ await Promise.all([
1394
+ stores.sessions.reauthenticateSession(record.id, now),
1395
+ stores.sessions.revokeSession(record.id, now)
1396
+ ]);
1397
+ equal((await stores.sessions.findSessionByTokenHash(record.tokenHash))?.revokedAt, now, "reauthenticateSession racing revokeSession: the session should stay revoked — one conditional write, never a read then a write");
1398
+ }
1399
+ }
1400
+ }
1401
+ ];
1402
+
1403
+ // src/conformance/cases/sessions/revocation.ts
1404
+ var group17 = "sessions";
1405
+ var sessionRevocationCases = [
1406
+ {
1407
+ id: "sessions.revoke",
1408
+ group: group17,
1409
+ name: "revokes once and keeps the first revokedAt; answers false only when there is no session",
1410
+ async run({ stores }) {
1411
+ const record = sessionRecord();
1412
+ await stores.sessions.insertSession(record);
1413
+ const first = at7("2026-02-01T00:00:00.000Z");
1414
+ equal(await stores.sessions.revokeSession(record.id, first), true, "revokeSession on a standing session");
1415
+ equal(await stores.sessions.revokeSession(record.id, at7("2026-03-01T00:00:00.000Z")), true, "revokeSession on a revoked session still answers true: the session exists");
1416
+ equal((await stores.sessions.findSessionByTokenHash(record.tokenHash))?.revokedAt, first, "revokeSession twice should keep the first revokedAt");
1417
+ equal(await stores.sessions.revokeSession(mintId2(), first), false, "revokeSession on an unknown session");
1418
+ }
1419
+ },
1420
+ {
1421
+ id: "sessions.revokeUser",
1422
+ group: group17,
1423
+ name: "revokes every standing session of one user but the one excepted, and counts only what it revoked",
1424
+ async run({ stores }) {
1425
+ const userId = mintId2();
1426
+ const current = sessionRecord({ userId });
1427
+ const other = sessionRecord({ userId });
1428
+ const already = sessionRecord({
1429
+ userId,
1430
+ revokedAt: at7("2026-01-02T00:00:00.000Z")
1431
+ });
1432
+ const stranger = sessionRecord();
1433
+ for (const record of [current, other, already, stranger]) {
1434
+ await stores.sessions.insertSession(record);
1435
+ }
1436
+ const now = at7("2026-02-01T00:00:00.000Z");
1437
+ equal(await stores.sessions.revokeUserSessions(userId, now, current.id), 1, "revokeUserSessions with except: how many this call revoked");
1438
+ isNull((await stores.sessions.findSessionByTokenHash(current.tokenHash))?.revokedAt ?? null, "revokeUserSessions should spare the excepted session");
1439
+ equal((await stores.sessions.findSessionByTokenHash(already.tokenHash))?.revokedAt, already.revokedAt, "revokeUserSessions should keep an earlier revokedAt");
1440
+ equal(await stores.sessions.findSessionByTokenHash(stranger.tokenHash), stranger, "revokeUserSessions should not touch another user");
1441
+ equal(await stores.sessions.revokeUserSessions(userId, now), 1, "revokeUserSessions without except");
1442
+ equal(await stores.sessions.revokeUserSessions(mintId2(), now), 0, "revokeUserSessions for a user with none answers 0, not a failure");
1443
+ }
1444
+ },
1445
+ {
1446
+ id: "sessions.revokeUserIssuedBefore",
1447
+ group: group17,
1448
+ name: "revokes only the sessions created strictly before issuedBefore, and still spares the one excepted",
1449
+ async run({ stores }) {
1450
+ const userId = mintId2();
1451
+ const cutoff = at7("2026-01-10T00:00:00.000Z");
1452
+ const older = sessionRecord({
1453
+ userId,
1454
+ createdAt: at7("2026-01-09T23:59:59.999Z")
1455
+ });
1456
+ const olderSpared = sessionRecord({
1457
+ userId,
1458
+ createdAt: at7("2026-01-05T00:00:00.000Z")
1459
+ });
1460
+ const atCutoff = sessionRecord({ userId, createdAt: cutoff });
1461
+ const newer = sessionRecord({
1462
+ userId,
1463
+ createdAt: at7("2026-01-11T00:00:00.000Z")
1464
+ });
1465
+ for (const record of [older, olderSpared, atCutoff, newer]) {
1466
+ await stores.sessions.insertSession(record);
1467
+ }
1468
+ const now = at7("2026-02-01T00:00:00.000Z");
1469
+ equal(await stores.sessions.revokeUserSessions(userId, now, olderSpared.id, cutoff), 1, "revokeUserSessions with issuedBefore and except: how many this call revoked");
1470
+ const revokedAt = async (record) => (await stores.sessions.findSessionByTokenHash(record.tokenHash))?.revokedAt ?? null;
1471
+ equal(await revokedAt(older), now, "a session created before the cut-off goes");
1472
+ isNull(await revokedAt(olderSpared), "the excepted session stands");
1473
+ isNull(await revokedAt(atCutoff), "a session created at the cut-off stands");
1474
+ isNull(await revokedAt(newer), "a session created after the cut-off stands");
1475
+ equal(await stores.sessions.revokeUserSessions(userId, now, undefined, cutoff), 1, "revokeUserSessions with issuedBefore and no except: only the older session left");
1476
+ equal(await revokedAt(olderSpared), now, "without an except, the older session goes as well");
1477
+ isNull(await revokedAt(atCutoff), "still standing at the cut-off");
1478
+ }
1479
+ }
1480
+ ];
1481
+
1482
+ // src/conformance/cases/sessions/index.ts
1483
+ var sessionStoreCases = [
1484
+ ...sessionReadCases,
1485
+ ...sessionInsertCases,
1486
+ ...sessionExtensionCases,
1487
+ ...sessionListCases,
1488
+ ...sessionReauthenticationCases,
1489
+ ...sessionRevocationCases,
1490
+ ...sessionDeletionCases
1491
+ ];
1492
+
1493
+ // src/conformance/cases/social-links/deletion.ts
1494
+ var group18 = "socialLinks";
1495
+ var needs8 = "socialLinks";
1496
+ var socialLinkDeletionCases = [
1497
+ {
1498
+ id: "socialLinks.deleteOwner",
1499
+ group: group18,
1500
+ needs: needs8,
1501
+ name: "deletes a link only for its owner: a wrong owner is false and keeps it, a repeat is false",
1502
+ async run({ stores }) {
1503
+ const links = socialLinksOf(stores);
1504
+ const record = socialLinkRecord();
1505
+ await links.insertSocialLink(record);
1506
+ const { provider, accountId } = record;
1507
+ ok(await links.deleteSocialLink(mintId2(), provider, accountId) === false, "deleteSocialLink by another user should answer false");
1508
+ equal(await links.findSocialLink(provider, accountId), record, "deleteSocialLink by another user should keep the link");
1509
+ ok(await links.deleteSocialLink(record.userId, provider, accountId) === true, "deleteSocialLink by the owner should answer true");
1510
+ isNull(await links.findSocialLink(provider, accountId), "findSocialLink after deleteSocialLink");
1511
+ ok(await links.deleteSocialLink(record.userId, provider, accountId) === false, "deleteSocialLink repeated should answer false");
1512
+ ok(await links.deleteSocialLink(record.userId, provider, `${accountId}-unknown`) === false, "deleteSocialLink of an unknown pair should answer false");
1513
+ }
1514
+ },
1515
+ {
1516
+ id: "socialLinks.deleteUser",
1517
+ group: group18,
1518
+ needs: needs8,
1519
+ name: "deletes every link of one user and counts them, 0 for a user with none, and leaves other users’ links",
1520
+ async run({ stores }) {
1521
+ const links = socialLinksOf(stores);
1522
+ const userId = mintId2();
1523
+ const own = [
1524
+ socialLinkRecord({ userId }),
1525
+ socialLinkRecord({ userId, provider: "github" }),
1526
+ socialLinkRecord({ userId, provider: "microsoft" })
1527
+ ];
1528
+ const stranger = socialLinkRecord();
1529
+ for (const record of [...own, stranger]) {
1530
+ await links.insertSocialLink(record);
1531
+ }
1532
+ equal(await links.deleteUserSocialLinks(userId), 3, "deleteUserSocialLinks should answer how many it deleted");
1533
+ for (const record of own) {
1534
+ isNull(await links.findSocialLink(record.provider, record.accountId), "findSocialLink after deleteUserSocialLinks");
1535
+ }
1536
+ equal(await links.findSocialLink(stranger.provider, stranger.accountId), stranger, "deleteUserSocialLinks should not touch another user");
1537
+ equal(await links.deleteUserSocialLinks(userId), 0, "deleteUserSocialLinks for a user with none answers 0, not a failure");
1538
+ }
1539
+ }
1540
+ ];
1541
+
1542
+ // src/conformance/cases/social-links/inserts.ts
1543
+ var group19 = "socialLinks";
1544
+ var needs9 = "socialLinks";
1545
+ var socialLinkInsertCases = [
1546
+ {
1547
+ id: "socialLinks.insertIdempotent",
1548
+ group: group19,
1549
+ needs: needs9,
1550
+ name: "answers the stored record when the same user inserts the same pair again, and writes nothing",
1551
+ async run({ stores }) {
1552
+ const links = socialLinksOf(stores);
1553
+ const first = socialLinkRecord();
1554
+ await links.insertSocialLink(first);
1555
+ const again = {
1556
+ ...first,
1557
+ email: "changed@example.test",
1558
+ createdAt: new Date("2027-01-01T00:00:00.000Z")
1559
+ };
1560
+ equal(await links.insertSocialLink(again), first, "insertSocialLink of a pair its user already holds should answer the stored record, not the new one");
1561
+ equal(await links.findSocialLink(first.provider, first.accountId), first, "insertSocialLink of a pair already held should not write");
1562
+ }
1563
+ },
1564
+ {
1565
+ id: "socialLinks.insertTaken",
1566
+ group: group19,
1567
+ needs: needs9,
1568
+ name: "answers the holder’s record, and writes nothing, when another user inserts a linked pair",
1569
+ async run({ stores }) {
1570
+ const links = socialLinksOf(stores);
1571
+ const holder = socialLinkRecord();
1572
+ await links.insertSocialLink(holder);
1573
+ const rival = socialLinkRecord({
1574
+ provider: holder.provider,
1575
+ accountId: holder.accountId,
1576
+ userId: mintId2()
1577
+ });
1578
+ equal(await links.insertSocialLink(rival), holder, "insertSocialLink of another user’s pair should answer the holder’s record: the core compares userId to learn it lost");
1579
+ equal(await links.findSocialLink(holder.provider, holder.accountId), holder, "insertSocialLink of another user’s pair should not replace the holder");
1580
+ equal(await links.listUserSocialLinks(rival.userId), [], "insertSocialLink of another user’s pair should leave the rival with no link");
1581
+ }
1582
+ },
1583
+ {
1584
+ id: "socialLinks.insertConcurrent",
1585
+ group: group19,
1586
+ needs: needs9,
1587
+ name: "stores one record when twenty users insert one pair at once, and answers all of them that record",
1588
+ async run({ stores }) {
1589
+ const links = socialLinksOf(stores);
1590
+ const base = socialLinkRecord();
1591
+ const attempts = Array.from({ length: 20 }, () => ({
1592
+ ...base,
1593
+ userId: mintId2()
1594
+ }));
1595
+ const answers = await Promise.all(attempts.map((record) => links.insertSocialLink(record)));
1596
+ const stored = await links.findSocialLink(base.provider, base.accountId);
1597
+ ok(stored !== null && attempts.some((a) => a.userId === stored.userId), "one of the twenty inserts should be the stored record");
1598
+ for (const answer of answers) {
1599
+ equal(answer, stored, "every concurrent insertSocialLink should answer the one stored record: a unique key, never a read then a write");
1600
+ }
1601
+ let held = 0;
1602
+ for (const record of attempts) {
1603
+ held += (await links.listUserSocialLinks(record.userId)).length;
1604
+ }
1605
+ equal(held, 1, "exactly one of the twenty users should hold the link");
1606
+ }
1607
+ }
1608
+ ];
1609
+
1610
+ // src/conformance/cases/social-links/reads.ts
1611
+ var group20 = "socialLinks";
1612
+ var needs10 = "socialLinks";
1613
+ var socialLinkReadCases = [
1614
+ {
1615
+ id: "socialLinks.findVerbatim",
1616
+ group: group20,
1617
+ needs: needs10,
1618
+ name: "answers a stored link verbatim by its pair, and null for an unknown pair",
1619
+ async run({ stores }) {
1620
+ const links = socialLinksOf(stores);
1621
+ const record = socialLinkRecord({
1622
+ email: null,
1623
+ createdAt: new Date("2026-01-05T10:20:30.456Z")
1624
+ });
1625
+ equal(await links.insertSocialLink(record), record, "insertSocialLink should answer the record as written: a null e-mail kept null, createdAt to the millisecond");
1626
+ equal(await links.findSocialLink(record.provider, record.accountId), record, "findSocialLink should answer the stored record verbatim");
1627
+ isNull(await links.findSocialLink(record.provider, `${record.accountId}-x`), "findSocialLink for an unknown accountId");
1628
+ isNull(await links.findSocialLink("github", record.accountId), "findSocialLink for the same accountId under another provider");
1629
+ }
1630
+ },
1631
+ {
1632
+ id: "socialLinks.bytesRoundTrip",
1633
+ group: group20,
1634
+ needs: needs10,
1635
+ name: "round-trips unicode, and compares provider and accountId case-sensitively",
1636
+ async run({ stores }) {
1637
+ const links = socialLinksOf(stores);
1638
+ const tag = mintId2();
1639
+ const lower = socialLinkRecord({ accountId: `abc-${tag}` });
1640
+ const upper = socialLinkRecord({
1641
+ accountId: `ABC-${tag}`,
1642
+ userId: mintId2()
1643
+ });
1644
+ const unicode = socialLinkRecord({
1645
+ accountId: `ünï-日本-\uD83D\uDE00-${tag}`,
1646
+ email: "ada@exämple.test"
1647
+ });
1648
+ const otherProvider = socialLinkRecord({
1649
+ provider: "Google",
1650
+ accountId: lower.accountId,
1651
+ userId: mintId2()
1652
+ });
1653
+ for (const record of [lower, upper, unicode, otherProvider]) {
1654
+ equal(await links.insertSocialLink(record), record, `insertSocialLink of "${record.provider}"/"${record.accountId}" should write a pair of its own: case is a difference`);
1655
+ }
1656
+ for (const record of [lower, upper, unicode, otherProvider]) {
1657
+ equal(await links.findSocialLink(record.provider, record.accountId), record, `findSocialLink of "${record.provider}"/"${record.accountId}" should answer it as written`);
1658
+ }
1659
+ }
1660
+ },
1661
+ {
1662
+ id: "socialLinks.listIsolation",
1663
+ group: group20,
1664
+ needs: needs10,
1665
+ name: "lists one user’s links and only theirs, and an empty list — never null — for a user with none",
1666
+ async run({ stores }) {
1667
+ const links = socialLinksOf(stores);
1668
+ const userId = mintId2();
1669
+ const own = [
1670
+ socialLinkRecord({ userId }),
1671
+ socialLinkRecord({ userId, provider: "github" })
1672
+ ];
1673
+ const stranger = socialLinkRecord();
1674
+ for (const record of [...own, stranger]) {
1675
+ await links.insertSocialLink(record);
1676
+ }
1677
+ const listed = [...await links.listUserSocialLinks(userId)].sort((a, b) => a.provider.localeCompare(b.provider));
1678
+ equal(listed, [...own].sort((a, b) => a.provider.localeCompare(b.provider)), "listUserSocialLinks should answer the user’s own links, verbatim, and no one else’s");
1679
+ equal(await links.listUserSocialLinks(mintId2()), [], "listUserSocialLinks for a user with none answers [], not null");
1680
+ }
1681
+ }
1682
+ ];
1683
+
1684
+ // src/conformance/cases/social-links/index.ts
1685
+ var socialLinkStoreCases = [
1686
+ ...socialLinkReadCases,
1687
+ ...socialLinkInsertCases,
1688
+ ...socialLinkDeletionCases
1689
+ ];
1690
+
1691
+ // src/conformance/cases/tokens/attempts.ts
1692
+ var group21 = "tokens";
1693
+ var tokenAttemptCases = [
1694
+ {
1695
+ id: "tokens.countAttempt",
1696
+ group: group21,
1697
+ name: "counts an attempt at a code, and answers the token as it is after the call",
1698
+ async run({ stores }) {
1699
+ const record = tokenRecord({
1700
+ kind: "signInCode",
1701
+ codeHash: "c".repeat(64)
1702
+ });
1703
+ await stores.tokens.insertToken(record);
1704
+ equal(await stores.tokens.countAttempt(record.tokenHash, "signInCode"), { ...record, attempts: 1 }, "countAttempt the first time should answer the token with attempts 1, codeHash as written");
1705
+ equal(await stores.tokens.countAttempt(record.tokenHash, "signInCode"), { ...record, attempts: 2 }, "countAttempt the second time should answer attempts 2");
1706
+ equal(await stores.tokens.consumeToken(record.tokenHash, "signInCode", at7("2026-02-01T00:00:00.000Z")), { ...record, attempts: 2 }, "consumeToken should answer the attempts counted, and spend the token");
1707
+ }
1708
+ },
1709
+ {
1710
+ id: "tokens.countAttemptConcurrency",
1711
+ group: group21,
1712
+ name: "gives twenty concurrent attempts twenty distinct counts — one conditional write, never a read then a write",
1713
+ async run({ stores }) {
1714
+ const record = tokenRecord({ kind: "secondFactor" });
1715
+ await stores.tokens.insertToken(record);
1716
+ const answers = await Promise.all(Array.from({ length: 20 }, () => stores.tokens.countAttempt(record.tokenHash, "secondFactor")));
1717
+ equal(answers.map((answer) => answer?.attempts).sort((a, b) => (a ?? 0) - (b ?? 0)), Array.from({ length: 20 }, (_, index) => index + 1), "countAttempt: twenty concurrent calls should answer 1 to 20, each once — two guesses reading one count is a guess for free");
1718
+ }
1719
+ },
1720
+ {
1721
+ id: "tokens.countAttemptRace",
1722
+ group: group21,
1723
+ name: "never counts an attempt once the token is spent, when attempts and a redemption race",
1724
+ async run({ stores }) {
1725
+ const record = tokenRecord({ kind: "signInCode" });
1726
+ await stores.tokens.insertToken(record);
1727
+ const now = at7("2026-02-01T00:00:00.000Z");
1728
+ const count = () => stores.tokens.countAttempt(record.tokenHash, "signInCode");
1729
+ const answers = await Promise.all([
1730
+ ...Array.from({ length: 10 }, count),
1731
+ stores.tokens.consumeToken(record.tokenHash, "signInCode", now),
1732
+ ...Array.from({ length: 10 }, count)
1733
+ ]);
1734
+ const final = await stores.tokens.consumeToken(record.tokenHash, "signInCode", now);
1735
+ if (final === null) {
1736
+ throw new Error("consumeToken after the race should answer the token");
1737
+ }
1738
+ const counted = answers.slice(0, 10).concat(answers.slice(11)).filter((answer) => answer !== null && answer.spentAt === null).map((answer) => answer?.attempts ?? 0).sort((a, b) => a - b);
1739
+ equal(counted, Array.from({ length: final.attempts }, (_, index) => index + 1), "countAttempt: the attempts answered unspent should be 1 to the final count, each once");
1740
+ equal(answers.filter((answer) => answer !== null && answer.spentAt !== null).every((answer) => answer?.attempts === final.attempts), true, "countAttempt: every answer after the spend should carry the final count — an attempt counted on a spent token is one the limit never saw");
1741
+ }
1742
+ },
1743
+ {
1744
+ id: "tokens.countAttemptSpent",
1745
+ group: group21,
1746
+ name: "does not count an attempt at a spent token, nor at a token of another kind, nor at none",
1747
+ async run({ stores }) {
1748
+ const spent = tokenRecord({
1749
+ kind: "signInCode",
1750
+ attempts: 3,
1751
+ spentAt: at7("2026-01-02T00:00:00.000Z")
1752
+ });
1753
+ const other = tokenRecord({ kind: "resetPassword" });
1754
+ await stores.tokens.insertToken(spent);
1755
+ await stores.tokens.insertToken(other);
1756
+ for (const call of ["first", "second"]) {
1757
+ equal(await stores.tokens.countAttempt(spent.tokenHash, "signInCode"), spent, `countAttempt on a spent token, the ${call} time, should answer it as it is: attempts still 3, nothing written`);
1758
+ }
1759
+ isNull(await stores.tokens.countAttempt(other.tokenHash, "signInCode"), "countAttempt for a resetPassword token counted as signInCode");
1760
+ equal(await stores.tokens.consumeToken(other.tokenHash, "resetPassword", at7("2026-02-01T00:00:00.000Z")), other, "countAttempt of the other kind should not have counted: attempts still 0");
1761
+ isNull(await stores.tokens.countAttempt("0".repeat(64), "signInCode"), "countAttempt for an unknown hash");
1762
+ }
1763
+ }
1764
+ ];
1765
+
1766
+ // src/conformance/cases/tokens/change-email.ts
1767
+ var group22 = "tokens";
1768
+ var tokenChangeEmailCases = [
1769
+ {
1770
+ id: "tokens.changeEmailKind",
1771
+ group: group22,
1772
+ name: "keeps an e-mail change apart from a verification, and keeps the address it replaces in codeHash",
1773
+ async run({ stores }) {
1774
+ const userId = mintId2();
1775
+ const address = "new@example.test";
1776
+ const change = tokenRecord({
1777
+ userId,
1778
+ address,
1779
+ kind: "changeEmail",
1780
+ codeHash: "f".repeat(64)
1781
+ });
1782
+ const verification = tokenRecord({
1783
+ userId,
1784
+ address,
1785
+ kind: "verifyEmail"
1786
+ });
1787
+ await stores.tokens.insertToken(change);
1788
+ await stores.tokens.insertToken(verification);
1789
+ const now = at7("2026-02-01T00:00:00.000Z");
1790
+ isNull(await stores.tokens.consumeToken(verification.tokenHash, "changeEmail", now), "consumeToken for a verifyEmail token redeemed as changeEmail");
1791
+ isNull(await stores.tokens.consumeToken(change.tokenHash, "verifyEmail", now), "consumeToken for a changeEmail token redeemed as verifyEmail");
1792
+ isNull(await stores.tokens.countAttempt(change.tokenHash, "verifyEmail"), "countAttempt for a changeEmail token counted as verifyEmail");
1793
+ equal(await stores.tokens.spendUserTokens(userId, "changeEmail", now), 1, "spendUserTokens of changeEmail: the change only");
1794
+ equal(await stores.tokens.consumeToken(verification.tokenHash, "verifyEmail", now), verification, "spendUserTokens of changeEmail should not touch a verification, nor anything else have counted it");
1795
+ }
1796
+ }
1797
+ ];
1798
+
1799
+ // src/conformance/cases/tokens/deletion.ts
1800
+ var group23 = "tokens";
1801
+ var tokenDeletionCases = [
1802
+ {
1803
+ id: "tokens.deleteUser",
1804
+ group: group23,
1805
+ name: "deletes every token of one user, spent or not, of either kind, and counts them",
1806
+ async run({ stores }) {
1807
+ const userId = mintId2();
1808
+ const records = [
1809
+ tokenRecord({ userId }),
1810
+ tokenRecord({ userId, kind: "verifyEmail" }),
1811
+ tokenRecord({ userId, spentAt: at7("2026-01-02T00:00:00.000Z") })
1812
+ ];
1813
+ const stranger = tokenRecord();
1814
+ for (const record of [...records, stranger]) {
1815
+ await stores.tokens.insertToken(record);
1816
+ }
1817
+ const now = at7("2026-02-01T00:00:00.000Z");
1818
+ equal(await stores.tokens.deleteUserTokens(userId), 3, "deleteUserTokens: how many it deleted");
1819
+ for (const record of records) {
1820
+ isNull(await stores.tokens.consumeToken(record.tokenHash, record.kind, now), "consumeToken after deleteUserTokens");
1821
+ }
1822
+ equal(await stores.tokens.consumeToken(stranger.tokenHash, stranger.kind, now), stranger, "deleteUserTokens should not touch another user");
1823
+ equal(await stores.tokens.deleteUserTokens(userId), 0, "deleteUserTokens for a user with none answers 0, not a failure");
1824
+ }
1825
+ },
1826
+ {
1827
+ id: "tokens.deleteExpired",
1828
+ group: group23,
1829
+ name: "deletes tokens whose expiry is at or before the instant, spent or not, and only those",
1830
+ needs: "deleteExpiredTokens",
1831
+ async run({ stores }) {
1832
+ const collect = stores.tokens.deleteExpiredTokens;
1833
+ ok(collect !== undefined, "deleteExpiredTokens should be present");
1834
+ const lapsedAt = at7("2026-01-10T00:00:00.000Z");
1835
+ const laterAt = at7("2026-01-10T00:00:00.001Z");
1836
+ const spentAt = at7("2026-01-05T00:00:00.000Z");
1837
+ const lapsed = tokenRecord({ expiresAt: lapsedAt });
1838
+ const lapsedSpent = tokenRecord({ expiresAt: lapsedAt, spentAt });
1839
+ const living = tokenRecord({ expiresAt: laterAt });
1840
+ const livingSpent = tokenRecord({ expiresAt: laterAt, spentAt });
1841
+ for (const record of [lapsed, lapsedSpent, living, livingSpent]) {
1842
+ await stores.tokens.insertToken(record);
1843
+ }
1844
+ equal(await collect?.call(stores.tokens, lapsedAt), 2, "deleteExpiredTokens: how many it deleted, spent ones included");
1845
+ for (const record of [lapsed, lapsedSpent]) {
1846
+ isNull(await stores.tokens.countAttempt(record.tokenHash, record.kind), "countAttempt after deleteExpiredTokens");
1847
+ }
1848
+ equal(await stores.tokens.countAttempt(living.tokenHash, living.kind), { ...living, attempts: 1 }, "deleteExpiredTokens should keep a token one millisecond short of lapsing");
1849
+ equal(await stores.tokens.countAttempt(livingSpent.tokenHash, livingSpent.kind), livingSpent, "deleteExpiredTokens should keep a spent token until it lapses, still spent");
1850
+ equal(await collect?.call(stores.tokens, lapsedAt), 0, "deleteExpiredTokens with nothing lapsed answers 0, not a failure");
1851
+ }
1852
+ }
1853
+ ];
1854
+
1855
+ // src/conformance/cases/tokens/inserts.ts
1856
+ var group24 = "tokens";
1857
+ var tokenInsertCases = [
1858
+ {
1859
+ id: "tokens.challenge",
1860
+ group: group24,
1861
+ name: "keeps a second-factor challenge, whose address is '' — nothing was sent for it",
1862
+ async run({ stores }) {
1863
+ const record = tokenRecord({ kind: "secondFactor", address: "" });
1864
+ await stores.tokens.insertToken(record);
1865
+ equal(await stores.tokens.countAttempt(record.tokenHash, "secondFactor"), { ...record, attempts: 1 }, "countAttempt should answer a challenge with its empty address kept — a store that refuses '' refuses every sign-in with a second factor");
1866
+ equal(await stores.tokens.consumeToken(record.tokenHash, "secondFactor", at7("2026-02-01T00:00:00.000Z")), { ...record, attempts: 1 }, "consumeToken should spend the challenge and answer it as it was");
1867
+ }
1868
+ },
1869
+ {
1870
+ id: "tokens.lapsed",
1871
+ group: group24,
1872
+ name: "spends a lapsed token all the same: expiry is compared by the core, after the call",
1873
+ async run({ stores }) {
1874
+ const record = tokenRecord({ expiresAt: at7("2020-01-01T00:00:00.000Z") });
1875
+ await stores.tokens.insertToken(record);
1876
+ const now = at7("2026-02-01T00:00:00.000Z");
1877
+ const first = await stores.tokens.consumeToken(record.tokenHash, "resetPassword", now);
1878
+ if (first !== null) {
1879
+ equal(first, record, "consumeToken on a lapsed token should answer it as it was");
1880
+ equal((await stores.tokens.consumeToken(record.tokenHash, "resetPassword", now))?.spentAt, now, "consumeToken should have spent the lapsed token, so it can never be retried");
1881
+ }
1882
+ }
1883
+ },
1884
+ {
1885
+ id: "tokens.idempotentInsert",
1886
+ group: group24,
1887
+ name: "is idempotent under retry: inserting an existing token hash writes nothing",
1888
+ async run({ stores }) {
1889
+ const record = tokenRecord();
1890
+ await stores.tokens.insertToken(record);
1891
+ await stores.tokens.insertToken({
1892
+ ...record,
1893
+ address: "other@example.test"
1894
+ });
1895
+ equal(await stores.tokens.consumeToken(record.tokenHash, "resetPassword", at7("2026-02-01T00:00:00.000Z")), record, "insertToken retried with the same hash should write nothing");
1896
+ }
1897
+ }
1898
+ ];
1899
+
1900
+ // src/conformance/cases/tokens/kinds.ts
1901
+ var group25 = "tokens";
1902
+ var KINDS = Object.keys({
1903
+ verifyEmail: true,
1904
+ resetPassword: true,
1905
+ secondFactor: true,
1906
+ signInCode: true,
1907
+ magicLink: true,
1908
+ stepUp: true,
1909
+ changeEmail: true,
1910
+ socialFlow: true,
1911
+ passkeyRegistration: true
1912
+ });
1913
+ var tokenKindCases = [
1914
+ {
1915
+ id: "tokens.everyKind",
1916
+ group: group25,
1917
+ name: "stores, counts and spends a token of every kind the port names",
1918
+ async run({ stores }) {
1919
+ const now = at7("2026-02-01T00:00:00.000Z");
1920
+ for (const kind of KINDS) {
1921
+ const record = tokenRecord({ kind, codeHash: "c".repeat(64) });
1922
+ await stores.tokens.insertToken(record);
1923
+ equal(await stores.tokens.countAttempt(record.tokenHash, kind), { ...record, attempts: 1 }, `countAttempt on a ${kind} token should answer it with one attempt`);
1924
+ equal(await stores.tokens.consumeToken(record.tokenHash, kind, now), { ...record, attempts: 1 }, `consumeToken on a ${kind} token should answer it as it was — spentAt null`);
1925
+ }
1926
+ }
1927
+ },
1928
+ {
1929
+ id: "tokens.stepUpKind",
1930
+ group: group25,
1931
+ name: "keeps a step-up apart from a sign-in code: neither is counted, spent nor answered as the other",
1932
+ async run({ stores }) {
1933
+ const userId = mintId2();
1934
+ const stepUp = tokenRecord({ userId, kind: "stepUp" });
1935
+ const signInCode = tokenRecord({ userId, kind: "signInCode" });
1936
+ await stores.tokens.insertToken(stepUp);
1937
+ await stores.tokens.insertToken(signInCode);
1938
+ const now = at7("2026-02-01T00:00:00.000Z");
1939
+ isNull(await stores.tokens.countAttempt(stepUp.tokenHash, "signInCode"), "countAttempt for a stepUp token counted as signInCode");
1940
+ isNull(await stores.tokens.consumeToken(signInCode.tokenHash, "stepUp", now), "consumeToken for a signInCode token redeemed as stepUp");
1941
+ equal(await stores.tokens.spendUserTokens(userId, "stepUp", now), 1, "spendUserTokens of stepUp: the step-up only");
1942
+ equal(await stores.tokens.consumeToken(signInCode.tokenHash, "signInCode", now), signInCode, "spendUserTokens of stepUp should not touch a sign-in code, nor anything else have counted it");
1943
+ }
1944
+ },
1945
+ {
1946
+ id: "tokens.magicLinkKind",
1947
+ group: group25,
1948
+ name: "keeps a sign-in link apart from a sign-in code: neither is counted, spent nor answered as the other",
1949
+ async run({ stores }) {
1950
+ const userId = mintId2();
1951
+ const link = tokenRecord({ userId, kind: "magicLink" });
1952
+ const code = tokenRecord({
1953
+ userId,
1954
+ kind: "signInCode",
1955
+ codeHash: "c".repeat(64)
1956
+ });
1957
+ await stores.tokens.insertToken(link);
1958
+ await stores.tokens.insertToken(code);
1959
+ const now = at7("2026-02-01T00:00:00.000Z");
1960
+ isNull(await stores.tokens.consumeToken(code.tokenHash, "magicLink", now), "consumeToken for a signInCode token redeemed as magicLink");
1961
+ isNull(await stores.tokens.countAttempt(link.tokenHash, "signInCode"), "countAttempt for a magicLink token counted as signInCode");
1962
+ equal(await stores.tokens.spendUserTokens(userId, "magicLink", now), 1, "spendUserTokens of magicLink: the link only");
1963
+ equal(await stores.tokens.consumeToken(code.tokenHash, "signInCode", now), code, "spendUserTokens of magicLink should not touch a sign-in code, nor anything else have counted it");
1964
+ }
1965
+ },
1966
+ {
1967
+ id: "tokens.amr",
1968
+ group: group25,
1969
+ name: "keeps the methods a second-factor challenge carries, and answers none when none were given",
1970
+ async run({ stores }) {
1971
+ const now = at7("2026-02-01T00:00:00.000Z");
1972
+ const carrying = tokenRecord({
1973
+ kind: "secondFactor",
1974
+ amr: ["hwk", "user"]
1975
+ });
1976
+ const plain = tokenRecord({ kind: "secondFactor" });
1977
+ await stores.tokens.insertToken(carrying);
1978
+ await stores.tokens.insertToken(plain);
1979
+ equal(await stores.tokens.consumeToken(carrying.tokenHash, "secondFactor", now), carrying, "consumeToken should answer the challenge with the methods it carried");
1980
+ equal(await stores.tokens.consumeToken(plain.tokenHash, "secondFactor", now), plain, "a challenge written without amr should read back without one");
1981
+ }
1982
+ }
1983
+ ];
1984
+
1985
+ // src/conformance/cases/tokens/redemption.ts
1986
+ var group26 = "tokens";
1987
+ var tokenRedemptionCases = [
1988
+ {
1989
+ id: "tokens.consume",
1990
+ group: group26,
1991
+ name: "answers the token as it was before the call: spentAt null means this call spent it",
1992
+ async run({ stores }) {
1993
+ const record = tokenRecord();
1994
+ await stores.tokens.insertToken(record);
1995
+ const first = at7("2026-02-01T00:00:00.000Z");
1996
+ equal(await stores.tokens.consumeToken(record.tokenHash, "resetPassword", first), record, "consumeToken the first time should answer the token as it was — spentAt null");
1997
+ equal(await stores.tokens.consumeToken(record.tokenHash, "resetPassword", at7("2026-02-02T00:00:00.000Z")), { ...record, spentAt: first }, "consumeToken the second time should answer it spent at the first call’s instant, and change nothing");
1998
+ }
1999
+ },
2000
+ {
2001
+ id: "tokens.concurrency",
2002
+ group: group26,
2003
+ name: "lets exactly one of twenty concurrent redemptions spend a token — one conditional write, never a read then a write",
2004
+ async run({ stores }) {
2005
+ const record = tokenRecord();
2006
+ await stores.tokens.insertToken(record);
2007
+ const now = at7("2026-02-01T00:00:00.000Z");
2008
+ const answers = await Promise.all(Array.from({ length: 20 }, () => stores.tokens.consumeToken(record.tokenHash, "resetPassword", now)));
2009
+ equal(answers.filter((answer) => answer !== null && answer.spentAt === null).length, 1, "consumeToken: of twenty concurrent calls, exactly one should see spentAt null — a reset token redeemed twice is an account takeover");
2010
+ }
2011
+ },
2012
+ {
2013
+ id: "tokens.kind",
2014
+ group: group26,
2015
+ name: "does not know, and does not spend, a token of the other kind",
2016
+ async run({ stores }) {
2017
+ const record = tokenRecord({ kind: "verifyEmail" });
2018
+ await stores.tokens.insertToken(record);
2019
+ isNull(await stores.tokens.consumeToken(record.tokenHash, "resetPassword", at7("2026-02-01T00:00:00.000Z")), "consumeToken for a verifyEmail token redeemed as resetPassword");
2020
+ const own = await stores.tokens.consumeToken(record.tokenHash, "verifyEmail", at7("2026-02-02T00:00:00.000Z"));
2021
+ equal(own, record, "consumeToken of the other kind should not have spent the token: redeemed as its own kind, it is still unspent");
2022
+ isNull(await stores.tokens.consumeToken("0".repeat(64), "resetPassword", at7("2026-02-01T00:00:00.000Z")), "consumeToken for an unknown hash");
2023
+ }
2024
+ },
2025
+ {
2026
+ id: "tokens.consumeBound",
2027
+ group: group26,
2028
+ name: "given a userId, answers null and does not spend a token of another user",
2029
+ async run({ stores }) {
2030
+ const record = tokenRecord({ kind: "verifyEmail" });
2031
+ await stores.tokens.insertToken(record);
2032
+ isNull(await stores.tokens.consumeToken(record.tokenHash, "verifyEmail", at7("2026-02-01T00:00:00.000Z"), mintId2()), "consumeToken bound to another user");
2033
+ isNull(await stores.tokens.consumeToken(record.tokenHash, "verifyEmail", at7("2026-02-01T00:00:00.000Z"), ""), "consumeToken bound to an empty id should match no token, not any");
2034
+ equal(await stores.tokens.consumeToken(record.tokenHash, "verifyEmail", at7("2026-02-02T00:00:00.000Z"), record.userId), record, "consumeToken bound to the token’s own user should answer it unspent: the other user’s call spent nothing");
2035
+ }
2036
+ }
2037
+ ];
2038
+
2039
+ // src/conformance/cases/tokens/social-flow.ts
2040
+ var group27 = "tokens";
2041
+ var tokenSocialFlowCases = [
2042
+ {
2043
+ id: "tokens.socialFlowKind",
2044
+ group: group27,
2045
+ name: "keeps a social flow apart from a verification, and keeps its binding hash in codeHash",
2046
+ async run({ stores }) {
2047
+ const userId = mintId2();
2048
+ const flow = tokenRecord({
2049
+ userId,
2050
+ address: "",
2051
+ kind: "socialFlow",
2052
+ codeHash: "e".repeat(64)
2053
+ });
2054
+ const verification = tokenRecord({ userId, kind: "verifyEmail" });
2055
+ await stores.tokens.insertToken(flow);
2056
+ await stores.tokens.insertToken(verification);
2057
+ const now = at7("2026-02-01T00:00:00.000Z");
2058
+ isNull(await stores.tokens.consumeToken(verification.tokenHash, "socialFlow", now), "consumeToken for a verifyEmail token redeemed as socialFlow");
2059
+ isNull(await stores.tokens.consumeToken(flow.tokenHash, "verifyEmail", now), "consumeToken for a socialFlow token redeemed as verifyEmail");
2060
+ isNull(await stores.tokens.countAttempt(flow.tokenHash, "magicLink"), "countAttempt for a socialFlow token counted as magicLink");
2061
+ equal(await stores.tokens.spendUserTokens(userId, "socialFlow", now), 1, "spendUserTokens of socialFlow: the flow only");
2062
+ equal(await stores.tokens.consumeToken(verification.tokenHash, "verifyEmail", now), verification, "spendUserTokens of socialFlow should not touch a verification");
2063
+ }
2064
+ }
2065
+ ];
2066
+
2067
+ // src/conformance/cases/tokens/spending.ts
2068
+ var group28 = "tokens";
2069
+ var tokenSpendingCases = [
2070
+ {
2071
+ id: "tokens.spendUserTokens",
2072
+ group: group28,
2073
+ name: "spends every unspent token of one user and one kind, and counts them, leaving the rest as they were",
2074
+ async run({ stores }) {
2075
+ const userId = mintId2();
2076
+ const first = tokenRecord({ userId, kind: "signInCode" });
2077
+ const second = tokenRecord({ userId, kind: "signInCode", attempts: 2 });
2078
+ const spentBefore = at7("2026-01-02T00:00:00.000Z");
2079
+ const spent = tokenRecord({
2080
+ userId,
2081
+ kind: "signInCode",
2082
+ spentAt: spentBefore
2083
+ });
2084
+ const otherKind = tokenRecord({ userId, kind: "resetPassword" });
2085
+ const otherUser = tokenRecord({ kind: "signInCode" });
2086
+ for (const record of [first, second, spent, otherKind, otherUser]) {
2087
+ await stores.tokens.insertToken(record);
2088
+ }
2089
+ const now = at7("2026-02-01T00:00:00.000Z");
2090
+ equal(await stores.tokens.spendUserTokens(userId, "signInCode", now), 2, "spendUserTokens: how many it spent — the two unspent signInCode tokens, not the one already spent");
2091
+ for (const record of [first, second]) {
2092
+ equal(await stores.tokens.consumeToken(record.tokenHash, "signInCode", now), { ...record, spentAt: now }, "spendUserTokens should have spent it at `at`, keeping its attempts");
2093
+ }
2094
+ equal(await stores.tokens.consumeToken(spent.tokenHash, "signInCode", now), spent, "spendUserTokens should keep the spentAt of a token already spent");
2095
+ equal(await stores.tokens.consumeToken(otherKind.tokenHash, "resetPassword", now), otherKind, "spendUserTokens should not touch a token of another kind");
2096
+ equal(await stores.tokens.consumeToken(otherUser.tokenHash, "signInCode", now), otherUser, "spendUserTokens should not touch another user");
2097
+ equal(await stores.tokens.spendUserTokens(userId, "signInCode", now), 0, "spendUserTokens for a user with none left unspent answers 0, not a failure");
2098
+ equal(await stores.tokens.spendUserTokens(mintId2(), "signInCode", now), 0, "spendUserTokens for a user with no token at all answers 0");
2099
+ }
2100
+ },
2101
+ {
2102
+ id: "tokens.spendUserTokensExcept",
2103
+ group: group28,
2104
+ name: "spares the token named by except, and spends the rest",
2105
+ async run({ stores }) {
2106
+ const userId = mintId2();
2107
+ const kept = tokenRecord({ userId, kind: "signInCode" });
2108
+ const others = [
2109
+ tokenRecord({ userId, kind: "signInCode" }),
2110
+ tokenRecord({ userId, kind: "signInCode" })
2111
+ ];
2112
+ for (const record of [kept, ...others]) {
2113
+ await stores.tokens.insertToken(record);
2114
+ }
2115
+ const now = at7("2026-02-01T00:00:00.000Z");
2116
+ equal(await stores.tokens.spendUserTokens(userId, "signInCode", now, kept.tokenHash), 2, "spendUserTokens with except: how many it spent — every token but the one named");
2117
+ equal(await stores.tokens.consumeToken(kept.tokenHash, "signInCode", now), kept, "spendUserTokens should not spend the token named by except");
2118
+ for (const record of others) {
2119
+ equal((await stores.tokens.consumeToken(record.tokenHash, "signInCode", now))?.spentAt, now, "spendUserTokens with except should spend every other token");
2120
+ }
2121
+ }
2122
+ },
2123
+ {
2124
+ id: "tokens.spendUserTokensRace",
2125
+ group: group28,
2126
+ name: "spends a token once, when spending a user's tokens races a redemption",
2127
+ async run({ stores }) {
2128
+ const now = at7("2026-02-01T00:00:00.000Z");
2129
+ for (let round = 0;round < 10; round += 1) {
2130
+ const record = tokenRecord({ kind: "signInCode" });
2131
+ await stores.tokens.insertToken(record);
2132
+ const [counted, redeemed] = await Promise.all([
2133
+ stores.tokens.spendUserTokens(record.userId, "signInCode", now),
2134
+ stores.tokens.consumeToken(record.tokenHash, "signInCode", now)
2135
+ ]);
2136
+ equal(counted + (redeemed?.spentAt === null ? 1 : 0), 1, "spendUserTokens and consumeToken: exactly one of the two should have spent the token");
2137
+ }
2138
+ }
2139
+ }
2140
+ ];
2141
+
2142
+ // src/conformance/cases/tokens/index.ts
2143
+ var tokenStoreCases = [
2144
+ ...tokenRedemptionCases,
2145
+ ...tokenAttemptCases,
2146
+ ...tokenSpendingCases,
2147
+ ...tokenInsertCases,
2148
+ ...tokenKindCases,
2149
+ ...tokenChangeEmailCases,
2150
+ ...tokenSocialFlowCases,
2151
+ ...tokenDeletionCases
2152
+ ];
2153
+
2154
+ // src/conformance/cases/users/batch.ts
2155
+ var group29 = "users";
2156
+ var byId = (a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
2157
+ var userBatchCases = [
2158
+ {
2159
+ id: "users.findUsers",
2160
+ group: group29,
2161
+ name: "findUsers answers each stored user once, byte for byte and whatever its type, and leaves out an id nobody holds",
2162
+ needs: "findUsers",
2163
+ async run({ stores }) {
2164
+ const findUsers = stores.users.findUsers;
2165
+ ok(findUsers !== undefined, "findUsers should be present");
2166
+ const patient = userRecord({ type: "patient" });
2167
+ const staff = userRecord({ type: "staff" });
2168
+ const other = userRecord();
2169
+ for (const record of [patient, staff, other]) {
2170
+ await stores.users.insertUser(record);
2171
+ }
2172
+ const answer = await findUsers?.call(stores.users, [
2173
+ staff.id,
2174
+ mintId2(),
2175
+ patient.id
2176
+ ]);
2177
+ ok(Array.isArray(answer), "findUsers should answer a list — an absence is a shorter list, never null");
2178
+ equal([...answer ?? []].sort(byId), [patient, staff].sort(byId), "findUsers should answer the two stored users exactly as written, and only them");
2179
+ }
2180
+ },
2181
+ {
2182
+ id: "users.findUsersNone",
2183
+ group: group29,
2184
+ name: "findUsers answers an empty list, not null, when no id is held",
2185
+ needs: "findUsers",
2186
+ async run({ stores }) {
2187
+ await stores.users.insertUser(userRecord());
2188
+ equal(await stores.users.findUsers?.call(stores.users, [mintId2(), mintId2()]), [], "findUsers for ids nobody holds should answer []");
2189
+ }
2190
+ }
2191
+ ];
2192
+
2193
+ // src/conformance/cases/users/deletion.ts
2194
+ var group30 = "users";
2195
+ var userDeletionCases = [
2196
+ {
2197
+ id: "users.delete",
2198
+ group: group30,
2199
+ name: "deletes a user and frees their logins, answers false for nobody, and touches no other user",
2200
+ async run({ stores }) {
2201
+ const record = userRecord();
2202
+ const other = userRecord();
2203
+ await stores.users.insertUser(record);
2204
+ await stores.users.insertUser(other);
2205
+ const [login] = record.logins;
2206
+ equal(await stores.users.deleteUser(record.id), true, "deleteUser for a stored user should answer true");
2207
+ isNull(await stores.users.findUser(record.id), "findUser after deleteUser");
2208
+ isNull(await stores.users.findUserByLogin(record.type, login ?? ""), "findUserByLogin for a deleted user’s login");
2209
+ equal(await stores.users.deleteUser(record.id), false, "deleteUser replayed should answer false, not fail: a deletion interrupted half-way is replayed");
2210
+ equal(await stores.users.findUser(other.id), other, "deleteUser should not touch another user");
2211
+ const successor = userRecord({ logins: [login ?? ""] });
2212
+ equal(await stores.users.insertUser(successor), successor, "insertUser onto a deleted user’s login should succeed");
2213
+ }
2214
+ }
2215
+ ];
2216
+
2217
+ // src/conformance/cases/users/inserts.ts
2218
+ var group31 = "users";
2219
+ var userInsertCases = [
2220
+ {
2221
+ id: "users.idempotentInsert",
2222
+ group: group31,
2223
+ name: "is idempotent under retry: inserting an existing id answers the stored record and writes nothing",
2224
+ async run({ stores }) {
2225
+ const record = userRecord();
2226
+ await stores.users.insertUser(record);
2227
+ const retried = await stores.users.insertUser({
2228
+ ...record,
2229
+ fields: { email: "changed@example.test" }
2230
+ });
2231
+ equal(retried, record, "insertUser retried with the same id should answer the stored record");
2232
+ equal(await stores.users.findUser(record.id), record, "insertUser retried should write nothing");
2233
+ }
2234
+ },
2235
+ {
2236
+ id: "users.uniqueness",
2237
+ group: group31,
2238
+ name: "lets exactly one of twenty concurrent inserts hold a login: uniqueness is a constraint, not a read",
2239
+ async run({ stores }) {
2240
+ const records = Array.from({ length: 20 }, () => userRecord({ logins: ["contested@example.test"] }));
2241
+ const outcomes = await Promise.allSettled(records.map((record) => stores.users.insertUser(record)));
2242
+ const accepted = outcomes.filter((o) => o.status === "fulfilled");
2243
+ const refused = outcomes.flatMap((o) => o.status === "rejected" ? [o.reason] : []);
2244
+ equal(accepted.length, 1, "insertUser: of twenty concurrent inserts of one login, exactly one should be accepted — a read followed by a write lets several through");
2245
+ for (const error of refused) {
2246
+ isOurs(error, StoreConflict2, "StoreConflict", "insertUser should refuse a taken login with StoreConflict");
2247
+ equal(error.code, "LOGIN_TAKEN", "insertUser: the conflict code");
2248
+ equal(error.login, "contested@example.test", "insertUser: the conflict should name the login");
2249
+ ok(!error.message.includes("contested@example.test"), `insertUser: the conflict's message should not quote the login — a message never carries a value; got ${JSON.stringify(error.message)}`);
2250
+ }
2251
+ let stored = 0;
2252
+ for (const record of records) {
2253
+ if (await stores.users.findUser(record.id) !== null)
2254
+ stored += 1;
2255
+ }
2256
+ equal(stored, 1, "insertUser: a refused insert should write nothing");
2257
+ }
2258
+ }
2259
+ ];
2260
+
2261
+ // src/conformance/cases/users/listing.ts
2262
+ var group32 = "users";
2263
+ var userListingCases = [
2264
+ {
2265
+ id: "users.pagination",
2266
+ group: group32,
2267
+ name: "pages 25 users of one type by 10 in ascending id order, with no gap, no repeat and no other type, and ends on a null cursor",
2268
+ async run({ stores }) {
2269
+ const records = Array.from({ length: 25 }, () => userRecord());
2270
+ const others = Array.from({ length: 5 }, () => userRecord({ type: "staff" }));
2271
+ for (const [index, record] of [...records].reverse().entries()) {
2272
+ await stores.users.insertUser(record);
2273
+ const other = others[index];
2274
+ if (other !== undefined)
2275
+ await stores.users.insertUser(other);
2276
+ }
2277
+ const expected = records.map((record) => record.id).sort();
2278
+ const seen = [];
2279
+ const sizes = [];
2280
+ let after = null;
2281
+ for (let page = 0;page < 10; page += 1) {
2282
+ const answer = await stores.users.listUsers({
2283
+ type: "user",
2284
+ after,
2285
+ limit: 10
2286
+ });
2287
+ seen.push(...answer.items.map((item) => item.id));
2288
+ sizes.push(answer.items.length);
2289
+ after = answer.nextCursor;
2290
+ if (after === null)
2291
+ break;
2292
+ }
2293
+ equal(sizes, [10, 10, 5], "listUsers: page sizes for 25 users by 10");
2294
+ equal(seen, expected, "listUsers: every id of the type once, in ascending order");
2295
+ const between = await stores.users.listUsers({
2296
+ type: "user",
2297
+ after: "00000000-0000-7000-8000-000000000000",
2298
+ limit: 3
2299
+ });
2300
+ ok(between.items[0]?.id === expected[0], "listUsers: a cursor naming no stored user should start after it, not fail");
2301
+ }
2302
+ },
2303
+ {
2304
+ id: "users.loginPrefix",
2305
+ group: group32,
2306
+ name: "lists and counts only the users of the type holding a login that starts with the prefix, byte for byte, with no gap or repeat across pages",
2307
+ async run({ stores }) {
2308
+ const stamp = mintId2();
2309
+ const mine = `pfx-${stamp}`;
2310
+ const named = (login, overrides = {}) => userRecord({ logins: [login], ...overrides });
2311
+ const matching = [
2312
+ named(`${mine}-a@example.test`),
2313
+ named(`${mine}-b@example.test`),
2314
+ named(`${mine}-c@example.test`)
2315
+ ];
2316
+ const recordsOf = [
2317
+ ...matching,
2318
+ named(`${mine}-staff@example.test`, { type: "staff" }),
2319
+ named(`other-${stamp}@example.test`),
2320
+ named(`x-${mine}@example.test`),
2321
+ named(`${mine.toUpperCase()}-upper@example.test`)
2322
+ ];
2323
+ const twoLogins = named(`zz-${stamp}@example.test`);
2324
+ const withOther = {
2325
+ ...twoLogins,
2326
+ logins: [`zz-${stamp}@example.test`, `${mine}-second@example.test`]
2327
+ };
2328
+ for (const record of [...recordsOf, withOther]) {
2329
+ await stores.users.insertUser(record);
2330
+ }
2331
+ const expected = [...matching, withOther].map((r) => r.id).sort();
2332
+ const seen = [];
2333
+ let after = null;
2334
+ for (let page = 0;page < 10; page += 1) {
2335
+ const answer = await stores.users.listUsers({
2336
+ type: "user",
2337
+ loginPrefix: mine,
2338
+ after,
2339
+ limit: 2
2340
+ });
2341
+ seen.push(...answer.items.map((item) => item.id));
2342
+ after = answer.nextCursor;
2343
+ if (after === null)
2344
+ break;
2345
+ }
2346
+ equal(seen, expected, "listUsers: a loginPrefix should list the users of the type with a login starting with it, in id order across pages");
2347
+ equal(await stores.users.countUsers({ type: "user", loginPrefix: mine }), expected.length, "countUsers: a loginPrefix should count what listUsers lists");
2348
+ equal(await stores.users.countUsers({
2349
+ type: "staff",
2350
+ loginPrefix: mine
2351
+ }), 1, "countUsers: the type is part of the filter");
2352
+ equal(await stores.users.countUsers({
2353
+ type: "user",
2354
+ loginPrefix: `${mine}-zzz`
2355
+ }), 0, "countUsers: no match should answer 0");
2356
+ ok(await stores.users.countUsers({ type: "user" }) >= recordsOf.length - 1, "countUsers: without a prefix, every user of the type is counted");
2357
+ }
2358
+ },
2359
+ {
2360
+ id: "users.loginPrefix.literal",
2361
+ group: group32,
2362
+ name: 'treats the prefix as text: ".", "+", "%", "_", "\\" and "*" match themselves and nothing else',
2363
+ async run({ stores }) {
2364
+ const stamp = mintId2();
2365
+ const base = `lit-${stamp}`;
2366
+ const holders = {
2367
+ dot: `${base}.a@example.test`,
2368
+ plus: `${base}+a@example.test`,
2369
+ percent: `${base}%a@example.test`,
2370
+ underscore: `${base}_a@example.test`,
2371
+ backslash: `${base}\\a@example.test`,
2372
+ star: `${base}*a@example.test`,
2373
+ bang: `${base}!a@example.test`,
2374
+ paren: `${base}(a@example.test`,
2375
+ anyChar: `${base}Xa@example.test`,
2376
+ dashed: `${base}-a@example.test`
2377
+ };
2378
+ const byName = new Map;
2379
+ for (const [name, login] of Object.entries(holders)) {
2380
+ const record = userRecord({ logins: [login] });
2381
+ byName.set(name, record.id);
2382
+ await stores.users.insertUser(record);
2383
+ }
2384
+ for (const [name, symbol] of [
2385
+ ["dot", "."],
2386
+ ["plus", "+"],
2387
+ ["percent", "%"],
2388
+ ["underscore", "_"],
2389
+ ["backslash", "\\"],
2390
+ ["star", "*"],
2391
+ ["bang", "!"],
2392
+ ["paren", "("]
2393
+ ]) {
2394
+ const answer = await stores.users.listUsers({
2395
+ type: "user",
2396
+ loginPrefix: `${base}${symbol}`,
2397
+ after: null,
2398
+ limit: 10
2399
+ });
2400
+ equal(answer.items.map((item) => item.id), [byName.get(name)], `listUsers: the prefix "${symbol}" should match only its own login`);
2401
+ equal(await stores.users.countUsers({
2402
+ type: "user",
2403
+ loginPrefix: `${base}${symbol}`
2404
+ }), 1, `countUsers: the prefix "${symbol}" should count only its own login`);
2405
+ }
2406
+ }
2407
+ },
2408
+ {
2409
+ id: "users.namePrefix",
2410
+ group: group32,
2411
+ name: "lists and counts only the users of the type whose name key starts with the prefix, byte for byte, combined with a loginPrefix, with no gap or repeat across pages",
2412
+ async run({ stores }) {
2413
+ const stamp = mintId2();
2414
+ const mine = `nm-${stamp}`;
2415
+ const named = (nameKey, overrides = {}) => userRecord({
2416
+ ...nameKey === undefined ? {} : { nameKey },
2417
+ ...overrides
2418
+ });
2419
+ const matching = [
2420
+ named(`${mine} a`),
2421
+ named(`${mine} b`),
2422
+ named(`${mine} c`)
2423
+ ];
2424
+ const withLogin = named(`${mine} d`, {
2425
+ logins: [`pair-${stamp}@example.test`]
2426
+ });
2427
+ for (const record of [
2428
+ ...matching,
2429
+ withLogin,
2430
+ named(`${mine} staff`, { type: "staff" }),
2431
+ named(`x ${mine}`),
2432
+ named(undefined),
2433
+ named(mine.toUpperCase())
2434
+ ]) {
2435
+ await stores.users.insertUser(record);
2436
+ }
2437
+ const expected = [...matching, withLogin].map((r) => r.id).sort();
2438
+ const seen = [];
2439
+ let after = null;
2440
+ for (let page = 0;page < 10; page += 1) {
2441
+ const answer = await stores.users.listUsers({
2442
+ type: "user",
2443
+ namePrefix: mine,
2444
+ after,
2445
+ limit: 2
2446
+ });
2447
+ seen.push(...answer.items.map((item) => item.id));
2448
+ after = answer.nextCursor;
2449
+ if (after === null)
2450
+ break;
2451
+ }
2452
+ equal(seen, expected, "listUsers: a namePrefix should list the users of the type whose name key starts with it, in id order across pages");
2453
+ equal(await stores.users.countUsers({ type: "user", namePrefix: mine }), expected.length, "countUsers: a namePrefix should count what listUsers lists");
2454
+ equal(await stores.users.countUsers({ type: "staff", namePrefix: mine }), 1, "countUsers: the type is part of the filter");
2455
+ equal(await stores.users.countUsers({
2456
+ type: "user",
2457
+ namePrefix: `${mine} zzz`
2458
+ }), 0, "countUsers: no match should answer 0");
2459
+ const both = await stores.users.listUsers({
2460
+ type: "user",
2461
+ namePrefix: mine,
2462
+ loginPrefix: `pair-${stamp}`,
2463
+ after: null,
2464
+ limit: 10
2465
+ });
2466
+ equal(both.items.map((item) => item.id), [withLogin.id], "listUsers: a namePrefix and a loginPrefix should both hold");
2467
+ equal(await stores.users.countUsers({
2468
+ type: "user",
2469
+ namePrefix: mine,
2470
+ loginPrefix: `pair-${stamp}`
2471
+ }), 1, "countUsers: a namePrefix and a loginPrefix should both hold");
2472
+ }
2473
+ },
2474
+ {
2475
+ id: "users.namePrefix.literal",
2476
+ group: group32,
2477
+ name: 'treats the name prefix as text: ".", "+", "%", "_", "\\" and "*" match themselves and nothing else',
2478
+ async run({ stores }) {
2479
+ const base = `ln-${mintId2()}`;
2480
+ const holders = [
2481
+ [".", `${base}.a`],
2482
+ ["+", `${base}+a`],
2483
+ ["%", `${base}%a`],
2484
+ ["_", `${base}_a`],
2485
+ ["\\", `${base}\\a`],
2486
+ ["*", `${base}*a`],
2487
+ ["X", `${base}Xa`],
2488
+ ["-", `${base}-a`]
2489
+ ];
2490
+ const ids = new Map;
2491
+ for (const [symbol, nameKey] of holders) {
2492
+ const record = userRecord({ nameKey });
2493
+ ids.set(symbol, record.id);
2494
+ await stores.users.insertUser(record);
2495
+ }
2496
+ for (const symbol of [".", "+", "%", "_", "\\", "*"]) {
2497
+ const answer = await stores.users.listUsers({
2498
+ type: "user",
2499
+ namePrefix: `${base}${symbol}`,
2500
+ after: null,
2501
+ limit: 10
2502
+ });
2503
+ equal(answer.items.map((item) => item.id), [ids.get(symbol)], `listUsers: the name prefix "${symbol}" should match only its own name`);
2504
+ equal(await stores.users.countUsers({
2505
+ type: "user",
2506
+ namePrefix: `${base}${symbol}`
2507
+ }), 1, `countUsers: the name prefix "${symbol}" should count only its own name`);
2508
+ }
2509
+ }
2510
+ }
2511
+ ];
2512
+
2513
+ // src/conformance/cases/users/avatar.ts
2514
+ var avatar = {
2515
+ id: "avatars/ada.3f9c1d",
2516
+ updatedAt: at7("2026-01-05T10:20:30.456Z")
2517
+ };
2518
+ var writtenAt = (version) => new Date(Date.UTC(2026, 1, 2 + version));
2519
+ var avatarSlotCase = {
2520
+ id: "users.avatarSlot",
2521
+ group: "users",
2522
+ name: "round-trips an avatar, keeps it when a patch does not name it, replaces it whole when one does, and removes it when the patch names null",
2523
+ async run({ stores }) {
2524
+ const record = userRecord({ avatar });
2525
+ equal(await stores.users.insertUser(record), record, "insertUser should answer an avatar as written: its id verbatim and its updatedAt to the millisecond");
2526
+ equal((await stores.users.findUser(record.id))?.avatar, avatar, "findUser should answer the avatar insertUser wrote");
2527
+ const kept = await stores.users.updateUser(record.id, { updatedAt: writtenAt(0) }, 0);
2528
+ equal(kept.avatar, avatar, "updateUser not naming avatar should keep it");
2529
+ const replacement = {
2530
+ id: "avatars/ada.b7e204",
2531
+ updatedAt: at7("2026-02-03T04:05:06.789Z")
2532
+ };
2533
+ const replaced = await stores.users.updateUser(record.id, { updatedAt: writtenAt(1), avatar: replacement }, 1);
2534
+ equal(replaced.avatar, replacement, "updateUser naming avatar should replace it whole");
2535
+ equal((await stores.users.findUser(record.id))?.avatar, replacement, "findUser after updateUser naming avatar should answer it as written");
2536
+ isNull((await stores.users.updateUser(record.id, { updatedAt: writtenAt(2), avatar: null }, 2)).avatar, "updateUser with avatar: null should remove the avatar");
2537
+ isNull((await stores.users.findUser(record.id))?.avatar, "findUser after updateUser with avatar: null should answer no avatar");
2538
+ const absent = userRecord();
2539
+ isNull((await stores.users.insertUser(absent)).avatar, "insertUser should answer a user with no avatar as avatar: null");
2540
+ }
2541
+ };
2542
+
2543
+ // src/conformance/cases/users/second-factor.ts
2544
+ var secondFactor = {
2545
+ method: "totp",
2546
+ secret: "v1.2026-09.aXY.Y2lwaGVydGV4dA",
2547
+ confirmedAt: null,
2548
+ lastStep: null,
2549
+ recoveryCodes: []
2550
+ };
2551
+ var recoveryCodes = [
2552
+ "v1.2026-09.zHc0dGhpcmQ",
2553
+ "v1.2026-09.Yg2ZpcnN0",
2554
+ "v1.2026-09.mc2Vjb25k"
2555
+ ];
2556
+ var secondFactorSlotCase = {
2557
+ id: "users.secondFactorSlot",
2558
+ group: "users",
2559
+ name: "round-trips a second factor and its recovery codes in order, keeps it when a patch does not name it, replaces it whole when one does, and removes it, codes included, when the patch names null",
2560
+ async run({ stores }) {
2561
+ const record = userRecord({ secondFactor });
2562
+ equal(await stores.users.insertUser(record), record, "insertUser should answer a pending second factor as written: confirmedAt and lastStep null, recoveryCodes []");
2563
+ await noCodesIsNotNoFactor(stores, record.id);
2564
+ const confirmed = {
2565
+ ...secondFactor,
2566
+ confirmedAt: at7("2026-02-01T00:00:00.000Z"),
2567
+ lastStep: 59000000,
2568
+ recoveryCodes
2569
+ };
2570
+ await patchFactor(stores, record.id, confirmed, 0, "secondFactor");
2571
+ equal((await stores.users.updateUser(record.id, { updatedAt: writtenAt2(1) }, 1)).secondFactor, confirmed, "updateUser not naming secondFactor should keep it, recovery codes included");
2572
+ await replacesCodesWhole(stores, record.id, confirmed);
2573
+ await nullClearsCodes(stores, record.id);
2574
+ }
2575
+ };
2576
+ var writtenAt2 = (version) => new Date(Date.UTC(2026, 1, 2 + version));
2577
+ async function noCodesIsNotNoFactor(stores, id) {
2578
+ const user = await stores.users.findUser(id);
2579
+ ok(user !== null, "findUser should answer the user insertUser wrote");
2580
+ const found = user?.secondFactor;
2581
+ ok(found !== null && found !== undefined, "findUser should answer a second factor with recoveryCodes [] as a factor, not as null — no codes is not no factor");
2582
+ equal(found?.recoveryCodes, [], "findUser should answer recoveryCodes [] as [] — never null, never undefined");
2583
+ }
2584
+ async function patchFactor(stores, id, factor, version, what) {
2585
+ const written = await stores.users.updateUser(id, {
2586
+ updatedAt: writtenAt2(version),
2587
+ secondFactor: factor
2588
+ }, version);
2589
+ equal(written.secondFactor, factor, `updateUser naming ${what} should replace the second factor whole, its recovery codes in the order written`);
2590
+ equal((await stores.users.findUser(id))?.secondFactor, factor, `findUser after updateUser naming ${what} should answer it as written, its recovery codes in the order written`);
2591
+ }
2592
+ async function replacesCodesWhole(stores, id, confirmed) {
2593
+ const kept = recoveryCodes.filter((_, index) => index !== 1);
2594
+ await patchFactor(stores, id, { ...confirmed, recoveryCodes: kept }, 2, "secondFactor with one recovery code fewer");
2595
+ await patchFactor(stores, id, { ...confirmed, recoveryCodes: [] }, 3, "secondFactor with recoveryCodes []");
2596
+ }
2597
+ async function nullClearsCodes(stores, id) {
2598
+ await patchFactor(stores, id, { ...secondFactor, recoveryCodes }, 4, "secondFactor with recovery codes");
2599
+ isNull((await stores.users.updateUser(id, { updatedAt: writtenAt2(5), secondFactor: null }, 5)).secondFactor, "updateUser with secondFactor: null should remove the second factor");
2600
+ isNull((await stores.users.findUser(id))?.secondFactor, "findUser after updateUser with secondFactor: null should answer no second factor");
2601
+ await patchFactor(stores, id, secondFactor, 6, "a new secondFactor after null, with recoveryCodes [] — the removed codes must not come back");
2602
+ }
2603
+
2604
+ // src/conformance/cases/users/patches.ts
2605
+ var group33 = "users";
2606
+ var userPatchCases = [
2607
+ {
2608
+ id: "users.omission",
2609
+ group: group33,
2610
+ name: "omission — the Kratos PUT trap: an update leaves every field it does not name exactly as it was",
2611
+ async run({ stores }) {
2612
+ const record = userRecord({
2613
+ fields: { email: "kept@example.test", plan: "pro" },
2614
+ secondFactor: {
2615
+ ...secondFactor,
2616
+ confirmedAt: at7("2026-01-03T00:00:00.000Z"),
2617
+ lastStep: 59000000,
2618
+ recoveryCodes: recoveryCodes.slice(0, 2)
2619
+ },
2620
+ emailVerifiedAt: at7("2026-01-02T00:00:00.000Z")
2621
+ });
2622
+ await stores.users.insertUser(record);
2623
+ const written = await stores.users.updateUser(record.id, { updatedAt: at7("2026-02-01T00:00:00.000Z"), schemaVersion: "2" }, 0);
2624
+ equal(written, {
2625
+ ...record,
2626
+ schemaVersion: "2",
2627
+ version: 1,
2628
+ updatedAt: at7("2026-02-01T00:00:00.000Z")
2629
+ }, "updateUser naming only schemaVersion should leave active, fields, logins, password, secondFactor and emailVerifiedAt untouched");
2630
+ }
2631
+ },
2632
+ {
2633
+ id: "users.nameKeySlot",
2634
+ group: group33,
2635
+ name: "keeps a name key the patch does not name, replaces one it names, and removes one it names null",
2636
+ async run({ stores }) {
2637
+ const record = userRecord({ nameKey: "ada lovelace" });
2638
+ await stores.users.insertUser(record);
2639
+ const kept = await stores.users.updateUser(record.id, { updatedAt: at7("2026-02-01T00:00:00.000Z"), schemaVersion: "2" }, 0);
2640
+ equal(kept.nameKey, "ada lovelace", "updateUser not naming nameKey should keep it");
2641
+ const replaced = await stores.users.updateUser(record.id, { updatedAt: at7("2026-02-02T00:00:00.000Z"), nameKey: "grace hopper" }, 1);
2642
+ equal(replaced.nameKey, "grace hopper", "updateUser naming nameKey should replace it");
2643
+ equal(await stores.users.countUsers({ type: "user", namePrefix: "grace" }), 1, "countUsers: the replaced name key should be the one searched");
2644
+ const removed = await stores.users.updateUser(record.id, { updatedAt: at7("2026-02-03T00:00:00.000Z"), nameKey: null }, 2);
2645
+ equal("nameKey" in removed, false, "updateUser naming nameKey null should leave the record with no nameKey");
2646
+ equal(await stores.users.countUsers({ type: "user", namePrefix: "grace" }), 0, "countUsers: a removed name key should match no prefix");
2647
+ }
2648
+ },
2649
+ {
2650
+ id: "users.passwordSlot",
2651
+ group: group33,
2652
+ name: "keeps a password the patch does not name, and removes one the patch names null",
2653
+ async run({ stores }) {
2654
+ const record = userRecord();
2655
+ await stores.users.insertUser(record);
2656
+ const kept = await stores.users.updateUser(record.id, { updatedAt: at7("2026-02-01T00:00:00.000Z") }, 0);
2657
+ equal(kept.password, record.password, "updateUser not naming password should keep it");
2658
+ const removed = await stores.users.updateUser(record.id, { updatedAt: at7("2026-02-02T00:00:00.000Z"), password: null }, 1);
2659
+ isNull(removed.password, "updateUser with password: null should remove the password");
2660
+ }
2661
+ },
2662
+ secondFactorSlotCase,
2663
+ avatarSlotCase,
2664
+ {
2665
+ id: "users.loginsMove",
2666
+ group: group33,
2667
+ name: "moves logins on update: the old one is free, the new one found, one held elsewhere refused",
2668
+ async run({ stores }) {
2669
+ const record = userRecord();
2670
+ const other = userRecord();
2671
+ await stores.users.insertUser(record);
2672
+ await stores.users.insertUser(other);
2673
+ const [old] = record.logins;
2674
+ const moved = "moved@example.test";
2675
+ await stores.users.updateUser(record.id, { updatedAt: at7("2026-02-01T00:00:00.000Z"), logins: [moved] }, 0);
2676
+ isNull(await stores.users.findUserByLogin("user", old ?? ""), "findUserByLogin for a login the update replaced");
2677
+ equal((await stores.users.findUserByLogin("user", moved))?.id, record.id, "findUserByLogin for the login the update wrote");
2678
+ const error = await rejects(stores.users.updateUser(other.id, { updatedAt: at7("2026-02-02T00:00:00.000Z"), logins: [moved] }, 0), "updateUser onto a login another user holds should reject");
2679
+ isOurs(error, StoreConflict2, "StoreConflict", "updateUser onto a held login should reject with StoreConflict");
2680
+ equal(error.code, "LOGIN_TAKEN", "updateUser: the conflict code");
2681
+ equal(await stores.users.findUser(other.id), other, "updateUser refused for a login should have written nothing");
2682
+ }
2683
+ }
2684
+ ];
2685
+
2686
+ // src/conformance/cases/users/reads.ts
2687
+ var group34 = "users";
2688
+ var userReadCases = [
2689
+ {
2690
+ id: "users.roundTrip",
2691
+ group: group34,
2692
+ name: 'round-trips a record byte for byte: nested fields, a 1 that stays a number, a "1" that stays a string',
2693
+ async run({ stores }) {
2694
+ const record = userRecord({
2695
+ fields: {
2696
+ email: "Ada@Example.test",
2697
+ name: { first: "Ada", last: "Lovelace" },
2698
+ count: 1,
2699
+ code: "1",
2700
+ zero: 0,
2701
+ flags: [true, false, null],
2702
+ note: " spaced ",
2703
+ unicode: "Bob — ÿ",
2704
+ nested: { deep: { deeper: [1, { two: 2 }] } },
2705
+ tags: ["a", "b"]
2706
+ },
2707
+ emailVerifiedAt: at7("2026-01-02T00:00:00.000Z")
2708
+ });
2709
+ equal(await stores.users.insertUser(record), record, "insertUser should answer the record as stored");
2710
+ equal(await stores.users.findUser(record.id), record, "findUser should answer the record exactly as it was written");
2711
+ }
2712
+ },
2713
+ {
2714
+ id: "users.edgeCharacters",
2715
+ group: group34,
2716
+ name: "round-trips every character the core lets through: control characters, U+FFFF and a surrogate pair",
2717
+ async run({ stores }) {
2718
+ const edge = "a\x01\x1F￿ \uD83D\uDE00 z";
2719
+ const record = userRecord({
2720
+ logins: [edge],
2721
+ fields: { email: "ada@example.test", [edge]: [edge, { [edge]: edge }] }
2722
+ });
2723
+ await stores.users.insertUser(record);
2724
+ equal(await stores.users.findUser(record.id), record, "findUser should answer every edge character exactly as written");
2725
+ equal((await stores.users.findUserByLogin("user", edge))?.id, record.id, "findUserByLogin should find a login made of edge characters");
2726
+ }
2727
+ },
2728
+ {
2729
+ id: "users.absence",
2730
+ group: group34,
2731
+ name: "answers null for an absence, never undefined, and an empty page for an empty store",
2732
+ async run({ stores }) {
2733
+ isNull(await stores.users.findUser(mintId2()), "findUser for an unknown id");
2734
+ isNull(await stores.users.findUserByLogin("user", "nobody@example.test"), "findUserByLogin for an unknown login");
2735
+ equal(await stores.users.listUsers({ type: "user", after: null, limit: 10 }), { items: [], nextCursor: null }, "listUsers on an empty store should answer an empty page");
2736
+ }
2737
+ },
2738
+ {
2739
+ id: "users.loginBytes",
2740
+ group: group34,
2741
+ name: "compares logins as bytes, within one type: no case folding, no trimming, no collation",
2742
+ async run({ stores }) {
2743
+ const upper = userRecord({ logins: ["Ada@Example.test"] });
2744
+ const lower = userRecord({ logins: ["ada@example.test"] });
2745
+ const staff = userRecord({ type: "staff", logins: ["ada@example.test"] });
2746
+ for (const record of [upper, lower, staff]) {
2747
+ await stores.users.insertUser(record);
2748
+ }
2749
+ equal((await stores.users.findUserByLogin("user", "Ada@Example.test"))?.id, upper.id, "findUserByLogin should find the login with its exact bytes");
2750
+ equal((await stores.users.findUserByLogin("user", "ada@example.test"))?.id, lower.id, 'findUserByLogin should tell "Ada@…" from "ada@…": normalisation is the core’s');
2751
+ equal((await stores.users.findUserByLogin("staff", "ada@example.test"))?.id, staff.id, "uniqueness is of (type, login): the same login under another type is another user");
2752
+ }
2753
+ }
2754
+ ];
2755
+
2756
+ // src/conformance/cases/users/versions.ts
2757
+ var group35 = "users";
2758
+ var userVersionCases = [
2759
+ {
2760
+ id: "users.versionIncrements",
2761
+ group: group35,
2762
+ name: "applies an update at the expected version, and answers the record written with its version one higher",
2763
+ async run({ stores }) {
2764
+ const record = userRecord();
2765
+ await stores.users.insertUser(record);
2766
+ const written = await stores.users.updateUser(record.id, { updatedAt: at7("2026-02-01T00:00:00.000Z"), active: false }, 0);
2767
+ const expected = {
2768
+ ...record,
2769
+ active: false,
2770
+ version: 1,
2771
+ updatedAt: at7("2026-02-01T00:00:00.000Z")
2772
+ };
2773
+ equal(written, expected, "updateUser should answer the record as written");
2774
+ equal(await stores.users.findUser(record.id), expected, "findUser after updateUser");
2775
+ }
2776
+ },
2777
+ {
2778
+ id: "users.versionConflict",
2779
+ group: group35,
2780
+ name: "refuses a stale version with both versions, and leaves the record identical byte for byte",
2781
+ async run({ stores }) {
2782
+ const record = userRecord();
2783
+ await stores.users.insertUser(record);
2784
+ await stores.users.updateUser(record.id, { updatedAt: at7("2026-02-01T00:00:00.000Z"), active: false }, 0);
2785
+ const before = await stores.users.findUser(record.id);
2786
+ const error = await rejects(stores.users.updateUser(record.id, {
2787
+ updatedAt: at7("2026-03-01T00:00:00.000Z"),
2788
+ active: true,
2789
+ fields: { email: "overwritten@example.test" }
2790
+ }, 0), "updateUser at a stale version should reject");
2791
+ isOurs(error, StoreConflict2, "StoreConflict", "updateUser at a stale version should reject with StoreConflict");
2792
+ equal(error.code, "VERSION_CONFLICT", "updateUser: the conflict code");
2793
+ equal(error.expectedVersion, 0, "updateUser: expectedVersion");
2794
+ equal(error.actualVersion, 1, "updateUser: actualVersion");
2795
+ equal(await stores.users.findUser(record.id), before, "updateUser refused for its version should have written nothing");
2796
+ }
2797
+ },
2798
+ {
2799
+ id: "users.unknownUpdate",
2800
+ group: group35,
2801
+ name: "refuses an update to an unknown id with NotFoundError, told apart from a version conflict",
2802
+ async run({ stores }) {
2803
+ const error = await rejects(stores.users.updateUser(mintId2(), { updatedAt: at7("2026-02-01T00:00:00.000Z") }, 0), "updateUser on an unknown id should reject");
2804
+ isOurs(error, NotFoundError2, "NotFoundError", "updateUser on an unknown id should reject with NotFoundError, not a version conflict");
2805
+ }
2806
+ }
2807
+ ];
2808
+
2809
+ // src/conformance/cases/users/index.ts
2810
+ var userStoreCases = [
2811
+ ...userReadCases,
2812
+ ...userBatchCases,
2813
+ ...userInsertCases,
2814
+ ...userVersionCases,
2815
+ ...userPatchCases,
2816
+ ...userListingCases,
2817
+ ...userDeletionCases
2818
+ ];
2819
+
2820
+ // src/conformance/describe.ts
2821
+ var allCases = [
2822
+ ...userStoreCases,
2823
+ ...sessionStoreCases,
2824
+ ...tokenStoreCases,
2825
+ ...socialLinkStoreCases,
2826
+ ...passkeyStoreCases,
2827
+ ...outageCases
2828
+ ];
2829
+ var SKIP_REASONS = {
2830
+ faults: "faults not provided: the outage invariant is not proven for this adapter",
2831
+ deleteExpiredSessions: "stores.sessions does not implement the optional deleteExpiredSessions",
2832
+ listUserSessions: "stores.sessions does not implement the optional listUserSessions",
2833
+ deleteExpiredTokens: "stores.tokens does not implement the optional deleteExpiredTokens",
2834
+ findUsers: "stores.users does not implement the optional findUsers: findMany reads with findUser instead",
2835
+ socialLinks: "stores.socialLinks is not provided: the slot is optional, needed only for social sign-in",
2836
+ passkeys: "stores.passkeys is not provided: the slot is optional, needed only for passkeys",
2837
+ apiKeysBound: "the API key store does not implement the optional listBoundApiKeys and revokeBoundApiKeys: keys cannot be scoped or bound",
2838
+ apiKeysUserBound: "the API key store does not implement the optional listUserBoundApiKeys: apiKeys.list filters on a bound object by reading the user’s keys",
2839
+ apiKeysExpiryNotice: "the API key store does not implement the optional listExpiringApiKeys and markApiKeyExpiryNotified"
2840
+ };
2841
+ async function runCase(conformanceCase, harness) {
2842
+ const opened = await harness.open();
2843
+ try {
2844
+ const missing = needsOf(conformanceCase).find((need) => !provides(opened, need));
2845
+ if (missing !== undefined)
2846
+ return { skipped: SKIP_REASONS[missing] };
2847
+ await conformanceCase.run({
2848
+ stores: opened.stores,
2849
+ faults: opened.faults ?? null
2850
+ });
2851
+ return { passed: true };
2852
+ } finally {
2853
+ await opened.close?.();
2854
+ }
2855
+ }
2856
+ function needsOf(conformanceCase) {
2857
+ const { needs } = conformanceCase;
2858
+ return needs === undefined ? [] : typeof needs === "string" ? [needs] : needs;
2859
+ }
2860
+ function provides(opened, need) {
2861
+ switch (need) {
2862
+ case "faults":
2863
+ return opened.faults !== undefined;
2864
+ case "listUserSessions":
2865
+ return opened.stores.sessions.listUserSessions !== undefined;
2866
+ case "deleteExpiredSessions":
2867
+ return opened.stores.sessions.deleteExpiredSessions !== undefined;
2868
+ case "deleteExpiredTokens":
2869
+ return opened.stores.tokens.deleteExpiredTokens !== undefined;
2870
+ case "findUsers":
2871
+ return opened.stores.users.findUsers !== undefined;
2872
+ case "socialLinks":
2873
+ return opened.stores.socialLinks !== undefined;
2874
+ case "passkeys":
2875
+ return opened.stores.passkeys !== undefined;
2876
+ }
2877
+ }
2878
+ function describeJanusStores(options) {
2879
+ describeSuite({
2880
+ title: `${options.name} — @softistx/janus conformance`,
2881
+ cases: allCases,
2882
+ run: (conformanceCase) => runCase(conformanceCase, options.harness),
2883
+ runner: options.runner ?? fromGlobals("describeJanusStores"),
2884
+ skip: options.skip ?? {},
2885
+ faults: options.faults
2886
+ });
2887
+ }
2888
+ function needsList(described) {
2889
+ const { needs } = described;
2890
+ return needs === undefined ? [] : typeof needs === "string" ? [needs] : needs;
2891
+ }
2892
+ function describeSuite(options) {
2893
+ const { runner, skip, cases } = options;
2894
+ const groups = [...new Set(cases.map((c) => c.group))];
2895
+ const title = options.faults === false ? `${options.title} (WITHOUT faults: ${SKIP_REASONS.faults})` : options.title;
2896
+ runner.describe(title, () => {
2897
+ for (const group of groups) {
2898
+ runner.describe(group, () => {
2899
+ for (const conformanceCase of cases.filter((c) => c.group === group)) {
2900
+ const reason = skip[conformanceCase.id];
2901
+ if (reason !== undefined) {
2902
+ runner.it.skip(`${conformanceCase.name} — skipped: ${reason}`, async () => {});
2903
+ continue;
2904
+ }
2905
+ if (needsList(conformanceCase).includes("faults") && options.faults === false) {
2906
+ runner.it.skip(`${conformanceCase.name} — skipped: ${SKIP_REASONS.faults}`, async () => {});
2907
+ continue;
2908
+ }
2909
+ runner.it(conformanceCase.name, async () => {
2910
+ const outcome = await options.run(conformanceCase);
2911
+ if ("skipped" in outcome) {
2912
+ process.emitWarning(`${conformanceCase.id} skipped: ${outcome.skipped}`, { code: "JANUS_CONFORMANCE_SKIPPED" });
2913
+ }
2914
+ });
2915
+ }
2916
+ });
2917
+ }
2918
+ });
2919
+ }
2920
+ function fromGlobals(where) {
2921
+ const globals = globalThis;
2922
+ if (typeof globals.describe !== "function" || typeof globals.it !== "function") {
2923
+ throw new TypeError(`${where}: no test runner on globalThis — pass runner: { describe, it } (under bun test: import them from 'bun:test')`);
2924
+ }
2925
+ return { describe: globals.describe, it: globals.it };
2926
+ }
2927
+
2928
+ // src/conformance/api-keys/describe.ts
2929
+ var allApiKeyCases = [
2930
+ ...apiKeyStoreCases,
2931
+ ...apiKeyOutageCases
2932
+ ];
2933
+ async function runApiKeyCase(apiKeyCase, harness) {
2934
+ const opened = await harness.open();
2935
+ try {
2936
+ const missing = missingNeed(apiKeyCase, opened);
2937
+ if (missing !== null)
2938
+ return { skipped: SKIP_REASONS[missing] };
2939
+ await apiKeyCase.run({
2940
+ store: opened.store,
2941
+ faults: opened.faults ?? null
2942
+ });
2943
+ return { passed: true };
2944
+ } finally {
2945
+ await opened.close?.();
2946
+ }
2947
+ }
2948
+ function missingNeed(apiKeyCase, opened) {
2949
+ const needs = apiKeyCase.needs === undefined ? [] : typeof apiKeyCase.needs === "string" ? [apiKeyCase.needs] : apiKeyCase.needs;
2950
+ const { store } = opened;
2951
+ for (const need of needs) {
2952
+ if (need === "faults" && opened.faults === undefined)
2953
+ return "faults";
2954
+ if (need === "bound" && store.listBoundApiKeys === undefined) {
2955
+ return "apiKeysBound";
2956
+ }
2957
+ if (need === "userBound" && store.listUserBoundApiKeys === undefined) {
2958
+ return "apiKeysUserBound";
2959
+ }
2960
+ if (need === "expiryNotice" && store.listExpiringApiKeys === undefined) {
2961
+ return "apiKeysExpiryNotice";
2962
+ }
2963
+ }
2964
+ return null;
2965
+ }
2966
+ function describeApiKeyStores(options) {
2967
+ describeSuite({
2968
+ title: `${options.name} — @softistx/janus API key conformance`,
2969
+ cases: allApiKeyCases,
2970
+ run: (apiKeyCase) => runApiKeyCase(apiKeyCase, options.harness),
2971
+ runner: options.runner ?? fromGlobals("describeApiKeyStores"),
2972
+ skip: options.skip ?? {},
2973
+ faults: options.faults
2974
+ });
2975
+ }
2976
+ // src/conformance/api-keys/reference.ts
2977
+ function referenceApiKeyHarness() {
2978
+ return {
2979
+ async open() {
2980
+ const failing = new Set;
2981
+ const inner = createMemoryApiKeys2();
2982
+ const store = Object.fromEntries(Object.entries(inner).map(([method, fn]) => [
2983
+ method,
2984
+ (...args) => failing.has(method) ? Promise.reject(new StoreFailure2(`apiKeys.${method}: the store could not answer`, { slot: "apiKeys", operation: method })) : fn.apply(inner, args)
2985
+ ]));
2986
+ return {
2987
+ store,
2988
+ faults: {
2989
+ async fail(method) {
2990
+ failing.add(method);
2991
+ }
2992
+ }
2993
+ };
2994
+ }
2995
+ };
2996
+ }
2997
+ // src/conformance/invitations/fixtures.ts
2998
+ function invitation(overrides = {}) {
2999
+ const id = overrides.id ?? mintId2();
3000
+ return {
3001
+ id,
3002
+ scope: "org-1",
3003
+ email: `${id}@example.com`,
3004
+ name: "Ada",
3005
+ role: "member",
3006
+ locale: null,
3007
+ ref: null,
3008
+ type: null,
3009
+ codeHash: id.replaceAll("-", "").padEnd(64, "a"),
3010
+ invitedBy: mintId2(),
3011
+ status: "pending",
3012
+ version: 0,
3013
+ createdAt: new Date("2026-01-01T00:00:00.000Z"),
3014
+ updatedAt: new Date("2026-01-01T00:00:00.000Z"),
3015
+ expiresAt: new Date("2027-01-01T00:00:00.000Z"),
3016
+ acceptedBy: null,
3017
+ acceptedAt: null,
3018
+ revokedAt: null,
3019
+ revokedBy: null,
3020
+ resentBy: null,
3021
+ ...overrides
3022
+ };
3023
+ }
3024
+
3025
+ // src/conformance/invitations/cases/actors.ts
3026
+ var group36 = "invitations";
3027
+ var t = new Date("2026-03-01T00:00:00.000Z");
3028
+ var invitationActorCases = [
3029
+ {
3030
+ id: "invitations.update.actors",
3031
+ group: group36,
3032
+ name: "updateInvitation stores revokedBy and resentBy, a record without them reads as absent or null, and null erases a resender",
3033
+ async run({ store }) {
3034
+ const { revokedBy: _r, resentBy: _s, ...bare } = invitation();
3035
+ await store.insertInvitation(bare);
3036
+ const found = await store.findInvitation(bare.id);
3037
+ equal(found?.revokedBy ?? null, null, "findInvitation: a record without revokedBy reads as absent or null");
3038
+ equal(found?.resentBy ?? null, null, "findInvitation: a record without resentBy reads as absent or null");
3039
+ const resender = mintId2();
3040
+ const revoker = mintId2();
3041
+ const resent = await store.updateInvitation(bare.id, 0, {
3042
+ updatedAt: t,
3043
+ resentBy: resender
3044
+ });
3045
+ equal(resent?.resentBy, resender, "updateInvitation: resentBy is stored and answered");
3046
+ equal(resent?.revokedBy ?? null, null, "updateInvitation: revokedBy stays null until it is written");
3047
+ const revoked = await store.updateInvitation(bare.id, 1, {
3048
+ updatedAt: t,
3049
+ status: "revoked",
3050
+ revokedAt: t,
3051
+ revokedBy: revoker,
3052
+ resentBy: null
3053
+ });
3054
+ equal(revoked?.revokedBy, revoker, "updateInvitation: revokedBy");
3055
+ equal(revoked?.resentBy, null, "updateInvitation: null erases resentBy");
3056
+ const read = await store.findInvitation(bare.id);
3057
+ equal(read?.revokedBy, revoker, "findInvitation reads revokedBy");
3058
+ equal(read?.resentBy, null, "findInvitation reads resentBy as null");
3059
+ }
3060
+ }
3061
+ ];
3062
+
3063
+ // src/conformance/invitations/cases/find-pending.ts
3064
+ var group37 = "invitations";
3065
+ var lapsedAt = new Date("2026-05-01T00:00:00.000Z");
3066
+ var t2 = new Date("2026-03-01T00:00:00.000Z");
3067
+ var invitationFindPendingCases = [
3068
+ {
3069
+ id: "invitations.find-pending",
3070
+ group: group37,
3071
+ name: "findPendingInvitation answers the pending invitation of an address in a scope, lapsed or not, and null for none",
3072
+ async run({ store }) {
3073
+ if (store.findPendingInvitation === undefined)
3074
+ return;
3075
+ const scope = `org-${mintId2()}`;
3076
+ const standing = invitation({ scope });
3077
+ const lapsed = invitation({ scope, expiresAt: lapsedAt });
3078
+ const revoked = invitation({ scope });
3079
+ const accepted = invitation({ scope });
3080
+ for (const record of [standing, lapsed, revoked, accepted]) {
3081
+ await store.insertInvitation(record);
3082
+ }
3083
+ const otherScope = `other-${mintId2()}`;
3084
+ const elsewhere = invitation({
3085
+ scope: otherScope,
3086
+ email: standing.email
3087
+ });
3088
+ await store.insertInvitation(elsewhere);
3089
+ await store.updateInvitation(revoked.id, 0, {
3090
+ updatedAt: t2,
3091
+ status: "revoked",
3092
+ revokedAt: t2
3093
+ });
3094
+ await store.updateInvitation(accepted.id, 0, {
3095
+ updatedAt: t2,
3096
+ status: "accepted",
3097
+ acceptedAt: t2,
3098
+ acceptedBy: mintId2()
3099
+ });
3100
+ equal(await store.findPendingInvitation(scope, standing.email), standing, "findPendingInvitation: the pending invitation, verbatim");
3101
+ equal(await store.findPendingInvitation(scope, lapsed.email), lapsed, "findPendingInvitation: a lapsed pending invitation is still pending");
3102
+ isNull(await store.findPendingInvitation(scope, revoked.email), "findPendingInvitation: a revoked invitation is not pending");
3103
+ isNull(await store.findPendingInvitation(scope, accepted.email), "findPendingInvitation: an accepted invitation is not pending");
3104
+ equal(await store.findPendingInvitation(otherScope, standing.email), elsewhere, "findPendingInvitation: another scope answers its own record");
3105
+ isNull(await store.findPendingInvitation(scope, standing.email.toUpperCase()), "findPendingInvitation: the address is compared exactly, as stored");
3106
+ isNull(await store.findPendingInvitation(`none-${mintId2()}`, standing.email), "findPendingInvitation: another scope is null");
3107
+ isNull(await store.findPendingInvitation(scope, `nobody-${mintId2()}@example.com`), "findPendingInvitation: another address is null");
3108
+ }
3109
+ }
3110
+ ];
3111
+
3112
+ // src/conformance/invitations/cases/imported.ts
3113
+ var group38 = "invitations";
3114
+ var invitationImportedCases = [
3115
+ {
3116
+ id: "invitations.insert.imported",
3117
+ group: group38,
3118
+ name: 'insertInvitation stores an imported accepted record and a revoked one with a codeHash that is not hex ("import:…") verbatim, and findInvitationByCodeHash finds each by it',
3119
+ async run({ store }) {
3120
+ const accepted = invitation({
3121
+ status: "accepted",
3122
+ codeHash: `import:${"a1".repeat(32)}`,
3123
+ acceptedBy: mintId2(),
3124
+ acceptedAt: new Date("2026-02-01T00:00:00.000Z"),
3125
+ expiresAt: new Date("2026-01-08T00:00:00.000Z")
3126
+ });
3127
+ const revoked = invitation({
3128
+ status: "revoked",
3129
+ codeHash: `import:${"b2".repeat(32)}`,
3130
+ revokedAt: new Date("2026-02-02T00:00:00.000Z"),
3131
+ revokedBy: mintId2(),
3132
+ expiresAt: new Date("2026-01-08T00:00:00.000Z")
3133
+ });
3134
+ for (const record of [accepted, revoked]) {
3135
+ equal(await store.insertInvitation(record), true, "insertInvitation: an imported record answers true");
3136
+ }
3137
+ for (const record of [accepted, revoked]) {
3138
+ equal(await store.findInvitation(record.id), record, `findInvitation: the ${record.status} record as written`);
3139
+ equal(await store.findInvitationByCodeHash(record.codeHash), record, `findInvitationByCodeHash: the ${record.status} record, found by its "import:" hash`);
3140
+ }
3141
+ }
3142
+ }
3143
+ ];
3144
+
3145
+ // src/conformance/invitations/cases/insert.ts
3146
+ var group39 = "invitations";
3147
+ var at8 = (iso) => new Date(iso);
3148
+ var invitationInsertCases = [
3149
+ {
3150
+ id: "invitations.insert",
3151
+ group: group39,
3152
+ name: "insertInvitation stores an invitation that findInvitation and findInvitationByCodeHash answer verbatim, and null for an unknown id or hash",
3153
+ async run({ store }) {
3154
+ const record = invitation({
3155
+ locale: "fr",
3156
+ name: "Zoë “Z” Ünal",
3157
+ acceptedBy: mintId2(),
3158
+ acceptedAt: at8("2026-02-01T00:00:00.000Z"),
3159
+ revokedAt: at8("2026-02-02T00:00:00.000Z"),
3160
+ status: "revoked"
3161
+ });
3162
+ equal(await store.insertInvitation(record), true, "insertInvitation: a new invitation answers true");
3163
+ equal(await store.findInvitation(record.id), record, "findInvitation: the invitation as written");
3164
+ equal(await store.findInvitationByCodeHash(record.codeHash), record, "findInvitationByCodeHash: the invitation as written, whatever its status");
3165
+ isNull(await store.findInvitation(mintId2()), "findInvitation: an unknown id is null, not undefined");
3166
+ isNull(await store.findInvitationByCodeHash("f".repeat(64)), "findInvitationByCodeHash: an unknown hash is null, not undefined");
3167
+ }
3168
+ },
3169
+ {
3170
+ id: "invitations.insert.system",
3171
+ group: group39,
3172
+ name: "insertInvitation stores an invitation issued by the system (invitedBy: null) and reads it back as null, not as a missing field or a placeholder",
3173
+ async run({ store }) {
3174
+ const record = invitation({ invitedBy: null });
3175
+ equal(await store.insertInvitation(record), true, "insertInvitation: a system invitation answers true");
3176
+ equal((await store.findInvitation(record.id))?.invitedBy, null, "findInvitation: invitedBy is null");
3177
+ equal((await store.findInvitationByCodeHash(record.codeHash))?.invitedBy, null, "findInvitationByCodeHash: invitedBy is null");
3178
+ const page = await store.listScopeInvitations(record.scope, {
3179
+ status: null,
3180
+ first: 10,
3181
+ after: null
3182
+ });
3183
+ equal(page.items.find((item) => item.id === record.id)?.invitedBy, null, "listScopeInvitations: invitedBy is null");
3184
+ }
3185
+ },
3186
+ {
3187
+ id: "invitations.insert.type",
3188
+ group: group39,
3189
+ name: "insertInvitation keeps the user type as stored: a name stays that name and null stays null",
3190
+ async run({ store }) {
3191
+ const named = invitation({ type: "guardian" });
3192
+ const legacy = invitation({ type: null });
3193
+ await store.insertInvitation(named);
3194
+ await store.insertInvitation(legacy);
3195
+ equal((await store.findInvitation(named.id))?.type, "guardian", "findInvitation: the type as written");
3196
+ equal((await store.findInvitationByCodeHash(named.codeHash))?.type, "guardian", "findInvitationByCodeHash: the type as written");
3197
+ equal((await store.findInvitation(legacy.id))?.type, null, "findInvitation: a null type is returned as null, not dropped or filled in");
3198
+ }
3199
+ },
3200
+ {
3201
+ id: "invitations.insert.idempotent",
3202
+ group: group39,
3203
+ name: "insertInvitation is idempotent by id: a retry writes nothing, answers true and does not throw",
3204
+ async run({ store }) {
3205
+ const record = invitation();
3206
+ await store.insertInvitation(record);
3207
+ await store.updateInvitation(record.id, 0, {
3208
+ updatedAt: at8("2026-03-01T00:00:00.000Z"),
3209
+ status: "revoked",
3210
+ revokedAt: at8("2026-03-01T00:00:00.000Z")
3211
+ });
3212
+ equal(await store.insertInvitation({ ...record, name: "replayed" }), true, "insertInvitation: a replay of a stored id answers true");
3213
+ equal((await store.findInvitation(record.id))?.name, record.name, "insertInvitation replayed should leave the stored invitation untouched");
3214
+ equal((await store.findInvitation(record.id))?.status, "revoked", "insertInvitation replayed should not bring a revoked invitation back");
3215
+ }
3216
+ },
3217
+ {
3218
+ id: "invitations.insert.one-pending",
3219
+ group: group39,
3220
+ name: "insertInvitation answers false when the scope and address already hold a pending invitation, and writes nothing",
3221
+ async run({ store }) {
3222
+ const first = invitation({ email: "ada@example.com" });
3223
+ const second = invitation({ email: "ada@example.com" });
3224
+ await store.insertInvitation(first);
3225
+ equal(await store.insertInvitation(second), false, "insertInvitation: a second pending invitation for the same scope and address is false");
3226
+ isNull(await store.findInvitation(second.id), "insertInvitation: a refused invitation is not stored");
3227
+ equal(await store.insertInvitation(invitation({ email: "ada@example.com", scope: "org-2" })), true, "insertInvitation: the same address in another scope is allowed");
3228
+ equal(await store.insertInvitation(invitation({ email: "Ada@example.com" })), true, "insertInvitation: addresses are compared as stored bytes, the core normalises");
3229
+ }
3230
+ },
3231
+ {
3232
+ id: "invitations.insert.one-pending.concurrent",
3233
+ group: group39,
3234
+ name: "of 20 concurrent insertInvitation calls for one scope and address exactly one answers true and the others false, leaving one pending invitation",
3235
+ async run({ store }) {
3236
+ const records = Array.from({ length: 20 }, () => invitation({ email: "race@example.com" }));
3237
+ const results = await Promise.all(records.map((record) => store.insertInvitation(record)));
3238
+ equal(results.filter((won) => won).length, 1, "insertInvitation: exactly one concurrent insert for a held scope and address should win");
3239
+ equal(await store.countPendingInvitations(records[0]?.scope ?? "", new Date(0)), 1, "countPendingInvitations: one pending invitation should remain");
3240
+ }
3241
+ },
3242
+ {
3243
+ id: "invitations.insert.after-final",
3244
+ group: group39,
3245
+ name: "a revoked or accepted invitation frees its scope and address for a new pending one",
3246
+ async run({ store }) {
3247
+ const old = invitation({ email: "ada@example.com" });
3248
+ await store.insertInvitation(old);
3249
+ await store.updateInvitation(old.id, 0, {
3250
+ updatedAt: at8("2026-03-01T00:00:00.000Z"),
3251
+ status: "revoked",
3252
+ revokedAt: at8("2026-03-01T00:00:00.000Z")
3253
+ });
3254
+ const fresh = invitation({ email: "ada@example.com" });
3255
+ equal(await store.insertInvitation(fresh), true, "insertInvitation: a revoked invitation no longer holds the address");
3256
+ equal((await store.findInvitation(old.id))?.status, "revoked", "insertInvitation: the revoked one is kept");
3257
+ }
3258
+ }
3259
+ ];
3260
+
3261
+ // src/conformance/invitations/cases/list.ts
3262
+ var group40 = "invitations";
3263
+ var invitationListCases = [
3264
+ {
3265
+ id: "invitations.list",
3266
+ group: group40,
3267
+ name: "listScopeInvitations pages one scope’s invitations in id order with a cursor, and leaves other scopes out",
3268
+ async run({ store }) {
3269
+ const scope = `org-${mintId2()}`;
3270
+ const [a, b, c] = [mintId2(), mintId2(), mintId2()].sort();
3271
+ await store.insertInvitation(invitation({ id: c, scope }));
3272
+ await store.insertInvitation(invitation({ id: a, scope }));
3273
+ await store.insertInvitation(invitation({ id: b, scope }));
3274
+ await store.insertInvitation(invitation({ scope: "elsewhere" }));
3275
+ const first = await store.listScopeInvitations(scope, {
3276
+ status: null,
3277
+ first: 2,
3278
+ after: null
3279
+ });
3280
+ equal(first.items.map((item) => item.id), [a, b], "listScopeInvitations: the first page");
3281
+ equal(first.nextCursor, b, "listScopeInvitations: nextCursor is the last id");
3282
+ const second = await store.listScopeInvitations(scope, {
3283
+ status: null,
3284
+ first: 2,
3285
+ after: first.nextCursor
3286
+ });
3287
+ equal(second.items.map((item) => item.id), [c], "listScopeInvitations: the last page");
3288
+ equal(second.nextCursor, null, "listScopeInvitations: the last page ends with null");
3289
+ equal((await store.listScopeInvitations(scope, {
3290
+ status: null,
3291
+ first: 3,
3292
+ after: null
3293
+ })).nextCursor, null, "listScopeInvitations: a page that ends exactly has no cursor");
3294
+ equal(await store.listScopeInvitations(scope, {
3295
+ status: null,
3296
+ first: 5,
3297
+ after: b
3298
+ }), { items: [await store.findInvitation(c)], nextCursor: null }, "listScopeInvitations: a cursor past a stored id pages past it");
3299
+ equal(await store.listScopeInvitations(`none-${mintId2()}`, {
3300
+ status: null,
3301
+ first: 5,
3302
+ after: null
3303
+ }), { items: [], nextCursor: null }, "listScopeInvitations: a scope without invitations has an empty page, never null");
3304
+ }
3305
+ },
3306
+ {
3307
+ id: "invitations.list-filters",
3308
+ group: group40,
3309
+ name: "listScopeInvitations filters by role and ref, pages newest first with order desc, and stores the ref verbatim",
3310
+ async run({ store }) {
3311
+ const scope = `org-${mintId2()}`;
3312
+ const [a, b, c, d] = [mintId2(), mintId2(), mintId2(), mintId2()].sort();
3313
+ await store.insertInvitation(invitation({ id: c, scope, ref: "p1", role: "member" }));
3314
+ await store.insertInvitation(invitation({ id: a, scope, ref: "p1", role: "admin" }));
3315
+ await store.insertInvitation(invitation({ id: d, scope, ref: "p2", role: "member" }));
3316
+ await store.insertInvitation(invitation({ id: b, scope }));
3317
+ await store.insertInvitation(invitation({ scope: "elsewhere", ref: "p1" }));
3318
+ equal((await store.findInvitation(a))?.ref, "p1", "findInvitation: the ref is stored as given");
3319
+ equal((await store.findInvitation(b))?.ref ?? null, null, "findInvitation: no ref reads as null");
3320
+ const ids = async (query) => (await store.listScopeInvitations(scope, {
3321
+ status: null,
3322
+ first: 10,
3323
+ after: null,
3324
+ ...query
3325
+ })).items.map((item) => item.id);
3326
+ equal(await ids({ ref: "p1" }), [a, c], "listScopeInvitations: by ref");
3327
+ equal(await ids({ role: "member" }), [b, c, d], "listScopeInvitations: by role");
3328
+ equal(await ids({ ref: "p1", role: "member" }), [c], "listScopeInvitations: by ref and role");
3329
+ equal(await ids({ ref: "none" }), [], "listScopeInvitations: an unknown ref is an empty page");
3330
+ equal(await ids({ order: "desc" }), [d, c, b, a], "listScopeInvitations: newest first");
3331
+ const first = await store.listScopeInvitations(scope, {
3332
+ status: null,
3333
+ first: 3,
3334
+ after: null,
3335
+ order: "desc"
3336
+ });
3337
+ equal(first.nextCursor, b, "listScopeInvitations: desc nextCursor is the last id of the page");
3338
+ equal(await store.listScopeInvitations(scope, {
3339
+ status: null,
3340
+ first: 3,
3341
+ after: first.nextCursor,
3342
+ order: "desc"
3343
+ }), { items: [await store.findInvitation(a)], nextCursor: null }, "listScopeInvitations: desc pages past the cursor to smaller ids");
3344
+ }
3345
+ },
3346
+ {
3347
+ id: "invitations.count",
3348
+ group: group40,
3349
+ name: "countScopeInvitations counts one scope by status, role and ref, whatever the page",
3350
+ async run({ store }) {
3351
+ if (store.countScopeInvitations === undefined)
3352
+ return;
3353
+ const scope = `org-${mintId2()}`;
3354
+ await store.insertInvitation(invitation({ scope, ref: "p1", role: "admin" }));
3355
+ await store.insertInvitation(invitation({ scope, ref: "p1", status: "revoked" }));
3356
+ await store.insertInvitation(invitation({ scope }));
3357
+ await store.insertInvitation(invitation({ scope: "elsewhere", ref: "p1" }));
3358
+ const count = (filter) => store.countScopeInvitations?.(scope, {
3359
+ status: null,
3360
+ role: null,
3361
+ ref: null,
3362
+ ...filter
3363
+ });
3364
+ equal(await count({}), 3, "countScopeInvitations: all");
3365
+ equal(await count({ status: "pending" }), 2, "countScopeInvitations: by status");
3366
+ equal(await count({ ref: "p1" }), 2, "countScopeInvitations: by ref");
3367
+ equal(await count({ ref: "p1", role: "admin" }), 1, "countScopeInvitations: by ref and role");
3368
+ equal(await count({ ref: "p1", status: "revoked" }), 1, "countScopeInvitations: by ref and status");
3369
+ equal(await store.countScopeInvitations(`none-${mintId2()}`, {
3370
+ status: null,
3371
+ role: null,
3372
+ ref: null
3373
+ }), 0, "countScopeInvitations: an empty scope is 0");
3374
+ }
3375
+ }
3376
+ ];
3377
+
3378
+ // src/conformance/invitations/cases/list-lapsed.ts
3379
+ var group41 = "invitations";
3380
+ var now3 = new Date("2026-06-01T00:00:00.000Z");
3381
+ var before2 = new Date("2026-05-01T00:00:00.000Z");
3382
+ var after = new Date("2026-07-01T00:00:00.000Z");
3383
+ async function seed2(store) {
3384
+ const scope = `org-${mintId2()}`;
3385
+ const ids = {
3386
+ live: mintId2(),
3387
+ lapsed: mintId2(),
3388
+ boundary: mintId2(),
3389
+ accepted: mintId2(),
3390
+ revoked: mintId2()
3391
+ };
3392
+ await store.insertInvitation(invitation({ id: ids.live, scope, expiresAt: after }));
3393
+ await store.insertInvitation(invitation({ id: ids.lapsed, scope, expiresAt: before2 }));
3394
+ await store.insertInvitation(invitation({ id: ids.boundary, scope, expiresAt: now3 }));
3395
+ for (const [id, status] of [
3396
+ [ids.accepted, "accepted"],
3397
+ [ids.revoked, "revoked"]
3398
+ ]) {
3399
+ await store.insertInvitation(invitation({ id, scope, status, expiresAt: before2 }));
3400
+ }
3401
+ return { scope, ids };
3402
+ }
3403
+ var invitationListLapsedCases = [
3404
+ {
3405
+ id: "invitations.list.lapsed",
3406
+ group: group41,
3407
+ name: "listScopeInvitations leaves lapsed pending invitations out or keeps only them, the boundary lapsed, accepted and revoked never",
3408
+ async run({ store }) {
3409
+ const { scope, ids } = await seed2(store);
3410
+ const ofMode = async (mode, status = null) => (await store.listScopeInvitations(scope, {
3411
+ status,
3412
+ first: 10,
3413
+ after: null,
3414
+ lapsed: mode === null ? null : { mode, now: now3 }
3415
+ })).items.map((item) => item.id).sort();
3416
+ const sorted = (...list) => list.sort();
3417
+ equal(await ofMode("only"), sorted(ids.lapsed, ids.boundary), "listScopeInvitations: only keeps the lapsed, expiresAt === now included");
3418
+ equal(await ofMode("exclude"), sorted(ids.live, ids.accepted, ids.revoked), "listScopeInvitations: exclude keeps every other record, of any status");
3419
+ equal((await ofMode(null)).length, 5, "listScopeInvitations: null is no filter");
3420
+ equal(await ofMode("only", "accepted"), [], "listScopeInvitations: an accepted record is never lapsed");
3421
+ equal(await ofMode("exclude", "accepted"), [ids.accepted], "listScopeInvitations: exclude with a status intersects");
3422
+ equal(await ofMode("only", "pending"), sorted(ids.lapsed, ids.boundary), "listScopeInvitations: only with pending");
3423
+ const page = await store.listScopeInvitations(scope, {
3424
+ status: null,
3425
+ first: 1,
3426
+ after: null,
3427
+ lapsed: { mode: "exclude", now: now3 }
3428
+ });
3429
+ equal(page.items.length === 1 && page.nextCursor !== null, true, "listScopeInvitations: a page of the filter has a cursor while more match");
3430
+ }
3431
+ },
3432
+ {
3433
+ id: "invitations.count.lapsed",
3434
+ group: group41,
3435
+ name: "countScopeInvitations follows the lapsed filter, alone and with a status",
3436
+ async run({ store }) {
3437
+ if (store.countScopeInvitations === undefined)
3438
+ return;
3439
+ const { scope } = await seed2(store);
3440
+ const count = (mode, status = null) => store.countScopeInvitations?.(scope, {
3441
+ status,
3442
+ role: null,
3443
+ ref: null,
3444
+ lapsed: mode === null ? null : { mode, now: now3 }
3445
+ });
3446
+ equal(await count(null), 5, "countScopeInvitations: no filter");
3447
+ equal(await count("only"), 2, "countScopeInvitations: only");
3448
+ equal(await count("exclude"), 3, "countScopeInvitations: exclude");
3449
+ equal(await count("only", "accepted"), 0, "countScopeInvitations: accepted is never lapsed");
3450
+ equal(await count("exclude", "pending"), 1, "countScopeInvitations: exclude with pending");
3451
+ equal(await count("only", "pending"), 2, "countScopeInvitations: only with pending");
3452
+ }
3453
+ }
3454
+ ];
3455
+
3456
+ // src/conformance/invitations/cases/list-status.ts
3457
+ var group42 = "invitations";
3458
+ var at9 = (iso) => new Date(iso);
3459
+ var t3 = at9("2026-03-01T00:00:00.000Z");
3460
+ var invitationListStatusCases = [
3461
+ {
3462
+ id: "invitations.list.status",
3463
+ group: group42,
3464
+ name: "listScopeInvitations filters by status, and the cursor pages within the filter",
3465
+ async run({ store }) {
3466
+ const scope = `org-${mintId2()}`;
3467
+ const ids = [mintId2(), mintId2(), mintId2(), mintId2()].sort();
3468
+ for (const id of ids)
3469
+ await store.insertInvitation(invitation({ id, scope }));
3470
+ await store.updateInvitation(ids[1], 0, {
3471
+ updatedAt: t3,
3472
+ status: "revoked",
3473
+ revokedAt: t3
3474
+ });
3475
+ await store.updateInvitation(ids[2], 0, {
3476
+ updatedAt: t3,
3477
+ status: "accepted",
3478
+ acceptedBy: mintId2(),
3479
+ acceptedAt: t3
3480
+ });
3481
+ const ofStatus = async (status) => (await store.listScopeInvitations(scope, {
3482
+ status,
3483
+ first: 10,
3484
+ after: null
3485
+ })).items.map((item) => item.id);
3486
+ equal(await ofStatus("pending"), [ids[0], ids[3]], "listScopeInvitations: pending only");
3487
+ equal(await ofStatus("revoked"), [ids[1]], "listScopeInvitations: revoked only");
3488
+ equal(await ofStatus("accepted"), [ids[2]], "listScopeInvitations: accepted only");
3489
+ const page = await store.listScopeInvitations(scope, {
3490
+ status: "pending",
3491
+ first: 1,
3492
+ after: null
3493
+ });
3494
+ equal(page.nextCursor, ids[0], "listScopeInvitations: a filtered page has a cursor while more match");
3495
+ equal((await store.listScopeInvitations(scope, {
3496
+ status: "pending",
3497
+ first: 1,
3498
+ after: page.nextCursor
3499
+ })).items.map((item) => item.id), [ids[3]], "listScopeInvitations: the cursor skips what the filter excludes");
3500
+ }
3501
+ }
3502
+ ];
3503
+
3504
+ // src/conformance/invitations/cases/scope.ts
3505
+ var group43 = "invitations";
3506
+ var at10 = (iso) => new Date(iso);
3507
+ var t4 = at10("2026-03-01T00:00:00.000Z");
3508
+ var invitationScopeCases = [
3509
+ {
3510
+ id: "invitations.get",
3511
+ group: group43,
3512
+ name: "findInvitation answers the invitation with the scope it was stored in, and null for an id nobody stored",
3513
+ async run({ store }) {
3514
+ const scope = `org-${mintId2()}`;
3515
+ const mine = invitation({ scope });
3516
+ const theirs = invitation({ scope: `other-${mintId2()}` });
3517
+ await store.insertInvitation(mine);
3518
+ await store.insertInvitation(theirs);
3519
+ const found = await store.findInvitation(mine.id);
3520
+ equal(found, mine, "findInvitation: the invitation as written");
3521
+ equal(found?.scope, scope, "findInvitation: it carries its scope");
3522
+ equal((await store.findInvitation(theirs.id))?.scope === scope, false, "findInvitation: an invitation of another scope is not of this one");
3523
+ isNull(await store.findInvitation(mintId2()), "findInvitation: an unknown id is null");
3524
+ }
3525
+ },
3526
+ {
3527
+ id: "invitations.count-pending",
3528
+ group: group43,
3529
+ name: "countPendingInvitations counts one scope’s pending invitations that have not lapsed, and 0 for none",
3530
+ async run({ store }) {
3531
+ const scope = `org-${mintId2()}`;
3532
+ const now = at10("2026-06-01T00:00:00.000Z");
3533
+ const standing = invitation({ scope });
3534
+ const lapsed = invitation({
3535
+ scope,
3536
+ expiresAt: at10("2026-05-01T00:00:00.000Z")
3537
+ });
3538
+ const atNow = invitation({ scope, expiresAt: now });
3539
+ const revoked = invitation({ scope });
3540
+ await store.insertInvitation(standing);
3541
+ await store.insertInvitation(lapsed);
3542
+ await store.insertInvitation(atNow);
3543
+ await store.insertInvitation(revoked);
3544
+ await store.insertInvitation(invitation({ scope: "elsewhere" }));
3545
+ await store.updateInvitation(revoked.id, 0, {
3546
+ updatedAt: t4,
3547
+ status: "revoked",
3548
+ revokedAt: t4
3549
+ });
3550
+ equal(await store.countPendingInvitations(scope, now), 1, "countPendingInvitations: only the standing pending invitation, one expiring exactly now is lapsed");
3551
+ equal(await store.countPendingInvitations(`none-${mintId2()}`, now), 0, "countPendingInvitations: a scope without invitations is 0");
3552
+ }
3553
+ },
3554
+ {
3555
+ id: "invitations.delete-scope",
3556
+ group: group43,
3557
+ name: "deleteScopeInvitations deletes every invitation of one scope, whatever its status, and answers how many",
3558
+ async run({ store }) {
3559
+ const scope = `org-${mintId2()}`;
3560
+ const kept = invitation({ scope: "elsewhere" });
3561
+ const revoked = invitation({ scope });
3562
+ await store.insertInvitation(invitation({ scope }));
3563
+ await store.insertInvitation(revoked);
3564
+ await store.insertInvitation(kept);
3565
+ await store.updateInvitation(revoked.id, 0, {
3566
+ updatedAt: t4,
3567
+ status: "revoked",
3568
+ revokedAt: t4
3569
+ });
3570
+ equal(await store.deleteScopeInvitations(scope), 2, "deleteScopeInvitations: both are deleted");
3571
+ equal(await store.deleteScopeInvitations(scope), 0, "deleteScopeInvitations: a replay answers 0");
3572
+ equal(await store.findInvitation(kept.id), kept, "deleteScopeInvitations: another scope is left alone");
3573
+ }
3574
+ },
3575
+ {
3576
+ id: "invitations.delete-expired",
3577
+ group: group43,
3578
+ name: "deleteExpiredInvitations, when implemented, deletes invitations expiring at or before the instant and answers how many",
3579
+ async run({ store }) {
3580
+ if (store.deleteExpiredInvitations === undefined)
3581
+ return;
3582
+ const old = invitation({ expiresAt: at10("2026-01-10T00:00:00.000Z") });
3583
+ const edge = invitation({ expiresAt: at10("2026-02-01T00:00:00.000Z") });
3584
+ const live = invitation({ expiresAt: at10("2026-03-01T00:00:00.000Z") });
3585
+ await store.insertInvitation(old);
3586
+ await store.insertInvitation(edge);
3587
+ await store.insertInvitation(live);
3588
+ equal(await store.deleteExpiredInvitations(at10("2026-02-01T00:00:00.000Z")), 2, "deleteExpiredInvitations: at or before the instant");
3589
+ equal(await store.findInvitation(live.id), live, "deleteExpiredInvitations: a later one is kept");
3590
+ }
3591
+ }
3592
+ ];
3593
+
3594
+ // src/conformance/invitations/cases/update.ts
3595
+ var group44 = "invitations";
3596
+ var at11 = (iso) => new Date(iso);
3597
+ var t5 = at11("2026-03-01T00:00:00.000Z");
3598
+ var invitationUpdateCases = [
3599
+ {
3600
+ id: "invitations.update",
3601
+ group: group44,
3602
+ name: "updateInvitation applies a patch under ifVersion, answers the record as written with version + 1, and leaves unnamed fields alone",
3603
+ async run({ store }) {
3604
+ const record = invitation({ locale: "fr" });
3605
+ await store.insertInvitation(record);
3606
+ const by = mintId2();
3607
+ const written = await store.updateInvitation(record.id, 0, {
3608
+ updatedAt: t5,
3609
+ status: "accepted",
3610
+ acceptedBy: by,
3611
+ acceptedAt: t5
3612
+ });
3613
+ const expected = {
3614
+ ...record,
3615
+ version: 1,
3616
+ updatedAt: t5,
3617
+ status: "accepted",
3618
+ acceptedBy: by,
3619
+ acceptedAt: t5
3620
+ };
3621
+ equal(written, expected, "updateInvitation: the record as written");
3622
+ equal(await store.findInvitation(record.id), expected, "updateInvitation: findInvitation reads the write");
3623
+ equal(await store.findInvitationByCodeHash(record.codeHash), expected, "updateInvitation: the code hash still finds it");
3624
+ }
3625
+ },
3626
+ {
3627
+ id: "invitations.update.fields",
3628
+ group: group44,
3629
+ name: "updateInvitation replaces codeHash, expiresAt and locale whole, and a null locale erases it",
3630
+ async run({ store }) {
3631
+ const record = invitation({ locale: "fr" });
3632
+ await store.insertInvitation(record);
3633
+ const codeHash = "c".repeat(64);
3634
+ const expiresAt = at11("2028-01-01T00:00:00.000Z");
3635
+ await store.updateInvitation(record.id, 0, {
3636
+ updatedAt: t5,
3637
+ codeHash,
3638
+ expiresAt,
3639
+ locale: null
3640
+ });
3641
+ equal(await store.findInvitation(record.id), {
3642
+ ...record,
3643
+ version: 1,
3644
+ updatedAt: t5,
3645
+ codeHash,
3646
+ expiresAt,
3647
+ locale: null
3648
+ }, "updateInvitation: the new code hash, expiry and locale");
3649
+ isNull(await store.findInvitationByCodeHash(record.codeHash), "updateInvitation: the old code hash finds nothing");
3650
+ }
3651
+ },
3652
+ {
3653
+ id: "invitations.update.absent",
3654
+ group: group44,
3655
+ name: "updateInvitation answers null, writing nothing, for an id that is not stored",
3656
+ async run({ store }) {
3657
+ isNull(await store.updateInvitation(mintId2(), 0, {
3658
+ updatedAt: t5,
3659
+ status: "revoked",
3660
+ revokedAt: t5
3661
+ }), "updateInvitation: an absent invitation is null, not undefined and not a throw");
3662
+ }
3663
+ },
3664
+ {
3665
+ id: "invitations.update.version",
3666
+ group: group44,
3667
+ name: "updateInvitation throws StoreConflict on a version that moved, writing nothing",
3668
+ async run({ store }) {
3669
+ const record = invitation();
3670
+ await store.insertInvitation(record);
3671
+ await store.updateInvitation(record.id, 0, {
3672
+ updatedAt: t5,
3673
+ name: "first"
3674
+ });
3675
+ const error = await rejects(store.updateInvitation(record.id, 0, { updatedAt: t5, name: "stale" }), "updateInvitation with a stale version should reject");
3676
+ isOurs(error, StoreConflict2, "StoreConflict", "updateInvitation under a moved version");
3677
+ equal(error.on, "version", "updateInvitation: the conflict is on the version");
3678
+ equal((await store.findInvitation(record.id))?.name, "first", "a refused update should have changed nothing");
3679
+ equal((await store.findInvitation(record.id))?.version, 1, "a refused update should not move the version");
3680
+ }
3681
+ },
3682
+ {
3683
+ id: "invitations.update.concurrent",
3684
+ group: group44,
3685
+ name: "updateInvitation: of 20 concurrent claims on one version exactly one wins and the others throw StoreConflict",
3686
+ async run({ store }) {
3687
+ const record = invitation();
3688
+ await store.insertInvitation(record);
3689
+ const settled = await Promise.allSettled(Array.from({ length: 20 }, () => store.updateInvitation(record.id, 0, {
3690
+ updatedAt: t5,
3691
+ status: "accepted",
3692
+ acceptedBy: mintId2(),
3693
+ acceptedAt: t5
3694
+ })));
3695
+ equal(settled.filter((result) => result.status === "fulfilled").length, 1, "updateInvitation: exactly one of twenty concurrent claims should have won");
3696
+ const losers = settled.filter((result) => result.status === "rejected");
3697
+ for (const loser of losers) {
3698
+ isOurs(loser.reason, StoreConflict2, "StoreConflict", "a losing claim");
3699
+ }
3700
+ equal(losers.length, 19, "updateInvitation: the other nineteen should have thrown");
3701
+ equal((await store.findInvitation(record.id))?.version, 1, "updateInvitation: one write, one version");
3702
+ }
3703
+ },
3704
+ {
3705
+ id: "invitations.update.release",
3706
+ group: group44,
3707
+ name: "updateInvitation can release a claim to pending, but throws StoreConflict when another pending invitation holds the address",
3708
+ async run({ store }) {
3709
+ const record = invitation({ email: "ada@example.com" });
3710
+ await store.insertInvitation(record);
3711
+ await store.updateInvitation(record.id, 0, {
3712
+ updatedAt: t5,
3713
+ status: "accepted",
3714
+ acceptedBy: mintId2(),
3715
+ acceptedAt: t5
3716
+ });
3717
+ const released = await store.updateInvitation(record.id, 1, {
3718
+ updatedAt: t5,
3719
+ status: "pending",
3720
+ acceptedBy: null,
3721
+ acceptedAt: null
3722
+ });
3723
+ equal(released?.status, "pending", "updateInvitation: a claim is released to pending");
3724
+ equal(released?.acceptedBy, null, "updateInvitation: and its acceptor is cleared");
3725
+ await store.updateInvitation(record.id, 2, {
3726
+ updatedAt: t5,
3727
+ status: "accepted",
3728
+ acceptedBy: mintId2(),
3729
+ acceptedAt: t5
3730
+ });
3731
+ equal(await store.insertInvitation(invitation({ email: "ada@example.com" })), true, "insertInvitation: the claimed invitation no longer holds the address");
3732
+ const error = await rejects(store.updateInvitation(record.id, 3, {
3733
+ updatedAt: t5,
3734
+ status: "pending"
3735
+ }), "releasing onto a held address should reject");
3736
+ isOurs(error, StoreConflict2, "StoreConflict", "a release onto a held address");
3737
+ equal(error.on, "pending", "the conflict is on the pending slot, not the version");
3738
+ equal(error.code, "INVITATION_PENDING", "the conflict code");
3739
+ equal((await store.findInvitation(record.id))?.status, "accepted", "a refused release should have changed nothing");
3740
+ }
3741
+ }
3742
+ ];
3743
+
3744
+ // src/conformance/invitations/cases/index.ts
3745
+ var invitationStoreCases = [
3746
+ ...invitationInsertCases,
3747
+ ...invitationImportedCases,
3748
+ ...invitationFindPendingCases,
3749
+ ...invitationListCases,
3750
+ ...invitationListLapsedCases,
3751
+ ...invitationListStatusCases,
3752
+ ...invitationScopeCases,
3753
+ ...invitationUpdateCases,
3754
+ ...invitationActorCases
3755
+ ];
3756
+ // src/conformance/invitations/cases/outage.ts
3757
+ var seeded2 = invitation({ id: "00000000-0000-7000-8000-000000000001" });
3758
+ var when2 = new Date("2026-09-01T00:00:00.000Z");
3759
+ function outage3(method, call, after) {
3760
+ return {
3761
+ id: `outage.${method}`,
3762
+ group: "outage",
3763
+ name: `invitations.${method} rejects when the store cannot answer — never null, false, 0 or an empty page`,
3764
+ needs: "faults",
3765
+ async run({ store, faults }) {
3766
+ await store.insertInvitation(seeded2);
3767
+ await faults?.fail(method);
3768
+ const error = await rejects(call(store), `invitations.${method} under an outage should reject`);
3769
+ if (error instanceof JanusError2 || error?.name === "StoreFailure") {
3770
+ isOurs(error, StoreFailure2, "StoreFailure", `invitations.${method} under an outage`);
3771
+ }
3772
+ ok(error?.code !== "NOT_FOUND", `invitations.${method} under an outage rejected with NOT_FOUND: an outage is never an absence`);
3773
+ await after?.(store);
3774
+ }
3775
+ };
3776
+ }
3777
+ function optional2(invitationCase) {
3778
+ const method = invitationCase.id.slice("outage.".length);
3779
+ return {
3780
+ ...invitationCase,
3781
+ async run(context) {
3782
+ if (context.store[method] === undefined)
3783
+ return;
3784
+ await invitationCase.run(context);
3785
+ }
3786
+ };
3787
+ }
3788
+ var unchanged = async (store) => equal(await store.findInvitation(seeded2.id), seeded2, "a rejected write should have changed nothing");
3789
+ var invitationOutageCases = [
3790
+ outage3("insertInvitation", (store) => store.insertInvitation(invitation())),
3791
+ outage3("findInvitation", (store) => store.findInvitation(seeded2.id)),
3792
+ outage3("findInvitationByCodeHash", (store) => store.findInvitationByCodeHash(seeded2.codeHash)),
3793
+ outage3("listScopeInvitations", (store) => store.listScopeInvitations(seeded2.scope, {
3794
+ status: null,
3795
+ first: 10,
3796
+ after: null
3797
+ })),
3798
+ outage3("countPendingInvitations", (store) => store.countPendingInvitations(seeded2.scope, when2)),
3799
+ outage3("updateInvitation", (store) => store.updateInvitation(seeded2.id, 0, {
3800
+ updatedAt: when2,
3801
+ status: "revoked",
3802
+ revokedAt: when2
3803
+ }), unchanged),
3804
+ outage3("deleteScopeInvitations", (store) => store.deleteScopeInvitations(seeded2.scope), async (store) => equal((await store.findInvitation(seeded2.id))?.id, seeded2.id, "a rejected deletion should have deleted nothing")),
3805
+ optional2(outage3("deleteExpiredInvitations", (store) => store.deleteExpiredInvitations(new Date("2100-01-01T00:00:00.000Z")))),
3806
+ optional2(outage3("countScopeInvitations", (store) => store.countScopeInvitations(seeded2.scope, { status: null, role: null, ref: null, lapsed: null }))),
3807
+ optional2(outage3("findPendingInvitation", (store) => store.findPendingInvitation(seeded2.scope, "someone@example.com")))
3808
+ ];
3809
+ // src/conformance/invitations/describe.ts
3810
+ var allInvitationCases = [
3811
+ ...invitationStoreCases,
3812
+ ...invitationOutageCases
3813
+ ];
3814
+ async function runInvitationCase(invitationCase, harness) {
3815
+ const opened = await harness.open();
3816
+ try {
3817
+ if (invitationCase.needs === "faults" && opened.faults === undefined) {
3818
+ return { skipped: SKIP_REASONS.faults };
3819
+ }
3820
+ await invitationCase.run({
3821
+ store: opened.store,
3822
+ faults: opened.faults ?? null
3823
+ });
3824
+ return { passed: true };
3825
+ } finally {
3826
+ await opened.close?.();
3827
+ }
3828
+ }
3829
+ function describeInvitationStores(options) {
3830
+ describeSuite({
3831
+ title: `${options.name} — @softistx/janus invitation conformance`,
3832
+ cases: allInvitationCases,
3833
+ run: (invitationCase) => runInvitationCase(invitationCase, options.harness),
3834
+ runner: options.runner ?? fromGlobals("describeInvitationStores"),
3835
+ skip: options.skip ?? {},
3836
+ faults: options.faults
3837
+ });
3838
+ }
3839
+ // src/conformance/invitations/reference.ts
3840
+ function referenceInvitationHarness() {
3841
+ return {
3842
+ async open() {
3843
+ const failing = new Set;
3844
+ const inner = createMemoryInvitations2();
3845
+ const store = Object.fromEntries(Object.entries(inner).map(([method, fn]) => [
3846
+ method,
3847
+ (...args) => failing.has(method) ? Promise.reject(new StoreFailure2(`invitations.${method}: the store could not answer`, { slot: "invitations", operation: method })) : fn.apply(inner, args)
3848
+ ]));
3849
+ return {
3850
+ store,
3851
+ faults: {
3852
+ async fail(method) {
3853
+ failing.add(method);
3854
+ }
3855
+ }
3856
+ };
3857
+ }
3858
+ };
3859
+ }
3860
+ // src/conformance/reference.ts
3861
+ function referenceHarness() {
3862
+ return {
3863
+ async open() {
3864
+ const failing = new Set;
3865
+ const stores = withFaults(createMemoryStores2(), failing);
3866
+ const faults = {
3867
+ async fail(slot, method) {
3868
+ failing.add(`${slot}.${method}`);
3869
+ }
3870
+ };
3871
+ return { stores, faults };
3872
+ }
3873
+ };
3874
+ }
3875
+ function withFaults(stores, failing) {
3876
+ const wrap = (slot, store) => {
3877
+ const wrapped = {};
3878
+ for (const [method, fn] of Object.entries(store)) {
3879
+ wrapped[method] = (...args) => {
3880
+ if (failing.has(`${slot}.${method}`)) {
3881
+ return Promise.reject(new StoreFailure2(`${slot}.${method}: the store could not answer`, {
3882
+ slot,
3883
+ operation: method
3884
+ }));
3885
+ }
3886
+ return fn.apply(store, args);
3887
+ };
3888
+ }
3889
+ return wrapped;
3890
+ };
3891
+ return {
3892
+ users: wrap("users", stores.users),
3893
+ sessions: wrap("sessions", stores.sessions),
3894
+ tokens: wrap("tokens", stores.tokens),
3895
+ ...stores.socialLinks === undefined ? {} : { socialLinks: wrap("socialLinks", stores.socialLinks) },
3896
+ ...stores.passkeys === undefined ? {} : { passkeys: wrap("passkeys", stores.passkeys) }
3897
+ };
3898
+ }
3899
+ // src/conformance/relations/fixtures.ts
3900
+ var entity = (type, id = mintId2()) => ({
3901
+ type,
3902
+ id
3903
+ });
3904
+ var set = (type, id, relation) => ({
3905
+ type,
3906
+ id,
3907
+ relation
3908
+ });
3909
+ var tuple = (object, relation, subject) => ({ object, relation, subject });
3910
+ var sorted = (subjects) => subjects.map(formatSubject2).sort();
3911
+
3912
+ // src/conformance/relations/cases/deletion.ts
3913
+ var group45 = "relations";
3914
+ var relationDeletionCases = [
3915
+ {
3916
+ id: "relations.deleteEntity",
3917
+ group: group45,
3918
+ name: "deletes every tuple naming an entity — as object, as subject, as a set’s entity — and counts them",
3919
+ async run({ store }) {
3920
+ const team = entity("team");
3921
+ const other = entity("team");
3922
+ const kept = [
3923
+ tuple(other, "member", entity("staff")),
3924
+ tuple(entity("record"), "viewer", set("team", other.id, "member"))
3925
+ ];
3926
+ await store.write({
3927
+ add: [
3928
+ tuple(team, "member", entity("staff")),
3929
+ tuple(entity("record"), "team", team),
3930
+ tuple(entity("record"), "viewer", set("team", team.id, "member")),
3931
+ ...kept
3932
+ ]
3933
+ });
3934
+ equal(await store.deleteEntity(team), 3, "deleteEntity: how many it deleted");
3935
+ for (const survivor of kept) {
3936
+ equal(await store.has(survivor), true, "deleteEntity should not touch another entity");
3937
+ }
3938
+ equal(await store.deleteEntity(team), 0, "deleteEntity replayed answers 0, not a failure");
3939
+ }
3940
+ }
3941
+ ];
3942
+
3943
+ // src/conformance/relations/cases/holders.ts
3944
+ var group46 = "relations";
3945
+ var relationHolderCases = [
3946
+ {
3947
+ id: "relations.findHolders",
3948
+ group: group46,
3949
+ name: "findHolders pages the single entities of one object and relation in type then id order, with a cursor, and leaves out subject sets and other relations",
3950
+ async run({ store }) {
3951
+ if (store.findHolders === undefined)
3952
+ return;
3953
+ const findHolders = store.findHolders.bind(store);
3954
+ const record = entity("record", "holders");
3955
+ const staff = ["b2", "a1", "c3"].map((id) => entity("staff", id));
3956
+ const other = entity("patient", "a1");
3957
+ await store.write({
3958
+ add: [
3959
+ ...staff.map((holder) => tuple(record, "viewer", holder)),
3960
+ tuple(record, "viewer", other),
3961
+ tuple(record, "viewer", set("team", "t1", "member")),
3962
+ tuple(record, "owner", entity("staff", "zz")),
3963
+ tuple(entity("record", "else"), "viewer", entity("staff", "yy"))
3964
+ ]
3965
+ });
3966
+ const read = (after, limit) => findHolders({
3967
+ object: record,
3968
+ relation: "viewer",
3969
+ after,
3970
+ limit,
3971
+ search: null
3972
+ });
3973
+ const first = await read(null, 3);
3974
+ equal(first.items, [other, entity("staff", "a1"), entity("staff", "b2")], "findHolders: the first page, by type then id");
3975
+ equal(first.nextCursor, holderCursor2(entity("staff", "b2")), "findHolders: nextCursor follows the last item");
3976
+ equal(await read(first.nextCursor, 3), { items: [entity("staff", "c3")], nextCursor: null }, "findHolders: the last page ends with a null nextCursor");
3977
+ equal(await read(holderCursor2(entity("staff", "a1")), 1), {
3978
+ items: [entity("staff", "b2")],
3979
+ nextCursor: holderCursor2(entity("staff", "b2"))
3980
+ }, "findHolders: a cursor need not name a stored holder");
3981
+ }
3982
+ },
3983
+ {
3984
+ id: "relations.findHolders.search",
3985
+ group: group46,
3986
+ name: "findHolders search keeps the holders whose id contains the text, ignoring case, and takes % _ . and \\ literally",
3987
+ async run({ store }) {
3988
+ if (store.findHolders === undefined)
3989
+ return;
3990
+ const findHolders = store.findHolders.bind(store);
3991
+ const record = entity("record", "search");
3992
+ const ids = ["Ana", "banana", "a.b", "a_b", "a%b", "a\\b", "axb", "zed"];
3993
+ await store.write({
3994
+ add: ids.map((id) => tuple(record, "viewer", entity("staff", id)))
3995
+ });
3996
+ const found = async (search) => {
3997
+ const all = [];
3998
+ let after = null;
3999
+ do {
4000
+ const page = await findHolders({
4001
+ object: record,
4002
+ relation: "viewer",
4003
+ after,
4004
+ limit: 2,
4005
+ search
4006
+ });
4007
+ all.push(...page.items);
4008
+ after = page.nextCursor;
4009
+ } while (after !== null);
4010
+ return all.map((holder) => holder.id).sort();
4011
+ };
4012
+ equal(await found("ANA"), ["Ana", "banana"], "findHolders: ignores case");
4013
+ equal(await found("a.b"), ["a.b"], 'findHolders: "." is not a wildcard');
4014
+ equal(await found("a_b"), ["a_b"], 'findHolders: "_" is not a wildcard');
4015
+ equal(await found("a%b"), ["a%b"], 'findHolders: "%" is not a wildcard');
4016
+ equal(await found("a\\b"), ["a\\b"], 'findHolders: "\\" is no escape');
4017
+ equal(await found("nobody"), [], "findHolders: no match is an empty page");
4018
+ }
4019
+ },
4020
+ {
4021
+ id: "relations.findHolders.cursor",
4022
+ group: group46,
4023
+ name: "findHolders refuses a cursor it did not mint with InvalidCursorError, never the first page",
4024
+ async run({ store }) {
4025
+ if (store.findHolders === undefined)
4026
+ return;
4027
+ const findHolders = store.findHolders.bind(store);
4028
+ const record = entity("record", "cursor");
4029
+ await store.write({
4030
+ add: [tuple(record, "viewer", entity("staff", "u1"))]
4031
+ });
4032
+ const error = await rejects(findHolders({
4033
+ object: record,
4034
+ relation: "viewer",
4035
+ after: "not a cursor of this store",
4036
+ limit: 5,
4037
+ search: null
4038
+ }), "findHolders should refuse a foreign cursor");
4039
+ isOurs(error, InvalidCursorError2, "InvalidCursorError", "findHolders");
4040
+ }
4041
+ }
4042
+ ];
4043
+
4044
+ // src/conformance/relations/cases/reads.ts
4045
+ var group47 = "relations";
4046
+ var relationReadCases = [
4047
+ {
4048
+ id: "relations.roundTrip",
4049
+ group: group47,
4050
+ name: "holds exactly the tuples written, byte for byte: staff:u1 is not patient:u1, and a set is not its entity",
4051
+ async run({ store }) {
4052
+ const record = entity("record", "R:1 — ÿ");
4053
+ const direct = tuple(record, "viewer", entity("staff", "u1"));
4054
+ const inherited = tuple(record, "viewer", set("team", "t1", "member"));
4055
+ await store.write({ add: [direct, inherited] });
4056
+ equal(await store.has(direct), true, "has for a written tuple");
4057
+ equal(await store.has(inherited), true, "has for a written subject set");
4058
+ equal(await store.has(tuple(record, "viewer", entity("patient", "u1"))), false, "has for the same id under another subject type: types are part of the subject");
4059
+ equal(await store.has(tuple(record, "viewer", entity("team", "t1"))), false, "has for the entity of a stored subject set: a set is not its entity");
4060
+ equal(await store.has(tuple(entity("record", "r:1 — ÿ"), "viewer", direct.subject)), false, "has for an id differing in one character: ids are compared as written");
4061
+ }
4062
+ },
4063
+ {
4064
+ id: "relations.edgeCharacters",
4065
+ group: group47,
4066
+ name: "round-trips every character the core lets through in an id: control characters, U+FFFF and a surrogate pair",
4067
+ async run({ store }) {
4068
+ const edge = "a\x01\x1F￿ \uD83D\uDE00 z";
4069
+ const record = entity("record", edge);
4070
+ const written = tuple(record, "viewer", set("team", edge, "member"));
4071
+ const direct = tuple(record, "viewer", entity("staff", edge));
4072
+ await store.write({ add: [written, direct] });
4073
+ equal(await store.has(written), true, "has for ids of edge characters");
4074
+ equal(await store.findSubjectSets(record, "viewer"), [set("team", edge, "member")], "findSubjectSets answers the set id as written");
4075
+ equal(await store.findEntities(record, "viewer"), [entity("staff", edge)], "findEntities answers the entity id as written");
4076
+ equal(await store.findObjects({
4077
+ type: "record",
4078
+ relation: "viewer",
4079
+ subject: direct.subject,
4080
+ after: null,
4081
+ limit: 10
4082
+ }), { items: [edge], nextCursor: null }, "findObjects answers the object id as written");
4083
+ equal(await store.has(tuple(entity("record", edge.replace("\uD83D\uDE00", "\uD83D\uDE01")), "viewer", written.subject)), false, "has for an id differing in one astral character");
4084
+ }
4085
+ },
4086
+ {
4087
+ id: "relations.undefinedRelation",
4088
+ group: group47,
4089
+ name: "reads a subject whose relation is undefined as its entity, not as a set",
4090
+ async run({ store }) {
4091
+ const record = entity("record");
4092
+ const staff = entity("staff");
4093
+ const spread = { ...staff, relation: undefined };
4094
+ await store.write({ add: [tuple(record, "viewer", spread)] });
4095
+ equal(await store.has(tuple(record, "viewer", staff)), true, "has for the entity, after writing it with relation: undefined");
4096
+ equal(await store.findEntities(record, "viewer"), [staff], "findEntities: the tuple names an entity");
4097
+ equal(await store.findSubjectSets(record, "viewer"), [], "findSubjectSets: relation: undefined is no set");
4098
+ equal(await store.findObjects({
4099
+ type: "record",
4100
+ relation: "viewer",
4101
+ subject: spread,
4102
+ after: null,
4103
+ limit: 10
4104
+ }), { items: [record.id], nextCursor: null }, "findObjects for the subject written with relation: undefined");
4105
+ equal(await store.findObjects({
4106
+ type: "record",
4107
+ relation: "viewer",
4108
+ subject: set("staff", staff.id, "x"),
4109
+ after: null,
4110
+ limit: 10
4111
+ }), { items: [], nextCursor: null }, "findObjects for a set of that entity: the entity is not a set");
4112
+ await store.write({ remove: [tuple(record, "viewer", spread)] });
4113
+ equal(await store.has(tuple(record, "viewer", staff)), false, "has after removing it with relation: undefined");
4114
+ }
4115
+ },
4116
+ {
4117
+ id: "relations.absence",
4118
+ group: group47,
4119
+ name: "answers false, [], an empty page and 0 for an empty store — never null or undefined",
4120
+ async run({ store }) {
4121
+ const record = entity("record");
4122
+ const staff = entity("staff");
4123
+ equal(await store.has(tuple(record, "viewer", staff)), false, "has");
4124
+ equal(await store.findSubjectSets(record, "viewer"), [], "findSubjectSets");
4125
+ equal(await store.findEntities(record, "viewer"), [], "findEntities");
4126
+ equal(await store.findObjects({
4127
+ type: "record",
4128
+ relation: "viewer",
4129
+ subject: staff,
4130
+ after: null,
4131
+ limit: 10
4132
+ }), { items: [], nextCursor: null }, "findObjects on an empty store");
4133
+ equal(await store.deleteEntity(staff), 0, "deleteEntity");
4134
+ }
4135
+ }
4136
+ ];
4137
+
4138
+ // src/conformance/relations/cases/traversal.ts
4139
+ var group48 = "relations";
4140
+ var relationTraversalCases = [
4141
+ {
4142
+ id: "relations.oneHop",
4143
+ group: group48,
4144
+ name: "answers one hop: the subject sets and the entities holding one relation on one object, and nothing else",
4145
+ async run({ store }) {
4146
+ const record = entity("record");
4147
+ const staff = entity("staff");
4148
+ const team = entity("team");
4149
+ const members = set("team", team.id, "member");
4150
+ const leads = set("team", team.id, "lead");
4151
+ await store.write({
4152
+ add: [
4153
+ tuple(record, "viewer", staff),
4154
+ tuple(record, "viewer", team),
4155
+ tuple(record, "viewer", members),
4156
+ tuple(record, "viewer", leads),
4157
+ tuple(record, "editor", set("team", team.id, "admin")),
4158
+ tuple(entity("record"), "viewer", set("team", "other", "member"))
4159
+ ]
4160
+ });
4161
+ equal(sorted(await store.findSubjectSets(record, "viewer")), sorted([members, leads]), "findSubjectSets: the sets only, of this object and this relation");
4162
+ equal(sorted(await store.findEntities(record, "viewer")), sorted([staff, team]), "findEntities: the single entities only, of this object and this relation");
4163
+ }
4164
+ },
4165
+ {
4166
+ id: "relations.objects",
4167
+ group: group48,
4168
+ name: "pages 25 objects by 10 in ascending id order, for one type, relation and exact subject, and ends on a null cursor",
4169
+ async run({ store }) {
4170
+ const staff = entity("staff");
4171
+ const ids = Array.from({ length: 25 }, (_, n) => `r${String(n).padStart(2, "0")}`);
4172
+ for (const id of [...ids].reverse()) {
4173
+ await store.write({
4174
+ add: [
4175
+ tuple(entity("record", id), "viewer", staff),
4176
+ tuple(entity("record", `${id}x`), "editor", staff),
4177
+ tuple(entity("folder", id), "viewer", staff),
4178
+ tuple(entity("record", `${id}y`), "viewer", set("staff", staff.id, "x"))
4179
+ ]
4180
+ });
4181
+ }
4182
+ const seen = [];
4183
+ const sizes = [];
4184
+ let after = null;
4185
+ for (let page = 0;page < 10; page += 1) {
4186
+ const answer = await store.findObjects({
4187
+ type: "record",
4188
+ relation: "viewer",
4189
+ subject: staff,
4190
+ after,
4191
+ limit: 10
4192
+ });
4193
+ seen.push(...answer.items);
4194
+ sizes.push(answer.items.length);
4195
+ after = answer.nextCursor;
4196
+ if (after === null)
4197
+ break;
4198
+ }
4199
+ equal(sizes, [10, 10, 5], "findObjects: page sizes for 25 objects by 10");
4200
+ equal(seen, ids, "findObjects: every id once, in ascending order");
4201
+ const between = await store.findObjects({
4202
+ type: "record",
4203
+ relation: "viewer",
4204
+ subject: staff,
4205
+ after: "r04a",
4206
+ limit: 2
4207
+ });
4208
+ equal(between.items, ["r05", "r06"], "findObjects: a cursor naming no stored object should start after it");
4209
+ }
4210
+ }
4211
+ ];
4212
+
4213
+ // src/conformance/relations/cases/writes.ts
4214
+ var group49 = "relations";
4215
+ var relationWriteCases = [
4216
+ {
4217
+ id: "relations.idempotentWrite",
4218
+ group: group49,
4219
+ name: "is idempotent under retry: adding a stored tuple and removing an absent one write nothing",
4220
+ async run({ store }) {
4221
+ const record = entity("record");
4222
+ const viewer = tuple(record, "viewer", entity("team"));
4223
+ await store.write({ add: [viewer] });
4224
+ await store.write({ add: [viewer] });
4225
+ await store.write({ remove: [tuple(record, "viewer", entity("team"))] });
4226
+ equal((await store.findEntities(record, "viewer")).length, 1, "findEntities after the same tuple was added twice");
4227
+ }
4228
+ },
4229
+ {
4230
+ id: "relations.uniqueness",
4231
+ group: group49,
4232
+ name: "keeps one tuple when twenty concurrent writes add it: uniqueness is a constraint, not a read",
4233
+ async run({ store }) {
4234
+ const record = entity("record");
4235
+ const parent = entity("folder");
4236
+ await Promise.all(Array.from({ length: 20 }, () => store.write({ add: [tuple(record, "parent", parent)] })));
4237
+ equal(await store.findEntities(record, "parent"), [parent], "findEntities after twenty concurrent adds of one tuple");
4238
+ }
4239
+ },
4240
+ {
4241
+ id: "relations.removeThenAdd",
4242
+ group: group49,
4243
+ name: "applies one write’s removals and additions together",
4244
+ async run({ store }) {
4245
+ const record = entity("record");
4246
+ const before = tuple(record, "owner", entity("staff", "a"));
4247
+ const after = tuple(record, "owner", entity("staff", "b"));
4248
+ await store.write({ add: [before] });
4249
+ await store.write({ remove: [before], add: [after] });
4250
+ equal(await store.has(before), false, "the removed tuple");
4251
+ equal(await store.has(after), true, "the added tuple");
4252
+ }
4253
+ }
4254
+ ];
4255
+
4256
+ // src/conformance/relations/cases/index.ts
4257
+ var relationStoreCases = [
4258
+ ...relationReadCases,
4259
+ ...relationHolderCases,
4260
+ ...relationWriteCases,
4261
+ ...relationTraversalCases,
4262
+ ...relationDeletionCases
4263
+ ];
4264
+ // src/conformance/relations/cases/outage.ts
4265
+ function outage4(method, call, after) {
4266
+ return {
4267
+ id: `outage.${method}`,
4268
+ group: "outage",
4269
+ name: `relations.${method} rejects when the store cannot answer — never false, [], an empty page or 0`,
4270
+ needs: "faults",
4271
+ async run({ store, faults }) {
4272
+ await store.write({ add: [seeded3] });
4273
+ await faults?.fail(method);
4274
+ const error = await rejects(call(store), `relations.${method} under an outage should reject`);
4275
+ if (error instanceof JanusError2 || error?.name === "StoreFailure") {
4276
+ isOurs(error, StoreFailure2, "StoreFailure", `relations.${method} under an outage`);
4277
+ }
4278
+ ok(error?.code !== "NOT_FOUND", `relations.${method} under an outage rejected with NOT_FOUND: an outage is never an absence`);
4279
+ await after?.(store);
4280
+ }
4281
+ };
4282
+ }
4283
+ function optional3(relationCase) {
4284
+ const method = relationCase.id.slice("outage.".length);
4285
+ return {
4286
+ ...relationCase,
4287
+ async run(context) {
4288
+ if (context.store[method] === undefined)
4289
+ return;
4290
+ await relationCase.run(context);
4291
+ }
4292
+ };
4293
+ }
4294
+ var seededObject = { type: "record", id: "seeded" };
4295
+ var seededSubject = { type: "staff", id: "seeded" };
4296
+ var seeded3 = tuple(seededObject, "viewer", seededSubject);
4297
+ var relationOutageCases = [
4298
+ outage4("write", (store) => store.write({
4299
+ remove: [seeded3],
4300
+ add: [tuple(seededObject, "owner", seededSubject)]
4301
+ }), async (store) => {
4302
+ equal(await store.has(seeded3), true, "relations.write rejected, and still removed a tuple: a write is all or nothing");
4303
+ equal(await store.has(tuple(seededObject, "owner", seededSubject)), false, "relations.write rejected, and still added a tuple: a write is all or nothing");
4304
+ }),
4305
+ outage4("has", (store) => store.has(seeded3)),
4306
+ outage4("findSubjectSets", (store) => store.findSubjectSets(seededObject, "viewer")),
4307
+ outage4("findEntities", (store) => store.findEntities(seededObject, "viewer")),
4308
+ optional3(outage4("findHolders", (store) => store.findHolders({
4309
+ object: seededObject,
4310
+ relation: "viewer",
4311
+ after: null,
4312
+ limit: 10,
4313
+ search: null
4314
+ }))),
4315
+ outage4("findObjects", (store) => store.findObjects({
4316
+ type: "record",
4317
+ relation: "viewer",
4318
+ subject: seededSubject,
4319
+ after: null,
4320
+ limit: 10
4321
+ })),
4322
+ outage4("deleteEntity", (store) => store.deleteEntity(seededSubject))
4323
+ ];
4324
+ // src/conformance/relations/describe.ts
4325
+ var allRelationCases = [
4326
+ ...relationStoreCases,
4327
+ ...relationOutageCases
4328
+ ];
4329
+ async function runRelationCase(relationCase, harness) {
4330
+ const opened = await harness.open();
4331
+ try {
4332
+ if (relationCase.needs === "faults" && opened.faults === undefined) {
4333
+ return { skipped: SKIP_REASONS.faults };
4334
+ }
4335
+ await relationCase.run({
4336
+ store: opened.store,
4337
+ faults: opened.faults ?? null
4338
+ });
4339
+ return { passed: true };
4340
+ } finally {
4341
+ await opened.close?.();
4342
+ }
4343
+ }
4344
+ function describeRelationStores(options) {
4345
+ describeSuite({
4346
+ title: `${options.name} — @softistx/janus relation conformance`,
4347
+ cases: allRelationCases,
4348
+ run: (relationCase) => runRelationCase(relationCase, options.harness),
4349
+ runner: options.runner ?? fromGlobals("describeRelationStores"),
4350
+ skip: options.skip ?? {},
4351
+ faults: options.faults
4352
+ });
4353
+ }
4354
+ // src/conformance/relations/reference.ts
4355
+ function referenceRelationHarness() {
4356
+ return {
4357
+ async open() {
4358
+ const failing = new Set;
4359
+ const inner = createMemoryRelations2();
4360
+ const store = Object.fromEntries(Object.entries(inner).map(([method, fn]) => [
4361
+ method,
4362
+ (...args) => failing.has(method) ? Promise.reject(new StoreFailure2(`relations.${method}: the store could not answer`, {
4363
+ slot: "relations",
4364
+ operation: method
4365
+ })) : fn.apply(inner, args)
4366
+ ]));
4367
+ return {
4368
+ store,
4369
+ faults: {
4370
+ async fail(method) {
4371
+ failing.add(method);
4372
+ }
4373
+ }
4374
+ };
4375
+ }
4376
+ };
4377
+ }
4378
+ export {
4379
+ SKIP_REASONS,
4380
+ allApiKeyCases,
4381
+ allCases,
4382
+ allInvitationCases,
4383
+ allRelationCases,
4384
+ apiKeyOutageCases,
4385
+ apiKeyStoreCases,
4386
+ describeApiKeyStores,
4387
+ describeInvitationStores,
4388
+ describeJanusStores,
4389
+ describeRelationStores,
4390
+ invitationOutageCases,
4391
+ invitationStoreCases,
4392
+ outageCases,
4393
+ passkeyStoreCases,
4394
+ referenceApiKeyHarness,
4395
+ referenceHarness,
4396
+ referenceInvitationHarness,
4397
+ referenceRelationHarness,
4398
+ relationOutageCases,
4399
+ relationStoreCases,
4400
+ runApiKeyCase,
4401
+ runCase,
4402
+ runInvitationCase,
4403
+ runRelationCase,
4404
+ sessionStoreCases,
4405
+ socialLinkStoreCases,
4406
+ tokenStoreCases,
4407
+ userStoreCases
4408
+ };
4409
+
4410
+ //# debugId=D7A565CB51A0DC5864756E2164756E21
4411
+ //# sourceMappingURL=index.js.map