Skip to content

DaveManager

Manages the DAVE (Discord Audio/Video Encryption) MLS session lifecycle for a voice connection.

Owns the MLS session, encryptor, per-user decryptors, and SSRC-to-user-ID mapping. Opcode handlers return frames to send and roster IDs rather than performing I/O - the caller (Voice.Connection) is responsible for sending frames and firing events.

DaveManager.daveSession  :: Session?
DaveManager.pendingDaveProtocolVersion  :: number?
DaveManager.isPendingCommitter  :: boolean
DaveManager.daveEncryptor  :: Encryptor?
DaveManager.daveDecryptors  :: {
{ [string]: dave.Decryptor } }
DaveManager.recognizedUserIds  :: { string }
DaveManager.ssrcToUserId  :: {
{ [number]: string } }
DaveManager.logger  :: Logger
DaveManager : cleanup ( )  -> ()

Destroys the active DAVE session, encryptor, and all per-user decryptors, then resets all state.

DaveManager : rotateDaveKeys ( rosterIds userId ssrc )  -> ()

Updates the encryptor key ratchet and rebuilds per-user decryptors from the current MLS roster. Destroys decryptors for users no longer in the roster.

Parameters

rosterIds: { string }
userId: string
ssrc: number?
DaveManager : initSession ( protocolVersion channelId userId )  -> ()

Creates and initialises a new DAVE MLS session for the given protocol version, channel, and user.

Parameters

protocolVersion: number
channelId: string
userId: string
DaveManager : handlePrepareTransition ( payload )  -> buffer

Stores the incoming protocol version and returns a DaveProtocolTransitionReady frame to send to the server.

Parameters

payload: any

Returns

buffer
DaveManager : handleExecuteTransition ( _payload )  -> ()

Applies the pending protocol version to the active session and clears the pending state.

Parameters

_payload: any
DaveManager : handlePrepareEpoch ( payload channelId userId )  -> ()

Resets or creates the DAVE session in preparation for a new MLS epoch, then initialises it.

Parameters

payload: any
channelId: string
userId: string
DaveManager : handleExternalSender ( payload )  -> buffer?

Sets the MLS external sender and returns a DaveMlsKeyPackage frame for the server.

Parameters

payload: any

Returns

buffer?
DaveManager : handleProposals ( payload userId ssrc )  -> buffer?

Processes incoming MLS proposals and returns a commit+welcome frame and the current roster snapshot.

Parameters

payload: any
userId: string
ssrc: number?

Returns

buffer?
{ string }?
DaveManager : handleCommitTransition ( payload userId ssrc )  -> { string }?

Processes an MLS commit, advances the epoch, and rotates encryption keys for the new roster. Returns the updated roster member IDs, or nil if the commit was rejected or ignored.

Parameters

payload: any
userId: string
ssrc: number?
DaveManager : handleWelcome ( payload userId ssrc )  -> { string }?

Processes an MLS welcome for clients being added to an existing epoch, then rotates keys for the roster.

Parameters

payload: any
userId: string
ssrc: number?
DaveManager . new ( loggerInstance )  -> DaveManager

Responsible for constructing this class.

Parameters

loggerInstance: Logger

Returns

DaveManager