@jini-ai/user-management 0.7.3-next.1 → 0.7.3-next.3

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 (378) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +55 -2
  3. package/dist/admin/adapters/memory.js +4 -4
  4. package/dist/admin-http/auth/auth-request.d.ts +112 -0
  5. package/dist/admin-http/auth/auth-request.js +32 -0
  6. package/dist/admin-http/auth/boot-redemption.d.ts +9 -0
  7. package/dist/admin-http/auth/boot-redemption.js +17 -0
  8. package/dist/admin-http/auth/boot-session.d.ts +30 -0
  9. package/dist/admin-http/auth/boot-session.js +40 -0
  10. package/dist/admin-http/auth/current-user.d.ts +28 -0
  11. package/dist/admin-http/auth/current-user.js +34 -0
  12. package/dist/admin-http/auth/index.d.ts +17 -0
  13. package/dist/admin-http/auth/index.js +9 -0
  14. package/dist/admin-http/auth/local-boot-session.d.ts +9 -0
  15. package/dist/admin-http/auth/local-boot-session.js +30 -0
  16. package/dist/admin-http/auth/logout.d.ts +10 -0
  17. package/dist/admin-http/auth/logout.js +17 -0
  18. package/dist/admin-http/auth/mfa-login.d.ts +30 -0
  19. package/dist/admin-http/auth/mfa-login.js +43 -0
  20. package/dist/admin-http/auth/password-login.d.ts +35 -0
  21. package/dist/admin-http/auth/password-login.js +52 -0
  22. package/dist/admin-http/auth/password-status.d.ts +34 -0
  23. package/dist/admin-http/auth/password-status.js +42 -0
  24. package/dist/admin-http/http/api-keys.d.ts +45 -0
  25. package/dist/admin-http/http/api-keys.js +28 -0
  26. package/dist/admin-http/http/users.d.ts +71 -0
  27. package/dist/admin-http/http/users.js +42 -0
  28. package/dist/admin-http/owner/mfa-deps.d.ts +41 -0
  29. package/dist/admin-http/owner/mfa-deps.js +26 -0
  30. package/dist/admin-http/owner/mfa-routes.d.ts +72 -0
  31. package/dist/admin-http/owner/mfa-routes.js +105 -0
  32. package/dist/admin-http/owner/passkey-admission.d.ts +46 -0
  33. package/dist/admin-http/owner/passkey-admission.js +23 -0
  34. package/dist/admin-http/owner/passkey-route-deps.d.ts +53 -0
  35. package/dist/admin-http/owner/passkey-route-deps.js +33 -0
  36. package/dist/admin-http/owner/passkey-routes.d.ts +146 -0
  37. package/dist/admin-http/owner/passkey-routes.js +98 -0
  38. package/dist/admin-http/owner/recovery-routes.d.ts +71 -0
  39. package/dist/admin-http/owner/recovery-routes.js +112 -0
  40. package/dist/admin-http/routes/api-keys/create-principal.d.ts +26 -0
  41. package/dist/admin-http/routes/api-keys/create-principal.js +37 -0
  42. package/dist/admin-http/routes/api-keys/issue.d.ts +32 -0
  43. package/dist/admin-http/routes/api-keys/issue.js +38 -0
  44. package/dist/admin-http/routes/api-keys/revoke.d.ts +26 -0
  45. package/dist/admin-http/routes/api-keys/revoke.js +31 -0
  46. package/dist/admin-http/routes/api-keys/shared.d.ts +46 -0
  47. package/dist/admin-http/routes/api-keys/shared.js +38 -0
  48. package/dist/admin-http/routes/users/access-shared.d.ts +103 -0
  49. package/dist/admin-http/routes/users/access-shared.js +85 -0
  50. package/dist/admin-http/routes/users/assign-role.d.ts +24 -0
  51. package/dist/admin-http/routes/users/assign-role.js +30 -0
  52. package/dist/admin-http/routes/users/attach-policy.d.ts +25 -0
  53. package/dist/admin-http/routes/users/attach-policy.js +31 -0
  54. package/dist/admin-http/routes/users/create-policy.d.ts +19 -0
  55. package/dist/admin-http/routes/users/create-policy.js +28 -0
  56. package/dist/admin-http/routes/users/create-role.d.ts +15 -0
  57. package/dist/admin-http/routes/users/create-role.js +21 -0
  58. package/dist/admin-http/routes/users/create.d.ts +32 -0
  59. package/dist/admin-http/routes/users/create.js +67 -0
  60. package/dist/admin-http/routes/users/delete-policy.d.ts +16 -0
  61. package/dist/admin-http/routes/users/delete-policy.js +24 -0
  62. package/dist/admin-http/routes/users/delete-role.d.ts +16 -0
  63. package/dist/admin-http/routes/users/delete-role.js +24 -0
  64. package/dist/admin-http/routes/users/delete.d.ts +35 -0
  65. package/dist/admin-http/routes/users/delete.js +35 -0
  66. package/dist/admin-http/routes/users/disable.d.ts +31 -0
  67. package/dist/admin-http/routes/users/disable.js +38 -0
  68. package/dist/admin-http/routes/users/enable.d.ts +32 -0
  69. package/dist/admin-http/routes/users/enable.js +45 -0
  70. package/dist/admin-http/routes/users/list-policies.d.ts +18 -0
  71. package/dist/admin-http/routes/users/list-policies.js +20 -0
  72. package/dist/admin-http/routes/users/list-policy-permissions.d.ts +28 -0
  73. package/dist/admin-http/routes/users/list-policy-permissions.js +30 -0
  74. package/dist/admin-http/routes/users/list-roles.d.ts +18 -0
  75. package/dist/admin-http/routes/users/list-roles.js +20 -0
  76. package/dist/admin-http/routes/users/list.d.ts +40 -0
  77. package/dist/admin-http/routes/users/list.js +82 -0
  78. package/dist/admin-http/routes/users/remove-policy-permission.d.ts +48 -0
  79. package/dist/admin-http/routes/users/remove-policy-permission.js +62 -0
  80. package/dist/admin-http/routes/users/reset-password.d.ts +33 -0
  81. package/dist/admin-http/routes/users/reset-password.js +52 -0
  82. package/dist/admin-http/routes/users/shared.d.ts +124 -0
  83. package/dist/admin-http/routes/users/shared.js +93 -0
  84. package/dist/admin-http/routes/users/update-policy.d.ts +25 -0
  85. package/dist/admin-http/routes/users/update-policy.js +30 -0
  86. package/dist/admin-http/routes/users/update-role.d.ts +23 -0
  87. package/dist/admin-http/routes/users/update-role.js +29 -0
  88. package/dist/admin-http/routes/users/update.d.ts +35 -0
  89. package/dist/admin-http/routes/users/update.js +78 -0
  90. package/dist/admin-http/routes/users/write-policy-permission.d.ts +31 -0
  91. package/dist/admin-http/routes/users/write-policy-permission.js +45 -0
  92. package/dist/core/ports.d.ts +22 -3
  93. package/dist/core/types.d.ts +17 -5
  94. package/dist/core/types.js +12 -0
  95. package/dist/identity/api-key-secret.d.ts +68 -0
  96. package/dist/identity/api-key-secret.js +229 -0
  97. package/dist/identity/api-key-service.d.ts +144 -0
  98. package/dist/identity/api-key-service.js +389 -0
  99. package/dist/identity/api-key-types.d.ts +79 -0
  100. package/dist/identity/api-key-types.js +2 -0
  101. package/dist/identity/boot-session-token.d.ts +18 -0
  102. package/dist/identity/boot-session-token.js +92 -0
  103. package/dist/identity/builtin-role-grants.d.ts +120 -0
  104. package/dist/identity/builtin-role-grants.js +88 -0
  105. package/dist/identity/delete-user-service.d.ts +195 -0
  106. package/dist/identity/delete-user-service.js +275 -0
  107. package/dist/identity/owner-reset-env.d.ts +37 -0
  108. package/dist/identity/owner-reset-env.js +38 -0
  109. package/dist/identity/permission-grants.d.ts +31 -0
  110. package/dist/identity/permission-grants.js +12 -0
  111. package/dist/identity/permission-list-tool.d.ts +35 -0
  112. package/dist/identity/permission-list-tool.js +47 -0
  113. package/dist/identity/repo.authentication.d.ts +57 -0
  114. package/dist/identity/repo.authentication.js +153 -0
  115. package/dist/identity/repo.authorization.d.ts +82 -0
  116. package/dist/identity/repo.authorization.js +203 -0
  117. package/dist/identity/repo.d.ts +87 -0
  118. package/dist/identity/repo.js +167 -0
  119. package/dist/identity/repo.memory.d.ts +31 -0
  120. package/dist/identity/repo.memory.js +37 -0
  121. package/dist/identity/role-manage-permission.d.ts +34 -0
  122. package/dist/identity/role-manage-permission.js +39 -0
  123. package/dist/identity/site-key-permission.d.ts +66 -0
  124. package/dist/identity/site-key-permission.js +92 -0
  125. package/dist/identity/sql/kernel-user-purge.d.ts +19 -0
  126. package/dist/identity/sql/kernel-user-purge.js +34 -0
  127. package/dist/identity/sql/kernel-user-trash-store.d.ts +15 -0
  128. package/dist/identity/sql/kernel-user-trash-store.js +41 -0
  129. package/dist/identity/sql/user-trash-adapter.d.ts +87 -0
  130. package/dist/identity/sql/user-trash-adapter.js +124 -0
  131. package/dist/identity/tool-registrations.d.ts +100 -0
  132. package/dist/identity/tool-registrations.js +257 -0
  133. package/dist/identity/user-manage-permission.d.ts +8 -0
  134. package/dist/identity/user-manage-permission.js +8 -0
  135. package/dist/identity/user-purge-types.d.ts +85 -0
  136. package/dist/identity/user-purge-types.js +17 -0
  137. package/dist/identity/user-purge.d.ts +69 -0
  138. package/dist/identity/user-purge.js +46 -0
  139. package/dist/identity/username-change-ports.d.ts +15 -0
  140. package/dist/identity/username-change-ports.js +22 -0
  141. package/dist/mail/site/capture-clear.d.ts +58 -0
  142. package/dist/mail/site/capture-clear.js +21 -0
  143. package/dist/mail/status/agent-tools.d.ts +65 -0
  144. package/dist/mail/status/agent-tools.js +22 -0
  145. package/dist/mail/status/delivery-agent-tools.d.ts +206 -0
  146. package/dist/mail/status/delivery-agent-tools.js +63 -0
  147. package/dist/mail/status/delivery-tool-registrations.d.ts +216 -0
  148. package/dist/mail/status/delivery-tool-registrations.js +110 -0
  149. package/dist/mail/status/domain-deps.d.ts +25 -0
  150. package/dist/mail/status/domain-deps.js +23 -0
  151. package/dist/mail/status/permissions.d.ts +43 -0
  152. package/dist/mail/status/permissions.js +45 -0
  153. package/dist/mail/status/provider-agent-tools.d.ts +38 -0
  154. package/dist/mail/status/provider-agent-tools.js +17 -0
  155. package/dist/mail/status/provider-operations.d.ts +166 -0
  156. package/dist/mail/status/provider-operations.js +121 -0
  157. package/dist/mail/status/provider-tool-registrations.d.ts +65 -0
  158. package/dist/mail/status/provider-tool-registrations.js +106 -0
  159. package/dist/mail/status/tool-registrations.d.ts +152 -0
  160. package/dist/mail/status/tool-registrations.js +112 -0
  161. package/dist/member-login/credentials.d.ts +40 -0
  162. package/dist/member-login/credentials.js +26 -0
  163. package/dist/member-login/link-service.d.ts +66 -0
  164. package/dist/member-login/link-service.js +141 -0
  165. package/dist/member-login/oidc-login.d.ts +132 -0
  166. package/dist/member-login/oidc-login.js +206 -0
  167. package/dist/member-login/oidc-request.d.ts +80 -0
  168. package/dist/member-login/oidc-request.js +86 -0
  169. package/dist/member-login/providers.d.ts +79 -0
  170. package/dist/member-login/providers.js +41 -0
  171. package/dist/member-login/ready-providers.d.ts +17 -0
  172. package/dist/member-login/ready-providers.js +11 -0
  173. package/dist/member-login/unlink-identity.d.ts +26 -0
  174. package/dist/member-login/unlink-identity.js +59 -0
  175. package/dist/members/access-resolver.d.ts +107 -0
  176. package/dist/members/access-resolver.js +231 -0
  177. package/dist/members/agent-tools.d.ts +14 -0
  178. package/dist/members/agent-tools.js +139 -0
  179. package/dist/members/auth-mail.d.ts +27 -0
  180. package/dist/members/auth-mail.js +21 -0
  181. package/dist/members/capability-card.d.ts +18 -0
  182. package/dist/members/capability-card.js +27 -0
  183. package/dist/members/consent-service.d.ts +115 -0
  184. package/dist/members/consent-service.js +179 -0
  185. package/dist/members/member-admin-writes.d.ts +73 -0
  186. package/dist/members/member-admin-writes.js +149 -0
  187. package/dist/members/member-challenge-request.d.ts +59 -0
  188. package/dist/members/member-challenge-request.js +145 -0
  189. package/dist/members/member-challenge.d.ts +37 -0
  190. package/dist/members/member-challenge.js +84 -0
  191. package/dist/members/member-credentials.d.ts +35 -0
  192. package/dist/members/member-credentials.js +57 -0
  193. package/dist/members/member-sign-in.d.ts +44 -0
  194. package/dist/members/member-sign-in.js +130 -0
  195. package/dist/members/member-validation.d.ts +5 -0
  196. package/dist/members/member-validation.js +13 -0
  197. package/dist/members/password-auth.d.ts +55 -0
  198. package/dist/members/password-auth.js +177 -0
  199. package/dist/members/ports.d.ts +455 -0
  200. package/dist/members/ports.js +21 -0
  201. package/dist/members/public-member-auth-response.d.ts +68 -0
  202. package/dist/members/public-member-auth-response.js +45 -0
  203. package/dist/members/public-member-response.d.ts +25 -0
  204. package/dist/members/public-member-response.js +15 -0
  205. package/dist/members/repo.d.ts +199 -0
  206. package/dist/members/repo.js +324 -0
  207. package/dist/members/repo.memory.d.ts +276 -0
  208. package/dist/members/repo.memory.js +395 -0
  209. package/dist/members/repo.rows.d.ts +153 -0
  210. package/dist/members/repo.rows.js +250 -0
  211. package/dist/members/repo.sessions.d.ts +80 -0
  212. package/dist/members/repo.sessions.js +166 -0
  213. package/dist/members/repo.sql.d.ts +9 -0
  214. package/dist/members/repo.sql.js +11 -0
  215. package/dist/members/subscriber-directory.d.ts +85 -0
  216. package/dist/members/subscriber-directory.js +70 -0
  217. package/dist/members/tool-registrations.d.ts +143 -0
  218. package/dist/members/tool-registrations.js +247 -0
  219. package/dist/members/trash-member.d.ts +24 -0
  220. package/dist/members/trash-member.js +24 -0
  221. package/dist/members/types.d.ts +321 -0
  222. package/dist/members/types.js +34 -0
  223. package/dist/members/write-service.d.ts +17 -0
  224. package/dist/members/write-service.js +15 -0
  225. package/dist/newsletter/agent-tools.d.ts +20 -0
  226. package/dist/newsletter/agent-tools.js +236 -0
  227. package/dist/newsletter/campaign-write-service.d.ts +92 -0
  228. package/dist/newsletter/campaign-write-service.js +190 -0
  229. package/dist/newsletter/campaign.d.ts +53 -0
  230. package/dist/newsletter/campaign.js +95 -0
  231. package/dist/newsletter/confirmation.d.ts +75 -0
  232. package/dist/newsletter/confirmation.js +142 -0
  233. package/dist/newsletter/data-module-manifest.d.ts +68 -0
  234. package/dist/newsletter/data-module-manifest.js +126 -0
  235. package/dist/newsletter/delivery/tool-registrations.d.ts +67 -0
  236. package/dist/newsletter/delivery/tool-registrations.js +229 -0
  237. package/dist/newsletter/errors.d.ts +93 -0
  238. package/dist/newsletter/errors.js +93 -0
  239. package/dist/newsletter/hooks.d.ts +59 -0
  240. package/dist/newsletter/hooks.js +49 -0
  241. package/dist/newsletter/http-error-responses.d.ts +17 -0
  242. package/dist/newsletter/http-error-responses.js +96 -0
  243. package/dist/newsletter/launch-gate.d.ts +62 -0
  244. package/dist/newsletter/launch-gate.js +29 -0
  245. package/dist/newsletter/lists.d.ts +60 -0
  246. package/dist/newsletter/lists.js +83 -0
  247. package/dist/newsletter/ports.d.ts +278 -0
  248. package/dist/newsletter/ports.js +2 -0
  249. package/dist/newsletter/repo-sends.d.ts +82 -0
  250. package/dist/newsletter/repo-sends.js +178 -0
  251. package/dist/newsletter/repo-subscribers.d.ts +82 -0
  252. package/dist/newsletter/repo-subscribers.js +193 -0
  253. package/dist/newsletter/repo.d.ts +61 -0
  254. package/dist/newsletter/repo.js +147 -0
  255. package/dist/newsletter/repo.memory.d.ts +201 -0
  256. package/dist/newsletter/repo.memory.js +250 -0
  257. package/dist/newsletter/repo.rows.d.ts +221 -0
  258. package/dist/newsletter/repo.rows.js +260 -0
  259. package/dist/newsletter/send-pipeline.d.ts +236 -0
  260. package/dist/newsletter/send-pipeline.js +514 -0
  261. package/dist/newsletter/subscriptions.d.ts +87 -0
  262. package/dist/newsletter/subscriptions.js +119 -0
  263. package/dist/newsletter/tool-registrations.d.ts +89 -0
  264. package/dist/newsletter/tool-registrations.deps.d.ts +9 -0
  265. package/dist/newsletter/tool-registrations.deps.js +9 -0
  266. package/dist/newsletter/tool-registrations.js +133 -0
  267. package/dist/newsletter/tool-registrations.read.d.ts +76 -0
  268. package/dist/newsletter/tool-registrations.read.js +140 -0
  269. package/dist/newsletter/tool-registrations.write.d.ts +54 -0
  270. package/dist/newsletter/tool-registrations.write.js +229 -0
  271. package/dist/newsletter/types.d.ts +279 -0
  272. package/dist/newsletter/types.js +23 -0
  273. package/dist/newsletter/unsubscribe.d.ts +41 -0
  274. package/dist/newsletter/unsubscribe.js +100 -0
  275. package/dist/project-keys/attached-vault.d.ts +23 -0
  276. package/dist/project-keys/attached-vault.js +65 -0
  277. package/dist/project-keys/create-vault.d.ts +17 -0
  278. package/dist/project-keys/create-vault.js +29 -0
  279. package/dist/project-keys/service.d.ts +133 -0
  280. package/dist/project-keys/service.js +128 -0
  281. package/dist/project-keys/site-references.d.ts +30 -0
  282. package/dist/project-keys/site-references.js +63 -0
  283. package/dist/project-keys/site-sealer.d.ts +28 -0
  284. package/dist/project-keys/site-sealer.js +64 -0
  285. package/dist/project-keys/sql/attachments.d.ts +33 -0
  286. package/dist/project-keys/sql/attachments.js +55 -0
  287. package/dist/project-keys/tools.d.ts +86 -0
  288. package/dist/project-keys/tools.js +66 -0
  289. package/dist/public-http/routes/mail/feedback.d.ts +44 -0
  290. package/dist/public-http/routes/mail/feedback.js +17 -0
  291. package/dist/public-http/routes/newsletter/confirm.d.ts +38 -0
  292. package/dist/public-http/routes/newsletter/confirm.js +33 -0
  293. package/dist/public-http/routes/newsletter/page.d.ts +29 -0
  294. package/dist/public-http/routes/newsletter/page.js +34 -0
  295. package/dist/public-http/routes/newsletter/unsubscribe.d.ts +33 -0
  296. package/dist/public-http/routes/newsletter/unsubscribe.js +35 -0
  297. package/dist/react/auth/Passkeys.d.ts +2 -34
  298. package/dist/react/auth/RecoveryCodesCard.d.ts +27 -0
  299. package/dist/react/auth/RecoveryCodesCard.hooks.d.ts +67 -0
  300. package/dist/react/auth/RecoveryCodesCard.hooks.js +38 -0
  301. package/dist/react/auth/RecoveryCodesCard.js +56 -0
  302. package/dist/react/auth/TotpSettings.d.ts +2 -23
  303. package/dist/react/auth/local-owner-signin.d.ts +40 -0
  304. package/dist/react/auth/local-owner-signin.js +25 -0
  305. package/dist/react/auth/owner-mfa-api.d.ts +10 -0
  306. package/dist/react/auth/owner-mfa-api.js +17 -0
  307. package/dist/react/auth/owner-passkey-api.d.ts +11 -0
  308. package/dist/react/auth/owner-passkey-api.js +17 -0
  309. package/dist/react/auth/owner-recovery-api.d.ts +51 -0
  310. package/dist/react/auth/owner-recovery-api.js +29 -0
  311. package/dist/react/auth/owner-request.d.ts +7 -0
  312. package/dist/react/auth/owner-request.js +2 -0
  313. package/dist/react/index.d.ts +10 -0
  314. package/dist/react/index.js +6 -0
  315. package/dist/react/mail/Email.d.ts +20 -0
  316. package/dist/react/mail/Email.js +143 -0
  317. package/dist/react/mail/EmailProviderTab.d.ts +34 -0
  318. package/dist/react/mail/EmailProviderTab.js +132 -0
  319. package/dist/react/mail/EmailSegments.d.ts +24 -0
  320. package/dist/react/mail/EmailSegments.js +15 -0
  321. package/dist/react/mail/EmailTemplateEditor.d.ts +146 -0
  322. package/dist/react/mail/EmailTemplateEditor.js +116 -0
  323. package/dist/react/mail/email-view.types.d.ts +236 -0
  324. package/dist/react/mail/email-view.types.js +2 -0
  325. package/dist/react/members/Members.d.ts +5 -3
  326. package/dist/react/members/Members.js +3 -3
  327. package/dist/react/members/api/members-api.d.ts +37 -0
  328. package/dist/react/members/api/members-api.js +16 -0
  329. package/dist/react/members/hooks/use-members.hooks.js +2 -1
  330. package/dist/react/members/members-i18n.d.ts +23 -0
  331. package/dist/react/members/members-i18n.js +25 -0
  332. package/dist/react/members/members-i18n.locales-a.d.ts +4 -0
  333. package/dist/react/members/members-i18n.locales-a.js +294 -0
  334. package/dist/react/members/members-i18n.locales-b.d.ts +4 -0
  335. package/dist/react/members/members-i18n.locales-b.js +265 -0
  336. package/dist/react/models.d.ts +1 -49
  337. package/dist/react/ports.d.ts +3 -143
  338. package/dist/react/roles/api/roles-api.d.ts +74 -0
  339. package/dist/react/roles/api/roles-api.js +22 -0
  340. package/dist/react/testing.js +18 -9
  341. package/dist/react/users/UsersPanel.d.ts +30 -0
  342. package/dist/react/users/UsersPanel.hooks.d.ts +8 -0
  343. package/dist/react/users/UsersPanel.hooks.js +9 -0
  344. package/dist/react/users/UsersPanel.js +9 -0
  345. package/dist/react/users/api/users-api.d.ts +65 -0
  346. package/dist/react/users/api/users-api.js +46 -0
  347. package/dist/react/users/hooks/use-localized-users.hooks.d.ts +43 -0
  348. package/dist/react/users/hooks/use-localized-users.hooks.js +15 -0
  349. package/dist/react/users/hooks/use-users-state.hooks.d.ts +18 -18
  350. package/dist/react/users/password-reset-notice.d.ts +8 -0
  351. package/dist/react/users/password-reset-notice.js +36 -0
  352. package/dist/server/admin-crud-service.d.ts +4 -10
  353. package/dist/server/admin-crud-service.js +20 -6
  354. package/dist/server/agent-tool-registrations.js +20 -5
  355. package/dist/server/agent-tools.js +16 -3
  356. package/dist/server/auth-challenge.d.ts +1 -1
  357. package/dist/server/auth-service.js +2 -1
  358. package/dist/server/grant-service.d.ts +1 -0
  359. package/dist/server/grant-service.js +7 -4
  360. package/dist/server/mfa/passkey-service.d.ts +2 -2
  361. package/dist/server/mfa/passkey-service.js +1 -1
  362. package/dist/server/mfa/service.js +6 -4
  363. package/dist/server/repo.memory.d.ts +30 -2
  364. package/dist/server/repo.memory.js +58 -4
  365. package/dist/server/seed.js +3 -3
  366. package/dist/server/sql/assignments.d.ts +90 -0
  367. package/dist/server/sql/assignments.js +128 -0
  368. package/dist/server/sql/index.d.ts +6 -0
  369. package/dist/server/sql/index.js +5 -0
  370. package/dist/server/sql/kernel.d.ts +9 -0
  371. package/dist/server/sql/kernel.js +2 -0
  372. package/dist/server/sql/mfa.d.ts +36 -0
  373. package/dist/server/sql/mfa.js +51 -0
  374. package/dist/server/sql/passkeys.d.ts +25 -0
  375. package/dist/server/sql/passkeys.js +33 -0
  376. package/dist/server/sql/recovery-codes.d.ts +22 -0
  377. package/dist/server/sql/recovery-codes.js +32 -0
  378. package/package.json +910 -12
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - @jini-ai/core@0.7.2
8
+
3
9
  ## 0.7.1
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -8,6 +8,7 @@ All current entries are included in the unchanged 0.1.0 package version:
8
8
  | `@jini-ai/user-management` | Universal | Records, errors, repository/runtime ports, permission catalog |
9
9
  | `@jini-ai/user-management/session-bootstrap` | Universal | Initial identity read with one admitted bootstrap, probe-then-redeem decision, plain-HTTP loopback URL guard |
10
10
  | `@jini-ai/user-management/server` | Node | Auth, sessions, grants, administration, hashing, memory repos, seeding, migrations, tool metadata/parser and registration composition |
11
+ | `@jini-ai/user-management/server/sql` | Node | Kysely SQL stores for the owner recovery-code, passkey and MFA ports and the role/principal assignment repos; the host injects the kernel, `IdentityTransactionPort` and table names (`kysely` is an optional peer, used type-only) |
11
12
  | `@jini-ai/user-management/react` | Browser | Login, Users, Members, hooks, browser DTOs and typed host ports |
12
13
  | `@jini-ai/user-management/react/testing` | Browser | Generalized fake login/users/roles/members ports |
13
14
  | `@jini-ai/user-management/react/kit` | Browser | The UI contract the screens render through: four components and five hooks, provided once by the host via `UserManagementKitProvider` |
@@ -32,9 +33,10 @@ import no `ui` or `admin` component: they render through `<UserManagementKitProv
32
33
  at its root with its own implementations (`const kit = {...} satisfies UserManagementKit`). Mount the
33
34
  provider inside the host's query provider; the fetch hooks in the kit own the cache. The roles/policies module uses `@jini-ai/ui-kit` and its React facades;
34
35
  see [roles administration wiring and cleanup](./src/admin/PORT.md).
35
- Member timestamps use `formatTimestamp({ iso })` from `@jini-ai/core/text`.
36
+ Member timestamps use `formatTimestamp({ iso }, { viewerTimeZone })` from `@jini-ai/core/text`; omit `viewerTimeZone` to show the stored time as written.
36
37
  Supply `port`, `translate` and a session/workspace `queryScope`.
37
- Login requires `productName`. Members optionally accepts a host-filtered refresh port.
38
+ Login requires `productName`. Members requires a host-bound `useMembersHook` (bind the exported `useMembers`
39
+ or your own controller hook; the screen has no default) and optionally accepts a host-filtered refresh port.
38
40
  Screen ports use object IDs and separate optional fields. The fake roles port
39
41
  retains a policy's name when an update omits it or supplies `undefined`.
40
42
  Remount screens when switching sessions/workspaces. The host supplies styles and dictionaries; see
@@ -87,6 +89,33 @@ Members are deferred as a complete backend extraction, not partially implemented
87
89
 
88
90
  See [stage-B checklist and source map](./stage-b-report.md) and [validation evidence](./validation.md). Build with `tsc -p tsconfig.json`; test with `vitest run` from this directory.
89
91
 
92
+ ## Wiring
93
+
94
+ Admin route specs (`src/admin-http/routes/users/*`, DTOs in `src/admin-http/http/users.ts`) are
95
+ server-neutral `defineJsonRoute` specs, each with its own small `<Name>RouteDeps`. A host mounts one
96
+ with `mountJsonRoute({ app, spec, deps })` from `@jini-ai/http-kit`, passing its `authorize` port.
97
+ Principal routes: list, create, update, disable, enable, reset-password, delete, assign-role,
98
+ attach-policy. Role/policy routes: create/update/delete role, create/update/delete policy, write a
99
+ policy permission. The identity services they call live in the node `./server` entry, so each spec
100
+ takes the one it calls as a required deps field (typed with `typeof`) and the host binds it from
101
+ `@jini-ai/user-management/server`; the specs import only `src/core` errors and types. Host-owned rules
102
+ are injected too: the identity deps assembler (`identityServices`/`identityServiceDeps`, a thunk built
103
+ per request), the Trash index and trash move, the account-protection guard (`assertUserAccountAction`
104
+ plus the seeded `ownerPrincipalId`, run by disable, enable and reset-password), host error classes as
105
+ predicates (`isUserInTrashError`, `isSelfDeleteError`, …), and the ungrantable-permission list and
106
+ its refusal copy. Authorization happens inside the identity services (`role.manage`, `user.manage`),
107
+ so the specs never call the `authorize` port except `list`, which receives the host's raw
108
+ `decidePermission` (two permissions, "either one", no entity type). The three role/policy reads
109
+ (`list-roles`, `list-policies`, `list-policy-permissions`) ask the `authorize` port for `role.manage`
110
+ themselves, with no `entityType` and no entity scope (the port receives neither key), and read only
111
+ the `Pick`ed repo methods they call. `remove-policy-permission` takes the identity transaction port,
112
+ the policy-permission row read and two host owner guards (`principalHoldsOwnerWildcard`,
113
+ `assertActiveOwnerFloor`) as deps, and answers its 204 as a bodiless `routeReply`.
114
+
115
+ `./admin-http/owner/mfa-deps`: `composeOwnerMfaDeps({ deps, authServiceDeps, totp, sealedSecrets })`
116
+ builds `OwnerMfaDeps` from a host's late-bound identity, MFA storage and sealing ports; the host
117
+ injects `createOtplibTotp`/`createSealedMfaSecrets` from `./server`.
118
+
90
119
  ## Design decisions
91
120
 
92
121
  - [Identity, authorization and sessions fail closed](docs/decisions/DR-001-identity-and-session-boundary.md).
@@ -108,3 +137,27 @@ replace authentication prose through `defaultUserManagementMessages` and the `me
108
137
  Session `workspaceId` remains required: session and principal repositories address records by
109
138
  composite tenant/record keys and session validation must not cross tenant boundaries. It is an
110
139
  opaque host scope in meaning, but renaming or making it optional would violate that store contract.
140
+
141
+ ## Wiring
142
+
143
+ `./admin-http/auth` routes are mounted by the host with per-route deps and its `AuthRequest`
144
+ context. Behavior contract for owner MFA login (`POST /api/admin/v1/auth/mfa/login`, B12): only a
145
+ refused proof classified as `MfaProofRefusedError` answers `400 { error: MFA_PROOF_REFUSED_MESSAGE,
146
+ code: "MFA_REFUSED" }`, with that fixed text. Any other failure, including another
147
+ `IdentityValidationError` from an injected collaborator, is rethrown to the host's redacted login
148
+ envelope (`Cache-Control: no-store` is already set), so proof or token text never reaches the body.
149
+ A host binding `completeOwnerLogin` must throw `MfaProofRefusedError` for a wrong, replayed or
150
+ expired code. Password login (`POST /api/admin/v1/auth/login`) coerces credential fields only after
151
+ readiness and the limiter, so a denied request always gets its exact 429 and `Retry-After`.
152
+
153
+ Each route's context is a narrowed view of `AuthRequest` naming only the operations it calls
154
+ (`CurrentPrincipalAuth` for `/auth/me` and `/auth/me/password-status`, `LogoutAuth` = session
155
+ revocation + cookie clearing, `SignInAuth` for password and MFA login, `BootSessionAuth` and
156
+ `LocalBootSessionAuth` for the boot routes). A host binding its full `AuthRequest` satisfies all
157
+ of them; the response policy (cookies, cache headers, limiter, `onError`) stays host code.
158
+
159
+ `RecoveryCodesCard` (`./react`) takes every hook as a required prop: `createDownloadHook`
160
+ (`createOwnerRecoveryKitDownload`), `useRecoveryKitHook` (`useOwnerRecoveryKit` bound by the host
161
+ to `useRecoveryKit`) and `useDesktopOwnerResetHook` (`useDesktopOwnerReset` bound to
162
+ `useOwnerPasswordReset`). The two wrapper hooks likewise take their inner hook as a required
163
+ second argument; neither the card nor the wrappers default to an imported hook.
@@ -72,8 +72,8 @@ function roleOperations(ctx) {
72
72
  const { roles, workspaceId, options } = ctx;
73
73
  return {
74
74
  async listRoles(_r, o = {}) { check(o); return { roles: [...roles.values()].map(r => ({ ...r })) }; },
75
- async createRole(r, o = {}) { ctx.write(o); const n = ctx.name(r.name); ctx.unique(roles, n); const role = { id: ctx.id(), workspaceId, name: n, isBuiltin: false }; roles.set(role.id, role); return { role: { ...role } }; },
76
- async updateRole(r, o = {}) { ctx.write(o); const old = ctx.editableRole(r.roleId), n = ctx.name(r.name); ctx.unique(roles, n, old.id); const role = { ...old, name: n }; roles.set(role.id, role); return { role: { ...role } }; },
75
+ async createRole(r, o = {}) { ctx.write(o); const n = ctx.name(r.name); ctx.unique(roles, n); const role = { id: ctx.id(), workspaceId, name: n, isBuiltin: false, version: 1 }; roles.set(role.id, role); return { role: { ...role } }; },
76
+ async updateRole(r, o = {}) { ctx.write(o); const old = ctx.editableRole(r.roleId), n = ctx.name(r.name); ctx.unique(roles, n, old.id); const role = { ...old, name: n, version: old.version + 1 }; roles.set(role.id, role); return { role: { ...role } }; },
77
77
  async deleteRole(r, o = {}) {
78
78
  ctx.write(o);
79
79
  ctx.editableRole(r.roleId);
@@ -88,7 +88,7 @@ function policyOperations(ctx) {
88
88
  const { policies, permissions, workspaceId, options } = ctx;
89
89
  return {
90
90
  async listPolicies(_r, o = {}) { check(o); return { policies: [...policies.values()].map(p => ({ ...p })) }; },
91
- async createPolicy(r, o = {}) { ctx.write(o); const n = ctx.name(r.name); ctx.unique(policies, n); const policy = { id: ctx.id(), workspaceId, name: n, isBuiltin: false, isFrozen: false, ...(o.description !== undefined ? { description: o.description } : {}) }; policies.set(policy.id, policy); return { policy: { ...policy } }; },
91
+ async createPolicy(r, o = {}) { ctx.write(o); const n = ctx.name(r.name); ctx.unique(policies, n); const policy = { version: 1, id: ctx.id(), workspaceId, name: n, isBuiltin: false, isFrozen: false, ...(o.description !== undefined ? { description: o.description } : {}) }; policies.set(policy.id, policy); return { policy: { ...policy } }; },
92
92
  async updatePolicy(r, o = {}) {
93
93
  ctx.write(o);
94
94
  const old = ctx.editablePolicy(r.policyId);
@@ -97,7 +97,7 @@ function policyOperations(ctx) {
97
97
  }
98
98
  const n = o.name === undefined ? old.name : ctx.name(o.name);
99
99
  ctx.unique(policies, n, old.id);
100
- const policy = { ...old, name: n, ...(o.description !== undefined ? { description: o.description } : {}) };
100
+ const policy = { ...old, name: n, version: old.version + 1, ...(o.description !== undefined ? { description: o.description } : {}) };
101
101
  policies.set(policy.id, policy);
102
102
  return { policy: { ...policy } };
103
103
  },
@@ -0,0 +1,112 @@
1
+ /** Request metadata recorded on every ordinary session. */
2
+ export interface AuthSessionOptions {
3
+ readonly ip?: string | undefined;
4
+ readonly userAgent?: string | undefined;
5
+ readonly sessionTtlMs: number;
6
+ }
7
+ /** A freshly minted bearer and when it expires. */
8
+ export interface AuthSessionIssue {
9
+ readonly rawToken: string;
10
+ readonly expiresAtIso: string;
11
+ }
12
+ export interface AuthPrincipal {
13
+ readonly id: string;
14
+ readonly kind?: string;
15
+ readonly displayName?: string | null;
16
+ }
17
+ /** The outcome of redeeming a one-time boot token; see `redeemBootSession`. */
18
+ export type BootRedemption = {
19
+ readonly kind: 'refused';
20
+ } | {
21
+ readonly kind: 'mfa';
22
+ readonly body: unknown;
23
+ } | {
24
+ readonly kind: 'failure';
25
+ readonly error: unknown;
26
+ } | {
27
+ readonly kind: 'session';
28
+ readonly principal: AuthPrincipal;
29
+ readonly setCookies: readonly string[];
30
+ };
31
+ export interface AuthRequest {
32
+ /** The client key the shared login limiter counts against. */
33
+ readonly clientKey: string;
34
+ sessionOptions(): AuthSessionOptions;
35
+ /** The registration's single limiter, shared with the recovery, MFA and passkey routes. */
36
+ readonly rateLimit: {
37
+ check(): Promise<{
38
+ readonly allowed: boolean;
39
+ readonly retryAfterSeconds: number;
40
+ }>;
41
+ };
42
+ currentPrincipal(): Promise<AuthPrincipal | null>;
43
+ /** Revokes every bearer this request carried; runs before a replacement cookie is set. */
44
+ revokeSessions(): Promise<void>;
45
+ readonly cookies: {
46
+ /** Sets the session cookie and returns the `Set-Cookie` values in the order they were written. */
47
+ replaceSession(required: AuthSessionIssue, optional?: {
48
+ readonly name?: string;
49
+ }): readonly string[];
50
+ clearSessions(): readonly string[];
51
+ };
52
+ noStore(): void;
53
+ retryAfter(seconds: number): void;
54
+ /** Fire-and-forget: never awaited, and its failure never changes the response. */
55
+ signedIn(required: {
56
+ readonly principalId: string;
57
+ }): void;
58
+ readonly loopback: boolean;
59
+ readonly localOwnerSignIn: {
60
+ readonly enabled: boolean;
61
+ acceptsCapability(): boolean;
62
+ allowsRequest(): boolean;
63
+ };
64
+ redeemBootSession(required: {
65
+ readonly token: unknown;
66
+ }, optional?: {
67
+ readonly mintLocal?: boolean;
68
+ }): Promise<BootRedemption>;
69
+ }
70
+ /** Who is signed in; the `/auth/me*` routes read nothing else. */
71
+ export type CurrentPrincipalAuth = Pick<AuthRequest, 'currentPrincipal'>;
72
+ /** The shared limiter and its Retry-After header. */
73
+ type RateLimitedAuth = Pick<AuthRequest, 'rateLimit' | 'retryAfter'>;
74
+ /** What the sign-in signal and the uncacheable answer of a boot redemption need. */
75
+ export type BootAnswerAuth = Pick<AuthRequest, 'noStore' | 'signedIn'>;
76
+ /** Password and MFA sign-in: limiter, session metadata, revocation, the replacement cookie and the signal. */
77
+ export type SignInAuth = RateLimitedAuth & BootAnswerAuth & Pick<AuthRequest, 'sessionOptions' | 'revokeSessions'> & {
78
+ readonly cookies: Pick<AuthRequest['cookies'], 'replaceSession'>;
79
+ };
80
+ /** Logout: session revocation and clearing the cookies, nothing else. */
81
+ export type LogoutAuth = Pick<AuthRequest, 'revokeSessions'> & {
82
+ readonly cookies: Pick<AuthRequest['cookies'], 'clearSessions'>;
83
+ };
84
+ /** Boot-token redemption, gated on loopback. */
85
+ export type BootSessionAuth = BootAnswerAuth & Pick<AuthRequest, 'loopback' | 'redeemBootSession'>;
86
+ /** Local owner sign-in: the boot redemption plus its policy and the existing-session check. */
87
+ export type LocalBootSessionAuth = BootSessionAuth & CurrentPrincipalAuth & Pick<AuthRequest, 'localOwnerSignIn'>;
88
+ /** The mount binds a context on every request; a missing one is a wiring fault, not a caller error. */
89
+ export declare function requireAuthRequest<Context>({ context }: {
90
+ context: Context | undefined;
91
+ }, _optional?: Record<string, never>): Context;
92
+ /** A flat-body refusal for the host's `onError` to write verbatim. */
93
+ export declare function refuse({ status, body }: {
94
+ status: number;
95
+ body: Readonly<Record<string, unknown>>;
96
+ }, _optional?: Record<string, never>): never;
97
+ /** A JSON body as a record, or an empty one; missing and non-object bodies read as empty. */
98
+ export declare function bodyRecord({ body }: {
99
+ body: unknown;
100
+ }, _optional?: Record<string, never>): Readonly<Record<string, unknown>>;
101
+ /** A deliberate sign-in failure the host answers with its redacted auth-failure envelope for
102
+ * `operation`. Anything else a route throws (a repository fault, say) takes the host's ordinary
103
+ * error path instead, so the two are told apart by type, never by message. */
104
+ export declare class OwnerAuthFailure extends Error {
105
+ readonly operation: string;
106
+ constructor({ error, operation }: {
107
+ error: unknown;
108
+ operation: string;
109
+ }, _optional?: Record<string, never>);
110
+ }
111
+ export {};
112
+ //# sourceMappingURL=auth-request.d.ts.map
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @file The per-request context a host's `authenticate` port binds for the owner-auth routes. It is
3
+ * the host-injected response policy: cookies, cache headers, the shared login limiter, session
4
+ * revocation and the sign-in signal all stay host code, so these routes name no cookie, header or
5
+ * framework. Every refusal is thrown as a `RouteRefusalError`; the host's `onError` writes its body.
6
+ */
7
+ import { RouteRefusalError } from '@jini-ai/core/errors/route-refusal';
8
+ /** The mount binds a context on every request; a missing one is a wiring fault, not a caller error. */
9
+ export function requireAuthRequest({ context }, _optional = {}) {
10
+ if (!context)
11
+ throw new Error('owner-auth route mounted without an authenticate port');
12
+ return context;
13
+ }
14
+ /** A flat-body refusal for the host's `onError` to write verbatim. */
15
+ export function refuse({ status, body }, _optional = {}) {
16
+ throw new RouteRefusalError({ status, body });
17
+ }
18
+ /** A JSON body as a record, or an empty one; missing and non-object bodies read as empty. */
19
+ export function bodyRecord({ body }, _optional = {}) {
20
+ return typeof body === 'object' && body !== null ? body : {};
21
+ }
22
+ /** A deliberate sign-in failure the host answers with its redacted auth-failure envelope for
23
+ * `operation`. Anything else a route throws (a repository fault, say) takes the host's ordinary
24
+ * error path instead, so the two are told apart by type, never by message. */
25
+ export class OwnerAuthFailure extends Error {
26
+ operation;
27
+ constructor({ error, operation }, _optional = {}) {
28
+ super('owner sign-in could not finish', { cause: error });
29
+ this.operation = operation;
30
+ }
31
+ }
32
+ //# sourceMappingURL=auth-request.js.map
@@ -0,0 +1,9 @@
1
+ import { type BootAnswerAuth, type BootRedemption } from './auth-request.js';
2
+ /** Turns a redemption into the route's answer. Every rejection is one flat 401 with no detail, so
3
+ * unarmed, wrong and already-spent tokens are indistinguishable to a caller. The sign-in signal
4
+ * fires only after the host has installed the session cookie. */
5
+ export declare function answerBootRedemption({ redemption, auth }: {
6
+ redemption: BootRedemption;
7
+ auth: BootAnswerAuth;
8
+ }, _optional?: Record<string, never>): unknown;
9
+ //# sourceMappingURL=boot-redemption.d.ts.map
@@ -0,0 +1,17 @@
1
+ import { OwnerAuthFailure, refuse } from './auth-request.js';
2
+ /** Turns a redemption into the route's answer. Every rejection is one flat 401 with no detail, so
3
+ * unarmed, wrong and already-spent tokens are indistinguishable to a caller. The sign-in signal
4
+ * fires only after the host has installed the session cookie. */
5
+ export function answerBootRedemption({ redemption, auth }, _optional = {}) {
6
+ if (redemption.kind === 'refused')
7
+ refuse({ status: 401, body: { error: 'invalid or spent boot token', code: 'UNAUTHENTICATED' } });
8
+ if (redemption.kind === 'mfa') {
9
+ auth.noStore();
10
+ return redemption.body;
11
+ }
12
+ if (redemption.kind === 'failure')
13
+ throw new OwnerAuthFailure({ error: redemption.error, operation: 'boot-session' });
14
+ auth.signedIn({ principalId: redemption.principal.id });
15
+ return { user: { id: redemption.principal.id } };
16
+ }
17
+ //# sourceMappingURL=boot-redemption.js.map
@@ -0,0 +1,30 @@
1
+ import { type BootSessionAuth } from './auth-request.js';
2
+ /** The body stays unread until the loopback check passes. */
3
+ export interface BootSessionInput {
4
+ readonly body: unknown;
5
+ }
6
+ /**
7
+ * Exchange a single-use boot token for an ordinary admin session.
8
+ *
9
+ * Exists so a process that STARTED this server can prove it started it without knowing a
10
+ * password. The token is minted only when the launcher asked for one, lives in this
11
+ * process's memory for one launch, and is destroyed on first redemption
12
+ * (the host's boot-session token store).
13
+ *
14
+ * **This route knows nothing about who is calling it.** No desktop/Electron branch, no
15
+ * launcher-specific name — the contract is only "a valid single-use loopback token starts a
16
+ * session", so nothing here has to change or be removed if a particular launcher goes away.
17
+ *
18
+ * Every rejection is a flat 401 with no distinguishing detail: unarmed, wrong, and already-spent
19
+ * are indistinguishable to a caller, so this cannot be used as an oracle for whether a token
20
+ * exists. There is deliberately NO arm in which an unminted token means "allow" — an unarmed
21
+ * store refuses every input, so an ordinary server start (which mints nothing) has this route
22
+ * present but permanently closed.
23
+ *
24
+ * The session it creates is an ordinary one: a real, revocable `sessions` row bound to the seeded
25
+ * owner principal, resolved by the same `validateSession` and gated by the same `authorize()` as
26
+ * a password login. Nothing downstream can tell the difference, and no bypass flag is threaded
27
+ * anywhere.
28
+ */
29
+ export declare const bootSessionRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<BootSessionInput, unknown, Record<string, never>, BootSessionAuth>;
30
+ //# sourceMappingURL=boot-session.d.ts.map
@@ -0,0 +1,40 @@
1
+ import { defineJsonRoute, ok } from '@jini-ai/core/contracts/server';
2
+ import { bodyRecord, refuse, requireAuthRequest } from './auth-request.js';
3
+ import { answerBootRedemption } from './boot-redemption.js';
4
+ /**
5
+ * Exchange a single-use boot token for an ordinary admin session.
6
+ *
7
+ * Exists so a process that STARTED this server can prove it started it without knowing a
8
+ * password. The token is minted only when the launcher asked for one, lives in this
9
+ * process's memory for one launch, and is destroyed on first redemption
10
+ * (the host's boot-session token store).
11
+ *
12
+ * **This route knows nothing about who is calling it.** No desktop/Electron branch, no
13
+ * launcher-specific name — the contract is only "a valid single-use loopback token starts a
14
+ * session", so nothing here has to change or be removed if a particular launcher goes away.
15
+ *
16
+ * Every rejection is a flat 401 with no distinguishing detail: unarmed, wrong, and already-spent
17
+ * are indistinguishable to a caller, so this cannot be used as an oracle for whether a token
18
+ * exists. There is deliberately NO arm in which an unminted token means "allow" — an unarmed
19
+ * store refuses every input, so an ordinary server start (which mints nothing) has this route
20
+ * present but permanently closed.
21
+ *
22
+ * The session it creates is an ordinary one: a real, revocable `sessions` row bound to the seeded
23
+ * owner principal, resolved by the same `validateSession` and gated by the same `authorize()` as
24
+ * a password login. Nothing downstream can tell the difference, and no bypass flag is threaded
25
+ * anywhere.
26
+ */
27
+ export const bootSessionRoute = defineJsonRoute({
28
+ method: 'post',
29
+ path: '/api/admin/v1/auth/boot-session',
30
+ parse: raw => ok({ value: { body: raw.body } }),
31
+ handle: async ({ input, context }) => {
32
+ const auth = requireAuthRequest({ context });
33
+ // Checked before the token is even looked at, so a remote caller cannot probe redemption.
34
+ if (!auth.loopback)
35
+ refuse({ status: 403, body: { error: 'boot-session is loopback-only', code: 'FORBIDDEN' } });
36
+ const redemption = await auth.redeemBootSession({ token: bodyRecord({ body: input.body }).token });
37
+ return ok({ value: answerBootRedemption({ redemption, auth }) });
38
+ },
39
+ });
40
+ //# sourceMappingURL=boot-session.js.map
@@ -0,0 +1,28 @@
1
+ import { type AuthPrincipal, type CurrentPrincipalAuth } from './auth-request.js';
2
+ export interface CurrentUserRouteDeps {
3
+ readonly workspaceId: string;
4
+ readonly findUserByPrincipalId: (required: {
5
+ workspaceId: string;
6
+ principalId: string;
7
+ }) => Promise<{
8
+ readonly username: string;
9
+ } | null | undefined>;
10
+ readonly effectivePermissions: (required: {
11
+ workspaceId: string;
12
+ principalId: string;
13
+ }) => Promise<readonly string[]>;
14
+ /** Owner or the built-in admin role, which deliberately holds no `user.manage`/`*` grant; a permission
15
+ * string check alone would hide a working affordance from an admin-role caller. */
16
+ readonly callerMayManageUserTrash: (required: {
17
+ workspaceId: string;
18
+ callerPrincipalId: string;
19
+ }) => Promise<boolean>;
20
+ readonly canPublishToLive: () => boolean;
21
+ }
22
+ /** The signed-in principal, or the flat 401 every `/auth/me*` route answers without one. */
23
+ export declare function signedInPrincipal({ auth }: {
24
+ auth: CurrentPrincipalAuth;
25
+ }, _optional?: Record<string, never>): Promise<AuthPrincipal>;
26
+ /** `GET /api/admin/v1/auth/me`: who is signed in and which affordances to show. */
27
+ export declare const currentUserRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<Record<string, never>, unknown, CurrentUserRouteDeps, CurrentPrincipalAuth>;
28
+ //# sourceMappingURL=current-user.d.ts.map
@@ -0,0 +1,34 @@
1
+ import { defineJsonRoute, ok } from '@jini-ai/core/contracts/server';
2
+ import { refuse, requireAuthRequest } from './auth-request.js';
3
+ /** The signed-in principal, or the flat 401 every `/auth/me*` route answers without one. */
4
+ export async function signedInPrincipal({ auth }, _optional = {}) {
5
+ const principal = await auth.currentPrincipal();
6
+ if (!principal)
7
+ refuse({ status: 401, body: { error: 'unauthenticated', code: 'UNAUTHENTICATED' } });
8
+ return principal;
9
+ }
10
+ /** `GET /api/admin/v1/auth/me`: who is signed in and which affordances to show. */
11
+ export const currentUserRoute = defineJsonRoute({
12
+ method: 'get',
13
+ path: '/api/admin/v1/auth/me',
14
+ parse: () => ok({ value: {} }),
15
+ handle: async ({ deps, context }) => {
16
+ const principal = await signedInPrincipal({ auth: requireAuthRequest({ context }) });
17
+ const principalId = principal.id;
18
+ const workspaceId = deps.workspaceId;
19
+ const userRow = await deps.findUserByPrincipalId({ workspaceId, principalId });
20
+ const effectivePermissions = await deps.effectivePermissions({ workspaceId, principalId });
21
+ // The same check the trash routes gate on, so this affordance flag can never drift from the
22
+ // real boundary. Not itself a security boundary.
23
+ const canManageUserTrash = await deps.callerMayManageUserTrash({ workspaceId, callerPrincipalId: principalId });
24
+ return ok({ value: {
25
+ user: { id: principalId, username: userRow?.username ?? principal.displayName },
26
+ effectivePermissions,
27
+ canManageUserTrash,
28
+ // Affordance flag, not the boundary: the admin hides every Publish entry point when this is
29
+ // `false` (the live site); the push routes refuse on their own.
30
+ canPublishToLive: deps.canPublishToLive(),
31
+ } });
32
+ },
33
+ });
34
+ //# sourceMappingURL=current-user.js.map
@@ -0,0 +1,17 @@
1
+ export { passwordLoginRoute } from './password-login.js';
2
+ export type { PasswordLoginRouteDeps, PasswordLoginInput, PasswordLoginOutcome } from './password-login.js';
3
+ export { mfaLoginRoute } from './mfa-login.js';
4
+ export type { MfaLoginRouteDeps, MfaLoginInput } from './mfa-login.js';
5
+ export { logoutRoute } from './logout.js';
6
+ export type { LogoutRouteDeps } from './logout.js';
7
+ export type { AuthRequest, AuthSessionOptions, AuthSessionIssue, AuthPrincipal, BootRedemption } from './auth-request.js';
8
+ export type { CurrentPrincipalAuth, BootAnswerAuth, SignInAuth, LogoutAuth, BootSessionAuth, LocalBootSessionAuth } from './auth-request.js';
9
+ export { bootSessionRoute } from './boot-session.js';
10
+ export type { BootSessionInput } from './boot-session.js';
11
+ export { localBootSessionRoute } from './local-boot-session.js';
12
+ export { OwnerAuthFailure } from './auth-request.js';
13
+ export { currentUserRoute } from './current-user.js';
14
+ export type { CurrentUserRouteDeps } from './current-user.js';
15
+ export { createPasswordStatusRoute } from './password-status.js';
16
+ export type { PasswordStatusRouteDeps } from './password-status.js';
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,9 @@
1
+ export { passwordLoginRoute } from './password-login.js';
2
+ export { mfaLoginRoute } from './mfa-login.js';
3
+ export { logoutRoute } from './logout.js';
4
+ export { bootSessionRoute } from './boot-session.js';
5
+ export { localBootSessionRoute } from './local-boot-session.js';
6
+ export { OwnerAuthFailure } from './auth-request.js';
7
+ export { currentUserRoute } from './current-user.js';
8
+ export { createPasswordStatusRoute } from './password-status.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,9 @@
1
+ import { type LocalBootSessionAuth } from './auth-request.js';
2
+ /** A desktop launch signs its own browser in without exposing a raw boot token.
3
+ * Desktop must present its private launch capability before browser-style header admission.
4
+ * The browser has no private parent stdout pipe. A launcher-armed, same-origin loopback
5
+ * request uses a request-scoped one-time token; no raw boot token is exposed to JS or logs.
6
+ * Separate stores prevent concurrent tabs, or the desktop's still-armed token, burning each other.
7
+ */
8
+ export declare const localBootSessionRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<Record<string, never>, unknown, Record<string, never>, LocalBootSessionAuth>;
9
+ //# sourceMappingURL=local-boot-session.d.ts.map
@@ -0,0 +1,30 @@
1
+ import { defineJsonRoute, ok } from '@jini-ai/core/contracts/server';
2
+ import { refuse, requireAuthRequest } from './auth-request.js';
3
+ import { answerBootRedemption } from './boot-redemption.js';
4
+ /** A desktop launch signs its own browser in without exposing a raw boot token.
5
+ * Desktop must present its private launch capability before browser-style header admission.
6
+ * The browser has no private parent stdout pipe. A launcher-armed, same-origin loopback
7
+ * request uses a request-scoped one-time token; no raw boot token is exposed to JS or logs.
8
+ * Separate stores prevent concurrent tabs, or the desktop's still-armed token, burning each other.
9
+ */
10
+ export const localBootSessionRoute = defineJsonRoute({
11
+ method: 'post',
12
+ path: '/api/admin/v1/auth/local-boot-session',
13
+ parse: () => ok({ value: {} }),
14
+ handle: async ({ context }) => {
15
+ const auth = requireAuthRequest({ context });
16
+ const policy = auth.localOwnerSignIn;
17
+ if (!policy.enabled || !policy.acceptsCapability())
18
+ refuse({ status: 404, body: { error: 'local owner sign-in is disabled', code: 'NOT_FOUND' } });
19
+ if (!auth.loopback || !policy.allowsRequest())
20
+ refuse({ status: 403, body: { error: 'local owner sign-in requires a same-origin loopback request', code: 'FORBIDDEN' } });
21
+ auth.noStore();
22
+ // Keep an existing human session; auto sign-in must never promote a non-owner account.
23
+ const existing = await auth.currentPrincipal();
24
+ if (existing)
25
+ return ok({ value: { user: { id: existing.id } } });
26
+ const redemption = await auth.redeemBootSession({ token: undefined }, { mintLocal: true });
27
+ return ok({ value: answerBootRedemption({ redemption, auth }) });
28
+ },
29
+ });
30
+ //# sourceMappingURL=local-boot-session.js.map
@@ -0,0 +1,10 @@
1
+ import { type LogoutAuth } from './auth-request.js';
2
+ export interface LogoutRouteDeps {
3
+ readonly identityReady: Promise<unknown>;
4
+ }
5
+ /** `POST /api/admin/v1/auth/logout`: revokes this request's sessions and clears both cookies.
6
+ * Failures are thrown so the host answers them like the login route instead of leaving the request hanging. */
7
+ export declare const logoutRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<Record<string, never>, {
8
+ ok: true;
9
+ }, LogoutRouteDeps, LogoutAuth>;
10
+ //# sourceMappingURL=logout.d.ts.map
@@ -0,0 +1,17 @@
1
+ import { defineJsonRoute, ok } from '@jini-ai/core/contracts/server';
2
+ import { requireAuthRequest } from './auth-request.js';
3
+ /** `POST /api/admin/v1/auth/logout`: revokes this request's sessions and clears both cookies.
4
+ * Failures are thrown so the host answers them like the login route instead of leaving the request hanging. */
5
+ export const logoutRoute = defineJsonRoute({
6
+ method: 'post',
7
+ path: '/api/admin/v1/auth/logout',
8
+ parse: () => ok({ value: {} }),
9
+ handle: async ({ deps, context }) => {
10
+ const auth = requireAuthRequest({ context });
11
+ await deps.identityReady;
12
+ await auth.revokeSessions();
13
+ auth.cookies.clearSessions();
14
+ return ok({ value: { ok: true } });
15
+ },
16
+ });
17
+ //# sourceMappingURL=logout.js.map
@@ -0,0 +1,30 @@
1
+ import { type AuthPrincipal, type AuthSessionOptions, type SignInAuth } from './auth-request.js';
2
+ export interface MfaLoginRouteDeps {
3
+ readonly workspaceId: string;
4
+ readonly completeOwnerLogin: (required: {
5
+ input: {
6
+ workspaceId: string;
7
+ pendingToken: string;
8
+ code: string;
9
+ };
10
+ }, optional: AuthSessionOptions) => Promise<{
11
+ readonly principal: AuthPrincipal;
12
+ readonly session: {
13
+ readonly expiresAt: string;
14
+ };
15
+ readonly rawToken: string;
16
+ }>;
17
+ readonly findUserByPrincipalId: (required: {
18
+ workspaceId: string;
19
+ principalId: string;
20
+ }) => Promise<{
21
+ readonly username: string;
22
+ } | null | undefined>;
23
+ }
24
+ export interface MfaLoginInput {
25
+ readonly pendingToken: string;
26
+ readonly code: string;
27
+ }
28
+ /** `POST /api/admin/v1/auth/mfa/login`: completes an owner MFA challenge. */
29
+ export declare const mfaLoginRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<MfaLoginInput, unknown, MfaLoginRouteDeps, SignInAuth>;
30
+ //# sourceMappingURL=mfa-login.d.ts.map
@@ -0,0 +1,43 @@
1
+ import { defineJsonRoute, ok } from '@jini-ai/core/contracts/server';
2
+ import { MFA_PROOF_REFUSED_MESSAGE, MfaProofRefusedError } from '../../core/types.js';
3
+ import { bodyRecord, refuse, requireAuthRequest } from './auth-request.js';
4
+ /** MFA proofs are strings; objects/numbers never become bearer tokens by coercion. O(1). */
5
+ function mfaBodyText(body, key) {
6
+ const value = body[key];
7
+ return typeof value === 'string' ? value : '';
8
+ }
9
+ async function mfaLogin({ input, deps, auth }) {
10
+ const rate = await auth.rateLimit.check();
11
+ if (!rate.allowed) {
12
+ auth.retryAfter(rate.retryAfterSeconds);
13
+ refuse({ status: 429, body: { error: 'Too many authenticator attempts. Wait a minute and try again.', code: 'RATE_LIMIT_EXCEEDED' } });
14
+ }
15
+ const result = await deps.completeOwnerLogin({ input: { workspaceId: deps.workspaceId, pendingToken: input.pendingToken, code: input.code } }, auth.sessionOptions());
16
+ await auth.revokeSessions();
17
+ auth.cookies.replaceSession({ rawToken: result.rawToken, expiresAtIso: result.session.expiresAt });
18
+ const user = await deps.findUserByPrincipalId({ workspaceId: deps.workspaceId, principalId: result.principal.id });
19
+ auth.signedIn({ principalId: result.principal.id });
20
+ return { user: { id: result.principal.id, username: user?.username ?? result.principal.displayName } };
21
+ }
22
+ /** `POST /api/admin/v1/auth/mfa/login`: completes an owner MFA challenge. */
23
+ export const mfaLoginRoute = defineJsonRoute({
24
+ method: 'post',
25
+ path: '/api/admin/v1/auth/mfa/login',
26
+ parse: raw => { const body = bodyRecord({ body: raw.body }); return ok({ value: { pendingToken: mfaBodyText(body, 'pendingToken'), code: mfaBodyText(body, 'code') } }); },
27
+ handle: async ({ input, deps, context }) => {
28
+ const auth = requireAuthRequest({ context });
29
+ // Every answer, refusals and failures included, is uncacheable: set before anything can throw.
30
+ auth.noStore();
31
+ try {
32
+ return ok({ value: await mfaLogin({ input, deps, auth }) });
33
+ }
34
+ catch (error) {
35
+ // Only the classified proof refusal is public, with its fixed text; any other failure (an injected
36
+ // collaborator's validation error can echo the proof) goes to the host's redacted envelope.
37
+ if (error instanceof MfaProofRefusedError)
38
+ refuse({ status: 400, body: { error: MFA_PROOF_REFUSED_MESSAGE, code: 'MFA_REFUSED' } });
39
+ throw error;
40
+ }
41
+ },
42
+ });
43
+ //# sourceMappingURL=mfa-login.js.map