node-easywechat 3.5.18 → 3.5.20
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 +9 -0
- package/dist/Core/Http/ServerRequest.js +1 -1
- package/dist/Pay/Encryptor.d.ts +23 -0
- package/dist/Pay/Encryptor.js +27 -0
- package/dist/Pay/Utils.d.ts +1 -0
- package/dist/Pay/Utils.js +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +5 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -138,7 +138,7 @@ class ServerRequest {
|
|
|
138
138
|
static createFromIncomingMessage(req, body = null) {
|
|
139
139
|
return __awaiter(this, void 0, void 0, function* () {
|
|
140
140
|
let request = new ServerRequest(req.method, req.url, req.headers || {}, body, req.httpVersion);
|
|
141
|
-
if (!body) {
|
|
141
|
+
if (req.method.toUpperCase() === 'POST' && !body) {
|
|
142
142
|
let res = yield (0, raw_body_1.default)(req);
|
|
143
143
|
request.withBody(res);
|
|
144
144
|
}
|
package/dist/Pay/Encryptor.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { PrivateKey } from "../Core/Support/PrivateKey";
|
|
2
3
|
import { PublicKey } from "../Core/Support/PublicKey";
|
|
3
4
|
import RSA from "../Core/Support/RSA";
|
|
5
|
+
/**
|
|
6
|
+
* 敏感信息加解密
|
|
7
|
+
* @see https://pay.weixin.qq.com/docs/merchant/development/interface-rules/sensitive-data-encryption.html
|
|
8
|
+
*/
|
|
4
9
|
declare class Encryptor extends RSA {
|
|
5
10
|
protected publicCert: PublicKey;
|
|
6
11
|
protected privateCert: PrivateKey;
|
|
@@ -14,5 +19,23 @@ declare class Encryptor extends RSA {
|
|
|
14
19
|
* 获取公钥的序列号
|
|
15
20
|
*/
|
|
16
21
|
getSerialNo(): string;
|
|
22
|
+
/**
|
|
23
|
+
* 加密
|
|
24
|
+
* @param plaintext 待加密文本
|
|
25
|
+
* @param encoding 编码,默认:'base64'
|
|
26
|
+
* @param hashType 哈希方式,默认:'sha1'
|
|
27
|
+
* @param padding 补位方式,默认:crypto.constants.RSA_PKCS1_OAEP_PADDING
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
encrypt(plaintext: string, encoding?: BufferEncoding, hashType?: string, padding?: number): string;
|
|
31
|
+
/**
|
|
32
|
+
* 解密
|
|
33
|
+
* @param ciphertext 待解密文本
|
|
34
|
+
* @param encoding 编码,默认:'base64'
|
|
35
|
+
* @param hashType 哈希方式,默认:'sha1'
|
|
36
|
+
* @param padding 补位方式,默认:crypto.constants.RSA_PKCS1_OAEP_PADDING
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
decrypt(ciphertext: string, encoding?: BufferEncoding, hashType?: string, padding?: number): string;
|
|
17
40
|
}
|
|
18
41
|
export = Encryptor;
|
package/dist/Pay/Encryptor.js
CHANGED
|
@@ -3,6 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
const RSA_1 = __importDefault(require("../Core/Support/RSA"));
|
|
6
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
7
|
+
/**
|
|
8
|
+
* 敏感信息加解密
|
|
9
|
+
* @see https://pay.weixin.qq.com/docs/merchant/development/interface-rules/sensitive-data-encryption.html
|
|
10
|
+
*/
|
|
6
11
|
class Encryptor extends RSA_1.default {
|
|
7
12
|
/**
|
|
8
13
|
* 设置加密机所需的公私密钥
|
|
@@ -21,5 +26,27 @@ class Encryptor extends RSA_1.default {
|
|
|
21
26
|
getSerialNo() {
|
|
22
27
|
return this.publicCert.getSerialNo();
|
|
23
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* 加密
|
|
31
|
+
* @param plaintext 待加密文本
|
|
32
|
+
* @param encoding 编码,默认:'base64'
|
|
33
|
+
* @param hashType 哈希方式,默认:'sha1'
|
|
34
|
+
* @param padding 补位方式,默认:crypto.constants.RSA_PKCS1_OAEP_PADDING
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
encrypt(plaintext, encoding = 'base64', hashType = 'sha1', padding = crypto_1.default.constants.RSA_PKCS1_OAEP_PADDING) {
|
|
38
|
+
return super.encrypt(plaintext, encoding, hashType, padding);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 解密
|
|
42
|
+
* @param ciphertext 待解密文本
|
|
43
|
+
* @param encoding 编码,默认:'base64'
|
|
44
|
+
* @param hashType 哈希方式,默认:'sha1'
|
|
45
|
+
* @param padding 补位方式,默认:crypto.constants.RSA_PKCS1_OAEP_PADDING
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
decrypt(ciphertext, encoding = 'base64', hashType = 'sha1', padding = crypto_1.default.constants.RSA_PKCS1_OAEP_PADDING) {
|
|
49
|
+
return super.decrypt(ciphertext, encoding, hashType, padding);
|
|
50
|
+
}
|
|
24
51
|
}
|
|
25
52
|
module.exports = Encryptor;
|
package/dist/Pay/Utils.d.ts
CHANGED
package/dist/Pay/Utils.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,9 @@ import OfficialAccountMessage from './OfficialAccount/Message';
|
|
|
12
12
|
import WorkMessage from './Work/Message';
|
|
13
13
|
import OpenPlatformMessage from './OpenPlatform/Message';
|
|
14
14
|
import OpenWorkMessage from './OpenWork/Message';
|
|
15
|
-
|
|
15
|
+
import { PublicKey } from './Core/Support/PublicKey';
|
|
16
|
+
import { PrivateKey } from './Core/Support/PrivateKey';
|
|
17
|
+
export { OfficialAccount, OfficialAccountConfig, MiniApp, MiniAppConfig, Pay, PayConfig, OpenPlatform, OpenPlatformConfig, Work, WorkConfig, OpenWork, OpenWorkConfig, CacheInterface, ServerRequest, LogHandler, ServerEventType, ServerHandlerClosure, PublicKey, PrivateKey,
|
|
16
18
|
/**
|
|
17
19
|
* 表单对象
|
|
18
20
|
* @see https://github.com/axios/axios#formdata
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.definePaymentScannedHandler = exports.definePaymentRefundedHandler = exports.definePaymentPaidHandler = exports.definePaymentAlertHandler = exports.definePaymentFailHandler = exports.defineHttpClientFailureJudgeClosure = exports.defineOpenWorkServerHandler = exports.defineOpenPlatformServerHandler = exports.defineWorkServerHandler = exports.defineMiniAppServerHandler = exports.defineOfficeAccountServerHandler = exports.defineLogHandler = exports.defineOpenWorkConfig = exports.defineWorkConfig = exports.defineOpenPlatformConfig = exports.definePayConfig = exports.defineMiniAppConfig = exports.defineOfficialAccountConfig = exports.FormData = exports.ServerRequest = exports.CacheInterface = exports.OpenWork = exports.Work = exports.OpenPlatform = exports.Pay = exports.MiniApp = exports.OfficialAccount = void 0;
|
|
6
|
+
exports.definePaymentScannedHandler = exports.definePaymentRefundedHandler = exports.definePaymentPaidHandler = exports.definePaymentAlertHandler = exports.definePaymentFailHandler = exports.defineHttpClientFailureJudgeClosure = exports.defineOpenWorkServerHandler = exports.defineOpenPlatformServerHandler = exports.defineWorkServerHandler = exports.defineMiniAppServerHandler = exports.defineOfficeAccountServerHandler = exports.defineLogHandler = exports.defineOpenWorkConfig = exports.defineWorkConfig = exports.defineOpenPlatformConfig = exports.definePayConfig = exports.defineMiniAppConfig = exports.defineOfficialAccountConfig = exports.FormData = exports.PrivateKey = exports.PublicKey = exports.ServerRequest = exports.CacheInterface = exports.OpenWork = exports.Work = exports.OpenPlatform = exports.Pay = exports.MiniApp = exports.OfficialAccount = void 0;
|
|
7
7
|
const Application_1 = __importDefault(require("./OfficialAccount/Application"));
|
|
8
8
|
exports.OfficialAccount = Application_1.default;
|
|
9
9
|
const Application_2 = __importDefault(require("./MiniApp/Application"));
|
|
@@ -22,6 +22,10 @@ const ServerRequest_1 = __importDefault(require("./Core/Http/ServerRequest"));
|
|
|
22
22
|
exports.ServerRequest = ServerRequest_1.default;
|
|
23
23
|
const form_data_1 = __importDefault(require("form-data"));
|
|
24
24
|
exports.FormData = form_data_1.default;
|
|
25
|
+
const PublicKey_1 = require("./Core/Support/PublicKey");
|
|
26
|
+
Object.defineProperty(exports, "PublicKey", { enumerable: true, get: function () { return PublicKey_1.PublicKey; } });
|
|
27
|
+
const PrivateKey_1 = require("./Core/Support/PrivateKey");
|
|
28
|
+
Object.defineProperty(exports, "PrivateKey", { enumerable: true, get: function () { return PrivateKey_1.PrivateKey; } });
|
|
25
29
|
/**
|
|
26
30
|
* 定义公众号配置
|
|
27
31
|
* @param config
|