@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,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Notification store contract (G-027 step 2, notification-store SPEC §5A, §5B, §10
|
|
2
|
+
* Notification store contract (G-027 step 2, notification-store SPEC §5A, §5B, §10; G-035
|
|
3
|
+
* notification-center SPEC §5A, §5B: kind label / severity, list filters, unread, archive, bulk).
|
|
3
4
|
*
|
|
4
5
|
* One per-user, tenant-walled inbox in `<ns>_identity.user_notification` (identity migration
|
|
5
6
|
* 108). Every per-user statement is scoped by BOTH the user and the tenant (the session's active
|
|
@@ -11,10 +12,35 @@
|
|
|
11
12
|
/** The two inbox categories (SPEC §10). The category always comes from the kind registration. */
|
|
12
13
|
export declare const NOTIFICATION_CATEGORIES: readonly ["announcement", "personal"];
|
|
13
14
|
export type NotificationCategory = (typeof NOTIFICATION_CATEGORIES)[number];
|
|
15
|
+
/** How a notice type is marked in the UI (notification-center SPEC §10); default `info`. */
|
|
16
|
+
export declare const NOTIFICATION_SEVERITIES: readonly ["info", "success", "warning"];
|
|
17
|
+
export type NotificationSeverity = (typeof NOTIFICATION_SEVERITIES)[number];
|
|
18
|
+
/** The longest label (code points) an app may register (notification-center SPEC §5A). */
|
|
19
|
+
export declare const NOTIFICATION_LABEL_MAX = 40;
|
|
14
20
|
/** One `notificationKinds` registration (`ShieldModule.forRoot({ notificationKinds })`). */
|
|
15
21
|
export interface NotificationKindRegistration {
|
|
16
22
|
readonly kind: string;
|
|
17
23
|
readonly category: NotificationCategory;
|
|
24
|
+
/**
|
|
25
|
+
* Plain-text type name shown to every company (e.g. "Task assigned"), 1–40 characters, no
|
|
26
|
+
* control characters; no company or person names. Absent ⇒ generated from the kind's last
|
|
27
|
+
* segment (one boot warning lists such kinds).
|
|
28
|
+
*/
|
|
29
|
+
readonly label?: string;
|
|
30
|
+
/** Default `info`. */
|
|
31
|
+
readonly severity?: NotificationSeverity;
|
|
32
|
+
}
|
|
33
|
+
/** Status filter of the notice list (notification-center SPEC §10). Absent ⇒ not archived. */
|
|
34
|
+
export declare const NOTIFICATION_STATUSES: readonly ["unread", "read", "archived"];
|
|
35
|
+
export type NotificationStatus = (typeof NOTIFICATION_STATUSES)[number];
|
|
36
|
+
/** Bulk actions (notification-center SPEC §10); 1–100 uuids per call. */
|
|
37
|
+
export declare const NOTIFICATION_BULK_ACTIONS: readonly ["read", "unread", "archive", "unarchive"];
|
|
38
|
+
export type NotificationBulkAction = (typeof NOTIFICATION_BULK_ACTIONS)[number];
|
|
39
|
+
export declare const NOTIFICATION_BULK_MAX = 100;
|
|
40
|
+
/** One distinct type the user has notices of (`listKinds`). */
|
|
41
|
+
export interface NotificationKindSummary {
|
|
42
|
+
readonly kind: string;
|
|
43
|
+
readonly category: NotificationCategory;
|
|
18
44
|
}
|
|
19
45
|
/** A stored notice as the store returns it (no tenant id, user id or dedupe key). */
|
|
20
46
|
export interface NotificationRow {
|
|
@@ -27,6 +53,8 @@ export interface NotificationRow {
|
|
|
27
53
|
readonly createdAtMs: number;
|
|
28
54
|
/** `null` ⇒ unread. */
|
|
29
55
|
readonly readAtMs: number | null;
|
|
56
|
+
/** `null` ⇒ not archived. An archived notice is always read. */
|
|
57
|
+
readonly archivedAtMs: number | null;
|
|
30
58
|
}
|
|
31
59
|
/** A row to insert; every field already validated and server-stamped by the service. */
|
|
32
60
|
export interface NotificationInsert {
|
|
@@ -44,7 +72,18 @@ export interface NotificationInsert {
|
|
|
44
72
|
export interface NotificationListQuery {
|
|
45
73
|
/** Absent ⇒ both categories. */
|
|
46
74
|
readonly category?: NotificationCategory;
|
|
75
|
+
/** The dropdown's filter: unread (and so never archived) only. */
|
|
47
76
|
readonly unreadOnly: boolean;
|
|
77
|
+
/** Absent ⇒ every kind. */
|
|
78
|
+
readonly kind?: string;
|
|
79
|
+
/** Absent ⇒ not archived; `unread` / `read` also leave archived notices out. */
|
|
80
|
+
readonly status?: NotificationStatus;
|
|
81
|
+
/** Inclusive lower bound on the creation time (epoch ms). */
|
|
82
|
+
readonly fromMs?: number;
|
|
83
|
+
/** Inclusive upper bound on the creation time (epoch ms). */
|
|
84
|
+
readonly toMs?: number;
|
|
85
|
+
/** Plain text matched inside title or body (the store escapes `LIKE` wildcards); non-empty. */
|
|
86
|
+
readonly search?: string;
|
|
48
87
|
/** ≥ 1. */
|
|
49
88
|
readonly page: number;
|
|
50
89
|
/** 1–100. */
|
|
@@ -72,10 +111,21 @@ export interface NotificationWriteOptions {
|
|
|
72
111
|
/** The persistence port; `MariaDbNotificationStore` is the framework default. */
|
|
73
112
|
export interface NotificationStore {
|
|
74
113
|
list(userId: string, tenantId: string, query: NotificationListQuery): Promise<NotificationListResult>;
|
|
114
|
+
/** Unread, not archived, per category. */
|
|
75
115
|
countUnread(userId: string, tenantId: string): Promise<NotificationUnreadCounts>;
|
|
116
|
+
/** The distinct `(kind, category)` pairs of this user's notices in this tenant. */
|
|
117
|
+
listKinds(userId: string, tenantId: string): Promise<readonly NotificationKindSummary[]>;
|
|
76
118
|
/** `true` when the notice exists for this user in this tenant (read already or now). */
|
|
77
119
|
markRead(userId: string, tenantId: string, uuid: string, nowMs: number): Promise<boolean>;
|
|
78
|
-
/**
|
|
120
|
+
/** `true` when the notice exists for this user in this tenant (an archived one stays read). */
|
|
121
|
+
markUnread(userId: string, tenantId: string, uuid: string): Promise<boolean>;
|
|
122
|
+
/** `true` when the notice exists for this user in this tenant; also marks it read. */
|
|
123
|
+
archive(userId: string, tenantId: string, uuid: string, nowMs: number): Promise<boolean>;
|
|
124
|
+
/** `true` when the notice exists for this user in this tenant; it comes back as read. */
|
|
125
|
+
unarchive(userId: string, tenantId: string, uuid: string): Promise<boolean>;
|
|
126
|
+
/** One action on 1–100 of this user's notices in this tenant ⇒ the number changed. */
|
|
127
|
+
bulk(userId: string, tenantId: string, action: NotificationBulkAction, uuids: readonly string[], nowMs: number): Promise<number>;
|
|
128
|
+
/** Number of notices changed from unread to read (archived ones are skipped). */
|
|
79
129
|
markAllRead(userId: string, tenantId: string, category: NotificationCategory | undefined, nowMs: number): Promise<number>;
|
|
80
130
|
/** Inserted count; a repeated dedupe key is a no-op, not an error. */
|
|
81
131
|
insertMany(rows: readonly NotificationInsert[], opts?: NotificationWriteOptions): Promise<number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/notifications/ports.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/notifications/ports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,iGAAiG;AACjG,eAAO,MAAM,uBAAuB,uCAAwC,CAAC;AAC7E,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5E,4FAA4F;AAC5F,eAAO,MAAM,uBAAuB,yCAA0C,CAAC;AAC/E,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5E,0FAA0F;AAC1F,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC,4FAA4F;AAC5F,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;IACxC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,sBAAsB;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CAC1C;AAED,8FAA8F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,SAAQ,KAAK;IACrD,SAAkB,IAAI,kCAAkC;;CAIzD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Notification store contract (G-027 step 2, notification-store SPEC §5A, §5B, §10
|
|
3
|
+
* Notification store contract (G-027 step 2, notification-store SPEC §5A, §5B, §10; G-035
|
|
4
|
+
* notification-center SPEC §5A, §5B: kind label / severity, list filters, unread, archive, bulk).
|
|
4
5
|
*
|
|
5
6
|
* One per-user, tenant-walled inbox in `<ns>_identity.user_notification` (identity migration
|
|
6
7
|
* 108). Every per-user statement is scoped by BOTH the user and the tenant (the session's active
|
|
@@ -10,9 +11,18 @@
|
|
|
10
11
|
* Errors carry the FIELD, kind or variable name only, never a submitted value (core 50 #10).
|
|
11
12
|
*/
|
|
12
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.NotificationUnavailableError = exports.NotificationValidationError = exports.NotificationKindError = exports.NOTIFICATION_KIND_MAX_LENGTH = exports.NOTIFICATION_KIND_PATTERN = exports.NOTIFICATION_CATEGORIES = void 0;
|
|
14
|
+
exports.NotificationUnavailableError = exports.NotificationValidationError = exports.NotificationKindError = exports.NOTIFICATION_KIND_MAX_LENGTH = exports.NOTIFICATION_KIND_PATTERN = exports.NOTIFICATION_BULK_MAX = exports.NOTIFICATION_BULK_ACTIONS = exports.NOTIFICATION_STATUSES = exports.NOTIFICATION_LABEL_MAX = exports.NOTIFICATION_SEVERITIES = exports.NOTIFICATION_CATEGORIES = void 0;
|
|
14
15
|
/** The two inbox categories (SPEC §10). The category always comes from the kind registration. */
|
|
15
16
|
exports.NOTIFICATION_CATEGORIES = ['announcement', 'personal'];
|
|
17
|
+
/** How a notice type is marked in the UI (notification-center SPEC §10); default `info`. */
|
|
18
|
+
exports.NOTIFICATION_SEVERITIES = ['info', 'success', 'warning'];
|
|
19
|
+
/** The longest label (code points) an app may register (notification-center SPEC §5A). */
|
|
20
|
+
exports.NOTIFICATION_LABEL_MAX = 40;
|
|
21
|
+
/** Status filter of the notice list (notification-center SPEC §10). Absent ⇒ not archived. */
|
|
22
|
+
exports.NOTIFICATION_STATUSES = ['unread', 'read', 'archived'];
|
|
23
|
+
/** Bulk actions (notification-center SPEC §10); 1–100 uuids per call. */
|
|
24
|
+
exports.NOTIFICATION_BULK_ACTIONS = ['read', 'unread', 'archive', 'unarchive'];
|
|
25
|
+
exports.NOTIFICATION_BULK_MAX = 100;
|
|
16
26
|
/** Kind pattern (SPEC §10): dotted lower-case segments, at least two. */
|
|
17
27
|
exports.NOTIFICATION_KIND_PATTERN = /^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$/;
|
|
18
28
|
exports.NOTIFICATION_KIND_MAX_LENGTH = 64;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strict session liveness (G-036 M1, agent-read-capabilities SPEC §5 guard section, §10 step 1).
|
|
3
|
+
*
|
|
4
|
+
* `check(sessionId, tenantId)` answers whether a session is still live, still acting on `tenantId`
|
|
5
|
+
* and unrestricted, from ONE Redis `GET shield:sessclaims:<sessionId>` (the liveness entry the
|
|
6
|
+
* {@link import('../request-auth/session-token-binder.js').SessionTokenBinder} writes at login and
|
|
7
|
+
* deletes on logout, admin end-sessions and the disable sweep). Unlike the binder's
|
|
8
|
+
* `sessionTenant()`, which swallows errors into `null`, every failure here is `'unavailable'`, so a
|
|
9
|
+
* caller can fail closed (Shield #1) instead of reading an outage as "ended".
|
|
10
|
+
*
|
|
11
|
+
* - entry missing ⇒ `'ended'`
|
|
12
|
+
* - Redis error, unparseable or malformed entry ⇒ `'unavailable'`
|
|
13
|
+
* - entry tenant ≠ `canonicalUuid(tenantId)` ⇒ `'tenant_changed'` (scope switch)
|
|
14
|
+
* - `restrictionOf(claims, now) !== null` ⇒ `'restricted'` (the guard's own rule, grace
|
|
15
|
+
* deadline included)
|
|
16
|
+
* - otherwise ⇒ `'live'`
|
|
17
|
+
*
|
|
18
|
+
* Used inside a handler (the agent executor), never on the guard's per-request path: it adds no read
|
|
19
|
+
* there (Shield #12). Exported on `@astram/guard/internal` only.
|
|
20
|
+
*/
|
|
21
|
+
import type Redis from 'ioredis';
|
|
22
|
+
export type SessionLivenessState = 'live' | 'ended' | 'tenant_changed' | 'restricted' | 'unavailable';
|
|
23
|
+
/** The port behind `SHIELD_SESSION_LIVENESS`. Never throws. */
|
|
24
|
+
export interface SessionLiveness {
|
|
25
|
+
check(sessionId: string, tenantId: string): Promise<SessionLivenessState>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The session-claims key prefix. Must equal the binder's private `SESS_CLAIMS_PREFIX`; the spec
|
|
29
|
+
* proves it by binding a session through the real binder and reading it back here.
|
|
30
|
+
*/
|
|
31
|
+
export declare const SESSION_CLAIMS_KEY_PREFIX = "shield:sessclaims:";
|
|
32
|
+
/** The Redis client surface the check uses (one `get`). */
|
|
33
|
+
type RedisGet = Pick<Redis, 'get'>;
|
|
34
|
+
export declare class RedisSessionLiveness implements SessionLiveness {
|
|
35
|
+
private readonly redis;
|
|
36
|
+
private readonly now;
|
|
37
|
+
constructor(redis: RedisGet, now?: () => number);
|
|
38
|
+
check(sessionId: string, tenantId: string): Promise<SessionLivenessState>;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=session-liveness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-liveness.d.ts","sourceRoot":"","sources":["../../src/session/session-liveness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAIjC,MAAM,MAAM,oBAAoB,GAC9B,MAAM,GAAG,OAAO,GAAG,gBAAgB,GAAG,YAAY,GAAG,aAAa,CAAC;AAErE,+DAA+D;AAC/D,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAC3E;AAED;;;GAGG;AACH,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAE9D,2DAA2D;AAC3D,KAAK,QAAQ,GAAG,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAEnC,qBAAa,oBAAqB,YAAW,eAAe;IAExD,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,GAAG;gBADH,KAAK,EAAE,QAAQ,EACf,GAAG,GAAE,MAAM,MAAiB;IAGzC,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;CA+ChF"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedisSessionLiveness = exports.SESSION_CLAIMS_KEY_PREFIX = void 0;
|
|
4
|
+
const engine_1 = require("@astram/engine");
|
|
5
|
+
const session_restriction_js_1 = require("./session-restriction.js");
|
|
6
|
+
/**
|
|
7
|
+
* The session-claims key prefix. Must equal the binder's private `SESS_CLAIMS_PREFIX`; the spec
|
|
8
|
+
* proves it by binding a session through the real binder and reading it back here.
|
|
9
|
+
*/
|
|
10
|
+
exports.SESSION_CLAIMS_KEY_PREFIX = 'shield:sessclaims:';
|
|
11
|
+
class RedisSessionLiveness {
|
|
12
|
+
redis;
|
|
13
|
+
now;
|
|
14
|
+
constructor(redis, now = Date.now) {
|
|
15
|
+
this.redis = redis;
|
|
16
|
+
this.now = now;
|
|
17
|
+
}
|
|
18
|
+
async check(sessionId, tenantId) {
|
|
19
|
+
// A service-account principal has no session id: nothing to look up, and never live.
|
|
20
|
+
if (typeof sessionId !== 'string' || sessionId === '')
|
|
21
|
+
return 'ended';
|
|
22
|
+
let raw;
|
|
23
|
+
try {
|
|
24
|
+
raw = await this.redis.get(`${exports.SESSION_CLAIMS_KEY_PREFIX}${sessionId}`);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return 'unavailable';
|
|
28
|
+
}
|
|
29
|
+
if (raw === null)
|
|
30
|
+
return 'ended';
|
|
31
|
+
let parsed;
|
|
32
|
+
try {
|
|
33
|
+
parsed = JSON.parse(raw);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return 'unavailable';
|
|
37
|
+
}
|
|
38
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
39
|
+
return 'unavailable';
|
|
40
|
+
}
|
|
41
|
+
const claims = parsed;
|
|
42
|
+
const bound = (0, engine_1.canonicalUuid)(claims.tenantId);
|
|
43
|
+
if (bound === null)
|
|
44
|
+
return 'unavailable';
|
|
45
|
+
const wanted = (0, engine_1.canonicalUuid)(tenantId);
|
|
46
|
+
if (wanted === null || wanted !== bound)
|
|
47
|
+
return 'tenant_changed';
|
|
48
|
+
const input = {
|
|
49
|
+
mustReenroll: claims.mustReenroll === true,
|
|
50
|
+
...(claims.restriction !== undefined
|
|
51
|
+
? { restriction: claims.restriction }
|
|
52
|
+
: {}),
|
|
53
|
+
...(claims.mfaEnrollmentDeadlineMs !== undefined
|
|
54
|
+
? {
|
|
55
|
+
mfaEnrollmentDeadlineMs: claims.mfaEnrollmentDeadlineMs,
|
|
56
|
+
}
|
|
57
|
+
: {}),
|
|
58
|
+
};
|
|
59
|
+
const restriction = (0, session_restriction_js_1.restrictionOf)(input, this.now());
|
|
60
|
+
return restriction === null ? 'live' : 'restricted';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.RedisSessionLiveness = RedisSessionLiveness;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astram/guard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Astram framework — the enforcement guard + real-world adapters (the 'hands'). One global deny-by-default gate every request passes through (ADR-0002), classification decorators, boot-pool assertion (ADR-0018), the forRoot() registration seam, and the DB/Redis/crypto adapters that connect the sealed core to a real backend. Depends on @astram/core (ADR-0003, ADR-0023).",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"argon2": "^0.41.1",
|
|
37
37
|
"ioredis": "^5.4.1",
|
|
38
38
|
"mariadb": "^3.5.4",
|
|
39
|
-
"@astram/core": "1.
|
|
40
|
-
"@astram/engine": "0.
|
|
39
|
+
"@astram/core": "1.15.0",
|
|
40
|
+
"@astram/engine": "0.17.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@nestjs/common": "^11",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@nestjs/platform-express": "^11",
|
|
46
46
|
"reflect-metadata": "^0.2",
|
|
47
47
|
"rxjs": "^7",
|
|
48
|
-
"@astram/messaging": "^0.1.
|
|
48
|
+
"@astram/messaging": "^0.1.14"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|
|
51
51
|
"@astram/messaging": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"typescript": "^5.7.0",
|
|
69
69
|
"unplugin-swc": "^1.5.1",
|
|
70
70
|
"vitest": "^2.1.8",
|
|
71
|
-
"@astram/messaging": "0.1.
|
|
71
|
+
"@astram/messaging": "0.1.14"
|
|
72
72
|
},
|
|
73
73
|
"repository": {
|
|
74
74
|
"type": "git",
|