opencode-studio-server 1.9.3 → 1.9.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.
- package/index.js +63 -6
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1310,6 +1310,10 @@ const getProfileDir = (provider, activePlugin) => {
|
|
|
1310
1310
|
const plainDir = path.join(AUTH_PROFILES_DIR, 'google');
|
|
1311
1311
|
const nsHas = fs.existsSync(nsDir) && fs.readdirSync(nsDir).filter(f => f.endsWith('.json')).length > 0;
|
|
1312
1312
|
const plainHas = fs.existsSync(plainDir) && fs.readdirSync(plainDir).filter(f => f.endsWith('.json')).length > 0;
|
|
1313
|
+
|
|
1314
|
+
// Debug
|
|
1315
|
+
console.log(`[Auth] getProfileDir: ns=${ns}, nsHas=${nsHas}, plainHas=${plainHas}`);
|
|
1316
|
+
|
|
1313
1317
|
if (!nsHas && plainHas) return plainDir;
|
|
1314
1318
|
}
|
|
1315
1319
|
return path.join(AUTH_PROFILES_DIR, ns);
|
|
@@ -1318,7 +1322,11 @@ const getProfileDir = (provider, activePlugin) => {
|
|
|
1318
1322
|
const listAuthProfiles = (p, activePlugin) => {
|
|
1319
1323
|
const d = getProfileDir(p, activePlugin);
|
|
1320
1324
|
if (!fs.existsSync(d)) return [];
|
|
1321
|
-
try {
|
|
1325
|
+
try {
|
|
1326
|
+
const files = fs.readdirSync(d).filter(f => f.endsWith('.json'));
|
|
1327
|
+
console.log(`[Auth] listAuthProfiles(${p}): dir=${d}, count=${files.length}`);
|
|
1328
|
+
return files.map(f => f.replace('.json', ''));
|
|
1329
|
+
} catch { return []; }
|
|
1322
1330
|
};
|
|
1323
1331
|
|
|
1324
1332
|
app.get('/api/auth/providers', (req, res) => {
|
|
@@ -1511,6 +1519,51 @@ app.post('/api/auth/profiles/:provider/:name/activate', (req, res) => {
|
|
|
1511
1519
|
res.json({ success: true });
|
|
1512
1520
|
});
|
|
1513
1521
|
|
|
1522
|
+
// IMPORTANT: This route must be BEFORE /:provider/:name to avoid 'all' being captured as :name
|
|
1523
|
+
app.delete('/api/auth/profiles/:provider/all', (req, res) => {
|
|
1524
|
+
const { provider } = req.params;
|
|
1525
|
+
console.log(`[Auth] Deleting ALL profiles for: ${provider}`);
|
|
1526
|
+
const activePlugin = getActiveGooglePlugin();
|
|
1527
|
+
const namespace = provider === 'google'
|
|
1528
|
+
? (activePlugin === 'antigravity' ? 'google.antigravity' : 'google.gemini')
|
|
1529
|
+
: provider;
|
|
1530
|
+
|
|
1531
|
+
const dir = getProfileDir(provider, activePlugin);
|
|
1532
|
+
|
|
1533
|
+
if (fs.existsSync(dir)) {
|
|
1534
|
+
const files = fs.readdirSync(dir).filter(f => f.endsWith('.json'));
|
|
1535
|
+
files.forEach(f => fs.unlinkSync(path.join(dir, f)));
|
|
1536
|
+
console.log(`[Auth] Deleted ${files.length} profiles from ${dir}`);
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
const studio = loadStudioConfig();
|
|
1540
|
+
if (studio.activeProfiles && studio.activeProfiles[provider]) {
|
|
1541
|
+
delete studio.activeProfiles[provider];
|
|
1542
|
+
saveStudioConfig(studio);
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
const authCfg = loadAuthConfig() || {};
|
|
1546
|
+
if (authCfg[provider]) {
|
|
1547
|
+
delete authCfg[provider];
|
|
1548
|
+
if (provider === 'google') {
|
|
1549
|
+
const key = activePlugin === 'antigravity' ? 'google.antigravity' : 'google.gemini';
|
|
1550
|
+
delete authCfg.google;
|
|
1551
|
+
delete authCfg[key];
|
|
1552
|
+
}
|
|
1553
|
+
const cp = getConfigPath();
|
|
1554
|
+
const ap = path.join(path.dirname(cp), 'auth.json');
|
|
1555
|
+
atomicWriteFileSync(ap, JSON.stringify(authCfg, null, 2));
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
const metadata = loadPoolMetadata();
|
|
1559
|
+
if (metadata[namespace]) {
|
|
1560
|
+
delete metadata[namespace];
|
|
1561
|
+
savePoolMetadata(metadata);
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
res.json({ success: true });
|
|
1565
|
+
});
|
|
1566
|
+
|
|
1514
1567
|
app.delete('/api/auth/profiles/:provider/:name', (req, res) => {
|
|
1515
1568
|
const { provider, name } = req.params;
|
|
1516
1569
|
console.log(`[Auth] Deleting profile: ${provider}/${name}`);
|
|
@@ -1700,12 +1753,14 @@ app.delete('/api/auth/:provider', (req, res) => {
|
|
|
1700
1753
|
if (studio.activeProfiles) delete studio.activeProfiles[provider];
|
|
1701
1754
|
saveStudioConfig(studio);
|
|
1702
1755
|
|
|
1703
|
-
|
|
1704
|
-
|
|
1756
|
+
// Do NOT delete the profile directory on logout. Users want to keep saved profiles.
|
|
1757
|
+
// const providerDir = path.join(AUTH_PROFILES_DIR, provider);
|
|
1758
|
+
// if (fs.existsSync(providerDir)) fs.rmSync(providerDir, { recursive: true, force: true });
|
|
1705
1759
|
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1760
|
+
// Do NOT delete metadata either, as it tracks profile stats.
|
|
1761
|
+
// const metadata = loadPoolMetadata();
|
|
1762
|
+
// delete metadata[provider];
|
|
1763
|
+
// savePoolMetadata(metadata);
|
|
1709
1764
|
}
|
|
1710
1765
|
|
|
1711
1766
|
if (provider === 'google' && activePlugin) {
|
|
@@ -2571,6 +2626,8 @@ app.post('/api/auth/google/start', async (req, res) => {
|
|
|
2571
2626
|
if (!fs.existsSync(profileDir)) fs.mkdirSync(profileDir, { recursive: true });
|
|
2572
2627
|
const profileName = email || `google-${Date.now()}`;
|
|
2573
2628
|
const profilePath = path.join(profileDir, `${profileName}.json`);
|
|
2629
|
+
|
|
2630
|
+
console.log(`[Auth] Saving profile to: ${profilePath}`);
|
|
2574
2631
|
atomicWriteFileSync(profilePath, JSON.stringify(credentials, null, 2));
|
|
2575
2632
|
|
|
2576
2633
|
const metadata = loadPoolMetadata();
|