@sphereon/ssi-types 0.8.1-unstable.9 → 0.9.0
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/dist/mapper/credential-mapper.d.ts +34 -11
- package/dist/mapper/credential-mapper.d.ts.map +1 -1
- package/dist/mapper/credential-mapper.js +169 -48
- package/dist/mapper/credential-mapper.js.map +1 -1
- package/dist/types/did.d.ts +2 -1
- package/dist/types/did.d.ts.map +1 -1
- package/dist/types/did.js +1 -0
- package/dist/types/did.js.map +1 -1
- package/dist/types/vc.d.ts +49 -24
- package/dist/types/vc.d.ts.map +1 -1
- package/dist/types/vc.js +7 -1
- package/dist/types/vc.js.map +1 -1
- package/package.json +3 -2
- package/src/mapper/credential-mapper.ts +219 -63
- package/src/types/did.ts +1 -0
- package/src/types/vc.ts +51 -25
package/src/types/vc.ts
CHANGED
|
@@ -1,42 +1,40 @@
|
|
|
1
1
|
import { PresentationSubmission } from './pex'
|
|
2
2
|
import { IProofPurpose, IProofType } from './did'
|
|
3
3
|
|
|
4
|
-
type
|
|
4
|
+
export type AdditionalClaims = Record<string, any>
|
|
5
|
+
|
|
6
|
+
export type IIssuerId = string
|
|
5
7
|
|
|
6
8
|
export interface ICredential {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
'@context': ICredentialContextType | ICredentialContextType[]
|
|
10
|
+
type: string[]
|
|
11
|
+
credentialSchema?: undefined | ICredentialSchemaType | ICredentialSchemaType[]
|
|
9
12
|
// If iss is present, the value MUST be used to set the issuer property of the new credential JSON object or the holder property of the new presentation JSON object.
|
|
10
|
-
issuer:
|
|
13
|
+
issuer: IIssuerId | IIssuer
|
|
11
14
|
// 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.
|
|
12
15
|
issuanceDate: string
|
|
13
16
|
// 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.
|
|
14
|
-
credentialSubject: ICredentialSubject &
|
|
17
|
+
credentialSubject: (ICredentialSubject & AdditionalClaims) | (ICredentialSubject & AdditionalClaims)[]
|
|
18
|
+
// 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.
|
|
19
|
+
expirationDate?: string
|
|
15
20
|
// If jti is present, the value MUST be used to set the value of the id property of the new JSON object.
|
|
16
21
|
id?: string
|
|
17
|
-
'@context': ICredentialContextType[] | ICredentialContextType
|
|
18
22
|
credentialStatus?: ICredentialStatus
|
|
19
|
-
credentialSchema?: undefined | ICredentialSchemaType | ICredentialSchemaType[]
|
|
20
23
|
description?: string
|
|
21
24
|
name?: string
|
|
22
|
-
type: string[]
|
|
23
25
|
|
|
24
26
|
[x: string]: any
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
export interface ICredentialSubject {
|
|
28
30
|
id?: string
|
|
29
|
-
|
|
30
|
-
// [x: string]: string | string[] | object | object[] | unknown
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export type ICredentialContextType = (ICredentialContext &
|
|
33
|
+
export type ICredentialContextType = (ICredentialContext & AdditionalClaims) | string
|
|
34
34
|
|
|
35
35
|
export interface ICredentialContext {
|
|
36
36
|
name?: string
|
|
37
37
|
did?: string
|
|
38
|
-
|
|
39
|
-
// [x: string]: unknown
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
export type ICredentialSchemaType = ICredentialSchema | string
|
|
@@ -55,10 +53,11 @@ export interface IProof {
|
|
|
55
53
|
domain?: string // A string restricting the (usage of a) proof to the domain and protects against replay attacks
|
|
56
54
|
proofValue?: string // One of any number of valid representations of proof values
|
|
57
55
|
jws?: string // JWS based proof
|
|
56
|
+
jwt?: string //Jwt 2020 proof. Used to map a JWT VC onto a uniform presentation, and retain access to the original JWT
|
|
58
57
|
nonce?: string // Similar to challenge. A nonce to protect against replay attacks, used in some ZKP proofs
|
|
59
58
|
requiredRevealStatements?: string[] // The parts of the proof that must be revealed in a derived proof
|
|
60
59
|
|
|
61
|
-
|
|
60
|
+
[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
61
|
}
|
|
63
62
|
|
|
64
63
|
export interface ICredentialStatus {
|
|
@@ -78,11 +77,23 @@ export interface IHasProof {
|
|
|
78
77
|
|
|
79
78
|
export type IVerifiableCredential = ICredential & IHasProof
|
|
80
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Represents a Json Web Token in compact form.
|
|
82
|
+
*/
|
|
83
|
+
export type CompactJWT = string
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Represents a signed Verifiable Credential (includes proof), in either JSON or compact JWT format.
|
|
87
|
+
* See {@link https://www.w3.org/TR/vc-data-model/#credentials | VC data model}
|
|
88
|
+
* See {@link https://www.w3.org/TR/vc-data-model/#proof-formats | proof formats}
|
|
89
|
+
*/
|
|
90
|
+
export type W3CVerifiableCredential = IVerifiableCredential | CompactJWT
|
|
91
|
+
|
|
81
92
|
export interface IPresentation {
|
|
82
93
|
id?: string
|
|
83
94
|
'@context': ICredentialContextType | ICredentialContextType[]
|
|
84
|
-
type
|
|
85
|
-
verifiableCredential
|
|
95
|
+
type?: string | string[]
|
|
96
|
+
verifiableCredential?: W3CVerifiableCredential[]
|
|
86
97
|
presentation_submission?: PresentationSubmission
|
|
87
98
|
holder?: string
|
|
88
99
|
|
|
@@ -91,6 +102,13 @@ export interface IPresentation {
|
|
|
91
102
|
|
|
92
103
|
export type IVerifiablePresentation = IPresentation & IHasProof
|
|
93
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Represents a signed Verifiable Presentation (includes proof), in either JSON or compact JWT format.
|
|
107
|
+
* See {@link https://www.w3.org/TR/vc-data-model/#presentations | VC data model}
|
|
108
|
+
* See {@link https://www.w3.org/TR/vc-data-model/#proof-formats | proof formats}
|
|
109
|
+
*/
|
|
110
|
+
export type W3CVerifiablePresentation = IVerifiablePresentation | CompactJWT
|
|
111
|
+
|
|
94
112
|
export interface WrappedVerifiableCredential {
|
|
95
113
|
/**
|
|
96
114
|
* Original VC that we've received
|
|
@@ -107,11 +125,11 @@ export interface WrappedVerifiableCredential {
|
|
|
107
125
|
/**
|
|
108
126
|
* The claim format, typically used during exchange transport protocols
|
|
109
127
|
*/
|
|
110
|
-
format:
|
|
128
|
+
format: CredentialFormat
|
|
111
129
|
/**
|
|
112
|
-
* Internal stable representation of a Credential
|
|
130
|
+
* Internal stable representation of a Credential
|
|
113
131
|
*/
|
|
114
|
-
credential:
|
|
132
|
+
credential: IVerifiableCredential
|
|
115
133
|
}
|
|
116
134
|
|
|
117
135
|
export interface WrappedVerifiablePresentation {
|
|
@@ -130,7 +148,7 @@ export interface WrappedVerifiablePresentation {
|
|
|
130
148
|
/**
|
|
131
149
|
* The claim format, typically used during exchange transport protocols
|
|
132
150
|
*/
|
|
133
|
-
format:
|
|
151
|
+
format: PresentationFormat
|
|
134
152
|
/**
|
|
135
153
|
* Internal stable representation of a Presentation without proofs, created based on https://www.w3.org/TR/vc-data-model/#jwt-decoding
|
|
136
154
|
*/
|
|
@@ -149,14 +167,14 @@ export enum OriginalType {
|
|
|
149
167
|
|
|
150
168
|
export interface UniformVerifiablePresentation {
|
|
151
169
|
'@context': ICredentialContextType | ICredentialContextType[]
|
|
152
|
-
type: string[]
|
|
170
|
+
type: string | string[]
|
|
153
171
|
verifiableCredential: WrappedVerifiableCredential[]
|
|
154
172
|
presentation_submission?: PresentationSubmission
|
|
155
173
|
holder?: string
|
|
156
174
|
}
|
|
157
175
|
|
|
158
176
|
export interface JwtDecodedVerifiableCredential {
|
|
159
|
-
vc:
|
|
177
|
+
vc: IVerifiableCredential
|
|
160
178
|
exp: string
|
|
161
179
|
iss: string
|
|
162
180
|
nbf: string
|
|
@@ -177,8 +195,16 @@ export interface JwtDecodedVerifiablePresentation {
|
|
|
177
195
|
[x: string]: any
|
|
178
196
|
}
|
|
179
197
|
|
|
180
|
-
export type
|
|
198
|
+
export type CredentialFormat = 'jwt' | 'ldp' | 'jwt_vc' | 'ldp_vc' | string
|
|
199
|
+
export type PresentationFormat = 'jwt' | 'ldp' | 'jwt_vp' | 'ldp_vp' | string
|
|
200
|
+
export type ClaimFormat = CredentialFormat | PresentationFormat
|
|
181
201
|
|
|
182
|
-
export type OriginalVerifiableCredential =
|
|
183
|
-
export type OriginalVerifiablePresentation =
|
|
202
|
+
export type OriginalVerifiableCredential = W3CVerifiableCredential | JwtDecodedVerifiableCredential
|
|
203
|
+
export type OriginalVerifiablePresentation = W3CVerifiablePresentation | JwtDecodedVerifiablePresentation
|
|
184
204
|
export type Original = OriginalVerifiablePresentation | OriginalVerifiableCredential
|
|
205
|
+
|
|
206
|
+
export const enum DocumentFormat {
|
|
207
|
+
JWT,
|
|
208
|
+
JSONLD,
|
|
209
|
+
EIP712,
|
|
210
|
+
}
|