@twin.org/api-auth-entity-storage-service 0.0.1-next.25 → 0.0.1-next.26
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/dist/cjs/index.cjs +4 -9
- package/dist/esm/index.mjs +4 -9
- package/dist/types/index.d.ts +2 -0
- package/dist/types/models/IAuthHeaderProcessorConstructorOptions.d.ts +15 -0
- package/dist/types/models/IEntityStorageAuthenticationServiceConstructorOptions.d.ts +20 -0
- package/dist/types/processors/authHeaderProcessor.d.ts +2 -7
- package/dist/types/services/entityStorageAuthenticationService.d.ts +2 -9
- package/docs/changelog.md +1 -1
- package/docs/reference/classes/AuthHeaderProcessor.md +35 -21
- package/docs/reference/classes/EntityStorageAuthenticationService.md +25 -39
- package/docs/reference/classes/PasswordHelper.md +6 -2
- package/docs/reference/classes/TokenHelper.md +33 -31
- package/docs/reference/functions/authenticationLogin.md +9 -3
- package/docs/reference/functions/authenticationLogout.md +9 -3
- package/docs/reference/functions/authenticationRefreshToken.md +9 -3
- package/docs/reference/functions/generateRestRoutesAuthentication.md +6 -2
- package/docs/reference/index.md +2 -0
- package/docs/reference/interfaces/IAuthHeaderProcessorConstructorOptions.md +25 -0
- package/docs/reference/interfaces/IEntityStorageAuthenticationServiceConstructorOptions.md +39 -0
- package/package.json +4 -4
package/dist/cjs/index.cjs
CHANGED
@@ -34,19 +34,19 @@ exports.AuthenticationUser = class AuthenticationUser {
|
|
34
34
|
__decorate([
|
35
35
|
entity.property({ type: "string", isPrimary: true }),
|
36
36
|
__metadata("design:type", String)
|
37
|
-
], exports.AuthenticationUser.prototype, "email",
|
37
|
+
], exports.AuthenticationUser.prototype, "email", undefined);
|
38
38
|
__decorate([
|
39
39
|
entity.property({ type: "string" }),
|
40
40
|
__metadata("design:type", String)
|
41
|
-
], exports.AuthenticationUser.prototype, "password",
|
41
|
+
], exports.AuthenticationUser.prototype, "password", undefined);
|
42
42
|
__decorate([
|
43
43
|
entity.property({ type: "string" }),
|
44
44
|
__metadata("design:type", String)
|
45
|
-
], exports.AuthenticationUser.prototype, "salt",
|
45
|
+
], exports.AuthenticationUser.prototype, "salt", undefined);
|
46
46
|
__decorate([
|
47
47
|
entity.property({ type: "string" }),
|
48
48
|
__metadata("design:type", String)
|
49
|
-
], exports.AuthenticationUser.prototype, "identity",
|
49
|
+
], exports.AuthenticationUser.prototype, "identity", undefined);
|
50
50
|
exports.AuthenticationUser = __decorate([
|
51
51
|
entity.entity()
|
52
52
|
], exports.AuthenticationUser);
|
@@ -190,8 +190,6 @@ class AuthHeaderProcessor {
|
|
190
190
|
/**
|
191
191
|
* Create a new instance of AuthCookiePreProcessor.
|
192
192
|
* @param options Options for the processor.
|
193
|
-
* @param options.vaultConnectorType The vault for the private keys, defaults to "vault".
|
194
|
-
* @param options.config The configuration for the processor.
|
195
193
|
*/
|
196
194
|
constructor(options) {
|
197
195
|
this._vaultConnector = vaultModels.VaultConnectorFactory.get(options?.vaultConnectorType ?? "vault");
|
@@ -547,9 +545,6 @@ class EntityStorageAuthenticationService {
|
|
547
545
|
/**
|
548
546
|
* Create a new instance of EntityStorageAuthentication.
|
549
547
|
* @param options The dependencies for the identity connector.
|
550
|
-
* @param options.userEntityStorageType The entity storage for the users, defaults to "authentication-user".
|
551
|
-
* @param options.vaultConnectorType The vault for the private keys, defaults to "vault".
|
552
|
-
* @param options.config The configuration for the authentication.
|
553
548
|
*/
|
554
549
|
constructor(options) {
|
555
550
|
this._userEntityStorage = entityStorageModels.EntityStorageConnectorFactory.get(options?.userEntityStorageType ?? "authentication-user");
|
package/dist/esm/index.mjs
CHANGED
@@ -32,19 +32,19 @@ let AuthenticationUser = class AuthenticationUser {
|
|
32
32
|
__decorate([
|
33
33
|
property({ type: "string", isPrimary: true }),
|
34
34
|
__metadata("design:type", String)
|
35
|
-
], AuthenticationUser.prototype, "email",
|
35
|
+
], AuthenticationUser.prototype, "email", undefined);
|
36
36
|
__decorate([
|
37
37
|
property({ type: "string" }),
|
38
38
|
__metadata("design:type", String)
|
39
|
-
], AuthenticationUser.prototype, "password",
|
39
|
+
], AuthenticationUser.prototype, "password", undefined);
|
40
40
|
__decorate([
|
41
41
|
property({ type: "string" }),
|
42
42
|
__metadata("design:type", String)
|
43
|
-
], AuthenticationUser.prototype, "salt",
|
43
|
+
], AuthenticationUser.prototype, "salt", undefined);
|
44
44
|
__decorate([
|
45
45
|
property({ type: "string" }),
|
46
46
|
__metadata("design:type", String)
|
47
|
-
], AuthenticationUser.prototype, "identity",
|
47
|
+
], AuthenticationUser.prototype, "identity", undefined);
|
48
48
|
AuthenticationUser = __decorate([
|
49
49
|
entity()
|
50
50
|
], AuthenticationUser);
|
@@ -188,8 +188,6 @@ class AuthHeaderProcessor {
|
|
188
188
|
/**
|
189
189
|
* Create a new instance of AuthCookiePreProcessor.
|
190
190
|
* @param options Options for the processor.
|
191
|
-
* @param options.vaultConnectorType The vault for the private keys, defaults to "vault".
|
192
|
-
* @param options.config The configuration for the processor.
|
193
191
|
*/
|
194
192
|
constructor(options) {
|
195
193
|
this._vaultConnector = VaultConnectorFactory.get(options?.vaultConnectorType ?? "vault");
|
@@ -545,9 +543,6 @@ class EntityStorageAuthenticationService {
|
|
545
543
|
/**
|
546
544
|
* Create a new instance of EntityStorageAuthentication.
|
547
545
|
* @param options The dependencies for the identity connector.
|
548
|
-
* @param options.userEntityStorageType The entity storage for the users, defaults to "authentication-user".
|
549
|
-
* @param options.vaultConnectorType The vault for the private keys, defaults to "vault".
|
550
|
-
* @param options.config The configuration for the authentication.
|
551
546
|
*/
|
552
547
|
constructor(options) {
|
553
548
|
this._userEntityStorage = EntityStorageConnectorFactory.get(options?.userEntityStorageType ?? "authentication-user");
|
package/dist/types/index.d.ts
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
export * from "./entities/authenticationUser";
|
2
2
|
export * from "./models/IAuthHeaderProcessorConfig";
|
3
|
+
export * from "./models/IAuthHeaderProcessorConstructorOptions";
|
3
4
|
export * from "./models/IEntityStorageAuthenticationServiceConfig";
|
5
|
+
export * from "./models/IEntityStorageAuthenticationServiceConstructorOptions";
|
4
6
|
export * from "./processors/authHeaderProcessor";
|
5
7
|
export * from "./restEntryPoints";
|
6
8
|
export * from "./routes/entityStorageAuthenticationRoutes";
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import type { IAuthHeaderProcessorConfig } from "./IAuthHeaderProcessorConfig";
|
2
|
+
/**
|
3
|
+
* Options for the AuthHeaderProcessor constructor.
|
4
|
+
*/
|
5
|
+
export interface IAuthHeaderProcessorConstructorOptions {
|
6
|
+
/**
|
7
|
+
* The vault for the private keys.
|
8
|
+
* @default vault
|
9
|
+
*/
|
10
|
+
vaultConnectorType?: string;
|
11
|
+
/**
|
12
|
+
* The configuration for the processor.
|
13
|
+
*/
|
14
|
+
config?: IAuthHeaderProcessorConfig;
|
15
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import type { IEntityStorageAuthenticationServiceConfig } from "./IEntityStorageAuthenticationServiceConfig";
|
2
|
+
/**
|
3
|
+
* Options for the EntityStorageAuthenticationService constructor.
|
4
|
+
*/
|
5
|
+
export interface IEntityStorageAuthenticationServiceConstructorOptions {
|
6
|
+
/**
|
7
|
+
* The entity storage for the users.
|
8
|
+
* @default authentication-user
|
9
|
+
*/
|
10
|
+
userEntityStorageType?: string;
|
11
|
+
/**
|
12
|
+
* The vault for the private keys.
|
13
|
+
* @default vault
|
14
|
+
*/
|
15
|
+
vaultConnectorType?: string;
|
16
|
+
/**
|
17
|
+
* The configuration for the authentication.
|
18
|
+
*/
|
19
|
+
config?: IEntityStorageAuthenticationServiceConfig;
|
20
|
+
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { type IBaseRoute, type IBaseRouteProcessor, type IHttpRequestIdentity, type IHttpResponse, type IHttpServerRequest } from "@twin.org/api-models";
|
2
|
-
import type {
|
2
|
+
import type { IAuthHeaderProcessorConstructorOptions } from "../models/IAuthHeaderProcessorConstructorOptions";
|
3
3
|
/**
|
4
4
|
* Handle a JWT token in the authorization header or cookies and validate it to populate request context identity.
|
5
5
|
*/
|
@@ -15,13 +15,8 @@ export declare class AuthHeaderProcessor implements IBaseRouteProcessor {
|
|
15
15
|
/**
|
16
16
|
* Create a new instance of AuthCookiePreProcessor.
|
17
17
|
* @param options Options for the processor.
|
18
|
-
* @param options.vaultConnectorType The vault for the private keys, defaults to "vault".
|
19
|
-
* @param options.config The configuration for the processor.
|
20
18
|
*/
|
21
|
-
constructor(options?:
|
22
|
-
vaultConnectorType?: string;
|
23
|
-
config?: IAuthHeaderProcessorConfig;
|
24
|
-
});
|
19
|
+
constructor(options?: IAuthHeaderProcessorConstructorOptions);
|
25
20
|
/**
|
26
21
|
* The service needs to be started when the application is initialized.
|
27
22
|
* @param nodeIdentity The identity of the node.
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { IAuthenticationComponent } from "@twin.org/api-auth-entity-storage-models";
|
2
|
-
import type {
|
2
|
+
import type { IEntityStorageAuthenticationServiceConstructorOptions } from "../models/IEntityStorageAuthenticationServiceConstructorOptions";
|
3
3
|
/**
|
4
4
|
* Implementation of the authentication component using entity storage.
|
5
5
|
*/
|
@@ -15,15 +15,8 @@ export declare class EntityStorageAuthenticationService implements IAuthenticati
|
|
15
15
|
/**
|
16
16
|
* Create a new instance of EntityStorageAuthentication.
|
17
17
|
* @param options The dependencies for the identity connector.
|
18
|
-
* @param options.userEntityStorageType The entity storage for the users, defaults to "authentication-user".
|
19
|
-
* @param options.vaultConnectorType The vault for the private keys, defaults to "vault".
|
20
|
-
* @param options.config The configuration for the authentication.
|
21
18
|
*/
|
22
|
-
constructor(options?:
|
23
|
-
userEntityStorageType?: string;
|
24
|
-
vaultConnectorType?: string;
|
25
|
-
config?: IEntityStorageAuthenticationServiceConfig;
|
26
|
-
});
|
19
|
+
constructor(options?: IEntityStorageAuthenticationServiceConstructorOptions);
|
27
20
|
/**
|
28
21
|
* The service needs to be started when the application is initialized.
|
29
22
|
* @param nodeIdentity The identity of the node.
|
package/docs/changelog.md
CHANGED
@@ -16,17 +16,11 @@ Create a new instance of AuthCookiePreProcessor.
|
|
16
16
|
|
17
17
|
#### Parameters
|
18
18
|
|
19
|
-
|
19
|
+
##### options?
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
• **options.vaultConnectorType?**: `string`
|
24
|
-
|
25
|
-
The vault for the private keys, defaults to "vault".
|
26
|
-
|
27
|
-
• **options.config?**: [`IAuthHeaderProcessorConfig`](../interfaces/IAuthHeaderProcessorConfig.md)
|
21
|
+
[`IAuthHeaderProcessorConstructorOptions`](../interfaces/IAuthHeaderProcessorConstructorOptions.md)
|
28
22
|
|
29
|
-
|
23
|
+
Options for the processor.
|
30
24
|
|
31
25
|
#### Returns
|
32
26
|
|
@@ -62,11 +56,15 @@ The service needs to be started when the application is initialized.
|
|
62
56
|
|
63
57
|
#### Parameters
|
64
58
|
|
65
|
-
|
59
|
+
##### nodeIdentity
|
60
|
+
|
61
|
+
`string`
|
66
62
|
|
67
63
|
The identity of the node.
|
68
64
|
|
69
|
-
|
65
|
+
##### nodeLoggingConnectorType?
|
66
|
+
|
67
|
+
`string`
|
70
68
|
|
71
69
|
The node logging connector type, defaults to "node-logging".
|
72
70
|
|
@@ -90,23 +88,31 @@ Pre process the REST request for the specified route.
|
|
90
88
|
|
91
89
|
#### Parameters
|
92
90
|
|
93
|
-
|
91
|
+
##### request
|
92
|
+
|
93
|
+
`IHttpServerRequest`
|
94
94
|
|
95
95
|
The incoming request.
|
96
96
|
|
97
|
-
|
97
|
+
##### response
|
98
|
+
|
99
|
+
`IHttpResponse`
|
98
100
|
|
99
101
|
The outgoing response.
|
100
102
|
|
101
|
-
|
103
|
+
##### route
|
102
104
|
|
103
105
|
The route to process.
|
104
106
|
|
105
|
-
|
107
|
+
`undefined` | `IBaseRoute`
|
108
|
+
|
109
|
+
##### requestIdentity
|
110
|
+
|
111
|
+
`IHttpRequestIdentity`
|
106
112
|
|
107
113
|
The identity context for the request.
|
108
114
|
|
109
|
-
|
115
|
+
##### processorState
|
110
116
|
|
111
117
|
The state handed through the processors.
|
112
118
|
|
@@ -128,23 +134,31 @@ Post process the REST request for the specified route.
|
|
128
134
|
|
129
135
|
#### Parameters
|
130
136
|
|
131
|
-
|
137
|
+
##### request
|
138
|
+
|
139
|
+
`IHttpServerRequest`
|
132
140
|
|
133
141
|
The incoming request.
|
134
142
|
|
135
|
-
|
143
|
+
##### response
|
144
|
+
|
145
|
+
`IHttpResponse`
|
136
146
|
|
137
147
|
The outgoing response.
|
138
148
|
|
139
|
-
|
149
|
+
##### route
|
140
150
|
|
141
151
|
The route to process.
|
142
152
|
|
143
|
-
|
153
|
+
`undefined` | `IBaseRoute`
|
154
|
+
|
155
|
+
##### requestIdentity
|
156
|
+
|
157
|
+
`IHttpRequestIdentity`
|
144
158
|
|
145
159
|
The identity context for the request.
|
146
160
|
|
147
|
-
|
161
|
+
##### processorState
|
148
162
|
|
149
163
|
The state handed through the processors.
|
150
164
|
|
@@ -16,21 +16,11 @@ Create a new instance of EntityStorageAuthentication.
|
|
16
16
|
|
17
17
|
#### Parameters
|
18
18
|
|
19
|
-
|
19
|
+
##### options?
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
• **options.userEntityStorageType?**: `string`
|
24
|
-
|
25
|
-
The entity storage for the users, defaults to "authentication-user".
|
26
|
-
|
27
|
-
• **options.vaultConnectorType?**: `string`
|
28
|
-
|
29
|
-
The vault for the private keys, defaults to "vault".
|
30
|
-
|
31
|
-
• **options.config?**: [`IEntityStorageAuthenticationServiceConfig`](../interfaces/IEntityStorageAuthenticationServiceConfig.md)
|
21
|
+
[`IEntityStorageAuthenticationServiceConstructorOptions`](../interfaces/IEntityStorageAuthenticationServiceConstructorOptions.md)
|
32
22
|
|
33
|
-
The
|
23
|
+
The dependencies for the identity connector.
|
34
24
|
|
35
25
|
#### Returns
|
36
26
|
|
@@ -66,11 +56,15 @@ The service needs to be started when the application is initialized.
|
|
66
56
|
|
67
57
|
#### Parameters
|
68
58
|
|
69
|
-
|
59
|
+
##### nodeIdentity
|
60
|
+
|
61
|
+
`string`
|
70
62
|
|
71
63
|
The identity of the node.
|
72
64
|
|
73
|
-
|
65
|
+
##### nodeLoggingConnectorType?
|
66
|
+
|
67
|
+
`string`
|
74
68
|
|
75
69
|
The node logging connector type, defaults to "node-logging".
|
76
70
|
|
@@ -88,34 +82,30 @@ Nothing.
|
|
88
82
|
|
89
83
|
### login()
|
90
84
|
|
91
|
-
> **login**(`email`, `password`): `Promise
|
85
|
+
> **login**(`email`, `password`): `Promise`\<\{ `token`: `string`; `expiry`: `number`; \}\>
|
92
86
|
|
93
87
|
Perform a login for the user.
|
94
88
|
|
95
89
|
#### Parameters
|
96
90
|
|
97
|
-
|
91
|
+
##### email
|
92
|
+
|
93
|
+
`string`
|
98
94
|
|
99
95
|
The email address for the user.
|
100
96
|
|
101
|
-
|
97
|
+
##### password
|
98
|
+
|
99
|
+
`string`
|
102
100
|
|
103
101
|
The password for the user.
|
104
102
|
|
105
103
|
#### Returns
|
106
104
|
|
107
|
-
`Promise
|
105
|
+
`Promise`\<\{ `token`: `string`; `expiry`: `number`; \}\>
|
108
106
|
|
109
107
|
The authentication token for the user, if it uses a mechanism with public access.
|
110
108
|
|
111
|
-
##### token?
|
112
|
-
|
113
|
-
> `optional` **token**: `string`
|
114
|
-
|
115
|
-
##### expiry
|
116
|
-
|
117
|
-
> **expiry**: `number`
|
118
|
-
|
119
109
|
#### Implementation of
|
120
110
|
|
121
111
|
`IAuthenticationComponent.login`
|
@@ -130,7 +120,9 @@ Logout the current user.
|
|
130
120
|
|
131
121
|
#### Parameters
|
132
122
|
|
133
|
-
|
123
|
+
##### token?
|
124
|
+
|
125
|
+
`string`
|
134
126
|
|
135
127
|
The token to logout, if it uses a mechanism with public access.
|
136
128
|
|
@@ -148,30 +140,24 @@ Nothing.
|
|
148
140
|
|
149
141
|
### refresh()
|
150
142
|
|
151
|
-
> **refresh**(`token`?): `Promise
|
143
|
+
> **refresh**(`token`?): `Promise`\<\{ `token`: `string`; `expiry`: `number`; \}\>
|
152
144
|
|
153
145
|
Refresh the token.
|
154
146
|
|
155
147
|
#### Parameters
|
156
148
|
|
157
|
-
|
149
|
+
##### token?
|
150
|
+
|
151
|
+
`string`
|
158
152
|
|
159
153
|
The token to refresh, if it uses a mechanism with public access.
|
160
154
|
|
161
155
|
#### Returns
|
162
156
|
|
163
|
-
`Promise
|
157
|
+
`Promise`\<\{ `token`: `string`; `expiry`: `number`; \}\>
|
164
158
|
|
165
159
|
The refreshed token, if it uses a mechanism with public access.
|
166
160
|
|
167
|
-
##### token
|
168
|
-
|
169
|
-
> **token**: `string`
|
170
|
-
|
171
|
-
##### expiry
|
172
|
-
|
173
|
-
> **expiry**: `number`
|
174
|
-
|
175
161
|
#### Implementation of
|
176
162
|
|
177
163
|
`IAuthenticationComponent.refresh`
|
@@ -22,11 +22,15 @@ Hash the password for the user.
|
|
22
22
|
|
23
23
|
#### Parameters
|
24
24
|
|
25
|
-
|
25
|
+
##### passwordBytes
|
26
|
+
|
27
|
+
`Uint8Array`
|
26
28
|
|
27
29
|
The password bytes.
|
28
30
|
|
29
|
-
|
31
|
+
##### saltBytes
|
32
|
+
|
33
|
+
`Uint8Array`
|
30
34
|
|
31
35
|
The salt bytes.
|
32
36
|
|
@@ -16,78 +16,76 @@ Helper class for token operations.
|
|
16
16
|
|
17
17
|
### createToken()
|
18
18
|
|
19
|
-
> `static` **createToken**(`vaultConnector`, `signingKeyName`, `subject`, `ttlMinutes`): `Promise
|
19
|
+
> `static` **createToken**(`vaultConnector`, `signingKeyName`, `subject`, `ttlMinutes`): `Promise`\<\{ `token`: `string`; `expiry`: `number`; \}\>
|
20
20
|
|
21
21
|
Create a new token.
|
22
22
|
|
23
23
|
#### Parameters
|
24
24
|
|
25
|
-
|
25
|
+
##### vaultConnector
|
26
|
+
|
27
|
+
`IVaultConnector`
|
26
28
|
|
27
29
|
The vault connector.
|
28
30
|
|
29
|
-
|
31
|
+
##### signingKeyName
|
32
|
+
|
33
|
+
`string`
|
30
34
|
|
31
35
|
The signing key name.
|
32
36
|
|
33
|
-
|
37
|
+
##### subject
|
38
|
+
|
39
|
+
`string`
|
34
40
|
|
35
41
|
The subject for the token.
|
36
42
|
|
37
|
-
|
43
|
+
##### ttlMinutes
|
44
|
+
|
45
|
+
`number`
|
38
46
|
|
39
47
|
The time to live for the token in minutes.
|
40
48
|
|
41
49
|
#### Returns
|
42
50
|
|
43
|
-
`Promise
|
51
|
+
`Promise`\<\{ `token`: `string`; `expiry`: `number`; \}\>
|
44
52
|
|
45
53
|
The new token and its expiry date.
|
46
54
|
|
47
|
-
##### token
|
48
|
-
|
49
|
-
> **token**: `string`
|
50
|
-
|
51
|
-
##### expiry
|
52
|
-
|
53
|
-
> **expiry**: `number`
|
54
|
-
|
55
55
|
***
|
56
56
|
|
57
57
|
### verify()
|
58
58
|
|
59
|
-
> `static` **verify**(`vaultConnector`, `signingKeyName`, `token`): `Promise
|
59
|
+
> `static` **verify**(`vaultConnector`, `signingKeyName`, `token`): `Promise`\<\{ `header`: `IJwtHeader`; `payload`: `IJwtPayload`; \}\>
|
60
60
|
|
61
61
|
Verify the token.
|
62
62
|
|
63
63
|
#### Parameters
|
64
64
|
|
65
|
-
|
65
|
+
##### vaultConnector
|
66
|
+
|
67
|
+
`IVaultConnector`
|
66
68
|
|
67
69
|
The vault connector.
|
68
70
|
|
69
|
-
|
71
|
+
##### signingKeyName
|
72
|
+
|
73
|
+
`string`
|
70
74
|
|
71
75
|
The signing key name.
|
72
76
|
|
73
|
-
|
77
|
+
##### token
|
74
78
|
|
75
79
|
The token to verify.
|
76
80
|
|
81
|
+
`undefined` | `string`
|
82
|
+
|
77
83
|
#### Returns
|
78
84
|
|
79
|
-
`Promise
|
85
|
+
`Promise`\<\{ `header`: `IJwtHeader`; `payload`: `IJwtPayload`; \}\>
|
80
86
|
|
81
87
|
The verified details.
|
82
88
|
|
83
|
-
##### header
|
84
|
-
|
85
|
-
> **header**: `IJwtHeader`
|
86
|
-
|
87
|
-
##### payload
|
88
|
-
|
89
|
-
> **payload**: `IJwtPayload`
|
90
|
-
|
91
89
|
#### Throws
|
92
90
|
|
93
91
|
UnauthorizedError if the token is missing, invalid or expired.
|
@@ -96,22 +94,26 @@ UnauthorizedError if the token is missing, invalid or expired.
|
|
96
94
|
|
97
95
|
### extractTokenFromHeaders()
|
98
96
|
|
99
|
-
> `static` **extractTokenFromHeaders**(`headers`?, `cookieName`?): `undefined` \| `
|
97
|
+
> `static` **extractTokenFromHeaders**(`headers`?, `cookieName`?): `undefined` \| \{ `token`: `string`; `location`: `"authorization"` \| `"cookie"`; \}
|
100
98
|
|
101
99
|
Extract the auth token from the headers, either from the authorization header or the cookie header.
|
102
100
|
|
103
101
|
#### Parameters
|
104
102
|
|
105
|
-
|
103
|
+
##### headers?
|
104
|
+
|
105
|
+
`IHttpHeaders`
|
106
106
|
|
107
107
|
The headers to extract the token from.
|
108
108
|
|
109
|
-
|
109
|
+
##### cookieName?
|
110
|
+
|
111
|
+
`string`
|
110
112
|
|
111
113
|
The name of the cookie to extract the token from.
|
112
114
|
|
113
115
|
#### Returns
|
114
116
|
|
115
|
-
`undefined` \| `
|
117
|
+
`undefined` \| \{ `token`: `string`; `location`: `"authorization"` \| `"cookie"`; \}
|
116
118
|
|
117
119
|
The token if found.
|
@@ -6,15 +6,21 @@ Login to the server.
|
|
6
6
|
|
7
7
|
## Parameters
|
8
8
|
|
9
|
-
|
9
|
+
### httpRequestContext
|
10
|
+
|
11
|
+
`IHttpRequestContext`
|
10
12
|
|
11
13
|
The request context for the API.
|
12
14
|
|
13
|
-
|
15
|
+
### componentName
|
16
|
+
|
17
|
+
`string`
|
14
18
|
|
15
19
|
The name of the component to use in the routes.
|
16
20
|
|
17
|
-
|
21
|
+
### request
|
22
|
+
|
23
|
+
`ILoginRequest`
|
18
24
|
|
19
25
|
The request.
|
20
26
|
|
@@ -6,15 +6,21 @@ Logout from the server.
|
|
6
6
|
|
7
7
|
## Parameters
|
8
8
|
|
9
|
-
|
9
|
+
### httpRequestContext
|
10
|
+
|
11
|
+
`IHttpRequestContext`
|
10
12
|
|
11
13
|
The request context for the API.
|
12
14
|
|
13
|
-
|
15
|
+
### componentName
|
16
|
+
|
17
|
+
`string`
|
14
18
|
|
15
19
|
The name of the component to use in the routes.
|
16
20
|
|
17
|
-
|
21
|
+
### request
|
22
|
+
|
23
|
+
`ILogoutRequest`
|
18
24
|
|
19
25
|
The request.
|
20
26
|
|
@@ -6,15 +6,21 @@ Refresh the login token.
|
|
6
6
|
|
7
7
|
## Parameters
|
8
8
|
|
9
|
-
|
9
|
+
### httpRequestContext
|
10
|
+
|
11
|
+
`IHttpRequestContext`
|
10
12
|
|
11
13
|
The request context for the API.
|
12
14
|
|
13
|
-
|
15
|
+
### componentName
|
16
|
+
|
17
|
+
`string`
|
14
18
|
|
15
19
|
The name of the component to use in the routes.
|
16
20
|
|
17
|
-
|
21
|
+
### request
|
22
|
+
|
23
|
+
`IRefreshTokenRequest`
|
18
24
|
|
19
25
|
The request.
|
20
26
|
|
@@ -6,11 +6,15 @@ The REST routes for authentication.
|
|
6
6
|
|
7
7
|
## Parameters
|
8
8
|
|
9
|
-
|
9
|
+
### baseRouteName
|
10
|
+
|
11
|
+
`string`
|
10
12
|
|
11
13
|
Prefix to prepend to the paths.
|
12
14
|
|
13
|
-
|
15
|
+
### componentName
|
16
|
+
|
17
|
+
`string`
|
14
18
|
|
15
19
|
The name of the component to use in the routes stored in the ComponentFactory.
|
16
20
|
|
package/docs/reference/index.md
CHANGED
@@ -11,7 +11,9 @@
|
|
11
11
|
## Interfaces
|
12
12
|
|
13
13
|
- [IAuthHeaderProcessorConfig](interfaces/IAuthHeaderProcessorConfig.md)
|
14
|
+
- [IAuthHeaderProcessorConstructorOptions](interfaces/IAuthHeaderProcessorConstructorOptions.md)
|
14
15
|
- [IEntityStorageAuthenticationServiceConfig](interfaces/IEntityStorageAuthenticationServiceConfig.md)
|
16
|
+
- [IEntityStorageAuthenticationServiceConstructorOptions](interfaces/IEntityStorageAuthenticationServiceConstructorOptions.md)
|
15
17
|
|
16
18
|
## Variables
|
17
19
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Interface: IAuthHeaderProcessorConstructorOptions
|
2
|
+
|
3
|
+
Options for the AuthHeaderProcessor constructor.
|
4
|
+
|
5
|
+
## Properties
|
6
|
+
|
7
|
+
### vaultConnectorType?
|
8
|
+
|
9
|
+
> `optional` **vaultConnectorType**: `string`
|
10
|
+
|
11
|
+
The vault for the private keys.
|
12
|
+
|
13
|
+
#### Default
|
14
|
+
|
15
|
+
```ts
|
16
|
+
vault
|
17
|
+
```
|
18
|
+
|
19
|
+
***
|
20
|
+
|
21
|
+
### config?
|
22
|
+
|
23
|
+
> `optional` **config**: [`IAuthHeaderProcessorConfig`](IAuthHeaderProcessorConfig.md)
|
24
|
+
|
25
|
+
The configuration for the processor.
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Interface: IEntityStorageAuthenticationServiceConstructorOptions
|
2
|
+
|
3
|
+
Options for the EntityStorageAuthenticationService constructor.
|
4
|
+
|
5
|
+
## Properties
|
6
|
+
|
7
|
+
### userEntityStorageType?
|
8
|
+
|
9
|
+
> `optional` **userEntityStorageType**: `string`
|
10
|
+
|
11
|
+
The entity storage for the users.
|
12
|
+
|
13
|
+
#### Default
|
14
|
+
|
15
|
+
```ts
|
16
|
+
authentication-user
|
17
|
+
```
|
18
|
+
|
19
|
+
***
|
20
|
+
|
21
|
+
### vaultConnectorType?
|
22
|
+
|
23
|
+
> `optional` **vaultConnectorType**: `string`
|
24
|
+
|
25
|
+
The vault for the private keys.
|
26
|
+
|
27
|
+
#### Default
|
28
|
+
|
29
|
+
```ts
|
30
|
+
vault
|
31
|
+
```
|
32
|
+
|
33
|
+
***
|
34
|
+
|
35
|
+
### config?
|
36
|
+
|
37
|
+
> `optional` **config**: [`IEntityStorageAuthenticationServiceConfig`](IEntityStorageAuthenticationServiceConfig.md)
|
38
|
+
|
39
|
+
The configuration for the authentication.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@twin.org/api-auth-entity-storage-service",
|
3
|
-
"version": "0.0.1-next.
|
3
|
+
"version": "0.0.1-next.26",
|
4
4
|
"description": "Auth Entity Storage contract implementation and REST endpoint definitions",
|
5
5
|
"repository": {
|
6
6
|
"type": "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.1-next.
|
18
|
-
"@twin.org/api-core": "0.0.1-next.
|
19
|
-
"@twin.org/api-models": "0.0.1-next.
|
17
|
+
"@twin.org/api-auth-entity-storage-models": "0.0.1-next.26",
|
18
|
+
"@twin.org/api-core": "0.0.1-next.26",
|
19
|
+
"@twin.org/api-models": "0.0.1-next.26",
|
20
20
|
"@twin.org/core": "next",
|
21
21
|
"@twin.org/crypto": "next",
|
22
22
|
"@twin.org/entity": "next",
|