@jayfong/x-server 2.4.3 → 2.6.0
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/lib/_cjs/services/emoji.js +2037 -0
- package/lib/_cjs/services/pay.js +37 -5
- package/lib/_cjs/x.js +3 -1
- package/lib/services/emoji.d.ts +10 -0
- package/lib/services/emoji.js +2030 -0
- package/lib/services/pay.d.ts +11 -2
- package/lib/services/pay.js +37 -5
- package/lib/x.d.ts +1 -0
- package/lib/x.js +2 -1
- package/package.json +3 -2
package/lib/services/pay.d.ts
CHANGED
|
@@ -64,6 +64,15 @@ export interface PayServicePrepareWepayResult {
|
|
|
64
64
|
paySign: string;
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
+
export interface PayServiceVerifyNotifyDataResult {
|
|
68
|
+
/**
|
|
69
|
+
* 渠道订单号。
|
|
70
|
+
*
|
|
71
|
+
* - 支付宝最长 `64` 位;
|
|
72
|
+
* - 微信支付最长 `32` 位。
|
|
73
|
+
*/
|
|
74
|
+
channelOrderNo: string;
|
|
75
|
+
}
|
|
67
76
|
export declare class PayService implements BaseService {
|
|
68
77
|
private options;
|
|
69
78
|
serviceName: string;
|
|
@@ -71,8 +80,8 @@ export declare class PayService implements BaseService {
|
|
|
71
80
|
constructor(options: PayServiceOptions);
|
|
72
81
|
prepareAlipay(options: PayServicePrepareAlipayOptions): Promise<PayServicePrepareAlipayResult>;
|
|
73
82
|
prepareWepay(options: PayServicePrepareWepayOptions): Promise<PayServicePrepareWepayResult>;
|
|
74
|
-
verifyNotifyData(data: any):
|
|
75
|
-
verifyNotifyDataOrFail(data: any, message?: string):
|
|
83
|
+
verifyNotifyData(data: any): false | PayServiceVerifyNotifyDataResult;
|
|
84
|
+
verifyNotifyDataOrFail(data: any, message?: string): PayServiceVerifyNotifyDataResult;
|
|
76
85
|
private wepaySign;
|
|
77
86
|
private wepayDecrypt;
|
|
78
87
|
private wepayRequest;
|
package/lib/services/pay.js
CHANGED
|
@@ -82,20 +82,52 @@ export class PayService {
|
|
|
82
82
|
|
|
83
83
|
verifyNotifyData(data) {
|
|
84
84
|
try {
|
|
85
|
-
|
|
85
|
+
if (!data || typeof data !== 'object') {
|
|
86
|
+
return false;
|
|
87
|
+
} // 支付宝
|
|
88
|
+
// https://opendocs.alipay.com/open/270/105902
|
|
86
89
|
|
|
87
|
-
|
|
88
|
-
data.passback_params === 'alipay'
|
|
89
|
-
|
|
90
|
+
|
|
91
|
+
if (data.passback_params === 'alipay') {
|
|
92
|
+
var _this$alipaySdk;
|
|
93
|
+
|
|
94
|
+
if (!((_this$alipaySdk = this.alipaySdk) != null && _this$alipaySdk.checkNotifySign(data))) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
channelOrderNo: data.trade_no
|
|
100
|
+
};
|
|
101
|
+
} // 微信支付
|
|
102
|
+
// https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_5.shtml
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
if (data.resource) {
|
|
106
|
+
const params = JSON.parse(this.wepayDecrypt(data.resource));
|
|
107
|
+
|
|
108
|
+
if (params.attach === 'wepay') {
|
|
109
|
+
return {
|
|
110
|
+
channelOrderNo: params.transaction_id
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return false;
|
|
90
118
|
} catch {
|
|
91
119
|
return false;
|
|
92
120
|
}
|
|
93
121
|
}
|
|
94
122
|
|
|
95
123
|
verifyNotifyDataOrFail(data, message) {
|
|
96
|
-
|
|
124
|
+
const res = this.verifyNotifyData(data);
|
|
125
|
+
|
|
126
|
+
if (!res) {
|
|
97
127
|
throw new HttpError.BadRequest(message);
|
|
98
128
|
}
|
|
129
|
+
|
|
130
|
+
return res;
|
|
99
131
|
}
|
|
100
132
|
|
|
101
133
|
wepaySign(data) {
|
package/lib/x.d.ts
CHANGED
package/lib/x.js
CHANGED
|
@@ -2,6 +2,7 @@ import fs from 'fs-extra';
|
|
|
2
2
|
import os from 'os';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { DisposeService } from "./services/dispose";
|
|
5
|
+
import { EmojiService } from "./services/emoji";
|
|
5
6
|
import { LogService } from "./services/log";
|
|
6
7
|
const env = JSON.parse(process.env.X_SERVER_ENVS || '{}');
|
|
7
8
|
export const x = {
|
|
@@ -18,4 +19,4 @@ export const x = {
|
|
|
18
19
|
fs.ensureDirSync(x.dataDir);
|
|
19
20
|
x.register(new DisposeService({
|
|
20
21
|
disposeOnExit: true
|
|
21
|
-
}), new LogService());
|
|
22
|
+
}), new LogService(), new EmojiService());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jayfong/x-server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "lib/_cjs/index.js",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"ts-morph": "^12.2.0",
|
|
73
73
|
"utf-8-validate": "^5.0.9",
|
|
74
74
|
"vscode-generate-index-standalone": "^1.7.1",
|
|
75
|
-
"vtils": "^4.
|
|
75
|
+
"vtils": "^4.75.0",
|
|
76
76
|
"yargs": "^17.4.1"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
"@types/ioredis": "^4.28.10",
|
|
82
82
|
"@types/json-schema": "^7.0.11",
|
|
83
83
|
"@types/lz-string": "^1.3.34",
|
|
84
|
+
"axios": "^1.4.0",
|
|
84
85
|
"eslint": "^7.32.0",
|
|
85
86
|
"haoma": "^3.6.4",
|
|
86
87
|
"husky": "^4.3.8",
|