@astram/guard 0.26.0 → 0.28.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.
- package/dist/auth/auth.module.d.ts +4 -0
- package/dist/auth/auth.module.d.ts.map +1 -1
- package/dist/auth/auth.module.js +20 -1
- package/dist/auth/persistence.module.d.ts +4 -0
- package/dist/auth/persistence.module.d.ts.map +1 -1
- package/dist/auth/persistence.module.js +5 -1
- package/dist/auth/tokens.d.ts +8 -0
- package/dist/auth/tokens.d.ts.map +1 -1
- package/dist/auth/tokens.js +10 -2
- package/dist/boot/boot.module.d.ts +4 -0
- package/dist/boot/boot.module.d.ts.map +1 -1
- package/dist/boot/boot.module.js +3 -0
- package/dist/config/config.module.d.ts +4 -0
- package/dist/config/config.module.d.ts.map +1 -1
- package/dist/config/config.module.js +3 -0
- package/dist/enforcement/enforcement.module.d.ts +4 -0
- package/dist/enforcement/enforcement.module.d.ts.map +1 -1
- package/dist/enforcement/enforcement.module.js +3 -0
- package/dist/enforcement/global-enforcement.guard.d.ts +12 -0
- package/dist/enforcement/global-enforcement.guard.d.ts.map +1 -1
- package/dist/enforcement/global-enforcement.guard.js +42 -0
- package/dist/identity/identity-actions.d.ts +16 -0
- package/dist/identity/identity-actions.d.ts.map +1 -1
- package/dist/identity/identity-actions.js +15 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -5
- package/dist/internal.d.ts +14 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +19 -1
- package/dist/module/shield.module.d.ts +9 -0
- package/dist/module/shield.module.d.ts.map +1 -1
- package/dist/module/shield.module.js +11 -1
- package/dist/notifications/mariadb-notification-store.d.ts +26 -1
- package/dist/notifications/mariadb-notification-store.d.ts.map +1 -1
- package/dist/notifications/mariadb-notification-store.js +128 -3
- package/dist/notifications/notification.service.d.ts +40 -5
- package/dist/notifications/notification.service.d.ts.map +1 -1
- package/dist/notifications/notification.service.js +86 -4
- package/dist/notifications/notifications.controller.d.ts +43 -3
- package/dist/notifications/notifications.controller.d.ts.map +1 -1
- package/dist/notifications/notifications.controller.js +233 -6
- package/dist/notifications/ports.d.ts +52 -2
- package/dist/notifications/ports.d.ts.map +1 -1
- package/dist/notifications/ports.js +12 -2
- package/dist/session/session-liveness.d.ts +41 -0
- package/dist/session/session-liveness.d.ts.map +1 -0
- package/dist/session/session-liveness.js +63 -0
- package/package.json +5 -5
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NotificationService = exports.FRAMEWORK_NOTIFICATION_KINDS = exports.FRAMEWORK_KIND_PREFIX = exports.NOTIFICATION_RECIPIENTS_MAX = exports.NOTIFICATION_LINK_MAX = exports.NOTIFICATION_BODY_MAX = exports.NOTIFICATION_TITLE_MAX = void 0;
|
|
4
|
+
exports.generatedKindLabel = generatedKindLabel;
|
|
5
|
+
exports.fallbackKindInfo = fallbackKindInfo;
|
|
4
6
|
exports.resolveNotificationKinds = resolveNotificationKinds;
|
|
5
7
|
/**
|
|
6
8
|
* `NotificationService` — the one way app and framework code posts notices (notification-store
|
|
@@ -22,6 +24,10 @@ exports.resolveNotificationKinds = resolveNotificationKinds;
|
|
|
22
24
|
*
|
|
23
25
|
* The tenant is the caller's server-side decision (e.g. the session's active company or the
|
|
24
26
|
* granting transaction's company), never request input passed through unchecked (core 50 #7).
|
|
27
|
+
*
|
|
28
|
+
* G-035 (notification-center SPEC §5A): each kind carries a `label` and a `severity`, checked at
|
|
29
|
+
* boot by {@link resolveNotificationKinds}; `kindInfo(kind)` answers them at read time (labels are
|
|
30
|
+
* never stored), with a generated fallback for a kind no longer registered.
|
|
25
31
|
*/
|
|
26
32
|
const node_crypto_1 = require("node:crypto");
|
|
27
33
|
const common_1 = require("@nestjs/common");
|
|
@@ -39,6 +45,13 @@ const DEDUPE_KEY_PATTERN = /^[A-Za-z0-9._:-]{1,64}$/;
|
|
|
39
45
|
const CONTROL_CHARS = /[\u0000-\u001f\u007f]/;
|
|
40
46
|
// eslint-disable-next-line no-control-regex
|
|
41
47
|
const CONTROL_CHARS_EXCEPT_NEWLINE = /[\u0000-\u0009\u000b-\u001f\u007f]/;
|
|
48
|
+
/**
|
|
49
|
+
* Not allowed in a kind label (shown to every company): C0/C1 controls, DEL, zero-width and
|
|
50
|
+
* direction-override characters, which could hide or reorder the visible text.
|
|
51
|
+
*/
|
|
52
|
+
const LABEL_DISALLOWED =
|
|
53
|
+
// eslint-disable-next-line no-control-regex
|
|
54
|
+
/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2060-\u2069\ufeff]/;
|
|
42
55
|
/** The prefix reserved for the framework's own kinds. */
|
|
43
56
|
exports.FRAMEWORK_KIND_PREFIX = 'shield.';
|
|
44
57
|
/**
|
|
@@ -46,7 +59,12 @@ exports.FRAMEWORK_KIND_PREFIX = 'shield.';
|
|
|
46
59
|
* `AccessChangeNotifier`, a personal notice listing the recipient's gained / lost capabilities).
|
|
47
60
|
*/
|
|
48
61
|
exports.FRAMEWORK_NOTIFICATION_KINDS = [
|
|
49
|
-
{
|
|
62
|
+
{
|
|
63
|
+
kind: `${exports.FRAMEWORK_KIND_PREFIX}access_changed`,
|
|
64
|
+
category: 'personal',
|
|
65
|
+
label: 'Access change',
|
|
66
|
+
severity: 'info',
|
|
67
|
+
},
|
|
50
68
|
];
|
|
51
69
|
/** Length in characters (code points), as `VARCHAR(n)` in utf8mb4 counts them. */
|
|
52
70
|
function codePoints(s) {
|
|
@@ -55,10 +73,36 @@ function codePoints(s) {
|
|
|
55
73
|
function isCategory(v) {
|
|
56
74
|
return ports_js_1.NOTIFICATION_CATEGORIES.includes(v);
|
|
57
75
|
}
|
|
76
|
+
function isSeverity(v) {
|
|
77
|
+
return ports_js_1.NOTIFICATION_SEVERITIES.includes(v);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The label generated from a kind's last segment (`app.task_assigned` ⇒ "Task assigned"): `_`
|
|
81
|
+
* becomes a space, the first letter upper-case; over 40 code points ⇒ the first 39 and "…".
|
|
82
|
+
* Total for any string (an old row's kind is shown, never thrown on).
|
|
83
|
+
*/
|
|
84
|
+
function generatedKindLabel(kind) {
|
|
85
|
+
const last = kind.slice(kind.lastIndexOf('.') + 1);
|
|
86
|
+
const words = last.split('_').filter((w) => w.length > 0);
|
|
87
|
+
const joined = words.join(' ');
|
|
88
|
+
if (joined === '')
|
|
89
|
+
return 'Notification';
|
|
90
|
+
// Upper-case first, then count: one code point can grow ("ß" ⇒ "SS").
|
|
91
|
+
const first = Array.from(joined)[0];
|
|
92
|
+
const chars = Array.from(first.toUpperCase() + joined.slice(first.length));
|
|
93
|
+
return chars.length > ports_js_1.NOTIFICATION_LABEL_MAX
|
|
94
|
+
? `${chars.slice(0, ports_js_1.NOTIFICATION_LABEL_MAX - 1).join('')}…`
|
|
95
|
+
: chars.join('');
|
|
96
|
+
}
|
|
97
|
+
/** The info of a kind the registry does not know (an old row): generated label, `info`. */
|
|
98
|
+
function fallbackKindInfo(kind, storedCategory) {
|
|
99
|
+
return { label: generatedKindLabel(kind), severity: 'info', category: storedCategory };
|
|
100
|
+
}
|
|
58
101
|
/**
|
|
59
102
|
* Build the kind registry from the app's `notificationKinds` (validated at boot, SPEC §5C) and the
|
|
60
103
|
* framework's own kinds. Refuses a malformed or over-long kind, an unknown category, a duplicate,
|
|
61
|
-
*
|
|
104
|
+
* an app kind under the reserved `shield.` prefix, a bad label (not 1–40 characters of plain text)
|
|
105
|
+
* and an unknown severity; each error names the kind, never the label.
|
|
62
106
|
*/
|
|
63
107
|
function resolveNotificationKinds(appKinds, frameworkKinds = exports.FRAMEWORK_NOTIFICATION_KINDS) {
|
|
64
108
|
if (appKinds !== undefined && !Array.isArray(appKinds)) {
|
|
@@ -68,6 +112,8 @@ function resolveNotificationKinds(appKinds, frameworkKinds = exports.FRAMEWORK_N
|
|
|
68
112
|
const add = (entry, framework) => {
|
|
69
113
|
const kind = entry?.kind;
|
|
70
114
|
const category = entry?.category;
|
|
115
|
+
const label = entry?.label;
|
|
116
|
+
const severity = entry?.severity;
|
|
71
117
|
if (typeof kind !== 'string') {
|
|
72
118
|
throw ports_js_1.NotificationKindError.registration(kind, 'must be a string');
|
|
73
119
|
}
|
|
@@ -83,10 +129,28 @@ function resolveNotificationKinds(appKinds, frameworkKinds = exports.FRAMEWORK_N
|
|
|
83
129
|
if (!isCategory(category)) {
|
|
84
130
|
throw ports_js_1.NotificationKindError.registration(kind, 'needs a category: announcement or personal');
|
|
85
131
|
}
|
|
132
|
+
// An app label is trimmed, then must be 1–40 code points with no control character (a longer
|
|
133
|
+
// one fails the boot; only a GENERATED label is cut). The label itself is never printed.
|
|
134
|
+
const text = typeof label === 'string' ? label.trim() : undefined;
|
|
135
|
+
if (label !== undefined &&
|
|
136
|
+
(text === undefined ||
|
|
137
|
+
codePoints(text) < 1 ||
|
|
138
|
+
codePoints(text) > ports_js_1.NOTIFICATION_LABEL_MAX ||
|
|
139
|
+
LABEL_DISALLOWED.test(text))) {
|
|
140
|
+
throw ports_js_1.NotificationKindError.registration(kind, `needs a label of 1 to ${ports_js_1.NOTIFICATION_LABEL_MAX} characters of plain text (no control, zero-width or direction characters)`);
|
|
141
|
+
}
|
|
142
|
+
if (severity !== undefined && !isSeverity(severity)) {
|
|
143
|
+
throw ports_js_1.NotificationKindError.registration(kind, 'needs a severity: info, success or warning');
|
|
144
|
+
}
|
|
86
145
|
if (registry.has(kind)) {
|
|
87
146
|
throw ports_js_1.NotificationKindError.registration(kind, 'is registered more than once');
|
|
88
147
|
}
|
|
89
|
-
registry.set(kind,
|
|
148
|
+
registry.set(kind, {
|
|
149
|
+
category,
|
|
150
|
+
label: text ?? generatedKindLabel(kind),
|
|
151
|
+
severity: severity ?? 'info',
|
|
152
|
+
labelGenerated: text === undefined,
|
|
153
|
+
});
|
|
90
154
|
};
|
|
91
155
|
for (const entry of frameworkKinds)
|
|
92
156
|
add(entry, true);
|
|
@@ -115,11 +179,29 @@ class NotificationService {
|
|
|
115
179
|
this.membershipTable = (0, framework_schema_names_js_1.qualifiedTableName)(s.app, 'company_membership');
|
|
116
180
|
this.now = options.now ?? Date.now;
|
|
117
181
|
this.logger = options.logger ?? new common_1.Logger('Shield');
|
|
182
|
+
// One boot warning (the service is built once per app): kind names only, never a label.
|
|
183
|
+
const unlabelled = [...this.kinds]
|
|
184
|
+
.filter(([, def]) => def.labelGenerated)
|
|
185
|
+
.map(([kind]) => kind);
|
|
186
|
+
if (unlabelled.length > 0) {
|
|
187
|
+
this.logger.warn?.(`[notifications] kinds without a label (generated from the kind): ${unlabelled.join(', ')}`);
|
|
188
|
+
}
|
|
118
189
|
}
|
|
119
190
|
/** Whether `kind` is registered (framework or app). */
|
|
120
191
|
hasKind(kind) {
|
|
121
192
|
return this.kinds.has(kind);
|
|
122
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* The label, severity and category shown for `kind` (notification-center SPEC §5A). A kind no
|
|
196
|
+
* longer registered (old rows stay readable) ⇒ a label generated from the kind, `info`, and
|
|
197
|
+
* `storedCategory` (the row's) as the category.
|
|
198
|
+
*/
|
|
199
|
+
kindInfo(kind, storedCategory) {
|
|
200
|
+
const def = this.kinds.get(kind);
|
|
201
|
+
if (def === undefined)
|
|
202
|
+
return fallbackKindInfo(kind, storedCategory);
|
|
203
|
+
return { label: def.label, severity: def.severity, category: def.category };
|
|
204
|
+
}
|
|
123
205
|
async post(input, opts = {}) {
|
|
124
206
|
if (typeof input !== 'object' || input === null) {
|
|
125
207
|
throw new ports_js_1.NotificationValidationError('input', 'must be an object');
|
|
@@ -130,7 +212,7 @@ class NotificationService {
|
|
|
130
212
|
const tenantId = (0, engine_1.canonicalUuid)(input.tenantId);
|
|
131
213
|
if (tenantId === null)
|
|
132
214
|
throw new ports_js_1.NotificationValidationError('tenantId', 'must be a uuid');
|
|
133
|
-
const category = typeof input.kind === 'string' ? this.kinds.get(input.kind) : undefined;
|
|
215
|
+
const category = typeof input.kind === 'string' ? this.kinds.get(input.kind)?.category : undefined;
|
|
134
216
|
if (category === undefined)
|
|
135
217
|
throw new ports_js_1.NotificationKindError(input.kind);
|
|
136
218
|
const title = validTitle(input.title);
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import type { SessionTokenBinder } from '../request-auth/session-token-binder.js';
|
|
2
2
|
import type { MfaRequirementService } from '../session/mfa-requirement-service.js';
|
|
3
|
-
import { type
|
|
3
|
+
import { type NotificationService } from './notification.service.js';
|
|
4
|
+
import { type NotificationCategory, type NotificationSeverity, type NotificationStore } from './ports.js';
|
|
5
|
+
/** Longest `search` after trimming, in code points (notification-center SPEC §3). */
|
|
6
|
+
export declare const NOTIFICATION_SEARCH_MAX = 100;
|
|
4
7
|
/** One notice as the API returns it: no tenant id, user id or dedupe key (SPEC §5D). */
|
|
5
8
|
export interface NotificationView {
|
|
6
9
|
readonly uuid: string;
|
|
7
10
|
readonly category: NotificationCategory;
|
|
8
11
|
readonly kind: string;
|
|
12
|
+
/** The kind's registered label, or one generated from the kind (never the raw kind). */
|
|
13
|
+
readonly kindLabel: string;
|
|
14
|
+
readonly severity: NotificationSeverity;
|
|
9
15
|
readonly title: string;
|
|
10
16
|
readonly body: string | null;
|
|
11
17
|
readonly link: string | null;
|
|
@@ -13,6 +19,13 @@ export interface NotificationView {
|
|
|
13
19
|
readonly createdAt: string;
|
|
14
20
|
/** ISO 8601; `null` ⇒ unread. */
|
|
15
21
|
readonly readAt: string | null;
|
|
22
|
+
/** ISO 8601; `null` ⇒ not archived. */
|
|
23
|
+
readonly archivedAt: string | null;
|
|
24
|
+
}
|
|
25
|
+
export interface NotificationKindView {
|
|
26
|
+
readonly kind: string;
|
|
27
|
+
readonly label: string;
|
|
28
|
+
readonly category: NotificationCategory;
|
|
16
29
|
}
|
|
17
30
|
export interface NotificationListView {
|
|
18
31
|
readonly total: number;
|
|
@@ -30,7 +43,9 @@ export declare class NotificationsController {
|
|
|
30
43
|
private readonly binder?;
|
|
31
44
|
private readonly store?;
|
|
32
45
|
private readonly mfaRequirement?;
|
|
33
|
-
|
|
46
|
+
private readonly notifications?;
|
|
47
|
+
constructor(binder?: SessionTokenBinder | undefined, store?: (NotificationStore | null) | undefined, mfaRequirement?: (MfaRequirementService | null) | undefined, notifications?: (NotificationService | null) | undefined);
|
|
48
|
+
private kindInfo;
|
|
34
49
|
/**
|
|
35
50
|
* The caller's claims after the mandatory-2FA refresh and the restriction gate (mirrors
|
|
36
51
|
* `AccountController.requireClaims` + `enforceReenroll(claims, false)`): no notification route is
|
|
@@ -38,20 +53,45 @@ export declare class NotificationsController {
|
|
|
38
53
|
*/
|
|
39
54
|
private requireSession;
|
|
40
55
|
private requireStore;
|
|
41
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* `GET /account/notifications` — newest first ⇒ `{ total, rows, page, limit }`. Filters
|
|
58
|
+
* `category`, `unread`, `kind`, `status` (absent ⇒ not archived), `from` / `to` (UTC days,
|
|
59
|
+
* inclusive), `search` (title or body; blank ⇒ no search).
|
|
60
|
+
*/
|
|
42
61
|
list(authorization: string | undefined, query: QueryParams): Promise<NotificationListView>;
|
|
62
|
+
/**
|
|
63
|
+
* `GET /account/notifications/kinds` ⇒ `{ kinds: [{ kind, label, category }] }`: the types the
|
|
64
|
+
* caller has notices of in the active company (the Type filter). The category is the stored one.
|
|
65
|
+
*/
|
|
66
|
+
kinds(authorization: string | undefined): Promise<{
|
|
67
|
+
kinds: NotificationKindView[];
|
|
68
|
+
}>;
|
|
43
69
|
/** `GET /account/notifications/unread-count` ⇒ `{ announcement, personal, total }`. */
|
|
44
70
|
unreadCount(authorization: string | undefined): Promise<NotificationUnreadCountView>;
|
|
45
71
|
/** `POST /account/notifications/read-all?category=` ⇒ `{ updated }`. */
|
|
46
72
|
readAll(authorization: string | undefined, query: QueryParams): Promise<{
|
|
47
73
|
updated: number;
|
|
48
74
|
}>;
|
|
75
|
+
/**
|
|
76
|
+
* `POST /account/notifications/bulk` body `{ action: read|unread|archive|unarchive, uuids:
|
|
77
|
+
* 1–100 }` ⇒ `{ updated }`: the number of the caller's own notices in the active company that
|
|
78
|
+
* changed (another user's or company's uuid, or an unknown one, counts 0).
|
|
79
|
+
*/
|
|
80
|
+
bulk(authorization: string | undefined, body: unknown): Promise<{
|
|
81
|
+
updated: number;
|
|
82
|
+
}>;
|
|
49
83
|
/**
|
|
50
84
|
* `POST /account/notifications/:uuid/read` ⇒ 204 (idempotent: the first read time is kept).
|
|
51
85
|
* The uuid is canonicalised here, after the session check (401 before 400), as
|
|
52
86
|
* `/account/mfa/devices/:id` does.
|
|
53
87
|
*/
|
|
54
88
|
read(authorization: string | undefined, rawUuid: string): Promise<void>;
|
|
89
|
+
/** `POST /account/notifications/:uuid/unread` ⇒ 204 (an archived notice stays read). */
|
|
90
|
+
unread(authorization: string | undefined, rawUuid: string): Promise<void>;
|
|
91
|
+
/** `POST /account/notifications/:uuid/archive` ⇒ 204 (idempotent; also marks it read). */
|
|
92
|
+
archive(authorization: string | undefined, rawUuid: string): Promise<void>;
|
|
93
|
+
/** `POST /account/notifications/:uuid/unarchive` ⇒ 204 (idempotent; it comes back as read). */
|
|
94
|
+
unarchive(authorization: string | undefined, rawUuid: string): Promise<void>;
|
|
55
95
|
}
|
|
56
96
|
export {};
|
|
57
97
|
//# sourceMappingURL=notifications.controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.controller.d.ts","sourceRoot":"","sources":["../../src/notifications/notifications.controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notifications.controller.d.ts","sourceRoot":"","sources":["../../src/notifications/notifications.controller.ts"],"names":[],"mappings":"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"}
|
|
@@ -12,7 +12,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.NotificationsController = void 0;
|
|
15
|
+
exports.NotificationsController = exports.NOTIFICATION_SEARCH_MAX = void 0;
|
|
16
16
|
/**
|
|
17
17
|
* `/account/notifications` — the signed-in user's own notice inbox (G-027 step 2,
|
|
18
18
|
* notification-store SPEC §3, §5D, §13).
|
|
@@ -30,20 +30,33 @@ exports.NotificationsController = void 0;
|
|
|
30
30
|
* Order on every route: 401 (no/invalid session) → 403 (restricted session) → 501 (store not
|
|
31
31
|
* wired) → 400 (bad query parameter or `:uuid`, naming the parameter, never echoing the value) →
|
|
32
32
|
* store call (any throw ⇒ 503 `notifications_unavailable`, the driver message never surfaces).
|
|
33
|
+
*
|
|
34
|
+
* G-035 (notification-center SPEC §3, §5C, §13): the list takes `kind`, `status`, `from` / `to`
|
|
35
|
+
* (UTC days, inclusive) and `search`; rows carry `kindLabel` / `severity` (from the kind
|
|
36
|
+
* registration, `NotificationService.kindInfo`) and `archivedAt`. New: `GET kinds`, `POST
|
|
37
|
+
* :uuid/{unread,archive,unarchive}` (as `:uuid/read`) and `POST bulk` ⇒ `{ updated }`. Static
|
|
38
|
+
* routes are declared before the `:uuid/*` ones.
|
|
33
39
|
*/
|
|
34
40
|
const common_1 = require("@nestjs/common");
|
|
41
|
+
const engine_1 = require("@astram/engine");
|
|
35
42
|
const classification_decorator_js_1 = require("../enforcement/classification.decorator.js");
|
|
36
43
|
const uuid_pipe_js_1 = require("../enforcement/uuid.pipe.js");
|
|
37
44
|
const request_principal_js_1 = require("../request-auth/request-principal.js");
|
|
38
45
|
const tokens_js_1 = require("../request-auth/tokens.js");
|
|
39
46
|
const tokens_js_2 = require("../auth/tokens.js");
|
|
40
47
|
const session_restriction_js_1 = require("../session/session-restriction.js");
|
|
48
|
+
const notification_service_js_1 = require("./notification.service.js");
|
|
41
49
|
const ports_js_1 = require("./ports.js");
|
|
42
50
|
/** Default and maximum page size (SPEC §10). */
|
|
43
51
|
const DEFAULT_LIMIT = 20;
|
|
44
52
|
const MAX_LIMIT = 100;
|
|
53
|
+
/** Longest `search` after trimming, in code points (notification-center SPEC §3). */
|
|
54
|
+
exports.NOTIFICATION_SEARCH_MAX = 100;
|
|
45
55
|
/** A decimal integer as a query string (no sign, no exponent, no whitespace). */
|
|
46
56
|
const DIGITS = /^[0-9]{1,16}$/;
|
|
57
|
+
/** An ISO calendar date `YYYY-MM-DD` (UTC day). */
|
|
58
|
+
const ISO_DATE = /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/;
|
|
59
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
47
60
|
/** The generic 401, as `/account/*` (never distinguishes no token / bad token / API key). */
|
|
48
61
|
function unauthorized() {
|
|
49
62
|
throw new common_1.HttpException({ error: 'unauthorized' }, common_1.HttpStatus.UNAUTHORIZED);
|
|
@@ -95,16 +108,95 @@ function parseBoundedInt(name, value, fallback, max) {
|
|
|
95
108
|
badParameter(name);
|
|
96
109
|
return n;
|
|
97
110
|
}
|
|
98
|
-
|
|
111
|
+
/** Optional `kind`: absent ⇒ every kind; otherwise a well-formed kind (≤ 64, dotted segments). */
|
|
112
|
+
function parseKind(value) {
|
|
113
|
+
if (value === undefined)
|
|
114
|
+
return undefined;
|
|
115
|
+
if (typeof value !== 'string' ||
|
|
116
|
+
value.length > ports_js_1.NOTIFICATION_KIND_MAX_LENGTH ||
|
|
117
|
+
!ports_js_1.NOTIFICATION_KIND_PATTERN.test(value)) {
|
|
118
|
+
badParameter('kind');
|
|
119
|
+
}
|
|
120
|
+
return value;
|
|
121
|
+
}
|
|
122
|
+
/** Optional `status`: absent ⇒ not archived; otherwise `unread`, `read` or `archived`. */
|
|
123
|
+
function parseStatus(value) {
|
|
124
|
+
if (value === undefined)
|
|
125
|
+
return undefined;
|
|
126
|
+
if (typeof value !== 'string' || !ports_js_1.NOTIFICATION_STATUSES.includes(value)) {
|
|
127
|
+
badParameter('status');
|
|
128
|
+
}
|
|
129
|
+
return value;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Optional ISO date `YYYY-MM-DD` as a UTC day ⇒ its first millisecond, or with `endOfDay` its
|
|
133
|
+
* last (inclusive days). A date that does not exist (2026-02-30) is refused.
|
|
134
|
+
*/
|
|
135
|
+
function parseDay(name, value, endOfDay) {
|
|
136
|
+
if (value === undefined)
|
|
137
|
+
return undefined;
|
|
138
|
+
const m = typeof value === 'string' ? ISO_DATE.exec(value) : null;
|
|
139
|
+
if (m === null)
|
|
140
|
+
return badParameter(name);
|
|
141
|
+
const [y, mo, d] = [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
142
|
+
const start = Date.UTC(y, mo - 1, d);
|
|
143
|
+
const back = new Date(start);
|
|
144
|
+
if (y < 1970 ||
|
|
145
|
+
back.getUTCFullYear() !== y ||
|
|
146
|
+
back.getUTCMonth() !== mo - 1 ||
|
|
147
|
+
back.getUTCDate() !== d) {
|
|
148
|
+
badParameter(name);
|
|
149
|
+
}
|
|
150
|
+
return endOfDay ? start + DAY_MS - 1 : start;
|
|
151
|
+
}
|
|
152
|
+
/** Optional `search`: trimmed; empty ⇒ absent (not an error); over 100 code points ⇒ 400. */
|
|
153
|
+
function parseSearch(value) {
|
|
154
|
+
if (value === undefined)
|
|
155
|
+
return undefined;
|
|
156
|
+
if (typeof value !== 'string')
|
|
157
|
+
badParameter('search');
|
|
158
|
+
const term = value.trim();
|
|
159
|
+
if (term.length === 0)
|
|
160
|
+
return undefined;
|
|
161
|
+
if (Array.from(term).length > exports.NOTIFICATION_SEARCH_MAX)
|
|
162
|
+
badParameter('search');
|
|
163
|
+
return term;
|
|
164
|
+
}
|
|
165
|
+
/** Body `action` of `POST bulk`. */
|
|
166
|
+
function parseBulkAction(value) {
|
|
167
|
+
if (typeof value !== 'string' ||
|
|
168
|
+
!ports_js_1.NOTIFICATION_BULK_ACTIONS.includes(value)) {
|
|
169
|
+
badParameter('action');
|
|
170
|
+
}
|
|
171
|
+
return value;
|
|
172
|
+
}
|
|
173
|
+
/** Body `uuids` of `POST bulk`: 1–100 uuids, canonical and de-duplicated. */
|
|
174
|
+
function parseBulkUuids(value) {
|
|
175
|
+
if (!Array.isArray(value) || value.length < 1 || value.length > ports_js_1.NOTIFICATION_BULK_MAX) {
|
|
176
|
+
throw new common_1.BadRequestException(`uuids must be a list of 1 to ${ports_js_1.NOTIFICATION_BULK_MAX} uuids`);
|
|
177
|
+
}
|
|
178
|
+
const out = new Set();
|
|
179
|
+
for (const v of value) {
|
|
180
|
+
const canonical = (0, engine_1.canonicalUuid)(v);
|
|
181
|
+
if (canonical === null)
|
|
182
|
+
throw new common_1.BadRequestException('uuids must contain uuids only');
|
|
183
|
+
out.add(canonical);
|
|
184
|
+
}
|
|
185
|
+
return [...out];
|
|
186
|
+
}
|
|
187
|
+
function toView(row, info) {
|
|
99
188
|
return {
|
|
100
189
|
uuid: row.uuid,
|
|
101
190
|
category: row.category,
|
|
102
191
|
kind: row.kind,
|
|
192
|
+
kindLabel: info.label,
|
|
193
|
+
severity: info.severity,
|
|
103
194
|
title: row.title,
|
|
104
195
|
body: row.body,
|
|
105
196
|
link: row.link,
|
|
106
197
|
createdAt: new Date(row.createdAtMs).toISOString(),
|
|
107
198
|
readAt: row.readAtMs === null ? null : new Date(row.readAtMs).toISOString(),
|
|
199
|
+
archivedAt: row.archivedAtMs === null ? null : new Date(row.archivedAtMs).toISOString(),
|
|
108
200
|
};
|
|
109
201
|
}
|
|
110
202
|
/** Run one store call; any throw is the fixed 503. */
|
|
@@ -120,10 +212,15 @@ let NotificationsController = class NotificationsController {
|
|
|
120
212
|
binder;
|
|
121
213
|
store;
|
|
122
214
|
mfaRequirement;
|
|
123
|
-
|
|
215
|
+
notifications;
|
|
216
|
+
constructor(binder, store, mfaRequirement, notifications) {
|
|
124
217
|
this.binder = binder;
|
|
125
218
|
this.store = store;
|
|
126
219
|
this.mfaRequirement = mfaRequirement;
|
|
220
|
+
this.notifications = notifications;
|
|
221
|
+
}
|
|
222
|
+
kindInfo(kind, category) {
|
|
223
|
+
return this.notifications?.kindInfo(kind, category) ?? (0, notification_service_js_1.fallbackKindInfo)(kind, category);
|
|
127
224
|
}
|
|
128
225
|
/**
|
|
129
226
|
* The caller's claims after the mandatory-2FA refresh and the restriction gate (mirrors
|
|
@@ -153,12 +250,24 @@ let NotificationsController = class NotificationsController {
|
|
|
153
250
|
notAvailable();
|
|
154
251
|
return this.store;
|
|
155
252
|
}
|
|
156
|
-
/**
|
|
253
|
+
/**
|
|
254
|
+
* `GET /account/notifications` — newest first ⇒ `{ total, rows, page, limit }`. Filters
|
|
255
|
+
* `category`, `unread`, `kind`, `status` (absent ⇒ not archived), `from` / `to` (UTC days,
|
|
256
|
+
* inclusive), `search` (title or body; blank ⇒ no search).
|
|
257
|
+
*/
|
|
157
258
|
async list(authorization, query) {
|
|
158
259
|
const claims = await this.requireSession(authorization);
|
|
159
260
|
const store = this.requireStore();
|
|
160
261
|
const category = parseCategory(query?.category);
|
|
161
262
|
const unreadOnly = parseUnread(query?.unread);
|
|
263
|
+
const kind = parseKind(query?.kind);
|
|
264
|
+
const status = parseStatus(query?.status);
|
|
265
|
+
const fromMs = parseDay('from', query?.from, false);
|
|
266
|
+
const toMs = parseDay('to', query?.to, true);
|
|
267
|
+
if (fromMs !== undefined && toMs !== undefined && fromMs > toMs) {
|
|
268
|
+
throw new common_1.BadRequestException('from must not be after to');
|
|
269
|
+
}
|
|
270
|
+
const search = parseSearch(query?.search);
|
|
162
271
|
const limit = parseBoundedInt('limit', query?.limit, DEFAULT_LIMIT, MAX_LIMIT);
|
|
163
272
|
const page = parseBoundedInt('page', query?.page, 1, Number.MAX_SAFE_INTEGER);
|
|
164
273
|
// The store refuses an offset past the safe-integer range; answer that as the caller's 400.
|
|
@@ -167,10 +276,36 @@ let NotificationsController = class NotificationsController {
|
|
|
167
276
|
const result = await guarded(() => store.list(claims.id, claims.tenantId, {
|
|
168
277
|
...(category !== undefined ? { category } : {}),
|
|
169
278
|
unreadOnly,
|
|
279
|
+
...(kind !== undefined ? { kind } : {}),
|
|
280
|
+
...(status !== undefined ? { status } : {}),
|
|
281
|
+
...(fromMs !== undefined ? { fromMs } : {}),
|
|
282
|
+
...(toMs !== undefined ? { toMs } : {}),
|
|
283
|
+
...(search !== undefined ? { search } : {}),
|
|
170
284
|
page,
|
|
171
285
|
limit,
|
|
172
286
|
}));
|
|
173
|
-
return {
|
|
287
|
+
return {
|
|
288
|
+
total: result.total,
|
|
289
|
+
rows: result.rows.map((r) => toView(r, this.kindInfo(r.kind, r.category))),
|
|
290
|
+
page,
|
|
291
|
+
limit,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* `GET /account/notifications/kinds` ⇒ `{ kinds: [{ kind, label, category }] }`: the types the
|
|
296
|
+
* caller has notices of in the active company (the Type filter). The category is the stored one.
|
|
297
|
+
*/
|
|
298
|
+
async kinds(authorization) {
|
|
299
|
+
const claims = await this.requireSession(authorization);
|
|
300
|
+
const store = this.requireStore();
|
|
301
|
+
const rows = await guarded(() => store.listKinds(claims.id, claims.tenantId));
|
|
302
|
+
return {
|
|
303
|
+
kinds: rows.map((r) => ({
|
|
304
|
+
kind: r.kind,
|
|
305
|
+
label: this.kindInfo(r.kind, r.category).label,
|
|
306
|
+
category: r.category,
|
|
307
|
+
})),
|
|
308
|
+
};
|
|
174
309
|
}
|
|
175
310
|
/** `GET /account/notifications/unread-count` ⇒ `{ announcement, personal, total }`. */
|
|
176
311
|
async unreadCount(authorization) {
|
|
@@ -191,6 +326,20 @@ let NotificationsController = class NotificationsController {
|
|
|
191
326
|
const updated = await guarded(() => store.markAllRead(claims.id, claims.tenantId, category, Date.now()));
|
|
192
327
|
return { updated };
|
|
193
328
|
}
|
|
329
|
+
/**
|
|
330
|
+
* `POST /account/notifications/bulk` body `{ action: read|unread|archive|unarchive, uuids:
|
|
331
|
+
* 1–100 }` ⇒ `{ updated }`: the number of the caller's own notices in the active company that
|
|
332
|
+
* changed (another user's or company's uuid, or an unknown one, counts 0).
|
|
333
|
+
*/
|
|
334
|
+
async bulk(authorization, body) {
|
|
335
|
+
const claims = await this.requireSession(authorization);
|
|
336
|
+
const store = this.requireStore();
|
|
337
|
+
const input = (typeof body === 'object' && body !== null ? body : {});
|
|
338
|
+
const action = parseBulkAction(input.action);
|
|
339
|
+
const uuids = parseBulkUuids(input.uuids);
|
|
340
|
+
const updated = await guarded(() => store.bulk(claims.id, claims.tenantId, action, uuids, Date.now()));
|
|
341
|
+
return { updated };
|
|
342
|
+
}
|
|
194
343
|
/**
|
|
195
344
|
* `POST /account/notifications/:uuid/read` ⇒ 204 (idempotent: the first read time is kept).
|
|
196
345
|
* The uuid is canonicalised here, after the session check (401 before 400), as
|
|
@@ -204,6 +353,33 @@ let NotificationsController = class NotificationsController {
|
|
|
204
353
|
if (!found)
|
|
205
354
|
notFound();
|
|
206
355
|
}
|
|
356
|
+
/** `POST /account/notifications/:uuid/unread` ⇒ 204 (an archived notice stays read). */
|
|
357
|
+
async unread(authorization, rawUuid) {
|
|
358
|
+
const claims = await this.requireSession(authorization);
|
|
359
|
+
const store = this.requireStore();
|
|
360
|
+
const uuid = (0, uuid_pipe_js_1.uuidField)(rawUuid, 'uuid');
|
|
361
|
+
const found = await guarded(() => store.markUnread(claims.id, claims.tenantId, uuid));
|
|
362
|
+
if (!found)
|
|
363
|
+
notFound();
|
|
364
|
+
}
|
|
365
|
+
/** `POST /account/notifications/:uuid/archive` ⇒ 204 (idempotent; also marks it read). */
|
|
366
|
+
async archive(authorization, rawUuid) {
|
|
367
|
+
const claims = await this.requireSession(authorization);
|
|
368
|
+
const store = this.requireStore();
|
|
369
|
+
const uuid = (0, uuid_pipe_js_1.uuidField)(rawUuid, 'uuid');
|
|
370
|
+
const found = await guarded(() => store.archive(claims.id, claims.tenantId, uuid, Date.now()));
|
|
371
|
+
if (!found)
|
|
372
|
+
notFound();
|
|
373
|
+
}
|
|
374
|
+
/** `POST /account/notifications/:uuid/unarchive` ⇒ 204 (idempotent; it comes back as read). */
|
|
375
|
+
async unarchive(authorization, rawUuid) {
|
|
376
|
+
const claims = await this.requireSession(authorization);
|
|
377
|
+
const store = this.requireStore();
|
|
378
|
+
const uuid = (0, uuid_pipe_js_1.uuidField)(rawUuid, 'uuid');
|
|
379
|
+
const found = await guarded(() => store.unarchive(claims.id, claims.tenantId, uuid));
|
|
380
|
+
if (!found)
|
|
381
|
+
notFound();
|
|
382
|
+
}
|
|
207
383
|
};
|
|
208
384
|
exports.NotificationsController = NotificationsController;
|
|
209
385
|
__decorate([
|
|
@@ -216,6 +392,15 @@ __decorate([
|
|
|
216
392
|
__metadata("design:paramtypes", [Object, Object]),
|
|
217
393
|
__metadata("design:returntype", Promise)
|
|
218
394
|
], NotificationsController.prototype, "list", null);
|
|
395
|
+
__decorate([
|
|
396
|
+
(0, classification_decorator_js_1.Public)(),
|
|
397
|
+
(0, common_1.Get)('kinds'),
|
|
398
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
399
|
+
__param(0, (0, common_1.Headers)('authorization')),
|
|
400
|
+
__metadata("design:type", Function),
|
|
401
|
+
__metadata("design:paramtypes", [Object]),
|
|
402
|
+
__metadata("design:returntype", Promise)
|
|
403
|
+
], NotificationsController.prototype, "kinds", null);
|
|
219
404
|
__decorate([
|
|
220
405
|
(0, classification_decorator_js_1.Public)(),
|
|
221
406
|
(0, common_1.Get)('unread-count'),
|
|
@@ -235,6 +420,16 @@ __decorate([
|
|
|
235
420
|
__metadata("design:paramtypes", [Object, Object]),
|
|
236
421
|
__metadata("design:returntype", Promise)
|
|
237
422
|
], NotificationsController.prototype, "readAll", null);
|
|
423
|
+
__decorate([
|
|
424
|
+
(0, classification_decorator_js_1.Public)(),
|
|
425
|
+
(0, common_1.Post)('bulk'),
|
|
426
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
427
|
+
__param(0, (0, common_1.Headers)('authorization')),
|
|
428
|
+
__param(1, (0, common_1.Body)()),
|
|
429
|
+
__metadata("design:type", Function),
|
|
430
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
431
|
+
__metadata("design:returntype", Promise)
|
|
432
|
+
], NotificationsController.prototype, "bulk", null);
|
|
238
433
|
__decorate([
|
|
239
434
|
(0, classification_decorator_js_1.Public)(),
|
|
240
435
|
(0, common_1.Post)(':uuid/read'),
|
|
@@ -245,6 +440,36 @@ __decorate([
|
|
|
245
440
|
__metadata("design:paramtypes", [Object, String]),
|
|
246
441
|
__metadata("design:returntype", Promise)
|
|
247
442
|
], NotificationsController.prototype, "read", null);
|
|
443
|
+
__decorate([
|
|
444
|
+
(0, classification_decorator_js_1.Public)(),
|
|
445
|
+
(0, common_1.Post)(':uuid/unread'),
|
|
446
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
447
|
+
__param(0, (0, common_1.Headers)('authorization')),
|
|
448
|
+
__param(1, (0, common_1.Param)('uuid')),
|
|
449
|
+
__metadata("design:type", Function),
|
|
450
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
451
|
+
__metadata("design:returntype", Promise)
|
|
452
|
+
], NotificationsController.prototype, "unread", null);
|
|
453
|
+
__decorate([
|
|
454
|
+
(0, classification_decorator_js_1.Public)(),
|
|
455
|
+
(0, common_1.Post)(':uuid/archive'),
|
|
456
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
457
|
+
__param(0, (0, common_1.Headers)('authorization')),
|
|
458
|
+
__param(1, (0, common_1.Param)('uuid')),
|
|
459
|
+
__metadata("design:type", Function),
|
|
460
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
461
|
+
__metadata("design:returntype", Promise)
|
|
462
|
+
], NotificationsController.prototype, "archive", null);
|
|
463
|
+
__decorate([
|
|
464
|
+
(0, classification_decorator_js_1.Public)(),
|
|
465
|
+
(0, common_1.Post)(':uuid/unarchive'),
|
|
466
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.NO_CONTENT),
|
|
467
|
+
__param(0, (0, common_1.Headers)('authorization')),
|
|
468
|
+
__param(1, (0, common_1.Param)('uuid')),
|
|
469
|
+
__metadata("design:type", Function),
|
|
470
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
471
|
+
__metadata("design:returntype", Promise)
|
|
472
|
+
], NotificationsController.prototype, "unarchive", null);
|
|
248
473
|
exports.NotificationsController = NotificationsController = __decorate([
|
|
249
474
|
(0, common_1.Controller)('account/notifications'),
|
|
250
475
|
__param(0, (0, common_1.Optional)()),
|
|
@@ -253,5 +478,7 @@ exports.NotificationsController = NotificationsController = __decorate([
|
|
|
253
478
|
__param(1, (0, common_1.Inject)(tokens_js_2.SHIELD_NOTIFICATION_STORE)),
|
|
254
479
|
__param(2, (0, common_1.Optional)()),
|
|
255
480
|
__param(2, (0, common_1.Inject)(tokens_js_2.SHIELD_MFA_REQUIREMENT)),
|
|
256
|
-
|
|
481
|
+
__param(3, (0, common_1.Optional)()),
|
|
482
|
+
__param(3, (0, common_1.Inject)(tokens_js_2.SHIELD_NOTIFICATIONS)),
|
|
483
|
+
__metadata("design:paramtypes", [Function, Object, Object, Object])
|
|
257
484
|
], NotificationsController);
|