@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,98 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 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 nock = require('nock');
|
|
19
|
+
const { castArray, every, includes, pick, keyBy } = require('lodash/fp');
|
|
20
|
+
|
|
21
|
+
const credentialTypeMetadata = keyBy('credentialType', [
|
|
22
|
+
{
|
|
23
|
+
credentialType: 'EmailV1.0',
|
|
24
|
+
layer1: true,
|
|
25
|
+
schemaUrl:
|
|
26
|
+
'https://velocitynetwork.foundation/schemas/email-v1.0.schema.json',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
credentialType: 'EmploymentCurrentV1.1',
|
|
30
|
+
layer1: true,
|
|
31
|
+
schemaUrl:
|
|
32
|
+
'https://velocitynetwork.foundation/schemas/employment-v1.1.schema.json',
|
|
33
|
+
jsonldContext: [
|
|
34
|
+
'https://velocitynetwork.foundation/contexts/layer1-credentials-v1.1.json',
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
credentialType: 'EmploymentCurrentV1.0',
|
|
39
|
+
layer1: true,
|
|
40
|
+
schemaUrl:
|
|
41
|
+
'https://velocitynetwork.foundation/schemas/employment-v1.0.schema.json',
|
|
42
|
+
jsonldContext: [
|
|
43
|
+
'https://velocitynetwork.foundation/contexts/layer1-credentials-v1.0.json',
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
credentialType: 'PastEmploymentPosition',
|
|
48
|
+
layer1: true,
|
|
49
|
+
schemaUrl: 'http://oracle.localhost.test/schemas/PastEmploymentPosition',
|
|
50
|
+
jsonldContext: [
|
|
51
|
+
'https://velocitynetwork.foundation/contexts/layer1-credentials-v1.1.json',
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
credentialType: 'EducationDegree',
|
|
56
|
+
layer1: true,
|
|
57
|
+
schemaUrl:
|
|
58
|
+
'http://oracle.localhost.test/schemas/education-degree-v1.1.json',
|
|
59
|
+
jsonldContext: [
|
|
60
|
+
'https://velocitynetwork.foundation/contexts/layer1-credentials-v1.1.json',
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
credentialType: '1EdtechCLR2.0',
|
|
65
|
+
layer1: false,
|
|
66
|
+
schemaUrl: 'https://imsglobal.org/schemas/clr-v2.0-schema.json',
|
|
67
|
+
jsonldContext: ['https://imsglobal.org/schemas/clr-context.json'],
|
|
68
|
+
},
|
|
69
|
+
]);
|
|
70
|
+
|
|
71
|
+
const nockCredentialTypes = (times = 2) => {
|
|
72
|
+
nock('http://oracle.localhost.test')
|
|
73
|
+
.get('/api/v0.6/credential-types')
|
|
74
|
+
.query((query) =>
|
|
75
|
+
every(
|
|
76
|
+
(credentialType) =>
|
|
77
|
+
includes(credentialType, Object.keys(credentialTypeMetadata)),
|
|
78
|
+
castArray(query.credentialType)
|
|
79
|
+
)
|
|
80
|
+
)
|
|
81
|
+
.times(times)
|
|
82
|
+
.reply(200, (uri) => {
|
|
83
|
+
const questionMarkIdx = uri.indexOf('?');
|
|
84
|
+
const searchParamsString = uri.substring(questionMarkIdx);
|
|
85
|
+
const query = new URLSearchParams(searchParamsString);
|
|
86
|
+
return Object.values(
|
|
87
|
+
pick(query.getAll('credentialType'), credentialTypeMetadata)
|
|
88
|
+
);
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const freeCredentialTypesList = ['EmailV1.0', 'DrivingLicenseV1.0'];
|
|
93
|
+
|
|
94
|
+
module.exports = {
|
|
95
|
+
credentialTypeMetadata,
|
|
96
|
+
nockCredentialTypes,
|
|
97
|
+
freeCredentialTypesList,
|
|
98
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
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 { createTestServer } = require('@verii/server-provider');
|
|
18
|
+
const { loadTestEnv, buildMongoConnection } = require('@verii/tests-helpers');
|
|
19
|
+
|
|
20
|
+
loadTestEnv();
|
|
21
|
+
|
|
22
|
+
const { flow } = require('lodash/fp');
|
|
23
|
+
const { holderConfig } = require('../../../src/config/holder-config');
|
|
24
|
+
const { initHolderServer } = require('../../../src/init-holder-server');
|
|
25
|
+
|
|
26
|
+
const mongoConnection = buildMongoConnection('test-credential-agent');
|
|
27
|
+
|
|
28
|
+
module.exports = (overrideConfig = {}) =>
|
|
29
|
+
flow(
|
|
30
|
+
createTestServer,
|
|
31
|
+
initHolderServer
|
|
32
|
+
)({ ...holderConfig, ...overrideConfig, mongoConnection });
|
|
@@ -0,0 +1,441 @@
|
|
|
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 { generateKeyPair } = require('@verii/crypto');
|
|
18
|
+
const { mapWithIndex } = require('@verii/common-functions');
|
|
19
|
+
const {
|
|
20
|
+
castArray,
|
|
21
|
+
fromPairs,
|
|
22
|
+
get,
|
|
23
|
+
map,
|
|
24
|
+
merge,
|
|
25
|
+
pick,
|
|
26
|
+
set,
|
|
27
|
+
values,
|
|
28
|
+
unset,
|
|
29
|
+
slice,
|
|
30
|
+
size,
|
|
31
|
+
} = require('lodash/fp');
|
|
32
|
+
const { nanoid } = require('nanoid/non-secure');
|
|
33
|
+
const {
|
|
34
|
+
jwkFromSecp256k1Key,
|
|
35
|
+
generateDocJwt,
|
|
36
|
+
generateCredentialJwt,
|
|
37
|
+
generatePresentationJwt,
|
|
38
|
+
jwkThumbprint,
|
|
39
|
+
} = require('@verii/jwt');
|
|
40
|
+
const { ExchangeProtocols } = require('../../../src/entities');
|
|
41
|
+
|
|
42
|
+
const credential1 = {
|
|
43
|
+
sub: 'did:velocity:0xda16fdbde1f8b73d1c981e6988bbca37fcdaa6ae',
|
|
44
|
+
vc: {
|
|
45
|
+
'@context': ['https://www.w3.org/2018/credentials/v1'],
|
|
46
|
+
id: 'did:velocity:0xda16fdbde1f8b73d1c981e6988bbca37fcdaa6ae',
|
|
47
|
+
type: ['IdDocumentV1.0', 'VerifiableCredential'],
|
|
48
|
+
issuer: 'did:velocity:0x0b154da48d0f213c26c4b1d040dc5ff1dbf99ffa',
|
|
49
|
+
credentialSubject: {
|
|
50
|
+
firstName: {
|
|
51
|
+
localized: {
|
|
52
|
+
en: 'Adam',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
lastName: {
|
|
56
|
+
localized: {
|
|
57
|
+
en: 'Smith',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
dob: {
|
|
61
|
+
day: 3,
|
|
62
|
+
month: 3,
|
|
63
|
+
year: 1971,
|
|
64
|
+
},
|
|
65
|
+
kind: 'DriversLicense',
|
|
66
|
+
authority: 'California DMV',
|
|
67
|
+
identityNumber: '12310312312',
|
|
68
|
+
location: {
|
|
69
|
+
countryCode: 'US',
|
|
70
|
+
regionCode: 'CA',
|
|
71
|
+
},
|
|
72
|
+
address: {
|
|
73
|
+
line1: '400 Bell St',
|
|
74
|
+
line2: 'East Palo Alto',
|
|
75
|
+
postcode: '94303',
|
|
76
|
+
regionCode: 'CA',
|
|
77
|
+
countryCode: 'US',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
credentialStatus: {
|
|
81
|
+
id: 'https://credentialstatus.velocitycareerlabs.io',
|
|
82
|
+
type: 'VelocityRevocationRegistry',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const credential2 = {
|
|
88
|
+
sub: 'did:velocity:0x358f694f4ba5f00c15f7e92ecc3e4ccac7ca5f00',
|
|
89
|
+
vc: {
|
|
90
|
+
'@context': ['https://www.w3.org/2018/credentials/v1'],
|
|
91
|
+
id: 'did:velocity:0x358f694f4ba5f00c15f7e92ecc3e4ccac7ca5f00',
|
|
92
|
+
type: ['CurrentEmploymentPosition', 'VerifiableCredential'],
|
|
93
|
+
issuer: 'did:velocity:0x0b154da48d0f213c26c4b1d040dc5ff1dbf99ffa',
|
|
94
|
+
issuanceDate: '2020-08-17T11:26:49.000Z',
|
|
95
|
+
credentialSubject: {
|
|
96
|
+
company: 'did:velocity:iamanissuer1234567890',
|
|
97
|
+
companyName: {
|
|
98
|
+
localized: {
|
|
99
|
+
en: 'ACME Corporation',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
title: {
|
|
103
|
+
localized: {
|
|
104
|
+
en: 'Programme Manager',
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
startMonthYear: {
|
|
108
|
+
month: 2,
|
|
109
|
+
year: 2015,
|
|
110
|
+
},
|
|
111
|
+
location: {
|
|
112
|
+
countryCode: 'US',
|
|
113
|
+
regionCode: 'CA',
|
|
114
|
+
},
|
|
115
|
+
description:
|
|
116
|
+
'Responsible for digital transformation portfolio at ACME Corporation',
|
|
117
|
+
},
|
|
118
|
+
credentialStatus: {
|
|
119
|
+
id: 'https://credentialstatus.velocitycareerlabs.io',
|
|
120
|
+
type: 'VelocityRevocationRegistry',
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const credential3 = {
|
|
126
|
+
sub: 'did:velocity:0x0a63c18d09d5430363b2f3b270698a677fb513e4',
|
|
127
|
+
vc: {
|
|
128
|
+
'@context': ['https://www.w3.org/2018/credentials/v1'],
|
|
129
|
+
id: 'did:velocity:0x0a63c18d09d5430363b2f3b270698a677fb513e4',
|
|
130
|
+
type: ['EducationDegree', 'VerifiableCredential'],
|
|
131
|
+
issuer: { id: 'did:velocity:0x0b154da48d0f213c26c4b1d040dc5ff1dbf99ffa' },
|
|
132
|
+
issuanceDate: '2020-08-17T11:27:06.000Z',
|
|
133
|
+
credentialSubject: {
|
|
134
|
+
school: 'did:velocity:0x0b154da48d0f213c26c4b1d040dc5ff1dbf99ffa',
|
|
135
|
+
schoolName: {
|
|
136
|
+
localized: {
|
|
137
|
+
en: 'University of Cambridge',
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
degreeName: {
|
|
141
|
+
localized: {
|
|
142
|
+
en: 'Bachelor',
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
program: {
|
|
146
|
+
localized: {
|
|
147
|
+
en: 'Computer Science',
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
startMonthYear: {
|
|
151
|
+
month: 9,
|
|
152
|
+
year: 2002,
|
|
153
|
+
},
|
|
154
|
+
endMonthYear: {
|
|
155
|
+
month: 5,
|
|
156
|
+
year: 2005,
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
credentialStatus: {
|
|
160
|
+
id: 'https://credentialstatus.velocitycareerlabs.io',
|
|
161
|
+
type: 'VelocityRevocationRegistry',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const credential4 = {
|
|
167
|
+
sub: 'did:ethr.0x0a63c18d09d5430363b2f3b270698a677fb513e4',
|
|
168
|
+
vc: {
|
|
169
|
+
'@context': ['https://www.w3.org/2018/credentials/v1'],
|
|
170
|
+
id: 'did:ethr.0x0a63c18d09d5430363b2f3b270698a677fb513e5',
|
|
171
|
+
type: ['EmailV1.0', 'VerifiableCredential'],
|
|
172
|
+
issuer: { id: 'did:ethr.0x0b154da48d0f213c26c4b1d040dc5ff1dbf99ffa' },
|
|
173
|
+
issuanceDate: '2020-08-17T11:27:06.000Z',
|
|
174
|
+
credentialSubject: {
|
|
175
|
+
email: 'adam.smith@example.com',
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const idDocPayload = {
|
|
181
|
+
sub: 'did:velocity:0x0a63c18d09d5430363b2f3b270698a677fb513e4',
|
|
182
|
+
vc: {
|
|
183
|
+
'@context': ['https://www.w3.org/2018/credentials/v1'],
|
|
184
|
+
id: 'did:velocity:0x0a63c18d09d5430363b2f3b270698a677fb513e4',
|
|
185
|
+
issuer: { id: 'did:velocity:0x0b154da48d0f213c26c4b1d040dc5ff1dbf99ffa' },
|
|
186
|
+
issuanceDate: '2020-08-17T11:27:06.000Z',
|
|
187
|
+
type: ['IdDocumentV1.0', 'VerifiableCredential'],
|
|
188
|
+
credentialSubject: {
|
|
189
|
+
person: {
|
|
190
|
+
givenName: 'Sam',
|
|
191
|
+
familyName: 'Smith',
|
|
192
|
+
},
|
|
193
|
+
validity: {
|
|
194
|
+
validFrom: '2017-09-01',
|
|
195
|
+
validUntil: '2021-09-01',
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const driversLicensePayload = {
|
|
202
|
+
sub: 'did:velocity:0x0a63c18d09d5430363b2f3b270698a677fb513e4',
|
|
203
|
+
vc: {
|
|
204
|
+
'@context': ['https://www.w3.org/2018/credentials/v1'],
|
|
205
|
+
id: 'did:velocity:0x0a63c18d09d5430363b2f3b270698a677fb513e4',
|
|
206
|
+
issuer: 'did:velocity:0x0b154da48d0f213c26c4b1d040dc5ff1dbf99ffa',
|
|
207
|
+
issuanceDate: '2020-08-17T11:27:06.000Z',
|
|
208
|
+
type: ['DriversLicensesV1.0', 'VerifiableCredential'],
|
|
209
|
+
credentialSubject: {
|
|
210
|
+
person: {
|
|
211
|
+
givenName: 'Sam',
|
|
212
|
+
familyName: 'Smith',
|
|
213
|
+
},
|
|
214
|
+
identifier: '2200221100',
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const legacyIdDocPayload = {
|
|
220
|
+
sub: 'did:velocity:0x0a63c18d09d5430363b2f3b270698a677fb513e4',
|
|
221
|
+
vc: {
|
|
222
|
+
'@context': ['https://www.w3.org/2018/credentials/v1'],
|
|
223
|
+
id: 'did:velocity:0x0a63c18d09d5430363b2f3b270698a677fb513e4',
|
|
224
|
+
issuer: { id: 'did:velocity:0x0b154da48d0f213c26c4b1d040dc5ff1dbf99ffa' },
|
|
225
|
+
issuanceDate: '2020-08-17T11:27:06.000Z',
|
|
226
|
+
type: ['IdDocument', 'VerifiableCredential'],
|
|
227
|
+
credentialSubject: {
|
|
228
|
+
firstName: { localized: { en: 'Sam' } },
|
|
229
|
+
lastName: { localized: { en: 'Smith' } },
|
|
230
|
+
},
|
|
231
|
+
validFrom: '2017-09-01',
|
|
232
|
+
validUntil: '2021-09-01',
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
const verificationIdentifierPayload = {
|
|
237
|
+
sub: 'did:velocity:0x0a63c18d09d5430363b2f3b270698a677fb513e4',
|
|
238
|
+
vc: {
|
|
239
|
+
'@context': ['https://www.w3.org/2018/credentials/v1'],
|
|
240
|
+
id: 'did:velocity:0x0a63c18d09d5430363b2f3b270698a677fb513e4',
|
|
241
|
+
issuer: { id: 'did:velocity:0x0b154da48d0f213c26c4b1d040dc5ff1dbf99ffa' },
|
|
242
|
+
issuanceDate: '2020-08-17T11:27:06.000Z',
|
|
243
|
+
type: ['VerificationIdentifier', 'VerifiableCredential'],
|
|
244
|
+
credentialSubject: {
|
|
245
|
+
id: 'dff447309917830',
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const phonePayload = {
|
|
251
|
+
sub: 'did:velocity:0x0a63c18d09d5430363b2f3b270698a677fb513e4',
|
|
252
|
+
vc: {
|
|
253
|
+
'@context': ['https://www.w3.org/2018/credentials/v1'],
|
|
254
|
+
id: 'did:velocity:0x0a63c18d09d5430363b2f3b270698a677fb513e4',
|
|
255
|
+
issuer: { id: 'did:velocity:0x0b154da48d0f213c26c4b1d040dc5ff1dbf99ffa' },
|
|
256
|
+
issuanceDate: '2020-08-17T11:27:06.000Z',
|
|
257
|
+
type: ['PhoneV1.0', 'VerifiableCredential'],
|
|
258
|
+
credentialSubject: {
|
|
259
|
+
phone: '+447309917830',
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
const emailPayload = {
|
|
265
|
+
sub: 'did:velocity:0x0a63c18d09d5430363b2f3b270698a677fb513e4',
|
|
266
|
+
vc: {
|
|
267
|
+
'@context': ['https://www.w3.org/2018/credentials/v1'],
|
|
268
|
+
id: 'did:velocity:0x0a63c18d09d5430363b2f3b270698a677fb513e4',
|
|
269
|
+
issuer: 'did:velocity:0x0b154da48d0f213c26c4b1d040dc5ff1dbf99ffa',
|
|
270
|
+
issuanceDate: '2020-08-17T11:27:06.000Z',
|
|
271
|
+
type: ['EmailV1.0', 'VerifiableCredential'],
|
|
272
|
+
credentialSubject: {
|
|
273
|
+
email: 'adam.smith@example.com',
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
const legacyEmailPayload = {
|
|
278
|
+
sub: 'did:velocity:0x0a63c18d09d5430363b2f3b270698a677fb513e4',
|
|
279
|
+
vc: {
|
|
280
|
+
'@context': ['https://www.w3.org/2018/credentials/v1'],
|
|
281
|
+
id: 'did:velocity:0x0a63c18d09d5430363b2f3b270698a677fb513e4',
|
|
282
|
+
issuer: 'did:velocity:0x0b154da48d0f213c26c4b1d040dc5ff1dbf99ffa',
|
|
283
|
+
issuanceDate: '2020-08-17T11:27:06.000Z',
|
|
284
|
+
type: ['Email', 'VerifiableCredential'],
|
|
285
|
+
credentialSubject: {
|
|
286
|
+
email: 'adam.smith@example.com',
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
const whateverPayload = {
|
|
292
|
+
sub: 'did:velocity:0x0a63c18d09d5430363b2f3b270698a677fb513e4',
|
|
293
|
+
vc: {
|
|
294
|
+
'@context': ['https://www.w3.org/2018/credentials/v1'],
|
|
295
|
+
id: 'did:velocity:0x0a63c18d09d5430363b2f3b270698a677fb513e4',
|
|
296
|
+
issuer: { id: 'did:velocity:0x0b154da48d0f213c26c4b1d040dc5ff1dbf99ffa' },
|
|
297
|
+
issuanceDate: '2020-08-17T11:27:06.000Z',
|
|
298
|
+
type: ['Whatever', 'VerifiableCredential'],
|
|
299
|
+
credentialSubject: {
|
|
300
|
+
email: 'adam.smith@example.com',
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
const { privateKey, publicKey } = generateKeyPair();
|
|
306
|
+
|
|
307
|
+
const generateKYCPresentation = (exchange, idDocTypes, options) => {
|
|
308
|
+
const idCredentials = {
|
|
309
|
+
email: emailPayload,
|
|
310
|
+
legacyEmail: legacyEmailPayload,
|
|
311
|
+
phone: phonePayload,
|
|
312
|
+
idDocument: idDocPayload,
|
|
313
|
+
driversLicense: driversLicensePayload,
|
|
314
|
+
legacyIdDocument: legacyIdDocPayload,
|
|
315
|
+
verificationIdentifier: verificationIdentifierPayload,
|
|
316
|
+
whateverIdentifier: whateverPayload,
|
|
317
|
+
whateverWithLogoName: {
|
|
318
|
+
...emailPayload,
|
|
319
|
+
vc: {
|
|
320
|
+
...emailPayload.vc,
|
|
321
|
+
issuer: {
|
|
322
|
+
id: emailPayload.vc.issuer,
|
|
323
|
+
image: 'https://example.com/image.png',
|
|
324
|
+
name: 'Whatever',
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
const selectedCredentials = idDocTypes
|
|
331
|
+
? pick(castArray(idDocTypes), idCredentials)
|
|
332
|
+
: values(idCredentials);
|
|
333
|
+
|
|
334
|
+
return doGeneratePresentation(selectedCredentials, exchange, options);
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
const generatePresentation = (exchange) => {
|
|
338
|
+
return doGeneratePresentation(
|
|
339
|
+
[credential1, credential2, credential3, credential4],
|
|
340
|
+
exchange
|
|
341
|
+
);
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
const doGeneratePresentation = async (
|
|
345
|
+
credentials,
|
|
346
|
+
exchange,
|
|
347
|
+
options = { isBrokeVCS: false }
|
|
348
|
+
) => {
|
|
349
|
+
const signedCredentials = await Promise.all(
|
|
350
|
+
map((c) => generateCredentialJwt(c, privateKey), credentials)
|
|
351
|
+
);
|
|
352
|
+
|
|
353
|
+
const publicJwk = jwkFromSecp256k1Key(publicKey, false);
|
|
354
|
+
|
|
355
|
+
const presentation =
|
|
356
|
+
get('protocolMetadata.protocol', exchange) === ExchangeProtocols.OIDC_SIOP
|
|
357
|
+
? {
|
|
358
|
+
id: nanoid(),
|
|
359
|
+
state: exchange._id,
|
|
360
|
+
sub: await jwkThumbprint(publicJwk),
|
|
361
|
+
sub_jwk: publicJwk,
|
|
362
|
+
aud: exchange.protocolMetadata.redirect_uri,
|
|
363
|
+
nonce: exchange.protocolMetadata.nonce,
|
|
364
|
+
iss: 'https://self-issuanceDate.me',
|
|
365
|
+
...fromPairs(
|
|
366
|
+
mapWithIndex(
|
|
367
|
+
(c, i) => [`signedCredential${i + 1}`, c],
|
|
368
|
+
signedCredentials
|
|
369
|
+
)
|
|
370
|
+
),
|
|
371
|
+
presentation_submission: {
|
|
372
|
+
id: nanoid(),
|
|
373
|
+
definition_id: `${exchange._id}.${exchange.disclosureId}`,
|
|
374
|
+
descriptor_map: mapWithIndex(
|
|
375
|
+
(c, i) => ({
|
|
376
|
+
id: nanoid(),
|
|
377
|
+
path: `$.signedCredential${i + 1}`,
|
|
378
|
+
format: 'jwt_vc',
|
|
379
|
+
}),
|
|
380
|
+
signedCredentials
|
|
381
|
+
),
|
|
382
|
+
},
|
|
383
|
+
}
|
|
384
|
+
: {
|
|
385
|
+
id: nanoid(),
|
|
386
|
+
issuer: 'https://self-issuanceDate.me',
|
|
387
|
+
verifiableCredential: options.isBrokeVCS
|
|
388
|
+
? [
|
|
389
|
+
...slice(0, 1, signedCredentials),
|
|
390
|
+
...Array(size(signedCredentials) - 1).fill(''),
|
|
391
|
+
]
|
|
392
|
+
: signedCredentials,
|
|
393
|
+
presentation_submission: {
|
|
394
|
+
id: nanoid(),
|
|
395
|
+
definition_id: `${exchange._id}.${exchange.disclosureId}`,
|
|
396
|
+
descriptor_map: mapWithIndex(
|
|
397
|
+
(c, i) => ({
|
|
398
|
+
id: nanoid(),
|
|
399
|
+
path: `$.verifiableCredential[${i}]`,
|
|
400
|
+
format: 'jwt_vc',
|
|
401
|
+
}),
|
|
402
|
+
signedCredentials
|
|
403
|
+
),
|
|
404
|
+
},
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
return {
|
|
408
|
+
presentation,
|
|
409
|
+
credentials,
|
|
410
|
+
override(overrides) {
|
|
411
|
+
return merge(this, { presentation: overrides });
|
|
412
|
+
},
|
|
413
|
+
delete(key) {
|
|
414
|
+
return set('presentation', unset(key, this.presentation), this);
|
|
415
|
+
},
|
|
416
|
+
sign(kid, personPrivateKey, issuer = 'https://self-issuanceDate.me') {
|
|
417
|
+
this.presentation.issuer = issuer;
|
|
418
|
+
return generatePresentationJwt(this.presentation, personPrivateKey, kid);
|
|
419
|
+
},
|
|
420
|
+
selfSign() {
|
|
421
|
+
return get('protocolMetadata.protocol', exchange) ===
|
|
422
|
+
ExchangeProtocols.OIDC_SIOP
|
|
423
|
+
? generateDocJwt(this.presentation, privateKey, {
|
|
424
|
+
// iss: this.presentation.iss,
|
|
425
|
+
aud: this.presentation.aud,
|
|
426
|
+
jti: nanoid(),
|
|
427
|
+
})
|
|
428
|
+
: generatePresentationJwt(this.presentation, privateKey);
|
|
429
|
+
},
|
|
430
|
+
};
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
module.exports = {
|
|
434
|
+
generatePresentation,
|
|
435
|
+
generateKYCPresentation,
|
|
436
|
+
idDocPayload,
|
|
437
|
+
legacyIdDocPayload,
|
|
438
|
+
emailPayload,
|
|
439
|
+
phonePayload,
|
|
440
|
+
verificationIdentifierPayload,
|
|
441
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
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 { jwtSign } = require('@verii/jwt');
|
|
19
|
+
const { getUnixTime } = require('date-fns/fp');
|
|
20
|
+
const { nanoid } = require('nanoid');
|
|
21
|
+
|
|
22
|
+
const generateTestAccessToken = (
|
|
23
|
+
id,
|
|
24
|
+
issuer,
|
|
25
|
+
subject,
|
|
26
|
+
scope,
|
|
27
|
+
payload,
|
|
28
|
+
expiresIn,
|
|
29
|
+
exp,
|
|
30
|
+
privateKey,
|
|
31
|
+
kid
|
|
32
|
+
) => {
|
|
33
|
+
const tokenPayload = payload != null ? { ...payload } : {};
|
|
34
|
+
if (scope != null) {
|
|
35
|
+
tokenPayload.scope = scope;
|
|
36
|
+
}
|
|
37
|
+
const t = getUnixTime(new Date());
|
|
38
|
+
const options = {
|
|
39
|
+
iat: t,
|
|
40
|
+
nbf: t,
|
|
41
|
+
jti: id == null ? nanoid(16) : id.toString(),
|
|
42
|
+
issuer,
|
|
43
|
+
subject,
|
|
44
|
+
audience: issuer,
|
|
45
|
+
expiresIn,
|
|
46
|
+
exp,
|
|
47
|
+
};
|
|
48
|
+
if (kid != null) {
|
|
49
|
+
options.kid = kid;
|
|
50
|
+
}
|
|
51
|
+
return jwtSign(tokenPayload, privateKey, options);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
module.exports = { generateTestAccessToken };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 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 jwtAccessTokenExpectation = (tenant, header, payload) => ({
|
|
19
|
+
header: { alg: 'ES256K', typ: 'JWT', kid: '#exchanges-1', ...header },
|
|
20
|
+
payload: {
|
|
21
|
+
aud: tenant.did,
|
|
22
|
+
iss: tenant.did,
|
|
23
|
+
exp: expect.any(Number),
|
|
24
|
+
iat: expect.any(Number),
|
|
25
|
+
nbf: expect.any(Number),
|
|
26
|
+
jti: expect.any(String),
|
|
27
|
+
sub: expect.any(String),
|
|
28
|
+
...payload,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
module.exports = { jwtAccessTokenExpectation };
|