shogun-core 1.7.0 → 1.7.2

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 (81) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +57 -34
  3. package/dist/browser/shogun-core.js +7328 -3849
  4. package/dist/browser/shogun-core.js.map +1 -1
  5. package/dist/gundb/crypto.js +122 -54
  6. package/dist/gundb/derive.js +63 -4
  7. package/dist/gundb/errors.js +0 -0
  8. package/dist/gundb/gun-Instance.js +143 -13
  9. package/dist/gundb/gun-rxjs.js +186 -13
  10. package/dist/gundb/index.js +0 -0
  11. package/dist/gundb/restricted-put.js +0 -0
  12. package/dist/gundb/types.js +0 -0
  13. package/dist/index.js +0 -0
  14. package/dist/plugins/base.js +0 -0
  15. package/dist/plugins/index.js +0 -0
  16. package/dist/plugins/nostr/index.js +0 -0
  17. package/dist/plugins/nostr/nostrConnector.js +0 -0
  18. package/dist/plugins/nostr/nostrConnectorPlugin.js +52 -13
  19. package/dist/plugins/nostr/nostrSigner.js +0 -0
  20. package/dist/plugins/nostr/types.js +0 -0
  21. package/dist/plugins/oauth/index.js +0 -0
  22. package/dist/plugins/oauth/oauthConnector.js +0 -0
  23. package/dist/plugins/oauth/oauthPlugin.js +59 -21
  24. package/dist/plugins/oauth/types.js +0 -0
  25. package/dist/plugins/web3/index.js +0 -0
  26. package/dist/plugins/web3/types.js +0 -0
  27. package/dist/plugins/web3/web3Connector.js +0 -0
  28. package/dist/plugins/web3/web3ConnectorPlugin.js +84 -36
  29. package/dist/plugins/web3/web3Signer.js +0 -0
  30. package/dist/plugins/webauthn/index.js +0 -0
  31. package/dist/plugins/webauthn/types.js +0 -0
  32. package/dist/plugins/webauthn/webauthn.js +3 -1
  33. package/dist/plugins/webauthn/webauthnPlugin.js +76 -23
  34. package/dist/plugins/webauthn/webauthnSigner.js +0 -0
  35. package/dist/storage/storage.js +31 -36
  36. package/dist/types/common.js +0 -0
  37. package/dist/types/events.js +0 -0
  38. package/dist/types/gundb/crypto.d.ts +8 -12
  39. package/dist/types/gundb/derive.d.ts +0 -0
  40. package/dist/types/gundb/errors.d.ts +0 -0
  41. package/dist/types/gundb/gun-Instance.d.ts +62 -3
  42. package/dist/types/gundb/gun-rxjs.d.ts +25 -5
  43. package/dist/types/gundb/index.d.ts +0 -0
  44. package/dist/types/gundb/restricted-put.d.ts +0 -0
  45. package/dist/types/gundb/types.d.ts +0 -0
  46. package/dist/types/index.d.ts +0 -0
  47. package/dist/types/plugin.js +0 -0
  48. package/dist/types/plugins/base.d.ts +0 -0
  49. package/dist/types/plugins/index.d.ts +1 -1
  50. package/dist/types/plugins/nostr/index.d.ts +0 -0
  51. package/dist/types/plugins/nostr/nostrConnector.d.ts +0 -0
  52. package/dist/types/plugins/nostr/nostrConnectorPlugin.d.ts +0 -0
  53. package/dist/types/plugins/nostr/nostrSigner.d.ts +0 -0
  54. package/dist/types/plugins/nostr/types.d.ts +0 -0
  55. package/dist/types/plugins/oauth/index.d.ts +0 -0
  56. package/dist/types/plugins/oauth/oauthConnector.d.ts +0 -0
  57. package/dist/types/plugins/oauth/oauthPlugin.d.ts +0 -0
  58. package/dist/types/plugins/oauth/types.d.ts +0 -0
  59. package/dist/types/plugins/web3/index.d.ts +0 -0
  60. package/dist/types/plugins/web3/types.d.ts +1 -1
  61. package/dist/types/plugins/web3/web3Connector.d.ts +0 -0
  62. package/dist/types/plugins/web3/web3ConnectorPlugin.d.ts +3 -3
  63. package/dist/types/plugins/web3/web3Signer.d.ts +0 -0
  64. package/dist/types/plugins/webauthn/index.d.ts +0 -0
  65. package/dist/types/plugins/webauthn/types.d.ts +0 -0
  66. package/dist/types/plugins/webauthn/webauthn.d.ts +0 -0
  67. package/dist/types/plugins/webauthn/webauthnPlugin.d.ts +0 -0
  68. package/dist/types/plugins/webauthn/webauthnSigner.d.ts +0 -0
  69. package/dist/types/shogun.js +0 -0
  70. package/dist/types/storage/storage.d.ts +3 -3
  71. package/dist/types/types/common.d.ts +0 -0
  72. package/dist/types/types/events.d.ts +0 -0
  73. package/dist/types/types/plugin.d.ts +0 -0
  74. package/dist/types/types/shogun.d.ts +0 -0
  75. package/dist/types/utils/errorHandler.d.ts +0 -0
  76. package/dist/types/utils/eventEmitter.d.ts +0 -0
  77. package/dist/types/utils/validation.d.ts +0 -0
  78. package/dist/utils/errorHandler.js +32 -32
  79. package/dist/utils/eventEmitter.js +3 -1
  80. package/dist/utils/validation.js +9 -2
  81. package/package.json +61 -2
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Shogun Core 📦
2
2
 
3
- [![npm](https://img.shields.io/badge/npm-v1.6.17-blue)](https://www.npmjs.com/package/shogun-core)
3
+ [![npm](https://img.shields.io/badge/npm-v1.7.0-blue)](https://www.npmjs.com/package/shogun-core)
4
4
  [![License](https://img.shields.io/badge/license-MIT-yellow)](https://opensource.org/licenses/MIT)
5
5
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.3.3-blue)](https://www.typescriptlang.org/)
6
6
 
@@ -20,7 +20,7 @@ Shogun Core is a comprehensive SDK for building decentralized applications (dApp
20
20
  - 🔑 **Cryptographic Wallets**: Automatic derivation of Bitcoin and Ethereum wallets from user keys
21
21
  - ✅ **Type Consistency**: Unified return types across all authentication methods
22
22
 
23
- ## Recent Updates (v1.6.15)
23
+ ## Recent Updates (v1.7.0)
24
24
 
25
25
  ### ✅ **Type System Fixes**
26
26
 
@@ -153,7 +153,7 @@ interface SignUpResult {
153
153
  isNewUser?: boolean;
154
154
  authMethod?: AuthMethod; // ✅ ADDED
155
155
  sessionToken?: string; // ✅ ADDED
156
- sea?: SEAPair; // SEA pair for session persistence
156
+ sea?: { pub: string; priv: string; epub: string; epriv: string }; // SEA pair for session persistence
157
157
  // OAuth flow support - ✅ ADDED
158
158
  redirectUrl?: string;
159
159
  pendingAuth?: boolean;
@@ -466,7 +466,8 @@ You can also use Shogun Core directly in the browser by including it from a CDN.
466
466
  #### Authentication
467
467
 
468
468
  - `login(username: string, password: string): Promise<AuthResult>` - Authenticate with username/password
469
- - `signUp(username: string, password: string, passwordConfirmation?: string): Promise<SignUpResult>` - Create new user account
469
+ - `loginWithPair(pair: ISEAPair): Promise<AuthResult>` - Authenticate directly with a GunDB SEA pair
470
+ - `signUp(username: string, password: string, email?: string, pair?: ISEAPair | null): Promise<SignUpResult>` - Create new user account
470
471
  - `logout(): void` - Logout current user
471
472
  - `isLoggedIn(): boolean` - Check if user is authenticated
472
473
 
@@ -564,10 +565,7 @@ shogun.on("auth:signup", (data) => {
564
565
  console.log("New user signed up:", data.username);
565
566
  });
566
567
 
567
- // Listen for wallet creation (Bitcoin and Ethereum wallets derived from user keys)
568
- shogun.on("wallet:created", (data) => {
569
- console.log("Wallet created:", data.address);
570
- });
568
+ // Nota: in v1.7.0 l'evento `wallet:created` non è emesso dal core
571
569
 
572
570
  // Listen for errors
573
571
  shogun.on("error", (error) => {
@@ -577,24 +575,7 @@ shogun.on("error", (error) => {
577
575
 
578
576
  ## Cryptographic Wallets
579
577
 
580
- Shogun Core automatically derives Bitcoin and Ethereum wallets from user authentication keys:
581
-
582
- ```typescript
583
- // After successful authentication, wallets are available
584
- if (shogun.wallets) {
585
- console.log("Bitcoin wallet:", {
586
- address: shogun.wallets.secp256k1Bitcoin.address,
587
- publicKey: shogun.wallets.secp256k1Bitcoin.publicKey,
588
- // privateKey is available but should be handled securely
589
- });
590
-
591
- console.log("Ethereum wallet:", {
592
- address: shogun.wallets.secp256k1Ethereum.address,
593
- publicKey: shogun.wallets.secp256k1Ethereum.publicKey,
594
- // privateKey is available but should be handled securely
595
- });
596
- }
597
- ```
578
+ Nota: la derivazione automatica dei wallet e l'evento `wallet:created` sono sperimentali e non garantiti in v1.7.0.
598
579
 
599
580
  ## Error Handling
600
581
 
@@ -698,18 +679,60 @@ This project includes a comprehensive test suite that covers:
698
679
 
699
680
  ## Running Tests
700
681
 
682
+ You can eseguire i test sia dalla root del monorepo sia entrando nella cartella `shogun-core`.
683
+
684
+ Inside `shogun-core/` directory:
685
+
701
686
  ```bash
702
- # Run all tests
703
- npm test
687
+ # Install deps
688
+ yarn install
689
+
690
+ # Tutti i test (una sola esecuzione) con coverage
691
+ yarn test:ci
692
+
693
+ # Watch mode
694
+ yarn test:watch
704
695
 
705
- # Run tests in watch mode
706
- npm run test:watch
696
+ # Coverage (report HTML in coverage/lcov-report/index.html)
697
+ yarn coverage
698
+
699
+ # Solo i test dei plugin
700
+ yarn test src/__tests__/plugins
701
+
702
+ # Evita conflitti di config Jest (se servisse)
703
+ yarn jest --ci --coverage --watchAll=false --config jest.config.js
704
+ ```
707
705
 
708
- # Run tests with coverage
709
- npm run test:coverage
706
+ From repository root (senza cambiare directory):
707
+
708
+ ```bash
709
+ # Install deps
710
+ yarn --cwd shogun-core install
711
+
712
+ # Tutti i test con coverage (CI‑like)
713
+ yarn --cwd shogun-core test:ci
714
+
715
+ # Solo plugin tests
716
+ yarn --cwd shogun-core test src/__tests__/plugins
717
+
718
+ # Coverage
719
+ yarn --cwd shogun-core coverage
720
+
721
+ # Watch mode
722
+ yarn --cwd shogun-core test:watch
723
+
724
+ # Se compaiono più configurazioni Jest, specifica esplicitamente il config file
725
+ yarn --cwd shogun-core jest --ci --coverage --watchAll=false --config jest.config.js
726
+ ```
727
+
728
+ CI & QA scripts:
729
+
730
+ ```bash
731
+ # Mutation testing (Stryker) – più lento, richiede devDeps installate
732
+ yarn --cwd shogun-core mutation
710
733
 
711
- # Run tests in CI mode
712
- npm run test:ci
734
+ # SAST (Semgrep) richiede semgrep installato (es. `pip install semgrep`)
735
+ yarn --cwd shogun-core sast
713
736
  ```
714
737
 
715
738
  ## Test Coverage