@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.
- 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 +278 -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 +82 -0
- package/dist/newsletter/repo-subscribers.js +193 -0
- package/dist/newsletter/repo.d.ts +61 -0
- package/dist/newsletter/repo.js +147 -0
- package/dist/newsletter/repo.memory.d.ts +201 -0
- package/dist/newsletter/repo.memory.js +250 -0
- package/dist/newsletter/repo.rows.d.ts +221 -0
- package/dist/newsletter/repo.rows.js +260 -0
- package/dist/newsletter/send-pipeline.d.ts +236 -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 +20 -5
- package/dist/server/agent-tools.js +16 -3
- 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,26 @@
|
|
|
1
|
+
import type { revokeApiKey } from "../../../identity/api-key-service.js";
|
|
2
|
+
import { type UserRoutePrincipal } from "../users/shared.js";
|
|
3
|
+
import { type ApiKeyServicesFn } from "./shared.js";
|
|
4
|
+
/** The deps this route reads. */
|
|
5
|
+
export interface ApiKeyRevokeRouteDeps {
|
|
6
|
+
workspaceId: string;
|
|
7
|
+
apiKeyServices: ApiKeyServicesFn;
|
|
8
|
+
/** Injected service (subpath isolation); the host binds it from `@jini-ai/user-management/identity/api-key-service`. */
|
|
9
|
+
revokeApiKey: typeof revokeApiKey;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* POST api-keys/:id/revoke — `APIKEY_REVOKE` (api.spec §1, state.spec §3 `REVOKE_API_KEY`).
|
|
13
|
+
* Revocation takes effect immediately: `authenticateApiKey` reads `revokedAt` on every request, so
|
|
14
|
+
* the next request presenting the key is rejected with no cache to wait out.
|
|
15
|
+
*
|
|
16
|
+
* Idempotent by design — re-revoking an already-revoked key is a 204, not a 409, so a client that
|
|
17
|
+
* retries a timed-out revoke never has to distinguish "it worked" from "it already had".
|
|
18
|
+
*
|
|
19
|
+
* 204 with no body (api.spec §3), mirroring `users/reset-password.ts`. The `?? ""` fallback on the
|
|
20
|
+
* `:id` segment is kept: the host router always fills a matched param, but a direct handler call can omit it
|
|
21
|
+
* and must still answer the ordinary not-found.
|
|
22
|
+
*/
|
|
23
|
+
export declare const apiKeyRevokeRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
|
|
24
|
+
keyId: string;
|
|
25
|
+
}, undefined, ApiKeyRevokeRouteDeps, UserRoutePrincipal>;
|
|
26
|
+
//# sourceMappingURL=revoke.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
|
|
2
|
+
import { rejectUserError, userActorId } from "../users/shared.js";
|
|
3
|
+
import { API_KEY_ERRORS } from "./shared.js";
|
|
4
|
+
/**
|
|
5
|
+
* POST api-keys/:id/revoke — `APIKEY_REVOKE` (api.spec §1, state.spec §3 `REVOKE_API_KEY`).
|
|
6
|
+
* Revocation takes effect immediately: `authenticateApiKey` reads `revokedAt` on every request, so
|
|
7
|
+
* the next request presenting the key is rejected with no cache to wait out.
|
|
8
|
+
*
|
|
9
|
+
* Idempotent by design — re-revoking an already-revoked key is a 204, not a 409, so a client that
|
|
10
|
+
* retries a timed-out revoke never has to distinguish "it worked" from "it already had".
|
|
11
|
+
*
|
|
12
|
+
* 204 with no body (api.spec §3), mirroring `users/reset-password.ts`. The `?? ""` fallback on the
|
|
13
|
+
* `:id` segment is kept: the host router always fills a matched param, but a direct handler call can omit it
|
|
14
|
+
* and must still answer the ordinary not-found.
|
|
15
|
+
*/
|
|
16
|
+
export const apiKeyRevokeRoute = defineJsonRoute({
|
|
17
|
+
method: "post",
|
|
18
|
+
path: "/api/admin/v1/api-keys/:id/revoke",
|
|
19
|
+
parse: (raw) => ok({ value: { keyId: String(raw.params.id ?? "") } }),
|
|
20
|
+
handle: async ({ input, deps, context }) => {
|
|
21
|
+
try {
|
|
22
|
+
const callerPrincipalId = userActorId({ context });
|
|
23
|
+
await deps.revokeApiKey({ deps: deps.apiKeyServices(), input: { workspaceId: deps.workspaceId, callerPrincipalId, keyId: input.keyId } });
|
|
24
|
+
return ok({ value: undefined });
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
return rejectUserError({ err, rungs: API_KEY_ERRORS });
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
}, { successStatus: 204 });
|
|
31
|
+
//# sourceMappingURL=revoke.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ApiKeyServiceDeps } from "../../../identity/api-key-service.js";
|
|
2
|
+
import { type UserErrorRung } from "../users/shared.js";
|
|
3
|
+
/**
|
|
4
|
+
* @file Shared pieces of the three api-key admin route specs (principal create, issue, revoke).
|
|
5
|
+
*
|
|
6
|
+
* The hand-written routes shared one `sendApiKeyError` ladder because all three throw from the same
|
|
7
|
+
* service module and errors.spec.md gives them the same codes; {@link API_KEY_ERRORS} keeps that
|
|
8
|
+
* ladder, in its order, as rungs `rejectUserError` maps. Anything unmapped is rethrown to the host's
|
|
9
|
+
* redacted-500 port. The service functions and their deps bag are injected (subpath isolation: the
|
|
10
|
+
* admin-http entry does not reach the `identity` service implementation).
|
|
11
|
+
*/
|
|
12
|
+
/** Builds the api-key service deps bag per request (the host's assembler over its repo fields). */
|
|
13
|
+
export type ApiKeyServicesFn = (required?: Record<string, never>) => ApiKeyServiceDeps;
|
|
14
|
+
/**
|
|
15
|
+
* **The no-escalation guard.** All three operations in this family are `security:
|
|
16
|
+
* [{ adminSessionCookie: [] }]` in `openapi/006-identity-and-authorization.yaml`: a human admin
|
|
17
|
+
* session mints, issues, and revokes keys — an API key may not. Without this, any key holding
|
|
18
|
+
* `apikey.manage` could issue itself a successor, and revoking the original would not end the
|
|
19
|
+
* caller's access; key issuance would be a privilege-escalation primitive rather than a delegation
|
|
20
|
+
* of authority a human can withdraw.
|
|
21
|
+
*
|
|
22
|
+
* Runs BEFORE the request body is read and before any existence check, so an api_key caller learns
|
|
23
|
+
* nothing about whether a target exists.
|
|
24
|
+
*
|
|
25
|
+
* @returns `true` when the request may proceed. On `false` the 403 has already been sent.
|
|
26
|
+
* @complexity O(1).
|
|
27
|
+
* @overallScore 100
|
|
28
|
+
*/
|
|
29
|
+
export declare const API_KEY_SESSION_CREDENTIAL_GATE: {
|
|
30
|
+
readonly message: "api-key credentials may not manage api keys; use an admin session";
|
|
31
|
+
readonly permission: "apikey.manage";
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Maps this family's thrown error types onto the admin error envelope. Shared by all three routes
|
|
35
|
+
* because all three throw from the same service module and errors.spec.md gives them the same
|
|
36
|
+
* codes (mirrors `users/attach-policy.ts`'s `sendAttachPolicyError`, one level up).
|
|
37
|
+
*
|
|
38
|
+
* @complexity O(1).
|
|
39
|
+
* @overallScore 100
|
|
40
|
+
*/
|
|
41
|
+
export declare const API_KEY_ERRORS: readonly UserErrorRung[];
|
|
42
|
+
/** The request body as the hand-written routes read it (`req.body?.<field>`), never assumed an object. @complexity O(1). */
|
|
43
|
+
export declare function apiKeyBody(raw: {
|
|
44
|
+
body?: unknown;
|
|
45
|
+
}): Record<string, unknown> | undefined;
|
|
46
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { USER_FORBIDDEN, USER_GRANT_EXCEEDS_ISSUER, USER_NOT_FOUND, USER_VALIDATION } from "../users/shared.js";
|
|
2
|
+
/**
|
|
3
|
+
* **The no-escalation guard.** All three operations in this family are `security:
|
|
4
|
+
* [{ adminSessionCookie: [] }]` in `openapi/006-identity-and-authorization.yaml`: a human admin
|
|
5
|
+
* session mints, issues, and revokes keys — an API key may not. Without this, any key holding
|
|
6
|
+
* `apikey.manage` could issue itself a successor, and revoking the original would not end the
|
|
7
|
+
* caller's access; key issuance would be a privilege-escalation primitive rather than a delegation
|
|
8
|
+
* of authority a human can withdraw.
|
|
9
|
+
*
|
|
10
|
+
* Runs BEFORE the request body is read and before any existence check, so an api_key caller learns
|
|
11
|
+
* nothing about whether a target exists.
|
|
12
|
+
*
|
|
13
|
+
* @returns `true` when the request may proceed. On `false` the 403 has already been sent.
|
|
14
|
+
* @complexity O(1).
|
|
15
|
+
* @overallScore 100
|
|
16
|
+
*/
|
|
17
|
+
// Moved from the hand-written guard: the host now enforces it as its session-credential-only mount
|
|
18
|
+
// gate with this copy (the 403 message and the permission it names), so the `@returns` above describes
|
|
19
|
+
// that gate's admit/refuse outcome.
|
|
20
|
+
export const API_KEY_SESSION_CREDENTIAL_GATE = {
|
|
21
|
+
message: "api-key credentials may not manage api keys; use an admin session",
|
|
22
|
+
permission: "apikey.manage",
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Maps this family's thrown error types onto the admin error envelope. Shared by all three routes
|
|
26
|
+
* because all three throw from the same service module and errors.spec.md gives them the same
|
|
27
|
+
* codes (mirrors `users/attach-policy.ts`'s `sendAttachPolicyError`, one level up).
|
|
28
|
+
*
|
|
29
|
+
* @complexity O(1).
|
|
30
|
+
* @overallScore 100
|
|
31
|
+
*/
|
|
32
|
+
// The ladder as the rung list `rejectUserError` maps, in the hand-written order.
|
|
33
|
+
export const API_KEY_ERRORS = [USER_FORBIDDEN, USER_GRANT_EXCEEDS_ISSUER, USER_VALIDATION, USER_NOT_FOUND];
|
|
34
|
+
/** The request body as the hand-written routes read it (`req.body?.<field>`), never assumed an object. @complexity O(1). */
|
|
35
|
+
export function apiKeyBody(raw) {
|
|
36
|
+
return (raw.body ?? undefined);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { JsonRouteAuthorize } from "@jini-ai/core/contracts/server";
|
|
2
|
+
import type { AuthServiceDeps } from "../../../server/auth-service.js";
|
|
3
|
+
/**
|
|
4
|
+
* @file Shared guards and error mapping for the role/policy admin route specs (the users family's
|
|
5
|
+
* access half: roles, policies and a policy's permission rows).
|
|
6
|
+
*
|
|
7
|
+
* Every write here is authorized by the identity service itself (`role.manage`, checked inside
|
|
8
|
+
* `createRole`/`updatePolicy`/…), never by the route — so these specs ask the host's `authorize`
|
|
9
|
+
* port nothing; a refusal arrives as `IdentityForbiddenError` and maps to the same 403 body the
|
|
10
|
+
* hand-written routes wrote. Each hand-written route had its own `instanceof` ladder; each spec
|
|
11
|
+
* keeps its exact ladder (same rungs, same order) as a small mapping list, and anything unmapped is
|
|
12
|
+
* rethrown so the host answers it as its redacted 500.
|
|
13
|
+
*/
|
|
14
|
+
/** The principal fields these routes read: only the id, as the identity transition's caller. */
|
|
15
|
+
export interface AccessRoutePrincipal {
|
|
16
|
+
id: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Assembles the identity services' deps bag. Injected as a thunk because the bag is the host's
|
|
20
|
+
* (it binds the host's rename port among others) and the hand-written routes assembled it per
|
|
21
|
+
* request, inside their `try` — a failure assembling it is therefore mapped/500'd like any other.
|
|
22
|
+
*/
|
|
23
|
+
export type IdentityServiceDepsFn = () => AuthServiceDeps;
|
|
24
|
+
/** The two fields every service-backed role/policy route reads. */
|
|
25
|
+
export interface AccessServiceRouteDeps {
|
|
26
|
+
workspaceId: string;
|
|
27
|
+
identityServiceDeps: IdentityServiceDepsFn;
|
|
28
|
+
}
|
|
29
|
+
/** One `catch` rung: which thrown error it matches and the exact refusal it answers. */
|
|
30
|
+
export interface AccessErrorMapping {
|
|
31
|
+
readonly matches: (required: {
|
|
32
|
+
err: unknown;
|
|
33
|
+
}, optional?: Record<string, never>) => boolean;
|
|
34
|
+
readonly respond: (required: {
|
|
35
|
+
err: unknown;
|
|
36
|
+
}, optional?: Record<string, never>) => {
|
|
37
|
+
status: number;
|
|
38
|
+
body: Record<string, unknown>;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export declare const ACCESS_FORBIDDEN: AccessErrorMapping;
|
|
42
|
+
export declare const ACCESS_VALIDATION: AccessErrorMapping;
|
|
43
|
+
export declare const ACCESS_NOT_FOUND: AccessErrorMapping;
|
|
44
|
+
export declare const ACCESS_GRANT_EXCEEDS_ISSUER: AccessErrorMapping;
|
|
45
|
+
/** A stale editor basis: someone saved the record after this caller opened it. */
|
|
46
|
+
export declare const ACCESS_VERSION_CONFLICT: AccessErrorMapping;
|
|
47
|
+
/**
|
|
48
|
+
* The optional `expectedVersion` an identity editor PATCH carries. Absent stays absent (legacy
|
|
49
|
+
* clients keep working); present must be a non-negative integer, else `400 VALIDATION_ERROR` —
|
|
50
|
+
* a mistyped basis is never read as "no basis". @complexity O(1).
|
|
51
|
+
*/
|
|
52
|
+
export declare function accessExpectedVersion({ value }: {
|
|
53
|
+
value: unknown;
|
|
54
|
+
}, _optional?: Record<string, never>): number | undefined;
|
|
55
|
+
export declare const ACCESS_OWNER_REQUIRED: AccessErrorMapping;
|
|
56
|
+
/** A still-referenced delete target (INV-09): 409 naming the id field the client sent. @complexity O(1). */
|
|
57
|
+
export declare function accessConflictOn({ field }: {
|
|
58
|
+
field: string;
|
|
59
|
+
}, _optional?: Record<string, never>): AccessErrorMapping;
|
|
60
|
+
/** An unregistered permission: 400 echoing the permission exactly as the client sent it (raw, not
|
|
61
|
+
* coerced — an absent one drops out of the JSON, as `req.body?.permission` did). @complexity O(1). */
|
|
62
|
+
export declare function accessPermissionUnknown({ requested }: {
|
|
63
|
+
requested: unknown;
|
|
64
|
+
}, _optional?: Record<string, never>): AccessErrorMapping;
|
|
65
|
+
/**
|
|
66
|
+
* Refuses with the first matching rung; anything unmapped is rethrown unchanged so the host's error
|
|
67
|
+
* port answers it as an unexpected (redacted) failure under the route's own operation copy.
|
|
68
|
+
* @complexity O(n) in the mapping list length, a small fixed list per route.
|
|
69
|
+
*/
|
|
70
|
+
export declare function rejectAccessError({ err, mappings }: {
|
|
71
|
+
err: unknown;
|
|
72
|
+
mappings: readonly AccessErrorMapping[];
|
|
73
|
+
}, _optional?: Record<string, never>): never;
|
|
74
|
+
/**
|
|
75
|
+
* The role/policy READ routes (list-roles, list-policies, list-policy-permissions) are the
|
|
76
|
+
* exception to "the service owns the gate": they have no identity transition to call, so they ask
|
|
77
|
+
* the host's `authorize` port for `role.manage` themselves — with no `entityType` and no entity
|
|
78
|
+
* scope, exactly the params the hand-written `deps.authorize` call sent. A mount without an
|
|
79
|
+
* authorizer is a wiring bug, so it fails closed. @complexity O(1) plus the injected authorizer.
|
|
80
|
+
*/
|
|
81
|
+
export declare function authorizeRoleManage({ authorize }: {
|
|
82
|
+
authorize: JsonRouteAuthorize | undefined;
|
|
83
|
+
}, _optional?: Record<string, never>): Promise<void>;
|
|
84
|
+
/** The authenticated caller's id. A missing principal is a wiring bug (the host mounts these behind
|
|
85
|
+
* its session), so it fails closed as an unexpected failure, as `getAuthedPrincipal` did. @complexity O(1). */
|
|
86
|
+
export declare function accessActorId({ context }: {
|
|
87
|
+
context: AccessRoutePrincipal | undefined;
|
|
88
|
+
}, _optional?: Record<string, never>): string;
|
|
89
|
+
/** One path segment; Express always fills it, the `?? ""` keeps the hand-written guard (an absent id
|
|
90
|
+
* becomes an honest not-found from the service, never a wildcard). @complexity O(1). */
|
|
91
|
+
export declare function accessPathParam({ params, name }: {
|
|
92
|
+
params: Record<string, string | undefined>;
|
|
93
|
+
name: string;
|
|
94
|
+
}, _optional?: Record<string, never>): string;
|
|
95
|
+
/** The untyped JSON body as a record (`req.body ?? {}`). @complexity O(1). */
|
|
96
|
+
export declare function accessBody({ body }: {
|
|
97
|
+
body: unknown;
|
|
98
|
+
}, _optional?: Record<string, never>): Record<string, unknown>;
|
|
99
|
+
/** An optional string field: `undefined` means "absent / leave unchanged", anything else is coerced. @complexity O(1). */
|
|
100
|
+
export declare function optionalString({ value }: {
|
|
101
|
+
value: unknown;
|
|
102
|
+
}, _optional?: Record<string, never>): string | undefined;
|
|
103
|
+
//# sourceMappingURL=access-shared.d.ts.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { rejectRoute, RouteRefusalError } from "@jini-ai/core/errors/route-refusal";
|
|
2
|
+
import { parseExpectedVersion, RecordVersionConflictError, versionConflictBody } from "@jini-ai/core/optimistic-concurrency";
|
|
3
|
+
import { GrantExceedsIssuerError, IdentityConflictError, IdentityForbiddenError, IdentityNotFoundError, IdentityValidationError, OwnerRequiredError, PermissionUnknownError, } from "../../../core/types.js";
|
|
4
|
+
/** A rung for one error class; `body` builds the flat envelope (key order is the wire order). @complexity O(1). */
|
|
5
|
+
function rung({ errorClass, status, body }, _optional = {}) {
|
|
6
|
+
return { matches: ({ err }) => err instanceof errorClass, respond: ({ err }) => ({ status, body: body(err) }) };
|
|
7
|
+
}
|
|
8
|
+
export const ACCESS_FORBIDDEN = rung({ errorClass: IdentityForbiddenError, status: 403, body: (err) => ({
|
|
9
|
+
error: err.message, code: "FORBIDDEN", details: { permission: err.permission, reason: err.reason },
|
|
10
|
+
}) });
|
|
11
|
+
export const ACCESS_VALIDATION = rung({ errorClass: IdentityValidationError, status: 400, body: (err) => ({ error: err.message, code: "VALIDATION_ERROR" }) });
|
|
12
|
+
export const ACCESS_NOT_FOUND = rung({ errorClass: IdentityNotFoundError, status: 404, body: (err) => ({ error: err.message, code: "RESOURCE_NOT_FOUND" }) });
|
|
13
|
+
export const ACCESS_GRANT_EXCEEDS_ISSUER = rung({ errorClass: GrantExceedsIssuerError, status: 403, body: (err) => ({
|
|
14
|
+
error: err.message, code: "GRANT_EXCEEDS_ISSUER", details: { offendingPermissions: err.offendingPermissions },
|
|
15
|
+
}) });
|
|
16
|
+
/** A stale editor basis: someone saved the record after this caller opened it. */
|
|
17
|
+
export const ACCESS_VERSION_CONFLICT = rung({ errorClass: RecordVersionConflictError, status: 409, body: (err) => ({ ...versionConflictBody({ error: err }) }) });
|
|
18
|
+
/**
|
|
19
|
+
* The optional `expectedVersion` an identity editor PATCH carries. Absent stays absent (legacy
|
|
20
|
+
* clients keep working); present must be a non-negative integer, else `400 VALIDATION_ERROR` —
|
|
21
|
+
* a mistyped basis is never read as "no basis". @complexity O(1).
|
|
22
|
+
*/
|
|
23
|
+
export function accessExpectedVersion({ value }, _optional = {}) {
|
|
24
|
+
try {
|
|
25
|
+
return parseExpectedVersion({ value });
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
// parseExpectedVersion throws only for a malformed basis; its message names the field.
|
|
29
|
+
return rejectRoute({ status: 400, error: err.message, code: "VALIDATION_ERROR" });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export const ACCESS_OWNER_REQUIRED = rung({ errorClass: OwnerRequiredError, status: 409, body: (err) => ({ error: err.message, code: "OWNER_REQUIRED" }) });
|
|
33
|
+
/** A still-referenced delete target (INV-09): 409 naming the id field the client sent. @complexity O(1). */
|
|
34
|
+
export function accessConflictOn({ field }, _optional = {}) {
|
|
35
|
+
return rung({ errorClass: IdentityConflictError, status: 409, body: (err) => ({ error: err.message, code: "RESOURCE_CONFLICT", details: { field } }) });
|
|
36
|
+
}
|
|
37
|
+
/** An unregistered permission: 400 echoing the permission exactly as the client sent it (raw, not
|
|
38
|
+
* coerced — an absent one drops out of the JSON, as `req.body?.permission` did). @complexity O(1). */
|
|
39
|
+
export function accessPermissionUnknown({ requested }, _optional = {}) {
|
|
40
|
+
return rung({ errorClass: PermissionUnknownError, status: 400, body: (err) => ({ error: err.message, code: "PERMISSION_UNKNOWN", details: { permission: requested } }) });
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Refuses with the first matching rung; anything unmapped is rethrown unchanged so the host's error
|
|
44
|
+
* port answers it as an unexpected (redacted) failure under the route's own operation copy.
|
|
45
|
+
* @complexity O(n) in the mapping list length, a small fixed list per route.
|
|
46
|
+
*/
|
|
47
|
+
export function rejectAccessError({ err, mappings }, _optional = {}) {
|
|
48
|
+
const mapping = mappings.find((candidate) => candidate.matches({ err }));
|
|
49
|
+
if (!mapping)
|
|
50
|
+
throw err;
|
|
51
|
+
throw new RouteRefusalError(mapping.respond({ err }));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The role/policy READ routes (list-roles, list-policies, list-policy-permissions) are the
|
|
55
|
+
* exception to "the service owns the gate": they have no identity transition to call, so they ask
|
|
56
|
+
* the host's `authorize` port for `role.manage` themselves — with no `entityType` and no entity
|
|
57
|
+
* scope, exactly the params the hand-written `deps.authorize` call sent. A mount without an
|
|
58
|
+
* authorizer is a wiring bug, so it fails closed. @complexity O(1) plus the injected authorizer.
|
|
59
|
+
*/
|
|
60
|
+
export async function authorizeRoleManage({ authorize }, _optional = {}) {
|
|
61
|
+
if (!authorize)
|
|
62
|
+
throw new Error("users admin route has no authorizer");
|
|
63
|
+
await authorize({ permission: "role.manage" });
|
|
64
|
+
}
|
|
65
|
+
/** The authenticated caller's id. A missing principal is a wiring bug (the host mounts these behind
|
|
66
|
+
* its session), so it fails closed as an unexpected failure, as `getAuthedPrincipal` did. @complexity O(1). */
|
|
67
|
+
export function accessActorId({ context }, _optional = {}) {
|
|
68
|
+
if (!context)
|
|
69
|
+
throw new Error("users admin route has no authenticated principal");
|
|
70
|
+
return context.id;
|
|
71
|
+
}
|
|
72
|
+
/** One path segment; Express always fills it, the `?? ""` keeps the hand-written guard (an absent id
|
|
73
|
+
* becomes an honest not-found from the service, never a wildcard). @complexity O(1). */
|
|
74
|
+
export function accessPathParam({ params, name }, _optional = {}) {
|
|
75
|
+
return String(params[name] ?? "");
|
|
76
|
+
}
|
|
77
|
+
/** The untyped JSON body as a record (`req.body ?? {}`). @complexity O(1). */
|
|
78
|
+
export function accessBody({ body }, _optional = {}) {
|
|
79
|
+
return (body ?? {});
|
|
80
|
+
}
|
|
81
|
+
/** An optional string field: `undefined` means "absent / leave unchanged", anything else is coerced. @complexity O(1). */
|
|
82
|
+
export function optionalString({ value }, _optional = {}) {
|
|
83
|
+
return value !== undefined ? String(value) : undefined;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=access-shared.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { PrincipalRoleRecord } from "../../../core/types.js";
|
|
2
|
+
import type { assignRole } from "../../../server/grant-service.js";
|
|
3
|
+
import { type IdentityServicesFn, type UserRoutePrincipal } from "./shared.js";
|
|
4
|
+
/** The deps this route reads. */
|
|
5
|
+
export interface UserAssignRoleRouteDeps {
|
|
6
|
+
workspaceId: string;
|
|
7
|
+
/** Identity service(s), injected: the admin-http entry may not reach the `server` source domain
|
|
8
|
+
* (subpath isolation); the host binds them from `@jini-ai/user-management/server`. */
|
|
9
|
+
assignRole: typeof assignRole;
|
|
10
|
+
identityServices: IdentityServicesFn;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* POST users/:principalId/roles — `ASSIGN_ROLE` (state.spec §3, AC-24/AC-25).
|
|
14
|
+
* Gated by `role.manage`; target must be a `kind='user'` principal; the
|
|
15
|
+
* INV-07 grant clamp must pass over every permission carried by the role's
|
|
16
|
+
* policies. See `grant-service.ts`'s `assignRole` for the full contract.
|
|
17
|
+
*/
|
|
18
|
+
export declare const userAssignRoleRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
|
|
19
|
+
principalId: string;
|
|
20
|
+
roleId: string;
|
|
21
|
+
}, {
|
|
22
|
+
assignment: PrincipalRoleRecord;
|
|
23
|
+
}, UserAssignRoleRouteDeps, UserRoutePrincipal>;
|
|
24
|
+
//# sourceMappingURL=assign-role.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
|
|
2
|
+
import { principalIdParam, rejectUserError, USER_FORBIDDEN, USER_GRANT_EXCEEDS_ISSUER, USER_NOT_FOUND_CODELESS, USER_OWNER_REQUIRED, USER_VALIDATION, userActorId, } from "./shared.js";
|
|
3
|
+
/** Unmapped failures go to the host; a missing target/grant was always the code-less 404. */
|
|
4
|
+
const USER_ASSIGN_ROLE_ERRORS = [USER_FORBIDDEN, USER_GRANT_EXCEEDS_ISSUER, USER_VALIDATION, USER_NOT_FOUND_CODELESS, USER_OWNER_REQUIRED];
|
|
5
|
+
/**
|
|
6
|
+
* POST users/:principalId/roles — `ASSIGN_ROLE` (state.spec §3, AC-24/AC-25).
|
|
7
|
+
* Gated by `role.manage`; target must be a `kind='user'` principal; the
|
|
8
|
+
* INV-07 grant clamp must pass over every permission carried by the role's
|
|
9
|
+
* policies. See `grant-service.ts`'s `assignRole` for the full contract.
|
|
10
|
+
*/
|
|
11
|
+
export const userAssignRoleRoute = defineJsonRoute({
|
|
12
|
+
method: "post",
|
|
13
|
+
path: "/api/admin/v1/workspaces/:workspaceId/users/:principalId/roles",
|
|
14
|
+
// `?.` as the host read it: a null, absent or non-object body leaves the id empty for the service to refuse.
|
|
15
|
+
parse: (raw) => ok({ value: { principalId: principalIdParam(raw.params), roleId: String(raw.body?.roleId ?? "") } }),
|
|
16
|
+
handle: async ({ input, deps, context }) => {
|
|
17
|
+
const callerPrincipalId = userActorId({ context });
|
|
18
|
+
try {
|
|
19
|
+
const { assignment } = await deps.assignRole({
|
|
20
|
+
deps: deps.identityServices(),
|
|
21
|
+
input: { workspaceId: deps.workspaceId, callerPrincipalId, principalId: input.principalId, roleId: input.roleId },
|
|
22
|
+
});
|
|
23
|
+
return ok({ value: { assignment } });
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
return rejectUserError({ err, rungs: USER_ASSIGN_ROLE_ERRORS });
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
}, { successStatus: 201 });
|
|
30
|
+
//# sourceMappingURL=assign-role.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { PrincipalPolicyRecord } from "../../../core/types.js";
|
|
2
|
+
import type { attachPolicy } from "../../../server/grant-service.js";
|
|
3
|
+
import { type IdentityServicesFn, type UserRoutePrincipal } from "./shared.js";
|
|
4
|
+
/** The deps this route reads. */
|
|
5
|
+
export interface UserAttachPolicyRouteDeps {
|
|
6
|
+
workspaceId: string;
|
|
7
|
+
/** Identity service(s), injected: the admin-http entry may not reach the `server` source domain
|
|
8
|
+
* (subpath isolation); the host binds them from `@jini-ai/user-management/server`. */
|
|
9
|
+
attachPolicy: typeof attachPolicy;
|
|
10
|
+
identityServices: IdentityServicesFn;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* POST users/:principalId/policies — `ATTACH_POLICY` (state.spec §3,
|
|
14
|
+
* AC-24/AC-25). Gated by `role.manage`; target must be a `kind='user'`
|
|
15
|
+
* principal; the INV-07 grant clamp must pass over every permission the
|
|
16
|
+
* policy carries. See `grant-service.ts`'s `attachPolicy` for the full
|
|
17
|
+
* contract.
|
|
18
|
+
*/
|
|
19
|
+
export declare const userAttachPolicyRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
|
|
20
|
+
principalId: string;
|
|
21
|
+
policyId: string;
|
|
22
|
+
}, {
|
|
23
|
+
attachment: PrincipalPolicyRecord;
|
|
24
|
+
}, UserAttachPolicyRouteDeps, UserRoutePrincipal>;
|
|
25
|
+
//# sourceMappingURL=attach-policy.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
|
|
2
|
+
import { principalIdParam, rejectUserError, USER_FORBIDDEN, USER_GRANT_EXCEEDS_ISSUER, USER_NOT_FOUND_CODELESS, USER_OWNER_REQUIRED, USER_VALIDATION, userActorId, } from "./shared.js";
|
|
3
|
+
/** Unmapped failures go to the host; a missing target/grant was always the code-less 404. */
|
|
4
|
+
const USER_ATTACH_POLICY_ERRORS = [USER_FORBIDDEN, USER_GRANT_EXCEEDS_ISSUER, USER_VALIDATION, USER_NOT_FOUND_CODELESS, USER_OWNER_REQUIRED];
|
|
5
|
+
/**
|
|
6
|
+
* POST users/:principalId/policies — `ATTACH_POLICY` (state.spec §3,
|
|
7
|
+
* AC-24/AC-25). Gated by `role.manage`; target must be a `kind='user'`
|
|
8
|
+
* principal; the INV-07 grant clamp must pass over every permission the
|
|
9
|
+
* policy carries. See `grant-service.ts`'s `attachPolicy` for the full
|
|
10
|
+
* contract.
|
|
11
|
+
*/
|
|
12
|
+
export const userAttachPolicyRoute = defineJsonRoute({
|
|
13
|
+
method: "post",
|
|
14
|
+
path: "/api/admin/v1/workspaces/:workspaceId/users/:principalId/policies",
|
|
15
|
+
// `?.` as the host read it: a null, absent or non-object body leaves the id empty for the service to refuse.
|
|
16
|
+
parse: (raw) => ok({ value: { principalId: principalIdParam(raw.params), policyId: String(raw.body?.policyId ?? "") } }),
|
|
17
|
+
handle: async ({ input, deps, context }) => {
|
|
18
|
+
const callerPrincipalId = userActorId({ context });
|
|
19
|
+
try {
|
|
20
|
+
const { attachment } = await deps.attachPolicy({
|
|
21
|
+
deps: deps.identityServices(),
|
|
22
|
+
input: { workspaceId: deps.workspaceId, callerPrincipalId, principalId: input.principalId, policyId: input.policyId },
|
|
23
|
+
});
|
|
24
|
+
return ok({ value: { attachment } });
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
return rejectUserError({ err, rungs: USER_ATTACH_POLICY_ERRORS });
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
}, { successStatus: 201 });
|
|
31
|
+
//# sourceMappingURL=attach-policy.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { createPolicy } from "../../../server/grant-service.js";
|
|
2
|
+
import { type AdminPolicyResponse } from "../../http/users.js";
|
|
3
|
+
import { type AccessRoutePrincipal, type AccessServiceRouteDeps } from "./access-shared.js";
|
|
4
|
+
/** The deps this route reads: the workspace, the identity services' deps bag and the service it calls. */
|
|
5
|
+
export interface PolicyCreateRouteDeps extends AccessServiceRouteDeps {
|
|
6
|
+
/** Injected: the service lives in the node `./server` entry; the host binds it. */
|
|
7
|
+
createPolicy: typeof createPolicy;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* POST policies — `CREATE_POLICY` (state.spec §3). Gated by `role.manage`;
|
|
11
|
+
* always mints `isBuiltin=false` and `isFrozen=false`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const policyCreateRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
|
|
14
|
+
name: string;
|
|
15
|
+
description: string | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
policy: AdminPolicyResponse;
|
|
18
|
+
}, PolicyCreateRouteDeps, AccessRoutePrincipal>;
|
|
19
|
+
//# sourceMappingURL=create-policy.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
|
|
2
|
+
import { toAdminPolicyResponse } from "../../http/users.js";
|
|
3
|
+
import { ACCESS_FORBIDDEN, ACCESS_VALIDATION, accessActorId, accessBody, optionalString, rejectAccessError, } from "./access-shared.js";
|
|
4
|
+
const POLICY_CREATE_ERRORS = [ACCESS_FORBIDDEN, ACCESS_VALIDATION];
|
|
5
|
+
/**
|
|
6
|
+
* POST policies — `CREATE_POLICY` (state.spec §3). Gated by `role.manage`;
|
|
7
|
+
* always mints `isBuiltin=false` and `isFrozen=false`.
|
|
8
|
+
*/
|
|
9
|
+
export const policyCreateRoute = defineJsonRoute({
|
|
10
|
+
method: "post",
|
|
11
|
+
path: "/api/admin/v1/workspaces/:workspaceId/policies",
|
|
12
|
+
// This route's `name`/`description` POST fields, read off an untyped body in one place.
|
|
13
|
+
parse: (raw) => {
|
|
14
|
+
const body = accessBody({ body: raw.body });
|
|
15
|
+
return ok({ value: { name: String(body.name ?? ""), description: optionalString({ value: body.description }) } });
|
|
16
|
+
},
|
|
17
|
+
handle: async ({ input, deps, context }) => {
|
|
18
|
+
const callerPrincipalId = accessActorId({ context });
|
|
19
|
+
try {
|
|
20
|
+
const { policy } = await deps.createPolicy({ deps: deps.identityServiceDeps(), input: { workspaceId: deps.workspaceId, callerPrincipalId, name: input.name } }, { description: input.description });
|
|
21
|
+
return ok({ value: { policy: toAdminPolicyResponse(policy) } });
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
return rejectAccessError({ err, mappings: POLICY_CREATE_ERRORS });
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
}, { successStatus: 201 });
|
|
28
|
+
//# sourceMappingURL=create-policy.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { createRole } from "../../../server/grant-service.js";
|
|
2
|
+
import { type AdminRoleResponse } from "../../http/users.js";
|
|
3
|
+
import { type AccessRoutePrincipal, type AccessServiceRouteDeps } from "./access-shared.js";
|
|
4
|
+
/** The deps this route reads: the workspace, the identity services' deps bag and the service it calls. */
|
|
5
|
+
export interface RoleCreateRouteDeps extends AccessServiceRouteDeps {
|
|
6
|
+
/** Injected: the service lives in the node `./server` entry; the host binds it. */
|
|
7
|
+
createRole: typeof createRole;
|
|
8
|
+
}
|
|
9
|
+
/** POST roles — `CREATE_ROLE` (state.spec §3). Gated by `role.manage`; always mints `isBuiltin=false`. */
|
|
10
|
+
export declare const roleCreateRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<{
|
|
11
|
+
name: string;
|
|
12
|
+
}, {
|
|
13
|
+
role: AdminRoleResponse;
|
|
14
|
+
}, RoleCreateRouteDeps, AccessRoutePrincipal>;
|
|
15
|
+
//# sourceMappingURL=create-role.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineJsonRoute, ok } from "@jini-ai/core/contracts/server";
|
|
2
|
+
import { toAdminRoleResponse } from "../../http/users.js";
|
|
3
|
+
import { ACCESS_FORBIDDEN, ACCESS_VALIDATION, accessActorId, accessBody, rejectAccessError, } from "./access-shared.js";
|
|
4
|
+
const ROLE_CREATE_ERRORS = [ACCESS_FORBIDDEN, ACCESS_VALIDATION];
|
|
5
|
+
/** POST roles — `CREATE_ROLE` (state.spec §3). Gated by `role.manage`; always mints `isBuiltin=false`. */
|
|
6
|
+
export const roleCreateRoute = defineJsonRoute({
|
|
7
|
+
method: "post",
|
|
8
|
+
path: "/api/admin/v1/workspaces/:workspaceId/roles",
|
|
9
|
+
parse: (raw) => ok({ value: { name: String(accessBody({ body: raw.body }).name ?? "") } }),
|
|
10
|
+
handle: async ({ input, deps, context }) => {
|
|
11
|
+
const callerPrincipalId = accessActorId({ context });
|
|
12
|
+
try {
|
|
13
|
+
const { role } = await deps.createRole({ deps: deps.identityServiceDeps(), input: { workspaceId: deps.workspaceId, callerPrincipalId, name: input.name } });
|
|
14
|
+
return ok({ value: { role: toAdminRoleResponse(role) } });
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
return rejectAccessError({ err, mappings: ROLE_CREATE_ERRORS });
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
}, { successStatus: 201 });
|
|
21
|
+
//# sourceMappingURL=create-role.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { createUser } from "../../../server/grant-service.js";
|
|
2
|
+
import type { normalizeUsername } from "../../../server/username.js";
|
|
3
|
+
import { type AdminUserResponse } from "../../http/users.js";
|
|
4
|
+
import { type IdentityServicesFn, type IsInTrashFn, type UserRoutePrincipal } from "./shared.js";
|
|
5
|
+
/** The deps this route reads. */
|
|
6
|
+
export interface UserCreateRouteDeps {
|
|
7
|
+
workspaceId: string;
|
|
8
|
+
/** Identity service(s), injected: the admin-http entry may not reach the `server` source domain
|
|
9
|
+
* (subpath isolation); the host binds them from `@jini-ai/user-management/server`. */
|
|
10
|
+
createUser: typeof createUser;
|
|
11
|
+
normalizeUsername: typeof normalizeUsername;
|
|
12
|
+
identityServices: IdentityServicesFn;
|
|
13
|
+
isInTrash: IsInTrashFn;
|
|
14
|
+
}
|
|
15
|
+
/** This route's three body fields, read off an untyped body in one place. */
|
|
16
|
+
export interface UserCreateInput {
|
|
17
|
+
username: string;
|
|
18
|
+
email: string | undefined;
|
|
19
|
+
password: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* POST users — `CREATE_USER` (state.spec §3, REQ-01/MF-1). Gated by `user.manage` only (operator
|
|
23
|
+
* login creation), enforced inside `grant-service.ts`'s `createUser` rather than here — see that
|
|
24
|
+
* file's header for why the gate lives in the service function.
|
|
25
|
+
*
|
|
26
|
+
* Not routed through the SPEC-001 command gateway: `CREATE_USER` mints two rows (principal + user)
|
|
27
|
+
* as one structural unit, not a single entity with a natural inverse-capture/revert story.
|
|
28
|
+
*/
|
|
29
|
+
export declare const userCreateRoute: import("@jini-ai/core/contracts/server").JsonRouteSpec<UserCreateInput, {
|
|
30
|
+
user: AdminUserResponse;
|
|
31
|
+
}, UserCreateRouteDeps, UserRoutePrincipal>;
|
|
32
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -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
|