@idos-network/credentials 1.1.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/LICENSE +21 -0
- package/README.md +153 -0
- package/assets/country-codes.xml +271 -0
- package/assets/ed25519-signature-2020-v1.json +93 -0
- package/assets/idos-credential-subject-face-id-v1.json +8 -0
- package/assets/idos-credential-subject-v1.json +41 -0
- package/assets/idos-credential-subject-v2.json +37 -0
- package/assets/idos-credentials-v1.json +9 -0
- package/assets/v1.json +273 -0
- package/dist/builder/index.d.mts +20 -0
- package/dist/builder/index.d.mts.map +1 -0
- package/dist/builder/index.mjs +619 -0
- package/dist/builder/index.mjs.map +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1 -0
- package/dist/types/index.d.mts +135 -0
- package/dist/types/index.d.mts.map +1 -0
- package/dist/types/index.mjs +63 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/utils/index.d.mts +33 -0
- package/dist/utils/index.d.mts.map +1 -0
- package/dist/utils/index.mjs +124 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +73 -0
- package/src/builder/builder.test.ts +407 -0
- package/src/builder/index.ts +122 -0
- package/src/builder/loader.ts +76 -0
- package/src/builder/verifier.ts +55 -0
- package/src/index.ts +2 -0
- package/src/types/credentials.ts +282 -0
- package/src/types/index.ts +4 -0
- package/src/types/issuers.ts +21 -0
- package/src/utils/index.ts +277 -0
- package/src/utils/utils.test.ts +303 -0
- package/types/index.d.ts +4 -0
- package/types/internals.d.ts +124 -0
package/assets/v1.json
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": {
|
|
3
|
+
"@version": 1.1,
|
|
4
|
+
"@protected": true,
|
|
5
|
+
|
|
6
|
+
"id": "@id",
|
|
7
|
+
"type": "@type",
|
|
8
|
+
|
|
9
|
+
"VerifiableCredential": {
|
|
10
|
+
"@id": "https://www.w3.org/2018/credentials#VerifiableCredential",
|
|
11
|
+
"@context": {
|
|
12
|
+
"@version": 1.1,
|
|
13
|
+
"@protected": true,
|
|
14
|
+
|
|
15
|
+
"id": "@id",
|
|
16
|
+
"type": "@type",
|
|
17
|
+
|
|
18
|
+
"cred": "https://www.w3.org/2018/credentials#",
|
|
19
|
+
"sec": "https://w3id.org/security#",
|
|
20
|
+
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
|
21
|
+
|
|
22
|
+
"credentialSchema": {
|
|
23
|
+
"@id": "cred:credentialSchema",
|
|
24
|
+
"@type": "@id",
|
|
25
|
+
"@context": {
|
|
26
|
+
"@version": 1.1,
|
|
27
|
+
"@protected": true,
|
|
28
|
+
|
|
29
|
+
"id": "@id",
|
|
30
|
+
"type": "@type",
|
|
31
|
+
|
|
32
|
+
"cred": "https://www.w3.org/2018/credentials#",
|
|
33
|
+
|
|
34
|
+
"JsonSchemaValidator2018": "cred:JsonSchemaValidator2018"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"credentialStatus": { "@id": "cred:credentialStatus", "@type": "@id" },
|
|
38
|
+
"credentialSubject": { "@id": "cred:credentialSubject", "@type": "@id" },
|
|
39
|
+
"evidence": { "@id": "cred:evidence", "@type": "@id" },
|
|
40
|
+
"expirationDate": { "@id": "cred:expirationDate", "@type": "xsd:dateTime" },
|
|
41
|
+
"holder": { "@id": "cred:holder", "@type": "@id" },
|
|
42
|
+
"issued": { "@id": "cred:issued", "@type": "xsd:dateTime" },
|
|
43
|
+
"issuer": { "@id": "cred:issuer", "@type": "@id" },
|
|
44
|
+
"issuanceDate": { "@id": "cred:issuanceDate", "@type": "xsd:dateTime" },
|
|
45
|
+
"proof": { "@id": "sec:proof", "@type": "@id", "@container": "@graph" },
|
|
46
|
+
"refreshService": {
|
|
47
|
+
"@id": "cred:refreshService",
|
|
48
|
+
"@type": "@id",
|
|
49
|
+
"@context": {
|
|
50
|
+
"@version": 1.1,
|
|
51
|
+
"@protected": true,
|
|
52
|
+
|
|
53
|
+
"id": "@id",
|
|
54
|
+
"type": "@type",
|
|
55
|
+
|
|
56
|
+
"cred": "https://www.w3.org/2018/credentials#",
|
|
57
|
+
|
|
58
|
+
"ManualRefreshService2018": "cred:ManualRefreshService2018"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"termsOfUse": { "@id": "cred:termsOfUse", "@type": "@id" },
|
|
62
|
+
"validFrom": { "@id": "cred:validFrom", "@type": "xsd:dateTime" },
|
|
63
|
+
"validUntil": { "@id": "cred:validUntil", "@type": "xsd:dateTime" }
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
"VerifiablePresentation": {
|
|
68
|
+
"@id": "https://www.w3.org/2018/credentials#VerifiablePresentation",
|
|
69
|
+
"@context": {
|
|
70
|
+
"@version": 1.1,
|
|
71
|
+
"@protected": true,
|
|
72
|
+
|
|
73
|
+
"id": "@id",
|
|
74
|
+
"type": "@type",
|
|
75
|
+
|
|
76
|
+
"cred": "https://www.w3.org/2018/credentials#",
|
|
77
|
+
"sec": "https://w3id.org/security#",
|
|
78
|
+
|
|
79
|
+
"holder": { "@id": "cred:holder", "@type": "@id" },
|
|
80
|
+
"proof": { "@id": "sec:proof", "@type": "@id", "@container": "@graph" },
|
|
81
|
+
"verifiableCredential": {
|
|
82
|
+
"@id": "cred:verifiableCredential",
|
|
83
|
+
"@type": "@id",
|
|
84
|
+
"@container": "@graph"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
"EcdsaSecp256k1Signature2019": {
|
|
90
|
+
"@id": "https://w3id.org/security#EcdsaSecp256k1Signature2019",
|
|
91
|
+
"@context": {
|
|
92
|
+
"@version": 1.1,
|
|
93
|
+
"@protected": true,
|
|
94
|
+
|
|
95
|
+
"id": "@id",
|
|
96
|
+
"type": "@type",
|
|
97
|
+
|
|
98
|
+
"sec": "https://w3id.org/security#",
|
|
99
|
+
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
|
100
|
+
|
|
101
|
+
"challenge": "sec:challenge",
|
|
102
|
+
"created": { "@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime" },
|
|
103
|
+
"domain": "sec:domain",
|
|
104
|
+
"expires": { "@id": "sec:expiration", "@type": "xsd:dateTime" },
|
|
105
|
+
"jws": "sec:jws",
|
|
106
|
+
"nonce": "sec:nonce",
|
|
107
|
+
"proofPurpose": {
|
|
108
|
+
"@id": "sec:proofPurpose",
|
|
109
|
+
"@type": "@vocab",
|
|
110
|
+
"@context": {
|
|
111
|
+
"@version": 1.1,
|
|
112
|
+
"@protected": true,
|
|
113
|
+
|
|
114
|
+
"id": "@id",
|
|
115
|
+
"type": "@type",
|
|
116
|
+
|
|
117
|
+
"sec": "https://w3id.org/security#",
|
|
118
|
+
|
|
119
|
+
"assertionMethod": {
|
|
120
|
+
"@id": "sec:assertionMethod",
|
|
121
|
+
"@type": "@id",
|
|
122
|
+
"@container": "@set"
|
|
123
|
+
},
|
|
124
|
+
"authentication": {
|
|
125
|
+
"@id": "sec:authenticationMethod",
|
|
126
|
+
"@type": "@id",
|
|
127
|
+
"@container": "@set"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
"proofValue": "sec:proofValue",
|
|
132
|
+
"verificationMethod": { "@id": "sec:verificationMethod", "@type": "@id" }
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
"EcdsaSecp256r1Signature2019": {
|
|
137
|
+
"@id": "https://w3id.org/security#EcdsaSecp256r1Signature2019",
|
|
138
|
+
"@context": {
|
|
139
|
+
"@version": 1.1,
|
|
140
|
+
"@protected": true,
|
|
141
|
+
|
|
142
|
+
"id": "@id",
|
|
143
|
+
"type": "@type",
|
|
144
|
+
|
|
145
|
+
"sec": "https://w3id.org/security#",
|
|
146
|
+
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
|
147
|
+
|
|
148
|
+
"challenge": "sec:challenge",
|
|
149
|
+
"created": { "@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime" },
|
|
150
|
+
"domain": "sec:domain",
|
|
151
|
+
"expires": { "@id": "sec:expiration", "@type": "xsd:dateTime" },
|
|
152
|
+
"jws": "sec:jws",
|
|
153
|
+
"nonce": "sec:nonce",
|
|
154
|
+
"proofPurpose": {
|
|
155
|
+
"@id": "sec:proofPurpose",
|
|
156
|
+
"@type": "@vocab",
|
|
157
|
+
"@context": {
|
|
158
|
+
"@version": 1.1,
|
|
159
|
+
"@protected": true,
|
|
160
|
+
|
|
161
|
+
"id": "@id",
|
|
162
|
+
"type": "@type",
|
|
163
|
+
|
|
164
|
+
"sec": "https://w3id.org/security#",
|
|
165
|
+
|
|
166
|
+
"assertionMethod": {
|
|
167
|
+
"@id": "sec:assertionMethod",
|
|
168
|
+
"@type": "@id",
|
|
169
|
+
"@container": "@set"
|
|
170
|
+
},
|
|
171
|
+
"authentication": {
|
|
172
|
+
"@id": "sec:authenticationMethod",
|
|
173
|
+
"@type": "@id",
|
|
174
|
+
"@container": "@set"
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
"proofValue": "sec:proofValue",
|
|
179
|
+
"verificationMethod": { "@id": "sec:verificationMethod", "@type": "@id" }
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
"Ed25519Signature2018": {
|
|
184
|
+
"@id": "https://w3id.org/security#Ed25519Signature2018",
|
|
185
|
+
"@context": {
|
|
186
|
+
"@version": 1.1,
|
|
187
|
+
"@protected": true,
|
|
188
|
+
|
|
189
|
+
"id": "@id",
|
|
190
|
+
"type": "@type",
|
|
191
|
+
|
|
192
|
+
"sec": "https://w3id.org/security#",
|
|
193
|
+
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
|
194
|
+
|
|
195
|
+
"challenge": "sec:challenge",
|
|
196
|
+
"created": { "@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime" },
|
|
197
|
+
"domain": "sec:domain",
|
|
198
|
+
"expires": { "@id": "sec:expiration", "@type": "xsd:dateTime" },
|
|
199
|
+
"jws": "sec:jws",
|
|
200
|
+
"nonce": "sec:nonce",
|
|
201
|
+
"proofPurpose": {
|
|
202
|
+
"@id": "sec:proofPurpose",
|
|
203
|
+
"@type": "@vocab",
|
|
204
|
+
"@context": {
|
|
205
|
+
"@version": 1.1,
|
|
206
|
+
"@protected": true,
|
|
207
|
+
|
|
208
|
+
"id": "@id",
|
|
209
|
+
"type": "@type",
|
|
210
|
+
|
|
211
|
+
"sec": "https://w3id.org/security#",
|
|
212
|
+
|
|
213
|
+
"assertionMethod": {
|
|
214
|
+
"@id": "sec:assertionMethod",
|
|
215
|
+
"@type": "@id",
|
|
216
|
+
"@container": "@set"
|
|
217
|
+
},
|
|
218
|
+
"authentication": {
|
|
219
|
+
"@id": "sec:authenticationMethod",
|
|
220
|
+
"@type": "@id",
|
|
221
|
+
"@container": "@set"
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
"proofValue": "sec:proofValue",
|
|
226
|
+
"verificationMethod": { "@id": "sec:verificationMethod", "@type": "@id" }
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
"RsaSignature2018": {
|
|
231
|
+
"@id": "https://w3id.org/security#RsaSignature2018",
|
|
232
|
+
"@context": {
|
|
233
|
+
"@version": 1.1,
|
|
234
|
+
"@protected": true,
|
|
235
|
+
|
|
236
|
+
"challenge": "sec:challenge",
|
|
237
|
+
"created": { "@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime" },
|
|
238
|
+
"domain": "sec:domain",
|
|
239
|
+
"expires": { "@id": "sec:expiration", "@type": "xsd:dateTime" },
|
|
240
|
+
"jws": "sec:jws",
|
|
241
|
+
"nonce": "sec:nonce",
|
|
242
|
+
"proofPurpose": {
|
|
243
|
+
"@id": "sec:proofPurpose",
|
|
244
|
+
"@type": "@vocab",
|
|
245
|
+
"@context": {
|
|
246
|
+
"@version": 1.1,
|
|
247
|
+
"@protected": true,
|
|
248
|
+
|
|
249
|
+
"id": "@id",
|
|
250
|
+
"type": "@type",
|
|
251
|
+
|
|
252
|
+
"sec": "https://w3id.org/security#",
|
|
253
|
+
|
|
254
|
+
"assertionMethod": {
|
|
255
|
+
"@id": "sec:assertionMethod",
|
|
256
|
+
"@type": "@id",
|
|
257
|
+
"@container": "@set"
|
|
258
|
+
},
|
|
259
|
+
"authentication": {
|
|
260
|
+
"@id": "sec:authenticationMethod",
|
|
261
|
+
"@type": "@id",
|
|
262
|
+
"@container": "@set"
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
"proofValue": "sec:proofValue",
|
|
267
|
+
"verificationMethod": { "@id": "sec:verificationMethod", "@type": "@id" }
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
|
|
271
|
+
"proof": { "@id": "https://w3id.org/security#proof", "@type": "@id", "@container": "@graph" }
|
|
272
|
+
}
|
|
273
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AvailableIssuerType, CredentialFields, CredentialSubject, CredentialSubjectFaceId, VerifiableCredential, VerifiableCredentialSubject } from "../types/index.mjs";
|
|
2
|
+
import * as vc from "@digitalbazaar/vc";
|
|
3
|
+
import { JsonLDDocumentLoaderInstance } from "jsonld-document-loader";
|
|
4
|
+
|
|
5
|
+
//#region src/builder/verifier.d.ts
|
|
6
|
+
type VerifyCredentialResult = [boolean, Map<AvailableIssuerType, vc.VerifyCredentialResult>];
|
|
7
|
+
declare function verifyCredential<K = VerifiableCredentialSubject>(credential: VerifiableCredential<K>, issuers: AvailableIssuerType[], customDocumentLoader?: JsonLDDocumentLoaderInstance): Promise<VerifyCredentialResult>;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/builder/index.d.ts
|
|
10
|
+
type Credential = VerifiableCredential<VerifiableCredentialSubject>;
|
|
11
|
+
type FaceIdCredential = VerifiableCredential<CredentialSubjectFaceId>;
|
|
12
|
+
type CredentialBuilder<TInput, TOutput = TInput> = (fields: CredentialFields, subject: TInput, issuer: AvailableIssuerType, validate?: boolean) => Promise<VerifiableCredential<TOutput>>;
|
|
13
|
+
type CredentialConverter<TInput> = (subject: TInput, validate: boolean) => Record<string, any>;
|
|
14
|
+
declare const credentialSubjectConverter: CredentialConverter<CredentialSubject>;
|
|
15
|
+
declare const credentialFaceIdSubjectConverter: CredentialConverter<CredentialSubjectFaceId>;
|
|
16
|
+
declare const buildCredential: CredentialBuilder<CredentialSubject, VerifiableCredentialSubject>;
|
|
17
|
+
declare const buildFaceIdCredential: CredentialBuilder<CredentialSubjectFaceId>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { Credential, CredentialBuilder, CredentialConverter, FaceIdCredential, type VerifyCredentialResult, buildCredential, buildFaceIdCredential, credentialFaceIdSubjectConverter, credentialSubjectConverter, verifyCredential };
|
|
20
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/builder/verifier.ts","../../src/builder/index.ts"],"mappings":";;;;;KAcY,sBAAA,aAAmC,GAAA,CAAI,mBAAA,EAAqB,EAAA,CAAG,sBAAA;AAAA,iBAErD,gBAAA,KAAqB,2BAAA,CAAA,CACzC,UAAA,EAAY,oBAAA,CAAqB,CAAA,GACjC,OAAA,EAAS,mBAAA,IACT,oBAAA,GAAuB,4BAAA,GACtB,OAAA,CAAQ,sBAAA;;;KCOC,UAAA,GAAa,oBAAA,CAAqB,2BAAA;AAAA,KAClC,gBAAA,GAAmB,oBAAA,CAAqB,uBAAA;AAAA,KAExC,iBAAA,mBAAoC,MAAA,KAC9C,MAAA,EAAQ,gBAAA,EACR,OAAA,EAAS,MAAA,EACT,MAAA,EAAQ,mBAAA,EACR,QAAA,eACG,OAAA,CAAQ,oBAAA,CAAqB,OAAA;AAAA,KAEtB,mBAAA,YACV,OAAA,EAAS,MAAA,EACT,QAAA,cAEG,MAAA;AAAA,cAyCQ,0BAAA,EAA4B,mBAAA,CAAoB,iBAAA;AAAA,cAgBhD,gCAAA,EAAkC,mBAAA,CAAoB,uBAAA;AAAA,cActD,eAAA,EAAiB,iBAAA,CAAkB,iBAAA,EAAmB,2BAAA;AAAA,cAKtD,qBAAA,EAAuB,iBAAA,CAAkB,uBAAA"}
|