
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
@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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.