@jini-ai/user-management 0.7.3-next.2 → 0.7.4

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 (380) hide show
  1. package/CHANGELOG.md +7 -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 +283 -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 +83 -0
  252. package/dist/newsletter/repo-subscribers.js +215 -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 +202 -0
  256. package/dist/newsletter/repo.memory.js +260 -0
  257. package/dist/newsletter/repo.rows.d.ts +221 -0
  258. package/dist/newsletter/repo.rows.js +260 -0
  259. package/dist/newsletter/save-guard.d.ts +32 -0
  260. package/dist/newsletter/save-guard.js +27 -0
  261. package/dist/newsletter/send-pipeline.d.ts +240 -0
  262. package/dist/newsletter/send-pipeline.js +514 -0
  263. package/dist/newsletter/subscriptions.d.ts +87 -0
  264. package/dist/newsletter/subscriptions.js +119 -0
  265. package/dist/newsletter/tool-registrations.d.ts +89 -0
  266. package/dist/newsletter/tool-registrations.deps.d.ts +9 -0
  267. package/dist/newsletter/tool-registrations.deps.js +9 -0
  268. package/dist/newsletter/tool-registrations.js +133 -0
  269. package/dist/newsletter/tool-registrations.read.d.ts +76 -0
  270. package/dist/newsletter/tool-registrations.read.js +140 -0
  271. package/dist/newsletter/tool-registrations.write.d.ts +54 -0
  272. package/dist/newsletter/tool-registrations.write.js +229 -0
  273. package/dist/newsletter/types.d.ts +279 -0
  274. package/dist/newsletter/types.js +23 -0
  275. package/dist/newsletter/unsubscribe.d.ts +41 -0
  276. package/dist/newsletter/unsubscribe.js +100 -0
  277. package/dist/project-keys/attached-vault.d.ts +23 -0
  278. package/dist/project-keys/attached-vault.js +65 -0
  279. package/dist/project-keys/create-vault.d.ts +17 -0
  280. package/dist/project-keys/create-vault.js +29 -0
  281. package/dist/project-keys/service.d.ts +133 -0
  282. package/dist/project-keys/service.js +128 -0
  283. package/dist/project-keys/site-references.d.ts +30 -0
  284. package/dist/project-keys/site-references.js +63 -0
  285. package/dist/project-keys/site-sealer.d.ts +28 -0
  286. package/dist/project-keys/site-sealer.js +64 -0
  287. package/dist/project-keys/sql/attachments.d.ts +33 -0
  288. package/dist/project-keys/sql/attachments.js +55 -0
  289. package/dist/project-keys/tools.d.ts +86 -0
  290. package/dist/project-keys/tools.js +66 -0
  291. package/dist/public-http/routes/mail/feedback.d.ts +44 -0
  292. package/dist/public-http/routes/mail/feedback.js +17 -0
  293. package/dist/public-http/routes/newsletter/confirm.d.ts +38 -0
  294. package/dist/public-http/routes/newsletter/confirm.js +33 -0
  295. package/dist/public-http/routes/newsletter/page.d.ts +29 -0
  296. package/dist/public-http/routes/newsletter/page.js +34 -0
  297. package/dist/public-http/routes/newsletter/unsubscribe.d.ts +33 -0
  298. package/dist/public-http/routes/newsletter/unsubscribe.js +35 -0
  299. package/dist/react/auth/Passkeys.d.ts +2 -34
  300. package/dist/react/auth/RecoveryCodesCard.d.ts +27 -0
  301. package/dist/react/auth/RecoveryCodesCard.hooks.d.ts +67 -0
  302. package/dist/react/auth/RecoveryCodesCard.hooks.js +38 -0
  303. package/dist/react/auth/RecoveryCodesCard.js +56 -0
  304. package/dist/react/auth/TotpSettings.d.ts +2 -23
  305. package/dist/react/auth/local-owner-signin.d.ts +40 -0
  306. package/dist/react/auth/local-owner-signin.js +25 -0
  307. package/dist/react/auth/owner-mfa-api.d.ts +10 -0
  308. package/dist/react/auth/owner-mfa-api.js +17 -0
  309. package/dist/react/auth/owner-passkey-api.d.ts +11 -0
  310. package/dist/react/auth/owner-passkey-api.js +17 -0
  311. package/dist/react/auth/owner-recovery-api.d.ts +51 -0
  312. package/dist/react/auth/owner-recovery-api.js +29 -0
  313. package/dist/react/auth/owner-request.d.ts +7 -0
  314. package/dist/react/auth/owner-request.js +2 -0
  315. package/dist/react/index.d.ts +10 -0
  316. package/dist/react/index.js +6 -0
  317. package/dist/react/mail/Email.d.ts +20 -0
  318. package/dist/react/mail/Email.js +143 -0
  319. package/dist/react/mail/EmailProviderTab.d.ts +34 -0
  320. package/dist/react/mail/EmailProviderTab.js +132 -0
  321. package/dist/react/mail/EmailSegments.d.ts +24 -0
  322. package/dist/react/mail/EmailSegments.js +15 -0
  323. package/dist/react/mail/EmailTemplateEditor.d.ts +146 -0
  324. package/dist/react/mail/EmailTemplateEditor.js +116 -0
  325. package/dist/react/mail/email-view.types.d.ts +236 -0
  326. package/dist/react/mail/email-view.types.js +2 -0
  327. package/dist/react/members/Members.d.ts +5 -3
  328. package/dist/react/members/Members.js +3 -3
  329. package/dist/react/members/api/members-api.d.ts +37 -0
  330. package/dist/react/members/api/members-api.js +16 -0
  331. package/dist/react/members/hooks/use-members.hooks.js +2 -1
  332. package/dist/react/members/members-i18n.d.ts +23 -0
  333. package/dist/react/members/members-i18n.js +25 -0
  334. package/dist/react/members/members-i18n.locales-a.d.ts +4 -0
  335. package/dist/react/members/members-i18n.locales-a.js +294 -0
  336. package/dist/react/members/members-i18n.locales-b.d.ts +4 -0
  337. package/dist/react/members/members-i18n.locales-b.js +265 -0
  338. package/dist/react/models.d.ts +1 -49
  339. package/dist/react/ports.d.ts +3 -143
  340. package/dist/react/roles/api/roles-api.d.ts +74 -0
  341. package/dist/react/roles/api/roles-api.js +22 -0
  342. package/dist/react/testing.js +18 -9
  343. package/dist/react/users/UsersPanel.d.ts +30 -0
  344. package/dist/react/users/UsersPanel.hooks.d.ts +8 -0
  345. package/dist/react/users/UsersPanel.hooks.js +9 -0
  346. package/dist/react/users/UsersPanel.js +9 -0
  347. package/dist/react/users/api/users-api.d.ts +65 -0
  348. package/dist/react/users/api/users-api.js +46 -0
  349. package/dist/react/users/hooks/use-localized-users.hooks.d.ts +43 -0
  350. package/dist/react/users/hooks/use-localized-users.hooks.js +15 -0
  351. package/dist/react/users/hooks/use-users-state.hooks.d.ts +18 -18
  352. package/dist/react/users/password-reset-notice.d.ts +8 -0
  353. package/dist/react/users/password-reset-notice.js +36 -0
  354. package/dist/server/admin-crud-service.d.ts +4 -10
  355. package/dist/server/admin-crud-service.js +20 -6
  356. package/dist/server/agent-tool-registrations.js +26 -7
  357. package/dist/server/agent-tools.js +22 -7
  358. package/dist/server/auth-challenge.d.ts +1 -1
  359. package/dist/server/auth-service.js +2 -1
  360. package/dist/server/grant-service.d.ts +1 -0
  361. package/dist/server/grant-service.js +7 -4
  362. package/dist/server/mfa/passkey-service.d.ts +2 -2
  363. package/dist/server/mfa/passkey-service.js +1 -1
  364. package/dist/server/mfa/service.js +6 -4
  365. package/dist/server/repo.memory.d.ts +30 -2
  366. package/dist/server/repo.memory.js +58 -4
  367. package/dist/server/seed.js +3 -3
  368. package/dist/server/sql/assignments.d.ts +90 -0
  369. package/dist/server/sql/assignments.js +128 -0
  370. package/dist/server/sql/index.d.ts +6 -0
  371. package/dist/server/sql/index.js +5 -0
  372. package/dist/server/sql/kernel.d.ts +9 -0
  373. package/dist/server/sql/kernel.js +2 -0
  374. package/dist/server/sql/mfa.d.ts +36 -0
  375. package/dist/server/sql/mfa.js +51 -0
  376. package/dist/server/sql/passkeys.d.ts +25 -0
  377. package/dist/server/sql/passkeys.js +33 -0
  378. package/dist/server/sql/recovery-codes.d.ts +22 -0
  379. package/dist/server/sql/recovery-codes.js +32 -0
  380. package/package.json +909 -11
@@ -0,0 +1,38 @@
1
+ import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
2
+ import { toApiKeyIssueResponse } from "../../http/api-keys.js";
3
+ import { rejectUserError, userActorId } from "../users/shared.js";
4
+ import { API_KEY_ERRORS, apiKeyBody } from "./shared.js";
5
+ /**
6
+ * POST api-keys — `APIKEY_ISSUE` (api.spec §1, state.spec §3 `ISSUE_API_KEY`). Issues a key bound
7
+ * to a grantless `kind='api_key'` principal, snapshotting the requested policies into a frozen,
8
+ * machine-owned policy that a later `WRITE_POLICY_PERMISSION` can never widen (F-054-01).
9
+ *
10
+ * **This is the only response in the admin API that contains a live secret.** `rawKey` is produced
11
+ * by `issueApiKey` in memory and returned once; the row it writes holds a scrypt digest of the
12
+ * secret half only, so no subsequent read of any table can reproduce it (INV-05). Nothing in this
13
+ * handler logs the response body.
14
+ *
15
+ * Gated by `apikey.manage` plus the INV-07 issuance clamp, both enforced inside `issueApiKey`.
16
+ */
17
+ export const apiKeyIssueRoute = defineJsonRoute({
18
+ method: "post",
19
+ path: "/api/admin/v1/api-keys",
20
+ parse: (raw) => {
21
+ const body = apiKeyBody(raw);
22
+ return ok({ value: { principalId: body?.principalId, label: body?.label, policyIds: body?.policyIds, expiresAt: body?.expiresAt } });
23
+ },
24
+ handle: async ({ input, deps, context }) => {
25
+ try {
26
+ const callerPrincipalId = userActorId({ context });
27
+ const { apiKey, rawKey } = await deps.issueApiKey({
28
+ deps: deps.apiKeyServices(),
29
+ input: { workspaceId: deps.workspaceId, callerPrincipalId, principalId: input.principalId, label: input.label, policyIds: input.policyIds, expiresAt: input.expiresAt },
30
+ });
31
+ return ok({ value: { apiKey: toApiKeyIssueResponse({ apiKey, rawKey }) } });
32
+ }
33
+ catch (err) {
34
+ return rejectUserError({ err, rungs: API_KEY_ERRORS });
35
+ }
36
+ },
37
+ }, { successStatus: 201 });
38
+ //# sourceMappingURL=issue.js.map
@@ -0,0 +1,26 @@
1
+ import type { revokeApiKey } from "../../../identity/api-key-service.js";
2
+ import { type UserRoutePrincipal } from "../users/shared.js";
3
+ import { type ApiKeyServicesFn } from "./shared.js";
4
+ /** The deps this route reads. */
5
+ export interface ApiKeyRevokeRouteDeps {
6
+ workspaceId: string;
7
+ apiKeyServices: ApiKeyServicesFn;
8
+ /** Injected service (subpath isolation); the host binds it from `@jini-ai/user-management/identity/api-key-service`. */
9
+ revokeApiKey: typeof revokeApiKey;
10
+ }
11
+ /**
12
+ * POST api-keys/:id/revoke — `APIKEY_REVOKE` (api.spec §1, state.spec §3 `REVOKE_API_KEY`).
13
+ * Revocation takes effect immediately: `authenticateApiKey` reads `revokedAt` on every request, so
14
+ * the next request presenting the key is rejected with no cache to wait out.
15
+ *
16
+ * Idempotent by design — re-revoking an already-revoked key is a 204, not a 409, so a client that
17
+ * retries a timed-out revoke never has to distinguish "it worked" from "it already had".
18
+ *
19
+ * 204 with no body (api.spec §3), mirroring `users/reset-password.ts`. The `?? ""` fallback on the
20
+ * `:id` segment is kept: the host router always fills a matched param, but a direct handler call can omit it
21
+ * and must still answer the ordinary not-found.
22
+ */
23
+ export declare const apiKeyRevokeRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
24
+ keyId: string;
25
+ }, undefined, ApiKeyRevokeRouteDeps, UserRoutePrincipal>;
26
+ //# sourceMappingURL=revoke.d.ts.map
@@ -0,0 +1,31 @@
1
+ import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
2
+ import { rejectUserError, userActorId } from "../users/shared.js";
3
+ import { API_KEY_ERRORS } from "./shared.js";
4
+ /**
5
+ * POST api-keys/:id/revoke — `APIKEY_REVOKE` (api.spec §1, state.spec §3 `REVOKE_API_KEY`).
6
+ * Revocation takes effect immediately: `authenticateApiKey` reads `revokedAt` on every request, so
7
+ * the next request presenting the key is rejected with no cache to wait out.
8
+ *
9
+ * Idempotent by design — re-revoking an already-revoked key is a 204, not a 409, so a client that
10
+ * retries a timed-out revoke never has to distinguish "it worked" from "it already had".
11
+ *
12
+ * 204 with no body (api.spec §3), mirroring `users/reset-password.ts`. The `?? ""` fallback on the
13
+ * `:id` segment is kept: the host router always fills a matched param, but a direct handler call can omit it
14
+ * and must still answer the ordinary not-found.
15
+ */
16
+ export const apiKeyRevokeRoute = defineJsonRoute({
17
+ method: "post",
18
+ path: "/api/admin/v1/api-keys/:id/revoke",
19
+ parse: (raw) => ok({ value: { keyId: String(raw.params.id ?? "") } }),
20
+ handle: async ({ input, deps, context }) => {
21
+ try {
22
+ const callerPrincipalId = userActorId({ context });
23
+ await deps.revokeApiKey({ deps: deps.apiKeyServices(), input: { workspaceId: deps.workspaceId, callerPrincipalId, keyId: input.keyId } });
24
+ return ok({ value: undefined });
25
+ }
26
+ catch (err) {
27
+ return rejectUserError({ err, rungs: API_KEY_ERRORS });
28
+ }
29
+ },
30
+ }, { successStatus: 204 });
31
+ //# sourceMappingURL=revoke.js.map
@@ -0,0 +1,46 @@
1
+ import type { ApiKeyServiceDeps } from "../../../identity/api-key-service.js";
2
+ import { type UserErrorRung } from "../users/shared.js";
3
+ /**
4
+ * @file Shared pieces of the three api-key admin route specs (principal create, issue, revoke).
5
+ *
6
+ * The hand-written routes shared one `sendApiKeyError` ladder because all three throw from the same
7
+ * service module and errors.spec.md gives them the same codes; {@link API_KEY_ERRORS} keeps that
8
+ * ladder, in its order, as rungs `rejectUserError` maps. Anything unmapped is rethrown to the host's
9
+ * redacted-500 port. The service functions and their deps bag are injected (subpath isolation: the
10
+ * admin-http entry does not reach the `identity` service implementation).
11
+ */
12
+ /** Builds the api-key service deps bag per request (the host's assembler over its repo fields). */
13
+ export type ApiKeyServicesFn = (required?: Record<string, never>) => ApiKeyServiceDeps;
14
+ /**
15
+ * **The no-escalation guard.** All three operations in this family are `security:
16
+ * [{ adminSessionCookie: [] }]` in `openapi/006-identity-and-authorization.yaml`: a human admin
17
+ * session mints, issues, and revokes keys — an API key may not. Without this, any key holding
18
+ * `apikey.manage` could issue itself a successor, and revoking the original would not end the
19
+ * caller's access; key issuance would be a privilege-escalation primitive rather than a delegation
20
+ * of authority a human can withdraw.
21
+ *
22
+ * Runs BEFORE the request body is read and before any existence check, so an api_key caller learns
23
+ * nothing about whether a target exists.
24
+ *
25
+ * @returns `true` when the request may proceed. On `false` the 403 has already been sent.
26
+ * @complexity O(1).
27
+ * @overallScore 100
28
+ */
29
+ export declare const API_KEY_SESSION_CREDENTIAL_GATE: {
30
+ readonly message: "api-key credentials may not manage api keys; use an admin session";
31
+ readonly permission: "apikey.manage";
32
+ };
33
+ /**
34
+ * Maps this family's thrown error types onto the admin error envelope. Shared by all three routes
35
+ * because all three throw from the same service module and errors.spec.md gives them the same
36
+ * codes (mirrors `users/attach-policy.ts`'s `sendAttachPolicyError`, one level up).
37
+ *
38
+ * @complexity O(1).
39
+ * @overallScore 100
40
+ */
41
+ export declare const API_KEY_ERRORS: readonly UserErrorRung[];
42
+ /** The request body as the hand-written routes read it (`req.body?.<field>`), never assumed an object. @complexity O(1). */
43
+ export declare function apiKeyBody(raw: {
44
+ body?: unknown;
45
+ }): Record<string, unknown> | undefined;
46
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1,38 @@
1
+ import { USER_FORBIDDEN, USER_GRANT_EXCEEDS_ISSUER, USER_NOT_FOUND, USER_VALIDATION } from "../users/shared.js";
2
+ /**
3
+ * **The no-escalation guard.** All three operations in this family are `security:
4
+ * [{ adminSessionCookie: [] }]` in `openapi/006-identity-and-authorization.yaml`: a human admin
5
+ * session mints, issues, and revokes keys — an API key may not. Without this, any key holding
6
+ * `apikey.manage` could issue itself a successor, and revoking the original would not end the
7
+ * caller's access; key issuance would be a privilege-escalation primitive rather than a delegation
8
+ * of authority a human can withdraw.
9
+ *
10
+ * Runs BEFORE the request body is read and before any existence check, so an api_key caller learns
11
+ * nothing about whether a target exists.
12
+ *
13
+ * @returns `true` when the request may proceed. On `false` the 403 has already been sent.
14
+ * @complexity O(1).
15
+ * @overallScore 100
16
+ */
17
+ // Moved from the hand-written guard: the host now enforces it as its session-credential-only mount
18
+ // gate with this copy (the 403 message and the permission it names), so the `@returns` above describes
19
+ // that gate's admit/refuse outcome.
20
+ export const API_KEY_SESSION_CREDENTIAL_GATE = {
21
+ message: "api-key credentials may not manage api keys; use an admin session",
22
+ permission: "apikey.manage",
23
+ };
24
+ /**
25
+ * Maps this family's thrown error types onto the admin error envelope. Shared by all three routes
26
+ * because all three throw from the same service module and errors.spec.md gives them the same
27
+ * codes (mirrors `users/attach-policy.ts`'s `sendAttachPolicyError`, one level up).
28
+ *
29
+ * @complexity O(1).
30
+ * @overallScore 100
31
+ */
32
+ // The ladder as the rung list `rejectUserError` maps, in the hand-written order.
33
+ export const API_KEY_ERRORS = [USER_FORBIDDEN, USER_GRANT_EXCEEDS_ISSUER, USER_VALIDATION, USER_NOT_FOUND];
34
+ /** The request body as the hand-written routes read it (`req.body?.<field>`), never assumed an object. @complexity O(1). */
35
+ export function apiKeyBody(raw) {
36
+ return (raw.body ?? undefined);
37
+ }
38
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1,103 @@
1
+ import type { JsonRouteAuthorize } from "@jini-ai/core/contracts/server";
2
+ import type { AuthServiceDeps } from "../../../server/auth-service.js";
3
+ /**
4
+ * @file Shared guards and error mapping for the role/policy admin route specs (the users family's
5
+ * access half: roles, policies and a policy's permission rows).
6
+ *
7
+ * Every write here is authorized by the identity service itself (`role.manage`, checked inside
8
+ * `createRole`/`updatePolicy`/…), never by the route — so these specs ask the host's `authorize`
9
+ * port nothing; a refusal arrives as `IdentityForbiddenError` and maps to the same 403 body the
10
+ * hand-written routes wrote. Each hand-written route had its own `instanceof` ladder; each spec
11
+ * keeps its exact ladder (same rungs, same order) as a small mapping list, and anything unmapped is
12
+ * rethrown so the host answers it as its redacted 500.
13
+ */
14
+ /** The principal fields these routes read: only the id, as the identity transition's caller. */
15
+ export interface AccessRoutePrincipal {
16
+ id: string;
17
+ }
18
+ /**
19
+ * Assembles the identity services' deps bag. Injected as a thunk because the bag is the host's
20
+ * (it binds the host's rename port among others) and the hand-written routes assembled it per
21
+ * request, inside their `try` — a failure assembling it is therefore mapped/500'd like any other.
22
+ */
23
+ export type IdentityServiceDepsFn = () => AuthServiceDeps;
24
+ /** The two fields every service-backed role/policy route reads. */
25
+ export interface AccessServiceRouteDeps {
26
+ workspaceId: string;
27
+ identityServiceDeps: IdentityServiceDepsFn;
28
+ }
29
+ /** One `catch` rung: which thrown error it matches and the exact refusal it answers. */
30
+ export interface AccessErrorMapping {
31
+ readonly matches: (required: {
32
+ err: unknown;
33
+ }, optional?: Record<string, never>) => boolean;
34
+ readonly respond: (required: {
35
+ err: unknown;
36
+ }, optional?: Record<string, never>) => {
37
+ status: number;
38
+ body: Record<string, unknown>;
39
+ };
40
+ }
41
+ export declare const ACCESS_FORBIDDEN: AccessErrorMapping;
42
+ export declare const ACCESS_VALIDATION: AccessErrorMapping;
43
+ export declare const ACCESS_NOT_FOUND: AccessErrorMapping;
44
+ export declare const ACCESS_GRANT_EXCEEDS_ISSUER: AccessErrorMapping;
45
+ /** A stale editor basis: someone saved the record after this caller opened it. */
46
+ export declare const ACCESS_VERSION_CONFLICT: AccessErrorMapping;
47
+ /**
48
+ * The optional `expectedVersion` an identity editor PATCH carries. Absent stays absent (legacy
49
+ * clients keep working); present must be a non-negative integer, else `400 VALIDATION_ERROR` —
50
+ * a mistyped basis is never read as "no basis". @complexity O(1).
51
+ */
52
+ export declare function accessExpectedVersion({ value }: {
53
+ value: unknown;
54
+ }, _optional?: Record<string, never>): number | undefined;
55
+ export declare const ACCESS_OWNER_REQUIRED: AccessErrorMapping;
56
+ /** A still-referenced delete target (INV-09): 409 naming the id field the client sent. @complexity O(1). */
57
+ export declare function accessConflictOn({ field }: {
58
+ field: string;
59
+ }, _optional?: Record<string, never>): AccessErrorMapping;
60
+ /** An unregistered permission: 400 echoing the permission exactly as the client sent it (raw, not
61
+ * coerced — an absent one drops out of the JSON, as `req.body?.permission` did). @complexity O(1). */
62
+ export declare function accessPermissionUnknown({ requested }: {
63
+ requested: unknown;
64
+ }, _optional?: Record<string, never>): AccessErrorMapping;
65
+ /**
66
+ * Refuses with the first matching rung; anything unmapped is rethrown unchanged so the host's error
67
+ * port answers it as an unexpected (redacted) failure under the route's own operation copy.
68
+ * @complexity O(n) in the mapping list length, a small fixed list per route.
69
+ */
70
+ export declare function rejectAccessError({ err, mappings }: {
71
+ err: unknown;
72
+ mappings: readonly AccessErrorMapping[];
73
+ }, _optional?: Record<string, never>): never;
74
+ /**
75
+ * The role/policy READ routes (list-roles, list-policies, list-policy-permissions) are the
76
+ * exception to "the service owns the gate": they have no identity transition to call, so they ask
77
+ * the host's `authorize` port for `role.manage` themselves — with no `entityType` and no entity
78
+ * scope, exactly the params the hand-written `deps.authorize` call sent. A mount without an
79
+ * authorizer is a wiring bug, so it fails closed. @complexity O(1) plus the injected authorizer.
80
+ */
81
+ export declare function authorizeRoleManage({ authorize }: {
82
+ authorize: JsonRouteAuthorize | undefined;
83
+ }, _optional?: Record<string, never>): Promise<void>;
84
+ /** The authenticated caller's id. A missing principal is a wiring bug (the host mounts these behind
85
+ * its session), so it fails closed as an unexpected failure, as `getAuthedPrincipal` did. @complexity O(1). */
86
+ export declare function accessActorId({ context }: {
87
+ context: AccessRoutePrincipal | undefined;
88
+ }, _optional?: Record<string, never>): string;
89
+ /** One path segment; Express always fills it, the `?? ""` keeps the hand-written guard (an absent id
90
+ * becomes an honest not-found from the service, never a wildcard). @complexity O(1). */
91
+ export declare function accessPathParam({ params, name }: {
92
+ params: Record<string, string | undefined>;
93
+ name: string;
94
+ }, _optional?: Record<string, never>): string;
95
+ /** The untyped JSON body as a record (`req.body ?? {}`). @complexity O(1). */
96
+ export declare function accessBody({ body }: {
97
+ body: unknown;
98
+ }, _optional?: Record<string, never>): Record<string, unknown>;
99
+ /** An optional string field: `undefined` means "absent / leave unchanged", anything else is coerced. @complexity O(1). */
100
+ export declare function optionalString({ value }: {
101
+ value: unknown;
102
+ }, _optional?: Record<string, never>): string | undefined;
103
+ //# sourceMappingURL=access-shared.d.ts.map
@@ -0,0 +1,85 @@
1
+ import { rejectRoute, RouteRefusalError } from "@jini-ai/core/errors/route-refusal";
2
+ import { parseExpectedVersion, RecordVersionConflictError, versionConflictBody } from "@jini-ai/core/optimistic-concurrency";
3
+ import { GrantExceedsIssuerError, IdentityConflictError, IdentityForbiddenError, IdentityNotFoundError, IdentityValidationError, OwnerRequiredError, PermissionUnknownError, } from "../../../core/types.js";
4
+ /** A rung for one error class; `body` builds the flat envelope (key order is the wire order). @complexity O(1). */
5
+ function rung({ errorClass, status, body }, _optional = {}) {
6
+ return { matches: ({ err }) => err instanceof errorClass, respond: ({ err }) => ({ status, body: body(err) }) };
7
+ }
8
+ export const ACCESS_FORBIDDEN = rung({ errorClass: IdentityForbiddenError, status: 403, body: (err) => ({
9
+ error: err.message, code: "FORBIDDEN", details: { permission: err.permission, reason: err.reason },
10
+ }) });
11
+ export const ACCESS_VALIDATION = rung({ errorClass: IdentityValidationError, status: 400, body: (err) => ({ error: err.message, code: "VALIDATION_ERROR" }) });
12
+ export const ACCESS_NOT_FOUND = rung({ errorClass: IdentityNotFoundError, status: 404, body: (err) => ({ error: err.message, code: "RESOURCE_NOT_FOUND" }) });
13
+ export const ACCESS_GRANT_EXCEEDS_ISSUER = rung({ errorClass: GrantExceedsIssuerError, status: 403, body: (err) => ({
14
+ error: err.message, code: "GRANT_EXCEEDS_ISSUER", details: { offendingPermissions: err.offendingPermissions },
15
+ }) });
16
+ /** A stale editor basis: someone saved the record after this caller opened it. */
17
+ export const ACCESS_VERSION_CONFLICT = rung({ errorClass: RecordVersionConflictError, status: 409, body: (err) => ({ ...versionConflictBody({ error: err }) }) });
18
+ /**
19
+ * The optional `expectedVersion` an identity editor PATCH carries. Absent stays absent (legacy
20
+ * clients keep working); present must be a non-negative integer, else `400 VALIDATION_ERROR` —
21
+ * a mistyped basis is never read as "no basis". @complexity O(1).
22
+ */
23
+ export function accessExpectedVersion({ value }, _optional = {}) {
24
+ try {
25
+ return parseExpectedVersion({ value });
26
+ }
27
+ catch (err) {
28
+ // parseExpectedVersion throws only for a malformed basis; its message names the field.
29
+ return rejectRoute({ status: 400, error: err.message, code: "VALIDATION_ERROR" });
30
+ }
31
+ }
32
+ export const ACCESS_OWNER_REQUIRED = rung({ errorClass: OwnerRequiredError, status: 409, body: (err) => ({ error: err.message, code: "OWNER_REQUIRED" }) });
33
+ /** A still-referenced delete target (INV-09): 409 naming the id field the client sent. @complexity O(1). */
34
+ export function accessConflictOn({ field }, _optional = {}) {
35
+ return rung({ errorClass: IdentityConflictError, status: 409, body: (err) => ({ error: err.message, code: "RESOURCE_CONFLICT", details: { field } }) });
36
+ }
37
+ /** An unregistered permission: 400 echoing the permission exactly as the client sent it (raw, not
38
+ * coerced — an absent one drops out of the JSON, as `req.body?.permission` did). @complexity O(1). */
39
+ export function accessPermissionUnknown({ requested }, _optional = {}) {
40
+ return rung({ errorClass: PermissionUnknownError, status: 400, body: (err) => ({ error: err.message, code: "PERMISSION_UNKNOWN", details: { permission: requested } }) });
41
+ }
42
+ /**
43
+ * Refuses with the first matching rung; anything unmapped is rethrown unchanged so the host's error
44
+ * port answers it as an unexpected (redacted) failure under the route's own operation copy.
45
+ * @complexity O(n) in the mapping list length, a small fixed list per route.
46
+ */
47
+ export function rejectAccessError({ err, mappings }, _optional = {}) {
48
+ const mapping = mappings.find((candidate) => candidate.matches({ err }));
49
+ if (!mapping)
50
+ throw err;
51
+ throw new RouteRefusalError(mapping.respond({ err }));
52
+ }
53
+ /**
54
+ * The role/policy READ routes (list-roles, list-policies, list-policy-permissions) are the
55
+ * exception to "the service owns the gate": they have no identity transition to call, so they ask
56
+ * the host's `authorize` port for `role.manage` themselves — with no `entityType` and no entity
57
+ * scope, exactly the params the hand-written `deps.authorize` call sent. A mount without an
58
+ * authorizer is a wiring bug, so it fails closed. @complexity O(1) plus the injected authorizer.
59
+ */
60
+ export async function authorizeRoleManage({ authorize }, _optional = {}) {
61
+ if (!authorize)
62
+ throw new Error("users admin route has no authorizer");
63
+ await authorize({ permission: "role.manage" });
64
+ }
65
+ /** The authenticated caller's id. A missing principal is a wiring bug (the host mounts these behind
66
+ * its session), so it fails closed as an unexpected failure, as `getAuthedPrincipal` did. @complexity O(1). */
67
+ export function accessActorId({ context }, _optional = {}) {
68
+ if (!context)
69
+ throw new Error("users admin route has no authenticated principal");
70
+ return context.id;
71
+ }
72
+ /** One path segment; Express always fills it, the `?? ""` keeps the hand-written guard (an absent id
73
+ * becomes an honest not-found from the service, never a wildcard). @complexity O(1). */
74
+ export function accessPathParam({ params, name }, _optional = {}) {
75
+ return String(params[name] ?? "");
76
+ }
77
+ /** The untyped JSON body as a record (`req.body ?? {}`). @complexity O(1). */
78
+ export function accessBody({ body }, _optional = {}) {
79
+ return (body ?? {});
80
+ }
81
+ /** An optional string field: `undefined` means "absent / leave unchanged", anything else is coerced. @complexity O(1). */
82
+ export function optionalString({ value }, _optional = {}) {
83
+ return value !== undefined ? String(value) : undefined;
84
+ }
85
+ //# sourceMappingURL=access-shared.js.map
@@ -0,0 +1,24 @@
1
+ import type { PrincipalRoleRecord } from "../../../core/types.js";
2
+ import type { assignRole } from "../../../server/grant-service.js";
3
+ import { type IdentityServicesFn, type UserRoutePrincipal } from "./shared.js";
4
+ /** The deps this route reads. */
5
+ export interface UserAssignRoleRouteDeps {
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
+ assignRole: typeof assignRole;
10
+ identityServices: IdentityServicesFn;
11
+ }
12
+ /**
13
+ * POST users/:principalId/roles — `ASSIGN_ROLE` (state.spec §3, AC-24/AC-25).
14
+ * Gated by `role.manage`; target must be a `kind='user'` principal; the
15
+ * INV-07 grant clamp must pass over every permission carried by the role's
16
+ * policies. See `grant-service.ts`'s `assignRole` for the full contract.
17
+ */
18
+ export declare const userAssignRoleRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
19
+ principalId: string;
20
+ roleId: string;
21
+ }, {
22
+ assignment: PrincipalRoleRecord;
23
+ }, UserAssignRoleRouteDeps, UserRoutePrincipal>;
24
+ //# sourceMappingURL=assign-role.d.ts.map
@@ -0,0 +1,30 @@
1
+ import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
2
+ import { principalIdParam, rejectUserError, USER_FORBIDDEN, USER_GRANT_EXCEEDS_ISSUER, USER_NOT_FOUND_CODELESS, USER_OWNER_REQUIRED, USER_VALIDATION, userActorId, } from "./shared.js";
3
+ /** Unmapped failures go to the host; a missing target/grant was always the code-less 404. */
4
+ const USER_ASSIGN_ROLE_ERRORS = [USER_FORBIDDEN, USER_GRANT_EXCEEDS_ISSUER, USER_VALIDATION, USER_NOT_FOUND_CODELESS, USER_OWNER_REQUIRED];
5
+ /**
6
+ * POST users/:principalId/roles — `ASSIGN_ROLE` (state.spec §3, AC-24/AC-25).
7
+ * Gated by `role.manage`; target must be a `kind='user'` principal; the
8
+ * INV-07 grant clamp must pass over every permission carried by the role's
9
+ * policies. See `grant-service.ts`'s `assignRole` for the full contract.
10
+ */
11
+ export const userAssignRoleRoute = defineJsonRoute({
12
+ method: "post",
13
+ path: "/api/admin/v1/workspaces/:workspaceId/users/:principalId/roles",
14
+ // `?.` as the host read it: a null, absent or non-object body leaves the id empty for the service to refuse.
15
+ parse: (raw) => ok({ value: { principalId: principalIdParam(raw.params), roleId: String(raw.body?.roleId ?? "") } }),
16
+ handle: async ({ input, deps, context }) => {
17
+ const callerPrincipalId = userActorId({ context });
18
+ try {
19
+ const { assignment } = await deps.assignRole({
20
+ deps: deps.identityServices(),
21
+ input: { workspaceId: deps.workspaceId, callerPrincipalId, principalId: input.principalId, roleId: input.roleId },
22
+ });
23
+ return ok({ value: { assignment } });
24
+ }
25
+ catch (err) {
26
+ return rejectUserError({ err, rungs: USER_ASSIGN_ROLE_ERRORS });
27
+ }
28
+ },
29
+ }, { successStatus: 201 });
30
+ //# sourceMappingURL=assign-role.js.map
@@ -0,0 +1,25 @@
1
+ import type { PrincipalPolicyRecord } from "../../../core/types.js";
2
+ import type { attachPolicy } from "../../../server/grant-service.js";
3
+ import { type IdentityServicesFn, type UserRoutePrincipal } from "./shared.js";
4
+ /** The deps this route reads. */
5
+ export interface UserAttachPolicyRouteDeps {
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
+ attachPolicy: typeof attachPolicy;
10
+ identityServices: IdentityServicesFn;
11
+ }
12
+ /**
13
+ * POST users/:principalId/policies — `ATTACH_POLICY` (state.spec §3,
14
+ * AC-24/AC-25). Gated by `role.manage`; target must be a `kind='user'`
15
+ * principal; the INV-07 grant clamp must pass over every permission the
16
+ * policy carries. See `grant-service.ts`'s `attachPolicy` for the full
17
+ * contract.
18
+ */
19
+ export declare const userAttachPolicyRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
20
+ principalId: string;
21
+ policyId: string;
22
+ }, {
23
+ attachment: PrincipalPolicyRecord;
24
+ }, UserAttachPolicyRouteDeps, UserRoutePrincipal>;
25
+ //# sourceMappingURL=attach-policy.d.ts.map
@@ -0,0 +1,31 @@
1
+ import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
2
+ import { principalIdParam, rejectUserError, USER_FORBIDDEN, USER_GRANT_EXCEEDS_ISSUER, USER_NOT_FOUND_CODELESS, USER_OWNER_REQUIRED, USER_VALIDATION, userActorId, } from "./shared.js";
3
+ /** Unmapped failures go to the host; a missing target/grant was always the code-less 404. */
4
+ const USER_ATTACH_POLICY_ERRORS = [USER_FORBIDDEN, USER_GRANT_EXCEEDS_ISSUER, USER_VALIDATION, USER_NOT_FOUND_CODELESS, USER_OWNER_REQUIRED];
5
+ /**
6
+ * POST users/:principalId/policies — `ATTACH_POLICY` (state.spec §3,
7
+ * AC-24/AC-25). Gated by `role.manage`; target must be a `kind='user'`
8
+ * principal; the INV-07 grant clamp must pass over every permission the
9
+ * policy carries. See `grant-service.ts`'s `attachPolicy` for the full
10
+ * contract.
11
+ */
12
+ export const userAttachPolicyRoute = defineJsonRoute({
13
+ method: "post",
14
+ path: "/api/admin/v1/workspaces/:workspaceId/users/:principalId/policies",
15
+ // `?.` as the host read it: a null, absent or non-object body leaves the id empty for the service to refuse.
16
+ parse: (raw) => ok({ value: { principalId: principalIdParam(raw.params), policyId: String(raw.body?.policyId ?? "") } }),
17
+ handle: async ({ input, deps, context }) => {
18
+ const callerPrincipalId = userActorId({ context });
19
+ try {
20
+ const { attachment } = await deps.attachPolicy({
21
+ deps: deps.identityServices(),
22
+ input: { workspaceId: deps.workspaceId, callerPrincipalId, principalId: input.principalId, policyId: input.policyId },
23
+ });
24
+ return ok({ value: { attachment } });
25
+ }
26
+ catch (err) {
27
+ return rejectUserError({ err, rungs: USER_ATTACH_POLICY_ERRORS });
28
+ }
29
+ },
30
+ }, { successStatus: 201 });
31
+ //# sourceMappingURL=attach-policy.js.map
@@ -0,0 +1,19 @@
1
+ import type { createPolicy } from "../../../server/grant-service.js";
2
+ import { type AdminPolicyResponse } from "../../http/users.js";
3
+ import { type AccessRoutePrincipal, type AccessServiceRouteDeps } from "./access-shared.js";
4
+ /** The deps this route reads: the workspace, the identity services' deps bag and the service it calls. */
5
+ export interface PolicyCreateRouteDeps extends AccessServiceRouteDeps {
6
+ /** Injected: the service lives in the node `./server` entry; the host binds it. */
7
+ createPolicy: typeof createPolicy;
8
+ }
9
+ /**
10
+ * POST policies — `CREATE_POLICY` (state.spec §3). Gated by `role.manage`;
11
+ * always mints `isBuiltin=false` and `isFrozen=false`.
12
+ */
13
+ export declare const policyCreateRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
14
+ name: string;
15
+ description: string | undefined;
16
+ }, {
17
+ policy: AdminPolicyResponse;
18
+ }, PolicyCreateRouteDeps, AccessRoutePrincipal>;
19
+ //# sourceMappingURL=create-policy.d.ts.map
@@ -0,0 +1,28 @@
1
+ import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
2
+ import { toAdminPolicyResponse } from "../../http/users.js";
3
+ import { ACCESS_FORBIDDEN, ACCESS_VALIDATION, accessActorId, accessBody, optionalString, rejectAccessError, } from "./access-shared.js";
4
+ const POLICY_CREATE_ERRORS = [ACCESS_FORBIDDEN, ACCESS_VALIDATION];
5
+ /**
6
+ * POST policies — `CREATE_POLICY` (state.spec §3). Gated by `role.manage`;
7
+ * always mints `isBuiltin=false` and `isFrozen=false`.
8
+ */
9
+ export const policyCreateRoute = defineJsonRoute({
10
+ method: "post",
11
+ path: "/api/admin/v1/workspaces/:workspaceId/policies",
12
+ // This route's `name`/`description` POST fields, read off an untyped body in one place.
13
+ parse: (raw) => {
14
+ const body = accessBody({ body: raw.body });
15
+ return ok({ value: { name: String(body.name ?? ""), description: optionalString({ value: body.description }) } });
16
+ },
17
+ handle: async ({ input, deps, context }) => {
18
+ const callerPrincipalId = accessActorId({ context });
19
+ try {
20
+ const { policy } = await deps.createPolicy({ deps: deps.identityServiceDeps(), input: { workspaceId: deps.workspaceId, callerPrincipalId, name: input.name } }, { description: input.description });
21
+ return ok({ value: { policy: toAdminPolicyResponse(policy) } });
22
+ }
23
+ catch (err) {
24
+ return rejectAccessError({ err, mappings: POLICY_CREATE_ERRORS });
25
+ }
26
+ },
27
+ }, { successStatus: 201 });
28
+ //# sourceMappingURL=create-policy.js.map
@@ -0,0 +1,15 @@
1
+ import type { createRole } from "../../../server/grant-service.js";
2
+ import { type AdminRoleResponse } from "../../http/users.js";
3
+ import { type AccessRoutePrincipal, type AccessServiceRouteDeps } from "./access-shared.js";
4
+ /** The deps this route reads: the workspace, the identity services' deps bag and the service it calls. */
5
+ export interface RoleCreateRouteDeps extends AccessServiceRouteDeps {
6
+ /** Injected: the service lives in the node `./server` entry; the host binds it. */
7
+ createRole: typeof createRole;
8
+ }
9
+ /** POST roles — `CREATE_ROLE` (state.spec §3). Gated by `role.manage`; always mints `isBuiltin=false`. */
10
+ export declare const roleCreateRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
11
+ name: string;
12
+ }, {
13
+ role: AdminRoleResponse;
14
+ }, RoleCreateRouteDeps, AccessRoutePrincipal>;
15
+ //# sourceMappingURL=create-role.d.ts.map
@@ -0,0 +1,21 @@
1
+ import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
2
+ import { toAdminRoleResponse } from "../../http/users.js";
3
+ import { ACCESS_FORBIDDEN, ACCESS_VALIDATION, accessActorId, accessBody, rejectAccessError, } from "./access-shared.js";
4
+ const ROLE_CREATE_ERRORS = [ACCESS_FORBIDDEN, ACCESS_VALIDATION];
5
+ /** POST roles — `CREATE_ROLE` (state.spec §3). Gated by `role.manage`; always mints `isBuiltin=false`. */
6
+ export const roleCreateRoute = defineJsonRoute({
7
+ method: "post",
8
+ path: "/api/admin/v1/workspaces/:workspaceId/roles",
9
+ parse: (raw) => ok({ value: { name: String(accessBody({ body: raw.body }).name ?? "") } }),
10
+ handle: async ({ input, deps, context }) => {
11
+ const callerPrincipalId = accessActorId({ context });
12
+ try {
13
+ const { role } = await deps.createRole({ deps: deps.identityServiceDeps(), input: { workspaceId: deps.workspaceId, callerPrincipalId, name: input.name } });
14
+ return ok({ value: { role: toAdminRoleResponse(role) } });
15
+ }
16
+ catch (err) {
17
+ return rejectAccessError({ err, mappings: ROLE_CREATE_ERRORS });
18
+ }
19
+ },
20
+ }, { successStatus: 201 });
21
+ //# sourceMappingURL=create-role.js.map
@@ -0,0 +1,32 @@
1
+ import type { createUser } from "../../../server/grant-service.js";
2
+ import type { normalizeUsername } from "../../../server/username.js";
3
+ import { type AdminUserResponse } from "../../http/users.js";
4
+ import { type IdentityServicesFn, type IsInTrashFn, type UserRoutePrincipal } from "./shared.js";
5
+ /** The deps this route reads. */
6
+ export interface UserCreateRouteDeps {
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
+ createUser: typeof createUser;
11
+ normalizeUsername: typeof normalizeUsername;
12
+ identityServices: IdentityServicesFn;
13
+ isInTrash: IsInTrashFn;
14
+ }
15
+ /** This route's three body fields, read off an untyped body in one place. */
16
+ export interface UserCreateInput {
17
+ username: string;
18
+ email: string | undefined;
19
+ password: string;
20
+ }
21
+ /**
22
+ * POST users — `CREATE_USER` (state.spec §3, REQ-01/MF-1). Gated by `user.manage` only (operator
23
+ * login creation), enforced inside `grant-service.ts`'s `createUser` rather than here — see that
24
+ * file's header for why the gate lives in the service function.
25
+ *
26
+ * Not routed through the SPEC-001 command gateway: `CREATE_USER` mints two rows (principal + user)
27
+ * as one structural unit, not a single entity with a natural inverse-capture/revert story.
28
+ */
29
+ export declare const userCreateRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<UserCreateInput, {
30
+ user: AdminUserResponse;
31
+ }, UserCreateRouteDeps, UserRoutePrincipal>;
32
+ //# sourceMappingURL=create.d.ts.map