@withwiz/toolkit 0.6.1 → 0.6.3
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 +2 -2
- package/dist/auth/adapters/prisma/index.js +2 -2
- package/dist/auth/config.d.ts +0 -3
- package/dist/auth/config.js +1 -1
- package/dist/auth/core/jwt/cookie.js +2 -2
- package/dist/auth/core/jwt/index.js +2 -2
- package/dist/auth/core/jwt/types.js +1 -1
- package/dist/auth/core/oauth/index.d.ts +1 -1
- package/dist/auth/core/oauth/index.js +12 -4
- package/dist/auth/core/oauth/providers/index.d.ts +2 -0
- package/dist/auth/core/oauth/providers/index.js +11 -3
- package/dist/auth/core/oauth/providers/kakao.js +1 -1
- package/dist/auth/core/oauth/providers/meta.d.ts +14 -0
- package/dist/auth/core/oauth/providers/meta.js +8 -0
- package/dist/auth/core/oauth/providers/microsoft.d.ts +21 -0
- package/dist/auth/core/oauth/providers/microsoft.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/handlers/forgot-password.handler.js +1 -1
- package/dist/auth/handlers/index.js +27 -25
- package/dist/auth/handlers/login.handler.js +3 -3
- package/dist/auth/handlers/logout.handler.js +3 -3
- package/dist/auth/handlers/me.handler.js +2 -2
- package/dist/auth/handlers/oauth-authorize.handler.js +7 -5
- package/dist/auth/handlers/oauth-callback.handler.js +10 -8
- package/dist/auth/handlers/refresh.handler.js +3 -3
- package/dist/auth/handlers/register.handler.js +3 -3
- package/dist/auth/handlers/reset-password.handler.js +1 -1
- package/dist/auth/handlers/verify-email.handler.js +1 -1
- package/dist/auth/index.js +8 -6
- package/dist/auth/services/email-verification.service.js +1 -1
- package/dist/auth/services/index.js +12 -12
- package/dist/auth/services/login.service.js +2 -2
- package/dist/auth/services/oauth-callback.service.js +3 -3
- package/dist/auth/services/password-reset.service.js +1 -1
- package/dist/auth/services/register.service.js +2 -2
- package/dist/auth/services/token-refresh.service.js +2 -2
- package/dist/auth/types/index.d.ts +2 -0
- package/dist/auth/types/index.js +1 -1
- package/dist/cache/cache-config.js +4 -4
- package/dist/cache/cache-env.js +3 -3
- package/dist/cache/cache-factory.js +12 -12
- package/dist/cache/cache-invalidation.js +13 -13
- package/dist/cache/cache-redis.js +6 -6
- package/dist/cache/cache-wrapper.js +13 -13
- package/dist/cache/cache.js +14 -14
- package/dist/cache/config.d.ts +0 -14
- package/dist/cache/config.js +1 -1
- package/dist/cache/hybrid-cache-manager.js +8 -8
- package/dist/cache/index.js +14 -14
- package/dist/cache/inmemory-cache-manager.js +3 -3
- package/dist/cache/noop-cache-manager.js +5 -5
- package/dist/cache/redis-cache-manager.js +7 -7
- package/dist/{chunk-3ECJUXLM.js → chunk-2KG2G35D.js} +3 -3
- package/dist/{chunk-3AJHXCDG.js → chunk-34IDAA7V.js} +2 -2
- package/dist/{chunk-77BJRPMN.js → chunk-3LVCK2NQ.js} +4 -4
- package/dist/{chunk-W2GBKW2T.js → chunk-545Q34YU.js} +2 -2
- package/dist/{chunk-HZLJYEOO.js → chunk-57HPJEZB.js} +9 -1
- package/dist/{chunk-2VMTIYLX.js → chunk-7DMKTJHU.js} +2 -2
- package/dist/{chunk-O35V6RIF.js → chunk-7UQZH2OH.js} +3 -3
- package/dist/{chunk-7KZRPDQD.js → chunk-A6FKWYO2.js} +2 -2
- package/dist/{chunk-EXJQKCTN.js → chunk-A7TN46LC.js} +4 -4
- package/dist/{chunk-AYZJN32D.js → chunk-CDLCZB6F.js} +10 -15
- package/dist/{chunk-SR3SQL72.js → chunk-CVFVL5FL.js} +2 -2
- package/dist/{chunk-Q7VFOUFI.js → chunk-D6MIC5AU.js} +1 -1
- package/dist/{chunk-Q6KXN7HL.js → chunk-ENETIGKL.js} +2 -2
- package/dist/{chunk-WNEXLSDB.js → chunk-ERO4PGNO.js} +1 -1
- package/dist/{chunk-BEV7PQM3.js → chunk-F3NGZYL2.js} +1 -1
- package/dist/chunk-FDFPNSKY.js +14 -0
- package/dist/{chunk-G5OMETUS.js → chunk-FDRQUDFH.js} +1 -1
- package/dist/{chunk-ITGUSYUH.js → chunk-G2WAL2T7.js} +3 -1
- package/dist/{chunk-6JY6NUR6.js → chunk-GDX3YQGK.js} +1 -1
- package/dist/{chunk-6B7VU6RZ.js → chunk-JDXC3QIA.js} +0 -1
- package/dist/chunk-K3OYTLXU.js +63 -0
- package/dist/{chunk-MGQV723O.js → chunk-L74XPPH4.js} +1 -1
- package/dist/{chunk-SSS6XSEG.js → chunk-LG6GH4V7.js} +1 -1
- package/dist/{chunk-HHCDMWEF.js → chunk-LGAV5UU2.js} +1 -1
- package/dist/{chunk-3CBGGMIY.js → chunk-LHIVUV7Q.js} +10 -15
- package/dist/{chunk-OHBAELPZ.js → chunk-LMQSV5UK.js} +15 -21
- package/dist/{chunk-A2XAOU55.js → chunk-LNPZZ23G.js} +13 -19
- package/dist/{chunk-X6MGVFT3.js → chunk-LRRQ54YJ.js} +1 -1
- package/dist/chunk-MGBNIDTP.js +100 -0
- package/dist/{chunk-PYVYYO4X.js → chunk-MULM3Q5S.js} +5 -5
- package/dist/{chunk-TEXVRHPF.js → chunk-NOAU2JG7.js} +1 -1
- package/dist/{chunk-WJSMXUZB.js → chunk-NQUYNPSD.js} +1 -1
- package/dist/{chunk-CKK55QFQ.js → chunk-NW3JIRFK.js} +1 -1
- package/dist/{chunk-FI46LV42.js → chunk-O5E36ZIJ.js} +1 -1
- package/dist/{chunk-DBHISLC6.js → chunk-OFSPZUQD.js} +2 -2
- package/dist/{chunk-WRWWB2NU.js → chunk-PT4FA7U4.js} +2 -2
- package/dist/{chunk-VCOA6LMN.js → chunk-QOKDGW3F.js} +1 -1
- package/dist/{chunk-OCI7QCLM.js → chunk-QXIQB6OF.js} +2 -2
- package/dist/{chunk-L5WLPC2T.js → chunk-QXPMO2CO.js} +1 -1
- package/dist/{chunk-LFKPXF5E.js → chunk-RXVX2DCW.js} +2 -2
- package/dist/{chunk-PAF5OGDU.js → chunk-SI2Z26KP.js} +7 -7
- package/dist/{chunk-ETMTDHK2.js → chunk-SOQOAFB2.js} +0 -1
- package/dist/{chunk-4BGAE7NU.js → chunk-TLBY3DUK.js} +1 -1
- package/dist/{chunk-2QQNL4ND.js → chunk-TLZJQR26.js} +17 -6
- package/dist/{chunk-IHUQRVPV.js → chunk-UQM35MAO.js} +2 -2
- package/dist/{chunk-G2Q4TI3Q.js → chunk-V3ZIR4UL.js} +1 -1
- package/dist/chunk-VB64KFBD.js +99 -0
- package/dist/{chunk-GFWGLWTS.js → chunk-WJWCTCWZ.js} +10 -15
- package/dist/{chunk-CMU52MEQ.js → chunk-WLXAEHKK.js} +2 -2
- package/dist/{chunk-SFPMFVSD.js → chunk-WPW4HXW4.js} +9 -15
- package/dist/{chunk-ON7HZ3PW.js → chunk-WSXOKK6N.js} +1 -1
- package/dist/{chunk-S7OQWKUJ.js → chunk-XIJMATSG.js} +3 -3
- package/dist/{chunk-MDTID4D2.js → chunk-XY3ZVORI.js} +1 -1
- package/dist/{chunk-KF3O2DAV.js → chunk-YTXCKIWE.js} +1 -1
- package/dist/{chunk-7JKZBEVB.js → chunk-YX3XMDDI.js} +8 -8
- package/dist/{chunk-CW3INZMV.js → chunk-ZG2XGO44.js} +1 -1
- package/dist/config/common.d.ts +0 -3
- package/dist/config/common.js +1 -1
- package/dist/config/registry.d.ts +5 -13
- package/dist/config/registry.js +1 -1
- package/dist/error/error-handler.js +3 -3
- package/dist/error/index.js +3 -3
- package/dist/geolocation/batch-processor.js +3 -3
- package/dist/geolocation/config.d.ts +0 -3
- package/dist/geolocation/config.js +1 -1
- package/dist/geolocation/index.js +7 -7
- package/dist/geolocation/providers/index.js +4 -4
- package/dist/geolocation/providers/ipgeolocation-provider.js +2 -2
- package/dist/geolocation/providers/maxmind-provider.js +2 -2
- package/dist/initialize.d.ts +2 -1
- package/dist/initialize.js +18 -17
- package/dist/logger/config.d.ts +0 -3
- package/dist/logger/config.js +1 -1
- package/dist/logger/logger.js +2 -2
- package/dist/middleware/auth.js +5 -5
- package/dist/middleware/cors-config.d.ts +0 -3
- package/dist/middleware/cors-config.js +1 -1
- package/dist/middleware/cors.js +4 -4
- package/dist/middleware/error-handler.js +4 -4
- package/dist/middleware/index.js +14 -14
- package/dist/middleware/middleware-chain.js +3 -3
- package/dist/middleware/rate-limit.js +3 -3
- package/dist/middleware/response-logger.js +3 -3
- package/dist/middleware/security.js +3 -3
- package/dist/middleware/wrappers.js +14 -14
- package/dist/storage/config.d.ts +0 -3
- package/dist/storage/config.js +1 -1
- package/dist/storage/r2-storage.js +1 -1
- package/dist/system/cpu.js +4 -4
- package/dist/system/disk.js +4 -4
- package/dist/system/environment.js +8 -8
- package/dist/system/health-check.js +5 -5
- package/dist/system/index.js +13 -13
- package/dist/system/memory.js +4 -4
- package/dist/system/network.js +4 -4
- package/dist/system/utils.js +3 -3
- package/dist/utils/cors.js +3 -3
- package/dist/utils/csv-export.js +3 -3
- package/dist/utils/error-processor.js +3 -3
- package/dist/utils/index.js +7 -7
- package/package.json +1 -1
- package/dist/chunk-GTPUVHSV.js +0 -30
- package/dist/chunk-UCIUAZQT.js +0 -106
- /package/dist/{chunk-T4MDCVUQ.js → chunk-6CLQRZC2.js} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/config/registry.ts
|
|
2
|
+
var _a;
|
|
3
|
+
(_a = globalThis.__withwiz_config) != null ? _a : globalThis.__withwiz_config = {};
|
|
4
|
+
var config = globalThis.__withwiz_config;
|
|
5
|
+
function resetConfig() {
|
|
6
|
+
for (const key of Object.keys(globalThis.__withwiz_config)) {
|
|
7
|
+
delete globalThis.__withwiz_config[key];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
config,
|
|
13
|
+
resetConfig
|
|
14
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OAuthError
|
|
3
|
+
} from "./chunk-AIH3F7JV.js";
|
|
4
|
+
|
|
5
|
+
// src/auth/core/oauth/providers/meta.ts
|
|
6
|
+
var META_GRAPH_VERSION = "v25.0";
|
|
7
|
+
var MetaOAuthProvider = class {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.name = "meta";
|
|
10
|
+
}
|
|
11
|
+
getLoginUrl(config, state) {
|
|
12
|
+
const params = new URLSearchParams({
|
|
13
|
+
client_id: config.clientId,
|
|
14
|
+
redirect_uri: config.redirectUri,
|
|
15
|
+
response_type: "code",
|
|
16
|
+
scope: "email,public_profile"
|
|
17
|
+
});
|
|
18
|
+
if (state) {
|
|
19
|
+
params.set("state", state);
|
|
20
|
+
}
|
|
21
|
+
return `https://www.facebook.com/${META_GRAPH_VERSION}/dialog/oauth?${params.toString()}`;
|
|
22
|
+
}
|
|
23
|
+
async exchangeCodeForToken(config, code) {
|
|
24
|
+
const params = new URLSearchParams({
|
|
25
|
+
client_id: config.clientId,
|
|
26
|
+
client_secret: config.clientSecret,
|
|
27
|
+
code,
|
|
28
|
+
redirect_uri: config.redirectUri
|
|
29
|
+
});
|
|
30
|
+
const url = `https://graph.facebook.com/${META_GRAPH_VERSION}/oauth/access_token?${params.toString()}`;
|
|
31
|
+
const response = await fetch(url);
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
const errorData = await response.text();
|
|
34
|
+
throw new OAuthError(`Meta token exchange failed: ${errorData}`, "TOKEN_EXCHANGE_FAILED");
|
|
35
|
+
}
|
|
36
|
+
return response.json();
|
|
37
|
+
}
|
|
38
|
+
async getUserInfo(accessToken) {
|
|
39
|
+
var _a, _b, _c, _d;
|
|
40
|
+
const url = `https://graph.facebook.com/${META_GRAPH_VERSION}/me?fields=id,name,email,picture`;
|
|
41
|
+
const response = await fetch(url, {
|
|
42
|
+
headers: { Authorization: `Bearer ${accessToken}` }
|
|
43
|
+
});
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
throw new OAuthError("Failed to get Meta user info", "USER_INFO_FAILED");
|
|
46
|
+
}
|
|
47
|
+
const data = await response.json();
|
|
48
|
+
if (!data.id) {
|
|
49
|
+
throw new OAuthError("Invalid Meta response: missing id", "INVALID_RESPONSE");
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
id: data.id,
|
|
53
|
+
email: data.email,
|
|
54
|
+
name: (_a = data.name) != null ? _a : null,
|
|
55
|
+
image: (_d = (_c = (_b = data.picture) == null ? void 0 : _b.data) == null ? void 0 : _c.url) != null ? _d : null,
|
|
56
|
+
emailVerified: !!data.email
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
MetaOAuthProvider
|
|
63
|
+
};
|
|
@@ -6,30 +6,25 @@ import {
|
|
|
6
6
|
} from "./chunk-2QH66EVQ.js";
|
|
7
7
|
|
|
8
8
|
// src/geolocation/config.ts
|
|
9
|
-
var GLOBAL_KEY = "__withwiz_geolocation_config";
|
|
10
|
-
function getConfig() {
|
|
11
|
-
var _a;
|
|
12
|
-
return (_a = globalThis[GLOBAL_KEY]) != null ? _a : null;
|
|
13
|
-
}
|
|
14
|
-
function setConfig(config) {
|
|
15
|
-
globalThis[GLOBAL_KEY] = config;
|
|
16
|
-
}
|
|
17
9
|
function initializeGeolocation(config) {
|
|
18
|
-
|
|
10
|
+
var _a;
|
|
11
|
+
(_a = globalThis.__withwiz_config) != null ? _a : globalThis.__withwiz_config = {};
|
|
12
|
+
if (globalThis.__withwiz_config.geolocation) return;
|
|
19
13
|
if (!config.ipgeolocationApiKey) configWarn("Geolocation", "ipgeolocationApiKey not provided, IPGeolocation provider will be unavailable");
|
|
20
14
|
if (!config.maxmindLicenseKey) configWarn("Geolocation", "maxmindLicenseKey not provided, MaxMind provider will be unavailable");
|
|
21
|
-
|
|
15
|
+
globalThis.__withwiz_config.geolocation = {
|
|
22
16
|
ipgeolocationApiKey: config.ipgeolocationApiKey,
|
|
23
17
|
maxmindLicenseKey: config.maxmindLicenseKey
|
|
24
|
-
}
|
|
18
|
+
};
|
|
25
19
|
}
|
|
26
20
|
function getGeolocationConfig() {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
var _a;
|
|
22
|
+
const geo = (_a = globalThis.__withwiz_config) == null ? void 0 : _a.geolocation;
|
|
23
|
+
if (!geo) throw new ConfigurationError("Geolocation", "Not initialized. Call initializeGeolocation() first.");
|
|
24
|
+
return geo;
|
|
30
25
|
}
|
|
31
26
|
function resetGeolocation() {
|
|
32
|
-
globalThis
|
|
27
|
+
if (globalThis.__withwiz_config) delete globalThis.__withwiz_config.geolocation;
|
|
33
28
|
}
|
|
34
29
|
|
|
35
30
|
export {
|
|
@@ -6,37 +6,31 @@ import {
|
|
|
6
6
|
} from "./chunk-2QH66EVQ.js";
|
|
7
7
|
|
|
8
8
|
// src/logger/config.ts
|
|
9
|
-
var GLOBAL_KEY = "__withwiz_logger_config";
|
|
10
|
-
function getConfig() {
|
|
11
|
-
var _a;
|
|
12
|
-
return (_a = globalThis[GLOBAL_KEY]) != null ? _a : null;
|
|
13
|
-
}
|
|
14
|
-
function setConfig(config) {
|
|
15
|
-
globalThis[GLOBAL_KEY] = config;
|
|
16
|
-
}
|
|
17
9
|
function initializeLogger(config) {
|
|
18
|
-
var _a, _b, _c, _d, _e;
|
|
19
|
-
|
|
10
|
+
var _a, _b, _c, _d, _e, _f;
|
|
11
|
+
(_a = globalThis.__withwiz_config) != null ? _a : globalThis.__withwiz_config = {};
|
|
12
|
+
if (globalThis.__withwiz_config.logger) return;
|
|
20
13
|
if (config.level === void 0) configWarn("Logger", "level not provided, using default: info");
|
|
21
14
|
if (config.dir === void 0) configWarn("Logger", "dir not provided, using default: ./logs");
|
|
22
15
|
if (config.file === void 0) configWarn("Logger", "file not provided, using default: app.log");
|
|
23
16
|
if (config.fileEnabled === void 0) configWarn("Logger", "fileEnabled not provided, using default: true");
|
|
24
17
|
if (config.consoleEnabled === void 0) configWarn("Logger", "consoleEnabled not provided, using default: true");
|
|
25
|
-
|
|
26
|
-
level: (
|
|
27
|
-
dir: (
|
|
28
|
-
file: (
|
|
29
|
-
fileEnabled: (
|
|
30
|
-
consoleEnabled: (
|
|
31
|
-
}
|
|
18
|
+
globalThis.__withwiz_config.logger = {
|
|
19
|
+
level: (_b = config.level) != null ? _b : "info",
|
|
20
|
+
dir: (_c = config.dir) != null ? _c : "./logs",
|
|
21
|
+
file: (_d = config.file) != null ? _d : "app.log",
|
|
22
|
+
fileEnabled: (_e = config.fileEnabled) != null ? _e : true,
|
|
23
|
+
consoleEnabled: (_f = config.consoleEnabled) != null ? _f : true
|
|
24
|
+
};
|
|
32
25
|
}
|
|
33
26
|
function getLoggerConfig() {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
var _a;
|
|
28
|
+
const logger = (_a = globalThis.__withwiz_config) == null ? void 0 : _a.logger;
|
|
29
|
+
if (!logger) throw new ConfigurationError("Logger", "Not initialized. Call initializeLogger() first.");
|
|
30
|
+
return logger;
|
|
37
31
|
}
|
|
38
32
|
function resetLogger() {
|
|
39
|
-
globalThis
|
|
33
|
+
if (globalThis.__withwiz_config) delete globalThis.__withwiz_config.logger;
|
|
40
34
|
}
|
|
41
35
|
|
|
42
36
|
export {
|
|
@@ -6,17 +6,10 @@ import {
|
|
|
6
6
|
} from "./chunk-2QH66EVQ.js";
|
|
7
7
|
|
|
8
8
|
// src/auth/config.ts
|
|
9
|
-
var GLOBAL_KEY = "__withwiz_auth_config";
|
|
10
|
-
function getConfig() {
|
|
11
|
-
var _a;
|
|
12
|
-
return (_a = globalThis[GLOBAL_KEY]) != null ? _a : null;
|
|
13
|
-
}
|
|
14
|
-
function setConfig(config) {
|
|
15
|
-
globalThis[GLOBAL_KEY] = config;
|
|
16
|
-
}
|
|
17
9
|
function initializeAuth(config) {
|
|
18
|
-
var _a, _b, _c;
|
|
19
|
-
|
|
10
|
+
var _a, _b, _c, _d;
|
|
11
|
+
(_a = globalThis.__withwiz_config) != null ? _a : globalThis.__withwiz_config = {};
|
|
12
|
+
if (globalThis.__withwiz_config.auth) return;
|
|
20
13
|
if (!config.jwtSecret) {
|
|
21
14
|
throw new ConfigurationError("Auth", "jwtSecret is required");
|
|
22
15
|
}
|
|
@@ -26,22 +19,23 @@ function initializeAuth(config) {
|
|
|
26
19
|
if (!config.refreshTokenExpiry) {
|
|
27
20
|
configWarn("Auth", "refreshTokenExpiry not provided, using default: 30d");
|
|
28
21
|
}
|
|
29
|
-
|
|
22
|
+
globalThis.__withwiz_config.auth = {
|
|
30
23
|
jwtSecret: config.jwtSecret,
|
|
31
|
-
accessTokenExpiry: (
|
|
32
|
-
refreshTokenExpiry: (
|
|
33
|
-
cookieSecure: (
|
|
34
|
-
}
|
|
24
|
+
accessTokenExpiry: (_b = config.accessTokenExpiry) != null ? _b : "7d",
|
|
25
|
+
refreshTokenExpiry: (_c = config.refreshTokenExpiry) != null ? _c : "30d",
|
|
26
|
+
cookieSecure: (_d = config.cookieSecure) != null ? _d : false
|
|
27
|
+
};
|
|
35
28
|
}
|
|
36
29
|
function getAuthConfig() {
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
var _a;
|
|
31
|
+
const auth = (_a = globalThis.__withwiz_config) == null ? void 0 : _a.auth;
|
|
32
|
+
if (!auth) {
|
|
39
33
|
throw new ConfigurationError("Auth", "Not initialized. Call initializeAuth() first.");
|
|
40
34
|
}
|
|
41
|
-
return
|
|
35
|
+
return auth;
|
|
42
36
|
}
|
|
43
37
|
function resetAuth() {
|
|
44
|
-
globalThis
|
|
38
|
+
if (globalThis.__withwiz_config) delete globalThis.__withwiz_config.auth;
|
|
45
39
|
}
|
|
46
40
|
|
|
47
41
|
export {
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigurationError
|
|
3
|
+
} from "./chunk-2QH66EVQ.js";
|
|
4
|
+
import {
|
|
5
|
+
CACHE_DURATION_DEFAULTS,
|
|
6
|
+
CACHE_FALLBACK_DEFAULTS,
|
|
7
|
+
CACHE_HEALTH_DEFAULTS,
|
|
8
|
+
CACHE_TTL_DEFAULTS,
|
|
9
|
+
INMEMORY_CACHE_DEFAULTS
|
|
10
|
+
} from "./chunk-57W32BFZ.js";
|
|
11
|
+
import {
|
|
12
|
+
__spreadValues
|
|
13
|
+
} from "./chunk-ORMEWXMH.js";
|
|
14
|
+
|
|
15
|
+
// src/cache/config.ts
|
|
16
|
+
function initializeCache(input) {
|
|
17
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __;
|
|
18
|
+
(_a = globalThis.__withwiz_config) != null ? _a : globalThis.__withwiz_config = {};
|
|
19
|
+
if (globalThis.__withwiz_config.cache) return;
|
|
20
|
+
if (input.redis !== void 0) {
|
|
21
|
+
if (!input.redis.url) {
|
|
22
|
+
throw new ConfigurationError("cache", "redis.url is required");
|
|
23
|
+
}
|
|
24
|
+
if (!input.redis.token) {
|
|
25
|
+
throw new ConfigurationError("cache", "redis.token is required");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const defaultCategories = {};
|
|
29
|
+
for (const [key, duration] of Object.entries(CACHE_DURATION_DEFAULTS)) {
|
|
30
|
+
defaultCategories[key] = { enabled: true, duration };
|
|
31
|
+
}
|
|
32
|
+
const mergedCategories = __spreadValues({}, defaultCategories);
|
|
33
|
+
if (input.categories) {
|
|
34
|
+
for (const [key, value] of Object.entries(input.categories)) {
|
|
35
|
+
if (value !== void 0) {
|
|
36
|
+
mergedCategories[key] = {
|
|
37
|
+
enabled: (_b = value.enabled) != null ? _b : true,
|
|
38
|
+
duration: (_e = (_d = value.duration) != null ? _d : (_c = defaultCategories[key]) == null ? void 0 : _c.duration) != null ? _e : CACHE_TTL_DEFAULTS.DEFAULT
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
globalThis.__withwiz_config.cache = {
|
|
44
|
+
enabled: (_f = input.enabled) != null ? _f : true,
|
|
45
|
+
redis: input.redis ? {
|
|
46
|
+
url: input.redis.url,
|
|
47
|
+
token: input.redis.token,
|
|
48
|
+
enabled: (_g = input.redis.enabled) != null ? _g : true
|
|
49
|
+
} : void 0,
|
|
50
|
+
inmemory: {
|
|
51
|
+
enabled: (_i = (_h = input.inmemory) == null ? void 0 : _h.enabled) != null ? _i : true,
|
|
52
|
+
maxSize: (_k = (_j = input.inmemory) == null ? void 0 : _j.maxSize) != null ? _k : INMEMORY_CACHE_DEFAULTS.MAX_SIZE,
|
|
53
|
+
maxMb: (_m = (_l = input.inmemory) == null ? void 0 : _l.maxMb) != null ? _m : INMEMORY_CACHE_DEFAULTS.MAX_MB,
|
|
54
|
+
eviction: (_o = (_n = input.inmemory) == null ? void 0 : _n.eviction) != null ? _o : INMEMORY_CACHE_DEFAULTS.EVICTION,
|
|
55
|
+
cleanupInterval: (_q = (_p = input.inmemory) == null ? void 0 : _p.cleanupInterval) != null ? _q : INMEMORY_CACHE_DEFAULTS.CLEANUP_INTERVAL
|
|
56
|
+
},
|
|
57
|
+
ttl: {
|
|
58
|
+
DEFAULT: (_s = (_r = input.ttl) == null ? void 0 : _r.DEFAULT) != null ? _s : CACHE_TTL_DEFAULTS.DEFAULT,
|
|
59
|
+
SHORT: (_u = (_t = input.ttl) == null ? void 0 : _t.SHORT) != null ? _u : CACHE_TTL_DEFAULTS.SHORT,
|
|
60
|
+
LONG: (_w = (_v = input.ttl) == null ? void 0 : _v.LONG) != null ? _w : CACHE_TTL_DEFAULTS.LONG,
|
|
61
|
+
GEOIP: (_y = (_x = input.ttl) == null ? void 0 : _x.GEOIP) != null ? _y : CACHE_TTL_DEFAULTS.GEOIP,
|
|
62
|
+
SETTINGS: (_A = (_z = input.ttl) == null ? void 0 : _z.SETTINGS) != null ? _A : CACHE_TTL_DEFAULTS.SETTINGS,
|
|
63
|
+
ANALYTICS: (_C = (_B = input.ttl) == null ? void 0 : _B.ANALYTICS) != null ? _C : CACHE_TTL_DEFAULTS.ANALYTICS,
|
|
64
|
+
USER: (_E = (_D = input.ttl) == null ? void 0 : _D.USER) != null ? _E : CACHE_TTL_DEFAULTS.USER
|
|
65
|
+
},
|
|
66
|
+
categories: mergedCategories,
|
|
67
|
+
fallback: {
|
|
68
|
+
redisErrorThresholdGlobal: (_G = (_F = input.fallback) == null ? void 0 : _F.redisErrorThresholdGlobal) != null ? _G : CACHE_FALLBACK_DEFAULTS.REDIS_ERROR_THRESHOLD_GLOBAL,
|
|
69
|
+
redisErrorThresholdLocal: (_I = (_H = input.fallback) == null ? void 0 : _H.redisErrorThresholdLocal) != null ? _I : CACHE_FALLBACK_DEFAULTS.REDIS_ERROR_THRESHOLD_LOCAL,
|
|
70
|
+
redisReconnectInterval: (_K = (_J = input.fallback) == null ? void 0 : _J.redisReconnectInterval) != null ? _K : CACHE_FALLBACK_DEFAULTS.REDIS_RECONNECT_INTERVAL,
|
|
71
|
+
fallbackOnRedisError: (_M = (_L = input.fallback) == null ? void 0 : _L.fallbackOnRedisError) != null ? _M : CACHE_FALLBACK_DEFAULTS.FALLBACK_ON_REDIS_ERROR,
|
|
72
|
+
writeToMemory: (_O = (_N = input.fallback) == null ? void 0 : _N.writeToMemory) != null ? _O : CACHE_FALLBACK_DEFAULTS.WRITE_TO_MEMORY
|
|
73
|
+
},
|
|
74
|
+
health: {
|
|
75
|
+
errorRateThreshold: (_Q = (_P = input.health) == null ? void 0 : _P.errorRateThreshold) != null ? _Q : CACHE_HEALTH_DEFAULTS.ERROR_RATE_THRESHOLD,
|
|
76
|
+
hitRateThreshold: (_S = (_R = input.health) == null ? void 0 : _R.hitRateThreshold) != null ? _S : CACHE_HEALTH_DEFAULTS.HIT_RATE_THRESHOLD,
|
|
77
|
+
reportHitRateThreshold: (_U = (_T = input.health) == null ? void 0 : _T.reportHitRateThreshold) != null ? _U : CACHE_HEALTH_DEFAULTS.REPORT_HIT_RATE_THRESHOLD,
|
|
78
|
+
reportResponseTimeThreshold: (_W = (_V = input.health) == null ? void 0 : _V.reportResponseTimeThreshold) != null ? _W : CACHE_HEALTH_DEFAULTS.REPORT_RESPONSE_TIME_THRESHOLD,
|
|
79
|
+
reportInvalidationThreshold: (_Y = (_X = input.health) == null ? void 0 : _X.reportInvalidationThreshold) != null ? _Y : CACHE_HEALTH_DEFAULTS.REPORT_INVALIDATION_THRESHOLD,
|
|
80
|
+
reportMinRequests: (__ = (_Z = input.health) == null ? void 0 : _Z.reportMinRequests) != null ? __ : CACHE_HEALTH_DEFAULTS.REPORT_MIN_REQUESTS
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function getResolvedCacheConfig() {
|
|
85
|
+
var _a;
|
|
86
|
+
const cache = (_a = globalThis.__withwiz_config) == null ? void 0 : _a.cache;
|
|
87
|
+
if (!cache) {
|
|
88
|
+
throw new ConfigurationError("cache", "Cache config not initialized. Call initializeCache() first.");
|
|
89
|
+
}
|
|
90
|
+
return cache;
|
|
91
|
+
}
|
|
92
|
+
function resetCache() {
|
|
93
|
+
if (globalThis.__withwiz_config) delete globalThis.__withwiz_config.cache;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export {
|
|
97
|
+
initializeCache,
|
|
98
|
+
getResolvedCacheConfig,
|
|
99
|
+
resetCache
|
|
100
|
+
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getPlatform
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LRRQ54YJ.js";
|
|
4
4
|
import {
|
|
5
5
|
getGeolocationConfig
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LHIVUV7Q.js";
|
|
7
7
|
import {
|
|
8
8
|
getAuthConfig
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-LNPZZ23G.js";
|
|
10
10
|
import {
|
|
11
11
|
getCommonConfig
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-WPW4HXW4.js";
|
|
13
13
|
import {
|
|
14
14
|
getResolvedCacheConfig
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-MGBNIDTP.js";
|
|
16
16
|
|
|
17
17
|
// src/system/environment.ts
|
|
18
18
|
import os from "os";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AUTH_ERROR_CODE_MAP
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XY3ZVORI.js";
|
|
4
4
|
import {
|
|
5
5
|
AppError
|
|
6
6
|
} from "./chunk-EOEMOXNT.js";
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from "./chunk-AIH3F7JV.js";
|
|
17
17
|
import {
|
|
18
18
|
logger
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-NOAU2JG7.js";
|
|
20
20
|
import {
|
|
21
21
|
__spreadValues
|
|
22
22
|
} from "./chunk-ORMEWXMH.js";
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
formatBytesPerSec,
|
|
4
4
|
runCommand,
|
|
5
5
|
runMacCommand
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LRRQ54YJ.js";
|
|
7
7
|
import {
|
|
8
8
|
logger
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-NOAU2JG7.js";
|
|
10
10
|
|
|
11
11
|
// src/system/network.ts
|
|
12
12
|
async function getNetworkInfo() {
|
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
} from "./chunk-3GAY2T2A.js";
|
|
10
10
|
import {
|
|
11
11
|
getAuthConfig
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-LNPZZ23G.js";
|
|
13
13
|
import {
|
|
14
14
|
logger
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-NOAU2JG7.js";
|
|
16
16
|
|
|
17
17
|
// src/middleware/auth.ts
|
|
18
18
|
function setAccessTokenBlacklistChecker(checker) {
|
|
@@ -3,27 +3,27 @@ import {
|
|
|
3
3
|
} from "./chunk-62Q7DN5G.js";
|
|
4
4
|
import {
|
|
5
5
|
MiddlewareChain
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YTXCKIWE.js";
|
|
7
7
|
import {
|
|
8
8
|
rateLimitMiddleware
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-NQUYNPSD.js";
|
|
10
10
|
import {
|
|
11
11
|
responseLoggerMiddleware
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-NW3JIRFK.js";
|
|
13
13
|
import {
|
|
14
14
|
securityMiddleware
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-TLBY3DUK.js";
|
|
16
16
|
import {
|
|
17
17
|
adminMiddleware,
|
|
18
18
|
authMiddleware,
|
|
19
19
|
optionalAuthMiddleware
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-RXVX2DCW.js";
|
|
21
21
|
import {
|
|
22
22
|
corsMiddleware
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-A6FKWYO2.js";
|
|
24
24
|
import {
|
|
25
25
|
errorHandlerMiddleware
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-PT4FA7U4.js";
|
|
27
27
|
|
|
28
28
|
// src/middleware/wrappers.ts
|
|
29
29
|
function withPublicApi(handler) {
|
|
@@ -32,7 +32,6 @@ var RegisterService = class {
|
|
|
32
32
|
email: input.email,
|
|
33
33
|
password: hashedPassword,
|
|
34
34
|
name: (_a = input.name) != null ? _a : null,
|
|
35
|
-
role: "USER",
|
|
36
35
|
emailVerified: this.emailVerificationRequired ? null : /* @__PURE__ */ new Date()
|
|
37
36
|
});
|
|
38
37
|
let verificationSent = false;
|