File tree Expand file tree Collapse file tree
packages/siop-oid4vp/lib/authorization-response Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -104,10 +104,26 @@ export const extractDcqlPresentationFromDcqlVpToken = (
104104 opts ?: { hasher ?: HasherSync } ,
105105) : PresentationSubmission => {
106106 return Object . fromEntries (
107- Object . entries ( DcqlPresentation . parse ( vpToken ) ) . map ( ( [ credentialQueryId , vp ] ) => [
107+ Object . entries ( DcqlPresentation . parse ( vpToken ) ) . map ( ( [ credentialQueryId , vp ] ) => {
108+ let singleVp : W3CVerifiablePresentation | CompactSdJwtVc | string
109+
110+ if ( Array . isArray ( vp ) ) {
111+ if ( vp . length === 0 ) {
112+ throw new Error ( `DCQL query '${ credentialQueryId } ' has empty array of presentations` )
113+ }
114+ if ( vp . length > 1 ) {
115+ throw new Error ( `DCQL query '${ credentialQueryId } ' has multiple presentations (${ vp . length } ), but only one is supported atm` )
116+ }
117+ singleVp = vp [ 0 ]
118+ } else {
119+ singleVp = vp
120+ }
121+
122+ return [
108123 credentialQueryId ,
109- CredentialMapper . toWrappedVerifiablePresentation ( vp as W3CVerifiablePresentation | CompactSdJwtVc | string , { hasher : opts ?. hasher } ) ,
110- ] ) ,
124+ CredentialMapper . toWrappedVerifiablePresentation ( singleVp as W3CVerifiablePresentation | CompactSdJwtVc | string , { hasher : opts ?. hasher } ) ,
125+ ]
126+ } ) ,
111127 )
112128}
113129
You can’t perform that action at this time.
0 commit comments