@withwiz/toolkit 0.2.7 → 0.3.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/config.d.ts +13 -0
- package/dist/auth/config.js +13 -0
- package/dist/auth/index.js +18 -18
- package/dist/cache/cache-config.js +6 -3
- package/dist/cache/cache-env.d.ts +11 -20
- package/dist/cache/cache-env.js +5 -6
- package/dist/cache/cache-factory.js +14 -9
- package/dist/cache/cache-invalidation.js +15 -10
- package/dist/cache/cache-redis.js +8 -3
- package/dist/cache/cache-wrapper.js +15 -10
- package/dist/cache/cache.js +25 -17
- package/dist/cache/config.d.ts +113 -0
- package/dist/cache/config.js +13 -0
- package/dist/cache/hybrid-cache-manager.js +10 -5
- package/dist/cache/index.d.ts +2 -1
- package/dist/cache/index.js +25 -17
- package/dist/cache/inmemory-cache-manager.js +6 -2
- package/dist/cache/noop-cache-manager.js +7 -4
- package/dist/cache/redis-cache-manager.js +9 -4
- package/dist/chunk-2LCLLZME.js +122 -0
- package/dist/chunk-2QH66EVQ.js +11 -0
- package/dist/{chunk-YVF4RXOK.js → chunk-3GKJ763I.js} +12 -12
- package/dist/{chunk-XN4YP4XO.js → chunk-4CSSGCW5.js} +5 -5
- package/dist/{chunk-WZDS4QEC.js → chunk-576PAKLR.js} +1 -1
- package/dist/chunk-5MBKG2ZD.js +32 -0
- package/dist/{chunk-74MSBKYW.js → chunk-5P4E6SGV.js} +17 -13
- package/dist/{chunk-R5OFGX3C.js → chunk-6VNEAK73.js} +6 -6
- package/dist/{chunk-S73334QY.js → chunk-AWFY2HWG.js} +2 -2
- package/dist/{chunk-YMIDD4YE.js → chunk-BJWG3LH5.js} +6 -6
- package/dist/{chunk-BX5CNRVS.js → chunk-BY653UR3.js} +2 -2
- package/dist/{chunk-HCTNZM7D.js → chunk-C3WPAWID.js} +1 -1
- package/dist/{chunk-JOGXLVUZ.js → chunk-CZHFHEBG.js} +5 -5
- package/dist/{chunk-P6VSEFZE.js → chunk-DC2OFQ43.js} +18 -10
- package/dist/{chunk-HOMWLK62.js → chunk-FGA7VLYK.js} +2 -2
- package/dist/{chunk-T3YUJYBX.js → chunk-FIRLRKET.js} +1 -1
- package/dist/{chunk-LEWQBXN6.js → chunk-FO77EZCU.js} +1 -1
- package/dist/{chunk-WEDR5GJO.js → chunk-GRGOD3W5.js} +2 -2
- package/dist/{chunk-JWZSWMOM.js → chunk-HKJCBV3H.js} +6 -6
- package/dist/chunk-ITSXXSFN.js +42 -0
- package/dist/{chunk-6WVKLXVT.js → chunk-JGGGHEBC.js} +1 -1
- package/dist/chunk-JNB7MWG4.js +40 -0
- package/dist/chunk-JTPLPUI7.js +102 -0
- package/dist/chunk-K25ICPU4.js +8 -0
- package/dist/{chunk-IT43YQND.js → chunk-KAIGEZAL.js} +20 -5
- package/dist/{chunk-AOZVTVJG.js → chunk-L6M4DZV2.js} +1 -1
- package/dist/{chunk-GSUQE3SZ.js → chunk-LX2EYD74.js} +31 -16
- package/dist/{chunk-QMZ75GBU.js → chunk-M776IH4D.js} +3 -3
- package/dist/{chunk-DH2ZHGW2.js → chunk-MVH5ZPFD.js} +14 -2
- package/dist/{chunk-WDJLAZCW.js → chunk-NE33JZW3.js} +18 -3
- package/dist/{chunk-2NNLUXPF.js → chunk-NWAN2VRP.js} +12 -12
- package/dist/{chunk-I5PCM2JQ.js → chunk-PU2LFTI5.js} +4 -4
- package/dist/{chunk-4NWJ3WCZ.js → chunk-Q7NIAITA.js} +8 -1
- package/dist/chunk-RLXRDUBX.js +38 -0
- package/dist/{chunk-AZASEBSP.js → chunk-S54PFAEU.js} +1 -1
- package/dist/{chunk-5A2L6TXD.js → chunk-SNNXLA5F.js} +34 -15
- package/dist/{chunk-M5LIX3TD.js → chunk-STNIT65W.js} +1 -1
- package/dist/{chunk-MZRYR3UQ.js → chunk-TQJDNWBL.js} +4 -4
- package/dist/{chunk-NJXCFTOE.js → chunk-UD7YHLHI.js} +1 -1
- package/dist/{chunk-GCZOXUDV.js → chunk-USL5SQLZ.js} +50 -10
- package/dist/chunk-V33BEN6H.js +31 -0
- package/dist/chunk-X2QSMX3B.js +156 -0
- package/dist/{chunk-Y6IHEA3Q.js → chunk-XZ4HMXSK.js} +1 -1
- package/dist/chunk-YCIYDWJU.js +37 -0
- package/dist/{chunk-7KCWVRPR.js → chunk-ZBU2DYLD.js} +2 -2
- package/dist/{chunk-67KRDPIH.js → chunk-ZFFWKCHN.js} +2 -2
- package/dist/components/ui/DataTable.js +6 -6
- package/dist/components/ui/data-table/DataTable.js +6 -6
- package/dist/components/ui/data-table/DataTableFilters.js +2 -2
- package/dist/components/ui/data-table/DataTableSearch.js +2 -2
- package/dist/config/common.d.ts +9 -0
- package/dist/config/common.js +13 -0
- package/dist/config/errors.d.ts +3 -0
- package/dist/config/errors.js +7 -0
- package/dist/config/warn.d.ts +4 -0
- package/dist/config/warn.js +7 -0
- package/dist/constants/index.js +23 -23
- package/dist/error/error-display.js +5 -5
- package/dist/error/error-handler.js +7 -3
- package/dist/error/friendly-messages-v2.js +3 -3
- package/dist/error/index.js +20 -16
- package/dist/error/messages/index.js +2 -2
- package/dist/geolocation/batch-processor.js +6 -2
- package/dist/geolocation/config.d.ts +11 -0
- package/dist/geolocation/config.js +13 -0
- package/dist/geolocation/index.js +10 -5
- package/dist/geolocation/providers/index.js +6 -3
- package/dist/geolocation/providers/ipgeolocation-provider.js +4 -1
- package/dist/geolocation/providers/maxmind-provider.js +4 -1
- package/dist/initialize.d.ts +18 -0
- package/dist/initialize.js +41 -0
- package/dist/logger/config.d.ts +17 -0
- package/dist/logger/config.js +13 -0
- package/dist/logger/logger.js +5 -1
- package/dist/middleware/auth.js +8 -3
- package/dist/middleware/cors-config.d.ts +11 -0
- package/dist/middleware/cors-config.js +13 -0
- package/dist/middleware/cors.js +7 -2
- package/dist/middleware/error-handler.js +11 -7
- package/dist/middleware/index.js +25 -19
- package/dist/middleware/middleware-chain.js +6 -2
- package/dist/middleware/rate-limit.js +6 -2
- package/dist/middleware/response-logger.js +6 -2
- package/dist/middleware/security.js +6 -2
- package/dist/middleware/wrappers.js +20 -14
- package/dist/storage/config.d.ts +17 -0
- package/dist/storage/config.js +13 -0
- package/dist/storage/r2-storage.d.ts +4 -0
- package/dist/storage/r2-storage.js +19 -10
- package/dist/system/cpu.js +7 -3
- package/dist/system/disk.js +7 -3
- package/dist/system/environment.js +11 -3
- package/dist/system/health-check.js +9 -3
- package/dist/system/index.js +18 -10
- package/dist/system/memory.js +7 -3
- package/dist/system/network.js +7 -3
- package/dist/system/utils.js +6 -2
- package/dist/types/env.d.ts +12 -2
- package/dist/utils/cors.js +5 -1
- package/dist/utils/csv-export.js +6 -2
- package/dist/utils/error-processor.js +6 -2
- package/dist/utils/index.js +31 -26
- package/package.json +10 -1
- package/dist/chunk-N4XYQB2G.js +0 -193
- package/dist/chunk-OFPRBEO6.js +0 -93
- package/dist/{chunk-TH45RVP7.js → chunk-KHYY4KCV.js} +3 -3
- package/dist/{chunk-EBUEBEJX.js → chunk-QMCOX3DP.js} +0 -0
- package/dist/{chunk-LJEGM4OO.js → chunk-SEZJN4TC.js} +3 -3
- package/dist/{chunk-ASXZ2NZJ.js → chunk-Y2JYA2AR.js} +3 -3
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NoopCacheManager
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-FGA7VLYK.js";
|
|
4
|
+
import "../chunk-C3WPAWID.js";
|
|
5
|
+
import "../chunk-X2QSMX3B.js";
|
|
6
|
+
import "../chunk-JTPLPUI7.js";
|
|
7
|
+
import "../chunk-5MBKG2ZD.js";
|
|
7
8
|
import "../chunk-IQQKKUAV.js";
|
|
9
|
+
import "../chunk-K25ICPU4.js";
|
|
10
|
+
import "../chunk-2QH66EVQ.js";
|
|
8
11
|
import "../chunk-ORMEWXMH.js";
|
|
9
12
|
export {
|
|
10
13
|
NoopCacheManager
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RedisCacheManager
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-4CSSGCW5.js";
|
|
4
|
+
import "../chunk-PU2LFTI5.js";
|
|
5
|
+
import "../chunk-SNNXLA5F.js";
|
|
6
|
+
import "../chunk-X2QSMX3B.js";
|
|
7
|
+
import "../chunk-RLXRDUBX.js";
|
|
8
|
+
import "../chunk-JTPLPUI7.js";
|
|
9
|
+
import "../chunk-5MBKG2ZD.js";
|
|
7
10
|
import "../chunk-IQQKKUAV.js";
|
|
11
|
+
import "../chunk-K25ICPU4.js";
|
|
12
|
+
import "../chunk-2QH66EVQ.js";
|
|
8
13
|
import "../chunk-ORMEWXMH.js";
|
|
9
14
|
export {
|
|
10
15
|
RedisCacheManager
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getPlatform
|
|
3
|
+
} from "./chunk-JGGGHEBC.js";
|
|
4
|
+
import {
|
|
5
|
+
getGeolocationConfig
|
|
6
|
+
} from "./chunk-V33BEN6H.js";
|
|
7
|
+
import {
|
|
8
|
+
getResolvedCacheConfig
|
|
9
|
+
} from "./chunk-JTPLPUI7.js";
|
|
10
|
+
import {
|
|
11
|
+
getCommonConfig
|
|
12
|
+
} from "./chunk-5MBKG2ZD.js";
|
|
13
|
+
import {
|
|
14
|
+
getAuthConfig
|
|
15
|
+
} from "./chunk-ITSXXSFN.js";
|
|
16
|
+
|
|
17
|
+
// src/system/environment.ts
|
|
18
|
+
import os from "os";
|
|
19
|
+
function checkEnvironmentVariables() {
|
|
20
|
+
const platform = getPlatform();
|
|
21
|
+
const results = [];
|
|
22
|
+
try {
|
|
23
|
+
const auth = getAuthConfig();
|
|
24
|
+
results.push({
|
|
25
|
+
key: "JWT_SECRET",
|
|
26
|
+
ok: true,
|
|
27
|
+
value: auth.jwtSecret.length > 20 ? auth.jwtSecret.substring(0, 20) + "..." : auth.jwtSecret
|
|
28
|
+
});
|
|
29
|
+
} catch (e) {
|
|
30
|
+
results.push({ key: "JWT_SECRET", ok: false });
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const cache = getResolvedCacheConfig();
|
|
34
|
+
results.push({
|
|
35
|
+
key: "CACHE_ENABLED",
|
|
36
|
+
ok: true,
|
|
37
|
+
value: String(cache.enabled)
|
|
38
|
+
});
|
|
39
|
+
if (cache.redis) {
|
|
40
|
+
results.push({
|
|
41
|
+
key: "UPSTASH_REDIS_REST_URL",
|
|
42
|
+
ok: true,
|
|
43
|
+
value: cache.redis.url.length > 20 ? cache.redis.url.substring(0, 20) + "..." : cache.redis.url
|
|
44
|
+
});
|
|
45
|
+
results.push({ key: "UPSTASH_REDIS_REST_TOKEN", ok: true, value: "***" });
|
|
46
|
+
} else {
|
|
47
|
+
results.push({ key: "UPSTASH_REDIS_REST_URL", ok: false });
|
|
48
|
+
results.push({ key: "UPSTASH_REDIS_REST_TOKEN", ok: false });
|
|
49
|
+
}
|
|
50
|
+
} catch (e) {
|
|
51
|
+
results.push({ key: "CACHE_ENABLED", ok: false });
|
|
52
|
+
results.push({ key: "UPSTASH_REDIS_REST_URL", ok: false });
|
|
53
|
+
results.push({ key: "UPSTASH_REDIS_REST_TOKEN", ok: false });
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const geo = getGeolocationConfig();
|
|
57
|
+
results.push({ key: "IPGEOLOCATION_API_KEY", ok: !!geo.ipgeolocationApiKey });
|
|
58
|
+
results.push({ key: "MAXMIND_LICENSE_KEY", ok: !!geo.maxmindLicenseKey });
|
|
59
|
+
} catch (e) {
|
|
60
|
+
results.push({ key: "IPGEOLOCATION_API_KEY", ok: false });
|
|
61
|
+
results.push({ key: "MAXMIND_LICENSE_KEY", ok: false });
|
|
62
|
+
}
|
|
63
|
+
results.push({
|
|
64
|
+
key: "PLATFORM",
|
|
65
|
+
ok: true,
|
|
66
|
+
value: platform === "darwin" ? "macOS" : "Linux"
|
|
67
|
+
});
|
|
68
|
+
let nodeEnvValue;
|
|
69
|
+
try {
|
|
70
|
+
nodeEnvValue = getCommonConfig().nodeEnv;
|
|
71
|
+
} catch (e) {
|
|
72
|
+
nodeEnvValue = "development";
|
|
73
|
+
}
|
|
74
|
+
results.push({
|
|
75
|
+
key: "NODE_ENV",
|
|
76
|
+
ok: true,
|
|
77
|
+
value: nodeEnvValue
|
|
78
|
+
});
|
|
79
|
+
results.push({
|
|
80
|
+
key: "ARCHITECTURE",
|
|
81
|
+
ok: true,
|
|
82
|
+
value: process.arch
|
|
83
|
+
});
|
|
84
|
+
results.push({
|
|
85
|
+
key: "NODE_VERSION",
|
|
86
|
+
ok: true,
|
|
87
|
+
value: process.version
|
|
88
|
+
});
|
|
89
|
+
results.push({
|
|
90
|
+
key: "HOSTNAME",
|
|
91
|
+
ok: true,
|
|
92
|
+
value: os.hostname()
|
|
93
|
+
});
|
|
94
|
+
results.push({
|
|
95
|
+
key: "USER_HOME",
|
|
96
|
+
ok: true,
|
|
97
|
+
value: os.homedir()
|
|
98
|
+
});
|
|
99
|
+
results.push({
|
|
100
|
+
key: "TEMP_DIR",
|
|
101
|
+
ok: true,
|
|
102
|
+
value: os.tmpdir()
|
|
103
|
+
});
|
|
104
|
+
if (platform === "darwin") {
|
|
105
|
+
results.push({
|
|
106
|
+
key: "MACOS_VERSION",
|
|
107
|
+
ok: true,
|
|
108
|
+
value: os.release()
|
|
109
|
+
});
|
|
110
|
+
} else {
|
|
111
|
+
results.push({
|
|
112
|
+
key: "LINUX_DISTRO",
|
|
113
|
+
ok: true,
|
|
114
|
+
value: os.release()
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return results;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export {
|
|
121
|
+
checkEnvironmentVariables
|
|
122
|
+
};
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RedisCacheManager
|
|
3
|
+
} from "./chunk-4CSSGCW5.js";
|
|
1
4
|
import {
|
|
2
5
|
HybridCacheManager
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6VNEAK73.js";
|
|
4
7
|
import {
|
|
5
8
|
InMemoryCacheManager
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-XZ4HMXSK.js";
|
|
7
10
|
import {
|
|
8
11
|
NoopCacheManager
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import {
|
|
11
|
-
RedisCacheManager
|
|
12
|
-
} from "./chunk-XN4YP4XO.js";
|
|
12
|
+
} from "./chunk-FGA7VLYK.js";
|
|
13
13
|
import {
|
|
14
14
|
getCacheConfig
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-C3WPAWID.js";
|
|
16
16
|
import {
|
|
17
17
|
isRedisAvailableNow,
|
|
18
18
|
isRedisGloballyDisabled
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-PU2LFTI5.js";
|
|
20
|
+
import {
|
|
21
|
+
logger
|
|
22
|
+
} from "./chunk-SNNXLA5F.js";
|
|
20
23
|
import {
|
|
21
24
|
getENV,
|
|
22
25
|
isCacheEnabled
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
import {
|
|
25
|
-
logger
|
|
26
|
-
} from "./chunk-5A2L6TXD.js";
|
|
26
|
+
} from "./chunk-X2QSMX3B.js";
|
|
27
27
|
|
|
28
28
|
// src/cache/cache-factory.ts
|
|
29
29
|
function getInMemoryConfig() {
|
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
isRedisGloballyDisabled,
|
|
4
4
|
notifyRedisError,
|
|
5
5
|
resetRedisGlobalState
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PU2LFTI5.js";
|
|
7
|
+
import {
|
|
8
|
+
logger
|
|
9
|
+
} from "./chunk-SNNXLA5F.js";
|
|
7
10
|
import {
|
|
8
11
|
getENV,
|
|
9
12
|
isCacheEnabled
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import {
|
|
12
|
-
logger
|
|
13
|
-
} from "./chunk-5A2L6TXD.js";
|
|
13
|
+
} from "./chunk-X2QSMX3B.js";
|
|
14
14
|
import {
|
|
15
15
|
__spreadValues
|
|
16
16
|
} from "./chunk-ORMEWXMH.js";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
configWarn
|
|
3
|
+
} from "./chunk-K25ICPU4.js";
|
|
4
|
+
import {
|
|
5
|
+
ConfigurationError
|
|
6
|
+
} from "./chunk-2QH66EVQ.js";
|
|
7
|
+
|
|
8
|
+
// src/config/common.ts
|
|
9
|
+
var _config = null;
|
|
10
|
+
function initializeCommon(config) {
|
|
11
|
+
var _a;
|
|
12
|
+
if (_config) return;
|
|
13
|
+
if (!config.nodeEnv) {
|
|
14
|
+
configWarn("Common", "nodeEnv not provided, using default: development");
|
|
15
|
+
}
|
|
16
|
+
_config = { nodeEnv: (_a = config.nodeEnv) != null ? _a : "development" };
|
|
17
|
+
}
|
|
18
|
+
function getCommonConfig() {
|
|
19
|
+
if (!_config) {
|
|
20
|
+
throw new ConfigurationError("Common", "Not initialized. Call initializeCommon() first.");
|
|
21
|
+
}
|
|
22
|
+
return _config;
|
|
23
|
+
}
|
|
24
|
+
function resetCommon() {
|
|
25
|
+
_config = null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
initializeCommon,
|
|
30
|
+
getCommonConfig,
|
|
31
|
+
resetCommon
|
|
32
|
+
};
|
|
@@ -2,14 +2,17 @@ import {
|
|
|
2
2
|
AppError
|
|
3
3
|
} from "./chunk-KXXROUA5.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
logger
|
|
6
|
+
} from "./chunk-SNNXLA5F.js";
|
|
7
|
+
import {
|
|
8
|
+
getAuthConfig
|
|
9
|
+
} from "./chunk-ITSXXSFN.js";
|
|
7
10
|
import {
|
|
8
11
|
JWTManager
|
|
9
12
|
} from "./chunk-2ATBAIRL.js";
|
|
10
13
|
import {
|
|
11
|
-
|
|
12
|
-
} from "./chunk-
|
|
14
|
+
ERROR_CODES
|
|
15
|
+
} from "./chunk-SNVGJPPX.js";
|
|
13
16
|
|
|
14
17
|
// src/middleware/auth.ts
|
|
15
18
|
function setAccessTokenBlacklistChecker(checker) {
|
|
@@ -26,17 +29,19 @@ var _jwtManager = null;
|
|
|
26
29
|
var _jwtWarningLogged = false;
|
|
27
30
|
function getJWTManager() {
|
|
28
31
|
if (!_jwtManager) {
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
let authConfig;
|
|
33
|
+
try {
|
|
34
|
+
authConfig = getAuthConfig();
|
|
35
|
+
} catch (e) {
|
|
31
36
|
if (!_jwtWarningLogged) {
|
|
32
37
|
logger.warn(
|
|
33
|
-
"[Auth Middleware]
|
|
38
|
+
"[Auth Middleware] Auth not initialized. Authentication is DISABLED.\nCall initializeAuth() or initialize() to enable auth."
|
|
34
39
|
);
|
|
35
40
|
_jwtWarningLogged = true;
|
|
36
41
|
}
|
|
37
42
|
return null;
|
|
38
43
|
}
|
|
39
|
-
if (
|
|
44
|
+
if (authConfig.jwtSecret.length < 32) {
|
|
40
45
|
logger.error(
|
|
41
46
|
"[Auth Middleware] JWT_SECRET must be at least 32 characters long"
|
|
42
47
|
);
|
|
@@ -44,12 +49,11 @@ function getJWTManager() {
|
|
|
44
49
|
}
|
|
45
50
|
_jwtManager = new JWTManager(
|
|
46
51
|
{
|
|
47
|
-
secret,
|
|
48
|
-
accessTokenExpiry:
|
|
49
|
-
refreshTokenExpiry:
|
|
52
|
+
secret: authConfig.jwtSecret,
|
|
53
|
+
accessTokenExpiry: authConfig.accessTokenExpiry,
|
|
54
|
+
refreshTokenExpiry: authConfig.refreshTokenExpiry,
|
|
50
55
|
algorithm: "HS256"
|
|
51
56
|
},
|
|
52
|
-
// Winston logger for middleware
|
|
53
57
|
{
|
|
54
58
|
debug: (msg, meta) => logger.debug(`[Auth] ${msg}`, meta),
|
|
55
59
|
info: (msg, meta) => logger.info(`[Auth] ${msg}`, meta),
|
|
@@ -58,7 +62,7 @@ function getJWTManager() {
|
|
|
58
62
|
}
|
|
59
63
|
);
|
|
60
64
|
logger.info(
|
|
61
|
-
`[Auth Middleware] \u2705 Initialized - Access: ${
|
|
65
|
+
`[Auth Middleware] \u2705 Initialized - Access: ${authConfig.accessTokenExpiry}, Refresh: ${authConfig.refreshTokenExpiry}`
|
|
62
66
|
);
|
|
63
67
|
}
|
|
64
68
|
return _jwtManager;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
InMemoryCacheManager
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XZ4HMXSK.js";
|
|
4
4
|
import {
|
|
5
5
|
isRedisGloballyDisabled,
|
|
6
6
|
notifyRedisError
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import {
|
|
9
|
-
getCacheFallbackConfig
|
|
10
|
-
} from "./chunk-N4XYQB2G.js";
|
|
7
|
+
} from "./chunk-PU2LFTI5.js";
|
|
11
8
|
import {
|
|
12
9
|
logger
|
|
13
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-SNNXLA5F.js";
|
|
11
|
+
import {
|
|
12
|
+
getCacheFallbackConfig
|
|
13
|
+
} from "./chunk-X2QSMX3B.js";
|
|
14
14
|
import {
|
|
15
15
|
__spreadValues
|
|
16
16
|
} from "./chunk-ORMEWXMH.js";
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
} from "./chunk-VSGKVZB4.js";
|
|
7
7
|
import {
|
|
8
8
|
IPGeolocationProvider
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-MVH5ZPFD.js";
|
|
10
10
|
import {
|
|
11
11
|
MaxMindProvider
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-Q7NIAITA.js";
|
|
13
13
|
|
|
14
14
|
// src/geolocation/providers/index.ts
|
|
15
15
|
var GeoIPProviderFactory = class {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getCacheManager,
|
|
3
3
|
getEffectiveCacheBackend
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3GKJ763I.js";
|
|
5
5
|
import {
|
|
6
6
|
getCacheConfig,
|
|
7
7
|
getCacheTTL
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import {
|
|
10
|
-
isCacheEnabled
|
|
11
|
-
} from "./chunk-N4XYQB2G.js";
|
|
8
|
+
} from "./chunk-C3WPAWID.js";
|
|
12
9
|
import {
|
|
13
10
|
logger
|
|
14
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-SNNXLA5F.js";
|
|
12
|
+
import {
|
|
13
|
+
isCacheEnabled
|
|
14
|
+
} from "./chunk-X2QSMX3B.js";
|
|
15
15
|
|
|
16
16
|
// src/cache/cache-wrapper.ts
|
|
17
17
|
function getCacheBackendLabel() {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AppError
|
|
3
3
|
} from "./chunk-KXXROUA5.js";
|
|
4
|
-
import {
|
|
5
|
-
ERROR_CODES,
|
|
6
|
-
formatErrorMessage
|
|
7
|
-
} from "./chunk-SNVGJPPX.js";
|
|
8
4
|
import {
|
|
9
5
|
logApiRequest,
|
|
10
6
|
logApiResponse,
|
|
11
7
|
logger
|
|
12
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-SNNXLA5F.js";
|
|
9
|
+
import {
|
|
10
|
+
ERROR_CODES,
|
|
11
|
+
formatErrorMessage
|
|
12
|
+
} from "./chunk-SNVGJPPX.js";
|
|
13
13
|
|
|
14
14
|
// src/utils/error-processor.ts
|
|
15
15
|
import { NextResponse } from "next/server";
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AUTH_ERROR_CODE_MAP
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import {
|
|
5
|
-
getErrorMessage
|
|
6
|
-
} from "./chunk-ASXZ2NZJ.js";
|
|
3
|
+
} from "./chunk-HKJCBV3H.js";
|
|
7
4
|
import {
|
|
8
5
|
AppError
|
|
9
6
|
} from "./chunk-KXXROUA5.js";
|
|
10
7
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
getErrorMessage
|
|
9
|
+
} from "./chunk-Y2JYA2AR.js";
|
|
10
|
+
import {
|
|
11
|
+
logger
|
|
12
|
+
} from "./chunk-SNNXLA5F.js";
|
|
13
|
+
import {
|
|
14
|
+
getCommonConfig
|
|
15
|
+
} from "./chunk-5MBKG2ZD.js";
|
|
14
16
|
import {
|
|
15
17
|
AuthError
|
|
16
18
|
} from "./chunk-AIH3F7JV.js";
|
|
17
19
|
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
ERROR_CODES,
|
|
21
|
+
classifyError
|
|
22
|
+
} from "./chunk-SNVGJPPX.js";
|
|
20
23
|
import {
|
|
21
24
|
__spreadValues
|
|
22
25
|
} from "./chunk-ORMEWXMH.js";
|
|
@@ -73,7 +76,12 @@ var errorHandlerMiddleware = async (context, next) => {
|
|
|
73
76
|
}
|
|
74
77
|
const classified = error instanceof Error ? classifyError(error) : ERROR_CODES.INTERNAL_SERVER_ERROR;
|
|
75
78
|
logger.error("[ErrorHandler] Unexpected error:", error);
|
|
76
|
-
|
|
79
|
+
let isProduction = false;
|
|
80
|
+
try {
|
|
81
|
+
isProduction = getCommonConfig().nodeEnv === "production";
|
|
82
|
+
} catch (e) {
|
|
83
|
+
isProduction = false;
|
|
84
|
+
}
|
|
77
85
|
const safeMessage = isProduction ? classified.message : error instanceof Error ? error.message : "Unknown error";
|
|
78
86
|
return createErrorResponse(
|
|
79
87
|
classified.code,
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AppError
|
|
3
3
|
} from "./chunk-KXXROUA5.js";
|
|
4
|
+
import {
|
|
5
|
+
logger
|
|
6
|
+
} from "./chunk-SNNXLA5F.js";
|
|
7
|
+
import {
|
|
8
|
+
AuthError
|
|
9
|
+
} from "./chunk-AIH3F7JV.js";
|
|
4
10
|
import {
|
|
5
11
|
ERROR_CODES,
|
|
6
12
|
classifyError,
|
|
7
13
|
formatErrorMessage,
|
|
8
14
|
getHttpStatus
|
|
9
15
|
} from "./chunk-SNVGJPPX.js";
|
|
10
|
-
import {
|
|
11
|
-
AuthError
|
|
12
|
-
} from "./chunk-AIH3F7JV.js";
|
|
13
|
-
import {
|
|
14
|
-
logger
|
|
15
|
-
} from "./chunk-5A2L6TXD.js";
|
|
16
16
|
import {
|
|
17
17
|
__spreadProps,
|
|
18
18
|
__spreadValues
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
configWarn
|
|
3
|
+
} from "./chunk-K25ICPU4.js";
|
|
4
|
+
import {
|
|
5
|
+
ConfigurationError
|
|
6
|
+
} from "./chunk-2QH66EVQ.js";
|
|
7
|
+
|
|
8
|
+
// src/auth/config.ts
|
|
9
|
+
var _config = null;
|
|
10
|
+
function initializeAuth(config) {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
if (_config) return;
|
|
13
|
+
if (!config.jwtSecret) {
|
|
14
|
+
throw new ConfigurationError("Auth", "jwtSecret is required");
|
|
15
|
+
}
|
|
16
|
+
if (!config.accessTokenExpiry) {
|
|
17
|
+
configWarn("Auth", "accessTokenExpiry not provided, using default: 7d");
|
|
18
|
+
}
|
|
19
|
+
if (!config.refreshTokenExpiry) {
|
|
20
|
+
configWarn("Auth", "refreshTokenExpiry not provided, using default: 30d");
|
|
21
|
+
}
|
|
22
|
+
_config = {
|
|
23
|
+
jwtSecret: config.jwtSecret,
|
|
24
|
+
accessTokenExpiry: (_a = config.accessTokenExpiry) != null ? _a : "7d",
|
|
25
|
+
refreshTokenExpiry: (_b = config.refreshTokenExpiry) != null ? _b : "30d"
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function getAuthConfig() {
|
|
29
|
+
if (!_config) {
|
|
30
|
+
throw new ConfigurationError("Auth", "Not initialized. Call initializeAuth() first.");
|
|
31
|
+
}
|
|
32
|
+
return _config;
|
|
33
|
+
}
|
|
34
|
+
function resetAuth() {
|
|
35
|
+
_config = null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
initializeAuth,
|
|
40
|
+
getAuthConfig,
|
|
41
|
+
resetAuth
|
|
42
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
configWarn
|
|
3
|
+
} from "./chunk-K25ICPU4.js";
|
|
4
|
+
import {
|
|
5
|
+
ConfigurationError
|
|
6
|
+
} from "./chunk-2QH66EVQ.js";
|
|
7
|
+
|
|
8
|
+
// src/middleware/cors-config.ts
|
|
9
|
+
var _config = null;
|
|
10
|
+
function initializeCors(config) {
|
|
11
|
+
if (_config) return;
|
|
12
|
+
if (!config.allowedOrigins) {
|
|
13
|
+
throw new ConfigurationError("CORS", "allowedOrigins is required");
|
|
14
|
+
}
|
|
15
|
+
if (config.allowedOrigins.length === 0) {
|
|
16
|
+
throw new ConfigurationError("CORS", "allowedOrigins must not be empty");
|
|
17
|
+
}
|
|
18
|
+
if (config.baseUrl === void 0) {
|
|
19
|
+
configWarn("CORS", "baseUrl not provided");
|
|
20
|
+
}
|
|
21
|
+
_config = {
|
|
22
|
+
allowedOrigins: [...config.allowedOrigins],
|
|
23
|
+
baseUrl: config.baseUrl
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function getCorsConfig() {
|
|
27
|
+
if (!_config) {
|
|
28
|
+
throw new ConfigurationError("CORS", "Not initialized. Call initializeCors() first.");
|
|
29
|
+
}
|
|
30
|
+
return _config;
|
|
31
|
+
}
|
|
32
|
+
function resetCors() {
|
|
33
|
+
_config = null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
initializeCors,
|
|
38
|
+
getCorsConfig,
|
|
39
|
+
resetCors
|
|
40
|
+
};
|