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,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SHIP-07: Secure Vault Interface
|
|
4
|
+
*
|
|
5
|
+
* @title ISHIP_07 - Secure Encrypted Vault
|
|
6
|
+
* @notice Interface for secure encrypted key-value storage on GunDB
|
|
7
|
+
* @dev This interface depends on ISHIP_00 for identity and encryption
|
|
8
|
+
*
|
|
9
|
+
* ## Abstract
|
|
10
|
+
*
|
|
11
|
+
* This standard defines an interface for secure vault storage that allows:
|
|
12
|
+
* - End-to-end encrypted key-value storage
|
|
13
|
+
* - Soft delete with recovery
|
|
14
|
+
* - Export/import for backup
|
|
15
|
+
* - Rich metadata support
|
|
16
|
+
* - Simple, secure, focused on storage only
|
|
17
|
+
*
|
|
18
|
+
* ## Dependencies
|
|
19
|
+
*
|
|
20
|
+
* - ISHIP_00: Identity and authentication layer
|
|
21
|
+
* - GunDB: P2P storage
|
|
22
|
+
* - SEA: Cryptography (AES-256-GCM)
|
|
23
|
+
*
|
|
24
|
+
* ## Inspiration
|
|
25
|
+
*
|
|
26
|
+
* Based on Gunsafe (https://github.com/draeder/gunsafe)
|
|
27
|
+
* Adapted for Shogun ecosystem with SHIP-00 integration
|
|
28
|
+
*/
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
// ============================================================================
|
|
31
|
+
// IMPLEMENTATION EXAMPLE
|
|
32
|
+
// ============================================================================
|
|
33
|
+
/**
|
|
34
|
+
* Example of how to implement ISHIP_07 with ISHIP_00 dependency
|
|
35
|
+
*
|
|
36
|
+
* ```typescript
|
|
37
|
+
* import { ISHIP_00 } from './ISHIP_00';
|
|
38
|
+
* import { ISHIP_07, VaultRecord, VaultResult } from './ISHIP_07';
|
|
39
|
+
*
|
|
40
|
+
* class SecureVault implements ISHIP_07 {
|
|
41
|
+
* private vaultNode: any;
|
|
42
|
+
* private initialized: boolean = false;
|
|
43
|
+
*
|
|
44
|
+
* constructor(private identity: ISHIP_00) {
|
|
45
|
+
* if (!identity.isLoggedIn()) {
|
|
46
|
+
* throw new Error('User must be authenticated via SHIP-00');
|
|
47
|
+
* }
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* getIdentity(): ISHIP_00 {
|
|
51
|
+
* return this.identity;
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
54
|
+
* async initialize(): Promise<void> {
|
|
55
|
+
* // Get Gun user node
|
|
56
|
+
* const gun = this.identity.shogun.db.gun;
|
|
57
|
+
* this.vaultNode = gun.user().get('vault').get('records');
|
|
58
|
+
*
|
|
59
|
+
* // Initialize vault metadata
|
|
60
|
+
* await gun.user().get('vault').get('metadata').put({
|
|
61
|
+
* version: '1.0.0',
|
|
62
|
+
* created: Date.now().toString()
|
|
63
|
+
* });
|
|
64
|
+
*
|
|
65
|
+
* this.initialized = true;
|
|
66
|
+
* }
|
|
67
|
+
*
|
|
68
|
+
* isInitialized(): boolean {
|
|
69
|
+
* return this.initialized;
|
|
70
|
+
* }
|
|
71
|
+
*
|
|
72
|
+
* async put(name: string, data: any, metadata?: RecordMetadata): Promise<VaultResult> {
|
|
73
|
+
* if (!this.initialized) {
|
|
74
|
+
* return { success: false, error: 'Vault not initialized' };
|
|
75
|
+
* }
|
|
76
|
+
*
|
|
77
|
+
* try {
|
|
78
|
+
* // Get SEA crypto
|
|
79
|
+
* const crypto = this.identity.shogun.db.crypto;
|
|
80
|
+
* const pair = this.identity.getKeyPair();
|
|
81
|
+
*
|
|
82
|
+
* if (!pair) {
|
|
83
|
+
* return { success: false, error: 'Cannot access key pair' };
|
|
84
|
+
* }
|
|
85
|
+
*
|
|
86
|
+
* // Encrypt data
|
|
87
|
+
* const encryptedData = await crypto.encrypt(
|
|
88
|
+
* JSON.stringify(data),
|
|
89
|
+
* pair.epriv
|
|
90
|
+
* );
|
|
91
|
+
*
|
|
92
|
+
* // Encrypt metadata if provided
|
|
93
|
+
* const encryptedMetadata = metadata
|
|
94
|
+
* ? await crypto.encrypt(JSON.stringify(metadata), pair.epriv)
|
|
95
|
+
* : undefined;
|
|
96
|
+
*
|
|
97
|
+
* // Store in vault
|
|
98
|
+
* const record = {
|
|
99
|
+
* data: encryptedData,
|
|
100
|
+
* created: Date.now().toString(),
|
|
101
|
+
* updated: Date.now().toString(),
|
|
102
|
+
* deleted: false,
|
|
103
|
+
* metadata: encryptedMetadata
|
|
104
|
+
* };
|
|
105
|
+
*
|
|
106
|
+
* await this.vaultNode.get(name).put(record);
|
|
107
|
+
*
|
|
108
|
+
* return { success: true, recordName: name };
|
|
109
|
+
* } catch (error: any) {
|
|
110
|
+
* return { success: false, error: error.message };
|
|
111
|
+
* }
|
|
112
|
+
* }
|
|
113
|
+
*
|
|
114
|
+
* async get(name: string, options?: GetOptions): Promise<VaultRecord | null> {
|
|
115
|
+
* if (!this.initialized) {
|
|
116
|
+
* return null;
|
|
117
|
+
* }
|
|
118
|
+
*
|
|
119
|
+
* try {
|
|
120
|
+
* // Retrieve from vault
|
|
121
|
+
* const encryptedRecord = await this.vaultNode.get(name).then();
|
|
122
|
+
*
|
|
123
|
+
* if (!encryptedRecord || !encryptedRecord.data) {
|
|
124
|
+
* return null;
|
|
125
|
+
* }
|
|
126
|
+
*
|
|
127
|
+
* // Skip if deleted (unless includeDeleted)
|
|
128
|
+
* if (encryptedRecord.deleted && !options?.includeDeleted) {
|
|
129
|
+
* return null;
|
|
130
|
+
* }
|
|
131
|
+
*
|
|
132
|
+
* // Decrypt data
|
|
133
|
+
* const crypto = this.identity.shogun.db.crypto;
|
|
134
|
+
* const pair = this.identity.getKeyPair();
|
|
135
|
+
*
|
|
136
|
+
* if (!pair) {
|
|
137
|
+
* return null;
|
|
138
|
+
* }
|
|
139
|
+
*
|
|
140
|
+
* const decryptedData = await crypto.decrypt(
|
|
141
|
+
* encryptedRecord.data,
|
|
142
|
+
* pair.epriv
|
|
143
|
+
* );
|
|
144
|
+
*
|
|
145
|
+
* // Decrypt metadata if present
|
|
146
|
+
* const decryptedMetadata = encryptedRecord.metadata
|
|
147
|
+
* ? JSON.parse(await crypto.decrypt(encryptedRecord.metadata, pair.epriv))
|
|
148
|
+
* : undefined;
|
|
149
|
+
*
|
|
150
|
+
* return {
|
|
151
|
+
* name,
|
|
152
|
+
* data: JSON.parse(decryptedData),
|
|
153
|
+
* created: parseInt(encryptedRecord.created),
|
|
154
|
+
* updated: parseInt(encryptedRecord.updated),
|
|
155
|
+
* deleted: encryptedRecord.deleted,
|
|
156
|
+
* metadata: decryptedMetadata
|
|
157
|
+
* };
|
|
158
|
+
* } catch (error) {
|
|
159
|
+
* console.error('Error retrieving record:', error);
|
|
160
|
+
* return null;
|
|
161
|
+
* }
|
|
162
|
+
* }
|
|
163
|
+
*
|
|
164
|
+
* async delete(name?: string): Promise<VaultResult> {
|
|
165
|
+
* // Implementation here
|
|
166
|
+
* return { success: true };
|
|
167
|
+
* }
|
|
168
|
+
*
|
|
169
|
+
* async list(options?: ListOptions): Promise<string[]> {
|
|
170
|
+
* // Implementation here
|
|
171
|
+
* return [];
|
|
172
|
+
* }
|
|
173
|
+
*
|
|
174
|
+
* // ... implement other methods
|
|
175
|
+
* }
|
|
176
|
+
*
|
|
177
|
+
* // Usage
|
|
178
|
+
* const identity = new SHIP_00(config);
|
|
179
|
+
* await identity.login('alice', 'password123');
|
|
180
|
+
*
|
|
181
|
+
* const vault = new SecureVault(identity);
|
|
182
|
+
* await vault.initialize();
|
|
183
|
+
*
|
|
184
|
+
* // Store encrypted data
|
|
185
|
+
* await vault.put('my-password', 'super_secret', {
|
|
186
|
+
* type: 'password',
|
|
187
|
+
* description: 'GitHub password'
|
|
188
|
+
* });
|
|
189
|
+
*
|
|
190
|
+
* // Retrieve decrypted data
|
|
191
|
+
* const record = await vault.get('my-password');
|
|
192
|
+
* console.log('Password:', record?.data);
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* SHIP-06 Ephemeral Chat - STANDALONE
|
|
4
|
+
*
|
|
5
|
+
* NO login/password required!
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* tsx ship/examples/ephemeral-cli.ts <nickname> <room>
|
|
9
|
+
*
|
|
10
|
+
* Example:
|
|
11
|
+
* tsx ship/examples/ephemeral-cli.ts alice test-room
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* SHIP-00 Identity CLI Example
|
|
4
|
+
*
|
|
5
|
+
* Interactive CLI demonstrating SHIP-00 identity and authentication
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* yarn identity <username> <password>
|
|
9
|
+
*
|
|
10
|
+
* Features:
|
|
11
|
+
* - User signup and login
|
|
12
|
+
* - Login with keypair (multi-device)
|
|
13
|
+
* - Public key publication
|
|
14
|
+
* - User discovery and lookup
|
|
15
|
+
* - Key pair export/import
|
|
16
|
+
* - Ethereum address derivation
|
|
17
|
+
*/
|
|
18
|
+
declare class IdentityCLI {
|
|
19
|
+
private identity;
|
|
20
|
+
private rl;
|
|
21
|
+
private username;
|
|
22
|
+
private running;
|
|
23
|
+
constructor();
|
|
24
|
+
login(username: string, password: string): Promise<boolean>;
|
|
25
|
+
loginWithKeypair(): Promise<void>;
|
|
26
|
+
exportKeypair(): Promise<void>;
|
|
27
|
+
showCurrentUser(): Promise<void>;
|
|
28
|
+
showPublicKey(): Promise<void>;
|
|
29
|
+
lookupUser(): Promise<void>;
|
|
30
|
+
lookupByPublicKey(): Promise<void>;
|
|
31
|
+
showMenu(): Promise<void>;
|
|
32
|
+
deriveAddress(): Promise<void>;
|
|
33
|
+
publishPublicKey(): Promise<void>;
|
|
34
|
+
logout(): Promise<void>;
|
|
35
|
+
private printHeader;
|
|
36
|
+
prompt(question: string): Promise<string>;
|
|
37
|
+
cleanup(): void;
|
|
38
|
+
start(username?: string, password?: string): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
export { IdentityCLI };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Shogun Chat - CLI Interface
|
|
4
|
+
*
|
|
5
|
+
* End-to-end encrypted decentralized chat
|
|
6
|
+
* Simple and functional CLI interface
|
|
7
|
+
*/
|
|
8
|
+
export declare class MessengerCLI {
|
|
9
|
+
private identity;
|
|
10
|
+
private messaging;
|
|
11
|
+
private rl;
|
|
12
|
+
private currentUser;
|
|
13
|
+
private recipient;
|
|
14
|
+
private derivedAddress;
|
|
15
|
+
private isAuthenticated;
|
|
16
|
+
private channelToken;
|
|
17
|
+
private currentChannel;
|
|
18
|
+
constructor();
|
|
19
|
+
private setupHandlers;
|
|
20
|
+
private withTimeout;
|
|
21
|
+
login(username: string, password: string): Promise<boolean>;
|
|
22
|
+
private sendMessage;
|
|
23
|
+
private onMessageReceived;
|
|
24
|
+
private onChannelMessageReceived;
|
|
25
|
+
private exportKeyPair;
|
|
26
|
+
private importKeyPair;
|
|
27
|
+
private loginWithPair;
|
|
28
|
+
private wipeAllMessages;
|
|
29
|
+
private handleCommand;
|
|
30
|
+
private joinChannel;
|
|
31
|
+
private leaveChannel;
|
|
32
|
+
private showHelp;
|
|
33
|
+
private showStatus;
|
|
34
|
+
private showHeader;
|
|
35
|
+
private updatePrompt;
|
|
36
|
+
start(): Promise<void>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* SHIP-03 Stealth Address CLI Example
|
|
4
|
+
*
|
|
5
|
+
* Demonstrates dual-key stealth addresses with Fluidkey integration
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* yarn stealth <username> <password>
|
|
9
|
+
*/
|
|
10
|
+
declare class StealthCLI {
|
|
11
|
+
private identity;
|
|
12
|
+
private eth;
|
|
13
|
+
private stealth;
|
|
14
|
+
private rl;
|
|
15
|
+
constructor();
|
|
16
|
+
login(username: string, password: string): Promise<boolean>;
|
|
17
|
+
register(username: string, password: string): Promise<boolean>;
|
|
18
|
+
showStealthKeys(): Promise<void>;
|
|
19
|
+
generateStealthAddress(): Promise<void>;
|
|
20
|
+
openStealthAddress(): Promise<void>;
|
|
21
|
+
batchGenerateStealthAddresses(): Promise<void>;
|
|
22
|
+
scanForStealthPayments(): Promise<void>;
|
|
23
|
+
showMenu(): Promise<void>;
|
|
24
|
+
lookupUserKeys(): Promise<void>;
|
|
25
|
+
exportKeys(): Promise<void>;
|
|
26
|
+
publishKeys(): Promise<void>;
|
|
27
|
+
showWalletInfo(): Promise<void>;
|
|
28
|
+
prompt(question: string): Promise<string>;
|
|
29
|
+
close(): void;
|
|
30
|
+
}
|
|
31
|
+
export { StealthCLI };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* SHIP-05 Storage CLI Example
|
|
4
|
+
*
|
|
5
|
+
* Interactive CLI demonstrating SHIP-05 encrypted file storage on IPFS
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* yarn storage <username> <password>
|
|
9
|
+
*
|
|
10
|
+
* Features:
|
|
11
|
+
* - Encrypted file upload to IPFS (uses SEA from SHIP-00)
|
|
12
|
+
* - Multiple IPFS services (Pinata, IPFS Client, Custom Gateway)
|
|
13
|
+
* - File download and decryption
|
|
14
|
+
* - File metadata management
|
|
15
|
+
* - Storage statistics
|
|
16
|
+
*/
|
|
17
|
+
declare class StorageCLI {
|
|
18
|
+
private identity;
|
|
19
|
+
private storage;
|
|
20
|
+
private rl;
|
|
21
|
+
private username;
|
|
22
|
+
private running;
|
|
23
|
+
private ipfsService;
|
|
24
|
+
private ipfsConfig;
|
|
25
|
+
private configFile;
|
|
26
|
+
constructor();
|
|
27
|
+
login(username: string, password: string): Promise<boolean>;
|
|
28
|
+
configureIPFS(): Promise<void>;
|
|
29
|
+
configurePinata(): Promise<void>;
|
|
30
|
+
configureIPFSClient(): Promise<void>;
|
|
31
|
+
configureCustomGateway(): Promise<void>;
|
|
32
|
+
saveIPFSConfig(): void;
|
|
33
|
+
loadIPFSConfig(): boolean;
|
|
34
|
+
uploadFile(): Promise<void>;
|
|
35
|
+
downloadFile(): Promise<void>;
|
|
36
|
+
viewUserFiles(): Promise<void>;
|
|
37
|
+
deleteFile(): Promise<void>;
|
|
38
|
+
showStorageStats(): Promise<void>;
|
|
39
|
+
testEncryption(): Promise<void>;
|
|
40
|
+
showMenu(): Promise<void>;
|
|
41
|
+
reconfigureIPFS(): Promise<void>;
|
|
42
|
+
logout(): Promise<void>;
|
|
43
|
+
private printHeader;
|
|
44
|
+
prompt(question: string): Promise<string>;
|
|
45
|
+
cleanup(): void;
|
|
46
|
+
start(username?: string, password?: string): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
export { StorageCLI };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* SHIP-07 Secure Vault CLI Example
|
|
4
|
+
*
|
|
5
|
+
* Test secure encrypted vault with SHIP-07
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* tsx ship/examples/vault-cli.ts <username> <password>
|
|
9
|
+
*
|
|
10
|
+
* Example:
|
|
11
|
+
* tsx ship/examples/vault-cli.ts alice pass123
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHIP-02 Example: Ethereum Wallet CLI
|
|
3
|
+
*
|
|
4
|
+
* Interactive CLI demonstrating SHIP-02 HD wallet derivation
|
|
5
|
+
* Built on top of SHIP-00 identity
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* yarn wallet <username> <password>
|
|
9
|
+
*
|
|
10
|
+
* Features:
|
|
11
|
+
* - Derive Ethereum addresses from identity (no mnemonics!)
|
|
12
|
+
* - BIP-44 HD wallet support
|
|
13
|
+
* - Sign transactions and messages
|
|
14
|
+
* - Export/import address book
|
|
15
|
+
* - Gun persistence
|
|
16
|
+
*
|
|
17
|
+
* Note: For stealth addresses, use `yarn stealth` (SHIP-03)
|
|
18
|
+
*/
|
|
19
|
+
declare class WalletCLI {
|
|
20
|
+
private identity;
|
|
21
|
+
private wallet;
|
|
22
|
+
private rl;
|
|
23
|
+
private username;
|
|
24
|
+
private running;
|
|
25
|
+
constructor(username: string, password: string);
|
|
26
|
+
/**
|
|
27
|
+
* Start the CLI
|
|
28
|
+
*/
|
|
29
|
+
start(password: string): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Authenticate user with SHIP-00
|
|
32
|
+
*/
|
|
33
|
+
private authenticate;
|
|
34
|
+
/**
|
|
35
|
+
* Initialize SHIP-02 wallet
|
|
36
|
+
*/
|
|
37
|
+
private initializeWallet;
|
|
38
|
+
/**
|
|
39
|
+
* Main menu loop
|
|
40
|
+
*/
|
|
41
|
+
private mainMenu;
|
|
42
|
+
/**
|
|
43
|
+
* View all addresses
|
|
44
|
+
*/
|
|
45
|
+
private viewAddresses;
|
|
46
|
+
/**
|
|
47
|
+
* Derive new address with custom index
|
|
48
|
+
*/
|
|
49
|
+
private deriveNewAddress;
|
|
50
|
+
/**
|
|
51
|
+
* Derive BIP-44 address with custom parameters
|
|
52
|
+
*/
|
|
53
|
+
private deriveBIP44Address;
|
|
54
|
+
/**
|
|
55
|
+
* Derive multiple addresses at once
|
|
56
|
+
*/
|
|
57
|
+
private deriveMultipleAddresses;
|
|
58
|
+
/**
|
|
59
|
+
* Import address book
|
|
60
|
+
*/
|
|
61
|
+
private importAddressBook;
|
|
62
|
+
/**
|
|
63
|
+
* Export encrypted wallet data
|
|
64
|
+
*/
|
|
65
|
+
private exportWalletData;
|
|
66
|
+
/**
|
|
67
|
+
* Sync with Gun database
|
|
68
|
+
*/
|
|
69
|
+
private syncWithGun;
|
|
70
|
+
/**
|
|
71
|
+
* View/Export mnemonic
|
|
72
|
+
*/
|
|
73
|
+
private viewExportMnemonic;
|
|
74
|
+
/**
|
|
75
|
+
* Verify addresses match MetaMask
|
|
76
|
+
*/
|
|
77
|
+
private verifyMetaMaskAddresses;
|
|
78
|
+
/**
|
|
79
|
+
* Sign message
|
|
80
|
+
*/
|
|
81
|
+
private signMessage;
|
|
82
|
+
/**
|
|
83
|
+
* Sign transaction
|
|
84
|
+
*/
|
|
85
|
+
private signTransaction;
|
|
86
|
+
/**
|
|
87
|
+
* Export address book
|
|
88
|
+
*/
|
|
89
|
+
private exportAddressBook;
|
|
90
|
+
/**
|
|
91
|
+
* View master public key
|
|
92
|
+
*/
|
|
93
|
+
private viewMasterPublicKey;
|
|
94
|
+
/**
|
|
95
|
+
* Create wallet using frontend API
|
|
96
|
+
*/
|
|
97
|
+
private createWalletFrontendAPI;
|
|
98
|
+
/**
|
|
99
|
+
* Load all wallets using frontend API
|
|
100
|
+
*/
|
|
101
|
+
private loadAllWallets;
|
|
102
|
+
/**
|
|
103
|
+
* View main wallet (derived from Gun keys)
|
|
104
|
+
*/
|
|
105
|
+
private viewMainWallet;
|
|
106
|
+
/**
|
|
107
|
+
* Export all user data (complete backup)
|
|
108
|
+
*/
|
|
109
|
+
private exportAllUserData;
|
|
110
|
+
/**
|
|
111
|
+
* Set RPC provider URL
|
|
112
|
+
*/
|
|
113
|
+
private setRpcProvider;
|
|
114
|
+
/**
|
|
115
|
+
* Send transaction via RPC
|
|
116
|
+
*/
|
|
117
|
+
private sendTransactionRPC;
|
|
118
|
+
/**
|
|
119
|
+
* Print header
|
|
120
|
+
*/
|
|
121
|
+
private printHeader;
|
|
122
|
+
/**
|
|
123
|
+
* Prompt user for input
|
|
124
|
+
*/
|
|
125
|
+
private prompt;
|
|
126
|
+
/**
|
|
127
|
+
* Cleanup and exit
|
|
128
|
+
*/
|
|
129
|
+
private cleanup;
|
|
130
|
+
}
|
|
131
|
+
export { WalletCLI };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHIP-00: Decentralized Identity & Authentication Implementation
|
|
3
|
+
*
|
|
4
|
+
* Foundation layer for the Shogun ecosystem.
|
|
5
|
+
* Provides identity and authentication services for all other SHIPs.
|
|
6
|
+
*
|
|
7
|
+
* Based on:
|
|
8
|
+
* - Shogun Core API (see ../API.md)
|
|
9
|
+
* - GunDB for P2P identity storage
|
|
10
|
+
* - SEA for cryptographic operations
|
|
11
|
+
* - shogun-derive for address derivation
|
|
12
|
+
*
|
|
13
|
+
* Features:
|
|
14
|
+
* ✅ Username/password authentication
|
|
15
|
+
* ✅ SEA key pair management
|
|
16
|
+
* ✅ Public key publication and discovery
|
|
17
|
+
* ✅ User registry and lookup
|
|
18
|
+
* ✅ Blockchain address derivation
|
|
19
|
+
* ✅ Multi-device support (export/import)
|
|
20
|
+
*/
|
|
21
|
+
import type { ISHIP_00, SignupResult, AuthResult, OperationResult, SEAPair, UserIdentity, UserData, PublicKeyData } from "../interfaces/ISHIP_00";
|
|
22
|
+
import { ShogunCoreConfig } from "../../src/interfaces/shogun";
|
|
23
|
+
/**
|
|
24
|
+
* SHIP-00 Reference Implementation
|
|
25
|
+
*
|
|
26
|
+
* Uses Shogun Core as the underlying implementation.
|
|
27
|
+
* This class wraps Shogun Core APIs to provide the ISHIP_00 standard interface.
|
|
28
|
+
*/
|
|
29
|
+
declare class SHIP_00 implements ISHIP_00 {
|
|
30
|
+
private shogun;
|
|
31
|
+
static readonly NODES: {
|
|
32
|
+
readonly USERS: "users";
|
|
33
|
+
readonly PUBLIC_KEYS: "publicKeys";
|
|
34
|
+
readonly REGISTRY: "registry";
|
|
35
|
+
};
|
|
36
|
+
constructor(shogunConfig: ShogunCoreConfig);
|
|
37
|
+
/**
|
|
38
|
+
* Register new user
|
|
39
|
+
* Uses Shogun Core signUp method (see API.md)
|
|
40
|
+
*/
|
|
41
|
+
signup(username: string, password: string): Promise<SignupResult>;
|
|
42
|
+
/**
|
|
43
|
+
* Login with username and password
|
|
44
|
+
* Uses Shogun Core login method (see API.md)
|
|
45
|
+
*/
|
|
46
|
+
login(username: string, password: string): Promise<AuthResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Login with SEA Key Pair
|
|
49
|
+
* Uses Shogun Core loginWithPair method (see API.md)
|
|
50
|
+
*/
|
|
51
|
+
loginWithPair(seaPair: SEAPair): Promise<AuthResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Logout
|
|
54
|
+
* Uses Shogun Core logout method (see API.md line 325)
|
|
55
|
+
*/
|
|
56
|
+
logout(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Check if user is logged in
|
|
59
|
+
* Uses Shogun Core isLoggedIn method (see API.md line 326)
|
|
60
|
+
*/
|
|
61
|
+
isLoggedIn(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Get underlying ShogunCore instance
|
|
64
|
+
* Provides access to Gun, SEA, and crypto utilities
|
|
65
|
+
*/
|
|
66
|
+
getShogun(): any;
|
|
67
|
+
/**
|
|
68
|
+
* Publish public key on GunDB
|
|
69
|
+
* Makes user's public key discoverable by others
|
|
70
|
+
*/
|
|
71
|
+
publishPublicKey(): Promise<OperationResult>;
|
|
72
|
+
/**
|
|
73
|
+
* Export current user's SEA key pair
|
|
74
|
+
* For backup and multi-device usage
|
|
75
|
+
* Uses Shogun Core exportPair method (see API.md line 354)
|
|
76
|
+
*/
|
|
77
|
+
exportKeyPair(): SEAPair | null;
|
|
78
|
+
/**
|
|
79
|
+
* Get current user's key pair
|
|
80
|
+
* Alias for exportKeyPair()
|
|
81
|
+
*/
|
|
82
|
+
getKeyPair(): SEAPair | null;
|
|
83
|
+
/**
|
|
84
|
+
* Get user information by username
|
|
85
|
+
* Uses Shogun Core getUserByAlias method (see API.md line 1141-1148)
|
|
86
|
+
*/
|
|
87
|
+
getUserByAlias(username: string): Promise<UserData | null>;
|
|
88
|
+
/**
|
|
89
|
+
* Get user information by public key
|
|
90
|
+
* Uses Shogun Core getUserDataByPub method (see API.md line 1150-1152)
|
|
91
|
+
*/
|
|
92
|
+
getUserByPub(userPub: string): Promise<UserData | null>;
|
|
93
|
+
/**
|
|
94
|
+
* Check if user exists
|
|
95
|
+
* Uses SimpleGunAPI userExists method (see API.md line 188)
|
|
96
|
+
*/
|
|
97
|
+
userExists(username: string): Promise<boolean>;
|
|
98
|
+
/**
|
|
99
|
+
* Get public key by username
|
|
100
|
+
*/
|
|
101
|
+
getPublicKey(username: string): Promise<PublicKeyData | null>;
|
|
102
|
+
/**
|
|
103
|
+
* Get current authenticated user info
|
|
104
|
+
* Uses Shogun Core getCurrentUser method (see API.md line 429)
|
|
105
|
+
*/
|
|
106
|
+
getCurrentUser(): UserIdentity | null;
|
|
107
|
+
/**
|
|
108
|
+
* Derive Ethereum address from SEA keypair
|
|
109
|
+
* Uses shogun-derive package for deterministic derivation
|
|
110
|
+
*/
|
|
111
|
+
deriveEthereumAddress(publicKey?: string): Promise<string>;
|
|
112
|
+
}
|
|
113
|
+
export { SHIP_00 };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHIP-01: Decentralized Encrypted Messaging Implementation
|
|
3
|
+
*
|
|
4
|
+
* Messaggistica decentralizzata E2E che dipende da SHIP-00 per l'identità.
|
|
5
|
+
*
|
|
6
|
+
* Dipendenze:
|
|
7
|
+
* - SHIP-00 (Identity & Authentication) - per gestione utenti e chiavi
|
|
8
|
+
* - GunDB - per storage decentralizzato P2P
|
|
9
|
+
* - SEA - per crittografia ECDH + AES-GCM
|
|
10
|
+
*
|
|
11
|
+
* Vantaggi dell'architettura modulare:
|
|
12
|
+
* ✅ Separazione delle responsabilità (Identity vs Messaging)
|
|
13
|
+
* ✅ Riusabilità di SHIP-00 in altre applicazioni
|
|
14
|
+
* ✅ Testing più semplice e isolato
|
|
15
|
+
* ✅ Manutenibilità migliorata
|
|
16
|
+
*/
|
|
17
|
+
import type { ISHIP_00 } from "../interfaces/ISHIP_00";
|
|
18
|
+
import type { ISHIP_01, SendMessageResult, DecryptedMessage, MessageHistoryEntry } from "../interfaces/ISHIP_01";
|
|
19
|
+
/**
|
|
20
|
+
* SHIP-01 Reference Implementation
|
|
21
|
+
*
|
|
22
|
+
* Questa implementazione dipende da ISHIP_00 per tutte le operazioni di identità.
|
|
23
|
+
* Si concentra esclusivamente sulla logica di messaggistica.
|
|
24
|
+
*/
|
|
25
|
+
declare class SHIP_01 implements ISHIP_01 {
|
|
26
|
+
private identity;
|
|
27
|
+
static readonly NODES: {
|
|
28
|
+
readonly MESSAGES: "messages";
|
|
29
|
+
readonly TOKEN_MESSAGES: "token_messages";
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Constructor
|
|
33
|
+
* @param identity ISHIP_00 instance for identity operations
|
|
34
|
+
*/
|
|
35
|
+
constructor(identity: ISHIP_00);
|
|
36
|
+
/**
|
|
37
|
+
* Get identity provider
|
|
38
|
+
*/
|
|
39
|
+
getIdentity(): ISHIP_00;
|
|
40
|
+
/**
|
|
41
|
+
* Send encrypted message to a user
|
|
42
|
+
* Uses identity provider (SHIP-00) to get keys
|
|
43
|
+
*/
|
|
44
|
+
sendMessage(recipientUsername: string, message: string): Promise<SendMessageResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Listen for incoming encrypted messages
|
|
47
|
+
* Uses identity provider (SHIP-00) to decrypt messages
|
|
48
|
+
*/
|
|
49
|
+
listenForMessages(onMessage: (message: DecryptedMessage) => void): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Get message history with a user
|
|
52
|
+
* Uses identity provider (SHIP-00) to decrypt messages
|
|
53
|
+
*/
|
|
54
|
+
getMessageHistory(withUsername: string): Promise<MessageHistoryEntry[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Decrypt a message using ECDH
|
|
57
|
+
* Uses identity provider (SHIP-00) to get keys
|
|
58
|
+
*/
|
|
59
|
+
private decryptMessage;
|
|
60
|
+
/**
|
|
61
|
+
* Get public key by pub key
|
|
62
|
+
* Uses identity provider internally
|
|
63
|
+
*/
|
|
64
|
+
private getPublicKeyByPub;
|
|
65
|
+
/**
|
|
66
|
+
* Generate unique message ID
|
|
67
|
+
*/
|
|
68
|
+
private generateMessageId;
|
|
69
|
+
/**
|
|
70
|
+
* Send message encrypted with shared token/password
|
|
71
|
+
* Useful for group chats, channels, broadcast messages
|
|
72
|
+
*/
|
|
73
|
+
sendMessageWithToken(token: string, message: string, channel?: string): Promise<SendMessageResult>;
|
|
74
|
+
/**
|
|
75
|
+
* Listen for token-encrypted messages
|
|
76
|
+
* Automatically decrypts with provided token
|
|
77
|
+
*/
|
|
78
|
+
listenForTokenMessages(token: string, onMessage: (message: any) => void, channel?: string): Promise<void>;
|
|
79
|
+
}
|
|
80
|
+
export { SHIP_01 };
|