@@ -23,17 +23,30 @@ export const ISOTimeStamp = ({date = new Date()} = {}) => {
23
23
} ;
24
24
25
25
export const getCredentialStatus = async ( { verifiableCredential} ) => {
26
+ // get SLC for the VC
26
27
const { credentialStatus} = verifiableCredential ;
27
- const { statusListCredential} = credentialStatus ;
28
- // get StatusList Credential for the VC
29
- const { data : slc } = await httpClient . get (
30
- statusListCredential , { agent} ) ;
31
- const { credentialSubject : { encodedList} } = slc ;
28
+ if ( Array . isArray ( credentialStatus ) ) {
29
+ throw new Error ( 'Multiple credential statuses not supported.' ) ;
30
+ }
31
+ let slcUrl ;
32
+ let statusListIndexProperty ;
33
+ if ( credentialStatus . type === 'RevocationList2020Status' ) {
34
+ slcUrl = credentialStatus . revocationListCredential ;
35
+ statusListIndexProperty = 'revocationListIndex' ;
36
+ } else {
37
+ slcUrl = credentialStatus . statusListCredential ;
38
+ statusListIndexProperty = 'statusListIndex' ;
39
+ }
40
+ if ( ! slcUrl ) {
41
+ throw new Error ( 'Status list credential missing from credential status.' ) ;
42
+ }
43
+ const { data : slc } = await httpClient . get ( slcUrl , { agent} ) ;
44
+ const { encodedList} = slc . credentialSubject ;
32
45
const list = await decodeList ( { encodedList} ) ;
33
46
const statusListIndex = parseInt (
34
- credentialStatus . statusListIndex , 10 ) ;
47
+ credentialStatus [ statusListIndexProperty ] , 10 ) ;
35
48
const status = list . getStatus ( statusListIndex ) ;
36
- return { status, statusListCredential} ;
49
+ return { status, statusListCredential : slcUrl } ;
37
50
} ;
38
51
39
52
export const issueVc = async ( { issuer} ) => {
@@ -102,8 +115,5 @@ export async function updateStatus({
102
115
should . not . exist ( err2 ) ;
103
116
should . exist ( result2 ) ;
104
117
statusCode2 . should . equal ( 204 ) ;
105
- // get the status of the VC
106
- const { status} = await getCredentialStatus ( { verifiableCredential : vc } ) ;
107
- status . should . equal ( true ) ;
108
118
return vc ;
109
119
}
0 commit comments