shogun-button-react 6.4.1 → 6.4.2
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.
|
@@ -23,6 +23,7 @@ type ShogunContextType = {
|
|
|
23
23
|
remove: (path: string) => Promise<void>;
|
|
24
24
|
completePendingSignup: () => void;
|
|
25
25
|
hasPendingSignup: boolean;
|
|
26
|
+
setHasPendingSignup: (value: boolean) => void;
|
|
26
27
|
};
|
|
27
28
|
export declare const useShogun: () => ShogunContextType;
|
|
28
29
|
type ShogunButtonProviderProps = {
|
|
@@ -27,6 +27,7 @@ const defaultShogunContext = {
|
|
|
27
27
|
remove: async () => { },
|
|
28
28
|
completePendingSignup: () => { },
|
|
29
29
|
hasPendingSignup: false,
|
|
30
|
+
setHasPendingSignup: (_value) => { },
|
|
30
31
|
};
|
|
31
32
|
// Create context using React's createContext directly
|
|
32
33
|
const ShogunContext = createContext(defaultShogunContext);
|
|
@@ -38,6 +39,7 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
|
|
|
38
39
|
const [isLoggedIn, setIsLoggedIn] = useState(false);
|
|
39
40
|
const [userPub, setUserPub] = useState(null);
|
|
40
41
|
const [username, setUsername] = useState(null);
|
|
42
|
+
const [hasPendingSignup, setHasPendingSignup] = useState(false);
|
|
41
43
|
// Effetto per gestire l'inizializzazione e pulizia
|
|
42
44
|
useEffect(() => {
|
|
43
45
|
var _a, _b;
|
|
@@ -353,6 +355,8 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
|
|
|
353
355
|
seedPhrase: result.seedPhrase,
|
|
354
356
|
authMethod: authMethod,
|
|
355
357
|
};
|
|
358
|
+
const pendingBackup = Boolean(result.seedPhrase || result.trapdoor);
|
|
359
|
+
setHasPendingSignup(pendingBackup);
|
|
356
360
|
onSignupSuccess === null || onSignupSuccess === void 0 ? void 0 : onSignupSuccess(signupPayload);
|
|
357
361
|
}
|
|
358
362
|
else {
|
|
@@ -486,8 +490,9 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
|
|
|
486
490
|
const gunPlugin = null;
|
|
487
491
|
// Plugin hooks removed - GunAdvancedPlugin no longer available
|
|
488
492
|
const pluginHooks = {};
|
|
489
|
-
const completePendingSignup = React.useCallback(() => {
|
|
490
|
-
|
|
493
|
+
const completePendingSignup = React.useCallback(() => {
|
|
494
|
+
setHasPendingSignup(false);
|
|
495
|
+
}, [setHasPendingSignup]);
|
|
491
496
|
// Create a properly typed context value
|
|
492
497
|
const contextValue = React.useMemo(() => ({
|
|
493
498
|
core,
|
|
@@ -507,6 +512,7 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
|
|
|
507
512
|
gunPlugin,
|
|
508
513
|
completePendingSignup,
|
|
509
514
|
hasPendingSignup,
|
|
515
|
+
setHasPendingSignup,
|
|
510
516
|
put: async (path, data) => {
|
|
511
517
|
if (isShogunCore(core)) {
|
|
512
518
|
if (!core.gun)
|
|
@@ -566,6 +572,8 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
|
|
|
566
572
|
gunPlugin,
|
|
567
573
|
pluginHooks,
|
|
568
574
|
completePendingSignup,
|
|
575
|
+
hasPendingSignup,
|
|
576
|
+
setHasPendingSignup,
|
|
569
577
|
]);
|
|
570
578
|
// Provide the context value to children
|
|
571
579
|
return (React.createElement(ShogunContext.Provider, { value: contextValue }, children));
|
|
@@ -615,7 +623,7 @@ const ExportIcon = () => (React.createElement("svg", { xmlns: "http://www.w3.org
|
|
|
615
623
|
// Component for Shogun login button
|
|
616
624
|
export const ShogunButton = (() => {
|
|
617
625
|
const Button = () => {
|
|
618
|
-
const { isLoggedIn, username, logout, login, signUp, core, options, exportGunPair, importGunPair, hasPlugin, } = useShogun();
|
|
626
|
+
const { isLoggedIn, username, logout, login, signUp, core, options, exportGunPair, importGunPair, hasPlugin, hasPendingSignup, setHasPendingSignup, } = useShogun();
|
|
619
627
|
// Form states
|
|
620
628
|
const [modalIsOpen, setModalIsOpen] = useState(false);
|
|
621
629
|
const [formUsername, setFormUsername] = useState("");
|
|
@@ -657,6 +665,20 @@ export const ShogunButton = (() => {
|
|
|
657
665
|
};
|
|
658
666
|
}
|
|
659
667
|
}, [dropdownOpen]);
|
|
668
|
+
useEffect(() => {
|
|
669
|
+
if (hasPendingSignup) {
|
|
670
|
+
setModalIsOpen(true);
|
|
671
|
+
if (authView !== "webauthn-signup-result" &&
|
|
672
|
+
authView !== "zkproof-signup-result") {
|
|
673
|
+
if (webauthnSeedPhrase) {
|
|
674
|
+
setAuthView("webauthn-signup-result");
|
|
675
|
+
}
|
|
676
|
+
else if (zkSignupTrapdoor) {
|
|
677
|
+
setAuthView("zkproof-signup-result");
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}, [hasPendingSignup, authView, webauthnSeedPhrase, zkSignupTrapdoor]);
|
|
660
682
|
// If already logged in, show only logout button
|
|
661
683
|
if (isLoggedIn && username && !modalIsOpen) {
|
|
662
684
|
return (React.createElement("div", { className: "shogun-logged-in-container" },
|
|
@@ -855,6 +877,7 @@ export const ShogunButton = (() => {
|
|
|
855
877
|
setZkSignupTrapdoor(trapdoorValue);
|
|
856
878
|
setShowZkTrapdoorCopySuccess(false);
|
|
857
879
|
setAuthView("zkproof-signup-result");
|
|
880
|
+
setHasPendingSignup(true);
|
|
858
881
|
}
|
|
859
882
|
else {
|
|
860
883
|
setAuthView("options");
|
|
@@ -991,11 +1014,13 @@ export const ShogunButton = (() => {
|
|
|
991
1014
|
const closeModal = () => {
|
|
992
1015
|
setError("");
|
|
993
1016
|
setModalIsOpen(false);
|
|
1017
|
+
setHasPendingSignup(false);
|
|
994
1018
|
};
|
|
995
1019
|
const finalizeZkProofSignup = () => {
|
|
996
1020
|
setError("");
|
|
997
1021
|
resetForm();
|
|
998
1022
|
setModalIsOpen(false);
|
|
1023
|
+
setHasPendingSignup(false);
|
|
999
1024
|
};
|
|
1000
1025
|
const toggleMode = () => {
|
|
1001
1026
|
resetForm();
|