cgserver 7.2.684 → 7.2.686
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/dist/lib/Logic/HttpTool.js +30 -14
- package/dist/lib/ThirdParty/AppleTool.js +2 -2
- package/dist/lib/ThirdParty/OpenSocial.js +2 -2
- package/dist/lib/ThirdParty/QQTool.js +3 -3
- package/dist/lib/ThirdParty/WechatTool.js +2 -2
- package/dist/types/Logic/HttpTool.d.ts +2 -2
- package/package.json +1 -1
|
@@ -7,30 +7,46 @@ const Log_1 = require("./Log");
|
|
|
7
7
|
const cgserver_1 = require("cgserver");
|
|
8
8
|
exports.GHttpTool = null;
|
|
9
9
|
class HttpTool {
|
|
10
|
-
|
|
10
|
+
get(options_url) {
|
|
11
|
+
let options = null;
|
|
12
|
+
if (cgserver_1.core.isString(options_url)) {
|
|
13
|
+
options = { url: options_url };
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
options = options_url;
|
|
17
|
+
}
|
|
11
18
|
return new Promise((resolve, reject) => {
|
|
12
|
-
request.get(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
request.get(options, (error, response, body) => {
|
|
20
|
+
let bd = body;
|
|
21
|
+
if (error) {
|
|
22
|
+
Log_1.GLog.error("get:" + options.url);
|
|
23
|
+
Log_1.GLog.error(error);
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
if (cgserver_1.core.isString(body)) {
|
|
27
|
+
body = JSON.parse(body);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
17
31
|
try {
|
|
18
|
-
|
|
19
|
-
body = JSON.parse(body);
|
|
20
|
-
}
|
|
32
|
+
body = qs.parse(body);
|
|
21
33
|
}
|
|
22
34
|
catch (e) {
|
|
23
|
-
|
|
24
|
-
body = qs.parse(body);
|
|
25
|
-
}
|
|
26
|
-
catch (e) { }
|
|
35
|
+
body = bd;
|
|
27
36
|
}
|
|
28
37
|
}
|
|
29
38
|
resolve({ error, response, body });
|
|
30
39
|
});
|
|
31
40
|
});
|
|
32
41
|
}
|
|
33
|
-
|
|
42
|
+
post(options_url) {
|
|
43
|
+
let options = null;
|
|
44
|
+
if (cgserver_1.core.isString(options_url)) {
|
|
45
|
+
options = { url: options_url };
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
options = options_url;
|
|
49
|
+
}
|
|
34
50
|
return new Promise((resolve, reject) => {
|
|
35
51
|
request.post(options, (error, response, body) => {
|
|
36
52
|
let bd = body;
|
|
@@ -174,12 +174,12 @@ class AppleTool {
|
|
|
174
174
|
let reqb = new RequestBody();
|
|
175
175
|
reqb['receipt-data'] = receipt;
|
|
176
176
|
//先验证生产环境
|
|
177
|
-
var resb = (await HttpTool_1.GHttpTool.
|
|
177
|
+
var resb = (await HttpTool_1.GHttpTool.post({ url, form: JSON.stringify(reqb) })).body;
|
|
178
178
|
Log_1.GLog.info("production end onVerify_Res============================status=" + (resb ? resb.status : "null"));
|
|
179
179
|
//状态21007表示是沙盒环境
|
|
180
180
|
if (resb && resb.status == 21007) {
|
|
181
181
|
url = this._sandboxVerifyUrl;
|
|
182
|
-
resb = (await HttpTool_1.GHttpTool.
|
|
182
|
+
resb = (await HttpTool_1.GHttpTool.post({ url, form: JSON.stringify(reqb) })).body;
|
|
183
183
|
Log_1.GLog.info("sandbox end onVerify_Res============================status=" + (resb ? resb.status : "null"));
|
|
184
184
|
}
|
|
185
185
|
Log_1.GLog.info(resb);
|
|
@@ -16,7 +16,7 @@ class OpenSocial {
|
|
|
16
16
|
unionid: unionid,
|
|
17
17
|
openid: openid
|
|
18
18
|
};
|
|
19
|
-
let rs = await HttpTool_1.GHttpTool.
|
|
19
|
+
let rs = await HttpTool_1.GHttpTool.post({ url: IServerConfig_1.GServerCfg.third_cfg.open_social.user_url, json: msg });
|
|
20
20
|
return rs.body;
|
|
21
21
|
}
|
|
22
22
|
async updatePwd(unionid, openid, new_pwd) {
|
|
@@ -25,7 +25,7 @@ class OpenSocial {
|
|
|
25
25
|
openid: openid,
|
|
26
26
|
password: new_pwd
|
|
27
27
|
};
|
|
28
|
-
let jsonData = await HttpTool_1.GHttpTool.
|
|
28
|
+
let jsonData = await HttpTool_1.GHttpTool.post({ url: IServerConfig_1.GServerCfg.third_cfg.open_social.update_pwd_url, json: msg });
|
|
29
29
|
return jsonData.body || jsonData.error;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -75,7 +75,7 @@ class QQTool {
|
|
|
75
75
|
//必须 成功授权后的回调地址,必须是注册appid时填写的主域名下的地址,建议设置为网站首页或网站的用户中心
|
|
76
76
|
let redirect_uri = URLEncode.encode(IServerConfig_1.GServerCfg.third_cfg.qq.redirect_uri);
|
|
77
77
|
let url = "https://graph.qq.com/oauth2.0/token?code=" + auth_code + "&grant_type=" + grant_type + "&client_id=" + client_id + "&client_secret=" + client_secret + "&redirect_uri=" + redirect_uri;
|
|
78
|
-
let rs = await HttpTool_1.GHttpTool.
|
|
78
|
+
let rs = await HttpTool_1.GHttpTool.get(url);
|
|
79
79
|
if (rs.body && rs.body.access_token) {
|
|
80
80
|
return rs.body.access_token;
|
|
81
81
|
}
|
|
@@ -86,7 +86,7 @@ class QQTool {
|
|
|
86
86
|
}
|
|
87
87
|
async getOpenId(access_token) {
|
|
88
88
|
let url = "https://graph.qq.com/oauth2.0/me?access_token=" + access_token;
|
|
89
|
-
let rs = await HttpTool_1.GHttpTool.
|
|
89
|
+
let rs = await HttpTool_1.GHttpTool.get(url);
|
|
90
90
|
let body = rs.response ? rs.response.body : null;
|
|
91
91
|
if (body) {
|
|
92
92
|
body = body.replace("callback( ", "");
|
|
@@ -104,7 +104,7 @@ class QQTool {
|
|
|
104
104
|
}
|
|
105
105
|
async getUserInfo(access_token, openid) {
|
|
106
106
|
let url = "https://graph.qq.com/user/get_user_info?access_token=" + access_token + "&oauth_consumer_key=" + IServerConfig_1.GServerCfg.third_cfg.qq.app_id + "&openid=" + openid;
|
|
107
|
-
let rs = await HttpTool_1.GHttpTool.
|
|
107
|
+
let rs = await HttpTool_1.GHttpTool.get(url);
|
|
108
108
|
if (rs.body) {
|
|
109
109
|
return rs.body;
|
|
110
110
|
}
|
|
@@ -41,7 +41,7 @@ class WechatTool {
|
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
43
43
|
let url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + IServerConfig_1.GServerCfg.third_cfg.wechat.app_id + "&secret=" + IServerConfig_1.GServerCfg.third_cfg.wechat.app_key + "&code=" + auth_code + "&grant_type=authorization_code";
|
|
44
|
-
let rs = await HttpTool_1.GHttpTool.
|
|
44
|
+
let rs = await HttpTool_1.GHttpTool.get(url);
|
|
45
45
|
/*
|
|
46
46
|
{
|
|
47
47
|
"access_token":"ACCESS_TOKEN",
|
|
@@ -63,7 +63,7 @@ class WechatTool {
|
|
|
63
63
|
}
|
|
64
64
|
async getUserInfo(access_token, openid) {
|
|
65
65
|
let url = "https://api.weixin.qq.com/sns/userinfo?access_token=" + access_token + "&openid=" + openid;
|
|
66
|
-
let rs = await HttpTool_1.GHttpTool.
|
|
66
|
+
let rs = await HttpTool_1.GHttpTool.get(url);
|
|
67
67
|
if (rs.body) {
|
|
68
68
|
return rs.body;
|
|
69
69
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as request from "request";
|
|
2
2
|
export declare let GHttpTool: HttpTool;
|
|
3
3
|
declare class HttpTool {
|
|
4
|
-
|
|
4
|
+
get(options_url: request.OptionsWithUrl | string): Promise<{
|
|
5
5
|
error: any;
|
|
6
6
|
response: any;
|
|
7
7
|
body: any;
|
|
8
8
|
}>;
|
|
9
|
-
|
|
9
|
+
post(options_url: request.OptionsWithUrl | string): Promise<{
|
|
10
10
|
error: any;
|
|
11
11
|
response: any;
|
|
12
12
|
body: any;
|