nucleus-core-ts 0.9.730 → 0.9.731
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.
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared, fail-closed account-state kill-switch for EVERY token-minting auth path
|
|
3
|
+
* (password login, OAuth callback, magic-link verify, WebAuthn, refresh). A locked or
|
|
4
|
+
* deactivated account must not be able to obtain a fresh access/refresh token or session
|
|
5
|
+
* through ANY path — otherwise an admin's lock/deactivation is trivially bypassed by simply
|
|
6
|
+
* logging in again via a different mechanism. Centralized here so the invariant can't drift
|
|
7
|
+
* out of sync between handlers again.
|
|
8
|
+
*
|
|
9
|
+
* Semantics mirror the canonical refresh check (routes/auth/refresh):
|
|
10
|
+
* - `isActive === false` → denied (admin deactivation). Absent/undefined isActive is NOT a
|
|
11
|
+
* denial, so deployments without the column keep working (fail-open only on absence).
|
|
12
|
+
* - `isLocked === true` AND the lock has NOT expired (`lockedUntil` null or in the future)
|
|
13
|
+
* → denied. A past `lockedUntil` means the lock lapsed and no longer blocks.
|
|
14
|
+
*
|
|
15
|
+
* Cohort-expiry is intentionally NOT handled here: it needs a separate table lookup and is
|
|
16
|
+
* enforced per-path where cohorts apply (login/refresh).
|
|
17
|
+
*/
|
|
18
|
+
export interface AccountStateFields {
|
|
19
|
+
isActive?: unknown;
|
|
20
|
+
isLocked?: unknown;
|
|
21
|
+
lockedUntil?: unknown;
|
|
22
|
+
}
|
|
23
|
+
export type AccountStateResult = {
|
|
24
|
+
allowed: true;
|
|
25
|
+
} | {
|
|
26
|
+
allowed: false;
|
|
27
|
+
reason: 'inactive' | 'locked';
|
|
28
|
+
message: string;
|
|
29
|
+
};
|
|
30
|
+
export declare function evaluateAccountState(user: AccountStateFields, now?: Date): AccountStateResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nucleus-core-ts",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.731",
|
|
4
4
|
"description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
|
|
5
5
|
"author": "Hidayet Can Özcan <hidayetcan@gmail.com>",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|