@starfysh/gdrive-mcp 1.0.0 → 1.0.1
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/auth.js +24 -7
- package/package.json +1 -1
package/dist/auth.js
CHANGED
|
@@ -4,13 +4,30 @@ import { JWT } from 'google-auth-library'; // ADDED: Import for Service Account
|
|
|
4
4
|
import * as fs from 'fs/promises';
|
|
5
5
|
import * as path from 'path';
|
|
6
6
|
import * as readline from 'readline/promises';
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
import * as os from 'os';
|
|
8
|
+
import { existsSync } from 'fs';
|
|
9
|
+
// --- Calculate paths with fallback locations ---
|
|
10
|
+
const CONFIG_DIR = path.join(os.homedir(), '.config', 'gdrive-mcp');
|
|
11
|
+
function resolvePath(envVar, filename) {
|
|
12
|
+
// 1. Environment variable (explicit override)
|
|
13
|
+
if (process.env[envVar]) {
|
|
14
|
+
return process.env[envVar];
|
|
15
|
+
}
|
|
16
|
+
// 2. Current working directory
|
|
17
|
+
const cwdPath = path.join(process.cwd(), filename);
|
|
18
|
+
if (existsSync(cwdPath)) {
|
|
19
|
+
return cwdPath;
|
|
20
|
+
}
|
|
21
|
+
// 3. User config directory (~/.config/gdrive-mcp/)
|
|
22
|
+
const configPath = path.join(CONFIG_DIR, filename);
|
|
23
|
+
if (existsSync(configPath)) {
|
|
24
|
+
return configPath;
|
|
25
|
+
}
|
|
26
|
+
// Default to cwd (will error at read time with helpful message)
|
|
27
|
+
return cwdPath;
|
|
28
|
+
}
|
|
29
|
+
const TOKEN_PATH = resolvePath('GDRIVE_MCP_TOKEN_PATH', 'token.json');
|
|
30
|
+
const CREDENTIALS_PATH = resolvePath('GDRIVE_MCP_CREDENTIALS_PATH', 'credentials.json');
|
|
14
31
|
// --- End of path calculation ---
|
|
15
32
|
const SCOPES = [
|
|
16
33
|
'https://www.googleapis.com/auth/documents',
|