opencode-studio-server 1.9.3 → 1.9.4
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 +18 -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) => {
|
|
@@ -1700,12 +1708,14 @@ app.delete('/api/auth/:provider', (req, res) => {
|
|
|
1700
1708
|
if (studio.activeProfiles) delete studio.activeProfiles[provider];
|
|
1701
1709
|
saveStudioConfig(studio);
|
|
1702
1710
|
|
|
1703
|
-
|
|
1704
|
-
|
|
1711
|
+
// Do NOT delete the profile directory on logout. Users want to keep saved profiles.
|
|
1712
|
+
// const providerDir = path.join(AUTH_PROFILES_DIR, provider);
|
|
1713
|
+
// if (fs.existsSync(providerDir)) fs.rmSync(providerDir, { recursive: true, force: true });
|
|
1705
1714
|
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1715
|
+
// Do NOT delete metadata either, as it tracks profile stats.
|
|
1716
|
+
// const metadata = loadPoolMetadata();
|
|
1717
|
+
// delete metadata[provider];
|
|
1718
|
+
// savePoolMetadata(metadata);
|
|
1709
1719
|
}
|
|
1710
1720
|
|
|
1711
1721
|
if (provider === 'google' && activePlugin) {
|
|
@@ -2571,6 +2581,8 @@ app.post('/api/auth/google/start', async (req, res) => {
|
|
|
2571
2581
|
if (!fs.existsSync(profileDir)) fs.mkdirSync(profileDir, { recursive: true });
|
|
2572
2582
|
const profileName = email || `google-${Date.now()}`;
|
|
2573
2583
|
const profilePath = path.join(profileDir, `${profileName}.json`);
|
|
2584
|
+
|
|
2585
|
+
console.log(`[Auth] Saving profile to: ${profilePath}`);
|
|
2574
2586
|
atomicWriteFileSync(profilePath, JSON.stringify(credentials, null, 2));
|
|
2575
2587
|
|
|
2576
2588
|
const metadata = loadPoolMetadata();
|