shogun-core 3.3.0 → 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/browser/shogun-core.js +83301 -148719
- package/dist/browser/shogun-core.js.map +1 -1
- package/dist/ship/examples/ephemeral-cli.js +234 -0
- package/dist/ship/examples/identity-cli.js +503 -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/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_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/src/index.js +1 -15
- 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/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/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_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/dist/types/src/index.d.ts +0 -10
- package/dist/types/src/types/shogun.d.ts +2 -0
- package/package.json +1 -1
- package/dist/browser/_e6ae.shogun-core.js +0 -14
- package/dist/browser/_e6ae.shogun-core.js.map +0 -1
|
@@ -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
|
+
*/
|
|
@@ -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
|
+
*/
|
package/dist/src/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.autoQuickStart = exports.AutoQuickStart = exports.createSimpleAPI = exports.quickStart = exports.QuickStart = exports.SimpleGunAPI = exports.DataBase = exports.GunErrors = exports.derive = exports.crypto = exports.RxJS = exports.SEA = exports.ShogunCore = exports.Gun =
|
|
20
|
+
exports.autoQuickStart = exports.AutoQuickStart = exports.createSimpleAPI = exports.quickStart = exports.QuickStart = exports.SimpleGunAPI = exports.DataBase = exports.GunErrors = exports.derive = exports.crypto = exports.RxJS = exports.SEA = exports.ShogunCore = exports.Gun = void 0;
|
|
21
21
|
const core_1 = require("./core");
|
|
22
22
|
Object.defineProperty(exports, "ShogunCore", { enumerable: true, get: function () { return core_1.ShogunCore; } });
|
|
23
23
|
const db_1 = require("./gundb/db");
|
|
@@ -42,17 +42,3 @@ __exportStar(require("./utils/errorHandler"), exports);
|
|
|
42
42
|
__exportStar(require("./plugins"), exports);
|
|
43
43
|
__exportStar(require("./interfaces/shogun"), exports);
|
|
44
44
|
__exportStar(require("./config/simplified-config"), exports);
|
|
45
|
-
var SHIP_00_1 = require("../ship/implementation/SHIP_00");
|
|
46
|
-
Object.defineProperty(exports, "SHIP_00", { enumerable: true, get: function () { return SHIP_00_1.SHIP_00; } });
|
|
47
|
-
var SHIP_01_1 = require("../ship/implementation/SHIP_01");
|
|
48
|
-
Object.defineProperty(exports, "SHIP_01", { enumerable: true, get: function () { return SHIP_01_1.SHIP_01; } });
|
|
49
|
-
var SHIP_02_1 = require("../ship/implementation/SHIP_02");
|
|
50
|
-
Object.defineProperty(exports, "SHIP_02", { enumerable: true, get: function () { return SHIP_02_1.SHIP_02; } });
|
|
51
|
-
var SHIP_03_1 = require("../ship/implementation/SHIP_03");
|
|
52
|
-
Object.defineProperty(exports, "SHIP_03", { enumerable: true, get: function () { return SHIP_03_1.SHIP_03; } });
|
|
53
|
-
// Export CLI tools only in Node.js environment (not browser)
|
|
54
|
-
// This prevents "readline is not a function" errors in browser builds
|
|
55
|
-
var messenger_cli_1 = require("../ship/examples/messenger-cli");
|
|
56
|
-
Object.defineProperty(exports, "MessengerCLI", { enumerable: true, get: function () { return messenger_cli_1.MessengerCLI; } });
|
|
57
|
-
var wallet_cli_1 = require("../ship/examples/wallet-cli");
|
|
58
|
-
Object.defineProperty(exports, "WalletCLI", { enumerable: true, get: function () { return wallet_cli_1.WalletCLI; } });
|
|
@@ -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,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 {};
|