shogun-button-react 6.9.3 → 6.9.6

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.
@@ -3,7 +3,9 @@ import { Observable } from "rxjs";
3
3
  import "../styles/index.css";
4
4
  // Helper type to check if core is ShogunCore
5
5
  function isShogunCore(core) {
6
- return core && typeof core.isLoggedIn === 'function' && typeof core.gun !== 'undefined';
6
+ return (core &&
7
+ typeof core.isLoggedIn === "function" &&
8
+ typeof core.gun !== "undefined");
7
9
  }
8
10
  // Default context
9
11
  const defaultShogunContext = {
@@ -61,9 +63,9 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
61
63
  }
62
64
  // Poiché il metodo 'on' non esiste su ShogunCore,
63
65
  // gestiamo gli stati direttamente nei metodi di login/logout
64
- }, [core, onLoginSuccess]);
66
+ }, [core]);
65
67
  // RxJS observe method
66
- const observe = (path) => {
68
+ const observe = React.useCallback((path) => {
67
69
  var _a;
68
70
  if (!core) {
69
71
  return new Observable();
@@ -74,9 +76,9 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
74
76
  return observable;
75
77
  }
76
78
  return new Observable();
77
- };
79
+ }, [core]);
78
80
  // Unified login
79
- const login = async (method, ...args) => {
81
+ const login = React.useCallback(async (method, ...args) => {
80
82
  var _a, _b;
81
83
  try {
82
84
  if (!core) {
@@ -174,24 +176,6 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
174
176
  throw new Error("Nostr requires ShogunCore");
175
177
  }
176
178
  break;
177
- case "zkproof":
178
- const trapdoor = args[0];
179
- if (!trapdoor || typeof trapdoor !== "string") {
180
- throw new Error("Invalid trapdoor provided");
181
- }
182
- if (isShogunCore(core)) {
183
- const zkproof = core.getPlugin("zkproof");
184
- if (!zkproof)
185
- throw new Error("ZK-Proof plugin not available");
186
- const zkLoginResult = await zkproof.login(trapdoor);
187
- result = zkLoginResult;
188
- username = zkLoginResult.username || zkLoginResult.alias || `zk_${(zkLoginResult.userPub || "").slice(0, 16)}`;
189
- authMethod = "zkproof";
190
- }
191
- else {
192
- throw new Error("ZK-Proof requires ShogunCore");
193
- }
194
- break;
195
179
  case "challenge":
196
180
  username = args[0];
197
181
  if (!username)
@@ -248,9 +232,9 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
248
232
  onError === null || onError === void 0 ? void 0 : onError(error.message || "Error during login");
249
233
  return { success: false, error: error.message };
250
234
  }
251
- };
235
+ }, [core, onLoginSuccess, onError]);
252
236
  // Unified signup
253
- const signUp = async (method, ...args) => {
237
+ const signUp = React.useCallback(async (method, ...args) => {
254
238
  var _a, _b, _c;
255
239
  try {
256
240
  if (!core) {
@@ -351,21 +335,6 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
351
335
  throw new Error("Nostr requires ShogunCore");
352
336
  }
353
337
  break;
354
- case "zkproof":
355
- if (isShogunCore(core)) {
356
- const zkproofPlugin = core.getPlugin("zkproof");
357
- if (!zkproofPlugin)
358
- throw new Error("ZK-Proof plugin not available");
359
- const seed = args[0]; // Optional seed
360
- const zkSignupResult = await zkproofPlugin.signUp(seed);
361
- result = zkSignupResult;
362
- username = zkSignupResult.username || zkSignupResult.alias || `zk_${(zkSignupResult.userPub || "").slice(0, 16)}`;
363
- authMethod = "zkproof";
364
- }
365
- else {
366
- throw new Error("ZK-Proof requires ShogunCore");
367
- }
368
- break;
369
338
  default:
370
339
  throw new Error("Unsupported signup method");
371
340
  }
@@ -397,18 +366,18 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
397
366
  onError === null || onError === void 0 ? void 0 : onError(error.message || "Error during registration");
398
367
  return { success: false, error: error.message };
399
368
  }
400
- };
369
+ }, [core, onSignupSuccess, onError]);
401
370
  // Logout
402
- const logout = () => {
371
+ const logout = React.useCallback(() => {
403
372
  if (isShogunCore(core)) {
404
373
  core.logout();
405
374
  }
406
375
  setIsLoggedIn(false);
407
376
  setUserPub(null);
408
377
  setUsername(null);
409
- };
378
+ }, [core]);
410
379
  // Implementazione del metodo setProvider
411
- const setProvider = (provider) => {
380
+ const setProvider = React.useCallback((provider) => {
412
381
  var _a;
413
382
  if (!core) {
414
383
  return false;
@@ -440,21 +409,21 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
440
409
  console.error("Error setting provider:", error);
441
410
  return false;
442
411
  }
443
- };
444
- const hasPlugin = (name) => {
412
+ }, [core]);
413
+ const hasPlugin = React.useCallback((name) => {
445
414
  if (isShogunCore(core)) {
446
415
  return core.hasPlugin(name);
447
416
  }
448
417
  return false;
449
- };
450
- const getPlugin = (name) => {
418
+ }, [core]);
419
+ const getPlugin = React.useCallback((name) => {
451
420
  if (isShogunCore(core)) {
452
421
  return core.getPlugin(name);
453
422
  }
454
423
  return undefined;
455
- };
424
+ }, [core]);
456
425
  // Export Gun pair functionality
457
- const exportGunPair = async (password) => {
426
+ const exportGunPair = React.useCallback(async (password) => {
458
427
  if (!core) {
459
428
  throw new Error("SDK not initialized");
460
429
  }
@@ -482,9 +451,9 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
482
451
  catch (error) {
483
452
  throw new Error(`Failed to export Gun pair: ${error.message}`);
484
453
  }
485
- };
454
+ }, [core, isLoggedIn]);
486
455
  // Import Gun pair functionality
487
- const importGunPair = async (pairData, password) => {
456
+ const importGunPair = React.useCallback(async (pairData, password) => {
488
457
  if (!core) {
489
458
  throw new Error("SDK not initialized");
490
459
  }
@@ -514,11 +483,9 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
514
483
  catch (error) {
515
484
  throw new Error(`Failed to import Gun pair: ${error.message}`);
516
485
  }
517
- };
486
+ }, [core, login]);
518
487
  // Plugin initialization removed - GunAdvancedPlugin no longer available
519
488
  const gunPlugin = null;
520
- // Plugin hooks removed - GunAdvancedPlugin no longer available
521
- const pluginHooks = {};
522
489
  const completePendingSignup = React.useCallback(() => {
523
490
  setHasPendingSignup(false);
524
491
  }, [setHasPendingSignup]);
@@ -545,7 +512,7 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
545
512
  put: async (path, data) => {
546
513
  if (isShogunCore(core)) {
547
514
  if (!core.gun)
548
- throw new Error('Gun instance not available');
515
+ throw new Error("Gun instance not available");
549
516
  return new Promise((resolve, reject) => {
550
517
  core.gun.get(path).put(data, (ack) => {
551
518
  if (ack.err)
@@ -556,7 +523,7 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
556
523
  });
557
524
  }
558
525
  else {
559
- throw new Error('Core not available');
526
+ throw new Error("Core not available");
560
527
  }
561
528
  },
562
529
  get: (path) => {
@@ -570,7 +537,7 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
570
537
  remove: async (path) => {
571
538
  if (isShogunCore(core)) {
572
539
  if (!core.gun)
573
- throw new Error('Gun instance not available');
540
+ throw new Error("Gun instance not available");
574
541
  return new Promise((resolve, reject) => {
575
542
  core.gun.get(path).put(null, (ack) => {
576
543
  if (ack.err)
@@ -581,7 +548,7 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
581
548
  });
582
549
  }
583
550
  else {
584
- throw new Error('Core not available');
551
+ throw new Error("Core not available");
585
552
  }
586
553
  },
587
554
  }), [
@@ -599,7 +566,6 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
599
566
  exportGunPair,
600
567
  importGunPair,
601
568
  gunPlugin,
602
- pluginHooks,
603
569
  completePendingSignup,
604
570
  hasPendingSignup,
605
571
  setHasPendingSignup,
@@ -640,10 +606,6 @@ const ImportIcon = () => (React.createElement("svg", { xmlns: "http://www.w3.org
640
606
  React.createElement("polyline", { points: "14,2 14,8 20,8" }),
641
607
  React.createElement("line", { x1: "16", y1: "13", x2: "8", y2: "13" }),
642
608
  React.createElement("line", { x1: "12", y1: "17", x2: "12", y2: "9" })));
643
- const ZkProofIcon = () => (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" },
644
- React.createElement("path", { d: "M12 2L2 7l10 5 10-5-10-5z" }),
645
- React.createElement("path", { d: "M2 17l10 5 10-5" }),
646
- React.createElement("path", { d: "M2 12l10 5 10-5" })));
647
609
  const ChallengeIcon = () => (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" },
648
610
  React.createElement("polygon", { points: "12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" })));
649
611
  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" },
@@ -660,24 +622,17 @@ export const ShogunButton = (() => {
660
622
  const [formUsername, setFormUsername] = useState("");
661
623
  const [formPassword, setFormPassword] = useState("");
662
624
  const [formPasswordConfirm, setFormPasswordConfirm] = useState("");
663
- const [formHint, setFormHint] = useState("");
664
- const [formSecurityQuestion] = useState("What is your favorite color?"); // Hardcoded for now
665
- const [formSecurityAnswer, setFormSecurityAnswer] = useState("");
666
625
  const [formMode, setFormMode] = useState("login");
667
626
  const [authView, setAuthView] = useState("options");
668
627
  const [error, setError] = useState("");
669
628
  const [loading, setLoading] = useState(false);
670
629
  const [dropdownOpen, setDropdownOpen] = useState(false);
671
- const [recoveredHint, setRecoveredHint] = useState("");
672
630
  const [exportPassword, setExportPassword] = useState("");
673
631
  const [importPassword, setImportPassword] = useState("");
674
632
  const [importPairData, setImportPairData] = useState("");
675
633
  const [exportedPair, setExportedPair] = useState("");
676
634
  const [showCopySuccess, setShowCopySuccess] = useState(false);
677
635
  const [showImportSuccess, setShowImportSuccess] = useState(false);
678
- const [zkTrapdoor, setZkTrapdoor] = useState("");
679
- const [zkSignupTrapdoor, setZkSignupTrapdoor] = useState("");
680
- const [showZkTrapdoorCopySuccess, setShowZkTrapdoorCopySuccess] = useState(false);
681
636
  const [webauthnSeedPhrase, setWebauthnSeedPhrase] = useState("");
682
637
  const [webauthnRecoverySeed, setWebauthnRecoverySeed] = useState("");
683
638
  const [formMnemonic, setFormMnemonic] = useState("");
@@ -700,17 +655,13 @@ export const ShogunButton = (() => {
700
655
  useEffect(() => {
701
656
  if (hasPendingSignup) {
702
657
  setModalIsOpen(true);
703
- if (authView !== "webauthn-signup-result" &&
704
- authView !== "zkproof-signup-result") {
658
+ if (authView !== "webauthn-signup-result") {
705
659
  if (webauthnSeedPhrase) {
706
660
  setAuthView("webauthn-signup-result");
707
661
  }
708
- else if (zkSignupTrapdoor) {
709
- setAuthView("zkproof-signup-result");
710
- }
711
662
  }
712
663
  }
713
- }, [hasPendingSignup, authView, webauthnSeedPhrase, zkSignupTrapdoor]);
664
+ }, [hasPendingSignup, authView, webauthnSeedPhrase]);
714
665
  // If already logged in, show only logout button
715
666
  if (isLoggedIn && username && !modalIsOpen) {
716
667
  return (React.createElement("div", { className: "shogun-logged-in-container" },
@@ -787,26 +738,6 @@ export const ShogunButton = (() => {
787
738
  if (formMode === "signup") {
788
739
  const result = await signUp("password", formUsername, formPassword, formPasswordConfirm);
789
740
  if (result && result.success) {
790
- // Password hint functionality has been removed from shogun-core
791
- // Users should store hints manually in their own data structures if needed
792
- if (isShogunCore(core) && core.db && formHint) {
793
- try {
794
- // Store hint manually in user data
795
- const user = core.gun.user();
796
- if (user && user.is) {
797
- core.db.gun.get('users').get(formUsername).get('hint').put(formHint);
798
- if (formSecurityAnswer) {
799
- core.db.gun.get('users').get(formUsername).get('security').put({
800
- question: formSecurityQuestion,
801
- answer: formSecurityAnswer
802
- });
803
- }
804
- }
805
- }
806
- catch (error) {
807
- console.warn('Failed to store password hint:', error);
808
- }
809
- }
810
741
  setModalIsOpen(false);
811
742
  }
812
743
  else if (result && result.error) {
@@ -866,63 +797,6 @@ export const ShogunButton = (() => {
866
797
  setLoading(false);
867
798
  }
868
799
  };
869
- const handleZkProofAuth = () => {
870
- if (!hasPlugin("zkproof")) {
871
- setError("ZK-Proof plugin not available");
872
- return;
873
- }
874
- if (formMode === "login") {
875
- setAuthView("zkproof-login");
876
- }
877
- else {
878
- // For signup, directly call signUp and show trapdoor
879
- handleZkProofSignup();
880
- }
881
- };
882
- const handleZkProofLogin = async () => {
883
- setError("");
884
- setLoading(true);
885
- try {
886
- if (!zkTrapdoor.trim()) {
887
- throw new Error("Please enter your trapdoor");
888
- }
889
- await handleAuth("zkproof", zkTrapdoor);
890
- setModalIsOpen(false);
891
- }
892
- catch (e) {
893
- setError(e.message || "ZK-Proof login failed");
894
- }
895
- finally {
896
- setLoading(false);
897
- }
898
- };
899
- const handleZkProofSignup = async () => {
900
- setError("");
901
- setLoading(true);
902
- try {
903
- const result = await signUp("zkproof");
904
- if (!result || !result.success) {
905
- throw new Error((result === null || result === void 0 ? void 0 : result.error) || "ZK-Proof signup failed");
906
- }
907
- const trapdoorValue = result.seedPhrase || result.trapdoor || "";
908
- if (trapdoorValue) {
909
- setZkSignupTrapdoor(trapdoorValue);
910
- setShowZkTrapdoorCopySuccess(false);
911
- setAuthView("zkproof-signup-result");
912
- setHasPendingSignup(true);
913
- }
914
- else {
915
- setAuthView("options");
916
- setModalIsOpen(false);
917
- }
918
- }
919
- catch (e) {
920
- setError(e.message || "ZK-Proof signup failed");
921
- }
922
- finally {
923
- setLoading(false);
924
- }
925
- };
926
800
  const handleChallengeAuth = () => {
927
801
  if (!hasPlugin("challenge")) {
928
802
  setError("Challenge plugin not available");
@@ -967,51 +841,9 @@ export const ShogunButton = (() => {
967
841
  setLoading(false);
968
842
  }
969
843
  };
970
- const handleRecover = async () => {
971
- setError("");
972
- setLoading(true);
973
- try {
974
- if (isShogunCore(core) && core.db) {
975
- // Password recovery functionality has been removed from shogun-core
976
- // Users should implement their own recovery logic using Gun's get operations
977
- try {
978
- const hintNode = await new Promise((resolve) => {
979
- core.db.gun.get('users').get(formUsername).get('hint').once((hint) => {
980
- resolve(hint || null);
981
- });
982
- });
983
- const securityNode = await new Promise((resolve) => {
984
- core.db.gun.get('users').get(formUsername).get('security').once((security) => {
985
- resolve(security || null);
986
- });
987
- });
988
- if (securityNode && securityNode.answer === formSecurityAnswer) {
989
- if (hintNode) {
990
- setRecoveredHint(hintNode);
991
- setAuthView("showHint");
992
- }
993
- else {
994
- setError("No hint found for this user.");
995
- }
996
- }
997
- else {
998
- setError("Security answer is incorrect.");
999
- }
1000
- }
1001
- catch (error) {
1002
- setError(error.message || "Could not recover hint.");
1003
- }
1004
- }
1005
- else {
1006
- setError("Password recovery requires ShogunCore");
1007
- }
1008
- }
1009
- catch (e) {
1010
- setError(e.message || "An unexpected error occurred.");
1011
- }
1012
- finally {
1013
- setLoading(false);
1014
- }
844
+ const handleForgotPassword = async (e) => {
845
+ e.preventDefault();
846
+ setError("Password recovery is no longer supported.");
1015
847
  };
1016
848
  const handleExportPair = async () => {
1017
849
  setError("");
@@ -1064,8 +896,6 @@ export const ShogunButton = (() => {
1064
896
  setFormUsername("");
1065
897
  setFormPassword("");
1066
898
  setFormPasswordConfirm("");
1067
- setFormHint("");
1068
- setFormSecurityAnswer("");
1069
899
  setError("");
1070
900
  setLoading(false);
1071
901
  setAuthView("options");
@@ -1075,10 +905,7 @@ export const ShogunButton = (() => {
1075
905
  setExportedPair("");
1076
906
  setShowCopySuccess(false);
1077
907
  setShowImportSuccess(false);
1078
- setRecoveredHint("");
1079
- setZkTrapdoor("");
1080
- setZkSignupTrapdoor("");
1081
- setShowZkTrapdoorCopySuccess(false);
908
+ // Additional reset code if needed
1082
909
  setWebauthnSeedPhrase("");
1083
910
  setWebauthnRecoverySeed("");
1084
911
  setFormMnemonic("");
@@ -1093,7 +920,7 @@ export const ShogunButton = (() => {
1093
920
  setModalIsOpen(false);
1094
921
  setHasPendingSignup(false);
1095
922
  };
1096
- const finalizeZkProofSignup = () => {
923
+ const finalizeSignup = () => {
1097
924
  setError("");
1098
925
  resetForm();
1099
926
  setModalIsOpen(false);
@@ -1128,12 +955,6 @@ export const ShogunButton = (() => {
1128
955
  formMode === "login"
1129
956
  ? "Login with Challenge"
1130
957
  : "Signup with Challenge (N/A)"))),
1131
- options.showZkProof !== false && hasPlugin("zkproof") && (React.createElement("div", { className: "shogun-auth-option-group" },
1132
- React.createElement("button", { type: "button", className: "shogun-auth-option-button", onClick: handleZkProofAuth, disabled: loading },
1133
- React.createElement(ZkProofIcon, null),
1134
- formMode === "login"
1135
- ? "Login with ZK-Proof"
1136
- : "Signup with ZK-Proof"))),
1137
958
  React.createElement("div", { className: "shogun-divider" },
1138
959
  React.createElement("span", null, "or")),
1139
960
  React.createElement("button", { type: "button", className: "shogun-auth-option-button", onClick: () => setAuthView("password"), disabled: loading },
@@ -1163,22 +984,7 @@ export const ShogunButton = (() => {
1163
984
  React.createElement("label", { htmlFor: "passwordConfirm" },
1164
985
  React.createElement(KeyIcon, null),
1165
986
  React.createElement("span", null, "Confirm Password")),
1166
- React.createElement("input", { type: "password", id: "passwordConfirm", value: formPasswordConfirm, onChange: (e) => setFormPasswordConfirm(e.target.value), disabled: loading, required: true, placeholder: "Confirm your password" })),
1167
- React.createElement("div", { className: "shogun-form-group" },
1168
- React.createElement("label", { htmlFor: "hint" },
1169
- React.createElement(UserIcon, null),
1170
- React.createElement("span", null, "Password Hint")),
1171
- React.createElement("input", { type: "text", id: "hint", value: formHint, onChange: (e) => setFormHint(e.target.value), disabled: loading, required: true, placeholder: "Enter your password hint" })),
1172
- React.createElement("div", { className: "shogun-form-group" },
1173
- React.createElement("label", { htmlFor: "securityQuestion" },
1174
- React.createElement(UserIcon, null),
1175
- React.createElement("span", null, "Security Question")),
1176
- React.createElement("input", { type: "text", id: "securityQuestion", value: formSecurityQuestion, disabled: true })),
1177
- React.createElement("div", { className: "shogun-form-group" },
1178
- React.createElement("label", { htmlFor: "securityAnswer" },
1179
- React.createElement(UserIcon, null),
1180
- React.createElement("span", null, "Security Answer")),
1181
- React.createElement("input", { type: "text", id: "securityAnswer", value: formSecurityAnswer, onChange: (e) => setFormSecurityAnswer(e.target.value), disabled: loading, required: true, placeholder: "Enter your security answer" })))),
987
+ React.createElement("input", { type: "password", id: "passwordConfirm", value: formPasswordConfirm, onChange: (e) => setFormPasswordConfirm(e.target.value), disabled: loading, required: true, placeholder: "Confirm your password" })))),
1182
988
  React.createElement("button", { type: "submit", className: "shogun-submit-button", disabled: loading }, loading
1183
989
  ? "Processing..."
1184
990
  : formMode === "login"
@@ -1187,8 +993,7 @@ export const ShogunButton = (() => {
1187
993
  React.createElement("div", { className: "shogun-form-footer" },
1188
994
  React.createElement("button", { type: "button", className: "shogun-toggle-mode shogun-prominent-toggle", onClick: toggleMode, disabled: loading }, formMode === "login"
1189
995
  ? "Don't have an account? Sign up"
1190
- : "Already have an account? Log in"),
1191
- formMode === "login" && (React.createElement("button", { type: "button", className: "shogun-toggle-mode", onClick: () => setAuthView("recover"), disabled: loading }, "Forgot password?")))));
996
+ : "Already have an account? Log in"))));
1192
997
  const renderWebAuthnUsernameForm = () => (React.createElement("div", { className: "shogun-auth-form" },
1193
998
  React.createElement("h3", null, formMode === "login"
1194
999
  ? "Login with WebAuthn"
@@ -1264,31 +1069,6 @@ export const ShogunButton = (() => {
1264
1069
  setError("");
1265
1070
  setAuthView("webauthn-username");
1266
1071
  }, disabled: loading }, "\u2190 Back to WebAuthn"))));
1267
- const renderRecoveryForm = () => (React.createElement("div", { className: "shogun-auth-form" },
1268
- React.createElement("div", { className: "shogun-form-group" },
1269
- React.createElement("label", { htmlFor: "username" },
1270
- React.createElement(UserIcon, null),
1271
- React.createElement("span", null, "Username")),
1272
- React.createElement("input", { type: "text", id: "username", value: formUsername, onChange: (e) => setFormUsername(e.target.value), disabled: loading, required: true, placeholder: "Enter your username" })),
1273
- React.createElement("div", { className: "shogun-form-group" },
1274
- React.createElement("label", null, "Security Question"),
1275
- React.createElement("p", null, formSecurityQuestion)),
1276
- React.createElement("div", { className: "shogun-form-group" },
1277
- React.createElement("label", { htmlFor: "securityAnswer" },
1278
- React.createElement(KeyIcon, null),
1279
- React.createElement("span", null, "Answer")),
1280
- React.createElement("input", { type: "text", id: "securityAnswer", value: formSecurityAnswer, onChange: (e) => setFormSecurityAnswer(e.target.value), disabled: loading, required: true, placeholder: "Enter your answer" })),
1281
- React.createElement("button", { type: "button", className: "shogun-submit-button", onClick: handleRecover, disabled: loading }, loading ? "Recovering..." : "Get Hint"),
1282
- React.createElement("div", { className: "shogun-form-footer" },
1283
- React.createElement("button", { className: "shogun-toggle-mode", onClick: () => setAuthView("password"), disabled: loading }, "Back to Login"))));
1284
- const renderHint = () => (React.createElement("div", { className: "shogun-auth-form" },
1285
- React.createElement("h3", null, "Your Password Hint"),
1286
- React.createElement("p", { className: "shogun-hint" }, recoveredHint),
1287
- React.createElement("button", { className: "shogun-submit-button", onClick: () => {
1288
- setAuthView("password");
1289
- resetForm();
1290
- setFormMode("login");
1291
- } }, "Back to Login")));
1292
1072
  const renderExportForm = () => (React.createElement("div", { className: "shogun-auth-form" },
1293
1073
  React.createElement("h3", null, "Export Gun Pair"),
1294
1074
  React.createElement("div", { style: {
@@ -1345,86 +1125,6 @@ export const ShogunButton = (() => {
1345
1125
  setExportedPair("");
1346
1126
  }
1347
1127
  }, disabled: loading }, "Back"))));
1348
- const renderZkProofLoginForm = () => (React.createElement("div", { className: "shogun-auth-form" },
1349
- React.createElement("h3", null, "Login with ZK-Proof"),
1350
- React.createElement("div", { style: {
1351
- backgroundColor: "#f0f9ff",
1352
- padding: "12px",
1353
- borderRadius: "8px",
1354
- marginBottom: "16px",
1355
- border: "1px solid #0ea5e9",
1356
- } },
1357
- React.createElement("p", { style: {
1358
- fontSize: "14px",
1359
- color: "#0c4a6e",
1360
- margin: "0",
1361
- fontWeight: "500",
1362
- } }, "\uD83D\uDD12 Anonymous Authentication"),
1363
- React.createElement("p", { style: { fontSize: "13px", color: "#075985", margin: "4px 0 0 0" } }, "Enter your trapdoor (recovery phrase) to login anonymously using Zero-Knowledge Proofs. Your identity remains private.")),
1364
- React.createElement("div", { className: "shogun-form-group" },
1365
- React.createElement("label", { htmlFor: "zkTrapdoor" },
1366
- React.createElement(KeyIcon, null),
1367
- React.createElement("span", null, "Trapdoor / Recovery Phrase")),
1368
- React.createElement("textarea", { id: "zkTrapdoor", value: zkTrapdoor, onChange: (e) => setZkTrapdoor(e.target.value), disabled: loading, placeholder: "Enter your trapdoor...", rows: 4, style: {
1369
- fontFamily: "monospace",
1370
- fontSize: "12px",
1371
- width: "100%",
1372
- padding: "8px",
1373
- border: "1px solid #ccc",
1374
- borderRadius: "4px",
1375
- } })),
1376
- React.createElement("button", { type: "button", className: "shogun-submit-button", onClick: handleZkProofLogin, disabled: loading || !zkTrapdoor.trim() }, loading ? "Processing..." : "Login Anonymously"),
1377
- React.createElement("div", { className: "shogun-form-footer" },
1378
- React.createElement("button", { className: "shogun-toggle-mode", onClick: () => setAuthView("options"), disabled: loading }, "Back to Login Options"))));
1379
- const renderZkProofSignupResult = () => (React.createElement("div", { className: "shogun-auth-form" },
1380
- React.createElement("h3", null, "ZK-Proof Account Created!"),
1381
- React.createElement("div", { style: {
1382
- backgroundColor: "#fef3c7",
1383
- padding: "12px",
1384
- borderRadius: "8px",
1385
- marginBottom: "16px",
1386
- border: "1px solid #f59e0b",
1387
- } },
1388
- React.createElement("p", { style: {
1389
- fontSize: "14px",
1390
- color: "#92400e",
1391
- margin: "0",
1392
- fontWeight: "500",
1393
- } }, "\u26A0\uFE0F Important: Save Your Trapdoor"),
1394
- React.createElement("p", { style: { fontSize: "13px", color: "#a16207", margin: "4px 0 0 0" } }, "This trapdoor lets you restore your anonymous identity on new devices. Store it securely and never share it.")),
1395
- React.createElement("div", { className: "shogun-form-group" },
1396
- React.createElement("label", null, "Your Trapdoor (Recovery Phrase):"),
1397
- React.createElement("textarea", { value: zkSignupTrapdoor, readOnly: true, rows: 4, style: {
1398
- fontFamily: "monospace",
1399
- fontSize: "12px",
1400
- width: "100%",
1401
- padding: "8px",
1402
- border: "2px solid #f59e0b",
1403
- borderRadius: "4px",
1404
- backgroundColor: "#fffbeb",
1405
- } }),
1406
- React.createElement("button", { type: "button", className: "shogun-submit-button", style: { marginTop: "8px" }, onClick: async () => {
1407
- if (!zkSignupTrapdoor) {
1408
- return;
1409
- }
1410
- try {
1411
- if (navigator.clipboard) {
1412
- await navigator.clipboard.writeText(zkSignupTrapdoor);
1413
- setShowZkTrapdoorCopySuccess(true);
1414
- setTimeout(() => setShowZkTrapdoorCopySuccess(false), 3000);
1415
- }
1416
- }
1417
- catch (copyError) {
1418
- console.warn("Failed to copy trapdoor:", copyError);
1419
- }
1420
- }, disabled: !zkSignupTrapdoor }, "Copy Trapdoor"),
1421
- showZkTrapdoorCopySuccess && (React.createElement("p", { style: {
1422
- color: "#047857",
1423
- fontSize: "12px",
1424
- marginTop: "6px",
1425
- } }, "Trapdoor copied to clipboard!"))),
1426
- React.createElement("div", { className: "shogun-form-footer" },
1427
- React.createElement("button", { type: "button", className: "shogun-submit-button", onClick: finalizeZkProofSignup }, "I Saved My Trapdoor"))));
1428
1128
  const renderWebauthnSignupResult = () => (React.createElement("div", { className: "shogun-auth-form" },
1429
1129
  React.createElement("h3", null, "WebAuthn Account Created!"),
1430
1130
  React.createElement("div", { style: {
@@ -1470,7 +1170,7 @@ export const ShogunButton = (() => {
1470
1170
  border: "1px solid #22c55e",
1471
1171
  textAlign: "center",
1472
1172
  } }, "\u2705 You're now logged in with WebAuthn!"),
1473
- React.createElement("button", { type: "button", className: "shogun-submit-button", style: { marginTop: "16px" }, onClick: finalizeZkProofSignup }, "Close and Start Using App")));
1173
+ React.createElement("button", { type: "button", className: "shogun-submit-button", style: { marginTop: "16px" }, onClick: finalizeSignup }, "Close and Start Using App")));
1474
1174
  const renderChallengeForm = () => (React.createElement("div", { className: "shogun-auth-form" },
1475
1175
  React.createElement("div", { className: "shogun-form-group" },
1476
1176
  React.createElement("label", { htmlFor: "challenge-username" },
@@ -1562,23 +1262,17 @@ export const ShogunButton = (() => {
1562
1262
  modalIsOpen && (React.createElement("div", { className: "shogun-modal-overlay", onClick: closeModal },
1563
1263
  React.createElement("div", { className: "shogun-modal", onClick: (e) => e.stopPropagation() },
1564
1264
  React.createElement("div", { className: "shogun-modal-header" },
1565
- React.createElement("h2", null, authView === "recover"
1566
- ? "Recover Password"
1567
- : authView === "showHint"
1568
- ? "Password Hint"
1569
- : authView === "export"
1570
- ? "Export Gun Pair"
1571
- : authView === "import"
1572
- ? "Import Gun Pair"
1573
- : authView === "webauthn-username"
1574
- ? "WebAuthn"
1575
- : authView === "zkproof-login"
1576
- ? "ZK-Proof Login"
1577
- : authView === "seed-login"
1578
- ? "Login with Seed"
1579
- : formMode === "login"
1580
- ? "Login"
1581
- : "Sign Up"),
1265
+ React.createElement("h2", null, authView === "export"
1266
+ ? "Export Gun Pair"
1267
+ : authView === "import"
1268
+ ? "Import Gun Pair"
1269
+ : authView === "webauthn-username"
1270
+ ? "WebAuthn"
1271
+ : authView === "seed-login"
1272
+ ? "Login with Seed"
1273
+ : formMode === "login"
1274
+ ? "Login"
1275
+ : "Sign Up"),
1582
1276
  React.createElement("button", { className: "shogun-close-button", onClick: closeModal, "aria-label": "Close" },
1583
1277
  React.createElement(CloseIcon, null))),
1584
1278
  React.createElement("div", { className: "shogun-modal-content" },
@@ -1593,8 +1287,6 @@ export const ShogunButton = (() => {
1593
1287
  authView === "password" && (React.createElement(React.Fragment, null,
1594
1288
  React.createElement("button", { className: "shogun-back-button", onClick: () => setAuthView("options") }, "\u2190 Back"),
1595
1289
  renderPasswordForm())),
1596
- authView === "recover" && renderRecoveryForm(),
1597
- authView === "showHint" && renderHint(),
1598
1290
  authView === "export" && renderExportForm(),
1599
1291
  authView === "import" && renderImportForm(),
1600
1292
  authView === "webauthn-username" &&
@@ -1603,11 +1295,7 @@ export const ShogunButton = (() => {
1603
1295
  renderWebauthnRecoveryForm(),
1604
1296
  authView === "webauthn-signup-result" &&
1605
1297
  renderWebauthnSignupResult(),
1606
- authView === "zkproof-login" && renderZkProofLoginForm(),
1607
- authView === "zkproof-signup-result" &&
1608
- renderZkProofSignupResult(),
1609
- authView === "challenge-username" &&
1610
- renderChallengeForm()))))));
1298
+ authView === "challenge-username" && renderChallengeForm()))))));
1611
1299
  };
1612
1300
  Button.displayName = "ShogunButton";
1613
1301
  return Object.assign(Button, {