node-easywechat 3.6.3 → 3.7.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +25 -0
  3. package/dist/Channel/AccessToken.d.ts +8 -0
  4. package/dist/Channel/AccessToken.js +15 -0
  5. package/dist/Channel/Account.d.ts +4 -0
  6. package/dist/Channel/Account.js +8 -0
  7. package/dist/Channel/Application.d.ts +60 -0
  8. package/dist/Channel/Application.js +125 -0
  9. package/dist/Channel/Contracts/AccountInterface.d.ts +23 -0
  10. package/dist/Channel/Contracts/AccountInterface.js +25 -0
  11. package/dist/Channel/Contracts/ApplicationInterface.d.ts +62 -0
  12. package/dist/Channel/Contracts/ApplicationInterface.js +55 -0
  13. package/dist/Channel/Message.d.ts +542 -0
  14. package/dist/Channel/Message.js +9 -0
  15. package/dist/Channel/Server.d.ts +91 -0
  16. package/dist/Channel/Server.js +16 -0
  17. package/dist/Core/Cache/FileCache.js +46 -63
  18. package/dist/Core/Contracts/AccessTokenInterface.js +2 -15
  19. package/dist/Core/Contracts/CacheInterface.js +4 -21
  20. package/dist/Core/Contracts/RefreshableAccessTokenInterface.js +1 -12
  21. package/dist/Core/Contracts/ServerInterface.d.ts +3 -3
  22. package/dist/Core/Contracts/ServerInterface.js +4 -15
  23. package/dist/Core/Http/ServerRequest.js +34 -49
  24. package/dist/Core/HttpClient/AccessTokenAwareClient.js +6 -17
  25. package/dist/Core/HttpClient/Contracts/HttpClientInterface.js +1 -12
  26. package/dist/Core/HttpClient/HttpClient.js +74 -85
  27. package/dist/Core/HttpClient/HttpClientResponse.js +35 -50
  28. package/dist/Core/HttpClient/Mixins/HttpClientMethodsMixin.js +34 -59
  29. package/dist/Core/HttpClient/Mixins/PresetMixin.js +8 -11
  30. package/dist/Core/Message.js +20 -31
  31. package/dist/Core/Mixins/{DecryptXmlMessageMixin.d.ts → DecryptMessageMixin.d.ts} +2 -2
  32. package/dist/Core/Mixins/DecryptMessageMixin.js +34 -0
  33. package/dist/Core/Mixins/HandlersMixin.d.ts +8 -8
  34. package/dist/Core/Mixins/HandlersMixin.js +26 -39
  35. package/dist/Core/Mixins/{ResponseXmlMessageMixin.d.ts → ResponseMessageMixin.d.ts} +4 -3
  36. package/dist/Core/Mixins/ResponseMessageMixin.js +61 -0
  37. package/dist/Core/Support/Utils.js +8 -19
  38. package/dist/MiniApp/Application.js +1 -1
  39. package/dist/MiniApp/Utils.js +13 -24
  40. package/dist/OfficialAccount/AccessToken.js +42 -59
  41. package/dist/OfficialAccount/Application.js +1 -1
  42. package/dist/OfficialAccount/JsApiTicket.js +31 -44
  43. package/dist/OfficialAccount/Server.d.ts +24 -0
  44. package/dist/OfficialAccount/Server.js +25 -37
  45. package/dist/OfficialAccount/Utils.js +6 -17
  46. package/dist/OpenPlatform/Application.js +62 -86
  47. package/dist/OpenPlatform/Authorizer/MiniApp/Utils.js +14 -25
  48. package/dist/OpenPlatform/AuthorizerAccessToken.js +6 -19
  49. package/dist/OpenPlatform/ComponentAccessToken.js +27 -42
  50. package/dist/OpenPlatform/Server.js +31 -54
  51. package/dist/OpenPlatform/VerifyTicket.js +14 -27
  52. package/dist/OpenWork/Application.js +61 -84
  53. package/dist/OpenWork/AuthorizerAccessToken.js +32 -47
  54. package/dist/OpenWork/JsApiTicket.js +64 -81
  55. package/dist/OpenWork/ProviderAccessToken.js +26 -41
  56. package/dist/OpenWork/Server.js +50 -94
  57. package/dist/OpenWork/SuiteAccessToken.js +27 -42
  58. package/dist/OpenWork/SuiteTicket.js +14 -27
  59. package/dist/Pay/Application.js +1 -2
  60. package/dist/Pay/Client.js +63 -77
  61. package/dist/Pay/LegacySignature.js +2 -3
  62. package/dist/Pay/Merchant.js +36 -52
  63. package/dist/Pay/Server.js +55 -70
  64. package/dist/Pay/Utils.js +13 -26
  65. package/dist/Pay/Validator.js +28 -39
  66. package/dist/Types/global.d.ts +31 -0
  67. package/dist/Work/AccessToken.js +26 -41
  68. package/dist/Work/Application.js +21 -32
  69. package/dist/Work/JsApiTicket.js +60 -77
  70. package/dist/Work/Server.js +47 -86
  71. package/dist/Work/Utils.js +12 -25
  72. package/dist/index.d.ts +14 -2
  73. package/dist/index.js +19 -1
  74. package/package.json +1 -1
  75. package/tsconfig.json +2 -2
  76. package/dist/Core/Mixins/DecryptXmlMessageMixin.js +0 -38
  77. package/dist/Core/Mixins/ResponseXmlMessageMixin.js +0 -63
@@ -1,63 +0,0 @@
1
- 'use strict';
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- const merge_1 = __importDefault(require("merge"));
15
- const Response_1 = __importDefault(require("../Http/Response"));
16
- const Utils_1 = require("../Support/Utils");
17
- class ResponseXmlMessageMixin {
18
- /**
19
- * 转化为回复消息
20
- * @returns
21
- */
22
- transformToReply(response_1, message_1) {
23
- return __awaiter(this, arguments, void 0, function* (response, message, encryptor = null) {
24
- if (!response || response === true) {
25
- return new Response_1.default(200, {}, 'success');
26
- }
27
- let attributes = merge_1.default.recursive({
28
- ToUserName: message['FromUserName'],
29
- FromUserName: message['ToUserName'],
30
- CreateTime: (0, Utils_1.getTimestamp)(),
31
- }, yield this.normalizeResponse(response));
32
- return this.createXmlResponse(attributes, encryptor);
33
- });
34
- }
35
- normalizeResponse(response) {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- if (typeof response === 'function') {
38
- response = yield response();
39
- }
40
- if (typeof response === 'object') {
41
- if (!response['MsgType']) {
42
- throw new Error('`MsgType` cannot be empty.');
43
- }
44
- return response;
45
- }
46
- if (typeof response === 'string' || typeof response === 'number') {
47
- return {
48
- MsgType: 'text',
49
- Content: response,
50
- };
51
- }
52
- throw new Error(`Invalid Response "${response.toString()}".`);
53
- });
54
- }
55
- createXmlResponse(attributes, encryptor = null) {
56
- let xml = (0, Utils_1.buildXml)(attributes);
57
- return new Response_1.default(200, {
58
- 'Content-Type': 'application/xml'
59
- }, encryptor ? encryptor.encrypt(xml) : xml);
60
- }
61
- }
62
- ;
63
- module.exports = ResponseXmlMessageMixin;