@openlup/platform 0.15.0 → 0.17.0
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 +124 -0
- package/README.md +633 -6
- package/dist/communications/accountingDocumentDelivery.d.ts +35 -0
- package/dist/communications/accountingDocumentDelivery.js +33 -0
- package/dist/communications/authEmailError.d.ts +5 -0
- package/dist/communications/authEmailError.js +8 -0
- package/dist/communications/authEmailPorts.d.ts +2 -0
- package/dist/communications/authEmailPorts.js +1 -0
- package/dist/communications/authSendEmailHook.d.ts +35 -0
- package/dist/communications/authSendEmailHook.js +250 -0
- package/dist/communications/capturedTransactionalDelivery.d.ts +13 -0
- package/dist/communications/capturedTransactionalDelivery.js +14 -0
- package/dist/communications/communicationSync.d.ts +11 -0
- package/dist/communications/communicationSync.js +79 -0
- package/dist/communications/communicationSyncWorker.d.ts +68 -0
- package/dist/communications/communicationSyncWorker.js +218 -0
- package/dist/communications/consentPolicy.d.ts +19 -0
- package/dist/communications/consentPolicy.js +43 -0
- package/dist/communications/consentPurposeRegistry.d.ts +4 -0
- package/dist/communications/consentPurposeRegistry.js +24 -0
- package/dist/communications/contracts/abandonedCart.d.ts +27 -0
- package/dist/communications/contracts/abandonedCart.js +25 -0
- package/dist/communications/contracts/authEmail.d.ts +62 -0
- package/dist/communications/contracts/authEmail.js +1 -0
- package/dist/communications/contracts/backInStock.d.ts +28 -0
- package/dist/communications/contracts/backInStock.js +28 -0
- package/dist/communications/contracts/blocks.d.ts +24 -0
- package/dist/communications/contracts/blocks.js +23 -0
- package/dist/communications/contracts/checkoutExpired.d.ts +22 -0
- package/dist/communications/contracts/checkoutExpired.js +25 -0
- package/dist/communications/contracts/checkoutRecovery.d.ts +26 -0
- package/dist/communications/contracts/checkoutRecovery.js +37 -0
- package/dist/communications/contracts/commerceEmailContent.d.ts +176 -0
- package/dist/communications/contracts/commerceEmailContent.js +1 -0
- package/dist/communications/contracts/commerceEngagementEmailContent.d.ts +95 -0
- package/dist/communications/contracts/commerceEngagementEmailContent.js +1 -0
- package/dist/communications/contracts/consent.d.ts +12 -0
- package/dist/communications/contracts/consent.js +1 -0
- package/dist/communications/contracts/email.d.ts +182 -0
- package/dist/communications/contracts/email.js +1 -0
- package/dist/communications/contracts/guideCard.d.ts +3 -0
- package/dist/communications/contracts/guideCard.js +26 -0
- package/dist/communications/contracts/index.d.ts +51 -0
- package/dist/communications/contracts/index.js +42 -0
- package/dist/communications/contracts/inquiryContent.d.ts +32 -0
- package/dist/communications/contracts/inquiryContent.js +33 -0
- package/dist/communications/contracts/invoiceDocumentContent.d.ts +26 -0
- package/dist/communications/contracts/invoiceDocumentContent.js +36 -0
- package/dist/communications/contracts/marketingAutomation.d.ts +52 -0
- package/dist/communications/contracts/marketingAutomation.js +1 -0
- package/dist/communications/contracts/newsletter.d.ts +63 -0
- package/dist/communications/contracts/newsletter.js +1 -0
- package/dist/communications/contracts/newsletterWebhook.d.ts +26 -0
- package/dist/communications/contracts/newsletterWebhook.js +1 -0
- package/dist/communications/contracts/optOutContent.d.ts +11 -0
- package/dist/communications/contracts/optOutContent.js +17 -0
- package/dist/communications/contracts/orderCanceled.d.ts +25 -0
- package/dist/communications/contracts/orderCanceled.js +27 -0
- package/dist/communications/contracts/orderDraft.d.ts +46 -0
- package/dist/communications/contracts/orderDraft.js +46 -0
- package/dist/communications/contracts/orderPaid.d.ts +53 -0
- package/dist/communications/contracts/orderPaid.js +71 -0
- package/dist/communications/contracts/orderRefunded.d.ts +24 -0
- package/dist/communications/contracts/orderRefunded.js +27 -0
- package/dist/communications/contracts/paymentFailed.d.ts +24 -0
- package/dist/communications/contracts/paymentFailed.js +24 -0
- package/dist/communications/contracts/publicIntake.d.ts +49 -0
- package/dist/communications/contracts/publicIntake.js +1 -0
- package/dist/communications/contracts/render.d.ts +2 -0
- package/dist/communications/contracts/render.js +229 -0
- package/dist/communications/contracts/reorderReminder.d.ts +24 -0
- package/dist/communications/contracts/reorderReminder.js +24 -0
- package/dist/communications/contracts/returnEmails.d.ts +25 -0
- package/dist/communications/contracts/returnEmails.js +62 -0
- package/dist/communications/contracts/reviewEffects.d.ts +26 -0
- package/dist/communications/contracts/reviewEffects.js +25 -0
- package/dist/communications/contracts/reviewRequest.d.ts +26 -0
- package/dist/communications/contracts/reviewRequest.js +24 -0
- package/dist/communications/contracts/roleNotificationContent.d.ts +25 -0
- package/dist/communications/contracts/roleNotificationContent.js +46 -0
- package/dist/communications/contracts/shipmentDelivered.d.ts +23 -0
- package/dist/communications/contracts/shipmentDelivered.js +24 -0
- package/dist/communications/contracts/shipmentDispatched.d.ts +27 -0
- package/dist/communications/contracts/shipmentDispatched.js +35 -0
- package/dist/communications/contracts/shipmentException.d.ts +21 -0
- package/dist/communications/contracts/shipmentException.js +26 -0
- package/dist/communications/contracts/subscriptionActivationActionRequired.d.ts +17 -0
- package/dist/communications/contracts/subscriptionActivationActionRequired.js +22 -0
- package/dist/communications/contracts/subscriptionAddressChanged.d.ts +19 -0
- package/dist/communications/contracts/subscriptionAddressChanged.js +25 -0
- package/dist/communications/contracts/subscriptionCancelled.d.ts +19 -0
- package/dist/communications/contracts/subscriptionCancelled.js +25 -0
- package/dist/communications/contracts/subscriptionCycleSkipped.d.ts +25 -0
- package/dist/communications/contracts/subscriptionCycleSkipped.js +40 -0
- package/dist/communications/contracts/subscriptionDeliveryRescheduled.d.ts +25 -0
- package/dist/communications/contracts/subscriptionDeliveryRescheduled.js +39 -0
- package/dist/communications/contracts/subscriptionEmailContent.d.ts +145 -0
- package/dist/communications/contracts/subscriptionEmailContent.js +1 -0
- package/dist/communications/contracts/subscriptionPackageChanged.d.ts +20 -0
- package/dist/communications/contracts/subscriptionPackageChanged.js +26 -0
- package/dist/communications/contracts/subscriptionPauseReminder.d.ts +23 -0
- package/dist/communications/contracts/subscriptionPauseReminder.js +29 -0
- package/dist/communications/contracts/subscriptionPaused.d.ts +21 -0
- package/dist/communications/contracts/subscriptionPaused.js +25 -0
- package/dist/communications/contracts/subscriptionPaymentExpired.d.ts +34 -0
- package/dist/communications/contracts/subscriptionPaymentExpired.js +37 -0
- package/dist/communications/contracts/subscriptionPaymentFailed.d.ts +49 -0
- package/dist/communications/contracts/subscriptionPaymentFailed.js +56 -0
- package/dist/communications/contracts/subscriptionPaymentRecovered.d.ts +19 -0
- package/dist/communications/contracts/subscriptionPaymentRecovered.js +22 -0
- package/dist/communications/contracts/subscriptionRenewalAtRisk.d.ts +36 -0
- package/dist/communications/contracts/subscriptionRenewalAtRisk.js +36 -0
- package/dist/communications/contracts/subscriptionRenewalUpcoming.d.ts +49 -0
- package/dist/communications/contracts/subscriptionRenewalUpcoming.js +43 -0
- package/dist/communications/contracts/subscriptionResumed.d.ts +23 -0
- package/dist/communications/contracts/subscriptionResumed.js +25 -0
- package/dist/communications/contracts/subscriptionWelcome.d.ts +44 -0
- package/dist/communications/contracts/subscriptionWelcome.js +45 -0
- package/dist/communications/contracts/subscriptionWinback.d.ts +21 -0
- package/dist/communications/contracts/subscriptionWinback.js +28 -0
- package/dist/communications/contracts/transactionalDelivery.d.ts +42 -0
- package/dist/communications/contracts/transactionalDelivery.js +1 -0
- package/dist/communications/contracts/types.d.ts +46 -0
- package/dist/communications/contracts/types.js +1 -0
- package/dist/communications/contribution.d.ts +10 -0
- package/dist/communications/contribution.js +24 -0
- package/dist/communications/deliveryReconciliation.d.ts +64 -0
- package/dist/communications/deliveryReconciliation.js +60 -0
- package/dist/communications/emailEgress.d.ts +38 -0
- package/dist/communications/emailEgress.js +100 -0
- package/dist/communications/emailHealthAssessment.d.ts +39 -0
- package/dist/communications/emailHealthAssessment.js +59 -0
- package/dist/communications/emailHealthMetricsPort.d.ts +17 -0
- package/dist/communications/emailHealthMetricsPort.js +1 -0
- package/dist/communications/emailNotificationControl.d.ts +27 -0
- package/dist/communications/emailNotificationControl.js +10 -0
- package/dist/communications/emailObservation.d.ts +28 -0
- package/dist/communications/emailObservation.js +23 -0
- package/dist/communications/emailTransport.d.ts +82 -0
- package/dist/communications/emailTransport.js +95 -0
- package/dist/communications/errors.d.ts +15 -0
- package/dist/communications/errors.js +30 -0
- package/dist/communications/index.d.ts +46 -0
- package/dist/communications/index.js +38 -0
- package/dist/communications/integrationEventSignature.d.ts +15 -0
- package/dist/communications/integrationEventSignature.js +37 -0
- package/dist/communications/managedTransactionalDeliveryStore.d.ts +12 -0
- package/dist/communications/managedTransactionalDeliveryStore.js +49 -0
- package/dist/communications/nativeOperations.d.ts +79 -0
- package/dist/communications/nativeOperations.js +3 -0
- package/dist/communications/newsletterIntegrationContracts.d.ts +130 -0
- package/dist/communications/newsletterIntegrationContracts.js +128 -0
- package/dist/communications/newsletterWebhookPort.d.ts +11 -0
- package/dist/communications/newsletterWebhookPort.js +84 -0
- package/dist/communications/newsletterWebhookProcessing.d.ts +17 -0
- package/dist/communications/newsletterWebhookProcessing.js +71 -0
- package/dist/communications/originPolicy.d.ts +40 -0
- package/dist/communications/originPolicy.js +100 -0
- package/dist/communications/postgresCommunicationSync.d.ts +79 -0
- package/dist/communications/postgresCommunicationSync.js +111 -0
- package/dist/communications/postgresConsentEvaluator.d.ts +19 -0
- package/dist/communications/postgresConsentEvaluator.js +43 -0
- package/dist/communications/postgresDeliveryReconciliation.d.ts +3 -0
- package/dist/communications/postgresDeliveryReconciliation.js +113 -0
- package/dist/communications/postgresNativeOperations.d.ts +13 -0
- package/dist/communications/postgresNativeOperations.js +63 -0
- package/dist/communications/postgresNotificationRecipients.d.ts +37 -0
- package/dist/communications/postgresNotificationRecipients.js +60 -0
- package/dist/communications/postgresTransactionalDeliveryStore.d.ts +7 -0
- package/dist/communications/postgresTransactionalDeliveryStore.js +55 -0
- package/dist/communications/preferencesToken.d.ts +10 -0
- package/dist/communications/preferencesToken.js +40 -0
- package/dist/communications/publicPreferenceToken.d.ts +24 -0
- package/dist/communications/publicPreferenceToken.js +53 -0
- package/dist/communications/shipmentNotifications.d.ts +34 -0
- package/dist/communications/shipmentNotifications.js +61 -0
- package/dist/communications/sql.d.ts +26 -0
- package/dist/communications/sql.js +7 -0
- package/dist/communications/standardWebhooks.d.ts +14 -0
- package/dist/communications/standardWebhooks.js +73 -0
- package/dist/communications/status.d.ts +11 -0
- package/dist/communications/status.js +36 -0
- package/dist/communications/transactionalDelivery.d.ts +19 -0
- package/dist/communications/transactionalDelivery.js +96 -0
- package/dist/communications/transactionalDeliveryIdentifier.d.ts +3 -0
- package/dist/communications/transactionalDeliveryIdentifier.js +6 -0
- package/dist/communications/unsubscribeToken.d.ts +77 -0
- package/dist/communications/unsubscribeToken.js +150 -0
- package/dist/communications/validation.d.ts +2 -0
- package/dist/communications/validation.js +3 -0
- package/dist/http/index.d.ts +1 -0
- package/dist/http/index.js +1 -0
- package/dist/http/webhookSignature.d.ts +42 -0
- package/dist/http/webhookSignature.js +86 -0
- package/dist/identity/adminAuthBinding.d.ts +28 -0
- package/dist/identity/adminAuthBinding.js +66 -0
- package/dist/identity/adminAuthorization.d.ts +34 -0
- package/dist/identity/adminAuthorization.js +72 -0
- package/dist/identity/adminContracts.d.ts +70 -0
- package/dist/identity/adminContracts.js +43 -0
- package/dist/identity/adminMagicLinkHandler.d.ts +39 -0
- package/dist/identity/adminMagicLinkHandler.js +94 -0
- package/dist/identity/adminMeHandler.d.ts +15 -0
- package/dist/identity/adminMeHandler.js +49 -0
- package/dist/identity/adminPreflight.d.ts +16 -0
- package/dist/identity/adminPreflight.js +38 -0
- package/dist/identity/adminUserActionPorts.d.ts +31 -0
- package/dist/identity/adminUserActionPorts.js +51 -0
- package/dist/identity/adminUserHandlers.d.ts +38 -0
- package/dist/identity/adminUserHandlers.js +140 -0
- package/dist/identity/authVerifyUrl.d.ts +6 -0
- package/dist/identity/authVerifyUrl.js +54 -0
- package/dist/identity/contracts/contracts.d.ts +8 -0
- package/dist/identity/contracts/contracts.js +2 -0
- package/dist/identity/contracts/emailTrust.d.ts +3 -0
- package/dist/identity/contracts/emailTrust.js +4 -0
- package/dist/identity/contracts/index.d.ts +8 -0
- package/dist/identity/contracts/index.js +8 -0
- package/dist/identity/contracts/oidc.d.ts +3 -0
- package/dist/identity/contracts/oidc.js +9 -0
- package/dist/identity/contracts/operatorAuth.d.ts +35 -0
- package/dist/identity/contracts/operatorAuth.js +53 -0
- package/dist/identity/contracts/operatorInvitations.d.ts +37 -0
- package/dist/identity/contracts/operatorInvitations.js +1 -0
- package/dist/identity/contracts/ports.d.ts +22 -0
- package/dist/identity/contracts/ports.js +1 -0
- package/dist/identity/contracts/privacy.d.ts +62 -0
- package/dist/identity/contracts/privacy.js +99 -0
- package/dist/identity/contracts/providerList.d.ts +3 -0
- package/dist/identity/contracts/providerList.js +11 -0
- package/dist/identity/contracts/types.d.ts +16 -0
- package/dist/identity/contracts/types.js +4 -0
- package/dist/identity/contribution.d.ts +8 -0
- package/dist/identity/contribution.js +22 -0
- package/dist/identity/customerAuth.d.ts +8 -0
- package/dist/identity/customerAuth.js +1 -0
- package/dist/identity/customerAuthorization.d.ts +5 -0
- package/dist/identity/customerAuthorization.js +22 -0
- package/dist/identity/customerContracts.d.ts +42 -0
- package/dist/identity/customerContracts.js +43 -0
- package/dist/identity/customerIdentityBinding.d.ts +44 -0
- package/dist/identity/customerIdentityBinding.js +60 -0
- package/dist/identity/customerIdentityVerifier.d.ts +8 -0
- package/dist/identity/customerIdentityVerifier.js +101 -0
- package/dist/identity/customerMagicLinkHandler.d.ts +38 -0
- package/dist/identity/customerMagicLinkHandler.js +115 -0
- package/dist/identity/customerMeHandler.d.ts +11 -0
- package/dist/identity/customerMeHandler.js +46 -0
- package/dist/identity/customerPorts.d.ts +4 -0
- package/dist/identity/customerPorts.js +1 -0
- package/dist/identity/customerSessionBinding.d.ts +38 -0
- package/dist/identity/customerSessionBinding.js +80 -0
- package/dist/identity/customerSessionIssuer.d.ts +10 -0
- package/dist/identity/customerSessionIssuer.js +57 -0
- package/dist/identity/customerVerifyOtpHandler.d.ts +8 -0
- package/dist/identity/customerVerifyOtpHandler.js +41 -0
- package/dist/identity/directOperatorInvitationStore.d.ts +19 -0
- package/dist/identity/directOperatorInvitationStore.js +193 -0
- package/dist/identity/emailTrustPolicy.d.ts +14 -0
- package/dist/identity/emailTrustPolicy.js +16 -0
- package/dist/identity/identityPersonalDataContributor.d.ts +7 -0
- package/dist/identity/identityPersonalDataContributor.js +46 -0
- package/dist/identity/identityReadiness.d.ts +10 -0
- package/dist/identity/identityReadiness.js +25 -0
- package/dist/identity/index.d.ts +67 -0
- package/dist/identity/index.js +66 -0
- package/dist/identity/inviteAdminUserUseCase.d.ts +89 -0
- package/dist/identity/inviteAdminUserUseCase.js +75 -0
- package/dist/identity/jwtLibrary.d.ts +54 -0
- package/dist/identity/jwtLibrary.js +1 -0
- package/dist/identity/machineActorWriteFence.d.ts +4 -0
- package/dist/identity/machineActorWriteFence.js +13 -0
- package/dist/identity/magicLinkPorts.d.ts +28 -0
- package/dist/identity/magicLinkPorts.js +1 -0
- package/dist/identity/managedAccountLinkStore.d.ts +2 -0
- package/dist/identity/managedAccountLinkStore.js +93 -0
- package/dist/identity/managedAdminAuthVerifier.d.ts +7 -0
- package/dist/identity/managedAdminAuthVerifier.js +27 -0
- package/dist/identity/managedAdminUserGateways.d.ts +123 -0
- package/dist/identity/managedAdminUserGateways.js +127 -0
- package/dist/identity/managedClient.d.ts +90 -0
- package/dist/identity/managedClient.js +10 -0
- package/dist/identity/managedClientAuthLink.d.ts +3 -0
- package/dist/identity/managedClientAuthLink.js +115 -0
- package/dist/identity/managedCustomerMe.d.ts +13 -0
- package/dist/identity/managedCustomerMe.js +30 -0
- package/dist/identity/managedEmailTrustPolicy.d.ts +11 -0
- package/dist/identity/managedEmailTrustPolicy.js +105 -0
- package/dist/identity/managedIdentityVerifier.d.ts +2 -0
- package/dist/identity/managedIdentityVerifier.js +16 -0
- package/dist/identity/managedPrivacy.d.ts +4 -0
- package/dist/identity/managedPrivacy.js +39 -0
- package/dist/identity/messages.d.ts +29 -0
- package/dist/identity/messages.js +39 -0
- package/dist/identity/oidcIdentityVerifier.d.ts +45 -0
- package/dist/identity/oidcIdentityVerifier.js +309 -0
- package/dist/identity/oidcPrincipal.d.ts +2 -0
- package/dist/identity/oidcPrincipal.js +10 -0
- package/dist/identity/operatorAdminAuth.d.ts +6 -0
- package/dist/identity/operatorAdminAuth.js +13 -0
- package/dist/identity/operatorAuthHandlers.d.ts +18 -0
- package/dist/identity/operatorAuthHandlers.js +71 -0
- package/dist/identity/operatorIdentityVerifier.d.ts +8 -0
- package/dist/identity/operatorIdentityVerifier.js +19 -0
- package/dist/identity/operatorInvitationLifecycle.d.ts +7 -0
- package/dist/identity/operatorInvitationLifecycle.js +15 -0
- package/dist/identity/operatorInvitationPorts.d.ts +31 -0
- package/dist/identity/operatorInvitationPorts.js +1 -0
- package/dist/identity/operatorPorts.d.ts +37 -0
- package/dist/identity/operatorPorts.js +1 -0
- package/dist/identity/operatorSession.d.ts +13 -0
- package/dist/identity/operatorSession.js +31 -0
- package/dist/identity/operatorTokenAdminAuth.d.ts +15 -0
- package/dist/identity/operatorTokenAdminAuth.js +50 -0
- package/dist/identity/personalDataRegistry.d.ts +4 -0
- package/dist/identity/personalDataRegistry.js +11 -0
- package/dist/identity/platformAdminAuth.d.ts +15 -0
- package/dist/identity/platformAdminAuth.js +1 -0
- package/dist/identity/ports.d.ts +127 -0
- package/dist/identity/ports.js +38 -0
- package/dist/identity/postgresAccountLinkStore.d.ts +7 -0
- package/dist/identity/postgresAccountLinkStore.js +52 -0
- package/dist/identity/postgresCustomerMe.d.ts +3 -0
- package/dist/identity/postgresCustomerMe.js +21 -0
- package/dist/identity/postgresCustomerRecovery.d.ts +11 -0
- package/dist/identity/postgresCustomerRecovery.js +57 -0
- package/dist/identity/postgresOperatorIdentity.d.ts +5 -0
- package/dist/identity/postgresOperatorIdentity.js +137 -0
- package/dist/identity/postgresPrivacy.d.ts +7 -0
- package/dist/identity/postgresPrivacy.js +126 -0
- package/dist/identity/privacyHandlers.d.ts +10 -0
- package/dist/identity/privacyHandlers.js +35 -0
- package/dist/identity/privacyPorts.d.ts +72 -0
- package/dist/identity/privacyPorts.js +8 -0
- package/dist/identity/privacyUseCases.d.ts +5 -0
- package/dist/identity/privacyUseCases.js +55 -0
- package/dist/identity/reconcileAccountForPrincipal.d.ts +20 -0
- package/dist/identity/reconcileAccountForPrincipal.js +66 -0
- package/dist/identity/reconcileAccountHandler.d.ts +11 -0
- package/dist/identity/reconcileAccountHandler.js +30 -0
- package/dist/identity/removeAdminUserUseCase.d.ts +31 -0
- package/dist/identity/removeAdminUserUseCase.js +60 -0
- package/dist/identity/response.d.ts +3 -0
- package/dist/identity/response.js +2 -0
- package/dist/identity/sql.d.ts +44 -0
- package/dist/identity/sql.js +10 -0
- package/package.json +22 -2
- package/release-gates.json +63 -8
- package/sql/20260807190000_comms_outbox_rail.sql +329 -0
- package/sql/20260810120001_transactional_delivery_receipts.sql +209 -0
- package/sql/20260810180001_self_host_actor_auth.sql +40 -0
- package/sql/20260810204057_customer_identity_read.sql +31 -0
- package/sql/20260813120000_communications_control_plane.sql +568 -0
- package/sql/20260814090000_customer_selfservice_recovery.sql +477 -0
- package/sql/20260901143000_admin_membership_authority_foundation.sql +234 -0
- package/sql/20261018120000_identity_operator_invitations.sql +42 -0
- package/sql/20261018180000_identity_operator_challenges.sql +56 -0
- package/sql/20261018190000_identity_privacy_erasures.sql +15 -0
- package/sql/20261019200000_communications_native_operations.sql +68 -0
- package/src/communications/accountingDocumentDelivery.ts +63 -0
- package/src/communications/authEmailError.ts +10 -0
- package/src/communications/authEmailPorts.ts +2 -0
- package/src/communications/authSendEmailHook.ts +310 -0
- package/src/communications/capturedTransactionalDelivery.ts +29 -0
- package/src/communications/communicationSync.ts +96 -0
- package/src/communications/communicationSyncWorker.ts +302 -0
- package/src/communications/consentPolicy.ts +82 -0
- package/src/communications/consentPurposeRegistry.ts +31 -0
- package/src/communications/contracts/abandonedCart.ts +64 -0
- package/src/communications/contracts/authEmail.ts +73 -0
- package/src/communications/contracts/backInStock.ts +69 -0
- package/src/communications/contracts/blocks.ts +47 -0
- package/src/communications/contracts/checkoutExpired.ts +62 -0
- package/src/communications/contracts/checkoutRecovery.ts +68 -0
- package/src/communications/contracts/commerceEmailContent.ts +189 -0
- package/src/communications/contracts/commerceEngagementEmailContent.ts +106 -0
- package/src/communications/contracts/consent.ts +13 -0
- package/src/communications/contracts/email.ts +210 -0
- package/src/communications/contracts/guideCard.ts +34 -0
- package/src/communications/contracts/index.ts +51 -0
- package/src/communications/contracts/inquiryContent.ts +53 -0
- package/src/communications/contracts/invoiceDocumentContent.ts +57 -0
- package/src/communications/contracts/marketingAutomation.ts +45 -0
- package/src/communications/contracts/newsletter.ts +78 -0
- package/src/communications/contracts/newsletterWebhook.ts +23 -0
- package/src/communications/contracts/optOutContent.ts +23 -0
- package/src/communications/contracts/orderCanceled.ts +64 -0
- package/src/communications/contracts/orderDraft.ts +112 -0
- package/src/communications/contracts/orderPaid.ts +147 -0
- package/src/communications/contracts/orderRefunded.ts +63 -0
- package/src/communications/contracts/paymentFailed.ts +59 -0
- package/src/communications/contracts/publicIntake.ts +53 -0
- package/src/communications/contracts/render.ts +271 -0
- package/src/communications/contracts/reorderReminder.ts +59 -0
- package/src/communications/contracts/returnEmails.ts +113 -0
- package/src/communications/contracts/reviewEffects.ts +60 -0
- package/src/communications/contracts/reviewRequest.ts +59 -0
- package/src/communications/contracts/roleNotificationContent.ts +65 -0
- package/src/communications/contracts/shipmentDelivered.ts +59 -0
- package/src/communications/contracts/shipmentDispatched.ts +77 -0
- package/src/communications/contracts/shipmentException.ts +62 -0
- package/src/communications/contracts/subscriptionActivationActionRequired.ts +37 -0
- package/src/communications/contracts/subscriptionAddressChanged.ts +56 -0
- package/src/communications/contracts/subscriptionCancelled.ts +57 -0
- package/src/communications/contracts/subscriptionCycleSkipped.ts +80 -0
- package/src/communications/contracts/subscriptionDeliveryRescheduled.ts +79 -0
- package/src/communications/contracts/subscriptionEmailContent.ts +163 -0
- package/src/communications/contracts/subscriptionPackageChanged.ts +59 -0
- package/src/communications/contracts/subscriptionPauseReminder.ts +63 -0
- package/src/communications/contracts/subscriptionPaused.ts +58 -0
- package/src/communications/contracts/subscriptionPaymentExpired.ts +83 -0
- package/src/communications/contracts/subscriptionPaymentFailed.ts +117 -0
- package/src/communications/contracts/subscriptionPaymentRecovered.ts +50 -0
- package/src/communications/contracts/subscriptionRenewalAtRisk.ts +85 -0
- package/src/communications/contracts/subscriptionRenewalUpcoming.ts +103 -0
- package/src/communications/contracts/subscriptionResumed.ts +60 -0
- package/src/communications/contracts/subscriptionWelcome.ts +102 -0
- package/src/communications/contracts/subscriptionWinback.ts +62 -0
- package/src/communications/contracts/transactionalDelivery.ts +43 -0
- package/src/communications/contracts/types.ts +58 -0
- package/src/communications/contribution.ts +33 -0
- package/src/communications/deliveryReconciliation.ts +108 -0
- package/src/communications/emailEgress.ts +111 -0
- package/src/communications/emailHealthAssessment.ts +106 -0
- package/src/communications/emailHealthMetricsPort.ts +17 -0
- package/src/communications/emailNotificationControl.ts +28 -0
- package/src/communications/emailObservation.ts +43 -0
- package/src/communications/emailTransport.ts +167 -0
- package/src/communications/errors.ts +34 -0
- package/src/communications/index.ts +46 -0
- package/src/communications/integrationEventSignature.ts +49 -0
- package/src/communications/managedTransactionalDeliveryStore.ts +59 -0
- package/src/communications/nativeOperations.ts +40 -0
- package/src/communications/newsletterIntegrationContracts.ts +154 -0
- package/src/communications/newsletterWebhookPort.ts +104 -0
- package/src/communications/newsletterWebhookProcessing.ts +102 -0
- package/src/communications/originPolicy.ts +151 -0
- package/src/communications/postgresCommunicationSync.ts +127 -0
- package/src/communications/postgresConsentEvaluator.ts +49 -0
- package/src/communications/postgresDeliveryReconciliation.ts +101 -0
- package/src/communications/postgresNativeOperations.ts +55 -0
- package/src/communications/postgresNotificationRecipients.ts +57 -0
- package/src/communications/postgresTransactionalDeliveryStore.ts +79 -0
- package/src/communications/preferencesToken.ts +62 -0
- package/src/communications/publicPreferenceToken.ts +68 -0
- package/src/communications/shipmentNotifications.ts +78 -0
- package/src/communications/sql.ts +7 -0
- package/src/communications/standardWebhooks.ts +84 -0
- package/src/communications/status.ts +51 -0
- package/src/communications/transactionalDelivery.ts +114 -0
- package/src/communications/transactionalDeliveryIdentifier.ts +9 -0
- package/src/communications/unsubscribeToken.ts +186 -0
- package/src/communications/validation.ts +3 -0
- package/src/http/index.ts +1 -0
- package/src/http/webhookSignature.ts +96 -0
- package/src/identity/adminAuthBinding.ts +76 -0
- package/src/identity/adminAuthorization.ts +106 -0
- package/src/identity/adminContracts.ts +52 -0
- package/src/identity/adminMagicLinkHandler.ts +132 -0
- package/src/identity/adminMeHandler.ts +64 -0
- package/src/identity/adminPreflight.ts +46 -0
- package/src/identity/adminUserActionPorts.ts +78 -0
- package/src/identity/adminUserHandlers.ts +174 -0
- package/src/identity/authVerifyUrl.ts +56 -0
- package/src/identity/contracts/contracts.ts +15 -0
- package/src/identity/contracts/emailTrust.ts +5 -0
- package/src/identity/contracts/index.ts +8 -0
- package/src/identity/contracts/oidc.ts +10 -0
- package/src/identity/contracts/operatorAuth.ts +61 -0
- package/src/identity/contracts/operatorInvitations.ts +32 -0
- package/src/identity/contracts/ports.ts +25 -0
- package/src/identity/contracts/privacy.ts +86 -0
- package/src/identity/contracts/providerList.ts +13 -0
- package/src/identity/contracts/types.ts +25 -0
- package/src/identity/contribution.ts +29 -0
- package/src/identity/customerAuth.ts +3 -0
- package/src/identity/customerAuthorization.ts +38 -0
- package/src/identity/customerContracts.ts +52 -0
- package/src/identity/customerIdentityBinding.ts +125 -0
- package/src/identity/customerIdentityVerifier.ts +141 -0
- package/src/identity/customerMagicLinkHandler.ts +171 -0
- package/src/identity/customerMeHandler.ts +64 -0
- package/src/identity/customerPorts.ts +2 -0
- package/src/identity/customerSessionBinding.ts +114 -0
- package/src/identity/customerSessionIssuer.ts +71 -0
- package/src/identity/customerVerifyOtpHandler.ts +44 -0
- package/src/identity/directOperatorInvitationStore.ts +178 -0
- package/src/identity/emailTrustPolicy.ts +16 -0
- package/src/identity/identityPersonalDataContributor.ts +48 -0
- package/src/identity/identityReadiness.ts +26 -0
- package/src/identity/index.ts +69 -0
- package/src/identity/inviteAdminUserUseCase.ts +134 -0
- package/src/identity/jwtLibrary.ts +24 -0
- package/src/identity/machineActorWriteFence.ts +19 -0
- package/src/identity/magicLinkPorts.ts +7 -0
- package/src/identity/managedAccountLinkStore.ts +105 -0
- package/src/identity/managedAdminAuthVerifier.ts +40 -0
- package/src/identity/managedAdminUserGateways.ts +164 -0
- package/src/identity/managedClient.ts +58 -0
- package/src/identity/managedClientAuthLink.ts +120 -0
- package/src/identity/managedCustomerMe.ts +52 -0
- package/src/identity/managedEmailTrustPolicy.ts +90 -0
- package/src/identity/managedIdentityVerifier.ts +20 -0
- package/src/identity/managedPrivacy.ts +37 -0
- package/src/identity/messages.ts +41 -0
- package/src/identity/oidcIdentityVerifier.ts +229 -0
- package/src/identity/oidcPrincipal.ts +10 -0
- package/src/identity/operatorAdminAuth.ts +14 -0
- package/src/identity/operatorAuthHandlers.ts +52 -0
- package/src/identity/operatorIdentityVerifier.ts +19 -0
- package/src/identity/operatorInvitationLifecycle.ts +14 -0
- package/src/identity/operatorInvitationPorts.ts +11 -0
- package/src/identity/operatorPorts.ts +11 -0
- package/src/identity/operatorSession.ts +30 -0
- package/src/identity/operatorTokenAdminAuth.ts +79 -0
- package/src/identity/personalDataRegistry.ts +8 -0
- package/src/identity/platformAdminAuth.ts +7 -0
- package/src/identity/ports.ts +158 -0
- package/src/identity/postgresAccountLinkStore.ts +49 -0
- package/src/identity/postgresCustomerMe.ts +33 -0
- package/src/identity/postgresCustomerRecovery.ts +72 -0
- package/src/identity/postgresOperatorIdentity.ts +123 -0
- package/src/identity/postgresPrivacy.ts +117 -0
- package/src/identity/privacyHandlers.ts +33 -0
- package/src/identity/privacyPorts.ts +52 -0
- package/src/identity/privacyUseCases.ts +48 -0
- package/src/identity/reconcileAccountForPrincipal.ts +99 -0
- package/src/identity/reconcileAccountHandler.ts +36 -0
- package/src/identity/removeAdminUserUseCase.ts +85 -0
- package/src/identity/response.ts +3 -0
- package/src/identity/sql.ts +10 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
-- Dormant direct human membership authority.
|
|
2
|
+
--
|
|
3
|
+
-- This forward introduces a provider-neutral human principal and its separate
|
|
4
|
+
-- current-panel membership for the direct bundle. It mirrors the managed role,
|
|
5
|
+
-- active/revoked state, provenance, acceptance, revocation, retained identity,
|
|
6
|
+
-- last-human-administrator refusal, and one-row revoke audit semantics. It does
|
|
7
|
+
-- not verify a login, grant browser access, seed a person, or link to the
|
|
8
|
+
-- existing platform_control_operators machine authority. The direct host owns
|
|
9
|
+
-- activation of a future human-login adapter; until then these relations are
|
|
10
|
+
-- deliberately dormant and default-deny for the actor roles.
|
|
11
|
+
|
|
12
|
+
CREATE TABLE public.platform_human_principals (
|
|
13
|
+
principal_id uuid PRIMARY KEY,
|
|
14
|
+
email text NOT NULL UNIQUE,
|
|
15
|
+
created_at timestamptz NOT NULL DEFAULT now()
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
CREATE TABLE public.platform_human_memberships (
|
|
19
|
+
principal_id uuid PRIMARY KEY REFERENCES public.platform_human_principals(principal_id) ON DELETE RESTRICT,
|
|
20
|
+
role text NOT NULL CHECK (role IN ('admin', 'distributor')),
|
|
21
|
+
membership_state text NOT NULL CHECK (membership_state IN ('active', 'revoked')),
|
|
22
|
+
membership_provenance text NOT NULL CHECK (membership_provenance IN ('legacy', 'invitation')),
|
|
23
|
+
membership_accepted_at timestamptz NOT NULL,
|
|
24
|
+
membership_revoked_at timestamptz,
|
|
25
|
+
membership_revoked_by uuid REFERENCES public.platform_human_principals(principal_id) ON DELETE RESTRICT,
|
|
26
|
+
membership_revocation_reason text,
|
|
27
|
+
CONSTRAINT platform_human_memberships_lifecycle_check CHECK (
|
|
28
|
+
(membership_state = 'active'
|
|
29
|
+
AND membership_revoked_at IS NULL
|
|
30
|
+
AND membership_revoked_by IS NULL
|
|
31
|
+
AND membership_revocation_reason IS NULL)
|
|
32
|
+
OR
|
|
33
|
+
(membership_state = 'revoked'
|
|
34
|
+
AND membership_revoked_at IS NOT NULL
|
|
35
|
+
AND membership_revoked_by IS NOT NULL)
|
|
36
|
+
),
|
|
37
|
+
CONSTRAINT platform_human_memberships_distinct_revoker_check
|
|
38
|
+
CHECK (membership_revoked_by IS NULL OR membership_revoked_by <> principal_id),
|
|
39
|
+
CONSTRAINT platform_human_memberships_reason_length_check
|
|
40
|
+
CHECK (membership_revocation_reason IS NULL OR char_length(membership_revocation_reason) <= 1000)
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
CREATE TABLE public.platform_human_membership_audit_events (
|
|
44
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
45
|
+
actor_principal_id uuid NOT NULL REFERENCES public.platform_human_principals(principal_id) ON DELETE RESTRICT,
|
|
46
|
+
target_principal_id uuid NOT NULL REFERENCES public.platform_human_principals(principal_id) ON DELETE RESTRICT,
|
|
47
|
+
action text NOT NULL CHECK (action = 'revoke'),
|
|
48
|
+
old_value jsonb NOT NULL,
|
|
49
|
+
new_value jsonb NOT NULL,
|
|
50
|
+
reason text,
|
|
51
|
+
occurred_at timestamptz NOT NULL DEFAULT now()
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
CREATE INDEX platform_human_membership_audit_target_idx
|
|
55
|
+
ON public.platform_human_membership_audit_events(target_principal_id, occurred_at DESC);
|
|
56
|
+
|
|
57
|
+
REVOKE ALL ON TABLE
|
|
58
|
+
public.platform_human_principals,
|
|
59
|
+
public.platform_human_memberships,
|
|
60
|
+
public.platform_human_membership_audit_events
|
|
61
|
+
FROM PUBLIC, anon, authenticated;
|
|
62
|
+
|
|
63
|
+
CREATE FUNCTION public.platform_human_membership_is_active(p_principal_id uuid)
|
|
64
|
+
RETURNS boolean
|
|
65
|
+
LANGUAGE sql
|
|
66
|
+
STABLE
|
|
67
|
+
SET search_path = pg_catalog
|
|
68
|
+
AS $$
|
|
69
|
+
SELECT EXISTS (
|
|
70
|
+
SELECT 1
|
|
71
|
+
FROM public.platform_human_memberships AS membership_row
|
|
72
|
+
WHERE membership_row.principal_id = p_principal_id
|
|
73
|
+
AND membership_row.membership_state = 'active'
|
|
74
|
+
);
|
|
75
|
+
$$;
|
|
76
|
+
|
|
77
|
+
CREATE FUNCTION public.platform_human_membership_is_administrator(p_principal_id uuid)
|
|
78
|
+
RETURNS boolean
|
|
79
|
+
LANGUAGE sql
|
|
80
|
+
STABLE
|
|
81
|
+
SET search_path = pg_catalog
|
|
82
|
+
AS $$
|
|
83
|
+
SELECT EXISTS (
|
|
84
|
+
SELECT 1
|
|
85
|
+
FROM public.platform_human_memberships AS membership_row
|
|
86
|
+
WHERE membership_row.principal_id = p_principal_id
|
|
87
|
+
AND membership_row.membership_state = 'active'
|
|
88
|
+
AND membership_row.role = 'admin'
|
|
89
|
+
);
|
|
90
|
+
$$;
|
|
91
|
+
|
|
92
|
+
CREATE FUNCTION public.platform_human_memberships_guard()
|
|
93
|
+
RETURNS trigger
|
|
94
|
+
LANGUAGE plpgsql
|
|
95
|
+
SET search_path = pg_catalog, public
|
|
96
|
+
AS $$
|
|
97
|
+
DECLARE
|
|
98
|
+
v_removes_active_human_admin boolean := false;
|
|
99
|
+
v_other_active_human_admins integer;
|
|
100
|
+
BEGIN
|
|
101
|
+
IF TG_OP = 'DELETE' THEN
|
|
102
|
+
v_removes_active_human_admin := OLD.membership_state = 'active' AND OLD.role = 'admin';
|
|
103
|
+
ELSE
|
|
104
|
+
IF (OLD.membership_state, OLD.membership_provenance, OLD.membership_accepted_at,
|
|
105
|
+
OLD.membership_revoked_at, OLD.membership_revoked_by,
|
|
106
|
+
OLD.membership_revocation_reason)
|
|
107
|
+
IS DISTINCT FROM
|
|
108
|
+
(NEW.membership_state, NEW.membership_provenance, NEW.membership_accepted_at,
|
|
109
|
+
NEW.membership_revoked_at, NEW.membership_revoked_by,
|
|
110
|
+
NEW.membership_revocation_reason)
|
|
111
|
+
AND current_setting('app.platform_human_membership_revoke', true) IS DISTINCT FROM 'true' THEN
|
|
112
|
+
RAISE EXCEPTION 'platform_human_membership_lifecycle_update_forbidden' USING ERRCODE = '42501';
|
|
113
|
+
END IF;
|
|
114
|
+
|
|
115
|
+
IF OLD.membership_state <> 'active' AND NEW.role IS DISTINCT FROM OLD.role THEN
|
|
116
|
+
RAISE EXCEPTION 'platform_human_target_membership_inactive' USING ERRCODE = 'P0001';
|
|
117
|
+
END IF;
|
|
118
|
+
|
|
119
|
+
v_removes_active_human_admin := OLD.membership_state = 'active'
|
|
120
|
+
AND OLD.role = 'admin'
|
|
121
|
+
AND (NEW.membership_state <> 'active' OR NEW.role <> 'admin');
|
|
122
|
+
END IF;
|
|
123
|
+
|
|
124
|
+
IF v_removes_active_human_admin THEN
|
|
125
|
+
PERFORM pg_advisory_xact_lock(hashtext('platform_human_memberships_active_admin')::bigint);
|
|
126
|
+
SELECT count(*)
|
|
127
|
+
INTO v_other_active_human_admins
|
|
128
|
+
FROM public.platform_human_memberships
|
|
129
|
+
WHERE principal_id <> OLD.principal_id
|
|
130
|
+
AND membership_state = 'active'
|
|
131
|
+
AND role = 'admin';
|
|
132
|
+
|
|
133
|
+
IF v_other_active_human_admins < 1 THEN
|
|
134
|
+
RAISE EXCEPTION 'platform_human_last_admin_lockout' USING ERRCODE = 'P0001';
|
|
135
|
+
END IF;
|
|
136
|
+
END IF;
|
|
137
|
+
|
|
138
|
+
IF TG_OP = 'DELETE' THEN
|
|
139
|
+
RAISE EXCEPTION 'platform_human_membership_delete_forbidden' USING ERRCODE = '42501';
|
|
140
|
+
END IF;
|
|
141
|
+
|
|
142
|
+
RETURN NEW;
|
|
143
|
+
END;
|
|
144
|
+
$$;
|
|
145
|
+
|
|
146
|
+
CREATE TRIGGER trg_platform_human_memberships_guard
|
|
147
|
+
BEFORE UPDATE OR DELETE ON public.platform_human_memberships
|
|
148
|
+
FOR EACH ROW EXECUTE FUNCTION public.platform_human_memberships_guard();
|
|
149
|
+
|
|
150
|
+
CREATE FUNCTION public.platform_revoke_human_membership(
|
|
151
|
+
p_actor_principal_id uuid,
|
|
152
|
+
p_target_principal_id uuid,
|
|
153
|
+
p_reason text DEFAULT NULL
|
|
154
|
+
)
|
|
155
|
+
RETURNS public.platform_human_memberships
|
|
156
|
+
LANGUAGE plpgsql
|
|
157
|
+
SET search_path = pg_catalog, public
|
|
158
|
+
AS $$
|
|
159
|
+
DECLARE
|
|
160
|
+
v_target public.platform_human_memberships;
|
|
161
|
+
v_reason text := NULLIF(btrim(p_reason), '');
|
|
162
|
+
v_revoked_at timestamptz := clock_timestamp();
|
|
163
|
+
BEGIN
|
|
164
|
+
IF NOT public.platform_human_membership_is_administrator(p_actor_principal_id) THEN
|
|
165
|
+
RAISE EXCEPTION 'platform_human_revoke_forbidden' USING ERRCODE = '42501';
|
|
166
|
+
END IF;
|
|
167
|
+
|
|
168
|
+
IF p_target_principal_id IS NULL THEN
|
|
169
|
+
RAISE EXCEPTION 'platform_human_target_required' USING ERRCODE = '22023';
|
|
170
|
+
END IF;
|
|
171
|
+
|
|
172
|
+
IF p_target_principal_id = p_actor_principal_id THEN
|
|
173
|
+
RAISE EXCEPTION 'platform_human_self_revoke_forbidden' USING ERRCODE = 'P0001';
|
|
174
|
+
END IF;
|
|
175
|
+
|
|
176
|
+
IF v_reason IS NOT NULL AND char_length(v_reason) > 1000 THEN
|
|
177
|
+
RAISE EXCEPTION 'platform_human_revocation_reason_too_long' USING ERRCODE = '22023';
|
|
178
|
+
END IF;
|
|
179
|
+
|
|
180
|
+
SELECT * INTO v_target
|
|
181
|
+
FROM public.platform_human_memberships
|
|
182
|
+
WHERE principal_id = p_target_principal_id
|
|
183
|
+
FOR UPDATE;
|
|
184
|
+
|
|
185
|
+
IF NOT FOUND THEN
|
|
186
|
+
RAISE EXCEPTION 'platform_human_target_not_found' USING ERRCODE = 'P0002';
|
|
187
|
+
END IF;
|
|
188
|
+
|
|
189
|
+
IF v_target.membership_state = 'revoked' THEN
|
|
190
|
+
RETURN v_target;
|
|
191
|
+
END IF;
|
|
192
|
+
|
|
193
|
+
PERFORM set_config('app.platform_human_membership_revoke', 'true', true);
|
|
194
|
+
|
|
195
|
+
UPDATE public.platform_human_memberships
|
|
196
|
+
SET membership_state = 'revoked',
|
|
197
|
+
membership_revoked_at = v_revoked_at,
|
|
198
|
+
membership_revoked_by = p_actor_principal_id,
|
|
199
|
+
membership_revocation_reason = v_reason
|
|
200
|
+
WHERE principal_id = p_target_principal_id
|
|
201
|
+
RETURNING * INTO v_target;
|
|
202
|
+
|
|
203
|
+
INSERT INTO public.platform_human_membership_audit_events
|
|
204
|
+
(actor_principal_id, target_principal_id, action, old_value, new_value, reason, occurred_at)
|
|
205
|
+
VALUES (
|
|
206
|
+
p_actor_principal_id,
|
|
207
|
+
p_target_principal_id,
|
|
208
|
+
'revoke',
|
|
209
|
+
jsonb_build_object('membershipState', 'active', 'role', v_target.role),
|
|
210
|
+
jsonb_build_object(
|
|
211
|
+
'membershipState', 'revoked',
|
|
212
|
+
'revokedAt', v_revoked_at,
|
|
213
|
+
'revokedBy', p_actor_principal_id,
|
|
214
|
+
'revocationReason', v_reason
|
|
215
|
+
),
|
|
216
|
+
v_reason,
|
|
217
|
+
v_revoked_at
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
RETURN v_target;
|
|
221
|
+
END;
|
|
222
|
+
$$;
|
|
223
|
+
|
|
224
|
+
REVOKE ALL ON FUNCTION public.platform_human_membership_is_active(uuid)
|
|
225
|
+
FROM PUBLIC, anon, authenticated;
|
|
226
|
+
REVOKE ALL ON FUNCTION public.platform_human_membership_is_administrator(uuid)
|
|
227
|
+
FROM PUBLIC, anon, authenticated;
|
|
228
|
+
REVOKE ALL ON FUNCTION public.platform_human_memberships_guard()
|
|
229
|
+
FROM PUBLIC, anon, authenticated;
|
|
230
|
+
REVOKE ALL ON FUNCTION public.platform_revoke_human_membership(uuid, uuid, text)
|
|
231
|
+
FROM PUBLIC, anon, authenticated;
|
|
232
|
+
|
|
233
|
+
COMMENT ON FUNCTION public.platform_revoke_human_membership(uuid, uuid, text) IS
|
|
234
|
+
'Dormant direct-bundle revoke command. Requires an active human administrator, retains the target principal/membership, refuses self and last-admin removal, and records one atomic revoke event.';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
-- Pending direct operator invitations. Lifecycle commands use the trusted
|
|
2
|
+
-- server transaction lane; this forward adds no function or actor privilege.
|
|
3
|
+
CREATE TABLE public.identity_operator_invitations (
|
|
4
|
+
principal_id uuid PRIMARY KEY REFERENCES public.platform_human_principals(principal_id),
|
|
5
|
+
invitation_id uuid NOT NULL UNIQUE,
|
|
6
|
+
email_key text NOT NULL UNIQUE,
|
|
7
|
+
role text NOT NULL CHECK (role IN ('admin', 'distributor')),
|
|
8
|
+
phase text NOT NULL CHECK (phase IN ('invited', 'accepted', 'expired', 'cancelled')),
|
|
9
|
+
invited_by uuid NOT NULL REFERENCES public.platform_human_principals(principal_id),
|
|
10
|
+
invited_at timestamptz NOT NULL,
|
|
11
|
+
expires_at timestamptz NOT NULL,
|
|
12
|
+
accepted_at timestamptz,
|
|
13
|
+
closed_at timestamptz,
|
|
14
|
+
CHECK (email_key = lower(btrim(email_key)) AND NOT email_key = ''),
|
|
15
|
+
CHECK (expires_at BETWEEN invited_at + interval '60 seconds' AND invited_at + interval '30 days'),
|
|
16
|
+
CHECK (
|
|
17
|
+
(phase = 'invited' AND accepted_at IS NULL AND closed_at IS NULL)
|
|
18
|
+
OR (phase = 'accepted' AND accepted_at IS NOT NULL
|
|
19
|
+
AND accepted_at BETWEEN invited_at AND expires_at
|
|
20
|
+
AND NOT accepted_at = expires_at AND closed_at = accepted_at)
|
|
21
|
+
OR (phase = 'expired' AND accepted_at IS NULL AND closed_at = expires_at)
|
|
22
|
+
OR (phase = 'cancelled' AND accepted_at IS NULL AND closed_at IS NOT NULL)
|
|
23
|
+
)
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
CREATE TABLE public.identity_operator_invitation_events (
|
|
27
|
+
event_id uuid PRIMARY KEY,
|
|
28
|
+
invitation_id uuid NOT NULL,
|
|
29
|
+
principal_id uuid NOT NULL REFERENCES public.platform_human_principals(principal_id),
|
|
30
|
+
action text NOT NULL CHECK (action IN ('issue', 'reissue', 'accept', 'expire', 'cancel')),
|
|
31
|
+
actor_kind text NOT NULL CHECK (actor_kind IN ('human', 'system')),
|
|
32
|
+
actor_principal_id uuid REFERENCES public.platform_human_principals(principal_id),
|
|
33
|
+
old_value jsonb NOT NULL,
|
|
34
|
+
new_value jsonb NOT NULL,
|
|
35
|
+
occurred_at timestamptz NOT NULL,
|
|
36
|
+
UNIQUE (invitation_id, action),
|
|
37
|
+
CHECK ((actor_kind = 'human' AND actor_principal_id IS NOT NULL)
|
|
38
|
+
OR (actor_kind = 'system' AND actor_principal_id IS NULL))
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
CREATE INDEX identity_operator_invitation_events_target_idx
|
|
42
|
+
ON public.identity_operator_invitation_events(principal_id, occurred_at DESC);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
CREATE UNIQUE INDEX platform_human_principals_normalized_email_key
|
|
2
|
+
ON public.platform_human_principals (lower(btrim(email)));
|
|
3
|
+
|
|
4
|
+
CREATE TABLE public.operator_identity_challenges (
|
|
5
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
6
|
+
principal_id uuid NOT NULL
|
|
7
|
+
REFERENCES public.platform_human_principals(principal_id),
|
|
8
|
+
email_fingerprint text NOT NULL,
|
|
9
|
+
token_hash text NOT NULL,
|
|
10
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
11
|
+
expires_at timestamptz NOT NULL,
|
|
12
|
+
used_at timestamptz,
|
|
13
|
+
|
|
14
|
+
CONSTRAINT operator_identity_challenges_email_fingerprint_check
|
|
15
|
+
CHECK (
|
|
16
|
+
length(email_fingerprint) = 64
|
|
17
|
+
AND translate(
|
|
18
|
+
email_fingerprint,
|
|
19
|
+
'0123456789abcdef',
|
|
20
|
+
''
|
|
21
|
+
) = ''
|
|
22
|
+
),
|
|
23
|
+
|
|
24
|
+
CONSTRAINT operator_identity_challenges_token_hash_check
|
|
25
|
+
CHECK (
|
|
26
|
+
length(token_hash) = 64
|
|
27
|
+
AND translate(
|
|
28
|
+
token_hash,
|
|
29
|
+
'0123456789abcdef',
|
|
30
|
+
''
|
|
31
|
+
) = ''
|
|
32
|
+
),
|
|
33
|
+
|
|
34
|
+
CONSTRAINT operator_identity_challenges_token_hash_key
|
|
35
|
+
UNIQUE (token_hash),
|
|
36
|
+
|
|
37
|
+
CONSTRAINT operator_identity_challenges_expiry_check
|
|
38
|
+
CHECK (
|
|
39
|
+
expires_at BETWEEN
|
|
40
|
+
created_at + INTERVAL '1 second'
|
|
41
|
+
AND created_at + INTERVAL '10 minutes'
|
|
42
|
+
),
|
|
43
|
+
|
|
44
|
+
CONSTRAINT operator_identity_challenges_used_at_check
|
|
45
|
+
CHECK (
|
|
46
|
+
used_at IS NULL
|
|
47
|
+
OR used_at BETWEEN created_at AND expires_at
|
|
48
|
+
)
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
CREATE INDEX operator_identity_challenges_principal_created_idx
|
|
52
|
+
ON public.operator_identity_challenges
|
|
53
|
+
(principal_id, created_at DESC);
|
|
54
|
+
|
|
55
|
+
CREATE INDEX operator_identity_challenges_expiry_idx
|
|
56
|
+
ON public.operator_identity_challenges (expires_at, id);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
-- Direct identity erasure receipts. Audit and idempotency share one retained
|
|
2
|
+
-- pseudonymous record; no personal export snapshot or actor grants are stored.
|
|
3
|
+
CREATE TABLE public.identity_privacy_erasures (
|
|
4
|
+
erasure_id uuid PRIMARY KEY,
|
|
5
|
+
idempotency_key uuid NOT NULL UNIQUE,
|
|
6
|
+
client_id uuid UNIQUE REFERENCES public.clients(id),
|
|
7
|
+
principal_id uuid UNIQUE,
|
|
8
|
+
actor_principal_id uuid NOT NULL REFERENCES public.platform_human_principals(principal_id),
|
|
9
|
+
contract_version text NOT NULL CHECK (contract_version = 'identity.erasure.v1'),
|
|
10
|
+
contributor_versions jsonb NOT NULL,
|
|
11
|
+
dispositions jsonb NOT NULL,
|
|
12
|
+
retained_obligations jsonb NOT NULL,
|
|
13
|
+
completed_at timestamptz NOT NULL,
|
|
14
|
+
CHECK (client_id IS NOT NULL OR principal_id IS NOT NULL)
|
|
15
|
+
);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
-- Native communications facts only. The existing outbox owns all sync claims.
|
|
2
|
+
-- CREATE-only: runtime capabilities refuse unsafe effective browser/PUBLIC ACLs.
|
|
3
|
+
CREATE TABLE public.communication_native_sends (
|
|
4
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
5
|
+
binding text NOT NULL CHECK (length(binding) BETWEEN 1 AND 256),
|
|
6
|
+
source_key text NOT NULL CHECK (length(source_key) BETWEEN 1 AND 256),
|
|
7
|
+
message_id text NOT NULL CHECK (length(message_id) BETWEEN 1 AND 256),
|
|
8
|
+
recipient_fingerprint text NOT NULL CHECK (length(recipient_fingerprint) = 64),
|
|
9
|
+
template_reference text NOT NULL CHECK (length(template_reference) BETWEEN 1 AND 256),
|
|
10
|
+
accepted_at timestamptz NOT NULL,
|
|
11
|
+
observed_state text CHECK (observed_state IN ('sent','delayed','delivered','bounced','complained','failed')),
|
|
12
|
+
observed_at timestamptz,
|
|
13
|
+
last_poll_at timestamptz,
|
|
14
|
+
not_found_count integer NOT NULL DEFAULT 0 CHECK (not_found_count BETWEEN 0 AND 2147483647),
|
|
15
|
+
abandoned_at timestamptz,
|
|
16
|
+
CONSTRAINT communication_native_sends_source_key UNIQUE (binding, source_key),
|
|
17
|
+
CONSTRAINT communication_native_sends_message_key UNIQUE (binding, message_id)
|
|
18
|
+
);
|
|
19
|
+
CREATE INDEX communication_native_sends_poll ON public.communication_native_sends (binding, last_poll_at, accepted_at, id);
|
|
20
|
+
CREATE TABLE public.communication_native_observations (
|
|
21
|
+
binding text NOT NULL,
|
|
22
|
+
observation_key text NOT NULL CHECK (length(observation_key) BETWEEN 1 AND 256),
|
|
23
|
+
send_id uuid NOT NULL REFERENCES public.communication_native_sends(id),
|
|
24
|
+
kind text NOT NULL CHECK (kind IN ('sent','delayed','delivered','bounced','complained','failed')),
|
|
25
|
+
occurred_at timestamptz NOT NULL,
|
|
26
|
+
source text NOT NULL CHECK (source IN ('poll','callback')),
|
|
27
|
+
fact_fingerprint text NOT NULL CHECK (length(fact_fingerprint) = 64),
|
|
28
|
+
CONSTRAINT communication_native_observations_pkey PRIMARY KEY (binding, observation_key)
|
|
29
|
+
);
|
|
30
|
+
CREATE INDEX communication_native_observations_send ON public.communication_native_observations (send_id, occurred_at, observation_key);
|
|
31
|
+
CREATE TABLE public.communication_native_sync_state (
|
|
32
|
+
work_id uuid PRIMARY KEY REFERENCES public.outbox_events(id),
|
|
33
|
+
binding text NOT NULL CHECK (length(binding) BETWEEN 1 AND 256),
|
|
34
|
+
provider_kind text NOT NULL CHECK (length(provider_kind) BETWEEN 1 AND 256),
|
|
35
|
+
contact_id text NOT NULL CHECK (length(contact_id) BETWEEN 1 AND 256),
|
|
36
|
+
normalized_email text NOT NULL CHECK (length(normalized_email) BETWEEN 3 AND 320),
|
|
37
|
+
purpose text NOT NULL CHECK (purpose IN ('marketing_launch_offer','marketing_newsletter')),
|
|
38
|
+
event_kind text NOT NULL CHECK (event_kind IN ('subscribe','update','unsubscribe','suppress')),
|
|
39
|
+
origin_provider_kind text,
|
|
40
|
+
origin_provider_event_id text,
|
|
41
|
+
remote_profile_id text,
|
|
42
|
+
remote_list_id text,
|
|
43
|
+
response_summary jsonb NOT NULL DEFAULT '{}' CHECK (jsonb_typeof(response_summary) = 'object'),
|
|
44
|
+
command_fingerprint text NOT NULL CHECK (length(command_fingerprint) = 64),
|
|
45
|
+
max_attempts integer NOT NULL DEFAULT 8 CHECK (max_attempts BETWEEN 1 AND 20)
|
|
46
|
+
);
|
|
47
|
+
CREATE TABLE public.notification_recipients (
|
|
48
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
49
|
+
email text NOT NULL CHECK (email = lower(btrim(email))),
|
|
50
|
+
name text,
|
|
51
|
+
active boolean NOT NULL DEFAULT true,
|
|
52
|
+
notification_type text NOT NULL CHECK (notification_type IN ('packaging_digest','new_signup','commerce_payment_critical')),
|
|
53
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
54
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
55
|
+
CONSTRAINT notification_recipients_type_email_key UNIQUE (notification_type, email)
|
|
56
|
+
);
|
|
57
|
+
CREATE INDEX notification_recipients_order ON public.notification_recipients (notification_type, created_at, id);
|
|
58
|
+
CREATE TABLE public.communication_native_policy_decisions (
|
|
59
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
60
|
+
recipient_fingerprint text NOT NULL CHECK (length(recipient_fingerprint) = 64),
|
|
61
|
+
purpose text NOT NULL CHECK (length(purpose) BETWEEN 1 AND 256),
|
|
62
|
+
allowed boolean NOT NULL,
|
|
63
|
+
reason text NOT NULL CHECK (length(reason) BETWEEN 1 AND 256),
|
|
64
|
+
permission_snapshot jsonb NOT NULL CHECK (jsonb_typeof(permission_snapshot) = 'object'),
|
|
65
|
+
source_table text,
|
|
66
|
+
source_id text,
|
|
67
|
+
evaluated_at timestamptz NOT NULL DEFAULT now()
|
|
68
|
+
);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The sealed transport boundary for handing an accounting document to its recipient.
|
|
5
|
+
*
|
|
6
|
+
* The kernel exercises the whole capability up to this line: a document is owed, registered with
|
|
7
|
+
* whatever authority the market has, queued, claimed and settled against a receipt. What crosses
|
|
8
|
+
* the line is one opaque hand-off, and this adapter is the deliberately inert implementation of
|
|
9
|
+
* it -- deterministic, and leaving the installation by no route at all.
|
|
10
|
+
*
|
|
11
|
+
* It is FAIL CLOSED, and that is the whole design. An installation that has declared no delivery
|
|
12
|
+
* channel gets a refusal, never a silent success: a boundary whose default answer is "fine" is
|
|
13
|
+
* how a deployment discovers months later that nothing was ever handed to anyone.
|
|
14
|
+
*/
|
|
15
|
+
export type CapturedDocumentDeliveryCommand = {
|
|
16
|
+
readonly deliveryId: string;
|
|
17
|
+
readonly recipientReference: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type CapturedDocumentDeliveryPort = {
|
|
21
|
+
deliver(command: CapturedDocumentDeliveryCommand): Promise<{ readonly receiptReference: string }>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type CapturedDocumentDeliveryResolution =
|
|
25
|
+
| { readonly port: CapturedDocumentDeliveryPort; readonly refused?: undefined }
|
|
26
|
+
| { readonly port?: undefined; readonly refused: string };
|
|
27
|
+
|
|
28
|
+
/** The one marker that opens the boundary. Anything else, including its absence, is a refusal. */
|
|
29
|
+
export const CAPTURED_DOCUMENT_DELIVERY_CHANNEL = "captured";
|
|
30
|
+
const CHANNEL_KEY = "PLATFORM_DOCUMENT_DELIVERY_CHANNEL";
|
|
31
|
+
|
|
32
|
+
const reference = (command: CapturedDocumentDeliveryCommand): string =>
|
|
33
|
+
`captured:${createHash("sha256")
|
|
34
|
+
.update(`${command.deliveryId}::${command.recipientReference}`)
|
|
35
|
+
.digest("hex")
|
|
36
|
+
.slice(0, 32)}`;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Resolve the boundary for one installation. The environment is the only input, and every path
|
|
40
|
+
* that is not an explicit declaration of the captured channel ends in a named refusal.
|
|
41
|
+
*/
|
|
42
|
+
export function resolveCapturedDocumentDelivery(
|
|
43
|
+
env: Record<string, string | undefined>,
|
|
44
|
+
): CapturedDocumentDeliveryResolution {
|
|
45
|
+
const declared = env[CHANNEL_KEY]?.trim().toLowerCase() ?? "";
|
|
46
|
+
if (declared === "") return { refused: "document_delivery_channel_undeclared" };
|
|
47
|
+
if (declared !== CAPTURED_DOCUMENT_DELIVERY_CHANNEL) {
|
|
48
|
+
return { refused: "document_delivery_channel_unsupported" };
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
port: {
|
|
52
|
+
async deliver(command) {
|
|
53
|
+
if (typeof command.deliveryId !== "string" || command.deliveryId.trim() === "") {
|
|
54
|
+
throw new Error("document_delivery_command_invalid");
|
|
55
|
+
}
|
|
56
|
+
if (typeof command.recipientReference !== "string" || command.recipientReference.trim() === "") {
|
|
57
|
+
throw new Error("document_delivery_recipient_missing");
|
|
58
|
+
}
|
|
59
|
+
return { receiptReference: reference(command) };
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Typed refusal used by public/default composition when product copy is absent. */
|
|
2
|
+
export class AuthEmailContentUnavailableError extends Error {
|
|
3
|
+
readonly code = "auth_email_content_unavailable";
|
|
4
|
+
|
|
5
|
+
constructor() {
|
|
6
|
+
super("Auth email content unavailable");
|
|
7
|
+
this.name = "AuthEmailContentUnavailableError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|