@jini-ai/user-management 0.7.3-next.2 → 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 (377) hide show
  1. package/README.md +55 -2
  2. package/dist/admin/adapters/memory.js +4 -4
  3. package/dist/admin-http/auth/auth-request.d.ts +112 -0
  4. package/dist/admin-http/auth/auth-request.js +32 -0
  5. package/dist/admin-http/auth/boot-redemption.d.ts +9 -0
  6. package/dist/admin-http/auth/boot-redemption.js +17 -0
  7. package/dist/admin-http/auth/boot-session.d.ts +30 -0
  8. package/dist/admin-http/auth/boot-session.js +40 -0
  9. package/dist/admin-http/auth/current-user.d.ts +28 -0
  10. package/dist/admin-http/auth/current-user.js +34 -0
  11. package/dist/admin-http/auth/index.d.ts +17 -0
  12. package/dist/admin-http/auth/index.js +9 -0
  13. package/dist/admin-http/auth/local-boot-session.d.ts +9 -0
  14. package/dist/admin-http/auth/local-boot-session.js +30 -0
  15. package/dist/admin-http/auth/logout.d.ts +10 -0
  16. package/dist/admin-http/auth/logout.js +17 -0
  17. package/dist/admin-http/auth/mfa-login.d.ts +30 -0
  18. package/dist/admin-http/auth/mfa-login.js +43 -0
  19. package/dist/admin-http/auth/password-login.d.ts +35 -0
  20. package/dist/admin-http/auth/password-login.js +52 -0
  21. package/dist/admin-http/auth/password-status.d.ts +34 -0
  22. package/dist/admin-http/auth/password-status.js +42 -0
  23. package/dist/admin-http/http/api-keys.d.ts +45 -0
  24. package/dist/admin-http/http/api-keys.js +28 -0
  25. package/dist/admin-http/http/users.d.ts +71 -0
  26. package/dist/admin-http/http/users.js +42 -0
  27. package/dist/admin-http/owner/mfa-deps.d.ts +41 -0
  28. package/dist/admin-http/owner/mfa-deps.js +26 -0
  29. package/dist/admin-http/owner/mfa-routes.d.ts +72 -0
  30. package/dist/admin-http/owner/mfa-routes.js +105 -0
  31. package/dist/admin-http/owner/passkey-admission.d.ts +46 -0
  32. package/dist/admin-http/owner/passkey-admission.js +23 -0
  33. package/dist/admin-http/owner/passkey-route-deps.d.ts +53 -0
  34. package/dist/admin-http/owner/passkey-route-deps.js +33 -0
  35. package/dist/admin-http/owner/passkey-routes.d.ts +146 -0
  36. package/dist/admin-http/owner/passkey-routes.js +98 -0
  37. package/dist/admin-http/owner/recovery-routes.d.ts +71 -0
  38. package/dist/admin-http/owner/recovery-routes.js +112 -0
  39. package/dist/admin-http/routes/api-keys/create-principal.d.ts +26 -0
  40. package/dist/admin-http/routes/api-keys/create-principal.js +37 -0
  41. package/dist/admin-http/routes/api-keys/issue.d.ts +32 -0
  42. package/dist/admin-http/routes/api-keys/issue.js +38 -0
  43. package/dist/admin-http/routes/api-keys/revoke.d.ts +26 -0
  44. package/dist/admin-http/routes/api-keys/revoke.js +31 -0
  45. package/dist/admin-http/routes/api-keys/shared.d.ts +46 -0
  46. package/dist/admin-http/routes/api-keys/shared.js +38 -0
  47. package/dist/admin-http/routes/users/access-shared.d.ts +103 -0
  48. package/dist/admin-http/routes/users/access-shared.js +85 -0
  49. package/dist/admin-http/routes/users/assign-role.d.ts +24 -0
  50. package/dist/admin-http/routes/users/assign-role.js +30 -0
  51. package/dist/admin-http/routes/users/attach-policy.d.ts +25 -0
  52. package/dist/admin-http/routes/users/attach-policy.js +31 -0
  53. package/dist/admin-http/routes/users/create-policy.d.ts +19 -0
  54. package/dist/admin-http/routes/users/create-policy.js +28 -0
  55. package/dist/admin-http/routes/users/create-role.d.ts +15 -0
  56. package/dist/admin-http/routes/users/create-role.js +21 -0
  57. package/dist/admin-http/routes/users/create.d.ts +32 -0
  58. package/dist/admin-http/routes/users/create.js +67 -0
  59. package/dist/admin-http/routes/users/delete-policy.d.ts +16 -0
  60. package/dist/admin-http/routes/users/delete-policy.js +24 -0
  61. package/dist/admin-http/routes/users/delete-role.d.ts +16 -0
  62. package/dist/admin-http/routes/users/delete-role.js +24 -0
  63. package/dist/admin-http/routes/users/delete.d.ts +35 -0
  64. package/dist/admin-http/routes/users/delete.js +35 -0
  65. package/dist/admin-http/routes/users/disable.d.ts +31 -0
  66. package/dist/admin-http/routes/users/disable.js +38 -0
  67. package/dist/admin-http/routes/users/enable.d.ts +32 -0
  68. package/dist/admin-http/routes/users/enable.js +45 -0
  69. package/dist/admin-http/routes/users/list-policies.d.ts +18 -0
  70. package/dist/admin-http/routes/users/list-policies.js +20 -0
  71. package/dist/admin-http/routes/users/list-policy-permissions.d.ts +28 -0
  72. package/dist/admin-http/routes/users/list-policy-permissions.js +30 -0
  73. package/dist/admin-http/routes/users/list-roles.d.ts +18 -0
  74. package/dist/admin-http/routes/users/list-roles.js +20 -0
  75. package/dist/admin-http/routes/users/list.d.ts +40 -0
  76. package/dist/admin-http/routes/users/list.js +82 -0
  77. package/dist/admin-http/routes/users/remove-policy-permission.d.ts +48 -0
  78. package/dist/admin-http/routes/users/remove-policy-permission.js +62 -0
  79. package/dist/admin-http/routes/users/reset-password.d.ts +33 -0
  80. package/dist/admin-http/routes/users/reset-password.js +52 -0
  81. package/dist/admin-http/routes/users/shared.d.ts +124 -0
  82. package/dist/admin-http/routes/users/shared.js +93 -0
  83. package/dist/admin-http/routes/users/update-policy.d.ts +25 -0
  84. package/dist/admin-http/routes/users/update-policy.js +30 -0
  85. package/dist/admin-http/routes/users/update-role.d.ts +23 -0
  86. package/dist/admin-http/routes/users/update-role.js +29 -0
  87. package/dist/admin-http/routes/users/update.d.ts +35 -0
  88. package/dist/admin-http/routes/users/update.js +78 -0
  89. package/dist/admin-http/routes/users/write-policy-permission.d.ts +31 -0
  90. package/dist/admin-http/routes/users/write-policy-permission.js +45 -0
  91. package/dist/core/ports.d.ts +22 -3
  92. package/dist/core/types.d.ts +17 -5
  93. package/dist/core/types.js +12 -0
  94. package/dist/identity/api-key-secret.d.ts +68 -0
  95. package/dist/identity/api-key-secret.js +229 -0
  96. package/dist/identity/api-key-service.d.ts +144 -0
  97. package/dist/identity/api-key-service.js +389 -0
  98. package/dist/identity/api-key-types.d.ts +79 -0
  99. package/dist/identity/api-key-types.js +2 -0
  100. package/dist/identity/boot-session-token.d.ts +18 -0
  101. package/dist/identity/boot-session-token.js +92 -0
  102. package/dist/identity/builtin-role-grants.d.ts +120 -0
  103. package/dist/identity/builtin-role-grants.js +88 -0
  104. package/dist/identity/delete-user-service.d.ts +195 -0
  105. package/dist/identity/delete-user-service.js +275 -0
  106. package/dist/identity/owner-reset-env.d.ts +37 -0
  107. package/dist/identity/owner-reset-env.js +38 -0
  108. package/dist/identity/permission-grants.d.ts +31 -0
  109. package/dist/identity/permission-grants.js +12 -0
  110. package/dist/identity/permission-list-tool.d.ts +35 -0
  111. package/dist/identity/permission-list-tool.js +47 -0
  112. package/dist/identity/repo.authentication.d.ts +57 -0
  113. package/dist/identity/repo.authentication.js +153 -0
  114. package/dist/identity/repo.authorization.d.ts +82 -0
  115. package/dist/identity/repo.authorization.js +203 -0
  116. package/dist/identity/repo.d.ts +87 -0
  117. package/dist/identity/repo.js +167 -0
  118. package/dist/identity/repo.memory.d.ts +31 -0
  119. package/dist/identity/repo.memory.js +37 -0
  120. package/dist/identity/role-manage-permission.d.ts +34 -0
  121. package/dist/identity/role-manage-permission.js +39 -0
  122. package/dist/identity/site-key-permission.d.ts +66 -0
  123. package/dist/identity/site-key-permission.js +92 -0
  124. package/dist/identity/sql/kernel-user-purge.d.ts +19 -0
  125. package/dist/identity/sql/kernel-user-purge.js +34 -0
  126. package/dist/identity/sql/kernel-user-trash-store.d.ts +15 -0
  127. package/dist/identity/sql/kernel-user-trash-store.js +41 -0
  128. package/dist/identity/sql/user-trash-adapter.d.ts +87 -0
  129. package/dist/identity/sql/user-trash-adapter.js +124 -0
  130. package/dist/identity/tool-registrations.d.ts +100 -0
  131. package/dist/identity/tool-registrations.js +257 -0
  132. package/dist/identity/user-manage-permission.d.ts +8 -0
  133. package/dist/identity/user-manage-permission.js +8 -0
  134. package/dist/identity/user-purge-types.d.ts +85 -0
  135. package/dist/identity/user-purge-types.js +17 -0
  136. package/dist/identity/user-purge.d.ts +69 -0
  137. package/dist/identity/user-purge.js +46 -0
  138. package/dist/identity/username-change-ports.d.ts +15 -0
  139. package/dist/identity/username-change-ports.js +22 -0
  140. package/dist/mail/site/capture-clear.d.ts +58 -0
  141. package/dist/mail/site/capture-clear.js +21 -0
  142. package/dist/mail/status/agent-tools.d.ts +65 -0
  143. package/dist/mail/status/agent-tools.js +22 -0
  144. package/dist/mail/status/delivery-agent-tools.d.ts +206 -0
  145. package/dist/mail/status/delivery-agent-tools.js +63 -0
  146. package/dist/mail/status/delivery-tool-registrations.d.ts +216 -0
  147. package/dist/mail/status/delivery-tool-registrations.js +110 -0
  148. package/dist/mail/status/domain-deps.d.ts +25 -0
  149. package/dist/mail/status/domain-deps.js +23 -0
  150. package/dist/mail/status/permissions.d.ts +43 -0
  151. package/dist/mail/status/permissions.js +45 -0
  152. package/dist/mail/status/provider-agent-tools.d.ts +38 -0
  153. package/dist/mail/status/provider-agent-tools.js +17 -0
  154. package/dist/mail/status/provider-operations.d.ts +166 -0
  155. package/dist/mail/status/provider-operations.js +121 -0
  156. package/dist/mail/status/provider-tool-registrations.d.ts +65 -0
  157. package/dist/mail/status/provider-tool-registrations.js +106 -0
  158. package/dist/mail/status/tool-registrations.d.ts +152 -0
  159. package/dist/mail/status/tool-registrations.js +112 -0
  160. package/dist/member-login/credentials.d.ts +40 -0
  161. package/dist/member-login/credentials.js +26 -0
  162. package/dist/member-login/link-service.d.ts +66 -0
  163. package/dist/member-login/link-service.js +141 -0
  164. package/dist/member-login/oidc-login.d.ts +132 -0
  165. package/dist/member-login/oidc-login.js +206 -0
  166. package/dist/member-login/oidc-request.d.ts +80 -0
  167. package/dist/member-login/oidc-request.js +86 -0
  168. package/dist/member-login/providers.d.ts +79 -0
  169. package/dist/member-login/providers.js +41 -0
  170. package/dist/member-login/ready-providers.d.ts +17 -0
  171. package/dist/member-login/ready-providers.js +11 -0
  172. package/dist/member-login/unlink-identity.d.ts +26 -0
  173. package/dist/member-login/unlink-identity.js +59 -0
  174. package/dist/members/access-resolver.d.ts +107 -0
  175. package/dist/members/access-resolver.js +231 -0
  176. package/dist/members/agent-tools.d.ts +14 -0
  177. package/dist/members/agent-tools.js +139 -0
  178. package/dist/members/auth-mail.d.ts +27 -0
  179. package/dist/members/auth-mail.js +21 -0
  180. package/dist/members/capability-card.d.ts +18 -0
  181. package/dist/members/capability-card.js +27 -0
  182. package/dist/members/consent-service.d.ts +115 -0
  183. package/dist/members/consent-service.js +179 -0
  184. package/dist/members/member-admin-writes.d.ts +73 -0
  185. package/dist/members/member-admin-writes.js +149 -0
  186. package/dist/members/member-challenge-request.d.ts +59 -0
  187. package/dist/members/member-challenge-request.js +145 -0
  188. package/dist/members/member-challenge.d.ts +37 -0
  189. package/dist/members/member-challenge.js +84 -0
  190. package/dist/members/member-credentials.d.ts +35 -0
  191. package/dist/members/member-credentials.js +57 -0
  192. package/dist/members/member-sign-in.d.ts +44 -0
  193. package/dist/members/member-sign-in.js +130 -0
  194. package/dist/members/member-validation.d.ts +5 -0
  195. package/dist/members/member-validation.js +13 -0
  196. package/dist/members/password-auth.d.ts +55 -0
  197. package/dist/members/password-auth.js +177 -0
  198. package/dist/members/ports.d.ts +455 -0
  199. package/dist/members/ports.js +21 -0
  200. package/dist/members/public-member-auth-response.d.ts +68 -0
  201. package/dist/members/public-member-auth-response.js +45 -0
  202. package/dist/members/public-member-response.d.ts +25 -0
  203. package/dist/members/public-member-response.js +15 -0
  204. package/dist/members/repo.d.ts +199 -0
  205. package/dist/members/repo.js +324 -0
  206. package/dist/members/repo.memory.d.ts +276 -0
  207. package/dist/members/repo.memory.js +395 -0
  208. package/dist/members/repo.rows.d.ts +153 -0
  209. package/dist/members/repo.rows.js +250 -0
  210. package/dist/members/repo.sessions.d.ts +80 -0
  211. package/dist/members/repo.sessions.js +166 -0
  212. package/dist/members/repo.sql.d.ts +9 -0
  213. package/dist/members/repo.sql.js +11 -0
  214. package/dist/members/subscriber-directory.d.ts +85 -0
  215. package/dist/members/subscriber-directory.js +70 -0
  216. package/dist/members/tool-registrations.d.ts +143 -0
  217. package/dist/members/tool-registrations.js +247 -0
  218. package/dist/members/trash-member.d.ts +24 -0
  219. package/dist/members/trash-member.js +24 -0
  220. package/dist/members/types.d.ts +321 -0
  221. package/dist/members/types.js +34 -0
  222. package/dist/members/write-service.d.ts +17 -0
  223. package/dist/members/write-service.js +15 -0
  224. package/dist/newsletter/agent-tools.d.ts +20 -0
  225. package/dist/newsletter/agent-tools.js +236 -0
  226. package/dist/newsletter/campaign-write-service.d.ts +92 -0
  227. package/dist/newsletter/campaign-write-service.js +190 -0
  228. package/dist/newsletter/campaign.d.ts +53 -0
  229. package/dist/newsletter/campaign.js +95 -0
  230. package/dist/newsletter/confirmation.d.ts +75 -0
  231. package/dist/newsletter/confirmation.js +142 -0
  232. package/dist/newsletter/data-module-manifest.d.ts +68 -0
  233. package/dist/newsletter/data-module-manifest.js +126 -0
  234. package/dist/newsletter/delivery/tool-registrations.d.ts +67 -0
  235. package/dist/newsletter/delivery/tool-registrations.js +229 -0
  236. package/dist/newsletter/errors.d.ts +93 -0
  237. package/dist/newsletter/errors.js +93 -0
  238. package/dist/newsletter/hooks.d.ts +59 -0
  239. package/dist/newsletter/hooks.js +49 -0
  240. package/dist/newsletter/http-error-responses.d.ts +17 -0
  241. package/dist/newsletter/http-error-responses.js +96 -0
  242. package/dist/newsletter/launch-gate.d.ts +62 -0
  243. package/dist/newsletter/launch-gate.js +29 -0
  244. package/dist/newsletter/lists.d.ts +60 -0
  245. package/dist/newsletter/lists.js +83 -0
  246. package/dist/newsletter/ports.d.ts +278 -0
  247. package/dist/newsletter/ports.js +2 -0
  248. package/dist/newsletter/repo-sends.d.ts +82 -0
  249. package/dist/newsletter/repo-sends.js +178 -0
  250. package/dist/newsletter/repo-subscribers.d.ts +82 -0
  251. package/dist/newsletter/repo-subscribers.js +193 -0
  252. package/dist/newsletter/repo.d.ts +61 -0
  253. package/dist/newsletter/repo.js +147 -0
  254. package/dist/newsletter/repo.memory.d.ts +201 -0
  255. package/dist/newsletter/repo.memory.js +250 -0
  256. package/dist/newsletter/repo.rows.d.ts +221 -0
  257. package/dist/newsletter/repo.rows.js +260 -0
  258. package/dist/newsletter/send-pipeline.d.ts +236 -0
  259. package/dist/newsletter/send-pipeline.js +514 -0
  260. package/dist/newsletter/subscriptions.d.ts +87 -0
  261. package/dist/newsletter/subscriptions.js +119 -0
  262. package/dist/newsletter/tool-registrations.d.ts +89 -0
  263. package/dist/newsletter/tool-registrations.deps.d.ts +9 -0
  264. package/dist/newsletter/tool-registrations.deps.js +9 -0
  265. package/dist/newsletter/tool-registrations.js +133 -0
  266. package/dist/newsletter/tool-registrations.read.d.ts +76 -0
  267. package/dist/newsletter/tool-registrations.read.js +140 -0
  268. package/dist/newsletter/tool-registrations.write.d.ts +54 -0
  269. package/dist/newsletter/tool-registrations.write.js +229 -0
  270. package/dist/newsletter/types.d.ts +279 -0
  271. package/dist/newsletter/types.js +23 -0
  272. package/dist/newsletter/unsubscribe.d.ts +41 -0
  273. package/dist/newsletter/unsubscribe.js +100 -0
  274. package/dist/project-keys/attached-vault.d.ts +23 -0
  275. package/dist/project-keys/attached-vault.js +65 -0
  276. package/dist/project-keys/create-vault.d.ts +17 -0
  277. package/dist/project-keys/create-vault.js +29 -0
  278. package/dist/project-keys/service.d.ts +133 -0
  279. package/dist/project-keys/service.js +128 -0
  280. package/dist/project-keys/site-references.d.ts +30 -0
  281. package/dist/project-keys/site-references.js +63 -0
  282. package/dist/project-keys/site-sealer.d.ts +28 -0
  283. package/dist/project-keys/site-sealer.js +64 -0
  284. package/dist/project-keys/sql/attachments.d.ts +33 -0
  285. package/dist/project-keys/sql/attachments.js +55 -0
  286. package/dist/project-keys/tools.d.ts +86 -0
  287. package/dist/project-keys/tools.js +66 -0
  288. package/dist/public-http/routes/mail/feedback.d.ts +44 -0
  289. package/dist/public-http/routes/mail/feedback.js +17 -0
  290. package/dist/public-http/routes/newsletter/confirm.d.ts +38 -0
  291. package/dist/public-http/routes/newsletter/confirm.js +33 -0
  292. package/dist/public-http/routes/newsletter/page.d.ts +29 -0
  293. package/dist/public-http/routes/newsletter/page.js +34 -0
  294. package/dist/public-http/routes/newsletter/unsubscribe.d.ts +33 -0
  295. package/dist/public-http/routes/newsletter/unsubscribe.js +35 -0
  296. package/dist/react/auth/Passkeys.d.ts +2 -34
  297. package/dist/react/auth/RecoveryCodesCard.d.ts +27 -0
  298. package/dist/react/auth/RecoveryCodesCard.hooks.d.ts +67 -0
  299. package/dist/react/auth/RecoveryCodesCard.hooks.js +38 -0
  300. package/dist/react/auth/RecoveryCodesCard.js +56 -0
  301. package/dist/react/auth/TotpSettings.d.ts +2 -23
  302. package/dist/react/auth/local-owner-signin.d.ts +40 -0
  303. package/dist/react/auth/local-owner-signin.js +25 -0
  304. package/dist/react/auth/owner-mfa-api.d.ts +10 -0
  305. package/dist/react/auth/owner-mfa-api.js +17 -0
  306. package/dist/react/auth/owner-passkey-api.d.ts +11 -0
  307. package/dist/react/auth/owner-passkey-api.js +17 -0
  308. package/dist/react/auth/owner-recovery-api.d.ts +51 -0
  309. package/dist/react/auth/owner-recovery-api.js +29 -0
  310. package/dist/react/auth/owner-request.d.ts +7 -0
  311. package/dist/react/auth/owner-request.js +2 -0
  312. package/dist/react/index.d.ts +10 -0
  313. package/dist/react/index.js +6 -0
  314. package/dist/react/mail/Email.d.ts +20 -0
  315. package/dist/react/mail/Email.js +143 -0
  316. package/dist/react/mail/EmailProviderTab.d.ts +34 -0
  317. package/dist/react/mail/EmailProviderTab.js +132 -0
  318. package/dist/react/mail/EmailSegments.d.ts +24 -0
  319. package/dist/react/mail/EmailSegments.js +15 -0
  320. package/dist/react/mail/EmailTemplateEditor.d.ts +146 -0
  321. package/dist/react/mail/EmailTemplateEditor.js +116 -0
  322. package/dist/react/mail/email-view.types.d.ts +236 -0
  323. package/dist/react/mail/email-view.types.js +2 -0
  324. package/dist/react/members/Members.d.ts +5 -3
  325. package/dist/react/members/Members.js +3 -3
  326. package/dist/react/members/api/members-api.d.ts +37 -0
  327. package/dist/react/members/api/members-api.js +16 -0
  328. package/dist/react/members/hooks/use-members.hooks.js +2 -1
  329. package/dist/react/members/members-i18n.d.ts +23 -0
  330. package/dist/react/members/members-i18n.js +25 -0
  331. package/dist/react/members/members-i18n.locales-a.d.ts +4 -0
  332. package/dist/react/members/members-i18n.locales-a.js +294 -0
  333. package/dist/react/members/members-i18n.locales-b.d.ts +4 -0
  334. package/dist/react/members/members-i18n.locales-b.js +265 -0
  335. package/dist/react/models.d.ts +1 -49
  336. package/dist/react/ports.d.ts +3 -143
  337. package/dist/react/roles/api/roles-api.d.ts +74 -0
  338. package/dist/react/roles/api/roles-api.js +22 -0
  339. package/dist/react/testing.js +18 -9
  340. package/dist/react/users/UsersPanel.d.ts +30 -0
  341. package/dist/react/users/UsersPanel.hooks.d.ts +8 -0
  342. package/dist/react/users/UsersPanel.hooks.js +9 -0
  343. package/dist/react/users/UsersPanel.js +9 -0
  344. package/dist/react/users/api/users-api.d.ts +65 -0
  345. package/dist/react/users/api/users-api.js +46 -0
  346. package/dist/react/users/hooks/use-localized-users.hooks.d.ts +43 -0
  347. package/dist/react/users/hooks/use-localized-users.hooks.js +15 -0
  348. package/dist/react/users/hooks/use-users-state.hooks.d.ts +18 -18
  349. package/dist/react/users/password-reset-notice.d.ts +8 -0
  350. package/dist/react/users/password-reset-notice.js +36 -0
  351. package/dist/server/admin-crud-service.d.ts +4 -10
  352. package/dist/server/admin-crud-service.js +20 -6
  353. package/dist/server/agent-tool-registrations.js +20 -5
  354. package/dist/server/agent-tools.js +16 -3
  355. package/dist/server/auth-challenge.d.ts +1 -1
  356. package/dist/server/auth-service.js +2 -1
  357. package/dist/server/grant-service.d.ts +1 -0
  358. package/dist/server/grant-service.js +7 -4
  359. package/dist/server/mfa/passkey-service.d.ts +2 -2
  360. package/dist/server/mfa/passkey-service.js +1 -1
  361. package/dist/server/mfa/service.js +6 -4
  362. package/dist/server/repo.memory.d.ts +30 -2
  363. package/dist/server/repo.memory.js +58 -4
  364. package/dist/server/seed.js +3 -3
  365. package/dist/server/sql/assignments.d.ts +90 -0
  366. package/dist/server/sql/assignments.js +128 -0
  367. package/dist/server/sql/index.d.ts +6 -0
  368. package/dist/server/sql/index.js +5 -0
  369. package/dist/server/sql/kernel.d.ts +9 -0
  370. package/dist/server/sql/kernel.js +2 -0
  371. package/dist/server/sql/mfa.d.ts +36 -0
  372. package/dist/server/sql/mfa.js +51 -0
  373. package/dist/server/sql/passkeys.d.ts +25 -0
  374. package/dist/server/sql/passkeys.js +33 -0
  375. package/dist/server/sql/recovery-codes.d.ts +22 -0
  376. package/dist/server/sql/recovery-codes.js +32 -0
  377. package/package.json +909 -11
@@ -0,0 +1,16 @@
1
+ import type { deletePolicy } from "../../../server/admin-crud-service.js";
2
+ import { type AccessRoutePrincipal, type AccessServiceRouteDeps } from "./access-shared.js";
3
+ /** The deps this route reads: the workspace, the identity services' deps bag and the service it calls. */
4
+ export interface PolicyDeleteRouteDeps extends AccessServiceRouteDeps {
5
+ /** Injected: the service lives in the node `./server` entry; the host binds it. */
6
+ deletePolicy: typeof deletePolicy;
7
+ }
8
+ /**
9
+ * DELETE policies/:policyId — `DELETE_POLICY` (SPEC-006 0.6.0, REQ-19/INV-09). Gated by
10
+ * `role.manage`; a built-in or frozen target is refused `VALIDATION_ERROR`, a still-referenced
11
+ * target `RESOURCE_CONFLICT` (AC-31). Answers 204 with no body.
12
+ */
13
+ export declare const policyDeleteRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
14
+ policyId: string;
15
+ }, undefined, PolicyDeleteRouteDeps, AccessRoutePrincipal>;
16
+ //# sourceMappingURL=delete-policy.d.ts.map
@@ -0,0 +1,24 @@
1
+ import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
2
+ import { ACCESS_FORBIDDEN, ACCESS_NOT_FOUND, ACCESS_VALIDATION, accessActorId, accessConflictOn, accessPathParam, rejectAccessError, } from "./access-shared.js";
3
+ const POLICY_DELETE_ERRORS = [ACCESS_FORBIDDEN, accessConflictOn({ field: "policyId" }), ACCESS_VALIDATION, ACCESS_NOT_FOUND];
4
+ /**
5
+ * DELETE policies/:policyId — `DELETE_POLICY` (SPEC-006 0.6.0, REQ-19/INV-09). Gated by
6
+ * `role.manage`; a built-in or frozen target is refused `VALIDATION_ERROR`, a still-referenced
7
+ * target `RESOURCE_CONFLICT` (AC-31). Answers 204 with no body.
8
+ */
9
+ export const policyDeleteRoute = defineJsonRoute({
10
+ method: "delete",
11
+ path: "/api/admin/v1/workspaces/:workspaceId/policies/:policyId",
12
+ parse: (raw) => ok({ value: { policyId: accessPathParam({ params: raw.params, name: "policyId" }) } }),
13
+ handle: async ({ input, deps, context }) => {
14
+ const callerPrincipalId = accessActorId({ context });
15
+ try {
16
+ await deps.deletePolicy({ deps: deps.identityServiceDeps(), input: { workspaceId: deps.workspaceId, callerPrincipalId, policyId: input.policyId } });
17
+ return ok({ value: undefined });
18
+ }
19
+ catch (err) {
20
+ return rejectAccessError({ err, mappings: POLICY_DELETE_ERRORS });
21
+ }
22
+ },
23
+ }, { successStatus: 204 });
24
+ //# sourceMappingURL=delete-policy.js.map
@@ -0,0 +1,16 @@
1
+ import type { deleteRole } from "../../../server/admin-crud-service.js";
2
+ import { type AccessRoutePrincipal, type AccessServiceRouteDeps } from "./access-shared.js";
3
+ /** The deps this route reads: the workspace, the identity services' deps bag and the service it calls. */
4
+ export interface RoleDeleteRouteDeps extends AccessServiceRouteDeps {
5
+ /** Injected: the service lives in the node `./server` entry; the host binds it. */
6
+ deleteRole: typeof deleteRole;
7
+ }
8
+ /**
9
+ * DELETE roles/:roleId — `DELETE_ROLE` (SPEC-006 0.6.0, REQ-19/INV-09). Gated by `role.manage`; a
10
+ * built-in target is refused `VALIDATION_ERROR`, a still-referenced target `RESOURCE_CONFLICT`
11
+ * (AC-31). Answers 204 with no body.
12
+ */
13
+ export declare const roleDeleteRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
14
+ roleId: string;
15
+ }, undefined, RoleDeleteRouteDeps, AccessRoutePrincipal>;
16
+ //# sourceMappingURL=delete-role.d.ts.map
@@ -0,0 +1,24 @@
1
+ import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
2
+ import { ACCESS_FORBIDDEN, ACCESS_NOT_FOUND, ACCESS_VALIDATION, accessActorId, accessConflictOn, accessPathParam, rejectAccessError, } from "./access-shared.js";
3
+ const ROLE_DELETE_ERRORS = [ACCESS_FORBIDDEN, accessConflictOn({ field: "roleId" }), ACCESS_VALIDATION, ACCESS_NOT_FOUND];
4
+ /**
5
+ * DELETE roles/:roleId — `DELETE_ROLE` (SPEC-006 0.6.0, REQ-19/INV-09). Gated by `role.manage`; a
6
+ * built-in target is refused `VALIDATION_ERROR`, a still-referenced target `RESOURCE_CONFLICT`
7
+ * (AC-31). Answers 204 with no body.
8
+ */
9
+ export const roleDeleteRoute = defineJsonRoute({
10
+ method: "delete",
11
+ path: "/api/admin/v1/workspaces/:workspaceId/roles/:roleId",
12
+ parse: (raw) => ok({ value: { roleId: accessPathParam({ params: raw.params, name: "roleId" }) } }),
13
+ handle: async ({ input, deps, context }) => {
14
+ const callerPrincipalId = accessActorId({ context });
15
+ try {
16
+ await deps.deleteRole({ deps: deps.identityServiceDeps(), input: { workspaceId: deps.workspaceId, callerPrincipalId, roleId: input.roleId } });
17
+ return ok({ value: undefined });
18
+ }
19
+ catch (err) {
20
+ return rejectAccessError({ err, mappings: ROLE_DELETE_ERRORS });
21
+ }
22
+ },
23
+ }, { successStatus: 204 });
24
+ //# sourceMappingURL=delete-role.js.map
@@ -0,0 +1,35 @@
1
+ import { type HostErrorPredicate, type UserRoutePrincipal } from "./shared.js";
2
+ /**
3
+ * Moves one user to the Trash. Injected because the trash pipeline is the host's: it owns the
4
+ * Trash store, the self/owner/admin rules and the purge. It throws the identity errors the ladder
5
+ * maps, plus the host's self-target and "no Trash wiring" errors (matched by injected predicates).
6
+ */
7
+ export type UserTrashFn = (required: {
8
+ workspaceId: string;
9
+ callerPrincipalId: string;
10
+ principalId: string;
11
+ seededOwnerPrincipalId: string;
12
+ }) => Promise<unknown>;
13
+ /** The deps this route reads. */
14
+ export interface UserDeleteRouteDeps {
15
+ workspaceId: string;
16
+ /** The seeded (bootstrap) owner's principal id, resolved by the host at boot. */
17
+ ownerPrincipalId: PromiseLike<string> | string;
18
+ trashUser: UserTrashFn;
19
+ isSelfDeleteError: HostErrorPredicate;
20
+ /** Matches the host's error for a composition root with no Trash wiring (answered 501). */
21
+ isUserDeleteUnsupportedError: HostErrorPredicate;
22
+ }
23
+ /**
24
+ * DELETE users/:principalId — moves a user to the Trash (delete-user plan v2, decisions 4/5/7, and
25
+ * the OWNER DECISION 2026-09-24 that supersedes decision 1). Gated by the caller being the owner or
26
+ * holding the built-in `admin` role; refuses the caller's own principal (`SELF_DELETE`), the seeded
27
+ * owner or the workspace's last active owner-`*` principal (`OWNER_REQUIRED`); a target already in
28
+ * the Trash is an idempotent 204; 501s when the composition root has no Trash wiring
29
+ * (`NOT_SUPPORTED`, the in-memory identity store) — see the host's trash move for the full rule
30
+ * set. Permanent deletion happens only through the Trash's own purge, never here.
31
+ */
32
+ export declare const userDeleteRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
33
+ principalId: string;
34
+ }, undefined, UserDeleteRouteDeps, UserRoutePrincipal>;
35
+ //# sourceMappingURL=delete.d.ts.map
@@ -0,0 +1,35 @@
1
+ import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
2
+ import { hostRung, principalIdParam, rejectUserError, USER_FORBIDDEN, USER_NOT_FOUND, USER_OWNER_REQUIRED, USER_VALIDATION, userActorId, } from "./shared.js";
3
+ /** This route's ladder, in the hand-written order. @complexity O(1). */
4
+ function userDeleteErrors({ deps }, _optional = {}) {
5
+ return [
6
+ USER_FORBIDDEN, hostRung({ matches: deps.isSelfDeleteError, status: 409, code: "SELF_DELETE" }), USER_OWNER_REQUIRED, USER_VALIDATION, USER_NOT_FOUND,
7
+ hostRung({ matches: deps.isUserDeleteUnsupportedError, status: 501, code: "NOT_SUPPORTED" }),
8
+ ];
9
+ }
10
+ /**
11
+ * DELETE users/:principalId — moves a user to the Trash (delete-user plan v2, decisions 4/5/7, and
12
+ * the OWNER DECISION 2026-09-24 that supersedes decision 1). Gated by the caller being the owner or
13
+ * holding the built-in `admin` role; refuses the caller's own principal (`SELF_DELETE`), the seeded
14
+ * owner or the workspace's last active owner-`*` principal (`OWNER_REQUIRED`); a target already in
15
+ * the Trash is an idempotent 204; 501s when the composition root has no Trash wiring
16
+ * (`NOT_SUPPORTED`, the in-memory identity store) — see the host's trash move for the full rule
17
+ * set. Permanent deletion happens only through the Trash's own purge, never here.
18
+ */
19
+ export const userDeleteRoute = defineJsonRoute({
20
+ method: "delete",
21
+ path: "/api/admin/v1/workspaces/:workspaceId/users/:principalId",
22
+ parse: (raw) => ok({ value: { principalId: principalIdParam(raw.params) } }),
23
+ handle: async ({ input, deps, context }) => {
24
+ const callerPrincipalId = userActorId({ context });
25
+ try {
26
+ const seededOwnerPrincipalId = await deps.ownerPrincipalId;
27
+ await deps.trashUser({ workspaceId: deps.workspaceId, callerPrincipalId, principalId: input.principalId, seededOwnerPrincipalId });
28
+ return ok({ value: undefined });
29
+ }
30
+ catch (err) {
31
+ return rejectUserError({ err, rungs: userDeleteErrors({ deps }) });
32
+ }
33
+ },
34
+ }, { successStatus: 204 });
35
+ //# sourceMappingURL=delete.js.map
@@ -0,0 +1,31 @@
1
+ import type { disablePrincipal } from "../../../server/admin-crud-service.js";
2
+ import type { AdminUserResponse } from "../../http/users.js";
3
+ import { type AssertUserAccountActionFn, type HostErrorPredicate, type IdentityServicesFn, type UserRoutePrincipal } from "./shared.js";
4
+ /** The deps this route reads. */
5
+ export interface UserDisableRouteDeps {
6
+ workspaceId: string;
7
+ /** Identity service(s), injected: the admin-http entry may not reach the `server` source domain
8
+ * (subpath isolation); the host binds them from `@jini-ai/user-management/server`. */
9
+ disablePrincipal: typeof disablePrincipal;
10
+ identityServices: IdentityServicesFn;
11
+ /** The seeded (bootstrap) owner's principal id, resolved by the host at boot. */
12
+ ownerPrincipalId: PromiseLike<string> | string;
13
+ assertUserAccountAction: AssertUserAccountActionFn;
14
+ /** Matches the host's "you cannot disable your own account" error. */
15
+ isSelfDeleteError: HostErrorPredicate;
16
+ }
17
+ /**
18
+ * POST users/:principalId/disable — `DISABLE_PRINCIPAL` (SPEC-006 0.6.0, REQ-11, first HTTP route
19
+ * for a transition specified since v0.5.0). Gated by `user.manage`; refuses the seeded owner
20
+ * unconditionally and refuses any disable that would drop the active owner-`*` count to zero
21
+ * (INV-08) — see `server/admin-crud-service.ts`'s `disablePrincipal` for the full contract.
22
+ *
23
+ * `disablePrincipal` returns only the updated `PrincipalRecord` — the admin shape also needs the
24
+ * paired `UserRecord` (see `adminUserForPrincipal` for why that lookup is defensive).
25
+ */
26
+ export declare const userDisableRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
27
+ principalId: string;
28
+ }, {
29
+ user: AdminUserResponse;
30
+ }, UserDisableRouteDeps, UserRoutePrincipal>;
31
+ //# sourceMappingURL=disable.d.ts.map
@@ -0,0 +1,38 @@
1
+ import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
2
+ import { adminUserForPrincipal, hostRung, principalIdParam, rejectUserError, USER_FORBIDDEN, USER_NOT_FOUND, USER_OWNER_REQUIRED, USER_VALIDATION, userActorId, } from "./shared.js";
3
+ /** This route's ladder, in the hand-written order; the self-target rung is the host's class. @complexity O(1). */
4
+ function userDisableErrors({ deps }, _optional = {}) {
5
+ return [hostRung({ matches: deps.isSelfDeleteError, status: 409, code: "SELF_DELETE" }), USER_FORBIDDEN, USER_OWNER_REQUIRED, USER_VALIDATION, USER_NOT_FOUND];
6
+ }
7
+ /**
8
+ * POST users/:principalId/disable — `DISABLE_PRINCIPAL` (SPEC-006 0.6.0, REQ-11, first HTTP route
9
+ * for a transition specified since v0.5.0). Gated by `user.manage`; refuses the seeded owner
10
+ * unconditionally and refuses any disable that would drop the active owner-`*` count to zero
11
+ * (INV-08) — see `server/admin-crud-service.ts`'s `disablePrincipal` for the full contract.
12
+ *
13
+ * `disablePrincipal` returns only the updated `PrincipalRecord` — the admin shape also needs the
14
+ * paired `UserRecord` (see `adminUserForPrincipal` for why that lookup is defensive).
15
+ */
16
+ export const userDisableRoute = defineJsonRoute({
17
+ method: "post",
18
+ path: "/api/admin/v1/workspaces/:workspaceId/users/:principalId/disable",
19
+ parse: (raw) => ok({ value: { principalId: principalIdParam(raw.params) } }),
20
+ handle: async ({ input, deps, context }) => {
21
+ const callerPrincipalId = userActorId({ context });
22
+ const { workspaceId } = deps;
23
+ const { principalId } = input;
24
+ try {
25
+ const seededOwnerPrincipalId = await deps.ownerPrincipalId;
26
+ const services = deps.identityServices();
27
+ const { principal } = await services.repos.transactions.run({ workspaceId, execute: async () => {
28
+ await deps.assertUserAccountAction({ deps: services, workspaceId, principalId, action: "disable" }, { callerPrincipalId, seededOwnerPrincipalId });
29
+ return deps.disablePrincipal({ deps: services, input: { workspaceId, callerPrincipalId, principalId, seededOwnerPrincipalId } });
30
+ } });
31
+ return ok({ value: { user: await adminUserForPrincipal({ repos: services.repos, workspaceId, principal }) } });
32
+ }
33
+ catch (err) {
34
+ return rejectUserError({ err, rungs: userDisableErrors({ deps }) });
35
+ }
36
+ },
37
+ });
38
+ //# sourceMappingURL=disable.js.map
@@ -0,0 +1,32 @@
1
+ import type { enablePrincipal } from "../../../server/admin-crud-service.js";
2
+ import type { assertCallerHasAnyPermission } from "../../../server/grant-service.js";
3
+ import type { AdminUserResponse } from "../../http/users.js";
4
+ import { type AssertUserAccountActionFn, type HostErrorPredicate, type IdentityServicesFn, type IsInTrashFn, type UserRoutePrincipal } from "./shared.js";
5
+ /** The deps this route reads. */
6
+ export interface UserEnableRouteDeps {
7
+ workspaceId: string;
8
+ /** Identity service(s), injected: the admin-http entry may not reach the `server` source domain
9
+ * (subpath isolation); the host binds them from `@jini-ai/user-management/server`. */
10
+ enablePrincipal: typeof enablePrincipal;
11
+ assertCallerHasAnyPermission: typeof assertCallerHasAnyPermission;
12
+ identityServices: IdentityServicesFn;
13
+ isInTrash: IsInTrashFn;
14
+ /** The seeded (bootstrap) owner's principal id, resolved by the host at boot. */
15
+ ownerPrincipalId: PromiseLike<string> | string;
16
+ /** The host's account guard, run with action `enable` (B151): only an owner may re-enable an admin or owner. */
17
+ assertUserAccountAction: AssertUserAccountActionFn;
18
+ /** Matches the host's "user is in the Trash" error, which its Trash index may throw itself. */
19
+ isUserInTrashError: HostErrorPredicate;
20
+ }
21
+ /**
22
+ * POST users/:principalId/enable — `ENABLE_PRINCIPAL` (SPEC-006 0.6.0, REQ-15) — the symmetric
23
+ * re-activation `DISABLE_PRINCIPAL` never had a counterpart for. Gated by `user.manage`; target
24
+ * must be `kind='user'` (EC-14). See `adminUserForPrincipal` for why the paired-user lookup is
25
+ * defensive, not an expected runtime path.
26
+ */
27
+ export declare const userEnableRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
28
+ principalId: string;
29
+ }, {
30
+ user: AdminUserResponse;
31
+ }, UserEnableRouteDeps, UserRoutePrincipal>;
32
+ //# sourceMappingURL=enable.d.ts.map
@@ -0,0 +1,45 @@
1
+ import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
2
+ import { adminUserForPrincipal, principalIdParam, rejectUserError, rejectUserInTrash, USER_FORBIDDEN, USER_NOT_FOUND, USER_OWNER_REQUIRED, USER_VALIDATION, userActorId, hostRung, } from "./shared.js";
3
+ /** This route's ladder, in the hand-written order; the in-Trash rung is the host's class. @complexity O(1). */
4
+ function userEnableErrors({ deps }, _optional = {}) {
5
+ return [hostRung({ matches: deps.isUserInTrashError, status: 409, code: "USER_IN_TRASH" }), USER_FORBIDDEN, USER_VALIDATION, USER_NOT_FOUND, USER_OWNER_REQUIRED];
6
+ }
7
+ /**
8
+ * POST users/:principalId/enable — `ENABLE_PRINCIPAL` (SPEC-006 0.6.0, REQ-15) — the symmetric
9
+ * re-activation `DISABLE_PRINCIPAL` never had a counterpart for. Gated by `user.manage`; target
10
+ * must be `kind='user'` (EC-14). See `adminUserForPrincipal` for why the paired-user lookup is
11
+ * defensive, not an expected runtime path.
12
+ */
13
+ export const userEnableRoute = defineJsonRoute({
14
+ method: "post",
15
+ path: "/api/admin/v1/workspaces/:workspaceId/users/:principalId/enable",
16
+ parse: (raw) => ok({ value: { principalId: principalIdParam(raw.params) } }),
17
+ handle: async ({ input, deps, context }) => {
18
+ const callerPrincipalId = userActorId({ context });
19
+ const { workspaceId } = deps;
20
+ const { principalId } = input;
21
+ try {
22
+ // Trash membership is private too: use the identity owner's gate before looking it up.
23
+ const services = deps.identityServices();
24
+ await deps.assertCallerHasAnyPermission({ deps: services, workspaceId, callerPrincipalId, permissions: ["user.manage"] });
25
+ // OWNER DECISION 2026-09-24 (delete-user plan v2, decision 7) — refuse BEFORE the transition:
26
+ // re-activating a trashed principal would leave an ACTIVE user still indexed for purge. The
27
+ // refusal is not a rung, so `rejectUserError` rethrows it unchanged.
28
+ if (await deps.isInTrash({ principalId }))
29
+ rejectUserInTrash();
30
+ // B151 (owner rule 2026-11-20): only an owner may turn an admin or owner account back on —
31
+ // `user.manage` alone would let an admin undo the owner's disable. Same guard as disable.ts,
32
+ // in the same transaction as the write.
33
+ const seededOwnerPrincipalId = await deps.ownerPrincipalId;
34
+ const { principal } = await services.repos.transactions.run({ workspaceId, execute: async () => {
35
+ await deps.assertUserAccountAction({ deps: services, workspaceId, principalId, action: "enable" }, { callerPrincipalId, seededOwnerPrincipalId });
36
+ return deps.enablePrincipal({ deps: services, input: { workspaceId, callerPrincipalId, principalId } });
37
+ } });
38
+ return ok({ value: { user: await adminUserForPrincipal({ repos: services.repos, workspaceId, principal }) } });
39
+ }
40
+ catch (err) {
41
+ return rejectUserError({ err, rungs: userEnableErrors({ deps }) });
42
+ }
43
+ },
44
+ });
45
+ //# sourceMappingURL=enable.js.map
@@ -0,0 +1,18 @@
1
+ import type { PolicyRepoPort } from "../../../core/ports.js";
2
+ import { type AdminPolicyResponse } from "../../http/users.js";
3
+ import { type AccessRoutePrincipal } from "./access-shared.js";
4
+ /** The deps this route reads: the workspace and the policy list. */
5
+ export interface PolicyListRouteDeps {
6
+ workspaceId: string;
7
+ policyRepo: Pick<PolicyRepoPort, "list">;
8
+ }
9
+ /**
10
+ * GET policies — list a workspace's policies (built-in + custom) for the Users admin screen's
11
+ * policy picker. Gated by `role.manage`, mirroring `list-roles.ts`'s identical reasoning
12
+ * (`createPolicy` is also gated by `role.manage`, not a separate `policy.manage`; 2026-07-16
13
+ * authz sweep: this route previously had zero permission check beyond session auth).
14
+ */
15
+ export declare const policyListRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<Record<string, never>, {
16
+ policies: AdminPolicyResponse[];
17
+ }, PolicyListRouteDeps, AccessRoutePrincipal>;
18
+ //# sourceMappingURL=list-policies.d.ts.map
@@ -0,0 +1,20 @@
1
+ import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
2
+ import { toAdminPolicyResponse } from "../../http/users.js";
3
+ import { authorizeRoleManage } from "./access-shared.js";
4
+ /**
5
+ * GET policies — list a workspace's policies (built-in + custom) for the Users admin screen's
6
+ * policy picker. Gated by `role.manage`, mirroring `list-roles.ts`'s identical reasoning
7
+ * (`createPolicy` is also gated by `role.manage`, not a separate `policy.manage`; 2026-07-16
8
+ * authz sweep: this route previously had zero permission check beyond session auth).
9
+ */
10
+ export const policyListRoute = defineJsonRoute({
11
+ method: "get",
12
+ path: "/api/admin/v1/workspaces/:workspaceId/policies",
13
+ parse: () => ok({ value: {} }),
14
+ handle: async ({ deps, authorize }) => {
15
+ await authorizeRoleManage({ authorize });
16
+ const policies = await deps.policyRepo.list({ workspaceId: deps.workspaceId });
17
+ return ok({ value: { policies: policies.map(toAdminPolicyResponse) } });
18
+ },
19
+ });
20
+ //# sourceMappingURL=list-policies.js.map
@@ -0,0 +1,28 @@
1
+ import type { PolicyPermissionRepoPort, PolicyRepoPort } from "../../../core/ports.js";
2
+ import type { PolicyPermissionRecord } from "../../../core/types.js";
3
+ import { type AccessRoutePrincipal } from "./access-shared.js";
4
+ /** The deps this route reads: the workspace, the policy lookup and its permission rows. */
5
+ export interface PolicyPermissionListRouteDeps {
6
+ workspaceId: string;
7
+ policyRepo: Pick<PolicyRepoPort, "findById">;
8
+ policyPermissionRepo: Pick<PolicyPermissionRepoPort, "listByPolicyId">;
9
+ }
10
+ /**
11
+ * GET policies/:policyId/permissions — the permission rows written onto one policy (OQ-10).
12
+ *
13
+ * Nothing exposed these before: `toAdminPolicyResponse` carries `id`/`name`/`description`/
14
+ * `isBuiltin`/`isFrozen` and no permissions field, so the admin could POST a permission onto a
15
+ * policy but never see what a policy already held. That made `remove-policy-permission.ts`
16
+ * unusable on its own — a removal route needs an id, and this is the only route that yields one.
17
+ *
18
+ * Gated by `role.manage`, the same permission `list-policies.ts` requires (a policy's permission
19
+ * set is exactly as sensitive as the policy list itself), and checked with the same inline
20
+ * `deps.authorize` shape that file uses rather than the service-layer helper — this is a read, so
21
+ * there is no identity transition to call.
22
+ */
23
+ export declare const policyPermissionListRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
24
+ policyId: string;
25
+ }, {
26
+ policyPermissions: PolicyPermissionRecord[];
27
+ }, PolicyPermissionListRouteDeps, AccessRoutePrincipal>;
28
+ //# sourceMappingURL=list-policy-permissions.d.ts.map
@@ -0,0 +1,30 @@
1
+ import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
2
+ import { rejectRoute } from "@jini-ai/core/errors/route-refusal";
3
+ import { accessPathParam, authorizeRoleManage } from "./access-shared.js";
4
+ /**
5
+ * GET policies/:policyId/permissions — the permission rows written onto one policy (OQ-10).
6
+ *
7
+ * Nothing exposed these before: `toAdminPolicyResponse` carries `id`/`name`/`description`/
8
+ * `isBuiltin`/`isFrozen` and no permissions field, so the admin could POST a permission onto a
9
+ * policy but never see what a policy already held. That made `remove-policy-permission.ts`
10
+ * unusable on its own — a removal route needs an id, and this is the only route that yields one.
11
+ *
12
+ * Gated by `role.manage`, the same permission `list-policies.ts` requires (a policy's permission
13
+ * set is exactly as sensitive as the policy list itself), and checked with the same inline
14
+ * `deps.authorize` shape that file uses rather than the service-layer helper — this is a read, so
15
+ * there is no identity transition to call.
16
+ */
17
+ export const policyPermissionListRoute = defineJsonRoute({
18
+ method: "get",
19
+ path: "/api/admin/v1/workspaces/:workspaceId/policies/:policyId/permissions",
20
+ parse: (raw) => ok({ value: { policyId: accessPathParam({ params: raw.params, name: "policyId" }) } }),
21
+ handle: async ({ input, deps, authorize }) => {
22
+ await authorizeRoleManage({ authorize });
23
+ const policy = await deps.policyRepo.findById({ workspaceId: deps.workspaceId, id: input.policyId });
24
+ if (!policy)
25
+ rejectRoute({ status: 404, error: `policy '${input.policyId}' was not found`, code: "RESOURCE_NOT_FOUND" });
26
+ const policyPermissions = await deps.policyPermissionRepo.listByPolicyId({ workspaceId: deps.workspaceId, policyId: input.policyId });
27
+ return ok({ value: { policyPermissions } });
28
+ },
29
+ });
30
+ //# sourceMappingURL=list-policy-permissions.js.map
@@ -0,0 +1,18 @@
1
+ import type { RoleRepoPort } from "../../../core/ports.js";
2
+ import { type AdminRoleResponse } from "../../http/users.js";
3
+ import { type AccessRoutePrincipal } from "./access-shared.js";
4
+ /** The deps this route reads: the workspace and the role list. */
5
+ export interface RoleListRouteDeps {
6
+ workspaceId: string;
7
+ roleRepo: Pick<RoleRepoPort, "list">;
8
+ }
9
+ /**
10
+ * GET roles — list a workspace's roles (built-in + custom) for the Users admin screen's role
11
+ * picker. Gated by `role.manage` — matches `createRole`/`createPolicy`'s own gate (identity's
12
+ * `grant-service.ts`), since no separate `role.read` permission exists in the catalog (2026-07-16
13
+ * authz sweep: this route previously had zero permission check beyond session auth).
14
+ */
15
+ export declare const roleListRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<Record<string, never>, {
16
+ roles: AdminRoleResponse[];
17
+ }, RoleListRouteDeps, AccessRoutePrincipal>;
18
+ //# sourceMappingURL=list-roles.d.ts.map
@@ -0,0 +1,20 @@
1
+ import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
2
+ import { toAdminRoleResponse } from "../../http/users.js";
3
+ import { authorizeRoleManage } from "./access-shared.js";
4
+ /**
5
+ * GET roles — list a workspace's roles (built-in + custom) for the Users admin screen's role
6
+ * picker. Gated by `role.manage` — matches `createRole`/`createPolicy`'s own gate (identity's
7
+ * `grant-service.ts`), since no separate `role.read` permission exists in the catalog (2026-07-16
8
+ * authz sweep: this route previously had zero permission check beyond session auth).
9
+ */
10
+ export const roleListRoute = defineJsonRoute({
11
+ method: "get",
12
+ path: "/api/admin/v1/workspaces/:workspaceId/roles",
13
+ parse: () => ok({ value: {} }),
14
+ handle: async ({ deps, authorize }) => {
15
+ await authorizeRoleManage({ authorize });
16
+ const roles = await deps.roleRepo.list({ workspaceId: deps.workspaceId });
17
+ return ok({ value: { roles: roles.map(toAdminRoleResponse) } });
18
+ },
19
+ });
20
+ //# sourceMappingURL=list-roles.js.map
@@ -0,0 +1,40 @@
1
+ import type { AuthorizeFn } from "@jini-ai/core/contracts/events";
2
+ import type { AuthServiceDeps } from "../../../server/auth-service.js";
3
+ import type { AdminUserResponse } from "../../http/users.js";
4
+ import { type IdentityServicesFn, type IsInTrashFn, type UserRoutePrincipal } from "./shared.js";
5
+ /** The host's per-account protection flags the users screen shows (owner / protected admin account). */
6
+ export interface UserAccountProtection {
7
+ isOwner: boolean;
8
+ isProtectedAccount: boolean;
9
+ }
10
+ /** The host's account-protection read; it owns which accounts are protected. */
11
+ export type UserAccountProtectionFn = (required: {
12
+ deps: AuthServiceDeps;
13
+ workspaceId: string;
14
+ principalId: string;
15
+ }, optional?: Record<string, never>) => Promise<UserAccountProtection>;
16
+ /** The deps this route reads. */
17
+ export interface UserListRouteDeps {
18
+ workspaceId: string;
19
+ /** The host's raw RBAC decision (`{ allowed, reason }`), asked directly: this route's "either of
20
+ * two permissions" rule and its combined 403 body do not fit the single-permission authorize port. */
21
+ decidePermission: AuthorizeFn;
22
+ identityServices: IdentityServicesFn;
23
+ isInTrash: IsInTrashFn;
24
+ /** The seeded (bootstrap) owner's principal id, resolved by the host at boot. */
25
+ ownerPrincipalId: PromiseLike<string> | string;
26
+ userAccountProtection: UserAccountProtectionFn;
27
+ }
28
+ /** One listed user: the host's protection flags, the rename affordance, then the admin user fields. */
29
+ export type AdminUserListEntry = UserAccountProtection & {
30
+ canRename: boolean;
31
+ } & AdminUserResponse;
32
+ /**
33
+ * GET users — list a workspace's human (`kind='user'`) principals for the admin UI. No dedicated
34
+ * `listUsers` business-logic function exists in this package's server services (they export
35
+ * grant-writing mutations, not read-side wrappers) — this route calls the repo ports directly.
36
+ */
37
+ export declare const userListRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<Record<string, never>, {
38
+ users: AdminUserListEntry[];
39
+ }, UserListRouteDeps, UserRoutePrincipal>;
40
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1,82 @@
1
+ import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
2
+ import { rejectRoute } from "@jini-ai/core/errors/route-refusal";
3
+ import { adminUserWithGrants, userActorId } from "./shared.js";
4
+ /**
5
+ * Gated by `user.manage`/`member.manage` (either) for this read-only roster; operator creation
6
+ * separately requires `user.manage`. No separate `user.read` permission exists in the catalog.
7
+ * 2026-07-16 authz sweep: this route previously had zero permission check beyond session auth,
8
+ * letting any authenticated admin session read the full user roster regardless of role.
9
+ * Both decisions are asked (in parallel, as before); the refusal names `user.manage`'s reason.
10
+ * @complexity O(1) plus two injected decisions.
11
+ */
12
+ async function authorizeUserRoster({ deps, principalId }, _optional = {}) {
13
+ const [userManage, memberManage] = await Promise.all([
14
+ deps.decidePermission({ principalId, permission: "user.manage", workspaceId: deps.workspaceId }),
15
+ deps.decidePermission({ principalId, permission: "member.manage", workspaceId: deps.workspaceId }),
16
+ ]);
17
+ if (userManage.allowed || memberManage.allowed)
18
+ return;
19
+ rejectRoute({
20
+ status: 403,
21
+ error: `principal '${principalId}' is not authorized for 'user.manage' or 'member.manage' (${userManage.reason})`,
22
+ code: "FORBIDDEN",
23
+ details: { permission: "user.manage", reason: userManage.reason },
24
+ });
25
+ }
26
+ /**
27
+ * Non-human principals (`system`, `agent`, `api_key` — including the disabled legacy `user-local`
28
+ * seed row) are filtered out: this screen is "Users" (human operators), not the full roster.
29
+ * @complexity O(n) Trash lookups, n = principal count.
30
+ */
31
+ async function listedHumanPrincipals({ deps, repos }, _optional = {}) {
32
+ const principals = await repos.principals.list({ workspaceId: deps.workspaceId });
33
+ const entries = await Promise.all(principals
34
+ .filter((principal) => principal.kind === "user")
35
+ .map(async (principal) => ({
36
+ principal,
37
+ // OWNER DECISION 2026-09-24 (delete-user plan v2, decision 7's list side): a user
38
+ // trashed via DELETE_USER is `status:'disabled'` plus a `trashed_items` row — this
39
+ // screen must not list them as an ordinary disabled user, since restoring them here
40
+ // means EnablePrincipal, not the Trash's own restore. An intentionally-disabled user
41
+ // (never trashed) has no `trashed_items` row and stays listed.
42
+ trashed: principal.status === "disabled" && (await deps.isInTrash({ principalId: principal.id })),
43
+ })));
44
+ return entries.filter((entry) => !entry.trashed).map((entry) => entry.principal);
45
+ }
46
+ /** One roster row, or `null` for a principal without its paired users row. @complexity O(1) plus four reads. */
47
+ async function listEntry({ deps, services, principal, seededOwnerPrincipalId }, _optional = {}) {
48
+ const user = await services.repos.users.findByPrincipalId({ workspaceId: deps.workspaceId, principalId: principal.id });
49
+ // Every kind='user' principal has a paired users row by construction
50
+ // (CREATE_USER/SEED_FIRST_BOOT's atomicity guarantee) — this null
51
+ // check is defensive, not an expected runtime path.
52
+ if (!user)
53
+ return null;
54
+ const response = await adminUserWithGrants({ repos: services.repos, workspaceId: deps.workspaceId, principal, user });
55
+ const protection = await deps.userAccountProtection({ deps: deps.identityServices(), workspaceId: deps.workspaceId, principalId: principal.id });
56
+ // The bootstrap owner is still found by login at reboot; offer rename only when safe.
57
+ return { ...protection, canRename: principal.id !== seededOwnerPrincipalId, ...response };
58
+ }
59
+ /**
60
+ * GET users — list a workspace's human (`kind='user'`) principals for the admin UI. No dedicated
61
+ * `listUsers` business-logic function exists in this package's server services (they export
62
+ * grant-writing mutations, not read-side wrappers) — this route calls the repo ports directly.
63
+ */
64
+ export const userListRoute = defineJsonRoute({
65
+ method: "get",
66
+ path: "/api/admin/v1/workspaces/:workspaceId/users",
67
+ parse: () => ok({ value: {} }),
68
+ handle: async ({ deps, context }) => {
69
+ await authorizeUserRoster({ deps, principalId: userActorId({ context }) });
70
+ const services = deps.identityServices();
71
+ const principals = await listedHumanPrincipals({ deps, repos: services.repos });
72
+ const seededOwnerPrincipalId = await deps.ownerPrincipalId;
73
+ // O(n) repo round trips, n = human principal count. Unbounded by a caller-controlled
74
+ // collection (this is an operator-managed roster, not member/content scale — the same
75
+ // assumption `resolveEffectivePermissions` already makes) — no cap needed this pass; a future
76
+ // pagination pass would mirror `MemberRepoPort.list`'s afterId/limit shape if this workspace's
77
+ // operator count ever grows unexpectedly large.
78
+ const users = await Promise.all(principals.map((principal) => listEntry({ deps, services, principal, seededOwnerPrincipalId })));
79
+ return ok({ value: { users: users.filter((user) => user !== null) } });
80
+ },
81
+ });
82
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1,48 @@
1
+ import { type RouteReply } from "@jini-ai/core/contracts/server";
2
+ import type { IdentityTransactionPort, PolicyPermissionRepoPort } from "../../../core/ports.js";
3
+ import type { removePolicyPermission } from "../../../server/admin-crud-service.js";
4
+ import type { AuthServiceDeps } from "../../../server/auth-service.js";
5
+ import { type AccessRoutePrincipal, type AccessServiceRouteDeps } from "./access-shared.js";
6
+ /** The host's owner test: does this principal hold the unconstrained `*` grant? (The host owns who is an owner.) */
7
+ export type PrincipalHoldsOwnerWildcardFn = (required: {
8
+ deps: AuthServiceDeps;
9
+ workspaceId: string;
10
+ principalId: string;
11
+ }, optional?: Record<string, never>) => Promise<boolean>;
12
+ /** The host's post-write invariant: throws `OwnerRequiredError` when no active owner would remain. */
13
+ export type AssertActiveOwnerFloorFn = (required: {
14
+ deps: AuthServiceDeps;
15
+ workspaceId: string;
16
+ }, optional?: Record<string, never>) => Promise<void>;
17
+ /** The deps this route reads. */
18
+ export interface PolicyPermissionRemoveRouteDeps extends AccessServiceRouteDeps {
19
+ transactions: Pick<IdentityTransactionPort, "run">;
20
+ policyPermissionRepo: Pick<PolicyPermissionRepoPort, "listByPolicyId">;
21
+ /** Injected: the service lives in the node `./server` entry; the host binds it. */
22
+ removePolicyPermission: typeof removePolicyPermission;
23
+ principalHoldsOwnerWildcard: PrincipalHoldsOwnerWildcardFn;
24
+ assertActiveOwnerFloor: AssertActiveOwnerFloorFn;
25
+ }
26
+ interface RemoveInput {
27
+ policyId: string;
28
+ policyPermissionId: string;
29
+ }
30
+ /**
31
+ * DELETE policies/:policyId/permissions/:policyPermissionId — `REMOVE_POLICY_PERMISSION` (OQ-10),
32
+ * the inverse of `write-policy-permission.ts` and the route that closes the gap `Roles.tsx`'s own
33
+ * header comment flagged: until now a policy's permission set was append-only, and the only way to
34
+ * shrink it was `DELETE_POLICY` + recreate — which INV-09 refuses outright the moment any role or
35
+ * principal references the policy.
36
+ *
37
+ * Gated by `role.manage`, exactly as the ADD route is. A built-in or frozen parent policy is
38
+ * refused `VALIDATION_ERROR` (INV-06/AC-26); a permission id that is absent — or that belongs to a
39
+ * different policy — is `RESOURCE_NOT_FOUND`, never a silent no-op success (the service proves
40
+ * membership from the policy's own rows before deleting).
41
+ *
42
+ * Returns 204, matching `delete-policy.ts`'s convention for a delete with nothing to echo back —
43
+ * as an explicit bodiless `routeReply`, so the host writes a bare `send()` (the hand-written
44
+ * route's `res.status(204).send()`), never a JSON body.
45
+ */
46
+ export declare const policyPermissionRemoveRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<RemoveInput, RouteReply<unknown>, PolicyPermissionRemoveRouteDeps, AccessRoutePrincipal>;
47
+ export {};
48
+ //# sourceMappingURL=remove-policy-permission.d.ts.map