silgi 0.38.1 → 0.38.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.
- package/dist/cli/index.mjs +1 -1
- package/dist/kit/index.d.mts +2 -2
- package/dist/kit/index.mjs +5 -12
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
package/dist/kit/index.d.mts
CHANGED
|
@@ -282,10 +282,10 @@ declare function useResponse<T extends ServerResponse>(event: SilgiEvent): Serve
|
|
|
282
282
|
declare function getIpAddress(event: SilgiEvent): string | boolean;
|
|
283
283
|
/**
|
|
284
284
|
* Extract the client's IP address from request headers with high accuracy
|
|
285
|
-
* @param req - The incoming HTTP request
|
|
285
|
+
* @param req - The incoming HTTP request (Fetch API Request)
|
|
286
286
|
* @returns The client's IP address or empty string if not found
|
|
287
287
|
*/
|
|
288
|
-
declare function ipAddress(req:
|
|
288
|
+
declare function ipAddress(req: Request): string;
|
|
289
289
|
|
|
290
290
|
declare function relativeWithDot(from: string, to: string): string;
|
|
291
291
|
declare function toArray<T>(value: T | T[]): T[];
|
package/dist/kit/index.mjs
CHANGED
|
@@ -940,12 +940,8 @@ function useResponse(event) {
|
|
|
940
940
|
return event;
|
|
941
941
|
}
|
|
942
942
|
function getIpAddress(event) {
|
|
943
|
-
const
|
|
944
|
-
|
|
945
|
-
const _ipAddress = ipAddress(event.node.req);
|
|
946
|
-
return _ipAddress;
|
|
947
|
-
}
|
|
948
|
-
return false;
|
|
943
|
+
const _ipAddress = ipAddress(event.req);
|
|
944
|
+
return _ipAddress;
|
|
949
945
|
}
|
|
950
946
|
function ipAddress(req) {
|
|
951
947
|
const headers = [
|
|
@@ -981,13 +977,11 @@ function ipAddress(req) {
|
|
|
981
977
|
// Used by some CDNs
|
|
982
978
|
];
|
|
983
979
|
for (const header of headers) {
|
|
984
|
-
const value = req.headers
|
|
980
|
+
const value = req.headers.get(header);
|
|
985
981
|
if (!value)
|
|
986
982
|
continue;
|
|
987
983
|
let ip;
|
|
988
|
-
if (
|
|
989
|
-
ip = value[0];
|
|
990
|
-
} else if (header === "x-forwarded-for" || header === "forwarded-for" || header === "x-original-forwarded-for") {
|
|
984
|
+
if (header === "x-forwarded-for" || header === "forwarded-for" || header === "x-original-forwarded-for") {
|
|
991
985
|
ip = value.split(",")[0];
|
|
992
986
|
} else if (header === "forwarded") {
|
|
993
987
|
const match = value.match(/for=([^;]+)/);
|
|
@@ -1000,8 +994,7 @@ function ipAddress(req) {
|
|
|
1000
994
|
return cleanIp;
|
|
1001
995
|
}
|
|
1002
996
|
}
|
|
1003
|
-
|
|
1004
|
-
return socketIp && isValidIp(socketIp) ? socketIp : "";
|
|
997
|
+
return "";
|
|
1005
998
|
}
|
|
1006
999
|
function isValidIp(ip) {
|
|
1007
1000
|
if (ip === "::1" || ip === "localhost" || ip === "127.0.0.1")
|