@twin.org/identity-connector-entity-storage 0.10.1-next.2 → 0.10.1-next.3
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/es/entityStorageIdentityConnector.js +153 -93
- package/dist/es/entityStorageIdentityConnector.js.map +1 -1
- package/dist/types/entityStorageIdentityConnector.d.ts +2 -4
- package/docs/changelog.md +15 -0
- package/docs/reference/classes/EntityStorageIdentityConnector.md +5 -9
- package/locales/en.json +3 -0
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright 2024 IOTA Stiftung.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
-
import { ArrayHelper, BaseError, BitString, Coerce, Compression, CompressionType, Converter, GeneralError, Guards, Is, JsonHelper, LruCache, NotFoundError, ObjectHelper, RandomHelper, Url, Urn } from "@twin.org/core";
|
|
3
|
+
import { ArrayHelper, BaseError, BitString, Coerce, Compression, CompressionType, Converter, GeneralError, Guards, Is, JsonHelper, LruCache, NotFoundError, ObjectHelper, RandomHelper, UnauthorizedError, Url, Urn } from "@twin.org/core";
|
|
4
4
|
import { JsonLdHelper, JsonLdProcessor } from "@twin.org/data-json-ld";
|
|
5
5
|
import { EntityStorageConnectorFactory } from "@twin.org/entity-storage-models";
|
|
6
6
|
import { DocumentHelper, VerificationHelper } from "@twin.org/identity-models";
|
|
@@ -101,6 +101,20 @@ export class EntityStorageIdentityConnector {
|
|
|
101
101
|
throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "signatureVerificationFailed");
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Confirm the caller matches the controller stored against the document.
|
|
106
|
+
* @param controller The controller making the request.
|
|
107
|
+
* @param identityDocument The stored entity to check against.
|
|
108
|
+
* @throws UnauthorizedError if the caller is not the stored controller.
|
|
109
|
+
* @internal
|
|
110
|
+
*/
|
|
111
|
+
static assertController(controller, identityDocument) {
|
|
112
|
+
if (identityDocument.controller !== controller) {
|
|
113
|
+
throw new UnauthorizedError(EntityStorageIdentityConnector.CLASS_NAME, "notController", {
|
|
114
|
+
documentId: identityDocument.id
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
104
118
|
/**
|
|
105
119
|
* Returns the class name of the component.
|
|
106
120
|
* @returns The class name of the component.
|
|
@@ -163,6 +177,7 @@ export class EntityStorageIdentityConnector {
|
|
|
163
177
|
if (Is.empty(didDocument)) {
|
|
164
178
|
throw new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, "documentNotFound", documentId);
|
|
165
179
|
}
|
|
180
|
+
EntityStorageIdentityConnector.assertController(controller, didDocument);
|
|
166
181
|
await this._didDocumentEntityStorage.remove(documentId);
|
|
167
182
|
this._didResolutionCache?.delete(this.ownDidCacheKey(documentId));
|
|
168
183
|
if (options?.removeKeys ?? false) {
|
|
@@ -201,7 +216,7 @@ export class EntityStorageIdentityConnector {
|
|
|
201
216
|
Guards.arrayOneOf(EntityStorageIdentityConnector.CLASS_NAME, "verificationMethodType", verificationMethodType, Object.values(DidVerificationMethodType));
|
|
202
217
|
let tempKeyId;
|
|
203
218
|
try {
|
|
204
|
-
const didIdentityDocument = await this.
|
|
219
|
+
const didIdentityDocument = await this.resolveOwnDocumentForController(controller, documentId);
|
|
205
220
|
const didDocument = didIdentityDocument.document;
|
|
206
221
|
let methodKeyPublic;
|
|
207
222
|
if (Is.stringValue(verificationMethodId)) {
|
|
@@ -231,19 +246,7 @@ export class EntityStorageIdentityConnector {
|
|
|
231
246
|
await this._vaultConnector.renameKey(EntityStorageIdentityConnector.buildVaultKey(didDocument.id, tempKeyId), EntityStorageIdentityConnector.buildVaultKey(didDocument.id, verificationMethodId ?? kid));
|
|
232
247
|
tempKeyId = undefined;
|
|
233
248
|
}
|
|
234
|
-
|
|
235
|
-
const existingMethodIndex = methods.findIndex(m => {
|
|
236
|
-
if (Is.string(m.method)) {
|
|
237
|
-
return m.method === methodId;
|
|
238
|
-
}
|
|
239
|
-
return m.method.id === methodId;
|
|
240
|
-
});
|
|
241
|
-
if (existingMethodIndex !== -1) {
|
|
242
|
-
const methodArray = didDocument[methods[existingMethodIndex].arrayKey];
|
|
243
|
-
if (Is.array(methodArray)) {
|
|
244
|
-
methodArray.splice(existingMethodIndex, 1);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
249
|
+
this.removeMethodById(didDocument, methodId);
|
|
247
250
|
const didVerificationMethod = {
|
|
248
251
|
id: methodId,
|
|
249
252
|
controller: documentId,
|
|
@@ -289,25 +292,9 @@ export class EntityStorageIdentityConnector {
|
|
|
289
292
|
if (Is.empty(idParts.fragment)) {
|
|
290
293
|
throw new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, "missingDid", verificationMethodId);
|
|
291
294
|
}
|
|
292
|
-
const didIdentityDocument = await this.
|
|
295
|
+
const didIdentityDocument = await this.resolveOwnDocumentForController(controller, idParts.id);
|
|
293
296
|
const didDocument = didIdentityDocument.document;
|
|
294
|
-
|
|
295
|
-
const existingMethodIndex = methods.findIndex(m => {
|
|
296
|
-
if (Is.string(m.method)) {
|
|
297
|
-
return m.method === verificationMethodId;
|
|
298
|
-
}
|
|
299
|
-
return m.method.id === verificationMethodId;
|
|
300
|
-
});
|
|
301
|
-
if (existingMethodIndex !== -1) {
|
|
302
|
-
const methodArray = didDocument[methods[existingMethodIndex].arrayKey];
|
|
303
|
-
if (Is.array(methodArray)) {
|
|
304
|
-
methodArray.splice(existingMethodIndex, 1);
|
|
305
|
-
if (methodArray.length === 0) {
|
|
306
|
-
delete didDocument[methods[existingMethodIndex].arrayKey];
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
297
|
+
if (!this.removeMethodById(didDocument, verificationMethodId)) {
|
|
311
298
|
throw new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, "verificationMethodNotFound", verificationMethodId);
|
|
312
299
|
}
|
|
313
300
|
await this.updateDocument(controller, didDocument);
|
|
@@ -349,7 +336,7 @@ export class EntityStorageIdentityConnector {
|
|
|
349
336
|
Guards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, "serviceEndpoint", serviceEndpoint);
|
|
350
337
|
}
|
|
351
338
|
try {
|
|
352
|
-
const didIdentityDocument = await this.
|
|
339
|
+
const didIdentityDocument = await this.resolveOwnDocumentForController(controller, documentId);
|
|
353
340
|
const didDocument = didIdentityDocument.document;
|
|
354
341
|
const fullServiceId = serviceId.includes("#") ? serviceId : `${documentId}#${serviceId}`;
|
|
355
342
|
if (Is.array(didDocument.service)) {
|
|
@@ -387,7 +374,7 @@ export class EntityStorageIdentityConnector {
|
|
|
387
374
|
if (Is.empty(idParts.fragment)) {
|
|
388
375
|
throw new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, "missingDid", serviceId);
|
|
389
376
|
}
|
|
390
|
-
const didIdentityDocument = await this.
|
|
377
|
+
const didIdentityDocument = await this.resolveOwnDocumentForController(controller, idParts.id);
|
|
391
378
|
const didDocument = didIdentityDocument.document;
|
|
392
379
|
if (Is.array(didDocument.service)) {
|
|
393
380
|
const existingServiceIndex = didDocument.service.findIndex(s => s.id === serviceId);
|
|
@@ -428,7 +415,7 @@ export class EntityStorageIdentityConnector {
|
|
|
428
415
|
throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "invalidAlias", { alias });
|
|
429
416
|
}
|
|
430
417
|
try {
|
|
431
|
-
const didIdentityDocument = await this.
|
|
418
|
+
const didIdentityDocument = await this.resolveOwnDocumentForController(controller, documentId);
|
|
432
419
|
const didDocument = didIdentityDocument.document;
|
|
433
420
|
const existing = Is.array(didDocument.alsoKnownAs) ? didDocument.alsoKnownAs : [];
|
|
434
421
|
if (existing.includes(alias)) {
|
|
@@ -459,7 +446,7 @@ export class EntityStorageIdentityConnector {
|
|
|
459
446
|
throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "invalidAlias", { alias });
|
|
460
447
|
}
|
|
461
448
|
try {
|
|
462
|
-
const didIdentityDocument = await this.
|
|
449
|
+
const didIdentityDocument = await this.resolveOwnDocumentForController(controller, documentId);
|
|
463
450
|
const didDocument = didIdentityDocument.document;
|
|
464
451
|
if (!Is.array(didDocument.alsoKnownAs) || !didDocument.alsoKnownAs.includes(alias)) {
|
|
465
452
|
return;
|
|
@@ -497,6 +484,15 @@ export class EntityStorageIdentityConnector {
|
|
|
497
484
|
Guards.object(EntityStorageIdentityConnector.CLASS_NAME, "subject", subject);
|
|
498
485
|
if (!Is.undefined(options?.revocationIndex)) {
|
|
499
486
|
Guards.number(EntityStorageIdentityConnector.CLASS_NAME, "options.revocationIndex", options.revocationIndex);
|
|
487
|
+
// An index outside the bitmap would be accepted here and then throw on every later
|
|
488
|
+
// revocation check, so it is rejected while the credential can still be reissued.
|
|
489
|
+
if (options.revocationIndex < 0 ||
|
|
490
|
+
options.revocationIndex >= EntityStorageIdentityConnector._REVOCATION_BITS_SIZE) {
|
|
491
|
+
throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "revocationIndexOutOfRange", {
|
|
492
|
+
revocationIndex: options.revocationIndex,
|
|
493
|
+
maxIndex: EntityStorageIdentityConnector._REVOCATION_BITS_SIZE - 1
|
|
494
|
+
});
|
|
495
|
+
}
|
|
500
496
|
}
|
|
501
497
|
if (!Is.undefined(options?.expirationDate)) {
|
|
502
498
|
Guards.date(EntityStorageIdentityConnector.CLASS_NAME, "options.expirationDate", options.expirationDate);
|
|
@@ -506,7 +502,7 @@ export class EntityStorageIdentityConnector {
|
|
|
506
502
|
if (Is.empty(idParts.fragment)) {
|
|
507
503
|
throw new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, "missingDid", verificationMethodId);
|
|
508
504
|
}
|
|
509
|
-
const issuerIdentityDocument = await this.
|
|
505
|
+
const issuerIdentityDocument = await this.resolveOwnDocumentForController(controller, idParts.id);
|
|
510
506
|
const issuerDidDocument = issuerIdentityDocument.document;
|
|
511
507
|
const methods = this.getAllMethods(issuerDidDocument);
|
|
512
508
|
const methodAndArray = methods.find(m => {
|
|
@@ -567,7 +563,7 @@ export class EntityStorageIdentityConnector {
|
|
|
567
563
|
]);
|
|
568
564
|
// Add the proof to the VC after extracting the jwt data
|
|
569
565
|
// as the jwt does not include the proof
|
|
570
|
-
verifiableCredential.proof = await this.
|
|
566
|
+
verifiableCredential.proof = await this.buildProof(issuerDidDocument, verificationMethodId, ProofTypes.DataIntegrityProof, JsonLdHelper.toNodeObject(verifiableCredential));
|
|
571
567
|
// As we are adding the receipt to the data we update the JSON-LD context
|
|
572
568
|
const proofContext = verifiableCredential.proof["@context"];
|
|
573
569
|
if (Is.notEmpty(proofContext)) {
|
|
@@ -704,7 +700,7 @@ export class EntityStorageIdentityConnector {
|
|
|
704
700
|
Guards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, "issuerDocumentId", issuerDocumentId);
|
|
705
701
|
Guards.arrayValue(EntityStorageIdentityConnector.CLASS_NAME, "credentialIndices", credentialIndices);
|
|
706
702
|
try {
|
|
707
|
-
const issuerIdentityDocument = await this.
|
|
703
|
+
const issuerIdentityDocument = await this.resolveOwnDocumentForController(controller, issuerDocumentId);
|
|
708
704
|
const issuerDidDocument = issuerIdentityDocument.document;
|
|
709
705
|
const revocationService = issuerDidDocument.service?.find(s => s.id.endsWith("#revocation"));
|
|
710
706
|
if (revocationService &&
|
|
@@ -740,7 +736,7 @@ export class EntityStorageIdentityConnector {
|
|
|
740
736
|
Guards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, "issuerDocumentId", issuerDocumentId);
|
|
741
737
|
Guards.arrayValue(EntityStorageIdentityConnector.CLASS_NAME, "credentialIndices", credentialIndices);
|
|
742
738
|
try {
|
|
743
|
-
const issuerIdentityDocument = await this.
|
|
739
|
+
const issuerIdentityDocument = await this.resolveOwnDocumentForController(controller, issuerDocumentId);
|
|
744
740
|
const issuerDidDocument = issuerIdentityDocument.document;
|
|
745
741
|
const revocationService = issuerDidDocument.service?.find(s => s.id.endsWith("#revocation"));
|
|
746
742
|
if (revocationService &&
|
|
@@ -797,7 +793,7 @@ export class EntityStorageIdentityConnector {
|
|
|
797
793
|
if (Is.empty(idParts.fragment)) {
|
|
798
794
|
throw new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, "missingDid", verificationMethodId);
|
|
799
795
|
}
|
|
800
|
-
const holderIdentityDocument = await this.
|
|
796
|
+
const holderIdentityDocument = await this.resolveOwnDocumentForController(controller, idParts.id);
|
|
801
797
|
const holderDidDocument = holderIdentityDocument.document;
|
|
802
798
|
const methods = this.getAllMethods(holderDidDocument);
|
|
803
799
|
const methodAndArray = methods.find(m => {
|
|
@@ -846,7 +842,7 @@ export class EntityStorageIdentityConnector {
|
|
|
846
842
|
]);
|
|
847
843
|
// Add the proof to the VP after extracting the jwt data
|
|
848
844
|
// as the jwt does not include the proof
|
|
849
|
-
verifiablePresentation.proof = await this.
|
|
845
|
+
verifiablePresentation.proof = await this.buildProof(holderDidDocument, verificationMethodId, ProofTypes.DataIntegrityProof, JsonLdHelper.toNodeObject(verifiablePresentation));
|
|
850
846
|
const jwtPayload = {
|
|
851
847
|
...options?.jwtPayloadFields,
|
|
852
848
|
iss: verifiablePresentation.holder,
|
|
@@ -876,6 +872,14 @@ export class EntityStorageIdentityConnector {
|
|
|
876
872
|
const { proof, ...doc } = presentation;
|
|
877
873
|
const proofEntry = ArrayHelper.fromObjectOrArray(proof)[0];
|
|
878
874
|
Guards.objectValue(EntityStorageIdentityConnector.CLASS_NAME, "proofEntry", proofEntry);
|
|
875
|
+
Guards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, "proofEntry.verificationMethod", proofEntry.verificationMethod);
|
|
876
|
+
const signerDid = DocumentHelper.parseId(proofEntry.verificationMethod).id;
|
|
877
|
+
if (Is.stringValue(doc.holder) && doc.holder !== signerDid) {
|
|
878
|
+
throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "holderMismatch", {
|
|
879
|
+
holder: doc.holder,
|
|
880
|
+
method: proofEntry.verificationMethod
|
|
881
|
+
});
|
|
882
|
+
}
|
|
879
883
|
const presentationVerified = await this.verifyProof(JsonLdHelper.toNodeObject(doc), proofEntry);
|
|
880
884
|
if (!presentationVerified) {
|
|
881
885
|
throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "signatureVerificationFailed");
|
|
@@ -909,18 +913,24 @@ export class EntityStorageIdentityConnector {
|
|
|
909
913
|
throw new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, "documentNotFound", holderDocumentId);
|
|
910
914
|
}
|
|
911
915
|
await EntityStorageIdentityConnector.verifyDocument(holderIdentityDocument, this._vaultConnector);
|
|
916
|
+
const holderDidDocument = holderIdentityDocument.document;
|
|
917
|
+
Guards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, "jwtHeader.kid", jwtHeader.kid);
|
|
918
|
+
// Resolving the key from the holder's own document is what binds the signature to the
|
|
919
|
+
// holder named by iss.
|
|
920
|
+
const publicKeyJwk = this.getMethodJwk(holderDidDocument, jwtHeader.kid);
|
|
921
|
+
await Jwt.verifySignature(presentationJwt, await Jwk.toCryptoKey(publicKeyJwk));
|
|
912
922
|
const issuers = [];
|
|
913
923
|
const tokensRevoked = [];
|
|
914
924
|
const verifiablePresentation = jwtPayload?.vp;
|
|
915
|
-
if (Is.object(verifiablePresentation)
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
const
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
925
|
+
if (Is.object(verifiablePresentation)) {
|
|
926
|
+
// The holder is not carried in the vp claim, so restore it from the token issuer.
|
|
927
|
+
verifiablePresentation.holder = holderDocumentId;
|
|
928
|
+
if (Is.array(verifiablePresentation.verifiableCredential)) {
|
|
929
|
+
for (const embeddedCredential of verifiablePresentation.verifiableCredential) {
|
|
930
|
+
const issuerDocumentId = Is.stringValue(embeddedCredential)
|
|
931
|
+
? (await Jwt.decode(embeddedCredential)).payload?.iss
|
|
932
|
+
: this.getCredentialIssuer(embeddedCredential);
|
|
933
|
+
if (Is.stringValue(issuerDocumentId)) {
|
|
924
934
|
const issuerDidDocument = await this._didDocumentEntityStorage.get(issuerDocumentId);
|
|
925
935
|
if (Is.undefined(issuerDidDocument)) {
|
|
926
936
|
throw new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, "documentNotFound", issuerDocumentId);
|
|
@@ -931,10 +941,9 @@ export class EntityStorageIdentityConnector {
|
|
|
931
941
|
...issuerDidDocument
|
|
932
942
|
});
|
|
933
943
|
}
|
|
934
|
-
const credentialCheck = await this.checkVerifiableCredential(
|
|
935
|
-
|
|
944
|
+
const credentialCheck = await this.checkVerifiableCredential(embeddedCredential);
|
|
945
|
+
tokensRevoked.push(credentialCheck.revoked);
|
|
936
946
|
}
|
|
937
|
-
tokensRevoked.push(revoked);
|
|
938
947
|
}
|
|
939
948
|
}
|
|
940
949
|
return {
|
|
@@ -960,57 +969,23 @@ export class EntityStorageIdentityConnector {
|
|
|
960
969
|
* @param verificationMethodId The verification method id to use.
|
|
961
970
|
* @param proofType The type of proof to create.
|
|
962
971
|
* @param unsecureDocument The unsecure document to create the proof for.
|
|
963
|
-
* @param resolvedDocument Optional already-resolved document for the DID, so a caller that
|
|
964
|
-
* just resolved it (e.g. createVerifiableCredential) skips a redundant re-resolve. Resolves
|
|
965
|
-
* it itself if omitted.
|
|
966
972
|
* @returns The proof.
|
|
967
973
|
* @throws NotFoundError if the identity or method is not found.
|
|
974
|
+
* @throws UnauthorizedError if the caller is not the stored controller.
|
|
968
975
|
* @throws GeneralError if algorithm doesn't match key type or proof creation fails.
|
|
969
976
|
*/
|
|
970
|
-
async createProof(controller, verificationMethodId, proofType, unsecureDocument
|
|
977
|
+
async createProof(controller, verificationMethodId, proofType, unsecureDocument) {
|
|
971
978
|
Guards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, "controller", controller);
|
|
972
979
|
Guards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, "verificationMethodId", verificationMethodId);
|
|
973
980
|
Guards.arrayOneOf(EntityStorageIdentityConnector.CLASS_NAME, "proofType", proofType, Object.values(ProofTypes));
|
|
974
981
|
Guards.object(EntityStorageIdentityConnector.CLASS_NAME, "unsecureDocument", unsecureDocument);
|
|
975
|
-
if (!Is.undefined(resolvedDocument)) {
|
|
976
|
-
Guards.object(EntityStorageIdentityConnector.CLASS_NAME, "resolvedDocument", resolvedDocument);
|
|
977
|
-
}
|
|
978
982
|
try {
|
|
979
983
|
const idParts = DocumentHelper.parseId(verificationMethodId);
|
|
980
984
|
if (Is.empty(idParts.fragment)) {
|
|
981
985
|
throw new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, "missingDid", verificationMethodId);
|
|
982
986
|
}
|
|
983
|
-
const
|
|
984
|
-
|
|
985
|
-
: resolvedDocument;
|
|
986
|
-
const methods = this.getAllMethods(didDocument);
|
|
987
|
-
const methodAndArray = methods.find(m => {
|
|
988
|
-
if (Is.string(m.method)) {
|
|
989
|
-
return m.method === verificationMethodId;
|
|
990
|
-
}
|
|
991
|
-
return m.method.id === verificationMethodId;
|
|
992
|
-
});
|
|
993
|
-
if (!methodAndArray) {
|
|
994
|
-
throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "methodMissing", {
|
|
995
|
-
method: verificationMethodId
|
|
996
|
-
});
|
|
997
|
-
}
|
|
998
|
-
const didMethod = methodAndArray.method;
|
|
999
|
-
if (!Is.stringValue(didMethod.publicKeyJwk?.x)) {
|
|
1000
|
-
throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "publicKeyJwkMissing", {
|
|
1001
|
-
method: verificationMethodId
|
|
1002
|
-
});
|
|
1003
|
-
}
|
|
1004
|
-
const vaultKey = EntityStorageIdentityConnector.buildVaultKey(didDocument.id, idParts.fragment ?? "");
|
|
1005
|
-
const keyType = await this._vaultConnector.getKeyType(vaultKey);
|
|
1006
|
-
if (Is.undefined(keyType)) {
|
|
1007
|
-
throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "privateKeyMissing", {
|
|
1008
|
-
keyId: vaultKey
|
|
1009
|
-
});
|
|
1010
|
-
}
|
|
1011
|
-
const unsignedProof = ProofHelper.createUnsignedProof(proofType, verificationMethodId);
|
|
1012
|
-
const signedProof = await ProofHelper.createProofWithSigner(proofType, unsecureDocument, unsignedProof, async (data, algorithm) => this.signWithVault(vaultKey, keyType, data, algorithm));
|
|
1013
|
-
return signedProof;
|
|
987
|
+
const identityDocument = await this.resolveOwnDocumentForController(controller, idParts.id);
|
|
988
|
+
return await this.buildProof(identityDocument.document, verificationMethodId, proofType, unsecureDocument);
|
|
1014
989
|
}
|
|
1015
990
|
catch (error) {
|
|
1016
991
|
throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "createProofFailed", undefined, error);
|
|
@@ -1062,6 +1037,29 @@ export class EntityStorageIdentityConnector {
|
|
|
1062
1037
|
throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "verifyProofFailed", undefined, error);
|
|
1063
1038
|
}
|
|
1064
1039
|
}
|
|
1040
|
+
/**
|
|
1041
|
+
* Build a proof against a document whose controller has already been verified by the caller.
|
|
1042
|
+
* @param didDocument The resolved DID document owning the verification method.
|
|
1043
|
+
* @param verificationMethodId The verification method id to use.
|
|
1044
|
+
* @param proofType The type of proof to create.
|
|
1045
|
+
* @param unsecureDocument The unsecure document to create the proof for.
|
|
1046
|
+
* @returns The proof.
|
|
1047
|
+
* @throws GeneralError if the method or its key material is missing.
|
|
1048
|
+
* @internal
|
|
1049
|
+
*/
|
|
1050
|
+
async buildProof(didDocument, verificationMethodId, proofType, unsecureDocument) {
|
|
1051
|
+
const idParts = DocumentHelper.parseId(verificationMethodId);
|
|
1052
|
+
this.getMethodJwk(didDocument, verificationMethodId);
|
|
1053
|
+
const vaultKey = EntityStorageIdentityConnector.buildVaultKey(didDocument.id, idParts.fragment ?? "");
|
|
1054
|
+
const keyType = await this._vaultConnector.getKeyType(vaultKey);
|
|
1055
|
+
if (Is.undefined(keyType)) {
|
|
1056
|
+
throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "privateKeyMissing", {
|
|
1057
|
+
keyId: vaultKey
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
const unsignedProof = ProofHelper.createUnsignedProof(proofType, verificationMethodId);
|
|
1061
|
+
return ProofHelper.createProofWithSigner(proofType, unsecureDocument, unsignedProof, async (data, algorithm) => this.signWithVault(vaultKey, keyType, data, algorithm));
|
|
1062
|
+
}
|
|
1065
1063
|
/**
|
|
1066
1064
|
* Signs data using the vault connector with algorithm validation.
|
|
1067
1065
|
* @param vaultKey The vault key identifier.
|
|
@@ -1103,6 +1101,54 @@ export class EntityStorageIdentityConnector {
|
|
|
1103
1101
|
}
|
|
1104
1102
|
return methods;
|
|
1105
1103
|
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Get the issuer DID from a credential in object form.
|
|
1106
|
+
* @param credential The credential to read.
|
|
1107
|
+
* @returns The issuer DID, or undefined if it has none.
|
|
1108
|
+
* @internal
|
|
1109
|
+
*/
|
|
1110
|
+
getCredentialIssuer(credential) {
|
|
1111
|
+
return Is.object(credential.issuer) ? credential.issuer.id : credential.issuer;
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Remove a verification method from whichever relationship holds it.
|
|
1115
|
+
* The relationship arrays are searched individually, because an index taken from the flat list
|
|
1116
|
+
* getAllMethods returns does not address the per-relationship array it came from.
|
|
1117
|
+
* @param didDocument The document to update.
|
|
1118
|
+
* @param verificationMethodId The full id of the method to remove.
|
|
1119
|
+
* @returns True if the method was found and removed.
|
|
1120
|
+
* @internal
|
|
1121
|
+
*/
|
|
1122
|
+
removeMethodById(didDocument, verificationMethodId) {
|
|
1123
|
+
for (const methodType of Object.values(DidVerificationMethodType)) {
|
|
1124
|
+
const methodArray = didDocument[methodType];
|
|
1125
|
+
if (Is.arrayValue(methodArray)) {
|
|
1126
|
+
const index = methodArray.findIndex(m => (Is.string(m) ? m : m.id) === verificationMethodId);
|
|
1127
|
+
if (index !== -1) {
|
|
1128
|
+
methodArray.splice(index, 1);
|
|
1129
|
+
if (methodArray.length === 0) {
|
|
1130
|
+
delete didDocument[methodType];
|
|
1131
|
+
}
|
|
1132
|
+
return true;
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
return false;
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* Get the public key for a verification method from whichever relationship holds it.
|
|
1140
|
+
* getJwk looks in a single relationship, defaulting to verificationMethod, but a method is
|
|
1141
|
+
* only ever added to the relationship it was created under.
|
|
1142
|
+
* @param didDocument The document owning the method.
|
|
1143
|
+
* @param verificationMethodId The full id of the method.
|
|
1144
|
+
* @returns The public key.
|
|
1145
|
+
* @throws GeneralError if the method is not on the document or carries no public key.
|
|
1146
|
+
* @internal
|
|
1147
|
+
*/
|
|
1148
|
+
getMethodJwk(didDocument, verificationMethodId) {
|
|
1149
|
+
const methodType = Object.values(DidVerificationMethodType).find(type => didDocument[type]?.some(m => (Is.string(m) ? m : m.id) === verificationMethodId));
|
|
1150
|
+
return DocumentHelper.getJwk(didDocument, verificationMethodId, methodType);
|
|
1151
|
+
}
|
|
1106
1152
|
/**
|
|
1107
1153
|
* Resolve the issuer document for a verification method, verified against its stored signature.
|
|
1108
1154
|
* @param verificationMethodId The verification method id whose owning DID to resolve.
|
|
@@ -1167,6 +1213,20 @@ export class EntityStorageIdentityConnector {
|
|
|
1167
1213
|
const identityDocument = await this._didResolutionCache.getOrSet(this.ownDidCacheKey(documentId), async () => this.loadOwnDocument(documentId));
|
|
1168
1214
|
return ObjectHelper.clone(identityDocument);
|
|
1169
1215
|
}
|
|
1216
|
+
/**
|
|
1217
|
+
* Resolve a document's own storage entity and confirm the caller controls it.
|
|
1218
|
+
* @param controller The controller making the request.
|
|
1219
|
+
* @param documentId The DID to resolve.
|
|
1220
|
+
* @returns The verified storage entity.
|
|
1221
|
+
* @throws NotFoundError if the DID could not be resolved.
|
|
1222
|
+
* @throws UnauthorizedError if the caller is not the stored controller.
|
|
1223
|
+
* @internal
|
|
1224
|
+
*/
|
|
1225
|
+
async resolveOwnDocumentForController(controller, documentId) {
|
|
1226
|
+
const identityDocument = await this.resolveOwnDocumentCached(documentId);
|
|
1227
|
+
EntityStorageIdentityConnector.assertController(controller, identityDocument);
|
|
1228
|
+
return identityDocument;
|
|
1229
|
+
}
|
|
1170
1230
|
/**
|
|
1171
1231
|
* Check whether a credential's status entry or entries report it as revoked.
|
|
1172
1232
|
* @param document The issuer document owning the revocation bitmap service.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entityStorageIdentityConnector.js","sourceRoot":"","sources":["../../src/entityStorageIdentityConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,WAAW,EACX,SAAS,EACT,SAAS,EACT,MAAM,EACN,WAAW,EACX,eAAe,EACf,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,UAAU,EACV,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,GAAG,EACH,GAAG,EACH,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,YAAY,EACZ,eAAe,EAGf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACN,cAAc,EACd,kBAAkB,EAElB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,WAAW,EACX,QAAQ,EACR,yBAAyB,EAGzB,aAAa,EACb,WAAW,EACX,UAAU,EAQV,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EAEZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAgD,MAAM,eAAe,CAAC;AAIvF;;GAEG;AACH,MAAM,OAAO,8BAA8B;IAC1C;;OAEG;IACI,MAAM,CAAU,UAAU,oCAAoD;IAErF;;OAEG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,SAAS,CAAC;YAC7C,UAAU;SACV,CAAC;QAEF,MAAM,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAE3D,IAAI,CAAC,mBAAmB,EAAE,GAAG,CAC5B,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC,EACnC,YAAY,CAAC,KAAK,CAAC,gBAAgB,CAAC,CACpC,CAAC;IACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tArrayHelper,\n\tBaseError,\n\tBitString,\n\tCoerce,\n\tCompression,\n\tCompressionType,\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tJsonHelper,\n\tLruCache,\n\tNotFoundError,\n\tObjectHelper,\n\tRandomHelper,\n\tUrl,\n\tUrn\n} from \"@twin.org/core\";\nimport {\n\tJsonLdHelper,\n\tJsonLdProcessor,\n\ttype IJsonLdContextDefinitionRoot,\n\ttype IJsonLdNodeObject\n} from \"@twin.org/data-json-ld\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport {\n\tDocumentHelper,\n\tVerificationHelper,\n\ttype IIdentityConnector\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDidContexts,\n\tDidTypes,\n\tDidVerificationMethodType,\n\ttype IDidCredentialStatus,\n\ttype IDidVerifiableCredential,\n\tJwsAlgorithms,\n\tProofHelper,\n\tProofTypes,\n\ttype IDidDocument,\n\ttype IDidDocumentVerificationMethod,\n\ttype IDidService,\n\ttype IDidVerifiableCredentialV1,\n\ttype IDidVerifiablePresentationV1,\n\ttype IProof,\n\ttype IDidVerifiablePresentation\n} from \"@twin.org/standards-w3c-did\";\nimport {\n\tVaultConnectorFactory,\n\tVaultConnectorHelper,\n\tVaultKeyType,\n\ttype IVaultConnector\n} from \"@twin.org/vault-models\";\nimport { Jwk, Jwt, type IJwk, type IJwtHeader, type IJwtPayload } from \"@twin.org/web\";\nimport type { IdentityDocument } from \"./entities/identityDocument.js\";\nimport type { IEntityStorageIdentityConnectorConstructorOptions } from \"./models/IEntityStorageIdentityConnectorConstructorOptions.js\";\n\n/**\n * Class for performing identity operations using entity storage.\n */\nexport class EntityStorageIdentityConnector implements IIdentityConnector {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageIdentityConnector>();\n\n\t/**\n\t * The namespace supported by the identity connector.\n\t */\n\tpublic static readonly NAMESPACE: string = \"entity-storage\";\n\n\t/**\n\t * The size of the revocation bitmap in bits (16Kb).\n\t * @internal\n\t */\n\tprivate static readonly _REVOCATION_BITS_SIZE: number = 131072;\n\n\t/**\n\t * The entity storage for identities.\n\t * @internal\n\t */\n\tprotected readonly _didDocumentEntityStorage: IEntityStorageConnector<IdentityDocument>;\n\n\t/**\n\t * The vault for the keys.\n\t * @internal\n\t */\n\tprotected readonly _vaultConnector: IVaultConnector;\n\n\t/**\n\t * TTL in ms for caching DID documents resolved for this connector's own sign/mutate\n\t * operations. 0 disables caching (see resolveOwnDocumentCached). Never applied to proof or\n\t * credential verification of third-party claims.\n\t * @internal\n\t */\n\tprivate readonly _didResolutionCacheTtlMs: number;\n\n\t/**\n\t * Maximum number of own DID documents retained in cache.\n\t * @internal\n\t */\n\tprivate readonly _didResolutionCacheCapacity: number;\n\n\t/**\n\t * Maximum wait time for own DID cache getOrSet mutex acquisition in milliseconds.\n\t * @internal\n\t */\n\tprivate readonly _didResolutionCacheMutexTimeoutMs?: number;\n\n\t/**\n\t * LRU cache for own DID documents. Undefined when caching is disabled (ttl is 0).\n\t * @internal\n\t */\n\tprivate readonly _didResolutionCache?: LruCache<IdentityDocument>;\n\n\t/**\n\t * Create a new instance of EntityStorageIdentityConnector.\n\t * @param options The options for the identity connector.\n\t */\n\tconstructor(options?: IEntityStorageIdentityConnectorConstructorOptions) {\n\t\tthis._didDocumentEntityStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.didDocumentEntityStorageType ?? \"identity-document\"\n\t\t);\n\t\tthis._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? \"vault\");\n\n\t\tthis._didResolutionCacheTtlMs = options?.config?.didResolutionCacheTtlMs ?? 30_000;\n\t\tthis._didResolutionCacheCapacity = options?.config?.didResolutionCacheCapacity ?? 1000;\n\t\tthis._didResolutionCacheMutexTimeoutMs = options?.config?.didResolutionCacheMutexTimeoutMs;\n\t\tthis._didResolutionCache =\n\t\t\tthis._didResolutionCacheTtlMs > 0\n\t\t\t\t? new LruCache<IdentityDocument>({\n\t\t\t\t\t\tcapacity: this._didResolutionCacheCapacity,\n\t\t\t\t\t\tttiMs: this._didResolutionCacheTtlMs,\n\t\t\t\t\t\tmutexTimeoutMs: this._didResolutionCacheMutexTimeoutMs\n\t\t\t\t\t})\n\t\t\t\t: undefined;\n\t}\n\n\t/**\n\t * Build the key name to access the specified key in the vault.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param key The key to access in the vault.\n\t * @returns The vault key.\n\t * @internal\n\t */\n\tpublic static buildVaultKey(identity: string, key: string): string {\n\t\treturn `${identity}/${key}`;\n\t}\n\n\t/**\n\t * Verify the document in storage.\n\t * @param didDocument The did document that was stored.\n\t * @param vaultConnector The vault connector to use for verification.\n\t * @returns A promise that resolves when verification is complete.\n\t * @throws GeneralError if the document signature is invalid.\n\t * @internal\n\t */\n\tpublic static async verifyDocument(\n\t\tdidDocument: IdentityDocument,\n\t\tvaultConnector: IVaultConnector\n\t): Promise<void> {\n\t\tconst stringifiedDocument = JsonHelper.canonicalize(didDocument.document);\n\t\tconst docBytes = Converter.utf8ToBytes(stringifiedDocument);\n\n\t\tconst verified = await vaultConnector.verify(\n\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, \"did\"),\n\t\t\tdocBytes,\n\t\t\tConverter.base64ToBytes(didDocument.signature)\n\t\t);\n\n\t\tif (!verified) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"signatureVerificationFailed\"\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageIdentityConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Stop the service.\n\t * Destroys in-memory resources owned by this component.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t * @returns A promise that resolves when the service has stopped.\n\t */\n\tpublic async stop(nodeLoggingComponentType?: string): Promise<void> {\n\t\tthis._didResolutionCache?.destroy();\n\t}\n\n\t/**\n\t * Create a new document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns The created document.\n\t */\n\tpublic async createDocument(controller: string): Promise<IDidDocument> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\n\t\ttry {\n\t\t\tconst did = `did:${EntityStorageIdentityConnector.NAMESPACE}:${Converter.bytesToHex(RandomHelper.generate(32), true)}`;\n\n\t\t\tawait this._vaultConnector.createKey(\n\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(did, \"did\"),\n\t\t\t\tVaultKeyType.Ed25519\n\t\t\t);\n\n\t\t\tconst bitString = new BitString(EntityStorageIdentityConnector._REVOCATION_BITS_SIZE);\n\t\t\tconst compressed = await Compression.compress(bitString.getBits(), CompressionType.Gzip);\n\n\t\t\tconst didDocument: IDidDocument = {\n\t\t\t\t\"@context\": DidContexts.Context,\n\t\t\t\tid: did,\n\t\t\t\tservice: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${did}#revocation`,\n\t\t\t\t\t\ttype: \"BitstringStatusList\",\n\t\t\t\t\t\tserviceEndpoint: `data:application/octet-stream;base64,${Converter.bytesToBase64Url(compressed)}`\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t};\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\n\t\t\treturn didDocument;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createDocumentFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove a document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to remove.\n\t * @param options Optional settings.\n\t * @param options.removeKeys Also remove any associated private keys from the vault.\n\t * @returns A promise that resolves when the document has been removed.\n\t */\n\tpublic async removeDocument(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\toptions?: { removeKeys?: boolean }\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\n\t\ttry {\n\t\t\tconst didDocument = await this._didDocumentEntityStorage.get(documentId);\n\t\t\tif (Is.empty(didDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tdocumentId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this._didDocumentEntityStorage.remove(documentId);\n\t\t\tthis._didResolutionCache?.delete(this.ownDidCacheKey(documentId));\n\n\t\t\tif (options?.removeKeys ?? false) {\n\t\t\t\tconst methods = this.getAllMethods(didDocument.document);\n\t\t\t\tfor (const { method } of methods) {\n\t\t\t\t\tconst methodId = Is.string(method) ? method : method.id;\n\t\t\t\t\tif (Is.stringValue(methodId)) {\n\t\t\t\t\t\tconst idParts = DocumentHelper.parseId(methodId);\n\t\t\t\t\t\tif (Is.stringValue(idParts.fragment)) {\n\t\t\t\t\t\t\tconst vaultKey = EntityStorageIdentityConnector.buildVaultKey(\n\t\t\t\t\t\t\t\tdocumentId,\n\t\t\t\t\t\t\t\tidParts.fragment\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (await this._vaultConnector.keyExists(vaultKey)) {\n\t\t\t\t\t\t\t\tawait this._vaultConnector.removeKey(vaultKey);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeDocumentFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Add a verification method to the document in JSON Web key Format.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to add the verification method to.\n\t * @param verificationMethodType The type of the verification method to add.\n\t * @param verificationMethodId The id of the verification method, if undefined uses the kid of the generated JWK.\n\t * @returns The verification method.\n\t * @throws NotFoundError if the id can not be resolved.\n\t * @throws NotSupportedError if the platform does not support multiple keys.\n\t */\n\tpublic async addVerificationMethod(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\tverificationMethodType: DidVerificationMethodType,\n\t\tverificationMethodId?: string\n\t): Promise<IDidDocumentVerificationMethod> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.arrayOneOf<DidVerificationMethodType>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodType),\n\t\t\tverificationMethodType,\n\t\t\tObject.values(DidVerificationMethodType)\n\t\t);\n\n\t\tlet tempKeyId;\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentCached(documentId);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tlet methodKeyPublic;\n\t\t\tif (Is.stringValue(verificationMethodId)) {\n\t\t\t\t// If there is a verification method id, we will try to get the key from the vault.\n\t\t\t\ttry {\n\t\t\t\t\t// If there is an existing key, we will use it.\n\t\t\t\t\tconst existingKey = await this._vaultConnector.getKey(\n\t\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, verificationMethodId),\n\t\t\t\t\t\t\"public\"\n\t\t\t\t\t);\n\t\t\t\t\tmethodKeyPublic = existingKey.publicKey;\n\t\t\t\t} catch {}\n\t\t\t}\n\n\t\t\tif (Is.empty(methodKeyPublic)) {\n\t\t\t\t// If there is no existing key, we will create a new one with a temporary name.\n\t\t\t\ttempKeyId = `temp-vm-${Converter.bytesToBase64Url(RandomHelper.generate(16))}`;\n\t\t\t\tmethodKeyPublic = await this._vaultConnector.createKey(\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, tempKeyId),\n\t\t\t\t\tVaultKeyType.Ed25519\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst jwkParams: IJwk = {\n\t\t\t\talg: \"EdDSA\",\n\t\t\t\tkty: \"OKP\",\n\t\t\t\tcrv: \"Ed25519\",\n\t\t\t\tx: Converter.bytesToBase64Url(methodKeyPublic)\n\t\t\t};\n\n\t\t\tconst kid = await Jwk.generateKid(jwkParams);\n\n\t\t\tconst methodId = `${documentId}#${verificationMethodId ?? kid}`;\n\n\t\t\tif (Is.stringValue(tempKeyId)) {\n\t\t\t\t// If we created a temporary key, we will rename it to the final method id.\n\t\t\t\tawait this._vaultConnector.renameKey(\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, tempKeyId),\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, verificationMethodId ?? kid)\n\t\t\t\t);\n\t\t\t\ttempKeyId = undefined;\n\t\t\t}\n\n\t\t\tconst methods = this.getAllMethods(didDocument);\n\t\t\tconst existingMethodIndex = methods.findIndex(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === methodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === methodId;\n\t\t\t});\n\n\t\t\tif (existingMethodIndex !== -1) {\n\t\t\t\tconst methodArray =\n\t\t\t\t\tdidDocument[methods[existingMethodIndex].arrayKey as keyof IDidDocument];\n\n\t\t\t\tif (Is.array(methodArray)) {\n\t\t\t\t\tmethodArray.splice(existingMethodIndex, 1);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst didVerificationMethod: IDidDocumentVerificationMethod = {\n\t\t\t\tid: methodId,\n\t\t\t\tcontroller: documentId,\n\t\t\t\ttype: \"JsonWebKey2020\",\n\t\t\t\tpublicKeyJwk: {\n\t\t\t\t\t...jwkParams,\n\t\t\t\t\tkid\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tdidDocument[verificationMethodType] ??= [];\n\t\t\tdidDocument[verificationMethodType]?.push(didVerificationMethod);\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\n\t\t\treturn didVerificationMethod;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"addVerificationMethodFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t} finally {\n\t\t\tif (Is.stringValue(tempKeyId)) {\n\t\t\t\t// If we created a temporary key and it is still in use, we will remove it from the vault.\n\t\t\t\ttry {\n\t\t\t\t\tawait this._vaultConnector.removeKey(tempKeyId);\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Remove a verification method from the document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The id of the verification method.\n\t * @param options Optional settings.\n\t * @param options.removeKeys Also remove any associated private key from the vault.\n\t * @returns A promise that resolves when the verification method has been removed.\n\t * @throws NotFoundError if the id can not be resolved.\n\t * @throws NotSupportedError if the platform does not support multiple revocable keys.\n\t */\n\tpublic async removeVerificationMethod(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\toptions?: { removeKeys?: boolean }\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentCached(idParts.id);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tconst methods = this.getAllMethods(didDocument);\n\t\t\tconst existingMethodIndex = methods.findIndex(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === verificationMethodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === verificationMethodId;\n\t\t\t});\n\n\t\t\tif (existingMethodIndex !== -1) {\n\t\t\t\tconst methodArray =\n\t\t\t\t\tdidDocument[methods[existingMethodIndex].arrayKey as keyof IDidDocument];\n\n\t\t\t\tif (Is.array(methodArray)) {\n\t\t\t\t\tmethodArray.splice(existingMethodIndex, 1);\n\t\t\t\t\tif (methodArray.length === 0) {\n\t\t\t\t\t\tdelete didDocument[methods[existingMethodIndex].arrayKey as keyof IDidDocument];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"verificationMethodNotFound\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\n\t\t\tif (options?.removeKeys ?? false) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this._vaultConnector.removeKey(\n\t\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment)\n\t\t\t\t\t);\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeVerificationMethodFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Add a service to the document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to add the service to.\n\t * @param serviceId The id of the service.\n\t * @param serviceType The type of the service.\n\t * @param serviceEndpoint The endpoint for the service.\n\t * @returns The service.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async addService(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\tserviceId: string,\n\t\tserviceType: string | string[],\n\t\tserviceEndpoint: string | string[]\n\t): Promise<IDidService> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(serviceId), serviceId);\n\t\tif (Is.array(serviceType)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(serviceType),\n\t\t\t\tserviceType\n\t\t\t);\n\t\t} else {\n\t\t\tGuards.stringValue(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(serviceType),\n\t\t\t\tserviceType\n\t\t\t);\n\t\t}\n\t\tif (Is.array(serviceEndpoint)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(serviceEndpoint),\n\t\t\t\tserviceEndpoint\n\t\t\t);\n\t\t} else {\n\t\t\tGuards.stringValue(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(serviceEndpoint),\n\t\t\t\tserviceEndpoint\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentCached(documentId);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tconst fullServiceId = serviceId.includes(\"#\") ? serviceId : `${documentId}#${serviceId}`;\n\n\t\t\tif (Is.array(didDocument.service)) {\n\t\t\t\tconst existingServiceIndex = didDocument.service.findIndex(s => s.id === fullServiceId);\n\t\t\t\tif (existingServiceIndex !== -1) {\n\t\t\t\t\tdidDocument.service?.splice(existingServiceIndex, 1);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst didService: IDidService = {\n\t\t\t\tid: fullServiceId,\n\t\t\t\ttype: serviceType,\n\t\t\t\tserviceEndpoint\n\t\t\t};\n\n\t\t\tdidDocument.service ??= [];\n\t\t\tdidDocument.service.push(didService);\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\n\t\t\treturn didService;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"addServiceFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove a service from the document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param serviceId The id of the service.\n\t * @returns A promise that resolves when the service has been removed.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async removeService(controller: string, serviceId: string): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(serviceId), serviceId);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(serviceId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, \"missingDid\", serviceId);\n\t\t\t}\n\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentCached(idParts.id);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tif (Is.array(didDocument.service)) {\n\t\t\t\tconst existingServiceIndex = didDocument.service.findIndex(s => s.id === serviceId);\n\t\t\t\tif (existingServiceIndex !== -1) {\n\t\t\t\t\tdidDocument.service?.splice(existingServiceIndex, 1);\n\t\t\t\t\tif (didDocument.service?.length === 0) {\n\t\t\t\t\t\tdelete didDocument.service;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\t\"serviceNotFound\",\n\t\t\t\t\t\tserviceId\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"serviceNotFound\",\n\t\t\t\t\tserviceId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeServiceFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Add an alias to the alsoKnownAs property on the document.\n\t * If the alias is already present the operation is a no-op.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to update.\n\t * @param alias The alias to add. Must be a Url or Urn (typically another DID).\n\t * @returns A promise that resolves when the alias has been added.\n\t * @throws GeneralError if the alias is not a Url or Urn.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async addAlsoKnownAs(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\talias: string\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(alias), alias);\n\t\tif (!Url.tryParseExact(alias) && !Urn.tryParseExact(alias)) {\n\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"invalidAlias\", { alias });\n\t\t}\n\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentCached(documentId);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tconst existing = Is.array(didDocument.alsoKnownAs) ? didDocument.alsoKnownAs : [];\n\t\t\tif (existing.includes(alias)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdidDocument.alsoKnownAs = [...existing, alias];\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"addAlsoKnownAsFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove an alias from the alsoKnownAs property on the document.\n\t * If the alias is not present the operation is a no-op.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to update.\n\t * @param alias The alias to remove. Must be a Url or Urn.\n\t * @returns A promise that resolves when the alias has been removed.\n\t * @throws GeneralError if the alias is not a Url or Urn.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async removeAlsoKnownAs(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\talias: string\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(alias), alias);\n\t\tif (!Url.tryParseExact(alias) && !Urn.tryParseExact(alias)) {\n\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"invalidAlias\", { alias });\n\t\t}\n\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentCached(documentId);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tif (!Is.array(didDocument.alsoKnownAs) || !didDocument.alsoKnownAs.includes(alias)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst filtered = didDocument.alsoKnownAs.filter(a => a !== alias);\n\t\t\tif (filtered.length === 0) {\n\t\t\t\tdelete didDocument.alsoKnownAs;\n\t\t\t} else {\n\t\t\t\tdidDocument.alsoKnownAs = filtered;\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeAlsoKnownAsFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a verifiable credential for a verification method.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param id The id of the credential.\n\t * @param subject The credential subject to store in the verifiable credential.\n\t * @param options Additional options for creating the verifiable credential.\n\t * @param options.revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.\n\t * @param options.expirationDate The date the verifiable credential is valid until.\n\t * @param options.jwtHeaderFields Additional fields to add to the JWT header.\n\t * @param options.jwtPayloadFields Additional fields to add to the JWT payload.\n\t * @returns The created verifiable credential and its token.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async createVerifiableCredential(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\tid: string | undefined,\n\t\tsubject: IJsonLdNodeObject,\n\t\toptions?: {\n\t\t\trevocationIndex?: number;\n\t\t\texpirationDate?: Date;\n\t\t\tjwtHeaderFields?: { [id: string]: string };\n\t\t\tjwtPayloadFields?: { [id: string]: string };\n\t\t}\n\t): Promise<{\n\t\tverifiableCredential: IDidVerifiableCredentialV1;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(subject),\n\t\t\tsubject\n\t\t);\n\t\tif (!Is.undefined(options?.revocationIndex)) {\n\t\t\tGuards.number(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(options.revocationIndex),\n\t\t\t\toptions.revocationIndex\n\t\t\t);\n\t\t}\n\t\tif (!Is.undefined(options?.expirationDate)) {\n\t\t\tGuards.date(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(options.expirationDate),\n\t\t\t\toptions.expirationDate\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst issuerIdentityDocument = await this.resolveOwnDocumentCached(idParts.id);\n\t\t\tconst issuerDidDocument = issuerIdentityDocument.document;\n\n\t\t\tconst methods = this.getAllMethods(issuerDidDocument);\n\t\t\tconst methodAndArray = methods.find(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === verificationMethodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === verificationMethodId;\n\t\t\t});\n\n\t\t\tif (!methodAndArray) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"methodMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst verificationDidMethod = methodAndArray.method;\n\t\t\tif (!Is.stringValue(verificationDidMethod.publicKeyJwk?.x)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"publicKeyJwkMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst revocationService = issuerDidDocument.service?.find(s => s.id.endsWith(\"#revocation\"));\n\n\t\t\tconst subjectClone = ObjectHelper.clone(subject);\n\n\t\t\tconst credContext = ObjectHelper.extractProperty<IJsonLdContextDefinitionRoot>(subjectClone, [\n\t\t\t\t\"@context\"\n\t\t\t]);\n\t\t\tconst credId = ObjectHelper.extractProperty<string>(subjectClone, [\"@id\", \"id\"], false);\n\n\t\t\tconst verifiableCredential: IDidVerifiableCredentialV1 = {\n\t\t\t\t\"@context\": (JsonLdProcessor.combineContexts(DidContexts.ContextVCv1, credContext) ??\n\t\t\t\t\tDidContexts.ContextVCv1) as [typeof DidContexts.ContextVCv1],\n\t\t\t\tid,\n\t\t\t\ttype: DidTypes.VerifiableCredential,\n\t\t\t\tcredentialSubject: subjectClone,\n\t\t\t\tissuer: issuerDidDocument.id,\n\t\t\t\tissuanceDate: new Date(Date.now()).toISOString(),\n\t\t\t\texpirationDate: Is.date(options?.expirationDate)\n\t\t\t\t\t? options?.expirationDate.toISOString()\n\t\t\t\t\t: undefined,\n\t\t\t\tcredentialStatus:\n\t\t\t\t\trevocationService && !Is.undefined(options?.revocationIndex)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tid: revocationService.id,\n\t\t\t\t\t\t\t\ttype: Is.array(revocationService.type)\n\t\t\t\t\t\t\t\t\t? revocationService.type[0]\n\t\t\t\t\t\t\t\t\t: revocationService.type,\n\t\t\t\t\t\t\t\trevocationBitmapIndex: options.revocationIndex.toString()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined\n\t\t\t};\n\n\t\t\tconst jwtHeader: IJwtHeader = {\n\t\t\t\t...options?.jwtHeaderFields,\n\t\t\t\tkid: verificationDidMethod.id,\n\t\t\t\ttyp: \"JWT\",\n\t\t\t\talg: JwsAlgorithms.EdDSA\n\t\t\t};\n\n\t\t\tconst jwtVc = ObjectHelper.pick(ObjectHelper.clone(verifiableCredential), [\n\t\t\t\t\"@context\",\n\t\t\t\t\"type\",\n\t\t\t\t\"credentialSubject\",\n\t\t\t\t\"credentialStatus\"\n\t\t\t]);\n\n\t\t\t// Add the proof to the VC after extracting the jwt data\n\t\t\t// as the jwt does not include the proof\n\t\t\tverifiableCredential.proof = await this.createProof(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tProofTypes.DataIntegrityProof,\n\t\t\t\tJsonLdHelper.toNodeObject(verifiableCredential),\n\t\t\t\tissuerDidDocument\n\t\t\t);\n\n\t\t\t// As we are adding the receipt to the data we update the JSON-LD context\n\t\t\tconst proofContext = verifiableCredential.proof[\"@context\"];\n\t\t\tif (Is.notEmpty(proofContext)) {\n\t\t\t\tverifiableCredential[\"@context\"] = (JsonLdProcessor.combineContexts(\n\t\t\t\t\tverifiableCredential[\"@context\"],\n\t\t\t\t\tproofContext\n\t\t\t\t) ?? verifiableCredential[\"@context\"]) as IDidVerifiableCredentialV1[\"@context\"];\n\t\t\t\tdelete verifiableCredential.proof[\"@context\"];\n\t\t\t}\n\n\t\t\tif (Is.array(jwtVc.credentialSubject)) {\n\t\t\t\tjwtVc.credentialSubject = jwtVc.credentialSubject.map(c => {\n\t\t\t\t\tObjectHelper.propertyDelete(c, \"id\");\n\t\t\t\t\treturn c;\n\t\t\t\t});\n\t\t\t} else if (Is.object(jwtVc.credentialSubject)) {\n\t\t\t\tObjectHelper.propertyDelete(jwtVc.credentialSubject, \"id\");\n\t\t\t}\n\n\t\t\tconst jwtPayload: IJwtPayload = {\n\t\t\t\t...options?.jwtPayloadFields,\n\t\t\t\tiss: idParts.id,\n\t\t\t\tnbf: Math.floor(Date.now() / 1000),\n\t\t\t\tjti: verifiableCredential.id,\n\t\t\t\tsub: credId,\n\t\t\t\tvc: jwtVc\n\t\t\t};\n\n\t\t\tif (Is.date(options?.expirationDate)) {\n\t\t\t\tjwtPayload.exp = Math.floor(options.expirationDate.getTime() / 1000);\n\t\t\t}\n\n\t\t\tconst signature = await Jwt.encodeWithSigner(jwtHeader, jwtPayload, async (header, payload) =>\n\t\t\t\tVaultConnectorHelper.jwtSigner(\n\t\t\t\t\tthis._vaultConnector,\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment ?? \"\"),\n\t\t\t\t\theader,\n\t\t\t\t\tpayload\n\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tverifiableCredential,\n\t\t\t\tjwt: signature\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createVerifiableCredentialFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Check a verifiable credential is valid.\n\t * @param credential The credential to verify.\n\t * @returns The credential stored in the jwt and the revocation status.\n\t */\n\tpublic async checkVerifiableCredential(credential: string | IDidVerifiableCredential): Promise<{\n\t\trevoked: boolean;\n\t\tverifiableCredential?: IDidVerifiableCredential;\n\t}> {\n\t\tif (Is.object(credential)) {\n\t\t\tGuards.objectValue<IDidVerifiableCredential>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(credential),\n\t\t\t\tcredential\n\t\t\t);\n\t\t\tGuards.objectValue<IDidVerifiableCredential>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(credential.proof),\n\t\t\t\tcredential.proof\n\t\t\t);\n\t\t\tVerificationHelper.checkValidityPeriod(credential);\n\n\t\t\tconst { proof, ...doc } = credential;\n\t\t\tconst proofEntry = ArrayHelper.fromObjectOrArray(proof)[0];\n\t\t\tGuards.stringValue(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(proofEntry.verificationMethod),\n\t\t\t\tproofEntry.verificationMethod\n\t\t\t);\n\n\t\t\tconst issuer = Is.object<{ id: string }>(doc.issuer) ? doc.issuer.id : doc.issuer;\n\t\t\tconst signerDid = DocumentHelper.parseId(proofEntry.verificationMethod).id;\n\t\t\tif (Is.stringValue(issuer) && issuer !== signerDid) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"issuerMismatch\", {\n\t\t\t\t\tissuer,\n\t\t\t\t\tmethod: proofEntry.verificationMethod\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst issuerDidDocument = await this.resolveAssertionMethodDocument(\n\t\t\t\tproofEntry.verificationMethod\n\t\t\t);\n\t\t\tconst publicKeyJwk = DocumentHelper.getJwk(\n\t\t\t\tissuerDidDocument,\n\t\t\t\tproofEntry.verificationMethod,\n\t\t\t\tDidVerificationMethodType.AssertionMethod\n\t\t\t);\n\n\t\t\tconst credentialVerified = await ProofHelper.verifyProof(\n\t\t\t\tJsonLdHelper.toNodeObject(doc),\n\t\t\t\tproofEntry,\n\t\t\t\tpublicKeyJwk\n\t\t\t);\n\t\t\tif (!credentialVerified) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"signatureVerificationFailed\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst revoked = await this.checkCredentialStatusRevoked(\n\t\t\t\tissuerDidDocument,\n\t\t\t\tdoc.credentialStatus\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\trevoked,\n\t\t\t\tverifiableCredential: revoked ? undefined : doc\n\t\t\t};\n\t\t}\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(credential), credential);\n\n\t\ttry {\n\t\t\tconst jwtDecoded = await Jwt.decode(credential);\n\n\t\t\tconst jwtHeader = jwtDecoded.header;\n\t\t\tconst jwtPayload = jwtDecoded.payload;\n\t\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\t\tif (\n\t\t\t\tIs.undefined(jwtHeader) ||\n\t\t\t\tIs.undefined(jwtPayload) ||\n\t\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\t\tIs.undefined(jwtSignature)\n\t\t\t) {\n\t\t\t\tthrow new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, \"jwkSignatureFailed\");\n\t\t\t}\n\n\t\t\tconst issuerDocumentId = jwtPayload.iss;\n\t\t\tconst issuerIdentityDocument = await this._didDocumentEntityStorage.get(issuerDocumentId);\n\t\t\tif (Is.undefined(issuerIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tissuerDocumentId\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tissuerIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\t\t\tconst issuerDidDocument = issuerIdentityDocument.document;\n\n\t\t\tGuards.stringValue(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(jwtHeader.kid),\n\t\t\t\tjwtHeader.kid\n\t\t\t);\n\t\t\tconst publicKeyJwk = DocumentHelper.getJwk(\n\t\t\t\tissuerDidDocument,\n\t\t\t\tjwtHeader.kid,\n\t\t\t\tDidVerificationMethodType.AssertionMethod\n\t\t\t);\n\n\t\t\tawait Jwt.verifySignature(credential, await Jwk.toCryptoKey(publicKeyJwk));\n\n\t\t\tconst verifiableCredential = jwtPayload.vc as IDidVerifiableCredentialV1;\n\t\t\tif (Is.object(verifiableCredential)) {\n\t\t\t\tif (Is.string(jwtPayload.jti)) {\n\t\t\t\t\tverifiableCredential.id = jwtPayload.jti;\n\t\t\t\t}\n\t\t\t\tverifiableCredential.issuer = issuerDocumentId;\n\t\t\t\tif (Is.number(jwtPayload.nbf)) {\n\t\t\t\t\tverifiableCredential.issuanceDate = new Date(jwtPayload.nbf * 1000).toISOString();\n\t\t\t\t}\n\t\t\t\tif (Is.number(jwtPayload.exp)) {\n\t\t\t\t\tverifiableCredential.expirationDate = new Date(jwtPayload.exp * 1000).toISOString();\n\t\t\t\t}\n\t\t\t\tif (Is.array(verifiableCredential.credentialSubject)) {\n\t\t\t\t\tverifiableCredential.credentialSubject = verifiableCredential.credentialSubject.map(c => {\n\t\t\t\t\t\tObjectHelper.propertySet(c, \"id\", jwtPayload.sub);\n\t\t\t\t\t\treturn c;\n\t\t\t\t\t});\n\t\t\t\t} else if (Is.object(verifiableCredential.credentialSubject)) {\n\t\t\t\t\tObjectHelper.propertySet(verifiableCredential.credentialSubject, \"id\", jwtPayload.sub);\n\t\t\t\t}\n\t\t\t}\n\t\t\tVerificationHelper.checkValidityPeriod(verifiableCredential);\n\n\t\t\tconst revoked = await this.checkCredentialStatusRevoked(\n\t\t\t\tissuerDidDocument,\n\t\t\t\tverifiableCredential.credentialStatus\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\trevoked,\n\t\t\t\tverifiableCredential: revoked ? undefined : verifiableCredential\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"checkingVerifiableCredentialFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Revoke verifiable credential(s).\n\t * @param controller The controller of the identity who can make changes.\n\t * @param issuerDocumentId The id of the document to update the revocation list for.\n\t * @param credentialIndices The revocation bitmap index or indices to revoke.\n\t * @returns A promise that resolves when the credentials have been revoked.\n\t */\n\tpublic async revokeVerifiableCredentials(\n\t\tcontroller: string,\n\t\tissuerDocumentId: string,\n\t\tcredentialIndices: number[]\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(issuerDocumentId),\n\t\t\tissuerDocumentId\n\t\t);\n\t\tGuards.arrayValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(credentialIndices),\n\t\t\tcredentialIndices\n\t\t);\n\n\t\ttry {\n\t\t\tconst issuerIdentityDocument = await this.resolveOwnDocumentCached(issuerDocumentId);\n\t\t\tconst issuerDidDocument = issuerIdentityDocument.document;\n\n\t\t\tconst revocationService = issuerDidDocument.service?.find(s => s.id.endsWith(\"#revocation\"));\n\t\t\tif (\n\t\t\t\trevocationService &&\n\t\t\t\tIs.string(revocationService.serviceEndpoint) &&\n\t\t\t\trevocationService.type === \"BitstringStatusList\"\n\t\t\t) {\n\t\t\t\tconst revocationParts = revocationService.serviceEndpoint.split(\",\");\n\t\t\t\tif (revocationParts.length === 2) {\n\t\t\t\t\tconst compressedRevocationBytes = Converter.base64UrlToBytes(revocationParts[1]);\n\t\t\t\t\tconst decompressed = await Compression.decompress(\n\t\t\t\t\t\tcompressedRevocationBytes,\n\t\t\t\t\t\tCompressionType.Gzip\n\t\t\t\t\t);\n\n\t\t\t\t\tconst bitString = BitString.fromBits(\n\t\t\t\t\t\tdecompressed,\n\t\t\t\t\t\tEntityStorageIdentityConnector._REVOCATION_BITS_SIZE\n\t\t\t\t\t);\n\n\t\t\t\t\tfor (const credentialIndex of credentialIndices) {\n\t\t\t\t\t\tbitString.setBit(credentialIndex, true);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst compressed = await Compression.compress(bitString.getBits(), CompressionType.Gzip);\n\t\t\t\t\trevocationService.serviceEndpoint = `data:application/octet-stream;base64,${Converter.bytesToBase64Url(compressed)}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, issuerDidDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"revokeVerifiableCredentialsFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Unrevoke verifiable credential(s).\n\t * @param controller The controller of the identity who can make changes.\n\t * @param issuerDocumentId The id of the document to update the revocation list for.\n\t * @param credentialIndices The revocation bitmap index or indices to un revoke.\n\t * @returns A promise that resolves when the credentials have been unrevoked.\n\t */\n\tpublic async unrevokeVerifiableCredentials(\n\t\tcontroller: string,\n\t\tissuerDocumentId: string,\n\t\tcredentialIndices: number[]\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(issuerDocumentId),\n\t\t\tissuerDocumentId\n\t\t);\n\t\tGuards.arrayValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(credentialIndices),\n\t\t\tcredentialIndices\n\t\t);\n\n\t\ttry {\n\t\t\tconst issuerIdentityDocument = await this.resolveOwnDocumentCached(issuerDocumentId);\n\t\t\tconst issuerDidDocument = issuerIdentityDocument.document;\n\n\t\t\tconst revocationService = issuerDidDocument.service?.find(s => s.id.endsWith(\"#revocation\"));\n\t\t\tif (\n\t\t\t\trevocationService &&\n\t\t\t\tIs.string(revocationService.serviceEndpoint) &&\n\t\t\t\trevocationService.type === \"BitstringStatusList\"\n\t\t\t) {\n\t\t\t\tconst revocationParts = revocationService.serviceEndpoint.split(\",\");\n\t\t\t\tif (revocationParts.length === 2) {\n\t\t\t\t\tconst compressedRevocationBytes = Converter.base64UrlToBytes(revocationParts[1]);\n\t\t\t\t\tconst decompressed = await Compression.decompress(\n\t\t\t\t\t\tcompressedRevocationBytes,\n\t\t\t\t\t\tCompressionType.Gzip\n\t\t\t\t\t);\n\n\t\t\t\t\tconst bitString = BitString.fromBits(\n\t\t\t\t\t\tdecompressed,\n\t\t\t\t\t\tEntityStorageIdentityConnector._REVOCATION_BITS_SIZE\n\t\t\t\t\t);\n\n\t\t\t\t\tfor (const credentialIndex of credentialIndices) {\n\t\t\t\t\t\tbitString.setBit(credentialIndex, false);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst compressed = await Compression.compress(bitString.getBits(), CompressionType.Gzip);\n\t\t\t\t\trevocationService.serviceEndpoint = `data:application/octet-stream;base64,${Converter.bytesToBase64Url(compressed)}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, issuerDidDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"unrevokeVerifiableCredentialsFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a verifiable presentation from the supplied verifiable credentials.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The method to associate with the presentation.\n\t * @param presentationId The id of the presentation.\n\t * @param contexts The contexts for the data stored in the verifiable credential.\n\t * @param types The types for the data stored in the verifiable credential.\n\t * @param verifiableCredentials The credentials to use for creating the presentation in jwt format.\n\t * @param options Additional options for creating the verifiable presentation.\n\t * @param options.expirationDate The date the verifiable presentation is valid until.\n\t * @param options.jwtHeaderFields Additional fields to add to the JWT header.\n\t * @param options.jwtPayloadFields Additional fields to add to the JWT payload.\n\t * @returns The created verifiable presentation and its token.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async createVerifiablePresentation(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\tpresentationId: string | undefined,\n\t\tcontexts: IJsonLdContextDefinitionRoot | undefined,\n\t\ttypes: string | string[] | undefined,\n\t\tverifiableCredentials: (string | IDidVerifiableCredentialV1)[],\n\t\toptions?: {\n\t\t\texpirationDate?: Date;\n\t\t\tjwtHeaderFields?: { [id: string]: string };\n\t\t\tjwtPayloadFields?: { [id: string]: string };\n\t\t}\n\t): Promise<{\n\t\tverifiablePresentation: IDidVerifiablePresentationV1;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tif (Is.array(types)) {\n\t\t\tGuards.arrayValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(types), types);\n\t\t} else if (Is.string(types)) {\n\t\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(types), types);\n\t\t}\n\t\tGuards.arrayValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verifiableCredentials),\n\t\t\tverifiableCredentials\n\t\t);\n\t\tif (!Is.undefined(options?.expirationDate)) {\n\t\t\tGuards.date(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(options.expirationDate),\n\t\t\t\toptions.expirationDate\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst holderIdentityDocument = await this.resolveOwnDocumentCached(idParts.id);\n\t\t\tconst holderDidDocument = holderIdentityDocument.document;\n\n\t\t\tconst methods = this.getAllMethods(holderDidDocument);\n\t\t\tconst methodAndArray = methods.find(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === verificationMethodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === verificationMethodId;\n\t\t\t});\n\n\t\t\tif (!methodAndArray) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"methodMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst didMethod = methodAndArray.method;\n\t\t\tif (!Is.stringValue(didMethod.publicKeyJwk?.x)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"publicKeyJwkMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst finalTypes: string[] = [DidTypes.VerifiablePresentation];\n\t\t\tif (Is.array(types)) {\n\t\t\t\tfinalTypes.push(...types);\n\t\t\t} else if (Is.stringValue(types)) {\n\t\t\t\tfinalTypes.push(types);\n\t\t\t}\n\n\t\t\tconst combinedContext =\n\t\t\t\tJsonLdProcessor.combineContexts(DidContexts.ContextVCv1, contexts) ??\n\t\t\t\tDidContexts.ContextVCv1;\n\n\t\t\tconst verifiablePresentation: IDidVerifiablePresentationV1 = {\n\t\t\t\t\"@context\": combinedContext as [typeof DidContexts.ContextVCv1],\n\t\t\t\tid: presentationId,\n\t\t\t\ttype: finalTypes,\n\t\t\t\tverifiableCredential: verifiableCredentials,\n\t\t\t\tholder: idParts.id\n\t\t\t};\n\n\t\t\tconst jwtHeader: IJwtHeader = {\n\t\t\t\t...options?.jwtHeaderFields,\n\t\t\t\tkid: didMethod.id,\n\t\t\t\ttyp: \"JWT\",\n\t\t\t\talg: JwsAlgorithms.EdDSA\n\t\t\t};\n\n\t\t\tconst jwtVp = ObjectHelper.pick(ObjectHelper.clone(verifiablePresentation), [\n\t\t\t\t\"@context\",\n\t\t\t\t\"type\",\n\t\t\t\t\"verifiableCredential\"\n\t\t\t]);\n\n\t\t\t// Add the proof to the VP after extracting the jwt data\n\t\t\t// as the jwt does not include the proof\n\t\t\tverifiablePresentation.proof = await this.createProof(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tProofTypes.DataIntegrityProof,\n\t\t\t\tJsonLdHelper.toNodeObject(verifiablePresentation),\n\t\t\t\tholderDidDocument\n\t\t\t);\n\n\t\t\tconst jwtPayload: IJwtPayload = {\n\t\t\t\t...options?.jwtPayloadFields,\n\t\t\t\tiss: verifiablePresentation.holder,\n\t\t\t\tnbf: Math.floor(Date.now() / 1000),\n\t\t\t\tvp: jwtVp\n\t\t\t};\n\n\t\t\tif (Is.date(options?.expirationDate)) {\n\t\t\t\tjwtPayload.exp = Math.floor(options.expirationDate.getTime() / 1000);\n\t\t\t}\n\n\t\t\tconst signature = await Jwt.encodeWithSigner(jwtHeader, jwtPayload, async (header, payload) =>\n\t\t\t\tVaultConnectorHelper.jwtSigner(\n\t\t\t\t\tthis._vaultConnector,\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment ?? \"\"),\n\t\t\t\t\theader,\n\t\t\t\t\tpayload\n\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tverifiablePresentation,\n\t\t\t\tjwt: signature\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createVerifiablePresentationFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Check a verifiable presentation is valid.\n\t * @param presentation The presentation to verify.\n\t * @returns The presentation stored in the jwt and the revocation status.\n\t */\n\tpublic async checkVerifiablePresentation(\n\t\tpresentation: string | IDidVerifiablePresentation\n\t): Promise<{\n\t\trevoked: boolean;\n\t\tverifiablePresentation?: IDidVerifiablePresentationV1;\n\t\tissuers?: IDidDocument[];\n\t}> {\n\t\tif (Is.object(presentation)) {\n\t\t\tconst { proof, ...doc } = presentation as IDidVerifiablePresentationV1;\n\t\t\tconst proofEntry = ArrayHelper.fromObjectOrArray(proof)[0];\n\t\t\tGuards.objectValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(proofEntry), proofEntry);\n\t\t\tconst presentationVerified = await this.verifyProof(\n\t\t\t\tJsonLdHelper.toNodeObject(doc),\n\t\t\t\tproofEntry\n\t\t\t);\n\t\t\tif (!presentationVerified) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"signatureVerificationFailed\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tlet revoked = false;\n\t\t\tfor (const embeddedCredential of doc.verifiableCredential ?? []) {\n\t\t\t\tconst credentialCheck = await this.checkVerifiableCredential(embeddedCredential);\n\t\t\t\tif (credentialCheck.revoked) {\n\t\t\t\t\trevoked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { revoked, verifiablePresentation: doc };\n\t\t}\n\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(presentation),\n\t\t\tpresentation\n\t\t);\n\n\t\tconst presentationJwt = presentation;\n\n\t\ttry {\n\t\t\tconst jwtDecoded = await Jwt.decode(presentationJwt);\n\n\t\t\tconst jwtHeader = jwtDecoded.header;\n\t\t\tconst jwtPayload = jwtDecoded.payload;\n\t\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\t\tif (\n\t\t\t\tIs.undefined(jwtHeader) ||\n\t\t\t\tIs.undefined(jwtPayload) ||\n\t\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\t\tIs.undefined(jwtSignature)\n\t\t\t) {\n\t\t\t\tthrow new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, \"jwkSignatureFailed\");\n\t\t\t}\n\n\t\t\tconst holderDocumentId = jwtPayload.iss;\n\t\t\tconst holderIdentityDocument = await this._didDocumentEntityStorage.get(holderDocumentId);\n\t\t\tif (Is.undefined(holderIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tholderDocumentId\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tholderIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\n\t\t\tconst issuers: IDidDocument[] = [];\n\t\t\tconst tokensRevoked: boolean[] = [];\n\t\t\tconst verifiablePresentation = jwtPayload?.vp as IDidVerifiablePresentationV1;\n\t\t\tif (\n\t\t\t\tIs.object<IDidVerifiablePresentationV1>(verifiablePresentation) &&\n\t\t\t\tIs.array(verifiablePresentation.verifiableCredential)\n\t\t\t) {\n\t\t\t\tfor (const vcJwt of verifiablePresentation.verifiableCredential) {\n\t\t\t\t\tlet revoked = false;\n\t\t\t\t\tif (Is.stringValue(vcJwt)) {\n\t\t\t\t\t\tconst jwt = await Jwt.decode(vcJwt);\n\n\t\t\t\t\t\tif (Is.string(jwt.payload?.iss)) {\n\t\t\t\t\t\t\tconst issuerDocumentId = jwt.payload.iss;\n\t\t\t\t\t\t\tverifiablePresentation.holder = issuerDocumentId;\n\n\t\t\t\t\t\t\tconst issuerDidDocument = await this._didDocumentEntityStorage.get(issuerDocumentId);\n\t\t\t\t\t\t\tif (Is.undefined(issuerDidDocument)) {\n\t\t\t\t\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\t\t\t\t\tissuerDocumentId\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\t\t\t\t\tissuerDidDocument,\n\t\t\t\t\t\t\t\tthis._vaultConnector\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tissuers.push({\n\t\t\t\t\t\t\t\t\"@context\": DidContexts.Context,\n\t\t\t\t\t\t\t\t...issuerDidDocument\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst credentialCheck = await this.checkVerifiableCredential(vcJwt);\n\t\t\t\t\t\trevoked = credentialCheck.revoked;\n\t\t\t\t\t}\n\t\t\t\t\ttokensRevoked.push(revoked);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\trevoked: tokensRevoked.some(Boolean),\n\t\t\t\tverifiablePresentation,\n\t\t\t\tissuers\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (BaseError.isErrorMessage(error, /revoked/i)) {\n\t\t\t\treturn {\n\t\t\t\t\trevoked: true\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"checkingVerifiablePresentationFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a proof for arbitrary data with the specified verification method.\n\t * This method uses async signing to ensure the private key never leaves the vault,\n\t * with algorithm validation to ensure key type compatibility.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param proofType The type of proof to create.\n\t * @param unsecureDocument The unsecure document to create the proof for.\n\t * @param resolvedDocument Optional already-resolved document for the DID, so a caller that\n\t * just resolved it (e.g. createVerifiableCredential) skips a redundant re-resolve. Resolves\n\t * it itself if omitted.\n\t * @returns The proof.\n\t * @throws NotFoundError if the identity or method is not found.\n\t * @throws GeneralError if algorithm doesn't match key type or proof creation fails.\n\t */\n\tpublic async createProof(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\tproofType: ProofTypes,\n\t\tunsecureDocument: IJsonLdNodeObject,\n\t\tresolvedDocument?: IDidDocument\n\t): Promise<IProof> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.arrayOneOf<ProofTypes>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(proofType),\n\t\t\tproofType,\n\t\t\tObject.values(ProofTypes)\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(unsecureDocument),\n\t\t\tunsecureDocument\n\t\t);\n\t\tif (!Is.undefined(resolvedDocument)) {\n\t\t\tGuards.object<IDidDocument>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(resolvedDocument),\n\t\t\t\tresolvedDocument\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst didDocument = Is.undefined(resolvedDocument)\n\t\t\t\t? (await this.resolveOwnDocumentCached(idParts.id)).document\n\t\t\t\t: resolvedDocument;\n\n\t\t\tconst methods = this.getAllMethods(didDocument);\n\t\t\tconst methodAndArray = methods.find(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === verificationMethodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === verificationMethodId;\n\t\t\t});\n\n\t\t\tif (!methodAndArray) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"methodMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst didMethod = methodAndArray.method;\n\t\t\tif (!Is.stringValue(didMethod.publicKeyJwk?.x)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"publicKeyJwkMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst vaultKey = EntityStorageIdentityConnector.buildVaultKey(\n\t\t\t\tdidDocument.id,\n\t\t\t\tidParts.fragment ?? \"\"\n\t\t\t);\n\t\t\tconst keyType = await this._vaultConnector.getKeyType(vaultKey);\n\n\t\t\tif (Is.undefined(keyType)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"privateKeyMissing\", {\n\t\t\t\t\tkeyId: vaultKey\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst unsignedProof = ProofHelper.createUnsignedProof(proofType, verificationMethodId);\n\n\t\t\tconst signedProof = await ProofHelper.createProofWithSigner(\n\t\t\t\tproofType,\n\t\t\t\tunsecureDocument,\n\t\t\t\tunsignedProof,\n\t\t\t\tasync (data, algorithm) => this.signWithVault(vaultKey, keyType, data, algorithm)\n\t\t\t);\n\n\t\t\treturn signedProof;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createProofFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Verify proof for arbitrary data with the specified verification method.\n\t * @param document The document to verify.\n\t * @param proof The proof to verify.\n\t * @returns True if the proof is verified.\n\t */\n\tpublic async verifyProof(document: IJsonLdNodeObject, proof: IProof): Promise<boolean> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(document),\n\t\t\tdocument\n\t\t);\n\t\tGuards.object<IProof>(EntityStorageIdentityConnector.CLASS_NAME, nameof(proof), proof);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(proof.verificationMethod),\n\t\t\tproof.verificationMethod\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(proof.verificationMethod);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tproof.verificationMethod\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst didIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);\n\t\t\tif (Is.undefined(didIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tidParts.id\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tdidIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tconst methods = this.getAllMethods(didDocument);\n\n\t\t\tconst methodAndArray = methods.find(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === proof.verificationMethod;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === proof.verificationMethod;\n\t\t\t});\n\n\t\t\tif (!methodAndArray) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"methodMissing\", {\n\t\t\t\t\tmethod: proof.verificationMethod\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst didMethod = methodAndArray.method;\n\t\t\tif (!Is.stringValue(didMethod.publicKeyJwk?.x)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"publicKeyJwkMissing\", {\n\t\t\t\t\tmethod: proof.verificationMethod\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst result = await ProofHelper.verifyProof(document, proof, didMethod.publicKeyJwk);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"verifyProofFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Signs data using the vault connector with algorithm validation.\n\t * @param vaultKey The vault key identifier.\n\t * @param keyType The type of the key.\n\t * @param data The data to sign.\n\t * @param algorithm The signing algorithm.\n\t * @returns The signature bytes.\n\t * @throws GeneralError if algorithm doesn't match key type.\n\t * @internal\n\t */\n\tprivate async signWithVault(\n\t\tvaultKey: string,\n\t\tkeyType: VaultKeyType,\n\t\tdata: Uint8Array,\n\t\talgorithm: string\n\t): Promise<Uint8Array> {\n\t\tif (algorithm === JwsAlgorithms.EdDSA && keyType !== VaultKeyType.Ed25519) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"algorithmKeyTypeMismatch\",\n\t\t\t\t{\n\t\t\t\t\talgorithm,\n\t\t\t\t\texpectedKeyType: VaultKeyType.Ed25519,\n\t\t\t\t\tactualKeyType: keyType,\n\t\t\t\t\tkeyId: vaultKey\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t\treturn this._vaultConnector.sign(vaultKey, data);\n\t}\n\n\t/**\n\t * Get all the methods from a document.\n\t * @param document The document to get the methods from.\n\t * @returns The methods.\n\t * @internal\n\t */\n\tprivate getAllMethods(\n\t\tdocument: IDidDocument\n\t): { arrayKey: string; method: Partial<IDidDocumentVerificationMethod> }[] {\n\t\tconst methods: {\n\t\t\tarrayKey: string;\n\t\t\tmethod: Partial<IDidDocumentVerificationMethod>;\n\t\t}[] = [];\n\n\t\tconst methodTypes: DidVerificationMethodType[] = Object.values(DidVerificationMethodType);\n\n\t\tfor (const methodType of methodTypes) {\n\t\t\tconst mt = document[methodType];\n\t\t\tif (Is.arrayValue(mt)) {\n\t\t\t\tmethods.push(\n\t\t\t\t\t...mt.map(m => ({\n\t\t\t\t\t\tarrayKey: methodType,\n\t\t\t\t\t\tmethod: Is.string(m) ? { id: m } : m\n\t\t\t\t\t}))\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn methods;\n\t}\n\n\t/**\n\t * Resolve the issuer document for a verification method, verified against its stored signature.\n\t * @param verificationMethodId The verification method id whose owning DID to resolve.\n\t * @returns The resolved document.\n\t * @throws NotFoundError if the id has no DID, or the DID cannot be resolved.\n\t * @internal\n\t */\n\tprivate async resolveAssertionMethodDocument(\n\t\tverificationMethodId: string\n\t): Promise<IDidDocument> {\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\tif (Is.empty(idParts.fragment)) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"missingDid\",\n\t\t\t\tverificationMethodId\n\t\t\t);\n\t\t}\n\n\t\tconst identityDocument = await this._didDocumentEntityStorage.get(idParts.id);\n\t\tif (Is.undefined(identityDocument)) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"documentNotFound\",\n\t\t\t\tidParts.id\n\t\t\t);\n\t\t}\n\t\tawait EntityStorageIdentityConnector.verifyDocument(identityDocument, this._vaultConnector);\n\n\t\treturn identityDocument.document;\n\t}\n\n\t/**\n\t * Cache key for a DID resolved for this connector's own sign/mutate operations (role 1).\n\t * Deliberately namespaced (\"own\") and never shared with proof/credential verification of\n\t * third-party claims (role 2/3), which this connector never caches.\n\t * @param documentId The DID being resolved.\n\t * @returns The cache key.\n\t * @internal\n\t */\n\tprivate ownDidCacheKey(documentId: string): string {\n\t\treturn `${EntityStorageIdentityConnector.CLASS_NAME}:own:${documentId}`;\n\t}\n\n\t/**\n\t * Load and verify a document's own storage entity, uncached.\n\t * @param documentId The DID to load.\n\t * @returns The verified storage entity.\n\t * @throws NotFoundError if the DID could not be resolved.\n\t * @internal\n\t */\n\tprivate async loadOwnDocument(documentId: string): Promise<IdentityDocument> {\n\t\tconst identityDocument = await this._didDocumentEntityStorage.get(documentId);\n\t\tif (Is.undefined(identityDocument)) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"documentNotFound\",\n\t\t\t\tdocumentId\n\t\t\t);\n\t\t}\n\t\tawait EntityStorageIdentityConnector.verifyDocument(identityDocument, this._vaultConnector);\n\n\t\treturn identityDocument;\n\t}\n\n\t/**\n\t * Resolve a document's own storage entity for this connector's own sign/mutate operations,\n\t * cached for didResolutionCacheTtlMs (0 disables caching and resolves fresh every call).\n\t * Only ever used for the connector's own create/update/revoke paths - never for verifyProof\n\t * or credential/presentation verification, which must stay uncached.\n\t * A clone is always returned: mutators edit the entity in place before storing it, and the\n\t * cached instance must never be handed out by reference.\n\t * @param documentId The DID to resolve.\n\t * @returns The verified storage entity.\n\t * @throws NotFoundError if the DID could not be resolved.\n\t * @internal\n\t */\n\tprivate async resolveOwnDocumentCached(documentId: string): Promise<IdentityDocument> {\n\t\tif (Is.undefined(this._didResolutionCache)) {\n\t\t\treturn this.loadOwnDocument(documentId);\n\t\t}\n\n\t\tconst identityDocument = await this._didResolutionCache.getOrSet(\n\t\t\tthis.ownDidCacheKey(documentId),\n\t\t\tasync () => this.loadOwnDocument(documentId)\n\t\t);\n\t\treturn ObjectHelper.clone(identityDocument);\n\t}\n\n\t/**\n\t * Check whether a credential's status entry or entries report it as revoked.\n\t * @param document The issuer document owning the revocation bitmap service.\n\t * @param credentialStatus The credential's status entry or entries to check.\n\t * @returns True if any entry is reported revoked.\n\t * @internal\n\t */\n\tprivate async checkCredentialStatusRevoked(\n\t\tdocument: IDidDocument,\n\t\tcredentialStatus: IDidCredentialStatus | IDidCredentialStatus[] | undefined\n\t): Promise<boolean> {\n\t\tlet statuses: IDidCredentialStatus[] = [];\n\t\tif (Is.array<IDidCredentialStatus>(credentialStatus)) {\n\t\t\tstatuses = credentialStatus;\n\t\t} else if (Is.object<IDidCredentialStatus>(credentialStatus)) {\n\t\t\tstatuses = [credentialStatus];\n\t\t}\n\n\t\tfor (const status of statuses) {\n\t\t\tif (await this.checkRevocation(document, status.revocationBitmapIndex)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Check if a revocation index is revoked.\n\t * @param document The document to check.\n\t * @param revocationBitmapIndex The revocation index to check.\n\t * @returns True if the index is revoked.\n\t * @internal\n\t */\n\tprivate async checkRevocation(\n\t\tdocument: IDidDocument,\n\t\trevocationBitmapIndex?: unknown\n\t): Promise<boolean> {\n\t\tconst revocationIndex = Coerce.number(revocationBitmapIndex);\n\t\tif (Is.number(revocationIndex)) {\n\t\t\tconst revocationService = document.service?.find(s => s.id.endsWith(\"#revocation\"));\n\t\t\tif (\n\t\t\t\trevocationService &&\n\t\t\t\tIs.string(revocationService.serviceEndpoint) &&\n\t\t\t\trevocationService.type === \"BitstringStatusList\"\n\t\t\t) {\n\t\t\t\tconst revocationParts = revocationService.serviceEndpoint.split(\",\");\n\t\t\t\tif (revocationParts.length === 2) {\n\t\t\t\t\tconst compressedRevocationBytes = Converter.base64UrlToBytes(revocationParts[1]);\n\t\t\t\t\tconst decompressed = await Compression.decompress(\n\t\t\t\t\t\tcompressedRevocationBytes,\n\t\t\t\t\t\tCompressionType.Gzip\n\t\t\t\t\t);\n\n\t\t\t\t\tconst bitString = BitString.fromBits(\n\t\t\t\t\t\tdecompressed,\n\t\t\t\t\t\tEntityStorageIdentityConnector._REVOCATION_BITS_SIZE\n\t\t\t\t\t);\n\n\t\t\t\t\treturn bitString.getBit(revocationIndex);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Update the document in storage.\n\t * @param controller The controller of the document.\n\t * @param didDocument The did document to store.\n\t * @returns A promise that resolves when the document has been signed and persisted.\n\t * @internal\n\t */\n\tprivate async updateDocument(controller: string, didDocument: IDidDocument): Promise<void> {\n\t\tconst stringifiedDocument = JsonHelper.canonicalize(didDocument);\n\t\tconst docBytes = Converter.utf8ToBytes(stringifiedDocument);\n\n\t\tconst signature = await this._vaultConnector.sign(\n\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, \"did\"),\n\t\t\tdocBytes\n\t\t);\n\n\t\tconst identityDocument: IdentityDocument = {\n\t\t\tid: didDocument.id,\n\t\t\tdocument: didDocument,\n\t\t\tsignature: Converter.bytesToBase64(signature),\n\t\t\tcontroller\n\t\t};\n\n\t\tawait this._didDocumentEntityStorage.set(identityDocument);\n\n\t\tthis._didResolutionCache?.set(\n\t\t\tthis.ownDidCacheKey(didDocument.id),\n\t\t\tObjectHelper.clone(identityDocument)\n\t\t);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"entityStorageIdentityConnector.js","sourceRoot":"","sources":["../../src/entityStorageIdentityConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,WAAW,EACX,SAAS,EACT,SAAS,EACT,MAAM,EACN,WAAW,EACX,eAAe,EACf,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,UAAU,EACV,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,GAAG,EACH,GAAG,EACH,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,YAAY,EACZ,eAAe,EAGf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACN,cAAc,EACd,kBAAkB,EAElB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,WAAW,EACX,QAAQ,EACR,yBAAyB,EAGzB,aAAa,EACb,WAAW,EACX,UAAU,EAQV,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EAEZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAgD,MAAM,eAAe,CAAC;AAIvF;;GAEG;AACH,MAAM,OAAO,8BAA8B;IAC1C;;OAEG;IACI,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AAa,CAAC,SAAS,CAAC;YAC7C,UAAU;SACV,CAAC;QAEF,MAAM,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAE3D,IAAI,CAAC,mBAAmB,EAAE,GAAG,CAC5B,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC,EACnC,YAAY,CAAC,KAAK,CAAC,gBAAgB,CAAC,CACpC,CAAC;IACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tArrayHelper,\n\tBaseError,\n\tBitString,\n\tCoerce,\n\tCompression,\n\tCompressionType,\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tJsonHelper,\n\tLruCache,\n\tNotFoundError,\n\tObjectHelper,\n\tRandomHelper,\n\tUnauthorizedError,\n\tUrl,\n\tUrn\n} from \"@twin.org/core\";\nimport {\n\tJsonLdHelper,\n\tJsonLdProcessor,\n\ttype IJsonLdContextDefinitionRoot,\n\ttype IJsonLdNodeObject\n} from \"@twin.org/data-json-ld\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport {\n\tDocumentHelper,\n\tVerificationHelper,\n\ttype IIdentityConnector\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDidContexts,\n\tDidTypes,\n\tDidVerificationMethodType,\n\ttype IDidCredentialStatus,\n\ttype IDidVerifiableCredential,\n\tJwsAlgorithms,\n\tProofHelper,\n\tProofTypes,\n\ttype IDidDocument,\n\ttype IDidDocumentVerificationMethod,\n\ttype IDidService,\n\ttype IDidVerifiableCredentialV1,\n\ttype IDidVerifiablePresentationV1,\n\ttype IProof,\n\ttype IDidVerifiablePresentation\n} from \"@twin.org/standards-w3c-did\";\nimport {\n\tVaultConnectorFactory,\n\tVaultConnectorHelper,\n\tVaultKeyType,\n\ttype IVaultConnector\n} from \"@twin.org/vault-models\";\nimport { Jwk, Jwt, type IJwk, type IJwtHeader, type IJwtPayload } from \"@twin.org/web\";\nimport type { IdentityDocument } from \"./entities/identityDocument.js\";\nimport type { IEntityStorageIdentityConnectorConstructorOptions } from \"./models/IEntityStorageIdentityConnectorConstructorOptions.js\";\n\n/**\n * Class for performing identity operations using entity storage.\n */\nexport class EntityStorageIdentityConnector implements IIdentityConnector {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageIdentityConnector>();\n\n\t/**\n\t * The namespace supported by the identity connector.\n\t */\n\tpublic static readonly NAMESPACE: string = \"entity-storage\";\n\n\t/**\n\t * The size of the revocation bitmap in bits (16Kb).\n\t * @internal\n\t */\n\tprivate static readonly _REVOCATION_BITS_SIZE: number = 131072;\n\n\t/**\n\t * The entity storage for identities.\n\t * @internal\n\t */\n\tprotected readonly _didDocumentEntityStorage: IEntityStorageConnector<IdentityDocument>;\n\n\t/**\n\t * The vault for the keys.\n\t * @internal\n\t */\n\tprotected readonly _vaultConnector: IVaultConnector;\n\n\t/**\n\t * TTL in ms for caching DID documents resolved for this connector's own sign/mutate\n\t * operations. 0 disables caching (see resolveOwnDocumentCached). Never applied to proof or\n\t * credential verification of third-party claims.\n\t * @internal\n\t */\n\tprivate readonly _didResolutionCacheTtlMs: number;\n\n\t/**\n\t * Maximum number of own DID documents retained in cache.\n\t * @internal\n\t */\n\tprivate readonly _didResolutionCacheCapacity: number;\n\n\t/**\n\t * Maximum wait time for own DID cache getOrSet mutex acquisition in milliseconds.\n\t * @internal\n\t */\n\tprivate readonly _didResolutionCacheMutexTimeoutMs?: number;\n\n\t/**\n\t * LRU cache for own DID documents. Undefined when caching is disabled (ttl is 0).\n\t * @internal\n\t */\n\tprivate readonly _didResolutionCache?: LruCache<IdentityDocument>;\n\n\t/**\n\t * Create a new instance of EntityStorageIdentityConnector.\n\t * @param options The options for the identity connector.\n\t */\n\tconstructor(options?: IEntityStorageIdentityConnectorConstructorOptions) {\n\t\tthis._didDocumentEntityStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.didDocumentEntityStorageType ?? \"identity-document\"\n\t\t);\n\t\tthis._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? \"vault\");\n\n\t\tthis._didResolutionCacheTtlMs = options?.config?.didResolutionCacheTtlMs ?? 30_000;\n\t\tthis._didResolutionCacheCapacity = options?.config?.didResolutionCacheCapacity ?? 1000;\n\t\tthis._didResolutionCacheMutexTimeoutMs = options?.config?.didResolutionCacheMutexTimeoutMs;\n\t\tthis._didResolutionCache =\n\t\t\tthis._didResolutionCacheTtlMs > 0\n\t\t\t\t? new LruCache<IdentityDocument>({\n\t\t\t\t\t\tcapacity: this._didResolutionCacheCapacity,\n\t\t\t\t\t\tttiMs: this._didResolutionCacheTtlMs,\n\t\t\t\t\t\tmutexTimeoutMs: this._didResolutionCacheMutexTimeoutMs\n\t\t\t\t\t})\n\t\t\t\t: undefined;\n\t}\n\n\t/**\n\t * Build the key name to access the specified key in the vault.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param key The key to access in the vault.\n\t * @returns The vault key.\n\t * @internal\n\t */\n\tpublic static buildVaultKey(identity: string, key: string): string {\n\t\treturn `${identity}/${key}`;\n\t}\n\n\t/**\n\t * Verify the document in storage.\n\t * @param didDocument The did document that was stored.\n\t * @param vaultConnector The vault connector to use for verification.\n\t * @returns A promise that resolves when verification is complete.\n\t * @throws GeneralError if the document signature is invalid.\n\t * @internal\n\t */\n\tpublic static async verifyDocument(\n\t\tdidDocument: IdentityDocument,\n\t\tvaultConnector: IVaultConnector\n\t): Promise<void> {\n\t\tconst stringifiedDocument = JsonHelper.canonicalize(didDocument.document);\n\t\tconst docBytes = Converter.utf8ToBytes(stringifiedDocument);\n\n\t\tconst verified = await vaultConnector.verify(\n\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, \"did\"),\n\t\t\tdocBytes,\n\t\t\tConverter.base64ToBytes(didDocument.signature)\n\t\t);\n\n\t\tif (!verified) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"signatureVerificationFailed\"\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Confirm the caller matches the controller stored against the document.\n\t * @param controller The controller making the request.\n\t * @param identityDocument The stored entity to check against.\n\t * @throws UnauthorizedError if the caller is not the stored controller.\n\t * @internal\n\t */\n\tprivate static assertController(controller: string, identityDocument: IdentityDocument): void {\n\t\tif (identityDocument.controller !== controller) {\n\t\t\tthrow new UnauthorizedError(EntityStorageIdentityConnector.CLASS_NAME, \"notController\", {\n\t\t\t\tdocumentId: identityDocument.id\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageIdentityConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Stop the service.\n\t * Destroys in-memory resources owned by this component.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t * @returns A promise that resolves when the service has stopped.\n\t */\n\tpublic async stop(nodeLoggingComponentType?: string): Promise<void> {\n\t\tthis._didResolutionCache?.destroy();\n\t}\n\n\t/**\n\t * Create a new document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns The created document.\n\t */\n\tpublic async createDocument(controller: string): Promise<IDidDocument> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\n\t\ttry {\n\t\t\tconst did = `did:${EntityStorageIdentityConnector.NAMESPACE}:${Converter.bytesToHex(RandomHelper.generate(32), true)}`;\n\n\t\t\tawait this._vaultConnector.createKey(\n\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(did, \"did\"),\n\t\t\t\tVaultKeyType.Ed25519\n\t\t\t);\n\n\t\t\tconst bitString = new BitString(EntityStorageIdentityConnector._REVOCATION_BITS_SIZE);\n\t\t\tconst compressed = await Compression.compress(bitString.getBits(), CompressionType.Gzip);\n\n\t\t\tconst didDocument: IDidDocument = {\n\t\t\t\t\"@context\": DidContexts.Context,\n\t\t\t\tid: did,\n\t\t\t\tservice: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${did}#revocation`,\n\t\t\t\t\t\ttype: \"BitstringStatusList\",\n\t\t\t\t\t\tserviceEndpoint: `data:application/octet-stream;base64,${Converter.bytesToBase64Url(compressed)}`\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t};\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\n\t\t\treturn didDocument;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createDocumentFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove a document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to remove.\n\t * @param options Optional settings.\n\t * @param options.removeKeys Also remove any associated private keys from the vault.\n\t * @returns A promise that resolves when the document has been removed.\n\t */\n\tpublic async removeDocument(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\toptions?: { removeKeys?: boolean }\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\n\t\ttry {\n\t\t\tconst didDocument = await this._didDocumentEntityStorage.get(documentId);\n\t\t\tif (Is.empty(didDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tdocumentId\n\t\t\t\t);\n\t\t\t}\n\t\t\tEntityStorageIdentityConnector.assertController(controller, didDocument);\n\n\t\t\tawait this._didDocumentEntityStorage.remove(documentId);\n\t\t\tthis._didResolutionCache?.delete(this.ownDidCacheKey(documentId));\n\n\t\t\tif (options?.removeKeys ?? false) {\n\t\t\t\tconst methods = this.getAllMethods(didDocument.document);\n\t\t\t\tfor (const { method } of methods) {\n\t\t\t\t\tconst methodId = Is.string(method) ? method : method.id;\n\t\t\t\t\tif (Is.stringValue(methodId)) {\n\t\t\t\t\t\tconst idParts = DocumentHelper.parseId(methodId);\n\t\t\t\t\t\tif (Is.stringValue(idParts.fragment)) {\n\t\t\t\t\t\t\tconst vaultKey = EntityStorageIdentityConnector.buildVaultKey(\n\t\t\t\t\t\t\t\tdocumentId,\n\t\t\t\t\t\t\t\tidParts.fragment\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (await this._vaultConnector.keyExists(vaultKey)) {\n\t\t\t\t\t\t\t\tawait this._vaultConnector.removeKey(vaultKey);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeDocumentFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Add a verification method to the document in JSON Web key Format.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to add the verification method to.\n\t * @param verificationMethodType The type of the verification method to add.\n\t * @param verificationMethodId The id of the verification method, if undefined uses the kid of the generated JWK.\n\t * @returns The verification method.\n\t * @throws NotFoundError if the id can not be resolved.\n\t * @throws NotSupportedError if the platform does not support multiple keys.\n\t */\n\tpublic async addVerificationMethod(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\tverificationMethodType: DidVerificationMethodType,\n\t\tverificationMethodId?: string\n\t): Promise<IDidDocumentVerificationMethod> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.arrayOneOf<DidVerificationMethodType>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodType),\n\t\t\tverificationMethodType,\n\t\t\tObject.values(DidVerificationMethodType)\n\t\t);\n\n\t\tlet tempKeyId;\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentForController(\n\t\t\t\tcontroller,\n\t\t\t\tdocumentId\n\t\t\t);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tlet methodKeyPublic;\n\t\t\tif (Is.stringValue(verificationMethodId)) {\n\t\t\t\t// If there is a verification method id, we will try to get the key from the vault.\n\t\t\t\ttry {\n\t\t\t\t\t// If there is an existing key, we will use it.\n\t\t\t\t\tconst existingKey = await this._vaultConnector.getKey(\n\t\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, verificationMethodId),\n\t\t\t\t\t\t\"public\"\n\t\t\t\t\t);\n\t\t\t\t\tmethodKeyPublic = existingKey.publicKey;\n\t\t\t\t} catch {}\n\t\t\t}\n\n\t\t\tif (Is.empty(methodKeyPublic)) {\n\t\t\t\t// If there is no existing key, we will create a new one with a temporary name.\n\t\t\t\ttempKeyId = `temp-vm-${Converter.bytesToBase64Url(RandomHelper.generate(16))}`;\n\t\t\t\tmethodKeyPublic = await this._vaultConnector.createKey(\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, tempKeyId),\n\t\t\t\t\tVaultKeyType.Ed25519\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst jwkParams: IJwk = {\n\t\t\t\talg: \"EdDSA\",\n\t\t\t\tkty: \"OKP\",\n\t\t\t\tcrv: \"Ed25519\",\n\t\t\t\tx: Converter.bytesToBase64Url(methodKeyPublic)\n\t\t\t};\n\n\t\t\tconst kid = await Jwk.generateKid(jwkParams);\n\n\t\t\tconst methodId = `${documentId}#${verificationMethodId ?? kid}`;\n\n\t\t\tif (Is.stringValue(tempKeyId)) {\n\t\t\t\t// If we created a temporary key, we will rename it to the final method id.\n\t\t\t\tawait this._vaultConnector.renameKey(\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, tempKeyId),\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, verificationMethodId ?? kid)\n\t\t\t\t);\n\t\t\t\ttempKeyId = undefined;\n\t\t\t}\n\n\t\t\tthis.removeMethodById(didDocument, methodId);\n\n\t\t\tconst didVerificationMethod: IDidDocumentVerificationMethod = {\n\t\t\t\tid: methodId,\n\t\t\t\tcontroller: documentId,\n\t\t\t\ttype: \"JsonWebKey2020\",\n\t\t\t\tpublicKeyJwk: {\n\t\t\t\t\t...jwkParams,\n\t\t\t\t\tkid\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tdidDocument[verificationMethodType] ??= [];\n\t\t\tdidDocument[verificationMethodType]?.push(didVerificationMethod);\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\n\t\t\treturn didVerificationMethod;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"addVerificationMethodFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t} finally {\n\t\t\tif (Is.stringValue(tempKeyId)) {\n\t\t\t\t// If we created a temporary key and it is still in use, we will remove it from the vault.\n\t\t\t\ttry {\n\t\t\t\t\tawait this._vaultConnector.removeKey(tempKeyId);\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Remove a verification method from the document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The id of the verification method.\n\t * @param options Optional settings.\n\t * @param options.removeKeys Also remove any associated private key from the vault.\n\t * @returns A promise that resolves when the verification method has been removed.\n\t * @throws NotFoundError if the id can not be resolved.\n\t * @throws NotSupportedError if the platform does not support multiple revocable keys.\n\t */\n\tpublic async removeVerificationMethod(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\toptions?: { removeKeys?: boolean }\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentForController(\n\t\t\t\tcontroller,\n\t\t\t\tidParts.id\n\t\t\t);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tif (!this.removeMethodById(didDocument, verificationMethodId)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"verificationMethodNotFound\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\n\t\t\tif (options?.removeKeys ?? false) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this._vaultConnector.removeKey(\n\t\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment)\n\t\t\t\t\t);\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeVerificationMethodFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Add a service to the document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to add the service to.\n\t * @param serviceId The id of the service.\n\t * @param serviceType The type of the service.\n\t * @param serviceEndpoint The endpoint for the service.\n\t * @returns The service.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async addService(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\tserviceId: string,\n\t\tserviceType: string | string[],\n\t\tserviceEndpoint: string | string[]\n\t): Promise<IDidService> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(serviceId), serviceId);\n\t\tif (Is.array(serviceType)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(serviceType),\n\t\t\t\tserviceType\n\t\t\t);\n\t\t} else {\n\t\t\tGuards.stringValue(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(serviceType),\n\t\t\t\tserviceType\n\t\t\t);\n\t\t}\n\t\tif (Is.array(serviceEndpoint)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(serviceEndpoint),\n\t\t\t\tserviceEndpoint\n\t\t\t);\n\t\t} else {\n\t\t\tGuards.stringValue(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(serviceEndpoint),\n\t\t\t\tserviceEndpoint\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentForController(\n\t\t\t\tcontroller,\n\t\t\t\tdocumentId\n\t\t\t);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tconst fullServiceId = serviceId.includes(\"#\") ? serviceId : `${documentId}#${serviceId}`;\n\n\t\t\tif (Is.array(didDocument.service)) {\n\t\t\t\tconst existingServiceIndex = didDocument.service.findIndex(s => s.id === fullServiceId);\n\t\t\t\tif (existingServiceIndex !== -1) {\n\t\t\t\t\tdidDocument.service?.splice(existingServiceIndex, 1);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst didService: IDidService = {\n\t\t\t\tid: fullServiceId,\n\t\t\t\ttype: serviceType,\n\t\t\t\tserviceEndpoint\n\t\t\t};\n\n\t\t\tdidDocument.service ??= [];\n\t\t\tdidDocument.service.push(didService);\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\n\t\t\treturn didService;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"addServiceFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove a service from the document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param serviceId The id of the service.\n\t * @returns A promise that resolves when the service has been removed.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async removeService(controller: string, serviceId: string): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(serviceId), serviceId);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(serviceId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, \"missingDid\", serviceId);\n\t\t\t}\n\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentForController(\n\t\t\t\tcontroller,\n\t\t\t\tidParts.id\n\t\t\t);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tif (Is.array(didDocument.service)) {\n\t\t\t\tconst existingServiceIndex = didDocument.service.findIndex(s => s.id === serviceId);\n\t\t\t\tif (existingServiceIndex !== -1) {\n\t\t\t\t\tdidDocument.service?.splice(existingServiceIndex, 1);\n\t\t\t\t\tif (didDocument.service?.length === 0) {\n\t\t\t\t\t\tdelete didDocument.service;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\t\"serviceNotFound\",\n\t\t\t\t\t\tserviceId\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"serviceNotFound\",\n\t\t\t\t\tserviceId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeServiceFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Add an alias to the alsoKnownAs property on the document.\n\t * If the alias is already present the operation is a no-op.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to update.\n\t * @param alias The alias to add. Must be a Url or Urn (typically another DID).\n\t * @returns A promise that resolves when the alias has been added.\n\t * @throws GeneralError if the alias is not a Url or Urn.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async addAlsoKnownAs(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\talias: string\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(alias), alias);\n\t\tif (!Url.tryParseExact(alias) && !Urn.tryParseExact(alias)) {\n\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"invalidAlias\", { alias });\n\t\t}\n\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentForController(\n\t\t\t\tcontroller,\n\t\t\t\tdocumentId\n\t\t\t);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tconst existing = Is.array(didDocument.alsoKnownAs) ? didDocument.alsoKnownAs : [];\n\t\t\tif (existing.includes(alias)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdidDocument.alsoKnownAs = [...existing, alias];\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"addAlsoKnownAsFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove an alias from the alsoKnownAs property on the document.\n\t * If the alias is not present the operation is a no-op.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to update.\n\t * @param alias The alias to remove. Must be a Url or Urn.\n\t * @returns A promise that resolves when the alias has been removed.\n\t * @throws GeneralError if the alias is not a Url or Urn.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async removeAlsoKnownAs(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\talias: string\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(alias), alias);\n\t\tif (!Url.tryParseExact(alias) && !Urn.tryParseExact(alias)) {\n\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"invalidAlias\", { alias });\n\t\t}\n\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentForController(\n\t\t\t\tcontroller,\n\t\t\t\tdocumentId\n\t\t\t);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tif (!Is.array(didDocument.alsoKnownAs) || !didDocument.alsoKnownAs.includes(alias)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst filtered = didDocument.alsoKnownAs.filter(a => a !== alias);\n\t\t\tif (filtered.length === 0) {\n\t\t\t\tdelete didDocument.alsoKnownAs;\n\t\t\t} else {\n\t\t\t\tdidDocument.alsoKnownAs = filtered;\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeAlsoKnownAsFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a verifiable credential for a verification method.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param id The id of the credential.\n\t * @param subject The credential subject to store in the verifiable credential.\n\t * @param options Additional options for creating the verifiable credential.\n\t * @param options.revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.\n\t * @param options.expirationDate The date the verifiable credential is valid until.\n\t * @param options.jwtHeaderFields Additional fields to add to the JWT header.\n\t * @param options.jwtPayloadFields Additional fields to add to the JWT payload.\n\t * @returns The created verifiable credential and its token.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async createVerifiableCredential(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\tid: string | undefined,\n\t\tsubject: IJsonLdNodeObject,\n\t\toptions?: {\n\t\t\trevocationIndex?: number;\n\t\t\texpirationDate?: Date;\n\t\t\tjwtHeaderFields?: { [id: string]: string };\n\t\t\tjwtPayloadFields?: { [id: string]: string };\n\t\t}\n\t): Promise<{\n\t\tverifiableCredential: IDidVerifiableCredentialV1;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(subject),\n\t\t\tsubject\n\t\t);\n\t\tif (!Is.undefined(options?.revocationIndex)) {\n\t\t\tGuards.number(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(options.revocationIndex),\n\t\t\t\toptions.revocationIndex\n\t\t\t);\n\t\t\t// An index outside the bitmap would be accepted here and then throw on every later\n\t\t\t// revocation check, so it is rejected while the credential can still be reissued.\n\t\t\tif (\n\t\t\t\toptions.revocationIndex < 0 ||\n\t\t\t\toptions.revocationIndex >= EntityStorageIdentityConnector._REVOCATION_BITS_SIZE\n\t\t\t) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"revocationIndexOutOfRange\",\n\t\t\t\t\t{\n\t\t\t\t\t\trevocationIndex: options.revocationIndex,\n\t\t\t\t\t\tmaxIndex: EntityStorageIdentityConnector._REVOCATION_BITS_SIZE - 1\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (!Is.undefined(options?.expirationDate)) {\n\t\t\tGuards.date(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(options.expirationDate),\n\t\t\t\toptions.expirationDate\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst issuerIdentityDocument = await this.resolveOwnDocumentForController(\n\t\t\t\tcontroller,\n\t\t\t\tidParts.id\n\t\t\t);\n\t\t\tconst issuerDidDocument = issuerIdentityDocument.document;\n\n\t\t\tconst methods = this.getAllMethods(issuerDidDocument);\n\t\t\tconst methodAndArray = methods.find(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === verificationMethodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === verificationMethodId;\n\t\t\t});\n\n\t\t\tif (!methodAndArray) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"methodMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst verificationDidMethod = methodAndArray.method;\n\t\t\tif (!Is.stringValue(verificationDidMethod.publicKeyJwk?.x)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"publicKeyJwkMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst revocationService = issuerDidDocument.service?.find(s => s.id.endsWith(\"#revocation\"));\n\n\t\t\tconst subjectClone = ObjectHelper.clone(subject);\n\n\t\t\tconst credContext = ObjectHelper.extractProperty<IJsonLdContextDefinitionRoot>(subjectClone, [\n\t\t\t\t\"@context\"\n\t\t\t]);\n\t\t\tconst credId = ObjectHelper.extractProperty<string>(subjectClone, [\"@id\", \"id\"], false);\n\n\t\t\tconst verifiableCredential: IDidVerifiableCredentialV1 = {\n\t\t\t\t\"@context\": (JsonLdProcessor.combineContexts(DidContexts.ContextVCv1, credContext) ??\n\t\t\t\t\tDidContexts.ContextVCv1) as [typeof DidContexts.ContextVCv1],\n\t\t\t\tid,\n\t\t\t\ttype: DidTypes.VerifiableCredential,\n\t\t\t\tcredentialSubject: subjectClone,\n\t\t\t\tissuer: issuerDidDocument.id,\n\t\t\t\tissuanceDate: new Date(Date.now()).toISOString(),\n\t\t\t\texpirationDate: Is.date(options?.expirationDate)\n\t\t\t\t\t? options?.expirationDate.toISOString()\n\t\t\t\t\t: undefined,\n\t\t\t\tcredentialStatus:\n\t\t\t\t\trevocationService && !Is.undefined(options?.revocationIndex)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tid: revocationService.id,\n\t\t\t\t\t\t\t\ttype: Is.array(revocationService.type)\n\t\t\t\t\t\t\t\t\t? revocationService.type[0]\n\t\t\t\t\t\t\t\t\t: revocationService.type,\n\t\t\t\t\t\t\t\trevocationBitmapIndex: options.revocationIndex.toString()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined\n\t\t\t};\n\n\t\t\tconst jwtHeader: IJwtHeader = {\n\t\t\t\t...options?.jwtHeaderFields,\n\t\t\t\tkid: verificationDidMethod.id,\n\t\t\t\ttyp: \"JWT\",\n\t\t\t\talg: JwsAlgorithms.EdDSA\n\t\t\t};\n\n\t\t\tconst jwtVc = ObjectHelper.pick(ObjectHelper.clone(verifiableCredential), [\n\t\t\t\t\"@context\",\n\t\t\t\t\"type\",\n\t\t\t\t\"credentialSubject\",\n\t\t\t\t\"credentialStatus\"\n\t\t\t]);\n\n\t\t\t// Add the proof to the VC after extracting the jwt data\n\t\t\t// as the jwt does not include the proof\n\t\t\tverifiableCredential.proof = await this.buildProof(\n\t\t\t\tissuerDidDocument,\n\t\t\t\tverificationMethodId,\n\t\t\t\tProofTypes.DataIntegrityProof,\n\t\t\t\tJsonLdHelper.toNodeObject(verifiableCredential)\n\t\t\t);\n\n\t\t\t// As we are adding the receipt to the data we update the JSON-LD context\n\t\t\tconst proofContext = verifiableCredential.proof[\"@context\"];\n\t\t\tif (Is.notEmpty(proofContext)) {\n\t\t\t\tverifiableCredential[\"@context\"] = (JsonLdProcessor.combineContexts(\n\t\t\t\t\tverifiableCredential[\"@context\"],\n\t\t\t\t\tproofContext\n\t\t\t\t) ?? verifiableCredential[\"@context\"]) as IDidVerifiableCredentialV1[\"@context\"];\n\t\t\t\tdelete verifiableCredential.proof[\"@context\"];\n\t\t\t}\n\n\t\t\tif (Is.array(jwtVc.credentialSubject)) {\n\t\t\t\tjwtVc.credentialSubject = jwtVc.credentialSubject.map(c => {\n\t\t\t\t\tObjectHelper.propertyDelete(c, \"id\");\n\t\t\t\t\treturn c;\n\t\t\t\t});\n\t\t\t} else if (Is.object(jwtVc.credentialSubject)) {\n\t\t\t\tObjectHelper.propertyDelete(jwtVc.credentialSubject, \"id\");\n\t\t\t}\n\n\t\t\tconst jwtPayload: IJwtPayload = {\n\t\t\t\t...options?.jwtPayloadFields,\n\t\t\t\tiss: idParts.id,\n\t\t\t\tnbf: Math.floor(Date.now() / 1000),\n\t\t\t\tjti: verifiableCredential.id,\n\t\t\t\tsub: credId,\n\t\t\t\tvc: jwtVc\n\t\t\t};\n\n\t\t\tif (Is.date(options?.expirationDate)) {\n\t\t\t\tjwtPayload.exp = Math.floor(options.expirationDate.getTime() / 1000);\n\t\t\t}\n\n\t\t\tconst signature = await Jwt.encodeWithSigner(jwtHeader, jwtPayload, async (header, payload) =>\n\t\t\t\tVaultConnectorHelper.jwtSigner(\n\t\t\t\t\tthis._vaultConnector,\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment ?? \"\"),\n\t\t\t\t\theader,\n\t\t\t\t\tpayload\n\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tverifiableCredential,\n\t\t\t\tjwt: signature\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createVerifiableCredentialFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Check a verifiable credential is valid.\n\t * @param credential The credential to verify.\n\t * @returns The credential stored in the jwt and the revocation status.\n\t */\n\tpublic async checkVerifiableCredential(credential: string | IDidVerifiableCredential): Promise<{\n\t\trevoked: boolean;\n\t\tverifiableCredential?: IDidVerifiableCredential;\n\t}> {\n\t\tif (Is.object(credential)) {\n\t\t\tGuards.objectValue<IDidVerifiableCredential>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(credential),\n\t\t\t\tcredential\n\t\t\t);\n\t\t\tGuards.objectValue<IDidVerifiableCredential>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(credential.proof),\n\t\t\t\tcredential.proof\n\t\t\t);\n\t\t\tVerificationHelper.checkValidityPeriod(credential);\n\n\t\t\tconst { proof, ...doc } = credential;\n\t\t\tconst proofEntry = ArrayHelper.fromObjectOrArray(proof)[0];\n\t\t\tGuards.stringValue(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(proofEntry.verificationMethod),\n\t\t\t\tproofEntry.verificationMethod\n\t\t\t);\n\n\t\t\tconst issuer = Is.object<{ id: string }>(doc.issuer) ? doc.issuer.id : doc.issuer;\n\t\t\tconst signerDid = DocumentHelper.parseId(proofEntry.verificationMethod).id;\n\t\t\tif (Is.stringValue(issuer) && issuer !== signerDid) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"issuerMismatch\", {\n\t\t\t\t\tissuer,\n\t\t\t\t\tmethod: proofEntry.verificationMethod\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst issuerDidDocument = await this.resolveAssertionMethodDocument(\n\t\t\t\tproofEntry.verificationMethod\n\t\t\t);\n\t\t\tconst publicKeyJwk = DocumentHelper.getJwk(\n\t\t\t\tissuerDidDocument,\n\t\t\t\tproofEntry.verificationMethod,\n\t\t\t\tDidVerificationMethodType.AssertionMethod\n\t\t\t);\n\n\t\t\tconst credentialVerified = await ProofHelper.verifyProof(\n\t\t\t\tJsonLdHelper.toNodeObject(doc),\n\t\t\t\tproofEntry,\n\t\t\t\tpublicKeyJwk\n\t\t\t);\n\t\t\tif (!credentialVerified) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"signatureVerificationFailed\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst revoked = await this.checkCredentialStatusRevoked(\n\t\t\t\tissuerDidDocument,\n\t\t\t\tdoc.credentialStatus\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\trevoked,\n\t\t\t\tverifiableCredential: revoked ? undefined : doc\n\t\t\t};\n\t\t}\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(credential), credential);\n\n\t\ttry {\n\t\t\tconst jwtDecoded = await Jwt.decode(credential);\n\n\t\t\tconst jwtHeader = jwtDecoded.header;\n\t\t\tconst jwtPayload = jwtDecoded.payload;\n\t\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\t\tif (\n\t\t\t\tIs.undefined(jwtHeader) ||\n\t\t\t\tIs.undefined(jwtPayload) ||\n\t\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\t\tIs.undefined(jwtSignature)\n\t\t\t) {\n\t\t\t\tthrow new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, \"jwkSignatureFailed\");\n\t\t\t}\n\n\t\t\tconst issuerDocumentId = jwtPayload.iss;\n\t\t\tconst issuerIdentityDocument = await this._didDocumentEntityStorage.get(issuerDocumentId);\n\t\t\tif (Is.undefined(issuerIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tissuerDocumentId\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tissuerIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\t\t\tconst issuerDidDocument = issuerIdentityDocument.document;\n\n\t\t\tGuards.stringValue(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(jwtHeader.kid),\n\t\t\t\tjwtHeader.kid\n\t\t\t);\n\t\t\tconst publicKeyJwk = DocumentHelper.getJwk(\n\t\t\t\tissuerDidDocument,\n\t\t\t\tjwtHeader.kid,\n\t\t\t\tDidVerificationMethodType.AssertionMethod\n\t\t\t);\n\n\t\t\tawait Jwt.verifySignature(credential, await Jwk.toCryptoKey(publicKeyJwk));\n\n\t\t\tconst verifiableCredential = jwtPayload.vc as IDidVerifiableCredentialV1;\n\t\t\tif (Is.object(verifiableCredential)) {\n\t\t\t\tif (Is.string(jwtPayload.jti)) {\n\t\t\t\t\tverifiableCredential.id = jwtPayload.jti;\n\t\t\t\t}\n\t\t\t\tverifiableCredential.issuer = issuerDocumentId;\n\t\t\t\tif (Is.number(jwtPayload.nbf)) {\n\t\t\t\t\tverifiableCredential.issuanceDate = new Date(jwtPayload.nbf * 1000).toISOString();\n\t\t\t\t}\n\t\t\t\tif (Is.number(jwtPayload.exp)) {\n\t\t\t\t\tverifiableCredential.expirationDate = new Date(jwtPayload.exp * 1000).toISOString();\n\t\t\t\t}\n\t\t\t\tif (Is.array(verifiableCredential.credentialSubject)) {\n\t\t\t\t\tverifiableCredential.credentialSubject = verifiableCredential.credentialSubject.map(c => {\n\t\t\t\t\t\tObjectHelper.propertySet(c, \"id\", jwtPayload.sub);\n\t\t\t\t\t\treturn c;\n\t\t\t\t\t});\n\t\t\t\t} else if (Is.object(verifiableCredential.credentialSubject)) {\n\t\t\t\t\tObjectHelper.propertySet(verifiableCredential.credentialSubject, \"id\", jwtPayload.sub);\n\t\t\t\t}\n\t\t\t}\n\t\t\tVerificationHelper.checkValidityPeriod(verifiableCredential);\n\n\t\t\tconst revoked = await this.checkCredentialStatusRevoked(\n\t\t\t\tissuerDidDocument,\n\t\t\t\tverifiableCredential.credentialStatus\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\trevoked,\n\t\t\t\tverifiableCredential: revoked ? undefined : verifiableCredential\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"checkingVerifiableCredentialFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Revoke verifiable credential(s).\n\t * @param controller The controller of the identity who can make changes.\n\t * @param issuerDocumentId The id of the document to update the revocation list for.\n\t * @param credentialIndices The revocation bitmap index or indices to revoke.\n\t * @returns A promise that resolves when the credentials have been revoked.\n\t */\n\tpublic async revokeVerifiableCredentials(\n\t\tcontroller: string,\n\t\tissuerDocumentId: string,\n\t\tcredentialIndices: number[]\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(issuerDocumentId),\n\t\t\tissuerDocumentId\n\t\t);\n\t\tGuards.arrayValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(credentialIndices),\n\t\t\tcredentialIndices\n\t\t);\n\n\t\ttry {\n\t\t\tconst issuerIdentityDocument = await this.resolveOwnDocumentForController(\n\t\t\t\tcontroller,\n\t\t\t\tissuerDocumentId\n\t\t\t);\n\t\t\tconst issuerDidDocument = issuerIdentityDocument.document;\n\n\t\t\tconst revocationService = issuerDidDocument.service?.find(s => s.id.endsWith(\"#revocation\"));\n\t\t\tif (\n\t\t\t\trevocationService &&\n\t\t\t\tIs.string(revocationService.serviceEndpoint) &&\n\t\t\t\trevocationService.type === \"BitstringStatusList\"\n\t\t\t) {\n\t\t\t\tconst revocationParts = revocationService.serviceEndpoint.split(\",\");\n\t\t\t\tif (revocationParts.length === 2) {\n\t\t\t\t\tconst compressedRevocationBytes = Converter.base64UrlToBytes(revocationParts[1]);\n\t\t\t\t\tconst decompressed = await Compression.decompress(\n\t\t\t\t\t\tcompressedRevocationBytes,\n\t\t\t\t\t\tCompressionType.Gzip\n\t\t\t\t\t);\n\n\t\t\t\t\tconst bitString = BitString.fromBits(\n\t\t\t\t\t\tdecompressed,\n\t\t\t\t\t\tEntityStorageIdentityConnector._REVOCATION_BITS_SIZE\n\t\t\t\t\t);\n\n\t\t\t\t\tfor (const credentialIndex of credentialIndices) {\n\t\t\t\t\t\tbitString.setBit(credentialIndex, true);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst compressed = await Compression.compress(bitString.getBits(), CompressionType.Gzip);\n\t\t\t\t\trevocationService.serviceEndpoint = `data:application/octet-stream;base64,${Converter.bytesToBase64Url(compressed)}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, issuerDidDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"revokeVerifiableCredentialsFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Unrevoke verifiable credential(s).\n\t * @param controller The controller of the identity who can make changes.\n\t * @param issuerDocumentId The id of the document to update the revocation list for.\n\t * @param credentialIndices The revocation bitmap index or indices to un revoke.\n\t * @returns A promise that resolves when the credentials have been unrevoked.\n\t */\n\tpublic async unrevokeVerifiableCredentials(\n\t\tcontroller: string,\n\t\tissuerDocumentId: string,\n\t\tcredentialIndices: number[]\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(issuerDocumentId),\n\t\t\tissuerDocumentId\n\t\t);\n\t\tGuards.arrayValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(credentialIndices),\n\t\t\tcredentialIndices\n\t\t);\n\n\t\ttry {\n\t\t\tconst issuerIdentityDocument = await this.resolveOwnDocumentForController(\n\t\t\t\tcontroller,\n\t\t\t\tissuerDocumentId\n\t\t\t);\n\t\t\tconst issuerDidDocument = issuerIdentityDocument.document;\n\n\t\t\tconst revocationService = issuerDidDocument.service?.find(s => s.id.endsWith(\"#revocation\"));\n\t\t\tif (\n\t\t\t\trevocationService &&\n\t\t\t\tIs.string(revocationService.serviceEndpoint) &&\n\t\t\t\trevocationService.type === \"BitstringStatusList\"\n\t\t\t) {\n\t\t\t\tconst revocationParts = revocationService.serviceEndpoint.split(\",\");\n\t\t\t\tif (revocationParts.length === 2) {\n\t\t\t\t\tconst compressedRevocationBytes = Converter.base64UrlToBytes(revocationParts[1]);\n\t\t\t\t\tconst decompressed = await Compression.decompress(\n\t\t\t\t\t\tcompressedRevocationBytes,\n\t\t\t\t\t\tCompressionType.Gzip\n\t\t\t\t\t);\n\n\t\t\t\t\tconst bitString = BitString.fromBits(\n\t\t\t\t\t\tdecompressed,\n\t\t\t\t\t\tEntityStorageIdentityConnector._REVOCATION_BITS_SIZE\n\t\t\t\t\t);\n\n\t\t\t\t\tfor (const credentialIndex of credentialIndices) {\n\t\t\t\t\t\tbitString.setBit(credentialIndex, false);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst compressed = await Compression.compress(bitString.getBits(), CompressionType.Gzip);\n\t\t\t\t\trevocationService.serviceEndpoint = `data:application/octet-stream;base64,${Converter.bytesToBase64Url(compressed)}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, issuerDidDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"unrevokeVerifiableCredentialsFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a verifiable presentation from the supplied verifiable credentials.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The method to associate with the presentation.\n\t * @param presentationId The id of the presentation.\n\t * @param contexts The contexts for the data stored in the verifiable credential.\n\t * @param types The types for the data stored in the verifiable credential.\n\t * @param verifiableCredentials The credentials to use for creating the presentation in jwt format.\n\t * @param options Additional options for creating the verifiable presentation.\n\t * @param options.expirationDate The date the verifiable presentation is valid until.\n\t * @param options.jwtHeaderFields Additional fields to add to the JWT header.\n\t * @param options.jwtPayloadFields Additional fields to add to the JWT payload.\n\t * @returns The created verifiable presentation and its token.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async createVerifiablePresentation(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\tpresentationId: string | undefined,\n\t\tcontexts: IJsonLdContextDefinitionRoot | undefined,\n\t\ttypes: string | string[] | undefined,\n\t\tverifiableCredentials: (string | IDidVerifiableCredentialV1)[],\n\t\toptions?: {\n\t\t\texpirationDate?: Date;\n\t\t\tjwtHeaderFields?: { [id: string]: string };\n\t\t\tjwtPayloadFields?: { [id: string]: string };\n\t\t}\n\t): Promise<{\n\t\tverifiablePresentation: IDidVerifiablePresentationV1;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tif (Is.array(types)) {\n\t\t\tGuards.arrayValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(types), types);\n\t\t} else if (Is.string(types)) {\n\t\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(types), types);\n\t\t}\n\t\tGuards.arrayValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verifiableCredentials),\n\t\t\tverifiableCredentials\n\t\t);\n\t\tif (!Is.undefined(options?.expirationDate)) {\n\t\t\tGuards.date(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(options.expirationDate),\n\t\t\t\toptions.expirationDate\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst holderIdentityDocument = await this.resolveOwnDocumentForController(\n\t\t\t\tcontroller,\n\t\t\t\tidParts.id\n\t\t\t);\n\t\t\tconst holderDidDocument = holderIdentityDocument.document;\n\n\t\t\tconst methods = this.getAllMethods(holderDidDocument);\n\t\t\tconst methodAndArray = methods.find(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === verificationMethodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === verificationMethodId;\n\t\t\t});\n\n\t\t\tif (!methodAndArray) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"methodMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst didMethod = methodAndArray.method;\n\t\t\tif (!Is.stringValue(didMethod.publicKeyJwk?.x)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"publicKeyJwkMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst finalTypes: string[] = [DidTypes.VerifiablePresentation];\n\t\t\tif (Is.array(types)) {\n\t\t\t\tfinalTypes.push(...types);\n\t\t\t} else if (Is.stringValue(types)) {\n\t\t\t\tfinalTypes.push(types);\n\t\t\t}\n\n\t\t\tconst combinedContext =\n\t\t\t\tJsonLdProcessor.combineContexts(DidContexts.ContextVCv1, contexts) ??\n\t\t\t\tDidContexts.ContextVCv1;\n\n\t\t\tconst verifiablePresentation: IDidVerifiablePresentationV1 = {\n\t\t\t\t\"@context\": combinedContext as [typeof DidContexts.ContextVCv1],\n\t\t\t\tid: presentationId,\n\t\t\t\ttype: finalTypes,\n\t\t\t\tverifiableCredential: verifiableCredentials,\n\t\t\t\tholder: idParts.id\n\t\t\t};\n\n\t\t\tconst jwtHeader: IJwtHeader = {\n\t\t\t\t...options?.jwtHeaderFields,\n\t\t\t\tkid: didMethod.id,\n\t\t\t\ttyp: \"JWT\",\n\t\t\t\talg: JwsAlgorithms.EdDSA\n\t\t\t};\n\n\t\t\tconst jwtVp = ObjectHelper.pick(ObjectHelper.clone(verifiablePresentation), [\n\t\t\t\t\"@context\",\n\t\t\t\t\"type\",\n\t\t\t\t\"verifiableCredential\"\n\t\t\t]);\n\n\t\t\t// Add the proof to the VP after extracting the jwt data\n\t\t\t// as the jwt does not include the proof\n\t\t\tverifiablePresentation.proof = await this.buildProof(\n\t\t\t\tholderDidDocument,\n\t\t\t\tverificationMethodId,\n\t\t\t\tProofTypes.DataIntegrityProof,\n\t\t\t\tJsonLdHelper.toNodeObject(verifiablePresentation)\n\t\t\t);\n\n\t\t\tconst jwtPayload: IJwtPayload = {\n\t\t\t\t...options?.jwtPayloadFields,\n\t\t\t\tiss: verifiablePresentation.holder,\n\t\t\t\tnbf: Math.floor(Date.now() / 1000),\n\t\t\t\tvp: jwtVp\n\t\t\t};\n\n\t\t\tif (Is.date(options?.expirationDate)) {\n\t\t\t\tjwtPayload.exp = Math.floor(options.expirationDate.getTime() / 1000);\n\t\t\t}\n\n\t\t\tconst signature = await Jwt.encodeWithSigner(jwtHeader, jwtPayload, async (header, payload) =>\n\t\t\t\tVaultConnectorHelper.jwtSigner(\n\t\t\t\t\tthis._vaultConnector,\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment ?? \"\"),\n\t\t\t\t\theader,\n\t\t\t\t\tpayload\n\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tverifiablePresentation,\n\t\t\t\tjwt: signature\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createVerifiablePresentationFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Check a verifiable presentation is valid.\n\t * @param presentation The presentation to verify.\n\t * @returns The presentation stored in the jwt and the revocation status.\n\t */\n\tpublic async checkVerifiablePresentation(\n\t\tpresentation: string | IDidVerifiablePresentation\n\t): Promise<{\n\t\trevoked: boolean;\n\t\tverifiablePresentation?: IDidVerifiablePresentationV1;\n\t\tissuers?: IDidDocument[];\n\t}> {\n\t\tif (Is.object(presentation)) {\n\t\t\tconst { proof, ...doc } = presentation as IDidVerifiablePresentationV1;\n\t\t\tconst proofEntry = ArrayHelper.fromObjectOrArray(proof)[0];\n\t\t\tGuards.objectValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(proofEntry), proofEntry);\n\t\t\tGuards.stringValue(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(proofEntry.verificationMethod),\n\t\t\t\tproofEntry.verificationMethod\n\t\t\t);\n\n\t\t\tconst signerDid = DocumentHelper.parseId(proofEntry.verificationMethod).id;\n\t\t\tif (Is.stringValue(doc.holder) && doc.holder !== signerDid) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"holderMismatch\", {\n\t\t\t\t\tholder: doc.holder,\n\t\t\t\t\tmethod: proofEntry.verificationMethod\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst presentationVerified = await this.verifyProof(\n\t\t\t\tJsonLdHelper.toNodeObject(doc),\n\t\t\t\tproofEntry\n\t\t\t);\n\t\t\tif (!presentationVerified) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"signatureVerificationFailed\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tlet revoked = false;\n\t\t\tfor (const embeddedCredential of doc.verifiableCredential ?? []) {\n\t\t\t\tconst credentialCheck = await this.checkVerifiableCredential(embeddedCredential);\n\t\t\t\tif (credentialCheck.revoked) {\n\t\t\t\t\trevoked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { revoked, verifiablePresentation: doc };\n\t\t}\n\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(presentation),\n\t\t\tpresentation\n\t\t);\n\n\t\tconst presentationJwt = presentation;\n\n\t\ttry {\n\t\t\tconst jwtDecoded = await Jwt.decode(presentationJwt);\n\n\t\t\tconst jwtHeader = jwtDecoded.header;\n\t\t\tconst jwtPayload = jwtDecoded.payload;\n\t\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\t\tif (\n\t\t\t\tIs.undefined(jwtHeader) ||\n\t\t\t\tIs.undefined(jwtPayload) ||\n\t\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\t\tIs.undefined(jwtSignature)\n\t\t\t) {\n\t\t\t\tthrow new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, \"jwkSignatureFailed\");\n\t\t\t}\n\n\t\t\tconst holderDocumentId = jwtPayload.iss;\n\t\t\tconst holderIdentityDocument = await this._didDocumentEntityStorage.get(holderDocumentId);\n\t\t\tif (Is.undefined(holderIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tholderDocumentId\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tholderIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\t\t\tconst holderDidDocument = holderIdentityDocument.document;\n\n\t\t\tGuards.stringValue(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(jwtHeader.kid),\n\t\t\t\tjwtHeader.kid\n\t\t\t);\n\n\t\t\t// Resolving the key from the holder's own document is what binds the signature to the\n\t\t\t// holder named by iss.\n\t\t\tconst publicKeyJwk = this.getMethodJwk(holderDidDocument, jwtHeader.kid);\n\n\t\t\tawait Jwt.verifySignature(presentationJwt, await Jwk.toCryptoKey(publicKeyJwk));\n\n\t\t\tconst issuers: IDidDocument[] = [];\n\t\t\tconst tokensRevoked: boolean[] = [];\n\t\t\tconst verifiablePresentation = jwtPayload?.vp as IDidVerifiablePresentationV1;\n\t\t\tif (Is.object<IDidVerifiablePresentationV1>(verifiablePresentation)) {\n\t\t\t\t// The holder is not carried in the vp claim, so restore it from the token issuer.\n\t\t\t\tverifiablePresentation.holder = holderDocumentId;\n\n\t\t\t\tif (Is.array(verifiablePresentation.verifiableCredential)) {\n\t\t\t\t\tfor (const embeddedCredential of verifiablePresentation.verifiableCredential) {\n\t\t\t\t\t\tconst issuerDocumentId = Is.stringValue(embeddedCredential)\n\t\t\t\t\t\t\t? (await Jwt.decode(embeddedCredential)).payload?.iss\n\t\t\t\t\t\t\t: this.getCredentialIssuer(embeddedCredential);\n\n\t\t\t\t\t\tif (Is.stringValue(issuerDocumentId)) {\n\t\t\t\t\t\t\tconst issuerDidDocument = await this._didDocumentEntityStorage.get(issuerDocumentId);\n\t\t\t\t\t\t\tif (Is.undefined(issuerDidDocument)) {\n\t\t\t\t\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\t\t\t\t\tissuerDocumentId\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\t\t\t\t\tissuerDidDocument,\n\t\t\t\t\t\t\t\tthis._vaultConnector\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tissuers.push({\n\t\t\t\t\t\t\t\t\"@context\": DidContexts.Context,\n\t\t\t\t\t\t\t\t...issuerDidDocument\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst credentialCheck = await this.checkVerifiableCredential(embeddedCredential);\n\t\t\t\t\t\ttokensRevoked.push(credentialCheck.revoked);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\trevoked: tokensRevoked.some(Boolean),\n\t\t\t\tverifiablePresentation,\n\t\t\t\tissuers\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (BaseError.isErrorMessage(error, /revoked/i)) {\n\t\t\t\treturn {\n\t\t\t\t\trevoked: true\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"checkingVerifiablePresentationFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a proof for arbitrary data with the specified verification method.\n\t * This method uses async signing to ensure the private key never leaves the vault,\n\t * with algorithm validation to ensure key type compatibility.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param proofType The type of proof to create.\n\t * @param unsecureDocument The unsecure document to create the proof for.\n\t * @returns The proof.\n\t * @throws NotFoundError if the identity or method is not found.\n\t * @throws UnauthorizedError if the caller is not the stored controller.\n\t * @throws GeneralError if algorithm doesn't match key type or proof creation fails.\n\t */\n\tpublic async createProof(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\tproofType: ProofTypes,\n\t\tunsecureDocument: IJsonLdNodeObject\n\t): Promise<IProof> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.arrayOneOf<ProofTypes>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(proofType),\n\t\t\tproofType,\n\t\t\tObject.values(ProofTypes)\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(unsecureDocument),\n\t\t\tunsecureDocument\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst identityDocument = await this.resolveOwnDocumentForController(controller, idParts.id);\n\n\t\t\treturn await this.buildProof(\n\t\t\t\tidentityDocument.document,\n\t\t\t\tverificationMethodId,\n\t\t\t\tproofType,\n\t\t\t\tunsecureDocument\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createProofFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Verify proof for arbitrary data with the specified verification method.\n\t * @param document The document to verify.\n\t * @param proof The proof to verify.\n\t * @returns True if the proof is verified.\n\t */\n\tpublic async verifyProof(document: IJsonLdNodeObject, proof: IProof): Promise<boolean> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(document),\n\t\t\tdocument\n\t\t);\n\t\tGuards.object<IProof>(EntityStorageIdentityConnector.CLASS_NAME, nameof(proof), proof);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(proof.verificationMethod),\n\t\t\tproof.verificationMethod\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(proof.verificationMethod);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tproof.verificationMethod\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst didIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);\n\t\t\tif (Is.undefined(didIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tidParts.id\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tdidIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tconst methods = this.getAllMethods(didDocument);\n\n\t\t\tconst methodAndArray = methods.find(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === proof.verificationMethod;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === proof.verificationMethod;\n\t\t\t});\n\n\t\t\tif (!methodAndArray) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"methodMissing\", {\n\t\t\t\t\tmethod: proof.verificationMethod\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst didMethod = methodAndArray.method;\n\t\t\tif (!Is.stringValue(didMethod.publicKeyJwk?.x)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"publicKeyJwkMissing\", {\n\t\t\t\t\tmethod: proof.verificationMethod\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst result = await ProofHelper.verifyProof(document, proof, didMethod.publicKeyJwk);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"verifyProofFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Build a proof against a document whose controller has already been verified by the caller.\n\t * @param didDocument The resolved DID document owning the verification method.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param proofType The type of proof to create.\n\t * @param unsecureDocument The unsecure document to create the proof for.\n\t * @returns The proof.\n\t * @throws GeneralError if the method or its key material is missing.\n\t * @internal\n\t */\n\tprivate async buildProof(\n\t\tdidDocument: IDidDocument,\n\t\tverificationMethodId: string,\n\t\tproofType: ProofTypes,\n\t\tunsecureDocument: IJsonLdNodeObject\n\t): Promise<IProof> {\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tthis.getMethodJwk(didDocument, verificationMethodId);\n\n\t\tconst vaultKey = EntityStorageIdentityConnector.buildVaultKey(\n\t\t\tdidDocument.id,\n\t\t\tidParts.fragment ?? \"\"\n\t\t);\n\t\tconst keyType = await this._vaultConnector.getKeyType(vaultKey);\n\n\t\tif (Is.undefined(keyType)) {\n\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"privateKeyMissing\", {\n\t\t\t\tkeyId: vaultKey\n\t\t\t});\n\t\t}\n\n\t\tconst unsignedProof = ProofHelper.createUnsignedProof(proofType, verificationMethodId);\n\n\t\treturn ProofHelper.createProofWithSigner(\n\t\t\tproofType,\n\t\t\tunsecureDocument,\n\t\t\tunsignedProof,\n\t\t\tasync (data, algorithm) => this.signWithVault(vaultKey, keyType, data, algorithm)\n\t\t);\n\t}\n\n\t/**\n\t * Signs data using the vault connector with algorithm validation.\n\t * @param vaultKey The vault key identifier.\n\t * @param keyType The type of the key.\n\t * @param data The data to sign.\n\t * @param algorithm The signing algorithm.\n\t * @returns The signature bytes.\n\t * @throws GeneralError if algorithm doesn't match key type.\n\t * @internal\n\t */\n\tprivate async signWithVault(\n\t\tvaultKey: string,\n\t\tkeyType: VaultKeyType,\n\t\tdata: Uint8Array,\n\t\talgorithm: string\n\t): Promise<Uint8Array> {\n\t\tif (algorithm === JwsAlgorithms.EdDSA && keyType !== VaultKeyType.Ed25519) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"algorithmKeyTypeMismatch\",\n\t\t\t\t{\n\t\t\t\t\talgorithm,\n\t\t\t\t\texpectedKeyType: VaultKeyType.Ed25519,\n\t\t\t\t\tactualKeyType: keyType,\n\t\t\t\t\tkeyId: vaultKey\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t\treturn this._vaultConnector.sign(vaultKey, data);\n\t}\n\n\t/**\n\t * Get all the methods from a document.\n\t * @param document The document to get the methods from.\n\t * @returns The methods.\n\t * @internal\n\t */\n\tprivate getAllMethods(\n\t\tdocument: IDidDocument\n\t): { arrayKey: string; method: Partial<IDidDocumentVerificationMethod> }[] {\n\t\tconst methods: {\n\t\t\tarrayKey: string;\n\t\t\tmethod: Partial<IDidDocumentVerificationMethod>;\n\t\t}[] = [];\n\n\t\tconst methodTypes: DidVerificationMethodType[] = Object.values(DidVerificationMethodType);\n\n\t\tfor (const methodType of methodTypes) {\n\t\t\tconst mt = document[methodType];\n\t\t\tif (Is.arrayValue(mt)) {\n\t\t\t\tmethods.push(\n\t\t\t\t\t...mt.map(m => ({\n\t\t\t\t\t\tarrayKey: methodType,\n\t\t\t\t\t\tmethod: Is.string(m) ? { id: m } : m\n\t\t\t\t\t}))\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn methods;\n\t}\n\n\t/**\n\t * Get the issuer DID from a credential in object form.\n\t * @param credential The credential to read.\n\t * @returns The issuer DID, or undefined if it has none.\n\t * @internal\n\t */\n\tprivate getCredentialIssuer(credential: IDidVerifiableCredential): string | undefined {\n\t\treturn Is.object<{ id: string }>(credential.issuer) ? credential.issuer.id : credential.issuer;\n\t}\n\n\t/**\n\t * Remove a verification method from whichever relationship holds it.\n\t * The relationship arrays are searched individually, because an index taken from the flat list\n\t * getAllMethods returns does not address the per-relationship array it came from.\n\t * @param didDocument The document to update.\n\t * @param verificationMethodId The full id of the method to remove.\n\t * @returns True if the method was found and removed.\n\t * @internal\n\t */\n\tprivate removeMethodById(didDocument: IDidDocument, verificationMethodId: string): boolean {\n\t\tfor (const methodType of Object.values(DidVerificationMethodType)) {\n\t\t\tconst methodArray = didDocument[methodType];\n\t\t\tif (Is.arrayValue(methodArray)) {\n\t\t\t\tconst index = methodArray.findIndex(\n\t\t\t\t\tm => (Is.string(m) ? m : m.id) === verificationMethodId\n\t\t\t\t);\n\t\t\t\tif (index !== -1) {\n\t\t\t\t\tmethodArray.splice(index, 1);\n\t\t\t\t\tif (methodArray.length === 0) {\n\t\t\t\t\t\tdelete didDocument[methodType];\n\t\t\t\t\t}\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Get the public key for a verification method from whichever relationship holds it.\n\t * getJwk looks in a single relationship, defaulting to verificationMethod, but a method is\n\t * only ever added to the relationship it was created under.\n\t * @param didDocument The document owning the method.\n\t * @param verificationMethodId The full id of the method.\n\t * @returns The public key.\n\t * @throws GeneralError if the method is not on the document or carries no public key.\n\t * @internal\n\t */\n\tprivate getMethodJwk(didDocument: IDidDocument, verificationMethodId: string): IJwk {\n\t\tconst methodType = Object.values(DidVerificationMethodType).find(type =>\n\t\t\tdidDocument[type]?.some(m => (Is.string(m) ? m : m.id) === verificationMethodId)\n\t\t);\n\n\t\treturn DocumentHelper.getJwk(didDocument, verificationMethodId, methodType);\n\t}\n\n\t/**\n\t * Resolve the issuer document for a verification method, verified against its stored signature.\n\t * @param verificationMethodId The verification method id whose owning DID to resolve.\n\t * @returns The resolved document.\n\t * @throws NotFoundError if the id has no DID, or the DID cannot be resolved.\n\t * @internal\n\t */\n\tprivate async resolveAssertionMethodDocument(\n\t\tverificationMethodId: string\n\t): Promise<IDidDocument> {\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\tif (Is.empty(idParts.fragment)) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"missingDid\",\n\t\t\t\tverificationMethodId\n\t\t\t);\n\t\t}\n\n\t\tconst identityDocument = await this._didDocumentEntityStorage.get(idParts.id);\n\t\tif (Is.undefined(identityDocument)) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"documentNotFound\",\n\t\t\t\tidParts.id\n\t\t\t);\n\t\t}\n\t\tawait EntityStorageIdentityConnector.verifyDocument(identityDocument, this._vaultConnector);\n\n\t\treturn identityDocument.document;\n\t}\n\n\t/**\n\t * Cache key for a DID resolved for this connector's own sign/mutate operations (role 1).\n\t * Deliberately namespaced (\"own\") and never shared with proof/credential verification of\n\t * third-party claims (role 2/3), which this connector never caches.\n\t * @param documentId The DID being resolved.\n\t * @returns The cache key.\n\t * @internal\n\t */\n\tprivate ownDidCacheKey(documentId: string): string {\n\t\treturn `${EntityStorageIdentityConnector.CLASS_NAME}:own:${documentId}`;\n\t}\n\n\t/**\n\t * Load and verify a document's own storage entity, uncached.\n\t * @param documentId The DID to load.\n\t * @returns The verified storage entity.\n\t * @throws NotFoundError if the DID could not be resolved.\n\t * @internal\n\t */\n\tprivate async loadOwnDocument(documentId: string): Promise<IdentityDocument> {\n\t\tconst identityDocument = await this._didDocumentEntityStorage.get(documentId);\n\t\tif (Is.undefined(identityDocument)) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"documentNotFound\",\n\t\t\t\tdocumentId\n\t\t\t);\n\t\t}\n\t\tawait EntityStorageIdentityConnector.verifyDocument(identityDocument, this._vaultConnector);\n\n\t\treturn identityDocument;\n\t}\n\n\t/**\n\t * Resolve a document's own storage entity for this connector's own sign/mutate operations,\n\t * cached for didResolutionCacheTtlMs (0 disables caching and resolves fresh every call).\n\t * Only ever used for the connector's own create/update/revoke paths - never for verifyProof\n\t * or credential/presentation verification, which must stay uncached.\n\t * A clone is always returned: mutators edit the entity in place before storing it, and the\n\t * cached instance must never be handed out by reference.\n\t * @param documentId The DID to resolve.\n\t * @returns The verified storage entity.\n\t * @throws NotFoundError if the DID could not be resolved.\n\t * @internal\n\t */\n\tprivate async resolveOwnDocumentCached(documentId: string): Promise<IdentityDocument> {\n\t\tif (Is.undefined(this._didResolutionCache)) {\n\t\t\treturn this.loadOwnDocument(documentId);\n\t\t}\n\n\t\tconst identityDocument = await this._didResolutionCache.getOrSet(\n\t\t\tthis.ownDidCacheKey(documentId),\n\t\t\tasync () => this.loadOwnDocument(documentId)\n\t\t);\n\t\treturn ObjectHelper.clone(identityDocument);\n\t}\n\n\t/**\n\t * Resolve a document's own storage entity and confirm the caller controls it.\n\t * @param controller The controller making the request.\n\t * @param documentId The DID to resolve.\n\t * @returns The verified storage entity.\n\t * @throws NotFoundError if the DID could not be resolved.\n\t * @throws UnauthorizedError if the caller is not the stored controller.\n\t * @internal\n\t */\n\tprivate async resolveOwnDocumentForController(\n\t\tcontroller: string,\n\t\tdocumentId: string\n\t): Promise<IdentityDocument> {\n\t\tconst identityDocument = await this.resolveOwnDocumentCached(documentId);\n\t\tEntityStorageIdentityConnector.assertController(controller, identityDocument);\n\t\treturn identityDocument;\n\t}\n\n\t/**\n\t * Check whether a credential's status entry or entries report it as revoked.\n\t * @param document The issuer document owning the revocation bitmap service.\n\t * @param credentialStatus The credential's status entry or entries to check.\n\t * @returns True if any entry is reported revoked.\n\t * @internal\n\t */\n\tprivate async checkCredentialStatusRevoked(\n\t\tdocument: IDidDocument,\n\t\tcredentialStatus: IDidCredentialStatus | IDidCredentialStatus[] | undefined\n\t): Promise<boolean> {\n\t\tlet statuses: IDidCredentialStatus[] = [];\n\t\tif (Is.array<IDidCredentialStatus>(credentialStatus)) {\n\t\t\tstatuses = credentialStatus;\n\t\t} else if (Is.object<IDidCredentialStatus>(credentialStatus)) {\n\t\t\tstatuses = [credentialStatus];\n\t\t}\n\n\t\tfor (const status of statuses) {\n\t\t\tif (await this.checkRevocation(document, status.revocationBitmapIndex)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Check if a revocation index is revoked.\n\t * @param document The document to check.\n\t * @param revocationBitmapIndex The revocation index to check.\n\t * @returns True if the index is revoked.\n\t * @internal\n\t */\n\tprivate async checkRevocation(\n\t\tdocument: IDidDocument,\n\t\trevocationBitmapIndex?: unknown\n\t): Promise<boolean> {\n\t\tconst revocationIndex = Coerce.number(revocationBitmapIndex);\n\t\tif (Is.number(revocationIndex)) {\n\t\t\tconst revocationService = document.service?.find(s => s.id.endsWith(\"#revocation\"));\n\t\t\tif (\n\t\t\t\trevocationService &&\n\t\t\t\tIs.string(revocationService.serviceEndpoint) &&\n\t\t\t\trevocationService.type === \"BitstringStatusList\"\n\t\t\t) {\n\t\t\t\tconst revocationParts = revocationService.serviceEndpoint.split(\",\");\n\t\t\t\tif (revocationParts.length === 2) {\n\t\t\t\t\tconst compressedRevocationBytes = Converter.base64UrlToBytes(revocationParts[1]);\n\t\t\t\t\tconst decompressed = await Compression.decompress(\n\t\t\t\t\t\tcompressedRevocationBytes,\n\t\t\t\t\t\tCompressionType.Gzip\n\t\t\t\t\t);\n\n\t\t\t\t\tconst bitString = BitString.fromBits(\n\t\t\t\t\t\tdecompressed,\n\t\t\t\t\t\tEntityStorageIdentityConnector._REVOCATION_BITS_SIZE\n\t\t\t\t\t);\n\n\t\t\t\t\treturn bitString.getBit(revocationIndex);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Update the document in storage.\n\t * @param controller The controller of the document.\n\t * @param didDocument The did document to store.\n\t * @returns A promise that resolves when the document has been signed and persisted.\n\t * @internal\n\t */\n\tprivate async updateDocument(controller: string, didDocument: IDidDocument): Promise<void> {\n\t\tconst stringifiedDocument = JsonHelper.canonicalize(didDocument);\n\t\tconst docBytes = Converter.utf8ToBytes(stringifiedDocument);\n\n\t\tconst signature = await this._vaultConnector.sign(\n\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, \"did\"),\n\t\t\tdocBytes\n\t\t);\n\n\t\tconst identityDocument: IdentityDocument = {\n\t\t\tid: didDocument.id,\n\t\t\tdocument: didDocument,\n\t\t\tsignature: Converter.bytesToBase64(signature),\n\t\t\tcontroller\n\t\t};\n\n\t\tawait this._didDocumentEntityStorage.set(identityDocument);\n\n\t\tthis._didResolutionCache?.set(\n\t\t\tthis.ownDidCacheKey(didDocument.id),\n\t\t\tObjectHelper.clone(identityDocument)\n\t\t);\n\t}\n}\n"]}
|
|
@@ -210,14 +210,12 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
|
|
|
210
210
|
* @param verificationMethodId The verification method id to use.
|
|
211
211
|
* @param proofType The type of proof to create.
|
|
212
212
|
* @param unsecureDocument The unsecure document to create the proof for.
|
|
213
|
-
* @param resolvedDocument Optional already-resolved document for the DID, so a caller that
|
|
214
|
-
* just resolved it (e.g. createVerifiableCredential) skips a redundant re-resolve. Resolves
|
|
215
|
-
* it itself if omitted.
|
|
216
213
|
* @returns The proof.
|
|
217
214
|
* @throws NotFoundError if the identity or method is not found.
|
|
215
|
+
* @throws UnauthorizedError if the caller is not the stored controller.
|
|
218
216
|
* @throws GeneralError if algorithm doesn't match key type or proof creation fails.
|
|
219
217
|
*/
|
|
220
|
-
createProof(controller: string, verificationMethodId: string, proofType: ProofTypes, unsecureDocument: IJsonLdNodeObject
|
|
218
|
+
createProof(controller: string, verificationMethodId: string, proofType: ProofTypes, unsecureDocument: IJsonLdNodeObject): Promise<IProof>;
|
|
221
219
|
/**
|
|
222
220
|
* Verify proof for arbitrary data with the specified verification method.
|
|
223
221
|
* @param document The document to verify.
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @twin.org/identity-connector-entity-storage- Changelog
|
|
2
2
|
|
|
3
|
+
## [0.10.1-next.3](https://github.com/iotaledger/twin-identity/compare/identity-connector-entity-storage-v0.10.1-next.2...identity-connector-entity-storage-v0.10.1-next.3) (2026-09-23)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* check vp holder ([#241](https://github.com/iotaledger/twin-identity/issues/241)) ([e752a45](https://github.com/iotaledger/twin-identity/commit/e752a45bd2949c4d9c9cc4882379304879f9ef45))
|
|
9
|
+
* identity controller check ([#240](https://github.com/iotaledger/twin-identity/issues/240)) ([6bb8bc4](https://github.com/iotaledger/twin-identity/commit/6bb8bc448d8fcd96280062eeb37abb08b2a28081))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Dependencies
|
|
13
|
+
|
|
14
|
+
* The following workspace dependencies were updated
|
|
15
|
+
* dependencies
|
|
16
|
+
* @twin.org/identity-models bumped from 0.10.1-next.2 to 0.10.1-next.3
|
|
17
|
+
|
|
3
18
|
## [0.10.1-next.2](https://github.com/iotaledger/twin-identity/compare/identity-connector-entity-storage-v0.10.1-next.1...identity-connector-entity-storage-v0.10.1-next.2) (2026-09-23)
|
|
4
19
|
|
|
5
20
|
|
|
@@ -731,7 +731,7 @@ The presentation stored in the jwt and the revocation status.
|
|
|
731
731
|
|
|
732
732
|
### createProof() {#createproof}
|
|
733
733
|
|
|
734
|
-
> **createProof**(`controller`, `verificationMethodId`, `proofType`, `unsecureDocument
|
|
734
|
+
> **createProof**(`controller`, `verificationMethodId`, `proofType`, `unsecureDocument`): `Promise`\<`IProof`\>
|
|
735
735
|
|
|
736
736
|
Create a proof for arbitrary data with the specified verification method.
|
|
737
737
|
This method uses async signing to ensure the private key never leaves the vault,
|
|
@@ -763,14 +763,6 @@ The type of proof to create.
|
|
|
763
763
|
|
|
764
764
|
The unsecure document to create the proof for.
|
|
765
765
|
|
|
766
|
-
##### resolvedDocument?
|
|
767
|
-
|
|
768
|
-
`IDidDocument`
|
|
769
|
-
|
|
770
|
-
Optional already-resolved document for the DID, so a caller that
|
|
771
|
-
just resolved it (e.g. createVerifiableCredential) skips a redundant re-resolve. Resolves
|
|
772
|
-
it itself if omitted.
|
|
773
|
-
|
|
774
766
|
#### Returns
|
|
775
767
|
|
|
776
768
|
`Promise`\<`IProof`\>
|
|
@@ -783,6 +775,10 @@ NotFoundError if the identity or method is not found.
|
|
|
783
775
|
|
|
784
776
|
#### Throws
|
|
785
777
|
|
|
778
|
+
UnauthorizedError if the caller is not the stored controller.
|
|
779
|
+
|
|
780
|
+
#### Throws
|
|
781
|
+
|
|
786
782
|
GeneralError if algorithm doesn't match key type or proof creation fails.
|
|
787
783
|
|
|
788
784
|
#### Implementation of
|
package/locales/en.json
CHANGED
|
@@ -16,17 +16,20 @@
|
|
|
16
16
|
"createVerifiableCredentialFailed": "Creating the verifiable credential failed",
|
|
17
17
|
"createVerifiablePresentationFailed": "Creating the verifiable presentation failed",
|
|
18
18
|
"documentNotFound": "The document could not be found \"{notFoundId}\"",
|
|
19
|
+
"holderMismatch": "The presentation holder \"{holder}\" does not match the DID of the proof verification method \"{method}\"",
|
|
19
20
|
"invalidAlias": "The alias is invalid it must be a Url or Urn, it is \"{alias}\"",
|
|
20
21
|
"issuerMismatch": "The credential issuer \"{issuer}\" does not match the DID of the proof verification method \"{method}\"",
|
|
21
22
|
"jwkSignatureFailed": "The signature on the JWK failed verification",
|
|
22
23
|
"methodMissing": "The verification method specified does not exist \"{method}\"",
|
|
23
24
|
"missingDid": "The full id including DID is required",
|
|
25
|
+
"notController": "Only the controller of the document can perform this action \"{documentId}\"",
|
|
24
26
|
"privateKeyMissing": "The private key could not be found for key \"{keyId}\"",
|
|
25
27
|
"publicKeyJwkMissing": "The verification method contains no publicKeyJwk in method \"{method}\"",
|
|
26
28
|
"removeAlsoKnownAsFailed": "Removing from the alsoKnownAs property failed",
|
|
27
29
|
"removeDocumentFailed": "Removing the document failed",
|
|
28
30
|
"removeServiceFailed": "Removing the service failed",
|
|
29
31
|
"removeVerificationMethodFailed": "Removing the verification method failed",
|
|
32
|
+
"revocationIndexOutOfRange": "The revocation index {revocationIndex} is outside the revocation bitmap, it must be between 0 and {maxIndex}",
|
|
30
33
|
"revokeVerifiableCredentialsFailed": "Revoking verifiable credentials failed",
|
|
31
34
|
"serviceNotFound": "The service could not be found",
|
|
32
35
|
"signatureVerificationFailed": "The document integrity check failed",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/identity-connector-entity-storage",
|
|
3
|
-
"version": "0.10.1-next.
|
|
3
|
+
"version": "0.10.1-next.3",
|
|
4
4
|
"description": "Entity storage connector for persisting and retrieving identity records through a consistent data layer.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@twin.org/data-json-ld": "next",
|
|
20
20
|
"@twin.org/entity": "next",
|
|
21
21
|
"@twin.org/entity-storage-models": "next",
|
|
22
|
-
"@twin.org/identity-models": "0.10.1-next.
|
|
22
|
+
"@twin.org/identity-models": "0.10.1-next.3",
|
|
23
23
|
"@twin.org/nameof": "next",
|
|
24
24
|
"@twin.org/standards-w3c-did": "next",
|
|
25
25
|
"@twin.org/vault-models": "next",
|