@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.
- package/dist/auth/core/jwt/index.d.ts +1 -1
- package/dist/auth/core/jwt/index.js +1 -1
- package/dist/auth/index.js +19 -19
- package/dist/cache/cache-config.js +3 -3
- package/dist/cache/cache-env.js +2 -2
- package/dist/cache/cache-factory.js +9 -9
- package/dist/cache/cache-invalidation.js +10 -10
- package/dist/cache/cache-redis.js +3 -3
- package/dist/cache/cache-wrapper.js +10 -10
- package/dist/cache/cache.js +11 -11
- package/dist/cache/hybrid-cache-manager.js +5 -5
- package/dist/cache/index.js +11 -11
- package/dist/cache/inmemory-cache-manager.js +2 -2
- package/dist/cache/noop-cache-manager.js +4 -4
- package/dist/cache/redis-cache-manager.js +4 -4
- package/dist/{chunk-UT4J7NPS.js → chunk-2ATBAIRL.js} +4 -8
- package/dist/{chunk-M4VXPTKV.js → chunk-45PS6FPL.js} +1 -1
- package/dist/{chunk-4KJXENRM.js → chunk-56BKKJOG.js} +1 -1
- package/dist/{chunk-HV3DGSSH.js → chunk-6FDDVTJY.js} +4 -4
- package/dist/{chunk-QYIUGQ5Q.js → chunk-7T6EAU4I.js} +2 -2
- package/dist/{chunk-26Y7VEYG.js → chunk-BCCXV7VY.js} +1 -1
- package/dist/{chunk-6LTZCXNC.js → chunk-BYQ6VG44.js} +2 -2
- package/dist/{chunk-Q7IP4JMW.js → chunk-DM6ANZVI.js} +2 -2
- package/dist/chunk-ELD6UH57.js +68 -0
- package/dist/{chunk-KAWVMIRJ.js → chunk-GJGLG2MN.js} +1 -1
- package/dist/{chunk-4DPSCTX4.js → chunk-HC7574TB.js} +2 -2
- package/dist/{chunk-EZR55KV2.js → chunk-HJIKCR6I.js} +1 -1
- package/dist/{chunk-I47QEDTX.js → chunk-HJL63P7P.js} +1 -1
- package/dist/{chunk-YBSHN67U.js → chunk-HWIINS3Q.js} +4 -4
- package/dist/{chunk-AIHQBQ3E.js → chunk-IVL62PFY.js} +8 -8
- package/dist/{chunk-WDRDGFHO.js → chunk-JVDJKMEF.js} +1 -1
- package/dist/{chunk-TXGNSECL.js → chunk-L26D4FDX.js} +1 -1
- package/dist/{chunk-G4NI37NN.js → chunk-L7AJJ3LC.js} +2 -2
- package/dist/{chunk-V4KAPU2S.js → chunk-MNORDAW2.js} +2 -2
- package/dist/{chunk-BKGVSC6S.js → chunk-MP66AGW5.js} +1 -1
- package/dist/{chunk-KWTBD4CM.js → chunk-P62T7AWY.js} +1 -1
- package/dist/{chunk-WTRBW2UY.js → chunk-PDQCJR4E.js} +10 -10
- package/dist/{chunk-WHR7HPWF.js → chunk-PJMXRAHZ.js} +2 -2
- package/dist/{chunk-Z4D4CMDA.js → chunk-PQ6GH2RP.js} +1 -1
- package/dist/{chunk-WSQMXMTL.js → chunk-SKCYXBDR.js} +6 -2
- package/dist/{chunk-TZAP5T4N.js → chunk-T7J2OS63.js} +1 -1
- package/dist/{chunk-6DD3MUDZ.js → chunk-UZDNS7TE.js} +1 -1
- package/dist/{chunk-GL2NANFH.js → chunk-VK23K5W7.js} +3 -3
- package/dist/{chunk-65LHDFU3.js → chunk-VQCW6FKJ.js} +2 -2
- package/dist/{chunk-L76O3X3D.js → chunk-WVPCER6E.js} +2 -2
- package/dist/{chunk-4ODT3Q4A.js → chunk-YGZBEEW2.js} +1 -1
- package/dist/error/error-handler.js +2 -2
- package/dist/error/index.js +2 -2
- package/dist/geolocation/batch-processor.js +2 -2
- package/dist/geolocation/index.js +2 -2
- package/dist/logger/logger.js +1 -1
- package/dist/middleware/auth.js +3 -3
- package/dist/middleware/cors.d.ts +39 -6
- package/dist/middleware/cors.js +4 -2
- package/dist/middleware/error-handler.js +3 -3
- package/dist/middleware/index.js +14 -14
- package/dist/middleware/middleware-chain.js +2 -2
- package/dist/middleware/rate-limit.js +2 -2
- package/dist/middleware/response-logger.js +2 -2
- package/dist/middleware/security.js +2 -1
- package/dist/middleware/wrappers.js +11 -11
- package/dist/system/cpu.js +3 -3
- package/dist/system/disk.js +3 -3
- package/dist/system/environment.js +3 -3
- package/dist/system/health-check.js +3 -3
- package/dist/system/index.js +10 -10
- package/dist/system/memory.js +3 -3
- package/dist/system/network.js +3 -3
- package/dist/system/utils.js +2 -2
- package/dist/utils/csv-export.js +2 -2
- package/dist/utils/error-processor.js +2 -2
- package/dist/utils/index.js +17 -17
- package/dist/utils/input-validation.d.ts +2 -0
- package/dist/utils/input-validation.js +4 -5
- package/package.json +1 -1
- package/dist/chunk-FOKAATUQ.js +0 -62
package/dist/system/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getDiskInfo
|
|
3
|
-
} from "../chunk-4DPSCTX4.js";
|
|
4
1
|
import {
|
|
5
2
|
checkEnvironmentVariables
|
|
6
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-BCCXV7VY.js";
|
|
7
4
|
import {
|
|
8
5
|
checkServiceHealth
|
|
9
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-PJMXRAHZ.js";
|
|
10
7
|
import "../chunk-OIVXOT2X.js";
|
|
11
8
|
import {
|
|
12
9
|
getMemoryInfo
|
|
13
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-L7AJJ3LC.js";
|
|
14
11
|
import {
|
|
15
12
|
getNetworkInfo
|
|
16
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-VQCW6FKJ.js";
|
|
17
14
|
import {
|
|
18
15
|
getCpuInfo
|
|
19
|
-
} from "../chunk-
|
|
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-
|
|
23
|
+
} from "../chunk-P62T7AWY.js";
|
|
24
24
|
import {
|
|
25
25
|
logger
|
|
26
|
-
} from "../chunk-
|
|
26
|
+
} from "../chunk-HJIKCR6I.js";
|
|
27
27
|
import "../chunk-ORMEWXMH.js";
|
|
28
28
|
|
|
29
29
|
// src/system/index.ts
|
package/dist/system/memory.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getMemoryInfo
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
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
|
package/dist/system/network.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getNetworkInfo
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
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
|
package/dist/system/utils.js
CHANGED
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
runMacCommand,
|
|
10
10
|
runPlatformCommand,
|
|
11
11
|
runSafeCommand
|
|
12
|
-
} from "../chunk-
|
|
13
|
-
import "../chunk-
|
|
12
|
+
} from "../chunk-P62T7AWY.js";
|
|
13
|
+
import "../chunk-HJIKCR6I.js";
|
|
14
14
|
import "../chunk-ORMEWXMH.js";
|
|
15
15
|
export {
|
|
16
16
|
commandExists,
|
package/dist/utils/csv-export.js
CHANGED
|
@@ -12,10 +12,10 @@ import {
|
|
|
12
12
|
throwUnauthorizedError,
|
|
13
13
|
throwValidationError,
|
|
14
14
|
withErrorHandling
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-45PS6FPL.js";
|
|
16
16
|
import "../chunk-KXXROUA5.js";
|
|
17
17
|
import "../chunk-SNVGJPPX.js";
|
|
18
|
-
import "../chunk-
|
|
18
|
+
import "../chunk-HJIKCR6I.js";
|
|
19
19
|
import "../chunk-ORMEWXMH.js";
|
|
20
20
|
export {
|
|
21
21
|
ErrorProcessor,
|
package/dist/utils/index.js
CHANGED
|
@@ -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-
|
|
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-
|
|
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-
|
|
86
|
+
import "../chunk-HJIKCR6I.js";
|
|
87
87
|
import "../chunk-ORMEWXMH.js";
|
|
88
88
|
export {
|
|
89
89
|
ErrorProcessor,
|
|
@@ -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
|
-
|
|
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
package/dist/chunk-FOKAATUQ.js
DELETED
|
@@ -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
|
-
};
|