Fix web client: gracefully handle CLI members in groups
- fetchPeerKey: catch JSON parse error for CLI bincode bundles, show clear "CLI client — needs WASM bridge" message - Group send: silently skip CLI members instead of showing error per member (mixed groups work, web members get messages, CLI members are skipped without noise) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -250,9 +250,15 @@ async function fetchPeerKey(peerFP) {
|
|||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
const bundleBytes = Uint8Array.from(atob(data.bundle), c => c.charCodeAt(0));
|
const bundleBytes = Uint8Array.from(atob(data.bundle), c => c.charCodeAt(0));
|
||||||
const bundleStr = new TextDecoder().decode(bundleBytes);
|
const bundleStr = new TextDecoder().decode(bundleBytes);
|
||||||
const bundle = JSON.parse(bundleStr);
|
|
||||||
|
|
||||||
if (bundle.type !== 'web') throw new Error('Peer is CLI client (incompatible crypto). Use CLI to chat with them.');
|
let bundle;
|
||||||
|
try {
|
||||||
|
bundle = JSON.parse(bundleStr);
|
||||||
|
} catch(e) {
|
||||||
|
throw new Error('CLI client — cannot encrypt (different crypto, needs WASM bridge)');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bundle.type !== 'web') throw new Error('CLI client — cannot encrypt (different crypto)');
|
||||||
|
|
||||||
const aesKey = await deriveAESKey(bundle.jwk);
|
const aesKey = await deriveAESKey(bundle.jwk);
|
||||||
derivedKeys[fp] = aesKey;
|
derivedKeys[fp] = aesKey;
|
||||||
@@ -459,11 +465,11 @@ async function sendToGroup(groupName, text) {
|
|||||||
message: Array.from(new TextEncoder().encode(envelope))
|
message: Array.from(new TextEncoder().encode(envelope))
|
||||||
});
|
});
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
addSys('Failed to encrypt for ' + memberFP.slice(0,8) + ': ' + e.message);
|
// Silently skip CLI members (different crypto)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (messages.length === 0) return;
|
if (messages.length === 0) { addSys('No compatible web members to send to'); return; }
|
||||||
|
|
||||||
await fetch(SERVER + '/v1/groups/' + groupName + '/send', {
|
await fetch(SERVER + '/v1/groups/' + groupName + '/send', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
Reference in New Issue
Block a user