@chatpanel/gateway 0.6.30 → 0.6.31

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 +1 -1
  2. package/src/server.js +13 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatpanel/gateway",
3
- "version": "0.6.30",
3
+ "version": "0.6.31",
4
4
  "description": "Local privacy gateway — redacts PII out of OpenAI/Anthropic API traffic before it reaches a model, then restores it in the reply. Point opencode, codex, aider, Claude Code, etc. at it.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/server.js CHANGED
@@ -45,7 +45,7 @@ import * as openai from './openai.js';
45
45
  import * as responses from './responses.js';
46
46
  import * as anthropic from './anthropic.js';
47
47
 
48
- export const VERSION = '0.6.30';
48
+ export const VERSION = '0.6.31';
49
49
 
50
50
  // WARM search tier — SQLite + FTS5 record store (falls back to an encrypted-JSON
51
51
  // store if SQLite can't load), fed by the extension's ingest sync + backup-ingest.
@@ -499,6 +499,18 @@ export function createGateway(cfg = loadConfig()) {
499
499
  if (req.headers.origin) setCors(res, req.headers.origin);
500
500
  if (req.method === 'OPTIONS') { res.writeHead(204); return res.end(); }
501
501
 
502
+ // Admin-token handshake. The extension authenticates admin routes by its
503
+ // chrome-extension:// Origin, but Chrome OMITS Origin on GET requests to a host the
504
+ // extension has permission for — so config READS (GET /config) would fail. A POST
505
+ // still carries the Origin, so the extension POSTs here (authorized by Origin) to get
506
+ // the token, then sends it as `Authorization: Bearer` on the GET admin routes. A
507
+ // drive-by web page can't reach this: its Origin isn't chrome-extension:// (Origin
508
+ // check) and it has no token. Additive route — old extensions ignore it.
509
+ if (pathname === '/admin/token' && req.method === 'POST') {
510
+ if (!isAdminAuthorized(req)) return sendJson(res, 403, { error: 'admin: extension origin or gateway token required' });
511
+ return sendJson(res, 200, { token: ensureGatewayToken() });
512
+ }
513
+
502
514
  // M2: ADMIN routes reconfigure the gateway (POST /config) or expose its in-memory
503
515
  // logs (GET /logs). Unlike the /v1 data plane (open to any local client — the
504
516
  // product), these must not be reachable by a no-Origin local process or a drive-by