@credo-ts/openid4vc 0.6.1-pr-2091-20241119140918 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/OpenId4VcApi.d.mts +24 -0
- package/build/OpenId4VcApi.d.mts.map +1 -0
- package/build/OpenId4VcApi.mjs +35 -0
- package/build/OpenId4VcApi.mjs.map +1 -0
- package/build/OpenId4VcModule.d.mts +30 -0
- package/build/OpenId4VcModule.d.mts.map +1 -0
- package/build/OpenId4VcModule.mjs +42 -0
- package/build/OpenId4VcModule.mjs.map +1 -0
- package/build/OpenId4VcModuleConfig.d.mts +44 -0
- package/build/OpenId4VcModuleConfig.d.mts.map +1 -0
- package/build/OpenId4VcModuleConfig.mjs +24 -0
- package/build/OpenId4VcModuleConfig.mjs.map +1 -0
- package/build/_virtual/_@oxc-project_runtime@0.99.0/helpers/decorate.mjs +10 -0
- package/build/_virtual/_@oxc-project_runtime@0.99.0/helpers/decorateMetadata.mjs +7 -0
- package/build/_virtual/_@oxc-project_runtime@0.99.0/helpers/decorateParam.mjs +9 -0
- package/build/index.d.mts +42 -0
- package/build/index.mjs +37 -0
- package/build/openid4vc-holder/OpenId4VcHolderApi.d.mts +238 -0
- package/build/openid4vc-holder/OpenId4VcHolderApi.d.mts.map +1 -0
- package/build/openid4vc-holder/OpenId4VcHolderApi.mjs +174 -0
- package/build/openid4vc-holder/OpenId4VcHolderApi.mjs.map +1 -0
- package/build/openid4vc-holder/OpenId4VcHolderModule.d.mts +17 -0
- package/build/openid4vc-holder/OpenId4VcHolderModule.d.mts.map +1 -0
- package/build/openid4vc-holder/OpenId4VcHolderModule.mjs +23 -0
- package/build/openid4vc-holder/OpenId4VcHolderModule.mjs.map +1 -0
- package/build/openid4vc-holder/OpenId4VciHolderService.d.mts +69 -0
- package/build/openid4vc-holder/OpenId4VciHolderService.d.mts.map +1 -0
- package/build/openid4vc-holder/OpenId4VciHolderService.mjs +751 -0
- package/build/openid4vc-holder/OpenId4VciHolderService.mjs.map +1 -0
- package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.d.mts +398 -0
- package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.d.mts.map +1 -0
- package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.mjs +16 -0
- package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.mjs.map +1 -0
- package/build/openid4vc-holder/OpenId4vpHolderService.d.mts +130 -0
- package/build/openid4vc-holder/OpenId4vpHolderService.d.mts.map +1 -0
- package/build/openid4vc-holder/OpenId4vpHolderService.mjs +278 -0
- package/build/openid4vc-holder/OpenId4vpHolderService.mjs.map +1 -0
- package/build/openid4vc-holder/OpenId4vpHolderServiceOptions.d.mts +112 -0
- package/build/openid4vc-holder/OpenId4vpHolderServiceOptions.d.mts.map +1 -0
- package/build/openid4vc-holder/index.d.mts +6 -0
- package/build/openid4vc-holder/index.mjs +5 -0
- package/build/openid4vc-issuer/OpenId4VcIssuanceSessionState.d.mts +16 -0
- package/build/openid4vc-issuer/OpenId4VcIssuanceSessionState.d.mts.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuanceSessionState.mjs +18 -0
- package/build/openid4vc-issuer/OpenId4VcIssuanceSessionState.mjs.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerApi.d.mts +137 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerApi.d.mts.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerApi.mjs +108 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerApi.mjs.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerEvents.d.mts +19 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerEvents.d.mts.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerEvents.mjs +9 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerEvents.mjs.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModule.d.mts +27 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModule.d.mts.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModule.mjs +150 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModule.mjs.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.d.mts +279 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.d.mts.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.mjs +179 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.mjs.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerService.d.mts +182 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerService.d.mts.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerService.mjs +881 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerService.mjs.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerServiceOptions.d.mts +340 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerServiceOptions.d.mts.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerServiceOptions.mjs +1 -0
- package/build/openid4vc-issuer/index.d.mts +11 -0
- package/build/openid4vc-issuer/index.mjs +11 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.d.mts +300 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.d.mts.map +1 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.mjs +102 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.mjs.map +1 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRepository.d.mts +10 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRepository.d.mts.map +1 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRepository.mjs +22 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRepository.mjs.map +1 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.d.mts +84 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.d.mts.map +1 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.mjs +89 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.mjs.map +1 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRepository.d.mts +12 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRepository.d.mts.map +1 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRepository.mjs +28 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRepository.mjs.map +1 -0
- package/build/openid4vc-issuer/repository/index.d.mts +4 -0
- package/build/openid4vc-issuer/repository/index.mjs +4 -0
- package/build/openid4vc-issuer/router/accessTokenEndpoint.mjs +199 -0
- package/build/openid4vc-issuer/router/accessTokenEndpoint.mjs.map +1 -0
- package/build/openid4vc-issuer/router/authorizationChallengeEndpoint.mjs +241 -0
- package/build/openid4vc-issuer/router/authorizationChallengeEndpoint.mjs.map +1 -0
- package/build/openid4vc-issuer/router/authorizationEndpoint.mjs +51 -0
- package/build/openid4vc-issuer/router/authorizationEndpoint.mjs.map +1 -0
- package/build/openid4vc-issuer/router/authorizationServerMetadataEndpoint.mjs +25 -0
- package/build/openid4vc-issuer/router/authorizationServerMetadataEndpoint.mjs.map +1 -0
- package/build/openid4vc-issuer/router/credentialEndpoint.mjs +142 -0
- package/build/openid4vc-issuer/router/credentialEndpoint.mjs.map +1 -0
- package/build/openid4vc-issuer/router/credentialOfferEndpoint.mjs +38 -0
- package/build/openid4vc-issuer/router/credentialOfferEndpoint.mjs.map +1 -0
- package/build/openid4vc-issuer/router/deferredCredentialEndpoint.mjs +84 -0
- package/build/openid4vc-issuer/router/deferredCredentialEndpoint.mjs.map +1 -0
- package/build/openid4vc-issuer/router/index.mjs +12 -0
- package/build/openid4vc-issuer/router/issuerMetadataEndpoint.mjs +43 -0
- package/build/openid4vc-issuer/router/issuerMetadataEndpoint.mjs.map +1 -0
- package/build/openid4vc-issuer/router/jwksEndpoint.mjs +18 -0
- package/build/openid4vc-issuer/router/jwksEndpoint.mjs.map +1 -0
- package/build/openid4vc-issuer/router/nonceEndpoint.mjs +29 -0
- package/build/openid4vc-issuer/router/nonceEndpoint.mjs.map +1 -0
- package/build/openid4vc-issuer/router/pushedAuthorizationRequestEndpoint.mjs +164 -0
- package/build/openid4vc-issuer/router/pushedAuthorizationRequestEndpoint.mjs.map +1 -0
- package/build/openid4vc-issuer/router/redirectEndpoint.mjs +124 -0
- package/build/openid4vc-issuer/router/redirectEndpoint.mjs.map +1 -0
- package/build/openid4vc-issuer/util/txCode.mjs +18 -0
- package/build/openid4vc-issuer/util/txCode.mjs.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcVerificationSessionState.d.mts +10 -0
- package/build/openid4vc-verifier/OpenId4VcVerificationSessionState.d.mts.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcVerificationSessionState.mjs +12 -0
- package/build/openid4vc-verifier/OpenId4VcVerificationSessionState.mjs.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierApi.d.mts +60 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierApi.d.mts.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierApi.mjs +83 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierApi.mjs.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierEvents.d.mts +19 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierEvents.d.mts.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierEvents.mjs +9 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierEvents.mjs.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierModule.d.mts +25 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierModule.d.mts.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierModule.mjs +91 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierModule.mjs.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.d.mts +55 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.d.mts.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.mjs +36 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.mjs.map +1 -0
- package/build/openid4vc-verifier/OpenId4VpVerifierService.d.mts +60 -0
- package/build/openid4vc-verifier/OpenId4VpVerifierService.d.mts.map +1 -0
- package/build/openid4vc-verifier/OpenId4VpVerifierService.mjs +714 -0
- package/build/openid4vc-verifier/OpenId4VpVerifierService.mjs.map +1 -0
- package/build/openid4vc-verifier/OpenId4VpVerifierServiceOptions.d.mts +194 -0
- package/build/openid4vc-verifier/OpenId4VpVerifierServiceOptions.d.mts.map +1 -0
- package/build/openid4vc-verifier/index.d.mts +12 -0
- package/build/openid4vc-verifier/index.mjs +11 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRecord.d.mts +129 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRecord.d.mts.map +1 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRecord.mjs +64 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRecord.mjs.map +1 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRepository.d.mts +10 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRepository.d.mts.map +1 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRepository.mjs +22 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRepository.mjs.map +1 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRecord.d.mts +33 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRecord.d.mts.map +1 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRecord.mjs +32 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRecord.mjs.map +1 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRepository.d.mts +12 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRepository.d.mts.map +1 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRepository.mjs +28 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRepository.mjs.map +1 -0
- package/build/openid4vc-verifier/repository/index.d.mts +4 -0
- package/build/openid4vc-verifier/repository/index.mjs +4 -0
- package/build/openid4vc-verifier/router/authorizationEndpoint.mjs +117 -0
- package/build/openid4vc-verifier/router/authorizationEndpoint.mjs.map +1 -0
- package/build/openid4vc-verifier/router/authorizationRequestEndpoint.mjs +39 -0
- package/build/openid4vc-verifier/router/authorizationRequestEndpoint.mjs.map +1 -0
- package/build/openid4vc-verifier/router/index.mjs +1 -0
- package/build/shared/callbacks.d.mts +47 -0
- package/build/shared/callbacks.d.mts.map +1 -0
- package/build/shared/callbacks.mjs +279 -0
- package/build/shared/callbacks.mjs.map +1 -0
- package/build/shared/index.d.mts +7 -0
- package/build/shared/index.mjs +4 -0
- package/build/shared/issuerMetadataUtils.d.mts +22 -0
- package/build/shared/issuerMetadataUtils.d.mts.map +1 -0
- package/build/shared/issuerMetadataUtils.mjs +30 -0
- package/build/shared/issuerMetadataUtils.mjs.map +1 -0
- package/build/shared/models/CredentialHolderBinding.d.mts +71 -0
- package/build/shared/models/CredentialHolderBinding.d.mts.map +1 -0
- package/build/shared/models/CredentialHolderBinding.mjs +1 -0
- package/build/shared/models/OpenId4VcJwtIssuer.d.mts +46 -0
- package/build/shared/models/OpenId4VcJwtIssuer.d.mts.map +1 -0
- package/build/shared/models/OpenId4VcJwtIssuer.mjs +1 -0
- package/build/shared/models/OpenId4VciAuthorizationServerConfig.d.mts +71 -0
- package/build/shared/models/OpenId4VciAuthorizationServerConfig.d.mts.map +1 -0
- package/build/shared/models/OpenId4VciCredentialFormatProfile.d.mts +12 -0
- package/build/shared/models/OpenId4VciCredentialFormatProfile.d.mts.map +1 -0
- package/build/shared/models/OpenId4VciCredentialFormatProfile.mjs +14 -0
- package/build/shared/models/OpenId4VciCredentialFormatProfile.mjs.map +1 -0
- package/build/shared/models/index.d.mts +30 -0
- package/build/shared/models/index.d.mts.map +1 -0
- package/build/shared/models/index.mjs +6 -0
- package/build/shared/router/context.mjs +52 -0
- package/build/shared/router/context.mjs.map +1 -0
- package/build/shared/router/express.browser.d.mts +5 -0
- package/build/shared/router/express.browser.d.mts.map +1 -0
- package/build/shared/router/express.browser.mjs +8 -0
- package/build/shared/router/express.browser.mjs.map +1 -0
- package/build/shared/router/express.mjs +10 -0
- package/build/shared/router/express.mjs.map +1 -0
- package/build/shared/router/express.native.d.mts +5 -0
- package/build/shared/router/express.native.d.mts.map +1 -0
- package/build/shared/router/express.native.mjs +8 -0
- package/build/shared/router/express.native.mjs.map +1 -0
- package/build/shared/router/index.mjs +3 -0
- package/build/shared/router/tenants.mjs +36 -0
- package/build/shared/router/tenants.mjs.map +1 -0
- package/build/shared/transactionData.mjs +19 -0
- package/build/shared/transactionData.mjs.map +1 -0
- package/build/shared/utils.mjs +90 -0
- package/build/shared/utils.mjs.map +1 -0
- package/package.json +30 -23
- package/build/index.d.ts +0 -4
- package/build/index.js +0 -21
- package/build/index.js.map +0 -1
- package/build/openid4vc-holder/OpenId4VcHolderApi.d.ts +0 -124
- package/build/openid4vc-holder/OpenId4VcHolderApi.js +0 -155
- package/build/openid4vc-holder/OpenId4VcHolderApi.js.map +0 -1
- package/build/openid4vc-holder/OpenId4VcHolderModule.d.ts +0 -13
- package/build/openid4vc-holder/OpenId4VcHolderModule.js +0 -35
- package/build/openid4vc-holder/OpenId4VcHolderModule.js.map +0 -1
- package/build/openid4vc-holder/OpenId4VciHolderService.d.ts +0 -72
- package/build/openid4vc-holder/OpenId4VciHolderService.js +0 -569
- package/build/openid4vc-holder/OpenId4VciHolderService.js.map +0 -1
- package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.d.ts +0 -238
- package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.js +0 -14
- package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.js.map +0 -1
- package/build/openid4vc-holder/OpenId4vcSiopHolderService.d.ts +0 -32
- package/build/openid4vc-holder/OpenId4vcSiopHolderService.js +0 -302
- package/build/openid4vc-holder/OpenId4vcSiopHolderService.js.map +0 -1
- package/build/openid4vc-holder/OpenId4vcSiopHolderServiceOptions.d.ts +0 -38
- package/build/openid4vc-holder/OpenId4vcSiopHolderServiceOptions.js +0 -3
- package/build/openid4vc-holder/OpenId4vcSiopHolderServiceOptions.js.map +0 -1
- package/build/openid4vc-holder/index.d.ts +0 -6
- package/build/openid4vc-holder/index.js +0 -23
- package/build/openid4vc-holder/index.js.map +0 -1
- package/build/openid4vc-issuer/OpenId4VcIssuanceSessionState.d.ts +0 -12
- package/build/openid4vc-issuer/OpenId4VcIssuanceSessionState.js +0 -19
- package/build/openid4vc-issuer/OpenId4VcIssuanceSessionState.js.map +0 -1
- package/build/openid4vc-issuer/OpenId4VcIssuerApi.d.ts +0 -101
- package/build/openid4vc-issuer/OpenId4VcIssuerApi.js +0 -110
- package/build/openid4vc-issuer/OpenId4VcIssuerApi.js.map +0 -1
- package/build/openid4vc-issuer/OpenId4VcIssuerEvents.d.ts +0 -13
- package/build/openid4vc-issuer/OpenId4VcIssuerEvents.js +0 -8
- package/build/openid4vc-issuer/OpenId4VcIssuerEvents.js.map +0 -1
- package/build/openid4vc-issuer/OpenId4VcIssuerModule.d.ts +0 -21
- package/build/openid4vc-issuer/OpenId4VcIssuerModule.js +0 -121
- package/build/openid4vc-issuer/OpenId4VcIssuerModule.js.map +0 -1
- package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.d.ts +0 -190
- package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.js +0 -141
- package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.js.map +0 -1
- package/build/openid4vc-issuer/OpenId4VcIssuerService.d.ts +0 -116
- package/build/openid4vc-issuer/OpenId4VcIssuerService.js +0 -698
- package/build/openid4vc-issuer/OpenId4VcIssuerService.js.map +0 -1
- package/build/openid4vc-issuer/OpenId4VcIssuerServiceOptions.d.ts +0 -229
- package/build/openid4vc-issuer/OpenId4VcIssuerServiceOptions.js +0 -3
- package/build/openid4vc-issuer/OpenId4VcIssuerServiceOptions.js.map +0 -1
- package/build/openid4vc-issuer/index.d.ts +0 -8
- package/build/openid4vc-issuer/index.js +0 -27
- package/build/openid4vc-issuer/index.js.map +0 -1
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.d.ts +0 -160
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.js +0 -88
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.js.map +0 -1
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRepository.d.ts +0 -5
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRepository.js +0 -29
- package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRepository.js.map +0 -1
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.d.ts +0 -56
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.js +0 -83
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.js.map +0 -1
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRepository.d.ts +0 -8
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRepository.js +0 -35
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRepository.js.map +0 -1
- package/build/openid4vc-issuer/repository/index.d.ts +0 -4
- package/build/openid4vc-issuer/repository/index.js +0 -21
- package/build/openid4vc-issuer/repository/index.js.map +0 -1
- package/build/openid4vc-issuer/router/accessTokenEndpoint.d.ts +0 -5
- package/build/openid4vc-issuer/router/accessTokenEndpoint.js +0 -164
- package/build/openid4vc-issuer/router/accessTokenEndpoint.js.map +0 -1
- package/build/openid4vc-issuer/router/authorizationChallengeEndpoint.d.ts +0 -3
- package/build/openid4vc-issuer/router/authorizationChallengeEndpoint.js +0 -213
- package/build/openid4vc-issuer/router/authorizationChallengeEndpoint.js.map +0 -1
- package/build/openid4vc-issuer/router/authorizationServerMetadataEndpoint.d.ts +0 -6
- package/build/openid4vc-issuer/router/authorizationServerMetadataEndpoint.js +0 -25
- package/build/openid4vc-issuer/router/authorizationServerMetadataEndpoint.js.map +0 -1
- package/build/openid4vc-issuer/router/credentialEndpoint.d.ts +0 -3
- package/build/openid4vc-issuer/router/credentialEndpoint.js +0 -176
- package/build/openid4vc-issuer/router/credentialEndpoint.js.map +0 -1
- package/build/openid4vc-issuer/router/credentialOfferEndpoint.d.ts +0 -3
- package/build/openid4vc-issuer/router/credentialOfferEndpoint.js +0 -45
- package/build/openid4vc-issuer/router/credentialOfferEndpoint.js.map +0 -1
- package/build/openid4vc-issuer/router/index.d.ts +0 -9
- package/build/openid4vc-issuer/router/index.js +0 -20
- package/build/openid4vc-issuer/router/index.js.map +0 -1
- package/build/openid4vc-issuer/router/issuerMetadataEndpoint.d.ts +0 -2
- package/build/openid4vc-issuer/router/issuerMetadataEndpoint.js +0 -26
- package/build/openid4vc-issuer/router/issuerMetadataEndpoint.js.map +0 -1
- package/build/openid4vc-issuer/router/jwksEndpoint.d.ts +0 -3
- package/build/openid4vc-issuer/router/jwksEndpoint.js +0 -20
- package/build/openid4vc-issuer/router/jwksEndpoint.js.map +0 -1
- package/build/openid4vc-issuer/router/nonceEndpoint.d.ts +0 -3
- package/build/openid4vc-issuer/router/nonceEndpoint.js +0 -26
- package/build/openid4vc-issuer/router/nonceEndpoint.js.map +0 -1
- package/build/openid4vc-issuer/router/requestContext.d.ts +0 -5
- package/build/openid4vc-issuer/router/requestContext.js +0 -3
- package/build/openid4vc-issuer/router/requestContext.js.map +0 -1
- package/build/openid4vc-issuer/util/txCode.d.ts +0 -3
- package/build/openid4vc-issuer/util/txCode.js +0 -18
- package/build/openid4vc-issuer/util/txCode.js.map +0 -1
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.d.ts +0 -55
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.js +0 -498
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.js.map +0 -1
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierServiceOptions.d.ts +0 -77
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierServiceOptions.js +0 -3
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierServiceOptions.js.map +0 -1
- package/build/openid4vc-verifier/OpenId4VcVerificationSessionState.d.ts +0 -6
- package/build/openid4vc-verifier/OpenId4VcVerificationSessionState.js +0 -11
- package/build/openid4vc-verifier/OpenId4VcVerificationSessionState.js.map +0 -1
- package/build/openid4vc-verifier/OpenId4VcVerifierApi.d.ts +0 -61
- package/build/openid4vc-verifier/OpenId4VcVerifierApi.js +0 -108
- package/build/openid4vc-verifier/OpenId4VcVerifierApi.js.map +0 -1
- package/build/openid4vc-verifier/OpenId4VcVerifierEvents.d.ts +0 -13
- package/build/openid4vc-verifier/OpenId4VcVerifierEvents.js +0 -8
- package/build/openid4vc-verifier/OpenId4VcVerifierEvents.js.map +0 -1
- package/build/openid4vc-verifier/OpenId4VcVerifierModule.d.ts +0 -21
- package/build/openid4vc-verifier/OpenId4VcVerifierModule.js +0 -109
- package/build/openid4vc-verifier/OpenId4VcVerifierModule.js.map +0 -1
- package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.d.ts +0 -31
- package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.js +0 -28
- package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.js.map +0 -1
- package/build/openid4vc-verifier/index.d.ts +0 -8
- package/build/openid4vc-verifier/index.js +0 -25
- package/build/openid4vc-verifier/index.js.map +0 -1
- package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartyEventEmitter.d.ts +0 -49
- package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartyEventEmitter.js +0 -234
- package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartyEventEmitter.js.map +0 -1
- package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartySessionManager.d.ts +0 -19
- package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartySessionManager.js +0 -146
- package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartySessionManager.js.map +0 -1
- package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRecord.d.ts +0 -71
- package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRecord.js +0 -46
- package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRecord.js.map +0 -1
- package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRepository.d.ts +0 -5
- package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRepository.js +0 -29
- package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRepository.js.map +0 -1
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRecord.d.ts +0 -29
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRecord.js +0 -29
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRecord.js.map +0 -1
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRepository.d.ts +0 -8
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRepository.js +0 -35
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRepository.js.map +0 -1
- package/build/openid4vc-verifier/repository/index.d.ts +0 -4
- package/build/openid4vc-verifier/repository/index.js +0 -21
- package/build/openid4vc-verifier/repository/index.js.map +0 -1
- package/build/openid4vc-verifier/router/authorizationEndpoint.d.ts +0 -11
- package/build/openid4vc-verifier/router/authorizationEndpoint.js +0 -102
- package/build/openid4vc-verifier/router/authorizationEndpoint.js.map +0 -1
- package/build/openid4vc-verifier/router/authorizationRequestEndpoint.d.ts +0 -11
- package/build/openid4vc-verifier/router/authorizationRequestEndpoint.js +0 -63
- package/build/openid4vc-verifier/router/authorizationRequestEndpoint.js.map +0 -1
- package/build/openid4vc-verifier/router/index.d.ts +0 -2
- package/build/openid4vc-verifier/router/index.js +0 -6
- package/build/openid4vc-verifier/router/index.js.map +0 -1
- package/build/openid4vc-verifier/router/requestContext.d.ts +0 -5
- package/build/openid4vc-verifier/router/requestContext.js +0 -3
- package/build/openid4vc-verifier/router/requestContext.js.map +0 -1
- package/build/shared/callbacks.d.ts +0 -18
- package/build/shared/callbacks.js +0 -81
- package/build/shared/callbacks.js.map +0 -1
- package/build/shared/index.d.ts +0 -2
- package/build/shared/index.js +0 -19
- package/build/shared/index.js.map +0 -1
- package/build/shared/issuerMetadataUtils.d.ts +0 -158
- package/build/shared/issuerMetadataUtils.js +0 -38
- package/build/shared/issuerMetadataUtils.js.map +0 -1
- package/build/shared/models/CredentialHolderBinding.d.ts +0 -13
- package/build/shared/models/CredentialHolderBinding.js +0 -3
- package/build/shared/models/CredentialHolderBinding.js.map +0 -1
- package/build/shared/models/OpenId4VcJwtIssuer.d.ts +0 -28
- package/build/shared/models/OpenId4VcJwtIssuer.js +0 -3
- package/build/shared/models/OpenId4VcJwtIssuer.js.map +0 -1
- package/build/shared/models/OpenId4VciAuthorizationServerConfig.d.ts +0 -10
- package/build/shared/models/OpenId4VciAuthorizationServerConfig.js +0 -3
- package/build/shared/models/OpenId4VciAuthorizationServerConfig.js.map +0 -1
- package/build/shared/models/OpenId4VciCredentialFormatProfile.d.ts +0 -7
- package/build/shared/models/OpenId4VciCredentialFormatProfile.js +0 -12
- package/build/shared/models/OpenId4VciCredentialFormatProfile.js.map +0 -1
- package/build/shared/models/index.d.ts +0 -24
- package/build/shared/models/index.js +0 -25
- package/build/shared/models/index.js.map +0 -1
- package/build/shared/router/context.d.ts +0 -17
- package/build/shared/router/context.js +0 -76
- package/build/shared/router/context.js.map +0 -1
- package/build/shared/router/express.d.ts +0 -2
- package/build/shared/router/express.js +0 -15
- package/build/shared/router/express.js.map +0 -1
- package/build/shared/router/express.native.d.ts +0 -1
- package/build/shared/router/express.native.js +0 -7
- package/build/shared/router/express.native.js.map +0 -1
- package/build/shared/router/index.d.ts +0 -3
- package/build/shared/router/index.js +0 -20
- package/build/shared/router/index.js.map +0 -1
- package/build/shared/router/tenants.d.ts +0 -13
- package/build/shared/router/tenants.js +0 -49
- package/build/shared/router/tenants.js.map +0 -1
- package/build/shared/transform.d.ts +0 -5
- package/build/shared/transform.js +0 -73
- package/build/shared/transform.js.map +0 -1
- package/build/shared/utils.d.ts +0 -22
- package/build/shared/utils.js +0 -154
- package/build/shared/utils.js.map +0 -1
|
@@ -1,698 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.OpenId4VcIssuerService = void 0;
|
|
13
|
-
const oauth2_1 = require("@animo-id/oauth2");
|
|
14
|
-
const oid4vci_1 = require("@animo-id/oid4vci");
|
|
15
|
-
const core_1 = require("@credo-ts/core");
|
|
16
|
-
const openid4vc_verifier_1 = require("../openid4vc-verifier");
|
|
17
|
-
const shared_1 = require("../shared");
|
|
18
|
-
const callbacks_1 = require("../shared/callbacks");
|
|
19
|
-
const issuerMetadataUtils_1 = require("../shared/issuerMetadataUtils");
|
|
20
|
-
const router_1 = require("../shared/router");
|
|
21
|
-
const utils_1 = require("../shared/utils");
|
|
22
|
-
const OpenId4VcIssuanceSessionState_1 = require("./OpenId4VcIssuanceSessionState");
|
|
23
|
-
const OpenId4VcIssuerEvents_1 = require("./OpenId4VcIssuerEvents");
|
|
24
|
-
const OpenId4VcIssuerModuleConfig_1 = require("./OpenId4VcIssuerModuleConfig");
|
|
25
|
-
const repository_1 = require("./repository");
|
|
26
|
-
const txCode_1 = require("./util/txCode");
|
|
27
|
-
/**
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
30
|
-
let OpenId4VcIssuerService = class OpenId4VcIssuerService {
|
|
31
|
-
constructor(w3cCredentialService, openId4VcIssuerConfig, openId4VcIssuerRepository, openId4VcIssuanceSessionRepository) {
|
|
32
|
-
this.w3cCredentialService = w3cCredentialService;
|
|
33
|
-
this.openId4VcIssuerConfig = openId4VcIssuerConfig;
|
|
34
|
-
this.openId4VcIssuerRepository = openId4VcIssuerRepository;
|
|
35
|
-
this.openId4VcIssuanceSessionRepository = openId4VcIssuanceSessionRepository;
|
|
36
|
-
}
|
|
37
|
-
async createStatelessCredentialOffer(agentContext, options) {
|
|
38
|
-
const { authorizationCodeFlowConfig, issuer, offeredCredentials } = options;
|
|
39
|
-
const vcIssuer = this.getIssuer(agentContext);
|
|
40
|
-
const issuerMetadata = await this.getIssuerMetadata(agentContext, issuer);
|
|
41
|
-
const uniqueOfferedCredentials = Array.from(new Set(options.offeredCredentials));
|
|
42
|
-
if (uniqueOfferedCredentials.length !== offeredCredentials.length) {
|
|
43
|
-
throw new core_1.CredoError('All offered credentials must have unique ids.');
|
|
44
|
-
}
|
|
45
|
-
// Check if all the offered credential configuration ids have a scope value. If not, it won't be possible to actually request
|
|
46
|
-
// issuance of the crednetial later on
|
|
47
|
-
(0, oid4vci_1.extractScopesForCredentialConfigurationIds)({
|
|
48
|
-
credentialConfigurationIds: options.offeredCredentials,
|
|
49
|
-
issuerMetadata,
|
|
50
|
-
throwOnConfigurationWithoutScope: true,
|
|
51
|
-
});
|
|
52
|
-
if (authorizationCodeFlowConfig.authorizationServerUrl === issuerMetadata.credentialIssuer.credential_issuer) {
|
|
53
|
-
throw new core_1.CredoError('Stateless offers can only be created for external authorization servers. Make sure to configure an external authorization server on the issuer record, and provide the authoriation server url.');
|
|
54
|
-
}
|
|
55
|
-
const { credentialOffer, credentialOfferObject } = await vcIssuer.createCredentialOffer({
|
|
56
|
-
credentialConfigurationIds: options.offeredCredentials,
|
|
57
|
-
grants: {
|
|
58
|
-
authorization_code: {
|
|
59
|
-
authorization_server: authorizationCodeFlowConfig.authorizationServerUrl,
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
credentialOfferScheme: options.baseUri,
|
|
63
|
-
issuerMetadata,
|
|
64
|
-
});
|
|
65
|
-
return {
|
|
66
|
-
credentialOffer,
|
|
67
|
-
credentialOfferObject,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
async createCredentialOffer(agentContext, options) {
|
|
71
|
-
var _a, _b, _c, _d, _e, _f;
|
|
72
|
-
const { preAuthorizedCodeFlowConfig, authorizationCodeFlowConfig, issuer, offeredCredentials, version = 'v1.draft11-13', } = options;
|
|
73
|
-
if (!preAuthorizedCodeFlowConfig && !authorizationCodeFlowConfig) {
|
|
74
|
-
throw new core_1.CredoError('Authorization Config or Pre-Authorized Config must be provided.');
|
|
75
|
-
}
|
|
76
|
-
const vcIssuer = this.getIssuer(agentContext);
|
|
77
|
-
const issuerMetadata = await this.getIssuerMetadata(agentContext, issuer);
|
|
78
|
-
const uniqueOfferedCredentials = Array.from(new Set(options.offeredCredentials));
|
|
79
|
-
if (uniqueOfferedCredentials.length !== offeredCredentials.length) {
|
|
80
|
-
throw new core_1.CredoError('All offered credentials must have unique ids.');
|
|
81
|
-
}
|
|
82
|
-
if (uniqueOfferedCredentials.length === 0) {
|
|
83
|
-
throw new core_1.CredoError('You need to offer at least one credential.');
|
|
84
|
-
}
|
|
85
|
-
// We always use shortened URIs currently
|
|
86
|
-
const hostedCredentialOfferUri = (0, core_1.joinUriParts)(issuerMetadata.credentialIssuer.credential_issuer, [
|
|
87
|
-
this.openId4VcIssuerConfig.credentialOfferEndpointPath,
|
|
88
|
-
// It doesn't really matter what the url is, as long as it's unique
|
|
89
|
-
core_1.utils.uuid(),
|
|
90
|
-
]);
|
|
91
|
-
// Check if all the offered credential configuration ids have a scope value. If not, it won't be possible to actually request
|
|
92
|
-
// issuance of the crednetial later on. For pre-auth it's not needed to add a scope.
|
|
93
|
-
if (options.authorizationCodeFlowConfig) {
|
|
94
|
-
(0, oid4vci_1.extractScopesForCredentialConfigurationIds)({
|
|
95
|
-
credentialConfigurationIds: options.offeredCredentials,
|
|
96
|
-
issuerMetadata,
|
|
97
|
-
throwOnConfigurationWithoutScope: true,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
const grants = await this.getGrantsFromConfig(agentContext, {
|
|
101
|
-
issuerMetadata,
|
|
102
|
-
preAuthorizedCodeFlowConfig,
|
|
103
|
-
authorizationCodeFlowConfig,
|
|
104
|
-
});
|
|
105
|
-
const { credentialOffer, credentialOfferObject } = await vcIssuer.createCredentialOffer({
|
|
106
|
-
credentialConfigurationIds: options.offeredCredentials,
|
|
107
|
-
grants,
|
|
108
|
-
credentialOfferUri: hostedCredentialOfferUri,
|
|
109
|
-
credentialOfferScheme: options.baseUri,
|
|
110
|
-
issuerMetadata: Object.assign({ originalDraftVersion: version === 'v1.draft11-13' ? oid4vci_1.Oid4vciDraftVersion.Draft11 : oid4vci_1.Oid4vciDraftVersion.Draft14 }, issuerMetadata),
|
|
111
|
-
});
|
|
112
|
-
const issuanceSessionRepository = this.openId4VcIssuanceSessionRepository;
|
|
113
|
-
const issuanceSession = new repository_1.OpenId4VcIssuanceSessionRecord({
|
|
114
|
-
credentialOfferPayload: credentialOfferObject,
|
|
115
|
-
credentialOfferUri: hostedCredentialOfferUri,
|
|
116
|
-
issuerId: issuer.issuerId,
|
|
117
|
-
state: OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.OfferCreated,
|
|
118
|
-
authorization: ((_b = (_a = credentialOfferObject.grants) === null || _a === void 0 ? void 0 : _a.authorization_code) === null || _b === void 0 ? void 0 : _b.issuer_state)
|
|
119
|
-
? {
|
|
120
|
-
issuerState: (_d = (_c = credentialOfferObject.grants) === null || _c === void 0 ? void 0 : _c.authorization_code) === null || _d === void 0 ? void 0 : _d.issuer_state,
|
|
121
|
-
}
|
|
122
|
-
: undefined,
|
|
123
|
-
presentation: (authorizationCodeFlowConfig === null || authorizationCodeFlowConfig === void 0 ? void 0 : authorizationCodeFlowConfig.requirePresentationDuringIssuance)
|
|
124
|
-
? {
|
|
125
|
-
required: true,
|
|
126
|
-
}
|
|
127
|
-
: undefined,
|
|
128
|
-
// TODO: how to mix pre-auth and auth? Need to do state checks
|
|
129
|
-
preAuthorizedCode: (_f = (_e = credentialOfferObject.grants) === null || _e === void 0 ? void 0 : _e[oauth2_1.preAuthorizedCodeGrantIdentifier]) === null || _f === void 0 ? void 0 : _f['pre-authorized_code'],
|
|
130
|
-
userPin: (preAuthorizedCodeFlowConfig === null || preAuthorizedCodeFlowConfig === void 0 ? void 0 : preAuthorizedCodeFlowConfig.txCode)
|
|
131
|
-
? (0, txCode_1.generateTxCode)(agentContext, preAuthorizedCodeFlowConfig.txCode)
|
|
132
|
-
: undefined,
|
|
133
|
-
issuanceMetadata: options.issuanceMetadata,
|
|
134
|
-
});
|
|
135
|
-
await issuanceSessionRepository.save(agentContext, issuanceSession);
|
|
136
|
-
this.emitStateChangedEvent(agentContext, issuanceSession, null);
|
|
137
|
-
return {
|
|
138
|
-
issuanceSession,
|
|
139
|
-
credentialOffer,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
async createCredentialResponse(agentContext, options) {
|
|
143
|
-
options.issuanceSession.assertState([
|
|
144
|
-
// OfferUriRetrieved is valid when doing auth flow (we should add a check)
|
|
145
|
-
OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.OfferUriRetrieved,
|
|
146
|
-
OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.AccessTokenCreated,
|
|
147
|
-
OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.CredentialRequestReceived,
|
|
148
|
-
// It is possible to issue multiple credentials in one session
|
|
149
|
-
OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.CredentialsPartiallyIssued,
|
|
150
|
-
]);
|
|
151
|
-
const { issuanceSession } = options;
|
|
152
|
-
const issuer = await this.getIssuerByIssuerId(agentContext, options.issuanceSession.issuerId);
|
|
153
|
-
const vcIssuer = this.getIssuer(agentContext);
|
|
154
|
-
const issuerMetadata = await this.getIssuerMetadata(agentContext, issuer);
|
|
155
|
-
const parsedCredentialRequest = vcIssuer.parseCredentialRequest({
|
|
156
|
-
credentialRequest: options.credentialRequest,
|
|
157
|
-
});
|
|
158
|
-
const { credentialRequest, credentialIdentifier, format, proofs } = parsedCredentialRequest;
|
|
159
|
-
if (credentialIdentifier) {
|
|
160
|
-
throw new oauth2_1.Oauth2ServerErrorResponseError({
|
|
161
|
-
error: oauth2_1.Oauth2ErrorCodes.InvalidCredentialRequest,
|
|
162
|
-
error_description: `Using unsupported 'credential_identifier'`,
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
if (!format) {
|
|
166
|
-
throw new oauth2_1.Oauth2ServerErrorResponseError({
|
|
167
|
-
error: oauth2_1.Oauth2ErrorCodes.UnsupportedCredentialFormat,
|
|
168
|
-
error_description: `Unsupported credential format '${credentialRequest.format}'`,
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
if (!(proofs === null || proofs === void 0 ? void 0 : proofs.jwt) || proofs.jwt.length === 0) {
|
|
172
|
-
const { cNonce, cNonceExpiresInSeconds } = await this.createNonce(agentContext, issuer);
|
|
173
|
-
throw new oauth2_1.Oauth2ServerErrorResponseError({
|
|
174
|
-
error: oauth2_1.Oauth2ErrorCodes.InvalidProof,
|
|
175
|
-
error_description: 'Missing required proof(s) in credential request',
|
|
176
|
-
c_nonce: cNonce,
|
|
177
|
-
c_nonce_expires_in: cNonceExpiresInSeconds,
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
await this.updateState(agentContext, issuanceSession, OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.CredentialRequestReceived);
|
|
181
|
-
let previousNonce = undefined;
|
|
182
|
-
const proofSigners = [];
|
|
183
|
-
for (const jwt of proofs.jwt) {
|
|
184
|
-
const { signer, payload } = await vcIssuer.verifyCredentialRequestJwtProof({
|
|
185
|
-
issuerMetadata,
|
|
186
|
-
jwt,
|
|
187
|
-
clientId: options.issuanceSession.clientId,
|
|
188
|
-
});
|
|
189
|
-
if (!payload.nonce) {
|
|
190
|
-
const { cNonce, cNonceExpiresInSeconds } = await this.createNonce(agentContext, issuer);
|
|
191
|
-
throw new oauth2_1.Oauth2ServerErrorResponseError({
|
|
192
|
-
error: oauth2_1.Oauth2ErrorCodes.InvalidProof,
|
|
193
|
-
error_description: 'Missing nonce in proof(s) in credential request',
|
|
194
|
-
c_nonce: cNonce,
|
|
195
|
-
c_nonce_expires_in: cNonceExpiresInSeconds,
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
// Set previous nonce if not yet set (first iteration)
|
|
199
|
-
if (!previousNonce)
|
|
200
|
-
previousNonce = payload.nonce;
|
|
201
|
-
if (previousNonce !== payload.nonce) {
|
|
202
|
-
const { cNonce, cNonceExpiresInSeconds } = await this.createNonce(agentContext, issuer);
|
|
203
|
-
throw new oauth2_1.Oauth2ServerErrorResponseError({
|
|
204
|
-
error: oauth2_1.Oauth2ErrorCodes.InvalidProof,
|
|
205
|
-
error_description: 'Not all nonce values in proofs are equal',
|
|
206
|
-
c_nonce: cNonce,
|
|
207
|
-
c_nonce_expires_in: cNonceExpiresInSeconds,
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
// Verify the nonce
|
|
211
|
-
await this.verifyNonce(agentContext, issuer, payload.nonce).catch(async (error) => {
|
|
212
|
-
const { cNonce, cNonceExpiresInSeconds } = await this.createNonce(agentContext, issuer);
|
|
213
|
-
throw new oauth2_1.Oauth2ServerErrorResponseError({
|
|
214
|
-
error: oauth2_1.Oauth2ErrorCodes.InvalidNonce,
|
|
215
|
-
error_description: 'Invalid nonce in credential request',
|
|
216
|
-
c_nonce: cNonce,
|
|
217
|
-
c_nonce_expires_in: cNonceExpiresInSeconds,
|
|
218
|
-
}, {
|
|
219
|
-
cause: error,
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
proofSigners.push(signer);
|
|
223
|
-
}
|
|
224
|
-
const signedCredentials = await this.getSignedCredentials(agentContext, {
|
|
225
|
-
credentialRequest,
|
|
226
|
-
issuanceSession,
|
|
227
|
-
issuer,
|
|
228
|
-
requestFormat: format,
|
|
229
|
-
authorization: options.authorization,
|
|
230
|
-
credentialRequestToCredentialMapper: options.credentialRequestToCredentialMapper,
|
|
231
|
-
proofSigners,
|
|
232
|
-
});
|
|
233
|
-
// NOTE: nonce in credential response is deprecated in newer drafts, but for now we keep it in
|
|
234
|
-
const { cNonce, cNonceExpiresInSeconds } = await this.createNonce(agentContext, issuer);
|
|
235
|
-
const credentialResponse = vcIssuer.createCredentialResponse({
|
|
236
|
-
credential: credentialRequest.proof ? signedCredentials.credentials[0] : undefined,
|
|
237
|
-
credentials: credentialRequest.proofs ? signedCredentials.credentials : undefined,
|
|
238
|
-
cNonce,
|
|
239
|
-
cNonceExpiresInSeconds,
|
|
240
|
-
credentialRequest: parsedCredentialRequest,
|
|
241
|
-
});
|
|
242
|
-
issuanceSession.issuedCredentials.push(signedCredentials.credentialConfigurationId);
|
|
243
|
-
const newState = issuanceSession.issuedCredentials.length >=
|
|
244
|
-
issuanceSession.credentialOfferPayload.credential_configuration_ids.length
|
|
245
|
-
? OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.Completed
|
|
246
|
-
: OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.CredentialsPartiallyIssued;
|
|
247
|
-
await this.updateState(agentContext, issuanceSession, newState);
|
|
248
|
-
return {
|
|
249
|
-
credentialResponse,
|
|
250
|
-
issuanceSession,
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
async findIssuanceSessionsByQuery(agentContext, query, queryOptions) {
|
|
254
|
-
return this.openId4VcIssuanceSessionRepository.findByQuery(agentContext, query, queryOptions);
|
|
255
|
-
}
|
|
256
|
-
async findSingleIssuancSessionByQuery(agentContext, query) {
|
|
257
|
-
return this.openId4VcIssuanceSessionRepository.findSingleByQuery(agentContext, query);
|
|
258
|
-
}
|
|
259
|
-
async getIssuanceSessionById(agentContext, issuanceSessionId) {
|
|
260
|
-
return this.openId4VcIssuanceSessionRepository.getById(agentContext, issuanceSessionId);
|
|
261
|
-
}
|
|
262
|
-
async getAllIssuers(agentContext) {
|
|
263
|
-
return this.openId4VcIssuerRepository.getAll(agentContext);
|
|
264
|
-
}
|
|
265
|
-
async getIssuerByIssuerId(agentContext, issuerId) {
|
|
266
|
-
return this.openId4VcIssuerRepository.getByIssuerId(agentContext, issuerId);
|
|
267
|
-
}
|
|
268
|
-
async updateIssuer(agentContext, issuer) {
|
|
269
|
-
return this.openId4VcIssuerRepository.update(agentContext, issuer);
|
|
270
|
-
}
|
|
271
|
-
async createIssuer(agentContext, options) {
|
|
272
|
-
var _a, _b;
|
|
273
|
-
// TODO: ideally we can store additional data with a key, such as:
|
|
274
|
-
// - createdAt
|
|
275
|
-
// - purpose
|
|
276
|
-
const accessTokenSignerKey = await agentContext.wallet.createKey({
|
|
277
|
-
keyType: (_a = options.accessTokenSignerKeyType) !== null && _a !== void 0 ? _a : core_1.KeyType.Ed25519,
|
|
278
|
-
});
|
|
279
|
-
const openId4VcIssuer = new repository_1.OpenId4VcIssuerRecord({
|
|
280
|
-
issuerId: (_b = options.issuerId) !== null && _b !== void 0 ? _b : core_1.utils.uuid(),
|
|
281
|
-
display: options.display,
|
|
282
|
-
dpopSigningAlgValuesSupported: options.dpopSigningAlgValuesSupported,
|
|
283
|
-
accessTokenPublicKeyFingerprint: accessTokenSignerKey.fingerprint,
|
|
284
|
-
authorizationServerConfigs: options.authorizationServerConfigs,
|
|
285
|
-
credentialConfigurationsSupported: options.credentialConfigurationsSupported,
|
|
286
|
-
batchCredentialIssuance: options.batchCredentialIssuance,
|
|
287
|
-
});
|
|
288
|
-
await this.openId4VcIssuerRepository.save(agentContext, openId4VcIssuer);
|
|
289
|
-
await (0, router_1.storeActorIdForContextCorrelationId)(agentContext, openId4VcIssuer.issuerId);
|
|
290
|
-
return openId4VcIssuer;
|
|
291
|
-
}
|
|
292
|
-
async rotateAccessTokenSigningKey(agentContext, issuer, options) {
|
|
293
|
-
var _a;
|
|
294
|
-
const accessTokenSignerKey = await agentContext.wallet.createKey({
|
|
295
|
-
keyType: (_a = options === null || options === void 0 ? void 0 : options.accessTokenSignerKeyType) !== null && _a !== void 0 ? _a : core_1.KeyType.Ed25519,
|
|
296
|
-
});
|
|
297
|
-
// TODO: ideally we can remove the previous key
|
|
298
|
-
issuer.accessTokenPublicKeyFingerprint = accessTokenSignerKey.fingerprint;
|
|
299
|
-
await this.openId4VcIssuerRepository.update(agentContext, issuer);
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* @param fetchExternalAuthorizationServerMetadata defaults to false
|
|
303
|
-
*/
|
|
304
|
-
async getIssuerMetadata(agentContext, issuerRecord, fetchExternalAuthorizationServerMetadata = false) {
|
|
305
|
-
var _a;
|
|
306
|
-
const config = agentContext.dependencyManager.resolve(OpenId4VcIssuerModuleConfig_1.OpenId4VcIssuerModuleConfig);
|
|
307
|
-
const issuerUrl = (0, core_1.joinUriParts)(config.baseUrl, [issuerRecord.issuerId]);
|
|
308
|
-
const oauth2Client = this.getOauth2Client(agentContext);
|
|
309
|
-
const extraAuthorizationServers = fetchExternalAuthorizationServerMetadata && issuerRecord.authorizationServerConfigs
|
|
310
|
-
? await Promise.all(issuerRecord.authorizationServerConfigs.map(async (server) => {
|
|
311
|
-
const metadata = await oauth2Client.fetchAuthorizationServerMetadata(server.issuer);
|
|
312
|
-
if (!metadata)
|
|
313
|
-
throw new core_1.CredoError(`Authorization server metadata not found for issuer '${server.issuer}'`);
|
|
314
|
-
return metadata;
|
|
315
|
-
}))
|
|
316
|
-
: [];
|
|
317
|
-
const authorizationServers = issuerRecord.authorizationServerConfigs && issuerRecord.authorizationServerConfigs.length > 0
|
|
318
|
-
? [
|
|
319
|
-
...issuerRecord.authorizationServerConfigs.map((authorizationServer) => authorizationServer.issuer),
|
|
320
|
-
// Our issuer is also a valid authorization server (only for pre-auth)
|
|
321
|
-
issuerUrl,
|
|
322
|
-
]
|
|
323
|
-
: undefined;
|
|
324
|
-
const credentialIssuerMetadata = {
|
|
325
|
-
credential_issuer: issuerUrl,
|
|
326
|
-
credential_endpoint: (0, core_1.joinUriParts)(issuerUrl, [config.credentialEndpointPath]),
|
|
327
|
-
credential_configurations_supported: (_a = issuerRecord.credentialConfigurationsSupported) !== null && _a !== void 0 ? _a : {},
|
|
328
|
-
authorization_servers: authorizationServers,
|
|
329
|
-
display: issuerRecord.display,
|
|
330
|
-
nonce_endpoint: (0, core_1.joinUriParts)(issuerUrl, [config.nonceEndpointPath]),
|
|
331
|
-
batch_credential_issuance: issuerRecord.batchCredentialIssuance
|
|
332
|
-
? {
|
|
333
|
-
batch_size: issuerRecord.batchCredentialIssuance.batchSize,
|
|
334
|
-
}
|
|
335
|
-
: undefined,
|
|
336
|
-
};
|
|
337
|
-
const issuerAuthorizationServer = {
|
|
338
|
-
issuer: issuerUrl,
|
|
339
|
-
token_endpoint: (0, core_1.joinUriParts)(issuerUrl, [config.accessTokenEndpointPath]),
|
|
340
|
-
'pre-authorized_grant_anonymous_access_supported': true,
|
|
341
|
-
jwks_uri: (0, core_1.joinUriParts)(issuerUrl, [config.jwksEndpointPath]),
|
|
342
|
-
authorization_challenge_endpoint: (0, core_1.joinUriParts)(issuerUrl, [config.authorizationChallengeEndpointPath]),
|
|
343
|
-
// TODO: PAR (maybe not needed as we only use this auth server for presentation during issuance)
|
|
344
|
-
// pushed_authorization_request_endpoint: '',
|
|
345
|
-
// require_pushed_authorization_requests: true
|
|
346
|
-
code_challenge_methods_supported: [oauth2_1.PkceCodeChallengeMethod.S256],
|
|
347
|
-
dpop_signing_alg_values_supported: issuerRecord.dpopSigningAlgValuesSupported,
|
|
348
|
-
};
|
|
349
|
-
return {
|
|
350
|
-
credentialIssuer: credentialIssuerMetadata,
|
|
351
|
-
authorizationServers: [issuerAuthorizationServer, ...extraAuthorizationServers],
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
async createNonce(agentContext, issuer) {
|
|
355
|
-
const issuerMetadata = await this.getIssuerMetadata(agentContext, issuer);
|
|
356
|
-
const jwsService = agentContext.dependencyManager.resolve(core_1.JwsService);
|
|
357
|
-
const cNonceExpiresInSeconds = this.openId4VcIssuerConfig.cNonceExpiresInSeconds;
|
|
358
|
-
const cNonceExpiresAt = (0, utils_1.addSecondsToDate)(new Date(), cNonceExpiresInSeconds);
|
|
359
|
-
const key = core_1.Key.fromFingerprint(issuer.accessTokenPublicKeyFingerprint);
|
|
360
|
-
const jwk = (0, core_1.getJwkFromKey)(key);
|
|
361
|
-
const cNonce = await jwsService.createJwsCompact(agentContext, {
|
|
362
|
-
key,
|
|
363
|
-
payload: core_1.JwtPayload.fromJson({
|
|
364
|
-
iss: issuerMetadata.credentialIssuer.credential_issuer,
|
|
365
|
-
exp: (0, utils_1.dateToSeconds)(cNonceExpiresAt),
|
|
366
|
-
}),
|
|
367
|
-
protectedHeaderOptions: {
|
|
368
|
-
typ: 'credo+cnonce',
|
|
369
|
-
kid: issuer.accessTokenPublicKeyFingerprint,
|
|
370
|
-
alg: jwk.supportedSignatureAlgorithms[0],
|
|
371
|
-
},
|
|
372
|
-
});
|
|
373
|
-
return {
|
|
374
|
-
cNonce,
|
|
375
|
-
cNonceExpiresAt,
|
|
376
|
-
cNonceExpiresInSeconds,
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* @todo nonces are very short lived (1 min), but it might be nice to also cache the nonces
|
|
381
|
-
* in the cache if we have 'seen' them. They will only be in the cache for a short time
|
|
382
|
-
* and it will prevent replay
|
|
383
|
-
*/
|
|
384
|
-
async verifyNonce(agentContext, issuer, cNonce) {
|
|
385
|
-
const issuerMetadata = await this.getIssuerMetadata(agentContext, issuer);
|
|
386
|
-
const jwsService = agentContext.dependencyManager.resolve(core_1.JwsService);
|
|
387
|
-
const key = core_1.Key.fromFingerprint(issuer.accessTokenPublicKeyFingerprint);
|
|
388
|
-
const jwk = (0, core_1.getJwkFromKey)(key);
|
|
389
|
-
const jwt = core_1.Jwt.fromSerializedJwt(cNonce);
|
|
390
|
-
jwt.payload.validate();
|
|
391
|
-
if (jwt.payload.iss !== issuerMetadata.credentialIssuer.credential_issuer) {
|
|
392
|
-
throw new core_1.CredoError(`Invalid 'iss' claim in cNonce jwt`);
|
|
393
|
-
}
|
|
394
|
-
if (jwt.header.typ !== 'credo+cnonce') {
|
|
395
|
-
throw new core_1.CredoError(`Invalid 'typ' claim in cNonce jwt header`);
|
|
396
|
-
}
|
|
397
|
-
const verification = await jwsService.verifyJws(agentContext, {
|
|
398
|
-
jws: cNonce,
|
|
399
|
-
jwkResolver: () => jwk,
|
|
400
|
-
});
|
|
401
|
-
if (!verification.signerKeys
|
|
402
|
-
.map((singerKey) => singerKey.fingerprint)
|
|
403
|
-
.includes(issuer.accessTokenPublicKeyFingerprint)) {
|
|
404
|
-
throw new core_1.CredoError('Invalid nonce');
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
getIssuer(agentContext) {
|
|
408
|
-
return new oid4vci_1.Oid4vciIssuer({
|
|
409
|
-
callbacks: (0, callbacks_1.getOid4vciCallbacks)(agentContext),
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
getOauth2Client(agentContext) {
|
|
413
|
-
return new oauth2_1.Oauth2Client({
|
|
414
|
-
callbacks: (0, callbacks_1.getOid4vciCallbacks)(agentContext),
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
getOauth2AuthorizationServer(agentContext) {
|
|
418
|
-
return new oauth2_1.Oauth2AuthorizationServer({
|
|
419
|
-
callbacks: (0, callbacks_1.getOid4vciCallbacks)(agentContext),
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
getResourceServer(agentContext, issuerRecord) {
|
|
423
|
-
return new oauth2_1.Oauth2ResourceServer({
|
|
424
|
-
callbacks: Object.assign(Object.assign({}, (0, callbacks_1.getOid4vciCallbacks)(agentContext)), { clientAuthentication: (0, callbacks_1.dynamicOid4vciClientAuthentication)(agentContext, issuerRecord) }),
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
/**
|
|
428
|
-
* Update the record to a new state and emit an state changed event. Also updates the record
|
|
429
|
-
* in storage.
|
|
430
|
-
*/
|
|
431
|
-
async updateState(agentContext, issuanceSession, newState) {
|
|
432
|
-
agentContext.config.logger.debug(`Updating openid4vc issuance session record ${issuanceSession.id} to state ${newState} (previous=${issuanceSession.state})`);
|
|
433
|
-
const previousState = issuanceSession.state;
|
|
434
|
-
issuanceSession.state = newState;
|
|
435
|
-
await this.openId4VcIssuanceSessionRepository.update(agentContext, issuanceSession);
|
|
436
|
-
this.emitStateChangedEvent(agentContext, issuanceSession, previousState);
|
|
437
|
-
}
|
|
438
|
-
emitStateChangedEvent(agentContext, issuanceSession, previousState) {
|
|
439
|
-
const eventEmitter = agentContext.dependencyManager.resolve(core_1.EventEmitter);
|
|
440
|
-
eventEmitter.emit(agentContext, {
|
|
441
|
-
type: OpenId4VcIssuerEvents_1.OpenId4VcIssuerEvents.IssuanceSessionStateChanged,
|
|
442
|
-
payload: {
|
|
443
|
-
issuanceSession: issuanceSession.clone(),
|
|
444
|
-
previousState: previousState,
|
|
445
|
-
},
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
async getGrantsFromConfig(agentContext, config) {
|
|
449
|
-
var _a;
|
|
450
|
-
const { preAuthorizedCodeFlowConfig, authorizationCodeFlowConfig, issuerMetadata } = config;
|
|
451
|
-
// TOOD: export type
|
|
452
|
-
const grants = {};
|
|
453
|
-
// Pre auth
|
|
454
|
-
if (preAuthorizedCodeFlowConfig) {
|
|
455
|
-
const { txCode, authorizationServerUrl, preAuthorizedCode } = preAuthorizedCodeFlowConfig;
|
|
456
|
-
grants[oauth2_1.preAuthorizedCodeGrantIdentifier] = {
|
|
457
|
-
'pre-authorized_code': preAuthorizedCode !== null && preAuthorizedCode !== void 0 ? preAuthorizedCode : (await agentContext.wallet.generateNonce()),
|
|
458
|
-
tx_code: txCode,
|
|
459
|
-
authorization_server: config.issuerMetadata.credentialIssuer.authorization_servers
|
|
460
|
-
? authorizationServerUrl
|
|
461
|
-
: undefined,
|
|
462
|
-
};
|
|
463
|
-
}
|
|
464
|
-
// Auth
|
|
465
|
-
if (authorizationCodeFlowConfig) {
|
|
466
|
-
const { requirePresentationDuringIssuance } = authorizationCodeFlowConfig;
|
|
467
|
-
let authorizationServerUrl = authorizationCodeFlowConfig.authorizationServerUrl;
|
|
468
|
-
if (requirePresentationDuringIssuance) {
|
|
469
|
-
if (authorizationServerUrl && authorizationServerUrl !== issuerMetadata.credentialIssuer.credential_issuer) {
|
|
470
|
-
throw new core_1.CredoError(`When 'requirePresentationDuringIssuance' is set, 'authorizationServerUrl' must be undefined or match the credential issuer identifier`);
|
|
471
|
-
}
|
|
472
|
-
authorizationServerUrl = issuerMetadata.credentialIssuer.credential_issuer;
|
|
473
|
-
}
|
|
474
|
-
grants.authorization_code = {
|
|
475
|
-
issuer_state:
|
|
476
|
-
// TODO: the issuer_state should not be guessable, so it's best if we generate it and now allow the user to provide it?
|
|
477
|
-
// but same is true for the pre-auth code and users of credo can also provide that value. We can't easily do unique constraint with askat
|
|
478
|
-
(_a = authorizationCodeFlowConfig.issuerState) !== null && _a !== void 0 ? _a : core_1.TypedArrayEncoder.toBase64URL(agentContext.wallet.getRandomValues(32)),
|
|
479
|
-
authorization_server: config.issuerMetadata.credentialIssuer.authorization_servers
|
|
480
|
-
? authorizationServerUrl
|
|
481
|
-
: undefined,
|
|
482
|
-
};
|
|
483
|
-
}
|
|
484
|
-
return grants;
|
|
485
|
-
}
|
|
486
|
-
async getHolderBindingFromRequestProofs(agentContext, proofSigners) {
|
|
487
|
-
const credentialHolderBindings = [];
|
|
488
|
-
for (const signer of proofSigners) {
|
|
489
|
-
if (signer.method === 'custom' || signer.method === 'x5c') {
|
|
490
|
-
throw new core_1.CredoError(`Only 'jwk' and 'did' based holder binding is supported`);
|
|
491
|
-
}
|
|
492
|
-
if (signer.method === 'jwk') {
|
|
493
|
-
const jwk = (0, core_1.getJwkFromJson)(signer.publicJwk);
|
|
494
|
-
credentialHolderBindings.push({
|
|
495
|
-
method: 'jwk',
|
|
496
|
-
jwk,
|
|
497
|
-
key: jwk.key,
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
if (signer.method === 'did') {
|
|
501
|
-
const key = await (0, utils_1.getKeyFromDid)(agentContext, signer.didUrl);
|
|
502
|
-
credentialHolderBindings.push({
|
|
503
|
-
method: 'did',
|
|
504
|
-
didUrl: signer.didUrl,
|
|
505
|
-
key,
|
|
506
|
-
});
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
return credentialHolderBindings;
|
|
510
|
-
}
|
|
511
|
-
getCredentialConfigurationsForRequest(options) {
|
|
512
|
-
var _a, _b;
|
|
513
|
-
const { requestFormat, issuanceSession, issuerMetadata, authorization } = options;
|
|
514
|
-
// Check against all credential configurations
|
|
515
|
-
const configurationsMatchingRequest = (0, oid4vci_1.getCredentialConfigurationsMatchingRequestFormat)({
|
|
516
|
-
requestFormat,
|
|
517
|
-
credentialConfigurations: issuerMetadata.credentialIssuer.credential_configurations_supported,
|
|
518
|
-
});
|
|
519
|
-
if (Object.keys(configurationsMatchingRequest).length === 0) {
|
|
520
|
-
throw new oauth2_1.Oauth2ServerErrorResponseError({
|
|
521
|
-
error: oauth2_1.Oauth2ErrorCodes.InvalidCredentialRequest,
|
|
522
|
-
error_description: 'Credential request does not match any credential configuration',
|
|
523
|
-
});
|
|
524
|
-
}
|
|
525
|
-
// Limit to offered configurations
|
|
526
|
-
const configurationsMatchingRequestAndOffer = (0, issuerMetadataUtils_1.getOfferedCredentials)(issuanceSession.credentialOfferPayload.credential_configuration_ids, configurationsMatchingRequest, { ignoreNotFoundIds: true });
|
|
527
|
-
if (Object.keys(configurationsMatchingRequestAndOffer).length === 0) {
|
|
528
|
-
throw new oauth2_1.Oauth2ServerErrorResponseError({
|
|
529
|
-
error: oauth2_1.Oauth2ErrorCodes.InvalidCredentialRequest,
|
|
530
|
-
error_description: 'Credential request does not match any credential configurations from credential offer',
|
|
531
|
-
});
|
|
532
|
-
}
|
|
533
|
-
// Limit to not-issued configurations
|
|
534
|
-
const configurationsMatchingRequestAndOfferNotIssued = (0, issuerMetadataUtils_1.getOfferedCredentials)(issuanceSession.credentialOfferPayload.credential_configuration_ids.filter((id) => !issuanceSession.issuedCredentials.includes(id)), configurationsMatchingRequestAndOffer, { ignoreNotFoundIds: true });
|
|
535
|
-
if (Object.keys(configurationsMatchingRequestAndOfferNotIssued).length === 0) {
|
|
536
|
-
throw new oauth2_1.Oauth2ServerErrorResponseError({
|
|
537
|
-
error: oauth2_1.Oauth2ErrorCodes.InvalidCredentialRequest,
|
|
538
|
-
error_description: 'Credential request does not match any credential configurations from credential offer that have not been issued yet',
|
|
539
|
-
});
|
|
540
|
-
}
|
|
541
|
-
// For pre-auth we allow all ids from the offer
|
|
542
|
-
if (authorization.accessToken.payload['pre-authorized_code']) {
|
|
543
|
-
return {
|
|
544
|
-
credentialConfigurations: configurationsMatchingRequestAndOfferNotIssued,
|
|
545
|
-
credentialConfigurationIds: Object.keys(configurationsMatchingRequestAndOfferNotIssued),
|
|
546
|
-
};
|
|
547
|
-
}
|
|
548
|
-
// Limit to scopes from the token
|
|
549
|
-
// We only do this for auth flow, so it's not required to add a scope for every configuration.
|
|
550
|
-
const configurationsMatchingRequestOfferScope = (0, issuerMetadataUtils_1.getCredentialConfigurationsSupportedForScopes)(configurationsMatchingRequestAndOfferNotIssued, (_b = (_a = authorization.accessToken.payload.scope) === null || _a === void 0 ? void 0 : _a.split(' ')) !== null && _b !== void 0 ? _b : []);
|
|
551
|
-
if (Object.keys(configurationsMatchingRequestOfferScope).length === 0) {
|
|
552
|
-
throw new oauth2_1.Oauth2ServerErrorResponseError({
|
|
553
|
-
error: oauth2_1.Oauth2ErrorCodes.InsufficientScope,
|
|
554
|
-
error_description: 'Scope does not grant issuance for any requested credential configurations from credential offer',
|
|
555
|
-
}, {
|
|
556
|
-
status: 403,
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
return {
|
|
560
|
-
credentialConfigurations: configurationsMatchingRequestOfferScope,
|
|
561
|
-
credentialConfigurationIds: Object.keys(configurationsMatchingRequestOfferScope),
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
async getSignedCredentials(agentContext, options) {
|
|
565
|
-
var _a, _b;
|
|
566
|
-
const { issuanceSession, issuer, requestFormat, authorization } = options;
|
|
567
|
-
const issuerMetadata = await this.getIssuerMetadata(agentContext, issuer);
|
|
568
|
-
const { credentialConfigurations, credentialConfigurationIds } = this.getCredentialConfigurationsForRequest({
|
|
569
|
-
issuanceSession,
|
|
570
|
-
issuerMetadata,
|
|
571
|
-
requestFormat,
|
|
572
|
-
authorization,
|
|
573
|
-
});
|
|
574
|
-
const mapper = (_a = options.credentialRequestToCredentialMapper) !== null && _a !== void 0 ? _a : this.openId4VcIssuerConfig.credentialRequestToCredentialMapper;
|
|
575
|
-
let verification = undefined;
|
|
576
|
-
// NOTE: this will throw an error if the verifier module is not registered and there is a
|
|
577
|
-
// verification session. But you can't get here without the verifier module anyway
|
|
578
|
-
if ((_b = issuanceSession.presentation) === null || _b === void 0 ? void 0 : _b.openId4VcVerificationSessionId) {
|
|
579
|
-
const verifierApi = agentContext.dependencyManager.resolve(openid4vc_verifier_1.OpenId4VcVerifierApi);
|
|
580
|
-
const session = await verifierApi.getVerificationSessionById(issuanceSession.presentation.openId4VcVerificationSessionId);
|
|
581
|
-
const response = await verifierApi.getVerifiedAuthorizationResponse(issuanceSession.presentation.openId4VcVerificationSessionId);
|
|
582
|
-
if (!response.presentationExchange) {
|
|
583
|
-
throw new core_1.CredoError(`Verified authorization response for verification session with id '${session.id}' does not have presenationExchange defined.`);
|
|
584
|
-
}
|
|
585
|
-
verification = {
|
|
586
|
-
session,
|
|
587
|
-
presentationExchange: response.presentationExchange,
|
|
588
|
-
};
|
|
589
|
-
}
|
|
590
|
-
const holderBindings = await this.getHolderBindingFromRequestProofs(agentContext, options.proofSigners);
|
|
591
|
-
const signOptions = await mapper({
|
|
592
|
-
agentContext,
|
|
593
|
-
issuanceSession,
|
|
594
|
-
holderBindings,
|
|
595
|
-
credentialOffer: issuanceSession.credentialOfferPayload,
|
|
596
|
-
verification,
|
|
597
|
-
credentialRequest: options.credentialRequest,
|
|
598
|
-
credentialRequestFormat: options.requestFormat,
|
|
599
|
-
// Macthing credential configuration ids
|
|
600
|
-
credentialConfigurationsSupported: credentialConfigurations,
|
|
601
|
-
credentialConfigurationIds,
|
|
602
|
-
// Authorization
|
|
603
|
-
authorization: options.authorization,
|
|
604
|
-
});
|
|
605
|
-
if (!credentialConfigurationIds.includes(signOptions.credentialConfigurationId)) {
|
|
606
|
-
throw new core_1.CredoError(`Credential request to credential mapper returned credential configuration id '${signOptions.credentialConfigurationId}' but is not part of provided input credential configuration ids. Allowed values are '${credentialConfigurationIds.join(', ')}'.`);
|
|
607
|
-
}
|
|
608
|
-
// NOTE: we may want to allow a mismatch between this (as with new attestations not every key
|
|
609
|
-
// needs a separate proof), but for now it needs to match
|
|
610
|
-
if (signOptions.credentials.length !== holderBindings.length) {
|
|
611
|
-
throw new core_1.CredoError(`Credential request to credential mapper returned '${signOptions.credentials.length}' to be signed, while only '${holderBindings.length}' holder binding entries were provided. Make sure to return one credential for each holder binding entry`);
|
|
612
|
-
}
|
|
613
|
-
if (signOptions.format === core_1.ClaimFormat.JwtVc || signOptions.format === core_1.ClaimFormat.LdpVc) {
|
|
614
|
-
const oid4vciFormatMap = {
|
|
615
|
-
[shared_1.OpenId4VciCredentialFormatProfile.JwtVcJson]: core_1.ClaimFormat.JwtVc,
|
|
616
|
-
[shared_1.OpenId4VciCredentialFormatProfile.JwtVcJsonLd]: core_1.ClaimFormat.JwtVc,
|
|
617
|
-
[shared_1.OpenId4VciCredentialFormatProfile.LdpVc]: core_1.ClaimFormat.LdpVc,
|
|
618
|
-
};
|
|
619
|
-
const expectedClaimFormat = oid4vciFormatMap[options.requestFormat.format];
|
|
620
|
-
if (signOptions.format !== expectedClaimFormat) {
|
|
621
|
-
throw new core_1.CredoError(`Invalid credential format returned by sign options. Expected '${expectedClaimFormat}', received '${signOptions.format}'.`);
|
|
622
|
-
}
|
|
623
|
-
return {
|
|
624
|
-
credentialConfigurationId: signOptions.credentialConfigurationId,
|
|
625
|
-
format: requestFormat.format,
|
|
626
|
-
credentials: (await Promise.all(signOptions.credentials.map((credential) => this.signW3cCredential(agentContext, signOptions.format, credential).then((signed) => signed.encoded)))),
|
|
627
|
-
};
|
|
628
|
-
}
|
|
629
|
-
else if (signOptions.format === core_1.ClaimFormat.SdJwtVc) {
|
|
630
|
-
if (signOptions.format !== requestFormat.format) {
|
|
631
|
-
throw new core_1.CredoError(`Invalid credential format returned by sign options. Expected '${requestFormat.format}', received '${signOptions.format}'.`);
|
|
632
|
-
}
|
|
633
|
-
if (!signOptions.credentials.every((c) => c.payload.vct === requestFormat.vct)) {
|
|
634
|
-
throw new core_1.CredoError(`One or more vct values of the offered credential(s) do not match the vct of the requested credential. Offered ${Array.from(new Set(signOptions.credentials.map((c) => `'${c.payload.vct}'`))).join(', ')} Requested '${requestFormat.vct}'.`);
|
|
635
|
-
}
|
|
636
|
-
const sdJwtVcApi = agentContext.dependencyManager.resolve(core_1.SdJwtVcApi);
|
|
637
|
-
return {
|
|
638
|
-
credentialConfigurationId: signOptions.credentialConfigurationId,
|
|
639
|
-
format: shared_1.OpenId4VciCredentialFormatProfile.SdJwtVc,
|
|
640
|
-
credentials: await Promise.all(signOptions.credentials.map((credential) => sdJwtVcApi.sign(credential).then((signed) => signed.compact))),
|
|
641
|
-
};
|
|
642
|
-
}
|
|
643
|
-
else if (signOptions.format === core_1.ClaimFormat.MsoMdoc) {
|
|
644
|
-
if (signOptions.format !== requestFormat.format) {
|
|
645
|
-
throw new core_1.CredoError(`Invalid credential format returned by sign options. Expected '${requestFormat.format}', received '${signOptions.format}'.`);
|
|
646
|
-
}
|
|
647
|
-
if (!signOptions.credentials.every((c) => c.docType === requestFormat.doctype)) {
|
|
648
|
-
throw new core_1.CredoError(`One or more doctype values of the offered credential(s) do not match the doctype of the requested credential. Offered ${Array.from(new Set(signOptions.credentials.map((c) => `'${c.docType}'`))).join(', ')} Requested '${requestFormat.doctype}'.`);
|
|
649
|
-
}
|
|
650
|
-
const mdocApi = agentContext.dependencyManager.resolve(core_1.MdocApi);
|
|
651
|
-
return {
|
|
652
|
-
credentialConfigurationId: signOptions.credentialConfigurationId,
|
|
653
|
-
format: shared_1.OpenId4VciCredentialFormatProfile.MsoMdoc,
|
|
654
|
-
credentials: await Promise.all(signOptions.credentials.map((credential) => mdocApi.sign(credential).then((signed) => signed.base64Url))),
|
|
655
|
-
};
|
|
656
|
-
}
|
|
657
|
-
else {
|
|
658
|
-
throw new core_1.CredoError(`Unsupported credential format ${signOptions.format}`);
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
async signW3cCredential(agentContext, format, options) {
|
|
662
|
-
const key = await (0, utils_1.getKeyFromDid)(agentContext, options.verificationMethod);
|
|
663
|
-
if (format === core_1.ClaimFormat.JwtVc) {
|
|
664
|
-
const supportedSignatureAlgorithms = (0, core_1.getJwkFromKey)(key).supportedSignatureAlgorithms;
|
|
665
|
-
if (supportedSignatureAlgorithms.length === 0) {
|
|
666
|
-
throw new core_1.CredoError(`No supported JWA signature algorithms found for key with keyType ${key.keyType}`);
|
|
667
|
-
}
|
|
668
|
-
const alg = supportedSignatureAlgorithms[0];
|
|
669
|
-
if (!alg) {
|
|
670
|
-
throw new core_1.CredoError(`No supported JWA signature algorithms for key type ${key.keyType}`);
|
|
671
|
-
}
|
|
672
|
-
return await this.w3cCredentialService.signCredential(agentContext, {
|
|
673
|
-
format: core_1.ClaimFormat.JwtVc,
|
|
674
|
-
credential: options.credential,
|
|
675
|
-
verificationMethod: options.verificationMethod,
|
|
676
|
-
alg,
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
else {
|
|
680
|
-
const proofType = (0, utils_1.getProofTypeFromKey)(agentContext, key);
|
|
681
|
-
return await this.w3cCredentialService.signCredential(agentContext, {
|
|
682
|
-
format: core_1.ClaimFormat.LdpVc,
|
|
683
|
-
credential: options.credential,
|
|
684
|
-
verificationMethod: options.verificationMethod,
|
|
685
|
-
proofType: proofType,
|
|
686
|
-
});
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
};
|
|
690
|
-
exports.OpenId4VcIssuerService = OpenId4VcIssuerService;
|
|
691
|
-
exports.OpenId4VcIssuerService = OpenId4VcIssuerService = __decorate([
|
|
692
|
-
(0, core_1.injectable)(),
|
|
693
|
-
__metadata("design:paramtypes", [core_1.W3cCredentialService,
|
|
694
|
-
OpenId4VcIssuerModuleConfig_1.OpenId4VcIssuerModuleConfig,
|
|
695
|
-
repository_1.OpenId4VcIssuerRepository,
|
|
696
|
-
repository_1.OpenId4VcIssuanceSessionRepository])
|
|
697
|
-
], OpenId4VcIssuerService);
|
|
698
|
-
//# sourceMappingURL=OpenId4VcIssuerService.js.map
|