@3sixty/api-auth-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 (73) 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/index.js +17 -0
  8. package/dist/es/index.js.map +1 -0
  9. package/dist/es/models/IEntityStorageAuthenticationAuditServiceConfig.js +4 -0
  10. package/dist/es/models/IEntityStorageAuthenticationAuditServiceConfig.js.map +1 -0
  11. package/dist/es/models/IEntityStorageAuthenticationAuditServiceConstructorOptions.js +2 -0
  12. package/dist/es/models/IEntityStorageAuthenticationAuditServiceConstructorOptions.js.map +1 -0
  13. package/dist/es/models/IEntityStorageAuthenticationRateServiceConfig.js +2 -0
  14. package/dist/es/models/IEntityStorageAuthenticationRateServiceConfig.js.map +1 -0
  15. package/dist/es/models/IEntityStorageAuthenticationRateServiceConstructorOptions.js +2 -0
  16. package/dist/es/models/IEntityStorageAuthenticationRateServiceConstructorOptions.js.map +1 -0
  17. package/dist/es/models/ITenantOverrideProcessorConfig.js +4 -0
  18. package/dist/es/models/ITenantOverrideProcessorConfig.js.map +1 -0
  19. package/dist/es/models/ITenantOverrideProcessorConstructorOptions.js +2 -0
  20. package/dist/es/models/ITenantOverrideProcessorConstructorOptions.js.map +1 -0
  21. package/dist/es/processors/tenantOverrideProcessor.js +144 -0
  22. package/dist/es/processors/tenantOverrideProcessor.js.map +1 -0
  23. package/dist/es/restEntryPoints.js +13 -0
  24. package/dist/es/restEntryPoints.js.map +1 -0
  25. package/dist/es/routes/entityStorageAuthenticationAuditRoutes.js +355 -0
  26. package/dist/es/routes/entityStorageAuthenticationAuditRoutes.js.map +1 -0
  27. package/dist/es/schema.js +13 -0
  28. package/dist/es/schema.js.map +1 -0
  29. package/dist/es/services/entityStorageAuthenticationAuditService.js +240 -0
  30. package/dist/es/services/entityStorageAuthenticationAuditService.js.map +1 -0
  31. package/dist/es/services/entityStorageAuthenticationRateService.js +213 -0
  32. package/dist/es/services/entityStorageAuthenticationRateService.js.map +1 -0
  33. package/dist/types/entities/authenticationAuditEntry.d.ts +49 -0
  34. package/dist/types/entities/authenticationRateEntry.d.ts +17 -0
  35. package/dist/types/index.d.ts +14 -0
  36. package/dist/types/models/IEntityStorageAuthenticationAuditServiceConfig.d.ts +9 -0
  37. package/dist/types/models/IEntityStorageAuthenticationAuditServiceConstructorOptions.d.ts +15 -0
  38. package/dist/types/models/IEntityStorageAuthenticationRateServiceConfig.d.ts +10 -0
  39. package/dist/types/models/IEntityStorageAuthenticationRateServiceConstructorOptions.d.ts +25 -0
  40. package/dist/types/models/ITenantOverrideProcessorConfig.d.ts +19 -0
  41. package/dist/types/models/ITenantOverrideProcessorConstructorOptions.d.ts +20 -0
  42. package/dist/types/processors/tenantOverrideProcessor.d.ts +48 -0
  43. package/dist/types/restEntryPoints.d.ts +5 -0
  44. package/dist/types/routes/entityStorageAuthenticationAuditRoutes.d.ts +54 -0
  45. package/dist/types/schema.d.ts +4 -0
  46. package/dist/types/services/entityStorageAuthenticationAuditService.d.ts +72 -0
  47. package/dist/types/services/entityStorageAuthenticationRateService.d.ts +60 -0
  48. package/docs/changelog.md +1633 -0
  49. package/docs/examples.md +137 -0
  50. package/docs/open-api/spec.json +911 -0
  51. package/docs/reference/classes/AuthenticationAuditEntry.md +101 -0
  52. package/docs/reference/classes/AuthenticationRateEntry.md +37 -0
  53. package/docs/reference/classes/EntityStorageAuthenticationAuditService.md +241 -0
  54. package/docs/reference/classes/EntityStorageAuthenticationRateService.md +227 -0
  55. package/docs/reference/classes/TenantOverrideProcessor.md +129 -0
  56. package/docs/reference/functions/authenticationAuditCreate.md +37 -0
  57. package/docs/reference/functions/authenticationAuditGet.md +31 -0
  58. package/docs/reference/functions/authenticationAuditQuery.md +31 -0
  59. package/docs/reference/functions/authenticationAuditRemove.md +31 -0
  60. package/docs/reference/functions/authenticationAuditUpdate.md +31 -0
  61. package/docs/reference/functions/generateRestRoutesAuthenticationAudit.md +25 -0
  62. package/docs/reference/functions/initSchema.md +9 -0
  63. package/docs/reference/index.md +33 -0
  64. package/docs/reference/interfaces/IEntityStorageAuthenticationAuditServiceConfig.md +11 -0
  65. package/docs/reference/interfaces/IEntityStorageAuthenticationAuditServiceConstructorOptions.md +25 -0
  66. package/docs/reference/interfaces/IEntityStorageAuthenticationRateServiceConfig.md +17 -0
  67. package/docs/reference/interfaces/IEntityStorageAuthenticationRateServiceConstructorOptions.md +53 -0
  68. package/docs/reference/interfaces/ITenantOverrideProcessorConfig.md +39 -0
  69. package/docs/reference/interfaces/ITenantOverrideProcessorConstructorOptions.md +39 -0
  70. package/docs/reference/variables/restEntryPoints.md +5 -0
  71. package/docs/reference/variables/tagsAuthenticationAudit.md +5 -0
  72. package/locales/en.json +22 -0
  73. package/package.json +62 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tenantOverrideProcessor.js","sources":["../../../src/processors/tenantOverrideProcessor.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,cAAc,EACd,iBAAiB,EACjB,eAAe,EAOf,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,aAAa,EAAoB,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE1F,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C;;;;GAIG;AACH,MAAM,OAAO,uBAAuB;IACnC;;OAEG;IACI,MAAM,CAAU,qBAAqB,GAAW,iBAAiB,CAAC;IAEzE;;OAEG;IACI,MAAM,CAAU,8BAA8B,GAAW,QAAQ,CAAC;IA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AAa,CAAC,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACzF,CAAC;IACF,CAAC;IAED;;;;;OAKG;IACK,KAAK,CAAC,kBAAkB,CAAC,QAAgB;QAChD,IAAI,MAAe,CAAC;QAEpB,IAAI,CAAC;YACJ,MAAM,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,qFAAqF;YACrF,yDAAyD;YACzD,IACC,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,aAAa,CAAC,UAAU,CAAC;gBACpD,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,UAAU,CAAC,UAAU,CAAC,EAChD,CAAC;gBACF,MAAM,IAAI,aAAa,CACtB,uBAAuB,CAAC,UAAU,EAClC,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,GAAG,CACH,CAAC;YACH,CAAC;YACD,MAAM,GAAG,CAAC;QACX,CAAC;QAED,IAAI,MAAM,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;YAC5B,MAAM,IAAI,aAAa,CAAC,uBAAuB,CAAC,UAAU,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QACzF,CAAC;IACF,CAAC;CACD","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tForbiddenError,\n\tHttpContextIdKeys,\n\tHttpErrorHelper,\n\ttype IBaseRoute,\n\ttype IBaseRouteProcessor,\n\ttype IHttpResponse,\n\ttype IHttpServerRequest,\n\ttype ITenant,\n\ttype ITenantAdminComponent\n} from \"@3sixty/api-models\";\nimport type { IAuthorizationComponent } from \"@3sixty/authorization-models\";\nimport { ContextIdKeys, type IContextIds } from \"@3sixty/context\";\nimport { BaseError, ComponentFactory, GuardError, Is, NotFoundError } from \"@3sixty/core\";\n\nimport { HttpStatusCode } from \"@3sixty/web\";\nimport type { ITenantOverrideProcessorConstructorOptions } from \"../models/ITenantOverrideProcessorConstructorOptions.js\";\n\n/**\n * Processes the overrideTenant query parameter for routes that allow tenant override.\n * Requires the caller to hold the escalated privilege role. Runs after AuthHeaderProcessor so\n * authentication is always resolved in the caller's own partition first.\n */\nexport class TenantOverrideProcessor implements IBaseRouteProcessor {\n\t/**\n\t * The query parameter name used to supply the override tenant ID.\n\t */\n\tpublic static readonly OVERRIDE_TENANT_PARAM: string = \"override-tenant\";\n\n\t/**\n\t * The model identifier that is reserved for system-only use.\n\t */\n\tpublic static readonly DEFAULT_AUTHORIZATION_MODEL_ID: string = \"system\";\n\n\t/**\n\t * The role string required to perform a tenant override.\n\t */\n\tpublic static readonly DEFAULT_ESCALATED_PRIVILEGE_ROLE: string = \"global-admin\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = \"TenantOverrideProcessor\";\n\n\t/**\n\t * The component used to resolve tenants.\n\t * @internal\n\t */\n\tprivate readonly _tenantAdminComponent: ITenantAdminComponent;\n\n\t/**\n\t * The authorization component for checking authorization roles.\n\t * @internal\n\t */\n\tprivate readonly _authorizationComponent: IAuthorizationComponent;\n\n\t/**\n\t * Include the stack with errors.\n\t * @internal\n\t */\n\tprivate readonly _includeErrorStack: boolean;\n\n\t/**\n\t * The role value that grants cross-tenant access.\n\t * @internal\n\t */\n\tprivate readonly _escalatedPrivilegeRole: string;\n\n\t/**\n\t * The authorization model ID to use for REST requests.\n\t * @internal\n\t */\n\tprivate readonly _authorizationModelId: string;\n\n\t/**\n\t * Create a new instance of TenantOverrideProcessor.\n\t * @param options Options for the processor.\n\t */\n\tconstructor(options?: ITenantOverrideProcessorConstructorOptions) {\n\t\tthis._tenantAdminComponent = ComponentFactory.get<ITenantAdminComponent>(\n\t\t\toptions?.tenantAdminComponentType ?? \"tenant-admin\"\n\t\t);\n\t\tthis._authorizationComponent = ComponentFactory.get(\n\t\t\toptions?.authorizationComponentType ?? \"authorization\"\n\t\t);\n\t\tthis._includeErrorStack = options?.config?.includeErrorStack ?? false;\n\t\tthis._escalatedPrivilegeRole =\n\t\t\toptions?.config?.escalatedPrivilegeRole ??\n\t\t\tTenantOverrideProcessor.DEFAULT_ESCALATED_PRIVILEGE_ROLE;\n\t\tthis._authorizationModelId =\n\t\t\toptions?.config?.authorizationModelId ??\n\t\t\tTenantOverrideProcessor.DEFAULT_AUTHORIZATION_MODEL_ID;\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn TenantOverrideProcessor.CLASS_NAME;\n\t}\n\n\t/**\n\t * Pre process the REST request for the specified route.\n\t * @param request The incoming request.\n\t * @param response The outgoing response.\n\t * @param route The route to process.\n\t * @param contextIds The context IDs of the request.\n\t * @param processorState The state handed through the processors.\n\t * @returns A promise that resolves when the tenant override has been applied or skipped.\n\t */\n\tpublic async pre(\n\t\trequest: IHttpServerRequest,\n\t\tresponse: IHttpResponse,\n\t\troute: IBaseRoute | undefined,\n\t\tcontextIds: IContextIds,\n\t\tprocessorState: { [id: string]: unknown }\n\t): Promise<void> {\n\t\tif (Is.empty(route) || (route.disableTenantOverride ?? false)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst overrideTenantParam = request.query?.[TenantOverrideProcessor.OVERRIDE_TENANT_PARAM];\n\t\tif (!Is.stringValue(overrideTenantParam)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If a prior processor already set an error response, skip processing.\n\t\tif (Is.notEmpty(response.statusCode) && response.statusCode >= HttpStatusCode.badRequest) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst userId = contextIds[ContextIdKeys.User];\n\t\t\tif (!Is.stringValue(userId)) {\n\t\t\t\tthrow new ForbiddenError(\n\t\t\t\t\tTenantOverrideProcessor.CLASS_NAME,\n\t\t\t\t\t\"missingUserIdForTenantOverride\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Role must be directly assigned to the user, not inherited through a group or other means.\n\t\t\tconst hasRole = await this._authorizationComponent.hasRoleForSubject(\n\t\t\t\tthis._authorizationModelId,\n\t\t\t\tuserId,\n\t\t\t\tthis._escalatedPrivilegeRole\n\t\t\t);\n\n\t\t\t// Caller must hold the escalated privilege role.\n\t\t\tif (!hasRole) {\n\t\t\t\tthrow new ForbiddenError(\n\t\t\t\t\tTenantOverrideProcessor.CLASS_NAME,\n\t\t\t\t\t\"insufficientRoleForTenantOverride\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Verify the tenant exists before substituting.\n\t\t\tawait this.verifyTenantExists(overrideTenantParam);\n\n\t\t\tcontextIds[HttpContextIdKeys.OriginalTenant] = contextIds[ContextIdKeys.Tenant];\n\t\t\tcontextIds[ContextIdKeys.Tenant] = overrideTenantParam;\n\t\t} catch (err) {\n\t\t\tconst error = BaseError.fromError(err);\n\t\t\tconst { httpStatusCode } = HttpErrorHelper.processError(error);\n\t\t\tHttpErrorHelper.buildResponse(response, error, httpStatusCode, this._includeErrorStack);\n\t\t}\n\t}\n\n\t/**\n\t * Confirm the tenant being switched to exists.\n\t * @param tenantId The tenant id from the override query parameter.\n\t * @throws NotFoundError if no tenant matches the id.\n\t * @internal\n\t */\n\tprivate async verifyTenantExists(tenantId: string): Promise<void> {\n\t\tlet tenant: ITenant;\n\n\t\ttry {\n\t\t\ttenant = await this._tenantAdminComponent.get(tenantId);\n\t\t} catch (err) {\n\t\t\t// An id that matches no tenant, or is not even well formed, is a not found; anything\n\t\t\t// else is a genuine fault and keeps its own status code.\n\t\t\tif (\n\t\t\t\tBaseError.isErrorName(err, NotFoundError.CLASS_NAME) ||\n\t\t\t\tBaseError.isErrorName(err, GuardError.CLASS_NAME)\n\t\t\t) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tTenantOverrideProcessor.CLASS_NAME,\n\t\t\t\t\t\"tenantNotFound\",\n\t\t\t\t\ttenantId,\n\t\t\t\t\tundefined,\n\t\t\t\t\terr\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow err;\n\t\t}\n\n\t\tif (tenant.id !== tenantId) {\n\t\t\tthrow new NotFoundError(TenantOverrideProcessor.CLASS_NAME, \"tenantNotFound\", tenantId);\n\t\t}\n\t}\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { generateRestRoutesAuthenticationAudit, tagsAuthenticationAudit } from "./routes/entityStorageAuthenticationAuditRoutes.js";
2
+ /**
3
+ * REST entry points for the authentication audit service.
4
+ */
5
+ export const restEntryPoints = [
6
+ {
7
+ name: "authenticationAudit",
8
+ defaultBaseRoute: "authentication/audit",
9
+ tags: tagsAuthenticationAudit,
10
+ generateRoutes: generateRestRoutesAuthenticationAudit
11
+ }
12
+ ];
13
+ //# sourceMappingURL=restEntryPoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restEntryPoints.js","sources":["../../src/restEntryPoints.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,qCAAqC,EACrC,uBAAuB,EACvB,MAAM,oDAAoD,CAAC;AAE5D;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAA2B;IACtD;QACC,IAAI,EAAE,qBAAqB;QAC3B,gBAAgB,EAAE,sBAAsB;QACxC,IAAI,EAAE,uBAAuB;QAC7B,cAAc,EAAE,qCAAqC;KACrD;CACD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IRestRouteEntryPoint } from \"@3sixty/api-models\";\nimport {\n\tgenerateRestRoutesAuthenticationAudit,\n\ttagsAuthenticationAudit\n} from \"./routes/entityStorageAuthenticationAuditRoutes.js\";\n\n/**\n * REST entry points for the authentication audit service.\n */\nexport const restEntryPoints: IRestRouteEntryPoint[] = [\n\t{\n\t\tname: \"authenticationAudit\",\n\t\tdefaultBaseRoute: \"authentication/audit\",\n\t\ttags: tagsAuthenticationAudit,\n\t\tgenerateRoutes: generateRestRoutesAuthenticationAudit\n\t}\n];\n"]}
@@ -0,0 +1,355 @@
1
+ import { HttpContextIdKeys, HttpHeaderHelper, HttpUrlHelper } from "@3sixty/api-models";
2
+ import { ContextIdStore } from "@3sixty/context";
3
+ import { Coerce, ComponentFactory, Guards } from "@3sixty/core";
4
+ import { HeaderTypes, HttpStatusCode } from "@3sixty/web";
5
+ /**
6
+ * The source used when communicating about these routes.
7
+ */
8
+ const ROUTES_SOURCE = "authenticationAuditRoutes";
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 tagsAuthenticationAudit = [
25
+ {
26
+ name: "Authentication Audit",
27
+ description: "Authentication audit endpoints for the REST server."
28
+ }
29
+ ];
30
+ /**
31
+ * The REST routes for authentication audit.
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 generateRestRoutesAuthenticationAudit(baseRouteName, componentName) {
37
+ const createRoute = {
38
+ operationId: "authenticationAuditCreate",
39
+ summary: "Create an authentication audit entry",
40
+ tag: tagsAuthenticationAudit[0].name,
41
+ method: "POST",
42
+ path: `${baseRouteName}`,
43
+ handler: async (httpRequestContext, request) => authenticationAuditCreate(httpRequestContext, componentName, request, baseRouteName),
44
+ requestType: {
45
+ type: "IAuditCreateRequest",
46
+ examples: [
47
+ {
48
+ id: "authenticationAuditCreateRequestExample",
49
+ description: "The request to create an authentication audit entry.",
50
+ request: {
51
+ body: {
52
+ actorId: "user@example.com",
53
+ event: "login-success",
54
+ data: {
55
+ organizationIdentity: "did:example:org1"
56
+ }
57
+ }
58
+ }
59
+ }
60
+ ]
61
+ },
62
+ responseType: [
63
+ {
64
+ type: "ICreatedResponse",
65
+ examples: [
66
+ {
67
+ id: "authenticationAuditCreateResponseExample",
68
+ description: "The response for creating an authentication audit entry.",
69
+ response: {
70
+ statusCode: 201,
71
+ headers: {
72
+ [HeaderTypes.Location]: "018f0b53d5d5704fa3a06d6ed2478575"
73
+ }
74
+ }
75
+ }
76
+ ]
77
+ },
78
+ {
79
+ type: "IUnauthorizedResponse"
80
+ }
81
+ ],
82
+ defaultAuthorization: DEFAULT_AUTHORIZATION_WRITER
83
+ };
84
+ const getRoute = {
85
+ operationId: "authenticationAuditGet",
86
+ summary: "Get an authentication audit entry",
87
+ tag: tagsAuthenticationAudit[0].name,
88
+ method: "GET",
89
+ path: `${baseRouteName}/:id`,
90
+ handler: async (httpRequestContext, request) => authenticationAuditGet(httpRequestContext, componentName, request),
91
+ requestType: {
92
+ type: "IAuditGetRequest",
93
+ examples: [
94
+ {
95
+ id: "authenticationAuditGetRequestExample",
96
+ description: "The request to get an authentication audit entry.",
97
+ request: {
98
+ pathParams: {
99
+ id: "018f0b53d5d5704fa3a06d6ed2478575"
100
+ }
101
+ }
102
+ }
103
+ ]
104
+ },
105
+ responseType: [
106
+ {
107
+ type: "IAuditGetResponse",
108
+ examples: [
109
+ {
110
+ id: "authenticationAuditGetResponseExample",
111
+ description: "The response for getting an authentication audit entry.",
112
+ response: {
113
+ body: {
114
+ id: "018f0b53d5d5704fa3a06d6ed2478575",
115
+ actorId: "user@example.com",
116
+ dateCreated: "2026-01-12T09:05:23.123Z",
117
+ event: "login-success",
118
+ data: {
119
+ organizationIdentity: "did:example:org1"
120
+ }
121
+ }
122
+ }
123
+ }
124
+ ]
125
+ },
126
+ {
127
+ type: "IUnauthorizedResponse"
128
+ }
129
+ ],
130
+ defaultAuthorization: DEFAULT_AUTHORIZATION_READER
131
+ };
132
+ const updateRoute = {
133
+ operationId: "authenticationAuditUpdate",
134
+ summary: "Update an authentication audit entry",
135
+ tag: tagsAuthenticationAudit[0].name,
136
+ method: "PUT",
137
+ path: `${baseRouteName}/:id`,
138
+ handler: async (httpRequestContext, request) => authenticationAuditUpdate(httpRequestContext, componentName, request),
139
+ requestType: {
140
+ type: "IAuditUpdateRequest",
141
+ examples: [
142
+ {
143
+ id: "authenticationAuditUpdateRequestExample",
144
+ description: "The request to update an authentication audit entry.",
145
+ request: {
146
+ pathParams: {
147
+ id: "018f0b53d5d5704fa3a06d6ed2478575"
148
+ },
149
+ body: {
150
+ data: {
151
+ organizationIdentity: "did:example:org1"
152
+ }
153
+ }
154
+ }
155
+ }
156
+ ]
157
+ },
158
+ responseType: [
159
+ {
160
+ type: "INoContentResponse"
161
+ },
162
+ {
163
+ type: "IUnauthorizedResponse"
164
+ }
165
+ ],
166
+ defaultAuthorization: DEFAULT_AUTHORIZATION_WRITER
167
+ };
168
+ const removeRoute = {
169
+ operationId: "authenticationAuditRemove",
170
+ summary: "Remove an authentication audit entry",
171
+ tag: tagsAuthenticationAudit[0].name,
172
+ method: "DELETE",
173
+ path: `${baseRouteName}/:id`,
174
+ handler: async (httpRequestContext, request) => authenticationAuditRemove(httpRequestContext, componentName, request),
175
+ requestType: {
176
+ type: "IAuditRemoveRequest",
177
+ examples: [
178
+ {
179
+ id: "authenticationAuditRemoveRequestExample",
180
+ description: "The request to remove an authentication audit entry.",
181
+ request: {
182
+ pathParams: {
183
+ id: "018f0b53d5d5704fa3a06d6ed2478575"
184
+ }
185
+ }
186
+ }
187
+ ]
188
+ },
189
+ responseType: [
190
+ {
191
+ type: "INoContentResponse"
192
+ },
193
+ {
194
+ type: "IUnauthorizedResponse"
195
+ }
196
+ ],
197
+ defaultAuthorization: DEFAULT_AUTHORIZATION_WRITER
198
+ };
199
+ const queryRoute = {
200
+ operationId: "authenticationAuditQuery",
201
+ summary: "Query authentication audit entries",
202
+ tag: tagsAuthenticationAudit[0].name,
203
+ method: "GET",
204
+ path: `${baseRouteName}`,
205
+ handler: async (httpRequestContext, request) => authenticationAuditQuery(httpRequestContext, componentName, request),
206
+ requestType: {
207
+ type: "IAuditQueryRequest",
208
+ examples: [
209
+ {
210
+ id: "authenticationAuditQueryRequestExample",
211
+ description: "The request to query authentication audit entries.",
212
+ request: {
213
+ query: {
214
+ actorId: "user@example.com",
215
+ event: "login-success",
216
+ startDate: "2026-01-01T00:00:00.000Z",
217
+ endDate: "2026-01-31T23:59:59.999Z",
218
+ limit: "50"
219
+ }
220
+ }
221
+ }
222
+ ]
223
+ },
224
+ responseType: [
225
+ {
226
+ type: "IAuditQueryResponse",
227
+ examples: [
228
+ {
229
+ id: "authenticationAuditQueryResponseExample",
230
+ description: "The response for querying authentication audit entries.",
231
+ response: {
232
+ body: {
233
+ entries: [
234
+ {
235
+ id: "018f0b53d5d5704fa3a06d6ed2478575",
236
+ actorId: "user@example.com",
237
+ dateCreated: "2026-01-12T09:05:23.123Z",
238
+ event: "login-success",
239
+ data: {
240
+ organizationIdentity: "did:example:org1"
241
+ }
242
+ }
243
+ ],
244
+ cursor: "next-cursor"
245
+ }
246
+ }
247
+ }
248
+ ]
249
+ },
250
+ {
251
+ type: "IUnauthorizedResponse"
252
+ }
253
+ ],
254
+ defaultAuthorization: DEFAULT_AUTHORIZATION_READER
255
+ };
256
+ return [createRoute, getRoute, updateRoute, removeRoute, queryRoute];
257
+ }
258
+ /**
259
+ * Create an authentication audit entry.
260
+ * @param httpRequestContext The request context for the API.
261
+ * @param componentName The name of the component to use in the routes.
262
+ * @param request The request.
263
+ * @param baseRouteName The base route name to use for the location header.
264
+ * @returns The response object with additional http response properties.
265
+ */
266
+ export async function authenticationAuditCreate(httpRequestContext, componentName, request, baseRouteName) {
267
+ Guards.object(ROUTES_SOURCE, "request", request);
268
+ Guards.object(ROUTES_SOURCE, "request.body", request.body);
269
+ const component = ComponentFactory.get(componentName);
270
+ const id = await component.create(request.body);
271
+ const contextIds = await ContextIdStore.getContextIds();
272
+ const publicOrigin = contextIds?.[HttpContextIdKeys.PublicOrigin];
273
+ const headers = {};
274
+ HttpHeaderHelper.buildId(headers, id, HttpUrlHelper.combineOriginPath(publicOrigin, `${baseRouteName}/:id`));
275
+ return {
276
+ statusCode: HttpStatusCode.created,
277
+ headers
278
+ };
279
+ }
280
+ /**
281
+ * Get an authentication audit entry.
282
+ * @param httpRequestContext The request context for the API.
283
+ * @param componentName The name of the component to use in the routes.
284
+ * @param request The request.
285
+ * @returns The response object with additional http response properties.
286
+ */
287
+ export async function authenticationAuditGet(httpRequestContext, componentName, request) {
288
+ Guards.object(ROUTES_SOURCE, "request", request);
289
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
290
+ const component = ComponentFactory.get(componentName);
291
+ const entry = await component.get(request.pathParams.id);
292
+ return {
293
+ body: entry
294
+ };
295
+ }
296
+ /**
297
+ * Update an authentication audit entry.
298
+ * @param httpRequestContext The request context for the API.
299
+ * @param componentName The name of the component to use in the routes.
300
+ * @param request The request.
301
+ * @returns The response object with additional http response properties.
302
+ */
303
+ export async function authenticationAuditUpdate(httpRequestContext, componentName, request) {
304
+ Guards.object(ROUTES_SOURCE, "request", request);
305
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
306
+ Guards.object(ROUTES_SOURCE, "request.body", request.body);
307
+ const component = ComponentFactory.get(componentName);
308
+ await component.update(request.pathParams.id, request.body);
309
+ return {
310
+ statusCode: HttpStatusCode.noContent
311
+ };
312
+ }
313
+ /**
314
+ * Remove an authentication audit entry.
315
+ * @param httpRequestContext The request context for the API.
316
+ * @param componentName The name of the component to use in the routes.
317
+ * @param request The request.
318
+ * @returns The response object with additional http response properties.
319
+ */
320
+ export async function authenticationAuditRemove(httpRequestContext, componentName, request) {
321
+ Guards.object(ROUTES_SOURCE, "request", request);
322
+ Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
323
+ const component = ComponentFactory.get(componentName);
324
+ await component.remove(request.pathParams.id);
325
+ return {
326
+ statusCode: HttpStatusCode.noContent
327
+ };
328
+ }
329
+ /**
330
+ * Query authentication audit entries.
331
+ * @param httpRequestContext The request context for the API.
332
+ * @param componentName The name of the component to use in the routes.
333
+ * @param request The request.
334
+ * @returns The response object with additional http response properties.
335
+ */
336
+ export async function authenticationAuditQuery(httpRequestContext, componentName, request) {
337
+ Guards.object(ROUTES_SOURCE, "request", request);
338
+ const component = ComponentFactory.get(componentName);
339
+ const result = await component.query({
340
+ actorId: request.query?.actorId,
341
+ organizationId: request.query?.organizationId,
342
+ tenantId: request.query?.tenantId,
343
+ nodeId: request.query?.nodeId,
344
+ event: request.query?.event,
345
+ startDate: request.query?.startDate,
346
+ endDate: request.query?.endDate
347
+ }, request.query?.cursor, Coerce.integer(request.query?.limit));
348
+ return {
349
+ body: {
350
+ entries: result.entries,
351
+ cursor: result.cursor
352
+ }
353
+ };
354
+ }
355
+ //# sourceMappingURL=entityStorageAuthenticationAuditRoutes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entityStorageAuthenticationAuditRoutes.js","sources":["../../../src/routes/entityStorageAuthenticationAuditRoutes.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,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAqB,MAAM,aAAa,CAAC;AAE7E;;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;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAu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rF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,KAAK,CACnC;QACC,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO;QAC/B,cAAc,EAAE,OAAO,CAAC,KAAK,EAAE,cAAc;QAC7C,QAAQ,EAAE,OAAO,CAAC,KAAK,EAAE,QAAQ;QACjC,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM;QAC7B,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK;QAC3B,SAAS,EAAE,OAAO,CAAC,KAAK,EAAE,SAAS;QACnC,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO;KAC/B,EACD,OAAO,CAAC,KAAK,EAAE,MAAM,EACrB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CACpC,CAAC;IAEF,OAAO;QACN,IAAI,EAAE;YACL,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,MAAM,EAAE,MAAM,CAAC,MAAM;SACrB;KACD,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tIAuditCreateRequest,\n\tIAuditGetRequest,\n\tIAuditGetResponse,\n\tIAuditQueryRequest,\n\tIAuditQueryResponse,\n\tIAuditRemoveRequest,\n\tIAuditUpdateRequest,\n\tIAuthenticationAuditComponent\n} from \"@3sixty/api-auth-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 { Coerce, ComponentFactory, Guards } from \"@3sixty/core\";\n\nimport { HeaderTypes, HttpStatusCode, type IHttpHeaders } from \"@3sixty/web\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"authenticationAuditRoutes\";\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/**\n * The tag to associate with the routes.\n */\nexport const tagsAuthenticationAudit: ITag[] = [\n\t{\n\t\tname: \"Authentication Audit\",\n\t\tdescription: \"Authentication audit endpoints for the REST server.\"\n\t}\n];\n\n/**\n * The REST routes for authentication audit.\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 generateRestRoutesAuthenticationAudit(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst createRoute: IRestRoute<IAuditCreateRequest, ICreatedResponse> = {\n\t\toperationId: \"authenticationAuditCreate\",\n\t\tsummary: \"Create an authentication audit entry\",\n\t\ttag: tagsAuthenticationAudit[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tauthenticationAuditCreate(httpRequestContext, componentName, request, baseRouteName),\n\t\trequestType: {\n\t\t\ttype: \"IAuditCreateRequest\",\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"authenticationAuditCreateRequestExample\",\n\t\t\t\t\tdescription: \"The request to create an authentication audit entry.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tactorId: \"user@example.com\",\n\t\t\t\t\t\t\tevent: \"login-success\",\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\torganizationIdentity: \"did:example:org1\"\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},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: \"ICreatedResponse\",\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"authenticationAuditCreateResponseExample\",\n\t\t\t\t\t\tdescription: \"The response for creating an authentication audit entry.\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tstatusCode: 201,\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t[HeaderTypes.Location]: \"018f0b53d5d5704fa3a06d6ed2478575\"\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_WRITER\n\t};\n\n\tconst getRoute: IRestRoute<IAuditGetRequest, IAuditGetResponse> = {\n\t\toperationId: \"authenticationAuditGet\",\n\t\tsummary: \"Get an authentication audit entry\",\n\t\ttag: tagsAuthenticationAudit[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tauthenticationAuditGet(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: \"IAuditGetRequest\",\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"authenticationAuditGetRequestExample\",\n\t\t\t\t\tdescription: \"The request to get an authentication audit entry.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"018f0b53d5d5704fa3a06d6ed2478575\"\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: \"IAuditGetResponse\",\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"authenticationAuditGetResponseExample\",\n\t\t\t\t\t\tdescription: \"The response for getting an authentication audit entry.\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tid: \"018f0b53d5d5704fa3a06d6ed2478575\",\n\t\t\t\t\t\t\t\tactorId: \"user@example.com\",\n\t\t\t\t\t\t\t\tdateCreated: \"2026-01-12T09:05:23.123Z\",\n\t\t\t\t\t\t\t\tevent: \"login-success\",\n\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\torganizationIdentity: \"did:example:org1\"\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},\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 updateRoute: IRestRoute<IAuditUpdateRequest, INoContentResponse> = {\n\t\toperationId: \"authenticationAuditUpdate\",\n\t\tsummary: \"Update an authentication audit entry\",\n\t\ttag: tagsAuthenticationAudit[0].name,\n\t\tmethod: \"PUT\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tauthenticationAuditUpdate(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: \"IAuditUpdateRequest\",\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"authenticationAuditUpdateRequestExample\",\n\t\t\t\t\tdescription: \"The request to update an authentication audit entry.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"018f0b53d5d5704fa3a06d6ed2478575\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\torganizationIdentity: \"did:example:org1\"\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},\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 removeRoute: IRestRoute<IAuditRemoveRequest, INoContentResponse> = {\n\t\toperationId: \"authenticationAuditRemove\",\n\t\tsummary: \"Remove an authentication audit entry\",\n\t\ttag: tagsAuthenticationAudit[0].name,\n\t\tmethod: \"DELETE\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tauthenticationAuditRemove(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: \"IAuditRemoveRequest\",\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"authenticationAuditRemoveRequestExample\",\n\t\t\t\t\tdescription: \"The request to remove an authentication audit entry.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"018f0b53d5d5704fa3a06d6ed2478575\"\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 queryRoute: IRestRoute<IAuditQueryRequest, IAuditQueryResponse> = {\n\t\toperationId: \"authenticationAuditQuery\",\n\t\tsummary: \"Query authentication audit entries\",\n\t\ttag: tagsAuthenticationAudit[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tauthenticationAuditQuery(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: \"IAuditQueryRequest\",\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"authenticationAuditQueryRequestExample\",\n\t\t\t\t\tdescription: \"The request to query authentication audit entries.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\tactorId: \"user@example.com\",\n\t\t\t\t\t\t\tevent: \"login-success\",\n\t\t\t\t\t\t\tstartDate: \"2026-01-01T00:00:00.000Z\",\n\t\t\t\t\t\t\tendDate: \"2026-01-31T23:59:59.999Z\",\n\t\t\t\t\t\t\tlimit: \"50\"\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: \"IAuditQueryResponse\",\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"authenticationAuditQueryResponseExample\",\n\t\t\t\t\t\tdescription: \"The response for querying authentication audit entries.\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tentries: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: \"018f0b53d5d5704fa3a06d6ed2478575\",\n\t\t\t\t\t\t\t\t\t\tactorId: \"user@example.com\",\n\t\t\t\t\t\t\t\t\t\tdateCreated: \"2026-01-12T09:05:23.123Z\",\n\t\t\t\t\t\t\t\t\t\tevent: \"login-success\",\n\t\t\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t\t\torganizationIdentity: \"did:example:org1\"\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tcursor: \"next-cursor\"\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\treturn [createRoute, getRoute, updateRoute, removeRoute, queryRoute];\n}\n\n/**\n * Create an authentication audit entry.\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 authenticationAuditCreate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IAuditCreateRequest,\n\tbaseRouteName: string\n): Promise<ICreatedResponse> {\n\tGuards.object<IAuditCreateRequest>(ROUTES_SOURCE, \"request\", request);\n\tGuards.object<IAuditCreateRequest[\"body\"]>(ROUTES_SOURCE, \"request.body\", request.body);\n\n\tconst component = ComponentFactory.get<IAuthenticationAuditComponent>(componentName);\n\tconst id = await 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\tid,\n\t\tHttpUrlHelper.combineOriginPath(publicOrigin, `${baseRouteName}/:id`)\n\t);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.created,\n\t\theaders\n\t};\n}\n\n/**\n * Get an authentication audit entry.\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 authenticationAuditGet(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IAuditGetRequest\n): Promise<IAuditGetResponse> {\n\tGuards.object<IAuditGetRequest>(ROUTES_SOURCE, \"request\", request);\n\tGuards.object<IAuditGetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\t\"request.pathParams\",\n\t\trequest.pathParams\n\t);\n\n\tconst component = ComponentFactory.get<IAuthenticationAuditComponent>(componentName);\n\tconst entry = await component.get(request.pathParams.id);\n\n\treturn {\n\t\tbody: entry\n\t};\n}\n\n/**\n * Update an authentication audit entry.\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 authenticationAuditUpdate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IAuditUpdateRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IAuditUpdateRequest>(ROUTES_SOURCE, \"request\", request);\n\tGuards.object<IAuditUpdateRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\t\"request.pathParams\",\n\t\trequest.pathParams\n\t);\n\tGuards.object<IAuditUpdateRequest[\"body\"]>(ROUTES_SOURCE, \"request.body\", request.body);\n\n\tconst component = ComponentFactory.get<IAuthenticationAuditComponent>(componentName);\n\tawait component.update(request.pathParams.id, request.body);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Remove an authentication audit entry.\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 authenticationAuditRemove(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IAuditRemoveRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IAuditRemoveRequest>(ROUTES_SOURCE, \"request\", request);\n\tGuards.object<IAuditRemoveRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\t\"request.pathParams\",\n\t\trequest.pathParams\n\t);\n\n\tconst component = ComponentFactory.get<IAuthenticationAuditComponent>(componentName);\n\tawait component.remove(request.pathParams.id);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Query authentication audit entries.\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 authenticationAuditQuery(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IAuditQueryRequest\n): Promise<IAuditQueryResponse> {\n\tGuards.object<IAuditQueryRequest>(ROUTES_SOURCE, \"request\", request);\n\n\tconst component = ComponentFactory.get<IAuthenticationAuditComponent>(componentName);\n\tconst result = await component.query(\n\t\t{\n\t\t\tactorId: request.query?.actorId,\n\t\t\torganizationId: request.query?.organizationId,\n\t\t\ttenantId: request.query?.tenantId,\n\t\t\tnodeId: request.query?.nodeId,\n\t\t\tevent: request.query?.event,\n\t\t\tstartDate: request.query?.startDate,\n\t\t\tendDate: request.query?.endDate\n\t\t},\n\t\trequest.query?.cursor,\n\t\tCoerce.integer(request.query?.limit)\n\t);\n\n\treturn {\n\t\tbody: {\n\t\t\tentries: result.entries,\n\t\t\tcursor: result.cursor\n\t\t}\n\t};\n}\n"]}
@@ -0,0 +1,13 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { EntitySchemaFactory, EntitySchemaHelper } from "@3sixty/entity";
4
+ import { AuthenticationAuditEntry } from "./entities/authenticationAuditEntry.js";
5
+ import { AuthenticationRateEntry } from "./entities/authenticationRateEntry.js";
6
+ /**
7
+ * Initialize the schema for the authentication audit and rate services.
8
+ */
9
+ export function initSchema() {
10
+ EntitySchemaFactory.register("AuthenticationAuditEntry", () => EntitySchemaHelper.getSchema(AuthenticationAuditEntry));
11
+ EntitySchemaFactory.register("AuthenticationRateEntry", () => EntitySchemaHelper.getSchema(AuthenticationRateEntry));
12
+ }
13
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sources":["../../src/schema.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAEhF;;GAEG;AACH,MAAM,UAAU,UAAU;IACzB,mBAAmB,CAAC,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE,CAC7D,kBAAkB,CAAC,SAAS,CAAC,wBAAwB,CAAC,CACtD,CAAC;IACF,mBAAmB,CAAC,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE,CAC5D,kBAAkB,CAAC,SAAS,CAAC,uBAAuB,CAAC,CACrD,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { EntitySchemaFactory, EntitySchemaHelper } from \"@3sixty/entity\";\n\nimport { AuthenticationAuditEntry } from \"./entities/authenticationAuditEntry.js\";\nimport { AuthenticationRateEntry } from \"./entities/authenticationRateEntry.js\";\n\n/**\n * Initialize the schema for the authentication audit and rate services.\n */\nexport function initSchema(): void {\n\tEntitySchemaFactory.register(\"AuthenticationAuditEntry\", () =>\n\t\tEntitySchemaHelper.getSchema(AuthenticationAuditEntry)\n\t);\n\tEntitySchemaFactory.register(\"AuthenticationRateEntry\", () =>\n\t\tEntitySchemaHelper.getSchema(AuthenticationRateEntry)\n\t);\n}\n"]}