@twin.org/identity-connector-entity-storage 0.9.2 → 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 +207 -139
- 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 +2 -0
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/IEntityStorageIdentityConnectorConfig.js +4 -0
- package/dist/es/models/IEntityStorageIdentityConnectorConfig.js.map +1 -0
- package/dist/es/models/IEntityStorageIdentityConnectorConstructorOptions.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/entityStorageIdentityConnector.d.ts +11 -1
- package/dist/types/entityStorageIdentityResolverConnector.d.ts +9 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/models/IEntityStorageIdentityConnectorConfig.d.ts +26 -0
- package/dist/types/models/IEntityStorageIdentityConnectorConstructorOptions.d.ts +5 -0
- package/dist/types/models/IEntityStorageIdentityResolverConnectorConfig.d.ts +23 -0
- package/dist/types/models/IEntityStorageIdentityResolverConnectorConstructorOptions.d.ts +5 -0
- package/docs/changelog.md +69 -0
- package/docs/reference/classes/EntityStorageIdentityConnector.md +36 -1
- package/docs/reference/classes/EntityStorageIdentityResolverConnector.md +29 -1
- package/docs/reference/index.md +2 -0
- package/docs/reference/interfaces/IEntityStorageIdentityConnectorConfig.md +46 -0
- package/docs/reference/interfaces/IEntityStorageIdentityConnectorConstructorOptions.md +12 -0
- package/docs/reference/interfaces/IEntityStorageIdentityResolverConnectorConfig.md +43 -0
- package/docs/reference/interfaces/IEntityStorageIdentityResolverConnectorConstructorOptions.md +8 -0
- package/locales/en.json +1 -0
- package/package.json +11 -11
|
@@ -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,IAA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AAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tAlreadyExistsError,\n\tBaseError,\n\tGeneralError,\n\tGuards,\n\tIs,\n\tNotFoundError,\n\tObjectHelper\n} from \"@twin.org/core\";\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\nimport { ComparisonOperator } from \"@twin.org/entity\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport type { IIdentityProfileConnector } from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IdentityProfile } from \"./entities/identityProfile.js\";\nimport type { IEntityStorageIdentityProfileConnectorConstructorOptions } from \"./models/IEntityStorageIdentityProfileConnectorConstructorOptions.js\";\n\n/**\n * Class which implements the identity profile connector contract.\n */\nexport class EntityStorageIdentityProfileConnector<\n\tT extends IJsonLdDocument = IJsonLdDocument,\n\tU extends IJsonLdDocument = IJsonLdDocument\n> implements IIdentityProfileConnector<T, U> {\n\t/**\n\t * The namespace supported by the identity profile connector.\n\t */\n\tpublic static readonly NAMESPACE: string = \"entity-storage\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageIdentityProfileConnector>();\n\n\t/**\n\t * The storage connector for the profiles.\n\t * @internal\n\t */\n\tprivate readonly _profileEntityStorage: IEntityStorageConnector<IdentityProfile>;\n\n\t/**\n\t * Create a new instance of EntityStorageIdentityProfileConnector.\n\t * @param options The options for the identity service.\n\t */\n\tconstructor(options?: IEntityStorageIdentityProfileConnectorConstructorOptions) {\n\t\tthis._profileEntityStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.profileEntityStorageType ?? \"identity-profile\"\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageIdentityProfileConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create the profile properties for an identity.\n\t * @param identity The identity of the profile to create.\n\t * @param publicProfile The public profile data.\n\t * @param privateProfile The private profile data.\n\t * @returns A promise that resolves when the profile has been created.\n\t */\n\tpublic async create(identity: string, publicProfile?: T, privateProfile?: U): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\n\t\t\tif (!Is.empty(profile)) {\n\t\t\t\tthrow new AlreadyExistsError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"alreadyExists\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this._profileEntityStorage.set({\n\t\t\t\tidentity,\n\t\t\t\tpublicProfile,\n\t\t\t\tprivateProfile\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"createFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the profile properties for an identity.\n\t * @param identity The identity of the item to get.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @returns The items properties.\n\t */\n\tpublic async get(\n\t\tidentity: string,\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[]\n\t): Promise<{\n\t\tpublicProfile: Partial<T>;\n\t\tprivateProfile: Partial<U>;\n\t}> {\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (!profile) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"identityNotFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn this.pickProperties(profile, publicPropertyNames, privatePropertyNames);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"getFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Update the profile properties of an identity.\n\t * @param identity The identity to update.\n\t * @param publicProfile The public profile data.\n\t * @param privateProfile The private profile data.\n\t * @returns A promise that resolves when the profile has been updated.\n\t */\n\tpublic async update(identity: string, publicProfile?: T, privateProfile?: U): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (Is.empty(profile)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"notFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tprofile.publicProfile = publicProfile ?? profile.publicProfile;\n\t\t\tprofile.privateProfile = privateProfile ?? profile.privateProfile;\n\n\t\t\tawait this._profileEntityStorage.set(profile);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"updateFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Delete the profile for an identity.\n\t * @param identity The identity to delete.\n\t * @returns A promise that resolves when the profile has been removed.\n\t */\n\tpublic async remove(identity: string): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\tnameof(identity),\n\t\t\tidentity\n\t\t);\n\n\t\ttry {\n\t\t\tconst profile = await this._profileEntityStorage.get(identity);\n\t\t\tif (Is.empty(profile)) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\t\"notFound\",\n\t\t\t\t\tidentity\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this._profileEntityStorage.remove(identity);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, EntityStorageIdentityProfileConnector.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"removeFailed\",\n\t\t\t\t{ identity },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get a list of the requested types.\n\t * @param publicFilters The filters to apply to the identities public profiles.\n\t * @param privateFilters The filters to apply to the identities private profiles.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @param cursor The cursor for paged requests.\n\t * @param limit The maximum number of items in a page.\n\t * @returns The list of items and cursor for paging.\n\t */\n\tpublic async list(\n\t\tpublicFilters?: {\n\t\t\tpropertyName: string;\n\t\t\tpropertyValue: unknown;\n\t\t}[],\n\t\tprivateFilters?: {\n\t\t\tpropertyName: string;\n\t\t\tpropertyValue: unknown;\n\t\t}[],\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[],\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\t/**\n\t\t * The identities.\n\t\t */\n\t\titems: {\n\t\t\tidentity: string;\n\t\t\tpublicProfile?: Partial<T>;\n\t\t\tprivateProfile?: Partial<U>;\n\t\t}[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}> {\n\t\ttry {\n\t\t\tconst conditions = [];\n\n\t\t\tif (Is.arrayValue(publicFilters)) {\n\t\t\t\tfor (const filter of publicFilters) {\n\t\t\t\t\tconditions.push({\n\t\t\t\t\t\tproperty: `publicProfile.${filter.propertyName}`,\n\t\t\t\t\t\tvalue: filter.propertyValue,\n\t\t\t\t\t\tcomparison: ComparisonOperator.Equals\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Is.arrayValue(privateFilters)) {\n\t\t\t\tfor (const filter of privateFilters) {\n\t\t\t\t\tconditions.push({\n\t\t\t\t\t\tproperty: `privateProfile.${filter.propertyName}`,\n\t\t\t\t\t\tvalue: filter.propertyValue,\n\t\t\t\t\t\tcomparison: ComparisonOperator.Equals\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst result = await this._profileEntityStorage.query(\n\t\t\t\tIs.arrayValue(conditions)\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tconditions\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\tcursor,\n\t\t\t\tlimit\n\t\t\t);\n\n\t\t\tconst items: {\n\t\t\t\tidentity: string;\n\t\t\t\tpublicProfile?: Partial<T>;\n\t\t\t\tprivateProfile?: Partial<U>;\n\t\t\t}[] = [];\n\t\t\tfor (const resultEntity of result.entities) {\n\t\t\t\titems.push({\n\t\t\t\t\tidentity: resultEntity.identity ?? \"\",\n\t\t\t\t\t...this.pickProperties(resultEntity, publicPropertyNames, privatePropertyNames)\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\titems,\n\t\t\t\tcursor: result.cursor\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tEntityStorageIdentityProfileConnector.CLASS_NAME,\n\t\t\t\t\"listFailed\",\n\t\t\t\tundefined,\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the profile properties for an identity.\n\t * @param profile The profile to pick the properties from.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to all.\n\t * @returns The identity profile, will only return private data if you have correct permissions.\n\t * @internal\n\t */\n\tprivate pickProperties(\n\t\tprofile: Partial<IdentityProfile>,\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[]\n\t): {\n\t\tpublicProfile: Partial<T>;\n\t\tprivateProfile: Partial<U>;\n\t} {\n\t\treturn {\n\t\t\tpublicProfile: Is.array(publicPropertyNames)\n\t\t\t\t? ObjectHelper.pick(profile.publicProfile as T, publicPropertyNames)\n\t\t\t\t: (profile.publicProfile as T),\n\t\t\tprivateProfile: Is.array(privatePropertyNames)\n\t\t\t\t? ObjectHelper.pick(profile.privateProfile as U, privatePropertyNames)\n\t\t\t\t: (profile.privateProfile as U)\n\t\t};\n\t}\n}\n"]}
|
|
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,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,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,YAAY,CACrB,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,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C;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,YAAY,CACrB,sCAAsC,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
|
@@ -5,8 +5,10 @@ export * from "./entities/identityProfile.js";
|
|
|
5
5
|
export * from "./entityStorageIdentityConnector.js";
|
|
6
6
|
export * from "./entityStorageIdentityProfileConnector.js";
|
|
7
7
|
export * from "./entityStorageIdentityResolverConnector.js";
|
|
8
|
+
export * from "./models/IEntityStorageIdentityConnectorConfig.js";
|
|
8
9
|
export * from "./models/IEntityStorageIdentityConnectorConstructorOptions.js";
|
|
9
10
|
export * from "./models/IEntityStorageIdentityProfileConnectorConstructorOptions.js";
|
|
11
|
+
export * from "./models/IEntityStorageIdentityResolverConnectorConfig.js";
|
|
10
12
|
export * from "./models/IEntityStorageIdentityResolverConnectorConstructorOptions.js";
|
|
11
13
|
export * from "./schema.js";
|
|
12
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,+DAA+D,CAAC;AAC9E,cAAc,sEAAsE,CAAC;AACrF,cAAc,uEAAuE,CAAC;AACtF,cAAc,aAAa,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./entities/identityDocument.js\";\nexport * from \"./entities/identityProfile.js\";\nexport * from \"./entityStorageIdentityConnector.js\";\nexport * from \"./entityStorageIdentityProfileConnector.js\";\nexport * from \"./entityStorageIdentityResolverConnector.js\";\nexport * from \"./models/IEntityStorageIdentityConnectorConstructorOptions.js\";\nexport * from \"./models/IEntityStorageIdentityProfileConnectorConstructorOptions.js\";\nexport * from \"./models/IEntityStorageIdentityResolverConnectorConstructorOptions.js\";\nexport * from \"./schema.js\";\n"]}
|
|
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":"IEntityStorageIdentityConnectorConfig.js","sourceRoot":"","sources":["../../../src/models/IEntityStorageIdentityConnectorConfig.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 Connector.\n */\nexport interface IEntityStorageIdentityConnectorConfig {\n\t/**\n\t * TTL in ms for caching DID documents resolved for the connector's own sign/mutate\n\t * operations (create/update/revoke on an identity this connector controls). 0 disables\n\t * caching. Does not affect proof or credential verification of third-party claims, which\n\t * is never cached by this connector. Refreshed by every mutation made through this\n\t * connector instance; a mutation made through a different instance or out-of-band is not\n\t * observed until the entry's TTL expires.\n\t * @default 30000\n\t */\n\tdidResolutionCacheTtlMs?: number;\n\n\t/**\n\t * Maximum number of DID documents kept in the own-DID 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 own-DID cache getOrSet mutex acquisition.\n\t * Only used when didResolutionCacheTtlMs > 0.\n\t */\n\tdidResolutionCacheMutexTimeoutMs?: number;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IEntityStorageIdentityConnectorConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IEntityStorageIdentityConnectorConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IEntityStorageIdentityResolverConnectorConstructorOptions } from \"./IEntityStorageIdentityResolverConnectorConstructorOptions.js\";\n\n/**\n * Options for the entity storage identity connector constructor.\n */\n// eslint-disable-next-line
|
|
1
|
+
{"version":3,"file":"IEntityStorageIdentityConnectorConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IEntityStorageIdentityConnectorConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IEntityStorageIdentityConnectorConfig } from \"./IEntityStorageIdentityConnectorConfig.js\";\nimport type { IEntityStorageIdentityResolverConnectorConstructorOptions } from \"./IEntityStorageIdentityResolverConnectorConstructorOptions.js\";\n\n/**\n * Options for the entity storage identity connector constructor.\n */\n// eslint-disable-next-line max-len\nexport interface IEntityStorageIdentityConnectorConstructorOptions extends IEntityStorageIdentityResolverConnectorConstructorOptions {\n\t/**\n\t * Configuration for the connector.\n\t */\n\tconfig?: IEntityStorageIdentityConnectorConfig;\n}\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,6 +24,13 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
|
|
|
24
24
|
* @returns The class name of the component.
|
|
25
25
|
*/
|
|
26
26
|
className(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Stop the service.
|
|
29
|
+
* Destroys in-memory resources owned by this component.
|
|
30
|
+
* @param nodeLoggingComponentType The node logging component type.
|
|
31
|
+
* @returns A promise that resolves when the service has stopped.
|
|
32
|
+
*/
|
|
33
|
+
stop(nodeLoggingComponentType?: string): Promise<void>;
|
|
27
34
|
/**
|
|
28
35
|
* Create a new document.
|
|
29
36
|
* @param controller The controller of the identity who can make changes.
|
|
@@ -203,11 +210,14 @@ export declare class EntityStorageIdentityConnector implements IIdentityConnecto
|
|
|
203
210
|
* @param verificationMethodId The verification method id to use.
|
|
204
211
|
* @param proofType The type of proof to create.
|
|
205
212
|
* @param unsecureDocument The unsecure document to create the proof for.
|
|
213
|
+
* @param resolvedDocument Optional already-resolved document for the DID, so a caller that
|
|
214
|
+
* just resolved it (e.g. createVerifiableCredential) skips a redundant re-resolve. Resolves
|
|
215
|
+
* it itself if omitted.
|
|
206
216
|
* @returns The proof.
|
|
207
217
|
* @throws NotFoundError if the identity or method is not found.
|
|
208
218
|
* @throws GeneralError if algorithm doesn't match key type or proof creation fails.
|
|
209
219
|
*/
|
|
210
|
-
createProof(controller: string, verificationMethodId: string, proofType: ProofTypes, unsecureDocument: IJsonLdNodeObject): Promise<IProof>;
|
|
220
|
+
createProof(controller: string, verificationMethodId: string, proofType: ProofTypes, unsecureDocument: IJsonLdNodeObject, resolvedDocument?: IDidDocument): Promise<IProof>;
|
|
211
221
|
/**
|
|
212
222
|
* Verify proof for arbitrary data with the specified verification method.
|
|
213
223
|
* @param document The document to verify.
|
|
@@ -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
|
@@ -3,7 +3,9 @@ export * from "./entities/identityProfile.js";
|
|
|
3
3
|
export * from "./entityStorageIdentityConnector.js";
|
|
4
4
|
export * from "./entityStorageIdentityProfileConnector.js";
|
|
5
5
|
export * from "./entityStorageIdentityResolverConnector.js";
|
|
6
|
+
export * from "./models/IEntityStorageIdentityConnectorConfig.js";
|
|
6
7
|
export * from "./models/IEntityStorageIdentityConnectorConstructorOptions.js";
|
|
7
8
|
export * from "./models/IEntityStorageIdentityProfileConnectorConstructorOptions.js";
|
|
9
|
+
export * from "./models/IEntityStorageIdentityResolverConnectorConfig.js";
|
|
8
10
|
export * from "./models/IEntityStorageIdentityResolverConnectorConstructorOptions.js";
|
|
9
11
|
export * from "./schema.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for the Entity Storage Identity Connector.
|
|
3
|
+
*/
|
|
4
|
+
export interface IEntityStorageIdentityConnectorConfig {
|
|
5
|
+
/**
|
|
6
|
+
* TTL in ms for caching DID documents resolved for the connector's own sign/mutate
|
|
7
|
+
* operations (create/update/revoke on an identity this connector controls). 0 disables
|
|
8
|
+
* caching. Does not affect proof or credential verification of third-party claims, which
|
|
9
|
+
* is never cached by this connector. Refreshed by every mutation made through this
|
|
10
|
+
* connector instance; a mutation made through a different instance or out-of-band is not
|
|
11
|
+
* observed until the entry's TTL expires.
|
|
12
|
+
* @default 30000
|
|
13
|
+
*/
|
|
14
|
+
didResolutionCacheTtlMs?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Maximum number of DID documents kept in the own-DID resolution cache.
|
|
17
|
+
* Only used when didResolutionCacheTtlMs > 0.
|
|
18
|
+
* @default 1000
|
|
19
|
+
*/
|
|
20
|
+
didResolutionCacheCapacity?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Maximum time in milliseconds to wait for own-DID cache getOrSet mutex acquisition.
|
|
23
|
+
* Only used when didResolutionCacheTtlMs > 0.
|
|
24
|
+
*/
|
|
25
|
+
didResolutionCacheMutexTimeoutMs?: number;
|
|
26
|
+
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import type { IEntityStorageIdentityConnectorConfig } from "./IEntityStorageIdentityConnectorConfig.js";
|
|
1
2
|
import type { IEntityStorageIdentityResolverConnectorConstructorOptions } from "./IEntityStorageIdentityResolverConnectorConstructorOptions.js";
|
|
2
3
|
/**
|
|
3
4
|
* Options for the entity storage identity connector constructor.
|
|
4
5
|
*/
|
|
5
6
|
export interface IEntityStorageIdentityConnectorConstructorOptions extends IEntityStorageIdentityResolverConnectorConstructorOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Configuration for the connector.
|
|
9
|
+
*/
|
|
10
|
+
config?: IEntityStorageIdentityConnectorConfig;
|
|
6
11
|
}
|
|
@@ -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,74 @@
|
|
|
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
|
+
|
|
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)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* add addAlsoKnownAs to identity connector ([#117](https://github.com/iotaledger/twin-identity/issues/117)) ([aa27cff](https://github.com/iotaledger/twin-identity/commit/aa27cff88e61e7c8c6e32aeb437fb01c6ee9f57a))
|
|
23
|
+
* add context id features ([#62](https://github.com/iotaledger/twin-identity/issues/62)) ([e02ecca](https://github.com/iotaledger/twin-identity/commit/e02ecca9c45a849104bfbf7bc18a1f44e6eea8a1))
|
|
24
|
+
* add expiration date option to vc creation ([73e05e1](https://github.com/iotaledger/twin-identity/commit/73e05e1ae61112c7e056889969751f4ff82d9f29))
|
|
25
|
+
* add identity remove ([eebc13f](https://github.com/iotaledger/twin-identity/commit/eebc13f4c2cd994d2d9cce4da2128fb346c80ba7))
|
|
26
|
+
* add optional jwt payload and headers to vc and vp tokens ([#135](https://github.com/iotaledger/twin-identity/issues/135)) ([aa1de0f](https://github.com/iotaledger/twin-identity/commit/aa1de0f63be95ff62bae3c699aabc85ea93d74c2))
|
|
27
|
+
* add own-DID resolution caching to EntityStorageIdentityConnector ([#216](https://github.com/iotaledger/twin-identity/issues/216)) ([a4c170b](https://github.com/iotaledger/twin-identity/commit/a4c170be83d00f2bf53d70056321d53a3b22f940))
|
|
28
|
+
* add proof to vc in entity storage connector ([2a968a1](https://github.com/iotaledger/twin-identity/commit/2a968a1a011cbafb8a0997234e069c91c4eaa793))
|
|
29
|
+
* add proof to vcs and verify vs documents ([#103](https://github.com/iotaledger/twin-identity/issues/103)) ([b60bf0c](https://github.com/iotaledger/twin-identity/commit/b60bf0cb7d453d67574c5c0e4f769e67cf7cd6d1))
|
|
30
|
+
* add validate-locales ([04d74b4](https://github.com/iotaledger/twin-identity/commit/04d74b4d1ebe42672e8ca75a7bdb8e3556afd0be))
|
|
31
|
+
* add vault signing ([#153](https://github.com/iotaledger/twin-identity/issues/153)) ([9458e4c](https://github.com/iotaledger/twin-identity/commit/9458e4c96ce19e0fc704905dfb3aac04dc6cf237))
|
|
32
|
+
* common connector tests ([4f9642c](https://github.com/iotaledger/twin-identity/commit/4f9642ceb09843870909fc6819bf69fb20ef952a))
|
|
33
|
+
* ensure credential subject exists ([3847e82](https://github.com/iotaledger/twin-identity/commit/3847e8250ac5abd1fffcd1a72d3157f32d08478c))
|
|
34
|
+
* eslint migration to flat config ([fd6246d](https://github.com/iotaledger/twin-identity/commit/fd6246d566280b6d5d10a108eb1e92c4b510f2f2))
|
|
35
|
+
* expanded cli methods ([#121](https://github.com/iotaledger/twin-identity/issues/121)) ([80a52b7](https://github.com/iotaledger/twin-identity/commit/80a52b779237cd633d1f2813fa976585cef6e551))
|
|
36
|
+
* health and key removal ([#191](https://github.com/iotaledger/twin-identity/issues/191)) ([8504101](https://github.com/iotaledger/twin-identity/commit/8504101a7a08b2a042a4e59f666c245308527088))
|
|
37
|
+
* identity key separator use slash ([1319d0d](https://github.com/iotaledger/twin-identity/commit/1319d0d07164a36b3ec279e6421b8835ffefc3d3))
|
|
38
|
+
* implement async proof signing with vault security ([#110](https://github.com/iotaledger/twin-identity/issues/110)) ([9651c24](https://github.com/iotaledger/twin-identity/commit/9651c2492d63eca6545735f5638d3191e25bd185))
|
|
39
|
+
* increase resolve timeout ([523e5b6](https://github.com/iotaledger/twin-identity/commit/523e5b6375dbac06278d309bec8ca383a8e81807))
|
|
40
|
+
* re-use vault keys if available ([5a848d7](https://github.com/iotaledger/twin-identity/commit/5a848d7520829d9c891ec889fd773fbc0ee77ba5))
|
|
41
|
+
* remove auth generator ([#98](https://github.com/iotaledger/twin-identity/issues/98)) ([a8969e8](https://github.com/iotaledger/twin-identity/commit/a8969e85a5a2804abfc787406e2d12eb168dd978))
|
|
42
|
+
* typescript 6 update ([e8806ad](https://github.com/iotaledger/twin-identity/commit/e8806ad6858c37be3c0f54c41cf654023773bef3))
|
|
43
|
+
* update contexts ([#100](https://github.com/iotaledger/twin-identity/issues/100)) ([7c17f98](https://github.com/iotaledger/twin-identity/commit/7c17f983110b2fc5db1b19531d0b2a7c53e02aaa))
|
|
44
|
+
* update framework core ([c824497](https://github.com/iotaledger/twin-identity/commit/c82449709af0215eb7af496cf687c93fb30b5ae0))
|
|
45
|
+
* update namespaces and contexts ([#90](https://github.com/iotaledger/twin-identity/issues/90)) ([0c34d64](https://github.com/iotaledger/twin-identity/commit/0c34d64add8cca77856fa2d0357e774d72fbbfc1))
|
|
46
|
+
* use new generateKid method ([f0fe779](https://github.com/iotaledger/twin-identity/commit/f0fe779323b675575bb9f80aa74f1957dc57a094))
|
|
47
|
+
* use shared store mechanism ([#27](https://github.com/iotaledger/twin-identity/issues/27)) ([ce41f3f](https://github.com/iotaledger/twin-identity/commit/ce41f3fc3da1b206ec06da7ea5b2c968f788804d))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Bug Fixes
|
|
51
|
+
|
|
52
|
+
* add exp to jwt payload in entity storage vc ([41f0fbd](https://github.com/iotaledger/twin-identity/commit/41f0fbd641b4fd1fe3b23f1a16f4748e09b31f50))
|
|
53
|
+
* associate vault keys with document not controller ([#86](https://github.com/iotaledger/twin-identity/issues/86)) ([6430f4b](https://github.com/iotaledger/twin-identity/commit/6430f4b559315a1fe99b60c6db1c661d317bc243))
|
|
54
|
+
* enforce credentialStatus, validity period and assertionMethod scope on object-form verification ([#215](https://github.com/iotaledger/twin-identity/issues/215)) ([8e6eb92](https://github.com/iotaledger/twin-identity/commit/8e6eb920564e0fe4ebdc984bdf682b7779f747d0))
|
|
55
|
+
* identity subject type property ([#146](https://github.com/iotaledger/twin-identity/issues/146)) ([fe71dc6](https://github.com/iotaledger/twin-identity/commit/fe71dc66972120b42f1ff0e1dc8732cb48e1dd2a))
|
|
56
|
+
* Import path and bump version ([#21](https://github.com/iotaledger/twin-identity/issues/21)) ([ccea845](https://github.com/iotaledger/twin-identity/commit/ccea845bf32562267280bc1b3dde1c9af1a00360))
|
|
57
|
+
* Install sdk-wasm ([#20](https://github.com/iotaledger/twin-identity/issues/20)) ([75ec14e](https://github.com/iotaledger/twin-identity/commit/75ec14e072f8c219863a1c028a3b0783802086e9))
|
|
58
|
+
* linting ([08dd93e](https://github.com/iotaledger/twin-identity/commit/08dd93e7b6ba3877c9cd051533f08aff39733a5b))
|
|
59
|
+
* proof verification ([#186](https://github.com/iotaledger/twin-identity/issues/186)) ([6e926be](https://github.com/iotaledger/twin-identity/commit/6e926be25c333ea7df6ead503a9b99e4e46286fe))
|
|
60
|
+
* update vault key naming convention to use document ID prefix ([#94](https://github.com/iotaledger/twin-identity/issues/94)) ([ab125c1](https://github.com/iotaledger/twin-identity/commit/ab125c1b7eb189b5dceaddc69e5e53e33a0886db))
|
|
61
|
+
* use async getStore in tests ([cfc0d87](https://github.com/iotaledger/twin-identity/commit/cfc0d873532e8ab2010f86f05bffaad3bbaf5786))
|
|
62
|
+
* use async getStore in tests ([3424c81](https://github.com/iotaledger/twin-identity/commit/3424c81cf7407ede4a89a026072720d52bf689b2))
|
|
63
|
+
* use nameof for property guards ([9d571cf](https://github.com/iotaledger/twin-identity/commit/9d571cffae8838035fcbca8966795783013e1a99))
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
### Dependencies
|
|
67
|
+
|
|
68
|
+
* The following workspace dependencies were updated
|
|
69
|
+
* dependencies
|
|
70
|
+
* @twin.org/identity-models bumped from 0.9.3-next.0 to 0.9.3-next.1
|
|
71
|
+
|
|
3
72
|
## [0.9.2](https://github.com/iotaledger/twin-identity/compare/identity-connector-entity-storage-v0.9.2...identity-connector-entity-storage-v0.9.2) (2026-08-24)
|
|
4
73
|
|
|
5
74
|
|
|
@@ -62,6 +62,33 @@ 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
|
+
`IIdentityConnector.stop`
|
|
89
|
+
|
|
90
|
+
***
|
|
91
|
+
|
|
65
92
|
### createDocument() {#createdocument}
|
|
66
93
|
|
|
67
94
|
> **createDocument**(`controller`): `Promise`\<`IDidDocument`\>
|
|
@@ -704,7 +731,7 @@ The presentation stored in the jwt and the revocation status.
|
|
|
704
731
|
|
|
705
732
|
### createProof() {#createproof}
|
|
706
733
|
|
|
707
|
-
> **createProof**(`controller`, `verificationMethodId`, `proofType`, `unsecureDocument`): `Promise`\<`IProof`\>
|
|
734
|
+
> **createProof**(`controller`, `verificationMethodId`, `proofType`, `unsecureDocument`, `resolvedDocument?`): `Promise`\<`IProof`\>
|
|
708
735
|
|
|
709
736
|
Create a proof for arbitrary data with the specified verification method.
|
|
710
737
|
This method uses async signing to ensure the private key never leaves the vault,
|
|
@@ -736,6 +763,14 @@ The type of proof to create.
|
|
|
736
763
|
|
|
737
764
|
The unsecure document to create the proof for.
|
|
738
765
|
|
|
766
|
+
##### resolvedDocument?
|
|
767
|
+
|
|
768
|
+
`IDidDocument`
|
|
769
|
+
|
|
770
|
+
Optional already-resolved document for the DID, so a caller that
|
|
771
|
+
just resolved it (e.g. createVerifiableCredential) skips a redundant re-resolve. Resolves
|
|
772
|
+
it itself if omitted.
|
|
773
|
+
|
|
739
774
|
#### Returns
|
|
740
775
|
|
|
741
776
|
`Promise`\<`IProof`\>
|
|
@@ -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
|
@@ -10,8 +10,10 @@
|
|
|
10
10
|
|
|
11
11
|
## Interfaces
|
|
12
12
|
|
|
13
|
+
- [IEntityStorageIdentityConnectorConfig](interfaces/IEntityStorageIdentityConnectorConfig.md)
|
|
13
14
|
- [IEntityStorageIdentityConnectorConstructorOptions](interfaces/IEntityStorageIdentityConnectorConstructorOptions.md)
|
|
14
15
|
- [IEntityStorageIdentityProfileConnectorConstructorOptions](interfaces/IEntityStorageIdentityProfileConnectorConstructorOptions.md)
|
|
16
|
+
- [IEntityStorageIdentityResolverConnectorConfig](interfaces/IEntityStorageIdentityResolverConnectorConfig.md)
|
|
15
17
|
- [IEntityStorageIdentityResolverConnectorConstructorOptions](interfaces/IEntityStorageIdentityResolverConnectorConstructorOptions.md)
|
|
16
18
|
|
|
17
19
|
## Functions
|