@lingxiteam/ebe-utils 0.0.33 → 0.0.35
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/h5public/src/components/factory/src/Icon/IconED/index.less +43 -0
- package/lib/h5public/src/components/factory/src/Icon/IconED/index.tsx +290 -0
- 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/lib/public/src/utils/useTool.ts +2 -172
- package/lib/public/yarn.lock +11441 -0
- package/package.json +3 -3
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/closeIcon.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/fileName.png +0 -0
- package/lib/pcpublic/src/components/pcfactory/src/StdUpload/assets/img.png +0 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { createFromIconfontCN } from '@ant-design/icons';
|
|
2
|
+
import { Icon as LegacyIcon } from '@lingxiteam/icons';
|
|
3
|
+
import { LingXiEdFC } from '@lingxiteam/types';
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
6
|
+
import './index.less';
|
|
7
|
+
|
|
8
|
+
export interface IconFileEDProps {
|
|
9
|
+
fileId: string;
|
|
10
|
+
fileCode: string;
|
|
11
|
+
fileSubType: 'ICON_IMAGE' | 'ICONFONT';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface MyIconEDProps {
|
|
15
|
+
type?: string;
|
|
16
|
+
isIconFont?: boolean;
|
|
17
|
+
fontAddress?: string;
|
|
18
|
+
svgContent?: string;
|
|
19
|
+
theme?: string;
|
|
20
|
+
iconFileInfo?: any;
|
|
21
|
+
iconFile?: IconFileEDProps;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface IconEDProps {
|
|
25
|
+
icon?: MyIconEDProps;
|
|
26
|
+
type?: string;
|
|
27
|
+
isIconFont?: boolean;
|
|
28
|
+
fontAddress?: string;
|
|
29
|
+
svgContent?: string;
|
|
30
|
+
theme?: string;
|
|
31
|
+
style?: any;
|
|
32
|
+
className?: any;
|
|
33
|
+
rotate?: any;
|
|
34
|
+
iconFileInfo?: any;
|
|
35
|
+
iconFile?: IconFileEDProps;
|
|
36
|
+
size?: any;
|
|
37
|
+
color?: any;
|
|
38
|
+
mode?: string;
|
|
39
|
+
iconItems?: any;
|
|
40
|
+
isUsePrimary?: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const IconED: LingXiEdFC<IconEDProps> = (props) => {
|
|
44
|
+
const {
|
|
45
|
+
icon = {},
|
|
46
|
+
type,
|
|
47
|
+
rotate,
|
|
48
|
+
size,
|
|
49
|
+
style,
|
|
50
|
+
mode,
|
|
51
|
+
iconItems,
|
|
52
|
+
isUsePrimary: curIsUsePrimary,
|
|
53
|
+
theme: curTheme,
|
|
54
|
+
isIconFont: curIsIconFont,
|
|
55
|
+
fontAddress: curFontAddress,
|
|
56
|
+
svgContent: curSvgContent,
|
|
57
|
+
iconFileInfo: curIconFileInfo,
|
|
58
|
+
iconFile: curIconFile,
|
|
59
|
+
getEdEngineApi,
|
|
60
|
+
$$componentItem,
|
|
61
|
+
...restProps
|
|
62
|
+
} = props;
|
|
63
|
+
const [scriptUrl, setScripUrl] = useState<any>();
|
|
64
|
+
|
|
65
|
+
const {
|
|
66
|
+
curType,
|
|
67
|
+
iconFile,
|
|
68
|
+
iconFileInfo,
|
|
69
|
+
fontAddress,
|
|
70
|
+
isIconFont,
|
|
71
|
+
theme,
|
|
72
|
+
svgContent,
|
|
73
|
+
isUsePrimary,
|
|
74
|
+
color,
|
|
75
|
+
} = useMemo(() => {
|
|
76
|
+
const iconInfo = Array.isArray(iconItems) && iconItems[0];
|
|
77
|
+
if (mode === 'custom' && iconInfo) {
|
|
78
|
+
return {
|
|
79
|
+
curType: iconInfo?.icon?.type,
|
|
80
|
+
theme: iconInfo?.icon?.theme,
|
|
81
|
+
isIconFont: iconInfo?.icon?.isIconFont,
|
|
82
|
+
fontAddress: iconInfo?.icon?.fontAddress,
|
|
83
|
+
svgContent: iconInfo?.icon?.svgContent,
|
|
84
|
+
iconFileInfo: iconInfo?.icon?.iconFileInfo,
|
|
85
|
+
iconFile: iconInfo?.icon?.iconFile,
|
|
86
|
+
isUsePrimary: iconInfo?.isUsePrimary,
|
|
87
|
+
color: iconInfo?.color,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
curType: icon?.type || type,
|
|
92
|
+
iconFile: icon?.iconFile || curIconFile,
|
|
93
|
+
iconFileInfo: icon?.iconFileInfo || curIconFileInfo,
|
|
94
|
+
fontAddress: icon?.fontAddress || curFontAddress,
|
|
95
|
+
isIconFont: icon?.isIconFont || curIsIconFont,
|
|
96
|
+
theme: icon?.theme || curTheme,
|
|
97
|
+
svgContent: icon?.svgContent || curSvgContent,
|
|
98
|
+
};
|
|
99
|
+
}, [
|
|
100
|
+
JSON.stringify(icon),
|
|
101
|
+
type,
|
|
102
|
+
curIconFile,
|
|
103
|
+
curIconFileInfo,
|
|
104
|
+
curFontAddress,
|
|
105
|
+
curIsIconFont,
|
|
106
|
+
curTheme,
|
|
107
|
+
curSvgContent,
|
|
108
|
+
mode,
|
|
109
|
+
iconItems,
|
|
110
|
+
]);
|
|
111
|
+
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
if (iconFile) {
|
|
114
|
+
const { fileId, fileCode, fileHttp } = iconFile;
|
|
115
|
+
(async () => {
|
|
116
|
+
const { getAppFileUrlById, getAppFileUrlByFileCode } =
|
|
117
|
+
getEdEngineApi?.() || {};
|
|
118
|
+
if (fileId && getAppFileUrlById) {
|
|
119
|
+
setScripUrl(getAppFileUrlById(fileId));
|
|
120
|
+
} else if (fileCode && getAppFileUrlByFileCode) {
|
|
121
|
+
setScripUrl(
|
|
122
|
+
getAppFileUrlByFileCode({
|
|
123
|
+
appId: $$componentItem?.appId || window.appId,
|
|
124
|
+
fileCode,
|
|
125
|
+
}),
|
|
126
|
+
);
|
|
127
|
+
} else if (fileHttp) {
|
|
128
|
+
setScripUrl(fileHttp);
|
|
129
|
+
}
|
|
130
|
+
})();
|
|
131
|
+
} else if (fontAddress) {
|
|
132
|
+
setScripUrl(fontAddress);
|
|
133
|
+
} else if (iconFileInfo && !iconFileInfo.svgContent) {
|
|
134
|
+
const { getMaterialFile } = getEdEngineApi?.() || {};
|
|
135
|
+
(async () => {
|
|
136
|
+
if (iconFileInfo.materialId && iconFileInfo.fileName) {
|
|
137
|
+
setScripUrl(
|
|
138
|
+
getMaterialFile({
|
|
139
|
+
materialId: iconFileInfo.materialId,
|
|
140
|
+
fileName: iconFileInfo.fileName,
|
|
141
|
+
}),
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
})();
|
|
145
|
+
} else {
|
|
146
|
+
setScripUrl('');
|
|
147
|
+
}
|
|
148
|
+
}, [iconFile, fontAddress, iconFileInfo]);
|
|
149
|
+
|
|
150
|
+
const curClassName = classnames({
|
|
151
|
+
[restProps?.className]: restProps?.className,
|
|
152
|
+
'cust-icon-ed': true,
|
|
153
|
+
'cust-icon-theme': isUsePrimary,
|
|
154
|
+
[`cust-icon-ed-${size}`]: size,
|
|
155
|
+
});
|
|
156
|
+
const curStyle = useMemo(
|
|
157
|
+
() => ({
|
|
158
|
+
width: style?.fontSize || style?.width,
|
|
159
|
+
height: style?.fontSize || style?.height,
|
|
160
|
+
fontSize: style?.fontSize || style?.width, // 兼容存量数据
|
|
161
|
+
...(style || {}),
|
|
162
|
+
color: isUsePrimary
|
|
163
|
+
? undefined
|
|
164
|
+
: color || style?.color || restProps?.color,
|
|
165
|
+
fill: isUsePrimary
|
|
166
|
+
? undefined
|
|
167
|
+
: color || style?.color || restProps?.color,
|
|
168
|
+
}),
|
|
169
|
+
[isUsePrimary, style, color],
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
if (svgContent) {
|
|
173
|
+
return (
|
|
174
|
+
<div
|
|
175
|
+
className={curClassName}
|
|
176
|
+
style={{
|
|
177
|
+
...curStyle,
|
|
178
|
+
transform: `rotate(${rotate}deg)`,
|
|
179
|
+
}}
|
|
180
|
+
// eslint-disable-next-line react/no-danger
|
|
181
|
+
dangerouslySetInnerHTML={{
|
|
182
|
+
__html: svgContent,
|
|
183
|
+
}}
|
|
184
|
+
/>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (curType) {
|
|
189
|
+
if (fontAddress || iconFile?.fileSubType === 'ICONFONT' || isIconFont) {
|
|
190
|
+
if (scriptUrl) {
|
|
191
|
+
const IconFont = createFromIconfontCN({
|
|
192
|
+
scriptUrl,
|
|
193
|
+
});
|
|
194
|
+
return (
|
|
195
|
+
<IconFont
|
|
196
|
+
type={curType}
|
|
197
|
+
rotate={rotate}
|
|
198
|
+
{...restProps}
|
|
199
|
+
style={curStyle}
|
|
200
|
+
className={curClassName}
|
|
201
|
+
/>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
if (!fontAddress) {
|
|
205
|
+
// 采用项目本地的iconfont文件
|
|
206
|
+
return (
|
|
207
|
+
<svg
|
|
208
|
+
style={{
|
|
209
|
+
...curStyle,
|
|
210
|
+
transform: `rotate(${rotate}deg)`,
|
|
211
|
+
}}
|
|
212
|
+
aria-hidden="true"
|
|
213
|
+
className={curClassName}
|
|
214
|
+
>
|
|
215
|
+
<use xlinkHref={`#${curType}`} />
|
|
216
|
+
</svg>
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
} else if (
|
|
220
|
+
theme &&
|
|
221
|
+
!['cross-circle', 'cross-circle-o'].includes(curType) &&
|
|
222
|
+
Object.keys(iconFileInfo || {})?.length < 1
|
|
223
|
+
) {
|
|
224
|
+
// 兼容原来的antd-mobile的图标
|
|
225
|
+
return (
|
|
226
|
+
<LegacyIcon
|
|
227
|
+
type={curType}
|
|
228
|
+
rotate={rotate}
|
|
229
|
+
theme={theme}
|
|
230
|
+
{...restProps}
|
|
231
|
+
style={curStyle}
|
|
232
|
+
className={curClassName}
|
|
233
|
+
/>
|
|
234
|
+
);
|
|
235
|
+
} else if (iconFileInfo && Object.keys(iconFileInfo)?.length > 0) {
|
|
236
|
+
if (iconFileInfo.svgContent) {
|
|
237
|
+
return (
|
|
238
|
+
<div
|
|
239
|
+
className={curClassName}
|
|
240
|
+
style={{
|
|
241
|
+
...curStyle,
|
|
242
|
+
transform: `rotate(${rotate}deg)`,
|
|
243
|
+
}}
|
|
244
|
+
// eslint-disable-next-line react/no-danger
|
|
245
|
+
dangerouslySetInnerHTML={{ __html: iconFileInfo.svgContent }}
|
|
246
|
+
/>
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
return (
|
|
250
|
+
<img
|
|
251
|
+
className={curClassName}
|
|
252
|
+
style={{
|
|
253
|
+
...curStyle,
|
|
254
|
+
transform: `rotate(${rotate}deg)`,
|
|
255
|
+
}}
|
|
256
|
+
src={scriptUrl}
|
|
257
|
+
alt=""
|
|
258
|
+
/>
|
|
259
|
+
);
|
|
260
|
+
} else if (curType) {
|
|
261
|
+
return (
|
|
262
|
+
<LegacyIcon
|
|
263
|
+
type={curType}
|
|
264
|
+
rotate={rotate}
|
|
265
|
+
theme={theme}
|
|
266
|
+
{...restProps}
|
|
267
|
+
style={curStyle}
|
|
268
|
+
className={curClassName}
|
|
269
|
+
/>
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (iconFile?.fileSubType === 'ICON_IMAGE' && scriptUrl) {
|
|
274
|
+
return (
|
|
275
|
+
<img
|
|
276
|
+
alt="图片格式错误"
|
|
277
|
+
src={scriptUrl}
|
|
278
|
+
{...restProps}
|
|
279
|
+
style={{
|
|
280
|
+
...curStyle,
|
|
281
|
+
transform: `rotate(${rotate}deg)`,
|
|
282
|
+
}}
|
|
283
|
+
className={curClassName}
|
|
284
|
+
/>
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
return null;
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
export default IconED;
|
|
@@ -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 };
|
|
@@ -1,129 +1,40 @@
|
|
|
1
1
|
// 不建议使用环境变量,后期通一通过config来配置
|
|
2
2
|
// 兼容非node环境构建(如:小程序)
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
'
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
'
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
'
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
'
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
'
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
'a',
|
|
42
|
-
'c',
|
|
43
|
-
'0',
|
|
44
|
-
'I',
|
|
45
|
-
'a',
|
|
46
|
-
].join('');
|
|
47
|
-
|
|
48
|
-
export const securityHeaderKey = 'XA-TYPE';
|
|
49
|
-
|
|
50
|
-
export const signSaltKey =
|
|
51
|
-
process.env.LING_XI_USER_KEY_IN_COOKIE || 'X-LX-N-ID';
|
|
52
|
-
|
|
53
|
-
export const signKey =
|
|
54
|
-
process.env.LING_XI_HTTP_SIGN_KEY ||
|
|
55
|
-
[
|
|
56
|
-
'z',
|
|
57
|
-
'r',
|
|
58
|
-
'T',
|
|
59
|
-
'5',
|
|
60
|
-
'b',
|
|
61
|
-
'i',
|
|
62
|
-
'2',
|
|
63
|
-
'e',
|
|
64
|
-
's',
|
|
65
|
-
'c',
|
|
66
|
-
'X',
|
|
67
|
-
'i',
|
|
68
|
-
'l',
|
|
69
|
-
'a',
|
|
70
|
-
'H',
|
|
71
|
-
'1',
|
|
72
|
-
'f',
|
|
73
|
-
's',
|
|
74
|
-
'6',
|
|
75
|
-
'5',
|
|
76
|
-
'3',
|
|
77
|
-
'u',
|
|
78
|
-
'Z',
|
|
79
|
-
'i',
|
|
80
|
-
'H',
|
|
81
|
-
'9',
|
|
82
|
-
'R',
|
|
83
|
-
'W',
|
|
84
|
-
'f',
|
|
85
|
-
'z',
|
|
86
|
-
'C',
|
|
87
|
-
'S',
|
|
88
|
-
].join('');
|
|
89
|
-
|
|
90
|
-
export const signHeaderKey =
|
|
91
|
-
process.env.LINGXI_HTTP_SIGN_HEADER_KEY ||
|
|
92
|
-
process.env.REACT_APP_HTTP_SIGN_HEADER_KEY ||
|
|
93
|
-
process.env.UMI_APP_HTTP_SIGN_HEADER_KEY ||
|
|
94
|
-
process.env.FISHX_APP_HTTP_SIGN_HEADER_KEY ||
|
|
95
|
-
defaultSignHeaderKey;
|
|
96
|
-
|
|
97
|
-
export const rsaPublicKey =
|
|
98
|
-
process.env.LINGXI_HTTP_RSA_PUBLIC_KEY ||
|
|
99
|
-
process.env.REACT_APP_HTTP_RSA_PUBLIC_KEY ||
|
|
100
|
-
process.env.UMI_APP_HTTP_RSA_PUBLIC_KEY ||
|
|
101
|
-
process.env.FISHX_APP_HTTP_RSA_PUBLIC_KEY;
|
|
102
|
-
|
|
103
|
-
export const rsaPrivKey =
|
|
104
|
-
process.env.LINGXI_HTTP_RSA_PRIV_KEY ||
|
|
105
|
-
process.env.REACT_APP_HTTP_RSA_PRIV_KEY ||
|
|
106
|
-
process.env.UMI_APP_HTTP_RSA_PRIV_KEY ||
|
|
107
|
-
process.env.FISHX_APP_HTTP_RSA_PRIV_KEY;
|
|
108
|
-
|
|
109
|
-
export const aesKey =
|
|
110
|
-
process.env.LINGXI_HTTP_AES_KEY ||
|
|
111
|
-
process.env.REACT_APP_HTTP_AES_KEY ||
|
|
112
|
-
process.env.UMI_APP_HTTP_AES_KEY ||
|
|
113
|
-
process.env.FISHX_APP_HTTP_AES_KEY ||
|
|
114
|
-
defaultAESKey;
|
|
115
|
-
|
|
116
|
-
export const desKey =
|
|
117
|
-
process.env.LINGXI_HTTP_DES_KEY ||
|
|
118
|
-
process.env.REACT_APP_HTTP_DES_KEY ||
|
|
119
|
-
process.env.UMI_APP_HTTP_DES_KEY ||
|
|
120
|
-
process.env.FISHX_APP_HTTP_DES_KEY ||
|
|
121
|
-
defaultDESKey;
|
|
122
|
-
|
|
123
|
-
export default {
|
|
124
|
-
signKey,
|
|
125
|
-
rsaPublicKey,
|
|
126
|
-
rsaPrivKey,
|
|
127
|
-
aesKey,
|
|
128
|
-
desKey,
|
|
129
|
-
};
|
|
3
|
+
// const _process = typeof process === 'undefined' ? { env: {} } as any : process;
|
|
4
|
+
import customAtob from './utils/atob';
|
|
5
|
+
|
|
6
|
+
export const reqIdKey = 'reqid';
|
|
7
|
+
|
|
8
|
+
export const commonGlobal: any = (function () {
|
|
9
|
+
// nodejs、wx、electron 环境(在wx和electron同时具备global和window,wx下写入的全局变量在global里,故优先使用global)
|
|
10
|
+
if (typeof global !== 'undefined') {
|
|
11
|
+
return global;
|
|
12
|
+
}
|
|
13
|
+
// 使用标准的方式来获取不同环境下的全局 this 对象
|
|
14
|
+
if (typeof globalThis !== 'undefined') {
|
|
15
|
+
return globalThis;
|
|
16
|
+
}
|
|
17
|
+
// 浏览器环境
|
|
18
|
+
if (typeof window !== 'undefined') {
|
|
19
|
+
return window;
|
|
20
|
+
}
|
|
21
|
+
// Workers环境
|
|
22
|
+
if (typeof self !== 'undefined') {
|
|
23
|
+
return self;
|
|
24
|
+
}
|
|
25
|
+
return {};
|
|
26
|
+
})();
|
|
27
|
+
|
|
28
|
+
// 'd86d7bab3d6ac01a,X-SIGN,d86d7bab3d6ac0Ia,XA-TYPE,X-LX-N-ID,zrT5bi2escXilaH1fs653uZiH9RWfzCS'
|
|
29
|
+
const k = customAtob(
|
|
30
|
+
'ZDg2ZDdiYWIzZDZhYzAxYSxYLVNJR04sZDg2ZDdiYWIzZDZhYzBJYSxYQS1UWVBFLFgtTFgtTi1JRCx6clQ1YmkyZXNjWGlsYUgxZnM2NTN1WmlIOVJXZnpDUw==',
|
|
31
|
+
).split(',');
|
|
32
|
+
|
|
33
|
+
export const aesKey = k[0];
|
|
34
|
+
export const signHeaderKey = k[1];
|
|
35
|
+
export const lxKey = k[2];
|
|
36
|
+
export const securityHeaderKey = k[3];
|
|
37
|
+
export const signSaltKey = k[4];
|
|
38
|
+
export const signKey = k[5];
|
|
39
|
+
export const rsaPublicKey = k[6];
|
|
40
|
+
export const rsaPrivKey = k[7];
|