Skip to content

computeWebSocketAccept

computeWebSocketAccept(key): Promise<string>

Defined in: packages/net-websocket/src/handshake/websocket-accept.ts:21

The Sec-WebSocket-Accept value proving a server read the client’s Sec-WebSocket-Key (RFC 6455 §4.2.2): the base64 SHA-1 of the key followed by the protocol’s GUID.

Not a security measure — SHA-1 is used here only because the protocol fixes it — but a handshake whose value does not match must be refused.

string

Promise<string>

await computeWebSocketAccept("dGhlIHNhbXBsZSBub25jZQ==");
// "s3pPLMBiTxaQ9kYGzzhZRbK+xOo="
```;