New: a threat-model-first guide to choosing your network defence, plus the nym-smoldvpn dVPN package and nym-swizzle sender hygiene.
Developers
TypeDoc Reference
Classes
MixWebSocket

@nymproject/mix-websocketDocs


@nymproject/mix-websocket / MixWebSocket

Class: MixWebSocket

WebSocket-like channel over the Nym mixnet. The tunnel must already be set up (setupMixTunnel()) before constructing one.

Differences from the browser WebSocket:

  • Constructor resolves asynchronously; use await ws.opened() if you need to block until the upgrade completes.
  • binaryType is fixed to arraybuffer (no Blob support).
  • No bufferedAmount; the tunnel queues writes through the worker.

Extends

  • EventTarget

Constructors

new MixWebSocket()

new MixWebSocket(url, protocols?): MixWebSocket

Parameters

url: string

protocols?: string | string[]

Returns

MixWebSocket

Overrides

EventTarget.constructor

Source

mix-websocket/src/index.ts:44 (opens in a new tab)

Properties

url

readonly url: string

Source

mix-websocket/src/index.ts:38 (opens in a new tab)


protocols

readonly protocols: string[]

Source

mix-websocket/src/index.ts:39 (opens in a new tab)


handleIdPromise

private handleIdPromise: Promise<number>

Source

mix-websocket/src/index.ts:41 (opens in a new tab)


state

private state: MixWebSocketReadyState = CONNECTING

Source

mix-websocket/src/index.ts:42 (opens in a new tab)

Accessors

readyState

get readyState(): MixWebSocketReadyState

Returns

MixWebSocketReadyState

Source

mix-websocket/src/index.ts:76 (opens in a new tab)

Methods

opened()

opened(): Promise<void>

Block until the WebSocket transitions out of CONNECTING. Resolves when open fires (or when the connection fails before opening).

Returns

Promise<void>

Source

mix-websocket/src/index.ts:84 (opens in a new tab)


send()

send(data): Promise<void>

Parameters

data: string | ArrayBuffer | Uint8Array

Returns

Promise<void>

Source

mix-websocket/src/index.ts:97 (opens in a new tab)


close()

close(code, reason): Promise<void>

Parameters

code: number= 1000

reason: string= ''

Returns

Promise<void>

Source

mix-websocket/src/index.ts:106 (opens in a new tab)


handleEvent()

private handleEvent(type, data): void

Parameters

type: WsEventType

data: unknown

Returns

void

Source

mix-websocket/src/index.ts:114 (opens in a new tab)