@axium/server 0.34.0 → 0.34.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.
- package/dist/audit.js +4 -2
- package/dist/config.d.ts +4 -4
- package/dist/config.js +5 -5
- package/package.json +1 -1
- package/schemas/config.json +2 -18
package/dist/audit.js
CHANGED
|
@@ -20,8 +20,6 @@ export function styleSeverity(sev, align = false) {
|
|
|
20
20
|
return styleText(severityFormat[sev], text.toUpperCase());
|
|
21
21
|
}
|
|
22
22
|
function output(event) {
|
|
23
|
-
if (event.severity > Severity[capitalize(config.audit.min_severity)])
|
|
24
|
-
return;
|
|
25
23
|
console.error('[audit]', styleText('dim', io.prettyDate(event.timestamp)), styleSeverity(event.severity), event.name);
|
|
26
24
|
}
|
|
27
25
|
export async function audit_raw(event) {
|
|
@@ -29,6 +27,8 @@ export async function audit_raw(event) {
|
|
|
29
27
|
io.warn('[audit] Ignoring raw event (disabled)');
|
|
30
28
|
return;
|
|
31
29
|
}
|
|
30
|
+
if (event.severity > Severity[capitalize(config.audit.min_severity)])
|
|
31
|
+
return;
|
|
32
32
|
const result = await database.insertInto('audit_log').values(event).returningAll().executeTakeFirstOrThrow();
|
|
33
33
|
output(result);
|
|
34
34
|
}
|
|
@@ -48,6 +48,8 @@ export async function audit(eventName, userId, extra) {
|
|
|
48
48
|
io.warn('Ignoring audit event with unknown event name: ' + eventName);
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
|
+
if (cfg.severity > Severity[capitalize(config.audit.min_severity)])
|
|
52
|
+
return;
|
|
51
53
|
try {
|
|
52
54
|
if (cfg.extra)
|
|
53
55
|
extra = cfg.extra.parse(extra);
|
package/dist/config.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export declare const Config: z.ZodObject<{
|
|
|
9
9
|
audit: z.ZodOptional<z.ZodObject<{
|
|
10
10
|
allow_raw: z.ZodOptional<z.ZodBoolean>;
|
|
11
11
|
retention: z.ZodOptional<z.ZodNumber>;
|
|
12
|
-
min_severity: z.ZodOptional<z.ZodLiteral<"
|
|
13
|
-
auto_suspend: z.ZodOptional<z.ZodLiteral<"
|
|
12
|
+
min_severity: z.ZodOptional<z.ZodLiteral<"emergency" | "alert" | "critical" | "error" | "warning" | "notice" | "info" | "debug">>;
|
|
13
|
+
auto_suspend: z.ZodOptional<z.ZodLiteral<"emergency" | "alert" | "critical" | "error" | "warning" | "notice" | "info" | "debug">>;
|
|
14
14
|
}, z.core.$loose>>;
|
|
15
15
|
auth: z.ZodOptional<z.ZodObject<{
|
|
16
16
|
passkey_probation: z.ZodOptional<z.ZodNumber>;
|
|
@@ -86,8 +86,8 @@ export declare const ConfigFile: z.ZodObject<{
|
|
|
86
86
|
audit: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
87
87
|
allow_raw: z.ZodOptional<z.ZodBoolean>;
|
|
88
88
|
retention: z.ZodOptional<z.ZodNumber>;
|
|
89
|
-
min_severity: z.ZodOptional<z.ZodLiteral<"
|
|
90
|
-
auto_suspend: z.ZodOptional<z.ZodLiteral<"
|
|
89
|
+
min_severity: z.ZodOptional<z.ZodLiteral<"emergency" | "alert" | "critical" | "error" | "warning" | "notice" | "info" | "debug">>;
|
|
90
|
+
auto_suspend: z.ZodOptional<z.ZodLiteral<"emergency" | "alert" | "critical" | "error" | "warning" | "notice" | "info" | "debug">>;
|
|
91
91
|
}, z.core.$loose>>>;
|
|
92
92
|
auth: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
93
93
|
passkey_probation: z.ZodOptional<z.ZodNumber>;
|
package/dist/config.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
+
import { serverConfigs, toBaseName } from '@axium/core';
|
|
1
2
|
import * as io from '@axium/core/node/io';
|
|
2
3
|
import { loadPlugin } from '@axium/core/node/plugins';
|
|
3
4
|
import { levelText } from 'logzen';
|
|
4
5
|
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
5
6
|
import { dirname, join, resolve } from 'node:path/posix';
|
|
6
|
-
import {
|
|
7
|
+
import { deepAssign, omit } from 'utilium';
|
|
7
8
|
import * as z from 'zod';
|
|
8
9
|
import { dirs, logger, systemDir } from './io.js';
|
|
9
10
|
import { _duplicateStateWarnings, _unique } from './state.js';
|
|
10
|
-
import { serverConfigs, toBaseName } from '@axium/core';
|
|
11
11
|
const audit_severity_levels = ['emergency', 'alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'];
|
|
12
|
-
const z_audit_severity = z.literal([...audit_severity_levels, ...audit_severity_levels.map(capitalize)]);
|
|
13
12
|
export const Config = z
|
|
14
13
|
.looseObject({
|
|
15
14
|
/** Whether /api/admin is enabled */
|
|
@@ -25,8 +24,9 @@ export const Config = z
|
|
|
25
24
|
allow_raw: z.boolean(),
|
|
26
25
|
/** How many days to keep events in the audit log */
|
|
27
26
|
retention: z.number().min(0),
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
/** Minimum severity level. Less severe events will be ignored. */
|
|
28
|
+
min_severity: z.literal(audit_severity_levels),
|
|
29
|
+
auto_suspend: z.literal(audit_severity_levels),
|
|
30
30
|
})
|
|
31
31
|
.partial(),
|
|
32
32
|
auth: z
|
package/package.json
CHANGED
package/schemas/config.json
CHANGED
|
@@ -40,15 +40,7 @@
|
|
|
40
40
|
"warning",
|
|
41
41
|
"notice",
|
|
42
42
|
"info",
|
|
43
|
-
"debug"
|
|
44
|
-
"Emergency",
|
|
45
|
-
"Alert",
|
|
46
|
-
"Critical",
|
|
47
|
-
"Error",
|
|
48
|
-
"Warning",
|
|
49
|
-
"Notice",
|
|
50
|
-
"Info",
|
|
51
|
-
"Debug"
|
|
43
|
+
"debug"
|
|
52
44
|
]
|
|
53
45
|
},
|
|
54
46
|
"auto_suspend": {
|
|
@@ -61,15 +53,7 @@
|
|
|
61
53
|
"warning",
|
|
62
54
|
"notice",
|
|
63
55
|
"info",
|
|
64
|
-
"debug"
|
|
65
|
-
"Emergency",
|
|
66
|
-
"Alert",
|
|
67
|
-
"Critical",
|
|
68
|
-
"Error",
|
|
69
|
-
"Warning",
|
|
70
|
-
"Notice",
|
|
71
|
-
"Info",
|
|
72
|
-
"Debug"
|
|
56
|
+
"debug"
|
|
73
57
|
]
|
|
74
58
|
}
|
|
75
59
|
},
|