@learncard/network-brain-service 4.1.3 → 5.0.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/.env.example +14 -0
- package/CHANGELOG.md +143 -0
- package/README.md +27 -1
- package/bootstrapLambda.test.ts +70 -32
- package/config/config.dev.json +1 -0
- package/config/config.example.json +2 -1
- package/config/config.production.json +1 -0
- package/config/config.scouts.dev.json +1 -0
- package/config/config.scouts.production.json +1 -0
- package/consentFlowDeadlineLambda.test.ts +108 -0
- package/consentFlowDeadlineLambda.ts +18 -0
- package/consentFlowDeadlineLambdaApp.ts +14 -0
- package/dist/accesslayer/boost/create.d.ts +8 -2
- package/dist/accesslayer/boost/create.d.ts.map +1 -1
- package/dist/accesslayer/campaign/audience.d.ts +4 -4
- package/dist/accesslayer/campaign/audience.d.ts.map +1 -1
- package/dist/accesslayer/campaign/create.d.ts +1 -1
- package/dist/accesslayer/campaign/create.d.ts.map +1 -1
- package/dist/accesslayer/campaign/delivery.d.ts +5 -0
- package/dist/accesslayer/campaign/delivery.d.ts.map +1 -0
- package/dist/accesslayer/campaign/dispatch.d.ts +5 -0
- package/dist/accesslayer/campaign/dispatch.d.ts.map +1 -0
- package/dist/accesslayer/campaign/dispatch.test.d.ts +2 -0
- package/dist/accesslayer/campaign/dispatch.test.d.ts.map +1 -0
- package/dist/accesslayer/campaign/email.d.ts +10 -0
- package/dist/accesslayer/campaign/email.d.ts.map +1 -0
- package/dist/accesslayer/campaign/email.test.d.ts +2 -0
- package/dist/accesslayer/campaign/email.test.d.ts.map +1 -0
- package/dist/accesslayer/campaign/preferences.d.ts +5 -0
- package/dist/accesslayer/campaign/preferences.d.ts.map +1 -0
- package/dist/accesslayer/campaign/read.d.ts.map +1 -1
- package/dist/accesslayer/campaign/test.d.ts +5 -0
- package/dist/accesslayer/campaign/test.d.ts.map +1 -0
- package/dist/accesslayer/campaign/test.test.d.ts +2 -0
- package/dist/accesslayer/campaign/test.test.d.ts.map +1 -0
- package/dist/accesslayer/campaign/update.d.ts.map +1 -1
- package/dist/accesslayer/consentflowcontract/create.d.ts.map +1 -1
- package/dist/accesslayer/consentflowcontract/delete.d.ts +1 -1
- package/dist/accesslayer/consentflowcontract/delete.d.ts.map +1 -1
- package/dist/accesslayer/consentflowcontract/read.d.ts.map +1 -1
- package/dist/accesslayer/consentflowcontract/relationships/create.d.ts +2 -1
- package/dist/accesslayer/consentflowcontract/relationships/create.d.ts.map +1 -1
- package/dist/accesslayer/consentflowcontract/relationships/read.d.ts +19 -4
- package/dist/accesslayer/consentflowcontract/relationships/read.d.ts.map +1 -1
- package/dist/accesslayer/consentflowcontract/relationships/update.d.ts +6 -1
- package/dist/accesslayer/consentflowcontract/relationships/update.d.ts.map +1 -1
- package/dist/accesslayer/consentflowcontract/versions.d.ts +68 -0
- package/dist/accesslayer/consentflowcontract/versions.d.ts.map +1 -0
- package/dist/accesslayer/credential/create.d.ts +3 -1
- package/dist/accesslayer/credential/create.d.ts.map +1 -1
- package/dist/accesslayer/credential/delete.d.ts +1 -0
- package/dist/accesslayer/credential/delete.d.ts.map +1 -1
- package/dist/accesslayer/credential/relationships/create.d.ts +15 -3
- package/dist/accesslayer/credential/relationships/create.d.ts.map +1 -1
- package/dist/accesslayer/credential/relationships/read.d.ts +2 -0
- package/dist/accesslayer/credential/relationships/read.d.ts.map +1 -1
- package/dist/accesslayer/credential/relationships/update.d.ts.map +1 -1
- package/dist/accesslayer/credential-refresh/read.d.ts +1 -0
- 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-credential/create.d.ts +1 -0
- package/dist/accesslayer/inbox-credential/create.d.ts.map +1 -1
- package/dist/accesslayer/inbox-credential/refresh.d.ts +7 -0
- package/dist/accesslayer/inbox-credential/refresh.d.ts.map +1 -1
- package/dist/app.d.ts +11 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/cache/app-store.caches.d.ts +61 -1
- package/dist/cache/app-store.caches.d.ts.map +1 -1
- package/dist/campaign-unsubscribe.d.ts +7 -0
- package/dist/campaign-unsubscribe.d.ts.map +1 -0
- package/dist/campaign-unsubscribe.test.d.ts +2 -0
- package/dist/campaign-unsubscribe.test.d.ts.map +1 -0
- package/dist/config/environment.d.ts +42 -0
- package/dist/config/environment.d.ts.map +1 -1
- package/dist/config/stageConfig.d.ts +4 -0
- package/dist/config/stageConfig.d.ts.map +1 -1
- package/dist/credential-refresh.d.ts.map +1 -1
- package/dist/helpers/boost.helpers.d.ts +4 -1
- package/dist/helpers/boost.helpers.d.ts.map +1 -1
- package/dist/helpers/campaign-app-origin.helpers.d.ts +2 -0
- package/dist/helpers/campaign-app-origin.helpers.d.ts.map +1 -0
- package/dist/helpers/campaign-email.helpers.d.ts +13 -0
- package/dist/helpers/campaign-email.helpers.d.ts.map +1 -0
- package/dist/helpers/campaign-notifications.helpers.d.ts +7 -0
- package/dist/helpers/campaign-notifications.helpers.d.ts.map +1 -0
- package/dist/helpers/campaign-queue.helpers.d.ts +7 -0
- package/dist/helpers/campaign-queue.helpers.d.ts.map +1 -0
- package/dist/helpers/campaign-queue.helpers.test.d.ts +2 -0
- package/dist/helpers/campaign-queue.helpers.test.d.ts.map +1 -0
- package/dist/helpers/campaign-unsubscribe-page.d.ts +2 -0
- package/dist/helpers/campaign-unsubscribe-page.d.ts.map +1 -0
- package/dist/helpers/campaign-unsubscribe.helpers.d.ts +7 -0
- package/dist/helpers/campaign-unsubscribe.helpers.d.ts.map +1 -0
- package/dist/helpers/campaign-webhook.helpers.test.d.ts +2 -0
- package/dist/helpers/campaign-webhook.helpers.test.d.ts.map +1 -0
- package/dist/helpers/consentflow-deadline.helpers.d.ts +5 -0
- package/dist/helpers/consentflow-deadline.helpers.d.ts.map +1 -0
- package/dist/helpers/consentflow-legacy-migration.helpers.d.ts +2 -0
- package/dist/helpers/consentflow-legacy-migration.helpers.d.ts.map +1 -0
- package/dist/helpers/contract-events.helpers.d.ts.map +1 -1
- package/dist/helpers/contract.helpers.d.ts +1 -1
- package/dist/helpers/contract.helpers.d.ts.map +1 -1
- package/dist/helpers/credential-display.helpers.d.ts +5 -0
- package/dist/helpers/credential-display.helpers.d.ts.map +1 -0
- package/dist/helpers/credential-display.helpers.test.d.ts +2 -0
- package/dist/helpers/credential-display.helpers.test.d.ts.map +1 -0
- package/dist/helpers/credential-refresh-email.helpers.d.ts.map +1 -1
- package/dist/helpers/credential-refresh-materiality.helpers.d.ts +4 -0
- package/dist/helpers/credential-refresh-materiality.helpers.d.ts.map +1 -1
- package/dist/helpers/credential-refresh.helpers.d.ts +30 -1
- package/dist/helpers/credential-refresh.helpers.d.ts.map +1 -1
- package/dist/helpers/credential-status-mutation.helpers.d.ts +5 -0
- package/dist/helpers/credential-status-mutation.helpers.d.ts.map +1 -0
- package/dist/helpers/credential-status-mutation.helpers.test.d.ts +2 -0
- package/dist/helpers/credential-status-mutation.helpers.test.d.ts.map +1 -0
- package/dist/helpers/credential.helpers.d.ts +1 -1
- package/dist/helpers/credential.helpers.d.ts.map +1 -1
- package/dist/helpers/inbox-refresh.helpers.d.ts +4 -2
- package/dist/helpers/inbox-refresh.helpers.d.ts.map +1 -1
- package/dist/helpers/inbox.helpers.d.ts +1 -0
- package/dist/helpers/inbox.helpers.d.ts.map +1 -1
- package/dist/helpers/learnCard.helpers.d.ts +1 -0
- package/dist/helpers/learnCard.helpers.d.ts.map +1 -1
- package/dist/helpers/managed-status.helpers.d.ts +7 -0
- package/dist/helpers/managed-status.helpers.d.ts.map +1 -0
- package/dist/helpers/managed-status.helpers.test.d.ts +2 -0
- package/dist/helpers/managed-status.helpers.test.d.ts.map +1 -0
- package/dist/helpers/notification-delivery-boundary.helpers.test.d.ts +2 -0
- package/dist/helpers/notification-delivery-boundary.helpers.test.d.ts.map +1 -0
- package/dist/helpers/notification-webhook-fetch.helpers.d.ts +13 -0
- package/dist/helpers/notification-webhook-fetch.helpers.d.ts.map +1 -0
- package/dist/helpers/notification-webhook-fetch.helpers.test.d.ts +2 -0
- package/dist/helpers/notification-webhook-fetch.helpers.test.d.ts.map +1 -0
- package/dist/helpers/notificationQueue.helpers.d.ts.map +1 -1
- package/dist/helpers/notifications.helpers.d.ts.map +1 -1
- package/dist/helpers/refresh-send-intent.helpers.d.ts +13 -5
- package/dist/helpers/refresh-send-intent.helpers.d.ts.map +1 -1
- package/dist/helpers/refresh-send-intent.helpers.test.d.ts +2 -0
- package/dist/helpers/refresh-send-intent.helpers.test.d.ts.map +1 -0
- package/dist/helpers/send-contract.helpers.d.ts +11 -0
- package/dist/helpers/send-contract.helpers.d.ts.map +1 -0
- package/dist/helpers/status-list.helpers.d.ts +12 -1
- package/dist/helpers/status-list.helpers.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/models/ConsentFlowContract.d.ts.map +1 -1
- package/dist/models/ConsentFlowContractVersion.d.ts +12 -0
- package/dist/models/ConsentFlowContractVersion.d.ts.map +1 -0
- package/dist/models/ConsentFlowTerms.d.ts.map +1 -1
- package/dist/models/Credential.d.ts +2 -0
- package/dist/models/Credential.d.ts.map +1 -1
- package/dist/models/CredentialRefresh.d.ts +5 -0
- package/dist/models/CredentialRefresh.d.ts.map +1 -1
- package/dist/models/Integration.d.ts +1 -1
- package/dist/models/Profile.d.ts.map +1 -1
- package/dist/models/campaign-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/openapi.d.ts.map +1 -1
- package/dist/publish-metafile.json +1 -1
- package/dist/routes/activity.d.ts +15 -5
- package/dist/routes/activity.d.ts.map +1 -1
- package/dist/routes/app-store.d.ts +15 -5
- package/dist/routes/app-store.d.ts.map +1 -1
- package/dist/routes/auth-grants.d.ts +12 -2
- package/dist/routes/auth-grants.d.ts.map +1 -1
- package/dist/routes/bench.d.ts +11 -1
- package/dist/routes/bench.d.ts.map +1 -1
- package/dist/routes/boosts.d.ts +70 -15
- package/dist/routes/boosts.d.ts.map +1 -1
- package/dist/routes/campaigns.d.ts +183 -51
- package/dist/routes/campaigns.d.ts.map +1 -1
- package/dist/routes/claim-hooks.d.ts +11 -1
- package/dist/routes/claim-hooks.d.ts.map +1 -1
- package/dist/routes/contact-methods.d.ts +11 -1
- package/dist/routes/contact-methods.d.ts.map +1 -1
- package/dist/routes/contracts.d.ts +374 -8
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/credential-input-privacy.test.d.ts +2 -0
- package/dist/routes/credential-input-privacy.test.d.ts.map +1 -0
- package/dist/routes/credential-refreshes.d.ts +210 -1
- package/dist/routes/credential-refreshes.d.ts.map +1 -1
- package/dist/routes/credential-share-previews.d.ts +11 -1
- package/dist/routes/credential-share-previews.d.ts.map +1 -1
- package/dist/routes/credentials.d.ts +132 -3
- package/dist/routes/credentials.d.ts.map +1 -1
- package/dist/routes/did-metadata.d.ts +11 -1
- package/dist/routes/did-metadata.d.ts.map +1 -1
- package/dist/routes/federation.d.ts +11 -1
- package/dist/routes/federation.d.ts.map +1 -1
- package/dist/routes/inbox.d.ts +54 -19
- package/dist/routes/inbox.d.ts.map +1 -1
- package/dist/routes/index.d.ts +100 -1
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/integrations.d.ts +14 -4
- package/dist/routes/integrations.d.ts.map +1 -1
- package/dist/routes/presentations.d.ts +11 -1
- package/dist/routes/presentations.d.ts.map +1 -1
- package/dist/routes/profile-manager.d.ts +11 -1
- package/dist/routes/profile-manager.d.ts.map +1 -1
- package/dist/routes/profiles.d.ts +11 -1
- package/dist/routes/profiles.d.ts.map +1 -1
- package/dist/routes/public-share-links.d.ts +22 -2
- package/dist/routes/public-share-links.d.ts.map +1 -1
- package/dist/routes/share-links.d.ts +36 -16
- package/dist/routes/share-links.d.ts.map +1 -1
- package/dist/routes/skill-frameworks.d.ts +11 -1
- package/dist/routes/skill-frameworks.d.ts.map +1 -1
- package/dist/routes/skills.d.ts +11 -1
- package/dist/routes/skills.d.ts.map +1 -1
- package/dist/routes/storage.d.ts +37 -23
- package/dist/routes/storage.d.ts.map +1 -1
- package/dist/routes/test.d.ts +79 -3
- package/dist/routes/test.d.ts.map +1 -1
- package/dist/routes/utilities.d.ts +11 -1
- package/dist/routes/utilities.d.ts.map +1 -1
- package/dist/routes/workflows.d.ts +11 -1
- package/dist/routes/workflows.d.ts.map +1 -1
- package/dist/services/delivery/adapters/postmark.adapter.d.ts +3 -0
- package/dist/services/delivery/adapters/postmark.adapter.d.ts.map +1 -1
- package/dist/services/delivery/delivery.service.d.ts +10 -0
- package/dist/services/delivery/delivery.service.d.ts.map +1 -1
- package/dist/types/activity.d.ts +3 -3
- package/dist/types/app-manifest.d.ts +10 -10
- package/dist/types/campaign.d.ts +13 -1
- package/dist/types/campaign.d.ts.map +1 -1
- package/dist/types/consentflowcontract.d.ts +175 -7
- package/dist/types/consentflowcontract.d.ts.map +1 -1
- package/dist/types/credential-refresh.d.ts +27 -0
- package/dist/types/credential-refresh.d.ts.map +1 -1
- package/dist/types/credential.d.ts +5 -0
- package/dist/types/credential.d.ts.map +1 -1
- package/dist/types/integration.d.ts +3 -3
- package/lambda.ts +44 -14
- package/lambdaApp.ts +20 -0
- package/package.json +20 -19
- package/project.json +5 -0
- package/scripts/migrate-consent-flow-versions.ts +9 -0
- package/scripts/report-send-template-exposure.ts +47 -0
- package/scripts/verify-python-contracts.ts +16 -1
- package/serverless-local.yml +15 -2
- package/serverless.function-env.cjs +4 -0
- package/serverless.local.yml +12 -0
- package/serverless.yml +48 -3
- package/src/accesslayer/boost/create.ts +62 -7
- package/src/accesslayer/campaign/README.md +275 -6
- package/src/accesslayer/campaign/audience.ts +39 -7
- package/src/accesslayer/campaign/create.ts +4 -2
- package/src/accesslayer/campaign/delivery.ts +66 -0
- package/src/accesslayer/campaign/dispatch.test.ts +59 -0
- package/src/accesslayer/campaign/dispatch.ts +172 -0
- package/src/accesslayer/campaign/email.test.ts +73 -0
- package/src/accesslayer/campaign/email.ts +91 -0
- package/src/accesslayer/campaign/preferences.ts +53 -0
- package/src/accesslayer/campaign/read.ts +3 -1
- package/src/accesslayer/campaign/state.ts +1 -1
- package/src/accesslayer/campaign/test.test.ts +31 -0
- package/src/accesslayer/campaign/test.ts +75 -0
- package/src/accesslayer/campaign/update.ts +15 -4
- package/src/accesslayer/consentflowcontract/create.ts +20 -1
- package/src/accesslayer/consentflowcontract/delete.ts +121 -3
- package/src/accesslayer/consentflowcontract/read.ts +15 -9
- package/src/accesslayer/consentflowcontract/relationships/create.ts +70 -36
- package/src/accesslayer/consentflowcontract/relationships/read.ts +305 -73
- package/src/accesslayer/consentflowcontract/relationships/smartResume.ts +1 -1
- package/src/accesslayer/consentflowcontract/relationships/update.ts +269 -98
- package/src/accesslayer/consentflowcontract/versions.ts +790 -0
- package/src/accesslayer/credential/create.ts +33 -9
- package/src/accesslayer/credential/delete.ts +45 -0
- package/src/accesslayer/credential/relationships/create.ts +102 -47
- package/src/accesslayer/credential/relationships/update.ts +8 -116
- package/src/accesslayer/credential-refresh/read.ts +26 -2
- package/src/accesslayer/credential-refresh/update.ts +6 -2
- package/src/accesslayer/inbox-credential/create.ts +7 -1
- package/src/accesslayer/inbox-credential/refresh.ts +14 -4
- package/src/campaign-unsubscribe.test.ts +158 -0
- package/src/campaign-unsubscribe.ts +86 -0
- package/src/config/environment.test.ts +52 -0
- package/src/config/environment.ts +58 -0
- package/src/config/serverlessFunctionEnv.test.ts +59 -0
- package/src/credential-refresh.ts +1 -0
- package/src/docker-entry.ts +26 -1
- package/src/helpers/boost-storage.helpers.test.ts +107 -41
- package/src/helpers/boost.helpers.ts +88 -40
- package/src/helpers/campaign-app-origin.helpers.ts +25 -0
- package/src/helpers/campaign-email.helpers.ts +113 -0
- package/src/helpers/campaign-notifications.helpers.ts +127 -0
- package/src/helpers/campaign-queue.helpers.test.ts +442 -0
- package/src/helpers/campaign-queue.helpers.ts +122 -0
- package/src/helpers/campaign-unsubscribe-page.ts +107 -0
- package/src/helpers/campaign-unsubscribe.helpers.ts +56 -0
- package/src/helpers/campaign-webhook.helpers.test.ts +137 -0
- package/src/helpers/consentflow-deadline.helpers.ts +22 -0
- package/src/helpers/consentflow-legacy-migration.helpers.ts +179 -0
- package/src/helpers/contract-events.helpers.ts +35 -3
- package/src/helpers/contract-requests.helpers.ts +1 -1
- package/src/helpers/contract.helpers.ts +5 -1
- package/src/helpers/credential-display.helpers.test.ts +68 -0
- package/src/helpers/credential-display.helpers.ts +15 -0
- package/src/helpers/credential-refresh-email.helpers.ts +5 -12
- package/src/helpers/credential-refresh-materiality.helpers.test.ts +138 -1
- package/src/helpers/credential-refresh-materiality.helpers.ts +62 -1
- package/src/helpers/credential-refresh-proof.helpers.test.ts +1 -1
- package/src/helpers/credential-refresh-proof.helpers.ts +2 -2
- package/src/helpers/credential-refresh.helpers.ts +1166 -376
- package/src/helpers/credential-status-mutation.helpers.test.ts +155 -0
- package/src/helpers/credential-status-mutation.helpers.ts +166 -0
- package/src/helpers/credential.helpers.ts +19 -11
- package/src/helpers/finalize-inbox.helpers.ts +1 -1
- package/src/helpers/inbox-refresh.helpers.ts +34 -8
- package/src/helpers/inbox.helpers.ts +2 -0
- package/src/helpers/learnCard.helpers.ts +23 -0
- package/src/helpers/managed-status.helpers.test.ts +101 -0
- package/src/helpers/managed-status.helpers.ts +147 -0
- package/src/helpers/notification-delivery-boundary.helpers.test.ts +114 -0
- package/src/helpers/notification-webhook-fetch.helpers.test.ts +228 -0
- package/src/helpers/notification-webhook-fetch.helpers.ts +166 -0
- package/src/helpers/notificationQueue.helpers.ts +5 -0
- package/src/helpers/notifications.helpers.ts +19 -12
- package/src/helpers/refresh-send-intent.helpers.test.ts +60 -0
- package/src/helpers/refresh-send-intent.helpers.ts +81 -18
- package/src/helpers/send-contract.helpers.ts +36 -0
- package/src/helpers/status-list.helpers.test.ts +29 -12
- package/src/helpers/status-list.helpers.ts +329 -20
- package/src/models/ConsentFlowContract.ts +3 -0
- package/src/models/ConsentFlowContractVersion.ts +50 -0
- package/src/models/ConsentFlowTerms.ts +4 -0
- package/src/models/Credential.ts +2 -0
- package/src/models/CredentialRefresh.ts +2 -0
- package/src/models/Profile.ts +2 -0
- package/src/models/campaign-constraints.ts +13 -8
- package/src/models/index.ts +2 -0
- package/src/openapi.ts +21 -0
- package/src/routes/app-store.ts +2 -1
- package/src/routes/boosts.ts +219 -137
- package/src/routes/campaigns.ts +98 -19
- package/src/routes/contracts.ts +433 -115
- package/src/routes/credential-input-privacy.test.ts +92 -0
- package/src/routes/credential-refreshes.ts +273 -2
- package/src/routes/federation.ts +7 -2
- package/src/routes/inbox.ts +6 -1
- package/src/routes/index.ts +31 -2
- package/src/routes/workflows.ts +61 -46
- package/src/services/delivery/adapters/postmark.adapter.test.ts +70 -1
- package/src/services/delivery/adapters/postmark.adapter.ts +84 -11
- package/src/services/delivery/delivery.service.ts +4 -0
- package/src/types/campaign.ts +14 -1
- package/src/types/consentflowcontract.ts +43 -2
- package/src/types/credential-refresh.ts +11 -1
- package/src/types/credential.ts +2 -0
- package/test/boost-status-cleanup.spec.ts +123 -0
- package/test/campaigns-email.unit.spec.ts +268 -0
- package/test/campaigns.spec.ts +804 -30
- package/test/consent-autoboost-idempotency.spec.ts +432 -0
- package/test/consent-data-boundaries.spec.ts +322 -26
- package/test/consent-legacy-migration.spec.ts +315 -0
- package/test/consent-recipients.spec.ts +7 -7
- package/test/consent-version-updates.spec.ts +761 -0
- package/test/consentflow.spec.ts +698 -226
- package/test/contract-requests.spec.ts +55 -9
- package/test/credential-refresh-allocation.spec.ts +212 -14
- package/test/credential-refresh-email.spec.ts +6 -10
- package/test/credential-refresh-endpoint.spec.ts +3 -0
- package/test/credential-refresh-publication.spec.ts +52 -15
- package/test/credential-storage.neo4j.spec.ts +33 -6
- package/test/helpers/legacy-autoboost.ts +48 -0
- package/test/holder-mode-send.spec.ts +710 -0
- package/test/inbox-refresh.spec.ts +105 -0
- package/test/inbox-security.e2e.ts +18 -22
- package/test/managed-status-revocation.spec.ts +970 -0
- package/test/notifications-worker.spec.ts +31 -25
- package/test/refresh-send.spec.ts +334 -5
- package/test/smart-resume-consent.spec.ts +1 -1
- package/test/verification/campaigns.ts +40 -0
- package/vitest.campaigns.config.ts +2 -0
- package/vitest.config.ts +14 -0
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import { Boost, Credential, Profile } from '@models';
|
|
2
|
+
import { createContractCredentialRelationships } from '@accesslayer/credential/relationships/create';
|
|
3
|
+
import type { DbTermsType } from 'types/consentflowcontract';
|
|
4
|
+
import type { ProfileType } from 'types/profile';
|
|
5
|
+
import { minimalContract, minimalTerms, normalContract, normalFullTerms } from './helpers/contract';
|
|
6
|
+
import { testUnsignedBoost } from './helpers/send';
|
|
7
|
+
import { getUser } from './helpers/getClient';
|
|
8
|
+
import {
|
|
9
|
+
getContractTermsByUri,
|
|
10
|
+
getTransactionsForTerms,
|
|
11
|
+
} from '@accesslayer/consentflowcontract/relationships/read';
|
|
12
|
+
import {
|
|
13
|
+
getConsentFlowContractVersionRecord,
|
|
14
|
+
updateConsentFlowContractVersion,
|
|
15
|
+
} from '@accesslayer/consentflowcontract/versions';
|
|
16
|
+
import { getIdFromUri } from '@helpers/uri.helpers';
|
|
17
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
18
|
+
import { randomBytes, randomUUID } from 'node:crypto';
|
|
19
|
+
import { neogma } from '@instance';
|
|
20
|
+
import * as boostHelpers from '@helpers/boost.helpers';
|
|
21
|
+
import {
|
|
22
|
+
claimAutoBoostTransaction,
|
|
23
|
+
completeAutoBoostTransaction,
|
|
24
|
+
} from '@accesslayer/consentflowcontract/relationships/update';
|
|
25
|
+
describe('consent autoboost transaction claims', () => {
|
|
26
|
+
it('retains an initial delivery claim after sending begins and the outcome is unknown', async () => {
|
|
27
|
+
const owner = await getUser(randomBytes(32).toString('hex'));
|
|
28
|
+
const learner = await getUser(randomBytes(32).toString('hex'));
|
|
29
|
+
const ownerId = `ambiguous-owner-${randomBytes(5).toString('hex')}`;
|
|
30
|
+
const learnerId = `ambiguous-user-${randomBytes(5).toString('hex')}`;
|
|
31
|
+
profileIds.push(ownerId, learnerId);
|
|
32
|
+
await owner.clients.fullAuth.profile.createProfile({ profileId: ownerId });
|
|
33
|
+
await learner.clients.fullAuth.profile.createProfile({ profileId: learnerId });
|
|
34
|
+
await owner.clients.fullAuth.profile.registerSigningAuthority({
|
|
35
|
+
endpoint: 'http://localhost:5000/api',
|
|
36
|
+
name: 'mysa',
|
|
37
|
+
did: 'did:key:z6MkitsQTk2GDNYXAFckVcQHtC68S9j9ruVFYWrixM6RG5Mw',
|
|
38
|
+
});
|
|
39
|
+
const boostUri = await owner.clients.fullAuth.boost.createBoost({
|
|
40
|
+
credential: testUnsignedBoost,
|
|
41
|
+
category: 'Achievement',
|
|
42
|
+
name: 'Ambiguous delivery',
|
|
43
|
+
});
|
|
44
|
+
const boostId = getIdFromUri(boostUri);
|
|
45
|
+
boostIds.push(boostId);
|
|
46
|
+
const uri = await owner.clients.fullAuth.contracts.createConsentFlowContract({
|
|
47
|
+
name: 'Initial delivery claim',
|
|
48
|
+
contract: normalContract,
|
|
49
|
+
autoboosts: [
|
|
50
|
+
{
|
|
51
|
+
boostUri,
|
|
52
|
+
signingAuthority: { endpoint: 'http://localhost:5000/api', name: 'mysa' },
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
const contractId = getIdFromUri(uri);
|
|
57
|
+
contractIds.push(contractId);
|
|
58
|
+
const sending = vi
|
|
59
|
+
.spyOn(boostHelpers, 'sendBoost')
|
|
60
|
+
.mockRejectedValueOnce(new Error('Delivery response was lost'));
|
|
61
|
+
try {
|
|
62
|
+
const { termsUri } = await learner.clients.fullAuth.contracts.consentToContract({
|
|
63
|
+
contractUri: uri,
|
|
64
|
+
terms: normalFullTerms,
|
|
65
|
+
});
|
|
66
|
+
const termsId = getIdFromUri(termsUri);
|
|
67
|
+
termsIds.push(termsId);
|
|
68
|
+
const claims = await neogma.queryRunner.run(
|
|
69
|
+
`MATCH (claim:ConsentFlowAutoBoostClaim {termsId:$termsId,boostId:$boostId})
|
|
70
|
+
RETURN claim.id AS id`,
|
|
71
|
+
{ termsId, boostId }
|
|
72
|
+
);
|
|
73
|
+
expect(claims.records.map(record => record.get('id'))).toEqual([expect.any(String)]);
|
|
74
|
+
expect(await claimAutoBoostTransaction(contractId, termsId, boostId)).toBeNull();
|
|
75
|
+
expect(
|
|
76
|
+
(await getTransactionsForTerms(termsId, { limit: 25 })).filter(
|
|
77
|
+
tx => tx.action === 'write'
|
|
78
|
+
)
|
|
79
|
+
).toEqual([]);
|
|
80
|
+
} finally {
|
|
81
|
+
sending.mockRestore();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const fixtureMarkers: string[] = [];
|
|
86
|
+
const contractIds: string[] = [];
|
|
87
|
+
const profileIds: string[] = [];
|
|
88
|
+
const termsIds: string[] = [];
|
|
89
|
+
const boostIds: string[] = [];
|
|
90
|
+
|
|
91
|
+
afterEach(async () => {
|
|
92
|
+
await neogma.queryRunner.run(
|
|
93
|
+
`MATCH (node) WHERE node.lcConsentTest IN $markers DETACH DELETE node`,
|
|
94
|
+
{ markers: fixtureMarkers.splice(0) }
|
|
95
|
+
);
|
|
96
|
+
await neogma.queryRunner.run(
|
|
97
|
+
`MATCH (claim:ConsentFlowAutoBoostClaim) WHERE claim.termsId IN $ids DETACH DELETE claim`,
|
|
98
|
+
{ ids: termsIds }
|
|
99
|
+
);
|
|
100
|
+
const ids = contractIds.splice(0);
|
|
101
|
+
await neogma.queryRunner.run(
|
|
102
|
+
`MATCH (event:ConsentFlowEvent) WHERE event.contractId IN $ids DETACH DELETE event`,
|
|
103
|
+
{ ids }
|
|
104
|
+
);
|
|
105
|
+
await neogma.queryRunner.run(
|
|
106
|
+
`MATCH (contract:ConsentFlowContract) WHERE contract.id IN $ids
|
|
107
|
+
OPTIONAL MATCH (terms:ConsentFlowTerms)-[:CONSENTS_TO]->(contract)
|
|
108
|
+
OPTIONAL MATCH (terms)<-[:IS_FOR]-(transaction:ConsentFlowTransaction)
|
|
109
|
+
DETACH DELETE transaction, terms, contract`,
|
|
110
|
+
{ ids }
|
|
111
|
+
);
|
|
112
|
+
termsIds.splice(0);
|
|
113
|
+
await neogma.queryRunner.run(
|
|
114
|
+
`MATCH (profile:Profile) WHERE profile.profileId IN $ids DETACH DELETE profile`,
|
|
115
|
+
{ ids: profileIds.splice(0) }
|
|
116
|
+
);
|
|
117
|
+
await neogma.queryRunner.run(
|
|
118
|
+
`MATCH (boost:Boost) WHERE boost.id IN $ids
|
|
119
|
+
OPTIONAL MATCH (credential:Credential)-[:INSTANCE_OF]->(boost)
|
|
120
|
+
DETACH DELETE credential, boost`,
|
|
121
|
+
{ ids: ['boost-identity', ...boostIds.splice(0)] }
|
|
122
|
+
);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const createConsent = async (
|
|
126
|
+
status: string,
|
|
127
|
+
version: number,
|
|
128
|
+
consentedVersion: number,
|
|
129
|
+
oneTime = false
|
|
130
|
+
) => {
|
|
131
|
+
const contractId = randomUUID();
|
|
132
|
+
const termsId = randomUUID();
|
|
133
|
+
contractIds.push(contractId);
|
|
134
|
+
termsIds.push(termsId);
|
|
135
|
+
await neogma.queryRunner.run(
|
|
136
|
+
`CREATE (contract:ConsentFlowContract {id:$contractId, currentVersion:$version})
|
|
137
|
+
CREATE (terms:ConsentFlowTerms {id:$termsId, status:$status, consentedVersion:$consentedVersion, oneTime:$oneTime})
|
|
138
|
+
CREATE (terms)-[:CONSENTS_TO]->(contract)`,
|
|
139
|
+
{ contractId, termsId, status, version, consentedVersion, oneTime }
|
|
140
|
+
);
|
|
141
|
+
return { contractId, termsId };
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
it('claims a terms/boost identity once under concurrency and records a write only after send', async () => {
|
|
145
|
+
const { contractId, termsId } = await createConsent('live', 1, 1);
|
|
146
|
+
const claims = await Promise.all(
|
|
147
|
+
Array.from({ length: 8 }, () =>
|
|
148
|
+
claimAutoBoostTransaction(contractId, termsId, 'boost-identity')
|
|
149
|
+
)
|
|
150
|
+
);
|
|
151
|
+
expect(claims.filter(Boolean)).toHaveLength(1);
|
|
152
|
+
const claimId = claims.find(Boolean)!;
|
|
153
|
+
|
|
154
|
+
const beforeCompletion = await neogma.queryRunner.run(
|
|
155
|
+
`MATCH (:ConsentFlowTerms {id:$termsId})<-[:IS_FOR]-(transaction:ConsentFlowTransaction)
|
|
156
|
+
RETURN count(transaction) AS count`,
|
|
157
|
+
{ termsId }
|
|
158
|
+
);
|
|
159
|
+
expect(Number(beforeCompletion.records[0]?.get('count'))).toBe(0);
|
|
160
|
+
await neogma.queryRunner.run(
|
|
161
|
+
`CREATE (boost:Boost {id:'boost-identity'})
|
|
162
|
+
CREATE (credential:Credential {id:$credentialId, credential:'{}'})
|
|
163
|
+
CREATE (transaction:ConsentFlowTransaction {id:$transactionId, action:'write', date:'2026-01-01T00:00:00.000Z'})
|
|
164
|
+
WITH boost, credential, transaction
|
|
165
|
+
MATCH (terms:ConsentFlowTerms {id:$termsId})
|
|
166
|
+
CREATE (transaction)-[:IS_FOR]->(terms)
|
|
167
|
+
CREATE (credential)-[:ISSUED_VIA_TRANSACTION]->(transaction)
|
|
168
|
+
CREATE (credential)-[:INSTANCE_OF]->(boost)`,
|
|
169
|
+
{ termsId, credentialId: randomUUID(), transactionId: randomUUID() }
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
await completeAutoBoostTransaction(claimId, termsId, 'boost-identity');
|
|
173
|
+
expect(await claimAutoBoostTransaction(contractId, termsId, 'boost-identity')).toBeNull();
|
|
174
|
+
const afterCompletion = await neogma.queryRunner.run(
|
|
175
|
+
`MATCH (:ConsentFlowTerms {id:$termsId})<-[:IS_FOR]-(transaction:ConsentFlowTransaction {boostId:'boost-identity'})
|
|
176
|
+
RETURN count(transaction) AS count`,
|
|
177
|
+
{ termsId }
|
|
178
|
+
);
|
|
179
|
+
expect(Number(afterCompletion.records[0]?.get('count'))).toBe(1);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it.each(['needs_reconsent', 'suspended', 'consumed'] as const)(
|
|
183
|
+
'does not claim autoboosts for %s consent',
|
|
184
|
+
async status => {
|
|
185
|
+
const { contractId, termsId } = await createConsent(status, 2, 1);
|
|
186
|
+
await expect(
|
|
187
|
+
claimAutoBoostTransaction(contractId, termsId, 'boost-identity')
|
|
188
|
+
).resolves.toBeNull();
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
it.each(['update', 'reconsent'] as const)(
|
|
192
|
+
'delivers a newly enabled one-time AutoBoost once through explicit %s',
|
|
193
|
+
async path => {
|
|
194
|
+
const owner = await getUser(randomBytes(32).toString('hex'));
|
|
195
|
+
const learner = await getUser(randomBytes(32).toString('hex'));
|
|
196
|
+
const ownerId = `autoboost-owner-${randomBytes(5).toString('hex')}`;
|
|
197
|
+
const learnerId = `autoboost-user-${randomBytes(5).toString('hex')}`;
|
|
198
|
+
profileIds.push(ownerId, learnerId);
|
|
199
|
+
await owner.clients.fullAuth.profile.createProfile({ profileId: ownerId });
|
|
200
|
+
await learner.clients.fullAuth.profile.createProfile({ profileId: learnerId });
|
|
201
|
+
await owner.clients.fullAuth.profile.registerSigningAuthority({
|
|
202
|
+
endpoint: 'http://localhost:5000/api',
|
|
203
|
+
name: 'mysa',
|
|
204
|
+
did: 'did:key:z6MkitsQTk2GDNYXAFckVcQHtC68S9j9ruVFYWrixM6RG5Mw',
|
|
205
|
+
});
|
|
206
|
+
const boostUri = await owner.clients.fullAuth.boost.createBoost({
|
|
207
|
+
credential: testUnsignedBoost,
|
|
208
|
+
category: 'Achievement',
|
|
209
|
+
name: 'One-time QA',
|
|
210
|
+
});
|
|
211
|
+
boostIds.push(getIdFromUri(boostUri));
|
|
212
|
+
const uri = await owner.clients.fullAuth.contracts.createConsentFlowContract({
|
|
213
|
+
name: 'One-time access QA',
|
|
214
|
+
contract: normalContract,
|
|
215
|
+
autoboosts: [
|
|
216
|
+
{
|
|
217
|
+
boostUri,
|
|
218
|
+
signingAuthority: { endpoint: 'http://localhost:5000/api', name: 'mysa' },
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
});
|
|
222
|
+
contractIds.push(getIdFromUri(uri));
|
|
223
|
+
const initialTerms = structuredClone(normalFullTerms);
|
|
224
|
+
initialTerms.write.credentials.categories.Achievement = false;
|
|
225
|
+
const { termsUri } = await learner.clients.fullAuth.contracts.consentToContract({
|
|
226
|
+
contractUri: uri,
|
|
227
|
+
terms: initialTerms,
|
|
228
|
+
oneTime: path === 'reconsent',
|
|
229
|
+
});
|
|
230
|
+
termsIds.push(getIdFromUri(termsUri));
|
|
231
|
+
expect(
|
|
232
|
+
(await learner.clients.fullAuth.contracts.getCredentialsForContract({ termsUri }))
|
|
233
|
+
.records
|
|
234
|
+
).toEqual([]);
|
|
235
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
236
|
+
if (path === 'update') {
|
|
237
|
+
const update = learner.clients.fullAuth.contracts.updateConsentedContractTerms({
|
|
238
|
+
uri: termsUri,
|
|
239
|
+
terms: normalFullTerms,
|
|
240
|
+
oneTime: true,
|
|
241
|
+
});
|
|
242
|
+
if (attempt === 0) await update;
|
|
243
|
+
else await expect(update).rejects.toMatchObject({ code: 'FORBIDDEN' });
|
|
244
|
+
} else {
|
|
245
|
+
const response = await learner.clients.fullAuth.contracts.consentToContract({
|
|
246
|
+
contractUri: uri,
|
|
247
|
+
terms: normalFullTerms,
|
|
248
|
+
oneTime: true,
|
|
249
|
+
});
|
|
250
|
+
expect(response.termsUri).toBe(termsUri);
|
|
251
|
+
}
|
|
252
|
+
const received = await learner.clients.fullAuth.contracts.getCredentialsForContract(
|
|
253
|
+
{ termsUri }
|
|
254
|
+
);
|
|
255
|
+
expect(received.records.map(record => getIdFromUri(record.boostUri))).toEqual([
|
|
256
|
+
getIdFromUri(boostUri),
|
|
257
|
+
]);
|
|
258
|
+
expect((await getContractTermsByUri(termsUri))?.terms.status).toBe('consumed');
|
|
259
|
+
}
|
|
260
|
+
const transactions =
|
|
261
|
+
await learner.clients.fullAuth.contracts.getTermsTransactionHistory({
|
|
262
|
+
uri: termsUri,
|
|
263
|
+
});
|
|
264
|
+
expect(
|
|
265
|
+
transactions.records.filter(transaction => transaction.action === 'write')
|
|
266
|
+
).toHaveLength(1);
|
|
267
|
+
}
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
it('does not deliver a credential signed for v1 after consent becomes pending at v2', async () => {
|
|
271
|
+
const marker = randomUUID();
|
|
272
|
+
fixtureMarkers.push(marker);
|
|
273
|
+
const contractId = randomUUID();
|
|
274
|
+
const termsId = randomUUID();
|
|
275
|
+
const ownerId = randomUUID();
|
|
276
|
+
const recipientId = randomUUID();
|
|
277
|
+
const credentialId = randomUUID();
|
|
278
|
+
const boostId = randomUUID();
|
|
279
|
+
contractIds.push(contractId);
|
|
280
|
+
termsIds.push(termsId);
|
|
281
|
+
|
|
282
|
+
await neogma.queryRunner.run(
|
|
283
|
+
`CREATE (owner:Profile {profileId:$ownerId, lcConsentTest:$marker})
|
|
284
|
+
CREATE (recipient:Profile {profileId:$recipientId, lcConsentTest:$marker})
|
|
285
|
+
CREATE (contract:ConsentFlowContract {
|
|
286
|
+
id:$contractId, currentVersion:2, status:'active', lcConsentTest:$marker
|
|
287
|
+
})
|
|
288
|
+
CREATE (terms:ConsentFlowTerms {
|
|
289
|
+
id:$termsId, status:'needs_reconsent', consentedVersion:1,
|
|
290
|
+
expiresAt:'', \`terms.deniedWriters\`:[], lcConsentTest:$marker
|
|
291
|
+
})
|
|
292
|
+
CREATE (credential:Credential {id:$credentialId, credential:'{}', lcConsentTest:$marker})
|
|
293
|
+
CREATE (boost:Boost {id:$boostId, category:null, lcConsentTest:$marker})
|
|
294
|
+
CREATE (contract)-[:CREATED_BY]->(owner)
|
|
295
|
+
CREATE (contract)-[:CAN_WRITE]->(owner)
|
|
296
|
+
CREATE (recipient)-[:CREATED_BY]->(terms)
|
|
297
|
+
CREATE (terms)-[:CONSENTS_TO]->(contract)`,
|
|
298
|
+
{ marker, contractId, termsId, ownerId, recipientId, credentialId, boostId }
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
const [owner, recipient, credential, boost] = await Promise.all([
|
|
302
|
+
Profile.findOne({ where: { profileId: ownerId } }),
|
|
303
|
+
Profile.findOne({ where: { profileId: recipientId } }),
|
|
304
|
+
Credential.findOne({ where: { id: credentialId } }),
|
|
305
|
+
Boost.findOne({ where: { id: boostId } }),
|
|
306
|
+
]);
|
|
307
|
+
if (!owner || !recipient || !credential || !boost) {
|
|
308
|
+
throw new Error('Could not load persisted contract delivery fixtures');
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
await expect(
|
|
312
|
+
createContractCredentialRelationships({
|
|
313
|
+
// The fixture profile nodes only supply fields used by this helper.
|
|
314
|
+
issuer: { type: 'profile', profile: owner.dataValues as unknown as ProfileType },
|
|
315
|
+
writerProfileId: ownerId,
|
|
316
|
+
recipient: recipient.dataValues as unknown as ProfileType,
|
|
317
|
+
credential,
|
|
318
|
+
boost,
|
|
319
|
+
terms: { id: termsId, consentedVersion: 1 } as unknown as DbTermsType,
|
|
320
|
+
})
|
|
321
|
+
).rejects.toMatchObject({ code: 'FORBIDDEN' });
|
|
322
|
+
|
|
323
|
+
const result = await neogma.queryRunner.run(
|
|
324
|
+
`MATCH (credential:Credential {id:$credentialId})
|
|
325
|
+
OPTIONAL MATCH (owner:Profile)-[sent:CREDENTIAL_SENT]->(credential)
|
|
326
|
+
OPTIONAL MATCH (credential)-[:INSTANCE_OF]->(boost:Boost)
|
|
327
|
+
OPTIONAL MATCH (credential)-[:ISSUED_VIA_TRANSACTION]->(transaction:ConsentFlowTransaction)
|
|
328
|
+
RETURN count(DISTINCT sent) AS sent, count(DISTINCT boost) AS instances,
|
|
329
|
+
count(DISTINCT transaction) AS transactions`,
|
|
330
|
+
{ credentialId }
|
|
331
|
+
);
|
|
332
|
+
expect(Number(result.records[0]?.get('sent'))).toBe(0);
|
|
333
|
+
expect(Number(result.records[0]?.get('instances'))).toBe(0);
|
|
334
|
+
expect(Number(result.records[0]?.get('transactions'))).toBe(0);
|
|
335
|
+
await neogma.queryRunner.run(
|
|
336
|
+
`MATCH (terms:ConsentFlowTerms {id:$termsId})
|
|
337
|
+
SET terms.status = 'live', terms.consentedVersion = 2`,
|
|
338
|
+
{ termsId }
|
|
339
|
+
);
|
|
340
|
+
await createContractCredentialRelationships({
|
|
341
|
+
issuer: { type: 'profile', profile: owner.dataValues as unknown as ProfileType },
|
|
342
|
+
writerProfileId: ownerId,
|
|
343
|
+
recipient: recipient.dataValues as unknown as ProfileType,
|
|
344
|
+
credential,
|
|
345
|
+
boost,
|
|
346
|
+
terms: { id: termsId, consentedVersion: 2 } as unknown as DbTermsType,
|
|
347
|
+
});
|
|
348
|
+
const delivered = await neogma.queryRunner.run(
|
|
349
|
+
`MATCH (:Profile {profileId:$ownerId})-[sent:CREDENTIAL_SENT]->(credential:Credential {id:$credentialId})
|
|
350
|
+
MATCH (credential)-[:INSTANCE_OF]->(:Boost {id:$boostId})
|
|
351
|
+
MATCH (credential)-[:ISSUED_VIA_TRANSACTION]->(transaction:ConsentFlowTransaction {action:'write'})
|
|
352
|
+
RETURN count(sent) AS deliveries, count(transaction) AS writes`,
|
|
353
|
+
{ ownerId, credentialId, boostId }
|
|
354
|
+
);
|
|
355
|
+
expect(Number(delivered.records[0]?.get('deliveries'))).toBe(1);
|
|
356
|
+
expect(Number(delivered.records[0]?.get('writes'))).toBe(1);
|
|
357
|
+
});
|
|
358
|
+
it('advances guardian approval only for a quiet live migration and preserves its history', async () => {
|
|
359
|
+
const actor = await getUser(randomUUID().replaceAll('-', '').repeat(2));
|
|
360
|
+
const holder = await getUser(randomUUID().replaceAll('-', '').repeat(2));
|
|
361
|
+
const ownerProfileId = randomUUID();
|
|
362
|
+
const holderProfileId = randomUUID();
|
|
363
|
+
profileIds.push(ownerProfileId, holderProfileId);
|
|
364
|
+
await actor.clients.fullAuth.profile.createProfile({ profileId: ownerProfileId });
|
|
365
|
+
await holder.clients.fullAuth.profile.createProfile({ profileId: holderProfileId });
|
|
366
|
+
const uri = await actor.clients.fullAuth.contracts.createConsentFlowContract({
|
|
367
|
+
contract: minimalContract,
|
|
368
|
+
name: 'Guardian quiet migration regression',
|
|
369
|
+
});
|
|
370
|
+
const contractId = getIdFromUri(uri);
|
|
371
|
+
contractIds.push(contractId);
|
|
372
|
+
const { termsUri } = await holder.clients.fullAuth.contracts.consentToContract({
|
|
373
|
+
contractUri: uri,
|
|
374
|
+
terms: minimalTerms,
|
|
375
|
+
});
|
|
376
|
+
const relationship = await getContractTermsByUri(termsUri);
|
|
377
|
+
if (!relationship) throw new Error('Could not load persisted consent fixture');
|
|
378
|
+
const termsId = relationship.terms.id;
|
|
379
|
+
termsIds.push(termsId);
|
|
380
|
+
const version1 = await getConsentFlowContractVersionRecord(contractId, 1);
|
|
381
|
+
if (!version1) throw new Error('Could not load initial contract version');
|
|
382
|
+
const approval = {
|
|
383
|
+
guardianProfileId: randomUUID(),
|
|
384
|
+
guardianDid: `did:example:${randomUUID()}`,
|
|
385
|
+
approvedAt: new Date().toISOString(),
|
|
386
|
+
contractUpdatedAt: version1.createdAt,
|
|
387
|
+
};
|
|
388
|
+
await neogma.queryRunner.run(
|
|
389
|
+
`MATCH (terms:ConsentFlowTerms {id:$termsId})
|
|
390
|
+
SET terms['guardianApproval.guardianProfileId']=$guardianProfileId,
|
|
391
|
+
terms['guardianApproval.guardianDid']=$guardianDid,
|
|
392
|
+
terms['guardianApproval.approvedAt']=$approvedAt,
|
|
393
|
+
terms['guardianApproval.contractUpdatedAt']=$contractUpdatedAt
|
|
394
|
+
WITH terms
|
|
395
|
+
MATCH (transaction:ConsentFlowTransaction)-[:IS_FOR]->(terms)
|
|
396
|
+
WHERE transaction.action='consent'
|
|
397
|
+
SET transaction['guardianApproval.guardianProfileId']=$guardianProfileId,
|
|
398
|
+
transaction['guardianApproval.guardianDid']=$guardianDid,
|
|
399
|
+
transaction['guardianApproval.approvedAt']=$approvedAt,
|
|
400
|
+
transaction['guardianApproval.contractUpdatedAt']=$contractUpdatedAt`,
|
|
401
|
+
{ termsId, ...approval }
|
|
402
|
+
);
|
|
403
|
+
const optionalCategoryContract = {
|
|
404
|
+
...minimalContract,
|
|
405
|
+
write: {
|
|
406
|
+
...minimalContract.write,
|
|
407
|
+
credentials: {
|
|
408
|
+
...minimalContract.write.credentials,
|
|
409
|
+
categories: { OptionalAddition: { required: false } },
|
|
410
|
+
},
|
|
411
|
+
},
|
|
412
|
+
};
|
|
413
|
+
const updated = await updateConsentFlowContractVersion(
|
|
414
|
+
{ uri, changes: { contract: optionalCategoryContract } },
|
|
415
|
+
ownerProfileId,
|
|
416
|
+
'localhost'
|
|
417
|
+
);
|
|
418
|
+
expect(updated).toMatchObject({ version: 2, kind: 'expanded_optional' });
|
|
419
|
+
const version2 = await getConsentFlowContractVersionRecord(contractId, 2);
|
|
420
|
+
const after = await getContractTermsByUri(termsUri);
|
|
421
|
+
expect(after?.terms.status).toBe('live');
|
|
422
|
+
expect(after?.terms.guardianApproval).toEqual({
|
|
423
|
+
...approval,
|
|
424
|
+
contractUpdatedAt: version2?.createdAt,
|
|
425
|
+
});
|
|
426
|
+
const history = await getTransactionsForTerms(termsId, { limit: 10 });
|
|
427
|
+
expect(
|
|
428
|
+
history.find(transaction => transaction.action === 'consent')?.guardianApproval
|
|
429
|
+
).toEqual(approval);
|
|
430
|
+
expect(history.some(transaction => transaction.action === 'update')).toBe(true);
|
|
431
|
+
});
|
|
432
|
+
});
|