@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,375 @@
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 default authorization for the routes, used to seed authorization rules.
11
+ */
12
+ const DEFAULT_AUTHORIZATION_READER = {
13
+ permission: "user-admin:read",
14
+ role: "user-admin"
15
+ };
16
+ const DEFAULT_AUTHORIZATION_WRITER = {
17
+ permission: "user-admin:write",
18
+ role: "user-admin",
19
+ inherits: [DEFAULT_AUTHORIZATION_READER.permission]
20
+ };
21
+ /**
22
+ * The tag to associate with the routes.
23
+ */
24
+ export const tagsAuthenticationAdmin = [
25
+ {
26
+ name: "Authentication Admin",
27
+ description: "Authentication Admin endpoints for the REST server."
28
+ }
29
+ ];
30
+ /**
31
+ * The REST routes for authentication admin.
32
+ * @param baseRouteName Prefix to prepend to the paths.
33
+ * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
34
+ * @returns The generated routes.
35
+ */
36
+ export function generateRestRoutesAuthenticationAdmin(baseRouteName, componentName) {
37
+ const createUserRoute = {
38
+ operationId: "authenticationAdminCreateUser",
39
+ summary: "Create a new user",
40
+ tag: tagsAuthenticationAdmin[0].name,
41
+ method: "POST",
42
+ path: `${baseRouteName}/users`,
43
+ handler: async (httpRequestContext, request) => authenticationAdminCreateUser(httpRequestContext, componentName, request, baseRouteName),
44
+ requestType: {
45
+ type: "IAdminUserCreateRequest",
46
+ examples: [
47
+ {
48
+ id: "createUserRequestExample",
49
+ description: "The request to create a new user.",
50
+ request: {
51
+ body: {
52
+ email: "user@example.com",
53
+ password: "MyPassword123!",
54
+ userIdentity: "did:example:123456789abcdefghi",
55
+ organizationIdentity: "did:example:123456789abcdefghi"
56
+ }
57
+ }
58
+ }
59
+ ]
60
+ },
61
+ responseType: [
62
+ {
63
+ type: "INoContentResponse"
64
+ },
65
+ {
66
+ type: "IUnauthorizedResponse"
67
+ }
68
+ ],
69
+ defaultAuthorization: DEFAULT_AUTHORIZATION_WRITER
70
+ };
71
+ const updateUserRoute = {
72
+ operationId: "authenticationAdminUpdateUser",
73
+ summary: "Update an existing user",
74
+ tag: tagsAuthenticationAdmin[0].name,
75
+ method: "PUT",
76
+ path: `${baseRouteName}/users/:email`,
77
+ handler: async (httpRequestContext, request) => authenticationAdminUpdateUser(httpRequestContext, componentName, request),
78
+ requestType: {
79
+ type: "IAdminUserUpdateRequest",
80
+ examples: [
81
+ {
82
+ id: "updateUserRequestExample",
83
+ description: "The request to update an existing user.",
84
+ request: {
85
+ pathParams: {
86
+ email: "user@example.com"
87
+ },
88
+ body: {
89
+ userIdentity: "did:example:123456789abcdefghi",
90
+ organizationIdentity: "did:example:123456789abcdefghi"
91
+ }
92
+ }
93
+ }
94
+ ]
95
+ },
96
+ responseType: [
97
+ {
98
+ type: "INoContentResponse"
99
+ },
100
+ {
101
+ type: "IUnauthorizedResponse"
102
+ }
103
+ ],
104
+ defaultAuthorization: DEFAULT_AUTHORIZATION_WRITER
105
+ };
106
+ const updateUserPasswordRoute = {
107
+ operationId: "authenticationAdminUpdateUserPassword",
108
+ summary: "Update an existing user password",
109
+ tag: tagsAuthenticationAdmin[0].name,
110
+ method: "PUT",
111
+ path: `${baseRouteName}/users/:email/password`,
112
+ handler: async (httpRequestContext, request) => authenticationAdminUpdateUserPassword(httpRequestContext, componentName, request),
113
+ requestType: {
114
+ type: "IAdminUserUpdatePasswordRequest",
115
+ examples: [
116
+ {
117
+ id: "updateUserPasswordRequestExample",
118
+ description: "The request to update an existing user password.",
119
+ request: {
120
+ pathParams: {
121
+ email: "user@example.com"
122
+ },
123
+ body: {
124
+ newPassword: "MyNewPassword123!"
125
+ }
126
+ }
127
+ }
128
+ ]
129
+ },
130
+ responseType: [
131
+ {
132
+ type: "INoContentResponse"
133
+ },
134
+ {
135
+ type: "IUnauthorizedResponse"
136
+ }
137
+ ],
138
+ defaultAuthorization: DEFAULT_AUTHORIZATION_WRITER
139
+ };
140
+ const getUserRoute = {
141
+ operationId: "authenticationAdminGetUser",
142
+ summary: "Get existing user",
143
+ tag: tagsAuthenticationAdmin[0].name,
144
+ method: "GET",
145
+ path: `${baseRouteName}/users/:email`,
146
+ handler: async (httpRequestContext, request) => authenticationAdminGetUser(httpRequestContext, componentName, request),
147
+ requestType: {
148
+ type: "IAdminUserGetRequest",
149
+ examples: [
150
+ {
151
+ id: "getUserRequestExample",
152
+ description: "The request to get an existing user.",
153
+ request: {
154
+ pathParams: {
155
+ email: "user@example.com"
156
+ }
157
+ }
158
+ }
159
+ ]
160
+ },
161
+ responseType: [
162
+ {
163
+ type: "IAdminUserGetResponse",
164
+ examples: [
165
+ {
166
+ id: "getUserResponseExample",
167
+ description: "The response to get an existing user.",
168
+ response: {
169
+ body: {
170
+ email: "user@example.com",
171
+ userIdentity: "did:example:123456789abcdefghi",
172
+ organizationIdentity: "did:example:123456789abcdefghi"
173
+ }
174
+ }
175
+ }
176
+ ]
177
+ },
178
+ {
179
+ type: "IUnauthorizedResponse"
180
+ }
181
+ ],
182
+ defaultAuthorization: DEFAULT_AUTHORIZATION_READER
183
+ };
184
+ const getByIdentityUserRoute = {
185
+ operationId: "authenticationAdminGetByIdentityUser",
186
+ summary: "Get existing user by identity",
187
+ tag: tagsAuthenticationAdmin[0].name,
188
+ method: "GET",
189
+ path: `${baseRouteName}/users/identity/:identity`,
190
+ handler: async (httpRequestContext, request) => authenticationAdminGetUserByIdentity(httpRequestContext, componentName, request),
191
+ requestType: {
192
+ type: "IAdminUserGetByIdentityRequest",
193
+ examples: [
194
+ {
195
+ id: "getUserByIdentityRequestExample",
196
+ description: "The request to get an existing user by identity.",
197
+ request: {
198
+ pathParams: {
199
+ identity: "did:example:123456789abcdefghi"
200
+ }
201
+ }
202
+ }
203
+ ]
204
+ },
205
+ responseType: [
206
+ {
207
+ type: "IAdminUserGetResponse",
208
+ examples: [
209
+ {
210
+ id: "getUserResponseExample",
211
+ description: "The response to get an existing user.",
212
+ response: {
213
+ body: {
214
+ email: "user@example.com",
215
+ userIdentity: "did:example:123456789abcdefghi",
216
+ organizationIdentity: "did:example:123456789abcdefghi"
217
+ }
218
+ }
219
+ }
220
+ ]
221
+ },
222
+ {
223
+ type: "IUnauthorizedResponse"
224
+ }
225
+ ],
226
+ defaultAuthorization: DEFAULT_AUTHORIZATION_READER
227
+ };
228
+ const removeUserRoute = {
229
+ operationId: "authenticationAdminRemoveUser",
230
+ summary: "Remove existing user",
231
+ tag: tagsAuthenticationAdmin[0].name,
232
+ method: "DELETE",
233
+ path: `${baseRouteName}/users/:email`,
234
+ handler: async (httpRequestContext, request) => authenticationAdminRemoveUser(httpRequestContext, componentName, request),
235
+ requestType: {
236
+ type: "IAdminUserRemoveRequest",
237
+ examples: [
238
+ {
239
+ id: "removeUserRequestExample",
240
+ description: "The request to remove an existing user.",
241
+ request: {
242
+ pathParams: {
243
+ email: "user@example.com"
244
+ }
245
+ }
246
+ }
247
+ ]
248
+ },
249
+ responseType: [
250
+ {
251
+ type: "INoContentResponse"
252
+ },
253
+ {
254
+ type: "IUnauthorizedResponse"
255
+ }
256
+ ],
257
+ defaultAuthorization: DEFAULT_AUTHORIZATION_WRITER
258
+ };
259
+ return [
260
+ createUserRoute,
261
+ updateUserRoute,
262
+ updateUserPasswordRoute,
263
+ getUserRoute,
264
+ getByIdentityUserRoute,
265
+ removeUserRoute
266
+ ];
267
+ }
268
+ /**
269
+ * Create a new user.
270
+ * @param httpRequestContext The request context for the API.
271
+ * @param componentName The name of the component to use in the routes.
272
+ * @param request The request.
273
+ * @param baseRouteName The base route name to use for the location header.
274
+ * @returns The response object with additional http response properties.
275
+ */
276
+ export async function authenticationAdminCreateUser(httpRequestContext, componentName, request, baseRouteName) {
277
+ Guards.object(ROUTES_SOURCE, "request", request);
278
+ Guards.object(ROUTES_SOURCE, "request.body", request.body);
279
+ const component = ComponentFactory.get(componentName);
280
+ await component.create(request.body);
281
+ const contextIds = await ContextIdStore.getContextIds();
282
+ const publicOrigin = contextIds?.[HttpContextIdKeys.PublicOrigin];
283
+ const headers = {};
284
+ HttpHeaderHelper.buildId(headers, request.body.email, HttpUrlHelper.combineOriginPath(publicOrigin, `${baseRouteName}/users/:id`));
285
+ return {
286
+ statusCode: HttpStatusCode.created,
287
+ headers
288
+ };
289
+ }
290
+ /**
291
+ * Update an existing user.
292
+ * @param httpRequestContext The request context for the API.
293
+ * @param componentName The name of the component to use in the routes.
294
+ * @param request The request.
295
+ * @returns The response object with additional http response properties.
296
+ */
297
+ export async function authenticationAdminUpdateUser(httpRequestContext, componentName, request) {
298
+ Guards.object(ROUTES_SOURCE, "request", request);
299
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
300
+ Guards.object(ROUTES_SOURCE, "request.body", request.body);
301
+ const component = ComponentFactory.get(componentName);
302
+ await component.update({
303
+ ...request.body,
304
+ email: request.pathParams.email
305
+ });
306
+ return {
307
+ statusCode: HttpStatusCode.noContent
308
+ };
309
+ }
310
+ /**
311
+ * Update an existing user password.
312
+ * @param httpRequestContext The request context for the API.
313
+ * @param componentName The name of the component to use in the routes.
314
+ * @param request The request.
315
+ * @returns The response object with additional http response properties.
316
+ */
317
+ export async function authenticationAdminUpdateUserPassword(httpRequestContext, componentName, request) {
318
+ Guards.object(ROUTES_SOURCE, "request", request);
319
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
320
+ Guards.object(ROUTES_SOURCE, "request.body", request.body);
321
+ const component = ComponentFactory.get(componentName);
322
+ await component.updatePassword(request.pathParams.email, request.body.newPassword);
323
+ return {
324
+ statusCode: HttpStatusCode.noContent
325
+ };
326
+ }
327
+ /**
328
+ * Get an existing user.
329
+ * @param httpRequestContext The request context for the API.
330
+ * @param componentName The name of the component to use in the routes.
331
+ * @param request The request.
332
+ * @returns The response object with additional http response properties.
333
+ */
334
+ export async function authenticationAdminGetUser(httpRequestContext, componentName, request) {
335
+ Guards.object(ROUTES_SOURCE, "request", request);
336
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
337
+ const component = ComponentFactory.get(componentName);
338
+ const result = await component.get(request.pathParams.email);
339
+ return {
340
+ body: result
341
+ };
342
+ }
343
+ /**
344
+ * Get an existing user by identity.
345
+ * @param httpRequestContext The request context for the API.
346
+ * @param componentName The name of the component to use in the routes.
347
+ * @param request The request.
348
+ * @returns The response object with additional http response properties.
349
+ */
350
+ export async function authenticationAdminGetUserByIdentity(httpRequestContext, componentName, request) {
351
+ Guards.object(ROUTES_SOURCE, "request", request);
352
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
353
+ const component = ComponentFactory.get(componentName);
354
+ const result = await component.getByIdentity(request.pathParams.identity);
355
+ return {
356
+ body: result
357
+ };
358
+ }
359
+ /**
360
+ * Remove an existing user.
361
+ * @param httpRequestContext The request context for the API.
362
+ * @param componentName The name of the component to use in the routes.
363
+ * @param request The request.
364
+ * @returns The response object with additional http response properties.
365
+ */
366
+ export async function authenticationAdminRemoveUser(httpRequestContext, componentName, request) {
367
+ Guards.object(ROUTES_SOURCE, "request", request);
368
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
369
+ const component = ComponentFactory.get(componentName);
370
+ await component.remove(request.pathParams.email);
371
+ return {
372
+ statusCode: HttpStatusCode.noContent
373
+ };
374
+ }
375
+ //# sourceMappingURL=entityStorageAuthenticationAdminRoutes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entityStorageAuthenticationAdminRoutes.js","sources":["../../../src/routes/entityStorageAuthenticationAdminRoutes.ts"],"names":[],"mappings":"AAYA,OAAO,EACN,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EAQb,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,4BAA4B,GAAwB;IACzD,UAAU,EAAE,iBAAiB;IAC7B,IAAI,EAAE,YAAY;CAClB,CAAC;AACF,MAAM,4BAA4B,GAAwB;IACzD,UAAU,EAAE,kBAAkB;IAC9B,IAAI,EAAE,YAAY;IAClB,QAAQ,EAAE,CAAC,4BAA4B,CAAC,UAAU,CAAC;CACnD,CAAC;AACF;;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,EAAE,aAAa,CAAC;QACzF,WAAW,EAAE;YACZ,IAAI,EAAE,yBAAyB;YAC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,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,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAC1E,MAAM,CAAC,MAAM,CACZ,aAAa,EACb,oBAAoB,EACpB,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 IRouteAuthorization,\n\ttype ITag,\n\ttype IUnauthorizedResponse\n} from \"@3sixty/api-models\";\nimport { ContextIdStore } from \"@3sixty/context\";\nimport { ComponentFactory, Guards } from \"@3sixty/core\";\n\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 default authorization for the routes, used to seed authorization rules.\n */\nconst DEFAULT_AUTHORIZATION_READER: IRouteAuthorization = {\n\tpermission: \"user-admin:read\",\n\trole: \"user-admin\"\n};\nconst DEFAULT_AUTHORIZATION_WRITER: IRouteAuthorization = {\n\tpermission: \"user-admin:write\",\n\trole: \"user-admin\",\n\tinherits: [DEFAULT_AUTHORIZATION_READER.permission]\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: \"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}\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: \"INoContentResponse\"\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: \"IUnauthorizedResponse\"\n\t\t\t}\n\t\t],\n\t\tdefaultAuthorization: DEFAULT_AUTHORIZATION_WRITER\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: \"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}\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: \"INoContentResponse\"\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: \"IUnauthorizedResponse\"\n\t\t\t}\n\t\t],\n\t\tdefaultAuthorization: DEFAULT_AUTHORIZATION_WRITER\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: \"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: \"INoContentResponse\"\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: \"IUnauthorizedResponse\"\n\t\t\t}\n\t\t],\n\t\tdefaultAuthorization: DEFAULT_AUTHORIZATION_WRITER\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: \"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: \"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}\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: \"IUnauthorizedResponse\"\n\t\t\t}\n\t\t],\n\t\tdefaultAuthorization: DEFAULT_AUTHORIZATION_READER\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: \"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: \"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}\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: \"IUnauthorizedResponse\"\n\t\t\t\t}\n\t\t\t],\n\t\t\tdefaultAuthorization: DEFAULT_AUTHORIZATION_READER\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: \"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: \"INoContentResponse\"\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: \"IUnauthorizedResponse\"\n\t\t\t}\n\t\t],\n\t\tdefaultAuthorization: DEFAULT_AUTHORIZATION_WRITER\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, \"request\", request);\n\tGuards.object<IAdminUserCreateRequest[\"body\"]>(ROUTES_SOURCE, \"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, \"request\", request);\n\tGuards.object<IAdminUserUpdateRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\t\"request.pathParams\",\n\t\trequest.pathParams\n\t);\n\tGuards.object<IAdminUserUpdateRequest[\"body\"]>(ROUTES_SOURCE, \"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, \"request\", request);\n\tGuards.object<IAdminUserUpdatePasswordRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\t\"request.pathParams\",\n\t\trequest.pathParams\n\t);\n\tGuards.object<IAdminUserUpdatePasswordRequest[\"body\"]>(\n\t\tROUTES_SOURCE,\n\t\t\"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, \"request\", request);\n\tGuards.object<IAdminUserGetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\t\"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, \"request\", request);\n\tGuards.object<IAdminUserGetByIdentityRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\t\"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, \"request\", request);\n\tGuards.object<IAdminUserRemoveRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\t\"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"]}