shogun-button-react 4.3.6 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -4
- package/dist/components/ShogunButton.js +3 -1
- package/dist/connector.js +16 -2
- package/dist/index.js +1 -1
- package/dist/interfaces/connector-options.d.ts +6 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A comprehensive React component library for seamless integration of Shogun authentication into your applications. This library provides a simple yet powerful way to add multi-method authentication, account management, and real-time data synchronization to your React applications.
|
|
4
4
|
|
|
5
|
-
> **Version 4.
|
|
5
|
+
> **Version 4.4.0** - Compatible with shogun-core ^5.0.0
|
|
6
6
|
|
|
7
7
|
## ✨ Features
|
|
8
8
|
|
|
@@ -14,11 +14,13 @@ A comprehensive React component library for seamless integration of Shogun authe
|
|
|
14
14
|
- 🌍 **TypeScript Support** - Full type safety and IntelliSense support
|
|
15
15
|
- 🔌 **Plugin System** - Advanced Gun operations with custom hooks
|
|
16
16
|
- 📊 **Real-time Data** - Reactive data synchronization with RxJS observables
|
|
17
|
+
- ✅ **Robust Foundation** - Built on shogun-core v5.0.0 with 99.86% test coverage
|
|
18
|
+
- 🗄️ **Flexible Storage** - Support for GunDB, SQLite, PostgreSQL, MongoDB via TransportLayer
|
|
17
19
|
|
|
18
20
|
## 📦 Requirements
|
|
19
21
|
|
|
20
22
|
- **React**: ^18.0.0
|
|
21
|
-
- **shogun-core**: ^
|
|
23
|
+
- **shogun-core**: ^5.0.0
|
|
22
24
|
- **Node.js**: ≥18
|
|
23
25
|
|
|
24
26
|
## 🚀 Quick Start
|
|
@@ -104,7 +106,7 @@ const { core, options } = shogunConnector({
|
|
|
104
106
|
showNostr: true,
|
|
105
107
|
showZkProof: true,
|
|
106
108
|
|
|
107
|
-
// Network configuration
|
|
109
|
+
// Network configuration (backward compatible)
|
|
108
110
|
peers: [
|
|
109
111
|
"https://gun-manhattan.herokuapp.com/gun"
|
|
110
112
|
],
|
|
@@ -123,6 +125,51 @@ const { core, options } = shogunConnector({
|
|
|
123
125
|
});
|
|
124
126
|
```
|
|
125
127
|
|
|
128
|
+
### Advanced Transport Layer Configuration (New in v5.0.0)
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
const { core, options } = shogunConnector({
|
|
132
|
+
appName: "My App",
|
|
133
|
+
|
|
134
|
+
// Use new transport layer system
|
|
135
|
+
transport: {
|
|
136
|
+
type: "gun", // or "sqlite", "postgresql", "mongodb", "custom"
|
|
137
|
+
options: {
|
|
138
|
+
peers: ["https://gun-manhattan.herokuapp.com/gun"],
|
|
139
|
+
// Additional transport-specific options
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
// Alternative: Use SQLite for local development
|
|
144
|
+
transport: {
|
|
145
|
+
type: "sqlite",
|
|
146
|
+
options: {
|
|
147
|
+
filename: "./my-app.db",
|
|
148
|
+
// SQLite-specific options
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
// Alternative: Use PostgreSQL for production
|
|
153
|
+
transport: {
|
|
154
|
+
type: "postgresql",
|
|
155
|
+
options: {
|
|
156
|
+
host: "localhost",
|
|
157
|
+
port: 5432,
|
|
158
|
+
database: "myapp",
|
|
159
|
+
username: "user",
|
|
160
|
+
password: "password",
|
|
161
|
+
// PostgreSQL-specific options
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
// Authentication methods
|
|
166
|
+
showMetamask: true,
|
|
167
|
+
showWebauthn: true,
|
|
168
|
+
showNostr: true,
|
|
169
|
+
showZkProof: true,
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
126
173
|
## 🎯 API Reference
|
|
127
174
|
|
|
128
175
|
### ShogunButtonProvider
|
|
@@ -602,10 +649,18 @@ interface ShogunConnectorOptions {
|
|
|
602
649
|
showNostr?: boolean;
|
|
603
650
|
darkMode?: boolean;
|
|
604
651
|
|
|
605
|
-
// Network configuration
|
|
652
|
+
// Network configuration (backward compatible)
|
|
606
653
|
peers?: string[];
|
|
607
654
|
authToken?: string;
|
|
608
655
|
gunInstance?: IGunInstance<any>;
|
|
656
|
+
gunOptions?: any;
|
|
657
|
+
|
|
658
|
+
// Transport layer configuration (new in v5.0.0)
|
|
659
|
+
transport?: {
|
|
660
|
+
type: "gun" | "sqlite" | "postgresql" | "mongodb" | "custom";
|
|
661
|
+
options?: any;
|
|
662
|
+
customTransport?: any;
|
|
663
|
+
};
|
|
609
664
|
|
|
610
665
|
// Timeouts and provider configs
|
|
611
666
|
timeouts?: {
|
|
@@ -194,7 +194,9 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
|
|
|
194
194
|
console.log(`[DEBUG] ShogunButton: core object:`, core);
|
|
195
195
|
console.log(`[DEBUG] ShogunButton: core.signUp exists:`, typeof (core === null || core === void 0 ? void 0 : core.signUp));
|
|
196
196
|
try {
|
|
197
|
+
console.log(`[DEBUG] ShogunButton: About to call core.signUp...`);
|
|
197
198
|
result = await core.signUp(args[0], args[1]);
|
|
199
|
+
console.log(`[DEBUG] ShogunButton: core.signUp completed successfully`);
|
|
198
200
|
console.log(`[DEBUG] ShogunButton: core.signUp result:`, result);
|
|
199
201
|
}
|
|
200
202
|
catch (error) {
|
|
@@ -207,7 +209,7 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
|
|
|
207
209
|
const webauthn = core.getPlugin("webauthn");
|
|
208
210
|
if (!webauthn)
|
|
209
211
|
throw new Error("WebAuthn plugin not available");
|
|
210
|
-
result = await webauthn.signUp(username);
|
|
212
|
+
result = await webauthn.signUp(username, { generateSeedPhrase: true });
|
|
211
213
|
break;
|
|
212
214
|
case "web3":
|
|
213
215
|
const web3 = core.getPlugin("web3");
|
package/dist/connector.js
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import { ShogunCore } from "shogun-core";
|
|
2
2
|
export async function shogunConnector(options) {
|
|
3
|
-
const { gunInstance, gunOptions, appName, timeouts, webauthn, nostr, web3, zkproof, showWebauthn, showNostr, showMetamask, showZkProof, darkMode, enableGunDebug = true, enableConnectionMonitoring = true, defaultPageSize = 20, connectionTimeout = 10000, debounceInterval = 100, ...restOptions } = options;
|
|
3
|
+
const { gunInstance, gunOptions, transport, appName, timeouts, webauthn, nostr, web3, zkproof, showWebauthn, showNostr, showMetamask, showZkProof, darkMode, enableGunDebug = true, enableConnectionMonitoring = true, defaultPageSize = 20, connectionTimeout = 10000, debounceInterval = 100, ...restOptions } = options;
|
|
4
4
|
let core = null;
|
|
5
|
-
|
|
5
|
+
// Priority: transport > gunInstance > gunOptions
|
|
6
|
+
if (transport !== undefined) {
|
|
7
|
+
// Use new transport layer configuration
|
|
8
|
+
core = new ShogunCore({
|
|
9
|
+
transport: transport,
|
|
10
|
+
webauthn,
|
|
11
|
+
nostr,
|
|
12
|
+
web3,
|
|
13
|
+
zkproof,
|
|
14
|
+
timeouts,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
else if (gunInstance !== undefined) {
|
|
18
|
+
// Use existing Gun instance (backward compatibility)
|
|
6
19
|
core = new ShogunCore({
|
|
7
20
|
gunInstance: gunInstance,
|
|
8
21
|
webauthn,
|
|
@@ -13,6 +26,7 @@ export async function shogunConnector(options) {
|
|
|
13
26
|
});
|
|
14
27
|
}
|
|
15
28
|
else {
|
|
29
|
+
// Use Gun options (backward compatibility)
|
|
16
30
|
core = new ShogunCore({
|
|
17
31
|
gunOptions: gunOptions,
|
|
18
32
|
webauthn,
|