@jiexiaoyin/wecom-api 0.0.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.
Files changed (58) hide show
  1. package/README.md +228 -0
  2. package/config.example.json +7 -0
  3. package/config.js +76 -0
  4. package/docs/approval-templates.example.json +11 -0
  5. package/docs/nginx-mirror.md +193 -0
  6. package/openclaw.plugin.json +15 -0
  7. package/package.json +34 -0
  8. package/plugin.cjs +172 -0
  9. package/plugin.ts +136 -0
  10. package/skills/wecom-api/SKILL.md +40 -0
  11. package/skills/wecom-api/index.js +288 -0
  12. package/skills/wecom-api/openclaw.plugin.json +10 -0
  13. package/src/callback-helper.js +198 -0
  14. package/src/config.cjs +286 -0
  15. package/src/core/permission.js +479 -0
  16. package/src/crypto.js +130 -0
  17. package/src/index.js +199 -0
  18. package/src/modules/addressbook/index.js +413 -0
  19. package/src/modules/addressbook_cache/index.js +365 -0
  20. package/src/modules/advanced/index.js +159 -0
  21. package/src/modules/app/index.js +102 -0
  22. package/src/modules/approval/index.js +146 -0
  23. package/src/modules/auth/index.js +103 -0
  24. package/src/modules/callback/index.js +1180 -0
  25. package/src/modules/chain/index.js +193 -0
  26. package/src/modules/checkin/index.js +142 -0
  27. package/src/modules/checkin_rules/index.js +251 -0
  28. package/src/modules/contact/index.js +481 -0
  29. package/src/modules/contact_stats/index.js +349 -0
  30. package/src/modules/custom/index.js +140 -0
  31. package/src/modules/customer/index.js +51 -0
  32. package/src/modules/disk/index.js +245 -0
  33. package/src/modules/document/index.js +282 -0
  34. package/src/modules/hr/index.js +93 -0
  35. package/src/modules/intelligence/index.js +346 -0
  36. package/src/modules/kf/index.js +74 -0
  37. package/src/modules/live/index.js +122 -0
  38. package/src/modules/media/index.js +183 -0
  39. package/src/modules/meeting/index.js +665 -0
  40. package/src/modules/message/index.js +402 -0
  41. package/src/modules/messenger/index.js +208 -0
  42. package/src/modules/moments/index.js +161 -0
  43. package/src/modules/msgaudit/index.js +24 -0
  44. package/src/modules/notify/index.js +81 -0
  45. package/src/modules/oceanengine/index.js +199 -0
  46. package/src/modules/openchat/index.js +197 -0
  47. package/src/modules/phone/index.js +45 -0
  48. package/src/modules/room/index.js +178 -0
  49. package/src/modules/schedule/index.js +246 -0
  50. package/src/modules/school/index.js +199 -0
  51. package/src/modules/security/index.js +223 -0
  52. package/src/modules/sensitive/index.js +170 -0
  53. package/src/modules/thirdparty/index.js +145 -0
  54. package/src/sdk/index.js +269 -0
  55. package/src/utils/callback-helper.js +198 -0
  56. package/test/callback-crypto.test.js +55 -0
  57. package/test/crypto.test.js +85 -0
  58. package/test/permission.test.js +115 -0
@@ -0,0 +1,223 @@
1
+ /**
2
+ * 安全管理模块
3
+ * API 章节:七 - 安全管理
4
+ * 包含:文件防泄漏、设备管理、截屏/录屏管理、高级功能账号管理、操作日志
5
+ */
6
+
7
+ const WeComSDK = require('../../sdk');
8
+
9
+ class Security extends WeComSDK {
10
+ constructor(config) {
11
+ super(config);
12
+ }
13
+
14
+ // ========== 文件防泄漏 ==========
15
+
16
+ /**
17
+ * 获取文件防泄漏规则列表
18
+ * @param {number} offset 偏移量
19
+ * @param {number} size 每页数量
20
+ */
21
+ async getDlpRules(offset = 0, size = 100) {
22
+ return this.post('/dlp/rules/list', { offset, limit: size });
23
+ }
24
+
25
+ /**
26
+ * 获取文件防泄漏规则详情
27
+ * @param {string} ruleId 规则 ID
28
+ */
29
+ async getDlpRuleDetail(ruleId) {
30
+ return this.post('/dlp/rules/get', { rule_id: ruleId });
31
+ }
32
+
33
+ /**
34
+ * 创建文件防泄漏规则
35
+ * @param {object} rule 规则配置
36
+ */
37
+ async createDlpRule(rule) {
38
+ return this.post('/dlp/rules/add', rule);
39
+ }
40
+
41
+ /**
42
+ * 更新文件防泄漏规则
43
+ * @param {string} ruleId 规则 ID
44
+ * @param {object} rule 规则配置
45
+ */
46
+ async updateDlpRule(ruleId, rule) {
47
+ return this.post('/dlp/rules/update', { rule_id: ruleId, ...rule });
48
+ }
49
+
50
+ /**
51
+ * 删除文件防泄漏规则
52
+ * @param {string} ruleId 规则 ID
53
+ */
54
+ async deleteDlpRule(ruleId) {
55
+ return this.post('/dlp/rules/del', { rule_id: ruleId });
56
+ }
57
+
58
+ // ========== 设备管理 ==========
59
+
60
+ /**
61
+ * 获取设备列表
62
+ * @param {string} deviceId 设备 ID
63
+ * @param {number} offset 偏移量
64
+ * @param {number} size 每页数量
65
+ */
66
+ async getDeviceList(deviceId = '', offset = 0, size = 100) {
67
+ return this.post('/device/list', {
68
+ device_id: deviceId,
69
+ offset,
70
+ limit: size
71
+ });
72
+ }
73
+
74
+ /**
75
+ * 获取设备详情
76
+ * @param {string} deviceId 设备 ID
77
+ */
78
+ async getDeviceDetail(deviceId) {
79
+ return this.post('/device/get', { device_id: deviceId });
80
+ }
81
+
82
+ /**
83
+ * 绑定设备
84
+ * @param {string} deviceId 设备 ID
85
+ * @param {string} userId 成员 ID
86
+ */
87
+ async bindDevice(deviceId, userId) {
88
+ return this.post('/device/bind', { device_id: deviceId, userid: userId });
89
+ }
90
+
91
+ /**
92
+ * 解绑设备
93
+ * @param {string} deviceId 设备 ID
94
+ */
95
+ async unbindDevice(deviceId) {
96
+ return this.post('/device/unbind', { device_id: deviceId });
97
+ }
98
+
99
+ /**
100
+ * 获取设备使用记录
101
+ * @param {string} deviceId 设备 ID
102
+ * @param {number} startTime 开始时间戳
103
+ * @param {number} endTime 结束时间戳
104
+ */
105
+ async getDeviceLog(deviceId, startTime, endTime) {
106
+ return this.post('/device/log', {
107
+ device_id: deviceId,
108
+ start_time: startTime,
109
+ end_time: endTime
110
+ });
111
+ }
112
+
113
+ // ========== 截屏/录屏管理 ==========
114
+
115
+ /**
116
+ * 获取截屏/录屏管理规则
117
+ */
118
+ async getScreenCaptureRule() {
119
+ return this.post('/device/screen_capture/get', {});
120
+ }
121
+
122
+ /**
123
+ * 设置截屏/录屏管理规则
124
+ * @param {number} status 状态: 0-关闭 1-开启
125
+ * @param {string} allowUsers 允许截屏的成员列表
126
+ * @param {string} denyUsers 禁止截屏的成员列表
127
+ */
128
+ async setScreenCaptureRule(status, allowUsers = '', denyUsers = '') {
129
+ return this.post('/device/screen_capture/set', {
130
+ status,
131
+ allow_users: allowUsers,
132
+ deny_users: denyUsers
133
+ });
134
+ }
135
+
136
+ // ========== 高级功能账号管理 ==========
137
+
138
+ /**
139
+ * 分配高级功能账号
140
+ * @param {string} userId 成员 ID
141
+ * @param {string} type 高级功能类型: exmail, wecom, file, yzp
142
+ */
143
+ async assignAdvancedAccount(userId, type) {
144
+ return this.post('/security/assign_advanced_account', {
145
+ userid: userId,
146
+ type
147
+ });
148
+ }
149
+
150
+ /**
151
+ * 取消高级功能账号
152
+ * @param {string} userId 成员 ID
153
+ * @param {string} type 高级功能类型
154
+ */
155
+ async cancelAdvancedAccount(userId, type) {
156
+ return this.post('/security/cancel_advanced_account', {
157
+ userid: userId,
158
+ type
159
+ });
160
+ }
161
+
162
+ /**
163
+ * 获取高级功能账号列表
164
+ * @param {string} type 高级功能类型
165
+ */
166
+ async getAdvancedAccountList(type) {
167
+ return this.post('/security/list_advanced_account', { type });
168
+ }
169
+
170
+ // ========== 操作日志 ==========
171
+
172
+ /**
173
+ * 获取成员操作记录
174
+ * @param {string} userId 成员 ID
175
+ * @param {number} startTime 开始时间戳
176
+ * @param {number} endTime 结束时间戳
177
+ * @param {number} offset 偏移量
178
+ * @param {number} size 每页数量
179
+ */
180
+ async getMemberOperationLog(userId, startTime, endTime, offset = 0, size = 100) {
181
+ return this.post('/security/get_member_operation_log', {
182
+ userid: userId,
183
+ start_time: startTime,
184
+ end_time: endTime,
185
+ offset,
186
+ limit: size
187
+ });
188
+ }
189
+
190
+ /**
191
+ * 获取管理端操作日志
192
+ * @param {number} startTime 开始时间戳
193
+ * @param {number} endTime 结束时间戳
194
+ * @param {string} operUserId 操作人 ID
195
+ * @param {number} offset 偏移量
196
+ * @param {number} size 每页数量
197
+ */
198
+ async getAdminOperationLog(startTime, endTime, operUserId = '', offset = 0, size = 100) {
199
+ return this.post('/security/get_admin_operation_log', {
200
+ start_time: startTime,
201
+ end_time: endTime,
202
+ oper_userid: operUserId,
203
+ offset,
204
+ limit: size
205
+ });
206
+ }
207
+
208
+ /**
209
+ * 获取企业微信域名 IP 信息
210
+ */
211
+ async getDomainIpList() {
212
+ return this.post('/security/get_domain_ip_list', {});
213
+ }
214
+
215
+ /**
216
+ * 获取回调 IP 段信息
217
+ */
218
+ async getCallbackIpList() {
219
+ return this.post('/security/get_callback_ip_list', {});
220
+ }
221
+ }
222
+
223
+ module.exports = Security;
@@ -0,0 +1,170 @@
1
+ /**
2
+ * 敏感词管理模块
3
+ * API 章节:十三 - 聊天敏感词
4
+ * 包含:敏感词管理、敏感行为管理
5
+ */
6
+
7
+ const WeComSDK = require('../../sdk');
8
+
9
+ class Sensitive extends WeComSDK {
10
+ constructor(config) {
11
+ super(config);
12
+ }
13
+
14
+ // ========== 敏感词管理 ==========
15
+
16
+ /**
17
+ * 获取敏感词列表
18
+ * @param {number} offset 偏移量
19
+ * @param {number} size 每页数量
20
+ */
21
+ async getSensitiveWordList(offset = 0, size = 100) {
22
+ return this.post('/externalcontact/get_sensitive_word_list', {
23
+ offset,
24
+ limit: size
25
+ });
26
+ }
27
+
28
+ /**
29
+ * 获取敏感词详情
30
+ * @param {string} wordId 敏感词 ID
31
+ */
32
+ async getSensitiveWordDetail(wordId) {
33
+ return this.post('/externalcontact/get_sensitive_word', {
34
+ word_id: wordId
35
+ });
36
+ }
37
+
38
+ /**
39
+ * 添加敏感词
40
+ * @param {string} word 敏感词
41
+ * @param {string} wordType 敏感词类型
42
+ * @param {string} ruleId 规则 ID
43
+ */
44
+ async addSensitiveWord(word, wordType = 'keyword', ruleId = '') {
45
+ return this.post('/externalcontact/add_sensitive_word', {
46
+ word,
47
+ word_type: wordType,
48
+ rule_id: ruleId
49
+ });
50
+ }
51
+
52
+ /**
53
+ * 编辑敏感词
54
+ * @param {string} wordId 敏感词 ID
55
+ * @param {string} word 敏感词
56
+ */
57
+ async updateSensitiveWord(wordId, word) {
58
+ return this.post('/externalcontact/update_sensitive_word', {
59
+ word_id: wordId,
60
+ word
61
+ });
62
+ }
63
+
64
+ /**
65
+ * 删除敏感词
66
+ * @param {string} wordId 敏感词 ID
67
+ */
68
+ async deleteSensitiveWord(wordId) {
69
+ return this.post('/externalcontact/del_sensitive_word', {
70
+ word_id: wordId
71
+ });
72
+ }
73
+
74
+ // ========== 敏感词规则管理 ==========
75
+
76
+ /**
77
+ * 获取敏感词规则列表
78
+ */
79
+ async getSensitiveRuleList() {
80
+ return this.post('/externalcontact/get_sensitive_rule_list', {});
81
+ }
82
+
83
+ /**
84
+ * 获取敏感词规则详情
85
+ * @param {string} ruleId 规则 ID
86
+ */
87
+ async getSensitiveRuleDetail(ruleId) {
88
+ return this.post('/externalcontact/get_sensitive_rule', {
89
+ rule_id: ruleId
90
+ });
91
+ }
92
+
93
+ /**
94
+ * 添加敏感词规则
95
+ * @param {object} rule 规则配置
96
+ */
97
+ async addSensitiveRule(rule) {
98
+ return this.post('/externalcontact/add_sensitive_rule', rule);
99
+ }
100
+
101
+ /**
102
+ * 编辑敏感词规则
103
+ * @param {string} ruleId 规则 ID
104
+ * @param {object} rule 规则配置
105
+ */
106
+ async updateSensitiveRule(ruleId, rule) {
107
+ return this.post('/externalcontact/update_sensitive_rule', {
108
+ rule_id: ruleId,
109
+ ...rule
110
+ });
111
+ }
112
+
113
+ /**
114
+ * 删除敏感词规则
115
+ * @param {string} ruleId 规则 ID
116
+ */
117
+ async deleteSensitiveRule(ruleId) {
118
+ return this.post('/externalcontact/del_sensitive_rule', {
119
+ rule_id: ruleId
120
+ });
121
+ }
122
+
123
+ // ========== 敏感操作管理 ==========
124
+
125
+ /**
126
+ * 获取成员敏感行为列表
127
+ * @param {number} startTime 开始时间戳
128
+ * @param {number} endTime 结束时间戳
129
+ * @param {string} userId 成员 ID
130
+ * @param {string} type 行为类型
131
+ * @param {number} offset 偏移量
132
+ * @param {number} size 每页数量
133
+ */
134
+ async getSensitiveActionList(startTime, endTime, userId = '', type = '', offset = 0, size = 100) {
135
+ return this.post('/externalcontact/get_sensitive_action_list', {
136
+ start_time: startTime,
137
+ end_time: endTime,
138
+ userid: userId,
139
+ type,
140
+ offset,
141
+ limit: size
142
+ });
143
+ }
144
+
145
+ // ========== 敏感成员配置 ==========
146
+
147
+ /**
148
+ * 获取使用敏感词的成员列表
149
+ * @param {string} wordId 敏感词 ID
150
+ */
151
+ async getSensitiveWordUsers(wordId) {
152
+ return this.post('/externalcontact/get_sensitive_word_users', {
153
+ word_id: wordId
154
+ });
155
+ }
156
+
157
+ /**
158
+ * 配置敏感词成员例外
159
+ * @param {string} wordId 敏感词 ID
160
+ * @param {string[]} userIds 例外成员 ID
161
+ */
162
+ async setSensitiveWordExusers(wordId, userIds) {
163
+ return this.post('/externalcontact/set_sensitive_word_exusers', {
164
+ word_id: wordId,
165
+ user_ids: userIds
166
+ });
167
+ }
168
+ }
169
+
170
+ module.exports = Sensitive;
@@ -0,0 +1,145 @@
1
+ /**
2
+ * 企业互联模块
3
+ * API 章节:五 - 企业互联
4
+ * 包含:获取下级企业 token、小程序 session 等
5
+ */
6
+
7
+ const WeComSDK = require('../../sdk');
8
+
9
+ class ThirdParty extends WeComSDK {
10
+ constructor(config) {
11
+ super(config);
12
+ this.providerSecret = config.providerSecret || '';
13
+ }
14
+
15
+ // ========== 企业互联基础 ==========
16
+
17
+ /**
18
+ * 获取下级/下游企业的 access_token
19
+ * @param {string} corpId 下级企业 ID
20
+ * @param {string} permanentCode 永久授权码
21
+ */
22
+ async getSubCorpToken(corpId, permanentCode) {
23
+ return this.post('/thirdparty/get_sub_corp_token', {
24
+ corpid: corpId,
25
+ permanent_code: permanentCode
26
+ });
27
+ }
28
+
29
+ /**
30
+ * 获取下级企业授权码
31
+ * @param {string} authCode 授权 code
32
+ */
33
+ async getPermanentCode(authCode) {
34
+ return this.post('/thirdparty/get_permanent_code', { auth_code: authCode });
35
+ }
36
+
37
+ /**
38
+ * 获取下级企业授权信息
39
+ * @param {string} corpId 下级企业 ID
40
+ */
41
+ async getCorpInfo(corpId) {
42
+ return this.post('/thirdparty/get_corp_info', { corpid: corpId });
43
+ }
44
+
45
+ /**
46
+ * 获取下级企业列表
47
+ * @param {number} offset 偏移量
48
+ * @param {number} size 每页数量
49
+ */
50
+ async getCorpList(offset = 0, size = 100) {
51
+ return this.post('/thirdparty/get_corp_list', { offset, limit: size });
52
+ }
53
+
54
+ /**
55
+ * 获取下级/下游企业小程序 session
56
+ * @param {string} userId 用户 ID
57
+ * @param {string} sessionKey 小程序 session key
58
+ * @param {number} type 类型
59
+ */
60
+ async getSubCorpMiniProgramSession(userId, sessionKey, type = 1) {
61
+ return this.post('/thirdparty/get_sub_corp_mini_program_session', {
62
+ userid: userId,
63
+ session_key: sessionKey,
64
+ type
65
+ });
66
+ }
67
+
68
+ /**
69
+ * 获取应用共享信息
70
+ * @param {string} agentId 应用 ID
71
+ */
72
+ async getCorpSharedInfo(agentId) {
73
+ return this.post('/thirdparty/get_corp_shared_info', { agentid: agentId });
74
+ }
75
+
76
+ // ========== 通讯录同步 ==========
77
+
78
+ /**
79
+ * 激活下级企业
80
+ * @param {string} corpId 下级企业 ID
81
+ * @param {number} activateState 激活状态
82
+ */
83
+ async activateCorp(corpId, activateState = 1) {
84
+ return this.post('/thirdparty/activate_corp', {
85
+ corpid: corpId,
86
+ activate_state: activateState
87
+ });
88
+ }
89
+
90
+ /**
91
+ * 设置下级企业同步范围
92
+ * @param {string} corpId 下级企业 ID
93
+ * @param {number[]} departmentIds 部门 ID 列表
94
+ */
95
+ async setSyncScope(corpId, departmentIds) {
96
+ return this.post('/thirdparty/set_sync_scope', {
97
+ corpid: corpId,
98
+ department_ids: departmentIds
99
+ });
100
+ }
101
+
102
+ // ========== 应用管理 ==========
103
+
104
+ /**
105
+ * 获取下级企业应用列表
106
+ * @param {string} corpId 下级企业 ID
107
+ */
108
+ async getSubCorpAgentList(corpId) {
109
+ return this.post('/thirdparty/agent/list', { corpid: corpId });
110
+ }
111
+
112
+ /**
113
+ * 设置下级企业应用
114
+ * @param {string} corpId 下级企业 ID
115
+ * @param {number} agentId 应用 ID
116
+ * @param {object} params 应用参数
117
+ */
118
+ async setSubCorpAgent(corpId, agentId, params) {
119
+ return this.post('/thirdparty/agent/set', {
120
+ corpid: corpId,
121
+ agentid: agentId,
122
+ ...params
123
+ });
124
+ }
125
+
126
+ // ========== 消息推送 ==========
127
+
128
+ /**
129
+ * 给下级企业发送消息
130
+ * @param {string} corpId 下级企业 ID
131
+ * @param {string} toUser 接收成员
132
+ * @param {object} content 消息内容
133
+ * @param {string} msgType 消息类型
134
+ */
135
+ async sendToSubCorp(corpId, toUser, content, msgType = 'text') {
136
+ return this.post('/thirdparty/message/send', {
137
+ corpid: corpId,
138
+ touser: toUser,
139
+ msgtype: msgType,
140
+ [msgType]: content
141
+ });
142
+ }
143
+ }
144
+
145
+ module.exports = ThirdParty;