node-easywechat 3.5.14 → 3.5.15

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 CHANGED
@@ -1,6 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
3
 
4
+ ## v3.5.15 (2023-12-20)
5
+
6
+ - Fix: 微信支付的敏感信息加密机增加获取公钥序列号的方法 (#57)
7
+
4
8
  ## v3.5.14 (2023-12-20)
5
9
 
6
10
  - Fix: 修复个别情况下微信支付的敏感信息加密功能可能使用旧证书的问题 (#57)
@@ -0,0 +1,18 @@
1
+ import { PrivateKey } from "../Core/Support/PrivateKey";
2
+ import { PublicKey } from "../Core/Support/PublicKey";
3
+ import RSA from "../Core/Support/RSA";
4
+ declare class Encryptor extends RSA {
5
+ protected publicCert: PublicKey;
6
+ protected privateCert: PrivateKey;
7
+ /**
8
+ * 设置加密机所需的公私密钥
9
+ * @param publicCert PublicKey封装的公钥
10
+ * @param privateCert PrivateKey封装的私钥
11
+ */
12
+ setCerts(publicCert: PublicKey, privateCert: PrivateKey): void;
13
+ /**
14
+ * 获取公钥的序列号
15
+ */
16
+ getSerialNo(): string;
17
+ }
18
+ export = Encryptor;
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ const RSA_1 = __importDefault(require("../Core/Support/RSA"));
6
+ class Encryptor extends RSA_1.default {
7
+ /**
8
+ * 设置加密机所需的公私密钥
9
+ * @param publicCert PublicKey封装的公钥
10
+ * @param privateCert PrivateKey封装的私钥
11
+ */
12
+ setCerts(publicCert, privateCert) {
13
+ this.publicCert = publicCert;
14
+ this.privateCert = privateCert;
15
+ this.setPublicKey(publicCert.toString());
16
+ this.setPrivateKey(privateCert.toString());
17
+ }
18
+ /**
19
+ * 获取公钥的序列号
20
+ */
21
+ getSerialNo() {
22
+ return this.publicCert.getSerialNo();
23
+ }
24
+ }
25
+ module.exports = Encryptor;
@@ -1,7 +1,7 @@
1
1
  import { PublicKey } from '../Core/Support/PublicKey';
2
- import RSA from '../Core/Support/RSA';
3
2
  import { PayAppConfig, PayBridgeConfig, PaySdkConfig } from '../Types/global';
4
3
  import MerchantInterface from './Contracts/MerchantInterface';
4
+ import Encryptor from './Encryptor';
5
5
  declare class Utils {
6
6
  protected merchant: MerchantInterface;
7
7
  constructor(merchant: MerchantInterface);
@@ -15,7 +15,7 @@ declare class Utils {
15
15
  * @param platformCert PublicKey封装过的平台证书
16
16
  * @returns
17
17
  */
18
- getEncryptor(platformCert?: PublicKey): Promise<RSA>;
18
+ getEncryptor(platformCert?: PublicKey): Promise<Encryptor>;
19
19
  /**
20
20
  * 创建签名(V3),并返回签名字符串
21
21
  * @param params 参数集合
package/dist/Pay/Utils.js CHANGED
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  const PublicKey_1 = require("../Core/Support/PublicKey");
15
15
  const RSA_1 = __importDefault(require("../Core/Support/RSA"));
16
16
  const Utils_1 = require("../Core/Support/Utils");
17
+ const Encryptor_1 = __importDefault(require("./Encryptor"));
17
18
  class Utils {
18
19
  constructor(merchant) {
19
20
  this.merchant = merchant;
@@ -38,13 +39,12 @@ class Utils {
38
39
  */
39
40
  getEncryptor(platformCert = null) {
40
41
  return __awaiter(this, void 0, void 0, function* () {
41
- let rsa = new RSA_1.default;
42
42
  if (!platformCert || !(platformCert instanceof PublicKey_1.PublicKey)) {
43
43
  platformCert = yield this.getPlatformCert();
44
44
  }
45
- rsa.setPublicKey(platformCert.toString());
46
- rsa.setPrivateKey(this.merchant.getPrivateKey().toString());
47
- return rsa;
45
+ let encryptor = new Encryptor_1.default;
46
+ encryptor.setCerts(platformCert, this.merchant.getPrivateKey());
47
+ return encryptor;
48
48
  });
49
49
  }
50
50
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-easywechat",
3
- "version": "3.5.14",
3
+ "version": "3.5.15",
4
4
  "description": "EasyWechat SDK for Node.js (NOT OFFICIAL)",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {