yuang-framework-ui-common 1.0.26 → 1.0.28
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/lib/config/httpConfig.ts +6 -5
- package/lib/utils/ssoUtils.ts +21 -1
- package/lib/utils/uuidUtils.ts +1 -1
- package/package.json +1 -1
package/lib/config/httpConfig.ts
CHANGED
@@ -51,19 +51,19 @@ http.interceptors.response.use((res) => {
|
|
51
51
|
callback: (action: string) => {
|
52
52
|
if (action === 'confirm') {
|
53
53
|
clearSsoAccessToken();
|
54
|
-
location.href = getSsoLoginUrl();
|
54
|
+
window.location.href = getSsoLoginUrl() || '';
|
55
55
|
}
|
56
56
|
}
|
57
57
|
});
|
58
58
|
return Promise.reject(new Error(res?.data?.message));
|
59
59
|
} else if (res?.data?.statusCode === 822001) {
|
60
60
|
clearGatewayConfig();
|
61
|
-
showErrorMessage(messageMap.requestError);
|
61
|
+
showErrorMessage(messageMap.requestError || messageMap.requestError);
|
62
62
|
return Promise.reject(new Error(res?.data?.message));
|
63
63
|
} else if (res?.data?.statusCode === 815001) {
|
64
|
-
showErrorMessage(res?.data?.message);
|
64
|
+
showErrorMessage(res?.data?.message || messageMap.requestError);
|
65
65
|
clearSsoAccessToken();
|
66
|
-
location.href = getSsoLoginUrl();
|
66
|
+
window.location.href = getSsoLoginUrl() || '';
|
67
67
|
return Promise.reject(new Error(res?.data?.message));
|
68
68
|
} else if (res?.data?.statusCode === 815002) {
|
69
69
|
axios.get('/sso-api/client/auth/getSsoRefreshToken').then(res => {
|
@@ -72,7 +72,7 @@ http.interceptors.response.use((res) => {
|
|
72
72
|
return axios.request(res.config);
|
73
73
|
})
|
74
74
|
} else if (res?.data?.statusCode === 815003) {
|
75
|
-
showErrorMessage(res?.data?.message);
|
75
|
+
showErrorMessage(res?.data?.message || messageMap.requestError);
|
76
76
|
return Promise.reject(new Error(res?.data?.message));
|
77
77
|
}
|
78
78
|
|
@@ -87,6 +87,7 @@ http.interceptors.response.use((res) => {
|
|
87
87
|
if (statusCode !== 200) {
|
88
88
|
errorMessage = message;
|
89
89
|
}
|
90
|
+
errorMessage = errorMessage || messageMap.requestError
|
90
91
|
} else {
|
91
92
|
errorMessage = error?.message || messageMap.requestError;
|
92
93
|
}
|
package/lib/utils/ssoUtils.ts
CHANGED
@@ -64,6 +64,25 @@ const getSsoEncrypt = (password = '') => {
|
|
64
64
|
return {encryptPassword, rsaAesKey};
|
65
65
|
}
|
66
66
|
|
67
|
+
/**
|
68
|
+
* 获取sso加密参数列表
|
69
|
+
* @param password
|
70
|
+
*/
|
71
|
+
const getSsoEncryptList = (passwordList = []) => {
|
72
|
+
let gatewayPublicKey = getLocalStorageItem('gatewayPublicKey');
|
73
|
+
// 每次请求生成aeskey
|
74
|
+
let aesKey = getAesRandomKey();
|
75
|
+
// 用登陆后后端生成并返回给前端的的RSA密钥对的公钥将AES16位密钥进行加密
|
76
|
+
const rsaAesKey = rsaEncrypt(gatewayPublicKey, aesKey);
|
77
|
+
// 使用AES16位的密钥将请求报文加密(使用的是加密前的aes密钥)
|
78
|
+
const encryptPasswordList = [];
|
79
|
+
for (let i = 0; i < passwordList.length; i++) {
|
80
|
+
encryptPasswordList[i] = aesEncrypt(aesKey, passwordList[i]);
|
81
|
+
}
|
82
|
+
|
83
|
+
return {encryptPasswordList, rsaAesKey};
|
84
|
+
}
|
85
|
+
|
67
86
|
|
68
87
|
const ssoAccessTokenCookieKey: string = 'Sso-Access-Token';
|
69
88
|
const ssoAccessTokenLocalKey: string = 'ssoAccessToken';
|
@@ -101,7 +120,7 @@ const clearSsoAccessToken = () => {
|
|
101
120
|
|
102
121
|
const logoutSso = () => {
|
103
122
|
clearSsoAccessToken();
|
104
|
-
window.location.href = getSsoLogoutUrl();
|
123
|
+
window.location.href = getSsoLogoutUrl() || '';
|
105
124
|
}
|
106
125
|
|
107
126
|
|
@@ -111,6 +130,7 @@ export {
|
|
111
130
|
getSsoLoginRoutePath,
|
112
131
|
|
113
132
|
getSsoEncrypt,
|
133
|
+
getSsoEncryptList,
|
114
134
|
|
115
135
|
getSsoAccessToken,
|
116
136
|
setSsoAccessToken,
|
package/lib/utils/uuidUtils.ts
CHANGED