node-easywechat 2.8.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/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 -7
- package/dist/Core/Mixins/HttpMixin.js +4 -4
- package/dist/Core/ServerGuard.js +5 -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 +2 -0
- package/dist/MiniProgram/Application.js +5 -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/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/UrlLink/UrlLinkClient.d.ts +6 -1
- package/dist/MiniProgram/UrlLink/UrlLinkClient.js +7 -2
- 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.js +14 -14
- 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 +45 -0
- package/dist/Work/ExternalContact/Client.js +72 -0
- package/dist/Work/ExternalContact/ContactWayClient.js +2 -2
- package/dist/Work/ExternalContact/MessageClient.js +4 -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 +9 -9
|
@@ -70,7 +70,7 @@ class OpenPlatform extends BaseApplication_1.default {
|
|
|
70
70
|
*/
|
|
71
71
|
getPreAuthorizationUrl(callbackUrl, optional = {}) {
|
|
72
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
if (Utils_1.isString(optional)) {
|
|
73
|
+
if ((0, Utils_1.isString)(optional)) {
|
|
74
74
|
optional = {
|
|
75
75
|
pre_auth_code: optional,
|
|
76
76
|
};
|
|
@@ -78,7 +78,7 @@ class OpenPlatform extends BaseApplication_1.default {
|
|
|
78
78
|
else {
|
|
79
79
|
optional['pre_auth_code'] = (yield this.createPreAuthorizationCode())['pre_auth_code'];
|
|
80
80
|
}
|
|
81
|
-
return 'https://mp.weixin.qq.com/cgi-bin/componentloginpage?' + Utils_1.buildQueryString(Utils_1.merge(Utils_1.merge({}, optional), {
|
|
81
|
+
return 'https://mp.weixin.qq.com/cgi-bin/componentloginpage?' + (0, Utils_1.buildQueryString)((0, Utils_1.merge)((0, Utils_1.merge)({}, optional), {
|
|
82
82
|
component_appid: this.config['app_id'],
|
|
83
83
|
redirect_uri: callbackUrl,
|
|
84
84
|
}));
|
|
@@ -91,7 +91,7 @@ class OpenPlatform extends BaseApplication_1.default {
|
|
|
91
91
|
*/
|
|
92
92
|
getMobilePreAuthorizationUrl(callbackUrl, optional = {}) {
|
|
93
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
if (Utils_1.isString(optional)) {
|
|
94
|
+
if ((0, Utils_1.isString)(optional)) {
|
|
95
95
|
optional = {
|
|
96
96
|
pre_auth_code: optional,
|
|
97
97
|
};
|
|
@@ -99,7 +99,7 @@ class OpenPlatform extends BaseApplication_1.default {
|
|
|
99
99
|
else {
|
|
100
100
|
optional['pre_auth_code'] = yield this.createPreAuthorizationCode()['pre_auth_code'];
|
|
101
101
|
}
|
|
102
|
-
return 'https://mp.weixin.qq.com/safe/bindcomponent?' + Utils_1.buildQueryString(Utils_1.merge(optional, {
|
|
102
|
+
return 'https://mp.weixin.qq.com/safe/bindcomponent?' + (0, Utils_1.buildQueryString)((0, Utils_1.merge)(optional, {
|
|
103
103
|
component_appid: this.config['app_id'],
|
|
104
104
|
redirect_uri: callbackUrl,
|
|
105
105
|
action: 'bindcomponent',
|
|
@@ -108,7 +108,7 @@ class OpenPlatform extends BaseApplication_1.default {
|
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
getAuthorizerConfig(appId, refreshToken = null) {
|
|
111
|
-
return Utils_1.merge(Utils_1.merge({}, this.config), {
|
|
111
|
+
return (0, Utils_1.merge)((0, Utils_1.merge)({}, this.config), {
|
|
112
112
|
component_app_id: this.config['app_id'],
|
|
113
113
|
app_id: appId,
|
|
114
114
|
refresh_token: refreshToken,
|
|
@@ -139,7 +139,7 @@ class OpenPlatform extends BaseApplication_1.default {
|
|
|
139
139
|
*/
|
|
140
140
|
officialAccount(appId, refreshToken = null, accessToken = null) {
|
|
141
141
|
let that = this;
|
|
142
|
-
let services = Utils_1.merge(Utils_1.merge({}, this.getReplaceServices(accessToken)), {
|
|
142
|
+
let services = (0, Utils_1.merge)((0, Utils_1.merge)({}, this.getReplaceServices(accessToken)), {
|
|
143
143
|
encryptor: this.encryptor,
|
|
144
144
|
account: function (app) {
|
|
145
145
|
return new Client_1.default(app, that);
|
|
@@ -159,7 +159,7 @@ class OpenPlatform extends BaseApplication_1.default {
|
|
|
159
159
|
*/
|
|
160
160
|
miniProgram(appId, refreshToken = null, accessToken = null) {
|
|
161
161
|
let that = this;
|
|
162
|
-
let services = Utils_1.merge(Utils_1.merge({}, this.getReplaceServices(accessToken)), {
|
|
162
|
+
let services = (0, Utils_1.merge)((0, Utils_1.merge)({}, this.getReplaceServices(accessToken)), {
|
|
163
163
|
auth: function (app) {
|
|
164
164
|
return new Client_2.default(app, that);
|
|
165
165
|
},
|
|
@@ -34,7 +34,7 @@ class AccessToken extends BaseAccessToken_1.default {
|
|
|
34
34
|
}
|
|
35
35
|
getEndpoint() {
|
|
36
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
return 'cgi-bin/component/api_authorizer_token?' + Utils_1.buildQueryString({
|
|
37
|
+
return 'cgi-bin/component/api_authorizer_token?' + (0, Utils_1.buildQueryString)({
|
|
38
38
|
component_access_token: (yield this.component.access_token.getToken())['component_access_token'],
|
|
39
39
|
});
|
|
40
40
|
});
|
|
@@ -23,7 +23,7 @@ class Client extends Client_1.default {
|
|
|
23
23
|
appid: this.app.config.app_id,
|
|
24
24
|
redirect_uri: callbackUrl,
|
|
25
25
|
};
|
|
26
|
-
return 'https://mp.weixin.qq.com/cgi-bin/fastregisterauth?' + Utils_1.buildQueryString(query);
|
|
26
|
+
return 'https://mp.weixin.qq.com/cgi-bin/fastregisterauth?' + (0, Utils_1.buildQueryString)(query);
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* 第三方平台调用快速注册 API 完成注册
|
|
@@ -117,12 +117,12 @@ class Payment extends BaseApplication_1.default {
|
|
|
117
117
|
let params = {
|
|
118
118
|
appid: this.config.app_id,
|
|
119
119
|
mch_id: this.config.mch_id,
|
|
120
|
-
time_stamp: Utils_1.getTimestamp(),
|
|
121
|
-
nonce_str: Utils_1.randomString(16),
|
|
120
|
+
time_stamp: (0, Utils_1.getTimestamp)(),
|
|
121
|
+
nonce_str: (0, Utils_1.randomString)(16),
|
|
122
122
|
product_id,
|
|
123
123
|
};
|
|
124
|
-
params['sign'] = Utils_1.makeSignature(params, this.config.key);
|
|
125
|
-
return 'weixin://wxpay/bizpayurl?' + Utils_1.buildQueryString(params);
|
|
124
|
+
params['sign'] = (0, Utils_1.makeSignature)(params, this.config.key);
|
|
125
|
+
return 'weixin://wxpay/bizpayurl?' + (0, Utils_1.buildQueryString)(params);
|
|
126
126
|
}
|
|
127
127
|
codeUrlScheme(codeUrl) {
|
|
128
128
|
return 'weixin://wxpay/bizpayurl?sr=' + codeUrl;
|
|
@@ -26,7 +26,7 @@ class BillClient extends BaseClient_1.default {
|
|
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
options = options || {};
|
|
28
28
|
options['encoding'] = 'binary';
|
|
29
|
-
let params = Utils_1.merge({
|
|
29
|
+
let params = (0, Utils_1.merge)({
|
|
30
30
|
appid: this.app.config.app_id,
|
|
31
31
|
bill_date: date,
|
|
32
32
|
bill_type: type,
|
|
@@ -34,7 +34,7 @@ class BillClient extends BaseClient_1.default {
|
|
|
34
34
|
let res = yield this.requestRaw(this.wrap('pay/downloadbill'), params);
|
|
35
35
|
let content = res.getContent().toString();
|
|
36
36
|
if (content && content.indexOf('<xml>') === 0) {
|
|
37
|
-
return yield Utils_1.parseXml(content);
|
|
37
|
+
return yield (0, Utils_1.parseXml)(content);
|
|
38
38
|
}
|
|
39
39
|
return StreamResponse_1.default.buildFromResponse(res);
|
|
40
40
|
});
|
|
@@ -30,7 +30,7 @@ class BaseClient {
|
|
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
31
|
let base = {
|
|
32
32
|
mch_id: this.app.config.mch_id,
|
|
33
|
-
nonce_str: Utils_1.randomString(32),
|
|
33
|
+
nonce_str: (0, Utils_1.randomString)(32),
|
|
34
34
|
};
|
|
35
35
|
if (this.app.config.sub_mch_id) {
|
|
36
36
|
base['sub_mch_id'] = '';
|
|
@@ -38,14 +38,14 @@ class BaseClient {
|
|
|
38
38
|
if (this.app.config.sub_appid) {
|
|
39
39
|
base['sub_appid'] = '';
|
|
40
40
|
}
|
|
41
|
-
let localParams = Utils_1.merge(Utils_1.merge(base, this.prepends()), params);
|
|
41
|
+
let localParams = (0, Utils_1.merge)((0, Utils_1.merge)(base, this.prepends()), params);
|
|
42
42
|
let secretKey = yield this.app.getKey(endpoint);
|
|
43
|
-
localParams['sign'] = Utils_1.makeSignature(localParams, secretKey, localParams['sign_type'] || 'MD5');
|
|
44
|
-
let payload = Utils_1.merge(Utils_1.merge({}, options), {
|
|
43
|
+
localParams['sign'] = (0, Utils_1.makeSignature)(localParams, secretKey, localParams['sign_type'] || 'MD5');
|
|
44
|
+
let payload = (0, Utils_1.merge)((0, Utils_1.merge)({}, options), {
|
|
45
45
|
url: endpoint,
|
|
46
46
|
method,
|
|
47
47
|
responseType: 'text',
|
|
48
|
-
data: Utils_1.buildXml(localParams)
|
|
48
|
+
data: (0, Utils_1.buildXml)(localParams)
|
|
49
49
|
});
|
|
50
50
|
let response = yield this.doRequest(payload);
|
|
51
51
|
if (returnResponse) {
|
|
@@ -54,7 +54,7 @@ class BaseClient {
|
|
|
54
54
|
else {
|
|
55
55
|
let body = response.data;
|
|
56
56
|
try {
|
|
57
|
-
body = yield Utils_1.parseXml(body);
|
|
57
|
+
body = yield (0, Utils_1.parseXml)(body);
|
|
58
58
|
}
|
|
59
59
|
catch (e) { }
|
|
60
60
|
return body;
|
|
@@ -62,7 +62,7 @@ class BaseClient {
|
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
safeRequest(endpoint, params = {}, method = 'post', options = {}) {
|
|
65
|
-
options = Utils_1.merge(Utils_1.merge({}, options), {
|
|
65
|
+
options = (0, Utils_1.merge)((0, Utils_1.merge)({}, options), {
|
|
66
66
|
httpsAgent: new https_1.default.Agent({
|
|
67
67
|
pfx: fs_1.default.readFileSync(this.app.config.cert_path),
|
|
68
68
|
passphrase: this.app.config.mch_id,
|
|
@@ -112,5 +112,5 @@ class BaseClient {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
;
|
|
115
|
-
Utils_1.applyMixins(BaseClient, [HttpMixin_1.default]);
|
|
115
|
+
(0, Utils_1.applyMixins)(BaseClient, [HttpMixin_1.default]);
|
|
116
116
|
exports.default = BaseClient;
|
|
@@ -24,12 +24,12 @@ class JssdkClient extends JssdkClient_1.default {
|
|
|
24
24
|
bridgeConfig(prepayId, json = true) {
|
|
25
25
|
let params = {
|
|
26
26
|
appId: this.app.config.sub_appid ? this.app.config.sub_appid : this.app.config.app_id,
|
|
27
|
-
timeStamp: Utils_1.getTimestamp() + '',
|
|
28
|
-
nonceStr: Utils_1.randomString(16),
|
|
27
|
+
timeStamp: (0, Utils_1.getTimestamp)() + '',
|
|
28
|
+
nonceStr: (0, Utils_1.randomString)(16),
|
|
29
29
|
package: `prepay_id=${prepayId}`,
|
|
30
30
|
signType: 'MD5',
|
|
31
31
|
};
|
|
32
|
-
params['paySign'] = Utils_1.makeSignature(params, this.app.config.key, 'md5');
|
|
32
|
+
params['paySign'] = (0, Utils_1.makeSignature)(params, this.app.config.key, 'md5');
|
|
33
33
|
return json ? JSON.stringify(params) : params;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
@@ -51,11 +51,11 @@ class JssdkClient extends JssdkClient_1.default {
|
|
|
51
51
|
appid: this.app.config.app_id,
|
|
52
52
|
partnerid: this.app.config.mch_id,
|
|
53
53
|
prepayid: prepayId,
|
|
54
|
-
noncestr: Utils_1.randomString(16),
|
|
55
|
-
timestamp: Utils_1.getTimestamp() + '',
|
|
54
|
+
noncestr: (0, Utils_1.randomString)(16),
|
|
55
|
+
timestamp: (0, Utils_1.getTimestamp)() + '',
|
|
56
56
|
package: 'Sign=WXPay',
|
|
57
57
|
};
|
|
58
|
-
params['sign'] = Utils_1.makeSignature(params, this.app.config.key, 'md5');
|
|
58
|
+
params['sign'] = (0, Utils_1.makeSignature)(params, this.app.config.key, 'md5');
|
|
59
59
|
return params;
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
@@ -71,8 +71,8 @@ class JssdkClient extends JssdkClient_1.default {
|
|
|
71
71
|
let params = {
|
|
72
72
|
appId: this.app.config.app_id,
|
|
73
73
|
scope: 'jsapi_address',
|
|
74
|
-
timeStamp: Utils_1.getTimestamp() + '',
|
|
75
|
-
nonceStr: Utils_1.randomString(16),
|
|
74
|
+
timeStamp: (0, Utils_1.getTimestamp)() + '',
|
|
75
|
+
nonceStr: (0, Utils_1.randomString)(16),
|
|
76
76
|
signType: 'SHA1',
|
|
77
77
|
};
|
|
78
78
|
let signParams = {
|
|
@@ -82,7 +82,7 @@ class JssdkClient extends JssdkClient_1.default {
|
|
|
82
82
|
noncestr: params['nonceStr'],
|
|
83
83
|
accesstoken: '' + accessToken,
|
|
84
84
|
};
|
|
85
|
-
params['addrSign'] = Utils_1.makeSignature(signParams, '', 'sha1');
|
|
85
|
+
params['addrSign'] = (0, Utils_1.makeSignature)(signParams, '', 'sha1');
|
|
86
86
|
return json ? JSON.stringify(params) : params;
|
|
87
87
|
});
|
|
88
88
|
}
|
|
@@ -94,8 +94,8 @@ class JssdkClient extends JssdkClient_1.default {
|
|
|
94
94
|
contractConfig(params, json = false) {
|
|
95
95
|
return __awaiter(this, void 0, void 0, function* () {
|
|
96
96
|
params['appid'] = this.app.config.app_id;
|
|
97
|
-
params['timestamp'] = Utils_1.getTimestamp() + '';
|
|
98
|
-
params['sign'] = Utils_1.makeSignature(params, this.app.config.key, 'md5');
|
|
97
|
+
params['timestamp'] = (0, Utils_1.getTimestamp)() + '';
|
|
98
|
+
params['sign'] = (0, Utils_1.makeSignature)(params, this.app.config.key, 'md5');
|
|
99
99
|
return json ? JSON.stringify(params) : params;
|
|
100
100
|
});
|
|
101
101
|
}
|
|
@@ -108,11 +108,11 @@ class JssdkClient extends JssdkClient_1.default {
|
|
|
108
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
109
|
let params = {
|
|
110
110
|
appId: this.app.config.app_id,
|
|
111
|
-
timeStamp: Utils_1.getTimestamp() + '',
|
|
112
|
-
nonceStr: Utils_1.randomString(16),
|
|
111
|
+
timeStamp: (0, Utils_1.getTimestamp)() + '',
|
|
112
|
+
nonceStr: (0, Utils_1.randomString)(16),
|
|
113
113
|
package: pkg,
|
|
114
114
|
};
|
|
115
|
-
params['paySign'] = Utils_1.makeSignature(params, '', 'md5');
|
|
115
|
+
params['paySign'] = (0, Utils_1.makeSignature)(params, '', 'md5');
|
|
116
116
|
params['signType'] = 'MD5';
|
|
117
117
|
delete params.appId;
|
|
118
118
|
return json ? JSON.stringify(params) : params;
|
|
@@ -28,7 +28,7 @@ class MerchantClient extends BaseClient_1.default {
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
manage(data, query) {
|
|
31
|
-
let params = Utils_1.merge(Utils_1.merge({}, data), {
|
|
31
|
+
let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, data), {
|
|
32
32
|
appid: this.app.config.app_id,
|
|
33
33
|
nonce_str: '',
|
|
34
34
|
sub_mech_id: '',
|
|
@@ -50,11 +50,11 @@ class Handler {
|
|
|
50
50
|
return_code: this.fail === null ? this.SUCCESS : this.FAIL,
|
|
51
51
|
return_msg: this.fail
|
|
52
52
|
};
|
|
53
|
-
let attributes = Utils_1.merge(base, this.attributes);
|
|
53
|
+
let attributes = (0, Utils_1.merge)(base, this.attributes);
|
|
54
54
|
if (this.sign) {
|
|
55
|
-
attributes['sign'] = Utils_1.makeSignature(attributes, yield this.app.getKey());
|
|
55
|
+
attributes['sign'] = (0, Utils_1.makeSignature)(attributes, yield this.app.getKey());
|
|
56
56
|
}
|
|
57
|
-
return new Response_1.default(Buffer.from(Utils_1.buildXml(attributes)));
|
|
57
|
+
return new Response_1.default(Buffer.from((0, Utils_1.buildXml)(attributes)));
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
getMessage() {
|
|
@@ -76,13 +76,13 @@ class Handler {
|
|
|
76
76
|
if (!message[key]) {
|
|
77
77
|
return null;
|
|
78
78
|
}
|
|
79
|
-
return AES_1.AES.decrypt(Buffer.from(message[key], 'base64'), Utils_1.createHash(this.app.config.key, 'md5'), '', true, 'aes-256-ecb').toString();
|
|
79
|
+
return AES_1.AES.decrypt(Buffer.from(message[key], 'base64'), (0, Utils_1.createHash)(this.app.config.key, 'md5'), '', true, 'aes-256-ecb').toString();
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
validate(message) {
|
|
83
83
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
84
|
let sign = message['sign'];
|
|
85
|
-
if (Utils_1.makeSignature(message, yield this.app.getKey()) !== sign) {
|
|
85
|
+
if ((0, Utils_1.makeSignature)(message, yield this.app.getKey()) !== sign) {
|
|
86
86
|
throw new Error('Invalid Sign');
|
|
87
87
|
}
|
|
88
88
|
});
|
|
@@ -32,7 +32,7 @@ class RefundedHandler extends Handler_1.default {
|
|
|
32
32
|
}
|
|
33
33
|
reqInfo() {
|
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
return yield Utils_1.parseXml(yield this.decryptMessage('req_info'));
|
|
35
|
+
return yield (0, Utils_1.parseXml)(yield this.decryptMessage('req_info'));
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -41,10 +41,10 @@ class ScannedHandler extends Handler_1.default {
|
|
|
41
41
|
result_code: (this.alert === null && this.fail === null) ? this.SUCCESS : this.FAIL,
|
|
42
42
|
err_code_des: this.alert,
|
|
43
43
|
};
|
|
44
|
-
if (this.alert === null && Utils_1.isString(result)) {
|
|
44
|
+
if (this.alert === null && (0, Utils_1.isString)(result)) {
|
|
45
45
|
attributes['appid'] = this.app.config.app_id;
|
|
46
46
|
attributes['mch_id'] = this.app.config.mch_id;
|
|
47
|
-
attributes['nonce_str'] = Utils_1.randomString(16);
|
|
47
|
+
attributes['nonce_str'] = (0, Utils_1.randomString)(16);
|
|
48
48
|
attributes['prepay_id'] = result;
|
|
49
49
|
}
|
|
50
50
|
return yield this.respondWith(attributes, true).toResponse();
|
|
@@ -30,7 +30,7 @@ class OrderClient extends BaseClient_1.default {
|
|
|
30
30
|
if (isContract) {
|
|
31
31
|
params['contract_appid'] = this.app.config.app_id;
|
|
32
32
|
params['contract_mchid'] = this.app.config.mch_id;
|
|
33
|
-
params['request_serial'] = params['request_serial'] || Utils_1.getTimestamp();
|
|
33
|
+
params['request_serial'] = params['request_serial'] || (0, Utils_1.getTimestamp)();
|
|
34
34
|
params['contract_notify_url'] = params['contract_notify_url'] || this.app.config.contract_notify_url;
|
|
35
35
|
return this.request(this.wrap('pay/contractorder'), params);
|
|
36
36
|
}
|
|
@@ -20,10 +20,10 @@ class RedpackClient extends BaseClient_1.default {
|
|
|
20
20
|
* @param mchBillno 商户订单号
|
|
21
21
|
*/
|
|
22
22
|
info(mchBillno) {
|
|
23
|
-
let data = Utils_1.isObject(mchBillno) ? mchBillno : {
|
|
23
|
+
let data = (0, Utils_1.isObject)(mchBillno) ? mchBillno : {
|
|
24
24
|
mch_billno: mchBillno
|
|
25
25
|
};
|
|
26
|
-
let params = Utils_1.merge(Utils_1.merge({}, data), {
|
|
26
|
+
let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, data), {
|
|
27
27
|
appid: this.app.config.app_id,
|
|
28
28
|
bill_type: 'MCHT',
|
|
29
29
|
});
|
|
@@ -35,7 +35,7 @@ class RedpackClient extends BaseClient_1.default {
|
|
|
35
35
|
*/
|
|
36
36
|
sendMiniprogramNormal(data) {
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
let params = Utils_1.merge(Utils_1.merge({}, data), {
|
|
38
|
+
let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, data), {
|
|
39
39
|
notify_way: 'MINI_PROGRAM_JSAPI',
|
|
40
40
|
wxappid: this.app.config.app_id,
|
|
41
41
|
total_num: 1,
|
|
@@ -50,7 +50,7 @@ class RedpackClient extends BaseClient_1.default {
|
|
|
50
50
|
*/
|
|
51
51
|
sendNormal(data) {
|
|
52
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
let params = Utils_1.merge(Utils_1.merge({}, data), {
|
|
53
|
+
let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, data), {
|
|
54
54
|
wxappid: this.app.config.app_id,
|
|
55
55
|
total_num: 1,
|
|
56
56
|
client_ip: data['client_ip'] || (yield this.getServerIp()),
|
|
@@ -63,7 +63,7 @@ class RedpackClient extends BaseClient_1.default {
|
|
|
63
63
|
* @param params 红包参数
|
|
64
64
|
*/
|
|
65
65
|
sendGroup(params) {
|
|
66
|
-
params = Utils_1.merge(params, {
|
|
66
|
+
params = (0, Utils_1.merge)(params, {
|
|
67
67
|
wxappid: this.app.config.app_id,
|
|
68
68
|
amt_type: 'ALL_RAND',
|
|
69
69
|
});
|
|
@@ -15,7 +15,7 @@ class RefundClient extends BaseClient_1.default {
|
|
|
15
15
|
* @param optional 其它参数
|
|
16
16
|
*/
|
|
17
17
|
byOutTradeNumber(number, refundNumber, totalFee, refundFee, optional = {}) {
|
|
18
|
-
return this.refund(refundNumber, totalFee, refundFee, Utils_1.merge(Utils_1.merge({}, optional), {
|
|
18
|
+
return this.refund(refundNumber, totalFee, refundFee, (0, Utils_1.merge)((0, Utils_1.merge)({}, optional), {
|
|
19
19
|
out_trade_no: number,
|
|
20
20
|
}));
|
|
21
21
|
}
|
|
@@ -28,12 +28,12 @@ class RefundClient extends BaseClient_1.default {
|
|
|
28
28
|
* @param optional 其它参数
|
|
29
29
|
*/
|
|
30
30
|
byTransactionId(transactionId, refundNumber, totalFee, refundFee, optional = {}) {
|
|
31
|
-
return this.refund(refundNumber, totalFee, refundFee, Utils_1.merge(Utils_1.merge({}, optional), {
|
|
31
|
+
return this.refund(refundNumber, totalFee, refundFee, (0, Utils_1.merge)((0, Utils_1.merge)({}, optional), {
|
|
32
32
|
transaction_id: transactionId,
|
|
33
33
|
}));
|
|
34
34
|
}
|
|
35
35
|
refund(refundNumber, totalFee, refundFee, optional = {}) {
|
|
36
|
-
let params = Utils_1.merge({
|
|
36
|
+
let params = (0, Utils_1.merge)({
|
|
37
37
|
appid: this.app.config.app_id,
|
|
38
38
|
out_refund_no: refundNumber,
|
|
39
39
|
total_fee: totalFee,
|
|
@@ -34,7 +34,7 @@ class SandboxClient extends BaseClient_1.default {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
getCacheKey() {
|
|
37
|
-
return 'easywechat.payment.sandbox.' + Utils_1.createHash(this.app.config.app_id + this.app.config.mch_id, 'md5');
|
|
37
|
+
return 'easywechat.payment.sandbox.' + (0, Utils_1.createHash)(this.app.config.app_id + this.app.config.mch_id, 'md5');
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
exports.default = SandboxClient;
|
|
@@ -54,7 +54,7 @@ class TransferClient extends BaseClient_1.default {
|
|
|
54
54
|
if (!params['spbill_create_ip']) {
|
|
55
55
|
params['spbill_create_ip'] = yield this.getServerIp();
|
|
56
56
|
}
|
|
57
|
-
return this.safeRequest('mmpaymkttransfers/promotion/transfers', Utils_1.merge(base, params));
|
|
57
|
+
return this.safeRequest('mmpaymkttransfers/promotion/transfers', (0, Utils_1.merge)(base, params));
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
@@ -13,7 +13,7 @@ class AgentClient extends BaseClient_1.default {
|
|
|
13
13
|
return this.httpGet('cgi-bin/agent/get', params);
|
|
14
14
|
}
|
|
15
15
|
set(agentId, attributes) {
|
|
16
|
-
let params = Utils_1.merge({
|
|
16
|
+
let params = (0, Utils_1.merge)({
|
|
17
17
|
agentid: agentId,
|
|
18
18
|
}, attributes);
|
|
19
19
|
return this.httpPostJson('cgi-bin/agent/set', params);
|
|
@@ -13,7 +13,7 @@ class CalendarClient extends BaseClient_1.default {
|
|
|
13
13
|
return this.httpPostJson('cgi-bin/oa/calendar/add', params);
|
|
14
14
|
}
|
|
15
15
|
update(id, calendar) {
|
|
16
|
-
let params = Utils_1.merge({
|
|
16
|
+
let params = (0, Utils_1.merge)({
|
|
17
17
|
cal_id: id,
|
|
18
18
|
}, calendar);
|
|
19
19
|
return this.httpPostJson('cgi-bin/oa/calendar/update', params);
|
|
@@ -15,7 +15,7 @@ class ChatClient extends BaseClient_1.default {
|
|
|
15
15
|
return this.httpPostJson('cgi-bin/appchat/create', data);
|
|
16
16
|
}
|
|
17
17
|
update(chatId, data) {
|
|
18
|
-
let params = Utils_1.merge({
|
|
18
|
+
let params = (0, Utils_1.merge)({
|
|
19
19
|
chatid: chatId,
|
|
20
20
|
}, data);
|
|
21
21
|
return this.httpPostJson('cgi-bin/appchat/update', params);
|
|
@@ -10,7 +10,7 @@ class DepartmentClient extends BaseClient_1.default {
|
|
|
10
10
|
return this.httpPostJson('cgi-bin/department/create', data);
|
|
11
11
|
}
|
|
12
12
|
update(id, data) {
|
|
13
|
-
let params = Utils_1.merge({
|
|
13
|
+
let params = (0, Utils_1.merge)({
|
|
14
14
|
id: id,
|
|
15
15
|
}, data);
|
|
16
16
|
return this.httpPostJson('cgi-bin/department/update', params);
|
|
@@ -163,4 +163,49 @@ export default class ExternalContactClient extends BaseClient {
|
|
|
163
163
|
* @returns
|
|
164
164
|
*/
|
|
165
165
|
markTags(data: object): Promise<any>;
|
|
166
|
+
/**
|
|
167
|
+
* 外部联系人unionid转换
|
|
168
|
+
* @see https://work.weixin.qq.com/api/doc/90001/90143/93274
|
|
169
|
+
* @param unionid 微信客户的unionid
|
|
170
|
+
* @param openid 微信客户的openid
|
|
171
|
+
* @returns
|
|
172
|
+
*/
|
|
173
|
+
unionidToExternalUserid(unionid?: string, openid?: string): Promise<any>;
|
|
174
|
+
/**
|
|
175
|
+
* 代开发应用external_userid转换
|
|
176
|
+
* @see https://work.weixin.qq.com/api/doc/90001/90143/95195
|
|
177
|
+
* @param unionid 微信客户的unionid
|
|
178
|
+
* @returns
|
|
179
|
+
*/
|
|
180
|
+
toServiceExternalUserid(externalUserid: string): Promise<any>;
|
|
181
|
+
/**
|
|
182
|
+
* 转换external_userid
|
|
183
|
+
* @see https://open.work.weixin.qq.com/api/doc/90001/90143/95327#%E8%BD%AC%E6%8D%A2external_userid
|
|
184
|
+
* @param externalUserIds
|
|
185
|
+
* @returns
|
|
186
|
+
*/
|
|
187
|
+
getNewExternalUserid(externalUserIds: string[]): Promise<any>;
|
|
188
|
+
/**
|
|
189
|
+
* 设置迁移完成
|
|
190
|
+
* @see https://open.work.weixin.qq.com/api/doc/90001/90143/95327#%E8%AE%BE%E7%BD%AE%E8%BF%81%E7%A7%BB%E5%AE%8C%E6%88%90
|
|
191
|
+
* @param corpid
|
|
192
|
+
* @returns
|
|
193
|
+
*/
|
|
194
|
+
finishExternalUseridMigration(corpid: string): Promise<any>;
|
|
195
|
+
/**
|
|
196
|
+
* unionid查询external_userid
|
|
197
|
+
* @see https://open.work.weixin.qq.com/api/doc/90001/90143/95327#4.2%20unionid%E6%9F%A5%E8%AF%A2external_userid
|
|
198
|
+
* @param unionid
|
|
199
|
+
* @param openid
|
|
200
|
+
* @param corpid
|
|
201
|
+
* @returns
|
|
202
|
+
*/
|
|
203
|
+
unionidToexternalUserid3rd(unionid: string, openid: string, corpid?: string): Promise<any>;
|
|
204
|
+
/**
|
|
205
|
+
* 客户群opengid转换
|
|
206
|
+
* @see https://work.weixin.qq.com/api/doc/90000/90135/94822
|
|
207
|
+
* @param opengid
|
|
208
|
+
* @returns
|
|
209
|
+
*/
|
|
210
|
+
opengidToChatid(opengid: string): Promise<any>;
|
|
166
211
|
}
|
|
@@ -273,5 +273,77 @@ class ExternalContactClient extends BaseClient_1.default {
|
|
|
273
273
|
markTags(data) {
|
|
274
274
|
return this.httpPostJson('cgi-bin/externalcontact/mark_tag', data);
|
|
275
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* 外部联系人unionid转换
|
|
278
|
+
* @see https://work.weixin.qq.com/api/doc/90001/90143/93274
|
|
279
|
+
* @param unionid 微信客户的unionid
|
|
280
|
+
* @param openid 微信客户的openid
|
|
281
|
+
* @returns
|
|
282
|
+
*/
|
|
283
|
+
unionidToExternalUserid(unionid = null, openid = null) {
|
|
284
|
+
return this.httpPostJson('cgi-bin/externalcontact/unionid_to_external_userid', {
|
|
285
|
+
unionid,
|
|
286
|
+
openid,
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* 代开发应用external_userid转换
|
|
291
|
+
* @see https://work.weixin.qq.com/api/doc/90001/90143/95195
|
|
292
|
+
* @param unionid 微信客户的unionid
|
|
293
|
+
* @returns
|
|
294
|
+
*/
|
|
295
|
+
toServiceExternalUserid(externalUserid) {
|
|
296
|
+
return this.httpPostJson('cgi-bin/externalcontact/to_service_external_userid', {
|
|
297
|
+
external_userid: externalUserid,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* 转换external_userid
|
|
302
|
+
* @see https://open.work.weixin.qq.com/api/doc/90001/90143/95327#%E8%BD%AC%E6%8D%A2external_userid
|
|
303
|
+
* @param externalUserIds
|
|
304
|
+
* @returns
|
|
305
|
+
*/
|
|
306
|
+
getNewExternalUserid(externalUserIds) {
|
|
307
|
+
return this.httpPostJson('cgi-bin/externalcontact/get_new_external_userid', {
|
|
308
|
+
external_userid_list: externalUserIds,
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* 设置迁移完成
|
|
313
|
+
* @see https://open.work.weixin.qq.com/api/doc/90001/90143/95327#%E8%AE%BE%E7%BD%AE%E8%BF%81%E7%A7%BB%E5%AE%8C%E6%88%90
|
|
314
|
+
* @param corpid
|
|
315
|
+
* @returns
|
|
316
|
+
*/
|
|
317
|
+
finishExternalUseridMigration(corpid) {
|
|
318
|
+
return this.httpPostJson('cgi-bin/externalcontact/finish_external_userid_migration', {
|
|
319
|
+
corpid,
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* unionid查询external_userid
|
|
324
|
+
* @see https://open.work.weixin.qq.com/api/doc/90001/90143/95327#4.2%20unionid%E6%9F%A5%E8%AF%A2external_userid
|
|
325
|
+
* @param unionid
|
|
326
|
+
* @param openid
|
|
327
|
+
* @param corpid
|
|
328
|
+
* @returns
|
|
329
|
+
*/
|
|
330
|
+
unionidToexternalUserid3rd(unionid, openid, corpid = '') {
|
|
331
|
+
return this.httpPostJson('cgi-bin/externalcontact/unionid_to_external_userid_3rd', {
|
|
332
|
+
unionid,
|
|
333
|
+
openid,
|
|
334
|
+
corpid,
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* 客户群opengid转换
|
|
339
|
+
* @see https://work.weixin.qq.com/api/doc/90000/90135/94822
|
|
340
|
+
* @param opengid
|
|
341
|
+
* @returns
|
|
342
|
+
*/
|
|
343
|
+
opengidToChatid(opengid) {
|
|
344
|
+
return this.httpPostJson('cgi-bin/externalcontact/opengid_to_chatid', {
|
|
345
|
+
opengid,
|
|
346
|
+
});
|
|
347
|
+
}
|
|
276
348
|
}
|
|
277
349
|
exports.default = ExternalContactClient;
|
|
@@ -7,7 +7,7 @@ const BaseClient_1 = __importDefault(require("../../Core/BaseClient"));
|
|
|
7
7
|
const Utils_1 = require("../../Core/Utils");
|
|
8
8
|
class ContactWayClient extends BaseClient_1.default {
|
|
9
9
|
create(type, scene, config) {
|
|
10
|
-
let params = Utils_1.merge({
|
|
10
|
+
let params = (0, Utils_1.merge)({
|
|
11
11
|
type,
|
|
12
12
|
scene,
|
|
13
13
|
}, config);
|
|
@@ -19,7 +19,7 @@ class ContactWayClient extends BaseClient_1.default {
|
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
update(configId, config) {
|
|
22
|
-
let params = Utils_1.merge({
|
|
22
|
+
let params = (0, Utils_1.merge)({
|
|
23
23
|
config_id: configId,
|
|
24
24
|
}, config);
|
|
25
25
|
return this.httpPostJson('cgi-bin/externalcontact/update_contact_way', params);
|
|
@@ -123,13 +123,13 @@ class MessageClient extends BaseClient_1.default {
|
|
|
123
123
|
*/
|
|
124
124
|
sendWelcome(welcomeCode, msg) {
|
|
125
125
|
let formattedMsg = this.formatMessage(msg);
|
|
126
|
-
let params = Utils_1.merge(Utils_1.merge({}, formattedMsg), {
|
|
126
|
+
let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, formattedMsg), {
|
|
127
127
|
welcome_code: welcomeCode,
|
|
128
128
|
});
|
|
129
129
|
return this.httpPostJson('cgi-bin/externalcontact/send_welcome_msg', params);
|
|
130
130
|
}
|
|
131
131
|
formatMessage(data) {
|
|
132
|
-
let params = Utils_1.merge({}, data);
|
|
132
|
+
let params = (0, Utils_1.merge)({}, data);
|
|
133
133
|
if (params['text']) {
|
|
134
134
|
params['text'] = this.formatFields(params['text'], this.textMessage);
|
|
135
135
|
}
|
|
@@ -145,9 +145,9 @@ class MessageClient extends BaseClient_1.default {
|
|
|
145
145
|
return params;
|
|
146
146
|
}
|
|
147
147
|
formatFields(data, defaults) {
|
|
148
|
-
let params = Utils_1.merge(Utils_1.merge({}, defaults), data);
|
|
148
|
+
let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, defaults), data);
|
|
149
149
|
for (let key in params) {
|
|
150
|
-
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) {
|
|
151
151
|
throw new Error(`Attribute "${key}" can not be empty!`);
|
|
152
152
|
}
|
|
153
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];
|