@withwiz/toolkit 0.2.4 → 0.2.5

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 (76) hide show
  1. package/dist/auth/core/jwt/index.d.ts +1 -1
  2. package/dist/auth/core/jwt/index.js +1 -1
  3. package/dist/auth/index.js +19 -19
  4. package/dist/cache/cache-config.js +3 -3
  5. package/dist/cache/cache-env.js +2 -2
  6. package/dist/cache/cache-factory.js +9 -9
  7. package/dist/cache/cache-invalidation.js +10 -10
  8. package/dist/cache/cache-redis.js +3 -3
  9. package/dist/cache/cache-wrapper.js +10 -10
  10. package/dist/cache/cache.js +11 -11
  11. package/dist/cache/hybrid-cache-manager.js +5 -5
  12. package/dist/cache/index.js +11 -11
  13. package/dist/cache/inmemory-cache-manager.js +2 -2
  14. package/dist/cache/noop-cache-manager.js +4 -4
  15. package/dist/cache/redis-cache-manager.js +4 -4
  16. package/dist/{chunk-UT4J7NPS.js → chunk-2ATBAIRL.js} +4 -8
  17. package/dist/{chunk-M4VXPTKV.js → chunk-45PS6FPL.js} +1 -1
  18. package/dist/{chunk-4KJXENRM.js → chunk-56BKKJOG.js} +1 -1
  19. package/dist/{chunk-HV3DGSSH.js → chunk-6FDDVTJY.js} +4 -4
  20. package/dist/{chunk-QYIUGQ5Q.js → chunk-7T6EAU4I.js} +2 -2
  21. package/dist/{chunk-26Y7VEYG.js → chunk-BCCXV7VY.js} +1 -1
  22. package/dist/{chunk-6LTZCXNC.js → chunk-BYQ6VG44.js} +2 -2
  23. package/dist/{chunk-Q7IP4JMW.js → chunk-DM6ANZVI.js} +2 -2
  24. package/dist/chunk-ELD6UH57.js +68 -0
  25. package/dist/{chunk-KAWVMIRJ.js → chunk-GJGLG2MN.js} +1 -1
  26. package/dist/{chunk-4DPSCTX4.js → chunk-HC7574TB.js} +2 -2
  27. package/dist/{chunk-EZR55KV2.js → chunk-HJIKCR6I.js} +1 -1
  28. package/dist/{chunk-I47QEDTX.js → chunk-HJL63P7P.js} +1 -1
  29. package/dist/{chunk-YBSHN67U.js → chunk-HWIINS3Q.js} +4 -4
  30. package/dist/{chunk-AIHQBQ3E.js → chunk-IVL62PFY.js} +8 -8
  31. package/dist/{chunk-WDRDGFHO.js → chunk-JVDJKMEF.js} +1 -1
  32. package/dist/{chunk-TXGNSECL.js → chunk-L26D4FDX.js} +1 -1
  33. package/dist/{chunk-G4NI37NN.js → chunk-L7AJJ3LC.js} +2 -2
  34. package/dist/{chunk-V4KAPU2S.js → chunk-MNORDAW2.js} +2 -2
  35. package/dist/{chunk-BKGVSC6S.js → chunk-MP66AGW5.js} +1 -1
  36. package/dist/{chunk-KWTBD4CM.js → chunk-P62T7AWY.js} +1 -1
  37. package/dist/{chunk-WTRBW2UY.js → chunk-PDQCJR4E.js} +10 -10
  38. package/dist/{chunk-WHR7HPWF.js → chunk-PJMXRAHZ.js} +2 -2
  39. package/dist/{chunk-Z4D4CMDA.js → chunk-PQ6GH2RP.js} +1 -1
  40. package/dist/{chunk-WSQMXMTL.js → chunk-SKCYXBDR.js} +6 -2
  41. package/dist/{chunk-TZAP5T4N.js → chunk-T7J2OS63.js} +1 -1
  42. package/dist/{chunk-6DD3MUDZ.js → chunk-UZDNS7TE.js} +1 -1
  43. package/dist/{chunk-GL2NANFH.js → chunk-VK23K5W7.js} +3 -3
  44. package/dist/{chunk-65LHDFU3.js → chunk-VQCW6FKJ.js} +2 -2
  45. package/dist/{chunk-L76O3X3D.js → chunk-WVPCER6E.js} +2 -2
  46. package/dist/{chunk-4ODT3Q4A.js → chunk-YGZBEEW2.js} +1 -1
  47. package/dist/error/error-handler.js +2 -2
  48. package/dist/error/index.js +2 -2
  49. package/dist/geolocation/batch-processor.js +2 -2
  50. package/dist/geolocation/index.js +2 -2
  51. package/dist/logger/logger.js +1 -1
  52. package/dist/middleware/auth.js +3 -3
  53. package/dist/middleware/cors.d.ts +39 -6
  54. package/dist/middleware/cors.js +4 -2
  55. package/dist/middleware/error-handler.js +3 -3
  56. package/dist/middleware/index.js +14 -14
  57. package/dist/middleware/middleware-chain.js +2 -2
  58. package/dist/middleware/rate-limit.js +2 -2
  59. package/dist/middleware/response-logger.js +2 -2
  60. package/dist/middleware/security.js +2 -1
  61. package/dist/middleware/wrappers.js +11 -11
  62. package/dist/system/cpu.js +3 -3
  63. package/dist/system/disk.js +3 -3
  64. package/dist/system/environment.js +3 -3
  65. package/dist/system/health-check.js +3 -3
  66. package/dist/system/index.js +10 -10
  67. package/dist/system/memory.js +3 -3
  68. package/dist/system/network.js +3 -3
  69. package/dist/system/utils.js +2 -2
  70. package/dist/utils/csv-export.js +2 -2
  71. package/dist/utils/error-processor.js +2 -2
  72. package/dist/utils/index.js +17 -17
  73. package/dist/utils/input-validation.d.ts +2 -0
  74. package/dist/utils/input-validation.js +4 -5
  75. package/package.json +1 -1
  76. package/dist/chunk-FOKAATUQ.js +0 -62
@@ -1,29 +1,29 @@
1
- import {
2
- getDiskInfo
3
- } from "../chunk-4DPSCTX4.js";
4
1
  import {
5
2
  checkEnvironmentVariables
6
- } from "../chunk-26Y7VEYG.js";
3
+ } from "../chunk-BCCXV7VY.js";
7
4
  import {
8
5
  checkServiceHealth
9
- } from "../chunk-WHR7HPWF.js";
6
+ } from "../chunk-PJMXRAHZ.js";
10
7
  import "../chunk-OIVXOT2X.js";
11
8
  import {
12
9
  getMemoryInfo
13
- } from "../chunk-G4NI37NN.js";
10
+ } from "../chunk-L7AJJ3LC.js";
14
11
  import {
15
12
  getNetworkInfo
16
- } from "../chunk-65LHDFU3.js";
13
+ } from "../chunk-VQCW6FKJ.js";
17
14
  import {
18
15
  getCpuInfo
19
- } from "../chunk-L76O3X3D.js";
16
+ } from "../chunk-WVPCER6E.js";
17
+ import {
18
+ getDiskInfo
19
+ } from "../chunk-HC7574TB.js";
20
20
  import {
21
21
  getPlatform,
22
22
  getRecommendedCommands
23
- } from "../chunk-KWTBD4CM.js";
23
+ } from "../chunk-P62T7AWY.js";
24
24
  import {
25
25
  logger
26
- } from "../chunk-EZR55KV2.js";
26
+ } from "../chunk-HJIKCR6I.js";
27
27
  import "../chunk-ORMEWXMH.js";
28
28
 
29
29
  // src/system/index.ts
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  getMemoryInfo
3
- } from "../chunk-G4NI37NN.js";
4
- import "../chunk-KWTBD4CM.js";
5
- import "../chunk-EZR55KV2.js";
3
+ } from "../chunk-L7AJJ3LC.js";
4
+ import "../chunk-P62T7AWY.js";
5
+ import "../chunk-HJIKCR6I.js";
6
6
  import "../chunk-ORMEWXMH.js";
7
7
  export {
8
8
  getMemoryInfo
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  getNetworkInfo
3
- } from "../chunk-65LHDFU3.js";
4
- import "../chunk-KWTBD4CM.js";
5
- import "../chunk-EZR55KV2.js";
3
+ } from "../chunk-VQCW6FKJ.js";
4
+ import "../chunk-P62T7AWY.js";
5
+ import "../chunk-HJIKCR6I.js";
6
6
  import "../chunk-ORMEWXMH.js";
7
7
  export {
8
8
  getNetworkInfo
@@ -9,8 +9,8 @@ import {
9
9
  runMacCommand,
10
10
  runPlatformCommand,
11
11
  runSafeCommand
12
- } from "../chunk-KWTBD4CM.js";
13
- import "../chunk-EZR55KV2.js";
12
+ } from "../chunk-P62T7AWY.js";
13
+ import "../chunk-HJIKCR6I.js";
14
14
  import "../chunk-ORMEWXMH.js";
15
15
  export {
16
16
  commandExists,
@@ -6,8 +6,8 @@ import {
6
6
  dateFormatter,
7
7
  escapeCsvField,
8
8
  rowToCsv
9
- } from "../chunk-BKGVSC6S.js";
10
- import "../chunk-EZR55KV2.js";
9
+ } from "../chunk-MP66AGW5.js";
10
+ import "../chunk-HJIKCR6I.js";
11
11
  import "../chunk-ORMEWXMH.js";
12
12
  export {
13
13
  boolFormatter,
@@ -12,10 +12,10 @@ import {
12
12
  throwUnauthorizedError,
13
13
  throwValidationError,
14
14
  withErrorHandling
15
- } from "../chunk-M4VXPTKV.js";
15
+ } from "../chunk-45PS6FPL.js";
16
16
  import "../chunk-KXXROUA5.js";
17
17
  import "../chunk-SNVGJPPX.js";
18
- import "../chunk-EZR55KV2.js";
18
+ import "../chunk-HJIKCR6I.js";
19
19
  import "../chunk-ORMEWXMH.js";
20
20
  export {
21
21
  ErrorProcessor,
@@ -34,6 +34,20 @@ import {
34
34
  isValidJSON,
35
35
  isValidUrl
36
36
  } from "../chunk-EUQATJLI.js";
37
+ import {
38
+ createPaginatedResponse,
39
+ getReferer,
40
+ getSearchParam,
41
+ getUserAgent,
42
+ parseBooleanParam,
43
+ parseFilters,
44
+ parseNumberParam,
45
+ parsePagination,
46
+ parseRequestBody,
47
+ parseSort,
48
+ requireAdmin,
49
+ validateAndParse
50
+ } from "../chunk-7JWIX5BS.js";
37
51
  import {
38
52
  getAllowedOrigins,
39
53
  getCorsConfig,
@@ -52,7 +66,7 @@ import {
52
66
  dateFormatter,
53
67
  escapeCsvField,
54
68
  rowToCsv
55
- } from "../chunk-BKGVSC6S.js";
69
+ } from "../chunk-MP66AGW5.js";
56
70
  import {
57
71
  ErrorProcessor,
58
72
  errorToResponse,
@@ -66,24 +80,10 @@ import {
66
80
  throwUnauthorizedError,
67
81
  throwValidationError,
68
82
  withErrorHandling
69
- } from "../chunk-M4VXPTKV.js";
70
- import {
71
- createPaginatedResponse,
72
- getReferer,
73
- getSearchParam,
74
- getUserAgent,
75
- parseBooleanParam,
76
- parseFilters,
77
- parseNumberParam,
78
- parsePagination,
79
- parseRequestBody,
80
- parseSort,
81
- requireAdmin,
82
- validateAndParse
83
- } from "../chunk-7JWIX5BS.js";
83
+ } from "../chunk-45PS6FPL.js";
84
84
  import "../chunk-KXXROUA5.js";
85
85
  import "../chunk-SNVGJPPX.js";
86
- import "../chunk-EZR55KV2.js";
86
+ import "../chunk-HJIKCR6I.js";
87
87
  import "../chunk-ORMEWXMH.js";
88
88
  export {
89
89
  ErrorProcessor,
@@ -10,6 +10,8 @@ export interface URLValidationOptions {
10
10
  allowedSchemes?: string[];
11
11
  maxLength?: number;
12
12
  requireProtocol?: boolean;
13
+ /** localhost/127.0.0.1 URL 허용 여부 (기본값: false) */
14
+ allowLocalhost?: boolean;
13
15
  }
14
16
  /**
15
17
  * URL 안전성 검증
@@ -29,7 +29,8 @@ function validateURL(url, options = {}) {
29
29
  const {
30
30
  allowedSchemes = ALLOWED_URL_SCHEMES,
31
31
  maxLength = 2048,
32
- requireProtocol = true
32
+ requireProtocol = true,
33
+ allowLocalhost = false
33
34
  } = options;
34
35
  if (!url || typeof url !== "string") {
35
36
  return { valid: false, error: "URL is required" };
@@ -57,10 +58,8 @@ function validateURL(url, options = {}) {
57
58
  try {
58
59
  const urlToParse = hasProtocol ? trimmedUrl : `https://${trimmedUrl}`;
59
60
  const parsed = new URL(urlToParse);
60
- if (parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1") {
61
- if (process.env.NODE_ENV === "production") {
62
- return { valid: false, error: "Internal URLs are not allowed" };
63
- }
61
+ if (!allowLocalhost && (parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1")) {
62
+ return { valid: false, error: "Internal URLs are not allowed" };
64
63
  }
65
64
  return {
66
65
  valid: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@withwiz/toolkit",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Shared utility library for withwiz projects",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -1,62 +0,0 @@
1
- import {
2
- logger
3
- } from "./chunk-EZR55KV2.js";
4
-
5
- // src/middleware/cors.ts
6
- import { NextResponse } from "next/server";
7
- var getAllowedOrigins = () => {
8
- const nodeEnv = process.env.NODE_ENV;
9
- if (nodeEnv === "production") {
10
- return [
11
- process.env.NEXT_PUBLIC_APP_URL || "https://tlog.net",
12
- "https://www.tlog.net"
13
- ].filter(Boolean);
14
- }
15
- return [
16
- "http://localhost:3000",
17
- "http://localhost:3001",
18
- "http://127.0.0.1:3000",
19
- process.env.NEXT_PUBLIC_APP_URL
20
- ].filter(Boolean);
21
- };
22
- var corsMiddleware = async (context, next) => {
23
- const { request } = context;
24
- const origin = request.headers.get("origin");
25
- const allowedOrigins = getAllowedOrigins();
26
- if (request.method === "OPTIONS") {
27
- const response2 = new NextResponse(null, { status: 204 });
28
- if (origin && allowedOrigins.includes(origin)) {
29
- response2.headers.set("Access-Control-Allow-Origin", origin);
30
- } else if (allowedOrigins.includes("*")) {
31
- response2.headers.set("Access-Control-Allow-Origin", "*");
32
- }
33
- response2.headers.set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, PATCH, OPTIONS");
34
- response2.headers.set("Access-Control-Allow-Headers", "Content-Type, Authorization, X-Requested-With, X-API-Key");
35
- response2.headers.set("Access-Control-Max-Age", "86400");
36
- response2.headers.set("Access-Control-Allow-Credentials", "true");
37
- return response2;
38
- }
39
- const response = await next();
40
- if (origin && allowedOrigins.includes(origin)) {
41
- response.headers.set("Access-Control-Allow-Origin", origin);
42
- response.headers.set("Access-Control-Allow-Credentials", "true");
43
- } else if (allowedOrigins.includes("*") || process.env.NODE_ENV === "test") {
44
- response.headers.set("Access-Control-Allow-Origin", origin || "*");
45
- response.headers.set("Access-Control-Allow-Credentials", "true");
46
- }
47
- response.headers.set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, PATCH, OPTIONS");
48
- response.headers.set("Access-Control-Allow-Headers", "Content-Type, Authorization, X-Requested-With, X-API-Key");
49
- return response;
50
- };
51
- function validateCorsConfiguration() {
52
- const allowedOrigins = getAllowedOrigins();
53
- const nodeEnv = process.env.NODE_ENV;
54
- logger.info(
55
- `[CORS Middleware] \u2705 Initialized - Environment: ${nodeEnv}, Allowed Origins: [${allowedOrigins.join(", ")}]`
56
- );
57
- }
58
-
59
- export {
60
- corsMiddleware,
61
- validateCorsConfiguration
62
- };