Simple utility to generate a websocket handshake hash/response.
$ npm install --save websocket-handshake
Import the module
const { getResponseHash, getResponseHeaders } = require('websocket-handshake');
Create the handshake response hash
const hash = getResponseHash('dGhlIHNhbXBsZSBub25jZQ==');
// => s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
Create the handshake response headers
const request = { ... }; // instance of http.ServerRequest
const headers = getResponseHeaders(request);
// => HTTP/1.1 101 Switching Protocols
// Upgrade: websocket
// Connection: Upgrade
// Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
MIT © Vu Tran