Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
const wsOpen = cmdline === 'bash websocket open'
if (wsOpen) {
// N is the random identifier for this connection
const N = uuid()
const session = existingSession || {
uid,
gid,
token: uuid() // use a different uuid for the session cookie
}
const sessionToken = Buffer.from(JSON.stringify(session)).toString('base64')
const cookie = { key: sessionKey, session }
const { wss } = await wssMain(N, server, port, cookie)
debug('spawning subprocess')
const child = spawn(process.argv[0], [mainPath, 'bash', 'websocket', 'stdio'], options)
child.on('error', err => {
console.error('error spawning subprocess', err)
reject(err)
})
child.on('exit', code => {
debug('subprocess exit', code)
})
const channel = new StdioChannelWebsocketSide(wss)
await channel.init(child, process.env.KUI_HEARTBEAT_INTERVAL || 30000)