Skip to content

Commit

Permalink
feat: add reason property to verificationResult
Browse files Browse the repository at this point in the history
  • Loading branch information
DJHunn39 committed Oct 29, 2024
1 parent 0de69d7 commit ae0504f
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ export class OpenId4VcSiopVerifierService {
if (!encodedPresentation) throw new CredoError('Did not receive a presentation for verification.')

let isValid: boolean
let reason: string | undefined

// TODO: it might be better here to look at the presentation submission to know
// If presentation includes a ~, we assume it's an SD-JWT-VC
Expand All @@ -622,6 +623,7 @@ export class OpenId4VcSiopVerifierService {
})

isValid = verificationResult.verification.isValid
reason = verificationResult.isValid ? undefined : verificationResult.error.message
} else if (typeof encodedPresentation === 'string') {
const verificationResult = await this.w3cCredentialService.verifyPresentation(agentContext, {
presentation: encodedPresentation,
Expand All @@ -633,6 +635,7 @@ export class OpenId4VcSiopVerifierService {
})

isValid = verificationResult.isValid
reason = verificationResult.error?.message
} else {
const verificationResult = await this.w3cCredentialService.verifyPresentation(agentContext, {
presentation: JsonTransformer.fromJSON(encodedPresentation, W3cJsonLdVerifiablePresentation),
Expand All @@ -641,10 +644,12 @@ export class OpenId4VcSiopVerifierService {
})

isValid = verificationResult.isValid
reason = verificationResult.error?.message
}

return {
verified: isValid,
reason,
}
} catch (error) {
agentContext.config.logger.warn('Error occurred during verification of presentation', {
Expand Down

0 comments on commit ae0504f

Please sign in to comment.