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,234 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* SHIP-06 Ephemeral Chat - STANDALONE
|
|
5
|
+
*
|
|
6
|
+
* NO login/password required!
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* tsx ship/examples/ephemeral-cli.ts <nickname> <room>
|
|
10
|
+
*
|
|
11
|
+
* Example:
|
|
12
|
+
* tsx ship/examples/ephemeral-cli.ts alice test-room
|
|
13
|
+
*/
|
|
14
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(o, k2, desc);
|
|
21
|
+
}) : (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
}));
|
|
25
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
26
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
27
|
+
}) : function(o, v) {
|
|
28
|
+
o["default"] = v;
|
|
29
|
+
});
|
|
30
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
31
|
+
var ownKeys = function(o) {
|
|
32
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
33
|
+
var ar = [];
|
|
34
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
35
|
+
return ar;
|
|
36
|
+
};
|
|
37
|
+
return ownKeys(o);
|
|
38
|
+
};
|
|
39
|
+
return function (mod) {
|
|
40
|
+
if (mod && mod.__esModule) return mod;
|
|
41
|
+
var result = {};
|
|
42
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
43
|
+
__setModuleDefault(result, mod);
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
const SHIP_06_1 = require("../implementation/SHIP_06");
|
|
49
|
+
const readline = __importStar(require("readline"));
|
|
50
|
+
// ============================================================================
|
|
51
|
+
// GUN PEERS
|
|
52
|
+
// ============================================================================
|
|
53
|
+
const GUN_PEERS = [
|
|
54
|
+
"https://v5g5jseqhgkp43lppgregcfbvi.srv.us/gun",
|
|
55
|
+
"https://relay.shogun-eco.xyz/gun",
|
|
56
|
+
"https://peer.wallie.io/gun",
|
|
57
|
+
];
|
|
58
|
+
// ============================================================================
|
|
59
|
+
// CLI
|
|
60
|
+
// ============================================================================
|
|
61
|
+
const rl = readline.createInterface({
|
|
62
|
+
input: process.stdin,
|
|
63
|
+
output: process.stdout,
|
|
64
|
+
});
|
|
65
|
+
function prompt(question) {
|
|
66
|
+
return new Promise((resolve) => {
|
|
67
|
+
rl.question(question, (answer) => {
|
|
68
|
+
resolve(answer);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
// ============================================================================
|
|
73
|
+
// MAIN
|
|
74
|
+
// ============================================================================
|
|
75
|
+
async function main() {
|
|
76
|
+
console.clear();
|
|
77
|
+
console.log("🗡️ SHOGUN EPHEMERAL CHAT");
|
|
78
|
+
console.log("=".repeat(70));
|
|
79
|
+
const args = process.argv.slice(2);
|
|
80
|
+
if (args.length < 2) {
|
|
81
|
+
console.log("Usage: tsx ephemeral-cli.ts <nickname> <room>");
|
|
82
|
+
console.log();
|
|
83
|
+
console.log("Example:");
|
|
84
|
+
console.log(" tsx ephemeral-cli.ts alice test-room");
|
|
85
|
+
console.log();
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
const [nickname, roomId] = args;
|
|
89
|
+
try {
|
|
90
|
+
console.log(`✅ Welcome ${nickname}!`);
|
|
91
|
+
console.log(`📡 Connecting to room: ${roomId}...`);
|
|
92
|
+
// Create ephemeral chat (NO login required!)
|
|
93
|
+
const ephemeral = new SHIP_06_1.SHIP_06(GUN_PEERS, roomId, { debug: false });
|
|
94
|
+
await ephemeral.connect();
|
|
95
|
+
console.log(`✅ Connected!`);
|
|
96
|
+
console.log();
|
|
97
|
+
// ========================================================================
|
|
98
|
+
// EVENTS
|
|
99
|
+
// ========================================================================
|
|
100
|
+
ephemeral.onPeerSeen((address) => {
|
|
101
|
+
console.log(`\n👋 Peer joined: ${address.substring(0, 12)}... (Total: ${ephemeral.getPeers().length})`);
|
|
102
|
+
displayPrompt();
|
|
103
|
+
});
|
|
104
|
+
ephemeral.onPeerLeft((address) => {
|
|
105
|
+
console.log(`\n👋 Peer left: ${address.substring(0, 12)}... (Total: ${ephemeral.getPeers().length})`);
|
|
106
|
+
displayPrompt();
|
|
107
|
+
});
|
|
108
|
+
ephemeral.onMessage((msg) => {
|
|
109
|
+
const time = new Date(msg.timestamp).toLocaleTimeString();
|
|
110
|
+
const icon = msg.type === "broadcast" ? "📢" : "📨";
|
|
111
|
+
console.log(`\n${icon} [${time}] ${msg.from.substring(0, 8)}...: ${msg.content}`);
|
|
112
|
+
displayPrompt();
|
|
113
|
+
});
|
|
114
|
+
// ========================================================================
|
|
115
|
+
// CHAT
|
|
116
|
+
// ========================================================================
|
|
117
|
+
console.log("💬 COMMANDS: /peers /direct /help /exit");
|
|
118
|
+
console.log("=".repeat(70));
|
|
119
|
+
console.log();
|
|
120
|
+
let running = true;
|
|
121
|
+
function displayPrompt() {
|
|
122
|
+
if (running) {
|
|
123
|
+
process.stdout.write(`\n${nickname}> `);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
displayPrompt();
|
|
127
|
+
while (running) {
|
|
128
|
+
const input = await prompt("");
|
|
129
|
+
if (!input.trim()) {
|
|
130
|
+
displayPrompt();
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
// Commands
|
|
134
|
+
if (input.startsWith("/")) {
|
|
135
|
+
const command = input.toLowerCase();
|
|
136
|
+
if (command === "/exit" || command === "/quit") {
|
|
137
|
+
console.log("\n👋 Bye!");
|
|
138
|
+
ephemeral.disconnect();
|
|
139
|
+
running = false;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
else if (command === "/peers") {
|
|
143
|
+
const peers = ephemeral.getPeers();
|
|
144
|
+
console.log(`\n👥 Peers (${peers.length}):`);
|
|
145
|
+
if (peers.length === 0) {
|
|
146
|
+
console.log(" No peers");
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
peers.forEach((peer, i) => {
|
|
150
|
+
console.log(` ${i + 1}. ${peer}`);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
console.log(); // Add blank line
|
|
154
|
+
displayPrompt(); // Show prompt again
|
|
155
|
+
continue; // Continue to next iteration
|
|
156
|
+
}
|
|
157
|
+
else if (command === "/debug") {
|
|
158
|
+
console.log("\n🔍 DEBUG INFO:");
|
|
159
|
+
console.log(` My address: ${ephemeral.getAddress()}`);
|
|
160
|
+
console.log(` Swarm ID: ${ephemeral.getSwarmId().substring(0, 32)}...`);
|
|
161
|
+
console.log(` Peers: ${ephemeral.getPeers().length}`);
|
|
162
|
+
console.log();
|
|
163
|
+
displayPrompt();
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
else if (command.startsWith("/direct")) {
|
|
167
|
+
const peers = ephemeral.getPeers();
|
|
168
|
+
if (peers.length === 0) {
|
|
169
|
+
console.log("\n❌ No peers");
|
|
170
|
+
console.log();
|
|
171
|
+
displayPrompt();
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
console.log("\n👥 Select peer:");
|
|
176
|
+
peers.forEach((peer, i) => {
|
|
177
|
+
console.log(` ${i + 1}. ${peer}`);
|
|
178
|
+
});
|
|
179
|
+
const peerIndex = await prompt("\nPeer number: ");
|
|
180
|
+
const selectedPeer = peers[parseInt(peerIndex) - 1];
|
|
181
|
+
if (selectedPeer) {
|
|
182
|
+
const message = await prompt("Message: ");
|
|
183
|
+
if (message.trim()) {
|
|
184
|
+
await ephemeral.sendDirect(selectedPeer, message);
|
|
185
|
+
console.log(`✅ Sent to ${selectedPeer.substring(0, 8)}...`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
console.log("❌ Invalid");
|
|
190
|
+
}
|
|
191
|
+
console.log();
|
|
192
|
+
displayPrompt();
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
else if (command === "/help") {
|
|
197
|
+
console.log("\n💬 COMMANDS:");
|
|
198
|
+
console.log(" /peers - List peers");
|
|
199
|
+
console.log(" /direct - Direct message");
|
|
200
|
+
console.log(" /help - This help");
|
|
201
|
+
console.log(" /exit - Exit");
|
|
202
|
+
console.log();
|
|
203
|
+
displayPrompt();
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
console.log(`\n❌ Unknown: ${command}`);
|
|
208
|
+
displayPrompt();
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
// Send broadcast
|
|
213
|
+
try {
|
|
214
|
+
await ephemeral.sendBroadcast(input);
|
|
215
|
+
const time = new Date().toLocaleTimeString();
|
|
216
|
+
console.log(`📢 [${time}] You: ${input}`);
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
console.error(`\n❌ Error: ${error.message}`);
|
|
220
|
+
}
|
|
221
|
+
displayPrompt();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
console.error("\n❌ Error:", error);
|
|
226
|
+
process.exit(1);
|
|
227
|
+
}
|
|
228
|
+
rl.close();
|
|
229
|
+
process.exit(0);
|
|
230
|
+
}
|
|
231
|
+
main().catch((error) => {
|
|
232
|
+
console.error("Fatal error:", error);
|
|
233
|
+
process.exit(1);
|
|
234
|
+
});
|