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

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,36 @@
1
- # @twin.org/api-auth-entity-storage-rest-client - Changelog
1
+ # Changelog
2
+
3
+ ## [0.0.3-next.22](https://github.com/twinfoundation/api/compare/api-auth-entity-storage-rest-client-v0.0.3-next.21...api-auth-entity-storage-rest-client-v0.0.3-next.22) (2026-03-27)
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.21 to 0.0.3-next.22
16
+ * @twin.org/api-core bumped from 0.0.3-next.21 to 0.0.3-next.22
17
+ * @twin.org/api-models bumped from 0.0.3-next.21 to 0.0.3-next.22
18
+
19
+ ## [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)
20
+
21
+
22
+ ### Miscellaneous Chores
23
+
24
+ * **api-auth-entity-storage-rest-client:** Synchronize repo versions
25
+
26
+
27
+ ### Dependencies
28
+
29
+ * The following workspace dependencies were updated
30
+ * dependencies
31
+ * @twin.org/api-auth-entity-storage-models bumped from 0.0.3-next.20 to 0.0.3-next.21
32
+ * @twin.org/api-core bumped from 0.0.3-next.20 to 0.0.3-next.21
33
+ * @twin.org/api-models bumped from 0.0.3-next.20 to 0.0.3-next.21
2
34
 
3
35
  ## [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
36
 
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
+ ```
@@ -36,7 +36,7 @@ The configuration for the client.
36
36
 
37
37
  ## Properties
38
38
 
39
- ### CLASS\_NAME
39
+ ### CLASS\_NAME {#class_name}
40
40
 
41
41
  > `readonly` `static` **CLASS\_NAME**: `string`
42
42
 
@@ -44,7 +44,7 @@ Runtime name for the class.
44
44
 
45
45
  ## Methods
46
46
 
47
- ### className()
47
+ ### className() {#classname}
48
48
 
49
49
  > **className**(): `string`
50
50
 
@@ -62,7 +62,7 @@ The class name of the component.
62
62
 
63
63
  ***
64
64
 
65
- ### create()
65
+ ### create() {#create}
66
66
 
67
67
  > **create**(`user`): `Promise`\<`void`\>
68
68
 
@@ -88,7 +88,7 @@ Nothing.
88
88
 
89
89
  ***
90
90
 
91
- ### update()
91
+ ### update() {#update}
92
92
 
93
93
  > **update**(`user`): `Promise`\<`void`\>
94
94
 
@@ -114,7 +114,7 @@ Nothing.
114
114
 
115
115
  ***
116
116
 
117
- ### get()
117
+ ### get() {#get}
118
118
 
119
119
  > **get**(`email`): `Promise`\<`Omit`\<`IAuthenticationUser`, `"salt"` \| `"password"`\>\>
120
120
 
@@ -140,7 +140,7 @@ The user details.
140
140
 
141
141
  ***
142
142
 
143
- ### getByIdentity()
143
+ ### getByIdentity() {#getbyidentity}
144
144
 
145
145
  > **getByIdentity**(`identity`): `Promise`\<`Omit`\<`IAuthenticationUser`, `"salt"` \| `"password"`\>\>
146
146
 
@@ -166,7 +166,7 @@ The user details.
166
166
 
167
167
  ***
168
168
 
169
- ### remove()
169
+ ### remove() {#remove}
170
170
 
171
171
  > **remove**(`email`): `Promise`\<`void`\>
172
172
 
@@ -192,7 +192,7 @@ Nothing.
192
192
 
193
193
  ***
194
194
 
195
- ### updatePassword()
195
+ ### updatePassword() {#updatepassword}
196
196
 
197
197
  > **updatePassword**(`email`, `newPassword`, `currentPassword?`): `Promise`\<`void`\>
198
198
 
@@ -227,3 +227,69 @@ Nothing.
227
227
  #### Implementation of
228
228
 
229
229
  `IAuthenticationAdminComponent.updatePassword`
230
+
231
+ ***
232
+
233
+ ### getEndpointWithPrefix() {#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() {#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`
@@ -36,7 +36,7 @@ The configuration for the client.
36
36
 
37
37
  ## Properties
38
38
 
39
- ### CLASS\_NAME
39
+ ### CLASS\_NAME {#class_name}
40
40
 
41
41
  > `readonly` `static` **CLASS\_NAME**: `string`
42
42
 
@@ -44,7 +44,7 @@ Runtime name for the class.
44
44
 
45
45
  ## Methods
46
46
 
47
- ### className()
47
+ ### className() {#classname}
48
48
 
49
49
  > **className**(): `string`
50
50
 
@@ -62,7 +62,7 @@ The class name of the component.
62
62
 
63
63
  ***
64
64
 
65
- ### login()
65
+ ### login() {#login}
66
66
 
67
67
  > **login**(`email`, `password`): `Promise`\<\{ `token?`: `string`; `expiry`: `number`; \}\>
68
68
 
@@ -94,7 +94,7 @@ The authentication token for the user, if it uses a mechanism with public access
94
94
 
95
95
  ***
96
96
 
97
- ### logout()
97
+ ### logout() {#logout}
98
98
 
99
99
  > **logout**(`token?`): `Promise`\<`void`\>
100
100
 
@@ -120,7 +120,7 @@ Nothing.
120
120
 
121
121
  ***
122
122
 
123
- ### refresh()
123
+ ### refresh() {#refresh}
124
124
 
125
125
  > **refresh**(`token?`): `Promise`\<\{ `token?`: `string`; `expiry`: `number`; \}\>
126
126
 
@@ -146,7 +146,7 @@ The refreshed token, if it uses a mechanism with public access.
146
146
 
147
147
  ***
148
148
 
149
- ### updatePassword()
149
+ ### updatePassword() {#updatepassword}
150
150
 
151
151
  > **updatePassword**(`currentPassword`, `newPassword`): `Promise`\<`void`\>
152
152
 
@@ -175,3 +175,69 @@ Nothing.
175
175
  #### Implementation of
176
176
 
177
177
  `IAuthenticationComponent.updatePassword`
178
+
179
+ ***
180
+
181
+ ### getEndpointWithPrefix() {#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() {#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`
@@ -8,9 +8,9 @@ Options for the Entity Storage Authentication REST client constructor.
8
8
 
9
9
  ## Properties
10
10
 
11
- ### cookieName?
11
+ ### cookieName? {#cookiename}
12
12
 
13
- > `optional` **cookieName**: `string`
13
+ > `optional` **cookieName?**: `string`
14
14
 
15
15
  The name of the cookie to use for storing the auth token.
16
16
 
@@ -19,3 +19,63 @@ The name of the cookie to use for storing the auth token.
19
19
  ```ts
20
20
  access_token
21
21
  ```
22
+
23
+ ***
24
+
25
+ ### endpoint {#endpoint}
26
+
27
+ > **endpoint**: `string`
28
+
29
+ The endpoint where the api is hosted.
30
+
31
+ #### Inherited from
32
+
33
+ `IBaseRestClientConfig.endpoint`
34
+
35
+ ***
36
+
37
+ ### pathPrefix? {#pathprefix}
38
+
39
+ > `optional` **pathPrefix?**: `string`
40
+
41
+ The prefix to the routes.
42
+
43
+ #### Inherited from
44
+
45
+ `IBaseRestClientConfig.pathPrefix`
46
+
47
+ ***
48
+
49
+ ### headers? {#headers}
50
+
51
+ > `optional` **headers?**: `IHttpHeaders`
52
+
53
+ The headers to include in requests.
54
+
55
+ #### Inherited from
56
+
57
+ `IBaseRestClientConfig.headers`
58
+
59
+ ***
60
+
61
+ ### timeout? {#timeout}
62
+
63
+ > `optional` **timeout?**: `number`
64
+
65
+ Timeout for requests in ms.
66
+
67
+ #### Inherited from
68
+
69
+ `IBaseRestClientConfig.timeout`
70
+
71
+ ***
72
+
73
+ ### includeCredentials? {#includecredentials}
74
+
75
+ > `optional` **includeCredentials?**: `boolean`
76
+
77
+ Include credentials in the request, defaults to true.
78
+
79
+ #### Inherited from
80
+
81
+ `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.22",
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.22",
18
+ "@twin.org/api-core": "0.0.3-next.22",
19
+ "@twin.org/api-models": "0.0.3-next.22",
20
20
  "@twin.org/core": "next",
21
21
  "@twin.org/nameof": "next",
22
22
  "@twin.org/web": "next"