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.
- package/LICENSE +0 -0
- package/README.md +57 -34
- package/dist/browser/shogun-core.js +7328 -3849
- package/dist/browser/shogun-core.js.map +1 -1
- package/dist/gundb/crypto.js +122 -54
- package/dist/gundb/derive.js +63 -4
- package/dist/gundb/errors.js +0 -0
- package/dist/gundb/gun-Instance.js +143 -13
- package/dist/gundb/gun-rxjs.js +186 -13
- package/dist/gundb/index.js +0 -0
- package/dist/gundb/restricted-put.js +0 -0
- package/dist/gundb/types.js +0 -0
- package/dist/index.js +0 -0
- package/dist/plugins/base.js +0 -0
- package/dist/plugins/index.js +0 -0
- package/dist/plugins/nostr/index.js +0 -0
- package/dist/plugins/nostr/nostrConnector.js +0 -0
- package/dist/plugins/nostr/nostrConnectorPlugin.js +52 -13
- package/dist/plugins/nostr/nostrSigner.js +0 -0
- package/dist/plugins/nostr/types.js +0 -0
- package/dist/plugins/oauth/index.js +0 -0
- package/dist/plugins/oauth/oauthConnector.js +0 -0
- package/dist/plugins/oauth/oauthPlugin.js +59 -21
- package/dist/plugins/oauth/types.js +0 -0
- package/dist/plugins/web3/index.js +0 -0
- package/dist/plugins/web3/types.js +0 -0
- package/dist/plugins/web3/web3Connector.js +0 -0
- package/dist/plugins/web3/web3ConnectorPlugin.js +84 -36
- package/dist/plugins/web3/web3Signer.js +0 -0
- package/dist/plugins/webauthn/index.js +0 -0
- package/dist/plugins/webauthn/types.js +0 -0
- package/dist/plugins/webauthn/webauthn.js +3 -1
- package/dist/plugins/webauthn/webauthnPlugin.js +76 -23
- package/dist/plugins/webauthn/webauthnSigner.js +0 -0
- package/dist/storage/storage.js +31 -36
- package/dist/types/common.js +0 -0
- package/dist/types/events.js +0 -0
- package/dist/types/gundb/crypto.d.ts +8 -12
- package/dist/types/gundb/derive.d.ts +0 -0
- package/dist/types/gundb/errors.d.ts +0 -0
- package/dist/types/gundb/gun-Instance.d.ts +62 -3
- package/dist/types/gundb/gun-rxjs.d.ts +25 -5
- package/dist/types/gundb/index.d.ts +0 -0
- package/dist/types/gundb/restricted-put.d.ts +0 -0
- package/dist/types/gundb/types.d.ts +0 -0
- package/dist/types/index.d.ts +0 -0
- package/dist/types/plugin.js +0 -0
- package/dist/types/plugins/base.d.ts +0 -0
- package/dist/types/plugins/index.d.ts +1 -1
- package/dist/types/plugins/nostr/index.d.ts +0 -0
- package/dist/types/plugins/nostr/nostrConnector.d.ts +0 -0
- package/dist/types/plugins/nostr/nostrConnectorPlugin.d.ts +0 -0
- package/dist/types/plugins/nostr/nostrSigner.d.ts +0 -0
- package/dist/types/plugins/nostr/types.d.ts +0 -0
- package/dist/types/plugins/oauth/index.d.ts +0 -0
- package/dist/types/plugins/oauth/oauthConnector.d.ts +0 -0
- package/dist/types/plugins/oauth/oauthPlugin.d.ts +0 -0
- package/dist/types/plugins/oauth/types.d.ts +0 -0
- package/dist/types/plugins/web3/index.d.ts +0 -0
- package/dist/types/plugins/web3/types.d.ts +1 -1
- package/dist/types/plugins/web3/web3Connector.d.ts +0 -0
- package/dist/types/plugins/web3/web3ConnectorPlugin.d.ts +3 -3
- package/dist/types/plugins/web3/web3Signer.d.ts +0 -0
- package/dist/types/plugins/webauthn/index.d.ts +0 -0
- package/dist/types/plugins/webauthn/types.d.ts +0 -0
- package/dist/types/plugins/webauthn/webauthn.d.ts +0 -0
- package/dist/types/plugins/webauthn/webauthnPlugin.d.ts +0 -0
- package/dist/types/plugins/webauthn/webauthnSigner.d.ts +0 -0
- package/dist/types/shogun.js +0 -0
- package/dist/types/storage/storage.d.ts +3 -3
- package/dist/types/types/common.d.ts +0 -0
- package/dist/types/types/events.d.ts +0 -0
- package/dist/types/types/plugin.d.ts +0 -0
- package/dist/types/types/shogun.d.ts +0 -0
- package/dist/types/utils/errorHandler.d.ts +0 -0
- package/dist/types/utils/eventEmitter.d.ts +0 -0
- package/dist/types/utils/validation.d.ts +0 -0
- package/dist/utils/errorHandler.js +32 -32
- package/dist/utils/eventEmitter.js +3 -1
- package/dist/utils/validation.js +9 -2
- 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
|
-
[](https://www.npmjs.com/package/shogun-core)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
[](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.
|
|
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?:
|
|
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
|
-
- `
|
|
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
|
-
//
|
|
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
|
-
|
|
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
|
-
#
|
|
703
|
-
|
|
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
|
-
#
|
|
706
|
-
|
|
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
|
-
|
|
709
|
-
|
|
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
|
-
#
|
|
712
|
-
|
|
734
|
+
# SAST (Semgrep) – richiede semgrep installato (es. `pip install semgrep`)
|
|
735
|
+
yarn --cwd shogun-core sast
|
|
713
736
|
```
|
|
714
737
|
|
|
715
738
|
## Test Coverage
|