@solongate/proxy 0.81.5 → 0.81.7
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/dist/global-install.js +1 -1
- package/dist/index.js +1 -1
- package/dist/login.js +39 -5
- package/hooks/audit.mjs +4 -0
- package/package.json +1 -1
package/dist/global-install.js
CHANGED
|
@@ -232,7 +232,7 @@ async function runGlobalInstall(opts = {}) {
|
|
|
232
232
|
writeFileSync(join(p.hooksDir, "stop.mjs"), readHook("stop.mjs"));
|
|
233
233
|
writeFileSync(join(p.hooksDir, "shield.mjs"), readHook("shield.mjs"));
|
|
234
234
|
console.log(` Installed hooks \u2192 ${p.hooksDir}`);
|
|
235
|
-
|
|
235
|
+
installClaudeShim(join(p.hooksDir, "shield.mjs"));
|
|
236
236
|
writeFileSync(p.configPath, JSON.stringify({ apiKey, apiUrl }, null, 2) + "\n");
|
|
237
237
|
console.log(` Wrote ${p.configPath}`);
|
|
238
238
|
let existing = {};
|
package/dist/index.js
CHANGED
|
@@ -10576,7 +10576,7 @@ async function runGlobalInstall(opts = {}) {
|
|
|
10576
10576
|
writeFileSync4(join9(p.hooksDir, "stop.mjs"), readHook("stop.mjs"));
|
|
10577
10577
|
writeFileSync4(join9(p.hooksDir, "shield.mjs"), readHook("shield.mjs"));
|
|
10578
10578
|
console.log(` Installed hooks \u2192 ${p.hooksDir}`);
|
|
10579
|
-
|
|
10579
|
+
installClaudeShim(join9(p.hooksDir, "shield.mjs"));
|
|
10580
10580
|
writeFileSync4(p.configPath, JSON.stringify({ apiKey, apiUrl }, null, 2) + "\n");
|
|
10581
10581
|
console.log(` Wrote ${p.configPath}`);
|
|
10582
10582
|
let existing = {};
|
package/dist/login.js
CHANGED
|
@@ -141,6 +141,19 @@ var SHIM_END = "# <<< SolonGate shield <<<";
|
|
|
141
141
|
function escapeRe(s) {
|
|
142
142
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
143
143
|
}
|
|
144
|
+
function resolveRealClaude() {
|
|
145
|
+
try {
|
|
146
|
+
const finder = process.platform === "win32" ? "where" : "which";
|
|
147
|
+
const out = execFileSync(finder, ["claude"], { encoding: "utf-8" }).split(/\r?\n/).map((s) => s.trim()).filter(Boolean);
|
|
148
|
+
if (process.platform === "win32") {
|
|
149
|
+
const low = (s) => s.toLowerCase();
|
|
150
|
+
return out.find((l) => low(l).endsWith(".cmd")) || out.find((l) => low(l).endsWith(".exe")) || out.find((l) => low(l).endsWith(".bat")) || out[0] || null;
|
|
151
|
+
}
|
|
152
|
+
return out[0] || null;
|
|
153
|
+
} catch {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
144
157
|
function shimTargets() {
|
|
145
158
|
if (process.platform === "win32") {
|
|
146
159
|
try {
|
|
@@ -163,13 +176,34 @@ function writeShimBlock(file, block) {
|
|
|
163
176
|
mkdirSync(dirname(file), { recursive: true });
|
|
164
177
|
writeFileSync(file, content);
|
|
165
178
|
}
|
|
166
|
-
function
|
|
167
|
-
|
|
179
|
+
function installClaudeShim(shieldPath) {
|
|
180
|
+
const real = resolveRealClaude();
|
|
181
|
+
if (!real) {
|
|
182
|
+
console.log(" (Claude Code not found on PATH \u2014 skipped auto-shield. Install it, then re-run `login`.)");
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const node = process.execPath.replace(/\\/g, "/");
|
|
186
|
+
const shield = shieldPath.replace(/\\/g, "/");
|
|
187
|
+
const win = process.platform === "win32";
|
|
188
|
+
const block = win ? `${SHIM_BEGIN}
|
|
189
|
+
function claude { & "${node}" "${shield}" -- "${real}" @args }
|
|
190
|
+
${SHIM_END}` : `${SHIM_BEGIN}
|
|
191
|
+
claude() { "${node}" "${shield}" -- "${real}" "$@"; }
|
|
192
|
+
${SHIM_END}`;
|
|
193
|
+
const targets = shimTargets();
|
|
194
|
+
if (targets.length === 0) {
|
|
195
|
+
console.log(" (No shell profile found for auto-shield; run `claude` via `solongate shield -- claude` manually.)");
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
for (const file of targets) {
|
|
168
199
|
try {
|
|
169
|
-
writeShimBlock(file,
|
|
170
|
-
|
|
200
|
+
writeShimBlock(file, block);
|
|
201
|
+
console.log(` Auto-shield on: \`claude\` now masks secrets (${file})`);
|
|
202
|
+
} catch (e) {
|
|
203
|
+
console.log(` (Could not enable auto-shield in ${file}: ${e.message})`);
|
|
171
204
|
}
|
|
172
205
|
}
|
|
206
|
+
console.log(" Open a NEW terminal for it to take effect.");
|
|
173
207
|
}
|
|
174
208
|
async function runGlobalInstall(opts = {}) {
|
|
175
209
|
const p = globalPaths();
|
|
@@ -197,7 +231,7 @@ async function runGlobalInstall(opts = {}) {
|
|
|
197
231
|
writeFileSync(join(p.hooksDir, "stop.mjs"), readHook("stop.mjs"));
|
|
198
232
|
writeFileSync(join(p.hooksDir, "shield.mjs"), readHook("shield.mjs"));
|
|
199
233
|
console.log(` Installed hooks \u2192 ${p.hooksDir}`);
|
|
200
|
-
|
|
234
|
+
installClaudeShim(join(p.hooksDir, "shield.mjs"));
|
|
201
235
|
writeFileSync(p.configPath, JSON.stringify({ apiKey, apiUrl }, null, 2) + "\n");
|
|
202
236
|
console.log(` Wrote ${p.configPath}`);
|
|
203
237
|
let existing = {};
|
package/hooks/audit.mjs
CHANGED
|
@@ -497,6 +497,10 @@ try { input += readFileSync(0, 'utf-8'); } catch {}
|
|
|
497
497
|
if (tr && typeof tr === 'object' && typeof tr.stdout === 'string') updated = { ...tr, stdout: out };
|
|
498
498
|
else if (tr && typeof tr === 'object' && typeof tr.content === 'string') updated = { ...tr, content: out };
|
|
499
499
|
else if (tr && typeof tr === 'object' && Array.isArray(tr.content)) updated = { ...tr, content: [{ type: 'text', text: out }] };
|
|
500
|
+
// Read / NotebookRead nest the file body at file.content. It's a STRUCTURED
|
|
501
|
+
// result, so a bare-string replacement is rejected ("PostToolUse:Read hook
|
|
502
|
+
// warning") and the raw secret leaks through — preserve the shape instead.
|
|
503
|
+
else if (tr && typeof tr === 'object' && tr.file && typeof tr.file.content === 'string') updated = { ...tr, file: { ...tr.file, content: out } };
|
|
500
504
|
else updated = out;
|
|
501
505
|
EMITTED_PAYLOAD = JSON.stringify({
|
|
502
506
|
hookSpecificOutput: { hookEventName: 'PostToolUse', updatedToolOutput: updated },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solongate/proxy",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.7",
|
|
4
4
|
"description": "AI tool security proxy: protect any AI tool server with customizable policies, path/command constraints, rate limiting, and audit logging. No code changes required.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|