@twin.org/api-auth-entity-storage-service 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,6 +1,6 @@
1
- # TWIN Auth Entity Storage Service
1
+ # TWIN API Auth Entity Storage Service
2
2
 
3
- Auth Entity Storage contract implementation and REST endpoint definitions.
3
+ This package provides an authentication service implementation and REST routes backed by entity storage.
4
4
 
5
5
  ## Installation
6
6
 
package/docs/changelog.md CHANGED
@@ -1,4 +1,36 @@
1
- # @twin.org/api-auth-entity-storage-service - Changelog
1
+ # Changelog
2
+
3
+ ## [0.0.3-next.22](https://github.com/twinfoundation/api/compare/api-auth-entity-storage-service-v0.0.3-next.21...api-auth-entity-storage-service-v0.0.3-next.22) (2026-03-27)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **api-auth-entity-storage-service:** 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-service-v0.0.3-next.20...api-auth-entity-storage-service-v0.0.3-next.21) (2026-03-11)
20
+
21
+
22
+ ### Miscellaneous Chores
23
+
24
+ * **api-auth-entity-storage-service:** 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-service-v0.0.3-next.19...api-auth-entity-storage-service-v0.0.3-next.20) (2026-02-09)
4
36
 
package/docs/examples.md CHANGED
@@ -1 +1,88 @@
1
- # @twin.org/api-auth-entity-storage-service - Examples
1
+ # Auth Entity Storage Service Examples
2
+
3
+ These snippets show how to wire authentication services into your component container and apply token processing in request pipelines.
4
+
5
+ ## EntityStorageAuthenticationAdminService
6
+
7
+ ```typescript
8
+ import { EntityStorageAuthenticationAdminService } from '@twin.org/api-auth-entity-storage-service';
9
+
10
+ const adminService = new EntityStorageAuthenticationAdminService();
11
+
12
+ console.log(adminService.className()); // EntityStorageAuthenticationAdminService
13
+
14
+ await adminService.create({
15
+ email: 'owner@example.org',
16
+ password: 'StartPassword123',
17
+ userIdentity: 'did:example:owner',
18
+ organizationIdentity: 'did:example:org',
19
+ scope: ['admin']
20
+ });
21
+
22
+ await adminService.update({
23
+ email: 'owner@example.org',
24
+ scope: ['admin', 'security']
25
+ });
26
+
27
+ await adminService.updatePassword('owner@example.org', 'StartPassword124', 'StartPassword123');
28
+
29
+ const fromIdentity = await adminService.getByIdentity('did:example:owner');
30
+ console.log(fromIdentity.scope.length); // 2
31
+ ```
32
+
33
+ ```typescript
34
+ import { EntityStorageAuthenticationAdminService } from '@twin.org/api-auth-entity-storage-service';
35
+
36
+ const adminService = new EntityStorageAuthenticationAdminService();
37
+ const user = await adminService.get('owner@example.org');
38
+ await adminService.remove(user.email);
39
+
40
+ console.log(user.email); // owner@example.org
41
+ ```
42
+
43
+ ## EntityStorageAuthenticationService
44
+
45
+ ```typescript
46
+ import { EntityStorageAuthenticationService } from '@twin.org/api-auth-entity-storage-service';
47
+
48
+ const authService = new EntityStorageAuthenticationService();
49
+
50
+ await authService.start('default');
51
+ console.log(authService.className()); // EntityStorageAuthenticationService
52
+
53
+ const loginResult = await authService.login('alice@example.org', 'correct-horse-battery-staple');
54
+
55
+ const refreshResult = await authService.refresh(loginResult.token);
56
+
57
+ await authService.updatePassword('correct-horse-battery-staple', 'correct-horse-battery-staple-2');
58
+
59
+ await authService.logout(refreshResult.token);
60
+ console.log(refreshResult.expiry > 0); // true
61
+ ```
62
+
63
+ ## AuthHeaderProcessor
64
+
65
+ ```typescript
66
+ import { AuthHeaderProcessor } from '@twin.org/api-auth-entity-storage-service';
67
+
68
+ const processor = new AuthHeaderProcessor();
69
+
70
+ await processor.start('default');
71
+ console.log(processor.className()); // AuthHeaderProcessor
72
+
73
+ const request = {
74
+ method: 'get',
75
+ url: '/info',
76
+ headers: {
77
+ authorization: 'Bearer token-value'
78
+ }
79
+ };
80
+
81
+ const response = {};
82
+ const contextIds = {};
83
+ const processorState: { [id: string]: unknown } = {};
84
+
85
+ await processor.pre(request, response, { skipAuth: false }, contextIds, processorState);
86
+
87
+ await processor.post(request, response, { skipAuth: false }, contextIds, processorState);
88
+ ```
@@ -28,7 +28,7 @@ Options for the processor.
28
28
 
29
29
  ## Properties
30
30
 
31
- ### CLASS\_NAME
31
+ ### CLASS\_NAME {#class_name}
32
32
 
33
33
  > `readonly` `static` **CLASS\_NAME**: `string`
34
34
 
@@ -36,7 +36,7 @@ Runtime name for the class.
36
36
 
37
37
  ## Methods
38
38
 
39
- ### className()
39
+ ### className() {#classname}
40
40
 
41
41
  > **className**(): `string`
42
42
 
@@ -54,7 +54,7 @@ The class name of the component.
54
54
 
55
55
  ***
56
56
 
57
- ### start()
57
+ ### start() {#start}
58
58
 
59
59
  > **start**(`nodeLoggingComponentType?`): `Promise`\<`void`\>
60
60
 
@@ -80,7 +80,7 @@ Nothing.
80
80
 
81
81
  ***
82
82
 
83
- ### pre()
83
+ ### pre() {#pre}
84
84
 
85
85
  > **pre**(`request`, `response`, `route`, `contextIds`, `processorState`): `Promise`\<`void`\>
86
86
 
@@ -102,9 +102,9 @@ The outgoing response.
102
102
 
103
103
  ##### route
104
104
 
105
- The route to process.
105
+ `IBaseRoute` \| `undefined`
106
106
 
107
- `IBaseRoute` | `undefined`
107
+ The route to process.
108
108
 
109
109
  ##### contextIds
110
110
 
@@ -126,7 +126,7 @@ The state handed through the processors.
126
126
 
127
127
  ***
128
128
 
129
- ### post()
129
+ ### post() {#post}
130
130
 
131
131
  > **post**(`request`, `response`, `route`, `contextIds`, `processorState`): `Promise`\<`void`\>
132
132
 
@@ -148,9 +148,9 @@ The outgoing response.
148
148
 
149
149
  ##### route
150
150
 
151
- The route to process.
151
+ `IBaseRoute` \| `undefined`
152
152
 
153
- `IBaseRoute` | `undefined`
153
+ The route to process.
154
154
 
155
155
  ##### contextIds
156
156
 
@@ -14,7 +14,7 @@ Class defining the storage for user login credentials.
14
14
 
15
15
  ## Properties
16
16
 
17
- ### email
17
+ ### email {#email}
18
18
 
19
19
  > **email**: `string`
20
20
 
@@ -22,7 +22,7 @@ The user e-mail address.
22
22
 
23
23
  ***
24
24
 
25
- ### password
25
+ ### password {#password}
26
26
 
27
27
  > **password**: `string`
28
28
 
@@ -30,7 +30,7 @@ The encrypted password for the user.
30
30
 
31
31
  ***
32
32
 
33
- ### salt
33
+ ### salt {#salt}
34
34
 
35
35
  > **salt**: `string`
36
36
 
@@ -38,7 +38,7 @@ The salt for the password.
38
38
 
39
39
  ***
40
40
 
41
- ### identity
41
+ ### identity {#identity}
42
42
 
43
43
  > **identity**: `string`
44
44
 
@@ -46,7 +46,7 @@ The user identity.
46
46
 
47
47
  ***
48
48
 
49
- ### organization
49
+ ### organization {#organization}
50
50
 
51
51
  > **organization**: `string`
52
52
 
@@ -54,7 +54,7 @@ The users organization.
54
54
 
55
55
  ***
56
56
 
57
- ### scope
57
+ ### scope {#scope}
58
58
 
59
59
  > **scope**: `string`
60
60
 
@@ -28,7 +28,7 @@ The dependencies for the identity connector.
28
28
 
29
29
  ## Properties
30
30
 
31
- ### CLASS\_NAME
31
+ ### CLASS\_NAME {#class_name}
32
32
 
33
33
  > `readonly` `static` **CLASS\_NAME**: `string`
34
34
 
@@ -36,7 +36,7 @@ Runtime name for the class.
36
36
 
37
37
  ## Methods
38
38
 
39
- ### className()
39
+ ### className() {#classname}
40
40
 
41
41
  > **className**(): `string`
42
42
 
@@ -54,7 +54,7 @@ The class name of the component.
54
54
 
55
55
  ***
56
56
 
57
- ### create()
57
+ ### create() {#create}
58
58
 
59
59
  > **create**(`user`): `Promise`\<`void`\>
60
60
 
@@ -80,7 +80,7 @@ Nothing.
80
80
 
81
81
  ***
82
82
 
83
- ### update()
83
+ ### update() {#update}
84
84
 
85
85
  > **update**(`user`): `Promise`\<`void`\>
86
86
 
@@ -106,7 +106,7 @@ Nothing.
106
106
 
107
107
  ***
108
108
 
109
- ### get()
109
+ ### get() {#get}
110
110
 
111
111
  > **get**(`email`): `Promise`\<`Omit`\<`IAuthenticationUser`, `"salt"` \| `"password"`\>\>
112
112
 
@@ -132,7 +132,7 @@ The user details.
132
132
 
133
133
  ***
134
134
 
135
- ### getByIdentity()
135
+ ### getByIdentity() {#getbyidentity}
136
136
 
137
137
  > **getByIdentity**(`identity`): `Promise`\<`Omit`\<`IAuthenticationUser`, `"salt"` \| `"password"`\>\>
138
138
 
@@ -158,7 +158,7 @@ The user details.
158
158
 
159
159
  ***
160
160
 
161
- ### remove()
161
+ ### remove() {#remove}
162
162
 
163
163
  > **remove**(`email`): `Promise`\<`void`\>
164
164
 
@@ -184,7 +184,7 @@ Nothing.
184
184
 
185
185
  ***
186
186
 
187
- ### updatePassword()
187
+ ### updatePassword() {#updatepassword}
188
188
 
189
189
  > **updatePassword**(`email`, `newPassword`, `currentPassword?`): `Promise`\<`void`\>
190
190
 
@@ -28,7 +28,7 @@ The dependencies for the identity connector.
28
28
 
29
29
  ## Properties
30
30
 
31
- ### CLASS\_NAME
31
+ ### CLASS\_NAME {#class_name}
32
32
 
33
33
  > `readonly` `static` **CLASS\_NAME**: `string`
34
34
 
@@ -36,7 +36,7 @@ Runtime name for the class.
36
36
 
37
37
  ## Methods
38
38
 
39
- ### className()
39
+ ### className() {#classname}
40
40
 
41
41
  > **className**(): `string`
42
42
 
@@ -54,7 +54,7 @@ The class name of the component.
54
54
 
55
55
  ***
56
56
 
57
- ### start()
57
+ ### start() {#start}
58
58
 
59
59
  > **start**(`nodeLoggingComponentType?`): `Promise`\<`void`\>
60
60
 
@@ -80,7 +80,7 @@ Nothing.
80
80
 
81
81
  ***
82
82
 
83
- ### login()
83
+ ### login() {#login}
84
84
 
85
85
  > **login**(`email`, `password`): `Promise`\<\{ `token?`: `string`; `expiry`: `number`; \}\>
86
86
 
@@ -112,7 +112,7 @@ The authentication token for the user, if it uses a mechanism with public access
112
112
 
113
113
  ***
114
114
 
115
- ### logout()
115
+ ### logout() {#logout}
116
116
 
117
117
  > **logout**(`token?`): `Promise`\<`void`\>
118
118
 
@@ -138,7 +138,7 @@ Nothing.
138
138
 
139
139
  ***
140
140
 
141
- ### refresh()
141
+ ### refresh() {#refresh}
142
142
 
143
143
  > **refresh**(`token?`): `Promise`\<\{ `token?`: `string`; `expiry`: `number`; \}\>
144
144
 
@@ -164,7 +164,7 @@ The refreshed token, if it uses a mechanism with public access.
164
164
 
165
165
  ***
166
166
 
167
- ### updatePassword()
167
+ ### updatePassword() {#updatepassword}
168
168
 
169
169
  > **updatePassword**(`currentPassword`, `newPassword`): `Promise`\<`void`\>
170
170
 
@@ -14,7 +14,7 @@ Helper class for token operations.
14
14
 
15
15
  ## Properties
16
16
 
17
- ### CLASS\_NAME
17
+ ### CLASS\_NAME {#class_name}
18
18
 
19
19
  > `readonly` `static` **CLASS\_NAME**: `string`
20
20
 
@@ -22,7 +22,7 @@ Runtime name for the class.
22
22
 
23
23
  ## Methods
24
24
 
25
- ### createToken()
25
+ ### createToken() {#createtoken}
26
26
 
27
27
  > `static` **createToken**(`vaultConnector`, `signingKeyName`, `userIdentity`, `organizationIdentity`, `tenantId`, `ttlMinutes`, `scope?`): `Promise`\<\{ `token`: `string`; `expiry`: `number`; \}\>
28
28
 
@@ -50,15 +50,15 @@ The subject for the token.
50
50
 
51
51
  ##### organizationIdentity
52
52
 
53
- The organization for the token.
53
+ `string` \| `undefined`
54
54
 
55
- `string` | `undefined`
55
+ The organization for the token.
56
56
 
57
57
  ##### tenantId
58
58
 
59
- The tenant id for the token.
59
+ `string` \| `undefined`
60
60
 
61
- `string` | `undefined`
61
+ The tenant id for the token.
62
62
 
63
63
  ##### ttlMinutes
64
64
 
@@ -80,7 +80,7 @@ The new token and its expiry date.
80
80
 
81
81
  ***
82
82
 
83
- ### verify()
83
+ ### verify() {#verify}
84
84
 
85
85
  > `static` **verify**(`vaultConnector`, `signingKeyName`, `token`, `requiredScopes?`): `Promise`\<\{ `header`: `JWTHeaderParameters`; `payload`: `JWTPayload`; \}\>
86
86
 
@@ -102,9 +102,9 @@ The signing key name.
102
102
 
103
103
  ##### token
104
104
 
105
- The token to verify.
105
+ `string` \| `undefined`
106
106
 
107
- `string` | `undefined`
107
+ The token to verify.
108
108
 
109
109
  ##### requiredScopes?
110
110
 
@@ -124,7 +124,7 @@ UnauthorizedError if the token is missing, invalid or expired.
124
124
 
125
125
  ***
126
126
 
127
- ### extractTokenFromHeaders()
127
+ ### extractTokenFromHeaders() {#extracttokenfromheaders}
128
128
 
129
129
  > `static` **extractTokenFromHeaders**(`headers?`, `cookieName?`): \{ `token`: `string`; `location`: `"authorization"` \| `"cookie"`; \} \| `undefined`
130
130
 
@@ -4,9 +4,9 @@ Configuration for the authentication header processor
4
4
 
5
5
  ## Properties
6
6
 
7
- ### signingKeyName?
7
+ ### signingKeyName? {#signingkeyname}
8
8
 
9
- > `optional` **signingKeyName**: `string`
9
+ > `optional` **signingKeyName?**: `string`
10
10
 
11
11
  The name of the key to retrieve from the vault for signing JWT.
12
12
 
@@ -18,9 +18,9 @@ auth-signing
18
18
 
19
19
  ***
20
20
 
21
- ### cookieName?
21
+ ### cookieName? {#cookiename}
22
22
 
23
- > `optional` **cookieName**: `string`
23
+ > `optional` **cookieName?**: `string`
24
24
 
25
25
  The name of the cookie to use for the token.
26
26
 
@@ -4,9 +4,9 @@ Options for the AuthHeaderProcessor constructor.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### vaultConnectorType?
7
+ ### vaultConnectorType? {#vaultconnectortype}
8
8
 
9
- > `optional` **vaultConnectorType**: `string`
9
+ > `optional` **vaultConnectorType?**: `string`
10
10
 
11
11
  The vault for the private keys.
12
12
 
@@ -18,8 +18,8 @@ vault
18
18
 
19
19
  ***
20
20
 
21
- ### config?
21
+ ### config? {#config}
22
22
 
23
- > `optional` **config**: [`IAuthHeaderProcessorConfig`](IAuthHeaderProcessorConfig.md)
23
+ > `optional` **config?**: [`IAuthHeaderProcessorConfig`](IAuthHeaderProcessorConfig.md)
24
24
 
25
25
  The configuration for the processor.
@@ -4,9 +4,9 @@ Configuration for the entity storage authentication admin service.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### minPasswordLength?
7
+ ### minPasswordLength? {#minpasswordlength}
8
8
 
9
- > `optional` **minPasswordLength**: `number`
9
+ > `optional` **minPasswordLength?**: `number`
10
10
 
11
11
  The minimum password length.
12
12
 
@@ -4,9 +4,9 @@ Options for the EntityStorageAuthenticationAdminService constructor.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### userEntityStorageType?
7
+ ### userEntityStorageType? {#userentitystoragetype}
8
8
 
9
- > `optional` **userEntityStorageType**: `string`
9
+ > `optional` **userEntityStorageType?**: `string`
10
10
 
11
11
  The entity storage for the users.
12
12
 
@@ -18,8 +18,8 @@ authentication-user
18
18
 
19
19
  ***
20
20
 
21
- ### config?
21
+ ### config? {#config}
22
22
 
23
- > `optional` **config**: [`IEntityStorageAuthenticationAdminServiceConfig`](IEntityStorageAuthenticationAdminServiceConfig.md)
23
+ > `optional` **config?**: [`IEntityStorageAuthenticationAdminServiceConfig`](IEntityStorageAuthenticationAdminServiceConfig.md)
24
24
 
25
25
  The configuration for the authentication.
@@ -4,9 +4,9 @@ Configuration for the entity storage authentication service.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### signingKeyName?
7
+ ### signingKeyName? {#signingkeyname}
8
8
 
9
- > `optional` **signingKeyName**: `string`
9
+ > `optional` **signingKeyName?**: `string`
10
10
 
11
11
  The name of the key to retrieve from the vault for signing JWT.
12
12
 
@@ -18,9 +18,9 @@ auth-signing
18
18
 
19
19
  ***
20
20
 
21
- ### defaultTtlMinutes?
21
+ ### defaultTtlMinutes? {#defaultttlminutes}
22
22
 
23
- > `optional` **defaultTtlMinutes**: `number`
23
+ > `optional` **defaultTtlMinutes?**: `number`
24
24
 
25
25
  The default time to live for the JWT.
26
26
 
@@ -4,9 +4,9 @@ Options for the EntityStorageAuthenticationService constructor.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### userEntityStorageType?
7
+ ### userEntityStorageType? {#userentitystoragetype}
8
8
 
9
- > `optional` **userEntityStorageType**: `string`
9
+ > `optional` **userEntityStorageType?**: `string`
10
10
 
11
11
  The entity storage for the users.
12
12
 
@@ -18,9 +18,9 @@ authentication-user
18
18
 
19
19
  ***
20
20
 
21
- ### vaultConnectorType?
21
+ ### vaultConnectorType? {#vaultconnectortype}
22
22
 
23
- > `optional` **vaultConnectorType**: `string`
23
+ > `optional` **vaultConnectorType?**: `string`
24
24
 
25
25
  The vault for the private keys.
26
26
 
@@ -32,9 +32,9 @@ vault
32
32
 
33
33
  ***
34
34
 
35
- ### authenticationAdminServiceType?
35
+ ### authenticationAdminServiceType? {#authenticationadminservicetype}
36
36
 
37
- > `optional` **authenticationAdminServiceType**: `string`
37
+ > `optional` **authenticationAdminServiceType?**: `string`
38
38
 
39
39
  The admin service.
40
40
 
@@ -46,8 +46,8 @@ authentication-admin
46
46
 
47
47
  ***
48
48
 
49
- ### config?
49
+ ### config? {#config}
50
50
 
51
- > `optional` **config**: [`IEntityStorageAuthenticationServiceConfig`](IEntityStorageAuthenticationServiceConfig.md)
51
+ > `optional` **config?**: [`IEntityStorageAuthenticationServiceConfig`](IEntityStorageAuthenticationServiceConfig.md)
52
52
 
53
53
  The configuration for the authentication.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@twin.org/api-auth-entity-storage-service",
3
- "version": "0.0.3-next.20",
4
- "description": "Auth Entity Storage contract implementation and REST endpoint definitions",
3
+ "version": "0.0.3-next.22",
4
+ "description": "Authentication service implementation and REST routes backed by entity storage.",
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/context": "next",
21
21
  "@twin.org/core": "next",
22
22
  "@twin.org/crypto": "next",