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 sha1HashedInBase64 = crypto.createHash('sha1').update(concatenated, 'binary').digest('base64'); return sha1HashedInBase64; }; module.exports = { generateWebsocketAcceptValue };