@jayfong/x-server 1.24.0 → 1.24.1
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 +2 -0
- package/lib/_cjs/services/pay.js +8 -0
- package/lib/services/pay.d.ts +1 -0
- package/lib/services/pay.js +7 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.24.1](https://github.com/jfWorks/x-server/compare/v1.24.0...v1.24.1) (2022-05-02)
|
|
6
|
+
|
|
5
7
|
## [1.24.0](https://github.com/jfWorks/x-server/compare/v1.23.0...v1.24.0) (2022-05-02)
|
|
6
8
|
|
|
7
9
|
|
package/lib/_cjs/services/pay.js
CHANGED
|
@@ -13,6 +13,8 @@ var _crypto = _interopRequireDefault(require("crypto"));
|
|
|
13
13
|
|
|
14
14
|
var _got = _interopRequireDefault(require("got"));
|
|
15
15
|
|
|
16
|
+
var _http_error = require("../core/http_error");
|
|
17
|
+
|
|
16
18
|
var _x = require("../x");
|
|
17
19
|
|
|
18
20
|
class PayService {
|
|
@@ -100,6 +102,12 @@ class PayService {
|
|
|
100
102
|
return true;
|
|
101
103
|
}
|
|
102
104
|
|
|
105
|
+
async verifyNotifyDataOrFail(data, message) {
|
|
106
|
+
if (!(await this.verifyNotifyData(data))) {
|
|
107
|
+
throw new _http_error.HttpError.BadRequest(message);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
103
111
|
wepaySign(data) {
|
|
104
112
|
return _crypto.default.createSign('RSA-SHA256').update(data.map(v => `${v}\n`).join('')).sign(this.options.wepay.privateKey, 'base64');
|
|
105
113
|
}
|
package/lib/services/pay.d.ts
CHANGED
|
@@ -70,6 +70,7 @@ export declare class PayService implements BaseService {
|
|
|
70
70
|
prepareAlipay(options: PayPrepareAlipayOptions): Promise<PayPrepareAlipayResult>;
|
|
71
71
|
prepareWepay(options: PayPrepareWepayOptions): Promise<PayPrepareWepayResult>;
|
|
72
72
|
verifyNotifyData(data: any): Promise<boolean>;
|
|
73
|
+
verifyNotifyDataOrFail(data: any, message?: string): Promise<void>;
|
|
73
74
|
private wepaySign;
|
|
74
75
|
private wepayDecrypt;
|
|
75
76
|
private wepayRequest;
|
package/lib/services/pay.js
CHANGED
|
@@ -2,6 +2,7 @@ import AlipayFormData from 'alipay-sdk/lib/form';
|
|
|
2
2
|
import AlipaySdk from 'alipay-sdk';
|
|
3
3
|
import crypto from 'crypto';
|
|
4
4
|
import got from 'got';
|
|
5
|
+
import { HttpError } from "../core/http_error";
|
|
5
6
|
import { x } from "../x";
|
|
6
7
|
export class PayService {
|
|
7
8
|
constructor(options) {
|
|
@@ -88,6 +89,12 @@ export class PayService {
|
|
|
88
89
|
return true;
|
|
89
90
|
}
|
|
90
91
|
|
|
92
|
+
async verifyNotifyDataOrFail(data, message) {
|
|
93
|
+
if (!(await this.verifyNotifyData(data))) {
|
|
94
|
+
throw new HttpError.BadRequest(message);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
91
98
|
wepaySign(data) {
|
|
92
99
|
return crypto.createSign('RSA-SHA256').update(data.map(v => `${v}\n`).join('')).sign(this.options.wepay.privateKey, 'base64');
|
|
93
100
|
}
|