@twin.org/identity-connector-entity-storage 0.0.2-next.9 → 0.0.3-next.2

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.
Files changed (31) hide show
  1. package/dist/es/entities/identityDocument.js +45 -0
  2. package/dist/es/entities/identityDocument.js.map +1 -0
  3. package/dist/es/entities/identityProfile.js +37 -0
  4. package/dist/es/entities/identityProfile.js.map +1 -0
  5. package/dist/{esm/index.mjs → es/entityStorageIdentityConnector.js} +18 -355
  6. package/dist/es/entityStorageIdentityConnector.js.map +1 -0
  7. package/dist/es/entityStorageIdentityProfileConnector.js +203 -0
  8. package/dist/es/entityStorageIdentityProfileConnector.js.map +1 -0
  9. package/dist/es/entityStorageIdentityResolverConnector.js +65 -0
  10. package/dist/es/entityStorageIdentityResolverConnector.js.map +1 -0
  11. package/dist/es/index.js +12 -0
  12. package/dist/es/index.js.map +1 -0
  13. package/dist/es/models/IEntityStorageIdentityConnectorConstructorOptions.js +2 -0
  14. package/dist/es/models/IEntityStorageIdentityConnectorConstructorOptions.js.map +1 -0
  15. package/dist/es/models/IEntityStorageIdentityProfileConnectorConstructorOptions.js +4 -0
  16. package/dist/es/models/IEntityStorageIdentityProfileConnectorConstructorOptions.js.map +1 -0
  17. package/dist/es/models/IEntityStorageIdentityResolverConnectorConstructorOptions.js +4 -0
  18. package/dist/es/models/IEntityStorageIdentityResolverConnectorConstructorOptions.js.map +1 -0
  19. package/dist/es/schema.js +20 -0
  20. package/dist/es/schema.js.map +1 -0
  21. package/dist/types/entityStorageIdentityConnector.d.ts +6 -1
  22. package/dist/types/entityStorageIdentityProfileConnector.d.ts +6 -1
  23. package/dist/types/entityStorageIdentityResolverConnector.d.ts +6 -1
  24. package/dist/types/index.d.ts +9 -9
  25. package/dist/types/models/IEntityStorageIdentityConnectorConstructorOptions.d.ts +1 -1
  26. package/docs/changelog.md +57 -0
  27. package/docs/reference/classes/EntityStorageIdentityConnector.md +22 -4
  28. package/docs/reference/classes/EntityStorageIdentityProfileConnector.md +18 -0
  29. package/docs/reference/classes/EntityStorageIdentityResolverConnector.md +18 -0
  30. package/package.json +6 -8
  31. package/dist/cjs/index.cjs +0 -1326
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entityStorageIdentityConnector.js","sourceRoot":"","sources":["../../src/entityStorageIdentityConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,SAAS,EACT,SAAS,EACT,MAAM,EACN,WAAW,EACX,eAAe,EACf,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,UAAU,EACV,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,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,EACzB,WAAW,EACX,UAAU,EAOV,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EAEZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAgD,MAAM,eAAe,CAAC;AAIvF;;GAEG;AACH,MAAM,OAAO,8BAA8B;IAC1C;;OAEG;IACI,MAAM,CAAU,UAAU,oCAAoD;IAErF;;OAEG;IACI,MAAM,CAAU,SAAS,GAAW,gBAAgB,CAAC;IAE5D;;;OAGG;IACK,MAAM,CAAU,qBAAqB,GAAW,MAAM,CAAC;IAE/D;;;OAGG;IACgB,yBAAyB,CAA4C;IAExF;;;OAGG;IACgB,eAAe,CAAkB;IAEpD;;;OAGG;IACH,YAAY,OAA2D;QACtE,IAAI,CAAC,yBAAyB,GAAG,6BAA6B,CAAC,GAAG,CACjE,OAAO,EAAE,4BAA4B,IAAI,mBAA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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\tBaseError,\n\tBitString,\n\tCoerce,\n\tCompression,\n\tCompressionType,\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tJsonHelper,\n\tNotFoundError,\n\tObjectHelper,\n\tRandomHelper\n} from \"@twin.org/core\";\nimport {\n\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\tProofHelper,\n\tProofTypes,\n\ttype IDidDocument,\n\ttype IDidDocumentVerificationMethod,\n\ttype IDidService,\n\ttype IDidVerifiableCredentialV1,\n\ttype IDidVerifiablePresentationV1,\n\ttype IProof\n} from \"@twin.org/standards-w3c-did\";\nimport {\n\tVaultConnectorFactory,\n\tVaultConnectorHelper,\n\tVaultKeyType,\n\ttype IVaultConnector\n} from \"@twin.org/vault-models\";\nimport { Jwk, Jwt, type IJwk, type IJwtHeader, type IJwtPayload } from \"@twin.org/web\";\nimport type { IdentityDocument } from \"./entities/identityDocument.js\";\nimport type { IEntityStorageIdentityConnectorConstructorOptions } from \"./models/IEntityStorageIdentityConnectorConstructorOptions.js\";\n\n/**\n * Class for performing identity operations using entity storage.\n */\nexport class EntityStorageIdentityConnector implements IIdentityConnector {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageIdentityConnector>();\n\n\t/**\n\t * The namespace supported by the identity connector.\n\t */\n\tpublic static readonly NAMESPACE: string = \"entity-storage\";\n\n\t/**\n\t * The size of the revocation bitmap in bits (16Kb).\n\t * @internal\n\t */\n\tprivate static readonly _REVOCATION_BITS_SIZE: number = 131072;\n\n\t/**\n\t * The entity storage for identities.\n\t * @internal\n\t */\n\tprotected readonly _didDocumentEntityStorage: IEntityStorageConnector<IdentityDocument>;\n\n\t/**\n\t * The vault for the keys.\n\t * @internal\n\t */\n\tprotected readonly _vaultConnector: IVaultConnector;\n\n\t/**\n\t * Create a new instance of EntityStorageIdentityConnector.\n\t * @param options The options for the identity connector.\n\t */\n\tconstructor(options?: IEntityStorageIdentityConnectorConstructorOptions) {\n\t\tthis._didDocumentEntityStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.didDocumentEntityStorageType ?? \"identity-document\"\n\t\t);\n\t\tthis._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? \"vault\");\n\t}\n\n\t/**\n\t * Build the key name to access the specified key in the vault.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @returns The vault key.\n\t * @internal\n\t */\n\tpublic static buildVaultKey(identity: string, key: string): string {\n\t\treturn `${identity}/${key}`;\n\t}\n\n\t/**\n\t * Verify the document in storage.\n\t * @param didDocument The did document that was stored.\n\t * @internal\n\t */\n\tpublic static async verifyDocument(\n\t\tdidDocument: IdentityDocument,\n\t\tvaultConnector: IVaultConnector\n\t): Promise<void> {\n\t\tconst stringifiedDocument = JsonHelper.canonicalize(didDocument.document);\n\t\tconst docBytes = Converter.utf8ToBytes(stringifiedDocument);\n\n\t\tconst verified = await vaultConnector.verify(\n\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, \"did\"),\n\t\t\tdocBytes,\n\t\t\tConverter.base64ToBytes(didDocument.signature)\n\t\t);\n\n\t\tif (!verified) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"signatureVerificationFailed\"\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageIdentityConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create a new document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns The created document.\n\t */\n\tpublic async createDocument(controller: string): Promise<IDidDocument> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\n\t\ttry {\n\t\t\tconst did = `did:${EntityStorageIdentityConnector.NAMESPACE}:${Converter.bytesToHex(RandomHelper.generate(32), true)}`;\n\n\t\t\tawait this._vaultConnector.createKey(\n\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(did, \"did\"),\n\t\t\t\tVaultKeyType.Ed25519\n\t\t\t);\n\n\t\t\tconst bitString = new BitString(EntityStorageIdentityConnector._REVOCATION_BITS_SIZE);\n\t\t\tconst compressed = await Compression.compress(bitString.getBits(), CompressionType.Gzip);\n\n\t\t\tconst didDocument: IDidDocument = {\n\t\t\t\t\"@context\": DidContexts.Context,\n\t\t\t\tid: did,\n\t\t\t\tservice: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${did}#revocation`,\n\t\t\t\t\t\ttype: \"BitstringStatusList\",\n\t\t\t\t\t\tserviceEndpoint: `data:application/octet-stream;base64,${Converter.bytesToBase64Url(compressed)}`\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t};\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\n\t\t\treturn didDocument;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createDocumentFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove a document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to remove.\n\t * @returns Nothing.\n\t */\n\tpublic async removeDocument(controller: string, documentId: string): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\n\t\ttry {\n\t\t\tconst didDocument = await this._didDocumentEntityStorage.get(documentId);\n\t\t\tif (Is.empty(didDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tdocumentId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this._didDocumentEntityStorage.remove(documentId);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeDocumentFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Add a verification method to the document in JSON Web key Format.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to add the verification method to.\n\t * @param verificationMethodType The type of the verification method to add.\n\t * @param verificationMethodId The id of the verification method, if undefined uses the kid of the generated JWK.\n\t * @returns The verification method.\n\t * @throws NotFoundError if the id can not be resolved.\n\t * @throws NotSupportedError if the platform does not support multiple keys.\n\t */\n\tpublic async addVerificationMethod(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\tverificationMethodType: DidVerificationMethodType,\n\t\tverificationMethodId?: string\n\t): Promise<IDidDocumentVerificationMethod> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.arrayOneOf<DidVerificationMethodType>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodType),\n\t\t\tverificationMethodType,\n\t\t\tObject.values(DidVerificationMethodType)\n\t\t);\n\n\t\tlet tempKeyId;\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this._didDocumentEntityStorage.get(documentId);\n\t\t\tif (Is.undefined(didIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tdocumentId\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tdidIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tlet methodKeyPublic;\n\t\t\tif (Is.stringValue(verificationMethodId)) {\n\t\t\t\t// If there is a verification method id, we will try to get the key from the vault.\n\t\t\t\ttry {\n\t\t\t\t\tconst defaultMethodId = `${controller}/${verificationMethodId}`;\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(defaultMethodId);\n\t\t\t\t\tmethodKeyPublic = existingKey.publicKey;\n\t\t\t\t} catch {}\n\t\t\t}\n\n\t\t\tif (Is.empty(methodKeyPublic)) {\n\t\t\t\t// If there is no existing key, we will create a new one with a temporary name.\n\t\t\t\ttempKeyId = `temp-vm-${Converter.bytesToBase64Url(RandomHelper.generate(16))}`;\n\t\t\t\tmethodKeyPublic = await this._vaultConnector.createKey(\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, tempKeyId),\n\t\t\t\t\tVaultKeyType.Ed25519\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst jwkParams: IJwk = {\n\t\t\t\talg: \"EdDSA\",\n\t\t\t\tkty: \"OKP\",\n\t\t\t\tcrv: \"Ed25519\",\n\t\t\t\tx: Converter.bytesToBase64Url(methodKeyPublic)\n\t\t\t};\n\n\t\t\tconst kid = await Jwk.generateKid(jwkParams);\n\n\t\t\tconst methodId = `${documentId}#${verificationMethodId ?? kid}`;\n\n\t\t\tif (Is.stringValue(tempKeyId)) {\n\t\t\t\t// If we created a temporary key, we will rename it to the final method id.\n\t\t\t\tawait this._vaultConnector.renameKey(\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, tempKeyId),\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, verificationMethodId ?? kid)\n\t\t\t\t);\n\t\t\t\ttempKeyId = undefined;\n\t\t\t}\n\n\t\t\tconst methods = this.getAllMethods(didDocument);\n\t\t\tconst existingMethodIndex = methods.findIndex(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === methodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === methodId;\n\t\t\t});\n\n\t\t\tif (existingMethodIndex !== -1) {\n\t\t\t\tconst methodArray =\n\t\t\t\t\tdidDocument[methods[existingMethodIndex].arrayKey as keyof IDidDocument];\n\n\t\t\t\tif (Is.array(methodArray)) {\n\t\t\t\t\tmethodArray.splice(existingMethodIndex, 1);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst didVerificationMethod: IDidDocumentVerificationMethod = {\n\t\t\t\tid: methodId,\n\t\t\t\tcontroller: documentId,\n\t\t\t\ttype: \"JsonWebKey\",\n\t\t\t\tpublicKeyJwk: {\n\t\t\t\t\t...jwkParams,\n\t\t\t\t\tkid\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tdidDocument[verificationMethodType] ??= [];\n\t\t\tdidDocument[verificationMethodType]?.push(didVerificationMethod);\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\n\t\t\treturn didVerificationMethod;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"addVerificationMethodFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t} finally {\n\t\t\tif (Is.stringValue(tempKeyId)) {\n\t\t\t\t// If we created a temporary key and it is still in use, we will remove it from the vault.\n\t\t\t\ttry {\n\t\t\t\t\tawait this._vaultConnector.removeKey(tempKeyId);\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Remove a verification method from the document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The id of the verification method.\n\t * @returns Nothing.\n\t * @throws NotFoundError if the id can not be resolved.\n\t * @throws NotSupportedError if the platform does not support multiple revocable keys.\n\t */\n\tpublic async removeVerificationMethod(\n\t\tcontroller: string,\n\t\tverificationMethodId: string\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst didIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);\n\t\t\tif (Is.undefined(didIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tidParts.id\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tdidIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tconst methods = this.getAllMethods(didDocument);\n\t\t\tconst existingMethodIndex = methods.findIndex(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === verificationMethodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === verificationMethodId;\n\t\t\t});\n\n\t\t\tif (existingMethodIndex !== -1) {\n\t\t\t\tconst methodArray =\n\t\t\t\t\tdidDocument[methods[existingMethodIndex].arrayKey as keyof IDidDocument];\n\n\t\t\t\tif (Is.array(methodArray)) {\n\t\t\t\t\tmethodArray.splice(existingMethodIndex, 1);\n\t\t\t\t\tif (methodArray.length === 0) {\n\t\t\t\t\t\tdelete didDocument[methods[existingMethodIndex].arrayKey as keyof IDidDocument];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"verificationMethodNotFound\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeVerificationMethodFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Add a service to the document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to add the service to.\n\t * @param serviceId The id of the service.\n\t * @param serviceType The type of the service.\n\t * @param serviceEndpoint The endpoint for the service.\n\t * @returns The service.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async addService(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\tserviceId: string,\n\t\tserviceType: string | string[],\n\t\tserviceEndpoint: string | string[]\n\t): Promise<IDidService> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(serviceId), serviceId);\n\t\tif (Is.array(serviceType)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(serviceType),\n\t\t\t\tserviceType\n\t\t\t);\n\t\t} else {\n\t\t\tGuards.stringValue(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(serviceType),\n\t\t\t\tserviceType\n\t\t\t);\n\t\t}\n\t\tif (Is.array(serviceEndpoint)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(serviceEndpoint),\n\t\t\t\tserviceEndpoint\n\t\t\t);\n\t\t} else {\n\t\t\tGuards.stringValue(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(serviceEndpoint),\n\t\t\t\tserviceEndpoint\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this._didDocumentEntityStorage.get(documentId);\n\t\t\tif (Is.undefined(didIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tdocumentId\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tdidIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tconst fullServiceId = serviceId.includes(\"#\") ? serviceId : `${documentId}#${serviceId}`;\n\n\t\t\tif (Is.array(didDocument.service)) {\n\t\t\t\tconst existingServiceIndex = didDocument.service.findIndex(s => s.id === fullServiceId);\n\t\t\t\tif (existingServiceIndex !== -1) {\n\t\t\t\t\tdidDocument.service?.splice(existingServiceIndex, 1);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst didService: IDidService = {\n\t\t\t\tid: fullServiceId,\n\t\t\t\ttype: serviceType,\n\t\t\t\tserviceEndpoint\n\t\t\t};\n\n\t\t\tdidDocument.service ??= [];\n\t\t\tdidDocument.service.push(didService);\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\n\t\t\treturn didService;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"addServiceFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove a service from the document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param serviceId The id of the service.\n\t * @returns Nothing.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async removeService(controller: string, serviceId: string): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(serviceId), serviceId);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(serviceId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, \"missingDid\", serviceId);\n\t\t\t}\n\n\t\t\tconst didIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);\n\t\t\tif (Is.undefined(didIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tidParts.id\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tdidIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tif (Is.array(didDocument.service)) {\n\t\t\t\tconst existingServiceIndex = didDocument.service.findIndex(s => s.id === serviceId);\n\t\t\t\tif (existingServiceIndex !== -1) {\n\t\t\t\t\tdidDocument.service?.splice(existingServiceIndex, 1);\n\t\t\t\t\tif (didDocument.service?.length === 0) {\n\t\t\t\t\t\tdelete didDocument.service;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"serviceNotFound\",\n\t\t\t\t\tserviceId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeServiceFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a verifiable credential for a verification method.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param id The id of the credential.\n\t * @param subject The credential subject to store in the verifiable credential.\n\t * @param options Additional options for creating the verifiable credential.\n\t * @param options.revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.\n\t * @param options.expirationDate The date the verifiable credential is valid until.\n\t * @returns The created verifiable credential and its token.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async createVerifiableCredential(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\tid: string | undefined,\n\t\tsubject: IJsonLdNodeObject,\n\t\toptions?: {\n\t\t\trevocationIndex?: number;\n\t\t\texpirationDate?: Date;\n\t\t}\n\t): Promise<{\n\t\tverifiableCredential: IDidVerifiableCredentialV1;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(subject),\n\t\t\tsubject\n\t\t);\n\t\tif (!Is.undefined(options?.revocationIndex)) {\n\t\t\tGuards.number(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(options.revocationIndex),\n\t\t\t\toptions.revocationIndex\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst issuerIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);\n\t\t\tif (Is.undefined(issuerIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tidParts.id\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tissuerIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\t\t\tconst issuerDidDocument = issuerIdentityDocument.document;\n\n\t\t\tconst methods = this.getAllMethods(issuerDidDocument);\n\t\t\tconst methodAndArray = methods.find(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === verificationMethodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === verificationMethodId;\n\t\t\t});\n\n\t\t\tif (!methodAndArray) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"methodMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst verificationDidMethod = methodAndArray.method;\n\t\t\tif (!Is.stringValue(verificationDidMethod.publicKeyJwk?.x)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"publicKeyJwkMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst revocationService = issuerDidDocument.service?.find(s => s.id.endsWith(\"#revocation\"));\n\n\t\t\tconst subjectClone = ObjectHelper.clone(subject);\n\n\t\t\tconst finalTypes: string[] = [DidTypes.VerifiableCredential];\n\t\t\tconst credContext = ObjectHelper.extractProperty<IJsonLdContextDefinitionRoot>(subjectClone, [\n\t\t\t\t\"@context\"\n\t\t\t]);\n\t\t\tconst credId = ObjectHelper.extractProperty<string>(subjectClone, [\"@id\", \"id\"], false);\n\t\t\tconst credType = ObjectHelper.extractProperty<string>(subjectClone, [\"@type\", \"type\"]);\n\t\t\tif (Is.stringValue(credType)) {\n\t\t\t\tfinalTypes.push(credType);\n\t\t\t}\n\n\t\t\tconst verifiableCredential: IDidVerifiableCredentialV1 = {\n\t\t\t\t\"@context\": JsonLdProcessor.combineContexts(DidContexts.ContextVCv1, credContext) as [\n\t\t\t\t\ttypeof DidContexts.ContextVCv1\n\t\t\t\t],\n\t\t\t\tid,\n\t\t\t\ttype: finalTypes,\n\t\t\t\tcredentialSubject: subjectClone,\n\t\t\t\tissuer: issuerDidDocument.id,\n\t\t\t\tissuanceDate: new Date(Date.now()).toISOString(),\n\t\t\t\texpirationDate: Is.date(options?.expirationDate)\n\t\t\t\t\t? options?.expirationDate.toISOString()\n\t\t\t\t\t: undefined,\n\t\t\t\tcredentialStatus:\n\t\t\t\t\trevocationService && !Is.undefined(options?.revocationIndex)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tid: revocationService.id,\n\t\t\t\t\t\t\t\ttype: Is.array(revocationService.type)\n\t\t\t\t\t\t\t\t\t? revocationService.type[0]\n\t\t\t\t\t\t\t\t\t: revocationService.type,\n\t\t\t\t\t\t\t\trevocationBitmapIndex: options.revocationIndex.toString()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined\n\t\t\t};\n\n\t\t\tconst jwtHeader: IJwtHeader = {\n\t\t\t\tkid: verificationDidMethod.id,\n\t\t\t\ttyp: \"JWT\",\n\t\t\t\talg: \"EdDSA\"\n\t\t\t};\n\n\t\t\tconst jwtVc = ObjectHelper.pick(ObjectHelper.clone(verifiableCredential), [\n\t\t\t\t\"@context\",\n\t\t\t\t\"type\",\n\t\t\t\t\"credentialSubject\",\n\t\t\t\t\"credentialStatus\"\n\t\t\t]);\n\n\t\t\tif (Is.array(jwtVc.credentialSubject)) {\n\t\t\t\tjwtVc.credentialSubject = jwtVc.credentialSubject.map(c => {\n\t\t\t\t\tObjectHelper.propertyDelete(c, \"id\");\n\t\t\t\t\treturn c;\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tObjectHelper.propertyDelete(jwtVc.credentialSubject, \"id\");\n\t\t\t}\n\n\t\t\tconst jwtPayload: IJwtPayload = {\n\t\t\t\tiss: idParts.id,\n\t\t\t\tnbf: Math.floor(Date.now() / 1000),\n\t\t\t\tjti: verifiableCredential.id,\n\t\t\t\tsub: credId,\n\t\t\t\tvc: jwtVc\n\t\t\t};\n\n\t\t\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 credentialJwt The credential to verify.\n\t * @returns The credential stored in the jwt and the revocation status.\n\t */\n\tpublic async checkVerifiableCredential(credentialJwt: string): Promise<{\n\t\trevoked: boolean;\n\t\tverifiableCredential?: IDidVerifiableCredentialV1;\n\t}> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(credentialJwt),\n\t\t\tcredentialJwt\n\t\t);\n\n\t\ttry {\n\t\t\tconst jwtDecoded = await Jwt.decode(credentialJwt);\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(credentialJwt, 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 expiresInMinutes The time in minutes for the presentation to expire.\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\texpiresInMinutes?: number\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(expiresInMinutes)) {\n\t\t\tGuards.integer(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(expiresInMinutes),\n\t\t\t\texpiresInMinutes\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst holderIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);\n\t\t\tif (Is.undefined(holderIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tidParts.id\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tholderIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\t\t\tconst holderDidDocument = holderIdentityDocument.document;\n\n\t\t\tconst methods = this.getAllMethods(holderDidDocument);\n\t\t\tconst methodAndArray = methods.find(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === verificationMethodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === verificationMethodId;\n\t\t\t});\n\n\t\t\tif (!methodAndArray) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"methodMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst didMethod = methodAndArray.method;\n\t\t\tif (!Is.stringValue(didMethod.publicKeyJwk?.x)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"publicKeyJwkMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst finalTypes: string[] = [DidTypes.VerifiablePresentation];\n\t\t\tif (Is.array(types)) {\n\t\t\t\tfinalTypes.push(...types);\n\t\t\t} else if (Is.stringValue(types)) {\n\t\t\t\tfinalTypes.push(types);\n\t\t\t}\n\n\t\t\tconst verifiablePresentation: IDidVerifiablePresentationV1 = {\n\t\t\t\t\"@context\": JsonLdProcessor.combineContexts(DidContexts.ContextVCv1, contexts) as [\n\t\t\t\t\ttypeof DidContexts.ContextVCv1\n\t\t\t\t],\n\t\t\t\tid: presentationId,\n\t\t\t\ttype: finalTypes,\n\t\t\t\tverifiableCredential: verifiableCredentials,\n\t\t\t\tholder: idParts.id\n\t\t\t};\n\n\t\t\tconst jwtHeader: IJwtHeader = {\n\t\t\t\tkid: didMethod.id,\n\t\t\t\ttyp: \"JWT\",\n\t\t\t\talg: \"EdDSA\"\n\t\t\t};\n\n\t\t\tconst jwtVp = ObjectHelper.pick(ObjectHelper.clone(verifiablePresentation), [\n\t\t\t\t\"@context\",\n\t\t\t\t\"type\",\n\t\t\t\t\"verifiableCredential\"\n\t\t\t]);\n\n\t\t\tconst jwtPayload: IJwtPayload = {\n\t\t\t\tiss: idParts.id,\n\t\t\t\tnbf: Math.floor(Date.now() / 1000),\n\t\t\t\tvp: jwtVp\n\t\t\t};\n\n\t\t\tif (Is.integer(expiresInMinutes)) {\n\t\t\t\tconst expiresInSeconds = expiresInMinutes * 60;\n\t\t\t\tjwtPayload.exp = Math.floor(Date.now() / 1000) + expiresInSeconds;\n\t\t\t}\n\n\t\t\tconst signature = await Jwt.encodeWithSigner(jwtHeader, jwtPayload, async (header, payload) =>\n\t\t\t\tVaultConnectorHelper.jwtSigner(\n\t\t\t\t\tthis._vaultConnector,\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment ?? \"\"),\n\t\t\t\t\theader,\n\t\t\t\t\tpayload\n\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tverifiablePresentation,\n\t\t\t\tjwt: signature\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createVerifiablePresentationFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Check a verifiable presentation is valid.\n\t * @param presentationJwt The presentation to verify.\n\t * @returns The presentation stored in the jwt and the revocation status.\n\t */\n\tpublic async checkVerifiablePresentation(presentationJwt: string): Promise<{\n\t\trevoked: boolean;\n\t\tverifiablePresentation?: IDidVerifiablePresentationV1;\n\t\tissuers?: IDidDocument[];\n\t}> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(presentationJwt),\n\t\t\tpresentationJwt\n\t\t);\n\n\t\ttry {\n\t\t\tconst jwtDecoded = await Jwt.decode(presentationJwt);\n\n\t\t\tconst jwtHeader = jwtDecoded.header;\n\t\t\tconst jwtPayload = jwtDecoded.payload;\n\t\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\t\tif (\n\t\t\t\tIs.undefined(jwtHeader) ||\n\t\t\t\tIs.undefined(jwtPayload) ||\n\t\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\t\tIs.undefined(jwtSignature)\n\t\t\t) {\n\t\t\t\tthrow new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, \"jwkSignatureFailed\");\n\t\t\t}\n\n\t\t\tconst holderDocumentId = jwtPayload.iss;\n\t\t\tconst holderIdentityDocument = await this._didDocumentEntityStorage.get(holderDocumentId);\n\t\t\tif (Is.undefined(holderIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tholderDocumentId\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tholderIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\n\t\t\tconst issuers: IDidDocument[] = [];\n\t\t\tconst tokensRevoked: boolean[] = [];\n\t\t\tconst verifiablePresentation = jwtPayload?.vp as IDidVerifiablePresentationV1;\n\t\t\tif (\n\t\t\t\tIs.object<IDidVerifiablePresentationV1>(verifiablePresentation) &&\n\t\t\t\tIs.array(verifiablePresentation.verifiableCredential)\n\t\t\t) {\n\t\t\t\tfor (const vcJwt of verifiablePresentation.verifiableCredential) {\n\t\t\t\t\tlet revoked = true;\n\t\t\t\t\tif (Is.stringValue(vcJwt)) {\n\t\t\t\t\t\tconst jwt = await Jwt.decode(vcJwt);\n\n\t\t\t\t\t\tif (Is.string(jwt.payload?.iss)) {\n\t\t\t\t\t\t\tconst issuerDocumentId = jwt.payload.iss;\n\t\t\t\t\t\t\tverifiablePresentation.holder = issuerDocumentId;\n\n\t\t\t\t\t\t\tconst issuerDidDocument = await this._didDocumentEntityStorage.get(issuerDocumentId);\n\t\t\t\t\t\t\tif (Is.undefined(issuerDidDocument)) {\n\t\t\t\t\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\t\t\t\t\tissuerDocumentId\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\t\t\t\t\tissuerDidDocument,\n\t\t\t\t\t\t\t\tthis._vaultConnector\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tissuers.push({\n\t\t\t\t\t\t\t\t\"@context\": DidContexts.Context,\n\t\t\t\t\t\t\t\t...issuerDidDocument\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tconst vc = jwt.payload.vc as IDidVerifiableCredentialV1;\n\t\t\t\t\t\t\tif (Is.object<IDidVerifiableCredentialV1>(vc)) {\n\t\t\t\t\t\t\t\tconst credentialStatus = vc.credentialStatus;\n\t\t\t\t\t\t\t\tif (Is.object(credentialStatus)) {\n\t\t\t\t\t\t\t\t\trevoked = await this.checkRevocation(\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\"@context\": DidContexts.Context,\n\t\t\t\t\t\t\t\t\t\t\t...issuerDidDocument\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tcredentialStatus.revocationBitmapIndex\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} else if (Is.arrayValue(credentialStatus)) {\n\t\t\t\t\t\t\t\t\tfor (let i = 0; i < credentialStatus.length; i++) {\n\t\t\t\t\t\t\t\t\t\trevoked = await this.checkRevocation(\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\"@context\": DidContexts.Context,\n\t\t\t\t\t\t\t\t\t\t\t\t...issuerDidDocument\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\tcredentialStatus[i].revocationBitmapIndex\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\tif (revoked) {\n\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\trevoked = false;\n\t\t\t\t\t}\n\t\t\t\t\ttokensRevoked.push(revoked);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\trevoked: tokensRevoked.some(Boolean),\n\t\t\t\tverifiablePresentation,\n\t\t\t\tissuers\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (BaseError.isErrorMessage(error, /revoked/i)) {\n\t\t\t\treturn {\n\t\t\t\t\trevoked: true\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"checkingVerifiablePresentationFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a proof for arbitrary data with the specified verification method.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param proofType The type of proof to create.\n\t * @param unsecureDocument The unsecure document to create the proof for.\n\t * @returns The proof.\n\t */\n\tpublic async createProof(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\tproofType: ProofTypes,\n\t\tunsecureDocument: IJsonLdNodeObject\n\t): Promise<IProof> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.arrayOneOf<ProofTypes>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(proofType),\n\t\t\tproofType,\n\t\t\tObject.values(ProofTypes)\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(unsecureDocument),\n\t\t\tunsecureDocument\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst didIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);\n\t\t\tif (Is.undefined(didIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tidParts.id\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tdidIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tconst methods = this.getAllMethods(didDocument);\n\t\t\tconst methodAndArray = methods.find(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === verificationMethodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === verificationMethodId;\n\t\t\t});\n\n\t\t\tif (!methodAndArray) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"methodMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst didMethod = methodAndArray.method;\n\t\t\tif (!Is.stringValue(didMethod.publicKeyJwk?.x)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"publicKeyJwkMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst vaultKey = EntityStorageIdentityConnector.buildVaultKey(\n\t\t\t\tdidDocument.id,\n\t\t\t\tidParts.fragment ?? \"\"\n\t\t\t);\n\t\t\tconst key = await this._vaultConnector.getKey(vaultKey);\n\n\t\t\tconst signedProof = await ProofHelper.createProof(\n\t\t\t\tproofType,\n\t\t\t\tunsecureDocument,\n\t\t\t\tProofHelper.createUnsignedProof(proofType, verificationMethodId),\n\t\t\t\tawait Jwk.fromEd25519Private(key.privateKey)\n\t\t\t);\n\n\t\t\treturn signedProof;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createProofFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Verify proof for arbitrary data with the specified verification method.\n\t * @param document The document to verify.\n\t * @param proof The proof to verify.\n\t * @returns True if the proof is verified.\n\t */\n\tpublic async verifyProof(document: IJsonLdNodeObject, proof: IProof): Promise<boolean> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(document),\n\t\t\tdocument\n\t\t);\n\t\tGuards.object<IProof>(EntityStorageIdentityConnector.CLASS_NAME, nameof(proof), proof);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(proof.verificationMethod),\n\t\t\tproof.verificationMethod\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(proof.verificationMethod);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tproof.verificationMethod\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst didIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);\n\t\t\tif (Is.undefined(didIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tidParts.id\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tdidIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tconst methods = this.getAllMethods(didDocument);\n\n\t\t\tconst methodAndArray = methods.find(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === proof.verificationMethod;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === proof.verificationMethod;\n\t\t\t});\n\n\t\t\tif (!methodAndArray) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"methodMissing\", {\n\t\t\t\t\tmethod: proof.verificationMethod\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst didMethod = methodAndArray.method;\n\t\t\tif (!Is.stringValue(didMethod.publicKeyJwk?.x)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"publicKeyJwkMissing\", {\n\t\t\t\t\tmethod: proof.verificationMethod\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst result = await ProofHelper.verifyProof(document, proof, didMethod.publicKeyJwk);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"verifyProofFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get all the methods from a document.\n\t * @param document The document to get the methods from.\n\t * @returns The methods.\n\t * @internal\n\t */\n\tprivate getAllMethods(\n\t\tdocument: IDidDocument\n\t): { arrayKey: string; method: Partial<IDidDocumentVerificationMethod> }[] {\n\t\tconst methods: {\n\t\t\tarrayKey: string;\n\t\t\tmethod: Partial<IDidDocumentVerificationMethod>;\n\t\t}[] = [];\n\n\t\tconst methodTypes: DidVerificationMethodType[] = Object.values(DidVerificationMethodType);\n\n\t\tfor (const methodType of methodTypes) {\n\t\t\tconst mt = document[methodType];\n\t\t\tif (Is.arrayValue(mt)) {\n\t\t\t\tmethods.push(\n\t\t\t\t\t...mt.map(m => ({\n\t\t\t\t\t\tarrayKey: methodType,\n\t\t\t\t\t\tmethod: Is.string(m) ? { id: m } : m\n\t\t\t\t\t}))\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn methods;\n\t}\n\n\t/**\n\t * Check if a revocation index is revoked.\n\t * @param document The document to check.\n\t * @param revocationBitmapIndex The revocation index to check.\n\t * @returns True if the index is revoked.\n\t * @internal\n\t */\n\tprivate async checkRevocation(\n\t\tdocument: IDidDocument,\n\t\trevocationBitmapIndex?: unknown\n\t): Promise<boolean> {\n\t\tif (Is.stringValue(revocationBitmapIndex)) {\n\t\t\tconst revocationIndex = Coerce.number(revocationBitmapIndex);\n\t\t\tif (Is.number(revocationIndex)) {\n\t\t\t\tconst revocationService = document.service?.find(s => s.id.endsWith(\"#revocation\"));\n\t\t\t\tif (\n\t\t\t\t\trevocationService &&\n\t\t\t\t\tIs.string(revocationService.serviceEndpoint) &&\n\t\t\t\t\trevocationService.type === \"BitstringStatusList\"\n\t\t\t\t) {\n\t\t\t\t\tconst revocationParts = revocationService.serviceEndpoint.split(\",\");\n\t\t\t\t\tif (revocationParts.length === 2) {\n\t\t\t\t\t\tconst compressedRevocationBytes = Converter.base64UrlToBytes(revocationParts[1]);\n\t\t\t\t\t\tconst decompressed = await Compression.decompress(\n\t\t\t\t\t\t\tcompressedRevocationBytes,\n\t\t\t\t\t\t\tCompressionType.Gzip\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst bitString = BitString.fromBits(\n\t\t\t\t\t\t\tdecompressed,\n\t\t\t\t\t\t\tEntityStorageIdentityConnector._REVOCATION_BITS_SIZE\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn bitString.getBit(revocationIndex);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Update the document in storage.\n\t * @param controller The controller of the document.\n\t * @param didDocument The did document to store.\n\t * @internal\n\t */\n\tprivate async updateDocument(controller: string, didDocument: IDidDocument): Promise<void> {\n\t\tconst stringifiedDocument = JsonHelper.canonicalize(didDocument);\n\t\tconst docBytes = Converter.utf8ToBytes(stringifiedDocument);\n\n\t\tconst signature = await this._vaultConnector.sign(\n\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, \"did\"),\n\t\t\tdocBytes\n\t\t);\n\n\t\tawait this._didDocumentEntityStorage.set({\n\t\t\tid: didDocument.id,\n\t\t\tdocument: didDocument,\n\t\t\tsignature: Converter.bytesToBase64(signature),\n\t\t\tcontroller\n\t\t});\n\t}\n}\n"]}
@@ -0,0 +1,203 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { AlreadyExistsError, BaseError, GeneralError, Guards, Is, NotFoundError, ObjectHelper } from "@twin.org/core";
4
+ import { ComparisonOperator } from "@twin.org/entity";
5
+ import { EntityStorageConnectorFactory } from "@twin.org/entity-storage-models";
6
+ /**
7
+ * Class which implements the identity profile connector contract.
8
+ */
9
+ export class EntityStorageIdentityProfileConnector {
10
+ /**
11
+ * The namespace supported by the identity profile connector.
12
+ */
13
+ static NAMESPACE = "entity-storage";
14
+ /**
15
+ * Runtime name for the class.
16
+ */
17
+ static CLASS_NAME = "EntityStorageIdentityProfileConnector";
18
+ /**
19
+ * The storage connector for the profiles.
20
+ * @internal
21
+ */
22
+ _profileEntityStorage;
23
+ /**
24
+ * Create a new instance of EntityStorageIdentityProfileConnector.
25
+ * @param options The options for the identity service.
26
+ */
27
+ constructor(options) {
28
+ this._profileEntityStorage = EntityStorageConnectorFactory.get(options?.profileEntityStorageType ?? "identity-profile");
29
+ }
30
+ /**
31
+ * Returns the class name of the component.
32
+ * @returns The class name of the component.
33
+ */
34
+ className() {
35
+ return EntityStorageIdentityProfileConnector.CLASS_NAME;
36
+ }
37
+ /**
38
+ * Create the profile properties for an identity.
39
+ * @param identity The identity of the profile to create.
40
+ * @param publicProfile The public profile data.
41
+ * @param privateProfile The private profile data.
42
+ * @returns Nothing.
43
+ */
44
+ async create(identity, publicProfile, privateProfile) {
45
+ Guards.stringValue(EntityStorageIdentityProfileConnector.CLASS_NAME, "identity", identity);
46
+ try {
47
+ const profile = await this._profileEntityStorage.get(identity);
48
+ if (!Is.empty(profile)) {
49
+ throw new AlreadyExistsError(EntityStorageIdentityProfileConnector.CLASS_NAME, "alreadyExists", identity);
50
+ }
51
+ await this._profileEntityStorage.set({
52
+ identity,
53
+ publicProfile,
54
+ privateProfile
55
+ });
56
+ }
57
+ catch (error) {
58
+ if (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {
59
+ throw error;
60
+ }
61
+ throw new GeneralError(EntityStorageIdentityProfileConnector.CLASS_NAME, "createFailed", { identity }, error);
62
+ }
63
+ }
64
+ /**
65
+ * Get the profile properties for an identity.
66
+ * @param identity The identity of the item to get.
67
+ * @param publicPropertyNames The public properties to get for the profile, defaults to all.
68
+ * @param privatePropertyNames The private properties to get for the profile, defaults to all.
69
+ * @returns The items properties.
70
+ */
71
+ async get(identity, publicPropertyNames, privatePropertyNames) {
72
+ try {
73
+ const profile = await this._profileEntityStorage.get(identity);
74
+ if (!profile) {
75
+ throw new NotFoundError(EntityStorageIdentityProfileConnector.CLASS_NAME, "identityNotFound", identity);
76
+ }
77
+ return this.pickProperties(profile, publicPropertyNames, privatePropertyNames);
78
+ }
79
+ catch (error) {
80
+ if (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {
81
+ throw error;
82
+ }
83
+ throw new GeneralError(EntityStorageIdentityProfileConnector.CLASS_NAME, "getFailed", { identity }, error);
84
+ }
85
+ }
86
+ /**
87
+ * Update the profile properties of an identity.
88
+ * @param identity The identity to update.
89
+ * @param publicProfile The public profile data.
90
+ * @param privateProfile The private profile data.
91
+ * @returns Nothing.
92
+ */
93
+ async update(identity, publicProfile, privateProfile) {
94
+ Guards.stringValue(EntityStorageIdentityProfileConnector.CLASS_NAME, "identity", identity);
95
+ try {
96
+ const profile = await this._profileEntityStorage.get(identity);
97
+ if (Is.empty(profile)) {
98
+ throw new NotFoundError(EntityStorageIdentityProfileConnector.CLASS_NAME, "notFound", identity);
99
+ }
100
+ profile.publicProfile = publicProfile ?? profile.publicProfile;
101
+ profile.privateProfile = privateProfile ?? profile.privateProfile;
102
+ await this._profileEntityStorage.set(profile);
103
+ }
104
+ catch (error) {
105
+ if (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {
106
+ throw error;
107
+ }
108
+ throw new GeneralError(EntityStorageIdentityProfileConnector.CLASS_NAME, "updateFailed", { identity }, error);
109
+ }
110
+ }
111
+ /**
112
+ * Delete the profile for an identity.
113
+ * @param identity The identity to delete.
114
+ * @returns Nothing.
115
+ */
116
+ async remove(identity) {
117
+ Guards.stringValue(EntityStorageIdentityProfileConnector.CLASS_NAME, "identity", identity);
118
+ try {
119
+ const profile = await this._profileEntityStorage.get(identity);
120
+ if (Is.empty(profile)) {
121
+ throw new NotFoundError(EntityStorageIdentityProfileConnector.CLASS_NAME, "notFound", identity);
122
+ }
123
+ await this._profileEntityStorage.remove(identity);
124
+ }
125
+ catch (error) {
126
+ if (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {
127
+ throw error;
128
+ }
129
+ throw new GeneralError(EntityStorageIdentityProfileConnector.CLASS_NAME, "removeFailed", { identity }, error);
130
+ }
131
+ }
132
+ /**
133
+ * Get a list of the requested types.
134
+ * @param publicFilters The filters to apply to the identities public profiles.
135
+ * @param privateFilters The filters to apply to the identities private profiles.
136
+ * @param publicPropertyNames The public properties to get for the profile, defaults to all.
137
+ * @param privatePropertyNames The private properties to get for the profile, defaults to all.
138
+ * @param cursor The cursor for paged requests.
139
+ * @param limit The maximum number of items in a page.
140
+ * @returns The list of items and cursor for paging.
141
+ */
142
+ async list(publicFilters, privateFilters, publicPropertyNames, privatePropertyNames, cursor, limit) {
143
+ try {
144
+ const conditions = [];
145
+ if (Is.arrayValue(publicFilters)) {
146
+ for (const filter of publicFilters) {
147
+ conditions.push({
148
+ property: `publicProfile.${filter.propertyName}`,
149
+ value: filter.propertyValue,
150
+ comparison: ComparisonOperator.Equals
151
+ });
152
+ }
153
+ }
154
+ if (Is.arrayValue(privateFilters)) {
155
+ for (const filter of privateFilters) {
156
+ conditions.push({
157
+ property: `privateProfile.${filter.propertyName}`,
158
+ value: filter.propertyValue,
159
+ comparison: ComparisonOperator.Equals
160
+ });
161
+ }
162
+ }
163
+ const result = await this._profileEntityStorage.query(Is.arrayValue(conditions)
164
+ ? {
165
+ conditions
166
+ }
167
+ : undefined, undefined, undefined, cursor, limit);
168
+ const items = [];
169
+ for (const resultEntity of result.entities) {
170
+ items.push({
171
+ identity: resultEntity.identity ?? "",
172
+ ...this.pickProperties(resultEntity, publicPropertyNames, privatePropertyNames)
173
+ });
174
+ }
175
+ return {
176
+ items,
177
+ cursor: result.cursor
178
+ };
179
+ }
180
+ catch (error) {
181
+ throw new GeneralError(EntityStorageIdentityProfileConnector.CLASS_NAME, "listFailed", undefined, error);
182
+ }
183
+ }
184
+ /**
185
+ * Get the profile properties for an identity.
186
+ * @param profile The profile to pick the properties from.
187
+ * @param publicPropertyNames The public properties to get for the profile, defaults to all.
188
+ * @param privatePropertyNames The private properties to get for the profile, defaults to all.
189
+ * @returns The identity profile, will only return private data if you have correct permissions.
190
+ * @internal
191
+ */
192
+ pickProperties(profile, publicPropertyNames, privatePropertyNames) {
193
+ return {
194
+ publicProfile: Is.array(publicPropertyNames)
195
+ ? ObjectHelper.pick(profile.publicProfile, publicPropertyNames)
196
+ : profile.publicProfile,
197
+ privateProfile: Is.array(privatePropertyNames)
198
+ ? ObjectHelper.pick(profile.privateProfile, privatePropertyNames)
199
+ : profile.privateProfile
200
+ };
201
+ }
202
+ }
203
+ //# sourceMappingURL=entityStorageIdentityProfileConnector.js.map
@@ -0,0 +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;IAKjD;;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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AAa,EAAE,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC;gBAC3C,CAAC,CAAC,YAAY,CAAC,IAAI,CAAI,OAAO,CAAC,aAAkB,EAAE,mBAAmB,CAAC;gBACvE,CAAC,CAAE,OAAO,CAAC,aAAmB;YAC/B,cAAc,EAAE,EAAE,CAAC,KAAK,CAAC,oBAAoB,CAAC;gBAC7C,CAAC,CAAC,YAAY,CAAC,IAAI,CAAI,OAAO,CAAC,cAAmB,EAAE,oBAAoB,CAAC;gBACzE,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{\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<T>(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<U>(profile.privateProfile as U, privatePropertyNames)\n\t\t\t\t: (profile.privateProfile as U)\n\t\t};\n\t}\n}\n"]}
@@ -0,0 +1,65 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { GeneralError, Guards, Is, NotFoundError } from "@twin.org/core";
4
+ import { EntityStorageConnectorFactory } from "@twin.org/entity-storage-models";
5
+ import { VaultConnectorFactory } from "@twin.org/vault-models";
6
+ import { EntityStorageIdentityConnector } from "./entityStorageIdentityConnector.js";
7
+ /**
8
+ * Class for performing identity operations using entity storage.
9
+ */
10
+ export class EntityStorageIdentityResolverConnector {
11
+ /**
12
+ * The namespace supported by the identity connector.
13
+ */
14
+ static NAMESPACE = "entity-storage";
15
+ /**
16
+ * Runtime name for the class.
17
+ */
18
+ static CLASS_NAME = "EntityStorageIdentityResolverConnector";
19
+ /**
20
+ * The entity storage for identities.
21
+ * @internal
22
+ */
23
+ _didDocumentEntityStorage;
24
+ /**
25
+ * The vault for the keys.
26
+ * @internal
27
+ */
28
+ _vaultConnector;
29
+ /**
30
+ * Create a new instance of EntityStorageIdentityResolverConnector.
31
+ * @param options The options for the identity connector.
32
+ */
33
+ constructor(options) {
34
+ this._didDocumentEntityStorage = EntityStorageConnectorFactory.get(options?.didDocumentEntityStorageType ?? "identity-document");
35
+ this._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? "vault");
36
+ }
37
+ /**
38
+ * Returns the class name of the component.
39
+ * @returns The class name of the component.
40
+ */
41
+ className() {
42
+ return EntityStorageIdentityResolverConnector.CLASS_NAME;
43
+ }
44
+ /**
45
+ * Resolve a document from its id.
46
+ * @param documentId The id of the document to resolve.
47
+ * @returns The resolved document.
48
+ * @throws NotFoundError if the id can not be resolved.
49
+ */
50
+ async resolveDocument(documentId) {
51
+ Guards.stringValue(EntityStorageIdentityResolverConnector.CLASS_NAME, "documentId", documentId);
52
+ try {
53
+ const didIdentityDocument = await this._didDocumentEntityStorage.get(documentId);
54
+ if (Is.undefined(didIdentityDocument)) {
55
+ throw new NotFoundError(EntityStorageIdentityResolverConnector.CLASS_NAME, "documentNotFound", documentId);
56
+ }
57
+ await EntityStorageIdentityConnector.verifyDocument(didIdentityDocument, this._vaultConnector);
58
+ return didIdentityDocument.document;
59
+ }
60
+ catch (error) {
61
+ throw new GeneralError(EntityStorageIdentityResolverConnector.CLASS_NAME, "resolveDocumentFailed", undefined, error);
62
+ }
63
+ }
64
+ }
65
+ //# sourceMappingURL=entityStorageIdentityResolverConnector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entityStorageIdentityResolverConnector.js","sourceRoot":"","sources":["../../src/entityStorageIdentityResolverConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAIzC,OAAO,EAAE,qBAAqB,EAAwB,MAAM,wBAAwB,CAAC;AAErF,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAGrF;;GAEG;AACH,MAAM,OAAO,sCAAsC;IAClD;;OAEG;IACI,MAAM,CAAU,SAAS,GAAW,gBAAgB,CAAC;IAE5D;;OAEG;IACI,MAAM,CAAU,UAAU,4CAA4D;IAE7F;;;OAGG;IACgB,yBAAyB,CAA4C;IAExF;;;OAGG;IACgB,eAAe,CAAkB;IAEpD;;;OAGG;IACH,YAAY,OAAmE;QAC9E,IAAI,CAAC,yBAAyB,GAAG,6BAA6B,CAAC,GAAG,CACjE,OAAO,EAAE,4BAA4B,IAAI,mBAAmB,CAC5D,CAAC;QACF,IAAI,CAAC,eAAe,GAAG,qBAAqB,CAAC,GAAG,CAAC,OAAO,EAAE,kBAAkB,IAAI,OAAO,CAAC,CAAC;IAC1F,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,sCAAsC,CAAC,UAAU,CAAC;IAC1D,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,eAAe,CAAC,UAAkB;QAC9C,MAAM,CAAC,WAAW,CACjB,sCAAsC,CAAC,UAAU,gBAEjD,UAAU,CACV,CAAC;QAEF,IAAI,CAAC;YACJ,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACjF,IAAI,EAAE,CAAC,SAAS,CAAC,mBAAmB,CAAC,EAAE,CAAC;gBACvC,MAAM,IAAI,aAAa,CACtB,sCAAsC,CAAC,UAAU,EACjD,kBAAkB,EAClB,UAAU,CACV,CAAC;YACH,CAAC;YACD,MAAM,8BAA8B,CAAC,cAAc,CAClD,mBAAmB,EACnB,IAAI,CAAC,eAAe,CACpB,CAAC;YAEF,OAAO,mBAAmB,CAAC,QAAQ,CAAC;QACrC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,YAAY,CACrB,sCAAsC,CAAC,UAAU,EACjD,uBAAuB,EACvB,SAAS,EACT,KAAK,CACL,CAAC;QACH,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { GeneralError, Guards, Is, NotFoundError } from \"@twin.org/core\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport type { IIdentityResolverConnector } from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IDidDocument } from \"@twin.org/standards-w3c-did\";\nimport { VaultConnectorFactory, type IVaultConnector } from \"@twin.org/vault-models\";\nimport type { IdentityDocument } from \"./entities/identityDocument.js\";\nimport { EntityStorageIdentityConnector } from \"./entityStorageIdentityConnector.js\";\nimport type { IEntityStorageIdentityResolverConnectorConstructorOptions } from \"./models/IEntityStorageIdentityResolverConnectorConstructorOptions.js\";\n\n/**\n * Class for performing identity operations using entity storage.\n */\nexport class EntityStorageIdentityResolverConnector implements IIdentityResolverConnector {\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 * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageIdentityResolverConnector>();\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 EntityStorageIdentityResolverConnector.\n\t * @param options The options for the identity connector.\n\t */\n\tconstructor(options?: IEntityStorageIdentityResolverConnectorConstructorOptions) {\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 * 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 EntityStorageIdentityResolverConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Resolve a document from its id.\n\t * @param documentId The id of the document to resolve.\n\t * @returns The resolved document.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async resolveDocument(documentId: string): Promise<IDidDocument> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityResolverConnector.CLASS_NAME,\n\t\t\tnameof(documentId),\n\t\t\tdocumentId\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\tEntityStorageIdentityResolverConnector.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\treturn didIdentityDocument.document;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityResolverConnector.CLASS_NAME,\n\t\t\t\t\"resolveDocumentFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
@@ -0,0 +1,12 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export * from "./entities/identityDocument.js";
4
+ export * from "./entities/identityProfile.js";
5
+ export * from "./entityStorageIdentityConnector.js";
6
+ export * from "./entityStorageIdentityProfileConnector.js";
7
+ export * from "./entityStorageIdentityResolverConnector.js";
8
+ export * from "./models/IEntityStorageIdentityConnectorConstructorOptions.js";
9
+ export * from "./models/IEntityStorageIdentityProfileConnectorConstructorOptions.js";
10
+ export * from "./models/IEntityStorageIdentityResolverConnectorConstructorOptions.js";
11
+ export * from "./schema.js";
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,+DAA+D,CAAC;AAC9E,cAAc,sEAAsE,CAAC;AACrF,cAAc,uEAAuE,CAAC;AACtF,cAAc,aAAa,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./entities/identityDocument.js\";\nexport * from \"./entities/identityProfile.js\";\nexport * from \"./entityStorageIdentityConnector.js\";\nexport * from \"./entityStorageIdentityProfileConnector.js\";\nexport * from \"./entityStorageIdentityResolverConnector.js\";\nexport * from \"./models/IEntityStorageIdentityConnectorConstructorOptions.js\";\nexport * from \"./models/IEntityStorageIdentityProfileConnectorConstructorOptions.js\";\nexport * from \"./models/IEntityStorageIdentityResolverConnectorConstructorOptions.js\";\nexport * from \"./schema.js\";\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IEntityStorageIdentityConnectorConstructorOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IEntityStorageIdentityConnectorConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IEntityStorageIdentityConnectorConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IEntityStorageIdentityResolverConnectorConstructorOptions } from \"./IEntityStorageIdentityResolverConnectorConstructorOptions.js\";\n\n/**\n * Options for the entity storage identity connector constructor.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IEntityStorageIdentityConnectorConstructorOptions\n\textends IEntityStorageIdentityResolverConnectorConstructorOptions {}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=IEntityStorageIdentityProfileConnectorConstructorOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IEntityStorageIdentityProfileConnectorConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IEntityStorageIdentityProfileConnectorConstructorOptions.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Options for the entity storage identity profile connector constructor.\n */\nexport interface IEntityStorageIdentityProfileConnectorConstructorOptions {\n\t/**\n\t * The storage connector for the profiles.\n\t * @default identity-profile\n\t */\n\tprofileEntityStorageType?: string;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=IEntityStorageIdentityResolverConnectorConstructorOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IEntityStorageIdentityResolverConnectorConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IEntityStorageIdentityResolverConnectorConstructorOptions.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Options for the entity storage identity connector constructor.\n */\nexport interface IEntityStorageIdentityResolverConnectorConstructorOptions {\n\t/**\n\t * The entity storage for the did documents.\n\t * @default identity-document\n\t */\n\tdidDocumentEntityStorageType?: string;\n\n\t/**\n\t * The vault for the private keys.\n\t * @default vault\n\t */\n\tvaultConnectorType?: string;\n}\n"]}
@@ -0,0 +1,20 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { EntitySchemaFactory, EntitySchemaHelper } from "@twin.org/entity";
4
+ import { IdentityDocument } from "./entities/identityDocument.js";
5
+ import { IdentityProfile } from "./entities/identityProfile.js";
6
+ /**
7
+ * Initialize the schema for the identity entity storage connector.
8
+ * @param options Options for which entities to register.
9
+ * @param options.includeDocument Whether to include the document entity, defaults to true.
10
+ * @param options.includeProfile Whether to include the profile entity, defaults to true.
11
+ */
12
+ export function initSchema(options) {
13
+ if (options?.includeDocument ?? true) {
14
+ EntitySchemaFactory.register("IdentityDocument", () => EntitySchemaHelper.getSchema(IdentityDocument));
15
+ }
16
+ if (options?.includeProfile ?? true) {
17
+ EntitySchemaFactory.register("IdentityProfile", () => EntitySchemaHelper.getSchema(IdentityProfile));
18
+ }
19
+ }
20
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,OAG1B;IACA,IAAI,OAAO,EAAE,eAAe,IAAI,IAAI,EAAE,CAAC;QACtC,mBAAmB,CAAC,QAAQ,qBAA2B,GAAG,EAAE,CAC3D,kBAAkB,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAC9C,CAAC;IACH,CAAC;IACD,IAAI,OAAO,EAAE,cAAc,IAAI,IAAI,EAAE,CAAC;QACrC,mBAAmB,CAAC,QAAQ,oBAA4B,GAAG,EAAE,CAC5D,kBAAkB,CAAC,SAAS,CAAC,eAAe,CAAC,CAC7C,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { EntitySchemaFactory, EntitySchemaHelper } from \"@twin.org/entity\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { IdentityDocument } from \"./entities/identityDocument.js\";\nimport { IdentityProfile } from \"./entities/identityProfile.js\";\n\n/**\n * Initialize the schema for the identity entity storage connector.\n * @param options Options for which entities to register.\n * @param options.includeDocument Whether to include the document entity, defaults to true.\n * @param options.includeProfile Whether to include the profile entity, defaults to true.\n */\nexport function initSchema(options?: {\n\tincludeDocument?: boolean;\n\tincludeProfile?: boolean;\n}): void {\n\tif (options?.includeDocument ?? true) {\n\t\tEntitySchemaFactory.register(nameof(IdentityDocument), () =>\n\t\t\tEntitySchemaHelper.getSchema(IdentityDocument)\n\t\t);\n\t}\n\tif (options?.includeProfile ?? true) {\n\t\tEntitySchemaFactory.register(nameof<IdentityProfile>(), () =>\n\t\t\tEntitySchemaHelper.getSchema(IdentityProfile)\n\t\t);\n\t}\n}\n"]}