@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/_cjs/services/pay.js
CHANGED
|
@@ -94,20 +94,52 @@ class PayService {
|
|
|
94
94
|
|
|
95
95
|
verifyNotifyData(data) {
|
|
96
96
|
try {
|
|
97
|
-
|
|
97
|
+
if (!data || typeof data !== 'object') {
|
|
98
|
+
return false;
|
|
99
|
+
} // 支付宝
|
|
100
|
+
// https://opendocs.alipay.com/open/270/105902
|
|
98
101
|
|
|
99
|
-
|
|
100
|
-
data.passback_params === 'alipay'
|
|
101
|
-
|
|
102
|
+
|
|
103
|
+
if (data.passback_params === 'alipay') {
|
|
104
|
+
var _this$alipaySdk;
|
|
105
|
+
|
|
106
|
+
if (!((_this$alipaySdk = this.alipaySdk) != null && _this$alipaySdk.checkNotifySign(data))) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
channelOrderNo: data.trade_no
|
|
112
|
+
};
|
|
113
|
+
} // 微信支付
|
|
114
|
+
// https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_5.shtml
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
if (data.resource) {
|
|
118
|
+
const params = JSON.parse(this.wepayDecrypt(data.resource));
|
|
119
|
+
|
|
120
|
+
if (params.attach === 'wepay') {
|
|
121
|
+
return {
|
|
122
|
+
channelOrderNo: params.transaction_id
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return false;
|
|
102
130
|
} catch {
|
|
103
131
|
return false;
|
|
104
132
|
}
|
|
105
133
|
}
|
|
106
134
|
|
|
107
135
|
verifyNotifyDataOrFail(data, message) {
|
|
108
|
-
|
|
136
|
+
const res = this.verifyNotifyData(data);
|
|
137
|
+
|
|
138
|
+
if (!res) {
|
|
109
139
|
throw new _http_error.HttpError.BadRequest(message);
|
|
110
140
|
}
|
|
141
|
+
|
|
142
|
+
return res;
|
|
111
143
|
}
|
|
112
144
|
|
|
113
145
|
wepaySign(data) {
|
package/lib/_cjs/x.js
CHANGED
|
@@ -13,6 +13,8 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
13
13
|
|
|
14
14
|
var _dispose = require("./services/dispose");
|
|
15
15
|
|
|
16
|
+
var _emoji = require("./services/emoji");
|
|
17
|
+
|
|
16
18
|
var _log = require("./services/log");
|
|
17
19
|
|
|
18
20
|
const env = JSON.parse(process.env.X_SERVER_ENVS || '{}');
|
|
@@ -33,4 +35,4 @@ _fsExtra.default.ensureDirSync(x.dataDir);
|
|
|
33
35
|
|
|
34
36
|
x.register(new _dispose.DisposeService({
|
|
35
37
|
disposeOnExit: true
|
|
36
|
-
}), new _log.LogService());
|
|
38
|
+
}), new _log.LogService(), new _emoji.EmojiService());
|