@3sixty/api-auth-entity-storage-service 0.0.0-stage → 0.20.0-next.1

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 (96) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +24 -2
  3. package/dist/es/entities/authenticationUser.js +61 -0
  4. package/dist/es/entities/authenticationUser.js.map +1 -0
  5. package/dist/es/entities/authenticationUserV0.js +69 -0
  6. package/dist/es/entities/authenticationUserV0.js.map +1 -0
  7. package/dist/es/index.js +21 -0
  8. package/dist/es/index.js.map +1 -0
  9. package/dist/es/models/IAuthHeaderProcessorConfig.js +4 -0
  10. package/dist/es/models/IAuthHeaderProcessorConfig.js.map +1 -0
  11. package/dist/es/models/IAuthHeaderProcessorConstructorOptions.js +2 -0
  12. package/dist/es/models/IAuthHeaderProcessorConstructorOptions.js.map +1 -0
  13. package/dist/es/models/IAuthTokenContext.js +4 -0
  14. package/dist/es/models/IAuthTokenContext.js.map +1 -0
  15. package/dist/es/models/IEntityStorageAuthenticationAdminServiceConfig.js +4 -0
  16. package/dist/es/models/IEntityStorageAuthenticationAdminServiceConfig.js.map +1 -0
  17. package/dist/es/models/IEntityStorageAuthenticationAdminServiceConstructorOptions.js +2 -0
  18. package/dist/es/models/IEntityStorageAuthenticationAdminServiceConstructorOptions.js.map +1 -0
  19. package/dist/es/models/IEntityStorageAuthenticationServiceConfig.js +2 -0
  20. package/dist/es/models/IEntityStorageAuthenticationServiceConfig.js.map +1 -0
  21. package/dist/es/models/IEntityStorageAuthenticationServiceConstructorOptions.js +2 -0
  22. package/dist/es/models/IEntityStorageAuthenticationServiceConstructorOptions.js.map +1 -0
  23. package/dist/es/processors/authHeaderProcessor.js +272 -0
  24. package/dist/es/processors/authHeaderProcessor.js.map +1 -0
  25. package/dist/es/restEntryPoints.js +20 -0
  26. package/dist/es/restEntryPoints.js.map +1 -0
  27. package/dist/es/routes/entityStorageAuthenticationAdminRoutes.js +375 -0
  28. package/dist/es/routes/entityStorageAuthenticationAdminRoutes.js.map +1 -0
  29. package/dist/es/routes/entityStorageAuthenticationRoutes.js +291 -0
  30. package/dist/es/routes/entityStorageAuthenticationRoutes.js.map +1 -0
  31. package/dist/es/schema.js +13 -0
  32. package/dist/es/schema.js.map +1 -0
  33. package/dist/es/services/entityStorageAuthenticationAdminService.js +324 -0
  34. package/dist/es/services/entityStorageAuthenticationAdminService.js.map +1 -0
  35. package/dist/es/services/entityStorageAuthenticationService.js +338 -0
  36. package/dist/es/services/entityStorageAuthenticationService.js.map +1 -0
  37. package/dist/es/utils/passwordHelper.js +60 -0
  38. package/dist/es/utils/passwordHelper.js.map +1 -0
  39. package/dist/es/utils/tokenHelper.js +121 -0
  40. package/dist/es/utils/tokenHelper.js.map +1 -0
  41. package/dist/types/entities/authenticationUser.d.ts +29 -0
  42. package/dist/types/entities/authenticationUserV0.d.ts +33 -0
  43. package/dist/types/index.d.ts +18 -0
  44. package/dist/types/models/IAuthHeaderProcessorConfig.d.ts +38 -0
  45. package/dist/types/models/IAuthHeaderProcessorConstructorOptions.d.ts +25 -0
  46. package/dist/types/models/IAuthTokenContext.d.ts +30 -0
  47. package/dist/types/models/IEntityStorageAuthenticationAdminServiceConfig.d.ts +25 -0
  48. package/dist/types/models/IEntityStorageAuthenticationAdminServiceConstructorOptions.d.ts +25 -0
  49. package/dist/types/models/IEntityStorageAuthenticationServiceConfig.d.ts +41 -0
  50. package/dist/types/models/IEntityStorageAuthenticationServiceConstructorOptions.d.ts +35 -0
  51. package/dist/types/processors/authHeaderProcessor.d.ts +57 -0
  52. package/dist/types/restEntryPoints.d.ts +5 -0
  53. package/dist/types/routes/entityStorageAuthenticationAdminRoutes.d.ts +62 -0
  54. package/dist/types/routes/entityStorageAuthenticationRoutes.d.ts +53 -0
  55. package/dist/types/schema.d.ts +4 -0
  56. package/dist/types/services/entityStorageAuthenticationAdminService.d.ts +69 -0
  57. package/dist/types/services/entityStorageAuthenticationService.d.ts +70 -0
  58. package/dist/types/utils/passwordHelper.d.ts +27 -0
  59. package/dist/types/utils/tokenHelper.d.ts +51 -0
  60. package/docs/changelog.md +19 -0
  61. package/docs/examples.md +94 -0
  62. package/docs/open-api/spec.json +1344 -0
  63. package/docs/reference/classes/AuthHeaderProcessor.md +197 -0
  64. package/docs/reference/classes/AuthenticationUser.md +61 -0
  65. package/docs/reference/classes/AuthenticationUserV0.md +69 -0
  66. package/docs/reference/classes/EntityStorageAuthenticationAdminService.md +237 -0
  67. package/docs/reference/classes/EntityStorageAuthenticationService.md +239 -0
  68. package/docs/reference/classes/PasswordHelper.md +74 -0
  69. package/docs/reference/classes/TokenHelper.md +163 -0
  70. package/docs/reference/functions/authenticationAdminCreateUser.md +37 -0
  71. package/docs/reference/functions/authenticationAdminGetUser.md +31 -0
  72. package/docs/reference/functions/authenticationAdminGetUserByIdentity.md +31 -0
  73. package/docs/reference/functions/authenticationAdminRemoveUser.md +31 -0
  74. package/docs/reference/functions/authenticationAdminUpdateUser.md +31 -0
  75. package/docs/reference/functions/authenticationAdminUpdateUserPassword.md +31 -0
  76. package/docs/reference/functions/authenticationLogin.md +31 -0
  77. package/docs/reference/functions/authenticationLogout.md +31 -0
  78. package/docs/reference/functions/authenticationPasswordPolicy.md +31 -0
  79. package/docs/reference/functions/authenticationRefreshToken.md +31 -0
  80. package/docs/reference/functions/authenticationUpdatePassword.md +31 -0
  81. package/docs/reference/functions/generateRestRoutesAuthentication.md +25 -0
  82. package/docs/reference/functions/generateRestRoutesAuthenticationAdmin.md +25 -0
  83. package/docs/reference/functions/initSchema.md +9 -0
  84. package/docs/reference/index.md +44 -0
  85. package/docs/reference/interfaces/IAuthHeaderProcessorConfig.md +85 -0
  86. package/docs/reference/interfaces/IAuthHeaderProcessorConstructorOptions.md +53 -0
  87. package/docs/reference/interfaces/IAuthTokenContext.md +52 -0
  88. package/docs/reference/interfaces/IEntityStorageAuthenticationAdminServiceConfig.md +59 -0
  89. package/docs/reference/interfaces/IEntityStorageAuthenticationAdminServiceConstructorOptions.md +53 -0
  90. package/docs/reference/interfaces/IEntityStorageAuthenticationServiceConfig.md +101 -0
  91. package/docs/reference/interfaces/IEntityStorageAuthenticationServiceConstructorOptions.md +81 -0
  92. package/docs/reference/variables/restEntryPoints.md +5 -0
  93. package/docs/reference/variables/tagsAuthentication.md +5 -0
  94. package/docs/reference/variables/tagsAuthenticationAdmin.md +5 -0
  95. package/locales/en.json +37 -0
  96. package/package.json +63 -5
@@ -0,0 +1,197 @@
1
+ # Class: AuthHeaderProcessor
2
+
3
+ Handle a JWT token in the authorization header or cookies and validate it to populate request context identity.
4
+
5
+ ## Implements
6
+
7
+ - `IBaseRouteProcessor`
8
+
9
+ ## Constructors
10
+
11
+ ### Constructor
12
+
13
+ > **new AuthHeaderProcessor**(`options?`): `AuthHeaderProcessor`
14
+
15
+ Create a new instance of AuthHeaderProcessor.
16
+
17
+ #### Parameters
18
+
19
+ ##### options?
20
+
21
+ [`IAuthHeaderProcessorConstructorOptions`](../interfaces/IAuthHeaderProcessorConstructorOptions.md)
22
+
23
+ Options for the processor.
24
+
25
+ #### Returns
26
+
27
+ `AuthHeaderProcessor`
28
+
29
+ ## Properties
30
+
31
+ ### CLASS\_NAME {#class_name}
32
+
33
+ > `readonly` `static` **CLASS\_NAME**: `string`
34
+
35
+ Runtime name for the class.
36
+
37
+ ## Methods
38
+
39
+ ### className() {#classname}
40
+
41
+ > **className**(): `string`
42
+
43
+ Returns the class name of the component.
44
+
45
+ #### Returns
46
+
47
+ `string`
48
+
49
+ The class name of the component.
50
+
51
+ #### Implementation of
52
+
53
+ `IBaseRouteProcessor.className`
54
+
55
+ ***
56
+
57
+ ### start() {#start}
58
+
59
+ > **start**(`nodeLoggingComponentType?`): `Promise`\<`void`\>
60
+
61
+ The service needs to be started when the application is initialized.
62
+
63
+ #### Parameters
64
+
65
+ ##### nodeLoggingComponentType?
66
+
67
+ `string`
68
+
69
+ The node logging component type.
70
+
71
+ #### Returns
72
+
73
+ `Promise`\<`void`\>
74
+
75
+ A promise that resolves when the node identity and organization ID have been cached.
76
+
77
+ #### Implementation of
78
+
79
+ `IBaseRouteProcessor.start`
80
+
81
+ ***
82
+
83
+ ### stop() {#stop}
84
+
85
+ > **stop**(): `Promise`\<`void`\>
86
+
87
+ Stop the processor and release the token cache.
88
+
89
+ #### Returns
90
+
91
+ `Promise`\<`void`\>
92
+
93
+ A promise that resolves when the processor has stopped.
94
+
95
+ #### Implementation of
96
+
97
+ `IBaseRouteProcessor.stop`
98
+
99
+ ***
100
+
101
+ ### pre() {#pre}
102
+
103
+ > **pre**(`request`, `response`, `route`, `contextIds`, `processorState`): `Promise`\<`void`\>
104
+
105
+ Pre process the REST request for the specified route.
106
+
107
+ #### Parameters
108
+
109
+ ##### request
110
+
111
+ `IHttpServerRequest`
112
+
113
+ The incoming request.
114
+
115
+ ##### response
116
+
117
+ `IHttpResponse`
118
+
119
+ The outgoing response.
120
+
121
+ ##### route
122
+
123
+ `IBaseRoute` \| `undefined`
124
+
125
+ The route to process.
126
+
127
+ ##### contextIds
128
+
129
+ `IContextIds`
130
+
131
+ The context IDs of the request.
132
+
133
+ ##### processorState
134
+
135
+ \{\[`id`: `string`\]: `unknown`; \}
136
+
137
+ The state handed through the processors.
138
+
139
+ #### Returns
140
+
141
+ `Promise`\<`void`\>
142
+
143
+ A promise that resolves when the JWT has been verified and the context populated, or an error response set.
144
+
145
+ #### Implementation of
146
+
147
+ `IBaseRouteProcessor.pre`
148
+
149
+ ***
150
+
151
+ ### post() {#post}
152
+
153
+ > **post**(`request`, `response`, `route`, `contextIds`, `processorState`): `Promise`\<`void`\>
154
+
155
+ Post process the REST request for the specified route.
156
+
157
+ #### Parameters
158
+
159
+ ##### request
160
+
161
+ `IHttpServerRequest`
162
+
163
+ The incoming request.
164
+
165
+ ##### response
166
+
167
+ `IHttpResponse`
168
+
169
+ The outgoing response.
170
+
171
+ ##### route
172
+
173
+ `IBaseRoute` \| `undefined`
174
+
175
+ The route to process.
176
+
177
+ ##### contextIds
178
+
179
+ `IContextIds`
180
+
181
+ The context IDs of the request.
182
+
183
+ ##### processorState
184
+
185
+ \{\[`id`: `string`\]: `unknown`; \}
186
+
187
+ The state handed through the processors.
188
+
189
+ #### Returns
190
+
191
+ `Promise`\<`void`\>
192
+
193
+ A promise that resolves when the Set-Cookie header has been applied to the response if required.
194
+
195
+ #### Implementation of
196
+
197
+ `IBaseRouteProcessor.post`
@@ -0,0 +1,61 @@
1
+ # Class: AuthenticationUser
2
+
3
+ Class defining the storage for user login credentials.
4
+
5
+ ## Constructors
6
+
7
+ ### Constructor
8
+
9
+ > **new AuthenticationUser**(): `AuthenticationUser`
10
+
11
+ #### Returns
12
+
13
+ `AuthenticationUser`
14
+
15
+ ## Properties
16
+
17
+ ### email {#email}
18
+
19
+ > **email**: `string`
20
+
21
+ The user e-mail address.
22
+
23
+ ***
24
+
25
+ ### password {#password}
26
+
27
+ > **password**: `string`
28
+
29
+ The encrypted password for the user.
30
+
31
+ ***
32
+
33
+ ### salt {#salt}
34
+
35
+ > **salt**: `string`
36
+
37
+ The salt for the password.
38
+
39
+ ***
40
+
41
+ ### identity {#identity}
42
+
43
+ > **identity**: `string`
44
+
45
+ The user identity.
46
+
47
+ ***
48
+
49
+ ### organization {#organization}
50
+
51
+ > **organization**: `string`
52
+
53
+ The users organization.
54
+
55
+ ***
56
+
57
+ ### passwordVersion? {#passwordversion}
58
+
59
+ > `optional` **passwordVersion?**: `number`
60
+
61
+ The password version counter, incremented on every password change to invalidate existing tokens.
@@ -0,0 +1,69 @@
1
+ # Class: AuthenticationUserV0
2
+
3
+ Class defining the storage for user login credentials.
4
+
5
+ ## Constructors
6
+
7
+ ### Constructor
8
+
9
+ > **new AuthenticationUserV0**(): `AuthenticationUserV0`
10
+
11
+ #### Returns
12
+
13
+ `AuthenticationUserV0`
14
+
15
+ ## Properties
16
+
17
+ ### email {#email}
18
+
19
+ > **email**: `string`
20
+
21
+ The user e-mail address.
22
+
23
+ ***
24
+
25
+ ### password {#password}
26
+
27
+ > **password**: `string`
28
+
29
+ The encrypted password for the user.
30
+
31
+ ***
32
+
33
+ ### salt {#salt}
34
+
35
+ > **salt**: `string`
36
+
37
+ The salt for the password.
38
+
39
+ ***
40
+
41
+ ### identity {#identity}
42
+
43
+ > **identity**: `string`
44
+
45
+ The user identity.
46
+
47
+ ***
48
+
49
+ ### organization {#organization}
50
+
51
+ > **organization**: `string`
52
+
53
+ The users organization.
54
+
55
+ ***
56
+
57
+ ### scope {#scope}
58
+
59
+ > **scope**: `string`
60
+
61
+ The scope assigned to the user, comma separated.
62
+
63
+ ***
64
+
65
+ ### passwordVersion? {#passwordversion}
66
+
67
+ > `optional` **passwordVersion?**: `number`
68
+
69
+ The password version counter, incremented on every password change to invalidate existing tokens.
@@ -0,0 +1,237 @@
1
+ # Class: EntityStorageAuthenticationAdminService
2
+
3
+ Implementation of the authentication component using entity storage.
4
+
5
+ ## Implements
6
+
7
+ - `IAuthenticationAdminComponent`
8
+
9
+ ## Constructors
10
+
11
+ ### Constructor
12
+
13
+ > **new EntityStorageAuthenticationAdminService**(`options?`): `EntityStorageAuthenticationAdminService`
14
+
15
+ Create a new instance of EntityStorageAuthentication.
16
+
17
+ #### Parameters
18
+
19
+ ##### options?
20
+
21
+ [`IEntityStorageAuthenticationAdminServiceConstructorOptions`](../interfaces/IEntityStorageAuthenticationAdminServiceConstructorOptions.md)
22
+
23
+ The dependencies for the identity connector.
24
+
25
+ #### Returns
26
+
27
+ `EntityStorageAuthenticationAdminService`
28
+
29
+ ## Properties
30
+
31
+ ### CLASS\_NAME {#class_name}
32
+
33
+ > `readonly` `static` **CLASS\_NAME**: `string`
34
+
35
+ Runtime name for the class.
36
+
37
+ ***
38
+
39
+ ### DEFAULT\_ESCALATED\_PRIVILEGE\_ROLE {#default_escalated_privilege_role}
40
+
41
+ > `readonly` `static` **DEFAULT\_ESCALATED\_PRIVILEGE\_ROLE**: `string` = `"global-admin"`
42
+
43
+ The default role that grants escalated privilege.
44
+
45
+ ***
46
+
47
+ ### DEFAULT\_AUTHORIZATION\_MODEL\_ID {#default_authorization_model_id}
48
+
49
+ > `readonly` `static` **DEFAULT\_AUTHORIZATION\_MODEL\_ID**: `string` = `"system"`
50
+
51
+ The default authorization model ID used to look up roles.
52
+
53
+ ## Methods
54
+
55
+ ### className() {#classname}
56
+
57
+ > **className**(): `string`
58
+
59
+ Returns the class name of the component.
60
+
61
+ #### Returns
62
+
63
+ `string`
64
+
65
+ The class name of the component.
66
+
67
+ #### Implementation of
68
+
69
+ `IAuthenticationAdminComponent.className`
70
+
71
+ ***
72
+
73
+ ### create() {#create}
74
+
75
+ > **create**(`user`): `Promise`\<`void`\>
76
+
77
+ Create a login for the user.
78
+
79
+ #### Parameters
80
+
81
+ ##### user
82
+
83
+ `IAuthenticationUser` & `object`
84
+
85
+ The user to create.
86
+
87
+ #### Returns
88
+
89
+ `Promise`\<`void`\>
90
+
91
+ A promise that resolves when the user account has been created and the audit entry recorded.
92
+
93
+ #### Implementation of
94
+
95
+ `IAuthenticationAdminComponent.create`
96
+
97
+ ***
98
+
99
+ ### update() {#update}
100
+
101
+ > **update**(`user`): `Promise`\<`void`\>
102
+
103
+ Update a login for the user.
104
+
105
+ #### Parameters
106
+
107
+ ##### user
108
+
109
+ `Partial`\<`IAuthenticationUser`\>
110
+
111
+ The user to update.
112
+
113
+ #### Returns
114
+
115
+ `Promise`\<`void`\>
116
+
117
+ A promise that resolves when the user account has been updated and the audit entry recorded.
118
+
119
+ #### Implementation of
120
+
121
+ `IAuthenticationAdminComponent.update`
122
+
123
+ ***
124
+
125
+ ### get() {#get}
126
+
127
+ > **get**(`email`): `Promise`\<`IAuthenticationUser`\>
128
+
129
+ Get a user by email.
130
+
131
+ #### Parameters
132
+
133
+ ##### email
134
+
135
+ `string`
136
+
137
+ The email address of the user to get.
138
+
139
+ #### Returns
140
+
141
+ `Promise`\<`IAuthenticationUser`\>
142
+
143
+ The user details.
144
+
145
+ #### Implementation of
146
+
147
+ `IAuthenticationAdminComponent.get`
148
+
149
+ ***
150
+
151
+ ### getByIdentity() {#getbyidentity}
152
+
153
+ > **getByIdentity**(`identity`): `Promise`\<`IAuthenticationUser`\>
154
+
155
+ Get a user by identity.
156
+
157
+ #### Parameters
158
+
159
+ ##### identity
160
+
161
+ `string`
162
+
163
+ The identity of the user to get.
164
+
165
+ #### Returns
166
+
167
+ `Promise`\<`IAuthenticationUser`\>
168
+
169
+ The user details.
170
+
171
+ #### Implementation of
172
+
173
+ `IAuthenticationAdminComponent.getByIdentity`
174
+
175
+ ***
176
+
177
+ ### remove() {#remove}
178
+
179
+ > **remove**(`email`): `Promise`\<`void`\>
180
+
181
+ Remove the current user.
182
+
183
+ #### Parameters
184
+
185
+ ##### email
186
+
187
+ `string`
188
+
189
+ The email address of the user to remove.
190
+
191
+ #### Returns
192
+
193
+ `Promise`\<`void`\>
194
+
195
+ A promise that resolves when the user account has been removed and the audit entry recorded.
196
+
197
+ #### Implementation of
198
+
199
+ `IAuthenticationAdminComponent.remove`
200
+
201
+ ***
202
+
203
+ ### updatePassword() {#updatepassword}
204
+
205
+ > **updatePassword**(`email`, `newPassword`, `currentPassword?`): `Promise`\<`void`\>
206
+
207
+ Update the user's password.
208
+
209
+ #### Parameters
210
+
211
+ ##### email
212
+
213
+ `string`
214
+
215
+ The email address of the user to update.
216
+
217
+ ##### newPassword
218
+
219
+ `string`
220
+
221
+ The new password for the user.
222
+
223
+ ##### currentPassword?
224
+
225
+ `string`
226
+
227
+ The current password, optional, if supplied will check against existing.
228
+
229
+ #### Returns
230
+
231
+ `Promise`\<`void`\>
232
+
233
+ A promise that resolves when the password has been updated.
234
+
235
+ #### Implementation of
236
+
237
+ `IAuthenticationAdminComponent.updatePassword`