chaimi-keep-mcp 3.3.0-beta.1 → 3.3.0-beta.2
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/oauth.js +15 -1
- package/package.json +1 -1
package/oauth.js
CHANGED
|
@@ -431,6 +431,10 @@ class FileTokenStorage extends TokenStorage {
|
|
|
431
431
|
const dir = this.path.dirname(this.filePath);
|
|
432
432
|
await this.fs.mkdir(dir, { recursive: true });
|
|
433
433
|
|
|
434
|
+
console.error('🔍 [DEBUG] 开始保存 Token');
|
|
435
|
+
console.error('🔍 [DEBUG] 加密密钥 (前8位):', this.key.substring(0, 8));
|
|
436
|
+
console.error('🔍 [DEBUG] Token 过期时间:', token.expiresAt);
|
|
437
|
+
|
|
434
438
|
// 加密 Token 后保存
|
|
435
439
|
const encrypted = encryptToken(token, this.key);
|
|
436
440
|
const data = {
|
|
@@ -445,6 +449,7 @@ class FileTokenStorage extends TokenStorage {
|
|
|
445
449
|
JSON.stringify(data, null, 2),
|
|
446
450
|
{ mode: 0o600 }
|
|
447
451
|
);
|
|
452
|
+
console.error('🔍 [DEBUG] Token 保存成功:', this.filePath);
|
|
448
453
|
}
|
|
449
454
|
|
|
450
455
|
async load() {
|
|
@@ -452,6 +457,10 @@ class FileTokenStorage extends TokenStorage {
|
|
|
452
457
|
const data = await this.fs.readFile(this.filePath, 'utf8');
|
|
453
458
|
const parsed = JSON.parse(data);
|
|
454
459
|
|
|
460
|
+
console.error('🔍 [DEBUG] 开始加载 Token 文件');
|
|
461
|
+
console.error('🔍 [DEBUG] 文件版本:', parsed.version);
|
|
462
|
+
console.error('🔍 [DEBUG] 加密密钥 (前8位):', this.key.substring(0, 8));
|
|
463
|
+
|
|
455
464
|
// 向后兼容:检测旧版明文格式
|
|
456
465
|
if (!parsed.version || parsed.version === '1.0') {
|
|
457
466
|
console.error('检测到旧版 Token 格式,自动升级...');
|
|
@@ -466,11 +475,16 @@ class FileTokenStorage extends TokenStorage {
|
|
|
466
475
|
}
|
|
467
476
|
|
|
468
477
|
// 新版加密格式,解密后返回
|
|
469
|
-
|
|
478
|
+
console.error('🔍 [DEBUG] 开始解密 Token...');
|
|
479
|
+
const decrypted = decryptToken(parsed.encrypted, this.key);
|
|
480
|
+
console.error('🔍 [DEBUG] 解密成功,Token 过期时间:', decrypted.expiresAt);
|
|
481
|
+
return decrypted;
|
|
470
482
|
} catch (err) {
|
|
471
483
|
if (err.code === 'ENOENT') {
|
|
484
|
+
console.error('🔍 [DEBUG] Token 文件不存在');
|
|
472
485
|
return null;
|
|
473
486
|
}
|
|
487
|
+
console.error('🔍 [DEBUG] 加载 Token 失败:', err.message);
|
|
474
488
|
throw err;
|
|
475
489
|
}
|
|
476
490
|
}
|