@fastcar/core 0.2.62 → 0.2.63
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 +1 -1
- package/src/FastCarApplication.ts +30 -9
- package/target/FastCarApplication.js +708 -692
- package/target/annotation/Application.js +45 -45
- package/target/annotation/ExceptionMonitor.js +16 -16
- package/target/annotation/bind/AddRequireModule.js +21 -21
- package/target/annotation/bind/AliasInjection.js +23 -23
- package/target/annotation/bind/Autowired.js +13 -13
- package/target/annotation/bind/CallDependency.js +23 -23
- package/target/annotation/data/DBType.js +11 -11
- package/target/annotation/data/DS.js +54 -54
- package/target/annotation/data/DSIndex.js +9 -9
- package/target/annotation/data/Entity.js +10 -10
- package/target/annotation/data/Field.js +18 -18
- package/target/annotation/data/PrimaryKey.js +9 -9
- package/target/annotation/data/SqlSession.js +9 -9
- package/target/annotation/data/Table.js +35 -35
- package/target/annotation/data/Transactional.js +52 -52
- package/target/annotation/env/ApplicationSetting.js +25 -25
- package/target/annotation/env/BaseFilePath.js +14 -14
- package/target/annotation/env/BaseName.js +9 -9
- package/target/annotation/env/BasePath.js +14 -14
- package/target/annotation/env/ENV.js +10 -10
- package/target/annotation/env/ResourcePath.js +9 -9
- package/target/annotation/lifeCycle/AddLifeCycleItem.js +18 -18
- package/target/annotation/lifeCycle/ApplicationDestory.js +15 -15
- package/target/annotation/lifeCycle/ApplicationInit.js +15 -15
- package/target/annotation/lifeCycle/ApplicationRunner.js +7 -7
- package/target/annotation/lifeCycle/ApplicationStart.js +24 -24
- package/target/annotation/lifeCycle/ApplicationStop.js +20 -20
- package/target/annotation/property/Deprecate.js +19 -19
- package/target/annotation/property/NotImplemented.js +8 -8
- package/target/annotation/property/Override.js +7 -7
- package/target/annotation/property/Readonly.js +16 -16
- package/target/annotation/scan/ComponentInjection.js +21 -21
- package/target/annotation/scan/ComponentScan.js +9 -9
- package/target/annotation/scan/ComponentScanExclusion.js +25 -25
- package/target/annotation/scan/ComponentScanMust.js +25 -25
- package/target/annotation/scan/Hotter.js +8 -8
- package/target/annotation/stereotype/BeanName.js +11 -11
- package/target/annotation/stereotype/Component.js +8 -8
- package/target/annotation/stereotype/Configure.js +14 -14
- package/target/annotation/stereotype/Controller.js +9 -9
- package/target/annotation/stereotype/Injection.js +12 -12
- package/target/annotation/stereotype/Log.js +17 -17
- package/target/annotation/stereotype/Repository.js +9 -9
- package/target/annotation/stereotype/Service.js +9 -9
- package/target/annotation/valid/AddChildValid.js +56 -56
- package/target/annotation/valid/CustomType.js +11 -11
- package/target/annotation/valid/DefaultVal.js +10 -10
- package/target/annotation/valid/NotNull.js +8 -8
- package/target/annotation/valid/Rule.js +100 -100
- package/target/annotation/valid/Size.js +10 -10
- package/target/annotation/valid/Type.js +10 -10
- package/target/annotation/valid/ValidCustom.js +17 -17
- package/target/annotation/valid/ValidForm.js +133 -133
- package/target/annotation.js +108 -108
- package/target/config/ApplicationConfig.js +2 -2
- package/target/config/SysConfig.js +19 -19
- package/target/constant/AppStatusEnum.js +9 -9
- package/target/constant/BootPriority.js +11 -11
- package/target/constant/CommonConstant.js +18 -18
- package/target/constant/ComponentKind.js +11 -11
- package/target/constant/DataTypes.js +19 -19
- package/target/constant/FastCarMetaData.js +31 -31
- package/target/constant/LifeCycleModule.js +9 -9
- package/target/db.js +49 -49
- package/target/index.js +21 -21
- package/target/interface/ApplicationHook.js +2 -2
- package/target/interface/ApplicationInterface.js +2 -2
- package/target/interface/ApplicationRunnerService.js +2 -2
- package/target/interface/DataSourceManager.js +2 -2
- package/target/interface/Logger.js +5 -5
- package/target/model/BaseMapper.js +98 -98
- package/target/model/DataMap.js +87 -87
- package/target/model/FormRuleModel.js +2 -2
- package/target/model/ValidError.js +5 -5
- package/target/model/WinstonLogger.js +96 -96
- package/target/type/ComponentDesc.js +2 -2
- package/target/type/DesignMeta.js +15 -15
- package/target/type/FileHotterDesc.js +2 -2
- package/target/type/MapperType.js +2 -2
- package/target/type/ProcessType.js +2 -2
- package/target/type/SqlError.js +5 -5
- package/target/type/WinstonLoggerType.js +9 -9
- package/target/utils/ClassLoader.js +65 -65
- package/target/utils/ClassUtils.js +35 -35
- package/target/utils/CryptoUtil.js +86 -86
- package/target/utils/DataFormat.js +88 -88
- package/target/utils/DateUtil.js +71 -71
- package/target/utils/FileUtil.js +153 -153
- package/target/utils/FormatStr.js +14 -14
- package/target/utils/IPUtils.js +34 -34
- package/target/utils/Id.js +9 -9
- package/target/utils/Mix.js +62 -62
- package/target/utils/ReflectUtil.js +22 -22
- package/target/utils/TypeUtil.js +53 -53
- package/target/utils/ValidationUtil.js +123 -123
- package/target/utils.js +25 -25
- package/test/unit/decorators-test.ts +3 -3
- package/test/unit/valid-test.ts +49 -54
- package/target/src/FastCarApplication.js +0 -704
- package/target/src/annotation/Application.js +0 -45
- package/target/src/annotation/ExceptionMonitor.js +0 -16
- package/target/src/annotation/bind/AddRequireModule.js +0 -21
- package/target/src/annotation/bind/AliasInjection.js +0 -23
- package/target/src/annotation/bind/Autowired.js +0 -13
- package/target/src/annotation/bind/CallDependency.js +0 -23
- package/target/src/annotation/data/DBType.js +0 -11
- package/target/src/annotation/data/DS.js +0 -54
- package/target/src/annotation/data/DSIndex.js +0 -9
- package/target/src/annotation/data/Entity.js +0 -10
- package/target/src/annotation/data/Field.js +0 -18
- package/target/src/annotation/data/PrimaryKey.js +0 -9
- package/target/src/annotation/data/SqlSession.js +0 -9
- package/target/src/annotation/data/Table.js +0 -35
- package/target/src/annotation/data/Transactional.js +0 -52
- package/target/src/annotation/env/ApplicationSetting.js +0 -25
- package/target/src/annotation/env/BaseFilePath.js +0 -14
- package/target/src/annotation/env/BaseName.js +0 -9
- package/target/src/annotation/env/BasePath.js +0 -14
- package/target/src/annotation/env/ENV.js +0 -10
- package/target/src/annotation/env/ResourcePath.js +0 -9
- package/target/src/annotation/lifeCycle/AddLifeCycleItem.js +0 -18
- package/target/src/annotation/lifeCycle/ApplicationDestory.js +0 -15
- package/target/src/annotation/lifeCycle/ApplicationInit.js +0 -15
- package/target/src/annotation/lifeCycle/ApplicationRunner.js +0 -7
- package/target/src/annotation/lifeCycle/ApplicationStart.js +0 -24
- package/target/src/annotation/lifeCycle/ApplicationStop.js +0 -20
- package/target/src/annotation/property/Deprecate.js +0 -19
- package/target/src/annotation/property/NotImplemented.js +0 -8
- package/target/src/annotation/property/Override.js +0 -7
- package/target/src/annotation/property/Readonly.js +0 -16
- package/target/src/annotation/scan/ComponentInjection.js +0 -21
- package/target/src/annotation/scan/ComponentScan.js +0 -9
- package/target/src/annotation/scan/ComponentScanExclusion.js +0 -25
- package/target/src/annotation/scan/ComponentScanMust.js +0 -25
- package/target/src/annotation/scan/Hotter.js +0 -8
- package/target/src/annotation/stereotype/BeanName.js +0 -11
- package/target/src/annotation/stereotype/Component.js +0 -8
- package/target/src/annotation/stereotype/Configure.js +0 -14
- package/target/src/annotation/stereotype/Controller.js +0 -9
- package/target/src/annotation/stereotype/Injection.js +0 -12
- package/target/src/annotation/stereotype/Log.js +0 -22
- package/target/src/annotation/stereotype/Repository.js +0 -9
- package/target/src/annotation/stereotype/Service.js +0 -9
- package/target/src/annotation/valid/AddChildValid.js +0 -56
- package/target/src/annotation/valid/CustomType.js +0 -11
- package/target/src/annotation/valid/DefaultVal.js +0 -10
- package/target/src/annotation/valid/NotNull.js +0 -8
- package/target/src/annotation/valid/Rule.js +0 -100
- package/target/src/annotation/valid/Size.js +0 -10
- package/target/src/annotation/valid/Type.js +0 -10
- package/target/src/annotation/valid/ValidCustom.js +0 -17
- package/target/src/annotation/valid/ValidForm.js +0 -133
- package/target/src/annotation.js +0 -108
- package/target/src/config/ApplicationConfig.js +0 -2
- package/target/src/config/SysConfig.js +0 -19
- package/target/src/constant/AppStatusEnum.js +0 -9
- package/target/src/constant/BootPriority.js +0 -11
- package/target/src/constant/CommonConstant.js +0 -18
- package/target/src/constant/ComponentKind.js +0 -11
- package/target/src/constant/DataTypes.js +0 -19
- package/target/src/constant/FastCarMetaData.js +0 -31
- package/target/src/constant/LifeCycleModule.js +0 -9
- package/target/src/db.js +0 -49
- package/target/src/index.js +0 -21
- package/target/src/interface/ApplicationHook.js +0 -2
- package/target/src/interface/ApplicationInterface.js +0 -2
- package/target/src/interface/ApplicationRunnerService.js +0 -2
- package/target/src/interface/DataSourceManager.js +0 -2
- package/target/src/interface/Logger.js +0 -5
- package/target/src/model/BaseMapper.js +0 -103
- package/target/src/model/DataMap.js +0 -87
- package/target/src/model/FormRuleModel.js +0 -2
- package/target/src/model/ValidError.js +0 -5
- package/target/src/model/WinstonLogger.js +0 -97
- package/target/src/type/ComponentDesc.js +0 -2
- package/target/src/type/DesignMeta.js +0 -15
- package/target/src/type/FileHotterDesc.js +0 -2
- package/target/src/type/MapperType.js +0 -2
- package/target/src/type/ProcessType.js +0 -2
- package/target/src/type/SqlError.js +0 -5
- package/target/src/type/WinstonLoggerType.js +0 -9
- package/target/src/utils/ClassLoader.js +0 -65
- package/target/src/utils/ClassUtils.js +0 -35
- package/target/src/utils/CryptoUtil.js +0 -86
- package/target/src/utils/DataFormat.js +0 -88
- package/target/src/utils/DateUtil.js +0 -71
- package/target/src/utils/FileUtil.js +0 -153
- package/target/src/utils/FormatStr.js +0 -14
- package/target/src/utils/IPUtils.js +0 -34
- package/target/src/utils/Id.js +0 -9
- package/target/src/utils/Mix.js +0 -62
- package/target/src/utils/ReflectUtil.js +0 -22
- package/target/src/utils/TypeUtil.js +0 -53
- package/target/src/utils/ValidationUtil.js +0 -118
- package/target/src/utils.js +0 -25
- package/target/test/example/simple/app-test.js +0 -57
- package/target/test/example/simple/app.js +0 -116
- package/target/test/example/simple/component/StartRunner.js +0 -19
- package/target/test/example/simple/component/StopRunner.js +0 -23
- package/target/test/example/simple/config/EnvConfig.js +0 -16
- package/target/test/example/simple/config/HelloConfig.js +0 -16
- package/target/test/example/simple/config/HotConfig.js +0 -18
- package/target/test/example/simple/controller/AliasController.js +0 -17
- package/target/test/example/simple/controller/HelloController.js +0 -55
- package/target/test/example/simple/controller/NotFoundController.js +0 -36
- package/target/test/example/simple/noclude/excludeApp.js +0 -17
- package/target/test/example/simple/service/CallService.js +0 -24
- package/target/test/example/simple/service/HelloService.js +0 -18
- package/target/test/example/simple/service/LogService.js +0 -32
- package/target/test/multi/app.js +0 -29
- package/target/test/multi/service/aService.js +0 -33
- package/target/test/multi/service/bService.js +0 -35
- package/target/test/multi/service/cService.js +0 -40
- package/target/test/unit/dataMap-test.js +0 -35
- package/target/test/unit/decorators-test.js +0 -59
- package/target/test/unit/ds-test.js +0 -58
- package/target/test/unit/reflectMetadata-test.js +0 -27
- package/target/test/unit/valid-test.js +0 -99
- package/target/test/unit/winston-test.js +0 -15
- package/test/example/logs/fastcar-server.sys.log +0 -3
- package/test/example/logs/other-server.app.log +0 -0
- package/test/example/logs/other-server.sys.log +0 -0
- package/test/example/logs/other-server.sys1.log +0 -0
- package/test/example/logs/other-server.sys2.log +0 -0
- package/test/example/logs/other-server.sys3.log +0 -6
- package/test/example/logs/other-server.sys4.log +0 -0
- package/test/example/logs/other-server.sys5.log +0 -0
- package/test/example/logs/other-server.sys6.log +0 -2
- package/test/logs/logger.log +0 -0
- package/test/logs/sys.log +0 -227
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const winston = require("winston");
|
|
4
|
-
const WinstonLoggerType_1 = require("../type/WinstonLoggerType");
|
|
5
|
-
const path = require("path");
|
|
6
|
-
const utils_1 = require("../utils");
|
|
7
|
-
const util = require("util");
|
|
8
|
-
const SPLAT = Symbol.for("splat");
|
|
9
|
-
class WinstonLogger {
|
|
10
|
-
constructor(config) {
|
|
11
|
-
this.config = config;
|
|
12
|
-
this.categoryMap = new Map();
|
|
13
|
-
}
|
|
14
|
-
//控制台着色
|
|
15
|
-
colorize(str, level) {
|
|
16
|
-
let colorStyle = Reflect.get(WinstonLoggerType_1.ColorLevelType, level);
|
|
17
|
-
if (!colorStyle) {
|
|
18
|
-
return str;
|
|
19
|
-
}
|
|
20
|
-
return `\x1B[${colorStyle[0]}m ${str} \x1B[${colorStyle[1]}m`;
|
|
21
|
-
}
|
|
22
|
-
//数据着色为白色
|
|
23
|
-
colorizeData(data) {
|
|
24
|
-
let msg = utils_1.ValidationUtil.isObject(data) ? JSON.stringify(data) : data;
|
|
25
|
-
return `\x1B[37m ${msg} \x1B[39m`;
|
|
26
|
-
}
|
|
27
|
-
setConfig(config) {
|
|
28
|
-
this.config = config;
|
|
29
|
-
}
|
|
30
|
-
hasLogger(category) {
|
|
31
|
-
return winston.loggers.has(category);
|
|
32
|
-
}
|
|
33
|
-
getLogger(category) {
|
|
34
|
-
return this.categoryMap.get(category);
|
|
35
|
-
}
|
|
36
|
-
addLogger(category) {
|
|
37
|
-
if (this.categoryMap.has(category)) {
|
|
38
|
-
winston.loggers.close(category);
|
|
39
|
-
}
|
|
40
|
-
let newLogger = winston.loggers.add(category, {
|
|
41
|
-
format: winston.format.combine(winston.format.label({ label: category }), winston.format.printf((info) => {
|
|
42
|
-
//debug模式等级时仅为控制台输出
|
|
43
|
-
let level = info.level.toUpperCase();
|
|
44
|
-
let timestamp = utils_1.DateUtil.toDateTimeMS();
|
|
45
|
-
let content = {
|
|
46
|
-
timestamp,
|
|
47
|
-
level,
|
|
48
|
-
label: info.label,
|
|
49
|
-
message: info.message,
|
|
50
|
-
};
|
|
51
|
-
if (Reflect.has(info, SPLAT)) {
|
|
52
|
-
let splat = Reflect.get(info, SPLAT);
|
|
53
|
-
Reflect.set(content, "splat", typeof splat == "string" ? splat : JSON.stringify(splat));
|
|
54
|
-
}
|
|
55
|
-
if (info.stack) {
|
|
56
|
-
Reflect.set(content, "stack", info.stack);
|
|
57
|
-
}
|
|
58
|
-
Reflect.set(info, "timestamp", content.timestamp);
|
|
59
|
-
//新增打印控制台
|
|
60
|
-
if (this.config.printConsole) {
|
|
61
|
-
let text = this.colorize(util.format("[%s] [%s] %s - ", timestamp, level, info.label), info.level);
|
|
62
|
-
text += this.colorizeData(content.message);
|
|
63
|
-
if (Reflect.has(info, SPLAT)) {
|
|
64
|
-
let splatMsg = Reflect.get(info, SPLAT);
|
|
65
|
-
splatMsg.forEach((item) => {
|
|
66
|
-
text += " " + this.colorizeData(item);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
if (info.stack) {
|
|
70
|
-
text += this.colorizeData(`\nstatck: ${info.stack}`);
|
|
71
|
-
}
|
|
72
|
-
let fn = console.info;
|
|
73
|
-
if (Reflect.has(console, info.level)) {
|
|
74
|
-
fn = Reflect.get(console, info.level);
|
|
75
|
-
}
|
|
76
|
-
Reflect.apply(fn, console, [text]);
|
|
77
|
-
}
|
|
78
|
-
return util.format("%j", content);
|
|
79
|
-
})),
|
|
80
|
-
transports: [
|
|
81
|
-
new winston.transports.File({
|
|
82
|
-
level: this.config.fileLevel,
|
|
83
|
-
filename: path.join(this.config.rootPath, `${category}.log`),
|
|
84
|
-
maxsize: this.config.maxsize,
|
|
85
|
-
maxFiles: this.config.maxFiles,
|
|
86
|
-
}),
|
|
87
|
-
],
|
|
88
|
-
});
|
|
89
|
-
this.categoryMap.set(category, newLogger);
|
|
90
|
-
return newLogger;
|
|
91
|
-
}
|
|
92
|
-
getLoggerList() {
|
|
93
|
-
return [...this.categoryMap.values()];
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.default = WinstonLogger;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const winston = require("winston");
|
|
4
|
+
const WinstonLoggerType_1 = require("../type/WinstonLoggerType");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const util = require("util");
|
|
8
|
+
const SPLAT = Symbol.for("splat");
|
|
9
|
+
class WinstonLogger {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.config = config;
|
|
12
|
+
this.categoryMap = new Map();
|
|
13
|
+
}
|
|
14
|
+
//控制台着色
|
|
15
|
+
colorize(str, level) {
|
|
16
|
+
let colorStyle = Reflect.get(WinstonLoggerType_1.ColorLevelType, level);
|
|
17
|
+
if (!colorStyle) {
|
|
18
|
+
return str;
|
|
19
|
+
}
|
|
20
|
+
return `\x1B[${colorStyle[0]}m ${str} \x1B[${colorStyle[1]}m`;
|
|
21
|
+
}
|
|
22
|
+
//数据着色为白色
|
|
23
|
+
colorizeData(data) {
|
|
24
|
+
let msg = utils_1.ValidationUtil.isObject(data) ? JSON.stringify(data) : data;
|
|
25
|
+
return `\x1B[37m ${msg} \x1B[39m`;
|
|
26
|
+
}
|
|
27
|
+
setConfig(config) {
|
|
28
|
+
this.config = config;
|
|
29
|
+
}
|
|
30
|
+
hasLogger(category) {
|
|
31
|
+
return winston.loggers.has(category);
|
|
32
|
+
}
|
|
33
|
+
getLogger(category) {
|
|
34
|
+
return this.categoryMap.get(category);
|
|
35
|
+
}
|
|
36
|
+
addLogger(category) {
|
|
37
|
+
if (this.categoryMap.has(category)) {
|
|
38
|
+
winston.loggers.close(category);
|
|
39
|
+
}
|
|
40
|
+
let newLogger = winston.loggers.add(category, {
|
|
41
|
+
format: winston.format.combine(winston.format.label({ label: category }), winston.format.printf((info) => {
|
|
42
|
+
//debug模式等级时仅为控制台输出
|
|
43
|
+
let level = info.level.toUpperCase();
|
|
44
|
+
let timestamp = utils_1.DateUtil.toDateTimeMS();
|
|
45
|
+
let content = {
|
|
46
|
+
timestamp,
|
|
47
|
+
level,
|
|
48
|
+
label: info.label,
|
|
49
|
+
message: info.message,
|
|
50
|
+
};
|
|
51
|
+
if (Reflect.has(info, SPLAT)) {
|
|
52
|
+
let splat = Reflect.get(info, SPLAT);
|
|
53
|
+
Reflect.set(content, "splat", typeof splat == "string" ? splat : JSON.stringify(splat));
|
|
54
|
+
}
|
|
55
|
+
if (info.stack) {
|
|
56
|
+
Reflect.set(content, "stack", info.stack);
|
|
57
|
+
}
|
|
58
|
+
Reflect.set(info, "timestamp", content.timestamp);
|
|
59
|
+
//新增打印控制台
|
|
60
|
+
if (this.config.printConsole) {
|
|
61
|
+
let text = this.colorize(util.format("[%s] [%s] %s - ", timestamp, level, info.label), info.level);
|
|
62
|
+
text += this.colorizeData(content.message);
|
|
63
|
+
if (Reflect.has(info, SPLAT)) {
|
|
64
|
+
let splatMsg = Reflect.get(info, SPLAT);
|
|
65
|
+
splatMsg.forEach((item) => {
|
|
66
|
+
text += " " + this.colorizeData(item);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if (info.stack) {
|
|
70
|
+
text += this.colorizeData(`\nstatck: ${info.stack}`);
|
|
71
|
+
}
|
|
72
|
+
let fn = console.info;
|
|
73
|
+
if (Reflect.has(console, info.level)) {
|
|
74
|
+
fn = Reflect.get(console, info.level);
|
|
75
|
+
}
|
|
76
|
+
Reflect.apply(fn, console, [text]);
|
|
77
|
+
}
|
|
78
|
+
return util.format("%j", content);
|
|
79
|
+
})),
|
|
80
|
+
transports: [
|
|
81
|
+
new winston.transports.File({
|
|
82
|
+
level: this.config.fileLevel,
|
|
83
|
+
filename: path.join(this.config.rootPath, `${category}.log`),
|
|
84
|
+
maxsize: this.config.maxsize,
|
|
85
|
+
maxFiles: this.config.maxFiles,
|
|
86
|
+
}),
|
|
87
|
+
],
|
|
88
|
+
});
|
|
89
|
+
this.categoryMap.set(category, newLogger);
|
|
90
|
+
return newLogger;
|
|
91
|
+
}
|
|
92
|
+
getLoggerList() {
|
|
93
|
+
return [...this.categoryMap.values()];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.default = WinstonLogger;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DesignMeta = void 0;
|
|
4
|
-
var DesignMeta;
|
|
5
|
-
(function (DesignMeta) {
|
|
6
|
-
DesignMeta["table"] = "db:table";
|
|
7
|
-
DesignMeta["field"] = "db:field";
|
|
8
|
-
DesignMeta["fieldMap"] = "db:fieldMap";
|
|
9
|
-
DesignMeta["dbType"] = "db:dbType";
|
|
10
|
-
DesignMeta["primaryKey"] = "db:primaryKey";
|
|
11
|
-
DesignMeta["entity"] = "db:entity";
|
|
12
|
-
DesignMeta["mapping"] = "db:mapping";
|
|
13
|
-
DesignMeta["dbFields"] = "db:fields";
|
|
14
|
-
DesignMeta["sqlSession"] = "SqlSession";
|
|
15
|
-
})(DesignMeta
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DesignMeta = void 0;
|
|
4
|
+
var DesignMeta;
|
|
5
|
+
(function (DesignMeta) {
|
|
6
|
+
DesignMeta["table"] = "db:table";
|
|
7
|
+
DesignMeta["field"] = "db:field";
|
|
8
|
+
DesignMeta["fieldMap"] = "db:fieldMap";
|
|
9
|
+
DesignMeta["dbType"] = "db:dbType";
|
|
10
|
+
DesignMeta["primaryKey"] = "db:primaryKey";
|
|
11
|
+
DesignMeta["entity"] = "db:entity";
|
|
12
|
+
DesignMeta["mapping"] = "db:mapping";
|
|
13
|
+
DesignMeta["dbFields"] = "db:fields";
|
|
14
|
+
DesignMeta["sqlSession"] = "SqlSession";
|
|
15
|
+
})(DesignMeta = exports.DesignMeta || (exports.DesignMeta = {}));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/target/type/SqlError.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class SqlError extends Error {
|
|
4
|
-
}
|
|
5
|
-
exports.default = SqlError;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class SqlError extends Error {
|
|
4
|
+
}
|
|
5
|
+
exports.default = SqlError;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ColorLevelType = void 0;
|
|
4
|
-
exports.ColorLevelType = {
|
|
5
|
-
info: [32, 39],
|
|
6
|
-
debug: [36, 39],
|
|
7
|
-
warn: [33, 39],
|
|
8
|
-
error: [91, 39], //red
|
|
9
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ColorLevelType = void 0;
|
|
4
|
+
exports.ColorLevelType = {
|
|
5
|
+
info: [32, 39],
|
|
6
|
+
debug: [36, 39],
|
|
7
|
+
warn: [33, 39],
|
|
8
|
+
error: [91, 39], //red
|
|
9
|
+
};
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const TypeUtil_1 = require("./TypeUtil");
|
|
4
|
-
const FileUtil_1 = require("./FileUtil");
|
|
5
|
-
const fs = require("fs");
|
|
6
|
-
const path = require("path");
|
|
7
|
-
class ClassLoader {
|
|
8
|
-
/***
|
|
9
|
-
* @version 1.0 加载模块
|
|
10
|
-
* @version 1.1 新增是否强制重载模块
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
|
-
static loadModule(filePath, force = false) {
|
|
14
|
-
//校验后缀名是否为js或者ts
|
|
15
|
-
if (!TypeUtil_1.default.isTSORJS(filePath)) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
//避免重复加载或者想要重新进行挂载
|
|
19
|
-
if (Reflect.has(require.cache, filePath)) {
|
|
20
|
-
if (force) {
|
|
21
|
-
Reflect.deleteProperty(require.cache, filePath);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
//可能不止一个方法
|
|
25
|
-
const modulesMap = new Map();
|
|
26
|
-
//进行方法加载
|
|
27
|
-
let moduleClass = require(filePath);
|
|
28
|
-
let keys = Object.keys(moduleClass);
|
|
29
|
-
let fileName = FileUtil_1.default.getFileName(filePath);
|
|
30
|
-
keys.forEach((key) => {
|
|
31
|
-
let instance = moduleClass[key];
|
|
32
|
-
if (TypeUtil_1.default.isFunction(instance)) {
|
|
33
|
-
modulesMap.set(instance.name, instance);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
if (TypeUtil_1.default.isObject(instance)) {
|
|
37
|
-
modulesMap.set(fileName, instance);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
return modulesMap;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* @version 1.0 监听某个文件或者文件夹
|
|
44
|
-
*/
|
|
45
|
-
static watchServices(fp, context, eventName = "reload") {
|
|
46
|
-
if (typeof context.emit != "function") {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
const currStats = fs.statSync(fp);
|
|
50
|
-
let fileFlag = currStats.isFile();
|
|
51
|
-
//添加热更方法
|
|
52
|
-
fs.watch(fp, function (event, filename) {
|
|
53
|
-
if (event === "change") {
|
|
54
|
-
if (!fileFlag && filename) {
|
|
55
|
-
context.emit(eventName, path.join(fp, filename));
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
context.emit(eventName, fp);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.default = ClassLoader;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const TypeUtil_1 = require("./TypeUtil");
|
|
4
|
+
const FileUtil_1 = require("./FileUtil");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
class ClassLoader {
|
|
8
|
+
/***
|
|
9
|
+
* @version 1.0 加载模块
|
|
10
|
+
* @version 1.1 新增是否强制重载模块
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
static loadModule(filePath, force = false) {
|
|
14
|
+
//校验后缀名是否为js或者ts
|
|
15
|
+
if (!TypeUtil_1.default.isTSORJS(filePath)) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
//避免重复加载或者想要重新进行挂载
|
|
19
|
+
if (Reflect.has(require.cache, filePath)) {
|
|
20
|
+
if (force) {
|
|
21
|
+
Reflect.deleteProperty(require.cache, filePath);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//可能不止一个方法
|
|
25
|
+
const modulesMap = new Map();
|
|
26
|
+
//进行方法加载
|
|
27
|
+
let moduleClass = require(filePath);
|
|
28
|
+
let keys = Object.keys(moduleClass);
|
|
29
|
+
let fileName = FileUtil_1.default.getFileName(filePath);
|
|
30
|
+
keys.forEach((key) => {
|
|
31
|
+
let instance = moduleClass[key];
|
|
32
|
+
if (TypeUtil_1.default.isFunction(instance)) {
|
|
33
|
+
modulesMap.set(instance.name, instance);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (TypeUtil_1.default.isObject(instance)) {
|
|
37
|
+
modulesMap.set(fileName, instance);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return modulesMap;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* @version 1.0 监听某个文件或者文件夹
|
|
44
|
+
*/
|
|
45
|
+
static watchServices(fp, context, eventName = "reload") {
|
|
46
|
+
if (typeof context.emit != "function") {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
const currStats = fs.statSync(fp);
|
|
50
|
+
let fileFlag = currStats.isFile();
|
|
51
|
+
//添加热更方法
|
|
52
|
+
fs.watch(fp, function (event, filename) {
|
|
53
|
+
if (event === "change") {
|
|
54
|
+
if (!fileFlag && filename) {
|
|
55
|
+
context.emit(eventName, path.join(fp, filename));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
context.emit(eventName, fp);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.default = ClassLoader;
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class ClassUtils {
|
|
4
|
-
//获取一个类所有的proto属性 采用递归的形式
|
|
5
|
-
static getProtoType(t) {
|
|
6
|
-
if (!t?.prototype) {
|
|
7
|
-
return [];
|
|
8
|
-
}
|
|
9
|
-
let keys = Reflect.ownKeys(t?.prototype).map((item) => {
|
|
10
|
-
return item;
|
|
11
|
-
});
|
|
12
|
-
let parentObj = Reflect.getPrototypeOf(t);
|
|
13
|
-
if (!parentObj || !Reflect.has(parentObj, "prototype")) {
|
|
14
|
-
return keys;
|
|
15
|
-
}
|
|
16
|
-
let parentKeys = ClassUtils.getProtoType(parentObj);
|
|
17
|
-
let s = new Set([...keys, ...parentKeys]);
|
|
18
|
-
return [...s];
|
|
19
|
-
}
|
|
20
|
-
static getProtoDesc(t, key) {
|
|
21
|
-
if (!t?.prototype) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
let desc = Object.getOwnPropertyDescriptor(t.prototype, key);
|
|
25
|
-
if (!!desc) {
|
|
26
|
-
return desc;
|
|
27
|
-
}
|
|
28
|
-
let parentObj = Reflect.getPrototypeOf(t);
|
|
29
|
-
if (!parentObj || !Reflect.has(parentObj, "prototype")) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
return ClassUtils.getProtoDesc(parentObj, key);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.default = ClassUtils;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class ClassUtils {
|
|
4
|
+
//获取一个类所有的proto属性 采用递归的形式
|
|
5
|
+
static getProtoType(t) {
|
|
6
|
+
if (!t?.prototype) {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
let keys = Reflect.ownKeys(t?.prototype).map((item) => {
|
|
10
|
+
return item;
|
|
11
|
+
});
|
|
12
|
+
let parentObj = Reflect.getPrototypeOf(t);
|
|
13
|
+
if (!parentObj || !Reflect.has(parentObj, "prototype")) {
|
|
14
|
+
return keys;
|
|
15
|
+
}
|
|
16
|
+
let parentKeys = ClassUtils.getProtoType(parentObj);
|
|
17
|
+
let s = new Set([...keys, ...parentKeys]);
|
|
18
|
+
return [...s];
|
|
19
|
+
}
|
|
20
|
+
static getProtoDesc(t, key) {
|
|
21
|
+
if (!t?.prototype) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
let desc = Object.getOwnPropertyDescriptor(t.prototype, key);
|
|
25
|
+
if (!!desc) {
|
|
26
|
+
return desc;
|
|
27
|
+
}
|
|
28
|
+
let parentObj = Reflect.getPrototypeOf(t);
|
|
29
|
+
if (!parentObj || !Reflect.has(parentObj, "prototype")) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return ClassUtils.getProtoDesc(parentObj, key);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.default = ClassUtils;
|
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const crypto = require("crypto");
|
|
4
|
-
class CryptoUtil {
|
|
5
|
-
static aesDecode(cryptkey, iv, secretdata, aesType = "aes-256-cbc" /* serects.aes */) {
|
|
6
|
-
let decipher = crypto.createDecipheriv(aesType, cryptkey, iv);
|
|
7
|
-
let decoded = decipher.update(secretdata, "base64", "utf8");
|
|
8
|
-
decoded += decipher.final("utf8");
|
|
9
|
-
return decoded;
|
|
10
|
-
}
|
|
11
|
-
static aesEncode(cryptkey, iv, cleardata, aesType = "aes-256-cbc" /* serects.aes */) {
|
|
12
|
-
let encipher = crypto.createCipheriv("aes-256-cbc" /* serects.aes */, cryptkey, iv);
|
|
13
|
-
let encoded = encipher.update(cleardata, "utf8", "base64");
|
|
14
|
-
encoded += encipher.final("base64");
|
|
15
|
-
return encoded;
|
|
16
|
-
}
|
|
17
|
-
static shaEncode(cryptkey, data) {
|
|
18
|
-
let hash = crypto.createHmac("sha256", cryptkey);
|
|
19
|
-
return hash.update(data).digest("base64");
|
|
20
|
-
}
|
|
21
|
-
static gcmEncrypt(password, msg) {
|
|
22
|
-
try {
|
|
23
|
-
let pwd = Buffer.from(password, "hex");
|
|
24
|
-
let iv = crypto.randomBytes(12);
|
|
25
|
-
let cipher = crypto.createCipheriv("aes-128-gcm", pwd, iv);
|
|
26
|
-
//加密
|
|
27
|
-
let enc = cipher.update(msg, "utf8", "base64");
|
|
28
|
-
enc += cipher.final("base64");
|
|
29
|
-
//cipher.getAuthTag() 方法返回一个 Buffer,它包含已从给定数据计算后的认证标签。
|
|
30
|
-
//cipher.getAuthTag() 方法只能在使用 cipher.final() 之后调用 这里返回的是一个十六进制后的数组
|
|
31
|
-
let tags = cipher.getAuthTag();
|
|
32
|
-
let encStr = Buffer.from(enc, "base64");
|
|
33
|
-
//由于和java对应的AES/GCM/PKCS5Padding模式对应 所以采用这个拼接
|
|
34
|
-
let totalLength = iv.length + encStr.length + tags.length;
|
|
35
|
-
let bufferMsg = Buffer.concat([iv, encStr, tags], totalLength);
|
|
36
|
-
return bufferMsg.toString("base64");
|
|
37
|
-
}
|
|
38
|
-
catch (e) {
|
|
39
|
-
console.log("Encrypt is error", e);
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
static gcmDecrypt(password, serect) {
|
|
44
|
-
try {
|
|
45
|
-
let tmpSerect = Buffer.from(serect, "base64");
|
|
46
|
-
let pwd = Buffer.from(password, "hex");
|
|
47
|
-
//读取数组
|
|
48
|
-
let iv = tmpSerect.subarray(0, 12);
|
|
49
|
-
let cipher = crypto.createDecipheriv("aes-128-gcm", pwd, iv);
|
|
50
|
-
//这边的数据为 去除头的iv12位和尾部的tags的16位
|
|
51
|
-
let msg = cipher.update(tmpSerect.subarray(12, tmpSerect.length - 16));
|
|
52
|
-
return msg.toString("utf8");
|
|
53
|
-
}
|
|
54
|
-
catch (e) {
|
|
55
|
-
console.log("Decrypt is error", e);
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
static sha256Encode(text, serect = crypto.randomBytes(32).toString("hex"), encoding = "base64") {
|
|
60
|
-
let msg = crypto.createHmac("sha256", serect).update(text).digest(encoding);
|
|
61
|
-
return {
|
|
62
|
-
salt: serect,
|
|
63
|
-
msg: msg,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
static sha256EncodeContent(str, encoding = "base64") {
|
|
67
|
-
let msg = crypto.createHash("sha256").update(str).digest(encoding);
|
|
68
|
-
return msg;
|
|
69
|
-
}
|
|
70
|
-
static sha256Very(msg, serect, encodeMsg, encoding = "base64") {
|
|
71
|
-
let result = this.sha256Encode(msg, serect, encoding);
|
|
72
|
-
return result.msg === encodeMsg;
|
|
73
|
-
}
|
|
74
|
-
static getHashStr(num = 16) {
|
|
75
|
-
return crypto.randomBytes(num).toString("hex");
|
|
76
|
-
}
|
|
77
|
-
//根据给定的字符串返回hash值按照追加的原则
|
|
78
|
-
static getHashStrByLength(serect, num) {
|
|
79
|
-
let list = crypto.createHash("md5").update(serect).digest().toString("hex");
|
|
80
|
-
while (list.length < num) {
|
|
81
|
-
list = list.repeat(num - list.length);
|
|
82
|
-
}
|
|
83
|
-
return list.substring(0, num);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
exports.default = CryptoUtil;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const crypto = require("crypto");
|
|
4
|
+
class CryptoUtil {
|
|
5
|
+
static aesDecode(cryptkey, iv, secretdata, aesType = "aes-256-cbc" /* serects.aes */) {
|
|
6
|
+
let decipher = crypto.createDecipheriv(aesType, cryptkey, iv);
|
|
7
|
+
let decoded = decipher.update(secretdata, "base64", "utf8");
|
|
8
|
+
decoded += decipher.final("utf8");
|
|
9
|
+
return decoded;
|
|
10
|
+
}
|
|
11
|
+
static aesEncode(cryptkey, iv, cleardata, aesType = "aes-256-cbc" /* serects.aes */) {
|
|
12
|
+
let encipher = crypto.createCipheriv("aes-256-cbc" /* serects.aes */, cryptkey, iv);
|
|
13
|
+
let encoded = encipher.update(cleardata, "utf8", "base64");
|
|
14
|
+
encoded += encipher.final("base64");
|
|
15
|
+
return encoded;
|
|
16
|
+
}
|
|
17
|
+
static shaEncode(cryptkey, data) {
|
|
18
|
+
let hash = crypto.createHmac("sha256", cryptkey);
|
|
19
|
+
return hash.update(data).digest("base64");
|
|
20
|
+
}
|
|
21
|
+
static gcmEncrypt(password, msg) {
|
|
22
|
+
try {
|
|
23
|
+
let pwd = Buffer.from(password, "hex");
|
|
24
|
+
let iv = crypto.randomBytes(12);
|
|
25
|
+
let cipher = crypto.createCipheriv("aes-128-gcm", pwd, iv);
|
|
26
|
+
//加密
|
|
27
|
+
let enc = cipher.update(msg, "utf8", "base64");
|
|
28
|
+
enc += cipher.final("base64");
|
|
29
|
+
//cipher.getAuthTag() 方法返回一个 Buffer,它包含已从给定数据计算后的认证标签。
|
|
30
|
+
//cipher.getAuthTag() 方法只能在使用 cipher.final() 之后调用 这里返回的是一个十六进制后的数组
|
|
31
|
+
let tags = cipher.getAuthTag();
|
|
32
|
+
let encStr = Buffer.from(enc, "base64");
|
|
33
|
+
//由于和java对应的AES/GCM/PKCS5Padding模式对应 所以采用这个拼接
|
|
34
|
+
let totalLength = iv.length + encStr.length + tags.length;
|
|
35
|
+
let bufferMsg = Buffer.concat([iv, encStr, tags], totalLength);
|
|
36
|
+
return bufferMsg.toString("base64");
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
console.log("Encrypt is error", e);
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
static gcmDecrypt(password, serect) {
|
|
44
|
+
try {
|
|
45
|
+
let tmpSerect = Buffer.from(serect, "base64");
|
|
46
|
+
let pwd = Buffer.from(password, "hex");
|
|
47
|
+
//读取数组
|
|
48
|
+
let iv = tmpSerect.subarray(0, 12);
|
|
49
|
+
let cipher = crypto.createDecipheriv("aes-128-gcm", pwd, iv);
|
|
50
|
+
//这边的数据为 去除头的iv12位和尾部的tags的16位
|
|
51
|
+
let msg = cipher.update(tmpSerect.subarray(12, tmpSerect.length - 16));
|
|
52
|
+
return msg.toString("utf8");
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
console.log("Decrypt is error", e);
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
static sha256Encode(text, serect = crypto.randomBytes(32).toString("hex"), encoding = "base64") {
|
|
60
|
+
let msg = crypto.createHmac("sha256", serect).update(text).digest(encoding);
|
|
61
|
+
return {
|
|
62
|
+
salt: serect,
|
|
63
|
+
msg: msg,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
static sha256EncodeContent(str, encoding = "base64") {
|
|
67
|
+
let msg = crypto.createHash("sha256").update(str).digest(encoding);
|
|
68
|
+
return msg;
|
|
69
|
+
}
|
|
70
|
+
static sha256Very(msg, serect, encodeMsg, encoding = "base64") {
|
|
71
|
+
let result = this.sha256Encode(msg, serect, encoding);
|
|
72
|
+
return result.msg === encodeMsg;
|
|
73
|
+
}
|
|
74
|
+
static getHashStr(num = 16) {
|
|
75
|
+
return crypto.randomBytes(num).toString("hex");
|
|
76
|
+
}
|
|
77
|
+
//根据给定的字符串返回hash值按照追加的原则
|
|
78
|
+
static getHashStrByLength(serect, num) {
|
|
79
|
+
let list = crypto.createHash("md5").update(serect).digest().toString("hex");
|
|
80
|
+
while (list.length < num) {
|
|
81
|
+
list = list.repeat(num - list.length);
|
|
82
|
+
}
|
|
83
|
+
return list.substring(0, num);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.default = CryptoUtil;
|