diff --git a/package.json b/package.json index b5e4987..046de54 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@xtr-dev/rondevu-client", - "version": "0.8.2", + "version": "0.8.3", "description": "TypeScript client for Rondevu DNS-like WebRTC with username claiming and service discovery", "type": "module", "main": "dist/index.js", diff --git a/src/usernames.ts b/src/usernames.ts index 97d74a6..543fdf3 100644 --- a/src/usernames.ts +++ b/src/usernames.ts @@ -1,7 +1,8 @@ import * as ed25519 from '@noble/ed25519'; // Set SHA-512 hash function for ed25519 (required in @noble/ed25519 v3+) -// Uses built-in WebCrypto API +// Uses built-in WebCrypto API which only provides async digest +// We use the async ed25519 functions (signAsync, verifyAsync, getPublicKeyAsync) ed25519.hashes.sha512Async = async (message: Uint8Array) => { return new Uint8Array(await crypto.subtle.digest('SHA-512', message as BufferSource)); }; @@ -58,7 +59,7 @@ export class RondevuUsername { */ async generateKeypair(): Promise<{ publicKey: string; privateKey: string }> { const privateKey = ed25519.utils.randomSecretKey(); - const publicKey = await ed25519.getPublicKey(privateKey); + const publicKey = await ed25519.getPublicKeyAsync(privateKey); return { publicKey: bytesToBase64(publicKey), @@ -74,7 +75,7 @@ export class RondevuUsername { const encoder = new TextEncoder(); const messageBytes = encoder.encode(message); - const signature = await ed25519.sign(messageBytes, privateKey); + const signature = await ed25519.signAsync(messageBytes, privateKey); return bytesToBase64(signature); }