@twin.org/api-auth-entity-storage-rest-client 0.0.3-next.4 → 0.0.3-next.40

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.
Files changed (24) hide show
  1. package/README.md +3 -3
  2. package/dist/es/entityStorageAuthenticationAdminRestClient.js +114 -0
  3. package/dist/es/entityStorageAuthenticationAdminRestClient.js.map +1 -0
  4. package/dist/es/entityStorageAuthenticationAuditRestClient.js +73 -0
  5. package/dist/es/entityStorageAuthenticationAuditRestClient.js.map +1 -0
  6. package/dist/es/entityStorageAuthenticationRestClient.js +27 -13
  7. package/dist/es/entityStorageAuthenticationRestClient.js.map +1 -1
  8. package/dist/es/index.js +3 -0
  9. package/dist/es/index.js.map +1 -1
  10. package/dist/es/models/entityStorageAuthenticationRestClientConstructorOptions.js +2 -0
  11. package/dist/es/models/entityStorageAuthenticationRestClientConstructorOptions.js.map +1 -0
  12. package/dist/types/entityStorageAuthenticationAdminRestClient.d.ts +62 -0
  13. package/dist/types/entityStorageAuthenticationAuditRestClient.d.ts +54 -0
  14. package/dist/types/entityStorageAuthenticationRestClient.d.ts +3 -4
  15. package/dist/types/index.d.ts +3 -0
  16. package/dist/types/models/entityStorageAuthenticationRestClientConstructorOptions.d.ts +11 -0
  17. package/docs/changelog.md +643 -54
  18. package/docs/examples.md +111 -1
  19. package/docs/reference/classes/EntityStorageAuthenticationAdminRestClient.md +295 -0
  20. package/docs/reference/classes/EntityStorageAuthenticationAuditRestClient.md +231 -0
  21. package/docs/reference/classes/EntityStorageAuthenticationRestClient.md +74 -14
  22. package/docs/reference/index.md +6 -0
  23. package/docs/reference/interfaces/IEntityStorageAuthenticationRestClientConstructorOptions.md +141 -0
  24. package/package.json +7 -7
package/docs/examples.md CHANGED
@@ -1 +1,111 @@
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
+ ```
74
+
75
+ ## EntityStorageAuthenticationAuditRestClient
76
+
77
+ ```typescript
78
+ import { EntityStorageAuthenticationAuditRestClient } from '@twin.org/api-auth-entity-storage-rest-client';
79
+
80
+ const auditClient = new EntityStorageAuthenticationAuditRestClient({
81
+ endpoint: 'https://api.example.org',
82
+ pathPrefix: 'v1'
83
+ });
84
+
85
+ console.log(auditClient.className()); // EntityStorageAuthenticationAuditRestClient
86
+
87
+ const auditEntryId = await auditClient.create({
88
+ event: 'login-success',
89
+ actorId: 'did:example:user:alice',
90
+ organizationId: 'did:example:org:core',
91
+ tenantId: 'did:example:tenant:alpha',
92
+ data: {
93
+ channel: 'web'
94
+ }
95
+ });
96
+
97
+ const auditResult = await auditClient.query(
98
+ {
99
+ actorId: 'did:example:user:alice',
100
+ event: 'login-success',
101
+ startDate: '2026-04-01T00:00:00.000Z',
102
+ endDate: '2026-04-30T23:59:59.999Z'
103
+ },
104
+ undefined,
105
+ 25
106
+ );
107
+
108
+ console.log(auditEntryId); // /authentication/audit/018f2f67bb9d4a0caad8386f56df85ce
109
+ console.log(auditResult.entries.length); // 1
110
+ console.log(auditResult.cursor); // eyJpZCI6IjAxOGYyZjY3YmI5ZDRhMGNhYWQ4Mzg2ZjU2ZGY4NWNlIn0=
111
+ ```
@@ -0,0 +1,295 @@
1
+ # Class: EntityStorageAuthenticationAdminRestClient
2
+
3
+ The client to connect to the authentication admin service.
4
+
5
+ ## Extends
6
+
7
+ - `BaseRestClient`
8
+
9
+ ## Implements
10
+
11
+ - `IAuthenticationAdminComponent`
12
+
13
+ ## Constructors
14
+
15
+ ### Constructor
16
+
17
+ > **new EntityStorageAuthenticationAdminRestClient**(`config`): `EntityStorageAuthenticationAdminRestClient`
18
+
19
+ Create a new instance of EntityStorageAuthenticationAdminRestClient.
20
+
21
+ #### Parameters
22
+
23
+ ##### config
24
+
25
+ `IBaseRestClientConfig`
26
+
27
+ The configuration for the client.
28
+
29
+ #### Returns
30
+
31
+ `EntityStorageAuthenticationAdminRestClient`
32
+
33
+ #### Overrides
34
+
35
+ `BaseRestClient.constructor`
36
+
37
+ ## Properties
38
+
39
+ ### CLASS\_NAME {#class_name}
40
+
41
+ > `readonly` `static` **CLASS\_NAME**: `string`
42
+
43
+ Runtime name for the class.
44
+
45
+ ## Methods
46
+
47
+ ### className() {#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
+ `IAuthenticationAdminComponent.className`
62
+
63
+ ***
64
+
65
+ ### create() {#create}
66
+
67
+ > **create**(`user`): `Promise`\<`void`\>
68
+
69
+ Create a login for the user.
70
+
71
+ #### Parameters
72
+
73
+ ##### user
74
+
75
+ `IAuthenticationUser` & `object`
76
+
77
+ The user to create.
78
+
79
+ #### Returns
80
+
81
+ `Promise`\<`void`\>
82
+
83
+ Nothing.
84
+
85
+ #### Implementation of
86
+
87
+ `IAuthenticationAdminComponent.create`
88
+
89
+ ***
90
+
91
+ ### update() {#update}
92
+
93
+ > **update**(`user`): `Promise`\<`void`\>
94
+
95
+ Update a login for the user.
96
+
97
+ #### Parameters
98
+
99
+ ##### user
100
+
101
+ `Partial`\<`IAuthenticationUser`\>
102
+
103
+ The user to update.
104
+
105
+ #### Returns
106
+
107
+ `Promise`\<`void`\>
108
+
109
+ Nothing.
110
+
111
+ #### Implementation of
112
+
113
+ `IAuthenticationAdminComponent.update`
114
+
115
+ ***
116
+
117
+ ### get() {#get}
118
+
119
+ > **get**(`email`): `Promise`\<`IAuthenticationUser`\>
120
+
121
+ Get a user by email.
122
+
123
+ #### Parameters
124
+
125
+ ##### email
126
+
127
+ `string`
128
+
129
+ The email address of the user to get.
130
+
131
+ #### Returns
132
+
133
+ `Promise`\<`IAuthenticationUser`\>
134
+
135
+ The user details.
136
+
137
+ #### Implementation of
138
+
139
+ `IAuthenticationAdminComponent.get`
140
+
141
+ ***
142
+
143
+ ### getByIdentity() {#getbyidentity}
144
+
145
+ > **getByIdentity**(`identity`): `Promise`\<`IAuthenticationUser`\>
146
+
147
+ Get a user by identity.
148
+
149
+ #### Parameters
150
+
151
+ ##### identity
152
+
153
+ `string`
154
+
155
+ The identity of the user to get.
156
+
157
+ #### Returns
158
+
159
+ `Promise`\<`IAuthenticationUser`\>
160
+
161
+ The user details.
162
+
163
+ #### Implementation of
164
+
165
+ `IAuthenticationAdminComponent.getByIdentity`
166
+
167
+ ***
168
+
169
+ ### remove() {#remove}
170
+
171
+ > **remove**(`email`): `Promise`\<`void`\>
172
+
173
+ Remove a user.
174
+
175
+ #### Parameters
176
+
177
+ ##### email
178
+
179
+ `string`
180
+
181
+ The email address of the user to remove.
182
+
183
+ #### Returns
184
+
185
+ `Promise`\<`void`\>
186
+
187
+ Nothing.
188
+
189
+ #### Implementation of
190
+
191
+ `IAuthenticationAdminComponent.remove`
192
+
193
+ ***
194
+
195
+ ### updatePassword() {#updatepassword}
196
+
197
+ > **updatePassword**(`email`, `newPassword`, `currentPassword?`): `Promise`\<`void`\>
198
+
199
+ Update the user's password.
200
+
201
+ #### Parameters
202
+
203
+ ##### email
204
+
205
+ `string`
206
+
207
+ The email address of the user to update.
208
+
209
+ ##### newPassword
210
+
211
+ `string`
212
+
213
+ The new password for the user.
214
+
215
+ ##### currentPassword?
216
+
217
+ `string`
218
+
219
+ The current password, optional, if supplied will check against existing.
220
+
221
+ #### Returns
222
+
223
+ `Promise`\<`void`\>
224
+
225
+ Nothing.
226
+
227
+ #### Implementation of
228
+
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`
@@ -0,0 +1,231 @@
1
+ # Class: EntityStorageAuthenticationAuditRestClient
2
+
3
+ The client to connect to the authentication audit service.
4
+
5
+ ## Extends
6
+
7
+ - `BaseRestClient`
8
+
9
+ ## Implements
10
+
11
+ - `IAuthenticationAuditComponent`
12
+
13
+ ## Constructors
14
+
15
+ ### Constructor
16
+
17
+ > **new EntityStorageAuthenticationAuditRestClient**(`config`): `EntityStorageAuthenticationAuditRestClient`
18
+
19
+ Create a new instance of EntityStorageAuthenticationAuditRestClient.
20
+
21
+ #### Parameters
22
+
23
+ ##### config
24
+
25
+ `IBaseRestClientConfig`
26
+
27
+ The configuration for the client.
28
+
29
+ #### Returns
30
+
31
+ `EntityStorageAuthenticationAuditRestClient`
32
+
33
+ #### Overrides
34
+
35
+ `BaseRestClient.constructor`
36
+
37
+ ## Properties
38
+
39
+ ### CLASS\_NAME {#class_name}
40
+
41
+ > `readonly` `static` **CLASS\_NAME**: `string`
42
+
43
+ Runtime name for the class.
44
+
45
+ ## Methods
46
+
47
+ ### className() {#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
+ `IAuthenticationAuditComponent.className`
62
+
63
+ ***
64
+
65
+ ### create() {#create}
66
+
67
+ > **create**(`entry`): `Promise`\<`string`\>
68
+
69
+ Create a new audit entry.
70
+
71
+ #### Parameters
72
+
73
+ ##### entry
74
+
75
+ `Omit`\<`IAuthenticationAuditEntry`, `"id"` \| `"dateCreated"`\>
76
+
77
+ The audit entry to be logged.
78
+
79
+ #### Returns
80
+
81
+ `Promise`\<`string`\>
82
+
83
+ The unique identifier of the created audit entry.
84
+
85
+ #### Implementation of
86
+
87
+ `IAuthenticationAuditComponent.create`
88
+
89
+ ***
90
+
91
+ ### query() {#query}
92
+
93
+ > **query**(`options?`, `cursor?`, `limit?`): `Promise`\<\{ `entries`: `IAuthenticationAuditEntry`[]; `cursor?`: `string`; \}\>
94
+
95
+ Query the audit entries.
96
+
97
+ #### Parameters
98
+
99
+ ##### options?
100
+
101
+ The query options.
102
+
103
+ ###### actorId?
104
+
105
+ `string`
106
+
107
+ The actor identifier to filter the audit entries, optional.
108
+
109
+ ###### organizationId?
110
+
111
+ `string`
112
+
113
+ The organization identifier to filter the audit entries, optional.
114
+
115
+ ###### tenantId?
116
+
117
+ `string`
118
+
119
+ The tenant identifier to filter the audit entries, optional.
120
+
121
+ ###### nodeId?
122
+
123
+ `string`
124
+
125
+ The node identifier to filter the audit entries, optional.
126
+
127
+ ###### event?
128
+
129
+ `string`
130
+
131
+ The audit event to filter the audit entries, optional.
132
+
133
+ ###### startDate?
134
+
135
+ `string`
136
+
137
+ The start date to filter the audit entries, optional.
138
+
139
+ ###### endDate?
140
+
141
+ `string`
142
+
143
+ The end date to filter the audit entries, optional.
144
+
145
+ ##### cursor?
146
+
147
+ `string`
148
+
149
+ The cursor for pagination.
150
+
151
+ ##### limit?
152
+
153
+ `number`
154
+
155
+ The maximum number of entries to return.
156
+
157
+ #### Returns
158
+
159
+ `Promise`\<\{ `entries`: `IAuthenticationAuditEntry`[]; `cursor?`: `string`; \}\>
160
+
161
+ The audit entries.
162
+
163
+ #### Implementation of
164
+
165
+ `IAuthenticationAuditComponent.query`
166
+
167
+ ***
168
+
169
+ ### getEndpointWithPrefix() {#getendpointwithprefix}
170
+
171
+ > **getEndpointWithPrefix**(): `string`
172
+
173
+ Get the endpoint with the prefix for the namespace.
174
+
175
+ #### Returns
176
+
177
+ `string`
178
+
179
+ The endpoint with namespace prefix attached.
180
+
181
+ #### Inherited from
182
+
183
+ `BaseRestClient.getEndpointWithPrefix`
184
+
185
+ ***
186
+
187
+ ### fetch() {#fetch}
188
+
189
+ > **fetch**\<`T`, `U`\>(`route`, `method`, `request?`): `Promise`\<`U`\>
190
+
191
+ Perform a request in json format.
192
+
193
+ #### Type Parameters
194
+
195
+ ##### T
196
+
197
+ `T` *extends* `IHttpRequest`\<`any`\>
198
+
199
+ ##### U
200
+
201
+ `U` *extends* `IHttpResponse`\<`any`\>
202
+
203
+ #### Parameters
204
+
205
+ ##### route
206
+
207
+ `string`
208
+
209
+ The route of the request.
210
+
211
+ ##### method
212
+
213
+ `HttpMethod`
214
+
215
+ The http method.
216
+
217
+ ##### request?
218
+
219
+ `T`
220
+
221
+ Request to send to the endpoint.
222
+
223
+ #### Returns
224
+
225
+ `Promise`\<`U`\>
226
+
227
+ The response.
228
+
229
+ #### Inherited from
230
+
231
+ `BaseRestClient.fetch`