@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,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
|
+
module.exports = {
|
|
18
|
+
...require('./exchange-error-handler-plugin'),
|
|
19
|
+
...require('./exchange-loader-plugin'),
|
|
20
|
+
...require('./disclosure-loader-plugin'),
|
|
21
|
+
...require('./tenant-loader-plugin'),
|
|
22
|
+
...require('./vendor-routes-auth-plugin'),
|
|
23
|
+
...require('./ensure-tenant-primary-address-plugin'),
|
|
24
|
+
...require('./verify-access-token-plugin'),
|
|
25
|
+
...require('./autoload-repos'),
|
|
26
|
+
...require('./validate-cao-plugin'),
|
|
27
|
+
...require('./ensure-tenant-default-issuing-disclosure-id-plugin'),
|
|
28
|
+
...require('./ensure-disclosure-configuration-type-plugin'),
|
|
29
|
+
...require('./ensure-disclosure-active-plugin'),
|
|
30
|
+
...require('./group-loader-plugin'),
|
|
31
|
+
...require('./kms-plugin'),
|
|
32
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
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 fp = require('fastify-plugin');
|
|
19
|
+
const { dbKmsPlugin } = require('@verii/db-kms');
|
|
20
|
+
const { multitenantExtension } = require('@verii/spencer-mongo-extensions');
|
|
21
|
+
|
|
22
|
+
const agentKmsOptions = {
|
|
23
|
+
name: 'keys',
|
|
24
|
+
entityName: 'key',
|
|
25
|
+
keyProp: 'key',
|
|
26
|
+
encryptedKeyProp: 'key',
|
|
27
|
+
publicKeyProp: 'publicKey',
|
|
28
|
+
defaultProjection: {
|
|
29
|
+
_id: 1,
|
|
30
|
+
purposes: 1,
|
|
31
|
+
algorithm: 1,
|
|
32
|
+
encoding: 1,
|
|
33
|
+
kidFragment: 1,
|
|
34
|
+
tenantId: 1,
|
|
35
|
+
createdAt: 1,
|
|
36
|
+
updatedAt: 1,
|
|
37
|
+
},
|
|
38
|
+
extensions: [multitenantExtension()],
|
|
39
|
+
transformToKmsKey: (result) => {
|
|
40
|
+
/* eslint-disable better-mutation/no-mutation */
|
|
41
|
+
result.id = result._id.toString();
|
|
42
|
+
result._id = undefined;
|
|
43
|
+
|
|
44
|
+
result.publicJwk = result.publicKey;
|
|
45
|
+
result.publicKey = undefined;
|
|
46
|
+
|
|
47
|
+
result.privateJwk = result.key;
|
|
48
|
+
result.key = undefined;
|
|
49
|
+
/* eslint-enable */
|
|
50
|
+
return result;
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const kmsPlugin = async (fastify) => {
|
|
55
|
+
fastify.register(dbKmsPlugin, agentKmsOptions);
|
|
56
|
+
};
|
|
57
|
+
module.exports = { kmsPlugin: fp(kmsPlugin), agentKmsOptions };
|
|
@@ -0,0 +1,91 @@
|
|
|
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 newError = require('http-errors');
|
|
18
|
+
const { ObjectId } = require('mongodb');
|
|
19
|
+
const {
|
|
20
|
+
isEmpty,
|
|
21
|
+
flatMap,
|
|
22
|
+
flow,
|
|
23
|
+
fromPairs,
|
|
24
|
+
map,
|
|
25
|
+
startsWith,
|
|
26
|
+
} = require('lodash/fp');
|
|
27
|
+
const fp = require('fastify-plugin');
|
|
28
|
+
const { mongoDb } = require('@spencejs/spence-mongo-repos');
|
|
29
|
+
const { tenantDefaultProjection } = require('../entities');
|
|
30
|
+
|
|
31
|
+
const buildSearchFilter = ({ tenantId }) => {
|
|
32
|
+
if (isEmpty(tenantId)) {
|
|
33
|
+
throw newError(404, 'Tenant was not specified', {
|
|
34
|
+
errorCode: 'did_not_defined',
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (startsWith('did:', tenantId)) {
|
|
38
|
+
return { $or: [{ did: tenantId }, { dids: tenantId }] };
|
|
39
|
+
}
|
|
40
|
+
return { _id: new ObjectId(tenantId) };
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const loadTenant = async (db, params, context) => {
|
|
44
|
+
const searchFilter = buildSearchFilter(params, context);
|
|
45
|
+
const tenant = await db
|
|
46
|
+
.collection('tenants')
|
|
47
|
+
.findOne(searchFilter, tenantDefaultProjection);
|
|
48
|
+
|
|
49
|
+
if (isEmpty(tenant)) {
|
|
50
|
+
const { tenantId } = params;
|
|
51
|
+
throw newError(404, `Tenant ${JSON.stringify({ tenantId })} not found`, {
|
|
52
|
+
errorCode: 'tenant_not_found',
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return tenant;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const loadTenantKeysByPurpose = async (db, context) => {
|
|
59
|
+
const { tenant } = context;
|
|
60
|
+
const tenantKeysCollection = db.collection('keys');
|
|
61
|
+
const tenantKeys = await tenantKeysCollection
|
|
62
|
+
.find(
|
|
63
|
+
{ tenantId: tenant._id },
|
|
64
|
+
{ projection: { _id: 1, purposes: 1, kidFragment: 1, publicKey: 1 } }
|
|
65
|
+
)
|
|
66
|
+
.toArray();
|
|
67
|
+
|
|
68
|
+
return flow(
|
|
69
|
+
flatMap(({ purposes, _id, kidFragment, publicKey }) => {
|
|
70
|
+
const key = { keyId: _id, kidFragment, publicKey };
|
|
71
|
+
return map((purpose) => [purpose, key], purposes);
|
|
72
|
+
}),
|
|
73
|
+
fromPairs
|
|
74
|
+
)(tenantKeys);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const tenantLoaderPlugin = async (fastify) => {
|
|
78
|
+
fastify
|
|
79
|
+
.decorateRequest('tenant', null)
|
|
80
|
+
.decorateRequest('tenantKeysByPurpose', null)
|
|
81
|
+
.addHook('onRequest', async (req) => {
|
|
82
|
+
const db = mongoDb();
|
|
83
|
+
req.tenant = await loadTenant(db, req.params, req);
|
|
84
|
+
req.tenantKeysByPurpose = await loadTenantKeysByPurpose(db, req);
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
module.exports = {
|
|
89
|
+
tenantLoaderPlugin: fp(tenantLoaderPlugin),
|
|
90
|
+
loadTenant,
|
|
91
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
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 fp = require('fastify-plugin');
|
|
18
|
+
const { includes } = require('lodash/fp');
|
|
19
|
+
const { ServiceCategories } = require('@verii/organizations-registry');
|
|
20
|
+
const { getOrganizationVerifiedProfile } = require('@verii/common-fetchers');
|
|
21
|
+
|
|
22
|
+
async function validateCao() {
|
|
23
|
+
const context = this;
|
|
24
|
+
|
|
25
|
+
if (!context.config.validateCaoDid) {
|
|
26
|
+
context.log.warn('CAO DID validation is turned off.');
|
|
27
|
+
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const registrarFetch = context.baseRegistrarFetch(context);
|
|
32
|
+
const caoErrorMessage =
|
|
33
|
+
// eslint-disable-next-line max-len
|
|
34
|
+
'The provided CAO is not permitted to operator on the network. Make sure the organization exists on the registrar and is approved for Credential Agent Operation';
|
|
35
|
+
let profile;
|
|
36
|
+
context.log.info('Validating CAO');
|
|
37
|
+
context.log.info({ caoDid: context.config.caoDid });
|
|
38
|
+
try {
|
|
39
|
+
profile = await getOrganizationVerifiedProfile(context.config.caoDid, {
|
|
40
|
+
registrarFetch,
|
|
41
|
+
});
|
|
42
|
+
} catch (error) {
|
|
43
|
+
context.log.info({ error });
|
|
44
|
+
const { response } = error;
|
|
45
|
+
const { statusCode } = response || {};
|
|
46
|
+
|
|
47
|
+
switch (true) {
|
|
48
|
+
case statusCode >= 400 && statusCode < 500:
|
|
49
|
+
throw new Error(caoErrorMessage);
|
|
50
|
+
default:
|
|
51
|
+
context.log.warn(
|
|
52
|
+
'The registrar was not available for the request. Please check your firewall settings.'
|
|
53
|
+
);
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
checkServiceCategories(profile, caoErrorMessage);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const checkServiceCategories = (profile, caoErrorMessage) => {
|
|
64
|
+
if (
|
|
65
|
+
!includes(
|
|
66
|
+
ServiceCategories.CredentialAgentOperator,
|
|
67
|
+
profile?.credentialSubject?.permittedVelocityServiceCategory
|
|
68
|
+
)
|
|
69
|
+
) {
|
|
70
|
+
throw new Error(caoErrorMessage);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const validateCaoPlugin = (fastify, options, next) => {
|
|
75
|
+
if (!fastify.config.isTest) {
|
|
76
|
+
fastify.addHook('onReady', validateCao);
|
|
77
|
+
}
|
|
78
|
+
next();
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
module.exports = { validateCaoPlugin: fp(validateCaoPlugin), validateCao };
|
|
@@ -0,0 +1,24 @@
|
|
|
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 fp = require('fastify-plugin');
|
|
18
|
+
|
|
19
|
+
const vendorRoutesAuthPlugin = (fastify, options, next) => {
|
|
20
|
+
fastify.addHook('preHandler', fastify.verifyAdmin);
|
|
21
|
+
next();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
module.exports = { vendorRoutesAuthPlugin: fp(vendorRoutesAuthPlugin) };
|
|
@@ -0,0 +1,88 @@
|
|
|
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 fp = require('fastify-plugin');
|
|
18
|
+
|
|
19
|
+
const { split } = require('lodash/fp');
|
|
20
|
+
const newError = require('http-errors');
|
|
21
|
+
const { verifyAccessToken } = require('../entities/tokens');
|
|
22
|
+
|
|
23
|
+
const initVerifyAccessToken = (options) => {
|
|
24
|
+
const loadUser = async (internalUserId, context) => {
|
|
25
|
+
try {
|
|
26
|
+
return await context.repos.vendorUserIdMappings.findById(internalUserId);
|
|
27
|
+
} catch (e) {
|
|
28
|
+
context.log.warn(
|
|
29
|
+
{ accessToken: context.accessToken, err: e },
|
|
30
|
+
'User in sub claim not found'
|
|
31
|
+
);
|
|
32
|
+
throw e;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return async (req) => {
|
|
36
|
+
if (options.feed === true) {
|
|
37
|
+
const disclosureFeed = req.disclosure?.feed;
|
|
38
|
+
if (disclosureFeed == null || disclosureFeed === false) {
|
|
39
|
+
return req;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const bearerToken = extractBearerToken(req);
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const { payload } = await verifyAccessToken(bearerToken, req);
|
|
46
|
+
const user = await loadUser(payload.sub, req);
|
|
47
|
+
/* eslint-disable better-mutation/no-mutation */
|
|
48
|
+
req.accessToken = payload;
|
|
49
|
+
req.user = user;
|
|
50
|
+
req.log = req.log.child({
|
|
51
|
+
// update the log to include access token and user if available
|
|
52
|
+
traceId: req.traceId,
|
|
53
|
+
accessToken: req.accessToken,
|
|
54
|
+
user: req.user,
|
|
55
|
+
});
|
|
56
|
+
/* eslint-enable better-mutation/no-mutation */
|
|
57
|
+
return req;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
req.log.warn(error);
|
|
60
|
+
throw newError(401, 'Unauthorized', {
|
|
61
|
+
errorCode: 'unauthorized',
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const extractBearerToken = (req) => {
|
|
68
|
+
const { headers } = req;
|
|
69
|
+
const authParts = split(' ', headers.authorization);
|
|
70
|
+
return authParts[1];
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const verifyAccessTokenPlugin = async (fastify, options) => {
|
|
74
|
+
if (!fastify.hasRequestDecorator('accessToken')) {
|
|
75
|
+
fastify.decorateRequest('accessToken', null);
|
|
76
|
+
}
|
|
77
|
+
if (!fastify.hasRequestDecorator('user')) {
|
|
78
|
+
fastify.decorateRequest('user', null);
|
|
79
|
+
}
|
|
80
|
+
fastify.addHook(
|
|
81
|
+
options.hook ?? 'preValidation',
|
|
82
|
+
initVerifyAccessToken(options)
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
module.exports = {
|
|
87
|
+
verifyAccessTokenPlugin: fp(verifyAccessTokenPlugin),
|
|
88
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
/* istanbul ignore file */
|
|
18
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
19
|
+
const dotenv = require('dotenv');
|
|
20
|
+
|
|
21
|
+
dotenv.config({ path: '.standalone.env' });
|
|
22
|
+
dotenv.config({ path: '.localdev.env' });
|
|
23
|
+
|
|
24
|
+
require('./main');
|
|
@@ -0,0 +1,38 @@
|
|
|
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 { createServer, listenServer } = require('@verii/server-provider');
|
|
19
|
+
const { flow } = require('lodash/fp');
|
|
20
|
+
const { config, holderConfig, operatorConfig } = require('./config');
|
|
21
|
+
const { initServer } = require('./init-server');
|
|
22
|
+
const { initHolderServer } = require('./init-holder-server');
|
|
23
|
+
const { initOperatorServer } = require('./init-operator-server');
|
|
24
|
+
|
|
25
|
+
const startAppServer = () =>
|
|
26
|
+
flow(createServer, initServer, listenServer)(config);
|
|
27
|
+
|
|
28
|
+
const startHolderAppServer = () =>
|
|
29
|
+
flow(createServer, initHolderServer, listenServer)(holderConfig);
|
|
30
|
+
|
|
31
|
+
const startOperatorAppServer = () =>
|
|
32
|
+
flow(createServer, initOperatorServer, listenServer)(operatorConfig);
|
|
33
|
+
|
|
34
|
+
module.exports = {
|
|
35
|
+
startAppServer,
|
|
36
|
+
startHolderAppServer,
|
|
37
|
+
startOperatorAppServer,
|
|
38
|
+
};
|
|
@@ -0,0 +1,199 @@
|
|
|
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 nock = require('nock');
|
|
18
|
+
const cheerio = require('cheerio');
|
|
19
|
+
const buildFastify = require('./helpers/credentialagent-build-fastify');
|
|
20
|
+
|
|
21
|
+
const appRedirectUrl = '/app-redirect';
|
|
22
|
+
|
|
23
|
+
const setupNock = () => {
|
|
24
|
+
nock('http://oracle.localhost.test')
|
|
25
|
+
.get(
|
|
26
|
+
'/api/v0.6/organizations/did%3Aion%3A4131209321321323123e/verified-profile'
|
|
27
|
+
)
|
|
28
|
+
.reply(200, {
|
|
29
|
+
credentialSubject: { logo: '' },
|
|
30
|
+
})
|
|
31
|
+
.get('/api/v0.6/organizations/did%3Avnf%3Atest/verified-profile')
|
|
32
|
+
.reply(200, {
|
|
33
|
+
credentialSubject: { logo: '' },
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
describe('app redirect controller test', () => {
|
|
38
|
+
let fastify;
|
|
39
|
+
|
|
40
|
+
beforeAll(async () => {
|
|
41
|
+
fastify = await buildFastify();
|
|
42
|
+
await fastify.ready();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
beforeEach(async () => {
|
|
46
|
+
nock.cleanAll();
|
|
47
|
+
jest.resetAllMocks();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
afterEach(() => {
|
|
51
|
+
nock.cleanAll();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
afterAll(async () => {
|
|
55
|
+
await fastify.close();
|
|
56
|
+
nock.cleanAll();
|
|
57
|
+
nock.restore();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should 400 if request_uri is not provided', async () => {
|
|
61
|
+
setupNock();
|
|
62
|
+
const response = await fastify.injectJson({
|
|
63
|
+
method: 'GET',
|
|
64
|
+
url: `${appRedirectUrl}?exchange_type=uri`,
|
|
65
|
+
});
|
|
66
|
+
expect(response.statusCode).toEqual(400);
|
|
67
|
+
expect(response.json.message).toEqual(
|
|
68
|
+
"querystring must have required property 'request_uri'"
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('should 400 if exchange_type is not provided', async () => {
|
|
73
|
+
setupNock();
|
|
74
|
+
const response = await fastify.injectJson({
|
|
75
|
+
method: 'GET',
|
|
76
|
+
url: `${appRedirectUrl}?request_uri=uri`,
|
|
77
|
+
});
|
|
78
|
+
expect(response.statusCode).toEqual(400);
|
|
79
|
+
expect(response.json.message).toEqual(
|
|
80
|
+
"querystring must have required property 'exchange_type'"
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('should 400 if exchange_type is not one of allowed values', async () => {
|
|
85
|
+
setupNock();
|
|
86
|
+
const response = await fastify.injectJson({
|
|
87
|
+
method: 'GET',
|
|
88
|
+
url: `${appRedirectUrl}?request_uri=uri&exchange_type=random`,
|
|
89
|
+
});
|
|
90
|
+
expect(response.statusCode).toEqual(400);
|
|
91
|
+
expect(response.json.message).toEqual(
|
|
92
|
+
'querystring/exchange_type must be equal to one of the allowed values'
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should 400 if exchange_type is issue and inspectorDid provided', async () => {
|
|
97
|
+
setupNock();
|
|
98
|
+
const response = await fastify.injectJson({
|
|
99
|
+
method: 'GET',
|
|
100
|
+
url: `${appRedirectUrl}?request_uri=uri&exchange_type=issue&inspectorDid=abc`,
|
|
101
|
+
});
|
|
102
|
+
expect(response.statusCode).toEqual(400);
|
|
103
|
+
expect(response.json.message).toEqual(
|
|
104
|
+
'inspectorDid should not be present for exchange_type = "issue"'
|
|
105
|
+
);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('should 400 if exchange_type is inspect and inspectorDid not provided', async () => {
|
|
109
|
+
setupNock();
|
|
110
|
+
const response = await fastify.injectJson({
|
|
111
|
+
method: 'GET',
|
|
112
|
+
url: `${appRedirectUrl}?request_uri=uri&exchange_type=inspect`,
|
|
113
|
+
});
|
|
114
|
+
expect(response.statusCode).toEqual(400);
|
|
115
|
+
expect(response.json.message).toEqual(
|
|
116
|
+
'inspectorDid should be present for exchange_type = "inspect"'
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('should 400 if exchange_type is not one of allowed values', async () => {
|
|
121
|
+
setupNock();
|
|
122
|
+
const response = await fastify.injectJson({
|
|
123
|
+
method: 'GET',
|
|
124
|
+
url: `${appRedirectUrl}?request_uri=uri&exchange_type=random`,
|
|
125
|
+
});
|
|
126
|
+
expect(response.statusCode).toEqual(400);
|
|
127
|
+
expect(response.json.message).toEqual(
|
|
128
|
+
'querystring/exchange_type must be equal to one of the allowed values'
|
|
129
|
+
);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('should link vnf wallet selection stylesheet', async () => {
|
|
133
|
+
const url =
|
|
134
|
+
// eslint-disable-next-line max-len
|
|
135
|
+
'http%3A%2F%2Flocalhost.test%2Fapi%2Fholder%2Fv0.6%2Forg%2Fdid%3Aion%3A4131209321321323123e%2Fissue%2Fget-credential-manifest%3Fexchange_id%3D5f123eab4362bb2e%26credential_types%3DPastEmploymentPosition%26id%3DsecretId';
|
|
136
|
+
const response = await fastify.injectJson({
|
|
137
|
+
method: 'GET',
|
|
138
|
+
url: `${appRedirectUrl}?request_uri=${url}&exchange_type=inspect&inspectorDid=321123`,
|
|
139
|
+
});
|
|
140
|
+
expect(response.statusCode).toEqual(200);
|
|
141
|
+
const $ = cheerio.load(response.body);
|
|
142
|
+
|
|
143
|
+
expect(response.headers['content-security-policy']).toBeDefined();
|
|
144
|
+
|
|
145
|
+
const execResult = /script-src 'nonce-([^']*)'/.exec(
|
|
146
|
+
response.headers['content-security-policy']
|
|
147
|
+
);
|
|
148
|
+
const nonceFromCspHeader = execResult[1];
|
|
149
|
+
|
|
150
|
+
const stylesheetTag = $('html > head > link[type="text/css"]');
|
|
151
|
+
expect(stylesheetTag.attr('href')).toEqual(
|
|
152
|
+
'http://lib.localhost.test/vnf-wallet-selection/site.css'
|
|
153
|
+
);
|
|
154
|
+
expect(stylesheetTag.attr('nonce')).toEqual(nonceFromCspHeader);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('should include vnf wallet selection script', async () => {
|
|
158
|
+
const url =
|
|
159
|
+
// eslint-disable-next-line max-len
|
|
160
|
+
'http%3A%2F%2Flocalhost.test%2Fapi%2Fholder%2Fv0.6%2Forg%2Fdid%3Aion%3A4131209321321323123e%2Fissue%2Fget-credential-manifest%3Fexchange_id%3D5f123eab4362bb2e%26credential_types%3DPastEmploymentPosition%26id%3DsecretId';
|
|
161
|
+
const response = await fastify.injectJson({
|
|
162
|
+
method: 'GET',
|
|
163
|
+
url: `${appRedirectUrl}?request_uri=${url}&exchange_type=inspect&inspectorDid=321123`,
|
|
164
|
+
});
|
|
165
|
+
expect(response.statusCode).toEqual(200);
|
|
166
|
+
const $ = cheerio.load(response.body);
|
|
167
|
+
|
|
168
|
+
expect(response.headers['content-security-policy']).toBeDefined();
|
|
169
|
+
const execResult = /script-src 'nonce-([^']*)'/.exec(
|
|
170
|
+
response.headers['content-security-policy']
|
|
171
|
+
);
|
|
172
|
+
const nonceFromCspHeader = execResult[1];
|
|
173
|
+
|
|
174
|
+
const scriptTag = $('html > body > script');
|
|
175
|
+
expect(scriptTag.attr('src')).toEqual(
|
|
176
|
+
'http://lib.localhost.test/vnf-wallet-selection/index.js'
|
|
177
|
+
);
|
|
178
|
+
expect(scriptTag.attr('nonce')).toEqual(nonceFromCspHeader);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('should include vnf wallet selection mount point', async () => {
|
|
182
|
+
const url =
|
|
183
|
+
// eslint-disable-next-line max-len
|
|
184
|
+
'http%3A%2F%2Flocalhost.test%2Fapi%2Fholder%2Fv0.6%2Forg%2Fdid%3Aion%3A4131209321321323123e%2Fissue%2Fget-credential-manifest%3Fexchange_id%3D5f123eab4362bb2e%26credential_types%3DPastEmploymentPosition%26id%3DsecretId';
|
|
185
|
+
const response = await fastify.injectJson({
|
|
186
|
+
method: 'GET',
|
|
187
|
+
url: `${appRedirectUrl}?request_uri=${url}&exchange_type=inspect&inspectorDid=321123`,
|
|
188
|
+
});
|
|
189
|
+
expect(response.statusCode).toEqual(200);
|
|
190
|
+
const $ = cheerio.load(response.body);
|
|
191
|
+
|
|
192
|
+
const scriptTag = $('html > body > #vnf-wallet-selection');
|
|
193
|
+
const deeplink =
|
|
194
|
+
// eslint-disable-next-line max-len
|
|
195
|
+
'velocity-test://inspect?request_uri=http%3A%2F%2Flocalhost.test%2Fapi%2Fholder%2Fv0.6%2Forg%2Fdid%3Aion%3A4131209321321323123e%2Fissue%2Fget-credential-manifest%3Fexchange_id%3D5f123eab4362bb2e%26credential_types%3DPastEmploymentPosition%26id%3DsecretId&inspectorDid=321123';
|
|
196
|
+
expect(scriptTag.attr('data-deeplink')).toEqual(deeplink);
|
|
197
|
+
expect(scriptTag.attr('data-automode')).toEqual('');
|
|
198
|
+
});
|
|
199
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { config } = require('../../../src/config');
|
|
24
|
+
const { initServer } = require('../../../src/init-server');
|
|
25
|
+
|
|
26
|
+
const mongoConnection = buildMongoConnection('test-credential-agent');
|
|
27
|
+
|
|
28
|
+
module.exports = () =>
|
|
29
|
+
flow(createTestServer, initServer)({ ...config, mongoConnection });
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
buildFastify: require('./credentialagent-build-fastify'),
|
|
19
|
+
...require('./nock-registrar-get-organization-diddoc'),
|
|
20
|
+
...require('./nock-registrar-get-organization-verified-profile'),
|
|
21
|
+
...require('./nock-registrar-app-schema-name'),
|
|
22
|
+
};
|