@twin.org/identity-connector-entity-storage 0.0.1-next.4 → 0.0.1-next.6
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/cjs/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var entity = require('@twin.org/entity');
|
|
4
4
|
var core = require('@twin.org/core');
|
|
5
5
|
var crypto = require('@twin.org/crypto');
|
|
6
|
+
var dataJsonLd = require('@twin.org/data-json-ld');
|
|
6
7
|
var entityStorageModels = require('@twin.org/entity-storage-models');
|
|
7
8
|
var identityModels = require('@twin.org/identity-models');
|
|
8
9
|
var standardsW3cDid = require('@twin.org/standards-w3c-did');
|
|
@@ -372,38 +373,16 @@ class EntityStorageIdentityConnector {
|
|
|
372
373
|
* Create a verifiable credential for a verification method.
|
|
373
374
|
* @param controller The controller of the identity who can make changes.
|
|
374
375
|
* @param verificationMethodId The verification method id to use.
|
|
375
|
-
* @param
|
|
376
|
-
* @param
|
|
377
|
-
* @param subject The subject data to store for the credential.
|
|
378
|
-
* @param contexts Additional contexts to include in the credential.
|
|
376
|
+
* @param id The id of the credential.
|
|
377
|
+
* @param credential The credential to store in the verifiable credential.
|
|
379
378
|
* @param revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.
|
|
380
379
|
* @returns The created verifiable credential and its token.
|
|
381
380
|
* @throws NotFoundError if the id can not be resolved.
|
|
382
381
|
*/
|
|
383
|
-
async createVerifiableCredential(controller, verificationMethodId,
|
|
382
|
+
async createVerifiableCredential(controller, verificationMethodId, id, credential, revocationIndex) {
|
|
384
383
|
core.Guards.stringValue(this.CLASS_NAME, "controller", controller);
|
|
385
384
|
core.Guards.stringValue(this.CLASS_NAME, "verificationMethodId", verificationMethodId);
|
|
386
|
-
|
|
387
|
-
core.Guards.stringValue(this.CLASS_NAME, "credentialId", credentialId);
|
|
388
|
-
}
|
|
389
|
-
if (core.Is.array(types)) {
|
|
390
|
-
core.Guards.array(this.CLASS_NAME, "types", types);
|
|
391
|
-
}
|
|
392
|
-
else if (!core.Is.undefined(types)) {
|
|
393
|
-
core.Guards.stringValue(this.CLASS_NAME, "types", types);
|
|
394
|
-
}
|
|
395
|
-
if (core.Is.array(subject)) {
|
|
396
|
-
core.Guards.arrayValue(this.CLASS_NAME, "subject", subject);
|
|
397
|
-
}
|
|
398
|
-
else {
|
|
399
|
-
core.Guards.object(this.CLASS_NAME, "subject", subject);
|
|
400
|
-
}
|
|
401
|
-
if (core.Is.array(contexts)) {
|
|
402
|
-
core.Guards.array(this.CLASS_NAME, "contexts", contexts);
|
|
403
|
-
}
|
|
404
|
-
else if (!core.Is.undefined(contexts)) {
|
|
405
|
-
core.Guards.stringValue(this.CLASS_NAME, "contexts", contexts);
|
|
406
|
-
}
|
|
385
|
+
core.Guards.object(this.CLASS_NAME, "credential", credential);
|
|
407
386
|
if (!core.Is.undefined(revocationIndex)) {
|
|
408
387
|
core.Guards.number(this.CLASS_NAME, "revocationIndex", revocationIndex);
|
|
409
388
|
}
|
|
@@ -434,24 +413,18 @@ class EntityStorageIdentityConnector {
|
|
|
434
413
|
}
|
|
435
414
|
const revocationService = issuerDidDocument.service?.find(s => s.id.endsWith("#revocation"));
|
|
436
415
|
const finalTypes = ["VerifiableCredential"];
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
finalTypes.push(
|
|
442
|
-
}
|
|
443
|
-
const finalContexts = ["https://www.w3.org/2018/credentials/v1"];
|
|
444
|
-
if (core.Is.array(contexts)) {
|
|
445
|
-
finalContexts.push(...contexts);
|
|
446
|
-
}
|
|
447
|
-
else if (core.Is.stringValue(contexts)) {
|
|
448
|
-
finalContexts.push(contexts);
|
|
416
|
+
const credContext = dataJsonLd.JsonLdProcessor.extractProperty(credential, ["@context"]);
|
|
417
|
+
const credId = dataJsonLd.JsonLdProcessor.extractProperty(credential, ["@id", "id"], false);
|
|
418
|
+
const credType = dataJsonLd.JsonLdProcessor.extractProperty(credential, ["@type", "type"]);
|
|
419
|
+
if (core.Is.stringValue(credType)) {
|
|
420
|
+
finalTypes.push(credType);
|
|
449
421
|
}
|
|
450
422
|
const verifiableCredential = {
|
|
451
|
-
"@context":
|
|
452
|
-
|
|
423
|
+
"@context": dataJsonLd.JsonLdProcessor.combineContexts("https://www.w3.org/2018/credentials/v2", credContext) ??
|
|
424
|
+
null,
|
|
425
|
+
id,
|
|
453
426
|
type: finalTypes,
|
|
454
|
-
credentialSubject:
|
|
427
|
+
credentialSubject: credential,
|
|
455
428
|
issuer: issuerDidDocument.id,
|
|
456
429
|
issuanceDate: new Date().toISOString(),
|
|
457
430
|
credentialStatus: revocationService && !core.Is.undefined(revocationIndex)
|
|
@@ -488,9 +461,7 @@ class EntityStorageIdentityConnector {
|
|
|
488
461
|
iss: idParts.id,
|
|
489
462
|
nbf: Math.floor(Date.now() / 1000),
|
|
490
463
|
jti: verifiableCredential.id,
|
|
491
|
-
sub:
|
|
492
|
-
? core.ObjectHelper.propertyGet(subject[0], "id")
|
|
493
|
-
: core.ObjectHelper.propertyGet(subject, "id"),
|
|
464
|
+
sub: credId,
|
|
494
465
|
vc: jwtVc
|
|
495
466
|
};
|
|
496
467
|
const signature = await web.Jwt.encodeWithSigner(jwtHeader, jwtPayload, async (alg, key, payload) => {
|
|
@@ -662,14 +633,15 @@ class EntityStorageIdentityConnector {
|
|
|
662
633
|
* Create a verifiable presentation from the supplied verifiable credentials.
|
|
663
634
|
* @param controller The controller of the identity who can make changes.
|
|
664
635
|
* @param presentationMethodId The method to associate with the presentation.
|
|
636
|
+
* @param presentationId The id of the presentation.
|
|
637
|
+
* @param contexts The contexts for the data stored in the verifiable credential.
|
|
665
638
|
* @param types The types for the data stored in the verifiable credential.
|
|
666
639
|
* @param verifiableCredentials The credentials to use for creating the presentation in jwt format.
|
|
667
|
-
* @param contexts Additional contexts to include in the presentation.
|
|
668
640
|
* @param expiresInMinutes The time in minutes for the presentation to expire.
|
|
669
641
|
* @returns The created verifiable presentation and its token.
|
|
670
642
|
* @throws NotFoundError if the id can not be resolved.
|
|
671
643
|
*/
|
|
672
|
-
async createVerifiablePresentation(controller, presentationMethodId, types, verifiableCredentials,
|
|
644
|
+
async createVerifiablePresentation(controller, presentationMethodId, presentationId, contexts, types, verifiableCredentials, expiresInMinutes) {
|
|
673
645
|
core.Guards.stringValue(this.CLASS_NAME, "controller", controller);
|
|
674
646
|
core.Guards.stringValue(this.CLASS_NAME, "presentationMethodId", presentationMethodId);
|
|
675
647
|
if (core.Is.array(types)) {
|
|
@@ -679,12 +651,6 @@ class EntityStorageIdentityConnector {
|
|
|
679
651
|
core.Guards.stringValue(this.CLASS_NAME, "types", types);
|
|
680
652
|
}
|
|
681
653
|
core.Guards.arrayValue(this.CLASS_NAME, "verifiableCredentials", verifiableCredentials);
|
|
682
|
-
if (core.Is.array(contexts)) {
|
|
683
|
-
core.Guards.arrayValue(this.CLASS_NAME, "contexts", contexts);
|
|
684
|
-
}
|
|
685
|
-
else if (core.Is.string(contexts)) {
|
|
686
|
-
core.Guards.stringValue(this.CLASS_NAME, "contexts", contexts);
|
|
687
|
-
}
|
|
688
654
|
if (!core.Is.undefined(expiresInMinutes)) {
|
|
689
655
|
core.Guards.integer(this.CLASS_NAME, "expiresInMinutes", expiresInMinutes);
|
|
690
656
|
}
|
|
@@ -720,15 +686,10 @@ class EntityStorageIdentityConnector {
|
|
|
720
686
|
else if (core.Is.stringValue(types)) {
|
|
721
687
|
finalTypes.push(types);
|
|
722
688
|
}
|
|
723
|
-
const finalContexts = ["https://www.w3.org/2018/credentials/v1"];
|
|
724
|
-
if (core.Is.array(contexts)) {
|
|
725
|
-
finalContexts.push(...contexts);
|
|
726
|
-
}
|
|
727
|
-
else if (core.Is.stringValue(contexts)) {
|
|
728
|
-
finalContexts.push(contexts);
|
|
729
|
-
}
|
|
730
689
|
const verifiablePresentation = {
|
|
731
|
-
"@context":
|
|
690
|
+
"@context": dataJsonLd.JsonLdProcessor.combineContexts("https://www.w3.org/2018/credentials/v2", contexts) ??
|
|
691
|
+
null,
|
|
692
|
+
id: presentationId,
|
|
732
693
|
type: finalTypes,
|
|
733
694
|
verifiableCredential: verifiableCredentials,
|
|
734
695
|
holder: idParts.id
|
|
@@ -795,22 +756,27 @@ class EntityStorageIdentityConnector {
|
|
|
795
756
|
if (core.Is.object(verifiablePresentation) &&
|
|
796
757
|
core.Is.array(verifiablePresentation.verifiableCredential)) {
|
|
797
758
|
for (const vcJwt of verifiablePresentation.verifiableCredential) {
|
|
798
|
-
const jwt = await web.Jwt.decode(vcJwt);
|
|
799
759
|
let revoked = true;
|
|
800
|
-
if (core.Is.
|
|
801
|
-
const
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
760
|
+
if (core.Is.stringValue(vcJwt)) {
|
|
761
|
+
const jwt = await web.Jwt.decode(vcJwt);
|
|
762
|
+
if (core.Is.string(jwt.payload?.iss)) {
|
|
763
|
+
const issuerDocumentId = jwt.payload.iss;
|
|
764
|
+
verifiablePresentation.holder = issuerDocumentId;
|
|
765
|
+
const issuerDidDocument = await this._didDocumentEntityStorage.get(issuerDocumentId);
|
|
766
|
+
if (core.Is.undefined(issuerDidDocument)) {
|
|
767
|
+
throw new core.NotFoundError(this.CLASS_NAME, "documentNotFound", issuerDocumentId);
|
|
768
|
+
}
|
|
769
|
+
await this.verifyDocument(issuerDidDocument);
|
|
770
|
+
issuers.push(issuerDidDocument);
|
|
771
|
+
const vc = jwt.payload.vc;
|
|
772
|
+
if (core.Is.object(vc)) {
|
|
773
|
+
revoked = await this.checkRevocation(issuerDidDocument, vc.credentialStatus?.revocationBitmapIndex);
|
|
774
|
+
}
|
|
812
775
|
}
|
|
813
776
|
}
|
|
777
|
+
else {
|
|
778
|
+
revoked = false;
|
|
779
|
+
}
|
|
814
780
|
tokensRevoked.push(revoked);
|
|
815
781
|
}
|
|
816
782
|
}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { property, entity, ComparisonOperator, EntitySchemaFactory, EntitySchemaHelper } from '@twin.org/entity';
|
|
2
2
|
import { Guards, Converter, RandomHelper, BitString, Compression, CompressionType, GeneralError, Is, NotFoundError, ObjectHelper, Coerce, JsonHelper, AlreadyExistsError, BaseError } from '@twin.org/core';
|
|
3
3
|
import { Sha256 } from '@twin.org/crypto';
|
|
4
|
+
import { JsonLdProcessor } from '@twin.org/data-json-ld';
|
|
4
5
|
import { EntityStorageConnectorFactory } from '@twin.org/entity-storage-models';
|
|
5
6
|
import { DocumentHelper } from '@twin.org/identity-models';
|
|
6
7
|
import { DidVerificationMethodType } from '@twin.org/standards-w3c-did';
|
|
@@ -370,38 +371,16 @@ class EntityStorageIdentityConnector {
|
|
|
370
371
|
* Create a verifiable credential for a verification method.
|
|
371
372
|
* @param controller The controller of the identity who can make changes.
|
|
372
373
|
* @param verificationMethodId The verification method id to use.
|
|
373
|
-
* @param
|
|
374
|
-
* @param
|
|
375
|
-
* @param subject The subject data to store for the credential.
|
|
376
|
-
* @param contexts Additional contexts to include in the credential.
|
|
374
|
+
* @param id The id of the credential.
|
|
375
|
+
* @param credential The credential to store in the verifiable credential.
|
|
377
376
|
* @param revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.
|
|
378
377
|
* @returns The created verifiable credential and its token.
|
|
379
378
|
* @throws NotFoundError if the id can not be resolved.
|
|
380
379
|
*/
|
|
381
|
-
async createVerifiableCredential(controller, verificationMethodId,
|
|
380
|
+
async createVerifiableCredential(controller, verificationMethodId, id, credential, revocationIndex) {
|
|
382
381
|
Guards.stringValue(this.CLASS_NAME, "controller", controller);
|
|
383
382
|
Guards.stringValue(this.CLASS_NAME, "verificationMethodId", verificationMethodId);
|
|
384
|
-
|
|
385
|
-
Guards.stringValue(this.CLASS_NAME, "credentialId", credentialId);
|
|
386
|
-
}
|
|
387
|
-
if (Is.array(types)) {
|
|
388
|
-
Guards.array(this.CLASS_NAME, "types", types);
|
|
389
|
-
}
|
|
390
|
-
else if (!Is.undefined(types)) {
|
|
391
|
-
Guards.stringValue(this.CLASS_NAME, "types", types);
|
|
392
|
-
}
|
|
393
|
-
if (Is.array(subject)) {
|
|
394
|
-
Guards.arrayValue(this.CLASS_NAME, "subject", subject);
|
|
395
|
-
}
|
|
396
|
-
else {
|
|
397
|
-
Guards.object(this.CLASS_NAME, "subject", subject);
|
|
398
|
-
}
|
|
399
|
-
if (Is.array(contexts)) {
|
|
400
|
-
Guards.array(this.CLASS_NAME, "contexts", contexts);
|
|
401
|
-
}
|
|
402
|
-
else if (!Is.undefined(contexts)) {
|
|
403
|
-
Guards.stringValue(this.CLASS_NAME, "contexts", contexts);
|
|
404
|
-
}
|
|
383
|
+
Guards.object(this.CLASS_NAME, "credential", credential);
|
|
405
384
|
if (!Is.undefined(revocationIndex)) {
|
|
406
385
|
Guards.number(this.CLASS_NAME, "revocationIndex", revocationIndex);
|
|
407
386
|
}
|
|
@@ -432,24 +411,18 @@ class EntityStorageIdentityConnector {
|
|
|
432
411
|
}
|
|
433
412
|
const revocationService = issuerDidDocument.service?.find(s => s.id.endsWith("#revocation"));
|
|
434
413
|
const finalTypes = ["VerifiableCredential"];
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
finalTypes.push(
|
|
440
|
-
}
|
|
441
|
-
const finalContexts = ["https://www.w3.org/2018/credentials/v1"];
|
|
442
|
-
if (Is.array(contexts)) {
|
|
443
|
-
finalContexts.push(...contexts);
|
|
444
|
-
}
|
|
445
|
-
else if (Is.stringValue(contexts)) {
|
|
446
|
-
finalContexts.push(contexts);
|
|
414
|
+
const credContext = JsonLdProcessor.extractProperty(credential, ["@context"]);
|
|
415
|
+
const credId = JsonLdProcessor.extractProperty(credential, ["@id", "id"], false);
|
|
416
|
+
const credType = JsonLdProcessor.extractProperty(credential, ["@type", "type"]);
|
|
417
|
+
if (Is.stringValue(credType)) {
|
|
418
|
+
finalTypes.push(credType);
|
|
447
419
|
}
|
|
448
420
|
const verifiableCredential = {
|
|
449
|
-
"@context":
|
|
450
|
-
|
|
421
|
+
"@context": JsonLdProcessor.combineContexts("https://www.w3.org/2018/credentials/v2", credContext) ??
|
|
422
|
+
null,
|
|
423
|
+
id,
|
|
451
424
|
type: finalTypes,
|
|
452
|
-
credentialSubject:
|
|
425
|
+
credentialSubject: credential,
|
|
453
426
|
issuer: issuerDidDocument.id,
|
|
454
427
|
issuanceDate: new Date().toISOString(),
|
|
455
428
|
credentialStatus: revocationService && !Is.undefined(revocationIndex)
|
|
@@ -486,9 +459,7 @@ class EntityStorageIdentityConnector {
|
|
|
486
459
|
iss: idParts.id,
|
|
487
460
|
nbf: Math.floor(Date.now() / 1000),
|
|
488
461
|
jti: verifiableCredential.id,
|
|
489
|
-
sub:
|
|
490
|
-
? ObjectHelper.propertyGet(subject[0], "id")
|
|
491
|
-
: ObjectHelper.propertyGet(subject, "id"),
|
|
462
|
+
sub: credId,
|
|
492
463
|
vc: jwtVc
|
|
493
464
|
};
|
|
494
465
|
const signature = await Jwt.encodeWithSigner(jwtHeader, jwtPayload, async (alg, key, payload) => {
|
|
@@ -660,14 +631,15 @@ class EntityStorageIdentityConnector {
|
|
|
660
631
|
* Create a verifiable presentation from the supplied verifiable credentials.
|
|
661
632
|
* @param controller The controller of the identity who can make changes.
|
|
662
633
|
* @param presentationMethodId The method to associate with the presentation.
|
|
634
|
+
* @param presentationId The id of the presentation.
|
|
635
|
+
* @param contexts The contexts for the data stored in the verifiable credential.
|
|
663
636
|
* @param types The types for the data stored in the verifiable credential.
|
|
664
637
|
* @param verifiableCredentials The credentials to use for creating the presentation in jwt format.
|
|
665
|
-
* @param contexts Additional contexts to include in the presentation.
|
|
666
638
|
* @param expiresInMinutes The time in minutes for the presentation to expire.
|
|
667
639
|
* @returns The created verifiable presentation and its token.
|
|
668
640
|
* @throws NotFoundError if the id can not be resolved.
|
|
669
641
|
*/
|
|
670
|
-
async createVerifiablePresentation(controller, presentationMethodId, types, verifiableCredentials,
|
|
642
|
+
async createVerifiablePresentation(controller, presentationMethodId, presentationId, contexts, types, verifiableCredentials, expiresInMinutes) {
|
|
671
643
|
Guards.stringValue(this.CLASS_NAME, "controller", controller);
|
|
672
644
|
Guards.stringValue(this.CLASS_NAME, "presentationMethodId", presentationMethodId);
|
|
673
645
|
if (Is.array(types)) {
|
|
@@ -677,12 +649,6 @@ class EntityStorageIdentityConnector {
|
|
|
677
649
|
Guards.stringValue(this.CLASS_NAME, "types", types);
|
|
678
650
|
}
|
|
679
651
|
Guards.arrayValue(this.CLASS_NAME, "verifiableCredentials", verifiableCredentials);
|
|
680
|
-
if (Is.array(contexts)) {
|
|
681
|
-
Guards.arrayValue(this.CLASS_NAME, "contexts", contexts);
|
|
682
|
-
}
|
|
683
|
-
else if (Is.string(contexts)) {
|
|
684
|
-
Guards.stringValue(this.CLASS_NAME, "contexts", contexts);
|
|
685
|
-
}
|
|
686
652
|
if (!Is.undefined(expiresInMinutes)) {
|
|
687
653
|
Guards.integer(this.CLASS_NAME, "expiresInMinutes", expiresInMinutes);
|
|
688
654
|
}
|
|
@@ -718,15 +684,10 @@ class EntityStorageIdentityConnector {
|
|
|
718
684
|
else if (Is.stringValue(types)) {
|
|
719
685
|
finalTypes.push(types);
|
|
720
686
|
}
|
|
721
|
-
const finalContexts = ["https://www.w3.org/2018/credentials/v1"];
|
|
722
|
-
if (Is.array(contexts)) {
|
|
723
|
-
finalContexts.push(...contexts);
|
|
724
|
-
}
|
|
725
|
-
else if (Is.stringValue(contexts)) {
|
|
726
|
-
finalContexts.push(contexts);
|
|
727
|
-
}
|
|
728
687
|
const verifiablePresentation = {
|
|
729
|
-
"@context":
|
|
688
|
+
"@context": JsonLdProcessor.combineContexts("https://www.w3.org/2018/credentials/v2", contexts) ??
|
|
689
|
+
null,
|
|
690
|
+
id: presentationId,
|
|
730
691
|
type: finalTypes,
|
|
731
692
|
verifiableCredential: verifiableCredentials,
|
|
732
693
|
holder: idParts.id
|
|
@@ -793,22 +754,27 @@ class EntityStorageIdentityConnector {
|
|
|
793
754
|
if (Is.object(verifiablePresentation) &&
|
|
794
755
|
Is.array(verifiablePresentation.verifiableCredential)) {
|
|
795
756
|
for (const vcJwt of verifiablePresentation.verifiableCredential) {
|
|
796
|
-
const jwt = await Jwt.decode(vcJwt);
|
|
797
757
|
let revoked = true;
|
|
798
|
-
if (Is.
|
|
799
|
-
const
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
758
|
+
if (Is.stringValue(vcJwt)) {
|
|
759
|
+
const jwt = await Jwt.decode(vcJwt);
|
|
760
|
+
if (Is.string(jwt.payload?.iss)) {
|
|
761
|
+
const issuerDocumentId = jwt.payload.iss;
|
|
762
|
+
verifiablePresentation.holder = issuerDocumentId;
|
|
763
|
+
const issuerDidDocument = await this._didDocumentEntityStorage.get(issuerDocumentId);
|
|
764
|
+
if (Is.undefined(issuerDidDocument)) {
|
|
765
|
+
throw new NotFoundError(this.CLASS_NAME, "documentNotFound", issuerDocumentId);
|
|
766
|
+
}
|
|
767
|
+
await this.verifyDocument(issuerDidDocument);
|
|
768
|
+
issuers.push(issuerDidDocument);
|
|
769
|
+
const vc = jwt.payload.vc;
|
|
770
|
+
if (Is.object(vc)) {
|
|
771
|
+
revoked = await this.checkRevocation(issuerDidDocument, vc.credentialStatus?.revocationBitmapIndex);
|
|
772
|
+
}
|
|
810
773
|
}
|
|
811
774
|
}
|
|
775
|
+
else {
|
|
776
|
+
revoked = false;
|
|
777
|
+
}
|
|
812
778
|
tokensRevoked.push(revoked);
|
|
813
779
|
}
|
|
814
780
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type IJsonLdNodeObject, type IJsonLdContextDefinitionRoot } from "@twin.org/data-json-ld";
|
|
1
2
|
import { type IIdentityConnector } from "@twin.org/identity-models";
|
|
2
3
|
import { DidVerificationMethodType, type IDidDocument, type IDidDocumentVerificationMethod, type IDidService, type IDidVerifiableCredential, type IDidVerifiablePresentation } from "@twin.org/standards-w3c-did";
|
|
3
4
|
/**
|
|
@@ -78,16 +79,14 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
|
|
|
78
79
|
* Create a verifiable credential for a verification method.
|
|
79
80
|
* @param controller The controller of the identity who can make changes.
|
|
80
81
|
* @param verificationMethodId The verification method id to use.
|
|
81
|
-
* @param
|
|
82
|
-
* @param
|
|
83
|
-
* @param subject The subject data to store for the credential.
|
|
84
|
-
* @param contexts Additional contexts to include in the credential.
|
|
82
|
+
* @param id The id of the credential.
|
|
83
|
+
* @param credential The credential to store in the verifiable credential.
|
|
85
84
|
* @param revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.
|
|
86
85
|
* @returns The created verifiable credential and its token.
|
|
87
86
|
* @throws NotFoundError if the id can not be resolved.
|
|
88
87
|
*/
|
|
89
|
-
createVerifiableCredential
|
|
90
|
-
verifiableCredential: IDidVerifiableCredential
|
|
88
|
+
createVerifiableCredential(controller: string, verificationMethodId: string, id: string | undefined, credential: IJsonLdNodeObject, revocationIndex?: number): Promise<{
|
|
89
|
+
verifiableCredential: IDidVerifiableCredential;
|
|
91
90
|
jwt: string;
|
|
92
91
|
}>;
|
|
93
92
|
/**
|
|
@@ -95,9 +94,9 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
|
|
|
95
94
|
* @param credentialJwt The credential to verify.
|
|
96
95
|
* @returns The credential stored in the jwt and the revocation status.
|
|
97
96
|
*/
|
|
98
|
-
checkVerifiableCredential
|
|
97
|
+
checkVerifiableCredential(credentialJwt: string): Promise<{
|
|
99
98
|
revoked: boolean;
|
|
100
|
-
verifiableCredential?: IDidVerifiableCredential
|
|
99
|
+
verifiableCredential?: IDidVerifiableCredential;
|
|
101
100
|
}>;
|
|
102
101
|
/**
|
|
103
102
|
* Revoke verifiable credential(s).
|
|
@@ -119,14 +118,15 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
|
|
|
119
118
|
* Create a verifiable presentation from the supplied verifiable credentials.
|
|
120
119
|
* @param controller The controller of the identity who can make changes.
|
|
121
120
|
* @param presentationMethodId The method to associate with the presentation.
|
|
121
|
+
* @param presentationId The id of the presentation.
|
|
122
|
+
* @param contexts The contexts for the data stored in the verifiable credential.
|
|
122
123
|
* @param types The types for the data stored in the verifiable credential.
|
|
123
124
|
* @param verifiableCredentials The credentials to use for creating the presentation in jwt format.
|
|
124
|
-
* @param contexts Additional contexts to include in the presentation.
|
|
125
125
|
* @param expiresInMinutes The time in minutes for the presentation to expire.
|
|
126
126
|
* @returns The created verifiable presentation and its token.
|
|
127
127
|
* @throws NotFoundError if the id can not be resolved.
|
|
128
128
|
*/
|
|
129
|
-
createVerifiablePresentation(controller: string, presentationMethodId: string,
|
|
129
|
+
createVerifiablePresentation(controller: string, presentationMethodId: string, presentationId: string | undefined, contexts: IJsonLdContextDefinitionRoot | undefined, types: string | string[] | undefined, verifiableCredentials: (string | IDidVerifiableCredential)[], expiresInMinutes?: number): Promise<{
|
|
130
130
|
verifiablePresentation: IDidVerifiablePresentation;
|
|
131
131
|
jwt: string;
|
|
132
132
|
}>;
|
package/docs/changelog.md
CHANGED
|
@@ -264,14 +264,10 @@ NotFoundError if the id can not be resolved.
|
|
|
264
264
|
|
|
265
265
|
### createVerifiableCredential()
|
|
266
266
|
|
|
267
|
-
> **createVerifiableCredential
|
|
267
|
+
> **createVerifiableCredential**(`controller`, `verificationMethodId`, `id`, `credential`, `revocationIndex`?): `Promise`\<`object`\>
|
|
268
268
|
|
|
269
269
|
Create a verifiable credential for a verification method.
|
|
270
270
|
|
|
271
|
-
#### Type Parameters
|
|
272
|
-
|
|
273
|
-
• **T**
|
|
274
|
-
|
|
275
271
|
#### Parameters
|
|
276
272
|
|
|
277
273
|
• **controller**: `string`
|
|
@@ -282,21 +278,13 @@ The controller of the identity who can make changes.
|
|
|
282
278
|
|
|
283
279
|
The verification method id to use.
|
|
284
280
|
|
|
285
|
-
• **
|
|
281
|
+
• **id**: `undefined` \| `string`
|
|
286
282
|
|
|
287
283
|
The id of the credential.
|
|
288
284
|
|
|
289
|
-
• **
|
|
290
|
-
|
|
291
|
-
The type for the data stored in the verifiable credential.
|
|
285
|
+
• **credential**: `IJsonLdNodeObject`
|
|
292
286
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
The subject data to store for the credential.
|
|
296
|
-
|
|
297
|
-
• **contexts?**: `string` \| `string`[]
|
|
298
|
-
|
|
299
|
-
Additional contexts to include in the credential.
|
|
287
|
+
The credential to store in the verifiable credential.
|
|
300
288
|
|
|
301
289
|
• **revocationIndex?**: `number`
|
|
302
290
|
|
|
@@ -310,7 +298,7 @@ The created verifiable credential and its token.
|
|
|
310
298
|
|
|
311
299
|
##### verifiableCredential
|
|
312
300
|
|
|
313
|
-
> **verifiableCredential**: `IDidVerifiableCredential
|
|
301
|
+
> **verifiableCredential**: `IDidVerifiableCredential`
|
|
314
302
|
|
|
315
303
|
##### jwt
|
|
316
304
|
|
|
@@ -328,14 +316,10 @@ NotFoundError if the id can not be resolved.
|
|
|
328
316
|
|
|
329
317
|
### checkVerifiableCredential()
|
|
330
318
|
|
|
331
|
-
> **checkVerifiableCredential
|
|
319
|
+
> **checkVerifiableCredential**(`credentialJwt`): `Promise`\<`object`\>
|
|
332
320
|
|
|
333
321
|
Check a verifiable credential is valid.
|
|
334
322
|
|
|
335
|
-
#### Type Parameters
|
|
336
|
-
|
|
337
|
-
• **T**
|
|
338
|
-
|
|
339
323
|
#### Parameters
|
|
340
324
|
|
|
341
325
|
• **credentialJwt**: `string`
|
|
@@ -354,7 +338,7 @@ The credential stored in the jwt and the revocation status.
|
|
|
354
338
|
|
|
355
339
|
##### verifiableCredential?
|
|
356
340
|
|
|
357
|
-
> `optional` **verifiableCredential**: `IDidVerifiableCredential
|
|
341
|
+
> `optional` **verifiableCredential**: `IDidVerifiableCredential`
|
|
358
342
|
|
|
359
343
|
#### Implementation of
|
|
360
344
|
|
|
@@ -428,7 +412,7 @@ Nothing.
|
|
|
428
412
|
|
|
429
413
|
### createVerifiablePresentation()
|
|
430
414
|
|
|
431
|
-
> **createVerifiablePresentation**(`controller`, `presentationMethodId`, `types`, `verifiableCredentials`, `
|
|
415
|
+
> **createVerifiablePresentation**(`controller`, `presentationMethodId`, `presentationId`, `contexts`, `types`, `verifiableCredentials`, `expiresInMinutes`?): `Promise`\<`object`\>
|
|
432
416
|
|
|
433
417
|
Create a verifiable presentation from the supplied verifiable credentials.
|
|
434
418
|
|
|
@@ -442,18 +426,22 @@ The controller of the identity who can make changes.
|
|
|
442
426
|
|
|
443
427
|
The method to associate with the presentation.
|
|
444
428
|
|
|
429
|
+
• **presentationId**: `undefined` \| `string`
|
|
430
|
+
|
|
431
|
+
The id of the presentation.
|
|
432
|
+
|
|
433
|
+
• **contexts**: `undefined` \| `IJsonLdContextDefinitionRoot`
|
|
434
|
+
|
|
435
|
+
The contexts for the data stored in the verifiable credential.
|
|
436
|
+
|
|
445
437
|
• **types**: `undefined` \| `string` \| `string`[]
|
|
446
438
|
|
|
447
439
|
The types for the data stored in the verifiable credential.
|
|
448
440
|
|
|
449
|
-
• **verifiableCredentials**: `string`[]
|
|
441
|
+
• **verifiableCredentials**: (`string` \| `IDidVerifiableCredential`)[]
|
|
450
442
|
|
|
451
443
|
The credentials to use for creating the presentation in jwt format.
|
|
452
444
|
|
|
453
|
-
• **contexts?**: `string` \| `string`[]
|
|
454
|
-
|
|
455
|
-
Additional contexts to include in the presentation.
|
|
456
|
-
|
|
457
445
|
• **expiresInMinutes?**: `number`
|
|
458
446
|
|
|
459
447
|
The time in minutes for the presentation to expire.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/identity-connector-entity-storage",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.6",
|
|
4
4
|
"description": "Identity connector implementation using entity storage",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@twin.org/data-core": "next",
|
|
20
20
|
"@twin.org/data-json-ld": "next",
|
|
21
21
|
"@twin.org/entity": "next",
|
|
22
|
-
"@twin.org/identity-models": "0.0.1-next.
|
|
22
|
+
"@twin.org/identity-models": "0.0.1-next.6",
|
|
23
23
|
"@twin.org/nameof": "next",
|
|
24
24
|
"@twin.org/standards-w3c-did": "next",
|
|
25
25
|
"@twin.org/vault-models": "next",
|