cgserver 9.1.8 → 9.1.10

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/README.md CHANGED
@@ -1,3 +1,10 @@
1
+ 9.1.10
2
+ 1、删除一些无用配置和代码
3
+ 2、整理现有的代码,增加一些人性化的提示
4
+ 9.1.9
5
+ 1、周起始时间bug修正
6
+ 9.1.8
7
+ 1、强制mongocache访问mongo的bug修改
1
8
  9.1.7
2
9
  1、httptool 默认可以支持全局输出日志了
3
10
  9.1.6
@@ -37,6 +37,61 @@ class WebServerConfig {
37
37
  rootview = "";
38
38
  }
39
39
  exports.WebServerConfig = WebServerConfig;
40
+ class AliSmsConfig {
41
+ signName = "";
42
+ accessKeyId = "";
43
+ secretAccessKey = "";
44
+ templateCode = "";
45
+ }
46
+ class QiNiuConfig {
47
+ host = "";
48
+ bucket = "";
49
+ accessKey = "";
50
+ secretKey = "";
51
+ }
52
+ class EmailConfig {
53
+ host = "";
54
+ port = 587;
55
+ secure = false;
56
+ auth = null;
57
+ from = "";
58
+ }
59
+ class QQConfig {
60
+ app_id = "";
61
+ app_key = "";
62
+ redirect_uri = "";
63
+ }
64
+ class WechatConfig {
65
+ app_id = "";
66
+ app_key = "";
67
+ redirect_uri = "";
68
+ }
69
+ class AlipayConfig {
70
+ open = false;
71
+ dev = false;
72
+ app_id = "";
73
+ app_key = "";
74
+ gateway = "";
75
+ //RSA1 RSA2
76
+ signType = "";
77
+ /** 指定private key类型, 默认: PKCS1, PKCS8: PRIVATE KEY, PKCS1: RSA PRIVATE KEY */
78
+ keyType = "";
79
+ alipay_root_cert_sn = "";
80
+ alipay_cert_sn = "";
81
+ app_cert_sn = "";
82
+ notify_url = "";
83
+ app_id_dev = "";
84
+ app_key_dev = "";
85
+ gateway_dev = "";
86
+ //RSA1 RSA2
87
+ signType_dev = "";
88
+ /** 指定private key类型, 默认: PKCS1, PKCS8: PRIVATE KEY, PKCS1: RSA PRIVATE KEY */
89
+ keyType_dev = "";
90
+ alipay_root_cert_sn_dev = "";
91
+ alipay_cert_sn_dev = "";
92
+ app_cert_sn_dev = "";
93
+ notify_url_dev;
94
+ }
40
95
  class FrameworkConfig extends Config_1.Config {
41
96
  /*
42
97
  *-1不输出到console,0,仅错误信息输出到console,1,都输出到console
@@ -119,82 +174,14 @@ class FrameworkConfig extends Config_1.Config {
119
174
  * 控制网络消息的
120
175
  */
121
176
  debug_msg = false;
122
- local_host = "127.0.0.1";
123
- internet_host = "127.0.0.1";
124
177
  db = new DbConfig_1.DbConfig();
125
- third_cfg = {
126
- open_social: {
127
- app_id: "appid_42313131",
128
- app_secret: "apps_FDS4342J34JL432",
129
- auth_url: "http://47.99.195.103:6666/auth/account/",
130
- user_url: "http://47.99.195.103:6666/auth/userinfo/",
131
- update_pwd_url: "http://47.99.195.103:6666/auth/updatepwd/"
132
- },
133
- aliSms: {
134
- signName: "而已网络",
135
- accessKeyId: "LTAIeqjiZ5OCev0B",
136
- secretAccessKey: "0w1fmDEORshI94QqtampBaAPQDqUAj",
137
- templateCode: "SMS_154589473"
138
- },
139
- qiniu: {
140
- host: "p0bj0dycx.bkt.clouddn.com",
141
- bucket: "eryiniuniu",
142
- accessKey: "OETxflxP9V5ZzPcjE30asCv-YxWBvDpmMPJegtI4",
143
- secretKey: "kZWsom120P0-cfQt_9_1-wR_X8RwuLeMXKbU_uc4"
144
- },
145
- email: {
146
- host: "smtp.live.com",
147
- port: 587,
148
- secure: false,
149
- auth: {
150
- user: "chengang01@live.com",
151
- pass: "cg123!@#" // generated ethereal password
152
- },
153
- from: "OpenSocial <chengang01@live.com>"
154
- },
155
- qq: {
156
- app_id: "101775753",
157
- app_key: "753d0f02f3c4093062e7b2f56c7fcb0c",
158
- redirect_uri: "http://www.eryinet.com/qq/callback"
159
- },
160
- wechat: {
161
- app_id: "wx80f0f10fe1304e9d",
162
- app_key: "a76fc337c49b309886a6538d31c344e2",
163
- redirect_uri: "http://www.eryinet.com/wechat/callback"
164
- },
165
- alipay: {
166
- open: false,
167
- dev: false,
168
- app_id: "",
169
- app_key: "",
170
- gateway: "",
171
- //RSA1 RSA2
172
- signType: 'RSA2',
173
- /** 指定private key类型, 默认: PKCS1, PKCS8: PRIVATE KEY, PKCS1: RSA PRIVATE KEY */
174
- keyType: 'PKCS1',
175
- alipay_root_cert_sn: "",
176
- alipay_cert_sn: "",
177
- app_cert_sn: "",
178
- notify_url: "",
179
- app_id_dev: "",
180
- app_key_dev: "",
181
- gateway_dev: "",
182
- //RSA1 RSA2
183
- signType_dev: 'RSA2',
184
- /** 指定private key类型, 默认: PKCS1, PKCS8: PRIVATE KEY, PKCS1: RSA PRIVATE KEY */
185
- keyType_dev: 'PKCS1',
186
- alipay_root_cert_sn_dev: "",
187
- alipay_cert_sn_dev: "",
188
- app_cert_sn_dev: "",
189
- notify_url_dev: ""
190
- },
191
- apple: {
192
- keyIds: {}
193
- },
194
- cgrpc: null
195
- };
196
- //key是ip,value是domain
197
- ip_to_domain = {};
178
+ aliSms = null;
179
+ qiniu = null;
180
+ email = null;
181
+ qq = null;
182
+ wechat = null;
183
+ alipay = null;
184
+ apple;
198
185
  root_path = process.cwd();
199
186
  constructor() {
200
187
  super("FrameworkConfig");
@@ -499,17 +499,17 @@ class core {
499
499
  let time = new Date(now.getFullYear(), now.getMonth());
500
500
  return time.getTime();
501
501
  }
502
- static getLastWeekStartTime() {
502
+ static getNextWeekStartTime() {
503
503
  let one_day = 24 * 60 * 60 * 1000;
504
504
  let time = this.getTodayStartTime();
505
505
  let day = new Date().getDay();
506
- return time - (day + 7) * one_day;
506
+ return time + (7 - (day - 1)) * one_day;
507
507
  }
508
508
  static getCurWeekStartTime() {
509
509
  let one_day = 24 * 60 * 60 * 1000;
510
510
  let time = this.getTodayStartTime();
511
511
  let day = new Date().getDay();
512
- return time - day * one_day;
512
+ return time - (day - 1) * one_day;
513
513
  }
514
514
  static isSameMonth(src_time, target_time) {
515
515
  let src_date = new Date(src_time);
@@ -5,7 +5,6 @@ const _error_1 = require("../Config/_error_");
5
5
  const MongoBaseService_1 = require("../Database/MongoBaseService");
6
6
  const MongoManager_1 = require("../Database/MongoManager");
7
7
  const CacheTool_1 = require("../Logic/CacheTool");
8
- const OpenSocial_1 = require("../ThirdParty/OpenSocial");
9
8
  const QQTool_1 = require("../ThirdParty/QQTool");
10
9
  const WechatTool_1 = require("../ThirdParty/WechatTool");
11
10
  const ini_1 = require("./ini");
@@ -37,7 +36,6 @@ class MongoAccountService extends MongoBaseService_1.MongoBaseService {
37
36
  async add(unionid, openid, ip, from) {
38
37
  let account = new this._t_type();
39
38
  switch (from) {
40
- case ini_1.EAccountFrom.OpenSocial:
41
39
  case ini_1.EAccountFrom.WeChat:
42
40
  case ini_1.EAccountFrom.QQ:
43
41
  case ini_1.EAccountFrom.Apple:
@@ -129,7 +127,6 @@ class MongoAccountService extends MongoBaseService_1.MongoBaseService {
129
127
  let extra_info = {};
130
128
  if (!account) {
131
129
  switch (from) {
132
- case ini_1.EAccountFrom.OpenSocial:
133
130
  case ini_1.EAccountFrom.QQ:
134
131
  case ini_1.EAccountFrom.WeChat:
135
132
  case ini_1.EAccountFrom.Guest:
@@ -155,29 +152,13 @@ class MongoAccountService extends MongoBaseService_1.MongoBaseService {
155
152
  let user = await MongoUserService_1.GUserSer.getByAccountId(account.id);
156
153
  if (!user) {
157
154
  switch (from) {
158
- case ini_1.EAccountFrom.OpenSocial:
159
155
  case ini_1.EAccountFrom.QQ:
160
156
  case ini_1.EAccountFrom.WeChat:
161
157
  case ini_1.EAccountFrom.Apple:
162
158
  case ini_1.EAccountFrom.Google:
163
159
  {
164
160
  if (!extra_info) {
165
- if (from == ini_1.EAccountFrom.OpenSocial) {
166
- let body = await OpenSocial_1.GOpenSocial.getUser(unionid, openid);
167
- if (body && body.errcode) {
168
- rs.errcode = body.errcode;
169
- return rs;
170
- }
171
- else if (body && body.user) {
172
- extra_info =
173
- {
174
- logo: body.user.logo,
175
- sex: body.user.sex,
176
- nickname: body.user.nickname
177
- };
178
- }
179
- }
180
- else if (from == ini_1.EAccountFrom.QQ) {
161
+ if (from == ini_1.EAccountFrom.QQ) {
181
162
  let userInfo = await QQTool_1.GQQTool.getUserInfo(access_token, openid);
182
163
  if (!userInfo) {
183
164
  rs.errcode = _error_1.EErrorCode.Server_Error;
@@ -258,7 +239,6 @@ class MongoAccountService extends MongoBaseService_1.MongoBaseService {
258
239
  let rs = { errcode: null, account: null };
259
240
  if (from == ini_1.EAccountFrom.QQ
260
241
  || from == ini_1.EAccountFrom.WeChat
261
- || from == ini_1.EAccountFrom.OpenSocial
262
242
  || from == ini_1.EAccountFrom.Apple
263
243
  || from == ini_1.EAccountFrom.Google) {
264
244
  rs.account = await this.getByThird(unionid, openid);
@@ -292,16 +272,6 @@ class MongoAccountService extends MongoBaseService_1.MongoBaseService {
292
272
  }
293
273
  return rs;
294
274
  }
295
- /**
296
- * 修改密码
297
- * @param unionid
298
- * @param openid
299
- * @param new_pwd
300
- */
301
- async updatePwd(unionid, openid, new_pwd) {
302
- let rs = await OpenSocial_1.GOpenSocial.updatePwd(unionid, openid, new_pwd);
303
- return rs;
304
- }
305
275
  async register(type, key, password, ip, extra) {
306
276
  let rs = { user: null, errcode: null };
307
277
  extra = extra || {};
@@ -11,7 +11,6 @@ const Property_1 = require("../Database/Decorator/Property");
11
11
  const MysqlBaseService_1 = require("../Database/MysqlBaseService");
12
12
  const CacheTool_1 = require("../Logic/CacheTool");
13
13
  const _error_1 = require("../Config/_error_");
14
- const OpenSocial_1 = require("../ThirdParty/OpenSocial");
15
14
  const MysqlUserService_1 = require("./MysqlUserService");
16
15
  const QQTool_1 = require("../ThirdParty/QQTool");
17
16
  const WechatTool_1 = require("../ThirdParty/WechatTool");
@@ -112,7 +111,6 @@ class MysqlAccountService extends MysqlBaseService_1.MysqlBaseService {
112
111
  async add(unionid, openid, ip, from) {
113
112
  let account = new this._t_type();
114
113
  switch (from) {
115
- case ini_1.EAccountFrom.OpenSocial:
116
114
  case ini_1.EAccountFrom.WeChat:
117
115
  case ini_1.EAccountFrom.QQ:
118
116
  case ini_1.EAccountFrom.Apple:
@@ -203,7 +201,6 @@ class MysqlAccountService extends MysqlBaseService_1.MysqlBaseService {
203
201
  let extra_info = {};
204
202
  if (!account) {
205
203
  switch (from) {
206
- case ini_1.EAccountFrom.OpenSocial:
207
204
  case ini_1.EAccountFrom.QQ:
208
205
  case ini_1.EAccountFrom.WeChat:
209
206
  case ini_1.EAccountFrom.Guest:
@@ -229,29 +226,13 @@ class MysqlAccountService extends MysqlBaseService_1.MysqlBaseService {
229
226
  let user = await MysqlUserService_1.GUserSer.getByAccountId(account.id);
230
227
  if (!user) {
231
228
  switch (from) {
232
- case ini_1.EAccountFrom.OpenSocial:
233
229
  case ini_1.EAccountFrom.QQ:
234
230
  case ini_1.EAccountFrom.WeChat:
235
231
  case ini_1.EAccountFrom.Apple:
236
232
  case ini_1.EAccountFrom.Google:
237
233
  {
238
234
  if (!extra_info) {
239
- if (from == ini_1.EAccountFrom.OpenSocial) {
240
- let body = await OpenSocial_1.GOpenSocial.getUser(unionid, openid);
241
- if (body && body.errcode) {
242
- rs.errcode = body.errcode;
243
- return rs;
244
- }
245
- else if (body && body.user) {
246
- extra_info =
247
- {
248
- logo: body.user.logo,
249
- sex: body.user.sex,
250
- nickname: body.user.nickname
251
- };
252
- }
253
- }
254
- else if (from == ini_1.EAccountFrom.QQ) {
235
+ if (from == ini_1.EAccountFrom.QQ) {
255
236
  let userInfo = await QQTool_1.GQQTool.getUserInfo(access_token, openid);
256
237
  if (userInfo.ret) {
257
238
  rs.errcode = _error_1.EErrorCode.Server_Error;
@@ -327,7 +308,6 @@ class MysqlAccountService extends MysqlBaseService_1.MysqlBaseService {
327
308
  let rs = { errcode: null, account: null };
328
309
  if (from == ini_1.EAccountFrom.QQ
329
310
  || from == ini_1.EAccountFrom.WeChat
330
- || from == ini_1.EAccountFrom.OpenSocial
331
311
  || from == ini_1.EAccountFrom.Apple
332
312
  || from == ini_1.EAccountFrom.Google) {
333
313
  rs.account = await this.getByThird(unionid, openid);
@@ -361,16 +341,6 @@ class MysqlAccountService extends MysqlBaseService_1.MysqlBaseService {
361
341
  }
362
342
  return rs;
363
343
  }
364
- /**
365
- * 修改密码
366
- * @param unionid
367
- * @param openid
368
- * @param new_pwd
369
- */
370
- async updatePwd(unionid, openid, new_pwd) {
371
- let rs = await OpenSocial_1.GOpenSocial.updatePwd(unionid, openid, new_pwd);
372
- return rs;
373
- }
374
344
  async register(type, key, password, ip, extra) {
375
345
  let rs = { user: null, errcode: null };
376
346
  extra = extra || {};
@@ -24,7 +24,7 @@ var EAccountState;
24
24
  var EAccountFrom;
25
25
  (function (EAccountFrom) {
26
26
  EAccountFrom[EAccountFrom["Guest"] = 0] = "Guest";
27
- EAccountFrom[EAccountFrom["OpenSocial"] = 1] = "OpenSocial";
27
+ EAccountFrom[EAccountFrom["_OpenSocial"] = 1] = "_OpenSocial";
28
28
  EAccountFrom[EAccountFrom["WeChat"] = 2] = "WeChat";
29
29
  EAccountFrom[EAccountFrom["QQ"] = 3] = "QQ";
30
30
  EAccountFrom[EAccountFrom["Phone"] = 4] = "Phone";
@@ -71,26 +71,26 @@ class AlipayTool {
71
71
  notify_url: ""
72
72
  };
73
73
  init() {
74
- if (!IServerConfig_1.GServerCfg.third_cfg.alipay
75
- || !IServerConfig_1.GServerCfg.third_cfg.alipay.open) {
74
+ if (!IServerConfig_1.GServerCfg.alipay
75
+ || !IServerConfig_1.GServerCfg.alipay.open) {
76
76
  return false;
77
77
  }
78
78
  let suffix = "";
79
- if (IServerConfig_1.GServerCfg.third_cfg.alipay.dev) {
79
+ if (IServerConfig_1.GServerCfg.alipay.dev) {
80
80
  suffix = "_dev";
81
81
  }
82
82
  this._cfg = {
83
- app_id: IServerConfig_1.GServerCfg.third_cfg.alipay["app_id" + suffix],
84
- app_key: IServerConfig_1.GServerCfg.third_cfg.alipay["app_key" + suffix],
85
- gateway: IServerConfig_1.GServerCfg.third_cfg.alipay["gateway" + suffix],
83
+ app_id: IServerConfig_1.GServerCfg.alipay["app_id" + suffix],
84
+ app_key: IServerConfig_1.GServerCfg.alipay["app_key" + suffix],
85
+ gateway: IServerConfig_1.GServerCfg.alipay["gateway" + suffix],
86
86
  //RSA1 RSA2
87
- signType: IServerConfig_1.GServerCfg.third_cfg.alipay["signType" + suffix],
87
+ signType: IServerConfig_1.GServerCfg.alipay["signType" + suffix],
88
88
  /** 指定private key类型, 默认: PKCS1, PKCS8: PRIVATE KEY, PKCS1: RSA PRIVATE KEY */
89
- keyType: IServerConfig_1.GServerCfg.third_cfg.alipay["signType" + suffix],
90
- alipay_root_cert_sn: IServerConfig_1.GServerCfg.third_cfg.alipay["alipay_root_cert_sn" + suffix],
91
- alipay_cert_sn: IServerConfig_1.GServerCfg.third_cfg.alipay["alipay_cert_sn" + suffix],
92
- app_cert_sn: IServerConfig_1.GServerCfg.third_cfg.alipay["app_cert_sn" + suffix],
93
- notify_url: IServerConfig_1.GServerCfg.third_cfg.alipay["notify_url" + suffix]
89
+ keyType: IServerConfig_1.GServerCfg.alipay["signType" + suffix],
90
+ alipay_root_cert_sn: IServerConfig_1.GServerCfg.alipay["alipay_root_cert_sn" + suffix],
91
+ alipay_cert_sn: IServerConfig_1.GServerCfg.alipay["alipay_cert_sn" + suffix],
92
+ app_cert_sn: IServerConfig_1.GServerCfg.alipay["app_cert_sn" + suffix],
93
+ notify_url: IServerConfig_1.GServerCfg.alipay["notify_url" + suffix]
94
94
  };
95
95
  if (this._cfg.alipay_cert_sn) {
96
96
  this._aliPay = new AliPayUtil_1.AliPayUtil(this._cfg.alipay_cert_sn, this._cfg.app_key);
@@ -111,6 +111,7 @@ class AlipayTool {
111
111
  keyType: this._cfg.keyType
112
112
  });
113
113
  }
114
+ Log_1.GLog.info("alipay init success!");
114
115
  }
115
116
  /**
116
117
  * charset:"utf-8",method:"alipay.trade.app.pay",sign_type:"RSA2,version:"1.0"
@@ -9,11 +9,15 @@ class SMSTool {
9
9
  _is_init = false;
10
10
  _sms_client = null;
11
11
  init() {
12
+ if (!IServerConfig_1.GServerCfg.aliSms) {
13
+ return false;
14
+ }
12
15
  if (this._is_init) {
13
16
  return true;
14
17
  }
15
18
  this._is_init = true;
16
- this._sms_client = new SMSClient({ accessKeyId: IServerConfig_1.GServerCfg.third_cfg.aliSms.accessKeyId, secretAccessKey: IServerConfig_1.GServerCfg.third_cfg.aliSms.secretAccessKey });
19
+ this._sms_client = new SMSClient({ accessKeyId: IServerConfig_1.GServerCfg.aliSms.accessKeyId, secretAccessKey: IServerConfig_1.GServerCfg.aliSms.secretAccessKey });
20
+ Log_1.GLog.info("SMSClient init success!");
17
21
  }
18
22
  /**
19
23
  * 发送短信验证码
@@ -25,8 +29,8 @@ class SMSTool {
25
29
  return new Promise((resolve, reject) => {
26
30
  this._sms_client.sendSMS({
27
31
  PhoneNumbers: phone,
28
- SignName: IServerConfig_1.GServerCfg.third_cfg.aliSms.signName,
29
- TemplateCode: IServerConfig_1.GServerCfg.third_cfg.aliSms.templateCode,
32
+ SignName: IServerConfig_1.GServerCfg.aliSms.signName,
33
+ TemplateCode: IServerConfig_1.GServerCfg.aliSms.templateCode,
30
34
  TemplateParam: JSON.stringify({ code: code })
31
35
  }).then((res) => {
32
36
  if (res.Code == "OK") {
@@ -187,7 +187,7 @@ class AppleTool {
187
187
  }
188
188
  signature(nickname, create_time, appBundleID, productIdentifier, offerIdentifier) {
189
189
  let keyIdentifier = "";
190
- for (var k in IServerConfig_1.GServerCfg.third_cfg.apple.keyIds) {
190
+ for (var k in IServerConfig_1.GServerCfg.apple.keyIds) {
191
191
  keyIdentifier = k;
192
192
  break;
193
193
  }
@@ -200,7 +200,7 @@ class AppleTool {
200
200
  nonce.toLowerCase() + '\u2063' +
201
201
  create_time;
202
202
  // Get the PEM-formatted private key string associated with the Key ID.
203
- const path = IServerConfig_1.GServerCfg.third_cfg.apple.keyIds[keyIdentifier];
203
+ const path = IServerConfig_1.GServerCfg.apple.keyIds[keyIdentifier];
204
204
  const keyString = fs.readFileSync(path).toString();
205
205
  // Create an Elliptic Curve Digital Signature Algorithm (ECDSA) object using the private key.
206
206
  const key = new ec_key_1.default(keyString, 'pem');
@@ -8,23 +8,28 @@ exports.GEmailTool = null;
8
8
  class EmailTool {
9
9
  send(to, subject, html) {
10
10
  return new Promise((resolve, reject) => {
11
+ if (!IServerConfig_1.GServerCfg.email) {
12
+ Log_1.GLog.error("email config not found!");
13
+ resolve("email config not found!");
14
+ return;
15
+ }
11
16
  let transport = nodeMailer.createTransport({
12
- host: IServerConfig_1.GServerCfg.third_cfg.email.host,
13
- port: IServerConfig_1.GServerCfg.third_cfg.email.port,
14
- secure: IServerConfig_1.GServerCfg.third_cfg.email.secure,
17
+ host: IServerConfig_1.GServerCfg.email.host,
18
+ port: IServerConfig_1.GServerCfg.email.port,
19
+ secure: IServerConfig_1.GServerCfg.email.secure,
15
20
  auth: {
16
- user: IServerConfig_1.GServerCfg.third_cfg.email.auth.user,
17
- pass: IServerConfig_1.GServerCfg.third_cfg.email.auth.pass
21
+ user: IServerConfig_1.GServerCfg.email.auth.user,
22
+ pass: IServerConfig_1.GServerCfg.email.auth.pass
18
23
  }
19
24
  });
20
25
  let mail = {
21
- from: IServerConfig_1.GServerCfg.third_cfg.email.from,
26
+ from: IServerConfig_1.GServerCfg.email.from,
22
27
  to: to,
23
28
  subject: subject,
24
29
  html: html
25
30
  };
26
31
  transport.sendMail(mail, (_err, msg) => {
27
- Log_1.GLog.error(JSON.stringify(_err));
32
+ Log_1.GLog.error(_err);
28
33
  resolve(_err);
29
34
  });
30
35
  });
@@ -44,10 +44,14 @@ class QQTool {
44
44
  如果传入“mobile”,则展示为mobile端下的样式。
45
45
  */
46
46
  getAuthCodeUrl(scope, display) {
47
+ if (!IServerConfig_1.GServerCfg.qq) {
48
+ Log_1.GLog.error("qq config not found!");
49
+ return null;
50
+ }
47
51
  //必须 成功授权后的回调地址,必须是注册appid时填写的主域名下的地址,建议设置为网站首页或网站的用户中心
48
- let redirect_uri = URLEncode.encode(IServerConfig_1.GServerCfg.third_cfg.qq.redirect_uri);
52
+ let redirect_uri = URLEncode.encode(IServerConfig_1.GServerCfg.qq.redirect_uri);
49
53
  //必须 申请QQ登录成功后,分配给应用的appid。
50
- let client_id = IServerConfig_1.GServerCfg.third_cfg.qq.app_id;
54
+ let client_id = IServerConfig_1.GServerCfg.qq.app_id;
51
55
  //必须 授权类型,此值固定为“code”。
52
56
  let response_type = "code";
53
57
  //必须 client端的状态值。用于第三方应用防止CSRF攻击,成功授权后回调时会原样带回。请务必严格按照流程检查用户与state参数状态的绑定。
@@ -66,14 +70,18 @@ class QQTool {
66
70
  if (!auth_code) {
67
71
  return null;
68
72
  }
73
+ if (!IServerConfig_1.GServerCfg.qq) {
74
+ Log_1.GLog.error("qq config not found!");
75
+ return null;
76
+ }
69
77
  //必须 授权类型,在本步骤中,此值为“authorization_code”。
70
78
  let grant_type = "authorization_code";
71
79
  //必须 申请QQ登录成功后,分配给应用的appid。
72
- let client_id = IServerConfig_1.GServerCfg.third_cfg.qq.app_id;
80
+ let client_id = IServerConfig_1.GServerCfg.qq.app_id;
73
81
  //必须 申请QQ登录成功后,分配给网站的appkey。
74
- let client_secret = IServerConfig_1.GServerCfg.third_cfg.qq.app_key;
82
+ let client_secret = IServerConfig_1.GServerCfg.qq.app_key;
75
83
  //必须 成功授权后的回调地址,必须是注册appid时填写的主域名下的地址,建议设置为网站首页或网站的用户中心
76
- let redirect_uri = URLEncode.encode(IServerConfig_1.GServerCfg.third_cfg.qq.redirect_uri);
84
+ let redirect_uri = URLEncode.encode(IServerConfig_1.GServerCfg.qq.redirect_uri);
77
85
  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
86
  let rs = await HttpTool_1.GHttpTool.get(url);
79
87
  if (rs.body && rs.body.access_token) {
@@ -106,7 +114,11 @@ class QQTool {
106
114
  if (!access_token || !openid) {
107
115
  return null;
108
116
  }
109
- 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;
117
+ if (!IServerConfig_1.GServerCfg.qq) {
118
+ Log_1.GLog.error("qq config not found!");
119
+ return null;
120
+ }
121
+ let url = "https://graph.qq.com/user/get_user_info?access_token=" + access_token + "&oauth_consumer_key=" + IServerConfig_1.GServerCfg.qq.app_id + "&openid=" + openid;
110
122
  let rs = await HttpTool_1.GHttpTool.get(url);
111
123
  if (rs.body) {
112
124
  return rs.body;
@@ -3,15 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GQiniuTool = void 0;
4
4
  const qiniu = require("qiniu");
5
5
  const IServerConfig_1 = require("../Config/IServerConfig");
6
+ const Log_1 = require("../Logic/Log");
6
7
  exports.GQiniuTool = null;
7
8
  class QiniuTool {
8
9
  get host() {
9
- return IServerConfig_1.GServerCfg.third_cfg.qiniu.host;
10
+ if (!IServerConfig_1.GServerCfg.qiniu) {
11
+ return "";
12
+ }
13
+ return IServerConfig_1.GServerCfg.qiniu.host;
10
14
  }
11
15
  getUploadToken(filename) {
12
- let mac = new qiniu.auth.digest.Mac(IServerConfig_1.GServerCfg.third_cfg.qiniu.accessKey, IServerConfig_1.GServerCfg.third_cfg.qiniu.secretKey);
16
+ if (!IServerConfig_1.GServerCfg.qiniu) {
17
+ Log_1.GLog.error("qiniu config not found!");
18
+ return "";
19
+ }
20
+ let mac = new qiniu.auth.digest.Mac(IServerConfig_1.GServerCfg.qiniu.accessKey, IServerConfig_1.GServerCfg.qiniu.secretKey);
13
21
  let options = {
14
- scope: IServerConfig_1.GServerCfg.third_cfg.qiniu.bucket + ":" + filename,
22
+ scope: IServerConfig_1.GServerCfg.qiniu.bucket + ":" + filename,
15
23
  };
16
24
  let putPolicy = new qiniu.rs.PutPolicy(options);
17
25
  let uploadToken = putPolicy.uploadToken(mac);
@@ -27,9 +27,12 @@ class WechatTool {
27
27
  * 获取获取code的url
28
28
  */
29
29
  getAuthCodeUrl() {
30
- let appid = "wx80f0f10fe1304e9d";
31
- let url = "https://open.weixin.qq.com/connect/qrconnect?appid=" + IServerConfig_1.GServerCfg.third_cfg.wechat.app_id;
32
- url += "&redirect_uri=" + URLEncode.encode(IServerConfig_1.GServerCfg.third_cfg.wechat.redirect_uri);
30
+ if (!IServerConfig_1.GServerCfg.wechat) {
31
+ Log_1.GLog.error("wechat config not found!");
32
+ return null;
33
+ }
34
+ let url = "https://open.weixin.qq.com/connect/qrconnect?appid=" + IServerConfig_1.GServerCfg.wechat.app_id;
35
+ url += "&redirect_uri=" + URLEncode.encode(IServerConfig_1.GServerCfg.wechat.redirect_uri);
33
36
  url += "&response_type=code&scope=snsapi_login";
34
37
  //必须 client端的状态值。用于第三方应用防止CSRF攻击,成功授权后回调时会原样带回。请务必严格按照流程检查用户与state参数状态的绑定。
35
38
  let state = _.random(1000000, 9999999);
@@ -40,7 +43,11 @@ class WechatTool {
40
43
  if (!auth_code) {
41
44
  return null;
42
45
  }
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";
46
+ if (!IServerConfig_1.GServerCfg.wechat) {
47
+ Log_1.GLog.error("wechat config not found!");
48
+ return null;
49
+ }
50
+ let url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + IServerConfig_1.GServerCfg.wechat.app_id + "&secret=" + IServerConfig_1.GServerCfg.wechat.app_key + "&code=" + auth_code + "&grant_type=authorization_code";
44
51
  let rs = await HttpTool_1.GHttpTool.get(url);
45
52
  /*
46
53
  {
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GMongoCacheSer = exports.MongoUserModel = exports.MysqlUserModel = exports.MongoUserService = exports.MysqlUserService = exports.MongoAccountService = exports.MysqlAccountService = exports.EAccountFrom = exports.EUserState = exports.ERoleGroup = exports.GLog = exports.GHttpTool = exports.GCacheTool = exports.RedisManager = exports.GRedisMgr = exports.SqlReturns = exports.SqlReturn = exports.SqlResult = exports.GMysqlMgr = exports.MysqlBaseService = exports.GMSSqlMgr = exports.GMongoMgr = exports.MongoExt = exports.MongoManager = exports.MongoBaseModel = exports.MysqlBaseModel = exports.MongoBaseService = exports.EPropertyType = exports.Type = exports.Table = exports.Property = exports.PrimaryKey = exports.NotNull = exports.AutoIncrement = exports.Timer = exports.core = exports.GServerCfg = exports.IServerConfig = exports.FrameworkConfig = exports.Config = exports.FrameworkErrorCode = exports.GTriggerMgr = exports.Trigger = exports.Point = exports.Entity = exports.BehaviorAI = exports.AStar = exports.AiObject = exports.GDBCache = exports.GCgServer = void 0;
4
- exports.CgMq = exports.Rpc = exports.RpcBaseMsg = exports.EAccountState = exports.GEventTool = exports.GSyncQueueTool = exports.WebServerConfig = exports.Response = exports.Request = exports.RazorJs = exports.Engine = exports.GCtrMgr = exports.JsonCreatorValidate = exports.JsonAuthorityValidate = exports.JsonAdminValidate = exports.CreatorValidate = exports.AuthorityValidate = exports.AdminValidate = exports.MongoAccountModel = exports.MysqlAccountModel = exports.MongoBaseUserController = exports.MysqlBaseUserController = exports.BaseController = exports.IWebServer = exports.GWechatTool = exports.GWechatOATool = exports.GQQTool = exports.GQiniuTool = exports.GOpenSocial = exports.GEmailTool = exports.GAppleTool = exports.GSmsTool = exports.AlipayCallBack = exports.AlipayResult = exports.GAlipayTool = exports.BaseMsg = exports.IWebSocket = exports.ISocketServer = exports.IClientWebSocket = exports.IServerWebSocket = exports.JsonProtoFilter = exports.GoogleProtoFilter = exports.EProtoType = exports.GProtoFactory = exports.RedisConfig = exports.MysqlConfig = exports.MongoConfig = exports.MSSqlConfig = exports.DbConfig = exports.MongoCacheModel = void 0;
5
- exports.GByteTool = exports.SyncCallServer2 = exports.SyncCallServer = exports.SyncCall2 = exports.SyncCall = exports.IRpcClientWebSocket = exports.IRpcServerWebSocket = exports.RpcConfig = void 0;
4
+ exports.RpcConfig = exports.CgMq = exports.Rpc = exports.RpcBaseMsg = exports.EAccountState = exports.GEventTool = exports.GSyncQueueTool = exports.WebServerConfig = exports.Response = exports.Request = exports.RazorJs = exports.Engine = exports.GCtrMgr = exports.JsonCreatorValidate = exports.JsonAuthorityValidate = exports.JsonAdminValidate = exports.CreatorValidate = exports.AuthorityValidate = exports.AdminValidate = exports.MongoAccountModel = exports.MysqlAccountModel = exports.MongoBaseUserController = exports.MysqlBaseUserController = exports.BaseController = exports.IWebServer = exports.GWechatTool = exports.GWechatOATool = exports.GQQTool = exports.GQiniuTool = exports.GEmailTool = exports.GAppleTool = exports.GSmsTool = exports.AlipayCallBack = exports.AlipayResult = exports.GAlipayTool = exports.BaseMsg = exports.IWebSocket = exports.ISocketServer = exports.IClientWebSocket = exports.IServerWebSocket = exports.JsonProtoFilter = exports.GoogleProtoFilter = exports.EProtoType = exports.GProtoFactory = exports.RedisConfig = exports.MysqlConfig = exports.MongoConfig = exports.MSSqlConfig = exports.DbConfig = exports.MongoCacheModel = void 0;
5
+ exports.GByteTool = exports.SyncCallServer2 = exports.SyncCallServer = exports.SyncCall2 = exports.SyncCall = exports.IRpcClientWebSocket = exports.IRpcServerWebSocket = void 0;
6
6
  var cgserver_1 = require("./cgserver");
7
7
  Object.defineProperty(exports, "GCgServer", { enumerable: true, get: function () { return cgserver_1.GCgServer; } });
8
8
  var DBCache_1 = require("./Database/Decorator/DBCache");
@@ -132,8 +132,6 @@ var AppleTool_1 = require("./ThirdParty/AppleTool");
132
132
  Object.defineProperty(exports, "GAppleTool", { enumerable: true, get: function () { return AppleTool_1.GAppleTool; } });
133
133
  var EmailTool_1 = require("./ThirdParty/EmailTool");
134
134
  Object.defineProperty(exports, "GEmailTool", { enumerable: true, get: function () { return EmailTool_1.GEmailTool; } });
135
- var OpenSocial_1 = require("./ThirdParty/OpenSocial");
136
- Object.defineProperty(exports, "GOpenSocial", { enumerable: true, get: function () { return OpenSocial_1.GOpenSocial; } });
137
135
  var QiniuTool_1 = require("./ThirdParty/QiniuTool");
138
136
  Object.defineProperty(exports, "GQiniuTool", { enumerable: true, get: function () { return QiniuTool_1.GQiniuTool; } });
139
137
  var QQTool_1 = require("./ThirdParty/QQTool");
@@ -1,4 +1,3 @@
1
- import { RpcConfig } from "../ThirdParty/CgMq";
2
1
  import { Config } from "./Config";
3
2
  import { DbConfig } from "./DbConfig";
4
3
  export declare enum ESessionType {
@@ -46,6 +45,62 @@ export declare class WebServerConfig {
46
45
  }[];
47
46
  rootview: string;
48
47
  }
48
+ declare class AliSmsConfig {
49
+ signName: string;
50
+ accessKeyId: string;
51
+ secretAccessKey: string;
52
+ templateCode: string;
53
+ }
54
+ declare class QiNiuConfig {
55
+ host: string;
56
+ bucket: string;
57
+ accessKey: string;
58
+ secretKey: string;
59
+ }
60
+ declare class EmailConfig {
61
+ host: string;
62
+ port: number;
63
+ secure: boolean;
64
+ auth: {
65
+ user: string;
66
+ pass: string;
67
+ };
68
+ from: string;
69
+ }
70
+ declare class QQConfig {
71
+ app_id: string;
72
+ app_key: string;
73
+ redirect_uri: string;
74
+ }
75
+ declare class WechatConfig {
76
+ app_id: string;
77
+ app_key: string;
78
+ redirect_uri: string;
79
+ }
80
+ declare class AlipayConfig {
81
+ open: boolean;
82
+ dev: boolean;
83
+ app_id: string;
84
+ app_key: string;
85
+ gateway: string;
86
+ signType: string;
87
+ /** 指定private key类型, 默认: PKCS1, PKCS8: PRIVATE KEY, PKCS1: RSA PRIVATE KEY */
88
+ keyType: string;
89
+ alipay_root_cert_sn: string;
90
+ alipay_cert_sn: string;
91
+ app_cert_sn: string;
92
+ notify_url: string;
93
+ app_id_dev: string;
94
+ app_key_dev: string;
95
+ gateway_dev: string;
96
+ signType_dev: string;
97
+ /** 指定private key类型, 默认: PKCS1, PKCS8: PRIVATE KEY, PKCS1: RSA PRIVATE KEY */
98
+ keyType_dev: string;
99
+ alipay_root_cert_sn_dev: string;
100
+ alipay_cert_sn_dev: string;
101
+ app_cert_sn_dev: string;
102
+ notify_url_dev: "";
103
+ }
49
104
  export declare class FrameworkConfig extends Config {
50
105
  console_level: number;
51
106
  log: {
@@ -125,80 +180,18 @@ export declare class FrameworkConfig extends Config {
125
180
  * 控制网络消息的
126
181
  */
127
182
  debug_msg: boolean;
128
- local_host: string;
129
- internet_host: string;
130
183
  db: DbConfig;
131
- third_cfg: {
132
- open_social: {
133
- app_id: string;
134
- app_secret: string;
135
- auth_url: string;
136
- user_url: string;
137
- update_pwd_url: string;
138
- };
139
- aliSms: {
140
- signName: string;
141
- accessKeyId: string;
142
- secretAccessKey: string;
143
- templateCode: string;
144
- };
145
- qiniu: {
146
- host: string;
147
- bucket: string;
148
- accessKey: string;
149
- secretKey: string;
150
- };
151
- email: {
152
- host: string;
153
- port: number;
154
- secure: boolean;
155
- auth: {
156
- user: string;
157
- pass: string;
158
- };
159
- from: string;
160
- };
161
- qq: {
162
- app_id: string;
163
- app_key: string;
164
- redirect_uri: string;
165
- };
166
- wechat: {
167
- app_id: string;
168
- app_key: string;
169
- redirect_uri: string;
170
- };
171
- alipay: {
172
- open: boolean;
173
- dev: boolean;
174
- app_id: string;
175
- app_key: string;
176
- gateway: string;
177
- signType: "RSA2" | "RSA";
178
- /** 指定private key类型, 默认: PKCS1, PKCS8: PRIVATE KEY, PKCS1: RSA PRIVATE KEY */
179
- keyType: "PKCS1" | "PKCS8";
180
- alipay_root_cert_sn: string;
181
- alipay_cert_sn: string;
182
- app_cert_sn: string;
183
- notify_url: string;
184
- app_id_dev: string;
185
- app_key_dev: string;
186
- gateway_dev: string;
187
- signType_dev: "RSA2" | "RSA";
188
- /** 指定private key类型, 默认: PKCS1, PKCS8: PRIVATE KEY, PKCS1: RSA PRIVATE KEY */
189
- keyType_dev: "PKCS1" | "PKCS8";
190
- alipay_root_cert_sn_dev: string;
191
- alipay_cert_sn_dev: string;
192
- app_cert_sn_dev: string;
193
- notify_url_dev: string;
194
- };
195
- apple: {
196
- keyIds: {};
197
- };
198
- cgrpc: RpcConfig;
184
+ aliSms: AliSmsConfig;
185
+ qiniu: QiNiuConfig;
186
+ email: EmailConfig;
187
+ qq: QQConfig;
188
+ wechat: WechatConfig;
189
+ alipay: AlipayConfig;
190
+ apple: {
191
+ keyIds: {};
199
192
  };
200
- ip_to_domain: {};
201
193
  root_path: string;
202
194
  constructor();
203
195
  init(): boolean;
204
196
  }
197
+ export {};
@@ -84,7 +84,7 @@ export declare class core {
84
84
  static getStartTime(time?: number): number;
85
85
  static getLastMonthStartTime(): number;
86
86
  static getCurMonthStartTime(): number;
87
- static getLastWeekStartTime(): number;
87
+ static getNextWeekStartTime(): number;
88
88
  static getCurWeekStartTime(): number;
89
89
  static isSameMonth(src_time: number, target_time: number): boolean;
90
90
  static isSameDay(src_time: number, target_time: number): boolean;
@@ -55,13 +55,6 @@ export declare class MongoAccountService<T extends MongoAccountModel> extends Mo
55
55
  errcode: any;
56
56
  account: T;
57
57
  }>;
58
- /**
59
- * 修改密码
60
- * @param unionid
61
- * @param openid
62
- * @param new_pwd
63
- */
64
- updatePwd(unionid: string, openid: string, new_pwd: string): Promise<any>;
65
58
  register(type: EAccountFrom, key: string, password: string, ip: string, extra?: any): Promise<{
66
59
  user: MongoUserModel;
67
60
  errcode: any;
@@ -60,13 +60,6 @@ export declare class MysqlAccountService<T extends MysqlAccountModel> extends My
60
60
  errcode: any;
61
61
  account: T;
62
62
  }>;
63
- /**
64
- * 修改密码
65
- * @param unionid
66
- * @param openid
67
- * @param new_pwd
68
- */
69
- updatePwd(unionid: string, openid: string, new_pwd: string): Promise<any>;
70
63
  register(type: EAccountFrom, key: string, password: string, ip: string, extra?: any): Promise<{
71
64
  user: MysqlUserModel;
72
65
  errcode: any;
@@ -17,7 +17,7 @@ export declare enum EAccountState {
17
17
  }
18
18
  export declare enum EAccountFrom {
19
19
  Guest = 0,
20
- OpenSocial = 1,
20
+ _OpenSocial = 1,
21
21
  WeChat = 2,
22
22
  QQ = 3,
23
23
  Phone = 4,
@@ -56,7 +56,6 @@ export { GAlipayTool, AlipayResult, AlipayCallBack } from './ThirdParty/AlipayTo
56
56
  export { GSmsTool } from './ThirdParty/Alisms';
57
57
  export { GAppleTool } from './ThirdParty/AppleTool';
58
58
  export { GEmailTool } from './ThirdParty/EmailTool';
59
- export { GOpenSocial } from './ThirdParty/OpenSocial';
60
59
  export { GQiniuTool } from './ThirdParty/QiniuTool';
61
60
  export { GQQTool } from './ThirdParty/QQTool';
62
61
  export { GWechatOATool } from './ThirdParty/WechatOATool';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cgserver",
3
- "version": "9.1.8",
3
+ "version": "9.1.10",
4
4
  "author": "trojan",
5
5
  "type": "commonjs",
6
6
  "description": "free for all.Websocket or Http",