shogun-core 1.2.4 → 1.2.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.
- package/README.md +108 -44
- package/dist/browser/shogun-core.js +1 -1
- package/dist/browser/shogun-core.js.LICENSE.txt +2 -0
- package/dist/browser/shogun-core.light.js +1 -1
- package/dist/browser/shogun-core.vendors.light.js +1 -1
- package/dist/core.js +9 -7
- package/dist/gundb/derive.js +173 -0
- package/dist/gundb/gun-es/gun-es.js +12 -0
- package/dist/gundb/gun-es/min.js +10 -0
- package/dist/gundb/index.js +23 -3
- package/dist/gundb/instance.js +1089 -0
- package/dist/plugins/nostr/nostrConnector.js +0 -9
- package/dist/plugins/web3/web3ConnectorPlugin.js +43 -57
- package/dist/plugins/webauthn/webauthn.js +0 -18
- package/dist/plugins/webauthn/webauthnPlugin.js +0 -18
- package/dist/types/core.d.ts +4 -2
- package/dist/types/gundb/derive.d.ts +6 -0
- package/dist/types/gundb/gun-es/gun-es.d.ts +8 -0
- package/dist/types/gundb/gun-es/min.d.ts +3 -0
- package/dist/types/gundb/index.d.ts +5 -1
- package/dist/types/gundb/{gun.d.ts → instance.d.ts} +62 -3
- package/dist/types/plugins/nostr/nostrConnector.d.ts +0 -5
- package/dist/types/plugins/web3/web3ConnectorPlugin.d.ts +7 -17
- package/dist/types/plugins/webauthn/webauthn.d.ts +0 -4
- package/dist/types/plugins/webauthn/webauthnPlugin.d.ts +0 -10
- package/dist/types/types/shogun.d.ts +1 -4
- package/dist/types/utils/errorHandler.d.ts +25 -31
- package/dist/utils/errorHandler.js +37 -37
- package/package.json +2 -1
- package/dist/gundb/gun.js +0 -677
package/README.md
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
# Shogun Core 📦
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/shogun-core)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
[](https://www.typescriptlang.org/)
|
|
6
6
|
|
|
7
7
|
## Overview
|
|
8
8
|
|
|
9
|
-
Shogun
|
|
9
|
+
Shogun Core is a comprehensive SDK for building decentralized applications (dApps) that simplifies authentication, wallet management, and decentralized data storage. It combines GunDB's peer-to-peer networking with modern authentication standards and blockchain integration to provide a secure, user-friendly foundation for Web3 applications.
|
|
10
10
|
|
|
11
11
|
## Key Features
|
|
12
12
|
|
|
13
|
-
- **[Authentication](wiki/core.md#authentication)**:
|
|
14
|
-
- **[Storage](wiki/gundb.md)**:
|
|
15
|
-
- **[Reactive Data](wiki/gundb.md#reactive-programming-with-rxjs)**: RxJS integration for real-time
|
|
16
|
-
- **[Security](wiki/core.md)**: End-to-end encryption and modern
|
|
13
|
+
- **[Multi-Method Authentication](wiki/core.md#authentication)**: Support for traditional passwords, WebAuthn biometrics, Ethereum wallets, and Nostr/Bitcoin protocols
|
|
14
|
+
- **[Decentralized Storage](wiki/gundb.md)**: Built on GunDB with offline resilience, real-time sync, and peer-to-peer networking
|
|
15
|
+
- **[Reactive Data Flows](wiki/gundb.md#reactive-programming-with-rxjs)**: RxJS integration for building responsive, real-time user interfaces
|
|
16
|
+
- **[Enterprise Security](wiki/core.md#security)**: End-to-end encryption, secure key management, and modern cryptographic standards
|
|
17
|
+
- **[Plugin Architecture](wiki/core.md#plugin-system)**: Extensible system for adding custom authentication methods and functionality
|
|
18
|
+
- **[Smart Contract Integration](wiki/contracts.md)**: Tools for interacting with Shogun Protocol contracts on Ethereum
|
|
17
19
|
|
|
18
20
|
## Core Components
|
|
19
21
|
|
|
20
|
-
- **[Core SDK](wiki/core.md)**: Main SDK entry point and
|
|
21
|
-
- **[GunDB Integration](wiki/gundb.md)**: Enhanced wrapper around GunDB with
|
|
22
|
-
- **[WebAuthn](wiki/webauthn.md)**: Passwordless authentication with biometrics and security keys
|
|
23
|
-
- **[Web3](wiki/web3.md)**: Ethereum wallet integration and authentication
|
|
24
|
-
- **[Nostr](wiki/nostr.md)**: Bitcoin and Nostr protocol integration
|
|
22
|
+
- **[Core SDK](wiki/core.md)**: Main SDK entry point, configuration, and plugin management
|
|
23
|
+
- **[GunDB Integration](wiki/gundb.md)**: Enhanced wrapper around GunDB with direct authentication and RxJS support
|
|
24
|
+
- **[WebAuthn Plugin](wiki/webauthn.md)**: Passwordless authentication with biometrics and security keys
|
|
25
|
+
- **[Web3 Plugin](wiki/web3.md)**: Ethereum wallet integration and blockchain authentication
|
|
26
|
+
- **[Nostr Plugin](wiki/nostr.md)**: Bitcoin and Nostr protocol integration for decentralized identity
|
|
25
27
|
- **[Contracts SDK](wiki/contracts.md)**: Tools for interacting with Shogun Protocol smart contracts
|
|
26
28
|
|
|
27
|
-
##
|
|
29
|
+
## External Plugins
|
|
28
30
|
|
|
29
31
|
For extended functionality, install these separate plugins:
|
|
30
32
|
|
|
@@ -38,7 +40,7 @@ npm install shogun-core
|
|
|
38
40
|
# or
|
|
39
41
|
yarn add shogun-core
|
|
40
42
|
|
|
41
|
-
# Optional plugins
|
|
43
|
+
# Optional external plugins
|
|
42
44
|
npm install @shogun/bip44 @shogun/stealth-address
|
|
43
45
|
```
|
|
44
46
|
|
|
@@ -47,73 +49,135 @@ npm install @shogun/bip44 @shogun/stealth-address
|
|
|
47
49
|
```typescript
|
|
48
50
|
import { ShogunCore } from "shogun-core";
|
|
49
51
|
|
|
50
|
-
// Initialize
|
|
52
|
+
// Initialize Shogun Core
|
|
51
53
|
const shogun = new ShogunCore({
|
|
52
54
|
peers: ["https://your-gun-peer.com/gun"],
|
|
53
|
-
scope: "app
|
|
55
|
+
scope: "my-app",
|
|
54
56
|
|
|
55
|
-
// Enable
|
|
57
|
+
// Enable built-in authentication plugins
|
|
56
58
|
webauthn: { enabled: true },
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
web3: { enabled: true },
|
|
60
|
+
nostr: { enabled: true },
|
|
61
|
+
|
|
62
|
+
// Configure logging
|
|
63
|
+
logging: {
|
|
64
|
+
enabled: true,
|
|
65
|
+
level: "info"
|
|
66
|
+
}
|
|
59
67
|
});
|
|
60
68
|
|
|
61
|
-
//
|
|
69
|
+
// Basic authentication
|
|
62
70
|
const loginResult = await shogun.login("username", "password");
|
|
71
|
+
if (loginResult.success) {
|
|
72
|
+
console.log("User logged in:", loginResult.userPub);
|
|
73
|
+
}
|
|
63
74
|
|
|
64
|
-
// Access
|
|
75
|
+
// Access built-in plugins
|
|
65
76
|
const webauthnPlugin = shogun.getPlugin("webauthn");
|
|
66
77
|
const web3Plugin = shogun.getPlugin("web3");
|
|
67
78
|
const nostrPlugin = shogun.getPlugin("nostr");
|
|
68
79
|
|
|
69
|
-
//
|
|
80
|
+
// Work with decentralized data
|
|
81
|
+
const gundb = shogun.gundb;
|
|
82
|
+
await gundb.put("user/profile", { name: "John Doe", status: "online" });
|
|
83
|
+
const profile = await gundb.get("user/profile");
|
|
84
|
+
|
|
85
|
+
// Reactive data with RxJS
|
|
86
|
+
shogun.rx.observe("user/profile").subscribe(profile => {
|
|
87
|
+
console.log("Profile updated:", profile);
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Advanced Usage
|
|
92
|
+
|
|
93
|
+
### Custom Plugin Registration
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
// Register external plugins
|
|
70
97
|
import { HDWalletPlugin } from "@shogun/bip44";
|
|
71
98
|
import { StealthPlugin } from "@shogun/stealth-address";
|
|
72
99
|
|
|
73
|
-
shogun.
|
|
74
|
-
shogun.
|
|
100
|
+
shogun.register(new HDWalletPlugin());
|
|
101
|
+
shogun.register(new StealthPlugin());
|
|
75
102
|
|
|
76
103
|
const bip44Plugin = shogun.getPlugin("bip44");
|
|
77
104
|
const stealthPlugin = shogun.getPlugin("stealth");
|
|
78
105
|
```
|
|
79
106
|
|
|
107
|
+
### Event Handling
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
// Listen for authentication events
|
|
111
|
+
shogun.on("auth:login", (data) => {
|
|
112
|
+
console.log("User logged in:", data.userPub);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
shogun.on("auth:logout", () => {
|
|
116
|
+
console.log("User logged out");
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
shogun.on("error", (error) => {
|
|
120
|
+
console.error("SDK error:", error);
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
80
124
|
## Documentation
|
|
81
125
|
|
|
82
|
-
For detailed documentation on each component
|
|
126
|
+
For detailed documentation on each component:
|
|
127
|
+
|
|
128
|
+
### Core Documentation
|
|
129
|
+
- **[Core SDK API](wiki/core.md)** - Main SDK initialization, configuration, and authentication
|
|
130
|
+
- **[GunDB Integration](wiki/gundb.md)** - Decentralized database operations and reactive data
|
|
83
131
|
|
|
84
|
-
|
|
85
|
-
- **[
|
|
86
|
-
- **[
|
|
87
|
-
- **[
|
|
88
|
-
- **[
|
|
89
|
-
- **[Contracts SDK](wiki/contracts.md)**
|
|
132
|
+
### Plugin Documentation
|
|
133
|
+
- **[WebAuthn Plugin](wiki/webauthn.md)** - Biometric and security key authentication
|
|
134
|
+
- **[Web3 Plugin](wiki/web3.md)** - Ethereum wallet integration
|
|
135
|
+
- **[Nostr Plugin](wiki/nostr.md)** - Bitcoin and Nostr protocol support
|
|
136
|
+
- **[Smart Contracts](wiki/contracts.md)** - Shogun Protocol contract interactions
|
|
90
137
|
|
|
91
|
-
External
|
|
92
|
-
- **[BIP44 HD Wallet Plugin](https://github.com/scobru/shogun-BIP44)**
|
|
93
|
-
- **[Stealth Address Plugin](https://github.com/scobru/shogun-stealth-address)**
|
|
138
|
+
### External Plugins
|
|
139
|
+
- **[BIP44 HD Wallet Plugin](https://github.com/scobru/shogun-BIP44)** - Hierarchical deterministic wallet management
|
|
140
|
+
- **[Stealth Address Plugin](https://github.com/scobru/shogun-stealth-address)** - Privacy-enhancing address generation
|
|
94
141
|
|
|
95
|
-
|
|
142
|
+
### Technical Documentation
|
|
143
|
+
Full API documentation is available at [shogun-core-docs.vercel.app](https://shogun-core-docs.vercel.app/).
|
|
96
144
|
|
|
97
145
|
## Use Cases
|
|
98
146
|
|
|
99
|
-
Shogun is
|
|
147
|
+
Shogun Core is ideal for building:
|
|
100
148
|
|
|
101
|
-
- **
|
|
102
|
-
- **
|
|
103
|
-
- **
|
|
104
|
-
- **
|
|
105
|
-
- **
|
|
149
|
+
- **Decentralized Social Networks**: Chat apps, forums, and social platforms with user-owned data
|
|
150
|
+
- **Web3 Wallets**: Browser-based cryptocurrency wallets with multiple authentication options
|
|
151
|
+
- **Enterprise dApps**: Business applications requiring secure, decentralized data storage
|
|
152
|
+
- **Gaming Platforms**: Real-time multiplayer games with decentralized leaderboards and assets
|
|
153
|
+
- **Privacy-Focused Applications**: Apps requiring anonymous interactions and stealth features
|
|
154
|
+
- **Collaborative Tools**: Real-time document editing, project management, and team coordination
|
|
155
|
+
- **IoT and Edge Computing**: Decentralized device management and data collection
|
|
156
|
+
|
|
157
|
+
## Browser Compatibility
|
|
158
|
+
|
|
159
|
+
Shogun Core supports all modern browsers with:
|
|
160
|
+
- WebAuthn API support (Chrome 67+, Firefox 60+, Safari 14+)
|
|
161
|
+
- WebCrypto API support
|
|
162
|
+
- IndexedDB support
|
|
163
|
+
- WebSocket support for real-time synchronization
|
|
164
|
+
|
|
165
|
+
## Node.js Support
|
|
166
|
+
|
|
167
|
+
Full Node.js support for server-side applications, testing, and automation.
|
|
106
168
|
|
|
107
169
|
## Contributing
|
|
108
170
|
|
|
109
|
-
|
|
171
|
+
We welcome contributions! Please follow our contribution guidelines:
|
|
110
172
|
|
|
111
173
|
1. Fork the repository
|
|
112
|
-
2. Create a branch
|
|
113
|
-
3. Commit your changes (`git commit -m '
|
|
174
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
175
|
+
3. Commit your changes (`git commit -m 'feat: add amazing feature'`)
|
|
114
176
|
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
115
177
|
5. Open a Pull Request
|
|
116
178
|
|
|
179
|
+
Please follow [Conventional Commits](https://conventionalcommits.org/) for commit messages.
|
|
180
|
+
|
|
117
181
|
## License
|
|
118
182
|
|
|
119
|
-
MIT
|
|
183
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|