feishu-mcp 0.3.1 → 0.3.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/dist/cli/commands/auth.js +12 -4
- package/package.json +1 -1
|
@@ -3,6 +3,8 @@ import { createServer as createNetServer } from 'net';
|
|
|
3
3
|
import express from 'express';
|
|
4
4
|
import { Config } from '../../utils/config.js';
|
|
5
5
|
import { AuthUtils, TokenCacheManager } from '../../utils/auth/index.js';
|
|
6
|
+
import { getRequiredScopes } from '../../services/constants/feishuScopes.js';
|
|
7
|
+
import { ModuleRegistry } from '../../modules/index.js';
|
|
6
8
|
// callbackService 需延迟导入,避免其模块级 Config.getInstance() 在 CLI 启动时提前触发 yargs
|
|
7
9
|
const AUTH_TIMEOUT_MS = 5 * 60 * 1000; // 5 分钟
|
|
8
10
|
const POLL_INTERVAL_MS = 1000;
|
|
@@ -87,13 +89,19 @@ export async function handleAuthRequired(userKey) {
|
|
|
87
89
|
// 1. 寻找可用端口(从配置端口开始)
|
|
88
90
|
const port = await findAvailablePort(config.server.port);
|
|
89
91
|
const redirectUri = `http://localhost:${port}/callback`;
|
|
90
|
-
// 2. 计算 clientKey 和 state
|
|
92
|
+
// 2. 计算 clientKey、scope 和 state
|
|
91
93
|
const clientKey = AuthUtils.generateClientKey(userKey);
|
|
94
|
+
const authType = config.feishu.authType;
|
|
95
|
+
const enabledIds = config.features.enabledModules;
|
|
96
|
+
const effectiveModules = ModuleRegistry.getEnabledModules(enabledIds, authType).map(m => m.id);
|
|
97
|
+
const scopeList = getRequiredScopes(effectiveModules, authType);
|
|
98
|
+
const scope = encodeURIComponent(scopeList.join(' '));
|
|
92
99
|
const state = AuthUtils.encodeState(appId, appSecret, clientKey, redirectUri);
|
|
93
|
-
// 3. 构造飞书 OAuth 授权 URL
|
|
94
|
-
const authUrl = `https://
|
|
95
|
-
`?
|
|
100
|
+
// 3. 构造飞书 OAuth 授权 URL(与 baseService.generateUserAuthUrl 保持一致)
|
|
101
|
+
const authUrl = `https://accounts.feishu.cn/open-apis/authen/v1/authorize` +
|
|
102
|
+
`?client_id=${encodeURIComponent(appId)}` +
|
|
96
103
|
`&redirect_uri=${encodeURIComponent(redirectUri)}` +
|
|
104
|
+
`&scope=${scope}` +
|
|
97
105
|
`&state=${encodeURIComponent(state)}`;
|
|
98
106
|
// 4. 启动临时 callback 服务器
|
|
99
107
|
let server;
|