thevoidforge 21.0.14 → 21.0.15
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { request as httpsRequest } from 'node:https';
|
|
2
2
|
import { addRoute } from '../router.js';
|
|
3
|
-
import { vaultSet, vaultExists, vaultUnlock, vaultKeys, vaultPath, vaultLock } from '../lib/vault.js';
|
|
3
|
+
import { vaultSet, vaultGet, vaultExists, vaultUnlock, vaultKeys, vaultPath, vaultLock } from '../lib/vault.js';
|
|
4
4
|
import { parseJsonBody } from '../lib/body-parser.js';
|
|
5
5
|
import { clearModelCache } from '../lib/anthropic.js';
|
|
6
6
|
import { sendJson } from '../lib/http-helpers.js';
|
|
@@ -183,11 +183,16 @@ addRoute('POST', '/api/credentials/unlock', async (req, res) => {
|
|
|
183
183
|
clearVaultFailures(ip);
|
|
184
184
|
sessionPassword = body.password;
|
|
185
185
|
touchVaultAccess(); // SEC-R2-004: Start auto-lock timer
|
|
186
|
-
// Check what's already stored
|
|
186
|
+
// Check what's already stored + load API key into process.env for PTY sessions
|
|
187
187
|
let hasAnthropic = false;
|
|
188
188
|
try {
|
|
189
189
|
const keys = await vaultKeys(sessionPassword);
|
|
190
190
|
hasAnthropic = keys.includes('anthropic-api-key');
|
|
191
|
+
if (hasAnthropic) {
|
|
192
|
+
const storedKey = await vaultGet(sessionPassword, 'anthropic-api-key');
|
|
193
|
+
if (storedKey)
|
|
194
|
+
process.env['ANTHROPIC_API_KEY'] = storedKey;
|
|
195
|
+
}
|
|
191
196
|
}
|
|
192
197
|
catch {
|
|
193
198
|
// Fresh vault
|
|
@@ -220,6 +225,8 @@ addRoute('POST', '/api/credentials/anthropic', async (req, res) => {
|
|
|
220
225
|
return;
|
|
221
226
|
}
|
|
222
227
|
await vaultSet(sessionPassword, 'anthropic-api-key', apiKey);
|
|
228
|
+
// Make the key available to PTY sessions spawned by this server process
|
|
229
|
+
process.env['ANTHROPIC_API_KEY'] = apiKey;
|
|
223
230
|
clearModelCache();
|
|
224
231
|
sendJson(res, 200, { stored: true });
|
|
225
232
|
});
|