@nocios/crudify-ui 1.0.87 → 1.0.89
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 +88 -29
- package/dist/index.mjs +88 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2597,19 +2597,25 @@ var _TokenManager = class _TokenManager {
|
|
|
2597
2597
|
* Load token from storage and synchronize with crudify
|
|
2598
2598
|
*/
|
|
2599
2599
|
loadTokenFromStorage() {
|
|
2600
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Entry point - loading token from storage");
|
|
2600
2601
|
try {
|
|
2602
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Getting token from secure session storage");
|
|
2601
2603
|
const storedToken = secureSessionStorage.getToken();
|
|
2604
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Stored token exists:", !!storedToken);
|
|
2602
2605
|
if (storedToken && this.isTokenValid(storedToken)) {
|
|
2606
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Stored token is valid, updating cache");
|
|
2603
2607
|
this.tokenCache = storedToken;
|
|
2604
2608
|
this.parsedTokenCache = this.parseToken(storedToken);
|
|
2605
2609
|
this.syncTokenWithCrudify(storedToken);
|
|
2606
|
-
console.log("\u{1F510} TokenManager - Token loaded from storage and synchronized");
|
|
2610
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Token loaded from storage and synchronized");
|
|
2607
2611
|
} else if (storedToken) {
|
|
2608
|
-
console.log("\u{1F510} TokenManager -
|
|
2612
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Stored token exists but is invalid/expired, clearing");
|
|
2609
2613
|
this.clearToken();
|
|
2614
|
+
} else {
|
|
2615
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: No stored token found");
|
|
2610
2616
|
}
|
|
2611
2617
|
} catch (error) {
|
|
2612
|
-
console.warn("\u{1F510} TokenManager - Error loading token from storage:", error);
|
|
2618
|
+
console.warn("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Error loading token from storage:", error);
|
|
2613
2619
|
this.clearToken();
|
|
2614
2620
|
}
|
|
2615
2621
|
}
|
|
@@ -2640,23 +2646,29 @@ var _TokenManager = class _TokenManager {
|
|
|
2640
2646
|
* Set a new JWT token with automatic synchronization
|
|
2641
2647
|
*/
|
|
2642
2648
|
setToken(token) {
|
|
2649
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: Entry point - setting token:", token ? "provided" : "null");
|
|
2643
2650
|
try {
|
|
2644
2651
|
if (!token) {
|
|
2652
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: No token provided, clearing token");
|
|
2645
2653
|
this.clearToken();
|
|
2646
2654
|
return;
|
|
2647
2655
|
}
|
|
2656
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: Validating token before setting");
|
|
2648
2657
|
if (!this.isTokenValid(token)) {
|
|
2649
|
-
console.warn("\u{1F510} TokenManager - Attempted to set invalid or expired token");
|
|
2658
|
+
console.warn("\u{1F510} TokenManager - SET_TOKEN: Attempted to set invalid or expired token");
|
|
2650
2659
|
this.clearToken();
|
|
2651
2660
|
return;
|
|
2652
2661
|
}
|
|
2662
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: Token is valid, updating cache");
|
|
2653
2663
|
this.tokenCache = token;
|
|
2654
2664
|
this.parsedTokenCache = this.parseToken(token);
|
|
2665
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: Storing token in secure storage");
|
|
2655
2666
|
secureSessionStorage.setToken(token);
|
|
2667
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: Synchronizing with crudify");
|
|
2656
2668
|
this.syncTokenWithCrudify(token);
|
|
2657
|
-
console.log("\u{1F510} TokenManager - Token set and synchronized successfully");
|
|
2669
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: Token set and synchronized successfully");
|
|
2658
2670
|
} catch (error) {
|
|
2659
|
-
console.error("\u{1F510} TokenManager - Error setting token:", error);
|
|
2671
|
+
console.error("\u{1F510} TokenManager - SET_TOKEN: Error setting token:", error);
|
|
2660
2672
|
this.clearToken();
|
|
2661
2673
|
}
|
|
2662
2674
|
}
|
|
@@ -2664,25 +2676,44 @@ var _TokenManager = class _TokenManager {
|
|
|
2664
2676
|
* Get the current JWT token
|
|
2665
2677
|
*/
|
|
2666
2678
|
getToken() {
|
|
2667
|
-
|
|
2668
|
-
|
|
2679
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: Entry point - checking cache");
|
|
2680
|
+
if (this.tokenCache) {
|
|
2681
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: Cache exists, validating token");
|
|
2682
|
+
if (this.isTokenValid(this.tokenCache)) {
|
|
2683
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: Cache valid, returning cached token");
|
|
2684
|
+
return this.tokenCache;
|
|
2685
|
+
} else {
|
|
2686
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: Cache invalid, clearing cache");
|
|
2687
|
+
this.tokenCache = null;
|
|
2688
|
+
}
|
|
2689
|
+
} else {
|
|
2690
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: No cache, loading from storage");
|
|
2669
2691
|
}
|
|
2692
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: Loading from storage");
|
|
2670
2693
|
this.loadTokenFromStorage();
|
|
2694
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: Returning final token:", !!this.tokenCache);
|
|
2671
2695
|
return this.tokenCache;
|
|
2672
2696
|
}
|
|
2673
2697
|
/**
|
|
2674
2698
|
* Parse the current JWT token
|
|
2675
2699
|
*/
|
|
2676
2700
|
parseToken(token) {
|
|
2677
|
-
|
|
2701
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Entry point - parsing token");
|
|
2702
|
+
const targetToken = token !== void 0 ? token : this.tokenCache;
|
|
2703
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Target token exists:", !!targetToken);
|
|
2678
2704
|
if (!targetToken) {
|
|
2705
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: No target token, returning null");
|
|
2679
2706
|
return null;
|
|
2680
2707
|
}
|
|
2681
2708
|
if (this.tokenCache === targetToken && this.parsedTokenCache) {
|
|
2709
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Returning cached parsed token");
|
|
2682
2710
|
return this.parsedTokenCache;
|
|
2683
2711
|
}
|
|
2712
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Cache miss, parsing token with decodeJwtSafely");
|
|
2684
2713
|
const parsed = decodeJwtSafely(targetToken);
|
|
2714
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Token parsed successfully:", !!parsed);
|
|
2685
2715
|
if (targetToken === this.tokenCache) {
|
|
2716
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Updating parsed token cache");
|
|
2686
2717
|
this.parsedTokenCache = parsed;
|
|
2687
2718
|
}
|
|
2688
2719
|
return parsed;
|
|
@@ -2691,17 +2722,26 @@ var _TokenManager = class _TokenManager {
|
|
|
2691
2722
|
* Check if a token is valid (properly formatted and not expired)
|
|
2692
2723
|
*/
|
|
2693
2724
|
isTokenValid(token) {
|
|
2694
|
-
|
|
2725
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Entry point - checking token validity");
|
|
2726
|
+
const targetToken = token !== void 0 ? token : this.tokenCache;
|
|
2727
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Target token exists:", !!targetToken);
|
|
2695
2728
|
if (!targetToken) {
|
|
2729
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: No token, returning false");
|
|
2696
2730
|
return false;
|
|
2697
2731
|
}
|
|
2698
2732
|
try {
|
|
2733
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Checking if token is expired");
|
|
2699
2734
|
if (isTokenExpired(targetToken)) {
|
|
2735
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Token is expired, returning false");
|
|
2700
2736
|
return false;
|
|
2701
2737
|
}
|
|
2738
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Token not expired, checking if can be parsed");
|
|
2702
2739
|
const parsed = decodeJwtSafely(targetToken);
|
|
2703
|
-
|
|
2704
|
-
|
|
2740
|
+
const isValid = parsed !== null;
|
|
2741
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Token parsing result:", isValid);
|
|
2742
|
+
return isValid;
|
|
2743
|
+
} catch (error) {
|
|
2744
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Error validating token:", error);
|
|
2705
2745
|
return false;
|
|
2706
2746
|
}
|
|
2707
2747
|
}
|
|
@@ -2719,14 +2759,18 @@ var _TokenManager = class _TokenManager {
|
|
|
2719
2759
|
* Clear the current token from all storages and crudify
|
|
2720
2760
|
*/
|
|
2721
2761
|
clearToken() {
|
|
2762
|
+
console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Entry point - clearing all tokens");
|
|
2722
2763
|
try {
|
|
2764
|
+
console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Clearing cache");
|
|
2723
2765
|
this.tokenCache = null;
|
|
2724
2766
|
this.parsedTokenCache = null;
|
|
2767
|
+
console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Clearing from secure storage");
|
|
2725
2768
|
secureSessionStorage.removeItem(this.TOKEN_KEY);
|
|
2769
|
+
console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Clearing from crudify");
|
|
2726
2770
|
import_crudify_browser4.default.setToken("");
|
|
2727
|
-
console.log("\u{1F510} TokenManager - Token cleared from all storages");
|
|
2771
|
+
console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Token cleared from all storages successfully");
|
|
2728
2772
|
} catch (error) {
|
|
2729
|
-
console.warn("\u{1F510} TokenManager - Error clearing token:", error);
|
|
2773
|
+
console.warn("\u{1F510} TokenManager - CLEAR_TOKEN: Error clearing token:", error);
|
|
2730
2774
|
}
|
|
2731
2775
|
}
|
|
2732
2776
|
/**
|
|
@@ -2900,20 +2944,34 @@ var CrudifyDataProvider = ({
|
|
|
2900
2944
|
}
|
|
2901
2945
|
}, []);
|
|
2902
2946
|
const updateAuthenticationState = (0, import_react12.useCallback)(() => {
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2947
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Starting authentication state update");
|
|
2948
|
+
try {
|
|
2949
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Getting token from TokenManager");
|
|
2950
|
+
const currentToken = tokenManager.getToken();
|
|
2951
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Token retrieved:", !!currentToken);
|
|
2952
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Parsing token");
|
|
2953
|
+
const parsedUser = tokenManager.parseToken();
|
|
2954
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Token parsed:", !!parsedUser);
|
|
2955
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Getting expiration");
|
|
2956
|
+
const expiration = tokenManager.getTokenExpiration();
|
|
2957
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Expiration retrieved:", !!expiration);
|
|
2958
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Checking authentication");
|
|
2959
|
+
const authenticated = tokenManager.isAuthenticated();
|
|
2960
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Authentication checked:", authenticated);
|
|
2961
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Updating state variables");
|
|
2962
|
+
setTokenState(currentToken);
|
|
2963
|
+
setUser(parsedUser);
|
|
2964
|
+
setTokenExpiration(expiration);
|
|
2965
|
+
setIsAuthenticated(authenticated);
|
|
2966
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Authentication state updated successfully:", {
|
|
2967
|
+
hasToken: !!currentToken,
|
|
2968
|
+
isAuthenticated: authenticated,
|
|
2969
|
+
userEmail: parsedUser?.email || null,
|
|
2970
|
+
expiration: expiration?.toISOString() || null
|
|
2971
|
+
});
|
|
2972
|
+
} catch (error) {
|
|
2973
|
+
console.error("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Error updating authentication state:", error);
|
|
2974
|
+
}
|
|
2917
2975
|
}, []);
|
|
2918
2976
|
const setToken = (0, import_react12.useCallback)((newToken) => {
|
|
2919
2977
|
console.log("\u{1F510} CrudifyDataProvider - Setting new token:", newToken ? "provided" : "null");
|
|
@@ -2989,8 +3047,9 @@ var CrudifyDataProvider = ({
|
|
|
2989
3047
|
};
|
|
2990
3048
|
}, []);
|
|
2991
3049
|
(0, import_react12.useEffect)(() => {
|
|
3050
|
+
console.log("\u{1F510} CrudifyDataProvider - INITIAL_AUTH_EFFECT: Loading initial authentication state");
|
|
2992
3051
|
updateAuthenticationState();
|
|
2993
|
-
}, [
|
|
3052
|
+
}, []);
|
|
2994
3053
|
const contextValue = {
|
|
2995
3054
|
// Configuration
|
|
2996
3055
|
config,
|
package/dist/index.mjs
CHANGED
|
@@ -2562,19 +2562,25 @@ var _TokenManager = class _TokenManager {
|
|
|
2562
2562
|
* Load token from storage and synchronize with crudify
|
|
2563
2563
|
*/
|
|
2564
2564
|
loadTokenFromStorage() {
|
|
2565
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Entry point - loading token from storage");
|
|
2565
2566
|
try {
|
|
2567
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Getting token from secure session storage");
|
|
2566
2568
|
const storedToken = secureSessionStorage.getToken();
|
|
2569
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Stored token exists:", !!storedToken);
|
|
2567
2570
|
if (storedToken && this.isTokenValid(storedToken)) {
|
|
2571
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Stored token is valid, updating cache");
|
|
2568
2572
|
this.tokenCache = storedToken;
|
|
2569
2573
|
this.parsedTokenCache = this.parseToken(storedToken);
|
|
2570
2574
|
this.syncTokenWithCrudify(storedToken);
|
|
2571
|
-
console.log("\u{1F510} TokenManager - Token loaded from storage and synchronized");
|
|
2575
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Token loaded from storage and synchronized");
|
|
2572
2576
|
} else if (storedToken) {
|
|
2573
|
-
console.log("\u{1F510} TokenManager -
|
|
2577
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Stored token exists but is invalid/expired, clearing");
|
|
2574
2578
|
this.clearToken();
|
|
2579
|
+
} else {
|
|
2580
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: No stored token found");
|
|
2575
2581
|
}
|
|
2576
2582
|
} catch (error) {
|
|
2577
|
-
console.warn("\u{1F510} TokenManager - Error loading token from storage:", error);
|
|
2583
|
+
console.warn("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Error loading token from storage:", error);
|
|
2578
2584
|
this.clearToken();
|
|
2579
2585
|
}
|
|
2580
2586
|
}
|
|
@@ -2605,23 +2611,29 @@ var _TokenManager = class _TokenManager {
|
|
|
2605
2611
|
* Set a new JWT token with automatic synchronization
|
|
2606
2612
|
*/
|
|
2607
2613
|
setToken(token) {
|
|
2614
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: Entry point - setting token:", token ? "provided" : "null");
|
|
2608
2615
|
try {
|
|
2609
2616
|
if (!token) {
|
|
2617
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: No token provided, clearing token");
|
|
2610
2618
|
this.clearToken();
|
|
2611
2619
|
return;
|
|
2612
2620
|
}
|
|
2621
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: Validating token before setting");
|
|
2613
2622
|
if (!this.isTokenValid(token)) {
|
|
2614
|
-
console.warn("\u{1F510} TokenManager - Attempted to set invalid or expired token");
|
|
2623
|
+
console.warn("\u{1F510} TokenManager - SET_TOKEN: Attempted to set invalid or expired token");
|
|
2615
2624
|
this.clearToken();
|
|
2616
2625
|
return;
|
|
2617
2626
|
}
|
|
2627
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: Token is valid, updating cache");
|
|
2618
2628
|
this.tokenCache = token;
|
|
2619
2629
|
this.parsedTokenCache = this.parseToken(token);
|
|
2630
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: Storing token in secure storage");
|
|
2620
2631
|
secureSessionStorage.setToken(token);
|
|
2632
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: Synchronizing with crudify");
|
|
2621
2633
|
this.syncTokenWithCrudify(token);
|
|
2622
|
-
console.log("\u{1F510} TokenManager - Token set and synchronized successfully");
|
|
2634
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: Token set and synchronized successfully");
|
|
2623
2635
|
} catch (error) {
|
|
2624
|
-
console.error("\u{1F510} TokenManager - Error setting token:", error);
|
|
2636
|
+
console.error("\u{1F510} TokenManager - SET_TOKEN: Error setting token:", error);
|
|
2625
2637
|
this.clearToken();
|
|
2626
2638
|
}
|
|
2627
2639
|
}
|
|
@@ -2629,25 +2641,44 @@ var _TokenManager = class _TokenManager {
|
|
|
2629
2641
|
* Get the current JWT token
|
|
2630
2642
|
*/
|
|
2631
2643
|
getToken() {
|
|
2632
|
-
|
|
2633
|
-
|
|
2644
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: Entry point - checking cache");
|
|
2645
|
+
if (this.tokenCache) {
|
|
2646
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: Cache exists, validating token");
|
|
2647
|
+
if (this.isTokenValid(this.tokenCache)) {
|
|
2648
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: Cache valid, returning cached token");
|
|
2649
|
+
return this.tokenCache;
|
|
2650
|
+
} else {
|
|
2651
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: Cache invalid, clearing cache");
|
|
2652
|
+
this.tokenCache = null;
|
|
2653
|
+
}
|
|
2654
|
+
} else {
|
|
2655
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: No cache, loading from storage");
|
|
2634
2656
|
}
|
|
2657
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: Loading from storage");
|
|
2635
2658
|
this.loadTokenFromStorage();
|
|
2659
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: Returning final token:", !!this.tokenCache);
|
|
2636
2660
|
return this.tokenCache;
|
|
2637
2661
|
}
|
|
2638
2662
|
/**
|
|
2639
2663
|
* Parse the current JWT token
|
|
2640
2664
|
*/
|
|
2641
2665
|
parseToken(token) {
|
|
2642
|
-
|
|
2666
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Entry point - parsing token");
|
|
2667
|
+
const targetToken = token !== void 0 ? token : this.tokenCache;
|
|
2668
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Target token exists:", !!targetToken);
|
|
2643
2669
|
if (!targetToken) {
|
|
2670
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: No target token, returning null");
|
|
2644
2671
|
return null;
|
|
2645
2672
|
}
|
|
2646
2673
|
if (this.tokenCache === targetToken && this.parsedTokenCache) {
|
|
2674
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Returning cached parsed token");
|
|
2647
2675
|
return this.parsedTokenCache;
|
|
2648
2676
|
}
|
|
2677
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Cache miss, parsing token with decodeJwtSafely");
|
|
2649
2678
|
const parsed = decodeJwtSafely(targetToken);
|
|
2679
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Token parsed successfully:", !!parsed);
|
|
2650
2680
|
if (targetToken === this.tokenCache) {
|
|
2681
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Updating parsed token cache");
|
|
2651
2682
|
this.parsedTokenCache = parsed;
|
|
2652
2683
|
}
|
|
2653
2684
|
return parsed;
|
|
@@ -2656,17 +2687,26 @@ var _TokenManager = class _TokenManager {
|
|
|
2656
2687
|
* Check if a token is valid (properly formatted and not expired)
|
|
2657
2688
|
*/
|
|
2658
2689
|
isTokenValid(token) {
|
|
2659
|
-
|
|
2690
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Entry point - checking token validity");
|
|
2691
|
+
const targetToken = token !== void 0 ? token : this.tokenCache;
|
|
2692
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Target token exists:", !!targetToken);
|
|
2660
2693
|
if (!targetToken) {
|
|
2694
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: No token, returning false");
|
|
2661
2695
|
return false;
|
|
2662
2696
|
}
|
|
2663
2697
|
try {
|
|
2698
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Checking if token is expired");
|
|
2664
2699
|
if (isTokenExpired(targetToken)) {
|
|
2700
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Token is expired, returning false");
|
|
2665
2701
|
return false;
|
|
2666
2702
|
}
|
|
2703
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Token not expired, checking if can be parsed");
|
|
2667
2704
|
const parsed = decodeJwtSafely(targetToken);
|
|
2668
|
-
|
|
2669
|
-
|
|
2705
|
+
const isValid = parsed !== null;
|
|
2706
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Token parsing result:", isValid);
|
|
2707
|
+
return isValid;
|
|
2708
|
+
} catch (error) {
|
|
2709
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Error validating token:", error);
|
|
2670
2710
|
return false;
|
|
2671
2711
|
}
|
|
2672
2712
|
}
|
|
@@ -2684,14 +2724,18 @@ var _TokenManager = class _TokenManager {
|
|
|
2684
2724
|
* Clear the current token from all storages and crudify
|
|
2685
2725
|
*/
|
|
2686
2726
|
clearToken() {
|
|
2727
|
+
console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Entry point - clearing all tokens");
|
|
2687
2728
|
try {
|
|
2729
|
+
console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Clearing cache");
|
|
2688
2730
|
this.tokenCache = null;
|
|
2689
2731
|
this.parsedTokenCache = null;
|
|
2732
|
+
console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Clearing from secure storage");
|
|
2690
2733
|
secureSessionStorage.removeItem(this.TOKEN_KEY);
|
|
2734
|
+
console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Clearing from crudify");
|
|
2691
2735
|
crudify4.setToken("");
|
|
2692
|
-
console.log("\u{1F510} TokenManager - Token cleared from all storages");
|
|
2736
|
+
console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Token cleared from all storages successfully");
|
|
2693
2737
|
} catch (error) {
|
|
2694
|
-
console.warn("\u{1F510} TokenManager - Error clearing token:", error);
|
|
2738
|
+
console.warn("\u{1F510} TokenManager - CLEAR_TOKEN: Error clearing token:", error);
|
|
2695
2739
|
}
|
|
2696
2740
|
}
|
|
2697
2741
|
/**
|
|
@@ -2865,20 +2909,34 @@ var CrudifyDataProvider = ({
|
|
|
2865
2909
|
}
|
|
2866
2910
|
}, []);
|
|
2867
2911
|
const updateAuthenticationState = useCallback2(() => {
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2912
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Starting authentication state update");
|
|
2913
|
+
try {
|
|
2914
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Getting token from TokenManager");
|
|
2915
|
+
const currentToken = tokenManager.getToken();
|
|
2916
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Token retrieved:", !!currentToken);
|
|
2917
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Parsing token");
|
|
2918
|
+
const parsedUser = tokenManager.parseToken();
|
|
2919
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Token parsed:", !!parsedUser);
|
|
2920
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Getting expiration");
|
|
2921
|
+
const expiration = tokenManager.getTokenExpiration();
|
|
2922
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Expiration retrieved:", !!expiration);
|
|
2923
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Checking authentication");
|
|
2924
|
+
const authenticated = tokenManager.isAuthenticated();
|
|
2925
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Authentication checked:", authenticated);
|
|
2926
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Updating state variables");
|
|
2927
|
+
setTokenState(currentToken);
|
|
2928
|
+
setUser(parsedUser);
|
|
2929
|
+
setTokenExpiration(expiration);
|
|
2930
|
+
setIsAuthenticated(authenticated);
|
|
2931
|
+
console.log("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Authentication state updated successfully:", {
|
|
2932
|
+
hasToken: !!currentToken,
|
|
2933
|
+
isAuthenticated: authenticated,
|
|
2934
|
+
userEmail: parsedUser?.email || null,
|
|
2935
|
+
expiration: expiration?.toISOString() || null
|
|
2936
|
+
});
|
|
2937
|
+
} catch (error) {
|
|
2938
|
+
console.error("\u{1F510} CrudifyDataProvider - UPDATE_AUTH_STATE: Error updating authentication state:", error);
|
|
2939
|
+
}
|
|
2882
2940
|
}, []);
|
|
2883
2941
|
const setToken = useCallback2((newToken) => {
|
|
2884
2942
|
console.log("\u{1F510} CrudifyDataProvider - Setting new token:", newToken ? "provided" : "null");
|
|
@@ -2954,8 +3012,9 @@ var CrudifyDataProvider = ({
|
|
|
2954
3012
|
};
|
|
2955
3013
|
}, []);
|
|
2956
3014
|
useEffect8(() => {
|
|
3015
|
+
console.log("\u{1F510} CrudifyDataProvider - INITIAL_AUTH_EFFECT: Loading initial authentication state");
|
|
2957
3016
|
updateAuthenticationState();
|
|
2958
|
-
}, [
|
|
3017
|
+
}, []);
|
|
2959
3018
|
const contextValue = {
|
|
2960
3019
|
// Configuration
|
|
2961
3020
|
config,
|