
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
@bsv/authsocket
Advanced tools
This repository provides a drop-in server-side solution for Socket.IO that enforces BRC-103 mutual authentication on all connected clients.
It pairs seamlessly with the authsocket-client library, which handles the client side of this handshake. However, if you are building your own client logic, you only need to ensure it also speaks BRC-103 and can sign/verify messages accordingly.
npm install
Wallet implementation (for instance from @bsv/sdk or your own custom code) that can sign and verify messages.Below is a minimal Express + HTTP + Socket.IO + authsocket server. You can adapt it to your own setup (e.g. Fastify, Koa, etc.) since only the raw http.Server is needed for Socket.IO.
import express from 'express'
import http from 'http'
import { AuthSocketServer } from '@bsv/authsocket'
import { ProtoWallet } from '@bsv/sdk' // your BRC-103 compatible wallet
const app = express()
const server = http.createServer(app)
const port = 3000
// Example: create or load your BRC-103 wallet
const serverWallet = new ProtoWallet('my-private-key-hex')
// Wrap your HTTP server with AuthSocketServer
// which internally wraps the Socket.IO server.
const io = new AuthSocketServer(server, {
wallet: serverWallet,
cors: {
origin: '*'
}
})
// Use it like standard Socket.IO
io.on('connection', (socket) => {
console.log('New Authenticated Connection -> socket ID:', socket.id)
// Listen for chat messages
socket.on('chatMessage', (msg) => {
console.log('Received message from client:', msg)
// Reply to the client
socket.emit('chatMessage', { from: socket.id, text: 'Hello from server!' })
})
socket.on('disconnect', () => {
console.log(`Socket ${socket.id} disconnected`)
})
})
server.listen(port, () => {
console.log(`Server listening on port ${port}`)
})
AuthSocketServer with the wallet option.'connection', you receive an AuthSocket instance that works like a normal Socket.IO socket: socket.on(...), socket.emit(...), etc.AuthSocketServer sets up a BRC-103 Peer with a corresponding transport (SocketServerTransport).'authMessage' channel are processed for authenticity and re-dispatched as your normal 'chatMessage' (or any other event name).AuthSocketServer:
SocketServerTransport.Peer for that connection.AuthSocket for your convenience.socket.id with their associated Peer.AuthSocket:
on(eventName, callback) and emit(eventName, data) (just like a normal Socket.IO socket).Peer to sign outbound messages and verify inbound ones.Transport interface for server-side usage.socket.on('authMessage', ...) from the Socket.IO layer.Peer for handshake steps (signature verification, certificate exchange, etc.).socket.emit('authMessage', ...).See LICENSE.txt.
FAQs
Mutually Authenticated Web Socket (Server-side)
We found that @bsv/authsocket demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.