shogun-button-react 1.9.6 → 1.10.0
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/CHANGELOG.md +0 -0
- package/README.md +0 -0
- package/dist/components/ShogunButton.d.ts +5 -4
- package/dist/components/ShogunButton.js +50 -50
- package/dist/connector.d.ts +0 -0
- package/dist/connector.js +8 -6
- package/dist/dist/styles/index.css +0 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +0 -0
- package/dist/styles/index.css +0 -0
- package/dist/types/connector-options.d.ts +3 -1
- package/dist/types/connector-options.js +0 -0
- package/package.json +2 -2
- package/src/styles/index.css +0 -0
package/CHANGELOG.md
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { ShogunCore } from "shogun-core";
|
|
2
|
+
import { IGunInstance, ShogunCore } from "shogun-core";
|
|
3
3
|
import { Observable } from "rxjs";
|
|
4
4
|
import "../styles/index.css";
|
|
5
5
|
type ShogunContextType = {
|
|
6
|
-
|
|
6
|
+
core: ShogunCore | null;
|
|
7
7
|
options: any;
|
|
8
8
|
isLoggedIn: boolean;
|
|
9
9
|
isConnected: boolean;
|
|
@@ -21,7 +21,8 @@ type ShogunContextType = {
|
|
|
21
21
|
export declare const useShogun: () => ShogunContextType;
|
|
22
22
|
type ShogunButtonProviderProps = {
|
|
23
23
|
children: React.ReactNode;
|
|
24
|
-
|
|
24
|
+
core: ShogunCore;
|
|
25
|
+
gun: IGunInstance<any>;
|
|
25
26
|
options: any;
|
|
26
27
|
onLoginSuccess?: (data: {
|
|
27
28
|
userPub: string;
|
|
@@ -38,7 +39,7 @@ type ShogunButtonProviderProps = {
|
|
|
38
39
|
onError?: (error: string) => void;
|
|
39
40
|
onLogout?: () => void;
|
|
40
41
|
};
|
|
41
|
-
export declare function ShogunButtonProvider({ children,
|
|
42
|
+
export declare function ShogunButtonProvider({ children, core, gun, options, onLoginSuccess, onSignupSuccess, onError, onLogout, }: ShogunButtonProviderProps): React.JSX.Element;
|
|
42
43
|
type ShogunButtonComponent = React.FC & {
|
|
43
44
|
Provider: typeof ShogunButtonProvider;
|
|
44
45
|
useShogun: typeof useShogun;
|
|
@@ -40,7 +40,7 @@ const rxjs_1 = require("rxjs");
|
|
|
40
40
|
require("../styles/index.css");
|
|
41
41
|
// Default context
|
|
42
42
|
const defaultShogunContext = {
|
|
43
|
-
|
|
43
|
+
core: null,
|
|
44
44
|
options: {},
|
|
45
45
|
isLoggedIn: false,
|
|
46
46
|
isConnected: false,
|
|
@@ -61,7 +61,7 @@ const ShogunContext = (0, react_1.createContext)(defaultShogunContext);
|
|
|
61
61
|
const useShogun = () => (0, react_1.useContext)(ShogunContext);
|
|
62
62
|
exports.useShogun = useShogun;
|
|
63
63
|
// Provider component
|
|
64
|
-
function ShogunButtonProvider({ children,
|
|
64
|
+
function ShogunButtonProvider({ children, core, gun, options, onLoginSuccess, onSignupSuccess, onError, onLogout, // AGGIUNTA
|
|
65
65
|
}) {
|
|
66
66
|
var _a, _b;
|
|
67
67
|
// Use React's useState directly
|
|
@@ -71,8 +71,8 @@ function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, onSignup
|
|
|
71
71
|
// Effetto per gestire l'inizializzazione e pulizia
|
|
72
72
|
(0, react_1.useEffect)(() => {
|
|
73
73
|
var _a, _b;
|
|
74
|
-
console.log(`🔧 ShogunButtonProvider useEffect - SDK available:`, !!
|
|
75
|
-
if (!
|
|
74
|
+
console.log(`🔧 ShogunButtonProvider useEffect - SDK available:`, !!core);
|
|
75
|
+
if (!core)
|
|
76
76
|
return;
|
|
77
77
|
// Check for existing session data
|
|
78
78
|
const sessionData = sessionStorage.getItem("gunSessionData");
|
|
@@ -83,11 +83,11 @@ function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, onSignup
|
|
|
83
83
|
});
|
|
84
84
|
// Verifichiamo se l'utente è già loggato all'inizializzazione
|
|
85
85
|
// Aggiungiamo un controllo di sicurezza per verificare se il metodo esiste
|
|
86
|
-
if (
|
|
87
|
-
const isLoggedIn =
|
|
86
|
+
if (core && typeof core.isLoggedIn === "function") {
|
|
87
|
+
const isLoggedIn = core.isLoggedIn();
|
|
88
88
|
console.log(`🔧 SDK isLoggedIn(): ${isLoggedIn}`);
|
|
89
89
|
if (isLoggedIn) {
|
|
90
|
-
const pub = (_b = (_a =
|
|
90
|
+
const pub = (_b = (_a = core.gun.user()) === null || _a === void 0 ? void 0 : _a.is) === null || _b === void 0 ? void 0 : _b.pub;
|
|
91
91
|
console.log(`🔧 User already logged in with pub: ${pub === null || pub === void 0 ? void 0 : pub.slice(0, 8)}...`);
|
|
92
92
|
if (pub) {
|
|
93
93
|
console.log(`🔧 Setting user state from existing session`);
|
|
@@ -119,20 +119,20 @@ function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, onSignup
|
|
|
119
119
|
}
|
|
120
120
|
// Poiché il metodo 'on' non esiste su ShogunCore,
|
|
121
121
|
// gestiamo gli stati direttamente nei metodi di login/logout
|
|
122
|
-
}, [
|
|
122
|
+
}, [core, onLoginSuccess]);
|
|
123
123
|
// RxJS observe method
|
|
124
124
|
const observe = (path) => {
|
|
125
|
-
if (!
|
|
125
|
+
if (!core) {
|
|
126
126
|
return new rxjs_1.Observable();
|
|
127
127
|
}
|
|
128
|
-
return
|
|
128
|
+
return core.rx.observe(path);
|
|
129
129
|
};
|
|
130
130
|
// Unified login
|
|
131
131
|
const login = async (method, ...args) => {
|
|
132
132
|
var _a, _b, _c;
|
|
133
133
|
console.log(`🔧 ShogunButtonProvider.login called with method: ${method}`, args);
|
|
134
134
|
try {
|
|
135
|
-
if (!
|
|
135
|
+
if (!core) {
|
|
136
136
|
throw new Error("SDK not initialized");
|
|
137
137
|
}
|
|
138
138
|
let result;
|
|
@@ -143,7 +143,7 @@ function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, onSignup
|
|
|
143
143
|
case "password":
|
|
144
144
|
username = args[0];
|
|
145
145
|
console.log(`🔧 Password login for username: ${username}`);
|
|
146
|
-
result = await
|
|
146
|
+
result = await core.login(args[0], args[1]);
|
|
147
147
|
break;
|
|
148
148
|
case "pair":
|
|
149
149
|
// New pair authentication method
|
|
@@ -153,12 +153,12 @@ function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, onSignup
|
|
|
153
153
|
}
|
|
154
154
|
console.log(`🔧 Pair login with pub: ${(_a = pair.pub) === null || _a === void 0 ? void 0 : _a.slice(0, 8)}...`);
|
|
155
155
|
// Prefer official API from shogun-core when available
|
|
156
|
-
if (typeof
|
|
157
|
-
result = await
|
|
156
|
+
if (typeof core.loginWithPair === "function") {
|
|
157
|
+
result = await core.loginWithPair(pair);
|
|
158
158
|
}
|
|
159
159
|
else {
|
|
160
160
|
result = await new Promise((resolve, reject) => {
|
|
161
|
-
|
|
161
|
+
core.gun.user().auth(pair, (ack) => {
|
|
162
162
|
if (ack.err) {
|
|
163
163
|
reject(new Error(`Pair authentication failed: ${ack.err}`));
|
|
164
164
|
return;
|
|
@@ -180,7 +180,7 @@ function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, onSignup
|
|
|
180
180
|
case "webauthn":
|
|
181
181
|
username = args[0];
|
|
182
182
|
console.log(`🔧 WebAuthn login for username: ${username}`);
|
|
183
|
-
const webauthn =
|
|
183
|
+
const webauthn = core.getPlugin("webauthn");
|
|
184
184
|
if (!webauthn)
|
|
185
185
|
throw new Error("WebAuthn plugin not available");
|
|
186
186
|
result = await webauthn.login(username);
|
|
@@ -188,7 +188,7 @@ function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, onSignup
|
|
|
188
188
|
break;
|
|
189
189
|
case "web3":
|
|
190
190
|
console.log(`🔧 Web3 login initiated`);
|
|
191
|
-
const web3 =
|
|
191
|
+
const web3 = core.getPlugin("web3");
|
|
192
192
|
if (!web3)
|
|
193
193
|
throw new Error("Web3 plugin not available");
|
|
194
194
|
const connectionResult = await web3.connectMetaMask();
|
|
@@ -202,7 +202,7 @@ function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, onSignup
|
|
|
202
202
|
break;
|
|
203
203
|
case "nostr":
|
|
204
204
|
console.log(`🔧 Nostr login initiated`);
|
|
205
|
-
const nostr =
|
|
205
|
+
const nostr = core.getPlugin("nostr");
|
|
206
206
|
if (!nostr)
|
|
207
207
|
throw new Error("Nostr plugin not available");
|
|
208
208
|
const nostrResult = await nostr.connectBitcoinWallet();
|
|
@@ -219,7 +219,7 @@ function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, onSignup
|
|
|
219
219
|
break;
|
|
220
220
|
case "oauth":
|
|
221
221
|
console.log(`🔧 OAuth login initiated`);
|
|
222
|
-
const oauth =
|
|
222
|
+
const oauth = core.getPlugin("oauth");
|
|
223
223
|
if (!oauth)
|
|
224
224
|
throw new Error("OAuth plugin not available");
|
|
225
225
|
const provider = args[0] || "google";
|
|
@@ -246,12 +246,12 @@ function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, onSignup
|
|
|
246
246
|
// Try multiple ways to get userPub
|
|
247
247
|
let userPub = result.userPub;
|
|
248
248
|
if (!userPub) {
|
|
249
|
-
console.log(`🔧 userPub not in result, trying
|
|
250
|
-
userPub = (_c = (_b =
|
|
249
|
+
console.log(`🔧 userPub not in result, trying core.gun.user()?.is?.pub`);
|
|
250
|
+
userPub = (_c = (_b = core.gun.user()) === null || _b === void 0 ? void 0 : _b.is) === null || _c === void 0 ? void 0 : _c.pub;
|
|
251
251
|
}
|
|
252
252
|
if (!userPub) {
|
|
253
253
|
console.log(`🔧 userPub still not available, trying to get from gun user object`);
|
|
254
|
-
const gunUser =
|
|
254
|
+
const gunUser = core.gun.user();
|
|
255
255
|
console.log(`🔧 Gun user object:`, gunUser);
|
|
256
256
|
if (gunUser && gunUser.is) {
|
|
257
257
|
userPub = gunUser.is.pub;
|
|
@@ -304,7 +304,7 @@ function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, onSignup
|
|
|
304
304
|
const signUp = async (method, ...args) => {
|
|
305
305
|
var _a, _b;
|
|
306
306
|
try {
|
|
307
|
-
if (!
|
|
307
|
+
if (!core) {
|
|
308
308
|
throw new Error("SDK not initialized");
|
|
309
309
|
}
|
|
310
310
|
let result;
|
|
@@ -316,17 +316,17 @@ function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, onSignup
|
|
|
316
316
|
if (args[1] !== args[2]) {
|
|
317
317
|
throw new Error("Passwords do not match");
|
|
318
318
|
}
|
|
319
|
-
result = await
|
|
319
|
+
result = await core.signUp(args[0], args[1]);
|
|
320
320
|
break;
|
|
321
321
|
case "webauthn":
|
|
322
322
|
username = args[0];
|
|
323
|
-
const webauthn =
|
|
323
|
+
const webauthn = core.getPlugin("webauthn");
|
|
324
324
|
if (!webauthn)
|
|
325
325
|
throw new Error("WebAuthn plugin not available");
|
|
326
326
|
result = await webauthn.signUp(username);
|
|
327
327
|
break;
|
|
328
328
|
case "web3":
|
|
329
|
-
const web3 =
|
|
329
|
+
const web3 = core.getPlugin("web3");
|
|
330
330
|
if (!web3)
|
|
331
331
|
throw new Error("Web3 plugin not available");
|
|
332
332
|
const connectionResult = await web3.connectMetaMask();
|
|
@@ -337,7 +337,7 @@ function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, onSignup
|
|
|
337
337
|
result = await web3.signUp(connectionResult.address);
|
|
338
338
|
break;
|
|
339
339
|
case "nostr":
|
|
340
|
-
const nostr =
|
|
340
|
+
const nostr = core.getPlugin("nostr");
|
|
341
341
|
if (!nostr)
|
|
342
342
|
throw new Error("Nostr plugin not available");
|
|
343
343
|
const nostrResult = await nostr.connectBitcoinWallet();
|
|
@@ -351,7 +351,7 @@ function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, onSignup
|
|
|
351
351
|
result = await nostr.signUp(pubkey);
|
|
352
352
|
break;
|
|
353
353
|
case "oauth":
|
|
354
|
-
const oauth =
|
|
354
|
+
const oauth = core.getPlugin("oauth");
|
|
355
355
|
if (!oauth)
|
|
356
356
|
throw new Error("OAuth plugin not available");
|
|
357
357
|
const provider = args[0] || "google";
|
|
@@ -374,7 +374,7 @@ function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, onSignup
|
|
|
374
374
|
throw new Error("Unsupported signup method");
|
|
375
375
|
}
|
|
376
376
|
if (result.success) {
|
|
377
|
-
const userPub = result.userPub || ((_b = (_a =
|
|
377
|
+
const userPub = result.userPub || ((_b = (_a = core.gun.user()) === null || _a === void 0 ? void 0 : _a.is) === null || _b === void 0 ? void 0 : _b.pub) || "";
|
|
378
378
|
const displayName = result.alias || username || userPub.slice(0, 8) + "...";
|
|
379
379
|
setIsLoggedIn(true);
|
|
380
380
|
setUserPub(userPub);
|
|
@@ -397,7 +397,7 @@ function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, onSignup
|
|
|
397
397
|
};
|
|
398
398
|
// Logout
|
|
399
399
|
const logout = () => {
|
|
400
|
-
|
|
400
|
+
core.logout();
|
|
401
401
|
setIsLoggedIn(false);
|
|
402
402
|
setUserPub(null);
|
|
403
403
|
setUsername(null);
|
|
@@ -408,18 +408,18 @@ function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, onSignup
|
|
|
408
408
|
onLogout(); // AGGIUNTA
|
|
409
409
|
};
|
|
410
410
|
const hasPlugin = (name) => {
|
|
411
|
-
return
|
|
412
|
-
?
|
|
411
|
+
return core && typeof core.hasPlugin === "function"
|
|
412
|
+
? core.hasPlugin(name)
|
|
413
413
|
: false;
|
|
414
414
|
};
|
|
415
415
|
const getPlugin = (name) => {
|
|
416
|
-
return
|
|
417
|
-
?
|
|
416
|
+
return core && typeof core.getPlugin === "function"
|
|
417
|
+
? core.getPlugin(name)
|
|
418
418
|
: undefined;
|
|
419
419
|
};
|
|
420
420
|
// Export Gun pair functionality
|
|
421
421
|
const exportGunPair = async (password) => {
|
|
422
|
-
if (!
|
|
422
|
+
if (!core) {
|
|
423
423
|
throw new Error("SDK not initialized");
|
|
424
424
|
}
|
|
425
425
|
if (!isLoggedIn) {
|
|
@@ -428,8 +428,8 @@ function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, onSignup
|
|
|
428
428
|
try {
|
|
429
429
|
// Prefer SDK export if available, fallback to storage
|
|
430
430
|
let pairJson = null;
|
|
431
|
-
if (typeof
|
|
432
|
-
pairJson =
|
|
431
|
+
if (typeof core.exportPair === "function") {
|
|
432
|
+
pairJson = core.exportPair();
|
|
433
433
|
}
|
|
434
434
|
else {
|
|
435
435
|
const stored = sessionStorage.getItem("gun/pair") ||
|
|
@@ -460,7 +460,7 @@ function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, onSignup
|
|
|
460
460
|
};
|
|
461
461
|
// Import Gun pair functionality
|
|
462
462
|
const importGunPair = async (pairData, password) => {
|
|
463
|
-
if (!
|
|
463
|
+
if (!core) {
|
|
464
464
|
throw new Error("SDK not initialized");
|
|
465
465
|
}
|
|
466
466
|
try {
|
|
@@ -492,10 +492,10 @@ function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, onSignup
|
|
|
492
492
|
};
|
|
493
493
|
// Provide the context value to children
|
|
494
494
|
return (react_1.default.createElement(ShogunContext.Provider, { value: {
|
|
495
|
-
|
|
495
|
+
core,
|
|
496
496
|
options,
|
|
497
497
|
isLoggedIn,
|
|
498
|
-
isConnected: !!((_b = (_a =
|
|
498
|
+
isConnected: !!((_b = (_a = core === null || core === void 0 ? void 0 : core.gun.user()) === null || _a === void 0 ? void 0 : _a.is) === null || _b === void 0 ? void 0 : _b.pub), // Verifica corretta se l'utente Gun è autenticato
|
|
499
499
|
userPub,
|
|
500
500
|
username,
|
|
501
501
|
login,
|
|
@@ -554,7 +554,7 @@ const ExportIcon = () => (react_1.default.createElement("svg", { xmlns: "http://
|
|
|
554
554
|
// Component for Shogun login button
|
|
555
555
|
exports.ShogunButton = (() => {
|
|
556
556
|
const Button = () => {
|
|
557
|
-
const { isLoggedIn, username, logout, login, signUp,
|
|
557
|
+
const { isLoggedIn, username, logout, login, signUp, core, options, exportGunPair, importGunPair, } = (0, exports.useShogun)();
|
|
558
558
|
// Form states
|
|
559
559
|
const [modalIsOpen, setModalIsOpen] = (0, react_1.useState)(false);
|
|
560
560
|
const [formUsername, setFormUsername] = (0, react_1.useState)("");
|
|
@@ -665,8 +665,8 @@ exports.ShogunButton = (() => {
|
|
|
665
665
|
if (formMode === "signup") {
|
|
666
666
|
const result = await signUp("password", formUsername, formPassword, formPasswordConfirm);
|
|
667
667
|
if (result && result.success) {
|
|
668
|
-
if (
|
|
669
|
-
|
|
668
|
+
if (core === null || core === void 0 ? void 0 : core.db) {
|
|
669
|
+
core.db.setPasswordHint(formHint);
|
|
670
670
|
}
|
|
671
671
|
setModalIsOpen(false);
|
|
672
672
|
}
|
|
@@ -686,7 +686,7 @@ exports.ShogunButton = (() => {
|
|
|
686
686
|
}
|
|
687
687
|
};
|
|
688
688
|
const handleWebAuthnAuth = () => {
|
|
689
|
-
if (!(
|
|
689
|
+
if (!(core === null || core === void 0 ? void 0 : core.hasPlugin("webauthn"))) {
|
|
690
690
|
setError("WebAuthn is not supported in your browser");
|
|
691
691
|
return;
|
|
692
692
|
}
|
|
@@ -696,10 +696,10 @@ exports.ShogunButton = (() => {
|
|
|
696
696
|
setError("");
|
|
697
697
|
setLoading(true);
|
|
698
698
|
try {
|
|
699
|
-
if (!(
|
|
699
|
+
if (!(core === null || core === void 0 ? void 0 : core.db)) {
|
|
700
700
|
throw new Error("SDK not ready");
|
|
701
701
|
}
|
|
702
|
-
const result = await
|
|
702
|
+
const result = await core.db.forgotPassword(formUsername, [
|
|
703
703
|
formSecurityAnswer,
|
|
704
704
|
]);
|
|
705
705
|
if (result.success && result.hint) {
|
|
@@ -803,23 +803,23 @@ exports.ShogunButton = (() => {
|
|
|
803
803
|
};
|
|
804
804
|
// Add buttons for both login and signup for alternative auth methods
|
|
805
805
|
const renderAuthOptions = () => (react_1.default.createElement("div", { className: "shogun-auth-options" },
|
|
806
|
-
options.showMetamask !== false && (
|
|
806
|
+
options.showMetamask !== false && (core === null || core === void 0 ? void 0 : core.hasPlugin("web3")) && (react_1.default.createElement("div", { className: "shogun-auth-option-group" },
|
|
807
807
|
react_1.default.createElement("button", { type: "button", className: "shogun-auth-option-button", onClick: () => handleAuth("web3"), disabled: loading },
|
|
808
808
|
react_1.default.createElement(WalletIcon, null),
|
|
809
809
|
formMode === "login"
|
|
810
810
|
? "Login with MetaMask"
|
|
811
811
|
: "Signup with MetaMask"))),
|
|
812
|
-
options.showWebauthn !== false && (
|
|
812
|
+
options.showWebauthn !== false && (core === null || core === void 0 ? void 0 : core.hasPlugin("webauthn")) && (react_1.default.createElement("div", { className: "shogun-auth-option-group" },
|
|
813
813
|
react_1.default.createElement("button", { type: "button", className: "shogun-auth-option-button", onClick: handleWebAuthnAuth, disabled: loading },
|
|
814
814
|
react_1.default.createElement(WebAuthnIcon, null),
|
|
815
815
|
formMode === "login"
|
|
816
816
|
? "Login with WebAuthn"
|
|
817
817
|
: "Signup with WebAuthn"))),
|
|
818
|
-
options.showNostr !== false && (
|
|
818
|
+
options.showNostr !== false && (core === null || core === void 0 ? void 0 : core.hasPlugin("nostr")) && (react_1.default.createElement("div", { className: "shogun-auth-option-group" },
|
|
819
819
|
react_1.default.createElement("button", { type: "button", className: "shogun-auth-option-button", onClick: () => handleAuth("nostr"), disabled: loading },
|
|
820
820
|
react_1.default.createElement(NostrIcon, null),
|
|
821
821
|
formMode === "login" ? "Login with Nostr" : "Signup with Nostr"))),
|
|
822
|
-
options.showOauth !== false && (
|
|
822
|
+
options.showOauth !== false && (core === null || core === void 0 ? void 0 : core.hasPlugin("oauth")) && (react_1.default.createElement("div", { className: "shogun-auth-option-group" },
|
|
823
823
|
react_1.default.createElement("button", { type: "button", className: "shogun-auth-option-button shogun-google-button", onClick: () => handleAuth("oauth", "google"), disabled: loading },
|
|
824
824
|
react_1.default.createElement(GoogleIcon, null),
|
|
825
825
|
formMode === "login"
|
package/dist/connector.d.ts
CHANGED
|
File without changes
|
package/dist/connector.js
CHANGED
|
@@ -3,12 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.shogunConnector = shogunConnector;
|
|
4
4
|
const shogun_core_1 = require("shogun-core");
|
|
5
5
|
function shogunConnector(options) {
|
|
6
|
-
const { peers = ["https://
|
|
6
|
+
const { peers = ["https://relay.shogun-eco.xyz/gun"], appName, timeouts, oauth, showMetamask, showWebauthn, showNostr, showOauth, localStorage, radisk, ...restOptions } = options;
|
|
7
7
|
// Build ShogunCore configuration with authentication plugins
|
|
8
8
|
const shogunConfig = {
|
|
9
9
|
peers,
|
|
10
10
|
scope: appName,
|
|
11
11
|
timeouts,
|
|
12
|
+
localStorage,
|
|
13
|
+
radisk,
|
|
12
14
|
};
|
|
13
15
|
// Configure Web3/MetaMask plugin
|
|
14
16
|
if (showMetamask) {
|
|
@@ -45,11 +47,11 @@ function shogunConnector(options) {
|
|
|
45
47
|
showNostr,
|
|
46
48
|
showOauth,
|
|
47
49
|
});
|
|
48
|
-
const
|
|
50
|
+
const core = new shogun_core_1.ShogunCore(shogunConfig);
|
|
49
51
|
const registerPlugin = (plugin) => {
|
|
50
|
-
if (
|
|
52
|
+
if (core && typeof core.register === "function") {
|
|
51
53
|
try {
|
|
52
|
-
|
|
54
|
+
core.register(plugin);
|
|
53
55
|
return true;
|
|
54
56
|
}
|
|
55
57
|
catch (error) {
|
|
@@ -60,10 +62,10 @@ function shogunConnector(options) {
|
|
|
60
62
|
return false;
|
|
61
63
|
};
|
|
62
64
|
const hasPlugin = (name) => {
|
|
63
|
-
return
|
|
65
|
+
return core ? core.hasPlugin(name) : false;
|
|
64
66
|
};
|
|
65
67
|
return {
|
|
66
|
-
|
|
68
|
+
core,
|
|
67
69
|
options,
|
|
68
70
|
registerPlugin,
|
|
69
71
|
hasPlugin,
|
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
File without changes
|
package/dist/styles/index.css
CHANGED
|
File without changes
|
|
@@ -14,6 +14,8 @@ export interface ShogunConnectorOptions {
|
|
|
14
14
|
peers?: string[];
|
|
15
15
|
authToken?: string;
|
|
16
16
|
gunInstance?: IGunInstance<any>;
|
|
17
|
+
localStorage?: boolean;
|
|
18
|
+
radisk?: boolean;
|
|
17
19
|
timeouts?: {
|
|
18
20
|
login?: number;
|
|
19
21
|
signup?: number;
|
|
@@ -28,7 +30,7 @@ export interface ShogunConnectorOptions {
|
|
|
28
30
|
};
|
|
29
31
|
}
|
|
30
32
|
export interface ShogunConnectorResult {
|
|
31
|
-
|
|
33
|
+
core: ShogunCore;
|
|
32
34
|
options: ShogunConnectorOptions;
|
|
33
35
|
registerPlugin: (plugin: any) => boolean;
|
|
34
36
|
hasPlugin: (name: string) => boolean;
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shogun-button-react",
|
|
3
3
|
"description": "Shogun connector button",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.10.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
7
|
"src/styles/index.css"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"ethers": "^6.13.5",
|
|
34
34
|
"prettier": "^3.5.3",
|
|
35
35
|
"rxjs": "^7.8.1",
|
|
36
|
-
"shogun-core": "^1.
|
|
36
|
+
"shogun-core": "^1.10.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"react": "^18.0.0",
|
package/src/styles/index.css
CHANGED
|
File without changes
|