@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
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { getPublicJwkFromDid } from "./utils.mjs";
|
|
2
|
+
import { AgentContext, Buffer, CredoError, Hasher, JsonEncoder, JwsService, JwtPayload, Kms, TypedArrayEncoder, X509Certificate, X509ModuleConfig, X509Service } from "@credo-ts/core";
|
|
3
|
+
import { clientAuthenticationDynamic, decodeJwtHeader } from "@openid4vc/oauth2";
|
|
4
|
+
|
|
5
|
+
//#region src/shared/callbacks.ts
|
|
6
|
+
function getOid4vcJwtVerifyCallback(agentContext, options) {
|
|
7
|
+
const jwsService = agentContext.dependencyManager.resolve(JwsService);
|
|
8
|
+
return async (signer, { compact, header, payload }) => {
|
|
9
|
+
let trustedCertificates = options?.trustedCertificates;
|
|
10
|
+
if (signer.method === "x5c" && (header.typ === "oauth-authz-req+jwt" || options?.isAuthorizationRequestJwt) && !trustedCertificates) {
|
|
11
|
+
const x509Config = agentContext.dependencyManager.resolve(X509ModuleConfig);
|
|
12
|
+
const certificateChain = signer.x5c?.map((cert) => X509Certificate.fromEncodedCertificate(cert));
|
|
13
|
+
trustedCertificates = await x509Config.getTrustedCertificatesForVerification?.(agentContext, {
|
|
14
|
+
certificateChain,
|
|
15
|
+
verification: {
|
|
16
|
+
type: "oauth2SecuredAuthorizationRequest",
|
|
17
|
+
authorizationRequest: {
|
|
18
|
+
jwt: compact,
|
|
19
|
+
payload: JwtPayload.fromJson(payload)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (signer.method === "x5c" && (header.typ === "keyattestation+jwt" || header.typ === "key-attestation+jwt") && options?.issuanceSessionId && !trustedCertificates) {
|
|
25
|
+
const x509Config = agentContext.dependencyManager.resolve(X509ModuleConfig);
|
|
26
|
+
const certificateChain = signer.x5c?.map((cert) => X509Certificate.fromEncodedCertificate(cert));
|
|
27
|
+
trustedCertificates = await x509Config.getTrustedCertificatesForVerification?.(agentContext, {
|
|
28
|
+
certificateChain,
|
|
29
|
+
verification: {
|
|
30
|
+
type: "openId4VciKeyAttestation",
|
|
31
|
+
openId4VcIssuanceSessionId: options.issuanceSessionId,
|
|
32
|
+
keyAttestation: {
|
|
33
|
+
jwt: compact,
|
|
34
|
+
payload: JwtPayload.fromJson(payload)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (signer.method === "x5c" && header.typ === "openidvci-issuer-metadata+jwt" && !trustedCertificates) {
|
|
40
|
+
const x509Config = agentContext.dependencyManager.resolve(X509ModuleConfig);
|
|
41
|
+
const certificateChain = signer.x5c?.map((cert) => X509Certificate.fromEncodedCertificate(cert));
|
|
42
|
+
trustedCertificates = await x509Config.getTrustedCertificatesForVerification?.(agentContext, {
|
|
43
|
+
certificateChain,
|
|
44
|
+
verification: {
|
|
45
|
+
type: "openId4VciCredentialIssuerMetadata",
|
|
46
|
+
credentialIssuerMetadata: {
|
|
47
|
+
jwt: compact,
|
|
48
|
+
payload: JwtPayload.fromJson(payload)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (signer.method === "x5c" && header.typ === "oauth-client-attestation+jwt" && options?.issuanceSessionId && !trustedCertificates) {
|
|
54
|
+
const x509Config = agentContext.dependencyManager.resolve(X509ModuleConfig);
|
|
55
|
+
const certificateChain = signer.x5c?.map((cert) => X509Certificate.fromEncodedCertificate(cert));
|
|
56
|
+
trustedCertificates = await x509Config.getTrustedCertificatesForVerification?.(agentContext, {
|
|
57
|
+
certificateChain,
|
|
58
|
+
verification: {
|
|
59
|
+
type: "oauth2ClientAttestation",
|
|
60
|
+
openId4VcIssuanceSessionId: options.issuanceSessionId,
|
|
61
|
+
clientAttestation: {
|
|
62
|
+
jwt: compact,
|
|
63
|
+
payload: JwtPayload.fromJson(payload)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const alg = signer.alg;
|
|
69
|
+
if (!Object.values(Kms.KnownJwaSignatureAlgorithms).includes(alg)) throw new CredoError(`Unsupported jwa signatre algorithm '${alg}'`);
|
|
70
|
+
const jwsSigner = signer.method === "did" ? {
|
|
71
|
+
method: "did",
|
|
72
|
+
didUrl: signer.didUrl,
|
|
73
|
+
jwk: await getPublicJwkFromDid(agentContext, signer.didUrl)
|
|
74
|
+
} : signer.method === "jwk" ? {
|
|
75
|
+
method: "jwk",
|
|
76
|
+
jwk: Kms.PublicJwk.fromUnknown(signer.publicJwk)
|
|
77
|
+
} : signer.method === "x5c" ? {
|
|
78
|
+
method: "x5c",
|
|
79
|
+
x5c: signer.x5c,
|
|
80
|
+
jwk: X509Certificate.fromEncodedCertificate(signer.x5c[0]).publicJwk
|
|
81
|
+
} : void 0;
|
|
82
|
+
if (!jwsSigner) throw new CredoError(`Unable to verify jws with unsupported jws signer method '${signer.method}'`);
|
|
83
|
+
const { isValid, jwsSigners } = await jwsService.verifyJws(agentContext, {
|
|
84
|
+
jws: compact,
|
|
85
|
+
trustedCertificates,
|
|
86
|
+
jwsSigner
|
|
87
|
+
});
|
|
88
|
+
if (!isValid) return {
|
|
89
|
+
verified: false,
|
|
90
|
+
signerJwk: void 0
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
verified: true,
|
|
94
|
+
signerJwk: jwsSigners[0].jwk.toJson()
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function getOid4vcEncryptJweCallback(agentContext) {
|
|
99
|
+
const kms = agentContext.dependencyManager.resolve(Kms.KeyManagementApi);
|
|
100
|
+
return async (jweEncryptor, compact) => {
|
|
101
|
+
if (jweEncryptor.method !== "jwk") throw new CredoError(`Jwt encryption method '${jweEncryptor.method}' is not supported for jwt signer. Only 'jwk' is supported.`);
|
|
102
|
+
const jwk = Kms.PublicJwk.fromUnknown(jweEncryptor.publicJwk);
|
|
103
|
+
if (!jwk.hasKeyId) throw new CredoError("Expected kid to be defined on the JWK");
|
|
104
|
+
if (jweEncryptor.alg !== "ECDH-ES") throw new CredoError("Only 'ECDH-ES' is supported as 'alg' value for JARM response encryption");
|
|
105
|
+
if (jweEncryptor.enc !== "A256GCM" && jweEncryptor.enc !== "A128GCM" && jweEncryptor.enc !== "A128CBC-HS256") throw new CredoError("Only 'A256GCM', 'A128GCM', and 'A128CBC-HS256' is supported as 'enc' value for JARM response encryption");
|
|
106
|
+
const jwkJson = jwk.toJson();
|
|
107
|
+
if (jwkJson.kty !== "EC" && jwkJson.kty !== "OKP") throw new CredoError(`Expected EC or OKP jwk for encryption, found ${Kms.getJwkHumanDescription(jwkJson)}`);
|
|
108
|
+
if (jwkJson.crv === "Ed25519") throw new CredoError(`Expected ${jwkJson.kty} with crv X25519, found ${Kms.getJwkHumanDescription(jwkJson)}`);
|
|
109
|
+
const ephmeralKey = await kms.createKey({ type: jwkJson });
|
|
110
|
+
try {
|
|
111
|
+
const header = {
|
|
112
|
+
kid: jweEncryptor.publicJwk.kid,
|
|
113
|
+
apu: jweEncryptor.apu,
|
|
114
|
+
apv: jweEncryptor.apv,
|
|
115
|
+
enc: jweEncryptor.enc,
|
|
116
|
+
alg: "ECDH-ES",
|
|
117
|
+
epk: ephmeralKey.publicJwk
|
|
118
|
+
};
|
|
119
|
+
const encodedHeader = JsonEncoder.toBase64URL(header);
|
|
120
|
+
const encrypted = await kms.encrypt({
|
|
121
|
+
key: { keyAgreement: {
|
|
122
|
+
keyId: ephmeralKey.keyId,
|
|
123
|
+
algorithm: "ECDH-ES",
|
|
124
|
+
apu: jweEncryptor.apu ? TypedArrayEncoder.fromBase64(jweEncryptor.apu) : void 0,
|
|
125
|
+
apv: jweEncryptor.apv ? TypedArrayEncoder.fromBase64(jweEncryptor.apv) : void 0,
|
|
126
|
+
externalPublicJwk: jwkJson
|
|
127
|
+
} },
|
|
128
|
+
data: Buffer.from(compact),
|
|
129
|
+
encryption: {
|
|
130
|
+
algorithm: jweEncryptor.enc,
|
|
131
|
+
aad: Buffer.from(encodedHeader)
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
if (!encrypted.iv || !encrypted.tag) throw new CredoError("Expected 'iv' and 'tag' to be defined");
|
|
135
|
+
const compactJwe = `${encodedHeader}..${TypedArrayEncoder.toBase64URL(encrypted.iv)}.${TypedArrayEncoder.toBase64URL(encrypted.encrypted)}.${TypedArrayEncoder.toBase64URL(encrypted.tag)}`;
|
|
136
|
+
return {
|
|
137
|
+
encryptionJwk: jweEncryptor.publicJwk,
|
|
138
|
+
jwe: compactJwe
|
|
139
|
+
};
|
|
140
|
+
} finally {
|
|
141
|
+
await kms.deleteKey({ keyId: ephmeralKey.keyId });
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function getOid4vcDecryptJweCallback(agentContext) {
|
|
146
|
+
const kms = agentContext.resolve(Kms.KeyManagementApi);
|
|
147
|
+
return async (jwe, options) => {
|
|
148
|
+
const { header } = decodeJwtHeader({ jwt: jwe });
|
|
149
|
+
let kid = options?.jwk?.kid ?? header.kid;
|
|
150
|
+
if (!kid) throw new CredoError("Uanbel to decrypt jwe. No kid or jwk found");
|
|
151
|
+
if (kid.startsWith("z")) try {
|
|
152
|
+
const publicJwk$1 = Kms.PublicJwk.fromFingerprint(kid);
|
|
153
|
+
if (publicJwk$1) kid = publicJwk$1.legacyKeyId;
|
|
154
|
+
} catch {}
|
|
155
|
+
const [encodedHeader, , encodedIv, encodedCiphertext, encodedTag] = jwe.split(".");
|
|
156
|
+
if (header.alg !== "ECDH-ES") throw new CredoError("Only 'ECDH-ES' is supported as 'alg' value for JARM response decryption");
|
|
157
|
+
if (header.enc !== "A256GCM" && header.enc !== "A128GCM" && header.enc !== "A128CBC-HS256") throw new CredoError("Only 'A256GCM', 'A128GCM', and 'A128CBC-HS256' is supported as 'enc' value for JARM response decryption");
|
|
158
|
+
let decryptedPayload;
|
|
159
|
+
let publicJwk;
|
|
160
|
+
const epk = Kms.PublicJwk.fromUnknown(header.epk);
|
|
161
|
+
try {
|
|
162
|
+
const decrypted = await kms.decrypt({
|
|
163
|
+
encrypted: TypedArrayEncoder.fromBase64(encodedCiphertext),
|
|
164
|
+
decryption: {
|
|
165
|
+
algorithm: header.enc,
|
|
166
|
+
aad: TypedArrayEncoder.fromString(encodedHeader),
|
|
167
|
+
iv: TypedArrayEncoder.fromBase64(encodedIv),
|
|
168
|
+
tag: TypedArrayEncoder.fromBase64(encodedTag)
|
|
169
|
+
},
|
|
170
|
+
key: { keyAgreement: {
|
|
171
|
+
algorithm: header.alg,
|
|
172
|
+
externalPublicJwk: epk.toJson(),
|
|
173
|
+
keyId: kid,
|
|
174
|
+
apu: typeof header.apu === "string" ? TypedArrayEncoder.fromBase64(header.apu) : void 0,
|
|
175
|
+
apv: typeof header.apv === "string" ? TypedArrayEncoder.fromBase64(header.apv) : void 0
|
|
176
|
+
} }
|
|
177
|
+
});
|
|
178
|
+
publicJwk = Kms.PublicJwk.fromUnknown(await kms.getPublicKey({ keyId: kid }));
|
|
179
|
+
decryptedPayload = TypedArrayEncoder.toUtf8String(decrypted.data);
|
|
180
|
+
} catch (error) {
|
|
181
|
+
agentContext.config.logger.error("Error decrypting JWE", { error });
|
|
182
|
+
return {
|
|
183
|
+
decrypted: false,
|
|
184
|
+
encryptionJwk: options?.jwk,
|
|
185
|
+
payload: void 0,
|
|
186
|
+
header
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
decrypted: true,
|
|
191
|
+
decryptionJwk: publicJwk.toJson(),
|
|
192
|
+
payload: decryptedPayload,
|
|
193
|
+
header
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function getOid4vcJwtSignCallback(agentContext) {
|
|
198
|
+
const jwsService = agentContext.dependencyManager.resolve(JwsService);
|
|
199
|
+
return async (signer, { payload, header }) => {
|
|
200
|
+
if (signer.method === "custom" || signer.method === "federation") throw new CredoError(`Jwt signer method 'custom' and 'federation' are not supported for jwt signer.`);
|
|
201
|
+
if (signer.method === "x5c") {
|
|
202
|
+
const leafCertificate = X509Service.getLeafCertificate(agentContext, { certificateChain: signer.x5c });
|
|
203
|
+
return {
|
|
204
|
+
jwt: await jwsService.createJwsCompact(agentContext, {
|
|
205
|
+
protectedHeaderOptions: {
|
|
206
|
+
...header,
|
|
207
|
+
alg: signer.alg,
|
|
208
|
+
jwk: void 0
|
|
209
|
+
},
|
|
210
|
+
payload: JwtPayload.fromJson(payload),
|
|
211
|
+
keyId: signer.kid ?? leafCertificate.publicJwk.keyId
|
|
212
|
+
}),
|
|
213
|
+
signerJwk: leafCertificate.publicJwk.toJson()
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
const publicJwk = signer.method === "did" ? await getPublicJwkFromDid(agentContext, signer.didUrl) : Kms.PublicJwk.fromUnknown(signer.publicJwk);
|
|
217
|
+
if (!publicJwk.supportedSignatureAlgorithms.includes(signer.alg)) throw new CredoError(`jwk ${publicJwk.jwkTypeHumanDescription} does not support JWS signature alg '${signer.alg}'`);
|
|
218
|
+
return {
|
|
219
|
+
jwt: await jwsService.createJwsCompact(agentContext, {
|
|
220
|
+
protectedHeaderOptions: {
|
|
221
|
+
...header,
|
|
222
|
+
jwk: header.jwk ? publicJwk : void 0,
|
|
223
|
+
alg: signer.alg
|
|
224
|
+
},
|
|
225
|
+
payload: JsonEncoder.toBuffer(payload),
|
|
226
|
+
keyId: signer.kid ?? publicJwk.keyId
|
|
227
|
+
}),
|
|
228
|
+
signerJwk: publicJwk.toJson()
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function getOid4vcCallbacks(agentContext, options) {
|
|
233
|
+
const kms = agentContext.resolve(Kms.KeyManagementApi);
|
|
234
|
+
return {
|
|
235
|
+
hash: (data, alg) => Hasher.hash(data, alg.toLowerCase()),
|
|
236
|
+
generateRandom: (length) => kms.randomBytes({ length }),
|
|
237
|
+
signJwt: getOid4vcJwtSignCallback(agentContext),
|
|
238
|
+
clientAuthentication: () => {
|
|
239
|
+
throw new CredoError("Did not expect client authentication to be called.");
|
|
240
|
+
},
|
|
241
|
+
verifyJwt: getOid4vcJwtVerifyCallback(agentContext, {
|
|
242
|
+
trustedCertificates: options?.trustedCertificates,
|
|
243
|
+
isAuthorizationRequestJwt: options?.isVerifyOpenId4VpAuthorizationRequest,
|
|
244
|
+
issuanceSessionId: options?.issuanceSessionId
|
|
245
|
+
}),
|
|
246
|
+
fetch: agentContext.config.agentDependencies.fetch,
|
|
247
|
+
encryptJwe: getOid4vcEncryptJweCallback(agentContext),
|
|
248
|
+
decryptJwe: getOid4vcDecryptJweCallback(agentContext),
|
|
249
|
+
getX509CertificateMetadata: (certificate) => {
|
|
250
|
+
const leafCertificate = X509Service.getLeafCertificate(agentContext, { certificateChain: [certificate] });
|
|
251
|
+
return {
|
|
252
|
+
sanDnsNames: leafCertificate.sanDnsNames,
|
|
253
|
+
sanUriNames: leafCertificate.sanUriNames
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Allows us to authenticate when making requests to an external
|
|
260
|
+
* authorization server
|
|
261
|
+
*/
|
|
262
|
+
function dynamicOid4vciClientAuthentication(agentContext, issuerRecord) {
|
|
263
|
+
return (callbackOptions) => {
|
|
264
|
+
const authorizationServer = issuerRecord.authorizationServerConfigs?.find((a) => a.issuer === callbackOptions.authorizationServerMetadata.issuer);
|
|
265
|
+
if (!authorizationServer) {
|
|
266
|
+
agentContext.config.logger.debug(`Unknown authorization server '${callbackOptions.authorizationServerMetadata.issuer}' for issuer '${issuerRecord.issuerId}' for request to '${callbackOptions.url}'`);
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (!authorizationServer.clientAuthentication) throw new CredoError(`Unable to authenticate to authorization server '${authorizationServer.issuer}' for issuer '${issuerRecord.issuerId}' for request to '${callbackOptions.url}'. Make sure to configure a 'clientId' and 'clientSecret' for the authorization server on the issuer record.`);
|
|
270
|
+
return clientAuthenticationDynamic({
|
|
271
|
+
clientId: authorizationServer.clientAuthentication.clientId,
|
|
272
|
+
clientSecret: authorizationServer.clientAuthentication.clientSecret
|
|
273
|
+
})(callbackOptions);
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
//#endregion
|
|
278
|
+
export { dynamicOid4vciClientAuthentication, getOid4vcCallbacks, getOid4vcDecryptJweCallback, getOid4vcEncryptJweCallback, getOid4vcJwtSignCallback, getOid4vcJwtVerifyCallback };
|
|
279
|
+
//# sourceMappingURL=callbacks.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callbacks.mjs","names":["jwsSigner: JwsSignerWithJwk | undefined","publicJwk","decryptedPayload: string","publicJwk: Kms.PublicJwk"],"sources":["../../src/shared/callbacks.ts"],"sourcesContent":["import {\n AgentContext,\n Buffer,\n CredoError,\n Hasher,\n JsonEncoder,\n JwsService,\n type JwsSignerWithJwk,\n JwtPayload,\n Kms,\n TypedArrayEncoder,\n X509Certificate,\n X509ModuleConfig,\n X509Service,\n} from '@credo-ts/core'\nimport type {\n CallbackContext,\n ClientAuthenticationCallback,\n DecryptJweCallback,\n EncryptJweCallback,\n Jwk,\n SignJwtCallback,\n VerifyJwtCallback,\n} from '@openid4vc/oauth2'\nimport { clientAuthenticationDynamic, decodeJwtHeader } from '@openid4vc/oauth2'\nimport type { OpenId4VcIssuerRecord } from '../openid4vc-issuer/repository'\n\nimport { getPublicJwkFromDid } from './utils'\n\nexport function getOid4vcJwtVerifyCallback(\n agentContext: AgentContext,\n options?: {\n trustedCertificates?: string[]\n\n issuanceSessionId?: string\n\n /**\n * Whether this verification callback should assume a JAR authorization is verified\n * Starting from OID4VP draft 24 the JAR must use oauth-authz-req+jwt header typ\n * but for backwards compatiblity we need to also handle the case where the header typ is different\n * @default false\n */\n isAuthorizationRequestJwt?: boolean\n }\n): VerifyJwtCallback {\n const jwsService = agentContext.dependencyManager.resolve(JwsService)\n\n return async (signer, { compact, header, payload }) => {\n let trustedCertificates = options?.trustedCertificates\n if (\n signer.method === 'x5c' &&\n (header.typ === 'oauth-authz-req+jwt' || options?.isAuthorizationRequestJwt) &&\n !trustedCertificates\n ) {\n const x509Config = agentContext.dependencyManager.resolve(X509ModuleConfig)\n const certificateChain = signer.x5c?.map((cert) => X509Certificate.fromEncodedCertificate(cert))\n\n trustedCertificates = await x509Config.getTrustedCertificatesForVerification?.(agentContext, {\n certificateChain,\n verification: {\n type: 'oauth2SecuredAuthorizationRequest',\n authorizationRequest: {\n jwt: compact,\n payload: JwtPayload.fromJson(payload),\n },\n },\n })\n }\n\n if (\n signer.method === 'x5c' &&\n (header.typ === 'keyattestation+jwt' || header.typ === 'key-attestation+jwt') &&\n options?.issuanceSessionId &&\n !trustedCertificates\n ) {\n const x509Config = agentContext.dependencyManager.resolve(X509ModuleConfig)\n const certificateChain = signer.x5c?.map((cert) => X509Certificate.fromEncodedCertificate(cert))\n\n trustedCertificates = await x509Config.getTrustedCertificatesForVerification?.(agentContext, {\n certificateChain,\n verification: {\n type: 'openId4VciKeyAttestation',\n openId4VcIssuanceSessionId: options.issuanceSessionId,\n keyAttestation: {\n jwt: compact,\n payload: JwtPayload.fromJson(payload),\n },\n },\n })\n }\n\n if (signer.method === 'x5c' && header.typ === 'openidvci-issuer-metadata+jwt' && !trustedCertificates) {\n const x509Config = agentContext.dependencyManager.resolve(X509ModuleConfig)\n const certificateChain = signer.x5c?.map((cert) => X509Certificate.fromEncodedCertificate(cert))\n\n trustedCertificates = await x509Config.getTrustedCertificatesForVerification?.(agentContext, {\n certificateChain,\n verification: {\n type: 'openId4VciCredentialIssuerMetadata',\n credentialIssuerMetadata: {\n jwt: compact,\n payload: JwtPayload.fromJson(payload),\n },\n },\n })\n }\n\n if (\n signer.method === 'x5c' &&\n header.typ === 'oauth-client-attestation+jwt' &&\n options?.issuanceSessionId &&\n !trustedCertificates\n ) {\n const x509Config = agentContext.dependencyManager.resolve(X509ModuleConfig)\n const certificateChain = signer.x5c?.map((cert) => X509Certificate.fromEncodedCertificate(cert))\n\n trustedCertificates = await x509Config.getTrustedCertificatesForVerification?.(agentContext, {\n certificateChain,\n verification: {\n type: 'oauth2ClientAttestation',\n openId4VcIssuanceSessionId: options.issuanceSessionId,\n clientAttestation: {\n jwt: compact,\n payload: JwtPayload.fromJson(payload),\n },\n },\n })\n }\n\n const alg = signer.alg as Kms.KnownJwaSignatureAlgorithm\n if (!Object.values(Kms.KnownJwaSignatureAlgorithms).includes(alg)) {\n throw new CredoError(`Unsupported jwa signatre algorithm '${alg}'`)\n }\n\n const jwsSigner: JwsSignerWithJwk | undefined =\n signer.method === 'did'\n ? {\n method: 'did',\n didUrl: signer.didUrl,\n jwk: await getPublicJwkFromDid(agentContext, signer.didUrl),\n }\n : signer.method === 'jwk'\n ? {\n method: 'jwk',\n jwk: Kms.PublicJwk.fromUnknown(signer.publicJwk),\n }\n : signer.method === 'x5c'\n ? {\n method: 'x5c',\n x5c: signer.x5c,\n jwk: X509Certificate.fromEncodedCertificate(signer.x5c[0]).publicJwk,\n }\n : undefined\n\n if (!jwsSigner) {\n throw new CredoError(`Unable to verify jws with unsupported jws signer method '${signer.method}'`)\n }\n\n const { isValid, jwsSigners } = await jwsService.verifyJws(agentContext, {\n jws: compact,\n trustedCertificates,\n jwsSigner,\n })\n\n if (!isValid) {\n return { verified: false, signerJwk: undefined }\n }\n\n const signerJwk = jwsSigners[0].jwk.toJson() as Jwk\n return { verified: true, signerJwk }\n }\n}\n\nexport function getOid4vcEncryptJweCallback(agentContext: AgentContext): EncryptJweCallback {\n const kms = agentContext.dependencyManager.resolve(Kms.KeyManagementApi)\n\n return async (jweEncryptor, compact) => {\n if (jweEncryptor.method !== 'jwk') {\n throw new CredoError(\n `Jwt encryption method '${jweEncryptor.method}' is not supported for jwt signer. Only 'jwk' is supported.`\n )\n }\n\n // TODO: we should probably add a key id or ference to the jweEncryptor/jwsSigner in\n // oid4vc-ts so we can keep a reference to the key\n const jwk = Kms.PublicJwk.fromUnknown(jweEncryptor.publicJwk)\n if (!jwk.hasKeyId) {\n throw new CredoError('Expected kid to be defined on the JWK')\n }\n\n if (jweEncryptor.alg !== 'ECDH-ES') {\n throw new CredoError(\"Only 'ECDH-ES' is supported as 'alg' value for JARM response encryption\")\n }\n\n if (jweEncryptor.enc !== 'A256GCM' && jweEncryptor.enc !== 'A128GCM' && jweEncryptor.enc !== 'A128CBC-HS256') {\n throw new CredoError(\n \"Only 'A256GCM', 'A128GCM', and 'A128CBC-HS256' is supported as 'enc' value for JARM response encryption\"\n )\n }\n\n const jwkJson = jwk.toJson()\n if (jwkJson.kty !== 'EC' && jwkJson.kty !== 'OKP') {\n throw new CredoError(`Expected EC or OKP jwk for encryption, found ${Kms.getJwkHumanDescription(jwkJson)}`)\n }\n\n if (jwkJson.crv === 'Ed25519') {\n throw new CredoError(`Expected ${jwkJson.kty} with crv X25519, found ${Kms.getJwkHumanDescription(jwkJson)}`)\n }\n\n // TODO: create a JWE service that handles this\n const ephmeralKey = await kms.createKey({\n type: jwkJson,\n })\n\n try {\n const header = {\n kid: jweEncryptor.publicJwk.kid,\n apu: jweEncryptor.apu,\n apv: jweEncryptor.apv,\n enc: jweEncryptor.enc,\n alg: 'ECDH-ES',\n epk: ephmeralKey.publicJwk,\n }\n const encodedHeader = JsonEncoder.toBase64URL(header)\n\n const encrypted = await kms.encrypt({\n key: {\n keyAgreement: {\n // FIXME: We can make the keyId optional for ECDH-ES\n // That way we don't have to store the key\n keyId: ephmeralKey.keyId,\n algorithm: 'ECDH-ES',\n apu: jweEncryptor.apu ? TypedArrayEncoder.fromBase64(jweEncryptor.apu) : undefined,\n apv: jweEncryptor.apv ? TypedArrayEncoder.fromBase64(jweEncryptor.apv) : undefined,\n externalPublicJwk: jwkJson,\n },\n },\n data: Buffer.from(compact),\n encryption: {\n algorithm: jweEncryptor.enc,\n aad: Buffer.from(encodedHeader),\n },\n })\n\n if (!encrypted.iv || !encrypted.tag) {\n throw new CredoError(\"Expected 'iv' and 'tag' to be defined\")\n }\n\n const compactJwe = `${encodedHeader}..${TypedArrayEncoder.toBase64URL(encrypted.iv)}.${TypedArrayEncoder.toBase64URL(\n encrypted.encrypted\n )}.${TypedArrayEncoder.toBase64URL(encrypted.tag)}`\n\n return { encryptionJwk: jweEncryptor.publicJwk, jwe: compactJwe }\n } finally {\n // Delete the key\n await kms.deleteKey({\n keyId: ephmeralKey.keyId,\n })\n }\n }\n}\n\nexport function getOid4vcDecryptJweCallback(agentContext: AgentContext): DecryptJweCallback {\n const kms = agentContext.resolve(Kms.KeyManagementApi)\n return async (jwe, options) => {\n // TODO: use custom header zod schema to limit which algorithms can be used\n const { header } = decodeJwtHeader({ jwt: jwe })\n\n let kid = options?.jwk?.kid ?? header.kid\n if (!kid) {\n throw new CredoError('Uanbel to decrypt jwe. No kid or jwk found')\n }\n\n // Previously we used the fingerprint as the kid for JARM\n // We try to parse it as fingerprint if it starts with z (base58 encoding)\n // It's not 100%\n if (kid.startsWith('z')) {\n try {\n const publicJwk = Kms.PublicJwk.fromFingerprint(kid)\n if (publicJwk) kid = publicJwk.legacyKeyId\n } catch {\n // no-op\n }\n }\n\n // TODO: decodeJwe method in oid4vc-ts\n // encryption key is not used (we don't use key wrapping)\n const [encodedHeader /* encryptionKey */, , encodedIv, encodedCiphertext, encodedTag] = jwe.split('.')\n\n if (header.alg !== 'ECDH-ES') {\n throw new CredoError(\"Only 'ECDH-ES' is supported as 'alg' value for JARM response decryption\")\n }\n\n if (header.enc !== 'A256GCM' && header.enc !== 'A128GCM' && header.enc !== 'A128CBC-HS256') {\n throw new CredoError(\n \"Only 'A256GCM', 'A128GCM', and 'A128CBC-HS256' is supported as 'enc' value for JARM response decryption\"\n )\n }\n\n let decryptedPayload: string\n let publicJwk: Kms.PublicJwk\n\n const epk = Kms.PublicJwk.fromUnknown(header.epk)\n\n try {\n const decrypted = await kms.decrypt({\n encrypted: TypedArrayEncoder.fromBase64(encodedCiphertext),\n decryption: {\n algorithm: header.enc,\n // aad is the base64 encoded bytes (not just the bytes)\n aad: TypedArrayEncoder.fromString(encodedHeader),\n iv: TypedArrayEncoder.fromBase64(encodedIv),\n tag: TypedArrayEncoder.fromBase64(encodedTag),\n },\n key: {\n keyAgreement: {\n algorithm: header.alg,\n externalPublicJwk: epk.toJson() as Kms.KmsJwkPublicEcdh,\n keyId: kid,\n apu: typeof header.apu === 'string' ? TypedArrayEncoder.fromBase64(header.apu) : undefined,\n apv: typeof header.apv === 'string' ? TypedArrayEncoder.fromBase64(header.apv) : undefined,\n },\n },\n })\n\n // TODO: decrypt should return the public jwk instance\n publicJwk = Kms.PublicJwk.fromUnknown(\n await kms.getPublicKey({\n keyId: kid,\n })\n )\n\n decryptedPayload = TypedArrayEncoder.toUtf8String(decrypted.data)\n } catch (error) {\n agentContext.config.logger.error('Error decrypting JWE', {\n error,\n })\n return {\n decrypted: false,\n encryptionJwk: options?.jwk,\n payload: undefined,\n header,\n }\n }\n\n return {\n decrypted: true,\n decryptionJwk: publicJwk.toJson() as Jwk,\n payload: decryptedPayload,\n header,\n }\n }\n}\n\nexport function getOid4vcJwtSignCallback(agentContext: AgentContext): SignJwtCallback {\n const jwsService = agentContext.dependencyManager.resolve(JwsService)\n\n return async (signer, { payload, header }) => {\n if (signer.method === 'custom' || signer.method === 'federation') {\n throw new CredoError(`Jwt signer method 'custom' and 'federation' are not supported for jwt signer.`)\n }\n\n if (signer.method === 'x5c') {\n const leafCertificate = X509Service.getLeafCertificate(agentContext, { certificateChain: signer.x5c })\n\n const jws = await jwsService.createJwsCompact(agentContext, {\n protectedHeaderOptions: { ...header, alg: signer.alg as Kms.KnownJwaSignatureAlgorithm, jwk: undefined },\n payload: JwtPayload.fromJson(payload),\n keyId: signer.kid ?? leafCertificate.publicJwk.keyId,\n })\n\n return { jwt: jws, signerJwk: leafCertificate.publicJwk.toJson() as Jwk }\n }\n\n // TOOD: createJwsCompact should return the Jwk, so we don't have to reoslve it here\n const publicJwk =\n signer.method === 'did'\n ? await getPublicJwkFromDid(agentContext, signer.didUrl)\n : Kms.PublicJwk.fromUnknown(signer.publicJwk)\n\n if (!publicJwk.supportedSignatureAlgorithms.includes(signer.alg as Kms.KnownJwaSignatureAlgorithm)) {\n throw new CredoError(\n `jwk ${publicJwk.jwkTypeHumanDescription} does not support JWS signature alg '${signer.alg}'`\n )\n }\n\n const jwt = await jwsService.createJwsCompact(agentContext, {\n protectedHeaderOptions: {\n ...header,\n jwk: header.jwk ? publicJwk : undefined,\n alg: signer.alg as Kms.KnownJwaSignatureAlgorithm,\n },\n payload: JsonEncoder.toBuffer(payload),\n keyId: signer.kid ?? publicJwk.keyId,\n })\n\n return { jwt, signerJwk: publicJwk.toJson() as Jwk }\n }\n}\n\nexport function getOid4vcCallbacks(\n agentContext: AgentContext,\n options?: {\n trustedCertificates?: string[]\n isVerifyOpenId4VpAuthorizationRequest?: boolean\n issuanceSessionId?: string\n }\n) {\n const kms = agentContext.resolve(Kms.KeyManagementApi)\n\n return {\n hash: (data, alg) => Hasher.hash(data, alg.toLowerCase()),\n generateRandom: (length) => kms.randomBytes({ length }),\n signJwt: getOid4vcJwtSignCallback(agentContext),\n clientAuthentication: () => {\n throw new CredoError('Did not expect client authentication to be called.')\n },\n verifyJwt: getOid4vcJwtVerifyCallback(agentContext, {\n trustedCertificates: options?.trustedCertificates,\n isAuthorizationRequestJwt: options?.isVerifyOpenId4VpAuthorizationRequest,\n issuanceSessionId: options?.issuanceSessionId,\n }),\n fetch: agentContext.config.agentDependencies.fetch,\n encryptJwe: getOid4vcEncryptJweCallback(agentContext),\n decryptJwe: getOid4vcDecryptJweCallback(agentContext),\n getX509CertificateMetadata: (certificate: string) => {\n const leafCertificate = X509Service.getLeafCertificate(agentContext, { certificateChain: [certificate] })\n return {\n sanDnsNames: leafCertificate.sanDnsNames,\n sanUriNames: leafCertificate.sanUriNames,\n }\n },\n } satisfies Partial<CallbackContext>\n}\n\n/**\n * Allows us to authenticate when making requests to an external\n * authorization server\n */\nexport function dynamicOid4vciClientAuthentication(\n agentContext: AgentContext,\n issuerRecord: OpenId4VcIssuerRecord\n): ClientAuthenticationCallback {\n return (callbackOptions) => {\n const authorizationServer = issuerRecord.authorizationServerConfigs?.find(\n (a) => a.issuer === callbackOptions.authorizationServerMetadata.issuer\n )\n\n if (!authorizationServer) {\n // No client authentication if authorization server is not configured\n agentContext.config.logger.debug(\n `Unknown authorization server '${callbackOptions.authorizationServerMetadata.issuer}' for issuer '${issuerRecord.issuerId}' for request to '${callbackOptions.url}'`\n )\n return\n }\n\n if (!authorizationServer.clientAuthentication) {\n throw new CredoError(\n `Unable to authenticate to authorization server '${authorizationServer.issuer}' for issuer '${issuerRecord.issuerId}' for request to '${callbackOptions.url}'. Make sure to configure a 'clientId' and 'clientSecret' for the authorization server on the issuer record.`\n )\n }\n\n return clientAuthenticationDynamic({\n clientId: authorizationServer.clientAuthentication.clientId,\n clientSecret: authorizationServer.clientAuthentication.clientSecret,\n })(callbackOptions)\n }\n}\n"],"mappings":";;;;;AA6BA,SAAgB,2BACd,cACA,SAamB;CACnB,MAAM,aAAa,aAAa,kBAAkB,QAAQ,WAAW;AAErE,QAAO,OAAO,QAAQ,EAAE,SAAS,QAAQ,cAAc;EACrD,IAAI,sBAAsB,SAAS;AACnC,MACE,OAAO,WAAW,UACjB,OAAO,QAAQ,yBAAyB,SAAS,8BAClD,CAAC,qBACD;GACA,MAAM,aAAa,aAAa,kBAAkB,QAAQ,iBAAiB;GAC3E,MAAM,mBAAmB,OAAO,KAAK,KAAK,SAAS,gBAAgB,uBAAuB,KAAK,CAAC;AAEhG,yBAAsB,MAAM,WAAW,wCAAw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ACzD,iBAAiB,WAAW,IAAI,YAAY,EAAE,QAAQ,CAAC;EACvD,SAAS,yBAAyB,aAAa;EAC/C,4BAA4B;AAC1B,SAAM,IAAI,WAAW,qDAAqD;;EAE5E,WAAW,2BAA2B,cAAc;GAClD,qBAAqB,SAAS;GAC9B,2BAA2B,SAAS;GACpC,mBAAmB,SAAS;GAC7B,CAAC;EACF,OAAO,aAAa,OAAO,kBAAkB;EAC7C,YAAY,4BAA4B,aAAa;EACrD,YAAY,4BAA4B,aAAa;EACrD,6BAA6B,gBAAwB;GACnD,MAAM,kBAAkB,YAAY,mBAAmB,cAAc,EAAE,kBAAkB,CAAC,YAAY,EAAE,CAAC;AACzG,UAAO;IACL,aAAa,gBAAgB;IAC7B,aAAa,gBAAgB;IAC9B;;EAEJ;;;;;;AAOH,SAAgB,mCACd,cACA,cAC8B;AAC9B,SAAQ,oBAAoB;EAC1B,MAAM,sBAAsB,aAAa,4BAA4B,MAClE,MAAM,EAAE,WAAW,gBAAgB,4BAA4B,OACjE;AAED,MAAI,CAAC,qBAAqB;AAExB,gBAAa,OAAO,OAAO,MACzB,iCAAiC,gBAAgB,4BAA4B,OAAO,gBAAgB,aAAa,SAAS,oBAAoB,gBAAgB,IAAI,GACnK;AACD;;AAGF,MAAI,CAAC,oBAAoB,qBACvB,OAAM,IAAI,WACR,mDAAmD,oBAAoB,OAAO,gBAAgB,aAAa,SAAS,oBAAoB,gBAAgB,IAAI,8GAC7J;AAGH,SAAO,4BAA4B;GACjC,UAAU,oBAAoB,qBAAqB;GACnD,cAAc,oBAAoB,qBAAqB;GACxD,CAAC,CAAC,gBAAgB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { OpenId4VcCredentialHolderAttestationBinding, OpenId4VcCredentialHolderBinding, OpenId4VcCredentialHolderDidBinding, OpenId4VcCredentialHolderJwkBinding, VerifiedOpenId4VcCredentialHolderBinding } from "./models/CredentialHolderBinding.mjs";
|
|
2
|
+
import { OpenId4VciAuthorizationServerClientAuthenticationClientSecret, OpenId4VciAuthorizationServerConfig, OpenId4VciChainedAuthorizationServerConfig, OpenId4VciDirectAuthorizationServerConfig } from "./models/OpenId4VciAuthorizationServerConfig.mjs";
|
|
3
|
+
import { OpenId4VciCredentialFormatProfile } from "./models/OpenId4VciCredentialFormatProfile.mjs";
|
|
4
|
+
import { OpenId4VcJwtIssuer, OpenId4VcJwtIssuerDid, OpenId4VcJwtIssuerEncoded, OpenId4VcJwtIssuerJwk, OpenId4VcJwtIssuerJwkEncoded, OpenId4VcJwtIssuerX5c, OpenId4VcJwtIssuerX5cEncoded } from "./models/OpenId4VcJwtIssuer.mjs";
|
|
5
|
+
import { OpenId4VciAccessTokenResponse, OpenId4VciCredentialConfigurationSupported, OpenId4VciCredentialConfigurationSupportedWithFormats, OpenId4VciCredentialConfigurationsSupported, OpenId4VciCredentialConfigurationsSupportedWithFormats, OpenId4VciCredentialIssuerMetadata, OpenId4VciCredentialIssuerMetadataDisplay, OpenId4VciCredentialOfferPayload, OpenId4VciCredentialRequest, OpenId4VciCredentialRequestFormatSpecific, OpenId4VciCredentialRequestWithFormats, OpenId4VciDeferredCredentialRequest, OpenId4VciMetadata, OpenId4VciParsedCredentialRequest, OpenId4VciTxCode, OpenId4VpAuthorizationRequestPayload, OpenId4VpAuthorizationResponsePayload, OpenId4VpVerifiedAuthorizationRequest, Openid4vpAuthorizationRequest, authorizationCodeGrantIdentifier, preAuthorizedCodeGrantIdentifier } from "./models/index.mjs";
|
|
6
|
+
import { dynamicOid4vciClientAuthentication, getOid4vcCallbacks, getOid4vcDecryptJweCallback, getOid4vcEncryptJweCallback, getOid4vcJwtSignCallback, getOid4vcJwtVerifyCallback } from "./callbacks.mjs";
|
|
7
|
+
import { getAllowedAndRequestedScopeValues, getCredentialConfigurationsSupportedForScopes, getOfferedCredentials, getScopesFromCredentialConfigurationsSupported } from "./issuerMetadataUtils.mjs";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { dynamicOid4vciClientAuthentication, getOid4vcCallbacks, getOid4vcDecryptJweCallback, getOid4vcEncryptJweCallback, getOid4vcJwtSignCallback, getOid4vcJwtVerifyCallback } from "./callbacks.mjs";
|
|
2
|
+
import { getAllowedAndRequestedScopeValues, getCredentialConfigurationsSupportedForScopes, getOfferedCredentials, getScopesFromCredentialConfigurationsSupported } from "./issuerMetadataUtils.mjs";
|
|
3
|
+
import { OpenId4VciCredentialFormatProfile } from "./models/OpenId4VciCredentialFormatProfile.mjs";
|
|
4
|
+
import { authorizationCodeGrantIdentifier, preAuthorizedCodeGrantIdentifier } from "./models/index.mjs";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { OpenId4VciCredentialConfigurationsSupported, OpenId4VciCredentialConfigurationsSupportedWithFormats } from "./models/index.mjs";
|
|
2
|
+
import { CredentialConfigurationsSupported } from "@openid4vc/openid4vci";
|
|
3
|
+
|
|
4
|
+
//#region src/shared/issuerMetadataUtils.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Returns all entries from the credential offer with the associated metadata resolved.
|
|
8
|
+
*/
|
|
9
|
+
declare function getOfferedCredentials<Configurations extends OpenId4VciCredentialConfigurationsSupported | OpenId4VciCredentialConfigurationsSupportedWithFormats>(offeredCredentialConfigurationIds: Array<string>, credentialConfigurationsSupported: Configurations, {
|
|
10
|
+
ignoreNotFoundIds
|
|
11
|
+
}?: {
|
|
12
|
+
ignoreNotFoundIds?: boolean;
|
|
13
|
+
}): Configurations extends OpenId4VciCredentialConfigurationsSupportedWithFormats ? OpenId4VciCredentialConfigurationsSupportedWithFormats : OpenId4VciCredentialConfigurationsSupported;
|
|
14
|
+
declare function getScopesFromCredentialConfigurationsSupported(credentialConfigurationsSupported: CredentialConfigurationsSupported): string[];
|
|
15
|
+
declare function getAllowedAndRequestedScopeValues(options: {
|
|
16
|
+
requestedScope: string;
|
|
17
|
+
allowedScopes: string[];
|
|
18
|
+
}): string[];
|
|
19
|
+
declare function getCredentialConfigurationsSupportedForScopes(credentialConfigurationsSupported: CredentialConfigurationsSupported, scopes: string[]): CredentialConfigurationsSupported;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { getAllowedAndRequestedScopeValues, getCredentialConfigurationsSupportedForScopes, getOfferedCredentials, getScopesFromCredentialConfigurationsSupported };
|
|
22
|
+
//# sourceMappingURL=issuerMetadataUtils.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issuerMetadataUtils.d.mts","names":[],"sources":["../../src/shared/issuerMetadataUtils.ts"],"sourcesContent":[],"mappings":";;;;;;;AASA;AAEM,iBAFU,qBAEV,CAAA,uBAAA,2CAAA,GACA,sDADA,CAAA,CAAA,iCAAA,EAG+B,KAH/B,CAAA,MAAA,CAAA,EAAA,iCAAA,EAI+B,cAJ/B,EAAA;EAAA;CAG+B,CAH/B,EAAA;EACA,iBAAA,CAAA,EAAA,OAAA;CAE+B,CAAA,EAGlC,cAHkC,SAGX,sDAHW,GAIjC,sDAJiC,GAKjC,2CALiC;AACA,iBA4BrB,8CAAA,CA5BqB,iCAAA,EA6BA,iCA7BA,CAAA,EAAA,MAAA,EAAA;AACjC,iBAuCY,iCAAA,CAvCZ,OAAA,EAAA;EACD,cAAA,EAAA,MAAA;EAAuB,aAAA,EAAA,MAAA,EAAA;CACtB,CAAA,EAAA,MAAA,EAAA;AACA,iBA6CY,6CAAA,CA7CZ,iCAAA,EA8CiC,iCA9CjC,EAAA,MAAA,EAAA,MAAA,EAAA,CAAA,EAgDD,iCAhDC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/shared/issuerMetadataUtils.ts
|
|
2
|
+
/**
|
|
3
|
+
* Returns all entries from the credential offer with the associated metadata resolved.
|
|
4
|
+
*/
|
|
5
|
+
function getOfferedCredentials(offeredCredentialConfigurationIds, credentialConfigurationsSupported, { ignoreNotFoundIds = false } = {}) {
|
|
6
|
+
const offeredCredentialConfigurations = {};
|
|
7
|
+
for (const offeredCredentialConfigurationId of offeredCredentialConfigurationIds) {
|
|
8
|
+
const foundCredentialConfiguration = credentialConfigurationsSupported[offeredCredentialConfigurationId];
|
|
9
|
+
if (!foundCredentialConfiguration) {
|
|
10
|
+
if (!ignoreNotFoundIds) throw new Error(`Offered credential configuration id '${offeredCredentialConfigurationId}' is not part of credential_configurations_supported of the issuer metadata.`);
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
offeredCredentialConfigurations[offeredCredentialConfigurationId] = foundCredentialConfiguration;
|
|
14
|
+
}
|
|
15
|
+
return offeredCredentialConfigurations;
|
|
16
|
+
}
|
|
17
|
+
function getScopesFromCredentialConfigurationsSupported(credentialConfigurationsSupported) {
|
|
18
|
+
return Array.from(new Set(Object.values(credentialConfigurationsSupported).map((configuration) => configuration.scope).filter((scope) => scope !== void 0)));
|
|
19
|
+
}
|
|
20
|
+
function getAllowedAndRequestedScopeValues(options) {
|
|
21
|
+
const requestedScopeValues = options.requestedScope.split(" ");
|
|
22
|
+
return options.allowedScopes.filter((allowedScope) => requestedScopeValues.includes(allowedScope));
|
|
23
|
+
}
|
|
24
|
+
function getCredentialConfigurationsSupportedForScopes(credentialConfigurationsSupported, scopes) {
|
|
25
|
+
return Object.fromEntries(Object.entries(credentialConfigurationsSupported).filter(([, configuration]) => configuration.scope && scopes.includes(configuration.scope)));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { getAllowedAndRequestedScopeValues, getCredentialConfigurationsSupportedForScopes, getOfferedCredentials, getScopesFromCredentialConfigurationsSupported };
|
|
30
|
+
//# sourceMappingURL=issuerMetadataUtils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issuerMetadataUtils.mjs","names":["offeredCredentialConfigurations: OpenId4VciCredentialConfigurationsSupported"],"sources":["../../src/shared/issuerMetadataUtils.ts"],"sourcesContent":["import type { CredentialConfigurationsSupported } from '@openid4vc/openid4vci'\nimport type {\n OpenId4VciCredentialConfigurationsSupported,\n OpenId4VciCredentialConfigurationsSupportedWithFormats,\n} from './models'\n\n/**\n * Returns all entries from the credential offer with the associated metadata resolved.\n */\nexport function getOfferedCredentials<\n Configurations extends\n | OpenId4VciCredentialConfigurationsSupported\n | OpenId4VciCredentialConfigurationsSupportedWithFormats,\n>(\n offeredCredentialConfigurationIds: Array<string>,\n credentialConfigurationsSupported: Configurations,\n { ignoreNotFoundIds = false }: { ignoreNotFoundIds?: boolean } = {}\n): Configurations extends OpenId4VciCredentialConfigurationsSupportedWithFormats\n ? OpenId4VciCredentialConfigurationsSupportedWithFormats\n : OpenId4VciCredentialConfigurationsSupported {\n const offeredCredentialConfigurations: OpenId4VciCredentialConfigurationsSupported = {}\n for (const offeredCredentialConfigurationId of offeredCredentialConfigurationIds) {\n const foundCredentialConfiguration = credentialConfigurationsSupported[offeredCredentialConfigurationId]\n\n // Make sure the issuer metadata includes the offered credential.\n if (!foundCredentialConfiguration) {\n if (!ignoreNotFoundIds) {\n throw new Error(\n `Offered credential configuration id '${offeredCredentialConfigurationId}' is not part of credential_configurations_supported of the issuer metadata.`\n )\n }\n\n continue\n }\n\n offeredCredentialConfigurations[offeredCredentialConfigurationId] = foundCredentialConfiguration\n }\n\n return offeredCredentialConfigurations as Configurations extends OpenId4VciCredentialConfigurationsSupportedWithFormats\n ? OpenId4VciCredentialConfigurationsSupportedWithFormats\n : OpenId4VciCredentialConfigurationsSupported\n}\n\nexport function getScopesFromCredentialConfigurationsSupported(\n credentialConfigurationsSupported: CredentialConfigurationsSupported\n): string[] {\n return Array.from(\n new Set(\n Object.values(credentialConfigurationsSupported)\n .map((configuration) => configuration.scope)\n .filter((scope): scope is string => scope !== undefined)\n )\n )\n}\n\nexport function getAllowedAndRequestedScopeValues(options: { requestedScope: string; allowedScopes: string[] }) {\n const requestedScopeValues = options.requestedScope.split(' ')\n const allowedAndRequestedScopeValues = options.allowedScopes.filter((allowedScope) =>\n requestedScopeValues.includes(allowedScope)\n )\n\n return allowedAndRequestedScopeValues\n}\n\nexport function getCredentialConfigurationsSupportedForScopes(\n credentialConfigurationsSupported: CredentialConfigurationsSupported,\n scopes: string[]\n): CredentialConfigurationsSupported {\n return Object.fromEntries(\n Object.entries(credentialConfigurationsSupported).filter(\n ([, configuration]) => configuration.scope && scopes.includes(configuration.scope)\n )\n )\n}\n"],"mappings":";;;;AASA,SAAgB,sBAKd,mCACA,mCACA,EAAE,oBAAoB,UAA2C,EAAE,EAGrB;CAC9C,MAAMA,kCAA+E,EAAE;AACvF,MAAK,MAAM,oCAAoC,mCAAmC;EAChF,MAAM,+BAA+B,kCAAkC;AAGvE,MAAI,CAAC,8BAA8B;AACjC,OAAI,CAAC,kBACH,OAAM,IAAI,MACR,wCAAwC,iCAAiC,8EAC1E;AAGH;;AAGF,kCAAgC,oCAAoC;;AAGtE,QAAO;;AAKT,SAAgB,+CACd,mCACU;AACV,QAAO,MAAM,KACX,IAAI,IACF,OAAO,OAAO,kCAAkC,CAC7C,KAAK,kBAAkB,cAAc,MAAM,CAC3C,QAAQ,UAA2B,UAAU,OAAU,CAC3D,CACF;;AAGH,SAAgB,kCAAkC,SAA8D;CAC9G,MAAM,uBAAuB,QAAQ,eAAe,MAAM,IAAI;AAK9D,QAJuC,QAAQ,cAAc,QAAQ,iBACnE,qBAAqB,SAAS,aAAa,CAC5C;;AAKH,SAAgB,8CACd,mCACA,QACmC;AACnC,QAAO,OAAO,YACZ,OAAO,QAAQ,kCAAkC,CAAC,QAC/C,GAAG,mBAAmB,cAAc,SAAS,OAAO,SAAS,cAAc,MAAM,CACnF,CACF"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Kms } from "@credo-ts/core";
|
|
2
|
+
import { Openid4vciIssuer } from "@openid4vc/openid4vci";
|
|
3
|
+
|
|
4
|
+
//#region src/shared/models/CredentialHolderBinding.d.ts
|
|
5
|
+
type VerifiedCredentialRequestAttestationProof = Awaited<ReturnType<InstanceType<typeof Openid4vciIssuer>['verifyCredentialRequestAttestationProof']>>;
|
|
6
|
+
type VerifiedCredentialRequestJwtProof = Awaited<ReturnType<InstanceType<typeof Openid4vciIssuer>['verifyCredentialRequestJwtProof']>>['keyAttestation'];
|
|
7
|
+
type OpenId4VcCredentialHolderAttestationBinding = {
|
|
8
|
+
method: 'attestation';
|
|
9
|
+
/**
|
|
10
|
+
* The key attestation JWT to use to request issuance of the credentials based
|
|
11
|
+
* on the attested_keys.
|
|
12
|
+
*
|
|
13
|
+
* When the `keyAttestationJwt` contains a `nonce` payload value it will be sent
|
|
14
|
+
* as an `attestation` proof (without signing using a key in the attested key).
|
|
15
|
+
* NOTE that the `nonce` value must match with the `c_nonce` value from the issuer.
|
|
16
|
+
*
|
|
17
|
+
* If no nonce is provided, the `jwt` proof type will be used and the proof will be
|
|
18
|
+
* signed using the first key from the `attested_keys` array.
|
|
19
|
+
*/
|
|
20
|
+
keyAttestationJwt: string;
|
|
21
|
+
};
|
|
22
|
+
interface OpenId4VcCredentialHolderDidBinding {
|
|
23
|
+
method: 'did';
|
|
24
|
+
didUrls: string[];
|
|
25
|
+
}
|
|
26
|
+
interface OpenId4VcCredentialHolderJwkBinding {
|
|
27
|
+
method: 'jwk';
|
|
28
|
+
keys: Kms.PublicJwk[];
|
|
29
|
+
}
|
|
30
|
+
type VerifiedOpenId4VcCredentialHolderBinding = {
|
|
31
|
+
proofType: 'jwt' | 'attestation';
|
|
32
|
+
/**
|
|
33
|
+
* The key attestation that was provided to attest the keys.
|
|
34
|
+
* Always defined if `proofType` is `attestation`, as well
|
|
35
|
+
* as when `key_attestations_required` is defined in the
|
|
36
|
+
* credential issuer metadata
|
|
37
|
+
*/
|
|
38
|
+
keyAttestation?: VerifiedCredentialRequestAttestationProof | VerifiedCredentialRequestJwtProof;
|
|
39
|
+
/**
|
|
40
|
+
* The binding method of the keys.
|
|
41
|
+
*
|
|
42
|
+
* Binding method `did` is only supported for proof type `jwt`.
|
|
43
|
+
*/
|
|
44
|
+
bindingMethod: 'did' | 'jwk';
|
|
45
|
+
} & ({
|
|
46
|
+
bindingMethod: 'did';
|
|
47
|
+
/**
|
|
48
|
+
* The DIDs that were provided as part of the `jwt` proofs in the credential request
|
|
49
|
+
*/
|
|
50
|
+
keys: Array<{
|
|
51
|
+
method: 'did';
|
|
52
|
+
jwk: Kms.PublicJwk;
|
|
53
|
+
didUrl: string;
|
|
54
|
+
}>;
|
|
55
|
+
} | {
|
|
56
|
+
bindingMethod: 'jwk';
|
|
57
|
+
/**
|
|
58
|
+
* The keys that were provided as part of the credential request proof.
|
|
59
|
+
* - If `proofType` is `attestation` these keys were extracted from the signed key attestation, but no proof was signed using one of the attested keys
|
|
60
|
+
* - If `proofType` is `jwt` and `attestation` is defined, the keys were extracted from the attestation, and proof was signed using one of the attested keys
|
|
61
|
+
* - Otherwise if `proofType` is `jwt` and no `attestation` is defined, the keys were not attested, and for each individual key a proof was signed using that key.
|
|
62
|
+
*/
|
|
63
|
+
keys: Array<{
|
|
64
|
+
method: 'jwk';
|
|
65
|
+
jwk: Kms.PublicJwk;
|
|
66
|
+
}>;
|
|
67
|
+
});
|
|
68
|
+
type OpenId4VcCredentialHolderBinding = OpenId4VcCredentialHolderDidBinding | OpenId4VcCredentialHolderJwkBinding | OpenId4VcCredentialHolderAttestationBinding;
|
|
69
|
+
//#endregion
|
|
70
|
+
export { OpenId4VcCredentialHolderAttestationBinding, OpenId4VcCredentialHolderBinding, OpenId4VcCredentialHolderDidBinding, OpenId4VcCredentialHolderJwkBinding, VerifiedOpenId4VcCredentialHolderBinding };
|
|
71
|
+
//# sourceMappingURL=CredentialHolderBinding.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CredentialHolderBinding.d.mts","names":[],"sources":["../../../src/shared/models/CredentialHolderBinding.ts"],"sourcesContent":[],"mappings":";;;;KAKK,yCAAA,GAA4C,QAC/C,WAAW,oBAAoB;KAE5B,iCAAA,GAAoC,QACvC,WAAW,oBAAoB;AAJ5B,KAOO,2CAAA,GAPkC;EACb,MAAA,EAAA,aAAA;EAApB;;;;AAD2C;;;;;;AAOxD;EAqBiB,iBAAA,EAAA,MAAA;AAKjB,CAAA;AAKY,UAVK,mCAAA,CAUmC;EASjC,MAAA,EAAA,KAAA;EAA4C,OAAA,EAAA,MAAA,EAAA;;AAenD,UA7BK,mCAAA,CA6BL;EAiBC,MAAI,EAAA,KAAA;EAFL,IAAA,EA1CJ,GAAA,CAAI,SA0CA,EAAA;;AAOA,KA9CA,wCAAA,GA8CgC;EACxC,SAAA,EAAA,KAAA,GAAA,aAAA;EACA;;;;;;mBAvCe,4CAA4C;;;;;;;;;;;;QAenD;;SAEC,GAAA,CAAI;;;;;;;;;;;QAaL;;SAEC,GAAA,CAAI;;;KAKL,gCAAA,GACR,sCACA,sCACA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { Openid4vciIssuer } from "@openid4vc/openid4vci";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Kms, X509Certificate } from "@credo-ts/core";
|
|
2
|
+
|
|
3
|
+
//#region src/shared/models/OpenId4VcJwtIssuer.d.ts
|
|
4
|
+
interface OpenId4VcJwtIssuerDid {
|
|
5
|
+
method: 'did';
|
|
6
|
+
/**
|
|
7
|
+
* The did url pointing to a specific verification method.
|
|
8
|
+
*
|
|
9
|
+
* Note a created DID record MUST exist for the did url, enabling extraction of the KMS key id from the did record.
|
|
10
|
+
*/
|
|
11
|
+
didUrl: string;
|
|
12
|
+
}
|
|
13
|
+
interface OpenId4VcJwtIssuerX5c {
|
|
14
|
+
method: 'x5c';
|
|
15
|
+
/**
|
|
16
|
+
* Array of X.509 certificates
|
|
17
|
+
*
|
|
18
|
+
* The certificate containing the public key corresponding to the key used to digitally sign the JWS MUST be the first certificate.
|
|
19
|
+
* The first certificate MUST also have a key id configured on the public key to enable signing with the KMS.
|
|
20
|
+
*/
|
|
21
|
+
x5c: X509Certificate[];
|
|
22
|
+
}
|
|
23
|
+
interface OpenId4VcJwtIssuerX5cEncoded {
|
|
24
|
+
method: 'x5c';
|
|
25
|
+
/**
|
|
26
|
+
* x5c encoded as base64
|
|
27
|
+
*/
|
|
28
|
+
x5c: string[];
|
|
29
|
+
/**
|
|
30
|
+
* key id associated with the leaf certificate
|
|
31
|
+
*/
|
|
32
|
+
leafCertificateKeyId: string;
|
|
33
|
+
}
|
|
34
|
+
interface OpenId4VcJwtIssuerJwk {
|
|
35
|
+
method: 'jwk';
|
|
36
|
+
jwk: Kms.PublicJwk;
|
|
37
|
+
}
|
|
38
|
+
interface OpenId4VcJwtIssuerJwkEncoded {
|
|
39
|
+
method: 'jwk';
|
|
40
|
+
jwk: Kms.KmsJwkPublic;
|
|
41
|
+
}
|
|
42
|
+
type OpenId4VcJwtIssuer = OpenId4VcJwtIssuerDid | OpenId4VcJwtIssuerX5c | OpenId4VcJwtIssuerJwk;
|
|
43
|
+
type OpenId4VcJwtIssuerEncoded = OpenId4VcJwtIssuerDid | OpenId4VcJwtIssuerX5cEncoded | OpenId4VcJwtIssuerJwkEncoded;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { OpenId4VcJwtIssuer, OpenId4VcJwtIssuerDid, OpenId4VcJwtIssuerEncoded, OpenId4VcJwtIssuerJwk, OpenId4VcJwtIssuerJwkEncoded, OpenId4VcJwtIssuerX5c, OpenId4VcJwtIssuerX5cEncoded };
|
|
46
|
+
//# sourceMappingURL=OpenId4VcJwtIssuer.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenId4VcJwtIssuer.d.mts","names":[],"sources":["../../../src/shared/models/OpenId4VcJwtIssuer.ts"],"sourcesContent":[],"mappings":";;;UAEiB,qBAAA;;EAAA;AAWjB;AAYA;AAcA;AAKA;EAKY,MAAA,EAAA,MAAA;;AAA6C,UApCxC,qBAAA,CAoCwC;EAAwB,MAAA,EAAA,KAAA;EAAqB;AACtG;;;;;OA5BO;;UAGU,4BAAA;;;;;;;;;;;UAcA,qBAAA;;OAEV,GAAA,CAAI;;UAGM,4BAAA;;OAEV,GAAA,CAAI;;KAGC,kBAAA,GAAqB,wBAAwB,wBAAwB;KACrE,yBAAA,GACR,wBACA,+BACA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { Kms, X509Certificate } from "@credo-ts/core";
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Optional } from "@credo-ts/core";
|
|
2
|
+
|
|
3
|
+
//#region src/shared/models/OpenId4VciAuthorizationServerConfig.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Credo supports two types of authorization servers, indicated by the `type` field:
|
|
7
|
+
*
|
|
8
|
+
* - `direct` - The authorization server will be listed as part of the
|
|
9
|
+
* `authorization_servers` in the OpenID4VCI issuer metadata and clients/wallets
|
|
10
|
+
* will directly interact with the authorization server. Your authorization server
|
|
11
|
+
* must be aware of wallet-specific features, such as `issuer_state`, and, optionally,
|
|
12
|
+
* wallet attestations, DPoP, PAR, etc.
|
|
13
|
+
*
|
|
14
|
+
* - `chained` - The authorization server will **not** be listed as part of the
|
|
15
|
+
* `authorization_servers` in the OpenID4VCI issuer metadata and clients/wallets
|
|
16
|
+
* will not directly interact with the authorization server. This allows all
|
|
17
|
+
* Credo's features, such as wallet attestations, DPoP & PAR, to be used while
|
|
18
|
+
* still leveraging the authentication of the external authorization server.
|
|
19
|
+
*/
|
|
20
|
+
type OpenId4VciAuthorizationServerConfig = OpenId4VciDirectAuthorizationServerConfig | OpenId4VciChainedAuthorizationServerConfig;
|
|
21
|
+
/**
|
|
22
|
+
* Perform authentication based on a client secret. It will dynamically use
|
|
23
|
+
* `client_secret_post` or `client_secret_basic` based on the method supported
|
|
24
|
+
* by the authorization server.
|
|
25
|
+
*/
|
|
26
|
+
interface OpenId4VciAuthorizationServerClientAuthenticationClientSecret {
|
|
27
|
+
/**
|
|
28
|
+
* @note if no type is defined, the default is `clientSecret` due to older versions
|
|
29
|
+
* of Credo not having a type
|
|
30
|
+
*/
|
|
31
|
+
type: 'clientSecret';
|
|
32
|
+
clientId: string;
|
|
33
|
+
clientSecret: string;
|
|
34
|
+
}
|
|
35
|
+
interface OpenId4VciDirectAuthorizationServerConfig {
|
|
36
|
+
type: 'direct';
|
|
37
|
+
/**
|
|
38
|
+
* The `issuer` url of your OAuth server. This URL must expose well-known OAuth2 metadata
|
|
39
|
+
*/
|
|
40
|
+
issuer: string;
|
|
41
|
+
/**
|
|
42
|
+
* Optional client authentication for token introspection
|
|
43
|
+
*
|
|
44
|
+
* @note `type` is optional for client secret authentication, in this case `clientSecret` is implied
|
|
45
|
+
* due to older versions of Credo not having a `type`.
|
|
46
|
+
*/
|
|
47
|
+
clientAuthentication?: Optional<OpenId4VciAuthorizationServerClientAuthenticationClientSecret, 'type'>;
|
|
48
|
+
}
|
|
49
|
+
interface OpenId4VciChainedAuthorizationServerConfig {
|
|
50
|
+
type: 'chained';
|
|
51
|
+
/**
|
|
52
|
+
* The `issuer` url of your OAuth server. This URL must expose well-known OAuth2 metadata
|
|
53
|
+
*/
|
|
54
|
+
issuer: string;
|
|
55
|
+
/**
|
|
56
|
+
* Client authentication for interacting with the external authorization server.
|
|
57
|
+
*
|
|
58
|
+
* This will be used for exchanging the authorization code for an access token
|
|
59
|
+
*/
|
|
60
|
+
clientAuthentication: OpenId4VciAuthorizationServerClientAuthenticationClientSecret;
|
|
61
|
+
/**
|
|
62
|
+
* Mapping between credential scopes and authorization server scopes.
|
|
63
|
+
*
|
|
64
|
+
* This is mandatory. If a scope is missing, an error will be thrown when making
|
|
65
|
+
* a credential offer. If no additional scope is needed, use an empty array.
|
|
66
|
+
*/
|
|
67
|
+
scopesMapping: Record<string, string[]>;
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
export { OpenId4VciAuthorizationServerClientAuthenticationClientSecret, OpenId4VciAuthorizationServerConfig, OpenId4VciChainedAuthorizationServerConfig, OpenId4VciDirectAuthorizationServerConfig };
|
|
71
|
+
//# sourceMappingURL=OpenId4VciAuthorizationServerConfig.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenId4VciAuthorizationServerConfig.d.mts","names":[],"sources":["../../../src/shared/models/OpenId4VciAuthorizationServerConfig.ts"],"sourcesContent":[],"mappings":";;;;;;AAiBA;AASA;AAWA;AAiBA;;;;;;;;;;KArCY,mCAAA,GACR,4CACA;;;;;;UAOa,6DAAA;;;;;;;;;UAWA,yCAAA;;;;;;;;;;;;yBAcQ,SAAS;;UAGjB,0CAAA;;;;;;;;;;;wBAaO;;;;;;;iBAQP"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/shared/models/OpenId4VciCredentialFormatProfile.d.ts
|
|
2
|
+
declare enum OpenId4VciCredentialFormatProfile {
|
|
3
|
+
JwtVcJson = "jwt_vc_json",
|
|
4
|
+
JwtVcJsonLd = "jwt_vc_json-ld",
|
|
5
|
+
LdpVc = "ldp_vc",
|
|
6
|
+
SdJwtVc = "vc+sd-jwt",
|
|
7
|
+
SdJwtDc = "dc+sd-jwt",
|
|
8
|
+
MsoMdoc = "mso_mdoc",
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { OpenId4VciCredentialFormatProfile };
|
|
12
|
+
//# sourceMappingURL=OpenId4VciCredentialFormatProfile.d.mts.map
|