@hasna/logs 0.3.31 → 0.3.32

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.
@@ -2148,12 +2148,12 @@ function isLocalOpenModeEnabled() {
2148
2148
  }
2149
2149
  function isTrustedLocalRequest(c) {
2150
2150
  const url = new URL(c.req.url);
2151
- const host = forwardedHost(c.req.header("x-forwarded-host")) ?? hostWithoutPort(c.req.header("host")) ?? url.hostname;
2152
- return isLocalHost(host) && isLocalOrigin(c.req.header("origin"));
2153
- }
2154
- function forwardedHost(value) {
2155
- const first = value?.split(",")[0]?.trim();
2156
- return first ? hostWithoutPort(first) : null;
2151
+ const hosts = [
2152
+ hostWithoutPort(c.req.header("host")),
2153
+ url.hostname,
2154
+ ...forwardedHosts(c.req.header("x-forwarded-host"))
2155
+ ].filter((host) => Boolean(host));
2156
+ return hosts.length > 0 && hosts.every((host) => isLocalHost(host)) && isLocalOrigin(c.req.header("origin"));
2157
2157
  }
2158
2158
  function hostWithoutPort(value) {
2159
2159
  if (!value)
@@ -2162,6 +2162,9 @@ function hostWithoutPort(value) {
2162
2162
  return value.slice(1, value.indexOf("]"));
2163
2163
  return value.split(":")[0] || null;
2164
2164
  }
2165
+ function forwardedHosts(value) {
2166
+ return value?.split(",").map((host) => hostWithoutPort(host.trim())).filter((host) => Boolean(host)) ?? [];
2167
+ }
2165
2168
  function isLocalOrigin(origin) {
2166
2169
  if (!origin)
2167
2170
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/logs",
3
- "version": "0.3.31",
3
+ "version": "0.3.32",
4
4
  "description": "Log aggregation + browser script + headless page scanner + performance monitoring for AI agents",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",