shogun-core 3.3.1 → 3.3.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/dist/ship/examples/ephemeral-cli.js +234 -0
- package/dist/ship/examples/identity-cli.js +503 -0
- package/dist/ship/examples/messenger-cli.js +745 -0
- package/dist/ship/examples/stealth-cli.js +433 -0
- package/dist/ship/examples/storage-cli.js +615 -0
- package/dist/ship/examples/vault-cli.js +444 -0
- package/dist/ship/examples/wallet-cli.js +767 -0
- package/dist/ship/implementation/SHIP_00.js +478 -0
- package/dist/ship/implementation/SHIP_01.js +433 -0
- package/dist/ship/implementation/SHIP_02.js +1366 -0
- package/dist/ship/implementation/SHIP_03.js +855 -0
- package/dist/ship/implementation/SHIP_04.js +589 -0
- package/dist/ship/implementation/SHIP_05.js +1064 -0
- package/dist/ship/implementation/SHIP_06.js +350 -0
- package/dist/ship/implementation/SHIP_07.js +635 -0
- package/dist/ship/index.js +17 -0
- package/dist/ship/interfaces/ISHIP_00.js +135 -0
- package/dist/ship/interfaces/ISHIP_01.js +128 -0
- package/dist/ship/interfaces/ISHIP_02.js +57 -0
- package/dist/ship/interfaces/ISHIP_03.js +61 -0
- package/dist/ship/interfaces/ISHIP_04.js +62 -0
- package/dist/ship/interfaces/ISHIP_05.js +59 -0
- package/dist/ship/interfaces/ISHIP_06.js +144 -0
- package/dist/ship/interfaces/ISHIP_07.js +194 -0
- package/dist/types/ship/examples/ephemeral-cli.d.ts +13 -0
- package/dist/types/ship/examples/identity-cli.d.ts +40 -0
- package/dist/types/ship/examples/messenger-cli.d.ts +37 -0
- package/dist/types/ship/examples/stealth-cli.d.ts +31 -0
- package/dist/types/ship/examples/storage-cli.d.ts +48 -0
- package/dist/types/ship/examples/vault-cli.d.ts +13 -0
- package/dist/types/ship/examples/wallet-cli.d.ts +131 -0
- package/dist/types/ship/implementation/SHIP_00.d.ts +113 -0
- package/dist/types/ship/implementation/SHIP_01.d.ts +80 -0
- package/dist/types/ship/implementation/SHIP_02.d.ts +297 -0
- package/dist/types/ship/implementation/SHIP_03.d.ts +127 -0
- package/dist/types/ship/implementation/SHIP_04.d.ts +76 -0
- package/dist/types/ship/implementation/SHIP_05.d.ts +70 -0
- package/dist/types/ship/implementation/SHIP_06.d.ts +66 -0
- package/dist/types/ship/implementation/SHIP_07.d.ts +101 -0
- package/dist/types/ship/index.d.ts +14 -0
- package/dist/types/ship/interfaces/ISHIP_00.d.ts +410 -0
- package/dist/types/ship/interfaces/ISHIP_01.d.ts +343 -0
- package/dist/types/ship/interfaces/ISHIP_02.d.ts +470 -0
- package/dist/types/ship/interfaces/ISHIP_03.d.ts +295 -0
- package/dist/types/ship/interfaces/ISHIP_04.d.ts +245 -0
- package/dist/types/ship/interfaces/ISHIP_05.d.ts +234 -0
- package/dist/types/ship/interfaces/ISHIP_06.d.ts +370 -0
- package/dist/types/ship/interfaces/ISHIP_07.d.ts +522 -0
- package/package.json +1 -1
- /package/dist/{config → src/config}/simplified-config.js +0 -0
- /package/dist/{core.js → src/core.js} +0 -0
- /package/dist/{examples → src/examples}/api-test.js +0 -0
- /package/dist/{examples → src/examples}/simple-api-test.js +0 -0
- /package/dist/{gundb → src/gundb}/api.js +0 -0
- /package/dist/{gundb → src/gundb}/crypto.js +0 -0
- /package/dist/{gundb → src/gundb}/db.js +0 -0
- /package/dist/{gundb → src/gundb}/derive.js +0 -0
- /package/dist/{gundb → src/gundb}/errors.js +0 -0
- /package/dist/{gundb → src/gundb}/index.js +0 -0
- /package/dist/{gundb → src/gundb}/rxjs.js +0 -0
- /package/dist/{gundb → src/gundb}/types.js +0 -0
- /package/dist/{index.js → src/index.js} +0 -0
- /package/dist/{interfaces → src/interfaces}/common.js +0 -0
- /package/dist/{interfaces → src/interfaces}/events.js +0 -0
- /package/dist/{interfaces → src/interfaces}/plugin.js +0 -0
- /package/dist/{interfaces → src/interfaces}/shogun.js +0 -0
- /package/dist/{managers → src/managers}/AuthManager.js +0 -0
- /package/dist/{managers → src/managers}/CoreInitializer.js +0 -0
- /package/dist/{managers → src/managers}/EventManager.js +0 -0
- /package/dist/{managers → src/managers}/PluginManager.js +0 -0
- /package/dist/{migration-test.js → src/migration-test.js} +0 -0
- /package/dist/{plugins → src/plugins}/base.js +0 -0
- /package/dist/{plugins → src/plugins}/index.js +0 -0
- /package/dist/{plugins → src/plugins}/nostr/index.js +0 -0
- /package/dist/{plugins → src/plugins}/nostr/nostrConnector.js +0 -0
- /package/dist/{plugins → src/plugins}/nostr/nostrConnectorPlugin.js +0 -0
- /package/dist/{plugins → src/plugins}/nostr/nostrSigner.js +0 -0
- /package/dist/{plugins → src/plugins}/nostr/types.js +0 -0
- /package/dist/{plugins → src/plugins}/oauth/index.js +0 -0
- /package/dist/{plugins → src/plugins}/oauth/oauthConnector.js +0 -0
- /package/dist/{plugins → src/plugins}/oauth/oauthPlugin.js +0 -0
- /package/dist/{plugins → src/plugins}/oauth/types.js +0 -0
- /package/dist/{plugins → src/plugins}/web3/index.js +0 -0
- /package/dist/{plugins → src/plugins}/web3/types.js +0 -0
- /package/dist/{plugins → src/plugins}/web3/web3Connector.js +0 -0
- /package/dist/{plugins → src/plugins}/web3/web3ConnectorPlugin.js +0 -0
- /package/dist/{plugins → src/plugins}/web3/web3Signer.js +0 -0
- /package/dist/{plugins → src/plugins}/webauthn/index.js +0 -0
- /package/dist/{plugins → src/plugins}/webauthn/types.js +0 -0
- /package/dist/{plugins → src/plugins}/webauthn/webauthn.js +0 -0
- /package/dist/{plugins → src/plugins}/webauthn/webauthnPlugin.js +0 -0
- /package/dist/{plugins → src/plugins}/webauthn/webauthnSigner.js +0 -0
- /package/dist/{storage → src/storage}/storage.js +0 -0
- /package/dist/{types → src/types}/events.js +0 -0
- /package/dist/{types → src/types}/shogun.js +0 -0
- /package/dist/{utils → src/utils}/errorHandler.js +0 -0
- /package/dist/{utils → src/utils}/eventEmitter.js +0 -0
- /package/dist/{utils → src/utils}/validation.js +0 -0
- /package/dist/types/{config → src/config}/simplified-config.d.ts +0 -0
- /package/dist/types/{core.d.ts → src/core.d.ts} +0 -0
- /package/dist/types/{examples → src/examples}/api-test.d.ts +0 -0
- /package/dist/types/{examples → src/examples}/simple-api-test.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/api.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/crypto.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/db.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/derive.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/errors.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/index.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/rxjs.d.ts +0 -0
- /package/dist/types/{gundb → src/gundb}/types.d.ts +0 -0
- /package/dist/types/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/types/{interfaces → src/interfaces}/common.d.ts +0 -0
- /package/dist/types/{interfaces → src/interfaces}/events.d.ts +0 -0
- /package/dist/types/{interfaces → src/interfaces}/plugin.d.ts +0 -0
- /package/dist/types/{interfaces → src/interfaces}/shogun.d.ts +0 -0
- /package/dist/types/{managers → src/managers}/AuthManager.d.ts +0 -0
- /package/dist/types/{managers → src/managers}/CoreInitializer.d.ts +0 -0
- /package/dist/types/{managers → src/managers}/EventManager.d.ts +0 -0
- /package/dist/types/{managers → src/managers}/PluginManager.d.ts +0 -0
- /package/dist/types/{migration-test.d.ts → src/migration-test.d.ts} +0 -0
- /package/dist/types/{plugins → src/plugins}/base.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/nostr/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/nostr/nostrConnector.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/nostr/nostrConnectorPlugin.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/nostr/nostrSigner.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/nostr/types.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/oauth/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/oauth/oauthConnector.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/oauth/oauthPlugin.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/oauth/types.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/web3/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/web3/types.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/web3/web3Connector.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/web3/web3ConnectorPlugin.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/web3/web3Signer.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/webauthn/index.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/webauthn/types.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/webauthn/webauthn.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/webauthn/webauthnPlugin.d.ts +0 -0
- /package/dist/types/{plugins → src/plugins}/webauthn/webauthnSigner.d.ts +0 -0
- /package/dist/types/{storage → src/storage}/storage.d.ts +0 -0
- /package/dist/types/{types → src/types}/events.d.ts +0 -0
- /package/dist/types/{types → src/types}/shogun.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/errorHandler.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/eventEmitter.d.ts +0 -0
- /package/dist/types/{utils → src/utils}/validation.d.ts +0 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SHIP-00: Decentralized Identity & Authentication Interface
|
|
4
|
+
*
|
|
5
|
+
* @title ISHIP_00 - Identity Foundation
|
|
6
|
+
* @notice Base interface for decentralized identity in Shogun ecosystem
|
|
7
|
+
*
|
|
8
|
+
* ## Abstract
|
|
9
|
+
*
|
|
10
|
+
* This standard defines the foundational interface for identity that enables:
|
|
11
|
+
* - Username/password authentication with deterministic key generation
|
|
12
|
+
* - SEA key pair management (export, import, backup)
|
|
13
|
+
* - Public key publication and discovery on GunDB
|
|
14
|
+
* - User registry and lookup system
|
|
15
|
+
* - Blockchain address derivation (Ethereum, Bitcoin, etc.)
|
|
16
|
+
*
|
|
17
|
+
* ## Specification
|
|
18
|
+
*
|
|
19
|
+
* Based on:
|
|
20
|
+
* - GunDB for P2P identity storage
|
|
21
|
+
* - SEA (Security, Encryption, Authorization) for key management
|
|
22
|
+
* - Shogun Core DataBase API for authentication
|
|
23
|
+
* - BIP32-like derivation for blockchain addresses
|
|
24
|
+
*
|
|
25
|
+
* ## Usage
|
|
26
|
+
*
|
|
27
|
+
* SHIP-00 serves as the foundation for all other SHIPs:
|
|
28
|
+
* - SHIP-01 (Messaging) depends on SHIP-00 for identity
|
|
29
|
+
* - SHIP-02 (Address Derivation) extends SHIP-00
|
|
30
|
+
* - SHIP-03 (Multi-Modal Auth) extends SHIP-00
|
|
31
|
+
* - SHIP-04 (File Storage) uses SHIP-00 for ACL
|
|
32
|
+
*/
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
// ============================================================================
|
|
35
|
+
// IMPLEMENTATION EXAMPLE
|
|
36
|
+
// ============================================================================
|
|
37
|
+
/**
|
|
38
|
+
* Example of how to implement ISHIP_00
|
|
39
|
+
*
|
|
40
|
+
* ```typescript
|
|
41
|
+
* import { ShogunCore } from 'shogun-core';
|
|
42
|
+
* import { ISHIP_00, SEAPair, AuthResult, SignupResult } from './interfaces/ISHIP_00';
|
|
43
|
+
*
|
|
44
|
+
* class IdentityManager implements ISHIP_00 {
|
|
45
|
+
* private shogun: ShogunCore;
|
|
46
|
+
*
|
|
47
|
+
* constructor(config: IdentityConfig) {
|
|
48
|
+
* this.shogun = new ShogunCore({
|
|
49
|
+
* gunOptions: {
|
|
50
|
+
* peers: config.peers,
|
|
51
|
+
* radisk: config.radisk,
|
|
52
|
+
* localStorage: config.localStorage
|
|
53
|
+
* },
|
|
54
|
+
* scope: config.scope
|
|
55
|
+
* });
|
|
56
|
+
* }
|
|
57
|
+
*
|
|
58
|
+
* async signup(username: string, password: string): Promise<SignupResult> {
|
|
59
|
+
* // Use Shogun Core signUp method
|
|
60
|
+
* const result = await this.shogun.signUp(username, password);
|
|
61
|
+
*
|
|
62
|
+
* if (result.success) {
|
|
63
|
+
* // Publish public key
|
|
64
|
+
* await this.publishPublicKey();
|
|
65
|
+
*
|
|
66
|
+
* // Derive Ethereum address
|
|
67
|
+
* const derivedAddress = await this.deriveEthereumAddress(result.userPub);
|
|
68
|
+
*
|
|
69
|
+
* return {
|
|
70
|
+
* success: true,
|
|
71
|
+
* userPub: result.userPub,
|
|
72
|
+
* username: username,
|
|
73
|
+
* derivedAddress: derivedAddress
|
|
74
|
+
* };
|
|
75
|
+
* }
|
|
76
|
+
*
|
|
77
|
+
* return {
|
|
78
|
+
* success: false,
|
|
79
|
+
* error: result.error || 'Signup failed'
|
|
80
|
+
* };
|
|
81
|
+
* }
|
|
82
|
+
*
|
|
83
|
+
* async login(username: string, password: string): Promise<AuthResult> {
|
|
84
|
+
* // Use Shogun Core login method
|
|
85
|
+
* const result = await this.shogun.login(username, password);
|
|
86
|
+
*
|
|
87
|
+
* if (result.success) {
|
|
88
|
+
* const derivedAddress = await this.deriveEthereumAddress(result.userPub);
|
|
89
|
+
*
|
|
90
|
+
* return {
|
|
91
|
+
* success: true,
|
|
92
|
+
* userPub: result.userPub,
|
|
93
|
+
* username: username,
|
|
94
|
+
* derivedAddress: derivedAddress
|
|
95
|
+
* };
|
|
96
|
+
* }
|
|
97
|
+
*
|
|
98
|
+
* return {
|
|
99
|
+
* success: false,
|
|
100
|
+
* error: result.error || 'Login failed'
|
|
101
|
+
* };
|
|
102
|
+
* }
|
|
103
|
+
*
|
|
104
|
+
* exportKeyPair(): SEAPair | null {
|
|
105
|
+
* if (!this.isLoggedIn()) return null;
|
|
106
|
+
*
|
|
107
|
+
* const seaPair = (this.shogun.db.gun.user() as any)?._?.sea;
|
|
108
|
+
* if (!seaPair) return null;
|
|
109
|
+
*
|
|
110
|
+
* return {
|
|
111
|
+
* pub: seaPair.pub,
|
|
112
|
+
* priv: seaPair.priv,
|
|
113
|
+
* epub: seaPair.epub,
|
|
114
|
+
* epriv: seaPair.epriv
|
|
115
|
+
* };
|
|
116
|
+
* }
|
|
117
|
+
*
|
|
118
|
+
* async getUserByAlias(username: string): Promise<UserData | null> {
|
|
119
|
+
* // Use Shogun Core getUserByAlias method
|
|
120
|
+
* return await this.shogun.db.getUserByAlias(username);
|
|
121
|
+
* }
|
|
122
|
+
*
|
|
123
|
+
* async deriveEthereumAddress(publicKey?: string): Promise<string> {
|
|
124
|
+
* // Use shogun-derive package
|
|
125
|
+
* const derived = await derive(seaPair.priv, null, {
|
|
126
|
+
* includeSecp256k1Ethereum: true
|
|
127
|
+
* });
|
|
128
|
+
*
|
|
129
|
+
* return derived.secp256k1Ethereum.address;
|
|
130
|
+
* }
|
|
131
|
+
*
|
|
132
|
+
* // ... implement other methods
|
|
133
|
+
* }
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shogun Messaging Protocol Interface
|
|
4
|
+
*
|
|
5
|
+
* @title ISHIP_01 - Decentralized Encrypted Messaging
|
|
6
|
+
* @notice Interface for decentralized encrypted messaging on GunDB
|
|
7
|
+
* @dev This interface depends on ISHIP_00 for identity and authentication
|
|
8
|
+
*
|
|
9
|
+
* ## Abstract
|
|
10
|
+
*
|
|
11
|
+
* This standard defines an interface for decentralized messaging that allows:
|
|
12
|
+
* - End-to-end encrypted message sending (ECDH)
|
|
13
|
+
* - Real-time message reception
|
|
14
|
+
* - Decentralized message history
|
|
15
|
+
*
|
|
16
|
+
* ## Dependencies
|
|
17
|
+
*
|
|
18
|
+
* - ISHIP_00: Identity and authentication layer
|
|
19
|
+
* - GunDB: P2P storage
|
|
20
|
+
* - SEA: Cryptography (ECDH + AES-GCM)
|
|
21
|
+
*
|
|
22
|
+
* ## Specification
|
|
23
|
+
*
|
|
24
|
+
* Based on:
|
|
25
|
+
* - SHIP-00 for identity management
|
|
26
|
+
* - GunDB for P2P storage
|
|
27
|
+
* - SEA (Security, Encryption, Authorization) for cryptography
|
|
28
|
+
* - ECDH (Elliptic Curve Diffie-Hellman) for key agreement
|
|
29
|
+
*/
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
// ============================================================================
|
|
32
|
+
// IMPLEMENTATION EXAMPLE
|
|
33
|
+
// ============================================================================
|
|
34
|
+
/**
|
|
35
|
+
* Example of how to implement ISHIP_01 with ISHIP_00 dependency
|
|
36
|
+
*
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import { ISHIP_00 } from './ISHIP_00';
|
|
39
|
+
* import { ISHIP_01, DecryptedMessage, SendMessageResult } from './ISHIP_01';
|
|
40
|
+
*
|
|
41
|
+
* class SecureMessagingApp implements ISHIP_01 {
|
|
42
|
+
* constructor(private identity: ISHIP_00) {
|
|
43
|
+
* // Verify identity is authenticated
|
|
44
|
+
* if (!identity.isLoggedIn()) {
|
|
45
|
+
* throw new Error('User must be authenticated');
|
|
46
|
+
* }
|
|
47
|
+
* }
|
|
48
|
+
*
|
|
49
|
+
* getIdentity(): ISHIP_00 {
|
|
50
|
+
* return this.identity;
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* async sendMessage(recipientUsername: string, message: string): Promise<SendMessageResult> {
|
|
54
|
+
* // 1. Get recipient's public key from identity provider
|
|
55
|
+
* const recipientKey = await this.identity.getPublicKey(recipientUsername);
|
|
56
|
+
* if (!recipientKey) {
|
|
57
|
+
* return { success: false, error: 'Recipient not found' };
|
|
58
|
+
* }
|
|
59
|
+
*
|
|
60
|
+
* // 2. Get sender's key pair from identity provider
|
|
61
|
+
* const senderPair = this.identity.getKeyPair();
|
|
62
|
+
* if (!senderPair) {
|
|
63
|
+
* return { success: false, error: 'Not authenticated' };
|
|
64
|
+
* }
|
|
65
|
+
*
|
|
66
|
+
* // 3. Encrypt with ECDH
|
|
67
|
+
* const encrypted = await crypto.encFor(
|
|
68
|
+
* message,
|
|
69
|
+
* senderPair,
|
|
70
|
+
* { epub: recipientKey.epub }
|
|
71
|
+
* );
|
|
72
|
+
*
|
|
73
|
+
* // 4. Save to GunDB
|
|
74
|
+
* const messageId = generateId();
|
|
75
|
+
* await gun.get('messages').get(messageId).put({
|
|
76
|
+
* content: encrypted,
|
|
77
|
+
* from: senderPair.pub,
|
|
78
|
+
* to: recipientUsername,
|
|
79
|
+
* timestamp: Date.now().toString()
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* return { success: true, messageId };
|
|
83
|
+
* }
|
|
84
|
+
*
|
|
85
|
+
* async listenForMessages(onMessage: (message: DecryptedMessage) => void): Promise<void> {
|
|
86
|
+
* const currentUser = this.identity.getCurrentUser();
|
|
87
|
+
* if (!currentUser) {
|
|
88
|
+
* throw new Error('Not authenticated');
|
|
89
|
+
* }
|
|
90
|
+
*
|
|
91
|
+
* gun.get('messages').map().on(async (data, key) => {
|
|
92
|
+
* if (data && data.to === currentUser.alias) {
|
|
93
|
+
* // Decrypt message
|
|
94
|
+
* const senderKey = await this.identity.getPublicKey(data.from);
|
|
95
|
+
* const receiverPair = this.identity.getKeyPair();
|
|
96
|
+
*
|
|
97
|
+
* if (senderKey && receiverPair) {
|
|
98
|
+
* const decrypted = await crypto.decFrom(
|
|
99
|
+
* data.content,
|
|
100
|
+
* { epub: senderKey.epub },
|
|
101
|
+
* receiverPair
|
|
102
|
+
* );
|
|
103
|
+
*
|
|
104
|
+
* onMessage({
|
|
105
|
+
* from: data.from,
|
|
106
|
+
* content: decrypted,
|
|
107
|
+
* timestamp: parseInt(data.timestamp)
|
|
108
|
+
* });
|
|
109
|
+
* }
|
|
110
|
+
* }
|
|
111
|
+
* });
|
|
112
|
+
* }
|
|
113
|
+
*
|
|
114
|
+
* async getMessageHistory(withUsername: string): Promise<MessageHistoryEntry[]> {
|
|
115
|
+
* // Implementation here
|
|
116
|
+
* return [];
|
|
117
|
+
* }
|
|
118
|
+
* }
|
|
119
|
+
*
|
|
120
|
+
* // Usage
|
|
121
|
+
* const identity = new SHIP_00(config);
|
|
122
|
+
* await identity.login('alice', 'password123');
|
|
123
|
+
* await identity.publishPublicKey();
|
|
124
|
+
*
|
|
125
|
+
* const messaging = new SecureMessagingApp(identity);
|
|
126
|
+
* await messaging.sendMessage('bob', 'Hello Bob!');
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SHIP-02: Ethereum Address Derivation Interface
|
|
4
|
+
*
|
|
5
|
+
* @title ISHIP_02 - Deterministic Address Derivation
|
|
6
|
+
* @notice Interface for deriving Ethereum addresses from SHIP-00 identity
|
|
7
|
+
*
|
|
8
|
+
* ## Abstract
|
|
9
|
+
*
|
|
10
|
+
* This standard extends SHIP-00 to enable:
|
|
11
|
+
* - Deterministic Ethereum address derivation from identity keys
|
|
12
|
+
* - BIP-32/BIP-44 hierarchical deterministic (HD) wallet support
|
|
13
|
+
* - Stealth address generation for enhanced privacy
|
|
14
|
+
* - Multiple address management from single identity
|
|
15
|
+
* - Transaction signing with derived keys
|
|
16
|
+
*
|
|
17
|
+
* ## Specification
|
|
18
|
+
*
|
|
19
|
+
* Based on:
|
|
20
|
+
* - SHIP-00 for identity foundation
|
|
21
|
+
* - BIP-32 for hierarchical deterministic wallets
|
|
22
|
+
* - BIP-44 for multi-account hierarchy
|
|
23
|
+
* - Ethers.js for Ethereum operations
|
|
24
|
+
* - ECDH for stealth address generation
|
|
25
|
+
*
|
|
26
|
+
* ## Dependencies
|
|
27
|
+
*
|
|
28
|
+
* - SHIP-00: Identity and authentication foundation
|
|
29
|
+
* - ethers: Ethereum wallet and signing operations
|
|
30
|
+
*
|
|
31
|
+
* ## Usage
|
|
32
|
+
*
|
|
33
|
+
* SHIP-02 enables wallet functionality on top of SHIP-00 identity:
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const identity = new SHIP_00({ gunOptions: { peers: ['...'] } });
|
|
36
|
+
* await identity.login('alice', 'password123');
|
|
37
|
+
*
|
|
38
|
+
* const addressDerivation = new SHIP_02(identity);
|
|
39
|
+
* await addressDerivation.initialize();
|
|
40
|
+
*
|
|
41
|
+
* const ethAddress = await addressDerivation.deriveEthereumAddress();
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.SHIP_02_EventType = void 0;
|
|
46
|
+
/**
|
|
47
|
+
* @notice Event types for SHIP-02 wallet operations
|
|
48
|
+
*/
|
|
49
|
+
var SHIP_02_EventType;
|
|
50
|
+
(function (SHIP_02_EventType) {
|
|
51
|
+
SHIP_02_EventType["WALLET_CREATED"] = "walletCreated";
|
|
52
|
+
SHIP_02_EventType["ADDRESS_DERIVED"] = "addressDerived";
|
|
53
|
+
SHIP_02_EventType["TRANSACTION_SIGNED"] = "transactionSigned";
|
|
54
|
+
SHIP_02_EventType["MNEMONIC_GENERATED"] = "mnemonicGenerated";
|
|
55
|
+
SHIP_02_EventType["SYNC_COMPLETED"] = "syncCompleted";
|
|
56
|
+
SHIP_02_EventType["ERROR"] = "error";
|
|
57
|
+
})(SHIP_02_EventType || (exports.SHIP_02_EventType = SHIP_02_EventType = {}));
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SHIP-03: Dual-Key Stealth Address Interface
|
|
4
|
+
*
|
|
5
|
+
* @title ISHIP_03 - Privacy-Preserving Stealth Addresses
|
|
6
|
+
* @notice Interface for ERC-5564 compatible stealth addresses
|
|
7
|
+
*
|
|
8
|
+
* ## Abstract
|
|
9
|
+
*
|
|
10
|
+
* This standard extends SHIP-00 and SHIP-02 to enable:
|
|
11
|
+
* - Dual-key stealth addresses (viewing + spending keys)
|
|
12
|
+
* - ERC-5564 / Fluidkey compatibility
|
|
13
|
+
* - Enhanced transaction privacy
|
|
14
|
+
* - Stealth address scanning and opening
|
|
15
|
+
* - Deterministic key derivation from SHIP-00 identity
|
|
16
|
+
*
|
|
17
|
+
* ## Specification
|
|
18
|
+
*
|
|
19
|
+
* Based on:
|
|
20
|
+
* - SHIP-00 for identity foundation
|
|
21
|
+
* - SHIP-02 for Ethereum address derivation
|
|
22
|
+
* - ERC-5564 for stealth address standard
|
|
23
|
+
* - Fluidkey Stealth Account Kit
|
|
24
|
+
* - ECDH for shared secret derivation
|
|
25
|
+
*
|
|
26
|
+
* ## Key Concepts
|
|
27
|
+
*
|
|
28
|
+
* **Viewing Key**: Used to scan blockchain for incoming stealth payments
|
|
29
|
+
* **Spending Key**: Used to spend funds received at stealth addresses
|
|
30
|
+
* **Ephemeral Key**: One-time key used by sender to generate stealth address
|
|
31
|
+
*
|
|
32
|
+
* ## Dependencies
|
|
33
|
+
*
|
|
34
|
+
* - SHIP-00: Identity and authentication foundation
|
|
35
|
+
* - SHIP-02: Ethereum wallet operations
|
|
36
|
+
* - @fluidkey/stealth-account-kit: ERC-5564 implementation
|
|
37
|
+
* - ethers: Ethereum operations
|
|
38
|
+
*
|
|
39
|
+
* ## Usage
|
|
40
|
+
*
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const identity = new SHIP_00({ gunOptions: { peers: ['...'] } });
|
|
43
|
+
* await identity.login('alice', 'password123');
|
|
44
|
+
*
|
|
45
|
+
* const eth = new SHIP_02(identity);
|
|
46
|
+
* await eth.initialize();
|
|
47
|
+
*
|
|
48
|
+
* const stealth = new SHIP_03(identity, eth);
|
|
49
|
+
* await stealth.initialize();
|
|
50
|
+
*
|
|
51
|
+
* // Get stealth keys (derived from SHIP-00 identity)
|
|
52
|
+
* const keys = await stealth.getStealthKeys();
|
|
53
|
+
*
|
|
54
|
+
* // Generate stealth address for recipient
|
|
55
|
+
* const stealthAddr = await stealth.generateStealthAddress(
|
|
56
|
+
* recipientViewingKey,
|
|
57
|
+
* recipientSpendingKey
|
|
58
|
+
* );
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SHIP-04: Multi-Modal Authentication Interface
|
|
4
|
+
*
|
|
5
|
+
* @title ISHIP_04 - Alternative Authentication Methods
|
|
6
|
+
* @notice Interface for multi-modal authentication extending SHIP-00
|
|
7
|
+
*
|
|
8
|
+
* ## Abstract
|
|
9
|
+
*
|
|
10
|
+
* This standard extends SHIP-00 to provide multiple authentication methods:
|
|
11
|
+
* - OAuth (Google, GitHub, Discord, etc.)
|
|
12
|
+
* - WebAuthn/Passkeys (biometric authentication)
|
|
13
|
+
* - Nostr (decentralized social protocol)
|
|
14
|
+
* - Web3 (MetaMask, WalletConnect, etc.)
|
|
15
|
+
*
|
|
16
|
+
* ## Dependencies
|
|
17
|
+
*
|
|
18
|
+
* - SHIP-00: Base identity foundation
|
|
19
|
+
* - Shogun Core Plugins: OAuth, WebAuthn, Nostr, Web3
|
|
20
|
+
*
|
|
21
|
+
* ## Inclusive Hierarchy
|
|
22
|
+
*
|
|
23
|
+
* SHIP-04 extends SHIP-00 (✅ allowed):
|
|
24
|
+
* ```
|
|
25
|
+
* SHIP-04 (Multi-Modal Auth)
|
|
26
|
+
* ↓ depends on
|
|
27
|
+
* SHIP-00 (Identity Foundation)
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* ## Usage
|
|
31
|
+
*
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const identity = new SHIP_00(config);
|
|
34
|
+
* const multiAuth = new SHIP_04(identity);
|
|
35
|
+
*
|
|
36
|
+
* // Login with OAuth
|
|
37
|
+
* await multiAuth.loginWithOAuth('google');
|
|
38
|
+
*
|
|
39
|
+
* // Or WebAuthn
|
|
40
|
+
* await multiAuth.loginWithWebAuthn('alice');
|
|
41
|
+
*
|
|
42
|
+
* // Result is SHIP-00 compatible!
|
|
43
|
+
* const user = identity.getCurrentUser();
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
exports.AuthMethod = void 0;
|
|
48
|
+
// ============================================================================
|
|
49
|
+
// CORE TYPES
|
|
50
|
+
// ============================================================================
|
|
51
|
+
/**
|
|
52
|
+
* Available authentication methods
|
|
53
|
+
* Exported as const enum to allow usage as both type and value
|
|
54
|
+
*/
|
|
55
|
+
var AuthMethod;
|
|
56
|
+
(function (AuthMethod) {
|
|
57
|
+
AuthMethod["PASSWORD"] = "password";
|
|
58
|
+
AuthMethod["OAUTH"] = "oauth";
|
|
59
|
+
AuthMethod["WEBAUTHN"] = "webauthn";
|
|
60
|
+
AuthMethod["NOSTR"] = "nostr";
|
|
61
|
+
AuthMethod["WEB3"] = "web3";
|
|
62
|
+
})(AuthMethod || (exports.AuthMethod = AuthMethod = {}));
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SHIP-05: Decentralized File Storage Interface
|
|
4
|
+
*
|
|
5
|
+
* @title ISHIP_05 - IPFS Storage with Relay Network
|
|
6
|
+
* @notice Interface for decentralized file storage with encryption
|
|
7
|
+
*
|
|
8
|
+
* ## Abstract
|
|
9
|
+
*
|
|
10
|
+
* This standard extends SHIP-00 to enable:
|
|
11
|
+
* - Encrypted file storage on IPFS
|
|
12
|
+
* - Relay network management for storage providers
|
|
13
|
+
* - On-chain subscription system for storage
|
|
14
|
+
* - Deterministic encryption from wallet signatures
|
|
15
|
+
* - File sharing with access control
|
|
16
|
+
*
|
|
17
|
+
* ## Specification
|
|
18
|
+
*
|
|
19
|
+
* Based on:
|
|
20
|
+
* - SHIP-00 for identity foundation
|
|
21
|
+
* - IPFS for decentralized storage
|
|
22
|
+
* - Smart contracts for relay payment system
|
|
23
|
+
* - Deterministic encryption from wallet signatures
|
|
24
|
+
*
|
|
25
|
+
* ## Dependencies
|
|
26
|
+
*
|
|
27
|
+
* - SHIP-00: Identity and authentication foundation
|
|
28
|
+
* - IPFS: Decentralized file storage
|
|
29
|
+
* - Ethereum: For relay subscription payments
|
|
30
|
+
* - shogun-ipfs: IPFS wrapper library
|
|
31
|
+
*
|
|
32
|
+
* ## Usage
|
|
33
|
+
*
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const identity = new SHIP_00({ gunOptions: { peers: ['...'] } });
|
|
36
|
+
* await identity.login('alice', 'password123');
|
|
37
|
+
*
|
|
38
|
+
* const storage = new SHIP_05(identity);
|
|
39
|
+
* await storage.initialize();
|
|
40
|
+
*
|
|
41
|
+
* // Upload encrypted file
|
|
42
|
+
* const result = await storage.uploadFile(file, { encrypt: true });
|
|
43
|
+
*
|
|
44
|
+
* // Download and decrypt
|
|
45
|
+
* const data = await storage.downloadFile(result.hash, { decrypt: true });
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.SHIP_05_EventType = void 0;
|
|
50
|
+
// ============================================================================
|
|
51
|
+
// EVENTS
|
|
52
|
+
// ============================================================================
|
|
53
|
+
var SHIP_05_EventType;
|
|
54
|
+
(function (SHIP_05_EventType) {
|
|
55
|
+
SHIP_05_EventType["FILE_UPLOADED"] = "fileUploaded";
|
|
56
|
+
SHIP_05_EventType["FILE_DOWNLOADED"] = "fileDownloaded";
|
|
57
|
+
SHIP_05_EventType["FILE_DELETED"] = "fileDeleted";
|
|
58
|
+
SHIP_05_EventType["ERROR"] = "error";
|
|
59
|
+
})(SHIP_05_EventType || (exports.SHIP_05_EventType = SHIP_05_EventType = {}));
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SHIP-06: Ephemeral P2P Messaging Interface
|
|
4
|
+
*
|
|
5
|
+
* @title ISHIP_06 - Ephemeral P2P Messaging
|
|
6
|
+
* @notice Interface for ephemeral peer-to-peer messaging via Gun Relay
|
|
7
|
+
* @dev Can work standalone OR with ISHIP_00 for authenticated sessions
|
|
8
|
+
*
|
|
9
|
+
* ## Abstract
|
|
10
|
+
*
|
|
11
|
+
* This standard defines an interface for ephemeral P2P messaging that allows:
|
|
12
|
+
* - Relay-based connections via Gun network
|
|
13
|
+
* - End-to-end encrypted messages (no storage)
|
|
14
|
+
* - Broadcast and direct messaging
|
|
15
|
+
* - Deterministic room discovery (SHA-256)
|
|
16
|
+
* - Standalone mode (no authentication needed!)
|
|
17
|
+
*
|
|
18
|
+
* ## Dependencies
|
|
19
|
+
*
|
|
20
|
+
* - Gun: Relay-based P2P database
|
|
21
|
+
* - Gun SEA: Cryptography (ECDH + AES-GCM)
|
|
22
|
+
* - ISHIP_00 (OPTIONAL): For authenticated sessions
|
|
23
|
+
*
|
|
24
|
+
* ## Modes
|
|
25
|
+
*
|
|
26
|
+
* **Standalone**: new SHIP_06(gunPeers[], roomId)
|
|
27
|
+
* **With Identity**: new SHIP_06(ISHIP_00, roomId)
|
|
28
|
+
*
|
|
29
|
+
* ## Inspiration
|
|
30
|
+
*
|
|
31
|
+
* Based on Bugoff (https://github.com/draeder/bugoff)
|
|
32
|
+
* Simplified for Gun relay instead of WebRTC
|
|
33
|
+
*/
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
// ============================================================================
|
|
36
|
+
// IMPLEMENTATION EXAMPLE
|
|
37
|
+
// ============================================================================
|
|
38
|
+
/**
|
|
39
|
+
* Example of how to implement ISHIP_06 with ISHIP_00 dependency
|
|
40
|
+
*
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import { ISHIP_00 } from './ISHIP_00';
|
|
43
|
+
* import { ISHIP_06, EphemeralMessage } from './ISHIP_06';
|
|
44
|
+
* import Bugout from 'bugout';
|
|
45
|
+
*
|
|
46
|
+
* class EphemeralMessaging implements ISHIP_06 {
|
|
47
|
+
* private bugout: any;
|
|
48
|
+
* private ephemeralPair: SEAPair | null = null;
|
|
49
|
+
* private peers: Map<string, PeerInfo> = new Map();
|
|
50
|
+
* private messageCallbacks: ((msg: EphemeralMessage) => void)[] = [];
|
|
51
|
+
*
|
|
52
|
+
* constructor(
|
|
53
|
+
* private identity: ISHIP_00,
|
|
54
|
+
* private roomId: string,
|
|
55
|
+
* private config?: EphemeralConfig
|
|
56
|
+
* ) {
|
|
57
|
+
* if (!identity.isLoggedIn()) {
|
|
58
|
+
* throw new Error('User must be authenticated via SHIP-00');
|
|
59
|
+
* }
|
|
60
|
+
* }
|
|
61
|
+
*
|
|
62
|
+
* getIdentity(): ISHIP_00 {
|
|
63
|
+
* return this.identity;
|
|
64
|
+
* }
|
|
65
|
+
*
|
|
66
|
+
* async connect(): Promise<void> {
|
|
67
|
+
* // 1. Generate ephemeral SEA pair
|
|
68
|
+
* const crypto = this.identity.shogun.db.crypto;
|
|
69
|
+
* this.ephemeralPair = await crypto.pair();
|
|
70
|
+
*
|
|
71
|
+
* // 2. Hash room ID
|
|
72
|
+
* const swarmId = await crypto.hashText(this.roomId);
|
|
73
|
+
*
|
|
74
|
+
* // 3. Create Bugout swarm
|
|
75
|
+
* this.bugout = new Bugout(swarmId, {
|
|
76
|
+
* iceServers: this.config?.iceServers
|
|
77
|
+
* });
|
|
78
|
+
*
|
|
79
|
+
* // 4. Set SEA pair
|
|
80
|
+
* await this.bugout.SEA(this.ephemeralPair);
|
|
81
|
+
*
|
|
82
|
+
* // 5. Listen for events
|
|
83
|
+
* this.bugout.on('seen', (address: string) => {
|
|
84
|
+
* this.handlePeerSeen(address);
|
|
85
|
+
* });
|
|
86
|
+
*
|
|
87
|
+
* this.bugout.on('decrypted', (address: string, pubkeys: any, message: string) => {
|
|
88
|
+
* this.handleMessage(address, pubkeys, message);
|
|
89
|
+
* });
|
|
90
|
+
* }
|
|
91
|
+
*
|
|
92
|
+
* disconnect(): void {
|
|
93
|
+
* if (this.bugout) {
|
|
94
|
+
* this.bugout.destroy();
|
|
95
|
+
* }
|
|
96
|
+
* }
|
|
97
|
+
*
|
|
98
|
+
* async sendBroadcast(message: string): Promise<void> {
|
|
99
|
+
* if (!this.bugout) {
|
|
100
|
+
* throw new Error('Not connected to swarm');
|
|
101
|
+
* }
|
|
102
|
+
*
|
|
103
|
+
* this.bugout.send(message);
|
|
104
|
+
* }
|
|
105
|
+
*
|
|
106
|
+
* async sendDirect(peerAddress: string, message: string): Promise<void> {
|
|
107
|
+
* if (!this.bugout) {
|
|
108
|
+
* throw new Error('Not connected to swarm');
|
|
109
|
+
* }
|
|
110
|
+
*
|
|
111
|
+
* this.bugout.send(peerAddress, message);
|
|
112
|
+
* }
|
|
113
|
+
*
|
|
114
|
+
* onMessage(callback: (message: EphemeralMessage) => void): void {
|
|
115
|
+
* this.messageCallbacks.push(callback);
|
|
116
|
+
* }
|
|
117
|
+
*
|
|
118
|
+
* private handleMessage(address: string, pubkeys: any, content: string) {
|
|
119
|
+
* const message: EphemeralMessage = {
|
|
120
|
+
* from: address,
|
|
121
|
+
* fromPubKey: pubkeys.pub,
|
|
122
|
+
* content,
|
|
123
|
+
* timestamp: Date.now(),
|
|
124
|
+
* type: 'broadcast'
|
|
125
|
+
* };
|
|
126
|
+
*
|
|
127
|
+
* this.messageCallbacks.forEach(cb => cb(message));
|
|
128
|
+
* }
|
|
129
|
+
* }
|
|
130
|
+
*
|
|
131
|
+
* // Usage
|
|
132
|
+
* const identity = new SHIP_00(config);
|
|
133
|
+
* await identity.login('alice', 'password123');
|
|
134
|
+
*
|
|
135
|
+
* const ephemeral = new EphemeralMessaging(identity, 'my-room');
|
|
136
|
+
* await ephemeral.connect();
|
|
137
|
+
*
|
|
138
|
+
* ephemeral.onMessage((msg) => {
|
|
139
|
+
* console.log(`${msg.from}: ${msg.content}`);
|
|
140
|
+
* });
|
|
141
|
+
*
|
|
142
|
+
* await ephemeral.sendBroadcast('Hello everyone!');
|
|
143
|
+
* ```
|
|
144
|
+
*/
|