@twin.org/identity-connector-entity-storage 0.0.3-next.15 → 0.0.3-next.17
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 +43 -9
- package/dist/es/entityStorageIdentityConnector.js.map +1 -1
- package/dist/types/entityStorageIdentityConnector.d.ts +4 -0
- package/docs/changelog.md +28 -0
- package/docs/reference/classes/EntityStorageIdentityConnector.md +10 -0
- package/locales/en.json +18 -16
- package/package.json +2 -2
|
@@ -4,7 +4,7 @@ import { ArrayHelper, BaseError, BitString, Coerce, Compression, CompressionType
|
|
|
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 } from "@twin.org/identity-models";
|
|
7
|
-
import { DidContexts, DidTypes, DidVerificationMethodType, ProofHelper, ProofTypes } from "@twin.org/standards-w3c-did";
|
|
7
|
+
import { DidContexts, DidTypes, DidVerificationMethodType, JwsAlgorithms, ProofHelper, ProofTypes } from "@twin.org/standards-w3c-did";
|
|
8
8
|
import { VaultConnectorFactory, VaultConnectorHelper, VaultKeyType } from "@twin.org/vault-models";
|
|
9
9
|
import { Jwk, Jwt } from "@twin.org/web";
|
|
10
10
|
/**
|
|
@@ -414,7 +414,8 @@ export class EntityStorageIdentityConnector {
|
|
|
414
414
|
finalTypes.push(credType);
|
|
415
415
|
}
|
|
416
416
|
const verifiableCredential = {
|
|
417
|
-
"@context": JsonLdProcessor.combineContexts(DidContexts.ContextVCv1, credContext)
|
|
417
|
+
"@context": (JsonLdProcessor.combineContexts(DidContexts.ContextVCv1, credContext) ??
|
|
418
|
+
DidContexts.ContextVCv1),
|
|
418
419
|
id,
|
|
419
420
|
type: finalTypes,
|
|
420
421
|
credentialSubject: subjectClone,
|
|
@@ -436,7 +437,7 @@ export class EntityStorageIdentityConnector {
|
|
|
436
437
|
const jwtHeader = {
|
|
437
438
|
kid: verificationDidMethod.id,
|
|
438
439
|
typ: "JWT",
|
|
439
|
-
alg:
|
|
440
|
+
alg: JwsAlgorithms.EdDSA
|
|
440
441
|
};
|
|
441
442
|
const jwtVc = ObjectHelper.pick(ObjectHelper.clone(verifiableCredential), [
|
|
442
443
|
"@context",
|
|
@@ -450,7 +451,7 @@ export class EntityStorageIdentityConnector {
|
|
|
450
451
|
// As we are adding the receipt to the data we update the JSON-LD context
|
|
451
452
|
const proofContext = verifiableCredential.proof["@context"];
|
|
452
453
|
if (!Is.empty(proofContext)) {
|
|
453
|
-
verifiableCredential["@context"] = JsonLdProcessor.combineContexts(verifiableCredential["@context"], proofContext);
|
|
454
|
+
verifiableCredential["@context"] = (JsonLdProcessor.combineContexts(verifiableCredential["@context"], proofContext) ?? verifiableCredential["@context"]);
|
|
454
455
|
delete verifiableCredential.proof["@context"];
|
|
455
456
|
}
|
|
456
457
|
if (Is.array(jwtVc.credentialSubject)) {
|
|
@@ -719,8 +720,10 @@ export class EntityStorageIdentityConnector {
|
|
|
719
720
|
else if (Is.stringValue(types)) {
|
|
720
721
|
finalTypes.push(types);
|
|
721
722
|
}
|
|
723
|
+
const combinedContext = JsonLdProcessor.combineContexts(DidContexts.ContextVCv1, contexts) ??
|
|
724
|
+
DidContexts.ContextVCv1;
|
|
722
725
|
const verifiablePresentation = {
|
|
723
|
-
"@context":
|
|
726
|
+
"@context": combinedContext,
|
|
724
727
|
id: presentationId,
|
|
725
728
|
type: finalTypes,
|
|
726
729
|
verifiableCredential: verifiableCredentials,
|
|
@@ -729,7 +732,7 @@ export class EntityStorageIdentityConnector {
|
|
|
729
732
|
const jwtHeader = {
|
|
730
733
|
kid: didMethod.id,
|
|
731
734
|
typ: "JWT",
|
|
732
|
-
alg:
|
|
735
|
+
alg: JwsAlgorithms.EdDSA
|
|
733
736
|
};
|
|
734
737
|
const jwtVp = ObjectHelper.pick(ObjectHelper.clone(verifiablePresentation), [
|
|
735
738
|
"@context",
|
|
@@ -737,7 +740,7 @@ export class EntityStorageIdentityConnector {
|
|
|
737
740
|
"verifiableCredential"
|
|
738
741
|
]);
|
|
739
742
|
const jwtPayload = {
|
|
740
|
-
iss:
|
|
743
|
+
iss: verifiablePresentation.holder,
|
|
741
744
|
nbf: Math.floor(Date.now() / 1000),
|
|
742
745
|
vp: jwtVp
|
|
743
746
|
};
|
|
@@ -845,11 +848,15 @@ export class EntityStorageIdentityConnector {
|
|
|
845
848
|
}
|
|
846
849
|
/**
|
|
847
850
|
* Create a proof for arbitrary data with the specified verification method.
|
|
851
|
+
* This method uses async signing to ensure the private key never leaves the vault,
|
|
852
|
+
* with algorithm validation to ensure key type compatibility.
|
|
848
853
|
* @param controller The controller of the identity who can make changes.
|
|
849
854
|
* @param verificationMethodId The verification method id to use.
|
|
850
855
|
* @param proofType The type of proof to create.
|
|
851
856
|
* @param unsecureDocument The unsecure document to create the proof for.
|
|
852
857
|
* @returns The proof.
|
|
858
|
+
* @throws NotFoundError if the identity or method is not found.
|
|
859
|
+
* @throws GeneralError if algorithm doesn't match key type or proof creation fails.
|
|
853
860
|
*/
|
|
854
861
|
async createProof(controller, verificationMethodId, proofType, unsecureDocument) {
|
|
855
862
|
Guards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, "controller", controller);
|
|
@@ -886,8 +893,14 @@ export class EntityStorageIdentityConnector {
|
|
|
886
893
|
});
|
|
887
894
|
}
|
|
888
895
|
const vaultKey = EntityStorageIdentityConnector.buildVaultKey(didDocument.id, idParts.fragment ?? "");
|
|
889
|
-
const
|
|
890
|
-
|
|
896
|
+
const keyType = await this._vaultConnector.getKeyType(vaultKey);
|
|
897
|
+
if (Is.undefined(keyType)) {
|
|
898
|
+
throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "privateKeyMissing", {
|
|
899
|
+
keyId: vaultKey
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
const unsignedProof = ProofHelper.createUnsignedProof(proofType, verificationMethodId);
|
|
903
|
+
const signedProof = await ProofHelper.createProofWithSigner(proofType, unsecureDocument, unsignedProof, async (data, algorithm) => this.signWithVault(vaultKey, keyType, data, algorithm));
|
|
891
904
|
return signedProof;
|
|
892
905
|
}
|
|
893
906
|
catch (error) {
|
|
@@ -940,6 +953,27 @@ export class EntityStorageIdentityConnector {
|
|
|
940
953
|
throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "verifyProofFailed", undefined, error);
|
|
941
954
|
}
|
|
942
955
|
}
|
|
956
|
+
/**
|
|
957
|
+
* Signs data using the vault connector with algorithm validation.
|
|
958
|
+
* @param vaultKey The vault key identifier.
|
|
959
|
+
* @param keyType The type of the key.
|
|
960
|
+
* @param data The data to sign.
|
|
961
|
+
* @param algorithm The signing algorithm.
|
|
962
|
+
* @returns The signature bytes.
|
|
963
|
+
* @throws GeneralError if algorithm doesn't match key type.
|
|
964
|
+
* @internal
|
|
965
|
+
*/
|
|
966
|
+
async signWithVault(vaultKey, keyType, data, algorithm) {
|
|
967
|
+
if (algorithm === JwsAlgorithms.EdDSA && keyType !== VaultKeyType.Ed25519) {
|
|
968
|
+
throw new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, "algorithmKeyTypeMismatch", {
|
|
969
|
+
algorithm,
|
|
970
|
+
expectedKeyType: VaultKeyType.Ed25519,
|
|
971
|
+
actualKeyType: keyType,
|
|
972
|
+
keyId: vaultKey
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
return this._vaultConnector.sign(vaultKey, data);
|
|
976
|
+
}
|
|
943
977
|
/**
|
|
944
978
|
* Get all the methods from a document.
|
|
945
979
|
* @param document The document to get the methods from.
|
|
@@ -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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,UAAkB,EAAE,WAAyB;QACzE,MAAM,mBAAmB,GAAG,UAAU,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QACjE,MAAM,QAAQ,GAAG,SAAS,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;QAE5D,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CAChD,8BAA8B,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC,EACnE,QAAQ,CACR,CAAC;QAEF,MAAM,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC;YACxC,EAAE,EAAE,WAAW,CAAC,EAAE;YAClB,QAAQ,EAAE,WAAW;YACrB,SAAS,EAAE,SAAS,CAAC,aAAa,CAAC,SAAS,CAAC;YAC7C,UAAU;SACV,CAAC,CAAC;IACJ,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\tNotFoundError,\n\tObjectHelper,\n\tRandomHelper\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 { DocumentHelper, type IIdentityConnector } from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDidContexts,\n\tDidTypes,\n\tDidVerificationMethodType,\n\ttype IDidVerifiableCredential,\n\tProofHelper,\n\tProofTypes,\n\ttype IDidDocument,\n\ttype IDidDocumentVerificationMethod,\n\ttype IDidService,\n\ttype IDidVerifiableCredentialV1,\n\ttype IDidVerifiablePresentationV1,\n\ttype IProof\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 * 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\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 * @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 * @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 * 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 * @returns Nothing.\n\t */\n\tpublic async removeDocument(controller: string, documentId: string): 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} 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._didDocumentEntityStorage.get(documentId);\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\tdocumentId\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\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);\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: \"JsonWebKey\",\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 * @returns Nothing.\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): 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._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\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\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._didDocumentEntityStorage.get(documentId);\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\tdocumentId\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 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 Nothing.\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._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\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}\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 * 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 * @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}\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._didDocumentEntityStorage.get(idParts.id);\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\tidParts.id\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\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 finalTypes: string[] = [DidTypes.VerifiableCredential];\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\t\t\tconst credType = ObjectHelper.extractProperty<string>(subjectClone, [\"@type\", \"type\"]);\n\t\t\tif (Is.stringValue(credType)) {\n\t\t\t\tfinalTypes.push(credType);\n\t\t\t}\n\n\t\t\tconst verifiableCredential: IDidVerifiableCredentialV1 = {\n\t\t\t\t\"@context\": JsonLdProcessor.combineContexts(DidContexts.ContextVCv1, credContext) as [\n\t\t\t\t\ttypeof DidContexts.ContextVCv1\n\t\t\t\t],\n\t\t\t\tid,\n\t\t\t\ttype: finalTypes,\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\tkid: verificationDidMethod.id,\n\t\t\t\ttyp: \"JWT\",\n\t\t\t\talg: \"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);\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.empty(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) 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 {\n\t\t\t\tObjectHelper.propertyDelete(jwtVc.credentialSubject, \"id\");\n\t\t\t}\n\n\t\t\tconst jwtPayload: IJwtPayload = {\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\tconst { proof, ...doc } = credential;\n\t\t\tawait this.verifyProof(\n\t\t\t\tJsonLdHelper.toNodeObject(doc),\n\t\t\t\tArrayHelper.fromObjectOrArray(proof)[0]\n\t\t\t);\n\t\t\treturn {\n\t\t\t\trevoked: false,\n\t\t\t\tverifiableCredential: 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\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 === jwtHeader.kid;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === jwtHeader.kid;\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: jwtHeader.kid\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: jwtHeader.kid\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tawait Jwt.verifySignature(credential, await Jwk.toCryptoKey(didMethod.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.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\n\t\t\tconst credentialStatus = verifiableCredential.credentialStatus;\n\t\t\tlet revoked = false;\n\t\t\tif (Is.object(credentialStatus)) {\n\t\t\t\trevoked = await this.checkRevocation(\n\t\t\t\t\tissuerDidDocument,\n\t\t\t\t\tcredentialStatus.revocationBitmapIndex\n\t\t\t\t);\n\t\t\t} else if (Is.arrayValue(credentialStatus)) {\n\t\t\t\tfor (let i = 0; i < credentialStatus.length; i++) {\n\t\t\t\t\trevoked = await this.checkRevocation(\n\t\t\t\t\t\tissuerDidDocument,\n\t\t\t\t\t\tcredentialStatus[i].revocationBitmapIndex\n\t\t\t\t\t);\n\t\t\t\t\tif (revoked) {\n\t\t\t\t\t\tbreak;\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,\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 Nothing.\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._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\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 Nothing.\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._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\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 * @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}\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._didDocumentEntityStorage.get(idParts.id);\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\tidParts.id\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\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 verifiablePresentation: IDidVerifiablePresentationV1 = {\n\t\t\t\t\"@context\": JsonLdProcessor.combineContexts(DidContexts.ContextVCv1, contexts) as [\n\t\t\t\t\ttypeof DidContexts.ContextVCv1\n\t\t\t\t],\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\tkid: didMethod.id,\n\t\t\t\ttyp: \"JWT\",\n\t\t\t\talg: \"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\tconst jwtPayload: IJwtPayload = {\n\t\t\t\tiss: idParts.id,\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 presentationJwt The presentation to verify.\n\t * @returns The presentation stored in the jwt and the revocation status.\n\t */\n\tpublic async checkVerifiablePresentation(presentationJwt: string): Promise<{\n\t\trevoked: boolean;\n\t\tverifiablePresentation?: IDidVerifiablePresentationV1;\n\t\tissuers?: IDidDocument[];\n\t}> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(presentationJwt),\n\t\t\tpresentationJwt\n\t\t);\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 = true;\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\n\t\t\t\t\t\t\tconst vc = jwt.payload.vc as IDidVerifiableCredentialV1;\n\t\t\t\t\t\t\tif (Is.object<IDidVerifiableCredentialV1>(vc)) {\n\t\t\t\t\t\t\t\tconst credentialStatus = vc.credentialStatus;\n\t\t\t\t\t\t\t\tif (Is.object(credentialStatus)) {\n\t\t\t\t\t\t\t\t\trevoked = await this.checkRevocation(\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\"@context\": DidContexts.Context,\n\t\t\t\t\t\t\t\t\t\t\t...issuerDidDocument\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tcredentialStatus.revocationBitmapIndex\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} else if (Is.arrayValue(credentialStatus)) {\n\t\t\t\t\t\t\t\t\tfor (let i = 0; i < credentialStatus.length; i++) {\n\t\t\t\t\t\t\t\t\t\trevoked = await this.checkRevocation(\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\"@context\": DidContexts.Context,\n\t\t\t\t\t\t\t\t\t\t\t\t...issuerDidDocument\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\tcredentialStatus[i].revocationBitmapIndex\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\tif (revoked) {\n\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\trevoked = false;\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 * @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 */\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 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\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 key = await this._vaultConnector.getKey(vaultKey);\n\n\t\t\tconst signedProof = await ProofHelper.createProof(\n\t\t\t\tproofType,\n\t\t\t\tunsecureDocument,\n\t\t\t\tProofHelper.createUnsignedProof(proofType, verificationMethodId),\n\t\t\t\tawait Jwk.fromEd25519Private(key.privateKey)\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 * 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 * 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\tif (Is.stringValue(revocationBitmapIndex)) {\n\t\t\tconst revocationIndex = Coerce.number(revocationBitmapIndex);\n\t\t\tif (Is.number(revocationIndex)) {\n\t\t\t\tconst revocationService = document.service?.find(s => s.id.endsWith(\"#revocation\"));\n\t\t\t\tif (\n\t\t\t\t\trevocationService &&\n\t\t\t\t\tIs.string(revocationService.serviceEndpoint) &&\n\t\t\t\t\trevocationService.type === \"BitstringStatusList\"\n\t\t\t\t) {\n\t\t\t\t\tconst revocationParts = revocationService.serviceEndpoint.split(\",\");\n\t\t\t\t\tif (revocationParts.length === 2) {\n\t\t\t\t\t\tconst compressedRevocationBytes = Converter.base64UrlToBytes(revocationParts[1]);\n\t\t\t\t\t\tconst decompressed = await Compression.decompress(\n\t\t\t\t\t\t\tcompressedRevocationBytes,\n\t\t\t\t\t\t\tCompressionType.Gzip\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst bitString = BitString.fromBits(\n\t\t\t\t\t\t\tdecompressed,\n\t\t\t\t\t\t\tEntityStorageIdentityConnector._REVOCATION_BITS_SIZE\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn bitString.getBit(revocationIndex);\n\t\t\t\t\t}\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 * @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\tawait this._didDocumentEntityStorage.set({\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\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,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,YAAY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EAAE,WAAW;YACrB,SAAS,EAAE,SAAS,CAAC,aAAa,CAAC,SAAS,CAAC;YAC7C,UAAU;SACV,CAAC,CAAC;IACJ,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\tNotFoundError,\n\tObjectHelper,\n\tRandomHelper\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 { DocumentHelper, type IIdentityConnector } from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDidContexts,\n\tDidTypes,\n\tDidVerificationMethodType,\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} 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 * 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\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 * @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 * @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 * 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 * @returns Nothing.\n\t */\n\tpublic async removeDocument(controller: string, documentId: string): 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} 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._didDocumentEntityStorage.get(documentId);\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\tdocumentId\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\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);\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: \"JsonWebKey\",\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 * @returns Nothing.\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): 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._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\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\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._didDocumentEntityStorage.get(documentId);\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\tdocumentId\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 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 Nothing.\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._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\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}\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 * 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 * @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}\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._didDocumentEntityStorage.get(idParts.id);\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\tidParts.id\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\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 finalTypes: string[] = [DidTypes.VerifiableCredential];\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\t\t\tconst credType = ObjectHelper.extractProperty<string>(subjectClone, [\"@type\", \"type\"]);\n\t\t\tif (Is.stringValue(credType)) {\n\t\t\t\tfinalTypes.push(credType);\n\t\t\t}\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: finalTypes,\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\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);\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.empty(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 {\n\t\t\t\tObjectHelper.propertyDelete(jwtVc.credentialSubject, \"id\");\n\t\t\t}\n\n\t\t\tconst jwtPayload: IJwtPayload = {\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\tconst { proof, ...doc } = credential;\n\t\t\tawait this.verifyProof(\n\t\t\t\tJsonLdHelper.toNodeObject(doc),\n\t\t\t\tArrayHelper.fromObjectOrArray(proof)[0]\n\t\t\t);\n\t\t\treturn {\n\t\t\t\trevoked: false,\n\t\t\t\tverifiableCredential: 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\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 === jwtHeader.kid;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === jwtHeader.kid;\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: jwtHeader.kid\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: jwtHeader.kid\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tawait Jwt.verifySignature(credential, await Jwk.toCryptoKey(didMethod.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.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\n\t\t\tconst credentialStatus = verifiableCredential.credentialStatus;\n\t\t\tlet revoked = false;\n\t\t\tif (Is.object(credentialStatus)) {\n\t\t\t\trevoked = await this.checkRevocation(\n\t\t\t\t\tissuerDidDocument,\n\t\t\t\t\tcredentialStatus.revocationBitmapIndex\n\t\t\t\t);\n\t\t\t} else if (Is.arrayValue(credentialStatus)) {\n\t\t\t\tfor (let i = 0; i < credentialStatus.length; i++) {\n\t\t\t\t\trevoked = await this.checkRevocation(\n\t\t\t\t\t\tissuerDidDocument,\n\t\t\t\t\t\tcredentialStatus[i].revocationBitmapIndex\n\t\t\t\t\t);\n\t\t\t\t\tif (revoked) {\n\t\t\t\t\t\tbreak;\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,\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 Nothing.\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._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\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 Nothing.\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._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\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 * @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}\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._didDocumentEntityStorage.get(idParts.id);\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\tidParts.id\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\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\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\tconst jwtPayload: IJwtPayload = {\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 presentationJwt The presentation to verify.\n\t * @returns The presentation stored in the jwt and the revocation status.\n\t */\n\tpublic async checkVerifiablePresentation(presentationJwt: string): Promise<{\n\t\trevoked: boolean;\n\t\tverifiablePresentation?: IDidVerifiablePresentationV1;\n\t\tissuers?: IDidDocument[];\n\t}> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(presentationJwt),\n\t\t\tpresentationJwt\n\t\t);\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 = true;\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\n\t\t\t\t\t\t\tconst vc = jwt.payload.vc as IDidVerifiableCredentialV1;\n\t\t\t\t\t\t\tif (Is.object<IDidVerifiableCredentialV1>(vc)) {\n\t\t\t\t\t\t\t\tconst credentialStatus = vc.credentialStatus;\n\t\t\t\t\t\t\t\tif (Is.object(credentialStatus)) {\n\t\t\t\t\t\t\t\t\trevoked = await this.checkRevocation(\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\"@context\": DidContexts.Context,\n\t\t\t\t\t\t\t\t\t\t\t...issuerDidDocument\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tcredentialStatus.revocationBitmapIndex\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} else if (Is.arrayValue(credentialStatus)) {\n\t\t\t\t\t\t\t\t\tfor (let i = 0; i < credentialStatus.length; i++) {\n\t\t\t\t\t\t\t\t\t\trevoked = await this.checkRevocation(\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\"@context\": DidContexts.Context,\n\t\t\t\t\t\t\t\t\t\t\t\t...issuerDidDocument\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\tcredentialStatus[i].revocationBitmapIndex\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\tif (revoked) {\n\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\trevoked = false;\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 * @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): 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 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\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 * 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\tif (Is.stringValue(revocationBitmapIndex)) {\n\t\t\tconst revocationIndex = Coerce.number(revocationBitmapIndex);\n\t\t\tif (Is.number(revocationIndex)) {\n\t\t\t\tconst revocationService = document.service?.find(s => s.id.endsWith(\"#revocation\"));\n\t\t\t\tif (\n\t\t\t\t\trevocationService &&\n\t\t\t\t\tIs.string(revocationService.serviceEndpoint) &&\n\t\t\t\t\trevocationService.type === \"BitstringStatusList\"\n\t\t\t\t) {\n\t\t\t\t\tconst revocationParts = revocationService.serviceEndpoint.split(\",\");\n\t\t\t\t\tif (revocationParts.length === 2) {\n\t\t\t\t\t\tconst compressedRevocationBytes = Converter.base64UrlToBytes(revocationParts[1]);\n\t\t\t\t\t\tconst decompressed = await Compression.decompress(\n\t\t\t\t\t\t\tcompressedRevocationBytes,\n\t\t\t\t\t\t\tCompressionType.Gzip\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst bitString = BitString.fromBits(\n\t\t\t\t\t\t\tdecompressed,\n\t\t\t\t\t\t\tEntityStorageIdentityConnector._REVOCATION_BITS_SIZE\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn bitString.getBit(revocationIndex);\n\t\t\t\t\t}\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 * @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\tawait this._didDocumentEntityStorage.set({\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\t}\n}\n"]}
|
|
@@ -151,11 +151,15 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
|
|
|
151
151
|
}>;
|
|
152
152
|
/**
|
|
153
153
|
* Create a proof for arbitrary data with the specified verification method.
|
|
154
|
+
* This method uses async signing to ensure the private key never leaves the vault,
|
|
155
|
+
* with algorithm validation to ensure key type compatibility.
|
|
154
156
|
* @param controller The controller of the identity who can make changes.
|
|
155
157
|
* @param verificationMethodId The verification method id to use.
|
|
156
158
|
* @param proofType The type of proof to create.
|
|
157
159
|
* @param unsecureDocument The unsecure document to create the proof for.
|
|
158
160
|
* @returns The proof.
|
|
161
|
+
* @throws NotFoundError if the identity or method is not found.
|
|
162
|
+
* @throws GeneralError if algorithm doesn't match key type or proof creation fails.
|
|
159
163
|
*/
|
|
160
164
|
createProof(controller: string, verificationMethodId: string, proofType: ProofTypes, unsecureDocument: IJsonLdNodeObject): Promise<IProof>;
|
|
161
165
|
/**
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @twin.org/identity-connector-entity-storage- Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.17](https://github.com/twinfoundation/identity/compare/identity-connector-entity-storage-v0.0.3-next.16...identity-connector-entity-storage-v0.0.3-next.17) (2026-02-24)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* implement async proof signing with vault security ([#110](https://github.com/twinfoundation/identity/issues/110)) ([9651c24](https://github.com/twinfoundation/identity/commit/9651c2492d63eca6545735f5638d3191e25bd185))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/identity-models bumped from 0.0.3-next.16 to 0.0.3-next.17
|
|
16
|
+
|
|
17
|
+
## [0.0.3-next.16](https://github.com/twinfoundation/identity/compare/identity-connector-entity-storage-v0.0.3-next.15...identity-connector-entity-storage-v0.0.3-next.16) (2026-02-13)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Miscellaneous Chores
|
|
21
|
+
|
|
22
|
+
* **identity-connector-entity-storage:** Synchronize repo versions
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
* The following workspace dependencies were updated
|
|
28
|
+
* dependencies
|
|
29
|
+
* @twin.org/identity-models bumped from 0.0.3-next.15 to 0.0.3-next.16
|
|
30
|
+
|
|
3
31
|
## [0.0.3-next.15](https://github.com/twinfoundation/identity/compare/identity-connector-entity-storage-v0.0.3-next.14...identity-connector-entity-storage-v0.0.3-next.15) (2026-02-12)
|
|
4
32
|
|
|
5
33
|
|
|
@@ -569,6 +569,8 @@ The presentation stored in the jwt and the revocation status.
|
|
|
569
569
|
> **createProof**(`controller`, `verificationMethodId`, `proofType`, `unsecureDocument`): `Promise`\<`IProof`\>
|
|
570
570
|
|
|
571
571
|
Create a proof for arbitrary data with the specified verification method.
|
|
572
|
+
This method uses async signing to ensure the private key never leaves the vault,
|
|
573
|
+
with algorithm validation to ensure key type compatibility.
|
|
572
574
|
|
|
573
575
|
#### Parameters
|
|
574
576
|
|
|
@@ -602,6 +604,14 @@ The unsecure document to create the proof for.
|
|
|
602
604
|
|
|
603
605
|
The proof.
|
|
604
606
|
|
|
607
|
+
#### Throws
|
|
608
|
+
|
|
609
|
+
NotFoundError if the identity or method is not found.
|
|
610
|
+
|
|
611
|
+
#### Throws
|
|
612
|
+
|
|
613
|
+
GeneralError if algorithm doesn't match key type or proof creation fails.
|
|
614
|
+
|
|
605
615
|
#### Implementation of
|
|
606
616
|
|
|
607
617
|
`IIdentityConnector.createProof`
|
package/locales/en.json
CHANGED
|
@@ -5,28 +5,30 @@
|
|
|
5
5
|
"resolveDocumentFailed": "Resolving the document failed"
|
|
6
6
|
},
|
|
7
7
|
"entityStorageIdentityConnector": {
|
|
8
|
-
"createDocumentFailed": "Creating the document failed",
|
|
9
|
-
"removeDocumentFailed": "Removing the document failed",
|
|
10
|
-
"signatureVerificationFailed": "The document integrity check failed",
|
|
11
|
-
"missingDid": "The full id including DID is required",
|
|
12
|
-
"addVerificationMethodFailed": "Adding the verification method failed",
|
|
13
|
-
"removeVerificationMethodFailed": "Removing the verification method failed",
|
|
14
8
|
"addServiceFailed": "Adding the service failed",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"verificationMethodNotFound": "The verification method could not be found",
|
|
18
|
-
"serviceNotFound": "The service could not be found",
|
|
19
|
-
"publicKeyJwkMissing": "The verification method contains no publicKeyJwk in method \"{method}\"",
|
|
20
|
-
"jwkSignatureFailed": "The signature on the JWK failed verification",
|
|
21
|
-
"createVerifiableCredentialFailed": "Creating the verifiable credential failed",
|
|
9
|
+
"addVerificationMethodFailed": "Adding the verification method failed",
|
|
10
|
+
"algorithmKeyTypeMismatch": "Algorithm \"{algorithm}\" requires key type \"{expectedKeyType}\", but key \"{keyId}\" has type \"{actualKeyType}\"",
|
|
22
11
|
"checkingVerifiableCredentialFailed": "Checking the verifiable credential failed",
|
|
23
|
-
"createVerifiablePresentationFailed": "Creating the verifiable presentation failed",
|
|
24
12
|
"checkingVerifiablePresentationFailed": "Checking the verifiable presentation failed",
|
|
13
|
+
"createDocumentFailed": "Creating the document failed",
|
|
25
14
|
"createProofFailed": "Creating the signature for the data failed",
|
|
15
|
+
"createVerifiableCredentialFailed": "Creating the verifiable credential failed",
|
|
16
|
+
"createVerifiablePresentationFailed": "Creating the verifiable presentation failed",
|
|
17
|
+
"documentNotFound": "The document could not be found \"{notFoundId}\"",
|
|
18
|
+
"jwkSignatureFailed": "The signature on the JWK failed verification",
|
|
26
19
|
"methodMissing": "The verification method specified does not exist \"{method}\"",
|
|
27
|
-
"
|
|
20
|
+
"missingDid": "The full id including DID is required",
|
|
21
|
+
"privateKeyMissing": "The private key could not be found for key \"{keyId}\"",
|
|
22
|
+
"publicKeyJwkMissing": "The verification method contains no publicKeyJwk in method \"{method}\"",
|
|
23
|
+
"removeDocumentFailed": "Removing the document failed",
|
|
24
|
+
"removeServiceFailed": "Removing the service failed",
|
|
25
|
+
"removeVerificationMethodFailed": "Removing the verification method failed",
|
|
28
26
|
"revokeVerifiableCredentialsFailed": "Revoking verifiable credentials failed",
|
|
29
|
-
"
|
|
27
|
+
"serviceNotFound": "The service could not be found",
|
|
28
|
+
"signatureVerificationFailed": "The document integrity check failed",
|
|
29
|
+
"unrevokeVerifiableCredentialsFailed": "Unrevoking verifiable credentials failed",
|
|
30
|
+
"verificationMethodNotFound": "The verification method could not be found",
|
|
31
|
+
"verifyProofFailed": "Verifying the signature for the data failed"
|
|
30
32
|
},
|
|
31
33
|
"entityStorageIdentityProfileConnector": {
|
|
32
34
|
"alreadyExists": "The identity profile already exists for the identity \"{existingId}\"",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/identity-connector-entity-storage",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.17",
|
|
4
4
|
"description": "Identity connector implementation using entity storage",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@twin.org/data-core": "next",
|
|
20
20
|
"@twin.org/data-json-ld": "next",
|
|
21
21
|
"@twin.org/entity": "next",
|
|
22
|
-
"@twin.org/identity-models": "0.0.3-next.
|
|
22
|
+
"@twin.org/identity-models": "0.0.3-next.17",
|
|
23
23
|
"@twin.org/nameof": "next",
|
|
24
24
|
"@twin.org/standards-w3c-did": "next",
|
|
25
25
|
"@twin.org/vault-models": "next",
|