@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,16 @@
|
|
|
1
|
+
/** Explicitly retain verifier-only admission. This does not bypass mailbox verification. */
|
|
2
|
+
export function createVerifierResultOnlyEmailTrustPolicy() {
|
|
3
|
+
return { async assess() { return { trusted: true }; } };
|
|
4
|
+
}
|
|
5
|
+
/** Invalid, absent or throwing JavaScript bindings fail closed, including invalid results. */
|
|
6
|
+
export async function assessEmailTrust(policy) {
|
|
7
|
+
try {
|
|
8
|
+
const result = await policy.assess();
|
|
9
|
+
if (result?.trusted === true)
|
|
10
|
+
return { trusted: true };
|
|
11
|
+
if (result?.trusted === false && result.code === "EMAIL_TRUST_ENVELOPE_REFUSED")
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
catch { /* Do not expose policy or transport details. */ }
|
|
15
|
+
return { trusted: false, code: "EMAIL_TRUST_SETTINGS_UNAVAILABLE" };
|
|
16
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PersonalDataObligation } from "./contracts/privacy.js";
|
|
2
|
+
import { type PersonalDataContributor, type PrivacyStore } from "./privacyPorts.js";
|
|
3
|
+
export interface IdentityPrivacyPolicy {
|
|
4
|
+
/** Explicit dispositions for populated opaque contact fields; absence refuses erasure. */
|
|
5
|
+
retainedContactFields: Readonly<Record<string, PersonalDataObligation>>;
|
|
6
|
+
}
|
|
7
|
+
export declare function createIdentityPersonalDataContributor<C>(store: PrivacyStore<C>, policy: IdentityPrivacyPolicy, randomId: () => string): PersonalDataContributor<C>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { PrivacyRefusal } from "./privacyPorts.js";
|
|
2
|
+
const owned = new Set(["id", "email", "first_name", "last_name", "phone", "country", "principal_id", "created_at", "updated_at"]);
|
|
3
|
+
const populated = (value) => value !== null && value !== "" && !(typeof value === "object" && Object.keys(value).length === 0);
|
|
4
|
+
export function createIdentityPersonalDataContributor(store, policy, randomId) {
|
|
5
|
+
function obligations(identity) {
|
|
6
|
+
const contact = identity.contact;
|
|
7
|
+
const result = [{ owner: "identity", resource: "identity.audit-and-receipt", disposition: "retain", reasonCode: "PSEUDONYMOUS_AUDIT", remote: false }];
|
|
8
|
+
if (contact && typeof contact === "object" && !Array.isArray(contact)) {
|
|
9
|
+
for (const [key, value] of Object.entries(contact)) {
|
|
10
|
+
if (owned.has(key) || !populated(value))
|
|
11
|
+
continue;
|
|
12
|
+
const declaration = policy.retainedContactFields[key];
|
|
13
|
+
result.push(declaration?.disposition === "retain" && declaration.resource === `clients.${key}` ? declaration : { owner: "unassigned", resource: `clients.${key}`, disposition: "unresolved", reasonCode: "PRIVACY_OWNERSHIP_UNDECLARED", remote: false });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
id: "identity", version: "identity.personal-data.v1",
|
|
20
|
+
ownedResources: ["identity.contact-profile", "identity.principal", "identity.membership", "identity.invitations", "identity.audit-and-receipt"],
|
|
21
|
+
async prepareErasure() { },
|
|
22
|
+
async export(_context, subject) {
|
|
23
|
+
const unavailable = Array.isArray(subject.identity.unavailable) ? subject.identity.unavailable.map(String) : [];
|
|
24
|
+
const data = { ...subject.identity };
|
|
25
|
+
const contact = data.contact;
|
|
26
|
+
if (contact && typeof contact === "object" && !Array.isArray(contact)) {
|
|
27
|
+
data.contact = Object.fromEntries(Object.entries(contact).filter(([key]) => owned.has(key) || key === "auth_user_id"));
|
|
28
|
+
for (const key of Object.keys(contact))
|
|
29
|
+
if (!owned.has(key) && key !== "auth_user_id")
|
|
30
|
+
unavailable.push(`contact.${key}`);
|
|
31
|
+
}
|
|
32
|
+
return { contributorId: "identity", version: "identity.personal-data.v1", data,
|
|
33
|
+
coverage: { complete: unavailable.length === 0, included: Object.keys(subject.identity).filter(k => k !== "unavailable"), unavailable }, obligations: obligations(subject.identity) };
|
|
34
|
+
},
|
|
35
|
+
async assessErasure(_context, subject) {
|
|
36
|
+
const declared = obligations(subject.identity);
|
|
37
|
+
if (declared.some(o => o.disposition === "unresolved"))
|
|
38
|
+
throw new PrivacyRefusal("PRIVACY_OWNERSHIP_UNDECLARED");
|
|
39
|
+
return { obligations: declared };
|
|
40
|
+
},
|
|
41
|
+
async eraseOrRetain(context, subject, assessment, actor) {
|
|
42
|
+
await store.eraseIdentity(context, subject, actor, `erased+${randomId()}@identity.invalid`);
|
|
43
|
+
return { contributorId: "identity", version: "identity.personal-data.v1", obligations: assessment.obligations };
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReadinessIssue } from "@openlup/core/readiness";
|
|
2
|
+
import { type EmailTrustPolicy } from "./emailTrustPolicy.js";
|
|
3
|
+
/** The module field stays structural so older core readiness types still compile; no new core code is needed. */
|
|
4
|
+
export declare function identityEmailTrustReadiness(policy: EmailTrustPolicy): Promise<readonly (ReadinessIssue & {
|
|
5
|
+
module: "identity";
|
|
6
|
+
})[]>;
|
|
7
|
+
/** Discovery and fresh key availability are independent readiness observations. */
|
|
8
|
+
export declare function identityOidcReadiness(verifier: import("./oidcIdentityVerifier.js").OidcIdentityVerifier): Promise<readonly (ReadinessIssue & {
|
|
9
|
+
module: "identity";
|
|
10
|
+
})[]>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { assessEmailTrust } from "./emailTrustPolicy.js";
|
|
2
|
+
/** The module field stays structural so older core readiness types still compile; no new core code is needed. */
|
|
3
|
+
export async function identityEmailTrustReadiness(policy) {
|
|
4
|
+
const result = await assessEmailTrust(policy);
|
|
5
|
+
if (result.trusted)
|
|
6
|
+
return [];
|
|
7
|
+
return [{
|
|
8
|
+
code: "OPENLUP_E_PORT_MISSING", package: "@openlup/platform", module: "identity",
|
|
9
|
+
subject: "emailTrustPolicy", observation: result.code,
|
|
10
|
+
fix: result.code === "EMAIL_TRUST_ENVELOPE_REFUSED"
|
|
11
|
+
? "Disable automatic confirmation and declare only providers that verify email."
|
|
12
|
+
: "Restore access to valid public identity settings or bind an explicit email-trust policy.",
|
|
13
|
+
}];
|
|
14
|
+
}
|
|
15
|
+
/** Discovery and fresh key availability are independent readiness observations. */
|
|
16
|
+
export async function identityOidcReadiness(verifier) {
|
|
17
|
+
const report = await verifier.readiness();
|
|
18
|
+
if (report.state === "ready")
|
|
19
|
+
return [];
|
|
20
|
+
return [
|
|
21
|
+
...(!report.discovery.valid ? ["oidcDiscovery"] : []),
|
|
22
|
+
...(!report.jwks.loaded ? ["oidcJwks"] : []),
|
|
23
|
+
].map(subject => ({ code: "OPENLUP_E_PORT_MISSING", package: "@openlup/platform", module: "identity", subject,
|
|
24
|
+
observation: report.code ?? "OIDC_JWKS_INVALID", fix: "Restore valid issuer discovery and fresh same-origin signing keys." }));
|
|
25
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export * from "./adminMagicLinkHandler.js";
|
|
2
|
+
export * from "./reconcileAccountForPrincipal.js";
|
|
3
|
+
export * from "./customerVerifyOtpHandler.js";
|
|
4
|
+
export * from "./authVerifyUrl.js";
|
|
5
|
+
export * from "./customerIdentityVerifier.js";
|
|
6
|
+
export * from "./operatorTokenAdminAuth.js";
|
|
7
|
+
export * from "./managedIdentityVerifier.js";
|
|
8
|
+
export * from "./managedAdminAuthVerifier.js";
|
|
9
|
+
export * from "./managedCustomerMe.js";
|
|
10
|
+
export * from "./sql.js";
|
|
11
|
+
export * from "./customerMeHandler.js";
|
|
12
|
+
export * from "./messages.js";
|
|
13
|
+
export * from "./managedAccountLinkStore.js";
|
|
14
|
+
export * from "./customerIdentityBinding.js";
|
|
15
|
+
export * from "./adminUserActionPorts.js";
|
|
16
|
+
export * from "./contribution.js";
|
|
17
|
+
export * from "./customerContracts.js";
|
|
18
|
+
export * from "./machineActorWriteFence.js";
|
|
19
|
+
export * from "./managedClient.js";
|
|
20
|
+
export * from "./customerAuthorization.js";
|
|
21
|
+
export * from "./customerSessionIssuer.js";
|
|
22
|
+
export * from "./managedClientAuthLink.js";
|
|
23
|
+
export * from "./customerAuth.js";
|
|
24
|
+
export * from "./reconcileAccountHandler.js";
|
|
25
|
+
export * from "./postgresCustomerMe.js";
|
|
26
|
+
export * from "./ports.js";
|
|
27
|
+
export * from "./postgresCustomerRecovery.js";
|
|
28
|
+
export * from "./customerMagicLinkHandler.js";
|
|
29
|
+
export * from "./customerSessionBinding.js";
|
|
30
|
+
export * from "./adminUserHandlers.js";
|
|
31
|
+
export * from "./adminPreflight.js";
|
|
32
|
+
export * from "./adminAuthBinding.js";
|
|
33
|
+
export * from "./customerPorts.js";
|
|
34
|
+
export * from "./magicLinkPorts.js";
|
|
35
|
+
export * from "./inviteAdminUserUseCase.js";
|
|
36
|
+
export * from "./adminAuthorization.js";
|
|
37
|
+
export * from "./removeAdminUserUseCase.js";
|
|
38
|
+
export * from "./adminMeHandler.js";
|
|
39
|
+
export * from "./managedAdminUserGateways.js";
|
|
40
|
+
export * from "./jwtLibrary.js";
|
|
41
|
+
export * from "./platformAdminAuth.js";
|
|
42
|
+
export * from "./adminContracts.js";
|
|
43
|
+
export * from "./contracts/emailTrust.js";
|
|
44
|
+
export { createVerifierResultOnlyEmailTrustPolicy } from "./emailTrustPolicy.js";
|
|
45
|
+
export type { EmailTrustAssessment, EmailTrustPolicy } from "./emailTrustPolicy.js";
|
|
46
|
+
export * from "./managedEmailTrustPolicy.js";
|
|
47
|
+
export * from "./identityReadiness.js";
|
|
48
|
+
export * from "./operatorInvitationPorts.js";
|
|
49
|
+
export * from "./operatorInvitationLifecycle.js";
|
|
50
|
+
export * from "./directOperatorInvitationStore.js";
|
|
51
|
+
export * from "./operatorPorts.js";
|
|
52
|
+
export * from "./operatorSession.js";
|
|
53
|
+
export * from "./operatorIdentityVerifier.js";
|
|
54
|
+
export * from "./operatorAdminAuth.js";
|
|
55
|
+
export * from "./operatorAuthHandlers.js";
|
|
56
|
+
export * from "./postgresOperatorIdentity.js";
|
|
57
|
+
export * from "./privacyPorts.js";
|
|
58
|
+
export * from "./personalDataRegistry.js";
|
|
59
|
+
export * from "./privacyUseCases.js";
|
|
60
|
+
export * from "./identityPersonalDataContributor.js";
|
|
61
|
+
export * from "./postgresPrivacy.js";
|
|
62
|
+
export * from "./managedPrivacy.js";
|
|
63
|
+
export * from "./privacyHandlers.js";
|
|
64
|
+
export * from "./oidcIdentityVerifier.js";
|
|
65
|
+
export * from "./oidcPrincipal.js";
|
|
66
|
+
export * from "./postgresAccountLinkStore.js";
|
|
67
|
+
export * from "./contracts/oidc.js";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export * from "./adminMagicLinkHandler.js";
|
|
2
|
+
export * from "./reconcileAccountForPrincipal.js";
|
|
3
|
+
export * from "./customerVerifyOtpHandler.js";
|
|
4
|
+
export * from "./authVerifyUrl.js";
|
|
5
|
+
export * from "./customerIdentityVerifier.js";
|
|
6
|
+
export * from "./operatorTokenAdminAuth.js";
|
|
7
|
+
export * from "./managedIdentityVerifier.js";
|
|
8
|
+
export * from "./managedAdminAuthVerifier.js";
|
|
9
|
+
export * from "./managedCustomerMe.js";
|
|
10
|
+
export * from "./sql.js";
|
|
11
|
+
export * from "./customerMeHandler.js";
|
|
12
|
+
export * from "./messages.js";
|
|
13
|
+
export * from "./managedAccountLinkStore.js";
|
|
14
|
+
export * from "./customerIdentityBinding.js";
|
|
15
|
+
export * from "./adminUserActionPorts.js";
|
|
16
|
+
export * from "./contribution.js";
|
|
17
|
+
export * from "./customerContracts.js";
|
|
18
|
+
export * from "./machineActorWriteFence.js";
|
|
19
|
+
export * from "./managedClient.js";
|
|
20
|
+
export * from "./customerAuthorization.js";
|
|
21
|
+
export * from "./customerSessionIssuer.js";
|
|
22
|
+
export * from "./managedClientAuthLink.js";
|
|
23
|
+
export * from "./customerAuth.js";
|
|
24
|
+
export * from "./reconcileAccountHandler.js";
|
|
25
|
+
export * from "./postgresCustomerMe.js";
|
|
26
|
+
export * from "./ports.js";
|
|
27
|
+
export * from "./postgresCustomerRecovery.js";
|
|
28
|
+
export * from "./customerMagicLinkHandler.js";
|
|
29
|
+
export * from "./customerSessionBinding.js";
|
|
30
|
+
export * from "./adminUserHandlers.js";
|
|
31
|
+
export * from "./adminPreflight.js";
|
|
32
|
+
export * from "./adminAuthBinding.js";
|
|
33
|
+
export * from "./customerPorts.js";
|
|
34
|
+
export * from "./magicLinkPorts.js";
|
|
35
|
+
export * from "./inviteAdminUserUseCase.js";
|
|
36
|
+
export * from "./adminAuthorization.js";
|
|
37
|
+
export * from "./removeAdminUserUseCase.js";
|
|
38
|
+
export * from "./adminMeHandler.js";
|
|
39
|
+
export * from "./managedAdminUserGateways.js";
|
|
40
|
+
export * from "./jwtLibrary.js";
|
|
41
|
+
export * from "./platformAdminAuth.js";
|
|
42
|
+
export * from "./adminContracts.js";
|
|
43
|
+
export * from "./contracts/emailTrust.js";
|
|
44
|
+
export { createVerifierResultOnlyEmailTrustPolicy } from "./emailTrustPolicy.js";
|
|
45
|
+
export * from "./managedEmailTrustPolicy.js";
|
|
46
|
+
export * from "./identityReadiness.js";
|
|
47
|
+
export * from "./operatorInvitationPorts.js";
|
|
48
|
+
export * from "./operatorInvitationLifecycle.js";
|
|
49
|
+
export * from "./directOperatorInvitationStore.js";
|
|
50
|
+
export * from "./operatorPorts.js";
|
|
51
|
+
export * from "./operatorSession.js";
|
|
52
|
+
export * from "./operatorIdentityVerifier.js";
|
|
53
|
+
export * from "./operatorAdminAuth.js";
|
|
54
|
+
export * from "./operatorAuthHandlers.js";
|
|
55
|
+
export * from "./postgresOperatorIdentity.js";
|
|
56
|
+
export * from "./privacyPorts.js";
|
|
57
|
+
export * from "./personalDataRegistry.js";
|
|
58
|
+
export * from "./privacyUseCases.js";
|
|
59
|
+
export * from "./identityPersonalDataContributor.js";
|
|
60
|
+
export * from "./postgresPrivacy.js";
|
|
61
|
+
export * from "./managedPrivacy.js";
|
|
62
|
+
export * from "./privacyHandlers.js";
|
|
63
|
+
export * from "./oidcIdentityVerifier.js";
|
|
64
|
+
export * from "./oidcPrincipal.js";
|
|
65
|
+
export * from "./postgresAccountLinkStore.js";
|
|
66
|
+
export * from "./contracts/oidc.js";
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { ManagedOperatorMembershipResult, OperatorInvitationConflict } from "./contracts/operatorInvitations.js";
|
|
2
|
+
import type { OperatorInvitationStore } from "./operatorInvitationPorts.js";
|
|
3
|
+
import { type IdentityMessages } from "./messages.js";
|
|
4
|
+
export type AdminUserInviteRole = "admin" | "distributor";
|
|
5
|
+
export declare const ADMIN_ROLE_NOTIFICATION_LOCALE: "en";
|
|
6
|
+
export type AdminRoleNotificationSkipReason = "admin_disabled" | "egress_suppressed";
|
|
7
|
+
export type InviteAdminUserResponse = {
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
success?: boolean;
|
|
10
|
+
message?: string;
|
|
11
|
+
error?: string;
|
|
12
|
+
code?: string;
|
|
13
|
+
deliveryReference?: string | null;
|
|
14
|
+
deliveryReferencePresent?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export interface InviteAdminUserGateway {
|
|
17
|
+
getUser: (accessToken: string) => Promise<{
|
|
18
|
+
user: {
|
|
19
|
+
id: string;
|
|
20
|
+
} | null;
|
|
21
|
+
error: unknown;
|
|
22
|
+
}>;
|
|
23
|
+
findAdminUser: (userId: string) => Promise<{
|
|
24
|
+
id: string;
|
|
25
|
+
role: string;
|
|
26
|
+
membership_state: string;
|
|
27
|
+
is_machine_actor: boolean;
|
|
28
|
+
} | null>;
|
|
29
|
+
findAdminUserByEmail: (email: string) => Promise<{
|
|
30
|
+
id: string;
|
|
31
|
+
} | null>;
|
|
32
|
+
findAuthUserByEmail: (email: string) => Promise<{
|
|
33
|
+
id: string;
|
|
34
|
+
email?: string | null;
|
|
35
|
+
} | null>;
|
|
36
|
+
inviteAuthUser: (input: {
|
|
37
|
+
email: string;
|
|
38
|
+
redirectTo: string;
|
|
39
|
+
role: AdminUserInviteRole;
|
|
40
|
+
}) => Promise<{
|
|
41
|
+
user: {
|
|
42
|
+
id: string;
|
|
43
|
+
} | null;
|
|
44
|
+
error: {
|
|
45
|
+
message: string;
|
|
46
|
+
} | null;
|
|
47
|
+
}>;
|
|
48
|
+
}
|
|
49
|
+
export interface AdminRoleNotificationPort {
|
|
50
|
+
sendRoleGranted: (input: {
|
|
51
|
+
email: string;
|
|
52
|
+
authUserId: string;
|
|
53
|
+
role: AdminUserInviteRole;
|
|
54
|
+
locale: "pl" | "en";
|
|
55
|
+
invitationId?: string;
|
|
56
|
+
expiresAt?: string;
|
|
57
|
+
}) => Promise<{
|
|
58
|
+
ok: boolean;
|
|
59
|
+
providerMessageId: string | null;
|
|
60
|
+
providerError: string | null;
|
|
61
|
+
skipped: boolean;
|
|
62
|
+
skipReason: AdminRoleNotificationSkipReason | null;
|
|
63
|
+
}>;
|
|
64
|
+
}
|
|
65
|
+
export declare function runInviteAdminUserUseCase(request: {
|
|
66
|
+
accessToken: string | null;
|
|
67
|
+
email: string;
|
|
68
|
+
role: string;
|
|
69
|
+
}, deps: {
|
|
70
|
+
gateway: InviteAdminUserGateway;
|
|
71
|
+
roleNotificationPort: AdminRoleNotificationPort;
|
|
72
|
+
siteUrl: string;
|
|
73
|
+
messages?: IdentityMessages;
|
|
74
|
+
notificationLocale?: "pl" | "en";
|
|
75
|
+
} & ({
|
|
76
|
+
invitationStore: OperatorInvitationStore;
|
|
77
|
+
ttlSeconds: number;
|
|
78
|
+
} | {
|
|
79
|
+
activateMembership: (input: {
|
|
80
|
+
principalId: string;
|
|
81
|
+
email: string;
|
|
82
|
+
role: AdminUserInviteRole;
|
|
83
|
+
}) => Promise<ManagedOperatorMembershipResult | {
|
|
84
|
+
code: OperatorInvitationConflict;
|
|
85
|
+
}>;
|
|
86
|
+
})): Promise<{
|
|
87
|
+
status: number;
|
|
88
|
+
body: InviteAdminUserResponse;
|
|
89
|
+
}>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { assertOperatorInvitationTtl } from "./operatorInvitationLifecycle.js";
|
|
2
|
+
import { identityMessages } from "./messages.js";
|
|
3
|
+
export const ADMIN_ROLE_NOTIFICATION_LOCALE = "en";
|
|
4
|
+
export async function runInviteAdminUserUseCase(request, deps) {
|
|
5
|
+
const messages = deps.messages ?? identityMessages.en;
|
|
6
|
+
try {
|
|
7
|
+
if ("invitationStore" in deps)
|
|
8
|
+
assertOperatorInvitationTtl(deps.ttlSeconds);
|
|
9
|
+
if (!request.accessToken) {
|
|
10
|
+
return { status: 401, body: { code: "UNAUTHORIZED", error: messages.unauthorized } };
|
|
11
|
+
}
|
|
12
|
+
const { user, error: authError } = await deps.gateway.getUser(request.accessToken);
|
|
13
|
+
if (authError || !user) {
|
|
14
|
+
return { status: 401, body: { code: "INVALID_TOKEN", error: messages.invalidToken } };
|
|
15
|
+
}
|
|
16
|
+
const callerAdmin = await deps.gateway.findAdminUser(user.id);
|
|
17
|
+
if (!callerAdmin || callerAdmin.role !== "admin" || callerAdmin.membership_state !== "active" || callerAdmin.is_machine_actor !== false) {
|
|
18
|
+
return { status: 403, body: { code: "INVITE_FORBIDDEN", error: messages.inviteForbidden } };
|
|
19
|
+
}
|
|
20
|
+
if (!request.email) {
|
|
21
|
+
return { status: 400, body: { code: "EMAIL_REQUIRED", error: messages.emailRequired } };
|
|
22
|
+
}
|
|
23
|
+
if (!isInviteRole(request.role)) {
|
|
24
|
+
return { status: 400, body: { code: "INVALID_ROLE", error: messages.invalidRole } };
|
|
25
|
+
}
|
|
26
|
+
const role = request.role;
|
|
27
|
+
const email = request.email.trim().toLowerCase();
|
|
28
|
+
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email))
|
|
29
|
+
return { status: 400, body: { code: "INVALID_EMAIL", error: "Invalid email" } };
|
|
30
|
+
const existingMembership = await deps.gateway.findAdminUserByEmail(email);
|
|
31
|
+
let principal = await deps.gateway.findAuthUserByEmail(email);
|
|
32
|
+
if (existingMembership && existingMembership.id !== principal?.id)
|
|
33
|
+
return { status: 409, body: { code: "IDENTITY_CONFLICT", error: "IDENTITY_CONFLICT" } };
|
|
34
|
+
if (!principal) {
|
|
35
|
+
const invite = await deps.gateway.inviteAuthUser({ email, role, redirectTo: new URL("/admin/auth/callback", deps.siteUrl).toString() });
|
|
36
|
+
if (invite.error || !invite.user) {
|
|
37
|
+
// A provider duplicate race reuses the durable identity. Never delete it.
|
|
38
|
+
principal = await deps.gateway.findAuthUserByEmail(email);
|
|
39
|
+
if (!principal)
|
|
40
|
+
throw new Error("operator_identity_creation_failed");
|
|
41
|
+
}
|
|
42
|
+
else
|
|
43
|
+
principal = invite.user;
|
|
44
|
+
}
|
|
45
|
+
const issued = "invitationStore" in deps
|
|
46
|
+
? await deps.invitationStore.issue({ actorPrincipalId: user.id, targetPrincipalId: principal.id, email, role, ttlSeconds: deps.ttlSeconds })
|
|
47
|
+
: await deps.activateMembership({ principalId: principal.id, email, role });
|
|
48
|
+
if (!("membershipState" in issued))
|
|
49
|
+
return { status: 409, body: { code: issued.code, error: issued.code } };
|
|
50
|
+
let delivery = {};
|
|
51
|
+
if (issued.code !== "ALREADY_INVITED" && issued.code !== "ALREADY_ACTIVE") {
|
|
52
|
+
try {
|
|
53
|
+
const notification = await deps.roleNotificationPort.sendRoleGranted({ email, authUserId: principal.id, role, locale: deps.notificationLocale ?? ADMIN_ROLE_NOTIFICATION_LOCALE, ...(issued.membershipState === "invited" ? { invitationId: issued.invitationId, expiresAt: issued.expiresAt } : {}) });
|
|
54
|
+
if (!notification.ok)
|
|
55
|
+
throw new Error("operator_invitation_notification_failed");
|
|
56
|
+
delivery = { deliveryReference: notification.skipped ? null : notification.providerMessageId, deliveryReferencePresent: !notification.skipped && Boolean(notification.providerMessageId) };
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return { status: 503, body: issued.membershipState === "invited"
|
|
60
|
+
? { code: "INVITATION_NOTIFICATION_FAILED", error: "Invitation persisted; notification unavailable", invitationId: issued.invitationId }
|
|
61
|
+
: { ...issued, code: "INVITATION_NOTIFICATION_FAILED", error: "Membership active; notification unavailable" } };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return { status: 200, body: { success: true, ...issued, ...delivery, message: issued.membershipState === "invited" ? `Invitation pending until ${issued.expiresAt}` : "Operator membership active" } };
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
const failure = err;
|
|
68
|
+
if (failure.identityCode)
|
|
69
|
+
return { status: failure.bffCode === "FORBIDDEN" ? 403 : 409, body: { code: failure.identityCode, error: failure.identityCode } };
|
|
70
|
+
return { status: 503, body: { code: "IDENTITY_ACTION_FAILED", error: String(err) } };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function isInviteRole(value) {
|
|
74
|
+
return value === "admin" || value === "distributor";
|
|
75
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface IdentityJwk {
|
|
2
|
+
[key: string]: unknown;
|
|
3
|
+
kty?: string;
|
|
4
|
+
alg?: string;
|
|
5
|
+
crv?: string;
|
|
6
|
+
kid?: string;
|
|
7
|
+
use?: string;
|
|
8
|
+
x?: string;
|
|
9
|
+
y?: string;
|
|
10
|
+
d?: string;
|
|
11
|
+
}
|
|
12
|
+
type Key = CryptoKey | Uint8Array;
|
|
13
|
+
interface Signer {
|
|
14
|
+
setProtectedHeader(header: {
|
|
15
|
+
alg: string;
|
|
16
|
+
kid: string;
|
|
17
|
+
typ: string;
|
|
18
|
+
}): Signer;
|
|
19
|
+
setSubject(value: string): Signer;
|
|
20
|
+
setIssuer(value: string): Signer;
|
|
21
|
+
setAudience(value: string): Signer;
|
|
22
|
+
setIssuedAt(value: number): Signer;
|
|
23
|
+
setExpirationTime(value: number): Signer;
|
|
24
|
+
sign(key: Key): Promise<string>;
|
|
25
|
+
}
|
|
26
|
+
/** The host loads its selected JWT implementation only for the selected adapter. */
|
|
27
|
+
export interface IdentityJwtLibrary {
|
|
28
|
+
importJWK(jwk: IdentityJwk, alg: string): Promise<Key>;
|
|
29
|
+
jwtVerify(token: string, key: (header: {
|
|
30
|
+
alg?: string;
|
|
31
|
+
kid?: string;
|
|
32
|
+
}) => Promise<Key>, options: {
|
|
33
|
+
algorithms: string[];
|
|
34
|
+
audience: string;
|
|
35
|
+
issuer: string;
|
|
36
|
+
currentDate?: Date;
|
|
37
|
+
clockTolerance?: number;
|
|
38
|
+
}): Promise<{
|
|
39
|
+
payload: IdentityJwtClaims;
|
|
40
|
+
}>;
|
|
41
|
+
SignJWT: new (payload: Record<string, unknown>) => Signer;
|
|
42
|
+
}
|
|
43
|
+
export type IdentityJwtLibraryLoader = () => Promise<IdentityJwtLibrary>;
|
|
44
|
+
/** Claims returned only after signature verification by the host library. */
|
|
45
|
+
export interface IdentityJwtClaims {
|
|
46
|
+
[claim: string]: unknown;
|
|
47
|
+
sub?: string;
|
|
48
|
+
iss?: string;
|
|
49
|
+
aud?: string | string[];
|
|
50
|
+
exp?: number;
|
|
51
|
+
iat?: number;
|
|
52
|
+
nbf?: number;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { HttpResponse } from "../http/index.js";
|
|
2
|
+
import { type IdentityResponseOptions } from "./response.js";
|
|
3
|
+
export declare function refusesMachineActorRequest(route: string, method: string | undefined, isMachineActor: boolean | undefined, writeRoutes?: readonly string[]): boolean;
|
|
4
|
+
export declare function sendMachineActorWriteRefused(res: HttpResponse, options?: IdentityResponseOptions): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createIdentityResponder } from "./response.js";
|
|
2
|
+
export function refusesMachineActorRequest(route, method, isMachineActor, writeRoutes = []) {
|
|
3
|
+
if (isMachineActor === false)
|
|
4
|
+
return false;
|
|
5
|
+
const verb = (method ?? "").toUpperCase();
|
|
6
|
+
return verb !== "GET" && verb !== "HEAD" && !writeRoutes.includes(route);
|
|
7
|
+
}
|
|
8
|
+
export function sendMachineActorWriteRefused(res, options = {}) {
|
|
9
|
+
const { sendBffError } = createIdentityResponder(options);
|
|
10
|
+
sendBffError(res, "FORBIDDEN", "Human operator required", {
|
|
11
|
+
details: { reason: "machine_actor_write_refused" },
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface MagicLinkAuthClient {
|
|
2
|
+
auth: {
|
|
3
|
+
signInWithOtp(input: {
|
|
4
|
+
email: string;
|
|
5
|
+
options: {
|
|
6
|
+
shouldCreateUser: false;
|
|
7
|
+
emailRedirectTo: string;
|
|
8
|
+
};
|
|
9
|
+
}): Promise<{
|
|
10
|
+
error: {
|
|
11
|
+
name?: string;
|
|
12
|
+
message?: string;
|
|
13
|
+
} | null;
|
|
14
|
+
}>;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface MagicLinkRateLimitClient {
|
|
18
|
+
rpc(fn: string, args: Record<string, unknown>): Promise<{
|
|
19
|
+
data: unknown;
|
|
20
|
+
error: {
|
|
21
|
+
message?: string;
|
|
22
|
+
} | null;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
export interface MagicLinkDecision {
|
|
26
|
+
allowed: boolean;
|
|
27
|
+
reason?: string;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export function createSupabaseAccountLinkStore(rawClient) {
|
|
2
|
+
const client = rawClient;
|
|
3
|
+
return {
|
|
4
|
+
async findAccountByPrincipalId(principalId) {
|
|
5
|
+
const { data, error } = await client
|
|
6
|
+
.from("clients")
|
|
7
|
+
.select("id, email, auth_user_id")
|
|
8
|
+
.eq("auth_user_id", principalId)
|
|
9
|
+
.maybeSingle();
|
|
10
|
+
if (error)
|
|
11
|
+
throw error;
|
|
12
|
+
if (!data)
|
|
13
|
+
return null;
|
|
14
|
+
return { id: data.id, email: data.email ?? null, principalId: data.auth_user_id ?? null };
|
|
15
|
+
},
|
|
16
|
+
async findAccountByEmail(email) {
|
|
17
|
+
const rows = await findManagedContactsByEmail(client, email, false);
|
|
18
|
+
if (rows.length > 1) {
|
|
19
|
+
throw Object.assign(new Error("multiple rows returned"), { code: "PGRST116" });
|
|
20
|
+
}
|
|
21
|
+
const data = rows[0];
|
|
22
|
+
if (!data)
|
|
23
|
+
return null;
|
|
24
|
+
return { id: data.id, email: data.email ?? null, principalId: data.auth_user_id ?? null };
|
|
25
|
+
},
|
|
26
|
+
async isReservedPrincipal(principalId) {
|
|
27
|
+
const { data, error } = await client
|
|
28
|
+
.from("admin_users")
|
|
29
|
+
.select("id, is_machine_actor")
|
|
30
|
+
.eq("id", principalId)
|
|
31
|
+
.maybeSingle();
|
|
32
|
+
if (error)
|
|
33
|
+
throw error;
|
|
34
|
+
if (!data)
|
|
35
|
+
return false;
|
|
36
|
+
return data.is_machine_actor !== false;
|
|
37
|
+
},
|
|
38
|
+
async linkPrincipalToAccount(accountId, principalId) {
|
|
39
|
+
const { data, error } = await client
|
|
40
|
+
.from("clients")
|
|
41
|
+
.update({ auth_user_id: principalId })
|
|
42
|
+
.eq("id", accountId)
|
|
43
|
+
.is("auth_user_id", null)
|
|
44
|
+
.select("auth_user_id")
|
|
45
|
+
.maybeSingle();
|
|
46
|
+
if (error)
|
|
47
|
+
throw error;
|
|
48
|
+
if (data?.auth_user_id === principalId) {
|
|
49
|
+
return { ok: true, alreadyLinked: false };
|
|
50
|
+
}
|
|
51
|
+
const { data: current, error: currentError } = await client
|
|
52
|
+
.from("clients")
|
|
53
|
+
.select("auth_user_id")
|
|
54
|
+
.eq("id", accountId)
|
|
55
|
+
.maybeSingle();
|
|
56
|
+
if (currentError)
|
|
57
|
+
throw currentError;
|
|
58
|
+
if (current?.auth_user_id === principalId) {
|
|
59
|
+
return { ok: true, alreadyLinked: true };
|
|
60
|
+
}
|
|
61
|
+
return { ok: false, existingPrincipalId: current?.auth_user_id ?? null };
|
|
62
|
+
},
|
|
63
|
+
async createAccount(input) {
|
|
64
|
+
const { data, error } = await client
|
|
65
|
+
.from("clients")
|
|
66
|
+
.insert({
|
|
67
|
+
email: input.email,
|
|
68
|
+
auth_user_id: input.principalId,
|
|
69
|
+
acquisition_source: input.acquisitionSource,
|
|
70
|
+
lifecycle_stage: input.lifecycleStage,
|
|
71
|
+
})
|
|
72
|
+
.select("id")
|
|
73
|
+
.single();
|
|
74
|
+
if (error)
|
|
75
|
+
throw error;
|
|
76
|
+
return { id: data.id };
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
async function findManagedContactsByEmail(client, email, oldestFirst) {
|
|
81
|
+
const normalized = email.trim().toLowerCase();
|
|
82
|
+
// Escaping bounds the database prefilter; Unicode regex folding can still
|
|
83
|
+
// widen it, so only exact normalized addresses may cross this boundary.
|
|
84
|
+
let query = client.from("clients")
|
|
85
|
+
.select("id, email, auth_user_id")
|
|
86
|
+
.filter("email", "imatch", `^${normalized.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&")}$`);
|
|
87
|
+
if (oldestFirst)
|
|
88
|
+
query = query.order("created_at", { ascending: true });
|
|
89
|
+
const { data, error } = await query.limit(10);
|
|
90
|
+
if (error)
|
|
91
|
+
throw error;
|
|
92
|
+
return (data ?? []).filter((row) => row.email?.trim().toLowerCase() === normalized);
|
|
93
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SupabaseCreateClient } from "../data/index.js";
|
|
2
|
+
import type { AdminAuthPort } from "./ports.js";
|
|
3
|
+
export declare function createSupabaseAdminAuth(rawClient: unknown): AdminAuthPort;
|
|
4
|
+
export declare function createSupabaseAdminAuthFromEnv(env: {
|
|
5
|
+
url: string;
|
|
6
|
+
anonKey: string;
|
|
7
|
+
}, accessToken: string | null, createClient: SupabaseCreateClient): AdminAuthPort;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { authorizeAdminWithUser } from "./adminAuthorization.js";
|
|
2
|
+
export function createSupabaseAdminAuth(rawClient) {
|
|
3
|
+
const client = rawClient;
|
|
4
|
+
return {
|
|
5
|
+
async authorize(accessToken, options) {
|
|
6
|
+
const authz = await authorizeAdminWithUser(client, accessToken, options);
|
|
7
|
+
if (authz.ok === false) {
|
|
8
|
+
return { ok: false, code: authz.code, message: authz.message };
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
ok: true,
|
|
12
|
+
principalId: authz.userId,
|
|
13
|
+
role: authz.role,
|
|
14
|
+
isMachineActor: authz.isMachineActor,
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function createSupabaseAdminAuthFromEnv(env, accessToken, createClient) {
|
|
20
|
+
const client = createClient(env.url, env.anonKey, {
|
|
21
|
+
auth: { persistSession: false, autoRefreshToken: false },
|
|
22
|
+
global: {
|
|
23
|
+
headers: accessToken ? { Authorization: `Bearer ${accessToken}` } : {},
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
return createSupabaseAdminAuth(client);
|
|
27
|
+
}
|