UNPKG

@bsv/authsocket

Version:

Mutually Authenticated Web Socket (Server-side)

27 lines 819 B
/** * Implements the Transport interface for a specific client socket. * * This transport simply relays AuthMessages over 'authMessage' * in the underlying Socket.IO connection. */ export class SocketServerTransport { socket; onDataCallback; constructor(socket) { this.socket = socket; } async send(message) { // We'll emit with a special low-level event named: 'authMessage' this.socket.emit('authMessage', message); } async onData(callback) { this.onDataCallback = callback; // Listen for 'authMessage' from the client this.socket.on('authMessage', async (msg) => { if (this.onDataCallback) { await this.onDataCallback(msg); } }); } } //# sourceMappingURL=SocketServerTransport.js.map