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.
- package/dist/browser/defaultVendors-node_modules_shogun-ipfs_node_modules_axios_index_js.shogun-core.js +4073 -2
- package/dist/browser/defaultVendors-node_modules_shogun-ipfs_node_modules_axios_index_js.shogun-core.js.map +1 -0
- package/dist/browser/shogun-core.js +597 -343
- package/dist/browser/shogun-core.js.map +1 -1
- package/dist/ship/examples/identity-cli.js +12 -4
- package/dist/ship/examples/vault-cli.js +2 -2
- package/dist/ship/implementation/SHIP_06.js +574 -289
- package/dist/ship/interfaces/ISHIP_06.js +135 -85
- package/dist/src/gundb/db.js +7 -49
- package/dist/types/ship/implementation/SHIP_06.d.ts +90 -55
- package/dist/types/ship/interfaces/ISHIP_06.d.ts +383 -231
- package/package.json +2 -8
- package/dist/ship/examples/ephemeral-cli.js +0 -234
- package/dist/ship/implementation/SHIP_07.js +0 -635
- package/dist/ship/interfaces/ISHIP_07.js +0 -194
- package/dist/types/ship/examples/ephemeral-cli.d.ts +0 -13
- package/dist/types/ship/implementation/SHIP_07.d.ts +0 -101
- package/dist/types/ship/interfaces/ISHIP_07.d.ts +0 -522
|
@@ -1,194 +0,0 @@
|
|
|
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
|
-
*/
|
|
@@ -1,13 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SHIP-07: Secure Vault Implementation
|
|
3
|
-
*
|
|
4
|
-
* Vault crittografato decentralizzato 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 AES-256-GCM
|
|
10
|
-
*
|
|
11
|
-
* Ispirato a: https://github.com/draeder/gunsafe
|
|
12
|
-
*/
|
|
13
|
-
import type { ISHIP_00 } from "../interfaces/ISHIP_00";
|
|
14
|
-
import type { ISHIP_07, VaultRecord, VaultResult, VaultStats, RecordMetadata, GetOptions, ListOptions, ImportOptions, ExportOptions } from "../interfaces/ISHIP_07";
|
|
15
|
-
/**
|
|
16
|
-
* SHIP-07 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
|
-
*/
|
|
21
|
-
declare class SHIP_07 implements ISHIP_07 {
|
|
22
|
-
private identity;
|
|
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
|
-
*/
|
|
39
|
-
getIdentity(): ISHIP_00;
|
|
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;
|
|
100
|
-
}
|
|
101
|
-
export { SHIP_07 };
|