@bbloker/sdk 0.3.0 → 0.4.1
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/adapters/express.cjs +4 -1
- package/dist/adapters/express.js +4 -1
- package/dist/adapters/fastify.cjs +4 -1
- package/dist/adapters/fastify.js +4 -1
- package/dist/adapters/hono.cjs +4 -1
- package/dist/adapters/hono.js +4 -1
- package/dist/adapters/nextjs.cjs +6 -1
- package/dist/adapters/nextjs.js +6 -1
- package/dist/adapters/node.cjs +4 -1
- package/dist/adapters/node.js +4 -1
- package/package.json +1 -1
|
@@ -45,7 +45,7 @@ function normalizeExpressRequest(req) {
|
|
|
45
45
|
headerNames.push(lower);
|
|
46
46
|
}
|
|
47
47
|
const forwarded = _optionalChain([headers, 'access', _ => _["x-forwarded-for"], 'optionalAccess', _2 => _2.split, 'call', _3 => _3(","), 'access', _4 => _4[0], 'optionalAccess', _5 => _5.trim, 'call', _6 => _6()]);
|
|
48
|
-
const ip = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(
|
|
48
|
+
const ip = stripIPv6Prefix(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(forwarded, () => ( headers["x-real-ip"])), () => ( req.ip)), () => ( _optionalChain([req, 'access', _7 => _7.socket, 'optionalAccess', _8 => _8.remoteAddress]))), () => ( "0.0.0.0")));
|
|
49
49
|
return {
|
|
50
50
|
ip,
|
|
51
51
|
userAgent: _nullishCoalesce(headers["user-agent"], () => ( "")),
|
|
@@ -55,6 +55,9 @@ function normalizeExpressRequest(req) {
|
|
|
55
55
|
method: _nullishCoalesce(req.method, () => ( "GET"))
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
+
function stripIPv6Prefix(ip) {
|
|
59
|
+
return ip.startsWith("::ffff:") ? ip.slice(7) : ip;
|
|
60
|
+
}
|
|
58
61
|
|
|
59
62
|
|
|
60
63
|
|
package/dist/adapters/express.js
CHANGED
|
@@ -45,7 +45,7 @@ function normalizeExpressRequest(req) {
|
|
|
45
45
|
headerNames.push(lower);
|
|
46
46
|
}
|
|
47
47
|
const forwarded = headers["x-forwarded-for"]?.split(",")[0]?.trim();
|
|
48
|
-
const ip =
|
|
48
|
+
const ip = stripIPv6Prefix(forwarded ?? headers["x-real-ip"] ?? req.ip ?? req.socket?.remoteAddress ?? "0.0.0.0");
|
|
49
49
|
return {
|
|
50
50
|
ip,
|
|
51
51
|
userAgent: headers["user-agent"] ?? "",
|
|
@@ -55,6 +55,9 @@ function normalizeExpressRequest(req) {
|
|
|
55
55
|
method: req.method ?? "GET"
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
+
function stripIPv6Prefix(ip) {
|
|
59
|
+
return ip.startsWith("::ffff:") ? ip.slice(7) : ip;
|
|
60
|
+
}
|
|
58
61
|
export {
|
|
59
62
|
Bbloker,
|
|
60
63
|
createMiddleware
|
|
@@ -48,7 +48,7 @@ function normalizeFastifyRequest(req) {
|
|
|
48
48
|
headerNames.push(lower);
|
|
49
49
|
}
|
|
50
50
|
const forwarded = _optionalChain([headers, 'access', _ => _["x-forwarded-for"], 'optionalAccess', _2 => _2.split, 'call', _3 => _3(","), 'access', _4 => _4[0], 'optionalAccess', _5 => _5.trim, 'call', _6 => _6()]);
|
|
51
|
-
const ip = _nullishCoalesce(_nullishCoalesce(
|
|
51
|
+
const ip = stripIPv6Prefix(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(forwarded, () => ( headers["x-real-ip"])), () => ( req.ip)), () => ( "0.0.0.0")));
|
|
52
52
|
return {
|
|
53
53
|
ip,
|
|
54
54
|
userAgent: _nullishCoalesce(headers["user-agent"], () => ( "")),
|
|
@@ -58,6 +58,9 @@ function normalizeFastifyRequest(req) {
|
|
|
58
58
|
method: _nullishCoalesce(req.method, () => ( "GET"))
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
+
function stripIPv6Prefix(ip) {
|
|
62
|
+
return ip.startsWith("::ffff:") ? ip.slice(7) : ip;
|
|
63
|
+
}
|
|
61
64
|
|
|
62
65
|
|
|
63
66
|
|
package/dist/adapters/fastify.js
CHANGED
|
@@ -48,7 +48,7 @@ function normalizeFastifyRequest(req) {
|
|
|
48
48
|
headerNames.push(lower);
|
|
49
49
|
}
|
|
50
50
|
const forwarded = headers["x-forwarded-for"]?.split(",")[0]?.trim();
|
|
51
|
-
const ip =
|
|
51
|
+
const ip = stripIPv6Prefix(forwarded ?? headers["x-real-ip"] ?? req.ip ?? "0.0.0.0");
|
|
52
52
|
return {
|
|
53
53
|
ip,
|
|
54
54
|
userAgent: headers["user-agent"] ?? "",
|
|
@@ -58,6 +58,9 @@ function normalizeFastifyRequest(req) {
|
|
|
58
58
|
method: req.method ?? "GET"
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
+
function stripIPv6Prefix(ip) {
|
|
62
|
+
return ip.startsWith("::ffff:") ? ip.slice(7) : ip;
|
|
63
|
+
}
|
|
61
64
|
export {
|
|
62
65
|
Bbloker,
|
|
63
66
|
createPlugin
|
package/dist/adapters/hono.cjs
CHANGED
|
@@ -39,7 +39,7 @@ function normalizeHonoRequest(c) {
|
|
|
39
39
|
});
|
|
40
40
|
const forwarded = _optionalChain([headers, 'access', _ => _["x-forwarded-for"], 'optionalAccess', _2 => _2.split, 'call', _3 => _3(","), 'access', _4 => _4[0], 'optionalAccess', _5 => _5.trim, 'call', _6 => _6()]);
|
|
41
41
|
const cfIp = headers["cf-connecting-ip"];
|
|
42
|
-
const ip = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(cfIp, () => ( forwarded)), () => ( headers["x-real-ip"])), () => ( "0.0.0.0"));
|
|
42
|
+
const ip = stripIPv6Prefix(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(cfIp, () => ( forwarded)), () => ( headers["x-real-ip"])), () => ( "0.0.0.0")));
|
|
43
43
|
return {
|
|
44
44
|
ip,
|
|
45
45
|
userAgent: _nullishCoalesce(headers["user-agent"], () => ( "")),
|
|
@@ -49,6 +49,9 @@ function normalizeHonoRequest(c) {
|
|
|
49
49
|
method: c.req.method
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
+
function stripIPv6Prefix(ip) {
|
|
53
|
+
return ip.startsWith("::ffff:") ? ip.slice(7) : ip;
|
|
54
|
+
}
|
|
52
55
|
|
|
53
56
|
|
|
54
57
|
|
package/dist/adapters/hono.js
CHANGED
|
@@ -39,7 +39,7 @@ function normalizeHonoRequest(c) {
|
|
|
39
39
|
});
|
|
40
40
|
const forwarded = headers["x-forwarded-for"]?.split(",")[0]?.trim();
|
|
41
41
|
const cfIp = headers["cf-connecting-ip"];
|
|
42
|
-
const ip = cfIp ?? forwarded ?? headers["x-real-ip"] ?? "0.0.0.0";
|
|
42
|
+
const ip = stripIPv6Prefix(cfIp ?? forwarded ?? headers["x-real-ip"] ?? "0.0.0.0");
|
|
43
43
|
return {
|
|
44
44
|
ip,
|
|
45
45
|
userAgent: headers["user-agent"] ?? "",
|
|
@@ -49,6 +49,9 @@ function normalizeHonoRequest(c) {
|
|
|
49
49
|
method: c.req.method
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
+
function stripIPv6Prefix(ip) {
|
|
53
|
+
return ip.startsWith("::ffff:") ? ip.slice(7) : ip;
|
|
54
|
+
}
|
|
52
55
|
export {
|
|
53
56
|
Bbloker,
|
|
54
57
|
createMiddleware
|
package/dist/adapters/nextjs.cjs
CHANGED
|
@@ -39,7 +39,9 @@ function normalizeNextRequest(req) {
|
|
|
39
39
|
headerNames.push(lower);
|
|
40
40
|
});
|
|
41
41
|
return {
|
|
42
|
-
ip:
|
|
42
|
+
ip: stripIPv6Prefix(
|
|
43
|
+
_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([headers, 'access', _ => _["x-forwarded-for"], 'optionalAccess', _2 => _2.split, 'call', _3 => _3(","), 'access', _4 => _4[0], 'optionalAccess', _5 => _5.trim, 'call', _6 => _6()]), () => ( headers["x-real-ip"])), () => ( req.ip)), () => ( "0.0.0.0"))
|
|
44
|
+
),
|
|
43
45
|
userAgent: _nullishCoalesce(headers["user-agent"], () => ( "")),
|
|
44
46
|
headers,
|
|
45
47
|
headerNames,
|
|
@@ -47,6 +49,9 @@ function normalizeNextRequest(req) {
|
|
|
47
49
|
method: req.method
|
|
48
50
|
};
|
|
49
51
|
}
|
|
52
|
+
function stripIPv6Prefix(ip) {
|
|
53
|
+
return ip.startsWith("::ffff:") ? ip.slice(7) : ip;
|
|
54
|
+
}
|
|
50
55
|
|
|
51
56
|
|
|
52
57
|
|
package/dist/adapters/nextjs.js
CHANGED
|
@@ -39,7 +39,9 @@ function normalizeNextRequest(req) {
|
|
|
39
39
|
headerNames.push(lower);
|
|
40
40
|
});
|
|
41
41
|
return {
|
|
42
|
-
ip:
|
|
42
|
+
ip: stripIPv6Prefix(
|
|
43
|
+
headers["x-forwarded-for"]?.split(",")[0]?.trim() ?? headers["x-real-ip"] ?? req.ip ?? "0.0.0.0"
|
|
44
|
+
),
|
|
43
45
|
userAgent: headers["user-agent"] ?? "",
|
|
44
46
|
headers,
|
|
45
47
|
headerNames,
|
|
@@ -47,6 +49,9 @@ function normalizeNextRequest(req) {
|
|
|
47
49
|
method: req.method
|
|
48
50
|
};
|
|
49
51
|
}
|
|
52
|
+
function stripIPv6Prefix(ip) {
|
|
53
|
+
return ip.startsWith("::ffff:") ? ip.slice(7) : ip;
|
|
54
|
+
}
|
|
50
55
|
export {
|
|
51
56
|
Bbloker,
|
|
52
57
|
createMiddleware
|
package/dist/adapters/node.cjs
CHANGED
|
@@ -44,7 +44,7 @@ function normalizeNodeRequest(req) {
|
|
|
44
44
|
headerNames.push(lower);
|
|
45
45
|
}
|
|
46
46
|
const forwarded = _optionalChain([headers, 'access', _ => _["x-forwarded-for"], 'optionalAccess', _2 => _2.split, 'call', _3 => _3(","), 'access', _4 => _4[0], 'optionalAccess', _5 => _5.trim, 'call', _6 => _6()]);
|
|
47
|
-
const ip = _nullishCoalesce(_nullishCoalesce(forwarded, () => ( _optionalChain([req, 'access', _7 => _7.socket, 'optionalAccess', _8 => _8.remoteAddress]))), () => ( "0.0.0.0"));
|
|
47
|
+
const ip = stripIPv6Prefix(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(forwarded, () => ( headers["x-real-ip"])), () => ( _optionalChain([req, 'access', _7 => _7.socket, 'optionalAccess', _8 => _8.remoteAddress]))), () => ( "0.0.0.0")));
|
|
48
48
|
return {
|
|
49
49
|
ip,
|
|
50
50
|
userAgent: _nullishCoalesce(headers["user-agent"], () => ( "")),
|
|
@@ -54,6 +54,9 @@ function normalizeNodeRequest(req) {
|
|
|
54
54
|
method: _nullishCoalesce(req.method, () => ( "GET"))
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
+
function stripIPv6Prefix(ip) {
|
|
58
|
+
return ip.startsWith("::ffff:") ? ip.slice(7) : ip;
|
|
59
|
+
}
|
|
57
60
|
|
|
58
61
|
|
|
59
62
|
|
package/dist/adapters/node.js
CHANGED
|
@@ -44,7 +44,7 @@ function normalizeNodeRequest(req) {
|
|
|
44
44
|
headerNames.push(lower);
|
|
45
45
|
}
|
|
46
46
|
const forwarded = headers["x-forwarded-for"]?.split(",")[0]?.trim();
|
|
47
|
-
const ip = forwarded ?? req.socket?.remoteAddress ?? "0.0.0.0";
|
|
47
|
+
const ip = stripIPv6Prefix(forwarded ?? headers["x-real-ip"] ?? req.socket?.remoteAddress ?? "0.0.0.0");
|
|
48
48
|
return {
|
|
49
49
|
ip,
|
|
50
50
|
userAgent: headers["user-agent"] ?? "",
|
|
@@ -54,6 +54,9 @@ function normalizeNodeRequest(req) {
|
|
|
54
54
|
method: req.method ?? "GET"
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
+
function stripIPv6Prefix(ip) {
|
|
58
|
+
return ip.startsWith("::ffff:") ? ip.slice(7) : ip;
|
|
59
|
+
}
|
|
57
60
|
export {
|
|
58
61
|
Bbloker,
|
|
59
62
|
createHandler
|