shogun-core 3.3.4 → 3.3.5

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.
@@ -1,66 +1,101 @@
1
1
  /**
2
- * SHIP-06: Ephemeral P2P Messaging Implementation
2
+ * SHIP-06: Secure Vault Implementation
3
3
  *
4
- * Two modes:
5
- * 1. Standalone: new SHIP_06(gunPeers[], roomId) - NO authentication!
6
- * - Uses ShogunCore internally with silent: true, disableAutoRecall: true
7
- * - Zero logs, zero storage, pure relay communication
8
- * - Room hashed with Web Crypto API SHA-256 for deterministic IDs
4
+ * Vault crittografato decentralizzato che dipende da SHIP-00 per l'identità.
9
5
  *
10
- * 2. With Identity: new SHIP_06(ISHIP_00, roomId) - Authenticated sessions
11
- * - Uses existing Gun instance from SHIP-00
12
- * - All ShogunCore features available
6
+ * Dipendenze:
7
+ * - SHIP-00 (Identity & Authentication) - per gestione utenti e chiavi
8
+ * - GunDB - per storage decentralizzato P2P
9
+ * - SEA - per crittografia AES-256-GCM
13
10
  *
14
- * Architecture:
15
- * - Gun Relay for P2P communication (no WebRTC complexity!)
16
- * - SEA for ephemeral key generation and ECDH encryption
17
- * - Pure relay mode: radisk: false, localStorage: false, multicast: false
11
+ * Ispirato a: https://github.com/draeder/gunsafe
18
12
  */
19
13
  import type { ISHIP_00 } from "../interfaces/ISHIP_00";
20
- import type { ISHIP_06, EphemeralMessage, EphemeralConfig, PeerInfo } from "../interfaces/ISHIP_06";
21
- import type { SEAPair } from "../interfaces/ISHIP_00";
14
+ import type { ISHIP_06, VaultRecord, VaultResult, VaultStats, RecordMetadata, GetOptions, ListOptions, ImportOptions, ExportOptions } from "../interfaces/ISHIP_06";
15
+ /**
16
+ * SHIP-06 Reference Implementation
17
+ *
18
+ * Questa implementazione dipende da ISHIP_00 per tutte le operazioni di identità.
19
+ * Si concentra esclusivamente sulla logica del vault crittografato.
20
+ */
22
21
  declare class SHIP_06 implements ISHIP_06 {
23
22
  private identity;
24
- private roomId;
25
- private config;
26
- private connected;
27
- private swarmId;
28
- private myAddress;
29
- private myPair;
30
- private gun;
31
- private sea;
32
- private roomNode;
33
- private presenceNode;
34
- private messagesNode;
35
- private peers;
36
- private messageHandlers;
37
- private encryptedMessageHandlers;
38
- private peerSeenHandlers;
39
- private peerLeftHandlers;
40
- private heartbeatInterval;
41
- private processedMessages;
42
- constructor(identityOrPeers: ISHIP_00 | string[], roomId: string, config?: Partial<EphemeralConfig> | {
43
- debug?: boolean;
44
- });
23
+ private initialized;
24
+ private vaultNodeName;
25
+ private vaultNode;
26
+ private recordsNode;
27
+ private metadataNode;
28
+ private static readonly VAULT_VERSION;
29
+ private static readonly DEFAULT_NODE_NAME;
30
+ /**
31
+ * Constructor
32
+ * @param identity ISHIP_00 instance for identity operations
33
+ * @param vaultNodeName Optional custom vault node name
34
+ */
35
+ constructor(identity: ISHIP_00, vaultNodeName?: string);
36
+ /**
37
+ * Get identity provider
38
+ */
45
39
  getIdentity(): ISHIP_00;
46
- connect(): Promise<void>;
47
- disconnect(): void;
48
- isConnected(): boolean;
49
- getSwarmId(): string;
50
- getAddress(): string;
51
- private announcePresence;
52
- private startHeartbeat;
53
- private listenForPeers;
54
- sendBroadcast(message: string): Promise<void>;
55
- sendDirect(peerAddress: string, message: string): Promise<void>;
56
- private listenForMessages;
57
- onMessage(callback: (message: EphemeralMessage) => void): void;
58
- onPeerSeen(callback: (address: string) => void): void;
59
- onPeerLeft(callback: (address: string) => void): void;
60
- onEncryptedMessage(callback: (address: string, data: any) => void): void;
61
- getPeers(): string[];
62
- getPeerInfo(address: string): PeerInfo | null;
63
- getEphemeralPair(): Promise<SEAPair>;
64
- setEphemeralPair(pair: SEAPair): Promise<void>;
40
+ /**
41
+ * Initialize vault
42
+ */
43
+ initialize(): Promise<void>;
44
+ /**
45
+ * Check if vault is initialized
46
+ */
47
+ isInitialized(): boolean;
48
+ /**
49
+ * Store encrypted record in vault
50
+ */
51
+ put(name: string, data: any, metadata?: RecordMetadata): Promise<VaultResult>;
52
+ /**
53
+ * Retrieve and decrypt record from vault
54
+ */
55
+ get(name: string, options?: GetOptions): Promise<VaultRecord | null>;
56
+ /**
57
+ * Delete record from vault (soft delete)
58
+ */
59
+ delete(name?: string): Promise<VaultResult>;
60
+ /**
61
+ * List all record names in vault
62
+ */
63
+ list(options?: ListOptions): Promise<string[]>;
64
+ /**
65
+ * Check if record exists
66
+ */
67
+ exists(name: string): Promise<boolean>;
68
+ /**
69
+ * Update existing record
70
+ */
71
+ update(name: string, data: any): Promise<VaultResult>;
72
+ /**
73
+ * Export entire vault (encrypted)
74
+ */
75
+ export(password?: string, options?: ExportOptions): Promise<string>;
76
+ /**
77
+ * Import vault from backup
78
+ */
79
+ import(backupData: string, password?: string, options?: ImportOptions): Promise<VaultResult>;
80
+ /**
81
+ * Get vault statistics
82
+ */
83
+ getStats(): Promise<VaultStats>;
84
+ /**
85
+ * Clear all records (soft delete all)
86
+ */
87
+ clear(): Promise<VaultResult>;
88
+ /**
89
+ * Compact vault (remove deleted records permanently)
90
+ */
91
+ compact(): Promise<VaultResult>;
92
+ /**
93
+ * Search records by content
94
+ */
95
+ search(query: string): Promise<string[]>;
96
+ /**
97
+ * Update record count in metadata
98
+ */
99
+ private updateRecordCount;
65
100
  }
66
101
  export { SHIP_06 };