solrouter 0.2.0 → 0.2.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/package.json +1 -1
- package/src/config.js +1 -0
- package/src/providers.js +14 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solrouter",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Local privacy router for coding tools: pseudonymises every request before it leaves your machine, and sends work a frontier model would refuse to an uncensored open-weight model you control.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/config.js
CHANGED
|
@@ -53,6 +53,7 @@ function readJson(path) {
|
|
|
53
53
|
function deepMerge(a, b) {
|
|
54
54
|
const out = { ...a };
|
|
55
55
|
for (const k of Object.keys(b || {})) {
|
|
56
|
+
if (b[k] === undefined) continue; // never let an unset override clobber a default
|
|
56
57
|
out[k] = b[k] && typeof b[k] === "object" && !Array.isArray(b[k])
|
|
57
58
|
? deepMerge(a[k] || {}, b[k]) : b[k];
|
|
58
59
|
}
|
package/src/providers.js
CHANGED
|
@@ -13,8 +13,14 @@
|
|
|
13
13
|
|
|
14
14
|
import { loadAuth } from "./config.js";
|
|
15
15
|
|
|
16
|
-
//
|
|
17
|
-
|
|
16
|
+
// In pass-through mode we forward the client's headers VERBATIM (auth, every
|
|
17
|
+
// anthropic-beta flag, oauth markers, user-agent), dropping only hop-by-hop headers
|
|
18
|
+
// that must be recomputed for the new destination. An allowlist silently dropped
|
|
19
|
+
// headers Claude Code needs (beta flags, oauth), which broke subscription auth.
|
|
20
|
+
const DROP = new Set([
|
|
21
|
+
"host", "connection", "content-length", "transfer-encoding",
|
|
22
|
+
"accept-encoding", "keep-alive", "proxy-connection",
|
|
23
|
+
]);
|
|
18
24
|
|
|
19
25
|
function authHeaders(leg, clientHeaders = {}) {
|
|
20
26
|
const h = { "content-type": "application/json" };
|
|
@@ -33,9 +39,13 @@ function authHeaders(leg, clientHeaders = {}) {
|
|
|
33
39
|
return h;
|
|
34
40
|
}
|
|
35
41
|
|
|
36
|
-
// 2. pass-through (default): forward
|
|
42
|
+
// 2. pass-through (default): forward every client header verbatim
|
|
37
43
|
let forwarded = false;
|
|
38
|
-
for (const k of
|
|
44
|
+
for (const k of Object.keys(clientHeaders)) {
|
|
45
|
+
if (DROP.has(k)) continue;
|
|
46
|
+
h[k] = clientHeaders[k];
|
|
47
|
+
if (k === "authorization" || k === "x-api-key") forwarded = true;
|
|
48
|
+
}
|
|
39
49
|
if (!forwarded) {
|
|
40
50
|
// nothing to forward — fall back to the account token if we have one
|
|
41
51
|
const auth = loadAuth();
|