@twin.org/identity-rest-client 0.0.2-next.9 → 0.0.3-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.
@@ -0,0 +1,125 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { BaseRestClient } from "@twin.org/api-core";
4
+ import { HttpParameterHelper } from "@twin.org/api-models";
5
+ import { Coerce, Guards } from "@twin.org/core";
6
+ /**
7
+ * Client for performing identity through to REST endpoints.
8
+ */
9
+ export class IdentityProfileRestClient extends BaseRestClient {
10
+ /**
11
+ * Runtime name for the class.
12
+ */
13
+ static CLASS_NAME = "IdentityProfileRestClient";
14
+ /**
15
+ * Create a new instance of IdentityProfileRestClient.
16
+ * @param config The configuration for the client.
17
+ */
18
+ constructor(config) {
19
+ super("IdentityProfileRestClient", config, "identity/profile");
20
+ }
21
+ /**
22
+ * Returns the class name of the component.
23
+ * @returns The class name of the component.
24
+ */
25
+ className() {
26
+ return IdentityProfileRestClient.CLASS_NAME;
27
+ }
28
+ /**
29
+ * Create the profile properties for an identity.
30
+ * @param publicProfile The public profile data as JSON-LD.
31
+ * @param privateProfile The private profile data as JSON-LD.
32
+ * @returns Nothing.
33
+ */
34
+ async create(publicProfile, privateProfile) {
35
+ await this.fetch("", "POST", {
36
+ body: {
37
+ publicProfile,
38
+ privateProfile
39
+ }
40
+ });
41
+ }
42
+ /**
43
+ * Get the profile properties for an identity.
44
+ * @param publicPropertyNames The public properties to get for the profile, defaults to all.
45
+ * @param privatePropertyNames The private properties to get for the profile, defaults to all.
46
+ * @returns The identity and the items properties.
47
+ */
48
+ async get(publicPropertyNames, privatePropertyNames) {
49
+ const response = await this.fetch("/", "GET", {
50
+ query: {
51
+ publicPropertyNames: HttpParameterHelper.arrayToString(publicPropertyNames),
52
+ privatePropertyNames: HttpParameterHelper.arrayToString(privatePropertyNames)
53
+ }
54
+ });
55
+ return {
56
+ identity: response.body.identity,
57
+ publicProfile: response.body.publicProfile,
58
+ privateProfile: response.body.privateProfile
59
+ };
60
+ }
61
+ /**
62
+ * Get the public profile properties for an identity.
63
+ * @param identity The identity to perform the profile operation on.
64
+ * @param propertyNames The public properties to get for the profile, defaults to all.
65
+ * @returns The items properties.
66
+ */
67
+ async getPublic(identity, propertyNames) {
68
+ Guards.string(IdentityProfileRestClient.CLASS_NAME, "identity", identity);
69
+ const response = await this.fetch("/:identity/public", "GET", {
70
+ pathParams: {
71
+ identity
72
+ },
73
+ query: {
74
+ propertyNames: HttpParameterHelper.arrayToString(propertyNames)
75
+ }
76
+ });
77
+ return response.body;
78
+ }
79
+ /**
80
+ * Update the profile properties of an identity.
81
+ * @param publicProfile The public profile data as JSON-LD.
82
+ * @param privateProfile The private profile data as JSON-LD.
83
+ * @returns Nothing.
84
+ */
85
+ async update(publicProfile, privateProfile) {
86
+ await this.fetch("/", "PUT", {
87
+ body: {
88
+ publicProfile,
89
+ privateProfile
90
+ }
91
+ });
92
+ }
93
+ /**
94
+ * Delete the profile for an identity.
95
+ * @returns Nothing.
96
+ */
97
+ async remove() {
98
+ await this.fetch("/", "DELETE");
99
+ }
100
+ /**
101
+ * Get a list of the requested identities.
102
+ * @param publicFilters The filters to apply to the identities public profiles.
103
+ * @param publicPropertyNames The public properties to get for the profile, defaults to all.
104
+ * @param cursor The cursor for paged requests.
105
+ * @param limit The maximum number of items in a page.
106
+ * @returns The list of items and cursor for paging.
107
+ */
108
+ async list(publicFilters, publicPropertyNames, cursor, limit) {
109
+ const response = await this.fetch("/query", "GET", {
110
+ query: {
111
+ publicFilters: HttpParameterHelper.arrayToString(
112
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
113
+ publicFilters?.map(f => `${f.propertyName}:${f.propertyValue}`)),
114
+ publicPropertyNames: HttpParameterHelper.arrayToString(publicPropertyNames),
115
+ cursor,
116
+ limit: Coerce.string(limit)
117
+ }
118
+ });
119
+ return {
120
+ items: response.body.items,
121
+ cursor: response.body.cursor
122
+ };
123
+ }
124
+ }
125
+ //# sourceMappingURL=identityProfileRestClient.js.map
@@ -0,0 +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,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C,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 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"]}
@@ -0,0 +1,42 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { BaseRestClient } from "@twin.org/api-core";
4
+ import { Urn } from "@twin.org/core";
5
+ /**
6
+ * Client for performing identity through to REST endpoints.
7
+ */
8
+ export class IdentityResolverRestClient extends BaseRestClient {
9
+ /**
10
+ * Runtime name for the class.
11
+ */
12
+ static CLASS_NAME = "IdentityResolverRestClient";
13
+ /**
14
+ * Create a new instance of IdentityResolverRestClient.
15
+ * @param config The configuration for the client.
16
+ */
17
+ constructor(config) {
18
+ super("IdentityResolverRestClient", config, "identity");
19
+ }
20
+ /**
21
+ * Returns the class name of the component.
22
+ * @returns The class name of the component.
23
+ */
24
+ className() {
25
+ return IdentityResolverRestClient.CLASS_NAME;
26
+ }
27
+ /**
28
+ * Resolve an identity.
29
+ * @param documentId The id of the document to resolve.
30
+ * @returns The resolved document.
31
+ */
32
+ async identityResolve(documentId) {
33
+ Urn.guard(IdentityResolverRestClient.CLASS_NAME, "documentId", documentId);
34
+ const response = await this.fetch("/:identity", "GET", {
35
+ pathParams: {
36
+ identity: documentId
37
+ }
38
+ });
39
+ return response.body;
40
+ }
41
+ }
42
+ //# sourceMappingURL=identityResolverRestClient.js.map
@@ -0,0 +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,26 +1,31 @@
1
- import { BaseRestClient } from '@twin.org/api-core';
2
- import { Guards, Is, Coerce, Urn } from '@twin.org/core';
3
- import { DocumentHelper } from '@twin.org/identity-models';
4
- import { DidVerificationMethodType, ProofTypes } from '@twin.org/standards-w3c-did';
5
- import { HttpParameterHelper } from '@twin.org/api-models';
6
-
7
1
  // Copyright 2024 IOTA Stiftung.
8
2
  // SPDX-License-Identifier: Apache-2.0.
3
+ import { BaseRestClient } from "@twin.org/api-core";
4
+ import { Guards, Is } from "@twin.org/core";
5
+ import { DocumentHelper } from "@twin.org/identity-models";
6
+ import { DidVerificationMethodType, ProofTypes } from "@twin.org/standards-w3c-did";
9
7
  /**
10
8
  * Client for performing identity through to REST endpoints.
11
9
  */
12
- class IdentityRestClient extends BaseRestClient {
10
+ export class IdentityRestClient extends BaseRestClient {
13
11
  /**
14
12
  * Runtime name for the class.
15
13
  */
16
14
  static CLASS_NAME = "IdentityRestClient";
17
15
  /**
18
- * Create a new instance of IdentityClient.
16
+ * Create a new instance of IdentityRestClient.
19
17
  * @param config The configuration for the client.
20
18
  */
21
19
  constructor(config) {
22
20
  super("IdentityRestClient", config, "identity");
23
21
  }
22
+ /**
23
+ * Returns the class name of the component.
24
+ * @returns The class name of the component.
25
+ */
26
+ className() {
27
+ return IdentityRestClient.CLASS_NAME;
28
+ }
24
29
  /**
25
30
  * Create a new identity.
26
31
  * @param namespace The namespace of the connector to use for the identity, defaults to service configured namespace.
@@ -313,153 +318,4 @@ class IdentityRestClient extends BaseRestClient {
313
318
  return response.body.verified;
314
319
  }
315
320
  }
316
-
317
- // Copyright 2024 IOTA Stiftung.
318
- // SPDX-License-Identifier: Apache-2.0.
319
- /**
320
- * Client for performing identity through to REST endpoints.
321
- */
322
- class IdentityProfileRestClient extends BaseRestClient {
323
- /**
324
- * Runtime name for the class.
325
- */
326
- static CLASS_NAME = "IdentityProfileRestClient";
327
- /**
328
- * Create a new instance of IdentityClient.
329
- * @param config The configuration for the client.
330
- */
331
- constructor(config) {
332
- super("IdentityProfileRestClient", config, "identity/profile");
333
- }
334
- /**
335
- * Create the profile properties for an identity.
336
- * @param publicProfile The public profile data as JSON-LD.
337
- * @param privateProfile The private profile data as JSON-LD.
338
- * @returns Nothing.
339
- */
340
- async create(publicProfile, privateProfile) {
341
- await this.fetch("", "POST", {
342
- body: {
343
- publicProfile,
344
- privateProfile
345
- }
346
- });
347
- }
348
- /**
349
- * Get the profile properties for an identity.
350
- * @param publicPropertyNames The public properties to get for the profile, defaults to all.
351
- * @param privatePropertyNames The private properties to get for the profile, defaults to all.
352
- * @returns The identity and the items properties.
353
- */
354
- async get(publicPropertyNames, privatePropertyNames) {
355
- const response = await this.fetch("/", "GET", {
356
- query: {
357
- publicPropertyNames: HttpParameterHelper.arrayToString(publicPropertyNames),
358
- privatePropertyNames: HttpParameterHelper.arrayToString(privatePropertyNames)
359
- }
360
- });
361
- return {
362
- identity: response.body.identity,
363
- publicProfile: response.body.publicProfile,
364
- privateProfile: response.body.privateProfile
365
- };
366
- }
367
- /**
368
- * Get the public profile properties for an identity.
369
- * @param identity The identity to perform the profile operation on.
370
- * @param propertyNames The public properties to get for the profile, defaults to all.
371
- * @returns The items properties.
372
- */
373
- async getPublic(identity, propertyNames) {
374
- Guards.string(IdentityProfileRestClient.CLASS_NAME, "identity", identity);
375
- const response = await this.fetch("/:identity/public", "GET", {
376
- pathParams: {
377
- identity
378
- },
379
- query: {
380
- propertyNames: HttpParameterHelper.arrayToString(propertyNames)
381
- }
382
- });
383
- return response.body;
384
- }
385
- /**
386
- * Update the profile properties of an identity.
387
- * @param publicProfile The public profile data as JSON-LD.
388
- * @param privateProfile The private profile data as JSON-LD.
389
- * @returns Nothing.
390
- */
391
- async update(publicProfile, privateProfile) {
392
- await this.fetch("/", "PUT", {
393
- body: {
394
- publicProfile,
395
- privateProfile
396
- }
397
- });
398
- }
399
- /**
400
- * Delete the profile for an identity.
401
- * @returns Nothing.
402
- */
403
- async remove() {
404
- await this.fetch("/", "DELETE");
405
- }
406
- /**
407
- * Get a list of the requested identities.
408
- * @param publicFilters The filters to apply to the identities public profiles.
409
- * @param publicPropertyNames The public properties to get for the profile, defaults to all.
410
- * @param cursor The cursor for paged requests.
411
- * @param limit The maximum number of items in a page.
412
- * @returns The list of items and cursor for paging.
413
- */
414
- async list(publicFilters, publicPropertyNames, cursor, limit) {
415
- const response = await this.fetch("/query", "GET", {
416
- query: {
417
- publicFilters: HttpParameterHelper.arrayToString(
418
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
419
- publicFilters?.map(f => `${f.propertyName}:${f.propertyValue}`)),
420
- publicPropertyNames: HttpParameterHelper.arrayToString(publicPropertyNames),
421
- cursor,
422
- limit: Coerce.string(limit)
423
- }
424
- });
425
- return {
426
- items: response.body.items,
427
- cursor: response.body.cursor
428
- };
429
- }
430
- }
431
-
432
- // Copyright 2024 IOTA Stiftung.
433
- // SPDX-License-Identifier: Apache-2.0.
434
- /**
435
- * Client for performing identity through to REST endpoints.
436
- */
437
- class IdentityResolverRestClient extends BaseRestClient {
438
- /**
439
- * Runtime name for the class.
440
- */
441
- static CLASS_NAME = "IdentityResolverRestClient";
442
- /**
443
- * Create a new instance of IdentityClient.
444
- * @param config The configuration for the client.
445
- */
446
- constructor(config) {
447
- super("IdentityResolverRestClient", config, "identity");
448
- }
449
- /**
450
- * Resolve an identity.
451
- * @param documentId The id of the document to resolve.
452
- * @returns The resolved document.
453
- */
454
- async identityResolve(documentId) {
455
- Urn.guard(IdentityResolverRestClient.CLASS_NAME, "documentId", documentId);
456
- const response = await this.fetch("/:identity", "GET", {
457
- pathParams: {
458
- identity: documentId
459
- }
460
- });
461
- return response.body;
462
- }
463
- }
464
-
465
- export { IdentityProfileRestClient, IdentityResolverRestClient, IdentityRestClient };
321
+ //# sourceMappingURL=identityRestClient.js.map
@@ -0,0 +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;Q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Q,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 IIdentityRemoveRequest,\n\ttype IIdentityComponent,\n\ttype IIdentityCreateRequest,\n\ttype IIdentityCreateResponse,\n\ttype IIdentityProofCreateRequest,\n\ttype IIdentityProofCreateResponse,\n\ttype IIdentityProofVerifyRequest,\n\ttype IIdentityProofVerifyResponse,\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\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\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"]}
@@ -0,0 +1,6 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export * from "./identityRestClient.js";
4
+ export * from "./identityProfileRestClient.js";
5
+ export * from "./identityResolverRestClient.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./identityRestClient.js\";\nexport * from \"./identityProfileRestClient.js\";\nexport * from \"./identityResolverRestClient.js\";\n"]}
@@ -11,10 +11,15 @@ export declare class IdentityProfileRestClient<T extends IJsonLdDocument = IJson
11
11
  */
12
12
  static readonly CLASS_NAME: string;
13
13
  /**
14
- * Create a new instance of IdentityClient.
14
+ * Create a new instance of IdentityProfileRestClient.
15
15
  * @param config The configuration for the client.
16
16
  */
17
17
  constructor(config: IBaseRestClientConfig);
18
+ /**
19
+ * Returns the class name of the component.
20
+ * @returns The class name of the component.
21
+ */
22
+ className(): string;
18
23
  /**
19
24
  * Create the profile properties for an identity.
20
25
  * @param publicProfile The public profile data as JSON-LD.
@@ -11,10 +11,15 @@ export declare class IdentityResolverRestClient extends BaseRestClient implement
11
11
  */
12
12
  static readonly CLASS_NAME: string;
13
13
  /**
14
- * Create a new instance of IdentityClient.
14
+ * Create a new instance of IdentityResolverRestClient.
15
15
  * @param config The configuration for the client.
16
16
  */
17
17
  constructor(config: IBaseRestClientConfig);
18
+ /**
19
+ * Returns the class name of the component.
20
+ * @returns The class name of the component.
21
+ */
22
+ className(): string;
18
23
  /**
19
24
  * Resolve an identity.
20
25
  * @param documentId The id of the document to resolve.
@@ -12,10 +12,15 @@ export declare class IdentityRestClient extends BaseRestClient implements IIdent
12
12
  */
13
13
  static readonly CLASS_NAME: string;
14
14
  /**
15
- * Create a new instance of IdentityClient.
15
+ * Create a new instance of IdentityRestClient.
16
16
  * @param config The configuration for the client.
17
17
  */
18
18
  constructor(config: IBaseRestClientConfig);
19
+ /**
20
+ * Returns the class name of the component.
21
+ * @returns The class name of the component.
22
+ */
23
+ className(): string;
19
24
  /**
20
25
  * Create a new identity.
21
26
  * @param namespace The namespace of the connector to use for the identity, defaults to service configured namespace.
@@ -1,3 +1,3 @@
1
- export * from "./identityRestClient";
2
- export * from "./identityProfileRestClient";
3
- export * from "./identityResolverRestClient";
1
+ export * from "./identityRestClient.js";
2
+ export * from "./identityProfileRestClient.js";
3
+ export * from "./identityResolverRestClient.js";
package/docs/changelog.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # @twin.org/identity-rest-client - Changelog
2
2
 
3
+ ## [0.0.3-next.1](https://github.com/twinfoundation/identity/compare/identity-rest-client-v0.0.3-next.0...identity-rest-client-v0.0.3-next.1) (2025-11-11)
4
+
5
+
6
+ ### Features
7
+
8
+ * add context id features ([#62](https://github.com/twinfoundation/identity/issues/62)) ([e02ecca](https://github.com/twinfoundation/identity/commit/e02ecca9c45a849104bfbf7bc18a1f44e6eea8a1))
9
+ * add expiration date option to vc creation ([73e05e1](https://github.com/twinfoundation/identity/commit/73e05e1ae61112c7e056889969751f4ff82d9f29))
10
+ * add identity remove ([eebc13f](https://github.com/twinfoundation/identity/commit/eebc13f4c2cd994d2d9cce4da2128fb346c80ba7))
11
+ * add validate-locales ([04d74b4](https://github.com/twinfoundation/identity/commit/04d74b4d1ebe42672e8ca75a7bdb8e3556afd0be))
12
+ * eslint migration to flat config ([fd6246d](https://github.com/twinfoundation/identity/commit/fd6246d566280b6d5d10a108eb1e92c4b510f2f2))
13
+ * identity key separator use slash ([1319d0d](https://github.com/twinfoundation/identity/commit/1319d0d07164a36b3ec279e6421b8835ffefc3d3))
14
+ * update framework core ([c824497](https://github.com/twinfoundation/identity/commit/c82449709af0215eb7af496cf687c93fb30b5ae0))
15
+ * use shared store mechanism ([#27](https://github.com/twinfoundation/identity/issues/27)) ([ce41f3f](https://github.com/twinfoundation/identity/commit/ce41f3fc3da1b206ec06da7ea5b2c968f788804d))
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * Import path and bump version ([#21](https://github.com/twinfoundation/identity/issues/21)) ([ccea845](https://github.com/twinfoundation/identity/commit/ccea845bf32562267280bc1b3dde1c9af1a00360))
21
+ * Install sdk-wasm ([#20](https://github.com/twinfoundation/identity/issues/20)) ([75ec14e](https://github.com/twinfoundation/identity/commit/75ec14e072f8c219863a1c028a3b0783802086e9))
22
+ * query params force coercion ([d9347d2](https://github.com/twinfoundation/identity/commit/d9347d29d4a9cc58759f30f5d8526de864ea7522))
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/identity-models bumped from 0.0.3-next.0 to 0.0.3-next.1
30
+
31
+ ## [0.0.2-next.10](https://github.com/twinfoundation/identity/compare/identity-rest-client-v0.0.2-next.9...identity-rest-client-v0.0.2-next.10) (2025-10-27)
32
+
33
+
34
+ ### Miscellaneous Chores
35
+
36
+ * **identity-rest-client:** Synchronize repo versions
37
+
38
+
39
+ ### Dependencies
40
+
41
+ * The following workspace dependencies were updated
42
+ * dependencies
43
+ * @twin.org/identity-models bumped from 0.0.2-next.9 to 0.0.2-next.10
44
+
3
45
  ## [0.0.2-next.9](https://github.com/twinfoundation/identity/compare/identity-rest-client-v0.0.2-next.8...identity-rest-client-v0.0.2-next.9) (2025-10-09)
4
46
 
5
47
 
@@ -26,7 +26,7 @@ Client for performing identity through to REST endpoints.
26
26
 
27
27
  > **new IdentityProfileRestClient**\<`T`, `U`\>(`config`): `IdentityProfileRestClient`\<`T`, `U`\>
28
28
 
29
- Create a new instance of IdentityClient.
29
+ Create a new instance of IdentityProfileRestClient.
30
30
 
31
31
  #### Parameters
32
32
 
@@ -54,6 +54,24 @@ Runtime name for the class.
54
54
 
55
55
  ## Methods
56
56
 
57
+ ### className()
58
+
59
+ > **className**(): `string`
60
+
61
+ Returns the class name of the component.
62
+
63
+ #### Returns
64
+
65
+ `string`
66
+
67
+ The class name of the component.
68
+
69
+ #### Implementation of
70
+
71
+ `IIdentityProfileComponent.className`
72
+
73
+ ***
74
+
57
75
  ### create()
58
76
 
59
77
  > **create**(`publicProfile?`, `privateProfile?`): `Promise`\<`void`\>
@@ -16,7 +16,7 @@ Client for performing identity through to REST endpoints.
16
16
 
17
17
  > **new IdentityResolverRestClient**(`config`): `IdentityResolverRestClient`
18
18
 
19
- Create a new instance of IdentityClient.
19
+ Create a new instance of IdentityResolverRestClient.
20
20
 
21
21
  #### Parameters
22
22
 
@@ -44,6 +44,24 @@ Runtime name for the class.
44
44
 
45
45
  ## Methods
46
46
 
47
+ ### className()
48
+
49
+ > **className**(): `string`
50
+
51
+ Returns the class name of the component.
52
+
53
+ #### Returns
54
+
55
+ `string`
56
+
57
+ The class name of the component.
58
+
59
+ #### Implementation of
60
+
61
+ `IIdentityResolverComponent.className`
62
+
63
+ ***
64
+
47
65
  ### identityResolve()
48
66
 
49
67
  > **identityResolve**(`documentId`): `Promise`\<`IDidDocument`\>
@@ -16,7 +16,7 @@ Client for performing identity through to REST endpoints.
16
16
 
17
17
  > **new IdentityRestClient**(`config`): `IdentityRestClient`
18
18
 
19
- Create a new instance of IdentityClient.
19
+ Create a new instance of IdentityRestClient.
20
20
 
21
21
  #### Parameters
22
22
 
@@ -44,6 +44,24 @@ Runtime name for the class.
44
44
 
45
45
  ## Methods
46
46
 
47
+ ### className()
48
+
49
+ > **className**(): `string`
50
+
51
+ Returns the class name of the component.
52
+
53
+ #### Returns
54
+
55
+ `string`
56
+
57
+ The class name of the component.
58
+
59
+ #### Implementation of
60
+
61
+ `IIdentityComponent.className`
62
+
63
+ ***
64
+
47
65
  ### identityCreate()
48
66
 
49
67
  > **identityCreate**(`namespace?`): `Promise`\<`IDidDocument`\>
@@ -272,7 +290,7 @@ The verification method id to use.
272
290
 
273
291
  The id of the credential.
274
292
 
275
- `undefined` | `string`
293
+ `string` | `undefined`
276
294
 
277
295
  ##### subject
278
296
 
@@ -420,19 +438,19 @@ The method to associate with the presentation.
420
438
 
421
439
  The id of the presentation.
422
440
 
423
- `undefined` | `string`
441
+ `string` | `undefined`
424
442
 
425
443
  ##### contexts
426
444
 
427
445
  The contexts for the data stored in the verifiable credential.
428
446
 
429
- `undefined` | `IJsonLdContextDefinitionRoot`
447
+ `IJsonLdContextDefinitionRoot` | `undefined`
430
448
 
431
449
  ##### types
432
450
 
433
451
  The types for the data stored in the verifiable credential.
434
452
 
435
- `undefined` | `string` | `string`[]
453
+ `string` | `string`[] | `undefined`
436
454
 
437
455
  ##### verifiableCredentials
438
456
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/identity-rest-client",
3
- "version": "0.0.2-next.9",
3
+ "version": "0.0.3-next.1",
4
4
  "description": "Identity contract implementation which can connect to REST endpoints",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,24 +20,22 @@
20
20
  "@twin.org/data-core": "next",
21
21
  "@twin.org/data-json-ld": "next",
22
22
  "@twin.org/entity": "next",
23
- "@twin.org/identity-models": "0.0.2-next.9",
23
+ "@twin.org/identity-models": "0.0.3-next.1",
24
24
  "@twin.org/nameof": "next",
25
25
  "@twin.org/standards-w3c-did": "next"
26
26
  },
27
- "main": "./dist/cjs/index.cjs",
28
- "module": "./dist/esm/index.mjs",
27
+ "main": "./dist/es/index.js",
29
28
  "types": "./dist/types/index.d.ts",
30
29
  "exports": {
31
30
  ".": {
32
31
  "types": "./dist/types/index.d.ts",
33
- "require": "./dist/cjs/index.cjs",
34
- "import": "./dist/esm/index.mjs"
32
+ "import": "./dist/es/index.js",
33
+ "default": "./dist/es/index.js"
35
34
  },
36
35
  "./locales/*.json": "./locales/*.json"
37
36
  },
38
37
  "files": [
39
- "dist/cjs",
40
- "dist/esm",
38
+ "dist/es",
41
39
  "dist/types",
42
40
  "locales",
43
41
  "docs"
@@ -1,469 +0,0 @@
1
- 'use strict';
2
-
3
- var apiCore = require('@twin.org/api-core');
4
- var core = require('@twin.org/core');
5
- var identityModels = require('@twin.org/identity-models');
6
- var standardsW3cDid = require('@twin.org/standards-w3c-did');
7
- var apiModels = require('@twin.org/api-models');
8
-
9
- // Copyright 2024 IOTA Stiftung.
10
- // SPDX-License-Identifier: Apache-2.0.
11
- /**
12
- * Client for performing identity through to REST endpoints.
13
- */
14
- class IdentityRestClient extends apiCore.BaseRestClient {
15
- /**
16
- * Runtime name for the class.
17
- */
18
- static CLASS_NAME = "IdentityRestClient";
19
- /**
20
- * Create a new instance of IdentityClient.
21
- * @param config The configuration for the client.
22
- */
23
- constructor(config) {
24
- super("IdentityRestClient", config, "identity");
25
- }
26
- /**
27
- * Create a new identity.
28
- * @param namespace The namespace of the connector to use for the identity, defaults to service configured namespace.
29
- * @returns The created identity document.
30
- */
31
- async identityCreate(namespace) {
32
- const response = await this.fetch("/", "POST", {
33
- body: {
34
- namespace
35
- }
36
- });
37
- return response.body;
38
- }
39
- /**
40
- * Remove an identity.
41
- * @param identity The id of the document to remove.
42
- * @returns Nothing.
43
- */
44
- async identityRemove(identity) {
45
- core.Guards.stringValue(IdentityRestClient.CLASS_NAME, "identity", identity);
46
- await this.fetch("/:identity", "DELETE", {
47
- pathParams: {
48
- identity
49
- }
50
- });
51
- }
52
- /**
53
- * Add a verification method to the document in JSON Web key Format.
54
- * @param identity The id of the document to add the verification method to.
55
- * @param verificationMethodType The type of the verification method to add.
56
- * @param verificationMethodId The id of the verification method, if undefined uses the kid of the generated JWK.
57
- * @returns The verification method.
58
- * @throws NotFoundError if the id can not be resolved.
59
- * @throws NotSupportedError if the platform does not support multiple keys.
60
- */
61
- async verificationMethodCreate(identity, verificationMethodType, verificationMethodId) {
62
- core.Guards.stringValue(IdentityRestClient.CLASS_NAME, "identity", identity);
63
- core.Guards.arrayOneOf(IdentityRestClient.CLASS_NAME, "verificationMethodType", verificationMethodType, Object.values(standardsW3cDid.DidVerificationMethodType));
64
- const response = await this.fetch("/:identity/verification-method", "POST", {
65
- pathParams: {
66
- identity
67
- },
68
- body: {
69
- verificationMethodType,
70
- verificationMethodId
71
- }
72
- });
73
- return response.body;
74
- }
75
- /**
76
- * Remove a verification method from the document.
77
- * @param verificationMethodId The id of the verification method.
78
- * @returns Nothing.
79
- * @throws NotFoundError if the id can not be resolved.
80
- * @throws NotSupportedError if the platform does not support multiple revocable keys.
81
- */
82
- async verificationMethodRemove(verificationMethodId) {
83
- core.Guards.stringValue(IdentityRestClient.CLASS_NAME, "verificationMethodId", verificationMethodId);
84
- const idParts = identityModels.DocumentHelper.parseId(verificationMethodId);
85
- await this.fetch("/:identity/verification-method/:verificationMethodId", "DELETE", {
86
- pathParams: {
87
- identity: idParts.id,
88
- verificationMethodId: idParts.fragment ?? ""
89
- }
90
- });
91
- }
92
- /**
93
- * Add a service to the document.
94
- * @param identity The id of the document to add the service to.
95
- * @param serviceId The id of the service.
96
- * @param serviceType The type of the service.
97
- * @param serviceEndpoint The endpoint for the service.
98
- * @returns The service.
99
- * @throws NotFoundError if the id can not be resolved.
100
- */
101
- async serviceCreate(identity, serviceId, serviceType, serviceEndpoint) {
102
- core.Guards.stringValue(IdentityRestClient.CLASS_NAME, "identity", identity);
103
- core.Guards.stringValue(IdentityRestClient.CLASS_NAME, "serviceId", serviceId);
104
- if (core.Is.array(serviceType)) {
105
- core.Guards.arrayValue(IdentityRestClient.CLASS_NAME, "serviceType", serviceType);
106
- }
107
- else {
108
- core.Guards.stringValue(IdentityRestClient.CLASS_NAME, "serviceType", serviceType);
109
- }
110
- if (core.Is.array(serviceEndpoint)) {
111
- core.Guards.arrayValue(IdentityRestClient.CLASS_NAME, "serviceEndpoint", serviceEndpoint);
112
- }
113
- else {
114
- core.Guards.stringValue(IdentityRestClient.CLASS_NAME, "serviceEndpoint", serviceEndpoint);
115
- }
116
- const response = await this.fetch("/:identity/service", "POST", {
117
- pathParams: {
118
- identity
119
- },
120
- body: {
121
- serviceId,
122
- type: serviceType,
123
- endpoint: serviceEndpoint
124
- }
125
- });
126
- return response.body;
127
- }
128
- /**
129
- * Remove a service from the document.
130
- * @param serviceId The id of the service.
131
- * @returns Nothing.
132
- * @throws NotFoundError if the id can not be resolved.
133
- */
134
- async serviceRemove(serviceId) {
135
- core.Guards.stringValue(IdentityRestClient.CLASS_NAME, "serviceId", serviceId);
136
- const idParts = identityModels.DocumentHelper.parseId(serviceId);
137
- await this.fetch("/:identity/service/:serviceId", "DELETE", {
138
- pathParams: {
139
- identity: idParts.id,
140
- serviceId: idParts.fragment ?? ""
141
- }
142
- });
143
- }
144
- /**
145
- * Create a verifiable credential for a verification method.
146
- * @param verificationMethodId The verification method id to use.
147
- * @param id The id of the credential.
148
- * @param subject The credential subject to store in the verifiable credential.
149
- * @param options Additional options for creating the verifiable credential.
150
- * @param options.revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.
151
- * @param options.expirationDate The date the verifiable credential is valid until.
152
- * @returns The created verifiable credential and its token.
153
- * @throws NotFoundError if the id can not be resolved.
154
- */
155
- async verifiableCredentialCreate(verificationMethodId, id, subject, options) {
156
- core.Guards.stringValue(IdentityRestClient.CLASS_NAME, "verificationMethodId", verificationMethodId);
157
- core.Guards.object(IdentityRestClient.CLASS_NAME, "subject", subject);
158
- if (!core.Is.undefined(options?.revocationIndex)) {
159
- core.Guards.number(IdentityRestClient.CLASS_NAME, "options.revocationIndex", options?.revocationIndex);
160
- }
161
- const idParts = identityModels.DocumentHelper.parseId(verificationMethodId);
162
- const response = await this.fetch("/:identity/verifiable-credential", "POST", {
163
- pathParams: {
164
- identity: idParts.id,
165
- verificationMethodId: idParts.fragment ?? ""
166
- },
167
- body: {
168
- credentialId: id,
169
- subject,
170
- revocationIndex: options?.revocationIndex,
171
- expirationDate: options?.expirationDate?.toISOString()
172
- }
173
- });
174
- return response.body;
175
- }
176
- /**
177
- * Verify a verifiable credential is valid.
178
- * @param credentialJwt The credential to verify.
179
- * @returns The credential stored in the jwt and the revocation status.
180
- */
181
- async verifiableCredentialVerify(credentialJwt) {
182
- core.Guards.stringValue(IdentityRestClient.CLASS_NAME, "credentialJwt", credentialJwt);
183
- const response = await this.fetch("/verifiable-credential/verify", "POST", {
184
- query: {
185
- jwt: credentialJwt
186
- }
187
- });
188
- return response.body;
189
- }
190
- /**
191
- * Revoke verifiable credential.
192
- * @param issuerId The id of the document to update the revocation list for.
193
- * @param credentialIndex The revocation bitmap index revoke.
194
- * @returns Nothing.
195
- */
196
- async verifiableCredentialRevoke(issuerId, credentialIndex) {
197
- core.Guards.stringValue(IdentityRestClient.CLASS_NAME, "issuerId", issuerId);
198
- core.Guards.integer(IdentityRestClient.CLASS_NAME, "credentialIndex", credentialIndex);
199
- await this.fetch("/:identity/verifiable-credential/revoke/:revocationIndex", "GET", {
200
- pathParams: {
201
- identity: issuerId,
202
- revocationIndex: credentialIndex
203
- }
204
- });
205
- }
206
- /**
207
- * Unrevoke verifiable credential.
208
- * @param issuerId The id of the document to update the revocation list for.
209
- * @param credentialIndex The revocation bitmap index to un revoke.
210
- * @returns Nothing.
211
- */
212
- async verifiableCredentialUnrevoke(issuerId, credentialIndex) {
213
- core.Guards.stringValue(IdentityRestClient.CLASS_NAME, "issuerId", issuerId);
214
- core.Guards.integer(IdentityRestClient.CLASS_NAME, "credentialIndex", credentialIndex);
215
- await this.fetch("/:identity/verifiable-credential/unrevoke/:revocationIndex", "GET", {
216
- pathParams: {
217
- identity: issuerId,
218
- revocationIndex: credentialIndex
219
- }
220
- });
221
- }
222
- /**
223
- * Create a verifiable presentation from the supplied verifiable credentials.
224
- * @param verificationMethodId The method to associate with the presentation.
225
- * @param presentationId The id of the presentation.
226
- * @param contexts The contexts for the data stored in the verifiable credential.
227
- * @param types The types for the data stored in the verifiable credential.
228
- * @param verifiableCredentials The credentials to use for creating the presentation in jwt format.
229
- * @param expiresInMinutes The time in minutes for the presentation to expire.
230
- * @returns The created verifiable presentation and its token.
231
- * @throws NotFoundError if the id can not be resolved.
232
- */
233
- async verifiablePresentationCreate(verificationMethodId, presentationId, contexts, types, verifiableCredentials, expiresInMinutes) {
234
- core.Guards.stringValue(IdentityRestClient.CLASS_NAME, "verificationMethodId", verificationMethodId);
235
- if (core.Is.array(types)) {
236
- core.Guards.arrayValue(IdentityRestClient.CLASS_NAME, "types", types);
237
- }
238
- else if (core.Is.string(types)) {
239
- core.Guards.stringValue(IdentityRestClient.CLASS_NAME, "types", types);
240
- }
241
- core.Guards.arrayValue(IdentityRestClient.CLASS_NAME, "verifiableCredentials", verifiableCredentials);
242
- if (!core.Is.undefined(expiresInMinutes)) {
243
- core.Guards.integer(IdentityRestClient.CLASS_NAME, "expiresInMinutes", expiresInMinutes);
244
- }
245
- const idParts = identityModels.DocumentHelper.parseId(verificationMethodId);
246
- const response = await this.fetch("/:identity/verifiable-presentation", "POST", {
247
- pathParams: {
248
- identity: idParts.id,
249
- verificationMethodId: idParts.fragment ?? ""
250
- },
251
- body: {
252
- presentationId,
253
- contexts,
254
- types,
255
- verifiableCredentials,
256
- expiresInMinutes
257
- }
258
- });
259
- return response.body;
260
- }
261
- /**
262
- * Verify a verifiable presentation is valid.
263
- * @param presentationJwt The presentation to verify.
264
- * @returns The presentation stored in the jwt and the revocation status.
265
- */
266
- async verifiablePresentationVerify(presentationJwt) {
267
- core.Guards.stringValue(IdentityRestClient.CLASS_NAME, "presentationJwt", presentationJwt);
268
- const response = await this.fetch("/verifiable-presentation/verify", "POST", {
269
- query: {
270
- jwt: presentationJwt
271
- }
272
- });
273
- return response.body;
274
- }
275
- /**
276
- * Create a proof for a document with the specified verification method.
277
- * @param verificationMethodId The verification method id to use.
278
- * @param proofType The type of proof to create.
279
- * @param unsecureDocument The unsecure document to create the proof for.
280
- * @returns The proof.
281
- */
282
- async proofCreate(verificationMethodId, proofType, unsecureDocument) {
283
- core.Guards.stringValue(IdentityRestClient.CLASS_NAME, "verificationMethodId", verificationMethodId);
284
- core.Guards.arrayOneOf(IdentityRestClient.CLASS_NAME, "proofType", proofType, Object.values(standardsW3cDid.ProofTypes));
285
- core.Guards.object(IdentityRestClient.CLASS_NAME, "unsecureDocument", unsecureDocument);
286
- const idParts = identityModels.DocumentHelper.parseId(verificationMethodId);
287
- const response = await this.fetch("/:identity/proof", "POST", {
288
- pathParams: {
289
- identity: idParts.id,
290
- verificationMethodId: idParts.fragment ?? ""
291
- },
292
- body: {
293
- document: unsecureDocument,
294
- proofType
295
- }
296
- });
297
- return response.body;
298
- }
299
- /**
300
- * Verify proof for a document with the specified verification method.
301
- * @param document The document to verify.
302
- * @param proof The proof to verify.
303
- * @returns True if the proof is verified.
304
- */
305
- async proofVerify(document, proof) {
306
- core.Guards.object(IdentityRestClient.CLASS_NAME, "document", document);
307
- core.Guards.object(IdentityRestClient.CLASS_NAME, "proof", proof);
308
- core.Guards.stringValue(IdentityRestClient.CLASS_NAME, "proof.verificationMethod", proof.verificationMethod);
309
- const response = await this.fetch("/proof/verify", "POST", {
310
- body: {
311
- document,
312
- proof
313
- }
314
- });
315
- return response.body.verified;
316
- }
317
- }
318
-
319
- // Copyright 2024 IOTA Stiftung.
320
- // SPDX-License-Identifier: Apache-2.0.
321
- /**
322
- * Client for performing identity through to REST endpoints.
323
- */
324
- class IdentityProfileRestClient extends apiCore.BaseRestClient {
325
- /**
326
- * Runtime name for the class.
327
- */
328
- static CLASS_NAME = "IdentityProfileRestClient";
329
- /**
330
- * Create a new instance of IdentityClient.
331
- * @param config The configuration for the client.
332
- */
333
- constructor(config) {
334
- super("IdentityProfileRestClient", config, "identity/profile");
335
- }
336
- /**
337
- * Create the profile properties for an identity.
338
- * @param publicProfile The public profile data as JSON-LD.
339
- * @param privateProfile The private profile data as JSON-LD.
340
- * @returns Nothing.
341
- */
342
- async create(publicProfile, privateProfile) {
343
- await this.fetch("", "POST", {
344
- body: {
345
- publicProfile,
346
- privateProfile
347
- }
348
- });
349
- }
350
- /**
351
- * Get the profile properties for an identity.
352
- * @param publicPropertyNames The public properties to get for the profile, defaults to all.
353
- * @param privatePropertyNames The private properties to get for the profile, defaults to all.
354
- * @returns The identity and the items properties.
355
- */
356
- async get(publicPropertyNames, privatePropertyNames) {
357
- const response = await this.fetch("/", "GET", {
358
- query: {
359
- publicPropertyNames: apiModels.HttpParameterHelper.arrayToString(publicPropertyNames),
360
- privatePropertyNames: apiModels.HttpParameterHelper.arrayToString(privatePropertyNames)
361
- }
362
- });
363
- return {
364
- identity: response.body.identity,
365
- publicProfile: response.body.publicProfile,
366
- privateProfile: response.body.privateProfile
367
- };
368
- }
369
- /**
370
- * Get the public profile properties for an identity.
371
- * @param identity The identity to perform the profile operation on.
372
- * @param propertyNames The public properties to get for the profile, defaults to all.
373
- * @returns The items properties.
374
- */
375
- async getPublic(identity, propertyNames) {
376
- core.Guards.string(IdentityProfileRestClient.CLASS_NAME, "identity", identity);
377
- const response = await this.fetch("/:identity/public", "GET", {
378
- pathParams: {
379
- identity
380
- },
381
- query: {
382
- propertyNames: apiModels.HttpParameterHelper.arrayToString(propertyNames)
383
- }
384
- });
385
- return response.body;
386
- }
387
- /**
388
- * Update the profile properties of an identity.
389
- * @param publicProfile The public profile data as JSON-LD.
390
- * @param privateProfile The private profile data as JSON-LD.
391
- * @returns Nothing.
392
- */
393
- async update(publicProfile, privateProfile) {
394
- await this.fetch("/", "PUT", {
395
- body: {
396
- publicProfile,
397
- privateProfile
398
- }
399
- });
400
- }
401
- /**
402
- * Delete the profile for an identity.
403
- * @returns Nothing.
404
- */
405
- async remove() {
406
- await this.fetch("/", "DELETE");
407
- }
408
- /**
409
- * Get a list of the requested identities.
410
- * @param publicFilters The filters to apply to the identities public profiles.
411
- * @param publicPropertyNames The public properties to get for the profile, defaults to all.
412
- * @param cursor The cursor for paged requests.
413
- * @param limit The maximum number of items in a page.
414
- * @returns The list of items and cursor for paging.
415
- */
416
- async list(publicFilters, publicPropertyNames, cursor, limit) {
417
- const response = await this.fetch("/query", "GET", {
418
- query: {
419
- publicFilters: apiModels.HttpParameterHelper.arrayToString(
420
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
421
- publicFilters?.map(f => `${f.propertyName}:${f.propertyValue}`)),
422
- publicPropertyNames: apiModels.HttpParameterHelper.arrayToString(publicPropertyNames),
423
- cursor,
424
- limit: core.Coerce.string(limit)
425
- }
426
- });
427
- return {
428
- items: response.body.items,
429
- cursor: response.body.cursor
430
- };
431
- }
432
- }
433
-
434
- // Copyright 2024 IOTA Stiftung.
435
- // SPDX-License-Identifier: Apache-2.0.
436
- /**
437
- * Client for performing identity through to REST endpoints.
438
- */
439
- class IdentityResolverRestClient extends apiCore.BaseRestClient {
440
- /**
441
- * Runtime name for the class.
442
- */
443
- static CLASS_NAME = "IdentityResolverRestClient";
444
- /**
445
- * Create a new instance of IdentityClient.
446
- * @param config The configuration for the client.
447
- */
448
- constructor(config) {
449
- super("IdentityResolverRestClient", config, "identity");
450
- }
451
- /**
452
- * Resolve an identity.
453
- * @param documentId The id of the document to resolve.
454
- * @returns The resolved document.
455
- */
456
- async identityResolve(documentId) {
457
- core.Urn.guard(IdentityResolverRestClient.CLASS_NAME, "documentId", documentId);
458
- const response = await this.fetch("/:identity", "GET", {
459
- pathParams: {
460
- identity: documentId
461
- }
462
- });
463
- return response.body;
464
- }
465
- }
466
-
467
- exports.IdentityProfileRestClient = IdentityProfileRestClient;
468
- exports.IdentityResolverRestClient = IdentityResolverRestClient;
469
- exports.IdentityRestClient = IdentityRestClient;