@ahhaohho/auth-middleware 2.3.4 → 2.3.5

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,32 @@
1
+ name: Publish to npm
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ publish:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - name: Checkout code
15
+ uses: actions/checkout@v4
16
+
17
+ - name: Setup Node.js
18
+ uses: actions/setup-node@v4
19
+ with:
20
+ node-version: '22'
21
+ registry-url: 'https://registry.npmjs.org'
22
+
23
+ - name: Install dependencies
24
+ run: npm ci
25
+
26
+ - name: Build
27
+ run: npm run build
28
+
29
+ - name: Publish
30
+ run: npm publish
31
+ env:
32
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahhaohho/auth-middleware",
3
- "version": "2.3.4",
3
+ "version": "2.3.5",
4
4
  "description": "Shared authentication and authorization middleware for ahhaohho microservices",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -77,31 +77,28 @@ class SecretManager {
77
77
  }
78
78
 
79
79
  const secret = JSON.parse(response.SecretString);
80
- const currentKey = secret.current || secret.jwt_secret_key || resolveKeyByEnv(secret);
81
-
82
- // previous 결정: secret previous 필드 → AWSPREVIOUS 버전 순서
83
- let previousKey = secret.previous || null;
84
-
85
- if (!previousKey) {
86
- try {
87
- const prevCommand = new GetSecretValueCommand({
88
- SecretId: this.secretName,
89
- VersionStage: 'AWSPREVIOUS'
90
- });
91
- const prevResponse = await this.client.send(prevCommand);
92
- if (prevResponse.SecretString) {
93
- const prevSecret = JSON.parse(prevResponse.SecretString);
94
- const prevCandidate = prevSecret.current || prevSecret.jwt_secret_key || resolveKeyByEnv(prevSecret);
95
- // 이전 키가 현재 키와 다를 때만 사용
96
- if (prevCandidate && prevCandidate !== currentKey) {
97
- previousKey = prevCandidate;
98
- console.log('[@ahhaohho/auth-middleware] Using AWSPREVIOUS version as fallback key');
99
- }
80
+ const currentKey = resolveKeyByEnv(secret);
81
+
82
+ // 이전 키: AWSPREVIOUS에서 환경별 가져오기
83
+ let previousKey = null;
84
+ try {
85
+ const prevCommand = new GetSecretValueCommand({
86
+ SecretId: this.secretName,
87
+ VersionStage: 'AWSPREVIOUS'
88
+ });
89
+ const prevResponse = await this.client.send(prevCommand);
90
+ if (prevResponse.SecretString) {
91
+ const prevSecret = JSON.parse(prevResponse.SecretString);
92
+ const prevCandidate = resolveKeyByEnv(prevSecret);
93
+ // 이전 키가 현재 키와 다를 때만 사용
94
+ if (prevCandidate && prevCandidate !== currentKey) {
95
+ previousKey = prevCandidate;
96
+ console.log('[@ahhaohho/auth-middleware] Using AWSPREVIOUS version as fallback key');
100
97
  }
101
- } catch (prevError) {
102
- // AWSPREVIOUS가 없을 수 있음 (첫 시크릿이거나 로테이션 미사용)
103
- console.log('[@ahhaohho/auth-middleware] No AWSPREVIOUS version available');
104
98
  }
99
+ } catch (prevError) {
100
+ // AWSPREVIOUS가 없을 수 있음 (첫 시크릿이거나 로테이션 미사용)
101
+ console.log('[@ahhaohho/auth-middleware] No AWSPREVIOUS version available');
105
102
  }
106
103
 
107
104
  const keys = {