rterm-cli 3.7.3 → 3.7.5

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/package.json +3 -11
  2. package/rterm-cli.mjs +22 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rterm-cli",
3
- "version": "3.7.3",
3
+ "version": "3.7.5",
4
4
  "description": "rterm — command CLI for the RTerm / neuralOS backend WebSocket gateway",
5
5
  "type": "module",
6
6
  "bin": {
@@ -21,15 +21,7 @@
21
21
  "ssh",
22
22
  "ai",
23
23
  "agent",
24
- "cli",
25
- "chatops",
26
- "fde",
27
- "agentic-ai"
24
+ "cli"
28
25
  ],
29
- "license": "MIT",
30
- "repository": {
31
- "type": "git",
32
- "url": "git+https://github.com/DrOlu/RTerm.git",
33
- "directory": "apps/cli"
34
- }
26
+ "license": "MIT"
35
27
  }
package/rterm-cli.mjs CHANGED
@@ -91,11 +91,31 @@ function loadToken() {
91
91
  return null
92
92
  }
93
93
 
94
+ /**
95
+ * Append the token as an `access_token` query parameter. The gateway accepts
96
+ * the token from the Authorization header OR this query param; the query param
97
+ * works on every WebSocket client (native WS ignores constructor options on
98
+ * some runtimes, and browsers cannot send custom headers at all).
99
+ */
100
+ function urlWithToken(url, token) {
101
+ if (!token) return url
102
+ try {
103
+ const u = new URL(url)
104
+ if (!u.searchParams.has('access_token')) u.searchParams.set('access_token', token)
105
+ return u.toString()
106
+ } catch {
107
+ return url
108
+ }
109
+ }
110
+
94
111
  async function openSocket(url, token) {
95
112
  const headers = token ? { Authorization: `Bearer ${token}` } : undefined
96
113
  if (typeof globalThis.WebSocket === 'function') {
97
114
  return await new Promise((resolve, reject) => {
98
- const ws = new globalThis.WebSocket(url)
115
+ // Pass the token BOTH ways: as a query param (always works) and try the
116
+ // options object (native WebSocket in Node >= 22 forwards extra options
117
+ // to undici and sends the header; browsers ignore it harmlessly).
118
+ const ws = new globalThis.WebSocket(urlWithToken(url, token), headers ? { headers } : undefined)
99
119
  ws.onopen = () => resolve(ws)
100
120
  ws.onerror = () => reject(new Error(`Cannot connect to ${url}. Is the backend running? (gybackend)`))
101
121
  })
@@ -105,7 +125,7 @@ async function openSocket(url, token) {
105
125
  const require = createRequire(import.meta.url)
106
126
  const WS = require('ws')
107
127
  return await new Promise((resolve, reject) => {
108
- const ws = new WS(url, { headers })
128
+ const ws = new WS(urlWithToken(url, token), { headers })
109
129
  ws.on('open', () => resolve(ws))
110
130
  ws.on('error', () => reject(new Error(`Cannot connect to ${url}. Is the backend running? (gybackend)`)))
111
131
  })