@withwiz/toolkit 0.3.0 → 0.3.2

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 (110) hide show
  1. package/dist/auth/config.d.ts +3 -0
  2. package/dist/auth/config.js +1 -1
  3. package/dist/auth/core/jwt/index.js +1 -1
  4. package/dist/auth/index.js +1 -1
  5. package/dist/cache/cache-config.js +5 -5
  6. package/dist/cache/cache-env.js +4 -4
  7. package/dist/cache/cache-factory.js +14 -14
  8. package/dist/cache/cache-invalidation.js +14 -14
  9. package/dist/cache/cache-redis.js +7 -7
  10. package/dist/cache/cache-wrapper.js +14 -14
  11. package/dist/cache/cache.js +25 -25
  12. package/dist/cache/config.d.ts +3 -0
  13. package/dist/cache/config.js +2 -2
  14. package/dist/cache/hybrid-cache-manager.js +9 -9
  15. package/dist/cache/index.js +25 -25
  16. package/dist/cache/inmemory-cache-manager.js +4 -4
  17. package/dist/cache/noop-cache-manager.js +6 -6
  18. package/dist/cache/redis-cache-manager.js +8 -8
  19. package/dist/{chunk-HKJCBV3H.js → chunk-2KDLKHTO.js} +6 -6
  20. package/dist/{chunk-V33BEN6H.js → chunk-3CBGGMIY.js} +15 -7
  21. package/dist/{chunk-ZFFWKCHN.js → chunk-4HBAPPB2.js} +2 -2
  22. package/dist/{chunk-M776IH4D.js → chunk-6MI4XLWC.js} +3 -3
  23. package/dist/{chunk-BY653UR3.js → chunk-6SOQUYOU.js} +2 -2
  24. package/dist/{chunk-3GKJ763I.js → chunk-7IN4WRSO.js} +12 -12
  25. package/dist/{chunk-5P4E6SGV.js → chunk-A6V6XVPZ.js} +6 -6
  26. package/dist/{chunk-PU2LFTI5.js → chunk-AXCB7SKY.js} +2 -2
  27. package/dist/{chunk-YCIYDWJU.js → chunk-AYZJN32D.js} +15 -7
  28. package/dist/{chunk-DC2OFQ43.js → chunk-BKJPYZYO.js} +16 -13
  29. package/dist/{chunk-KAIGEZAL.js → chunk-BYCFXGQL.js} +3 -3
  30. package/dist/{chunk-AWFY2HWG.js → chunk-CUZPD3BF.js} +2 -2
  31. package/dist/{chunk-CZHFHEBG.js → chunk-E54MAI4I.js} +5 -5
  32. package/dist/{chunk-GRGOD3W5.js → chunk-FD2TXDTO.js} +2 -2
  33. package/dist/{chunk-FGA7VLYK.js → chunk-FDRIFPG6.js} +2 -2
  34. package/dist/{chunk-L6M4DZV2.js → chunk-FPESPW6P.js} +1 -1
  35. package/dist/{chunk-Q7NIAITA.js → chunk-G5OMETUS.js} +1 -1
  36. package/dist/{chunk-JNB7MWG4.js → chunk-GFWGLWTS.js} +15 -7
  37. package/dist/{chunk-SNNXLA5F.js → chunk-GQVBWZLH.js} +2 -2
  38. package/dist/{chunk-MVH5ZPFD.js → chunk-HHCDMWEF.js} +1 -1
  39. package/dist/{chunk-XZ4HMXSK.js → chunk-J4TTSXDN.js} +3 -3
  40. package/dist/{chunk-576PAKLR.js → chunk-JOM3N4EJ.js} +1 -1
  41. package/dist/{chunk-FIRLRKET.js → chunk-K3HAYBWX.js} +1 -1
  42. package/dist/{chunk-NE33JZW3.js → chunk-KGHWGLED.js} +4 -4
  43. package/dist/{chunk-4CSSGCW5.js → chunk-KZUBO2IL.js} +3 -3
  44. package/dist/{chunk-ZBU2DYLD.js → chunk-LFQ3IQQB.js} +2 -2
  45. package/dist/{chunk-SR65BF6X.js → chunk-N54KGJPU.js} +9 -1
  46. package/dist/{chunk-NWAN2VRP.js → chunk-NQS7UT6X.js} +9 -9
  47. package/dist/{chunk-C3WPAWID.js → chunk-O7CK3CKJ.js} +1 -1
  48. package/dist/{chunk-RLXRDUBX.js → chunk-OHBAELPZ.js} +15 -7
  49. package/dist/{chunk-STNIT65W.js → chunk-OIRAH57Y.js} +1 -1
  50. package/dist/{chunk-ITSXXSFN.js → chunk-OZE5KUS3.js} +15 -7
  51. package/dist/{chunk-UD7YHLHI.js → chunk-QVWDWROP.js} +1 -1
  52. package/dist/{chunk-2ATBAIRL.js → chunk-R6YVUU6I.js} +1 -1
  53. package/dist/{chunk-BJWG3LH5.js → chunk-RWVGJUON.js} +6 -6
  54. package/dist/{chunk-JGGGHEBC.js → chunk-S5UCZ2T3.js} +1 -1
  55. package/dist/{chunk-5MBKG2ZD.js → chunk-SFPMFVSD.js} +14 -6
  56. package/dist/{chunk-6VNEAK73.js → chunk-SV7X6HEN.js} +4 -4
  57. package/dist/{chunk-JTPLPUI7.js → chunk-TFD3DSM2.js} +18 -10
  58. package/dist/{chunk-USL5SQLZ.js → chunk-TO5CMMQC.js} +2 -2
  59. package/dist/{chunk-FO77EZCU.js → chunk-VF4EVAMV.js} +1 -1
  60. package/dist/{chunk-2LCLLZME.js → chunk-WNF2RKFA.js} +7 -7
  61. package/dist/{chunk-X2QSMX3B.js → chunk-XI4MRH5P.js} +4 -4
  62. package/dist/config/common.d.ts +3 -0
  63. package/dist/config/common.js +1 -1
  64. package/dist/error/error-handler.js +6 -6
  65. package/dist/error/index.js +7 -7
  66. package/dist/geolocation/batch-processor.js +4 -4
  67. package/dist/geolocation/config.d.ts +3 -0
  68. package/dist/geolocation/config.js +1 -1
  69. package/dist/geolocation/index.js +8 -8
  70. package/dist/geolocation/providers/index.js +4 -4
  71. package/dist/geolocation/providers/ipgeolocation-provider.js +2 -2
  72. package/dist/geolocation/providers/maxmind-provider.js +2 -2
  73. package/dist/initialize.js +11 -11
  74. package/dist/logger/config.d.ts +3 -0
  75. package/dist/logger/config.js +1 -1
  76. package/dist/logger/logger.js +3 -3
  77. package/dist/middleware/auth.js +8 -8
  78. package/dist/middleware/cors-config.d.ts +3 -0
  79. package/dist/middleware/cors-config.js +1 -1
  80. package/dist/middleware/cors.js +5 -5
  81. package/dist/middleware/error-handler.js +7 -7
  82. package/dist/middleware/index.js +19 -19
  83. package/dist/middleware/middleware-chain.js +4 -4
  84. package/dist/middleware/rate-limit.js +5 -5
  85. package/dist/middleware/response-logger.js +4 -4
  86. package/dist/middleware/security.js +4 -4
  87. package/dist/middleware/wrappers.js +17 -17
  88. package/dist/storage/config.d.ts +3 -0
  89. package/dist/storage/config.js +1 -1
  90. package/dist/storage/r2-storage.js +2 -2
  91. package/dist/system/cpu.js +5 -5
  92. package/dist/system/disk.js +5 -5
  93. package/dist/system/environment.js +9 -9
  94. package/dist/system/health-check.js +7 -7
  95. package/dist/system/index.js +14 -14
  96. package/dist/system/memory.js +5 -5
  97. package/dist/system/network.js +5 -5
  98. package/dist/system/utils.js +4 -4
  99. package/dist/utils/cors.js +3 -3
  100. package/dist/utils/csv-export.js +4 -4
  101. package/dist/utils/error-processor.js +5 -5
  102. package/dist/utils/index.js +16 -16
  103. package/dist/utils/ip-utils.d.ts +9 -6
  104. package/dist/utils/ip-utils.js +3 -6
  105. package/dist/utils/sanitizer.d.ts +5 -4
  106. package/dist/utils/sanitizer.js +1 -1
  107. package/dist/utils/short-code-generator.d.ts +2 -1
  108. package/dist/utils/short-code-generator.js +3 -1
  109. package/dist/utils/url-normalizer.js +22 -1
  110. package/package.json +1 -1
@@ -1,29 +1,29 @@
1
+ import {
2
+ NoopCacheManager
3
+ } from "./chunk-FDRIFPG6.js";
1
4
  import {
2
5
  RedisCacheManager
3
- } from "./chunk-4CSSGCW5.js";
6
+ } from "./chunk-KZUBO2IL.js";
4
7
  import {
5
8
  HybridCacheManager
6
- } from "./chunk-6VNEAK73.js";
9
+ } from "./chunk-SV7X6HEN.js";
7
10
  import {
8
11
  InMemoryCacheManager
9
- } from "./chunk-XZ4HMXSK.js";
10
- import {
11
- NoopCacheManager
12
- } from "./chunk-FGA7VLYK.js";
13
- import {
14
- getCacheConfig
15
- } from "./chunk-C3WPAWID.js";
12
+ } from "./chunk-J4TTSXDN.js";
16
13
  import {
17
14
  isRedisAvailableNow,
18
15
  isRedisGloballyDisabled
19
- } from "./chunk-PU2LFTI5.js";
16
+ } from "./chunk-AXCB7SKY.js";
20
17
  import {
21
18
  logger
22
- } from "./chunk-SNNXLA5F.js";
19
+ } from "./chunk-GQVBWZLH.js";
20
+ import {
21
+ getCacheConfig
22
+ } from "./chunk-O7CK3CKJ.js";
23
23
  import {
24
24
  getENV,
25
25
  isCacheEnabled
26
- } from "./chunk-X2QSMX3B.js";
26
+ } from "./chunk-XI4MRH5P.js";
27
27
 
28
28
  // src/cache/cache-factory.ts
29
29
  function getInMemoryConfig() {
@@ -2,17 +2,17 @@ import {
2
2
  AppError
3
3
  } from "./chunk-KXXROUA5.js";
4
4
  import {
5
- logger
6
- } from "./chunk-SNNXLA5F.js";
5
+ ERROR_CODES
6
+ } from "./chunk-SNVGJPPX.js";
7
7
  import {
8
8
  getAuthConfig
9
- } from "./chunk-ITSXXSFN.js";
9
+ } from "./chunk-OZE5KUS3.js";
10
10
  import {
11
11
  JWTManager
12
- } from "./chunk-2ATBAIRL.js";
12
+ } from "./chunk-R6YVUU6I.js";
13
13
  import {
14
- ERROR_CODES
15
- } from "./chunk-SNVGJPPX.js";
14
+ logger
15
+ } from "./chunk-GQVBWZLH.js";
16
16
 
17
17
  // src/middleware/auth.ts
18
18
  function setAccessTokenBlacklistChecker(checker) {
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-SNNXLA5F.js";
3
+ } from "./chunk-GQVBWZLH.js";
4
4
  import {
5
5
  getCacheFallbackConfig,
6
6
  getConfig,
7
7
  getEnv,
8
8
  isCacheEnabled,
9
9
  validateRedisEnvironment
10
- } from "./chunk-X2QSMX3B.js";
10
+ } from "./chunk-XI4MRH5P.js";
11
11
 
12
12
  // src/cache/cache-redis.ts
13
13
  import { Redis } from "@upstash/redis";
@@ -6,28 +6,36 @@ import {
6
6
  } from "./chunk-2QH66EVQ.js";
7
7
 
8
8
  // src/storage/config.ts
9
- var _config = null;
9
+ var GLOBAL_KEY = "__withwiz_storage_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
+ }
10
17
  function initializeStorage(config) {
11
- if (_config) return;
18
+ if (getConfig()) return;
12
19
  if (!config.accountId) throw new ConfigurationError("Storage", "accountId is required");
13
20
  if (!config.accessKeyId) throw new ConfigurationError("Storage", "accessKeyId is required");
14
21
  if (!config.secretAccessKey) throw new ConfigurationError("Storage", "secretAccessKey is required");
15
22
  if (!config.bucketName) throw new ConfigurationError("Storage", "bucketName is required");
16
23
  if (config.publicUrl === void 0) configWarn("Storage", "publicUrl not provided");
17
- _config = {
24
+ setConfig({
18
25
  accountId: config.accountId,
19
26
  accessKeyId: config.accessKeyId,
20
27
  secretAccessKey: config.secretAccessKey,
21
28
  bucketName: config.bucketName,
22
29
  publicUrl: config.publicUrl
23
- };
30
+ });
24
31
  }
25
32
  function getStorageConfig() {
26
- if (!_config) throw new ConfigurationError("Storage", "Not initialized. Call initializeStorage() first.");
27
- return _config;
33
+ const config = getConfig();
34
+ if (!config) throw new ConfigurationError("Storage", "Not initialized. Call initializeStorage() first.");
35
+ return config;
28
36
  }
29
37
  function resetStorage() {
30
- _config = null;
38
+ globalThis[GLOBAL_KEY] = void 0;
31
39
  }
32
40
 
33
41
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AUTH_ERROR_CODE_MAP
3
- } from "./chunk-HKJCBV3H.js";
3
+ } from "./chunk-2KDLKHTO.js";
4
4
  import {
5
5
  AppError
6
6
  } from "./chunk-KXXROUA5.js";
@@ -8,18 +8,18 @@ import {
8
8
  getErrorMessage
9
9
  } from "./chunk-Y2JYA2AR.js";
10
10
  import {
11
- logger
12
- } from "./chunk-SNNXLA5F.js";
13
- import {
14
- getCommonConfig
15
- } from "./chunk-5MBKG2ZD.js";
11
+ ERROR_CODES,
12
+ classifyError
13
+ } from "./chunk-SNVGJPPX.js";
16
14
  import {
17
15
  AuthError
18
16
  } from "./chunk-AIH3F7JV.js";
19
17
  import {
20
- ERROR_CODES,
21
- classifyError
22
- } from "./chunk-SNVGJPPX.js";
18
+ logger
19
+ } from "./chunk-GQVBWZLH.js";
20
+ import {
21
+ getCommonConfig
22
+ } from "./chunk-SFPMFVSD.js";
23
23
  import {
24
24
  __spreadValues
25
25
  } from "./chunk-ORMEWXMH.js";
@@ -28,7 +28,7 @@ import {
28
28
  import { NextResponse } from "next/server";
29
29
  import { z } from "zod";
30
30
  var errorHandlerMiddleware = async (context, next) => {
31
- var _a, _b;
31
+ var _a;
32
32
  try {
33
33
  return await next();
34
34
  } catch (error) {
@@ -75,7 +75,11 @@ var errorHandlerMiddleware = async (context, next) => {
75
75
  );
76
76
  }
77
77
  const classified = error instanceof Error ? classifyError(error) : ERROR_CODES.INTERNAL_SERVER_ERROR;
78
- logger.error("[ErrorHandler] Unexpected error:", error);
78
+ logger.error("[ErrorHandler] Unexpected error:", {
79
+ error,
80
+ requestId: context.requestId,
81
+ stack: error instanceof Error ? error.stack : void 0
82
+ });
79
83
  let isProduction = false;
80
84
  try {
81
85
  isProduction = getCommonConfig().nodeEnv === "production";
@@ -87,8 +91,7 @@ var errorHandlerMiddleware = async (context, next) => {
87
91
  classified.code,
88
92
  safeMessage,
89
93
  context.locale,
90
- context.requestId,
91
- !isProduction && error instanceof Error ? { stack: (_b = error.stack) == null ? void 0 : _b.split("\n").slice(0, 5) } : void 0
94
+ context.requestId
92
95
  );
93
96
  }
94
97
  };
@@ -4,13 +4,13 @@ import {
4
4
  } from "./chunk-OIVXOT2X.js";
5
5
  import {
6
6
  getPlatform
7
- } from "./chunk-JGGGHEBC.js";
7
+ } from "./chunk-S5UCZ2T3.js";
8
8
  import {
9
9
  logger
10
- } from "./chunk-SNNXLA5F.js";
10
+ } from "./chunk-GQVBWZLH.js";
11
11
  import {
12
12
  getResolvedCacheConfig
13
- } from "./chunk-JTPLPUI7.js";
13
+ } from "./chunk-TFD3DSM2.js";
14
14
 
15
15
  // src/system/health-check.ts
16
16
  async function checkServiceHealth(prismaClient) {
@@ -6,10 +6,10 @@ import {
6
6
  } from "./chunk-VSGKVZB4.js";
7
7
  import {
8
8
  IPGeolocationProvider
9
- } from "./chunk-MVH5ZPFD.js";
9
+ } from "./chunk-HHCDMWEF.js";
10
10
  import {
11
11
  MaxMindProvider
12
- } from "./chunk-Q7NIAITA.js";
12
+ } from "./chunk-G5OMETUS.js";
13
13
 
14
14
  // src/geolocation/providers/index.ts
15
15
  var GeoIPProviderFactory = class {
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  AppError
3
3
  } from "./chunk-KXXROUA5.js";
4
- import {
5
- logApiRequest,
6
- logApiResponse,
7
- logger
8
- } from "./chunk-SNNXLA5F.js";
9
4
  import {
10
5
  ERROR_CODES,
11
6
  formatErrorMessage
12
7
  } from "./chunk-SNVGJPPX.js";
8
+ import {
9
+ logApiRequest,
10
+ logApiResponse,
11
+ logger
12
+ } from "./chunk-GQVBWZLH.js";
13
13
 
14
14
  // src/utils/error-processor.ts
15
15
  import { NextResponse } from "next/server";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  runCommand,
3
3
  runMacCommand
4
- } from "./chunk-JGGGHEBC.js";
4
+ } from "./chunk-S5UCZ2T3.js";
5
5
  import {
6
6
  logger
7
- } from "./chunk-SNNXLA5F.js";
7
+ } from "./chunk-GQVBWZLH.js";
8
8
 
9
9
  // src/system/cpu.ts
10
10
  import os from "os";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  getCacheConfig
3
- } from "./chunk-C3WPAWID.js";
3
+ } from "./chunk-O7CK3CKJ.js";
4
4
  import {
5
5
  getENV
6
- } from "./chunk-X2QSMX3B.js";
6
+ } from "./chunk-XI4MRH5P.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
  logger
3
- } from "./chunk-SNNXLA5F.js";
3
+ } from "./chunk-GQVBWZLH.js";
4
4
  import {
5
5
  __spreadValues
6
6
  } from "./chunk-ORMEWXMH.js";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-AHDPGRXS.js";
4
4
  import {
5
5
  getGeolocationConfig
6
- } from "./chunk-V33BEN6H.js";
6
+ } from "./chunk-3CBGGMIY.js";
7
7
 
8
8
  // src/geolocation/providers/maxmind-provider.ts
9
9
  var MaxMindProvider = class extends BaseGeoIPProvider {
@@ -6,9 +6,16 @@ import {
6
6
  } from "./chunk-2QH66EVQ.js";
7
7
 
8
8
  // src/middleware/cors-config.ts
9
- var _config = null;
9
+ var GLOBAL_KEY = "__withwiz_cors_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
+ }
10
17
  function initializeCors(config) {
11
- if (_config) return;
18
+ if (getConfig()) return;
12
19
  if (!config.allowedOrigins) {
13
20
  throw new ConfigurationError("CORS", "allowedOrigins is required");
14
21
  }
@@ -18,19 +25,20 @@ function initializeCors(config) {
18
25
  if (config.baseUrl === void 0) {
19
26
  configWarn("CORS", "baseUrl not provided");
20
27
  }
21
- _config = {
28
+ setConfig({
22
29
  allowedOrigins: [...config.allowedOrigins],
23
30
  baseUrl: config.baseUrl
24
- };
31
+ });
25
32
  }
26
33
  function getCorsConfig() {
27
- if (!_config) {
34
+ const config = getConfig();
35
+ if (!config) {
28
36
  throw new ConfigurationError("CORS", "Not initialized. Call initializeCors() first.");
29
37
  }
30
- return _config;
38
+ return config;
31
39
  }
32
40
  function resetCors() {
33
- _config = null;
41
+ globalThis[GLOBAL_KEY] = void 0;
34
42
  }
35
43
 
36
44
  export {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  getLoggerConfig
3
- } from "./chunk-RLXRDUBX.js";
3
+ } from "./chunk-OHBAELPZ.js";
4
4
  import {
5
5
  getCommonConfig
6
- } from "./chunk-5MBKG2ZD.js";
6
+ } from "./chunk-SFPMFVSD.js";
7
7
  import {
8
8
  __spreadProps,
9
9
  __spreadValues
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-AHDPGRXS.js";
5
5
  import {
6
6
  getGeolocationConfig
7
- } from "./chunk-V33BEN6H.js";
7
+ } from "./chunk-3CBGGMIY.js";
8
8
 
9
9
  // src/geolocation/providers/ipgeolocation-provider.ts
10
10
  var IPGeolocationProvider = class extends BaseGeoIPProvider {
@@ -1,9 +1,9 @@
1
+ import {
2
+ logger
3
+ } from "./chunk-GQVBWZLH.js";
1
4
  import {
2
5
  DEFAULT_INMEMORY_CONFIG
3
6
  } from "./chunk-SS56XFLI.js";
4
- import {
5
- logger
6
- } from "./chunk-SNNXLA5F.js";
7
7
  import {
8
8
  __spreadProps,
9
9
  __spreadValues
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-SNNXLA5F.js";
3
+ } from "./chunk-GQVBWZLH.js";
4
4
  import {
5
5
  __spreadValues
6
6
  } from "./chunk-ORMEWXMH.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-SNNXLA5F.js";
3
+ } from "./chunk-GQVBWZLH.js";
4
4
  import {
5
5
  __spreadValues
6
6
  } from "./chunk-ORMEWXMH.js";
@@ -1,9 +1,9 @@
1
- import {
2
- logger
3
- } from "./chunk-SNNXLA5F.js";
4
1
  import {
5
2
  getCorsConfig
6
- } from "./chunk-JNB7MWG4.js";
3
+ } from "./chunk-GFWGLWTS.js";
4
+ import {
5
+ logger
6
+ } from "./chunk-GQVBWZLH.js";
7
7
 
8
8
  // src/middleware/cors.ts
9
9
  import { NextResponse } from "next/server";
@@ -3,14 +3,14 @@ import {
3
3
  isRedisGloballyDisabled,
4
4
  notifyRedisError,
5
5
  resetRedisGlobalState
6
- } from "./chunk-PU2LFTI5.js";
6
+ } from "./chunk-AXCB7SKY.js";
7
7
  import {
8
8
  logger
9
- } from "./chunk-SNNXLA5F.js";
9
+ } from "./chunk-GQVBWZLH.js";
10
10
  import {
11
11
  getENV,
12
12
  isCacheEnabled
13
- } from "./chunk-X2QSMX3B.js";
13
+ } from "./chunk-XI4MRH5P.js";
14
14
  import {
15
15
  __spreadValues
16
16
  } from "./chunk-ORMEWXMH.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  runCommand,
3
3
  runMacCommand
4
- } from "./chunk-JGGGHEBC.js";
4
+ } from "./chunk-S5UCZ2T3.js";
5
5
  import {
6
6
  logger
7
- } from "./chunk-SNNXLA5F.js";
7
+ } from "./chunk-GQVBWZLH.js";
8
8
 
9
9
  // src/system/memory.ts
10
10
  import os from "os";
@@ -7,7 +7,15 @@ function sanitizeHtml(input) {
7
7
  if (!input || typeof input !== "string") {
8
8
  return "";
9
9
  }
10
- return input.replace(/<[^>]*>/g, "").replace(/&lt;/gi, "<").replace(/&gt;/gi, ">").replace(/<[^>]*>/g, "").replace(/&amp;/gi, "&").replace(/&quot;/gi, '"').replace(/&#x27;/gi, "'").replace(/&#x2F;/gi, "/").trim();
10
+ let result = input;
11
+ result = result.replace(/<[^>]*>/g, "");
12
+ result = result.replace(/&lt;/gi, "<").replace(/&gt;/gi, ">");
13
+ result = result.replace(/<[^>]*>/g, "");
14
+ result = result.replace(/&#(\d+);/g, (_, dec) => String.fromCharCode(Number(dec))).replace(/&#x([0-9a-fA-F]+);/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)));
15
+ result = result.replace(/<[^>]*>/g, "");
16
+ result = result.replace(/<[^>]*$/g, "");
17
+ result = result.replace(/&amp;/gi, "&").replace(/&quot;/gi, '"').replace(/&#x27;/gi, "'").replace(/&#x2F;/gi, "/");
18
+ return result.trim();
11
19
  }
12
20
  function removeEventHandlers(input) {
13
21
  if (!input || typeof input !== "string") {
@@ -1,29 +1,29 @@
1
- import {
2
- errorHandlerMiddleware
3
- } from "./chunk-DC2OFQ43.js";
4
1
  import {
5
2
  initRequestMiddleware
6
3
  } from "./chunk-62Q7DN5G.js";
7
4
  import {
8
5
  MiddlewareChain
9
- } from "./chunk-L6M4DZV2.js";
6
+ } from "./chunk-FPESPW6P.js";
10
7
  import {
11
8
  rateLimitMiddleware
12
- } from "./chunk-M776IH4D.js";
9
+ } from "./chunk-6MI4XLWC.js";
13
10
  import {
14
11
  responseLoggerMiddleware
15
- } from "./chunk-STNIT65W.js";
12
+ } from "./chunk-OIRAH57Y.js";
16
13
  import {
17
14
  securityMiddleware
18
- } from "./chunk-UD7YHLHI.js";
15
+ } from "./chunk-QVWDWROP.js";
19
16
  import {
20
17
  adminMiddleware,
21
18
  authMiddleware,
22
19
  optionalAuthMiddleware
23
- } from "./chunk-5P4E6SGV.js";
20
+ } from "./chunk-A6V6XVPZ.js";
24
21
  import {
25
22
  corsMiddleware
26
- } from "./chunk-NE33JZW3.js";
23
+ } from "./chunk-KGHWGLED.js";
24
+ import {
25
+ errorHandlerMiddleware
26
+ } from "./chunk-BKJPYZYO.js";
27
27
 
28
28
  // src/middleware/wrappers.ts
29
29
  function withPublicApi(handler) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getENV,
3
3
  isCacheEnabled
4
- } from "./chunk-X2QSMX3B.js";
4
+ } from "./chunk-XI4MRH5P.js";
5
5
 
6
6
  // src/cache/cache-config.ts
7
7
  var getCacheConfig = {
@@ -6,29 +6,37 @@ import {
6
6
  } from "./chunk-2QH66EVQ.js";
7
7
 
8
8
  // src/logger/config.ts
9
- var _config = null;
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
+ }
10
17
  function initializeLogger(config) {
11
18
  var _a, _b, _c, _d, _e;
12
- if (_config) return;
19
+ if (getConfig()) return;
13
20
  if (config.level === void 0) configWarn("Logger", "level not provided, using default: info");
14
21
  if (config.dir === void 0) configWarn("Logger", "dir not provided, using default: ./logs");
15
22
  if (config.file === void 0) configWarn("Logger", "file not provided, using default: app.log");
16
23
  if (config.fileEnabled === void 0) configWarn("Logger", "fileEnabled not provided, using default: true");
17
24
  if (config.consoleEnabled === void 0) configWarn("Logger", "consoleEnabled not provided, using default: true");
18
- _config = {
25
+ setConfig({
19
26
  level: (_a = config.level) != null ? _a : "info",
20
27
  dir: (_b = config.dir) != null ? _b : "./logs",
21
28
  file: (_c = config.file) != null ? _c : "app.log",
22
29
  fileEnabled: (_d = config.fileEnabled) != null ? _d : true,
23
30
  consoleEnabled: (_e = config.consoleEnabled) != null ? _e : true
24
- };
31
+ });
25
32
  }
26
33
  function getLoggerConfig() {
27
- if (!_config) throw new ConfigurationError("Logger", "Not initialized. Call initializeLogger() first.");
28
- return _config;
34
+ const config = getConfig();
35
+ if (!config) throw new ConfigurationError("Logger", "Not initialized. Call initializeLogger() first.");
36
+ return config;
29
37
  }
30
38
  function resetLogger() {
31
- _config = null;
39
+ globalThis[GLOBAL_KEY] = void 0;
32
40
  }
33
41
 
34
42
  export {
@@ -2,7 +2,7 @@ import {
2
2
  logApiRequest,
3
3
  logApiResponse,
4
4
  logger
5
- } from "./chunk-SNNXLA5F.js";
5
+ } from "./chunk-GQVBWZLH.js";
6
6
 
7
7
  // src/middleware/response-logger.ts
8
8
  var responseLoggerMiddleware = async (context, next) => {
@@ -6,10 +6,17 @@ import {
6
6
  } from "./chunk-2QH66EVQ.js";
7
7
 
8
8
  // src/auth/config.ts
9
- var _config = null;
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
+ }
10
17
  function initializeAuth(config) {
11
18
  var _a, _b;
12
- if (_config) return;
19
+ if (getConfig()) return;
13
20
  if (!config.jwtSecret) {
14
21
  throw new ConfigurationError("Auth", "jwtSecret is required");
15
22
  }
@@ -19,20 +26,21 @@ function initializeAuth(config) {
19
26
  if (!config.refreshTokenExpiry) {
20
27
  configWarn("Auth", "refreshTokenExpiry not provided, using default: 30d");
21
28
  }
22
- _config = {
29
+ setConfig({
23
30
  jwtSecret: config.jwtSecret,
24
31
  accessTokenExpiry: (_a = config.accessTokenExpiry) != null ? _a : "7d",
25
32
  refreshTokenExpiry: (_b = config.refreshTokenExpiry) != null ? _b : "30d"
26
- };
33
+ });
27
34
  }
28
35
  function getAuthConfig() {
29
- if (!_config) {
36
+ const config = getConfig();
37
+ if (!config) {
30
38
  throw new ConfigurationError("Auth", "Not initialized. Call initializeAuth() first.");
31
39
  }
32
- return _config;
40
+ return config;
33
41
  }
34
42
  function resetAuth() {
35
- _config = null;
43
+ globalThis[GLOBAL_KEY] = void 0;
36
44
  }
37
45
 
38
46
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-SNNXLA5F.js";
3
+ } from "./chunk-GQVBWZLH.js";
4
4
 
5
5
  // src/middleware/security.ts
6
6
  import { NextResponse } from "next/server";
@@ -25,7 +25,7 @@ var JWTManager = class {
25
25
  });
26
26
  return jwt;
27
27
  } catch (error) {
28
- this.logger.error("Failed to create access token", { error, payload });
28
+ this.logger.error("Failed to create access token", { error, userId: payload.userId });
29
29
  throw new JWTError(
30
30
  "Access token creation failed",
31
31
  "TOKEN_CREATION_FAILED"
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  getCacheManager,
3
3
  getEffectiveCacheBackend
4
- } from "./chunk-3GKJ763I.js";
4
+ } from "./chunk-7IN4WRSO.js";
5
+ import {
6
+ logger
7
+ } from "./chunk-GQVBWZLH.js";
5
8
  import {
6
9
  getCacheConfig,
7
10
  getCacheTTL
8
- } from "./chunk-C3WPAWID.js";
9
- import {
10
- logger
11
- } from "./chunk-SNNXLA5F.js";
11
+ } from "./chunk-O7CK3CKJ.js";
12
12
  import {
13
13
  isCacheEnabled
14
- } from "./chunk-X2QSMX3B.js";
14
+ } from "./chunk-XI4MRH5P.js";
15
15
 
16
16
  // src/cache/cache-wrapper.ts
17
17
  function getCacheBackendLabel() {