@lingxiteam/ebe-utils 0.0.33 → 0.0.37
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/es/index.d.ts +5 -1
- package/es/index.js +107 -62
- package/lib/public/src/services/api/engine.ts +0 -2
- package/lib/public/src/utils/Security/clientCapabilities.ts +8 -0
- package/lib/public/src/utils/Security/config.ts +56 -49
- package/lib/public/src/utils/Security/const.ts +38 -127
- package/lib/public/src/utils/Security/debug/data.ts +86 -0
- package/lib/public/src/utils/Security/debug/index.ts +21 -0
- package/lib/public/src/utils/Security/encipher/sign.ts +25 -56
- package/lib/public/src/utils/Security/html.ts +52 -0
- package/lib/public/src/utils/Security/httpEncryption.ts +42 -23
- package/lib/public/src/utils/Security/index.ts +15 -7
- package/lib/public/src/utils/Security/requester/fetch.ts +87 -52
- package/lib/public/src/utils/Security/requester/wx.ts +60 -11
- package/lib/public/src/utils/Security/requester/xhr.ts +194 -40
- package/lib/public/src/utils/Security/types.ts +8 -90
- package/lib/public/src/utils/Security/urlEncryption.ts +108 -0
- package/lib/public/src/utils/Security/utils/atob.ts +34 -0
- package/lib/public/src/utils/Security/utils/caseInsensitive.ts +25 -0
- package/lib/public/src/utils/Security/utils/check.ts +27 -3
- package/lib/public/src/utils/Security/utils/cookie.ts +101 -53
- package/lib/public/src/utils/Security/utils/encrypted.ts +190 -43
- package/lib/public/src/utils/Security/utils/random.ts +21 -0
- package/lib/public/src/utils/Security/utils/storge.ts +22 -0
- package/lib/public/src/utils/Security/utils/url.ts +30 -5
- package/lib/public/src/utils/getSceneCode.ts +51 -0
- package/package.json +2 -2
package/es/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const removeObjectByRules: (data: any, rules: IRulesType, paths?:
|
|
|
7
7
|
export declare const treeForEach: (tree: any, callback: (item: any, root: boolean) => void, options?: {
|
|
8
8
|
children: string;
|
|
9
9
|
}) => void;
|
|
10
|
-
export declare const getPageDsls: (resultObjects: any[]) => any[];
|
|
10
|
+
export declare const getPageDsls: (resultObjects: any[], hasPageRulesPages: any[]) => any[];
|
|
11
11
|
export declare function findAllItem<T = any>(target: T[], callback: (item: T, index: number, list: T[]) => boolean, itemHash: any): void;
|
|
12
12
|
export declare function findItem<T = any>(target: T[], callback: (item: T, index: number, list: T[]) => boolean): T | null;
|
|
13
13
|
export declare const cleanTree: (tree: any, fields: any) => any;
|
|
@@ -39,6 +39,8 @@ interface CodeServices {
|
|
|
39
39
|
}) => Promise<any>;
|
|
40
40
|
queryAppFileResourcePage: (data: any) => Promise<any>;
|
|
41
41
|
downloadFileByFileCode: (data: any) => Promise<any>;
|
|
42
|
+
selectToolBoxPage: (data: any) => Promise<any>;
|
|
43
|
+
batchQryPageRulesByPageIds: (data: any) => Promise<any>;
|
|
42
44
|
}
|
|
43
45
|
export declare const getSafeTypeName: (name: any) => any;
|
|
44
46
|
interface CodeOptions {
|
|
@@ -85,6 +87,8 @@ export declare const fetchData: ({ appId, services, platform, baseUrl, onProgres
|
|
|
85
87
|
pageTypeMap: any;
|
|
86
88
|
appFileResource: any;
|
|
87
89
|
hasExtendsApp: boolean | undefined;
|
|
90
|
+
toolBox: any;
|
|
91
|
+
pageRules: unknown;
|
|
88
92
|
};
|
|
89
93
|
cleanedTree: any;
|
|
90
94
|
}>;
|
package/es/index.js
CHANGED
|
@@ -145,11 +145,14 @@ export var treeForEach = function treeForEach(tree, callback) {
|
|
|
145
145
|
var list = tree[options.children];
|
|
146
146
|
loop(list);
|
|
147
147
|
};
|
|
148
|
-
export var getPageDsls = function getPageDsls(resultObjects) {
|
|
148
|
+
export var getPageDsls = function getPageDsls(resultObjects, hasPageRulesPages) {
|
|
149
149
|
return resultObjects.filter(Boolean).map(function (i) {
|
|
150
150
|
try {
|
|
151
151
|
var pageData = JSON.parse(i.attrMappingJson);
|
|
152
152
|
pageData.pageId = i === null || i === void 0 ? void 0 : i.pageId;
|
|
153
|
+
if (checkHasPageRules(pageData)) {
|
|
154
|
+
hasPageRulesPages.push(i === null || i === void 0 ? void 0 : i.pageId);
|
|
155
|
+
}
|
|
153
156
|
return pageData;
|
|
154
157
|
} catch (error) {
|
|
155
158
|
console.error(error, '该页面信息出错', i);
|
|
@@ -248,10 +251,20 @@ export var init = /*#__PURE__*/function () {
|
|
|
248
251
|
var getIsIncrementalConstruction = function getIsIncrementalConstruction(ic) {
|
|
249
252
|
return !!ic && ((ic === null || ic === void 0 ? void 0 : ic.busiCompIds) && ic.busiCompIds.length > 0 || (ic === null || ic === void 0 ? void 0 : ic.pageIds) && ic.pageIds.length > 0 || (ic === null || ic === void 0 ? void 0 : ic.frontendHookChange) || (ic === null || ic === void 0 ? void 0 : ic.globalStoreChange));
|
|
250
253
|
};
|
|
254
|
+
var checkHasPageRules = function checkHasPageRules(pageDsl) {
|
|
255
|
+
if (!(pageDsl !== null && pageDsl !== void 0 && pageDsl.dataSource)) return false;
|
|
256
|
+
for (var key = 0; key <= pageDsl.dataSource.length; key++) {
|
|
257
|
+
var _pageDsl$dataSource$k;
|
|
258
|
+
if (((_pageDsl$dataSource$k = pageDsl.dataSource[key]) === null || _pageDsl$dataSource$k === void 0 ? void 0 : _pageDsl$dataSource$k.source) === 'object') {
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return false;
|
|
263
|
+
};
|
|
251
264
|
export var fetchData = /*#__PURE__*/function () {
|
|
252
265
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref4) {
|
|
253
266
|
var _ref6, _attrSpecPage;
|
|
254
|
-
var appId, services, platform, baseUrl, onProgress, needTranslatePagePathToEnglish, incrementalConstruction, hasAppFileResource, hasExtendsApp, isIncrementalConstruction, attrSpecPage, incrementalConstructionPageList, globalDataInfo, busiData, themeCss, frontendHookList, pageTypeMap, globalDataMap, appInfo, appPageList, temCompAssetList, compAssetList, _globalDataInfo, dataSourceList, pageIdMapping, lastPageId, data, needFindDataPages, requestQueue, requests, pages, _yield$services$qryBu, itemLists, BusiCompRequest, _incrementalConstruct, itemHash, _itemLists, alllBusiComp, busiPages, getTranslateName, chinese, translateNames, key, _translateNames, translateName, pagePathEnglishMapping, pagePathEnglishSet, getName, pagesChinese, pagesTranslateNames, findPageKeyByPageId, _key2, _appPageList$_key2$pa, _pagePathEnglishMappi, _pagesTranslateNames, safeTranslateName, pageKey, pageDSLS, getPlatform, appFileResource, _services$queryAppFil, _yield$services$query, list, appFileResourceList, options, cleanedTree;
|
|
267
|
+
var appId, services, platform, baseUrl, onProgress, needTranslatePagePathToEnglish, incrementalConstruction, hasAppFileResource, hasExtendsApp, isIncrementalConstruction, attrSpecPage, incrementalConstructionPageList, globalDataInfo, busiData, themeCss, frontendHookList, pageTypeMap, hasPageRulesPages, globalDataMap, appInfo, appPageList, temCompAssetList, compAssetList, _globalDataInfo, dataSourceList, pageIdMapping, lastPageId, data, needFindDataPages, requestQueue, requests, pages, _yield$services$qryBu, itemLists, BusiCompRequest, _incrementalConstruct, itemHash, _itemLists, alllBusiComp, busiPages, getTranslateName, chinese, translateNames, key, _translateNames, translateName, pagePathEnglishMapping, pagePathEnglishSet, getName, pagesChinese, pagesTranslateNames, findPageKeyByPageId, _key2, _appPageList$_key2$pa, _pagePathEnglishMappi, _pagesTranslateNames, safeTranslateName, pageKey, pageDSLS, getPlatform, appFileResource, _services$queryAppFil, _yield$services$query, list, appFileResourceList, _yield$services$selec, toolBoxList, toolBox, pageRules, options, cleanedTree;
|
|
255
268
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
256
269
|
while (1) switch (_context3.prev = _context3.next) {
|
|
257
270
|
case 0:
|
|
@@ -267,40 +280,41 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
267
280
|
busiData = [];
|
|
268
281
|
themeCss = '';
|
|
269
282
|
frontendHookList = [];
|
|
270
|
-
pageTypeMap = {};
|
|
283
|
+
pageTypeMap = {}; // 记录需要请求页面 rules 的页面
|
|
284
|
+
hasPageRulesPages = [];
|
|
271
285
|
globalDataMap = {};
|
|
272
|
-
_context3.next =
|
|
286
|
+
_context3.next = 13;
|
|
273
287
|
return services.findApplication({
|
|
274
288
|
appId: appId
|
|
275
289
|
});
|
|
276
|
-
case
|
|
290
|
+
case 13:
|
|
277
291
|
appInfo = _context3.sent;
|
|
278
292
|
onProgress({
|
|
279
293
|
log: '获取应用信息',
|
|
280
294
|
progress: 1
|
|
281
295
|
});
|
|
282
296
|
if (!(!isIncrementalConstruction || incrementalConstruction !== null && incrementalConstruction !== void 0 && incrementalConstruction.frontendHookChange)) {
|
|
283
|
-
_context3.next =
|
|
297
|
+
_context3.next = 19;
|
|
284
298
|
break;
|
|
285
299
|
}
|
|
286
|
-
_context3.next =
|
|
300
|
+
_context3.next = 18;
|
|
287
301
|
return services.queryFrontendHookList({
|
|
288
302
|
appId: appId
|
|
289
303
|
});
|
|
290
|
-
case 17:
|
|
291
|
-
frontendHookList = _context3.sent;
|
|
292
304
|
case 18:
|
|
305
|
+
frontendHookList = _context3.sent;
|
|
306
|
+
case 19:
|
|
293
307
|
onProgress({
|
|
294
308
|
log: '获取当前应用的全部页面',
|
|
295
309
|
progress: 2
|
|
296
310
|
});
|
|
297
311
|
// 根据 appId 获取当前应用的全部页面
|
|
298
|
-
_context3.next =
|
|
312
|
+
_context3.next = 22;
|
|
299
313
|
return services.qryPageInstListByAppId({
|
|
300
314
|
appId: appId,
|
|
301
315
|
terminalType: platform
|
|
302
316
|
});
|
|
303
|
-
case
|
|
317
|
+
case 22:
|
|
304
318
|
appPageList = _context3.sent;
|
|
305
319
|
appPageList.forEach(function (o) {
|
|
306
320
|
if (o.pageContainerType === 'Drawer') {
|
|
@@ -312,24 +326,24 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
312
326
|
// pageTypeMap[o.pageContainerType][o.pageId] = true;
|
|
313
327
|
});
|
|
314
328
|
if (isIncrementalConstruction) {
|
|
315
|
-
_context3.next =
|
|
329
|
+
_context3.next = 28;
|
|
316
330
|
break;
|
|
317
331
|
}
|
|
318
|
-
_context3.next =
|
|
332
|
+
_context3.next = 27;
|
|
319
333
|
return services.qryAttrSpecPage({
|
|
320
334
|
appId: appId,
|
|
321
335
|
pageNum: 1,
|
|
322
336
|
pageSize: 999999
|
|
323
337
|
});
|
|
324
|
-
case 26:
|
|
325
|
-
attrSpecPage = _context3.sent;
|
|
326
338
|
case 27:
|
|
339
|
+
attrSpecPage = _context3.sent;
|
|
340
|
+
case 28:
|
|
327
341
|
if (!(!isIncrementalConstruction || incrementalConstruction !== null && incrementalConstruction !== void 0 && incrementalConstruction.themeCssChange)) {
|
|
328
|
-
_context3.next =
|
|
342
|
+
_context3.next = 39;
|
|
329
343
|
break;
|
|
330
344
|
}
|
|
331
|
-
_context3.prev =
|
|
332
|
-
_context3.next =
|
|
345
|
+
_context3.prev = 29;
|
|
346
|
+
_context3.next = 32;
|
|
333
347
|
return Promise.race([new Promise(function (resolve, reject) {
|
|
334
348
|
services.getThemeCss({
|
|
335
349
|
appId: appId,
|
|
@@ -342,26 +356,26 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
342
356
|
resolve('');
|
|
343
357
|
}, 5000);
|
|
344
358
|
})]);
|
|
345
|
-
case
|
|
359
|
+
case 32:
|
|
346
360
|
themeCss = _context3.sent;
|
|
347
361
|
console.log('====获取主题成功');
|
|
348
|
-
_context3.next =
|
|
362
|
+
_context3.next = 39;
|
|
349
363
|
break;
|
|
350
|
-
case
|
|
351
|
-
_context3.prev =
|
|
352
|
-
_context3.t0 = _context3["catch"](
|
|
364
|
+
case 36:
|
|
365
|
+
_context3.prev = 36;
|
|
366
|
+
_context3.t0 = _context3["catch"](29);
|
|
353
367
|
console.error('====获取主题失败', _context3.t0);
|
|
354
|
-
case
|
|
368
|
+
case 39:
|
|
355
369
|
// 根据 appId 获取当前应用的使用的自定义组件
|
|
356
370
|
onProgress({
|
|
357
371
|
log: '获取当前应用的使用的自定义组件',
|
|
358
372
|
progress: 3
|
|
359
373
|
});
|
|
360
|
-
_context3.next =
|
|
374
|
+
_context3.next = 42;
|
|
361
375
|
return services.qryPageCompAssetList({
|
|
362
376
|
appId: appId
|
|
363
377
|
});
|
|
364
|
-
case
|
|
378
|
+
case 42:
|
|
365
379
|
temCompAssetList = _context3.sent;
|
|
366
380
|
// 兼容下割接数据,数组前面的自定义组件是新的
|
|
367
381
|
compAssetList = temCompAssetList.reduce(function (acc, current) {
|
|
@@ -374,7 +388,7 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
374
388
|
return acc;
|
|
375
389
|
}, []);
|
|
376
390
|
if (!(!isIncrementalConstruction || incrementalConstruction !== null && incrementalConstruction !== void 0 && incrementalConstruction.globalStoreChange)) {
|
|
377
|
-
_context3.next =
|
|
391
|
+
_context3.next = 51;
|
|
378
392
|
break;
|
|
379
393
|
}
|
|
380
394
|
// 根据appId 获取全局数据源
|
|
@@ -382,12 +396,12 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
382
396
|
log: '获取全局数据源',
|
|
383
397
|
progress: 4
|
|
384
398
|
});
|
|
385
|
-
_context3.next =
|
|
399
|
+
_context3.next = 48;
|
|
386
400
|
return services.queryFrontendDatasourcePage({
|
|
387
401
|
appId: appId,
|
|
388
402
|
pageSize: 10000
|
|
389
403
|
});
|
|
390
|
-
case
|
|
404
|
+
case 48:
|
|
391
405
|
globalDataInfo = _context3.sent;
|
|
392
406
|
dataSourceList = ((_globalDataInfo = globalDataInfo) === null || _globalDataInfo === void 0 ? void 0 : _globalDataInfo.list) || [];
|
|
393
407
|
dataSourceList.forEach(function (item) {
|
|
@@ -400,7 +414,7 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
400
414
|
} catch (err) {}
|
|
401
415
|
return null;
|
|
402
416
|
});
|
|
403
|
-
case
|
|
417
|
+
case 51:
|
|
404
418
|
pageIdMapping = {};
|
|
405
419
|
lastPageId = ''; // 根据 pageId 获得 dsl
|
|
406
420
|
data = [];
|
|
@@ -422,15 +436,15 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
422
436
|
}).then(resolve).catch(reject);
|
|
423
437
|
});
|
|
424
438
|
});
|
|
425
|
-
_context3.next =
|
|
439
|
+
_context3.next = 60;
|
|
426
440
|
return Promise.all(requests);
|
|
427
|
-
case
|
|
441
|
+
case 60:
|
|
428
442
|
data = _context3.sent;
|
|
429
443
|
// 先清空
|
|
430
444
|
requests = null;
|
|
431
|
-
pages = getPageDsls(data);
|
|
445
|
+
pages = getPageDsls(data, hasPageRulesPages);
|
|
432
446
|
if (isIncrementalConstruction) {
|
|
433
|
-
_context3.next =
|
|
447
|
+
_context3.next = 76;
|
|
434
448
|
break;
|
|
435
449
|
}
|
|
436
450
|
onProgress({
|
|
@@ -439,7 +453,7 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
439
453
|
});
|
|
440
454
|
|
|
441
455
|
// 业务组件从被使用才生成改为全部生成
|
|
442
|
-
_context3.next =
|
|
456
|
+
_context3.next = 67;
|
|
443
457
|
return services.qryBusiCompPage({
|
|
444
458
|
appIds: [appId],
|
|
445
459
|
appId: appId,
|
|
@@ -448,7 +462,7 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
448
462
|
pageSize: 999999,
|
|
449
463
|
terminalType: platform
|
|
450
464
|
});
|
|
451
|
-
case
|
|
465
|
+
case 67:
|
|
452
466
|
_yield$services$qryBu = _context3.sent;
|
|
453
467
|
itemLists = _yield$services$qryBu.list;
|
|
454
468
|
BusiCompRequest = itemLists.map(function (i) {
|
|
@@ -462,15 +476,15 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
462
476
|
}).then(resolve).catch(reject);
|
|
463
477
|
});
|
|
464
478
|
});
|
|
465
|
-
_context3.next =
|
|
479
|
+
_context3.next = 72;
|
|
466
480
|
return Promise.all(BusiCompRequest);
|
|
467
|
-
case
|
|
481
|
+
case 72:
|
|
468
482
|
busiData = _context3.sent;
|
|
469
483
|
// 先清空
|
|
470
484
|
BusiCompRequest = null;
|
|
471
|
-
_context3.next =
|
|
485
|
+
_context3.next = 83;
|
|
472
486
|
break;
|
|
473
|
-
case
|
|
487
|
+
case 76:
|
|
474
488
|
// busiCompId 过滤重复
|
|
475
489
|
itemHash = {}; // 找到所有页面使用到的 业务组件
|
|
476
490
|
findAllItem(pages, function (item) {
|
|
@@ -478,7 +492,7 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
478
492
|
}, itemHash);
|
|
479
493
|
_itemLists = Object.keys(itemHash); // 请求所有业务组件的 dsl
|
|
480
494
|
alllBusiComp = ((_incrementalConstruct = incrementalConstruction === null || incrementalConstruction === void 0 ? void 0 : incrementalConstruction.busiCompIds) !== null && _incrementalConstruct !== void 0 ? _incrementalConstruct : []).concat(_itemLists);
|
|
481
|
-
_context3.next =
|
|
495
|
+
_context3.next = 82;
|
|
482
496
|
return Promise.all(alllBusiComp.map(function (i) {
|
|
483
497
|
return services.findBusiCompById({
|
|
484
498
|
busiCompId: i,
|
|
@@ -486,9 +500,9 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
486
500
|
pageId: lastPageId
|
|
487
501
|
});
|
|
488
502
|
}));
|
|
489
|
-
case 81:
|
|
490
|
-
busiData = _context3.sent;
|
|
491
503
|
case 82:
|
|
504
|
+
busiData = _context3.sent;
|
|
505
|
+
case 83:
|
|
492
506
|
// 过滤为空
|
|
493
507
|
busiPages = busiData.filter(Boolean).map(function (i, index) {
|
|
494
508
|
var _i$busiCompVersion;
|
|
@@ -561,14 +575,14 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
561
575
|
});
|
|
562
576
|
translateNames = {};
|
|
563
577
|
if (!(chinese.length > 0)) {
|
|
564
|
-
_context3.next =
|
|
578
|
+
_context3.next = 91;
|
|
565
579
|
break;
|
|
566
580
|
}
|
|
567
|
-
_context3.next =
|
|
581
|
+
_context3.next = 90;
|
|
568
582
|
return getTranslateName(appId, chinese, 'UPPER_CAMEL');
|
|
569
|
-
case 89:
|
|
570
|
-
translateNames = _context3.sent;
|
|
571
583
|
case 90:
|
|
584
|
+
translateNames = _context3.sent;
|
|
585
|
+
case 91:
|
|
572
586
|
// 翻译业务组件的名字
|
|
573
587
|
for (key = 0; key < busiPages.length; key++) {
|
|
574
588
|
onProgress({
|
|
@@ -583,7 +597,7 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
583
597
|
}
|
|
584
598
|
pagePathEnglishMapping = {};
|
|
585
599
|
if (!needTranslatePagePathToEnglish) {
|
|
586
|
-
_context3.next =
|
|
600
|
+
_context3.next = 104;
|
|
587
601
|
break;
|
|
588
602
|
}
|
|
589
603
|
pagePathEnglishSet = {};
|
|
@@ -605,14 +619,14 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
605
619
|
});
|
|
606
620
|
pagesTranslateNames = {};
|
|
607
621
|
if (!(pagesChinese.length > 0)) {
|
|
608
|
-
_context3.next =
|
|
622
|
+
_context3.next = 102;
|
|
609
623
|
break;
|
|
610
624
|
}
|
|
611
|
-
_context3.next =
|
|
625
|
+
_context3.next = 101;
|
|
612
626
|
return getTranslateName(appId, pagesChinese, 'UPPER_CAMEL');
|
|
613
|
-
case 100:
|
|
614
|
-
pagesTranslateNames = _context3.sent;
|
|
615
627
|
case 101:
|
|
628
|
+
pagesTranslateNames = _context3.sent;
|
|
629
|
+
case 102:
|
|
616
630
|
findPageKeyByPageId = function findPageKeyByPageId(id, arrs) {
|
|
617
631
|
for (var _key = 0; _key < arrs.length; _key++) {
|
|
618
632
|
var _arrs$_key;
|
|
@@ -638,7 +652,7 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
638
652
|
pages[pageKey].pagePath = safeTranslateName;
|
|
639
653
|
}
|
|
640
654
|
}
|
|
641
|
-
case
|
|
655
|
+
case 104:
|
|
642
656
|
// 合并页面,生成器那边支持页面类型和业务组件类型
|
|
643
657
|
pageDSLS = [].concat(_toConsumableArray(pages), _toConsumableArray(busiPages));
|
|
644
658
|
getPlatform = function getPlatform(platFormtype) {
|
|
@@ -653,10 +667,10 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
653
667
|
}; // { '31232133':{fileName:'xxx',data:base64 }}
|
|
654
668
|
appFileResource = {}; // 如果开启下载静态资源
|
|
655
669
|
if (!hasAppFileResource) {
|
|
656
|
-
_context3.next =
|
|
670
|
+
_context3.next = 116;
|
|
657
671
|
break;
|
|
658
672
|
}
|
|
659
|
-
_context3.next =
|
|
673
|
+
_context3.next = 110;
|
|
660
674
|
return services === null || services === void 0 || (_services$queryAppFil = services.queryAppFileResourcePage) === null || _services$queryAppFil === void 0 ? void 0 : _services$queryAppFil.call(services, {
|
|
661
675
|
appId: appId,
|
|
662
676
|
orderType: 'DESC',
|
|
@@ -664,10 +678,10 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
664
678
|
pageSize: 999999,
|
|
665
679
|
sharedObjFilter: 'F'
|
|
666
680
|
});
|
|
667
|
-
case
|
|
681
|
+
case 110:
|
|
668
682
|
_yield$services$query = _context3.sent;
|
|
669
683
|
list = _yield$services$query.list;
|
|
670
|
-
_context3.next =
|
|
684
|
+
_context3.next = 114;
|
|
671
685
|
return Promise.all((list || []).map(function (item) {
|
|
672
686
|
return new Promise(function (resolve, reject) {
|
|
673
687
|
requestQueue.sendRequest(function () {
|
|
@@ -690,12 +704,41 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
690
704
|
}).catch(reject);
|
|
691
705
|
});
|
|
692
706
|
}));
|
|
693
|
-
case
|
|
707
|
+
case 114:
|
|
694
708
|
appFileResourceList = _context3.sent;
|
|
695
709
|
appFileResourceList.filter(Boolean).forEach(function (i) {
|
|
696
710
|
appFileResource[i.fileCode] = i;
|
|
697
711
|
});
|
|
698
|
-
case
|
|
712
|
+
case 116:
|
|
713
|
+
_context3.next = 118;
|
|
714
|
+
return services.selectToolBoxPage({
|
|
715
|
+
appId: appId,
|
|
716
|
+
qryType: 'F',
|
|
717
|
+
toolScan: 'front_function'
|
|
718
|
+
});
|
|
719
|
+
case 118:
|
|
720
|
+
_yield$services$selec = _context3.sent;
|
|
721
|
+
toolBoxList = _yield$services$selec.list;
|
|
722
|
+
toolBox = (toolBoxList || []).map(function (i) {
|
|
723
|
+
var toolScriptJson = JSON.parse((i === null || i === void 0 ? void 0 : i.toolScriptJson) || '{}');
|
|
724
|
+
var toolScript = toolScriptJson === null || toolScriptJson === void 0 ? void 0 : toolScriptJson.script;
|
|
725
|
+
return "export ".concat(toolScript.replace(/function\s+(\w+)\s*\(/, "function ".concat(i === null || i === void 0 ? void 0 : i.toolCode, "(")));
|
|
726
|
+
}).join('\n'); //TODO: 新接口,有些环境还没部署,等都部署了,可以去掉这个兜底
|
|
727
|
+
_context3.next = 123;
|
|
728
|
+
return Promise.race([new Promise(function (resolve, reject) {
|
|
729
|
+
services.batchQryPageRulesByPageIds({
|
|
730
|
+
appId: appId,
|
|
731
|
+
pageIds: hasPageRulesPages.join(',')
|
|
732
|
+
}).then(function (res) {
|
|
733
|
+
resolve(res);
|
|
734
|
+
});
|
|
735
|
+
}), new Promise(function (resolve, reject) {
|
|
736
|
+
setTimeout(function () {
|
|
737
|
+
resolve({});
|
|
738
|
+
}, 5000);
|
|
739
|
+
})]);
|
|
740
|
+
case 123:
|
|
741
|
+
pageRules = _context3.sent;
|
|
699
742
|
options = {
|
|
700
743
|
platform: getPlatform(platform),
|
|
701
744
|
appId: appId,
|
|
@@ -716,7 +759,9 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
716
759
|
incrementalConstruction: incrementalConstruction,
|
|
717
760
|
pageTypeMap: pageTypeMap,
|
|
718
761
|
appFileResource: appFileResource,
|
|
719
|
-
hasExtendsApp: hasExtendsApp
|
|
762
|
+
hasExtendsApp: hasExtendsApp,
|
|
763
|
+
toolBox: toolBox,
|
|
764
|
+
pageRules: pageRules
|
|
720
765
|
};
|
|
721
766
|
onProgress({
|
|
722
767
|
log: '清理无用数据',
|
|
@@ -728,11 +773,11 @@ export var fetchData = /*#__PURE__*/function () {
|
|
|
728
773
|
options: options,
|
|
729
774
|
cleanedTree: cleanedTree
|
|
730
775
|
});
|
|
731
|
-
case
|
|
776
|
+
case 129:
|
|
732
777
|
case "end":
|
|
733
778
|
return _context3.stop();
|
|
734
779
|
}
|
|
735
|
-
}, _callee3, null, [[
|
|
780
|
+
}, _callee3, null, [[29, 36]]);
|
|
736
781
|
}));
|
|
737
782
|
return function fetchData(_x) {
|
|
738
783
|
return _ref5.apply(this, arguments);
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 环境检测
|
|
3
|
+
*/
|
|
1
4
|
export const isBrowser =
|
|
2
5
|
typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
3
6
|
export const isNode =
|
|
@@ -6,13 +9,18 @@ export const isNode =
|
|
|
6
9
|
typeof process.versions.node !== 'undefined';
|
|
7
10
|
export const isWXminiProgram = !isBrowser && typeof wx === 'object';
|
|
8
11
|
|
|
12
|
+
/**
|
|
13
|
+
* 环境能力检测
|
|
14
|
+
*/
|
|
9
15
|
const capabilities = (function () {
|
|
10
16
|
return {
|
|
11
17
|
cookie: isBrowser && navigator.cookieEnabled,
|
|
12
18
|
fetch: typeof fetch === 'function',
|
|
13
19
|
xhr: typeof XMLHttpRequest === 'function',
|
|
14
20
|
wxRequest: isWXminiProgram && typeof wx.request === 'function',
|
|
21
|
+
wxStorage: isWXminiProgram && typeof wx.getStorageSync === 'function',
|
|
15
22
|
localStorage: typeof localStorage === 'object',
|
|
23
|
+
proxy: typeof Proxy === 'function',
|
|
16
24
|
};
|
|
17
25
|
})();
|
|
18
26
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import merge from 'merge';
|
|
2
|
-
import
|
|
2
|
+
import { isBrowser } from './clientCapabilities';
|
|
3
3
|
import {
|
|
4
4
|
aesKey,
|
|
5
|
-
desKey,
|
|
6
5
|
rsaPrivKey,
|
|
7
6
|
rsaPublicKey,
|
|
8
7
|
securityHeaderKey,
|
|
@@ -10,64 +9,67 @@ import {
|
|
|
10
9
|
signKey,
|
|
11
10
|
signSaltKey,
|
|
12
11
|
} from './const';
|
|
13
|
-
import type { configType } from './types';
|
|
12
|
+
import type { configType, securityType } from './types';
|
|
14
13
|
import { MODE } from './types';
|
|
14
|
+
import customAtob from './utils/atob';
|
|
15
15
|
import CookieUtil from './utils/cookie';
|
|
16
|
-
|
|
17
|
-
let isInit: boolean = false;
|
|
16
|
+
import storageUtil from './utils/storge';
|
|
18
17
|
|
|
19
18
|
// 在浏览器模式下,通过平台env/info.js写入配置数据
|
|
20
19
|
const defaultMode = () =>
|
|
21
20
|
(isBrowser && (window as any).lxSecurityMode) || MODE.SIGN_WITH_TIME;
|
|
21
|
+
const defaultLxKey = () =>
|
|
22
|
+
(isBrowser &&
|
|
23
|
+
(window as any).lxKey &&
|
|
24
|
+
customAtob((window as any).lxKey)?.split(',')) ||
|
|
25
|
+
undefined;
|
|
22
26
|
const defaultSignSaltKey = () =>
|
|
23
27
|
(isBrowser && (window as any).lxDataSaltCode) || signSaltKey;
|
|
24
|
-
const
|
|
25
|
-
isBrowser && (window as any).
|
|
26
|
-
?
|
|
28
|
+
const defaultTimeDeviation = () =>
|
|
29
|
+
isBrowser && (window as any).lxClientTimeDeviation
|
|
30
|
+
? (window as any).lxClientTimeDeviation
|
|
27
31
|
: 0;
|
|
28
32
|
|
|
29
|
-
export const createDefaultConfig = (): configType =>
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
export const createDefaultConfig = (): configType => {
|
|
34
|
+
const lxkey = defaultLxKey();
|
|
35
|
+
return {
|
|
36
|
+
// 安全模式
|
|
37
|
+
mode: defaultMode(),
|
|
32
38
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
privKey: rsaPrivKey,
|
|
51
|
-
publicKey: rsaPublicKey,
|
|
52
|
-
},
|
|
39
|
+
requester: ['xhr', 'fetch', 'wxRequest'],
|
|
40
|
+
// 签名&加密配置
|
|
41
|
+
sign: {
|
|
42
|
+
key: lxkey?.[0] || signKey,
|
|
43
|
+
saltKey: defaultSignSaltKey(),
|
|
44
|
+
saltValue: isBrowser
|
|
45
|
+
? () => CookieUtil.getItem(config.sign?.saltKey as string)
|
|
46
|
+
: '',
|
|
47
|
+
valueKeyName: signHeaderKey,
|
|
48
|
+
},
|
|
49
|
+
aes: {
|
|
50
|
+
key: lxkey?.[1] || aesKey,
|
|
51
|
+
},
|
|
52
|
+
rsa: {
|
|
53
|
+
privKey: lxkey?.[2] || rsaPrivKey,
|
|
54
|
+
publicKey: lxkey?.[3] || rsaPublicKey,
|
|
55
|
+
},
|
|
53
56
|
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
// 服务器与客户端时间偏差
|
|
58
|
+
timeDeviation: defaultTimeDeviation(),
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
// 服务器时间
|
|
61
|
+
serverTime: null,
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
// 通过请求头传递给后端安全类型的字段
|
|
64
|
+
securityHeaderKey,
|
|
62
65
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
});
|
|
66
|
+
debug: storageUtil.get('lxDebug') === 'true',
|
|
67
|
+
};
|
|
68
|
+
};
|
|
67
69
|
|
|
68
70
|
const config: configType = {};
|
|
69
71
|
|
|
70
|
-
const setConfig = (newConfig
|
|
72
|
+
const setConfig: typeof securityType.setConfig = (newConfig) => {
|
|
71
73
|
// 只更新服务器时间时,重新计算时间偏差
|
|
72
74
|
if (
|
|
73
75
|
newConfig.serverTime &&
|
|
@@ -77,13 +79,18 @@ const setConfig = (newConfig: configType = {}): void => {
|
|
|
77
79
|
newConfig.timeDeviation =
|
|
78
80
|
Date.now() - Number(new Date(newConfig.serverTime));
|
|
79
81
|
}
|
|
80
|
-
|
|
81
|
-
isInit = true;
|
|
82
|
-
merge.recursive(config, createDefaultConfig(), newConfig);
|
|
83
|
-
} else {
|
|
84
|
-
merge.recursive(config, newConfig);
|
|
85
|
-
}
|
|
82
|
+
merge.recursive(config, newConfig);
|
|
86
83
|
};
|
|
87
84
|
|
|
85
|
+
const getConfig: typeof securityType.getConfig = (key) => {
|
|
86
|
+
return config[key];
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const initConfig = () => {
|
|
90
|
+
setConfig(createDefaultConfig());
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
initConfig();
|
|
94
|
+
|
|
88
95
|
export default config;
|
|
89
|
-
export { setConfig };
|
|
96
|
+
export { setConfig, initConfig, getConfig };
|