node-easywechat 2.7.1 → 2.8.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.
- 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/Agent/WorkbenchClient.d.ts +24 -0
- package/dist/Work/Agent/WorkbenchClient.js +39 -0
- package/dist/Work/Application.d.ts +8 -0
- package/dist/Work/Application.js +20 -0
- package/dist/Work/Calendar/CalendarClient.js +1 -1
- package/dist/Work/Chat/ChatClient.js +1 -1
- package/dist/Work/CorpGroup/CorpGroupClient.d.ts +34 -0
- package/dist/Work/CorpGroup/CorpGroupClient.js +42 -0
- package/dist/Work/Department/DepartmentClient.js +1 -1
- package/dist/Work/ExternalContact/Client.d.ts +202 -3
- package/dist/Work/ExternalContact/Client.js +244 -6
- package/dist/Work/ExternalContact/ContactWayClient.d.ts +37 -0
- package/dist/Work/ExternalContact/ContactWayClient.js +51 -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/ExternalContact/MomentClient.d.ts +56 -3
- package/dist/Work/ExternalContact/MomentClient.js +62 -3
- package/dist/Work/ExternalContact/StatisticsClient.d.ts +24 -0
- package/dist/Work/ExternalContact/StatisticsClient.js +35 -0
- package/dist/Work/Jssdk/JssdkClient.js +3 -3
- package/dist/Work/Kf/KfAccountClient.d.ts +41 -0
- package/dist/Work/Kf/KfAccountClient.js +71 -0
- package/dist/Work/Kf/KfMessageClient.d.ts +44 -0
- package/dist/Work/Kf/KfMessageClient.js +73 -0
- package/dist/Work/Kf/KfServicerClient.d.ts +26 -0
- package/dist/Work/Kf/KfServicerClient.js +47 -0
- 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
|
@@ -13,7 +13,7 @@ class SemanticClient extends BaseClient_1.default {
|
|
|
13
13
|
* @param optional 其它参数。属性:latitude,纬度,与城市二选一;longitude,经度,与城市二选一;city,城市,与经纬度二选一;region,区域名称,在城市存在的情况下可省;uid,用户唯一id(非开发者id);
|
|
14
14
|
*/
|
|
15
15
|
query(keyword, categories, optional = {}) {
|
|
16
|
-
let params = Utils_1.merge({
|
|
16
|
+
let params = (0, Utils_1.merge)({
|
|
17
17
|
query: keyword,
|
|
18
18
|
category: categories,
|
|
19
19
|
appid: this.app.config.app_id,
|
|
@@ -82,9 +82,9 @@ class SubscribeMessageClient extends BaseClient_1.default {
|
|
|
82
82
|
return this.httpPostJson(this.API_SEND, params);
|
|
83
83
|
}
|
|
84
84
|
formatMessage(data) {
|
|
85
|
-
let params = Utils_1.merge(Utils_1.merge({}, this.message), data);
|
|
85
|
+
let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, this.message), data);
|
|
86
86
|
for (let key in params) {
|
|
87
|
-
if (Utils_1.inArray(key, this.required) && !params[key]) {
|
|
87
|
+
if ((0, Utils_1.inArray)(key, this.required) && !params[key]) {
|
|
88
88
|
throw new Error(`Attribute "${key}" can not be empty!`);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -95,12 +95,12 @@ class SubscribeMessageClient extends BaseClient_1.default {
|
|
|
95
95
|
let formatted = {}, value;
|
|
96
96
|
for (let key in data) {
|
|
97
97
|
value = {};
|
|
98
|
-
if (Utils_1.isArray(data[key]) && data[key].length == 2) {
|
|
98
|
+
if ((0, Utils_1.isArray)(data[key]) && data[key].length == 2) {
|
|
99
99
|
value = {
|
|
100
100
|
value: data[key][0],
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
else if (Utils_1.isObject(data[key]) && data[key]['value']) {
|
|
103
|
+
else if ((0, Utils_1.isObject)(data[key]) && data[key]['value']) {
|
|
104
104
|
value = data[key];
|
|
105
105
|
}
|
|
106
106
|
else {
|
|
@@ -79,9 +79,9 @@ class Client extends BaseClient_1.default {
|
|
|
79
79
|
return this.httpPostJson('cgi-bin/message/template/subscribe', params);
|
|
80
80
|
}
|
|
81
81
|
formatMessage(data) {
|
|
82
|
-
let params = Utils_1.merge(Utils_1.merge({}, this.message), data);
|
|
82
|
+
let params = (0, Utils_1.merge)((0, Utils_1.merge)({}, this.message), data);
|
|
83
83
|
for (let key in params) {
|
|
84
|
-
if (Utils_1.inArray(key, this.required) && !params[key]) {
|
|
84
|
+
if ((0, Utils_1.inArray)(key, this.required) && !params[key]) {
|
|
85
85
|
throw new Error(`Attribute "${key}" can not be empty!`);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -92,13 +92,13 @@ class Client extends BaseClient_1.default {
|
|
|
92
92
|
let formatted = {}, value;
|
|
93
93
|
for (let key in data) {
|
|
94
94
|
value = {};
|
|
95
|
-
if (Utils_1.isArray(data[key]) && data[key].length == 2) {
|
|
95
|
+
if ((0, Utils_1.isArray)(data[key]) && data[key].length == 2) {
|
|
96
96
|
value = {
|
|
97
97
|
value: data[key][0],
|
|
98
98
|
color: data[key][1],
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
|
-
else if (Utils_1.isObject(data[key]) && data[key]['value']) {
|
|
101
|
+
else if ((0, Utils_1.isObject)(data[key]) && data[key]['value']) {
|
|
102
102
|
value = data[key];
|
|
103
103
|
}
|
|
104
104
|
else {
|
|
@@ -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;
|
|
@@ -23,4 +23,16 @@ export default class JssdkClient extends BaseClient {
|
|
|
23
23
|
* @param json 是否返回json字符串,默认:true
|
|
24
24
|
*/
|
|
25
25
|
shareAddressConfig(accessToken: string | AccessToken, json?: Boolean): Promise<any>;
|
|
26
|
+
/**
|
|
27
|
+
* 生成联系人配置
|
|
28
|
+
* @param params
|
|
29
|
+
* @param json 是否返回JSON字符串,默认:false
|
|
30
|
+
*/
|
|
31
|
+
contractConfig(params: object, json?: Boolean): Promise<any>;
|
|
32
|
+
/**
|
|
33
|
+
* 生成小程序红包配置
|
|
34
|
+
* @param pkg
|
|
35
|
+
* @param json 是否返回JSON字符串,默认:false
|
|
36
|
+
*/
|
|
37
|
+
miniprogramRedpackConfig(pkg: string, json?: Boolean): Promise<any>;
|
|
26
38
|
}
|
|
@@ -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,39 @@ 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
|
+
return json ? JSON.stringify(params) : params;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* 生成联系人配置
|
|
91
|
+
* @param params
|
|
92
|
+
* @param json 是否返回JSON字符串,默认:false
|
|
93
|
+
*/
|
|
94
|
+
contractConfig(params, json = false) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
params['appid'] = this.app.config.app_id;
|
|
97
|
+
params['timestamp'] = (0, Utils_1.getTimestamp)() + '';
|
|
98
|
+
params['sign'] = (0, Utils_1.makeSignature)(params, this.app.config.key, 'md5');
|
|
99
|
+
return json ? JSON.stringify(params) : params;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* 生成小程序红包配置
|
|
104
|
+
* @param pkg
|
|
105
|
+
* @param json 是否返回JSON字符串,默认:false
|
|
106
|
+
*/
|
|
107
|
+
miniprogramRedpackConfig(pkg, json = false) {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
let params = {
|
|
110
|
+
appId: this.app.config.app_id,
|
|
111
|
+
timeStamp: (0, Utils_1.getTimestamp)() + '',
|
|
112
|
+
nonceStr: (0, Utils_1.randomString)(16),
|
|
113
|
+
package: pkg,
|
|
114
|
+
};
|
|
115
|
+
params['paySign'] = (0, Utils_1.makeSignature)(params, '', 'md5');
|
|
116
|
+
params['signType'] = 'MD5';
|
|
117
|
+
delete params.appId;
|
|
86
118
|
return json ? JSON.stringify(params) : params;
|
|
87
119
|
});
|
|
88
120
|
}
|
|
@@ -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);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import BaseClient from '../../Core/BaseClient';
|
|
2
|
+
export default class WorkbenchClient extends BaseClient {
|
|
3
|
+
/**
|
|
4
|
+
* 设置应用在工作台展示的模版
|
|
5
|
+
* @see https://open.work.weixin.qq.com/api/doc/90000/90135/92535#设置应用在工作台展示的模版
|
|
6
|
+
* @param params
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
setWorkbenchTemplate(params: object): Promise<any>;
|
|
10
|
+
/**
|
|
11
|
+
* 获取应用在工作台展示的模版
|
|
12
|
+
* @see https://open.work.weixin.qq.com/api/doc/90000/90135/92535#获取应用在工作台展示的模版
|
|
13
|
+
* @param agentId
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
getWorkbenchTemplate(agentId: number): Promise<any>;
|
|
17
|
+
/**
|
|
18
|
+
* 设置应用在用户工作台展示的数据
|
|
19
|
+
* @see https://open.work.weixin.qq.com/api/doc/90000/90135/92535#设置应用在用户工作台展示的数据
|
|
20
|
+
* @param params
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
setWorkbenchData(params: object): Promise<any>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const BaseClient_1 = __importDefault(require("../../Core/BaseClient"));
|
|
7
|
+
class WorkbenchClient extends BaseClient_1.default {
|
|
8
|
+
/**
|
|
9
|
+
* 设置应用在工作台展示的模版
|
|
10
|
+
* @see https://open.work.weixin.qq.com/api/doc/90000/90135/92535#设置应用在工作台展示的模版
|
|
11
|
+
* @param params
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
setWorkbenchTemplate(params) {
|
|
15
|
+
return this.httpPostJson('cgi-bin/agent/set_workbench_template', params);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 获取应用在工作台展示的模版
|
|
19
|
+
* @see https://open.work.weixin.qq.com/api/doc/90000/90135/92535#获取应用在工作台展示的模版
|
|
20
|
+
* @param agentId
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
getWorkbenchTemplate(agentId) {
|
|
24
|
+
let params = {
|
|
25
|
+
agentid: agentId,
|
|
26
|
+
};
|
|
27
|
+
return this.httpPostJson('cgi-bin/agent/get_workbench_template', params);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 设置应用在用户工作台展示的数据
|
|
31
|
+
* @see https://open.work.weixin.qq.com/api/doc/90000/90135/92535#设置应用在用户工作台展示的数据
|
|
32
|
+
* @param params
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
setWorkbenchData(params) {
|
|
36
|
+
return this.httpPostJson('cgi-bin/agent/set_workbench_data', params);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.default = WorkbenchClient;
|
|
@@ -4,6 +4,7 @@ import WorkBase from './Base/WorkBase';
|
|
|
4
4
|
import OAClient from './OA/OAClient';
|
|
5
5
|
import AccessToken from './Auth/AccessToken';
|
|
6
6
|
import AgentClient from './Agent/AgentClient';
|
|
7
|
+
import WorkbenchClient from './Agent/WorkbenchClient';
|
|
7
8
|
import CalendarClient from './Calendar/CalendarClient';
|
|
8
9
|
import ChatClient from './Chat/ChatClient';
|
|
9
10
|
import DepartmentClient from './Department/DepartmentClient';
|
|
@@ -11,6 +12,9 @@ import GroupRobotClient from './GroupRobot/GroupRobotClient';
|
|
|
11
12
|
import GroupRobotMessenger from './GroupRobot/Messenger';
|
|
12
13
|
import InvoiceClient from './Invoice/InvoiceClient';
|
|
13
14
|
import JssdkClient from './Jssdk/JssdkClient';
|
|
15
|
+
import KfAccountClient from './Kf/KfAccountClient';
|
|
16
|
+
import KfMessageClient from './Kf/KfMessageClient';
|
|
17
|
+
import KfServicerClient from './Kf/KfServicerClient';
|
|
14
18
|
import LiveClient from './Live/LiveClient';
|
|
15
19
|
import MediaClient from './Media/MediaClient';
|
|
16
20
|
import MenuClient from './Menu/MenuClient';
|
|
@@ -36,6 +40,7 @@ export default class Work extends BaseApplication {
|
|
|
36
40
|
oa: OAClient;
|
|
37
41
|
access_token: AccessToken;
|
|
38
42
|
agent: AgentClient;
|
|
43
|
+
agent_workbench: WorkbenchClient;
|
|
39
44
|
base: WorkBase;
|
|
40
45
|
calendar: CalendarClient;
|
|
41
46
|
chat: ChatClient;
|
|
@@ -52,6 +57,9 @@ export default class Work extends BaseApplication {
|
|
|
52
57
|
group_robot_messenger: GroupRobotMessenger;
|
|
53
58
|
invoice: InvoiceClient;
|
|
54
59
|
jssdk: JssdkClient;
|
|
60
|
+
kf_account: KfAccountClient;
|
|
61
|
+
kf_message: KfMessageClient;
|
|
62
|
+
kf_servicer: KfServicerClient;
|
|
55
63
|
live: LiveClient;
|
|
56
64
|
media: MediaClient;
|
|
57
65
|
menu: MenuClient;
|