@nauth-toolkit/core 0.1.65 → 0.1.67
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/dto/forgot-password.dto.d.ts +23 -0
- package/dist/dto/forgot-password.dto.d.ts.map +1 -1
- package/dist/dto/forgot-password.dto.js +35 -0
- package/dist/dto/forgot-password.dto.js.map +1 -1
- package/dist/interfaces/config.interface.d.ts +16 -45
- package/dist/interfaces/config.interface.d.ts.map +1 -1
- package/dist/interfaces/provider.interface.d.ts +7 -2
- package/dist/interfaces/provider.interface.d.ts.map +1 -1
- package/dist/interfaces/storage-adapter.interface.d.ts +12 -1
- package/dist/interfaces/storage-adapter.interface.d.ts.map +1 -1
- package/dist/schemas/auth-config.schema.d.ts +11 -43
- package/dist/schemas/auth-config.schema.d.ts.map +1 -1
- package/dist/schemas/auth-config.schema.js +2 -5
- package/dist/schemas/auth-config.schema.js.map +1 -1
- package/dist/services/auth-service-internal-helpers.d.ts.map +1 -1
- package/dist/services/auth-service-internal-helpers.js +2 -1
- package/dist/services/auth-service-internal-helpers.js.map +1 -1
- package/dist/services/auth.service.d.ts.map +1 -1
- package/dist/services/auth.service.js +3 -1
- package/dist/services/auth.service.js.map +1 -1
- package/dist/services/password-reset.service.d.ts +4 -1
- package/dist/services/password-reset.service.d.ts.map +1 -1
- package/dist/services/password-reset.service.js +17 -6
- package/dist/services/password-reset.service.js.map +1 -1
- package/dist/storage/account-lockout-storage.service.d.ts +2 -1
- package/dist/storage/account-lockout-storage.service.d.ts.map +1 -1
- package/dist/storage/account-lockout-storage.service.js +12 -2
- package/dist/storage/account-lockout-storage.service.js.map +1 -1
- package/package.json +1 -1
|
@@ -17,11 +17,12 @@ class AccountLockoutStorageService {
|
|
|
17
17
|
/**
|
|
18
18
|
* Record failed login attempt for an IP address
|
|
19
19
|
* @param ipAddress - IP address that made the failed attempt
|
|
20
|
+
* @param ttlSeconds - Optional TTL (seconds) for the attempt counter window
|
|
20
21
|
* @returns Number of failed attempts for this IP
|
|
21
22
|
*/
|
|
22
|
-
async recordFailedAttempt(ipAddress) {
|
|
23
|
+
async recordFailedAttempt(ipAddress, ttlSeconds) {
|
|
23
24
|
const key = this.getKey(ipAddress);
|
|
24
|
-
return await this.storageAdapter.incr(key);
|
|
25
|
+
return await this.storageAdapter.incr(key, ttlSeconds);
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
27
28
|
* Get failed attempts count for an IP address
|
|
@@ -56,6 +57,15 @@ class AccountLockoutStorageService {
|
|
|
56
57
|
lockedUntil: new Date(Date.now() + duration * 1000).toISOString(),
|
|
57
58
|
});
|
|
58
59
|
await this.storageAdapter.set(lockKey, lockData, duration);
|
|
60
|
+
// ============================================================================
|
|
61
|
+
// IMPORTANT: Reset attempt counter on lock
|
|
62
|
+
// ============================================================================
|
|
63
|
+
// WHY:
|
|
64
|
+
// - Without this, a user can remain at/above maxAttempts and get re-locked immediately
|
|
65
|
+
// once the lock TTL expires (especially when attempt counters are long-lived).
|
|
66
|
+
// - Lock duration is the penalty window; after it expires, users should get a fresh
|
|
67
|
+
// attempt budget within the next attempt window.
|
|
68
|
+
await this.resetFailedAttempts(ipAddress);
|
|
59
69
|
}
|
|
60
70
|
/**
|
|
61
71
|
* Unlock an IP address and reset failed attempts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-lockout-storage.service.js","sourceRoot":"","sources":["../../src/storage/account-lockout-storage.service.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,MAAa,4BAA4B;IAIV;IAHZ,SAAS,GAAG,mBAAmB,CAAC;IAChC,aAAa,GAAG,kBAAkB,CAAC;IAEpD,YAA6B,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;IAAG,CAAC;IAE/D
|
|
1
|
+
{"version":3,"file":"account-lockout-storage.service.js","sourceRoot":"","sources":["../../src/storage/account-lockout-storage.service.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,MAAa,4BAA4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