You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Client-side BRC-103 mutual authentication wrapper for socket.io-client. Signs all outbound messages and verifies inbound messages using a wallet, enabling authenticated peer-to-peer WebSocket communication.
Install
npm install @bsv/authsocket-client
Quick start
import{AuthSocketClient}from'@bsv/authsocket-client'import{PrivateKey,ProtoWallet}from'@bsv/sdk'constclientWallet=newProtoWallet(PrivateKey.fromHex('0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef'))constsocket=AuthSocketClient('http://localhost:3000',{wallet: clientWallet})socket.on('connect',()=>{console.log('Connected. Socket ID:',socket.id)socket.emit('chatMessage',{text: 'Hello from client!'})})socket.on('chatMessage',(msg)=>{console.log('Server says:',msg)})socket.on('disconnect',()=>{console.log('Disconnected')})
What it provides
AuthSocketClient — Wraps socket.io-client with BRC-103 authentication
Automatic message signing — All outbound messages signed with client wallet key
Automatic message verification — Inbound messages verified against server's public key