@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.
- package/CHANGELOG.md +7 -0
- package/README.md +55 -2
- package/dist/admin/adapters/memory.js +4 -4
- package/dist/admin-http/auth/auth-request.d.ts +112 -0
- package/dist/admin-http/auth/auth-request.js +32 -0
- package/dist/admin-http/auth/boot-redemption.d.ts +9 -0
- package/dist/admin-http/auth/boot-redemption.js +17 -0
- package/dist/admin-http/auth/boot-session.d.ts +30 -0
- package/dist/admin-http/auth/boot-session.js +40 -0
- package/dist/admin-http/auth/current-user.d.ts +28 -0
- package/dist/admin-http/auth/current-user.js +34 -0
- package/dist/admin-http/auth/index.d.ts +17 -0
- package/dist/admin-http/auth/index.js +9 -0
- package/dist/admin-http/auth/local-boot-session.d.ts +9 -0
- package/dist/admin-http/auth/local-boot-session.js +30 -0
- package/dist/admin-http/auth/logout.d.ts +10 -0
- package/dist/admin-http/auth/logout.js +17 -0
- package/dist/admin-http/auth/mfa-login.d.ts +30 -0
- package/dist/admin-http/auth/mfa-login.js +43 -0
- package/dist/admin-http/auth/password-login.d.ts +35 -0
- package/dist/admin-http/auth/password-login.js +52 -0
- package/dist/admin-http/auth/password-status.d.ts +34 -0
- package/dist/admin-http/auth/password-status.js +42 -0
- package/dist/admin-http/http/api-keys.d.ts +45 -0
- package/dist/admin-http/http/api-keys.js +28 -0
- package/dist/admin-http/http/users.d.ts +71 -0
- package/dist/admin-http/http/users.js +42 -0
- package/dist/admin-http/owner/mfa-deps.d.ts +41 -0
- package/dist/admin-http/owner/mfa-deps.js +26 -0
- package/dist/admin-http/owner/mfa-routes.d.ts +72 -0
- package/dist/admin-http/owner/mfa-routes.js +105 -0
- package/dist/admin-http/owner/passkey-admission.d.ts +46 -0
- package/dist/admin-http/owner/passkey-admission.js +23 -0
- package/dist/admin-http/owner/passkey-route-deps.d.ts +53 -0
- package/dist/admin-http/owner/passkey-route-deps.js +33 -0
- package/dist/admin-http/owner/passkey-routes.d.ts +146 -0
- package/dist/admin-http/owner/passkey-routes.js +98 -0
- package/dist/admin-http/owner/recovery-routes.d.ts +71 -0
- package/dist/admin-http/owner/recovery-routes.js +112 -0
- package/dist/admin-http/routes/api-keys/create-principal.d.ts +26 -0
- package/dist/admin-http/routes/api-keys/create-principal.js +37 -0
- package/dist/admin-http/routes/api-keys/issue.d.ts +32 -0
- package/dist/admin-http/routes/api-keys/issue.js +38 -0
- package/dist/admin-http/routes/api-keys/revoke.d.ts +26 -0
- package/dist/admin-http/routes/api-keys/revoke.js +31 -0
- package/dist/admin-http/routes/api-keys/shared.d.ts +46 -0
- package/dist/admin-http/routes/api-keys/shared.js +38 -0
- package/dist/admin-http/routes/users/access-shared.d.ts +103 -0
- package/dist/admin-http/routes/users/access-shared.js +85 -0
- package/dist/admin-http/routes/users/assign-role.d.ts +24 -0
- package/dist/admin-http/routes/users/assign-role.js +30 -0
- package/dist/admin-http/routes/users/attach-policy.d.ts +25 -0
- package/dist/admin-http/routes/users/attach-policy.js +31 -0
- package/dist/admin-http/routes/users/create-policy.d.ts +19 -0
- package/dist/admin-http/routes/users/create-policy.js +28 -0
- package/dist/admin-http/routes/users/create-role.d.ts +15 -0
- package/dist/admin-http/routes/users/create-role.js +21 -0
- package/dist/admin-http/routes/users/create.d.ts +32 -0
- package/dist/admin-http/routes/users/create.js +67 -0
- package/dist/admin-http/routes/users/delete-policy.d.ts +16 -0
- package/dist/admin-http/routes/users/delete-policy.js +24 -0
- package/dist/admin-http/routes/users/delete-role.d.ts +16 -0
- package/dist/admin-http/routes/users/delete-role.js +24 -0
- package/dist/admin-http/routes/users/delete.d.ts +35 -0
- package/dist/admin-http/routes/users/delete.js +35 -0
- package/dist/admin-http/routes/users/disable.d.ts +31 -0
- package/dist/admin-http/routes/users/disable.js +38 -0
- package/dist/admin-http/routes/users/enable.d.ts +32 -0
- package/dist/admin-http/routes/users/enable.js +45 -0
- package/dist/admin-http/routes/users/list-policies.d.ts +18 -0
- package/dist/admin-http/routes/users/list-policies.js +20 -0
- package/dist/admin-http/routes/users/list-policy-permissions.d.ts +28 -0
- package/dist/admin-http/routes/users/list-policy-permissions.js +30 -0
- package/dist/admin-http/routes/users/list-roles.d.ts +18 -0
- package/dist/admin-http/routes/users/list-roles.js +20 -0
- package/dist/admin-http/routes/users/list.d.ts +40 -0
- package/dist/admin-http/routes/users/list.js +82 -0
- package/dist/admin-http/routes/users/remove-policy-permission.d.ts +48 -0
- package/dist/admin-http/routes/users/remove-policy-permission.js +62 -0
- package/dist/admin-http/routes/users/reset-password.d.ts +33 -0
- package/dist/admin-http/routes/users/reset-password.js +52 -0
- package/dist/admin-http/routes/users/shared.d.ts +124 -0
- package/dist/admin-http/routes/users/shared.js +93 -0
- package/dist/admin-http/routes/users/update-policy.d.ts +25 -0
- package/dist/admin-http/routes/users/update-policy.js +30 -0
- package/dist/admin-http/routes/users/update-role.d.ts +23 -0
- package/dist/admin-http/routes/users/update-role.js +29 -0
- package/dist/admin-http/routes/users/update.d.ts +35 -0
- package/dist/admin-http/routes/users/update.js +78 -0
- package/dist/admin-http/routes/users/write-policy-permission.d.ts +31 -0
- package/dist/admin-http/routes/users/write-policy-permission.js +45 -0
- package/dist/core/ports.d.ts +22 -3
- package/dist/core/types.d.ts +17 -5
- package/dist/core/types.js +12 -0
- package/dist/identity/api-key-secret.d.ts +68 -0
- package/dist/identity/api-key-secret.js +229 -0
- package/dist/identity/api-key-service.d.ts +144 -0
- package/dist/identity/api-key-service.js +389 -0
- package/dist/identity/api-key-types.d.ts +79 -0
- package/dist/identity/api-key-types.js +2 -0
- package/dist/identity/boot-session-token.d.ts +18 -0
- package/dist/identity/boot-session-token.js +92 -0
- package/dist/identity/builtin-role-grants.d.ts +120 -0
- package/dist/identity/builtin-role-grants.js +88 -0
- package/dist/identity/delete-user-service.d.ts +195 -0
- package/dist/identity/delete-user-service.js +275 -0
- package/dist/identity/owner-reset-env.d.ts +37 -0
- package/dist/identity/owner-reset-env.js +38 -0
- package/dist/identity/permission-grants.d.ts +31 -0
- package/dist/identity/permission-grants.js +12 -0
- package/dist/identity/permission-list-tool.d.ts +35 -0
- package/dist/identity/permission-list-tool.js +47 -0
- package/dist/identity/repo.authentication.d.ts +57 -0
- package/dist/identity/repo.authentication.js +153 -0
- package/dist/identity/repo.authorization.d.ts +82 -0
- package/dist/identity/repo.authorization.js +203 -0
- package/dist/identity/repo.d.ts +87 -0
- package/dist/identity/repo.js +167 -0
- package/dist/identity/repo.memory.d.ts +31 -0
- package/dist/identity/repo.memory.js +37 -0
- package/dist/identity/role-manage-permission.d.ts +34 -0
- package/dist/identity/role-manage-permission.js +39 -0
- package/dist/identity/site-key-permission.d.ts +66 -0
- package/dist/identity/site-key-permission.js +92 -0
- package/dist/identity/sql/kernel-user-purge.d.ts +19 -0
- package/dist/identity/sql/kernel-user-purge.js +34 -0
- package/dist/identity/sql/kernel-user-trash-store.d.ts +15 -0
- package/dist/identity/sql/kernel-user-trash-store.js +41 -0
- package/dist/identity/sql/user-trash-adapter.d.ts +87 -0
- package/dist/identity/sql/user-trash-adapter.js +124 -0
- package/dist/identity/tool-registrations.d.ts +100 -0
- package/dist/identity/tool-registrations.js +257 -0
- package/dist/identity/user-manage-permission.d.ts +8 -0
- package/dist/identity/user-manage-permission.js +8 -0
- package/dist/identity/user-purge-types.d.ts +85 -0
- package/dist/identity/user-purge-types.js +17 -0
- package/dist/identity/user-purge.d.ts +69 -0
- package/dist/identity/user-purge.js +46 -0
- package/dist/identity/username-change-ports.d.ts +15 -0
- package/dist/identity/username-change-ports.js +22 -0
- package/dist/mail/site/capture-clear.d.ts +58 -0
- package/dist/mail/site/capture-clear.js +21 -0
- package/dist/mail/status/agent-tools.d.ts +65 -0
- package/dist/mail/status/agent-tools.js +22 -0
- package/dist/mail/status/delivery-agent-tools.d.ts +206 -0
- package/dist/mail/status/delivery-agent-tools.js +63 -0
- package/dist/mail/status/delivery-tool-registrations.d.ts +216 -0
- package/dist/mail/status/delivery-tool-registrations.js +110 -0
- package/dist/mail/status/domain-deps.d.ts +25 -0
- package/dist/mail/status/domain-deps.js +23 -0
- package/dist/mail/status/permissions.d.ts +43 -0
- package/dist/mail/status/permissions.js +45 -0
- package/dist/mail/status/provider-agent-tools.d.ts +38 -0
- package/dist/mail/status/provider-agent-tools.js +17 -0
- package/dist/mail/status/provider-operations.d.ts +166 -0
- package/dist/mail/status/provider-operations.js +121 -0
- package/dist/mail/status/provider-tool-registrations.d.ts +65 -0
- package/dist/mail/status/provider-tool-registrations.js +106 -0
- package/dist/mail/status/tool-registrations.d.ts +152 -0
- package/dist/mail/status/tool-registrations.js +112 -0
- package/dist/member-login/credentials.d.ts +40 -0
- package/dist/member-login/credentials.js +26 -0
- package/dist/member-login/link-service.d.ts +66 -0
- package/dist/member-login/link-service.js +141 -0
- package/dist/member-login/oidc-login.d.ts +132 -0
- package/dist/member-login/oidc-login.js +206 -0
- package/dist/member-login/oidc-request.d.ts +80 -0
- package/dist/member-login/oidc-request.js +86 -0
- package/dist/member-login/providers.d.ts +79 -0
- package/dist/member-login/providers.js +41 -0
- package/dist/member-login/ready-providers.d.ts +17 -0
- package/dist/member-login/ready-providers.js +11 -0
- package/dist/member-login/unlink-identity.d.ts +26 -0
- package/dist/member-login/unlink-identity.js +59 -0
- package/dist/members/access-resolver.d.ts +107 -0
- package/dist/members/access-resolver.js +231 -0
- package/dist/members/agent-tools.d.ts +14 -0
- package/dist/members/agent-tools.js +139 -0
- package/dist/members/auth-mail.d.ts +27 -0
- package/dist/members/auth-mail.js +21 -0
- package/dist/members/capability-card.d.ts +18 -0
- package/dist/members/capability-card.js +27 -0
- package/dist/members/consent-service.d.ts +115 -0
- package/dist/members/consent-service.js +179 -0
- package/dist/members/member-admin-writes.d.ts +73 -0
- package/dist/members/member-admin-writes.js +149 -0
- package/dist/members/member-challenge-request.d.ts +59 -0
- package/dist/members/member-challenge-request.js +145 -0
- package/dist/members/member-challenge.d.ts +37 -0
- package/dist/members/member-challenge.js +84 -0
- package/dist/members/member-credentials.d.ts +35 -0
- package/dist/members/member-credentials.js +57 -0
- package/dist/members/member-sign-in.d.ts +44 -0
- package/dist/members/member-sign-in.js +130 -0
- package/dist/members/member-validation.d.ts +5 -0
- package/dist/members/member-validation.js +13 -0
- package/dist/members/password-auth.d.ts +55 -0
- package/dist/members/password-auth.js +177 -0
- package/dist/members/ports.d.ts +455 -0
- package/dist/members/ports.js +21 -0
- package/dist/members/public-member-auth-response.d.ts +68 -0
- package/dist/members/public-member-auth-response.js +45 -0
- package/dist/members/public-member-response.d.ts +25 -0
- package/dist/members/public-member-response.js +15 -0
- package/dist/members/repo.d.ts +199 -0
- package/dist/members/repo.js +324 -0
- package/dist/members/repo.memory.d.ts +276 -0
- package/dist/members/repo.memory.js +395 -0
- package/dist/members/repo.rows.d.ts +153 -0
- package/dist/members/repo.rows.js +250 -0
- package/dist/members/repo.sessions.d.ts +80 -0
- package/dist/members/repo.sessions.js +166 -0
- package/dist/members/repo.sql.d.ts +9 -0
- package/dist/members/repo.sql.js +11 -0
- package/dist/members/subscriber-directory.d.ts +85 -0
- package/dist/members/subscriber-directory.js +70 -0
- package/dist/members/tool-registrations.d.ts +143 -0
- package/dist/members/tool-registrations.js +247 -0
- package/dist/members/trash-member.d.ts +24 -0
- package/dist/members/trash-member.js +24 -0
- package/dist/members/types.d.ts +321 -0
- package/dist/members/types.js +34 -0
- package/dist/members/write-service.d.ts +17 -0
- package/dist/members/write-service.js +15 -0
- package/dist/newsletter/agent-tools.d.ts +20 -0
- package/dist/newsletter/agent-tools.js +236 -0
- package/dist/newsletter/campaign-write-service.d.ts +92 -0
- package/dist/newsletter/campaign-write-service.js +190 -0
- package/dist/newsletter/campaign.d.ts +53 -0
- package/dist/newsletter/campaign.js +95 -0
- package/dist/newsletter/confirmation.d.ts +75 -0
- package/dist/newsletter/confirmation.js +142 -0
- package/dist/newsletter/data-module-manifest.d.ts +68 -0
- package/dist/newsletter/data-module-manifest.js +126 -0
- package/dist/newsletter/delivery/tool-registrations.d.ts +67 -0
- package/dist/newsletter/delivery/tool-registrations.js +229 -0
- package/dist/newsletter/errors.d.ts +93 -0
- package/dist/newsletter/errors.js +93 -0
- package/dist/newsletter/hooks.d.ts +59 -0
- package/dist/newsletter/hooks.js +49 -0
- package/dist/newsletter/http-error-responses.d.ts +17 -0
- package/dist/newsletter/http-error-responses.js +96 -0
- package/dist/newsletter/launch-gate.d.ts +62 -0
- package/dist/newsletter/launch-gate.js +29 -0
- package/dist/newsletter/lists.d.ts +60 -0
- package/dist/newsletter/lists.js +83 -0
- package/dist/newsletter/ports.d.ts +283 -0
- package/dist/newsletter/ports.js +2 -0
- package/dist/newsletter/repo-sends.d.ts +82 -0
- package/dist/newsletter/repo-sends.js +178 -0
- package/dist/newsletter/repo-subscribers.d.ts +83 -0
- package/dist/newsletter/repo-subscribers.js +215 -0
- package/dist/newsletter/repo.d.ts +61 -0
- package/dist/newsletter/repo.js +147 -0
- package/dist/newsletter/repo.memory.d.ts +202 -0
- package/dist/newsletter/repo.memory.js +260 -0
- package/dist/newsletter/repo.rows.d.ts +221 -0
- package/dist/newsletter/repo.rows.js +260 -0
- package/dist/newsletter/save-guard.d.ts +32 -0
- package/dist/newsletter/save-guard.js +27 -0
- package/dist/newsletter/send-pipeline.d.ts +240 -0
- package/dist/newsletter/send-pipeline.js +514 -0
- package/dist/newsletter/subscriptions.d.ts +87 -0
- package/dist/newsletter/subscriptions.js +119 -0
- package/dist/newsletter/tool-registrations.d.ts +89 -0
- package/dist/newsletter/tool-registrations.deps.d.ts +9 -0
- package/dist/newsletter/tool-registrations.deps.js +9 -0
- package/dist/newsletter/tool-registrations.js +133 -0
- package/dist/newsletter/tool-registrations.read.d.ts +76 -0
- package/dist/newsletter/tool-registrations.read.js +140 -0
- package/dist/newsletter/tool-registrations.write.d.ts +54 -0
- package/dist/newsletter/tool-registrations.write.js +229 -0
- package/dist/newsletter/types.d.ts +279 -0
- package/dist/newsletter/types.js +23 -0
- package/dist/newsletter/unsubscribe.d.ts +41 -0
- package/dist/newsletter/unsubscribe.js +100 -0
- package/dist/project-keys/attached-vault.d.ts +23 -0
- package/dist/project-keys/attached-vault.js +65 -0
- package/dist/project-keys/create-vault.d.ts +17 -0
- package/dist/project-keys/create-vault.js +29 -0
- package/dist/project-keys/service.d.ts +133 -0
- package/dist/project-keys/service.js +128 -0
- package/dist/project-keys/site-references.d.ts +30 -0
- package/dist/project-keys/site-references.js +63 -0
- package/dist/project-keys/site-sealer.d.ts +28 -0
- package/dist/project-keys/site-sealer.js +64 -0
- package/dist/project-keys/sql/attachments.d.ts +33 -0
- package/dist/project-keys/sql/attachments.js +55 -0
- package/dist/project-keys/tools.d.ts +86 -0
- package/dist/project-keys/tools.js +66 -0
- package/dist/public-http/routes/mail/feedback.d.ts +44 -0
- package/dist/public-http/routes/mail/feedback.js +17 -0
- package/dist/public-http/routes/newsletter/confirm.d.ts +38 -0
- package/dist/public-http/routes/newsletter/confirm.js +33 -0
- package/dist/public-http/routes/newsletter/page.d.ts +29 -0
- package/dist/public-http/routes/newsletter/page.js +34 -0
- package/dist/public-http/routes/newsletter/unsubscribe.d.ts +33 -0
- package/dist/public-http/routes/newsletter/unsubscribe.js +35 -0
- package/dist/react/auth/Passkeys.d.ts +2 -34
- package/dist/react/auth/RecoveryCodesCard.d.ts +27 -0
- package/dist/react/auth/RecoveryCodesCard.hooks.d.ts +67 -0
- package/dist/react/auth/RecoveryCodesCard.hooks.js +38 -0
- package/dist/react/auth/RecoveryCodesCard.js +56 -0
- package/dist/react/auth/TotpSettings.d.ts +2 -23
- package/dist/react/auth/local-owner-signin.d.ts +40 -0
- package/dist/react/auth/local-owner-signin.js +25 -0
- package/dist/react/auth/owner-mfa-api.d.ts +10 -0
- package/dist/react/auth/owner-mfa-api.js +17 -0
- package/dist/react/auth/owner-passkey-api.d.ts +11 -0
- package/dist/react/auth/owner-passkey-api.js +17 -0
- package/dist/react/auth/owner-recovery-api.d.ts +51 -0
- package/dist/react/auth/owner-recovery-api.js +29 -0
- package/dist/react/auth/owner-request.d.ts +7 -0
- package/dist/react/auth/owner-request.js +2 -0
- package/dist/react/index.d.ts +10 -0
- package/dist/react/index.js +6 -0
- package/dist/react/mail/Email.d.ts +20 -0
- package/dist/react/mail/Email.js +143 -0
- package/dist/react/mail/EmailProviderTab.d.ts +34 -0
- package/dist/react/mail/EmailProviderTab.js +132 -0
- package/dist/react/mail/EmailSegments.d.ts +24 -0
- package/dist/react/mail/EmailSegments.js +15 -0
- package/dist/react/mail/EmailTemplateEditor.d.ts +146 -0
- package/dist/react/mail/EmailTemplateEditor.js +116 -0
- package/dist/react/mail/email-view.types.d.ts +236 -0
- package/dist/react/mail/email-view.types.js +2 -0
- package/dist/react/members/Members.d.ts +5 -3
- package/dist/react/members/Members.js +3 -3
- package/dist/react/members/api/members-api.d.ts +37 -0
- package/dist/react/members/api/members-api.js +16 -0
- package/dist/react/members/hooks/use-members.hooks.js +2 -1
- package/dist/react/members/members-i18n.d.ts +23 -0
- package/dist/react/members/members-i18n.js +25 -0
- package/dist/react/members/members-i18n.locales-a.d.ts +4 -0
- package/dist/react/members/members-i18n.locales-a.js +294 -0
- package/dist/react/members/members-i18n.locales-b.d.ts +4 -0
- package/dist/react/members/members-i18n.locales-b.js +265 -0
- package/dist/react/models.d.ts +1 -49
- package/dist/react/ports.d.ts +3 -143
- package/dist/react/roles/api/roles-api.d.ts +74 -0
- package/dist/react/roles/api/roles-api.js +22 -0
- package/dist/react/testing.js +18 -9
- package/dist/react/users/UsersPanel.d.ts +30 -0
- package/dist/react/users/UsersPanel.hooks.d.ts +8 -0
- package/dist/react/users/UsersPanel.hooks.js +9 -0
- package/dist/react/users/UsersPanel.js +9 -0
- package/dist/react/users/api/users-api.d.ts +65 -0
- package/dist/react/users/api/users-api.js +46 -0
- package/dist/react/users/hooks/use-localized-users.hooks.d.ts +43 -0
- package/dist/react/users/hooks/use-localized-users.hooks.js +15 -0
- package/dist/react/users/hooks/use-users-state.hooks.d.ts +18 -18
- package/dist/react/users/password-reset-notice.d.ts +8 -0
- package/dist/react/users/password-reset-notice.js +36 -0
- package/dist/server/admin-crud-service.d.ts +4 -10
- package/dist/server/admin-crud-service.js +20 -6
- package/dist/server/agent-tool-registrations.js +26 -7
- package/dist/server/agent-tools.js +22 -7
- package/dist/server/auth-challenge.d.ts +1 -1
- package/dist/server/auth-service.js +2 -1
- package/dist/server/grant-service.d.ts +1 -0
- package/dist/server/grant-service.js +7 -4
- package/dist/server/mfa/passkey-service.d.ts +2 -2
- package/dist/server/mfa/passkey-service.js +1 -1
- package/dist/server/mfa/service.js +6 -4
- package/dist/server/repo.memory.d.ts +30 -2
- package/dist/server/repo.memory.js +58 -4
- package/dist/server/seed.js +3 -3
- package/dist/server/sql/assignments.d.ts +90 -0
- package/dist/server/sql/assignments.js +128 -0
- package/dist/server/sql/index.d.ts +6 -0
- package/dist/server/sql/index.js +5 -0
- package/dist/server/sql/kernel.d.ts +9 -0
- package/dist/server/sql/kernel.js +2 -0
- package/dist/server/sql/mfa.d.ts +36 -0
- package/dist/server/sql/mfa.js +51 -0
- package/dist/server/sql/passkeys.d.ts +25 -0
- package/dist/server/sql/passkeys.js +33 -0
- package/dist/server/sql/recovery-codes.d.ts +22 -0
- package/dist/server/sql/recovery-codes.js +32 -0
- package/package.json +909 -11
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
|
|
2
|
+
import { RouteRefusalError } from "@jini-ai/core/errors/route-refusal";
|
|
3
|
+
import { IdentityConflictError } from "../../../core/types.js";
|
|
4
|
+
import { toAdminUserResponse } from "../../http/users.js";
|
|
5
|
+
import { rejectUserError, USER_FORBIDDEN, USER_USERNAME_CONFLICT, USER_VALIDATION, userActorId, } from "./shared.js";
|
|
6
|
+
/** Unmapped failures go to the host. */
|
|
7
|
+
const USER_CREATE_ERRORS = [USER_FORBIDDEN, USER_USERNAME_CONFLICT, USER_VALIDATION];
|
|
8
|
+
/**
|
|
9
|
+
* OWNER DECISION 2026-09-24 (delete-user plan v2, decision 7) — re-derives whether `rawUsername`'s
|
|
10
|
+
* existing holder (the one `createUser` itself just found and rejected as a conflict) is currently
|
|
11
|
+
* in the Trash. Run only AFTER `createUser` throws `IdentityConflictError`, not as a pre-check
|
|
12
|
+
* before calling it: `createUser` runs its own permission gate first (`assertCallerHasAnyPermission`),
|
|
13
|
+
* so pre-checking here would leak "a trashed user holds this username" to a caller who was never
|
|
14
|
+
* authorized to reach the conflict path at all. `normalizeUsername` is the exact function
|
|
15
|
+
* `createUser` normalizes with internally, so this looks up the SAME row `createUser` found.
|
|
16
|
+
*
|
|
17
|
+
* @complexity O(1): one normalize, one indexed `findByUsername`, one `isInTrash` check.
|
|
18
|
+
*/
|
|
19
|
+
async function usernameHeldByTrashedUser({ deps, rawUsername }, _optional = {}) {
|
|
20
|
+
const username = deps.normalizeUsername({ raw: rawUsername });
|
|
21
|
+
if (!username)
|
|
22
|
+
return false;
|
|
23
|
+
const existingUser = await deps.identityServices().repos.users.findByUsername({ workspaceId: deps.workspaceId, username });
|
|
24
|
+
if (!existingUser)
|
|
25
|
+
return false;
|
|
26
|
+
return deps.isInTrash({ principalId: existingUser.principalId });
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* POST users — `CREATE_USER` (state.spec §3, REQ-01/MF-1). Gated by `user.manage` only (operator
|
|
30
|
+
* login creation), enforced inside `grant-service.ts`'s `createUser` rather than here — see that
|
|
31
|
+
* file's header for why the gate lives in the service function.
|
|
32
|
+
*
|
|
33
|
+
* Not routed through the SPEC-001 command gateway: `CREATE_USER` mints two rows (principal + user)
|
|
34
|
+
* as one structural unit, not a single entity with a natural inverse-capture/revert story.
|
|
35
|
+
*/
|
|
36
|
+
export const userCreateRoute = defineJsonRoute({
|
|
37
|
+
method: "post",
|
|
38
|
+
path: "/api/admin/v1/workspaces/:workspaceId/users",
|
|
39
|
+
parse: (raw) => {
|
|
40
|
+
const body = (raw.body ?? {});
|
|
41
|
+
return ok({ value: {
|
|
42
|
+
username: String(body.username ?? ""),
|
|
43
|
+
email: body.email !== undefined ? String(body.email) : undefined,
|
|
44
|
+
password: String(body.password ?? ""),
|
|
45
|
+
} });
|
|
46
|
+
},
|
|
47
|
+
handle: async ({ input, deps, context }) => {
|
|
48
|
+
const callerPrincipalId = userActorId({ context });
|
|
49
|
+
try {
|
|
50
|
+
const { principal, user } = await deps.createUser({
|
|
51
|
+
deps: deps.identityServices(),
|
|
52
|
+
input: { workspaceId: deps.workspaceId, callerPrincipalId, username: input.username, password: input.password },
|
|
53
|
+
}, { email: input.email });
|
|
54
|
+
return ok({ value: { user: toAdminUserResponse({ principal, user, roleIds: [], policyIds: [] }) } });
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
// OWNER DECISION 2026-09-24 (decision 7) — a username conflict `createUser` itself already
|
|
58
|
+
// found and rejected may belong to a TRASHED user; see `usernameHeldByTrashedUser`'s doc for
|
|
59
|
+
// why this re-check runs only here, after `createUser`'s own permission gate has passed.
|
|
60
|
+
if (err instanceof IdentityConflictError && (await usernameHeldByTrashedUser({ deps, rawUsername: input.username }))) {
|
|
61
|
+
throw new RouteRefusalError({ status: 409, body: { error: "a user with this username is in the Trash; restore or delete them permanently first", code: "USERNAME_IN_TRASH" } });
|
|
62
|
+
}
|
|
63
|
+
return rejectUserError({ err, rungs: USER_CREATE_ERRORS });
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
}, { successStatus: 201 });
|
|
67
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { deletePolicy } from "../../../server/admin-crud-service.js";
|
|
2
|
+
import { type AccessRoutePrincipal, type AccessServiceRouteDeps } from "./access-shared.js";
|
|
3
|
+
/** The deps this route reads: the workspace, the identity services' deps bag and the service it calls. */
|
|
4
|
+
export interface PolicyDeleteRouteDeps extends AccessServiceRouteDeps {
|
|
5
|
+
/** Injected: the service lives in the node `./server` entry; the host binds it. */
|
|
6
|
+
deletePolicy: typeof deletePolicy;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* DELETE policies/:policyId — `DELETE_POLICY` (SPEC-006 0.6.0, REQ-19/INV-09). Gated by
|
|
10
|
+
* `role.manage`; a built-in or frozen target is refused `VALIDATION_ERROR`, a still-referenced
|
|
11
|
+
* target `RESOURCE_CONFLICT` (AC-31). Answers 204 with no body.
|
|
12
|
+
*/
|
|
13
|
+
export declare const policyDeleteRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
|
|
14
|
+
policyId: string;
|
|
15
|
+
}, undefined, PolicyDeleteRouteDeps, AccessRoutePrincipal>;
|
|
16
|
+
//# sourceMappingURL=delete-policy.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
|
|
2
|
+
import { ACCESS_FORBIDDEN, ACCESS_NOT_FOUND, ACCESS_VALIDATION, accessActorId, accessConflictOn, accessPathParam, rejectAccessError, } from "./access-shared.js";
|
|
3
|
+
const POLICY_DELETE_ERRORS = [ACCESS_FORBIDDEN, accessConflictOn({ field: "policyId" }), ACCESS_VALIDATION, ACCESS_NOT_FOUND];
|
|
4
|
+
/**
|
|
5
|
+
* DELETE policies/:policyId — `DELETE_POLICY` (SPEC-006 0.6.0, REQ-19/INV-09). Gated by
|
|
6
|
+
* `role.manage`; a built-in or frozen target is refused `VALIDATION_ERROR`, a still-referenced
|
|
7
|
+
* target `RESOURCE_CONFLICT` (AC-31). Answers 204 with no body.
|
|
8
|
+
*/
|
|
9
|
+
export const policyDeleteRoute = defineJsonRoute({
|
|
10
|
+
method: "delete",
|
|
11
|
+
path: "/api/admin/v1/workspaces/:workspaceId/policies/:policyId",
|
|
12
|
+
parse: (raw) => ok({ value: { policyId: accessPathParam({ params: raw.params, name: "policyId" }) } }),
|
|
13
|
+
handle: async ({ input, deps, context }) => {
|
|
14
|
+
const callerPrincipalId = accessActorId({ context });
|
|
15
|
+
try {
|
|
16
|
+
await deps.deletePolicy({ deps: deps.identityServiceDeps(), input: { workspaceId: deps.workspaceId, callerPrincipalId, policyId: input.policyId } });
|
|
17
|
+
return ok({ value: undefined });
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
return rejectAccessError({ err, mappings: POLICY_DELETE_ERRORS });
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
}, { successStatus: 204 });
|
|
24
|
+
//# sourceMappingURL=delete-policy.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { deleteRole } from "../../../server/admin-crud-service.js";
|
|
2
|
+
import { type AccessRoutePrincipal, type AccessServiceRouteDeps } from "./access-shared.js";
|
|
3
|
+
/** The deps this route reads: the workspace, the identity services' deps bag and the service it calls. */
|
|
4
|
+
export interface RoleDeleteRouteDeps extends AccessServiceRouteDeps {
|
|
5
|
+
/** Injected: the service lives in the node `./server` entry; the host binds it. */
|
|
6
|
+
deleteRole: typeof deleteRole;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* DELETE roles/:roleId — `DELETE_ROLE` (SPEC-006 0.6.0, REQ-19/INV-09). Gated by `role.manage`; a
|
|
10
|
+
* built-in target is refused `VALIDATION_ERROR`, a still-referenced target `RESOURCE_CONFLICT`
|
|
11
|
+
* (AC-31). Answers 204 with no body.
|
|
12
|
+
*/
|
|
13
|
+
export declare const roleDeleteRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
|
|
14
|
+
roleId: string;
|
|
15
|
+
}, undefined, RoleDeleteRouteDeps, AccessRoutePrincipal>;
|
|
16
|
+
//# sourceMappingURL=delete-role.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
|
|
2
|
+
import { ACCESS_FORBIDDEN, ACCESS_NOT_FOUND, ACCESS_VALIDATION, accessActorId, accessConflictOn, accessPathParam, rejectAccessError, } from "./access-shared.js";
|
|
3
|
+
const ROLE_DELETE_ERRORS = [ACCESS_FORBIDDEN, accessConflictOn({ field: "roleId" }), ACCESS_VALIDATION, ACCESS_NOT_FOUND];
|
|
4
|
+
/**
|
|
5
|
+
* DELETE roles/:roleId — `DELETE_ROLE` (SPEC-006 0.6.0, REQ-19/INV-09). Gated by `role.manage`; a
|
|
6
|
+
* built-in target is refused `VALIDATION_ERROR`, a still-referenced target `RESOURCE_CONFLICT`
|
|
7
|
+
* (AC-31). Answers 204 with no body.
|
|
8
|
+
*/
|
|
9
|
+
export const roleDeleteRoute = defineJsonRoute({
|
|
10
|
+
method: "delete",
|
|
11
|
+
path: "/api/admin/v1/workspaces/:workspaceId/roles/:roleId",
|
|
12
|
+
parse: (raw) => ok({ value: { roleId: accessPathParam({ params: raw.params, name: "roleId" }) } }),
|
|
13
|
+
handle: async ({ input, deps, context }) => {
|
|
14
|
+
const callerPrincipalId = accessActorId({ context });
|
|
15
|
+
try {
|
|
16
|
+
await deps.deleteRole({ deps: deps.identityServiceDeps(), input: { workspaceId: deps.workspaceId, callerPrincipalId, roleId: input.roleId } });
|
|
17
|
+
return ok({ value: undefined });
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
return rejectAccessError({ err, mappings: ROLE_DELETE_ERRORS });
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
}, { successStatus: 204 });
|
|
24
|
+
//# sourceMappingURL=delete-role.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type HostErrorPredicate, type UserRoutePrincipal } from "./shared.js";
|
|
2
|
+
/**
|
|
3
|
+
* Moves one user to the Trash. Injected because the trash pipeline is the host's: it owns the
|
|
4
|
+
* Trash store, the self/owner/admin rules and the purge. It throws the identity errors the ladder
|
|
5
|
+
* maps, plus the host's self-target and "no Trash wiring" errors (matched by injected predicates).
|
|
6
|
+
*/
|
|
7
|
+
export type UserTrashFn = (required: {
|
|
8
|
+
workspaceId: string;
|
|
9
|
+
callerPrincipalId: string;
|
|
10
|
+
principalId: string;
|
|
11
|
+
seededOwnerPrincipalId: string;
|
|
12
|
+
}) => Promise<unknown>;
|
|
13
|
+
/** The deps this route reads. */
|
|
14
|
+
export interface UserDeleteRouteDeps {
|
|
15
|
+
workspaceId: string;
|
|
16
|
+
/** The seeded (bootstrap) owner's principal id, resolved by the host at boot. */
|
|
17
|
+
ownerPrincipalId: PromiseLike<string> | string;
|
|
18
|
+
trashUser: UserTrashFn;
|
|
19
|
+
isSelfDeleteError: HostErrorPredicate;
|
|
20
|
+
/** Matches the host's error for a composition root with no Trash wiring (answered 501). */
|
|
21
|
+
isUserDeleteUnsupportedError: HostErrorPredicate;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* DELETE users/:principalId — moves a user to the Trash (delete-user plan v2, decisions 4/5/7, and
|
|
25
|
+
* the OWNER DECISION 2026-09-24 that supersedes decision 1). Gated by the caller being the owner or
|
|
26
|
+
* holding the built-in `admin` role; refuses the caller's own principal (`SELF_DELETE`), the seeded
|
|
27
|
+
* owner or the workspace's last active owner-`*` principal (`OWNER_REQUIRED`); a target already in
|
|
28
|
+
* the Trash is an idempotent 204; 501s when the composition root has no Trash wiring
|
|
29
|
+
* (`NOT_SUPPORTED`, the in-memory identity store) — see the host's trash move for the full rule
|
|
30
|
+
* set. Permanent deletion happens only through the Trash's own purge, never here.
|
|
31
|
+
*/
|
|
32
|
+
export declare const userDeleteRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
|
|
33
|
+
principalId: string;
|
|
34
|
+
}, undefined, UserDeleteRouteDeps, UserRoutePrincipal>;
|
|
35
|
+
//# sourceMappingURL=delete.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
|
|
2
|
+
import { hostRung, principalIdParam, rejectUserError, USER_FORBIDDEN, USER_NOT_FOUND, USER_OWNER_REQUIRED, USER_VALIDATION, userActorId, } from "./shared.js";
|
|
3
|
+
/** This route's ladder, in the hand-written order. @complexity O(1). */
|
|
4
|
+
function userDeleteErrors({ deps }, _optional = {}) {
|
|
5
|
+
return [
|
|
6
|
+
USER_FORBIDDEN, hostRung({ matches: deps.isSelfDeleteError, status: 409, code: "SELF_DELETE" }), USER_OWNER_REQUIRED, USER_VALIDATION, USER_NOT_FOUND,
|
|
7
|
+
hostRung({ matches: deps.isUserDeleteUnsupportedError, status: 501, code: "NOT_SUPPORTED" }),
|
|
8
|
+
];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* DELETE users/:principalId — moves a user to the Trash (delete-user plan v2, decisions 4/5/7, and
|
|
12
|
+
* the OWNER DECISION 2026-09-24 that supersedes decision 1). Gated by the caller being the owner or
|
|
13
|
+
* holding the built-in `admin` role; refuses the caller's own principal (`SELF_DELETE`), the seeded
|
|
14
|
+
* owner or the workspace's last active owner-`*` principal (`OWNER_REQUIRED`); a target already in
|
|
15
|
+
* the Trash is an idempotent 204; 501s when the composition root has no Trash wiring
|
|
16
|
+
* (`NOT_SUPPORTED`, the in-memory identity store) — see the host's trash move for the full rule
|
|
17
|
+
* set. Permanent deletion happens only through the Trash's own purge, never here.
|
|
18
|
+
*/
|
|
19
|
+
export const userDeleteRoute = defineJsonRoute({
|
|
20
|
+
method: "delete",
|
|
21
|
+
path: "/api/admin/v1/workspaces/:workspaceId/users/:principalId",
|
|
22
|
+
parse: (raw) => ok({ value: { principalId: principalIdParam(raw.params) } }),
|
|
23
|
+
handle: async ({ input, deps, context }) => {
|
|
24
|
+
const callerPrincipalId = userActorId({ context });
|
|
25
|
+
try {
|
|
26
|
+
const seededOwnerPrincipalId = await deps.ownerPrincipalId;
|
|
27
|
+
await deps.trashUser({ workspaceId: deps.workspaceId, callerPrincipalId, principalId: input.principalId, seededOwnerPrincipalId });
|
|
28
|
+
return ok({ value: undefined });
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
return rejectUserError({ err, rungs: userDeleteErrors({ deps }) });
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
}, { successStatus: 204 });
|
|
35
|
+
//# sourceMappingURL=delete.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { disablePrincipal } from "../../../server/admin-crud-service.js";
|
|
2
|
+
import type { AdminUserResponse } from "../../http/users.js";
|
|
3
|
+
import { type AssertUserAccountActionFn, type HostErrorPredicate, type IdentityServicesFn, type UserRoutePrincipal } from "./shared.js";
|
|
4
|
+
/** The deps this route reads. */
|
|
5
|
+
export interface UserDisableRouteDeps {
|
|
6
|
+
workspaceId: string;
|
|
7
|
+
/** Identity service(s), injected: the admin-http entry may not reach the `server` source domain
|
|
8
|
+
* (subpath isolation); the host binds them from `@jini-ai/user-management/server`. */
|
|
9
|
+
disablePrincipal: typeof disablePrincipal;
|
|
10
|
+
identityServices: IdentityServicesFn;
|
|
11
|
+
/** The seeded (bootstrap) owner's principal id, resolved by the host at boot. */
|
|
12
|
+
ownerPrincipalId: PromiseLike<string> | string;
|
|
13
|
+
assertUserAccountAction: AssertUserAccountActionFn;
|
|
14
|
+
/** Matches the host's "you cannot disable your own account" error. */
|
|
15
|
+
isSelfDeleteError: HostErrorPredicate;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* POST users/:principalId/disable — `DISABLE_PRINCIPAL` (SPEC-006 0.6.0, REQ-11, first HTTP route
|
|
19
|
+
* for a transition specified since v0.5.0). Gated by `user.manage`; refuses the seeded owner
|
|
20
|
+
* unconditionally and refuses any disable that would drop the active owner-`*` count to zero
|
|
21
|
+
* (INV-08) — see `server/admin-crud-service.ts`'s `disablePrincipal` for the full contract.
|
|
22
|
+
*
|
|
23
|
+
* `disablePrincipal` returns only the updated `PrincipalRecord` — the admin shape also needs the
|
|
24
|
+
* paired `UserRecord` (see `adminUserForPrincipal` for why that lookup is defensive).
|
|
25
|
+
*/
|
|
26
|
+
export declare const userDisableRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
|
|
27
|
+
principalId: string;
|
|
28
|
+
}, {
|
|
29
|
+
user: AdminUserResponse;
|
|
30
|
+
}, UserDisableRouteDeps, UserRoutePrincipal>;
|
|
31
|
+
//# sourceMappingURL=disable.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
|
|
2
|
+
import { adminUserForPrincipal, hostRung, principalIdParam, rejectUserError, USER_FORBIDDEN, USER_NOT_FOUND, USER_OWNER_REQUIRED, USER_VALIDATION, userActorId, } from "./shared.js";
|
|
3
|
+
/** This route's ladder, in the hand-written order; the self-target rung is the host's class. @complexity O(1). */
|
|
4
|
+
function userDisableErrors({ deps }, _optional = {}) {
|
|
5
|
+
return [hostRung({ matches: deps.isSelfDeleteError, status: 409, code: "SELF_DELETE" }), USER_FORBIDDEN, USER_OWNER_REQUIRED, USER_VALIDATION, USER_NOT_FOUND];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* POST users/:principalId/disable — `DISABLE_PRINCIPAL` (SPEC-006 0.6.0, REQ-11, first HTTP route
|
|
9
|
+
* for a transition specified since v0.5.0). Gated by `user.manage`; refuses the seeded owner
|
|
10
|
+
* unconditionally and refuses any disable that would drop the active owner-`*` count to zero
|
|
11
|
+
* (INV-08) — see `server/admin-crud-service.ts`'s `disablePrincipal` for the full contract.
|
|
12
|
+
*
|
|
13
|
+
* `disablePrincipal` returns only the updated `PrincipalRecord` — the admin shape also needs the
|
|
14
|
+
* paired `UserRecord` (see `adminUserForPrincipal` for why that lookup is defensive).
|
|
15
|
+
*/
|
|
16
|
+
export const userDisableRoute = defineJsonRoute({
|
|
17
|
+
method: "post",
|
|
18
|
+
path: "/api/admin/v1/workspaces/:workspaceId/users/:principalId/disable",
|
|
19
|
+
parse: (raw) => ok({ value: { principalId: principalIdParam(raw.params) } }),
|
|
20
|
+
handle: async ({ input, deps, context }) => {
|
|
21
|
+
const callerPrincipalId = userActorId({ context });
|
|
22
|
+
const { workspaceId } = deps;
|
|
23
|
+
const { principalId } = input;
|
|
24
|
+
try {
|
|
25
|
+
const seededOwnerPrincipalId = await deps.ownerPrincipalId;
|
|
26
|
+
const services = deps.identityServices();
|
|
27
|
+
const { principal } = await services.repos.transactions.run({ workspaceId, execute: async () => {
|
|
28
|
+
await deps.assertUserAccountAction({ deps: services, workspaceId, principalId, action: "disable" }, { callerPrincipalId, seededOwnerPrincipalId });
|
|
29
|
+
return deps.disablePrincipal({ deps: services, input: { workspaceId, callerPrincipalId, principalId, seededOwnerPrincipalId } });
|
|
30
|
+
} });
|
|
31
|
+
return ok({ value: { user: await adminUserForPrincipal({ repos: services.repos, workspaceId, principal }) } });
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
return rejectUserError({ err, rungs: userDisableErrors({ deps }) });
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=disable.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { enablePrincipal } from "../../../server/admin-crud-service.js";
|
|
2
|
+
import type { assertCallerHasAnyPermission } from "../../../server/grant-service.js";
|
|
3
|
+
import type { AdminUserResponse } from "../../http/users.js";
|
|
4
|
+
import { type AssertUserAccountActionFn, type HostErrorPredicate, type IdentityServicesFn, type IsInTrashFn, type UserRoutePrincipal } from "./shared.js";
|
|
5
|
+
/** The deps this route reads. */
|
|
6
|
+
export interface UserEnableRouteDeps {
|
|
7
|
+
workspaceId: string;
|
|
8
|
+
/** Identity service(s), injected: the admin-http entry may not reach the `server` source domain
|
|
9
|
+
* (subpath isolation); the host binds them from `@jini-ai/user-management/server`. */
|
|
10
|
+
enablePrincipal: typeof enablePrincipal;
|
|
11
|
+
assertCallerHasAnyPermission: typeof assertCallerHasAnyPermission;
|
|
12
|
+
identityServices: IdentityServicesFn;
|
|
13
|
+
isInTrash: IsInTrashFn;
|
|
14
|
+
/** The seeded (bootstrap) owner's principal id, resolved by the host at boot. */
|
|
15
|
+
ownerPrincipalId: PromiseLike<string> | string;
|
|
16
|
+
/** The host's account guard, run with action `enable` (B151): only an owner may re-enable an admin or owner. */
|
|
17
|
+
assertUserAccountAction: AssertUserAccountActionFn;
|
|
18
|
+
/** Matches the host's "user is in the Trash" error, which its Trash index may throw itself. */
|
|
19
|
+
isUserInTrashError: HostErrorPredicate;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* POST users/:principalId/enable — `ENABLE_PRINCIPAL` (SPEC-006 0.6.0, REQ-15) — the symmetric
|
|
23
|
+
* re-activation `DISABLE_PRINCIPAL` never had a counterpart for. Gated by `user.manage`; target
|
|
24
|
+
* must be `kind='user'` (EC-14). See `adminUserForPrincipal` for why the paired-user lookup is
|
|
25
|
+
* defensive, not an expected runtime path.
|
|
26
|
+
*/
|
|
27
|
+
export declare const userEnableRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
|
|
28
|
+
principalId: string;
|
|
29
|
+
}, {
|
|
30
|
+
user: AdminUserResponse;
|
|
31
|
+
}, UserEnableRouteDeps, UserRoutePrincipal>;
|
|
32
|
+
//# sourceMappingURL=enable.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
|
|
2
|
+
import { adminUserForPrincipal, principalIdParam, rejectUserError, rejectUserInTrash, USER_FORBIDDEN, USER_NOT_FOUND, USER_OWNER_REQUIRED, USER_VALIDATION, userActorId, hostRung, } from "./shared.js";
|
|
3
|
+
/** This route's ladder, in the hand-written order; the in-Trash rung is the host's class. @complexity O(1). */
|
|
4
|
+
function userEnableErrors({ deps }, _optional = {}) {
|
|
5
|
+
return [hostRung({ matches: deps.isUserInTrashError, status: 409, code: "USER_IN_TRASH" }), USER_FORBIDDEN, USER_VALIDATION, USER_NOT_FOUND, USER_OWNER_REQUIRED];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* POST users/:principalId/enable — `ENABLE_PRINCIPAL` (SPEC-006 0.6.0, REQ-15) — the symmetric
|
|
9
|
+
* re-activation `DISABLE_PRINCIPAL` never had a counterpart for. Gated by `user.manage`; target
|
|
10
|
+
* must be `kind='user'` (EC-14). See `adminUserForPrincipal` for why the paired-user lookup is
|
|
11
|
+
* defensive, not an expected runtime path.
|
|
12
|
+
*/
|
|
13
|
+
export const userEnableRoute = defineJsonRoute({
|
|
14
|
+
method: "post",
|
|
15
|
+
path: "/api/admin/v1/workspaces/:workspaceId/users/:principalId/enable",
|
|
16
|
+
parse: (raw) => ok({ value: { principalId: principalIdParam(raw.params) } }),
|
|
17
|
+
handle: async ({ input, deps, context }) => {
|
|
18
|
+
const callerPrincipalId = userActorId({ context });
|
|
19
|
+
const { workspaceId } = deps;
|
|
20
|
+
const { principalId } = input;
|
|
21
|
+
try {
|
|
22
|
+
// Trash membership is private too: use the identity owner's gate before looking it up.
|
|
23
|
+
const services = deps.identityServices();
|
|
24
|
+
await deps.assertCallerHasAnyPermission({ deps: services, workspaceId, callerPrincipalId, permissions: ["user.manage"] });
|
|
25
|
+
// OWNER DECISION 2026-09-24 (delete-user plan v2, decision 7) — refuse BEFORE the transition:
|
|
26
|
+
// re-activating a trashed principal would leave an ACTIVE user still indexed for purge. The
|
|
27
|
+
// refusal is not a rung, so `rejectUserError` rethrows it unchanged.
|
|
28
|
+
if (await deps.isInTrash({ principalId }))
|
|
29
|
+
rejectUserInTrash();
|
|
30
|
+
// B151 (owner rule 2026-11-20): only an owner may turn an admin or owner account back on —
|
|
31
|
+
// `user.manage` alone would let an admin undo the owner's disable. Same guard as disable.ts,
|
|
32
|
+
// in the same transaction as the write.
|
|
33
|
+
const seededOwnerPrincipalId = await deps.ownerPrincipalId;
|
|
34
|
+
const { principal } = await services.repos.transactions.run({ workspaceId, execute: async () => {
|
|
35
|
+
await deps.assertUserAccountAction({ deps: services, workspaceId, principalId, action: "enable" }, { callerPrincipalId, seededOwnerPrincipalId });
|
|
36
|
+
return deps.enablePrincipal({ deps: services, input: { workspaceId, callerPrincipalId, principalId } });
|
|
37
|
+
} });
|
|
38
|
+
return ok({ value: { user: await adminUserForPrincipal({ repos: services.repos, workspaceId, principal }) } });
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
return rejectUserError({ err, rungs: userEnableErrors({ deps }) });
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=enable.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PolicyRepoPort } from "../../../core/ports.js";
|
|
2
|
+
import { type AdminPolicyResponse } from "../../http/users.js";
|
|
3
|
+
import { type AccessRoutePrincipal } from "./access-shared.js";
|
|
4
|
+
/** The deps this route reads: the workspace and the policy list. */
|
|
5
|
+
export interface PolicyListRouteDeps {
|
|
6
|
+
workspaceId: string;
|
|
7
|
+
policyRepo: Pick<PolicyRepoPort, "list">;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* GET policies — list a workspace's policies (built-in + custom) for the Users admin screen's
|
|
11
|
+
* policy picker. Gated by `role.manage`, mirroring `list-roles.ts`'s identical reasoning
|
|
12
|
+
* (`createPolicy` is also gated by `role.manage`, not a separate `policy.manage`; 2026-07-16
|
|
13
|
+
* authz sweep: this route previously had zero permission check beyond session auth).
|
|
14
|
+
*/
|
|
15
|
+
export declare const policyListRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<Record<string, never>, {
|
|
16
|
+
policies: AdminPolicyResponse[];
|
|
17
|
+
}, PolicyListRouteDeps, AccessRoutePrincipal>;
|
|
18
|
+
//# sourceMappingURL=list-policies.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
|
|
2
|
+
import { toAdminPolicyResponse } from "../../http/users.js";
|
|
3
|
+
import { authorizeRoleManage } from "./access-shared.js";
|
|
4
|
+
/**
|
|
5
|
+
* GET policies — list a workspace's policies (built-in + custom) for the Users admin screen's
|
|
6
|
+
* policy picker. Gated by `role.manage`, mirroring `list-roles.ts`'s identical reasoning
|
|
7
|
+
* (`createPolicy` is also gated by `role.manage`, not a separate `policy.manage`; 2026-07-16
|
|
8
|
+
* authz sweep: this route previously had zero permission check beyond session auth).
|
|
9
|
+
*/
|
|
10
|
+
export const policyListRoute = defineJsonRoute({
|
|
11
|
+
method: "get",
|
|
12
|
+
path: "/api/admin/v1/workspaces/:workspaceId/policies",
|
|
13
|
+
parse: () => ok({ value: {} }),
|
|
14
|
+
handle: async ({ deps, authorize }) => {
|
|
15
|
+
await authorizeRoleManage({ authorize });
|
|
16
|
+
const policies = await deps.policyRepo.list({ workspaceId: deps.workspaceId });
|
|
17
|
+
return ok({ value: { policies: policies.map(toAdminPolicyResponse) } });
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=list-policies.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PolicyPermissionRepoPort, PolicyRepoPort } from "../../../core/ports.js";
|
|
2
|
+
import type { PolicyPermissionRecord } from "../../../core/types.js";
|
|
3
|
+
import { type AccessRoutePrincipal } from "./access-shared.js";
|
|
4
|
+
/** The deps this route reads: the workspace, the policy lookup and its permission rows. */
|
|
5
|
+
export interface PolicyPermissionListRouteDeps {
|
|
6
|
+
workspaceId: string;
|
|
7
|
+
policyRepo: Pick<PolicyRepoPort, "findById">;
|
|
8
|
+
policyPermissionRepo: Pick<PolicyPermissionRepoPort, "listByPolicyId">;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* GET policies/:policyId/permissions — the permission rows written onto one policy (OQ-10).
|
|
12
|
+
*
|
|
13
|
+
* Nothing exposed these before: `toAdminPolicyResponse` carries `id`/`name`/`description`/
|
|
14
|
+
* `isBuiltin`/`isFrozen` and no permissions field, so the admin could POST a permission onto a
|
|
15
|
+
* policy but never see what a policy already held. That made `remove-policy-permission.ts`
|
|
16
|
+
* unusable on its own — a removal route needs an id, and this is the only route that yields one.
|
|
17
|
+
*
|
|
18
|
+
* Gated by `role.manage`, the same permission `list-policies.ts` requires (a policy's permission
|
|
19
|
+
* set is exactly as sensitive as the policy list itself), and checked with the same inline
|
|
20
|
+
* `deps.authorize` shape that file uses rather than the service-layer helper — this is a read, so
|
|
21
|
+
* there is no identity transition to call.
|
|
22
|
+
*/
|
|
23
|
+
export declare const policyPermissionListRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
|
|
24
|
+
policyId: string;
|
|
25
|
+
}, {
|
|
26
|
+
policyPermissions: PolicyPermissionRecord[];
|
|
27
|
+
}, PolicyPermissionListRouteDeps, AccessRoutePrincipal>;
|
|
28
|
+
//# sourceMappingURL=list-policy-permissions.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
|
|
2
|
+
import { rejectRoute } from "@jini-ai/core/errors/route-refusal";
|
|
3
|
+
import { accessPathParam, authorizeRoleManage } from "./access-shared.js";
|
|
4
|
+
/**
|
|
5
|
+
* GET policies/:policyId/permissions — the permission rows written onto one policy (OQ-10).
|
|
6
|
+
*
|
|
7
|
+
* Nothing exposed these before: `toAdminPolicyResponse` carries `id`/`name`/`description`/
|
|
8
|
+
* `isBuiltin`/`isFrozen` and no permissions field, so the admin could POST a permission onto a
|
|
9
|
+
* policy but never see what a policy already held. That made `remove-policy-permission.ts`
|
|
10
|
+
* unusable on its own — a removal route needs an id, and this is the only route that yields one.
|
|
11
|
+
*
|
|
12
|
+
* Gated by `role.manage`, the same permission `list-policies.ts` requires (a policy's permission
|
|
13
|
+
* set is exactly as sensitive as the policy list itself), and checked with the same inline
|
|
14
|
+
* `deps.authorize` shape that file uses rather than the service-layer helper — this is a read, so
|
|
15
|
+
* there is no identity transition to call.
|
|
16
|
+
*/
|
|
17
|
+
export const policyPermissionListRoute = defineJsonRoute({
|
|
18
|
+
method: "get",
|
|
19
|
+
path: "/api/admin/v1/workspaces/:workspaceId/policies/:policyId/permissions",
|
|
20
|
+
parse: (raw) => ok({ value: { policyId: accessPathParam({ params: raw.params, name: "policyId" }) } }),
|
|
21
|
+
handle: async ({ input, deps, authorize }) => {
|
|
22
|
+
await authorizeRoleManage({ authorize });
|
|
23
|
+
const policy = await deps.policyRepo.findById({ workspaceId: deps.workspaceId, id: input.policyId });
|
|
24
|
+
if (!policy)
|
|
25
|
+
rejectRoute({ status: 404, error: `policy '${input.policyId}' was not found`, code: "RESOURCE_NOT_FOUND" });
|
|
26
|
+
const policyPermissions = await deps.policyPermissionRepo.listByPolicyId({ workspaceId: deps.workspaceId, policyId: input.policyId });
|
|
27
|
+
return ok({ value: { policyPermissions } });
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=list-policy-permissions.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RoleRepoPort } from "../../../core/ports.js";
|
|
2
|
+
import { type AdminRoleResponse } from "../../http/users.js";
|
|
3
|
+
import { type AccessRoutePrincipal } from "./access-shared.js";
|
|
4
|
+
/** The deps this route reads: the workspace and the role list. */
|
|
5
|
+
export interface RoleListRouteDeps {
|
|
6
|
+
workspaceId: string;
|
|
7
|
+
roleRepo: Pick<RoleRepoPort, "list">;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* GET roles — list a workspace's roles (built-in + custom) for the Users admin screen's role
|
|
11
|
+
* picker. Gated by `role.manage` — matches `createRole`/`createPolicy`'s own gate (identity's
|
|
12
|
+
* `grant-service.ts`), since no separate `role.read` permission exists in the catalog (2026-07-16
|
|
13
|
+
* authz sweep: this route previously had zero permission check beyond session auth).
|
|
14
|
+
*/
|
|
15
|
+
export declare const roleListRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<Record<string, never>, {
|
|
16
|
+
roles: AdminRoleResponse[];
|
|
17
|
+
}, RoleListRouteDeps, AccessRoutePrincipal>;
|
|
18
|
+
//# sourceMappingURL=list-roles.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
|
|
2
|
+
import { toAdminRoleResponse } from "../../http/users.js";
|
|
3
|
+
import { authorizeRoleManage } from "./access-shared.js";
|
|
4
|
+
/**
|
|
5
|
+
* GET roles — list a workspace's roles (built-in + custom) for the Users admin screen's role
|
|
6
|
+
* picker. Gated by `role.manage` — matches `createRole`/`createPolicy`'s own gate (identity's
|
|
7
|
+
* `grant-service.ts`), since no separate `role.read` permission exists in the catalog (2026-07-16
|
|
8
|
+
* authz sweep: this route previously had zero permission check beyond session auth).
|
|
9
|
+
*/
|
|
10
|
+
export const roleListRoute = defineJsonRoute({
|
|
11
|
+
method: "get",
|
|
12
|
+
path: "/api/admin/v1/workspaces/:workspaceId/roles",
|
|
13
|
+
parse: () => ok({ value: {} }),
|
|
14
|
+
handle: async ({ deps, authorize }) => {
|
|
15
|
+
await authorizeRoleManage({ authorize });
|
|
16
|
+
const roles = await deps.roleRepo.list({ workspaceId: deps.workspaceId });
|
|
17
|
+
return ok({ value: { roles: roles.map(toAdminRoleResponse) } });
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=list-roles.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { AuthorizeFn } from "@jini-ai/core/contracts/events";
|
|
2
|
+
import type { AuthServiceDeps } from "../../../server/auth-service.js";
|
|
3
|
+
import type { AdminUserResponse } from "../../http/users.js";
|
|
4
|
+
import { type IdentityServicesFn, type IsInTrashFn, type UserRoutePrincipal } from "./shared.js";
|
|
5
|
+
/** The host's per-account protection flags the users screen shows (owner / protected admin account). */
|
|
6
|
+
export interface UserAccountProtection {
|
|
7
|
+
isOwner: boolean;
|
|
8
|
+
isProtectedAccount: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** The host's account-protection read; it owns which accounts are protected. */
|
|
11
|
+
export type UserAccountProtectionFn = (required: {
|
|
12
|
+
deps: AuthServiceDeps;
|
|
13
|
+
workspaceId: string;
|
|
14
|
+
principalId: string;
|
|
15
|
+
}, optional?: Record<string, never>) => Promise<UserAccountProtection>;
|
|
16
|
+
/** The deps this route reads. */
|
|
17
|
+
export interface UserListRouteDeps {
|
|
18
|
+
workspaceId: string;
|
|
19
|
+
/** The host's raw RBAC decision (`{ allowed, reason }`), asked directly: this route's "either of
|
|
20
|
+
* two permissions" rule and its combined 403 body do not fit the single-permission authorize port. */
|
|
21
|
+
decidePermission: AuthorizeFn;
|
|
22
|
+
identityServices: IdentityServicesFn;
|
|
23
|
+
isInTrash: IsInTrashFn;
|
|
24
|
+
/** The seeded (bootstrap) owner's principal id, resolved by the host at boot. */
|
|
25
|
+
ownerPrincipalId: PromiseLike<string> | string;
|
|
26
|
+
userAccountProtection: UserAccountProtectionFn;
|
|
27
|
+
}
|
|
28
|
+
/** One listed user: the host's protection flags, the rename affordance, then the admin user fields. */
|
|
29
|
+
export type AdminUserListEntry = UserAccountProtection & {
|
|
30
|
+
canRename: boolean;
|
|
31
|
+
} & AdminUserResponse;
|
|
32
|
+
/**
|
|
33
|
+
* GET users — list a workspace's human (`kind='user'`) principals for the admin UI. No dedicated
|
|
34
|
+
* `listUsers` business-logic function exists in this package's server services (they export
|
|
35
|
+
* grant-writing mutations, not read-side wrappers) — this route calls the repo ports directly.
|
|
36
|
+
*/
|
|
37
|
+
export declare const userListRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<Record<string, never>, {
|
|
38
|
+
users: AdminUserListEntry[];
|
|
39
|
+
}, UserListRouteDeps, UserRoutePrincipal>;
|
|
40
|
+
//# sourceMappingURL=list.d.ts.map
|