shogun-core 3.0.13 → 3.0.15

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.
Files changed (57) hide show
  1. package/README.md +27 -1
  2. package/dist/browser/shogun-core.js +103157 -84871
  3. package/dist/browser/shogun-core.js.map +1 -1
  4. package/dist/config/simplified-config.js +22 -16
  5. package/dist/core.js +18 -26
  6. package/dist/examples/api-test.js +273 -0
  7. package/dist/examples/simple-api-test.js +89 -0
  8. package/dist/gundb/api.js +126 -189
  9. package/dist/gundb/crypto.js +32 -17
  10. package/dist/gundb/db.js +89 -137
  11. package/dist/gundb/derive.js +20 -17
  12. package/dist/gundb/errors.js +17 -7
  13. package/dist/gundb/index.js +19 -3
  14. package/dist/gundb/rxjs.js +19 -17
  15. package/dist/gundb/types.js +2 -1
  16. package/dist/index.js +43 -12
  17. package/dist/interfaces/common.js +2 -1
  18. package/dist/interfaces/events.js +6 -2
  19. package/dist/interfaces/plugin.js +2 -1
  20. package/dist/interfaces/shogun.js +7 -4
  21. package/dist/managers/AuthManager.js +9 -7
  22. package/dist/managers/CoreInitializer.js +23 -20
  23. package/dist/managers/EventManager.js +7 -4
  24. package/dist/managers/PluginManager.js +6 -3
  25. package/dist/migration-test.js +13 -8
  26. package/dist/plugins/base.js +11 -8
  27. package/dist/plugins/index.js +36 -10
  28. package/dist/plugins/nostr/index.js +20 -4
  29. package/dist/plugins/nostr/nostrConnector.js +42 -36
  30. package/dist/plugins/nostr/nostrConnectorPlugin.js +36 -29
  31. package/dist/plugins/nostr/nostrSigner.js +17 -11
  32. package/dist/plugins/nostr/types.js +2 -1
  33. package/dist/plugins/oauth/index.js +7 -2
  34. package/dist/plugins/oauth/oauthConnector.js +75 -69
  35. package/dist/plugins/oauth/oauthPlugin.js +31 -27
  36. package/dist/plugins/oauth/types.js +2 -1
  37. package/dist/plugins/web3/index.js +20 -4
  38. package/dist/plugins/web3/types.js +2 -1
  39. package/dist/plugins/web3/web3Connector.js +38 -33
  40. package/dist/plugins/web3/web3ConnectorPlugin.js +29 -22
  41. package/dist/plugins/web3/web3Signer.js +24 -18
  42. package/dist/plugins/webauthn/index.js +19 -3
  43. package/dist/plugins/webauthn/types.js +5 -2
  44. package/dist/plugins/webauthn/webauthn.js +30 -25
  45. package/dist/plugins/webauthn/webauthnPlugin.js +21 -14
  46. package/dist/plugins/webauthn/webauthnSigner.js +20 -14
  47. package/dist/storage/storage.js +5 -4
  48. package/dist/types/events.js +8 -2
  49. package/dist/types/examples/api-test.d.ts +12 -0
  50. package/dist/types/examples/simple-api-test.d.ts +5 -0
  51. package/dist/types/gundb/api.d.ts +0 -26
  52. package/dist/types/gundb/db.d.ts +2 -35
  53. package/dist/types/shogun.js +7 -4
  54. package/dist/utils/errorHandler.js +13 -8
  55. package/dist/utils/eventEmitter.js +5 -2
  56. package/dist/utils/validation.js +14 -7
  57. package/package.json +2 -1
package/README.md CHANGED
@@ -45,6 +45,12 @@ Shogun Core is a comprehensive SDK for building decentralized applications (dApp
45
45
  - **Improved Maintainability**: Better organized codebase with clear separation between simple and advanced APIs
46
46
  - **Better Performance**: Optimized operations with advanced peer management and user tracking
47
47
 
48
+ ### ⚠️ **BREAKING CHANGES**
49
+
50
+ - **🚨 REMOVED: Array Functions**: `putUserArray()`, `getUserArray()`, `addToUserArray()`, `removeFromUserArray()`, `updateInUserArray()` have been **REMOVED** due to GunDB compatibility issues
51
+ - **⚠️ DEPRECATED: Global Array Functions**: `putArray()`, `getArray()`, `addToArray()`, `removeFromArray()`, `updateInArray()` are deprecated and show warnings
52
+ - **✅ MIGRATION**: Use **Collections** or **Direct GunDB Operations** instead (see examples below)
53
+
48
54
  ## Recent Updates (v1.7.0)
49
55
 
50
56
  ### ✅ **Type System Fixes**
@@ -217,7 +223,11 @@ const settings = await shogun.api.getSettings();
217
223
  await shogun.api.savePreferences({ theme: 'dark', fontSize: 14 });
218
224
  const preferences = await shogun.api.getPreferences();
219
225
 
220
- // Collections (for structured data)
226
+ // Collections (recommended for structured data)
227
+ // Note: Array functions (putUserArray, getUserArray, etc.) have been removed due to GunDB compatibility issues
228
+ // Use collections or direct GunDB operations instead:
229
+
230
+ // Option 1: Collections (recommended for most use cases)
221
231
  await shogun.api.createCollection('todos', {
222
232
  '1': { text: 'Learn Shogun Core', done: false },
223
233
  '2': { text: 'Build dApp', done: false }
@@ -231,6 +241,12 @@ await shogun.api.addToCollection('todos', '3', {
231
241
  const todos = await shogun.api.getCollection('todos');
232
242
  await shogun.api.removeFromCollection('todos', '2');
233
243
 
244
+ // Option 2: Direct GunDB operations for complex nested data
245
+ await shogun.api.node('users').get('alice').get('todos').get('1').put({
246
+ text: 'Learn Shogun Core',
247
+ done: false
248
+ });
249
+
234
250
  // Utility methods
235
251
  const currentUser = shogun.api.getCurrentUser();
236
252
  const userExists = await shogun.api.userExists('username');
@@ -777,6 +793,16 @@ You can also use Shogun Core directly in the browser by including it from a CDN.
777
793
  - `getCollection(name: string): Promise<Record<string, unknown> | null>` - Get collection
778
794
  - `removeFromCollection(name: string, itemId: string): Promise<boolean>` - Remove item from collection
779
795
 
796
+ #### Utility Functions
797
+ - `arrayToIndexedObject<T>(arr: T[]): Record<string, T>` - Convert array to indexed object (helper)
798
+ - `indexedObjectToArray<T>(indexedObj: Record<string, T>): T[]` - Convert indexed object to array (helper)
799
+
800
+ #### ⚠️ **REMOVED FUNCTIONS**
801
+ The following array functions have been **REMOVED** due to GunDB compatibility issues:
802
+ - `putUserArray()`, `getUserArray()`, `addToUserArray()`, `removeFromUserArray()`, `updateInUserArray()`
803
+
804
+ **Use collections or direct GunDB operations instead** (see examples above).
805
+
780
806
  ### Advanced API Methods
781
807
 
782
808
  #### Core Authentication