1'use strict' 2 3// This is a Globally Unique Identifier unique used 4// to validate that the endpoint accepts websocket 5// connections. 6// See https://www.rfc-editor.org/rfc/rfc6455.html#section-1.3 7const uid = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11' 8 9/** @type {PropertyDescriptor} */ 10const staticPropertyDescriptors = { 11 enumerable: true, 12 writable: false, 13 configurable: false 14} 15 16const states = { 17 CONNECTING: 0, 18 OPEN: 1, 19 CLOSING: 2, 20 CLOSED: 3 21} 22 23const opcodes = { 24 CONTINUATION: 0x0, 25 TEXT: 0x1, 26 BINARY: 0x2, 27 CLOSE: 0x8, 28 PING: 0x9, 29 PONG: 0xA 30} 31 32const maxUnsigned16Bit = 2 ** 16 - 1 // 65535 33 34const parserStates = { 35 INFO: 0, 36 PAYLOADLENGTH_16: 2, 37 PAYLOADLENGTH_64: 3, 38 READ_DATA: 4 39} 40 41const emptyBuffer = Buffer.allocUnsafe(0) 42 43module.exports = { 44 uid, 45 staticPropertyDescriptors, 46 states, 47 opcodes, 48 maxUnsigned16Bit, 49 parserStates, 50 emptyBuffer 51} 52