node-easywechat 2.7.0 → 2.8.1
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 +24 -1
- package/dist/BaseService/Jssdk/JssdkClient.js +5 -5
- package/dist/BaseService/Media/MediaClient.js +1 -1
- package/dist/Core/AES.d.ts +1 -1
- package/dist/Core/AES.js +4 -4
- package/dist/Core/BaseAccessToken.js +2 -2
- package/dist/Core/BaseApplication.js +4 -4
- package/dist/Core/BaseClient.js +2 -2
- package/dist/Core/Cache/FileCache.js +3 -3
- package/dist/Core/Encryptor.js +3 -3
- package/dist/Core/Http/Request.js +11 -11
- package/dist/Core/Http/StreamResponse.js +1 -1
- package/dist/Core/Messages/Media.js +2 -2
- package/dist/Core/Messages/Message.js +7 -9
- package/dist/Core/Mixins/HttpMixin.js +4 -4
- package/dist/Core/ServerGuard.d.ts +1 -0
- package/dist/Core/ServerGuard.js +8 -5
- package/dist/Core/Utils.js +18 -18
- package/dist/MicroMerchant/Application.js +1 -1
- package/dist/MicroMerchant/Base/MicroMerchantBase.js +6 -6
- package/dist/MicroMerchant/Certficates/CertficatesClient.js +1 -1
- package/dist/MicroMerchant/Core/BaseClient.js +8 -8
- package/dist/MicroMerchant/Media/MediaClient.js +1 -1
- package/dist/MicroMerchant/MerchantConfig/MerchantConfigClient.js +1 -1
- package/dist/MicroMerchant/Meterial/MeterialClient.js +4 -4
- package/dist/MicroMerchant/Withdraw/WithdrawClient.js +2 -2
- package/dist/MiniProgram/ActivityMessage/ActivityMessageClient.js +3 -3
- package/dist/MiniProgram/AppCode/AppCodeClient.js +2 -2
- package/dist/MiniProgram/Application.d.ts +6 -0
- package/dist/MiniProgram/Application.js +15 -0
- package/dist/MiniProgram/Base/MiniProgramBase.js +1 -1
- package/dist/MiniProgram/NearbyPoi/NearbyPoiClient.js +3 -3
- package/dist/MiniProgram/OpenData/OpenDataClient.js +2 -2
- package/dist/MiniProgram/PhoneNumber/PhoneNumberClient.d.ts +10 -0
- package/dist/MiniProgram/PhoneNumber/PhoneNumberClient.js +20 -0
- package/dist/MiniProgram/RealtimeLog/RealtimeLogClient.js +1 -1
- package/dist/MiniProgram/ShortLink/ShortLinkClient.d.ts +11 -0
- package/dist/MiniProgram/ShortLink/ShortLinkClient.js +23 -0
- package/dist/MiniProgram/SubscribeMessage/SubscribeMessageClient.js +5 -5
- package/dist/MiniProgram/UniformMessage/UniformMessageClient.js +3 -3
- package/dist/MiniProgram/Union/UnionClient.d.ts +3 -0
- package/dist/MiniProgram/Union/UnionClient.js +9 -0
- package/dist/MiniProgram/UrlLink/UrlLinkClient.d.ts +9 -0
- package/dist/MiniProgram/UrlLink/UrlLinkClient.js +17 -0
- package/dist/OfficialAccount/Base/OfficialAccountBase.js +2 -2
- package/dist/OfficialAccount/Broadcasting/BroadcastingClient.js +2 -2
- package/dist/OfficialAccount/Broadcasting/MessageBuilder.js +1 -1
- package/dist/OfficialAccount/Card/Client.js +1 -1
- package/dist/OfficialAccount/Card/JssdkClient.js +2 -2
- package/dist/OfficialAccount/Card/MemberCardClient.js +1 -1
- package/dist/OfficialAccount/CustomerService/CustomerServiceClient.js +2 -2
- package/dist/OfficialAccount/CustomerService/Messenger.js +1 -1
- package/dist/OfficialAccount/DataCube/DataCubeClient.js +1 -1
- package/dist/OfficialAccount/Material/MaterialClient.js +2 -2
- package/dist/OfficialAccount/OCR/OCRClient.js +1 -1
- package/dist/OfficialAccount/Semantic/SemanticClient.js +1 -1
- package/dist/OfficialAccount/SubscribeMessage/SubscribeMessageClient.js +4 -4
- package/dist/OfficialAccount/TemplateMessage/TemplateMessageClient.js +4 -4
- package/dist/OpenPlatform/Application.js +7 -7
- package/dist/OpenPlatform/Authorizer/Auth/AccessToken.js +1 -1
- package/dist/OpenPlatform/Authorizer/OfficialAccount/Account/Client.js +1 -1
- package/dist/Payment/Application.js +4 -4
- package/dist/Payment/Bill/BillClient.js +2 -2
- package/dist/Payment/Core/BaseClient.js +8 -8
- package/dist/Payment/Jssdk/JssdkClient.d.ts +12 -0
- package/dist/Payment/Jssdk/JssdkClient.js +41 -9
- package/dist/Payment/Merchant/MerchantClient.js +1 -1
- package/dist/Payment/Notify/Handler.js +5 -5
- package/dist/Payment/Notify/Refunded.js +1 -1
- package/dist/Payment/Notify/Scanned.js +2 -2
- package/dist/Payment/Order/OrderClient.js +1 -1
- package/dist/Payment/Redpack/RedpackClient.js +5 -5
- package/dist/Payment/Refund/RefundClient.js +3 -3
- package/dist/Payment/Sandbox/SandboxClient.js +1 -1
- package/dist/Payment/Transfer/TransferClient.js +1 -1
- package/dist/Work/Agent/AgentClient.js +1 -1
- package/dist/Work/Calendar/CalendarClient.js +1 -1
- package/dist/Work/Chat/ChatClient.js +1 -1
- package/dist/Work/Department/DepartmentClient.js +1 -1
- package/dist/Work/ExternalContact/Client.d.ts +191 -3
- package/dist/Work/ExternalContact/Client.js +228 -6
- package/dist/Work/ExternalContact/ContactWayClient.js +2 -2
- package/dist/Work/ExternalContact/MessageClient.d.ts +45 -0
- package/dist/Work/ExternalContact/MessageClient.js +90 -4
- package/dist/Work/ExternalContact/MessageTemplateClient.js +3 -3
- package/dist/Work/Jssdk/JssdkClient.js +3 -3
- package/dist/Work/Media/MediaClient.js +1 -1
- package/dist/Work/Message/Messenger.js +2 -2
- package/dist/Work/Schedule/ScheduleClient.js +1 -1
- package/dist/Work/User/UserClient.js +3 -3
- package/dist/index.js +1 -1
- package/node-easywechat.file_cache.easywechat.kernel.access_token.8a9684b45da7de42a06a70ba01a7005a.cache +1 -1
- package/node-easywechat.file_cache.easywechat.kernel.access_token.c3d06edaf326aad75d32f31348df787a.cache +1 -1
- package/package.json +11 -11
|
@@ -26,24 +26,110 @@ class MessageClient extends BaseClient_1.default {
|
|
|
26
26
|
page: '',
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* 添加企业群发消息模板
|
|
31
|
+
* @param msg
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
29
34
|
submit(msg) {
|
|
30
35
|
let params = this.formatMessage(msg);
|
|
31
36
|
return this.httpPostJson('cgi-bin/externalcontact/add_msg_template', params);
|
|
32
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* 获取企业群发消息发送结果
|
|
40
|
+
* @param msgId
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
33
43
|
get(msgId) {
|
|
34
44
|
return this.httpPostJson('cgi-bin/externalcontact/get_group_msg_result', {
|
|
35
45
|
msgid: msgId,
|
|
36
46
|
});
|
|
37
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* 获取群发记录列表
|
|
50
|
+
* @param chatType 群发任务的类型,默认为single,表示发送给客户,group表示发送给客户群
|
|
51
|
+
* @param startTime 群发任务记录开始时间
|
|
52
|
+
* @param endTime 群发任务记录结束时间
|
|
53
|
+
* @param creator 群发任务创建人企业账号id
|
|
54
|
+
* @param filterType 创建人类型。0:企业发表 1:个人发表 2:所有,包括个人创建以及企业创建,默认情况下为所有类型
|
|
55
|
+
* @param limit 返回的最大记录数,整型,最大值100,默认值50,超过最大值时取默认值
|
|
56
|
+
* @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
getGroupmsgListV2(chatType, startTime, endTime, creator = null, filterType = null, limit = null, cursor = null) {
|
|
60
|
+
let params = {
|
|
61
|
+
chat_type: chatType,
|
|
62
|
+
start_time: startTime,
|
|
63
|
+
end_time: endTime,
|
|
64
|
+
creator: creator,
|
|
65
|
+
filter_type: filterType,
|
|
66
|
+
limit: limit,
|
|
67
|
+
cursor: cursor,
|
|
68
|
+
};
|
|
69
|
+
Object.keys(params).map(key => {
|
|
70
|
+
if (params[key] === null || params[key] === undefined) {
|
|
71
|
+
delete params[key];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return this.httpPostJson('cgi-bin/externalcontact/get_groupmsg_list_v2', params);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* 获取群发成员发送任务列表
|
|
78
|
+
* @param msgId 群发消息的id,通过获取群发记录列表接口返回
|
|
79
|
+
* @param limit 返回的最大记录数,整型,最大值1000,默认值500,超过最大值时取默认值
|
|
80
|
+
* @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
83
|
+
getGroupmsgTask(msgId, limit = null, cursor = null) {
|
|
84
|
+
let params = {
|
|
85
|
+
msgid: msgId,
|
|
86
|
+
limit: limit,
|
|
87
|
+
cursor: cursor,
|
|
88
|
+
};
|
|
89
|
+
Object.keys(params).map(key => {
|
|
90
|
+
if (params[key] === null || params[key] === undefined) {
|
|
91
|
+
delete params[key];
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
return this.httpPostJson('cgi-bin/externalcontact/get_groupmsg_task', params);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 获取企业群发成员执行结果
|
|
98
|
+
* @param msgId 群发消息的id,通过获取群发记录列表接口返回
|
|
99
|
+
* @param userId 发送成员userid,通过获取群发成员发送任务列表接口返回
|
|
100
|
+
* @param limit 返回的最大记录数,整型,最大值1000,默认值500,超过最大值时取默认值
|
|
101
|
+
* @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
|
|
102
|
+
* @returns
|
|
103
|
+
*/
|
|
104
|
+
getGroupmsgSendResult(msgId, userId, limit = null, cursor = null) {
|
|
105
|
+
let params = {
|
|
106
|
+
msgid: msgId,
|
|
107
|
+
userid: userId,
|
|
108
|
+
limit: limit,
|
|
109
|
+
cursor: cursor,
|
|
110
|
+
};
|
|
111
|
+
Object.keys(params).map(key => {
|
|
112
|
+
if (params[key] === null || params[key] === undefined) {
|
|
113
|
+
delete params[key];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
return this.httpPostJson('cgi-bin/externalcontact/get_groupmsg_send_result', params);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* 发送新客户欢迎语
|
|
120
|
+
* @param welcomeCode
|
|
121
|
+
* @param msg
|
|
122
|
+
* @returns
|
|
123
|
+
*/
|
|
38
124
|
sendWelcome(welcomeCode, msg) {
|
|
39
125
|
let formattedMsg = this.formatMessage(msg);
|
|
40
|
-
let params = Utils_1.merge(Utils_1.merge({}, formattedMsg), {
|
|
126
|
+
let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, formattedMsg), {
|
|
41
127
|
welcome_code: welcomeCode,
|
|
42
128
|
});
|
|
43
129
|
return this.httpPostJson('cgi-bin/externalcontact/send_welcome_msg', params);
|
|
44
130
|
}
|
|
45
131
|
formatMessage(data) {
|
|
46
|
-
let params = Utils_1.merge({}, data);
|
|
132
|
+
let params = (0, Utils_1.merge)({}, data);
|
|
47
133
|
if (params['text']) {
|
|
48
134
|
params['text'] = this.formatFields(params['text'], this.textMessage);
|
|
49
135
|
}
|
|
@@ -59,9 +145,9 @@ class MessageClient extends BaseClient_1.default {
|
|
|
59
145
|
return params;
|
|
60
146
|
}
|
|
61
147
|
formatFields(data, defaults) {
|
|
62
|
-
let params = Utils_1.merge(Utils_1.merge({}, defaults), data);
|
|
148
|
+
let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, defaults), data);
|
|
63
149
|
for (let key in params) {
|
|
64
|
-
if (Utils_1.inArray(key, this.required) && typeof params[key] == undefined && typeof defaults[key] == undefined) {
|
|
150
|
+
if ((0, Utils_1.inArray)(key, this.required) && typeof params[key] == undefined && typeof defaults[key] == undefined) {
|
|
65
151
|
throw new Error(`Attribute "${key}" can not be empty!`);
|
|
66
152
|
}
|
|
67
153
|
params[key] = params[key] || defaults[key];
|
|
@@ -49,7 +49,7 @@ class MessageTemplateClient extends BaseClient_1.default {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
formatMessage(data) {
|
|
52
|
-
let params = Utils_1.merge({}, data);
|
|
52
|
+
let params = (0, Utils_1.merge)({}, data);
|
|
53
53
|
if (params['text']) {
|
|
54
54
|
params['text'] = this.formatFields(params['text'], this.textMessage);
|
|
55
55
|
}
|
|
@@ -65,9 +65,9 @@ class MessageTemplateClient extends BaseClient_1.default {
|
|
|
65
65
|
return params;
|
|
66
66
|
}
|
|
67
67
|
formatFields(data, defaults) {
|
|
68
|
-
let params = Utils_1.merge(Utils_1.merge({}, defaults), data);
|
|
68
|
+
let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, defaults), data);
|
|
69
69
|
for (let key in params) {
|
|
70
|
-
if (Utils_1.inArray(key, this.required) && typeof params[key] == undefined && typeof defaults[key] == undefined) {
|
|
70
|
+
if ((0, Utils_1.inArray)(key, this.required) && typeof params[key] == undefined && typeof defaults[key] == undefined) {
|
|
71
71
|
throw new Error(`Attribute "${key}" can not be empty!`);
|
|
72
72
|
}
|
|
73
73
|
params[key] = params[key] || defaults[key];
|
|
@@ -29,7 +29,7 @@ class JssdkClient extends JssdkClient_1.default {
|
|
|
29
29
|
}
|
|
30
30
|
buildAgentConfig(jsApiList, agentId, debug = false, beta = false, json, openTagList = [], url = '') {
|
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
let config = Utils_1.merge({
|
|
32
|
+
let config = (0, Utils_1.merge)({
|
|
33
33
|
debug,
|
|
34
34
|
beta,
|
|
35
35
|
jsApiList,
|
|
@@ -41,8 +41,8 @@ class JssdkClient extends JssdkClient_1.default {
|
|
|
41
41
|
agentConfigSignature(agentId, url = '', nonce = '', timestamp = '') {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
43
|
url = url || this.getUrl();
|
|
44
|
-
nonce = nonce || Utils_1.randomString(10);
|
|
45
|
-
timestamp = timestamp || Utils_1.getTimestamp() + '';
|
|
44
|
+
nonce = nonce || (0, Utils_1.randomString)(10);
|
|
45
|
+
timestamp = timestamp || (0, Utils_1.getTimestamp)() + '';
|
|
46
46
|
let ticket = yield this.getAgentTicket(agentId);
|
|
47
47
|
return {
|
|
48
48
|
corpid: this.getAppId(),
|
|
@@ -69,7 +69,7 @@ class MediaClient extends BaseClient_1.default {
|
|
|
69
69
|
if (!file) {
|
|
70
70
|
throw new Error(`File does not exist, or the file is unreadable: '${file}'`);
|
|
71
71
|
}
|
|
72
|
-
if (!Utils_1.inArray(type, this.allowTypes)) {
|
|
72
|
+
if (!(0, Utils_1.inArray)(type, this.allowTypes)) {
|
|
73
73
|
throw new Error(`Unsupported media type: '${type}'`);
|
|
74
74
|
}
|
|
75
75
|
let files = {
|
|
@@ -32,7 +32,7 @@ class Messenger {
|
|
|
32
32
|
return this;
|
|
33
33
|
}
|
|
34
34
|
setRecipients(ids, key) {
|
|
35
|
-
if (Utils_1.isArray(ids)) {
|
|
35
|
+
if ((0, Utils_1.isArray)(ids)) {
|
|
36
36
|
ids = ids.join('|');
|
|
37
37
|
}
|
|
38
38
|
this.to = {};
|
|
@@ -58,7 +58,7 @@ class Messenger {
|
|
|
58
58
|
if (!this.agentId) {
|
|
59
59
|
throw new Error('No agentid specified.');
|
|
60
60
|
}
|
|
61
|
-
let data = this.message.transformForJsonRequest(Utils_1.merge({
|
|
61
|
+
let data = this.message.transformForJsonRequest((0, Utils_1.merge)({
|
|
62
62
|
agentid: this.agentId,
|
|
63
63
|
safe: this.secretive ? 1 : 0,
|
|
64
64
|
}, this.to));
|
|
@@ -10,12 +10,12 @@ class UserClient extends BaseClient_1.default {
|
|
|
10
10
|
return this.httpPostJson('cgi-bin/user/create', data);
|
|
11
11
|
}
|
|
12
12
|
update(id, data) {
|
|
13
|
-
return this.httpPostJson('cgi-bin/user/update', Utils_1.merge({
|
|
13
|
+
return this.httpPostJson('cgi-bin/user/update', (0, Utils_1.merge)({
|
|
14
14
|
userid: id,
|
|
15
15
|
}, data));
|
|
16
16
|
}
|
|
17
17
|
delete(userId) {
|
|
18
|
-
if (Utils_1.isArray(userId)) {
|
|
18
|
+
if ((0, Utils_1.isArray)(userId)) {
|
|
19
19
|
return this.batchDelete(userId);
|
|
20
20
|
}
|
|
21
21
|
return this.httpGet('cgi-bin/user/delete', {
|
|
@@ -69,7 +69,7 @@ class UserClient extends BaseClient_1.default {
|
|
|
69
69
|
return this.httpPostJson('cgi-bin/batch/invite', params);
|
|
70
70
|
}
|
|
71
71
|
getInvitationQrCode(sizeType = 1) {
|
|
72
|
-
if (Utils_1.inArray(sizeType, [1, 2, 3, 4])) {
|
|
72
|
+
if ((0, Utils_1.inArray)(sizeType, [1, 2, 3, 4])) {
|
|
73
73
|
throw new Error('The sizeType must be 1, 2, 3, 4.');
|
|
74
74
|
}
|
|
75
75
|
return this.httpGet('cgi-bin/corp/get_join_qrcode', {
|
package/dist/index.js
CHANGED
|
@@ -38,7 +38,7 @@ const StreamResponse_1 = __importDefault(require("./Core/Http/StreamResponse"));
|
|
|
38
38
|
const Messages = __importStar(require("./Core/Messages"));
|
|
39
39
|
function getInstance(service, config) {
|
|
40
40
|
try {
|
|
41
|
-
let s = Utils_1.strStudly(service);
|
|
41
|
+
let s = (0, Utils_1.strStudly)(service);
|
|
42
42
|
let applicationClass = this[s];
|
|
43
43
|
return new applicationClass(config);
|
|
44
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"data":{"errcode":0,"errmsg":"ok","access_token":"moke-token","expires_in":7200},"lifeTime":
|
|
1
|
+
{"data":{"errcode":0,"errmsg":"ok","access_token":"moke-token","expires_in":7200},"lifeTime":1641494146}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"data":{"errcode":0,"errmsg":"ok"},"lifeTime":
|
|
1
|
+
{"data":{"errcode":0,"errmsg":"ok"},"lifeTime":1641494146}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-easywechat",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.1",
|
|
4
4
|
"description": "EasyWechat SDK for Node.js (NOT OFFICIAL)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,19 +19,19 @@
|
|
|
19
19
|
"author": "Hpyer",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@types/node": "^
|
|
23
|
-
"mocha": "^
|
|
24
|
-
"sinon": "^
|
|
25
|
-
"typedoc": "^0.
|
|
26
|
-
"typedoc-plugin-markdown": "^3.
|
|
27
|
-
"typescript": "^4.
|
|
22
|
+
"@types/node": "^17.0.8",
|
|
23
|
+
"mocha": "^9.1.3",
|
|
24
|
+
"sinon": "^12.0.1",
|
|
25
|
+
"typedoc": "^0.22.10",
|
|
26
|
+
"typedoc-plugin-markdown": "^3.11.9",
|
|
27
|
+
"typescript": "^4.5.4"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"axios": "^0.21.
|
|
30
|
+
"axios": "^0.21.4",
|
|
31
31
|
"form-data": "^4.0.0",
|
|
32
|
-
"node-socialite": "^1.2.
|
|
33
|
-
"qs": "^6.
|
|
34
|
-
"raw-body": "^2.4.
|
|
32
|
+
"node-socialite": "^1.2.4",
|
|
33
|
+
"qs": "^6.10.2",
|
|
34
|
+
"raw-body": "^2.4.2",
|
|
35
35
|
"xml2js": "^0.4.23"
|
|
36
36
|
}
|
|
37
37
|
}
|