midway-fatcms 0.0.1-beta.63 → 0.0.1-beta.65
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/.eslintrc.json +14 -14
- package/.prettierrc.js +4 -4
- package/README.md +8 -8
- package/dist/config/config.default.d.ts +3 -3
- package/dist/config/config.default.js +160 -160
- package/dist/config/utils.d.ts +1 -1
- package/dist/config/utils.js +23 -23
- package/dist/configuration.d.ts +7 -7
- package/dist/configuration.js +113 -113
- package/dist/controller/base/BaseApiController.d.ts +37 -37
- package/dist/controller/base/BaseApiController.js +164 -164
- package/dist/controller/gateway/AnyApiGatewayController.d.ts +13 -13
- package/dist/controller/gateway/AnyApiGatewayController.js +55 -55
- package/dist/controller/gateway/AsyncTaskController.d.ts +20 -20
- package/dist/controller/gateway/AsyncTaskController.js +181 -181
- package/dist/controller/gateway/CrudMtdGatewayController.d.ts +21 -21
- package/dist/controller/gateway/CrudMtdGatewayController.js +122 -122
- package/dist/controller/gateway/CrudStdGatewayController.d.ts +38 -38
- package/dist/controller/gateway/CrudStdGatewayController.js +129 -129
- package/dist/controller/gateway/DocGatewayController.d.ts +27 -27
- package/dist/controller/gateway/DocGatewayController.js +179 -179
- package/dist/controller/gateway/FileController.d.ts +28 -28
- package/dist/controller/gateway/FileController.js +144 -144
- package/dist/controller/gateway/ProxyApiGatewayController.d.ts +18 -18
- package/dist/controller/gateway/ProxyApiGatewayController.js +78 -78
- package/dist/controller/gateway/PublicApiController.d.ts +31 -31
- package/dist/controller/gateway/PublicApiController.js +179 -179
- package/dist/controller/gateway/StaticController.d.ts +23 -23
- package/dist/controller/gateway/StaticController.js +286 -286
- package/dist/controller/helpers.controller.d.ts +39 -39
- package/dist/controller/helpers.controller.js +188 -188
- package/dist/controller/home.controller.d.ts +9 -9
- package/dist/controller/home.controller.js +72 -72
- package/dist/controller/manage/AnyApiMangeApi.d.ts +10 -10
- package/dist/controller/manage/AnyApiMangeApi.js +98 -98
- package/dist/controller/manage/AppLogMangeApi.d.ts +10 -10
- package/dist/controller/manage/AppLogMangeApi.js +88 -88
- package/dist/controller/manage/AppMangeApi.d.ts +10 -10
- package/dist/controller/manage/AppMangeApi.js +88 -88
- package/dist/controller/manage/AppPageMangeApi.d.ts +10 -10
- package/dist/controller/manage/AppPageMangeApi.js +87 -87
- package/dist/controller/manage/AppSchemaHistoryApi.d.ts +10 -10
- package/dist/controller/manage/AppSchemaHistoryApi.js +83 -83
- package/dist/controller/manage/CrudMethodsMangeApi.d.ts +10 -10
- package/dist/controller/manage/CrudMethodsMangeApi.js +84 -84
- package/dist/controller/manage/CrudStandardDesignApi.d.ts +46 -46
- package/dist/controller/manage/CrudStandardDesignApi.js +367 -367
- package/dist/controller/manage/DataDictManageApi.d.ts +15 -15
- package/dist/controller/manage/DataDictManageApi.js +133 -133
- package/dist/controller/manage/DeployManageApi.d.ts +19 -19
- package/dist/controller/manage/DeployManageApi.js +180 -180
- package/dist/controller/manage/DocLibManageApi.d.ts +10 -10
- package/dist/controller/manage/DocLibManageApi.js +104 -104
- package/dist/controller/manage/DocManageApi.d.ts +11 -11
- package/dist/controller/manage/DocManageApi.js +130 -130
- package/dist/controller/manage/FileManageApi.d.ts +13 -13
- package/dist/controller/manage/FileManageApi.js +77 -77
- package/dist/controller/manage/LowCodeTplManageApi.d.ts +13 -13
- package/dist/controller/manage/LowCodeTplManageApi.js +86 -86
- package/dist/controller/manage/MenuManageApi.d.ts +10 -10
- package/dist/controller/manage/MenuManageApi.js +93 -93
- package/dist/controller/manage/ProxyApiMangeApi.d.ts +10 -10
- package/dist/controller/manage/ProxyApiMangeApi.js +87 -87
- package/dist/controller/manage/SuperAdminManageApi.d.ts +24 -24
- package/dist/controller/manage/SuperAdminManageApi.js +153 -153
- package/dist/controller/manage/SysConfigMangeApi.d.ts +11 -11
- package/dist/controller/manage/SysConfigMangeApi.js +126 -126
- package/dist/controller/manage/SystemInfoManageApi.d.ts +12 -12
- package/dist/controller/manage/SystemInfoManageApi.js +72 -72
- package/dist/controller/manage/UserAccountManageApi.d.ts +14 -14
- package/dist/controller/manage/UserAccountManageApi.js +129 -129
- package/dist/controller/manage/WorkbenchMangeApi.d.ts +11 -11
- package/dist/controller/manage/WorkbenchMangeApi.js +103 -103
- package/dist/controller/myinfo/AuthController.d.ts +33 -33
- package/dist/controller/myinfo/AuthController.js +136 -136
- package/dist/controller/myinfo/MyInfoController.d.ts +13 -13
- package/dist/controller/myinfo/MyInfoController.js +51 -51
- package/dist/controller/render/AppRenderController.d.ts +11 -11
- package/dist/controller/render/AppRenderController.js +92 -92
- package/dist/controller/test.controller.d.ts +8 -8
- package/dist/controller/test.controller.js +51 -51
- package/dist/filter/default.filter.d.ts +7 -7
- package/dist/filter/default.filter.js +23 -23
- package/dist/filter/notfound.filter.d.ts +5 -5
- package/dist/filter/notfound.filter.js +20 -20
- package/dist/index.d.ts +103 -103
- package/dist/index.js +121 -121
- package/dist/interface.d.ts +27 -27
- package/dist/interface.js +3 -3
- package/dist/libs/crud-pro/CrudPro.d.ts +37 -37
- package/dist/libs/crud-pro/CrudPro.js +136 -136
- package/dist/libs/crud-pro/defaultConfigs.d.ts +4 -4
- package/dist/libs/crud-pro/defaultConfigs.js +15 -15
- package/dist/libs/crud-pro/exceptions.d.ts +104 -104
- package/dist/libs/crud-pro/exceptions.js +117 -117
- package/dist/libs/crud-pro/interfaces.d.ts +165 -165
- package/dist/libs/crud-pro/interfaces.js +12 -12
- package/dist/libs/crud-pro/models/ExecuteContext.d.ts +49 -49
- package/dist/libs/crud-pro/models/ExecuteContext.js +79 -79
- package/dist/libs/crud-pro/models/ExecuteContextFunc.d.ts +38 -38
- package/dist/libs/crud-pro/models/ExecuteContextFunc.js +72 -72
- package/dist/libs/crud-pro/models/FuncContext.d.ts +18 -18
- package/dist/libs/crud-pro/models/FuncContext.js +6 -6
- package/dist/libs/crud-pro/models/RequestCfgModel.d.ts +65 -65
- package/dist/libs/crud-pro/models/RequestCfgModel.js +81 -81
- package/dist/libs/crud-pro/models/RequestModel.d.ts +25 -25
- package/dist/libs/crud-pro/models/RequestModel.js +113 -113
- package/dist/libs/crud-pro/models/ResModel.d.ts +16 -16
- package/dist/libs/crud-pro/models/ResModel.js +2 -2
- package/dist/libs/crud-pro/models/ServiceHub.d.ts +20 -20
- package/dist/libs/crud-pro/models/ServiceHub.js +2 -2
- package/dist/libs/crud-pro/models/SqlCfgModel.d.ts +22 -22
- package/dist/libs/crud-pro/models/SqlCfgModel.js +40 -40
- package/dist/libs/crud-pro/models/SqlSegArg.d.ts +6 -6
- package/dist/libs/crud-pro/models/SqlSegArg.js +12 -12
- package/dist/libs/crud-pro/models/Transaction.d.ts +30 -30
- package/dist/libs/crud-pro/models/Transaction.js +74 -74
- package/dist/libs/crud-pro/models/TransactionMySQL.d.ts +28 -28
- package/dist/libs/crud-pro/models/TransactionMySQL.js +76 -76
- package/dist/libs/crud-pro/models/TransactionPostgres.d.ts +28 -28
- package/dist/libs/crud-pro/models/TransactionPostgres.js +85 -85
- package/dist/libs/crud-pro/models/TransactionSqlServer.d.ts +34 -34
- package/dist/libs/crud-pro/models/TransactionSqlServer.js +92 -92
- package/dist/libs/crud-pro/models/keys.d.ts +110 -110
- package/dist/libs/crud-pro/models/keys.js +154 -154
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.d.ts +11 -11
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.js +73 -73
- package/dist/libs/crud-pro/services/CrudProExecuteFuncService.d.ts +9 -9
- package/dist/libs/crud-pro/services/CrudProExecuteFuncService.js +125 -125
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.d.ts +17 -17
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +225 -225
- package/dist/libs/crud-pro/services/CrudProFieldUpdateService.d.ts +9 -9
- package/dist/libs/crud-pro/services/CrudProFieldUpdateService.js +51 -51
- package/dist/libs/crud-pro/services/CrudProFieldValidateService.d.ts +13 -13
- package/dist/libs/crud-pro/services/CrudProFieldValidateService.js +148 -148
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.d.ts +24 -24
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.js +355 -355
- package/dist/libs/crud-pro/services/CrudProGenSqlService.d.ts +25 -25
- package/dist/libs/crud-pro/services/CrudProGenSqlService.js +165 -165
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.d.ts +32 -32
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +334 -334
- package/dist/libs/crud-pro/services/CrudProServiceBase.d.ts +24 -24
- package/dist/libs/crud-pro/services/CrudProServiceBase.js +90 -90
- package/dist/libs/crud-pro/services/CrudProTableMetaService.d.ts +9 -9
- package/dist/libs/crud-pro/services/CrudProTableMetaService.js +72 -72
- package/dist/libs/crud-pro/services/CurdProServiceHub.d.ts +32 -32
- package/dist/libs/crud-pro/services/CurdProServiceHub.js +64 -64
- package/dist/libs/crud-pro/utils/CompareUtils.d.ts +9 -9
- package/dist/libs/crud-pro/utils/CompareUtils.js +25 -25
- package/dist/libs/crud-pro/utils/DatabaseName.d.ts +9 -9
- package/dist/libs/crud-pro/utils/DatabaseName.js +50 -50
- package/dist/libs/crud-pro/utils/DateTimeUtils.d.ts +7 -7
- package/dist/libs/crud-pro/utils/DateTimeUtils.js +21 -21
- package/dist/libs/crud-pro/utils/MemoryRefreshCache.d.ts +19 -19
- package/dist/libs/crud-pro/utils/MemoryRefreshCache.js +47 -47
- package/dist/libs/crud-pro/utils/MessageParseUtils.d.ts +5 -5
- package/dist/libs/crud-pro/utils/MessageParseUtils.js +33 -33
- package/dist/libs/crud-pro/utils/MixinUtils.d.ts +39 -39
- package/dist/libs/crud-pro/utils/MixinUtils.js +255 -255
- package/dist/libs/crud-pro/utils/ModelUtils.d.ts +11 -11
- package/dist/libs/crud-pro/utils/ModelUtils.js +54 -54
- package/dist/libs/crud-pro/utils/MultiKeyMap.d.ts +11 -11
- package/dist/libs/crud-pro/utils/MultiKeyMap.js +63 -63
- package/dist/libs/crud-pro/utils/SqlFuncUtils.d.ts +5 -5
- package/dist/libs/crud-pro/utils/SqlFuncUtils.js +29 -29
- package/dist/libs/crud-pro/utils/TypeUtils.d.ts +40 -40
- package/dist/libs/crud-pro/utils/TypeUtils.js +166 -166
- package/dist/libs/crud-pro/utils/ValidateUtils.d.ts +3 -3
- package/dist/libs/crud-pro/utils/ValidateUtils.js +165 -165
- package/dist/libs/crud-pro/utils/pool/MySQLUtils.d.ts +3 -3
- package/dist/libs/crud-pro/utils/pool/MySQLUtils.js +19 -19
- package/dist/libs/crud-pro/utils/pool/PostgresUtils.d.ts +3 -3
- package/dist/libs/crud-pro/utils/pool/PostgresUtils.js +20 -20
- package/dist/libs/crud-pro/utils/pool/SqlServerUtils.d.ts +3 -3
- package/dist/libs/crud-pro/utils/pool/SqlServerUtils.js +20 -20
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.d.ts +4 -4
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.js +21 -21
- package/dist/libs/crud-pro/utils/sqlConvert/convertMix.d.ts +3 -3
- package/dist/libs/crud-pro/utils/sqlConvert/convertMix.js +22 -22
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.d.ts +2 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.js +11 -11
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.d.ts +2 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.js +11 -11
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgType.d.ts +2 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgType.js +128 -128
- package/dist/libs/global-config/global-config.d.ts +69 -69
- package/dist/libs/global-config/global-config.js +36 -36
- package/dist/libs/utils/base64.d.ts +9 -9
- package/dist/libs/utils/base64.js +42 -42
- package/dist/libs/utils/common-dto.d.ts +18 -18
- package/dist/libs/utils/common-dto.js +40 -40
- package/dist/libs/utils/crypto-utils.d.ts +3 -3
- package/dist/libs/utils/crypto-utils.js +46 -46
- package/dist/libs/utils/errorToString.d.ts +2 -2
- package/dist/libs/utils/errorToString.js +57 -57
- package/dist/libs/utils/fatcms-request.d.ts +30 -30
- package/dist/libs/utils/fatcms-request.js +104 -104
- package/dist/libs/utils/functions.d.ts +5 -5
- package/dist/libs/utils/functions.js +72 -72
- package/dist/libs/utils/ordernum-utils.d.ts +2 -2
- package/dist/libs/utils/ordernum-utils.js +13 -13
- package/dist/libs/utils/parseConfig.d.ts +8 -7
- package/dist/libs/utils/parseConfig.js +47 -44
- package/dist/libs/utils/parseCreateSql.d.ts +10 -10
- package/dist/libs/utils/parseCreateSql.js +87 -87
- package/dist/libs/utils/render-utils.d.ts +28 -28
- package/dist/libs/utils/render-utils.js +133 -133
- package/dist/middleware/forbidden.middleware.d.ts +10 -10
- package/dist/middleware/forbidden.middleware.js +54 -54
- package/dist/middleware/global.middleware.d.ts +10 -10
- package/dist/middleware/global.middleware.js +266 -266
- package/dist/middleware/permission.middleware.d.ts +18 -18
- package/dist/middleware/permission.middleware.js +74 -74
- package/dist/middleware/rediscache.middleware.d.ts +3 -3
- package/dist/middleware/rediscache.middleware.js +77 -77
- package/dist/middleware/redislock.middleware.d.ts +7 -7
- package/dist/middleware/redislock.middleware.js +72 -72
- package/dist/middleware/tx.middleware.d.ts +9 -9
- package/dist/middleware/tx.middleware.js +40 -40
- package/dist/models/AsyncTaskModel.d.ts +74 -74
- package/dist/models/AsyncTaskModel.js +31 -31
- package/dist/models/RedisKeys.d.ts +15 -15
- package/dist/models/RedisKeys.js +18 -18
- package/dist/models/SystemEntities.d.ts +105 -105
- package/dist/models/SystemEntities.js +9 -9
- package/dist/models/SystemPerm.d.ts +95 -95
- package/dist/models/SystemPerm.js +100 -100
- package/dist/models/SystemTables.d.ts +25 -25
- package/dist/models/SystemTables.js +28 -28
- package/dist/models/bizmodels.d.ts +104 -99
- package/dist/models/bizmodels.js +39 -39
- package/dist/models/contextLogger.d.ts +25 -25
- package/dist/models/contextLogger.js +112 -112
- package/dist/models/devops.d.ts +12 -12
- package/dist/models/devops.js +19 -19
- package/dist/models/userSession.d.ts +62 -62
- package/dist/models/userSession.js +165 -165
- package/dist/schedule/anonymousContext.d.ts +14 -14
- package/dist/schedule/anonymousContext.js +59 -59
- package/dist/schedule/index.d.ts +4 -4
- package/dist/schedule/index.js +10 -10
- package/dist/schedule/runSchedule.d.ts +12 -12
- package/dist/schedule/runSchedule.js +68 -68
- package/dist/schedule/scheduleNames.d.ts +13 -13
- package/dist/schedule/scheduleNames.js +17 -17
- package/dist/service/AuthService.d.ts +71 -71
- package/dist/service/AuthService.js +263 -259
- package/dist/service/EnumInfoService.d.ts +30 -30
- package/dist/service/EnumInfoService.js +127 -127
- package/dist/service/FileCenterService.d.ts +43 -43
- package/dist/service/FileCenterService.js +351 -351
- package/dist/service/SysConfigService.d.ts +7 -7
- package/dist/service/SysConfigService.js +47 -47
- package/dist/service/UserAccountService.d.ts +23 -23
- package/dist/service/UserAccountService.js +107 -107
- package/dist/service/UserSessionService.d.ts +38 -38
- package/dist/service/UserSessionService.js +157 -157
- package/dist/service/VisitStatService.d.ts +14 -14
- package/dist/service/VisitStatService.js +158 -158
- package/dist/service/WorkbenchService.d.ts +53 -53
- package/dist/service/WorkbenchService.js +211 -211
- package/dist/service/anyapi/AnyApiSandboxService.d.ts +15 -15
- package/dist/service/anyapi/AnyApiSandboxService.js +110 -110
- package/dist/service/anyapi/AnyApiService.d.ts +27 -27
- package/dist/service/anyapi/AnyApiService.js +181 -181
- package/dist/service/asyncTask/AsyncTaskRunnerService.d.ts +50 -50
- package/dist/service/asyncTask/AsyncTaskRunnerService.js +287 -287
- package/dist/service/asyncTask/AsyncTaskService.d.ts +7 -7
- package/dist/service/asyncTask/AsyncTaskService.js +34 -34
- package/dist/service/asyncTask/handler/ExcelInfoModel.d.ts +10 -10
- package/dist/service/asyncTask/handler/ExcelInfoModel.js +2 -2
- package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.d.ts +7 -7
- package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.js +216 -216
- package/dist/service/asyncTask/handler/ExportExcelByInnerHttpHandler.d.ts +36 -36
- package/dist/service/asyncTask/handler/ExportExcelByInnerHttpHandler.js +141 -141
- package/dist/service/asyncTask/handler/ExportExcelByStdCrudHandler.d.ts +46 -46
- package/dist/service/asyncTask/handler/ExportExcelByStdCrudHandler.js +135 -135
- package/dist/service/base/ApiBaseService.d.ts +15 -15
- package/dist/service/base/ApiBaseService.js +50 -50
- package/dist/service/base/ApiRateLimiter.d.ts +10 -10
- package/dist/service/base/ApiRateLimiter.js +51 -51
- package/dist/service/base/BaseService.d.ts +41 -41
- package/dist/service/base/BaseService.js +101 -101
- package/dist/service/base/RedisCacheService.d.ts +20 -20
- package/dist/service/base/RedisCacheService.js +57 -57
- package/dist/service/crudstd/CrudStdActionService.d.ts +17 -17
- package/dist/service/crudstd/CrudStdActionService.js +32 -32
- package/dist/service/crudstd/CrudStdConstant.d.ts +58 -58
- package/dist/service/crudstd/CrudStdConstant.js +64 -64
- package/dist/service/crudstd/CrudStdRelationService.d.ts +10 -10
- package/dist/service/crudstd/CrudStdRelationService.js +121 -121
- package/dist/service/crudstd/CrudStdService.d.ts +70 -69
- package/dist/service/crudstd/CrudStdService.js +403 -392
- package/dist/service/curd/CrudProQuick.d.ts +44 -44
- package/dist/service/curd/CrudProQuick.js +147 -147
- package/dist/service/curd/CurdMixByAccountService.d.ts +9 -9
- package/dist/service/curd/CurdMixByAccountService.js +113 -113
- package/dist/service/curd/CurdMixByDictService.d.ts +13 -13
- package/dist/service/curd/CurdMixByDictService.js +114 -114
- package/dist/service/curd/CurdMixByLinkToCustomService.d.ts +31 -31
- package/dist/service/curd/CurdMixByLinkToCustomService.js +203 -203
- package/dist/service/curd/CurdMixBySysConfigService.d.ts +9 -9
- package/dist/service/curd/CurdMixBySysConfigService.js +80 -80
- package/dist/service/curd/CurdMixByWorkbenchService.d.ts +10 -10
- package/dist/service/curd/CurdMixByWorkbenchService.js +78 -78
- package/dist/service/curd/CurdMixService.d.ts +28 -28
- package/dist/service/curd/CurdMixService.js +100 -100
- package/dist/service/curd/CurdMixUtils.d.ts +57 -57
- package/dist/service/curd/CurdMixUtils.js +331 -331
- package/dist/service/curd/CurdProService.d.ts +32 -32
- package/dist/service/curd/CurdProService.js +212 -212
- package/dist/service/curd/fixCfgModel.d.ts +3 -3
- package/dist/service/curd/fixCfgModel.js +104 -104
- package/dist/service/proxyapi/ProxyApiLoadService.d.ts +21 -21
- package/dist/service/proxyapi/ProxyApiLoadService.js +167 -167
- package/dist/service/proxyapi/ProxyApiService.d.ts +61 -61
- package/dist/service/proxyapi/ProxyApiService.js +294 -294
- package/dist/service/proxyapi/ProxyApiUtils.d.ts +15 -15
- package/dist/service/proxyapi/ProxyApiUtils.js +34 -34
- package/dist/service/proxyapi/RouteHandler.d.ts +5 -5
- package/dist/service/proxyapi/RouteHandler.js +9 -9
- package/dist/service/proxyapi/RouteTrie.d.ts +12 -12
- package/dist/service/proxyapi/RouteTrie.js +63 -63
- package/dist/service/proxyapi/WeightedRandom.d.ts +9 -9
- package/dist/service/proxyapi/WeightedRandom.js +31 -31
- package/dist/service/proxyapi/WeightedRoundRobin.d.ts +8 -8
- package/dist/service/proxyapi/WeightedRoundRobin.js +32 -32
- package/index.d.ts +10 -10
- package/package.json +87 -87
- package/src/controller/manage/DocLibManageApi.ts +5 -5
- package/src/controller/manage/FileManageApi.ts +5 -5
- package/src/controller/manage/MenuManageApi.ts +4 -4
- package/src/libs/utils/parseConfig.ts +4 -0
- package/src/models/bizmodels.ts +8 -2
- package/src/service/AuthService.ts +6 -1
- package/src/service/EnumInfoService.ts +1 -1
- package/src/service/crudstd/CrudStdService.ts +15 -2
- package/src/service/proxyapi/WeightedRandom.ts +1 -1
- package/src/service/proxyapi/WeightedRoundRobin.ts +1 -1
- package/tsconfig.json +32 -32
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommonResult = void 0;
|
|
4
|
-
class CommonResult {
|
|
5
|
-
static successNotNull(data) {
|
|
6
|
-
const res = new CommonResult();
|
|
7
|
-
if (data) {
|
|
8
|
-
res.success = true;
|
|
9
|
-
res.data = data;
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
res.success = false;
|
|
13
|
-
res.message = '对象找不到';
|
|
14
|
-
}
|
|
15
|
-
return res;
|
|
16
|
-
}
|
|
17
|
-
static successRes(data) {
|
|
18
|
-
const res = new CommonResult();
|
|
19
|
-
res.success = true;
|
|
20
|
-
res.data = data;
|
|
21
|
-
return res;
|
|
22
|
-
}
|
|
23
|
-
static successMsg(message, data) {
|
|
24
|
-
const res = new CommonResult();
|
|
25
|
-
res.success = true;
|
|
26
|
-
res.message = message;
|
|
27
|
-
res.data = data;
|
|
28
|
-
return res;
|
|
29
|
-
}
|
|
30
|
-
static errorRes(message, errorCode = '', debugInfo = null) {
|
|
31
|
-
const res = new CommonResult();
|
|
32
|
-
res.success = false;
|
|
33
|
-
res.data = null;
|
|
34
|
-
res.message = message;
|
|
35
|
-
res.code = errorCode;
|
|
36
|
-
res.debugInfo = debugInfo;
|
|
37
|
-
return res;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.CommonResult = CommonResult;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommonResult = void 0;
|
|
4
|
+
class CommonResult {
|
|
5
|
+
static successNotNull(data) {
|
|
6
|
+
const res = new CommonResult();
|
|
7
|
+
if (data) {
|
|
8
|
+
res.success = true;
|
|
9
|
+
res.data = data;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
res.success = false;
|
|
13
|
+
res.message = '对象找不到';
|
|
14
|
+
}
|
|
15
|
+
return res;
|
|
16
|
+
}
|
|
17
|
+
static successRes(data) {
|
|
18
|
+
const res = new CommonResult();
|
|
19
|
+
res.success = true;
|
|
20
|
+
res.data = data;
|
|
21
|
+
return res;
|
|
22
|
+
}
|
|
23
|
+
static successMsg(message, data) {
|
|
24
|
+
const res = new CommonResult();
|
|
25
|
+
res.success = true;
|
|
26
|
+
res.message = message;
|
|
27
|
+
res.data = data;
|
|
28
|
+
return res;
|
|
29
|
+
}
|
|
30
|
+
static errorRes(message, errorCode = '', debugInfo = null) {
|
|
31
|
+
const res = new CommonResult();
|
|
32
|
+
res.success = false;
|
|
33
|
+
res.data = null;
|
|
34
|
+
res.message = message;
|
|
35
|
+
res.code = errorCode;
|
|
36
|
+
res.debugInfo = debugInfo;
|
|
37
|
+
return res;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.CommonResult = CommonResult;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Aes128CBC } from 'aes-128-cbc';
|
|
2
|
-
declare const privateAES: Aes128CBC;
|
|
3
|
-
export { privateAES };
|
|
1
|
+
import { Aes128CBC } from 'aes-128-cbc';
|
|
2
|
+
declare const privateAES: Aes128CBC;
|
|
3
|
+
export { privateAES };
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.privateAES = void 0;
|
|
4
|
-
const crypto = require("crypto");
|
|
5
|
-
const path = require("path");
|
|
6
|
-
const fs = require("fs");
|
|
7
|
-
const md5 = require("md5");
|
|
8
|
-
const aes_128_cbc_1 = require("aes-128-cbc");
|
|
9
|
-
function hashUtf8Hex(data) {
|
|
10
|
-
const hash = crypto.createHash('sha256');
|
|
11
|
-
const chunkSize = 1024; // 每次处理 1MB 数据
|
|
12
|
-
for (let i = 0; i < data.length; i += chunkSize) {
|
|
13
|
-
const chunk = data.slice(i, i + chunkSize);
|
|
14
|
-
const inputBuffer = Buffer.from(chunk, 'utf8');
|
|
15
|
-
hash.update(inputBuffer);
|
|
16
|
-
}
|
|
17
|
-
return hash.digest('hex');
|
|
18
|
-
}
|
|
19
|
-
function readSeed1() {
|
|
20
|
-
// 这个文件肯定存在
|
|
21
|
-
const t = path.join(__dirname, '../../config/seed/aeskey.txt');
|
|
22
|
-
return fs.readFileSync(t, 'utf-8');
|
|
23
|
-
}
|
|
24
|
-
function readSeed2() {
|
|
25
|
-
const filePath = path.join(__dirname, '../../../config/seed/aeskey.txt');
|
|
26
|
-
if (!fs.existsSync(filePath)) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
return fs.readFileSync(filePath, 'utf-8');
|
|
30
|
-
}
|
|
31
|
-
function createAes128BySeedContent(seedContent) {
|
|
32
|
-
const hash1 = hashUtf8Hex(seedContent.trim());
|
|
33
|
-
const key = md5(hash1);
|
|
34
|
-
const iv = md5(key + hash1);
|
|
35
|
-
return new aes_128_cbc_1.Aes128CBC(key, iv);
|
|
36
|
-
}
|
|
37
|
-
function createAes128BySeedFile() {
|
|
38
|
-
const seed2 = readSeed2();
|
|
39
|
-
if (seed2) {
|
|
40
|
-
return createAes128BySeedContent(seed2);
|
|
41
|
-
}
|
|
42
|
-
const seed1 = readSeed1();
|
|
43
|
-
return createAes128BySeedContent(seed1);
|
|
44
|
-
}
|
|
45
|
-
const privateAES = createAes128BySeedFile();
|
|
46
|
-
exports.privateAES = privateAES;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.privateAES = void 0;
|
|
4
|
+
const crypto = require("crypto");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const md5 = require("md5");
|
|
8
|
+
const aes_128_cbc_1 = require("aes-128-cbc");
|
|
9
|
+
function hashUtf8Hex(data) {
|
|
10
|
+
const hash = crypto.createHash('sha256');
|
|
11
|
+
const chunkSize = 1024; // 每次处理 1MB 数据
|
|
12
|
+
for (let i = 0; i < data.length; i += chunkSize) {
|
|
13
|
+
const chunk = data.slice(i, i + chunkSize);
|
|
14
|
+
const inputBuffer = Buffer.from(chunk, 'utf8');
|
|
15
|
+
hash.update(inputBuffer);
|
|
16
|
+
}
|
|
17
|
+
return hash.digest('hex');
|
|
18
|
+
}
|
|
19
|
+
function readSeed1() {
|
|
20
|
+
// 这个文件肯定存在
|
|
21
|
+
const t = path.join(__dirname, '../../config/seed/aeskey.txt');
|
|
22
|
+
return fs.readFileSync(t, 'utf-8');
|
|
23
|
+
}
|
|
24
|
+
function readSeed2() {
|
|
25
|
+
const filePath = path.join(__dirname, '../../../config/seed/aeskey.txt');
|
|
26
|
+
if (!fs.existsSync(filePath)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return fs.readFileSync(filePath, 'utf-8');
|
|
30
|
+
}
|
|
31
|
+
function createAes128BySeedContent(seedContent) {
|
|
32
|
+
const hash1 = hashUtf8Hex(seedContent.trim());
|
|
33
|
+
const key = md5(hash1);
|
|
34
|
+
const iv = md5(key + hash1);
|
|
35
|
+
return new aes_128_cbc_1.Aes128CBC(key, iv);
|
|
36
|
+
}
|
|
37
|
+
function createAes128BySeedFile() {
|
|
38
|
+
const seed2 = readSeed2();
|
|
39
|
+
if (seed2) {
|
|
40
|
+
return createAes128BySeedContent(seed2);
|
|
41
|
+
}
|
|
42
|
+
const seed1 = readSeed1();
|
|
43
|
+
return createAes128BySeedContent(seed1);
|
|
44
|
+
}
|
|
45
|
+
const privateAES = createAes128BySeedFile();
|
|
46
|
+
exports.privateAES = privateAES;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function errorToString(error: any): string;
|
|
2
|
-
export { errorToString };
|
|
1
|
+
declare function errorToString(error: any): string;
|
|
2
|
+
export { errorToString };
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.errorToString = void 0;
|
|
4
|
-
function errorToString(error) {
|
|
5
|
-
var _a;
|
|
6
|
-
// 处理非错误对象的情况
|
|
7
|
-
if (typeof error === 'undefined') {
|
|
8
|
-
return 'Error: undefined was thrown';
|
|
9
|
-
}
|
|
10
|
-
if (error === null) {
|
|
11
|
-
return 'Error: null was thrown';
|
|
12
|
-
}
|
|
13
|
-
// 处理原始值类型
|
|
14
|
-
const primitiveTypes = ['string', 'number', 'boolean', 'symbol'];
|
|
15
|
-
if (primitiveTypes.includes(typeof error)) {
|
|
16
|
-
return `Error: A primitive value was thrown\nValue: ${String(error)}`;
|
|
17
|
-
}
|
|
18
|
-
// 处理 Error 对象
|
|
19
|
-
if (error instanceof Error) {
|
|
20
|
-
const errorDetails = [];
|
|
21
|
-
errorDetails.push(`Error: ${error.name || 'Error'}`);
|
|
22
|
-
errorDetails.push(`Message: ${error.message || 'No error message'}`);
|
|
23
|
-
if (error.stack) {
|
|
24
|
-
errorDetails.push('Stack Trace:');
|
|
25
|
-
errorDetails.push(error.stack);
|
|
26
|
-
}
|
|
27
|
-
const extraProperties = ['code', 'fileName', 'lineNumber', 'columnNumber'];
|
|
28
|
-
extraProperties.forEach(prop => {
|
|
29
|
-
if (error[prop] !== undefined) {
|
|
30
|
-
errorDetails.push(`${prop}: ${error[prop]}`);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
const customProps = Object.keys(error).filter(key => !['name', 'message', 'stack', ...extraProperties].includes(key));
|
|
34
|
-
if (customProps.length > 0) {
|
|
35
|
-
errorDetails.push('Custom Properties:');
|
|
36
|
-
customProps.forEach(prop => {
|
|
37
|
-
try {
|
|
38
|
-
const value = JSON.stringify(error[prop], null, 2) || String(error[prop]);
|
|
39
|
-
errorDetails.push(` ${prop}: ${value}`);
|
|
40
|
-
}
|
|
41
|
-
catch (e) {
|
|
42
|
-
errorDetails.push(` ${prop}: [Object cannot be serialized]`);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
return errorDetails.join('\n');
|
|
47
|
-
}
|
|
48
|
-
// 处理普通对象
|
|
49
|
-
try {
|
|
50
|
-
const objectDetails = JSON.stringify(error, null, 2);
|
|
51
|
-
return `Error: A plain object was thrown\nObject: ${objectDetails}`;
|
|
52
|
-
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
return `Error: An object was thrown but could not be serialized\nType: ${((_a = error.constructor) === null || _a === void 0 ? void 0 : _a.name) || 'Unknown'}`;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.errorToString = errorToString;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.errorToString = void 0;
|
|
4
|
+
function errorToString(error) {
|
|
5
|
+
var _a;
|
|
6
|
+
// 处理非错误对象的情况
|
|
7
|
+
if (typeof error === 'undefined') {
|
|
8
|
+
return 'Error: undefined was thrown';
|
|
9
|
+
}
|
|
10
|
+
if (error === null) {
|
|
11
|
+
return 'Error: null was thrown';
|
|
12
|
+
}
|
|
13
|
+
// 处理原始值类型
|
|
14
|
+
const primitiveTypes = ['string', 'number', 'boolean', 'symbol'];
|
|
15
|
+
if (primitiveTypes.includes(typeof error)) {
|
|
16
|
+
return `Error: A primitive value was thrown\nValue: ${String(error)}`;
|
|
17
|
+
}
|
|
18
|
+
// 处理 Error 对象
|
|
19
|
+
if (error instanceof Error) {
|
|
20
|
+
const errorDetails = [];
|
|
21
|
+
errorDetails.push(`Error: ${error.name || 'Error'}`);
|
|
22
|
+
errorDetails.push(`Message: ${error.message || 'No error message'}`);
|
|
23
|
+
if (error.stack) {
|
|
24
|
+
errorDetails.push('Stack Trace:');
|
|
25
|
+
errorDetails.push(error.stack);
|
|
26
|
+
}
|
|
27
|
+
const extraProperties = ['code', 'fileName', 'lineNumber', 'columnNumber'];
|
|
28
|
+
extraProperties.forEach(prop => {
|
|
29
|
+
if (error[prop] !== undefined) {
|
|
30
|
+
errorDetails.push(`${prop}: ${error[prop]}`);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const customProps = Object.keys(error).filter(key => !['name', 'message', 'stack', ...extraProperties].includes(key));
|
|
34
|
+
if (customProps.length > 0) {
|
|
35
|
+
errorDetails.push('Custom Properties:');
|
|
36
|
+
customProps.forEach(prop => {
|
|
37
|
+
try {
|
|
38
|
+
const value = JSON.stringify(error[prop], null, 2) || String(error[prop]);
|
|
39
|
+
errorDetails.push(` ${prop}: ${value}`);
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
errorDetails.push(` ${prop}: [Object cannot be serialized]`);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return errorDetails.join('\n');
|
|
47
|
+
}
|
|
48
|
+
// 处理普通对象
|
|
49
|
+
try {
|
|
50
|
+
const objectDetails = JSON.stringify(error, null, 2);
|
|
51
|
+
return `Error: A plain object was thrown\nObject: ${objectDetails}`;
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
return `Error: An object was thrown but could not be serialized\nType: ${((_a = error.constructor) === null || _a === void 0 ? void 0 : _a.name) || 'Unknown'}`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.errorToString = errorToString;
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { Context } from '@midwayjs/koa';
|
|
2
|
-
/**
|
|
3
|
-
* 是否开启调试能力
|
|
4
|
-
* @param ctx
|
|
5
|
-
*/
|
|
6
|
-
export declare function isEnableDebug(ctx: Context): boolean;
|
|
7
|
-
/**
|
|
8
|
-
* 是否开启SA账号。只有账号密码没有用,必须通过ModHeader插件设置如下字段
|
|
9
|
-
* @param ctx
|
|
10
|
-
*/
|
|
11
|
-
export declare function isEnableSuperAdmin(ctx: Context): boolean;
|
|
12
|
-
export declare function isLocalEnv(ctx: Context): boolean;
|
|
13
|
-
/**
|
|
14
|
-
* 获取调试时专用的站点code
|
|
15
|
-
* @param ctx
|
|
16
|
-
*/
|
|
17
|
-
export declare function getDebugWorkbenchCode(ctx: Context): any;
|
|
18
|
-
/**
|
|
19
|
-
* 代理转发服务专用
|
|
20
|
-
* @param ctx
|
|
21
|
-
*/
|
|
22
|
-
export declare function getDebugProxyTarget(ctx: Context): string;
|
|
23
|
-
export declare function getCsrfToken(ctx: Context): string;
|
|
24
|
-
/**
|
|
25
|
-
* 扩展的源码应用:本地开发调试时加载本地的js脚本
|
|
26
|
-
* @param ctx
|
|
27
|
-
*/
|
|
28
|
-
export declare function getExtLocalLoaderPort(ctx: Context): string;
|
|
29
|
-
export declare function isCsrfTokenValid(ctx: Context): Promise<boolean>;
|
|
30
|
-
export declare function assertCsrfToken(ctx: Context): Promise<void>;
|
|
1
|
+
import { Context } from '@midwayjs/koa';
|
|
2
|
+
/**
|
|
3
|
+
* 是否开启调试能力
|
|
4
|
+
* @param ctx
|
|
5
|
+
*/
|
|
6
|
+
export declare function isEnableDebug(ctx: Context): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* 是否开启SA账号。只有账号密码没有用,必须通过ModHeader插件设置如下字段
|
|
9
|
+
* @param ctx
|
|
10
|
+
*/
|
|
11
|
+
export declare function isEnableSuperAdmin(ctx: Context): boolean;
|
|
12
|
+
export declare function isLocalEnv(ctx: Context): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* 获取调试时专用的站点code
|
|
15
|
+
* @param ctx
|
|
16
|
+
*/
|
|
17
|
+
export declare function getDebugWorkbenchCode(ctx: Context): any;
|
|
18
|
+
/**
|
|
19
|
+
* 代理转发服务专用
|
|
20
|
+
* @param ctx
|
|
21
|
+
*/
|
|
22
|
+
export declare function getDebugProxyTarget(ctx: Context): string;
|
|
23
|
+
export declare function getCsrfToken(ctx: Context): string;
|
|
24
|
+
/**
|
|
25
|
+
* 扩展的源码应用:本地开发调试时加载本地的js脚本
|
|
26
|
+
* @param ctx
|
|
27
|
+
*/
|
|
28
|
+
export declare function getExtLocalLoaderPort(ctx: Context): string;
|
|
29
|
+
export declare function isCsrfTokenValid(ctx: Context): Promise<boolean>;
|
|
30
|
+
export declare function assertCsrfToken(ctx: Context): Promise<void>;
|
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertCsrfToken = exports.isCsrfTokenValid = exports.getExtLocalLoaderPort = exports.getCsrfToken = exports.getDebugProxyTarget = exports.getDebugWorkbenchCode = exports.isLocalEnv = exports.isEnableSuperAdmin = exports.isEnableDebug = void 0;
|
|
4
|
-
const _ = require("lodash");
|
|
5
|
-
const crypto_utils_1 = require("./crypto-utils");
|
|
6
|
-
const exceptions_1 = require("../crud-pro/exceptions");
|
|
7
|
-
function isEnableByHeaderKey(ctx, configName) {
|
|
8
|
-
const fatcmsDebug = ctx.app.getConfig(configName);
|
|
9
|
-
const headerKey = _.get(fatcmsDebug, 'headerKey');
|
|
10
|
-
const headerSecret = _.get(fatcmsDebug, 'headerSecret');
|
|
11
|
-
if (!headerSecret || !headerKey) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
const headers = _.get(ctx, 'request.headers') || {};
|
|
15
|
-
return headers[headerKey] === headerSecret;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* 是否开启调试能力
|
|
19
|
-
* @param ctx
|
|
20
|
-
*/
|
|
21
|
-
function isEnableDebug(ctx) {
|
|
22
|
-
return isEnableByHeaderKey(ctx, 'fatcmsDebug');
|
|
23
|
-
}
|
|
24
|
-
exports.isEnableDebug = isEnableDebug;
|
|
25
|
-
/**
|
|
26
|
-
* 是否开启SA账号。只有账号密码没有用,必须通过ModHeader插件设置如下字段
|
|
27
|
-
* @param ctx
|
|
28
|
-
*/
|
|
29
|
-
function isEnableSuperAdmin(ctx) {
|
|
30
|
-
return isEnableByHeaderKey(ctx, 'fatcmsSAEnable');
|
|
31
|
-
}
|
|
32
|
-
exports.isEnableSuperAdmin = isEnableSuperAdmin;
|
|
33
|
-
function isLocalEnv(ctx) {
|
|
34
|
-
// 系统内部调用。如定时任务,没有request对象。
|
|
35
|
-
if (!ctx.request) {
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
const host = ctx.request.host;
|
|
39
|
-
return host.startsWith('127.0.0.1') || host.startsWith('localhost:');
|
|
40
|
-
}
|
|
41
|
-
exports.isLocalEnv = isLocalEnv;
|
|
42
|
-
/**
|
|
43
|
-
* 获取调试时专用的站点code
|
|
44
|
-
* @param ctx
|
|
45
|
-
*/
|
|
46
|
-
function getDebugWorkbenchCode(ctx) {
|
|
47
|
-
const headers = _.get(ctx, 'request.headers') || {};
|
|
48
|
-
return headers['fatcmsworkbench'];
|
|
49
|
-
}
|
|
50
|
-
exports.getDebugWorkbenchCode = getDebugWorkbenchCode;
|
|
51
|
-
/**
|
|
52
|
-
* 代理转发服务专用
|
|
53
|
-
* @param ctx
|
|
54
|
-
*/
|
|
55
|
-
function getDebugProxyTarget(ctx) {
|
|
56
|
-
const headers = _.get(ctx, 'request.headers') || {};
|
|
57
|
-
return headers['fatcmsdebugproxytarget'];
|
|
58
|
-
}
|
|
59
|
-
exports.getDebugProxyTarget = getDebugProxyTarget;
|
|
60
|
-
function getCsrfToken(ctx) {
|
|
61
|
-
const headers = _.get(ctx, 'request.headers') || {};
|
|
62
|
-
return headers['fatcmscsrftoken'];
|
|
63
|
-
}
|
|
64
|
-
exports.getCsrfToken = getCsrfToken;
|
|
65
|
-
/**
|
|
66
|
-
* 扩展的源码应用:本地开发调试时加载本地的js脚本
|
|
67
|
-
* @param ctx
|
|
68
|
-
*/
|
|
69
|
-
function getExtLocalLoaderPort(ctx) {
|
|
70
|
-
const headers = _.get(ctx, 'request.headers') || {};
|
|
71
|
-
return headers['fatcmsextlocalloaderport'];
|
|
72
|
-
}
|
|
73
|
-
exports.getExtLocalLoaderPort = getExtLocalLoaderPort;
|
|
74
|
-
async function isCsrfTokenValid(ctx) {
|
|
75
|
-
// 本地开发,不需要校验
|
|
76
|
-
if (isLocalEnv(ctx) || isEnableDebug(ctx)) {
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
const fatcmscsrftoken = getCsrfToken(ctx);
|
|
80
|
-
if (!fatcmscsrftoken) {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
try {
|
|
84
|
-
const depryptToken = await crypto_utils_1.privateAES.time_decrypt_base64_utf8(fatcmscsrftoken);
|
|
85
|
-
if (depryptToken) {
|
|
86
|
-
const num = Number(depryptToken);
|
|
87
|
-
if (num && num + 6 * 3600 * 1000 > Date.now()) {
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
catch (e) {
|
|
93
|
-
console.info('isCsrfTokenValid验证失败');
|
|
94
|
-
}
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
exports.isCsrfTokenValid = isCsrfTokenValid;
|
|
98
|
-
async function assertCsrfToken(ctx) {
|
|
99
|
-
const isOK = await isCsrfTokenValid(ctx);
|
|
100
|
-
if (!isOK) {
|
|
101
|
-
throw new exceptions_1.CommonException('ASSERT_CSRF_TOKEN_ERROR', 'CSRF_TOKEN 验证失败');
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
exports.assertCsrfToken = assertCsrfToken;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertCsrfToken = exports.isCsrfTokenValid = exports.getExtLocalLoaderPort = exports.getCsrfToken = exports.getDebugProxyTarget = exports.getDebugWorkbenchCode = exports.isLocalEnv = exports.isEnableSuperAdmin = exports.isEnableDebug = void 0;
|
|
4
|
+
const _ = require("lodash");
|
|
5
|
+
const crypto_utils_1 = require("./crypto-utils");
|
|
6
|
+
const exceptions_1 = require("../crud-pro/exceptions");
|
|
7
|
+
function isEnableByHeaderKey(ctx, configName) {
|
|
8
|
+
const fatcmsDebug = ctx.app.getConfig(configName);
|
|
9
|
+
const headerKey = _.get(fatcmsDebug, 'headerKey');
|
|
10
|
+
const headerSecret = _.get(fatcmsDebug, 'headerSecret');
|
|
11
|
+
if (!headerSecret || !headerKey) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const headers = _.get(ctx, 'request.headers') || {};
|
|
15
|
+
return headers[headerKey] === headerSecret;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 是否开启调试能力
|
|
19
|
+
* @param ctx
|
|
20
|
+
*/
|
|
21
|
+
function isEnableDebug(ctx) {
|
|
22
|
+
return isEnableByHeaderKey(ctx, 'fatcmsDebug');
|
|
23
|
+
}
|
|
24
|
+
exports.isEnableDebug = isEnableDebug;
|
|
25
|
+
/**
|
|
26
|
+
* 是否开启SA账号。只有账号密码没有用,必须通过ModHeader插件设置如下字段
|
|
27
|
+
* @param ctx
|
|
28
|
+
*/
|
|
29
|
+
function isEnableSuperAdmin(ctx) {
|
|
30
|
+
return isEnableByHeaderKey(ctx, 'fatcmsSAEnable');
|
|
31
|
+
}
|
|
32
|
+
exports.isEnableSuperAdmin = isEnableSuperAdmin;
|
|
33
|
+
function isLocalEnv(ctx) {
|
|
34
|
+
// 系统内部调用。如定时任务,没有request对象。
|
|
35
|
+
if (!ctx.request) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
const host = ctx.request.host;
|
|
39
|
+
return host.startsWith('127.0.0.1') || host.startsWith('localhost:');
|
|
40
|
+
}
|
|
41
|
+
exports.isLocalEnv = isLocalEnv;
|
|
42
|
+
/**
|
|
43
|
+
* 获取调试时专用的站点code
|
|
44
|
+
* @param ctx
|
|
45
|
+
*/
|
|
46
|
+
function getDebugWorkbenchCode(ctx) {
|
|
47
|
+
const headers = _.get(ctx, 'request.headers') || {};
|
|
48
|
+
return headers['fatcmsworkbench'];
|
|
49
|
+
}
|
|
50
|
+
exports.getDebugWorkbenchCode = getDebugWorkbenchCode;
|
|
51
|
+
/**
|
|
52
|
+
* 代理转发服务专用
|
|
53
|
+
* @param ctx
|
|
54
|
+
*/
|
|
55
|
+
function getDebugProxyTarget(ctx) {
|
|
56
|
+
const headers = _.get(ctx, 'request.headers') || {};
|
|
57
|
+
return headers['fatcmsdebugproxytarget'];
|
|
58
|
+
}
|
|
59
|
+
exports.getDebugProxyTarget = getDebugProxyTarget;
|
|
60
|
+
function getCsrfToken(ctx) {
|
|
61
|
+
const headers = _.get(ctx, 'request.headers') || {};
|
|
62
|
+
return headers['fatcmscsrftoken'];
|
|
63
|
+
}
|
|
64
|
+
exports.getCsrfToken = getCsrfToken;
|
|
65
|
+
/**
|
|
66
|
+
* 扩展的源码应用:本地开发调试时加载本地的js脚本
|
|
67
|
+
* @param ctx
|
|
68
|
+
*/
|
|
69
|
+
function getExtLocalLoaderPort(ctx) {
|
|
70
|
+
const headers = _.get(ctx, 'request.headers') || {};
|
|
71
|
+
return headers['fatcmsextlocalloaderport'];
|
|
72
|
+
}
|
|
73
|
+
exports.getExtLocalLoaderPort = getExtLocalLoaderPort;
|
|
74
|
+
async function isCsrfTokenValid(ctx) {
|
|
75
|
+
// 本地开发,不需要校验
|
|
76
|
+
if (isLocalEnv(ctx) || isEnableDebug(ctx)) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
const fatcmscsrftoken = getCsrfToken(ctx);
|
|
80
|
+
if (!fatcmscsrftoken) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const depryptToken = await crypto_utils_1.privateAES.time_decrypt_base64_utf8(fatcmscsrftoken);
|
|
85
|
+
if (depryptToken) {
|
|
86
|
+
const num = Number(depryptToken);
|
|
87
|
+
if (num && num + 6 * 3600 * 1000 > Date.now()) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
console.info('isCsrfTokenValid验证失败');
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
exports.isCsrfTokenValid = isCsrfTokenValid;
|
|
98
|
+
async function assertCsrfToken(ctx) {
|
|
99
|
+
const isOK = await isCsrfTokenValid(ctx);
|
|
100
|
+
if (!isOK) {
|
|
101
|
+
throw new exceptions_1.CommonException('ASSERT_CSRF_TOKEN_ERROR', 'CSRF_TOKEN 验证失败');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.assertCsrfToken = assertCsrfToken;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
declare function createUniqueId(): string;
|
|
2
|
-
declare function parseJsonObject(str: any): any;
|
|
3
|
-
declare function parseStringTrimArray(obj: any, separator?: string): string[];
|
|
4
|
-
declare function getCurrentFullMoment(): string;
|
|
5
|
-
export { createUniqueId, parseJsonObject, parseStringTrimArray, getCurrentFullMoment };
|
|
1
|
+
declare function createUniqueId(): string;
|
|
2
|
+
declare function parseJsonObject(str: any): any;
|
|
3
|
+
declare function parseStringTrimArray(obj: any, separator?: string): string[];
|
|
4
|
+
declare function getCurrentFullMoment(): string;
|
|
5
|
+
export { createUniqueId, parseJsonObject, parseStringTrimArray, getCurrentFullMoment };
|