@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,64 @@
|
|
|
1
|
+
import { ToolInputError } from '@jini-ai/core';
|
|
2
|
+
/** Credential services need an active handle for human saves, never owner key derivation.
|
|
3
|
+
* @returns A handle-only keyring; every derivation fails without reaching the owner keyring.
|
|
4
|
+
* @complexity O(1), no database I/O.
|
|
5
|
+
*/
|
|
6
|
+
export function ownerKeyHandleOnly({ keyring, derivationRefusedMessage }, _optional = {}) {
|
|
7
|
+
const refuse = async () => { throw new ToolInputError({ message: derivationRefusedMessage }); };
|
|
8
|
+
return { activeKey: (options) => keyring.activeKey(options), derive: refuse, deriveSigningSecret: refuse };
|
|
9
|
+
}
|
|
10
|
+
/** Extract only the selected identity from Jini's frozen vault AAD; the full AAD is compared below. */
|
|
11
|
+
function selectedIdentity({ aad, ownerScope, accessRefusedMessage }) {
|
|
12
|
+
const prefix = 'secrets-vault:v1:';
|
|
13
|
+
if (!aad?.startsWith(prefix))
|
|
14
|
+
throw refused(accessRefusedMessage);
|
|
15
|
+
let value;
|
|
16
|
+
try {
|
|
17
|
+
value = JSON.parse(aad.slice(prefix.length));
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
throw refused(accessRefusedMessage);
|
|
21
|
+
}
|
|
22
|
+
if (!isOwnerKeyIdentity(value, ownerScope))
|
|
23
|
+
throw refused(accessRefusedMessage);
|
|
24
|
+
return { workspaceId: value[0], id: value[1] };
|
|
25
|
+
}
|
|
26
|
+
/** Only API-key AAD under the fixed owner scope can reach the owner's crypto service. */
|
|
27
|
+
function isOwnerKeyIdentity(value, ownerScope) {
|
|
28
|
+
if (!Array.isArray(value) || value.length !== 6)
|
|
29
|
+
return false;
|
|
30
|
+
const [workspaceId, id] = value;
|
|
31
|
+
if (workspaceId !== ownerScope.workspaceId || typeof id !== 'string')
|
|
32
|
+
return false;
|
|
33
|
+
return ownerKeyScope({ value, ownerScope });
|
|
34
|
+
}
|
|
35
|
+
function ownerKeyScope({ value, ownerScope }, _optional = {}) {
|
|
36
|
+
const [, , kind, ownerKey, principalId, binding] = value;
|
|
37
|
+
return typeof kind === 'string' && ownerScope.kinds.includes(kind)
|
|
38
|
+
&& ownerKey === ownerScope.ownerKey && principalId === null && binding === null;
|
|
39
|
+
}
|
|
40
|
+
function refused(accessRefusedMessage) {
|
|
41
|
+
return new ToolInputError({ message: accessRefusedMessage });
|
|
42
|
+
}
|
|
43
|
+
/** Keep crypto inside the owner boundary and recheck the site grant before and after each open.
|
|
44
|
+
* A caller retaining an envelope cannot decrypt it after revoke. Jini authenticates the full AAD;
|
|
45
|
+
* no envelope inventory or additional owner-row hydration is needed for this authorization check.
|
|
46
|
+
* @returns A site-fenced sealer; human saves still seal through the trusted owner service.
|
|
47
|
+
* @complexity O(1) indexed grant/reference reads plus O(ciphertext bytes) crypto.
|
|
48
|
+
*/
|
|
49
|
+
export function siteGrantedSealer({ allowed, sealer, ownerScope, accessRefusedMessage }, _optional = {}) {
|
|
50
|
+
return {
|
|
51
|
+
seal: ({ plaintext, key, aad }) => sealer.seal({ plaintext, key, aad }),
|
|
52
|
+
open: async (input, options = {}) => {
|
|
53
|
+
const identity = selectedIdentity({ aad: options.aad, ownerScope, accessRefusedMessage });
|
|
54
|
+
const access = { credentialId: identity.id };
|
|
55
|
+
if (!await allowed(access))
|
|
56
|
+
throw refused(accessRefusedMessage);
|
|
57
|
+
const plaintext = await sealer.open(input, options);
|
|
58
|
+
if (!await allowed(access))
|
|
59
|
+
throw refused(accessRefusedMessage);
|
|
60
|
+
return plaintext;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=site-sealer.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type RawBuilder } from "kysely";
|
|
2
|
+
import type { KeyAttachments } from "@jini-ai/core/contracts/site/project-key-attachments";
|
|
3
|
+
type Empty = Record<string, never>;
|
|
4
|
+
export interface AttachmentSqlPort {
|
|
5
|
+
readonly dialect: string;
|
|
6
|
+
query<Row>(statement: RawBuilder<unknown>, optional?: Empty): Promise<readonly Row[]>;
|
|
7
|
+
execute(statement: RawBuilder<unknown>, optional?: Empty): Promise<unknown>;
|
|
8
|
+
}
|
|
9
|
+
export interface AttachmentPolicy {
|
|
10
|
+
ownerWorkspaceId: string;
|
|
11
|
+
customKind: string;
|
|
12
|
+
vendorKind: string;
|
|
13
|
+
vendorCredentialType: string;
|
|
14
|
+
maxGrants: number;
|
|
15
|
+
tooManyKeys: string;
|
|
16
|
+
ambiguousLabel: string;
|
|
17
|
+
noSiteId: string;
|
|
18
|
+
}
|
|
19
|
+
/** One indexed lookup per check; no cache so attach/detach changes the next credential read. */
|
|
20
|
+
export declare function createKeyAttachments({ sql: kernel, tables, nowIso, policy, credentialTypeText }: {
|
|
21
|
+
sql: AttachmentSqlPort;
|
|
22
|
+
tables: {
|
|
23
|
+
attachments: string;
|
|
24
|
+
vault: string;
|
|
25
|
+
};
|
|
26
|
+
nowIso: () => string;
|
|
27
|
+
policy: AttachmentPolicy;
|
|
28
|
+
credentialTypeText: (required: {
|
|
29
|
+
column: RawBuilder<unknown>;
|
|
30
|
+
}, optional?: Empty) => RawBuilder<string | null>;
|
|
31
|
+
}, _optional?: Empty): KeyAttachments;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=attachments.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { sql } from "kysely";
|
|
2
|
+
/** A vault row's `meta.worksFor` labels; SQLite hands `meta` back as JSON text, Postgres as an object. */
|
|
3
|
+
function worksForOf(meta) {
|
|
4
|
+
const parsed = typeof meta === "string" ? JSON.parse(meta) : meta;
|
|
5
|
+
return Array.isArray(parsed.worksFor) ? parsed.worksFor : [];
|
|
6
|
+
}
|
|
7
|
+
/** One indexed lookup per check; no cache so attach/detach changes the next credential read. */
|
|
8
|
+
export function createKeyAttachments({ sql: kernel, tables, nowIso, policy, credentialTypeText }, _optional = {}) {
|
|
9
|
+
for (const name of [tables.attachments, tables.vault]) {
|
|
10
|
+
if (!/^[A-Za-z_]\w*$/.test(name))
|
|
11
|
+
throw new Error("Invalid attachment table identifier.");
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
async keyForLabel({ siteId, label }) {
|
|
15
|
+
if (!siteId)
|
|
16
|
+
return null;
|
|
17
|
+
// The `worksFor` array lives in JSON the dialect helpers cannot search, so match it here: the rows are
|
|
18
|
+
// this one site's attachments, which `keysFor` also caps at 100.
|
|
19
|
+
const credentialType = credentialTypeText({ column: sql.ref("v.meta") });
|
|
20
|
+
const candidates = await kernel.query(sql `SELECT a.key_id, v.label, v.meta FROM ${sql.table(tables.vault)} v JOIN ${sql.table(tables.attachments)} a ON a.key_id=v.id AND a.site_id=${siteId} WHERE v.workspace_id=${policy.ownerWorkspaceId} AND (v.kind=${policy.customKind} OR (v.kind=${policy.vendorKind} AND ${credentialType}=${policy.vendorCredentialType})) ORDER BY a.key_id LIMIT ${policy.maxGrants + 1}`);
|
|
21
|
+
if (candidates.length > policy.maxGrants)
|
|
22
|
+
throw new Error(policy.tooManyKeys);
|
|
23
|
+
const rows = candidates.filter(row => row.label === label || worksForOf(row.meta).includes(label));
|
|
24
|
+
if (rows.length > 1)
|
|
25
|
+
throw new Error(policy.ambiguousLabel);
|
|
26
|
+
return rows[0]?.key_id ?? null;
|
|
27
|
+
},
|
|
28
|
+
async keysFor({ siteId }) {
|
|
29
|
+
if (!siteId)
|
|
30
|
+
return [];
|
|
31
|
+
const rows = await kernel.query(sql `SELECT key_id FROM ${sql.table(tables.attachments)} WHERE site_id=${siteId} ORDER BY key_id LIMIT ${policy.maxGrants + 1}`);
|
|
32
|
+
if (rows.length > policy.maxGrants)
|
|
33
|
+
throw new Error(policy.tooManyKeys);
|
|
34
|
+
return rows.map(row => row.key_id);
|
|
35
|
+
},
|
|
36
|
+
async attach({ siteId, keyId, siteName }) {
|
|
37
|
+
if (!siteId)
|
|
38
|
+
throw new Error(policy.noSiteId);
|
|
39
|
+
await kernel.execute(sql `INSERT INTO ${sql.table(tables.attachments)} (site_id, key_id, site_name, attached_at) VALUES (${siteId}, ${keyId}, ${siteName}, ${nowIso()}) ON CONFLICT (site_id, key_id) DO NOTHING`);
|
|
40
|
+
},
|
|
41
|
+
detach: async ({ siteId, keyId }) => { await kernel.execute(sql `DELETE FROM ${sql.table(tables.attachments)} WHERE site_id=${siteId} AND key_id=${keyId}`); },
|
|
42
|
+
async isAttached({ siteId, keyId }) {
|
|
43
|
+
if (!siteId)
|
|
44
|
+
return false;
|
|
45
|
+
return (await kernel.query(sql `SELECT 1 FROM ${sql.table(tables.attachments)} WHERE site_id=${siteId} AND key_id=${keyId}`)).length > 0;
|
|
46
|
+
},
|
|
47
|
+
async usersOf({ keyId }) {
|
|
48
|
+
const rows = await kernel.query(sql `SELECT site_id, site_name FROM ${sql.table(tables.attachments)} WHERE key_id=${keyId} ORDER BY site_name, site_id`);
|
|
49
|
+
return rows.map(row => ({ siteId: row.site_id, siteName: row.site_name }));
|
|
50
|
+
},
|
|
51
|
+
removeKey: async ({ keyId }) => { await kernel.execute(sql `DELETE FROM ${sql.table(tables.attachments)} WHERE key_id=${keyId}`); },
|
|
52
|
+
renameSite: async ({ siteId, siteName }) => { await kernel.execute(sql `UPDATE ${sql.table(tables.attachments)} SET site_name=${siteName} WHERE site_id=${siteId}`); },
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=attachments.js.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type AgentToolDefinition, type ToolExecutionContext, type ToolHandler, type ToolExecutionOptions, type ToolMetadataById, type ToolRegistration, type AgentToolSideEffect } from "@jini-ai/core";
|
|
2
|
+
import type { AssistantSurfaceDeps } from "@jini-ai/core/contracts/site/daemon-surface-exchanges";
|
|
3
|
+
import type { DevRestartPort } from "@jini-ai/core/contracts/site/dev-supervisor-dev-restart";
|
|
4
|
+
import type { PluginCredentialCard } from "@jini-ai/core/contracts/credentials";
|
|
5
|
+
import type { SurfaceDetail } from "@jini-ai/core/contracts/cards";
|
|
6
|
+
import type { ProjectKeysPort } from "./service.js";
|
|
7
|
+
export declare function createProjectKeysCatalog({ readPermission, restartPermission, descriptions }: {
|
|
8
|
+
readPermission: string;
|
|
9
|
+
restartPermission: string;
|
|
10
|
+
descriptions: {
|
|
11
|
+
list: string;
|
|
12
|
+
use: string;
|
|
13
|
+
restart: string;
|
|
14
|
+
};
|
|
15
|
+
}, _optional?: Record<string, never>): AgentToolDefinition[];
|
|
16
|
+
export declare const projectKeysRisk: ReadonlyMap<string, AgentToolSideEffect>;
|
|
17
|
+
type ProjectKeyRegistrationInput = {
|
|
18
|
+
keys?: ProjectKeysPort;
|
|
19
|
+
authorize: (input: {
|
|
20
|
+
ctx: ToolExecutionContext;
|
|
21
|
+
permission: string;
|
|
22
|
+
}) => Promise<void>;
|
|
23
|
+
loadCards: () => Promise<readonly PluginCredentialCard[]>;
|
|
24
|
+
surfaces: AssistantSurfaceDeps;
|
|
25
|
+
restart: DevRestartPort | null;
|
|
26
|
+
host: {
|
|
27
|
+
metadata: ToolMetadataById;
|
|
28
|
+
catalog: readonly AgentToolDefinition[];
|
|
29
|
+
catalogModule: string;
|
|
30
|
+
readPermission: string;
|
|
31
|
+
restartPermission: string;
|
|
32
|
+
restartReason: "provider-settings-live-apply";
|
|
33
|
+
copy: {
|
|
34
|
+
unavailable: string;
|
|
35
|
+
noArguments: string;
|
|
36
|
+
revokeInput: string;
|
|
37
|
+
ungranted: string;
|
|
38
|
+
restartTitle: string;
|
|
39
|
+
restartWarning: string;
|
|
40
|
+
restartLabel: string;
|
|
41
|
+
restartUnavailable: string;
|
|
42
|
+
restartUnconfirmed: string;
|
|
43
|
+
restartAccepted: string;
|
|
44
|
+
};
|
|
45
|
+
approvalToolHandler: (required: {
|
|
46
|
+
surfaces: AssistantSurfaceDeps;
|
|
47
|
+
prepare: (required: {
|
|
48
|
+
ctx: ToolExecutionContext;
|
|
49
|
+
}) => Promise<{
|
|
50
|
+
restart: DevRestartPort | null;
|
|
51
|
+
}>;
|
|
52
|
+
describe: (required: {
|
|
53
|
+
ctx: ToolExecutionContext;
|
|
54
|
+
prepared: {
|
|
55
|
+
restart: DevRestartPort | null;
|
|
56
|
+
};
|
|
57
|
+
}) => {
|
|
58
|
+
toolId: string;
|
|
59
|
+
errorCode: string;
|
|
60
|
+
title: string;
|
|
61
|
+
warning: string;
|
|
62
|
+
details: readonly SurfaceDetail[];
|
|
63
|
+
confirmLabel: string;
|
|
64
|
+
};
|
|
65
|
+
run: (required: {
|
|
66
|
+
ctx: ToolExecutionContext;
|
|
67
|
+
prepared: {
|
|
68
|
+
restart: DevRestartPort | null;
|
|
69
|
+
};
|
|
70
|
+
executionOptions: ToolExecutionOptions;
|
|
71
|
+
}) => Promise<unknown>;
|
|
72
|
+
}, optional: {
|
|
73
|
+
ask: (required: {
|
|
74
|
+
prepared: {
|
|
75
|
+
restart: DevRestartPort | null;
|
|
76
|
+
};
|
|
77
|
+
}) => boolean;
|
|
78
|
+
declined: (required: {
|
|
79
|
+
reason: string;
|
|
80
|
+
}) => unknown;
|
|
81
|
+
}) => ToolHandler;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export declare function buildProjectKeyRegistrations({ keys, authorize, loadCards, surfaces, restart, host }: ProjectKeyRegistrationInput, _optional?: Record<string, never>): ToolRegistration[];
|
|
85
|
+
export {};
|
|
86
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { buildDomainRegistrations, indexCatalogById, requireInputRecord, ToolInputError } from "@jini-ai/core";
|
|
2
|
+
export function createProjectKeysCatalog({ readPermission, restartPermission, descriptions }, _optional = {}) {
|
|
3
|
+
return [
|
|
4
|
+
{ name: "project_keys_list", description: descriptions.list, sideEffects: "none", authorization: { permission: readPermission }, inputSchema: { type: "object", additionalProperties: false, properties: {} } },
|
|
5
|
+
{ name: "project_key_use", description: descriptions.use, sideEffects: "mutates-durable-state", authorization: { permission: "resolved-per-kind" }, inputSchema: { type: "object", additionalProperties: false, required: ["keyId", "use"], properties: { keyId: { type: "string", minLength: 1 }, use: { type: "boolean", const: false } } } },
|
|
6
|
+
{ name: "site_restart", description: descriptions.restart, sideEffects: "mutates-durable-state", authorization: { permission: restartPermission }, inputSchema: { type: "object", additionalProperties: false, properties: {} } },
|
|
7
|
+
];
|
|
8
|
+
}
|
|
9
|
+
export const projectKeysRisk = new Map([["project_keys_list", "none"], ["project_key_use", "mutates-durable-state"], ["site_restart", "mutates-durable-state"]]);
|
|
10
|
+
export function buildProjectKeyRegistrations({ keys, authorize, loadCards, surfaces, restart, host }, _optional = {}) {
|
|
11
|
+
const available = () => {
|
|
12
|
+
if (!keys)
|
|
13
|
+
throw new ToolInputError({ message: host.copy.unavailable });
|
|
14
|
+
return keys;
|
|
15
|
+
};
|
|
16
|
+
const empty = ({ input }, _optional = {}) => {
|
|
17
|
+
const value = input === undefined ? {} : requireInputRecord({ input });
|
|
18
|
+
if (Object.keys(value).length)
|
|
19
|
+
throw new ToolInputError({ message: host.copy.noArguments });
|
|
20
|
+
};
|
|
21
|
+
return buildDomainRegistrations({ metadata: host.metadata, domain: "project-keys", catalogModule: host.catalogModule,
|
|
22
|
+
catalog: indexCatalogById({ catalog: host.catalog }), derivedRisk: projectKeysRisk, handlers: {
|
|
23
|
+
project_keys_list: async (ctx) => {
|
|
24
|
+
empty({ input: ctx.input });
|
|
25
|
+
await authorize({ ctx, permission: host.readPermission });
|
|
26
|
+
return { keys: await available().listGranted({ cards: await loadCards() }) };
|
|
27
|
+
},
|
|
28
|
+
project_key_use: async (ctx) => {
|
|
29
|
+
const input = requireInputRecord({ input: ctx.input });
|
|
30
|
+
if (Object.keys(input).some(key => key !== "keyId" && key !== "use") || typeof input.keyId !== "string" || !input.keyId || input.use !== false)
|
|
31
|
+
throw new ToolInputError({ message: host.copy.revokeInput });
|
|
32
|
+
await authorize({ ctx, permission: host.readPermission });
|
|
33
|
+
const row = (await available().listGranted({})).find(row => row.keyId === input.keyId);
|
|
34
|
+
if (!row)
|
|
35
|
+
throw new ToolInputError({ message: host.copy.ungranted });
|
|
36
|
+
await authorize({ ctx, permission: await available().permissionFor({ keyId: row.keyId }) });
|
|
37
|
+
ctx.signal.throwIfAborted();
|
|
38
|
+
return { ...await available().use({ keyId: row.keyId, use: false }), usedBy: [] };
|
|
39
|
+
},
|
|
40
|
+
site_restart: createRestartApprovalHandler({ surfaces, restart, authorize, host, empty }),
|
|
41
|
+
} });
|
|
42
|
+
}
|
|
43
|
+
function createRestartApprovalHandler({ surfaces, restart, authorize, host, empty }) {
|
|
44
|
+
// The shared Jini approval lifecycle freezes the call and binds the actor; no supervisor = no card.
|
|
45
|
+
return host.approvalToolHandler({ surfaces,
|
|
46
|
+
prepare: async ({ ctx }) => {
|
|
47
|
+
empty({ input: ctx.input });
|
|
48
|
+
await authorize({ ctx, permission: host.restartPermission });
|
|
49
|
+
return { restart };
|
|
50
|
+
},
|
|
51
|
+
describe: () => ({ toolId: "site_restart", errorCode: "SITE_RESTART", title: host.copy.restartTitle, warning: host.copy.restartWarning, details: [], confirmLabel: host.copy.restartLabel }),
|
|
52
|
+
run: async ({ ctx, prepared }) => {
|
|
53
|
+
if (!prepared.restart)
|
|
54
|
+
return { restarted: false, message: host.copy.restartUnavailable };
|
|
55
|
+
ctx.signal.throwIfAborted();
|
|
56
|
+
await authorize({ ctx, permission: host.restartPermission });
|
|
57
|
+
const decision = await prepared.restart.requestRestart({ reason: host.restartReason }, { awaitAcceptance: true });
|
|
58
|
+
if (!decision)
|
|
59
|
+
return { restarted: false, reason: host.copy.restartUnconfirmed };
|
|
60
|
+
if (!decision.accepted)
|
|
61
|
+
return { restarted: false, reason: decision.reason };
|
|
62
|
+
return { restartRequested: true, message: host.copy.restartAccepted };
|
|
63
|
+
},
|
|
64
|
+
}, { ask: ({ prepared }) => prepared.restart !== null, declined: ({ reason }) => ({ restarted: false, reason }) });
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { RouteInputContext } from "@jini-ai/core/contracts/server";
|
|
2
|
+
/**
|
|
3
|
+
* @file `POST /hooks/mail/:providerId` — a mail provider's bounce/complaint webhook. Unauthenticated:
|
|
4
|
+
* the provider's signature is the credential, and it is over the exact request bytes, so the host
|
|
5
|
+
* mounts a raw body parser (any content type, capped at the ingest's own limit) on this route ahead
|
|
6
|
+
* of any JSON parser, and this spec hands those bytes to the ingest untouched.
|
|
7
|
+
*/
|
|
8
|
+
/** Node-style request headers: lower-case keys, repeated headers as arrays. */
|
|
9
|
+
export type MailFeedbackHeaders = Readonly<Record<string, string | readonly string[] | undefined>>;
|
|
10
|
+
/** What the host injects. */
|
|
11
|
+
export interface MailFeedbackRouteDeps {
|
|
12
|
+
/** The provider-feedback ingest: provider lookup, signature over the exact bytes, rate limit, replay dedup, record. */
|
|
13
|
+
readonly ingest: {
|
|
14
|
+
handle(required: {
|
|
15
|
+
providerId: string;
|
|
16
|
+
rawBody: Uint8Array;
|
|
17
|
+
headers: MailFeedbackHeaders;
|
|
18
|
+
}): Promise<{
|
|
19
|
+
readonly status: number;
|
|
20
|
+
readonly body: unknown;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
/** This request's headers, bound per request by the host: which of them a provider signs is the provider's business. */
|
|
24
|
+
readonly requestHeaders: MailFeedbackHeaders;
|
|
25
|
+
}
|
|
26
|
+
/** The provider webhook as a structural raw spec (kept structural so this package never imports the server toolkit). */
|
|
27
|
+
export interface MailFeedbackPublicRawRoute {
|
|
28
|
+
readonly method: "post";
|
|
29
|
+
readonly path: string;
|
|
30
|
+
readonly bufferedReply: true;
|
|
31
|
+
handle(required: {
|
|
32
|
+
readonly raw: RouteInputContext;
|
|
33
|
+
readonly deps: MailFeedbackRouteDeps;
|
|
34
|
+
}, optional: {
|
|
35
|
+
readonly signal: AbortSignal;
|
|
36
|
+
}): Promise<Response>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Forwards the raw bytes, provider id and headers to the ingest and answers its status and JSON body.
|
|
40
|
+
* An ingest failure propagates: the host writes the redacted 500, since the caller is unauthenticated.
|
|
41
|
+
* @complexity O(n) in the body size (one copy) plus the ingest.
|
|
42
|
+
*/
|
|
43
|
+
export declare const mailFeedbackRoute: MailFeedbackPublicRawRoute;
|
|
44
|
+
//# sourceMappingURL=feedback.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Forwards the raw bytes, provider id and headers to the ingest and answers its status and JSON body.
|
|
3
|
+
* An ingest failure propagates: the host writes the redacted 500, since the caller is unauthenticated.
|
|
4
|
+
* @complexity O(n) in the body size (one copy) plus the ingest.
|
|
5
|
+
*/
|
|
6
|
+
export const mailFeedbackRoute = {
|
|
7
|
+
method: "post",
|
|
8
|
+
path: "/hooks/mail/:providerId",
|
|
9
|
+
bufferedReply: true,
|
|
10
|
+
async handle({ raw, deps }) {
|
|
11
|
+
// No body at all leaves `req.body` as `{}`; an empty buffer is what the signature saw.
|
|
12
|
+
const body = raw.body instanceof Uint8Array ? raw.body : new Uint8Array(0);
|
|
13
|
+
const result = await deps.ingest.handle({ providerId: raw.params.providerId ?? "", rawBody: new Uint8Array(body), headers: deps.requestHeaders });
|
|
14
|
+
return new Response(JSON.stringify(result.body), { status: result.status, headers: { "content-type": "application/json; charset=utf-8" } });
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=feedback.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type NewsletterPublicRawRoute } from "./page.js";
|
|
2
|
+
/** What the host injects. */
|
|
3
|
+
export interface NewsletterConfirmRouteDeps {
|
|
4
|
+
/** Resolves once the newsletter ports are ready; awaited before the token is read. */
|
|
5
|
+
ready(): Promise<void>;
|
|
6
|
+
/** Consumes the emailed confirmation token for the host's workspace. Throws {@link NewsletterConfirmTokenInvalidError} for a bad one. */
|
|
7
|
+
consume(required: {
|
|
8
|
+
readonly rawToken: string;
|
|
9
|
+
}): Promise<{
|
|
10
|
+
readonly changed: boolean;
|
|
11
|
+
readonly subscription: {
|
|
12
|
+
readonly listId: string;
|
|
13
|
+
};
|
|
14
|
+
readonly eventId: string;
|
|
15
|
+
}>;
|
|
16
|
+
/** Visitor analytics for a first (state-changing) confirmation; never alters the answer. */
|
|
17
|
+
onSubscribed(required: {
|
|
18
|
+
readonly listId: string;
|
|
19
|
+
readonly eventId: string;
|
|
20
|
+
}): void;
|
|
21
|
+
/** Records an unexpected failure with the host's incident tracker and answers its error id. */
|
|
22
|
+
reportFailure(required: {
|
|
23
|
+
readonly error: unknown;
|
|
24
|
+
}): {
|
|
25
|
+
readonly errorId: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* `GET /newsletter/confirm?token=...` — `CONFIRM_SUBSCRIPTION` (api.spec.md §1a). Public,
|
|
30
|
+
* cookie-less, no-login by design (§1a's "same cookie-less, no-admin-authority origin lineage as
|
|
31
|
+
* ADR-020/025/027's isolation pattern"): this route family must NEVER read or set a session cookie,
|
|
32
|
+
* and must never import `requireAdminSession`/`getAuthedPrincipal` (mirrors `routes/members/
|
|
33
|
+
* sign-in.ts`'s ADR-PIPE-013 Enforcement note). Renders an HTML page (a human clicks this link),
|
|
34
|
+
* not JSON.
|
|
35
|
+
* @complexity O(1) beyond the token verification and one repository write.
|
|
36
|
+
*/
|
|
37
|
+
export declare const newsletterConfirmRoute: NewsletterPublicRawRoute<NewsletterConfirmRouteDeps>;
|
|
38
|
+
//# sourceMappingURL=confirm.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { NewsletterConfirmTokenInvalidError } from "../../../newsletter/errors.js";
|
|
2
|
+
import { newsletterPage, queryToken } from "./page.js";
|
|
3
|
+
/**
|
|
4
|
+
* `GET /newsletter/confirm?token=...` — `CONFIRM_SUBSCRIPTION` (api.spec.md §1a). Public,
|
|
5
|
+
* cookie-less, no-login by design (§1a's "same cookie-less, no-admin-authority origin lineage as
|
|
6
|
+
* ADR-020/025/027's isolation pattern"): this route family must NEVER read or set a session cookie,
|
|
7
|
+
* and must never import `requireAdminSession`/`getAuthedPrincipal` (mirrors `routes/members/
|
|
8
|
+
* sign-in.ts`'s ADR-PIPE-013 Enforcement note). Renders an HTML page (a human clicks this link),
|
|
9
|
+
* not JSON.
|
|
10
|
+
* @complexity O(1) beyond the token verification and one repository write.
|
|
11
|
+
*/
|
|
12
|
+
export const newsletterConfirmRoute = {
|
|
13
|
+
method: "get",
|
|
14
|
+
path: "/newsletter/confirm",
|
|
15
|
+
bufferedReply: true,
|
|
16
|
+
handle: async ({ raw, deps }) => {
|
|
17
|
+
await deps.ready();
|
|
18
|
+
try {
|
|
19
|
+
const result = await deps.consume({ rawToken: queryToken({ query: raw.query }) });
|
|
20
|
+
if (result.changed)
|
|
21
|
+
deps.onSubscribed({ listId: result.subscription.listId, eventId: result.eventId });
|
|
22
|
+
return newsletterPage({ status: 200, title: "Subscription confirmed", message: "Your subscription is confirmed. You're all set." });
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
if (err instanceof NewsletterConfirmTokenInvalidError) {
|
|
26
|
+
return newsletterPage({ status: 400, title: "Confirmation link invalid", message: "This confirmation link is invalid or has expired. Please request a new one." });
|
|
27
|
+
}
|
|
28
|
+
const { errorId } = deps.reportFailure({ error: err });
|
|
29
|
+
return newsletterPage({ status: 500, title: "Subscription confirmation unavailable", message: `The site couldn’t complete subscription confirmation. Try the original action again and report this error ID if it keeps happening. Error ID: ${errorId}` });
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=confirm.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** One finished newsletter page as a web `Response` with the given status.
|
|
2
|
+
* @complexity O(n) in the text length.
|
|
3
|
+
*/
|
|
4
|
+
export declare function newsletterPage({ status, title, message }: {
|
|
5
|
+
readonly status: number;
|
|
6
|
+
readonly title: string;
|
|
7
|
+
readonly message: string;
|
|
8
|
+
}, _optional?: Record<string, never>): Response;
|
|
9
|
+
/** The query `token` as a string; anything else (absent, repeated, non-string) is the empty token, which the
|
|
10
|
+
* token verifier refuses as invalid exactly as a malformed one.
|
|
11
|
+
* @complexity O(1).
|
|
12
|
+
*/
|
|
13
|
+
export declare function queryToken({ query }: {
|
|
14
|
+
readonly query: Readonly<Record<string, unknown>>;
|
|
15
|
+
}, _optional?: Record<string, never>): string;
|
|
16
|
+
/** A public, cookie-less newsletter raw route in the exact shape `@jini-ai/http-kit`'s `RawRouteSpec` mounts,
|
|
17
|
+
* kept structural so this package never imports the server toolkit. */
|
|
18
|
+
export interface NewsletterPublicRawRoute<Deps> {
|
|
19
|
+
readonly method: "get" | "post";
|
|
20
|
+
readonly path: string;
|
|
21
|
+
readonly bufferedReply: true;
|
|
22
|
+
handle(required: {
|
|
23
|
+
readonly raw: import("@jini-ai/core/contracts/server").RouteInputContext;
|
|
24
|
+
readonly deps: Deps;
|
|
25
|
+
}, optional: {
|
|
26
|
+
readonly signal: AbortSignal;
|
|
27
|
+
}): Promise<Response>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=page.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { escapeHtml } from "@jini-ai/core/text";
|
|
2
|
+
/**
|
|
3
|
+
* @file The one HTML answer the public newsletter token routes (`confirm`, `unsubscribe`) share: a bare
|
|
4
|
+
* page with a heading and a sentence, a human clicked an emailed link and reads the result. Every answer is
|
|
5
|
+
* `text/html; charset=utf-8`; the specs mark themselves `bufferedReply` so the host writes it through Express's
|
|
6
|
+
* own `res.send`, keeping `Content-Length` and the weak ETag the hand-written routes produced.
|
|
7
|
+
*/
|
|
8
|
+
/** The rendered page: markup-escaped title and message in a minimal document.
|
|
9
|
+
* @complexity O(n) in the text length.
|
|
10
|
+
*/
|
|
11
|
+
function renderPage({ title, message }, _optional = {}) {
|
|
12
|
+
return `<!doctype html>
|
|
13
|
+
<html lang="en">
|
|
14
|
+
<head><meta charset="utf-8"><title>${escapeHtml({ text: title })}</title></head>
|
|
15
|
+
<body>
|
|
16
|
+
<h1>${escapeHtml({ text: title })}</h1>
|
|
17
|
+
<p>${escapeHtml({ text: message })}</p>
|
|
18
|
+
</body>
|
|
19
|
+
</html>`;
|
|
20
|
+
}
|
|
21
|
+
/** One finished newsletter page as a web `Response` with the given status.
|
|
22
|
+
* @complexity O(n) in the text length.
|
|
23
|
+
*/
|
|
24
|
+
export function newsletterPage({ status, title, message }, _optional = {}) {
|
|
25
|
+
return new Response(renderPage({ title, message }), { status, headers: { "content-type": "text/html; charset=utf-8" } });
|
|
26
|
+
}
|
|
27
|
+
/** The query `token` as a string; anything else (absent, repeated, non-string) is the empty token, which the
|
|
28
|
+
* token verifier refuses as invalid exactly as a malformed one.
|
|
29
|
+
* @complexity O(1).
|
|
30
|
+
*/
|
|
31
|
+
export function queryToken({ query }, _optional = {}) {
|
|
32
|
+
return typeof query.token === "string" ? query.token : "";
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=page.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type NewsletterPublicRawRoute } from "./page.js";
|
|
2
|
+
/** What the host injects. */
|
|
3
|
+
export interface NewsletterUnsubscribeRouteDeps {
|
|
4
|
+
/** Resolves once the newsletter ports are ready; awaited before the token is read. */
|
|
5
|
+
ready(): Promise<void>;
|
|
6
|
+
/** Processes the emailed unsubscribe token. Throws {@link NewsletterUnsubscribeTokenInvalidError} for a bad one. */
|
|
7
|
+
unsubscribe(required: {
|
|
8
|
+
readonly rawToken: string;
|
|
9
|
+
}): Promise<{
|
|
10
|
+
readonly outcome: "unsubscribed" | "already-unsubscribed";
|
|
11
|
+
}>;
|
|
12
|
+
/** Records an unexpected failure with the host's incident tracker and answers its error id. */
|
|
13
|
+
reportFailure(required: {
|
|
14
|
+
readonly error: unknown;
|
|
15
|
+
}): {
|
|
16
|
+
readonly errorId: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* `GET|POST /newsletter/unsubscribe?token=...` — `UNSUBSCRIBE` (api.spec.md §1a). Public,
|
|
21
|
+
* cookie-less, no-login by design, same isolation lineage as `confirm.ts` — never reads
|
|
22
|
+
* or sets a session cookie. `POST` is the RFC 8058 one-click path (the mail client itself, not this
|
|
23
|
+
* server, is what stamps `List-Unsubscribe-Post: List-Unsubscribe=One-Click` on the ORIGINAL
|
|
24
|
+
* outbound email so it knows a bare POST here needs no further confirmation) — "GET with the same
|
|
25
|
+
* token is equally valid" (api.spec.md §4), so both methods share one handler. Idempotent on a
|
|
26
|
+
* repeat click of an already-processed token (REQ-15/EC-03): `processUnsubscribe` itself returns
|
|
27
|
+
* `already-unsubscribed` rather than throwing, and this route renders the SAME success page either way.
|
|
28
|
+
* @complexity O(1) beyond the token verification and one repository write.
|
|
29
|
+
*/
|
|
30
|
+
export declare const newsletterUnsubscribeGetRoute: NewsletterPublicRawRoute<NewsletterUnsubscribeRouteDeps>;
|
|
31
|
+
/** The RFC 8058 one-click `POST` of {@link newsletterUnsubscribeGetRoute}; the same handler. */
|
|
32
|
+
export declare const newsletterUnsubscribePostRoute: NewsletterPublicRawRoute<NewsletterUnsubscribeRouteDeps>;
|
|
33
|
+
//# sourceMappingURL=unsubscribe.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { NewsletterUnsubscribeTokenInvalidError } from "../../../newsletter/errors.js";
|
|
2
|
+
import { newsletterPage, queryToken } from "./page.js";
|
|
3
|
+
const handle = async ({ raw, deps }) => {
|
|
4
|
+
await deps.ready();
|
|
5
|
+
try {
|
|
6
|
+
await deps.unsubscribe({ rawToken: queryToken({ query: raw.query }) });
|
|
7
|
+
return newsletterPage({ status: 200, title: "You're unsubscribed", message: "You will no longer receive this newsletter. If this was a mistake, you can re-subscribe at any time." });
|
|
8
|
+
}
|
|
9
|
+
catch (err) {
|
|
10
|
+
if (err instanceof NewsletterUnsubscribeTokenInvalidError) {
|
|
11
|
+
return newsletterPage({ status: 400, title: "Unsubscribe link invalid", message: "This unsubscribe link is invalid or has expired." });
|
|
12
|
+
}
|
|
13
|
+
const { errorId } = deps.reportFailure({ error: err });
|
|
14
|
+
return newsletterPage({ status: 500, title: "Unsubscription unavailable", message: `The site couldn’t complete unsubscription. Try the original action again and report this error ID if it keeps happening. Error ID: ${errorId}` });
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* `GET|POST /newsletter/unsubscribe?token=...` — `UNSUBSCRIBE` (api.spec.md §1a). Public,
|
|
19
|
+
* cookie-less, no-login by design, same isolation lineage as `confirm.ts` — never reads
|
|
20
|
+
* or sets a session cookie. `POST` is the RFC 8058 one-click path (the mail client itself, not this
|
|
21
|
+
* server, is what stamps `List-Unsubscribe-Post: List-Unsubscribe=One-Click` on the ORIGINAL
|
|
22
|
+
* outbound email so it knows a bare POST here needs no further confirmation) — "GET with the same
|
|
23
|
+
* token is equally valid" (api.spec.md §4), so both methods share one handler. Idempotent on a
|
|
24
|
+
* repeat click of an already-processed token (REQ-15/EC-03): `processUnsubscribe` itself returns
|
|
25
|
+
* `already-unsubscribed` rather than throwing, and this route renders the SAME success page either way.
|
|
26
|
+
* @complexity O(1) beyond the token verification and one repository write.
|
|
27
|
+
*/
|
|
28
|
+
export const newsletterUnsubscribeGetRoute = {
|
|
29
|
+
method: "get", path: "/newsletter/unsubscribe", bufferedReply: true, handle,
|
|
30
|
+
};
|
|
31
|
+
/** The RFC 8058 one-click `POST` of {@link newsletterUnsubscribeGetRoute}; the same handler. */
|
|
32
|
+
export const newsletterUnsubscribePostRoute = {
|
|
33
|
+
method: "post", path: "/newsletter/unsubscribe", bufferedReply: true, handle,
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=unsubscribe.js.map
|
|
@@ -1,40 +1,9 @@
|
|
|
1
|
-
import type { PasskeyOptions } from '../../core/types.js';
|
|
2
1
|
import { runPasskeyCeremony } from './passkey-browser.js';
|
|
3
2
|
import { usePasskeySettings, usePasskeySignIn } from './Passkeys.hooks.js';
|
|
4
3
|
import { type Translate } from '@jini-ai/core/text';
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
options: PasskeyOptions;
|
|
8
|
-
};
|
|
9
|
-
type Finish = {
|
|
10
|
-
pendingToken: string;
|
|
11
|
-
response: unknown;
|
|
12
|
-
};
|
|
4
|
+
import type { PasskeySettingsPort, PasskeySignInPort } from '@jini-ai/core/contracts/site/user-management-react';
|
|
5
|
+
export type { PasskeySettingsPort, PasskeySignInPort } from '@jini-ai/core/contracts/site/user-management-react';
|
|
13
6
|
type Ceremony = typeof runPasskeyCeremony;
|
|
14
|
-
export interface PasskeySignInPort {
|
|
15
|
-
begin(input: {
|
|
16
|
-
pendingToken: string;
|
|
17
|
-
}): Promise<Started>;
|
|
18
|
-
complete(input: Finish): Promise<void>;
|
|
19
|
-
}
|
|
20
|
-
export interface PasskeySettingsPort {
|
|
21
|
-
status(): Promise<{
|
|
22
|
-
isOwner: boolean;
|
|
23
|
-
credentials: {
|
|
24
|
-
id: string;
|
|
25
|
-
}[];
|
|
26
|
-
}>;
|
|
27
|
-
enroll(input: {
|
|
28
|
-
password: string;
|
|
29
|
-
code: string;
|
|
30
|
-
}): Promise<Started>;
|
|
31
|
-
confirm(input: Finish): Promise<void>;
|
|
32
|
-
remove(input: {
|
|
33
|
-
id: string;
|
|
34
|
-
password: string;
|
|
35
|
-
code: string;
|
|
36
|
-
}): Promise<void>;
|
|
37
|
-
}
|
|
38
7
|
/** Explicit alternative to a TOTP code; password proof remains required. O(1), two single-send calls. */
|
|
39
8
|
export declare function PasskeySignIn({ port, pendingToken, onComplete, translate: t, ceremony, usePasskeySignInHook }: {
|
|
40
9
|
port: PasskeySignInPort;
|
|
@@ -55,5 +24,4 @@ export declare function PasskeySettings({ port, translate: t, ceremony, usePassk
|
|
|
55
24
|
} & {
|
|
56
25
|
usePasskeySettingsHook?: typeof usePasskeySettings;
|
|
57
26
|
}): import("react").JSX.Element | null;
|
|
58
|
-
export {};
|
|
59
27
|
//# sourceMappingURL=Passkeys.d.ts.map
|