@imweapp/openclaw-imwe 2026.4.12-alpha.2 → 2026.4.12-alpha.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/README.md +36 -20
- package/openclaw.plugin.json +1 -47
- package/package.json +3 -3
- package/src/accounts.ts +28 -7
- package/src/config-schema.ts +3 -2
- package/src/secret-input.ts +6 -0
- package/src/types.ts +6 -4
package/README.md
CHANGED
|
@@ -7,17 +7,21 @@ imwe 即时通讯渠道插件,AppKey/AppSecret HMAC-SHA256 签名认证,支
|
|
|
7
7
|
|
|
8
8
|
### 单账号
|
|
9
9
|
|
|
10
|
+
凭证写在 `accounts.default` 内,共享配置(`dmPolicy`、`allowFrom`)放在顶层作为默认值。`apiBaseUrl` 可省略,默认使用 `https://im-pre.imweapi.com`。
|
|
11
|
+
|
|
10
12
|
```json
|
|
11
13
|
{
|
|
12
14
|
"channels": {
|
|
13
15
|
"imwe": {
|
|
14
|
-
"
|
|
15
|
-
"appKey": "your-app-key",
|
|
16
|
-
"appSecret": "your-app-secret",
|
|
16
|
+
"defaultAccount": "default",
|
|
17
17
|
"dmPolicy": "open",
|
|
18
|
-
"allowFrom": [
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
"allowFrom": ["*"],
|
|
19
|
+
"accounts": {
|
|
20
|
+
"default": {
|
|
21
|
+
"appKey": "your-app-key",
|
|
22
|
+
"appSecret": "your-app-secret"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
27
|
}
|
|
@@ -25,30 +29,42 @@ imwe 即时通讯渠道插件,AppKey/AppSecret HMAC-SHA256 签名认证,支
|
|
|
25
29
|
|
|
26
30
|
### 多账号
|
|
27
31
|
|
|
32
|
+
顶层写共享默认值,每个账号只写凭证。
|
|
33
|
+
|
|
28
34
|
```json
|
|
29
35
|
{
|
|
30
36
|
"channels": {
|
|
31
37
|
"imwe": {
|
|
32
|
-
"apiBaseUrl": "https://api.imwe.example.com",
|
|
33
38
|
"defaultAccount": "default",
|
|
39
|
+
"dmPolicy": "open",
|
|
40
|
+
"allowFrom": ["*"],
|
|
34
41
|
"accounts": {
|
|
35
42
|
"default": {
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"appSecret": "your-app-secret",
|
|
39
|
-
"dmPolicy": "open",
|
|
40
|
-
"allowFrom": [
|
|
41
|
-
"*"
|
|
42
|
-
],
|
|
43
|
+
"appKey": "app-key-1",
|
|
44
|
+
"appSecret": "app-secret-1"
|
|
43
45
|
},
|
|
44
46
|
"bot2": {
|
|
45
|
-
"
|
|
47
|
+
"appKey": "app-key-2",
|
|
48
|
+
"appSecret": "app-secret-2"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 使用 SecretRef 引用环境变量
|
|
57
|
+
|
|
58
|
+
凭证字段支持 SecretRef 对象,通过 `{ source: 'env', provider: 'default', id: '...' }` 引用环境变量:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"channels": {
|
|
63
|
+
"imwe": {
|
|
64
|
+
"accounts": {
|
|
65
|
+
"default": {
|
|
46
66
|
"appKey": "your-app-key",
|
|
47
|
-
"appSecret": "
|
|
48
|
-
"dmPolicy": "open",
|
|
49
|
-
"allowFrom": [
|
|
50
|
-
"*"
|
|
51
|
-
],
|
|
67
|
+
"appSecret": { "source": "env", "provider": "default", "id": "IMWE_APP_SECRET" }
|
|
52
68
|
}
|
|
53
69
|
}
|
|
54
70
|
}
|
package/openclaw.plugin.json
CHANGED
|
@@ -7,52 +7,6 @@
|
|
|
7
7
|
"configSchema": {
|
|
8
8
|
"type": "object",
|
|
9
9
|
"additionalProperties": false,
|
|
10
|
-
"properties": {
|
|
11
|
-
"accounts": {
|
|
12
|
-
"type": "object",
|
|
13
|
-
"description": "多账号配置,key 为 accountId",
|
|
14
|
-
"additionalProperties": {
|
|
15
|
-
"type": "object",
|
|
16
|
-
"additionalProperties": false,
|
|
17
|
-
"properties": {
|
|
18
|
-
"name": { "type": "string" },
|
|
19
|
-
"enabled": { "type": "boolean" },
|
|
20
|
-
"apiBaseUrl": { "type": "string" },
|
|
21
|
-
"appKey": { "type": "string" },
|
|
22
|
-
"appSecret": { "type": "string" },
|
|
23
|
-
"dmPolicy": {
|
|
24
|
-
"type": "string",
|
|
25
|
-
"enum": ["pairing", "allowlist", "open", "disabled"]
|
|
26
|
-
},
|
|
27
|
-
"allowFrom": {
|
|
28
|
-
"type": "array",
|
|
29
|
-
"items": { "type": ["string", "number"] }
|
|
30
|
-
},
|
|
31
|
-
"pollIntervalMs": {
|
|
32
|
-
"type": "number",
|
|
33
|
-
"description": "短轮询间隔(毫秒),默认 3000"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"defaultAccount": { "type": "string" },
|
|
39
|
-
"name": { "type": "string" },
|
|
40
|
-
"enabled": { "type": "boolean" },
|
|
41
|
-
"apiBaseUrl": { "type": "string" },
|
|
42
|
-
"appKey": { "type": "string" },
|
|
43
|
-
"appSecret": { "type": "string" },
|
|
44
|
-
"dmPolicy": {
|
|
45
|
-
"type": "string",
|
|
46
|
-
"enum": ["pairing", "allowlist", "open", "disabled"]
|
|
47
|
-
},
|
|
48
|
-
"allowFrom": {
|
|
49
|
-
"type": "array",
|
|
50
|
-
"items": { "type": ["string", "number"] }
|
|
51
|
-
},
|
|
52
|
-
"pollIntervalMs": {
|
|
53
|
-
"type": "number",
|
|
54
|
-
"description": "短轮询间隔(毫秒),默认 3000"
|
|
55
|
-
}
|
|
56
|
-
}
|
|
10
|
+
"properties": {}
|
|
57
11
|
}
|
|
58
12
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imweapp/openclaw-imwe",
|
|
3
|
-
"version": "2026.4.12-alpha.
|
|
3
|
+
"version": "2026.4.12-alpha.3",
|
|
4
4
|
"description": "OpenClaw imwe 渠道插件 —— AppKey/AppSecret 签名认证,支持多账号、私聊文字消息",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"quickstartAllowFrom": true
|
|
62
62
|
},
|
|
63
63
|
"install": {
|
|
64
|
-
"npmSpec": "@
|
|
64
|
+
"npmSpec": "@imweapp/opencalw-imwe",
|
|
65
65
|
"defaultChoice": "npm",
|
|
66
66
|
"minHostVersion": ">=2026.4.11"
|
|
67
67
|
},
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"pluginApi": ">=2026.4.11"
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "3815a36581e83ca8f98a95d1229b069233c98897"
|
|
73
73
|
}
|
package/src/accounts.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from 'openclaw/plugin-sdk/account-helpers';
|
|
15
15
|
import { normalizeAccountId } from 'openclaw/plugin-sdk/account-id';
|
|
16
16
|
import type { OpenClawConfig } from 'openclaw/plugin-sdk/config-runtime';
|
|
17
|
+
import { coerceSecretRef } from 'openclaw/plugin-sdk/provider-auth';
|
|
17
18
|
import type { ImweAccountConfig, ImweConfig, ResolvedImweAccount } from './types.js';
|
|
18
19
|
|
|
19
20
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -40,6 +41,28 @@ function mergeImweAccountConfig(cfg: OpenClawConfig, accountId: string): ImweAcc
|
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
45
|
+
// SecretRef 解析 helper
|
|
46
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
47
|
+
|
|
48
|
+
/** 将纯字符串或 SecretRef 对象解析为字符串值。env 类型 ref 从 process.env 读取。 */
|
|
49
|
+
function resolveSecretLike(value: unknown): string | undefined {
|
|
50
|
+
if (value != null && typeof value === 'string') {
|
|
51
|
+
const trimmed = value.trim();
|
|
52
|
+
if (trimmed) return trimmed;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const ref = coerceSecretRef(value);
|
|
56
|
+
if (!ref) return undefined;
|
|
57
|
+
|
|
58
|
+
// env 类型 SecretRef 从 process.env 读取
|
|
59
|
+
if (ref.source === 'env') {
|
|
60
|
+
return process.env[ref.id]?.trim() || undefined;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
43
66
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
44
67
|
// 凭证解析:优先级 账号级 config > 顶层 config > 环境变量
|
|
45
68
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -48,13 +71,11 @@ function resolveImweCredentials(
|
|
|
48
71
|
merged: ImweAccountConfig,
|
|
49
72
|
accountId: string,
|
|
50
73
|
): { appKey: string; appSecret: string; source: ResolvedImweAccount['credentialSource'] } {
|
|
51
|
-
// 1. config 里的 appKey + appSecret
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
source: 'config',
|
|
57
|
-
};
|
|
74
|
+
// 1. config 里的 appKey + appSecret(支持 SecretRef)
|
|
75
|
+
const configKey = resolveSecretLike(merged.appKey);
|
|
76
|
+
const configSecret = resolveSecretLike(merged.appSecret);
|
|
77
|
+
if (configKey && configSecret) {
|
|
78
|
+
return { appKey: configKey, appSecret: configSecret, source: 'config' };
|
|
58
79
|
}
|
|
59
80
|
|
|
60
81
|
// 2. 环境变量(仅 default 账号,避免多账号混用同一组 env)
|
package/src/config-schema.ts
CHANGED
|
@@ -10,13 +10,14 @@ import {
|
|
|
10
10
|
DmPolicySchema,
|
|
11
11
|
} from 'openclaw/plugin-sdk/channel-config-schema';
|
|
12
12
|
import { z } from 'openclaw/plugin-sdk/zod';
|
|
13
|
+
import { buildSecretInputSchema } from './secret-input.js';
|
|
13
14
|
|
|
14
15
|
const imweAccountSchema = z.object({
|
|
15
16
|
name: z.string().optional(),
|
|
16
17
|
enabled: z.boolean().optional(),
|
|
17
18
|
apiBaseUrl: z.string().optional(),
|
|
18
|
-
appKey:
|
|
19
|
-
appSecret:
|
|
19
|
+
appKey: buildSecretInputSchema().optional(),
|
|
20
|
+
appSecret: buildSecretInputSchema().optional(),
|
|
20
21
|
dmPolicy: DmPolicySchema.optional(),
|
|
21
22
|
allowFrom: AllowFromListSchema,
|
|
22
23
|
/** 短轮询间隔(毫秒),默认 3000 */
|
package/src/types.ts
CHANGED
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
* 无需 token、无需登录流程、无需持久化任何凭证。
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
import type { SecretInput } from 'openclaw/plugin-sdk/secret-input';
|
|
16
|
+
|
|
15
17
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
16
18
|
// 第一层:原始配置(对应 openclaw.json 里用户写的内容)
|
|
17
19
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -25,14 +27,14 @@ export type ImweAccountConfig = {
|
|
|
25
27
|
apiBaseUrl?: string;
|
|
26
28
|
/**
|
|
27
29
|
* 应用 Key,由 imwe 开放平台颁发,用于标识调用方身份。
|
|
28
|
-
*
|
|
30
|
+
* 支持纯字符串或 SecretRef 对象(如 { source: 'env', provider: 'default', id: 'IMWE_APP_KEY' })。
|
|
29
31
|
*/
|
|
30
|
-
appKey?: string;
|
|
32
|
+
appKey?: string | SecretInput;
|
|
31
33
|
/**
|
|
32
34
|
* 应用 Secret,与 AppKey 配对,用于 HMAC-SHA256 签名。
|
|
33
|
-
*
|
|
35
|
+
* 支持纯字符串或 SecretRef 对象(如 { source: 'env', provider: 'default', id: 'IMWE_APP_SECRET' })。
|
|
34
36
|
*/
|
|
35
|
-
appSecret?: string;
|
|
37
|
+
appSecret?: string | SecretInput;
|
|
36
38
|
/** DM 安全策略:pairing(配对审批)| allowlist | open | disabled */
|
|
37
39
|
dmPolicy?: 'pairing' | 'allowlist' | 'open' | 'disabled';
|
|
38
40
|
/** DM 发送者白名单(imwe userId 列表) */
|