@twin.org/identity-connector-entity-storage 0.0.3-next.34 → 0.0.3-next.36

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.
@@ -45,6 +45,7 @@ export class EntityStorageIdentityConnector {
45
45
  /**
46
46
  * Build the key name to access the specified key in the vault.
47
47
  * @param identity The identity of the user to access the vault keys.
48
+ * @param key The key to access in the vault.
48
49
  * @returns The vault key.
49
50
  * @internal
50
51
  */
@@ -54,6 +55,9 @@ export class EntityStorageIdentityConnector {
54
55
  /**
55
56
  * Verify the document in storage.
56
57
  * @param didDocument The did document that was stored.
58
+ * @param vaultConnector The vault connector to use for verification.
59
+ * @returns A promise that resolves when verification is complete.
60
+ * @throws GeneralError if the document signature is invalid.
57
61
  * @internal
58
62
  */
59
63
  static async verifyDocument(didDocument, vaultConnector) {
@@ -105,7 +109,7 @@ export class EntityStorageIdentityConnector {
105
109
  * Remove a document.
106
110
  * @param controller The controller of the identity who can make changes.
107
111
  * @param documentId The id of the document to remove.
108
- * @returns Nothing.
112
+ * @returns A promise that resolves when the document has been removed.
109
113
  */
110
114
  async removeDocument(controller, documentId) {
111
115
  Guards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, "controller", controller);
@@ -148,7 +152,7 @@ export class EntityStorageIdentityConnector {
148
152
  // If there is a verification method id, we will try to get the key from the vault.
149
153
  try {
150
154
  // If there is an existing key, we will use it.
151
- const existingKey = await this._vaultConnector.getKey(EntityStorageIdentityConnector.buildVaultKey(didDocument.id, verificationMethodId));
155
+ const existingKey = await this._vaultConnector.getKey(EntityStorageIdentityConnector.buildVaultKey(didDocument.id, verificationMethodId), "public");
152
156
  methodKeyPublic = existingKey.publicKey;
153
157
  }
154
158
  catch { }
@@ -215,7 +219,7 @@ export class EntityStorageIdentityConnector {
215
219
  * Remove a verification method from the document.
216
220
  * @param controller The controller of the identity who can make changes.
217
221
  * @param verificationMethodId The id of the verification method.
218
- * @returns Nothing.
222
+ * @returns A promise that resolves when the verification method has been removed.
219
223
  * @throws NotFoundError if the id can not be resolved.
220
224
  * @throws NotSupportedError if the platform does not support multiple revocable keys.
221
225
  */
@@ -316,7 +320,7 @@ export class EntityStorageIdentityConnector {
316
320
  * Remove a service from the document.
317
321
  * @param controller The controller of the identity who can make changes.
318
322
  * @param serviceId The id of the service.
319
- * @returns Nothing.
323
+ * @returns A promise that resolves when the service has been removed.
320
324
  * @throws NotFoundError if the id can not be resolved.
321
325
  */
322
326
  async removeService(controller, serviceId) {
@@ -357,7 +361,7 @@ export class EntityStorageIdentityConnector {
357
361
  * @param controller The controller of the identity who can make changes.
358
362
  * @param documentId The id of the document to update.
359
363
  * @param alias The alias to add. Must be a Url or Urn (typically another DID).
360
- * @returns Nothing.
364
+ * @returns A promise that resolves when the alias has been added.
361
365
  * @throws GeneralError if the alias is not a Url or Urn.
362
366
  * @throws NotFoundError if the id can not be resolved.
363
367
  */
@@ -392,7 +396,7 @@ export class EntityStorageIdentityConnector {
392
396
  * @param controller The controller of the identity who can make changes.
393
397
  * @param documentId The id of the document to update.
394
398
  * @param alias The alias to remove. Must be a Url or Urn.
395
- * @returns Nothing.
399
+ * @returns A promise that resolves when the alias has been removed.
396
400
  * @throws GeneralError if the alias is not a Url or Urn.
397
401
  * @throws NotFoundError if the id can not be resolved.
398
402
  */
@@ -657,7 +661,7 @@ export class EntityStorageIdentityConnector {
657
661
  * @param controller The controller of the identity who can make changes.
658
662
  * @param issuerDocumentId The id of the document to update the revocation list for.
659
663
  * @param credentialIndices The revocation bitmap index or indices to revoke.
660
- * @returns Nothing.
664
+ * @returns A promise that resolves when the credentials have been revoked.
661
665
  */
662
666
  async revokeVerifiableCredentials(controller, issuerDocumentId, credentialIndices) {
663
667
  Guards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, "controller", controller);
@@ -697,7 +701,7 @@ export class EntityStorageIdentityConnector {
697
701
  * @param controller The controller of the identity who can make changes.
698
702
  * @param issuerDocumentId The id of the document to update the revocation list for.
699
703
  * @param credentialIndices The revocation bitmap index or indices to un revoke.
700
- * @returns Nothing.
704
+ * @returns A promise that resolves when the credentials have been unrevoked.
701
705
  */
702
706
  async unrevokeVerifiableCredentials(controller, issuerDocumentId, credentialIndices) {
703
707
  Guards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, "controller", controller);
@@ -1114,6 +1118,7 @@ export class EntityStorageIdentityConnector {
1114
1118
  * Update the document in storage.
1115
1119
  * @param controller The controller of the document.
1116
1120
  * @param didDocument The did document to store.
1121
+ * @returns A promise that resolves when the document has been signed and persisted.
1117
1122
  * @internal
1118
1123
  */
1119
1124
  async updateDocument(controller, didDocument) {
@@ -1 +1 @@
1
- {"version":3,"file":"entityStorageIdentityConnector.js","sourceRoot":"","sources":["../../src/entityStorageIdentityConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,WAAW,EACX,SAAS,EACT,SAAS,EACT,MAAM,EACN,WAAW,EACX,eAAe,EACf,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,UAAU,EACV,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,GAAG,EACH,GAAG,EACH,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,YAAY,EACZ,eAAe,EAGf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,cAAc,EAA2B,MAAM,2BAA2B,CAAC;AAEpF,OAAO,EACN,WAAW,EACX,QAAQ,EACR,yBAAyB,EAEzB,aAAa,EACb,WAAW,EACX,UAAU,EAQV,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EAEZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAgD,MAAM,eAAe,CAAC;AAIvF;;GAEG;AACH,MAAM,OAAO,8BAA8B;IAC1C;;OAEG;IACI,MAAM,CAAU,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,yBAAyB,EACzB,eAAe,CAAC,IAAI,CACpB,CAAC;wBAEF,MAAM,SAAS,GAAG,SAAS,CAAC,QAAQ,CACnC,YAAY,EACZ,8BAA8B,CAAC,qBAAqB,CACpD,CAAC;wBAEF,OAAO,SAAS,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;oBAC1C,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACK,KAAK,CAAC,cAAc,CAAC,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\tUrl,\n\tUrn\n} from \"@twin.org/core\";\nimport {\n\tJsonLdHelper,\n\tJsonLdProcessor,\n\ttype IJsonLdContextDefinitionRoot,\n\ttype IJsonLdNodeObject\n} from \"@twin.org/data-json-ld\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport { 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\ttype IDidVerifiablePresentation\n} from \"@twin.org/standards-w3c-did\";\nimport {\n\tVaultConnectorFactory,\n\tVaultConnectorHelper,\n\tVaultKeyType,\n\ttype IVaultConnector\n} from \"@twin.org/vault-models\";\nimport { Jwk, Jwt, type IJwk, type IJwtHeader, type IJwtPayload } from \"@twin.org/web\";\nimport type { IdentityDocument } from \"./entities/identityDocument.js\";\nimport type { IEntityStorageIdentityConnectorConstructorOptions } from \"./models/IEntityStorageIdentityConnectorConstructorOptions.js\";\n\n/**\n * Class for performing identity operations using entity storage.\n */\nexport class EntityStorageIdentityConnector implements IIdentityConnector {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageIdentityConnector>();\n\n\t/**\n\t * The namespace supported by the identity connector.\n\t */\n\tpublic static readonly NAMESPACE: string = \"entity-storage\";\n\n\t/**\n\t * The size of the revocation bitmap in bits (16Kb).\n\t * @internal\n\t */\n\tprivate static readonly _REVOCATION_BITS_SIZE: number = 131072;\n\n\t/**\n\t * The entity storage for identities.\n\t * @internal\n\t */\n\tprotected readonly _didDocumentEntityStorage: IEntityStorageConnector<IdentityDocument>;\n\n\t/**\n\t * The vault for the keys.\n\t * @internal\n\t */\n\tprotected readonly _vaultConnector: IVaultConnector;\n\n\t/**\n\t * 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 * Add an alias to the alsoKnownAs property on the document.\n\t * If the alias is already present the operation is a no-op.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to update.\n\t * @param alias The alias to add. Must be a Url or Urn (typically another DID).\n\t * @returns Nothing.\n\t * @throws GeneralError if the alias is not a Url or Urn.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async addAlsoKnownAs(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\talias: string\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(alias), alias);\n\t\tif (!Url.tryParseExact(alias) && !Urn.tryParseExact(alias)) {\n\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"invalidAlias\", { alias });\n\t\t}\n\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this._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 existing = Is.array(didDocument.alsoKnownAs) ? didDocument.alsoKnownAs : [];\n\t\t\tif (existing.includes(alias)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdidDocument.alsoKnownAs = [...existing, alias];\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"addAlsoKnownAsFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove an alias from the alsoKnownAs property on the document.\n\t * If the alias is not present the operation is a no-op.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to update.\n\t * @param alias The alias to remove. Must be a Url or Urn.\n\t * @returns Nothing.\n\t * @throws GeneralError if the alias is not a Url or Urn.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async removeAlsoKnownAs(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\talias: string\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(alias), alias);\n\t\tif (!Url.tryParseExact(alias) && !Urn.tryParseExact(alias)) {\n\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"invalidAlias\", { alias });\n\t\t}\n\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this._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\tif (!Is.array(didDocument.alsoKnownAs) || !didDocument.alsoKnownAs.includes(alias)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst filtered = didDocument.alsoKnownAs.filter(a => a !== alias);\n\t\t\tif (filtered.length === 0) {\n\t\t\t\tdelete didDocument.alsoKnownAs;\n\t\t\t} else {\n\t\t\t\tdidDocument.alsoKnownAs = filtered;\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeAlsoKnownAsFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a verifiable credential for a verification method.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param id The id of the credential.\n\t * @param subject The credential subject to store in the verifiable credential.\n\t * @param options Additional options for creating the verifiable credential.\n\t * @param options.revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.\n\t * @param options.expirationDate The date the verifiable credential is valid until.\n\t * @param options.jwtHeaderFields Additional fields to add to the JWT header.\n\t * @param options.jwtPayloadFields Additional fields to add to the JWT payload.\n\t * @returns The created verifiable credential and its token.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async createVerifiableCredential(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\tid: string | undefined,\n\t\tsubject: IJsonLdNodeObject,\n\t\toptions?: {\n\t\t\trevocationIndex?: number;\n\t\t\texpirationDate?: Date;\n\t\t\tjwtHeaderFields?: { [id: string]: string };\n\t\t\tjwtPayloadFields?: { [id: string]: string };\n\t\t}\n\t): Promise<{\n\t\tverifiableCredential: IDidVerifiableCredentialV1;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(subject),\n\t\t\tsubject\n\t\t);\n\t\tif (!Is.undefined(options?.revocationIndex)) {\n\t\t\tGuards.number(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(options.revocationIndex),\n\t\t\t\toptions.revocationIndex\n\t\t\t);\n\t\t}\n\t\tif (!Is.undefined(options?.expirationDate)) {\n\t\t\tGuards.date(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(options.expirationDate),\n\t\t\t\toptions.expirationDate\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst issuerIdentityDocument = await this._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 credContext = ObjectHelper.extractProperty<IJsonLdContextDefinitionRoot>(subjectClone, [\n\t\t\t\t\"@context\"\n\t\t\t]);\n\t\t\tconst credId = ObjectHelper.extractProperty<string>(subjectClone, [\"@id\", \"id\"], false);\n\n\t\t\tconst verifiableCredential: IDidVerifiableCredentialV1 = {\n\t\t\t\t\"@context\": (JsonLdProcessor.combineContexts(DidContexts.ContextVCv1, credContext) ??\n\t\t\t\t\tDidContexts.ContextVCv1) as [typeof DidContexts.ContextVCv1],\n\t\t\t\tid,\n\t\t\t\ttype: DidTypes.VerifiableCredential,\n\t\t\t\tcredentialSubject: subjectClone,\n\t\t\t\tissuer: issuerDidDocument.id,\n\t\t\t\tissuanceDate: new Date(Date.now()).toISOString(),\n\t\t\t\texpirationDate: Is.date(options?.expirationDate)\n\t\t\t\t\t? options?.expirationDate.toISOString()\n\t\t\t\t\t: undefined,\n\t\t\t\tcredentialStatus:\n\t\t\t\t\trevocationService && !Is.undefined(options?.revocationIndex)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tid: revocationService.id,\n\t\t\t\t\t\t\t\ttype: Is.array(revocationService.type)\n\t\t\t\t\t\t\t\t\t? revocationService.type[0]\n\t\t\t\t\t\t\t\t\t: revocationService.type,\n\t\t\t\t\t\t\t\trevocationBitmapIndex: options.revocationIndex.toString()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined\n\t\t\t};\n\n\t\t\tconst jwtHeader: IJwtHeader = {\n\t\t\t\t...options?.jwtHeaderFields,\n\t\t\t\tkid: verificationDidMethod.id,\n\t\t\t\ttyp: \"JWT\",\n\t\t\t\talg: JwsAlgorithms.EdDSA\n\t\t\t};\n\n\t\t\tconst jwtVc = ObjectHelper.pick(ObjectHelper.clone(verifiableCredential), [\n\t\t\t\t\"@context\",\n\t\t\t\t\"type\",\n\t\t\t\t\"credentialSubject\",\n\t\t\t\t\"credentialStatus\"\n\t\t\t]);\n\n\t\t\t// Add the proof to the VC after extracting the jwt data\n\t\t\t// as the jwt does not include the proof\n\t\t\tverifiableCredential.proof = await this.createProof(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tProofTypes.DataIntegrityProof,\n\t\t\t\tJsonLdHelper.toNodeObject(verifiableCredential)\n\t\t\t);\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\t...options?.jwtPayloadFields,\n\t\t\t\tiss: idParts.id,\n\t\t\t\tnbf: Math.floor(Date.now() / 1000),\n\t\t\t\tjti: verifiableCredential.id,\n\t\t\t\tsub: credId,\n\t\t\t\tvc: jwtVc\n\t\t\t};\n\n\t\t\tif (Is.date(options?.expirationDate)) {\n\t\t\t\tjwtPayload.exp = Math.floor(options.expirationDate.getTime() / 1000);\n\t\t\t}\n\n\t\t\tconst signature = await Jwt.encodeWithSigner(jwtHeader, jwtPayload, async (header, payload) =>\n\t\t\t\tVaultConnectorHelper.jwtSigner(\n\t\t\t\t\tthis._vaultConnector,\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment ?? \"\"),\n\t\t\t\t\theader,\n\t\t\t\t\tpayload\n\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tverifiableCredential,\n\t\t\t\tjwt: signature\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createVerifiableCredentialFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Check a verifiable credential is valid.\n\t * @param credential The credential to verify.\n\t * @returns The credential stored in the jwt and the revocation status.\n\t */\n\tpublic async checkVerifiableCredential(credential: string | IDidVerifiableCredential): Promise<{\n\t\trevoked: boolean;\n\t\tverifiableCredential?: IDidVerifiableCredential;\n\t}> {\n\t\tif (Is.object(credential)) {\n\t\t\tGuards.objectValue<IDidVerifiableCredential>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(credential),\n\t\t\t\tcredential\n\t\t\t);\n\t\t\tGuards.objectValue<IDidVerifiableCredential>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(credential.proof),\n\t\t\t\tcredential.proof\n\t\t\t);\n\t\t\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 * @param options.jwtHeaderFields Additional fields to add to the JWT header.\n\t * @param options.jwtPayloadFields Additional fields to add to the JWT payload.\n\t * @returns The created verifiable presentation and its token.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async createVerifiablePresentation(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\tpresentationId: string | undefined,\n\t\tcontexts: IJsonLdContextDefinitionRoot | undefined,\n\t\ttypes: string | string[] | undefined,\n\t\tverifiableCredentials: (string | IDidVerifiableCredentialV1)[],\n\t\toptions?: {\n\t\t\texpirationDate?: Date;\n\t\t\tjwtHeaderFields?: { [id: string]: string };\n\t\t\tjwtPayloadFields?: { [id: string]: string };\n\t\t}\n\t): Promise<{\n\t\tverifiablePresentation: IDidVerifiablePresentationV1;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tif (Is.array(types)) {\n\t\t\tGuards.arrayValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(types), types);\n\t\t} else if (Is.string(types)) {\n\t\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(types), types);\n\t\t}\n\t\tGuards.arrayValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verifiableCredentials),\n\t\t\tverifiableCredentials\n\t\t);\n\t\tif (!Is.undefined(options?.expirationDate)) {\n\t\t\tGuards.date(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(options.expirationDate),\n\t\t\t\toptions.expirationDate\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst holderIdentityDocument = await this._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\t...options?.jwtHeaderFields,\n\t\t\t\tkid: didMethod.id,\n\t\t\t\ttyp: \"JWT\",\n\t\t\t\talg: JwsAlgorithms.EdDSA\n\t\t\t};\n\n\t\t\tconst jwtVp = ObjectHelper.pick(ObjectHelper.clone(verifiablePresentation), [\n\t\t\t\t\"@context\",\n\t\t\t\t\"type\",\n\t\t\t\t\"verifiableCredential\"\n\t\t\t]);\n\n\t\t\t// Add the proof to the VP after extracting the jwt data\n\t\t\t// as the jwt does not include the proof\n\t\t\tverifiablePresentation.proof = await this.createProof(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tProofTypes.DataIntegrityProof,\n\t\t\t\tJsonLdHelper.toNodeObject(verifiablePresentation)\n\t\t\t);\n\n\t\t\tconst jwtPayload: IJwtPayload = {\n\t\t\t\t...options?.jwtPayloadFields,\n\t\t\t\tiss: verifiablePresentation.holder,\n\t\t\t\tnbf: Math.floor(Date.now() / 1000),\n\t\t\t\tvp: jwtVp\n\t\t\t};\n\n\t\t\tif (Is.date(options?.expirationDate)) {\n\t\t\t\tjwtPayload.exp = Math.floor(options.expirationDate.getTime() / 1000);\n\t\t\t}\n\n\t\t\tconst signature = await Jwt.encodeWithSigner(jwtHeader, jwtPayload, async (header, payload) =>\n\t\t\t\tVaultConnectorHelper.jwtSigner(\n\t\t\t\t\tthis._vaultConnector,\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment ?? \"\"),\n\t\t\t\t\theader,\n\t\t\t\t\tpayload\n\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tverifiablePresentation,\n\t\t\t\tjwt: signature\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createVerifiablePresentationFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Check a verifiable presentation is valid.\n\t * @param presentation The presentation to verify.\n\t * @returns The presentation stored in the jwt and the revocation status.\n\t */\n\tpublic async checkVerifiablePresentation(\n\t\tpresentation: string | IDidVerifiablePresentation\n\t): Promise<{\n\t\trevoked: boolean;\n\t\tverifiablePresentation?: IDidVerifiablePresentationV1;\n\t\tissuers?: IDidDocument[];\n\t}> {\n\t\tif (Is.object(presentation)) {\n\t\t\tconst { proof, ...doc } = presentation as IDidVerifiablePresentationV1;\n\t\t\tconst proofEntry = ArrayHelper.fromObjectOrArray(proof)[0];\n\t\t\tGuards.objectValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(proofEntry), proofEntry);\n\t\t\tawait this.verifyProof(JsonLdHelper.toNodeObject(doc), proofEntry);\n\t\t\treturn { revoked: false, verifiablePresentation: doc };\n\t\t}\n\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(presentation),\n\t\t\tpresentation\n\t\t);\n\n\t\tconst presentationJwt = presentation;\n\n\t\ttry {\n\t\t\tconst jwtDecoded = await Jwt.decode(presentationJwt);\n\n\t\t\tconst jwtHeader = jwtDecoded.header;\n\t\t\tconst jwtPayload = jwtDecoded.payload;\n\t\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\t\tif (\n\t\t\t\tIs.undefined(jwtHeader) ||\n\t\t\t\tIs.undefined(jwtPayload) ||\n\t\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\t\tIs.undefined(jwtSignature)\n\t\t\t) {\n\t\t\t\tthrow new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, \"jwkSignatureFailed\");\n\t\t\t}\n\n\t\t\tconst holderDocumentId = jwtPayload.iss;\n\t\t\tconst holderIdentityDocument = await this._didDocumentEntityStorage.get(holderDocumentId);\n\t\t\tif (Is.undefined(holderIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tholderDocumentId\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tholderIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\n\t\t\tconst issuers: IDidDocument[] = [];\n\t\t\tconst tokensRevoked: boolean[] = [];\n\t\t\tconst verifiablePresentation = jwtPayload?.vp as IDidVerifiablePresentationV1;\n\t\t\tif (\n\t\t\t\tIs.object<IDidVerifiablePresentationV1>(verifiablePresentation) &&\n\t\t\t\tIs.array(verifiablePresentation.verifiableCredential)\n\t\t\t) {\n\t\t\t\tfor (const vcJwt of verifiablePresentation.verifiableCredential) {\n\t\t\t\t\tlet revoked = 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"]}
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,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,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\tUrl,\n\tUrn\n} from \"@twin.org/core\";\nimport {\n\tJsonLdHelper,\n\tJsonLdProcessor,\n\ttype IJsonLdContextDefinitionRoot,\n\ttype IJsonLdNodeObject\n} from \"@twin.org/data-json-ld\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport { 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\ttype IDidVerifiablePresentation\n} from \"@twin.org/standards-w3c-did\";\nimport {\n\tVaultConnectorFactory,\n\tVaultConnectorHelper,\n\tVaultKeyType,\n\ttype IVaultConnector\n} from \"@twin.org/vault-models\";\nimport { Jwk, Jwt, type IJwk, type IJwtHeader, type IJwtPayload } from \"@twin.org/web\";\nimport type { IdentityDocument } from \"./entities/identityDocument.js\";\nimport type { IEntityStorageIdentityConnectorConstructorOptions } from \"./models/IEntityStorageIdentityConnectorConstructorOptions.js\";\n\n/**\n * Class for performing identity operations using entity storage.\n */\nexport class EntityStorageIdentityConnector implements IIdentityConnector {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageIdentityConnector>();\n\n\t/**\n\t * The namespace supported by the identity connector.\n\t */\n\tpublic static readonly NAMESPACE: string = \"entity-storage\";\n\n\t/**\n\t * The size of the revocation bitmap in bits (16Kb).\n\t * @internal\n\t */\n\tprivate static readonly _REVOCATION_BITS_SIZE: number = 131072;\n\n\t/**\n\t * The entity storage for identities.\n\t * @internal\n\t */\n\tprotected readonly _didDocumentEntityStorage: IEntityStorageConnector<IdentityDocument>;\n\n\t/**\n\t * The vault for the keys.\n\t * @internal\n\t */\n\tprotected readonly _vaultConnector: IVaultConnector;\n\n\t/**\n\t * 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 * @param key The key to access in the vault.\n\t * @returns The vault key.\n\t * @internal\n\t */\n\tpublic static buildVaultKey(identity: string, key: string): string {\n\t\treturn `${identity}/${key}`;\n\t}\n\n\t/**\n\t * Verify the document in storage.\n\t * @param didDocument The did document that was stored.\n\t * @param vaultConnector The vault connector to use for verification.\n\t * @returns A promise that resolves when verification is complete.\n\t * @throws GeneralError if the document signature is invalid.\n\t * @internal\n\t */\n\tpublic static async verifyDocument(\n\t\tdidDocument: IdentityDocument,\n\t\tvaultConnector: IVaultConnector\n\t): Promise<void> {\n\t\tconst stringifiedDocument = JsonHelper.canonicalize(didDocument.document);\n\t\tconst docBytes = Converter.utf8ToBytes(stringifiedDocument);\n\n\t\tconst verified = await vaultConnector.verify(\n\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, \"did\"),\n\t\t\tdocBytes,\n\t\t\tConverter.base64ToBytes(didDocument.signature)\n\t\t);\n\n\t\tif (!verified) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"signatureVerificationFailed\"\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageIdentityConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * 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 A promise that resolves when the document has been removed.\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\t\"public\"\n\t\t\t\t\t);\n\t\t\t\t\tmethodKeyPublic = existingKey.publicKey;\n\t\t\t\t} catch {}\n\t\t\t}\n\n\t\t\tif (Is.empty(methodKeyPublic)) {\n\t\t\t\t// If there is no existing key, we will create a new one with a temporary name.\n\t\t\t\ttempKeyId = `temp-vm-${Converter.bytesToBase64Url(RandomHelper.generate(16))}`;\n\t\t\t\tmethodKeyPublic = await this._vaultConnector.createKey(\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, tempKeyId),\n\t\t\t\t\tVaultKeyType.Ed25519\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst jwkParams: IJwk = {\n\t\t\t\talg: \"EdDSA\",\n\t\t\t\tkty: \"OKP\",\n\t\t\t\tcrv: \"Ed25519\",\n\t\t\t\tx: Converter.bytesToBase64Url(methodKeyPublic)\n\t\t\t};\n\n\t\t\tconst kid = await Jwk.generateKid(jwkParams);\n\n\t\t\tconst methodId = `${documentId}#${verificationMethodId ?? kid}`;\n\n\t\t\tif (Is.stringValue(tempKeyId)) {\n\t\t\t\t// If we created a temporary key, we will rename it to the final method id.\n\t\t\t\tawait this._vaultConnector.renameKey(\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, tempKeyId),\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, verificationMethodId ?? kid)\n\t\t\t\t);\n\t\t\t\ttempKeyId = undefined;\n\t\t\t}\n\n\t\t\tconst methods = this.getAllMethods(didDocument);\n\t\t\tconst existingMethodIndex = methods.findIndex(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === methodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === methodId;\n\t\t\t});\n\n\t\t\tif (existingMethodIndex !== -1) {\n\t\t\t\tconst methodArray =\n\t\t\t\t\tdidDocument[methods[existingMethodIndex].arrayKey as keyof IDidDocument];\n\n\t\t\t\tif (Is.array(methodArray)) {\n\t\t\t\t\tmethodArray.splice(existingMethodIndex, 1);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst didVerificationMethod: IDidDocumentVerificationMethod = {\n\t\t\t\tid: methodId,\n\t\t\t\tcontroller: documentId,\n\t\t\t\ttype: \"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 A promise that resolves when the verification method has been removed.\n\t * @throws NotFoundError if the id can not be resolved.\n\t * @throws NotSupportedError if the platform does not support multiple revocable keys.\n\t */\n\tpublic async removeVerificationMethod(\n\t\tcontroller: string,\n\t\tverificationMethodId: string\n\t): 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 A promise that resolves when the service has been removed.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async removeService(controller: string, serviceId: string): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(serviceId), serviceId);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(serviceId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, \"missingDid\", serviceId);\n\t\t\t}\n\n\t\t\tconst didIdentityDocument = await this._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 * Add an alias to the alsoKnownAs property on the document.\n\t * If the alias is already present the operation is a no-op.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to update.\n\t * @param alias The alias to add. Must be a Url or Urn (typically another DID).\n\t * @returns A promise that resolves when the alias has been added.\n\t * @throws GeneralError if the alias is not a Url or Urn.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async addAlsoKnownAs(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\talias: string\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(alias), alias);\n\t\tif (!Url.tryParseExact(alias) && !Urn.tryParseExact(alias)) {\n\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"invalidAlias\", { alias });\n\t\t}\n\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this._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 existing = Is.array(didDocument.alsoKnownAs) ? didDocument.alsoKnownAs : [];\n\t\t\tif (existing.includes(alias)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdidDocument.alsoKnownAs = [...existing, alias];\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"addAlsoKnownAsFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove an alias from the alsoKnownAs property on the document.\n\t * If the alias is not present the operation is a no-op.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to update.\n\t * @param alias The alias to remove. Must be a Url or Urn.\n\t * @returns A promise that resolves when the alias has been removed.\n\t * @throws GeneralError if the alias is not a Url or Urn.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async removeAlsoKnownAs(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\talias: string\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(alias), alias);\n\t\tif (!Url.tryParseExact(alias) && !Urn.tryParseExact(alias)) {\n\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"invalidAlias\", { alias });\n\t\t}\n\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this._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\tif (!Is.array(didDocument.alsoKnownAs) || !didDocument.alsoKnownAs.includes(alias)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst filtered = didDocument.alsoKnownAs.filter(a => a !== alias);\n\t\t\tif (filtered.length === 0) {\n\t\t\t\tdelete didDocument.alsoKnownAs;\n\t\t\t} else {\n\t\t\t\tdidDocument.alsoKnownAs = filtered;\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeAlsoKnownAsFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a verifiable credential for a verification method.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param id The id of the credential.\n\t * @param subject The credential subject to store in the verifiable credential.\n\t * @param options Additional options for creating the verifiable credential.\n\t * @param options.revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.\n\t * @param options.expirationDate The date the verifiable credential is valid until.\n\t * @param options.jwtHeaderFields Additional fields to add to the JWT header.\n\t * @param options.jwtPayloadFields Additional fields to add to the JWT payload.\n\t * @returns The created verifiable credential and its token.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async createVerifiableCredential(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\tid: string | undefined,\n\t\tsubject: IJsonLdNodeObject,\n\t\toptions?: {\n\t\t\trevocationIndex?: number;\n\t\t\texpirationDate?: Date;\n\t\t\tjwtHeaderFields?: { [id: string]: string };\n\t\t\tjwtPayloadFields?: { [id: string]: string };\n\t\t}\n\t): Promise<{\n\t\tverifiableCredential: IDidVerifiableCredentialV1;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(subject),\n\t\t\tsubject\n\t\t);\n\t\tif (!Is.undefined(options?.revocationIndex)) {\n\t\t\tGuards.number(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(options.revocationIndex),\n\t\t\t\toptions.revocationIndex\n\t\t\t);\n\t\t}\n\t\tif (!Is.undefined(options?.expirationDate)) {\n\t\t\tGuards.date(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(options.expirationDate),\n\t\t\t\toptions.expirationDate\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst issuerIdentityDocument = await this._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 credContext = ObjectHelper.extractProperty<IJsonLdContextDefinitionRoot>(subjectClone, [\n\t\t\t\t\"@context\"\n\t\t\t]);\n\t\t\tconst credId = ObjectHelper.extractProperty<string>(subjectClone, [\"@id\", \"id\"], false);\n\n\t\t\tconst verifiableCredential: IDidVerifiableCredentialV1 = {\n\t\t\t\t\"@context\": (JsonLdProcessor.combineContexts(DidContexts.ContextVCv1, credContext) ??\n\t\t\t\t\tDidContexts.ContextVCv1) as [typeof DidContexts.ContextVCv1],\n\t\t\t\tid,\n\t\t\t\ttype: DidTypes.VerifiableCredential,\n\t\t\t\tcredentialSubject: subjectClone,\n\t\t\t\tissuer: issuerDidDocument.id,\n\t\t\t\tissuanceDate: new Date(Date.now()).toISOString(),\n\t\t\t\texpirationDate: Is.date(options?.expirationDate)\n\t\t\t\t\t? options?.expirationDate.toISOString()\n\t\t\t\t\t: undefined,\n\t\t\t\tcredentialStatus:\n\t\t\t\t\trevocationService && !Is.undefined(options?.revocationIndex)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tid: revocationService.id,\n\t\t\t\t\t\t\t\ttype: Is.array(revocationService.type)\n\t\t\t\t\t\t\t\t\t? revocationService.type[0]\n\t\t\t\t\t\t\t\t\t: revocationService.type,\n\t\t\t\t\t\t\t\trevocationBitmapIndex: options.revocationIndex.toString()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined\n\t\t\t};\n\n\t\t\tconst jwtHeader: IJwtHeader = {\n\t\t\t\t...options?.jwtHeaderFields,\n\t\t\t\tkid: verificationDidMethod.id,\n\t\t\t\ttyp: \"JWT\",\n\t\t\t\talg: JwsAlgorithms.EdDSA\n\t\t\t};\n\n\t\t\tconst jwtVc = ObjectHelper.pick(ObjectHelper.clone(verifiableCredential), [\n\t\t\t\t\"@context\",\n\t\t\t\t\"type\",\n\t\t\t\t\"credentialSubject\",\n\t\t\t\t\"credentialStatus\"\n\t\t\t]);\n\n\t\t\t// Add the proof to the VC after extracting the jwt data\n\t\t\t// as the jwt does not include the proof\n\t\t\tverifiableCredential.proof = await this.createProof(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tProofTypes.DataIntegrityProof,\n\t\t\t\tJsonLdHelper.toNodeObject(verifiableCredential)\n\t\t\t);\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\t...options?.jwtPayloadFields,\n\t\t\t\tiss: idParts.id,\n\t\t\t\tnbf: Math.floor(Date.now() / 1000),\n\t\t\t\tjti: verifiableCredential.id,\n\t\t\t\tsub: credId,\n\t\t\t\tvc: jwtVc\n\t\t\t};\n\n\t\t\tif (Is.date(options?.expirationDate)) {\n\t\t\t\tjwtPayload.exp = Math.floor(options.expirationDate.getTime() / 1000);\n\t\t\t}\n\n\t\t\tconst signature = await Jwt.encodeWithSigner(jwtHeader, jwtPayload, async (header, payload) =>\n\t\t\t\tVaultConnectorHelper.jwtSigner(\n\t\t\t\t\tthis._vaultConnector,\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment ?? \"\"),\n\t\t\t\t\theader,\n\t\t\t\t\tpayload\n\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tverifiableCredential,\n\t\t\t\tjwt: signature\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createVerifiableCredentialFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Check a verifiable credential is valid.\n\t * @param credential The credential to verify.\n\t * @returns The credential stored in the jwt and the revocation status.\n\t */\n\tpublic async checkVerifiableCredential(credential: string | IDidVerifiableCredential): Promise<{\n\t\trevoked: boolean;\n\t\tverifiableCredential?: IDidVerifiableCredential;\n\t}> {\n\t\tif (Is.object(credential)) {\n\t\t\tGuards.objectValue<IDidVerifiableCredential>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(credential),\n\t\t\t\tcredential\n\t\t\t);\n\t\t\tGuards.objectValue<IDidVerifiableCredential>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(credential.proof),\n\t\t\t\tcredential.proof\n\t\t\t);\n\t\t\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 A promise that resolves when the credentials have been revoked.\n\t */\n\tpublic async revokeVerifiableCredentials(\n\t\tcontroller: string,\n\t\tissuerDocumentId: string,\n\t\tcredentialIndices: number[]\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(issuerDocumentId),\n\t\t\tissuerDocumentId\n\t\t);\n\t\tGuards.arrayValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(credentialIndices),\n\t\t\tcredentialIndices\n\t\t);\n\n\t\ttry {\n\t\t\tconst issuerIdentityDocument = await this._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 A promise that resolves when the credentials have been unrevoked.\n\t */\n\tpublic async unrevokeVerifiableCredentials(\n\t\tcontroller: string,\n\t\tissuerDocumentId: string,\n\t\tcredentialIndices: number[]\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(issuerDocumentId),\n\t\t\tissuerDocumentId\n\t\t);\n\t\tGuards.arrayValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(credentialIndices),\n\t\t\tcredentialIndices\n\t\t);\n\n\t\ttry {\n\t\t\tconst issuerIdentityDocument = await this._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 * @param options.jwtHeaderFields Additional fields to add to the JWT header.\n\t * @param options.jwtPayloadFields Additional fields to add to the JWT payload.\n\t * @returns The created verifiable presentation and its token.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async createVerifiablePresentation(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\tpresentationId: string | undefined,\n\t\tcontexts: IJsonLdContextDefinitionRoot | undefined,\n\t\ttypes: string | string[] | undefined,\n\t\tverifiableCredentials: (string | IDidVerifiableCredentialV1)[],\n\t\toptions?: {\n\t\t\texpirationDate?: Date;\n\t\t\tjwtHeaderFields?: { [id: string]: string };\n\t\t\tjwtPayloadFields?: { [id: string]: string };\n\t\t}\n\t): Promise<{\n\t\tverifiablePresentation: IDidVerifiablePresentationV1;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tif (Is.array(types)) {\n\t\t\tGuards.arrayValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(types), types);\n\t\t} else if (Is.string(types)) {\n\t\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(types), types);\n\t\t}\n\t\tGuards.arrayValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verifiableCredentials),\n\t\t\tverifiableCredentials\n\t\t);\n\t\tif (!Is.undefined(options?.expirationDate)) {\n\t\t\tGuards.date(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(options.expirationDate),\n\t\t\t\toptions.expirationDate\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst holderIdentityDocument = await this._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\t...options?.jwtHeaderFields,\n\t\t\t\tkid: didMethod.id,\n\t\t\t\ttyp: \"JWT\",\n\t\t\t\talg: JwsAlgorithms.EdDSA\n\t\t\t};\n\n\t\t\tconst jwtVp = ObjectHelper.pick(ObjectHelper.clone(verifiablePresentation), [\n\t\t\t\t\"@context\",\n\t\t\t\t\"type\",\n\t\t\t\t\"verifiableCredential\"\n\t\t\t]);\n\n\t\t\t// Add the proof to the VP after extracting the jwt data\n\t\t\t// as the jwt does not include the proof\n\t\t\tverifiablePresentation.proof = await this.createProof(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tProofTypes.DataIntegrityProof,\n\t\t\t\tJsonLdHelper.toNodeObject(verifiablePresentation)\n\t\t\t);\n\n\t\t\tconst jwtPayload: IJwtPayload = {\n\t\t\t\t...options?.jwtPayloadFields,\n\t\t\t\tiss: verifiablePresentation.holder,\n\t\t\t\tnbf: Math.floor(Date.now() / 1000),\n\t\t\t\tvp: jwtVp\n\t\t\t};\n\n\t\t\tif (Is.date(options?.expirationDate)) {\n\t\t\t\tjwtPayload.exp = Math.floor(options.expirationDate.getTime() / 1000);\n\t\t\t}\n\n\t\t\tconst signature = await Jwt.encodeWithSigner(jwtHeader, jwtPayload, async (header, payload) =>\n\t\t\t\tVaultConnectorHelper.jwtSigner(\n\t\t\t\t\tthis._vaultConnector,\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment ?? \"\"),\n\t\t\t\t\theader,\n\t\t\t\t\tpayload\n\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tverifiablePresentation,\n\t\t\t\tjwt: signature\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createVerifiablePresentationFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Check a verifiable presentation is valid.\n\t * @param presentation The presentation to verify.\n\t * @returns The presentation stored in the jwt and the revocation status.\n\t */\n\tpublic async checkVerifiablePresentation(\n\t\tpresentation: string | IDidVerifiablePresentation\n\t): Promise<{\n\t\trevoked: boolean;\n\t\tverifiablePresentation?: IDidVerifiablePresentationV1;\n\t\tissuers?: IDidDocument[];\n\t}> {\n\t\tif (Is.object(presentation)) {\n\t\t\tconst { proof, ...doc } = presentation as IDidVerifiablePresentationV1;\n\t\t\tconst proofEntry = ArrayHelper.fromObjectOrArray(proof)[0];\n\t\t\tGuards.objectValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(proofEntry), proofEntry);\n\t\t\tawait this.verifyProof(JsonLdHelper.toNodeObject(doc), proofEntry);\n\t\t\treturn { revoked: false, verifiablePresentation: doc };\n\t\t}\n\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(presentation),\n\t\t\tpresentation\n\t\t);\n\n\t\tconst presentationJwt = presentation;\n\n\t\ttry {\n\t\t\tconst jwtDecoded = await Jwt.decode(presentationJwt);\n\n\t\t\tconst jwtHeader = jwtDecoded.header;\n\t\t\tconst jwtPayload = jwtDecoded.payload;\n\t\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\t\tif (\n\t\t\t\tIs.undefined(jwtHeader) ||\n\t\t\t\tIs.undefined(jwtPayload) ||\n\t\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\t\tIs.undefined(jwtSignature)\n\t\t\t) {\n\t\t\t\tthrow new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, \"jwkSignatureFailed\");\n\t\t\t}\n\n\t\t\tconst holderDocumentId = jwtPayload.iss;\n\t\t\tconst holderIdentityDocument = await this._didDocumentEntityStorage.get(holderDocumentId);\n\t\t\tif (Is.undefined(holderIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tholderDocumentId\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tholderIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\n\t\t\tconst issuers: IDidDocument[] = [];\n\t\t\tconst tokensRevoked: boolean[] = [];\n\t\t\tconst verifiablePresentation = jwtPayload?.vp as IDidVerifiablePresentationV1;\n\t\t\tif (\n\t\t\t\tIs.object<IDidVerifiablePresentationV1>(verifiablePresentation) &&\n\t\t\t\tIs.array(verifiablePresentation.verifiableCredential)\n\t\t\t) {\n\t\t\t\tfor (const vcJwt of verifiablePresentation.verifiableCredential) {\n\t\t\t\t\tlet revoked = 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 * @returns A promise that resolves when the document has been signed and persisted.\n\t * @internal\n\t */\n\tprivate async updateDocument(controller: string, didDocument: IDidDocument): Promise<void> {\n\t\tconst stringifiedDocument = JsonHelper.canonicalize(didDocument);\n\t\tconst docBytes = Converter.utf8ToBytes(stringifiedDocument);\n\n\t\tconst signature = await this._vaultConnector.sign(\n\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, \"did\"),\n\t\t\tdocBytes\n\t\t);\n\n\t\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"]}
@@ -39,7 +39,7 @@ export class EntityStorageIdentityProfileConnector {
39
39
  * @param identity The identity of the profile to create.
40
40
  * @param publicProfile The public profile data.
41
41
  * @param privateProfile The private profile data.
42
- * @returns Nothing.
42
+ * @returns A promise that resolves when the profile has been created.
43
43
  */
44
44
  async create(identity, publicProfile, privateProfile) {
45
45
  Guards.stringValue(EntityStorageIdentityProfileConnector.CLASS_NAME, "identity", identity);
@@ -88,7 +88,7 @@ export class EntityStorageIdentityProfileConnector {
88
88
  * @param identity The identity to update.
89
89
  * @param publicProfile The public profile data.
90
90
  * @param privateProfile The private profile data.
91
- * @returns Nothing.
91
+ * @returns A promise that resolves when the profile has been updated.
92
92
  */
93
93
  async update(identity, publicProfile, privateProfile) {
94
94
  Guards.stringValue(EntityStorageIdentityProfileConnector.CLASS_NAME, "identity", identity);
@@ -111,7 +111,7 @@ export class EntityStorageIdentityProfileConnector {
111
111
  /**
112
112
  * Delete the profile for an identity.
113
113
  * @param identity The identity to delete.
114
- * @returns Nothing.
114
+ * @returns A promise that resolves when the profile has been removed.
115
115
  */
116
116
  async remove(identity) {
117
117
  Guards.stringValue(EntityStorageIdentityProfileConnector.CLASS_NAME, "identity", identity);
@@ -1 +1 @@
1
- {"version":3,"file":"entityStorageIdentityProfileConnector.js","sourceRoot":"","sources":["../../src/entityStorageIdentityProfileConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,kBAAkB,EAClB,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,aAAa,EACb,YAAY,EACZ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAMzC;;GAEG;AACH,MAAM,OAAO,qCAAqC;IAIjD;;OAEG;IACI,MAAM,CAAU,SAAS,GAAW,gBAAgB,CAAC;IAE5D;;OAEG;IACI,MAAM,CAAU,UAAU,2CAA2D;IAE5F;;;OAGG;IACc,qBAAqB,CAA2C;IAEjF;;;OAGG;IACH,YAAY,OAAkE;QAC7E,IAAI,CAAC,qBAAqB,GAAG,6BAA6B,CAAC,GAAG,CAC7D,OAAO,EAAE,wBAAwB,IAAI,kBAAkB,CACvD,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,qCAAqC,CAAC,UAAU,CAAC;IACzD,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,MAAM,CAAC,QAAgB,EAAE,aAAiB,EAAE,cAAkB;QAC1E,MAAM,CAAC,WAAW,CACjB,qCAAqC,CAAC,UAAU,cAEhD,QAAQ,CACR,CAAC;QAEF,IAAI,CAAC;YACJ,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAE/D,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;gBACxB,MAAM,IAAI,kBAAkB,CAC3B,qCAAqC,CAAC,UAAU,E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\tGuards,\n\tIs,\n\tNotFoundError,\n\tObjectHelper\n} from \"@twin.org/core\";\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\nimport { ComparisonOperator } from \"@twin.org/entity\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport type { IIdentityProfileConnector } from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IdentityProfile } from \"./entities/identityProfile.js\";\nimport type { IEntityStorageIdentityProfileConnectorConstructorOptions } from \"./models/IEntityStorageIdentityProfileConnectorConstructorOptions.js\";\n\n/**\n * Class which implements the identity profile connector contract.\n */\nexport class EntityStorageIdentityProfileConnector<\n\tT extends IJsonLdDocument = IJsonLdDocument,\n\tU extends IJsonLdDocument = IJsonLdDocument\n> implements IIdentityProfileConnector<T, U> {\n\t/**\n\t * The namespace supported by the identity profile connector.\n\t */\n\tpublic static readonly NAMESPACE: string = \"entity-storage\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageIdentityProfileConnector>();\n\n\t/**\n\t * The storage connector for the profiles.\n\t * @internal\n\t */\n\tprivate readonly _profileEntityStorage: IEntityStorageConnector<IdentityProfile>;\n\n\t/**\n\t * Create a new instance of EntityStorageIdentityProfileConnector.\n\t * @param options The options for the identity service.\n\t */\n\tconstructor(options?: IEntityStorageIdentityProfileConnectorConstructorOptions) {\n\t\tthis._profileEntityStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.profileEntityStorageType ?? \"identity-profile\"\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 EntityStorageIdentityProfileConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create the profile properties for an identity.\n\t * @param identity The identity of the profile to create.\n\t * @param publicProfile The public profile data.\n\t * @param privateProfile The private profile data.\n\t * @returns Nothing.\n\t */\n\tpublic async create(identity: string, publicProfile?: T, privateProfile?: U): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\n\t\t\tif (!Is.empty(profile)) {\n\t\t\t\tthrow new AlreadyExistsError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"alreadyExists\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this._profileEntityStorage.set({\n\t\t\t\tidentity,\n\t\t\t\tpublicProfile,\n\t\t\t\tprivateProfile\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"createFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the profile properties for an identity.\n\t * @param identity The identity of the item to get.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @returns The items properties.\n\t */\n\tpublic async get(\n\t\tidentity: string,\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[]\n\t): Promise<{\n\t\tpublicProfile: Partial<T>;\n\t\tprivateProfile: Partial<U>;\n\t}> {\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (!profile) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"identityNotFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn this.pickProperties(profile, publicPropertyNames, privatePropertyNames);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"getFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Update the profile properties of an identity.\n\t * @param identity The identity to update.\n\t * @param publicProfile The public profile data.\n\t * @param privateProfile The private profile data.\n\t * @returns Nothing.\n\t */\n\tpublic async update(identity: string, publicProfile?: T, privateProfile?: U): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (Is.empty(profile)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"notFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tprofile.publicProfile = publicProfile ?? profile.publicProfile;\n\t\t\tprofile.privateProfile = privateProfile ?? profile.privateProfile;\n\n\t\t\tawait this._profileEntityStorage.set(profile);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"updateFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Delete the profile for an identity.\n\t * @param identity The identity to delete.\n\t * @returns Nothing.\n\t */\n\tpublic async remove(identity: string): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (Is.empty(profile)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"notFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this._profileEntityStorage.remove(identity);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"removeFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get a list of the requested types.\n\t * @param publicFilters The filters to apply to the identities public profiles.\n\t * @param privateFilters The filters to apply to the identities private profiles.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @param cursor The cursor for paged requests.\n\t * @param limit The maximum number of items in a page.\n\t * @returns The list of items and cursor for paging.\n\t */\n\tpublic async list(\n\t\tpublicFilters?: {\n\t\t\tpropertyName: string;\n\t\t\tpropertyValue: unknown;\n\t\t}[],\n\t\tprivateFilters?: {\n\t\t\tpropertyName: string;\n\t\t\tpropertyValue: unknown;\n\t\t}[],\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[],\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\t/**\n\t\t * The identities.\n\t\t */\n\t\titems: {\n\t\t\tidentity: string;\n\t\t\tpublicProfile?: Partial<T>;\n\t\t\tprivateProfile?: Partial<U>;\n\t\t}[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}> {\n\t\ttry {\n\t\t\tconst conditions = [];\n\n\t\t\tif (Is.arrayValue(publicFilters)) {\n\t\t\t\tfor (const filter of publicFilters) {\n\t\t\t\t\tconditions.push({\n\t\t\t\t\t\tproperty: `publicProfile.${filter.propertyName}`,\n\t\t\t\t\t\tvalue: filter.propertyValue,\n\t\t\t\t\t\tcomparison: ComparisonOperator.Equals\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Is.arrayValue(privateFilters)) {\n\t\t\t\tfor (const filter of privateFilters) {\n\t\t\t\t\tconditions.push({\n\t\t\t\t\t\tproperty: `privateProfile.${filter.propertyName}`,\n\t\t\t\t\t\tvalue: filter.propertyValue,\n\t\t\t\t\t\tcomparison: ComparisonOperator.Equals\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst result = await this._profileEntityStorage.query(\n\t\t\t\tIs.arrayValue(conditions)\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tconditions\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\tcursor,\n\t\t\t\tlimit\n\t\t\t);\n\n\t\t\tconst items: {\n\t\t\t\tidentity: string;\n\t\t\t\tpublicProfile?: Partial<T>;\n\t\t\t\tprivateProfile?: Partial<U>;\n\t\t\t}[] = [];\n\t\t\tfor (const resultEntity of result.entities) {\n\t\t\t\titems.push({\n\t\t\t\t\tidentity: resultEntity.identity ?? \"\",\n\t\t\t\t\t...this.pickProperties(resultEntity, publicPropertyNames, privatePropertyNames)\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\titems,\n\t\t\t\tcursor: result.cursor\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"listFailed\",\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 the profile properties for an identity.\n\t * @param profile The profile to pick the properties from.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @returns The identity profile, will only return private data if you have correct permissions.\n\t * @internal\n\t */\n\tprivate pickProperties(\n\t\tprofile: Partial<IdentityProfile>,\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[]\n\t): {\n\t\tpublicProfile: Partial<T>;\n\t\tprivateProfile: Partial<U>;\n\t} {\n\t\treturn {\n\t\t\tpublicProfile: Is.array(publicPropertyNames)\n\t\t\t\t? ObjectHelper.pick(profile.publicProfile as T, publicPropertyNames)\n\t\t\t\t: (profile.publicProfile as T),\n\t\t\tprivateProfile: Is.array(privatePropertyNames)\n\t\t\t\t? ObjectHelper.pick(profile.privateProfile as U, privatePropertyNames)\n\t\t\t\t: (profile.privateProfile as U)\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"entityStorageIdentityProfileConnector.js","sourceRoot":"","sources":["../../src/entityStorageIdentityProfileConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,kBAAkB,EAClB,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,aAAa,EACb,YAAY,EACZ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAMzC;;GAEG;AACH,MAAM,OAAO,qCAAqC;IAIjD;;OAEG;IACI,MAAM,CAAU,SAAS,GAAW,gBAAgB,CAAC;IAE5D;;OAEG;IACI,MAAM,CAAU,UAAU,2CAA2D;IAE5F;;;OAGG;IACc,qBAAqB,CAA2C;IAEjF;;;OAGG;IACH,YAAY,OAAkE;QAC7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IAED;;;;;;;OAOG;IACK,cAAc,CACrB,OAAiC,EACjC,mBAAiC,EACjC,oBAAkC;QAKlC,OAAO;YACN,aAAa,EAAE,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC;gBAC3C,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,aAAkB,EAAE,mBAAmB,CAAC;gBACpE,CAAC,CAAE,OAAO,CAAC,aAAmB;YAC/B,cAAc,EAAE,EAAE,CAAC,KAAK,CAAC,oBAAoB,CAAC;gBAC7C,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,cAAmB,EAAE,oBAAoB,CAAC;gBACtE,CAAC,CAAE,OAAO,CAAC,cAAoB;SAChC,CAAC;IACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tAlreadyExistsError,\n\tBaseError,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tNotFoundError,\n\tObjectHelper\n} from \"@twin.org/core\";\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\nimport { ComparisonOperator } from \"@twin.org/entity\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport type { IIdentityProfileConnector } from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IdentityProfile } from \"./entities/identityProfile.js\";\nimport type { IEntityStorageIdentityProfileConnectorConstructorOptions } from \"./models/IEntityStorageIdentityProfileConnectorConstructorOptions.js\";\n\n/**\n * Class which implements the identity profile connector contract.\n */\nexport class EntityStorageIdentityProfileConnector<\n\tT extends IJsonLdDocument = IJsonLdDocument,\n\tU extends IJsonLdDocument = IJsonLdDocument\n> implements IIdentityProfileConnector<T, U> {\n\t/**\n\t * The namespace supported by the identity profile connector.\n\t */\n\tpublic static readonly NAMESPACE: string = \"entity-storage\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageIdentityProfileConnector>();\n\n\t/**\n\t * The storage connector for the profiles.\n\t * @internal\n\t */\n\tprivate readonly _profileEntityStorage: IEntityStorageConnector<IdentityProfile>;\n\n\t/**\n\t * Create a new instance of EntityStorageIdentityProfileConnector.\n\t * @param options The options for the identity service.\n\t */\n\tconstructor(options?: IEntityStorageIdentityProfileConnectorConstructorOptions) {\n\t\tthis._profileEntityStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.profileEntityStorageType ?? \"identity-profile\"\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 EntityStorageIdentityProfileConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create the profile properties for an identity.\n\t * @param identity The identity of the profile to create.\n\t * @param publicProfile The public profile data.\n\t * @param privateProfile The private profile data.\n\t * @returns A promise that resolves when the profile has been created.\n\t */\n\tpublic async create(identity: string, publicProfile?: T, privateProfile?: U): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\n\t\t\tif (!Is.empty(profile)) {\n\t\t\t\tthrow new AlreadyExistsError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"alreadyExists\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this._profileEntityStorage.set({\n\t\t\t\tidentity,\n\t\t\t\tpublicProfile,\n\t\t\t\tprivateProfile\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"createFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the profile properties for an identity.\n\t * @param identity The identity of the item to get.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @returns The items properties.\n\t */\n\tpublic async get(\n\t\tidentity: string,\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[]\n\t): Promise<{\n\t\tpublicProfile: Partial<T>;\n\t\tprivateProfile: Partial<U>;\n\t}> {\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (!profile) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"identityNotFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn this.pickProperties(profile, publicPropertyNames, privatePropertyNames);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"getFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Update the profile properties of an identity.\n\t * @param identity The identity to update.\n\t * @param publicProfile The public profile data.\n\t * @param privateProfile The private profile data.\n\t * @returns A promise that resolves when the profile has been updated.\n\t */\n\tpublic async update(identity: string, publicProfile?: T, privateProfile?: U): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (Is.empty(profile)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"notFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tprofile.publicProfile = publicProfile ?? profile.publicProfile;\n\t\t\tprofile.privateProfile = privateProfile ?? profile.privateProfile;\n\n\t\t\tawait this._profileEntityStorage.set(profile);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"updateFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Delete the profile for an identity.\n\t * @param identity The identity to delete.\n\t * @returns A promise that resolves when the profile has been removed.\n\t */\n\tpublic async remove(identity: string): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (Is.empty(profile)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"notFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this._profileEntityStorage.remove(identity);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"removeFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get a list of the requested types.\n\t * @param publicFilters The filters to apply to the identities public profiles.\n\t * @param privateFilters The filters to apply to the identities private profiles.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @param cursor The cursor for paged requests.\n\t * @param limit The maximum number of items in a page.\n\t * @returns The list of items and cursor for paging.\n\t */\n\tpublic async list(\n\t\tpublicFilters?: {\n\t\t\tpropertyName: string;\n\t\t\tpropertyValue: unknown;\n\t\t}[],\n\t\tprivateFilters?: {\n\t\t\tpropertyName: string;\n\t\t\tpropertyValue: unknown;\n\t\t}[],\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[],\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\t/**\n\t\t * The identities.\n\t\t */\n\t\titems: {\n\t\t\tidentity: string;\n\t\t\tpublicProfile?: Partial<T>;\n\t\t\tprivateProfile?: Partial<U>;\n\t\t}[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}> {\n\t\ttry {\n\t\t\tconst conditions = [];\n\n\t\t\tif (Is.arrayValue(publicFilters)) {\n\t\t\t\tfor (const filter of publicFilters) {\n\t\t\t\t\tconditions.push({\n\t\t\t\t\t\tproperty: `publicProfile.${filter.propertyName}`,\n\t\t\t\t\t\tvalue: filter.propertyValue,\n\t\t\t\t\t\tcomparison: ComparisonOperator.Equals\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Is.arrayValue(privateFilters)) {\n\t\t\t\tfor (const filter of privateFilters) {\n\t\t\t\t\tconditions.push({\n\t\t\t\t\t\tproperty: `privateProfile.${filter.propertyName}`,\n\t\t\t\t\t\tvalue: filter.propertyValue,\n\t\t\t\t\t\tcomparison: ComparisonOperator.Equals\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst result = await this._profileEntityStorage.query(\n\t\t\t\tIs.arrayValue(conditions)\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tconditions\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\tcursor,\n\t\t\t\tlimit\n\t\t\t);\n\n\t\t\tconst items: {\n\t\t\t\tidentity: string;\n\t\t\t\tpublicProfile?: Partial<T>;\n\t\t\t\tprivateProfile?: Partial<U>;\n\t\t\t}[] = [];\n\t\t\tfor (const resultEntity of result.entities) {\n\t\t\t\titems.push({\n\t\t\t\t\tidentity: resultEntity.identity ?? \"\",\n\t\t\t\t\t...this.pickProperties(resultEntity, publicPropertyNames, privatePropertyNames)\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\titems,\n\t\t\t\tcursor: result.cursor\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"listFailed\",\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 the profile properties for an identity.\n\t * @param profile The profile to pick the properties from.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @returns The identity profile, will only return private data if you have correct permissions.\n\t * @internal\n\t */\n\tprivate pickProperties(\n\t\tprofile: Partial<IdentityProfile>,\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[]\n\t): {\n\t\tpublicProfile: Partial<T>;\n\t\tprivateProfile: Partial<U>;\n\t} {\n\t\treturn {\n\t\t\tpublicProfile: Is.array(publicPropertyNames)\n\t\t\t\t? ObjectHelper.pick(profile.publicProfile as T, publicPropertyNames)\n\t\t\t\t: (profile.publicProfile as T),\n\t\t\tprivateProfile: Is.array(privatePropertyNames)\n\t\t\t\t? ObjectHelper.pick(profile.privateProfile as U, privatePropertyNames)\n\t\t\t\t: (profile.privateProfile as U)\n\t\t};\n\t}\n}\n"]}
@@ -34,7 +34,7 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
34
34
  * Remove a document.
35
35
  * @param controller The controller of the identity who can make changes.
36
36
  * @param documentId The id of the document to remove.
37
- * @returns Nothing.
37
+ * @returns A promise that resolves when the document has been removed.
38
38
  */
39
39
  removeDocument(controller: string, documentId: string): Promise<void>;
40
40
  /**
@@ -52,7 +52,7 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
52
52
  * Remove a verification method from the document.
53
53
  * @param controller The controller of the identity who can make changes.
54
54
  * @param verificationMethodId The id of the verification method.
55
- * @returns Nothing.
55
+ * @returns A promise that resolves when the verification method has been removed.
56
56
  * @throws NotFoundError if the id can not be resolved.
57
57
  * @throws NotSupportedError if the platform does not support multiple revocable keys.
58
58
  */
@@ -72,7 +72,7 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
72
72
  * Remove a service from the document.
73
73
  * @param controller The controller of the identity who can make changes.
74
74
  * @param serviceId The id of the service.
75
- * @returns Nothing.
75
+ * @returns A promise that resolves when the service has been removed.
76
76
  * @throws NotFoundError if the id can not be resolved.
77
77
  */
78
78
  removeService(controller: string, serviceId: string): Promise<void>;
@@ -82,7 +82,7 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
82
82
  * @param controller The controller of the identity who can make changes.
83
83
  * @param documentId The id of the document to update.
84
84
  * @param alias The alias to add. Must be a Url or Urn (typically another DID).
85
- * @returns Nothing.
85
+ * @returns A promise that resolves when the alias has been added.
86
86
  * @throws GeneralError if the alias is not a Url or Urn.
87
87
  * @throws NotFoundError if the id can not be resolved.
88
88
  */
@@ -93,7 +93,7 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
93
93
  * @param controller The controller of the identity who can make changes.
94
94
  * @param documentId The id of the document to update.
95
95
  * @param alias The alias to remove. Must be a Url or Urn.
96
- * @returns Nothing.
96
+ * @returns A promise that resolves when the alias has been removed.
97
97
  * @throws GeneralError if the alias is not a Url or Urn.
98
98
  * @throws NotFoundError if the id can not be resolved.
99
99
  */
@@ -139,7 +139,7 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
139
139
  * @param controller The controller of the identity who can make changes.
140
140
  * @param issuerDocumentId The id of the document to update the revocation list for.
141
141
  * @param credentialIndices The revocation bitmap index or indices to revoke.
142
- * @returns Nothing.
142
+ * @returns A promise that resolves when the credentials have been revoked.
143
143
  */
144
144
  revokeVerifiableCredentials(controller: string, issuerDocumentId: string, credentialIndices: number[]): Promise<void>;
145
145
  /**
@@ -147,7 +147,7 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
147
147
  * @param controller The controller of the identity who can make changes.
148
148
  * @param issuerDocumentId The id of the document to update the revocation list for.
149
149
  * @param credentialIndices The revocation bitmap index or indices to un revoke.
150
- * @returns Nothing.
150
+ * @returns A promise that resolves when the credentials have been unrevoked.
151
151
  */
152
152
  unrevokeVerifiableCredentials(controller: string, issuerDocumentId: string, credentialIndices: number[]): Promise<void>;
153
153
  /**
@@ -28,7 +28,7 @@ export declare class EntityStorageIdentityProfileConnector<T extends IJsonLdDocu
28
28
  * @param identity The identity of the profile to create.
29
29
  * @param publicProfile The public profile data.
30
30
  * @param privateProfile The private profile data.
31
- * @returns Nothing.
31
+ * @returns A promise that resolves when the profile has been created.
32
32
  */
33
33
  create(identity: string, publicProfile?: T, privateProfile?: U): Promise<void>;
34
34
  /**
@@ -47,13 +47,13 @@ export declare class EntityStorageIdentityProfileConnector<T extends IJsonLdDocu
47
47
  * @param identity The identity to update.
48
48
  * @param publicProfile The public profile data.
49
49
  * @param privateProfile The private profile data.
50
- * @returns Nothing.
50
+ * @returns A promise that resolves when the profile has been updated.
51
51
  */
52
52
  update(identity: string, publicProfile?: T, privateProfile?: U): Promise<void>;
53
53
  /**
54
54
  * Delete the profile for an identity.
55
55
  * @param identity The identity to delete.
56
- * @returns Nothing.
56
+ * @returns A promise that resolves when the profile has been removed.
57
57
  */
58
58
  remove(identity: string): Promise<void>;
59
59
  /**
package/docs/changelog.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @twin.org/identity-connector-entity-storage- Changelog
2
2
 
3
+ ## [0.0.3-next.36](https://github.com/iotaledger/twin-identity/compare/identity-connector-entity-storage-v0.0.3-next.35...identity-connector-entity-storage-v0.0.3-next.36) (2026-06-17)
4
+
5
+
6
+ ### Features
7
+
8
+ * add vault signing ([#153](https://github.com/iotaledger/twin-identity/issues/153)) ([9458e4c](https://github.com/iotaledger/twin-identity/commit/9458e4c96ce19e0fc704905dfb3aac04dc6cf237))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * use async getStore in tests ([cfc0d87](https://github.com/iotaledger/twin-identity/commit/cfc0d873532e8ab2010f86f05bffaad3bbaf5786))
14
+ * use async getStore in tests ([3424c81](https://github.com/iotaledger/twin-identity/commit/3424c81cf7407ede4a89a026072720d52bf689b2))
15
+
16
+
17
+ ### Dependencies
18
+
19
+ * The following workspace dependencies were updated
20
+ * dependencies
21
+ * @twin.org/identity-models bumped from 0.0.3-next.35 to 0.0.3-next.36
22
+
23
+ ## [0.0.3-next.35](https://github.com/iotaledger/twin-identity/compare/identity-connector-entity-storage-v0.0.3-next.34...identity-connector-entity-storage-v0.0.3-next.35) (2026-06-01)
24
+
25
+
26
+ ### Miscellaneous Chores
27
+
28
+ * **identity-connector-entity-storage:** Synchronize repo versions
29
+
30
+
31
+ ### Dependencies
32
+
33
+ * The following workspace dependencies were updated
34
+ * dependencies
35
+ * @twin.org/identity-models bumped from 0.0.3-next.34 to 0.0.3-next.35
36
+
3
37
  ## [0.0.3-next.34](https://github.com/iotaledger/twin-identity/compare/identity-connector-entity-storage-v0.0.3-next.33...identity-connector-entity-storage-v0.0.3-next.34) (2026-06-01)
4
38
 
5
39
 
@@ -112,7 +112,7 @@ The id of the document to remove.
112
112
 
113
113
  `Promise`\<`void`\>
114
114
 
115
- Nothing.
115
+ A promise that resolves when the document has been removed.
116
116
 
117
117
  #### Implementation of
118
118
 
@@ -196,7 +196,7 @@ The id of the verification method.
196
196
 
197
197
  `Promise`\<`void`\>
198
198
 
199
- Nothing.
199
+ A promise that resolves when the verification method has been removed.
200
200
 
201
201
  #### Throws
202
202
 
@@ -290,7 +290,7 @@ The id of the service.
290
290
 
291
291
  `Promise`\<`void`\>
292
292
 
293
- Nothing.
293
+ A promise that resolves when the service has been removed.
294
294
 
295
295
  #### Throws
296
296
 
@@ -333,7 +333,7 @@ The alias to add. Must be a Url or Urn (typically another DID).
333
333
 
334
334
  `Promise`\<`void`\>
335
335
 
336
- Nothing.
336
+ A promise that resolves when the alias has been added.
337
337
 
338
338
  #### Throws
339
339
 
@@ -380,7 +380,7 @@ The alias to remove. Must be a Url or Urn.
380
380
 
381
381
  `Promise`\<`void`\>
382
382
 
383
- Nothing.
383
+ A promise that resolves when the alias has been removed.
384
384
 
385
385
  #### Throws
386
386
 
@@ -528,7 +528,7 @@ The revocation bitmap index or indices to revoke.
528
528
 
529
529
  `Promise`\<`void`\>
530
530
 
531
- Nothing.
531
+ A promise that resolves when the credentials have been revoked.
532
532
 
533
533
  #### Implementation of
534
534
 
@@ -566,7 +566,7 @@ The revocation bitmap index or indices to un revoke.
566
566
 
567
567
  `Promise`\<`void`\>
568
568
 
569
- Nothing.
569
+ A promise that resolves when the credentials have been unrevoked.
570
570
 
571
571
  #### Implementation of
572
572
 
@@ -102,7 +102,7 @@ The private profile data.
102
102
 
103
103
  `Promise`\<`void`\>
104
104
 
105
- Nothing.
105
+ A promise that resolves when the profile has been created.
106
106
 
107
107
  #### Implementation of
108
108
 
@@ -178,7 +178,7 @@ The private profile data.
178
178
 
179
179
  `Promise`\<`void`\>
180
180
 
181
- Nothing.
181
+ A promise that resolves when the profile has been updated.
182
182
 
183
183
  #### Implementation of
184
184
 
@@ -204,7 +204,7 @@ The identity to delete.
204
204
 
205
205
  `Promise`\<`void`\>
206
206
 
207
- Nothing.
207
+ A promise that resolves when the profile has been removed.
208
208
 
209
209
  #### Implementation of
210
210
 
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.34",
3
+ "version": "0.0.3-next.36",
4
4
  "description": "Entity storage connector for persisting and retrieving identity records through a consistent data layer.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@
19
19
  "@twin.org/data-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.34",
22
+ "@twin.org/identity-models": "0.0.3-next.36",
23
23
  "@twin.org/nameof": "next",
24
24
  "@twin.org/standards-w3c-did": "next",
25
25
  "@twin.org/vault-models": "next",