@twin.org/identity-rest-client 0.0.3-next.9 → 0.9.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # TWIN Identity REST Client
1
+ # TWIN Identity
2
2
 
3
- Identity contract implementation which can connect to REST endpoints.
3
+ The identity-rest-client package offers a reusable client interface for consuming identity REST endpoints defined by shared contracts. It simplifies application-side integration with identity services and keeps request and response handling consistent across projects.
4
4
 
5
5
  ## Installation
6
6
 
@@ -4,7 +4,7 @@ import { BaseRestClient } from "@twin.org/api-core";
4
4
  import { HttpParameterHelper } from "@twin.org/api-models";
5
5
  import { Coerce, Guards } from "@twin.org/core";
6
6
  /**
7
- * Client for performing identity through to REST endpoints.
7
+ * Client for performing identity profile operations through REST endpoints.
8
8
  */
9
9
  export class IdentityProfileRestClient extends BaseRestClient {
10
10
  /**
@@ -29,7 +29,7 @@ export class IdentityProfileRestClient extends BaseRestClient {
29
29
  * Create the profile properties for an identity.
30
30
  * @param publicProfile The public profile data as JSON-LD.
31
31
  * @param privateProfile The private profile data as JSON-LD.
32
- * @returns Nothing.
32
+ * @returns A promise that resolves when the profile has been created.
33
33
  */
34
34
  async create(publicProfile, privateProfile) {
35
35
  await this.fetch("", "POST", {
@@ -80,7 +80,7 @@ export class IdentityProfileRestClient extends BaseRestClient {
80
80
  * Update the profile properties of an identity.
81
81
  * @param publicProfile The public profile data as JSON-LD.
82
82
  * @param privateProfile The private profile data as JSON-LD.
83
- * @returns Nothing.
83
+ * @returns A promise that resolves when the profile has been updated.
84
84
  */
85
85
  async update(publicProfile, privateProfile) {
86
86
  await this.fetch("/", "PUT", {
@@ -92,7 +92,7 @@ export class IdentityProfileRestClient extends BaseRestClient {
92
92
  }
93
93
  /**
94
94
  * Delete the profile for an identity.
95
- * @returns Nothing.
95
+ * @returns A promise that resolves when the profile has been removed.
96
96
  */
97
97
  async remove() {
98
98
  await this.fetch("/", "DELETE");
@@ -1 +1 @@
1
- {"version":3,"file":"identityProfileRestClient.js","sourceRoot":"","sources":["../../src/identityProfileRestClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAA8B,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAehD;;GAEG;AACH,MAAM,OAAO,yBAIZ,SAAQ,cAAc;IAGtB;;OAEG;IACI,MAAM,CAAU,UAAU,+BAA+C;IAEhF;;;OAGG;IACH,YAAY,MAA6B;QACxC,KAAK,8BAAsC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACxE,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,yBAAyB,CAAC,UAAU,CAAC;IAC7C,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CAAC,aAAiB,EAAE,cAAkB;QACxD,MAAM,IAAI,CAAC,KAAK,CAAuC,EAAE,EAAE,MAAM,EAAE;YAClE,IAAI,EAAE;gBACL,aAAa;gBACb,cAAc;aACd;SACD,CAAC,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,GAAG,CACf,mBAAiC,EACjC,oBAAkC;QAMlC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAChC,GAAG,EACH,KAAK,EACL;YACC,KAAK,EAAE;gBACN,mBAAmB,EAAE,mBAAmB,CAAC,aAAa,CAAC,mBAAmB,CAAC;gBAC3E,oBAAoB,EAAE,mBAAmB,CAAC,aAAa,CAAC,oBAAoB,CAAC;aAC7E;SACD,CACD,CAAC;QAEF,OAAO;YACN,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ;YAChC,aAAa,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAkB;YAC/C,cAAc,EAAE,QAAQ,CAAC,IAAI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AAC,MAAM,CAAC,KAAK,CAAC;aAC3B;SACD,CACD,CAAC;QACF,OAAO;YACN,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,KAGlB;YACH,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM;SAC5B,CAAC;IACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport { HttpParameterHelper, type IBaseRestClientConfig } from \"@twin.org/api-models\";\nimport { Coerce, Guards } from \"@twin.org/core\";\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\nimport type {\n\tIIdentityProfileComponent,\n\tIIdentityProfileCreateRequest,\n\tIIdentityProfileGetPublicRequest,\n\tIIdentityProfileGetPublicResponse,\n\tIIdentityProfileGetRequest,\n\tIIdentityProfileGetResponse,\n\tIIdentityProfileListRequest,\n\tIIdentityProfileListResponse,\n\tIIdentityProfileUpdateRequest\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Client for performing identity through to REST endpoints.\n */\nexport class IdentityProfileRestClient<\n\t\tT extends IJsonLdDocument = IJsonLdDocument,\n\t\tU extends IJsonLdDocument = IJsonLdDocument\n\t>\n\textends BaseRestClient\n\timplements IIdentityProfileComponent<T, U>\n{\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityProfileRestClient>();\n\n\t/**\n\t * Create a new instance of IdentityProfileRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(nameof<IdentityProfileRestClient>(), config, \"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 IdentityProfileRestClient.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 * @returns Nothing.\n\t */\n\tpublic async create(publicProfile?: T, privateProfile?: U): Promise<void> {\n\t\tawait this.fetch<IIdentityProfileCreateRequest, never>(\"\", \"POST\", {\n\t\t\tbody: {\n\t\t\t\tpublicProfile,\n\t\t\t\tprivateProfile\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 * @returns The identity and the items properties.\n\t */\n\tpublic async get(\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[]\n\t): Promise<{\n\t\tidentity: string;\n\t\tpublicProfile?: Partial<T>;\n\t\tprivateProfile?: Partial<U>;\n\t}> {\n\t\tconst response = await this.fetch<IIdentityProfileGetRequest, IIdentityProfileGetResponse>(\n\t\t\t\"/\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\tquery: {\n\t\t\t\t\tpublicPropertyNames: HttpParameterHelper.arrayToString(publicPropertyNames),\n\t\t\t\t\tprivatePropertyNames: HttpParameterHelper.arrayToString(privatePropertyNames)\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn {\n\t\t\tidentity: response.body.identity,\n\t\t\tpublicProfile: response.body.publicProfile as T,\n\t\t\tprivateProfile: response.body.privateProfile as U\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 public properties to get for the profile, 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.string(IdentityProfileRestClient.CLASS_NAME, nameof(identity), identity);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityProfileGetPublicRequest,\n\t\t\tIIdentityProfileGetPublicResponse\n\t\t>(\"/:identity/public\", \"GET\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity\n\t\t\t},\n\t\t\tquery: {\n\t\t\t\tpropertyNames: HttpParameterHelper.arrayToString(propertyNames)\n\t\t\t}\n\t\t});\n\n\t\treturn response.body as Partial<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 * @returns Nothing.\n\t */\n\tpublic async update(publicProfile?: T, privateProfile?: U): Promise<void> {\n\t\tawait this.fetch<IIdentityProfileUpdateRequest, never>(\"/\", \"PUT\", {\n\t\t\tbody: {\n\t\t\t\tpublicProfile,\n\t\t\t\tprivateProfile\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Delete the profile for an identity.\n\t * @returns Nothing.\n\t */\n\tpublic async remove(): Promise<void> {\n\t\tawait this.fetch<never, never>(\"/\", \"DELETE\");\n\t}\n\n\t/**\n\t * Get a list of the requested identities.\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: {\n\t\t\tidentity: string;\n\t\t\tpublicProfile?: Partial<T>;\n\t\t}[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}> {\n\t\tconst response = await this.fetch<IIdentityProfileListRequest, IIdentityProfileListResponse>(\n\t\t\t\"/query\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\tquery: {\n\t\t\t\t\tpublicFilters: HttpParameterHelper.arrayToString(\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n\t\t\t\t\t\tpublicFilters?.map(f => `${f.propertyName}:${f.propertyValue}`)\n\t\t\t\t\t),\n\t\t\t\t\tpublicPropertyNames: HttpParameterHelper.arrayToString(publicPropertyNames),\n\t\t\t\t\tcursor,\n\t\t\t\t\tlimit: Coerce.string(limit)\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t\treturn {\n\t\t\titems: response.body.items as {\n\t\t\t\tidentity: string;\n\t\t\t\tpublicProfile?: Partial<T>;\n\t\t\t}[],\n\t\t\tcursor: response.body.cursor\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"identityProfileRestClient.js","sourceRoot":"","sources":["../../src/identityProfileRestClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAA8B,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAehD;;GAEG;AACH,MAAM,OAAO,yBAIZ,SAAQ,cAAc;IAGtB;;OAEG;IACI,MAAM,CAAU,UAAU,+BAA+C;IAEhF;;;OAGG;IACH,YAAY,MAA6B;QACxC,KAAK,8BAAsC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACxE,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,yBAAyB,CAAC,UAAU,CAAC;IAC7C,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CAAC,aAAiB,EAAE,cAAkB;QACxD,MAAM,IAAI,CAAC,KAAK,CAAuC,EAAE,EAAE,MAAM,EAAE;YAClE,IAAI,EAAE;gBACL,aAAa;gBACb,cAAc;aACd;SACD,CAAC,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,GAAG,CACf,mBAAiC,EACjC,oBAAkC;QAMlC,MAAM,QAAQ,GAAG,MAAM,IAAI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GAAG,MAAM,IAAI,CAAC,KAAK,CAChC,QAAQ,EACR,KAAK,EACL;YACC,KAAK,EAAE;gBACN,aAAa,EAAE,mBAAmB,CAAC,aAAa;gBAC/C,4EAA4E;gBAC5E,aAAa,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC,CAC/D;gBACD,mBAAmB,EAAE,mBAAmB,CAAC,aAAa,CAAC,mBAAmB,CAAC;gBAC3E,MAAM;gBACN,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;aAC3B;SACD,CACD,CAAC;QACF,OAAO;YACN,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,KAGlB;YACH,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM;SAC5B,CAAC;IACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport { HttpParameterHelper, type IBaseRestClientConfig } from \"@twin.org/api-models\";\nimport { Coerce, Guards } from \"@twin.org/core\";\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\nimport type {\n\tIIdentityProfileComponent,\n\tIIdentityProfileCreateRequest,\n\tIIdentityProfileGetPublicRequest,\n\tIIdentityProfileGetPublicResponse,\n\tIIdentityProfileGetRequest,\n\tIIdentityProfileGetResponse,\n\tIIdentityProfileListRequest,\n\tIIdentityProfileListResponse,\n\tIIdentityProfileUpdateRequest\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Client for performing identity profile operations through REST endpoints.\n */\nexport class IdentityProfileRestClient<\n\tT extends IJsonLdDocument = IJsonLdDocument,\n\tU extends IJsonLdDocument = IJsonLdDocument\n>\n\textends BaseRestClient\n\timplements IIdentityProfileComponent<T, U>\n{\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityProfileRestClient>();\n\n\t/**\n\t * Create a new instance of IdentityProfileRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(nameof<IdentityProfileRestClient>(), config, \"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 IdentityProfileRestClient.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 * @returns A promise that resolves when the profile has been created.\n\t */\n\tpublic async create(publicProfile?: T, privateProfile?: U): Promise<void> {\n\t\tawait this.fetch<IIdentityProfileCreateRequest, never>(\"\", \"POST\", {\n\t\t\tbody: {\n\t\t\t\tpublicProfile,\n\t\t\t\tprivateProfile\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 * @returns The identity and the items properties.\n\t */\n\tpublic async get(\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[]\n\t): Promise<{\n\t\tidentity: string;\n\t\tpublicProfile?: Partial<T>;\n\t\tprivateProfile?: Partial<U>;\n\t}> {\n\t\tconst response = await this.fetch<IIdentityProfileGetRequest, IIdentityProfileGetResponse>(\n\t\t\t\"/\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\tquery: {\n\t\t\t\t\tpublicPropertyNames: HttpParameterHelper.arrayToString(publicPropertyNames),\n\t\t\t\t\tprivatePropertyNames: HttpParameterHelper.arrayToString(privatePropertyNames)\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn {\n\t\t\tidentity: response.body.identity,\n\t\t\tpublicProfile: response.body.publicProfile as T,\n\t\t\tprivateProfile: response.body.privateProfile as U\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 public properties to get for the profile, 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.string(IdentityProfileRestClient.CLASS_NAME, nameof(identity), identity);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityProfileGetPublicRequest,\n\t\t\tIIdentityProfileGetPublicResponse\n\t\t>(\"/:identity/public\", \"GET\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity\n\t\t\t},\n\t\t\tquery: {\n\t\t\t\tpropertyNames: HttpParameterHelper.arrayToString(propertyNames)\n\t\t\t}\n\t\t});\n\n\t\treturn response.body as Partial<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 * @returns A promise that resolves when the profile has been updated.\n\t */\n\tpublic async update(publicProfile?: T, privateProfile?: U): Promise<void> {\n\t\tawait this.fetch<IIdentityProfileUpdateRequest, never>(\"/\", \"PUT\", {\n\t\t\tbody: {\n\t\t\t\tpublicProfile,\n\t\t\t\tprivateProfile\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Delete the profile for an identity.\n\t * @returns A promise that resolves when the profile has been removed.\n\t */\n\tpublic async remove(): Promise<void> {\n\t\tawait this.fetch<never, never>(\"/\", \"DELETE\");\n\t}\n\n\t/**\n\t * Get a list of the requested identities.\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: {\n\t\t\tidentity: string;\n\t\t\tpublicProfile?: Partial<T>;\n\t\t}[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}> {\n\t\tconst response = await this.fetch<IIdentityProfileListRequest, IIdentityProfileListResponse>(\n\t\t\t\"/query\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\tquery: {\n\t\t\t\t\tpublicFilters: HttpParameterHelper.arrayToString(\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n\t\t\t\t\t\tpublicFilters?.map(f => `${f.propertyName}:${f.propertyValue}`)\n\t\t\t\t\t),\n\t\t\t\t\tpublicPropertyNames: HttpParameterHelper.arrayToString(publicPropertyNames),\n\t\t\t\t\tcursor,\n\t\t\t\t\tlimit: Coerce.string(limit)\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t\treturn {\n\t\t\titems: response.body.items as {\n\t\t\t\tidentity: string;\n\t\t\t\tpublicProfile?: Partial<T>;\n\t\t\t}[],\n\t\t\tcursor: response.body.cursor\n\t\t};\n\t}\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  import { BaseRestClient } from "@twin.org/api-core";
4
4
  import { Urn } from "@twin.org/core";
5
5
  /**
6
- * Client for performing identity through to REST endpoints.
6
+ * Client for performing identity resolution through REST endpoints.
7
7
  */
8
8
  export class IdentityResolverRestClient extends BaseRestClient {
9
9
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"identityResolverRestClient.js","sourceRoot":"","sources":["../../src/identityResolverRestClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AASrC;;GAEG;AACH,MAAM,OAAO,0BACZ,SAAQ,cAAc;IAGtB;;OAEG;IACI,MAAM,CAAU,UAAU,gCAAgD;IAEjF;;;OAGG;IACH,YAAY,MAA6B;QACxC,KAAK,+BAAuC,MAAM,EAAE,UAAU,CAAC,CAAC;IACjE,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,0BAA0B,CAAC,UAAU,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,eAAe,CAAC,UAAkB;QAC9C,GAAG,CAAC,KAAK,CAAC,0BAA0B,CAAC,UAAU,gBAAsB,UAAU,CAAC,CAAC;QAEjF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAChC,YAAY,EACZ,KAAK,EACL;YACC,UAAU,EAAE;gBACX,QAAQ,EAAE,UAAU;aACpB;SACD,CACD,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACtB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport type { IBaseRestClientConfig } from \"@twin.org/api-models\";\nimport { Urn } 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 type { IDidDocument } from \"@twin.org/standards-w3c-did\";\n\n/**\n * Client for performing identity through to REST endpoints.\n */\nexport class IdentityResolverRestClient\n\textends BaseRestClient\n\timplements IIdentityResolverComponent\n{\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityResolverRestClient>();\n\n\t/**\n\t * Create a new instance of IdentityResolverRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(nameof<IdentityResolverRestClient>(), config, \"identity\");\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 IdentityResolverRestClient.CLASS_NAME;\n\t}\n\n\t/**\n\t * Resolve an identity.\n\t * @param documentId The id of the document to resolve.\n\t * @returns The resolved document.\n\t */\n\tpublic async identityResolve(documentId: string): Promise<IDidDocument> {\n\t\tUrn.guard(IdentityResolverRestClient.CLASS_NAME, nameof(documentId), documentId);\n\n\t\tconst response = await this.fetch<IIdentityResolveRequest, IIdentityResolveResponse>(\n\t\t\t\"/:identity\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: documentId\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body;\n\t}\n}\n"]}
1
+ {"version":3,"file":"identityResolverRestClient.js","sourceRoot":"","sources":["../../src/identityResolverRestClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AASrC;;GAEG;AACH,MAAM,OAAO,0BACZ,SAAQ,cAAc;IAGtB;;OAEG;IACI,MAAM,CAAU,UAAU,gCAAgD;IAEjF;;;OAGG;IACH,YAAY,MAA6B;QACxC,KAAK,+BAAuC,MAAM,EAAE,UAAU,CAAC,CAAC;IACjE,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,0BAA0B,CAAC,UAAU,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,eAAe,CAAC,UAAkB;QAC9C,GAAG,CAAC,KAAK,CAAC,0BAA0B,CAAC,UAAU,gBAAsB,UAAU,CAAC,CAAC;QAEjF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAChC,YAAY,EACZ,KAAK,EACL;YACC,UAAU,EAAE;gBACX,QAAQ,EAAE,UAAU;aACpB;SACD,CACD,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACtB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport type { IBaseRestClientConfig } from \"@twin.org/api-models\";\nimport { Urn } 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 type { IDidDocument } from \"@twin.org/standards-w3c-did\";\n\n/**\n * Client for performing identity resolution through REST endpoints.\n */\nexport class IdentityResolverRestClient\n\textends BaseRestClient\n\timplements IIdentityResolverComponent\n{\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityResolverRestClient>();\n\n\t/**\n\t * Create a new instance of IdentityResolverRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(nameof<IdentityResolverRestClient>(), config, \"identity\");\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 IdentityResolverRestClient.CLASS_NAME;\n\t}\n\n\t/**\n\t * Resolve an identity.\n\t * @param documentId The id of the document to resolve.\n\t * @returns The resolved document.\n\t */\n\tpublic async identityResolve(documentId: string): Promise<IDidDocument> {\n\t\tUrn.guard(IdentityResolverRestClient.CLASS_NAME, nameof(documentId), documentId);\n\n\t\tconst response = await this.fetch<IIdentityResolveRequest, IIdentityResolveResponse>(\n\t\t\t\"/:identity\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: documentId\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body;\n\t}\n}\n"]}
@@ -42,7 +42,7 @@ export class IdentityRestClient extends BaseRestClient {
42
42
  /**
43
43
  * Remove an identity.
44
44
  * @param identity The id of the document to remove.
45
- * @returns Nothing.
45
+ * @returns A promise that resolves when the identity has been removed.
46
46
  */
47
47
  async identityRemove(identity) {
48
48
  Guards.stringValue(IdentityRestClient.CLASS_NAME, "identity", identity);
@@ -78,7 +78,7 @@ export class IdentityRestClient extends BaseRestClient {
78
78
  /**
79
79
  * Remove a verification method from the document.
80
80
  * @param verificationMethodId The id of the verification method.
81
- * @returns Nothing.
81
+ * @returns A promise that resolves when the verification method has been removed.
82
82
  * @throws NotFoundError if the id can not be resolved.
83
83
  * @throws NotSupportedError if the platform does not support multiple revocable keys.
84
84
  */
@@ -131,7 +131,7 @@ export class IdentityRestClient extends BaseRestClient {
131
131
  /**
132
132
  * Remove a service from the document.
133
133
  * @param serviceId The id of the service.
134
- * @returns Nothing.
134
+ * @returns A promise that resolves when the service has been removed.
135
135
  * @throws NotFoundError if the id can not be resolved.
136
136
  */
137
137
  async serviceRemove(serviceId) {
@@ -144,6 +144,46 @@ export class IdentityRestClient extends BaseRestClient {
144
144
  }
145
145
  });
146
146
  }
147
+ /**
148
+ * Add an alias to the alsoKnownAs property on the document.
149
+ * If the alias is already present the operation is a no-op.
150
+ * @param documentId The id of the document to update.
151
+ * @param alias The alias to add. Must be a Url or Urn (typically another DID).
152
+ * @returns A promise that resolves when the alias has been added.
153
+ * @throws GeneralError if the alias is not a Url or Urn.
154
+ * @throws NotFoundError if the id can not be resolved.
155
+ */
156
+ async alsoKnownAsAdd(documentId, alias) {
157
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "documentId", documentId);
158
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "alias", alias);
159
+ await this.fetch("/:identity/alias", "POST", {
160
+ pathParams: {
161
+ identity: documentId
162
+ },
163
+ body: {
164
+ alias
165
+ }
166
+ });
167
+ }
168
+ /**
169
+ * Remove an alias from the alsoKnownAs property on the document.
170
+ * If the alias is not present the operation is a no-op.
171
+ * @param documentId The id of the document to update.
172
+ * @param alias The alias to remove. Must be a Url or Urn.
173
+ * @returns A promise that resolves when the alias has been removed.
174
+ * @throws GeneralError if the alias is not a Url or Urn.
175
+ * @throws NotFoundError if the id can not be resolved.
176
+ */
177
+ async alsoKnownAsRemove(documentId, alias) {
178
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "documentId", documentId);
179
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "alias", alias);
180
+ await this.fetch("/:identity/alias/:alias", "DELETE", {
181
+ pathParams: {
182
+ identity: documentId,
183
+ alias
184
+ }
185
+ });
186
+ }
147
187
  /**
148
188
  * Create a verifiable credential for a verification method.
149
189
  * @param verificationMethodId The verification method id to use.
@@ -152,6 +192,8 @@ export class IdentityRestClient extends BaseRestClient {
152
192
  * @param options Additional options for creating the verifiable credential.
153
193
  * @param options.revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.
154
194
  * @param options.expirationDate The date the verifiable credential is valid until.
195
+ * @param options.jwtHeaderFields Additional fields to include in the JWT header when creating the verifiable credential in jwt format.
196
+ * @param options.jwtPayloadFields Additional fields to include in the JWT payload when creating the verifiable credential in jwt format.
155
197
  * @returns The created verifiable credential and its token.
156
198
  * @throws NotFoundError if the id can not be resolved.
157
199
  */
@@ -171,30 +213,33 @@ export class IdentityRestClient extends BaseRestClient {
171
213
  credentialId: id,
172
214
  subject,
173
215
  revocationIndex: options?.revocationIndex,
174
- expirationDate: options?.expirationDate?.toISOString()
216
+ expirationDate: options?.expirationDate?.toISOString(),
217
+ jwtHeaderFields: options?.jwtHeaderFields,
218
+ jwtPayloadFields: options?.jwtPayloadFields
175
219
  }
176
220
  });
177
221
  return response.body;
178
222
  }
179
223
  /**
180
224
  * Verify a verifiable credential is valid.
181
- * @param credentialJwt The credential to verify.
225
+ * @param credential The credential to verify.
182
226
  * @returns The credential stored in the jwt and the revocation status.
183
227
  */
184
- async verifiableCredentialVerify(credentialJwt) {
185
- Guards.stringValue(IdentityRestClient.CLASS_NAME, "credentialJwt", credentialJwt);
186
- const response = await this.fetch("/verifiable-credential/verify", "POST", {
187
- query: {
188
- jwt: credentialJwt
189
- }
190
- });
228
+ async verifiableCredentialVerify(credential) {
229
+ if (Is.object(credential)) {
230
+ Guards.object(IdentityRestClient.CLASS_NAME, "credential", credential);
231
+ const response = await this.fetch("/verifiable-credential/verify/document", "POST", { body: credential });
232
+ return response.body;
233
+ }
234
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "credential", credential);
235
+ const response = await this.fetch("/verifiable-credential/verify", "GET", { query: { jwt: credential } });
191
236
  return response.body;
192
237
  }
193
238
  /**
194
239
  * Revoke verifiable credential.
195
240
  * @param issuerId The id of the document to update the revocation list for.
196
- * @param credentialIndex The revocation bitmap index revoke.
197
- * @returns Nothing.
241
+ * @param credentialIndex The revocation bitmap index to revoke.
242
+ * @returns A promise that resolves when the credential has been revoked.
198
243
  */
199
244
  async verifiableCredentialRevoke(issuerId, credentialIndex) {
200
245
  Guards.stringValue(IdentityRestClient.CLASS_NAME, "issuerId", issuerId);
@@ -209,8 +254,8 @@ export class IdentityRestClient extends BaseRestClient {
209
254
  /**
210
255
  * Unrevoke verifiable credential.
211
256
  * @param issuerId The id of the document to update the revocation list for.
212
- * @param credentialIndex The revocation bitmap index to un revoke.
213
- * @returns Nothing.
257
+ * @param credentialIndex The revocation bitmap index to unrevoke.
258
+ * @returns A promise that resolves when the credential has been unrevoked.
214
259
  */
215
260
  async verifiableCredentialUnrevoke(issuerId, credentialIndex) {
216
261
  Guards.stringValue(IdentityRestClient.CLASS_NAME, "issuerId", issuerId);
@@ -229,11 +274,14 @@ export class IdentityRestClient extends BaseRestClient {
229
274
  * @param contexts The contexts for the data stored in the verifiable credential.
230
275
  * @param types The types for the data stored in the verifiable credential.
231
276
  * @param verifiableCredentials The credentials to use for creating the presentation in jwt format.
232
- * @param expiresInMinutes The time in minutes for the presentation to expire.
277
+ * @param options Additional options for creating the verifiable presentation.
278
+ * @param options.expirationDate The date the verifiable presentation is valid until.
279
+ * @param options.jwtHeaderFields Additional fields to include in the JWT header when creating the verifiable presentation in jwt format.
280
+ * @param options.jwtPayloadFields Additional fields to include in the JWT payload when creating the verifiable presentation in jwt format.
233
281
  * @returns The created verifiable presentation and its token.
234
282
  * @throws NotFoundError if the id can not be resolved.
235
283
  */
236
- async verifiablePresentationCreate(verificationMethodId, presentationId, contexts, types, verifiableCredentials, expiresInMinutes) {
284
+ async verifiablePresentationCreate(verificationMethodId, presentationId, contexts, types, verifiableCredentials, options) {
237
285
  Guards.stringValue(IdentityRestClient.CLASS_NAME, "verificationMethodId", verificationMethodId);
238
286
  if (Is.array(types)) {
239
287
  Guards.arrayValue(IdentityRestClient.CLASS_NAME, "types", types);
@@ -242,8 +290,8 @@ export class IdentityRestClient extends BaseRestClient {
242
290
  Guards.stringValue(IdentityRestClient.CLASS_NAME, "types", types);
243
291
  }
244
292
  Guards.arrayValue(IdentityRestClient.CLASS_NAME, "verifiableCredentials", verifiableCredentials);
245
- if (!Is.undefined(expiresInMinutes)) {
246
- Guards.integer(IdentityRestClient.CLASS_NAME, "expiresInMinutes", expiresInMinutes);
293
+ if (!Is.undefined(options?.expirationDate)) {
294
+ Guards.date(IdentityRestClient.CLASS_NAME, "options.expirationDate", options?.expirationDate);
247
295
  }
248
296
  const idParts = DocumentHelper.parseId(verificationMethodId);
249
297
  const response = await this.fetch("/:identity/verifiable-presentation", "POST", {
@@ -256,21 +304,28 @@ export class IdentityRestClient extends BaseRestClient {
256
304
  contexts,
257
305
  types,
258
306
  verifiableCredentials,
259
- expiresInMinutes
307
+ expirationDate: options?.expirationDate?.toISOString(),
308
+ jwtHeaderFields: options?.jwtHeaderFields,
309
+ jwtPayloadFields: options?.jwtPayloadFields
260
310
  }
261
311
  });
262
312
  return response.body;
263
313
  }
264
314
  /**
265
315
  * Verify a verifiable presentation is valid.
266
- * @param presentationJwt The presentation to verify.
316
+ * @param presentation The presentation to verify.
267
317
  * @returns The presentation stored in the jwt and the revocation status.
268
318
  */
269
- async verifiablePresentationVerify(presentationJwt) {
270
- Guards.stringValue(IdentityRestClient.CLASS_NAME, "presentationJwt", presentationJwt);
319
+ async verifiablePresentationVerify(presentation) {
320
+ if (Is.object(presentation)) {
321
+ Guards.object(IdentityRestClient.CLASS_NAME, "presentation", presentation);
322
+ const response = await this.fetch("/verifiable-presentation/verify/document", "POST", { body: presentation });
323
+ return response.body;
324
+ }
325
+ Guards.stringValue(IdentityRestClient.CLASS_NAME, "presentation", presentation);
271
326
  const response = await this.fetch("/verifiable-presentation/verify", "POST", {
272
327
  query: {
273
- jwt: presentationJwt
328
+ jwt: presentation
274
329
  }
275
330
  });
276
331
  return response.body;
@@ -1 +1 @@
1
- {"version":3,"file":"identityRestClient.js","sourceRoot":"","sources":["../../src/identityRestClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EACN,cAAc,EAyBd,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,yBAAyB,EAOzB,UAAU,EACV,MAAM,6BAA6B,CAAC;AAErC;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,cAAc;IACrD;;OAEG;IACI,MAAM,CAAU,UAAU,wBAAwC;IAEzE;;;OAGG;IACH,YAAY,MAA6B;QACxC,KAAK,uBAA+B,MAAM,EAAE,UAAU,CAAC,CAAC;IACzD,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,kBAAkB,CAAC,UAAU,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,cAAc,CAAC,SAAkB;QAC7C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAChC,GAAG,EACH,MAAM,EACN;YACC,IAAI,EAAE;gBACL,SAAS;aACT;SACD,CACD,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,cAAc,CAAC,QAAgB;QAC3C,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC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License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport type { IBaseRestClientConfig, INoContentResponse } from \"@twin.org/api-models\";\nimport { Guards, Is } from \"@twin.org/core\";\nimport type { IJsonLdContextDefinitionRoot, IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport {\n\tDocumentHelper,\n\ttype IIdentityComponent,\n\ttype IIdentityCreateRequest,\n\ttype IIdentityCreateResponse,\n\ttype IIdentityProofCreateRequest,\n\ttype IIdentityProofCreateResponse,\n\ttype IIdentityProofVerifyRequest,\n\ttype IIdentityProofVerifyResponse,\n\ttype IIdentityRemoveRequest,\n\ttype IIdentityServiceCreateRequest,\n\ttype IIdentityServiceCreateResponse,\n\ttype IIdentityServiceRemoveRequest,\n\ttype IIdentityVerifiableCredentialCreateRequest,\n\ttype IIdentityVerifiableCredentialCreateResponse,\n\ttype IIdentityVerifiableCredentialRevokeRequest,\n\ttype IIdentityVerifiableCredentialUnrevokeRequest,\n\ttype IIdentityVerifiableCredentialVerifyRequest,\n\ttype IIdentityVerifiableCredentialVerifyResponse,\n\ttype IIdentityVerifiablePresentationCreateRequest,\n\ttype IIdentityVerifiablePresentationCreateResponse,\n\ttype IIdentityVerifiablePresentationVerifyRequest,\n\ttype IIdentityVerifiablePresentationVerifyResponse,\n\ttype IIdentityVerificationMethodCreateRequest,\n\ttype IIdentityVerificationMethodCreateResponse,\n\ttype IIdentityVerificationMethodRemoveRequest\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDidVerificationMethodType,\n\ttype IDidDocument,\n\ttype IDidDocumentVerificationMethod,\n\ttype IDidService,\n\ttype IDidVerifiableCredential,\n\ttype IDidVerifiablePresentation,\n\ttype IProof,\n\tProofTypes\n} from \"@twin.org/standards-w3c-did\";\n\n/**\n * Client for performing identity through to REST endpoints.\n */\nexport class IdentityRestClient extends BaseRestClient implements IIdentityComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityRestClient>();\n\n\t/**\n\t * Create a new instance of IdentityRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(nameof<IdentityRestClient>(), config, \"identity\");\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 IdentityRestClient.CLASS_NAME;\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 * @returns The created identity document.\n\t */\n\tpublic async identityCreate(namespace?: string): Promise<IDidDocument> {\n\t\tconst response = await this.fetch<IIdentityCreateRequest, IIdentityCreateResponse>(\n\t\t\t\"/\",\n\t\t\t\"POST\",\n\t\t\t{\n\t\t\t\tbody: {\n\t\t\t\t\tnamespace\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Remove an identity.\n\t * @param identity The id of the document to remove.\n\t * @returns Nothing.\n\t */\n\tpublic async identityRemove(identity: string): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(identity), identity);\n\t\tawait this.fetch<IIdentityRemoveRequest, INoContentResponse>(\"/:identity\", \"DELETE\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity\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 * @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): Promise<IDidDocumentVerificationMethod> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.arrayOneOf<DidVerificationMethodType>(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodType),\n\t\t\tverificationMethodType,\n\t\t\tObject.values(DidVerificationMethodType)\n\t\t);\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerificationMethodCreateRequest,\n\t\t\tIIdentityVerificationMethodCreateResponse\n\t\t>(\"/:identity/verification-method\", \"POST\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tverificationMethodType,\n\t\t\t\tverificationMethodId\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\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 * @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(verificationMethodId: string): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tawait this.fetch<IIdentityVerificationMethodRemoveRequest, INoContentResponse>(\n\t\t\t\"/:identity/verification-method/:verificationMethodId\",\n\t\t\t\"DELETE\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: idParts.id,\n\t\t\t\t\tverificationMethodId: idParts.fragment ?? \"\"\n\t\t\t\t}\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 * @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): Promise<IDidService> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(serviceId), serviceId);\n\t\tif (Is.array(serviceType)) {\n\t\t\tGuards.arrayValue<string>(IdentityRestClient.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t} else {\n\t\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t}\n\t\tif (Is.array(serviceEndpoint)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tIdentityRestClient.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(IdentityRestClient.CLASS_NAME, nameof(serviceEndpoint), serviceEndpoint);\n\t\t}\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityServiceCreateRequest,\n\t\t\tIIdentityServiceCreateResponse\n\t\t>(\"/:identity/service\", \"POST\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tserviceId,\n\t\t\t\ttype: serviceType,\n\t\t\t\tendpoint: serviceEndpoint\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Remove a service from the document.\n\t * @param serviceId The id of the service.\n\t * @returns Nothing.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async serviceRemove(serviceId: string): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(serviceId), serviceId);\n\n\t\tconst idParts = DocumentHelper.parseId(serviceId);\n\n\t\tawait this.fetch<IIdentityServiceRemoveRequest, INoContentResponse>(\n\t\t\t\"/:identity/service/:serviceId\",\n\t\t\t\"DELETE\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: idParts.id,\n\t\t\t\t\tserviceId: idParts.fragment ?? \"\"\n\t\t\t\t}\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 * @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}\n\t): Promise<{\n\t\tverifiableCredential: IDidVerifiableCredential;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(IdentityRestClient.CLASS_NAME, nameof(subject), subject);\n\t\tif (!Is.undefined(options?.revocationIndex)) {\n\t\t\tGuards.number(\n\t\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\t\tnameof(options?.revocationIndex),\n\t\t\t\toptions?.revocationIndex\n\t\t\t);\n\t\t}\n\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerifiableCredentialCreateRequest,\n\t\t\tIIdentityVerifiableCredentialCreateResponse\n\t\t>(\"/:identity/verifiable-credential\", \"POST\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity: idParts.id,\n\t\t\t\tverificationMethodId: idParts.fragment ?? \"\"\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tcredentialId: id,\n\t\t\t\tsubject,\n\t\t\t\trevocationIndex: options?.revocationIndex,\n\t\t\t\texpirationDate: options?.expirationDate?.toISOString()\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Verify a verifiable credential is valid.\n\t * @param credentialJwt The credential to verify.\n\t * @returns The credential stored in the jwt and the revocation status.\n\t */\n\tpublic async verifiableCredentialVerify(credentialJwt: string): Promise<{\n\t\trevoked: boolean;\n\t\tverifiableCredential?: IDidVerifiableCredential;\n\t}> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(credentialJwt), credentialJwt);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerifiableCredentialVerifyRequest,\n\t\t\tIIdentityVerifiableCredentialVerifyResponse\n\t\t>(\"/verifiable-credential/verify\", \"POST\", {\n\t\t\tquery: {\n\t\t\t\tjwt: credentialJwt\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Revoke verifiable credential.\n\t * @param issuerId The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index revoke.\n\t * @returns Nothing.\n\t */\n\tpublic async verifiableCredentialRevoke(\n\t\tissuerId: string,\n\t\tcredentialIndex: number\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(issuerId), issuerId);\n\t\tGuards.integer(IdentityRestClient.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\tawait this.fetch<IIdentityVerifiableCredentialRevokeRequest, INoContentResponse>(\n\t\t\t\"/:identity/verifiable-credential/revoke/:revocationIndex\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: issuerId,\n\t\t\t\t\trevocationIndex: credentialIndex.toString()\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Unrevoke verifiable credential.\n\t * @param issuerId The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index to un revoke.\n\t * @returns Nothing.\n\t */\n\tpublic async verifiableCredentialUnrevoke(\n\t\tissuerId: string,\n\t\tcredentialIndex: number\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(issuerId), issuerId);\n\t\tGuards.integer(IdentityRestClient.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\tawait this.fetch<IIdentityVerifiableCredentialUnrevokeRequest, INoContentResponse>(\n\t\t\t\"/:identity/verifiable-credential/unrevoke/:revocationIndex\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: issuerId,\n\t\t\t\t\trevocationIndex: credentialIndex.toString()\n\t\t\t\t}\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 expiresInMinutes The time in minutes for the presentation to expire.\n\t * @returns The created verifiable presentation and its token.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async 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\texpiresInMinutes?: number\n\t): Promise<{\n\t\tverifiablePresentation: IDidVerifiablePresentation;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tif (Is.array(types)) {\n\t\t\tGuards.arrayValue(IdentityRestClient.CLASS_NAME, nameof(types), types);\n\t\t} else if (Is.string(types)) {\n\t\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(types), types);\n\t\t}\n\t\tGuards.arrayValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verifiableCredentials),\n\t\t\tverifiableCredentials\n\t\t);\n\t\tif (!Is.undefined(expiresInMinutes)) {\n\t\t\tGuards.integer(IdentityRestClient.CLASS_NAME, nameof(expiresInMinutes), expiresInMinutes);\n\t\t}\n\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerifiablePresentationCreateRequest,\n\t\t\tIIdentityVerifiablePresentationCreateResponse\n\t\t>(\"/:identity/verifiable-presentation\", \"POST\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity: idParts.id,\n\t\t\t\tverificationMethodId: idParts.fragment ?? \"\"\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tpresentationId,\n\t\t\t\tcontexts,\n\t\t\t\ttypes,\n\t\t\t\tverifiableCredentials,\n\t\t\t\texpiresInMinutes\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Verify a verifiable presentation is valid.\n\t * @param presentationJwt The presentation to verify.\n\t * @returns The presentation stored in the jwt and the revocation status.\n\t */\n\tpublic async verifiablePresentationVerify(presentationJwt: string): Promise<{\n\t\trevoked: boolean;\n\t\tverifiablePresentation?: IDidVerifiablePresentation;\n\t\tissuers?: IDidDocument[];\n\t}> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(presentationJwt), presentationJwt);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerifiablePresentationVerifyRequest,\n\t\t\tIIdentityVerifiablePresentationVerifyResponse\n\t\t>(\"/verifiable-presentation/verify\", \"POST\", {\n\t\t\tquery: {\n\t\t\t\tjwt: presentationJwt\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\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 * @returns The proof.\n\t */\n\tpublic async proofCreate(\n\t\tverificationMethodId: string,\n\t\tproofType: ProofTypes,\n\t\tunsecureDocument: IJsonLdNodeObject\n\t): Promise<IProof> {\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.arrayOneOf<ProofTypes>(\n\t\t\tIdentityRestClient.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\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(unsecureDocument),\n\t\t\tunsecureDocument\n\t\t);\n\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tconst response = await this.fetch<IIdentityProofCreateRequest, IIdentityProofCreateResponse>(\n\t\t\t\"/:identity/proof\",\n\t\t\t\"POST\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: idParts.id,\n\t\t\t\t\tverificationMethodId: idParts.fragment ?? \"\"\n\t\t\t\t},\n\t\t\t\tbody: {\n\t\t\t\t\tdocument: unsecureDocument,\n\t\t\t\t\tproofType\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body;\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>(IdentityRestClient.CLASS_NAME, nameof(document), document);\n\t\tGuards.object<IProof>(IdentityRestClient.CLASS_NAME, nameof(proof), proof);\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(proof.verificationMethod),\n\t\t\tproof.verificationMethod\n\t\t);\n\n\t\tconst response = await this.fetch<IIdentityProofVerifyRequest, IIdentityProofVerifyResponse>(\n\t\t\t\"/proof/verify\",\n\t\t\t\"POST\",\n\t\t\t{\n\t\t\t\tbody: {\n\t\t\t\t\tdocument,\n\t\t\t\t\tproof\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body.verified;\n\t}\n}\n"]}
1
+ {"version":3,"file":"identityRestClient.js","sourceRoot":"","sources":["../../src/identityRestClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EACN,cAAc,EA6Bd,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,yBAAyB,EAOzB,UAAU,EACV,MAAM,6BAA6B,CAAC;AAErC;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,cAAc;IACrD;;OAEG;IACI,MAAM,CAAU,UAAU,wBAAwC;IAEzE;;;OAGG;IACH,YAAY,MAA6B;QACxC,KAAK,uBAA+B,MAAM,EAAE,UAAU,CAAC,CAAC;IACzD,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,kBAAkB,CAAC,UAAU,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,cAAc,CAAC,SAAkB;QAC7C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAChC,GAAG,EACH,MAAM,EACN;YACC,IAAI,EAAE;gBACL,SAAS;aACT;SACD,CACD,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,cAAc,CAAC,QAAgB;QAC3C,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,UAAU,cAAoB,QAAQ,CAAC,CAAC;QAC9E,MAAM,IAAI,CAAC,KAAK,CAA6C,YAAY,EAAE,QAAQ,EAAE;YACpF,UAAU,EAAE;gBACX,QAAQ;aACR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,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAChC,eAAe,EACf,MAAM,EACN;YACC,IAAI,EAAE;gBACL,QAAQ;gBACR,KAAK;aACL;SACD,CACD,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC/B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport type { IBaseRestClientConfig, INoContentResponse } from \"@twin.org/api-models\";\nimport { Guards, Is } from \"@twin.org/core\";\nimport type { IJsonLdContextDefinitionRoot, IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport {\n\tDocumentHelper,\n\ttype IIdentityVerifiablePresentationVerifyDocumentRequest,\n\ttype IIdentityAlsoKnownAsCreateRequest,\n\ttype IIdentityAlsoKnownAsRemoveRequest,\n\ttype IIdentityComponent,\n\ttype IIdentityCreateRequest,\n\ttype IIdentityCreateResponse,\n\ttype IIdentityProofCreateRequest,\n\ttype IIdentityProofCreateResponse,\n\ttype IIdentityProofVerifyRequest,\n\ttype IIdentityProofVerifyResponse,\n\ttype IIdentityRemoveRequest,\n\ttype IIdentityServiceCreateRequest,\n\ttype IIdentityServiceCreateResponse,\n\ttype IIdentityServiceRemoveRequest,\n\ttype IIdentityVerifiableCredentialCreateRequest,\n\ttype IIdentityVerifiableCredentialCreateResponse,\n\ttype IIdentityVerifiableCredentialRevokeRequest,\n\ttype IIdentityVerifiableCredentialUnrevokeRequest,\n\ttype IIdentityVerifiableCredentialVerifyDocumentRequest,\n\ttype IIdentityVerifiableCredentialVerifyRequest,\n\ttype IIdentityVerifiableCredentialVerifyResponse,\n\ttype IIdentityVerifiablePresentationCreateRequest,\n\ttype IIdentityVerifiablePresentationCreateResponse,\n\ttype IIdentityVerifiablePresentationVerifyRequest,\n\ttype IIdentityVerifiablePresentationVerifyResponse,\n\ttype IIdentityVerificationMethodCreateRequest,\n\ttype IIdentityVerificationMethodCreateResponse,\n\ttype IIdentityVerificationMethodRemoveRequest\n} from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDidVerificationMethodType,\n\ttype IDidDocument,\n\ttype IDidDocumentVerificationMethod,\n\ttype IDidService,\n\ttype IDidVerifiableCredential,\n\ttype IDidVerifiablePresentation,\n\ttype IProof,\n\tProofTypes\n} from \"@twin.org/standards-w3c-did\";\n\n/**\n * Client for performing identity through to REST endpoints.\n */\nexport class IdentityRestClient extends BaseRestClient implements IIdentityComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IdentityRestClient>();\n\n\t/**\n\t * Create a new instance of IdentityRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(nameof<IdentityRestClient>(), config, \"identity\");\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 IdentityRestClient.CLASS_NAME;\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 * @returns The created identity document.\n\t */\n\tpublic async identityCreate(namespace?: string): Promise<IDidDocument> {\n\t\tconst response = await this.fetch<IIdentityCreateRequest, IIdentityCreateResponse>(\n\t\t\t\"/\",\n\t\t\t\"POST\",\n\t\t\t{\n\t\t\t\tbody: {\n\t\t\t\t\tnamespace\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Remove an identity.\n\t * @param identity The id of the document to remove.\n\t * @returns A promise that resolves when the identity has been removed.\n\t */\n\tpublic async identityRemove(identity: string): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(identity), identity);\n\t\tawait this.fetch<IIdentityRemoveRequest, INoContentResponse>(\"/:identity\", \"DELETE\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity\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 * @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): Promise<IDidDocumentVerificationMethod> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.arrayOneOf<DidVerificationMethodType>(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodType),\n\t\t\tverificationMethodType,\n\t\t\tObject.values(DidVerificationMethodType)\n\t\t);\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerificationMethodCreateRequest,\n\t\t\tIIdentityVerificationMethodCreateResponse\n\t\t>(\"/:identity/verification-method\", \"POST\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tverificationMethodType,\n\t\t\t\tverificationMethodId\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\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 * @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(verificationMethodId: string): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tawait this.fetch<IIdentityVerificationMethodRemoveRequest, INoContentResponse>(\n\t\t\t\"/:identity/verification-method/:verificationMethodId\",\n\t\t\t\"DELETE\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: idParts.id,\n\t\t\t\t\tverificationMethodId: idParts.fragment ?? \"\"\n\t\t\t\t}\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 * @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): Promise<IDidService> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(identity), identity);\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(serviceId), serviceId);\n\t\tif (Is.array(serviceType)) {\n\t\t\tGuards.arrayValue<string>(IdentityRestClient.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t} else {\n\t\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(serviceType), serviceType);\n\t\t}\n\t\tif (Is.array(serviceEndpoint)) {\n\t\t\tGuards.arrayValue<string>(\n\t\t\t\tIdentityRestClient.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(IdentityRestClient.CLASS_NAME, nameof(serviceEndpoint), serviceEndpoint);\n\t\t}\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityServiceCreateRequest,\n\t\t\tIIdentityServiceCreateResponse\n\t\t>(\"/:identity/service\", \"POST\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tserviceId,\n\t\t\t\ttype: serviceType,\n\t\t\t\tendpoint: serviceEndpoint\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Remove a service from the document.\n\t * @param serviceId The id of the service.\n\t * @returns A promise that resolves when the service has been removed.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async serviceRemove(serviceId: string): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(serviceId), serviceId);\n\n\t\tconst idParts = DocumentHelper.parseId(serviceId);\n\n\t\tawait this.fetch<IIdentityServiceRemoveRequest, INoContentResponse>(\n\t\t\t\"/:identity/service/:serviceId\",\n\t\t\t\"DELETE\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: idParts.id,\n\t\t\t\t\tserviceId: idParts.fragment ?? \"\"\n\t\t\t\t}\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 * @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(documentId: string, alias: string): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(alias), alias);\n\n\t\tawait this.fetch<IIdentityAlsoKnownAsCreateRequest, INoContentResponse>(\n\t\t\t\"/:identity/alias\",\n\t\t\t\"POST\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: documentId\n\t\t\t\t},\n\t\t\t\tbody: {\n\t\t\t\t\talias\n\t\t\t\t}\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 * @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(documentId: string, alias: string): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(documentId), documentId);\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(alias), alias);\n\n\t\tawait this.fetch<IIdentityAlsoKnownAsRemoveRequest, INoContentResponse>(\n\t\t\t\"/:identity/alias/:alias\",\n\t\t\t\"DELETE\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: documentId,\n\t\t\t\t\talias\n\t\t\t\t}\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 * @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): Promise<{\n\t\tverifiableCredential: IDidVerifiableCredential;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.object<IJsonLdNodeObject>(IdentityRestClient.CLASS_NAME, nameof(subject), subject);\n\t\tif (!Is.undefined(options?.revocationIndex)) {\n\t\t\tGuards.number(\n\t\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\t\tnameof(options?.revocationIndex),\n\t\t\t\toptions?.revocationIndex\n\t\t\t);\n\t\t}\n\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerifiableCredentialCreateRequest,\n\t\t\tIIdentityVerifiableCredentialCreateResponse\n\t\t>(\"/:identity/verifiable-credential\", \"POST\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity: idParts.id,\n\t\t\t\tverificationMethodId: idParts.fragment ?? \"\"\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tcredentialId: id,\n\t\t\t\tsubject,\n\t\t\t\trevocationIndex: options?.revocationIndex,\n\t\t\t\texpirationDate: options?.expirationDate?.toISOString(),\n\t\t\t\tjwtHeaderFields: options?.jwtHeaderFields,\n\t\t\t\tjwtPayloadFields: options?.jwtPayloadFields\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\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.object<IDidVerifiableCredential>(\n\t\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\t\tnameof(credential),\n\t\t\t\tcredential\n\t\t\t);\n\t\t\tconst response = await this.fetch<\n\t\t\t\tIIdentityVerifiableCredentialVerifyDocumentRequest,\n\t\t\t\tIIdentityVerifiableCredentialVerifyResponse\n\t\t\t>(\"/verifiable-credential/verify/document\", \"POST\", { body: credential });\n\n\t\t\treturn response.body;\n\t\t}\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(credential), credential);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerifiableCredentialVerifyRequest,\n\t\t\tIIdentityVerifiableCredentialVerifyResponse\n\t\t>(\"/verifiable-credential/verify\", \"GET\", { query: { jwt: credential } });\n\n\t\treturn response.body;\n\t}\n\n\t/**\n\t * Revoke verifiable credential.\n\t * @param issuerId The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index to revoke.\n\t * @returns A promise that resolves when the credential has been revoked.\n\t */\n\tpublic async verifiableCredentialRevoke(\n\t\tissuerId: string,\n\t\tcredentialIndex: number\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(issuerId), issuerId);\n\t\tGuards.integer(IdentityRestClient.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\tawait this.fetch<IIdentityVerifiableCredentialRevokeRequest, INoContentResponse>(\n\t\t\t\"/:identity/verifiable-credential/revoke/:revocationIndex\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: issuerId,\n\t\t\t\t\trevocationIndex: credentialIndex.toString()\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Unrevoke verifiable credential.\n\t * @param issuerId The id of the document to update the revocation list for.\n\t * @param credentialIndex The revocation bitmap index to unrevoke.\n\t * @returns A promise that resolves when the credential has been unrevoked.\n\t */\n\tpublic async verifiableCredentialUnrevoke(\n\t\tissuerId: string,\n\t\tcredentialIndex: number\n\t): Promise<void> {\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(issuerId), issuerId);\n\t\tGuards.integer(IdentityRestClient.CLASS_NAME, nameof(credentialIndex), credentialIndex);\n\n\t\tawait this.fetch<IIdentityVerifiableCredentialUnrevokeRequest, INoContentResponse>(\n\t\t\t\"/:identity/verifiable-credential/unrevoke/:revocationIndex\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: issuerId,\n\t\t\t\t\trevocationIndex: credentialIndex.toString()\n\t\t\t\t}\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 Additional fields to include in the JWT payload when creating the verifiable presentation in jwt format.\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): Promise<{\n\t\tverifiablePresentation: IDidVerifiablePresentation;\n\t\tjwt: string;\n\t}> {\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tif (Is.array(types)) {\n\t\t\tGuards.arrayValue(IdentityRestClient.CLASS_NAME, nameof(types), types);\n\t\t} else if (Is.string(types)) {\n\t\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(types), types);\n\t\t}\n\t\tGuards.arrayValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verifiableCredentials),\n\t\t\tverifiableCredentials\n\t\t);\n\t\tif (!Is.undefined(options?.expirationDate)) {\n\t\t\tGuards.date(\n\t\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\t\tnameof(options.expirationDate),\n\t\t\t\toptions?.expirationDate\n\t\t\t);\n\t\t}\n\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerifiablePresentationCreateRequest,\n\t\t\tIIdentityVerifiablePresentationCreateResponse\n\t\t>(\"/:identity/verifiable-presentation\", \"POST\", {\n\t\t\tpathParams: {\n\t\t\t\tidentity: idParts.id,\n\t\t\t\tverificationMethodId: idParts.fragment ?? \"\"\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tpresentationId,\n\t\t\t\tcontexts,\n\t\t\t\ttypes,\n\t\t\t\tverifiableCredentials,\n\t\t\t\texpirationDate: options?.expirationDate?.toISOString(),\n\t\t\t\tjwtHeaderFields: options?.jwtHeaderFields,\n\t\t\t\tjwtPayloadFields: options?.jwtPayloadFields\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\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\tif (Is.object(presentation)) {\n\t\t\tGuards.object<IDidVerifiablePresentation>(\n\t\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\t\tnameof(presentation),\n\t\t\t\tpresentation\n\t\t\t);\n\t\t\tconst response = await this.fetch<\n\t\t\t\tIIdentityVerifiablePresentationVerifyDocumentRequest,\n\t\t\t\tIIdentityVerifiablePresentationVerifyResponse\n\t\t\t>(\"/verifiable-presentation/verify/document\", \"POST\", { body: presentation });\n\n\t\t\treturn response.body;\n\t\t}\n\n\t\tGuards.stringValue(IdentityRestClient.CLASS_NAME, nameof(presentation), presentation);\n\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityVerifiablePresentationVerifyRequest,\n\t\t\tIIdentityVerifiablePresentationVerifyResponse\n\t\t>(\"/verifiable-presentation/verify\", \"POST\", {\n\t\t\tquery: {\n\t\t\t\tjwt: presentation\n\t\t\t}\n\t\t});\n\n\t\treturn response.body;\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 * @returns The proof.\n\t */\n\tpublic async proofCreate(\n\t\tverificationMethodId: string,\n\t\tproofType: ProofTypes,\n\t\tunsecureDocument: IJsonLdNodeObject\n\t): Promise<IProof> {\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(verificationMethodId),\n\t\t\tverificationMethodId\n\t\t);\n\t\tGuards.arrayOneOf<ProofTypes>(\n\t\t\tIdentityRestClient.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\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(unsecureDocument),\n\t\t\tunsecureDocument\n\t\t);\n\n\t\tconst idParts = DocumentHelper.parseId(verificationMethodId);\n\n\t\tconst response = await this.fetch<IIdentityProofCreateRequest, IIdentityProofCreateResponse>(\n\t\t\t\"/:identity/proof\",\n\t\t\t\"POST\",\n\t\t\t{\n\t\t\t\tpathParams: {\n\t\t\t\t\tidentity: idParts.id,\n\t\t\t\t\tverificationMethodId: idParts.fragment ?? \"\"\n\t\t\t\t},\n\t\t\t\tbody: {\n\t\t\t\t\tdocument: unsecureDocument,\n\t\t\t\t\tproofType\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body;\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>(IdentityRestClient.CLASS_NAME, nameof(document), document);\n\t\tGuards.object<IProof>(IdentityRestClient.CLASS_NAME, nameof(proof), proof);\n\t\tGuards.stringValue(\n\t\t\tIdentityRestClient.CLASS_NAME,\n\t\t\tnameof(proof.verificationMethod),\n\t\t\tproof.verificationMethod\n\t\t);\n\n\t\tconst response = await this.fetch<IIdentityProofVerifyRequest, IIdentityProofVerifyResponse>(\n\t\t\t\"/proof/verify\",\n\t\t\t\"POST\",\n\t\t\t{\n\t\t\t\tbody: {\n\t\t\t\t\tdocument,\n\t\t\t\t\tproof\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body.verified;\n\t}\n}\n"]}
@@ -3,7 +3,7 @@ import { type IBaseRestClientConfig } from "@twin.org/api-models";
3
3
  import type { IJsonLdDocument } from "@twin.org/data-json-ld";
4
4
  import type { IIdentityProfileComponent } from "@twin.org/identity-models";
5
5
  /**
6
- * Client for performing identity through to REST endpoints.
6
+ * Client for performing identity profile operations through REST endpoints.
7
7
  */
8
8
  export declare class IdentityProfileRestClient<T extends IJsonLdDocument = IJsonLdDocument, U extends IJsonLdDocument = IJsonLdDocument> extends BaseRestClient implements IIdentityProfileComponent<T, U> {
9
9
  /**
@@ -24,7 +24,7 @@ export declare class IdentityProfileRestClient<T extends IJsonLdDocument = IJson
24
24
  * Create the profile properties for an identity.
25
25
  * @param publicProfile The public profile data as JSON-LD.
26
26
  * @param privateProfile The private profile data as JSON-LD.
27
- * @returns Nothing.
27
+ * @returns A promise that resolves when the profile has been created.
28
28
  */
29
29
  create(publicProfile?: T, privateProfile?: U): Promise<void>;
30
30
  /**
@@ -49,12 +49,12 @@ export declare class IdentityProfileRestClient<T extends IJsonLdDocument = IJson
49
49
  * Update the profile properties of an identity.
50
50
  * @param publicProfile The public profile data as JSON-LD.
51
51
  * @param privateProfile The private profile data as JSON-LD.
52
- * @returns Nothing.
52
+ * @returns A promise that resolves when the profile has been updated.
53
53
  */
54
54
  update(publicProfile?: T, privateProfile?: U): Promise<void>;
55
55
  /**
56
56
  * Delete the profile for an identity.
57
- * @returns Nothing.
57
+ * @returns A promise that resolves when the profile has been removed.
58
58
  */
59
59
  remove(): Promise<void>;
60
60
  /**
@@ -3,7 +3,7 @@ import type { IBaseRestClientConfig } from "@twin.org/api-models";
3
3
  import type { IIdentityResolverComponent } from "@twin.org/identity-models";
4
4
  import type { IDidDocument } from "@twin.org/standards-w3c-did";
5
5
  /**
6
- * Client for performing identity through to REST endpoints.
6
+ * Client for performing identity resolution through REST endpoints.
7
7
  */
8
8
  export declare class IdentityResolverRestClient extends BaseRestClient implements IIdentityResolverComponent {
9
9
  /**