@learncard/network-brain-service 3.18.0 → 3.19.1
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/.env.example +38 -2
- package/CHANGELOG.md +118 -0
- package/README.md +42 -0
- package/compose.inbox.yml +7 -0
- package/dist/accesslayer/auth-grant/read.d.ts +1 -0
- package/dist/accesslayer/auth-grant/read.d.ts.map +1 -1
- package/dist/accesslayer/consentflowcontract/relationships/create.d.ts.map +1 -1
- package/dist/accesslayer/consentflowcontract/relationships/update.d.ts.map +1 -1
- package/dist/accesslayer/credential-activity/create.d.ts.map +1 -1
- package/dist/accesslayer/credential-refresh/email-delivery.d.ts +18 -0
- package/dist/accesslayer/credential-refresh/email-delivery.d.ts.map +1 -0
- package/dist/accesslayer/credential-refresh/index.d.ts +1 -0
- package/dist/accesslayer/credential-refresh/index.d.ts.map +1 -1
- package/dist/accesslayer/credential-refresh/read.d.ts.map +1 -1
- package/dist/accesslayer/credential-refresh/update.d.ts.map +1 -1
- package/dist/accesslayer/inbox-batch/store.d.ts +33 -0
- package/dist/accesslayer/inbox-batch/store.d.ts.map +1 -0
- package/dist/accesslayer/inbox-credential/create.d.ts +5 -0
- package/dist/accesslayer/inbox-credential/create.d.ts.map +1 -1
- package/dist/accesslayer/inbox-credential/refresh.d.ts +71 -0
- package/dist/accesslayer/inbox-credential/refresh.d.ts.map +1 -0
- package/dist/accesslayer/inbox-credential/update.d.ts +1 -1
- package/dist/accesslayer/inbox-credential/update.d.ts.map +1 -1
- package/dist/accesslayer/presentation/read.d.ts.map +1 -1
- package/dist/accesslayer/presentation/relationships/create.d.ts +2 -2
- package/dist/accesslayer/presentation/relationships/create.d.ts.map +1 -1
- package/dist/accesslayer/presentation/relationships/read.d.ts.map +1 -1
- package/dist/accesslayer/share-link/abandon.d.ts +3 -0
- package/dist/accesslayer/share-link/abandon.d.ts.map +1 -0
- package/dist/accesslayer/share-link/cleanup.d.ts +6 -0
- package/dist/accesslayer/share-link/cleanup.d.ts.map +1 -0
- package/dist/accesslayer/share-link/errors.d.ts +8 -0
- package/dist/accesslayer/share-link/errors.d.ts.map +1 -0
- package/dist/accesslayer/share-link/finalize.d.ts +3 -0
- package/dist/accesslayer/share-link/finalize.d.ts.map +1 -0
- package/dist/accesslayer/share-link/helpers.d.ts +56 -0
- package/dist/accesslayer/share-link/helpers.d.ts.map +1 -0
- package/dist/accesslayer/share-link/index.d.ts +12 -0
- package/dist/accesslayer/share-link/index.d.ts.map +1 -0
- package/dist/accesslayer/share-link/list.d.ts +5 -0
- package/dist/accesslayer/share-link/list.d.ts.map +1 -0
- package/dist/accesslayer/share-link/read.d.ts +5 -0
- package/dist/accesslayer/share-link/read.d.ts.map +1 -0
- package/dist/accesslayer/share-link/receipt.d.ts +11 -0
- package/dist/accesslayer/share-link/receipt.d.ts.map +1 -0
- package/dist/accesslayer/share-link/recovery.d.ts +6 -0
- package/dist/accesslayer/share-link/recovery.d.ts.map +1 -0
- package/dist/accesslayer/share-link/reserve.d.ts +4 -0
- package/dist/accesslayer/share-link/reserve.d.ts.map +1 -0
- package/dist/accesslayer/share-link/revoke.d.ts +3 -0
- package/dist/accesslayer/share-link/revoke.d.ts.map +1 -0
- package/dist/accesslayer/share-link/transaction-execution.d.ts +18 -0
- package/dist/accesslayer/share-link/transaction-execution.d.ts.map +1 -0
- package/dist/accesslayer/share-link/transaction.d.ts +15 -0
- package/dist/accesslayer/share-link/transaction.d.ts.map +1 -0
- package/dist/accesslayer/share-link/types.d.ts +370 -0
- package/dist/accesslayer/share-link/types.d.ts.map +1 -0
- package/dist/app.d.ts +4 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/cache/atomic-counter.test-helpers.d.ts +3 -0
- package/dist/cache/atomic-counter.test-helpers.d.ts.map +1 -0
- package/dist/cache/atomic-counter.test.d.ts +2 -0
- package/dist/cache/atomic-counter.test.d.ts.map +1 -0
- package/dist/cache/index.d.ts +1 -1
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/config/environment.d.ts +55 -0
- package/dist/config/environment.d.ts.map +1 -1
- package/dist/constants/auth-grant.d.ts +2 -0
- package/dist/constants/auth-grant.d.ts.map +1 -1
- package/dist/credential-refresh.d.ts.map +1 -1
- package/dist/helpers/activity.helpers.d.ts +4 -0
- package/dist/helpers/activity.helpers.d.ts.map +1 -1
- package/dist/helpers/boost.helpers.d.ts.map +1 -1
- package/dist/helpers/contact-method.helpers.d.ts.map +1 -1
- package/dist/helpers/contact-method.helpers.test.d.ts +2 -0
- package/dist/helpers/contact-method.helpers.test.d.ts.map +1 -0
- package/dist/helpers/credential-refresh-email-content.helpers.d.ts +44 -0
- package/dist/helpers/credential-refresh-email-content.helpers.d.ts.map +1 -0
- package/dist/helpers/credential-refresh-email-content.helpers.test.d.ts +2 -0
- package/dist/helpers/credential-refresh-email-content.helpers.test.d.ts.map +1 -0
- package/dist/helpers/credential-refresh-email.helpers.d.ts +17 -0
- package/dist/helpers/credential-refresh-email.helpers.d.ts.map +1 -0
- package/dist/helpers/credential-refresh-proof.helpers.d.ts +4 -0
- package/dist/helpers/credential-refresh-proof.helpers.d.ts.map +1 -0
- package/dist/helpers/credential-refresh-proof.helpers.test.d.ts +2 -0
- package/dist/helpers/credential-refresh-proof.helpers.test.d.ts.map +1 -0
- package/dist/helpers/credential-refresh.helpers.d.ts +45 -2
- package/dist/helpers/credential-refresh.helpers.d.ts.map +1 -1
- package/dist/helpers/credential.helpers.d.ts +2 -1
- package/dist/helpers/credential.helpers.d.ts.map +1 -1
- package/dist/helpers/credentialSubject.helpers.d.ts +3 -0
- package/dist/helpers/credentialSubject.helpers.d.ts.map +1 -0
- package/dist/helpers/credentialSubject.helpers.test.d.ts +2 -0
- package/dist/helpers/credentialSubject.helpers.test.d.ts.map +1 -0
- package/dist/helpers/finalize-inbox.helpers.d.ts.map +1 -1
- package/dist/helpers/inbox-batch-http.helpers.d.ts +15 -0
- package/dist/helpers/inbox-batch-http.helpers.d.ts.map +1 -0
- package/dist/helpers/inbox-batch-http.helpers.test.d.ts +2 -0
- package/dist/helpers/inbox-batch-http.helpers.test.d.ts.map +1 -0
- package/dist/helpers/inbox-batch-status.helpers.d.ts +3 -0
- package/dist/helpers/inbox-batch-status.helpers.d.ts.map +1 -0
- package/dist/helpers/inbox-batch.helpers.d.ts +10 -0
- package/dist/helpers/inbox-batch.helpers.d.ts.map +1 -0
- package/dist/helpers/inbox-batch.helpers.test.d.ts +2 -0
- package/dist/helpers/inbox-batch.helpers.test.d.ts.map +1 -0
- package/dist/helpers/inbox-issuance-error.helpers.d.ts +13 -0
- package/dist/helpers/inbox-issuance-error.helpers.d.ts.map +1 -0
- package/dist/helpers/inbox-queue.helpers.d.ts +11 -0
- package/dist/helpers/inbox-queue.helpers.d.ts.map +1 -0
- package/dist/helpers/inbox-queue.helpers.test.d.ts +2 -0
- package/dist/helpers/inbox-queue.helpers.test.d.ts.map +1 -0
- package/dist/helpers/inbox-refresh.helpers.d.ts +186 -0
- package/dist/helpers/inbox-refresh.helpers.d.ts.map +1 -0
- package/dist/helpers/inbox.helpers.d.ts +9 -1
- package/dist/helpers/inbox.helpers.d.ts.map +1 -1
- package/dist/helpers/notificationMessages.d.ts +1 -1
- package/dist/helpers/notificationMessages.d.ts.map +1 -1
- package/dist/helpers/notifications.helpers.d.ts.map +1 -1
- package/dist/helpers/presentation-metadata.d.ts +4 -0
- package/dist/helpers/presentation-metadata.d.ts.map +1 -0
- package/dist/helpers/presentation.helpers.d.ts +1 -1
- package/dist/helpers/presentation.helpers.d.ts.map +1 -1
- package/dist/helpers/profile.helpers.d.ts +1 -0
- package/dist/helpers/profile.helpers.d.ts.map +1 -1
- package/dist/helpers/rateLimit.helpers.d.ts.map +1 -1
- package/dist/helpers/refresh-send-intent.helpers.d.ts +51 -0
- package/dist/helpers/refresh-send-intent.helpers.d.ts.map +1 -0
- package/dist/helpers/share-content-client/adapters.d.ts +10 -0
- package/dist/helpers/share-content-client/adapters.d.ts.map +1 -0
- package/dist/helpers/share-content-client/canonical.d.ts +7 -0
- package/dist/helpers/share-content-client/canonical.d.ts.map +1 -0
- package/dist/helpers/share-content-client/client.d.ts +5 -0
- package/dist/helpers/share-content-client/client.d.ts.map +1 -0
- package/dist/helpers/share-content-client/config.d.ts +11 -0
- package/dist/helpers/share-content-client/config.d.ts.map +1 -0
- package/dist/helpers/share-content-client/index.d.ts +6 -0
- package/dist/helpers/share-content-client/index.d.ts.map +1 -0
- package/dist/helpers/share-content-client/responses.d.ts +16 -0
- package/dist/helpers/share-content-client/responses.d.ts.map +1 -0
- package/dist/helpers/share-content-client/types.d.ts +145 -0
- package/dist/helpers/share-content-client/types.d.ts.map +1 -0
- package/dist/helpers/share-link-coordinator/budget-helpers.d.ts +5 -0
- package/dist/helpers/share-link-coordinator/budget-helpers.d.ts.map +1 -0
- package/dist/helpers/share-link-coordinator/cleanup-runner.d.ts +3 -0
- package/dist/helpers/share-link-coordinator/cleanup-runner.d.ts.map +1 -0
- package/dist/helpers/share-link-coordinator/coordinator.d.ts +4 -0
- package/dist/helpers/share-link-coordinator/coordinator.d.ts.map +1 -0
- package/dist/helpers/share-link-coordinator/index.d.ts +5 -0
- package/dist/helpers/share-link-coordinator/index.d.ts.map +1 -0
- package/dist/helpers/share-link-coordinator/recovery-runner.d.ts +9 -0
- package/dist/helpers/share-link-coordinator/recovery-runner.d.ts.map +1 -0
- package/dist/helpers/share-link-coordinator/runtime.d.ts +11 -0
- package/dist/helpers/share-link-coordinator/runtime.d.ts.map +1 -0
- package/dist/helpers/share-link-coordinator/stat.d.ts +4 -0
- package/dist/helpers/share-link-coordinator/stat.d.ts.map +1 -0
- package/dist/helpers/share-link-coordinator/types.d.ts +160 -0
- package/dist/helpers/share-link-coordinator/types.d.ts.map +1 -0
- package/dist/helpers/share-link-lifecycle/index.d.ts +5 -0
- package/dist/helpers/share-link-lifecycle/index.d.ts.map +1 -0
- package/dist/helpers/share-link-lifecycle/lease.helpers.d.ts +4 -0
- package/dist/helpers/share-link-lifecycle/lease.helpers.d.ts.map +1 -0
- package/dist/helpers/share-link-lifecycle/recovery.helpers.d.ts +21 -0
- package/dist/helpers/share-link-lifecycle/recovery.helpers.d.ts.map +1 -0
- package/dist/helpers/share-link-lifecycle/request-hash.helpers.d.ts +9 -0
- package/dist/helpers/share-link-lifecycle/request-hash.helpers.d.ts.map +1 -0
- package/dist/helpers/share-link-lifecycle/types.d.ts +14 -0
- package/dist/helpers/share-link-lifecycle/types.d.ts.map +1 -0
- package/dist/helpers/share-link-maintenance/budget.d.ts +12 -0
- package/dist/helpers/share-link-maintenance/budget.d.ts.map +1 -0
- package/dist/helpers/share-link-maintenance/config.d.ts +48 -0
- package/dist/helpers/share-link-maintenance/config.d.ts.map +1 -0
- package/dist/helpers/share-link-maintenance/index.d.ts +8 -0
- package/dist/helpers/share-link-maintenance/index.d.ts.map +1 -0
- package/dist/helpers/share-link-maintenance/runner.d.ts +19 -0
- package/dist/helpers/share-link-maintenance/runner.d.ts.map +1 -0
- package/dist/helpers/share-link-maintenance/runtime.d.ts +36 -0
- package/dist/helpers/share-link-maintenance/runtime.d.ts.map +1 -0
- package/dist/helpers/share-link-maintenance/scheduler.d.ts +18 -0
- package/dist/helpers/share-link-maintenance/scheduler.d.ts.map +1 -0
- package/dist/helpers/share-link-maintenance/telemetry.d.ts +5 -0
- package/dist/helpers/share-link-maintenance/telemetry.d.ts.map +1 -0
- package/dist/helpers/share-link-maintenance/types.d.ts +53 -0
- package/dist/helpers/share-link-maintenance/types.d.ts.map +1 -0
- package/dist/helpers/share-link-owner/config.d.ts +16 -0
- package/dist/helpers/share-link-owner/config.d.ts.map +1 -0
- package/dist/helpers/share-link-owner/diagnostics.d.ts +26 -0
- package/dist/helpers/share-link-owner/diagnostics.d.ts.map +1 -0
- package/dist/helpers/share-link-owner/lazy-initializer.d.ts +2 -0
- package/dist/helpers/share-link-owner/lazy-initializer.d.ts.map +1 -0
- package/dist/helpers/share-link-owner-projection.d.ts +4 -0
- package/dist/helpers/share-link-owner-projection.d.ts.map +1 -0
- package/dist/helpers/share-link-passcode-abuse.d.ts +2 -0
- package/dist/helpers/share-link-passcode-abuse.d.ts.map +1 -0
- package/dist/helpers/share-link-passcode.d.ts +6 -0
- package/dist/helpers/share-link-passcode.d.ts.map +1 -0
- package/dist/helpers/share-link-policy/index.d.ts +4 -0
- package/dist/helpers/share-link-policy/index.d.ts.map +1 -0
- package/dist/helpers/share-link-policy/production.d.ts +13 -0
- package/dist/helpers/share-link-policy/production.d.ts.map +1 -0
- package/dist/helpers/share-link-policy/resolver.d.ts +6 -0
- package/dist/helpers/share-link-policy/resolver.d.ts.map +1 -0
- package/dist/helpers/share-link-policy/types.d.ts +16 -0
- package/dist/helpers/share-link-policy/types.d.ts.map +1 -0
- package/dist/helpers/share-link-public/config.d.ts +13 -0
- package/dist/helpers/share-link-public/config.d.ts.map +1 -0
- package/dist/helpers/share-link-view-notification.d.ts +2 -0
- package/dist/helpers/share-link-view-notification.d.ts.map +1 -0
- package/dist/helpers/shim.d.ts +1 -1
- package/dist/helpers/shim.d.ts.map +1 -1
- package/dist/inbox-queue-local.d.ts +2 -0
- package/dist/inbox-queue-local.d.ts.map +1 -0
- package/dist/index.js +2 -2
- package/dist/models/AuthGrant.d.ts.map +1 -1
- package/dist/models/CredentialActivity.d.ts +1 -0
- package/dist/models/CredentialActivity.d.ts.map +1 -1
- package/dist/models/CredentialRefresh.d.ts +5 -2
- package/dist/models/CredentialRefresh.d.ts.map +1 -1
- package/dist/models/InboxCredential.d.ts +1 -0
- package/dist/models/InboxCredential.d.ts.map +1 -1
- package/dist/models/Presentation.d.ts +2 -0
- package/dist/models/Presentation.d.ts.map +1 -1
- package/dist/models/Profile.d.ts +2 -0
- package/dist/models/Profile.d.ts.map +1 -1
- package/dist/models/ShareLink.d.ts +44 -0
- package/dist/models/ShareLink.d.ts.map +1 -0
- package/dist/models/ShareViewReceipt.d.ts +22 -0
- package/dist/models/ShareViewReceipt.d.ts.map +1 -0
- package/dist/models/credential-refresh-constraints.d.ts.map +1 -1
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/share-link-constraints.d.ts +3 -0
- package/dist/models/share-link-constraints.d.ts.map +1 -0
- package/dist/openapi.d.ts.map +1 -1
- package/dist/public-share-link-http.d.ts +4 -0
- package/dist/public-share-link-http.d.ts.map +1 -0
- package/dist/routes/act-as.test.d.ts +2 -0
- package/dist/routes/act-as.test.d.ts.map +1 -0
- package/dist/routes/activity.d.ts +3 -0
- package/dist/routes/activity.d.ts.map +1 -1
- package/dist/routes/app-store.d.ts.map +1 -1
- package/dist/routes/auth-grants.d.ts +10 -0
- package/dist/routes/auth-grants.d.ts.map +1 -1
- package/dist/routes/boosts.d.ts +494 -0
- package/dist/routes/boosts.d.ts.map +1 -1
- package/dist/routes/contracts.d.ts +2 -2
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/credential-refreshes.d.ts.map +1 -1
- package/dist/routes/credentials.d.ts +1 -1
- package/dist/routes/credentials.d.ts.map +1 -1
- package/dist/routes/inbox.d.ts +953 -11
- package/dist/routes/inbox.d.ts.map +1 -1
- package/dist/routes/index.d.ts +154 -85
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/presentations.d.ts +1 -0
- package/dist/routes/presentations.d.ts.map +1 -1
- package/dist/routes/profile-manager.d.ts.map +1 -1
- package/dist/routes/profiles.d.ts.map +1 -1
- package/dist/routes/public-share-links.d.ts +230 -0
- package/dist/routes/public-share-links.d.ts.map +1 -0
- package/dist/routes/share-links.d.ts +844 -0
- package/dist/routes/share-links.d.ts.map +1 -0
- package/dist/routes/workflows.d.ts.map +1 -1
- package/dist/services/delivery/adapters/postmark.adapter.d.ts.map +1 -1
- package/dist/services/delivery/adapters/postmark.adapter.test.d.ts +2 -0
- package/dist/services/delivery/adapters/postmark.adapter.test.d.ts.map +1 -0
- package/dist/services/registry/registry.factory.d.ts.map +1 -1
- package/dist/types/activity.d.ts +4 -0
- package/dist/types/activity.d.ts.map +1 -1
- package/dist/types/consentflowcontract.d.ts +1 -1
- package/dist/types/credential-refresh.d.ts +10 -1
- package/dist/types/credential-refresh.d.ts.map +1 -1
- package/dist/types/inbox-batch.d.ts +38 -0
- package/dist/types/inbox-batch.d.ts.map +1 -0
- package/inbox-e2e-setup.ts +53 -1
- package/inbox-elasticmq.conf +10 -0
- package/lambda.ts +64 -16
- package/package.json +24 -16
- package/scripts/seed-demo-persona.ts +425 -0
- package/scripts/setup-inbox-queues.ts +60 -0
- package/serverless-local.yml +2 -0
- package/serverless.yml +111 -0
- package/shareLinkMaintenanceLambda.ts +49 -0
- package/src/accesslayer/auth-grant/read.ts +2 -1
- package/src/accesslayer/consentflowcontract/relationships/create.ts +9 -16
- package/src/accesslayer/consentflowcontract/relationships/update.ts +15 -28
- package/src/accesslayer/credential-activity/create.ts +1 -0
- package/src/accesslayer/credential-refresh/email-delivery.ts +116 -0
- package/src/accesslayer/credential-refresh/index.ts +1 -0
- package/src/accesslayer/credential-refresh/read.ts +8 -2
- package/src/accesslayer/credential-refresh/update.ts +4 -0
- package/src/accesslayer/inbox-batch/store.ts +469 -0
- package/src/accesslayer/inbox-credential/create.ts +51 -19
- package/src/accesslayer/inbox-credential/refresh.ts +221 -0
- package/src/accesslayer/inbox-credential/update.ts +1 -1
- package/src/accesslayer/presentation/read.ts +57 -25
- package/src/accesslayer/presentation/relationships/create.ts +54 -11
- package/src/accesslayer/presentation/relationships/read.ts +21 -6
- package/src/accesslayer/share-link/abandon.ts +100 -0
- package/src/accesslayer/share-link/cleanup.ts +271 -0
- package/src/accesslayer/share-link/errors.ts +32 -0
- package/src/accesslayer/share-link/finalize.ts +265 -0
- package/src/accesslayer/share-link/helpers.ts +419 -0
- package/src/accesslayer/share-link/index.ts +11 -0
- package/src/accesslayer/share-link/list.ts +162 -0
- package/src/accesslayer/share-link/read.ts +107 -0
- package/src/accesslayer/share-link/receipt.ts +548 -0
- package/src/accesslayer/share-link/recovery.ts +545 -0
- package/src/accesslayer/share-link/reserve.ts +684 -0
- package/src/accesslayer/share-link/revoke.ts +197 -0
- package/src/accesslayer/share-link/transaction-execution.ts +72 -0
- package/src/accesslayer/share-link/transaction.ts +126 -0
- package/src/accesslayer/share-link/types.ts +601 -0
- package/src/app.ts +6 -0
- package/src/cache/atomic-counter.test-helpers.ts +27 -0
- package/src/cache/atomic-counter.test.ts +6 -0
- package/src/cache/index.ts +25 -13
- package/src/config/environment.ts +40 -0
- package/src/constants/auth-grant.ts +5 -0
- package/src/credential-refresh.ts +5 -1
- package/src/docker-entry.ts +65 -0
- package/src/helpers/activity.helpers.ts +4 -0
- package/src/helpers/app-counter.helpers.ts +1 -1
- package/src/helpers/boost.helpers.ts +4 -31
- package/src/helpers/contact-method.helpers.test.ts +43 -0
- package/src/helpers/contact-method.helpers.ts +3 -4
- package/src/helpers/credential-refresh-email-content.helpers.test.ts +222 -0
- package/src/helpers/credential-refresh-email-content.helpers.ts +155 -0
- package/src/helpers/credential-refresh-email.helpers.ts +201 -0
- package/src/helpers/credential-refresh-proof.helpers.test.ts +103 -0
- package/src/helpers/credential-refresh-proof.helpers.ts +43 -0
- package/src/helpers/credential-refresh.helpers.ts +375 -99
- package/src/helpers/credential.helpers.ts +4 -1
- package/src/helpers/credentialSubject.helpers.test.ts +114 -0
- package/src/helpers/credentialSubject.helpers.ts +40 -0
- package/src/helpers/finalize-inbox.helpers.ts +29 -14
- package/src/helpers/inbox-batch-http.helpers.test.ts +188 -0
- package/src/helpers/inbox-batch-http.helpers.ts +150 -0
- package/src/helpers/inbox-batch-status.helpers.ts +11 -0
- package/src/helpers/inbox-batch.helpers.test.ts +668 -0
- package/src/helpers/inbox-batch.helpers.ts +374 -0
- package/src/helpers/inbox-issuance-error.helpers.ts +25 -0
- package/src/helpers/inbox-queue.helpers.test.ts +253 -0
- package/src/helpers/inbox-queue.helpers.ts +372 -0
- package/src/helpers/inbox-refresh.helpers.ts +432 -0
- package/src/helpers/inbox.helpers.ts +275 -36
- package/src/helpers/notificationMessages.ts +18 -1
- package/src/helpers/notifications.helpers.ts +4 -2
- package/src/helpers/presentation-metadata.ts +41 -0
- package/src/helpers/presentation.helpers.ts +27 -20
- package/src/helpers/profile.helpers.ts +7 -0
- package/src/helpers/rateLimit.helpers.ts +2 -5
- package/src/helpers/refresh-send-intent.helpers.ts +273 -0
- package/src/helpers/share-content-client/adapters.ts +55 -0
- package/src/helpers/share-content-client/canonical.ts +25 -0
- package/src/helpers/share-content-client/client.ts +440 -0
- package/src/helpers/share-content-client/config.ts +189 -0
- package/src/helpers/share-content-client/index.ts +27 -0
- package/src/helpers/share-content-client/responses.ts +273 -0
- package/src/helpers/share-content-client/types.ts +253 -0
- package/src/helpers/share-link-coordinator/budget-helpers.ts +53 -0
- package/src/helpers/share-link-coordinator/cleanup-runner.ts +286 -0
- package/src/helpers/share-link-coordinator/coordinator.ts +714 -0
- package/src/helpers/share-link-coordinator/index.ts +8 -0
- package/src/helpers/share-link-coordinator/recovery-runner.ts +428 -0
- package/src/helpers/share-link-coordinator/runtime.ts +88 -0
- package/src/helpers/share-link-coordinator/stat.ts +30 -0
- package/src/helpers/share-link-coordinator/types.ts +353 -0
- package/src/helpers/share-link-lifecycle/index.ts +4 -0
- package/src/helpers/share-link-lifecycle/lease.helpers.ts +35 -0
- package/src/helpers/share-link-lifecycle/recovery.helpers.ts +173 -0
- package/src/helpers/share-link-lifecycle/request-hash.helpers.ts +130 -0
- package/src/helpers/share-link-lifecycle/types.ts +58 -0
- package/src/helpers/share-link-maintenance/budget.ts +63 -0
- package/src/helpers/share-link-maintenance/config.ts +312 -0
- package/src/helpers/share-link-maintenance/index.ts +24 -0
- package/src/helpers/share-link-maintenance/runner.ts +223 -0
- package/src/helpers/share-link-maintenance/runtime.ts +334 -0
- package/src/helpers/share-link-maintenance/scheduler.ts +126 -0
- package/src/helpers/share-link-maintenance/telemetry.ts +70 -0
- package/src/helpers/share-link-maintenance/types.ts +89 -0
- package/src/helpers/share-link-owner/config.ts +48 -0
- package/src/helpers/share-link-owner/diagnostics.ts +89 -0
- package/src/helpers/share-link-owner/lazy-initializer.ts +29 -0
- package/src/helpers/share-link-owner-projection.ts +52 -0
- package/src/helpers/share-link-passcode-abuse.ts +36 -0
- package/src/helpers/share-link-passcode.ts +47 -0
- package/src/helpers/share-link-policy/index.ts +7 -0
- package/src/helpers/share-link-policy/production.ts +88 -0
- package/src/helpers/share-link-policy/resolver.ts +108 -0
- package/src/helpers/share-link-policy/types.ts +48 -0
- package/src/helpers/share-link-public/config.ts +41 -0
- package/src/helpers/share-link-view-notification.ts +18 -0
- package/src/helpers/shim.ts +32 -31
- package/src/inbox-queue-local.ts +28 -0
- package/src/models/AuthGrant.ts +1 -0
- package/src/models/CredentialActivity.ts +3 -5
- package/src/models/CredentialRefresh.ts +4 -2
- package/src/models/InboxCredential.ts +2 -0
- package/src/models/Presentation.ts +2 -2
- package/src/models/Profile.ts +3 -2
- package/src/models/ShareLink.ts +130 -0
- package/src/models/ShareViewReceipt.ts +69 -0
- package/src/models/credential-refresh-constraints.test.ts +8 -3
- package/src/models/credential-refresh-constraints.ts +5 -0
- package/src/models/index.ts +2 -0
- package/src/models/share-link-constraints.ts +93 -0
- package/src/openapi.ts +8 -0
- package/src/public-share-link-http.ts +49 -0
- package/src/routes/act-as.test.ts +239 -0
- package/src/routes/app-store.ts +4 -13
- package/src/routes/auth-grants.ts +13 -11
- package/src/routes/boosts.ts +916 -103
- package/src/routes/contracts.ts +2 -11
- package/src/routes/credential-refreshes.test.ts +8 -2
- package/src/routes/credential-refreshes.ts +4 -1
- package/src/routes/credentials.ts +2 -1
- package/src/routes/inbox.ts +95 -49
- package/src/routes/index.ts +216 -46
- package/src/routes/presentations.ts +19 -3
- package/src/routes/profile-manager.ts +10 -2
- package/src/routes/profiles.ts +17 -6
- package/src/routes/public-share-links.ts +814 -0
- package/src/routes/share-links.ts +640 -0
- package/src/routes/skills.ts +1 -1
- package/src/routes/workflows.ts +43 -24
- package/src/services/delivery/adapters/postmark.adapter.test.ts +54 -0
- package/src/services/delivery/adapters/postmark.adapter.ts +16 -1
- package/src/services/registry/registry.factory.ts +2 -1
- package/src/types/activity.ts +2 -0
- package/src/types/credential-refresh.ts +21 -2
- package/src/types/inbox-batch.ts +46 -0
- package/test/atomic-counter.e2e.ts +12 -0
- package/test/auth-grant.spec.ts +21 -21
- package/test/credential-refresh-email.spec.ts +663 -0
- package/test/credential-refresh-publication.spec.ts +2 -0
- package/test/dids.spec.ts +10 -1
- package/test/guardian-gated-routes.spec.ts +13 -0
- package/test/helpers/inbox-e2e-environment.ts +6 -0
- package/test/helpers/share-link-fixtures.ts +94 -0
- package/test/inbox-batch.spec.ts +1338 -0
- package/test/inbox-refresh.spec.ts +534 -0
- package/test/managed-recipient-inbox.spec.ts +130 -0
- package/test/notificationMessages.spec.ts +13 -0
- package/test/openapi.spec.ts +61 -1
- package/test/presentations.spec.ts +54 -6
- package/test/profiles.spec.ts +67 -1
- package/test/refresh-send.spec.ts +1799 -0
- package/test/registry.spec.ts +56 -11
- package/test/share-content-client.contract.spec.ts +365 -0
- package/test/share-content-client.unit.spec.ts +462 -0
- package/test/share-link-abuse.unit.spec.ts +65 -0
- package/test/share-link-coordinator.neo4j.spec.ts +684 -0
- package/test/share-link-coordinator.unit.spec.ts +990 -0
- package/test/share-link-dependency-diagnostics.unit.spec.ts +127 -0
- package/test/share-link-lifecycle.neo4j.spec.ts +1268 -0
- package/test/share-link-lifecycle.unit.spec.ts +205 -0
- package/test/share-link-list-cursor.unit.spec.ts +86 -0
- package/test/share-link-list.neo4j.spec.ts +324 -0
- package/test/share-link-maintenance.neo4j.spec.ts +355 -0
- package/test/share-link-maintenance.unit.spec.ts +1113 -0
- package/test/share-link-owner-policy.unit.spec.ts +210 -0
- package/test/share-link-owner-route.unit.spec.ts +752 -0
- package/test/share-link-owner-runtime.unit.spec.ts +102 -0
- package/test/share-link-passcode.unit.spec.ts +29 -0
- package/test/share-link-policy.unit.spec.ts +135 -0
- package/test/share-link-presentation-metadata.unit.spec.ts +49 -0
- package/test/share-link-production-policy.unit.spec.ts +77 -0
- package/test/share-link-public-config.unit.spec.ts +64 -0
- package/test/share-link-public-http-adapter.unit.spec.ts +315 -0
- package/test/share-link-public-route.unit.spec.ts +800 -0
- package/test/share-link-receipt.neo4j.spec.ts +943 -0
- package/test/share-link-recovery.neo4j.spec.ts +935 -0
- package/test/share-link-recovery.unit.spec.ts +726 -0
- package/vitest.config.ts +10 -0
- package/vitest.inbox-e2e.config.ts +5 -1
- package/vitest.integration.config.ts +2 -0
- package/vitest.share-links-neo4j.config.ts +19 -0
- package/vitest.share-links-unit.config.ts +28 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import {
|
|
3
|
+
SQSClient,
|
|
4
|
+
SendMessageBatchCommand,
|
|
5
|
+
ReceiveMessageCommand,
|
|
6
|
+
DeleteMessageCommand,
|
|
7
|
+
} from '@aws-sdk/client-sqs';
|
|
8
|
+
import { TRPCError } from '@trpc/server';
|
|
9
|
+
import type {
|
|
10
|
+
InboxBatchReceipt,
|
|
11
|
+
InboxBatchStatus,
|
|
12
|
+
IssueInboxCredentialBatch,
|
|
13
|
+
IssueInboxCredentialBatchItemResult,
|
|
14
|
+
} from '@learncard/types';
|
|
15
|
+
import { getInboxBatchRuntimeEnvironment } from '@environment';
|
|
16
|
+
import type { Context } from '@routes';
|
|
17
|
+
import type { ProfileType } from 'types/profile';
|
|
18
|
+
import type { BatchJobPayload } from 'types/inbox-batch';
|
|
19
|
+
import { getProfileByProfileId } from '@accesslayer/profile/read';
|
|
20
|
+
import {
|
|
21
|
+
batchReplayStore,
|
|
22
|
+
claimBatchItem,
|
|
23
|
+
createBatchJob,
|
|
24
|
+
finishBatchItem,
|
|
25
|
+
markBatchIssuanceStarted,
|
|
26
|
+
readBatchJob,
|
|
27
|
+
recoverInboxJobs,
|
|
28
|
+
takeInboxDispatches,
|
|
29
|
+
} from '@accesslayer/inbox-batch/store';
|
|
30
|
+
import { acknowledgeInboxDispatches, deadLetterBatchItem } from '@accesslayer/inbox-batch/store';
|
|
31
|
+
import { encryptInboxCredential, decryptInboxCredential } from './inbox-encryption.helpers';
|
|
32
|
+
import { fingerprint, issueInboxBatch } from './inbox-batch.helpers';
|
|
33
|
+
import { INBOX_BATCH_MAX_BYTES } from './inbox-batch-http.helpers';
|
|
34
|
+
import { getInboxBatchState } from './inbox-batch-status.helpers';
|
|
35
|
+
|
|
36
|
+
const queue = (): { client: SQSClient; url: string } => {
|
|
37
|
+
const env = getInboxBatchRuntimeEnvironment();
|
|
38
|
+
if (!env.INBOX_QUEUE_URL)
|
|
39
|
+
throw new TRPCError({
|
|
40
|
+
code: 'INTERNAL_SERVER_ERROR',
|
|
41
|
+
message: 'Inbox queue is not configured.',
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
url: env.INBOX_QUEUE_URL,
|
|
45
|
+
client: new SQSClient({
|
|
46
|
+
region: env.AWS_REGION ?? 'us-east-1',
|
|
47
|
+
...(env.INBOX_QUEUE_ENDPOINT
|
|
48
|
+
? {
|
|
49
|
+
endpoint: env.INBOX_QUEUE_ENDPOINT,
|
|
50
|
+
credentials: { accessKeyId: 'local', secretAccessKey: 'local' },
|
|
51
|
+
}
|
|
52
|
+
: {}),
|
|
53
|
+
}),
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** Only durable admission happens here. The dispatcher owns publication, including retries. */
|
|
58
|
+
export const submitInboxBatch = async (
|
|
59
|
+
profile: ProfileType,
|
|
60
|
+
batch: IssueInboxCredentialBatch,
|
|
61
|
+
ctx: Context
|
|
62
|
+
): Promise<InboxBatchReceipt> => {
|
|
63
|
+
if (Buffer.byteLength(JSON.stringify(batch), 'utf8') > INBOX_BATCH_MAX_BYTES)
|
|
64
|
+
throw new TRPCError({
|
|
65
|
+
code: 'PAYLOAD_TOO_LARGE',
|
|
66
|
+
message: 'Inbox batch exceeds the 4 MiB JSON payload limit',
|
|
67
|
+
});
|
|
68
|
+
if (!getInboxBatchRuntimeEnvironment().INBOX_QUEUE_URL)
|
|
69
|
+
throw new TRPCError({
|
|
70
|
+
code: 'INTERNAL_SERVER_ERROR',
|
|
71
|
+
message: 'Inbox queue is not configured.',
|
|
72
|
+
});
|
|
73
|
+
const seen = new Set<string>();
|
|
74
|
+
const items = await Promise.all(
|
|
75
|
+
batch.items.map(async item => {
|
|
76
|
+
const duplicate = item.idempotencyKey !== undefined && seen.has(item.idempotencyKey);
|
|
77
|
+
if (item.idempotencyKey !== undefined) seen.add(item.idempotencyKey);
|
|
78
|
+
return {
|
|
79
|
+
duplicate,
|
|
80
|
+
correlation: await encryptInboxCredential(
|
|
81
|
+
JSON.stringify({
|
|
82
|
+
idempotencyKey: item.idempotencyKey,
|
|
83
|
+
recipient: item.recipient,
|
|
84
|
+
})
|
|
85
|
+
),
|
|
86
|
+
replayKey:
|
|
87
|
+
item.idempotencyKey === undefined
|
|
88
|
+
? `internal:${randomUUID()}`
|
|
89
|
+
: `client:${fingerprint([profile.profileId, item.idempotencyKey])}`,
|
|
90
|
+
};
|
|
91
|
+
})
|
|
92
|
+
);
|
|
93
|
+
const configuredLimit = Number(getInboxBatchRuntimeEnvironment().INBOX_BATCH_ITEMS_PER_HOUR);
|
|
94
|
+
return createBatchJob({
|
|
95
|
+
issuer: profile.profileId,
|
|
96
|
+
requestId: batch.requestId,
|
|
97
|
+
requestHash: fingerprint({ batch, domain: ctx.domain, tenant: ctx.tenant?.id }),
|
|
98
|
+
payload: await encryptInboxCredential(
|
|
99
|
+
JSON.stringify({
|
|
100
|
+
batch,
|
|
101
|
+
context: { domain: ctx.domain, tenant: ctx.tenant },
|
|
102
|
+
scope: ctx.user?.scope,
|
|
103
|
+
} satisfies BatchJobPayload)
|
|
104
|
+
),
|
|
105
|
+
items,
|
|
106
|
+
limit:
|
|
107
|
+
Number.isSafeInteger(configuredLimit) && configuredLimit > 0 ? configuredLimit : 10_000,
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const getInboxBatch = async (issuer: string, batchId: string): Promise<InboxBatchStatus> => {
|
|
112
|
+
const { job, items } = await readBatchJob(batchId, issuer);
|
|
113
|
+
const entries = await Promise.all(
|
|
114
|
+
items.map(async item => {
|
|
115
|
+
const state = item.state as InboxBatchStatus['items'][number]['state'];
|
|
116
|
+
let result: IssueInboxCredentialBatchItemResult | undefined;
|
|
117
|
+
if (item.result)
|
|
118
|
+
result = {
|
|
119
|
+
...JSON.parse(await decryptInboxCredential(item.result)),
|
|
120
|
+
index: Number(item.index),
|
|
121
|
+
};
|
|
122
|
+
else if (state === 'NEEDS_RECONCILIATION' || state === 'COMPLETED')
|
|
123
|
+
result = {
|
|
124
|
+
success: false,
|
|
125
|
+
index: Number(item.index),
|
|
126
|
+
error: {
|
|
127
|
+
code:
|
|
128
|
+
state === 'NEEDS_RECONCILIATION' ? 'CONFLICT' : 'INTERNAL_SERVER_ERROR',
|
|
129
|
+
...(state === 'NEEDS_RECONCILIATION'
|
|
130
|
+
? { reason: 'UNCONFIRMED' as const }
|
|
131
|
+
: {}),
|
|
132
|
+
message:
|
|
133
|
+
state === 'NEEDS_RECONCILIATION'
|
|
134
|
+
? 'Issuance outcome is unconfirmed. Keep this key and contact support for reconciliation.'
|
|
135
|
+
: 'Processing could not be completed after worker failures or queue delivery exhaustion.',
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
if (result && item.correlation) {
|
|
139
|
+
const correlation = JSON.parse(await decryptInboxCredential(item.correlation));
|
|
140
|
+
result = {
|
|
141
|
+
...result,
|
|
142
|
+
recipient: correlation.recipient,
|
|
143
|
+
// Recovery may read a replay containing an internal key for an unkeyed item.
|
|
144
|
+
idempotencyKey: correlation.idempotencyKey,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return { index: Number(item.index), state, ...(result ? { result } : {}) };
|
|
148
|
+
})
|
|
149
|
+
);
|
|
150
|
+
const completed = entries.filter(
|
|
151
|
+
i => i.state === 'COMPLETED' || i.state === 'NEEDS_RECONCILIATION'
|
|
152
|
+
).length;
|
|
153
|
+
const unconfirmed = entries.filter(i => i.state === 'NEEDS_RECONCILIATION').length;
|
|
154
|
+
const succeeded = entries.filter(i => i.result?.success).length;
|
|
155
|
+
return {
|
|
156
|
+
batchId,
|
|
157
|
+
createdAt: new Date(Number(job.createdAt)).toISOString(),
|
|
158
|
+
status: getInboxBatchState(entries.map(item => item.state)),
|
|
159
|
+
done: completed === entries.length,
|
|
160
|
+
items: entries,
|
|
161
|
+
summary: {
|
|
162
|
+
total: entries.length,
|
|
163
|
+
succeeded,
|
|
164
|
+
failed: entries.filter(i => i.state === 'COMPLETED' && i.result && !i.result.success)
|
|
165
|
+
.length,
|
|
166
|
+
deduplicated: entries.filter(i => i.result?.success && i.result.deduplicated).length,
|
|
167
|
+
completed,
|
|
168
|
+
pending: entries.length - completed,
|
|
169
|
+
unconfirmed,
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/** SQS is at-least-once. Ownership and issuance checkpoints, not delivery count, control execution. */
|
|
175
|
+
export const processInboxQueueMessage = async (body: string): Promise<void> => {
|
|
176
|
+
const message: unknown = JSON.parse(body);
|
|
177
|
+
if (
|
|
178
|
+
!message ||
|
|
179
|
+
typeof message !== 'object' ||
|
|
180
|
+
!('itemId' in message) ||
|
|
181
|
+
typeof message.itemId !== 'string'
|
|
182
|
+
)
|
|
183
|
+
throw new Error('Invalid inbox queue message');
|
|
184
|
+
const owner = randomUUID();
|
|
185
|
+
const claimed = await claimBatchItem(message.itemId, owner);
|
|
186
|
+
if (!claimed) return;
|
|
187
|
+
const { job, item } = claimed;
|
|
188
|
+
const fail = (code: string, text: string): IssueInboxCredentialBatchItemResult => ({
|
|
189
|
+
success: false,
|
|
190
|
+
index: Number(item.index),
|
|
191
|
+
error: {
|
|
192
|
+
code,
|
|
193
|
+
message: text,
|
|
194
|
+
...(item.duplicate ? { reason: 'DUPLICATE_KEY' as const } : {}),
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
if (item.duplicate) {
|
|
198
|
+
await finishBatchItem(
|
|
199
|
+
item.id,
|
|
200
|
+
owner,
|
|
201
|
+
fail(
|
|
202
|
+
'CONFLICT',
|
|
203
|
+
'Duplicate idempotency key in this batch. Only its first occurrence is attempted.'
|
|
204
|
+
)
|
|
205
|
+
);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const payload = JSON.parse(await decryptInboxCredential(job.payload)) as BatchJobPayload;
|
|
209
|
+
const profile = await getProfileByProfileId(job.issuer);
|
|
210
|
+
if (!profile) {
|
|
211
|
+
await finishBatchItem(
|
|
212
|
+
item.id,
|
|
213
|
+
owner,
|
|
214
|
+
fail('NOT_FOUND', 'Issuer profile no longer exists.')
|
|
215
|
+
);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const input = payload.batch.items[Number(item.index)]!;
|
|
219
|
+
const result = await issueInboxBatch(
|
|
220
|
+
profile,
|
|
221
|
+
{
|
|
222
|
+
configuration: payload.batch.configuration,
|
|
223
|
+
// Internal keys protect unkeyed items against SQS redelivery without deduplicating new submissions.
|
|
224
|
+
items: [{ ...input, idempotencyKey: input.idempotencyKey ?? item.id }],
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
...payload.context,
|
|
228
|
+
user: { did: profile.did, isChallengeValid: true, scope: payload.scope },
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
cache: batchReplayStore(item.id, owner, item.replayKey),
|
|
232
|
+
beforeIssue: () => markBatchIssuanceStarted(item.id, owner),
|
|
233
|
+
}
|
|
234
|
+
);
|
|
235
|
+
await finishBatchItem(item.id, owner, {
|
|
236
|
+
...result.results[0]!,
|
|
237
|
+
index: Number(item.index),
|
|
238
|
+
idempotencyKey: input.idempotencyKey,
|
|
239
|
+
});
|
|
240
|
+
console.info('Inbox item processed', {
|
|
241
|
+
batchId: job.id,
|
|
242
|
+
index: Number(item.index),
|
|
243
|
+
success: result.results[0]!.success,
|
|
244
|
+
queueAgeMs: Date.now() - Number(job.createdAt),
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export const processInboxDeadLetter = async (body: string): Promise<void> => {
|
|
249
|
+
let message: unknown;
|
|
250
|
+
try {
|
|
251
|
+
message = JSON.parse(body);
|
|
252
|
+
} catch {
|
|
253
|
+
console.error('Discarding malformed inbox dead-letter JSON');
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
if (
|
|
257
|
+
!message ||
|
|
258
|
+
typeof message !== 'object' ||
|
|
259
|
+
!('itemId' in message) ||
|
|
260
|
+
typeof message.itemId !== 'string'
|
|
261
|
+
) {
|
|
262
|
+
console.error('Discarding malformed inbox dead-letter message');
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
await deadLetterBatchItem(message.itemId);
|
|
266
|
+
console.error('Inbox dead-letter recorded', { itemId: message.itemId });
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
export const dispatchInboxJobs = async (
|
|
270
|
+
maintenanceDeadline = Date.now() + 20_000
|
|
271
|
+
): Promise<void> => {
|
|
272
|
+
const { client, url } = queue();
|
|
273
|
+
try {
|
|
274
|
+
// Publish before maintenance: an unavailable recovery path must not stall new work.
|
|
275
|
+
// Recovered items become dispatchable here but wait for the next one-minute invocation,
|
|
276
|
+
// because this run has already claimed its publication set.
|
|
277
|
+
const leases = await takeInboxDispatches();
|
|
278
|
+
const failures: unknown[] = [];
|
|
279
|
+
for (let offset = 0; offset < leases.length; offset += 10) {
|
|
280
|
+
try {
|
|
281
|
+
const response = await client.send(
|
|
282
|
+
new SendMessageBatchCommand({
|
|
283
|
+
QueueUrl: url,
|
|
284
|
+
Entries: leases.slice(offset, offset + 10).map(({ id: itemId }, index) => ({
|
|
285
|
+
Id: String(index),
|
|
286
|
+
MessageBody: JSON.stringify({ itemId }),
|
|
287
|
+
})),
|
|
288
|
+
})
|
|
289
|
+
);
|
|
290
|
+
await acknowledgeInboxDispatches(
|
|
291
|
+
(response.Successful ?? []).map(entry => leases[offset + Number(entry.Id)]!)
|
|
292
|
+
);
|
|
293
|
+
if (response.Failed?.length) {
|
|
294
|
+
console.error('Inbox dispatch entries failed', {
|
|
295
|
+
count: response.Failed.length,
|
|
296
|
+
});
|
|
297
|
+
failures.push(
|
|
298
|
+
new Error('Inbox dispatch partially failed; durable outbox will retry')
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
} catch (error) {
|
|
302
|
+
console.error('Inbox dispatch chunk failed', { offset });
|
|
303
|
+
failures.push(error);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
if (leases.length) console.info('Inbox dispatch attempted', { count: leases.length });
|
|
307
|
+
try {
|
|
308
|
+
await recoverInboxJobs(maintenanceDeadline);
|
|
309
|
+
} catch (error) {
|
|
310
|
+
console.error('Inbox maintenance failed; publication was attempted independently');
|
|
311
|
+
failures.push(error);
|
|
312
|
+
}
|
|
313
|
+
// Report failures after attempting every chunk; alarms require sustained failures.
|
|
314
|
+
if (failures.length) throw failures[0];
|
|
315
|
+
} finally {
|
|
316
|
+
client.destroy();
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
/** Local/E2E consumer uses the same SQS protocol and processing entry point as Lambda. */
|
|
321
|
+
export const consumeInboxQueueOnce = async (waitSeconds = 1): Promise<void> => {
|
|
322
|
+
const { client, url } = queue();
|
|
323
|
+
try {
|
|
324
|
+
const response = await client.send(
|
|
325
|
+
new ReceiveMessageCommand({
|
|
326
|
+
QueueUrl: url,
|
|
327
|
+
MaxNumberOfMessages: 10,
|
|
328
|
+
WaitTimeSeconds: waitSeconds,
|
|
329
|
+
VisibilityTimeout: 1800,
|
|
330
|
+
})
|
|
331
|
+
);
|
|
332
|
+
const results = await Promise.allSettled(
|
|
333
|
+
(response.Messages ?? []).map(async message => {
|
|
334
|
+
await processInboxQueueMessage(message.Body ?? '');
|
|
335
|
+
await client.send(
|
|
336
|
+
new DeleteMessageCommand({
|
|
337
|
+
QueueUrl: url,
|
|
338
|
+
ReceiptHandle: message.ReceiptHandle!,
|
|
339
|
+
})
|
|
340
|
+
);
|
|
341
|
+
})
|
|
342
|
+
);
|
|
343
|
+
// Wait for every owned item before destroying the SQS client or starting another wave.
|
|
344
|
+
const failed = results.find(result => result.status === 'rejected');
|
|
345
|
+
if (failed?.status === 'rejected') throw failed.reason;
|
|
346
|
+
} finally {
|
|
347
|
+
client.destroy();
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
export const consumeInboxDeadLettersOnce = async (): Promise<void> => {
|
|
352
|
+
const url = getInboxBatchRuntimeEnvironment().INBOX_DEAD_LETTER_QUEUE_URL;
|
|
353
|
+
if (!url) return;
|
|
354
|
+
const { client } = queue();
|
|
355
|
+
try {
|
|
356
|
+
const response = await client.send(
|
|
357
|
+
new ReceiveMessageCommand({
|
|
358
|
+
QueueUrl: url,
|
|
359
|
+
MaxNumberOfMessages: 10,
|
|
360
|
+
WaitTimeSeconds: 0,
|
|
361
|
+
})
|
|
362
|
+
);
|
|
363
|
+
for (const message of response.Messages ?? []) {
|
|
364
|
+
await processInboxDeadLetter(message.Body ?? '');
|
|
365
|
+
await client.send(
|
|
366
|
+
new DeleteMessageCommand({ QueueUrl: url, ReceiptHandle: message.ReceiptHandle! })
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
} finally {
|
|
370
|
+
client.destroy();
|
|
371
|
+
}
|
|
372
|
+
};
|