shogun-button-react 1.10.3 โ†’ 1.11.1

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.
@@ -1,136 +1,76 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ShogunButton = exports.useShogun = void 0;
37
- exports.ShogunButtonProvider = ShogunButtonProvider;
38
- const react_1 = __importStar(require("react"));
39
- const rxjs_1 = require("rxjs");
40
- require("../styles/index.css");
1
+ import React, { useContext, useState, createContext, useEffect, useRef, } from "react";
2
+ import { Observable } from "rxjs";
3
+ import { GunAdvancedPlugin } from "../plugins/GunAdvancedPlugin";
4
+ import "../styles/index.css";
41
5
  // Default context
42
6
  const defaultShogunContext = {
43
7
  core: null,
44
8
  options: {},
45
9
  isLoggedIn: false,
46
- isConnected: false,
47
10
  userPub: null,
48
11
  username: null,
49
12
  login: async () => ({}),
50
13
  signUp: async () => ({}),
51
14
  logout: () => { },
52
- observe: () => new rxjs_1.Observable(),
15
+ observe: () => new Observable(),
16
+ setProvider: () => false,
53
17
  hasPlugin: () => false,
54
18
  getPlugin: () => undefined,
55
19
  exportGunPair: async () => "",
56
20
  importGunPair: async () => false,
21
+ gunPlugin: null,
22
+ useGunState: () => ({}),
23
+ useGunCollection: () => ({}),
24
+ useGunConnection: () => ({ isConnected: false, lastSeen: null, error: null }),
25
+ useGunDebug: () => { },
26
+ useGunRealtime: () => ({ data: null, key: null }),
27
+ put: async () => { },
28
+ get: () => null,
29
+ remove: async () => { },
57
30
  };
58
31
  // Create context using React's createContext directly
59
- const ShogunContext = (0, react_1.createContext)(defaultShogunContext);
32
+ const ShogunContext = createContext(defaultShogunContext);
60
33
  // Custom hook to access the context
61
- const useShogun = () => (0, react_1.useContext)(ShogunContext);
62
- exports.useShogun = useShogun;
34
+ export const useShogun = () => useContext(ShogunContext);
63
35
  // Provider component
64
- function ShogunButtonProvider({ children, core, gun, options, onLoginSuccess, onSignupSuccess, onError, onLogout, // AGGIUNTA
65
- }) {
66
- var _a, _b;
36
+ export function ShogunButtonProvider({ children, core, options, onLoginSuccess, onSignupSuccess, onError, }) {
67
37
  // Use React's useState directly
68
- const [isLoggedIn, setIsLoggedIn] = (0, react_1.useState)(false);
69
- const [userPub, setUserPub] = (0, react_1.useState)(null);
70
- const [username, setUsername] = (0, react_1.useState)(null);
38
+ const [isLoggedIn, setIsLoggedIn] = useState(false);
39
+ const [userPub, setUserPub] = useState(null);
40
+ const [username, setUsername] = useState(null);
71
41
  // Effetto per gestire l'inizializzazione e pulizia
72
- (0, react_1.useEffect)(() => {
42
+ useEffect(() => {
73
43
  var _a, _b;
74
- console.log(`๐Ÿ”ง ShogunButtonProvider useEffect - SDK available:`, !!core);
75
44
  if (!core)
76
45
  return;
77
- // Check for existing session data
78
- const sessionData = sessionStorage.getItem("gunSessionData");
79
- const pairData = sessionStorage.getItem("gun/pair") || sessionStorage.getItem("pair");
80
- console.log(`๐Ÿ”ง Session data available:`, {
81
- hasSessionData: !!sessionData,
82
- hasPairData: !!pairData,
83
- });
84
46
  // Verifichiamo se l'utente รจ giร  loggato all'inizializzazione
85
- // Aggiungiamo un controllo di sicurezza per verificare se il metodo esiste
86
- if (core && typeof core.isLoggedIn === "function") {
87
- const isLoggedIn = core.isLoggedIn();
88
- console.log(`๐Ÿ”ง SDK isLoggedIn(): ${isLoggedIn}`);
89
- if (isLoggedIn) {
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
- console.log(`๐Ÿ”ง User already logged in with pub: ${pub === null || pub === void 0 ? void 0 : pub.slice(0, 8)}...`);
92
- if (pub) {
93
- console.log(`๐Ÿ”ง Setting user state from existing session`);
94
- setIsLoggedIn(true);
95
- setUserPub(pub);
96
- setUsername(pub.slice(0, 8) + "...");
97
- }
98
- }
99
- else {
100
- console.log(`๐Ÿ”ง User not logged in`);
101
- // Try to restore session if we have pair data
102
- if (pairData && !isLoggedIn) {
103
- console.log(`๐Ÿ”ง Attempting to restore session from pair data`);
104
- try {
105
- const pair = JSON.parse(pairData);
106
- if (pair.pub) {
107
- console.log(`๐Ÿ”ง Found pair with pub: ${pair.pub.slice(0, 8)}...`);
108
- // Don't auto-login, just log the available data
109
- }
110
- }
111
- catch (error) {
112
- console.error(`๐Ÿ”ง Error parsing pair data:`, error);
113
- }
114
- }
47
+ if (core.isLoggedIn()) {
48
+ const pub = (_b = (_a = core.gun.user()) === null || _a === void 0 ? void 0 : _a.is) === null || _b === void 0 ? void 0 : _b.pub;
49
+ if (pub) {
50
+ setIsLoggedIn(true);
51
+ setUserPub(pub);
52
+ setUsername(pub.slice(0, 8) + "...");
115
53
  }
116
54
  }
117
- else {
118
- console.log(`๐Ÿ”ง SDK isLoggedIn method not available`);
119
- }
120
55
  // Poichรฉ il metodo 'on' non esiste su ShogunCore,
121
56
  // gestiamo gli stati direttamente nei metodi di login/logout
122
57
  }, [core, onLoginSuccess]);
123
58
  // RxJS observe method
124
59
  const observe = (path) => {
60
+ var _a;
125
61
  if (!core) {
126
- return new rxjs_1.Observable();
62
+ return new Observable();
127
63
  }
128
- return core.rx.observe(path);
64
+ const rx = (core === null || core === void 0 ? void 0 : core.rx) || ((_a = core === null || core === void 0 ? void 0 : core.db) === null || _a === void 0 ? void 0 : _a.rx);
65
+ if (rx && typeof rx.observe === "function") {
66
+ const observable = rx.observe(path);
67
+ return observable;
68
+ }
69
+ return new Observable();
129
70
  };
130
71
  // Unified login
131
72
  const login = async (method, ...args) => {
132
- var _a, _b, _c;
133
- console.log(`๐Ÿ”ง ShogunButtonProvider.login called with method: ${method}`, args);
73
+ var _a, _b;
134
74
  try {
135
75
  if (!core) {
136
76
  throw new Error("SDK not initialized");
@@ -138,11 +78,9 @@ function ShogunButtonProvider({ children, core, gun, options, onLoginSuccess, on
138
78
  let result;
139
79
  let authMethod = method;
140
80
  let username;
141
- console.log(`๐Ÿ”ง Processing login method: ${method}`);
142
81
  switch (method) {
143
82
  case "password":
144
83
  username = args[0];
145
- console.log(`๐Ÿ”ง Password login for username: ${username}`);
146
84
  result = await core.login(args[0], args[1]);
147
85
  break;
148
86
  case "pair":
@@ -151,43 +89,33 @@ function ShogunButtonProvider({ children, core, gun, options, onLoginSuccess, on
151
89
  if (!pair || typeof pair !== "object") {
152
90
  throw new Error("Invalid pair data provided");
153
91
  }
154
- console.log(`๐Ÿ”ง Pair login with pub: ${(_a = pair.pub) === null || _a === void 0 ? void 0 : _a.slice(0, 8)}...`);
155
- // Prefer official API from shogun-core when available
156
- if (typeof core.loginWithPair === "function") {
157
- result = await core.loginWithPair(pair);
158
- }
159
- else {
160
- result = await new Promise((resolve, reject) => {
161
- core.gun.user().auth(pair, (ack) => {
162
- if (ack.err) {
163
- reject(new Error(`Pair authentication failed: ${ack.err}`));
164
- return;
165
- }
166
- const pub = ack.pub || pair.pub;
167
- const alias = ack.alias || `user_${pub === null || pub === void 0 ? void 0 : pub.substring(0, 8)}`;
168
- resolve({
169
- success: true,
170
- userPub: pub,
171
- alias: alias,
172
- method: "pair",
173
- });
92
+ result = await new Promise((resolve, reject) => {
93
+ core.gun.user().auth(pair, (ack) => {
94
+ if (ack.err) {
95
+ reject(new Error(`Pair authentication failed: ${ack.err}`));
96
+ return;
97
+ }
98
+ const pub = ack.pub || pair.pub;
99
+ const alias = ack.alias || `user_${pub === null || pub === void 0 ? void 0 : pub.substring(0, 8)}`;
100
+ resolve({
101
+ success: true,
102
+ userPub: pub,
103
+ alias: alias,
104
+ method: "pair",
174
105
  });
175
106
  });
176
- }
107
+ });
177
108
  username = result.alias;
178
109
  authMethod = "pair";
179
110
  break;
180
111
  case "webauthn":
181
112
  username = args[0];
182
- console.log(`๐Ÿ”ง WebAuthn login for username: ${username}`);
183
113
  const webauthn = core.getPlugin("webauthn");
184
114
  if (!webauthn)
185
115
  throw new Error("WebAuthn plugin not available");
186
116
  result = await webauthn.login(username);
187
- authMethod = "webauthn";
188
117
  break;
189
118
  case "web3":
190
- console.log(`๐Ÿ”ง Web3 login initiated`);
191
119
  const web3 = core.getPlugin("web3");
192
120
  if (!web3)
193
121
  throw new Error("Web3 plugin not available");
@@ -196,12 +124,9 @@ function ShogunButtonProvider({ children, core, gun, options, onLoginSuccess, on
196
124
  throw new Error(connectionResult.error || "Failed to connect wallet.");
197
125
  }
198
126
  username = connectionResult.address;
199
- console.log(`๐Ÿ”ง Web3 connected to address: ${username}`);
200
127
  result = await web3.login(connectionResult.address);
201
- authMethod = "web3";
202
128
  break;
203
129
  case "nostr":
204
- console.log(`๐Ÿ”ง Nostr login initiated`);
205
130
  const nostr = core.getPlugin("nostr");
206
131
  if (!nostr)
207
132
  throw new Error("Nostr plugin not available");
@@ -213,26 +138,14 @@ function ShogunButtonProvider({ children, core, gun, options, onLoginSuccess, on
213
138
  if (!pubkey)
214
139
  throw new Error("Nessuna chiave pubblica ottenuta");
215
140
  username = pubkey;
216
- console.log(`๐Ÿ”ง Nostr connected to pubkey: ${username}`);
217
141
  result = await nostr.login(pubkey);
218
- authMethod = "nostr";
219
142
  break;
220
143
  case "oauth":
221
- console.log(`๐Ÿ”ง OAuth login initiated`);
222
144
  const oauth = core.getPlugin("oauth");
223
145
  if (!oauth)
224
146
  throw new Error("OAuth plugin not available");
225
147
  const provider = args[0] || "google";
226
- // Se abbiamo code e state, significa che siamo in un callback
227
- if (args[1] && args[2]) {
228
- const code = args[1];
229
- const state = args[2];
230
- result = await oauth.handleOAuthCallback(provider, code, state);
231
- }
232
- else {
233
- // Altrimenti iniziamo il flusso OAuth normale
234
- result = await oauth.login(provider);
235
- }
148
+ result = await oauth.login(provider);
236
149
  authMethod = "oauth";
237
150
  if (result.redirectUrl) {
238
151
  return result;
@@ -241,61 +154,24 @@ function ShogunButtonProvider({ children, core, gun, options, onLoginSuccess, on
241
154
  default:
242
155
  throw new Error("Unsupported login method");
243
156
  }
244
- console.log(`๐Ÿ”ง Login result:`, result);
245
157
  if (result.success) {
246
- // Try multiple ways to get userPub
247
- let userPub = result.userPub;
248
- if (!userPub) {
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
- }
252
- if (!userPub) {
253
- console.log(`๐Ÿ”ง userPub still not available, trying to get from gun user object`);
254
- const gunUser = core.gun.user();
255
- console.log(`๐Ÿ”ง Gun user object:`, gunUser);
256
- if (gunUser && gunUser.is) {
257
- userPub = gunUser.is.pub;
258
- console.log(`๐Ÿ”ง Found userPub in gun user:`, userPub ? userPub.slice(0, 8) + "..." : "null");
259
- }
260
- }
261
- if (!userPub) {
262
- console.error(`๐Ÿ”ง Could not get userPub after successful login`);
263
- // Try to get it from the result object if available
264
- if (result &&
265
- typeof result === "object" &&
266
- "user" in result &&
267
- result.user &&
268
- typeof result.user === "object" &&
269
- "pub" in result.user) {
270
- userPub = result.user.pub;
271
- console.log(`๐Ÿ”ง Got userPub from result.user:`, userPub ? userPub.slice(0, 8) + "..." : "null");
272
- }
273
- }
274
- const displayName = result.alias ||
275
- username ||
276
- (userPub ? userPub.slice(0, 8) + "..." : "Unknown User");
277
- console.log(`๐Ÿ”ง Login successful! Setting user state:`, {
278
- userPub: userPub ? userPub.slice(0, 8) + "..." : "null",
279
- displayName,
280
- authMethod,
281
- });
158
+ 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) || "";
159
+ const displayName = result.alias || username || userPub.slice(0, 8) + "...";
282
160
  setIsLoggedIn(true);
283
- setUserPub(userPub || "");
161
+ setUserPub(userPub);
284
162
  setUsername(displayName);
285
163
  onLoginSuccess === null || onLoginSuccess === void 0 ? void 0 : onLoginSuccess({
286
- userPub: userPub || "",
164
+ userPub: userPub,
287
165
  username: displayName,
288
166
  authMethod: authMethod,
289
167
  });
290
168
  }
291
169
  else {
292
- console.error(`๐Ÿ”ง Login failed:`, result.error);
293
170
  onError === null || onError === void 0 ? void 0 : onError(result.error || "Login failed");
294
171
  }
295
172
  return result;
296
173
  }
297
174
  catch (error) {
298
- console.error(`๐Ÿ”ง Login error:`, error);
299
175
  onError === null || onError === void 0 ? void 0 : onError(error.message || "Error during login");
300
176
  return { success: false, error: error.message };
301
177
  }
@@ -355,16 +231,7 @@ function ShogunButtonProvider({ children, core, gun, options, onLoginSuccess, on
355
231
  if (!oauth)
356
232
  throw new Error("OAuth plugin not available");
357
233
  const provider = args[0] || "google";
358
- // Se abbiamo code e state, significa che siamo in un callback
359
- if (args[1] && args[2]) {
360
- const code = args[1];
361
- const state = args[2];
362
- result = await oauth.handleOAuthCallback(provider, code, state);
363
- }
364
- else {
365
- // Altrimenti iniziamo il flusso OAuth normale
366
- result = await oauth.signUp(provider);
367
- }
234
+ result = await oauth.signUp(provider);
368
235
  authMethod = "oauth";
369
236
  if (result.redirectUrl) {
370
237
  return result;
@@ -404,18 +271,46 @@ function ShogunButtonProvider({ children, core, gun, options, onLoginSuccess, on
404
271
  sessionStorage.removeItem("gun/pair");
405
272
  sessionStorage.removeItem("gun/session");
406
273
  sessionStorage.removeItem("pair");
407
- if (onLogout)
408
- onLogout(); // AGGIUNTA
274
+ };
275
+ // Implementazione del metodo setProvider
276
+ const setProvider = (provider) => {
277
+ var _a;
278
+ if (!core) {
279
+ return false;
280
+ }
281
+ try {
282
+ let newProviderUrl = null;
283
+ if (provider && provider.connection && provider.connection.url) {
284
+ newProviderUrl = provider.connection.url;
285
+ }
286
+ else if (typeof provider === "string") {
287
+ newProviderUrl = provider;
288
+ }
289
+ if (newProviderUrl) {
290
+ const gun = ((_a = core === null || core === void 0 ? void 0 : core.db) === null || _a === void 0 ? void 0 : _a.gun) || (core === null || core === void 0 ? void 0 : core.gun);
291
+ if (gun && typeof gun.opt === "function") {
292
+ try {
293
+ gun.opt({ peers: [newProviderUrl] });
294
+ return true;
295
+ }
296
+ catch (e) {
297
+ console.error("Error adding peer via gun.opt:", e);
298
+ return false;
299
+ }
300
+ }
301
+ }
302
+ return false;
303
+ }
304
+ catch (error) {
305
+ console.error("Error setting provider:", error);
306
+ return false;
307
+ }
409
308
  };
410
309
  const hasPlugin = (name) => {
411
- return core && typeof core.hasPlugin === "function"
412
- ? core.hasPlugin(name)
413
- : false;
310
+ return core ? core.hasPlugin(name) : false;
414
311
  };
415
312
  const getPlugin = (name) => {
416
- return core && typeof core.getPlugin === "function"
417
- ? core.getPlugin(name)
418
- : undefined;
313
+ return core ? core.getPlugin(name) : undefined;
419
314
  };
420
315
  // Export Gun pair functionality
421
316
  const exportGunPair = async (password) => {
@@ -426,22 +321,11 @@ function ShogunButtonProvider({ children, core, gun, options, onLoginSuccess, on
426
321
  throw new Error("User not authenticated");
427
322
  }
428
323
  try {
429
- // Prefer SDK export if available, fallback to storage
430
- let pairJson = null;
431
- if (typeof core.exportPair === "function") {
432
- pairJson = core.exportPair();
433
- }
434
- else {
435
- const stored = sessionStorage.getItem("gun/pair") ||
436
- sessionStorage.getItem("pair") ||
437
- null;
438
- // Stored value is already a JSON stringified pair; don't double-encode
439
- pairJson = stored;
440
- }
441
- if (!pairJson) {
324
+ const pair = sessionStorage.getItem("gun/pair") || sessionStorage.getItem("pair");
325
+ if (!pair) {
442
326
  throw new Error("No Gun pair available for current user");
443
327
  }
444
- let pairData = pairJson;
328
+ let pairData = JSON.stringify(pair);
445
329
  // If password provided, encrypt the pair
446
330
  if (password && password.trim()) {
447
331
  // Use Gun's SEA for encryption if available
@@ -490,95 +374,182 @@ function ShogunButtonProvider({ children, core, gun, options, onLoginSuccess, on
490
374
  throw new Error(`Failed to import Gun pair: ${error.message}`);
491
375
  }
492
376
  };
377
+ // Inizializza il plugin
378
+ const gunPlugin = React.useMemo(() => {
379
+ if (!core)
380
+ return null;
381
+ return new GunAdvancedPlugin(core, {
382
+ enableDebug: options.enableGunDebug !== false,
383
+ enableConnectionMonitoring: options.enableConnectionMonitoring !== false,
384
+ defaultPageSize: options.defaultPageSize || 20,
385
+ connectionTimeout: options.connectionTimeout || 10000,
386
+ debounceInterval: options.debounceInterval || 100,
387
+ });
388
+ }, [core, options]);
389
+ // Effetto per pulizia del plugin
390
+ React.useEffect(() => {
391
+ return () => {
392
+ if (gunPlugin) {
393
+ gunPlugin.cleanup();
394
+ }
395
+ };
396
+ }, [gunPlugin]);
397
+ // Crea gli hook del plugin
398
+ const pluginHooks = React.useMemo(() => {
399
+ if (!gunPlugin)
400
+ return {};
401
+ return gunPlugin.createHooks();
402
+ }, [gunPlugin]);
403
+ // Create a properly typed context value
404
+ const contextValue = React.useMemo(() => ({
405
+ core,
406
+ options,
407
+ isLoggedIn,
408
+ userPub,
409
+ username,
410
+ login,
411
+ signUp,
412
+ logout,
413
+ observe,
414
+ hasPlugin,
415
+ getPlugin,
416
+ exportGunPair,
417
+ importGunPair,
418
+ setProvider,
419
+ gunPlugin,
420
+ // Ensure all required hooks are present with proper fallbacks
421
+ useGunState: pluginHooks.useGunState ||
422
+ (() => ({
423
+ data: null,
424
+ isLoading: false,
425
+ error: null,
426
+ update: async () => { },
427
+ set: async () => { },
428
+ remove: async () => { },
429
+ refresh: () => { },
430
+ })),
431
+ useGunCollection: pluginHooks.useGunCollection ||
432
+ (() => ({
433
+ items: [],
434
+ currentPage: 0,
435
+ totalPages: 0,
436
+ hasNextPage: false,
437
+ hasPrevPage: false,
438
+ nextPage: () => { },
439
+ prevPage: () => { },
440
+ goToPage: () => { },
441
+ isLoading: false,
442
+ error: null,
443
+ refresh: () => { },
444
+ addItem: async () => { },
445
+ updateItem: async () => { },
446
+ removeItem: async () => { },
447
+ })),
448
+ useGunConnection: pluginHooks.useGunConnection ||
449
+ (() => ({
450
+ isConnected: false,
451
+ lastSeen: null,
452
+ error: null,
453
+ })),
454
+ useGunDebug: pluginHooks.useGunDebug || (() => { }),
455
+ useGunRealtime: pluginHooks.useGunRealtime ||
456
+ (() => ({
457
+ data: null,
458
+ key: null,
459
+ })),
460
+ put: (gunPlugin === null || gunPlugin === void 0 ? void 0 : gunPlugin.put.bind(gunPlugin)) || (async () => { }),
461
+ get: (gunPlugin === null || gunPlugin === void 0 ? void 0 : gunPlugin.get.bind(gunPlugin)) || (() => null),
462
+ remove: (gunPlugin === null || gunPlugin === void 0 ? void 0 : gunPlugin.remove.bind(gunPlugin)) || (async () => { }),
463
+ }), [
464
+ core,
465
+ options,
466
+ isLoggedIn,
467
+ userPub,
468
+ username,
469
+ login,
470
+ signUp,
471
+ logout,
472
+ observe,
473
+ hasPlugin,
474
+ getPlugin,
475
+ exportGunPair,
476
+ importGunPair,
477
+ gunPlugin,
478
+ pluginHooks,
479
+ ]);
493
480
  // Provide the context value to children
494
- return (react_1.default.createElement(ShogunContext.Provider, { value: {
495
- core,
496
- options,
497
- isLoggedIn,
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
- userPub,
500
- username,
501
- login,
502
- signUp,
503
- logout,
504
- observe,
505
- hasPlugin,
506
- getPlugin,
507
- exportGunPair,
508
- importGunPair,
509
- } }, children));
481
+ return (React.createElement(ShogunContext.Provider, { value: contextValue }, children));
510
482
  }
511
483
  // SVG Icons Components
512
- const WalletIcon = () => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
513
- react_1.default.createElement("path", { d: "M21 12V7H5a2 2 0 0 1 0-4h14v4" }),
514
- react_1.default.createElement("path", { d: "M3 5v14a2 2 0 0 0 2 2h16v-5" }),
515
- react_1.default.createElement("path", { d: "M18 12a2 2 0 0 0 0 4h4v-4Z" })));
516
- const KeyIcon = () => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
517
- react_1.default.createElement("circle", { cx: "7.5", cy: "15.5", r: "5.5" }),
518
- react_1.default.createElement("path", { d: "m21 2-9.6 9.6" }),
519
- react_1.default.createElement("path", { d: "m15.5 7.5 3 3L22 7l-3-3" })));
520
- const GoogleIcon = () => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor" },
521
- react_1.default.createElement("path", { d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z", fill: "#4285F4" }),
522
- react_1.default.createElement("path", { d: "M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z", fill: "#34A853" }),
523
- react_1.default.createElement("path", { d: "M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z", fill: "#FBBC05" }),
524
- react_1.default.createElement("path", { d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z", fill: "#EA4335" })));
525
- const NostrIcon = () => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
526
- react_1.default.createElement("path", { d: "M19.5 4.5 15 9l-3-3-4.5 4.5L9 12l-1.5 1.5L12 18l4.5-4.5L15 12l1.5-1.5L21 6l-1.5-1.5Z" }),
527
- react_1.default.createElement("path", { d: "M12 12 6 6l-1.5 1.5L9 12l-4.5 4.5L6 18l6-6Z" })));
528
- const WebAuthnIcon = () => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
529
- react_1.default.createElement("path", { d: "M7 11v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1h-4" }),
530
- react_1.default.createElement("path", { d: "M14 4V2a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h2" })));
531
- const LogoutIcon = () => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
532
- react_1.default.createElement("path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }),
533
- react_1.default.createElement("polyline", { points: "16 17 21 12 16 7" }),
534
- react_1.default.createElement("line", { x1: "21", y1: "12", x2: "9", y2: "12" })));
535
- const UserIcon = () => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
536
- react_1.default.createElement("path", { d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" }),
537
- react_1.default.createElement("circle", { cx: "12", cy: "7", r: "4" })));
538
- const LockIcon = () => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
539
- react_1.default.createElement("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2", ry: "2" }),
540
- react_1.default.createElement("path", { d: "M7 11V7a5 5 0 0 1 10 0v4" })));
541
- const CloseIcon = () => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
542
- react_1.default.createElement("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
543
- react_1.default.createElement("line", { x1: "6", y1: "6", x2: "18", y2: "18" })));
544
- const ImportIcon = () => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
545
- react_1.default.createElement("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
546
- react_1.default.createElement("polyline", { points: "14,2 14,8 20,8" }),
547
- react_1.default.createElement("line", { x1: "16", y1: "13", x2: "8", y2: "13" }),
548
- react_1.default.createElement("line", { x1: "12", y1: "17", x2: "12", y2: "9" })));
549
- const ExportIcon = () => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
550
- react_1.default.createElement("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
551
- react_1.default.createElement("polyline", { points: "14,2 14,8 20,8" }),
552
- react_1.default.createElement("line", { x1: "12", y1: "11", x2: "12", y2: "21" }),
553
- react_1.default.createElement("polyline", { points: "16,15 12,11 8,15" })));
484
+ const WalletIcon = () => (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
485
+ React.createElement("path", { d: "M21 12V7H5a2 2 0 0 1 0-4h14v4" }),
486
+ React.createElement("path", { d: "M3 5v14a2 2 0 0 0 2 2h16v-5" }),
487
+ React.createElement("path", { d: "M18 12a2 2 0 0 0 0 4h4v-4Z" })));
488
+ const KeyIcon = () => (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
489
+ React.createElement("circle", { cx: "7.5", cy: "15.5", r: "5.5" }),
490
+ React.createElement("path", { d: "m21 2-9.6 9.6" }),
491
+ React.createElement("path", { d: "m15.5 7.5 3 3L22 7l-3-3" })));
492
+ const GoogleIcon = () => (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor" },
493
+ React.createElement("path", { d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z", fill: "#4285F4" }),
494
+ React.createElement("path", { d: "M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z", fill: "#34A853" }),
495
+ React.createElement("path", { d: "M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z", fill: "#FBBC05" }),
496
+ React.createElement("path", { d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z", fill: "#EA4335" })));
497
+ const NostrIcon = () => (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
498
+ React.createElement("path", { d: "M19.5 4.5 15 9l-3-3-4.5 4.5L9 12l-1.5 1.5L12 18l4.5-4.5L15 12l1.5-1.5L21 6l-1.5-1.5Z" }),
499
+ React.createElement("path", { d: "M12 12 6 6l-1.5 1.5L9 12l-4.5 4.5L6 18l6-6Z" })));
500
+ const WebAuthnIcon = () => (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
501
+ React.createElement("path", { d: "M7 11v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1h-4" }),
502
+ React.createElement("path", { d: "M14 4V2a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h2" })));
503
+ const LogoutIcon = () => (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
504
+ React.createElement("path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }),
505
+ React.createElement("polyline", { points: "16 17 21 12 16 7" }),
506
+ React.createElement("line", { x1: "21", y1: "12", x2: "9", y2: "12" })));
507
+ const UserIcon = () => (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
508
+ React.createElement("path", { d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" }),
509
+ React.createElement("circle", { cx: "12", cy: "7", r: "4" })));
510
+ const LockIcon = () => (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
511
+ React.createElement("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2", ry: "2" }),
512
+ React.createElement("path", { d: "M7 11V7a5 5 0 0 1 10 0v4" })));
513
+ const CloseIcon = () => (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
514
+ React.createElement("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
515
+ React.createElement("line", { x1: "6", y1: "6", x2: "18", y2: "18" })));
516
+ const ImportIcon = () => (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
517
+ React.createElement("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
518
+ React.createElement("polyline", { points: "14,2 14,8 20,8" }),
519
+ React.createElement("line", { x1: "16", y1: "13", x2: "8", y2: "13" }),
520
+ React.createElement("line", { x1: "12", y1: "17", x2: "12", y2: "9" })));
521
+ const ExportIcon = () => (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
522
+ React.createElement("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
523
+ React.createElement("polyline", { points: "14,2 14,8 20,8" }),
524
+ React.createElement("line", { x1: "12", y1: "11", x2: "12", y2: "21" }),
525
+ React.createElement("polyline", { points: "16,15 12,11 8,15" })));
554
526
  // Component for Shogun login button
555
- exports.ShogunButton = (() => {
527
+ export const ShogunButton = (() => {
556
528
  const Button = () => {
557
- const { isLoggedIn, username, logout, login, signUp, core, options, exportGunPair, importGunPair, } = (0, exports.useShogun)();
529
+ const { isLoggedIn, username, logout, login, signUp, core, options, exportGunPair, importGunPair, } = useShogun();
558
530
  // Form states
559
- const [modalIsOpen, setModalIsOpen] = (0, react_1.useState)(false);
560
- const [formUsername, setFormUsername] = (0, react_1.useState)("");
561
- const [formPassword, setFormPassword] = (0, react_1.useState)("");
562
- const [formPasswordConfirm, setFormPasswordConfirm] = (0, react_1.useState)("");
563
- const [formHint, setFormHint] = (0, react_1.useState)("");
564
- const [formSecurityQuestion] = (0, react_1.useState)("What is your favorite color?"); // Hardcoded for now
565
- const [formSecurityAnswer, setFormSecurityAnswer] = (0, react_1.useState)("");
566
- const [formMode, setFormMode] = (0, react_1.useState)("login");
567
- const [authView, setAuthView] = (0, react_1.useState)("options");
568
- const [error, setError] = (0, react_1.useState)("");
569
- const [loading, setLoading] = (0, react_1.useState)(false);
570
- const [dropdownOpen, setDropdownOpen] = (0, react_1.useState)(false);
571
- const [recoveredHint, setRecoveredHint] = (0, react_1.useState)("");
572
- const [exportPassword, setExportPassword] = (0, react_1.useState)("");
573
- const [importPassword, setImportPassword] = (0, react_1.useState)("");
574
- const [importPairData, setImportPairData] = (0, react_1.useState)("");
575
- const [exportedPair, setExportedPair] = (0, react_1.useState)("");
576
- const [showCopySuccess, setShowCopySuccess] = (0, react_1.useState)(false);
577
- const [showImportSuccess, setShowImportSuccess] = (0, react_1.useState)(false);
578
- const dropdownRef = (0, react_1.useRef)(null);
579
- // Rimuovi tutto ciรฒ che riguarda oauthPin
531
+ const [modalIsOpen, setModalIsOpen] = useState(false);
532
+ const [formUsername, setFormUsername] = useState("");
533
+ const [formPassword, setFormPassword] = useState("");
534
+ const [formPasswordConfirm, setFormPasswordConfirm] = useState("");
535
+ const [formHint, setFormHint] = useState("");
536
+ const [formSecurityQuestion] = useState("What is your favorite color?"); // Hardcoded for now
537
+ const [formSecurityAnswer, setFormSecurityAnswer] = useState("");
538
+ const [formMode, setFormMode] = useState("login");
539
+ const [authView, setAuthView] = useState("options");
540
+ const [error, setError] = useState("");
541
+ const [loading, setLoading] = useState(false);
542
+ const [dropdownOpen, setDropdownOpen] = useState(false);
543
+ const [recoveredHint, setRecoveredHint] = useState("");
544
+ const [exportPassword, setExportPassword] = useState("");
545
+ const [importPassword, setImportPassword] = useState("");
546
+ const [importPairData, setImportPairData] = useState("");
547
+ const [exportedPair, setExportedPair] = useState("");
548
+ const [showCopySuccess, setShowCopySuccess] = useState(false);
549
+ const [showImportSuccess, setShowImportSuccess] = useState(false);
550
+ const dropdownRef = useRef(null);
580
551
  // Handle click outside to close dropdown
581
- (0, react_1.useEffect)(() => {
552
+ useEffect(() => {
582
553
  const handleClickOutside = (event) => {
583
554
  if (dropdownRef.current &&
584
555
  !dropdownRef.current.contains(event.target)) {
@@ -594,66 +565,53 @@ exports.ShogunButton = (() => {
594
565
  }, [dropdownOpen]);
595
566
  // If already logged in, show only logout button
596
567
  if (isLoggedIn && username && !modalIsOpen) {
597
- return (react_1.default.createElement("div", { className: "shogun-logged-in-container" },
598
- react_1.default.createElement("div", { className: "shogun-dropdown", ref: dropdownRef },
599
- react_1.default.createElement("button", { className: "shogun-button shogun-logged-in", onClick: () => setDropdownOpen(!dropdownOpen) },
600
- react_1.default.createElement("div", { className: "shogun-avatar" }, username.substring(0, 2).toUpperCase()),
601
- react_1.default.createElement("span", { className: "shogun-username" }, username.length > 12
568
+ return (React.createElement("div", { className: "shogun-logged-in-container" },
569
+ React.createElement("div", { className: "shogun-dropdown", ref: dropdownRef },
570
+ React.createElement("button", { className: "shogun-button shogun-logged-in", onClick: () => setDropdownOpen(!dropdownOpen) },
571
+ React.createElement("div", { className: "shogun-avatar" }, username.substring(0, 2).toUpperCase()),
572
+ React.createElement("span", { className: "shogun-username" }, username.length > 12
602
573
  ? `${username.substring(0, 6)}...${username.substring(username.length - 4)}`
603
574
  : username)),
604
- dropdownOpen && (react_1.default.createElement("div", { className: "shogun-dropdown-menu" },
605
- react_1.default.createElement("div", { className: "shogun-dropdown-header" },
606
- react_1.default.createElement("div", { className: "shogun-avatar-large" }, username.substring(0, 2).toUpperCase()),
607
- react_1.default.createElement("div", { className: "shogun-user-info" },
608
- react_1.default.createElement("span", { className: "shogun-username-full" }, username.length > 20
575
+ dropdownOpen && (React.createElement("div", { className: "shogun-dropdown-menu" },
576
+ React.createElement("div", { className: "shogun-dropdown-header" },
577
+ React.createElement("div", { className: "shogun-avatar-large" }, username.substring(0, 2).toUpperCase()),
578
+ React.createElement("div", { className: "shogun-user-info" },
579
+ React.createElement("span", { className: "shogun-username-full" }, username.length > 20
609
580
  ? `${username.substring(0, 10)}...${username.substring(username.length - 6)}`
610
581
  : username))),
611
- react_1.default.createElement("div", { className: "shogun-dropdown-item", onClick: () => {
582
+ React.createElement("div", { className: "shogun-dropdown-item", onClick: () => {
612
583
  setDropdownOpen(false);
613
584
  setAuthView("export");
614
585
  setModalIsOpen(true);
615
586
  } },
616
- react_1.default.createElement(ExportIcon, null),
617
- react_1.default.createElement("span", null, "Export Pair")),
618
- react_1.default.createElement("div", { className: "shogun-dropdown-item", onClick: logout },
619
- react_1.default.createElement(LogoutIcon, null),
620
- react_1.default.createElement("span", null, "Disconnect")))))));
587
+ React.createElement(ExportIcon, null),
588
+ React.createElement("span", null, "Export Pair")),
589
+ React.createElement("div", { className: "shogun-dropdown-item", onClick: logout },
590
+ React.createElement(LogoutIcon, null),
591
+ React.createElement("span", null, "Disconnect")))))));
621
592
  }
622
593
  // Event handlers
623
594
  const handleAuth = async (method, ...args) => {
624
- console.log(`๐Ÿ”ง handleAuth called with method: ${method}`, args);
625
595
  setError("");
626
596
  setLoading(true);
627
597
  try {
628
598
  // Use formMode to determine whether to call login or signUp
629
599
  const action = formMode === "login" ? login : signUp;
630
- console.log(`๐Ÿ”ง Using action: ${formMode === "login" ? "login" : "signUp"}`);
631
- console.log(`๐Ÿ”ง Calling ${action.name} with method: ${method}`);
632
600
  const result = await action(method, ...args);
633
- console.log(`๐Ÿ”ง ${action.name} result:`, result);
634
601
  if (result && !result.success && result.error) {
635
- console.error(`๐Ÿ”ง ${action.name} failed with error:`, result.error);
636
602
  setError(result.error);
637
603
  }
638
604
  else if (result && result.redirectUrl) {
639
- console.log(`๐Ÿ”ง Redirecting to: ${result.redirectUrl}`);
640
605
  window.location.href = result.redirectUrl;
641
606
  }
642
- else if (result && result.success) {
643
- console.log(`๐Ÿ”ง ${action.name} successful, closing modal`);
644
- setModalIsOpen(false);
645
- }
646
607
  else {
647
- console.warn(`๐Ÿ”ง Unexpected result:`, result);
648
608
  setModalIsOpen(false);
649
609
  }
650
610
  }
651
611
  catch (e) {
652
- console.error(`๐Ÿ”ง handleAuth error:`, e);
653
612
  setError(e.message || "An unexpected error occurred.");
654
613
  }
655
614
  finally {
656
- console.log(`๐Ÿ”ง handleAuth completed, setting loading to false`);
657
615
  setLoading(false);
658
616
  }
659
617
  };
@@ -666,7 +624,17 @@ exports.ShogunButton = (() => {
666
624
  const result = await signUp("password", formUsername, formPassword, formPasswordConfirm);
667
625
  if (result && result.success) {
668
626
  if (core === null || core === void 0 ? void 0 : core.db) {
669
- core.db.setPasswordHint(formHint);
627
+ try {
628
+ const res = await core.db.setPasswordHintWithSecurity(formUsername, formPassword, formHint, [formSecurityQuestion], [formSecurityAnswer]);
629
+ if (!(res === null || res === void 0 ? void 0 : res.success)) {
630
+ // Fallback to legacy hint storage to avoid losing the hint
631
+ await core.db.setPasswordHint(formHint);
632
+ }
633
+ }
634
+ catch {
635
+ // Last-resort fallback
636
+ await core.db.setPasswordHint(formHint);
637
+ }
670
638
  }
671
639
  setModalIsOpen(false);
672
640
  }
@@ -685,6 +653,7 @@ exports.ShogunButton = (() => {
685
653
  setLoading(false);
686
654
  }
687
655
  };
656
+ const handleWeb3Auth = () => handleAuth("web3");
688
657
  const handleWebAuthnAuth = () => {
689
658
  if (!(core === null || core === void 0 ? void 0 : core.hasPlugin("webauthn"))) {
690
659
  setError("WebAuthn is not supported in your browser");
@@ -692,6 +661,8 @@ exports.ShogunButton = (() => {
692
661
  }
693
662
  setAuthView("webauthn-username");
694
663
  };
664
+ const handleNostrAuth = () => handleAuth("nostr");
665
+ const handleOAuth = (provider) => handleAuth("oauth", provider);
695
666
  const handleRecover = async () => {
696
667
  setError("");
697
668
  setLoading(true);
@@ -780,7 +751,6 @@ exports.ShogunButton = (() => {
780
751
  setShowCopySuccess(false);
781
752
  setShowImportSuccess(false);
782
753
  setRecoveredHint("");
783
- // Rimuovi tutto ciรฒ che riguarda oauthPin
784
754
  };
785
755
  const openModal = () => {
786
756
  resetForm();
@@ -791,177 +761,165 @@ exports.ShogunButton = (() => {
791
761
  setModalIsOpen(false);
792
762
  };
793
763
  const toggleMode = () => {
794
- console.log("๐Ÿ”ง toggleMode called - current formMode:", formMode);
795
- console.log("๐Ÿ”ง loading state:", loading);
796
764
  resetForm();
797
765
  setAuthView("options"); // Porta alla selezione dei metodi invece che direttamente al form password
798
- setFormMode((prev) => {
799
- const newMode = prev === "login" ? "signup" : "login";
800
- console.log("๐Ÿ”ง Switching from", prev, "to", newMode);
801
- return newMode;
802
- });
766
+ setFormMode((prev) => (prev === "login" ? "signup" : "login"));
803
767
  };
804
768
  // Add buttons for both login and signup for alternative auth methods
805
- const renderAuthOptions = () => (react_1.default.createElement("div", { className: "shogun-auth-options" },
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
- react_1.default.createElement("button", { type: "button", className: "shogun-auth-option-button", onClick: () => handleAuth("web3"), disabled: loading },
808
- react_1.default.createElement(WalletIcon, null),
769
+ const renderAuthOptions = () => (React.createElement("div", { className: "shogun-auth-options" },
770
+ options.showMetamask !== false && (core === null || core === void 0 ? void 0 : core.hasPlugin("web3")) && (React.createElement("div", { className: "shogun-auth-option-group" },
771
+ React.createElement("button", { type: "button", className: "shogun-auth-option-button", onClick: () => handleAuth("web3"), disabled: loading },
772
+ React.createElement(WalletIcon, null),
809
773
  formMode === "login"
810
774
  ? "Login with MetaMask"
811
775
  : "Signup with MetaMask"))),
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
- react_1.default.createElement("button", { type: "button", className: "shogun-auth-option-button", onClick: handleWebAuthnAuth, disabled: loading },
814
- react_1.default.createElement(WebAuthnIcon, null),
776
+ options.showWebauthn !== false && (core === null || core === void 0 ? void 0 : core.hasPlugin("webauthn")) && (React.createElement("div", { className: "shogun-auth-option-group" },
777
+ React.createElement("button", { type: "button", className: "shogun-auth-option-button", onClick: handleWebAuthnAuth, disabled: loading },
778
+ React.createElement(WebAuthnIcon, null),
815
779
  formMode === "login"
816
780
  ? "Login with WebAuthn"
817
781
  : "Signup with WebAuthn"))),
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
- react_1.default.createElement("button", { type: "button", className: "shogun-auth-option-button", onClick: () => handleAuth("nostr"), disabled: loading },
820
- react_1.default.createElement(NostrIcon, null),
782
+ options.showNostr !== false && (core === null || core === void 0 ? void 0 : core.hasPlugin("nostr")) && (React.createElement("div", { className: "shogun-auth-option-group" },
783
+ React.createElement("button", { type: "button", className: "shogun-auth-option-button", onClick: () => handleAuth("nostr"), disabled: loading },
784
+ React.createElement(NostrIcon, null),
821
785
  formMode === "login" ? "Login with Nostr" : "Signup with Nostr"))),
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
- react_1.default.createElement("button", { type: "button", className: "shogun-auth-option-button shogun-google-button", onClick: () => handleAuth("oauth", "google"), disabled: loading },
824
- react_1.default.createElement(GoogleIcon, null),
786
+ options.showOauth !== false && (core === null || core === void 0 ? void 0 : core.hasPlugin("oauth")) && (React.createElement("div", { className: "shogun-auth-option-group" },
787
+ React.createElement("button", { type: "button", className: "shogun-auth-option-button shogun-google-button", onClick: () => handleAuth("oauth", "google"), disabled: loading },
788
+ React.createElement(GoogleIcon, null),
825
789
  formMode === "login"
826
790
  ? "Login with Google"
827
791
  : "Signup with Google"))),
828
- react_1.default.createElement("div", { className: "shogun-divider" },
829
- react_1.default.createElement("span", null, "or")),
830
- react_1.default.createElement("button", { type: "button", className: "shogun-auth-option-button", onClick: () => setAuthView("password"), disabled: loading },
831
- react_1.default.createElement(LockIcon, null),
792
+ React.createElement("div", { className: "shogun-divider" },
793
+ React.createElement("span", null, "or")),
794
+ React.createElement("button", { type: "button", className: "shogun-auth-option-button", onClick: () => setAuthView("password"), disabled: loading },
795
+ React.createElement(LockIcon, null),
832
796
  formMode === "login"
833
797
  ? "Login with Password"
834
798
  : "Signup with Password"),
835
- formMode === "login" && (react_1.default.createElement("button", { type: "button", className: "shogun-auth-option-button", onClick: () => setAuthView("import"), disabled: loading },
836
- react_1.default.createElement(ImportIcon, null),
799
+ formMode === "login" && (React.createElement("button", { type: "button", className: "shogun-auth-option-button", onClick: () => setAuthView("import"), disabled: loading },
800
+ React.createElement(ImportIcon, null),
837
801
  "Import Gun Pair"))));
838
- const renderPasswordForm = () => (react_1.default.createElement("form", { onSubmit: handleSubmit, className: "shogun-auth-form" },
839
- react_1.default.createElement("div", { className: "shogun-form-group" },
840
- react_1.default.createElement("label", { htmlFor: "username" },
841
- react_1.default.createElement(UserIcon, null),
842
- react_1.default.createElement("span", null, "Username")),
843
- react_1.default.createElement("input", { type: "text", id: "username", value: formUsername, onChange: (e) => setFormUsername(e.target.value), disabled: loading, required: true, placeholder: "Enter your username" })),
844
- react_1.default.createElement("div", { className: "shogun-form-group" },
845
- react_1.default.createElement("label", { htmlFor: "password" },
846
- react_1.default.createElement(LockIcon, null),
847
- react_1.default.createElement("span", null, "Password")),
848
- react_1.default.createElement("input", { type: "password", id: "password", value: formPassword, onChange: (e) => setFormPassword(e.target.value), disabled: loading, required: true, placeholder: "Enter your password" })),
849
- formMode === "signup" && (react_1.default.createElement(react_1.default.Fragment, null,
850
- react_1.default.createElement("div", { className: "shogun-form-group" },
851
- react_1.default.createElement("label", { htmlFor: "passwordConfirm" },
852
- react_1.default.createElement(KeyIcon, null),
853
- react_1.default.createElement("span", null, "Confirm Password")),
854
- react_1.default.createElement("input", { type: "password", id: "passwordConfirm", value: formPasswordConfirm, onChange: (e) => setFormPasswordConfirm(e.target.value), disabled: loading, required: true, placeholder: "Confirm your password" })),
855
- react_1.default.createElement("div", { className: "shogun-form-group" },
856
- react_1.default.createElement("label", { htmlFor: "hint" },
857
- react_1.default.createElement(UserIcon, null),
858
- react_1.default.createElement("span", null, "Password Hint")),
859
- react_1.default.createElement("input", { type: "text", id: "hint", value: formHint, onChange: (e) => setFormHint(e.target.value), disabled: loading, required: true, placeholder: "Enter your password hint" })),
860
- react_1.default.createElement("div", { className: "shogun-form-group" },
861
- react_1.default.createElement("label", { htmlFor: "securityQuestion" },
862
- react_1.default.createElement(UserIcon, null),
863
- react_1.default.createElement("span", null, "Security Question")),
864
- react_1.default.createElement("input", { type: "text", id: "securityQuestion", value: formSecurityQuestion, disabled: true })),
865
- react_1.default.createElement("div", { className: "shogun-form-group" },
866
- react_1.default.createElement("label", { htmlFor: "securityAnswer" },
867
- react_1.default.createElement(UserIcon, null),
868
- react_1.default.createElement("span", null, "Security Answer")),
869
- react_1.default.createElement("input", { type: "text", id: "securityAnswer", value: formSecurityAnswer, onChange: (e) => setFormSecurityAnswer(e.target.value), disabled: loading, required: true, placeholder: "Enter your security answer" })))),
870
- react_1.default.createElement("button", { type: "submit", className: "shogun-submit-button", disabled: loading }, loading
802
+ const renderPasswordForm = () => (React.createElement("form", { onSubmit: handleSubmit, className: "shogun-auth-form" },
803
+ React.createElement("div", { className: "shogun-form-group" },
804
+ React.createElement("label", { htmlFor: "username" },
805
+ React.createElement(UserIcon, null),
806
+ React.createElement("span", null, "Username")),
807
+ React.createElement("input", { type: "text", id: "username", value: formUsername, onChange: (e) => setFormUsername(e.target.value), disabled: loading, required: true, placeholder: "Enter your username" })),
808
+ React.createElement("div", { className: "shogun-form-group" },
809
+ React.createElement("label", { htmlFor: "password" },
810
+ React.createElement(LockIcon, null),
811
+ React.createElement("span", null, "Password")),
812
+ React.createElement("input", { type: "password", id: "password", value: formPassword, onChange: (e) => setFormPassword(e.target.value), disabled: loading, required: true, placeholder: "Enter your password" })),
813
+ formMode === "signup" && (React.createElement(React.Fragment, null,
814
+ React.createElement("div", { className: "shogun-form-group" },
815
+ React.createElement("label", { htmlFor: "passwordConfirm" },
816
+ React.createElement(KeyIcon, null),
817
+ React.createElement("span", null, "Confirm Password")),
818
+ React.createElement("input", { type: "password", id: "passwordConfirm", value: formPasswordConfirm, onChange: (e) => setFormPasswordConfirm(e.target.value), disabled: loading, required: true, placeholder: "Confirm your password" })),
819
+ React.createElement("div", { className: "shogun-form-group" },
820
+ React.createElement("label", { htmlFor: "hint" },
821
+ React.createElement(UserIcon, null),
822
+ React.createElement("span", null, "Password Hint")),
823
+ React.createElement("input", { type: "text", id: "hint", value: formHint, onChange: (e) => setFormHint(e.target.value), disabled: loading, required: true, placeholder: "Enter your password hint" })),
824
+ React.createElement("div", { className: "shogun-form-group" },
825
+ React.createElement("label", { htmlFor: "securityQuestion" },
826
+ React.createElement(UserIcon, null),
827
+ React.createElement("span", null, "Security Question")),
828
+ React.createElement("input", { type: "text", id: "securityQuestion", value: formSecurityQuestion, disabled: true })),
829
+ React.createElement("div", { className: "shogun-form-group" },
830
+ React.createElement("label", { htmlFor: "securityAnswer" },
831
+ React.createElement(UserIcon, null),
832
+ React.createElement("span", null, "Security Answer")),
833
+ React.createElement("input", { type: "text", id: "securityAnswer", value: formSecurityAnswer, onChange: (e) => setFormSecurityAnswer(e.target.value), disabled: loading, required: true, placeholder: "Enter your security answer" })))),
834
+ React.createElement("button", { type: "submit", className: "shogun-submit-button", disabled: loading }, loading
871
835
  ? "Processing..."
872
836
  : formMode === "login"
873
837
  ? "Sign In"
874
838
  : "Create Account"),
875
- react_1.default.createElement("div", { className: "shogun-form-footer" },
876
- react_1.default.createElement("button", { type: "button", className: "shogun-toggle-mode shogun-prominent-toggle", onClick: () => {
877
- console.log("๐Ÿ”ง Signup button clicked!");
878
- console.log("๐Ÿ”ง Current formMode:", formMode);
879
- console.log("๐Ÿ”ง Current loading:", loading);
880
- console.log("๐Ÿ”ง Current authView:", authView);
881
- toggleMode();
882
- }, disabled: loading }, formMode === "login"
839
+ React.createElement("div", { className: "shogun-form-footer" },
840
+ React.createElement("button", { type: "button", className: "shogun-toggle-mode shogun-prominent-toggle", onClick: toggleMode, disabled: loading }, formMode === "login"
883
841
  ? "Don't have an account? Sign up"
884
842
  : "Already have an account? Log in"),
885
- formMode === "login" && (react_1.default.createElement("button", { type: "button", className: "shogun-toggle-mode", onClick: () => setAuthView("recover"), disabled: loading }, "Forgot password?")))));
886
- const renderWebAuthnUsernameForm = () => (react_1.default.createElement("div", { className: "shogun-auth-form" },
887
- react_1.default.createElement("h3", null, formMode === "login"
843
+ formMode === "login" && (React.createElement("button", { type: "button", className: "shogun-toggle-mode", onClick: () => setAuthView("recover"), disabled: loading }, "Forgot password?")))));
844
+ const renderWebAuthnUsernameForm = () => (React.createElement("div", { className: "shogun-auth-form" },
845
+ React.createElement("h3", null, formMode === "login"
888
846
  ? "Login with WebAuthn"
889
847
  : "Sign Up with WebAuthn"),
890
- react_1.default.createElement("div", { style: {
848
+ React.createElement("div", { style: {
891
849
  backgroundColor: "#f0f9ff",
892
850
  padding: "12px",
893
851
  borderRadius: "8px",
894
852
  marginBottom: "16px",
895
853
  border: "1px solid #0ea5e9",
896
854
  } },
897
- react_1.default.createElement("p", { style: {
855
+ React.createElement("p", { style: {
898
856
  fontSize: "14px",
899
857
  color: "#0c4a6e",
900
858
  margin: "0",
901
859
  fontWeight: "500",
902
860
  } }, "\uD83D\uDD11 WebAuthn Authentication"),
903
- react_1.default.createElement("p", { style: { fontSize: "13px", color: "#075985", margin: "4px 0 0 0" } },
861
+ React.createElement("p", { style: { fontSize: "13px", color: "#075985", margin: "4px 0 0 0" } },
904
862
  "Please enter your username to continue with WebAuthn",
905
863
  " ",
906
864
  formMode === "login" ? "login" : "registration",
907
865
  ".")),
908
- react_1.default.createElement("div", { className: "shogun-form-group" },
909
- react_1.default.createElement("label", { htmlFor: "username" },
910
- react_1.default.createElement(UserIcon, null),
911
- react_1.default.createElement("span", null, "Username")),
912
- react_1.default.createElement("input", { type: "text", id: "username", value: formUsername, onChange: (e) => setFormUsername(e.target.value), disabled: loading, required: true, placeholder: "Enter your username", autoFocus: true })),
913
- react_1.default.createElement("button", { type: "button", className: "shogun-submit-button", onClick: () => handleAuth("webauthn", formUsername), disabled: loading || !formUsername.trim() }, loading ? "Processing..." : `Continue with WebAuthn`),
914
- react_1.default.createElement("div", { className: "shogun-form-footer" },
915
- react_1.default.createElement("button", { type: "button", className: "shogun-back-button", onClick: () => setAuthView("options"), disabled: loading }, "\u2190 Back to Options"))));
916
- const renderRecoveryForm = () => (react_1.default.createElement("div", { className: "shogun-auth-form" },
917
- react_1.default.createElement("div", { className: "shogun-form-group" },
918
- react_1.default.createElement("label", { htmlFor: "username" },
919
- react_1.default.createElement(UserIcon, null),
920
- react_1.default.createElement("span", null, "Username")),
921
- react_1.default.createElement("input", { type: "text", id: "username", value: formUsername, onChange: (e) => setFormUsername(e.target.value), disabled: loading, required: true, placeholder: "Enter your username" })),
922
- react_1.default.createElement("div", { className: "shogun-form-group" },
923
- react_1.default.createElement("label", null, "Security Question"),
924
- react_1.default.createElement("p", null, formSecurityQuestion)),
925
- react_1.default.createElement("div", { className: "shogun-form-group" },
926
- react_1.default.createElement("label", { htmlFor: "securityAnswer" },
927
- react_1.default.createElement(KeyIcon, null),
928
- react_1.default.createElement("span", null, "Answer")),
929
- react_1.default.createElement("input", { type: "text", id: "securityAnswer", value: formSecurityAnswer, onChange: (e) => setFormSecurityAnswer(e.target.value), disabled: loading, required: true, placeholder: "Enter your answer" })),
930
- react_1.default.createElement("button", { type: "button", className: "shogun-submit-button", onClick: handleRecover, disabled: loading }, loading ? "Recovering..." : "Get Hint"),
931
- react_1.default.createElement("div", { className: "shogun-form-footer" },
932
- react_1.default.createElement("button", { className: "shogun-toggle-mode", onClick: () => setAuthView("password"), disabled: loading }, "Back to Login"))));
933
- const renderHint = () => (react_1.default.createElement("div", { className: "shogun-auth-form" },
934
- react_1.default.createElement("h3", null, "Your Password Hint"),
935
- react_1.default.createElement("p", { className: "shogun-hint" }, recoveredHint),
936
- react_1.default.createElement("button", { className: "shogun-submit-button", onClick: () => {
866
+ React.createElement("div", { className: "shogun-form-group" },
867
+ React.createElement("label", { htmlFor: "username" },
868
+ React.createElement(UserIcon, null),
869
+ React.createElement("span", null, "Username")),
870
+ React.createElement("input", { type: "text", id: "username", value: formUsername, onChange: (e) => setFormUsername(e.target.value), disabled: loading, required: true, placeholder: "Enter your username", autoFocus: true })),
871
+ React.createElement("button", { type: "button", className: "shogun-submit-button", onClick: () => handleAuth("webauthn", formUsername), disabled: loading || !formUsername.trim() }, loading ? "Processing..." : `Continue with WebAuthn`),
872
+ React.createElement("div", { className: "shogun-form-footer" },
873
+ React.createElement("button", { type: "button", className: "shogun-back-button", onClick: () => setAuthView("options"), disabled: loading }, "\u2190 Back to Options"))));
874
+ const renderRecoveryForm = () => (React.createElement("div", { className: "shogun-auth-form" },
875
+ React.createElement("div", { className: "shogun-form-group" },
876
+ React.createElement("label", { htmlFor: "username" },
877
+ React.createElement(UserIcon, null),
878
+ React.createElement("span", null, "Username")),
879
+ React.createElement("input", { type: "text", id: "username", value: formUsername, onChange: (e) => setFormUsername(e.target.value), disabled: loading, required: true, placeholder: "Enter your username" })),
880
+ React.createElement("div", { className: "shogun-form-group" },
881
+ React.createElement("label", null, "Security Question"),
882
+ React.createElement("p", null, formSecurityQuestion)),
883
+ React.createElement("div", { className: "shogun-form-group" },
884
+ React.createElement("label", { htmlFor: "securityAnswer" },
885
+ React.createElement(KeyIcon, null),
886
+ React.createElement("span", null, "Answer")),
887
+ React.createElement("input", { type: "text", id: "securityAnswer", value: formSecurityAnswer, onChange: (e) => setFormSecurityAnswer(e.target.value), disabled: loading, required: true, placeholder: "Enter your answer" })),
888
+ React.createElement("button", { type: "button", className: "shogun-submit-button", onClick: handleRecover, disabled: loading }, loading ? "Recovering..." : "Get Hint"),
889
+ React.createElement("div", { className: "shogun-form-footer" },
890
+ React.createElement("button", { className: "shogun-toggle-mode", onClick: () => setAuthView("password"), disabled: loading }, "Back to Login"))));
891
+ const renderHint = () => (React.createElement("div", { className: "shogun-auth-form" },
892
+ React.createElement("h3", null, "Your Password Hint"),
893
+ React.createElement("p", { className: "shogun-hint" }, recoveredHint),
894
+ React.createElement("button", { className: "shogun-submit-button", onClick: () => {
937
895
  setAuthView("password");
938
896
  resetForm();
939
897
  setFormMode("login");
940
898
  } }, "Back to Login")));
941
- const renderExportForm = () => (react_1.default.createElement("div", { className: "shogun-auth-form" },
942
- react_1.default.createElement("h3", null, "Export Gun Pair"),
943
- react_1.default.createElement("div", { style: {
899
+ const renderExportForm = () => (React.createElement("div", { className: "shogun-auth-form" },
900
+ React.createElement("h3", null, "Export Gun Pair"),
901
+ React.createElement("div", { style: {
944
902
  backgroundColor: "#f0f9ff",
945
903
  padding: "12px",
946
904
  borderRadius: "8px",
947
905
  marginBottom: "16px",
948
906
  border: "1px solid #0ea5e9",
949
907
  } },
950
- react_1.default.createElement("p", { style: {
908
+ React.createElement("p", { style: {
951
909
  fontSize: "14px",
952
910
  color: "#0c4a6e",
953
911
  margin: "0",
954
912
  fontWeight: "500",
955
913
  } }, "\uD83D\uDD12 Backup Your Account"),
956
- react_1.default.createElement("p", { style: { fontSize: "13px", color: "#075985", margin: "4px 0 0 0" } }, "Export your Gun pair to backup your account. You can use this to login from another device or restore access if needed.")),
957
- react_1.default.createElement("div", { className: "shogun-form-group" },
958
- react_1.default.createElement("label", { htmlFor: "exportPassword" },
959
- react_1.default.createElement(LockIcon, null),
960
- react_1.default.createElement("span", null, "Encryption Password (optional but recommended)")),
961
- react_1.default.createElement("input", { type: "password", id: "exportPassword", value: exportPassword, onChange: (e) => setExportPassword(e.target.value), disabled: loading, placeholder: "Leave empty to export unencrypted" })),
962
- exportedPair && (react_1.default.createElement("div", { className: "shogun-form-group" },
963
- react_1.default.createElement("label", null, "Your Gun Pair (copy this safely):"),
964
- showCopySuccess && (react_1.default.createElement("div", { style: {
914
+ React.createElement("p", { style: { fontSize: "13px", color: "#075985", margin: "4px 0 0 0" } }, "Export your Gun pair to backup your account. You can use this to login from another device or restore access if needed.")),
915
+ React.createElement("div", { className: "shogun-form-group" },
916
+ React.createElement("label", { htmlFor: "exportPassword" },
917
+ React.createElement(LockIcon, null),
918
+ React.createElement("span", null, "Encryption Password (optional but recommended)")),
919
+ React.createElement("input", { type: "password", id: "exportPassword", value: exportPassword, onChange: (e) => setExportPassword(e.target.value), disabled: loading, placeholder: "Leave empty to export unencrypted" })),
920
+ exportedPair && (React.createElement("div", { className: "shogun-form-group" },
921
+ React.createElement("label", null, "Your Gun Pair (copy this safely):"),
922
+ showCopySuccess && (React.createElement("div", { style: {
965
923
  backgroundColor: "#dcfce7",
966
924
  color: "#166534",
967
925
  padding: "8px 12px",
@@ -970,7 +928,7 @@ exports.ShogunButton = (() => {
970
928
  fontSize: "14px",
971
929
  border: "1px solid #22c55e",
972
930
  } }, "\u2705 Copied to clipboard successfully!")),
973
- react_1.default.createElement("textarea", { value: exportedPair, readOnly: true, rows: 6, style: {
931
+ React.createElement("textarea", { value: exportedPair, readOnly: true, rows: 6, style: {
974
932
  fontFamily: "monospace",
975
933
  fontSize: "12px",
976
934
  width: "100%",
@@ -978,10 +936,10 @@ exports.ShogunButton = (() => {
978
936
  border: "1px solid #ccc",
979
937
  borderRadius: "4px",
980
938
  } }),
981
- !navigator.clipboard && (react_1.default.createElement("p", { style: { fontSize: "12px", color: "#666", marginTop: "8px" } }, "\u26A0\uFE0F Auto-copy not available. Please manually copy the text above.")))),
982
- react_1.default.createElement("button", { type: "button", className: "shogun-submit-button", onClick: handleExportPair, disabled: loading }, loading ? "Exporting..." : "Export Pair"),
983
- react_1.default.createElement("div", { className: "shogun-form-footer" },
984
- react_1.default.createElement("button", { className: "shogun-toggle-mode", onClick: () => {
939
+ !navigator.clipboard && (React.createElement("p", { style: { fontSize: "12px", color: "#666", marginTop: "8px" } }, "\u26A0\uFE0F Auto-copy not available. Please manually copy the text above.")))),
940
+ React.createElement("button", { type: "button", className: "shogun-submit-button", onClick: handleExportPair, disabled: loading }, loading ? "Exporting..." : "Export Pair"),
941
+ React.createElement("div", { className: "shogun-form-footer" },
942
+ React.createElement("button", { className: "shogun-toggle-mode", onClick: () => {
985
943
  if (isLoggedIn) {
986
944
  // If user is logged in, close the modal instead of going to options
987
945
  setModalIsOpen(false);
@@ -994,27 +952,27 @@ exports.ShogunButton = (() => {
994
952
  setExportedPair("");
995
953
  }
996
954
  }, disabled: loading }, "Back"))));
997
- const renderImportForm = () => (react_1.default.createElement("div", { className: "shogun-auth-form" },
998
- react_1.default.createElement("h3", null, "Import Gun Pair"),
999
- react_1.default.createElement("div", { style: {
955
+ const renderImportForm = () => (React.createElement("div", { className: "shogun-auth-form" },
956
+ React.createElement("h3", null, "Import Gun Pair"),
957
+ React.createElement("div", { style: {
1000
958
  backgroundColor: "#fef3c7",
1001
959
  padding: "12px",
1002
960
  borderRadius: "8px",
1003
961
  marginBottom: "16px",
1004
962
  border: "1px solid #f59e0b",
1005
963
  } },
1006
- react_1.default.createElement("p", { style: {
964
+ React.createElement("p", { style: {
1007
965
  fontSize: "14px",
1008
966
  color: "#92400e",
1009
967
  margin: "0",
1010
968
  fontWeight: "500",
1011
969
  } }, "\uD83D\uDD11 Restore Your Account"),
1012
- react_1.default.createElement("p", { style: { fontSize: "13px", color: "#a16207", margin: "4px 0 0 0" } }, "Import a Gun pair to login with your existing account from another device. Make sure you have your backup data ready.")),
1013
- react_1.default.createElement("div", { className: "shogun-form-group" },
1014
- react_1.default.createElement("label", { htmlFor: "importPairData" },
1015
- react_1.default.createElement(ImportIcon, null),
1016
- react_1.default.createElement("span", null, "Gun Pair Data")),
1017
- react_1.default.createElement("textarea", { id: "importPairData", value: importPairData, onChange: (e) => setImportPairData(e.target.value), disabled: loading, placeholder: "Paste your Gun pair JSON here...", rows: 6, style: {
970
+ React.createElement("p", { style: { fontSize: "13px", color: "#a16207", margin: "4px 0 0 0" } }, "Import a Gun pair to login with your existing account from another device. Make sure you have your backup data ready.")),
971
+ React.createElement("div", { className: "shogun-form-group" },
972
+ React.createElement("label", { htmlFor: "importPairData" },
973
+ React.createElement(ImportIcon, null),
974
+ React.createElement("span", null, "Gun Pair Data")),
975
+ React.createElement("textarea", { id: "importPairData", value: importPairData, onChange: (e) => setImportPairData(e.target.value), disabled: loading, placeholder: "Paste your Gun pair JSON here...", rows: 6, style: {
1018
976
  fontFamily: "monospace",
1019
977
  fontSize: "12px",
1020
978
  width: "100%",
@@ -1022,12 +980,12 @@ exports.ShogunButton = (() => {
1022
980
  border: "1px solid #ccc",
1023
981
  borderRadius: "4px",
1024
982
  } })),
1025
- react_1.default.createElement("div", { className: "shogun-form-group" },
1026
- react_1.default.createElement("label", { htmlFor: "importPassword" },
1027
- react_1.default.createElement(LockIcon, null),
1028
- react_1.default.createElement("span", null, "Decryption Password (if encrypted)")),
1029
- react_1.default.createElement("input", { type: "password", id: "importPassword", value: importPassword, onChange: (e) => setImportPassword(e.target.value), disabled: loading, placeholder: "Enter password if pair was encrypted" })),
1030
- showImportSuccess && (react_1.default.createElement("div", { style: {
983
+ React.createElement("div", { className: "shogun-form-group" },
984
+ React.createElement("label", { htmlFor: "importPassword" },
985
+ React.createElement(LockIcon, null),
986
+ React.createElement("span", null, "Decryption Password (if encrypted)")),
987
+ React.createElement("input", { type: "password", id: "importPassword", value: importPassword, onChange: (e) => setImportPassword(e.target.value), disabled: loading, placeholder: "Enter password if pair was encrypted" })),
988
+ showImportSuccess && (React.createElement("div", { style: {
1031
989
  backgroundColor: "#dcfce7",
1032
990
  color: "#166534",
1033
991
  padding: "12px",
@@ -1037,26 +995,26 @@ exports.ShogunButton = (() => {
1037
995
  border: "1px solid #22c55e",
1038
996
  textAlign: "center",
1039
997
  } }, "\u2705 Pair imported successfully! Logging you in...")),
1040
- react_1.default.createElement("button", { type: "button", className: "shogun-submit-button", onClick: handleImportPair, disabled: loading || showImportSuccess }, loading
998
+ React.createElement("button", { type: "button", className: "shogun-submit-button", onClick: handleImportPair, disabled: loading || showImportSuccess }, loading
1041
999
  ? "Importing..."
1042
1000
  : showImportSuccess
1043
1001
  ? "Success!"
1044
1002
  : "Import and Login"),
1045
- react_1.default.createElement("div", { className: "shogun-form-footer" },
1046
- react_1.default.createElement("button", { className: "shogun-toggle-mode", onClick: () => {
1003
+ React.createElement("div", { className: "shogun-form-footer" },
1004
+ React.createElement("button", { className: "shogun-toggle-mode", onClick: () => {
1047
1005
  setAuthView("options");
1048
1006
  setImportPassword("");
1049
1007
  setImportPairData("");
1050
1008
  }, disabled: loading }, "Back to Login Options"))));
1051
1009
  // Render logic
1052
- return (react_1.default.createElement(react_1.default.Fragment, null,
1053
- react_1.default.createElement("button", { className: "shogun-connect-button", onClick: openModal },
1054
- react_1.default.createElement(WalletIcon, null),
1055
- react_1.default.createElement("span", null, "Login / Sign Up")),
1056
- modalIsOpen && (react_1.default.createElement("div", { className: "shogun-modal-overlay", onClick: closeModal },
1057
- react_1.default.createElement("div", { className: "shogun-modal", onClick: (e) => e.stopPropagation() },
1058
- react_1.default.createElement("div", { className: "shogun-modal-header" },
1059
- react_1.default.createElement("h2", null, authView === "recover"
1010
+ return (React.createElement(React.Fragment, null,
1011
+ React.createElement("button", { className: "shogun-connect-button", onClick: openModal },
1012
+ React.createElement(WalletIcon, null),
1013
+ React.createElement("span", null, "Login / Sign Up")),
1014
+ modalIsOpen && (React.createElement("div", { className: "shogun-modal-overlay", onClick: closeModal },
1015
+ React.createElement("div", { className: "shogun-modal", onClick: (e) => e.stopPropagation() },
1016
+ React.createElement("div", { className: "shogun-modal-header" },
1017
+ React.createElement("h2", null, authView === "recover"
1060
1018
  ? "Recover Password"
1061
1019
  : authView === "showHint"
1062
1020
  ? "Password Hint"
@@ -1069,24 +1027,18 @@ exports.ShogunButton = (() => {
1069
1027
  : formMode === "login"
1070
1028
  ? "Login"
1071
1029
  : "Sign Up"),
1072
- react_1.default.createElement("button", { className: "shogun-close-button", onClick: closeModal, "aria-label": "Close" },
1073
- react_1.default.createElement(CloseIcon, null))),
1074
- react_1.default.createElement("div", { className: "shogun-modal-content" },
1075
- error && react_1.default.createElement("div", { className: "shogun-error-message" }, error),
1076
- authView === "options" && (react_1.default.createElement(react_1.default.Fragment, null,
1030
+ React.createElement("button", { className: "shogun-close-button", onClick: closeModal, "aria-label": "Close" },
1031
+ React.createElement(CloseIcon, null))),
1032
+ React.createElement("div", { className: "shogun-modal-content" },
1033
+ error && React.createElement("div", { className: "shogun-error-message" }, error),
1034
+ authView === "options" && (React.createElement(React.Fragment, null,
1077
1035
  renderAuthOptions(),
1078
- react_1.default.createElement("div", { className: "shogun-form-footer" },
1079
- react_1.default.createElement("button", { type: "button", className: "shogun-toggle-mode shogun-prominent-toggle", onClick: () => {
1080
- console.log("๐Ÿ”ง Signup button clicked!");
1081
- console.log("๐Ÿ”ง Current formMode:", formMode);
1082
- console.log("๐Ÿ”ง Current loading:", loading);
1083
- console.log("๐Ÿ”ง Current authView:", authView);
1084
- toggleMode();
1085
- }, disabled: loading }, formMode === "login"
1036
+ React.createElement("div", { className: "shogun-form-footer" },
1037
+ React.createElement("button", { type: "button", className: "shogun-toggle-mode shogun-prominent-toggle", onClick: toggleMode, disabled: loading }, formMode === "login"
1086
1038
  ? "Don't have an account? Sign up"
1087
1039
  : "Already have an account? Log in")))),
1088
- authView === "password" && (react_1.default.createElement(react_1.default.Fragment, null,
1089
- react_1.default.createElement("button", { className: "shogun-back-button", onClick: () => setAuthView("options") }, "\u2190 Back"),
1040
+ authView === "password" && (React.createElement(React.Fragment, null,
1041
+ React.createElement("button", { className: "shogun-back-button", onClick: () => setAuthView("options") }, "\u2190 Back"),
1090
1042
  renderPasswordForm())),
1091
1043
  authView === "recover" && renderRecoveryForm(),
1092
1044
  authView === "showHint" && renderHint(),
@@ -1098,6 +1050,6 @@ exports.ShogunButton = (() => {
1098
1050
  Button.displayName = "ShogunButton";
1099
1051
  return Object.assign(Button, {
1100
1052
  Provider: ShogunButtonProvider,
1101
- useShogun: exports.useShogun,
1053
+ useShogun: useShogun,
1102
1054
  });
1103
1055
  })();