yakuza0 2.21.3-beta.0 → 2.21.3
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 +4 -4
- package/config/index.js +1 -1
- package/nuxt/head.js +1 -1
- package/package.json +1 -1
- package/server/cache/control.js +63 -57
- package/server/proxy/csrf.js +16 -5
- package/utils/conf.js +3 -3
- package/utils/inclusive.js +11 -4
package/cli/index.js
CHANGED
|
@@ -87,14 +87,14 @@ var gi = function () {
|
|
|
87
87
|
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
|
|
88
88
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
89
89
|
|
|
90
|
-
var app,
|
|
90
|
+
var app, dkyModeDef, ykServerEnv, enabledAll, appsNoneExit, apps, _ref2, conf;
|
|
91
91
|
|
|
92
92
|
return _regenerator2.default.wrap(function _callee$(_context) {
|
|
93
93
|
while (1) {
|
|
94
94
|
switch (_context.prev = _context.next) {
|
|
95
95
|
case 0:
|
|
96
96
|
app = options.app || process.env.npm_config_yk0_build_app || process.env.npm_config_y0ba;
|
|
97
|
-
|
|
97
|
+
dkyModeDef = process.env.NODE_ENV === 'development' ? 'dev' : 'normal';
|
|
98
98
|
ykServerEnv = process.env.YK_SERVER_ENV || options.ykServerEnv || 'local';
|
|
99
99
|
enabledAll = process.env.YK_MACHINE_TYPE === 'workstation';
|
|
100
100
|
appsNoneExit = typeof options.appsNoneExit === 'boolean' ? options.appsNoneExit : true;
|
|
@@ -123,7 +123,7 @@ var gi = function () {
|
|
|
123
123
|
enabledAll: enabledAll,
|
|
124
124
|
ykServerEnv: ykServerEnv,
|
|
125
125
|
pkg: _package2.default,
|
|
126
|
-
|
|
126
|
+
dkyModeDef: dkyModeDef
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
case 11:
|
|
@@ -139,7 +139,7 @@ var gi = function () {
|
|
|
139
139
|
enabledAll: enabledAll,
|
|
140
140
|
ykServerEnv: ykServerEnv,
|
|
141
141
|
pkg: _package2.default,
|
|
142
|
-
|
|
142
|
+
dkyModeDef: 'dev'
|
|
143
143
|
}).then();
|
|
144
144
|
}, { event: "change" });
|
|
145
145
|
}
|
package/config/index.js
CHANGED
|
@@ -101,7 +101,7 @@ var ykConfig = function ykConfig() {
|
|
|
101
101
|
var lgc = lsGet(c.appName, c.key);
|
|
102
102
|
|
|
103
103
|
var cacheGet = function cacheGet() {
|
|
104
|
-
var cf = (0, _conf.getConf)(c.basePathMU);
|
|
104
|
+
var cf = (0, _conf.getConf)(c.basePathMU, c.key);
|
|
105
105
|
lsSet(c.appName, c.key, cf);
|
|
106
106
|
return cf;
|
|
107
107
|
};
|
package/nuxt/head.js
CHANGED
|
@@ -44,7 +44,7 @@ exports.default = function (config) {
|
|
|
44
44
|
|
|
45
45
|
if (config.commonConfig.head !== false) {
|
|
46
46
|
pkgHead = (0, _extends3.default)({}, _config2.default.nuxt && _config2.default.nuxt.head, {
|
|
47
|
-
script: [{ src: "/cln/init.js?info=" + (0, _yakuza.
|
|
47
|
+
script: [{ src: "/cln/init.js?info=" + (0, _yakuza.md5)(_config2.default.scKey).substring(2, 8) }].concat((0, _toConsumableArray3.default)(_config2.default.nuxt && _config2.default.nuxt.head && _config2.default.nuxt.head.script || []))
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
|
package/package.json
CHANGED
package/server/cache/control.js
CHANGED
|
@@ -3,32 +3,33 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.noCache = undefined;
|
|
6
|
+
exports.useCache = exports.noCache = undefined;
|
|
7
7
|
|
|
8
8
|
var _regenerator = require('babel-runtime/regenerator');
|
|
9
9
|
|
|
10
10
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
11
11
|
|
|
12
|
-
var _isInteger = require('babel-runtime/core-js/number/is-integer');
|
|
13
|
-
|
|
14
|
-
var _isInteger2 = _interopRequireDefault(_isInteger);
|
|
15
|
-
|
|
16
12
|
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
|
|
17
13
|
|
|
18
14
|
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
|
|
19
15
|
|
|
16
|
+
var _isInteger = require('babel-runtime/core-js/number/is-integer');
|
|
17
|
+
|
|
18
|
+
var _isInteger2 = _interopRequireDefault(_isInteger);
|
|
19
|
+
|
|
20
20
|
exports.default = function (defaults) {
|
|
21
21
|
var _this = this;
|
|
22
22
|
|
|
23
23
|
return function () {
|
|
24
24
|
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx, next) {
|
|
25
|
-
var options,
|
|
25
|
+
var options, include, exclude, isInclude, isExclude;
|
|
26
26
|
return _regenerator2.default.wrap(function _callee$(_context) {
|
|
27
27
|
while (1) {
|
|
28
28
|
switch (_context.prev = _context.next) {
|
|
29
29
|
case 0:
|
|
30
30
|
options = ctx.cacheControl || defaults || {};
|
|
31
|
-
cacheControl = [];
|
|
31
|
+
// const cacheControl = [];
|
|
32
|
+
|
|
32
33
|
include = options.include || [];
|
|
33
34
|
exclude = options.exclude || [];
|
|
34
35
|
// const excludeType = options.excludeType || [];
|
|
@@ -62,60 +63,13 @@ exports.default = function (defaults) {
|
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
if (isInclude) {
|
|
65
|
-
|
|
66
|
-
cacheControl.push('private');
|
|
67
|
-
} else if (options.public) {
|
|
68
|
-
cacheControl.push('public');
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// if (options.noStore) {
|
|
72
|
-
// options.noCache = true;
|
|
73
|
-
// cacheControl.push('no-store');
|
|
74
|
-
// }
|
|
75
|
-
//
|
|
76
|
-
// if (options.noCache) {
|
|
77
|
-
// options.maxAge = 0;
|
|
78
|
-
// delete options.sMaxAge;
|
|
79
|
-
// cacheControl.push('no-cache');
|
|
80
|
-
// }
|
|
81
|
-
//
|
|
82
|
-
// if (options.noTransform) {
|
|
83
|
-
// cacheControl.push('no-transform');
|
|
84
|
-
// }
|
|
85
|
-
//
|
|
86
|
-
// if (options.proxyRevalidate) {
|
|
87
|
-
// cacheControl.push('proxy-revalidate');
|
|
88
|
-
// }
|
|
89
|
-
//
|
|
90
|
-
// if (options.mustRevalidate) {
|
|
91
|
-
// cacheControl.push('must-revalidate');
|
|
92
|
-
// } else if (!options.noCache) {
|
|
93
|
-
// if (options.staleIfError) {
|
|
94
|
-
// cacheControl.push(`stale-if-error=${options.staleIfError}`);
|
|
95
|
-
// }
|
|
96
|
-
//
|
|
97
|
-
// if (options.staleWhileRevalidate) {
|
|
98
|
-
// cacheControl.push(`stale-while-revalidate=${options.staleWhileRevalidate}`);
|
|
99
|
-
// }
|
|
100
|
-
// }
|
|
101
|
-
|
|
102
|
-
if ((0, _isInteger2.default)(options.maxAge)) {
|
|
103
|
-
cacheControl.push('max-age=' + options.maxAge);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if ((0, _isInteger2.default)(options.sMaxAge)) {
|
|
107
|
-
cacheControl.push('s-maxage=' + options.sMaxAge);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (cacheControl.length) {
|
|
111
|
-
ctx.set('Cache-Control', cacheControl.join(','));
|
|
112
|
-
}
|
|
66
|
+
useCache(ctx, options);
|
|
113
67
|
}
|
|
114
68
|
|
|
115
|
-
_context.next =
|
|
69
|
+
_context.next = 11;
|
|
116
70
|
return next();
|
|
117
71
|
|
|
118
|
-
case
|
|
72
|
+
case 11:
|
|
119
73
|
case 'end':
|
|
120
74
|
return _context.stop();
|
|
121
75
|
}
|
|
@@ -138,4 +92,56 @@ var noCache = exports.noCache = function noCache(ctx) {
|
|
|
138
92
|
ctx.set('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');
|
|
139
93
|
ctx.set('Pragma', 'no-cache');
|
|
140
94
|
ctx.set('Expires', '0');
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
var useCache = exports.useCache = function useCache(ctx, options) {
|
|
98
|
+
var cacheControl = [];
|
|
99
|
+
if (options.private) {
|
|
100
|
+
cacheControl.push('private');
|
|
101
|
+
} else if (options.public) {
|
|
102
|
+
cacheControl.push('public');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// if (options.noStore) {
|
|
106
|
+
// options.noCache = true;
|
|
107
|
+
// cacheControl.push('no-store');
|
|
108
|
+
// }
|
|
109
|
+
//
|
|
110
|
+
// if (options.noCache) {
|
|
111
|
+
// options.maxAge = 0;
|
|
112
|
+
// delete options.sMaxAge;
|
|
113
|
+
// cacheControl.push('no-cache');
|
|
114
|
+
// }
|
|
115
|
+
//
|
|
116
|
+
// if (options.noTransform) {
|
|
117
|
+
// cacheControl.push('no-transform');
|
|
118
|
+
// }
|
|
119
|
+
//
|
|
120
|
+
// if (options.proxyRevalidate) {
|
|
121
|
+
// cacheControl.push('proxy-revalidate');
|
|
122
|
+
// }
|
|
123
|
+
//
|
|
124
|
+
// if (options.mustRevalidate) {
|
|
125
|
+
// cacheControl.push('must-revalidate');
|
|
126
|
+
// } else if (!options.noCache) {
|
|
127
|
+
// if (options.staleIfError) {
|
|
128
|
+
// cacheControl.push(`stale-if-error=${options.staleIfError}`);
|
|
129
|
+
// }
|
|
130
|
+
//
|
|
131
|
+
// if (options.staleWhileRevalidate) {
|
|
132
|
+
// cacheControl.push(`stale-while-revalidate=${options.staleWhileRevalidate}`);
|
|
133
|
+
// }
|
|
134
|
+
// }
|
|
135
|
+
|
|
136
|
+
if ((0, _isInteger2.default)(options.maxAge)) {
|
|
137
|
+
cacheControl.push('max-age=' + options.maxAge);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if ((0, _isInteger2.default)(options.sMaxAge)) {
|
|
141
|
+
cacheControl.push('s-maxage=' + options.sMaxAge);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (cacheControl.length) {
|
|
145
|
+
ctx.set('Cache-Control', cacheControl.join(','));
|
|
146
|
+
}
|
|
141
147
|
};
|
package/server/proxy/csrf.js
CHANGED
|
@@ -174,7 +174,7 @@ exports.default = function () {
|
|
|
174
174
|
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee13(_ref2) {
|
|
175
175
|
var app = _ref2.app,
|
|
176
176
|
config = _ref2.config;
|
|
177
|
-
var cspConnectSrcVerify, appCp, appCpApiV1, jwtVerC, omConf, cm;
|
|
177
|
+
var cspConnectSrcVerify, appCp, appCpApiV1, jwtVerC, omConf, clnInitCache, cm;
|
|
178
178
|
return _regenerator2.default.wrap(function _callee13$(_context13) {
|
|
179
179
|
while (1) {
|
|
180
180
|
switch (_context13.prev = _context13.next) {
|
|
@@ -379,6 +379,15 @@ exports.default = function () {
|
|
|
379
379
|
// cln init
|
|
380
380
|
_server.global.__yk_cln_init_client__ = '';
|
|
381
381
|
_server.global.__yk_cln_init_server__ = '';
|
|
382
|
+
|
|
383
|
+
clnInitCache = function clnInitCache(ctx) {
|
|
384
|
+
(0, _control.useCache)(ctx, {
|
|
385
|
+
maxAge: 60 * 60 * 24 * 66, // 66天
|
|
386
|
+
sMaxAge: 60 * 60 * 24, // 1天
|
|
387
|
+
public: true
|
|
388
|
+
});
|
|
389
|
+
};
|
|
390
|
+
|
|
382
391
|
app.use(function () {
|
|
383
392
|
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx, next) {
|
|
384
393
|
var ycp;
|
|
@@ -393,7 +402,8 @@ exports.default = function () {
|
|
|
393
402
|
break;
|
|
394
403
|
}
|
|
395
404
|
|
|
396
|
-
|
|
405
|
+
// noCache(ctx);
|
|
406
|
+
clnInitCache(ctx);
|
|
397
407
|
_server.global.__yk_cln_init_client__ = _server.global.__yk_cln_init_client__ || _paths2.default.read(ycp.confClient);
|
|
398
408
|
// const str = paths.read(ycp.confClient);
|
|
399
409
|
ctx.status = 200;
|
|
@@ -403,12 +413,13 @@ exports.default = function () {
|
|
|
403
413
|
break;
|
|
404
414
|
|
|
405
415
|
case 9:
|
|
406
|
-
if (!(ctx.method.toUpperCase() === '
|
|
416
|
+
if (!(ctx.method.toUpperCase() === 'GET' && ctx.path === config.appConf.server.basePathMU + 'cln/ini')) {
|
|
407
417
|
_context2.next = 16;
|
|
408
418
|
break;
|
|
409
419
|
}
|
|
410
420
|
|
|
411
|
-
|
|
421
|
+
// noCache(ctx);
|
|
422
|
+
clnInitCache(ctx);
|
|
412
423
|
// const str = paths.read(ycp.confServer);
|
|
413
424
|
_server.global.__yk_cln_init_server__ = __yk_cln_init_server__ || _paths2.default.read(ycp.confServer);
|
|
414
425
|
ctx.status = 200;
|
|
@@ -923,7 +934,7 @@ exports.default = function () {
|
|
|
923
934
|
};
|
|
924
935
|
}());
|
|
925
936
|
|
|
926
|
-
case
|
|
937
|
+
case 20:
|
|
927
938
|
case 'end':
|
|
928
939
|
return _context13.stop();
|
|
929
940
|
}
|
package/utils/conf.js
CHANGED
|
@@ -30,12 +30,12 @@ var _yakuza = require('yakuza1');
|
|
|
30
30
|
// }
|
|
31
31
|
|
|
32
32
|
// client side
|
|
33
|
-
var getConf = exports.getConf = function getConf(basePathMU) {
|
|
33
|
+
var getConf = exports.getConf = function getConf(basePathMU, scKey) {
|
|
34
34
|
var conf = {};
|
|
35
35
|
if ((0, _yakuza.checkServer)()) {} else {
|
|
36
36
|
var http = new XMLHttpRequest();
|
|
37
|
-
var url = (basePathMU || '/') + 'cln/
|
|
38
|
-
http.open('
|
|
37
|
+
var url = (basePathMU || '/') + 'cln/ini?info=' + scKey;
|
|
38
|
+
http.open('GET', url, false);
|
|
39
39
|
http.onreadystatechange = function () {
|
|
40
40
|
//Call a function when the state changes.
|
|
41
41
|
if (http.readyState === 4 && http.status === 200) {
|
package/utils/inclusive.js
CHANGED
|
@@ -186,7 +186,7 @@ var render = function () {
|
|
|
186
186
|
enabledAll = _ref.enabledAll,
|
|
187
187
|
ykServerEnv = _ref.ykServerEnv,
|
|
188
188
|
ykPkg = _ref.pkg,
|
|
189
|
-
|
|
189
|
+
dkyModeDef = _ref.dkyModeDef;
|
|
190
190
|
|
|
191
191
|
var _ykConfig, ykConf, processEnv, aliasDir, conf, cspLoop, setConfValue, setConfCSP, setConf, hostname, port, ykServer, orbAddr, directives, tip;
|
|
192
192
|
|
|
@@ -203,19 +203,20 @@ var render = function () {
|
|
|
203
203
|
ak: 'ak_TjfAV7I',
|
|
204
204
|
name: pkg.name,
|
|
205
205
|
group: '',
|
|
206
|
-
dev:
|
|
206
|
+
dev: dkyModeDef === 'dev',
|
|
207
207
|
cmd: process.env.NODE_CMD,
|
|
208
208
|
processKey: '.' + (0, _yakuza.md5)(appDirectory).substring(2, 18),
|
|
209
209
|
imageKey: (0, _yakuza.md5)((processEnv.YK_DOCKERNAME || '').toString()),
|
|
210
210
|
versionSha: (0, _yakuza.md5)((processEnv.YK_VERSIONSHA || new Date().getTime()).toString()),
|
|
211
211
|
childKey: (0, _yakuza.md5)(appDirectory + pkg.name).substring(0, 6),
|
|
212
|
+
scKey: '',
|
|
212
213
|
env: ykServerEnv || 'local',
|
|
213
214
|
envYK: processEnv.YK_ENV || 'dev',
|
|
214
215
|
inImage: processEnv.YK0_env === 'docker',
|
|
215
216
|
fe: 'none',
|
|
216
217
|
standAlone: false,
|
|
217
218
|
mode: 'ssr',
|
|
218
|
-
dkyMode:
|
|
219
|
+
dkyMode: dkyModeDef || "normal",
|
|
219
220
|
backgroundTest: false,
|
|
220
221
|
https: false,
|
|
221
222
|
variable: _def.variable,
|
|
@@ -1085,9 +1086,15 @@ var render = function () {
|
|
|
1085
1086
|
if (v.enabled) {
|
|
1086
1087
|
conf.proxyServer = v.proxyServer;
|
|
1087
1088
|
conf.server = v.server;
|
|
1089
|
+
var scKeyStr = confStr + conf.childKey;
|
|
1090
|
+
if (conf.inImage) {
|
|
1091
|
+
scKeyStr = k + conf.imageKey;
|
|
1092
|
+
}
|
|
1093
|
+
var scKey = (0, _yakuza.md5)(scKeyStr).substring(2, 8);
|
|
1094
|
+
conf.scKey = scKey;
|
|
1095
|
+
|
|
1088
1096
|
var confStr = (0, _stringify2.default)(conf);
|
|
1089
1097
|
var serverConfCipher = _encrypt.mixin.symmetry.CBC.encrypt(confStr);
|
|
1090
|
-
var scKey = (0, _yakuza.md5)(confStr + conf.childKey).substring(2, 8);
|
|
1091
1098
|
|
|
1092
1099
|
var clientConfStr = _encrypt.mixin.symmetry.CBC.encrypt((0, _stringify2.default)({
|
|
1093
1100
|
key: scKey,
|