@nocios/crudify-ui 1.2.29 → 1.2.34
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/{CrudifyDataProvider-BLW4PCVZ.mjs → CrudifyDataProvider-5GXGNQKI.mjs} +4 -2
- package/dist/TokenManager-AYUNIXQU.mjs +8 -0
- package/dist/{chunk-LR5FXHGC.mjs → chunk-GY5F6KOF.mjs} +4 -506
- package/dist/chunk-M7V4UGCN.mjs +512 -0
- package/dist/index.js +29 -3
- package/dist/index.mjs +29 -9
- package/package.json +1 -1
|
@@ -2,9 +2,11 @@ import {
|
|
|
2
2
|
CrudifyDataProvider,
|
|
3
3
|
configurationManager,
|
|
4
4
|
crudifyInitializer,
|
|
5
|
-
tokenManager,
|
|
6
5
|
useCrudifyDataContext
|
|
7
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-GY5F6KOF.mjs";
|
|
7
|
+
import {
|
|
8
|
+
tokenManager
|
|
9
|
+
} from "./chunk-M7V4UGCN.mjs";
|
|
8
10
|
export {
|
|
9
11
|
CrudifyDataProvider,
|
|
10
12
|
configurationManager,
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
tokenManager
|
|
3
|
+
} from "./chunk-M7V4UGCN.mjs";
|
|
4
|
+
|
|
1
5
|
// src/providers/CrudifyDataProvider.tsx
|
|
2
6
|
import { createContext, useContext, useEffect, useState, useCallback } from "react";
|
|
3
7
|
|
|
@@ -462,506 +466,6 @@ _CrudifyInitializer.instance = null;
|
|
|
462
466
|
var CrudifyInitializer = _CrudifyInitializer;
|
|
463
467
|
var crudifyInitializer = CrudifyInitializer.getInstance();
|
|
464
468
|
|
|
465
|
-
// src/core/TokenManager.ts
|
|
466
|
-
import crudify2 from "@nocios/crudify-browser";
|
|
467
|
-
|
|
468
|
-
// src/components/CrudifyLogin/utils/secureStorage.ts
|
|
469
|
-
import CryptoJS from "crypto-js";
|
|
470
|
-
var SecureStorage = class {
|
|
471
|
-
constructor(storageType = "sessionStorage") {
|
|
472
|
-
this.encryptionKey = this.generateEncryptionKey();
|
|
473
|
-
this.storage = storageType === "localStorage" ? window.localStorage : window.sessionStorage;
|
|
474
|
-
}
|
|
475
|
-
generateEncryptionKey() {
|
|
476
|
-
const browserFingerprint = [
|
|
477
|
-
navigator.userAgent,
|
|
478
|
-
navigator.language,
|
|
479
|
-
(/* @__PURE__ */ new Date()).getTimezoneOffset(),
|
|
480
|
-
screen.colorDepth,
|
|
481
|
-
screen.width,
|
|
482
|
-
screen.height,
|
|
483
|
-
"crudify-login"
|
|
484
|
-
].join("|");
|
|
485
|
-
return CryptoJS.SHA256(browserFingerprint).toString();
|
|
486
|
-
}
|
|
487
|
-
setItem(key, value, expiryMinutes) {
|
|
488
|
-
try {
|
|
489
|
-
const encrypted = CryptoJS.AES.encrypt(value, this.encryptionKey).toString();
|
|
490
|
-
this.storage.setItem(key, encrypted);
|
|
491
|
-
if (expiryMinutes) {
|
|
492
|
-
const expiryTime = (/* @__PURE__ */ new Date()).getTime() + expiryMinutes * 60 * 1e3;
|
|
493
|
-
this.storage.setItem(`${key}_expiry`, expiryTime.toString());
|
|
494
|
-
}
|
|
495
|
-
} catch (error) {
|
|
496
|
-
console.error("Failed to encrypt and store data:", error);
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
getItem(key) {
|
|
500
|
-
try {
|
|
501
|
-
const expiryKey = `${key}_expiry`;
|
|
502
|
-
const expiry = this.storage.getItem(expiryKey);
|
|
503
|
-
if (expiry) {
|
|
504
|
-
const expiryTime = parseInt(expiry, 10);
|
|
505
|
-
if ((/* @__PURE__ */ new Date()).getTime() > expiryTime) {
|
|
506
|
-
this.removeItem(key);
|
|
507
|
-
return null;
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
const encrypted = this.storage.getItem(key);
|
|
511
|
-
if (!encrypted) return null;
|
|
512
|
-
const decrypted = CryptoJS.AES.decrypt(encrypted, this.encryptionKey);
|
|
513
|
-
const result = decrypted.toString(CryptoJS.enc.Utf8);
|
|
514
|
-
if (!result) {
|
|
515
|
-
console.warn("Failed to decrypt stored data - may be corrupted");
|
|
516
|
-
this.removeItem(key);
|
|
517
|
-
return null;
|
|
518
|
-
}
|
|
519
|
-
return result;
|
|
520
|
-
} catch (error) {
|
|
521
|
-
console.error("Failed to decrypt data:", error);
|
|
522
|
-
this.removeItem(key);
|
|
523
|
-
return null;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
removeItem(key) {
|
|
527
|
-
this.storage.removeItem(key);
|
|
528
|
-
this.storage.removeItem(`${key}_expiry`);
|
|
529
|
-
}
|
|
530
|
-
setToken(token) {
|
|
531
|
-
try {
|
|
532
|
-
const parts = token.split(".");
|
|
533
|
-
if (parts.length === 3) {
|
|
534
|
-
const payload = JSON.parse(atob(parts[1]));
|
|
535
|
-
if (payload.exp) {
|
|
536
|
-
const expiryTime = payload.exp * 1e3;
|
|
537
|
-
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
538
|
-
const minutesUntilExpiry = Math.floor((expiryTime - now) / (60 * 1e3));
|
|
539
|
-
if (minutesUntilExpiry > 0) {
|
|
540
|
-
this.setItem("authToken", token, minutesUntilExpiry);
|
|
541
|
-
return;
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
} catch (error) {
|
|
546
|
-
console.warn("Failed to parse token expiry, using default expiry");
|
|
547
|
-
}
|
|
548
|
-
this.setItem("authToken", token, 24 * 60);
|
|
549
|
-
}
|
|
550
|
-
getToken() {
|
|
551
|
-
const token = this.getItem("authToken");
|
|
552
|
-
if (token) {
|
|
553
|
-
try {
|
|
554
|
-
const parts = token.split(".");
|
|
555
|
-
if (parts.length === 3) {
|
|
556
|
-
const payload = JSON.parse(atob(parts[1]));
|
|
557
|
-
if (payload.exp) {
|
|
558
|
-
const now = Math.floor(Date.now() / 1e3);
|
|
559
|
-
if (payload.exp < now) {
|
|
560
|
-
this.removeItem("authToken");
|
|
561
|
-
return null;
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
} catch (error) {
|
|
566
|
-
console.warn("Failed to validate token expiry");
|
|
567
|
-
this.removeItem("authToken");
|
|
568
|
-
return null;
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
return token;
|
|
572
|
-
}
|
|
573
|
-
};
|
|
574
|
-
var secureSessionStorage = new SecureStorage("sessionStorage");
|
|
575
|
-
var secureLocalStorage = new SecureStorage("localStorage");
|
|
576
|
-
|
|
577
|
-
// src/utils/jwtUtils.ts
|
|
578
|
-
var decodeJwtSafely = (token) => {
|
|
579
|
-
try {
|
|
580
|
-
const parts = token.split(".");
|
|
581
|
-
if (parts.length !== 3) {
|
|
582
|
-
console.warn("Invalid JWT format: token must have 3 parts");
|
|
583
|
-
return null;
|
|
584
|
-
}
|
|
585
|
-
const payload = parts[1];
|
|
586
|
-
const paddedPayload = payload + "=".repeat((4 - payload.length % 4) % 4);
|
|
587
|
-
const decodedPayload = JSON.parse(atob(paddedPayload));
|
|
588
|
-
return decodedPayload;
|
|
589
|
-
} catch (error) {
|
|
590
|
-
console.warn("Failed to decode JWT token:", error);
|
|
591
|
-
return null;
|
|
592
|
-
}
|
|
593
|
-
};
|
|
594
|
-
var getCurrentUserEmail = () => {
|
|
595
|
-
try {
|
|
596
|
-
let token = null;
|
|
597
|
-
token = sessionStorage.getItem("authToken");
|
|
598
|
-
console.log("\u{1F50D} getCurrentUserEmail - authToken:", token ? `${token.substring(0, 20)}...` : null);
|
|
599
|
-
if (!token) {
|
|
600
|
-
token = sessionStorage.getItem("token");
|
|
601
|
-
console.log("\u{1F50D} getCurrentUserEmail - token:", token ? `${token.substring(0, 20)}...` : null);
|
|
602
|
-
}
|
|
603
|
-
if (!token) {
|
|
604
|
-
token = localStorage.getItem("authToken") || localStorage.getItem("token");
|
|
605
|
-
console.log("\u{1F50D} getCurrentUserEmail - localStorage:", token ? `${token.substring(0, 20)}...` : null);
|
|
606
|
-
}
|
|
607
|
-
if (!token) {
|
|
608
|
-
console.warn("\u{1F50D} getCurrentUserEmail - No token found in any storage");
|
|
609
|
-
return null;
|
|
610
|
-
}
|
|
611
|
-
const payload = decodeJwtSafely(token);
|
|
612
|
-
if (!payload) {
|
|
613
|
-
console.warn("\u{1F50D} getCurrentUserEmail - Failed to decode token");
|
|
614
|
-
return null;
|
|
615
|
-
}
|
|
616
|
-
const email = payload.email || payload["cognito:username"] || null;
|
|
617
|
-
console.log("\u{1F50D} getCurrentUserEmail - Extracted email:", email);
|
|
618
|
-
return email;
|
|
619
|
-
} catch (error) {
|
|
620
|
-
console.warn("Failed to get current user email:", error);
|
|
621
|
-
return null;
|
|
622
|
-
}
|
|
623
|
-
};
|
|
624
|
-
var isTokenExpired = (token) => {
|
|
625
|
-
try {
|
|
626
|
-
const payload = decodeJwtSafely(token);
|
|
627
|
-
if (!payload || !payload.exp) return true;
|
|
628
|
-
const currentTime = Math.floor(Date.now() / 1e3);
|
|
629
|
-
return payload.exp < currentTime;
|
|
630
|
-
} catch {
|
|
631
|
-
return true;
|
|
632
|
-
}
|
|
633
|
-
};
|
|
634
|
-
|
|
635
|
-
// src/core/TokenManager.ts
|
|
636
|
-
var _TokenManager = class _TokenManager {
|
|
637
|
-
constructor() {
|
|
638
|
-
this.TOKEN_KEY = "authToken";
|
|
639
|
-
// Compatible with crudia-ui
|
|
640
|
-
this.tokenCache = null;
|
|
641
|
-
this.parsedTokenCache = null;
|
|
642
|
-
this.expirationCheckInterval = null;
|
|
643
|
-
this.storageEventListener = null;
|
|
644
|
-
this.initializeTokenManager();
|
|
645
|
-
}
|
|
646
|
-
/**
|
|
647
|
-
* Singleton pattern to ensure consistent token management
|
|
648
|
-
*/
|
|
649
|
-
static getInstance() {
|
|
650
|
-
if (!_TokenManager.instance) {
|
|
651
|
-
_TokenManager.instance = new _TokenManager();
|
|
652
|
-
}
|
|
653
|
-
return _TokenManager.instance;
|
|
654
|
-
}
|
|
655
|
-
/**
|
|
656
|
-
* Reset the singleton instance (useful for testing)
|
|
657
|
-
*/
|
|
658
|
-
static resetInstance() {
|
|
659
|
-
if (_TokenManager.instance) {
|
|
660
|
-
_TokenManager.instance.cleanup();
|
|
661
|
-
}
|
|
662
|
-
_TokenManager.instance = null;
|
|
663
|
-
}
|
|
664
|
-
/**
|
|
665
|
-
* Initialize the token manager with storage synchronization
|
|
666
|
-
*/
|
|
667
|
-
initializeTokenManager() {
|
|
668
|
-
console.log("\u{1F510} TokenManager - Initializing token management");
|
|
669
|
-
this.migrateFromLocalStorage();
|
|
670
|
-
this.loadTokenFromStorage();
|
|
671
|
-
this.setupExpirationCheck();
|
|
672
|
-
this.setupStorageListener();
|
|
673
|
-
console.log("\u{1F510} TokenManager - Initialization complete");
|
|
674
|
-
}
|
|
675
|
-
/**
|
|
676
|
-
* Migrate tokens from plain localStorage to encrypted localStorage
|
|
677
|
-
* This ensures compatibility with older implementations
|
|
678
|
-
*/
|
|
679
|
-
migrateFromLocalStorage() {
|
|
680
|
-
try {
|
|
681
|
-
const legacyKeys = ["authToken", "token", "jwt", "jwtToken"];
|
|
682
|
-
for (const key of legacyKeys) {
|
|
683
|
-
const token = localStorage.getItem(key);
|
|
684
|
-
if (token && !secureLocalStorage.getToken()) {
|
|
685
|
-
console.log(`\u{1F510} TokenManager - Migrating token from localStorage key: ${key}`);
|
|
686
|
-
secureLocalStorage.setToken(token);
|
|
687
|
-
localStorage.removeItem(key);
|
|
688
|
-
break;
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
} catch (error) {
|
|
692
|
-
console.warn("\u{1F510} TokenManager - Token migration failed:", error);
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
/**
|
|
696
|
-
* Load token from storage and synchronize with crudify
|
|
697
|
-
*/
|
|
698
|
-
loadTokenFromStorage() {
|
|
699
|
-
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Entry point - loading token from storage");
|
|
700
|
-
try {
|
|
701
|
-
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Getting token from secure local storage");
|
|
702
|
-
const storedToken = secureLocalStorage.getToken();
|
|
703
|
-
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Stored token exists:", !!storedToken);
|
|
704
|
-
if (storedToken && this.isTokenValid(storedToken)) {
|
|
705
|
-
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Stored token is valid, updating cache");
|
|
706
|
-
this.tokenCache = storedToken;
|
|
707
|
-
this.parsedTokenCache = this.parseToken(storedToken);
|
|
708
|
-
this.syncTokenWithCrudify(storedToken);
|
|
709
|
-
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Token loaded from storage and synchronized");
|
|
710
|
-
} else if (storedToken) {
|
|
711
|
-
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Stored token exists but is invalid/expired, clearing");
|
|
712
|
-
this.clearToken();
|
|
713
|
-
} else {
|
|
714
|
-
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: No stored token found");
|
|
715
|
-
}
|
|
716
|
-
} catch (error) {
|
|
717
|
-
console.warn("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Error loading token from storage:", error);
|
|
718
|
-
this.clearToken();
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
/**
|
|
722
|
-
* Set up automatic token expiration checking
|
|
723
|
-
*/
|
|
724
|
-
setupExpirationCheck() {
|
|
725
|
-
this.expirationCheckInterval = window.setInterval(() => {
|
|
726
|
-
if (this.tokenCache && !this.isTokenValid(this.tokenCache)) {
|
|
727
|
-
console.log("\u{1F510} TokenManager - Token expired, clearing automatically");
|
|
728
|
-
this.clearToken();
|
|
729
|
-
}
|
|
730
|
-
}, 3e4);
|
|
731
|
-
}
|
|
732
|
-
/**
|
|
733
|
-
* Set up storage event listener for cross-tab synchronization
|
|
734
|
-
*/
|
|
735
|
-
setupStorageListener() {
|
|
736
|
-
this.storageEventListener = (event) => {
|
|
737
|
-
if (event.key === this.TOKEN_KEY) {
|
|
738
|
-
console.log("\u{1F510} TokenManager - Token change detected from another tab");
|
|
739
|
-
this.loadTokenFromStorage();
|
|
740
|
-
}
|
|
741
|
-
};
|
|
742
|
-
window.addEventListener("storage", this.storageEventListener);
|
|
743
|
-
}
|
|
744
|
-
/**
|
|
745
|
-
* Set a new JWT token with automatic synchronization
|
|
746
|
-
*/
|
|
747
|
-
setToken(token) {
|
|
748
|
-
console.log("\u{1F510} TokenManager - SET_TOKEN: Entry point - setting token:", token ? "provided" : "null");
|
|
749
|
-
try {
|
|
750
|
-
if (!token) {
|
|
751
|
-
console.log("\u{1F510} TokenManager - SET_TOKEN: No token provided, clearing token");
|
|
752
|
-
this.clearToken();
|
|
753
|
-
return;
|
|
754
|
-
}
|
|
755
|
-
console.log("\u{1F510} TokenManager - SET_TOKEN: Validating token before setting");
|
|
756
|
-
if (!this.isTokenValid(token)) {
|
|
757
|
-
console.warn("\u{1F510} TokenManager - SET_TOKEN: Attempted to set invalid or expired token");
|
|
758
|
-
this.clearToken();
|
|
759
|
-
return;
|
|
760
|
-
}
|
|
761
|
-
console.log("\u{1F510} TokenManager - SET_TOKEN: Token is valid, updating cache");
|
|
762
|
-
this.tokenCache = token;
|
|
763
|
-
this.parsedTokenCache = this.parseToken(token);
|
|
764
|
-
console.log("\u{1F510} TokenManager - SET_TOKEN: Storing token in secure storage");
|
|
765
|
-
secureLocalStorage.setToken(token);
|
|
766
|
-
console.log("\u{1F510} TokenManager - SET_TOKEN: Synchronizing with crudify");
|
|
767
|
-
this.syncTokenWithCrudify(token);
|
|
768
|
-
console.log("\u{1F510} TokenManager - SET_TOKEN: Token set and synchronized successfully");
|
|
769
|
-
} catch (error) {
|
|
770
|
-
console.error("\u{1F510} TokenManager - SET_TOKEN: Error setting token:", error);
|
|
771
|
-
this.clearToken();
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
/**
|
|
775
|
-
* Get the current JWT token
|
|
776
|
-
*/
|
|
777
|
-
getToken() {
|
|
778
|
-
console.log("\u{1F510} TokenManager - GET_TOKEN: Entry point - checking cache");
|
|
779
|
-
if (this.tokenCache) {
|
|
780
|
-
console.log("\u{1F510} TokenManager - GET_TOKEN: Cache exists, validating token");
|
|
781
|
-
if (this.isTokenValid(this.tokenCache)) {
|
|
782
|
-
console.log("\u{1F510} TokenManager - GET_TOKEN: Cache valid, returning cached token");
|
|
783
|
-
return this.tokenCache;
|
|
784
|
-
} else {
|
|
785
|
-
console.log("\u{1F510} TokenManager - GET_TOKEN: Cache invalid, clearing cache");
|
|
786
|
-
this.tokenCache = null;
|
|
787
|
-
}
|
|
788
|
-
} else {
|
|
789
|
-
console.log("\u{1F510} TokenManager - GET_TOKEN: No cache, loading from storage");
|
|
790
|
-
}
|
|
791
|
-
console.log("\u{1F510} TokenManager - GET_TOKEN: Loading from storage");
|
|
792
|
-
this.loadTokenFromStorage();
|
|
793
|
-
console.log("\u{1F510} TokenManager - GET_TOKEN: Returning final token:", !!this.tokenCache);
|
|
794
|
-
return this.tokenCache;
|
|
795
|
-
}
|
|
796
|
-
/**
|
|
797
|
-
* Parse the current JWT token
|
|
798
|
-
*/
|
|
799
|
-
parseToken(token) {
|
|
800
|
-
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Entry point - parsing token");
|
|
801
|
-
const targetToken = token !== void 0 ? token : this.tokenCache;
|
|
802
|
-
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Target token exists:", !!targetToken);
|
|
803
|
-
if (!targetToken) {
|
|
804
|
-
console.log("\u{1F510} TokenManager - PARSE_TOKEN: No target token, returning null");
|
|
805
|
-
return null;
|
|
806
|
-
}
|
|
807
|
-
if (this.tokenCache === targetToken && this.parsedTokenCache) {
|
|
808
|
-
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Returning cached parsed token");
|
|
809
|
-
return this.parsedTokenCache;
|
|
810
|
-
}
|
|
811
|
-
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Cache miss, parsing token with decodeJwtSafely");
|
|
812
|
-
const parsed = decodeJwtSafely(targetToken);
|
|
813
|
-
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Token parsed successfully:", !!parsed);
|
|
814
|
-
if (targetToken === this.tokenCache) {
|
|
815
|
-
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Updating parsed token cache");
|
|
816
|
-
this.parsedTokenCache = parsed;
|
|
817
|
-
}
|
|
818
|
-
return parsed;
|
|
819
|
-
}
|
|
820
|
-
/**
|
|
821
|
-
* Check if a token is valid (properly formatted and not expired)
|
|
822
|
-
*/
|
|
823
|
-
isTokenValid(token) {
|
|
824
|
-
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Entry point - checking token validity");
|
|
825
|
-
const targetToken = token !== void 0 ? token : this.tokenCache;
|
|
826
|
-
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Target token exists:", !!targetToken);
|
|
827
|
-
if (!targetToken) {
|
|
828
|
-
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: No token, returning false");
|
|
829
|
-
return false;
|
|
830
|
-
}
|
|
831
|
-
try {
|
|
832
|
-
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Checking if token is expired");
|
|
833
|
-
if (isTokenExpired(targetToken)) {
|
|
834
|
-
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Token is expired, returning false");
|
|
835
|
-
return false;
|
|
836
|
-
}
|
|
837
|
-
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Token not expired, checking if can be parsed");
|
|
838
|
-
const parsed = decodeJwtSafely(targetToken);
|
|
839
|
-
const isValid = parsed !== null;
|
|
840
|
-
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Token parsing result:", isValid);
|
|
841
|
-
return isValid;
|
|
842
|
-
} catch (error) {
|
|
843
|
-
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Error validating token:", error);
|
|
844
|
-
return false;
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
/**
|
|
848
|
-
* Get token expiration time as Date object
|
|
849
|
-
*/
|
|
850
|
-
getTokenExpiration() {
|
|
851
|
-
const token = this.getToken();
|
|
852
|
-
if (!token) return null;
|
|
853
|
-
const parsed = this.parseToken(token);
|
|
854
|
-
if (!parsed?.exp) return null;
|
|
855
|
-
return new Date(parsed.exp * 1e3);
|
|
856
|
-
}
|
|
857
|
-
/**
|
|
858
|
-
* Clear the current token from all storages and crudify
|
|
859
|
-
*/
|
|
860
|
-
clearToken() {
|
|
861
|
-
console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Entry point - clearing all tokens");
|
|
862
|
-
try {
|
|
863
|
-
console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Clearing cache");
|
|
864
|
-
this.tokenCache = null;
|
|
865
|
-
this.parsedTokenCache = null;
|
|
866
|
-
console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Clearing from secure storage");
|
|
867
|
-
secureLocalStorage.removeItem(this.TOKEN_KEY);
|
|
868
|
-
console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Clearing from crudify");
|
|
869
|
-
crudify2.setToken("");
|
|
870
|
-
console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Token cleared from all storages successfully");
|
|
871
|
-
} catch (error) {
|
|
872
|
-
console.warn("\u{1F510} TokenManager - CLEAR_TOKEN: Error clearing token:", error);
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
/**
|
|
876
|
-
* Synchronize token with crudify library
|
|
877
|
-
*/
|
|
878
|
-
syncTokenWithCrudify(token) {
|
|
879
|
-
try {
|
|
880
|
-
crudify2.setToken(token);
|
|
881
|
-
console.log("\u{1F510} TokenManager - Token synchronized with crudify");
|
|
882
|
-
} catch (error) {
|
|
883
|
-
console.warn("\u{1F510} TokenManager - Failed to sync token with crudify:", error);
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
/**
|
|
887
|
-
* Refresh token (placeholder for future implementation)
|
|
888
|
-
*/
|
|
889
|
-
async refreshToken() {
|
|
890
|
-
throw new Error("Token refresh not yet implemented");
|
|
891
|
-
}
|
|
892
|
-
/**
|
|
893
|
-
* Get user information from the current token
|
|
894
|
-
*/
|
|
895
|
-
getUserInfo() {
|
|
896
|
-
const parsed = this.parseToken();
|
|
897
|
-
if (!parsed) {
|
|
898
|
-
return {
|
|
899
|
-
email: null,
|
|
900
|
-
userId: null,
|
|
901
|
-
userIdentifier: null,
|
|
902
|
-
username: null
|
|
903
|
-
};
|
|
904
|
-
}
|
|
905
|
-
return {
|
|
906
|
-
email: parsed.email || null,
|
|
907
|
-
userId: parsed.sub || null,
|
|
908
|
-
userIdentifier: parsed["cognito:username"] || parsed.email || parsed.sub || null,
|
|
909
|
-
username: parsed["cognito:username"] || null
|
|
910
|
-
};
|
|
911
|
-
}
|
|
912
|
-
/**
|
|
913
|
-
* Check if user is currently authenticated
|
|
914
|
-
*/
|
|
915
|
-
isAuthenticated() {
|
|
916
|
-
return this.isTokenValid();
|
|
917
|
-
}
|
|
918
|
-
/**
|
|
919
|
-
* Get time until token expires in minutes
|
|
920
|
-
*/
|
|
921
|
-
getTimeUntilExpiration() {
|
|
922
|
-
const expiration = this.getTokenExpiration();
|
|
923
|
-
if (!expiration) return null;
|
|
924
|
-
const now = /* @__PURE__ */ new Date();
|
|
925
|
-
const minutesUntilExpiry = Math.floor((expiration.getTime() - now.getTime()) / (60 * 1e3));
|
|
926
|
-
return Math.max(0, minutesUntilExpiry);
|
|
927
|
-
}
|
|
928
|
-
/**
|
|
929
|
-
* Cleanup resources (call when the component unmounts)
|
|
930
|
-
*/
|
|
931
|
-
cleanup() {
|
|
932
|
-
if (this.expirationCheckInterval) {
|
|
933
|
-
window.clearInterval(this.expirationCheckInterval);
|
|
934
|
-
this.expirationCheckInterval = null;
|
|
935
|
-
}
|
|
936
|
-
if (this.storageEventListener) {
|
|
937
|
-
window.removeEventListener("storage", this.storageEventListener);
|
|
938
|
-
this.storageEventListener = null;
|
|
939
|
-
}
|
|
940
|
-
console.log("\u{1F510} TokenManager - Cleanup completed");
|
|
941
|
-
}
|
|
942
|
-
/**
|
|
943
|
-
* Get debug information about the current token state
|
|
944
|
-
*/
|
|
945
|
-
getDebugInfo() {
|
|
946
|
-
const token = this.getToken();
|
|
947
|
-
const parsed = this.parseToken();
|
|
948
|
-
const expiration = this.getTokenExpiration();
|
|
949
|
-
return {
|
|
950
|
-
hasToken: !!token,
|
|
951
|
-
tokenLength: token?.length || 0,
|
|
952
|
-
isValid: this.isTokenValid(),
|
|
953
|
-
isAuthenticated: this.isAuthenticated(),
|
|
954
|
-
expiration: expiration?.toISOString() || null,
|
|
955
|
-
minutesUntilExpiry: this.getTimeUntilExpiration(),
|
|
956
|
-
userInfo: this.getUserInfo(),
|
|
957
|
-
parsedTokenKeys: parsed ? Object.keys(parsed) : []
|
|
958
|
-
};
|
|
959
|
-
}
|
|
960
|
-
};
|
|
961
|
-
_TokenManager.instance = null;
|
|
962
|
-
var TokenManager = _TokenManager;
|
|
963
|
-
var tokenManager = TokenManager.getInstance();
|
|
964
|
-
|
|
965
469
|
// src/providers/CrudifyDataProvider.tsx
|
|
966
470
|
import { jsx } from "react/jsx-runtime";
|
|
967
471
|
var CrudifyDataContext = createContext(null);
|
|
@@ -1190,14 +694,8 @@ var useCrudifyDataContext = () => {
|
|
|
1190
694
|
|
|
1191
695
|
export {
|
|
1192
696
|
getCookie,
|
|
1193
|
-
secureSessionStorage,
|
|
1194
|
-
secureLocalStorage,
|
|
1195
697
|
configurationManager,
|
|
1196
698
|
crudifyInitializer,
|
|
1197
|
-
decodeJwtSafely,
|
|
1198
|
-
getCurrentUserEmail,
|
|
1199
|
-
isTokenExpired,
|
|
1200
|
-
tokenManager,
|
|
1201
699
|
CrudifyDataProvider,
|
|
1202
700
|
useCrudifyDataContext
|
|
1203
701
|
};
|
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
// src/core/TokenManager.ts
|
|
2
|
+
import crudify from "@nocios/crudify-browser";
|
|
3
|
+
|
|
4
|
+
// src/components/CrudifyLogin/utils/secureStorage.ts
|
|
5
|
+
import CryptoJS from "crypto-js";
|
|
6
|
+
var SecureStorage = class {
|
|
7
|
+
constructor(storageType = "sessionStorage") {
|
|
8
|
+
this.encryptionKey = this.generateEncryptionKey();
|
|
9
|
+
this.storage = storageType === "localStorage" ? window.localStorage : window.sessionStorage;
|
|
10
|
+
}
|
|
11
|
+
generateEncryptionKey() {
|
|
12
|
+
const browserFingerprint = [
|
|
13
|
+
navigator.userAgent,
|
|
14
|
+
navigator.language,
|
|
15
|
+
(/* @__PURE__ */ new Date()).getTimezoneOffset(),
|
|
16
|
+
screen.colorDepth,
|
|
17
|
+
screen.width,
|
|
18
|
+
screen.height,
|
|
19
|
+
"crudify-login"
|
|
20
|
+
].join("|");
|
|
21
|
+
return CryptoJS.SHA256(browserFingerprint).toString();
|
|
22
|
+
}
|
|
23
|
+
setItem(key, value, expiryMinutes) {
|
|
24
|
+
try {
|
|
25
|
+
const encrypted = CryptoJS.AES.encrypt(value, this.encryptionKey).toString();
|
|
26
|
+
this.storage.setItem(key, encrypted);
|
|
27
|
+
if (expiryMinutes) {
|
|
28
|
+
const expiryTime = (/* @__PURE__ */ new Date()).getTime() + expiryMinutes * 60 * 1e3;
|
|
29
|
+
this.storage.setItem(`${key}_expiry`, expiryTime.toString());
|
|
30
|
+
}
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error("Failed to encrypt and store data:", error);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
getItem(key) {
|
|
36
|
+
try {
|
|
37
|
+
const expiryKey = `${key}_expiry`;
|
|
38
|
+
const expiry = this.storage.getItem(expiryKey);
|
|
39
|
+
if (expiry) {
|
|
40
|
+
const expiryTime = parseInt(expiry, 10);
|
|
41
|
+
if ((/* @__PURE__ */ new Date()).getTime() > expiryTime) {
|
|
42
|
+
this.removeItem(key);
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const encrypted = this.storage.getItem(key);
|
|
47
|
+
if (!encrypted) return null;
|
|
48
|
+
const decrypted = CryptoJS.AES.decrypt(encrypted, this.encryptionKey);
|
|
49
|
+
const result = decrypted.toString(CryptoJS.enc.Utf8);
|
|
50
|
+
if (!result) {
|
|
51
|
+
console.warn("Failed to decrypt stored data - may be corrupted");
|
|
52
|
+
this.removeItem(key);
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.error("Failed to decrypt data:", error);
|
|
58
|
+
this.removeItem(key);
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
removeItem(key) {
|
|
63
|
+
this.storage.removeItem(key);
|
|
64
|
+
this.storage.removeItem(`${key}_expiry`);
|
|
65
|
+
}
|
|
66
|
+
setToken(token) {
|
|
67
|
+
try {
|
|
68
|
+
const parts = token.split(".");
|
|
69
|
+
if (parts.length === 3) {
|
|
70
|
+
const payload = JSON.parse(atob(parts[1]));
|
|
71
|
+
if (payload.exp) {
|
|
72
|
+
const expiryTime = payload.exp * 1e3;
|
|
73
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
74
|
+
const minutesUntilExpiry = Math.floor((expiryTime - now) / (60 * 1e3));
|
|
75
|
+
if (minutesUntilExpiry > 0) {
|
|
76
|
+
this.setItem("authToken", token, minutesUntilExpiry);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.warn("Failed to parse token expiry, using default expiry");
|
|
83
|
+
}
|
|
84
|
+
this.setItem("authToken", token, 24 * 60);
|
|
85
|
+
}
|
|
86
|
+
getToken() {
|
|
87
|
+
const token = this.getItem("authToken");
|
|
88
|
+
if (token) {
|
|
89
|
+
try {
|
|
90
|
+
const parts = token.split(".");
|
|
91
|
+
if (parts.length === 3) {
|
|
92
|
+
const payload = JSON.parse(atob(parts[1]));
|
|
93
|
+
if (payload.exp) {
|
|
94
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
95
|
+
if (payload.exp < now) {
|
|
96
|
+
this.removeItem("authToken");
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.warn("Failed to validate token expiry");
|
|
103
|
+
this.removeItem("authToken");
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return token;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var secureSessionStorage = new SecureStorage("sessionStorage");
|
|
111
|
+
var secureLocalStorage = new SecureStorage("localStorage");
|
|
112
|
+
|
|
113
|
+
// src/utils/jwtUtils.ts
|
|
114
|
+
var decodeJwtSafely = (token) => {
|
|
115
|
+
try {
|
|
116
|
+
const parts = token.split(".");
|
|
117
|
+
if (parts.length !== 3) {
|
|
118
|
+
console.warn("Invalid JWT format: token must have 3 parts");
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
const payload = parts[1];
|
|
122
|
+
const paddedPayload = payload + "=".repeat((4 - payload.length % 4) % 4);
|
|
123
|
+
const decodedPayload = JSON.parse(atob(paddedPayload));
|
|
124
|
+
return decodedPayload;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
console.warn("Failed to decode JWT token:", error);
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
var getCurrentUserEmail = () => {
|
|
131
|
+
try {
|
|
132
|
+
let token = null;
|
|
133
|
+
token = sessionStorage.getItem("authToken");
|
|
134
|
+
console.log("\u{1F50D} getCurrentUserEmail - authToken:", token ? `${token.substring(0, 20)}...` : null);
|
|
135
|
+
if (!token) {
|
|
136
|
+
token = sessionStorage.getItem("token");
|
|
137
|
+
console.log("\u{1F50D} getCurrentUserEmail - token:", token ? `${token.substring(0, 20)}...` : null);
|
|
138
|
+
}
|
|
139
|
+
if (!token) {
|
|
140
|
+
token = localStorage.getItem("authToken") || localStorage.getItem("token");
|
|
141
|
+
console.log("\u{1F50D} getCurrentUserEmail - localStorage:", token ? `${token.substring(0, 20)}...` : null);
|
|
142
|
+
}
|
|
143
|
+
if (!token) {
|
|
144
|
+
console.warn("\u{1F50D} getCurrentUserEmail - No token found in any storage");
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
const payload = decodeJwtSafely(token);
|
|
148
|
+
if (!payload) {
|
|
149
|
+
console.warn("\u{1F50D} getCurrentUserEmail - Failed to decode token");
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
const email = payload.email || payload["cognito:username"] || null;
|
|
153
|
+
console.log("\u{1F50D} getCurrentUserEmail - Extracted email:", email);
|
|
154
|
+
return email;
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.warn("Failed to get current user email:", error);
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
var isTokenExpired = (token) => {
|
|
161
|
+
try {
|
|
162
|
+
const payload = decodeJwtSafely(token);
|
|
163
|
+
if (!payload || !payload.exp) return true;
|
|
164
|
+
const currentTime = Math.floor(Date.now() / 1e3);
|
|
165
|
+
return payload.exp < currentTime;
|
|
166
|
+
} catch {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
// src/core/TokenManager.ts
|
|
172
|
+
var _TokenManager = class _TokenManager {
|
|
173
|
+
constructor() {
|
|
174
|
+
this.TOKEN_KEY = "authToken";
|
|
175
|
+
// Compatible with crudia-ui
|
|
176
|
+
this.tokenCache = null;
|
|
177
|
+
this.parsedTokenCache = null;
|
|
178
|
+
this.expirationCheckInterval = null;
|
|
179
|
+
this.storageEventListener = null;
|
|
180
|
+
this.initializeTokenManager();
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Singleton pattern to ensure consistent token management
|
|
184
|
+
*/
|
|
185
|
+
static getInstance() {
|
|
186
|
+
if (!_TokenManager.instance) {
|
|
187
|
+
_TokenManager.instance = new _TokenManager();
|
|
188
|
+
}
|
|
189
|
+
return _TokenManager.instance;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Reset the singleton instance (useful for testing)
|
|
193
|
+
*/
|
|
194
|
+
static resetInstance() {
|
|
195
|
+
if (_TokenManager.instance) {
|
|
196
|
+
_TokenManager.instance.cleanup();
|
|
197
|
+
}
|
|
198
|
+
_TokenManager.instance = null;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Initialize the token manager with storage synchronization
|
|
202
|
+
*/
|
|
203
|
+
initializeTokenManager() {
|
|
204
|
+
console.log("\u{1F510} TokenManager - Initializing token management");
|
|
205
|
+
this.migrateFromLocalStorage();
|
|
206
|
+
this.loadTokenFromStorage();
|
|
207
|
+
this.setupExpirationCheck();
|
|
208
|
+
this.setupStorageListener();
|
|
209
|
+
console.log("\u{1F510} TokenManager - Initialization complete");
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Migrate tokens from plain localStorage to encrypted localStorage
|
|
213
|
+
* This ensures compatibility with older implementations
|
|
214
|
+
*/
|
|
215
|
+
migrateFromLocalStorage() {
|
|
216
|
+
try {
|
|
217
|
+
const legacyKeys = ["authToken", "token", "jwt", "jwtToken"];
|
|
218
|
+
for (const key of legacyKeys) {
|
|
219
|
+
const token = localStorage.getItem(key);
|
|
220
|
+
if (token && !secureLocalStorage.getToken()) {
|
|
221
|
+
console.log(`\u{1F510} TokenManager - Migrating token from localStorage key: ${key}`);
|
|
222
|
+
secureLocalStorage.setToken(token);
|
|
223
|
+
localStorage.removeItem(key);
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
} catch (error) {
|
|
228
|
+
console.warn("\u{1F510} TokenManager - Token migration failed:", error);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Load token from storage and synchronize with crudify
|
|
233
|
+
*/
|
|
234
|
+
loadTokenFromStorage() {
|
|
235
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Entry point - loading token from storage");
|
|
236
|
+
try {
|
|
237
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Getting token from secure local storage");
|
|
238
|
+
const storedToken = secureLocalStorage.getToken();
|
|
239
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Stored token exists:", !!storedToken);
|
|
240
|
+
if (storedToken && this.isTokenValid(storedToken)) {
|
|
241
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Stored token is valid, updating cache");
|
|
242
|
+
this.tokenCache = storedToken;
|
|
243
|
+
this.parsedTokenCache = this.parseToken(storedToken);
|
|
244
|
+
this.syncTokenWithCrudify(storedToken);
|
|
245
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Token loaded from storage and synchronized");
|
|
246
|
+
} else if (storedToken) {
|
|
247
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Stored token exists but is invalid/expired, clearing");
|
|
248
|
+
this.clearToken();
|
|
249
|
+
} else {
|
|
250
|
+
console.log("\u{1F510} TokenManager - LOAD_FROM_STORAGE: No stored token found");
|
|
251
|
+
}
|
|
252
|
+
} catch (error) {
|
|
253
|
+
console.warn("\u{1F510} TokenManager - LOAD_FROM_STORAGE: Error loading token from storage:", error);
|
|
254
|
+
this.clearToken();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Set up automatic token expiration checking
|
|
259
|
+
*/
|
|
260
|
+
setupExpirationCheck() {
|
|
261
|
+
this.expirationCheckInterval = window.setInterval(() => {
|
|
262
|
+
if (this.tokenCache && !this.isTokenValid(this.tokenCache)) {
|
|
263
|
+
console.log("\u{1F510} TokenManager - Token expired, clearing automatically");
|
|
264
|
+
this.clearToken();
|
|
265
|
+
}
|
|
266
|
+
}, 3e4);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Set up storage event listener for cross-tab synchronization
|
|
270
|
+
*/
|
|
271
|
+
setupStorageListener() {
|
|
272
|
+
this.storageEventListener = (event) => {
|
|
273
|
+
if (event.key === this.TOKEN_KEY) {
|
|
274
|
+
console.log("\u{1F510} TokenManager - Token change detected from another tab");
|
|
275
|
+
this.loadTokenFromStorage();
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
window.addEventListener("storage", this.storageEventListener);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Set a new JWT token with automatic synchronization
|
|
282
|
+
*/
|
|
283
|
+
setToken(token) {
|
|
284
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: Entry point - setting token:", token ? "provided" : "null");
|
|
285
|
+
try {
|
|
286
|
+
if (!token) {
|
|
287
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: No token provided, clearing token");
|
|
288
|
+
this.clearToken();
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: Validating token before setting");
|
|
292
|
+
if (!this.isTokenValid(token)) {
|
|
293
|
+
console.warn("\u{1F510} TokenManager - SET_TOKEN: Attempted to set invalid or expired token");
|
|
294
|
+
this.clearToken();
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: Token is valid, updating cache");
|
|
298
|
+
this.tokenCache = token;
|
|
299
|
+
this.parsedTokenCache = this.parseToken(token);
|
|
300
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: Storing token in secure storage");
|
|
301
|
+
secureLocalStorage.setToken(token);
|
|
302
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: Synchronizing with crudify");
|
|
303
|
+
this.syncTokenWithCrudify(token);
|
|
304
|
+
console.log("\u{1F510} TokenManager - SET_TOKEN: Token set and synchronized successfully");
|
|
305
|
+
} catch (error) {
|
|
306
|
+
console.error("\u{1F510} TokenManager - SET_TOKEN: Error setting token:", error);
|
|
307
|
+
this.clearToken();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Get the current JWT token
|
|
312
|
+
*/
|
|
313
|
+
getToken() {
|
|
314
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: Entry point - checking cache");
|
|
315
|
+
if (this.tokenCache) {
|
|
316
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: Cache exists, validating token");
|
|
317
|
+
if (this.isTokenValid(this.tokenCache)) {
|
|
318
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: Cache valid, returning cached token");
|
|
319
|
+
return this.tokenCache;
|
|
320
|
+
} else {
|
|
321
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: Cache invalid, clearing cache");
|
|
322
|
+
this.tokenCache = null;
|
|
323
|
+
}
|
|
324
|
+
} else {
|
|
325
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: No cache, loading from storage");
|
|
326
|
+
}
|
|
327
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: Loading from storage");
|
|
328
|
+
this.loadTokenFromStorage();
|
|
329
|
+
console.log("\u{1F510} TokenManager - GET_TOKEN: Returning final token:", !!this.tokenCache);
|
|
330
|
+
return this.tokenCache;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Parse the current JWT token
|
|
334
|
+
*/
|
|
335
|
+
parseToken(token) {
|
|
336
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Entry point - parsing token");
|
|
337
|
+
const targetToken = token !== void 0 ? token : this.tokenCache;
|
|
338
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Target token exists:", !!targetToken);
|
|
339
|
+
if (!targetToken) {
|
|
340
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: No target token, returning null");
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
if (this.tokenCache === targetToken && this.parsedTokenCache) {
|
|
344
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Returning cached parsed token");
|
|
345
|
+
return this.parsedTokenCache;
|
|
346
|
+
}
|
|
347
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Cache miss, parsing token with decodeJwtSafely");
|
|
348
|
+
const parsed = decodeJwtSafely(targetToken);
|
|
349
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Token parsed successfully:", !!parsed);
|
|
350
|
+
if (targetToken === this.tokenCache) {
|
|
351
|
+
console.log("\u{1F510} TokenManager - PARSE_TOKEN: Updating parsed token cache");
|
|
352
|
+
this.parsedTokenCache = parsed;
|
|
353
|
+
}
|
|
354
|
+
return parsed;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Check if a token is valid (properly formatted and not expired)
|
|
358
|
+
*/
|
|
359
|
+
isTokenValid(token) {
|
|
360
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Entry point - checking token validity");
|
|
361
|
+
const targetToken = token !== void 0 ? token : this.tokenCache;
|
|
362
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Target token exists:", !!targetToken);
|
|
363
|
+
if (!targetToken) {
|
|
364
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: No token, returning false");
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
try {
|
|
368
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Checking if token is expired");
|
|
369
|
+
if (isTokenExpired(targetToken)) {
|
|
370
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Token is expired, returning false");
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Token not expired, checking if can be parsed");
|
|
374
|
+
const parsed = decodeJwtSafely(targetToken);
|
|
375
|
+
const isValid = parsed !== null;
|
|
376
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Token parsing result:", isValid);
|
|
377
|
+
return isValid;
|
|
378
|
+
} catch (error) {
|
|
379
|
+
console.log("\u{1F510} TokenManager - IS_TOKEN_VALID: Error validating token:", error);
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Get token expiration time as Date object
|
|
385
|
+
*/
|
|
386
|
+
getTokenExpiration() {
|
|
387
|
+
const token = this.getToken();
|
|
388
|
+
if (!token) return null;
|
|
389
|
+
const parsed = this.parseToken(token);
|
|
390
|
+
if (!parsed?.exp) return null;
|
|
391
|
+
return new Date(parsed.exp * 1e3);
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Clear the current token from all storages and crudify
|
|
395
|
+
*/
|
|
396
|
+
clearToken() {
|
|
397
|
+
console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Entry point - clearing all tokens");
|
|
398
|
+
try {
|
|
399
|
+
console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Clearing cache");
|
|
400
|
+
this.tokenCache = null;
|
|
401
|
+
this.parsedTokenCache = null;
|
|
402
|
+
console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Clearing from secure storage");
|
|
403
|
+
secureLocalStorage.removeItem(this.TOKEN_KEY);
|
|
404
|
+
console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Clearing from crudify");
|
|
405
|
+
crudify.setToken("");
|
|
406
|
+
console.log("\u{1F510} TokenManager - CLEAR_TOKEN: Token cleared from all storages successfully");
|
|
407
|
+
} catch (error) {
|
|
408
|
+
console.warn("\u{1F510} TokenManager - CLEAR_TOKEN: Error clearing token:", error);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Synchronize token with crudify library
|
|
413
|
+
*/
|
|
414
|
+
syncTokenWithCrudify(token) {
|
|
415
|
+
try {
|
|
416
|
+
console.log("\u{1F510} TokenManager - SYNC_TOKEN: Starting token sync with crudify");
|
|
417
|
+
console.log(" - Token to sync:", token ? `${token.substring(0, 20)}...` : "null");
|
|
418
|
+
crudify.setToken(token);
|
|
419
|
+
console.log(" - crudify.getToken() after sync:", crudify.getToken?.() ? `${crudify.getToken?.()?.substring(0, 20)}...` : "null");
|
|
420
|
+
console.log("\u{1F510} TokenManager - Token synchronized with crudify successfully");
|
|
421
|
+
} catch (error) {
|
|
422
|
+
console.warn("\u{1F510} TokenManager - Failed to sync token with crudify:", error);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Refresh token (placeholder for future implementation)
|
|
427
|
+
*/
|
|
428
|
+
async refreshToken() {
|
|
429
|
+
throw new Error("Token refresh not yet implemented");
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Get user information from the current token
|
|
433
|
+
*/
|
|
434
|
+
getUserInfo() {
|
|
435
|
+
const parsed = this.parseToken();
|
|
436
|
+
if (!parsed) {
|
|
437
|
+
return {
|
|
438
|
+
email: null,
|
|
439
|
+
userId: null,
|
|
440
|
+
userIdentifier: null,
|
|
441
|
+
username: null
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
return {
|
|
445
|
+
email: parsed.email || null,
|
|
446
|
+
userId: parsed.sub || null,
|
|
447
|
+
userIdentifier: parsed["cognito:username"] || parsed.email || parsed.sub || null,
|
|
448
|
+
username: parsed["cognito:username"] || null
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Check if user is currently authenticated
|
|
453
|
+
*/
|
|
454
|
+
isAuthenticated() {
|
|
455
|
+
return this.isTokenValid();
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Get time until token expires in minutes
|
|
459
|
+
*/
|
|
460
|
+
getTimeUntilExpiration() {
|
|
461
|
+
const expiration = this.getTokenExpiration();
|
|
462
|
+
if (!expiration) return null;
|
|
463
|
+
const now = /* @__PURE__ */ new Date();
|
|
464
|
+
const minutesUntilExpiry = Math.floor((expiration.getTime() - now.getTime()) / (60 * 1e3));
|
|
465
|
+
return Math.max(0, minutesUntilExpiry);
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Cleanup resources (call when the component unmounts)
|
|
469
|
+
*/
|
|
470
|
+
cleanup() {
|
|
471
|
+
if (this.expirationCheckInterval) {
|
|
472
|
+
window.clearInterval(this.expirationCheckInterval);
|
|
473
|
+
this.expirationCheckInterval = null;
|
|
474
|
+
}
|
|
475
|
+
if (this.storageEventListener) {
|
|
476
|
+
window.removeEventListener("storage", this.storageEventListener);
|
|
477
|
+
this.storageEventListener = null;
|
|
478
|
+
}
|
|
479
|
+
console.log("\u{1F510} TokenManager - Cleanup completed");
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Get debug information about the current token state
|
|
483
|
+
*/
|
|
484
|
+
getDebugInfo() {
|
|
485
|
+
const token = this.getToken();
|
|
486
|
+
const parsed = this.parseToken();
|
|
487
|
+
const expiration = this.getTokenExpiration();
|
|
488
|
+
return {
|
|
489
|
+
hasToken: !!token,
|
|
490
|
+
tokenLength: token?.length || 0,
|
|
491
|
+
isValid: this.isTokenValid(),
|
|
492
|
+
isAuthenticated: this.isAuthenticated(),
|
|
493
|
+
expiration: expiration?.toISOString() || null,
|
|
494
|
+
minutesUntilExpiry: this.getTimeUntilExpiration(),
|
|
495
|
+
userInfo: this.getUserInfo(),
|
|
496
|
+
parsedTokenKeys: parsed ? Object.keys(parsed) : []
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
_TokenManager.instance = null;
|
|
501
|
+
var TokenManager = _TokenManager;
|
|
502
|
+
var tokenManager = TokenManager.getInstance();
|
|
503
|
+
|
|
504
|
+
export {
|
|
505
|
+
secureSessionStorage,
|
|
506
|
+
secureLocalStorage,
|
|
507
|
+
decodeJwtSafely,
|
|
508
|
+
getCurrentUserEmail,
|
|
509
|
+
isTokenExpired,
|
|
510
|
+
TokenManager,
|
|
511
|
+
tokenManager
|
|
512
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -692,6 +692,11 @@ var init_jwtUtils = __esm({
|
|
|
692
692
|
});
|
|
693
693
|
|
|
694
694
|
// src/core/TokenManager.ts
|
|
695
|
+
var TokenManager_exports = {};
|
|
696
|
+
__export(TokenManager_exports, {
|
|
697
|
+
TokenManager: () => TokenManager,
|
|
698
|
+
tokenManager: () => tokenManager
|
|
699
|
+
});
|
|
695
700
|
var import_crudify_browser3, _TokenManager, TokenManager, tokenManager;
|
|
696
701
|
var init_TokenManager = __esm({
|
|
697
702
|
"src/core/TokenManager.ts"() {
|
|
@@ -943,8 +948,11 @@ var init_TokenManager = __esm({
|
|
|
943
948
|
*/
|
|
944
949
|
syncTokenWithCrudify(token) {
|
|
945
950
|
try {
|
|
951
|
+
console.log("\u{1F510} TokenManager - SYNC_TOKEN: Starting token sync with crudify");
|
|
952
|
+
console.log(" - Token to sync:", token ? `${token.substring(0, 20)}...` : "null");
|
|
946
953
|
import_crudify_browser3.default.setToken(token);
|
|
947
|
-
console.log("
|
|
954
|
+
console.log(" - crudify.getToken() after sync:", import_crudify_browser3.default.getToken?.() ? `${import_crudify_browser3.default.getToken?.()?.substring(0, 20)}...` : "null");
|
|
955
|
+
console.log("\u{1F510} TokenManager - Token synchronized with crudify successfully");
|
|
948
956
|
} catch (error) {
|
|
949
957
|
console.warn("\u{1F510} TokenManager - Failed to sync token with crudify:", error);
|
|
950
958
|
}
|
|
@@ -3690,10 +3698,27 @@ var useCrudifyInstance = () => {
|
|
|
3690
3698
|
console.log(`\u2705 useCrudifyInstance - ${operationName}: Crudify is ready`);
|
|
3691
3699
|
}
|
|
3692
3700
|
}, [isReady, waitForReady]);
|
|
3701
|
+
const ensureTokenSync = (0, import_react15.useCallback)(async () => {
|
|
3702
|
+
const { tokenManager: tokenManager2 } = await Promise.resolve().then(() => (init_TokenManager(), TokenManager_exports));
|
|
3703
|
+
const tmToken = tokenManager2.getToken();
|
|
3704
|
+
const crudifyToken = import_crudify_browser7.default.getToken?.();
|
|
3705
|
+
if (tmToken && tmToken !== crudifyToken) {
|
|
3706
|
+
console.log("\u{1F504} useCrudifyInstance - Forcing token sync for authenticated operation");
|
|
3707
|
+
import_crudify_browser7.default.setToken(tmToken);
|
|
3708
|
+
}
|
|
3709
|
+
}, []);
|
|
3693
3710
|
const getStructure = (0, import_react15.useCallback)(async (options) => {
|
|
3694
3711
|
console.log("\u{1F4E1} useCrudifyInstance - getStructure: Starting");
|
|
3695
3712
|
await ensureReady("getStructure");
|
|
3696
3713
|
try {
|
|
3714
|
+
const { tokenManager: tokenManager2 } = await Promise.resolve().then(() => (init_TokenManager(), TokenManager_exports));
|
|
3715
|
+
const tmToken = tokenManager2.getToken();
|
|
3716
|
+
const crudifyToken = import_crudify_browser7.default.getToken?.();
|
|
3717
|
+
console.log("\u{1F510} useCrudifyInstance - getStructure: Token status check:");
|
|
3718
|
+
console.log(" - TokenManager token:", tmToken ? `${tmToken.substring(0, 20)}...` : "null");
|
|
3719
|
+
console.log(" - crudify.getToken():", crudifyToken ? `${crudifyToken.substring(0, 20)}...` : "null");
|
|
3720
|
+
console.log(" - Tokens match:", tmToken === crudifyToken);
|
|
3721
|
+
await ensureTokenSync();
|
|
3697
3722
|
console.log("\u{1F4E1} useCrudifyInstance - getStructure: Calling crudify.getStructure");
|
|
3698
3723
|
const response = await import_crudify_browser7.default.getStructure(options);
|
|
3699
3724
|
console.log("\u{1F4E1} useCrudifyInstance - getStructure: Response received", response);
|
|
@@ -3702,7 +3727,7 @@ var useCrudifyInstance = () => {
|
|
|
3702
3727
|
console.error("\u{1F4E1} useCrudifyInstance - getStructure: Error", error);
|
|
3703
3728
|
throw error;
|
|
3704
3729
|
}
|
|
3705
|
-
}, [ensureReady]);
|
|
3730
|
+
}, [ensureReady, ensureTokenSync]);
|
|
3706
3731
|
const getStructurePublic = (0, import_react15.useCallback)(async (options) => {
|
|
3707
3732
|
console.log("\u{1F4E1} useCrudifyInstance - getStructurePublic: Starting");
|
|
3708
3733
|
await ensureReady("getStructurePublic");
|
|
@@ -3718,6 +3743,7 @@ var useCrudifyInstance = () => {
|
|
|
3718
3743
|
}, [ensureReady]);
|
|
3719
3744
|
const readItems = (0, import_react15.useCallback)(async (moduleKey, filter, options) => {
|
|
3720
3745
|
await ensureReady("readItems");
|
|
3746
|
+
await ensureTokenSync();
|
|
3721
3747
|
if (moduleKey === "__test_connection__") {
|
|
3722
3748
|
console.error("\u{1F6A8} FOUND TEST CONNECTION CALL in useCrudifyInstance! Stack trace:");
|
|
3723
3749
|
console.error(new Error().stack);
|
|
@@ -3729,7 +3755,7 @@ var useCrudifyInstance = () => {
|
|
|
3729
3755
|
console.error("\u{1F4CA} useCrudifyInstance - readItems error:", error);
|
|
3730
3756
|
throw error;
|
|
3731
3757
|
}
|
|
3732
|
-
}, [ensureReady]);
|
|
3758
|
+
}, [ensureReady, ensureTokenSync]);
|
|
3733
3759
|
const readItem = (0, import_react15.useCallback)(async (moduleKey, filter, options) => {
|
|
3734
3760
|
await ensureReady("readItem");
|
|
3735
3761
|
try {
|
package/dist/index.mjs
CHANGED
|
@@ -2,15 +2,17 @@ import {
|
|
|
2
2
|
CrudifyDataProvider,
|
|
3
3
|
configurationManager,
|
|
4
4
|
crudifyInitializer,
|
|
5
|
-
decodeJwtSafely,
|
|
6
5
|
getCookie,
|
|
6
|
+
useCrudifyDataContext
|
|
7
|
+
} from "./chunk-GY5F6KOF.mjs";
|
|
8
|
+
import {
|
|
9
|
+
decodeJwtSafely,
|
|
7
10
|
getCurrentUserEmail,
|
|
8
11
|
isTokenExpired,
|
|
9
12
|
secureLocalStorage,
|
|
10
13
|
secureSessionStorage,
|
|
11
|
-
tokenManager
|
|
12
|
-
|
|
13
|
-
} from "./chunk-LR5FXHGC.mjs";
|
|
14
|
+
tokenManager
|
|
15
|
+
} from "./chunk-M7V4UGCN.mjs";
|
|
14
16
|
|
|
15
17
|
// src/index.ts
|
|
16
18
|
import { default as default2 } from "@nocios/crudify-browser";
|
|
@@ -2388,7 +2390,7 @@ var useCrudifyInstance = () => {
|
|
|
2388
2390
|
}
|
|
2389
2391
|
try {
|
|
2390
2392
|
console.log("\u{1F504} useCrudifyInstance - waitForReady: Using CrudifyInitializer.waitForInitialization()");
|
|
2391
|
-
const { crudifyInitializer: crudifyInitializer2 } = await import("./CrudifyDataProvider-
|
|
2393
|
+
const { crudifyInitializer: crudifyInitializer2 } = await import("./CrudifyDataProvider-5GXGNQKI.mjs");
|
|
2392
2394
|
await crudifyInitializer2.waitForInitialization();
|
|
2393
2395
|
console.log("\u2705 useCrudifyInstance - waitForReady: CrudifyInitializer completed");
|
|
2394
2396
|
if (!crudifyInitializer2.isReady()) {
|
|
@@ -2408,10 +2410,27 @@ var useCrudifyInstance = () => {
|
|
|
2408
2410
|
console.log(`\u2705 useCrudifyInstance - ${operationName}: Crudify is ready`);
|
|
2409
2411
|
}
|
|
2410
2412
|
}, [isReady, waitForReady]);
|
|
2413
|
+
const ensureTokenSync = useCallback4(async () => {
|
|
2414
|
+
const { tokenManager: tokenManager2 } = await import("./TokenManager-AYUNIXQU.mjs");
|
|
2415
|
+
const tmToken = tokenManager2.getToken();
|
|
2416
|
+
const crudifyToken = crudify5.getToken?.();
|
|
2417
|
+
if (tmToken && tmToken !== crudifyToken) {
|
|
2418
|
+
console.log("\u{1F504} useCrudifyInstance - Forcing token sync for authenticated operation");
|
|
2419
|
+
crudify5.setToken(tmToken);
|
|
2420
|
+
}
|
|
2421
|
+
}, []);
|
|
2411
2422
|
const getStructure = useCallback4(async (options) => {
|
|
2412
2423
|
console.log("\u{1F4E1} useCrudifyInstance - getStructure: Starting");
|
|
2413
2424
|
await ensureReady("getStructure");
|
|
2414
2425
|
try {
|
|
2426
|
+
const { tokenManager: tokenManager2 } = await import("./TokenManager-AYUNIXQU.mjs");
|
|
2427
|
+
const tmToken = tokenManager2.getToken();
|
|
2428
|
+
const crudifyToken = crudify5.getToken?.();
|
|
2429
|
+
console.log("\u{1F510} useCrudifyInstance - getStructure: Token status check:");
|
|
2430
|
+
console.log(" - TokenManager token:", tmToken ? `${tmToken.substring(0, 20)}...` : "null");
|
|
2431
|
+
console.log(" - crudify.getToken():", crudifyToken ? `${crudifyToken.substring(0, 20)}...` : "null");
|
|
2432
|
+
console.log(" - Tokens match:", tmToken === crudifyToken);
|
|
2433
|
+
await ensureTokenSync();
|
|
2415
2434
|
console.log("\u{1F4E1} useCrudifyInstance - getStructure: Calling crudify.getStructure");
|
|
2416
2435
|
const response = await crudify5.getStructure(options);
|
|
2417
2436
|
console.log("\u{1F4E1} useCrudifyInstance - getStructure: Response received", response);
|
|
@@ -2420,7 +2439,7 @@ var useCrudifyInstance = () => {
|
|
|
2420
2439
|
console.error("\u{1F4E1} useCrudifyInstance - getStructure: Error", error);
|
|
2421
2440
|
throw error;
|
|
2422
2441
|
}
|
|
2423
|
-
}, [ensureReady]);
|
|
2442
|
+
}, [ensureReady, ensureTokenSync]);
|
|
2424
2443
|
const getStructurePublic = useCallback4(async (options) => {
|
|
2425
2444
|
console.log("\u{1F4E1} useCrudifyInstance - getStructurePublic: Starting");
|
|
2426
2445
|
await ensureReady("getStructurePublic");
|
|
@@ -2436,6 +2455,7 @@ var useCrudifyInstance = () => {
|
|
|
2436
2455
|
}, [ensureReady]);
|
|
2437
2456
|
const readItems = useCallback4(async (moduleKey, filter, options) => {
|
|
2438
2457
|
await ensureReady("readItems");
|
|
2458
|
+
await ensureTokenSync();
|
|
2439
2459
|
if (moduleKey === "__test_connection__") {
|
|
2440
2460
|
console.error("\u{1F6A8} FOUND TEST CONNECTION CALL in useCrudifyInstance! Stack trace:");
|
|
2441
2461
|
console.error(new Error().stack);
|
|
@@ -2447,7 +2467,7 @@ var useCrudifyInstance = () => {
|
|
|
2447
2467
|
console.error("\u{1F4CA} useCrudifyInstance - readItems error:", error);
|
|
2448
2468
|
throw error;
|
|
2449
2469
|
}
|
|
2450
|
-
}, [ensureReady]);
|
|
2470
|
+
}, [ensureReady, ensureTokenSync]);
|
|
2451
2471
|
const readItem = useCallback4(async (moduleKey, filter, options) => {
|
|
2452
2472
|
await ensureReady("readItem");
|
|
2453
2473
|
try {
|
|
@@ -2530,7 +2550,7 @@ var useCrudifyInstance = () => {
|
|
|
2530
2550
|
};
|
|
2531
2551
|
var getCrudifyInstanceAsync = async () => {
|
|
2532
2552
|
console.log("\u{1F504} getCrudifyInstanceAsync - Starting");
|
|
2533
|
-
const { crudifyInitializer: crudifyInitializer2 } = await import("./CrudifyDataProvider-
|
|
2553
|
+
const { crudifyInitializer: crudifyInitializer2 } = await import("./CrudifyDataProvider-5GXGNQKI.mjs");
|
|
2534
2554
|
console.log("\u{1F504} getCrudifyInstanceAsync - Checking if ready");
|
|
2535
2555
|
console.log(" - crudifyInitializer.isReady():", crudifyInitializer2.isReady());
|
|
2536
2556
|
console.log(" - crudifyInitializer.getStatus():", crudifyInitializer2.getStatus());
|
|
@@ -2549,7 +2569,7 @@ var getCrudifyInstanceAsync = async () => {
|
|
|
2549
2569
|
return crudify5;
|
|
2550
2570
|
};
|
|
2551
2571
|
var getCrudifyInstanceSync = async () => {
|
|
2552
|
-
const { crudifyInitializer: crudifyInitializer2 } = await import("./CrudifyDataProvider-
|
|
2572
|
+
const { crudifyInitializer: crudifyInitializer2 } = await import("./CrudifyDataProvider-5GXGNQKI.mjs");
|
|
2553
2573
|
if (!crudifyInitializer2.isReady()) {
|
|
2554
2574
|
throw new Error("Crudify not ready. Use getCrudifyInstanceAsync() or call this from within a React component using useCrudifyInstance()");
|
|
2555
2575
|
}
|