@nocios/crudify-ui 3.0.28 → 3.0.40
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.js +28 -6
- package/dist/index.mjs +28 -6
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -819,6 +819,9 @@ var SessionManager = class _SessionManager {
|
|
|
819
819
|
*/
|
|
820
820
|
setupResponseInterceptor() {
|
|
821
821
|
import_crudify_browser2.default.setResponseInterceptor(async (response) => {
|
|
822
|
+
if (response.errors) {
|
|
823
|
+
this.log("Response interceptor - received response with errors:", response);
|
|
824
|
+
}
|
|
822
825
|
if (response.errors) {
|
|
823
826
|
let hasAuthError = false;
|
|
824
827
|
if (Array.isArray(response.errors)) {
|
|
@@ -828,16 +831,35 @@ var SessionManager = class _SessionManager {
|
|
|
828
831
|
} else if (typeof response.errors === "object") {
|
|
829
832
|
const errorMessages = Object.values(response.errors).flat();
|
|
830
833
|
hasAuthError = errorMessages.some(
|
|
831
|
-
(message) => typeof message === "string" && (message.includes("NOT_AUTHORIZED") || message.includes("Unauthorized") || message.includes("UNAUTHENTICATED") || message.includes("Token"))
|
|
834
|
+
(message) => typeof message === "string" && (message.includes("NOT_AUTHORIZED") || message.includes("TOKEN_REFRESH_FAILED") || message.includes("PLEASE_LOGIN") || message.includes("Unauthorized") || message.includes("UNAUTHENTICATED") || message.includes("Token"))
|
|
832
835
|
);
|
|
833
836
|
}
|
|
834
|
-
if (hasAuthError &&
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
837
|
+
if (!hasAuthError && response.errorCode) {
|
|
838
|
+
const errorCode = response.errorCode;
|
|
839
|
+
hasAuthError = errorCode === "UNAUTHORIZED" || errorCode === "UNAUTHENTICATED" || errorCode === "TOKEN_EXPIRED";
|
|
840
|
+
}
|
|
841
|
+
if (hasAuthError) {
|
|
842
|
+
this.log("Auth error detected in response interceptor");
|
|
843
|
+
const isRefreshTokenFailed = response.errors && typeof response.errors === "object" && Object.values(response.errors).flat().some(
|
|
844
|
+
(message) => typeof message === "string" && message.includes("TOKEN_REFRESH_FAILED")
|
|
845
|
+
);
|
|
846
|
+
if (isRefreshTokenFailed) {
|
|
847
|
+
this.log("Refresh token failed, clearing tokens and triggering session expired");
|
|
848
|
+
TokenStorage.clearTokens();
|
|
849
|
+
this.config.onSessionExpired?.();
|
|
850
|
+
} else if (TokenStorage.hasValidTokens()) {
|
|
851
|
+
this.log("Auth error detected, attempting token refresh...");
|
|
852
|
+
const refreshSuccess = await this.refreshTokens();
|
|
853
|
+
if (!refreshSuccess) {
|
|
854
|
+
this.log("Session expired, triggering callback");
|
|
855
|
+
this.config.onSessionExpired?.();
|
|
856
|
+
}
|
|
857
|
+
} else {
|
|
858
|
+
this.log("Auth error but no valid tokens, triggering session expired");
|
|
839
859
|
this.config.onSessionExpired?.();
|
|
840
860
|
}
|
|
861
|
+
} else {
|
|
862
|
+
this.log("No auth error detected in response");
|
|
841
863
|
}
|
|
842
864
|
}
|
|
843
865
|
return response;
|
package/dist/index.mjs
CHANGED
|
@@ -746,6 +746,9 @@ var SessionManager = class _SessionManager {
|
|
|
746
746
|
*/
|
|
747
747
|
setupResponseInterceptor() {
|
|
748
748
|
crudify2.setResponseInterceptor(async (response) => {
|
|
749
|
+
if (response.errors) {
|
|
750
|
+
this.log("Response interceptor - received response with errors:", response);
|
|
751
|
+
}
|
|
749
752
|
if (response.errors) {
|
|
750
753
|
let hasAuthError = false;
|
|
751
754
|
if (Array.isArray(response.errors)) {
|
|
@@ -755,16 +758,35 @@ var SessionManager = class _SessionManager {
|
|
|
755
758
|
} else if (typeof response.errors === "object") {
|
|
756
759
|
const errorMessages = Object.values(response.errors).flat();
|
|
757
760
|
hasAuthError = errorMessages.some(
|
|
758
|
-
(message) => typeof message === "string" && (message.includes("NOT_AUTHORIZED") || message.includes("Unauthorized") || message.includes("UNAUTHENTICATED") || message.includes("Token"))
|
|
761
|
+
(message) => typeof message === "string" && (message.includes("NOT_AUTHORIZED") || message.includes("TOKEN_REFRESH_FAILED") || message.includes("PLEASE_LOGIN") || message.includes("Unauthorized") || message.includes("UNAUTHENTICATED") || message.includes("Token"))
|
|
759
762
|
);
|
|
760
763
|
}
|
|
761
|
-
if (hasAuthError &&
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
764
|
+
if (!hasAuthError && response.errorCode) {
|
|
765
|
+
const errorCode = response.errorCode;
|
|
766
|
+
hasAuthError = errorCode === "UNAUTHORIZED" || errorCode === "UNAUTHENTICATED" || errorCode === "TOKEN_EXPIRED";
|
|
767
|
+
}
|
|
768
|
+
if (hasAuthError) {
|
|
769
|
+
this.log("Auth error detected in response interceptor");
|
|
770
|
+
const isRefreshTokenFailed = response.errors && typeof response.errors === "object" && Object.values(response.errors).flat().some(
|
|
771
|
+
(message) => typeof message === "string" && message.includes("TOKEN_REFRESH_FAILED")
|
|
772
|
+
);
|
|
773
|
+
if (isRefreshTokenFailed) {
|
|
774
|
+
this.log("Refresh token failed, clearing tokens and triggering session expired");
|
|
775
|
+
TokenStorage.clearTokens();
|
|
776
|
+
this.config.onSessionExpired?.();
|
|
777
|
+
} else if (TokenStorage.hasValidTokens()) {
|
|
778
|
+
this.log("Auth error detected, attempting token refresh...");
|
|
779
|
+
const refreshSuccess = await this.refreshTokens();
|
|
780
|
+
if (!refreshSuccess) {
|
|
781
|
+
this.log("Session expired, triggering callback");
|
|
782
|
+
this.config.onSessionExpired?.();
|
|
783
|
+
}
|
|
784
|
+
} else {
|
|
785
|
+
this.log("Auth error but no valid tokens, triggering session expired");
|
|
766
786
|
this.config.onSessionExpired?.();
|
|
767
787
|
}
|
|
788
|
+
} else {
|
|
789
|
+
this.log("No auth error detected in response");
|
|
768
790
|
}
|
|
769
791
|
}
|
|
770
792
|
return response;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocios/crudify-ui",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.40",
|
|
4
4
|
"description": "Biblioteca de componentes UI para Crudify",
|
|
5
5
|
"author": "Nocios",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@mui/icons-material": "^7.1.0",
|
|
26
26
|
"@mui/material": "^7.1.0",
|
|
27
27
|
"@mui/x-data-grid": "^8.5.1",
|
|
28
|
-
"@nocios/crudify-browser": "^2.0.
|
|
28
|
+
"@nocios/crudify-browser": "^2.0.1",
|
|
29
29
|
"@types/uuid": "^10.0.0",
|
|
30
30
|
"crypto-js": "^4.2.0",
|
|
31
31
|
"i18next-browser-languagedetector": "^8.1.0",
|