@twin.org/identity-models 0.0.1-next.10

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.
Files changed (47) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +21 -0
  3. package/dist/cjs/index.cjs +71 -0
  4. package/dist/esm/index.mjs +66 -0
  5. package/dist/types/factories/identityConnectorFactory.d.ts +6 -0
  6. package/dist/types/factories/identityProfileConnectorFactory.d.ts +6 -0
  7. package/dist/types/index.d.ts +18 -0
  8. package/dist/types/models/IIdentityComponent.d.ts +13 -0
  9. package/dist/types/models/IIdentityConnector.d.ts +145 -0
  10. package/dist/types/models/IIdentityProfileComponent.d.ts +72 -0
  11. package/dist/types/models/IIdentityProfileConnector.d.ts +70 -0
  12. package/dist/types/models/api/IIdentityProfileCreateRequest.d.ts +19 -0
  13. package/dist/types/models/api/IIdentityProfileGetPublicRequest.d.ts +23 -0
  14. package/dist/types/models/api/IIdentityProfileGetPublicResponse.d.ts +17 -0
  15. package/dist/types/models/api/IIdentityProfileGetRequest.d.ts +18 -0
  16. package/dist/types/models/api/IIdentityProfileGetResponse.d.ts +23 -0
  17. package/dist/types/models/api/IIdentityProfileListRequest.d.ts +26 -0
  18. package/dist/types/models/api/IIdentityProfileListResponse.d.ts +28 -0
  19. package/dist/types/models/api/IIdentityProfileUpdateRequest.d.ts +19 -0
  20. package/dist/types/models/api/IIdentityResolveRequest.d.ts +14 -0
  21. package/dist/types/models/api/IIdentityResolveResponse.d.ts +10 -0
  22. package/dist/types/models/identityRole.d.ts +21 -0
  23. package/dist/types/utils/documentHelper.d.ts +14 -0
  24. package/docs/changelog.md +5 -0
  25. package/docs/examples.md +1 -0
  26. package/docs/reference/classes/DocumentHelper.md +41 -0
  27. package/docs/reference/index.md +32 -0
  28. package/docs/reference/interfaces/IIdentityComponent.md +27 -0
  29. package/docs/reference/interfaces/IIdentityConnector.md +495 -0
  30. package/docs/reference/interfaces/IIdentityProfileComponent.md +197 -0
  31. package/docs/reference/interfaces/IIdentityProfileConnector.md +177 -0
  32. package/docs/reference/interfaces/IIdentityProfileCreateRequest.md +23 -0
  33. package/docs/reference/interfaces/IIdentityProfileGetPublicRequest.md +31 -0
  34. package/docs/reference/interfaces/IIdentityProfileGetPublicResponse.md +23 -0
  35. package/docs/reference/interfaces/IIdentityProfileGetRequest.md +23 -0
  36. package/docs/reference/interfaces/IIdentityProfileGetResponse.md +29 -0
  37. package/docs/reference/interfaces/IIdentityProfileListRequest.md +35 -0
  38. package/docs/reference/interfaces/IIdentityProfileListResponse.md +23 -0
  39. package/docs/reference/interfaces/IIdentityProfileUpdateRequest.md +23 -0
  40. package/docs/reference/interfaces/IIdentityResolveRequest.md +17 -0
  41. package/docs/reference/interfaces/IIdentityResolveResponse.md +11 -0
  42. package/docs/reference/type-aliases/IdentityRole.md +5 -0
  43. package/docs/reference/variables/IdentityConnectorFactory.md +5 -0
  44. package/docs/reference/variables/IdentityProfileConnectorFactory.md +5 -0
  45. package/docs/reference/variables/IdentityRole.md +25 -0
  46. package/locales/en.json +13 -0
  47. package/package.json +42 -0
@@ -0,0 +1,495 @@
1
+ # Interface: IIdentityConnector
2
+
3
+ Interface describing an identity connector.
4
+
5
+ ## Extends
6
+
7
+ - `IComponent`
8
+
9
+ ## Methods
10
+
11
+ ### createDocument()
12
+
13
+ > **createDocument**(`controller`): `Promise`\<`IDidDocument`\>
14
+
15
+ Create a new document.
16
+
17
+ #### Parameters
18
+
19
+ • **controller**: `string`
20
+
21
+ The controller of the identity who can make changes.
22
+
23
+ #### Returns
24
+
25
+ `Promise`\<`IDidDocument`\>
26
+
27
+ The created document.
28
+
29
+ ***
30
+
31
+ ### resolveDocument()
32
+
33
+ > **resolveDocument**(`documentId`): `Promise`\<`IDidDocument`\>
34
+
35
+ Resolve a document from its id.
36
+
37
+ #### Parameters
38
+
39
+ • **documentId**: `string`
40
+
41
+ The id of the document to resolve.
42
+
43
+ #### Returns
44
+
45
+ `Promise`\<`IDidDocument`\>
46
+
47
+ The resolved document.
48
+
49
+ #### Throws
50
+
51
+ NotFoundError if the id can not be resolved.
52
+
53
+ ***
54
+
55
+ ### addVerificationMethod()
56
+
57
+ > **addVerificationMethod**(`controller`, `documentId`, `verificationMethodType`, `verificationMethodId`?): `Promise`\<`IDidDocumentVerificationMethod`\>
58
+
59
+ Add a verification method to the document in JSON Web key Format.
60
+
61
+ #### Parameters
62
+
63
+ • **controller**: `string`
64
+
65
+ The controller of the identity who can make changes.
66
+
67
+ • **documentId**: `string`
68
+
69
+ The id of the document to add the verification method to.
70
+
71
+ • **verificationMethodType**: `DidVerificationMethodType`
72
+
73
+ The type of the verification method to add.
74
+
75
+ • **verificationMethodId?**: `string`
76
+
77
+ The id of the verification method, if undefined uses the kid of the generated JWK.
78
+
79
+ #### Returns
80
+
81
+ `Promise`\<`IDidDocumentVerificationMethod`\>
82
+
83
+ The verification method.
84
+
85
+ #### Throws
86
+
87
+ NotFoundError if the id can not be resolved.
88
+
89
+ #### Throws
90
+
91
+ NotSupportedError if the platform does not support multiple keys.
92
+
93
+ ***
94
+
95
+ ### removeVerificationMethod()
96
+
97
+ > **removeVerificationMethod**(`controller`, `verificationMethodId`): `Promise`\<`void`\>
98
+
99
+ Remove a verification method from the document.
100
+
101
+ #### Parameters
102
+
103
+ • **controller**: `string`
104
+
105
+ The controller of the identity who can make changes.
106
+
107
+ • **verificationMethodId**: `string`
108
+
109
+ The id of the verification method.
110
+
111
+ #### Returns
112
+
113
+ `Promise`\<`void`\>
114
+
115
+ Nothing.
116
+
117
+ #### Throws
118
+
119
+ NotFoundError if the id can not be resolved.
120
+
121
+ #### Throws
122
+
123
+ NotSupportedError if the platform does not support multiple revocable keys.
124
+
125
+ ***
126
+
127
+ ### addService()
128
+
129
+ > **addService**(`controller`, `documentId`, `serviceId`, `serviceType`, `serviceEndpoint`): `Promise`\<`IDidService`\>
130
+
131
+ Add a service to the document.
132
+
133
+ #### Parameters
134
+
135
+ • **controller**: `string`
136
+
137
+ The controller of the identity who can make changes.
138
+
139
+ • **documentId**: `string`
140
+
141
+ The id of the document to add the service to.
142
+
143
+ • **serviceId**: `string`
144
+
145
+ The id of the service.
146
+
147
+ • **serviceType**: `string`
148
+
149
+ The type of the service.
150
+
151
+ • **serviceEndpoint**: `string`
152
+
153
+ The endpoint for the service.
154
+
155
+ #### Returns
156
+
157
+ `Promise`\<`IDidService`\>
158
+
159
+ The service.
160
+
161
+ #### Throws
162
+
163
+ NotFoundError if the id can not be resolved.
164
+
165
+ ***
166
+
167
+ ### removeService()
168
+
169
+ > **removeService**(`controller`, `serviceId`): `Promise`\<`void`\>
170
+
171
+ Remove a service from the document.
172
+
173
+ #### Parameters
174
+
175
+ • **controller**: `string`
176
+
177
+ The controller of the identity who can make changes.
178
+
179
+ • **serviceId**: `string`
180
+
181
+ The id of the service.
182
+
183
+ #### Returns
184
+
185
+ `Promise`\<`void`\>
186
+
187
+ Nothing.
188
+
189
+ #### Throws
190
+
191
+ NotFoundError if the id can not be resolved.
192
+
193
+ ***
194
+
195
+ ### createVerifiableCredential()
196
+
197
+ > **createVerifiableCredential**\<`T`\>(`controller`, `verificationMethodId`, `id`, `credential`, `revocationIndex`?): `Promise`\<`object`\>
198
+
199
+ Create a verifiable credential for a verification method.
200
+
201
+ #### Type Parameters
202
+
203
+ • **T** *extends* `IJsonLdObject` = `IJsonLdObject`
204
+
205
+ #### Parameters
206
+
207
+ • **controller**: `string`
208
+
209
+ The controller of the identity who can make changes.
210
+
211
+ • **verificationMethodId**: `string`
212
+
213
+ The verification method id to use.
214
+
215
+ • **id**: `undefined` \| `string`
216
+
217
+ The id of the credential.
218
+
219
+ • **credential**: `T`
220
+
221
+ The credential to store in the verifiable credential.
222
+
223
+ • **revocationIndex?**: `number`
224
+
225
+ The bitmap revocation index of the credential, if undefined will not have revocation status.
226
+
227
+ #### Returns
228
+
229
+ `Promise`\<`object`\>
230
+
231
+ The created verifiable credential and its token.
232
+
233
+ ##### verifiableCredential
234
+
235
+ > **verifiableCredential**: `IDidVerifiableCredential`\<`T`\>
236
+
237
+ ##### jwt
238
+
239
+ > **jwt**: `string`
240
+
241
+ #### Throws
242
+
243
+ NotFoundError if the id can not be resolved.
244
+
245
+ ***
246
+
247
+ ### checkVerifiableCredential()
248
+
249
+ > **checkVerifiableCredential**\<`T`\>(`credentialJwt`): `Promise`\<`object`\>
250
+
251
+ Check a verifiable credential is valid.
252
+
253
+ #### Type Parameters
254
+
255
+ • **T** *extends* `IJsonLdObject` = `IJsonLdObject`
256
+
257
+ #### Parameters
258
+
259
+ • **credentialJwt**: `string`
260
+
261
+ The credential to verify.
262
+
263
+ #### Returns
264
+
265
+ `Promise`\<`object`\>
266
+
267
+ The credential stored in the jwt and the revocation status.
268
+
269
+ ##### revoked
270
+
271
+ > **revoked**: `boolean`
272
+
273
+ ##### verifiableCredential?
274
+
275
+ > `optional` **verifiableCredential**: `IDidVerifiableCredential`\<`T`\>
276
+
277
+ ***
278
+
279
+ ### revokeVerifiableCredentials()
280
+
281
+ > **revokeVerifiableCredentials**(`controller`, `issuerDocumentId`, `credentialIndices`): `Promise`\<`void`\>
282
+
283
+ Revoke verifiable credential(s).
284
+
285
+ #### Parameters
286
+
287
+ • **controller**: `string`
288
+
289
+ The controller of the identity who can make changes.
290
+
291
+ • **issuerDocumentId**: `string`
292
+
293
+ The id of the document to update the revocation list for.
294
+
295
+ • **credentialIndices**: `number`[]
296
+
297
+ The revocation bitmap index or indices to revoke.
298
+
299
+ #### Returns
300
+
301
+ `Promise`\<`void`\>
302
+
303
+ Nothing.
304
+
305
+ ***
306
+
307
+ ### unrevokeVerifiableCredentials()
308
+
309
+ > **unrevokeVerifiableCredentials**(`controller`, `issuerDocumentId`, `credentialIndices`): `Promise`\<`void`\>
310
+
311
+ Unrevoke verifiable credential(s).
312
+
313
+ #### Parameters
314
+
315
+ • **controller**: `string`
316
+
317
+ The controller of the identity who can make changes.
318
+
319
+ • **issuerDocumentId**: `string`
320
+
321
+ The id of the document to update the revocation list for.
322
+
323
+ • **credentialIndices**: `number`[]
324
+
325
+ The revocation bitmap index or indices to un revoke.
326
+
327
+ #### Returns
328
+
329
+ `Promise`\<`void`\>
330
+
331
+ Nothing.
332
+
333
+ ***
334
+
335
+ ### createVerifiablePresentation()
336
+
337
+ > **createVerifiablePresentation**\<`T`\>(`controller`, `presentationMethodId`, `presentationId`, `contexts`, `types`, `verifiableCredentials`, `expiresInMinutes`?): `Promise`\<`object`\>
338
+
339
+ Create a verifiable presentation from the supplied verifiable credentials.
340
+
341
+ #### Type Parameters
342
+
343
+ • **T** *extends* `IJsonLdObject` = `IJsonLdObject`
344
+
345
+ #### Parameters
346
+
347
+ • **controller**: `string`
348
+
349
+ The controller of the identity who can make changes.
350
+
351
+ • **presentationMethodId**: `string`
352
+
353
+ The method to associate with the presentation.
354
+
355
+ • **presentationId**: `undefined` \| `string`
356
+
357
+ The id of the presentation.
358
+
359
+ • **contexts**: `undefined` \| `IJsonLdContextDefinitionRoot`
360
+
361
+ The contexts for the data stored in the verifiable credential.
362
+
363
+ • **types**: `undefined` \| `string` \| `string`[]
364
+
365
+ The types for the data stored in the verifiable credential.
366
+
367
+ • **verifiableCredentials**: (`string` \| `IDidVerifiableCredential`\<`T`\>)[]
368
+
369
+ The credentials to use for creating the presentation in jwt format.
370
+
371
+ • **expiresInMinutes?**: `number`
372
+
373
+ The time in minutes for the presentation to expire.
374
+
375
+ #### Returns
376
+
377
+ `Promise`\<`object`\>
378
+
379
+ The created verifiable presentation and its token.
380
+
381
+ ##### verifiablePresentation
382
+
383
+ > **verifiablePresentation**: `IDidVerifiablePresentation`\<`T`\>
384
+
385
+ ##### jwt
386
+
387
+ > **jwt**: `string`
388
+
389
+ #### Throws
390
+
391
+ NotFoundError if the id can not be resolved.
392
+
393
+ ***
394
+
395
+ ### checkVerifiablePresentation()
396
+
397
+ > **checkVerifiablePresentation**\<`T`\>(`presentationJwt`): `Promise`\<`object`\>
398
+
399
+ Check a verifiable presentation is valid.
400
+
401
+ #### Type Parameters
402
+
403
+ • **T** *extends* `IJsonLdObject` = `IJsonLdObject`
404
+
405
+ #### Parameters
406
+
407
+ • **presentationJwt**: `string`
408
+
409
+ The presentation to verify.
410
+
411
+ #### Returns
412
+
413
+ `Promise`\<`object`\>
414
+
415
+ The presentation stored in the jwt and the revocation status.
416
+
417
+ ##### revoked
418
+
419
+ > **revoked**: `boolean`
420
+
421
+ ##### verifiablePresentation?
422
+
423
+ > `optional` **verifiablePresentation**: `IDidVerifiablePresentation`\<`T`\>
424
+
425
+ ##### issuers?
426
+
427
+ > `optional` **issuers**: `IDidDocument`[]
428
+
429
+ ***
430
+
431
+ ### createProof()
432
+
433
+ > **createProof**(`controller`, `verificationMethodId`, `bytes`): `Promise`\<`object`\>
434
+
435
+ Create a proof for arbitrary data with the specified verification method.
436
+
437
+ #### Parameters
438
+
439
+ • **controller**: `string`
440
+
441
+ The controller of the identity who can make changes.
442
+
443
+ • **verificationMethodId**: `string`
444
+
445
+ The verification method id to use.
446
+
447
+ • **bytes**: `Uint8Array`
448
+
449
+ The data bytes to sign.
450
+
451
+ #### Returns
452
+
453
+ `Promise`\<`object`\>
454
+
455
+ The proof signature type and value.
456
+
457
+ ##### type
458
+
459
+ > **type**: `string`
460
+
461
+ ##### value
462
+
463
+ > **value**: `Uint8Array`
464
+
465
+ ***
466
+
467
+ ### verifyProof()
468
+
469
+ > **verifyProof**(`verificationMethodId`, `bytes`, `signatureType`, `signatureValue`): `Promise`\<`boolean`\>
470
+
471
+ Verify proof for arbitrary data with the specified verification method.
472
+
473
+ #### Parameters
474
+
475
+ • **verificationMethodId**: `string`
476
+
477
+ The verification method id to use.
478
+
479
+ • **bytes**: `Uint8Array`
480
+
481
+ The data bytes to verify.
482
+
483
+ • **signatureType**: `string`
484
+
485
+ The type of the signature for the proof.
486
+
487
+ • **signatureValue**: `Uint8Array`
488
+
489
+ The value of the signature for the proof.
490
+
491
+ #### Returns
492
+
493
+ `Promise`\<`boolean`\>
494
+
495
+ True if the signature is valid.
@@ -0,0 +1,197 @@
1
+ # Interface: IIdentityProfileComponent\<T, U\>
2
+
3
+ Interface describing a contract which provides profile operations.
4
+
5
+ ## Extends
6
+
7
+ - `IComponent`
8
+
9
+ ## Type Parameters
10
+
11
+ • **T** *extends* `IJsonLdDocument` = `IJsonLdDocument`
12
+
13
+ • **U** *extends* `IJsonLdDocument` = `IJsonLdDocument`
14
+
15
+ ## Methods
16
+
17
+ ### create()
18
+
19
+ > **create**(`publicProfile`?, `privateProfile`?, `identity`?): `Promise`\<`void`\>
20
+
21
+ Create the profile properties for an identity.
22
+
23
+ #### Parameters
24
+
25
+ • **publicProfile?**: `T`
26
+
27
+ The public profile data as JSON-LD.
28
+
29
+ • **privateProfile?**: `U`
30
+
31
+ The private profile data as JSON-LD.
32
+
33
+ • **identity?**: `string`
34
+
35
+ The identity to perform the profile operation on.
36
+
37
+ #### Returns
38
+
39
+ `Promise`\<`void`\>
40
+
41
+ Nothing.
42
+
43
+ ***
44
+
45
+ ### get()
46
+
47
+ > **get**(`publicPropertyNames`?, `privatePropertyNames`?, `identity`?): `Promise`\<`object`\>
48
+
49
+ Get the profile properties for an identity.
50
+
51
+ #### Parameters
52
+
53
+ • **publicPropertyNames?**: keyof `T`[]
54
+
55
+ The public properties to get for the profile, defaults to all.
56
+
57
+ • **privatePropertyNames?**: keyof `U`[]
58
+
59
+ The private properties to get for the profile, defaults to all.
60
+
61
+ • **identity?**: `string`
62
+
63
+ The identity to perform the profile operation on.
64
+
65
+ #### Returns
66
+
67
+ `Promise`\<`object`\>
68
+
69
+ The items identity and the properties.
70
+
71
+ ##### identity
72
+
73
+ > **identity**: `string`
74
+
75
+ ##### publicProfile?
76
+
77
+ > `optional` **publicProfile**: `Partial`\<`T`\>
78
+
79
+ ##### privateProfile?
80
+
81
+ > `optional` **privateProfile**: `Partial`\<`U`\>
82
+
83
+ ***
84
+
85
+ ### getPublic()
86
+
87
+ > **getPublic**(`identity`, `propertyNames`?): `Promise`\<`Partial`\<`T`\>\>
88
+
89
+ Get the public profile properties for an identity.
90
+
91
+ #### Parameters
92
+
93
+ • **identity**: `string`
94
+
95
+ The identity to perform the profile operation on.
96
+
97
+ • **propertyNames?**: keyof `T`[]
98
+
99
+ The public properties to get for the profile, defaults to all.
100
+
101
+ #### Returns
102
+
103
+ `Promise`\<`Partial`\<`T`\>\>
104
+
105
+ The items properties.
106
+
107
+ ***
108
+
109
+ ### update()
110
+
111
+ > **update**(`publicProfile`?, `privateProfile`?, `identity`?): `Promise`\<`void`\>
112
+
113
+ Update the profile properties of an identity.
114
+
115
+ #### Parameters
116
+
117
+ • **publicProfile?**: `T`
118
+
119
+ The public profile data as JSON-LD.
120
+
121
+ • **privateProfile?**: `U`
122
+
123
+ The private profile data as JSON-LD.
124
+
125
+ • **identity?**: `string`
126
+
127
+ The identity to perform the profile operation on.
128
+
129
+ #### Returns
130
+
131
+ `Promise`\<`void`\>
132
+
133
+ Nothing.
134
+
135
+ ***
136
+
137
+ ### remove()
138
+
139
+ > **remove**(`identity`?): `Promise`\<`void`\>
140
+
141
+ Delete the profile for an identity.
142
+
143
+ #### Parameters
144
+
145
+ • **identity?**: `string`
146
+
147
+ The identity to perform the profile operation on.
148
+
149
+ #### Returns
150
+
151
+ `Promise`\<`void`\>
152
+
153
+ Nothing.
154
+
155
+ ***
156
+
157
+ ### list()
158
+
159
+ > **list**(`publicFilters`?, `publicPropertyNames`?, `cursor`?, `pageSize`?): `Promise`\<`object`\>
160
+
161
+ Get a list of the requested identities.
162
+
163
+ #### Parameters
164
+
165
+ • **publicFilters?**: `object`[]
166
+
167
+ The filters to apply to the identities public profiles.
168
+
169
+ • **publicPropertyNames?**: keyof `T`[]
170
+
171
+ The public properties to get for the profile, defaults to all.
172
+
173
+ • **cursor?**: `string`
174
+
175
+ The cursor for paged requests.
176
+
177
+ • **pageSize?**: `number`
178
+
179
+ The maximum number of items in a page.
180
+
181
+ #### Returns
182
+
183
+ `Promise`\<`object`\>
184
+
185
+ The list of items and cursor for paging.
186
+
187
+ ##### items
188
+
189
+ > **items**: `object`[]
190
+
191
+ The identities.
192
+
193
+ ##### cursor?
194
+
195
+ > `optional` **cursor**: `string`
196
+
197
+ An optional cursor, when defined can be used to call find to get more entities.