const crypto = require('crypto'); const { handshakeGUID } = require('./constants'); const generateWebsocketAcceptValue = (websocketKey) => { if (typeof websocketKey !== 'string' || typeof handshakeGUID !== 'string') { // TODO: maybe throw error? return; } const concatenated = websocketKey + handshakeGUID; const sha1HashInBase64 = crypto.createHash('sha1').update(concatenated, 'binary').digest('base64'); return sha1HashInBase64; }; module.exports = { generateWebsocketAcceptValue };