@@ -2,13 +2,13 @@ import { Type } from 'class-transformer'
22import { IsEnum , IsNumber , IsString } from 'class-validator'
33
44import { JsonLdCredentialDetail , W3cCredentialSubject } from '../../../../../..'
5- import { W3cCredential } from '../../W3cCredential'
5+ import { W3cCredential , W3cCredentialOptions } from '../../W3cCredential'
66import { W3cCredentialStatus } from '../W3cCredentialStatus'
77
88// The purpose can be anything apart from this as well
99export enum BitstringStatusListCredentialStatusPurpose {
10- 'revocation' = 'revocation' ,
11- 'suspension' = 'suspension' ,
10+ Revocation = 'revocation' ,
11+ Suspension = 'suspension' ,
1212}
1313
1414export interface BitStringStatusListMessageOptions {
@@ -36,16 +36,23 @@ export class BitStringStatusListMessage {
3636 [ key : string ] : unknown | undefined
3737}
3838
39+ /**
40+ * Status list Entry, used to check status of a credential being issued or verified during presentaton.
41+ *
42+ * @see https://www.w3.org/TR/vc-bitstring-status-list/#bitstringstatuslistentry
43+ */
3944export class BitStringStatusListEntry extends W3cCredentialStatus {
40- public constructor ( options : {
41- id : string
42- serviceEndpoint : string
43- recipientKeys : string [ ]
44- routingKeys ?: string [ ]
45- accept ?: string [ ]
46- priority ?: number
47- } ) {
45+ public constructor ( options : IBitStringStatusListEntryOptions ) {
4846 super ( { ...options , type : BitStringStatusListEntry . type } )
47+
48+ if ( options ) {
49+ this . statusPurpose = options . statusPurpose
50+ this . statusListCredential = options . statusListCredential
51+ this . statusListIndex = options . statusListIndex
52+
53+ if ( options . statusSize ) this . statusSize = options . statusSize
54+ if ( options . statusMessage ) this . statusMessage = options . statusMessage
55+ }
4956 }
5057 public static type = 'BitstringStatusListEntry'
5158
@@ -75,12 +82,11 @@ export interface BitStringStatusListStatusMessage {
7582 [ key : string ] : unknown
7683}
7784
78- export interface IBitStringStatusListCredentialStatus {
85+ export interface IBitStringStatusListEntryOptions {
7986 id : string
80- // Since currenlty we are only trying to support 'BitStringStatusListEntry'
8187 type : 'BitstringStatusListEntry'
8288 statusPurpose : BitstringStatusListCredentialStatusPurpose
83- // Unique identifier for the specific credential
89+ // Unique identifier for specific credential
8490 statusListIndex : string
8591 // Must be url referencing to a VC of type 'BitstringStatusListCredential'
8692 statusListCredential : string
@@ -105,28 +111,33 @@ export class BitStringStatusListCredentialDetail extends JsonLdCredentialDetail
105111 public credential ! : BitStringStatusListCredentialStatus
106112}
107113
114+ /**
115+ * StatusListCredential describes the format of the verifiable credential that encapsulates the status list.
116+ *
117+ * @see https://www.w3.org/TR/vc-bitstring-status-list/#bitstringstatuslistcredential
118+ */
108119export class BitStringStatusListCredential extends W3cCredential {
109- public constructor ( options : {
110- id : string
111- serviceEndpoint : string
112- recipientKeys : string [ ]
113- routingKeys ?: string [ ] | undefined
114- accept ?: string [ ]
115- priority ?: number
116- issuer : string
117- issuanceDate : string
118- credentialSubject : BitStringStatusListCredentialSubject
119- } ) {
120+ public constructor ( options : IBitStringStatusListCredentialOptions ) {
120121 super ( {
121122 ...options ,
122- type : [ 'VerifiableCredential' , BitStringStatusListEntry . type ] ,
123+ type : BitStringStatusListCredential . type ,
123124 } )
125+
126+ if ( options ) {
127+ this . credentialSubject = options . credentialSubject
128+ }
124129 }
130+ public static type = [ 'VerifiableCredential' , 'BitstringStatusListCredential' ]
125131
126132 @IsString ( )
127133 public credentialSubject ! : BitStringStatusListCredentialSubject
128134}
129135
136+ export interface IBitStringStatusListCredentialOptions extends Omit < W3cCredentialOptions , 'credentialStatus' > {
137+ type : [ 'VerifiableCredential' , 'BitstringStatusListCredential' ]
138+ credentialSubject : BitStringStatusListCredentialSubject
139+ }
140+
130141// Define an interface for `credentialSubject`
131142export interface BitStringStatusListCredentialSubject extends W3cCredentialSubject {
132143 type : 'BitstringStatusList'
0 commit comments