@mu-cabin/opms-permission 0.8.1 → 0.8.3

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 CHANGED
@@ -206,9 +206,12 @@ axiosClient.interceptors.request.use((config) => {
206
206
  axiosClient.interceptors.response.use(
207
207
  (response) => {
208
208
  const res = response.data;
209
- const { code, msg } = res;
210
- if (code !== 200) {
211
- throw new Error(msg);
209
+ const { success, code, msg } = res;
210
+ if (!success) {
211
+ return Promise.reject({
212
+ code,
213
+ msg
214
+ });
212
215
  }
213
216
  return res;
214
217
  },
@@ -547,7 +550,7 @@ function jumpToSSOLogout({
547
550
  }
548
551
  const { location } = window;
549
552
  const ssoLoginUrl = `${baseUrl}/idp/oauth2/authorize?client_id=${clientId}&response_type=code&redirect_uri=${location.origin}/`;
550
- const redirectUrl = encodeURIComponent(redirectToUrl || ssoLoginUrl);
553
+ const redirectUrl = redirectToUrl || ssoLoginUrl;
551
554
  const logoutUrl = new URL(`${baseUrl}/idp/profile/OAUTH2/Redirect/GLO`);
552
555
  logoutUrl.searchParams.set("response_type", "code");
553
556
  logoutUrl.searchParams.set("entityId", clientId);
package/dist/index.mjs CHANGED
@@ -168,9 +168,12 @@ axiosClient.interceptors.request.use((config) => {
168
168
  axiosClient.interceptors.response.use(
169
169
  (response) => {
170
170
  const res = response.data;
171
- const { code, msg } = res;
172
- if (code !== 200) {
173
- throw new Error(msg);
171
+ const { success, code, msg } = res;
172
+ if (!success) {
173
+ return Promise.reject({
174
+ code,
175
+ msg
176
+ });
174
177
  }
175
178
  return res;
176
179
  },
@@ -509,7 +512,7 @@ function jumpToSSOLogout({
509
512
  }
510
513
  const { location } = window;
511
514
  const ssoLoginUrl = `${baseUrl}/idp/oauth2/authorize?client_id=${clientId}&response_type=code&redirect_uri=${location.origin}/`;
512
- const redirectUrl = encodeURIComponent(redirectToUrl || ssoLoginUrl);
515
+ const redirectUrl = redirectToUrl || ssoLoginUrl;
513
516
  const logoutUrl = new URL(`${baseUrl}/idp/profile/OAUTH2/Redirect/GLO`);
514
517
  logoutUrl.searchParams.set("response_type", "code");
515
518
  logoutUrl.searchParams.set("entityId", clientId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mu-cabin/opms-permission",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "description": "Frontend SDK for OPMS permission and auth management.",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",