feishu-openclaw 0.4.1 → 0.4.3
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/clawdbot.plugin.json +1 -1
- package/dist/src/probe.d.ts +4 -2
- package/dist/src/probe.d.ts.map +1 -1
- package/dist/src/probe.js +35 -18
- package/dist/src/probe.js.map +1 -1
- package/package.json +1 -1
package/clawdbot.plugin.json
CHANGED
package/dist/src/probe.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Feishu API connectivity probe.
|
|
3
|
+
*
|
|
4
|
+
* Validates credentials by fetching a tenant_access_token.
|
|
3
5
|
*/
|
|
4
6
|
import type { FeishuProbeResult } from "./types.js";
|
|
5
7
|
/**
|
|
6
|
-
* Probe the Feishu API by fetching
|
|
7
|
-
*
|
|
8
|
+
* Probe the Feishu API by fetching tenant_access_token.
|
|
9
|
+
* This is the standard way to validate appId + appSecret.
|
|
8
10
|
*/
|
|
9
11
|
export declare function probeFeishu(appId: string, appSecret: string, timeoutMs?: number): Promise<FeishuProbeResult>;
|
|
10
12
|
//# sourceMappingURL=probe.d.ts.map
|
package/dist/src/probe.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probe.d.ts","sourceRoot":"","sources":["../../src/probe.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"probe.d.ts","sourceRoot":"","sources":["../../src/probe.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,SAAS,SAAO,GACf,OAAO,CAAC,iBAAiB,CAAC,CAsE5B"}
|
package/dist/src/probe.js
CHANGED
|
@@ -1,40 +1,57 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Feishu API connectivity probe.
|
|
3
|
+
*
|
|
4
|
+
* Validates credentials by fetching a tenant_access_token.
|
|
3
5
|
*/
|
|
4
|
-
import * as Lark from "@larksuiteoapi/node-sdk";
|
|
5
6
|
/**
|
|
6
|
-
* Probe the Feishu API by fetching
|
|
7
|
-
*
|
|
7
|
+
* Probe the Feishu API by fetching tenant_access_token.
|
|
8
|
+
* This is the standard way to validate appId + appSecret.
|
|
8
9
|
*/
|
|
9
10
|
export async function probeFeishu(appId, appSecret, timeoutMs = 5000) {
|
|
10
11
|
if (!appId?.trim() || !appSecret?.trim()) {
|
|
11
12
|
return { ok: false, error: "Missing appId or appSecret", elapsedMs: 0 };
|
|
12
13
|
}
|
|
13
14
|
const startTime = Date.now();
|
|
15
|
+
const controller = new AbortController();
|
|
16
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
14
17
|
try {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
// Use the internal tenant_access_token endpoint to validate credentials
|
|
19
|
+
const response = await fetch("https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal", {
|
|
20
|
+
method: "POST",
|
|
21
|
+
headers: { "Content-Type": "application/json" },
|
|
22
|
+
body: JSON.stringify({
|
|
23
|
+
app_id: appId.trim(),
|
|
24
|
+
app_secret: appSecret.trim(),
|
|
25
|
+
}),
|
|
26
|
+
signal: controller.signal,
|
|
20
27
|
});
|
|
21
|
-
|
|
22
|
-
const response = await client.bot.v3.botInfo.get({});
|
|
28
|
+
clearTimeout(timeout);
|
|
23
29
|
const elapsedMs = Date.now() - startTime;
|
|
24
|
-
|
|
25
|
-
if (bot) {
|
|
30
|
+
if (!response.ok) {
|
|
26
31
|
return {
|
|
27
|
-
ok:
|
|
28
|
-
|
|
29
|
-
name: bot.bot_name,
|
|
30
|
-
openId: bot.open_id,
|
|
31
|
-
},
|
|
32
|
+
ok: false,
|
|
33
|
+
error: `HTTP ${response.status}: ${response.statusText}`,
|
|
32
34
|
elapsedMs,
|
|
33
35
|
};
|
|
34
36
|
}
|
|
35
|
-
|
|
37
|
+
const data = (await response.json());
|
|
38
|
+
if (data.code !== 0) {
|
|
39
|
+
return {
|
|
40
|
+
ok: false,
|
|
41
|
+
error: data.msg || `API error code: ${data.code}`,
|
|
42
|
+
elapsedMs,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
// Credentials are valid if we got a token
|
|
46
|
+
return {
|
|
47
|
+
ok: true,
|
|
48
|
+
elapsedMs,
|
|
49
|
+
// Note: We don't have bot info from this endpoint,
|
|
50
|
+
// but credentials are verified
|
|
51
|
+
};
|
|
36
52
|
}
|
|
37
53
|
catch (err) {
|
|
54
|
+
clearTimeout(timeout);
|
|
38
55
|
const elapsedMs = Date.now() - startTime;
|
|
39
56
|
if (err instanceof Error) {
|
|
40
57
|
if (err.name === "AbortError") {
|
package/dist/src/probe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probe.js","sourceRoot":"","sources":["../../src/probe.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"probe.js","sourceRoot":"","sources":["../../src/probe.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,KAAa,EACb,SAAiB,EACjB,SAAS,GAAG,IAAI;IAEhB,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;QACzC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,4BAA4B,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IAC1E,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAA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