yakuza0 2.20.9 → 2.21.0-beta.1
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/config/index.js +140 -53
- package/config/paths.js +11 -1
- package/nuxt/head.js +3 -1
- package/package.json +2 -2
- package/server/index.js +146 -0
- package/server/proxy/csrf.js +157 -112
- package/server/proxy/web.js +25 -2
- package/utils/conf.js +48 -0
- package/utils/inclusive.js +72 -21
- package/utils/secret.js +2 -2
package/config/index.js
CHANGED
|
@@ -4,81 +4,168 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
var _extends2 = require('babel-runtime/helpers/extends');
|
|
8
|
-
|
|
9
|
-
var _extends3 = _interopRequireDefault(_extends2);
|
|
10
|
-
|
|
11
|
-
var _config = require('.cache/yakuza0/config.json');
|
|
12
|
-
|
|
13
|
-
var _config2 = _interopRequireDefault(_config);
|
|
14
|
-
|
|
15
7
|
var _yakuza = require('yakuza1');
|
|
16
8
|
|
|
17
9
|
var _encrypt = require('yakuza1/lib/encrypt');
|
|
18
10
|
|
|
19
|
-
|
|
11
|
+
var _conf = require('../utils/conf.js');
|
|
20
12
|
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
var ec = function ec(cipher) {
|
|
14
|
+
try {
|
|
15
|
+
try {
|
|
16
|
+
cipher = JSON.parse(cipher);
|
|
17
|
+
} catch (e) {}
|
|
18
|
+
var c = _encrypt.mixin.symmetry.CBC.decrypt(cipher.es);
|
|
19
|
+
return JSON.parse(c);
|
|
20
|
+
} catch (e) {}
|
|
21
|
+
return {};
|
|
22
|
+
};
|
|
31
23
|
|
|
32
|
-
|
|
24
|
+
var safeGet = function safeGet() {
|
|
25
|
+
var cj = require('.cache/yakuza0/config.json');
|
|
26
|
+
return ec(cj);
|
|
27
|
+
};
|
|
33
28
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var ykConfigJson = paths.ykConfigJson,
|
|
37
|
-
read = paths.read;
|
|
29
|
+
var lsGet = function lsGet(key) {
|
|
30
|
+
var lgc = localStorage.getItem('cln_init');
|
|
38
31
|
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
if (lgc) {
|
|
33
|
+
var arr = lgc.split("_");
|
|
34
|
+
if (arr[0] === key) {
|
|
35
|
+
return arr[1];
|
|
36
|
+
}
|
|
41
37
|
}
|
|
38
|
+
};
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
} catch (e) {}
|
|
48
|
-
|
|
49
|
-
var config = str;
|
|
40
|
+
var lsSet = function lsSet(key, str) {
|
|
41
|
+
var content = key + '_' + str;
|
|
42
|
+
localStorage.setItem('cln_init', content);
|
|
43
|
+
};
|
|
50
44
|
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
var ykConfig = function ykConfig() {
|
|
46
|
+
var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
53
47
|
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
var config = {};
|
|
49
|
+
if ((0, _yakuza.checkServer)()) {
|
|
50
|
+
config = safeGet();
|
|
51
|
+
} else {
|
|
52
|
+
var c = ec(_encrypt.mixin.symmetry.CBC.decrypt(_yakuza.global.__cln_init__));
|
|
53
|
+
if (!c.security.isStupid) {
|
|
54
|
+
if (!_yakuza.global.__yk_conf_mt__) {
|
|
55
|
+
var lgc = lsGet(c.key);
|
|
56
|
+
|
|
57
|
+
var cacheGet = function cacheGet() {
|
|
58
|
+
var cf = (0, _conf.getConf)(c.basePathMU);
|
|
59
|
+
lsSet(c.key, cf);
|
|
60
|
+
return cf;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
if (!lgc) {
|
|
64
|
+
config = cacheGet();
|
|
65
|
+
} else {
|
|
66
|
+
config = lgc;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
config = _encrypt.mixin.symmetry.CBC.decrypt(config, _encrypt.mixin.getKey(c.key));
|
|
71
|
+
} catch (e) {
|
|
72
|
+
config = cacheGet();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
config = ec(config);
|
|
76
|
+
_yakuza._.readOnly(_yakuza.global, '__yk_conf_mt__', config);
|
|
77
|
+
} else {
|
|
78
|
+
config = _yakuza.global.__yk_conf_mt__;
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
config = safeGet();
|
|
82
|
+
}
|
|
56
83
|
}
|
|
57
|
-
|
|
58
|
-
// if (
|
|
59
|
-
//
|
|
60
|
-
// }
|
|
61
|
-
//
|
|
84
|
+
// console.log(config);
|
|
85
|
+
// if (!config.security) {
|
|
86
|
+
// throw ""
|
|
87
|
+
// }
|
|
88
|
+
// let json = {};
|
|
89
|
+
// const {cookie, fresh} = {
|
|
90
|
+
// fresh: true,
|
|
91
|
+
// ...opt,
|
|
92
|
+
// };
|
|
93
|
+
//
|
|
94
|
+
// if (checkServer() && fresh) {
|
|
95
|
+
// const paths = require('./paths').default;
|
|
96
|
+
// const {ykConfigJson, read} = paths;
|
|
97
|
+
// json = read(ykConfigJson);
|
|
98
|
+
// json = JSON.parse(json);
|
|
62
99
|
// }
|
|
63
100
|
//
|
|
64
|
-
//
|
|
65
|
-
// try {
|
|
66
|
-
// jtConf = JSON.parse(decodeURIComponent(jtConf));
|
|
67
|
-
// } catch (e) {
|
|
68
|
-
// }
|
|
101
|
+
// let str = mixin.symmetry.ECB.decrypt(json.es);
|
|
69
102
|
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
// if (jtConf.services) {
|
|
74
|
-
// config.proxyServer.base.services = jtConf.services
|
|
75
|
-
// }
|
|
103
|
+
// try {
|
|
104
|
+
// str = JSON.parse(str);
|
|
105
|
+
// } catch (e) {
|
|
76
106
|
// }
|
|
77
107
|
|
|
108
|
+
// const config = str;
|
|
109
|
+
|
|
110
|
+
_yakuza._.readOnly(_yakuza.global, '__enc_encryptType__', config.security && config.security.encrypt);
|
|
111
|
+
_yakuza._.readOnly(_yakuza.global, '__yConf_ak__', config.ak);
|
|
112
|
+
|
|
113
|
+
if (config.https && process && process.env) {
|
|
114
|
+
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
|
|
115
|
+
}
|
|
116
|
+
|
|
78
117
|
return config;
|
|
79
118
|
};
|
|
80
119
|
|
|
81
120
|
var yConf = ykConfig({ fresh: false });
|
|
82
121
|
yConf.ykConfig = ykConfig;
|
|
83
122
|
exports.default = yConf;
|
|
123
|
+
|
|
124
|
+
// import deasync from 'deasync';
|
|
125
|
+
|
|
126
|
+
// const getCF = () => getConf("aaa").then(result => result).catch(function(error) {
|
|
127
|
+
// console.log(error);
|
|
128
|
+
// });
|
|
129
|
+
|
|
130
|
+
// const asyncToSync = (callback) => {
|
|
131
|
+
// let data = null;
|
|
132
|
+
// // function doSomething() {
|
|
133
|
+
// // callback.then((result) => {
|
|
134
|
+
// // data = result;
|
|
135
|
+
// // })
|
|
136
|
+
// // }
|
|
137
|
+
// // doSomething()
|
|
138
|
+
// // const ivl = setInterval(function() {
|
|
139
|
+
// // console.log(ivl, 11);
|
|
140
|
+
// // if (data !== null) {
|
|
141
|
+
// // console.log(data, 1);
|
|
142
|
+
// // clearInterval(ivl);
|
|
143
|
+
// // console.log(ivl, 22);
|
|
144
|
+
// // }
|
|
145
|
+
// // }, 100);
|
|
146
|
+
//
|
|
147
|
+
// setTimeout(() => {
|
|
148
|
+
// console.log(1);
|
|
149
|
+
// callback.then((result) => {
|
|
150
|
+
// console.log(2);
|
|
151
|
+
// data = result;
|
|
152
|
+
// })
|
|
153
|
+
// console.log(3);
|
|
154
|
+
// }, 0)
|
|
155
|
+
//
|
|
156
|
+
// let start = Date.now();
|
|
157
|
+
// let now = start;
|
|
158
|
+
// let re = null
|
|
159
|
+
// while (now - start < 10000) {
|
|
160
|
+
// now = Date.now();
|
|
161
|
+
// re = data;
|
|
162
|
+
// console.log(re);
|
|
163
|
+
// }
|
|
164
|
+
// // while(data === null) {
|
|
165
|
+
// // console.log(data);
|
|
166
|
+
// // }
|
|
167
|
+
//
|
|
168
|
+
// return re
|
|
169
|
+
// }
|
|
170
|
+
|
|
84
171
|
module.exports = exports['default'];
|
package/config/paths.js
CHANGED
|
@@ -108,7 +108,10 @@ var ykConfigJs = appDirectory + (path.sep + 'ykconfig.js');
|
|
|
108
108
|
var ykConfigJson = ykCacheDir + (path.sep + 'config.json');
|
|
109
109
|
var ykCsrfPrivateKey = ykCacheTmpDir + (path.sep + 'csrfPrivate.key');
|
|
110
110
|
// const ykCsrfPublicKey = ykCacheTmpDir + `${path.sep}public.key`;
|
|
111
|
-
var ykConfigJsonClient =
|
|
111
|
+
var ykConfigJsonClient = function ykConfigJsonClient(appName) {
|
|
112
|
+
return ykCacheAppDir + ('' + path.sep + appName + path.sep + 'config_client');
|
|
113
|
+
};
|
|
114
|
+
var ykConfigJsonServer = ykCacheDir + (path.sep + 'config_server');
|
|
112
115
|
var interfereFile = ['' + appNodeModules + path.sep + '.package_versions.json', '' + appNodeModules + path.sep + '.recently_updates.txt'];
|
|
113
116
|
|
|
114
117
|
mkdir(cacheDir);
|
|
@@ -119,7 +122,13 @@ mkdir(ykCacheTmpPub);
|
|
|
119
122
|
|
|
120
123
|
// env file
|
|
121
124
|
var envPath = function envPath(env) {
|
|
125
|
+
var sf = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
126
|
+
|
|
122
127
|
var suffix = 'config.' + (env || 'default').toLowerCase();
|
|
128
|
+
if (sf) {
|
|
129
|
+
// suffix += '.' + sf;
|
|
130
|
+
suffix += sf;
|
|
131
|
+
}
|
|
123
132
|
// if (suffix !== 'default') {
|
|
124
133
|
// suffix = 'config.' + suffix
|
|
125
134
|
// }
|
|
@@ -159,6 +168,7 @@ exports.default = {
|
|
|
159
168
|
ykConfigJs: ykConfigJs,
|
|
160
169
|
ykConfigJson: ykConfigJson,
|
|
161
170
|
ykConfigJsonClient: ykConfigJsonClient,
|
|
171
|
+
ykConfigJsonServer: ykConfigJsonServer,
|
|
162
172
|
// ykMainConf,
|
|
163
173
|
hardSourceCache: appNodeModules + (path.sep + '.cache'),
|
|
164
174
|
interfereFile: interfereFile,
|
package/nuxt/head.js
CHANGED
|
@@ -35,7 +35,9 @@ exports.default = function (config) {
|
|
|
35
35
|
var pkgHead = {};
|
|
36
36
|
|
|
37
37
|
if (config.commonConfig.head !== false) {
|
|
38
|
-
pkgHead = (0, _extends3.default)({}, _config2.default.nuxt && _config2.default.nuxt.head
|
|
38
|
+
pkgHead = (0, _extends3.default)({}, _config2.default.nuxt && _config2.default.nuxt.head, {
|
|
39
|
+
script: [{ src: "/cln/init.js?info=" + (0, _yakuza.gPwd)() }].concat((0, _toConsumableArray3.default)(_config2.default.nuxt && _config2.default.nuxt.head && _config2.default.nuxt.head.script || []))
|
|
40
|
+
});
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
_yakuza._.forEach(pkgHead, function (v, key) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yakuza0",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.21.0-beta.1",
|
|
4
4
|
"description": "yakuza0 with nuxt",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "babel --no-babelrc src -d . --presets=env --plugins=transform-runtime,transform-object-rest-spread,add-module-exports",
|
|
8
|
-
"pub:beta": "npm run build && npm version prerelease --preid=beta &&
|
|
8
|
+
"pub:beta": "npm run build && npm version prerelease --preid=beta && pxnpm publish --tag beta",
|
|
9
9
|
"pub": "npm run build && npm version patch && npm publish",
|
|
10
10
|
"postinstall": "yk verify commit-init",
|
|
11
11
|
"test": "jest"
|
package/server/index.js
CHANGED
|
@@ -392,4 +392,150 @@ exports.default = function () {
|
|
|
392
392
|
};
|
|
393
393
|
}();
|
|
394
394
|
|
|
395
|
+
// import normal from './mode/normal';
|
|
396
|
+
// import start from './mode/start';
|
|
397
|
+
// import stop, {stat} from './mode/stop';
|
|
398
|
+
// // import lite from './mode/lite';
|
|
399
|
+
// import address from 'address';
|
|
400
|
+
// import build from './mode/build';
|
|
401
|
+
// import container from './mode/container';
|
|
402
|
+
// import paths from '../config/paths';
|
|
403
|
+
// import yConf from '../config';
|
|
404
|
+
// import chalk from 'chalk';
|
|
405
|
+
// import {_, machineId, md5, global} from 'yakuza1/server';
|
|
406
|
+
// // import getPort from 'get-port';
|
|
407
|
+
// import {curlOrb} from '../utils/curl';
|
|
408
|
+
//
|
|
409
|
+
// const styleLine = () => {
|
|
410
|
+
// // if (hasProcess) {
|
|
411
|
+
// console.log('------------');
|
|
412
|
+
// // }
|
|
413
|
+
// };
|
|
414
|
+
//
|
|
415
|
+
// export default async (mode, appName, notExit) => {
|
|
416
|
+
// const appHref = [];
|
|
417
|
+
// const router = yConf.router && yConf.router.config && yConf.router.config[appName];
|
|
418
|
+
// const isProjectMode = mode === 'start' || mode === 'normal';
|
|
419
|
+
// const isProdMode = mode === 'start' || mode === 'stop' || mode === 'container';
|
|
420
|
+
// // let hasProcess = false;
|
|
421
|
+
// const ports = {};
|
|
422
|
+
// const appPorts = {};
|
|
423
|
+
// let pool = _.range(3000, 3500);
|
|
424
|
+
// let appPool = _.range(26000, 26500);
|
|
425
|
+
//
|
|
426
|
+
// const appKey = yConf.name + ' => ' + key;
|
|
427
|
+
// const appPaths = paths.appBuildDir(key, yConf.server.appBuildCacheDirName);
|
|
428
|
+
// let nuxtConfPath = `${appPaths.appRoot}nuxt.config.js`;
|
|
429
|
+
// if (isProdMode) {
|
|
430
|
+
// nuxtConfPath = `${appPaths.appServerRoot}nuxt.config.js`
|
|
431
|
+
// }
|
|
432
|
+
//
|
|
433
|
+
// if (paths.access(nuxtConfPath)) {
|
|
434
|
+
// const conf = {};
|
|
435
|
+
// conf.appName = key;
|
|
436
|
+
// conf.appKey = appKey;
|
|
437
|
+
//
|
|
438
|
+
// conf.appConf = {
|
|
439
|
+
// ...router,
|
|
440
|
+
// port: ports[key],
|
|
441
|
+
// appPort: appPorts[key],
|
|
442
|
+
// ports,
|
|
443
|
+
// appPorts,
|
|
444
|
+
// };
|
|
445
|
+
//
|
|
446
|
+
// // register
|
|
447
|
+
// const mId = await machineId();
|
|
448
|
+
// const svcBaseKey = yConf.ak + yConf.name + yConf.imageKey;
|
|
449
|
+
// let svcKey = svcBaseKey + yConf.processKey + mId;
|
|
450
|
+
// if (!yConf.dev) {
|
|
451
|
+
// svcKey = svcBaseKey + yConf.processKey;
|
|
452
|
+
// }
|
|
453
|
+
// if (yConf.inImage) {
|
|
454
|
+
// svcKey = svcBaseKey;
|
|
455
|
+
// }
|
|
456
|
+
//
|
|
457
|
+
// const svcHost = conf.appConf.cHost || conf.appConf.domain || address.ip() || conf.appConf.host;
|
|
458
|
+
// const svcPort = conf.appConf.cPort || conf.appConf.port;
|
|
459
|
+
// let svcHostname = svcHost + (svcPort ? ':' + svcPort : '');
|
|
460
|
+
// if (conf.appConf.cPortHide) {
|
|
461
|
+
// svcHostname = svcHost;
|
|
462
|
+
// }
|
|
463
|
+
// let prefix = 'http://';
|
|
464
|
+
// if (conf.appConf.cSSL) {
|
|
465
|
+
// prefix = 'https://'
|
|
466
|
+
// }
|
|
467
|
+
// svcHostname = prefix + svcHostname
|
|
468
|
+
// conf.appConf.svcKey = md5(svcKey);
|
|
469
|
+
//
|
|
470
|
+
// const baseURL = yConf.router.config[key] && yConf.router.config[key].proxyServer.baseURL
|
|
471
|
+
//
|
|
472
|
+
// try {
|
|
473
|
+
// await curlOrb(`/apiv2/support/svc/signIn`, {
|
|
474
|
+
// method: 'POST',
|
|
475
|
+
// body: {
|
|
476
|
+
// mId,
|
|
477
|
+
// project: yConf.name,
|
|
478
|
+
// appName: conf.appName,
|
|
479
|
+
// ak: yConf.ak,
|
|
480
|
+
// svcHostname,
|
|
481
|
+
// svcKey: conf.appConf.svcKey,
|
|
482
|
+
// appCode: conf.appConf.appCode,
|
|
483
|
+
// baseURL,
|
|
484
|
+
// },
|
|
485
|
+
// timeout: yConf.server.infoTimeout,
|
|
486
|
+
// json: true,
|
|
487
|
+
// });
|
|
488
|
+
// // console.log(aaa, 111);
|
|
489
|
+
// } catch (e) {
|
|
490
|
+
// // console.log(e);
|
|
491
|
+
// }
|
|
492
|
+
//
|
|
493
|
+
// const config = require(nuxtConfPath)(conf);
|
|
494
|
+
// const options = {
|
|
495
|
+
// appPaths,
|
|
496
|
+
// config,
|
|
497
|
+
// };
|
|
498
|
+
//
|
|
499
|
+
// switch (mode) {
|
|
500
|
+
// case 'start':
|
|
501
|
+
// // console.log('------------');
|
|
502
|
+
// styleLine();
|
|
503
|
+
// await start(options);
|
|
504
|
+
// break;
|
|
505
|
+
// case 'stop':
|
|
506
|
+
// styleLine();
|
|
507
|
+
// await stop({config: {appKey}});
|
|
508
|
+
// break;
|
|
509
|
+
// case 'build':
|
|
510
|
+
// await build(options);
|
|
511
|
+
// break;
|
|
512
|
+
// case 'container':
|
|
513
|
+
// await container(options);
|
|
514
|
+
// break;
|
|
515
|
+
// default:
|
|
516
|
+
// await normal(options);
|
|
517
|
+
// }
|
|
518
|
+
//
|
|
519
|
+
// appHref.push(` - ${key}: ${chalk.cyan(yConf.server.host + ':' + options.config.appConf.port)}`);
|
|
520
|
+
// }
|
|
521
|
+
//
|
|
522
|
+
// if ((mode === 'start' || mode === 'stop') && notExit !== true) {
|
|
523
|
+
// // styleLine({hasProcess, mode});
|
|
524
|
+
// styleLine();
|
|
525
|
+
// process.exit(0);
|
|
526
|
+
// }
|
|
527
|
+
//
|
|
528
|
+
// if (yConf.dev || mode === 'container') {
|
|
529
|
+
// console.log();
|
|
530
|
+
// consola.ready(
|
|
531
|
+
// [
|
|
532
|
+
// ` App running at:`,
|
|
533
|
+
// ...appHref,
|
|
534
|
+
// ].join('\n'),
|
|
535
|
+
// );
|
|
536
|
+
// console.log();
|
|
537
|
+
// }
|
|
538
|
+
// }
|
|
539
|
+
|
|
540
|
+
|
|
395
541
|
module.exports = exports['default'];
|