shogun-button-react 6.9.3 → 6.9.4
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/components/ShogunButton.js +19 -22
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -61,9 +61,9 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
|
|
|
61
61
|
}
|
|
62
62
|
// Poiché il metodo 'on' non esiste su ShogunCore,
|
|
63
63
|
// gestiamo gli stati direttamente nei metodi di login/logout
|
|
64
|
-
}, [core
|
|
64
|
+
}, [core]);
|
|
65
65
|
// RxJS observe method
|
|
66
|
-
const observe = (path) => {
|
|
66
|
+
const observe = React.useCallback((path) => {
|
|
67
67
|
var _a;
|
|
68
68
|
if (!core) {
|
|
69
69
|
return new Observable();
|
|
@@ -74,9 +74,9 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
|
|
|
74
74
|
return observable;
|
|
75
75
|
}
|
|
76
76
|
return new Observable();
|
|
77
|
-
};
|
|
77
|
+
}, [core]);
|
|
78
78
|
// Unified login
|
|
79
|
-
const login = async (method, ...args) => {
|
|
79
|
+
const login = React.useCallback(async (method, ...args) => {
|
|
80
80
|
var _a, _b;
|
|
81
81
|
try {
|
|
82
82
|
if (!core) {
|
|
@@ -248,9 +248,9 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
|
|
|
248
248
|
onError === null || onError === void 0 ? void 0 : onError(error.message || "Error during login");
|
|
249
249
|
return { success: false, error: error.message };
|
|
250
250
|
}
|
|
251
|
-
};
|
|
251
|
+
}, [core, onLoginSuccess, onError]);
|
|
252
252
|
// Unified signup
|
|
253
|
-
const signUp = async (method, ...args) => {
|
|
253
|
+
const signUp = React.useCallback(async (method, ...args) => {
|
|
254
254
|
var _a, _b, _c;
|
|
255
255
|
try {
|
|
256
256
|
if (!core) {
|
|
@@ -397,18 +397,18 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
|
|
|
397
397
|
onError === null || onError === void 0 ? void 0 : onError(error.message || "Error during registration");
|
|
398
398
|
return { success: false, error: error.message };
|
|
399
399
|
}
|
|
400
|
-
};
|
|
400
|
+
}, [core, onSignupSuccess, onError]);
|
|
401
401
|
// Logout
|
|
402
|
-
const logout = () => {
|
|
402
|
+
const logout = React.useCallback(() => {
|
|
403
403
|
if (isShogunCore(core)) {
|
|
404
404
|
core.logout();
|
|
405
405
|
}
|
|
406
406
|
setIsLoggedIn(false);
|
|
407
407
|
setUserPub(null);
|
|
408
408
|
setUsername(null);
|
|
409
|
-
};
|
|
409
|
+
}, [core]);
|
|
410
410
|
// Implementazione del metodo setProvider
|
|
411
|
-
const setProvider = (provider) => {
|
|
411
|
+
const setProvider = React.useCallback((provider) => {
|
|
412
412
|
var _a;
|
|
413
413
|
if (!core) {
|
|
414
414
|
return false;
|
|
@@ -440,21 +440,21 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
|
|
|
440
440
|
console.error("Error setting provider:", error);
|
|
441
441
|
return false;
|
|
442
442
|
}
|
|
443
|
-
};
|
|
444
|
-
const hasPlugin = (name) => {
|
|
443
|
+
}, [core]);
|
|
444
|
+
const hasPlugin = React.useCallback((name) => {
|
|
445
445
|
if (isShogunCore(core)) {
|
|
446
446
|
return core.hasPlugin(name);
|
|
447
447
|
}
|
|
448
448
|
return false;
|
|
449
|
-
};
|
|
450
|
-
const getPlugin = (name) => {
|
|
449
|
+
}, [core]);
|
|
450
|
+
const getPlugin = React.useCallback((name) => {
|
|
451
451
|
if (isShogunCore(core)) {
|
|
452
452
|
return core.getPlugin(name);
|
|
453
453
|
}
|
|
454
454
|
return undefined;
|
|
455
|
-
};
|
|
455
|
+
}, [core]);
|
|
456
456
|
// Export Gun pair functionality
|
|
457
|
-
const exportGunPair = async (password) => {
|
|
457
|
+
const exportGunPair = React.useCallback(async (password) => {
|
|
458
458
|
if (!core) {
|
|
459
459
|
throw new Error("SDK not initialized");
|
|
460
460
|
}
|
|
@@ -482,9 +482,9 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
|
|
|
482
482
|
catch (error) {
|
|
483
483
|
throw new Error(`Failed to export Gun pair: ${error.message}`);
|
|
484
484
|
}
|
|
485
|
-
};
|
|
485
|
+
}, [core, isLoggedIn]);
|
|
486
486
|
// Import Gun pair functionality
|
|
487
|
-
const importGunPair = async (pairData, password) => {
|
|
487
|
+
const importGunPair = React.useCallback(async (pairData, password) => {
|
|
488
488
|
if (!core) {
|
|
489
489
|
throw new Error("SDK not initialized");
|
|
490
490
|
}
|
|
@@ -514,11 +514,9 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
|
|
|
514
514
|
catch (error) {
|
|
515
515
|
throw new Error(`Failed to import Gun pair: ${error.message}`);
|
|
516
516
|
}
|
|
517
|
-
};
|
|
517
|
+
}, [core, login]);
|
|
518
518
|
// Plugin initialization removed - GunAdvancedPlugin no longer available
|
|
519
519
|
const gunPlugin = null;
|
|
520
|
-
// Plugin hooks removed - GunAdvancedPlugin no longer available
|
|
521
|
-
const pluginHooks = {};
|
|
522
520
|
const completePendingSignup = React.useCallback(() => {
|
|
523
521
|
setHasPendingSignup(false);
|
|
524
522
|
}, [setHasPendingSignup]);
|
|
@@ -599,7 +597,6 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
|
|
|
599
597
|
exportGunPair,
|
|
600
598
|
importGunPair,
|
|
601
599
|
gunPlugin,
|
|
602
|
-
pluginHooks,
|
|
603
600
|
completePendingSignup,
|
|
604
601
|
hasPendingSignup,
|
|
605
602
|
setHasPendingSignup,
|