@verii/server-credentialagent 1.0.0-pre.1752076816
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/.localdev.e2e.env +40 -0
- package/.localdev.env +41 -0
- package/.standalone.env +5 -0
- package/LICENSE +202 -0
- package/NOTICE +1 -0
- package/README.md +19 -0
- package/docker/compose.yml +33 -0
- package/e2e/README.md +12 -0
- package/e2e/org-registration-and-issuing.e2e.test.js +624 -0
- package/jest.config.js +20 -0
- package/migrate-mongo.config.js +36 -0
- package/migrations/20210317133137-add-index-to-offers-repo.js +57 -0
- package/migrations/20210416145639-add-index-to-revocation-list.js +27 -0
- package/migrations/20210719120225-add_unique_did_index_to_tenant.js +45 -0
- package/migrations/20230524053029-add-vendorUserIdMappings-index.js +32 -0
- package/migrations/20230616111907-add-configuration-type-index.js +32 -0
- package/package.json +108 -0
- package/src/assets/public/favicon.ico +0 -0
- package/src/assets/public/logo192.png +0 -0
- package/src/assets/public/logo512.png +0 -0
- package/src/assets/public/manifest.json +28 -0
- package/src/assets/templates/app-redirect.hbs +16 -0
- package/src/config/config.js +44 -0
- package/src/config/core-config.js +143 -0
- package/src/config/holder-config.js +104 -0
- package/src/config/index.js +22 -0
- package/src/config/operator-config.js +64 -0
- package/src/controllers/autoload-holder-api-controllers.js +30 -0
- package/src/controllers/autoload-operator-api-controllers.js +31 -0
- package/src/controllers/autoload-root-api-controller.js +30 -0
- package/src/controllers/autoload-saasoperator-api-controllers.js +31 -0
- package/src/controllers/holder/autohooks.js +55 -0
- package/src/controllers/holder/get-exchange-progress/autohooks.js +27 -0
- package/src/controllers/holder/get-exchange-progress/controller.js +50 -0
- package/src/controllers/holder/inspect/autohooks.js +35 -0
- package/src/controllers/holder/inspect/get-presentation-request/controller.js +100 -0
- package/src/controllers/holder/inspect/schemas/holder-disclosure.schema.json +73 -0
- package/src/controllers/holder/inspect/schemas/index.js +33 -0
- package/src/controllers/holder/inspect/schemas/presentation-definition.v1.schema.json +461 -0
- package/src/controllers/holder/inspect/schemas/presentation-request.schema.json +279 -0
- package/src/controllers/holder/inspect/schemas/presentation-submission.schema.json +41 -0
- package/src/controllers/holder/inspect/schemas/siop-presentation-submission.schema.json +74 -0
- package/src/controllers/holder/inspect/schemas/velocity-presentation-submission.response.200.schema.json +36 -0
- package/src/controllers/holder/inspect/schemas/velocity-presentation-submission.schema.json +34 -0
- package/src/controllers/holder/inspect/submit-presentation/controller.js +89 -0
- package/src/controllers/holder/issue/autohooks.js +23 -0
- package/src/controllers/holder/issue/get-credential-manifest/controller.js +193 -0
- package/src/controllers/holder/issue/offers/autohooks.js +35 -0
- package/src/controllers/holder/issue/offers/controller.js +164 -0
- package/src/controllers/holder/issue/offers/credential-offers/controller.js +460 -0
- package/src/controllers/holder/issue/submit-identification/autohooks.js +37 -0
- package/src/controllers/holder/issue/submit-identification/controller.js +63 -0
- package/src/controllers/holder/oauth/autohooks.js +19 -0
- package/src/controllers/holder/oauth/controller.js +140 -0
- package/src/controllers/index.js +22 -0
- package/src/controllers/operator/tenants/_tenantId/autohooks.js +40 -0
- package/src/controllers/operator/tenants/_tenantId/check-credentials/autohooks.js +24 -0
- package/src/controllers/operator/tenants/_tenantId/check-credentials/controller-v0.8.js +200 -0
- package/src/controllers/operator/tenants/_tenantId/check-credentials/schemas/index.js +19 -0
- package/src/controllers/operator/tenants/_tenantId/check-credentials/schemas/vendor-credential.schema.json +244 -0
- package/src/controllers/operator/tenants/_tenantId/controller-v0.8.js +221 -0
- package/src/controllers/operator/tenants/_tenantId/disclosures/_id/autohooks.js +30 -0
- package/src/controllers/operator/tenants/_tenantId/disclosures/_id/controller-v0.8.js +271 -0
- package/src/controllers/operator/tenants/_tenantId/disclosures/_id/feeds/autohooks.js +45 -0
- package/src/controllers/operator/tenants/_tenantId/disclosures/_id/feeds/controller-v0.8.js +199 -0
- package/src/controllers/operator/tenants/_tenantId/disclosures/_id/feeds/schemas/add-feed.schema.js +14 -0
- package/src/controllers/operator/tenants/_tenantId/disclosures/_id/feeds/schemas/feed.schema.json +27 -0
- package/src/controllers/operator/tenants/_tenantId/disclosures/_id/feeds/schemas/index.js +25 -0
- package/src/controllers/operator/tenants/_tenantId/disclosures/_id/feeds/schemas/modify-feed-update-body.schema.js +18 -0
- package/src/controllers/operator/tenants/_tenantId/disclosures/_id/feeds/schemas/modify-feed.schema.json +19 -0
- package/src/controllers/operator/tenants/_tenantId/disclosures/autohooks.js +34 -0
- package/src/controllers/operator/tenants/_tenantId/disclosures/controller-v0.8.js +100 -0
- package/src/controllers/operator/tenants/_tenantId/disclosures/schemas/agent-disclosure-presentation-definition.schema.json +404 -0
- package/src/controllers/operator/tenants/_tenantId/disclosures/schemas/agent-disclosure.schema.js +24 -0
- package/src/controllers/operator/tenants/_tenantId/disclosures/schemas/index.js +29 -0
- package/src/controllers/operator/tenants/_tenantId/disclosures/schemas/new-agent-disclosure.schema.json +166 -0
- package/src/controllers/operator/tenants/_tenantId/disclosures/schemas/update-agent-disclosure.schema.js +20 -0
- package/src/controllers/operator/tenants/_tenantId/exchanges/_exchangeId/autohooks.js +30 -0
- package/src/controllers/operator/tenants/_tenantId/exchanges/_exchangeId/controller-v0.8.js +73 -0
- package/src/controllers/operator/tenants/_tenantId/exchanges/autohooks.js +19 -0
- package/src/controllers/operator/tenants/_tenantId/exchanges/controller-v0.8.js +150 -0
- package/src/controllers/operator/tenants/_tenantId/exchanges/schemas/get-exchange.response.body.json +147 -0
- package/src/controllers/operator/tenants/_tenantId/exchanges/schemas/index.js +21 -0
- package/src/controllers/operator/tenants/_tenantId/issued-credentials/autohooks.js +27 -0
- package/src/controllers/operator/tenants/_tenantId/issued-credentials/controller-v0.8.js +303 -0
- package/src/controllers/operator/tenants/_tenantId/issued-credentials/schemas/index.js +23 -0
- package/src/controllers/operator/tenants/_tenantId/issued-credentials/schemas/issued-credential.schema.json +115 -0
- package/src/controllers/operator/tenants/_tenantId/issued-credentials/schemas/revoke-credentials.schema.json +18 -0
- package/src/controllers/operator/tenants/_tenantId/keys/controller-v0.8.js +168 -0
- package/src/controllers/operator/tenants/_tenantId/offer-data/controller-v0.8.js +78 -0
- package/src/controllers/operator/tenants/_tenantId/offers/autohooks.js +34 -0
- package/src/controllers/operator/tenants/_tenantId/offers/controller-v0.8.js +253 -0
- package/src/controllers/operator/tenants/_tenantId/offers/schemas/index.js +23 -0
- package/src/controllers/operator/tenants/_tenantId/offers/schemas/new-vendor-offer.schema.js +47 -0
- package/src/controllers/operator/tenants/_tenantId/offers/schemas/vendor-offer.schema.json +56 -0
- package/src/controllers/operator/tenants/_tenantId/users/autohooks.js +24 -0
- package/src/controllers/operator/tenants/_tenantId/users/controller-v0.8.js +92 -0
- package/src/controllers/operator/tenants/_tenantId/users/schemas/index.js +23 -0
- package/src/controllers/operator/tenants/_tenantId/users/schemas/new-user.schema.json +13 -0
- package/src/controllers/operator/tenants/_tenantId/users/schemas/user.schema.json +16 -0
- package/src/controllers/operator/tenants/_tenantId/vc-api/credentials/autohooks.js +34 -0
- package/src/controllers/operator/tenants/_tenantId/vc-api/credentials/controller-v0.8.js +110 -0
- package/src/controllers/operator/tenants/_tenantId/vc-api/credentials/schemas/Credential.schema.js +18 -0
- package/src/controllers/operator/tenants/_tenantId/vc-api/credentials/schemas/IssueCredentialOptions.schema.json +42 -0
- package/src/controllers/operator/tenants/_tenantId/vc-api/credentials/schemas/IssueCredentialRequest.schema.json +13 -0
- package/src/controllers/operator/tenants/_tenantId/vc-api/credentials/schemas/IssueCredentialResponse.schema.json +19 -0
- package/src/controllers/operator/tenants/_tenantId/vc-api/credentials/schemas/LinkedDataProof.schema.json +43 -0
- package/src/controllers/operator/tenants/_tenantId/vc-api/credentials/schemas/VerifiableCredential.schema.js +16 -0
- package/src/controllers/operator/tenants/_tenantId/vc-api/credentials/schemas/index.js +31 -0
- package/src/controllers/operator/tenants/autohooks.js +65 -0
- package/src/controllers/operator/tenants/controller-v0.8.js +167 -0
- package/src/controllers/operator/tenants/schemas/index.js +41 -0
- package/src/controllers/operator/tenants/schemas/modify-secret.schema.json +11 -0
- package/src/controllers/operator/tenants/schemas/modify-tenant-v0.8.schema.json +44 -0
- package/src/controllers/operator/tenants/schemas/new-tenant-v0.8.schema.json +19 -0
- package/src/controllers/operator/tenants/schemas/new-tenant.response.200.schema.json +7 -0
- package/src/controllers/operator/tenants/schemas/secret-key-metadata.schema.json +31 -0
- package/src/controllers/operator/tenants/schemas/secret-key.schema.json +29 -0
- package/src/controllers/operator/tenants/schemas/secret-kid.schema.json +13 -0
- package/src/controllers/operator/tenants/schemas/secret-new-tenant-v0.8.schema.json +28 -0
- package/src/controllers/operator/tenants/schemas/secret-tenant-key-v0.8.schema.json +13 -0
- package/src/controllers/operator/tenants/schemas/tenant-key-v0.8.schema.json +14 -0
- package/src/controllers/operator/tenants/schemas/tenant-v0.8.schema.json +62 -0
- package/src/controllers/root/autohooks.js +23 -0
- package/src/controllers/root/controller.js +173 -0
- package/src/controllers/saasoperator/groups/_id/autohooks.js +9 -0
- package/src/controllers/saasoperator/groups/_id/controller.js +121 -0
- package/src/controllers/saasoperator/groups/autohooks.js +19 -0
- package/src/controllers/saasoperator/groups/controller.js +65 -0
- package/src/controllers/saasoperator/groups/schemas/group.schema.js +17 -0
- package/src/controllers/saasoperator/groups/schemas/index.js +4 -0
- package/src/controllers/saasoperator/groups/schemas/new-group.schema.js +13 -0
- package/src/entities/common/domains/get-json-at-path.js +28 -0
- package/src/entities/common/domains/index.js +17 -0
- package/src/entities/common/index.js +17 -0
- package/src/entities/credentials/domains/credential-format.js +22 -0
- package/src/entities/credentials/domains/index.js +19 -0
- package/src/entities/credentials/index.js +17 -0
- package/src/entities/deep-links/domains/extract-did.js +11 -0
- package/src/entities/deep-links/domains/index.js +20 -0
- package/src/entities/deep-links/domains/velocity-protocol-uri-to-http-uri.js +32 -0
- package/src/entities/deep-links/index.js +19 -0
- package/src/entities/disclosures/domains/assert-disclosure-active.js +21 -0
- package/src/entities/disclosures/domains/compute-disclosure-configuration-type.js +29 -0
- package/src/entities/disclosures/domains/constants.js +61 -0
- package/src/entities/disclosures/domains/errors.js +34 -0
- package/src/entities/disclosures/domains/get-disclosure-configuration-type.js +60 -0
- package/src/entities/disclosures/domains/index.js +32 -0
- package/src/entities/disclosures/domains/is-issuing-disclosure.js +23 -0
- package/src/entities/disclosures/domains/parse-body-to-disclosure.js +17 -0
- package/src/entities/disclosures/domains/validate-by-identification-method.js +69 -0
- package/src/entities/disclosures/domains/validate-commercial-entity.js +26 -0
- package/src/entities/disclosures/domains/validate-disclosure-by-configuration-type.js +47 -0
- package/src/entities/disclosures/domains/validate-disclosure-default-issuing.js +77 -0
- package/src/entities/disclosures/domains/validate-disclosure.js +37 -0
- package/src/entities/disclosures/domains/validate-feed.js +16 -0
- package/src/entities/disclosures/domains/validate-presentation-definition.js +54 -0
- package/src/entities/disclosures/domains/validate-vendor-endpoint.js +22 -0
- package/src/entities/disclosures/domains/validate-vendor-webhook.js +18 -0
- package/src/entities/disclosures/factories/disclosure-factory.js +94 -0
- package/src/entities/disclosures/factories/index.js +19 -0
- package/src/entities/disclosures/index.js +22 -0
- package/src/entities/disclosures/orchestrators/get-disclosure.js +18 -0
- package/src/entities/disclosures/orchestrators/index.js +20 -0
- package/src/entities/disclosures/orchestrators/update-disclosure-configuration-type.js +32 -0
- package/src/entities/disclosures/repos/index.js +20 -0
- package/src/entities/disclosures/repos/repo.js +118 -0
- package/src/entities/disclosures/repos/set-configuration-type.js +33 -0
- package/src/entities/exchanges/adapters/index.js +17 -0
- package/src/entities/exchanges/adapters/sign-exchange-response.js +45 -0
- package/src/entities/exchanges/domains/build-exchange-progress.js +56 -0
- package/src/entities/exchanges/domains/constants.js +24 -0
- package/src/entities/exchanges/domains/ensure-exchange-state-valid.js +35 -0
- package/src/entities/exchanges/domains/errors.js +33 -0
- package/src/entities/exchanges/domains/index.js +25 -0
- package/src/entities/exchanges/domains/states.js +43 -0
- package/src/entities/exchanges/domains/types.js +31 -0
- package/src/entities/exchanges/factories/disclosure-exchange-factory.js +46 -0
- package/src/entities/exchanges/factories/index.js +20 -0
- package/src/entities/exchanges/factories/offer-exchange-factory.js +48 -0
- package/src/entities/exchanges/index.js +23 -0
- package/src/entities/exchanges/orchestrators/build-exchange-request-deep-link.js +50 -0
- package/src/entities/exchanges/orchestrators/index.js +19 -0
- package/src/entities/exchanges/repos/exchange-repo-projections.js +45 -0
- package/src/entities/exchanges/repos/exchange-state-repo-extension.js +76 -0
- package/src/entities/exchanges/repos/index.js +20 -0
- package/src/entities/exchanges/repos/repo.js +44 -0
- package/src/entities/feeds/factories/feed-factory.js +47 -0
- package/src/entities/feeds/factories/index.js +19 -0
- package/src/entities/feeds/index.js +20 -0
- package/src/entities/feeds/repos/index.js +19 -0
- package/src/entities/feeds/repos/repo.js +95 -0
- package/src/entities/groups/domains/format-group.js +11 -0
- package/src/entities/groups/domains/index.js +3 -0
- package/src/entities/groups/factories/group-factory.js +40 -0
- package/src/entities/groups/factories/index.js +19 -0
- package/src/entities/groups/index.js +22 -0
- package/src/entities/groups/orchestrators/find-group-or-error.js +16 -0
- package/src/entities/groups/orchestrators/index.js +6 -0
- package/src/entities/groups/orchestrators/validate-did.js +24 -0
- package/src/entities/groups/orchestrators/validate-group-by-user.js +16 -0
- package/src/entities/groups/orchestrators/validate-group.js +39 -0
- package/src/entities/groups/repos/delete-tenant-extension.js +13 -0
- package/src/entities/groups/repos/index.js +19 -0
- package/src/entities/groups/repos/repo.js +38 -0
- package/src/entities/groups/repos/update-or-error-extension.js +46 -0
- package/src/entities/index.js +37 -0
- package/src/entities/keys/domains/constants.js +37 -0
- package/src/entities/keys/domains/index.js +21 -0
- package/src/entities/keys/domains/is-matching-private-key-kid.js +41 -0
- package/src/entities/keys/domains/validate-key.js +62 -0
- package/src/entities/keys/factories/index.js +19 -0
- package/src/entities/keys/factories/key-factory.js +56 -0
- package/src/entities/keys/index.js +22 -0
- package/src/entities/keys/orchestrators/index.js +3 -0
- package/src/entities/keys/orchestrators/validate-did-doc-keys.js +69 -0
- package/src/entities/metadata-list-allocations/index.js +19 -0
- package/src/entities/metadata-list-allocations/repos/index.js +19 -0
- package/src/entities/metadata-list-allocations/repos/repo.js +40 -0
- package/src/entities/notifications/domains/index.js +19 -0
- package/src/entities/notifications/domains/notification-types.js +25 -0
- package/src/entities/notifications/index.js +19 -0
- package/src/entities/offers/domains/build-clean-pii-filter.js +35 -0
- package/src/entities/offers/domains/build-deeplink-url.js +120 -0
- package/src/entities/offers/domains/build-offer.js +88 -0
- package/src/entities/offers/domains/build-qr-code-url.js +37 -0
- package/src/entities/offers/domains/constants.js +32 -0
- package/src/entities/offers/domains/filter-object-ids.js +34 -0
- package/src/entities/offers/domains/generate-issuing-challenge.js +26 -0
- package/src/entities/offers/domains/generate-link-code.js +35 -0
- package/src/entities/offers/domains/index.js +31 -0
- package/src/entities/offers/domains/post-validation-offers-handler.js +31 -0
- package/src/entities/offers/domains/prepare-linked-credentials-for-holder.js +36 -0
- package/src/entities/offers/domains/resolve-subject.js +142 -0
- package/src/entities/offers/domains/validate-offer-commercial-entity.js +24 -0
- package/src/entities/offers/domains/validate-offer.js +90 -0
- package/src/entities/offers/factories/index.js +19 -0
- package/src/entities/offers/factories/offer-factory.js +119 -0
- package/src/entities/offers/index.js +22 -0
- package/src/entities/offers/orchestrators/create-verifiable-credentials.js +131 -0
- package/src/entities/offers/orchestrators/finalize-exchange.js +44 -0
- package/src/entities/offers/orchestrators/index.js +23 -0
- package/src/entities/offers/orchestrators/load-credential-refs.js +57 -0
- package/src/entities/offers/orchestrators/load-credential-types-map.js +44 -0
- package/src/entities/offers/orchestrators/prepare-offers.js +35 -0
- package/src/entities/offers/orchestrators/trigger-issued-credentials-webhook.js +63 -0
- package/src/entities/offers/repos/clean-pii-extension.js +85 -0
- package/src/entities/offers/repos/index.js +20 -0
- package/src/entities/offers/repos/issued-credential-projection.js +44 -0
- package/src/entities/offers/repos/repo.js +177 -0
- package/src/entities/presentations/domains/build-identity-doc.js +120 -0
- package/src/entities/presentations/domains/build-request-response-schema.js +46 -0
- package/src/entities/presentations/domains/build-vendor-data.js +31 -0
- package/src/entities/presentations/domains/check-payment-requirement.js +30 -0
- package/src/entities/presentations/domains/errors.js +28 -0
- package/src/entities/presentations/domains/extract-fields-from-id-credential.js +35 -0
- package/src/entities/presentations/domains/index.js +26 -0
- package/src/entities/presentations/domains/merge-credential-check-results.js +24 -0
- package/src/entities/presentations/domains/validate-presentation.js +128 -0
- package/src/entities/presentations/index.js +20 -0
- package/src/entities/presentations/orchestrators/create-presentation-request.js +148 -0
- package/src/entities/presentations/orchestrators/deduplicate-disclosure-exchange.js +52 -0
- package/src/entities/presentations/orchestrators/handle-presentation-submission.js +47 -0
- package/src/entities/presentations/orchestrators/index.js +20 -0
- package/src/entities/presentations/orchestrators/match-identity-on-exchange.js +114 -0
- package/src/entities/presentations/orchestrators/share-identification-credentials.js +110 -0
- package/src/entities/presentations/orchestrators/share-presentation.js +234 -0
- package/src/entities/push-delegate/get-push-delegate.js +37 -0
- package/src/entities/push-delegate/index.js +17 -0
- package/src/entities/redirect/index.js +3 -0
- package/src/entities/redirect/orchestrators/index.js +3 -0
- package/src/entities/redirect/orchestrators/load-org-info.js +40 -0
- package/src/entities/revocation-list-allocations/index.js +19 -0
- package/src/entities/revocation-list-allocations/repos/index.js +19 -0
- package/src/entities/revocation-list-allocations/repos/repo.js +40 -0
- package/src/entities/schemas/index.js +19 -0
- package/src/entities/schemas/orchestrators/index.js +19 -0
- package/src/entities/schemas/orchestrators/load-schema-validation.js +73 -0
- package/src/entities/tenants/domains/build-service-ids.js +27 -0
- package/src/entities/tenants/domains/extract-service.js +27 -0
- package/src/entities/tenants/domains/index.js +21 -0
- package/src/entities/tenants/domains/validate-service-ids.js +35 -0
- package/src/entities/tenants/factories/index.js +19 -0
- package/src/entities/tenants/factories/tenant-factory.js +37 -0
- package/src/entities/tenants/index.js +22 -0
- package/src/entities/tenants/orchestrators/add-primary-address-to-tenant.js +47 -0
- package/src/entities/tenants/orchestrators/create-tenant.js +91 -0
- package/src/entities/tenants/orchestrators/index.js +22 -0
- package/src/entities/tenants/orchestrators/refresh-tenant-dids.js +146 -0
- package/src/entities/tenants/orchestrators/set-tenant-default-issuing-disclosure.js +31 -0
- package/src/entities/tenants/repos/index.js +20 -0
- package/src/entities/tenants/repos/insert-tenant-extension.js +33 -0
- package/src/entities/tenants/repos/repo.js +52 -0
- package/src/entities/tenants/repos/tenant-default-projection.js +33 -0
- package/src/entities/tokens/adapters/access-token.js +49 -0
- package/src/entities/tokens/adapters/index.js +19 -0
- package/src/entities/tokens/index.js +19 -0
- package/src/entities/users/factories/index.js +19 -0
- package/src/entities/users/factories/user-factory.js +36 -0
- package/src/entities/users/index.js +20 -0
- package/src/entities/users/repos/add-anonymous-user-repo-extension.js +23 -0
- package/src/entities/users/repos/find-or-insert-vendor-user-repo-extension.js +30 -0
- package/src/entities/users/repos/index.js +19 -0
- package/src/entities/users/repos/repo.js +50 -0
- package/src/fetchers/index.js +20 -0
- package/src/fetchers/operator/identify-fetcher.js +36 -0
- package/src/fetchers/operator/index.js +21 -0
- package/src/fetchers/operator/inspection-fetcher.js +35 -0
- package/src/fetchers/operator/issuing-fetcher.js +50 -0
- package/src/fetchers/operator/webhook-auth-header.js +45 -0
- package/src/fetchers/push-gateway/generate-push-gateway-token.js +40 -0
- package/src/fetchers/push-gateway/index.js +19 -0
- package/src/fetchers/push-gateway/push-fetcher.js +39 -0
- package/src/index.js +19 -0
- package/src/init-holder-server.js +108 -0
- package/src/init-operator-server.js +101 -0
- package/src/init-server.js +120 -0
- package/src/main-holder.js +18 -0
- package/src/main-operator.js +19 -0
- package/src/main.js +18 -0
- package/src/plugins/autoload-repos.js +28 -0
- package/src/plugins/disclosure-loader-plugin.js +56 -0
- package/src/plugins/ensure-disclosure-active-plugin.js +30 -0
- package/src/plugins/ensure-disclosure-configuration-type-plugin.js +29 -0
- package/src/plugins/ensure-tenant-default-issuing-disclosure-id-plugin.js +60 -0
- package/src/plugins/ensure-tenant-primary-address-plugin.js +44 -0
- package/src/plugins/exchange-error-handler-plugin.js +51 -0
- package/src/plugins/exchange-loader-plugin.js +50 -0
- package/src/plugins/group-loader-plugin.js +51 -0
- package/src/plugins/index.js +32 -0
- package/src/plugins/kms-plugin.js +57 -0
- package/src/plugins/tenant-loader-plugin.js +91 -0
- package/src/plugins/validate-cao-plugin.js +81 -0
- package/src/plugins/vendor-routes-auth-plugin.js +24 -0
- package/src/plugins/verify-access-token-plugin.js +88 -0
- package/src/standalone.js +24 -0
- package/src/start-app-server.js +38 -0
- package/test/combined/app-redirect.test.js +199 -0
- package/test/combined/helpers/credentialagent-build-fastify.js +29 -0
- package/test/combined/helpers/index.js +22 -0
- package/test/combined/helpers/nock-registrar-app-schema-name.js +50 -0
- package/test/combined/helpers/nock-registrar-get-organization-diddoc.js +26 -0
- package/test/combined/helpers/nock-registrar-get-organization-verified-profile.js +33 -0
- package/test/combined/manifest.json.test.js +55 -0
- package/test/combined/root-controller.test.js +42 -0
- package/test/combined/schemas/education-degree.schema.json +166 -0
- package/test/combined/schemas/employment-current-v1.1.schema.json +253 -0
- package/test/combined/schemas/open-badge-credential.schema.json +1285 -0
- package/test/combined/schemas/past-employment-position-with-uri-id.schema.js +22 -0
- package/test/combined/schemas/past-employment-position.schema.json +148 -0
- package/test/combined/schemas/will-always-validate.json +10 -0
- package/test/combined/validate-cao-plugin.test.js +155 -0
- package/test/get-push-delegate.test.js +54 -0
- package/test/helpers/jwt-vc-expectation.js +109 -0
- package/test/holder/build-request-response-schema.test.js +55 -0
- package/test/holder/credential-manifest-controller.test.js +3192 -0
- package/test/holder/e2e-issuing-controller.test.js +425 -0
- package/test/holder/get-exchange-progress-controller.test.js +521 -0
- package/test/holder/get-presentation-request.test.js +906 -0
- package/test/holder/helpers/credential-type-metadata.js +98 -0
- package/test/holder/helpers/credentialagent-holder-build-fastify.js +32 -0
- package/test/holder/helpers/generate-presentation.js +441 -0
- package/test/holder/helpers/generate-test-access-token.js +54 -0
- package/test/holder/helpers/jwt-access-token-expectation.js +32 -0
- package/test/holder/helpers/jwt-vc-expectation.js +115 -0
- package/test/holder/issuing-controller.test.js +7076 -0
- package/test/holder/oauth-token-controller.test.js +412 -0
- package/test/holder/presentation-submission.test.js +2365 -0
- package/test/holder/submit-identification.test.js +4815 -0
- package/test/operator/check-credentials-controller-v0.8.test.js +832 -0
- package/test/operator/credentials-revoke.test.js +536 -0
- package/test/operator/disclosures-controller-v0.8.test.js +4157 -0
- package/test/operator/exchanges-controller-v0.8.test.js +414 -0
- package/test/operator/exchanges-id-controller-v0.8.test.js +162 -0
- package/test/operator/feeds-controller-v0.8.test.js +659 -0
- package/test/operator/generate-push-gateway-token.test.js +116 -0
- package/test/operator/groups-controller.test.js +145 -0
- package/test/operator/groups-id-controller.test.js +287 -0
- package/test/operator/helpers/create-test-org-doc.js +60 -0
- package/test/operator/helpers/credentialagent-operator-build-fastify.js +32 -0
- package/test/operator/helpers/find-kms-key.js +31 -0
- package/test/operator/helpers/generate-primary-and-add-operator-to-primary.js +63 -0
- package/test/operator/helpers/init-agent-kms.js +22 -0
- package/test/operator/issued-credentials-controller-v0.8.test.js +398 -0
- package/test/operator/keys-controller-v0.8.test.js +1130 -0
- package/test/operator/offer-data-controller-v0.8.test.js +253 -0
- package/test/operator/offers-controller-v0.8.test.js +3026 -0
- package/test/operator/set-configuration-type-modifier.test.js +75 -0
- package/test/operator/swagger.test.js +37 -0
- package/test/operator/tenant-controller-v0.8.test.js +730 -0
- package/test/operator/tenant-loader-plugin.test.js +96 -0
- package/test/operator/tenants-controller-v0.8.test.js +2093 -0
- package/test/operator/users-controller-v0.8.test.js +137 -0
- package/test/operator/vc-api-credentials.test.js +963 -0
- package/verification.env +28 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const {
|
|
18
|
+
repoFactory,
|
|
19
|
+
autoboxIdsExtension,
|
|
20
|
+
} = require('@spencejs/spence-mongo-repos');
|
|
21
|
+
const { multitenantExtension } = require('@verii/spencer-mongo-extensions');
|
|
22
|
+
const { size, map, pick } = require('lodash/fp');
|
|
23
|
+
const { ObjectId } = require('mongodb');
|
|
24
|
+
const {
|
|
25
|
+
issuedCredentialProjection,
|
|
26
|
+
} = require('./issued-credential-projection');
|
|
27
|
+
const { cleanPiiExtension } = require('./clean-pii-extension');
|
|
28
|
+
|
|
29
|
+
module.exports = (app, options, next = () => {}) => {
|
|
30
|
+
next();
|
|
31
|
+
return repoFactory(
|
|
32
|
+
{
|
|
33
|
+
name: 'offers',
|
|
34
|
+
entityName: 'offers',
|
|
35
|
+
defaultProjection: {
|
|
36
|
+
_id: 1,
|
|
37
|
+
'@context': 1,
|
|
38
|
+
exchangeId: 1,
|
|
39
|
+
issuer: 1,
|
|
40
|
+
type: 1,
|
|
41
|
+
offerId: 1,
|
|
42
|
+
credentialSubject: 1,
|
|
43
|
+
credentialSchema: 1,
|
|
44
|
+
credentialStatus: 1,
|
|
45
|
+
contentHash: 1,
|
|
46
|
+
linkCodeCommitment: 1,
|
|
47
|
+
linkedCredentials: 1,
|
|
48
|
+
replaces: 1,
|
|
49
|
+
relatedResource: 1,
|
|
50
|
+
digestSRI: 1,
|
|
51
|
+
name: 1,
|
|
52
|
+
description: 1,
|
|
53
|
+
image: 1,
|
|
54
|
+
awardedDate: 1,
|
|
55
|
+
endorsement: 1,
|
|
56
|
+
endorsementJwt: 1,
|
|
57
|
+
evidence: 1,
|
|
58
|
+
refreshService: 1,
|
|
59
|
+
termsOfUrl: 1,
|
|
60
|
+
notifiedOfRevocationAt: 1,
|
|
61
|
+
validFrom: 1,
|
|
62
|
+
validUntil: 1,
|
|
63
|
+
issuanceDate: 1,
|
|
64
|
+
expirationDate: 1,
|
|
65
|
+
createdAt: 1,
|
|
66
|
+
updatedAt: 1,
|
|
67
|
+
rejectedAt: 1,
|
|
68
|
+
consentedAt: 1,
|
|
69
|
+
},
|
|
70
|
+
extensions: [
|
|
71
|
+
autoboxIdsExtension,
|
|
72
|
+
multitenantExtension({
|
|
73
|
+
migrateFrom: { repoProp: 'issuer.id', tenantProp: 'did' },
|
|
74
|
+
}),
|
|
75
|
+
(parent) => ({
|
|
76
|
+
findUnexpiredOffersById: async (offerIds) =>
|
|
77
|
+
parent.find({
|
|
78
|
+
filter: {
|
|
79
|
+
_id: {
|
|
80
|
+
$in: offerIds,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
orderBy: [{ createdAt: 1 }],
|
|
84
|
+
}),
|
|
85
|
+
findUniquePreparedOffers: async (
|
|
86
|
+
{ vendorUserId, types, offerHashes, exchangeId = null },
|
|
87
|
+
{ log }
|
|
88
|
+
) => {
|
|
89
|
+
let mongoFilter = {
|
|
90
|
+
'credentialSubject.vendorUserId': vendorUserId,
|
|
91
|
+
consentedAt: { $exists: false },
|
|
92
|
+
rejectedAt: { $exists: false },
|
|
93
|
+
};
|
|
94
|
+
if (size(types)) {
|
|
95
|
+
mongoFilter.type = { $in: types };
|
|
96
|
+
}
|
|
97
|
+
if (size(offerHashes)) {
|
|
98
|
+
mongoFilter['contentHash.value'] = { $nin: offerHashes };
|
|
99
|
+
}
|
|
100
|
+
if (exchangeId != null) {
|
|
101
|
+
mongoFilter.exchangeId = exchangeId;
|
|
102
|
+
}
|
|
103
|
+
mongoFilter = parent.prepFilter(mongoFilter);
|
|
104
|
+
log.info({ message: 'findUniquePreparedOffers', mongoFilter });
|
|
105
|
+
const offers = await parent.find({ filter: mongoFilter });
|
|
106
|
+
// FYI don't run validation on the offer
|
|
107
|
+
return filterDuplicates(offers);
|
|
108
|
+
},
|
|
109
|
+
approveOffer: async (
|
|
110
|
+
id,
|
|
111
|
+
vendorUserId,
|
|
112
|
+
credential,
|
|
113
|
+
consentedAt,
|
|
114
|
+
digestSRI,
|
|
115
|
+
context
|
|
116
|
+
) => {
|
|
117
|
+
const { config } = context;
|
|
118
|
+
const updates = {
|
|
119
|
+
did: credential.id,
|
|
120
|
+
consentedAt: consentedAt ?? new Date(),
|
|
121
|
+
digestSRI,
|
|
122
|
+
...pick(
|
|
123
|
+
[
|
|
124
|
+
'credentialStatus',
|
|
125
|
+
'credentialSchema',
|
|
126
|
+
'linkCodeCommitment',
|
|
127
|
+
'issued',
|
|
128
|
+
'issuanceDate',
|
|
129
|
+
'type',
|
|
130
|
+
'@context',
|
|
131
|
+
],
|
|
132
|
+
credential
|
|
133
|
+
),
|
|
134
|
+
};
|
|
135
|
+
if (config.autocleanFinalizedOfferPii) {
|
|
136
|
+
updates.credentialSubject = { vendorUserId };
|
|
137
|
+
} else {
|
|
138
|
+
updates['credentialSubject.id'] = credential.credentialSubject.id;
|
|
139
|
+
}
|
|
140
|
+
return parent.update(id, updates, issuedCredentialProjection);
|
|
141
|
+
},
|
|
142
|
+
rejectOffers: async (vendorUserId, offerIds, context) => {
|
|
143
|
+
const { config } = context;
|
|
144
|
+
const updates = { rejectedAt: new Date() };
|
|
145
|
+
if (config.autocleanFinalizedOfferPii) {
|
|
146
|
+
updates.credentialSubject = { vendorUserId };
|
|
147
|
+
}
|
|
148
|
+
return parent.updateUsingFilter(
|
|
149
|
+
{
|
|
150
|
+
filter: {
|
|
151
|
+
_id: { $in: map((v) => new ObjectId(v), offerIds) },
|
|
152
|
+
rejectedAt: { $exists: false },
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
updates
|
|
156
|
+
);
|
|
157
|
+
},
|
|
158
|
+
}),
|
|
159
|
+
cleanPiiExtension,
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
app
|
|
163
|
+
);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const filterDuplicates = (offers) => {
|
|
167
|
+
const hashes = new Set();
|
|
168
|
+
const filtered = [];
|
|
169
|
+
for (const offer of offers) {
|
|
170
|
+
if (!hashes.has(offer.contentHash.value)) {
|
|
171
|
+
filtered.push(offer);
|
|
172
|
+
hashes.add(offer.contentHash.value);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return filtered;
|
|
177
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
reduce,
|
|
20
|
+
flow,
|
|
21
|
+
get,
|
|
22
|
+
filter,
|
|
23
|
+
first,
|
|
24
|
+
omitBy,
|
|
25
|
+
isNil,
|
|
26
|
+
} = require('lodash/fp');
|
|
27
|
+
const {
|
|
28
|
+
extractFieldsFromIdCredential,
|
|
29
|
+
} = require('./extract-fields-from-id-credential');
|
|
30
|
+
|
|
31
|
+
const buildIdentityDoc = (credentials, context) =>
|
|
32
|
+
reduce(
|
|
33
|
+
(acc, { credential, credentialChecks }) => {
|
|
34
|
+
const docCredential = buildDocCredential(
|
|
35
|
+
credential,
|
|
36
|
+
credentialChecks,
|
|
37
|
+
context
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
if (['PhoneV1.0', 'Phone'].includes(docCredential.credentialType)) {
|
|
41
|
+
acc.phoneCredentials.push(docCredential);
|
|
42
|
+
acc.phones.push(credential?.credentialSubject?.phone);
|
|
43
|
+
return acc;
|
|
44
|
+
}
|
|
45
|
+
if (['EmailV1.0', 'Email'].includes(docCredential.credentialType)) {
|
|
46
|
+
acc.emailCredentials.push(docCredential);
|
|
47
|
+
acc.emails.push(credential?.credentialSubject?.email);
|
|
48
|
+
return acc;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
acc.idDocumentCredentials.push(docCredential);
|
|
52
|
+
return {
|
|
53
|
+
...acc,
|
|
54
|
+
...extractFieldsFromIdCredential(
|
|
55
|
+
docCredential.credentialType,
|
|
56
|
+
credential,
|
|
57
|
+
context
|
|
58
|
+
),
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
emails: [],
|
|
63
|
+
phones: [],
|
|
64
|
+
emailCredentials: [],
|
|
65
|
+
idDocumentCredentials: [],
|
|
66
|
+
phoneCredentials: [],
|
|
67
|
+
},
|
|
68
|
+
credentials
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const buildDocCredential = (credential, credentialChecks, context) => {
|
|
72
|
+
const basicDocCredential = {
|
|
73
|
+
credentialType: flow([
|
|
74
|
+
get('type'),
|
|
75
|
+
filter((type) => type !== 'VerifiableCredential'),
|
|
76
|
+
first,
|
|
77
|
+
])(credential),
|
|
78
|
+
issuer: credential.issuer,
|
|
79
|
+
issuanceDate: credential.issuanceDate,
|
|
80
|
+
validUntil: extractValidUntil(credential),
|
|
81
|
+
validFrom: extractValidFrom(credential),
|
|
82
|
+
...addWebhookSpecificFields(credential, credentialChecks, context),
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
if (context.config.vendorCredentialsIncludeIssuedClaim) {
|
|
86
|
+
basicDocCredential.issued = credential.issuanceDate;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return omitBy(isNil, basicDocCredential);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const addWebhookSpecificFields = (
|
|
93
|
+
credential,
|
|
94
|
+
credentialChecks,
|
|
95
|
+
{ config: { identifyWebhookVersion } }
|
|
96
|
+
) => {
|
|
97
|
+
if (identifyWebhookVersion === 2) {
|
|
98
|
+
return {
|
|
99
|
+
id: credential.id,
|
|
100
|
+
credentialSchema: credential.credentialSchema,
|
|
101
|
+
type: credential.type,
|
|
102
|
+
credentialSubject: credential.credentialSubject,
|
|
103
|
+
credentialChecks,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return credential.credentialSubject; // credentialSubject hoisted in older versions. Remove by 01/01/2023
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const extractValidUntil = (credential) =>
|
|
110
|
+
credential?.credentialSubject?.validity?.validUntil ??
|
|
111
|
+
credential?.credentialSubject?.validUntil ??
|
|
112
|
+
credential?.validUntil ??
|
|
113
|
+
credential?.expirationDate;
|
|
114
|
+
|
|
115
|
+
const extractValidFrom = (credential) =>
|
|
116
|
+
credential?.credentialSubject?.validity?.validFrom ??
|
|
117
|
+
credential?.credentialSubject?.validFrom ??
|
|
118
|
+
credential?.validFrom;
|
|
119
|
+
|
|
120
|
+
module.exports = { buildIdentityDoc };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const buildRequestResponseSchema = (prefix, { isProd }) => {
|
|
18
|
+
const requestName = `${prefix}_request`;
|
|
19
|
+
const defaultResponse = {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: { [requestName]: { type: 'string' } },
|
|
22
|
+
required: [requestName],
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
if (isProd) {
|
|
26
|
+
return defaultResponse;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
oneOf: [
|
|
31
|
+
defaultResponse,
|
|
32
|
+
{
|
|
33
|
+
type: 'object',
|
|
34
|
+
properties: {
|
|
35
|
+
[requestName]: {
|
|
36
|
+
type: 'object',
|
|
37
|
+
additionalProperties: true,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
required: [requestName],
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
module.exports = { buildRequestResponseSchema };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
const buildVendorData = (
|
|
18
|
+
disclosure,
|
|
19
|
+
vendorOriginContext,
|
|
20
|
+
{ tenant, exchange }
|
|
21
|
+
) => ({
|
|
22
|
+
tenantId: tenant._id,
|
|
23
|
+
tenantDID: tenant.did,
|
|
24
|
+
exchangeId: exchange._id.toString(),
|
|
25
|
+
vendorOrganizationId: tenant.vendorOrganizationId,
|
|
26
|
+
vendorDisclosureId: disclosure.vendorDisclosureId,
|
|
27
|
+
vendorOriginContext,
|
|
28
|
+
sendPushOnVerification: disclosure.sendPushOnVerification,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
module.exports = { buildVendorData };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const { CheckResults } = require('@verii/vc-checks');
|
|
18
|
+
const { any } = require('lodash/fp');
|
|
19
|
+
|
|
20
|
+
const checkPaymentRequirement = (checkedCredentials) =>
|
|
21
|
+
any(
|
|
22
|
+
(credential) =>
|
|
23
|
+
CheckResults.VOUCHER_RESERVE_EXHAUSTED ===
|
|
24
|
+
credential.credentialChecks?.TRUSTED_ISSUER ||
|
|
25
|
+
CheckResults.VOUCHER_RESERVE_EXHAUSTED ===
|
|
26
|
+
credential.credentialChecks?.UNTAMPERED,
|
|
27
|
+
checkedCredentials
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
module.exports = { checkPaymentRequirement };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const PresentationErrors = {
|
|
18
|
+
INVALID_INTEGRATED_IDENTIFICATION_RULE:
|
|
19
|
+
'Credential Agent only supports "pick" or "all" for "identityMatchers.rule"',
|
|
20
|
+
PRESENTATION_JSON_PATH_MISSING: ({ path }) =>
|
|
21
|
+
`Presentation doesnt contain value at ${path}`,
|
|
22
|
+
CHECKS_FAILED: ({ reason, id }) =>
|
|
23
|
+
`${reason}_credential_check_failed_credential_${id}`,
|
|
24
|
+
PRESENTATION_PREAUTH_MUST_CONTAIN_VENDOR_ORIGIN_CONTEXT:
|
|
25
|
+
'Presentation for a preauth disclosure must contain a vendorOriginContext',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
module.exports = { PresentationErrors };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const { flow, isNil, mapValues, omitBy, pick, sample } = require('lodash/fp');
|
|
18
|
+
|
|
19
|
+
const idCredentialMapper = (credential) =>
|
|
20
|
+
flow(
|
|
21
|
+
pick(['firstName', 'lastName', 'middleNames', 'address', 'dob']),
|
|
22
|
+
omitBy(isNil),
|
|
23
|
+
mapValues((val) => sample(val?.localized) ?? val) // extracts out firstName.localized.en = "Sam" or otherwise assumes its a string.
|
|
24
|
+
)(credential?.credentialSubject);
|
|
25
|
+
|
|
26
|
+
const extractFieldsFromIdCredential = (credentialType, credential) => {
|
|
27
|
+
if (credentialType === 'IdDocument') {
|
|
28
|
+
return idCredentialMapper(credential);
|
|
29
|
+
}
|
|
30
|
+
return {};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
module.exports = {
|
|
34
|
+
extractFieldsFromIdCredential,
|
|
35
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
...require('./build-identity-doc'),
|
|
19
|
+
...require('./build-request-response-schema'),
|
|
20
|
+
...require('./build-vendor-data'),
|
|
21
|
+
...require('./check-payment-requirement'),
|
|
22
|
+
...require('./errors'),
|
|
23
|
+
...require('./extract-fields-from-id-credential'),
|
|
24
|
+
...require('./merge-credential-check-results'),
|
|
25
|
+
...require('./validate-presentation'),
|
|
26
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
const { map } = require('lodash/fp');
|
|
18
|
+
|
|
19
|
+
const mergeCredentialCheckResults = map(({ credential, credentialChecks }) => ({
|
|
20
|
+
...credential,
|
|
21
|
+
credentialChecks,
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
module.exports = { mergeCredentialCheckResults };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const createError = require('http-errors');
|
|
19
|
+
const { reduce, isEmpty, first, includes } = require('lodash/fp');
|
|
20
|
+
const { jwtDecode } = require('@verii/jwt');
|
|
21
|
+
const {
|
|
22
|
+
validatePresentationContext,
|
|
23
|
+
} = require('@verii/verifiable-credentials');
|
|
24
|
+
const { getJsonAtPath } = require('../../common');
|
|
25
|
+
const {
|
|
26
|
+
ExchangeErrorCodeState,
|
|
27
|
+
ensureExchangeStateValid,
|
|
28
|
+
} = require('../../exchanges');
|
|
29
|
+
const { IdentificationMethods } = require('../../disclosures');
|
|
30
|
+
const { PresentationErrors } = require('./errors');
|
|
31
|
+
|
|
32
|
+
const validatePresentation = async (presentation, disclosure, context) => {
|
|
33
|
+
validatePresentationContext(presentation, context);
|
|
34
|
+
ensureExchangeStateValid(ExchangeErrorCodeState.EXCHANGE_INVALID, context);
|
|
35
|
+
crossValidateVp(presentation, context);
|
|
36
|
+
validateVendorOriginContext(presentation, disclosure);
|
|
37
|
+
return buildCanonicalVp(presentation);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const crossValidateVp = (presentation, { exchange }) => {
|
|
41
|
+
const { presentation_submission: presentationSubmission } = presentation;
|
|
42
|
+
|
|
43
|
+
if (presentationSubmission.definition_id == null) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const [exchangeId, disclosureId] =
|
|
48
|
+
presentationSubmission.definition_id.split('.');
|
|
49
|
+
|
|
50
|
+
if (exchange?._id.toString() !== exchangeId) {
|
|
51
|
+
throw createError(400, 'Mismatched Exchange Ids', {
|
|
52
|
+
exchange,
|
|
53
|
+
presentationSubmission,
|
|
54
|
+
errorCode: 'presention_mismatch_exchange',
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (exchange?.disclosureId.toString() !== disclosureId) {
|
|
58
|
+
throw createError(400, 'Mismatched Disclosure Ids', {
|
|
59
|
+
exchange,
|
|
60
|
+
presentationSubmission,
|
|
61
|
+
errorCode: 'presention_mismatch_disclosure',
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const validateVendorOriginContext = ({ vendorOriginContext }, disclosure) => {
|
|
67
|
+
if (
|
|
68
|
+
!includes(IdentificationMethods.PREAUTH, disclosure.identificationMethods)
|
|
69
|
+
) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (isEmpty(vendorOriginContext)) {
|
|
73
|
+
throw createError(
|
|
74
|
+
401,
|
|
75
|
+
PresentationErrors.PRESENTATION_PREAUTH_MUST_CONTAIN_VENDOR_ORIGIN_CONTEXT,
|
|
76
|
+
{ errorCode: 'presentation_request_invalid' }
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const buildCanonicalVp = ({
|
|
82
|
+
presentation_submission: presentationSubmission,
|
|
83
|
+
...json
|
|
84
|
+
}) =>
|
|
85
|
+
reduce(
|
|
86
|
+
(acc, descriptor) => {
|
|
87
|
+
if (!['jwt_vc', 'jwt_vp', 'JWT'].includes(descriptor.format)) {
|
|
88
|
+
throw createError(
|
|
89
|
+
400,
|
|
90
|
+
"Velocity Presentation Submission only supports 'jwt_vc' or 'jwt_vp' inputs",
|
|
91
|
+
{ errorCode: 'presentation_missing_jwtvc_or_jwtvp' }
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
const result = getJsonAtPath(descriptor.path, json);
|
|
95
|
+
if (isEmpty(result)) {
|
|
96
|
+
throw createError(
|
|
97
|
+
400,
|
|
98
|
+
'Velocity Presentation contains path descriptor that is empty',
|
|
99
|
+
{ descriptor, json, errorCode: 'presentation_jsonpath_empty' }
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
const jwtString = first(result);
|
|
103
|
+
|
|
104
|
+
if (isEmpty(jwtString)) {
|
|
105
|
+
return acc;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const { payload } = jwtDecode(jwtString);
|
|
109
|
+
if (payload.vc) {
|
|
110
|
+
acc.verifiableCredential.push(jwtString);
|
|
111
|
+
} else {
|
|
112
|
+
acc.verifiableCredential = acc.verifiableCredential.concat(
|
|
113
|
+
payload.vp.verifiableCredential
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return acc;
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
id: json.id,
|
|
121
|
+
verifiableCredential: [],
|
|
122
|
+
vendorOriginContext: json.vendorOriginContext,
|
|
123
|
+
presentationIssuer: json?.issuer?.id,
|
|
124
|
+
},
|
|
125
|
+
presentationSubmission.descriptor_map
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
module.exports = { validatePresentation };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
...require('./domains'),
|
|
19
|
+
...require('./orchestrators'),
|
|
20
|
+
};
|