@@ -53,10 +53,17 @@ export interface IVerificationController {
5353 errors : any [ ] ;
5454 warnings : any [ ] ;
5555 } ;
56- getRequirementGroups : ( ) => Array < { descriptorKey : string ; descriptorName : string ; candidates : any [ ] } > ;
56+ getRequirementGroups : ( ) => Array < {
57+ descriptorKey : string ;
58+ descriptorName : string ;
59+ candidates : any [ ] ;
60+ } > ;
5761 getSelectedCredentialsByDescriptor : ( ) => any [ ] ;
5862 getCredentialOptionsForDescriptor : ( credentialId : string ) => any ;
59- switchCredential : ( currentCredentialId : string , replacementCredentialId : string ) => Promise < void > ;
63+ switchCredential : (
64+ currentCredentialId : string ,
65+ replacementCredentialId : string ,
66+ ) => Promise < void > ;
6067 getRequestedAttributes : ( credentialId : string ) => any [ ] ;
6168 getCredentialStatus : ( credentialId : string ) => Promise < any > ;
6269 canSwitchCredential : ( credentialId : string ) => boolean ;
@@ -204,15 +211,22 @@ export function createVerificationController({
204211
205212 function getRequirementGroups ( ) {
206213 if ( filteredMatches . length === 0 ) {
207- return [ {
208- descriptorKey : 'default' ,
209- descriptorName : 'default' ,
210- candidates : [ ...filteredCredentials ] ,
211- } ] ;
214+ return [
215+ {
216+ descriptorKey : 'default' ,
217+ descriptorName : 'default' ,
218+ candidates : [ ...filteredCredentials ] ,
219+ } ,
220+ ] ;
212221 }
213222
214- const groups : Array < { descriptorKey : string ; descriptorName : string ; candidates : any [ ] } > = [ ] ;
215- const groupKeyFn = ( match ) => match . from ? JSON . stringify ( match . from ) : ( match . name || match . id || '' ) ;
223+ const groups : Array < {
224+ descriptorKey : string ;
225+ descriptorName : string ;
226+ candidates : any [ ] ;
227+ } > = [ ] ;
228+ const groupKeyFn = match =>
229+ match . from ? JSON . stringify ( match . from ) : match . name || match . id || '' ;
216230 const seen = new Map < string , number > ( ) ;
217231
218232 for ( const match of filteredMatches ) {
@@ -255,13 +269,18 @@ export function createVerificationController({
255269
256270 const groups = getRequirementGroups ( ) ;
257271 for ( const group of groups ) {
258- const chosen = group . candidates . find ( cred => ! selectedCredentials . has ( cred . id ) ) || group . candidates [ 0 ] ;
272+ const chosen =
273+ group . candidates . find ( cred => ! selectedCredentials . has ( cred . id ) ) ||
274+ group . candidates [ 0 ] ;
259275 if ( chosen ) {
260- selectedCredentials . set ( chosen . id , { credential : chosen } ) ;
276+ selectedCredentials . set ( chosen . id , { credential : chosen } ) ;
261277 }
262278 }
263279
264- assert ( selectedCredentials . size > 0 , 'No credentials could be selected for the presentation' ) ;
280+ assert (
281+ selectedCredentials . size > 0 ,
282+ 'No credentials could be selected for the presentation' ,
283+ ) ;
265284
266285 return createPresentation ( ) ;
267286 }
@@ -270,8 +289,11 @@ export function createVerificationController({
270289 const groups = getRequirementGroups ( ) ;
271290
272291 return groups . map ( group => {
273- const selected = group . candidates . find ( cred => selectedCredentials . has ( cred . id ) ) || null ;
274- const alternatives = group . candidates . filter ( cred => ! selected || cred . id !== selected . id ) ;
292+ const selected =
293+ group . candidates . find ( cred => selectedCredentials . has ( cred . id ) ) || null ;
294+ const alternatives = group . candidates . filter (
295+ cred => ! selected || cred . id !== selected . id ,
296+ ) ;
275297
276298 return {
277299 descriptorId : group . descriptorKey ,
@@ -284,9 +306,14 @@ export function createVerificationController({
284306
285307 function getCredentialOptionsForDescriptor ( credentialId : string ) {
286308 const groups = getRequirementGroups ( ) ;
287- const group = groups . find ( g => g . candidates . some ( c => c . id === credentialId ) ) ;
309+ const group = groups . find ( g =>
310+ g . candidates . some ( c => c . id === credentialId ) ,
311+ ) ;
288312
289- assert ( group , `Credential ${ credentialId } not found in any descriptor group` ) ;
313+ assert (
314+ group ,
315+ `Credential ${ credentialId } not found in any descriptor group` ,
316+ ) ;
290317
291318 const selected = group . candidates . find ( c => c . id === credentialId ) ;
292319 const alternatives = group . candidates . filter ( c => c . id !== credentialId ) ;
@@ -299,22 +326,27 @@ export function createVerificationController({
299326 } ;
300327 }
301328
302- async function switchCredential ( currentCredentialId : string , replacementCredentialId : string ) {
329+ async function switchCredential (
330+ currentCredentialId : string ,
331+ replacementCredentialId : string ,
332+ ) {
303333 assert (
304334 selectedCredentials . has ( currentCredentialId ) ,
305335 `Credential ${ currentCredentialId } is not currently selected` ,
306336 ) ;
307337
308338 const options = getCredentialOptionsForDescriptor ( currentCredentialId ) ;
309- const replacement = options . alternatives . find ( c => c . id === replacementCredentialId ) ;
339+ const replacement = options . alternatives . find (
340+ c => c . id === replacementCredentialId ,
341+ ) ;
310342
311343 assert (
312344 replacement ,
313345 `Credential ${ replacementCredentialId } is not a valid replacement for ${ currentCredentialId } ` ,
314346 ) ;
315347
316348 selectedCredentials . delete ( currentCredentialId ) ;
317- selectedCredentials . set ( replacementCredentialId , { credential : replacement } ) ;
349+ selectedCredentials . set ( replacementCredentialId , { credential : replacement } ) ;
318350
319351 return createPresentation ( ) ;
320352 }
@@ -329,16 +361,26 @@ export function createVerificationController({
329361 for ( const descriptor of definition . input_descriptors ) {
330362 const fields = descriptor . constraints ?. fields || [ ] ;
331363 for ( const field of fields ) {
332- if ( ! field . path ) continue ;
364+ if ( ! field . path ) {
365+ continue ;
366+ }
333367 const paths = Array . isArray ( field . path ) ? field . path : [ field . path ] ;
334368 for ( const p of paths ) {
335369 const attr = p . replace ( '$.' , '' ) ;
336- if ( attr && ! attributes . includes ( attr ) && ! attr . startsWith ( 'type' ) &&
337- ! attr . startsWith ( 'issuer' ) && ! attr . startsWith ( '@context' ) &&
338- ! attr . startsWith ( 'proof' ) && ! attr . startsWith ( 'credentialSchema' ) &&
339- ! attr . startsWith ( 'issuanceDate' ) ) {
370+ if (
371+ attr &&
372+ ! attributes . includes ( attr ) &&
373+ ! attr . startsWith ( 'type' ) &&
374+ ! attr . startsWith ( 'issuer' ) &&
375+ ! attr . startsWith ( '@context' ) &&
376+ ! attr . startsWith ( 'proof' ) &&
377+ ! attr . startsWith ( 'credentialSchema' ) &&
378+ ! attr . startsWith ( 'issuanceDate' )
379+ ) {
340380 // Only include if the credential actually has this attribute
341- const value = attr . split ( '.' ) . reduce ( ( obj , key ) => obj ?. [ key ] , credential ) ;
381+ const value = attr
382+ . split ( '.' )
383+ . reduce ( ( obj , key ) => obj ?. [ key ] , credential ) ;
342384 if ( value !== undefined ) {
343385 attributes . push ( attr ) ;
344386 }
@@ -352,9 +394,7 @@ export function createVerificationController({
352394 }
353395
354396 function ensureDescriptorMap ( presentation ) {
355- if (
356- presentation ?. presentation_submission ?. descriptor_map ?. length > 0
357- ) {
397+ if ( presentation ?. presentation_submission ?. descriptor_map ?. length > 0 ) {
358398 return presentation ;
359399 }
360400
@@ -363,11 +403,13 @@ export function createVerificationController({
363403 return presentation ;
364404 }
365405
366- const descriptorMap = definition . input_descriptors . map ( ( descriptor , idx ) => ( {
367- id : descriptor . id ,
368- format : 'ldp_vp' ,
369- path : `$.verifiableCredential[${ idx } ]` ,
370- } ) ) ;
406+ const descriptorMap = definition . input_descriptors . map (
407+ ( descriptor , idx ) => ( {
408+ id : descriptor . id ,
409+ format : 'ldp_vp' ,
410+ path : `$.verifiableCredential[${ idx } ]` ,
411+ } ) ,
412+ ) ;
371413
372414 presentation . presentation_submission = {
373415 ...presentation . presentation_submission ,
@@ -412,8 +454,12 @@ export function createVerificationController({
412454 bbsKvacSelections . map ( async sel => {
413455 return {
414456 credential : sel . credential ,
415- witness : await credentialProvider . getMembershipWitness ( sel . credential . id ) ,
416- attributesToReveal : sel . attributesToReveal || getAttributesToRevealFromTemplate ( sel . credential ) ,
457+ witness : await credentialProvider . getMembershipWitness (
458+ sel . credential . id ,
459+ ) ,
460+ attributesToReveal :
461+ sel . attributesToReveal ||
462+ getAttributesToRevealFromTemplate ( sel . credential ) ,
417463 } ;
418464 } ) ,
419465 ) ;
@@ -425,17 +471,22 @@ export function createVerificationController({
425471 credentialsWithWitness . map ( c =>
426472 credentialServiceRPC . deriveVCFromPresentation ( {
427473 proofRequest : templateJSON ,
428- credentials : [ {
429- credential : c . credential ,
430- witness : c . witness ,
431- attributesToReveal : c . attributesToReveal ,
432- } ] ,
474+ credentials : [
475+ {
476+ credential : c . credential ,
477+ witness : c . witness ,
478+ attributesToReveal : c . attributesToReveal ,
479+ } ,
480+ ] ,
433481 } ) ,
434482 ) ,
435483 ) ;
436484 const derivedCredentials = derivedResults . flat ( ) ;
437485
438- const nonBbsCredentials = await deriveNonBbsCredentials ( sdJwtSelections , regularSelections ) ;
486+ const nonBbsCredentials = await deriveNonBbsCredentials (
487+ sdJwtSelections ,
488+ regularSelections ,
489+ ) ;
439490 const presentation = await assembleSignedPresentation (
440491 [ ...derivedCredentials , ...nonBbsCredentials ] ,
441492 keyDoc ,
@@ -444,7 +495,10 @@ export function createVerificationController({
444495 }
445496
446497 // No BBS+/KVAC: handle SD-JWT and regular only
447- const credentials = await deriveNonBbsCredentials ( sdJwtSelections , regularSelections ) ;
498+ const credentials = await deriveNonBbsCredentials (
499+ sdJwtSelections ,
500+ regularSelections ,
501+ ) ;
448502 const presentation = await assembleSignedPresentation ( credentials , keyDoc ) ;
449503 return ensureDescriptorMap ( presentation ) ;
450504 }
@@ -494,7 +548,9 @@ export function createVerificationController({
494548 }
495549
496550 const groups = getRequirementGroups ( ) ;
497- const group = groups . find ( g => g . candidates . some ( c => c . id === credentialId ) ) ;
551+ const group = groups . find ( g =>
552+ g . candidates . some ( c => c . id === credentialId ) ,
553+ ) ;
498554 if ( ! group ) {
499555 return [ ] ;
500556 }
@@ -526,7 +582,7 @@ export function createVerificationController({
526582 . map ( field => {
527583 const paths = Array . isArray ( field . path ) ? field . path : [ field . path ] ;
528584 let resolvedPath = null ;
529- let value = undefined ;
585+ let value ;
530586
531587 for ( const p of paths ) {
532588 const cleanPath = p . replace ( '$.' , '' ) ;
@@ -572,8 +628,14 @@ export function createVerificationController({
572628 isRangeProof,
573629 isOptional : field . optional === true ,
574630 ...( isRangeProof && {
575- min : field . filter . minimum ?? field . filter . exclusiveMinimum ?? field . filter . formatMinimum ,
576- max : field . filter . maximum ?? field . filter . exclusiveMaximum ?? field . filter . formatMaximum ,
631+ min :
632+ field . filter . minimum ??
633+ field . filter . exclusiveMinimum ??
634+ field . filter . formatMinimum ,
635+ max :
636+ field . filter . maximum ??
637+ field . filter . exclusiveMaximum ??
638+ field . filter . formatMaximum ,
577639 } ) ,
578640 } ;
579641 } )
@@ -586,10 +648,15 @@ export function createVerificationController({
586648
587649 for ( const group of groups ) {
588650 credential = group . candidates . find ( c => c . id === credentialId ) ;
589- if ( credential ) break ;
651+ if ( credential ) {
652+ break ;
653+ }
590654 }
591655
592- assert ( credential , `Credential ${ credentialId } not found in any descriptor group` ) ;
656+ assert (
657+ credential ,
658+ `Credential ${ credentialId } not found in any descriptor group` ,
659+ ) ;
593660
594661 return credentialProvider . isValid ( credential ) ;
595662 }
@@ -609,9 +676,9 @@ export function createVerificationController({
609676 const res = await axios . post ( templateJSON . response_url , presentation ) ;
610677 return res . data ;
611678 } catch ( err ) {
612- const status = err ?. response ?. status ;
679+ const httpStatus = err ?. response ?. status ;
613680 const isRetryable =
614- ! status || status === 429 || status >= 500 ;
681+ ! httpStatus || httpStatus === 429 || httpStatus >= 500 ;
615682
616683 if ( ! isRetryable || attempt === maxRetries - 1 ) {
617684 throw err ;
0 commit comments