levix-bot 2.1.0 → 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.
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/deploy/install.sh CHANGED
@@ -66,21 +66,30 @@ node_major() {
66
66
  esac
67
67
  }
68
68
 
69
+ # Read distro metadata in a subshell. /etc/os-release commonly defines VERSION,
70
+ # which must never overwrite Levix's own release VERSION in the parent shell.
71
+ read_os_id() (
72
+ local os_release="$1"
73
+ [ -r "$os_release" ] || return 1
74
+ # shellcheck disable=SC1090
75
+ . "$os_release"
76
+ printf '%s\n' "${ID:-}"
77
+ )
78
+
69
79
  install_node24() {
70
- [ -r /etc/os-release ] ||
80
+ local distro_id
81
+ distro_id="$(read_os_id /etc/os-release)" ||
71
82
  die "Node ${MIN_NODE_MAJOR}+ is required. Automatic Node installation is supported on Debian and Ubuntu only."
72
83
 
73
- # shellcheck disable=SC1091
74
- . /etc/os-release
75
- case "${ID:-}" in
84
+ case "$distro_id" in
76
85
  debian|ubuntu) ;;
77
86
  *)
78
- die "Node ${MIN_NODE_MAJOR}+ is required. Automatic Node installation is supported on Debian and Ubuntu only (found ${ID:-unknown}). Install Node ${MIN_NODE_MAJOR}+ and run this installer again."
87
+ die "Node ${MIN_NODE_MAJOR}+ is required. Automatic Node installation is supported on Debian and Ubuntu only (found ${distro_id:-unknown}). Install Node ${MIN_NODE_MAJOR}+ and run this installer again."
79
88
  ;;
80
89
  esac
81
90
 
82
91
  command -v apt-get >/dev/null 2>&1 ||
83
- die "This looks like ${ID}, but apt-get is unavailable. Install Node ${MIN_NODE_MAJOR}+ and run this installer again."
92
+ die "This looks like ${distro_id}, but apt-get is unavailable. Install Node ${MIN_NODE_MAJOR}+ and run this installer again."
84
93
 
85
94
  say "Installing Node ${MIN_NODE_MAJOR} from NodeSource…"
86
95
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "levix-bot",
3
- "version": "2.1.0",
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": {