@sphereon/ssi-types 0.18.2-next.9 → 0.18.2-unstable.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/README.md +49 -49
- package/dist/index.d.ts +3 -3
- package/dist/index.js +19 -19
- package/dist/mapper/credential-mapper.d.ts +107 -107
- package/dist/mapper/credential-mapper.js +556 -556
- package/dist/mapper/index.d.ts +1 -1
- package/dist/mapper/index.js +17 -17
- package/dist/types/did.d.ts +35 -35
- package/dist/types/did.js +75 -75
- package/dist/types/generic.d.ts +7 -7
- package/dist/types/generic.js +2 -2
- package/dist/types/index.d.ts +6 -6
- package/dist/types/index.js +22 -22
- package/dist/types/pex.d.ts +35 -35
- package/dist/types/pex.js +2 -2
- package/dist/types/sd-jwt-vc.d.ts +170 -170
- package/dist/types/sd-jwt-vc.js +71 -71
- package/dist/types/vc.d.ts +23 -23
- package/dist/types/vc.js +23 -23
- package/dist/types/w3c-vc.d.ts +247 -247
- package/dist/types/w3c-vc.js +29 -29
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +17 -17
- package/dist/utils/object.d.ts +6 -6
- package/dist/utils/object.js +20 -20
- package/package.json +2 -2
- package/src/index.ts +3 -3
- package/src/mapper/credential-mapper.ts +686 -686
- package/src/mapper/index.ts +1 -1
- package/src/types/generic.ts +8 -8
- package/src/types/index.ts +6 -6
- package/src/types/pex.ts +36 -36
- package/src/types/sd-jwt-vc.ts +232 -232
- package/src/types/vc.ts +62 -62
- package/src/types/w3c-vc.ts +300 -300
- package/src/utils/index.ts +1 -1
- package/src/utils/object.ts +19 -19
package/src/types/w3c-vc.ts
CHANGED
|
@@ -1,300 +1,300 @@
|
|
|
1
|
-
import { PresentationSubmission } from './pex'
|
|
2
|
-
import { IProofPurpose, IProofType } from './did'
|
|
3
|
-
import { OriginalType, WrappedVerifiableCredential, WrappedVerifiablePresentation } from './vc'
|
|
4
|
-
|
|
5
|
-
export type AdditionalClaims = Record<string, any>
|
|
6
|
-
|
|
7
|
-
export type IIssuerId = string
|
|
8
|
-
|
|
9
|
-
export interface ICredential {
|
|
10
|
-
'@context': ICredentialContextType | ICredentialContextType[]
|
|
11
|
-
type: string[]
|
|
12
|
-
credentialSchema?: undefined | ICredentialSchemaType | ICredentialSchemaType[]
|
|
13
|
-
// If iss is present, the value MUST be used to set the issuer property of the new credential JSON object or the holderDID property of the new presentation JSON object.
|
|
14
|
-
issuer: IIssuerId | IIssuer
|
|
15
|
-
// If nbf is present, the UNIX timestamp MUST be converted to an [XMLSCHEMA11-2] date-time, and MUST be used to set the value of the issuanceDate property of the new JSON object.
|
|
16
|
-
issuanceDate: string
|
|
17
|
-
// If sub is present, the value MUST be used to set the value of the id property of credentialSubject of the new credential JSON object.
|
|
18
|
-
credentialSubject: (ICredentialSubject & AdditionalClaims) | (ICredentialSubject & AdditionalClaims)[]
|
|
19
|
-
// If exp is present, the UNIX timestamp MUST be converted to an [XMLSCHEMA11-2] date-time, and MUST be used to set the value of the expirationDate property of credentialSubject of the new JSON object.
|
|
20
|
-
expirationDate?: string
|
|
21
|
-
// If jti is present, the value MUST be used to set the value of the id property of the new JSON object.
|
|
22
|
-
id?: string
|
|
23
|
-
credentialStatus?: ICredentialStatus
|
|
24
|
-
description?: string
|
|
25
|
-
name?: string
|
|
26
|
-
|
|
27
|
-
[x: string]: any
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface ICredentialSubject {
|
|
31
|
-
id?: string
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export type ICredentialContextType = (ICredentialContext & AdditionalClaims) | string
|
|
35
|
-
|
|
36
|
-
export interface ICredentialContext {
|
|
37
|
-
name?: string
|
|
38
|
-
did?: string
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export type ICredentialSchemaType = ICredentialSchema | string
|
|
42
|
-
|
|
43
|
-
export interface ICredentialSchema {
|
|
44
|
-
id: string
|
|
45
|
-
type?: string
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface IProof {
|
|
49
|
-
type: IProofType | string // The proof type
|
|
50
|
-
created: string // The ISO8601 date-time string for creation
|
|
51
|
-
proofPurpose: IProofPurpose | string // The specific intent for the proof
|
|
52
|
-
verificationMethod: string // A set of parameters required to independently verify the proof
|
|
53
|
-
challenge?: string // A challenge to protect against replay attacks
|
|
54
|
-
domain?: string // A string restricting the (usage of a) proof to the domain and protects against replay attacks
|
|
55
|
-
proofValue?: string // One of any number of valid representations of proof values
|
|
56
|
-
jws?: string // JWS based proof
|
|
57
|
-
jwt?: string //Jwt 2020 proof. Used to map a JWT VC onto a uniform presentation, and retain access to the original JWT
|
|
58
|
-
nonce?: string // Similar to challenge. A nonce to protect against replay attacks, used in some ZKP proofs
|
|
59
|
-
requiredRevealStatements?: string[] // The parts of the proof that must be revealed in a derived proof
|
|
60
|
-
|
|
61
|
-
[x: string]: any // Any because we want to be able to access value1.value2.value3, which unknown does not allow for without a cast
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface ICredentialStatus {
|
|
65
|
-
id: string
|
|
66
|
-
type: string
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface IIssuer {
|
|
70
|
-
id: string
|
|
71
|
-
|
|
72
|
-
[x: string]: any
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface IHasProof {
|
|
76
|
-
proof: IProof | IProof[]
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export type IVerifiableCredential = ICredential & IHasProof
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Represents a Json Web Token in compact form.
|
|
83
|
-
*/
|
|
84
|
-
export type CompactJWT = string
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Represents a signed Verifiable Credential (includes proof), in either JSON, compact JWT or compact SD-JWT VC format.
|
|
88
|
-
* See {@link https://www.w3.org/TR/vc-data-model/#credentials | VC data model}
|
|
89
|
-
* See {@link https://www.w3.org/TR/vc-data-model/#proof-formats | proof formats}
|
|
90
|
-
*/
|
|
91
|
-
export type W3CVerifiableCredential = IVerifiableCredential | CompactJWT
|
|
92
|
-
|
|
93
|
-
export interface IPresentation {
|
|
94
|
-
id?: string
|
|
95
|
-
'@context': ICredentialContextType | ICredentialContextType[]
|
|
96
|
-
type?: string | string[]
|
|
97
|
-
verifiableCredential?: W3CVerifiableCredential[]
|
|
98
|
-
presentation_submission?: PresentationSubmission
|
|
99
|
-
holder?: string
|
|
100
|
-
verifier?: string
|
|
101
|
-
|
|
102
|
-
[x: string]: any
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export type IVerifiablePresentation = IPresentation & IHasProof
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Represents a signed Verifiable Presentation (includes proof), in either JSON or compact JWT format.
|
|
109
|
-
* See {@link https://www.w3.org/TR/vc-data-model/#presentations | VC data model}
|
|
110
|
-
* See {@link https://www.w3.org/TR/vc-data-model/#proof-formats | proof formats}
|
|
111
|
-
*/
|
|
112
|
-
export type W3CVerifiablePresentation = IVerifiablePresentation | CompactJWT
|
|
113
|
-
|
|
114
|
-
export interface WrappedW3CVerifiableCredential {
|
|
115
|
-
/**
|
|
116
|
-
* Original VC that we've received
|
|
117
|
-
*/
|
|
118
|
-
original: W3CVerifiableCredential | JwtDecodedVerifiableCredential
|
|
119
|
-
/**
|
|
120
|
-
* In case of JWT credential it will be the decoded version. In other cases it will be the same as original one
|
|
121
|
-
*/
|
|
122
|
-
decoded: JwtDecodedVerifiableCredential | IVerifiableCredential
|
|
123
|
-
/**
|
|
124
|
-
* Type of this credential. Supported types are json-ld, jwt (decoded/encoded)
|
|
125
|
-
*/
|
|
126
|
-
type: OriginalType.JSONLD | OriginalType.JWT_ENCODED | OriginalType.JWT_DECODED
|
|
127
|
-
/**
|
|
128
|
-
* The claim format, typically used during exchange transport protocols
|
|
129
|
-
*/
|
|
130
|
-
format: 'jwt_vc' | 'ldp_vc' | 'ldp' | 'jwt'
|
|
131
|
-
/**
|
|
132
|
-
* Internal stable representation of a Credential
|
|
133
|
-
*/
|
|
134
|
-
credential: IVerifiableCredential
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export interface WrappedW3CVerifiablePresentation {
|
|
138
|
-
/**
|
|
139
|
-
* Original VP that we've received
|
|
140
|
-
*/
|
|
141
|
-
original: W3CVerifiablePresentation | JwtDecodedVerifiablePresentation
|
|
142
|
-
/**
|
|
143
|
-
* In case of JWT VP it will be the decoded version. In other cases it will be the same as original one
|
|
144
|
-
*/
|
|
145
|
-
decoded: JwtDecodedVerifiablePresentation | IVerifiablePresentation
|
|
146
|
-
/**
|
|
147
|
-
* Type of this Presentation. Supported types are json-ld and jwt (decoded/encoded) and sd-jwt-vc (decoded/encoded)
|
|
148
|
-
*/
|
|
149
|
-
type: OriginalType.JSONLD | OriginalType.JWT_ENCODED | OriginalType.JWT_DECODED
|
|
150
|
-
/**
|
|
151
|
-
* The claim format, typically used during exchange transport protocols
|
|
152
|
-
*/
|
|
153
|
-
format: 'jwt_vp' | 'ldp_vp'
|
|
154
|
-
/**
|
|
155
|
-
* Internal stable representation of a Presentation without proofs, created based on https://www.w3.org/TR/vc-data-model/#jwt-decoding
|
|
156
|
-
*/
|
|
157
|
-
presentation: UniformVerifiablePresentation
|
|
158
|
-
/**
|
|
159
|
-
* Wrapped Verifiable Credentials belonging to the Presentation
|
|
160
|
-
*/
|
|
161
|
-
vcs: WrappedW3CVerifiableCredential[]
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export interface UniformVerifiablePresentation {
|
|
165
|
-
'@context': ICredentialContextType | ICredentialContextType[]
|
|
166
|
-
type: string | string[]
|
|
167
|
-
verifiableCredential: WrappedW3CVerifiableCredential[]
|
|
168
|
-
presentation_submission?: PresentationSubmission
|
|
169
|
-
holder?: string
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export interface JwtDecodedVerifiableCredential {
|
|
173
|
-
vc: IVerifiableCredential
|
|
174
|
-
exp: string
|
|
175
|
-
iss: string
|
|
176
|
-
nbf: string
|
|
177
|
-
sub: string
|
|
178
|
-
jti: string
|
|
179
|
-
|
|
180
|
-
[x: string]: any
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export interface JwtDecodedVerifiablePresentation {
|
|
184
|
-
vp: IVerifiablePresentation
|
|
185
|
-
exp: string
|
|
186
|
-
iss: string
|
|
187
|
-
nbf: string
|
|
188
|
-
sub: string
|
|
189
|
-
jti: string
|
|
190
|
-
aud: string
|
|
191
|
-
iat: string
|
|
192
|
-
|
|
193
|
-
[x: string]: any
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
export const JWT_PROOF_TYPE_2020 = 'JwtProof2020'
|
|
197
|
-
|
|
198
|
-
export interface IVerifyStatusResult {
|
|
199
|
-
verified: boolean
|
|
200
|
-
/**
|
|
201
|
-
* Optional Error object for the
|
|
202
|
-
* but currently the machine readable errors are not exported from DID-JWT package to be imported here
|
|
203
|
-
*/
|
|
204
|
-
error?: IError | undefined
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Other options can be specified for verification.
|
|
208
|
-
* They will be forwarded to the lower level modules. that performt the checks
|
|
209
|
-
*/
|
|
210
|
-
[x: string]: any
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export interface IVerifyResult {
|
|
214
|
-
/**
|
|
215
|
-
* This value is used to transmit the global result of verification.
|
|
216
|
-
*/
|
|
217
|
-
verified: boolean
|
|
218
|
-
|
|
219
|
-
results?: [
|
|
220
|
-
{
|
|
221
|
-
credential?: ICredential
|
|
222
|
-
presentation?: IPresentation
|
|
223
|
-
verified: boolean
|
|
224
|
-
error?: IError
|
|
225
|
-
log: [{ id: string; valid: boolean }]
|
|
226
|
-
}
|
|
227
|
-
]
|
|
228
|
-
|
|
229
|
-
statusResult?: IVerifyStatusResult
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Optional Error object for the
|
|
233
|
-
* but currently the machine readable errors are not exported from DID-JWT package to be imported here
|
|
234
|
-
*/
|
|
235
|
-
error?: IError | undefined
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Other options can be specified for verification.
|
|
239
|
-
* They will be forwarded to the lower level modules. that performt the checks
|
|
240
|
-
*/
|
|
241
|
-
[x: string]: any
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* An error object, which can contain a code.
|
|
246
|
-
* @beta
|
|
247
|
-
*/
|
|
248
|
-
export interface IError {
|
|
249
|
-
name?: string
|
|
250
|
-
|
|
251
|
-
errors?: IError[]
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* The details of the error being thrown or forwarded
|
|
255
|
-
*/
|
|
256
|
-
message?: string
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* The stack of the error
|
|
260
|
-
*/
|
|
261
|
-
stack?: string | string[]
|
|
262
|
-
|
|
263
|
-
details?: IErrorDetails
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* The code for the error being throw
|
|
267
|
-
*/
|
|
268
|
-
errorCode?: string
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
export interface IErrorDetails {
|
|
272
|
-
code?: string
|
|
273
|
-
url?: string
|
|
274
|
-
cause?: IError
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
export enum StatusListType {
|
|
278
|
-
StatusList2021 = 'StatusList2021',
|
|
279
|
-
}
|
|
280
|
-
export type StatusPurpose2021 = 'revocation' | 'suspension' | string
|
|
281
|
-
export enum StatusListCredentialIdMode {
|
|
282
|
-
ISSUANCE = 'ISSUANCE',
|
|
283
|
-
PERSISTENCE = 'PERSISTENCE',
|
|
284
|
-
NEVER = 'NEVER',
|
|
285
|
-
}
|
|
286
|
-
export type StatusListIndexingDirection = 'rightToLeft'
|
|
287
|
-
export enum StatusListDriverType {
|
|
288
|
-
AGENT_TYPEORM = 'agent_typeorm',
|
|
289
|
-
AGENT_KV_STORE = 'agent_kv_store',
|
|
290
|
-
GITHUB = 'github',
|
|
291
|
-
AGENT_FILESYSTEM = 'agent_filesystem',
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
export function isWrappedW3CVerifiableCredential(vc: WrappedVerifiableCredential): vc is WrappedW3CVerifiableCredential {
|
|
295
|
-
return vc.format === 'jwt_vc' || vc.format === 'ldp_vc'
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
export function isWrappedW3CVerifiablePresentation(vp: WrappedVerifiablePresentation): vp is WrappedW3CVerifiablePresentation {
|
|
299
|
-
return vp.format === 'jwt_vp' || vp.format === 'ldp_vp'
|
|
300
|
-
}
|
|
1
|
+
import { PresentationSubmission } from './pex'
|
|
2
|
+
import { IProofPurpose, IProofType } from './did'
|
|
3
|
+
import { OriginalType, WrappedVerifiableCredential, WrappedVerifiablePresentation } from './vc'
|
|
4
|
+
|
|
5
|
+
export type AdditionalClaims = Record<string, any>
|
|
6
|
+
|
|
7
|
+
export type IIssuerId = string
|
|
8
|
+
|
|
9
|
+
export interface ICredential {
|
|
10
|
+
'@context': ICredentialContextType | ICredentialContextType[]
|
|
11
|
+
type: string[]
|
|
12
|
+
credentialSchema?: undefined | ICredentialSchemaType | ICredentialSchemaType[]
|
|
13
|
+
// If iss is present, the value MUST be used to set the issuer property of the new credential JSON object or the holderDID property of the new presentation JSON object.
|
|
14
|
+
issuer: IIssuerId | IIssuer
|
|
15
|
+
// If nbf is present, the UNIX timestamp MUST be converted to an [XMLSCHEMA11-2] date-time, and MUST be used to set the value of the issuanceDate property of the new JSON object.
|
|
16
|
+
issuanceDate: string
|
|
17
|
+
// If sub is present, the value MUST be used to set the value of the id property of credentialSubject of the new credential JSON object.
|
|
18
|
+
credentialSubject: (ICredentialSubject & AdditionalClaims) | (ICredentialSubject & AdditionalClaims)[]
|
|
19
|
+
// If exp is present, the UNIX timestamp MUST be converted to an [XMLSCHEMA11-2] date-time, and MUST be used to set the value of the expirationDate property of credentialSubject of the new JSON object.
|
|
20
|
+
expirationDate?: string
|
|
21
|
+
// If jti is present, the value MUST be used to set the value of the id property of the new JSON object.
|
|
22
|
+
id?: string
|
|
23
|
+
credentialStatus?: ICredentialStatus
|
|
24
|
+
description?: string
|
|
25
|
+
name?: string
|
|
26
|
+
|
|
27
|
+
[x: string]: any
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ICredentialSubject {
|
|
31
|
+
id?: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type ICredentialContextType = (ICredentialContext & AdditionalClaims) | string
|
|
35
|
+
|
|
36
|
+
export interface ICredentialContext {
|
|
37
|
+
name?: string
|
|
38
|
+
did?: string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type ICredentialSchemaType = ICredentialSchema | string
|
|
42
|
+
|
|
43
|
+
export interface ICredentialSchema {
|
|
44
|
+
id: string
|
|
45
|
+
type?: string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface IProof {
|
|
49
|
+
type: IProofType | string // The proof type
|
|
50
|
+
created: string // The ISO8601 date-time string for creation
|
|
51
|
+
proofPurpose: IProofPurpose | string // The specific intent for the proof
|
|
52
|
+
verificationMethod: string // A set of parameters required to independently verify the proof
|
|
53
|
+
challenge?: string // A challenge to protect against replay attacks
|
|
54
|
+
domain?: string // A string restricting the (usage of a) proof to the domain and protects against replay attacks
|
|
55
|
+
proofValue?: string // One of any number of valid representations of proof values
|
|
56
|
+
jws?: string // JWS based proof
|
|
57
|
+
jwt?: string //Jwt 2020 proof. Used to map a JWT VC onto a uniform presentation, and retain access to the original JWT
|
|
58
|
+
nonce?: string // Similar to challenge. A nonce to protect against replay attacks, used in some ZKP proofs
|
|
59
|
+
requiredRevealStatements?: string[] // The parts of the proof that must be revealed in a derived proof
|
|
60
|
+
|
|
61
|
+
[x: string]: any // Any because we want to be able to access value1.value2.value3, which unknown does not allow for without a cast
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface ICredentialStatus {
|
|
65
|
+
id: string
|
|
66
|
+
type: string
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface IIssuer {
|
|
70
|
+
id: string
|
|
71
|
+
|
|
72
|
+
[x: string]: any
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface IHasProof {
|
|
76
|
+
proof: IProof | IProof[]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type IVerifiableCredential = ICredential & IHasProof
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Represents a Json Web Token in compact form.
|
|
83
|
+
*/
|
|
84
|
+
export type CompactJWT = string
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Represents a signed Verifiable Credential (includes proof), in either JSON, compact JWT or compact SD-JWT VC format.
|
|
88
|
+
* See {@link https://www.w3.org/TR/vc-data-model/#credentials | VC data model}
|
|
89
|
+
* See {@link https://www.w3.org/TR/vc-data-model/#proof-formats | proof formats}
|
|
90
|
+
*/
|
|
91
|
+
export type W3CVerifiableCredential = IVerifiableCredential | CompactJWT
|
|
92
|
+
|
|
93
|
+
export interface IPresentation {
|
|
94
|
+
id?: string
|
|
95
|
+
'@context': ICredentialContextType | ICredentialContextType[]
|
|
96
|
+
type?: string | string[]
|
|
97
|
+
verifiableCredential?: W3CVerifiableCredential[]
|
|
98
|
+
presentation_submission?: PresentationSubmission
|
|
99
|
+
holder?: string
|
|
100
|
+
verifier?: string
|
|
101
|
+
|
|
102
|
+
[x: string]: any
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export type IVerifiablePresentation = IPresentation & IHasProof
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Represents a signed Verifiable Presentation (includes proof), in either JSON or compact JWT format.
|
|
109
|
+
* See {@link https://www.w3.org/TR/vc-data-model/#presentations | VC data model}
|
|
110
|
+
* See {@link https://www.w3.org/TR/vc-data-model/#proof-formats | proof formats}
|
|
111
|
+
*/
|
|
112
|
+
export type W3CVerifiablePresentation = IVerifiablePresentation | CompactJWT
|
|
113
|
+
|
|
114
|
+
export interface WrappedW3CVerifiableCredential {
|
|
115
|
+
/**
|
|
116
|
+
* Original VC that we've received
|
|
117
|
+
*/
|
|
118
|
+
original: W3CVerifiableCredential | JwtDecodedVerifiableCredential
|
|
119
|
+
/**
|
|
120
|
+
* In case of JWT credential it will be the decoded version. In other cases it will be the same as original one
|
|
121
|
+
*/
|
|
122
|
+
decoded: JwtDecodedVerifiableCredential | IVerifiableCredential
|
|
123
|
+
/**
|
|
124
|
+
* Type of this credential. Supported types are json-ld, jwt (decoded/encoded)
|
|
125
|
+
*/
|
|
126
|
+
type: OriginalType.JSONLD | OriginalType.JWT_ENCODED | OriginalType.JWT_DECODED
|
|
127
|
+
/**
|
|
128
|
+
* The claim format, typically used during exchange transport protocols
|
|
129
|
+
*/
|
|
130
|
+
format: 'jwt_vc' | 'ldp_vc' | 'ldp' | 'jwt'
|
|
131
|
+
/**
|
|
132
|
+
* Internal stable representation of a Credential
|
|
133
|
+
*/
|
|
134
|
+
credential: IVerifiableCredential
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface WrappedW3CVerifiablePresentation {
|
|
138
|
+
/**
|
|
139
|
+
* Original VP that we've received
|
|
140
|
+
*/
|
|
141
|
+
original: W3CVerifiablePresentation | JwtDecodedVerifiablePresentation
|
|
142
|
+
/**
|
|
143
|
+
* In case of JWT VP it will be the decoded version. In other cases it will be the same as original one
|
|
144
|
+
*/
|
|
145
|
+
decoded: JwtDecodedVerifiablePresentation | IVerifiablePresentation
|
|
146
|
+
/**
|
|
147
|
+
* Type of this Presentation. Supported types are json-ld and jwt (decoded/encoded) and sd-jwt-vc (decoded/encoded)
|
|
148
|
+
*/
|
|
149
|
+
type: OriginalType.JSONLD | OriginalType.JWT_ENCODED | OriginalType.JWT_DECODED
|
|
150
|
+
/**
|
|
151
|
+
* The claim format, typically used during exchange transport protocols
|
|
152
|
+
*/
|
|
153
|
+
format: 'jwt_vp' | 'ldp_vp'
|
|
154
|
+
/**
|
|
155
|
+
* Internal stable representation of a Presentation without proofs, created based on https://www.w3.org/TR/vc-data-model/#jwt-decoding
|
|
156
|
+
*/
|
|
157
|
+
presentation: UniformVerifiablePresentation
|
|
158
|
+
/**
|
|
159
|
+
* Wrapped Verifiable Credentials belonging to the Presentation
|
|
160
|
+
*/
|
|
161
|
+
vcs: WrappedW3CVerifiableCredential[]
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface UniformVerifiablePresentation {
|
|
165
|
+
'@context': ICredentialContextType | ICredentialContextType[]
|
|
166
|
+
type: string | string[]
|
|
167
|
+
verifiableCredential: WrappedW3CVerifiableCredential[]
|
|
168
|
+
presentation_submission?: PresentationSubmission
|
|
169
|
+
holder?: string
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface JwtDecodedVerifiableCredential {
|
|
173
|
+
vc: IVerifiableCredential
|
|
174
|
+
exp: string
|
|
175
|
+
iss: string
|
|
176
|
+
nbf: string
|
|
177
|
+
sub: string
|
|
178
|
+
jti: string
|
|
179
|
+
|
|
180
|
+
[x: string]: any
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface JwtDecodedVerifiablePresentation {
|
|
184
|
+
vp: IVerifiablePresentation
|
|
185
|
+
exp: string
|
|
186
|
+
iss: string
|
|
187
|
+
nbf: string
|
|
188
|
+
sub: string
|
|
189
|
+
jti: string
|
|
190
|
+
aud: string
|
|
191
|
+
iat: string
|
|
192
|
+
|
|
193
|
+
[x: string]: any
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export const JWT_PROOF_TYPE_2020 = 'JwtProof2020'
|
|
197
|
+
|
|
198
|
+
export interface IVerifyStatusResult {
|
|
199
|
+
verified: boolean
|
|
200
|
+
/**
|
|
201
|
+
* Optional Error object for the
|
|
202
|
+
* but currently the machine readable errors are not exported from DID-JWT package to be imported here
|
|
203
|
+
*/
|
|
204
|
+
error?: IError | undefined
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Other options can be specified for verification.
|
|
208
|
+
* They will be forwarded to the lower level modules. that performt the checks
|
|
209
|
+
*/
|
|
210
|
+
[x: string]: any
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface IVerifyResult {
|
|
214
|
+
/**
|
|
215
|
+
* This value is used to transmit the global result of verification.
|
|
216
|
+
*/
|
|
217
|
+
verified: boolean
|
|
218
|
+
|
|
219
|
+
results?: [
|
|
220
|
+
{
|
|
221
|
+
credential?: ICredential
|
|
222
|
+
presentation?: IPresentation
|
|
223
|
+
verified: boolean
|
|
224
|
+
error?: IError
|
|
225
|
+
log: [{ id: string; valid: boolean }]
|
|
226
|
+
}
|
|
227
|
+
]
|
|
228
|
+
|
|
229
|
+
statusResult?: IVerifyStatusResult
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Optional Error object for the
|
|
233
|
+
* but currently the machine readable errors are not exported from DID-JWT package to be imported here
|
|
234
|
+
*/
|
|
235
|
+
error?: IError | undefined
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Other options can be specified for verification.
|
|
239
|
+
* They will be forwarded to the lower level modules. that performt the checks
|
|
240
|
+
*/
|
|
241
|
+
[x: string]: any
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* An error object, which can contain a code.
|
|
246
|
+
* @beta
|
|
247
|
+
*/
|
|
248
|
+
export interface IError {
|
|
249
|
+
name?: string
|
|
250
|
+
|
|
251
|
+
errors?: IError[]
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* The details of the error being thrown or forwarded
|
|
255
|
+
*/
|
|
256
|
+
message?: string
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* The stack of the error
|
|
260
|
+
*/
|
|
261
|
+
stack?: string | string[]
|
|
262
|
+
|
|
263
|
+
details?: IErrorDetails
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* The code for the error being throw
|
|
267
|
+
*/
|
|
268
|
+
errorCode?: string
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export interface IErrorDetails {
|
|
272
|
+
code?: string
|
|
273
|
+
url?: string
|
|
274
|
+
cause?: IError
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export enum StatusListType {
|
|
278
|
+
StatusList2021 = 'StatusList2021',
|
|
279
|
+
}
|
|
280
|
+
export type StatusPurpose2021 = 'revocation' | 'suspension' | string
|
|
281
|
+
export enum StatusListCredentialIdMode {
|
|
282
|
+
ISSUANCE = 'ISSUANCE',
|
|
283
|
+
PERSISTENCE = 'PERSISTENCE',
|
|
284
|
+
NEVER = 'NEVER',
|
|
285
|
+
}
|
|
286
|
+
export type StatusListIndexingDirection = 'rightToLeft'
|
|
287
|
+
export enum StatusListDriverType {
|
|
288
|
+
AGENT_TYPEORM = 'agent_typeorm',
|
|
289
|
+
AGENT_KV_STORE = 'agent_kv_store',
|
|
290
|
+
GITHUB = 'github',
|
|
291
|
+
AGENT_FILESYSTEM = 'agent_filesystem',
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export function isWrappedW3CVerifiableCredential(vc: WrappedVerifiableCredential): vc is WrappedW3CVerifiableCredential {
|
|
295
|
+
return vc.format === 'jwt_vc' || vc.format === 'ldp_vc'
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export function isWrappedW3CVerifiablePresentation(vp: WrappedVerifiablePresentation): vp is WrappedW3CVerifiablePresentation {
|
|
299
|
+
return vp.format === 'jwt_vp' || vp.format === 'ldp_vp'
|
|
300
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './object'
|
|
1
|
+
export * from './object'
|
package/src/utils/object.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export class ObjectUtils {
|
|
2
|
-
public static asArray(value: unknown) {
|
|
3
|
-
return Array.isArray(value) ? value : [value]
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
public static isObject(value: unknown) {
|
|
7
|
-
return Object.prototype.toString.call(value) === '[object Object]'
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
public static isUrlAbsolute(url: string) {
|
|
11
|
-
// regex to check for absolute IRI (starting scheme and ':') or blank node IRI
|
|
12
|
-
const isAbsoluteRegex = /^([A-Za-z][A-Za-z0-9+-.]*|_):[^\s]*$/
|
|
13
|
-
ObjectUtils.isString(url) && isAbsoluteRegex.test(url)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
public static isString(value: unknown): value is string {
|
|
17
|
-
return typeof value === 'string' || Object.prototype.toString.call(value) === '[object String]'
|
|
18
|
-
}
|
|
19
|
-
}
|
|
1
|
+
export class ObjectUtils {
|
|
2
|
+
public static asArray(value: unknown) {
|
|
3
|
+
return Array.isArray(value) ? value : [value]
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
public static isObject(value: unknown) {
|
|
7
|
+
return Object.prototype.toString.call(value) === '[object Object]'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public static isUrlAbsolute(url: string) {
|
|
11
|
+
// regex to check for absolute IRI (starting scheme and ':') or blank node IRI
|
|
12
|
+
const isAbsoluteRegex = /^([A-Za-z][A-Za-z0-9+-.]*|_):[^\s]*$/
|
|
13
|
+
ObjectUtils.isString(url) && isAbsoluteRegex.test(url)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public static isString(value: unknown): value is string {
|
|
17
|
+
return typeof value === 'string' || Object.prototype.toString.call(value) === '[object String]'
|
|
18
|
+
}
|
|
19
|
+
}
|