@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.
Files changed (157) hide show
  1. package/README.md +2 -2
  2. package/dist/auth/adapters/prisma/index.js +2 -2
  3. package/dist/auth/config.d.ts +0 -3
  4. package/dist/auth/config.js +1 -1
  5. package/dist/auth/core/jwt/cookie.js +2 -2
  6. package/dist/auth/core/jwt/index.js +2 -2
  7. package/dist/auth/core/jwt/types.js +1 -1
  8. package/dist/auth/core/oauth/index.d.ts +1 -1
  9. package/dist/auth/core/oauth/index.js +12 -4
  10. package/dist/auth/core/oauth/providers/index.d.ts +2 -0
  11. package/dist/auth/core/oauth/providers/index.js +11 -3
  12. package/dist/auth/core/oauth/providers/kakao.js +1 -1
  13. package/dist/auth/core/oauth/providers/meta.d.ts +14 -0
  14. package/dist/auth/core/oauth/providers/meta.js +8 -0
  15. package/dist/auth/core/oauth/providers/microsoft.d.ts +21 -0
  16. package/dist/auth/core/oauth/providers/microsoft.js +8 -0
  17. package/dist/auth/core/password/client-helper.js +1 -1
  18. package/dist/auth/core/password/index.js +1 -1
  19. package/dist/auth/handlers/forgot-password.handler.js +1 -1
  20. package/dist/auth/handlers/index.js +27 -25
  21. package/dist/auth/handlers/login.handler.js +3 -3
  22. package/dist/auth/handlers/logout.handler.js +3 -3
  23. package/dist/auth/handlers/me.handler.js +2 -2
  24. package/dist/auth/handlers/oauth-authorize.handler.js +7 -5
  25. package/dist/auth/handlers/oauth-callback.handler.js +10 -8
  26. package/dist/auth/handlers/refresh.handler.js +3 -3
  27. package/dist/auth/handlers/register.handler.js +3 -3
  28. package/dist/auth/handlers/reset-password.handler.js +1 -1
  29. package/dist/auth/handlers/verify-email.handler.js +1 -1
  30. package/dist/auth/index.js +8 -6
  31. package/dist/auth/services/email-verification.service.js +1 -1
  32. package/dist/auth/services/index.js +12 -12
  33. package/dist/auth/services/login.service.js +2 -2
  34. package/dist/auth/services/oauth-callback.service.js +3 -3
  35. package/dist/auth/services/password-reset.service.js +1 -1
  36. package/dist/auth/services/register.service.js +2 -2
  37. package/dist/auth/services/token-refresh.service.js +2 -2
  38. package/dist/auth/types/index.d.ts +2 -0
  39. package/dist/auth/types/index.js +1 -1
  40. package/dist/cache/cache-config.js +4 -4
  41. package/dist/cache/cache-env.js +3 -3
  42. package/dist/cache/cache-factory.js +12 -12
  43. package/dist/cache/cache-invalidation.js +13 -13
  44. package/dist/cache/cache-redis.js +6 -6
  45. package/dist/cache/cache-wrapper.js +13 -13
  46. package/dist/cache/cache.js +14 -14
  47. package/dist/cache/config.d.ts +0 -14
  48. package/dist/cache/config.js +1 -1
  49. package/dist/cache/hybrid-cache-manager.js +8 -8
  50. package/dist/cache/index.js +14 -14
  51. package/dist/cache/inmemory-cache-manager.js +3 -3
  52. package/dist/cache/noop-cache-manager.js +5 -5
  53. package/dist/cache/redis-cache-manager.js +7 -7
  54. package/dist/{chunk-3ECJUXLM.js → chunk-2KG2G35D.js} +3 -3
  55. package/dist/{chunk-3AJHXCDG.js → chunk-34IDAA7V.js} +2 -2
  56. package/dist/{chunk-77BJRPMN.js → chunk-3LVCK2NQ.js} +4 -4
  57. package/dist/{chunk-W2GBKW2T.js → chunk-545Q34YU.js} +2 -2
  58. package/dist/{chunk-HZLJYEOO.js → chunk-57HPJEZB.js} +9 -1
  59. package/dist/{chunk-2VMTIYLX.js → chunk-7DMKTJHU.js} +2 -2
  60. package/dist/{chunk-O35V6RIF.js → chunk-7UQZH2OH.js} +3 -3
  61. package/dist/{chunk-7KZRPDQD.js → chunk-A6FKWYO2.js} +2 -2
  62. package/dist/{chunk-EXJQKCTN.js → chunk-A7TN46LC.js} +4 -4
  63. package/dist/{chunk-AYZJN32D.js → chunk-CDLCZB6F.js} +10 -15
  64. package/dist/{chunk-SR3SQL72.js → chunk-CVFVL5FL.js} +2 -2
  65. package/dist/{chunk-Q7VFOUFI.js → chunk-D6MIC5AU.js} +1 -1
  66. package/dist/{chunk-Q6KXN7HL.js → chunk-ENETIGKL.js} +2 -2
  67. package/dist/{chunk-WNEXLSDB.js → chunk-ERO4PGNO.js} +1 -1
  68. package/dist/{chunk-BEV7PQM3.js → chunk-F3NGZYL2.js} +1 -1
  69. package/dist/chunk-FDFPNSKY.js +14 -0
  70. package/dist/{chunk-G5OMETUS.js → chunk-FDRQUDFH.js} +1 -1
  71. package/dist/{chunk-ITGUSYUH.js → chunk-G2WAL2T7.js} +3 -1
  72. package/dist/{chunk-6JY6NUR6.js → chunk-GDX3YQGK.js} +1 -1
  73. package/dist/{chunk-6B7VU6RZ.js → chunk-JDXC3QIA.js} +0 -1
  74. package/dist/chunk-K3OYTLXU.js +63 -0
  75. package/dist/{chunk-MGQV723O.js → chunk-L74XPPH4.js} +1 -1
  76. package/dist/{chunk-SSS6XSEG.js → chunk-LG6GH4V7.js} +1 -1
  77. package/dist/{chunk-HHCDMWEF.js → chunk-LGAV5UU2.js} +1 -1
  78. package/dist/{chunk-3CBGGMIY.js → chunk-LHIVUV7Q.js} +10 -15
  79. package/dist/{chunk-OHBAELPZ.js → chunk-LMQSV5UK.js} +15 -21
  80. package/dist/{chunk-A2XAOU55.js → chunk-LNPZZ23G.js} +13 -19
  81. package/dist/{chunk-X6MGVFT3.js → chunk-LRRQ54YJ.js} +1 -1
  82. package/dist/chunk-MGBNIDTP.js +100 -0
  83. package/dist/{chunk-PYVYYO4X.js → chunk-MULM3Q5S.js} +5 -5
  84. package/dist/{chunk-TEXVRHPF.js → chunk-NOAU2JG7.js} +1 -1
  85. package/dist/{chunk-WJSMXUZB.js → chunk-NQUYNPSD.js} +1 -1
  86. package/dist/{chunk-CKK55QFQ.js → chunk-NW3JIRFK.js} +1 -1
  87. package/dist/{chunk-FI46LV42.js → chunk-O5E36ZIJ.js} +1 -1
  88. package/dist/{chunk-DBHISLC6.js → chunk-OFSPZUQD.js} +2 -2
  89. package/dist/{chunk-WRWWB2NU.js → chunk-PT4FA7U4.js} +2 -2
  90. package/dist/{chunk-VCOA6LMN.js → chunk-QOKDGW3F.js} +1 -1
  91. package/dist/{chunk-OCI7QCLM.js → chunk-QXIQB6OF.js} +2 -2
  92. package/dist/{chunk-L5WLPC2T.js → chunk-QXPMO2CO.js} +1 -1
  93. package/dist/{chunk-LFKPXF5E.js → chunk-RXVX2DCW.js} +2 -2
  94. package/dist/{chunk-PAF5OGDU.js → chunk-SI2Z26KP.js} +7 -7
  95. package/dist/{chunk-ETMTDHK2.js → chunk-SOQOAFB2.js} +0 -1
  96. package/dist/{chunk-4BGAE7NU.js → chunk-TLBY3DUK.js} +1 -1
  97. package/dist/{chunk-2QQNL4ND.js → chunk-TLZJQR26.js} +17 -6
  98. package/dist/{chunk-IHUQRVPV.js → chunk-UQM35MAO.js} +2 -2
  99. package/dist/{chunk-G2Q4TI3Q.js → chunk-V3ZIR4UL.js} +1 -1
  100. package/dist/chunk-VB64KFBD.js +99 -0
  101. package/dist/{chunk-GFWGLWTS.js → chunk-WJWCTCWZ.js} +10 -15
  102. package/dist/{chunk-CMU52MEQ.js → chunk-WLXAEHKK.js} +2 -2
  103. package/dist/{chunk-SFPMFVSD.js → chunk-WPW4HXW4.js} +9 -15
  104. package/dist/{chunk-ON7HZ3PW.js → chunk-WSXOKK6N.js} +1 -1
  105. package/dist/{chunk-S7OQWKUJ.js → chunk-XIJMATSG.js} +3 -3
  106. package/dist/{chunk-MDTID4D2.js → chunk-XY3ZVORI.js} +1 -1
  107. package/dist/{chunk-KF3O2DAV.js → chunk-YTXCKIWE.js} +1 -1
  108. package/dist/{chunk-7JKZBEVB.js → chunk-YX3XMDDI.js} +8 -8
  109. package/dist/{chunk-CW3INZMV.js → chunk-ZG2XGO44.js} +1 -1
  110. package/dist/config/common.d.ts +0 -3
  111. package/dist/config/common.js +1 -1
  112. package/dist/config/registry.d.ts +5 -13
  113. package/dist/config/registry.js +1 -1
  114. package/dist/error/error-handler.js +3 -3
  115. package/dist/error/index.js +3 -3
  116. package/dist/geolocation/batch-processor.js +3 -3
  117. package/dist/geolocation/config.d.ts +0 -3
  118. package/dist/geolocation/config.js +1 -1
  119. package/dist/geolocation/index.js +7 -7
  120. package/dist/geolocation/providers/index.js +4 -4
  121. package/dist/geolocation/providers/ipgeolocation-provider.js +2 -2
  122. package/dist/geolocation/providers/maxmind-provider.js +2 -2
  123. package/dist/initialize.d.ts +2 -1
  124. package/dist/initialize.js +18 -17
  125. package/dist/logger/config.d.ts +0 -3
  126. package/dist/logger/config.js +1 -1
  127. package/dist/logger/logger.js +2 -2
  128. package/dist/middleware/auth.js +5 -5
  129. package/dist/middleware/cors-config.d.ts +0 -3
  130. package/dist/middleware/cors-config.js +1 -1
  131. package/dist/middleware/cors.js +4 -4
  132. package/dist/middleware/error-handler.js +4 -4
  133. package/dist/middleware/index.js +14 -14
  134. package/dist/middleware/middleware-chain.js +3 -3
  135. package/dist/middleware/rate-limit.js +3 -3
  136. package/dist/middleware/response-logger.js +3 -3
  137. package/dist/middleware/security.js +3 -3
  138. package/dist/middleware/wrappers.js +14 -14
  139. package/dist/storage/config.d.ts +0 -3
  140. package/dist/storage/config.js +1 -1
  141. package/dist/storage/r2-storage.js +1 -1
  142. package/dist/system/cpu.js +4 -4
  143. package/dist/system/disk.js +4 -4
  144. package/dist/system/environment.js +8 -8
  145. package/dist/system/health-check.js +5 -5
  146. package/dist/system/index.js +13 -13
  147. package/dist/system/memory.js +4 -4
  148. package/dist/system/network.js +4 -4
  149. package/dist/system/utils.js +3 -3
  150. package/dist/utils/cors.js +3 -3
  151. package/dist/utils/csv-export.js +3 -3
  152. package/dist/utils/error-processor.js +3 -3
  153. package/dist/utils/index.js +7 -7
  154. package/package.json +1 -1
  155. package/dist/chunk-GTPUVHSV.js +0 -30
  156. package/dist/chunk-UCIUAZQT.js +0 -106
  157. /package/dist/{chunk-T4MDCVUQ.js → chunk-6CLQRZC2.js} +0 -0
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  runCommand,
3
3
  runMacCommand
4
- } from "./chunk-X6MGVFT3.js";
4
+ } from "./chunk-LRRQ54YJ.js";
5
5
  import {
6
6
  logger
7
- } from "./chunk-TEXVRHPF.js";
7
+ } from "./chunk-NOAU2JG7.js";
8
8
 
9
9
  // src/system/cpu.ts
10
10
  import os from "os";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  RegisterService
3
- } from "./chunk-ETMTDHK2.js";
3
+ } from "./chunk-SOQOAFB2.js";
4
4
  import {
5
5
  AuthError
6
6
  } from "./chunk-AIH3F7JV.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  getCacheConfig
3
- } from "./chunk-BEV7PQM3.js";
3
+ } from "./chunk-F3NGZYL2.js";
4
4
  import {
5
5
  getENV
6
- } from "./chunk-DBHISLC6.js";
6
+ } from "./chunk-OFSPZUQD.js";
7
7
 
8
8
  // src/cache/noop-cache-manager.ts
9
9
  var NoopCacheManager = class {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  clearTokenCookies
3
- } from "./chunk-G2Q4TI3Q.js";
3
+ } from "./chunk-V3ZIR4UL.js";
4
4
 
5
5
  // src/auth/handlers/logout.handler.ts
6
6
  import { NextResponse } from "next/server";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getENV,
3
3
  isCacheEnabled
4
- } from "./chunk-DBHISLC6.js";
4
+ } from "./chunk-OFSPZUQD.js";
5
5
 
6
6
  // src/cache/cache-config.ts
7
7
  var getCacheConfig = {
@@ -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
+ };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-AHDPGRXS.js";
4
4
  import {
5
5
  getGeolocationConfig
6
- } from "./chunk-3CBGGMIY.js";
6
+ } from "./chunk-LHIVUV7Q.js";
7
7
 
8
8
  // src/geolocation/providers/maxmind-provider.ts
9
9
  var MaxMindProvider = class extends BaseGeoIPProvider {
@@ -2,7 +2,9 @@
2
2
  var OAUTH_PROVIDERS = {
3
3
  GOOGLE: "google",
4
4
  GITHUB: "github",
5
- KAKAO: "kakao"
5
+ KAKAO: "kakao",
6
+ MICROSOFT: "microsoft",
7
+ META: "meta"
6
8
  };
7
9
  var PasswordStrength = /* @__PURE__ */ ((PasswordStrength2) => {
8
10
  PasswordStrength2["VERY_WEAK"] = "VERY_WEAK";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  OAuthManager
3
- } from "./chunk-HZLJYEOO.js";
3
+ } from "./chunk-57HPJEZB.js";
4
4
 
5
5
  // src/auth/handlers/oauth-authorize.handler.ts
6
6
  import { NextResponse } from "next/server";
@@ -59,7 +59,6 @@ var OAuthCallbackService = class {
59
59
  email: input.email,
60
60
  name: input.name,
61
61
  image: input.image,
62
- role: "USER",
63
62
  emailVerified: /* @__PURE__ */ new Date()
64
63
  // OAuth users are auto-verified
65
64
  });
@@ -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
+ };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-3GAY2T2A.js";
4
4
  import {
5
5
  setTokenCookies
6
- } from "./chunk-G2Q4TI3Q.js";
6
+ } from "./chunk-V3ZIR4UL.js";
7
7
  import {
8
8
  AuthError
9
9
  } from "./chunk-AIH3F7JV.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-TEXVRHPF.js";
3
+ } from "./chunk-NOAU2JG7.js";
4
4
  import {
5
5
  __spreadValues
6
6
  } from "./chunk-ORMEWXMH.js";
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-AHDPGRXS.js";
5
5
  import {
6
6
  getGeolocationConfig
7
- } from "./chunk-3CBGGMIY.js";
7
+ } from "./chunk-LHIVUV7Q.js";
8
8
 
9
9
  // src/geolocation/providers/ipgeolocation-provider.ts
10
10
  var IPGeolocationProvider = class extends BaseGeoIPProvider {
@@ -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
- if (getConfig()) return;
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
- setConfig({
15
+ globalThis.__withwiz_config.geolocation = {
22
16
  ipgeolocationApiKey: config.ipgeolocationApiKey,
23
17
  maxmindLicenseKey: config.maxmindLicenseKey
24
- });
18
+ };
25
19
  }
26
20
  function getGeolocationConfig() {
27
- const config = getConfig();
28
- if (!config) throw new ConfigurationError("Geolocation", "Not initialized. Call initializeGeolocation() first.");
29
- return config;
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[GLOBAL_KEY] = void 0;
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
- if (getConfig()) return;
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
- setConfig({
26
- level: (_a = config.level) != null ? _a : "info",
27
- dir: (_b = config.dir) != null ? _b : "./logs",
28
- file: (_c = config.file) != null ? _c : "app.log",
29
- fileEnabled: (_d = config.fileEnabled) != null ? _d : true,
30
- consoleEnabled: (_e = config.consoleEnabled) != null ? _e : true
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
- const config = getConfig();
35
- if (!config) throw new ConfigurationError("Logger", "Not initialized. Call initializeLogger() first.");
36
- return config;
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[GLOBAL_KEY] = void 0;
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
- if (getConfig()) return;
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
- setConfig({
22
+ globalThis.__withwiz_config.auth = {
30
23
  jwtSecret: config.jwtSecret,
31
- accessTokenExpiry: (_a = config.accessTokenExpiry) != null ? _a : "7d",
32
- refreshTokenExpiry: (_b = config.refreshTokenExpiry) != null ? _b : "30d",
33
- cookieSecure: (_c = config.cookieSecure) != null ? _c : false
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
- const config = getConfig();
38
- if (!config) {
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 config;
35
+ return auth;
42
36
  }
43
37
  function resetAuth() {
44
- globalThis[GLOBAL_KEY] = void 0;
38
+ if (globalThis.__withwiz_config) delete globalThis.__withwiz_config.auth;
45
39
  }
46
40
 
47
41
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-TEXVRHPF.js";
3
+ } from "./chunk-NOAU2JG7.js";
4
4
 
5
5
  // src/system/utils.ts
6
6
  import { exec } from "child_process";
@@ -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-X6MGVFT3.js";
3
+ } from "./chunk-LRRQ54YJ.js";
4
4
  import {
5
5
  getGeolocationConfig
6
- } from "./chunk-3CBGGMIY.js";
6
+ } from "./chunk-LHIVUV7Q.js";
7
7
  import {
8
8
  getAuthConfig
9
- } from "./chunk-A2XAOU55.js";
9
+ } from "./chunk-LNPZZ23G.js";
10
10
  import {
11
11
  getCommonConfig
12
- } from "./chunk-SFPMFVSD.js";
12
+ } from "./chunk-WPW4HXW4.js";
13
13
  import {
14
14
  getResolvedCacheConfig
15
- } from "./chunk-UCIUAZQT.js";
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
  getLoggerConfig
3
- } from "./chunk-OHBAELPZ.js";
3
+ } from "./chunk-LMQSV5UK.js";
4
4
  import {
5
5
  __spreadProps,
6
6
  __spreadValues
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-SNTLJ646.js";
7
7
  import {
8
8
  logger
9
- } from "./chunk-TEXVRHPF.js";
9
+ } from "./chunk-NOAU2JG7.js";
10
10
 
11
11
  // src/middleware/rate-limit.ts
12
12
  var GLOBAL_KEY = "__withwiz_rateLimitAdapter__";
@@ -2,7 +2,7 @@ import {
2
2
  logApiRequest,
3
3
  logApiResponse,
4
4
  logger
5
- } from "./chunk-TEXVRHPF.js";
5
+ } from "./chunk-NOAU2JG7.js";
6
6
 
7
7
  // src/middleware/response-logger.ts
8
8
  var responseLoggerMiddleware = async (context, next) => {
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-JQFQT4S2.js";
4
4
  import {
5
5
  setTokenCookies
6
- } from "./chunk-G2Q4TI3Q.js";
6
+ } from "./chunk-V3ZIR4UL.js";
7
7
  import {
8
8
  AuthError
9
9
  } from "./chunk-AIH3F7JV.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  getCommonConfig
3
- } from "./chunk-SFPMFVSD.js";
3
+ } from "./chunk-WPW4HXW4.js";
4
4
  import {
5
5
  getResolvedCacheConfig
6
- } from "./chunk-UCIUAZQT.js";
6
+ } from "./chunk-MGBNIDTP.js";
7
7
 
8
8
  // src/cache/cache-env.ts
9
9
  function _getNodeEnv() {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AUTH_ERROR_CODE_MAP
3
- } from "./chunk-MDTID4D2.js";
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-TEXVRHPF.js";
19
+ } from "./chunk-NOAU2JG7.js";
20
20
  import {
21
21
  __spreadValues
22
22
  } from "./chunk-ORMEWXMH.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-TEXVRHPF.js";
3
+ } from "./chunk-NOAU2JG7.js";
4
4
  import {
5
5
  __spreadValues
6
6
  } from "./chunk-ORMEWXMH.js";
@@ -3,10 +3,10 @@ import {
3
3
  formatBytesPerSec,
4
4
  runCommand,
5
5
  runMacCommand
6
- } from "./chunk-X6MGVFT3.js";
6
+ } from "./chunk-LRRQ54YJ.js";
7
7
  import {
8
8
  logger
9
- } from "./chunk-TEXVRHPF.js";
9
+ } from "./chunk-NOAU2JG7.js";
10
10
 
11
11
  // src/system/network.ts
12
12
  async function getNetworkInfo() {
@@ -9,7 +9,7 @@ import {
9
9
  logApiRequest,
10
10
  logApiResponse,
11
11
  logger
12
- } from "./chunk-TEXVRHPF.js";
12
+ } from "./chunk-NOAU2JG7.js";
13
13
 
14
14
  // src/utils/error-processor.ts
15
15
  import { NextResponse } from "next/server";
@@ -9,10 +9,10 @@ import {
9
9
  } from "./chunk-3GAY2T2A.js";
10
10
  import {
11
11
  getAuthConfig
12
- } from "./chunk-A2XAOU55.js";
12
+ } from "./chunk-LNPZZ23G.js";
13
13
  import {
14
14
  logger
15
- } from "./chunk-TEXVRHPF.js";
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-KF3O2DAV.js";
6
+ } from "./chunk-YTXCKIWE.js";
7
7
  import {
8
8
  rateLimitMiddleware
9
- } from "./chunk-WJSMXUZB.js";
9
+ } from "./chunk-NQUYNPSD.js";
10
10
  import {
11
11
  responseLoggerMiddleware
12
- } from "./chunk-CKK55QFQ.js";
12
+ } from "./chunk-NW3JIRFK.js";
13
13
  import {
14
14
  securityMiddleware
15
- } from "./chunk-4BGAE7NU.js";
15
+ } from "./chunk-TLBY3DUK.js";
16
16
  import {
17
17
  adminMiddleware,
18
18
  authMiddleware,
19
19
  optionalAuthMiddleware
20
- } from "./chunk-LFKPXF5E.js";
20
+ } from "./chunk-RXVX2DCW.js";
21
21
  import {
22
22
  corsMiddleware
23
- } from "./chunk-7KZRPDQD.js";
23
+ } from "./chunk-A6FKWYO2.js";
24
24
  import {
25
25
  errorHandlerMiddleware
26
- } from "./chunk-WRWWB2NU.js";
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;