shogun-button-react 1.5.35 → 1.5.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,13 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 1.5.36
4
+
5
+ ### 🔧 Improvements
6
+
7
+ - Align peer/internal dependency to `shogun-core@^1.7.0` to leverage official `loginWithPair()` and `exportPair()` APIs where available.
8
+ - Hardened imports by removing explicit `.js` extensions in TypeScript sources for better resolver compatibility.
9
+
10
+ ### 🐛 Fixes
11
+
12
+ - Avoid double JSON encoding when exporting pair from sessionStorage fallback.
13
+
3
14
  ## Version 1.3.4 (Latest)
4
15
 
5
16
  ### 🐛 Bug Fixes
17
+
6
18
  - **Export Gun Pair Fix**: Fixed issue where "Export Pair" option was not accessible from user dropdown - now works correctly without requiring disconnect
7
19
  - **Modal Logic Improvement**: Enhanced modal rendering logic to allow export functionality when user is already authenticated
8
20
  - **UX Enhancement**: Improved back button behavior in export modal - now properly closes modal when user is logged in instead of showing unnecessary auth options
9
21
 
10
22
  ### 🔧 Technical Changes
23
+
11
24
  - Modified component render logic to show modal even when user is logged in
12
25
  - Improved export form navigation for better user experience
13
26
  - Reordered dropdown menu items for better flow (Export Pair before Disconnect)
@@ -15,11 +28,13 @@
15
28
  ## Version 1.3.3
16
29
 
17
30
  ### ✨ New Features
31
+
18
32
  - **Import Gun Pair Login**: Aggiunta possibilità di effettuare login tramite importazione di un Gun pair esistente
19
33
  - **Export Gun Pair**: Funzionalità per esportare il proprio Gun pair con opzione di crittografia tramite password
20
34
  - **Improved UX**: Migliorata l'interfaccia utente con feedback visivi e messaggi informativi
21
35
 
22
36
  ### 🔧 Improvements
37
+
23
38
  - **Navigation Fix**: Il toggle "Don't have account? Sign up" ora porta alla selezione dei metodi di autenticazione invece che direttamente al form password
24
39
  - **Visual Feedback**: Sostituiti gli alert con feedback visivi eleganti per export/import
25
40
  - **Better Icons**: Aggiunte icone SVG personalizzate per import/export
@@ -27,12 +42,14 @@
27
42
  - **Enhanced Security**: Messaggi informativi per guidare l'utente nell'uso sicuro delle funzionalità
28
43
 
29
44
  ### 🛠 Technical Changes
45
+
30
46
  - Rimosso l'uso del metodo `on` non disponibile in ShogunCore
31
47
  - Definiti tipi locali per `AuthResult` per compatibilità
32
48
  - Migliorata gestione degli stati nel provider
33
49
  - Aggiunto reset completo degli stati quando si chiude il modal
34
50
 
35
51
  ### 🎨 UI/UX Enhancements
52
+
36
53
  - Box informativi colorati per import/export
37
54
  - Feedback di successo con timer automatico
38
55
  - Indicatori di caricamento migliorati
@@ -41,6 +58,7 @@
41
58
  ## Version 1.3.2
42
59
 
43
60
  ### Features
61
+
44
62
  - Basic Gun pair export/import functionality
45
63
  - Multi-authentication support (Password, MetaMask, WebAuthn, Nostr, OAuth)
46
64
  - Dark mode support
@@ -49,6 +67,7 @@
49
67
  ## Version 1.3.1
50
68
 
51
69
  ### Features
70
+
52
71
  - Initial release
53
72
  - Basic authentication flow
54
- - Provider integration
73
+ - Provider integration
@@ -112,22 +112,28 @@ export function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, o
112
112
  throw new Error("Invalid pair data provided");
113
113
  }
114
114
  console.log(`🔧 Pair login with pub: ${(_a = pair.pub) === null || _a === void 0 ? void 0 : _a.slice(0, 8)}...`);
115
- result = await new Promise((resolve, reject) => {
116
- sdk.gun.user().auth(pair, (ack) => {
117
- if (ack.err) {
118
- reject(new Error(`Pair authentication failed: ${ack.err}`));
119
- return;
120
- }
121
- const pub = ack.pub || pair.pub;
122
- const alias = ack.alias || `user_${pub === null || pub === void 0 ? void 0 : pub.substring(0, 8)}`;
123
- resolve({
124
- success: true,
125
- userPub: pub,
126
- alias: alias,
127
- method: "pair",
115
+ // Prefer official API from shogun-core when available
116
+ if (typeof sdk.loginWithPair === "function") {
117
+ result = await sdk.loginWithPair(pair);
118
+ }
119
+ else {
120
+ result = await new Promise((resolve, reject) => {
121
+ sdk.gun.user().auth(pair, (ack) => {
122
+ if (ack.err) {
123
+ reject(new Error(`Pair authentication failed: ${ack.err}`));
124
+ return;
125
+ }
126
+ const pub = ack.pub || pair.pub;
127
+ const alias = ack.alias || `user_${pub === null || pub === void 0 ? void 0 : pub.substring(0, 8)}`;
128
+ resolve({
129
+ success: true,
130
+ userPub: pub,
131
+ alias: alias,
132
+ method: "pair",
133
+ });
128
134
  });
129
135
  });
130
- });
136
+ }
131
137
  username = result.alias;
132
138
  authMethod = "pair";
133
139
  break;
@@ -351,11 +357,22 @@ export function ShogunButtonProvider({ children, sdk, options, onLoginSuccess, o
351
357
  throw new Error("User not authenticated");
352
358
  }
353
359
  try {
354
- const pair = sessionStorage.getItem("gun/pair") || sessionStorage.getItem("pair");
355
- if (!pair) {
360
+ // Prefer SDK export if available, fallback to storage
361
+ let pairJson = null;
362
+ if (typeof sdk.exportPair === "function") {
363
+ pairJson = sdk.exportPair();
364
+ }
365
+ else {
366
+ const stored = sessionStorage.getItem("gun/pair") ||
367
+ sessionStorage.getItem("pair") ||
368
+ null;
369
+ // Stored value is already a JSON stringified pair; don't double-encode
370
+ pairJson = stored;
371
+ }
372
+ if (!pairJson) {
356
373
  throw new Error("No Gun pair available for current user");
357
374
  }
358
- let pairData = JSON.stringify(pair);
375
+ let pairData = pairJson;
359
376
  // If password provided, encrypt the pair
360
377
  if (password && password.trim()) {
361
378
  // Use Gun's SEA for encryption if available
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { ShogunButton, ShogunButtonProvider, useShogun } from './components/ShogunButton.js';
2
- import { ShogunConnectorOptions, ShogunConnectorResult } from './types/connector-options.js';
3
- import { shogunConnector } from './connector.js';
1
+ import { ShogunButton, ShogunButtonProvider, useShogun } from "./components/ShogunButton";
2
+ import { ShogunConnectorOptions, ShogunConnectorResult } from "./types/connector-options";
3
+ import { shogunConnector } from "./connector";
4
4
  export { ShogunButton, ShogunButtonProvider, useShogun };
5
5
  export { shogunConnector };
6
6
  export { ShogunConnectorOptions, ShogunConnectorResult };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { ShogunButton, ShogunButtonProvider, useShogun } from './components/ShogunButton.js';
2
- import { shogunConnector } from './connector.js';
1
+ import { ShogunButton, ShogunButtonProvider, useShogun, } from "./components/ShogunButton";
2
+ import { shogunConnector } from "./connector";
3
3
  // Export components
4
4
  export { ShogunButton, ShogunButtonProvider, useShogun };
5
5
  // Export connector function
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "shogun-button-react",
3
3
  "description": "Shogun connector button",
4
- "version": "1.5.35",
4
+ "version": "1.5.37",
5
5
  "files": [
6
6
  "dist",
7
7
  "src/styles/index.css"
@@ -34,7 +34,7 @@
34
34
  "ethers": "^6.13.5",
35
35
  "prettier": "^3.5.3",
36
36
  "rxjs": "^7.8.1",
37
- "shogun-core": "^1.6.17"
37
+ "shogun-core": "^1.7.1"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "react": "^18.0.0",