yakuza0 2.20.3 → 2.20.7
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/cli/index.js +19 -10
- package/nuxt/build/index.js +26 -5
- package/nuxt/buildModules/logger.js +5 -0
- package/nuxt/buildModules/stylelint.js +58 -0
- package/nuxt/buildModules/utils.js +13 -0
- package/nuxt/store/index.js +7 -0
- package/nuxt/store/init.js +27 -0
- package/nuxt/style.js +12 -0
- package/package.json +14 -4
- package/server/proxy/csrf.js +146 -101
- package/server/proxy/tire.js +41 -18
- package/template/yk.plugin.js +1 -0
- package/utils/console.js +22 -12
- package/utils/gray.js +1 -1
- package/utils/inclusive.js +35 -17
- package/utils/secret.js +21 -3
- package/utils/verify.js +77 -2
package/server/proxy/csrf.js
CHANGED
|
@@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
var _regenerator = require('babel-runtime/regenerator');
|
|
8
|
-
|
|
9
|
-
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
10
|
-
|
|
11
7
|
var _keys = require('babel-runtime/core-js/object/keys');
|
|
12
8
|
|
|
13
9
|
var _keys2 = _interopRequireDefault(_keys);
|
|
14
10
|
|
|
11
|
+
var _regenerator = require('babel-runtime/regenerator');
|
|
12
|
+
|
|
13
|
+
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
14
|
+
|
|
15
15
|
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
|
|
16
16
|
|
|
17
17
|
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
|
|
@@ -165,13 +165,13 @@ var ssrReqAllow = function ssrReqAllow(ctx) {
|
|
|
165
165
|
var ddos = {};
|
|
166
166
|
|
|
167
167
|
exports.default = function () {
|
|
168
|
-
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function
|
|
168
|
+
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(_ref2) {
|
|
169
169
|
var app = _ref2.app,
|
|
170
170
|
config = _ref2.config;
|
|
171
171
|
var cspConnectSrcVerify, appCp, appCpApiV1, jwtVerC, omConf, cm;
|
|
172
|
-
return _regenerator2.default.wrap(function
|
|
172
|
+
return _regenerator2.default.wrap(function _callee11$(_context11) {
|
|
173
173
|
while (1) {
|
|
174
|
-
switch (
|
|
174
|
+
switch (_context11.prev = _context11.next) {
|
|
175
175
|
case 0:
|
|
176
176
|
// if (yConf.security.isTire) {
|
|
177
177
|
// const proxy = httpProxy.createServer({
|
|
@@ -336,10 +336,55 @@ exports.default = function () {
|
|
|
336
336
|
|
|
337
337
|
app.use(function () {
|
|
338
338
|
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx, next) {
|
|
339
|
-
var keys;
|
|
340
339
|
return _regenerator2.default.wrap(function _callee$(_context) {
|
|
341
340
|
while (1) {
|
|
342
341
|
switch (_context.prev = _context.next) {
|
|
342
|
+
case 0:
|
|
343
|
+
if (!(ctx.method.toUpperCase() === 'GET' && ctx.path === '/sys/health-check')) {
|
|
344
|
+
_context.next = 5;
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
ctx.status = 200;
|
|
349
|
+
ctx.body = {
|
|
350
|
+
response_status: 200,
|
|
351
|
+
data: 'alive'
|
|
352
|
+
};
|
|
353
|
+
_context.next = 7;
|
|
354
|
+
break;
|
|
355
|
+
|
|
356
|
+
case 5:
|
|
357
|
+
_context.next = 7;
|
|
358
|
+
return next();
|
|
359
|
+
|
|
360
|
+
case 7:
|
|
361
|
+
case 'end':
|
|
362
|
+
return _context.stop();
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}, _callee, undefined);
|
|
366
|
+
}));
|
|
367
|
+
|
|
368
|
+
return function (_x3, _x4) {
|
|
369
|
+
return _ref4.apply(this, arguments);
|
|
370
|
+
};
|
|
371
|
+
}()
|
|
372
|
+
// if (ctx.method !== "/") {
|
|
373
|
+
// const keys = [...Object.keys(yConf.proxyServer.proxy), yConf.proxyServer.apiKey];
|
|
374
|
+
// keys.forEach((key) => {
|
|
375
|
+
// const tk = _.trim(key);
|
|
376
|
+
// ctx.path = ctx.path.replace(config.appConf.server.basePath + "/" + tk, tk);
|
|
377
|
+
// })
|
|
378
|
+
// }
|
|
379
|
+
// await next()
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
app.use(function () {
|
|
383
|
+
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx, next) {
|
|
384
|
+
var keys;
|
|
385
|
+
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
|
386
|
+
while (1) {
|
|
387
|
+
switch (_context2.prev = _context2.next) {
|
|
343
388
|
case 0:
|
|
344
389
|
if (config.appConf.server.basePath !== "/") {
|
|
345
390
|
keys = [].concat((0, _toConsumableArray3.default)((0, _keys2.default)(_config2.default.proxyServer.proxy)), [_config2.default.proxyServer.apiKey]);
|
|
@@ -349,19 +394,19 @@ exports.default = function () {
|
|
|
349
394
|
ctx.path = ctx.path.replace(config.appConf.server.basePath + "/" + tk, tk);
|
|
350
395
|
});
|
|
351
396
|
}
|
|
352
|
-
|
|
397
|
+
_context2.next = 3;
|
|
353
398
|
return next();
|
|
354
399
|
|
|
355
400
|
case 3:
|
|
356
401
|
case 'end':
|
|
357
|
-
return
|
|
402
|
+
return _context2.stop();
|
|
358
403
|
}
|
|
359
404
|
}
|
|
360
|
-
},
|
|
405
|
+
}, _callee2, undefined);
|
|
361
406
|
}));
|
|
362
407
|
|
|
363
|
-
return function (
|
|
364
|
-
return
|
|
408
|
+
return function (_x5, _x6) {
|
|
409
|
+
return _ref5.apply(this, arguments);
|
|
365
410
|
};
|
|
366
411
|
}());
|
|
367
412
|
|
|
@@ -381,69 +426,69 @@ exports.default = function () {
|
|
|
381
426
|
_server.global.__cpm__ = (0, _httpProxyMiddleware.createProxyMiddleware)((0, _extends3.default)({}, cm));
|
|
382
427
|
|
|
383
428
|
appCp(function () {
|
|
384
|
-
var
|
|
385
|
-
return _regenerator2.default.wrap(function
|
|
429
|
+
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx, next) {
|
|
430
|
+
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
|
386
431
|
while (1) {
|
|
387
|
-
switch (
|
|
432
|
+
switch (_context3.prev = _context3.next) {
|
|
388
433
|
case 0:
|
|
389
434
|
if (!(0, _om.isOmOpen)(ctx.req)) {
|
|
390
|
-
|
|
435
|
+
_context3.next = 9;
|
|
391
436
|
break;
|
|
392
437
|
}
|
|
393
438
|
|
|
394
439
|
if (!((0, _keys2.default)(omConf.router).length > 0)) {
|
|
395
|
-
|
|
440
|
+
_context3.next = 6;
|
|
396
441
|
break;
|
|
397
442
|
}
|
|
398
443
|
|
|
399
|
-
|
|
444
|
+
_context3.next = 4;
|
|
400
445
|
return (0, _koa2Connect2.default)(_server.global.__cpm__)(ctx, next);
|
|
401
446
|
|
|
402
447
|
case 4:
|
|
403
|
-
|
|
448
|
+
_context3.next = 7;
|
|
404
449
|
break;
|
|
405
450
|
|
|
406
451
|
case 6:
|
|
407
452
|
ctx.body = _msg.errMsg['server.om.target.none'];
|
|
408
453
|
|
|
409
454
|
case 7:
|
|
410
|
-
|
|
455
|
+
_context3.next = 11;
|
|
411
456
|
break;
|
|
412
457
|
|
|
413
458
|
case 9:
|
|
414
|
-
|
|
459
|
+
_context3.next = 11;
|
|
415
460
|
return next();
|
|
416
461
|
|
|
417
462
|
case 11:
|
|
418
463
|
case 'end':
|
|
419
|
-
return
|
|
464
|
+
return _context3.stop();
|
|
420
465
|
}
|
|
421
466
|
}
|
|
422
|
-
},
|
|
467
|
+
}, _callee3, undefined);
|
|
423
468
|
}));
|
|
424
469
|
|
|
425
|
-
return function (
|
|
426
|
-
return
|
|
470
|
+
return function (_x7, _x8) {
|
|
471
|
+
return _ref6.apply(this, arguments);
|
|
427
472
|
};
|
|
428
473
|
}());
|
|
429
474
|
}
|
|
430
475
|
|
|
431
476
|
appCp(function () {
|
|
432
|
-
var
|
|
433
|
-
return _regenerator2.default.wrap(function
|
|
477
|
+
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(ctx, next) {
|
|
478
|
+
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
|
434
479
|
while (1) {
|
|
435
|
-
switch (
|
|
480
|
+
switch (_context4.prev = _context4.next) {
|
|
436
481
|
case 0:
|
|
437
482
|
if (!(ctx.method === 'GET' || ctx.method === 'POST' || jwtVerC(ctx.path))) {
|
|
438
|
-
|
|
483
|
+
_context4.next = 5;
|
|
439
484
|
break;
|
|
440
485
|
}
|
|
441
486
|
|
|
442
|
-
|
|
487
|
+
_context4.next = 3;
|
|
443
488
|
return next();
|
|
444
489
|
|
|
445
490
|
case 3:
|
|
446
|
-
|
|
491
|
+
_context4.next = 6;
|
|
447
492
|
break;
|
|
448
493
|
|
|
449
494
|
case 5:
|
|
@@ -454,26 +499,26 @@ exports.default = function () {
|
|
|
454
499
|
|
|
455
500
|
case 6:
|
|
456
501
|
case 'end':
|
|
457
|
-
return
|
|
502
|
+
return _context4.stop();
|
|
458
503
|
}
|
|
459
504
|
}
|
|
460
|
-
},
|
|
505
|
+
}, _callee4, undefined);
|
|
461
506
|
}));
|
|
462
507
|
|
|
463
|
-
return function (
|
|
464
|
-
return
|
|
508
|
+
return function (_x9, _x10) {
|
|
509
|
+
return _ref7.apply(this, arguments);
|
|
465
510
|
};
|
|
466
511
|
}());
|
|
467
512
|
|
|
468
513
|
app.use(function () {
|
|
469
|
-
var
|
|
514
|
+
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(ctx, next) {
|
|
470
515
|
var isInclude, include, exclude, referer;
|
|
471
|
-
return _regenerator2.default.wrap(function
|
|
516
|
+
return _regenerator2.default.wrap(function _callee5$(_context5) {
|
|
472
517
|
while (1) {
|
|
473
|
-
switch (
|
|
518
|
+
switch (_context5.prev = _context5.next) {
|
|
474
519
|
case 0:
|
|
475
520
|
if (!_config2.default.server.hotLinking.enabled) {
|
|
476
|
-
|
|
521
|
+
_context5.next = 21;
|
|
477
522
|
break;
|
|
478
523
|
}
|
|
479
524
|
|
|
@@ -501,51 +546,51 @@ exports.default = function () {
|
|
|
501
546
|
// console.log(ctx.href, referer, ctx.href.indexOf(jsUrl('hostname', referer)), 11);
|
|
502
547
|
|
|
503
548
|
if (!isInclude) {
|
|
504
|
-
|
|
549
|
+
_context5.next = 17;
|
|
505
550
|
break;
|
|
506
551
|
}
|
|
507
552
|
|
|
508
553
|
if (!(typeof referer === 'string' && referer !== '' && ctx.href.indexOf((0, _server.jsUrl)('hostname', referer)) !== -1)) {
|
|
509
|
-
|
|
554
|
+
_context5.next = 14;
|
|
510
555
|
break;
|
|
511
556
|
}
|
|
512
557
|
|
|
513
|
-
|
|
558
|
+
_context5.next = 12;
|
|
514
559
|
return next();
|
|
515
560
|
|
|
516
561
|
case 12:
|
|
517
|
-
|
|
562
|
+
_context5.next = 15;
|
|
518
563
|
break;
|
|
519
564
|
|
|
520
565
|
case 14:
|
|
521
566
|
ctx.status = 404;
|
|
522
567
|
|
|
523
568
|
case 15:
|
|
524
|
-
|
|
569
|
+
_context5.next = 19;
|
|
525
570
|
break;
|
|
526
571
|
|
|
527
572
|
case 17:
|
|
528
|
-
|
|
573
|
+
_context5.next = 19;
|
|
529
574
|
return next();
|
|
530
575
|
|
|
531
576
|
case 19:
|
|
532
|
-
|
|
577
|
+
_context5.next = 23;
|
|
533
578
|
break;
|
|
534
579
|
|
|
535
580
|
case 21:
|
|
536
|
-
|
|
581
|
+
_context5.next = 23;
|
|
537
582
|
return next();
|
|
538
583
|
|
|
539
584
|
case 23:
|
|
540
585
|
case 'end':
|
|
541
|
-
return
|
|
586
|
+
return _context5.stop();
|
|
542
587
|
}
|
|
543
588
|
}
|
|
544
|
-
},
|
|
589
|
+
}, _callee5, undefined);
|
|
545
590
|
}));
|
|
546
591
|
|
|
547
|
-
return function (
|
|
548
|
-
return
|
|
592
|
+
return function (_x11, _x12) {
|
|
593
|
+
return _ref8.apply(this, arguments);
|
|
549
594
|
};
|
|
550
595
|
}()
|
|
551
596
|
// if (!yConf.security.stupid) {
|
|
@@ -557,16 +602,16 @@ exports.default = function () {
|
|
|
557
602
|
|
|
558
603
|
if (config.appConf.server.sslify.redirect && !config.appConf.server.generate.enabled) {
|
|
559
604
|
appCp(function () {
|
|
560
|
-
var
|
|
605
|
+
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx, next) {
|
|
561
606
|
var isRedirected;
|
|
562
|
-
return _regenerator2.default.wrap(function
|
|
607
|
+
return _regenerator2.default.wrap(function _callee6$(_context6) {
|
|
563
608
|
while (1) {
|
|
564
|
-
switch (
|
|
609
|
+
switch (_context6.prev = _context6.next) {
|
|
565
610
|
case 0:
|
|
566
611
|
isRedirected = (ctx.req.headers.cookie || '').indexOf(_config2.default.server.sslify.openKey) !== -1;
|
|
567
612
|
|
|
568
613
|
if (isRedirected) {
|
|
569
|
-
|
|
614
|
+
_context6.next = 7;
|
|
570
615
|
break;
|
|
571
616
|
}
|
|
572
617
|
|
|
@@ -574,37 +619,37 @@ exports.default = function () {
|
|
|
574
619
|
signed: false,
|
|
575
620
|
sameSite: _config2.default.server.cookieSameSite
|
|
576
621
|
});
|
|
577
|
-
|
|
622
|
+
_context6.next = 5;
|
|
578
623
|
return (0, _koaSslify2.default)((0, _extends3.default)({}, _config2.default.server.sslify.options))(ctx, next);
|
|
579
624
|
|
|
580
625
|
case 5:
|
|
581
|
-
|
|
626
|
+
_context6.next = 9;
|
|
582
627
|
break;
|
|
583
628
|
|
|
584
629
|
case 7:
|
|
585
|
-
|
|
630
|
+
_context6.next = 9;
|
|
586
631
|
return next();
|
|
587
632
|
|
|
588
633
|
case 9:
|
|
589
634
|
case 'end':
|
|
590
|
-
return
|
|
635
|
+
return _context6.stop();
|
|
591
636
|
}
|
|
592
637
|
}
|
|
593
|
-
},
|
|
638
|
+
}, _callee6, undefined);
|
|
594
639
|
}));
|
|
595
640
|
|
|
596
|
-
return function (
|
|
597
|
-
return
|
|
641
|
+
return function (_x13, _x14) {
|
|
642
|
+
return _ref9.apply(this, arguments);
|
|
598
643
|
};
|
|
599
644
|
}());
|
|
600
645
|
}
|
|
601
646
|
|
|
602
647
|
appCp(function () {
|
|
603
|
-
var
|
|
648
|
+
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(ctx, next) {
|
|
604
649
|
var parser, result, browserType, bt, bs, url, isNext;
|
|
605
|
-
return _regenerator2.default.wrap(function
|
|
650
|
+
return _regenerator2.default.wrap(function _callee7$(_context7) {
|
|
606
651
|
while (1) {
|
|
607
|
-
switch (
|
|
652
|
+
switch (_context7.prev = _context7.next) {
|
|
608
653
|
case 0:
|
|
609
654
|
parser = new _uaParserJs2.default();
|
|
610
655
|
|
|
@@ -635,23 +680,23 @@ exports.default = function () {
|
|
|
635
680
|
}
|
|
636
681
|
|
|
637
682
|
if (!isNext) {
|
|
638
|
-
|
|
683
|
+
_context7.next = 14;
|
|
639
684
|
break;
|
|
640
685
|
}
|
|
641
686
|
|
|
642
|
-
|
|
687
|
+
_context7.next = 14;
|
|
643
688
|
return next();
|
|
644
689
|
|
|
645
690
|
case 14:
|
|
646
691
|
case 'end':
|
|
647
|
-
return
|
|
692
|
+
return _context7.stop();
|
|
648
693
|
}
|
|
649
694
|
}
|
|
650
|
-
},
|
|
695
|
+
}, _callee7, undefined);
|
|
651
696
|
}));
|
|
652
697
|
|
|
653
|
-
return function (
|
|
654
|
-
return
|
|
698
|
+
return function (_x15, _x16) {
|
|
699
|
+
return _ref10.apply(this, arguments);
|
|
655
700
|
};
|
|
656
701
|
}());
|
|
657
702
|
|
|
@@ -668,11 +713,11 @@ exports.default = function () {
|
|
|
668
713
|
|
|
669
714
|
if (_config2.default.security.stupid) {
|
|
670
715
|
appCpApiV1(function () {
|
|
671
|
-
var
|
|
716
|
+
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(ctx, next) {
|
|
672
717
|
var isNext, rHost, rOrigin, rReferer;
|
|
673
|
-
return _regenerator2.default.wrap(function
|
|
718
|
+
return _regenerator2.default.wrap(function _callee8$(_context8) {
|
|
674
719
|
while (1) {
|
|
675
|
-
switch (
|
|
720
|
+
switch (_context8.prev = _context8.next) {
|
|
676
721
|
case 0:
|
|
677
722
|
isNext = true;
|
|
678
723
|
rHost = (0, _server.jsUrl)('hostname', ctx.get('host'));
|
|
@@ -684,15 +729,15 @@ exports.default = function () {
|
|
|
684
729
|
}
|
|
685
730
|
|
|
686
731
|
if (!isNext) {
|
|
687
|
-
|
|
732
|
+
_context8.next = 10;
|
|
688
733
|
break;
|
|
689
734
|
}
|
|
690
735
|
|
|
691
|
-
|
|
736
|
+
_context8.next = 8;
|
|
692
737
|
return next();
|
|
693
738
|
|
|
694
739
|
case 8:
|
|
695
|
-
|
|
740
|
+
_context8.next = 11;
|
|
696
741
|
break;
|
|
697
742
|
|
|
698
743
|
case 10:
|
|
@@ -703,14 +748,14 @@ exports.default = function () {
|
|
|
703
748
|
|
|
704
749
|
case 11:
|
|
705
750
|
case 'end':
|
|
706
|
-
return
|
|
751
|
+
return _context8.stop();
|
|
707
752
|
}
|
|
708
753
|
}
|
|
709
|
-
},
|
|
754
|
+
}, _callee8, undefined);
|
|
710
755
|
}));
|
|
711
756
|
|
|
712
|
-
return function (
|
|
713
|
-
return
|
|
757
|
+
return function (_x17, _x18) {
|
|
758
|
+
return _ref11.apply(this, arguments);
|
|
714
759
|
};
|
|
715
760
|
}()
|
|
716
761
|
// if (ctx.method === 'GET' || ctx.method === 'POST' || jwtVerC(ctx.path)) {
|
|
@@ -724,29 +769,29 @@ exports.default = function () {
|
|
|
724
769
|
);
|
|
725
770
|
|
|
726
771
|
app.use(function () {
|
|
727
|
-
var
|
|
728
|
-
return _regenerator2.default.wrap(function
|
|
772
|
+
var _ref12 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(ctx, next) {
|
|
773
|
+
return _regenerator2.default.wrap(function _callee9$(_context9) {
|
|
729
774
|
while (1) {
|
|
730
|
-
switch (
|
|
775
|
+
switch (_context9.prev = _context9.next) {
|
|
731
776
|
case 0:
|
|
732
777
|
// ctx.set('Surrogate-Control', 'no-store');
|
|
733
778
|
// ctx.set('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');
|
|
734
779
|
// ctx.set('Pragma', 'no-cache');
|
|
735
780
|
// ctx.set('Expires', '0');
|
|
736
781
|
(0, _control.noCache)(ctx);
|
|
737
|
-
|
|
782
|
+
_context9.next = 3;
|
|
738
783
|
return next();
|
|
739
784
|
|
|
740
785
|
case 3:
|
|
741
786
|
case 'end':
|
|
742
|
-
return
|
|
787
|
+
return _context9.stop();
|
|
743
788
|
}
|
|
744
789
|
}
|
|
745
|
-
},
|
|
790
|
+
}, _callee9, undefined);
|
|
746
791
|
}));
|
|
747
792
|
|
|
748
|
-
return function (
|
|
749
|
-
return
|
|
793
|
+
return function (_x19, _x20) {
|
|
794
|
+
return _ref12.apply(this, arguments);
|
|
750
795
|
};
|
|
751
796
|
}());
|
|
752
797
|
}
|
|
@@ -760,10 +805,10 @@ exports.default = function () {
|
|
|
760
805
|
}
|
|
761
806
|
|
|
762
807
|
app.use(function () {
|
|
763
|
-
var
|
|
764
|
-
return _regenerator2.default.wrap(function
|
|
808
|
+
var _ref13 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx, next) {
|
|
809
|
+
return _regenerator2.default.wrap(function _callee10$(_context10) {
|
|
765
810
|
while (1) {
|
|
766
|
-
switch (
|
|
811
|
+
switch (_context10.prev = _context10.next) {
|
|
767
812
|
case 0:
|
|
768
813
|
// const csrfCookie = ctx.cookies.get(variable.csrfCookie, {signed: false});
|
|
769
814
|
// console.log(ctx.path, ctx.req.headers.cookie, 111);
|
|
@@ -779,28 +824,28 @@ exports.default = function () {
|
|
|
779
824
|
cookieDomain: config.appConf.cookieDomain || _server.Cookies.getDefCookieDomain(ctx.hostname)
|
|
780
825
|
}, ctx.req.crossParams);
|
|
781
826
|
|
|
782
|
-
|
|
827
|
+
_context10.next = 3;
|
|
783
828
|
return next();
|
|
784
829
|
|
|
785
830
|
case 3:
|
|
786
831
|
case 'end':
|
|
787
|
-
return
|
|
832
|
+
return _context10.stop();
|
|
788
833
|
}
|
|
789
834
|
}
|
|
790
|
-
},
|
|
835
|
+
}, _callee10, undefined);
|
|
791
836
|
}));
|
|
792
837
|
|
|
793
|
-
return function (
|
|
794
|
-
return
|
|
838
|
+
return function (_x21, _x22) {
|
|
839
|
+
return _ref13.apply(this, arguments);
|
|
795
840
|
};
|
|
796
841
|
}());
|
|
797
842
|
|
|
798
|
-
case
|
|
843
|
+
case 16:
|
|
799
844
|
case 'end':
|
|
800
|
-
return
|
|
845
|
+
return _context11.stop();
|
|
801
846
|
}
|
|
802
847
|
}
|
|
803
|
-
},
|
|
848
|
+
}, _callee11, undefined);
|
|
804
849
|
}));
|
|
805
850
|
|
|
806
851
|
return function (_x) {
|
package/server/proxy/tire.js
CHANGED
|
@@ -4,6 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
+
var _keys = require("babel-runtime/core-js/object/keys");
|
|
8
|
+
|
|
9
|
+
var _keys2 = _interopRequireDefault(_keys);
|
|
10
|
+
|
|
7
11
|
var _extends2 = require("babel-runtime/helpers/extends");
|
|
8
12
|
|
|
9
13
|
var _extends3 = _interopRequireDefault(_extends2);
|
|
@@ -55,6 +59,8 @@ var express = require('express');
|
|
|
55
59
|
var _require = require('http-proxy-middleware'),
|
|
56
60
|
createProxyMiddleware = _require.createProxyMiddleware;
|
|
57
61
|
|
|
62
|
+
var autoRefreshCapacity = {};
|
|
63
|
+
|
|
58
64
|
var getCacheKey = function getCacheKey(str) {
|
|
59
65
|
return str.split('?')[0];
|
|
60
66
|
};
|
|
@@ -218,16 +224,18 @@ exports.default = function () {
|
|
|
218
224
|
app.use((0, _compression2.default)());
|
|
219
225
|
|
|
220
226
|
app.use(function (req, res, next) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
227
|
+
var method = req.method.toUpperCase();
|
|
228
|
+
var path = req.url;
|
|
229
|
+
if (method === "GET" && path === '/sys/health-check') {
|
|
230
|
+
res.status(200).send({
|
|
231
|
+
response_status: 200,
|
|
232
|
+
data: 'alive'
|
|
233
|
+
});
|
|
234
|
+
} else if (method === "GET" && path === '/__clearCache') {
|
|
224
235
|
(0, _secCache.secCacheClear)();
|
|
225
236
|
res.status(404).send("The page was not found ~~");
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
// } else {
|
|
229
|
-
//
|
|
230
|
-
// }
|
|
237
|
+
} else {
|
|
238
|
+
next();
|
|
231
239
|
}
|
|
232
240
|
});
|
|
233
241
|
|
|
@@ -323,15 +331,22 @@ exports.default = function () {
|
|
|
323
331
|
|
|
324
332
|
res.send(data.body);
|
|
325
333
|
|
|
326
|
-
|
|
334
|
+
var arKey = req.url;
|
|
335
|
+
autoRefreshCapacity[arKey] = autoRefreshCapacity[arKey] || 0;
|
|
336
|
+
if (server.generate.autoRefresh && autoRefreshCapacity[arKey] < server.generate.capacity) {
|
|
337
|
+
autoRefreshCapacity[arKey] += 1;
|
|
327
338
|
(0, _curl.curl)("http://127.0.0.1:" + config.appConf.port + req.url, {
|
|
328
339
|
method: 'GET',
|
|
329
340
|
headers: {
|
|
330
341
|
"Cookie": req.get("cookie"),
|
|
331
342
|
"x-gen-set": "true"
|
|
332
343
|
},
|
|
333
|
-
timeout:
|
|
334
|
-
}).then()
|
|
344
|
+
timeout: server.generate.autoRefreshTimeout
|
|
345
|
+
}).then(function () {
|
|
346
|
+
autoRefreshCapacity[arKey] -= 1;
|
|
347
|
+
}).catch(function () {
|
|
348
|
+
autoRefreshCapacity[arKey] -= 1;
|
|
349
|
+
});
|
|
335
350
|
}
|
|
336
351
|
} else {
|
|
337
352
|
next();
|
|
@@ -398,23 +413,31 @@ exports.default = function () {
|
|
|
398
413
|
server.generate.exclude = server.generate.exclude.split(',');
|
|
399
414
|
}
|
|
400
415
|
|
|
401
|
-
if (server.generate.
|
|
402
|
-
|
|
403
|
-
server.generate.include.forEach(function (path) {
|
|
416
|
+
if (server.generate.exclude.length !== 0) {
|
|
417
|
+
server.generate.exclude.forEach(function (path) {
|
|
404
418
|
if ((0, _server.minimatch)(req.url, path)) {
|
|
405
|
-
isCache =
|
|
419
|
+
isCache = false;
|
|
406
420
|
}
|
|
407
421
|
});
|
|
408
422
|
}
|
|
409
423
|
|
|
410
|
-
if (
|
|
411
|
-
|
|
412
|
-
if ((0, _server.minimatch)(req.url, path)) {
|
|
424
|
+
if ((0, _keys2.default)(appConf.proxyServer.proxy || []).length > 0) {
|
|
425
|
+
_server._.forEach(appConf.proxyServer.proxy, function (v, path) {
|
|
426
|
+
if ((0, _server.minimatch)(req.url, "/" + path + "*") || (0, _server.minimatch)(req.url, "/" + path + "/**")) {
|
|
413
427
|
isCache = false;
|
|
414
428
|
}
|
|
415
429
|
});
|
|
416
430
|
}
|
|
417
431
|
|
|
432
|
+
if (server.generate.include.length !== 0) {
|
|
433
|
+
isCache = false;
|
|
434
|
+
server.generate.include.forEach(function (path) {
|
|
435
|
+
if ((0, _server.minimatch)(req.url, path)) {
|
|
436
|
+
isCache = true;
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
|
|
418
441
|
var libContentType = ['application/javascript; charset=utf-8', 'text/css; charset=utf-8', 'font/woff', 'image/png', 'image/jpeg', 'image/x-icon'];
|
|
419
442
|
|
|
420
443
|
var isTireSave = _config2.default.security.isTire && isCache && ['text/html; charset=utf-8'].concat(libContentType).includes((proxyRes.headers['content-type'] || '').toLowerCase());
|