@twin.org/identity-connector-entity-storage 0.9.3-next.1 → 0.9.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.
- package/dist/es/entityStorageIdentityConnector.js +4 -5
- package/dist/es/entityStorageIdentityConnector.js.map +1 -1
- package/dist/es/entityStorageIdentityProfileConnector.js +1 -1
- package/dist/es/entityStorageIdentityProfileConnector.js.map +1 -1
- package/dist/es/entityStorageIdentityResolverConnector.js +59 -2
- package/dist/es/entityStorageIdentityResolverConnector.js.map +1 -1
- package/dist/es/index.js +1 -0
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/IEntityStorageIdentityResolverConnectorConfig.js +4 -0
- package/dist/es/models/IEntityStorageIdentityResolverConnectorConfig.js.map +1 -0
- package/dist/es/models/IEntityStorageIdentityResolverConnectorConstructorOptions.js +0 -2
- package/dist/es/models/IEntityStorageIdentityResolverConnectorConstructorOptions.js.map +1 -1
- package/dist/types/entityStorageIdentityResolverConnector.d.ts +9 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/models/IEntityStorageIdentityResolverConnectorConfig.d.ts +23 -0
- package/dist/types/models/IEntityStorageIdentityResolverConnectorConstructorOptions.d.ts +5 -0
- package/docs/changelog.md +14 -0
- package/docs/reference/classes/EntityStorageIdentityResolverConnector.md +29 -1
- package/docs/reference/index.md +1 -0
- package/docs/reference/interfaces/IEntityStorageIdentityConnectorConstructorOptions.md +4 -0
- package/docs/reference/interfaces/IEntityStorageIdentityResolverConnectorConfig.md +43 -0
- package/docs/reference/interfaces/IEntityStorageIdentityResolverConnectorConstructorOptions.md +8 -0
- package/package.json +2 -2
|
@@ -63,10 +63,9 @@ export class EntityStorageIdentityConnector {
|
|
|
63
63
|
constructor(options) {
|
|
64
64
|
this._didDocumentEntityStorage = EntityStorageConnectorFactory.get(options?.didDocumentEntityStorageType ?? "identity-document");
|
|
65
65
|
this._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? "vault");
|
|
66
|
-
|
|
67
|
-
this.
|
|
68
|
-
this.
|
|
69
|
-
this._didResolutionCacheMutexTimeoutMs = config.didResolutionCacheMutexTimeoutMs;
|
|
66
|
+
this._didResolutionCacheTtlMs = options?.config?.didResolutionCacheTtlMs ?? 30_000;
|
|
67
|
+
this._didResolutionCacheCapacity = options?.config?.didResolutionCacheCapacity ?? 1000;
|
|
68
|
+
this._didResolutionCacheMutexTimeoutMs = options?.config?.didResolutionCacheMutexTimeoutMs;
|
|
70
69
|
this._didResolutionCache =
|
|
71
70
|
this._didResolutionCacheTtlMs > 0
|
|
72
71
|
? new LruCache({
|
|
@@ -571,7 +570,7 @@ export class EntityStorageIdentityConnector {
|
|
|
571
570
|
verifiableCredential.proof = await this.createProof(controller, verificationMethodId, ProofTypes.DataIntegrityProof, JsonLdHelper.toNodeObject(verifiableCredential), issuerDidDocument);
|
|
572
571
|
// As we are adding the receipt to the data we update the JSON-LD context
|
|
573
572
|
const proofContext = verifiableCredential.proof["@context"];
|
|
574
|
-
if (
|
|
573
|
+
if (Is.notEmpty(proofContext)) {
|
|
575
574
|
verifiableCredential["@context"] = (JsonLdProcessor.combineContexts(verifiableCredential["@context"], proofContext) ?? verifiableCredential["@context"]);
|
|
576
575
|
delete verifiableCredential.proof["@context"];
|
|
577
576
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entityStorageIdentityConnector.js","sourceRoot":"","sources":["../../src/entityStorageIdentityConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,WAAW,EACX,SAAS,EACT,SAAS,EACT,MAAM,EACN,WAAW,EACX,eAAe,EACf,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,UAAU,EACV,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,GAAG,EACH,GAAG,EACH,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,YAAY,EACZ,eAAe,EAGf,MAAM,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AK,CAAC;IACd,CAAC;IAED;;;;;;OAMG;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,gBAAgB,GAAqB;YAC1C,EAAE,EAAE,WAAW,CAAC,EAAE;YAClB,QAAQ,EAAE,WAAW;YACrB,SAAS,EAAE,SAAS,CAAC,aAAa,CAAC,SAAS,CAAC;YAC7C,UAAU;SACV,CAAC;QAEF,MAAM,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAE3D,IAAI,CAAC,mBAAmB,EAAE,GAAG,CAC5B,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC,EACnC,YAAY,CAAC,KAAK,CAAC,gBAAgB,CAAC,CACpC,CAAC;IACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tArrayHelper,\n\tBaseError,\n\tBitString,\n\tCoerce,\n\tCompression,\n\tCompressionType,\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tJsonHelper,\n\tLruCache,\n\tNotFoundError,\n\tObjectHelper,\n\tRandomHelper,\n\tUrl,\n\tUrn\n} from \"@twin.org/core\";\nimport {\n\tJsonLdHelper,\n\tJsonLdProcessor,\n\ttype IJsonLdContextDefinitionRoot,\n\ttype IJsonLdNodeObject\n} from \"@twin.org/data-json-ld\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport {\n\tDocumentHelper,\n\tVerificationHelper,\n\ttype IIdentityConnector\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDidContexts,\n\tDidTypes,\n\tDidVerificationMethodType,\n\ttype IDidCredentialStatus,\n\ttype IDidVerifiableCredential,\n\tJwsAlgorithms,\n\tProofHelper,\n\tProofTypes,\n\ttype IDidDocument,\n\ttype IDidDocumentVerificationMethod,\n\ttype IDidService,\n\ttype IDidVerifiableCredentialV1,\n\ttype IDidVerifiablePresentationV1,\n\ttype IProof,\n\ttype IDidVerifiablePresentation\n} from \"@twin.org/standards-w3c-did\";\nimport {\n\tVaultConnectorFactory,\n\tVaultConnectorHelper,\n\tVaultKeyType,\n\ttype IVaultConnector\n} from \"@twin.org/vault-models\";\nimport { Jwk, Jwt, type IJwk, type IJwtHeader, type IJwtPayload } from \"@twin.org/web\";\nimport type { IdentityDocument } from \"./entities/identityDocument.js\";\nimport type { IEntityStorageIdentityConnectorConfig } from \"./models/IEntityStorageIdentityConnectorConfig.js\";\nimport type { IEntityStorageIdentityConnectorConstructorOptions } from \"./models/IEntityStorageIdentityConnectorConstructorOptions.js\";\n\n/**\n * Class for performing identity operations using entity storage.\n */\nexport class EntityStorageIdentityConnector implements IIdentityConnector {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageIdentityConnector>();\n\n\t/**\n\t * The namespace supported by the identity connector.\n\t */\n\tpublic static readonly NAMESPACE: string = \"entity-storage\";\n\n\t/**\n\t * The size of the revocation bitmap in bits (16Kb).\n\t * @internal\n\t */\n\tprivate static readonly _REVOCATION_BITS_SIZE: number = 131072;\n\n\t/**\n\t * The entity storage for identities.\n\t * @internal\n\t */\n\tprotected readonly _didDocumentEntityStorage: IEntityStorageConnector<IdentityDocument>;\n\n\t/**\n\t * The vault for the keys.\n\t * @internal\n\t */\n\tprotected readonly _vaultConnector: IVaultConnector;\n\n\t/**\n\t * TTL in ms for caching DID documents resolved for this connector's own sign/mutate\n\t * operations. 0 disables caching (see resolveOwnDocumentCached). Never applied to proof or\n\t * credential verification of third-party claims.\n\t * @internal\n\t */\n\tprivate readonly _didResolutionCacheTtlMs: number;\n\n\t/**\n\t * Maximum number of own DID documents retained in cache.\n\t * @internal\n\t */\n\tprivate readonly _didResolutionCacheCapacity: number;\n\n\t/**\n\t * Maximum wait time for own DID cache getOrSet mutex acquisition in milliseconds.\n\t * @internal\n\t */\n\tprivate readonly _didResolutionCacheMutexTimeoutMs?: number;\n\n\t/**\n\t * LRU cache for own DID documents. Undefined when caching is disabled (ttl is 0).\n\t * @internal\n\t */\n\tprivate readonly _didResolutionCache?: LruCache<IdentityDocument>;\n\n\t/**\n\t * Create a new instance of EntityStorageIdentityConnector.\n\t * @param options The options for the identity connector.\n\t */\n\tconstructor(options?: IEntityStorageIdentityConnectorConstructorOptions) {\n\t\tthis._didDocumentEntityStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.didDocumentEntityStorageType ?? \"identity-document\"\n\t\t);\n\t\tthis._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? \"vault\");\n\n\t\tconst config: IEntityStorageIdentityConnectorConfig = options?.config ?? {};\n\t\tthis._didResolutionCacheTtlMs = config.didResolutionCacheTtlMs ?? 30_000;\n\t\tthis._didResolutionCacheCapacity = config.didResolutionCacheCapacity ?? 1000;\n\t\tthis._didResolutionCacheMutexTimeoutMs = config.didResolutionCacheMutexTimeoutMs;\n\t\tthis._didResolutionCache =\n\t\t\tthis._didResolutionCacheTtlMs > 0\n\t\t\t\t? new LruCache<IdentityDocument>({\n\t\t\t\t\t\tcapacity: this._didResolutionCacheCapacity,\n\t\t\t\t\t\tttiMs: this._didResolutionCacheTtlMs,\n\t\t\t\t\t\tmutexTimeoutMs: this._didResolutionCacheMutexTimeoutMs\n\t\t\t\t\t})\n\t\t\t\t: undefined;\n\t}\n\n\t/**\n\t * Build the key name to access the specified key in the vault.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param key The key to access in the vault.\n\t * @returns The vault key.\n\t * @internal\n\t */\n\tpublic static buildVaultKey(identity: string, key: string): string {\n\t\treturn `${identity}/${key}`;\n\t}\n\n\t/**\n\t * Verify the document in storage.\n\t * @param didDocument The did document that was stored.\n\t * @param vaultConnector The vault connector to use for verification.\n\t * @returns A promise that resolves when verification is complete.\n\t * @throws GeneralError if the document signature is invalid.\n\t * @internal\n\t */\n\tpublic static async verifyDocument(\n\t\tdidDocument: IdentityDocument,\n\t\tvaultConnector: IVaultConnector\n\t): Promise<void> {\n\t\tconst stringifiedDocument = JsonHelper.canonicalize(didDocument.document);\n\t\tconst docBytes = Converter.utf8ToBytes(stringifiedDocument);\n\n\t\tconst verified = await vaultConnector.verify(\n\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, \"did\"),\n\t\t\tdocBytes,\n\t\t\tConverter.base64ToBytes(didDocument.signature)\n\t\t);\n\n\t\tif (!verified) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"signatureVerificationFailed\"\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageIdentityConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Stop the service.\n\t * Destroys in-memory resources owned by this component.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t * @returns A promise that resolves when the service has stopped.\n\t */\n\tpublic async stop(nodeLoggingComponentType?: string): Promise<void> {\n\t\tthis._didResolutionCache?.destroy();\n\t}\n\n\t/**\n\t * Create a new document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns The created document.\n\t */\n\tpublic async createDocument(controller: string): Promise<IDidDocument> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\n\t\ttry {\n\t\t\tconst did = `did:${EntityStorageIdentityConnector.NAMESPACE}:${Converter.bytesToHex(RandomHelper.generate(32), true)}`;\n\n\t\t\tawait this._vaultConnector.createKey(\n\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(did, \"did\"),\n\t\t\t\tVaultKeyType.Ed25519\n\t\t\t);\n\n\t\t\tconst bitString = new BitString(EntityStorageIdentityConnector._REVOCATION_BITS_SIZE);\n\t\t\tconst compressed = await Compression.compress(bitString.getBits(), CompressionType.Gzip);\n\n\t\t\tconst didDocument: IDidDocument = {\n\t\t\t\t\"@context\": DidContexts.Context,\n\t\t\t\tid: did,\n\t\t\t\tservice: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${did}#revocation`,\n\t\t\t\t\t\ttype: \"BitstringStatusList\",\n\t\t\t\t\t\tserviceEndpoint: `data:application/octet-stream;base64,${Converter.bytesToBase64Url(compressed)}`\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t};\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\n\t\t\treturn didDocument;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createDocumentFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove a document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to remove.\n\t * @param options Optional settings.\n\t * @param options.removeKeys Also remove any associated private keys from the vault.\n\t * @returns A promise that resolves when the document has been removed.\n\t */\n\tpublic async removeDocument(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\toptions?: { removeKeys?: boolean }\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\n\t\ttry {\n\t\t\tconst didDocument = await this._didDocumentEntityStorage.get(documentId);\n\t\t\tif (Is.empty(didDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tdocumentId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this._didDocumentEntityStorage.remove(documentId);\n\t\t\tthis._didResolutionCache?.delete(this.ownDidCacheKey(documentId));\n\n\t\t\tif (options?.removeKeys ?? false) {\n\t\t\t\tconst methods = this.getAllMethods(didDocument.document);\n\t\t\t\tfor (const { method } of methods) {\n\t\t\t\t\tconst methodId = Is.string(method) ? method : method.id;\n\t\t\t\t\tif (Is.stringValue(methodId)) {\n\t\t\t\t\t\tconst idParts = DocumentHelper.parseId(methodId);\n\t\t\t\t\t\tif (Is.stringValue(idParts.fragment)) {\n\t\t\t\t\t\t\tconst vaultKey = EntityStorageIdentityConnector.buildVaultKey(\n\t\t\t\t\t\t\t\tdocumentId,\n\t\t\t\t\t\t\t\tidParts.fragment\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (await this._vaultConnector.keyExists(vaultKey)) {\n\t\t\t\t\t\t\t\tawait this._vaultConnector.removeKey(vaultKey);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeDocumentFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Add a verification method to the document in JSON Web key Format.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to add the verification method to.\n\t * @param verificationMethodType The type of the verification method to add.\n\t * @param verificationMethodId The id of the verification method, if undefined uses the kid of the generated JWK.\n\t * @returns The verification method.\n\t * @throws NotFoundError if the id can not be resolved.\n\t * @throws NotSupportedError if the platform does not support multiple keys.\n\t */\n\tpublic async addVerificationMethod(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\tverificationMethodType: DidVerificationMethodType,\n\t\tverificationMethodId?: string\n\t): Promise<IDidDocumentVerificationMethod> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.arrayOneOf<DidVerificationMethodType>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodType),\n\t\t\tverificationMethodType,\n\t\t\tObject.values(DidVerificationMethodType)\n\t\t);\n\n\t\tlet tempKeyId;\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentCached(documentId);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tlet methodKeyPublic;\n\t\t\tif (Is.stringValue(verificationMethodId)) {\n\t\t\t\t// If there is a verification method id, we will try to get the key from the vault.\n\t\t\t\ttry {\n\t\t\t\t\t// If there is an existing key, we will use it.\n\t\t\t\t\tconst existingKey = await this._vaultConnector.getKey(\n\t\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, verificationMethodId),\n\t\t\t\t\t\t\"public\"\n\t\t\t\t\t);\n\t\t\t\t\tmethodKeyPublic = existingKey.publicKey;\n\t\t\t\t} catch {}\n\t\t\t}\n\n\t\t\tif (Is.empty(methodKeyPublic)) {\n\t\t\t\t// If there is no existing key, we will create a new one with a temporary name.\n\t\t\t\ttempKeyId = `temp-vm-${Converter.bytesToBase64Url(RandomHelper.generate(16))}`;\n\t\t\t\tmethodKeyPublic = await this._vaultConnector.createKey(\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, tempKeyId),\n\t\t\t\t\tVaultKeyType.Ed25519\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst jwkParams: IJwk = {\n\t\t\t\talg: \"EdDSA\",\n\t\t\t\tkty: \"OKP\",\n\t\t\t\tcrv: \"Ed25519\",\n\t\t\t\tx: Converter.bytesToBase64Url(methodKeyPublic)\n\t\t\t};\n\n\t\t\tconst kid = await Jwk.generateKid(jwkParams);\n\n\t\t\tconst methodId = `${documentId}#${verificationMethodId ?? kid}`;\n\n\t\t\tif (Is.stringValue(tempKeyId)) {\n\t\t\t\t// If we created a temporary key, we will rename it to the final method id.\n\t\t\t\tawait this._vaultConnector.renameKey(\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, tempKeyId),\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, verificationMethodId ?? kid)\n\t\t\t\t);\n\t\t\t\ttempKeyId = undefined;\n\t\t\t}\n\n\t\t\tconst methods = this.getAllMethods(didDocument);\n\t\t\tconst existingMethodIndex = methods.findIndex(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === methodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === methodId;\n\t\t\t});\n\n\t\t\tif (existingMethodIndex !== -1) {\n\t\t\t\tconst methodArray =\n\t\t\t\t\tdidDocument[methods[existingMethodIndex].arrayKey as keyof IDidDocument];\n\n\t\t\t\tif (Is.array(methodArray)) {\n\t\t\t\t\tmethodArray.splice(existingMethodIndex, 1);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst didVerificationMethod: IDidDocumentVerificationMethod = {\n\t\t\t\tid: methodId,\n\t\t\t\tcontroller: documentId,\n\t\t\t\ttype: \"JsonWebKey2020\",\n\t\t\t\tpublicKeyJwk: {\n\t\t\t\t\t...jwkParams,\n\t\t\t\t\tkid\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tdidDocument[verificationMethodType] ??= [];\n\t\t\tdidDocument[verificationMethodType]?.push(didVerificationMethod);\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\n\t\t\treturn didVerificationMethod;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"addVerificationMethodFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t} finally {\n\t\t\tif (Is.stringValue(tempKeyId)) {\n\t\t\t\t// If we created a temporary key and it is still in use, we will remove it from the vault.\n\t\t\t\ttry {\n\t\t\t\t\tawait this._vaultConnector.removeKey(tempKeyId);\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Remove a verification method from the document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The id of the verification method.\n\t * @param options Optional settings.\n\t * @param options.removeKeys Also remove any associated private key from the vault.\n\t * @returns A promise that resolves when the verification method has been removed.\n\t * @throws NotFoundError if the id can not be resolved.\n\t * @throws NotSupportedError if the platform does not support multiple revocable keys.\n\t */\n\tpublic async removeVerificationMethod(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\toptions?: { removeKeys?: boolean }\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentCached(idParts.id);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tconst methods = this.getAllMethods(didDocument);\n\t\t\tconst existingMethodIndex = methods.findIndex(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === verificationMethodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === verificationMethodId;\n\t\t\t});\n\n\t\t\tif (existingMethodIndex !== -1) {\n\t\t\t\tconst methodArray =\n\t\t\t\t\tdidDocument[methods[existingMethodIndex].arrayKey as keyof IDidDocument];\n\n\t\t\t\tif (Is.array(methodArray)) {\n\t\t\t\t\tmethodArray.splice(existingMethodIndex, 1);\n\t\t\t\t\tif (methodArray.length === 0) {\n\t\t\t\t\t\tdelete didDocument[methods[existingMethodIndex].arrayKey as keyof IDidDocument];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"verificationMethodNotFound\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\n\t\t\tif (options?.removeKeys ?? false) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this._vaultConnector.removeKey(\n\t\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment)\n\t\t\t\t\t);\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeVerificationMethodFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Add a service to the document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to add the service to.\n\t * @param serviceId The id of the service.\n\t * @param serviceType The type of the service.\n\t * @param serviceEndpoint The endpoint for the service.\n\t * @returns The service.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async addService(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\tserviceId: string,\n\t\tserviceType: string | string[],\n\t\tserviceEndpoint: string | string[]\n\t): Promise<IDidService> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(serviceId), serviceId);\n\t\tif (Is.array(serviceType)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(serviceType),\n\t\t\t\tserviceType\n\t\t\t);\n\t\t} else {\n\t\t\tGuards.stringValue(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(serviceType),\n\t\t\t\tserviceType\n\t\t\t);\n\t\t}\n\t\tif (Is.array(serviceEndpoint)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(serviceEndpoint),\n\t\t\t\tserviceEndpoint\n\t\t\t);\n\t\t} else {\n\t\t\tGuards.stringValue(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(serviceEndpoint),\n\t\t\t\tserviceEndpoint\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentCached(documentId);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tconst fullServiceId = serviceId.includes(\"#\") ? serviceId : `${documentId}#${serviceId}`;\n\n\t\t\tif (Is.array(didDocument.service)) {\n\t\t\t\tconst existingServiceIndex = didDocument.service.findIndex(s => s.id === fullServiceId);\n\t\t\t\tif (existingServiceIndex !== -1) {\n\t\t\t\t\tdidDocument.service?.splice(existingServiceIndex, 1);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst didService: IDidService = {\n\t\t\t\tid: fullServiceId,\n\t\t\t\ttype: serviceType,\n\t\t\t\tserviceEndpoint\n\t\t\t};\n\n\t\t\tdidDocument.service ??= [];\n\t\t\tdidDocument.service.push(didService);\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\n\t\t\treturn didService;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"addServiceFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove a service from the document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param serviceId The id of the service.\n\t * @returns A promise that resolves when the service has been removed.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async removeService(controller: string, serviceId: string): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(serviceId), serviceId);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(serviceId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, \"missingDid\", serviceId);\n\t\t\t}\n\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentCached(idParts.id);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tif (Is.array(didDocument.service)) {\n\t\t\t\tconst existingServiceIndex = didDocument.service.findIndex(s => s.id === serviceId);\n\t\t\t\tif (existingServiceIndex !== -1) {\n\t\t\t\t\tdidDocument.service?.splice(existingServiceIndex, 1);\n\t\t\t\t\tif (didDocument.service?.length === 0) {\n\t\t\t\t\t\tdelete didDocument.service;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\t\"serviceNotFound\",\n\t\t\t\t\t\tserviceId\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"serviceNotFound\",\n\t\t\t\t\tserviceId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeServiceFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Add an alias to the alsoKnownAs property on the document.\n\t * If the alias is already present the operation is a no-op.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to update.\n\t * @param alias The alias to add. Must be a Url or Urn (typically another DID).\n\t * @returns A promise that resolves when the alias has been added.\n\t * @throws GeneralError if the alias is not a Url or Urn.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async addAlsoKnownAs(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\talias: string\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(alias), alias);\n\t\tif (!Url.tryParseExact(alias) && !Urn.tryParseExact(alias)) {\n\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"invalidAlias\", { alias });\n\t\t}\n\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentCached(documentId);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tconst existing = Is.array(didDocument.alsoKnownAs) ? didDocument.alsoKnownAs : [];\n\t\t\tif (existing.includes(alias)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdidDocument.alsoKnownAs = [...existing, alias];\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"addAlsoKnownAsFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove an alias from the alsoKnownAs property on the document.\n\t * If the alias is not present the operation is a no-op.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to update.\n\t * @param alias The alias to remove. Must be a Url or Urn.\n\t * @returns A promise that resolves when the alias has been removed.\n\t * @throws GeneralError if the alias is not a Url or Urn.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async removeAlsoKnownAs(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\talias: string\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(alias), alias);\n\t\tif (!Url.tryParseExact(alias) && !Urn.tryParseExact(alias)) {\n\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"invalidAlias\", { alias });\n\t\t}\n\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentCached(documentId);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tif (!Is.array(didDocument.alsoKnownAs) || !didDocument.alsoKnownAs.includes(alias)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst filtered = didDocument.alsoKnownAs.filter(a => a !== alias);\n\t\t\tif (filtered.length === 0) {\n\t\t\t\tdelete didDocument.alsoKnownAs;\n\t\t\t} else {\n\t\t\t\tdidDocument.alsoKnownAs = filtered;\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeAlsoKnownAsFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a verifiable credential for a verification method.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param id The id of the credential.\n\t * @param subject The credential subject to store in the verifiable credential.\n\t * @param options Additional options for creating the verifiable credential.\n\t * @param options.revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.\n\t * @param options.expirationDate The date the verifiable credential is valid until.\n\t * @param options.jwtHeaderFields Additional fields to add to the JWT header.\n\t * @param options.jwtPayloadFields Additional fields to add to the JWT payload.\n\t * @returns The created verifiable credential and its token.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async createVerifiableCredential(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\tid: string | undefined,\n\t\tsubject: IJsonLdNodeObject,\n\t\toptions?: {\n\t\t\trevocationIndex?: number;\n\t\t\texpirationDate?: Date;\n\t\t\tjwtHeaderFields?: { [id: string]: string };\n\t\t\tjwtPayloadFields?: { [id: string]: string };\n\t\t}\n\t): Promise<{\n\t\tverifiableCredential: IDidVerifiableCredentialV1;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(subject),\n\t\t\tsubject\n\t\t);\n\t\tif (!Is.undefined(options?.revocationIndex)) {\n\t\t\tGuards.number(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(options.revocationIndex),\n\t\t\t\toptions.revocationIndex\n\t\t\t);\n\t\t}\n\t\tif (!Is.undefined(options?.expirationDate)) {\n\t\t\tGuards.date(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(options.expirationDate),\n\t\t\t\toptions.expirationDate\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst issuerIdentityDocument = await this.resolveOwnDocumentCached(idParts.id);\n\t\t\tconst issuerDidDocument = issuerIdentityDocument.document;\n\n\t\t\tconst methods = this.getAllMethods(issuerDidDocument);\n\t\t\tconst methodAndArray = methods.find(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === verificationMethodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === verificationMethodId;\n\t\t\t});\n\n\t\t\tif (!methodAndArray) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"methodMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst verificationDidMethod = methodAndArray.method;\n\t\t\tif (!Is.stringValue(verificationDidMethod.publicKeyJwk?.x)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"publicKeyJwkMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst revocationService = issuerDidDocument.service?.find(s => s.id.endsWith(\"#revocation\"));\n\n\t\t\tconst subjectClone = ObjectHelper.clone(subject);\n\n\t\t\tconst credContext = ObjectHelper.extractProperty<IJsonLdContextDefinitionRoot>(subjectClone, [\n\t\t\t\t\"@context\"\n\t\t\t]);\n\t\t\tconst credId = ObjectHelper.extractProperty<string>(subjectClone, [\"@id\", \"id\"], false);\n\n\t\t\tconst verifiableCredential: IDidVerifiableCredentialV1 = {\n\t\t\t\t\"@context\": (JsonLdProcessor.combineContexts(DidContexts.ContextVCv1, credContext) ??\n\t\t\t\t\tDidContexts.ContextVCv1) as [typeof DidContexts.ContextVCv1],\n\t\t\t\tid,\n\t\t\t\ttype: DidTypes.VerifiableCredential,\n\t\t\t\tcredentialSubject: subjectClone,\n\t\t\t\tissuer: issuerDidDocument.id,\n\t\t\t\tissuanceDate: new Date(Date.now()).toISOString(),\n\t\t\t\texpirationDate: Is.date(options?.expirationDate)\n\t\t\t\t\t? options?.expirationDate.toISOString()\n\t\t\t\t\t: undefined,\n\t\t\t\tcredentialStatus:\n\t\t\t\t\trevocationService && !Is.undefined(options?.revocationIndex)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tid: revocationService.id,\n\t\t\t\t\t\t\t\ttype: Is.array(revocationService.type)\n\t\t\t\t\t\t\t\t\t? revocationService.type[0]\n\t\t\t\t\t\t\t\t\t: revocationService.type,\n\t\t\t\t\t\t\t\trevocationBitmapIndex: options.revocationIndex.toString()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined\n\t\t\t};\n\n\t\t\tconst jwtHeader: IJwtHeader = {\n\t\t\t\t...options?.jwtHeaderFields,\n\t\t\t\tkid: verificationDidMethod.id,\n\t\t\t\ttyp: \"JWT\",\n\t\t\t\talg: JwsAlgorithms.EdDSA\n\t\t\t};\n\n\t\t\tconst jwtVc = ObjectHelper.pick(ObjectHelper.clone(verifiableCredential), [\n\t\t\t\t\"@context\",\n\t\t\t\t\"type\",\n\t\t\t\t\"credentialSubject\",\n\t\t\t\t\"credentialStatus\"\n\t\t\t]);\n\n\t\t\t// Add the proof to the VC after extracting the jwt data\n\t\t\t// as the jwt does not include the proof\n\t\t\tverifiableCredential.proof = await this.createProof(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tProofTypes.DataIntegrityProof,\n\t\t\t\tJsonLdHelper.toNodeObject(verifiableCredential),\n\t\t\t\tissuerDidDocument\n\t\t\t);\n\n\t\t\t// As we are adding the receipt to the data we update the JSON-LD context\n\t\t\tconst proofContext = verifiableCredential.proof[\"@context\"];\n\t\t\tif (!Is.empty(proofContext)) {\n\t\t\t\tverifiableCredential[\"@context\"] = (JsonLdProcessor.combineContexts(\n\t\t\t\t\tverifiableCredential[\"@context\"],\n\t\t\t\t\tproofContext\n\t\t\t\t) ?? verifiableCredential[\"@context\"]) as IDidVerifiableCredentialV1[\"@context\"];\n\t\t\t\tdelete verifiableCredential.proof[\"@context\"];\n\t\t\t}\n\n\t\t\tif (Is.array(jwtVc.credentialSubject)) {\n\t\t\t\tjwtVc.credentialSubject = jwtVc.credentialSubject.map(c => {\n\t\t\t\t\tObjectHelper.propertyDelete(c, \"id\");\n\t\t\t\t\treturn c;\n\t\t\t\t});\n\t\t\t} else if (Is.object(jwtVc.credentialSubject)) {\n\t\t\t\tObjectHelper.propertyDelete(jwtVc.credentialSubject, \"id\");\n\t\t\t}\n\n\t\t\tconst jwtPayload: IJwtPayload = {\n\t\t\t\t...options?.jwtPayloadFields,\n\t\t\t\tiss: idParts.id,\n\t\t\t\tnbf: Math.floor(Date.now() / 1000),\n\t\t\t\tjti: verifiableCredential.id,\n\t\t\t\tsub: credId,\n\t\t\t\tvc: jwtVc\n\t\t\t};\n\n\t\t\tif (Is.date(options?.expirationDate)) {\n\t\t\t\tjwtPayload.exp = Math.floor(options.expirationDate.getTime() / 1000);\n\t\t\t}\n\n\t\t\tconst signature = await Jwt.encodeWithSigner(jwtHeader, jwtPayload, async (header, payload) =>\n\t\t\t\tVaultConnectorHelper.jwtSigner(\n\t\t\t\t\tthis._vaultConnector,\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment ?? \"\"),\n\t\t\t\t\theader,\n\t\t\t\t\tpayload\n\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tverifiableCredential,\n\t\t\t\tjwt: signature\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createVerifiableCredentialFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Check a verifiable credential is valid.\n\t * @param credential The credential to verify.\n\t * @returns The credential stored in the jwt and the revocation status.\n\t */\n\tpublic async checkVerifiableCredential(credential: string | IDidVerifiableCredential): Promise<{\n\t\trevoked: boolean;\n\t\tverifiableCredential?: IDidVerifiableCredential;\n\t}> {\n\t\tif (Is.object(credential)) {\n\t\t\tGuards.objectValue<IDidVerifiableCredential>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(credential),\n\t\t\t\tcredential\n\t\t\t);\n\t\t\tGuards.objectValue<IDidVerifiableCredential>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(credential.proof),\n\t\t\t\tcredential.proof\n\t\t\t);\n\t\t\tVerificationHelper.checkValidityPeriod(credential);\n\n\t\t\tconst { proof, ...doc } = credential;\n\t\t\tconst proofEntry = ArrayHelper.fromObjectOrArray(proof)[0];\n\t\t\tGuards.stringValue(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(proofEntry.verificationMethod),\n\t\t\t\tproofEntry.verificationMethod\n\t\t\t);\n\n\t\t\tconst issuer = Is.object<{ id: string }>(doc.issuer) ? doc.issuer.id : doc.issuer;\n\t\t\tconst signerDid = DocumentHelper.parseId(proofEntry.verificationMethod).id;\n\t\t\tif (Is.stringValue(issuer) && issuer !== signerDid) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"issuerMismatch\", {\n\t\t\t\t\tissuer,\n\t\t\t\t\tmethod: proofEntry.verificationMethod\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst issuerDidDocument = await this.resolveAssertionMethodDocument(\n\t\t\t\tproofEntry.verificationMethod\n\t\t\t);\n\t\t\tconst publicKeyJwk = DocumentHelper.getJwk(\n\t\t\t\tissuerDidDocument,\n\t\t\t\tproofEntry.verificationMethod,\n\t\t\t\tDidVerificationMethodType.AssertionMethod\n\t\t\t);\n\n\t\t\tconst credentialVerified = await ProofHelper.verifyProof(\n\t\t\t\tJsonLdHelper.toNodeObject(doc),\n\t\t\t\tproofEntry,\n\t\t\t\tpublicKeyJwk\n\t\t\t);\n\t\t\tif (!credentialVerified) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"signatureVerificationFailed\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst revoked = await this.checkCredentialStatusRevoked(\n\t\t\t\tissuerDidDocument,\n\t\t\t\tdoc.credentialStatus\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\trevoked,\n\t\t\t\tverifiableCredential: revoked ? undefined : doc\n\t\t\t};\n\t\t}\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(credential), credential);\n\n\t\ttry {\n\t\t\tconst jwtDecoded = await Jwt.decode(credential);\n\n\t\t\tconst jwtHeader = jwtDecoded.header;\n\t\t\tconst jwtPayload = jwtDecoded.payload;\n\t\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\t\tif (\n\t\t\t\tIs.undefined(jwtHeader) ||\n\t\t\t\tIs.undefined(jwtPayload) ||\n\t\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\t\tIs.undefined(jwtSignature)\n\t\t\t) {\n\t\t\t\tthrow new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, \"jwkSignatureFailed\");\n\t\t\t}\n\n\t\t\tconst issuerDocumentId = jwtPayload.iss;\n\t\t\tconst issuerIdentityDocument = await this._didDocumentEntityStorage.get(issuerDocumentId);\n\t\t\tif (Is.undefined(issuerIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tissuerDocumentId\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tissuerIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\t\t\tconst issuerDidDocument = issuerIdentityDocument.document;\n\n\t\t\tGuards.stringValue(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(jwtHeader.kid),\n\t\t\t\tjwtHeader.kid\n\t\t\t);\n\t\t\tconst publicKeyJwk = DocumentHelper.getJwk(\n\t\t\t\tissuerDidDocument,\n\t\t\t\tjwtHeader.kid,\n\t\t\t\tDidVerificationMethodType.AssertionMethod\n\t\t\t);\n\n\t\t\tawait Jwt.verifySignature(credential, await Jwk.toCryptoKey(publicKeyJwk));\n\n\t\t\tconst verifiableCredential = jwtPayload.vc as IDidVerifiableCredentialV1;\n\t\t\tif (Is.object(verifiableCredential)) {\n\t\t\t\tif (Is.string(jwtPayload.jti)) {\n\t\t\t\t\tverifiableCredential.id = jwtPayload.jti;\n\t\t\t\t}\n\t\t\t\tverifiableCredential.issuer = issuerDocumentId;\n\t\t\t\tif (Is.number(jwtPayload.nbf)) {\n\t\t\t\t\tverifiableCredential.issuanceDate = new Date(jwtPayload.nbf * 1000).toISOString();\n\t\t\t\t}\n\t\t\t\tif (Is.number(jwtPayload.exp)) {\n\t\t\t\t\tverifiableCredential.expirationDate = new Date(jwtPayload.exp * 1000).toISOString();\n\t\t\t\t}\n\t\t\t\tif (Is.array(verifiableCredential.credentialSubject)) {\n\t\t\t\t\tverifiableCredential.credentialSubject = verifiableCredential.credentialSubject.map(c => {\n\t\t\t\t\t\tObjectHelper.propertySet(c, \"id\", jwtPayload.sub);\n\t\t\t\t\t\treturn c;\n\t\t\t\t\t});\n\t\t\t\t} else if (Is.object(verifiableCredential.credentialSubject)) {\n\t\t\t\t\tObjectHelper.propertySet(verifiableCredential.credentialSubject, \"id\", jwtPayload.sub);\n\t\t\t\t}\n\t\t\t}\n\t\t\tVerificationHelper.checkValidityPeriod(verifiableCredential);\n\n\t\t\tconst revoked = await this.checkCredentialStatusRevoked(\n\t\t\t\tissuerDidDocument,\n\t\t\t\tverifiableCredential.credentialStatus\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\trevoked,\n\t\t\t\tverifiableCredential: revoked ? undefined : verifiableCredential\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"checkingVerifiableCredentialFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Revoke verifiable credential(s).\n\t * @param controller The controller of the identity who can make changes.\n\t * @param issuerDocumentId The id of the document to update the revocation list for.\n\t * @param credentialIndices The revocation bitmap index or indices to revoke.\n\t * @returns A promise that resolves when the credentials have been revoked.\n\t */\n\tpublic async revokeVerifiableCredentials(\n\t\tcontroller: string,\n\t\tissuerDocumentId: string,\n\t\tcredentialIndices: number[]\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(issuerDocumentId),\n\t\t\tissuerDocumentId\n\t\t);\n\t\tGuards.arrayValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(credentialIndices),\n\t\t\tcredentialIndices\n\t\t);\n\n\t\ttry {\n\t\t\tconst issuerIdentityDocument = await this.resolveOwnDocumentCached(issuerDocumentId);\n\t\t\tconst issuerDidDocument = issuerIdentityDocument.document;\n\n\t\t\tconst revocationService = issuerDidDocument.service?.find(s => s.id.endsWith(\"#revocation\"));\n\t\t\tif (\n\t\t\t\trevocationService &&\n\t\t\t\tIs.string(revocationService.serviceEndpoint) &&\n\t\t\t\trevocationService.type === \"BitstringStatusList\"\n\t\t\t) {\n\t\t\t\tconst revocationParts = revocationService.serviceEndpoint.split(\",\");\n\t\t\t\tif (revocationParts.length === 2) {\n\t\t\t\t\tconst compressedRevocationBytes = Converter.base64UrlToBytes(revocationParts[1]);\n\t\t\t\t\tconst decompressed = await Compression.decompress(\n\t\t\t\t\t\tcompressedRevocationBytes,\n\t\t\t\t\t\tCompressionType.Gzip\n\t\t\t\t\t);\n\n\t\t\t\t\tconst bitString = BitString.fromBits(\n\t\t\t\t\t\tdecompressed,\n\t\t\t\t\t\tEntityStorageIdentityConnector._REVOCATION_BITS_SIZE\n\t\t\t\t\t);\n\n\t\t\t\t\tfor (const credentialIndex of credentialIndices) {\n\t\t\t\t\t\tbitString.setBit(credentialIndex, true);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst compressed = await Compression.compress(bitString.getBits(), CompressionType.Gzip);\n\t\t\t\t\trevocationService.serviceEndpoint = `data:application/octet-stream;base64,${Converter.bytesToBase64Url(compressed)}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, issuerDidDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"revokeVerifiableCredentialsFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Unrevoke verifiable credential(s).\n\t * @param controller The controller of the identity who can make changes.\n\t * @param issuerDocumentId The id of the document to update the revocation list for.\n\t * @param credentialIndices The revocation bitmap index or indices to un revoke.\n\t * @returns A promise that resolves when the credentials have been unrevoked.\n\t */\n\tpublic async unrevokeVerifiableCredentials(\n\t\tcontroller: string,\n\t\tissuerDocumentId: string,\n\t\tcredentialIndices: number[]\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(issuerDocumentId),\n\t\t\tissuerDocumentId\n\t\t);\n\t\tGuards.arrayValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(credentialIndices),\n\t\t\tcredentialIndices\n\t\t);\n\n\t\ttry {\n\t\t\tconst issuerIdentityDocument = await this.resolveOwnDocumentCached(issuerDocumentId);\n\t\t\tconst issuerDidDocument = issuerIdentityDocument.document;\n\n\t\t\tconst revocationService = issuerDidDocument.service?.find(s => s.id.endsWith(\"#revocation\"));\n\t\t\tif (\n\t\t\t\trevocationService &&\n\t\t\t\tIs.string(revocationService.serviceEndpoint) &&\n\t\t\t\trevocationService.type === \"BitstringStatusList\"\n\t\t\t) {\n\t\t\t\tconst revocationParts = revocationService.serviceEndpoint.split(\",\");\n\t\t\t\tif (revocationParts.length === 2) {\n\t\t\t\t\tconst compressedRevocationBytes = Converter.base64UrlToBytes(revocationParts[1]);\n\t\t\t\t\tconst decompressed = await Compression.decompress(\n\t\t\t\t\t\tcompressedRevocationBytes,\n\t\t\t\t\t\tCompressionType.Gzip\n\t\t\t\t\t);\n\n\t\t\t\t\tconst bitString = BitString.fromBits(\n\t\t\t\t\t\tdecompressed,\n\t\t\t\t\t\tEntityStorageIdentityConnector._REVOCATION_BITS_SIZE\n\t\t\t\t\t);\n\n\t\t\t\t\tfor (const credentialIndex of credentialIndices) {\n\t\t\t\t\t\tbitString.setBit(credentialIndex, false);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst compressed = await Compression.compress(bitString.getBits(), CompressionType.Gzip);\n\t\t\t\t\trevocationService.serviceEndpoint = `data:application/octet-stream;base64,${Converter.bytesToBase64Url(compressed)}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, issuerDidDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"unrevokeVerifiableCredentialsFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a verifiable presentation from the supplied verifiable credentials.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The method to associate with the presentation.\n\t * @param presentationId The id of the presentation.\n\t * @param contexts The contexts for the data stored in the verifiable credential.\n\t * @param types The types for the data stored in the verifiable credential.\n\t * @param verifiableCredentials The credentials to use for creating the presentation in jwt format.\n\t * @param options Additional options for creating the verifiable presentation.\n\t * @param options.expirationDate The date the verifiable presentation is valid until.\n\t * @param options.jwtHeaderFields Additional fields to add to the JWT header.\n\t * @param options.jwtPayloadFields Additional fields to add to the JWT payload.\n\t * @returns The created verifiable presentation and its token.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async createVerifiablePresentation(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\tpresentationId: string | undefined,\n\t\tcontexts: IJsonLdContextDefinitionRoot | undefined,\n\t\ttypes: string | string[] | undefined,\n\t\tverifiableCredentials: (string | IDidVerifiableCredentialV1)[],\n\t\toptions?: {\n\t\t\texpirationDate?: Date;\n\t\t\tjwtHeaderFields?: { [id: string]: string };\n\t\t\tjwtPayloadFields?: { [id: string]: string };\n\t\t}\n\t): Promise<{\n\t\tverifiablePresentation: IDidVerifiablePresentationV1;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tif (Is.array(types)) {\n\t\t\tGuards.arrayValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(types), types);\n\t\t} else if (Is.string(types)) {\n\t\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(types), types);\n\t\t}\n\t\tGuards.arrayValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verifiableCredentials),\n\t\t\tverifiableCredentials\n\t\t);\n\t\tif (!Is.undefined(options?.expirationDate)) {\n\t\t\tGuards.date(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(options.expirationDate),\n\t\t\t\toptions.expirationDate\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst holderIdentityDocument = await this.resolveOwnDocumentCached(idParts.id);\n\t\t\tconst holderDidDocument = holderIdentityDocument.document;\n\n\t\t\tconst methods = this.getAllMethods(holderDidDocument);\n\t\t\tconst methodAndArray = methods.find(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === verificationMethodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === verificationMethodId;\n\t\t\t});\n\n\t\t\tif (!methodAndArray) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"methodMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst didMethod = methodAndArray.method;\n\t\t\tif (!Is.stringValue(didMethod.publicKeyJwk?.x)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"publicKeyJwkMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst finalTypes: string[] = [DidTypes.VerifiablePresentation];\n\t\t\tif (Is.array(types)) {\n\t\t\t\tfinalTypes.push(...types);\n\t\t\t} else if (Is.stringValue(types)) {\n\t\t\t\tfinalTypes.push(types);\n\t\t\t}\n\n\t\t\tconst combinedContext =\n\t\t\t\tJsonLdProcessor.combineContexts(DidContexts.ContextVCv1, contexts) ??\n\t\t\t\tDidContexts.ContextVCv1;\n\n\t\t\tconst verifiablePresentation: IDidVerifiablePresentationV1 = {\n\t\t\t\t\"@context\": combinedContext as [typeof DidContexts.ContextVCv1],\n\t\t\t\tid: presentationId,\n\t\t\t\ttype: finalTypes,\n\t\t\t\tverifiableCredential: verifiableCredentials,\n\t\t\t\tholder: idParts.id\n\t\t\t};\n\n\t\t\tconst jwtHeader: IJwtHeader = {\n\t\t\t\t...options?.jwtHeaderFields,\n\t\t\t\tkid: didMethod.id,\n\t\t\t\ttyp: \"JWT\",\n\t\t\t\talg: JwsAlgorithms.EdDSA\n\t\t\t};\n\n\t\t\tconst jwtVp = ObjectHelper.pick(ObjectHelper.clone(verifiablePresentation), [\n\t\t\t\t\"@context\",\n\t\t\t\t\"type\",\n\t\t\t\t\"verifiableCredential\"\n\t\t\t]);\n\n\t\t\t// Add the proof to the VP after extracting the jwt data\n\t\t\t// as the jwt does not include the proof\n\t\t\tverifiablePresentation.proof = await this.createProof(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tProofTypes.DataIntegrityProof,\n\t\t\t\tJsonLdHelper.toNodeObject(verifiablePresentation),\n\t\t\t\tholderDidDocument\n\t\t\t);\n\n\t\t\tconst jwtPayload: IJwtPayload = {\n\t\t\t\t...options?.jwtPayloadFields,\n\t\t\t\tiss: verifiablePresentation.holder,\n\t\t\t\tnbf: Math.floor(Date.now() / 1000),\n\t\t\t\tvp: jwtVp\n\t\t\t};\n\n\t\t\tif (Is.date(options?.expirationDate)) {\n\t\t\t\tjwtPayload.exp = Math.floor(options.expirationDate.getTime() / 1000);\n\t\t\t}\n\n\t\t\tconst signature = await Jwt.encodeWithSigner(jwtHeader, jwtPayload, async (header, payload) =>\n\t\t\t\tVaultConnectorHelper.jwtSigner(\n\t\t\t\t\tthis._vaultConnector,\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment ?? \"\"),\n\t\t\t\t\theader,\n\t\t\t\t\tpayload\n\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tverifiablePresentation,\n\t\t\t\tjwt: signature\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createVerifiablePresentationFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Check a verifiable presentation is valid.\n\t * @param presentation The presentation to verify.\n\t * @returns The presentation stored in the jwt and the revocation status.\n\t */\n\tpublic async checkVerifiablePresentation(\n\t\tpresentation: string | IDidVerifiablePresentation\n\t): Promise<{\n\t\trevoked: boolean;\n\t\tverifiablePresentation?: IDidVerifiablePresentationV1;\n\t\tissuers?: IDidDocument[];\n\t}> {\n\t\tif (Is.object(presentation)) {\n\t\t\tconst { proof, ...doc } = presentation as IDidVerifiablePresentationV1;\n\t\t\tconst proofEntry = ArrayHelper.fromObjectOrArray(proof)[0];\n\t\t\tGuards.objectValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(proofEntry), proofEntry);\n\t\t\tconst presentationVerified = await this.verifyProof(\n\t\t\t\tJsonLdHelper.toNodeObject(doc),\n\t\t\t\tproofEntry\n\t\t\t);\n\t\t\tif (!presentationVerified) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"signatureVerificationFailed\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tlet revoked = false;\n\t\t\tfor (const embeddedCredential of doc.verifiableCredential ?? []) {\n\t\t\t\tconst credentialCheck = await this.checkVerifiableCredential(embeddedCredential);\n\t\t\t\tif (credentialCheck.revoked) {\n\t\t\t\t\trevoked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { revoked, verifiablePresentation: doc };\n\t\t}\n\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(presentation),\n\t\t\tpresentation\n\t\t);\n\n\t\tconst presentationJwt = presentation;\n\n\t\ttry {\n\t\t\tconst jwtDecoded = await Jwt.decode(presentationJwt);\n\n\t\t\tconst jwtHeader = jwtDecoded.header;\n\t\t\tconst jwtPayload = jwtDecoded.payload;\n\t\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\t\tif (\n\t\t\t\tIs.undefined(jwtHeader) ||\n\t\t\t\tIs.undefined(jwtPayload) ||\n\t\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\t\tIs.undefined(jwtSignature)\n\t\t\t) {\n\t\t\t\tthrow new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, \"jwkSignatureFailed\");\n\t\t\t}\n\n\t\t\tconst holderDocumentId = jwtPayload.iss;\n\t\t\tconst holderIdentityDocument = await this._didDocumentEntityStorage.get(holderDocumentId);\n\t\t\tif (Is.undefined(holderIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tholderDocumentId\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tholderIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\n\t\t\tconst issuers: IDidDocument[] = [];\n\t\t\tconst tokensRevoked: boolean[] = [];\n\t\t\tconst verifiablePresentation = jwtPayload?.vp as IDidVerifiablePresentationV1;\n\t\t\tif (\n\t\t\t\tIs.object<IDidVerifiablePresentationV1>(verifiablePresentation) &&\n\t\t\t\tIs.array(verifiablePresentation.verifiableCredential)\n\t\t\t) {\n\t\t\t\tfor (const vcJwt of verifiablePresentation.verifiableCredential) {\n\t\t\t\t\tlet revoked = false;\n\t\t\t\t\tif (Is.stringValue(vcJwt)) {\n\t\t\t\t\t\tconst jwt = await Jwt.decode(vcJwt);\n\n\t\t\t\t\t\tif (Is.string(jwt.payload?.iss)) {\n\t\t\t\t\t\t\tconst issuerDocumentId = jwt.payload.iss;\n\t\t\t\t\t\t\tverifiablePresentation.holder = issuerDocumentId;\n\n\t\t\t\t\t\t\tconst issuerDidDocument = await this._didDocumentEntityStorage.get(issuerDocumentId);\n\t\t\t\t\t\t\tif (Is.undefined(issuerDidDocument)) {\n\t\t\t\t\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\t\t\t\t\tissuerDocumentId\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\t\t\t\t\tissuerDidDocument,\n\t\t\t\t\t\t\t\tthis._vaultConnector\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tissuers.push({\n\t\t\t\t\t\t\t\t\"@context\": DidContexts.Context,\n\t\t\t\t\t\t\t\t...issuerDidDocument\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst credentialCheck = await this.checkVerifiableCredential(vcJwt);\n\t\t\t\t\t\trevoked = credentialCheck.revoked;\n\t\t\t\t\t}\n\t\t\t\t\ttokensRevoked.push(revoked);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\trevoked: tokensRevoked.some(Boolean),\n\t\t\t\tverifiablePresentation,\n\t\t\t\tissuers\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (BaseError.isErrorMessage(error, /revoked/i)) {\n\t\t\t\treturn {\n\t\t\t\t\trevoked: true\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"checkingVerifiablePresentationFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a proof for arbitrary data with the specified verification method.\n\t * This method uses async signing to ensure the private key never leaves the vault,\n\t * with algorithm validation to ensure key type compatibility.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param proofType The type of proof to create.\n\t * @param unsecureDocument The unsecure document to create the proof for.\n\t * @param resolvedDocument Optional already-resolved document for the DID, so a caller that\n\t * just resolved it (e.g. createVerifiableCredential) skips a redundant re-resolve. Resolves\n\t * it itself if omitted.\n\t * @returns The proof.\n\t * @throws NotFoundError if the identity or method is not found.\n\t * @throws GeneralError if algorithm doesn't match key type or proof creation fails.\n\t */\n\tpublic async createProof(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\tproofType: ProofTypes,\n\t\tunsecureDocument: IJsonLdNodeObject,\n\t\tresolvedDocument?: IDidDocument\n\t): Promise<IProof> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.arrayOneOf<ProofTypes>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(proofType),\n\t\t\tproofType,\n\t\t\tObject.values(ProofTypes)\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(unsecureDocument),\n\t\t\tunsecureDocument\n\t\t);\n\t\tif (!Is.undefined(resolvedDocument)) {\n\t\t\tGuards.object<IDidDocument>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(resolvedDocument),\n\t\t\t\tresolvedDocument\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst didDocument = Is.undefined(resolvedDocument)\n\t\t\t\t? (await this.resolveOwnDocumentCached(idParts.id)).document\n\t\t\t\t: resolvedDocument;\n\n\t\t\tconst methods = this.getAllMethods(didDocument);\n\t\t\tconst methodAndArray = methods.find(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === verificationMethodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === verificationMethodId;\n\t\t\t});\n\n\t\t\tif (!methodAndArray) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"methodMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst didMethod = methodAndArray.method;\n\t\t\tif (!Is.stringValue(didMethod.publicKeyJwk?.x)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"publicKeyJwkMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst vaultKey = EntityStorageIdentityConnector.buildVaultKey(\n\t\t\t\tdidDocument.id,\n\t\t\t\tidParts.fragment ?? \"\"\n\t\t\t);\n\t\t\tconst keyType = await this._vaultConnector.getKeyType(vaultKey);\n\n\t\t\tif (Is.undefined(keyType)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"privateKeyMissing\", {\n\t\t\t\t\tkeyId: vaultKey\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst unsignedProof = ProofHelper.createUnsignedProof(proofType, verificationMethodId);\n\n\t\t\tconst signedProof = await ProofHelper.createProofWithSigner(\n\t\t\t\tproofType,\n\t\t\t\tunsecureDocument,\n\t\t\t\tunsignedProof,\n\t\t\t\tasync (data, algorithm) => this.signWithVault(vaultKey, keyType, data, algorithm)\n\t\t\t);\n\n\t\t\treturn signedProof;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createProofFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Verify proof for arbitrary data with the specified verification method.\n\t * @param document The document to verify.\n\t * @param proof The proof to verify.\n\t * @returns True if the proof is verified.\n\t */\n\tpublic async verifyProof(document: IJsonLdNodeObject, proof: IProof): Promise<boolean> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(document),\n\t\t\tdocument\n\t\t);\n\t\tGuards.object<IProof>(EntityStorageIdentityConnector.CLASS_NAME, nameof(proof), proof);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(proof.verificationMethod),\n\t\t\tproof.verificationMethod\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(proof.verificationMethod);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tproof.verificationMethod\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst didIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);\n\t\t\tif (Is.undefined(didIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tidParts.id\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tdidIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tconst methods = this.getAllMethods(didDocument);\n\n\t\t\tconst methodAndArray = methods.find(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === proof.verificationMethod;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === proof.verificationMethod;\n\t\t\t});\n\n\t\t\tif (!methodAndArray) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"methodMissing\", {\n\t\t\t\t\tmethod: proof.verificationMethod\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst didMethod = methodAndArray.method;\n\t\t\tif (!Is.stringValue(didMethod.publicKeyJwk?.x)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"publicKeyJwkMissing\", {\n\t\t\t\t\tmethod: proof.verificationMethod\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst result = await ProofHelper.verifyProof(document, proof, didMethod.publicKeyJwk);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"verifyProofFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Signs data using the vault connector with algorithm validation.\n\t * @param vaultKey The vault key identifier.\n\t * @param keyType The type of the key.\n\t * @param data The data to sign.\n\t * @param algorithm The signing algorithm.\n\t * @returns The signature bytes.\n\t * @throws GeneralError if algorithm doesn't match key type.\n\t * @internal\n\t */\n\tprivate async signWithVault(\n\t\tvaultKey: string,\n\t\tkeyType: VaultKeyType,\n\t\tdata: Uint8Array,\n\t\talgorithm: string\n\t): Promise<Uint8Array> {\n\t\tif (algorithm === JwsAlgorithms.EdDSA && keyType !== VaultKeyType.Ed25519) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"algorithmKeyTypeMismatch\",\n\t\t\t\t{\n\t\t\t\t\talgorithm,\n\t\t\t\t\texpectedKeyType: VaultKeyType.Ed25519,\n\t\t\t\t\tactualKeyType: keyType,\n\t\t\t\t\tkeyId: vaultKey\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t\treturn this._vaultConnector.sign(vaultKey, data);\n\t}\n\n\t/**\n\t * Get all the methods from a document.\n\t * @param document The document to get the methods from.\n\t * @returns The methods.\n\t * @internal\n\t */\n\tprivate getAllMethods(\n\t\tdocument: IDidDocument\n\t): { arrayKey: string; method: Partial<IDidDocumentVerificationMethod> }[] {\n\t\tconst methods: {\n\t\t\tarrayKey: string;\n\t\t\tmethod: Partial<IDidDocumentVerificationMethod>;\n\t\t}[] = [];\n\n\t\tconst methodTypes: DidVerificationMethodType[] = Object.values(DidVerificationMethodType);\n\n\t\tfor (const methodType of methodTypes) {\n\t\t\tconst mt = document[methodType];\n\t\t\tif (Is.arrayValue(mt)) {\n\t\t\t\tmethods.push(\n\t\t\t\t\t...mt.map(m => ({\n\t\t\t\t\t\tarrayKey: methodType,\n\t\t\t\t\t\tmethod: Is.string(m) ? { id: m } : m\n\t\t\t\t\t}))\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn methods;\n\t}\n\n\t/**\n\t * Resolve the issuer document for a verification method, verified against its stored signature.\n\t * @param verificationMethodId The verification method id whose owning DID to resolve.\n\t * @returns The resolved document.\n\t * @throws NotFoundError if the id has no DID, or the DID cannot be resolved.\n\t * @internal\n\t */\n\tprivate async resolveAssertionMethodDocument(\n\t\tverificationMethodId: string\n\t): Promise<IDidDocument> {\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\tif (Is.empty(idParts.fragment)) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"missingDid\",\n\t\t\t\tverificationMethodId\n\t\t\t);\n\t\t}\n\n\t\tconst identityDocument = await this._didDocumentEntityStorage.get(idParts.id);\n\t\tif (Is.undefined(identityDocument)) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"documentNotFound\",\n\t\t\t\tidParts.id\n\t\t\t);\n\t\t}\n\t\tawait EntityStorageIdentityConnector.verifyDocument(identityDocument, this._vaultConnector);\n\n\t\treturn identityDocument.document;\n\t}\n\n\t/**\n\t * Cache key for a DID resolved for this connector's own sign/mutate operations (role 1).\n\t * Deliberately namespaced (\"own\") and never shared with proof/credential verification of\n\t * third-party claims (role 2/3), which this connector never caches.\n\t * @param documentId The DID being resolved.\n\t * @returns The cache key.\n\t * @internal\n\t */\n\tprivate ownDidCacheKey(documentId: string): string {\n\t\treturn `${EntityStorageIdentityConnector.CLASS_NAME}:own:${documentId}`;\n\t}\n\n\t/**\n\t * Load and verify a document's own storage entity, uncached.\n\t * @param documentId The DID to load.\n\t * @returns The verified storage entity.\n\t * @throws NotFoundError if the DID could not be resolved.\n\t * @internal\n\t */\n\tprivate async loadOwnDocument(documentId: string): Promise<IdentityDocument> {\n\t\tconst identityDocument = await this._didDocumentEntityStorage.get(documentId);\n\t\tif (Is.undefined(identityDocument)) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"documentNotFound\",\n\t\t\t\tdocumentId\n\t\t\t);\n\t\t}\n\t\tawait EntityStorageIdentityConnector.verifyDocument(identityDocument, this._vaultConnector);\n\n\t\treturn identityDocument;\n\t}\n\n\t/**\n\t * Resolve a document's own storage entity for this connector's own sign/mutate operations,\n\t * cached for didResolutionCacheTtlMs (0 disables caching and resolves fresh every call).\n\t * Only ever used for the connector's own create/update/revoke paths - never for verifyProof\n\t * or credential/presentation verification, which must stay uncached.\n\t * A clone is always returned: mutators edit the entity in place before storing it, and the\n\t * cached instance must never be handed out by reference.\n\t * @param documentId The DID to resolve.\n\t * @returns The verified storage entity.\n\t * @throws NotFoundError if the DID could not be resolved.\n\t * @internal\n\t */\n\tprivate async resolveOwnDocumentCached(documentId: string): Promise<IdentityDocument> {\n\t\tif (Is.undefined(this._didResolutionCache)) {\n\t\t\treturn this.loadOwnDocument(documentId);\n\t\t}\n\n\t\tconst identityDocument = await this._didResolutionCache.getOrSet(\n\t\t\tthis.ownDidCacheKey(documentId),\n\t\t\tasync () => this.loadOwnDocument(documentId)\n\t\t);\n\t\treturn ObjectHelper.clone(identityDocument);\n\t}\n\n\t/**\n\t * Check whether a credential's status entry or entries report it as revoked.\n\t * @param document The issuer document owning the revocation bitmap service.\n\t * @param credentialStatus The credential's status entry or entries to check.\n\t * @returns True if any entry is reported revoked.\n\t * @internal\n\t */\n\tprivate async checkCredentialStatusRevoked(\n\t\tdocument: IDidDocument,\n\t\tcredentialStatus: IDidCredentialStatus | IDidCredentialStatus[] | undefined\n\t): Promise<boolean> {\n\t\tlet statuses: IDidCredentialStatus[] = [];\n\t\tif (Is.array<IDidCredentialStatus>(credentialStatus)) {\n\t\t\tstatuses = credentialStatus;\n\t\t} else if (Is.object<IDidCredentialStatus>(credentialStatus)) {\n\t\t\tstatuses = [credentialStatus];\n\t\t}\n\n\t\tfor (const status of statuses) {\n\t\t\tif (await this.checkRevocation(document, status.revocationBitmapIndex)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Check if a revocation index is revoked.\n\t * @param document The document to check.\n\t * @param revocationBitmapIndex The revocation index to check.\n\t * @returns True if the index is revoked.\n\t * @internal\n\t */\n\tprivate async checkRevocation(\n\t\tdocument: IDidDocument,\n\t\trevocationBitmapIndex?: unknown\n\t): Promise<boolean> {\n\t\tconst revocationIndex = Coerce.number(revocationBitmapIndex);\n\t\tif (Is.number(revocationIndex)) {\n\t\t\tconst revocationService = document.service?.find(s => s.id.endsWith(\"#revocation\"));\n\t\t\tif (\n\t\t\t\trevocationService &&\n\t\t\t\tIs.string(revocationService.serviceEndpoint) &&\n\t\t\t\trevocationService.type === \"BitstringStatusList\"\n\t\t\t) {\n\t\t\t\tconst revocationParts = revocationService.serviceEndpoint.split(\",\");\n\t\t\t\tif (revocationParts.length === 2) {\n\t\t\t\t\tconst compressedRevocationBytes = Converter.base64UrlToBytes(revocationParts[1]);\n\t\t\t\t\tconst decompressed = await Compression.decompress(\n\t\t\t\t\t\tcompressedRevocationBytes,\n\t\t\t\t\t\tCompressionType.Gzip\n\t\t\t\t\t);\n\n\t\t\t\t\tconst bitString = BitString.fromBits(\n\t\t\t\t\t\tdecompressed,\n\t\t\t\t\t\tEntityStorageIdentityConnector._REVOCATION_BITS_SIZE\n\t\t\t\t\t);\n\n\t\t\t\t\treturn bitString.getBit(revocationIndex);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Update the document in storage.\n\t * @param controller The controller of the document.\n\t * @param didDocument The did document to store.\n\t * @returns A promise that resolves when the document has been signed and persisted.\n\t * @internal\n\t */\n\tprivate async updateDocument(controller: string, didDocument: IDidDocument): Promise<void> {\n\t\tconst stringifiedDocument = JsonHelper.canonicalize(didDocument);\n\t\tconst docBytes = Converter.utf8ToBytes(stringifiedDocument);\n\n\t\tconst signature = await this._vaultConnector.sign(\n\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, \"did\"),\n\t\t\tdocBytes\n\t\t);\n\n\t\tconst identityDocument: IdentityDocument = {\n\t\t\tid: didDocument.id,\n\t\t\tdocument: didDocument,\n\t\t\tsignature: Converter.bytesToBase64(signature),\n\t\t\tcontroller\n\t\t};\n\n\t\tawait this._didDocumentEntityStorage.set(identityDocument);\n\n\t\tthis._didResolutionCache?.set(\n\t\t\tthis.ownDidCacheKey(didDocument.id),\n\t\t\tObjectHelper.clone(identityDocument)\n\t\t);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"entityStorageIdentityConnector.js","sourceRoot":"","sources":["../../src/entityStorageIdentityConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,WAAW,EACX,SAAS,EACT,SAAS,EACT,MAAM,EACN,WAAW,EACX,eAAe,EACf,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF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CACpD,CAAC;oBAEF,OAAO,SAAS,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;gBAC1C,CAAC;YACF,CAAC;QACF,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IAED;;;;;;OAMG;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,gBAAgB,GAAqB;YAC1C,EAAE,EAAE,WAAW,CAAC,EAAE;YAClB,QAAQ,EAAE,WAAW;YACrB,SAAS,EAAE,SAAS,CAAC,aAAa,CAAC,SAAS,CAAC;YAC7C,UAAU;SACV,CAAC;QAEF,MAAM,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAE3D,IAAI,CAAC,mBAAmB,EAAE,GAAG,CAC5B,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC,EACnC,YAAY,CAAC,KAAK,CAAC,gBAAgB,CAAC,CACpC,CAAC;IACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tArrayHelper,\n\tBaseError,\n\tBitString,\n\tCoerce,\n\tCompression,\n\tCompressionType,\n\tConverter,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tJsonHelper,\n\tLruCache,\n\tNotFoundError,\n\tObjectHelper,\n\tRandomHelper,\n\tUrl,\n\tUrn\n} from \"@twin.org/core\";\nimport {\n\tJsonLdHelper,\n\tJsonLdProcessor,\n\ttype IJsonLdContextDefinitionRoot,\n\ttype IJsonLdNodeObject\n} from \"@twin.org/data-json-ld\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport {\n\tDocumentHelper,\n\tVerificationHelper,\n\ttype IIdentityConnector\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDidContexts,\n\tDidTypes,\n\tDidVerificationMethodType,\n\ttype IDidCredentialStatus,\n\ttype IDidVerifiableCredential,\n\tJwsAlgorithms,\n\tProofHelper,\n\tProofTypes,\n\ttype IDidDocument,\n\ttype IDidDocumentVerificationMethod,\n\ttype IDidService,\n\ttype IDidVerifiableCredentialV1,\n\ttype IDidVerifiablePresentationV1,\n\ttype IProof,\n\ttype IDidVerifiablePresentation\n} from \"@twin.org/standards-w3c-did\";\nimport {\n\tVaultConnectorFactory,\n\tVaultConnectorHelper,\n\tVaultKeyType,\n\ttype IVaultConnector\n} from \"@twin.org/vault-models\";\nimport { Jwk, Jwt, type IJwk, type IJwtHeader, type IJwtPayload } from \"@twin.org/web\";\nimport type { IdentityDocument } from \"./entities/identityDocument.js\";\nimport type { IEntityStorageIdentityConnectorConstructorOptions } from \"./models/IEntityStorageIdentityConnectorConstructorOptions.js\";\n\n/**\n * Class for performing identity operations using entity storage.\n */\nexport class EntityStorageIdentityConnector implements IIdentityConnector {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageIdentityConnector>();\n\n\t/**\n\t * The namespace supported by the identity connector.\n\t */\n\tpublic static readonly NAMESPACE: string = \"entity-storage\";\n\n\t/**\n\t * The size of the revocation bitmap in bits (16Kb).\n\t * @internal\n\t */\n\tprivate static readonly _REVOCATION_BITS_SIZE: number = 131072;\n\n\t/**\n\t * The entity storage for identities.\n\t * @internal\n\t */\n\tprotected readonly _didDocumentEntityStorage: IEntityStorageConnector<IdentityDocument>;\n\n\t/**\n\t * The vault for the keys.\n\t * @internal\n\t */\n\tprotected readonly _vaultConnector: IVaultConnector;\n\n\t/**\n\t * TTL in ms for caching DID documents resolved for this connector's own sign/mutate\n\t * operations. 0 disables caching (see resolveOwnDocumentCached). Never applied to proof or\n\t * credential verification of third-party claims.\n\t * @internal\n\t */\n\tprivate readonly _didResolutionCacheTtlMs: number;\n\n\t/**\n\t * Maximum number of own DID documents retained in cache.\n\t * @internal\n\t */\n\tprivate readonly _didResolutionCacheCapacity: number;\n\n\t/**\n\t * Maximum wait time for own DID cache getOrSet mutex acquisition in milliseconds.\n\t * @internal\n\t */\n\tprivate readonly _didResolutionCacheMutexTimeoutMs?: number;\n\n\t/**\n\t * LRU cache for own DID documents. Undefined when caching is disabled (ttl is 0).\n\t * @internal\n\t */\n\tprivate readonly _didResolutionCache?: LruCache<IdentityDocument>;\n\n\t/**\n\t * Create a new instance of EntityStorageIdentityConnector.\n\t * @param options The options for the identity connector.\n\t */\n\tconstructor(options?: IEntityStorageIdentityConnectorConstructorOptions) {\n\t\tthis._didDocumentEntityStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.didDocumentEntityStorageType ?? \"identity-document\"\n\t\t);\n\t\tthis._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? \"vault\");\n\n\t\tthis._didResolutionCacheTtlMs = options?.config?.didResolutionCacheTtlMs ?? 30_000;\n\t\tthis._didResolutionCacheCapacity = options?.config?.didResolutionCacheCapacity ?? 1000;\n\t\tthis._didResolutionCacheMutexTimeoutMs = options?.config?.didResolutionCacheMutexTimeoutMs;\n\t\tthis._didResolutionCache =\n\t\t\tthis._didResolutionCacheTtlMs > 0\n\t\t\t\t? new LruCache<IdentityDocument>({\n\t\t\t\t\t\tcapacity: this._didResolutionCacheCapacity,\n\t\t\t\t\t\tttiMs: this._didResolutionCacheTtlMs,\n\t\t\t\t\t\tmutexTimeoutMs: this._didResolutionCacheMutexTimeoutMs\n\t\t\t\t\t})\n\t\t\t\t: undefined;\n\t}\n\n\t/**\n\t * Build the key name to access the specified key in the vault.\n\t * @param identity The identity of the user to access the vault keys.\n\t * @param key The key to access in the vault.\n\t * @returns The vault key.\n\t * @internal\n\t */\n\tpublic static buildVaultKey(identity: string, key: string): string {\n\t\treturn `${identity}/${key}`;\n\t}\n\n\t/**\n\t * Verify the document in storage.\n\t * @param didDocument The did document that was stored.\n\t * @param vaultConnector The vault connector to use for verification.\n\t * @returns A promise that resolves when verification is complete.\n\t * @throws GeneralError if the document signature is invalid.\n\t * @internal\n\t */\n\tpublic static async verifyDocument(\n\t\tdidDocument: IdentityDocument,\n\t\tvaultConnector: IVaultConnector\n\t): Promise<void> {\n\t\tconst stringifiedDocument = JsonHelper.canonicalize(didDocument.document);\n\t\tconst docBytes = Converter.utf8ToBytes(stringifiedDocument);\n\n\t\tconst verified = await vaultConnector.verify(\n\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, \"did\"),\n\t\t\tdocBytes,\n\t\t\tConverter.base64ToBytes(didDocument.signature)\n\t\t);\n\n\t\tif (!verified) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"signatureVerificationFailed\"\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageIdentityConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Stop the service.\n\t * Destroys in-memory resources owned by this component.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t * @returns A promise that resolves when the service has stopped.\n\t */\n\tpublic async stop(nodeLoggingComponentType?: string): Promise<void> {\n\t\tthis._didResolutionCache?.destroy();\n\t}\n\n\t/**\n\t * Create a new document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns The created document.\n\t */\n\tpublic async createDocument(controller: string): Promise<IDidDocument> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\n\t\ttry {\n\t\t\tconst did = `did:${EntityStorageIdentityConnector.NAMESPACE}:${Converter.bytesToHex(RandomHelper.generate(32), true)}`;\n\n\t\t\tawait this._vaultConnector.createKey(\n\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(did, \"did\"),\n\t\t\t\tVaultKeyType.Ed25519\n\t\t\t);\n\n\t\t\tconst bitString = new BitString(EntityStorageIdentityConnector._REVOCATION_BITS_SIZE);\n\t\t\tconst compressed = await Compression.compress(bitString.getBits(), CompressionType.Gzip);\n\n\t\t\tconst didDocument: IDidDocument = {\n\t\t\t\t\"@context\": DidContexts.Context,\n\t\t\t\tid: did,\n\t\t\t\tservice: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${did}#revocation`,\n\t\t\t\t\t\ttype: \"BitstringStatusList\",\n\t\t\t\t\t\tserviceEndpoint: `data:application/octet-stream;base64,${Converter.bytesToBase64Url(compressed)}`\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t};\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\n\t\t\treturn didDocument;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createDocumentFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove a document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to remove.\n\t * @param options Optional settings.\n\t * @param options.removeKeys Also remove any associated private keys from the vault.\n\t * @returns A promise that resolves when the document has been removed.\n\t */\n\tpublic async removeDocument(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\toptions?: { removeKeys?: boolean }\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\n\t\ttry {\n\t\t\tconst didDocument = await this._didDocumentEntityStorage.get(documentId);\n\t\t\tif (Is.empty(didDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tdocumentId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this._didDocumentEntityStorage.remove(documentId);\n\t\t\tthis._didResolutionCache?.delete(this.ownDidCacheKey(documentId));\n\n\t\t\tif (options?.removeKeys ?? false) {\n\t\t\t\tconst methods = this.getAllMethods(didDocument.document);\n\t\t\t\tfor (const { method } of methods) {\n\t\t\t\t\tconst methodId = Is.string(method) ? method : method.id;\n\t\t\t\t\tif (Is.stringValue(methodId)) {\n\t\t\t\t\t\tconst idParts = DocumentHelper.parseId(methodId);\n\t\t\t\t\t\tif (Is.stringValue(idParts.fragment)) {\n\t\t\t\t\t\t\tconst vaultKey = EntityStorageIdentityConnector.buildVaultKey(\n\t\t\t\t\t\t\t\tdocumentId,\n\t\t\t\t\t\t\t\tidParts.fragment\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (await this._vaultConnector.keyExists(vaultKey)) {\n\t\t\t\t\t\t\t\tawait this._vaultConnector.removeKey(vaultKey);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeDocumentFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Add a verification method to the document in JSON Web key Format.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to add the verification method to.\n\t * @param verificationMethodType The type of the verification method to add.\n\t * @param verificationMethodId The id of the verification method, if undefined uses the kid of the generated JWK.\n\t * @returns The verification method.\n\t * @throws NotFoundError if the id can not be resolved.\n\t * @throws NotSupportedError if the platform does not support multiple keys.\n\t */\n\tpublic async addVerificationMethod(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\tverificationMethodType: DidVerificationMethodType,\n\t\tverificationMethodId?: string\n\t): Promise<IDidDocumentVerificationMethod> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.arrayOneOf<DidVerificationMethodType>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodType),\n\t\t\tverificationMethodType,\n\t\t\tObject.values(DidVerificationMethodType)\n\t\t);\n\n\t\tlet tempKeyId;\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentCached(documentId);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tlet methodKeyPublic;\n\t\t\tif (Is.stringValue(verificationMethodId)) {\n\t\t\t\t// If there is a verification method id, we will try to get the key from the vault.\n\t\t\t\ttry {\n\t\t\t\t\t// If there is an existing key, we will use it.\n\t\t\t\t\tconst existingKey = await this._vaultConnector.getKey(\n\t\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, verificationMethodId),\n\t\t\t\t\t\t\"public\"\n\t\t\t\t\t);\n\t\t\t\t\tmethodKeyPublic = existingKey.publicKey;\n\t\t\t\t} catch {}\n\t\t\t}\n\n\t\t\tif (Is.empty(methodKeyPublic)) {\n\t\t\t\t// If there is no existing key, we will create a new one with a temporary name.\n\t\t\t\ttempKeyId = `temp-vm-${Converter.bytesToBase64Url(RandomHelper.generate(16))}`;\n\t\t\t\tmethodKeyPublic = await this._vaultConnector.createKey(\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, tempKeyId),\n\t\t\t\t\tVaultKeyType.Ed25519\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst jwkParams: IJwk = {\n\t\t\t\talg: \"EdDSA\",\n\t\t\t\tkty: \"OKP\",\n\t\t\t\tcrv: \"Ed25519\",\n\t\t\t\tx: Converter.bytesToBase64Url(methodKeyPublic)\n\t\t\t};\n\n\t\t\tconst kid = await Jwk.generateKid(jwkParams);\n\n\t\t\tconst methodId = `${documentId}#${verificationMethodId ?? kid}`;\n\n\t\t\tif (Is.stringValue(tempKeyId)) {\n\t\t\t\t// If we created a temporary key, we will rename it to the final method id.\n\t\t\t\tawait this._vaultConnector.renameKey(\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, tempKeyId),\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, verificationMethodId ?? kid)\n\t\t\t\t);\n\t\t\t\ttempKeyId = undefined;\n\t\t\t}\n\n\t\t\tconst methods = this.getAllMethods(didDocument);\n\t\t\tconst existingMethodIndex = methods.findIndex(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === methodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === methodId;\n\t\t\t});\n\n\t\t\tif (existingMethodIndex !== -1) {\n\t\t\t\tconst methodArray =\n\t\t\t\t\tdidDocument[methods[existingMethodIndex].arrayKey as keyof IDidDocument];\n\n\t\t\t\tif (Is.array(methodArray)) {\n\t\t\t\t\tmethodArray.splice(existingMethodIndex, 1);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst didVerificationMethod: IDidDocumentVerificationMethod = {\n\t\t\t\tid: methodId,\n\t\t\t\tcontroller: documentId,\n\t\t\t\ttype: \"JsonWebKey2020\",\n\t\t\t\tpublicKeyJwk: {\n\t\t\t\t\t...jwkParams,\n\t\t\t\t\tkid\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tdidDocument[verificationMethodType] ??= [];\n\t\t\tdidDocument[verificationMethodType]?.push(didVerificationMethod);\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\n\t\t\treturn didVerificationMethod;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"addVerificationMethodFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t} finally {\n\t\t\tif (Is.stringValue(tempKeyId)) {\n\t\t\t\t// If we created a temporary key and it is still in use, we will remove it from the vault.\n\t\t\t\ttry {\n\t\t\t\t\tawait this._vaultConnector.removeKey(tempKeyId);\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Remove a verification method from the document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The id of the verification method.\n\t * @param options Optional settings.\n\t * @param options.removeKeys Also remove any associated private key from the vault.\n\t * @returns A promise that resolves when the verification method has been removed.\n\t * @throws NotFoundError if the id can not be resolved.\n\t * @throws NotSupportedError if the platform does not support multiple revocable keys.\n\t */\n\tpublic async removeVerificationMethod(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\toptions?: { removeKeys?: boolean }\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentCached(idParts.id);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tconst methods = this.getAllMethods(didDocument);\n\t\t\tconst existingMethodIndex = methods.findIndex(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === verificationMethodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === verificationMethodId;\n\t\t\t});\n\n\t\t\tif (existingMethodIndex !== -1) {\n\t\t\t\tconst methodArray =\n\t\t\t\t\tdidDocument[methods[existingMethodIndex].arrayKey as keyof IDidDocument];\n\n\t\t\t\tif (Is.array(methodArray)) {\n\t\t\t\t\tmethodArray.splice(existingMethodIndex, 1);\n\t\t\t\t\tif (methodArray.length === 0) {\n\t\t\t\t\t\tdelete didDocument[methods[existingMethodIndex].arrayKey as keyof IDidDocument];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"verificationMethodNotFound\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\n\t\t\tif (options?.removeKeys ?? false) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this._vaultConnector.removeKey(\n\t\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment)\n\t\t\t\t\t);\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeVerificationMethodFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Add a service to the document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to add the service to.\n\t * @param serviceId The id of the service.\n\t * @param serviceType The type of the service.\n\t * @param serviceEndpoint The endpoint for the service.\n\t * @returns The service.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async addService(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\tserviceId: string,\n\t\tserviceType: string | string[],\n\t\tserviceEndpoint: string | string[]\n\t): Promise<IDidService> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(serviceId), serviceId);\n\t\tif (Is.array(serviceType)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(serviceType),\n\t\t\t\tserviceType\n\t\t\t);\n\t\t} else {\n\t\t\tGuards.stringValue(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(serviceType),\n\t\t\t\tserviceType\n\t\t\t);\n\t\t}\n\t\tif (Is.array(serviceEndpoint)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(serviceEndpoint),\n\t\t\t\tserviceEndpoint\n\t\t\t);\n\t\t} else {\n\t\t\tGuards.stringValue(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(serviceEndpoint),\n\t\t\t\tserviceEndpoint\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentCached(documentId);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tconst fullServiceId = serviceId.includes(\"#\") ? serviceId : `${documentId}#${serviceId}`;\n\n\t\t\tif (Is.array(didDocument.service)) {\n\t\t\t\tconst existingServiceIndex = didDocument.service.findIndex(s => s.id === fullServiceId);\n\t\t\t\tif (existingServiceIndex !== -1) {\n\t\t\t\t\tdidDocument.service?.splice(existingServiceIndex, 1);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst didService: IDidService = {\n\t\t\t\tid: fullServiceId,\n\t\t\t\ttype: serviceType,\n\t\t\t\tserviceEndpoint\n\t\t\t};\n\n\t\t\tdidDocument.service ??= [];\n\t\t\tdidDocument.service.push(didService);\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\n\t\t\treturn didService;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"addServiceFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove a service from the document.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param serviceId The id of the service.\n\t * @returns A promise that resolves when the service has been removed.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async removeService(controller: string, serviceId: string): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(serviceId), serviceId);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(serviceId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, \"missingDid\", serviceId);\n\t\t\t}\n\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentCached(idParts.id);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tif (Is.array(didDocument.service)) {\n\t\t\t\tconst existingServiceIndex = didDocument.service.findIndex(s => s.id === serviceId);\n\t\t\t\tif (existingServiceIndex !== -1) {\n\t\t\t\t\tdidDocument.service?.splice(existingServiceIndex, 1);\n\t\t\t\t\tif (didDocument.service?.length === 0) {\n\t\t\t\t\t\tdelete didDocument.service;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\t\"serviceNotFound\",\n\t\t\t\t\t\tserviceId\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"serviceNotFound\",\n\t\t\t\t\tserviceId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeServiceFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Add an alias to the alsoKnownAs property on the document.\n\t * If the alias is already present the operation is a no-op.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to update.\n\t * @param alias The alias to add. Must be a Url or Urn (typically another DID).\n\t * @returns A promise that resolves when the alias has been added.\n\t * @throws GeneralError if the alias is not a Url or Urn.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async addAlsoKnownAs(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\talias: string\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(alias), alias);\n\t\tif (!Url.tryParseExact(alias) && !Urn.tryParseExact(alias)) {\n\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"invalidAlias\", { alias });\n\t\t}\n\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentCached(documentId);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tconst existing = Is.array(didDocument.alsoKnownAs) ? didDocument.alsoKnownAs : [];\n\t\t\tif (existing.includes(alias)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdidDocument.alsoKnownAs = [...existing, alias];\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"addAlsoKnownAsFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Remove an alias from the alsoKnownAs property on the document.\n\t * If the alias is not present the operation is a no-op.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param documentId The id of the document to update.\n\t * @param alias The alias to remove. Must be a Url or Urn.\n\t * @returns A promise that resolves when the alias has been removed.\n\t * @throws GeneralError if the alias is not a Url or Urn.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async removeAlsoKnownAs(\n\t\tcontroller: string,\n\t\tdocumentId: string,\n\t\talias: string\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(alias), alias);\n\t\tif (!Url.tryParseExact(alias) && !Urn.tryParseExact(alias)) {\n\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"invalidAlias\", { alias });\n\t\t}\n\n\t\ttry {\n\t\t\tconst didIdentityDocument = await this.resolveOwnDocumentCached(documentId);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tif (!Is.array(didDocument.alsoKnownAs) || !didDocument.alsoKnownAs.includes(alias)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst filtered = didDocument.alsoKnownAs.filter(a => a !== alias);\n\t\t\tif (filtered.length === 0) {\n\t\t\t\tdelete didDocument.alsoKnownAs;\n\t\t\t} else {\n\t\t\t\tdidDocument.alsoKnownAs = filtered;\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, didDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"removeAlsoKnownAsFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a verifiable credential for a verification method.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param id The id of the credential.\n\t * @param subject The credential subject to store in the verifiable credential.\n\t * @param options Additional options for creating the verifiable credential.\n\t * @param options.revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.\n\t * @param options.expirationDate The date the verifiable credential is valid until.\n\t * @param options.jwtHeaderFields Additional fields to add to the JWT header.\n\t * @param options.jwtPayloadFields Additional fields to add to the JWT payload.\n\t * @returns The created verifiable credential and its token.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async createVerifiableCredential(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\tid: string | undefined,\n\t\tsubject: IJsonLdNodeObject,\n\t\toptions?: {\n\t\t\trevocationIndex?: number;\n\t\t\texpirationDate?: Date;\n\t\t\tjwtHeaderFields?: { [id: string]: string };\n\t\t\tjwtPayloadFields?: { [id: string]: string };\n\t\t}\n\t): Promise<{\n\t\tverifiableCredential: IDidVerifiableCredentialV1;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(subject),\n\t\t\tsubject\n\t\t);\n\t\tif (!Is.undefined(options?.revocationIndex)) {\n\t\t\tGuards.number(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(options.revocationIndex),\n\t\t\t\toptions.revocationIndex\n\t\t\t);\n\t\t}\n\t\tif (!Is.undefined(options?.expirationDate)) {\n\t\t\tGuards.date(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(options.expirationDate),\n\t\t\t\toptions.expirationDate\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst issuerIdentityDocument = await this.resolveOwnDocumentCached(idParts.id);\n\t\t\tconst issuerDidDocument = issuerIdentityDocument.document;\n\n\t\t\tconst methods = this.getAllMethods(issuerDidDocument);\n\t\t\tconst methodAndArray = methods.find(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === verificationMethodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === verificationMethodId;\n\t\t\t});\n\n\t\t\tif (!methodAndArray) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"methodMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst verificationDidMethod = methodAndArray.method;\n\t\t\tif (!Is.stringValue(verificationDidMethod.publicKeyJwk?.x)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"publicKeyJwkMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst revocationService = issuerDidDocument.service?.find(s => s.id.endsWith(\"#revocation\"));\n\n\t\t\tconst subjectClone = ObjectHelper.clone(subject);\n\n\t\t\tconst credContext = ObjectHelper.extractProperty<IJsonLdContextDefinitionRoot>(subjectClone, [\n\t\t\t\t\"@context\"\n\t\t\t]);\n\t\t\tconst credId = ObjectHelper.extractProperty<string>(subjectClone, [\"@id\", \"id\"], false);\n\n\t\t\tconst verifiableCredential: IDidVerifiableCredentialV1 = {\n\t\t\t\t\"@context\": (JsonLdProcessor.combineContexts(DidContexts.ContextVCv1, credContext) ??\n\t\t\t\t\tDidContexts.ContextVCv1) as [typeof DidContexts.ContextVCv1],\n\t\t\t\tid,\n\t\t\t\ttype: DidTypes.VerifiableCredential,\n\t\t\t\tcredentialSubject: subjectClone,\n\t\t\t\tissuer: issuerDidDocument.id,\n\t\t\t\tissuanceDate: new Date(Date.now()).toISOString(),\n\t\t\t\texpirationDate: Is.date(options?.expirationDate)\n\t\t\t\t\t? options?.expirationDate.toISOString()\n\t\t\t\t\t: undefined,\n\t\t\t\tcredentialStatus:\n\t\t\t\t\trevocationService && !Is.undefined(options?.revocationIndex)\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tid: revocationService.id,\n\t\t\t\t\t\t\t\ttype: Is.array(revocationService.type)\n\t\t\t\t\t\t\t\t\t? revocationService.type[0]\n\t\t\t\t\t\t\t\t\t: revocationService.type,\n\t\t\t\t\t\t\t\trevocationBitmapIndex: options.revocationIndex.toString()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined\n\t\t\t};\n\n\t\t\tconst jwtHeader: IJwtHeader = {\n\t\t\t\t...options?.jwtHeaderFields,\n\t\t\t\tkid: verificationDidMethod.id,\n\t\t\t\ttyp: \"JWT\",\n\t\t\t\talg: JwsAlgorithms.EdDSA\n\t\t\t};\n\n\t\t\tconst jwtVc = ObjectHelper.pick(ObjectHelper.clone(verifiableCredential), [\n\t\t\t\t\"@context\",\n\t\t\t\t\"type\",\n\t\t\t\t\"credentialSubject\",\n\t\t\t\t\"credentialStatus\"\n\t\t\t]);\n\n\t\t\t// Add the proof to the VC after extracting the jwt data\n\t\t\t// as the jwt does not include the proof\n\t\t\tverifiableCredential.proof = await this.createProof(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tProofTypes.DataIntegrityProof,\n\t\t\t\tJsonLdHelper.toNodeObject(verifiableCredential),\n\t\t\t\tissuerDidDocument\n\t\t\t);\n\n\t\t\t// As we are adding the receipt to the data we update the JSON-LD context\n\t\t\tconst proofContext = verifiableCredential.proof[\"@context\"];\n\t\t\tif (Is.notEmpty(proofContext)) {\n\t\t\t\tverifiableCredential[\"@context\"] = (JsonLdProcessor.combineContexts(\n\t\t\t\t\tverifiableCredential[\"@context\"],\n\t\t\t\t\tproofContext\n\t\t\t\t) ?? verifiableCredential[\"@context\"]) as IDidVerifiableCredentialV1[\"@context\"];\n\t\t\t\tdelete verifiableCredential.proof[\"@context\"];\n\t\t\t}\n\n\t\t\tif (Is.array(jwtVc.credentialSubject)) {\n\t\t\t\tjwtVc.credentialSubject = jwtVc.credentialSubject.map(c => {\n\t\t\t\t\tObjectHelper.propertyDelete(c, \"id\");\n\t\t\t\t\treturn c;\n\t\t\t\t});\n\t\t\t} else if (Is.object(jwtVc.credentialSubject)) {\n\t\t\t\tObjectHelper.propertyDelete(jwtVc.credentialSubject, \"id\");\n\t\t\t}\n\n\t\t\tconst jwtPayload: IJwtPayload = {\n\t\t\t\t...options?.jwtPayloadFields,\n\t\t\t\tiss: idParts.id,\n\t\t\t\tnbf: Math.floor(Date.now() / 1000),\n\t\t\t\tjti: verifiableCredential.id,\n\t\t\t\tsub: credId,\n\t\t\t\tvc: jwtVc\n\t\t\t};\n\n\t\t\tif (Is.date(options?.expirationDate)) {\n\t\t\t\tjwtPayload.exp = Math.floor(options.expirationDate.getTime() / 1000);\n\t\t\t}\n\n\t\t\tconst signature = await Jwt.encodeWithSigner(jwtHeader, jwtPayload, async (header, payload) =>\n\t\t\t\tVaultConnectorHelper.jwtSigner(\n\t\t\t\t\tthis._vaultConnector,\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment ?? \"\"),\n\t\t\t\t\theader,\n\t\t\t\t\tpayload\n\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tverifiableCredential,\n\t\t\t\tjwt: signature\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createVerifiableCredentialFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Check a verifiable credential is valid.\n\t * @param credential The credential to verify.\n\t * @returns The credential stored in the jwt and the revocation status.\n\t */\n\tpublic async checkVerifiableCredential(credential: string | IDidVerifiableCredential): Promise<{\n\t\trevoked: boolean;\n\t\tverifiableCredential?: IDidVerifiableCredential;\n\t}> {\n\t\tif (Is.object(credential)) {\n\t\t\tGuards.objectValue<IDidVerifiableCredential>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(credential),\n\t\t\t\tcredential\n\t\t\t);\n\t\t\tGuards.objectValue<IDidVerifiableCredential>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(credential.proof),\n\t\t\t\tcredential.proof\n\t\t\t);\n\t\t\tVerificationHelper.checkValidityPeriod(credential);\n\n\t\t\tconst { proof, ...doc } = credential;\n\t\t\tconst proofEntry = ArrayHelper.fromObjectOrArray(proof)[0];\n\t\t\tGuards.stringValue(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(proofEntry.verificationMethod),\n\t\t\t\tproofEntry.verificationMethod\n\t\t\t);\n\n\t\t\tconst issuer = Is.object<{ id: string }>(doc.issuer) ? doc.issuer.id : doc.issuer;\n\t\t\tconst signerDid = DocumentHelper.parseId(proofEntry.verificationMethod).id;\n\t\t\tif (Is.stringValue(issuer) && issuer !== signerDid) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"issuerMismatch\", {\n\t\t\t\t\tissuer,\n\t\t\t\t\tmethod: proofEntry.verificationMethod\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst issuerDidDocument = await this.resolveAssertionMethodDocument(\n\t\t\t\tproofEntry.verificationMethod\n\t\t\t);\n\t\t\tconst publicKeyJwk = DocumentHelper.getJwk(\n\t\t\t\tissuerDidDocument,\n\t\t\t\tproofEntry.verificationMethod,\n\t\t\t\tDidVerificationMethodType.AssertionMethod\n\t\t\t);\n\n\t\t\tconst credentialVerified = await ProofHelper.verifyProof(\n\t\t\t\tJsonLdHelper.toNodeObject(doc),\n\t\t\t\tproofEntry,\n\t\t\t\tpublicKeyJwk\n\t\t\t);\n\t\t\tif (!credentialVerified) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"signatureVerificationFailed\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst revoked = await this.checkCredentialStatusRevoked(\n\t\t\t\tissuerDidDocument,\n\t\t\t\tdoc.credentialStatus\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\trevoked,\n\t\t\t\tverifiableCredential: revoked ? undefined : doc\n\t\t\t};\n\t\t}\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(credential), credential);\n\n\t\ttry {\n\t\t\tconst jwtDecoded = await Jwt.decode(credential);\n\n\t\t\tconst jwtHeader = jwtDecoded.header;\n\t\t\tconst jwtPayload = jwtDecoded.payload;\n\t\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\t\tif (\n\t\t\t\tIs.undefined(jwtHeader) ||\n\t\t\t\tIs.undefined(jwtPayload) ||\n\t\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\t\tIs.undefined(jwtSignature)\n\t\t\t) {\n\t\t\t\tthrow new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, \"jwkSignatureFailed\");\n\t\t\t}\n\n\t\t\tconst issuerDocumentId = jwtPayload.iss;\n\t\t\tconst issuerIdentityDocument = await this._didDocumentEntityStorage.get(issuerDocumentId);\n\t\t\tif (Is.undefined(issuerIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tissuerDocumentId\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tissuerIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\t\t\tconst issuerDidDocument = issuerIdentityDocument.document;\n\n\t\t\tGuards.stringValue(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(jwtHeader.kid),\n\t\t\t\tjwtHeader.kid\n\t\t\t);\n\t\t\tconst publicKeyJwk = DocumentHelper.getJwk(\n\t\t\t\tissuerDidDocument,\n\t\t\t\tjwtHeader.kid,\n\t\t\t\tDidVerificationMethodType.AssertionMethod\n\t\t\t);\n\n\t\t\tawait Jwt.verifySignature(credential, await Jwk.toCryptoKey(publicKeyJwk));\n\n\t\t\tconst verifiableCredential = jwtPayload.vc as IDidVerifiableCredentialV1;\n\t\t\tif (Is.object(verifiableCredential)) {\n\t\t\t\tif (Is.string(jwtPayload.jti)) {\n\t\t\t\t\tverifiableCredential.id = jwtPayload.jti;\n\t\t\t\t}\n\t\t\t\tverifiableCredential.issuer = issuerDocumentId;\n\t\t\t\tif (Is.number(jwtPayload.nbf)) {\n\t\t\t\t\tverifiableCredential.issuanceDate = new Date(jwtPayload.nbf * 1000).toISOString();\n\t\t\t\t}\n\t\t\t\tif (Is.number(jwtPayload.exp)) {\n\t\t\t\t\tverifiableCredential.expirationDate = new Date(jwtPayload.exp * 1000).toISOString();\n\t\t\t\t}\n\t\t\t\tif (Is.array(verifiableCredential.credentialSubject)) {\n\t\t\t\t\tverifiableCredential.credentialSubject = verifiableCredential.credentialSubject.map(c => {\n\t\t\t\t\t\tObjectHelper.propertySet(c, \"id\", jwtPayload.sub);\n\t\t\t\t\t\treturn c;\n\t\t\t\t\t});\n\t\t\t\t} else if (Is.object(verifiableCredential.credentialSubject)) {\n\t\t\t\t\tObjectHelper.propertySet(verifiableCredential.credentialSubject, \"id\", jwtPayload.sub);\n\t\t\t\t}\n\t\t\t}\n\t\t\tVerificationHelper.checkValidityPeriod(verifiableCredential);\n\n\t\t\tconst revoked = await this.checkCredentialStatusRevoked(\n\t\t\t\tissuerDidDocument,\n\t\t\t\tverifiableCredential.credentialStatus\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\trevoked,\n\t\t\t\tverifiableCredential: revoked ? undefined : verifiableCredential\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"checkingVerifiableCredentialFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Revoke verifiable credential(s).\n\t * @param controller The controller of the identity who can make changes.\n\t * @param issuerDocumentId The id of the document to update the revocation list for.\n\t * @param credentialIndices The revocation bitmap index or indices to revoke.\n\t * @returns A promise that resolves when the credentials have been revoked.\n\t */\n\tpublic async revokeVerifiableCredentials(\n\t\tcontroller: string,\n\t\tissuerDocumentId: string,\n\t\tcredentialIndices: number[]\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(issuerDocumentId),\n\t\t\tissuerDocumentId\n\t\t);\n\t\tGuards.arrayValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(credentialIndices),\n\t\t\tcredentialIndices\n\t\t);\n\n\t\ttry {\n\t\t\tconst issuerIdentityDocument = await this.resolveOwnDocumentCached(issuerDocumentId);\n\t\t\tconst issuerDidDocument = issuerIdentityDocument.document;\n\n\t\t\tconst revocationService = issuerDidDocument.service?.find(s => s.id.endsWith(\"#revocation\"));\n\t\t\tif (\n\t\t\t\trevocationService &&\n\t\t\t\tIs.string(revocationService.serviceEndpoint) &&\n\t\t\t\trevocationService.type === \"BitstringStatusList\"\n\t\t\t) {\n\t\t\t\tconst revocationParts = revocationService.serviceEndpoint.split(\",\");\n\t\t\t\tif (revocationParts.length === 2) {\n\t\t\t\t\tconst compressedRevocationBytes = Converter.base64UrlToBytes(revocationParts[1]);\n\t\t\t\t\tconst decompressed = await Compression.decompress(\n\t\t\t\t\t\tcompressedRevocationBytes,\n\t\t\t\t\t\tCompressionType.Gzip\n\t\t\t\t\t);\n\n\t\t\t\t\tconst bitString = BitString.fromBits(\n\t\t\t\t\t\tdecompressed,\n\t\t\t\t\t\tEntityStorageIdentityConnector._REVOCATION_BITS_SIZE\n\t\t\t\t\t);\n\n\t\t\t\t\tfor (const credentialIndex of credentialIndices) {\n\t\t\t\t\t\tbitString.setBit(credentialIndex, true);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst compressed = await Compression.compress(bitString.getBits(), CompressionType.Gzip);\n\t\t\t\t\trevocationService.serviceEndpoint = `data:application/octet-stream;base64,${Converter.bytesToBase64Url(compressed)}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, issuerDidDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"revokeVerifiableCredentialsFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Unrevoke verifiable credential(s).\n\t * @param controller The controller of the identity who can make changes.\n\t * @param issuerDocumentId The id of the document to update the revocation list for.\n\t * @param credentialIndices The revocation bitmap index or indices to un revoke.\n\t * @returns A promise that resolves when the credentials have been unrevoked.\n\t */\n\tpublic async unrevokeVerifiableCredentials(\n\t\tcontroller: string,\n\t\tissuerDocumentId: string,\n\t\tcredentialIndices: number[]\n\t): Promise<void> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(issuerDocumentId),\n\t\t\tissuerDocumentId\n\t\t);\n\t\tGuards.arrayValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(credentialIndices),\n\t\t\tcredentialIndices\n\t\t);\n\n\t\ttry {\n\t\t\tconst issuerIdentityDocument = await this.resolveOwnDocumentCached(issuerDocumentId);\n\t\t\tconst issuerDidDocument = issuerIdentityDocument.document;\n\n\t\t\tconst revocationService = issuerDidDocument.service?.find(s => s.id.endsWith(\"#revocation\"));\n\t\t\tif (\n\t\t\t\trevocationService &&\n\t\t\t\tIs.string(revocationService.serviceEndpoint) &&\n\t\t\t\trevocationService.type === \"BitstringStatusList\"\n\t\t\t) {\n\t\t\t\tconst revocationParts = revocationService.serviceEndpoint.split(\",\");\n\t\t\t\tif (revocationParts.length === 2) {\n\t\t\t\t\tconst compressedRevocationBytes = Converter.base64UrlToBytes(revocationParts[1]);\n\t\t\t\t\tconst decompressed = await Compression.decompress(\n\t\t\t\t\t\tcompressedRevocationBytes,\n\t\t\t\t\t\tCompressionType.Gzip\n\t\t\t\t\t);\n\n\t\t\t\t\tconst bitString = BitString.fromBits(\n\t\t\t\t\t\tdecompressed,\n\t\t\t\t\t\tEntityStorageIdentityConnector._REVOCATION_BITS_SIZE\n\t\t\t\t\t);\n\n\t\t\t\t\tfor (const credentialIndex of credentialIndices) {\n\t\t\t\t\t\tbitString.setBit(credentialIndex, false);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst compressed = await Compression.compress(bitString.getBits(), CompressionType.Gzip);\n\t\t\t\t\trevocationService.serviceEndpoint = `data:application/octet-stream;base64,${Converter.bytesToBase64Url(compressed)}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait this.updateDocument(controller, issuerDidDocument);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"unrevokeVerifiableCredentialsFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a verifiable presentation from the supplied verifiable credentials.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The method to associate with the presentation.\n\t * @param presentationId The id of the presentation.\n\t * @param contexts The contexts for the data stored in the verifiable credential.\n\t * @param types The types for the data stored in the verifiable credential.\n\t * @param verifiableCredentials The credentials to use for creating the presentation in jwt format.\n\t * @param options Additional options for creating the verifiable presentation.\n\t * @param options.expirationDate The date the verifiable presentation is valid until.\n\t * @param options.jwtHeaderFields Additional fields to add to the JWT header.\n\t * @param options.jwtPayloadFields Additional fields to add to the JWT payload.\n\t * @returns The created verifiable presentation and its token.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async createVerifiablePresentation(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\tpresentationId: string | undefined,\n\t\tcontexts: IJsonLdContextDefinitionRoot | undefined,\n\t\ttypes: string | string[] | undefined,\n\t\tverifiableCredentials: (string | IDidVerifiableCredentialV1)[],\n\t\toptions?: {\n\t\t\texpirationDate?: Date;\n\t\t\tjwtHeaderFields?: { [id: string]: string };\n\t\t\tjwtPayloadFields?: { [id: string]: string };\n\t\t}\n\t): Promise<{\n\t\tverifiablePresentation: IDidVerifiablePresentationV1;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tif (Is.array(types)) {\n\t\t\tGuards.arrayValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(types), types);\n\t\t} else if (Is.string(types)) {\n\t\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(types), types);\n\t\t}\n\t\tGuards.arrayValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verifiableCredentials),\n\t\t\tverifiableCredentials\n\t\t);\n\t\tif (!Is.undefined(options?.expirationDate)) {\n\t\t\tGuards.date(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(options.expirationDate),\n\t\t\t\toptions.expirationDate\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst holderIdentityDocument = await this.resolveOwnDocumentCached(idParts.id);\n\t\t\tconst holderDidDocument = holderIdentityDocument.document;\n\n\t\t\tconst methods = this.getAllMethods(holderDidDocument);\n\t\t\tconst methodAndArray = methods.find(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === verificationMethodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === verificationMethodId;\n\t\t\t});\n\n\t\t\tif (!methodAndArray) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"methodMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst didMethod = methodAndArray.method;\n\t\t\tif (!Is.stringValue(didMethod.publicKeyJwk?.x)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"publicKeyJwkMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst finalTypes: string[] = [DidTypes.VerifiablePresentation];\n\t\t\tif (Is.array(types)) {\n\t\t\t\tfinalTypes.push(...types);\n\t\t\t} else if (Is.stringValue(types)) {\n\t\t\t\tfinalTypes.push(types);\n\t\t\t}\n\n\t\t\tconst combinedContext =\n\t\t\t\tJsonLdProcessor.combineContexts(DidContexts.ContextVCv1, contexts) ??\n\t\t\t\tDidContexts.ContextVCv1;\n\n\t\t\tconst verifiablePresentation: IDidVerifiablePresentationV1 = {\n\t\t\t\t\"@context\": combinedContext as [typeof DidContexts.ContextVCv1],\n\t\t\t\tid: presentationId,\n\t\t\t\ttype: finalTypes,\n\t\t\t\tverifiableCredential: verifiableCredentials,\n\t\t\t\tholder: idParts.id\n\t\t\t};\n\n\t\t\tconst jwtHeader: IJwtHeader = {\n\t\t\t\t...options?.jwtHeaderFields,\n\t\t\t\tkid: didMethod.id,\n\t\t\t\ttyp: \"JWT\",\n\t\t\t\talg: JwsAlgorithms.EdDSA\n\t\t\t};\n\n\t\t\tconst jwtVp = ObjectHelper.pick(ObjectHelper.clone(verifiablePresentation), [\n\t\t\t\t\"@context\",\n\t\t\t\t\"type\",\n\t\t\t\t\"verifiableCredential\"\n\t\t\t]);\n\n\t\t\t// Add the proof to the VP after extracting the jwt data\n\t\t\t// as the jwt does not include the proof\n\t\t\tverifiablePresentation.proof = await this.createProof(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tProofTypes.DataIntegrityProof,\n\t\t\t\tJsonLdHelper.toNodeObject(verifiablePresentation),\n\t\t\t\tholderDidDocument\n\t\t\t);\n\n\t\t\tconst jwtPayload: IJwtPayload = {\n\t\t\t\t...options?.jwtPayloadFields,\n\t\t\t\tiss: verifiablePresentation.holder,\n\t\t\t\tnbf: Math.floor(Date.now() / 1000),\n\t\t\t\tvp: jwtVp\n\t\t\t};\n\n\t\t\tif (Is.date(options?.expirationDate)) {\n\t\t\t\tjwtPayload.exp = Math.floor(options.expirationDate.getTime() / 1000);\n\t\t\t}\n\n\t\t\tconst signature = await Jwt.encodeWithSigner(jwtHeader, jwtPayload, async (header, payload) =>\n\t\t\t\tVaultConnectorHelper.jwtSigner(\n\t\t\t\t\tthis._vaultConnector,\n\t\t\t\t\tEntityStorageIdentityConnector.buildVaultKey(idParts.id, idParts.fragment ?? \"\"),\n\t\t\t\t\theader,\n\t\t\t\t\tpayload\n\t\t\t\t)\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tverifiablePresentation,\n\t\t\t\tjwt: signature\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createVerifiablePresentationFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Check a verifiable presentation is valid.\n\t * @param presentation The presentation to verify.\n\t * @returns The presentation stored in the jwt and the revocation status.\n\t */\n\tpublic async checkVerifiablePresentation(\n\t\tpresentation: string | IDidVerifiablePresentation\n\t): Promise<{\n\t\trevoked: boolean;\n\t\tverifiablePresentation?: IDidVerifiablePresentationV1;\n\t\tissuers?: IDidDocument[];\n\t}> {\n\t\tif (Is.object(presentation)) {\n\t\t\tconst { proof, ...doc } = presentation as IDidVerifiablePresentationV1;\n\t\t\tconst proofEntry = ArrayHelper.fromObjectOrArray(proof)[0];\n\t\t\tGuards.objectValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(proofEntry), proofEntry);\n\t\t\tconst presentationVerified = await this.verifyProof(\n\t\t\t\tJsonLdHelper.toNodeObject(doc),\n\t\t\t\tproofEntry\n\t\t\t);\n\t\t\tif (!presentationVerified) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"signatureVerificationFailed\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tlet revoked = false;\n\t\t\tfor (const embeddedCredential of doc.verifiableCredential ?? []) {\n\t\t\t\tconst credentialCheck = await this.checkVerifiableCredential(embeddedCredential);\n\t\t\t\tif (credentialCheck.revoked) {\n\t\t\t\t\trevoked = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { revoked, verifiablePresentation: doc };\n\t\t}\n\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(presentation),\n\t\t\tpresentation\n\t\t);\n\n\t\tconst presentationJwt = presentation;\n\n\t\ttry {\n\t\t\tconst jwtDecoded = await Jwt.decode(presentationJwt);\n\n\t\t\tconst jwtHeader = jwtDecoded.header;\n\t\t\tconst jwtPayload = jwtDecoded.payload;\n\t\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\t\tif (\n\t\t\t\tIs.undefined(jwtHeader) ||\n\t\t\t\tIs.undefined(jwtPayload) ||\n\t\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\t\tIs.undefined(jwtSignature)\n\t\t\t) {\n\t\t\t\tthrow new NotFoundError(EntityStorageIdentityConnector.CLASS_NAME, \"jwkSignatureFailed\");\n\t\t\t}\n\n\t\t\tconst holderDocumentId = jwtPayload.iss;\n\t\t\tconst holderIdentityDocument = await this._didDocumentEntityStorage.get(holderDocumentId);\n\t\t\tif (Is.undefined(holderIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tholderDocumentId\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tholderIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\n\t\t\tconst issuers: IDidDocument[] = [];\n\t\t\tconst tokensRevoked: boolean[] = [];\n\t\t\tconst verifiablePresentation = jwtPayload?.vp as IDidVerifiablePresentationV1;\n\t\t\tif (\n\t\t\t\tIs.object<IDidVerifiablePresentationV1>(verifiablePresentation) &&\n\t\t\t\tIs.array(verifiablePresentation.verifiableCredential)\n\t\t\t) {\n\t\t\t\tfor (const vcJwt of verifiablePresentation.verifiableCredential) {\n\t\t\t\t\tlet revoked = false;\n\t\t\t\t\tif (Is.stringValue(vcJwt)) {\n\t\t\t\t\t\tconst jwt = await Jwt.decode(vcJwt);\n\n\t\t\t\t\t\tif (Is.string(jwt.payload?.iss)) {\n\t\t\t\t\t\t\tconst issuerDocumentId = jwt.payload.iss;\n\t\t\t\t\t\t\tverifiablePresentation.holder = issuerDocumentId;\n\n\t\t\t\t\t\t\tconst issuerDidDocument = await this._didDocumentEntityStorage.get(issuerDocumentId);\n\t\t\t\t\t\t\tif (Is.undefined(issuerDidDocument)) {\n\t\t\t\t\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\t\t\t\t\tissuerDocumentId\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\t\t\t\t\tissuerDidDocument,\n\t\t\t\t\t\t\t\tthis._vaultConnector\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tissuers.push({\n\t\t\t\t\t\t\t\t\"@context\": DidContexts.Context,\n\t\t\t\t\t\t\t\t...issuerDidDocument\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst credentialCheck = await this.checkVerifiableCredential(vcJwt);\n\t\t\t\t\t\trevoked = credentialCheck.revoked;\n\t\t\t\t\t}\n\t\t\t\t\ttokensRevoked.push(revoked);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\trevoked: tokensRevoked.some(Boolean),\n\t\t\t\tverifiablePresentation,\n\t\t\t\tissuers\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (BaseError.isErrorMessage(error, /revoked/i)) {\n\t\t\t\treturn {\n\t\t\t\t\trevoked: true\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"checkingVerifiablePresentationFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Create a proof for arbitrary data with the specified verification method.\n\t * This method uses async signing to ensure the private key never leaves the vault,\n\t * with algorithm validation to ensure key type compatibility.\n\t * @param controller The controller of the identity who can make changes.\n\t * @param verificationMethodId The verification method id to use.\n\t * @param proofType The type of proof to create.\n\t * @param unsecureDocument The unsecure document to create the proof for.\n\t * @param resolvedDocument Optional already-resolved document for the DID, so a caller that\n\t * just resolved it (e.g. createVerifiableCredential) skips a redundant re-resolve. Resolves\n\t * it itself if omitted.\n\t * @returns The proof.\n\t * @throws NotFoundError if the identity or method is not found.\n\t * @throws GeneralError if algorithm doesn't match key type or proof creation fails.\n\t */\n\tpublic async createProof(\n\t\tcontroller: string,\n\t\tverificationMethodId: string,\n\t\tproofType: ProofTypes,\n\t\tunsecureDocument: IJsonLdNodeObject,\n\t\tresolvedDocument?: IDidDocument\n\t): Promise<IProof> {\n\t\tGuards.stringValue(EntityStorageIdentityConnector.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.arrayOneOf<ProofTypes>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(proofType),\n\t\t\tproofType,\n\t\t\tObject.values(ProofTypes)\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(unsecureDocument),\n\t\t\tunsecureDocument\n\t\t);\n\t\tif (!Is.undefined(resolvedDocument)) {\n\t\t\tGuards.object<IDidDocument>(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\tnameof(resolvedDocument),\n\t\t\t\tresolvedDocument\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tverificationMethodId\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst didDocument = Is.undefined(resolvedDocument)\n\t\t\t\t? (await this.resolveOwnDocumentCached(idParts.id)).document\n\t\t\t\t: resolvedDocument;\n\n\t\t\tconst methods = this.getAllMethods(didDocument);\n\t\t\tconst methodAndArray = methods.find(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === verificationMethodId;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === verificationMethodId;\n\t\t\t});\n\n\t\t\tif (!methodAndArray) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"methodMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst didMethod = methodAndArray.method;\n\t\t\tif (!Is.stringValue(didMethod.publicKeyJwk?.x)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"publicKeyJwkMissing\", {\n\t\t\t\t\tmethod: verificationMethodId\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst vaultKey = EntityStorageIdentityConnector.buildVaultKey(\n\t\t\t\tdidDocument.id,\n\t\t\t\tidParts.fragment ?? \"\"\n\t\t\t);\n\t\t\tconst keyType = await this._vaultConnector.getKeyType(vaultKey);\n\n\t\t\tif (Is.undefined(keyType)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"privateKeyMissing\", {\n\t\t\t\t\tkeyId: vaultKey\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst unsignedProof = ProofHelper.createUnsignedProof(proofType, verificationMethodId);\n\n\t\t\tconst signedProof = await ProofHelper.createProofWithSigner(\n\t\t\t\tproofType,\n\t\t\t\tunsecureDocument,\n\t\t\t\tunsignedProof,\n\t\t\t\tasync (data, algorithm) => this.signWithVault(vaultKey, keyType, data, algorithm)\n\t\t\t);\n\n\t\t\treturn signedProof;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"createProofFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Verify proof for arbitrary data with the specified verification method.\n\t * @param document The document to verify.\n\t * @param proof The proof to verify.\n\t * @returns True if the proof is verified.\n\t */\n\tpublic async verifyProof(document: IJsonLdNodeObject, proof: IProof): Promise<boolean> {\n\t\tGuards.object<IJsonLdNodeObject>(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(document),\n\t\t\tdocument\n\t\t);\n\t\tGuards.object<IProof>(EntityStorageIdentityConnector.CLASS_NAME, nameof(proof), proof);\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\tnameof(proof.verificationMethod),\n\t\t\tproof.verificationMethod\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(proof.verificationMethod);\n\t\t\tif (Is.empty(idParts.fragment)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"missingDid\",\n\t\t\t\t\tproof.verificationMethod\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst didIdentityDocument = await this._didDocumentEntityStorage.get(idParts.id);\n\t\t\tif (Is.undefined(didIdentityDocument)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\t\"documentNotFound\",\n\t\t\t\t\tidParts.id\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait EntityStorageIdentityConnector.verifyDocument(\n\t\t\t\tdidIdentityDocument,\n\t\t\t\tthis._vaultConnector\n\t\t\t);\n\t\t\tconst didDocument = didIdentityDocument.document;\n\n\t\t\tconst methods = this.getAllMethods(didDocument);\n\n\t\t\tconst methodAndArray = methods.find(m => {\n\t\t\t\tif (Is.string(m.method)) {\n\t\t\t\t\treturn m.method === proof.verificationMethod;\n\t\t\t\t}\n\t\t\t\treturn m.method.id === proof.verificationMethod;\n\t\t\t});\n\n\t\t\tif (!methodAndArray) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"methodMissing\", {\n\t\t\t\t\tmethod: proof.verificationMethod\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst didMethod = methodAndArray.method;\n\t\t\tif (!Is.stringValue(didMethod.publicKeyJwk?.x)) {\n\t\t\t\tthrow new GeneralError(EntityStorageIdentityConnector.CLASS_NAME, \"publicKeyJwkMissing\", {\n\t\t\t\t\tmethod: proof.verificationMethod\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst result = await ProofHelper.verifyProof(document, proof, didMethod.publicKeyJwk);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"verifyProofFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Signs data using the vault connector with algorithm validation.\n\t * @param vaultKey The vault key identifier.\n\t * @param keyType The type of the key.\n\t * @param data The data to sign.\n\t * @param algorithm The signing algorithm.\n\t * @returns The signature bytes.\n\t * @throws GeneralError if algorithm doesn't match key type.\n\t * @internal\n\t */\n\tprivate async signWithVault(\n\t\tvaultKey: string,\n\t\tkeyType: VaultKeyType,\n\t\tdata: Uint8Array,\n\t\talgorithm: string\n\t): Promise<Uint8Array> {\n\t\tif (algorithm === JwsAlgorithms.EdDSA && keyType !== VaultKeyType.Ed25519) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"algorithmKeyTypeMismatch\",\n\t\t\t\t{\n\t\t\t\t\talgorithm,\n\t\t\t\t\texpectedKeyType: VaultKeyType.Ed25519,\n\t\t\t\t\tactualKeyType: keyType,\n\t\t\t\t\tkeyId: vaultKey\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t\treturn this._vaultConnector.sign(vaultKey, data);\n\t}\n\n\t/**\n\t * Get all the methods from a document.\n\t * @param document The document to get the methods from.\n\t * @returns The methods.\n\t * @internal\n\t */\n\tprivate getAllMethods(\n\t\tdocument: IDidDocument\n\t): { arrayKey: string; method: Partial<IDidDocumentVerificationMethod> }[] {\n\t\tconst methods: {\n\t\t\tarrayKey: string;\n\t\t\tmethod: Partial<IDidDocumentVerificationMethod>;\n\t\t}[] = [];\n\n\t\tconst methodTypes: DidVerificationMethodType[] = Object.values(DidVerificationMethodType);\n\n\t\tfor (const methodType of methodTypes) {\n\t\t\tconst mt = document[methodType];\n\t\t\tif (Is.arrayValue(mt)) {\n\t\t\t\tmethods.push(\n\t\t\t\t\t...mt.map(m => ({\n\t\t\t\t\t\tarrayKey: methodType,\n\t\t\t\t\t\tmethod: Is.string(m) ? { id: m } : m\n\t\t\t\t\t}))\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn methods;\n\t}\n\n\t/**\n\t * Resolve the issuer document for a verification method, verified against its stored signature.\n\t * @param verificationMethodId The verification method id whose owning DID to resolve.\n\t * @returns The resolved document.\n\t * @throws NotFoundError if the id has no DID, or the DID cannot be resolved.\n\t * @internal\n\t */\n\tprivate async resolveAssertionMethodDocument(\n\t\tverificationMethodId: string\n\t): Promise<IDidDocument> {\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\t\tif (Is.empty(idParts.fragment)) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"missingDid\",\n\t\t\t\tverificationMethodId\n\t\t\t);\n\t\t}\n\n\t\tconst identityDocument = await this._didDocumentEntityStorage.get(idParts.id);\n\t\tif (Is.undefined(identityDocument)) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"documentNotFound\",\n\t\t\t\tidParts.id\n\t\t\t);\n\t\t}\n\t\tawait EntityStorageIdentityConnector.verifyDocument(identityDocument, this._vaultConnector);\n\n\t\treturn identityDocument.document;\n\t}\n\n\t/**\n\t * Cache key for a DID resolved for this connector's own sign/mutate operations (role 1).\n\t * Deliberately namespaced (\"own\") and never shared with proof/credential verification of\n\t * third-party claims (role 2/3), which this connector never caches.\n\t * @param documentId The DID being resolved.\n\t * @returns The cache key.\n\t * @internal\n\t */\n\tprivate ownDidCacheKey(documentId: string): string {\n\t\treturn `${EntityStorageIdentityConnector.CLASS_NAME}:own:${documentId}`;\n\t}\n\n\t/**\n\t * Load and verify a document's own storage entity, uncached.\n\t * @param documentId The DID to load.\n\t * @returns The verified storage entity.\n\t * @throws NotFoundError if the DID could not be resolved.\n\t * @internal\n\t */\n\tprivate async loadOwnDocument(documentId: string): Promise<IdentityDocument> {\n\t\tconst identityDocument = await this._didDocumentEntityStorage.get(documentId);\n\t\tif (Is.undefined(identityDocument)) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\tEntityStorageIdentityConnector.CLASS_NAME,\n\t\t\t\t\"documentNotFound\",\n\t\t\t\tdocumentId\n\t\t\t);\n\t\t}\n\t\tawait EntityStorageIdentityConnector.verifyDocument(identityDocument, this._vaultConnector);\n\n\t\treturn identityDocument;\n\t}\n\n\t/**\n\t * Resolve a document's own storage entity for this connector's own sign/mutate operations,\n\t * cached for didResolutionCacheTtlMs (0 disables caching and resolves fresh every call).\n\t * Only ever used for the connector's own create/update/revoke paths - never for verifyProof\n\t * or credential/presentation verification, which must stay uncached.\n\t * A clone is always returned: mutators edit the entity in place before storing it, and the\n\t * cached instance must never be handed out by reference.\n\t * @param documentId The DID to resolve.\n\t * @returns The verified storage entity.\n\t * @throws NotFoundError if the DID could not be resolved.\n\t * @internal\n\t */\n\tprivate async resolveOwnDocumentCached(documentId: string): Promise<IdentityDocument> {\n\t\tif (Is.undefined(this._didResolutionCache)) {\n\t\t\treturn this.loadOwnDocument(documentId);\n\t\t}\n\n\t\tconst identityDocument = await this._didResolutionCache.getOrSet(\n\t\t\tthis.ownDidCacheKey(documentId),\n\t\t\tasync () => this.loadOwnDocument(documentId)\n\t\t);\n\t\treturn ObjectHelper.clone(identityDocument);\n\t}\n\n\t/**\n\t * Check whether a credential's status entry or entries report it as revoked.\n\t * @param document The issuer document owning the revocation bitmap service.\n\t * @param credentialStatus The credential's status entry or entries to check.\n\t * @returns True if any entry is reported revoked.\n\t * @internal\n\t */\n\tprivate async checkCredentialStatusRevoked(\n\t\tdocument: IDidDocument,\n\t\tcredentialStatus: IDidCredentialStatus | IDidCredentialStatus[] | undefined\n\t): Promise<boolean> {\n\t\tlet statuses: IDidCredentialStatus[] = [];\n\t\tif (Is.array<IDidCredentialStatus>(credentialStatus)) {\n\t\t\tstatuses = credentialStatus;\n\t\t} else if (Is.object<IDidCredentialStatus>(credentialStatus)) {\n\t\t\tstatuses = [credentialStatus];\n\t\t}\n\n\t\tfor (const status of statuses) {\n\t\t\tif (await this.checkRevocation(document, status.revocationBitmapIndex)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Check if a revocation index is revoked.\n\t * @param document The document to check.\n\t * @param revocationBitmapIndex The revocation index to check.\n\t * @returns True if the index is revoked.\n\t * @internal\n\t */\n\tprivate async checkRevocation(\n\t\tdocument: IDidDocument,\n\t\trevocationBitmapIndex?: unknown\n\t): Promise<boolean> {\n\t\tconst revocationIndex = Coerce.number(revocationBitmapIndex);\n\t\tif (Is.number(revocationIndex)) {\n\t\t\tconst revocationService = document.service?.find(s => s.id.endsWith(\"#revocation\"));\n\t\t\tif (\n\t\t\t\trevocationService &&\n\t\t\t\tIs.string(revocationService.serviceEndpoint) &&\n\t\t\t\trevocationService.type === \"BitstringStatusList\"\n\t\t\t) {\n\t\t\t\tconst revocationParts = revocationService.serviceEndpoint.split(\",\");\n\t\t\t\tif (revocationParts.length === 2) {\n\t\t\t\t\tconst compressedRevocationBytes = Converter.base64UrlToBytes(revocationParts[1]);\n\t\t\t\t\tconst decompressed = await Compression.decompress(\n\t\t\t\t\t\tcompressedRevocationBytes,\n\t\t\t\t\t\tCompressionType.Gzip\n\t\t\t\t\t);\n\n\t\t\t\t\tconst bitString = BitString.fromBits(\n\t\t\t\t\t\tdecompressed,\n\t\t\t\t\t\tEntityStorageIdentityConnector._REVOCATION_BITS_SIZE\n\t\t\t\t\t);\n\n\t\t\t\t\treturn bitString.getBit(revocationIndex);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Update the document in storage.\n\t * @param controller The controller of the document.\n\t * @param didDocument The did document to store.\n\t * @returns A promise that resolves when the document has been signed and persisted.\n\t * @internal\n\t */\n\tprivate async updateDocument(controller: string, didDocument: IDidDocument): Promise<void> {\n\t\tconst stringifiedDocument = JsonHelper.canonicalize(didDocument);\n\t\tconst docBytes = Converter.utf8ToBytes(stringifiedDocument);\n\n\t\tconst signature = await this._vaultConnector.sign(\n\t\t\tEntityStorageIdentityConnector.buildVaultKey(didDocument.id, \"did\"),\n\t\t\tdocBytes\n\t\t);\n\n\t\tconst identityDocument: IdentityDocument = {\n\t\t\tid: didDocument.id,\n\t\t\tdocument: didDocument,\n\t\t\tsignature: Converter.bytesToBase64(signature),\n\t\t\tcontroller\n\t\t};\n\n\t\tawait this._didDocumentEntityStorage.set(identityDocument);\n\n\t\tthis._didResolutionCache?.set(\n\t\t\tthis.ownDidCacheKey(didDocument.id),\n\t\t\tObjectHelper.clone(identityDocument)\n\t\t);\n\t}\n}\n"]}
|
|
@@ -45,7 +45,7 @@ export class EntityStorageIdentityProfileConnector {
|
|
|
45
45
|
Guards.stringValue(EntityStorageIdentityProfileConnector.CLASS_NAME, "identity", identity);
|
|
46
46
|
try {
|
|
47
47
|
const profile = await this._profileEntityStorage.get(identity);
|
|
48
|
-
if (
|
|
48
|
+
if (Is.notEmpty(profile)) {
|
|
49
49
|
throw new AlreadyExistsError(EntityStorageIdentityProfileConnector.CLASS_NAME, "alreadyExists", identity);
|
|
50
50
|
}
|
|
51
51
|
await this._profileEntityStorage.set({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entityStorageIdentityProfileConnector.js","sourceRoot":"","sources":["../../src/entityStorageIdentityProfileConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,kBAAkB,EAClB,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,aAAa,EACb,YAAY,EACZ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAMzC;;GAEG;AACH,MAAM,OAAO,qCAAqC;IAIjD;;OAEG;IACI,MAAM,CAAU,SAAS,GAAW,gBAAgB,CAAC;IAE5D;;OAEG;IACI,MAAM,CAAU,UAAU,2CAA2D;IAE5F;;;OAGG;IACc,qBAAqB,CAA2C;IAEjF;;;OAGG;IACH,YAAY,OAAkE;QAC7E,IAAI,CAAC,qBAAqB,GAAG,6BAA6B,CAAC,GAAG,CAC7D,OAAO,EAAE,wBAAwB,IAAI,kBAAkB,CACvD,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,qCAAqC,CAAC,UAAU,CAAC;IACzD,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,MAAM,CAAC,QAAgB,EAAE,aAAiB,EAAE,cAAkB;QAC1E,MAAM,CAAC,WAAW,CACjB,qCAAqC,CAAC,UAAU,cAEhD,QAAQ,CACR,CAAC;QAEF,IAAI,CAAC;YACJ,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAE/D,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;gBACxB,MA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nimport {\n\tAlreadyExistsError,\n\tBaseError,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tNotFoundError,\n\tObjectHelper\n} from \"@twin.org/core\";\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\nimport { ComparisonOperator } from \"@twin.org/entity\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport type { IIdentityProfileConnector } from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IdentityProfile } from \"./entities/identityProfile.js\";\nimport type { IEntityStorageIdentityProfileConnectorConstructorOptions } from \"./models/IEntityStorageIdentityProfileConnectorConstructorOptions.js\";\n\n/**\n * Class which implements the identity profile connector contract.\n */\nexport class EntityStorageIdentityProfileConnector<\n\tT extends IJsonLdDocument = IJsonLdDocument,\n\tU extends IJsonLdDocument = IJsonLdDocument\n> implements IIdentityProfileConnector<T, U> {\n\t/**\n\t * The namespace supported by the identity profile connector.\n\t */\n\tpublic static readonly NAMESPACE: string = \"entity-storage\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageIdentityProfileConnector>();\n\n\t/**\n\t * The storage connector for the profiles.\n\t * @internal\n\t */\n\tprivate readonly _profileEntityStorage: IEntityStorageConnector<IdentityProfile>;\n\n\t/**\n\t * Create a new instance of EntityStorageIdentityProfileConnector.\n\t * @param options The options for the identity service.\n\t */\n\tconstructor(options?: IEntityStorageIdentityProfileConnectorConstructorOptions) {\n\t\tthis._profileEntityStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.profileEntityStorageType ?? \"identity-profile\"\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageIdentityProfileConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create the profile properties for an identity.\n\t * @param identity The identity of the profile to create.\n\t * @param publicProfile The public profile data.\n\t * @param privateProfile The private profile data.\n\t * @returns A promise that resolves when the profile has been created.\n\t */\n\tpublic async create(identity: string, publicProfile?: T, privateProfile?: U): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\n\t\t\tif (!Is.empty(profile)) {\n\t\t\t\tthrow new AlreadyExistsError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"alreadyExists\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this._profileEntityStorage.set({\n\t\t\t\tidentity,\n\t\t\t\tpublicProfile,\n\t\t\t\tprivateProfile\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"createFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the profile properties for an identity.\n\t * @param identity The identity of the item to get.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @returns The items properties.\n\t */\n\tpublic async get(\n\t\tidentity: string,\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[]\n\t): Promise<{\n\t\tpublicProfile: Partial<T>;\n\t\tprivateProfile: Partial<U>;\n\t}> {\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (!profile) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"identityNotFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn this.pickProperties(profile, publicPropertyNames, privatePropertyNames);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"getFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Update the profile properties of an identity.\n\t * @param identity The identity to update.\n\t * @param publicProfile The public profile data.\n\t * @param privateProfile The private profile data.\n\t * @returns A promise that resolves when the profile has been updated.\n\t */\n\tpublic async update(identity: string, publicProfile?: T, privateProfile?: U): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (Is.empty(profile)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"notFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tprofile.publicProfile = publicProfile ?? profile.publicProfile;\n\t\t\tprofile.privateProfile = privateProfile ?? profile.privateProfile;\n\n\t\t\tawait this._profileEntityStorage.set(profile);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"updateFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Delete the profile for an identity.\n\t * @param identity The identity to delete.\n\t * @returns A promise that resolves when the profile has been removed.\n\t */\n\tpublic async remove(identity: string): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (Is.empty(profile)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"notFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this._profileEntityStorage.remove(identity);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"removeFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get a list of the requested types.\n\t * @param publicFilters The filters to apply to the identities public profiles.\n\t * @param privateFilters The filters to apply to the identities private profiles.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @param cursor The cursor for paged requests.\n\t * @param limit The maximum number of items in a page.\n\t * @returns The list of items and cursor for paging.\n\t */\n\tpublic async list(\n\t\tpublicFilters?: {\n\t\t\tpropertyName: string;\n\t\t\tpropertyValue: unknown;\n\t\t}[],\n\t\tprivateFilters?: {\n\t\t\tpropertyName: string;\n\t\t\tpropertyValue: unknown;\n\t\t}[],\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[],\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\t/**\n\t\t * The identities.\n\t\t */\n\t\titems: {\n\t\t\tidentity: string;\n\t\t\tpublicProfile?: Partial<T>;\n\t\t\tprivateProfile?: Partial<U>;\n\t\t}[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}> {\n\t\ttry {\n\t\t\tconst conditions = [];\n\n\t\t\tif (Is.arrayValue(publicFilters)) {\n\t\t\t\tfor (const filter of publicFilters) {\n\t\t\t\t\tconditions.push({\n\t\t\t\t\t\tproperty: `publicProfile.${filter.propertyName}`,\n\t\t\t\t\t\tvalue: filter.propertyValue,\n\t\t\t\t\t\tcomparison: ComparisonOperator.Equals\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Is.arrayValue(privateFilters)) {\n\t\t\t\tfor (const filter of privateFilters) {\n\t\t\t\t\tconditions.push({\n\t\t\t\t\t\tproperty: `privateProfile.${filter.propertyName}`,\n\t\t\t\t\t\tvalue: filter.propertyValue,\n\t\t\t\t\t\tcomparison: ComparisonOperator.Equals\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst result = await this._profileEntityStorage.query(\n\t\t\t\tIs.arrayValue(conditions)\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tconditions\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\tcursor,\n\t\t\t\tlimit\n\t\t\t);\n\n\t\t\tconst items: {\n\t\t\t\tidentity: string;\n\t\t\t\tpublicProfile?: Partial<T>;\n\t\t\t\tprivateProfile?: Partial<U>;\n\t\t\t}[] = [];\n\t\t\tfor (const resultEntity of result.entities) {\n\t\t\t\titems.push({\n\t\t\t\t\tidentity: resultEntity.identity ?? \"\",\n\t\t\t\t\t...this.pickProperties(resultEntity, publicPropertyNames, privatePropertyNames)\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\titems,\n\t\t\t\tcursor: result.cursor\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"listFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the profile properties for an identity.\n\t * @param profile The profile to pick the properties from.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @returns The identity profile, will only return private data if you have correct permissions.\n\t * @internal\n\t */\n\tprivate pickProperties(\n\t\tprofile: Partial<IdentityProfile>,\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[]\n\t): {\n\t\tpublicProfile: Partial<T>;\n\t\tprivateProfile: Partial<U>;\n\t} {\n\t\treturn {\n\t\t\tpublicProfile: Is.array(publicPropertyNames)\n\t\t\t\t? ObjectHelper.pick(profile.publicProfile as T, publicPropertyNames)\n\t\t\t\t: (profile.publicProfile as T),\n\t\t\tprivateProfile: Is.array(privatePropertyNames)\n\t\t\t\t? ObjectHelper.pick(profile.privateProfile as U, privatePropertyNames)\n\t\t\t\t: (profile.privateProfile as U)\n\t\t};\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"entityStorageIdentityProfileConnector.js","sourceRoot":"","sources":["../../src/entityStorageIdentityProfileConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,kBAAkB,EAClB,SAAS,EACT,YAAY,EACZ,MAAM,EACN,EAAE,EACF,aAAa,EACb,YAAY,EACZ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AAMzC;;GAEG;AACH,MAAM,OAAO,qCAAqC;IAIjD;;OAEG;IACI,MAAM,CAAU,SAAS,GAAW,gBAAgB,CAAC;IAE5D;;OAEG;IACI,MAAM,CA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,qCAAqC,CAAC,UAAU,EAChD,YAAY,EACZ,SAAS,EACT,KAAK,CACL,CAAC;QACH,CAAC;IACF,CAAC;IAED;;;;;;;OAOG;IACK,cAAc,CACrB,OAAiC,EACjC,mBAAiC,EACjC,oBAAkC;QAKlC,OAAO;YACN,aAAa,EAAE,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC;gBAC3C,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,aAAkB,EAAE,mBAAmB,CAAC;gBACpE,CAAC,CAAE,OAAO,CAAC,aAAmB;YAC/B,cAAc,EAAE,EAAE,CAAC,KAAK,CAAC,oBAAoB,CAAC;gBAC7C,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,cAAmB,EAAE,oBAAoB,CAAC;gBACtE,CAAC,CAAE,OAAO,CAAC,cAAoB;SAChC,CAAC;IACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tAlreadyExistsError,\n\tBaseError,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tNotFoundError,\n\tObjectHelper\n} from \"@twin.org/core\";\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\nimport { ComparisonOperator } from \"@twin.org/entity\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport type { IIdentityProfileConnector } from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IdentityProfile } from \"./entities/identityProfile.js\";\nimport type { IEntityStorageIdentityProfileConnectorConstructorOptions } from \"./models/IEntityStorageIdentityProfileConnectorConstructorOptions.js\";\n\n/**\n * Class which implements the identity profile connector contract.\n */\nexport class EntityStorageIdentityProfileConnector<\n\tT extends IJsonLdDocument = IJsonLdDocument,\n\tU extends IJsonLdDocument = IJsonLdDocument\n> implements IIdentityProfileConnector<T, U> {\n\t/**\n\t * The namespace supported by the identity profile connector.\n\t */\n\tpublic static readonly NAMESPACE: string = \"entity-storage\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageIdentityProfileConnector>();\n\n\t/**\n\t * The storage connector for the profiles.\n\t * @internal\n\t */\n\tprivate readonly _profileEntityStorage: IEntityStorageConnector<IdentityProfile>;\n\n\t/**\n\t * Create a new instance of EntityStorageIdentityProfileConnector.\n\t * @param options The options for the identity service.\n\t */\n\tconstructor(options?: IEntityStorageIdentityProfileConnectorConstructorOptions) {\n\t\tthis._profileEntityStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.profileEntityStorageType ?? \"identity-profile\"\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageIdentityProfileConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create the profile properties for an identity.\n\t * @param identity The identity of the profile to create.\n\t * @param publicProfile The public profile data.\n\t * @param privateProfile The private profile data.\n\t * @returns A promise that resolves when the profile has been created.\n\t */\n\tpublic async create(identity: string, publicProfile?: T, privateProfile?: U): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\n\t\t\tif (Is.notEmpty(profile)) {\n\t\t\t\tthrow new AlreadyExistsError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"alreadyExists\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this._profileEntityStorage.set({\n\t\t\t\tidentity,\n\t\t\t\tpublicProfile,\n\t\t\t\tprivateProfile\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"createFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the profile properties for an identity.\n\t * @param identity The identity of the item to get.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @returns The items properties.\n\t */\n\tpublic async get(\n\t\tidentity: string,\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[]\n\t): Promise<{\n\t\tpublicProfile: Partial<T>;\n\t\tprivateProfile: Partial<U>;\n\t}> {\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (!profile) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"identityNotFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn this.pickProperties(profile, publicPropertyNames, privatePropertyNames);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"getFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Update the profile properties of an identity.\n\t * @param identity The identity to update.\n\t * @param publicProfile The public profile data.\n\t * @param privateProfile The private profile data.\n\t * @returns A promise that resolves when the profile has been updated.\n\t */\n\tpublic async update(identity: string, publicProfile?: T, privateProfile?: U): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (Is.empty(profile)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"notFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tprofile.publicProfile = publicProfile ?? profile.publicProfile;\n\t\t\tprofile.privateProfile = privateProfile ?? profile.privateProfile;\n\n\t\t\tawait this._profileEntityStorage.set(profile);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"updateFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Delete the profile for an identity.\n\t * @param identity The identity to delete.\n\t * @returns A promise that resolves when the profile has been removed.\n\t */\n\tpublic async remove(identity: string): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (Is.empty(profile)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"notFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this._profileEntityStorage.remove(identity);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"removeFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get a list of the requested types.\n\t * @param publicFilters The filters to apply to the identities public profiles.\n\t * @param privateFilters The filters to apply to the identities private profiles.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @param cursor The cursor for paged requests.\n\t * @param limit The maximum number of items in a page.\n\t * @returns The list of items and cursor for paging.\n\t */\n\tpublic async list(\n\t\tpublicFilters?: {\n\t\t\tpropertyName: string;\n\t\t\tpropertyValue: unknown;\n\t\t}[],\n\t\tprivateFilters?: {\n\t\t\tpropertyName: string;\n\t\t\tpropertyValue: unknown;\n\t\t}[],\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[],\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\t/**\n\t\t * The identities.\n\t\t */\n\t\titems: {\n\t\t\tidentity: string;\n\t\t\tpublicProfile?: Partial<T>;\n\t\t\tprivateProfile?: Partial<U>;\n\t\t}[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}> {\n\t\ttry {\n\t\t\tconst conditions = [];\n\n\t\t\tif (Is.arrayValue(publicFilters)) {\n\t\t\t\tfor (const filter of publicFilters) {\n\t\t\t\t\tconditions.push({\n\t\t\t\t\t\tproperty: `publicProfile.${filter.propertyName}`,\n\t\t\t\t\t\tvalue: filter.propertyValue,\n\t\t\t\t\t\tcomparison: ComparisonOperator.Equals\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Is.arrayValue(privateFilters)) {\n\t\t\t\tfor (const filter of privateFilters) {\n\t\t\t\t\tconditions.push({\n\t\t\t\t\t\tproperty: `privateProfile.${filter.propertyName}`,\n\t\t\t\t\t\tvalue: filter.propertyValue,\n\t\t\t\t\t\tcomparison: ComparisonOperator.Equals\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst result = await this._profileEntityStorage.query(\n\t\t\t\tIs.arrayValue(conditions)\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tconditions\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\tcursor,\n\t\t\t\tlimit\n\t\t\t);\n\n\t\t\tconst items: {\n\t\t\t\tidentity: string;\n\t\t\t\tpublicProfile?: Partial<T>;\n\t\t\t\tprivateProfile?: Partial<U>;\n\t\t\t}[] = [];\n\t\t\tfor (const resultEntity of result.entities) {\n\t\t\t\titems.push({\n\t\t\t\t\tidentity: resultEntity.identity ?? \"\",\n\t\t\t\t\t...this.pickProperties(resultEntity, publicPropertyNames, privatePropertyNames)\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\titems,\n\t\t\t\tcursor: result.cursor\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"listFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the profile properties for an identity.\n\t * @param profile The profile to pick the properties from.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @returns The identity profile, will only return private data if you have correct permissions.\n\t * @internal\n\t */\n\tprivate pickProperties(\n\t\tprofile: Partial<IdentityProfile>,\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[]\n\t): {\n\t\tpublicProfile: Partial<T>;\n\t\tprivateProfile: Partial<U>;\n\t} {\n\t\treturn {\n\t\t\tpublicProfile: Is.array(publicPropertyNames)\n\t\t\t\t? ObjectHelper.pick(profile.publicProfile as T, publicPropertyNames)\n\t\t\t\t: (profile.publicProfile as T),\n\t\t\tprivateProfile: Is.array(privatePropertyNames)\n\t\t\t\t? ObjectHelper.pick(profile.privateProfile as U, privatePropertyNames)\n\t\t\t\t: (profile.privateProfile as U)\n\t\t};\n\t}\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright 2024 IOTA Stiftung.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
-
import { GeneralError, Guards, Is, NotFoundError } from "@twin.org/core";
|
|
3
|
+
import { GeneralError, Guards, Is, LruCache, NotFoundError, ObjectHelper } from "@twin.org/core";
|
|
4
4
|
import { EntityStorageConnectorFactory } from "@twin.org/entity-storage-models";
|
|
5
5
|
import { VaultConnectorFactory } from "@twin.org/vault-models";
|
|
6
6
|
import { EntityStorageIdentityConnector } from "./entityStorageIdentityConnector.js";
|
|
@@ -26,6 +26,26 @@ export class EntityStorageIdentityResolverConnector {
|
|
|
26
26
|
* @internal
|
|
27
27
|
*/
|
|
28
28
|
_vaultConnector;
|
|
29
|
+
/**
|
|
30
|
+
* TTL in ms for caching resolved DID documents. 0 disables caching.
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
_didResolutionCacheTtlMs;
|
|
34
|
+
/**
|
|
35
|
+
* Maximum number of DID documents retained in cache.
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
_didResolutionCacheCapacity;
|
|
39
|
+
/**
|
|
40
|
+
* Maximum wait time for resolution cache getOrSet mutex acquisition in milliseconds.
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
_didResolutionCacheMutexTimeoutMs;
|
|
44
|
+
/**
|
|
45
|
+
* LRU cache for resolved DID documents. Undefined when caching is disabled (ttl is 0).
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
_didResolutionCache;
|
|
29
49
|
/**
|
|
30
50
|
* Create a new instance of EntityStorageIdentityResolverConnector.
|
|
31
51
|
* @param options The options for the identity connector.
|
|
@@ -33,6 +53,17 @@ export class EntityStorageIdentityResolverConnector {
|
|
|
33
53
|
constructor(options) {
|
|
34
54
|
this._didDocumentEntityStorage = EntityStorageConnectorFactory.get(options?.didDocumentEntityStorageType ?? "identity-document");
|
|
35
55
|
this._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? "vault");
|
|
56
|
+
this._didResolutionCacheTtlMs = options?.config?.didResolutionCacheTtlMs ?? 30_000;
|
|
57
|
+
this._didResolutionCacheCapacity = options?.config?.didResolutionCacheCapacity ?? 1000;
|
|
58
|
+
this._didResolutionCacheMutexTimeoutMs = options?.config?.didResolutionCacheMutexTimeoutMs;
|
|
59
|
+
this._didResolutionCache =
|
|
60
|
+
this._didResolutionCacheTtlMs > 0
|
|
61
|
+
? new LruCache({
|
|
62
|
+
capacity: this._didResolutionCacheCapacity,
|
|
63
|
+
ttiMs: this._didResolutionCacheTtlMs,
|
|
64
|
+
mutexTimeoutMs: this._didResolutionCacheMutexTimeoutMs
|
|
65
|
+
})
|
|
66
|
+
: undefined;
|
|
36
67
|
}
|
|
37
68
|
/**
|
|
38
69
|
* Returns the class name of the component.
|
|
@@ -42,13 +73,39 @@ export class EntityStorageIdentityResolverConnector {
|
|
|
42
73
|
return EntityStorageIdentityResolverConnector.CLASS_NAME;
|
|
43
74
|
}
|
|
44
75
|
/**
|
|
45
|
-
*
|
|
76
|
+
* Stop the service.
|
|
77
|
+
* Destroys in-memory resources owned by this component.
|
|
78
|
+
* @param nodeLoggingComponentType The node logging component type.
|
|
79
|
+
* @returns A promise that resolves when the service has stopped.
|
|
80
|
+
*/
|
|
81
|
+
async stop(nodeLoggingComponentType) {
|
|
82
|
+
this._didResolutionCache?.destroy();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Resolve a document from its id, cached for didResolutionCacheTtlMs
|
|
86
|
+
* (0 disables caching and resolves fresh every call).
|
|
46
87
|
* @param documentId The id of the document to resolve.
|
|
47
88
|
* @returns The resolved document.
|
|
48
89
|
* @throws NotFoundError if the id can not be resolved.
|
|
49
90
|
*/
|
|
50
91
|
async resolveDocument(documentId) {
|
|
51
92
|
Guards.stringValue(EntityStorageIdentityResolverConnector.CLASS_NAME, "documentId", documentId);
|
|
93
|
+
if (Is.undefined(this._didResolutionCache)) {
|
|
94
|
+
return this.loadDocument(documentId);
|
|
95
|
+
}
|
|
96
|
+
const document = await this._didResolutionCache.getOrSet(documentId, async () => this.loadDocument(documentId));
|
|
97
|
+
// Return a deep clone, not the cached instance itself, so a caller mutating the document
|
|
98
|
+
// it receives cannot corrupt the entry shared with every other caller.
|
|
99
|
+
return ObjectHelper.clone(document);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Load and verify a document from storage, bypassing the cache.
|
|
103
|
+
* @param documentId The id of the document to resolve.
|
|
104
|
+
* @returns The resolved document.
|
|
105
|
+
* @throws NotFoundError if the id can not be resolved.
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
108
|
+
async loadDocument(documentId) {
|
|
52
109
|
try {
|
|
53
110
|
const didIdentityDocument = await this._didDocumentEntityStorage.get(documentId);
|
|
54
111
|
if (Is.undefined(didIdentityDocument)) {
|
|
@@ -1 +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;
|
|
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,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACjG,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC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AsC,CAAC,UAAU,EACjD,uBAAuB,EACvB,EAAE,UAAU,EAAE,EACd,KAAK,CACL,CAAC;QACH,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { GeneralError, Guards, Is, LruCache, NotFoundError, ObjectHelper } 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 * TTL in ms for caching resolved DID documents. 0 disables caching.\n\t * @internal\n\t */\n\tprivate readonly _didResolutionCacheTtlMs: number;\n\n\t/**\n\t * Maximum number of DID documents retained in cache.\n\t * @internal\n\t */\n\tprivate readonly _didResolutionCacheCapacity: number;\n\n\t/**\n\t * Maximum wait time for resolution cache getOrSet mutex acquisition in milliseconds.\n\t * @internal\n\t */\n\tprivate readonly _didResolutionCacheMutexTimeoutMs?: number;\n\n\t/**\n\t * LRU cache for resolved DID documents. Undefined when caching is disabled (ttl is 0).\n\t * @internal\n\t */\n\tprivate readonly _didResolutionCache?: LruCache<IDidDocument>;\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\n\t\tthis._didResolutionCacheTtlMs = options?.config?.didResolutionCacheTtlMs ?? 30_000;\n\t\tthis._didResolutionCacheCapacity = options?.config?.didResolutionCacheCapacity ?? 1000;\n\t\tthis._didResolutionCacheMutexTimeoutMs = options?.config?.didResolutionCacheMutexTimeoutMs;\n\t\tthis._didResolutionCache =\n\t\t\tthis._didResolutionCacheTtlMs > 0\n\t\t\t\t? new LruCache<IDidDocument>({\n\t\t\t\t\t\tcapacity: this._didResolutionCacheCapacity,\n\t\t\t\t\t\tttiMs: this._didResolutionCacheTtlMs,\n\t\t\t\t\t\tmutexTimeoutMs: this._didResolutionCacheMutexTimeoutMs\n\t\t\t\t\t})\n\t\t\t\t: undefined;\n\t}\n\n\t/**\n\t * 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 * Stop the service.\n\t * Destroys in-memory resources owned by this component.\n\t * @param nodeLoggingComponentType The node logging component type.\n\t * @returns A promise that resolves when the service has stopped.\n\t */\n\tpublic async stop(nodeLoggingComponentType?: string): Promise<void> {\n\t\tthis._didResolutionCache?.destroy();\n\t}\n\n\t/**\n\t * Resolve a document from its id, cached for didResolutionCacheTtlMs\n\t * (0 disables caching and resolves fresh every call).\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\tif (Is.undefined(this._didResolutionCache)) {\n\t\t\treturn this.loadDocument(documentId);\n\t\t}\n\n\t\tconst document = await this._didResolutionCache.getOrSet(documentId, async () =>\n\t\t\tthis.loadDocument(documentId)\n\t\t);\n\n\t\t// Return a deep clone, not the cached instance itself, so a caller mutating the document\n\t\t// it receives cannot corrupt the entry shared with every other caller.\n\t\treturn ObjectHelper.clone(document);\n\t}\n\n\t/**\n\t * Load and verify a document from storage, bypassing the cache.\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 * @internal\n\t */\n\tprivate async loadDocument(documentId: string): Promise<IDidDocument> {\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\t{ documentId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
|
package/dist/es/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export * from "./entityStorageIdentityResolverConnector.js";
|
|
|
8
8
|
export * from "./models/IEntityStorageIdentityConnectorConfig.js";
|
|
9
9
|
export * from "./models/IEntityStorageIdentityConnectorConstructorOptions.js";
|
|
10
10
|
export * from "./models/IEntityStorageIdentityProfileConnectorConstructorOptions.js";
|
|
11
|
+
export * from "./models/IEntityStorageIdentityResolverConnectorConfig.js";
|
|
11
12
|
export * from "./models/IEntityStorageIdentityResolverConnectorConstructorOptions.js";
|
|
12
13
|
export * from "./schema.js";
|
|
13
14
|
//# sourceMappingURL=index.js.map
|
package/dist/es/index.js.map
CHANGED
|
@@ -1 +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,mDAAmD,CAAC;AAClE,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/IEntityStorageIdentityConnectorConfig.js\";\nexport * from \"./models/IEntityStorageIdentityConnectorConstructorOptions.js\";\nexport * from \"./models/IEntityStorageIdentityProfileConnectorConstructorOptions.js\";\nexport * from \"./models/IEntityStorageIdentityResolverConnectorConstructorOptions.js\";\nexport * from \"./schema.js\";\n"]}
|
|
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,mDAAmD,CAAC;AAClE,cAAc,+DAA+D,CAAC;AAC9E,cAAc,sEAAsE,CAAC;AACrF,cAAc,2DAA2D,CAAC;AAC1E,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/IEntityStorageIdentityConnectorConfig.js\";\nexport * from \"./models/IEntityStorageIdentityConnectorConstructorOptions.js\";\nexport * from \"./models/IEntityStorageIdentityProfileConnectorConstructorOptions.js\";\nexport * from \"./models/IEntityStorageIdentityResolverConnectorConfig.js\";\nexport * from \"./models/IEntityStorageIdentityResolverConnectorConstructorOptions.js\";\nexport * from \"./schema.js\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEntityStorageIdentityResolverConnectorConfig.js","sourceRoot":"","sources":["../../../src/models/IEntityStorageIdentityResolverConnectorConfig.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Configuration for the Entity Storage Identity Resolver Connector.\n */\nexport interface IEntityStorageIdentityResolverConnectorConfig {\n\t/**\n\t * TTL in ms for caching resolved DID documents. 0 disables caching. As the documents\n\t * resolved here can belong to third parties, a non-zero TTL means changes made to a\n\t * document in storage, including revocation, are only observed once the entry expires.\n\t * @default 30000\n\t */\n\tdidResolutionCacheTtlMs?: number;\n\n\t/**\n\t * Maximum number of DID documents kept in the resolution cache.\n\t * Only used when didResolutionCacheTtlMs > 0.\n\t * @default 1000\n\t */\n\tdidResolutionCacheCapacity?: number;\n\n\t/**\n\t * Maximum time in milliseconds to wait for resolution cache getOrSet mutex acquisition.\n\t * Only used when didResolutionCacheTtlMs > 0.\n\t */\n\tdidResolutionCacheMutexTimeoutMs?: number;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IEntityStorageIdentityResolverConnectorConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IEntityStorageIdentityResolverConnectorConstructorOptions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IEntityStorageIdentityResolverConnectorConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IEntityStorageIdentityResolverConnectorConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IEntityStorageIdentityResolverConnectorConfig } from \"./IEntityStorageIdentityResolverConnectorConfig.js\";\n\n/**\n * Options for the entity storage identity connector constructor.\n */\nexport interface IEntityStorageIdentityResolverConnectorConstructorOptions {\n\t/**\n\t * Configuration for the connector.\n\t */\n\tconfig?: IEntityStorageIdentityResolverConnectorConfig;\n\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"]}
|
|
@@ -24,7 +24,15 @@ export declare class EntityStorageIdentityResolverConnector implements IIdentity
|
|
|
24
24
|
*/
|
|
25
25
|
className(): string;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Stop the service.
|
|
28
|
+
* Destroys in-memory resources owned by this component.
|
|
29
|
+
* @param nodeLoggingComponentType The node logging component type.
|
|
30
|
+
* @returns A promise that resolves when the service has stopped.
|
|
31
|
+
*/
|
|
32
|
+
stop(nodeLoggingComponentType?: string): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Resolve a document from its id, cached for didResolutionCacheTtlMs
|
|
35
|
+
* (0 disables caching and resolves fresh every call).
|
|
28
36
|
* @param documentId The id of the document to resolve.
|
|
29
37
|
* @returns The resolved document.
|
|
30
38
|
* @throws NotFoundError if the id can not be resolved.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,5 +6,6 @@ export * from "./entityStorageIdentityResolverConnector.js";
|
|
|
6
6
|
export * from "./models/IEntityStorageIdentityConnectorConfig.js";
|
|
7
7
|
export * from "./models/IEntityStorageIdentityConnectorConstructorOptions.js";
|
|
8
8
|
export * from "./models/IEntityStorageIdentityProfileConnectorConstructorOptions.js";
|
|
9
|
+
export * from "./models/IEntityStorageIdentityResolverConnectorConfig.js";
|
|
9
10
|
export * from "./models/IEntityStorageIdentityResolverConnectorConstructorOptions.js";
|
|
10
11
|
export * from "./schema.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for the Entity Storage Identity Resolver Connector.
|
|
3
|
+
*/
|
|
4
|
+
export interface IEntityStorageIdentityResolverConnectorConfig {
|
|
5
|
+
/**
|
|
6
|
+
* TTL in ms for caching resolved DID documents. 0 disables caching. As the documents
|
|
7
|
+
* resolved here can belong to third parties, a non-zero TTL means changes made to a
|
|
8
|
+
* document in storage, including revocation, are only observed once the entry expires.
|
|
9
|
+
* @default 30000
|
|
10
|
+
*/
|
|
11
|
+
didResolutionCacheTtlMs?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Maximum number of DID documents kept in the resolution cache.
|
|
14
|
+
* Only used when didResolutionCacheTtlMs > 0.
|
|
15
|
+
* @default 1000
|
|
16
|
+
*/
|
|
17
|
+
didResolutionCacheCapacity?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Maximum time in milliseconds to wait for resolution cache getOrSet mutex acquisition.
|
|
20
|
+
* Only used when didResolutionCacheTtlMs > 0.
|
|
21
|
+
*/
|
|
22
|
+
didResolutionCacheMutexTimeoutMs?: number;
|
|
23
|
+
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import type { IEntityStorageIdentityResolverConnectorConfig } from "./IEntityStorageIdentityResolverConnectorConfig.js";
|
|
1
2
|
/**
|
|
2
3
|
* Options for the entity storage identity connector constructor.
|
|
3
4
|
*/
|
|
4
5
|
export interface IEntityStorageIdentityResolverConnectorConstructorOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for the connector.
|
|
8
|
+
*/
|
|
9
|
+
config?: IEntityStorageIdentityResolverConnectorConfig;
|
|
5
10
|
/**
|
|
6
11
|
* The entity storage for the did documents.
|
|
7
12
|
* @default identity-document
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @twin.org/identity-connector-entity-storage- Changelog
|
|
2
2
|
|
|
3
|
+
## [0.9.3-next.2](https://github.com/iotaledger/twin-identity/compare/identity-connector-entity-storage-v0.9.3-next.1...identity-connector-entity-storage-v0.9.3-next.2) (2026-09-04)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* did resolver caching ([#220](https://github.com/iotaledger/twin-identity/issues/220)) ([fdcbf65](https://github.com/iotaledger/twin-identity/commit/fdcbf65fb6f9deef82e8c32a98835edaf6608e90))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/identity-models bumped from 0.9.3-next.1 to 0.9.3-next.2
|
|
16
|
+
|
|
3
17
|
## [0.9.3-next.1](https://github.com/iotaledger/twin-identity/compare/identity-connector-entity-storage-v0.9.3-next.0...identity-connector-entity-storage-v0.9.3-next.1) (2026-08-26)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -62,11 +62,39 @@ The class name of the component.
|
|
|
62
62
|
|
|
63
63
|
***
|
|
64
64
|
|
|
65
|
+
### stop() {#stop}
|
|
66
|
+
|
|
67
|
+
> **stop**(`nodeLoggingComponentType?`): `Promise`\<`void`\>
|
|
68
|
+
|
|
69
|
+
Stop the service.
|
|
70
|
+
Destroys in-memory resources owned by this component.
|
|
71
|
+
|
|
72
|
+
#### Parameters
|
|
73
|
+
|
|
74
|
+
##### nodeLoggingComponentType?
|
|
75
|
+
|
|
76
|
+
`string`
|
|
77
|
+
|
|
78
|
+
The node logging component type.
|
|
79
|
+
|
|
80
|
+
#### Returns
|
|
81
|
+
|
|
82
|
+
`Promise`\<`void`\>
|
|
83
|
+
|
|
84
|
+
A promise that resolves when the service has stopped.
|
|
85
|
+
|
|
86
|
+
#### Implementation of
|
|
87
|
+
|
|
88
|
+
`IIdentityResolverConnector.stop`
|
|
89
|
+
|
|
90
|
+
***
|
|
91
|
+
|
|
65
92
|
### resolveDocument() {#resolvedocument}
|
|
66
93
|
|
|
67
94
|
> **resolveDocument**(`documentId`): `Promise`\<`IDidDocument`\>
|
|
68
95
|
|
|
69
|
-
Resolve a document from its id
|
|
96
|
+
Resolve a document from its id, cached for didResolutionCacheTtlMs
|
|
97
|
+
(0 disables caching and resolves fresh every call).
|
|
70
98
|
|
|
71
99
|
#### Parameters
|
|
72
100
|
|
package/docs/reference/index.md
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
- [IEntityStorageIdentityConnectorConfig](interfaces/IEntityStorageIdentityConnectorConfig.md)
|
|
14
14
|
- [IEntityStorageIdentityConnectorConstructorOptions](interfaces/IEntityStorageIdentityConnectorConstructorOptions.md)
|
|
15
15
|
- [IEntityStorageIdentityProfileConnectorConstructorOptions](interfaces/IEntityStorageIdentityProfileConnectorConstructorOptions.md)
|
|
16
|
+
- [IEntityStorageIdentityResolverConnectorConfig](interfaces/IEntityStorageIdentityResolverConnectorConfig.md)
|
|
16
17
|
- [IEntityStorageIdentityResolverConnectorConstructorOptions](interfaces/IEntityStorageIdentityResolverConnectorConstructorOptions.md)
|
|
17
18
|
|
|
18
19
|
## Functions
|
|
@@ -14,6 +14,10 @@ Options for the entity storage identity connector constructor.
|
|
|
14
14
|
|
|
15
15
|
Configuration for the connector.
|
|
16
16
|
|
|
17
|
+
#### Overrides
|
|
18
|
+
|
|
19
|
+
[`IEntityStorageIdentityResolverConnectorConstructorOptions`](IEntityStorageIdentityResolverConnectorConstructorOptions.md).[`config`](IEntityStorageIdentityResolverConnectorConstructorOptions.md#config)
|
|
20
|
+
|
|
17
21
|
***
|
|
18
22
|
|
|
19
23
|
### didDocumentEntityStorageType? {#diddocumententitystoragetype}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Interface: IEntityStorageIdentityResolverConnectorConfig
|
|
2
|
+
|
|
3
|
+
Configuration for the Entity Storage Identity Resolver Connector.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### didResolutionCacheTtlMs? {#didresolutioncachettlms}
|
|
8
|
+
|
|
9
|
+
> `optional` **didResolutionCacheTtlMs?**: `number`
|
|
10
|
+
|
|
11
|
+
TTL in ms for caching resolved DID documents. 0 disables caching. As the documents
|
|
12
|
+
resolved here can belong to third parties, a non-zero TTL means changes made to a
|
|
13
|
+
document in storage, including revocation, are only observed once the entry expires.
|
|
14
|
+
|
|
15
|
+
#### Default
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
30000
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### didResolutionCacheCapacity? {#didresolutioncachecapacity}
|
|
24
|
+
|
|
25
|
+
> `optional` **didResolutionCacheCapacity?**: `number`
|
|
26
|
+
|
|
27
|
+
Maximum number of DID documents kept in the resolution cache.
|
|
28
|
+
Only used when didResolutionCacheTtlMs > 0.
|
|
29
|
+
|
|
30
|
+
#### Default
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
1000
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
***
|
|
37
|
+
|
|
38
|
+
### didResolutionCacheMutexTimeoutMs? {#didresolutioncachemutextimeoutms}
|
|
39
|
+
|
|
40
|
+
> `optional` **didResolutionCacheMutexTimeoutMs?**: `number`
|
|
41
|
+
|
|
42
|
+
Maximum time in milliseconds to wait for resolution cache getOrSet mutex acquisition.
|
|
43
|
+
Only used when didResolutionCacheTtlMs > 0.
|
package/docs/reference/interfaces/IEntityStorageIdentityResolverConnectorConstructorOptions.md
CHANGED
|
@@ -8,6 +8,14 @@ Options for the entity storage identity connector constructor.
|
|
|
8
8
|
|
|
9
9
|
## Properties
|
|
10
10
|
|
|
11
|
+
### config? {#config}
|
|
12
|
+
|
|
13
|
+
> `optional` **config?**: [`IEntityStorageIdentityResolverConnectorConfig`](IEntityStorageIdentityResolverConnectorConfig.md)
|
|
14
|
+
|
|
15
|
+
Configuration for the connector.
|
|
16
|
+
|
|
17
|
+
***
|
|
18
|
+
|
|
11
19
|
### didDocumentEntityStorageType? {#diddocumententitystoragetype}
|
|
12
20
|
|
|
13
21
|
> `optional` **didDocumentEntityStorageType?**: `string`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/identity-connector-entity-storage",
|
|
3
|
-
"version": "0.9.3-next.
|
|
3
|
+
"version": "0.9.3-next.2",
|
|
4
4
|
"description": "Entity storage connector for persisting and retrieving identity records through a consistent data layer.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@twin.org/data-json-ld": "next",
|
|
20
20
|
"@twin.org/entity": "next",
|
|
21
21
|
"@twin.org/entity-storage-models": "next",
|
|
22
|
-
"@twin.org/identity-models": "0.9.3-next.
|
|
22
|
+
"@twin.org/identity-models": "0.9.3-next.2",
|
|
23
23
|
"@twin.org/nameof": "next",
|
|
24
24
|
"@twin.org/standards-w3c-did": "next",
|
|
25
25
|
"@twin.org/vault-models": "next",
|