Skip to content

Commit

Permalink
chore: upgraded countVCsInAllVPs
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderPostma committed Nov 14, 2024
1 parent 339900d commit ac9c9ac
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/siopv2-oid4vp-op-auth/src/session/OpSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { encodeBase64url } from '@sphereon/ssi-sdk.core'
import {
CompactSdJwtVc,
CredentialMapper,
Hasher,
OriginalVerifiableCredential,
parseDid,
PresentationSubmission,
Expand Down Expand Up @@ -316,7 +317,7 @@ export class OpSession {
const totalInputDescriptors = request.presentationDefinitions?.reduce((sum, pd) => {
return sum + pd.definition.input_descriptors.length
}, 0)
const totalVCs = this.countVCsInAllVPs(args)
const totalVCs = this.countVCsInAllVPs(args.verifiablePresentations, args.hasher)

if (!request.presentationDefinitions || !args.verifiablePresentations || totalVCs !== totalInputDescriptors) {
throw Error(
Expand Down Expand Up @@ -366,9 +367,9 @@ export class OpSession {
}
}

private countVCsInAllVPs(args: IOpsSendSiopAuthorizationResponseArgs) {
return args.verifiablePresentations?.reduce((sum, vp) => {
const uvp = CredentialMapper.toUniformPresentation(vp, { hasher: args.hasher ?? this.options.hasher })
private countVCsInAllVPs(verifiablePresentations: W3CVerifiablePresentation[] | undefined, hasher: Hasher | undefined) {
return verifiablePresentations?.reduce((sum, vp) => {
const uvp = CredentialMapper.toUniformPresentation(vp, { hasher: hasher ?? this.options.hasher })
if (uvp.verifiableCredential?.length) {
return sum + uvp.verifiableCredential?.length
}
Expand Down

0 comments on commit ac9c9ac

Please sign in to comment.