@nocios/crudify-ui 3.0.24 → 3.0.26

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 CHANGED
@@ -820,9 +820,17 @@ var SessionManager = class _SessionManager {
820
820
  setupResponseInterceptor() {
821
821
  import_crudify_browser2.default.setResponseInterceptor(async (response) => {
822
822
  if (response.errors) {
823
- const hasAuthError = response.errors.some(
824
- (error) => error.message?.includes("Unauthorized") || error.message?.includes("Token") || error.extensions?.code === "UNAUTHENTICATED"
825
- );
823
+ let hasAuthError = false;
824
+ if (Array.isArray(response.errors)) {
825
+ hasAuthError = response.errors.some(
826
+ (error) => error.message?.includes("Unauthorized") || error.message?.includes("Token") || error.extensions?.code === "UNAUTHENTICATED" || error.message?.includes("NOT_AUTHORIZED")
827
+ );
828
+ } else if (typeof response.errors === "object") {
829
+ const errorMessages = Object.values(response.errors).flat();
830
+ hasAuthError = errorMessages.some(
831
+ (message) => typeof message === "string" && (message.includes("NOT_AUTHORIZED") || message.includes("Unauthorized") || message.includes("UNAUTHENTICATED") || message.includes("Token"))
832
+ );
833
+ }
826
834
  if (hasAuthError && TokenStorage.hasValidTokens()) {
827
835
  this.log("Auth error detected, attempting token refresh...");
828
836
  const refreshSuccess = await this.refreshTokens();
package/dist/index.mjs CHANGED
@@ -747,9 +747,17 @@ var SessionManager = class _SessionManager {
747
747
  setupResponseInterceptor() {
748
748
  crudify2.setResponseInterceptor(async (response) => {
749
749
  if (response.errors) {
750
- const hasAuthError = response.errors.some(
751
- (error) => error.message?.includes("Unauthorized") || error.message?.includes("Token") || error.extensions?.code === "UNAUTHENTICATED"
752
- );
750
+ let hasAuthError = false;
751
+ if (Array.isArray(response.errors)) {
752
+ hasAuthError = response.errors.some(
753
+ (error) => error.message?.includes("Unauthorized") || error.message?.includes("Token") || error.extensions?.code === "UNAUTHENTICATED" || error.message?.includes("NOT_AUTHORIZED")
754
+ );
755
+ } else if (typeof response.errors === "object") {
756
+ const errorMessages = Object.values(response.errors).flat();
757
+ hasAuthError = errorMessages.some(
758
+ (message) => typeof message === "string" && (message.includes("NOT_AUTHORIZED") || message.includes("Unauthorized") || message.includes("UNAUTHENTICATED") || message.includes("Token"))
759
+ );
760
+ }
753
761
  if (hasAuthError && TokenStorage.hasValidTokens()) {
754
762
  this.log("Auth error detected, attempting token refresh...");
755
763
  const refreshSuccess = await this.refreshTokens();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocios/crudify-ui",
3
- "version": "3.0.24",
3
+ "version": "3.0.26",
4
4
  "description": "Biblioteca de componentes UI para Crudify",
5
5
  "author": "Nocios",
6
6
  "license": "MIT",