@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,858 @@
1
+ # Writing an adapter — the ports and `@softistx/janus/conformance`
2
+
3
+ This page is for putting `janus()` or `permissions()` on a database of your
4
+ choice: the two ports you implement, the rules they carry, and the conformance
5
+ suites that check an implementation keeps them. If you only use an existing
6
+ adapter, such as `@softistx/janus-mongo`, you do not need it.
7
+
8
+ ```ts
9
+ import { describe, it } from 'bun:test';
10
+ import { describeJanusStores } from '@softistx/janus/conformance';
11
+
12
+ // Yours: myStores(db) builds your adapter's stores, freshDatabase() an empty
13
+ // database with a way to make one command fail.
14
+ describeJanusStores({
15
+ name: 'my adapter',
16
+ runner: { describe, it },
17
+ harness: {
18
+ async open() {
19
+ const db = await freshDatabase(); // one per case, never shared
20
+ return {
21
+ stores: myStores(db),
22
+ faults: { fail: (slot, method) => db.failNext(method) },
23
+ close: () => db.drop(),
24
+ };
25
+ },
26
+ },
27
+ });
28
+ ```
29
+
30
+ ## The two ports
31
+
32
+ | Port | Taken by | Methods |
33
+ | --- | --- | --- |
34
+ | `JanusStores` — `{ users: UserStore, sessions: SessionStore, tokens: TokenStore, socialLinks?: SocialLinkStore, passkeys?: PasskeyStore }` | `janus({ store })` | 6 (+ 1 optional) + 7 (+ 1 optional) + 5 (+ 1 optional) + 5 (the optional `socialLinks` slot) + 7 (the optional `passkeys` slot) |
35
+ | `RelationStore` | `permissions({ store })`, `janus({ relations })` | 6 (+ 1 optional) |
36
+
37
+ They are separate on purpose: an application that only authenticates
38
+ implements nothing for permissions, and each of the three user slots may come
39
+ from a different adapter — users in one database, sessions and tokens in
40
+ another:
41
+
42
+ ```ts
43
+ janus({
44
+ user: User,
45
+ password: { login: 'email' },
46
+ store: { users: mongo.users, sessions: other.sessions, tokens: other.tokens },
47
+ hasher: scryptHasher(),
48
+ });
49
+ ```
50
+
51
+ The seam is where atomicity is not required: a user and their password are one
52
+ record, a session is derived state, a token is ephemeral.
53
+
54
+ ### `UserStore`
55
+
56
+ ```ts
57
+ interface UserStore {
58
+ insertUser(record: UserRecord): Promise<UserRecord>;
59
+ findUser(id: Id): Promise<UserRecord | null>;
60
+ findUsers?(ids: readonly Id[]): Promise<readonly UserRecord[]>; // optional: one query for many ids
61
+ findUserByLogin(type: string, login: string): Promise<UserRecord | null>;
62
+ listUsers(page: UserPageRequest): Promise<CursorPage<UserRecord>>;
63
+ countUsers(filter: UserFilter): Promise<number>;
64
+ updateUser(id: Id, patch: UserPatch, ifVersion: number): Promise<UserRecord>;
65
+ deleteUser(id: Id): Promise<boolean>;
66
+ }
67
+ ```
68
+
69
+ - `insertUser` is **idempotent under retry**: a user with this `id` already
70
+ stored is answered as stored. A login held by another user of the same type
71
+ rejects with `StoreConflict('login', …)`, from the database's own unique
72
+ constraint, carrying `login` and `userType` — never the login in its
73
+ message, which the conformance suite checks.
74
+ - `updateUser` writes **only if the stored version is exactly `ifVersion`**,
75
+ and never replaces a record whole: a field the patch does not name is left
76
+ as it is. It rejects with `NotFoundError` for an unknown id — the one
77
+ absence on the port that throws, because an update always follows a read —
78
+ and `StoreConflict('version', …)` when the version moved.
79
+ - `listUsers` pages in ascending id order; `after` is the last id of the
80
+ previous page, already checked by the core. `UserPageRequest` extends
81
+ `UserFilter` (`{ type, loginPrefix? }`): with a `loginPrefix`, list only the
82
+ users holding **a login that starts with it**, byte for byte. The core has
83
+ normalised it already (an e-mail is lowercased and trimmed), so fold no case.
84
+ It is **text, not a pattern**: escape `.`, `+`, `%`, `_` and `\` for your
85
+ database, and answer it from the unique login index, never a scan —
86
+ MongoDB with an anchored `$regex` on `{ type, logins }`, PostgreSQL with
87
+ `like 'prefix%'` on a `collate "C"` `(type, login)` key. The conformance
88
+ suite lists with `.`, `+`, `%`, `_`, `\` and `*` in the prefix.
89
+ - `UserFilter.namePrefix` does the same for **`UserRecord.nameKey`**, the
90
+ display name the core already folded (NFKC, lowercase, white space
91
+ collapsed, 128 characters): keep the users whose `nameKey` starts with it,
92
+ byte for byte, **and** the `loginPrefix` when both are given. Store
93
+ `nameKey` verbatim and absent when the record has none (a patch's
94
+ `nameKey: null` removes it, an absent one leaves it); index `(type,
95
+ nameKey)` — MongoDB `{ type, nameKey }` with an anchored `$regex`,
96
+ PostgreSQL a nullable `collate "C"` column with `like 'prefix%'`. A store
97
+ that ignores `namePrefix` lists everyone, so the conformance cases
98
+ `users.namePrefix`, `users.namePrefix.literal` and `users.nameKeySlot`
99
+ check it.
100
+ - `countUsers` answers how many users `listUsers` would walk with the same
101
+ filter, exactly, `0` for none.
102
+
103
+ #### `UserStore.findUsers` (optional)
104
+
105
+ What `findMany` asks for: the users holding these ids, **in one query**.
106
+ Leave it out and nothing breaks — `findMany` reads with `findUser` instead,
107
+ ten at a time — so implement it when your database can answer a list of ids
108
+ in one round trip.
109
+
110
+ - **Whatever their type**, as `findUser`: the core keeps the type's own users,
111
+ and puts them back in its caller's order. Answer them **in any order**.
112
+ - **An id nobody holds is left out.** An absence is a shorter list — `[]` when
113
+ nobody holds any — never `null`, never a rejection.
114
+ - **A failure throws**, as everywhere on the port (rule 2). Answering `[]` for
115
+ an outage tells the application those users do not exist.
116
+ - The core calls it with **1 to 100 distinct, well-formed ids**, never an
117
+ empty list, and reads a longer list in several calls one after another — no
118
+ `IN` grows past 100.
119
+
120
+ ```ts
121
+ import type { UserStore } from '@softistx/janus';
122
+
123
+ // PostgreSQL through Drizzle — @softistx/janus-drizzle's, in one statement
124
+ findUsers: async (ids) =>
125
+ (await db.select().from(users).where(inArray(users.id, [...ids]))).map(toUser),
126
+
127
+ // MongoDB — @softistx/janus-mongo's, in one query
128
+ findUsers: async (ids) =>
129
+ (await collection.find({ _id: { $in: [...ids] } }).toArray()).map(toUser),
130
+ ```
131
+
132
+ `janus()` reads its presence once (`StoreCapabilities.findUsers`), and refuses
133
+ a `findUsers` that is there but not a function with a `TypeError`: a value in
134
+ the wrong place is a wiring mistake, not an absent capability. The suite's
135
+ `users.findUsers`, `users.findUsersNone` and `outage.findUsers` cases check it,
136
+ and are skipped with their reason for a store that leaves it out.
137
+
138
+ #### A user's password and second factor
139
+
140
+ Both are one field of `UserRecord`, `null` when the user has none, and a
141
+ patch treats both alike: **absent keeps it, `null` removes it, a value
142
+ replaces it whole**.
143
+
144
+ ```ts
145
+ interface UserRecord {
146
+ // …id, type, schemaVersion, active, fields, logins…
147
+ readonly password: { readonly hash: string; readonly updatedAt: Date } | null;
148
+ readonly secondFactor: {
149
+ readonly method: 'totp';
150
+ readonly secret: string; // opaque: store it byte for byte
151
+ readonly confirmedAt: Date | null; // null while enrolment waits for a first code
152
+ readonly lastStep: number | null; // the time step of the last code accepted
153
+ readonly recoveryCodes: readonly string[]; // opaque keyed hashes, in order; [] for none
154
+ } | null;
155
+ // …emailVerifiedAt, version, createdAt, updatedAt
156
+ }
157
+ ```
158
+
159
+ `secret` is **opaque to a store**: the core seals it with a key the
160
+ application holds — AES-256-GCM, written `v1.<key id>.<iv>.<ciphertext>` —
161
+ before a store sees it, so a dump of the users cannot produce a code. Keep it
162
+ like a password hash — byte for byte, no parsing, no trimming. The core
163
+ rewrites it, sealed under another key, when the application
164
+ [rotates its keys](second-factor.md#rotating-the-keys). Store
165
+ the second factor whole: a method without a secret, or a `lastStep` or
166
+ recovery codes without a method, is a record the core never writes.
167
+
168
+ `recoveryCodes` holds the hashes of the codes a user can sign in with when
169
+ their phone is gone — **keyed hashes the core computed, never a code**, each
170
+ as opaque as `secret`. Keep the array **in order** and byte for byte; a patch
171
+ that names `secondFactor` replaces it whole, codes included, and
172
+ `secondFactor: null` removes them with the factor. `[]` is a factor with no
173
+ codes left, never an absence of factor. **Every adapter must round-trip it**:
174
+ a store that drops the field answers a record with no codes, and a user who
175
+ lost their phone is locked out. A row or document written before the field
176
+ existed should read as `[]` — nullable, or optional, rather than a migration
177
+ that rewrites every user.
178
+
179
+ ```ts
180
+ import type { UserPatch } from '@softistx/janus';
181
+
182
+ const keep: UserPatch = { updatedAt: new Date() }; // secondFactor untouched
183
+ const remove: UserPatch = { updatedAt: new Date(), secondFactor: null };
184
+ ```
185
+
186
+ An adapter that stored users before this field existed reads its absence as
187
+ `null`, never `undefined` (rule 2): a user with no second factor holds `null`.
188
+
189
+ #### A user's avatar
190
+
191
+ `UserRecord.avatar` is `{ id, updatedAt } | null` and follows the same patch
192
+ rule: absent keeps it, `null` removes it, a value replaces it whole. `id` is
193
+ opaque to a store — the application's key for the image — so keep it byte for
194
+ byte, and keep `updatedAt` to the millisecond. A user stored before the slot
195
+ existed reads as `null`, never `undefined`. `avatar.set` and `avatar.remove`
196
+ write it.
197
+
198
+ ### `SessionStore` and `TokenStore`
199
+
200
+ ```ts
201
+ interface SessionStore {
202
+ insertSession(record: SessionRecord): Promise<void>;
203
+ findSessionByTokenHash(tokenHash: string): Promise<SessionRecord | null>;
204
+ extendSession(id: SessionId, expiresAt: Date): Promise<SessionRecord | null>; // null once revoked
205
+ reauthenticateSession(id: SessionId, at: Date, amr?: readonly string[]): Promise<SessionRecord | null>; // authenticatedAt, and amr when given; null once revoked
206
+ revokeSession(id: SessionId, at: Date): Promise<boolean>;
207
+ revokeUserSessions(
208
+ userId: Id,
209
+ at: Date,
210
+ except?: SessionId,
211
+ issuedBefore?: Date, // only sessions with createdAt < issuedBefore
212
+ ): Promise<number>;
213
+ deleteUserSessions(userId: Id): Promise<number>;
214
+ deleteExpiredSessions?(before: Date): Promise<number>; // optional: omit it if the database expires on its own
215
+ }
216
+
217
+ interface TokenStore {
218
+ insertToken(record: TokenRecord): Promise<void>;
219
+ consumeToken(tokenHash: string, kind: TokenKind, at: Date, userId?: Id): Promise<TokenRecord | null>; // userId: only that user's token matches
220
+ countAttempt(tokenHash: string, kind: TokenKind): Promise<TokenRecord | null>;
221
+ spendUserTokens(userId: Id, kind: TokenKind, at: Date, except?: string): Promise<number>; // the unspent ones, but except
222
+ deleteUserTokens(userId: Id): Promise<number>;
223
+ deleteExpiredTokens?(before: Date): Promise<number>; // optional: omit it if the database expires on its own
224
+ }
225
+ ```
226
+
227
+ **Upgrading a store.** `issuedBefore` is a fourth, optional argument. A store
228
+ still on the three-argument signature compiles, and ends **every** session of
229
+ the user once `signOutEverywhere` passes a cut-off. Honour
230
+ `createdAt < issuedBefore` (strictly: a session created at the cut-off
231
+ stands), run `describeJanusStores` (`sessions.revokeUserIssuedBefore`), and
232
+ upgrade the adapters together with the core.
233
+
234
+ **Listing sessions.** `SessionRecord` has optional `device` and `lastUsedAt`,
235
+ `extendSession` takes an optional third argument `lastUsedAt`, and the
236
+ optional `listUserSessions(userId, now)` answers the user's sessions that are
237
+ not revoked and expire after `now`, served by an index on the user.
238
+ A store that does not implement it keeps working: `auth.sessions.list` and
239
+ `revoke` throw `UNSUPPORTED`. Run `describeJanusStores`
240
+ (`sessions.listUser`, `sessions.extendLastUsed`).
241
+
242
+ **Upgrading a store, again.** `userId` is a fourth, optional argument of
243
+ `consumeToken`. A store still on the three-argument signature compiles, and
244
+ spends a token whichever user a `verifyEmail.confirm(token, { user })` names.
245
+ Honour it: put `userId` in the condition beside the hash and the kind, run
246
+ `describeJanusStores` (`tokens.consumeBound`), and upgrade the adapters
247
+ together with the core. The core refuses what such a store answers
248
+ (`TOKEN_UNKNOWN`) and emits the `JANUS_TOKEN_STORE_IGNORES_USER_ID` warning
249
+ once, but the store has already spent the token.
250
+
251
+ `consumeToken` is the most important method on the port: it spends the token
252
+ and answers it **as it was before the call**, in **one conditional write**.
253
+ Twenty concurrent calls must produce exactly one answer with `spentAt: null`;
254
+ in MongoDB that is one `findOneAndUpdate` returning the document before the
255
+ update. A read followed by a write lets two requests redeem one reset token.
256
+
257
+ When `userId` is given it is part of that same write: a token of another user,
258
+ or `userId` being `''`, answers `null` and is **not spent**. A check made after
259
+ the spend would burn the rightful owner's link.
260
+
261
+ A token is its hash, never its secret, and what it is for:
262
+
263
+ ```ts
264
+ type TokenKind = 'verifyEmail' | 'resetPassword' | 'secondFactor' | 'signInCode' | 'magicLink' | 'stepUp' | 'changeEmail' | 'socialFlow' | 'passkeyRegistration';
265
+
266
+ interface TokenRecord {
267
+ readonly tokenHash: string;
268
+ readonly kind: TokenKind;
269
+ readonly userId: Id;
270
+ readonly address: string; // '' for a secondFactor challenge: nothing was sent; the NEW address for changeEmail
271
+ readonly amr?: readonly string[]; // a secondFactor challenge's first-factor methods; omit when none, a store may drop it
272
+ readonly codeHash: string | null; // an e-mailed code, hashed — signInCode, or stepUp by e-mail; changeEmail: the address it replaces, keyed; else null
273
+ readonly attempts: number; // 0 at insertion
274
+ readonly expiresAt: Date;
275
+ readonly spentAt: Date | null;
276
+ readonly createdAt: Date;
277
+ }
278
+ ```
279
+
280
+ A token redeemed for another kind is unknown: every method that takes a
281
+ `kind` matches on it. A `stepUp` token is a signed-in user's confirmation of
282
+ a sensitive action; kept apart from `signInCode`, a sign-in code never
283
+ confirms an action, nor an action's code signs anyone in. A `magicLink`
284
+ token is a sign-in link's, new in 0.15, kept apart from `signInCode` the same
285
+ way: a sign-in code's challenge is handed to whoever asked for it, and a
286
+ store that redeemed it as a link would sign them in with no code —
287
+ `tokens.magicLinkKind` holds that it does not. A `changeEmail` token is the
288
+ link sent to a user's new address; its `address` is that new address, not the
289
+ one the user holds, and its `codeHash` is the address it replaces, keyed by the
290
+ token's secret — a store keeps both byte for byte. It is kept apart from
291
+ `verifyEmail` the same way: redeemed as a verification it would mark the new
292
+ address verified without changing it, and `tokens.changeEmailKind` holds that
293
+ it is not. A store that lists the kinds — a `CHECK`, an enum in a validator —
294
+ lists `stepUp`, `magicLink`, `changeEmail`, `socialFlow` and
295
+ `passkeyRegistration` too — **before** the version that writes a new kind is
296
+ deployed — which `tokens.everyKind` proves. A `passkeyRegistration` token is
297
+ the challenge of one passkey registration in progress, kept apart so no other
298
+ token completes a registration. A `socialFlow` token (new in 0.38) is the state of
299
+ a social sign-in or link in progress: its `address` is `''` and its `codeHash`
300
+ the keyed hash binding the flow cookie, and `tokens.socialFlowKind` holds that
301
+ it is kept apart from a verification. A `secondFactor` token is the challenge `signIn`
302
+ answers — or the count of a user's attempts at `regenerateRecoveryCodes`,
303
+ a token of the same kind whose secret nobody is given, never redeemed and
304
+ only counted — and its `address` is `''`: a column or a validator that refuses an
305
+ empty string refuses every sign-in with a code. `codeHash` and `attempts` round-trip like every other
306
+ field. An adapter whose stored tokens predate them reads them as `null` and
307
+ `0`, as the three published adapters do, so no data migration is needed for
308
+ them.
309
+
310
+ Expiry is the core's decision: a read answers a stored session verbatim,
311
+ lapsed or revoked, and never a record it has changed. A store with its own
312
+ expiry — a TTL index, a Redis key TTL — may drop a lapsed session or token
313
+ before anyone asks: reads then answer `null`, and `deleteUserSessions` does
314
+ not count it. The conformance suite accepts both.
315
+
316
+ ### `SessionStore.reauthenticateSession`
317
+
318
+ Moves `authenticatedAt` to `at` — **only while the session is not revoked**
319
+ — and, when `amr` is given, **replaces** `SessionRecord.amr` (an optional
320
+ `string[]`, the RFC 8176 methods proved; the core passes the union, and a store
321
+ writes and reads it back like any field, `[]` for a session without one), in
322
+ the same write. It answers the record as written, every other field as it was. It is
323
+ what a step-up calls once a signed-in user proved again who they are, so
324
+ that "signed in less than ten minutes ago" is one field of the session
325
+ `authenticate` already read. `null` for no session, or a revoked one: a
326
+ confirmation racing a revocation must never bring the session back, so the
327
+ condition is in the write — the same one `extendSession` has:
328
+
329
+ ```ts
330
+ import type { SessionStore } from '@softistx/janus';
331
+
332
+ export const reauthenticateSession: SessionStore['reauthenticateSession'] = async (id, at, amr) => {
333
+ const written = await sessions.findOneAndUpdate(
334
+ { _id: id, revokedAt: null },
335
+ { $set: amr === undefined ? { authenticatedAt: at } : { authenticatedAt: at, amr: [...amr] } },
336
+ { returnDocument: 'after' },
337
+ );
338
+ return written === null ? null : toSession(written);
339
+ };
340
+ ```
341
+
342
+ In SQL, `update … set authenticated_at = $2 [, amr = $3] where id = $1 and revoked_at is
343
+ null returning *`; in Redis, one Lua script that checks `revokedAt` is empty
344
+ before its `HSET`s. The conformance case `sessions.amr` checks the round trip. The expiry does not move, so neither does a TTL. It has
345
+ its own outage case, and `sessions.reauthenticateRace` races it against
346
+ `revokeSession`.
347
+
348
+ ### `TokenStore.countAttempt`
349
+
350
+ Counts one attempt at a code against a token, and answers the token **as it
351
+ is after the call** — what bounds the attempts at a six-digit code:
352
+
353
+ | The stored token | Written | Answered |
354
+ | --- | --- | --- |
355
+ | unspent, of this `kind` | `attempts + 1` | the token, with the new count |
356
+ | spent, of this `kind` | nothing | the token as it is |
357
+ | another `kind`, or no token with this hash | nothing | `null` |
358
+
359
+ Like `consumeToken`, it is **one conditional write**, never a read followed by
360
+ a write: twenty concurrent calls answer the counts 1 to 20, each once. A count
361
+ two attempts both read is an attempt for free. Whether the count is past the
362
+ limit, and whether the code matches, is the core's decision after the call;
363
+ spending the token stays `consumeToken`'s.
364
+
365
+ A **lapsed** token is counted all the same, or answered `null` by a store that
366
+ has already dropped it (a TTL index, a Redis key TTL). Do not compare
367
+ `expiresAt` in the store: as for `consumeToken`, the core compares it after
368
+ the call.
369
+
370
+ A **spent** token is kept, and answered as spent, **until its `expiresAt`**.
371
+ Drop it sooner — on `consumeToken`, on `spendUserTokens` — and the next
372
+ `countAttempt` answers `null`: the core inserts a fresh token, and a count of
373
+ `regenerateRecoveryCodes`' attempts starts over. A TTL on `expiresAt`, as the
374
+ published adapters set, keeps it exactly as long as needed.
375
+
376
+ In MongoDB, one `findOneAndUpdate` answering the document after it, then a
377
+ plain read for the spent case:
378
+
379
+ ```ts
380
+ import type { TokenStore } from '@softistx/janus';
381
+
382
+ // tokens: your collection; toToken: your document → TokenRecord
383
+ export const countAttempt: TokenStore['countAttempt'] = async (tokenHash, kind) => {
384
+ const after = await tokens.findOneAndUpdate(
385
+ { _id: tokenHash, kind, spentAt: null },
386
+ { $inc: { attempts: 1 } },
387
+ { returnDocument: 'after' },
388
+ );
389
+ if (after !== null) return toToken(after);
390
+ const spent = await tokens.findOne({ _id: tokenHash, kind }); // written nothing
391
+ return spent === null ? null : toToken(spent);
392
+ };
393
+ ```
394
+
395
+ In SQL, `update … set attempts = attempts + 1 where token_hash = $1 and kind =
396
+ $2 and spent_at is null returning *`, then the same plain read. In Redis, one
397
+ Lua script: `HINCRBY` only when `spentAt` is empty, then `HGETALL`. Wrap the
398
+ driver's error in `StoreFailure` as in [the six rules](#the-six-rules):
399
+ `countAttempt` has its own outage case.
400
+
401
+ ### `TokenStore.spendUserTokens`
402
+
403
+ Spends every **unspent** token of one user and one `kind` at `at` — but the
404
+ one whose hash is `except`, when given — and answers how many it spent. The
405
+ core calls it right after issuing a sign-in code, with that code's hash as
406
+ `except`, so only the last code sent works — and so after issuing a sign-in
407
+ link, a step-up or a reset link; and after writing a password, for the user's
408
+ `resetPassword` links and `secondFactor` challenges:
409
+
410
+ | The stored token | Written | Counted |
411
+ | --- | --- | --- |
412
+ | unspent, of this user and this `kind` | `spentAt: at` | yes |
413
+ | already spent | nothing — `spentAt` never changes once set | no |
414
+ | another `kind`, another user, or the one named by `except` | nothing | no |
415
+ | none at all | nothing | `0`, an absence — never a failure |
416
+
417
+ Each token is spent by a **conditional write**, as `consumeToken` spends one:
418
+ a token that a racing `consumeToken` spends at the same moment is counted by
419
+ exactly one of the two calls, never both. An expired token is spent all the
420
+ same, or not counted by a store that already dropped it.
421
+
422
+ In MongoDB, one `updateMany` through the `userId` index `deleteUserTokens`
423
+ already reads:
424
+
425
+ ```ts
426
+ import type { TokenStore } from '@softistx/janus';
427
+
428
+ export const spendUserTokens: TokenStore['spendUserTokens'] = async (userId, kind, at, except) => {
429
+ const result = await tokens.updateMany(
430
+ { userId, kind, spentAt: null, ...(except === undefined ? {} : { _id: { $ne: except } }) },
431
+ { $set: { spentAt: at } },
432
+ );
433
+ return result.modifiedCount;
434
+ };
435
+ ```
436
+
437
+ In SQL, `update … set spent_at = $3 where user_id = $1 and kind = $2 and
438
+ spent_at is null returning token_hash`, with `and token_hash <> $4` added
439
+ only when `except` is given — bound to `NULL`, `<>` matches no row — answering the row count: PostgreSQL
440
+ re-checks `spent_at is null` on a row a racing redemption just committed. In
441
+ Redis, one Lua script over the user's set of tokens, `HSET spentAt` on each
442
+ of the right `kind` whose `spentAt` is empty, skipping the one named by
443
+ `except`. `spendUserTokens` has its own
444
+ outage case.
445
+
446
+ ### `TokenStore.deleteExpiredTokens` (optional)
447
+
448
+ What `collectExpired()` asks for, beside `SessionStore.deleteExpiredSessions`:
449
+ **delete every token whose `expiresAt` is at or before `before`**, and answer
450
+ how many. Leave it out when your database expires records on its own (a TTL
451
+ index, a key TTL) — nothing breaks, the core compares `expiresAt` on every
452
+ redemption — and implement it when it does not, or the rows pile up.
453
+
454
+ | The stored token | Written |
455
+ | --- | --- |
456
+ | `expiresAt` at or before `before`, spent or not, of any kind and any user | deleted, and counted |
457
+ | `expiresAt` later than `before`, spent or not | **kept** |
458
+ | none at all | `0`, an absence — never a failure |
459
+
460
+ **Never delete a token whose `expiresAt` is later, spent or not**: a spent
461
+ token is kept, answered as spent, until it lapses, or a count would start
462
+ over. That includes the throttles' counts — ordinary `secondFactor` tokens
463
+ under a keyed-hash user id, which `deleteUserTokens` never reaches and this
464
+ method is the only thing to collect. The core calls it with `clock.now()`, no
465
+ margin: a link collected answers `TOKEN_UNKNOWN`.
466
+
467
+ ```ts
468
+ import type { TokenStore } from '@softistx/janus';
469
+
470
+ // PostgreSQL through Drizzle — one statement, over an index on expires_at
471
+ deleteExpiredTokens: async (before) =>
472
+ (await db.delete(tokens).where(lte(tokens.expiresAt, before)).returning({ tokenHash: tokens.tokenHash })).length,
473
+ ```
474
+
475
+ `janus()` reads its presence once (`StoreCapabilities.collectExpiredTokens`),
476
+ and refuses a `deleteExpiredTokens` that is there but not a function with a
477
+ `TypeError`. The suite's `tokens.deleteExpired` and `outage.deleteExpiredTokens`
478
+ cases check it, and are skipped with their reason for a store that leaves it
479
+ out. A failure throws, as everywhere on the port.
480
+
481
+ ### `RelationStore`
482
+
483
+ ```ts
484
+ interface RelationStore {
485
+ write(changes: { add?: readonly RelationTuple[]; remove?: readonly RelationTuple[] }): Promise<void>;
486
+ has(tuple: RelationTuple): Promise<boolean>;
487
+ findSubjectSets(object: Entity, relation: string): Promise<readonly SubjectSet[]>;
488
+ findEntities(object: Entity, relation: string): Promise<readonly Entity[]>;
489
+ findHolders?(request: HolderPageRequest): Promise<CursorPage<Entity>>;
490
+ findObjects(page: ObjectPageRequest): Promise<CursorPage<string>>;
491
+ deleteEntity(entity: Entity): Promise<number>;
492
+ }
493
+ ```
494
+
495
+ One-hop questions about stored tuples, never a permission: the traversal is
496
+ the core's. `write` is **all or nothing**, removals first, and idempotent.
497
+ `findHolders` is **optional**: the page `access.holders()` reads, of the single
498
+ entities holding a relation on an object, ordered by type then id, after the
499
+ cursor `holderCursor` minted (`readHolderCursor` refuses any other), and whose
500
+ id contains `search` — a literal, ignoring case. A store without it is served by
501
+ the core from `findEntities`, in memory; an adapter over a database implements
502
+ it. `pageOfHolders` is the reference. The relation suite checks it when present.
503
+ `findObjects` is the reverse index `list()` walks, in ascending id order.
504
+ `deleteEntity` removes every tuple naming the entity as object, as subject,
505
+ and as the entity of a subject set.
506
+
507
+ ### `SocialLinkStore` (the optional `socialLinks` slot)
508
+
509
+ New in 0.38. A slot of `JanusStores`, but **optional**: an adapter that does not
510
+ write it still compiles, and `assertStores` checks it only when it is there.
511
+ A `SocialLinkRecord` is `{ provider, accountId, userId, email, createdAt }`;
512
+ `(provider, accountId)` is the key, compared byte for byte (`Abc` and `abc` are
513
+ two accounts — a `collate "C"` column, a binary index). `insertSocialLink` is
514
+ one atomic insert-if-absent and **answers the record the store holds for the
515
+ pair**: its own when it wrote, the holder's when the pair was already linked
516
+ (then nothing is written; the core reads `userId` to learn it lost). Never a
517
+ read followed by a write: twenty concurrent inserts leave one record.
518
+ `findSocialLink` answers the record or `null`; `listUserSocialLinks` a list,
519
+ `[]` for none; `deleteSocialLink(userId, provider, accountId)` is conditional on
520
+ the owner and answers whether it deleted; `deleteUserSocialLinks` answers a
521
+ count, and is what deleting a user calls. The suite's `socialLinks` cases and
522
+ five outage cases run when the harness opens stores with the slot.
523
+ `createMemoryStores()` is the reference.
524
+
525
+ ### `PasskeyStore` (the optional `passkeys` slot)
526
+
527
+ A slot of `JanusStores`, **optional** like `socialLinks`: an adapter that does
528
+ not write it still compiles, and `assertStores` checks it only when it is
529
+ there. A `PasskeyRecord` is `{ credentialId, userId, publicKey, counter,
530
+ transports, aaguid, backupEligible, backedUp, name, createdAt, lastUsedAt }`.
531
+ `credentialId` (base64url) is the key, compared byte for byte, and `publicKey`
532
+ (COSE, base64url) must round-trip byte for byte: a re-encoded key no longer
533
+ verifies a signature. `insertPasskey` is one atomic insert-if-absent and
534
+ **answers the record the store holds for the credential**: its own when it
535
+ wrote, the holder's otherwise (nothing is written then; the core reads `userId`
536
+ to learn it lost) — twenty concurrent inserts leave one record.
537
+ `findPasskey` answers the record or `null`; `listUserPasskeys` a list, `[]` for
538
+ none. `recordPasskeyUse(userId, credentialId, { counter, backedUp, lastUsedAt },
539
+ ifCounter)` is one **conditional** write: it sets the three fields and answers
540
+ the updated record only if the passkey belongs to `userId` and its stored
541
+ counter is still `ifCounter`, and answers `null` otherwise, so two concurrent
542
+ uses that read the same counter cannot both pass. `renamePasskey(userId,
543
+ credentialId, name)` and `deletePasskey(userId, credentialId)` are conditional
544
+ on the owner and answer `true` or `false`. `deleteUserPasskeys` answers a
545
+ count, and is what deleting a user calls. The suite's twelve `passkeys` cases
546
+ and seven outage cases run when the harness opens stores with the slot.
547
+ `createMemoryStores()` is the reference.
548
+
549
+ ### `ApiKeyStore` (optional)
550
+
551
+ A port of its own, not a slot of `JanusStores`: an adapter that does not
552
+ implement it breaks nothing. `insertApiKey` is idempotent by id; `findApiKey`
553
+ answers a record verbatim or `null`; `listUserApiKeys(userId, { first, after })`
554
+ pages in id order (creation order); `touchApiKey(id, at, staleBefore)` is a conditional write
555
+ that answers whether it wrote (one winner among concurrent calls, never on a
556
+ revoked key); `revokeApiKey` keeps the first `revokedAt`;
557
+ `revokeUserApiKeys` and `deleteUserApiKeys` answer counts; `deleteExpiredApiKeys`
558
+ is optional. Two optional capabilities are pairs (their argument types are
559
+ `ApiKeyBound` and `ApiKeyExpiringRequest`): `bound` —
560
+ `listBoundApiKeys(bound, { first, after })` (any user's keys with that
561
+ `{ type, id }`, in id order) and `revokeBoundApiKeys(userId, bound, at)` (a
562
+ count), and a store with it keeps `scopes` and `bound` on the record verbatim,
563
+ absent when unset — and `expiryNotice` — `listExpiringApiKeys({ now, before,
564
+ first, after })` (not revoked, `now < expiresAt <= before`, no
565
+ `expiryNotifiedAt`) and `markApiKeyExpiryNotified(id, at)`, a conditional
566
+ write that answers `true` only for the call that set it, so of concurrent calls
567
+ exactly one wins. Half a pair is refused. A third, single-method capability
568
+ rides on `bound`: `userBound`, `listUserBoundApiKeys(userId, bound | null,
569
+ { first, after })` — one user's keys bound to `bound` (same `type` and `id`),
570
+ or unbound for `null`, every state, in id order — which makes
571
+ `apiKeys.list(user, { bound })` one read. A store without it still serves
572
+ that call: the core reads `listUserApiKeys` 100 at a time and filters. A store
573
+ with it must have `bound`, else `assertApiKeyStore` refuses it. The types follow the split:
574
+ `ApiKeyStoreBase` holds the required methods, `ApiKeyBoundMethods`,
575
+ `ApiKeyUserBoundMethods` and `ApiKeyExpiryNoticeMethods` each capability, and
576
+ `ApiKeyStore` is the base with all of them optional. An adapter that has a
577
+ capability names its type too, so half of it fails to compile:
578
+
579
+ ```ts
580
+ import type {
581
+ ApiKeyBoundMethods,
582
+ ApiKeyStore,
583
+ ApiKeyUserBoundMethods,
584
+ } from '@softistx/janus';
585
+
586
+ class MyApiKeys
587
+ implements ApiKeyStore, ApiKeyBoundMethods, ApiKeyUserBoundMethods
588
+ {
589
+ // … the required methods, then listBoundApiKeys, revokeBoundApiKeys
590
+ // and listUserBoundApiKeys
591
+ }
592
+ ```
593
+
594
+ `assertApiKeyStore(store, where)` checks the shape at run time,
595
+ answers the capabilities it found (an `ApiKeyStoreCapabilities`,
596
+ `{ collectExpired, bound, userBound, expiryNotice }`), and
597
+ `createMemoryApiKeys()` is the reference store. Its suite is
598
+ `describeApiKeyStores`, with `referenceApiKeyHarness()` as the example.
599
+
600
+ ### `InvitationStore` (optional)
601
+
602
+ A port of its own, not a slot of `JanusStores`: an adapter that does not
603
+ implement it breaks nothing. It keeps **one pending invitation per scope and
604
+ address**, as a constraint (a partial unique index), never a read then a write:
605
+ `insertInvitation` answers `false` when another pending one holds the place
606
+ (atomically: of concurrent inserts for one scope and address exactly one answers
607
+ `true`, held by the conformance case `invitations.insert.one-pending.concurrent`;
608
+ and is idempotent by id); `findInvitation` and `findInvitationByCodeHash`
609
+ answer a record verbatim, lapsed or not, or `null` (the `codeHash` is kept verbatim and unique: `sha256` hex for an issued invitation, `import:` and 64 hex digits for one imported with `importHistory`); `listScopeInvitations`
610
+ pages one scope in id order (newest first for `order: 'desc'`, with `after`
611
+ then meaning smaller ids), and optionally only the records of one `role` or
612
+ `ref`; `findPendingInvitation(scope, email)` is optional (without it the core
613
+ pages through the scope's pending invitations, one read per hundred, to find an
614
+ address) and answers the pending invitation of that exact address in that scope,
615
+ lapsed or not, or `null`: an index on `(scope, email)` where `status = 'pending'`
616
+ serves it, and the one-pending-per-address constraint already is that index;
617
+ `countScopeInvitations(scope, { status, role, ref, lapsed })` is optional (the
618
+ core pages through `listScopeInvitations` without it) and counts the matches;
619
+ the record's `ref` is stored as given and indexed with the scope (an adapter
620
+ that predates it reads `null`); the record's `type`, the user type the
621
+ invitation is for, is stored as given, `null` included, and **an adapter that
622
+ drops it breaks an instance with several invitation types** (`issue` reads the
623
+ record back once and throws a `TypeError` if `type` did not come back); a
624
+ record with no `type` reads as the first type listed in `invitations.type`;
625
+ `countPendingInvitations(scope, now)` counts the
626
+ ones not lapsed; `updateInvitation(id, ifVersion, patch)` is the conditional
627
+ write that makes a claim (of concurrent claims exactly one wins; the others get
628
+ `StoreConflict('version')`, and a patch that would make a second one pending
629
+ gets `StoreConflict('pending')`); `deleteScopeInvitations(scope)` answers a
630
+ count; `deleteExpiredInvitations` is optional. A failure is a `StoreFailure`
631
+ with `slot: 'invitations'`. `assertInvitationStore(store, where)` checks the shape and
632
+ `createMemoryInvitations()` is the reference store. Its suite is
633
+ `describeInvitationStores`, from `@softistx/janus/conformance`, with
634
+ `referenceInvitationHarness()` as the example. The flows that use
635
+ it are in the [invitations guide](invitations.md).
636
+
637
+ A custom `InvitationStore` must honour `role`, `ref` and `order` in
638
+ `listScopeInvitations` and in `countScopeInvitations` (when it implements it):
639
+ an adapter that ignores a filter lists or counts invitations the caller did not
640
+ ask for. The conformance cases `invitations.list-filters` and
641
+ `invitations.count` check it. `invitations.find-pending` checks
642
+ `findPendingInvitation` (skipped when absent).
643
+
644
+ It must also honour the `lapsed` field of the page request and of the filter, an
645
+ `InvitationLapsedFilter` (`{ mode: 'exclude' | 'only', now }`) or `null`/absent
646
+ for none, in both: lapsed means stored `pending` with
647
+ `expiresAt <= now`, so `'exclude'` drops those and keeps every other record,
648
+ and `'only'` keeps only those. A store that ignores it lists and counts
649
+ lapsed invitations the caller asked to leave out. The conformance cases
650
+ `invitations.list.lapsed` and `invitations.count.lapsed` check it.
651
+
652
+ ## The six rules
653
+
654
+ Written on the port's types, and checked by the suites:
655
+
656
+ 1. **An absence is `null`. A failure throws.** A method that can find nothing
657
+ answers `null`, `false`, `0` or an empty page; everything else throws,
658
+ preferably `StoreFailure` with the driver's error as `cause`. Never write
659
+ `try { … } catch { return null }` in an implementation.
660
+ 2. **`null`, not `undefined`.** A function that forgot to `return` produces
661
+ `undefined`; `null` has to be written on purpose.
662
+ 3. **Uniqueness is a constraint** — a unique index, never a read followed by a
663
+ write.
664
+ 4. **Bytes round-trip.** No normalising, trimming or retyping. The core
665
+ normalises logins before a store sees them, and never hands a store —
666
+ identity or relation — `\u0000` or a lone surrogate; every other
667
+ character comes back as written.
668
+ 5. **Every method is atomic on its own.** The core opens no transaction; an
669
+ adapter may open one inside a method. And **a read sees every write that
670
+ completed before it** — never a secondary or a read replica: a sign-in
671
+ re-reads the user to see a password written while it ran, and a new
672
+ sign-in code spends the ones issued before it. No suite can check this
673
+ one; a `readPreference: 'secondaryPreferred'` breaks it silently.
674
+ 6. **Schema management is not on the port.** Expose your own `sync`; the core
675
+ never calls it.
676
+
677
+ ```ts
678
+ import { type Id, StoreFailure, type UserRecord, type UserStore } from '@softistx/janus';
679
+
680
+ export const findUser: UserStore['findUser'] = async (id: Id) => {
681
+ let found: UserRecord | undefined;
682
+ try {
683
+ found = await db.users.findOne({ _id: id });
684
+ } catch (cause) {
685
+ throw new StoreFailure('users.findUser: the store could not answer', {
686
+ slot: 'users',
687
+ operation: 'findUser',
688
+ cause,
689
+ });
690
+ }
691
+ return found ?? null; // an absence, written on purpose
692
+ };
693
+ ```
694
+
695
+ An adapter **defines no error class**. It throws `@softistx/janus`'s own
696
+ `StoreFailure`, `StoreConflict` and `NotFoundError`, and declares
697
+ `@softistx/janus` as a **peer dependency**, never a dependency, so there is one
698
+ copy of each class and `instanceof` holds in the application. A cursor it
699
+ cannot read is `invalidCursor(where, cursor)`. Records, patches and page
700
+ requests are exported as types: `UserRecord`, `UserPatch`, `UserPageRequest`,
701
+ `AvatarRecord`, `PasswordRecord`, `SecondFactorRecord`, `SessionRecord`, `TokenRecord`, `TokenKind`, `Json`,
702
+ `JsonObject`, and `ObjectPageRequest`, `RelationChanges` from
703
+ `@softistx/janus/permissions`.
704
+
705
+ `createMemoryStores()` and `createMemoryRelations()` are the reference
706
+ implementations: read them when a rule is unclear. `janus()` runs
707
+ `assertStores` on what it is given, and a partially implemented store is a
708
+ compile error naming the missing method.
709
+
710
+ ## The conformance suites
711
+
712
+ | Suite | Cases | Harness opens |
713
+ | --- | --- | --- |
714
+ | `describeJanusStores({ name, harness, runner?, faults?, skip? })` | 99: users, sessions, tokens, the optional `socialLinks` and `passkeys` slots, and one outage per method whose honest answer can be "nothing" — twenty-nine of them | `{ stores, faults?, close? }` |
715
+ | `describeRelationStores({ name, harness, runner?, faults?, skip? })` | 16: the relation store, ids of edge characters, and one outage per method | `{ store, faults?, close? }` |
716
+ | `describeApiKeyStores({ name, harness, runner?, faults?, skip? })` | the optional `ApiKeyStore`: insert, list, the conditional touch, revoke, delete, and one outage per method; the `bound`, `userBound` and `expiryNotice` cases are skipped, with their reason, for a store without that capability | `{ store, faults?, close? }` |
717
+ | `describeInvitationStores({ name, harness, runner?, faults?, skip? })` | the optional `InvitationStore`: insert and the pending constraint, find by id and by code hash, list, count, the conditional update, delete, and one outage per method | `{ store, faults?, close? }` |
718
+
719
+ `harness.open()` is called **once per case** and must answer fresh, empty
720
+ stores: a case that leaks into the next is the hardest failure to debug.
721
+ `close()` runs after the case, pass or fail.
722
+
723
+ | Option | Type | Default | Effect |
724
+ | --- | --- | --- | --- |
725
+ | `name` | string | — | The suite's title |
726
+ | `harness` | `ConformanceHarness` / `RelationHarness` | — | Opens fresh stores per case |
727
+ | `runner` | `{ describe, it }` | `globalThis` | **Required under `bun test`**: Bun does not put `describe` and `it` on `globalThis`. jest, and vitest with `globals: true`, are found without it |
728
+ | `faults` | boolean | — | Declare `false` up front and the report says so in the suite's title |
729
+ | `skip` | `{ [caseId]: reason }` | `{}` | Skips a case, reported with the reason — never silent |
730
+
731
+ The suites import no test framework and no assertion library.
732
+
733
+ The second factor, the avatar, attempts and a user's tokens spent have their own cases — skip one by its id
734
+ while you work on it, never to ship:
735
+
736
+ | Case | Checks |
737
+ | --- | --- |
738
+ | `users.secondFactorSlot` | round-trip, recovery codes in order and `[]` as a factor with no codes, never as `null`; a patch not naming it keeps it; one naming it replaces the codes whole; `null` removes it, codes included, and a factor written after has none |
739
+ | `users.avatarSlot` | round-trip, the id verbatim and the date to the millisecond; a patch not naming it keeps it; one naming it replaces it whole; `null` removes it |
740
+ | `tokens.countAttempt` | two calls answer `attempts` 1 then 2, `codeHash` as written; `consumeToken` answers the count |
741
+ | `tokens.countAttemptConcurrency` | twenty concurrent calls answer 1 to 20, each once |
742
+ | `tokens.countAttemptRace` | attempts racing one redemption: the counts answered unspent are 1 to the final count, and every answer after the spend carries that final count |
743
+ | `tokens.amr` | a second-factor challenge's optional `amr` read back as written, and absent when none was given |
744
+ | `tokens.challenge` | a second-factor challenge, whose `address` is `''`, kept, counted and spent like any token |
745
+ | `tokens.countAttemptSpent` | a spent token answered unchanged; another kind and an unknown hash answer `null` and count nothing |
746
+ | `outage.countAttempt` | a store that cannot answer rejects, never `null` |
747
+ | `tokens.spendUserTokens` | spends the unspent tokens of one user and kind at `at`, keeping their attempts, and counts them; a spent token keeps its `spentAt`; another kind and another user are untouched; `0` for none |
748
+ | `tokens.spendUserTokensExcept` | spares the token named by `except`, and spends the user's others of that kind |
749
+ | `tokens.spendUserTokensRace` | racing one `consumeToken`, ten times over: exactly one of the two spends the token |
750
+ | `outage.spendUserTokens` | a store that cannot answer rejects, never `0` |
751
+
752
+ ### `faults`: prove the outage invariant
753
+
754
+ `faults` is optional, and **its absence is reported, never passed over**:
755
+ without it the outage cases are skipped with the reason *"faults not provided:
756
+ the outage invariant is not proven for this adapter"*.
757
+
758
+ ```ts
759
+ import type { StoreFaults } from '@softistx/janus/conformance';
760
+
761
+ const faults: StoreFaults = {
762
+ async fail(slot, method) {
763
+ await database.failNext(method); // make the DATABASE fail this call
764
+ },
765
+ };
766
+ ```
767
+
768
+ Make the database fail the way it really fails — for MongoDB, the
769
+ `failCommand` fail point with code 91 (`ShutdownInProgress`). A wrapper that
770
+ throws in front of your adapter proves the wrapper, not the adapter's
771
+ translation of a driver error. Fail **only the method named**: the write
772
+ outage cases read the store back afterwards, to prove a rejected write changed
773
+ nothing.
774
+
775
+ The relation suite's `faults` is `{ fail(method) }`, with no slot:
776
+
777
+ ```ts
778
+ import { describeRelationStores } from '@softistx/janus/conformance';
779
+
780
+ describeRelationStores({
781
+ name: 'my adapter',
782
+ runner: { describe, it },
783
+ harness: {
784
+ async open() {
785
+ const database = await freshDatabase();
786
+ return {
787
+ store: myRelations(database),
788
+ faults: { fail: (method) => database.failNext(method) },
789
+ close: () => database.drop(),
790
+ };
791
+ },
792
+ },
793
+ });
794
+ ```
795
+
796
+ ### Skipping a case, and declaring no faults
797
+
798
+ ```ts
799
+ describeJanusStores({
800
+ name: 'my adapter',
801
+ runner: { describe, it },
802
+ faults: false,
803
+ skip: { 'users.omission': 'not yet: tracked in the issue tracker' },
804
+ harness: {
805
+ async open() {
806
+ const database = await freshDatabase();
807
+ return { stores: myStores(database), close: () => database.drop() };
808
+ },
809
+ },
810
+ });
811
+ ```
812
+
813
+ A skipped case still appears in the run, with its reason in its name. A case
814
+ that cannot run on the stores it was given — an outage case with no `faults`,
815
+ `sessions.deleteExpired` on a store without `deleteExpiredSessions`,
816
+ `tokens.deleteExpired` on one without `deleteExpiredTokens`, a `findUsers`
817
+ case on a store without `findUsers` — passes, and emits a
818
+ `JANUS_CONFORMANCE_SKIPPED` warning with the reason. A case's `needs` says what
819
+ it cannot run without — one `CaseNeed` or a list: `outage.findUsers` needs
820
+ `['faults', 'findUsers']`, and is skipped for whichever is missing, `faults`
821
+ named first.
822
+ The API key cases do the same with `ApiKeyNeed` (`'faults'`, `'bound'`,
823
+ `'userBound'`, `'expiryNotice'`): `outage.listBoundApiKeys` needs `['faults', 'bound']`, and
824
+ a store without the `bound` capability skips the `apiKeys.bound.*` cases.
825
+
826
+ ### Without a test runner
827
+
828
+ The cases are data, and `runCase` runs one against a harness:
829
+
830
+ ```ts
831
+ import { allCases, referenceHarness, runCase } from '@softistx/janus/conformance';
832
+
833
+ for (const conformanceCase of allCases) {
834
+ const outcome = await runCase(conformanceCase, referenceHarness());
835
+ console.log(conformanceCase.id, 'skipped' in outcome ? `skipped: ${outcome.skipped}` : 'passed');
836
+ }
837
+ ```
838
+
839
+ | Export | What it is |
840
+ | --- | --- |
841
+ | `allCases`, `userStoreCases`, `sessionStoreCases`, `tokenStoreCases`, `outageCases` | The identity stores' cases, as `ConformanceCase` objects with a stable `id` |
842
+ | `runCase(case, harness)` | Runs one; throws on failure, answers `{ passed: true }` or `{ skipped }` |
843
+ | `SKIP_REASONS` | The reasons the suite gives itself |
844
+ | `allRelationCases`, `relationStoreCases`, `relationOutageCases`, `runRelationCase` | The same for the relation store |
845
+ | `referenceHarness()`, `referenceRelationHarness()` | The suites against the reference stores: the examples to copy |
846
+
847
+ Types: `ConformanceHarness`, `OpenedStores`, `StoreFaults`, `ConformanceCase`,
848
+ `CaseContext`, `ConformanceRunner`, `PortMethod`, and `RelationHarness`,
849
+ `OpenedRelations`, `RelationFaults`, `RelationCase`, `RelationContext`,
850
+ `RelationMethod`.
851
+
852
+ ## See also
853
+
854
+ - [Errors](errors.md) — `StoreFailure`, `StoreConflict` and the rule behind them
855
+ - [Vocabulary](vocabulary.md) — ids, cursors and `invalidCursor`
856
+ - `@softistx/janus-mongo` — an adapter that passes both suites against a real mongod, outages included
857
+ - `@softistx/janus-drizzle` — both suites on PostgreSQL 17, PostgreSQL 15 and PGlite
858
+ - `@softistx/janus-redis` — the sessions and one-time tokens cases on Redis 7.4, Redis 7.0 and Valkey 7.2