@zudojs/auth 1.0.0 → 1.2.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/README.md +54 -10
- package/dist/authErrors/authError.base.d.ts +6 -25
- package/dist/authErrors/authError.base.js +6 -20
- package/dist/authPassword/authPassword.core.d.ts +17 -29
- package/dist/authPassword/authPassword.core.js +33 -119
- package/dist/authPassword/authPassword.legacy.d.ts +21 -0
- package/dist/authPassword/authPassword.legacy.js +85 -0
- package/dist/authPassword/authPassword.policy.d.ts +30 -0
- package/dist/authPassword/authPassword.policy.js +30 -0
- package/dist/authPassword/authPassword.rehash.d.ts +15 -0
- package/dist/authPassword/authPassword.rehash.js +33 -0
- package/dist/authPassword/index.d.ts +3 -1
- package/dist/authPassword/index.js +3 -1
- package/dist/authProvider/authAttempt.eviction.d.ts +26 -0
- package/dist/authProvider/authAttempt.eviction.js +37 -0
- package/dist/authProvider/authAttempt.memory.d.ts +9 -0
- package/dist/authProvider/authAttempt.memory.js +22 -5
- package/dist/authProvider/authProvider.core.d.ts +13 -0
- package/dist/authProvider/authProvider.core.js +23 -45
- package/dist/authProvider/authProvider.throttle.d.ts +52 -0
- package/dist/authProvider/authProvider.throttle.js +88 -0
- package/dist/authSession/authSession.core.d.ts +7 -0
- package/dist/authSession/authSession.core.js +25 -4
- package/dist/authToken/authToken.core.d.ts +6 -0
- package/dist/authToken/authToken.core.js +8 -0
- package/dist/authToken/authToken.signing.d.ts +5 -0
- package/dist/authToken/authToken.signing.js +22 -2
- package/dist/authTypes/authAttempt.type.d.ts +18 -6
- package/dist/authUtils/authUtils.helper.d.ts +4 -0
- package/dist/authUtils/authUtils.helper.js +4 -0
- package/package.json +9 -4
|
@@ -17,9 +17,11 @@ export interface LoginAttemptRecord {
|
|
|
17
17
|
/**
|
|
18
18
|
* Store backing failed-attempt lockout and login rate limiting.
|
|
19
19
|
*
|
|
20
|
-
* Keys are the *submitted* identifier
|
|
21
|
-
*
|
|
22
|
-
* of
|
|
20
|
+
* Keys are the *submitted* identifier — trimmed, NFKC-normalised and
|
|
21
|
+
* lower-cased by `createAuthService()` so that case and whitespace variants
|
|
22
|
+
* of one email share a budget — not a resolved user id, so unknown and
|
|
23
|
+
* known accounts are throttled identically and the endpoint stays free of
|
|
24
|
+
* an existence oracle. The in-memory implementation
|
|
23
25
|
* (`createMemoryLoginAttemptStore`) is per-process; back this with Redis to
|
|
24
26
|
* make limits hold across instances.
|
|
25
27
|
*/
|
|
@@ -28,7 +30,11 @@ export interface LoginAttemptStore {
|
|
|
28
30
|
get(identifier: string): Promise<LoginAttemptRecord>;
|
|
29
31
|
/** Count an attempt (before credentials are checked). */
|
|
30
32
|
recordAttempt(identifier: string): Promise<LoginAttemptRecord>;
|
|
31
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Count a failed authentication. Must be atomic: `createAuthService()`
|
|
35
|
+
* reserves a failure *before* checking the password and relies on
|
|
36
|
+
* concurrent calls seeing distinct, increasing counts.
|
|
37
|
+
*/
|
|
32
38
|
recordFailure(identifier: string): Promise<LoginAttemptRecord>;
|
|
33
39
|
/** Lock an identifier until `until` (Unix milliseconds). */
|
|
34
40
|
lock(identifier: string, until: number): Promise<void>;
|
|
@@ -50,8 +56,14 @@ export interface LoginThrottleConfig {
|
|
|
50
56
|
readonly lockoutSeconds?: number;
|
|
51
57
|
/**
|
|
52
58
|
* Attempts allowed per identifier inside the store's rate-limit window
|
|
53
|
-
* (default: 20). Exceeding it throws `AuthRateLimitError`.
|
|
54
|
-
*
|
|
59
|
+
* (default: 20). Exceeding it throws `AuthRateLimitError`.
|
|
60
|
+
*
|
|
61
|
+
* This is a *per-identifier* budget: it bounds the password guesses
|
|
62
|
+
* against one account, not the scrypt work the server can be made to do.
|
|
63
|
+
* Every new identifier starts with a fresh budget, and unknown identifiers
|
|
64
|
+
* still burn a full scrypt verification, so an attacker rotating
|
|
65
|
+
* identifiers is not limited by it. Put a per-IP limiter (for example
|
|
66
|
+
* `createRateLimiter` from `@zudojs/security`) in front of `login()`.
|
|
55
67
|
*/
|
|
56
68
|
readonly maxAttemptsPerWindow?: number;
|
|
57
69
|
/**
|
|
@@ -55,6 +55,10 @@ export declare function extractUserId(token: unknown): string | null;
|
|
|
55
55
|
/**
|
|
56
56
|
* Generate a CSRF token.
|
|
57
57
|
*
|
|
58
|
+
* @deprecated This returns an unbound random value that nothing in the
|
|
59
|
+
* framework can validate. Use `generateCsrfToken` / `validateCsrfToken`
|
|
60
|
+
* (or `createCsrfProtection`) from `@zudojs/security`, which produce
|
|
61
|
+
* session-bound, HMAC-signed tokens.
|
|
58
62
|
* @returns Random hex string for CSRF protection
|
|
59
63
|
*/
|
|
60
64
|
export declare function generateCsrfToken(): string;
|
|
@@ -115,6 +115,10 @@ export function extractUserId(token) {
|
|
|
115
115
|
/**
|
|
116
116
|
* Generate a CSRF token.
|
|
117
117
|
*
|
|
118
|
+
* @deprecated This returns an unbound random value that nothing in the
|
|
119
|
+
* framework can validate. Use `generateCsrfToken` / `validateCsrfToken`
|
|
120
|
+
* (or `createCsrfProtection`) from `@zudojs/security`, which produce
|
|
121
|
+
* session-bound, HMAC-signed tokens.
|
|
118
122
|
* @returns Random hex string for CSRF protection
|
|
119
123
|
*/
|
|
120
124
|
export function generateCsrfToken() {
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zudojs/auth",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Authentication and authorization services for the Zudojs framework — JWT, sessions, RBAC, and password management.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Oluwayemi Oyinlola",
|
|
8
|
+
"url": "https://github.com/oyinlola-tech"
|
|
9
|
+
},
|
|
6
10
|
"type": "module",
|
|
7
11
|
"main": "./dist/index.js",
|
|
8
12
|
"module": "./dist/index.js",
|
|
@@ -21,9 +25,10 @@
|
|
|
21
25
|
"!dist/.tsbuildinfo"
|
|
22
26
|
],
|
|
23
27
|
"dependencies": {
|
|
24
|
-
"@zudojs/
|
|
25
|
-
"@zudojs/
|
|
26
|
-
"@zudojs/
|
|
28
|
+
"@zudojs/constants": "1.1.0",
|
|
29
|
+
"@zudojs/crypto": "1.2.0",
|
|
30
|
+
"@zudojs/errors": "1.1.0",
|
|
31
|
+
"@zudojs/permissions": "1.2.0"
|
|
27
32
|
},
|
|
28
33
|
"engines": {
|
|
29
34
|
"node": ">=24.0.0"
|