@lingxiteam/assets 1.0.9-alpha.4 → 1.0.9-xj
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/error/index.js +1 -2
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/es/security/encipher/aes.d.ts +1 -1
- package/es/security/encipher/aes.js +2 -22
- package/es/security/encipher/des.d.ts +2 -2
- package/es/security/encipher/des.js +2 -21
- package/es/security/encipher/rsa.d.ts +2 -2
- package/es/security/encipher/rsa.js +2 -13
- package/es/security/encipher/sign.js +5 -1
- package/es/security/index.d.ts +5 -5
- package/es/utils/cookieUtil.js +36 -0
- package/lib/index.js +0 -6
- package/package.json +1 -1
package/es/error/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import ErrorMsg from './errorDisplay/Web/ErrorMsg';
|
|
2
1
|
import MobileErrorMsg from './errorDisplay/Mobile/ErrorMsg';
|
|
3
2
|
import { getHttpErrorByCode } from './errorDisplay/compUtils';
|
|
4
3
|
import errorCatch from './errorCatch';
|
|
5
|
-
export {
|
|
4
|
+
export { MobileErrorMsg, getHttpErrorByCode, errorCatch };
|
package/es/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import security from './security';
|
|
2
|
-
import {
|
|
2
|
+
import { MobileErrorMsg, getHttpErrorByCode, errorCatch } from './error';
|
|
3
3
|
import { parseUrlExpression } from './utils/url';
|
|
4
4
|
export declare const IconCheckSvg: string;
|
|
5
5
|
export declare const IconNormalCheckSvg: string;
|
|
6
|
-
export { security,
|
|
6
|
+
export { security, MobileErrorMsg, getHttpErrorByCode, errorCatch, parseUrlExpression };
|
package/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getSvgImageBase64 } from './utils/img';
|
|
2
2
|
import security from './security';
|
|
3
|
-
import {
|
|
3
|
+
import { MobileErrorMsg, getHttpErrorByCode, errorCatch } from './error';
|
|
4
4
|
import { parseUrlExpression } from './utils/url';
|
|
5
5
|
export var IconCheckSvg = getSvgImageBase64("<?xml version=\"1.0\" encoding=\"UTF-8\"?><svg width=\"22px\" height=\"22px\" viewBox=\"0 0 22 22\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><title>\u5168\u5C40\u6837\u5F0F:20/\u539F\u5B50\u7EA7\u63A7\u4EF6/\u590D\u9009/\u72B6\u6001:#\u9009\u4E2D</title><g id=\"\u63A7\u4EF6\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\"><g id=\"system-complete\"><path d=\"M11,0 C17.075904,0 22,4.92409598 22,11 C22,17.075904 17.0734732,22 11,22 C4.92652679,22 0,17.0734732 0,11 C0,4.92652679 4.92409598,0 11,0 Z\" id=\"Shape\" fill=\"#1890FF\"></path><path d=\"M9.42871875,12.9681652 L7.2069029,10.7463493 C6.90006126,10.4395077 6.40257267,10.4395077 6.09573103,10.7463493 C5.78889035,11.05319 5.78889035,11.550677 6.09573103,11.8575177 C6.09573161,11.8575183 6.0957322,11.8575189 6.09573278,11.8575195 L8.72212536,14.4838955 C9.11265701,14.8744045 9.74581424,14.874407 10.136349,14.483901 L10.5404063,14.0798527 L10.5404063,14.0798527 L16.2813591,8.33795955 C16.588183,8.03108543 16.5881626,7.53359119 16.2813136,7.22674219 C15.974472,6.91990055 15.4769834,6.91990055 15.1701417,7.22674219 L9.42871875,12.9681652 L9.42871875,12.9681652 Z\" id=\"Path\" fill=\"#FFFFFF\"></path></g></g></svg>");
|
|
6
6
|
export var IconNormalCheckSvg = getSvgImageBase64("<?xml version=\"1.0\" encoding=\"UTF-8\"?><svg width=\"22px\" height=\"22px\" viewBox=\"0 0 22 22\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><title>\u5168\u5C40\u6837\u5F0F:20/\u539F\u5B50\u7EA7\u63A7\u4EF6/\u590D\u9009/\u72B6\u6001:\u672A\u9009\u4E2D</title><g id=\"\u63A7\u4EF6\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\"><g id=\"\u5143\u7D20/\u9009\u62E9/\u672A\u9009\u4E2D\"><path d=\"M11,22 C4.93492502,22 0,17.0653546 0,10.999496 C0,4.9337633 4.93492502,0 11,0 C17.065075,0 22,4.93464539 22,10.999496 C22,17.0644725 17.0660846,22 11,22\" id=\"Fill\" fill=\"#FFFFFF\"></path><path d=\"M11,0.5 C13.8998633,0.5 16.5248731,1.67505184 18.4249106,3.57508938 C20.3249482,5.47512693 21.5,8.10013672 21.5,11 C21.5,13.8995696 20.3245821,16.5243277 18.4245965,18.4243132 C16.5242275,20.3246822 13.8989967,21.5 11,21.5 C8.10129687,21.5 5.47631792,20.324316 3.57600094,18.4239991 C1.67568396,16.5236821 0.5,13.8987031 0.5,11 C0.5,8.10100334 1.67531776,5.47577251 3.57568679,3.57540349 C5.47567234,1.67541793 8.10043037,0.5 11,0.5 Z\" id=\"Shape\" stroke=\"#CCCCCC\"></path></g></g></svg>");
|
|
7
|
-
export { security,
|
|
7
|
+
export { security, MobileErrorMsg, getHttpErrorByCode, errorCatch, parseUrlExpression };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const AESEncrypt: (value: any, aesKey: string, handle?: any) => any;
|
|
2
|
-
export declare const AESDecrypt: (value: string, aesKey: string, handle?: any) =>
|
|
2
|
+
export declare const AESDecrypt: (value: string, aesKey: string, handle?: any) => string;
|
|
@@ -1,26 +1,6 @@
|
|
|
1
|
-
import CryptoJS from 'crypto-js';
|
|
2
1
|
export var AESEncrypt = function AESEncrypt(value, aesKey, handle) {
|
|
3
|
-
|
|
4
|
-
return handle(value, aesKey, CryptoJS);
|
|
5
|
-
}
|
|
6
|
-
var key = CryptoJS.enc.Utf8.parse(aesKey);
|
|
7
|
-
var ciphertext = CryptoJS.enc.Utf8.parse(value);
|
|
8
|
-
var encrypted = CryptoJS.AES.encrypt(ciphertext, key, {
|
|
9
|
-
mode: CryptoJS.mode.ECB,
|
|
10
|
-
padding: CryptoJS.pad.Pkcs7
|
|
11
|
-
});
|
|
12
|
-
return encrypted.toString();
|
|
2
|
+
return value;
|
|
13
3
|
};
|
|
14
4
|
export var AESDecrypt = function AESDecrypt(value, aesKey, handle) {
|
|
15
|
-
|
|
16
|
-
return handle(value, aesKey, CryptoJS);
|
|
17
|
-
}
|
|
18
|
-
var key = CryptoJS.enc.Utf8.parse(aesKey);
|
|
19
|
-
var ciphertext = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Base64.parse(value));
|
|
20
|
-
// const ciphertext = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Base64.parse(CryptoJS.enc.Utf8.parse(value).toString(CryptoJS.enc.Utf8)));
|
|
21
|
-
var encrypted = CryptoJS.AES.decrypt(ciphertext, key, {
|
|
22
|
-
mode: CryptoJS.mode.ECB,
|
|
23
|
-
padding: CryptoJS.pad.Pkcs7
|
|
24
|
-
});
|
|
25
|
-
return encrypted.toString(CryptoJS.enc.Utf8);
|
|
5
|
+
return value;
|
|
26
6
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const DESEncrypt: (value: string, aesKey: string, handle?: any) =>
|
|
2
|
-
export declare const DESDecrypt: (value: string, aesKey: string, handle?: any) =>
|
|
1
|
+
export declare const DESEncrypt: (value: string, aesKey: string, handle?: any) => string;
|
|
2
|
+
export declare const DESDecrypt: (value: string, aesKey: string, handle?: any) => string;
|
|
@@ -1,25 +1,6 @@
|
|
|
1
|
-
import CryptoJS from 'crypto-js';
|
|
2
1
|
export var DESEncrypt = function DESEncrypt(value, aesKey, handle) {
|
|
3
|
-
|
|
4
|
-
return handle(value, aesKey, CryptoJS);
|
|
5
|
-
}
|
|
6
|
-
var key = CryptoJS.enc.Utf8.parse(aesKey);
|
|
7
|
-
var ciphertext = CryptoJS.enc.Utf8.parse(value);
|
|
8
|
-
var encrypted = CryptoJS.DES.encrypt(ciphertext, key, {
|
|
9
|
-
mode: CryptoJS.mode.ECB,
|
|
10
|
-
padding: CryptoJS.pad.Pkcs7
|
|
11
|
-
});
|
|
12
|
-
return encrypted.toString();
|
|
2
|
+
return value;
|
|
13
3
|
};
|
|
14
4
|
export var DESDecrypt = function DESDecrypt(value, aesKey, handle) {
|
|
15
|
-
|
|
16
|
-
return handle(value, aesKey, CryptoJS);
|
|
17
|
-
}
|
|
18
|
-
var key = CryptoJS.enc.Utf8.parse(aesKey);
|
|
19
|
-
var ciphertext = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Base64.parse(value));
|
|
20
|
-
var encrypted = CryptoJS.DES.decrypt(ciphertext, key, {
|
|
21
|
-
mode: CryptoJS.mode.ECB,
|
|
22
|
-
padding: CryptoJS.pad.Pkcs7
|
|
23
|
-
});
|
|
24
|
-
return encrypted.toString(CryptoJS.enc.Utf8);
|
|
5
|
+
return value;
|
|
25
6
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const RSAEncrypt: (value: string, publicKey: string, handle?: any) =>
|
|
2
|
-
export declare const RSADecrypt: (value: string, privKey: string, handle?: any) =>
|
|
1
|
+
export declare const RSAEncrypt: (value: string, publicKey: string, handle?: any) => string;
|
|
2
|
+
export declare const RSADecrypt: (value: string, privKey: string, handle?: any) => string;
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import JSEncrypt from 'jsencrypt';
|
|
2
1
|
export var RSAEncrypt = function RSAEncrypt(value, publicKey, handle) {
|
|
3
|
-
|
|
4
|
-
return handle(value, publicKey, JSEncrypt);
|
|
5
|
-
}
|
|
6
|
-
var encryptor = new JSEncrypt();
|
|
7
|
-
encryptor.setPublicKey(publicKey);
|
|
8
|
-
return encryptor.encrypt(value);
|
|
2
|
+
return value;
|
|
9
3
|
};
|
|
10
4
|
export var RSADecrypt = function RSADecrypt(value, privKey, handle) {
|
|
11
|
-
|
|
12
|
-
return handle(value, privKey, JSEncrypt);
|
|
13
|
-
}
|
|
14
|
-
var decrypt = new JSEncrypt();
|
|
15
|
-
decrypt.setPrivateKey(privKey);
|
|
16
|
-
return decrypt.decrypt(value);
|
|
5
|
+
return value;
|
|
17
6
|
};
|
|
@@ -7,6 +7,7 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
|
|
|
7
7
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
8
8
|
import { sha256 } from 'js-sha256';
|
|
9
9
|
import { obj2QueryString } from '../../utils/url';
|
|
10
|
+
import CookieUtil from '../../utils/cookieUtil';
|
|
10
11
|
var SIGN_KEY = process.env.LING_XI_HTTP_SIGN_KEY || 'zrT5bi2escXilaH1fs653uZiH9RWfzCS';
|
|
11
12
|
// 注意:修改此文件请跑测试用例, npm run test
|
|
12
13
|
// 1、签名算法:
|
|
@@ -29,6 +30,7 @@ var SIGN_KEY = process.env.LING_XI_HTTP_SIGN_KEY || 'zrT5bi2escXilaH1fs653uZiH9R
|
|
|
29
30
|
// 由于X-B 的规则可能被业务网关使用,并往请求头增加内容,导致前后端加密不一致
|
|
30
31
|
// 2022.08.09 使用以下3个固定值 + X-LX-*匹配 方式
|
|
31
32
|
var hKeys = ['X-B-AUTH', 'X-B-TARGET-ID', 'APP-ID'];
|
|
33
|
+
var userKeyInCookie = process.env.LING_XI_USER_KEY_IN_COOKIE || 'X-LX-N-ID';
|
|
32
34
|
// 配置指定接口前缀,2023-03-16规则调整,不需要使用
|
|
33
35
|
// const apiPrefix =
|
|
34
36
|
// process.env.LING_XI_HTTP_SIGN_API_PERFIX ||
|
|
@@ -77,8 +79,10 @@ export var createHttpSignStr = function createHttpSignStr(url, options) {
|
|
|
77
79
|
} else {
|
|
78
80
|
params = _typeof(body) === 'object' ? JSON.stringify(body) : body;
|
|
79
81
|
}
|
|
82
|
+
// 获取参数4: 用户id
|
|
83
|
+
var userId = CookieUtil.get(userKeyInCookie) || '';
|
|
80
84
|
// 组装加密字符串
|
|
81
|
-
var str = [apiPath, headerParams, params, SIGN_KEY].join('#');
|
|
85
|
+
var str = [apiPath, headerParams, params, userId, SIGN_KEY].join('#');
|
|
82
86
|
if (typeof window !== 'undefined' && (window.lxDebug || window.localStorage.getItem('lxDebug'))) {
|
|
83
87
|
console.log(' --- signDebug ---');
|
|
84
88
|
console.log('url', url);
|
package/es/security/index.d.ts
CHANGED
|
@@ -22,12 +22,12 @@ declare const _default: {
|
|
|
22
22
|
createHttpSignStr: (url: string, options: any) => string;
|
|
23
23
|
getApiPath: (url: string) => string | undefined;
|
|
24
24
|
};
|
|
25
|
-
RSAEncrypt: (value: string, publicKey: string, handle?: any) =>
|
|
26
|
-
RSADecrypt: (value: string, privKey: string, handle?: any) =>
|
|
25
|
+
RSAEncrypt: (value: string, publicKey: string, handle?: any) => string;
|
|
26
|
+
RSADecrypt: (value: string, privKey: string, handle?: any) => string;
|
|
27
27
|
AESEncrypt: (value: any, aesKey: string, handle?: any) => any;
|
|
28
|
-
AESDecrypt: (value: string, aesKey: string, handle?: any) =>
|
|
29
|
-
DESEncrypt: (value: string, aesKey: string, handle?: any) =>
|
|
30
|
-
DESDecrypt: (value: string, aesKey: string, handle?: any) =>
|
|
28
|
+
AESDecrypt: (value: string, aesKey: string, handle?: any) => string;
|
|
29
|
+
DESEncrypt: (value: string, aesKey: string, handle?: any) => string;
|
|
30
|
+
DESDecrypt: (value: string, aesKey: string, handle?: any) => string;
|
|
31
31
|
KEYS: {
|
|
32
32
|
signKey: string;
|
|
33
33
|
rsaPublicKey: string | undefined;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var CookieUtil = {
|
|
2
|
+
get: function get(name) {
|
|
3
|
+
var cookieName = "".concat(encodeURIComponent(name), "=");
|
|
4
|
+
var cookieStart = document.cookie.indexOf(cookieName);
|
|
5
|
+
var cookieValue = null;
|
|
6
|
+
var cookieEnd;
|
|
7
|
+
if (cookieStart > -1) {
|
|
8
|
+
cookieEnd = document.cookie.indexOf(';', cookieStart);
|
|
9
|
+
if (cookieEnd === -1) {
|
|
10
|
+
cookieEnd = document.cookie.length;
|
|
11
|
+
}
|
|
12
|
+
cookieValue = decodeURIComponent(document.cookie.substring(cookieStart + cookieName.length, cookieEnd));
|
|
13
|
+
}
|
|
14
|
+
return cookieValue;
|
|
15
|
+
},
|
|
16
|
+
set: function set(name, value, expires, path, domain, secure) {
|
|
17
|
+
var cookieText = "".concat(encodeURIComponent(name), "=").concat(encodeURIComponent(value));
|
|
18
|
+
if (expires instanceof Date) {
|
|
19
|
+
cookieText += "; expires=".concat(expires.toGMTString());
|
|
20
|
+
}
|
|
21
|
+
if (path) {
|
|
22
|
+
cookieText += "; path=".concat(path);
|
|
23
|
+
}
|
|
24
|
+
if (domain) {
|
|
25
|
+
cookieText += "; domain=".concat(domain);
|
|
26
|
+
}
|
|
27
|
+
if (secure) {
|
|
28
|
+
cookieText += '; secure';
|
|
29
|
+
}
|
|
30
|
+
document.cookie = cookieText;
|
|
31
|
+
},
|
|
32
|
+
unset: function unset(name, path, domain, secure) {
|
|
33
|
+
this.set(name, '', new Date(0), path, domain, secure);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export default CookieUtil;
|
package/lib/index.js
CHANGED
|
@@ -3,12 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "ErrorMsg", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _error.ErrorMsg;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
6
|
exports.IconNormalCheckSvg = exports.IconCheckSvg = void 0;
|
|
13
7
|
Object.defineProperty(exports, "MobileErrorMsg", {
|
|
14
8
|
enumerable: true,
|