fix(broker): libsodium dynamic import — extract .default for bun
await import('libsodium-wrappers') returns the namespace object in
bun, not the sodium API. randombytes_buf et al. live on .default.
Without this, every topic_create on the deployed broker errored
with 'sodium.randombytes_buf is not a function' and the WS handler
silently dropped — CLI saw a 5s timeout.
Confirmed via broker docker logs:
warn ws message error: sodium.randombytes_buf is not a function
Same destructure pattern as crypto.ts (which uses the synchronous
default import).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -634,7 +634,7 @@ async function generateTopicKeyBundle(): Promise<{
|
||||
senderPubkey: Uint8Array;
|
||||
senderPubkeyHex: string;
|
||||
}> {
|
||||
const sodium = await import("libsodium-wrappers");
|
||||
const sodium = (await import("libsodium-wrappers")).default;
|
||||
await sodium.ready;
|
||||
const topicKey = sodium.randombytes_buf(32);
|
||||
const sender = sodium.crypto_box_keypair();
|
||||
@@ -674,7 +674,7 @@ async function sealTopicKeyForMember(args: {
|
||||
.where(eq(memberTable.id, args.memberId));
|
||||
if (!member) return;
|
||||
|
||||
const sodium = await import("libsodium-wrappers");
|
||||
const sodium = (await import("libsodium-wrappers")).default;
|
||||
await sodium.ready;
|
||||
let recipientX25519: Uint8Array;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user