Fixed encoding issue: changed from btoa(String.fromCharCode(...)) to Buffer.from().toString('base64')

This commit is contained in:
Chris Daßler
2025-09-18 14:15:33 +02:00
parent 7e46005c6f
commit 739ec66898

View File

@@ -218,11 +218,9 @@ export class Libp2pComponent implements ILibp2pComponent {
tcpPort: this.options.config?.tcpPort, tcpPort: this.options.config?.tcpPort,
wsPort: this.options.config?.wsPort, wsPort: this.options.config?.wsPort,
// Convert Uint8Array to base64 for passing to native module // Convert Uint8Array to base64 for passing to native module
keypair: this.options.keypair // Using Buffer.from for proper encoding of binary data
? { privateKey: this.options.keypair?.privateKey
privateKey: btoa(String.fromCharCode(...this.options.keypair.privateKey)), ? Buffer.from(this.options.keypair.privateKey).toString('base64')
publicKey: btoa(String.fromCharCode(...this.options.keypair.publicKey)),
}
: undefined, : undefined,
}; };