@idos-network/credentials 1.5.0 → 2.2.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/README.md +289 -85
- package/assets/idos-credential-subject-edd-v1.json +10 -0
- package/assets/idos-credential-subject-v1.json +1 -1
- package/assets/idos-credential-subject-v2.json +1 -1
- package/assets/idos-credential-subject-v3.json +83 -0
- package/assets/idos-credentials-v1.json +2 -2
- package/assets/idos-credentials-v2.json +10 -0
- package/dist/index-0NqXMjNk.d.mts +395 -0
- package/dist/index-0NqXMjNk.d.mts.map +1 -0
- package/dist/index-WW372Tf5.d.mts +57 -0
- package/dist/index-WW372Tf5.d.mts.map +1 -0
- package/dist/index.mjs +1 -1
- package/dist/loader-Cg6hs1-P.mjs +2 -0
- package/dist/loader-Cg6hs1-P.mjs.map +1 -0
- package/dist/parser/index.d.mts +19 -0
- package/dist/parser/index.d.mts.map +1 -0
- package/dist/parser/index.mjs +2 -0
- package/dist/parser/index.mjs.map +1 -0
- package/dist/schemas/index.d.mts +2 -0
- package/dist/schemas/index.mjs +1 -0
- package/dist/schemas-BVGuUlPe.mjs +2 -0
- package/dist/schemas-BVGuUlPe.mjs.map +1 -0
- package/dist/types/index.d.mts +2 -134
- package/dist/types/index.mjs +1 -63
- package/dist/utils/index.d.mts +37 -15
- package/dist/utils/index.d.mts.map +1 -1
- package/dist/utils/index.mjs +1 -116
- package/dist/utils/index.mjs.map +1 -1
- package/dist/verifier/index.d.mts +8 -0
- package/dist/verifier/index.d.mts.map +1 -0
- package/dist/verifier/index.mjs +2 -0
- package/dist/verifier/index.mjs.map +1 -0
- package/package.json +21 -9
- package/src/parser/index.test.ts +266 -0
- package/src/parser/index.ts +69 -0
- package/src/schemas/EddV1/index.test.ts +40 -0
- package/src/schemas/EddV1/index.ts +53 -0
- package/src/schemas/Envelope.ts +37 -0
- package/src/schemas/FaceIdV1/index.test.ts +26 -0
- package/src/schemas/FaceIdV1/index.ts +33 -0
- package/src/schemas/KycV1/IdDocument.ts +41 -0
- package/src/schemas/KycV1/ResidentialAddress.ts +56 -0
- package/src/schemas/KycV1/Subject.ts +86 -0
- package/src/schemas/KycV1/index.test.ts +156 -0
- package/src/schemas/KycV1/index.ts +40 -0
- package/src/schemas/KycV2/Subject.ts +67 -0
- package/src/schemas/KycV2/index.test.ts +162 -0
- package/src/schemas/KycV2/index.ts +45 -0
- package/src/schemas/KycV3/Biometric.ts +14 -0
- package/src/schemas/KycV3/Contact.ts +13 -0
- package/src/schemas/KycV3/EDD.ts +32 -0
- package/src/schemas/KycV3/IdDocument.ts +92 -0
- package/src/schemas/KycV3/Onboarding.ts +36 -0
- package/src/schemas/KycV3/Person.ts +105 -0
- package/src/schemas/KycV3/ResidentialAddress.ts +73 -0
- package/src/schemas/KycV3/Screening.ts +27 -0
- package/src/schemas/KycV3/SourceOfWealth.ts +44 -0
- package/src/schemas/KycV3/Subject.ts +54 -0
- package/src/schemas/KycV3/index.test.ts +682 -0
- package/src/schemas/KycV3/index.ts +108 -0
- package/src/schemas/VerifiableCredential.ts +232 -0
- package/src/schemas/enums.ts +126 -0
- package/src/schemas/index.ts +14 -0
- package/src/schemas/integration.test.ts +251 -0
- package/src/schemas/types.ts +11 -0
- package/src/schemas/utils.ts +274 -0
- package/src/types/credentials.ts +18 -249
- package/src/utils/{utils.test.ts → index.test.ts} +59 -67
- package/src/utils/index.ts +129 -134
- package/src/utils/issuer.ts +42 -0
- package/src/{builder → utils}/loader.ts +22 -17
- package/src/verifier/index.test.ts +149 -0
- package/src/{builder/verifier.ts → verifier/index.ts} +4 -8
- package/types/internals.d.ts +11 -6
- package/dist/builder/index.d.mts +0 -19
- package/dist/builder/index.d.mts.map +0 -1
- package/dist/builder/index.mjs +0 -619
- package/dist/builder/index.mjs.map +0 -1
- package/dist/types/index.d.mts.map +0 -1
- package/dist/types/index.mjs.map +0 -1
- package/src/builder/builder.test.ts +0 -407
- package/src/builder/index.ts +0 -122
package/dist/builder/index.mjs
DELETED
|
@@ -1,619 +0,0 @@
|
|
|
1
|
-
import { convertValues, issuerToKey } from "../utils/index.mjs";
|
|
2
|
-
import { CredentialFieldsSchema, CredentialSubjectFaceIdSchema, CredentialSubjectSchema } from "../types/index.mjs";
|
|
3
|
-
import { Ed25519Signature2020 } from "@digitalbazaar/ed25519-signature-2020";
|
|
4
|
-
import * as vc from "@digitalbazaar/vc";
|
|
5
|
-
import { JsonLdDocumentLoader } from "jsonld-document-loader";
|
|
6
|
-
//#region assets/ed25519-signature-2020-v1.json
|
|
7
|
-
var ed25519_signature_2020_v1_default = { "@context": {
|
|
8
|
-
"id": "@id",
|
|
9
|
-
"type": "@type",
|
|
10
|
-
"@protected": true,
|
|
11
|
-
"proof": {
|
|
12
|
-
"@id": "https://w3id.org/security#proof",
|
|
13
|
-
"@type": "@id",
|
|
14
|
-
"@container": "@graph"
|
|
15
|
-
},
|
|
16
|
-
"Ed25519VerificationKey2020": {
|
|
17
|
-
"@id": "https://w3id.org/security#Ed25519VerificationKey2020",
|
|
18
|
-
"@context": {
|
|
19
|
-
"@protected": true,
|
|
20
|
-
"id": "@id",
|
|
21
|
-
"type": "@type",
|
|
22
|
-
"controller": {
|
|
23
|
-
"@id": "https://w3id.org/security#controller",
|
|
24
|
-
"@type": "@id"
|
|
25
|
-
},
|
|
26
|
-
"revoked": {
|
|
27
|
-
"@id": "https://w3id.org/security#revoked",
|
|
28
|
-
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
|
|
29
|
-
},
|
|
30
|
-
"publicKeyMultibase": {
|
|
31
|
-
"@id": "https://w3id.org/security#publicKeyMultibase",
|
|
32
|
-
"@type": "https://w3id.org/security#multibase"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"Ed25519Signature2020": {
|
|
37
|
-
"@id": "https://w3id.org/security#Ed25519Signature2020",
|
|
38
|
-
"@context": {
|
|
39
|
-
"@protected": true,
|
|
40
|
-
"id": "@id",
|
|
41
|
-
"type": "@type",
|
|
42
|
-
"challenge": "https://w3id.org/security#challenge",
|
|
43
|
-
"created": {
|
|
44
|
-
"@id": "http://purl.org/dc/terms/created",
|
|
45
|
-
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
|
|
46
|
-
},
|
|
47
|
-
"domain": "https://w3id.org/security#domain",
|
|
48
|
-
"expires": {
|
|
49
|
-
"@id": "https://w3id.org/security#expiration",
|
|
50
|
-
"@type": "http://www.w3.org/2001/XMLSchema#dateTime"
|
|
51
|
-
},
|
|
52
|
-
"nonce": "https://w3id.org/security#nonce",
|
|
53
|
-
"proofPurpose": {
|
|
54
|
-
"@id": "https://w3id.org/security#proofPurpose",
|
|
55
|
-
"@type": "@vocab",
|
|
56
|
-
"@context": {
|
|
57
|
-
"@protected": true,
|
|
58
|
-
"id": "@id",
|
|
59
|
-
"type": "@type",
|
|
60
|
-
"assertionMethod": {
|
|
61
|
-
"@id": "https://w3id.org/security#assertionMethod",
|
|
62
|
-
"@type": "@id",
|
|
63
|
-
"@container": "@set"
|
|
64
|
-
},
|
|
65
|
-
"authentication": {
|
|
66
|
-
"@id": "https://w3id.org/security#authenticationMethod",
|
|
67
|
-
"@type": "@id",
|
|
68
|
-
"@container": "@set"
|
|
69
|
-
},
|
|
70
|
-
"capabilityInvocation": {
|
|
71
|
-
"@id": "https://w3id.org/security#capabilityInvocationMethod",
|
|
72
|
-
"@type": "@id",
|
|
73
|
-
"@container": "@set"
|
|
74
|
-
},
|
|
75
|
-
"capabilityDelegation": {
|
|
76
|
-
"@id": "https://w3id.org/security#capabilityDelegationMethod",
|
|
77
|
-
"@type": "@id",
|
|
78
|
-
"@container": "@set"
|
|
79
|
-
},
|
|
80
|
-
"keyAgreement": {
|
|
81
|
-
"@id": "https://w3id.org/security#keyAgreementMethod",
|
|
82
|
-
"@type": "@id",
|
|
83
|
-
"@container": "@set"
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
"proofValue": {
|
|
88
|
-
"@id": "https://w3id.org/security#proofValue",
|
|
89
|
-
"@type": "https://w3id.org/security#multibase"
|
|
90
|
-
},
|
|
91
|
-
"verificationMethod": {
|
|
92
|
-
"@id": "https://w3id.org/security#verificationMethod",
|
|
93
|
-
"@type": "@id"
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
} };
|
|
98
|
-
//#endregion
|
|
99
|
-
//#region assets/idos-credential-subject-face-id-v1.json
|
|
100
|
-
var idos_credential_subject_face_id_v1_default = { "@context": {
|
|
101
|
-
"@version": 1.1,
|
|
102
|
-
"@protected": true,
|
|
103
|
-
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
|
104
|
-
"faceSignUserId": "xsd:string"
|
|
105
|
-
} };
|
|
106
|
-
//#endregion
|
|
107
|
-
//#region assets/idos-credential-subject-v1.json
|
|
108
|
-
var idos_credential_subject_v1_default = { "@context": {
|
|
109
|
-
"@version": 1.1,
|
|
110
|
-
"@protected": true,
|
|
111
|
-
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
|
112
|
-
"aux": "https://raw.githubusercontent.com/idos-network/idos-sdk-js/168f449a799620123bc7b01fc224423739500f94/packages/issuer-sdk-js/assets/country-codes.xml",
|
|
113
|
-
"applicantId": "xsd:string",
|
|
114
|
-
"inquiryId": "xsd:string",
|
|
115
|
-
"firstName": "xsd:string",
|
|
116
|
-
"middleName": "xsd:string",
|
|
117
|
-
"nationality": "aux:ISO_3166-1_alpha-2",
|
|
118
|
-
"familyName": "xsd:string",
|
|
119
|
-
"maidenName": "xsd:string",
|
|
120
|
-
"gender": "xsd:string",
|
|
121
|
-
"governmentId": "xsd:string",
|
|
122
|
-
"governmentIdType": "xsd:string",
|
|
123
|
-
"email": "xsd:string",
|
|
124
|
-
"ssn": "xsd:string",
|
|
125
|
-
"phoneNumber": "xsd:string",
|
|
126
|
-
"dateOfBirth": "aux:date",
|
|
127
|
-
"placeOfBirth": "xsd:string",
|
|
128
|
-
"idDocumentCountry": "xsd:string",
|
|
129
|
-
"idDocumentNumber": "xsd:string",
|
|
130
|
-
"idDocumentType": "xsd:string",
|
|
131
|
-
"idDocumentDateOfIssue": "aux:date",
|
|
132
|
-
"idDocumentDateOfExpiry": "aux:date",
|
|
133
|
-
"idDocumentFrontFile": "xsd:string",
|
|
134
|
-
"idDocumentBackFile": "xsd:string",
|
|
135
|
-
"selfieFile": "xsd:string",
|
|
136
|
-
"residentialAddressStreet": "xsd:string",
|
|
137
|
-
"residentialAddressHouseNumber": "xsd:string",
|
|
138
|
-
"residentialAddressAdditionalAddressInfo": "xsd:string",
|
|
139
|
-
"residentialAddressRegion": "xsd:string",
|
|
140
|
-
"residentialAddressCity": "xsd:string",
|
|
141
|
-
"residentialAddressPostalCode": "xsd:string",
|
|
142
|
-
"residentialAddressCountry": "aux:ISO_3166-1_alpha-2",
|
|
143
|
-
"residentialAddressProofCategory": "xsd:string",
|
|
144
|
-
"residentialAddressProofDateOfIssue": "xsd:date",
|
|
145
|
-
"residentialAddressProofFile": "xsd:string"
|
|
146
|
-
} };
|
|
147
|
-
//#endregion
|
|
148
|
-
//#region assets/idos-credential-subject-v2.json
|
|
149
|
-
var idos_credential_subject_v2_default = { "@context": {
|
|
150
|
-
"@version": 1.1,
|
|
151
|
-
"@protected": true,
|
|
152
|
-
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
|
153
|
-
"aux": "https://raw.githubusercontent.com/idos-network/idos-sdk-js/168f449a799620123bc7b01fc224423739500f94/packages/issuer-sdk-js/assets/country-codes.xml",
|
|
154
|
-
"firstName": "xsd:string",
|
|
155
|
-
"middleName": "xsd:string",
|
|
156
|
-
"nationality": "aux:ISO_3166-1_alpha-2",
|
|
157
|
-
"familyName": "xsd:string",
|
|
158
|
-
"maidenName": "xsd:string",
|
|
159
|
-
"gender": "xsd:string",
|
|
160
|
-
"email": "xsd:string",
|
|
161
|
-
"phoneNumber": "xsd:string",
|
|
162
|
-
"ssn": "xsd:string",
|
|
163
|
-
"dateOfBirth": "aux:date",
|
|
164
|
-
"placeOfBirth": "xsd:string",
|
|
165
|
-
"idDocumentCountry": "xsd:string",
|
|
166
|
-
"idDocumentNumber": "xsd:string",
|
|
167
|
-
"idDocumentType": "xsd:string",
|
|
168
|
-
"idDocumentDateOfIssue": "aux:date",
|
|
169
|
-
"idDocumentDateOfExpiry": "aux:date",
|
|
170
|
-
"idDocumentFrontFile": "xsd:string",
|
|
171
|
-
"idDocumentBackFile": "xsd:string",
|
|
172
|
-
"selfieFile": "xsd:string",
|
|
173
|
-
"residentialAddressStreet": "xsd:string",
|
|
174
|
-
"residentialAddressHouseNumber": "xsd:string",
|
|
175
|
-
"residentialAddressAdditionalAddressInfo": "xsd:string",
|
|
176
|
-
"residentialAddressRegion": "xsd:string",
|
|
177
|
-
"residentialAddressCity": "xsd:string",
|
|
178
|
-
"residentialAddressPostalCode": "xsd:string",
|
|
179
|
-
"residentialAddressCountry": "aux:ISO_3166-1_alpha-2",
|
|
180
|
-
"residentialAddressProofCategory": "xsd:string",
|
|
181
|
-
"residentialAddressProofDateOfIssue": "xsd:date",
|
|
182
|
-
"residentialAddressProofFile": "xsd:string"
|
|
183
|
-
} };
|
|
184
|
-
//#endregion
|
|
185
|
-
//#region assets/idos-credentials-v1.json
|
|
186
|
-
var idos_credentials_v1_default = { "@context": {
|
|
187
|
-
"@version": 1.1,
|
|
188
|
-
"@protected": true,
|
|
189
|
-
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
|
190
|
-
"approvedAt": "xsd:date",
|
|
191
|
-
"level": "xsd:string"
|
|
192
|
-
} };
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region assets/v1.json
|
|
195
|
-
var v1_default = { "@context": {
|
|
196
|
-
"@version": 1.1,
|
|
197
|
-
"@protected": true,
|
|
198
|
-
"id": "@id",
|
|
199
|
-
"type": "@type",
|
|
200
|
-
"VerifiableCredential": {
|
|
201
|
-
"@id": "https://www.w3.org/2018/credentials#VerifiableCredential",
|
|
202
|
-
"@context": {
|
|
203
|
-
"@version": 1.1,
|
|
204
|
-
"@protected": true,
|
|
205
|
-
"id": "@id",
|
|
206
|
-
"type": "@type",
|
|
207
|
-
"cred": "https://www.w3.org/2018/credentials#",
|
|
208
|
-
"sec": "https://w3id.org/security#",
|
|
209
|
-
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
|
210
|
-
"credentialSchema": {
|
|
211
|
-
"@id": "cred:credentialSchema",
|
|
212
|
-
"@type": "@id",
|
|
213
|
-
"@context": {
|
|
214
|
-
"@version": 1.1,
|
|
215
|
-
"@protected": true,
|
|
216
|
-
"id": "@id",
|
|
217
|
-
"type": "@type",
|
|
218
|
-
"cred": "https://www.w3.org/2018/credentials#",
|
|
219
|
-
"JsonSchemaValidator2018": "cred:JsonSchemaValidator2018"
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
"credentialStatus": {
|
|
223
|
-
"@id": "cred:credentialStatus",
|
|
224
|
-
"@type": "@id"
|
|
225
|
-
},
|
|
226
|
-
"credentialSubject": {
|
|
227
|
-
"@id": "cred:credentialSubject",
|
|
228
|
-
"@type": "@id"
|
|
229
|
-
},
|
|
230
|
-
"evidence": {
|
|
231
|
-
"@id": "cred:evidence",
|
|
232
|
-
"@type": "@id"
|
|
233
|
-
},
|
|
234
|
-
"expirationDate": {
|
|
235
|
-
"@id": "cred:expirationDate",
|
|
236
|
-
"@type": "xsd:dateTime"
|
|
237
|
-
},
|
|
238
|
-
"holder": {
|
|
239
|
-
"@id": "cred:holder",
|
|
240
|
-
"@type": "@id"
|
|
241
|
-
},
|
|
242
|
-
"issued": {
|
|
243
|
-
"@id": "cred:issued",
|
|
244
|
-
"@type": "xsd:dateTime"
|
|
245
|
-
},
|
|
246
|
-
"issuer": {
|
|
247
|
-
"@id": "cred:issuer",
|
|
248
|
-
"@type": "@id"
|
|
249
|
-
},
|
|
250
|
-
"issuanceDate": {
|
|
251
|
-
"@id": "cred:issuanceDate",
|
|
252
|
-
"@type": "xsd:dateTime"
|
|
253
|
-
},
|
|
254
|
-
"proof": {
|
|
255
|
-
"@id": "sec:proof",
|
|
256
|
-
"@type": "@id",
|
|
257
|
-
"@container": "@graph"
|
|
258
|
-
},
|
|
259
|
-
"refreshService": {
|
|
260
|
-
"@id": "cred:refreshService",
|
|
261
|
-
"@type": "@id",
|
|
262
|
-
"@context": {
|
|
263
|
-
"@version": 1.1,
|
|
264
|
-
"@protected": true,
|
|
265
|
-
"id": "@id",
|
|
266
|
-
"type": "@type",
|
|
267
|
-
"cred": "https://www.w3.org/2018/credentials#",
|
|
268
|
-
"ManualRefreshService2018": "cred:ManualRefreshService2018"
|
|
269
|
-
}
|
|
270
|
-
},
|
|
271
|
-
"termsOfUse": {
|
|
272
|
-
"@id": "cred:termsOfUse",
|
|
273
|
-
"@type": "@id"
|
|
274
|
-
},
|
|
275
|
-
"validFrom": {
|
|
276
|
-
"@id": "cred:validFrom",
|
|
277
|
-
"@type": "xsd:dateTime"
|
|
278
|
-
},
|
|
279
|
-
"validUntil": {
|
|
280
|
-
"@id": "cred:validUntil",
|
|
281
|
-
"@type": "xsd:dateTime"
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
},
|
|
285
|
-
"VerifiablePresentation": {
|
|
286
|
-
"@id": "https://www.w3.org/2018/credentials#VerifiablePresentation",
|
|
287
|
-
"@context": {
|
|
288
|
-
"@version": 1.1,
|
|
289
|
-
"@protected": true,
|
|
290
|
-
"id": "@id",
|
|
291
|
-
"type": "@type",
|
|
292
|
-
"cred": "https://www.w3.org/2018/credentials#",
|
|
293
|
-
"sec": "https://w3id.org/security#",
|
|
294
|
-
"holder": {
|
|
295
|
-
"@id": "cred:holder",
|
|
296
|
-
"@type": "@id"
|
|
297
|
-
},
|
|
298
|
-
"proof": {
|
|
299
|
-
"@id": "sec:proof",
|
|
300
|
-
"@type": "@id",
|
|
301
|
-
"@container": "@graph"
|
|
302
|
-
},
|
|
303
|
-
"verifiableCredential": {
|
|
304
|
-
"@id": "cred:verifiableCredential",
|
|
305
|
-
"@type": "@id",
|
|
306
|
-
"@container": "@graph"
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
},
|
|
310
|
-
"EcdsaSecp256k1Signature2019": {
|
|
311
|
-
"@id": "https://w3id.org/security#EcdsaSecp256k1Signature2019",
|
|
312
|
-
"@context": {
|
|
313
|
-
"@version": 1.1,
|
|
314
|
-
"@protected": true,
|
|
315
|
-
"id": "@id",
|
|
316
|
-
"type": "@type",
|
|
317
|
-
"sec": "https://w3id.org/security#",
|
|
318
|
-
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
|
319
|
-
"challenge": "sec:challenge",
|
|
320
|
-
"created": {
|
|
321
|
-
"@id": "http://purl.org/dc/terms/created",
|
|
322
|
-
"@type": "xsd:dateTime"
|
|
323
|
-
},
|
|
324
|
-
"domain": "sec:domain",
|
|
325
|
-
"expires": {
|
|
326
|
-
"@id": "sec:expiration",
|
|
327
|
-
"@type": "xsd:dateTime"
|
|
328
|
-
},
|
|
329
|
-
"jws": "sec:jws",
|
|
330
|
-
"nonce": "sec:nonce",
|
|
331
|
-
"proofPurpose": {
|
|
332
|
-
"@id": "sec:proofPurpose",
|
|
333
|
-
"@type": "@vocab",
|
|
334
|
-
"@context": {
|
|
335
|
-
"@version": 1.1,
|
|
336
|
-
"@protected": true,
|
|
337
|
-
"id": "@id",
|
|
338
|
-
"type": "@type",
|
|
339
|
-
"sec": "https://w3id.org/security#",
|
|
340
|
-
"assertionMethod": {
|
|
341
|
-
"@id": "sec:assertionMethod",
|
|
342
|
-
"@type": "@id",
|
|
343
|
-
"@container": "@set"
|
|
344
|
-
},
|
|
345
|
-
"authentication": {
|
|
346
|
-
"@id": "sec:authenticationMethod",
|
|
347
|
-
"@type": "@id",
|
|
348
|
-
"@container": "@set"
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
},
|
|
352
|
-
"proofValue": "sec:proofValue",
|
|
353
|
-
"verificationMethod": {
|
|
354
|
-
"@id": "sec:verificationMethod",
|
|
355
|
-
"@type": "@id"
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
},
|
|
359
|
-
"EcdsaSecp256r1Signature2019": {
|
|
360
|
-
"@id": "https://w3id.org/security#EcdsaSecp256r1Signature2019",
|
|
361
|
-
"@context": {
|
|
362
|
-
"@version": 1.1,
|
|
363
|
-
"@protected": true,
|
|
364
|
-
"id": "@id",
|
|
365
|
-
"type": "@type",
|
|
366
|
-
"sec": "https://w3id.org/security#",
|
|
367
|
-
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
|
368
|
-
"challenge": "sec:challenge",
|
|
369
|
-
"created": {
|
|
370
|
-
"@id": "http://purl.org/dc/terms/created",
|
|
371
|
-
"@type": "xsd:dateTime"
|
|
372
|
-
},
|
|
373
|
-
"domain": "sec:domain",
|
|
374
|
-
"expires": {
|
|
375
|
-
"@id": "sec:expiration",
|
|
376
|
-
"@type": "xsd:dateTime"
|
|
377
|
-
},
|
|
378
|
-
"jws": "sec:jws",
|
|
379
|
-
"nonce": "sec:nonce",
|
|
380
|
-
"proofPurpose": {
|
|
381
|
-
"@id": "sec:proofPurpose",
|
|
382
|
-
"@type": "@vocab",
|
|
383
|
-
"@context": {
|
|
384
|
-
"@version": 1.1,
|
|
385
|
-
"@protected": true,
|
|
386
|
-
"id": "@id",
|
|
387
|
-
"type": "@type",
|
|
388
|
-
"sec": "https://w3id.org/security#",
|
|
389
|
-
"assertionMethod": {
|
|
390
|
-
"@id": "sec:assertionMethod",
|
|
391
|
-
"@type": "@id",
|
|
392
|
-
"@container": "@set"
|
|
393
|
-
},
|
|
394
|
-
"authentication": {
|
|
395
|
-
"@id": "sec:authenticationMethod",
|
|
396
|
-
"@type": "@id",
|
|
397
|
-
"@container": "@set"
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
},
|
|
401
|
-
"proofValue": "sec:proofValue",
|
|
402
|
-
"verificationMethod": {
|
|
403
|
-
"@id": "sec:verificationMethod",
|
|
404
|
-
"@type": "@id"
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
},
|
|
408
|
-
"Ed25519Signature2018": {
|
|
409
|
-
"@id": "https://w3id.org/security#Ed25519Signature2018",
|
|
410
|
-
"@context": {
|
|
411
|
-
"@version": 1.1,
|
|
412
|
-
"@protected": true,
|
|
413
|
-
"id": "@id",
|
|
414
|
-
"type": "@type",
|
|
415
|
-
"sec": "https://w3id.org/security#",
|
|
416
|
-
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
|
417
|
-
"challenge": "sec:challenge",
|
|
418
|
-
"created": {
|
|
419
|
-
"@id": "http://purl.org/dc/terms/created",
|
|
420
|
-
"@type": "xsd:dateTime"
|
|
421
|
-
},
|
|
422
|
-
"domain": "sec:domain",
|
|
423
|
-
"expires": {
|
|
424
|
-
"@id": "sec:expiration",
|
|
425
|
-
"@type": "xsd:dateTime"
|
|
426
|
-
},
|
|
427
|
-
"jws": "sec:jws",
|
|
428
|
-
"nonce": "sec:nonce",
|
|
429
|
-
"proofPurpose": {
|
|
430
|
-
"@id": "sec:proofPurpose",
|
|
431
|
-
"@type": "@vocab",
|
|
432
|
-
"@context": {
|
|
433
|
-
"@version": 1.1,
|
|
434
|
-
"@protected": true,
|
|
435
|
-
"id": "@id",
|
|
436
|
-
"type": "@type",
|
|
437
|
-
"sec": "https://w3id.org/security#",
|
|
438
|
-
"assertionMethod": {
|
|
439
|
-
"@id": "sec:assertionMethod",
|
|
440
|
-
"@type": "@id",
|
|
441
|
-
"@container": "@set"
|
|
442
|
-
},
|
|
443
|
-
"authentication": {
|
|
444
|
-
"@id": "sec:authenticationMethod",
|
|
445
|
-
"@type": "@id",
|
|
446
|
-
"@container": "@set"
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
},
|
|
450
|
-
"proofValue": "sec:proofValue",
|
|
451
|
-
"verificationMethod": {
|
|
452
|
-
"@id": "sec:verificationMethod",
|
|
453
|
-
"@type": "@id"
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
},
|
|
457
|
-
"RsaSignature2018": {
|
|
458
|
-
"@id": "https://w3id.org/security#RsaSignature2018",
|
|
459
|
-
"@context": {
|
|
460
|
-
"@version": 1.1,
|
|
461
|
-
"@protected": true,
|
|
462
|
-
"challenge": "sec:challenge",
|
|
463
|
-
"created": {
|
|
464
|
-
"@id": "http://purl.org/dc/terms/created",
|
|
465
|
-
"@type": "xsd:dateTime"
|
|
466
|
-
},
|
|
467
|
-
"domain": "sec:domain",
|
|
468
|
-
"expires": {
|
|
469
|
-
"@id": "sec:expiration",
|
|
470
|
-
"@type": "xsd:dateTime"
|
|
471
|
-
},
|
|
472
|
-
"jws": "sec:jws",
|
|
473
|
-
"nonce": "sec:nonce",
|
|
474
|
-
"proofPurpose": {
|
|
475
|
-
"@id": "sec:proofPurpose",
|
|
476
|
-
"@type": "@vocab",
|
|
477
|
-
"@context": {
|
|
478
|
-
"@version": 1.1,
|
|
479
|
-
"@protected": true,
|
|
480
|
-
"id": "@id",
|
|
481
|
-
"type": "@type",
|
|
482
|
-
"sec": "https://w3id.org/security#",
|
|
483
|
-
"assertionMethod": {
|
|
484
|
-
"@id": "sec:assertionMethod",
|
|
485
|
-
"@type": "@id",
|
|
486
|
-
"@container": "@set"
|
|
487
|
-
},
|
|
488
|
-
"authentication": {
|
|
489
|
-
"@id": "sec:authenticationMethod",
|
|
490
|
-
"@type": "@id",
|
|
491
|
-
"@container": "@set"
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
},
|
|
495
|
-
"proofValue": "sec:proofValue",
|
|
496
|
-
"verificationMethod": {
|
|
497
|
-
"@id": "sec:verificationMethod",
|
|
498
|
-
"@type": "@id"
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
},
|
|
502
|
-
"proof": {
|
|
503
|
-
"@id": "https://w3id.org/security#proof",
|
|
504
|
-
"@type": "@id",
|
|
505
|
-
"@container": "@graph"
|
|
506
|
-
}
|
|
507
|
-
} };
|
|
508
|
-
//#endregion
|
|
509
|
-
//#region src/builder/loader.ts
|
|
510
|
-
const CONTEXT_V1 = "https://www.w3.org/2018/credentials/v1";
|
|
511
|
-
const CONTEXT_ED25519_SIGNATURE_2020_V1 = "https://w3id.org/security/suites/ed25519-2020/v1";
|
|
512
|
-
const CONTEXT_IDOS_CREDENTIAL_V1 = "https://idos-network.github.io/idos-sdk-js/credentials/idos-credentials-v1.json";
|
|
513
|
-
const CONTEXT_IDOS_CREDENTIAL_V1_SUBJECT = "https://idos-network.github.io/idos-sdk-js/credentials/idos-credential-subject-v1.json";
|
|
514
|
-
const CONTEXT_IDOS_CREDENTIAL_V2_SUBJECT = "https://idos-network.github.io/idos-sdk-js/credentials/idos-credential-subject-v2.json";
|
|
515
|
-
const CONTEXT_IDOS_CREDENTIAL_V1_FACE_ID = "https://idos-network.github.io/idos-sdk-js/credentials/idos-credential-subject-face-id-v1.json";
|
|
516
|
-
const CONTEXT_IDOS_CREDENTIAL = CONTEXT_IDOS_CREDENTIAL_V1;
|
|
517
|
-
const CONTEXT_IDOS_CREDENTIAL_SUBJECT = CONTEXT_IDOS_CREDENTIAL_V2_SUBJECT;
|
|
518
|
-
const CONTEXT_IDOS_SIGNATURE = CONTEXT_ED25519_SIGNATURE_2020_V1;
|
|
519
|
-
const CONTEXT_IDOS_CREDENTIAL_FACE_ID = CONTEXT_IDOS_CREDENTIAL_V1_FACE_ID;
|
|
520
|
-
function buildDocumentLoader() {
|
|
521
|
-
const loader = new JsonLdDocumentLoader();
|
|
522
|
-
loader.addStatic(CONTEXT_V1, v1_default);
|
|
523
|
-
loader.addStatic(CONTEXT_IDOS_CREDENTIAL_V1, idos_credentials_v1_default);
|
|
524
|
-
loader.addStatic(CONTEXT_ED25519_SIGNATURE_2020_V1, ed25519_signature_2020_v1_default);
|
|
525
|
-
loader.addStatic(CONTEXT_IDOS_CREDENTIAL_V1_SUBJECT, idos_credential_subject_v1_default);
|
|
526
|
-
loader.addStatic(CONTEXT_IDOS_CREDENTIAL_V2_SUBJECT, idos_credential_subject_v2_default);
|
|
527
|
-
loader.addStatic(CONTEXT_IDOS_CREDENTIAL_V1_FACE_ID, idos_credential_subject_face_id_v1_default);
|
|
528
|
-
[
|
|
529
|
-
"1356fea6672d22deb07fedc5fa427478b2e1654c",
|
|
530
|
-
"346f14468348e4f3dd00039c89ce9bb49d88777c",
|
|
531
|
-
"1e8421744e037dfd7b0289cb39261c73ab6d643c",
|
|
532
|
-
"0049d2e93f8913c42398372e2bb65d92bed38ac0"
|
|
533
|
-
].forEach((hash) => {
|
|
534
|
-
loader.addStatic(`https://raw.githubusercontent.com/idos-network/idos-sdk-js/${hash}/packages/%40credentials/assets/idos-credentials-v1.json`, idos_credentials_v1_default);
|
|
535
|
-
loader.addStatic(`https://raw.githubusercontent.com/idos-network/idos-sdk-js/${hash}/packages/%40credentials/assets/idos-credential-subject-v1.json`, idos_credential_subject_v1_default);
|
|
536
|
-
});
|
|
537
|
-
["1bc3503f5302a7e42777076445d5b05fec8db429"].forEach((hash) => {
|
|
538
|
-
loader.addStatic(`https://raw.githubusercontent.com/idos-network/idos-sdk-js/${hash}/packages/issuer-sdk-js/assets/idos-credentials-v1.json`, idos_credentials_v1_default);
|
|
539
|
-
loader.addStatic(`https://raw.githubusercontent.com/idos-network/idos-sdk-js/${hash}/packages/issuer-sdk-js/assets/idos-credential-subject-v1.json`, idos_credential_subject_v1_default);
|
|
540
|
-
});
|
|
541
|
-
return loader.build();
|
|
542
|
-
}
|
|
543
|
-
const defaultDocumentLoader = buildDocumentLoader();
|
|
544
|
-
//#endregion
|
|
545
|
-
//#region src/builder/verifier.ts
|
|
546
|
-
async function verifyCredential(credential, issuers, customDocumentLoader) {
|
|
547
|
-
const resultsByIssuer = /* @__PURE__ */ new Map();
|
|
548
|
-
for (const issuer of issuers) {
|
|
549
|
-
const publicKey = await issuerToKey(issuer);
|
|
550
|
-
const vcVerifyingSuite = new Ed25519Signature2020({
|
|
551
|
-
key: publicKey,
|
|
552
|
-
verificationMethod: publicKey.id
|
|
553
|
-
});
|
|
554
|
-
const controller = {
|
|
555
|
-
"@context": "https://w3id.org/security/v2",
|
|
556
|
-
id: publicKey.controller,
|
|
557
|
-
assertionMethod: [publicKey.id],
|
|
558
|
-
authentication: [publicKey.id]
|
|
559
|
-
};
|
|
560
|
-
const verifyCredentialResult = await vc.verifyCredential({
|
|
561
|
-
credential,
|
|
562
|
-
suite: vcVerifyingSuite,
|
|
563
|
-
controller,
|
|
564
|
-
documentLoader: customDocumentLoader ?? defaultDocumentLoader
|
|
565
|
-
});
|
|
566
|
-
resultsByIssuer.set(issuer, verifyCredentialResult);
|
|
567
|
-
if (verifyCredentialResult.verified) return [true, resultsByIssuer];
|
|
568
|
-
}
|
|
569
|
-
return [false, resultsByIssuer];
|
|
570
|
-
}
|
|
571
|
-
//#endregion
|
|
572
|
-
//#region src/builder/index.ts
|
|
573
|
-
function genericCredentialBuilder(credentialConverter) {
|
|
574
|
-
async function builder(fields, subject, issuer, validate = true) {
|
|
575
|
-
if (validate) CredentialFieldsSchema.parse(fields);
|
|
576
|
-
const credentialSubject = credentialConverter(subject, validate);
|
|
577
|
-
const key = await issuerToKey(issuer);
|
|
578
|
-
const credential = {
|
|
579
|
-
"@context": [
|
|
580
|
-
CONTEXT_V1,
|
|
581
|
-
CONTEXT_IDOS_CREDENTIAL,
|
|
582
|
-
CONTEXT_IDOS_SIGNATURE
|
|
583
|
-
],
|
|
584
|
-
type: ["VerifiableCredential"],
|
|
585
|
-
issuer: key.controller,
|
|
586
|
-
...convertValues(fields),
|
|
587
|
-
credentialSubject
|
|
588
|
-
};
|
|
589
|
-
const suite = new Ed25519Signature2020({ key });
|
|
590
|
-
return vc.issue({
|
|
591
|
-
credential,
|
|
592
|
-
suite,
|
|
593
|
-
documentLoader: defaultDocumentLoader
|
|
594
|
-
});
|
|
595
|
-
}
|
|
596
|
-
return builder;
|
|
597
|
-
}
|
|
598
|
-
const credentialSubjectConverter = (subject, validate) => {
|
|
599
|
-
if (validate) CredentialSubjectSchema.parse(subject);
|
|
600
|
-
const { residentialAddress, ...subjectData } = subject;
|
|
601
|
-
return {
|
|
602
|
-
"@context": CONTEXT_IDOS_CREDENTIAL_SUBJECT,
|
|
603
|
-
...convertValues(subjectData),
|
|
604
|
-
...residentialAddress ? convertValues(residentialAddress, "residentialAddress") : {}
|
|
605
|
-
};
|
|
606
|
-
};
|
|
607
|
-
const credentialFaceIdSubjectConverter = (subject, validate) => {
|
|
608
|
-
if (validate) CredentialSubjectFaceIdSchema.parse(subject);
|
|
609
|
-
return {
|
|
610
|
-
"@context": CONTEXT_IDOS_CREDENTIAL_FACE_ID,
|
|
611
|
-
...convertValues(subject)
|
|
612
|
-
};
|
|
613
|
-
};
|
|
614
|
-
const buildCredential = genericCredentialBuilder(credentialSubjectConverter);
|
|
615
|
-
const buildFaceIdCredential = genericCredentialBuilder(credentialFaceIdSubjectConverter);
|
|
616
|
-
//#endregion
|
|
617
|
-
export { buildCredential, buildFaceIdCredential, credentialFaceIdSubjectConverter, credentialSubjectConverter, verifyCredential };
|
|
618
|
-
|
|
619
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["v1","idosCredentialsV1","ed25519Signature2020V1","idosCredentialSubjectV1","idosCredentialSubjectV2","idosCredentialSubjectFaceIdV1"],"sources":["../../assets/ed25519-signature-2020-v1.json","../../assets/idos-credential-subject-face-id-v1.json","../../assets/idos-credential-subject-v1.json","../../assets/idos-credential-subject-v2.json","../../assets/idos-credentials-v1.json","../../assets/v1.json","../../src/builder/loader.ts","../../src/builder/verifier.ts","../../src/builder/index.ts"],"sourcesContent":["","","","","","","import { type JsonLDDocumentLoaderInstance, JsonLdDocumentLoader } from \"jsonld-document-loader\";\n\nimport ed25519Signature2020V1 from \"../../assets/ed25519-signature-2020-v1.json\";\nimport idosCredentialSubjectFaceIdV1 from \"../../assets/idos-credential-subject-face-id-v1.json\";\nimport idosCredentialSubjectV1 from \"../../assets/idos-credential-subject-v1.json\";\nimport idosCredentialSubjectV2 from \"../../assets/idos-credential-subject-v2.json\";\nimport idosCredentialsV1 from \"../../assets/idos-credentials-v1.json\";\nimport v1 from \"../../assets/v1.json\";\n\nexport const CONTEXT_V1 = \"https://www.w3.org/2018/credentials/v1\";\nexport const CONTEXT_ED25519_SIGNATURE_2020_V1 = \"https://w3id.org/security/suites/ed25519-2020/v1\";\n\n// Check .github/workflow/pages.yml how those are deployed\nexport const CONTEXT_IDOS_CREDENTIAL_V1 =\n \"https://idos-network.github.io/idos-sdk-js/credentials/idos-credentials-v1.json\";\nexport const CONTEXT_IDOS_CREDENTIAL_V1_SUBJECT =\n \"https://idos-network.github.io/idos-sdk-js/credentials/idos-credential-subject-v1.json\";\nexport const CONTEXT_IDOS_CREDENTIAL_V2_SUBJECT =\n \"https://idos-network.github.io/idos-sdk-js/credentials/idos-credential-subject-v2.json\";\n\nexport const CONTEXT_IDOS_CREDENTIAL_V1_FACE_ID =\n \"https://idos-network.github.io/idos-sdk-js/credentials/idos-credential-subject-face-id-v1.json\";\n\n// Latest contexts for builder\nexport const CONTEXT_IDOS_CREDENTIAL: string = CONTEXT_IDOS_CREDENTIAL_V1;\nexport const CONTEXT_IDOS_CREDENTIAL_SUBJECT: string = CONTEXT_IDOS_CREDENTIAL_V2_SUBJECT;\nexport const CONTEXT_IDOS_SIGNATURE: string = CONTEXT_ED25519_SIGNATURE_2020_V1;\nexport const CONTEXT_IDOS_CREDENTIAL_FACE_ID: string = CONTEXT_IDOS_CREDENTIAL_V1_FACE_ID;\n\nexport function buildDocumentLoader(): JsonLDDocumentLoaderInstance {\n const loader = new JsonLdDocumentLoader();\n\n loader.addStatic(CONTEXT_V1, v1);\n loader.addStatic(CONTEXT_IDOS_CREDENTIAL_V1, idosCredentialsV1);\n loader.addStatic(CONTEXT_ED25519_SIGNATURE_2020_V1, ed25519Signature2020V1);\n\n // plus / basic + liveness credentials\n loader.addStatic(CONTEXT_IDOS_CREDENTIAL_V1_SUBJECT, idosCredentialSubjectV1);\n loader.addStatic(CONTEXT_IDOS_CREDENTIAL_V2_SUBJECT, idosCredentialSubjectV2);\n\n // PoP\n loader.addStatic(CONTEXT_IDOS_CREDENTIAL_V1_FACE_ID, idosCredentialSubjectFaceIdV1);\n\n // DEPRECATED: Those should be removed\n [\n \"1356fea6672d22deb07fedc5fa427478b2e1654c\",\n \"346f14468348e4f3dd00039c89ce9bb49d88777c\",\n \"1e8421744e037dfd7b0289cb39261c73ab6d643c\",\n \"0049d2e93f8913c42398372e2bb65d92bed38ac0\",\n ].forEach((hash) => {\n loader.addStatic(\n `https://raw.githubusercontent.com/idos-network/idos-sdk-js/${hash}/packages/%40credentials/assets/idos-credentials-v1.json`,\n idosCredentialsV1,\n );\n loader.addStatic(\n `https://raw.githubusercontent.com/idos-network/idos-sdk-js/${hash}/packages/%40credentials/assets/idos-credential-subject-v1.json`,\n idosCredentialSubjectV1,\n );\n });\n\n // DEPRECATED: Those should be removed\n [\"1bc3503f5302a7e42777076445d5b05fec8db429\"].forEach((hash) => {\n loader.addStatic(\n `https://raw.githubusercontent.com/idos-network/idos-sdk-js/${hash}/packages/issuer-sdk-js/assets/idos-credentials-v1.json`,\n idosCredentialsV1,\n );\n loader.addStatic(\n `https://raw.githubusercontent.com/idos-network/idos-sdk-js/${hash}/packages/issuer-sdk-js/assets/idos-credential-subject-v1.json`,\n idosCredentialSubjectV1,\n );\n });\n\n return loader.build();\n}\n\nexport const defaultDocumentLoader: JsonLDDocumentLoaderInstance = buildDocumentLoader();\n","import type { JsonLDDocumentLoaderInstance } from \"jsonld-document-loader\";\n\nimport { Ed25519Signature2020 } from \"@digitalbazaar/ed25519-signature-2020\";\nimport * as vc from \"@digitalbazaar/vc\";\n\nimport type {\n AvailableIssuerType,\n VerifiableCredential,\n VerifiableCredentialSubject,\n} from \"../types\";\n\nimport { issuerToKey } from \"../utils\";\nimport { defaultDocumentLoader } from \"./loader\";\n\nexport type VerifyCredentialResult = [boolean, Map<AvailableIssuerType, vc.VerifyCredentialResult>];\n\nexport async function verifyCredential<K = VerifiableCredentialSubject>(\n credential: VerifiableCredential<K>,\n issuers: AvailableIssuerType[],\n customDocumentLoader?: JsonLDDocumentLoaderInstance,\n): Promise<VerifyCredentialResult> {\n const resultsByIssuer: Map<AvailableIssuerType, vc.VerifyCredentialResult> = new Map();\n\n for (const issuer of issuers) {\n const publicKey = await issuerToKey(issuer);\n\n const vcVerifyingSuite = new Ed25519Signature2020({\n key: publicKey,\n verificationMethod: publicKey.id,\n });\n\n const controller = {\n \"@context\": \"https://w3id.org/security/v2\",\n id: publicKey.controller,\n assertionMethod: [publicKey.id],\n authentication: [publicKey.id],\n };\n\n // Verify the signature\n const verifyCredentialResult = await vc.verifyCredential<K>({\n credential: credential,\n suite: vcVerifyingSuite,\n controller,\n documentLoader: customDocumentLoader ?? defaultDocumentLoader,\n });\n\n resultsByIssuer.set(issuer, verifyCredentialResult);\n\n if (verifyCredentialResult.verified) {\n return [true, resultsByIssuer];\n }\n }\n\n return [false, resultsByIssuer];\n}\n","import { Ed25519Signature2020 } from \"@digitalbazaar/ed25519-signature-2020\";\nimport * as vc from \"@digitalbazaar/vc\";\n\nimport type { VerifyCredentialResult } from \"./verifier\";\n\nimport {\n type AvailableIssuerType,\n type CredentialFields,\n CredentialFieldsSchema,\n type CredentialSubject,\n type CredentialSubjectFaceId,\n CredentialSubjectFaceIdSchema,\n CredentialSubjectSchema,\n type VerifiableCredential,\n type VerifiableCredentialSubject,\n} from \"../types\";\nimport { convertValues, issuerToKey } from \"../utils\";\nimport {\n CONTEXT_IDOS_CREDENTIAL,\n CONTEXT_IDOS_CREDENTIAL_FACE_ID,\n CONTEXT_IDOS_CREDENTIAL_SUBJECT,\n CONTEXT_IDOS_SIGNATURE,\n CONTEXT_V1,\n defaultDocumentLoader,\n} from \"./loader\";\nimport { verifyCredential } from \"./verifier\";\n\nexport type Credential = VerifiableCredential<VerifiableCredentialSubject>;\nexport type FaceIdCredential = VerifiableCredential<CredentialSubjectFaceId>;\n\nexport type CredentialBuilder<TInput, TOutput = TInput> = (\n fields: CredentialFields,\n subject: TInput,\n issuer: AvailableIssuerType,\n validate?: boolean,\n) => Promise<VerifiableCredential<TOutput>>;\n\nexport type CredentialConverter<TInput> = (\n subject: TInput,\n validate: boolean,\n // oxlint-disable-next-line typescript/no-explicit-any -- any is needed here\n) => Record<string, any>;\n\nfunction genericCredentialBuilder<TInput, TOutput = TInput>(\n credentialConverter: CredentialConverter<TInput>,\n): CredentialBuilder<TInput, TOutput> {\n async function builder(\n fields: CredentialFields,\n subject: TInput,\n issuer: AvailableIssuerType,\n validate = true,\n ) {\n if (validate) {\n // This raises an z.ZodError exception if the fields are invalid\n CredentialFieldsSchema.parse(fields);\n }\n\n const credentialSubject = credentialConverter(subject, validate);\n\n const key = await issuerToKey(issuer);\n\n // Create credentials container\n const credential = {\n \"@context\": [CONTEXT_V1, CONTEXT_IDOS_CREDENTIAL, CONTEXT_IDOS_SIGNATURE],\n type: [\"VerifiableCredential\"],\n issuer: key.controller,\n ...convertValues(fields),\n credentialSubject,\n };\n\n const suite = new Ed25519Signature2020({ key });\n\n return vc.issue<TOutput>({\n credential,\n suite,\n documentLoader: defaultDocumentLoader,\n });\n }\n\n return builder;\n}\n\nexport const credentialSubjectConverter: CredentialConverter<CredentialSubject> = (\n subject,\n validate,\n) => {\n if (validate) {\n CredentialSubjectSchema.parse(subject);\n }\n\n const { residentialAddress, ...subjectData } = subject;\n return {\n \"@context\": CONTEXT_IDOS_CREDENTIAL_SUBJECT,\n ...convertValues(subjectData),\n ...(residentialAddress ? convertValues(residentialAddress, \"residentialAddress\") : {}),\n };\n};\n\nexport const credentialFaceIdSubjectConverter: CredentialConverter<CredentialSubjectFaceId> = (\n subject,\n validate,\n) => {\n if (validate) {\n CredentialSubjectFaceIdSchema.parse(subject);\n }\n\n return {\n \"@context\": CONTEXT_IDOS_CREDENTIAL_FACE_ID,\n ...convertValues(subject),\n };\n};\n\nexport const buildCredential: CredentialBuilder<CredentialSubject, VerifiableCredentialSubject> =\n genericCredentialBuilder<CredentialSubject, VerifiableCredentialSubject>(\n credentialSubjectConverter,\n );\n\nexport const buildFaceIdCredential: CredentialBuilder<CredentialSubjectFaceId> =\n genericCredentialBuilder<CredentialSubjectFaceId>(credentialFaceIdSubjectConverter);\n\nexport type { VerifyCredentialResult };\nexport { verifyCredential };\n"],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/types/credentials.ts","../../src/types/issuers.ts"],"mappings":";;;KAEY;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU,2BAA2B,KAAK;EAC1C,KAAK;EACL;EACA;EACA;;cAIW,wBAAwB,EAAE;EACrC,IAAI,EAAE;EACN,OAAO,EAAE;EACT,QAAQ,EAAE,YAAY,EAAE;EACxB,YAAY,EAAE,YAAY,EAAE;EAC5B,gBAAgB,EAAE,YAAY,EAAE;;KAiBtB,mBAAmB,EAAE,aAAa;cAGjC,oCAAoC,EAAE;EACjD,QAAQ,EAAE;EACV,aAAa,EAAE,YAAY,EAAE;EAC7B,uBAAuB,EAAE,YAAY,EAAE;EACvC,QAAQ,EAAE,YAAY,EAAE;EACxB,MAAM,EAAE;EACR,YAAY,EAAE,YAAY,EAAE;EAC5B,SAAS,EAAE;EACX,eAAe,EAAE;EACjB,kBAAkB,EAAE,YAAY,EAAE;EAClC,WAAW,EAAE,QAAQ,OAAO;;KAiClB,+BAA+B,EAAE,aAAa;cAE7C,sBAAsB,EAAE;EACnC;EACA;EACA;EACA;EACA;EACA;EACA;;KAUU,iBAAiB,EAAE,aAAa;cAE/B,cAAc,EAAE;EAC3B;EACA;EACA;;KAEU,SAAS,EAAE,aAAa;cAGvB,yBAAyB,EAAE;EACtC,IAAI,EAAE;EAEN,WAAW,EAAE,YAAY,EAAE;EAC3B,YAAY,EAAE,YAAY,EAAE;EAC5B,KAAK,EAAE,YAAY,EAAE;EACrB,QAAQ,EAAE,mBAAmB;EAC7B,aAAa,EAAE,YAAY,EAAE;EAE7B,YAAY,EAAE,YAAY,EAAE;EAC5B,YAAY,EAAE,YAAY,EAAE;EAC5B,OAAO,EAAE,YAAY,EAAE;EACvB,aAAa,EAAE,YAAY,EAAE;EAC7B,aAAa,EAAE;EACf,cAAc,EAAE,YAAY,EAAE;EAC9B,mBAAmB,EAAE;EACrB,kBAAkB,EAAE;EACpB,uBAAuB;EACvB,uBAAuB,EAAE,YAAY,EAAE;EACvC,wBAAwB,EAAE,YAAY,EAAE;EACxC,qBAAqB,EAAE,QAAQ,OAAO;EACtC,oBAAoB,EAAE,YAAY,EAAE,QAAQ,OAAO;EACnD,YAAY,EAAE,QAAQ,OAAO;EAC7B,oBAAoB,EAAE,mBAAmB;;KAwE/B,oBAAoB,EAAE,aAAa;UAE9B,oCAAoC,KACnD;EASA;EAEA;EACA;EACA;EAEA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EAEA;;UAMe;EACf;EACA;EACA;EACA;EACA;;cAGW,+BAA+B,EAAE;EAC5C,gBAAgB,EAAE;;KAKR,0BAA0B,EAAE,aAAa;UAEpC,oBAAoB;EACnC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,mBAAmB;EACnB;EACA,OAAO;;KAGG,qBAAqB,KAAK,oBAAoB;;;UCpRzC;EACf;EAGA;EAGA;;KAKU,sBACR,KAAK,6CACL,6BACA"}
|