node-easywechat 3.3.5 → 3.3.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 +4 -0
- package/dist/Core/Support/RSA.d.ts +5 -7
- package/dist/Core/Support/RSA.js +11 -16
- package/dist/Pay/Application.js +1 -1
- package/dist/Pay/Signature.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import crypto from 'crypto';
|
|
2
|
+
import crypto, { BinaryToTextEncoding } from 'crypto';
|
|
3
3
|
declare class RSA {
|
|
4
4
|
protected publicKey: crypto.KeyObject;
|
|
5
5
|
/**
|
|
@@ -40,21 +40,19 @@ declare class RSA {
|
|
|
40
40
|
/**
|
|
41
41
|
* 计算签名
|
|
42
42
|
* @param data 待解密文本
|
|
43
|
-
* @param hashType 哈希方式,默认:'
|
|
43
|
+
* @param hashType 哈希方式,默认:'RSA-SHA256'
|
|
44
44
|
* @param encoding 编码,默认:'base64'
|
|
45
|
-
* @param padding 补位方式,默认:crypto.constants.RSA_PKCS1_PSS_PADDING
|
|
46
45
|
* @returns
|
|
47
46
|
*/
|
|
48
|
-
sign(data: string, hashType?: string, encoding?:
|
|
47
|
+
sign(data: string, hashType?: string, encoding?: BinaryToTextEncoding): string;
|
|
49
48
|
/**
|
|
50
49
|
* 验证签名
|
|
51
50
|
* @param signature 待验证签名字符串
|
|
52
51
|
* @param data 待解密文本
|
|
53
|
-
* @param hashType 哈希方式,默认:'
|
|
52
|
+
* @param hashType 哈希方式,默认:'RSA-SHA256'
|
|
54
53
|
* @param encoding 编码,默认:'base64'
|
|
55
|
-
* @param padding 补位方式,默认:crypto.constants.RSA_PKCS1_PSS_PADDING
|
|
56
54
|
* @returns
|
|
57
55
|
*/
|
|
58
|
-
verify(signature: string, data: string, hashType
|
|
56
|
+
verify(signature: string, data: string, hashType?: string, encoding?: BinaryToTextEncoding): boolean;
|
|
59
57
|
}
|
|
60
58
|
export = RSA;
|
package/dist/Core/Support/RSA.js
CHANGED
|
@@ -65,33 +65,28 @@ class RSA {
|
|
|
65
65
|
/**
|
|
66
66
|
* 计算签名
|
|
67
67
|
* @param data 待解密文本
|
|
68
|
-
* @param hashType 哈希方式,默认:'
|
|
68
|
+
* @param hashType 哈希方式,默认:'RSA-SHA256'
|
|
69
69
|
* @param encoding 编码,默认:'base64'
|
|
70
|
-
* @param padding 补位方式,默认:crypto.constants.RSA_PKCS1_PSS_PADDING
|
|
71
70
|
* @returns
|
|
72
71
|
*/
|
|
73
|
-
sign(data, hashType = '
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return signature.toString(encoding);
|
|
72
|
+
sign(data, hashType = 'RSA-SHA256', encoding = 'base64') {
|
|
73
|
+
return crypto_1.default
|
|
74
|
+
.createSign(hashType)
|
|
75
|
+
.update(data)
|
|
76
|
+
.sign(this.privateKey, encoding);
|
|
79
77
|
}
|
|
80
78
|
/**
|
|
81
79
|
* 验证签名
|
|
82
80
|
* @param signature 待验证签名字符串
|
|
83
81
|
* @param data 待解密文本
|
|
84
|
-
* @param hashType 哈希方式,默认:'
|
|
82
|
+
* @param hashType 哈希方式,默认:'RSA-SHA256'
|
|
85
83
|
* @param encoding 编码,默认:'base64'
|
|
86
|
-
* @param padding 补位方式,默认:crypto.constants.RSA_PKCS1_PSS_PADDING
|
|
87
84
|
* @returns
|
|
88
85
|
*/
|
|
89
|
-
verify(signature, data, hashType
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}, Buffer.from(signature, encoding));
|
|
94
|
-
return !!isVerified;
|
|
86
|
+
verify(signature, data, hashType = 'RSA-SHA256', encoding = 'base64') {
|
|
87
|
+
const verify = crypto_1.default.createVerify(hashType);
|
|
88
|
+
verify.update(data);
|
|
89
|
+
return verify.verify(this.publicKey, signature, encoding);
|
|
95
90
|
}
|
|
96
91
|
}
|
|
97
92
|
;
|
package/dist/Pay/Application.js
CHANGED
package/dist/Pay/Signature.js
CHANGED
|
@@ -34,7 +34,7 @@ class Signature {
|
|
|
34
34
|
body = payload.data;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
let signString = `${method.toUpperCase()}\n${pathname}\n${timestamp}\n${nonce}\n${body}`;
|
|
37
|
+
let signString = `${method.toUpperCase()}\n${pathname}\n${timestamp}\n${nonce}\n${body}\n`;
|
|
38
38
|
let rsa = new RSA_1.default;
|
|
39
39
|
rsa.setPublicKey(this.merchant.getCertificate().getValue());
|
|
40
40
|
rsa.setPrivateKey(this.merchant.getPrivateKey().getKey());
|