@mediagraph/mcp 1.0.5 → 1.0.6
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/index.js +20 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -329,26 +329,38 @@ var TokenStore = class {
|
|
|
329
329
|
* Save tokens to encrypted file
|
|
330
330
|
*/
|
|
331
331
|
save(data) {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
332
|
+
try {
|
|
333
|
+
const dir = dirname(this.filePath);
|
|
334
|
+
console.error(`[TokenStore] Saving tokens to: ${this.filePath}`);
|
|
335
|
+
if (!existsSync(dir)) {
|
|
336
|
+
console.error(`[TokenStore] Creating directory: ${dir}`);
|
|
337
|
+
mkdirSync(dir, { recursive: true, mode: 448 });
|
|
338
|
+
}
|
|
339
|
+
const encrypted = this.encrypt(JSON.stringify(data));
|
|
340
|
+
writeFileSync(this.filePath, encrypted, { mode: 384 });
|
|
341
|
+
console.error(`[TokenStore] Tokens saved successfully`);
|
|
342
|
+
} catch (error) {
|
|
343
|
+
console.error(`[TokenStore] Failed to save tokens:`, error);
|
|
344
|
+
throw error;
|
|
335
345
|
}
|
|
336
|
-
const encrypted = this.encrypt(JSON.stringify(data));
|
|
337
|
-
writeFileSync(this.filePath, encrypted, { mode: 384 });
|
|
338
346
|
}
|
|
339
347
|
/**
|
|
340
348
|
* Load tokens from encrypted file
|
|
341
349
|
*/
|
|
342
350
|
load() {
|
|
351
|
+
console.error(`[TokenStore] Loading tokens from: ${this.filePath}`);
|
|
343
352
|
if (!existsSync(this.filePath)) {
|
|
353
|
+
console.error(`[TokenStore] Token file does not exist`);
|
|
344
354
|
return null;
|
|
345
355
|
}
|
|
346
356
|
try {
|
|
347
357
|
const encrypted = readFileSync(this.filePath);
|
|
348
358
|
const decrypted = this.decrypt(encrypted);
|
|
349
|
-
|
|
359
|
+
const data = JSON.parse(decrypted);
|
|
360
|
+
console.error(`[TokenStore] Tokens loaded for: ${data.userEmail || "unknown"}`);
|
|
361
|
+
return data;
|
|
350
362
|
} catch (error) {
|
|
351
|
-
console.error("Failed to load tokens:", error);
|
|
363
|
+
console.error("[TokenStore] Failed to load tokens:", error);
|
|
352
364
|
return null;
|
|
353
365
|
}
|
|
354
366
|
}
|
|
@@ -3308,14 +3320,7 @@ server.setRequestHandler(ListResourceTemplatesRequestSchema, async () => {
|
|
|
3308
3320
|
};
|
|
3309
3321
|
});
|
|
3310
3322
|
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
3311
|
-
|
|
3312
|
-
if (!token) {
|
|
3313
|
-
const authSuccess = await runAutoAuth();
|
|
3314
|
-
if (!authSuccess) {
|
|
3315
|
-
return { resources: [] };
|
|
3316
|
-
}
|
|
3317
|
-
token = await getAccessToken();
|
|
3318
|
-
}
|
|
3323
|
+
const token = await getAccessToken();
|
|
3319
3324
|
if (!token) {
|
|
3320
3325
|
return { resources: [] };
|
|
3321
3326
|
}
|