From 739ec66898919c3a3f2fd35503eb1c7b3871f924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20Da=C3=9Fler?= Date: Thu, 18 Sep 2025 14:15:33 +0200 Subject: [PATCH] Fixed encoding issue: changed from btoa(String.fromCharCode(...)) to Buffer.from().toString('base64') --- implementations/Libp2pComponent.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/implementations/Libp2pComponent.ts b/implementations/Libp2pComponent.ts index ef26d2b..9364cfb 100644 --- a/implementations/Libp2pComponent.ts +++ b/implementations/Libp2pComponent.ts @@ -218,11 +218,9 @@ export class Libp2pComponent implements ILibp2pComponent { tcpPort: this.options.config?.tcpPort, wsPort: this.options.config?.wsPort, // Convert Uint8Array to base64 for passing to native module - keypair: this.options.keypair - ? { - privateKey: btoa(String.fromCharCode(...this.options.keypair.privateKey)), - publicKey: btoa(String.fromCharCode(...this.options.keypair.publicKey)), - } + // Using Buffer.from for proper encoding of binary data + privateKey: this.options.keypair?.privateKey + ? Buffer.from(this.options.keypair.privateKey).toString('base64') : undefined, };