levix-bot 2.1.1 → 2.1.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.
Files changed (2) hide show
  1. package/app.cjs +13 -5
  2. package/package.json +1 -1
package/app.cjs CHANGED
@@ -41,11 +41,11 @@ function isAllowedOrigin(origin, host) {
41
41
  }
42
42
 
43
43
  // Browsers may legitimately serialize the Origin header as the literal string
44
- // "null" for a same-origin navigation in an opaque-origin context. Treating
45
- // that as a foreign origin breaks first-run/login forms in real browsers even
46
- // though Sec-Fetch-Site still proves the navigation is same-origin. Fetch
47
- // metadata headers are forbidden to page JavaScript, so they are a stronger
48
- // browser signal than trying to special-case the string "null" globally.
44
+ // "null" for a same-origin navigation in an opaque-origin context. Prefer
45
+ // Fetch Metadata when the browser sends it. Some Chromium form navigations omit
46
+ // Sec-Fetch-Site entirely, so only the two credential-gated auth forms get a
47
+ // narrow fallback for Origin:null; every other mutation remains strict.
48
+ const OPAQUE_ORIGIN_AUTH_PATHS = new Set(["/setup", "/login"]);
49
49
  function isAllowedMutationRequest(req) {
50
50
  const origin = req.get("origin");
51
51
  const host = req.get("host");
@@ -58,6 +58,14 @@ function isAllowedMutationRequest(req) {
58
58
  if (fetchSite === "same-origin") return true;
59
59
  if (fetchSite === "cross-site") return false;
60
60
 
61
+ // Real Chromium can submit a top-level auth form with Origin:null and no
62
+ // Sec-Fetch-Site header. Setup is still protected by the one-time setup code
63
+ // for remote clients; login by the password; both share TCP-peer throttling.
64
+ // Do not generalize this exception to dashboard APIs or logout.
65
+ if (origin === "null" && !fetchSite && OPAQUE_ORIGIN_AUTH_PATHS.has(req.path)) {
66
+ return true;
67
+ }
68
+
61
69
  return isAllowedOrigin(origin, host);
62
70
  }
63
71
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "levix-bot",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "A self-hosted personal WhatsApp bot with an AI agent, group moderation and a web control panel.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {