yakuza0 2.23.34 → 2.23.37

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yakuza0",
3
- "version": "2.23.34",
3
+ "version": "2.23.37",
4
4
  "description": "yakuza0 with nuxt",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -67,7 +67,7 @@
67
67
  "get-port": "^5.0.0",
68
68
  "html-loader": "^1.3.2",
69
69
  "http-proxy": "^1.18.1",
70
- "http-proxy-middleware": "^2.0.6",
70
+ "http-proxy-middleware": "^2.0.7",
71
71
  "isomorphic-fetch": "^2.2.1",
72
72
  "json-format": "^1.0.1",
73
73
  "koa": "^2.13.3",
@@ -112,7 +112,7 @@
112
112
  "stylus-loader": "^3.0.2",
113
113
  "sync-request": "^6.1.0",
114
114
  "tcp-port-used": "^1.0.1",
115
- "ua-parser-js": "^0.7.20",
115
+ "ua-parser-js": "^0.7.40",
116
116
  "uglify-js": "^3.17.4",
117
117
  "v8-compile-cache": "^2.0.2",
118
118
  "yakuza1": "^2.6.21"
package/pxnpm-lock.yaml CHANGED
@@ -141,7 +141,7 @@ dependencies:
141
141
  specifier: ^1.18.1
142
142
  version: 1.18.1
143
143
  http-proxy-middleware:
144
- specifier: ^2.0.6
144
+ specifier: ^2.0.7
145
145
  version: 2.0.7
146
146
  isomorphic-fetch:
147
147
  specifier: ^2.2.1
@@ -231,7 +231,7 @@ dependencies:
231
231
  specifier: ^2.2.0
232
232
  version: 2.5.0
233
233
  string-replace-loader:
234
- specifier: ^3.1.0
234
+ specifier: 3.1.0
235
235
  version: 3.1.0(webpack@4.47.0)
236
236
  stylelint:
237
237
  specifier: ^14.1.0
@@ -276,7 +276,7 @@ dependencies:
276
276
  specifier: ^1.0.1
277
277
  version: 1.0.2
278
278
  ua-parser-js:
279
- specifier: ^0.7.20
279
+ specifier: ^0.7.40
280
280
  version: 0.7.40
281
281
  uglify-js:
282
282
  specifier: ^3.17.4
@@ -88,10 +88,6 @@ var _koaSslify2 = _interopRequireDefault(_koaSslify);
88
88
 
89
89
  var _koaMid = require('../../utils/koaMid');
90
90
 
91
- var _universal = require('yakuza1/lib/ky/universal');
92
-
93
- var _universal2 = _interopRequireDefault(_universal);
94
-
95
91
  var _fraud = require('./fraud');
96
92
 
97
93
  var fraud = _interopRequireWildcard(_fraud);
@@ -106,10 +102,14 @@ var _httpProxy2 = _interopRequireDefault(_httpProxy);
106
102
 
107
103
  var _csp = require('../../utils/csp');
108
104
 
105
+ var _ck = require('../../utils/ck');
106
+
109
107
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
110
108
 
111
109
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
112
110
 
111
+ // import helmet from 'helmet';
112
+
113
113
  // import {symmetry as gs, asymmetric as as} from 'yakuza1/lib/encrypt/general';
114
114
  // import koaJwt from 'koa-jwt';
115
115
  var codeMessage = {
@@ -129,8 +129,6 @@ var codeMessage = {
129
129
  503: '服务不可用,服务器暂时过载或维护。',
130
130
  504: '网关超时。'
131
131
  };
132
- // import helmet from 'helmet';
133
-
134
132
  // import {getCache, keys} from "../cache/conf";
135
133
  // import csrfPri from "./csrfPri";
136
134
  // import csrfPub from "yakuza1/lib/cert/csrfPub";
@@ -176,6 +174,23 @@ var ssrReqAllow = function ssrReqAllow(ctx) {
176
174
  return ak && ak === _server.global.__yConf_ak__ && isSsr;
177
175
  };
178
176
 
177
+ var parseBrowserType = function parseBrowserType() {
178
+ var userAgent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
179
+
180
+ if (typeof userAgent !== 'string' || userAgent.length > 512) {
181
+ return '';
182
+ }
183
+
184
+ try {
185
+ var parser = new _uaParserJs2.default();
186
+ parser.setUA(userAgent);
187
+ var result = parser.getResult();
188
+ return result.browser.name + parseInt(result.browser.version, 10);
189
+ } catch (e) {
190
+ return '';
191
+ }
192
+ };
193
+
179
194
  var ddos = {};
180
195
 
181
196
  exports.default = function () {
@@ -420,7 +435,7 @@ exports.default = function () {
420
435
  }, _callee, undefined);
421
436
  }));
422
437
 
423
- return function (_x3, _x4) {
438
+ return function (_x4, _x5) {
424
439
  return _ref4.apply(this, arguments);
425
440
  };
426
441
  }());
@@ -447,7 +462,7 @@ exports.default = function () {
447
462
  }, _callee2, undefined);
448
463
  }));
449
464
 
450
- return function (_x5, _x6) {
465
+ return function (_x6, _x7) {
451
466
  return _ref5.apply(this, arguments);
452
467
  };
453
468
  }());
@@ -509,7 +524,7 @@ exports.default = function () {
509
524
  }, _callee3, undefined);
510
525
  }));
511
526
 
512
- return function (_x7, _x8) {
527
+ return function (_x8, _x9) {
513
528
  return _ref6.apply(this, arguments);
514
529
  };
515
530
  }());
@@ -540,7 +555,7 @@ exports.default = function () {
540
555
  }, _callee4, undefined);
541
556
  }));
542
557
 
543
- return function (_x9, _x10) {
558
+ return function (_x10, _x11) {
544
559
  return _ref7.apply(this, arguments);
545
560
  };
546
561
  }());
@@ -602,7 +617,7 @@ exports.default = function () {
602
617
  }, _callee5, undefined);
603
618
  }));
604
619
 
605
- return function (_x11, _x12) {
620
+ return function (_x12, _x13) {
606
621
  return _ref8.apply(this, arguments);
607
622
  };
608
623
  }());
@@ -640,7 +655,7 @@ exports.default = function () {
640
655
  }, _callee6, undefined);
641
656
  }));
642
657
 
643
- return function (_x13, _x14) {
658
+ return function (_x14, _x15) {
644
659
  return _ref9.apply(this, arguments);
645
660
  };
646
661
  }());
@@ -737,7 +752,7 @@ exports.default = function () {
737
752
  }, _callee7, undefined);
738
753
  }));
739
754
 
740
- return function (_x15, _x16) {
755
+ return function (_x16, _x17) {
741
756
  return _ref10.apply(this, arguments);
742
757
  };
743
758
  }()
@@ -786,7 +801,7 @@ exports.default = function () {
786
801
  }, _callee8, undefined);
787
802
  }));
788
803
 
789
- return function (_x17, _x18) {
804
+ return function (_x18, _x19) {
790
805
  return _ref11.apply(this, arguments);
791
806
  };
792
807
  }());
@@ -794,16 +809,12 @@ exports.default = function () {
794
809
 
795
810
  appCp(function () {
796
811
  var _ref12 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(ctx, next) {
797
- var parser, result, browserType, bt, bs, url, isNext;
812
+ var browserType, bt, bs, url, isNext;
798
813
  return _regenerator2.default.wrap(function _callee9$(_context9) {
799
814
  while (1) {
800
815
  switch (_context9.prev = _context9.next) {
801
816
  case 0:
802
- parser = new _uaParserJs2.default();
803
-
804
- parser.setUA(ctx.get('user-agent'));
805
- result = parser.getResult();
806
- browserType = result.browser.name + parseInt(result.browser.version, 10);
817
+ browserType = parseBrowserType(ctx.get('user-agent'));
807
818
  bt = config.appConf.server.browsers.redirect;
808
819
  bs = config.appConf.server.browsers.static;
809
820
  url = null;
@@ -828,14 +839,14 @@ exports.default = function () {
828
839
  }
829
840
 
830
841
  if (!isNext) {
831
- _context9.next = 14;
842
+ _context9.next = 11;
832
843
  break;
833
844
  }
834
845
 
835
- _context9.next = 14;
846
+ _context9.next = 11;
836
847
  return next();
837
848
 
838
- case 14:
849
+ case 11:
839
850
  case 'end':
840
851
  return _context9.stop();
841
852
  }
@@ -843,7 +854,7 @@ exports.default = function () {
843
854
  }, _callee9, undefined);
844
855
  }));
845
856
 
846
- return function (_x19, _x20) {
857
+ return function (_x20, _x21) {
847
858
  return _ref12.apply(this, arguments);
848
859
  };
849
860
  }());
@@ -878,7 +889,7 @@ exports.default = function () {
878
889
  }, _callee10, undefined);
879
890
  }));
880
891
 
881
- return function (_x21, _x22) {
892
+ return function (_x22, _x23) {
882
893
  return _ref13.apply(this, arguments);
883
894
  };
884
895
  }());
@@ -911,58 +922,65 @@ exports.default = function () {
911
922
  }
912
923
  Cookie = _server.Cookies.koaGetCookieStr({ req: ctx.req });
913
924
 
925
+ (0, _ck.logDebugSuError)(Cookie, 'rHost: ' + rHost);
926
+ (0, _ck.logDebugSuError)(Cookie, 'rOrigin: ' + rOrigin);
927
+ (0, _ck.logDebugSuError)(Cookie, 'rReferer: ' + rReferer);
928
+ (0, _ck.logDebugSuError)(Cookie, 'rx isNext: ' + isNext);
929
+
914
930
  if (!Cookie) {
915
- _context11.next = 15;
931
+ _context11.next = 20;
916
932
  break;
917
933
  }
918
934
 
919
- _context11.prev = 7;
920
- _context11.next = 10;
921
- return _universal2.default.post(_config2.default.server.orbAddr + '/apiv2/cln/verify/ck', {
935
+ _context11.prev = 11;
936
+ _context11.next = 14;
937
+ return (0, _server.curl)(_config2.default.server.orbAddr + '/apiv2/cln/verify/ck', {
938
+ method: 'POST',
922
939
  headers: {
923
940
  Cookie: Cookie
924
941
  },
925
942
  timeout: 2000
926
943
  });
927
944
 
928
- case 10:
929
- _context11.next = 15;
945
+ case 14:
946
+ _context11.next = 20;
930
947
  break;
931
948
 
932
- case 12:
933
- _context11.prev = 12;
934
- _context11.t0 = _context11['catch'](7);
949
+ case 16:
950
+ _context11.prev = 16;
951
+ _context11.t0 = _context11['catch'](11);
935
952
 
953
+ (0, _ck.logDebugSuError)(Cookie, _context11.t0);
936
954
  isNext = false;
937
955
 
938
- case 15:
956
+ case 20:
939
957
  if (!isNext) {
940
- _context11.next = 20;
958
+ _context11.next = 25;
941
959
  break;
942
960
  }
943
961
 
944
- _context11.next = 18;
962
+ _context11.next = 23;
945
963
  return next();
946
964
 
947
- case 18:
948
- _context11.next = 21;
965
+ case 23:
966
+ _context11.next = 26;
949
967
  break;
950
968
 
951
- case 20:
969
+ case 25:
952
970
  ctx.body = apiErr({
953
971
  status: 500,
954
972
  data: '请求完整性校验错误,连接被拒绝'
955
973
  }, ctx);
956
974
 
957
- case 21:
975
+ case 26:
958
976
  case 'end':
959
977
  return _context11.stop();
960
978
  }
961
979
  }
962
- }, _callee11, undefined, [[7, 12]]);
980
+ }, _callee11, undefined, [[11, 16]]);
963
981
  }));
964
982
 
965
- return function (_x23, _x24) {
983
+ return function (_x24, _x25) {
966
984
  return _ref14.apply(this, arguments);
967
985
  };
968
986
  }()
@@ -998,7 +1016,7 @@ exports.default = function () {
998
1016
  }, _callee12, undefined);
999
1017
  }));
1000
1018
 
1001
- return function (_x25, _x26) {
1019
+ return function (_x26, _x27) {
1002
1020
  return _ref15.apply(this, arguments);
1003
1021
  };
1004
1022
  }());
@@ -1043,7 +1061,7 @@ exports.default = function () {
1043
1061
  }, _callee13, undefined);
1044
1062
  }));
1045
1063
 
1046
- return function (_x27, _x28) {
1064
+ return function (_x28, _x29) {
1047
1065
  return _ref16.apply(this, arguments);
1048
1066
  };
1049
1067
  }());
@@ -1056,7 +1074,7 @@ exports.default = function () {
1056
1074
  }, _callee14, undefined);
1057
1075
  }));
1058
1076
 
1059
- return function (_x) {
1077
+ return function (_x2) {
1060
1078
  return _ref3.apply(this, arguments);
1061
1079
  };
1062
1080
  }();
package/utils/ck.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setOfflineCookie = exports.addCookieStr = undefined;
6
+ exports.setOfflineCookie = exports.addCookieStr = exports.logDebugSuError = exports.hasCookieKey = exports.DEBUG_SU_COOKIE_KEY = undefined;
7
7
 
8
8
  var _config = require("../config");
9
9
 
@@ -13,6 +13,27 @@ var _yakuza = require("yakuza1");
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
+ var DEBUG_SU_COOKIE_KEY = exports.DEBUG_SU_COOKIE_KEY = '__yk0_debug_su_';
17
+
18
+ var hasCookieKey = exports.hasCookieKey = function hasCookieKey(cookieStr, key) {
19
+ if (!cookieStr || !key) {
20
+ return false;
21
+ }
22
+
23
+ return cookieStr.split(';').some(function (item) {
24
+ var cookieKey = item.trim().split('=')[0];
25
+ return cookieKey === key;
26
+ });
27
+ };
28
+
29
+ var logDebugSuError = exports.logDebugSuError = function logDebugSuError(cookieStr, err) {
30
+ var message = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '[yk0 csrf verify cookie error]';
31
+
32
+ if (hasCookieKey(cookieStr, DEBUG_SU_COOKIE_KEY)) {
33
+ console.error(message, err);
34
+ }
35
+ };
36
+
16
37
  var addCookieStr = exports.addCookieStr = function addCookieStr(req, oc, key) {
17
38
  var match = '';
18
39
  if ((0, _yakuza.checkServer)() && req && req.headers && req.headers.cookie) {