@lark-apaas/fullstack-nestjs-core 1.1.12-alpha.1 → 1.1.12-alpha.11
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/dist/index.cjs +81 -30
- package/dist/index.js +81 -30
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -170,6 +170,51 @@ CsrfMiddleware = _ts_decorate2([
|
|
|
170
170
|
// src/middlewares/view-context/index.ts
|
|
171
171
|
var import_common3 = require("@nestjs/common");
|
|
172
172
|
var import_nestjs_common = require("@lark-apaas/nestjs-common");
|
|
173
|
+
|
|
174
|
+
// src/utils/safe-stringify.ts
|
|
175
|
+
function safeEscape(s) {
|
|
176
|
+
return s.replace(/[<>&='"\n\r\u2028\u2029]/g, function(c) {
|
|
177
|
+
switch (c.charCodeAt(0)) {
|
|
178
|
+
case 60:
|
|
179
|
+
return "\\u003c";
|
|
180
|
+
// <
|
|
181
|
+
case 62:
|
|
182
|
+
return "\\u003e";
|
|
183
|
+
// >
|
|
184
|
+
case 38:
|
|
185
|
+
return "\\u0026";
|
|
186
|
+
// &
|
|
187
|
+
case 61:
|
|
188
|
+
return "\\u003d";
|
|
189
|
+
// =
|
|
190
|
+
case 39:
|
|
191
|
+
return "\\u0027";
|
|
192
|
+
// '
|
|
193
|
+
case 34:
|
|
194
|
+
return "\\u0022";
|
|
195
|
+
// "
|
|
196
|
+
case 10:
|
|
197
|
+
return "\\u000a";
|
|
198
|
+
// \n
|
|
199
|
+
case 13:
|
|
200
|
+
return "\\u000d";
|
|
201
|
+
// \r
|
|
202
|
+
// 正常来说用户无法输入这几个字符, 现代浏览器也修复了这个问题
|
|
203
|
+
// https://zhuanlan.zhihu.com/p/29958439
|
|
204
|
+
case 8232:
|
|
205
|
+
return "\\u2028";
|
|
206
|
+
// 行分隔符
|
|
207
|
+
case 8233:
|
|
208
|
+
return "\\u2029";
|
|
209
|
+
// 段落分隔符
|
|
210
|
+
default:
|
|
211
|
+
return c;
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
__name(safeEscape, "safeEscape");
|
|
216
|
+
|
|
217
|
+
// src/middlewares/view-context/index.ts
|
|
173
218
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
174
219
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
175
220
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -225,9 +270,9 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
225
270
|
csrfToken: csrfToken ?? "",
|
|
226
271
|
userId: userId ?? "",
|
|
227
272
|
appId: appId ?? "",
|
|
228
|
-
appName: appInfo?.app_name ?? "",
|
|
273
|
+
appName: safeEscape(appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528"),
|
|
229
274
|
appAvatar: appInfo?.app_avatar ?? "",
|
|
230
|
-
appDescription: appInfo?.app_description ?? "",
|
|
275
|
+
appDescription: safeEscape(appInfo?.app_description ?? ""),
|
|
231
276
|
tenantId
|
|
232
277
|
};
|
|
233
278
|
res.locals = {
|
|
@@ -236,9 +281,9 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
236
281
|
userId: userId ?? "",
|
|
237
282
|
tenantId: tenantId ?? "",
|
|
238
283
|
appId: appId ?? "",
|
|
239
|
-
appName: appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528",
|
|
284
|
+
appName: safeEscape(appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528"),
|
|
240
285
|
appAvatar: appInfo?.app_avatar ?? "",
|
|
241
|
-
appDescription: appInfo?.app_description ?? ""
|
|
286
|
+
appDescription: safeEscape(appInfo?.app_description ?? "")
|
|
242
287
|
};
|
|
243
288
|
next();
|
|
244
289
|
}
|
|
@@ -716,6 +761,9 @@ PlatformHttpClientService = _ts_decorate8([
|
|
|
716
761
|
_ts_metadata5("design:paramtypes", [])
|
|
717
762
|
], PlatformHttpClientService);
|
|
718
763
|
|
|
764
|
+
// src/modules/platform/config/feature-switch.ts
|
|
765
|
+
var DISABLE_DATAPASS = process.env.FORCE_FRAMEWORK_DISABLE_DATAPASS === "true";
|
|
766
|
+
|
|
719
767
|
// src/modules/platform/module.ts
|
|
720
768
|
function _ts_decorate9(decorators, target, key, desc) {
|
|
721
769
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -752,32 +800,35 @@ var PlatformModule = class _PlatformModule {
|
|
|
752
800
|
timeout: 5e3,
|
|
753
801
|
maxRedirects: 5
|
|
754
802
|
}),
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
803
|
+
// 读取环境变量判断是否启用 DataPaasModule
|
|
804
|
+
...DISABLE_DATAPASS ? [] : [
|
|
805
|
+
import_nestjs_datapaas.DataPaasModule.forRootAsync({
|
|
806
|
+
imports: [
|
|
807
|
+
import_config2.ConfigModule,
|
|
808
|
+
import_nestjs_logger2.LoggerModule
|
|
809
|
+
],
|
|
810
|
+
inject: [
|
|
811
|
+
import_config2.ConfigService,
|
|
812
|
+
import_nestjs_logger2.AppLogger
|
|
813
|
+
],
|
|
814
|
+
useFactory: /* @__PURE__ */ __name(async (...args) => {
|
|
815
|
+
const configService = args[0];
|
|
816
|
+
const appLogger = args[1];
|
|
817
|
+
const drizzleLogger = {
|
|
818
|
+
logQuery(query, params) {
|
|
819
|
+
appLogger.log?.("SQL Query " + JSON.stringify({
|
|
820
|
+
query,
|
|
821
|
+
params
|
|
822
|
+
}), "Database");
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
return {
|
|
826
|
+
connectionString: configService.get("app.databaseUrl") ?? "",
|
|
827
|
+
logger: drizzleLogger
|
|
828
|
+
};
|
|
829
|
+
}, "useFactory")
|
|
830
|
+
})
|
|
831
|
+
],
|
|
781
832
|
import_nestjs_authnpaas.AuthNPaasModule.forRoot(),
|
|
782
833
|
import_nestjs_trigger.AutomationModule.forRoot()
|
|
783
834
|
],
|
package/dist/index.js
CHANGED
|
@@ -128,6 +128,51 @@ CsrfMiddleware = _ts_decorate2([
|
|
|
128
128
|
// src/middlewares/view-context/index.ts
|
|
129
129
|
import { Inject, Injectable as Injectable3, Logger } from "@nestjs/common";
|
|
130
130
|
import { PLATFORM_HTTP_CLIENT } from "@lark-apaas/nestjs-common";
|
|
131
|
+
|
|
132
|
+
// src/utils/safe-stringify.ts
|
|
133
|
+
function safeEscape(s) {
|
|
134
|
+
return s.replace(/[<>&='"\n\r\u2028\u2029]/g, function(c) {
|
|
135
|
+
switch (c.charCodeAt(0)) {
|
|
136
|
+
case 60:
|
|
137
|
+
return "\\u003c";
|
|
138
|
+
// <
|
|
139
|
+
case 62:
|
|
140
|
+
return "\\u003e";
|
|
141
|
+
// >
|
|
142
|
+
case 38:
|
|
143
|
+
return "\\u0026";
|
|
144
|
+
// &
|
|
145
|
+
case 61:
|
|
146
|
+
return "\\u003d";
|
|
147
|
+
// =
|
|
148
|
+
case 39:
|
|
149
|
+
return "\\u0027";
|
|
150
|
+
// '
|
|
151
|
+
case 34:
|
|
152
|
+
return "\\u0022";
|
|
153
|
+
// "
|
|
154
|
+
case 10:
|
|
155
|
+
return "\\u000a";
|
|
156
|
+
// \n
|
|
157
|
+
case 13:
|
|
158
|
+
return "\\u000d";
|
|
159
|
+
// \r
|
|
160
|
+
// 正常来说用户无法输入这几个字符, 现代浏览器也修复了这个问题
|
|
161
|
+
// https://zhuanlan.zhihu.com/p/29958439
|
|
162
|
+
case 8232:
|
|
163
|
+
return "\\u2028";
|
|
164
|
+
// 行分隔符
|
|
165
|
+
case 8233:
|
|
166
|
+
return "\\u2029";
|
|
167
|
+
// 段落分隔符
|
|
168
|
+
default:
|
|
169
|
+
return c;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
__name(safeEscape, "safeEscape");
|
|
174
|
+
|
|
175
|
+
// src/middlewares/view-context/index.ts
|
|
131
176
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
132
177
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
133
178
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -183,9 +228,9 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
183
228
|
csrfToken: csrfToken ?? "",
|
|
184
229
|
userId: userId ?? "",
|
|
185
230
|
appId: appId ?? "",
|
|
186
|
-
appName: appInfo?.app_name ?? "",
|
|
231
|
+
appName: safeEscape(appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528"),
|
|
187
232
|
appAvatar: appInfo?.app_avatar ?? "",
|
|
188
|
-
appDescription: appInfo?.app_description ?? "",
|
|
233
|
+
appDescription: safeEscape(appInfo?.app_description ?? ""),
|
|
189
234
|
tenantId
|
|
190
235
|
};
|
|
191
236
|
res.locals = {
|
|
@@ -194,9 +239,9 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
194
239
|
userId: userId ?? "",
|
|
195
240
|
tenantId: tenantId ?? "",
|
|
196
241
|
appId: appId ?? "",
|
|
197
|
-
appName: appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528",
|
|
242
|
+
appName: safeEscape(appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528"),
|
|
198
243
|
appAvatar: appInfo?.app_avatar ?? "",
|
|
199
|
-
appDescription: appInfo?.app_description ?? ""
|
|
244
|
+
appDescription: safeEscape(appInfo?.app_description ?? "")
|
|
200
245
|
};
|
|
201
246
|
next();
|
|
202
247
|
}
|
|
@@ -674,6 +719,9 @@ PlatformHttpClientService = _ts_decorate8([
|
|
|
674
719
|
_ts_metadata5("design:paramtypes", [])
|
|
675
720
|
], PlatformHttpClientService);
|
|
676
721
|
|
|
722
|
+
// src/modules/platform/config/feature-switch.ts
|
|
723
|
+
var DISABLE_DATAPASS = process.env.FORCE_FRAMEWORK_DISABLE_DATAPASS === "true";
|
|
724
|
+
|
|
677
725
|
// src/modules/platform/module.ts
|
|
678
726
|
function _ts_decorate9(decorators, target, key, desc) {
|
|
679
727
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -710,32 +758,35 @@ var PlatformModule = class _PlatformModule {
|
|
|
710
758
|
timeout: 5e3,
|
|
711
759
|
maxRedirects: 5
|
|
712
760
|
}),
|
|
713
|
-
DataPaasModule
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
761
|
+
// 读取环境变量判断是否启用 DataPaasModule
|
|
762
|
+
...DISABLE_DATAPASS ? [] : [
|
|
763
|
+
DataPaasModule.forRootAsync({
|
|
764
|
+
imports: [
|
|
765
|
+
ConfigModule,
|
|
766
|
+
LoggerModule
|
|
767
|
+
],
|
|
768
|
+
inject: [
|
|
769
|
+
ConfigService,
|
|
770
|
+
AppLogger2
|
|
771
|
+
],
|
|
772
|
+
useFactory: /* @__PURE__ */ __name(async (...args) => {
|
|
773
|
+
const configService = args[0];
|
|
774
|
+
const appLogger = args[1];
|
|
775
|
+
const drizzleLogger = {
|
|
776
|
+
logQuery(query, params) {
|
|
777
|
+
appLogger.log?.("SQL Query " + JSON.stringify({
|
|
778
|
+
query,
|
|
779
|
+
params
|
|
780
|
+
}), "Database");
|
|
781
|
+
}
|
|
782
|
+
};
|
|
783
|
+
return {
|
|
784
|
+
connectionString: configService.get("app.databaseUrl") ?? "",
|
|
785
|
+
logger: drizzleLogger
|
|
786
|
+
};
|
|
787
|
+
}, "useFactory")
|
|
788
|
+
})
|
|
789
|
+
],
|
|
739
790
|
AuthNPaasModule.forRoot(),
|
|
740
791
|
AutomationModule.forRoot()
|
|
741
792
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/fullstack-nestjs-core",
|
|
3
|
-
"version": "1.1.12-alpha.
|
|
3
|
+
"version": "1.1.12-alpha.11",
|
|
4
4
|
"description": "FullStack Nestjs Core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@lark-apaas/http-client": "0.1.2",
|
|
43
43
|
"@lark-apaas/nestjs-authnpaas": "^1.0.2",
|
|
44
44
|
"@lark-apaas/nestjs-common": "^0.1.0",
|
|
45
|
-
"@lark-apaas/nestjs-datapaas": "^1.0.
|
|
45
|
+
"@lark-apaas/nestjs-datapaas": "^1.0.7",
|
|
46
46
|
"@lark-apaas/nestjs-logger": "^1.0.4",
|
|
47
47
|
"@lark-apaas/nestjs-observable": "^0.0.1",
|
|
48
48
|
"@lark-apaas/nestjs-openapi-devtools": "^1.0.9",
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"@nestjs/swagger": "^7.4.2",
|
|
58
58
|
"@types/cookie-parser": "^1.4.9",
|
|
59
59
|
"@types/express": "^5.0.3",
|
|
60
|
+
"@types/serialize-javascript": "^5.0.4",
|
|
60
61
|
"class-transformer": "^0.5.1",
|
|
61
62
|
"class-validator": "^0.14.2",
|
|
62
63
|
"drizzle-orm": "0.44.6",
|