@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,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The D1c consent chokepoint (ADR-PIPE-013 Decision §4, crosscutting
|
|
3
|
+
* sweep D1c LOCKED 4-0).
|
|
4
|
+
*
|
|
5
|
+
* Purpose:
|
|
6
|
+
* `requestConsent`/`confirmConsent`/`revokeConsent`/`checkConsent` — the ONLY
|
|
7
|
+
* write path to `member_consents`. Kept separate from `write-service.ts`
|
|
8
|
+
* because consent has a distinct actor model: a caller *other than* the
|
|
9
|
+
* member or an operator (e.g. Newsletter, a sibling Tier-2 core module)
|
|
10
|
+
* requests/confirms on the member's behalf, attributed via an explicit
|
|
11
|
+
* `originModule` field rather than `write-service.ts`'s operator/member actor
|
|
12
|
+
* split.
|
|
13
|
+
*
|
|
14
|
+
* INV-NEW-02 (the one invariant this whole file exists to enforce): no caller
|
|
15
|
+
* may assert `status: 'granted'` directly — the only path is `requestConsent`
|
|
16
|
+
* (creates `pending`) then `confirmConsent` (transitions `pending -> granted`,
|
|
17
|
+
* and ONLY from `pending`). `confirmConsent` with no fresh matching pending
|
|
18
|
+
* row — whether none was ever requested, or the purpose already reached a
|
|
19
|
+
* terminal `granted`/`revoked` state — throws `MemberNotFoundError` and
|
|
20
|
+
* creates no row, mirroring `write-service.ts`'s existing not-found error
|
|
21
|
+
* shape rather than inventing a new error class for this one module.
|
|
22
|
+
*
|
|
23
|
+
* Every write here appends a same-tx `member_revisions` row (`entity_kind
|
|
24
|
+
* ='consent'`) via `MemberConsentRepoPort.transaction`, matching the
|
|
25
|
+
* ADR-022 §4a / ADR-028 §4 write-chokepoint discipline every other
|
|
26
|
+
* core-owned mutation in this repo already follows.
|
|
27
|
+
*/
|
|
28
|
+
import type { Clock as ClockPort, IdGenerator as IdGeneratorPort } from "@jini-ai/core/primitives";
|
|
29
|
+
import type { MemberConsentRepoPort, MemberRepoPort } from "./ports.js";
|
|
30
|
+
import { type ConsentEvidence, type ConsentPurpose, type MemberConsentRecord } from "./types.js";
|
|
31
|
+
/** Deps `consent-service.ts` needs — a distinct bundle from `MembersWriteServiceDeps` (no mailer/sessions/tiers). */
|
|
32
|
+
export interface ConsentServiceDeps {
|
|
33
|
+
clock: ClockPort;
|
|
34
|
+
ids: IdGeneratorPort;
|
|
35
|
+
members: MemberRepoPort;
|
|
36
|
+
consents: MemberConsentRepoPort;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Begin a consent request: creates (or resets) a `status: 'pending'` row for
|
|
40
|
+
* `(memberId, purpose)` and appends a `consent_request` revision, in the same
|
|
41
|
+
* `transaction()` call.
|
|
42
|
+
*
|
|
43
|
+
* @complexity O(1) — one member lookup, one consent lookup, one upsert, one revision append.
|
|
44
|
+
* @overallScore 100
|
|
45
|
+
*/
|
|
46
|
+
export declare function requestConsent(required: {
|
|
47
|
+
deps: ConsentServiceDeps;
|
|
48
|
+
input: {
|
|
49
|
+
workspaceId: string;
|
|
50
|
+
memberId: string;
|
|
51
|
+
purpose: ConsentPurpose;
|
|
52
|
+
evidence: ConsentEvidence;
|
|
53
|
+
originModule: string;
|
|
54
|
+
};
|
|
55
|
+
}, _optional?: Record<string, never>): Promise<{
|
|
56
|
+
consent: MemberConsentRecord;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Confirm a previously-requested consent: `pending -> granted`. The ONLY
|
|
60
|
+
* function that may write `status: 'granted'` (INV-NEW-02) — see file header.
|
|
61
|
+
*
|
|
62
|
+
* @complexity O(1).
|
|
63
|
+
* @overallScore 100
|
|
64
|
+
*/
|
|
65
|
+
export declare function confirmConsent(required: {
|
|
66
|
+
deps: ConsentServiceDeps;
|
|
67
|
+
input: {
|
|
68
|
+
workspaceId: string;
|
|
69
|
+
memberId: string;
|
|
70
|
+
purpose: ConsentPurpose;
|
|
71
|
+
evidence: ConsentEvidence;
|
|
72
|
+
originModule: string;
|
|
73
|
+
};
|
|
74
|
+
}, _optional?: Record<string, never>): Promise<{
|
|
75
|
+
consent: MemberConsentRecord;
|
|
76
|
+
}>;
|
|
77
|
+
/**
|
|
78
|
+
* Revoke a granted (or already-revoked) consent. Idempotent — revoking an
|
|
79
|
+
* already-revoked purpose is a no-op (no write, no new revision row),
|
|
80
|
+
* matching `disableMember`'s idempotency convention. Requires an existing
|
|
81
|
+
* consent record (mirrors `disableMember` requiring an existing member);
|
|
82
|
+
* a purpose with no consent record at all throws `MemberNotFoundError`.
|
|
83
|
+
*
|
|
84
|
+
* @complexity O(1).
|
|
85
|
+
* @overallScore 100
|
|
86
|
+
*/
|
|
87
|
+
export declare function revokeConsent(required: {
|
|
88
|
+
deps: ConsentServiceDeps;
|
|
89
|
+
input: {
|
|
90
|
+
workspaceId: string;
|
|
91
|
+
memberId: string;
|
|
92
|
+
purpose: ConsentPurpose;
|
|
93
|
+
};
|
|
94
|
+
}, _optional?: Record<string, never>): Promise<{
|
|
95
|
+
consent: MemberConsentRecord;
|
|
96
|
+
}>;
|
|
97
|
+
/**
|
|
98
|
+
* Read the current consent status for `(memberId, purpose)`. Total function —
|
|
99
|
+
* never throws, returns `{status:'none'}` when no row exists (Contract Map
|
|
100
|
+
* C-006). No member-existence check: a pure read, safe to call for any id.
|
|
101
|
+
*
|
|
102
|
+
* @complexity O(1).
|
|
103
|
+
* @overallScore 100
|
|
104
|
+
*/
|
|
105
|
+
export declare function checkConsent(required: {
|
|
106
|
+
deps: ConsentServiceDeps;
|
|
107
|
+
input: {
|
|
108
|
+
workspaceId: string;
|
|
109
|
+
memberId: string;
|
|
110
|
+
purpose: ConsentPurpose;
|
|
111
|
+
};
|
|
112
|
+
}, _optional?: Record<string, never>): Promise<{
|
|
113
|
+
status: MemberConsentRecord["status"] | "none";
|
|
114
|
+
}>;
|
|
115
|
+
//# sourceMappingURL=consent-service.d.ts.map
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { nowIso as clockNowIso } from "@jini-ai/core/primitives";
|
|
2
|
+
import { MemberNotFoundError, } from "./types.js";
|
|
3
|
+
async function assertMemberExists({ deps, workspaceId, memberId }, _optional = {}) {
|
|
4
|
+
const member = await deps.members.findById({ workspaceId, id: memberId });
|
|
5
|
+
if (!member) {
|
|
6
|
+
throw new MemberNotFoundError(`member '${memberId}' was not found`);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function buildPendingConsent({ deps, input, existing, nowIso }) {
|
|
10
|
+
const consent = existing
|
|
11
|
+
? {
|
|
12
|
+
...existing,
|
|
13
|
+
status: "pending",
|
|
14
|
+
evidence: input.evidence,
|
|
15
|
+
grantedAt: undefined,
|
|
16
|
+
revokedAt: undefined,
|
|
17
|
+
updatedAt: nowIso,
|
|
18
|
+
version: existing.version + 1,
|
|
19
|
+
}
|
|
20
|
+
: {
|
|
21
|
+
id: deps.ids.newId(),
|
|
22
|
+
workspaceId: input.workspaceId,
|
|
23
|
+
memberId: input.memberId,
|
|
24
|
+
purpose: input.purpose,
|
|
25
|
+
status: "pending",
|
|
26
|
+
evidence: input.evidence,
|
|
27
|
+
createdAt: nowIso,
|
|
28
|
+
updatedAt: nowIso,
|
|
29
|
+
version: 1,
|
|
30
|
+
};
|
|
31
|
+
return consent;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Begin a consent request: creates (or resets) a `status: 'pending'` row for
|
|
35
|
+
* `(memberId, purpose)` and appends a `consent_request` revision, in the same
|
|
36
|
+
* `transaction()` call.
|
|
37
|
+
*
|
|
38
|
+
* @complexity O(1) — one member lookup, one consent lookup, one upsert, one revision append.
|
|
39
|
+
* @overallScore 100
|
|
40
|
+
*/
|
|
41
|
+
export async function requestConsent(required, _optional = {}) {
|
|
42
|
+
const { deps, input } = required;
|
|
43
|
+
await assertMemberExists({ deps, workspaceId: input.workspaceId, memberId: input.memberId });
|
|
44
|
+
const nowIso = clockNowIso({ clock: deps.clock });
|
|
45
|
+
const existing = await deps.consents.findByMemberAndPurpose({
|
|
46
|
+
workspaceId: input.workspaceId,
|
|
47
|
+
memberId: input.memberId,
|
|
48
|
+
purpose: input.purpose,
|
|
49
|
+
});
|
|
50
|
+
const consent = buildPendingConsent({ deps, input, existing, nowIso });
|
|
51
|
+
await deps.consents.transaction({ fn: async () => {
|
|
52
|
+
await deps.consents.save(consent);
|
|
53
|
+
await deps.consents.appendRevision({
|
|
54
|
+
workspaceId: input.workspaceId,
|
|
55
|
+
memberId: input.memberId,
|
|
56
|
+
consentId: consent.id,
|
|
57
|
+
purpose: input.purpose,
|
|
58
|
+
op: "consent_request",
|
|
59
|
+
beforeJson: existing ? { status: existing.status } : null,
|
|
60
|
+
afterJson: { status: consent.status },
|
|
61
|
+
originModule: input.originModule,
|
|
62
|
+
createdAt: nowIso,
|
|
63
|
+
});
|
|
64
|
+
} });
|
|
65
|
+
return { consent };
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Confirm a previously-requested consent: `pending -> granted`. The ONLY
|
|
69
|
+
* function that may write `status: 'granted'` (INV-NEW-02) — see file header.
|
|
70
|
+
*
|
|
71
|
+
* @complexity O(1).
|
|
72
|
+
* @overallScore 100
|
|
73
|
+
*/
|
|
74
|
+
export async function confirmConsent(required, _optional = {}) {
|
|
75
|
+
const { deps, input } = required;
|
|
76
|
+
await assertMemberExists({ deps, workspaceId: input.workspaceId, memberId: input.memberId });
|
|
77
|
+
const existing = await deps.consents.findByMemberAndPurpose({
|
|
78
|
+
workspaceId: input.workspaceId,
|
|
79
|
+
memberId: input.memberId,
|
|
80
|
+
purpose: input.purpose,
|
|
81
|
+
});
|
|
82
|
+
if (!existing || existing.status !== "pending") {
|
|
83
|
+
// No fresh `requestConsent` to confirm — INV-NEW-02 forbids silently
|
|
84
|
+
// creating a granted row here. Mirrors `write-service.ts`'s not-found
|
|
85
|
+
// error shape rather than inventing a new error class for this module.
|
|
86
|
+
throw new MemberNotFoundError(`no pending consent request found for member '${input.memberId}' / purpose '${input.purpose}'`);
|
|
87
|
+
}
|
|
88
|
+
const nowIso = clockNowIso({ clock: deps.clock });
|
|
89
|
+
const consent = {
|
|
90
|
+
...existing,
|
|
91
|
+
status: "granted",
|
|
92
|
+
evidence: input.evidence,
|
|
93
|
+
grantedAt: nowIso,
|
|
94
|
+
updatedAt: nowIso,
|
|
95
|
+
version: existing.version + 1,
|
|
96
|
+
};
|
|
97
|
+
await deps.consents.transaction({ fn: async () => {
|
|
98
|
+
await deps.consents.save(consent);
|
|
99
|
+
await deps.consents.appendRevision({
|
|
100
|
+
workspaceId: input.workspaceId,
|
|
101
|
+
memberId: input.memberId,
|
|
102
|
+
consentId: consent.id,
|
|
103
|
+
purpose: input.purpose,
|
|
104
|
+
op: "consent_confirm",
|
|
105
|
+
beforeJson: { status: existing.status },
|
|
106
|
+
afterJson: { status: consent.status },
|
|
107
|
+
originModule: input.originModule,
|
|
108
|
+
createdAt: nowIso,
|
|
109
|
+
});
|
|
110
|
+
} });
|
|
111
|
+
return { consent };
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Revoke a granted (or already-revoked) consent. Idempotent — revoking an
|
|
115
|
+
* already-revoked purpose is a no-op (no write, no new revision row),
|
|
116
|
+
* matching `disableMember`'s idempotency convention. Requires an existing
|
|
117
|
+
* consent record (mirrors `disableMember` requiring an existing member);
|
|
118
|
+
* a purpose with no consent record at all throws `MemberNotFoundError`.
|
|
119
|
+
*
|
|
120
|
+
* @complexity O(1).
|
|
121
|
+
* @overallScore 100
|
|
122
|
+
*/
|
|
123
|
+
export async function revokeConsent(required, _optional = {}) {
|
|
124
|
+
const { deps, input } = required;
|
|
125
|
+
const existing = await deps.consents.findByMemberAndPurpose({
|
|
126
|
+
workspaceId: input.workspaceId,
|
|
127
|
+
memberId: input.memberId,
|
|
128
|
+
purpose: input.purpose,
|
|
129
|
+
});
|
|
130
|
+
if (!existing) {
|
|
131
|
+
throw new MemberNotFoundError(`no consent record found for member '${input.memberId}' / purpose '${input.purpose}'`);
|
|
132
|
+
}
|
|
133
|
+
if (existing.status === "revoked") {
|
|
134
|
+
return { consent: existing };
|
|
135
|
+
}
|
|
136
|
+
const nowIso = clockNowIso({ clock: deps.clock });
|
|
137
|
+
const consent = {
|
|
138
|
+
...existing,
|
|
139
|
+
status: "revoked",
|
|
140
|
+
revokedAt: nowIso,
|
|
141
|
+
updatedAt: nowIso,
|
|
142
|
+
version: existing.version + 1,
|
|
143
|
+
};
|
|
144
|
+
await deps.consents.transaction({ fn: async () => {
|
|
145
|
+
await deps.consents.save(consent);
|
|
146
|
+
await deps.consents.appendRevision({
|
|
147
|
+
workspaceId: input.workspaceId,
|
|
148
|
+
memberId: input.memberId,
|
|
149
|
+
consentId: consent.id,
|
|
150
|
+
purpose: input.purpose,
|
|
151
|
+
op: "consent_revoke",
|
|
152
|
+
beforeJson: { status: existing.status },
|
|
153
|
+
afterJson: { status: consent.status },
|
|
154
|
+
// No caller-supplied originModule for revoke (Decision §4's signature has none) — attribute
|
|
155
|
+
// to the module that owns this chokepoint itself.
|
|
156
|
+
originModule: "members",
|
|
157
|
+
createdAt: nowIso,
|
|
158
|
+
});
|
|
159
|
+
} });
|
|
160
|
+
return { consent };
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Read the current consent status for `(memberId, purpose)`. Total function —
|
|
164
|
+
* never throws, returns `{status:'none'}` when no row exists (Contract Map
|
|
165
|
+
* C-006). No member-existence check: a pure read, safe to call for any id.
|
|
166
|
+
*
|
|
167
|
+
* @complexity O(1).
|
|
168
|
+
* @overallScore 100
|
|
169
|
+
*/
|
|
170
|
+
export async function checkConsent(required, _optional = {}) {
|
|
171
|
+
const { deps, input } = required;
|
|
172
|
+
const existing = await deps.consents.findByMemberAndPurpose({
|
|
173
|
+
workspaceId: input.workspaceId,
|
|
174
|
+
memberId: input.memberId,
|
|
175
|
+
purpose: input.purpose,
|
|
176
|
+
});
|
|
177
|
+
return { status: existing?.status ?? "none" };
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=consent-service.js.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { MembersWriteServiceDeps } from "./ports.js";
|
|
2
|
+
import { type MemberRecord, type MemberSubscriptionRecord, type MemberSubscriptionStatus } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Operator/self profile update (validated, revision-recorded via `save`).
|
|
5
|
+
* @complexity O(1).
|
|
6
|
+
* @overallScore 100
|
|
7
|
+
*/
|
|
8
|
+
export declare function updateProfile(required: {
|
|
9
|
+
deps: MembersWriteServiceDeps;
|
|
10
|
+
input: {
|
|
11
|
+
workspaceId: string;
|
|
12
|
+
memberId: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
note?: string;
|
|
15
|
+
};
|
|
16
|
+
}, _options?: Record<string, never>): Promise<{
|
|
17
|
+
member: MemberRecord;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Operator: disable a member (ADR-021 §5 disable-only, never hard-delete).
|
|
21
|
+
* Idempotent — disabling an already-disabled member is a no-op, not an error.
|
|
22
|
+
* Also revokes every live session for the member so a disabled account cannot
|
|
23
|
+
* keep reading gated content through a session minted before the disable.
|
|
24
|
+
*
|
|
25
|
+
* @complexity O(s), s = the member's live session count (small, per-member).
|
|
26
|
+
* @overallScore 100
|
|
27
|
+
*/
|
|
28
|
+
export declare function disableMember(required: {
|
|
29
|
+
deps: MembersWriteServiceDeps;
|
|
30
|
+
input: {
|
|
31
|
+
workspaceId: string;
|
|
32
|
+
memberId: string;
|
|
33
|
+
};
|
|
34
|
+
}, _options?: Record<string, never>): Promise<{
|
|
35
|
+
member: MemberRecord;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* Operator: grant a comp subscription. Rejects an archived tier and rejects a
|
|
39
|
+
* duplicate active/comped subscription to the same tier (aggregate invariant:
|
|
40
|
+
* a member cannot hold two simultaneous entitlements to one tier).
|
|
41
|
+
*
|
|
42
|
+
* @complexity O(k), k = the member's active-subscription count (duplicate check).
|
|
43
|
+
* @overallScore 100
|
|
44
|
+
*/
|
|
45
|
+
export declare function compSubscription(required: {
|
|
46
|
+
deps: MembersWriteServiceDeps;
|
|
47
|
+
input: {
|
|
48
|
+
workspaceId: string;
|
|
49
|
+
memberId: string;
|
|
50
|
+
tierId: string;
|
|
51
|
+
};
|
|
52
|
+
}, _options?: Record<string, never>): Promise<{
|
|
53
|
+
subscription: MemberSubscriptionRecord;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* Change a subscription's status (cancel/expire; also the entry point a future
|
|
57
|
+
* billing plugin uses for `source='billing'` rows — ADR-030 §6).
|
|
58
|
+
*
|
|
59
|
+
* @complexity O(1).
|
|
60
|
+
* @overallScore 100
|
|
61
|
+
*/
|
|
62
|
+
export declare function setSubscriptionStatus(required: {
|
|
63
|
+
deps: MembersWriteServiceDeps;
|
|
64
|
+
input: {
|
|
65
|
+
workspaceId: string;
|
|
66
|
+
subscriptionId: string;
|
|
67
|
+
status: MemberSubscriptionStatus;
|
|
68
|
+
externalRef?: string;
|
|
69
|
+
};
|
|
70
|
+
}, _options?: Record<string, never>): Promise<{
|
|
71
|
+
subscription: MemberSubscriptionRecord;
|
|
72
|
+
}>;
|
|
73
|
+
//# sourceMappingURL=member-admin-writes.d.ts.map
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { nowIso as clockNowIso } from "@jini-ai/core/primitives";
|
|
2
|
+
import { MemberConflictError, MemberNotFoundError, MemberValidationError } from "./types.js";
|
|
3
|
+
const VALID_SUBSCRIPTION_STATUSES = [
|
|
4
|
+
"active",
|
|
5
|
+
"canceled",
|
|
6
|
+
"expired",
|
|
7
|
+
"comped",
|
|
8
|
+
];
|
|
9
|
+
/**
|
|
10
|
+
* Operator/self profile update (validated, revision-recorded via `save`).
|
|
11
|
+
* @complexity O(1).
|
|
12
|
+
* @overallScore 100
|
|
13
|
+
*/
|
|
14
|
+
export async function updateProfile(required, _options = {}) {
|
|
15
|
+
const { deps, input } = required;
|
|
16
|
+
const existing = await deps.members.findById({ workspaceId: input.workspaceId, id: input.memberId });
|
|
17
|
+
if (!existing) {
|
|
18
|
+
throw new MemberNotFoundError(`member '${input.memberId}' was not found`);
|
|
19
|
+
}
|
|
20
|
+
let name = existing.name;
|
|
21
|
+
if (input.name !== undefined) {
|
|
22
|
+
const trimmed = input.name.trim();
|
|
23
|
+
if (!trimmed) {
|
|
24
|
+
throw new MemberValidationError("name must not be blank when provided");
|
|
25
|
+
}
|
|
26
|
+
name = trimmed;
|
|
27
|
+
}
|
|
28
|
+
const note = input.note !== undefined ? input.note.trim() : existing.note;
|
|
29
|
+
const member = {
|
|
30
|
+
...existing,
|
|
31
|
+
name,
|
|
32
|
+
note,
|
|
33
|
+
updatedAt: clockNowIso({ clock: deps.clock }),
|
|
34
|
+
version: existing.version + 1,
|
|
35
|
+
};
|
|
36
|
+
await deps.members.save(member);
|
|
37
|
+
return { member };
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Operator: disable a member (ADR-021 §5 disable-only, never hard-delete).
|
|
41
|
+
* Idempotent — disabling an already-disabled member is a no-op, not an error.
|
|
42
|
+
* Also revokes every live session for the member so a disabled account cannot
|
|
43
|
+
* keep reading gated content through a session minted before the disable.
|
|
44
|
+
*
|
|
45
|
+
* @complexity O(s), s = the member's live session count (small, per-member).
|
|
46
|
+
* @overallScore 100
|
|
47
|
+
*/
|
|
48
|
+
export async function disableMember(required, _options = {}) {
|
|
49
|
+
const { deps, input } = required;
|
|
50
|
+
const existing = await deps.members.findById({ workspaceId: input.workspaceId, id: input.memberId });
|
|
51
|
+
if (!existing) {
|
|
52
|
+
throw new MemberNotFoundError(`member '${input.memberId}' was not found`);
|
|
53
|
+
}
|
|
54
|
+
if (existing.status === "disabled") {
|
|
55
|
+
return { member: existing };
|
|
56
|
+
}
|
|
57
|
+
const nowIso = clockNowIso({ clock: deps.clock });
|
|
58
|
+
const member = {
|
|
59
|
+
...existing,
|
|
60
|
+
status: "disabled",
|
|
61
|
+
credentialsRevokedAt: nowIso,
|
|
62
|
+
updatedAt: nowIso,
|
|
63
|
+
version: existing.version + 1,
|
|
64
|
+
};
|
|
65
|
+
await deps.members.save(member);
|
|
66
|
+
await deps.sessions.revokeAllForMember({
|
|
67
|
+
workspaceId: input.workspaceId,
|
|
68
|
+
memberId: input.memberId,
|
|
69
|
+
revokedAt: nowIso,
|
|
70
|
+
});
|
|
71
|
+
return { member };
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Operator: grant a comp subscription. Rejects an archived tier and rejects a
|
|
75
|
+
* duplicate active/comped subscription to the same tier (aggregate invariant:
|
|
76
|
+
* a member cannot hold two simultaneous entitlements to one tier).
|
|
77
|
+
*
|
|
78
|
+
* @complexity O(k), k = the member's active-subscription count (duplicate check).
|
|
79
|
+
* @overallScore 100
|
|
80
|
+
*/
|
|
81
|
+
export async function compSubscription(required, _options = {}) {
|
|
82
|
+
const { deps, input } = required;
|
|
83
|
+
const member = await deps.members.findById({ workspaceId: input.workspaceId, id: input.memberId });
|
|
84
|
+
if (!member) {
|
|
85
|
+
throw new MemberNotFoundError(`member '${input.memberId}' was not found`);
|
|
86
|
+
}
|
|
87
|
+
const tier = await deps.tiers.findById({ workspaceId: input.workspaceId, id: input.tierId });
|
|
88
|
+
if (!tier) {
|
|
89
|
+
throw new MemberNotFoundError(`tier '${input.tierId}' was not found`);
|
|
90
|
+
}
|
|
91
|
+
if (tier.status !== "active") {
|
|
92
|
+
throw new MemberValidationError(`tier '${input.tierId}' is archived and cannot accept new subscriptions`);
|
|
93
|
+
}
|
|
94
|
+
const nowIso = clockNowIso({ clock: deps.clock });
|
|
95
|
+
const activeSubscriptions = await deps.subscriptions.listActiveByMember({
|
|
96
|
+
workspaceId: input.workspaceId,
|
|
97
|
+
memberId: input.memberId,
|
|
98
|
+
nowIso,
|
|
99
|
+
});
|
|
100
|
+
if (activeSubscriptions.some((subscription) => subscription.tierId === input.tierId)) {
|
|
101
|
+
throw new MemberConflictError(`member '${input.memberId}' already has an active subscription to tier '${input.tierId}'`);
|
|
102
|
+
}
|
|
103
|
+
const subscription = {
|
|
104
|
+
id: deps.ids.newId(),
|
|
105
|
+
workspaceId: input.workspaceId,
|
|
106
|
+
memberId: input.memberId,
|
|
107
|
+
tierId: input.tierId,
|
|
108
|
+
status: "comped",
|
|
109
|
+
source: "comp",
|
|
110
|
+
startedAt: nowIso,
|
|
111
|
+
createdAt: nowIso,
|
|
112
|
+
updatedAt: nowIso,
|
|
113
|
+
version: 1,
|
|
114
|
+
};
|
|
115
|
+
await deps.subscriptions.save(subscription);
|
|
116
|
+
return { subscription };
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Change a subscription's status (cancel/expire; also the entry point a future
|
|
120
|
+
* billing plugin uses for `source='billing'` rows — ADR-030 §6).
|
|
121
|
+
*
|
|
122
|
+
* @complexity O(1).
|
|
123
|
+
* @overallScore 100
|
|
124
|
+
*/
|
|
125
|
+
export async function setSubscriptionStatus(required, _options = {}) {
|
|
126
|
+
const { deps, input } = required;
|
|
127
|
+
const existing = await deps.subscriptions.findById({
|
|
128
|
+
workspaceId: input.workspaceId,
|
|
129
|
+
id: input.subscriptionId,
|
|
130
|
+
});
|
|
131
|
+
if (!existing) {
|
|
132
|
+
throw new MemberNotFoundError(`subscription '${input.subscriptionId}' was not found`);
|
|
133
|
+
}
|
|
134
|
+
if (!VALID_SUBSCRIPTION_STATUSES.includes(input.status)) {
|
|
135
|
+
throw new MemberValidationError(`'${input.status}' is not a valid subscription status`);
|
|
136
|
+
}
|
|
137
|
+
const nowIso = clockNowIso({ clock: deps.clock });
|
|
138
|
+
const subscription = {
|
|
139
|
+
...existing,
|
|
140
|
+
status: input.status,
|
|
141
|
+
externalRef: input.externalRef ?? existing.externalRef,
|
|
142
|
+
canceledAt: input.status === "canceled" ? nowIso : existing.canceledAt,
|
|
143
|
+
updatedAt: nowIso,
|
|
144
|
+
version: existing.version + 1,
|
|
145
|
+
};
|
|
146
|
+
await deps.subscriptions.save(subscription);
|
|
147
|
+
return { subscription };
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=member-admin-writes.js.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { MembersWriteServiceDeps } from "./ports.js";
|
|
2
|
+
/** One challenge request: the composed deps, the visitor's input and which challenge to issue. */
|
|
3
|
+
export type MemberChallengeRequest = {
|
|
4
|
+
deps: MembersWriteServiceDeps;
|
|
5
|
+
input: {
|
|
6
|
+
workspaceId: string;
|
|
7
|
+
email: string;
|
|
8
|
+
redirectPath?: string;
|
|
9
|
+
};
|
|
10
|
+
purpose: "signin" | "password_reset";
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Issue sign-in or link-only reset through the same mail/readiness and challenge lifecycle.
|
|
14
|
+
* Ineligible addresses receive a fresh, unstored handle; requests never create members.
|
|
15
|
+
* Preparation checks site setup; deliver() owns all per-address work.
|
|
16
|
+
* Secrets enter only the rendered send payload, never a profile, repo row or idempotency key.
|
|
17
|
+
* @throws MemberSignInUnavailableError for site-wide setup; validation/adapter errors propagate.
|
|
18
|
+
* @complexity O(1) reads/writes and one bounded password hash for sign-in codes.
|
|
19
|
+
*/
|
|
20
|
+
export declare function prepareMemberChallenge(required: MemberChallengeRequest, _options?: Record<string, never>): Promise<{
|
|
21
|
+
challengeId: string;
|
|
22
|
+
deliver: () => Promise<{
|
|
23
|
+
delivered: boolean;
|
|
24
|
+
challengeId: string;
|
|
25
|
+
}>;
|
|
26
|
+
}>;
|
|
27
|
+
/** Existing callers retain the awaited delivery contract; public HTTP uses the same prepared owner. */
|
|
28
|
+
export declare function requestMemberChallenge(required: MemberChallengeRequest, _options?: Record<string, never>): Promise<{
|
|
29
|
+
delivered: boolean;
|
|
30
|
+
challengeId: string;
|
|
31
|
+
}>;
|
|
32
|
+
/** Request a link and six-digit code sharing one single-use challenge; O(1) adapter calls. */
|
|
33
|
+
export declare function requestSignInLink(required: {
|
|
34
|
+
deps: MembersWriteServiceDeps;
|
|
35
|
+
input: {
|
|
36
|
+
workspaceId: string;
|
|
37
|
+
email: string;
|
|
38
|
+
redirectPath?: string;
|
|
39
|
+
};
|
|
40
|
+
}, _options?: Record<string, never>): Promise<{
|
|
41
|
+
delivered: boolean;
|
|
42
|
+
challengeId: string;
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* Request a link-only reset for an existing eligible member; never reveal per-address outcomes.
|
|
46
|
+
* Reuses the sign-in mail setup checks and interactive lane. No member is created.
|
|
47
|
+
* @throws MemberSignInUnavailableError for site-wide mail/origin setup errors.
|
|
48
|
+
* @complexity O(1) adapter calls.
|
|
49
|
+
*/
|
|
50
|
+
export declare function requestPasswordReset(required: {
|
|
51
|
+
deps: MembersWriteServiceDeps;
|
|
52
|
+
input: {
|
|
53
|
+
workspaceId: string;
|
|
54
|
+
email: string;
|
|
55
|
+
};
|
|
56
|
+
}, _options?: Record<string, never>): Promise<{
|
|
57
|
+
accepted: true;
|
|
58
|
+
}>;
|
|
59
|
+
//# sourceMappingURL=member-challenge-request.d.ts.map
|