@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,167 @@
1
+ import { sql } from "kysely";
2
+ /**
3
+ * @file THE adapters for the `identity` repo ports (ADR-021 / SPEC-006): one Kysely query body for
4
+ * every dialect (storage plan §4, ADR-066).
5
+ *
6
+ * Purpose:
7
+ * The other half of each ADR-006 rule-of-two, mirroring `repo.memory.ts`'s exact save-is-upsert
8
+ * semantics. Built so identity survives a process restart — the in-memory-only adapters meant
9
+ * every `tsx watch` restart (any file save) wiped every logged-in session, and re-seeded a fresh
10
+ * random owner-principal id on top of that, so a persisted session alone wouldn't have helped
11
+ * either. This is the whole rule-of-two: principals, users, sessions, roles, policies, and the
12
+ * four join tables, all backed by real tables. Every lookup is composite `(workspace_id, …)`.
13
+ * `repo.sqlite.ts` holds the thin subclasses built from the content db handle.
14
+ *
15
+ * `is_builtin` / `is_frozen` are integer columns on both dialects (0/1), not booleans.
16
+ */
17
+ /**
18
+ * Bind identity's atomic guard/write unit to the SAME kernel as its repositories. Nested calls
19
+ * join the active transaction. The workspace lock also covers ordinary saves below, so a grant
20
+ * or status writer cannot insert a phantom owner/reference while a guarded mutation is deciding.
21
+ * SQLite's BEGIN IMMEDIATE serializes writers; Postgres uses the kernel's advisory lock.
22
+ * Shared transaction rationale lives in Jini user-management/src/core/ports.ts.
23
+ * @complexity O(1) binding; each run adds one transaction and one workspace-lock acquisition.
24
+ */
25
+ export function createIdentityTransactions({ kernel }, _optional = {}) {
26
+ return {
27
+ run: ({ workspaceId, execute }) => kernel.transaction(async () => {
28
+ await kernel.lockKey(`identity:${workspaceId}`);
29
+ return execute();
30
+ }),
31
+ };
32
+ }
33
+ function toPrincipalRecord(row) {
34
+ return {
35
+ id: row.id,
36
+ workspaceId: row.workspace_id,
37
+ kind: row.kind,
38
+ displayName: row.display_name,
39
+ status: row.status,
40
+ disabledAt: row.disabled_at ?? undefined,
41
+ createdAt: row.created_at,
42
+ };
43
+ }
44
+ export class SqlPrincipalRepo {
45
+ kernel;
46
+ table;
47
+ constructor({ kernel, table }, _optional = {}) {
48
+ this.kernel = kernel;
49
+ this.table = table;
50
+ }
51
+ async findById(required) {
52
+ const row = await this.kernel.run((db) => db
53
+ .withTables().selectFrom(this.table)
54
+ .selectAll()
55
+ .where("workspace_id", "=", required.workspaceId)
56
+ .where("id", "=", required.id)
57
+ .limit(1)
58
+ .executeTakeFirst());
59
+ return row ? toPrincipalRecord(row) : null;
60
+ }
61
+ async list(required) {
62
+ const rows = await this.kernel.run((db) => db.withTables().selectFrom(this.table).selectAll().where("workspace_id", "=", required.workspaceId).execute());
63
+ return rows.map(toPrincipalRecord);
64
+ }
65
+ async save(record) {
66
+ const row = {
67
+ id: record.id,
68
+ workspace_id: record.workspaceId,
69
+ kind: record.kind,
70
+ display_name: record.displayName,
71
+ status: record.status,
72
+ disabled_at: record.disabledAt ?? null,
73
+ created_at: record.createdAt,
74
+ };
75
+ await createIdentityTransactions({ kernel: this.kernel }).run({ workspaceId: record.workspaceId, execute: () => this.kernel.run((db) => db.withTables().insertInto(this.table).values(row).onConflict((oc) => oc.column("id").doUpdateSet(row)).execute()) });
76
+ }
77
+ }
78
+ function toUserRecord(row) {
79
+ return {
80
+ principalId: row.principal_id,
81
+ workspaceId: row.workspace_id,
82
+ username: row.username,
83
+ email: row.email ?? undefined,
84
+ passwordHash: row.password_hash,
85
+ lastLoginAt: row.last_login_at ?? undefined,
86
+ version: row.version,
87
+ };
88
+ }
89
+ export class SqlUserRepo {
90
+ kernel;
91
+ table;
92
+ assertVersionedWrite;
93
+ constructor({ kernel, table, assertVersionedWrite }, _optional = {}) {
94
+ this.kernel = kernel;
95
+ this.table = table;
96
+ this.assertVersionedWrite = assertVersionedWrite;
97
+ }
98
+ async findByPrincipalId(required) {
99
+ const row = await this.kernel.run((db) => db
100
+ .withTables().selectFrom(this.table)
101
+ .selectAll()
102
+ .where("workspace_id", "=", required.workspaceId)
103
+ .where("principal_id", "=", required.principalId)
104
+ .limit(1)
105
+ .executeTakeFirst());
106
+ return row ? toUserRecord(row) : null;
107
+ }
108
+ async findByUsername(required) {
109
+ const row = await this.kernel.run((db) => db
110
+ .withTables().selectFrom(this.table)
111
+ .selectAll()
112
+ .where("workspace_id", "=", required.workspaceId)
113
+ .where("username", "=", required.username)
114
+ .limit(1)
115
+ .executeTakeFirst());
116
+ return row ? toUserRecord(row) : null;
117
+ }
118
+ async list(required) {
119
+ const rows = await this.kernel.run((db) => db.withTables().selectFrom(this.table).selectAll().where("workspace_id", "=", required.workspaceId).execute());
120
+ return rows.map(toUserRecord);
121
+ }
122
+ async recordLogin(required) {
123
+ await createIdentityTransactions({ kernel: this.kernel }).run({ workspaceId: required.workspaceId, execute: () => this.kernel.run((db) => db
124
+ .withTables().updateTable(this.table)
125
+ .set({ last_login_at: required.lastLoginAt })
126
+ .where("workspace_id", "=", required.workspaceId)
127
+ .where("principal_id", "=", required.principalId)
128
+ .execute()) });
129
+ }
130
+ /**
131
+ * Without a basis this is the insert-or-replace used by create, seed and credential reset; it still
132
+ * advances the version so an editor's earlier basis goes stale. With a basis it is a profile edit:
133
+ * one conditional UPDATE whose `WHERE version = :expectedVersion` is the lock. Password and login
134
+ * time are written by their own paths and are not part of an editor's snapshot, so it never
135
+ * writes them back.
136
+ */
137
+ async save(record, optional = {}) {
138
+ const { expectedVersion } = optional;
139
+ await createIdentityTransactions({ kernel: this.kernel }).run({ workspaceId: record.workspaceId, execute: async () => {
140
+ if (expectedVersion === undefined)
141
+ return this.upsert(record);
142
+ const result = await this.kernel.run((db) => db.withTables().updateTable(this.table)
143
+ .set({ username: record.username, email: record.email ?? null, version: sql `version + 1` })
144
+ .where("workspace_id", "=", record.workspaceId).where("principal_id", "=", record.principalId)
145
+ .where("version", "=", expectedVersion).executeTakeFirst());
146
+ await this.assertVersionedWrite({ changedRows: result.numUpdatedRows, recordKind: "user", recordId: record.principalId, expectedVersion,
147
+ readCurrentVersion: async () => (await this.findByPrincipalId({ workspaceId: record.workspaceId, principalId: record.principalId }))?.version ?? null });
148
+ } });
149
+ }
150
+ async upsert(record) {
151
+ const row = {
152
+ principal_id: record.principalId,
153
+ workspace_id: record.workspaceId,
154
+ username: record.username,
155
+ email: record.email ?? null,
156
+ password_hash: record.passwordHash,
157
+ last_login_at: record.lastLoginAt ?? null,
158
+ version: record.version,
159
+ };
160
+ await this.kernel.run((db) => db
161
+ .withTables().insertInto(this.table)
162
+ .values(row)
163
+ .onConflict((oc) => oc.column("principal_id").doUpdateSet({ ...row, version: sql `${sql.ref(`${this.table}.version`)} + 1` }))
164
+ .execute());
165
+ }
166
+ }
167
+ //# sourceMappingURL=repo.js.map
@@ -0,0 +1,31 @@
1
+ import type { ApiKeyRecord, ApiKeyRepoPort } from "./api-key-types.js";
2
+ /**
3
+ * @file In-memory adapter for `ApiKeyRepoPort` (ADR-006 rule-of-two, other half in `repo.sqlite.ts`).
4
+ *
5
+ * Purpose:
6
+ * The host's hermetic (in-memory) composition root wires the in-memory identity repos `@jini-ai/cms/identity`
7
+ * ships, but that package has no api-keys port to ship an adapter for (its `INFO.md` scopes API
8
+ * keys out), so this is the in-memory half for the tenth table. Save-is-upsert by `id`, matching
9
+ * the exact semantics every `InMemory*Repo` in that package already has.
10
+ *
11
+ * Architectural role:
12
+ * Test/dev adapter. One `Map` per instance, so each `createRouteDeps()` — and therefore each
13
+ * test's server — gets an isolated store rather than sharing process-wide state.
14
+ */
15
+ export declare class InMemoryApiKeyRepo implements ApiKeyRepoPort {
16
+ private readonly rows;
17
+ findById(required: {
18
+ workspaceId: string;
19
+ id: string;
20
+ }): Promise<ApiKeyRecord | null>;
21
+ findByPrefix(required: {
22
+ workspaceId: string;
23
+ prefix: string;
24
+ }): Promise<ApiKeyRecord | null>;
25
+ listByPrincipalId(required: {
26
+ workspaceId: string;
27
+ principalId: string;
28
+ }): Promise<ApiKeyRecord[]>;
29
+ save(record: ApiKeyRecord): Promise<void>;
30
+ }
31
+ //# sourceMappingURL=repo.memory.d.ts.map
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @file In-memory adapter for `ApiKeyRepoPort` (ADR-006 rule-of-two, other half in `repo.sqlite.ts`).
3
+ *
4
+ * Purpose:
5
+ * The host's hermetic (in-memory) composition root wires the in-memory identity repos `@jini-ai/cms/identity`
6
+ * ships, but that package has no api-keys port to ship an adapter for (its `INFO.md` scopes API
7
+ * keys out), so this is the in-memory half for the tenth table. Save-is-upsert by `id`, matching
8
+ * the exact semantics every `InMemory*Repo` in that package already has.
9
+ *
10
+ * Architectural role:
11
+ * Test/dev adapter. One `Map` per instance, so each `createRouteDeps()` — and therefore each
12
+ * test's server — gets an isolated store rather than sharing process-wide state.
13
+ */
14
+ export class InMemoryApiKeyRepo {
15
+ rows = new Map();
16
+ async findById(required) {
17
+ const row = this.rows.get(required.id);
18
+ return row && row.workspaceId === required.workspaceId ? row : null;
19
+ }
20
+ async findByPrefix(required) {
21
+ for (const row of this.rows.values()) {
22
+ if (row.workspaceId === required.workspaceId && row.prefix === required.prefix)
23
+ return row;
24
+ }
25
+ return null;
26
+ }
27
+ async listByPrincipalId(required) {
28
+ return [...this.rows.values()].filter((row) => row.workspaceId === required.workspaceId && row.principalId === required.principalId);
29
+ }
30
+ async save(record) {
31
+ // Match the SQL adapter's terminal revocation even when auth holds an older row snapshot.
32
+ if (this.rows.get(record.id)?.revokedAt)
33
+ return;
34
+ this.rows.set(record.id, { ...record });
35
+ }
36
+ }
37
+ //# sourceMappingURL=repo.memory.js.map
@@ -0,0 +1,34 @@
1
+ import type { PermissionGrantRegistry } from "./permission-grants.js";
2
+ /**
3
+ * @file The built-in `admin` role holds `role.manage` — full Roles & Permissions access (owner
4
+ * decision, 2026-10-05).
5
+ *
6
+ * `@jini-ai/user-management`'s seed used to leave `role.manage` (with `user.manage`) owner-only, so a
7
+ * built-in admin saw no Roles section, its direct URL showed no access, and every roles/policies
8
+ * endpoint refused it. The owner reversed that for `role.manage`: an admin runs Roles & Permissions.
9
+ * `user.manage` is not part of that decision and stays owner-only.
10
+ *
11
+ * Two paths, same shape as `site-key-permission.ts`'s built-in-role grant:
12
+ * - the Jini seed list now includes `role.manage`, so a freshly seeded workspace's admin policy holds it;
13
+ * - the built-in-role grant below reaches every workspace seeded BEFORE that change, because
14
+ * `seedIdentity` early-returns once an owner user exists and never revisits the admin policy.
15
+ * `applyBuiltinRoleGrants` (chained off `identityReady` in `wiring.ts`) adds the one row on the
16
+ * next boot; it is additive and a no-op once the row exists. No migration is involved.
17
+ *
18
+ * `owner` needs neither (its `*` wildcard clears every gate). `editor`/`viewer` get nothing here.
19
+ *
20
+ * Registered explicitly from `server/runtime/composition/app-permission-grants.ts`; importing this
21
+ * module registers nothing.
22
+ */
23
+ /** The permission every roles/policies route checks (`routes/users/*-role.ts`, `*-policy*.ts`). */
24
+ export declare const ROLE_MANAGE_PERMISSION = "role.manage";
25
+ /**
26
+ * Register the built-in admin role's `role.manage` grant (see this file's header) on
27
+ * `required.registry`.
28
+ *
29
+ * @complexity O(1).
30
+ */
31
+ export declare function registerRoleManagePermissionGrants(required: {
32
+ registry: PermissionGrantRegistry;
33
+ }, _optional?: Record<string, never>): void;
34
+ //# sourceMappingURL=role-manage-permission.d.ts.map
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @file The built-in `admin` role holds `role.manage` — full Roles & Permissions access (owner
3
+ * decision, 2026-10-05).
4
+ *
5
+ * `@jini-ai/user-management`'s seed used to leave `role.manage` (with `user.manage`) owner-only, so a
6
+ * built-in admin saw no Roles section, its direct URL showed no access, and every roles/policies
7
+ * endpoint refused it. The owner reversed that for `role.manage`: an admin runs Roles & Permissions.
8
+ * `user.manage` is not part of that decision and stays owner-only.
9
+ *
10
+ * Two paths, same shape as `site-key-permission.ts`'s built-in-role grant:
11
+ * - the Jini seed list now includes `role.manage`, so a freshly seeded workspace's admin policy holds it;
12
+ * - the built-in-role grant below reaches every workspace seeded BEFORE that change, because
13
+ * `seedIdentity` early-returns once an owner user exists and never revisits the admin policy.
14
+ * `applyBuiltinRoleGrants` (chained off `identityReady` in `wiring.ts`) adds the one row on the
15
+ * next boot; it is additive and a no-op once the row exists. No migration is involved.
16
+ *
17
+ * `owner` needs neither (its `*` wildcard clears every gate). `editor`/`viewer` get nothing here.
18
+ *
19
+ * Registered explicitly from `server/runtime/composition/app-permission-grants.ts`; importing this
20
+ * module registers nothing.
21
+ */
22
+ /** The permission every roles/policies route checks (`routes/users/*-role.ts`, `*-policy*.ts`). */
23
+ export const ROLE_MANAGE_PERMISSION = "role.manage";
24
+ /**
25
+ * Register the built-in admin role's `role.manage` grant (see this file's header) on
26
+ * `required.registry`.
27
+ *
28
+ * @complexity O(1).
29
+ */
30
+ export function registerRoleManagePermissionGrants(required, _optional = {}) {
31
+ required.registry.roleGrants.register({
32
+ role: "admin",
33
+ permission: ROLE_MANAGE_PERMISSION,
34
+ reason: "Owner decision 2026-10-05: the built-in admin role has full Roles & Permissions access. " +
35
+ "Stated against the role so workspaces seeded before role.manage joined the admin seed list " +
36
+ "receive it on the next boot (seedIdentity early-returns once an owner user exists).",
37
+ });
38
+ }
39
+ //# sourceMappingURL=role-manage-permission.js.map
@@ -0,0 +1,66 @@
1
+ import type { PermissionGrantRegistry } from "./permission-grants.js";
2
+ /**
3
+ * @file The `admin.security.site-key.manage` permission, and the grants that make it real —
4
+ * gates the admin Security page's "Site key" tab (view/generate the
5
+ * host's site key, named by `siteKeyName`; `features/webhooks/keyring.env.ts`'s
6
+ * `inspectSiteKeyMaterial`/`generateFileSiteKey`).
7
+ *
8
+ * ## Why its own permission, not an identity check
9
+ *
10
+ * The owner explicitly rejected gating this on "is the workspace creator" — identity checks do
11
+ * not compose with roles (a second admin the owner adds could never manage the site key, and
12
+ * there is no way to delegate it short of sharing the owner's own login). A permission composes
13
+ * the normal way: any role — built-in or custom — can be granted it.
14
+ *
15
+ * ## Why its own string, not reusing `admin.integrations.manage`
16
+ *
17
+ * `admin.integrations.manage` gates a saved CONNECTION's config (OAuth connector settings,
18
+ * webhooks). The site key is a different order of sensitivity — it is the one thing that
19
+ * DECRYPTS every sealed credential this install holds, including everything
20
+ * `admin.integrations.manage` already protects. Collapsing the two would mean any future,
21
+ * narrower grant of connector-config access silently also grants site-key control, which is not
22
+ * a decision this file gets to make on that permission's behalf.
23
+ *
24
+ * ## The two grants below, same shape as `features/pages/permissions.ts`'s
25
+ * `pages.edit_html` (see that file's own header for the full reasoning this mirrors)
26
+ *
27
+ * - the migration `{ from: "admin.integrations.manage", to: [...] }` reaches any
28
+ * workspace whose `admin` policy already holds `admin.integrations.manage` — every FRESHLY
29
+ * seeded workspace, since `@jini-ai/cms`'s `BUILTIN_ADMIN_PERMISSIONS` includes it.
30
+ * - the built-in-role grant `{ role: "admin", ... }` states the same intent directly against
31
+ * the role, so a workspace seeded before `admin.integrations.manage` existed (this repo's own
32
+ * installs may be exactly that, per the host `pages/permissions.ts`'s own account of its seeded
33
+ * site database) still reaches `admin` even though the migration's `from` row is absent there.
34
+ *
35
+ * `owner` needs neither: `authorize()` short-circuits on its `*` wildcard before ever looking for
36
+ * a matching `policy_permissions` row. `editor`/`viewer` get neither grant, deliberately — this
37
+ * is a narrower trust boundary than ordinary content admin.
38
+ *
39
+ * ## Ordering
40
+ *
41
+ * The registrations below must run before `migrateDeprecatedPermissionGrants`/
42
+ * `applyBuiltinRoleGrants` do. They used to be module-evaluation side effects that ran first only
43
+ * because {@link SITE_KEY_MANAGE_PERMISSION} is imported by `server/inbound/admin-http/routes/
44
+ * system/site-key.ts`, which sat in `composition/app.ts`'s static import graph — the same "reached
45
+ * via its own consumer" mechanism `pages/permissions.ts` relied on. They are now an explicit call:
46
+ * `server/runtime/composition/app-permission-grants.ts` invokes
47
+ * {@link registerSiteKeyPermissionGrants} on the registry every composition root passes to
48
+ * identity wiring.
49
+ */
50
+ /**
51
+ * The permission required to read site-key status or generate a key file, at every sink that can
52
+ * do either. Named once and imported by the route so the gate and the 403 body cannot drift apart.
53
+ */
54
+ export declare const SITE_KEY_MANAGE_PERMISSION = "admin.security.site-key.manage";
55
+ /**
56
+ * Register the site-key permission's migrations and built-in-role grant (see this file's header) on
57
+ * `required.registry`. `required.siteKeyName` is the host's site-key env var name; the migration's
58
+ * audit reason names it, so the product's own name stays in the host (K3).
59
+ *
60
+ * @complexity O(1).
61
+ */
62
+ export declare function registerSiteKeyPermissionGrants(required: {
63
+ registry: PermissionGrantRegistry;
64
+ siteKeyName: string;
65
+ }, _optional?: Record<string, never>): void;
66
+ //# sourceMappingURL=site-key-permission.d.ts.map
@@ -0,0 +1,92 @@
1
+ /**
2
+ * @file The `admin.security.site-key.manage` permission, and the grants that make it real —
3
+ * gates the admin Security page's "Site key" tab (view/generate the
4
+ * host's site key, named by `siteKeyName`; `features/webhooks/keyring.env.ts`'s
5
+ * `inspectSiteKeyMaterial`/`generateFileSiteKey`).
6
+ *
7
+ * ## Why its own permission, not an identity check
8
+ *
9
+ * The owner explicitly rejected gating this on "is the workspace creator" — identity checks do
10
+ * not compose with roles (a second admin the owner adds could never manage the site key, and
11
+ * there is no way to delegate it short of sharing the owner's own login). A permission composes
12
+ * the normal way: any role — built-in or custom — can be granted it.
13
+ *
14
+ * ## Why its own string, not reusing `admin.integrations.manage`
15
+ *
16
+ * `admin.integrations.manage` gates a saved CONNECTION's config (OAuth connector settings,
17
+ * webhooks). The site key is a different order of sensitivity — it is the one thing that
18
+ * DECRYPTS every sealed credential this install holds, including everything
19
+ * `admin.integrations.manage` already protects. Collapsing the two would mean any future,
20
+ * narrower grant of connector-config access silently also grants site-key control, which is not
21
+ * a decision this file gets to make on that permission's behalf.
22
+ *
23
+ * ## The two grants below, same shape as `features/pages/permissions.ts`'s
24
+ * `pages.edit_html` (see that file's own header for the full reasoning this mirrors)
25
+ *
26
+ * - the migration `{ from: "admin.integrations.manage", to: [...] }` reaches any
27
+ * workspace whose `admin` policy already holds `admin.integrations.manage` — every FRESHLY
28
+ * seeded workspace, since `@jini-ai/cms`'s `BUILTIN_ADMIN_PERMISSIONS` includes it.
29
+ * - the built-in-role grant `{ role: "admin", ... }` states the same intent directly against
30
+ * the role, so a workspace seeded before `admin.integrations.manage` existed (this repo's own
31
+ * installs may be exactly that, per the host `pages/permissions.ts`'s own account of its seeded
32
+ * site database) still reaches `admin` even though the migration's `from` row is absent there.
33
+ *
34
+ * `owner` needs neither: `authorize()` short-circuits on its `*` wildcard before ever looking for
35
+ * a matching `policy_permissions` row. `editor`/`viewer` get neither grant, deliberately — this
36
+ * is a narrower trust boundary than ordinary content admin.
37
+ *
38
+ * ## Ordering
39
+ *
40
+ * The registrations below must run before `migrateDeprecatedPermissionGrants`/
41
+ * `applyBuiltinRoleGrants` do. They used to be module-evaluation side effects that ran first only
42
+ * because {@link SITE_KEY_MANAGE_PERMISSION} is imported by `server/inbound/admin-http/routes/
43
+ * system/site-key.ts`, which sat in `composition/app.ts`'s static import graph — the same "reached
44
+ * via its own consumer" mechanism `pages/permissions.ts` relied on. They are now an explicit call:
45
+ * `server/runtime/composition/app-permission-grants.ts` invokes
46
+ * {@link registerSiteKeyPermissionGrants} on the registry every composition root passes to
47
+ * identity wiring.
48
+ */
49
+ /**
50
+ * The permission required to read site-key status or generate a key file, at every sink that can
51
+ * do either. Named once and imported by the route so the gate and the 403 body cannot drift apart.
52
+ */
53
+ export const SITE_KEY_MANAGE_PERMISSION = "admin.security.site-key.manage";
54
+ /** See this file's header — the anchor an already-seeded workspace's `admin` policy is most
55
+ * likely to already hold. Spelled as a literal, not imported: it is a `policy_permissions` row
56
+ * value seeded by `@jini-ai/cms`, not a value this repo owns (same reasoning `pages/
57
+ * permissions.ts`'s own `DERIVED_FROM_PERMISSION` gives). */
58
+ const DERIVED_FROM_PERMISSION = "admin.integrations.manage";
59
+ /**
60
+ * Register the site-key permission's migrations and built-in-role grant (see this file's header) on
61
+ * `required.registry`. `required.siteKeyName` is the host's site-key env var name; the migration's
62
+ * audit reason names it, so the product's own name stays in the host (K3).
63
+ *
64
+ * @complexity O(1).
65
+ */
66
+ export function registerSiteKeyPermissionGrants(required, _optional = {}) {
67
+ // Existing custom policies keep their site-key capability on every boot. This is additive:
68
+ // retaining the former grant preserves audit history and does not grant integration management.
69
+ required.registry.migrations.register({
70
+ from: "admin.security.tokens.manage",
71
+ to: [SITE_KEY_MANAGE_PERMISSION],
72
+ reason: "Rename site key management without removing access from existing policies.",
73
+ });
74
+ required.registry.migrations.register({
75
+ from: DERIVED_FROM_PERMISSION,
76
+ to: [SITE_KEY_MANAGE_PERMISSION],
77
+ reason: `The admin Security page's Site key tab reads/generates the ${required.siteKeyName} ` +
78
+ "site key — the key that decrypts every sealed credential this install holds, including " +
79
+ "every connection admin.integrations.manage already protects. Every principal already " +
80
+ "trusted with integration connection config inherits site key management too.",
81
+ });
82
+ required.registry.roleGrants.register({
83
+ role: "admin",
84
+ permission: SITE_KEY_MANAGE_PERMISSION,
85
+ reason: "The built-in admin role manages the site key that decrypts every sealed credential this " +
86
+ "install holds; editor and viewer do not. Stated directly against the role, not only via the " +
87
+ "admin.integrations.manage migration above, because that migration only reaches a workspace " +
88
+ "whose admin policy already HOLDS admin.integrations.manage — a workspace seeded before that " +
89
+ "permission existed never will (seedIdentity early-returns once an owner user exists).",
90
+ });
91
+ }
92
+ //# sourceMappingURL=site-key-permission.js.map
@@ -0,0 +1,19 @@
1
+ import type { StorageKernel } from "@jini-ai/core/contracts/storage";
2
+ import type { DomainEvent } from "@jini-ai/core/contracts/events";
3
+ import type { Kysely } from "kysely";
4
+ import { SqlUserPurge, type UserPurgeSqlPorts } from "../user-purge.js";
5
+ export interface KernelUserPurgeRequired {
6
+ kernel: Pick<StorageKernel<Kysely<unknown>, unknown>, "run" | "transaction">;
7
+ /** The host's outbox row encoder for a domain event (for example `@jini-ai/db/events`' `outboxEventValues`). */
8
+ eventValues: (event: DomainEvent) => Record<string, unknown>;
9
+ }
10
+ /**
11
+ * Build the purge ports over one kernel.
12
+ * @complexity O(1) per port call (one statement each).
13
+ */
14
+ export declare function createKernelUserPurgePorts({ kernel, eventValues }: KernelUserPurgeRequired, _optional?: Record<string, never>): UserPurgeSqlPorts;
15
+ /** {@link SqlUserPurge} bound to a storage kernel — the host's real `UserPurgePort`. */
16
+ export declare class KernelUserPurge extends SqlUserPurge {
17
+ constructor(required: KernelUserPurgeRequired, _optional?: Record<string, never>);
18
+ }
19
+ //# sourceMappingURL=kernel-user-purge.d.ts.map
@@ -0,0 +1,34 @@
1
+ import { SqlUserPurge } from "../user-purge.js";
2
+ /**
3
+ * Build the purge ports over one kernel.
4
+ * @complexity O(1) per port call (one statement each).
5
+ */
6
+ export function createKernelUserPurgePorts({ kernel, eventValues }, _optional = {}) {
7
+ const run = (fn) => kernel.run((db) => fn(db.withTables()));
8
+ return {
9
+ transaction: ({ run: body }) => kernel.transaction(body),
10
+ deleteCounted: async ({ table, workspaceId, principalId }) => {
11
+ const result = await run((db) => db.deleteFrom(table).where("workspace_id", "=", workspaceId).where("principal_id", "=", principalId).executeTakeFirst());
12
+ return Number(result.numDeletedRows);
13
+ },
14
+ deletePrincipalVault: async ({ workspaceId, principalId }) => {
15
+ await run((db) => db.deleteFrom("secrets_vault").where("workspace_id", "=", workspaceId).where("principal_id", "=", principalId).execute());
16
+ },
17
+ deleteIdentityUser: async ({ workspaceId, principalId }) => {
18
+ await run((db) => db.deleteFrom("identity_users").where("workspace_id", "=", workspaceId).where("principal_id", "=", principalId).execute());
19
+ },
20
+ deletePrincipal: async ({ workspaceId, principalId }) => {
21
+ await run((db) => db.deleteFrom("principals").where("workspace_id", "=", workspaceId).where("id", "=", principalId).execute());
22
+ },
23
+ appendOutbox: async ({ event }) => {
24
+ await run((db) => db.insertInto("outbox_events").values(eventValues(event)).execute());
25
+ },
26
+ };
27
+ }
28
+ /** {@link SqlUserPurge} bound to a storage kernel — the host's real `UserPurgePort`. */
29
+ export class KernelUserPurge extends SqlUserPurge {
30
+ constructor(required, _optional = {}) {
31
+ super({ ports: createKernelUserPurgePorts(required) });
32
+ }
33
+ }
34
+ //# sourceMappingURL=kernel-user-purge.js.map
@@ -0,0 +1,15 @@
1
+ import type { StorageKernel } from "@jini-ai/core/contracts/storage";
2
+ import type { DomainEvent } from "@jini-ai/core/contracts/events";
3
+ import type { Kysely } from "kysely";
4
+ import { type UserTrashAdapterDeps } from "./user-trash-adapter.js";
5
+ export declare function bindKernelUserTrashAdapter({ kernelFor, entityType }: {
6
+ kernelFor: (required: {
7
+ store: StorageKernel<Kysely<unknown>, unknown>;
8
+ }) => () => StorageKernel<Kysely<unknown>, unknown>;
9
+ entityType: string;
10
+ }, _optional?: Record<string, never>): (deps: Pick<UserTrashAdapterDeps, "purge" | "idGen" | "clock"> & {
11
+ db: StorageKernel<Kysely<unknown>, unknown>;
12
+ eventValues: (event: DomainEvent) => Record<string, unknown>;
13
+ assertAccountAction: NonNullable<UserTrashAdapterDeps["policy"]["assertAccountAction"]>;
14
+ }, _optional?: Record<string, never>) => import("@jini-ai/core/contracts/site/cms-trash").TrashAdapter;
15
+ //# sourceMappingURL=kernel-user-trash-store.d.ts.map
@@ -0,0 +1,41 @@
1
+ import { createUserTrashAdapter } from "./user-trash-adapter.js";
2
+ export function bindKernelUserTrashAdapter({ kernelFor, entityType }, _optional = {}) {
3
+ return (deps, _optional = {}) => {
4
+ const kernel = kernelFor({ store: deps.db });
5
+ return createUserTrashAdapter({ ...deps, policy: { entityType, assertAccountAction: deps.assertAccountAction }, store: {
6
+ readPrincipal: async ({ workspaceId, principalId }) => {
7
+ const row = await kernel().run(db => db.withTables().selectFrom("principals")
8
+ .select(["status", "display_name"]).where("workspace_id", "=", workspaceId).where("id", "=", principalId).executeTakeFirst());
9
+ return row ? { status: row.status, displayName: row.display_name } : null;
10
+ },
11
+ readDisplayUsername: async ({ workspaceId, principalId, fallback }) => {
12
+ const row = await kernel().run(db => db.withTables().selectFrom("identity_users")
13
+ .select("username").where("workspace_id", "=", workspaceId).where("principal_id", "=", principalId).executeTakeFirst());
14
+ return row?.username ?? fallback;
15
+ },
16
+ compareAndSetStatus: async ({ workspaceId, principalId, expected, next, disabledAt }) => {
17
+ const result = await kernel().run(db => db.withTables().updateTable("principals")
18
+ .set({ status: next, ...(disabledAt === undefined ? {} : { disabled_at: disabledAt }) })
19
+ .where("workspace_id", "=", workspaceId).where("id", "=", principalId).where("status", "=", expected).executeTakeFirst());
20
+ return Number(result.numUpdatedRows);
21
+ },
22
+ revokeSessions: async ({ workspaceId, principalId }) => {
23
+ const result = await kernel().run(db => db.withTables().deleteFrom("sessions")
24
+ .where("workspace_id", "=", workspaceId).where("principal_id", "=", principalId).executeTakeFirst());
25
+ return Number(result.numDeletedRows);
26
+ },
27
+ appendEvent: async ({ event }) => {
28
+ await kernel().run(db => db.withTables().insertInto("outbox_events").values(deps.eventValues(event)).execute());
29
+ },
30
+ /** Runs `body` in one transaction holding the principal's row lock. */
31
+ underPrincipalLock: ({ workspaceId, principalId, run }) => {
32
+ const k = kernel();
33
+ return k.transaction(async () => {
34
+ await k.lockKey(`trash:${entityType}:${workspaceId}:${principalId}`);
35
+ return run();
36
+ });
37
+ },
38
+ } });
39
+ };
40
+ }
41
+ //# sourceMappingURL=kernel-user-trash-store.js.map