@twin.org/identity-service 0.0.3-next.35 → 0.0.3-next.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,7 +35,7 @@ export class IdentityProfileService {
35
35
  * @param publicProfile The public profile data as JSON-LD.
36
36
  * @param privateProfile The private profile data as JSON-LD.
37
37
  * @param identity The identity to perform the profile operation on.
38
- * @returns Nothing.
38
+ * @returns A promise that resolves when the profile has been created.
39
39
  */
40
40
  async create(publicProfile, privateProfile, identity) {
41
41
  Guards.stringValue(IdentityProfileService.CLASS_NAME, "identity", identity);
@@ -103,7 +103,7 @@ export class IdentityProfileService {
103
103
  * @param publicProfile The public profile data as JSON-LD.
104
104
  * @param privateProfile The private profile data as JSON-LD.
105
105
  * @param identity The identity to perform the profile operation on.
106
- * @returns Nothing.
106
+ * @returns A promise that resolves when the profile has been updated.
107
107
  */
108
108
  async update(publicProfile, privateProfile, identity) {
109
109
  Guards.stringValue(IdentityProfileService.CLASS_NAME, "identity", identity);
@@ -124,7 +124,7 @@ export class IdentityProfileService {
124
124
  /**
125
125
  * Delete the profile for an identity.
126
126
  * @param identity The identity to perform the profile operation on.
127
- * @returns Nothing.
127
+ * @returns A promise that resolves when the profile has been removed.
128
128
  */
129
129
  async remove(identity) {
130
130
  Guards.stringValue(IdentityProfileService.CLASS_NAME, "identity", identity);
@@ -1 +1 @@
1
- {"version":3,"file":"identityProfileService.js","sourceRoot":"","sources":["../../src/identityProfileService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpF,OAAO,EACN,+BAA+B,EAG/B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAIlC;;OAEG;IAC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,CAAC,QAAQ,CAAC,CAAC;QACvD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,sBAAsB,CAAC,UAAU,CAAC,EAAE,CAAC;gBACxE,MAAM,KAAK,CAAC;YACb,CAAC;YACD,MAAM,IAAI,YAAY,CACrB,sBAAsB,CAAC,UAAU,EACjC,cAAc,EACd,EAAE,QAAQ,EAAE,EACZ,KAAK,CACL,CAAC;QACH,CAAC;IACF,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,IAAI,CAChB,aAGG,EACH,mBAAiC,EACjC,MAAe,EACf,KAAc;QAWd,IAAI,CAAC;YACJ,iEAAiE;YACjE,gDAAgD;YAChD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,IAAI,CACvD,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,SAAS,EACT,MAAM,EACN,KAAK,CACL,CAAC;YACF,OAAO,MAAM,CAAC;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,YAAY,CAAC,sBAAsB,CAAC,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QAC3F,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseError, GeneralError, Guards, Is, NotFoundError } from \"@twin.org/core\";\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\nimport {\n\tIdentityProfileConnectorFactory,\n\ttype IIdentityProfileComponent,\n\ttype IIdentityProfileConnector\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { IdentityService } from \"./identityService.js\";\nimport type { IIdentityProfileServiceConstructorOptions } from \"./models/IIdentityProfileServiceConstructorOptions.js\";\n\n/**\n * Class which implements the identity profile contract.\n */\nexport class IdentityProfileService<\n\tT extends IJsonLdDocument = IJsonLdDocument,\n\tU extends IJsonLdDocument = IJsonLdDocument\n> implements IIdentityProfileComponent<T, U> {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityProfileService>();\n\n\t/**\n\t * The identity profile connector.\n\t * @internal\n\t */\n\tprivate readonly _identityProfileConnector: IIdentityProfileConnector<T, U>;\n\n\t/**\n\t * Create a new instance of IdentityProfileService.\n\t * @param options The dependencies for the identity profile service.\n\t */\n\tconstructor(options?: IIdentityProfileServiceConstructorOptions) {\n\t\tthis._identityProfileConnector = IdentityProfileConnectorFactory.get<\n\t\t\tIIdentityProfileConnector<T, U>\n\t\t>(options?.profileEntityConnectorType ?? \"identity-profile\");\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 IdentityService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create the profile properties for an identity.\n\t * @param publicProfile The public profile data as JSON-LD.\n\t * @param privateProfile The private profile data as JSON-LD.\n\t * @param identity The identity to perform the profile operation on.\n\t * @returns Nothing.\n\t */\n\tpublic async create(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tawait this._identityProfileConnector.create(identity, publicProfile, privateProfile);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.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 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 identity The identity to perform the profile operation on.\n\t * @returns The items identity and the properties.\n\t */\n\tpublic async get(\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[],\n\t\tidentity?: string\n\t): Promise<{\n\t\tidentity: string;\n\t\tpublicProfile?: Partial<T>;\n\t\tprivateProfile?: Partial<U>;\n\t}> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(\n\t\t\t\tidentity,\n\t\t\t\tpublicPropertyNames,\n\t\t\t\tprivatePropertyNames\n\t\t\t);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tidentity,\n\t\t\t\tpublicProfile: result.publicProfile,\n\t\t\t\tprivateProfile: result.privateProfile\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(IdentityProfileService.CLASS_NAME, \"getFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Get the public profile properties for an identity.\n\t * @param identity The identity to perform the profile operation on.\n\t * @param propertyNames The properties to get for the item, defaults to all.\n\t * @returns The items properties.\n\t */\n\tpublic async getPublic(identity: string, propertyNames?: (keyof T)[]): Promise<Partial<T>> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(identity, propertyNames);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\treturn result.publicProfile;\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.CLASS_NAME,\n\t\t\t\t\"getPublicFailed\",\n\t\t\t\tundefined,\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 publicProfile The public profile data as JSON-LD.\n\t * @param privateProfile The private profile data as JSON-LD.\n\t * @param identity The identity to perform the profile operation on.\n\t * @returns Nothing.\n\t */\n\tpublic async update(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(identity);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\tawait this._identityProfileConnector.update(identity, publicProfile, privateProfile);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.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 perform the profile operation on.\n\t * @returns Nothing.\n\t */\n\tpublic async remove(identity?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(identity);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\tawait this._identityProfileConnector.remove(identity);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.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 publicPropertyNames The public 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\tpublicPropertyNames?: (keyof T)[],\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: { identity: string; publicProfile?: Partial<T>; privateProfile?: Partial<U> }[];\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\t// We don't want to return private profile for this type of query\n\t\t\t// as it would expose the values to the REST api\n\t\t\tconst result = await this._identityProfileConnector.list(\n\t\t\t\tpublicFilters,\n\t\t\t\tundefined,\n\t\t\t\tpublicPropertyNames,\n\t\t\t\tundefined,\n\t\t\t\tcursor,\n\t\t\t\tlimit\n\t\t\t);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(IdentityProfileService.CLASS_NAME, \"listFailed\", undefined, error);\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"identityProfileService.js","sourceRoot":"","sources":["../../src/identityProfileService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpF,OAAO,EACN,+BAA+B,EAG/B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD;;GAE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C;YACD,MAAM,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACvD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,sBAAsB,CAAC,UAAU,CAAC,EAAE,CAAC;gBACxE,MAAM,KAAK,CAAC;YACb,CAAC;YACD,MAAM,IAAI,YAAY,CACrB,sBAAsB,CAAC,UAAU,EACjC,cAAc,EACd,EAAE,QAAQ,EAAE,EACZ,KAAK,CACL,CAAC;QACH,CAAC;IACF,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,IAAI,CAChB,aAGG,EACH,mBAAiC,EACjC,MAAe,EACf,KAAc;QAWd,IAAI,CAAC;YACJ,iEAAiE;YACjE,gDAAgD;YAChD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,IAAI,CACvD,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,SAAS,EACT,MAAM,EACN,KAAK,CACL,CAAC;YACF,OAAO,MAAM,CAAC;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,YAAY,CAAC,sBAAsB,CAAC,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QAC3F,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseError, GeneralError, Guards, Is, NotFoundError } from \"@twin.org/core\";\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\nimport {\n\tIdentityProfileConnectorFactory,\n\ttype IIdentityProfileComponent,\n\ttype IIdentityProfileConnector\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { IdentityService } from \"./identityService.js\";\nimport type { IIdentityProfileServiceConstructorOptions } from \"./models/IIdentityProfileServiceConstructorOptions.js\";\n\n/**\n * Class which implements the identity profile contract.\n */\nexport class IdentityProfileService<\n\tT extends IJsonLdDocument = IJsonLdDocument,\n\tU extends IJsonLdDocument = IJsonLdDocument\n> implements IIdentityProfileComponent<T, U> {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityProfileService>();\n\n\t/**\n\t * The identity profile connector.\n\t * @internal\n\t */\n\tprivate readonly _identityProfileConnector: IIdentityProfileConnector<T, U>;\n\n\t/**\n\t * Create a new instance of IdentityProfileService.\n\t * @param options The dependencies for the identity profile service.\n\t */\n\tconstructor(options?: IIdentityProfileServiceConstructorOptions) {\n\t\tthis._identityProfileConnector = IdentityProfileConnectorFactory.get<\n\t\t\tIIdentityProfileConnector<T, U>\n\t\t>(options?.profileEntityConnectorType ?? \"identity-profile\");\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 IdentityService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create the profile properties for an identity.\n\t * @param publicProfile The public profile data as JSON-LD.\n\t * @param privateProfile The private profile data as JSON-LD.\n\t * @param identity The identity to perform the profile operation on.\n\t * @returns A promise that resolves when the profile has been created.\n\t */\n\tpublic async create(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tawait this._identityProfileConnector.create(identity, publicProfile, privateProfile);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.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 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 identity The identity to perform the profile operation on.\n\t * @returns The items identity and the properties.\n\t */\n\tpublic async get(\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[],\n\t\tidentity?: string\n\t): Promise<{\n\t\tidentity: string;\n\t\tpublicProfile?: Partial<T>;\n\t\tprivateProfile?: Partial<U>;\n\t}> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(\n\t\t\t\tidentity,\n\t\t\t\tpublicPropertyNames,\n\t\t\t\tprivatePropertyNames\n\t\t\t);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tidentity,\n\t\t\t\tpublicProfile: result.publicProfile,\n\t\t\t\tprivateProfile: result.privateProfile\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(IdentityProfileService.CLASS_NAME, \"getFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Get the public profile properties for an identity.\n\t * @param identity The identity to perform the profile operation on.\n\t * @param propertyNames The properties to get for the item, defaults to all.\n\t * @returns The items properties.\n\t */\n\tpublic async getPublic(identity: string, propertyNames?: (keyof T)[]): Promise<Partial<T>> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(identity, propertyNames);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\treturn result.publicProfile;\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.CLASS_NAME,\n\t\t\t\t\"getPublicFailed\",\n\t\t\t\tundefined,\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 publicProfile The public profile data as JSON-LD.\n\t * @param privateProfile The private profile data as JSON-LD.\n\t * @param identity The identity to perform the profile operation on.\n\t * @returns A promise that resolves when the profile has been updated.\n\t */\n\tpublic async update(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(identity);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\tawait this._identityProfileConnector.update(identity, publicProfile, privateProfile);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.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 perform the profile operation on.\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(IdentityProfileService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst result = await this._identityProfileConnector.get(identity);\n\t\t\tif (Is.undefined(result)) {\n\t\t\t\tthrow new NotFoundError(IdentityProfileService.CLASS_NAME, \"notFound\", identity);\n\t\t\t}\n\t\t\tawait this._identityProfileConnector.remove(identity);\n\t\t} catch (error) {\n\t\t\tif (BaseError.someErrorClass(error, IdentityProfileService.CLASS_NAME)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityProfileService.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 publicPropertyNames The public 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\tpublicPropertyNames?: (keyof T)[],\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: { identity: string; publicProfile?: Partial<T>; privateProfile?: Partial<U> }[];\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\t// We don't want to return private profile for this type of query\n\t\t\t// as it would expose the values to the REST api\n\t\t\tconst result = await this._identityProfileConnector.list(\n\t\t\t\tpublicFilters,\n\t\t\t\tundefined,\n\t\t\t\tpublicPropertyNames,\n\t\t\t\tundefined,\n\t\t\t\tcursor,\n\t\t\t\tlimit\n\t\t\t);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(IdentityProfileService.CLASS_NAME, \"listFailed\", undefined, error);\n\t\t}\n\t}\n}\n"]}
@@ -14,7 +14,7 @@ export const tagsIdentityResolver = [
14
14
  }
15
15
  ];
16
16
  /**
17
- * The REST routes for identity.
17
+ * The REST routes for identity resolution.
18
18
  * @param baseRouteName Prefix to prepend to the paths.
19
19
  * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
20
20
  * @returns The generated routes.
@@ -1 +1 @@
1
- {"version":3,"file":"identityResolverRo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CACrE;iCACD;6BACD;yBACD;qBACD;iBACD;aACD;SACD;KACD,CAAC;IAEF,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAC/B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACpC,kBAAuC,EACvC,aAAqB,EACrB,OAAgC;IAEhC,MAAM,CAAC,MAAM,CAA0B,aAAa,aAAmB,OAAO,CAAC,CAAC;IAChF,MAAM,CAAC,MAAM,CACZ,aAAa,wBAEb,OAAO,CAAC,UAAU,CAClB,CAAC;IACF,MAAM,CAAC,WAAW,CACjB,aAAa,iCAEb,OAAO,CAAC,UAAU,CAAC,QAAQ,CAC3B,CAAC;IAEF,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAA6B,aAAa,CAAC,CAAC;IAElF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,eAAe,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAE5E,OAAO;QACN,IAAI,EAAE,MAAM;KACZ,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IHttpRequestContext, IRestRoute, ITag } from \"@twin.org/api-models\";\nimport { ComponentFactory, Guards } from \"@twin.org/core\";\nimport type {\n\tIIdentityResolverComponent,\n\tIIdentityResolveRequest,\n\tIIdentityResolveResponse\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { DidContexts } from \"@twin.org/standards-w3c-did\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"identityResolverRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsIdentityResolver: ITag[] = [\n\t{\n\t\tname: \"Identity\",\n\t\tdescription: \"Service to provide all features related to digital identity.\"\n\t}\n];\n\n/**\n * The REST routes for identity.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesIdentityResolver(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst identityResolveRoute: IRestRoute<IIdentityResolveRequest, IIdentityResolveResponse> = {\n\t\toperationId: \"identityResolve\",\n\t\tsummary: \"Resolve an identity\",\n\t\ttag: tagsIdentityResolver[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/:identity`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tidentityResolve(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IIdentityResolveRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"identityResolveRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tidentity:\n\t\t\t\t\t\t\t\t\"did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a\"\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},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IIdentityResolveResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"identityResolveResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": DidContexts.Context,\n\t\t\t\t\t\t\t\tid: \"did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a\",\n\t\t\t\t\t\t\t\tservice: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: \"did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a#revocation\",\n\t\t\t\t\t\t\t\t\t\ttype: \"RevocationBitmap2022\",\n\t\t\t\t\t\t\t\t\t\tserviceEndpoint: \"data:application/octet-stream;base64,eJyzMmAAAwABr\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [identityResolveRoute];\n}\n\n/**\n * Resolve an identity.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function identityResolve(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IIdentityResolveRequest\n): Promise<IIdentityResolveResponse> {\n\tGuards.object<IIdentityResolveRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IIdentityResolveRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams.identity),\n\t\trequest.pathParams.identity\n\t);\n\n\tconst component = ComponentFactory.get<IIdentityResolverComponent>(componentName);\n\n\tconst result = await component.identityResolve(request.pathParams.identity);\n\n\treturn {\n\t\tbody: result\n\t};\n}\n"]}
1
+ {"version":3,"file":"identityResolverRoutes.js","sourceRoot":"","sources":["../../src/identityResolverRoutes.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAO1D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D;;GAEG;AACH,MAAM,aAAa,GAAG,wBAAwB,CAAC;AAE/C;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAW;IAC3C;QACC,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,8DAA8D;KAC3E;CACD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,kCAAkC,CACjD,aAAqB,EACrB,aAAqB;IAErB,MAAM,oBAAoB,GA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GAAG,gBAAgB,CAAC,GAAG,CAA6B,aAAa,CAAC,CAAC;IAElF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,eAAe,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAE5E,OAAO;QACN,IAAI,EAAE,MAAM;KACZ,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IHttpRequestContext, IRestRoute, ITag } from \"@twin.org/api-models\";\nimport { ComponentFactory, Guards } from \"@twin.org/core\";\nimport type {\n\tIIdentityResolverComponent,\n\tIIdentityResolveRequest,\n\tIIdentityResolveResponse\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { DidContexts } from \"@twin.org/standards-w3c-did\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"identityResolverRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsIdentityResolver: ITag[] = [\n\t{\n\t\tname: \"Identity\",\n\t\tdescription: \"Service to provide all features related to digital identity.\"\n\t}\n];\n\n/**\n * The REST routes for identity resolution.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesIdentityResolver(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst identityResolveRoute: IRestRoute<IIdentityResolveRequest, IIdentityResolveResponse> = {\n\t\toperationId: \"identityResolve\",\n\t\tsummary: \"Resolve an identity\",\n\t\ttag: tagsIdentityResolver[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/:identity`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tidentityResolve(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IIdentityResolveRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"identityResolveRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tidentity:\n\t\t\t\t\t\t\t\t\"did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a\"\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},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IIdentityResolveResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"identityResolveResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": DidContexts.Context,\n\t\t\t\t\t\t\t\tid: \"did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a\",\n\t\t\t\t\t\t\t\tservice: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: \"did:iota:tst:0xe3088ba9aa8c28e1d139708a14e8c0fdff11ee8223baac4aa5bcf3321e4bfc6a#revocation\",\n\t\t\t\t\t\t\t\t\t\ttype: \"RevocationBitmap2022\",\n\t\t\t\t\t\t\t\t\t\tserviceEndpoint: \"data:application/octet-stream;base64,eJyzMmAAAwABr\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [identityResolveRoute];\n}\n\n/**\n * Resolve an identity.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function identityResolve(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IIdentityResolveRequest\n): Promise<IIdentityResolveResponse> {\n\tGuards.object<IIdentityResolveRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IIdentityResolveRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams.identity),\n\t\trequest.pathParams.identity\n\t);\n\n\tconst component = ComponentFactory.get<IIdentityResolverComponent>(componentName);\n\n\tconst result = await component.identityResolve(request.pathParams.identity);\n\n\treturn {\n\t\tbody: result\n\t};\n}\n"]}
@@ -62,6 +62,7 @@ export class IdentityResolverService {
62
62
  * Get the connector from the namespace.
63
63
  * @param namespace The namespace for the identity.
64
64
  * @returns The connector.
65
+ * @throws GeneralError if the connector is not found.
65
66
  * @internal
66
67
  */
67
68
  getConnectorByNamespace(namespace) {
@@ -82,6 +83,7 @@ export class IdentityResolverService {
82
83
  * Get the connector from the uri.
83
84
  * @param id The id of the identity in urn format.
84
85
  * @returns The connector.
86
+ * @throws GeneralError if the namespace does not match or the connector is not found.
85
87
  * @internal
86
88
  */
87
89
  getConnectorByUri(id) {
@@ -1 +1 @@
1
- {"version":3,"file":"identityResolverService.js","sourceRoot":"","sources":["../../src/identityResolverService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EACN,gCAAgC,EAGhC,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD;;GAEG;AACH,MAAM,OAAO,uBAAuB;IACnC;;OAEG;IACI,MAAM,CAAU,UAAU,6BAA6C;IAE9E;;;OAGG;IACc,iBAAiB,CAAS;IAE3C;;;OAGG;IACc,8BAA8B,CAAS;IAExD;;;OAGG;IACH,YAAY,OAAoD;QAC/D,MAAM,KAAK,GAAG,gCAAgC,CAAC,KAAK,EAAE,CAAC;QACvD,IAAI,KAAK,CAA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CAAC,SAAS,CAAC,EAAE,CAAC;gBACzB,MAAM,IAAI,YAAY,CAAC,uBAAuB,CAAC,UAAU,EAAE,mBAAmB,EAAE;oBAC/E,SAAS,EAAE,eAAe;iBAC1B,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACK,iBAAiB,CAAC,EAAU;QACnC,MAAM,KAAK,GAAG,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAEtC,IAAI,KAAK,CAAC,mBAAmB,EAAE,KAAK,KAAK,EAAE,CAAC;YAC3C,MAAM,IAAI,YAAY,CAAC,uBAAuB,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBAC/E,SAAS,EAAE,KAAK;gBAChB,EAAE;aACF,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC;IAC9D,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { GeneralError, Is, Urn } from \"@twin.org/core\";\nimport {\n\tIdentityResolverConnectorFactory,\n\ttype IIdentityResolverComponent,\n\ttype IIdentityResolverConnector\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IDidDocument } from \"@twin.org/standards-w3c-did\";\nimport { IdentityService } from \"./identityService.js\";\nimport type { IIdentityResolverServiceConstructorOptions } from \"./models/IIdentityResolverServiceConstructorOptions.js\";\n\n/**\n * Class which implements the identity resolver contract.\n */\nexport class IdentityResolverService implements IIdentityResolverComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityResolverService>();\n\n\t/**\n\t * The default namespace for the connector to use.\n\t * @internal\n\t */\n\tprivate readonly _defaultNamespace: string;\n\n\t/**\n\t * Fallback connector type to use if the namespace connector is not available.\n\t * @internal\n\t */\n\tprivate readonly _fallbackResolverConnectorType: string;\n\n\t/**\n\t * Create a new instance of IdentityResolverService.\n\t * @param options The options for the service.\n\t */\n\tconstructor(options?: IIdentityResolverServiceConstructorOptions) {\n\t\tconst names = IdentityResolverConnectorFactory.names();\n\t\tif (names.length === 0) {\n\t\t\tthrow new GeneralError(IdentityResolverService.CLASS_NAME, \"noConnectors\");\n\t\t}\n\n\t\tthis._defaultNamespace = options?.config?.defaultNamespace ?? names[0];\n\t\tthis._fallbackResolverConnectorType = options?.fallbackResolverConnectorType ?? \"universal\";\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 IdentityService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Resolve an identity.\n\t * @param identity The id of the document to resolve.\n\t * @returns The resolved document.\n\t */\n\tpublic async identityResolve(identity: string): Promise<IDidDocument> {\n\t\tUrn.guard(IdentityResolverService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst identityResolverConnector = this.getConnectorByUri(identity);\n\t\t\tconst document = await identityResolverConnector.resolveDocument(identity);\n\n\t\t\treturn document;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityResolverService.CLASS_NAME,\n\t\t\t\t\"identityResolveFailed\",\n\t\t\t\t{\n\t\t\t\t\tidentity\n\t\t\t\t},\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the connector from the namespace.\n\t * @param namespace The namespace for the identity.\n\t * @returns The connector.\n\t * @internal\n\t */\n\tprivate getConnectorByNamespace(namespace?: string): IIdentityResolverConnector {\n\t\tconst namespaceMethod = namespace ?? this._defaultNamespace;\n\n\t\tlet connector =\n\t\t\tIdentityResolverConnectorFactory.getIfExists<IIdentityResolverConnector>(namespaceMethod);\n\n\t\tif (Is.empty(connector)) {\n\t\t\t// Let's see if a fallback 'universal' connector is registered\n\t\t\tconnector = IdentityResolverConnectorFactory.getIfExists<IIdentityResolverConnector>(\n\t\t\t\tthis._fallbackResolverConnectorType\n\t\t\t);\n\t\t\tif (Is.empty(connector)) {\n\t\t\t\tthrow new GeneralError(IdentityResolverService.CLASS_NAME, \"connectorNotFound\", {\n\t\t\t\t\tnamespace: namespaceMethod\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn connector;\n\t}\n\n\t/**\n\t * Get the connector from the uri.\n\t * @param id The id of the identity in urn format.\n\t * @returns The connector.\n\t * @internal\n\t */\n\tprivate getConnectorByUri(id: string): IIdentityResolverConnector {\n\t\tconst idUri = Urn.fromValidString(id);\n\n\t\tif (idUri.namespaceIdentifier() !== \"did\") {\n\t\t\tthrow new GeneralError(IdentityResolverService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: \"did\",\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\treturn this.getConnectorByNamespace(idUri.namespaceMethod());\n\t}\n}\n"]}
1
+ {"version":3,"file":"identityResolverService.js","sourceRoot":"","sources":["../../src/identityResolverService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EACN,gCAAgC,EAGhC,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD;;GAEG;AACH,MAAM,OAAO,uBAAuB;IACnC;;OAEG;IACI,MAAM,CAAU,UAAU,6BAA6C;IAE9E;;;OAGG;IACc,iBAAiB,CAAS;IAE3C;;;OAGG;IACc,8BAA8B,CAAS;IAExD;;;OAGG;IACH,YAAY,OAAoD;QAC/D,MAAM,KAAK,GAAG,gCAAgC,CAAC,KAAK,EAAE,CAAC;QACvD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,YAAY,CAAC,uBAAuB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QAC5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SAAS,EAAE,eAAe;iBAC1B,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;IAED;;;;;;OAMG;IACK,iBAAiB,CAAC,EAAU;QACnC,MAAM,KAAK,GAAG,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAEtC,IAAI,KAAK,CAAC,mBAAmB,EAAE,KAAK,KAAK,EAAE,CAAC;YAC3C,MAAM,IAAI,YAAY,CAAC,uBAAuB,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBAC/E,SAAS,EAAE,KAAK;gBAChB,EAAE;aACF,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC;IAC9D,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { GeneralError, Is, Urn } from \"@twin.org/core\";\nimport {\n\tIdentityResolverConnectorFactory,\n\ttype IIdentityResolverComponent,\n\ttype IIdentityResolverConnector\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IDidDocument } from \"@twin.org/standards-w3c-did\";\nimport { IdentityService } from \"./identityService.js\";\nimport type { IIdentityResolverServiceConstructorOptions } from \"./models/IIdentityResolverServiceConstructorOptions.js\";\n\n/**\n * Class which implements the identity resolver contract.\n */\nexport class IdentityResolverService implements IIdentityResolverComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityResolverService>();\n\n\t/**\n\t * The default namespace for the connector to use.\n\t * @internal\n\t */\n\tprivate readonly _defaultNamespace: string;\n\n\t/**\n\t * Fallback connector type to use if the namespace connector is not available.\n\t * @internal\n\t */\n\tprivate readonly _fallbackResolverConnectorType: string;\n\n\t/**\n\t * Create a new instance of IdentityResolverService.\n\t * @param options The options for the service.\n\t */\n\tconstructor(options?: IIdentityResolverServiceConstructorOptions) {\n\t\tconst names = IdentityResolverConnectorFactory.names();\n\t\tif (names.length === 0) {\n\t\t\tthrow new GeneralError(IdentityResolverService.CLASS_NAME, \"noConnectors\");\n\t\t}\n\n\t\tthis._defaultNamespace = options?.config?.defaultNamespace ?? names[0];\n\t\tthis._fallbackResolverConnectorType = options?.fallbackResolverConnectorType ?? \"universal\";\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 IdentityService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Resolve an identity.\n\t * @param identity The id of the document to resolve.\n\t * @returns The resolved document.\n\t */\n\tpublic async identityResolve(identity: string): Promise<IDidDocument> {\n\t\tUrn.guard(IdentityResolverService.CLASS_NAME, nameof(identity), identity);\n\n\t\ttry {\n\t\t\tconst identityResolverConnector = this.getConnectorByUri(identity);\n\t\t\tconst document = await identityResolverConnector.resolveDocument(identity);\n\n\t\t\treturn document;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityResolverService.CLASS_NAME,\n\t\t\t\t\"identityResolveFailed\",\n\t\t\t\t{\n\t\t\t\t\tidentity\n\t\t\t\t},\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get the connector from the namespace.\n\t * @param namespace The namespace for the identity.\n\t * @returns The connector.\n\t * @throws GeneralError if the connector is not found.\n\t * @internal\n\t */\n\tprivate getConnectorByNamespace(namespace?: string): IIdentityResolverConnector {\n\t\tconst namespaceMethod = namespace ?? this._defaultNamespace;\n\n\t\tlet connector =\n\t\t\tIdentityResolverConnectorFactory.getIfExists<IIdentityResolverConnector>(namespaceMethod);\n\n\t\tif (Is.empty(connector)) {\n\t\t\t// Let's see if a fallback 'universal' connector is registered\n\t\t\tconnector = IdentityResolverConnectorFactory.getIfExists<IIdentityResolverConnector>(\n\t\t\t\tthis._fallbackResolverConnectorType\n\t\t\t);\n\t\t\tif (Is.empty(connector)) {\n\t\t\t\tthrow new GeneralError(IdentityResolverService.CLASS_NAME, \"connectorNotFound\", {\n\t\t\t\t\tnamespace: namespaceMethod\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn connector;\n\t}\n\n\t/**\n\t * Get the connector from the uri.\n\t * @param id The id of the identity in urn format.\n\t * @returns The connector.\n\t * @throws GeneralError if the namespace does not match or the connector is not found.\n\t * @internal\n\t */\n\tprivate getConnectorByUri(id: string): IIdentityResolverConnector {\n\t\tconst idUri = Urn.fromValidString(id);\n\n\t\tif (idUri.namespaceIdentifier() !== \"did\") {\n\t\t\tthrow new GeneralError(IdentityResolverService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: \"did\",\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\treturn this.getConnectorByNamespace(idUri.namespaceMethod());\n\t}\n}\n"]}
@@ -44,6 +44,7 @@ export class IdentityService {
44
44
  }
45
45
  /**
46
46
  * Register all identity metrics with the telemetry component.
47
+ * @returns A promise that resolves when all metrics have been registered.
47
48
  */
48
49
  async start() {
49
50
  if (Is.undefined(this._telemetryComponent)) {
@@ -75,7 +76,7 @@ export class IdentityService {
75
76
  * Remove an identity.
76
77
  * @param identity The id of the document to remove.
77
78
  * @param controller The controller of the identity who can make changes.
78
- * @returns Nothing.
79
+ * @returns A promise that resolves when the identity has been removed.
79
80
  */
80
81
  async identityRemove(identity, controller) {
81
82
  Guards.stringValue(IdentityService.CLASS_NAME, "identity", identity);
@@ -117,7 +118,7 @@ export class IdentityService {
117
118
  * Remove a verification method from the document.
118
119
  * @param verificationMethodId The id of the verification method.
119
120
  * @param controller The controller of the identity who can make changes.
120
- * @returns Nothing.
121
+ * @returns A promise that resolves when the verification method has been removed.
121
122
  * @throws NotFoundError if the id can not be resolved.
122
123
  * @throws NotSupportedError if the platform does not support multiple revocable keys.
123
124
  */
@@ -172,7 +173,7 @@ export class IdentityService {
172
173
  * Remove a service from the document.
173
174
  * @param serviceId The id of the service.
174
175
  * @param controller The controller of the identity who can make changes.
175
- * @returns Nothing.
176
+ * @returns A promise that resolves when the service has been removed.
176
177
  * @throws NotFoundError if the id can not be resolved.
177
178
  */
178
179
  async serviceRemove(serviceId, controller) {
@@ -193,7 +194,7 @@ export class IdentityService {
193
194
  * @param documentId The id of the document to update.
194
195
  * @param alias The alias to add. Must be a Url or Urn (typically another DID).
195
196
  * @param controller The controller of the identity who can make changes.
196
- * @returns Nothing.
197
+ * @returns A promise that resolves when the alias has been added.
197
198
  * @throws GeneralError if the alias is not a Url or Urn.
198
199
  * @throws NotFoundError if the id can not be resolved.
199
200
  */
@@ -216,7 +217,7 @@ export class IdentityService {
216
217
  * @param documentId The id of the document to update.
217
218
  * @param alias The alias to remove. Must be a Url or Urn.
218
219
  * @param controller The controller of the identity who can make changes.
219
- * @returns Nothing.
220
+ * @returns A promise that resolves when the alias has been removed.
220
221
  * @throws GeneralError if the alias is not a Url or Urn.
221
222
  * @throws NotFoundError if the id can not be resolved.
222
223
  */
@@ -319,9 +320,9 @@ export class IdentityService {
319
320
  /**
320
321
  * Revoke verifiable credential.
321
322
  * @param issuerIdentity The id of the document to update the revocation list for.
322
- * @param credentialIndex The revocation bitmap index revoke.
323
+ * @param credentialIndex The revocation bitmap index to revoke.
323
324
  * @param controller The controller of the identity who can make changes.
324
- * @returns Nothing.
325
+ * @returns A promise that resolves when the credential has been revoked.
325
326
  */
326
327
  async verifiableCredentialRevoke(issuerIdentity, credentialIndex, controller) {
327
328
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
@@ -343,7 +344,7 @@ export class IdentityService {
343
344
  * @param issuerIdentity The id of the document to update the revocation list for.
344
345
  * @param credentialIndex The revocation bitmap index to un revoke.
345
346
  * @param controller The controller of the identity who can make changes.
346
- * @returns Nothing.
347
+ * @returns A promise that resolves when the credential has been unrevoked.
347
348
  */
348
349
  async verifiableCredentialUnrevoke(issuerIdentity, credentialIndex, controller) {
349
350
  Guards.stringValue(IdentityService.CLASS_NAME, "controller", controller);
@@ -478,6 +479,7 @@ export class IdentityService {
478
479
  * Get the connector from the namespace.
479
480
  * @param namespace The namespace for the identity.
480
481
  * @returns The connector.
482
+ * @throws GeneralError if the connector is not found.
481
483
  * @internal
482
484
  */
483
485
  getConnectorByNamespace(namespace) {
@@ -494,6 +496,7 @@ export class IdentityService {
494
496
  * Get the connector from the uri.
495
497
  * @param id The id of the identity in urn format.
496
498
  * @returns The connector.
499
+ * @throws GeneralError if the namespace does not match or the connector is not found.
497
500
  * @internal
498
501
  */
499
502
  getConnectorByUri(id) {
@@ -1 +1 @@
1
- {"version":3,"file":"identityService.js","sourceRoot":"","sources":["../../src/identityService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAEjF,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAGf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,yBAAyB,EACzB,UAAU,EAOV,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,YAAY,EAA4B,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC;;GAEG;AACH,MAAM,OAAO,eAAe;IAC3B;;OAEG;IACI,MAAM,CAAU,UAAU,qBAAqC;IAEtE;;;OAGG;IACc,iBAAiB,CAAS;IAE3C;;;OAGG;IACc,mBAAmB,CAAuB;IAE3D;;;OAGG;IACH,YAAY,OAA4C;QACvD,MAAM,KAAK,GAAG,wBAAwB,CAAC,KAAK,EAAE,CAAC;QAC/C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,YAAY,CAAC,eAAe,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QACpE,CAAC;QAED,IAAI,CAAC,iBAAiB,GAAG,OAAO,EAAE,MAAM,EAA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;IACF,CAAC;IAED;;;;;OAKG;IACK,uBAAuB,CAAC,SAAkB;QACjD,MAAM,eAAe,GAAG,SAAS,IAAI,IAAI,CAAC,iBAAiB,CAAC;QAE5D,MAAM,SAAS,GAAG,wBAAwB,CAAC,WAAW,CAAqB,eAAe,CAAC,CAAC;QAE5F,IAAI,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,YAAY,CAAC,eAAe,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBACvE,SAAS,EAAE,eAAe;aAC1B,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACK,iBAAiB,CAAC,EAAU;QACnC,MAAM,KAAK,GAAG,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAEtC,IAAI,KAAK,CAAC,mBAAmB,EAAE,KAAK,KAAK,EAAE,CAAC;YAC3C,MAAM,IAAI,YAAY,CAAC,eAAe,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBACvE,SAAS,EAAE,KAAK;gBAChB,EAAE;aACF,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC;IAC9D,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, GeneralError, Guards, Is, Urn } from \"@twin.org/core\";\nimport type { IJsonLdContextDefinitionRoot, IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport {\n\tDocumentHelper,\n\tIdentityConnectorFactory,\n\tIdentityMetricIds,\n\tIdentityMetrics,\n\ttype IIdentityComponent,\n\ttype IIdentityConnector\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDidVerificationMethodType,\n\tProofTypes,\n\ttype IDidDocument,\n\ttype IDidDocumentVerificationMethod,\n\ttype IProof,\n\ttype IDidService,\n\ttype IDidVerifiableCredential,\n\ttype IDidVerifiablePresentation\n} from \"@twin.org/standards-w3c-did\";\nimport { MetricHelper, type ITelemetryComponent } from \"@twin.org/telemetry-models\";\nimport { Jwt } from \"@twin.org/web\";\nimport type { IIdentityServiceConstructorOptions } from \"./models/IIdentityServiceConstructorOptions.js\";\n\n/**\n * Class which implements the identity contract.\n */\nexport class IdentityService implements IIdentityComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityService>();\n\n\t/**\n\t * The default namespace for the connector to use.\n\t * @internal\n\t */\n\tprivate readonly _defaultNamespace: string;\n\n\t/**\n\t * The telemetry component.\n\t * @internal\n\t */\n\tprivate readonly _telemetryComponent?: ITelemetryComponent;\n\n\t/**\n\t * Create a new instance of IdentityService.\n\t * @param options The options for the service.\n\t */\n\tconstructor(options?: IIdentityServiceConstructorOptions) {\n\t\tconst names = IdentityConnectorFactory.names();\n\t\tif (names.length === 0) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"noConnectors\");\n\t\t}\n\n\t\tthis._defaultNamespace = options?.config?.defaultNamespace ?? names[0];\n\n\t\tthis._telemetryComponent = ComponentFactory.getIfExists<ITelemetryComponent>(\n\t\t\toptions?.telemetryComponentType\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 IdentityService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Register all identity metrics with the telemetry component.\n\t */\n\tpublic async start(): Promise<void> {\n\t\tif (Is.undefined(this._telemetryComponent)) {\n\t\t\treturn;\n\t\t}\n\n\t\tawait MetricHelper.createMetrics(this._telemetryComponent, IdentityMetrics);\n\t}\n\n\t/**\n\t * Create a new identity.\n\t * @param namespace The namespace of the connector to use for the identity, defaults to service configured namespace.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns The created identity document.\n\t */\n\tpublic async identityCreate(namespace?: string, controller?: string): Promise<IDidDocument> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByNamespace(namespace);\n\t\t\tconst result = await identityConnector.createDocument(controller);\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.DidsCreated, {\n\t\t\t\tnamespace: namespace ?? this._defaultNamespace\n\t\t\t});\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"identityCreateFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Remove an identity.\n\t * @param identity The id of the document to remove.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns Nothing.\n\t */\n\tpublic async identityRemove(identity: string, controller?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(identity);\n\t\t\tconst result = await identityConnector.removeDocument(controller, identity);\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.DidsRemoved);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"identityRemoveFailed\",\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 * Add a verification method to the document in JSON Web key Format.\n\t * @param identity 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 * @param controller The controller of the identity who can make changes.\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 verificationMethodCreate(\n\t\tidentity: string,\n\t\tverificationMethodType: DidVerificationMethodType,\n\t\tverificationMethodId?: string,\n\t\tcontroller?: string\n\t): Promise<IDidDocumentVerificationMethod> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(identity), identity);\n\n\t\tGuards.arrayOneOf(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(verificationMethodType),\n\t\t\tverificationMethodType,\n\t\t\tObject.values(DidVerificationMethodType)\n\t\t);\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(identity);\n\n\t\t\tconst verificationMethod = await identityConnector.addVerificationMethod(\n\t\t\t\tcontroller,\n\t\t\t\tidentity,\n\t\t\t\tverificationMethodType,\n\t\t\t\tverificationMethodId\n\t\t\t);\n\n\t\t\treturn verificationMethod;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verificationMethodCreateFailed\",\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 * Remove a verification method from the document.\n\t * @param verificationMethodId The id of the verification method.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns Nothing.\n\t * @throws NotFoundError if the id can not be resolved.\n\t * @throws NotSupportedError if the platform does not support multiple revocable keys.\n\t */\n\tpublic async verificationMethodRemove(\n\t\tverificationMethodId: string,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(verificationMethodId), verificationMethodId);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tawait identityConnector.removeVerificationMethod(controller, verificationMethodId);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verificationMethodRemoveFailed\",\n\t\t\t\t{ verificationMethodId },\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 identity 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 * @param controller The controller of the identity who can make changes.\n\t * @returns The service.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async serviceCreate(\n\t\tidentity: string,\n\t\tserviceId: string,\n\t\tserviceType: string | string[],\n\t\tserviceEndpoint: string | string[],\n\t\tcontroller?: string\n\t): Promise<IDidService> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(serviceId), serviceId);\n\t\tif (Is.array(serviceType)) {\n\t\t\tGuards.arrayValue<string>(IdentityService.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t} else {\n\t\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t}\n\t\tif (Is.array(serviceEndpoint)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tIdentityService.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(IdentityService.CLASS_NAME, nameof(serviceEndpoint), serviceEndpoint);\n\t\t}\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(identity);\n\n\t\t\tconst service = await identityConnector.addService(\n\t\t\t\tcontroller,\n\t\t\t\tidentity,\n\t\t\t\tserviceId,\n\t\t\t\tserviceType,\n\t\t\t\tserviceEndpoint\n\t\t\t);\n\n\t\t\treturn service;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"serviceCreateFailed\",\n\t\t\t\t{ identity, serviceId },\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 serviceId The id of the service.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns Nothing.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async serviceRemove(serviceId: string, controller?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(serviceId), serviceId);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(serviceId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tawait identityConnector.removeService(controller, serviceId);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"serviceRemoveFailed\",\n\t\t\t\t{ serviceId },\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 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 * @param controller The controller of the identity who can make changes.\n\t * @returns Nothing.\n\t * @throws GeneralError if the alias is not a Url or Urn.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async alsoKnownAsAdd(\n\t\tdocumentId: string,\n\t\talias: string,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(alias), alias);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(documentId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tawait identityConnector.addAlsoKnownAs(controller, documentId, alias);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"alsoKnownAsAddFailed\",\n\t\t\t\t{ identity: documentId, alias },\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 documentId The id of the document to update.\n\t * @param alias The alias to remove. Must be a Url or Urn.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns Nothing.\n\t * @throws GeneralError if the alias is not a Url or Urn.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async alsoKnownAsRemove(\n\t\tdocumentId: string,\n\t\talias: string,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(alias), alias);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(documentId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tawait identityConnector.removeAlsoKnownAs(controller, documentId, alias);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"alsoKnownAsRemoveFailed\",\n\t\t\t\t{ identity: documentId, alias },\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 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 include in the JWT header when creating the verifiable credential in jwt format.\n\t * @param options.jwtPayloadFields Additional fields to include in the JWT payload when creating the verifiable credential in jwt format.\n\t * @param controller The controller of the identity who can make changes.\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 verifiableCredentialCreate(\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\tcontroller?: string\n\t): Promise<{\n\t\tverifiableCredential: IDidVerifiableCredential;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(verificationMethodId), verificationMethodId);\n\t\tGuards.object(IdentityService.CLASS_NAME, nameof(subject), subject);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst service = await identityConnector.createVerifiableCredential(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tid,\n\t\t\t\tsubject,\n\t\t\t\toptions\n\t\t\t);\n\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsCreated, {\n\t\t\t\thasRevocation: Is.number(options?.revocationIndex),\n\t\t\t\thasExpiration: Is.date(options?.expirationDate)\n\t\t\t});\n\n\t\t\treturn service;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiableCredentialCreateFailed\",\n\t\t\t\t{ verificationMethodId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Verify 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 verifiableCredentialVerify(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\tIdentityService.CLASS_NAME,\n\t\t\t\tnameof(credential),\n\t\t\t\tcredential\n\t\t\t);\n\t\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(credential.issuer), credential.issuer);\n\t\t\tGuards.objectValue<IDidVerifiableCredential>(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\tnameof(credential.proof),\n\t\t\t\tcredential.proof\n\t\t\t);\n\n\t\t\ttry {\n\t\t\t\tconst identityConnector = this.getConnectorByUri(credential.issuer);\n\n\t\t\t\tconst service = await identityConnector.checkVerifiableCredential(credential);\n\n\t\t\t\tif (service.revoked) {\n\t\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\t\tIdentityMetricIds.VcsVerificationFailed,\n\t\t\t\t\t\t{ failureReason: \"revoked\" }\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\t\tIdentityMetricIds.VcsVerified\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn service;\n\t\t\t} catch (error) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\"verifiableCredentialVerifyFailed\",\n\t\t\t\t\tundefined,\n\t\t\t\t\terror\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(credential), credential);\n\n\t\tconst jwtDecoded = await Jwt.decode(credential);\n\n\t\tconst jwtHeader = jwtDecoded.header;\n\t\tconst jwtPayload = jwtDecoded.payload;\n\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\tif (\n\t\t\tIs.undefined(jwtHeader) ||\n\t\t\tIs.undefined(jwtPayload) ||\n\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\tIs.undefined(jwtSignature)\n\t\t) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"jwtDecodeFailed\");\n\t\t}\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(jwtPayload.iss);\n\n\t\t\tconst service = await identityConnector.checkVerifiableCredential(credential);\n\n\t\t\tif (service.revoked) {\n\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\tIdentityMetricIds.VcsVerificationFailed,\n\t\t\t\t\t{ failureReason: \"revoked\" }\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsVerified);\n\t\t\t}\n\n\t\t\treturn service;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiableCredentialVerifyFailed\",\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.\n\t * @param issuerIdentity The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index revoke.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns Nothing.\n\t */\n\tpublic async verifiableCredentialRevoke(\n\t\tissuerIdentity: string,\n\t\tcredentialIndex: number,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(issuerIdentity), issuerIdentity);\n\t\tGuards.number(IdentityService.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(issuerIdentity);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.revokeVerifiableCredentials(\n\t\t\t\tcontroller,\n\t\t\t\tissuerIdentity,\n\t\t\t\t[credentialIndex]\n\t\t\t);\n\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsRevoked);\n\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiableCredentialRevokeFailed\",\n\t\t\t\t{ issuerIdentity, credentialIndex },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Unrevoke verifiable credential.\n\t * @param issuerIdentity The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index to un revoke.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns Nothing.\n\t */\n\tpublic async verifiableCredentialUnrevoke(\n\t\tissuerIdentity: string,\n\t\tcredentialIndex: number,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(issuerIdentity), issuerIdentity);\n\t\tGuards.number(IdentityService.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(issuerIdentity);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.unrevokeVerifiableCredentials(\n\t\t\t\tcontroller,\n\t\t\t\tissuerIdentity,\n\t\t\t\t[credentialIndex]\n\t\t\t);\n\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsUnrevoked);\n\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiableCredentialUnrevokeFailed\",\n\t\t\t\t{ issuerIdentity, credentialIndex },\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 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 include in the JWT header when creating the verifiable presentation in jwt format.\n\t * @param options.jwtPayloadFields\tAdditional fields to include in the JWT payload when creating the verifiable presentation in jwt format.\n\t * @param controller The controller of the identity who can make changes.\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 verifiablePresentationCreate(\n\t\tverificationMethodId: string,\n\t\tpresentationId: string | undefined,\n\t\tcontexts: IJsonLdContextDefinitionRoot | undefined,\n\t\ttypes: string | string[] | undefined,\n\t\tverifiableCredentials: (string | IDidVerifiableCredential)[],\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\tcontroller?: string\n\t): Promise<{\n\t\tverifiablePresentation: IDidVerifiablePresentation;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tIdentityService.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\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.createVerifiablePresentation(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tpresentationId,\n\t\t\t\tcontexts,\n\t\t\t\ttypes,\n\t\t\t\tverifiableCredentials,\n\t\t\t\toptions\n\t\t\t);\n\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VpsCreated, {\n\t\t\t\tcredentialCount: verifiableCredentials.length\n\t\t\t});\n\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiablePresentationCreateFailed\",\n\t\t\t\t{ verificationMethodId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Verify 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 verifiablePresentationVerify(\n\t\tpresentation: string | IDidVerifiablePresentation\n\t): Promise<{\n\t\trevoked: boolean;\n\t\tverifiablePresentation?: IDidVerifiablePresentation;\n\t\tissuers?: IDidDocument[];\n\t}> {\n\t\tlet holder;\n\t\tif (Is.stringValue(presentation)) {\n\t\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(presentation), presentation);\n\n\t\t\tconst jwtDecoded = await Jwt.decode(presentation);\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 GeneralError(IdentityService.CLASS_NAME, \"jwtDecodeFailed\");\n\t\t\t}\n\n\t\t\tholder = jwtPayload.iss;\n\t\t} else {\n\t\t\tholder = presentation.holder;\n\t\t}\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(holder), holder);\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(holder);\n\n\t\t\tconst service = await identityConnector.checkVerifiablePresentation(presentation);\n\n\t\t\tif (service.revoked) {\n\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\tIdentityMetricIds.VpsVerificationFailed,\n\t\t\t\t\t{ failureReason: \"revoked\" }\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VpsVerified);\n\t\t\t}\n\n\t\t\treturn service;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiablePresentationVerifyFailed\",\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 a document with the specified verification method.\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 controller The controller of the identity who can make changes.\n\t * @returns The proof.\n\t */\n\tpublic async proofCreate(\n\t\tverificationMethodId: string,\n\t\tproofType: ProofTypes,\n\t\tunsecureDocument: IJsonLdNodeObject,\n\t\tcontroller?: string\n\t): Promise<IProof> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.arrayOneOf<ProofTypes>(\n\t\t\tIdentityService.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\tIdentityService.CLASS_NAME,\n\t\t\tnameof(unsecureDocument),\n\t\t\tunsecureDocument\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.createProof(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tproofType,\n\t\t\t\tunsecureDocument\n\t\t\t);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"proofCreateFailed\",\n\t\t\t\t{ verificationMethodId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Verify proof for a document 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 proofVerify(document: IJsonLdNodeObject, proof: IProof): Promise<boolean> {\n\t\tGuards.object<IJsonLdNodeObject>(IdentityService.CLASS_NAME, nameof(document), document);\n\t\tGuards.object<IProof>(IdentityService.CLASS_NAME, nameof(proof), proof);\n\t\tGuards.stringValue(\n\t\t\tIdentityService.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\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.verifyProof(document, proof);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"proofVerifyFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Get the connector from the namespace.\n\t * @param namespace The namespace for the identity.\n\t * @returns The connector.\n\t * @internal\n\t */\n\tprivate getConnectorByNamespace(namespace?: string): IIdentityConnector {\n\t\tconst namespaceMethod = namespace ?? this._defaultNamespace;\n\n\t\tconst connector = IdentityConnectorFactory.getIfExists<IIdentityConnector>(namespaceMethod);\n\n\t\tif (Is.empty(connector)) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"connectorNotFound\", {\n\t\t\t\tnamespace: namespaceMethod\n\t\t\t});\n\t\t}\n\n\t\treturn connector;\n\t}\n\n\t/**\n\t * Get the connector from the uri.\n\t * @param id The id of the identity in urn format.\n\t * @returns The connector.\n\t * @internal\n\t */\n\tprivate getConnectorByUri(id: string): IIdentityConnector {\n\t\tconst idUri = Urn.fromValidString(id);\n\n\t\tif (idUri.namespaceIdentifier() !== \"did\") {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: \"did\",\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\treturn this.getConnectorByNamespace(idUri.namespaceMethod());\n\t}\n}\n"]}
1
+ {"version":3,"file":"identityService.js","sourceRoot":"","sources":["../../src/identityService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAEjF,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EAGf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,yBAAyB,EACzB,UAAU,EAOV,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,YAAY,EAA4B,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC;;GAEG;AACH,MAAM,OAAO,eAAe;IAC3B;;OAEG;IACI,MAAM,CAAU,UAAU,qBAAqC;IAEtE;;;OAGG;IACc,iBAAiB,CAAS;IAE3C;;;OAGG;IACc,mBAAmB,CAAuB;IAE3D;;;OAGG;IACH,YAAY,OAA4C;QACvD,MAAM,KAAK,GAAG,wBAAwB,CAAC,KAAK,EAAE,CAAC;QAC/C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,YAAY,CAAC,eAAe,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QACpE,CAAC;QAED,IAAI,CAAC,iBAAiB,GAAG,OAAO,EAAE,MAAM,EAAE,gBAAgB,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;QAEvE,IAAI,CAAC,mB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eAAe,GAAG,SAAS,IAAI,IAAI,CAAC,iBAAiB,CAAC;QAE5D,MAAM,SAAS,GAAG,wBAAwB,CAAC,WAAW,CAAqB,eAAe,CAAC,CAAC;QAE5F,IAAI,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,YAAY,CAAC,eAAe,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBACvE,SAAS,EAAE,eAAe;aAC1B,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;IAED;;;;;;OAMG;IACK,iBAAiB,CAAC,EAAU;QACnC,MAAM,KAAK,GAAG,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAEtC,IAAI,KAAK,CAAC,mBAAmB,EAAE,KAAK,KAAK,EAAE,CAAC;YAC3C,MAAM,IAAI,YAAY,CAAC,eAAe,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBACvE,SAAS,EAAE,KAAK;gBAChB,EAAE;aACF,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC;IAC9D,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ComponentFactory, GeneralError, Guards, Is, Urn } from \"@twin.org/core\";\nimport type { IJsonLdContextDefinitionRoot, IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport {\n\tDocumentHelper,\n\tIdentityConnectorFactory,\n\tIdentityMetricIds,\n\tIdentityMetrics,\n\ttype IIdentityComponent,\n\ttype IIdentityConnector\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDidVerificationMethodType,\n\tProofTypes,\n\ttype IDidDocument,\n\ttype IDidDocumentVerificationMethod,\n\ttype IProof,\n\ttype IDidService,\n\ttype IDidVerifiableCredential,\n\ttype IDidVerifiablePresentation\n} from \"@twin.org/standards-w3c-did\";\nimport { MetricHelper, type ITelemetryComponent } from \"@twin.org/telemetry-models\";\nimport { Jwt } from \"@twin.org/web\";\nimport type { IIdentityServiceConstructorOptions } from \"./models/IIdentityServiceConstructorOptions.js\";\n\n/**\n * Class which implements the identity contract.\n */\nexport class IdentityService implements IIdentityComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityService>();\n\n\t/**\n\t * The default namespace for the connector to use.\n\t * @internal\n\t */\n\tprivate readonly _defaultNamespace: string;\n\n\t/**\n\t * The telemetry component.\n\t * @internal\n\t */\n\tprivate readonly _telemetryComponent?: ITelemetryComponent;\n\n\t/**\n\t * Create a new instance of IdentityService.\n\t * @param options The options for the service.\n\t */\n\tconstructor(options?: IIdentityServiceConstructorOptions) {\n\t\tconst names = IdentityConnectorFactory.names();\n\t\tif (names.length === 0) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"noConnectors\");\n\t\t}\n\n\t\tthis._defaultNamespace = options?.config?.defaultNamespace ?? names[0];\n\n\t\tthis._telemetryComponent = ComponentFactory.getIfExists<ITelemetryComponent>(\n\t\t\toptions?.telemetryComponentType\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 IdentityService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Register all identity metrics with the telemetry component.\n\t * @returns A promise that resolves when all metrics have been registered.\n\t */\n\tpublic async start(): Promise<void> {\n\t\tif (Is.undefined(this._telemetryComponent)) {\n\t\t\treturn;\n\t\t}\n\n\t\tawait MetricHelper.createMetrics(this._telemetryComponent, IdentityMetrics);\n\t}\n\n\t/**\n\t * Create a new identity.\n\t * @param namespace The namespace of the connector to use for the identity, defaults to service configured namespace.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns The created identity document.\n\t */\n\tpublic async identityCreate(namespace?: string, controller?: string): Promise<IDidDocument> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByNamespace(namespace);\n\t\t\tconst result = await identityConnector.createDocument(controller);\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.DidsCreated, {\n\t\t\t\tnamespace: namespace ?? this._defaultNamespace\n\t\t\t});\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"identityCreateFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Remove an identity.\n\t * @param identity The id of the document to remove.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns A promise that resolves when the identity has been removed.\n\t */\n\tpublic async identityRemove(identity: string, controller?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(identity);\n\t\t\tconst result = await identityConnector.removeDocument(controller, identity);\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.DidsRemoved);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"identityRemoveFailed\",\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 * Add a verification method to the document in JSON Web key Format.\n\t * @param identity 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 * @param controller The controller of the identity who can make changes.\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 verificationMethodCreate(\n\t\tidentity: string,\n\t\tverificationMethodType: DidVerificationMethodType,\n\t\tverificationMethodId?: string,\n\t\tcontroller?: string\n\t): Promise<IDidDocumentVerificationMethod> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(identity), identity);\n\n\t\tGuards.arrayOneOf(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(verificationMethodType),\n\t\t\tverificationMethodType,\n\t\t\tObject.values(DidVerificationMethodType)\n\t\t);\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(identity);\n\n\t\t\tconst verificationMethod = await identityConnector.addVerificationMethod(\n\t\t\t\tcontroller,\n\t\t\t\tidentity,\n\t\t\t\tverificationMethodType,\n\t\t\t\tverificationMethodId\n\t\t\t);\n\n\t\t\treturn verificationMethod;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verificationMethodCreateFailed\",\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 * Remove a verification method from the document.\n\t * @param verificationMethodId The id of the verification method.\n\t * @param controller The controller of the identity who can make changes.\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 verificationMethodRemove(\n\t\tverificationMethodId: string,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(verificationMethodId), verificationMethodId);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tawait identityConnector.removeVerificationMethod(controller, verificationMethodId);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verificationMethodRemoveFailed\",\n\t\t\t\t{ verificationMethodId },\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 identity 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 * @param controller The controller of the identity who can make changes.\n\t * @returns The service.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async serviceCreate(\n\t\tidentity: string,\n\t\tserviceId: string,\n\t\tserviceType: string | string[],\n\t\tserviceEndpoint: string | string[],\n\t\tcontroller?: string\n\t): Promise<IDidService> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(serviceId), serviceId);\n\t\tif (Is.array(serviceType)) {\n\t\t\tGuards.arrayValue<string>(IdentityService.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t} else {\n\t\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t}\n\t\tif (Is.array(serviceEndpoint)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tIdentityService.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(IdentityService.CLASS_NAME, nameof(serviceEndpoint), serviceEndpoint);\n\t\t}\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(identity);\n\n\t\t\tconst service = await identityConnector.addService(\n\t\t\t\tcontroller,\n\t\t\t\tidentity,\n\t\t\t\tserviceId,\n\t\t\t\tserviceType,\n\t\t\t\tserviceEndpoint\n\t\t\t);\n\n\t\t\treturn service;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"serviceCreateFailed\",\n\t\t\t\t{ identity, serviceId },\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 serviceId The id of the service.\n\t * @param controller The controller of the identity who can make changes.\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 serviceRemove(serviceId: string, controller?: string): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(serviceId), serviceId);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(serviceId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tawait identityConnector.removeService(controller, serviceId);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"serviceRemoveFailed\",\n\t\t\t\t{ serviceId },\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 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 * @param controller The controller of the identity who can make changes.\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 alsoKnownAsAdd(\n\t\tdocumentId: string,\n\t\talias: string,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(alias), alias);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(documentId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tawait identityConnector.addAlsoKnownAs(controller, documentId, alias);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"alsoKnownAsAddFailed\",\n\t\t\t\t{ identity: documentId, alias },\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 documentId The id of the document to update.\n\t * @param alias The alias to remove. Must be a Url or Urn.\n\t * @param controller The controller of the identity who can make changes.\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 alsoKnownAsRemove(\n\t\tdocumentId: string,\n\t\talias: string,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(alias), alias);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(documentId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tawait identityConnector.removeAlsoKnownAs(controller, documentId, alias);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"alsoKnownAsRemoveFailed\",\n\t\t\t\t{ identity: documentId, alias },\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 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 include in the JWT header when creating the verifiable credential in jwt format.\n\t * @param options.jwtPayloadFields Additional fields to include in the JWT payload when creating the verifiable credential in jwt format.\n\t * @param controller The controller of the identity who can make changes.\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 verifiableCredentialCreate(\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\tcontroller?: string\n\t): Promise<{\n\t\tverifiableCredential: IDidVerifiableCredential;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tUrn.guard(IdentityService.CLASS_NAME, nameof(verificationMethodId), verificationMethodId);\n\t\tGuards.object(IdentityService.CLASS_NAME, nameof(subject), subject);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst service = await identityConnector.createVerifiableCredential(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tid,\n\t\t\t\tsubject,\n\t\t\t\toptions\n\t\t\t);\n\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsCreated, {\n\t\t\t\thasRevocation: Is.number(options?.revocationIndex),\n\t\t\t\thasExpiration: Is.date(options?.expirationDate)\n\t\t\t});\n\n\t\t\treturn service;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiableCredentialCreateFailed\",\n\t\t\t\t{ verificationMethodId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Verify 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 verifiableCredentialVerify(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\tIdentityService.CLASS_NAME,\n\t\t\t\tnameof(credential),\n\t\t\t\tcredential\n\t\t\t);\n\t\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(credential.issuer), credential.issuer);\n\t\t\tGuards.objectValue<IDidVerifiableCredential>(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\tnameof(credential.proof),\n\t\t\t\tcredential.proof\n\t\t\t);\n\n\t\t\ttry {\n\t\t\t\tconst identityConnector = this.getConnectorByUri(credential.issuer);\n\n\t\t\t\tconst service = await identityConnector.checkVerifiableCredential(credential);\n\n\t\t\t\tif (service.revoked) {\n\t\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\t\tIdentityMetricIds.VcsVerificationFailed,\n\t\t\t\t\t\t{ failureReason: \"revoked\" }\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\t\tIdentityMetricIds.VcsVerified\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn service;\n\t\t\t} catch (error) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\t\"verifiableCredentialVerifyFailed\",\n\t\t\t\t\tundefined,\n\t\t\t\t\terror\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(credential), credential);\n\n\t\tconst jwtDecoded = await Jwt.decode(credential);\n\n\t\tconst jwtHeader = jwtDecoded.header;\n\t\tconst jwtPayload = jwtDecoded.payload;\n\t\tconst jwtSignature = jwtDecoded.signature;\n\n\t\tif (\n\t\t\tIs.undefined(jwtHeader) ||\n\t\t\tIs.undefined(jwtPayload) ||\n\t\t\tIs.undefined(jwtPayload.iss) ||\n\t\t\tIs.undefined(jwtSignature)\n\t\t) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"jwtDecodeFailed\");\n\t\t}\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(jwtPayload.iss);\n\n\t\t\tconst service = await identityConnector.checkVerifiableCredential(credential);\n\n\t\t\tif (service.revoked) {\n\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\tIdentityMetricIds.VcsVerificationFailed,\n\t\t\t\t\t{ failureReason: \"revoked\" }\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsVerified);\n\t\t\t}\n\n\t\t\treturn service;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiableCredentialVerifyFailed\",\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.\n\t * @param issuerIdentity The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index to revoke.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns A promise that resolves when the credential has been revoked.\n\t */\n\tpublic async verifiableCredentialRevoke(\n\t\tissuerIdentity: string,\n\t\tcredentialIndex: number,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(issuerIdentity), issuerIdentity);\n\t\tGuards.number(IdentityService.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(issuerIdentity);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.revokeVerifiableCredentials(\n\t\t\t\tcontroller,\n\t\t\t\tissuerIdentity,\n\t\t\t\t[credentialIndex]\n\t\t\t);\n\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsRevoked);\n\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiableCredentialRevokeFailed\",\n\t\t\t\t{ issuerIdentity, credentialIndex },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Unrevoke verifiable credential.\n\t * @param issuerIdentity The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index to un revoke.\n\t * @param controller The controller of the identity who can make changes.\n\t * @returns A promise that resolves when the credential has been unrevoked.\n\t */\n\tpublic async verifiableCredentialUnrevoke(\n\t\tissuerIdentity: string,\n\t\tcredentialIndex: number,\n\t\tcontroller?: string\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(issuerIdentity), issuerIdentity);\n\t\tGuards.number(IdentityService.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(issuerIdentity);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.unrevokeVerifiableCredentials(\n\t\t\t\tcontroller,\n\t\t\t\tissuerIdentity,\n\t\t\t\t[credentialIndex]\n\t\t\t);\n\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VcsUnrevoked);\n\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiableCredentialUnrevokeFailed\",\n\t\t\t\t{ issuerIdentity, credentialIndex },\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 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 include in the JWT header when creating the verifiable presentation in jwt format.\n\t * @param options.jwtPayloadFields\tAdditional fields to include in the JWT payload when creating the verifiable presentation in jwt format.\n\t * @param controller The controller of the identity who can make changes.\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 verifiablePresentationCreate(\n\t\tverificationMethodId: string,\n\t\tpresentationId: string | undefined,\n\t\tcontexts: IJsonLdContextDefinitionRoot | undefined,\n\t\ttypes: string | string[] | undefined,\n\t\tverifiableCredentials: (string | IDidVerifiableCredential)[],\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\tcontroller?: string\n\t): Promise<{\n\t\tverifiablePresentation: IDidVerifiablePresentation;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tIdentityService.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\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.createVerifiablePresentation(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tpresentationId,\n\t\t\t\tcontexts,\n\t\t\t\ttypes,\n\t\t\t\tverifiableCredentials,\n\t\t\t\toptions\n\t\t\t);\n\n\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VpsCreated, {\n\t\t\t\tcredentialCount: verifiableCredentials.length\n\t\t\t});\n\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiablePresentationCreateFailed\",\n\t\t\t\t{ verificationMethodId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Verify 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 verifiablePresentationVerify(\n\t\tpresentation: string | IDidVerifiablePresentation\n\t): Promise<{\n\t\trevoked: boolean;\n\t\tverifiablePresentation?: IDidVerifiablePresentation;\n\t\tissuers?: IDidDocument[];\n\t}> {\n\t\tlet holder;\n\t\tif (Is.stringValue(presentation)) {\n\t\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(presentation), presentation);\n\n\t\t\tconst jwtDecoded = await Jwt.decode(presentation);\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 GeneralError(IdentityService.CLASS_NAME, \"jwtDecodeFailed\");\n\t\t\t}\n\n\t\t\tholder = jwtPayload.iss;\n\t\t} else {\n\t\t\tholder = presentation.holder;\n\t\t}\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(holder), holder);\n\n\t\ttry {\n\t\t\tconst identityConnector = this.getConnectorByUri(holder);\n\n\t\t\tconst service = await identityConnector.checkVerifiablePresentation(presentation);\n\n\t\t\tif (service.revoked) {\n\t\t\t\tawait MetricHelper.metricIncrement(\n\t\t\t\t\tthis._telemetryComponent,\n\t\t\t\t\tIdentityMetricIds.VpsVerificationFailed,\n\t\t\t\t\t{ failureReason: \"revoked\" }\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tawait MetricHelper.metricIncrement(this._telemetryComponent, IdentityMetricIds.VpsVerified);\n\t\t\t}\n\n\t\t\treturn service;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"verifiablePresentationVerifyFailed\",\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 a document with the specified verification method.\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 controller The controller of the identity who can make changes.\n\t * @returns The proof.\n\t */\n\tpublic async proofCreate(\n\t\tverificationMethodId: string,\n\t\tproofType: ProofTypes,\n\t\tunsecureDocument: IJsonLdNodeObject,\n\t\tcontroller?: string\n\t): Promise<IProof> {\n\t\tGuards.stringValue(IdentityService.CLASS_NAME, nameof(controller), controller);\n\t\tGuards.stringValue(\n\t\t\tIdentityService.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.arrayOneOf<ProofTypes>(\n\t\t\tIdentityService.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\tIdentityService.CLASS_NAME,\n\t\t\tnameof(unsecureDocument),\n\t\t\tunsecureDocument\n\t\t);\n\n\t\ttry {\n\t\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.createProof(\n\t\t\t\tcontroller,\n\t\t\t\tverificationMethodId,\n\t\t\t\tproofType,\n\t\t\t\tunsecureDocument\n\t\t\t);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIdentityService.CLASS_NAME,\n\t\t\t\t\"proofCreateFailed\",\n\t\t\t\t{ verificationMethodId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Verify proof for a document 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 proofVerify(document: IJsonLdNodeObject, proof: IProof): Promise<boolean> {\n\t\tGuards.object<IJsonLdNodeObject>(IdentityService.CLASS_NAME, nameof(document), document);\n\t\tGuards.object<IProof>(IdentityService.CLASS_NAME, nameof(proof), proof);\n\t\tGuards.stringValue(\n\t\t\tIdentityService.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\n\t\t\tconst identityConnector = this.getConnectorByUri(idParts.id);\n\n\t\t\tconst result = await identityConnector.verifyProof(document, proof);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"proofVerifyFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Get the connector from the namespace.\n\t * @param namespace The namespace for the identity.\n\t * @returns The connector.\n\t * @throws GeneralError if the connector is not found.\n\t * @internal\n\t */\n\tprivate getConnectorByNamespace(namespace?: string): IIdentityConnector {\n\t\tconst namespaceMethod = namespace ?? this._defaultNamespace;\n\n\t\tconst connector = IdentityConnectorFactory.getIfExists<IIdentityConnector>(namespaceMethod);\n\n\t\tif (Is.empty(connector)) {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"connectorNotFound\", {\n\t\t\t\tnamespace: namespaceMethod\n\t\t\t});\n\t\t}\n\n\t\treturn connector;\n\t}\n\n\t/**\n\t * Get the connector from the uri.\n\t * @param id The id of the identity in urn format.\n\t * @returns The connector.\n\t * @throws GeneralError if the namespace does not match or the connector is not found.\n\t * @internal\n\t */\n\tprivate getConnectorByUri(id: string): IIdentityConnector {\n\t\tconst idUri = Urn.fromValidString(id);\n\n\t\tif (idUri.namespaceIdentifier() !== \"did\") {\n\t\t\tthrow new GeneralError(IdentityService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: \"did\",\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\treturn this.getConnectorByNamespace(idUri.namespaceMethod());\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IIdentityResolverServiceConfig.js","sourceRoot":"","sources":["../../../src/models/IIdentityResolverServiceConfig.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Configuration for the Identity Resolver Service.\n */\nexport interface IIdentityResolverServiceConfig {\n\t/**\n\t * What is the default connector to use for Identity. If not provided the first connector from the factory will be used.\n\t */\n\tdefaultNamespace?: string;\n}\n"]}
1
+ {"version":3,"file":"IIdentityResolverServiceConfig.js","sourceRoot":"","sources":["../../../src/models/IIdentityResolverServiceConfig.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Configuration for the Identity Resolver Service.\n */\nexport interface IIdentityResolverServiceConfig {\n\t/**\n\t * The default connector namespace to use for identity resolution. If not provided, the first registered connector is used.\n\t */\n\tdefaultNamespace?: string;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IIdentityServiceConfig.js","sourceRoot":"","sources":["../../../src/models/IIdentityServiceConfig.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Configuration for the Identity Service.\n */\nexport interface IIdentityServiceConfig {\n\t/**\n\t * What is the default connector to use for Identity. If not provided the first connector from the factory will be used.\n\t */\n\tdefaultNamespace?: string;\n}\n"]}
1
+ {"version":3,"file":"IIdentityServiceConfig.js","sourceRoot":"","sources":["../../../src/models/IIdentityServiceConfig.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Configuration for the Identity Service.\n */\nexport interface IIdentityServiceConfig {\n\t/**\n\t * The default connector namespace to use for identity operations. If not provided, the first registered connector is used.\n\t */\n\tdefaultNamespace?: string;\n}\n"]}
@@ -1,6 +1,9 @@
1
1
  import { generateRestRoutesIdentityProfile, tagsIdentityProfile } from "./identityProfileRoutes.js";
2
2
  import { generateRestRoutesIdentityResolver, tagsIdentityResolver } from "./identityResolverRoutes.js";
3
3
  import { generateRestRoutesIdentity, tagsIdentity } from "./identityRoutes.js";
4
+ /**
5
+ * REST entry points for the identity, identity resolver, and identity profile services.
6
+ */
4
7
  export const restEntryPoints = [
5
8
  {
6
9
  name: "identityResolver",
@@ -1 +1 @@
1
- {"version":3,"file":"restEntryPoints.js","sourceRoot":"","sources":["../../src/restEntryPoints.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iCAAiC,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACpG,OAAO,EACN,kCAAkC,EAClC,oBAAoB,EACpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE/E,MAAM,CAAC,MAAM,eAAe,GAA2B;IACtD;QACC,IAAI,EAAE,kBAAkB;QACxB,gBAAgB,EAAE,UAAU;QAC5B,IAAI,EAAE,oBAAoB;QAC1B,cAAc,EAAE,kCAAkC;KAClD;IACD;QACC,IAAI,EAAE,UAAU;QAChB,gBAAgB,EAAE,UAAU;QAC5B,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,0BAA0B;KAC1C;IACD;QACC,IAAI,EAAE,iBAAiB;QACvB,gBAAgB,EAAE,kBAAkB;QACpC,IAAI,EAAE,mBAAmB;QACzB,cAAc,EAAE,iCAAiC;KACjD;CACD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IRestRouteEntryPoint } from \"@twin.org/api-models\";\nimport { generateRestRoutesIdentityProfile, tagsIdentityProfile } from \"./identityProfileRoutes.js\";\nimport {\n\tgenerateRestRoutesIdentityResolver,\n\ttagsIdentityResolver\n} from \"./identityResolverRoutes.js\";\nimport { generateRestRoutesIdentity, tagsIdentity } from \"./identityRoutes.js\";\n\nexport const restEntryPoints: IRestRouteEntryPoint[] = [\n\t{\n\t\tname: \"identityResolver\",\n\t\tdefaultBaseRoute: \"identity\",\n\t\ttags: tagsIdentityResolver,\n\t\tgenerateRoutes: generateRestRoutesIdentityResolver\n\t},\n\t{\n\t\tname: \"identity\",\n\t\tdefaultBaseRoute: \"identity\",\n\t\ttags: tagsIdentity,\n\t\tgenerateRoutes: generateRestRoutesIdentity\n\t},\n\t{\n\t\tname: \"identityProfile\",\n\t\tdefaultBaseRoute: \"identity/profile\",\n\t\ttags: tagsIdentityProfile,\n\t\tgenerateRoutes: generateRestRoutesIdentityProfile\n\t}\n];\n"]}
1
+ {"version":3,"file":"restEntryPoints.js","sourceRoot":"","sources":["../../src/restEntryPoints.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iCAAiC,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACpG,OAAO,EACN,kCAAkC,EAClC,oBAAoB,EACpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAA2B;IACtD;QACC,IAAI,EAAE,kBAAkB;QACxB,gBAAgB,EAAE,UAAU;QAC5B,IAAI,EAAE,oBAAoB;QAC1B,cAAc,EAAE,kCAAkC;KAClD;IACD;QACC,IAAI,EAAE,UAAU;QAChB,gBAAgB,EAAE,UAAU;QAC5B,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,0BAA0B;KAC1C;IACD;QACC,IAAI,EAAE,iBAAiB;QACvB,gBAAgB,EAAE,kBAAkB;QACpC,IAAI,EAAE,mBAAmB;QACzB,cAAc,EAAE,iCAAiC;KACjD;CACD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IRestRouteEntryPoint } from \"@twin.org/api-models\";\nimport { generateRestRoutesIdentityProfile, tagsIdentityProfile } from \"./identityProfileRoutes.js\";\nimport {\n\tgenerateRestRoutesIdentityResolver,\n\ttagsIdentityResolver\n} from \"./identityResolverRoutes.js\";\nimport { generateRestRoutesIdentity, tagsIdentity } from \"./identityRoutes.js\";\n\n/**\n * REST entry points for the identity, identity resolver, and identity profile services.\n */\nexport const restEntryPoints: IRestRouteEntryPoint[] = [\n\t{\n\t\tname: \"identityResolver\",\n\t\tdefaultBaseRoute: \"identity\",\n\t\ttags: tagsIdentityResolver,\n\t\tgenerateRoutes: generateRestRoutesIdentityResolver\n\t},\n\t{\n\t\tname: \"identity\",\n\t\tdefaultBaseRoute: \"identity\",\n\t\ttags: tagsIdentity,\n\t\tgenerateRoutes: generateRestRoutesIdentity\n\t},\n\t{\n\t\tname: \"identityProfile\",\n\t\tdefaultBaseRoute: \"identity/profile\",\n\t\ttags: tagsIdentityProfile,\n\t\tgenerateRoutes: generateRestRoutesIdentityProfile\n\t}\n];\n"]}
@@ -24,7 +24,7 @@ export declare class IdentityProfileService<T extends IJsonLdDocument = IJsonLdD
24
24
  * @param publicProfile The public profile data as JSON-LD.
25
25
  * @param privateProfile The private profile data as JSON-LD.
26
26
  * @param identity The identity to perform the profile operation on.
27
- * @returns Nothing.
27
+ * @returns A promise that resolves when the profile has been created.
28
28
  */
29
29
  create(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void>;
30
30
  /**
@@ -51,13 +51,13 @@ export declare class IdentityProfileService<T extends IJsonLdDocument = IJsonLdD
51
51
  * @param publicProfile The public profile data as JSON-LD.
52
52
  * @param privateProfile The private profile data as JSON-LD.
53
53
  * @param identity The identity to perform the profile operation on.
54
- * @returns Nothing.
54
+ * @returns A promise that resolves when the profile has been updated.
55
55
  */
56
56
  update(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void>;
57
57
  /**
58
58
  * Delete the profile for an identity.
59
59
  * @param identity The identity to perform the profile operation on.
60
- * @returns Nothing.
60
+ * @returns A promise that resolves when the profile has been removed.
61
61
  */
62
62
  remove(identity?: string): Promise<void>;
63
63
  /**
@@ -5,7 +5,7 @@ import type { IIdentityResolveRequest, IIdentityResolveResponse } from "@twin.or
5
5
  */
6
6
  export declare const tagsIdentityResolver: ITag[];
7
7
  /**
8
- * The REST routes for identity.
8
+ * The REST routes for identity resolution.
9
9
  * @param baseRouteName Prefix to prepend to the paths.
10
10
  * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
11
11
  * @returns The generated routes.
@@ -22,6 +22,7 @@ export declare class IdentityService implements IIdentityComponent {
22
22
  className(): string;
23
23
  /**
24
24
  * Register all identity metrics with the telemetry component.
25
+ * @returns A promise that resolves when all metrics have been registered.
25
26
  */
26
27
  start(): Promise<void>;
27
28
  /**
@@ -35,7 +36,7 @@ export declare class IdentityService implements IIdentityComponent {
35
36
  * Remove an identity.
36
37
  * @param identity The id of the document to remove.
37
38
  * @param controller The controller of the identity who can make changes.
38
- * @returns Nothing.
39
+ * @returns A promise that resolves when the identity has been removed.
39
40
  */
40
41
  identityRemove(identity: string, controller?: string): Promise<void>;
41
42
  /**
@@ -53,7 +54,7 @@ export declare class IdentityService implements IIdentityComponent {
53
54
  * Remove a verification method from the document.
54
55
  * @param verificationMethodId The id of the verification method.
55
56
  * @param controller The controller of the identity who can make changes.
56
- * @returns Nothing.
57
+ * @returns A promise that resolves when the verification method has been removed.
57
58
  * @throws NotFoundError if the id can not be resolved.
58
59
  * @throws NotSupportedError if the platform does not support multiple revocable keys.
59
60
  */
@@ -73,7 +74,7 @@ export declare class IdentityService implements IIdentityComponent {
73
74
  * Remove a service from the document.
74
75
  * @param serviceId The id of the service.
75
76
  * @param controller The controller of the identity who can make changes.
76
- * @returns Nothing.
77
+ * @returns A promise that resolves when the service has been removed.
77
78
  * @throws NotFoundError if the id can not be resolved.
78
79
  */
79
80
  serviceRemove(serviceId: string, controller?: string): Promise<void>;
@@ -83,7 +84,7 @@ export declare class IdentityService implements IIdentityComponent {
83
84
  * @param documentId The id of the document to update.
84
85
  * @param alias The alias to add. Must be a Url or Urn (typically another DID).
85
86
  * @param controller The controller of the identity who can make changes.
86
- * @returns Nothing.
87
+ * @returns A promise that resolves when the alias has been added.
87
88
  * @throws GeneralError if the alias is not a Url or Urn.
88
89
  * @throws NotFoundError if the id can not be resolved.
89
90
  */
@@ -94,7 +95,7 @@ export declare class IdentityService implements IIdentityComponent {
94
95
  * @param documentId The id of the document to update.
95
96
  * @param alias The alias to remove. Must be a Url or Urn.
96
97
  * @param controller The controller of the identity who can make changes.
97
- * @returns Nothing.
98
+ * @returns A promise that resolves when the alias has been removed.
98
99
  * @throws GeneralError if the alias is not a Url or Urn.
99
100
  * @throws NotFoundError if the id can not be resolved.
100
101
  */
@@ -138,9 +139,9 @@ export declare class IdentityService implements IIdentityComponent {
138
139
  /**
139
140
  * Revoke verifiable credential.
140
141
  * @param issuerIdentity The id of the document to update the revocation list for.
141
- * @param credentialIndex The revocation bitmap index revoke.
142
+ * @param credentialIndex The revocation bitmap index to revoke.
142
143
  * @param controller The controller of the identity who can make changes.
143
- * @returns Nothing.
144
+ * @returns A promise that resolves when the credential has been revoked.
144
145
  */
145
146
  verifiableCredentialRevoke(issuerIdentity: string, credentialIndex: number, controller?: string): Promise<void>;
146
147
  /**
@@ -148,7 +149,7 @@ export declare class IdentityService implements IIdentityComponent {
148
149
  * @param issuerIdentity The id of the document to update the revocation list for.
149
150
  * @param credentialIndex The revocation bitmap index to un revoke.
150
151
  * @param controller The controller of the identity who can make changes.
151
- * @returns Nothing.
152
+ * @returns A promise that resolves when the credential has been unrevoked.
152
153
  */
153
154
  verifiableCredentialUnrevoke(issuerIdentity: string, credentialIndex: number, controller?: string): Promise<void>;
154
155
  /**
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export interface IIdentityResolverServiceConfig {
5
5
  /**
6
- * What is the default connector to use for Identity. If not provided the first connector from the factory will be used.
6
+ * The default connector namespace to use for identity resolution. If not provided, the first registered connector is used.
7
7
  */
8
8
  defaultNamespace?: string;
9
9
  }
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export interface IIdentityServiceConfig {
5
5
  /**
6
- * What is the default connector to use for Identity. If not provided the first connector from the factory will be used.
6
+ * The default connector namespace to use for identity operations. If not provided, the first registered connector is used.
7
7
  */
8
8
  defaultNamespace?: string;
9
9
  }
@@ -1,2 +1,5 @@
1
1
  import type { IRestRouteEntryPoint } from "@twin.org/api-models";
2
+ /**
3
+ * REST entry points for the identity, identity resolver, and identity profile services.
4
+ */
2
5
  export declare const restEntryPoints: IRestRouteEntryPoint[];
package/docs/changelog.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.3-next.36](https://github.com/iotaledger/twin-identity/compare/identity-service-v0.0.3-next.35...identity-service-v0.0.3-next.36) (2026-06-17)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * use async getStore in tests ([cfc0d87](https://github.com/iotaledger/twin-identity/commit/cfc0d873532e8ab2010f86f05bffaad3bbaf5786))
9
+ * use async getStore in tests ([3424c81](https://github.com/iotaledger/twin-identity/commit/3424c81cf7407ede4a89a026072720d52bf689b2))
10
+
11
+
12
+ ### Dependencies
13
+
14
+ * The following workspace dependencies were updated
15
+ * dependencies
16
+ * @twin.org/identity-models bumped from 0.0.3-next.35 to 0.0.3-next.36
17
+ * devDependencies
18
+ * @twin.org/identity-connector-entity-storage bumped from 0.0.3-next.35 to 0.0.3-next.36
19
+
3
20
  ## [0.0.3-next.35](https://github.com/iotaledger/twin-identity/compare/identity-service-v0.0.3-next.34...identity-service-v0.0.3-next.35) (2026-06-01)
4
21
 
5
22
 
@@ -94,7 +94,7 @@ The identity to perform the profile operation on.
94
94
 
95
95
  `Promise`\<`void`\>
96
96
 
97
- Nothing.
97
+ A promise that resolves when the profile has been created.
98
98
 
99
99
  #### Implementation of
100
100
 
@@ -202,7 +202,7 @@ The identity to perform the profile operation on.
202
202
 
203
203
  `Promise`\<`void`\>
204
204
 
205
- Nothing.
205
+ A promise that resolves when the profile has been updated.
206
206
 
207
207
  #### Implementation of
208
208
 
@@ -228,7 +228,7 @@ The identity to perform the profile operation on.
228
228
 
229
229
  `Promise`\<`void`\>
230
230
 
231
- Nothing.
231
+ A promise that resolves when the profile has been removed.
232
232
 
233
233
  #### Implementation of
234
234
 
@@ -64,6 +64,8 @@ Register all identity metrics with the telemetry component.
64
64
 
65
65
  `Promise`\<`void`\>
66
66
 
67
+ A promise that resolves when all metrics have been registered.
68
+
67
69
  #### Implementation of
68
70
 
69
71
  `IIdentityComponent.start`
@@ -126,7 +128,7 @@ The controller of the identity who can make changes.
126
128
 
127
129
  `Promise`\<`void`\>
128
130
 
129
- Nothing.
131
+ A promise that resolves when the identity has been removed.
130
132
 
131
133
  #### Implementation of
132
134
 
@@ -210,7 +212,7 @@ The controller of the identity who can make changes.
210
212
 
211
213
  `Promise`\<`void`\>
212
214
 
213
- Nothing.
215
+ A promise that resolves when the verification method has been removed.
214
216
 
215
217
  #### Throws
216
218
 
@@ -304,7 +306,7 @@ The controller of the identity who can make changes.
304
306
 
305
307
  `Promise`\<`void`\>
306
308
 
307
- Nothing.
309
+ A promise that resolves when the service has been removed.
308
310
 
309
311
  #### Throws
310
312
 
@@ -347,7 +349,7 @@ The controller of the identity who can make changes.
347
349
 
348
350
  `Promise`\<`void`\>
349
351
 
350
- Nothing.
352
+ A promise that resolves when the alias has been added.
351
353
 
352
354
  #### Throws
353
355
 
@@ -394,7 +396,7 @@ The controller of the identity who can make changes.
394
396
 
395
397
  `Promise`\<`void`\>
396
398
 
397
- Nothing.
399
+ A promise that resolves when the alias has been removed.
398
400
 
399
401
  #### Throws
400
402
 
@@ -530,7 +532,7 @@ The id of the document to update the revocation list for.
530
532
 
531
533
  `number`
532
534
 
533
- The revocation bitmap index revoke.
535
+ The revocation bitmap index to revoke.
534
536
 
535
537
  ##### controller?
536
538
 
@@ -542,7 +544,7 @@ The controller of the identity who can make changes.
542
544
 
543
545
  `Promise`\<`void`\>
544
546
 
545
- Nothing.
547
+ A promise that resolves when the credential has been revoked.
546
548
 
547
549
  #### Implementation of
548
550
 
@@ -580,7 +582,7 @@ The controller of the identity who can make changes.
580
582
 
581
583
  `Promise`\<`void`\>
582
584
 
583
- Nothing.
585
+ A promise that resolves when the credential has been unrevoked.
584
586
 
585
587
  #### Implementation of
586
588
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  > **generateRestRoutesIdentityResolver**(`baseRouteName`, `componentName`): `IRestRoute`\<`any`, `any`\>[]
4
4
 
5
- The REST routes for identity.
5
+ The REST routes for identity resolution.
6
6
 
7
7
  ## Parameters
8
8
 
@@ -8,4 +8,4 @@ Configuration for the Identity Resolver Service.
8
8
 
9
9
  > `optional` **defaultNamespace?**: `string`
10
10
 
11
- What is the default connector to use for Identity. If not provided the first connector from the factory will be used.
11
+ The default connector namespace to use for identity resolution. If not provided, the first registered connector is used.
@@ -8,4 +8,4 @@ Configuration for the Identity Service.
8
8
 
9
9
  > `optional` **defaultNamespace?**: `string`
10
10
 
11
- What is the default connector to use for Identity. If not provided the first connector from the factory will be used.
11
+ The default connector namespace to use for identity operations. If not provided, the first registered connector is used.
@@ -1,3 +1,5 @@
1
1
  # Variable: restEntryPoints
2
2
 
3
3
  > `const` **restEntryPoints**: `IRestRouteEntryPoint`[]
4
+
5
+ REST entry points for the identity, identity resolver, and identity profile services.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/identity-service",
3
- "version": "0.0.3-next.35",
3
+ "version": "0.0.3-next.36",
4
4
  "description": "Service contracts and REST endpoint definitions for exposing identity workflows through stable interfaces.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,7 +22,7 @@
22
22
  "@twin.org/data-json-ld": "next",
23
23
  "@twin.org/entity": "next",
24
24
  "@twin.org/entity-storage-models": "next",
25
- "@twin.org/identity-models": "0.0.3-next.35",
25
+ "@twin.org/identity-models": "0.0.3-next.36",
26
26
  "@twin.org/standards-w3c-did": "next",
27
27
  "@twin.org/telemetry-models": "next",
28
28
  "@twin.org/vault-models": "next",