-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow dynamicaly providing x509 certificates for all types of v…
…erifications (#2112) Signed-off-by: Timo Glastra <[email protected]>
- Loading branch information
1 parent
b41a4b1
commit 5f08bc6
Showing
24 changed files
with
417 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@credo-ts/openid4vc': minor | ||
'@credo-ts/core': minor | ||
--- | ||
|
||
feat: allow dynamicaly providing x509 certificates for all types of verifications |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ import { | |
W3cJsonLdVerifiablePresentation, | ||
W3cJwtVerifiablePresentation, | ||
} from '../../../vc' | ||
import { extractX509CertificatesFromJwt, X509ModuleConfig } from '../../../x509' | ||
import { ProofFormatSpec } from '../../models' | ||
|
||
const PRESENTATION_EXCHANGE_PRESENTATION_PROPOSAL = 'dif/presentation-exchange/[email protected]' | ||
|
@@ -301,13 +302,31 @@ export class DifPresentationExchangeProofFormatService | |
// whether it's a JWT or JSON-LD VP even though the input is the same. | ||
// Not sure how to fix | ||
if (parsedPresentation.claimFormat === ClaimFormat.JwtVp) { | ||
const x509Config = agentContext.dependencyManager.resolve(X509ModuleConfig) | ||
|
||
const certificateChain = extractX509CertificatesFromJwt(parsedPresentation.jwt) | ||
let trustedCertificates: string[] | undefined | ||
|
||
if (certificateChain && x509Config.getTrustedCertificatesForVerification) { | ||
trustedCertificates = await x509Config.getTrustedCertificatesForVerification?.(agentContext, { | ||
certificateChain, | ||
verification: { | ||
type: 'credential', | ||
credential: parsedPresentation, | ||
didcommProofRecordId: proofRecord.id, | ||
}, | ||
}) | ||
} | ||
|
||
if (!trustedCertificates) { | ||
trustedCertificates = x509Config.trustedCertificates ?? [] | ||
} | ||
|
||
verificationResult = await w3cCredentialService.verifyPresentation(agentContext, { | ||
presentation: parsedPresentation, | ||
challenge: request.options.challenge, | ||
domain: request.options.domain, | ||
verificationContext: { | ||
didcommProofRecordId: proofRecord.id, | ||
}, | ||
trustedCertificates, | ||
}) | ||
} else if (parsedPresentation.claimFormat === ClaimFormat.LdpVp) { | ||
if ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.