dms-middleware-auth 1.1.9 → 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.
@@ -366,10 +366,10 @@ let AuthMiddleware = AuthMiddleware_1 = class AuthMiddleware {
366
366
  async cacheSetSeconds(key, value, _ttlSeconds) {
367
367
  try {
368
368
  // Force a consistent one-day TTL in seconds; clamp to avoid 32-bit timer overflow even if a store multiplies by 1000
369
- const safeTtlSeconds = Math.min(AuthMiddleware_1.LIC_CACHE_TTL_SECONDS, Math.floor(2_147_483_647 / 1000) - 1 // ~24.8 days ceiling
370
- );
371
- await this.cacheManager.set(key, value, safeTtlSeconds);
372
- this.logger.debug(`Cache set: ${key} (TTL: ${safeTtlSeconds}s)`);
369
+ // Use a simple, safe 24-hour TTL; 86,400s (86,400,000ms if misread as ms) is far below the Node timer limit.
370
+ const ttlSeconds = AuthMiddleware_1.LIC_CACHE_TTL_SECONDS; // 24 * 60 * 60
371
+ await this.cacheManager.set(key, value, ttlSeconds);
372
+ this.logger.debug(`Cache set: ${key} (TTL: ${ttlSeconds}s)`);
373
373
  }
374
374
  catch (e) {
375
375
  this.logger.error(`Cache set failed for key=${key}: ${e?.message || e}`, e?.stack);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dms-middleware-auth",
3
- "version": "1.1.9",
3
+ "version": "1.2.0",
4
4
  "description": "Reusable middleware for authentication and authorization in NestJS applications.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -440,18 +440,15 @@ export class AuthMiddleware implements NestMiddleware, OnModuleInit {
440
440
  // -------------------------
441
441
  // Cache helper with overflow protection
442
442
  // -------------------------
443
- private async cacheSetSeconds(key: string, value: any, _ttlSeconds: number) {
444
- try {
445
- // Force a consistent one-day TTL in seconds; clamp to avoid 32-bit timer overflow even if a store multiplies by 1000
446
- const safeTtlSeconds = Math.min(
447
- AuthMiddleware.LIC_CACHE_TTL_SECONDS,
448
- Math.floor(2_147_483_647 / 1000) - 1 // ~24.8 days ceiling
449
- );
450
-
451
- await this.cacheManager.set(key, value, safeTtlSeconds);
452
- this.logger.debug(`Cache set: ${key} (TTL: ${safeTtlSeconds}s)`);
453
- } catch (e: any) {
454
- this.logger.error(`Cache set failed for key=${key}: ${e?.message || e}`, e?.stack);
455
- }
456
- }
457
- }
443
+ private async cacheSetSeconds(key: string, value: any, _ttlSeconds: number) {
444
+ try {
445
+ // Force a consistent one-day TTL in seconds; clamp to avoid 32-bit timer overflow even if a store multiplies by 1000
446
+ // Use a simple, safe 24-hour TTL; 86,400s (86,400,000ms if misread as ms) is far below the Node timer limit.
447
+ const ttlSeconds = AuthMiddleware.LIC_CACHE_TTL_SECONDS; // 24 * 60 * 60
448
+ await this.cacheManager.set(key, value, ttlSeconds);
449
+ this.logger.debug(`Cache set: ${key} (TTL: ${ttlSeconds}s)`);
450
+ } catch (e: any) {
451
+ this.logger.error(`Cache set failed for key=${key}: ${e?.message || e}`, e?.stack);
452
+ }
453
+ }
454
+ }