Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove unnecessary conditional #2076

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,18 +644,12 @@ export class OpenId4VcSiopVerifierService {
})

isValid = verificationResult.isValid
}

// FIXME: we throw an error here as there's a bug in sphereon library where they
// don't check the returned 'verified' property and only catch errors thrown.
// Once https://github.com/Sphereon-Opensource/SIOP-OID4VP/pull/70 is merged we
// can remove this.
if (!isValid) {
throw new CredoError('Presentation verification failed.')
reason = verificationResult.error?.message
}

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