shogun-core 3.0.6 → 3.0.7
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 +56 -5
- package/dist/browser/shogun-core.js +48 -3
- package/dist/browser/shogun-core.js.map +1 -1
- package/dist/gundb/db.js +1 -3
- package/dist/gundb/simple-api.js +48 -1
- package/dist/types/gundb/simple-api.d.ts +27 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,12 +34,13 @@ Shogun Core is a comprehensive SDK for building decentralized applications (dApp
|
|
|
34
34
|
- **⭐ NEW: Quick Start Functions**: `quickStart()` and `QuickStart` class for rapid initialization
|
|
35
35
|
- **⭐ NEW: Improved Type System**: Reduced `any` usage with better TypeScript types
|
|
36
36
|
- **⭐ NEW: Configuration Presets**: Pre-built configurations for common use cases
|
|
37
|
+
- **⭐ NEW: Advanced API Features**: Comprehensive plugin management, peer network control, advanced user management, and security systems
|
|
37
38
|
- **Removed Non-Essential Functions**: Eliminated debug/testing functions, rate limiting system, frozen space system, and complex username management
|
|
38
|
-
- **
|
|
39
|
-
- **Streamlined Event System**:
|
|
40
|
-
- **Enhanced Core Focus**: Maintained password hint system
|
|
41
|
-
- **Improved Maintainability**:
|
|
42
|
-
- **Better Performance**:
|
|
39
|
+
- **Enhanced Advanced Features**: Maintained and improved advanced plugin management, peer network management, and user tracking systems
|
|
40
|
+
- **Streamlined Event System**: Enhanced event system with better type safety and comprehensive event handling
|
|
41
|
+
- **Enhanced Core Focus**: Maintained password hint system with security questions and comprehensive user management
|
|
42
|
+
- **Improved Maintainability**: Better organized codebase with clear separation between simple and advanced APIs
|
|
43
|
+
- **Better Performance**: Optimized operations with advanced peer management and user tracking
|
|
43
44
|
|
|
44
45
|
## Recent Updates (v1.7.0)
|
|
45
46
|
|
|
@@ -629,17 +630,54 @@ You can also use Shogun Core directly in the browser by including it from a CDN.
|
|
|
629
630
|
- `signUp(username: string, password: string, email?: string, pair?: ISEAPair | null): Promise<SignUpResult>` - Create new user account
|
|
630
631
|
- `logout(): void` - Logout current user
|
|
631
632
|
- `isLoggedIn(): boolean` - Check if user is authenticated
|
|
633
|
+
- `setAuthMethod(method: AuthMethod): void` - Set authentication method
|
|
634
|
+
- `getAuthMethod(): AuthMethod | undefined` - Get current authentication method
|
|
635
|
+
- `saveCredentials(credentials: any): Promise<void>` - Save user credentials
|
|
632
636
|
|
|
633
637
|
#### Plugin Management
|
|
634
638
|
- `getPlugin<T>(name: string): T | undefined` - Get plugin by name
|
|
635
639
|
- `hasPlugin(name: string): boolean` - Check if plugin exists
|
|
636
640
|
- `register(plugin: ShogunPlugin): void` - Register custom plugin
|
|
637
641
|
- `unregister(pluginName: string): void` - Remove plugin
|
|
642
|
+
- `getPluginsInfo(): Array<{name: string; version: string; category?: PluginCategory; description?: string}>` - Get detailed plugin information
|
|
643
|
+
- `getPluginCount(): number` - Get total number of plugins
|
|
644
|
+
- `getPluginsInitializationStatus(): Record<string, {initialized: boolean; error?: string}>` - Check plugin initialization status
|
|
645
|
+
- `getPluginsByCategory(category: PluginCategory): ShogunPlugin[]` - Get plugins by category
|
|
646
|
+
- `validatePluginSystem(): {...}` - Validate plugin system health
|
|
647
|
+
- `reinitializeFailedPlugins(): {...}` - Reinitialize failed plugins
|
|
648
|
+
- `checkPluginCompatibility(): {...}` - Check plugin compatibility
|
|
649
|
+
- `getPluginSystemDebugInfo(): {...}` - Get comprehensive debug information
|
|
650
|
+
|
|
651
|
+
#### Peer Network Management (Database)
|
|
652
|
+
- `addPeer(peer: string): void` - Add new peer to network
|
|
653
|
+
- `removePeer(peer: string): void` - Remove peer from network
|
|
654
|
+
- `getCurrentPeers(): string[]` - Get currently connected peers
|
|
655
|
+
- `getAllConfiguredPeers(): string[]` - Get all configured peers
|
|
656
|
+
- `getPeerInfo(): {[peer: string]: {connected: boolean; status: string}}` - Get detailed peer information
|
|
657
|
+
- `reconnectToPeer(peer: string): void` - Reconnect to specific peer
|
|
658
|
+
- `resetPeers(newPeers?: string[]): void` - Reset all peers and optionally add new ones
|
|
659
|
+
|
|
660
|
+
#### Advanced User Management (Database)
|
|
661
|
+
- `getUserByAlias(alias: string): Promise<{...}>` - Get user by alias/username
|
|
662
|
+
- `getUserDataByPub(userPub: string): Promise<{...}>` - Get user by public key
|
|
663
|
+
- `getUserPubByEpub(epub: string): Promise<string | null>` - Get user public key by encryption key
|
|
664
|
+
- `getUserAliasByPub(userPub: string): Promise<string | null>` - Get user alias by public key
|
|
665
|
+
- `getAllRegisteredUsers(): Promise<Array<{...}>>` - Get all registered users
|
|
666
|
+
- `updateUserLastSeen(userPub: string): Promise<void>` - Update user's last seen timestamp
|
|
667
|
+
|
|
668
|
+
#### Password Recovery & Security (Database)
|
|
669
|
+
- `setPasswordHintWithSecurity(username: string, password: string, hint: string, securityQuestions: string[], securityAnswers: string[]): Promise<{success: boolean; error?: string}>` - Set up password recovery
|
|
670
|
+
- `forgotPassword(username: string, securityAnswers: string[]): Promise<{success: boolean; hint?: string; error?: string}>` - Recover password
|
|
671
|
+
|
|
672
|
+
#### Error Handling & Debugging
|
|
673
|
+
- `getRecentErrors(count?: number): ShogunError[]` - Get recent errors for debugging
|
|
638
674
|
|
|
639
675
|
#### Event Handling
|
|
640
676
|
- `on<K extends keyof ShogunEventMap>(eventName: K, listener: Function): this` - Subscribe to typed events
|
|
641
677
|
- `off<K extends keyof ShogunEventMap>(eventName: K, listener: Function): this` - Unsubscribe from events
|
|
678
|
+
- `once<K extends keyof ShogunEventMap>(eventName: K, listener: Function): this` - Subscribe to one-time events
|
|
642
679
|
- `emit<K extends keyof ShogunEventMap>(eventName: K, data?: ShogunEventMap[K]): boolean` - Emit custom events
|
|
680
|
+
- `removeAllListeners(eventName?: string | symbol): this` - Remove all event listeners
|
|
643
681
|
|
|
644
682
|
### Configuration Options
|
|
645
683
|
|
|
@@ -777,9 +815,22 @@ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) f
|
|
|
777
815
|
|
|
778
816
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
779
817
|
|
|
818
|
+
## Advanced Features
|
|
819
|
+
|
|
820
|
+
For advanced use cases and comprehensive API coverage, see the [Advanced API Features](./API.md#advanced-api-features) section which includes:
|
|
821
|
+
|
|
822
|
+
- **Advanced Plugin Management**: Plugin health monitoring, compatibility checking, and system validation
|
|
823
|
+
- **Peer Network Management**: Dynamic peer connection management and network monitoring
|
|
824
|
+
- **Advanced User Management**: Comprehensive user lookup, tracking, and metadata management
|
|
825
|
+
- **Password Recovery & Security**: Secure password hint system with security questions
|
|
826
|
+
- **Error Handling & Debugging**: Advanced error tracking and debugging capabilities
|
|
827
|
+
- **Event System**: Complete event handling reference with type safety
|
|
828
|
+
- **Database Lifecycle**: Advanced database initialization and management
|
|
829
|
+
|
|
780
830
|
## Support
|
|
781
831
|
|
|
782
832
|
- 📖 [Documentation](https://shogun-core-docs.vercel.app/)
|
|
833
|
+
- 📚 [Advanced API Reference](./API.md#advanced-api-features)
|
|
783
834
|
- 💬 [Telegram Community](t.me/shogun_eco)
|
|
784
835
|
- 🐛 [Issue Tracker](https://github.com/scobru/shogun-core/issues)
|
|
785
836
|
|
|
@@ -87905,6 +87905,7 @@ class DataBase {
|
|
|
87905
87905
|
this.crypto = gundb_crypto_namespaceObject;
|
|
87906
87906
|
this.sea = (sea_default());
|
|
87907
87907
|
this.node = null;
|
|
87908
|
+
this._rxjs = new RxJS(this.gun);
|
|
87908
87909
|
}
|
|
87909
87910
|
/**
|
|
87910
87911
|
* Initialize the GunInstance asynchronously
|
|
@@ -88367,9 +88368,6 @@ class DataBase {
|
|
|
88367
88368
|
* @returns GunRxJS instance
|
|
88368
88369
|
*/
|
|
88369
88370
|
rx() {
|
|
88370
|
-
if (!this._rxjs) {
|
|
88371
|
-
this._rxjs = new RxJS(this.gun);
|
|
88372
|
-
}
|
|
88373
88371
|
return this._rxjs;
|
|
88374
88372
|
}
|
|
88375
88373
|
/**
|
|
@@ -89700,6 +89698,10 @@ class SimpleGunAPI {
|
|
|
89700
89698
|
return null;
|
|
89701
89699
|
}
|
|
89702
89700
|
}
|
|
89701
|
+
// Get Gun node - returns Gun node for chaining operations like .map()
|
|
89702
|
+
getNode(path) {
|
|
89703
|
+
return this.db.get(path);
|
|
89704
|
+
}
|
|
89703
89705
|
// Simple put - returns success boolean
|
|
89704
89706
|
async put(path, data) {
|
|
89705
89707
|
try {
|
|
@@ -90105,12 +90107,55 @@ class QuickStart {
|
|
|
90105
90107
|
return this.db;
|
|
90106
90108
|
}
|
|
90107
90109
|
}
|
|
90110
|
+
/**
|
|
90111
|
+
* Auto Quick Start helper - creates a simple API with automatic Gun instance creation
|
|
90112
|
+
* No need to pass a Gun instance, it creates one automatically
|
|
90113
|
+
*/
|
|
90114
|
+
class AutoQuickStart {
|
|
90115
|
+
db;
|
|
90116
|
+
simpleAPI;
|
|
90117
|
+
gunInstance;
|
|
90118
|
+
constructor(config) {
|
|
90119
|
+
const gunConfig = {
|
|
90120
|
+
peers: config?.peers || [],
|
|
90121
|
+
...config,
|
|
90122
|
+
};
|
|
90123
|
+
// Remove appScope from gunConfig as it's not a Gun configuration option
|
|
90124
|
+
delete gunConfig.appScope;
|
|
90125
|
+
this.gunInstance = createGun(gunConfig);
|
|
90126
|
+
const appScope = config?.appScope || "shogun";
|
|
90127
|
+
this.db = new DataBase(this.gunInstance, appScope);
|
|
90128
|
+
this.simpleAPI = new SimpleGunAPI(this.db);
|
|
90129
|
+
}
|
|
90130
|
+
// Initialize the database
|
|
90131
|
+
async init() {
|
|
90132
|
+
await this.db.initialize();
|
|
90133
|
+
}
|
|
90134
|
+
// Get the simple API
|
|
90135
|
+
get api() {
|
|
90136
|
+
return this.simpleAPI;
|
|
90137
|
+
}
|
|
90138
|
+
// Get the full database instance for advanced usage
|
|
90139
|
+
get database() {
|
|
90140
|
+
return this.db;
|
|
90141
|
+
}
|
|
90142
|
+
// Get the Gun instance for advanced usage
|
|
90143
|
+
get gun() {
|
|
90144
|
+
return this.gunInstance;
|
|
90145
|
+
}
|
|
90146
|
+
}
|
|
90108
90147
|
/**
|
|
90109
90148
|
* Global helper for quick setup
|
|
90110
90149
|
*/
|
|
90111
90150
|
function quickStart(gunInstance, appScope) {
|
|
90112
90151
|
return new QuickStart(gunInstance, appScope);
|
|
90113
90152
|
}
|
|
90153
|
+
/**
|
|
90154
|
+
* Global helper for auto quick setup - creates Gun instance automatically
|
|
90155
|
+
*/
|
|
90156
|
+
function autoQuickStart(config) {
|
|
90157
|
+
return new AutoQuickStart(config);
|
|
90158
|
+
}
|
|
90114
90159
|
|
|
90115
90160
|
;// ./src/gundb/index.ts
|
|
90116
90161
|
// Export the main class
|