@twin.org/identity-models 0.0.1-next.13 → 0.0.1-next.15
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IComponent } from "@twin.org/core";
|
|
2
|
-
import type { IJsonLdContextDefinitionRoot,
|
|
3
|
-
import type { DidVerificationMethodType, IDidDocument, IDidDocumentVerificationMethod, IDidService, IDidVerifiableCredential, IDidVerifiablePresentation } from "@twin.org/standards-w3c-did";
|
|
2
|
+
import type { IJsonLdContextDefinitionRoot, IJsonLdNodeObject } from "@twin.org/data-json-ld";
|
|
3
|
+
import type { DidVerificationMethodType, IDidDocument, IDidDocumentVerificationMethod, IDidProof, IDidService, IDidVerifiableCredential, IDidVerifiablePresentation } from "@twin.org/standards-w3c-did";
|
|
4
4
|
/**
|
|
5
5
|
* Interface describing an identity connector.
|
|
6
6
|
*/
|
|
@@ -67,8 +67,8 @@ export interface IIdentityConnector extends IComponent {
|
|
|
67
67
|
* @returns The created verifiable credential and its token.
|
|
68
68
|
* @throws NotFoundError if the id can not be resolved.
|
|
69
69
|
*/
|
|
70
|
-
createVerifiableCredential
|
|
71
|
-
verifiableCredential: IDidVerifiableCredential
|
|
70
|
+
createVerifiableCredential(controller: string, verificationMethodId: string, id: string | undefined, credential: IJsonLdNodeObject, revocationIndex?: number): Promise<{
|
|
71
|
+
verifiableCredential: IDidVerifiableCredential;
|
|
72
72
|
jwt: string;
|
|
73
73
|
}>;
|
|
74
74
|
/**
|
|
@@ -76,9 +76,9 @@ export interface IIdentityConnector extends IComponent {
|
|
|
76
76
|
* @param credentialJwt The credential to verify.
|
|
77
77
|
* @returns The credential stored in the jwt and the revocation status.
|
|
78
78
|
*/
|
|
79
|
-
checkVerifiableCredential
|
|
79
|
+
checkVerifiableCredential(credentialJwt: string): Promise<{
|
|
80
80
|
revoked: boolean;
|
|
81
|
-
verifiableCredential?: IDidVerifiableCredential
|
|
81
|
+
verifiableCredential?: IDidVerifiableCredential;
|
|
82
82
|
}>;
|
|
83
83
|
/**
|
|
84
84
|
* Revoke verifiable credential(s).
|
|
@@ -108,8 +108,8 @@ export interface IIdentityConnector extends IComponent {
|
|
|
108
108
|
* @returns The created verifiable presentation and its token.
|
|
109
109
|
* @throws NotFoundError if the id can not be resolved.
|
|
110
110
|
*/
|
|
111
|
-
createVerifiablePresentation
|
|
112
|
-
verifiablePresentation: IDidVerifiablePresentation
|
|
111
|
+
createVerifiablePresentation(controller: string, presentationMethodId: string, presentationId: string | undefined, contexts: IJsonLdContextDefinitionRoot | undefined, types: string | string[] | undefined, verifiableCredentials: (string | IDidVerifiableCredential)[], expiresInMinutes?: number): Promise<{
|
|
112
|
+
verifiablePresentation: IDidVerifiablePresentation;
|
|
113
113
|
jwt: string;
|
|
114
114
|
}>;
|
|
115
115
|
/**
|
|
@@ -117,9 +117,9 @@ export interface IIdentityConnector extends IComponent {
|
|
|
117
117
|
* @param presentationJwt The presentation to verify.
|
|
118
118
|
* @returns The presentation stored in the jwt and the revocation status.
|
|
119
119
|
*/
|
|
120
|
-
checkVerifiablePresentation
|
|
120
|
+
checkVerifiablePresentation(presentationJwt: string): Promise<{
|
|
121
121
|
revoked: boolean;
|
|
122
|
-
verifiablePresentation?: IDidVerifiablePresentation
|
|
122
|
+
verifiablePresentation?: IDidVerifiablePresentation;
|
|
123
123
|
issuers?: IDidDocument[];
|
|
124
124
|
}>;
|
|
125
125
|
/**
|
|
@@ -127,19 +127,14 @@ export interface IIdentityConnector extends IComponent {
|
|
|
127
127
|
* @param controller The controller of the identity who can make changes.
|
|
128
128
|
* @param verificationMethodId The verification method id to use.
|
|
129
129
|
* @param bytes The data bytes to sign.
|
|
130
|
-
* @returns The proof
|
|
130
|
+
* @returns The proof.
|
|
131
131
|
*/
|
|
132
|
-
createProof(controller: string, verificationMethodId: string, bytes: Uint8Array): Promise<
|
|
133
|
-
type: string;
|
|
134
|
-
value: Uint8Array;
|
|
135
|
-
}>;
|
|
132
|
+
createProof(controller: string, verificationMethodId: string, bytes: Uint8Array): Promise<IDidProof>;
|
|
136
133
|
/**
|
|
137
134
|
* Verify proof for arbitrary data with the specified verification method.
|
|
138
|
-
* @param verificationMethodId The verification method id to use.
|
|
139
135
|
* @param bytes The data bytes to verify.
|
|
140
|
-
* @param
|
|
141
|
-
* @
|
|
142
|
-
* @returns True if the signature is valid.
|
|
136
|
+
* @param proof The proof to verify.
|
|
137
|
+
* @returns True if the proof is verified.
|
|
143
138
|
*/
|
|
144
|
-
verifyProof(
|
|
139
|
+
verifyProof(bytes: Uint8Array, proof: IDidProof): Promise<boolean>;
|
|
145
140
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -194,14 +194,10 @@ NotFoundError if the id can not be resolved.
|
|
|
194
194
|
|
|
195
195
|
### createVerifiableCredential()
|
|
196
196
|
|
|
197
|
-
> **createVerifiableCredential
|
|
197
|
+
> **createVerifiableCredential**(`controller`, `verificationMethodId`, `id`, `credential`, `revocationIndex`?): `Promise`\<`object`\>
|
|
198
198
|
|
|
199
199
|
Create a verifiable credential for a verification method.
|
|
200
200
|
|
|
201
|
-
#### Type Parameters
|
|
202
|
-
|
|
203
|
-
• **T** *extends* `IJsonLdObject`
|
|
204
|
-
|
|
205
201
|
#### Parameters
|
|
206
202
|
|
|
207
203
|
• **controller**: `string`
|
|
@@ -216,7 +212,7 @@ The verification method id to use.
|
|
|
216
212
|
|
|
217
213
|
The id of the credential.
|
|
218
214
|
|
|
219
|
-
• **credential**: `
|
|
215
|
+
• **credential**: `IJsonLdNodeObject`
|
|
220
216
|
|
|
221
217
|
The credential to store in the verifiable credential.
|
|
222
218
|
|
|
@@ -232,7 +228,7 @@ The created verifiable credential and its token.
|
|
|
232
228
|
|
|
233
229
|
##### verifiableCredential
|
|
234
230
|
|
|
235
|
-
> **verifiableCredential**: `IDidVerifiableCredential
|
|
231
|
+
> **verifiableCredential**: `IDidVerifiableCredential`
|
|
236
232
|
|
|
237
233
|
##### jwt
|
|
238
234
|
|
|
@@ -246,14 +242,10 @@ NotFoundError if the id can not be resolved.
|
|
|
246
242
|
|
|
247
243
|
### checkVerifiableCredential()
|
|
248
244
|
|
|
249
|
-
> **checkVerifiableCredential
|
|
245
|
+
> **checkVerifiableCredential**(`credentialJwt`): `Promise`\<`object`\>
|
|
250
246
|
|
|
251
247
|
Check a verifiable credential is valid.
|
|
252
248
|
|
|
253
|
-
#### Type Parameters
|
|
254
|
-
|
|
255
|
-
• **T** *extends* `IJsonLdObject`
|
|
256
|
-
|
|
257
249
|
#### Parameters
|
|
258
250
|
|
|
259
251
|
• **credentialJwt**: `string`
|
|
@@ -272,7 +264,7 @@ The credential stored in the jwt and the revocation status.
|
|
|
272
264
|
|
|
273
265
|
##### verifiableCredential?
|
|
274
266
|
|
|
275
|
-
> `optional` **verifiableCredential**: `IDidVerifiableCredential
|
|
267
|
+
> `optional` **verifiableCredential**: `IDidVerifiableCredential`
|
|
276
268
|
|
|
277
269
|
***
|
|
278
270
|
|
|
@@ -334,14 +326,10 @@ Nothing.
|
|
|
334
326
|
|
|
335
327
|
### createVerifiablePresentation()
|
|
336
328
|
|
|
337
|
-
> **createVerifiablePresentation
|
|
329
|
+
> **createVerifiablePresentation**(`controller`, `presentationMethodId`, `presentationId`, `contexts`, `types`, `verifiableCredentials`, `expiresInMinutes`?): `Promise`\<`object`\>
|
|
338
330
|
|
|
339
331
|
Create a verifiable presentation from the supplied verifiable credentials.
|
|
340
332
|
|
|
341
|
-
#### Type Parameters
|
|
342
|
-
|
|
343
|
-
• **T** *extends* `IJsonLdObject`
|
|
344
|
-
|
|
345
333
|
#### Parameters
|
|
346
334
|
|
|
347
335
|
• **controller**: `string`
|
|
@@ -364,7 +352,7 @@ The contexts for the data stored in the verifiable credential.
|
|
|
364
352
|
|
|
365
353
|
The types for the data stored in the verifiable credential.
|
|
366
354
|
|
|
367
|
-
• **verifiableCredentials**: (`string` \| `IDidVerifiableCredential
|
|
355
|
+
• **verifiableCredentials**: (`string` \| `IDidVerifiableCredential`)[]
|
|
368
356
|
|
|
369
357
|
The credentials to use for creating the presentation in jwt format.
|
|
370
358
|
|
|
@@ -380,7 +368,7 @@ The created verifiable presentation and its token.
|
|
|
380
368
|
|
|
381
369
|
##### verifiablePresentation
|
|
382
370
|
|
|
383
|
-
> **verifiablePresentation**: `IDidVerifiablePresentation
|
|
371
|
+
> **verifiablePresentation**: `IDidVerifiablePresentation`
|
|
384
372
|
|
|
385
373
|
##### jwt
|
|
386
374
|
|
|
@@ -394,14 +382,10 @@ NotFoundError if the id can not be resolved.
|
|
|
394
382
|
|
|
395
383
|
### checkVerifiablePresentation()
|
|
396
384
|
|
|
397
|
-
> **checkVerifiablePresentation
|
|
385
|
+
> **checkVerifiablePresentation**(`presentationJwt`): `Promise`\<`object`\>
|
|
398
386
|
|
|
399
387
|
Check a verifiable presentation is valid.
|
|
400
388
|
|
|
401
|
-
#### Type Parameters
|
|
402
|
-
|
|
403
|
-
• **T** *extends* `IJsonLdObject`
|
|
404
|
-
|
|
405
389
|
#### Parameters
|
|
406
390
|
|
|
407
391
|
• **presentationJwt**: `string`
|
|
@@ -420,7 +404,7 @@ The presentation stored in the jwt and the revocation status.
|
|
|
420
404
|
|
|
421
405
|
##### verifiablePresentation?
|
|
422
406
|
|
|
423
|
-
> `optional` **verifiablePresentation**: `IDidVerifiablePresentation
|
|
407
|
+
> `optional` **verifiablePresentation**: `IDidVerifiablePresentation`
|
|
424
408
|
|
|
425
409
|
##### issuers?
|
|
426
410
|
|
|
@@ -430,7 +414,7 @@ The presentation stored in the jwt and the revocation status.
|
|
|
430
414
|
|
|
431
415
|
### createProof()
|
|
432
416
|
|
|
433
|
-
> **createProof**(`controller`, `verificationMethodId`, `bytes`): `Promise`\<`
|
|
417
|
+
> **createProof**(`controller`, `verificationMethodId`, `bytes`): `Promise`\<`IDidProof`\>
|
|
434
418
|
|
|
435
419
|
Create a proof for arbitrary data with the specified verification method.
|
|
436
420
|
|
|
@@ -450,46 +434,30 @@ The data bytes to sign.
|
|
|
450
434
|
|
|
451
435
|
#### Returns
|
|
452
436
|
|
|
453
|
-
`Promise`\<`
|
|
454
|
-
|
|
455
|
-
The proof signature type and value.
|
|
437
|
+
`Promise`\<`IDidProof`\>
|
|
456
438
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
> **type**: `string`
|
|
460
|
-
|
|
461
|
-
##### value
|
|
462
|
-
|
|
463
|
-
> **value**: `Uint8Array`
|
|
439
|
+
The proof.
|
|
464
440
|
|
|
465
441
|
***
|
|
466
442
|
|
|
467
443
|
### verifyProof()
|
|
468
444
|
|
|
469
|
-
> **verifyProof**(`
|
|
445
|
+
> **verifyProof**(`bytes`, `proof`): `Promise`\<`boolean`\>
|
|
470
446
|
|
|
471
447
|
Verify proof for arbitrary data with the specified verification method.
|
|
472
448
|
|
|
473
449
|
#### Parameters
|
|
474
450
|
|
|
475
|
-
• **verificationMethodId**: `string`
|
|
476
|
-
|
|
477
|
-
The verification method id to use.
|
|
478
|
-
|
|
479
451
|
• **bytes**: `Uint8Array`
|
|
480
452
|
|
|
481
453
|
The data bytes to verify.
|
|
482
454
|
|
|
483
|
-
• **
|
|
484
|
-
|
|
485
|
-
The type of the signature for the proof.
|
|
486
|
-
|
|
487
|
-
• **signatureValue**: `Uint8Array`
|
|
455
|
+
• **proof**: `IDidProof`
|
|
488
456
|
|
|
489
|
-
The
|
|
457
|
+
The proof to verify.
|
|
490
458
|
|
|
491
459
|
#### Returns
|
|
492
460
|
|
|
493
461
|
`Promise`\<`boolean`\>
|
|
494
462
|
|
|
495
|
-
True if the
|
|
463
|
+
True if the proof is verified.
|