@withwiz/toolkit 0.4.0 → 0.5.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/dist/auth/adapters/prisma/index.d.ts +20 -4
- package/dist/auth/adapters/prisma/index.js +51 -61
- package/dist/auth/config.js +2 -2
- package/dist/auth/core/jwt/cookie.d.ts +1 -0
- package/dist/auth/core/jwt/cookie.js +4 -1
- package/dist/auth/core/jwt/index.d.ts +1 -1
- package/dist/auth/core/jwt/index.js +4 -1
- package/dist/auth/core/jwt/types.js +5 -7
- package/dist/auth/core/oauth/index.d.ts +17 -27
- package/dist/auth/core/oauth/index.js +18 -5
- package/dist/auth/core/oauth/providers/github.d.ts +12 -0
- package/dist/auth/core/oauth/providers/github.js +8 -0
- package/dist/auth/core/oauth/providers/google.d.ts +12 -0
- package/dist/auth/core/oauth/providers/google.js +8 -0
- package/dist/auth/core/oauth/providers/index.d.ts +3 -0
- package/dist/auth/core/oauth/providers/index.js +17 -0
- package/dist/auth/core/oauth/providers/kakao.d.ts +12 -0
- package/dist/auth/core/oauth/providers/kakao.js +8 -0
- package/dist/auth/core/password/client-helper.js +1 -1
- package/dist/auth/core/password/index.js +1 -1
- package/dist/auth/index.d.ts +2 -3
- package/dist/auth/index.js +27 -13
- package/dist/auth/types/index.d.ts +31 -31
- package/dist/auth/types/index.js +5 -7
- package/dist/cache/cache-config.d.ts +0 -32
- package/dist/cache/cache-config.js +6 -6
- package/dist/cache/cache-defaults.d.ts +2 -28
- package/dist/cache/cache-defaults.js +1 -1
- package/dist/cache/cache-env.js +5 -5
- package/dist/cache/cache-factory.js +14 -14
- package/dist/cache/cache-invalidation.js +15 -15
- package/dist/cache/cache-redis.js +8 -8
- package/dist/cache/cache-wrapper.js +15 -15
- package/dist/cache/cache.js +22 -26
- package/dist/cache/config.d.ts +0 -8
- package/dist/cache/config.js +2 -2
- package/dist/cache/hybrid-cache-manager.js +10 -10
- package/dist/cache/index.d.ts +0 -1
- package/dist/cache/index.js +22 -26
- package/dist/cache/inmemory-cache-manager.js +5 -5
- package/dist/cache/noop-cache-manager.d.ts +2 -2
- package/dist/cache/noop-cache-manager.js +7 -7
- package/dist/cache/redis-cache-manager.d.ts +2 -2
- package/dist/cache/redis-cache-manager.js +9 -9
- package/dist/chunk-2QQNL4ND.js +62 -0
- package/dist/{chunk-YP5SAHAP.js → chunk-3OZH2AMD.js} +10 -10
- package/dist/{chunk-WMQE2YK7.js → chunk-3WS5MO6P.js} +1 -1
- package/dist/{chunk-BYCFXGQL.js → chunk-4OCGUJL5.js} +4 -4
- package/dist/{chunk-IQQKKUAV.js → chunk-57W32BFZ.js} +4 -30
- package/dist/{chunk-VF4EVAMV.js → chunk-5HSGNXQ3.js} +1 -1
- package/dist/{chunk-KZUBO2IL.js → chunk-6OYE5XKI.js} +5 -5
- package/dist/{chunk-FD2TXDTO.js → chunk-6WI4HNAF.js} +2 -2
- package/dist/{chunk-J4TTSXDN.js → chunk-6XDE62WQ.js} +1 -1
- package/dist/{chunk-TO5CMMQC.js → chunk-7ZQQ6PJ4.js} +4 -17
- package/dist/{chunk-JLLMTTQ4.js → chunk-C4TSQUFA.js} +0 -7
- package/dist/{chunk-SV7X6HEN.js → chunk-D46PE6MU.js} +4 -4
- package/dist/{chunk-2F6KNGOD.js → chunk-DANUXNQU.js} +1 -1
- package/dist/{chunk-FDRIFPG6.js → chunk-DSRRNRZW.js} +4 -4
- package/dist/{chunk-XI4MRH5P.js → chunk-ET6RH4LB.js} +12 -40
- package/dist/{chunk-OIRAH57Y.js → chunk-FNKFQFZJ.js} +1 -1
- package/dist/{chunk-S5UCZ2T3.js → chunk-G5WP3MJG.js} +1 -1
- package/dist/chunk-GBLNXNEH.js +64 -0
- package/dist/{chunk-HHCDMWEF.js → chunk-GCR4PGRY.js} +1 -1
- package/dist/{chunk-4HBAPPB2.js → chunk-HGLQXH4D.js} +2 -2
- package/dist/chunk-HZLJYEOO.js +92 -0
- package/dist/{chunk-LX2EYD74.js → chunk-I7NVWJ72.js} +2 -2
- package/dist/{chunk-AXCB7SKY.js → chunk-IEFYARHC.js} +16 -16
- package/dist/{chunk-3YUKCYHI.js → chunk-JY62DSMP.js} +8 -8
- package/dist/{chunk-G5OMETUS.js → chunk-LCKQOHXI.js} +1 -1
- package/dist/{chunk-7IN4WRSO.js → chunk-MF4CWGMB.js} +12 -12
- package/dist/{chunk-J5AISIJS.js → chunk-NDET73GO.js} +22 -18
- package/dist/{chunk-JOM3N4EJ.js → chunk-NGV527RO.js} +1 -1
- package/dist/{chunk-RWVGJUON.js → chunk-OSDAP24S.js} +4 -4
- package/dist/{chunk-CUZPD3BF.js → chunk-PAYLVMZN.js} +2 -2
- package/dist/{chunk-6SOQUYOU.js → chunk-PYTRCD33.js} +2 -2
- package/dist/{chunk-6D3HHYER.js → chunk-QKC73SWB.js} +6 -12
- package/dist/{chunk-LFQ3IQQB.js → chunk-QO27AXIH.js} +2 -2
- package/dist/chunk-RVL5ROWQ.js +62 -0
- package/dist/{chunk-AQJAY5FA.js → chunk-S5KJZZKU.js} +1 -1
- package/dist/{chunk-K3HAYBWX.js → chunk-SNKCKED5.js} +1 -1
- package/dist/{chunk-AJLUPYCQ.js → chunk-SUA4WQRN.js} +20 -8
- package/dist/chunk-T4MDCVUQ.js +0 -0
- package/dist/{chunk-L6AU74EI.js → chunk-TOVBPLHD.js} +3 -3
- package/dist/{chunk-TFD3DSM2.js → chunk-UCIUAZQT.js} +14 -18
- package/dist/chunk-VIWM2ZZH.js +45 -0
- package/dist/{chunk-KGHWGLED.js → chunk-W3IVVPS5.js} +4 -4
- package/dist/{chunk-WNF2RKFA.js → chunk-WBU53USI.js} +13 -13
- package/dist/{chunk-FPESPW6P.js → chunk-XA32Z2OV.js} +1 -1
- package/dist/{chunk-GQVBWZLH.js → chunk-Y22GDIM6.js} +2 -2
- package/dist/{chunk-OIVXOT2X.js → chunk-YUBXS7YI.js} +2 -3
- package/dist/{chunk-VDXB5DCY.js → chunk-ZRDPJORV.js} +0 -10
- package/dist/components/ui/DataTable.js +5 -5
- package/dist/components/ui/data-table/DataTable.js +5 -5
- package/dist/components/ui/data-table/DataTableFilters.js +2 -2
- package/dist/components/ui/data-table/DataTableSearch.js +2 -2
- package/dist/config/common.js +2 -2
- package/dist/constants/index.js +11 -13
- package/dist/constants/pagination.d.ts +0 -5
- package/dist/constants/pagination.js +1 -1
- package/dist/constants/security.d.ts +0 -6
- package/dist/constants/security.js +1 -3
- package/dist/constants/validation.d.ts +1 -3
- package/dist/error/error-display.js +2 -2
- package/dist/error/error-handler.js +5 -5
- package/dist/error/index.js +15 -15
- package/dist/geolocation/batch-processor.js +5 -5
- package/dist/geolocation/config.js +2 -2
- package/dist/geolocation/index.js +9 -9
- package/dist/geolocation/providers/index.js +5 -5
- package/dist/geolocation/providers/ipgeolocation-provider.js +3 -3
- package/dist/geolocation/providers/maxmind-provider.js +3 -3
- package/dist/initialize.js +12 -12
- package/dist/logger/config.js +2 -2
- package/dist/logger/logger.js +4 -4
- package/dist/middleware/auth.d.ts +1 -0
- package/dist/middleware/auth.js +9 -7
- package/dist/middleware/cors-config.js +2 -2
- package/dist/middleware/cors.js +6 -6
- package/dist/middleware/error-handler.js +7 -7
- package/dist/middleware/index.d.ts +1 -1
- package/dist/middleware/index.js +22 -20
- package/dist/middleware/middleware-chain.js +5 -5
- package/dist/middleware/rate-limit.d.ts +3 -7
- package/dist/middleware/rate-limit.js +5 -5
- package/dist/middleware/response-logger.js +5 -5
- package/dist/middleware/security.js +5 -5
- package/dist/middleware/types.d.ts +1 -1
- package/dist/middleware/wrappers.js +17 -17
- package/dist/storage/config.js +2 -2
- package/dist/storage/r2-storage.js +2 -2
- package/dist/system/cpu.js +6 -6
- package/dist/system/disk.js +6 -6
- package/dist/system/environment.js +10 -10
- package/dist/system/health-check.js +9 -9
- package/dist/system/index.js +16 -16
- package/dist/system/memory.js +6 -6
- package/dist/system/network.js +6 -6
- package/dist/system/utils.js +5 -5
- package/dist/types/env.d.ts +2 -13
- package/dist/types/geoip.d.ts +4 -4
- package/dist/types/qr-code.d.ts +20 -20
- package/dist/types/qr-code.js +4 -4
- package/dist/utils/cors.d.ts +6 -4
- package/dist/utils/cors.js +4 -4
- package/dist/utils/csv-export.js +5 -5
- package/dist/utils/error-message-formatter.js +1 -1
- package/dist/utils/error-processor.js +5 -5
- package/dist/utils/index.js +8 -8
- package/dist/utils/optimistic-lock.d.ts +4 -4
- package/package.json +5 -1
- package/dist/cache/cache-keys-legacy.d.ts +0 -35
- package/dist/cache/cache-keys-legacy.js +0 -7
- package/dist/chunk-JBCDEAMW.js +0 -35
- package/dist/chunk-O7CK3CKJ.js +0 -84
- package/dist/chunk-V5K5FYU7.js +0 -200
- package/dist/{chunk-GFWGLWTS.js → chunk-23LXAAMU.js} +3 -3
- package/dist/{chunk-3CBGGMIY.js → chunk-2VNDWG6P.js} +3 -3
- package/dist/{chunk-OZE5KUS3.js → chunk-52BIDTZH.js} +3 -3
- package/dist/{chunk-OHBAELPZ.js → chunk-6O3I4ORK.js} +3 -3
- package/dist/{chunk-QMCOX3DP.js → chunk-EBUEBEJX.js} +0 -0
- package/dist/{chunk-BJSEYZBH.js → chunk-I4UEUKSB.js} +3 -3
- package/dist/{chunk-SEZJN4TC.js → chunk-LJEGM4OO.js} +3 -3
- package/dist/{chunk-AYZJN32D.js → chunk-PL33DK2X.js} +3 -3
- package/dist/{chunk-KHYY4KCV.js → chunk-TH45RVP7.js} +3 -3
- package/dist/{chunk-SFPMFVSD.js → chunk-XICTHSUH.js} +3 -3
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OAuthError
|
|
3
|
+
} from "./chunk-AIH3F7JV.js";
|
|
4
|
+
|
|
5
|
+
// src/auth/core/oauth/providers/github.ts
|
|
6
|
+
var GitHubOAuthProvider = class {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.name = "github";
|
|
9
|
+
}
|
|
10
|
+
getLoginUrl(config, state) {
|
|
11
|
+
const params = new URLSearchParams({
|
|
12
|
+
client_id: config.clientId,
|
|
13
|
+
redirect_uri: config.redirectUri,
|
|
14
|
+
scope: "read:user user:email"
|
|
15
|
+
});
|
|
16
|
+
if (state) {
|
|
17
|
+
params.set("state", state);
|
|
18
|
+
}
|
|
19
|
+
return `https://github.com/login/oauth/authorize?${params.toString()}`;
|
|
20
|
+
}
|
|
21
|
+
async exchangeCodeForToken(config, code) {
|
|
22
|
+
const response = await fetch("https://github.com/login/oauth/access_token", {
|
|
23
|
+
method: "POST",
|
|
24
|
+
headers: {
|
|
25
|
+
"Content-Type": "application/json",
|
|
26
|
+
Accept: "application/json"
|
|
27
|
+
},
|
|
28
|
+
body: JSON.stringify({
|
|
29
|
+
client_id: config.clientId,
|
|
30
|
+
client_secret: config.clientSecret,
|
|
31
|
+
code,
|
|
32
|
+
redirect_uri: config.redirectUri
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
const errorData = await response.text();
|
|
37
|
+
throw new OAuthError(`GitHub token exchange failed: ${errorData}`, "TOKEN_EXCHANGE_FAILED");
|
|
38
|
+
}
|
|
39
|
+
return response.json();
|
|
40
|
+
}
|
|
41
|
+
async getUserInfo(accessToken) {
|
|
42
|
+
const response = await fetch("https://api.github.com/user", {
|
|
43
|
+
headers: {
|
|
44
|
+
Authorization: `Bearer ${accessToken}`,
|
|
45
|
+
"User-Agent": "Auth-Module"
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
if (!response.ok) {
|
|
49
|
+
throw new OAuthError("Failed to get GitHub user info", "USER_INFO_FAILED");
|
|
50
|
+
}
|
|
51
|
+
const data = await response.json();
|
|
52
|
+
return {
|
|
53
|
+
id: data.id.toString(),
|
|
54
|
+
email: data.email,
|
|
55
|
+
name: data.name || null,
|
|
56
|
+
image: data.avatar_url || null,
|
|
57
|
+
emailVerified: !!data.email
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
GitHubOAuthProvider
|
|
64
|
+
};
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
formatBytesPerSec,
|
|
4
4
|
runCommand,
|
|
5
5
|
runMacCommand
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-G5WP3MJG.js";
|
|
7
7
|
import {
|
|
8
8
|
logger
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-Y22GDIM6.js";
|
|
10
10
|
|
|
11
11
|
// src/system/network.ts
|
|
12
12
|
async function getNetworkInfo() {
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {
|
|
2
|
+
KakaoOAuthProvider
|
|
3
|
+
} from "./chunk-2QQNL4ND.js";
|
|
4
|
+
import {
|
|
5
|
+
GitHubOAuthProvider
|
|
6
|
+
} from "./chunk-GBLNXNEH.js";
|
|
7
|
+
import {
|
|
8
|
+
GoogleOAuthProvider
|
|
9
|
+
} from "./chunk-RVL5ROWQ.js";
|
|
10
|
+
import {
|
|
11
|
+
OAuthError
|
|
12
|
+
} from "./chunk-AIH3F7JV.js";
|
|
13
|
+
|
|
14
|
+
// src/auth/core/oauth/index.ts
|
|
15
|
+
var OAuthManager = class {
|
|
16
|
+
constructor(config, logger) {
|
|
17
|
+
this.providers = /* @__PURE__ */ new Map();
|
|
18
|
+
this.config = config;
|
|
19
|
+
this.logger = logger;
|
|
20
|
+
this.registerProvider(new GoogleOAuthProvider());
|
|
21
|
+
this.registerProvider(new GitHubOAuthProvider());
|
|
22
|
+
this.registerProvider(new KakaoOAuthProvider());
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 프로바이더 어댑터 등록
|
|
26
|
+
*/
|
|
27
|
+
registerProvider(provider) {
|
|
28
|
+
this.providers.set(provider.name, provider);
|
|
29
|
+
this.logger.debug(`OAuth provider registered: ${provider.name}`);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* OAuth 로그인 URL 생성
|
|
33
|
+
*/
|
|
34
|
+
getLoginUrl(providerName, state) {
|
|
35
|
+
const provider = this.getProvider(providerName);
|
|
36
|
+
const config = this.getProviderConfig(providerName);
|
|
37
|
+
return provider.getLoginUrl(config, state);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 인증 코드를 액세스 토큰으로 교환
|
|
41
|
+
*/
|
|
42
|
+
async exchangeCodeForToken(providerName, code) {
|
|
43
|
+
const provider = this.getProvider(providerName);
|
|
44
|
+
const config = this.getProviderConfig(providerName);
|
|
45
|
+
try {
|
|
46
|
+
const tokenResponse = await provider.exchangeCodeForToken(config, code);
|
|
47
|
+
this.logger.debug(`${providerName} token exchange successful`);
|
|
48
|
+
return tokenResponse.access_token;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
this.logger.error(`${providerName} token exchange error`, { error: error.message });
|
|
51
|
+
throw error instanceof OAuthError ? error : new OAuthError(`${providerName} token exchange failed`, "TOKEN_EXCHANGE_FAILED");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 사용자 정보 가져오기
|
|
56
|
+
*/
|
|
57
|
+
async getUserInfo(providerName, accessToken) {
|
|
58
|
+
const provider = this.getProvider(providerName);
|
|
59
|
+
try {
|
|
60
|
+
const userInfo = await provider.getUserInfo(accessToken);
|
|
61
|
+
this.logger.debug(`${providerName} user info retrieved`, { userId: userInfo.id, email: userInfo.email });
|
|
62
|
+
return userInfo;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
this.logger.error(`${providerName} user info error`, { error: error.message });
|
|
65
|
+
throw error instanceof OAuthError ? error : new OAuthError(`Failed to retrieve ${providerName} user info`, "USER_INFO_FAILED");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 프로바이더 어댑터 조회
|
|
70
|
+
*/
|
|
71
|
+
getProvider(name) {
|
|
72
|
+
const provider = this.providers.get(name);
|
|
73
|
+
if (!provider) {
|
|
74
|
+
throw new OAuthError(`Unsupported OAuth provider: ${name}`, "UNSUPPORTED_PROVIDER");
|
|
75
|
+
}
|
|
76
|
+
return provider;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 프로바이더 설정 조회
|
|
80
|
+
*/
|
|
81
|
+
getProviderConfig(providerName) {
|
|
82
|
+
const config = this.config.providers[providerName];
|
|
83
|
+
if (!config) {
|
|
84
|
+
throw new OAuthError(`${providerName} OAuth not configured`, `${providerName.toUpperCase()}_NOT_CONFIGURED`);
|
|
85
|
+
}
|
|
86
|
+
return config;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export {
|
|
91
|
+
OAuthManager
|
|
92
|
+
};
|
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
} from "./chunk-MAATEX2R.js";
|
|
7
7
|
import {
|
|
8
8
|
DataTableFilters
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-LJEGM4OO.js";
|
|
10
10
|
import {
|
|
11
11
|
DataTablePagination
|
|
12
12
|
} from "./chunk-IPXPCBDO.js";
|
|
13
13
|
import {
|
|
14
14
|
DataTableSearch
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-TH45RVP7.js";
|
|
16
16
|
import {
|
|
17
17
|
DEFAULT_LABELS
|
|
18
18
|
} from "./chunk-NY5QXT33.js";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
logger
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Y22GDIM6.js";
|
|
4
4
|
import {
|
|
5
5
|
getCacheFallbackConfig,
|
|
6
6
|
getConfig,
|
|
7
7
|
getEnv,
|
|
8
8
|
isCacheEnabled,
|
|
9
9
|
validateRedisEnvironment
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ET6RH4LB.js";
|
|
11
11
|
|
|
12
12
|
// src/cache/cache-redis.ts
|
|
13
13
|
import { Redis } from "@upstash/redis";
|
|
@@ -72,13 +72,13 @@ async function tryReconnectRedisGlobally() {
|
|
|
72
72
|
logger.info("[Redis:Global] Attempting Redis reconnection...");
|
|
73
73
|
try {
|
|
74
74
|
const env = getEnv();
|
|
75
|
-
if (!env.
|
|
75
|
+
if (!env.REDIS_REST_URL || !env.REDIS_REST_TOKEN) {
|
|
76
76
|
scheduleNextReconnect();
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
79
|
const redis = new Redis({
|
|
80
|
-
url: env.
|
|
81
|
-
token: env.
|
|
80
|
+
url: env.REDIS_REST_URL,
|
|
81
|
+
token: env.REDIS_REST_TOKEN
|
|
82
82
|
});
|
|
83
83
|
const pingResult = await redis.ping();
|
|
84
84
|
if (pingResult === "PONG") {
|
|
@@ -176,8 +176,8 @@ async function checkRedisConnection() {
|
|
|
176
176
|
logger.info("[Redis:Cache] Redis connection status check started", {
|
|
177
177
|
purpose: "cache"
|
|
178
178
|
});
|
|
179
|
-
const redisUrl = env.
|
|
180
|
-
const redisToken = env.
|
|
179
|
+
const redisUrl = env.REDIS_REST_URL;
|
|
180
|
+
const redisToken = env.REDIS_REST_TOKEN;
|
|
181
181
|
if (!redisUrl || !redisToken || redisUrl.trim() === "" || redisToken.trim() === "") {
|
|
182
182
|
const error = "Redis environment variables are not configured.";
|
|
183
183
|
logger.error("[Redis:Cache] Redis connection failed: Environment variables not set", {
|
|
@@ -271,13 +271,13 @@ function getRedisClient() {
|
|
|
271
271
|
return null;
|
|
272
272
|
}
|
|
273
273
|
const env = getEnv();
|
|
274
|
-
if (!env.
|
|
274
|
+
if (!env.REDIS_REST_URL || !env.REDIS_REST_TOKEN) {
|
|
275
275
|
_redisClient = null;
|
|
276
276
|
return null;
|
|
277
277
|
}
|
|
278
278
|
_redisClient = new Redis({
|
|
279
|
-
url: env.
|
|
280
|
-
token: env.
|
|
279
|
+
url: env.REDIS_REST_URL,
|
|
280
|
+
token: env.REDIS_REST_TOKEN
|
|
281
281
|
});
|
|
282
282
|
return _redisClient;
|
|
283
283
|
}
|
|
@@ -289,24 +289,24 @@ function logRedisInitialization() {
|
|
|
289
289
|
const redis = getRedisClient();
|
|
290
290
|
const env = getEnv();
|
|
291
291
|
if (isRedisAvailableNow() && redis) {
|
|
292
|
-
logger.info("[Redis:Cache]
|
|
292
|
+
logger.info("[Redis:Cache] Redis cache connection initialization complete", {
|
|
293
293
|
purpose: "cache",
|
|
294
|
-
url: ((_a = env.
|
|
294
|
+
url: ((_a = env.REDIS_REST_URL) == null ? void 0 : _a.substring(0, 50)) + "...",
|
|
295
295
|
cacheEnabled: isCacheEnabled()
|
|
296
296
|
});
|
|
297
297
|
} else if (!isCacheEnabled()) {
|
|
298
298
|
logger.info("[Redis:Cache] Redis cache disabled (CACHE_ENABLED=false)", {
|
|
299
299
|
purpose: "cache",
|
|
300
300
|
cacheEnabled: false,
|
|
301
|
-
redisUrlSet: !!env.
|
|
302
|
-
redisTokenSet: !!env.
|
|
301
|
+
redisUrlSet: !!env.REDIS_REST_URL,
|
|
302
|
+
redisTokenSet: !!env.REDIS_REST_TOKEN
|
|
303
303
|
});
|
|
304
304
|
} else {
|
|
305
305
|
logger.warn("[Redis:Cache] Cache disabled due to missing Redis environment variables", {
|
|
306
306
|
purpose: "cache",
|
|
307
307
|
cacheEnabled: isCacheEnabled(),
|
|
308
|
-
redisUrlSet: !!env.
|
|
309
|
-
redisTokenSet: !!env.
|
|
308
|
+
redisUrlSet: !!env.REDIS_REST_URL,
|
|
309
|
+
redisTokenSet: !!env.REDIS_REST_TOKEN
|
|
310
310
|
});
|
|
311
311
|
}
|
|
312
312
|
if (typeof globalThis !== "undefined") {
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getErrorMessage
|
|
3
|
+
} from "./chunk-JNJALNRR.js";
|
|
1
4
|
import {
|
|
2
5
|
AUTH_ERROR_CODE_MAP
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TOVBPLHD.js";
|
|
4
7
|
import {
|
|
5
8
|
AppError
|
|
6
9
|
} from "./chunk-EOEMOXNT.js";
|
|
7
|
-
import {
|
|
8
|
-
getErrorMessage
|
|
9
|
-
} from "./chunk-JNJALNRR.js";
|
|
10
10
|
import {
|
|
11
11
|
ERROR_CODES,
|
|
12
12
|
classifyError
|
|
13
13
|
} from "./chunk-SNTLJ646.js";
|
|
14
|
+
import {
|
|
15
|
+
logger
|
|
16
|
+
} from "./chunk-Y22GDIM6.js";
|
|
14
17
|
import {
|
|
15
18
|
AuthError
|
|
16
19
|
} from "./chunk-AIH3F7JV.js";
|
|
17
|
-
import {
|
|
18
|
-
logger
|
|
19
|
-
} from "./chunk-GQVBWZLH.js";
|
|
20
20
|
import {
|
|
21
21
|
getCommonConfig
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-XICTHSUH.js";
|
|
23
23
|
import {
|
|
24
24
|
__spreadValues
|
|
25
25
|
} from "./chunk-ORMEWXMH.js";
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
NoopCacheManager
|
|
3
|
-
} from "./chunk-FDRIFPG6.js";
|
|
4
|
-
import {
|
|
5
|
-
RedisCacheManager
|
|
6
|
-
} from "./chunk-KZUBO2IL.js";
|
|
7
1
|
import {
|
|
8
2
|
HybridCacheManager
|
|
9
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-D46PE6MU.js";
|
|
10
4
|
import {
|
|
11
5
|
InMemoryCacheManager
|
|
12
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6XDE62WQ.js";
|
|
7
|
+
import {
|
|
8
|
+
NoopCacheManager
|
|
9
|
+
} from "./chunk-DSRRNRZW.js";
|
|
10
|
+
import {
|
|
11
|
+
RedisCacheManager
|
|
12
|
+
} from "./chunk-6OYE5XKI.js";
|
|
13
13
|
import {
|
|
14
14
|
isRedisAvailableNow,
|
|
15
15
|
isRedisGloballyDisabled
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-IEFYARHC.js";
|
|
17
17
|
import {
|
|
18
18
|
logger
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-Y22GDIM6.js";
|
|
20
20
|
import {
|
|
21
21
|
getCacheConfig
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-VIWM2ZZH.js";
|
|
23
23
|
import {
|
|
24
24
|
getENV,
|
|
25
25
|
isCacheEnabled
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-ET6RH4LB.js";
|
|
27
27
|
|
|
28
28
|
// src/cache/cache-factory.ts
|
|
29
29
|
function getInMemoryConfig() {
|
|
@@ -4,15 +4,15 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
ERROR_CODES
|
|
6
6
|
} from "./chunk-SNTLJ646.js";
|
|
7
|
+
import {
|
|
8
|
+
logger
|
|
9
|
+
} from "./chunk-Y22GDIM6.js";
|
|
7
10
|
import {
|
|
8
11
|
getAuthConfig
|
|
9
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-52BIDTZH.js";
|
|
10
13
|
import {
|
|
11
14
|
JWTManager
|
|
12
15
|
} from "./chunk-3GAY2T2A.js";
|
|
13
|
-
import {
|
|
14
|
-
logger
|
|
15
|
-
} from "./chunk-GQVBWZLH.js";
|
|
16
16
|
|
|
17
17
|
// src/middleware/auth.ts
|
|
18
18
|
function setAccessTokenBlacklistChecker(checker) {
|
|
@@ -72,7 +72,7 @@ function initializeAuthMiddleware() {
|
|
|
72
72
|
return jwtManager !== null;
|
|
73
73
|
}
|
|
74
74
|
var authMiddleware = async (context, next) => {
|
|
75
|
-
var _a, _b, _c, _d;
|
|
75
|
+
var _a, _b, _c, _d, _e;
|
|
76
76
|
try {
|
|
77
77
|
const jwtManager = getJWTManager();
|
|
78
78
|
if (!jwtManager) {
|
|
@@ -111,13 +111,13 @@ var authMiddleware = async (context, next) => {
|
|
|
111
111
|
email: (_c = payload.email) != null ? _c : "",
|
|
112
112
|
name: void 0,
|
|
113
113
|
// 필요시 DB에서 조회
|
|
114
|
-
role: payload.role
|
|
114
|
+
role: (_d = payload.role) != null ? _d : "USER"
|
|
115
115
|
};
|
|
116
116
|
} catch (error) {
|
|
117
117
|
if (error instanceof AppError) {
|
|
118
118
|
throw error;
|
|
119
119
|
}
|
|
120
|
-
if (error.code === "TOKEN_EXPIRED" || ((
|
|
120
|
+
if (error.code === "TOKEN_EXPIRED" || ((_e = error.message) == null ? void 0 : _e.includes("expired"))) {
|
|
121
121
|
throw new AppError(ERROR_CODES.TOKEN_EXPIRED.code, error.message);
|
|
122
122
|
}
|
|
123
123
|
throw new AppError(
|
|
@@ -128,7 +128,7 @@ var authMiddleware = async (context, next) => {
|
|
|
128
128
|
return await next();
|
|
129
129
|
};
|
|
130
130
|
var optionalAuthMiddleware = async (context, next) => {
|
|
131
|
-
var _a, _b, _c;
|
|
131
|
+
var _a, _b, _c, _d;
|
|
132
132
|
try {
|
|
133
133
|
const jwtManager = getJWTManager();
|
|
134
134
|
if (jwtManager) {
|
|
@@ -149,7 +149,7 @@ var optionalAuthMiddleware = async (context, next) => {
|
|
|
149
149
|
id: payload.userId,
|
|
150
150
|
email: (_c = payload.email) != null ? _c : "",
|
|
151
151
|
name: void 0,
|
|
152
|
-
role: payload.role
|
|
152
|
+
role: (_d = payload.role) != null ? _d : "USER"
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
155
|
}
|
|
@@ -158,20 +158,24 @@ var optionalAuthMiddleware = async (context, next) => {
|
|
|
158
158
|
}
|
|
159
159
|
return await next();
|
|
160
160
|
};
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
161
|
+
function createRoleMiddleware(...allowedRoles) {
|
|
162
|
+
return async (context, next) => {
|
|
163
|
+
if (!context.user) {
|
|
164
|
+
throw new AppError(ERROR_CODES.UNAUTHORIZED.code);
|
|
165
|
+
}
|
|
166
|
+
if (!allowedRoles.includes(context.user.role)) {
|
|
167
|
+
throw new AppError(ERROR_CODES.FORBIDDEN.code);
|
|
168
|
+
}
|
|
169
|
+
return await next();
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
var adminMiddleware = createRoleMiddleware("ADMIN");
|
|
170
173
|
|
|
171
174
|
export {
|
|
172
175
|
setAccessTokenBlacklistChecker,
|
|
173
176
|
initializeAuthMiddleware,
|
|
174
177
|
authMiddleware,
|
|
175
178
|
optionalAuthMiddleware,
|
|
179
|
+
createRoleMiddleware,
|
|
176
180
|
adminMiddleware
|
|
177
181
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getCacheManager,
|
|
3
3
|
getEffectiveCacheBackend
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MF4CWGMB.js";
|
|
5
5
|
import {
|
|
6
6
|
logger
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-Y22GDIM6.js";
|
|
8
8
|
import {
|
|
9
9
|
getCacheConfig,
|
|
10
10
|
getCacheTTL
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-VIWM2ZZH.js";
|
|
12
12
|
import {
|
|
13
13
|
isCacheEnabled
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-ET6RH4LB.js";
|
|
15
15
|
|
|
16
16
|
// src/cache/cache-wrapper.ts
|
|
17
17
|
function getCacheBackendLabel() {
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
} from "./chunk-VSGKVZB4.js";
|
|
7
7
|
import {
|
|
8
8
|
IPGeolocationProvider
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-GCR4PGRY.js";
|
|
10
10
|
import {
|
|
11
11
|
MaxMindProvider
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-LCKQOHXI.js";
|
|
13
13
|
|
|
14
14
|
// src/geolocation/providers/index.ts
|
|
15
15
|
var GeoIPProviderFactory = class {
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
// src/auth/types/index.ts
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
var OAuthProvider = /* @__PURE__ */ ((OAuthProvider2) => {
|
|
8
|
-
OAuthProvider2["GOOGLE"] = "google";
|
|
9
|
-
OAuthProvider2["GITHUB"] = "github";
|
|
10
|
-
return OAuthProvider2;
|
|
11
|
-
})(OAuthProvider || {});
|
|
2
|
+
var OAUTH_PROVIDERS = {
|
|
3
|
+
GOOGLE: "google",
|
|
4
|
+
GITHUB: "github",
|
|
5
|
+
KAKAO: "kakao"
|
|
6
|
+
};
|
|
12
7
|
var PasswordStrength = /* @__PURE__ */ ((PasswordStrength2) => {
|
|
13
8
|
PasswordStrength2["VERY_WEAK"] = "VERY_WEAK";
|
|
14
9
|
PasswordStrength2["WEAK"] = "WEAK";
|
|
@@ -25,8 +20,7 @@ var TokenType = /* @__PURE__ */ ((TokenType2) => {
|
|
|
25
20
|
})(TokenType || {});
|
|
26
21
|
|
|
27
22
|
export {
|
|
28
|
-
|
|
29
|
-
OAuthProvider,
|
|
23
|
+
OAUTH_PROVIDERS,
|
|
30
24
|
PasswordStrength,
|
|
31
25
|
TokenType
|
|
32
26
|
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OAuthError
|
|
3
|
+
} from "./chunk-AIH3F7JV.js";
|
|
4
|
+
|
|
5
|
+
// src/auth/core/oauth/providers/google.ts
|
|
6
|
+
var GoogleOAuthProvider = class {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.name = "google";
|
|
9
|
+
}
|
|
10
|
+
getLoginUrl(config, state) {
|
|
11
|
+
const params = new URLSearchParams({
|
|
12
|
+
client_id: config.clientId,
|
|
13
|
+
redirect_uri: config.redirectUri,
|
|
14
|
+
response_type: "code",
|
|
15
|
+
scope: "openid email profile",
|
|
16
|
+
access_type: "offline",
|
|
17
|
+
prompt: "select_account consent"
|
|
18
|
+
});
|
|
19
|
+
if (state) {
|
|
20
|
+
params.set("state", state);
|
|
21
|
+
}
|
|
22
|
+
return `https://accounts.google.com/o/oauth2/v2/auth?${params.toString()}`;
|
|
23
|
+
}
|
|
24
|
+
async exchangeCodeForToken(config, code) {
|
|
25
|
+
const response = await fetch("https://oauth2.googleapis.com/token", {
|
|
26
|
+
method: "POST",
|
|
27
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
28
|
+
body: new URLSearchParams({
|
|
29
|
+
client_id: config.clientId,
|
|
30
|
+
client_secret: config.clientSecret,
|
|
31
|
+
code,
|
|
32
|
+
grant_type: "authorization_code",
|
|
33
|
+
redirect_uri: config.redirectUri
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
const errorData = await response.text();
|
|
38
|
+
throw new OAuthError(`Google token exchange failed: ${errorData}`, "TOKEN_EXCHANGE_FAILED");
|
|
39
|
+
}
|
|
40
|
+
return response.json();
|
|
41
|
+
}
|
|
42
|
+
async getUserInfo(accessToken) {
|
|
43
|
+
const response = await fetch("https://www.googleapis.com/oauth2/v2/userinfo", {
|
|
44
|
+
headers: { Authorization: `Bearer ${accessToken}` }
|
|
45
|
+
});
|
|
46
|
+
if (!response.ok) {
|
|
47
|
+
throw new OAuthError("Failed to get Google user info", "USER_INFO_FAILED");
|
|
48
|
+
}
|
|
49
|
+
const data = await response.json();
|
|
50
|
+
return {
|
|
51
|
+
id: data.id,
|
|
52
|
+
email: data.email,
|
|
53
|
+
name: data.name || null,
|
|
54
|
+
image: data.picture || null,
|
|
55
|
+
emailVerified: data.verified_email || false
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
GoogleOAuthProvider
|
|
62
|
+
};
|