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 +4 -0
- package/dist/Pay/Encryptor.d.ts +18 -0
- package/dist/Pay/Encryptor.js +25 -0
- package/dist/Pay/Utils.d.ts +2 -2
- package/dist/Pay/Utils.js +4 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -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;
|
package/dist/Pay/Utils.d.ts
CHANGED
|
@@ -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<
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
return
|
|
45
|
+
let encryptor = new Encryptor_1.default;
|
|
46
|
+
encryptor.setCerts(platformCert, this.merchant.getPrivateKey());
|
|
47
|
+
return encryptor;
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
/**
|