@twin.org/identity-rest-client 0.9.2-next.5 → 0.9.2-next.7
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.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
3
|
import { BaseRestClient } from "@twin.org/api-core";
|
|
4
4
|
import { HttpParameterHelper } from "@twin.org/api-models";
|
|
5
|
-
import { Coerce, Guards } from "@twin.org/core";
|
|
5
|
+
import { Coerce, Guards, Is } from "@twin.org/core";
|
|
6
6
|
import { HttpMethod } from "@twin.org/web";
|
|
7
7
|
/**
|
|
8
8
|
* Client for performing identity profile operations through REST endpoints.
|
|
@@ -44,9 +44,27 @@ export class IdentityProfileRestClient extends BaseRestClient {
|
|
|
44
44
|
* Get the profile properties for an identity.
|
|
45
45
|
* @param publicPropertyNames The public properties to get for the profile, defaults to all.
|
|
46
46
|
* @param privatePropertyNames The private properties to get for the profile, defaults to all.
|
|
47
|
+
* @param identity The identity to perform the profile operation on, defaults to the current user.
|
|
47
48
|
* @returns The identity and the items properties.
|
|
48
49
|
*/
|
|
49
|
-
async get(publicPropertyNames, privatePropertyNames) {
|
|
50
|
+
async get(publicPropertyNames, privatePropertyNames, identity) {
|
|
51
|
+
if (!Is.empty(identity)) {
|
|
52
|
+
Guards.string(IdentityProfileRestClient.CLASS_NAME, "identity", identity);
|
|
53
|
+
const response = await this.fetch("/:userIdentity", HttpMethod.GET, {
|
|
54
|
+
pathParams: {
|
|
55
|
+
userIdentity: identity
|
|
56
|
+
},
|
|
57
|
+
query: {
|
|
58
|
+
publicPropertyNames: HttpParameterHelper.arrayToString(publicPropertyNames),
|
|
59
|
+
privatePropertyNames: HttpParameterHelper.arrayToString(privatePropertyNames)
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
identity: response.body.identity,
|
|
64
|
+
publicProfile: response.body.publicProfile,
|
|
65
|
+
privateProfile: response.body.privateProfile
|
|
66
|
+
};
|
|
67
|
+
}
|
|
50
68
|
const response = await this.fetch("/", HttpMethod.GET, {
|
|
51
69
|
query: {
|
|
52
70
|
publicPropertyNames: HttpParameterHelper.arrayToString(publicPropertyNames),
|
|
@@ -81,9 +99,23 @@ export class IdentityProfileRestClient extends BaseRestClient {
|
|
|
81
99
|
* Update the profile properties of an identity.
|
|
82
100
|
* @param publicProfile The public profile data as JSON-LD.
|
|
83
101
|
* @param privateProfile The private profile data as JSON-LD.
|
|
102
|
+
* @param identity The identity to perform the profile operation on, defaults to the current user.
|
|
84
103
|
* @returns A promise that resolves when the profile has been updated.
|
|
85
104
|
*/
|
|
86
|
-
async update(publicProfile, privateProfile) {
|
|
105
|
+
async update(publicProfile, privateProfile, identity) {
|
|
106
|
+
if (!Is.empty(identity)) {
|
|
107
|
+
Guards.string(IdentityProfileRestClient.CLASS_NAME, "identity", identity);
|
|
108
|
+
await this.fetch("/:userIdentity", HttpMethod.PUT, {
|
|
109
|
+
pathParams: {
|
|
110
|
+
userIdentity: identity
|
|
111
|
+
},
|
|
112
|
+
body: {
|
|
113
|
+
publicProfile,
|
|
114
|
+
privateProfile
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
87
119
|
await this.fetch("/", HttpMethod.PUT, {
|
|
88
120
|
body: {
|
|
89
121
|
publicProfile,
|
|
@@ -93,9 +125,19 @@ export class IdentityProfileRestClient extends BaseRestClient {
|
|
|
93
125
|
}
|
|
94
126
|
/**
|
|
95
127
|
* Delete the profile for an identity.
|
|
128
|
+
* @param identity The identity to perform the profile operation on, defaults to the current user.
|
|
96
129
|
* @returns A promise that resolves when the profile has been removed.
|
|
97
130
|
*/
|
|
98
|
-
async remove() {
|
|
131
|
+
async remove(identity) {
|
|
132
|
+
if (!Is.empty(identity)) {
|
|
133
|
+
Guards.string(IdentityProfileRestClient.CLASS_NAME, "identity", identity);
|
|
134
|
+
await this.fetch("/:userIdentity", HttpMethod.DELETE, {
|
|
135
|
+
pathParams: {
|
|
136
|
+
userIdentity: identity
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
99
141
|
await this.fetch("/", HttpMethod.DELETE);
|
|
100
142
|
}
|
|
101
143
|
/**
|
|
@@ -109,9 +151,7 @@ export class IdentityProfileRestClient extends BaseRestClient {
|
|
|
109
151
|
async list(publicFilters, publicPropertyNames, cursor, limit) {
|
|
110
152
|
const response = await this.fetch("/query", HttpMethod.GET, {
|
|
111
153
|
query: {
|
|
112
|
-
publicFilters: HttpParameterHelper.arrayToString(
|
|
113
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
114
|
-
publicFilters?.map(f => `${f.propertyName}:${f.propertyValue}`)),
|
|
154
|
+
publicFilters: HttpParameterHelper.arrayToString(publicFilters?.map(f => `${f.propertyName}:${Coerce.string(f.propertyValue) ?? ""}`)),
|
|
115
155
|
publicPropertyNames: HttpParameterHelper.arrayToString(publicPropertyNames),
|
|
116
156
|
cursor,
|
|
117
157
|
limit: Coerce.string(limit)
|
|
@@ -122,5 +162,31 @@ export class IdentityProfileRestClient extends BaseRestClient {
|
|
|
122
162
|
cursor: response.body.cursor
|
|
123
163
|
};
|
|
124
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Get the list of identity profiles including private properties.
|
|
167
|
+
* @param publicFilters The filters to apply to the identities public profiles.
|
|
168
|
+
* @param privateFilters The filters to apply to the identities private profiles.
|
|
169
|
+
* @param publicPropertyNames The public properties to get for the profile, defaults to all.
|
|
170
|
+
* @param privatePropertyNames The private properties to get for the profile, defaults to none.
|
|
171
|
+
* @param cursor The cursor for paged requests.
|
|
172
|
+
* @param limit The maximum number of items in a page.
|
|
173
|
+
* @returns The list of items and cursor for paging.
|
|
174
|
+
*/
|
|
175
|
+
async listAdmin(publicFilters, privateFilters, publicPropertyNames, privatePropertyNames, cursor, limit) {
|
|
176
|
+
const response = await this.fetch("/admin/query", HttpMethod.GET, {
|
|
177
|
+
query: {
|
|
178
|
+
publicFilters: HttpParameterHelper.arrayToString(publicFilters?.map(f => `${f.propertyName}:${Coerce.string(f.propertyValue) ?? ""}`)),
|
|
179
|
+
privateFilters: HttpParameterHelper.arrayToString(privateFilters?.map(f => `${f.propertyName}:${Coerce.string(f.propertyValue) ?? ""}`)),
|
|
180
|
+
publicPropertyNames: HttpParameterHelper.arrayToString(publicPropertyNames),
|
|
181
|
+
privatePropertyNames: HttpParameterHelper.arrayToString(privatePropertyNames),
|
|
182
|
+
cursor,
|
|
183
|
+
limit: Coerce.string(limit)
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
return {
|
|
187
|
+
items: response.body.items,
|
|
188
|
+
cursor: response.body.cursor
|
|
189
|
+
};
|
|
190
|
+
}
|
|
125
191
|
}
|
|
126
192
|
//# sourceMappingURL=identityProfileRestClient.js.map
|
|
@@ -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;AAchD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;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,cAAk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AI,EAAE;gBACL,aAAa;gBACb,cAAc;aACd;SACD,CAAC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,MAAM;QAClB,MAAM,IAAI,CAAC,KAAK,CAAe,GAAG,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,IAAI,CAChB,aAGG,EACH,mBAAiC,EACjC,MAAe,EACf,KAAc;QAcd,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAChC,QAAQ,EACR,UAAU,CAAC,GAAG,EACd;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\";\nimport { HttpMethod } from \"@twin.org/web\";\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>(\"/\", HttpMethod.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\tHttpMethod.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\", HttpMethod.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>(\"/\", HttpMethod.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>(\"/\", HttpMethod.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\tHttpMethod.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":"A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,CAAC,IAAI,CAAC,KAIlB;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, Is } from \"@twin.org/core\";\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\nimport type {\n\tIIdentityProfileAdminGetRequest,\n\tIIdentityProfileAdminListRequest,\n\tIIdentityProfileAdminListResponse,\n\tIIdentityProfileAdminRemoveRequest,\n\tIIdentityProfileAdminUpdateRequest,\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\";\nimport { HttpMethod } from \"@twin.org/web\";\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>(\"/\", HttpMethod.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 * @param identity The identity to perform the profile operation on, defaults to the current user.\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\tidentity?: string\n\t): Promise<{\n\t\tidentity: string;\n\t\tpublicProfile?: Partial<T>;\n\t\tprivateProfile?: Partial<U>;\n\t}> {\n\t\tif (!Is.empty(identity)) {\n\t\t\tGuards.string(IdentityProfileRestClient.CLASS_NAME, nameof(identity), identity);\n\t\t\tconst response = await this.fetch<\n\t\t\t\tIIdentityProfileAdminGetRequest,\n\t\t\t\tIIdentityProfileGetResponse\n\t\t\t>(\"/:userIdentity\", HttpMethod.GET, {\n\t\t\t\tpathParams: {\n\t\t\t\t\tuserIdentity: identity\n\t\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\treturn {\n\t\t\t\tidentity: response.body.identity,\n\t\t\t\tpublicProfile: response.body.publicProfile as T,\n\t\t\t\tprivateProfile: response.body.privateProfile as U\n\t\t\t};\n\t\t}\n\t\tconst response = await this.fetch<IIdentityProfileGetRequest, IIdentityProfileGetResponse>(\n\t\t\t\"/\",\n\t\t\tHttpMethod.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\", HttpMethod.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 * @param identity The identity to perform the profile operation on, defaults to the current user.\n\t * @returns A promise that resolves when the profile has been updated.\n\t */\n\tpublic async update(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void> {\n\t\tif (!Is.empty(identity)) {\n\t\t\tGuards.string(IdentityProfileRestClient.CLASS_NAME, nameof(identity), identity);\n\t\t\tawait this.fetch<IIdentityProfileAdminUpdateRequest, never>(\n\t\t\t\t\"/:userIdentity\",\n\t\t\t\tHttpMethod.PUT,\n\t\t\t\t{\n\t\t\t\t\tpathParams: {\n\t\t\t\t\t\tuserIdentity: identity\n\t\t\t\t\t},\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tpublicProfile,\n\t\t\t\t\t\tprivateProfile\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tawait this.fetch<IIdentityProfileUpdateRequest, never>(\"/\", HttpMethod.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 * @param identity The identity to perform the profile operation on, defaults to the current user.\n\t * @returns A promise that resolves when the profile has been removed.\n\t */\n\tpublic async remove(identity?: string): Promise<void> {\n\t\tif (!Is.empty(identity)) {\n\t\t\tGuards.string(IdentityProfileRestClient.CLASS_NAME, nameof(identity), identity);\n\t\t\tawait this.fetch<IIdentityProfileAdminRemoveRequest, never>(\n\t\t\t\t\"/:userIdentity\",\n\t\t\t\tHttpMethod.DELETE,\n\t\t\t\t{\n\t\t\t\t\tpathParams: {\n\t\t\t\t\t\tuserIdentity: identity\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tawait this.fetch<never, never>(\"/\", HttpMethod.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\tHttpMethod.GET,\n\t\t\t{\n\t\t\t\tquery: {\n\t\t\t\t\tpublicFilters: HttpParameterHelper.arrayToString(\n\t\t\t\t\t\tpublicFilters?.map(f => `${f.propertyName}:${Coerce.string(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\t/**\n\t * Get the list of identity profiles including private properties.\n\t * @param publicFilters The filters to apply to the identities public profiles.\n\t * @param privateFilters The filters to apply to the identities private profiles.\n\t * @param publicPropertyNames The public properties to get for the profile, defaults to all.\n\t * @param privatePropertyNames The private properties to get for the profile, defaults to none.\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 listAdmin(\n\t\tpublicFilters?: {\n\t\t\tpropertyName: string;\n\t\t\tpropertyValue: unknown;\n\t\t}[],\n\t\tprivateFilters?: {\n\t\t\tpropertyName: string;\n\t\t\tpropertyValue: unknown;\n\t\t}[],\n\t\tpublicPropertyNames?: (keyof T)[],\n\t\tprivatePropertyNames?: (keyof U)[],\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\titems: {\n\t\t\tidentity: string;\n\t\t\tpublicProfile?: Partial<T>;\n\t\t\tprivateProfile?: Partial<U>;\n\t\t}[];\n\t\tcursor?: string;\n\t}> {\n\t\tconst response = await this.fetch<\n\t\t\tIIdentityProfileAdminListRequest,\n\t\t\tIIdentityProfileAdminListResponse\n\t\t>(\"/admin/query\", HttpMethod.GET, {\n\t\t\tquery: {\n\t\t\t\tpublicFilters: HttpParameterHelper.arrayToString(\n\t\t\t\t\tpublicFilters?.map(f => `${f.propertyName}:${Coerce.string(f.propertyValue) ?? \"\"}`)\n\t\t\t\t),\n\t\t\t\tprivateFilters: HttpParameterHelper.arrayToString(\n\t\t\t\t\tprivateFilters?.map(f => `${f.propertyName}:${Coerce.string(f.propertyValue) ?? \"\"}`)\n\t\t\t\t),\n\t\t\t\tpublicPropertyNames: HttpParameterHelper.arrayToString(publicPropertyNames),\n\t\t\t\tprivatePropertyNames: HttpParameterHelper.arrayToString(privatePropertyNames),\n\t\t\t\tcursor,\n\t\t\t\tlimit: Coerce.string(limit)\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\tprivateProfile?: Partial<U>;\n\t\t\t}[],\n\t\t\tcursor: response.body.cursor\n\t\t};\n\t}\n}\n"]}
|
|
@@ -31,9 +31,10 @@ export declare class IdentityProfileRestClient<T extends IJsonLdDocument = IJson
|
|
|
31
31
|
* Get the profile properties for an identity.
|
|
32
32
|
* @param publicPropertyNames The public properties to get for the profile, defaults to all.
|
|
33
33
|
* @param privatePropertyNames The private properties to get for the profile, defaults to all.
|
|
34
|
+
* @param identity The identity to perform the profile operation on, defaults to the current user.
|
|
34
35
|
* @returns The identity and the items properties.
|
|
35
36
|
*/
|
|
36
|
-
get(publicPropertyNames?: (keyof T)[], privatePropertyNames?: (keyof U)[]): Promise<{
|
|
37
|
+
get(publicPropertyNames?: (keyof T)[], privatePropertyNames?: (keyof U)[], identity?: string): Promise<{
|
|
37
38
|
identity: string;
|
|
38
39
|
publicProfile?: Partial<T>;
|
|
39
40
|
privateProfile?: Partial<U>;
|
|
@@ -49,14 +50,16 @@ export declare class IdentityProfileRestClient<T extends IJsonLdDocument = IJson
|
|
|
49
50
|
* Update the profile properties of an identity.
|
|
50
51
|
* @param publicProfile The public profile data as JSON-LD.
|
|
51
52
|
* @param privateProfile The private profile data as JSON-LD.
|
|
53
|
+
* @param identity The identity to perform the profile operation on, defaults to the current user.
|
|
52
54
|
* @returns A promise that resolves when the profile has been updated.
|
|
53
55
|
*/
|
|
54
|
-
update(publicProfile?: T, privateProfile?: U): Promise<void>;
|
|
56
|
+
update(publicProfile?: T, privateProfile?: U, identity?: string): Promise<void>;
|
|
55
57
|
/**
|
|
56
58
|
* Delete the profile for an identity.
|
|
59
|
+
* @param identity The identity to perform the profile operation on, defaults to the current user.
|
|
57
60
|
* @returns A promise that resolves when the profile has been removed.
|
|
58
61
|
*/
|
|
59
|
-
remove(): Promise<void>;
|
|
62
|
+
remove(identity?: string): Promise<void>;
|
|
60
63
|
/**
|
|
61
64
|
* Get a list of the requested identities.
|
|
62
65
|
* @param publicFilters The filters to apply to the identities public profiles.
|
|
@@ -81,4 +84,28 @@ export declare class IdentityProfileRestClient<T extends IJsonLdDocument = IJson
|
|
|
81
84
|
*/
|
|
82
85
|
cursor?: string;
|
|
83
86
|
}>;
|
|
87
|
+
/**
|
|
88
|
+
* Get the list of identity profiles including private properties.
|
|
89
|
+
* @param publicFilters The filters to apply to the identities public profiles.
|
|
90
|
+
* @param privateFilters The filters to apply to the identities private profiles.
|
|
91
|
+
* @param publicPropertyNames The public properties to get for the profile, defaults to all.
|
|
92
|
+
* @param privatePropertyNames The private properties to get for the profile, defaults to none.
|
|
93
|
+
* @param cursor The cursor for paged requests.
|
|
94
|
+
* @param limit The maximum number of items in a page.
|
|
95
|
+
* @returns The list of items and cursor for paging.
|
|
96
|
+
*/
|
|
97
|
+
listAdmin(publicFilters?: {
|
|
98
|
+
propertyName: string;
|
|
99
|
+
propertyValue: unknown;
|
|
100
|
+
}[], privateFilters?: {
|
|
101
|
+
propertyName: string;
|
|
102
|
+
propertyValue: unknown;
|
|
103
|
+
}[], publicPropertyNames?: (keyof T)[], privatePropertyNames?: (keyof U)[], cursor?: string, limit?: number): Promise<{
|
|
104
|
+
items: {
|
|
105
|
+
identity: string;
|
|
106
|
+
publicProfile?: Partial<T>;
|
|
107
|
+
privateProfile?: Partial<U>;
|
|
108
|
+
}[];
|
|
109
|
+
cursor?: string;
|
|
110
|
+
}>;
|
|
84
111
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.9.2-next.7](https://github.com/iotaledger/twin-identity/compare/identity-rest-client-v0.9.2-next.6...identity-rest-client-v0.9.2-next.7) (2026-08-14)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* admin endpoints ([#199](https://github.com/iotaledger/twin-identity/issues/199)) ([da6c189](https://github.com/iotaledger/twin-identity/commit/da6c18963ed551451d919e36aedc1dd8b005a12f))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/identity-models bumped from 0.9.2-next.6 to 0.9.2-next.7
|
|
16
|
+
|
|
17
|
+
## [0.9.2-next.6](https://github.com/iotaledger/twin-identity/compare/identity-rest-client-v0.9.2-next.5...identity-rest-client-v0.9.2-next.6) (2026-08-11)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Miscellaneous Chores
|
|
21
|
+
|
|
22
|
+
* **identity-rest-client:** Synchronize repo versions
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
* The following workspace dependencies were updated
|
|
28
|
+
* dependencies
|
|
29
|
+
* @twin.org/identity-models bumped from 0.9.2-next.5 to 0.9.2-next.6
|
|
30
|
+
|
|
3
31
|
## [0.9.2-next.5](https://github.com/iotaledger/twin-identity/compare/identity-rest-client-v0.9.2-next.4...identity-rest-client-v0.9.2-next.5) (2026-08-10)
|
|
4
32
|
|
|
5
33
|
|
|
@@ -106,7 +106,7 @@ A promise that resolves when the profile has been created.
|
|
|
106
106
|
|
|
107
107
|
### get() {#get}
|
|
108
108
|
|
|
109
|
-
> **get**(`publicPropertyNames?`, `privatePropertyNames?`): `Promise`\<\{ `identity`: `string`; `publicProfile?`: `Partial`\<`T`\>; `privateProfile?`: `Partial`\<`U`\>; \}\>
|
|
109
|
+
> **get**(`publicPropertyNames?`, `privatePropertyNames?`, `identity?`): `Promise`\<\{ `identity`: `string`; `publicProfile?`: `Partial`\<`T`\>; `privateProfile?`: `Partial`\<`U`\>; \}\>
|
|
110
110
|
|
|
111
111
|
Get the profile properties for an identity.
|
|
112
112
|
|
|
@@ -124,6 +124,12 @@ keyof `U`[]
|
|
|
124
124
|
|
|
125
125
|
The private properties to get for the profile, defaults to all.
|
|
126
126
|
|
|
127
|
+
##### identity?
|
|
128
|
+
|
|
129
|
+
`string`
|
|
130
|
+
|
|
131
|
+
The identity to perform the profile operation on, defaults to the current user.
|
|
132
|
+
|
|
127
133
|
#### Returns
|
|
128
134
|
|
|
129
135
|
`Promise`\<\{ `identity`: `string`; `publicProfile?`: `Partial`\<`T`\>; `privateProfile?`: `Partial`\<`U`\>; \}\>
|
|
@@ -170,7 +176,7 @@ The items properties.
|
|
|
170
176
|
|
|
171
177
|
### update() {#update}
|
|
172
178
|
|
|
173
|
-
> **update**(`publicProfile?`, `privateProfile?`): `Promise`\<`void`\>
|
|
179
|
+
> **update**(`publicProfile?`, `privateProfile?`, `identity?`): `Promise`\<`void`\>
|
|
174
180
|
|
|
175
181
|
Update the profile properties of an identity.
|
|
176
182
|
|
|
@@ -188,6 +194,12 @@ The public profile data as JSON-LD.
|
|
|
188
194
|
|
|
189
195
|
The private profile data as JSON-LD.
|
|
190
196
|
|
|
197
|
+
##### identity?
|
|
198
|
+
|
|
199
|
+
`string`
|
|
200
|
+
|
|
201
|
+
The identity to perform the profile operation on, defaults to the current user.
|
|
202
|
+
|
|
191
203
|
#### Returns
|
|
192
204
|
|
|
193
205
|
`Promise`\<`void`\>
|
|
@@ -202,10 +214,18 @@ A promise that resolves when the profile has been updated.
|
|
|
202
214
|
|
|
203
215
|
### remove() {#remove}
|
|
204
216
|
|
|
205
|
-
> **remove**(): `Promise`\<`void`\>
|
|
217
|
+
> **remove**(`identity?`): `Promise`\<`void`\>
|
|
206
218
|
|
|
207
219
|
Delete the profile for an identity.
|
|
208
220
|
|
|
221
|
+
#### Parameters
|
|
222
|
+
|
|
223
|
+
##### identity?
|
|
224
|
+
|
|
225
|
+
`string`
|
|
226
|
+
|
|
227
|
+
The identity to perform the profile operation on, defaults to the current user.
|
|
228
|
+
|
|
209
229
|
#### Returns
|
|
210
230
|
|
|
211
231
|
`Promise`\<`void`\>
|
|
@@ -259,3 +279,59 @@ The list of items and cursor for paging.
|
|
|
259
279
|
#### Implementation of
|
|
260
280
|
|
|
261
281
|
`IIdentityProfileComponent.list`
|
|
282
|
+
|
|
283
|
+
***
|
|
284
|
+
|
|
285
|
+
### listAdmin() {#listadmin}
|
|
286
|
+
|
|
287
|
+
> **listAdmin**(`publicFilters?`, `privateFilters?`, `publicPropertyNames?`, `privatePropertyNames?`, `cursor?`, `limit?`): `Promise`\<\{ `items`: `object`[]; `cursor?`: `string`; \}\>
|
|
288
|
+
|
|
289
|
+
Get the list of identity profiles including private properties.
|
|
290
|
+
|
|
291
|
+
#### Parameters
|
|
292
|
+
|
|
293
|
+
##### publicFilters?
|
|
294
|
+
|
|
295
|
+
`object`[]
|
|
296
|
+
|
|
297
|
+
The filters to apply to the identities public profiles.
|
|
298
|
+
|
|
299
|
+
##### privateFilters?
|
|
300
|
+
|
|
301
|
+
`object`[]
|
|
302
|
+
|
|
303
|
+
The filters to apply to the identities private profiles.
|
|
304
|
+
|
|
305
|
+
##### publicPropertyNames?
|
|
306
|
+
|
|
307
|
+
keyof `T`[]
|
|
308
|
+
|
|
309
|
+
The public properties to get for the profile, defaults to all.
|
|
310
|
+
|
|
311
|
+
##### privatePropertyNames?
|
|
312
|
+
|
|
313
|
+
keyof `U`[]
|
|
314
|
+
|
|
315
|
+
The private properties to get for the profile, defaults to none.
|
|
316
|
+
|
|
317
|
+
##### cursor?
|
|
318
|
+
|
|
319
|
+
`string`
|
|
320
|
+
|
|
321
|
+
The cursor for paged requests.
|
|
322
|
+
|
|
323
|
+
##### limit?
|
|
324
|
+
|
|
325
|
+
`number`
|
|
326
|
+
|
|
327
|
+
The maximum number of items in a page.
|
|
328
|
+
|
|
329
|
+
#### Returns
|
|
330
|
+
|
|
331
|
+
`Promise`\<\{ `items`: `object`[]; `cursor?`: `string`; \}\>
|
|
332
|
+
|
|
333
|
+
The list of items and cursor for paging.
|
|
334
|
+
|
|
335
|
+
#### Implementation of
|
|
336
|
+
|
|
337
|
+
`IIdentityProfileComponent.listAdmin`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/identity-rest-client",
|
|
3
|
-
"version": "0.9.2-next.
|
|
3
|
+
"version": "0.9.2-next.7",
|
|
4
4
|
"description": "Client library for consuming identity REST endpoints through shared request and response contracts.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,7 +20,7 @@
|
|
|
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.9.2-next.
|
|
23
|
+
"@twin.org/identity-models": "0.9.2-next.7",
|
|
24
24
|
"@twin.org/nameof": "next",
|
|
25
25
|
"@twin.org/standards-w3c-did": "next",
|
|
26
26
|
"@twin.org/web": "next"
|