shogun-button-react 1.3.13 → 1.3.14

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/README.md CHANGED
@@ -27,48 +27,35 @@ yarn add shogun-button-react
27
27
 
28
28
  ```tsx
29
29
  import React from "react";
30
- import {
31
- ShogunButton,
32
- ShogunButtonProvider,
33
- shogunConnector,
34
- } from "shogun-button-react";
30
+ import { ShogunButton, ShogunButtonProvider, shogunConnector } from "shogun-button-react";
35
31
  import "shogun-button-react/styles.css";
36
32
 
37
33
  function App() {
38
- const { sdk, options } = shogunConnector({
34
+ const { core, options } = shogunConnector({
39
35
  appName: "My Awesome App",
40
- appDescription: "A decentralized application with Shogun authentication",
41
- appUrl: "https://myapp.com",
42
- appIcon: "https://myapp.com/icon.png",
43
36
  // Enable specific authentication methods
44
37
  showMetamask: true,
45
38
  showWebauthn: true,
46
39
  showNostr: true,
47
40
  showOauth: true,
41
+ // Optional peers
42
+ peers: [
43
+ "https://gun-manhattan.herokuapp.com/gun"
44
+ ],
48
45
  });
49
46
 
50
47
  return (
51
48
  <ShogunButtonProvider
52
- sdk={sdk}
49
+ core={core}
53
50
  options={options}
54
51
  onLoginSuccess={(data) => {
55
- console.log("🎉 Login successful!", data);
56
- // Handle successful login
57
- // data.userPub - User's public key
58
- // data.username - Display name
59
- // data.authMethod - Authentication method used
52
+ console.log("Login successful!", data);
60
53
  }}
61
54
  onSignupSuccess={(data) => {
62
- console.log("🎊 Account created successfully!", data);
63
- // Handle successful account creation
55
+ console.log("Account created successfully!", data);
64
56
  }}
65
57
  onError={(error) => {
66
- console.error("Authentication error:", error);
67
- // Handle authentication errors
68
- }}
69
- onLogout={() => {
70
- console.log("👋 User logged out");
71
- // Handle logout events
58
+ console.error("Authentication error:", error);
72
59
  }}
73
60
  >
74
61
  <div className="app">
@@ -76,9 +63,7 @@ function App() {
76
63
  <h1>Welcome to My Awesome App</h1>
77
64
  <ShogunButton />
78
65
  </header>
79
- <main>
80
- {/* Your app content */}
81
- </main>
66
+ <main>{/* Your app content */}</main>
82
67
  </div>
83
68
  </ShogunButtonProvider>
84
69
  );
@@ -92,47 +77,35 @@ export default App;
92
77
  ### Custom Authentication Options
93
78
 
94
79
  ```tsx
95
- const { sdk, options } = shogunConnector({
80
+ const { core, options } = shogunConnector({
96
81
  appName: "My App",
97
-
98
- // Customize which authentication methods to show
99
- showMetamask: true, // Enable MetaMask login
100
- showWebauthn: true, // Enable WebAuthn (biometric/security keys)
101
- showNostr: true, // Enable Nostr wallet connection
102
- showOauth: true, // Enable OAuth providers
103
-
82
+
83
+ // Toggle authentication methods in the UI
84
+ showMetamask: true,
85
+ showWebauthn: true,
86
+ showNostr: true,
87
+ showOauth: true,
88
+
104
89
  // Network configuration
105
90
  peers: [
106
- "https://gun-manhattan.herokuapp.com/gun",
107
- "https://gun-us.herokuapp.com/gun"
91
+ "https://gun-manhattan.herokuapp.com/gun"
108
92
  ],
109
-
110
- // OAuth provider configuration
93
+
94
+ // OAuth provider configuration (optional)
111
95
  oauth: {
112
96
  providers: {
113
97
  google: {
114
98
  clientId: "your-google-client-id",
115
- clientSecret: "your-google-client-secret",
116
- redirectUri: "https://myapp.com/auth/callback"
117
- },
118
- github: {
119
- clientId: "your-github-client-id",
120
99
  redirectUri: "https://myapp.com/auth/callback"
121
100
  }
122
101
  }
123
102
  },
124
-
125
- // Advanced plugin configuration
103
+
104
+ // Gun Advanced Plugin configuration
126
105
  enableGunDebug: true,
127
106
  enableConnectionMonitoring: true,
128
107
  defaultPageSize: 20,
129
108
  connectionTimeout: 10000,
130
-
131
- // Logging configuration
132
- logging: {
133
- enabled: true,
134
- level: "info" // "error" | "warning" | "info" | "debug"
135
- }
136
109
  });
137
110
  ```
138
111
 
@@ -146,12 +119,11 @@ The provider component that supplies Shogun context to your application.
146
119
 
147
120
  | Name | Type | Description | Required |
148
121
  |------|------|-------------|----------|
149
- | `sdk` | `ShogunCore` | Shogun SDK instance created by `shogunConnector` | ✅ |
122
+ | `core` | `ShogunCore` | Shogun SDK instance created by `shogunConnector` | ✅ |
150
123
  | `options` | `ShogunConnectorOptions` | Configuration options | ✅ |
151
124
  | `onLoginSuccess` | `(data: AuthData) => void` | Callback fired on successful login | ❌ |
152
125
  | `onSignupSuccess` | `(data: AuthData) => void` | Callback fired on successful signup | ❌ |
153
126
  | `onError` | `(error: string) => void` | Callback fired when an error occurs | ❌ |
154
- | `onLogout` | `() => void` | Callback fired when user logs out | ❌ |
155
127
 
156
128
  #### AuthData Interface
157
129
 
@@ -189,26 +161,26 @@ function UserProfile() {
189
161
  isLoggedIn,
190
162
  userPub,
191
163
  username,
192
-
164
+
193
165
  // Authentication methods
194
166
  login,
195
167
  signUp,
196
168
  logout,
197
-
169
+
198
170
  // Plugin management
199
171
  hasPlugin,
200
172
  getPlugin,
201
-
173
+
202
174
  // Account management
203
175
  exportGunPair,
204
176
  importGunPair,
205
-
177
+
206
178
  // Data operations
207
179
  observe,
208
180
  put,
209
181
  get,
210
182
  remove,
211
-
183
+
212
184
  // Advanced Gun hooks
213
185
  useGunState,
214
186
  useGunCollection,
@@ -302,12 +274,8 @@ function UserProfile() {
302
274
  </div>
303
275
 
304
276
  <div className="actions">
305
- <button onClick={handleExportAccount}>
306
- 🔒 Export Account
307
- </button>
308
- <button onClick={logout}>
309
- 🚪 Logout
310
- </button>
277
+ <button onClick={handleExportAccount}>Export Account</button>
278
+ <button onClick={logout}>Logout</button>
311
279
  </div>
312
280
  </div>
313
281
  );
@@ -509,29 +477,20 @@ Customize the appearance using CSS variables:
509
477
  interface ShogunConnectorOptions {
510
478
  // App information
511
479
  appName: string;
512
- appDescription?: string;
513
- appUrl?: string;
514
- appIcon?: string;
515
-
480
+
516
481
  // Feature toggles
517
482
  showMetamask?: boolean;
518
483
  showWebauthn?: boolean;
519
484
  showNostr?: boolean;
520
485
  showOauth?: boolean;
521
486
  darkMode?: boolean;
522
-
487
+
523
488
  // Network configuration
524
- websocketSecure?: boolean;
525
- providerUrl?: string | null;
526
489
  peers?: string[];
527
490
  authToken?: string;
528
491
  gunInstance?: IGunInstance<any>;
529
-
530
- // Advanced options
531
- logging?: {
532
- enabled: boolean;
533
- level: "error" | "warning" | "info" | "debug";
534
- };
492
+
493
+ // Timeouts and provider configs
535
494
  timeouts?: {
536
495
  login?: number;
537
496
  signup?: number;
@@ -540,11 +499,11 @@ interface ShogunConnectorOptions {
540
499
  oauth?: {
541
500
  providers: Record<string, {
542
501
  clientId: string;
543
- clientSecret?: string;
544
502
  redirectUri?: string;
545
- }>
503
+ clientSecret?: string;
504
+ }>;
546
505
  };
547
-
506
+
548
507
  // Gun Advanced Plugin configuration
549
508
  enableGunDebug?: boolean;
550
509
  enableConnectionMonitoring?: boolean;
@@ -558,8 +517,10 @@ interface ShogunConnectorOptions {
558
517
 
559
518
  ```typescript
560
519
  interface ShogunConnectorResult {
561
- sdk: ShogunCore;
520
+ core: ShogunCore;
562
521
  options: ShogunConnectorOptions;
522
+ setProvider: (provider: any) => boolean;
523
+ getCurrentProviderUrl: () => string | null;
563
524
  registerPlugin: (plugin: any) => boolean;
564
525
  hasPlugin: (name: string) => boolean;
565
526
  gunPlugin: GunAdvancedPlugin;
@@ -2,7 +2,6 @@ import React from "react";
2
2
  import { ShogunCore } from "shogun-core";
3
3
  import { Observable } from "rxjs";
4
4
  import { GunAdvancedPlugin } from "../plugins/GunAdvancedPlugin";
5
- import "../types/index.js";
6
5
  import "../styles/index.css";
7
6
  type ShogunContextType = {
8
7
  core: ShogunCore | null;
@@ -1,7 +1,6 @@
1
1
  import React, { useContext, useState, createContext, useEffect, useRef, } from "react";
2
2
  import { Observable } from "rxjs";
3
3
  import { GunAdvancedPlugin } from "../plugins/GunAdvancedPlugin";
4
- import "../types/index.js"; // Import type file to extend definitions
5
4
  import "../styles/index.css";
6
5
  // Default context
7
6
  const defaultShogunContext = {
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.3.13",
4
+ "version": "1.3.14",
5
5
  "files": [
6
6
  "dist",
7
7
  "src/styles/index.css"