@twin.org/api-auth-entity-storage-rest-client 0.0.3-next.20 → 0.0.3-next.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # TWIN Auth Entity Storage
1
+ # TWIN API Auth Entity Storage REST Client
2
2
 
3
- Perform REST authentication using entity storage.
3
+ This package provides REST clients for authentication and admin operations against entity storage endpoints.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```shell
8
- npm install @twin.org/api-auth-entity-storage
8
+ npm install @twin.org/api-auth-entity-storage-rest-client
9
9
  ```
10
10
 
11
11
  ## Examples
@@ -1 +1 @@
1
- {"version":3,"file":"entityStorageAuthenticationRestClientConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/entityStorageAuthenticationRestClientConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IBaseRestClientConfig } from \"@twin.org/api-models\";\n\n/**\n * Options for the Entity Storage Authentication REST client constructor.\n */\nexport interface IEntityStorageAuthenticationRestClientConstructorOptions\n\textends IBaseRestClientConfig {\n\t/**\n\t * The name of the cookie to use for storing the auth token.\n\t * @default access_token\n\t */\n\tcookieName?: string;\n}\n"]}
1
+ {"version":3,"file":"entityStorageAuthenticationRestClientConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/entityStorageAuthenticationRestClientConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IBaseRestClientConfig } from \"@twin.org/api-models\";\n\n/**\n * Options for the Entity Storage Authentication REST client constructor.\n */\nexport interface IEntityStorageAuthenticationRestClientConstructorOptions extends IBaseRestClientConfig {\n\t/**\n\t * The name of the cookie to use for storing the auth token.\n\t * @default access_token\n\t */\n\tcookieName?: string;\n}\n"]}
package/docs/changelog.md CHANGED
@@ -1,4 +1,20 @@
1
- # @twin.org/api-auth-entity-storage-rest-client - Changelog
1
+ # Changelog
2
+
3
+ ## [0.0.3-next.21](https://github.com/twinfoundation/api/compare/api-auth-entity-storage-rest-client-v0.0.3-next.20...api-auth-entity-storage-rest-client-v0.0.3-next.21) (2026-03-11)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **api-auth-entity-storage-rest-client:** Synchronize repo versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/api-auth-entity-storage-models bumped from 0.0.3-next.20 to 0.0.3-next.21
16
+ * @twin.org/api-core bumped from 0.0.3-next.20 to 0.0.3-next.21
17
+ * @twin.org/api-models bumped from 0.0.3-next.20 to 0.0.3-next.21
2
18
 
3
19
  ## [0.0.3-next.20](https://github.com/twinfoundation/api/compare/api-auth-entity-storage-rest-client-v0.0.3-next.19...api-auth-entity-storage-rest-client-v0.0.3-next.20) (2026-02-09)
4
20
 
package/docs/examples.md CHANGED
@@ -1 +1,73 @@
1
- # @twin.org/api-auth-entity-storage-rest-client - Examples
1
+ # Auth Entity Storage Rest Client Examples
2
+
3
+ Use these snippets to integrate sign-in and user administration flows from browser or server-side TypeScript applications.
4
+
5
+ ## EntityStorageAuthenticationAdminRestClient
6
+
7
+ ```typescript
8
+ import { EntityStorageAuthenticationAdminRestClient } from '@twin.org/api-auth-entity-storage-rest-client';
9
+
10
+ const adminClient = new EntityStorageAuthenticationAdminRestClient({
11
+ endpoint: 'https://api.example.org',
12
+ pathPrefix: 'v1'
13
+ });
14
+
15
+ console.log(adminClient.className()); // EntityStorageAuthenticationAdminRestClient
16
+
17
+ await adminClient.create({
18
+ email: 'ops@example.org',
19
+ password: 'StrongPassword123',
20
+ userIdentity: 'did:example:ops',
21
+ organizationIdentity: 'did:example:core',
22
+ scope: ['admin']
23
+ });
24
+
25
+ await adminClient.update({
26
+ email: 'ops@example.org',
27
+ userIdentity: 'did:example:ops:team',
28
+ scope: ['admin', 'support']
29
+ });
30
+
31
+ await adminClient.updatePassword('ops@example.org', 'StrongPassword124', 'StrongPassword123');
32
+ const adminUser = await adminClient.get('ops@example.org');
33
+ console.log(adminUser.email); // ops@example.org
34
+ ```
35
+
36
+ ```typescript
37
+ import { EntityStorageAuthenticationAdminRestClient } from '@twin.org/api-auth-entity-storage-rest-client';
38
+
39
+ const adminClient = new EntityStorageAuthenticationAdminRestClient({
40
+ endpoint: 'https://api.example.org',
41
+ pathPrefix: 'v1'
42
+ });
43
+
44
+ const byEmail = await adminClient.get('ops@example.org');
45
+ const byIdentity = await adminClient.getByIdentity('ops-team@example.org');
46
+ await adminClient.remove('ops@example.org');
47
+
48
+ console.log(byEmail.email); // ops@example.org
49
+ console.log(byIdentity.userIdentity); // did:example:ops:team
50
+ ```
51
+
52
+ ## EntityStorageAuthenticationRestClient
53
+
54
+ ```typescript
55
+ import { EntityStorageAuthenticationRestClient } from '@twin.org/api-auth-entity-storage-rest-client';
56
+
57
+ const authClient = new EntityStorageAuthenticationRestClient({
58
+ endpoint: 'https://api.example.org',
59
+ pathPrefix: 'v1',
60
+ cookieName: 'access_token'
61
+ });
62
+
63
+ console.log(authClient.className()); // EntityStorageAuthenticationRestClient
64
+
65
+ const loginResponse = await authClient.login('alice@example.org', 'correct-horse-battery-staple');
66
+
67
+ await authClient.updatePassword('correct-horse-battery-staple', 'correct-horse-battery-staple-2');
68
+
69
+ const refreshResponse = await authClient.refresh(loginResponse.token);
70
+
71
+ await authClient.logout(refreshResponse.token);
72
+ console.log(refreshResponse.expiry > 0); // true
73
+ ```
@@ -227,3 +227,69 @@ Nothing.
227
227
  #### Implementation of
228
228
 
229
229
  `IAuthenticationAdminComponent.updatePassword`
230
+
231
+ ***
232
+
233
+ ### getEndpointWithPrefix()
234
+
235
+ > **getEndpointWithPrefix**(): `string`
236
+
237
+ Get the endpoint with the prefix for the namespace.
238
+
239
+ #### Returns
240
+
241
+ `string`
242
+
243
+ The endpoint with namespace prefix attached.
244
+
245
+ #### Inherited from
246
+
247
+ `BaseRestClient.getEndpointWithPrefix`
248
+
249
+ ***
250
+
251
+ ### fetch()
252
+
253
+ > **fetch**\<`T`, `U`\>(`route`, `method`, `request?`): `Promise`\<`U`\>
254
+
255
+ Perform a request in json format.
256
+
257
+ #### Type Parameters
258
+
259
+ ##### T
260
+
261
+ `T` *extends* `IHttpRequest`\<`any`\>
262
+
263
+ ##### U
264
+
265
+ `U` *extends* `IHttpResponse`\<`any`\>
266
+
267
+ #### Parameters
268
+
269
+ ##### route
270
+
271
+ `string`
272
+
273
+ The route of the request.
274
+
275
+ ##### method
276
+
277
+ `HttpMethod`
278
+
279
+ The http method.
280
+
281
+ ##### request?
282
+
283
+ `T`
284
+
285
+ Request to send to the endpoint.
286
+
287
+ #### Returns
288
+
289
+ `Promise`\<`U`\>
290
+
291
+ The response.
292
+
293
+ #### Inherited from
294
+
295
+ `BaseRestClient.fetch`
@@ -175,3 +175,69 @@ Nothing.
175
175
  #### Implementation of
176
176
 
177
177
  `IAuthenticationComponent.updatePassword`
178
+
179
+ ***
180
+
181
+ ### getEndpointWithPrefix()
182
+
183
+ > **getEndpointWithPrefix**(): `string`
184
+
185
+ Get the endpoint with the prefix for the namespace.
186
+
187
+ #### Returns
188
+
189
+ `string`
190
+
191
+ The endpoint with namespace prefix attached.
192
+
193
+ #### Inherited from
194
+
195
+ `BaseRestClient.getEndpointWithPrefix`
196
+
197
+ ***
198
+
199
+ ### fetch()
200
+
201
+ > **fetch**\<`T`, `U`\>(`route`, `method`, `request?`): `Promise`\<`U`\>
202
+
203
+ Perform a request in json format.
204
+
205
+ #### Type Parameters
206
+
207
+ ##### T
208
+
209
+ `T` *extends* `IHttpRequest`\<`any`\>
210
+
211
+ ##### U
212
+
213
+ `U` *extends* `IHttpResponse`\<`any`\>
214
+
215
+ #### Parameters
216
+
217
+ ##### route
218
+
219
+ `string`
220
+
221
+ The route of the request.
222
+
223
+ ##### method
224
+
225
+ `HttpMethod`
226
+
227
+ The http method.
228
+
229
+ ##### request?
230
+
231
+ `T`
232
+
233
+ Request to send to the endpoint.
234
+
235
+ #### Returns
236
+
237
+ `Promise`\<`U`\>
238
+
239
+ The response.
240
+
241
+ #### Inherited from
242
+
243
+ `BaseRestClient.fetch`
@@ -14,8 +14,62 @@ Options for the Entity Storage Authentication REST client constructor.
14
14
 
15
15
  The name of the cookie to use for storing the auth token.
16
16
 
17
- #### Default
17
+ ***
18
18
 
19
- ```ts
20
- access_token
21
- ```
19
+ ### endpoint
20
+
21
+ > **endpoint**: `string`
22
+
23
+ The endpoint where the api is hosted.
24
+
25
+ #### Inherited from
26
+
27
+ `IBaseRestClientConfig.endpoint`
28
+
29
+ ***
30
+
31
+ ### pathPrefix?
32
+
33
+ > `optional` **pathPrefix**: `string`
34
+
35
+ The prefix to the routes.
36
+
37
+ #### Inherited from
38
+
39
+ `IBaseRestClientConfig.pathPrefix`
40
+
41
+ ***
42
+
43
+ ### headers?
44
+
45
+ > `optional` **headers**: `IHttpHeaders`
46
+
47
+ The headers to include in requests.
48
+
49
+ #### Inherited from
50
+
51
+ `IBaseRestClientConfig.headers`
52
+
53
+ ***
54
+
55
+ ### timeout?
56
+
57
+ > `optional` **timeout**: `number`
58
+
59
+ Timeout for requests in ms.
60
+
61
+ #### Inherited from
62
+
63
+ `IBaseRestClientConfig.timeout`
64
+
65
+ ***
66
+
67
+ ### includeCredentials?
68
+
69
+ > `optional` **includeCredentials**: `boolean`
70
+
71
+ Include credentials in the request, defaults to true.
72
+
73
+ #### Inherited from
74
+
75
+ `IBaseRestClientConfig.includeCredentials`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@twin.org/api-auth-entity-storage-rest-client",
3
- "version": "0.0.3-next.20",
4
- "description": "Perform REST authentication using entity storage.",
3
+ "version": "0.0.3-next.21",
4
+ "description": "REST clients for authentication and admin operations against entity storage endpoints.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/twinfoundation/api.git",
@@ -14,9 +14,9 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/api-auth-entity-storage-models": "0.0.3-next.20",
18
- "@twin.org/api-core": "0.0.3-next.20",
19
- "@twin.org/api-models": "0.0.3-next.20",
17
+ "@twin.org/api-auth-entity-storage-models": "0.0.3-next.21",
18
+ "@twin.org/api-core": "0.0.3-next.21",
19
+ "@twin.org/api-models": "0.0.3-next.21",
20
20
  "@twin.org/core": "next",
21
21
  "@twin.org/nameof": "next",
22
22
  "@twin.org/web": "next"