node-easywechat 3.5.5 → 3.5.6
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/CHANGELOG.md +6 -0
- package/dist/Core/Http/ServerRequest.d.ts +1 -0
- package/dist/Core/HttpClient/HttpClientResponse.js +4 -5
- package/dist/Core/Support/AES.d.ts +2 -0
- package/dist/Core/Support/RSA.d.ts +1 -0
- package/dist/OpenPlatform/Application.js +19 -6
- package/dist/OpenPlatform/Server.js +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -12,7 +12,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
const fs_1 = __importDefault(require("fs"));
|
|
15
|
-
const merge_1 = __importDefault(require("merge"));
|
|
16
15
|
const Utils_1 = require("../Support/Utils");
|
|
17
16
|
class HttpClientResponse {
|
|
18
17
|
constructor(response, failureJudge = null, throwError = false) {
|
|
@@ -46,7 +45,7 @@ class HttpClientResponse {
|
|
|
46
45
|
return;
|
|
47
46
|
}
|
|
48
47
|
if (typeof content === 'string') {
|
|
49
|
-
if (this.is('xml')
|
|
48
|
+
if (this.is('xml') || content.indexOf('<xml>') > -1) {
|
|
50
49
|
this.parsedContent = yield (0, Utils_1.parseXml)(content);
|
|
51
50
|
}
|
|
52
51
|
else if (this.is('json')) {
|
|
@@ -59,7 +58,7 @@ class HttpClientResponse {
|
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
|
-
else
|
|
61
|
+
else {
|
|
63
62
|
try {
|
|
64
63
|
this.parsedContent = (0, Utils_1.parseQueryString)(content);
|
|
65
64
|
}
|
|
@@ -67,6 +66,7 @@ class HttpClientResponse {
|
|
|
67
66
|
if (throwError) {
|
|
68
67
|
throw new Error('Fail to parse QueryString content.');
|
|
69
68
|
}
|
|
69
|
+
this.parsedContent = {};
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
}
|
|
@@ -216,13 +216,12 @@ class HttpClientResponse {
|
|
|
216
216
|
return this.response.status;
|
|
217
217
|
}
|
|
218
218
|
getHeaders(throwError) {
|
|
219
|
-
let headers = merge_1.default.recursive(true, this.response.headers);
|
|
220
219
|
for (let key in this.response.headers) {
|
|
221
220
|
if (key !== key.toLowerCase()) {
|
|
222
221
|
this.response.headers[key.toLowerCase()] = this.response.headers[key];
|
|
223
222
|
}
|
|
224
223
|
}
|
|
225
|
-
return headers;
|
|
224
|
+
return this.response.headers;
|
|
226
225
|
}
|
|
227
226
|
getContent(throwError) {
|
|
228
227
|
return this.response.data;
|
|
@@ -101,6 +101,15 @@ class Application {
|
|
|
101
101
|
else {
|
|
102
102
|
this.server.setRequest(this.getRequest());
|
|
103
103
|
}
|
|
104
|
+
if (this.server instanceof Server_1.default) {
|
|
105
|
+
this.server.withDefaultVerifyTicketHandler((message, next) => {
|
|
106
|
+
const ticket = this.getVerifyTicket();
|
|
107
|
+
if (typeof ticket.setTicket === 'function') {
|
|
108
|
+
ticket.setTicket(message.get('ComponentVerifyTicket'));
|
|
109
|
+
}
|
|
110
|
+
return next(message);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
104
113
|
return this.server;
|
|
105
114
|
}
|
|
106
115
|
/**
|
|
@@ -236,7 +245,7 @@ class Application {
|
|
|
236
245
|
* @param config
|
|
237
246
|
* @returns
|
|
238
247
|
*/
|
|
239
|
-
getOfficialAccountWithRefreshToken(appId, refreshToken, config =
|
|
248
|
+
getOfficialAccountWithRefreshToken(appId, refreshToken, config = {}) {
|
|
240
249
|
return __awaiter(this, void 0, void 0, function* () {
|
|
241
250
|
return this.getOfficialAccountWithAccessToken(appId, yield this.getAuthorizerAccessToken(appId, refreshToken), config);
|
|
242
251
|
});
|
|
@@ -248,7 +257,7 @@ class Application {
|
|
|
248
257
|
* @param config
|
|
249
258
|
* @returns
|
|
250
259
|
*/
|
|
251
|
-
getOfficialAccountWithAccessToken(appId, accessToken, config =
|
|
260
|
+
getOfficialAccountWithAccessToken(appId, accessToken, config = {}) {
|
|
252
261
|
return this.getOfficialAccount(new AuthorizerAccessToken_1.default(appId, accessToken), config);
|
|
253
262
|
}
|
|
254
263
|
/**
|
|
@@ -257,8 +266,10 @@ class Application {
|
|
|
257
266
|
* @param config
|
|
258
267
|
* @returns
|
|
259
268
|
*/
|
|
260
|
-
getOfficialAccount(authorizerAccessToken, config =
|
|
269
|
+
getOfficialAccount(authorizerAccessToken, config = {}) {
|
|
261
270
|
if (!(config instanceof ConfigInterface_1.default)) {
|
|
271
|
+
if (typeof config !== 'object' || config === null)
|
|
272
|
+
config = {};
|
|
262
273
|
config.app_id = authorizerAccessToken.getAppId();
|
|
263
274
|
config.token = this.config.get('token');
|
|
264
275
|
config.aes_key = this.config.get('aes_key');
|
|
@@ -302,7 +313,7 @@ class Application {
|
|
|
302
313
|
* @param config
|
|
303
314
|
* @returns
|
|
304
315
|
*/
|
|
305
|
-
getMiniAppWithRefreshToken(appId, refreshToken, config =
|
|
316
|
+
getMiniAppWithRefreshToken(appId, refreshToken, config = {}) {
|
|
306
317
|
return __awaiter(this, void 0, void 0, function* () {
|
|
307
318
|
return this.getMiniAppWithAccessToken(appId, yield this.getAuthorizerAccessToken(appId, refreshToken), config);
|
|
308
319
|
});
|
|
@@ -314,7 +325,7 @@ class Application {
|
|
|
314
325
|
* @param config
|
|
315
326
|
* @returns
|
|
316
327
|
*/
|
|
317
|
-
getMiniAppWithAccessToken(appId, accessToken, config =
|
|
328
|
+
getMiniAppWithAccessToken(appId, accessToken, config = {}) {
|
|
318
329
|
return this.getMiniApp(new AuthorizerAccessToken_1.default(appId, accessToken), config);
|
|
319
330
|
}
|
|
320
331
|
/**
|
|
@@ -323,8 +334,10 @@ class Application {
|
|
|
323
334
|
* @param config
|
|
324
335
|
* @returns
|
|
325
336
|
*/
|
|
326
|
-
getMiniApp(authorizerAccessToken, config =
|
|
337
|
+
getMiniApp(authorizerAccessToken, config = {}) {
|
|
327
338
|
if (!(config instanceof ConfigInterface_1.default)) {
|
|
339
|
+
if (typeof config !== 'object' || config === null)
|
|
340
|
+
config = {};
|
|
328
341
|
config.app_id = authorizerAccessToken.getAppId();
|
|
329
342
|
config.token = this.config.get('token');
|
|
330
343
|
config.aes_key = this.config.get('aes_key');
|
|
@@ -82,8 +82,8 @@ class Server extends ServerInterface_1.default {
|
|
|
82
82
|
* @returns
|
|
83
83
|
*/
|
|
84
84
|
withDefaultVerifyTicketHandler(handler) {
|
|
85
|
-
this.defaultVerifyTicketHandler = ()
|
|
86
|
-
return handler.
|
|
85
|
+
this.defaultVerifyTicketHandler = function () {
|
|
86
|
+
return handler.apply(this, arguments);
|
|
87
87
|
};
|
|
88
88
|
this.handleVerifyTicketRefreshed(this.defaultVerifyTicketHandler);
|
|
89
89
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-easywechat",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.6",
|
|
4
4
|
"description": "EasyWechat SDK for Node.js (NOT OFFICIAL)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^17.0.23",
|
|
26
|
-
"axios-mock-adapter": "^1.
|
|
26
|
+
"axios-mock-adapter": "^1.22.0",
|
|
27
27
|
"mocha": "^9.2.2",
|
|
28
28
|
"package-release": "^1.0.3",
|
|
29
29
|
"typescript": "^4.6.3"
|