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

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 (133) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +24 -2
  3. package/dist/es/entities/authenticationAuditEntry.js +121 -0
  4. package/dist/es/entities/authenticationAuditEntry.js.map +1 -0
  5. package/dist/es/entities/authenticationRateEntry.js +37 -0
  6. package/dist/es/entities/authenticationRateEntry.js.map +1 -0
  7. package/dist/es/entities/authenticationUser.js +69 -0
  8. package/dist/es/entities/authenticationUser.js.map +1 -0
  9. package/dist/es/index.js +29 -0
  10. package/dist/es/index.js.map +1 -0
  11. package/dist/es/models/IAuthHeaderProcessorConfig.js +4 -0
  12. package/dist/es/models/IAuthHeaderProcessorConfig.js.map +1 -0
  13. package/dist/es/models/IAuthHeaderProcessorConstructorOptions.js +2 -0
  14. package/dist/es/models/IAuthHeaderProcessorConstructorOptions.js.map +1 -0
  15. package/dist/es/models/IAuthTokenContext.js +4 -0
  16. package/dist/es/models/IAuthTokenContext.js.map +1 -0
  17. package/dist/es/models/IEntityStorageAuthenticationAdminServiceConfig.js +4 -0
  18. package/dist/es/models/IEntityStorageAuthenticationAdminServiceConfig.js.map +1 -0
  19. package/dist/es/models/IEntityStorageAuthenticationAdminServiceConstructorOptions.js +2 -0
  20. package/dist/es/models/IEntityStorageAuthenticationAdminServiceConstructorOptions.js.map +1 -0
  21. package/dist/es/models/IEntityStorageAuthenticationAuditServiceConfig.js +4 -0
  22. package/dist/es/models/IEntityStorageAuthenticationAuditServiceConfig.js.map +1 -0
  23. package/dist/es/models/IEntityStorageAuthenticationAuditServiceConstructorOptions.js +2 -0
  24. package/dist/es/models/IEntityStorageAuthenticationAuditServiceConstructorOptions.js.map +1 -0
  25. package/dist/es/models/IEntityStorageAuthenticationRateServiceConfig.js +2 -0
  26. package/dist/es/models/IEntityStorageAuthenticationRateServiceConfig.js.map +1 -0
  27. package/dist/es/models/IEntityStorageAuthenticationRateServiceConstructorOptions.js +2 -0
  28. package/dist/es/models/IEntityStorageAuthenticationRateServiceConstructorOptions.js.map +1 -0
  29. package/dist/es/models/IEntityStorageAuthenticationServiceConfig.js +2 -0
  30. package/dist/es/models/IEntityStorageAuthenticationServiceConfig.js.map +1 -0
  31. package/dist/es/models/IEntityStorageAuthenticationServiceConstructorOptions.js +2 -0
  32. package/dist/es/models/IEntityStorageAuthenticationServiceConstructorOptions.js.map +1 -0
  33. package/dist/es/processors/authHeaderProcessor.js +277 -0
  34. package/dist/es/processors/authHeaderProcessor.js.map +1 -0
  35. package/dist/es/restEntryPoints.js +27 -0
  36. package/dist/es/restEntryPoints.js.map +1 -0
  37. package/dist/es/routes/entityStorageAuthenticationAdminRoutes.js +367 -0
  38. package/dist/es/routes/entityStorageAuthenticationAdminRoutes.js.map +1 -0
  39. package/dist/es/routes/entityStorageAuthenticationAuditRoutes.js +343 -0
  40. package/dist/es/routes/entityStorageAuthenticationAuditRoutes.js.map +1 -0
  41. package/dist/es/routes/entityStorageAuthenticationRoutes.js +247 -0
  42. package/dist/es/routes/entityStorageAuthenticationRoutes.js.map +1 -0
  43. package/dist/es/schema.js +15 -0
  44. package/dist/es/schema.js.map +1 -0
  45. package/dist/es/services/entityStorageAuthenticationAdminService.js +323 -0
  46. package/dist/es/services/entityStorageAuthenticationAdminService.js.map +1 -0
  47. package/dist/es/services/entityStorageAuthenticationAuditService.js +240 -0
  48. package/dist/es/services/entityStorageAuthenticationAuditService.js.map +1 -0
  49. package/dist/es/services/entityStorageAuthenticationRateService.js +213 -0
  50. package/dist/es/services/entityStorageAuthenticationRateService.js.map +1 -0
  51. package/dist/es/services/entityStorageAuthenticationService.js +326 -0
  52. package/dist/es/services/entityStorageAuthenticationService.js.map +1 -0
  53. package/dist/es/utils/passwordHelper.js +58 -0
  54. package/dist/es/utils/passwordHelper.js.map +1 -0
  55. package/dist/es/utils/tokenHelper.js +142 -0
  56. package/dist/es/utils/tokenHelper.js.map +1 -0
  57. package/dist/types/entities/authenticationAuditEntry.d.ts +49 -0
  58. package/dist/types/entities/authenticationRateEntry.d.ts +17 -0
  59. package/dist/types/entities/authenticationUser.d.ts +33 -0
  60. package/dist/types/index.d.ts +26 -0
  61. package/dist/types/models/IAuthHeaderProcessorConfig.d.ts +39 -0
  62. package/dist/types/models/IAuthHeaderProcessorConstructorOptions.d.ts +25 -0
  63. package/dist/types/models/IAuthTokenContext.d.ts +34 -0
  64. package/dist/types/models/IEntityStorageAuthenticationAdminServiceConfig.d.ts +14 -0
  65. package/dist/types/models/IEntityStorageAuthenticationAdminServiceConstructorOptions.d.ts +20 -0
  66. package/dist/types/models/IEntityStorageAuthenticationAuditServiceConfig.d.ts +9 -0
  67. package/dist/types/models/IEntityStorageAuthenticationAuditServiceConstructorOptions.d.ts +15 -0
  68. package/dist/types/models/IEntityStorageAuthenticationRateServiceConfig.d.ts +10 -0
  69. package/dist/types/models/IEntityStorageAuthenticationRateServiceConstructorOptions.d.ts +25 -0
  70. package/dist/types/models/IEntityStorageAuthenticationServiceConfig.d.ts +36 -0
  71. package/dist/types/models/IEntityStorageAuthenticationServiceConstructorOptions.d.ts +35 -0
  72. package/dist/types/processors/authHeaderProcessor.d.ts +57 -0
  73. package/dist/types/restEntryPoints.d.ts +5 -0
  74. package/dist/types/routes/entityStorageAuthenticationAdminRoutes.d.ts +62 -0
  75. package/dist/types/routes/entityStorageAuthenticationAuditRoutes.d.ts +54 -0
  76. package/dist/types/routes/entityStorageAuthenticationRoutes.d.ts +45 -0
  77. package/dist/types/schema.d.ts +4 -0
  78. package/dist/types/services/entityStorageAuthenticationAdminService.d.ts +65 -0
  79. package/dist/types/services/entityStorageAuthenticationAuditService.d.ts +72 -0
  80. package/dist/types/services/entityStorageAuthenticationRateService.d.ts +60 -0
  81. package/dist/types/services/entityStorageAuthenticationService.d.ts +65 -0
  82. package/dist/types/utils/passwordHelper.d.ts +24 -0
  83. package/dist/types/utils/tokenHelper.d.ts +60 -0
  84. package/docs/changelog.md +0 -0
  85. package/docs/examples.md +178 -0
  86. package/docs/open-api/spec.json +2122 -0
  87. package/docs/reference/classes/AuthHeaderProcessor.md +193 -0
  88. package/docs/reference/classes/AuthenticationAuditEntry.md +101 -0
  89. package/docs/reference/classes/AuthenticationRateEntry.md +37 -0
  90. package/docs/reference/classes/AuthenticationUser.md +69 -0
  91. package/docs/reference/classes/EntityStorageAuthenticationAdminService.md +229 -0
  92. package/docs/reference/classes/EntityStorageAuthenticationAuditService.md +241 -0
  93. package/docs/reference/classes/EntityStorageAuthenticationRateService.md +227 -0
  94. package/docs/reference/classes/EntityStorageAuthenticationService.md +221 -0
  95. package/docs/reference/classes/PasswordHelper.md +74 -0
  96. package/docs/reference/classes/TokenHelper.md +205 -0
  97. package/docs/reference/functions/authenticationAdminCreateUser.md +37 -0
  98. package/docs/reference/functions/authenticationAdminGetUser.md +31 -0
  99. package/docs/reference/functions/authenticationAdminGetUserByIdentity.md +31 -0
  100. package/docs/reference/functions/authenticationAdminRemoveUser.md +31 -0
  101. package/docs/reference/functions/authenticationAdminUpdateUser.md +31 -0
  102. package/docs/reference/functions/authenticationAdminUpdateUserPassword.md +31 -0
  103. package/docs/reference/functions/authenticationAuditCreate.md +37 -0
  104. package/docs/reference/functions/authenticationAuditGet.md +31 -0
  105. package/docs/reference/functions/authenticationAuditQuery.md +31 -0
  106. package/docs/reference/functions/authenticationAuditRemove.md +31 -0
  107. package/docs/reference/functions/authenticationAuditUpdate.md +31 -0
  108. package/docs/reference/functions/authenticationLogin.md +31 -0
  109. package/docs/reference/functions/authenticationLogout.md +31 -0
  110. package/docs/reference/functions/authenticationRefreshToken.md +31 -0
  111. package/docs/reference/functions/authenticationUpdatePassword.md +31 -0
  112. package/docs/reference/functions/generateRestRoutesAuthentication.md +25 -0
  113. package/docs/reference/functions/generateRestRoutesAuthenticationAdmin.md +25 -0
  114. package/docs/reference/functions/generateRestRoutesAuthenticationAudit.md +25 -0
  115. package/docs/reference/functions/initSchema.md +9 -0
  116. package/docs/reference/index.md +57 -0
  117. package/docs/reference/interfaces/IAuthHeaderProcessorConfig.md +86 -0
  118. package/docs/reference/interfaces/IAuthHeaderProcessorConstructorOptions.md +53 -0
  119. package/docs/reference/interfaces/IAuthTokenContext.md +60 -0
  120. package/docs/reference/interfaces/IEntityStorageAuthenticationAdminServiceConfig.md +25 -0
  121. package/docs/reference/interfaces/IEntityStorageAuthenticationAdminServiceConstructorOptions.md +39 -0
  122. package/docs/reference/interfaces/IEntityStorageAuthenticationAuditServiceConfig.md +11 -0
  123. package/docs/reference/interfaces/IEntityStorageAuthenticationAuditServiceConstructorOptions.md +25 -0
  124. package/docs/reference/interfaces/IEntityStorageAuthenticationRateServiceConfig.md +17 -0
  125. package/docs/reference/interfaces/IEntityStorageAuthenticationRateServiceConstructorOptions.md +53 -0
  126. package/docs/reference/interfaces/IEntityStorageAuthenticationServiceConfig.md +87 -0
  127. package/docs/reference/interfaces/IEntityStorageAuthenticationServiceConstructorOptions.md +81 -0
  128. package/docs/reference/variables/restEntryPoints.md +5 -0
  129. package/docs/reference/variables/tagsAuthentication.md +5 -0
  130. package/docs/reference/variables/tagsAuthenticationAdmin.md +5 -0
  131. package/docs/reference/variables/tagsAuthenticationAudit.md +5 -0
  132. package/locales/en.json +52 -0
  133. package/package.json +64 -5
@@ -0,0 +1,367 @@
1
+ import { HttpContextIdKeys, HttpHeaderHelper, HttpUrlHelper } from "@3sixty/api-models";
2
+ import { ContextIdStore } from "@3sixty/context";
3
+ import { ComponentFactory, Guards } from "@3sixty/core";
4
+ import { HttpStatusCode } from "@3sixty/web";
5
+ /**
6
+ * The source used when communicating about these routes.
7
+ */
8
+ const ROUTES_SOURCE = "authenticationAdminRoutes";
9
+ /**
10
+ * The tag to associate with the routes.
11
+ */
12
+ export const tagsAuthenticationAdmin = [
13
+ {
14
+ name: "Authentication Admin",
15
+ description: "Authentication Admin endpoints for the REST server."
16
+ }
17
+ ];
18
+ /**
19
+ * The REST routes for authentication admin.
20
+ * @param baseRouteName Prefix to prepend to the paths.
21
+ * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
22
+ * @returns The generated routes.
23
+ */
24
+ export function generateRestRoutesAuthenticationAdmin(baseRouteName, componentName) {
25
+ const createUserRoute = {
26
+ operationId: "authenticationAdminCreateUser",
27
+ summary: "Create a new user",
28
+ tag: tagsAuthenticationAdmin[0].name,
29
+ method: "POST",
30
+ path: `${baseRouteName}/users`,
31
+ handler: async (httpRequestContext, request) => authenticationAdminCreateUser(httpRequestContext, componentName, request, baseRouteName),
32
+ requestType: {
33
+ type: "IAdminUserCreateRequest",
34
+ examples: [
35
+ {
36
+ id: "createUserRequestExample",
37
+ description: "The request to create a new user.",
38
+ request: {
39
+ body: {
40
+ email: "user@example.com",
41
+ password: "MyPassword123!",
42
+ userIdentity: "did:example:123456789abcdefghi",
43
+ organizationIdentity: "did:example:123456789abcdefghi",
44
+ scope: ["scope1", "scope2"]
45
+ }
46
+ }
47
+ }
48
+ ]
49
+ },
50
+ responseType: [
51
+ {
52
+ type: "INoContentResponse"
53
+ },
54
+ {
55
+ type: "IUnauthorizedResponse"
56
+ }
57
+ ],
58
+ requiredScope: ["user-admin"]
59
+ };
60
+ const updateUserRoute = {
61
+ operationId: "authenticationAdminUpdateUser",
62
+ summary: "Update an existing user",
63
+ tag: tagsAuthenticationAdmin[0].name,
64
+ method: "PUT",
65
+ path: `${baseRouteName}/users/:email`,
66
+ handler: async (httpRequestContext, request) => authenticationAdminUpdateUser(httpRequestContext, componentName, request),
67
+ requestType: {
68
+ type: "IAdminUserUpdateRequest",
69
+ examples: [
70
+ {
71
+ id: "updateUserRequestExample",
72
+ description: "The request to update an existing user.",
73
+ request: {
74
+ pathParams: {
75
+ email: "user@example.com"
76
+ },
77
+ body: {
78
+ userIdentity: "did:example:123456789abcdefghi",
79
+ organizationIdentity: "did:example:123456789abcdefghi",
80
+ scope: ["scope1", "scope2"]
81
+ }
82
+ }
83
+ }
84
+ ]
85
+ },
86
+ responseType: [
87
+ {
88
+ type: "INoContentResponse"
89
+ },
90
+ {
91
+ type: "IUnauthorizedResponse"
92
+ }
93
+ ],
94
+ requiredScope: ["user-admin"]
95
+ };
96
+ const updateUserPasswordRoute = {
97
+ operationId: "authenticationAdminUpdateUserPassword",
98
+ summary: "Update an existing user password",
99
+ tag: tagsAuthenticationAdmin[0].name,
100
+ method: "PUT",
101
+ path: `${baseRouteName}/users/:email/password`,
102
+ handler: async (httpRequestContext, request) => authenticationAdminUpdateUserPassword(httpRequestContext, componentName, request),
103
+ requestType: {
104
+ type: "IAdminUserUpdatePasswordRequest",
105
+ examples: [
106
+ {
107
+ id: "updateUserPasswordRequestExample",
108
+ description: "The request to update an existing user password.",
109
+ request: {
110
+ pathParams: {
111
+ email: "user@example.com"
112
+ },
113
+ body: {
114
+ newPassword: "MyNewPassword123!"
115
+ }
116
+ }
117
+ }
118
+ ]
119
+ },
120
+ responseType: [
121
+ {
122
+ type: "INoContentResponse"
123
+ },
124
+ {
125
+ type: "IUnauthorizedResponse"
126
+ }
127
+ ],
128
+ requiredScope: ["user-admin"]
129
+ };
130
+ const getUserRoute = {
131
+ operationId: "authenticationAdminGetUser",
132
+ summary: "Get existing user",
133
+ tag: tagsAuthenticationAdmin[0].name,
134
+ method: "GET",
135
+ path: `${baseRouteName}/users/:email`,
136
+ handler: async (httpRequestContext, request) => authenticationAdminGetUser(httpRequestContext, componentName, request),
137
+ requestType: {
138
+ type: "IAdminUserGetRequest",
139
+ examples: [
140
+ {
141
+ id: "getUserRequestExample",
142
+ description: "The request to get an existing user.",
143
+ request: {
144
+ pathParams: {
145
+ email: "user@example.com"
146
+ }
147
+ }
148
+ }
149
+ ]
150
+ },
151
+ responseType: [
152
+ {
153
+ type: "IAdminUserGetResponse",
154
+ examples: [
155
+ {
156
+ id: "getUserResponseExample",
157
+ description: "The response to get an existing user.",
158
+ response: {
159
+ body: {
160
+ email: "user@example.com",
161
+ userIdentity: "did:example:123456789abcdefghi",
162
+ organizationIdentity: "did:example:123456789abcdefghi",
163
+ scope: ["scope1", "scope2"]
164
+ }
165
+ }
166
+ }
167
+ ]
168
+ },
169
+ {
170
+ type: "IUnauthorizedResponse"
171
+ }
172
+ ],
173
+ requiredScope: ["user-admin"]
174
+ };
175
+ const getByIdentityUserRoute = {
176
+ operationId: "authenticationAdminGetByIdentityUser",
177
+ summary: "Get existing user by identity",
178
+ tag: tagsAuthenticationAdmin[0].name,
179
+ method: "GET",
180
+ path: `${baseRouteName}/users/identity/:identity`,
181
+ handler: async (httpRequestContext, request) => authenticationAdminGetUserByIdentity(httpRequestContext, componentName, request),
182
+ requestType: {
183
+ type: "IAdminUserGetByIdentityRequest",
184
+ examples: [
185
+ {
186
+ id: "getUserByIdentityRequestExample",
187
+ description: "The request to get an existing user by identity.",
188
+ request: {
189
+ pathParams: {
190
+ identity: "did:example:123456789abcdefghi"
191
+ }
192
+ }
193
+ }
194
+ ]
195
+ },
196
+ responseType: [
197
+ {
198
+ type: "IAdminUserGetResponse",
199
+ examples: [
200
+ {
201
+ id: "getUserResponseExample",
202
+ description: "The response to get an existing user.",
203
+ response: {
204
+ body: {
205
+ email: "user@example.com",
206
+ userIdentity: "did:example:123456789abcdefghi",
207
+ organizationIdentity: "did:example:123456789abcdefghi",
208
+ scope: ["scope1", "scope2"]
209
+ }
210
+ }
211
+ }
212
+ ]
213
+ },
214
+ {
215
+ type: "IUnauthorizedResponse"
216
+ }
217
+ ],
218
+ requiredScope: ["user-admin"]
219
+ };
220
+ const removeUserRoute = {
221
+ operationId: "authenticationAdminRemoveUser",
222
+ summary: "Remove existing user",
223
+ tag: tagsAuthenticationAdmin[0].name,
224
+ method: "DELETE",
225
+ path: `${baseRouteName}/users/:email`,
226
+ handler: async (httpRequestContext, request) => authenticationAdminRemoveUser(httpRequestContext, componentName, request),
227
+ requestType: {
228
+ type: "IAdminUserRemoveRequest",
229
+ examples: [
230
+ {
231
+ id: "removeUserRequestExample",
232
+ description: "The request to remove an existing user.",
233
+ request: {
234
+ pathParams: {
235
+ email: "user@example.com"
236
+ }
237
+ }
238
+ }
239
+ ]
240
+ },
241
+ responseType: [
242
+ {
243
+ type: "INoContentResponse"
244
+ },
245
+ {
246
+ type: "IUnauthorizedResponse"
247
+ }
248
+ ],
249
+ requiredScope: ["user-admin"]
250
+ };
251
+ return [
252
+ createUserRoute,
253
+ updateUserRoute,
254
+ updateUserPasswordRoute,
255
+ getUserRoute,
256
+ getByIdentityUserRoute,
257
+ removeUserRoute
258
+ ];
259
+ }
260
+ /**
261
+ * Create a new user.
262
+ * @param httpRequestContext The request context for the API.
263
+ * @param componentName The name of the component to use in the routes.
264
+ * @param request The request.
265
+ * @param baseRouteName The base route name to use for the location header.
266
+ * @returns The response object with additional http response properties.
267
+ */
268
+ export async function authenticationAdminCreateUser(httpRequestContext, componentName, request, baseRouteName) {
269
+ Guards.object(ROUTES_SOURCE, "request", request);
270
+ Guards.object(ROUTES_SOURCE, "request.body", request.body);
271
+ const component = ComponentFactory.get(componentName);
272
+ await component.create(request.body);
273
+ const contextIds = await ContextIdStore.getContextIds();
274
+ const publicOrigin = contextIds?.[HttpContextIdKeys.PublicOrigin];
275
+ const headers = {};
276
+ HttpHeaderHelper.buildId(headers, request.body.email, HttpUrlHelper.combineOriginPath(publicOrigin, `${baseRouteName}/users/:id`));
277
+ return {
278
+ statusCode: HttpStatusCode.created,
279
+ headers
280
+ };
281
+ }
282
+ /**
283
+ * Update an existing user.
284
+ * @param httpRequestContext The request context for the API.
285
+ * @param componentName The name of the component to use in the routes.
286
+ * @param request The request.
287
+ * @returns The response object with additional http response properties.
288
+ */
289
+ export async function authenticationAdminUpdateUser(httpRequestContext, componentName, request) {
290
+ Guards.object(ROUTES_SOURCE, "request", request);
291
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
292
+ Guards.object(ROUTES_SOURCE, "request.body", request.body);
293
+ const component = ComponentFactory.get(componentName);
294
+ await component.update({
295
+ ...request.body,
296
+ email: request.pathParams.email
297
+ });
298
+ return {
299
+ statusCode: HttpStatusCode.noContent
300
+ };
301
+ }
302
+ /**
303
+ * Update an existing user password.
304
+ * @param httpRequestContext The request context for the API.
305
+ * @param componentName The name of the component to use in the routes.
306
+ * @param request The request.
307
+ * @returns The response object with additional http response properties.
308
+ */
309
+ export async function authenticationAdminUpdateUserPassword(httpRequestContext, componentName, request) {
310
+ Guards.object(ROUTES_SOURCE, "request", request);
311
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
312
+ Guards.object(ROUTES_SOURCE, "request.body", request.body);
313
+ const component = ComponentFactory.get(componentName);
314
+ await component.updatePassword(request.pathParams.email, request.body.newPassword);
315
+ return {
316
+ statusCode: HttpStatusCode.noContent
317
+ };
318
+ }
319
+ /**
320
+ * Get an existing user.
321
+ * @param httpRequestContext The request context for the API.
322
+ * @param componentName The name of the component to use in the routes.
323
+ * @param request The request.
324
+ * @returns The response object with additional http response properties.
325
+ */
326
+ export async function authenticationAdminGetUser(httpRequestContext, componentName, request) {
327
+ Guards.object(ROUTES_SOURCE, "request", request);
328
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
329
+ const component = ComponentFactory.get(componentName);
330
+ const result = await component.get(request.pathParams.email);
331
+ return {
332
+ body: result
333
+ };
334
+ }
335
+ /**
336
+ * Get an existing user by identity.
337
+ * @param httpRequestContext The request context for the API.
338
+ * @param componentName The name of the component to use in the routes.
339
+ * @param request The request.
340
+ * @returns The response object with additional http response properties.
341
+ */
342
+ export async function authenticationAdminGetUserByIdentity(httpRequestContext, componentName, request) {
343
+ Guards.object(ROUTES_SOURCE, "request", request);
344
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
345
+ const component = ComponentFactory.get(componentName);
346
+ const result = await component.getByIdentity(request.pathParams.identity);
347
+ return {
348
+ body: result
349
+ };
350
+ }
351
+ /**
352
+ * Remove an existing user.
353
+ * @param httpRequestContext The request context for the API.
354
+ * @param componentName The name of the component to use in the routes.
355
+ * @param request The request.
356
+ * @returns The response object with additional http response properties.
357
+ */
358
+ export async function authenticationAdminRemoveUser(httpRequestContext, componentName, request) {
359
+ Guards.object(ROUTES_SOURCE, "request", request);
360
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
361
+ const component = ComponentFactory.get(componentName);
362
+ await component.remove(request.pathParams.email);
363
+ return {
364
+ statusCode: HttpStatusCode.noContent
365
+ };
366
+ }
367
+ //# sourceMappingURL=entityStorageAuthenticationAdminRoutes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entityStorageAuthenticationAdminRoutes.js","sourceRoot":"","sources":["../../../src/routes/entityStorageAuthenticationAdminRoutes.ts"],"names":[],"mappings":"AAYA,OAAO,EACN,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EAOb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAAE,cAAc,EAAqB,MAAM,aAAa,CAAC;AAEhE;;GAEG;AACH,MAAM,aAAa,GAAG,2BAA2B,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAW;IAC9C;QACC,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EAAE,qDAAqD;KAClE;CACD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,qCAAqC,CACpD,aAAqB,EACrB,aAAqB;IAErB,MAAM,eAAe,GAA0D;QAC9E,WAAW,EAAE,+BAA+B;QAC5C,OAAO,EAAE,mBAAmB;QAC5B,GAAG,EAAE,uBAAuB,CAAC,CAAC,CAAC,CAAC,IAAI;QACpC,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,GAAG,aAAa,QAAQ;QAC9B,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,EAAE,CAC9C,6BAA6B,CAAC,kBAAkB,EAAE,aAAa,EAAE,OAAO,EA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M,MAAM,GAAG,MAAM,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAE1E,OAAO;QACN,IAAI,EAAE,MAAM;KACZ,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAClD,kBAAuC,EACvC,aAAqB,EACrB,OAAgC;IAEhC,MAAM,CAAC,MAAM,CAA0B,aAAa,aAAmB,OAAO,CAAC,CAAC;IAChF,MAAM,CAAC,MAAM,CACZ,aAAa,wBAEb,OAAO,CAAC,UAAU,CAClB,CAAC;IAEF,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAgC,aAAa,CAAC,CAAC;IACrF,MAAM,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAEjD,OAAO;QACN,UAAU,EAAE,cAAc,CAAC,SAAS;KACpC,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tIAdminUserCreateRequest,\n\tIAdminUserGetByIdentityRequest,\n\tIAdminUserGetRequest,\n\tIAdminUserGetResponse,\n\tIAdminUserRemoveRequest,\n\tIAdminUserUpdatePasswordRequest,\n\tIAdminUserUpdateRequest,\n\tIAuthenticationAdminComponent\n} from \"@3sixty/api-auth-entity-storage-models\";\nimport {\n\tHttpContextIdKeys,\n\tHttpHeaderHelper,\n\tHttpUrlHelper,\n\ttype ICreatedResponse,\n\ttype IHttpRequestContext,\n\ttype INoContentResponse,\n\ttype IRestRoute,\n\ttype ITag,\n\ttype IUnauthorizedResponse\n} from \"@3sixty/api-models\";\nimport { ContextIdStore } from \"@3sixty/context\";\nimport { ComponentFactory, Guards } from \"@3sixty/core\";\nimport { nameof } from \"@3sixty/nameof\";\nimport { HttpStatusCode, type IHttpHeaders } from \"@3sixty/web\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"authenticationAdminRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsAuthenticationAdmin: ITag[] = [\n\t{\n\t\tname: \"Authentication Admin\",\n\t\tdescription: \"Authentication Admin endpoints for the REST server.\"\n\t}\n];\n\n/**\n * The REST routes for authentication admin.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesAuthenticationAdmin(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst createUserRoute: IRestRoute<IAdminUserCreateRequest, ICreatedResponse> = {\n\t\toperationId: \"authenticationAdminCreateUser\",\n\t\tsummary: \"Create a new user\",\n\t\ttag: tagsAuthenticationAdmin[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/users`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tauthenticationAdminCreateUser(httpRequestContext, componentName, request, baseRouteName),\n\t\trequestType: {\n\t\t\ttype: nameof<IAdminUserCreateRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"createUserRequestExample\",\n\t\t\t\t\tdescription: \"The request to create a new user.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\temail: \"user@example.com\",\n\t\t\t\t\t\t\tpassword: \"MyPassword123!\",\n\t\t\t\t\t\t\tuserIdentity: \"did:example:123456789abcdefghi\",\n\t\t\t\t\t\t\torganizationIdentity: \"did:example:123456789abcdefghi\",\n\t\t\t\t\t\t\tscope: [\"scope1\", \"scope2\"]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<IUnauthorizedResponse>()\n\t\t\t}\n\t\t],\n\t\trequiredScope: [\"user-admin\"]\n\t};\n\n\tconst updateUserRoute: IRestRoute<IAdminUserUpdateRequest, INoContentResponse> = {\n\t\toperationId: \"authenticationAdminUpdateUser\",\n\t\tsummary: \"Update an existing user\",\n\t\ttag: tagsAuthenticationAdmin[0].name,\n\t\tmethod: \"PUT\",\n\t\tpath: `${baseRouteName}/users/:email`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tauthenticationAdminUpdateUser(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IAdminUserUpdateRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"updateUserRequestExample\",\n\t\t\t\t\tdescription: \"The request to update an existing user.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\temail: \"user@example.com\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tuserIdentity: \"did:example:123456789abcdefghi\",\n\t\t\t\t\t\t\torganizationIdentity: \"did:example:123456789abcdefghi\",\n\t\t\t\t\t\t\tscope: [\"scope1\", \"scope2\"]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<IUnauthorizedResponse>()\n\t\t\t}\n\t\t],\n\t\trequiredScope: [\"user-admin\"]\n\t};\n\n\tconst updateUserPasswordRoute: IRestRoute<IAdminUserUpdatePasswordRequest, INoContentResponse> = {\n\t\toperationId: \"authenticationAdminUpdateUserPassword\",\n\t\tsummary: \"Update an existing user password\",\n\t\ttag: tagsAuthenticationAdmin[0].name,\n\t\tmethod: \"PUT\",\n\t\tpath: `${baseRouteName}/users/:email/password`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tauthenticationAdminUpdateUserPassword(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IAdminUserUpdatePasswordRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"updateUserPasswordRequestExample\",\n\t\t\t\t\tdescription: \"The request to update an existing user password.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\temail: \"user@example.com\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tnewPassword: \"MyNewPassword123!\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<IUnauthorizedResponse>()\n\t\t\t}\n\t\t],\n\t\trequiredScope: [\"user-admin\"]\n\t};\n\n\tconst getUserRoute: IRestRoute<IAdminUserGetRequest, IAdminUserGetResponse> = {\n\t\toperationId: \"authenticationAdminGetUser\",\n\t\tsummary: \"Get existing user\",\n\t\ttag: tagsAuthenticationAdmin[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/users/:email`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tauthenticationAdminGetUser(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IAdminUserGetRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"getUserRequestExample\",\n\t\t\t\t\tdescription: \"The request to get an existing user.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\temail: \"user@example.com\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IAdminUserGetResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"getUserResponseExample\",\n\t\t\t\t\t\tdescription: \"The response to get an existing user.\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\temail: \"user@example.com\",\n\t\t\t\t\t\t\t\tuserIdentity: \"did:example:123456789abcdefghi\",\n\t\t\t\t\t\t\t\torganizationIdentity: \"did:example:123456789abcdefghi\",\n\t\t\t\t\t\t\t\tscope: [\"scope1\", \"scope2\"]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<IUnauthorizedResponse>()\n\t\t\t}\n\t\t],\n\t\trequiredScope: [\"user-admin\"]\n\t};\n\n\tconst getByIdentityUserRoute: IRestRoute<IAdminUserGetByIdentityRequest, IAdminUserGetResponse> =\n\t\t{\n\t\t\toperationId: \"authenticationAdminGetByIdentityUser\",\n\t\t\tsummary: \"Get existing user by identity\",\n\t\t\ttag: tagsAuthenticationAdmin[0].name,\n\t\t\tmethod: \"GET\",\n\t\t\tpath: `${baseRouteName}/users/identity/:identity`,\n\t\t\thandler: async (httpRequestContext, request) =>\n\t\t\t\tauthenticationAdminGetUserByIdentity(httpRequestContext, componentName, request),\n\t\t\trequestType: {\n\t\t\t\ttype: nameof<IAdminUserGetByIdentityRequest>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"getUserByIdentityRequestExample\",\n\t\t\t\t\t\tdescription: \"The request to get an existing user by identity.\",\n\t\t\t\t\t\trequest: {\n\t\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\t\tidentity: \"did:example:123456789abcdefghi\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\tresponseType: [\n\t\t\t\t{\n\t\t\t\t\ttype: nameof<IAdminUserGetResponse>(),\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: \"getUserResponseExample\",\n\t\t\t\t\t\t\tdescription: \"The response to get an existing user.\",\n\t\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\temail: \"user@example.com\",\n\t\t\t\t\t\t\t\t\tuserIdentity: \"did:example:123456789abcdefghi\",\n\t\t\t\t\t\t\t\t\torganizationIdentity: \"did:example:123456789abcdefghi\",\n\t\t\t\t\t\t\t\t\tscope: [\"scope1\", \"scope2\"]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttype: nameof<IUnauthorizedResponse>()\n\t\t\t\t}\n\t\t\t],\n\t\t\trequiredScope: [\"user-admin\"]\n\t\t};\n\n\tconst removeUserRoute: IRestRoute<IAdminUserRemoveRequest, INoContentResponse> = {\n\t\toperationId: \"authenticationAdminRemoveUser\",\n\t\tsummary: \"Remove existing user\",\n\t\ttag: tagsAuthenticationAdmin[0].name,\n\t\tmethod: \"DELETE\",\n\t\tpath: `${baseRouteName}/users/:email`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tauthenticationAdminRemoveUser(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IAdminUserRemoveRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"removeUserRequestExample\",\n\t\t\t\t\tdescription: \"The request to remove an existing user.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\temail: \"user@example.com\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<IUnauthorizedResponse>()\n\t\t\t}\n\t\t],\n\t\trequiredScope: [\"user-admin\"]\n\t};\n\n\treturn [\n\t\tcreateUserRoute,\n\t\tupdateUserRoute,\n\t\tupdateUserPasswordRoute,\n\t\tgetUserRoute,\n\t\tgetByIdentityUserRoute,\n\t\tremoveUserRoute\n\t];\n}\n\n/**\n * Create a new user.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @param baseRouteName The base route name to use for the location header.\n * @returns The response object with additional http response properties.\n */\nexport async function authenticationAdminCreateUser(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IAdminUserCreateRequest,\n\tbaseRouteName: string\n): Promise<ICreatedResponse> {\n\tGuards.object<IAdminUserCreateRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IAdminUserCreateRequest[\"body\"]>(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst component = ComponentFactory.get<IAuthenticationAdminComponent>(componentName);\n\tawait component.create(request.body);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tconst publicOrigin = contextIds?.[HttpContextIdKeys.PublicOrigin];\n\n\tconst headers: IHttpHeaders = {};\n\tHttpHeaderHelper.buildId(\n\t\theaders,\n\t\trequest.body.email,\n\t\tHttpUrlHelper.combineOriginPath(publicOrigin, `${baseRouteName}/users/:id`)\n\t);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.created,\n\t\theaders\n\t};\n}\n\n/**\n * Update an existing user.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function authenticationAdminUpdateUser(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IAdminUserUpdateRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IAdminUserUpdateRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IAdminUserUpdateRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.object<IAdminUserUpdateRequest[\"body\"]>(ROUTES_SOURCE, nameof(request.body), request.body);\n\n\tconst component = ComponentFactory.get<IAuthenticationAdminComponent>(componentName);\n\tawait component.update({\n\t\t...request.body,\n\t\temail: request.pathParams.email\n\t});\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Update an existing user password.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function authenticationAdminUpdateUserPassword(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IAdminUserUpdatePasswordRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IAdminUserUpdatePasswordRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IAdminUserUpdatePasswordRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.object<IAdminUserUpdatePasswordRequest[\"body\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.body),\n\t\trequest.body\n\t);\n\n\tconst component = ComponentFactory.get<IAuthenticationAdminComponent>(componentName);\n\tawait component.updatePassword(request.pathParams.email, request.body.newPassword);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Get an existing user.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function authenticationAdminGetUser(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IAdminUserGetRequest\n): Promise<IAdminUserGetResponse> {\n\tGuards.object<IAdminUserGetRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IAdminUserGetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\n\tconst component = ComponentFactory.get<IAuthenticationAdminComponent>(componentName);\n\tconst result = await component.get(request.pathParams.email);\n\n\treturn {\n\t\tbody: result\n\t};\n}\n\n/**\n * Get an existing user by identity.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function authenticationAdminGetUserByIdentity(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IAdminUserGetByIdentityRequest\n): Promise<IAdminUserGetResponse> {\n\tGuards.object<IAdminUserGetByIdentityRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IAdminUserGetByIdentityRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\n\tconst component = ComponentFactory.get<IAuthenticationAdminComponent>(componentName);\n\tconst result = await component.getByIdentity(request.pathParams.identity);\n\n\treturn {\n\t\tbody: result\n\t};\n}\n\n/**\n * Remove an existing user.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function authenticationAdminRemoveUser(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IAdminUserRemoveRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IAdminUserRemoveRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IAdminUserRemoveRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\n\tconst component = ComponentFactory.get<IAuthenticationAdminComponent>(componentName);\n\tawait component.remove(request.pathParams.email);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n"]}