node-easywechat 2.6.9 → 2.7.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.
Files changed (53) hide show
  1. package/README.md +34 -4
  2. package/dist/BaseService/ContentSecurity/ContentSecurityClient.d.ts +5 -3
  3. package/dist/BaseService/ContentSecurity/ContentSecurityClient.js +2 -2
  4. package/dist/BaseService/Jssdk/JssdkClient.d.ts +15 -15
  5. package/dist/BaseService/Jssdk/JssdkClient.js +15 -15
  6. package/dist/BaseService/Media/MediaClient.d.ts +22 -20
  7. package/dist/BaseService/Media/MediaClient.js +14 -14
  8. package/dist/BaseService/Url/UrlClient.d.ts +1 -1
  9. package/dist/Core/AES.d.ts +46 -0
  10. package/dist/Core/AES.js +95 -0
  11. package/dist/Core/BaseApplication.js +9 -5
  12. package/dist/Core/Encryptor.d.ts +2 -14
  13. package/dist/Core/Encryptor.js +9 -39
  14. package/dist/Core/Http/Request.js +2 -6
  15. package/dist/Core/Messages/Message.js +2 -16
  16. package/dist/Core/PKCS.d.ts +15 -0
  17. package/dist/Core/PKCS.js +44 -0
  18. package/dist/Core/RSA.d.ts +59 -0
  19. package/dist/Core/RSA.js +99 -0
  20. package/dist/Core/ServerGuard.d.ts +1 -1
  21. package/dist/Core/ServerGuard.js +5 -33
  22. package/dist/Core/Types.d.ts +29 -4
  23. package/dist/Core/Utils.d.ts +8 -2
  24. package/dist/Core/Utils.js +61 -20
  25. package/dist/MicroMerchant/Application.d.ts +27 -0
  26. package/dist/MicroMerchant/Application.js +105 -0
  27. package/dist/MicroMerchant/Base/MicroMerchantBase.d.ts +7 -0
  28. package/dist/MicroMerchant/Base/MicroMerchantBase.js +52 -0
  29. package/dist/MicroMerchant/Certficates/CertficatesClient.d.ts +5 -0
  30. package/dist/MicroMerchant/Certficates/CertficatesClient.js +52 -0
  31. package/dist/MicroMerchant/Core/BaseClient.d.ts +9 -0
  32. package/dist/MicroMerchant/Core/BaseClient.js +106 -0
  33. package/dist/MicroMerchant/Media/MediaClient.d.ts +6 -0
  34. package/dist/MicroMerchant/Media/MediaClient.js +33 -0
  35. package/dist/MicroMerchant/MerchantConfig/MerchantConfigClient.d.ts +8 -0
  36. package/dist/MicroMerchant/MerchantConfig/MerchantConfigClient.js +49 -0
  37. package/dist/MicroMerchant/Meterial/MeterialClient.d.ts +5 -0
  38. package/dist/MicroMerchant/Meterial/MeterialClient.js +30 -0
  39. package/dist/MicroMerchant/Withdraw/WithdrawClient.d.ts +5 -0
  40. package/dist/MicroMerchant/Withdraw/WithdrawClient.js +28 -0
  41. package/dist/MiniProgram/Encryptor.js +2 -6
  42. package/dist/Payment/Bill/BillClient.js +1 -1
  43. package/dist/Payment/Core/BaseClient.d.ts +0 -1
  44. package/dist/Payment/Core/BaseClient.js +2 -20
  45. package/dist/Payment/Notify/Handler.js +3 -11
  46. package/dist/Payment/Notify/Refunded.d.ts +0 -1
  47. package/dist/Payment/Notify/Refunded.js +1 -11
  48. package/dist/Payment/Transfer/TransferClient.js +4 -3
  49. package/dist/index.d.ts +6 -0
  50. package/dist/index.js +2 -0
  51. package/node-easywechat.file_cache.easywechat.kernel.access_token.8a9684b45da7de42a06a70ba01a7005a.cache +1 -1
  52. package/node-easywechat.file_cache.easywechat.kernel.access_token.c3d06edaf326aad75d32f31348df787a.cache +1 -1
  53. package/package.json +9 -7
@@ -12,9 +12,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const xml2js_1 = __importDefault(require("xml2js"));
16
15
  const Utils_1 = require("../../Core/Utils");
17
16
  const Response_1 = __importDefault(require("../../Core/Http/Response"));
17
+ const AES_1 = require("../../Core/AES");
18
18
  class Handler {
19
19
  constructor(app) {
20
20
  this.SUCCESS = 'SUCCESS';
@@ -54,15 +54,7 @@ class Handler {
54
54
  if (this.sign) {
55
55
  attributes['sign'] = Utils_1.makeSignature(attributes, yield this.app.getKey());
56
56
  }
57
- let XmlBuilder = new xml2js_1.default.Builder({
58
- cdata: true,
59
- renderOpts: {
60
- pretty: false,
61
- indent: '',
62
- newline: '',
63
- }
64
- });
65
- return new Response_1.default(XmlBuilder.buildObject(attributes));
57
+ return new Response_1.default(Buffer.from(Utils_1.buildXml(attributes)));
66
58
  });
67
59
  }
68
60
  getMessage() {
@@ -84,7 +76,7 @@ class Handler {
84
76
  if (!message[key]) {
85
77
  return null;
86
78
  }
87
- return Utils_1.AesDecrypt(message[key], Utils_1.createHash(this.app.config.key, 'md5'), '', 'AES-256-ECB');
79
+ return AES_1.AES.decrypt(Buffer.from(message[key], 'base64'), Utils_1.createHash(this.app.config.key, 'md5'), '', true, 'aes-256-ecb').toString();
88
80
  });
89
81
  }
90
82
  validate(message) {
@@ -4,5 +4,4 @@ import { PaymentRefundedHandler } from '../../Core/Types';
4
4
  export default class RefundedHandler extends Handler {
5
5
  handle(closure: PaymentRefundedHandler): Promise<Response>;
6
6
  reqInfo(): Promise<any>;
7
- parseXml(xml: string): Promise<any>;
8
7
  }
@@ -13,7 +13,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const Handler_1 = __importDefault(require("./Handler"));
16
- const xml2js_1 = __importDefault(require("xml2js"));
17
16
  const Utils_1 = require("../../Core/Utils");
18
17
  class RefundedHandler extends Handler_1.default {
19
18
  handle(closure) {
@@ -33,16 +32,7 @@ class RefundedHandler extends Handler_1.default {
33
32
  }
34
33
  reqInfo() {
35
34
  return __awaiter(this, void 0, void 0, function* () {
36
- return yield this.parseXml(yield this.decryptMessage('req_info'));
37
- });
38
- }
39
- parseXml(xml) {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- let res = yield xml2js_1.default.parseStringPromise(xml);
42
- res = Utils_1.singleItem(res);
43
- if (res['xml'])
44
- res = res['xml'];
45
- return res;
35
+ return yield Utils_1.parseXml(yield this.decryptMessage('req_info'));
46
36
  });
47
37
  }
48
38
  }
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const BaseClient_1 = __importDefault(require("../Core/BaseClient"));
16
16
  const fs_1 = __importDefault(require("fs"));
17
- const node_rsa_1 = __importDefault(require("node-rsa"));
17
+ const RSA_1 = __importDefault(require("../../Core/RSA"));
18
18
  const Utils_1 = require("../../Core/Utils");
19
19
  class TransferClient extends BaseClient_1.default {
20
20
  /**
@@ -67,8 +67,9 @@ class TransferClient extends BaseClient_1.default {
67
67
  throw new Error(`${key} is required.`);
68
68
  }
69
69
  });
70
- let publicKey = fs_1.default.readFileSync(this.app.config.rsa_public_key_path).toString();
71
- let rsa = new node_rsa_1.default(publicKey);
70
+ let publicKey = fs_1.default.readFileSync(this.app.config.rsa_public_key_path);
71
+ let rsa = new RSA_1.default;
72
+ rsa.setPublicKey(publicKey);
72
73
  params['enc_bank_no'] = rsa.encrypt(params['enc_bank_no'], 'hex');
73
74
  params['enc_true_name'] = rsa.encrypt(params['enc_true_name'], 'hex');
74
75
  return this.safeRequest('mmpaymkttransfers/pay_bank', params);
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ import MiniProgram from './MiniProgram/Application';
4
4
  import OpenPlatform from './OpenPlatform/Application';
5
5
  import Payment from './Payment/Application';
6
6
  import Work from './Work/Application';
7
+ import MicroMerchant from './MicroMerchant/Application';
7
8
  import CacheInterface from './Core/Contracts/CacheInterface';
8
9
  import FinallResult from './Core/Decorators/FinallResult';
9
10
  import TerminateResult from './Core/Decorators/TerminateResult';
@@ -23,6 +24,7 @@ declare function getInstance(service: 'MiniProgram', config?: EasyWechatConfig):
23
24
  declare function getInstance(service: 'OpenPlatform', config?: EasyWechatConfig): OpenPlatform;
24
25
  declare function getInstance(service: 'Payment', config?: EasyWechatConfig): Payment;
25
26
  declare function getInstance(service: 'Work', config?: EasyWechatConfig): Work;
27
+ declare function getInstance(service: 'MicroMerchant', config?: EasyWechatConfig): MicroMerchant;
26
28
  declare class EasyWechat {
27
29
  /**
28
30
  * 实例工厂
@@ -52,6 +54,10 @@ declare class EasyWechat {
52
54
  * 企业微信类
53
55
  */
54
56
  Work: typeof Work;
57
+ /**
58
+ * 小微商户类
59
+ */
60
+ MicroMerchant: typeof MicroMerchant;
55
61
  /**
56
62
  * 通用获取实例方法
57
63
  * @param service 服务名称,可选值:'BaseService' | 'OfficialAccount' | 'MiniProgram' | 'OpenPlatform' | 'Payment'
package/dist/index.js CHANGED
@@ -28,6 +28,7 @@ const Application_3 = __importDefault(require("./MiniProgram/Application"));
28
28
  const Application_4 = __importDefault(require("./OpenPlatform/Application"));
29
29
  const Application_5 = __importDefault(require("./Payment/Application"));
30
30
  const Application_6 = __importDefault(require("./Work/Application"));
31
+ const Application_7 = __importDefault(require("./MicroMerchant/Application"));
31
32
  const CacheInterface_1 = __importDefault(require("./Core/Contracts/CacheInterface"));
32
33
  const FinallResult_1 = __importDefault(require("./Core/Decorators/FinallResult"));
33
34
  const TerminateResult_1 = __importDefault(require("./Core/Decorators/TerminateResult"));
@@ -63,6 +64,7 @@ class EasyWechat {
63
64
  OpenPlatform: Application_4.default,
64
65
  Payment: Application_5.default,
65
66
  Work: Application_6.default,
67
+ MicroMerchant: Application_7.default,
66
68
  getInstance: getInstance,
67
69
  };
68
70
  this.CacheInterface = CacheInterface_1.default;
@@ -1 +1 @@
1
- {"data":{"errcode":0,"errmsg":"ok","access_token":"moke-token","expires_in":7200},"lifeTime":1627580367}
1
+ {"data":{"errcode":0,"errmsg":"ok","access_token":"moke-token","expires_in":7200},"lifeTime":1633062831}
@@ -1 +1 @@
1
- {"data":{"errcode":0,"errmsg":"ok"},"lifeTime":1627580367}
1
+ {"data":{"errcode":0,"errmsg":"ok"},"lifeTime":1633062831}
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "node-easywechat",
3
- "version": "2.6.9",
3
+ "version": "2.7.2",
4
4
  "description": "EasyWechat SDK for Node.js (NOT OFFICIAL)",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
- "build": "rm -rf dist && node_modules/.bin/tsc",
8
- "test": "mocha ./test/**/*.js"
7
+ "build": "rm -rf dist && npx tsc",
8
+ "docs": "rm -rf doc && npx typedoc --out docs --plugin typedoc-plugin-markdown ./src/",
9
+ "test": "npx mocha ./test/**/*.js"
9
10
  },
10
11
  "repository": {
11
12
  "type": "git",
@@ -21,14 +22,15 @@
21
22
  "@types/node": "^12.12.7",
22
23
  "mocha": "^8.3.0",
23
24
  "sinon": "^9.2.4",
25
+ "typedoc": "^0.21.5",
26
+ "typedoc-plugin-markdown": "^3.10.4",
24
27
  "typescript": "^4.2.3"
25
28
  },
26
29
  "dependencies": {
27
- "axios": "^0.21.1",
30
+ "axios": "^0.21.4",
28
31
  "form-data": "^4.0.0",
29
- "node-rsa": "^1.1.1",
30
- "node-socialite": "^1.2.3",
31
- "qs": "^6.9.6",
32
+ "node-socialite": "^1.2.4",
33
+ "qs": "^6.10.1",
32
34
  "raw-body": "^2.4.1",
33
35
  "xml2js": "^0.4.23"
34
36
  }