Harden Chrome bridge framing and preserve panel state for IDE beta 7
This commit is contained in:
1 parent
fb6f57cd36
commit
57876d11f0
8 files changed
+192
-18
No files matched your search
@@ -223,7 +223,7 @@ export async function startChromeBridge({ directory, resolveBackend }) {
|
||||
let message
|
||||
try { message = JSON.parse(line) } catch { socket.destroy(); return }
|
||||
if (!authenticated) {
|
||||
if (typeof message.token !== 'string' || message.token.length !== token.length ||
|
||||
if (!message || typeof message.token !== 'string' || !/^[a-f0-9]{64}$/.test(message.token) ||
|
||||
!timingSafeEqual(Buffer.from(message.token), Buffer.from(token))) { socket.destroy(); return }
|
||||
authenticated = true
|
||||
clearTimeout(timer)
|
||||
@@ -245,8 +245,13 @@ export async function startChromeBridge({ directory, resolveBackend }) {
|
||||
server.listen(`\\\\.\\pipe\\${pipe}`, resolve)
|
||||
})
|
||||
const temporary = `${discovery}.${process.pid}.tmp`
|
||||
await writeFile(temporary, JSON.stringify({ protocol: 1, pipe, token }), { mode: 0o600 })
|
||||
await rename(temporary, discovery)
|
||||
try {
|
||||
await writeFile(temporary, JSON.stringify({ protocol: 1, pipe, token }), { mode: 0o600 })
|
||||
await rename(temporary, discovery)
|
||||
} catch (error) {
|
||||
server.close()
|
||||
throw error
|
||||
}
|
||||
return async () => {
|
||||
for (const socket of sockets) socket.destroy()
|
||||
server.close()
|
||||
|
||||
Reference in new issue
Block a user