@ahhaohho/auth-middleware 2.3.3 → 2.3.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahhaohho/auth-middleware",
3
- "version": "2.3.3",
3
+ "version": "2.3.4",
4
4
  "description": "Shared authentication and authorization middleware for ahhaohho microservices",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,6 +1,15 @@
1
1
  const { SecretsManagerClient, GetSecretValueCommand } = require('@aws-sdk/client-secrets-manager');
2
2
  const redisManager = require('../config/redis');
3
3
 
4
+ // NODE_ENV 검증 (모듈 로드 시 1회)
5
+ const JWT_KEY_ENV = process.env.NODE_ENV;
6
+ if (!JWT_KEY_ENV || !['development', 'staging', 'production'].includes(JWT_KEY_ENV)) {
7
+ console.warn(
8
+ `[@ahhaohho/auth-middleware] NODE_ENV="${JWT_KEY_ENV || ''}" is not explicitly set. JWT keys will default to "dev".`
9
+ );
10
+ }
11
+ console.log(`[@ahhaohho/auth-middleware] JWT key environment: ${JWT_KEY_ENV || 'dev (default)'}`);
12
+
4
13
  /**
5
14
  * NODE_ENV에 따라 시크릿에서 올바른 키를 선택
6
15
  * Secret 구조: { dev: "...", staging: "...", prod: "..." }
@@ -8,9 +17,8 @@ const redisManager = require('../config/redis');
8
17
  * @returns {string|undefined}
9
18
  */
10
19
  function resolveKeyByEnv(secret) {
11
- const env = process.env.NODE_ENV;
12
- if (env === 'production') return secret.prod;
13
- if (env === 'staging') return secret.staging;
20
+ if (JWT_KEY_ENV === 'production') return secret.prod;
21
+ if (JWT_KEY_ENV === 'staging') return secret.staging;
14
22
  return secret.dev;
15
23
  }
16
24