@withwiz/toolkit 0.10.0 → 0.12.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/README.md +6 -0
- package/dist/{chunk-Z64GNAB7.js → chunk-2SV6VZOC.js} +2 -2
- package/dist/{chunk-3P4TZM3O.js → chunk-3EEOZHIJ.js} +3 -3
- package/dist/chunk-4JZIIMAF.js +33 -0
- package/dist/{chunk-BICSVLN7.js → chunk-4OFL7KZ7.js} +11 -11
- package/dist/{chunk-XDB3K74B.js → chunk-4OKAMI6O.js} +1 -1
- package/dist/{chunk-W27FQNP6.js → chunk-5MPMPXIR.js} +1 -1
- package/dist/{chunk-XQIAXMRY.js → chunk-5VZIAXO2.js} +2 -1
- package/dist/{chunk-465MEI5K.js → chunk-6E2Q27EN.js} +1 -1
- package/dist/chunk-6NFMRZWB.js +8 -0
- package/dist/{chunk-HZN44RWL.js → chunk-7Q6SMNMN.js} +7 -7
- package/dist/{chunk-SROPI74N.js → chunk-AWFP2KAU.js} +1 -1
- package/dist/{chunk-7S2PCYNT.js → chunk-B2JZPUQ3.js} +2 -2
- package/dist/{chunk-HV6A6Z5R.js → chunk-BPDYEB37.js} +1 -1
- package/dist/{chunk-BRFW2LL2.js → chunk-D4QADM6T.js} +2 -2
- package/dist/{chunk-6NEGFM32.js → chunk-DTRXWS7G.js} +25 -16
- package/dist/{chunk-UIWR5MXM.js → chunk-ETXMWDXV.js} +1 -1
- package/dist/{chunk-4TGPAUJV.js → chunk-F2FTS6H4.js} +2 -2
- package/dist/{chunk-P4MGYRJM.js → chunk-G4IGD3AZ.js} +33 -13
- package/dist/{chunk-VHRBXD7U.js → chunk-HNFYO5XV.js} +10 -6
- package/dist/{chunk-23LQJYZN.js → chunk-KAS5ILUM.js} +1 -1
- package/dist/{chunk-KHXS4DGA.js → chunk-LFJ24NDO.js} +8 -8
- package/dist/{chunk-TRGFXIEF.js → chunk-M4ZVQFOH.js} +2 -2
- package/dist/{chunk-ATAQRXTH.js → chunk-MCPPJI3T.js} +1 -1
- package/dist/{chunk-ZEHNCHIV.js → chunk-MTRPUJ4B.js} +1 -1
- package/dist/{chunk-R7EFDSPZ.js → chunk-NHFIOK2D.js} +5 -5
- package/dist/{chunk-5Z5CZAZP.js → chunk-NT6URT4W.js} +14 -14
- package/dist/{chunk-Y6CPPBJI.js → chunk-OEZPVNSA.js} +1 -1
- package/dist/{chunk-KZ4PDS5K.js → chunk-RWN47K7J.js} +1 -1
- package/dist/{chunk-N3TCQ5BF.js → chunk-TQMQ5XXG.js} +17 -2
- package/dist/{chunk-OII5BXCZ.js → chunk-U2TGXJ3A.js} +1 -1
- package/dist/{chunk-5S7M2AJL.js → chunk-W2FBLCOR.js} +1 -1
- package/dist/{chunk-XF3WUF3F.js → chunk-ZFBY2FNS.js} +2 -2
- package/dist/{chunk-2GK4LDPV.js → chunk-ZLUID5BU.js} +2 -2
- package/dist/core/api-key/api-key.service.d.ts +1 -0
- package/dist/core/api-key/api-key.service.js +3 -2
- package/dist/core/api-key/errors.d.ts +21 -0
- package/dist/core/api-key/errors.js +11 -0
- package/dist/core/api-key/index.d.ts +1 -0
- package/dist/core/api-key/index.js +15 -7
- package/dist/core/auth/adapters/sql/email-token-repository.js +2 -2
- package/dist/core/auth/adapters/sql/index.js +8 -8
- package/dist/core/auth/adapters/sql/oauth-account-repository.js +2 -2
- package/dist/core/auth/adapters/sql/user-repository.js +2 -2
- package/dist/core/auth/config.js +2 -1
- package/dist/core/auth/cookie-names.d.ts +3 -0
- package/dist/core/auth/cookie-names.js +9 -0
- package/dist/core/auth/index.js +9 -8
- package/dist/core/auth/jwt/cookie.js +4 -3
- package/dist/core/auth/jwt/index.js +4 -3
- package/dist/core/auth/oauth/index.js +7 -7
- package/dist/core/auth/oauth/providers/index.js +6 -6
- package/dist/core/auth/services/cache-token-stores.d.ts +45 -0
- package/dist/core/auth/services/cache-token-stores.js +59 -0
- package/dist/core/auth/services/index.js +4 -3
- package/dist/core/auth/services/login.service.js +4 -3
- package/dist/core/auth/services/oauth-callback.service.js +4 -3
- package/dist/core/auth/services/token-refresh.service.js +4 -3
- package/dist/core/auth/token-delivery.js +5 -4
- package/dist/core/cache/cache-config.js +4 -4
- package/dist/core/cache/cache-env.js +3 -3
- package/dist/core/cache/cache-factory.js +9 -9
- package/dist/core/cache/cache-invalidation.js +10 -10
- package/dist/core/cache/cache-redis.js +4 -4
- package/dist/core/cache/cache-wrapper.js +10 -10
- package/dist/core/cache/cache.js +16 -16
- package/dist/core/cache/config.js +2 -2
- package/dist/core/cache/hybrid-cache-manager.js +5 -5
- package/dist/core/cache/index.js +16 -16
- package/dist/core/cache/noop-cache-manager.js +5 -5
- package/dist/core/cache/redis-cache-manager.js +5 -5
- package/dist/core/constants/error-codes.js +1 -1
- package/dist/core/constants/index.js +1 -1
- package/dist/core/error/app-error.js +2 -2
- package/dist/core/error/friendly-messages-v2.js +2 -2
- package/dist/core/error/friendly-messages.js +1 -1
- package/dist/core/error/index.js +5 -5
- package/dist/core/storage/r2-storage.js +2 -2
- package/dist/core/system/environment.js +6 -5
- package/dist/core/system/health-check.js +3 -3
- package/dist/core/system/index.js +10 -9
- package/dist/core/utils/optimistic-lock.js +2 -2
- package/dist/initialize.js +11 -10
- package/dist/next/auth-handlers/index.js +14 -13
- package/dist/next/auth-handlers/login.handler.js +6 -5
- package/dist/next/auth-handlers/logout.handler.js +5 -4
- package/dist/next/auth-handlers/me.handler.js +6 -5
- package/dist/next/auth-handlers/oauth-authorize.handler.js +4 -4
- package/dist/next/auth-handlers/oauth-callback.handler.js +8 -7
- package/dist/next/auth-handlers/refresh.handler.js +6 -5
- package/dist/next/auth-types/handler-types.js +5 -4
- package/dist/next/auth-types/index.js +5 -4
- package/dist/next/error/error-handler.js +4 -4
- package/dist/next/error/index.js +5 -5
- package/dist/next/middleware/auth.js +10 -9
- package/dist/next/middleware/error-handler.js +5 -5
- package/dist/next/middleware/index.js +27 -26
- package/dist/next/middleware/rate-limit.js +3 -3
- package/dist/next/middleware/wrappers.js +16 -15
- package/dist/next/oapi/api-key-auth.js +6 -5
- package/dist/next/oapi/index.js +6 -5
- package/dist/next/proxy.d.ts +38 -0
- package/dist/next/proxy.js +53 -0
- package/dist/next/utils/api-helpers.js +2 -2
- package/dist/next/utils/error-processor.js +3 -3
- package/dist/next/utils/index.js +27 -27
- package/package.json +13 -3
- package/dist/{chunk-GSRAIDD7.js → chunk-6A5JHOBB.js} +3 -3
- package/dist/{chunk-43XXILCX.js → chunk-BTYH4MHU.js} +3 -3
- package/dist/{chunk-MXWSG6ER.js → chunk-KYUJ6D65.js} +0 -0
- package/dist/{chunk-ER6LSA4M.js → chunk-P7WHMKN5.js} +6 -6
- package/dist/{chunk-7KIM5MHV.js → chunk-RHYETIUR.js} +3 -3
- package/dist/{chunk-5VDT3ZB4.js → chunk-VQJY52YF.js} +3 -3
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
JWT_DEFAULTS
|
|
3
3
|
} from "./chunk-7YWUKMZD.js";
|
|
4
|
+
import {
|
|
5
|
+
durationToSeconds
|
|
6
|
+
} from "./chunk-OVOBSYR4.js";
|
|
4
7
|
import {
|
|
5
8
|
configWarn
|
|
6
9
|
} from "./chunk-6J2EJVND.js";
|
|
@@ -9,6 +12,7 @@ import {
|
|
|
9
12
|
} from "./chunk-F3R3UYBF.js";
|
|
10
13
|
|
|
11
14
|
// src/core/auth/config.ts
|
|
15
|
+
var LONG_ACCESS_WARN_THRESHOLD_SEC = 24 * 3600;
|
|
12
16
|
function initializeAuth(config) {
|
|
13
17
|
var _a, _b, _c, _d, _e;
|
|
14
18
|
(_a = globalThis.__withwiz_config) != null ? _a : globalThis.__withwiz_config = {};
|
|
@@ -22,10 +26,21 @@ function initializeAuth(config) {
|
|
|
22
26
|
if (!config.refreshTokenExpiry) {
|
|
23
27
|
configWarn("Auth", `refreshTokenExpiry not provided, using default: ${JWT_DEFAULTS.DEFAULT_REFRESH_TOKEN_EXPIRES}`);
|
|
24
28
|
}
|
|
29
|
+
const accessTokenExpiry = (_b = config.accessTokenExpiry) != null ? _b : JWT_DEFAULTS.DEFAULT_ACCESS_TOKEN_EXPIRES;
|
|
30
|
+
const refreshTokenExpiry = (_c = config.refreshTokenExpiry) != null ? _c : JWT_DEFAULTS.DEFAULT_REFRESH_TOKEN_EXPIRES;
|
|
31
|
+
try {
|
|
32
|
+
if (durationToSeconds(accessTokenExpiry) > LONG_ACCESS_WARN_THRESHOLD_SEC) {
|
|
33
|
+
configWarn(
|
|
34
|
+
"Auth",
|
|
35
|
+
`accessTokenExpiry(${accessTokenExpiry})\uAC00 24h\uB97C \uCD08\uACFC\uD569\uB2C8\uB2E4. refresh \uD1A0\uD070\uC774 \uC788\uB2E4\uBA74 \uC9E7\uC740 access(\uC608: 15m)\uB97C \uAD8C\uC7A5\uD569\uB2C8\uB2E4 \u2014 revoke/\uB9CC\uB8CC \uD6A8\uACFC \uADF9\uB300\uD654.`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
} catch (e) {
|
|
39
|
+
}
|
|
25
40
|
globalThis.__withwiz_config.auth = {
|
|
26
41
|
jwtSecret: config.jwtSecret,
|
|
27
|
-
accessTokenExpiry
|
|
28
|
-
refreshTokenExpiry
|
|
42
|
+
accessTokenExpiry,
|
|
43
|
+
refreshTokenExpiry,
|
|
29
44
|
cookieSecure: (_d = config.cookieSecure) != null ? _d : false,
|
|
30
45
|
tokenDelivery: (_e = config.tokenDelivery) != null ? _e : "hybrid"
|
|
31
46
|
};
|
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
isRedisGloballyDisabled,
|
|
6
6
|
notifyRedisError
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-MTRPUJ4B.js";
|
|
8
8
|
import {
|
|
9
9
|
logger
|
|
10
10
|
} from "./chunk-QAIN3WNN.js";
|
|
11
11
|
import {
|
|
12
12
|
getCacheFallbackConfig
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BPDYEB37.js";
|
|
14
14
|
import {
|
|
15
15
|
__spreadValues
|
|
16
16
|
} from "./chunk-N3ETBM74.js";
|
|
@@ -13,6 +13,7 @@ export declare class ApiKeyService {
|
|
|
13
13
|
private prefix;
|
|
14
14
|
private toInfo;
|
|
15
15
|
private requireOwned;
|
|
16
|
+
private assertPlanNotRestricted;
|
|
16
17
|
generateApiKey(userId: string, options: CreateApiKeyOptions, plan: string): Promise<ApiKeyResult>;
|
|
17
18
|
validateApiKey(rawKey: string): Promise<ApiKeyValidationResult>;
|
|
18
19
|
getApiKey(id: string, userId: string, isAdmin?: boolean): Promise<ApiKeyInfo>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ApiKeyService
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-ZZTBIA57.js";
|
|
3
|
+
} from "../../chunk-G4IGD3AZ.js";
|
|
5
4
|
import "../../chunk-BTNM5YSU.js";
|
|
5
|
+
import "../../chunk-4JZIIMAF.js";
|
|
6
|
+
import "../../chunk-ZZTBIA57.js";
|
|
6
7
|
import "../../chunk-N3ETBM74.js";
|
|
7
8
|
export {
|
|
8
9
|
ApiKeyService
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const API_KEY_ERROR_CODES: {
|
|
2
|
+
/** 대상 API 키 미존재 */
|
|
3
|
+
readonly NOT_FOUND: "API_KEY_NOT_FOUND";
|
|
4
|
+
/** 비소유자 접근 (admin 우회 제외) */
|
|
5
|
+
readonly OWNERSHIP: "API_KEY_OWNERSHIP";
|
|
6
|
+
/** 제한 플랜(restrictedPlans)의 발급 시도 */
|
|
7
|
+
readonly PLAN_RESTRICTED: "API_KEY_PLAN_RESTRICTED";
|
|
8
|
+
/** 플랜별 활성 키 한도 초과 */
|
|
9
|
+
readonly LIMIT_REACHED: "API_KEY_LIMIT_REACHED";
|
|
10
|
+
};
|
|
11
|
+
export type ApiKeyErrorCode = (typeof API_KEY_ERROR_CODES)[keyof typeof API_KEY_ERROR_CODES];
|
|
12
|
+
export declare class ApiKeyError extends Error {
|
|
13
|
+
readonly code: ApiKeyErrorCode;
|
|
14
|
+
constructor(message: string, code: ApiKeyErrorCode);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* ApiKeyError 판별 가드. instanceof 대신 name+code 구조 검사를 사용해
|
|
18
|
+
* 패키지 중복 설치(모듈 인스턴스 분리) 환경에서도 판별이 깨지지 않는다.
|
|
19
|
+
* code를 지정하면 해당 코드까지 일치해야 true.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isApiKeyError(error: unknown, code?: ApiKeyErrorCode): error is ApiKeyError;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from '@withwiz/toolkit/core/api-key/types';
|
|
2
|
+
export * from '@withwiz/toolkit/core/api-key/errors';
|
|
2
3
|
export * from '@withwiz/toolkit/core/api-key/ports';
|
|
3
4
|
export * from '@withwiz/toolkit/core/api-key/key-generator';
|
|
4
5
|
export * from '@withwiz/toolkit/core/api-key/ip-whitelist';
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import "../../chunk-
|
|
1
|
+
import "../../chunk-KYUJ6D65.js";
|
|
2
|
+
import "../../chunk-TN5ZNYR2.js";
|
|
2
3
|
import {
|
|
3
4
|
ApiKeyService
|
|
4
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-G4IGD3AZ.js";
|
|
6
|
+
import {
|
|
7
|
+
validateApiKeyRecord
|
|
8
|
+
} from "../../chunk-BTNM5YSU.js";
|
|
9
|
+
import {
|
|
10
|
+
API_KEY_ERROR_CODES,
|
|
11
|
+
ApiKeyError,
|
|
12
|
+
isApiKeyError
|
|
13
|
+
} from "../../chunk-4JZIIMAF.js";
|
|
5
14
|
import {
|
|
6
15
|
isIpAllowed,
|
|
7
16
|
isIpInCidr
|
|
@@ -11,16 +20,15 @@ import {
|
|
|
11
20
|
hashKey,
|
|
12
21
|
keyPreview
|
|
13
22
|
} from "../../chunk-ZZTBIA57.js";
|
|
14
|
-
import "../../chunk-CWS5RPRX.js";
|
|
15
|
-
import "../../chunk-TN5ZNYR2.js";
|
|
16
|
-
import {
|
|
17
|
-
validateApiKeyRecord
|
|
18
|
-
} from "../../chunk-BTNM5YSU.js";
|
|
19
23
|
import "../../chunk-N3ETBM74.js";
|
|
24
|
+
import "../../chunk-CWS5RPRX.js";
|
|
20
25
|
export {
|
|
26
|
+
API_KEY_ERROR_CODES,
|
|
27
|
+
ApiKeyError,
|
|
21
28
|
ApiKeyService,
|
|
22
29
|
generateRawKey,
|
|
23
30
|
hashKey,
|
|
31
|
+
isApiKeyError,
|
|
24
32
|
isIpAllowed,
|
|
25
33
|
isIpInCidr,
|
|
26
34
|
keyPreview,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SqlEmailTokenRepository
|
|
3
|
-
} from "../../../../chunk-
|
|
4
|
-
import "../../../../chunk-E4TKORMQ.js";
|
|
3
|
+
} from "../../../../chunk-BTYH4MHU.js";
|
|
5
4
|
import "../../../../chunk-2JUFL4KX.js";
|
|
5
|
+
import "../../../../chunk-E4TKORMQ.js";
|
|
6
6
|
import "../../../../chunk-N3ETBM74.js";
|
|
7
7
|
export {
|
|
8
8
|
SqlEmailTokenRepository
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SqlEmailTokenRepository
|
|
3
|
+
} from "../../../../chunk-BTYH4MHU.js";
|
|
1
4
|
import {
|
|
2
5
|
SqlOAuthAccountRepository
|
|
3
|
-
} from "../../../../chunk-
|
|
6
|
+
} from "../../../../chunk-VQJY52YF.js";
|
|
4
7
|
import {
|
|
5
8
|
SqlUserRepository
|
|
6
|
-
} from "../../../../chunk-
|
|
7
|
-
import {
|
|
8
|
-
SqlEmailTokenRepository
|
|
9
|
-
} from "../../../../chunk-43XXILCX.js";
|
|
10
|
-
import {
|
|
11
|
-
resolveConfig
|
|
12
|
-
} from "../../../../chunk-E4TKORMQ.js";
|
|
9
|
+
} from "../../../../chunk-6A5JHOBB.js";
|
|
13
10
|
import {
|
|
14
11
|
ParamBuilder,
|
|
15
12
|
columnList,
|
|
16
13
|
getDialect
|
|
17
14
|
} from "../../../../chunk-2JUFL4KX.js";
|
|
15
|
+
import {
|
|
16
|
+
resolveConfig
|
|
17
|
+
} from "../../../../chunk-E4TKORMQ.js";
|
|
18
18
|
import "../../../../chunk-N3ETBM74.js";
|
|
19
19
|
export {
|
|
20
20
|
ParamBuilder,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SqlOAuthAccountRepository
|
|
3
|
-
} from "../../../../chunk-
|
|
4
|
-
import "../../../../chunk-E4TKORMQ.js";
|
|
3
|
+
} from "../../../../chunk-VQJY52YF.js";
|
|
5
4
|
import "../../../../chunk-2JUFL4KX.js";
|
|
5
|
+
import "../../../../chunk-E4TKORMQ.js";
|
|
6
6
|
import "../../../../chunk-N3ETBM74.js";
|
|
7
7
|
export {
|
|
8
8
|
SqlOAuthAccountRepository
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SqlUserRepository
|
|
3
|
-
} from "../../../../chunk-
|
|
4
|
-
import "../../../../chunk-E4TKORMQ.js";
|
|
3
|
+
} from "../../../../chunk-6A5JHOBB.js";
|
|
5
4
|
import "../../../../chunk-2JUFL4KX.js";
|
|
5
|
+
import "../../../../chunk-E4TKORMQ.js";
|
|
6
6
|
import "../../../../chunk-N3ETBM74.js";
|
|
7
7
|
export {
|
|
8
8
|
SqlUserRepository
|
package/dist/core/auth/config.js
CHANGED
|
@@ -2,8 +2,9 @@ import {
|
|
|
2
2
|
getAuthConfig,
|
|
3
3
|
initializeAuth,
|
|
4
4
|
resetAuth
|
|
5
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-TQMQ5XXG.js";
|
|
6
6
|
import "../../chunk-7YWUKMZD.js";
|
|
7
|
+
import "../../chunk-OVOBSYR4.js";
|
|
7
8
|
import "../../chunk-6J2EJVND.js";
|
|
8
9
|
import "../../chunk-F3R3UYBF.js";
|
|
9
10
|
import "../../chunk-N3ETBM74.js";
|
package/dist/core/auth/index.js
CHANGED
|
@@ -36,12 +36,8 @@ import {
|
|
|
36
36
|
} from "../../chunk-ILMPKSWS.js";
|
|
37
37
|
import {
|
|
38
38
|
OAuthManager
|
|
39
|
-
} from "../../chunk-
|
|
39
|
+
} from "../../chunk-P7WHMKN5.js";
|
|
40
40
|
import "../../chunk-CDALZTPN.js";
|
|
41
|
-
import "../../chunk-GSSHHVHF.js";
|
|
42
|
-
import {
|
|
43
|
-
GitHubOAuthProvider
|
|
44
|
-
} from "../../chunk-HIZ7USIF.js";
|
|
45
41
|
import {
|
|
46
42
|
GoogleOAuthProvider
|
|
47
43
|
} from "../../chunk-GF3DKZIW.js";
|
|
@@ -49,6 +45,10 @@ import {
|
|
|
49
45
|
KakaoOAuthProvider
|
|
50
46
|
} from "../../chunk-65HVR74O.js";
|
|
51
47
|
import "../../chunk-33RIHX7O.js";
|
|
48
|
+
import "../../chunk-GSSHHVHF.js";
|
|
49
|
+
import {
|
|
50
|
+
GitHubOAuthProvider
|
|
51
|
+
} from "../../chunk-HIZ7USIF.js";
|
|
52
52
|
import "../../chunk-JLRMET4V.js";
|
|
53
53
|
import {
|
|
54
54
|
TokenGenerator
|
|
@@ -70,12 +70,13 @@ import {
|
|
|
70
70
|
OAuthError,
|
|
71
71
|
PasswordError
|
|
72
72
|
} from "../../chunk-5GWGARXI.js";
|
|
73
|
-
import "../../chunk-
|
|
74
|
-
import "../../chunk-
|
|
75
|
-
import "../../chunk-N3TCQ5BF.js";
|
|
73
|
+
import "../../chunk-DTRXWS7G.js";
|
|
74
|
+
import "../../chunk-TQMQ5XXG.js";
|
|
76
75
|
import "../../chunk-7YWUKMZD.js";
|
|
76
|
+
import "../../chunk-OVOBSYR4.js";
|
|
77
77
|
import "../../chunk-6J2EJVND.js";
|
|
78
78
|
import "../../chunk-F3R3UYBF.js";
|
|
79
|
+
import "../../chunk-6NFMRZWB.js";
|
|
79
80
|
import "../../chunk-N3ETBM74.js";
|
|
80
81
|
export {
|
|
81
82
|
AUTH_ERROR_CODES,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
clearTokenCookies,
|
|
3
3
|
setTokenCookies
|
|
4
|
-
} from "../../../chunk-
|
|
5
|
-
import "../../../chunk-
|
|
6
|
-
import "../../../chunk-N3TCQ5BF.js";
|
|
4
|
+
} from "../../../chunk-DTRXWS7G.js";
|
|
5
|
+
import "../../../chunk-TQMQ5XXG.js";
|
|
7
6
|
import "../../../chunk-7YWUKMZD.js";
|
|
7
|
+
import "../../../chunk-OVOBSYR4.js";
|
|
8
8
|
import "../../../chunk-6J2EJVND.js";
|
|
9
9
|
import "../../../chunk-F3R3UYBF.js";
|
|
10
|
+
import "../../../chunk-6NFMRZWB.js";
|
|
10
11
|
import "../../../chunk-N3ETBM74.js";
|
|
11
12
|
export {
|
|
12
13
|
clearTokenCookies,
|
|
@@ -6,12 +6,13 @@ import "../../../chunk-5GWGARXI.js";
|
|
|
6
6
|
import {
|
|
7
7
|
clearTokenCookies,
|
|
8
8
|
setTokenCookies
|
|
9
|
-
} from "../../../chunk-
|
|
10
|
-
import "../../../chunk-
|
|
11
|
-
import "../../../chunk-N3TCQ5BF.js";
|
|
9
|
+
} from "../../../chunk-DTRXWS7G.js";
|
|
10
|
+
import "../../../chunk-TQMQ5XXG.js";
|
|
12
11
|
import "../../../chunk-7YWUKMZD.js";
|
|
12
|
+
import "../../../chunk-OVOBSYR4.js";
|
|
13
13
|
import "../../../chunk-6J2EJVND.js";
|
|
14
14
|
import "../../../chunk-F3R3UYBF.js";
|
|
15
|
+
import "../../../chunk-6NFMRZWB.js";
|
|
15
16
|
import "../../../chunk-N3ETBM74.js";
|
|
16
17
|
export {
|
|
17
18
|
JWTManager,
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
OAuthManager
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-P7WHMKN5.js";
|
|
4
4
|
import "../../../chunk-CDALZTPN.js";
|
|
5
|
-
import {
|
|
6
|
-
MicrosoftOAuthProvider
|
|
7
|
-
} from "../../../chunk-GSSHHVHF.js";
|
|
8
|
-
import {
|
|
9
|
-
GitHubOAuthProvider
|
|
10
|
-
} from "../../../chunk-HIZ7USIF.js";
|
|
11
5
|
import {
|
|
12
6
|
GoogleOAuthProvider
|
|
13
7
|
} from "../../../chunk-GF3DKZIW.js";
|
|
@@ -17,6 +11,12 @@ import {
|
|
|
17
11
|
import {
|
|
18
12
|
MetaOAuthProvider
|
|
19
13
|
} from "../../../chunk-33RIHX7O.js";
|
|
14
|
+
import {
|
|
15
|
+
MicrosoftOAuthProvider
|
|
16
|
+
} from "../../../chunk-GSSHHVHF.js";
|
|
17
|
+
import {
|
|
18
|
+
GitHubOAuthProvider
|
|
19
|
+
} from "../../../chunk-HIZ7USIF.js";
|
|
20
20
|
import {
|
|
21
21
|
OAUTH_STATE_COOKIE,
|
|
22
22
|
clearOAuthStateCookie,
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import "../../../../chunk-CDALZTPN.js";
|
|
2
|
-
import {
|
|
3
|
-
MicrosoftOAuthProvider
|
|
4
|
-
} from "../../../../chunk-GSSHHVHF.js";
|
|
5
|
-
import {
|
|
6
|
-
GitHubOAuthProvider
|
|
7
|
-
} from "../../../../chunk-HIZ7USIF.js";
|
|
8
2
|
import {
|
|
9
3
|
GoogleOAuthProvider
|
|
10
4
|
} from "../../../../chunk-GF3DKZIW.js";
|
|
@@ -14,6 +8,12 @@ import {
|
|
|
14
8
|
import {
|
|
15
9
|
MetaOAuthProvider
|
|
16
10
|
} from "../../../../chunk-33RIHX7O.js";
|
|
11
|
+
import {
|
|
12
|
+
MicrosoftOAuthProvider
|
|
13
|
+
} from "../../../../chunk-GSSHHVHF.js";
|
|
14
|
+
import {
|
|
15
|
+
GitHubOAuthProvider
|
|
16
|
+
} from "../../../../chunk-HIZ7USIF.js";
|
|
17
17
|
import "../../../../chunk-5GWGARXI.js";
|
|
18
18
|
import "../../../../chunk-N3ETBM74.js";
|
|
19
19
|
export {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { IRefreshTokenStore } from '@withwiz/toolkit/core/auth/services/refresh-token-store';
|
|
2
|
+
/**
|
|
3
|
+
* store 가 요구하는 최소 cache 형태 — IUnifiedCacheManager 의 부분집합.
|
|
4
|
+
* ttl 은 초 단위. (InMemoryCacheManager/HybridCacheManager 등이 그대로 만족)
|
|
5
|
+
*/
|
|
6
|
+
export interface TokenStoreCache {
|
|
7
|
+
set<T>(key: string, value: T, ttl?: number): Promise<void>;
|
|
8
|
+
delete(key: string): Promise<void>;
|
|
9
|
+
exists(key: string): Promise<boolean>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* next/middleware 의 IAccessTokenBlacklistChecker 와 구조적으로 호환한다
|
|
13
|
+
* (isAccessTokenRevoked). setAccessTokenBlacklistChecker(store) 로 주입 가능.
|
|
14
|
+
*/
|
|
15
|
+
export interface CacheAccessTokenBlacklist {
|
|
16
|
+
/** 이 access 토큰이 revoke 되었는지 여부. */
|
|
17
|
+
isAccessTokenRevoked(token: string): Promise<boolean>;
|
|
18
|
+
/** access 토큰 revoke — 남은 만료까지의 TTL(초). */
|
|
19
|
+
revokeAccessToken(token: string, ttlSec: number): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export interface CacheBlacklistOptions {
|
|
22
|
+
/** 키 네임스페이스 프리픽스. 기본 'revoked:at:' */
|
|
23
|
+
prefix?: string;
|
|
24
|
+
/** 토큰 → 키 식별자 변형. 기본 sha256 hex (원문 키 저장 지양). */
|
|
25
|
+
deriveId?: (token: string) => string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* access 토큰 blacklist(revoke) 를 cache 로 구현.
|
|
29
|
+
* 키: `${prefix}${sha256(token)}` = 1, TTL = 토큰 잔여 만료.
|
|
30
|
+
*/
|
|
31
|
+
export declare function createCacheBlacklistChecker(cache: TokenStoreCache, opts?: CacheBlacklistOptions): CacheAccessTokenBlacklist;
|
|
32
|
+
export interface CacheRefreshStoreOptions {
|
|
33
|
+
/** used jti 키 프리픽스. 기본 'rt:used:' */
|
|
34
|
+
usedPrefix?: string;
|
|
35
|
+
/** family revoke 키 프리픽스. 기본 'rt:famrevoked:' */
|
|
36
|
+
familyPrefix?: string;
|
|
37
|
+
/** meta.expiresAt 이 없을 때 사용할 기본 TTL(초). 기본 30d. */
|
|
38
|
+
defaultTtlSec?: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* refresh 토큰 store(회전/재사용탐지/family revoke)를 cache 로 구현.
|
|
42
|
+
* 키: used=`${usedPrefix}${jti}`, family=`${familyPrefix}${familyId}`.
|
|
43
|
+
* TTL 은 meta.expiresAt 잔여시간에 정렬(없으면 defaultTtlSec).
|
|
44
|
+
*/
|
|
45
|
+
export declare function createCacheRefreshTokenStore(cache: TokenStoreCache, opts?: CacheRefreshStoreOptions): IRefreshTokenStore;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import "../../../chunk-N3ETBM74.js";
|
|
2
|
+
|
|
3
|
+
// src/core/auth/services/cache-token-stores.ts
|
|
4
|
+
import { createHash } from "crypto";
|
|
5
|
+
var sha256Hex = (value) => createHash("sha256").update(value).digest("hex");
|
|
6
|
+
var normalizeTtl = (ttlSec, fallback) => {
|
|
7
|
+
const s = Math.floor(ttlSec);
|
|
8
|
+
return s > 0 ? s : fallback;
|
|
9
|
+
};
|
|
10
|
+
function createCacheBlacklistChecker(cache, opts = {}) {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const prefix = (_a = opts.prefix) != null ? _a : "revoked:at:";
|
|
13
|
+
const deriveId = (_b = opts.deriveId) != null ? _b : sha256Hex;
|
|
14
|
+
const keyFor = (token) => `${prefix}${deriveId(token)}`;
|
|
15
|
+
return {
|
|
16
|
+
async revokeAccessToken(token, ttlSec) {
|
|
17
|
+
await cache.set(keyFor(token), 1, normalizeTtl(ttlSec, 1));
|
|
18
|
+
},
|
|
19
|
+
async isAccessTokenRevoked(token) {
|
|
20
|
+
return cache.exists(keyFor(token));
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
var THIRTY_DAYS_SEC = 30 * 86400;
|
|
25
|
+
function createCacheRefreshTokenStore(cache, opts = {}) {
|
|
26
|
+
var _a, _b, _c;
|
|
27
|
+
const usedPrefix = (_a = opts.usedPrefix) != null ? _a : "rt:used:";
|
|
28
|
+
const familyPrefix = (_b = opts.familyPrefix) != null ? _b : "rt:famrevoked:";
|
|
29
|
+
const defaultTtl = (_c = opts.defaultTtlSec) != null ? _c : THIRTY_DAYS_SEC;
|
|
30
|
+
const ttlFrom = (expiresAt) => {
|
|
31
|
+
if (!expiresAt) return defaultTtl;
|
|
32
|
+
return normalizeTtl((expiresAt.getTime() - Date.now()) / 1e3, defaultTtl);
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
async isUsed(jti) {
|
|
36
|
+
return cache.exists(`${usedPrefix}${jti}`);
|
|
37
|
+
},
|
|
38
|
+
async markUsed(jti, meta) {
|
|
39
|
+
await cache.set(`${usedPrefix}${jti}`, 1, ttlFrom(meta == null ? void 0 : meta.expiresAt));
|
|
40
|
+
},
|
|
41
|
+
async isFamilyRevoked(familyId) {
|
|
42
|
+
return cache.exists(`${familyPrefix}${familyId}`);
|
|
43
|
+
},
|
|
44
|
+
async revokeFamily(familyId) {
|
|
45
|
+
await cache.set(`${familyPrefix}${familyId}`, 1, defaultTtl);
|
|
46
|
+
},
|
|
47
|
+
async register(record) {
|
|
48
|
+
await cache.set(
|
|
49
|
+
`${usedPrefix}issued:${record.jti}`,
|
|
50
|
+
{ familyId: record.familyId, userId: record.userId },
|
|
51
|
+
ttlFrom(record.expiresAt)
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
createCacheBlacklistChecker,
|
|
58
|
+
createCacheRefreshTokenStore
|
|
59
|
+
};
|
|
@@ -20,12 +20,13 @@ import "../../../chunk-ZZABL54F.js";
|
|
|
20
20
|
import "../../../chunk-GH3U4WRE.js";
|
|
21
21
|
import "../../../chunk-LWHLB2Y6.js";
|
|
22
22
|
import "../../../chunk-5GWGARXI.js";
|
|
23
|
-
import "../../../chunk-
|
|
24
|
-
import "../../../chunk-
|
|
25
|
-
import "../../../chunk-N3TCQ5BF.js";
|
|
23
|
+
import "../../../chunk-DTRXWS7G.js";
|
|
24
|
+
import "../../../chunk-TQMQ5XXG.js";
|
|
26
25
|
import "../../../chunk-7YWUKMZD.js";
|
|
26
|
+
import "../../../chunk-OVOBSYR4.js";
|
|
27
27
|
import "../../../chunk-6J2EJVND.js";
|
|
28
28
|
import "../../../chunk-F3R3UYBF.js";
|
|
29
|
+
import "../../../chunk-6NFMRZWB.js";
|
|
29
30
|
import "../../../chunk-N3ETBM74.js";
|
|
30
31
|
export {
|
|
31
32
|
EmailVerificationService,
|
|
@@ -3,12 +3,13 @@ import {
|
|
|
3
3
|
} from "../../../chunk-TNDEYJEL.js";
|
|
4
4
|
import "../../../chunk-LWHLB2Y6.js";
|
|
5
5
|
import "../../../chunk-5GWGARXI.js";
|
|
6
|
-
import "../../../chunk-
|
|
7
|
-
import "../../../chunk-
|
|
8
|
-
import "../../../chunk-N3TCQ5BF.js";
|
|
6
|
+
import "../../../chunk-DTRXWS7G.js";
|
|
7
|
+
import "../../../chunk-TQMQ5XXG.js";
|
|
9
8
|
import "../../../chunk-7YWUKMZD.js";
|
|
9
|
+
import "../../../chunk-OVOBSYR4.js";
|
|
10
10
|
import "../../../chunk-6J2EJVND.js";
|
|
11
11
|
import "../../../chunk-F3R3UYBF.js";
|
|
12
|
+
import "../../../chunk-6NFMRZWB.js";
|
|
12
13
|
import "../../../chunk-N3ETBM74.js";
|
|
13
14
|
export {
|
|
14
15
|
LoginService
|
|
@@ -3,12 +3,13 @@ import {
|
|
|
3
3
|
} from "../../../chunk-MTZXWVW3.js";
|
|
4
4
|
import "../../../chunk-LWHLB2Y6.js";
|
|
5
5
|
import "../../../chunk-5GWGARXI.js";
|
|
6
|
-
import "../../../chunk-
|
|
7
|
-
import "../../../chunk-
|
|
8
|
-
import "../../../chunk-N3TCQ5BF.js";
|
|
6
|
+
import "../../../chunk-DTRXWS7G.js";
|
|
7
|
+
import "../../../chunk-TQMQ5XXG.js";
|
|
9
8
|
import "../../../chunk-7YWUKMZD.js";
|
|
9
|
+
import "../../../chunk-OVOBSYR4.js";
|
|
10
10
|
import "../../../chunk-6J2EJVND.js";
|
|
11
11
|
import "../../../chunk-F3R3UYBF.js";
|
|
12
|
+
import "../../../chunk-6NFMRZWB.js";
|
|
12
13
|
import "../../../chunk-N3ETBM74.js";
|
|
13
14
|
export {
|
|
14
15
|
OAuthCallbackService
|
|
@@ -3,12 +3,13 @@ import {
|
|
|
3
3
|
} from "../../../chunk-XAGPZLRK.js";
|
|
4
4
|
import "../../../chunk-LWHLB2Y6.js";
|
|
5
5
|
import "../../../chunk-5GWGARXI.js";
|
|
6
|
-
import "../../../chunk-
|
|
7
|
-
import "../../../chunk-
|
|
8
|
-
import "../../../chunk-N3TCQ5BF.js";
|
|
6
|
+
import "../../../chunk-DTRXWS7G.js";
|
|
7
|
+
import "../../../chunk-TQMQ5XXG.js";
|
|
9
8
|
import "../../../chunk-7YWUKMZD.js";
|
|
9
|
+
import "../../../chunk-OVOBSYR4.js";
|
|
10
10
|
import "../../../chunk-6J2EJVND.js";
|
|
11
11
|
import "../../../chunk-F3R3UYBF.js";
|
|
12
|
+
import "../../../chunk-6NFMRZWB.js";
|
|
12
13
|
import "../../../chunk-N3ETBM74.js";
|
|
13
14
|
export {
|
|
14
15
|
TokenRefreshService
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getTokenDeliveryStrategy,
|
|
3
3
|
resolveTokenDelivery
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
7
|
-
import "../../chunk-N3TCQ5BF.js";
|
|
4
|
+
} from "../../chunk-HNFYO5XV.js";
|
|
5
|
+
import "../../chunk-DTRXWS7G.js";
|
|
6
|
+
import "../../chunk-TQMQ5XXG.js";
|
|
8
7
|
import "../../chunk-7YWUKMZD.js";
|
|
8
|
+
import "../../chunk-OVOBSYR4.js";
|
|
9
9
|
import "../../chunk-6J2EJVND.js";
|
|
10
10
|
import "../../chunk-F3R3UYBF.js";
|
|
11
|
+
import "../../chunk-6NFMRZWB.js";
|
|
11
12
|
import "../../chunk-N3ETBM74.js";
|
|
12
13
|
export {
|
|
13
14
|
getTokenDeliveryStrategy,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getCacheConfig,
|
|
3
3
|
getCacheTTL
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-OEZPVNSA.js";
|
|
5
|
+
import "../../chunk-BPDYEB37.js";
|
|
6
6
|
import "../../chunk-PX535BHW.js";
|
|
7
|
-
import "../../chunk-
|
|
7
|
+
import "../../chunk-RHYETIUR.js";
|
|
8
|
+
import "../../chunk-ERFD6YAW.js";
|
|
8
9
|
import "../../chunk-6J2EJVND.js";
|
|
9
10
|
import "../../chunk-F3R3UYBF.js";
|
|
10
|
-
import "../../chunk-ERFD6YAW.js";
|
|
11
11
|
import "../../chunk-N3ETBM74.js";
|
|
12
12
|
export {
|
|
13
13
|
getCacheConfig,
|