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.
Summary
Properties
DaveManager.daveSession :: dave.Session?DaveManager.pendingDaveProtocolVersion :: number?DaveManager.isPendingCommitter :: booleanDaveManager.daveEncryptor :: dave.Encryptor?DaveManager.daveDecryptors :: { [string]: dave.Decryptor }DaveManager.recognizedUserIds :: { string }DaveManager.ssrcToUserId :: { [number]: string }DaveManager.logger :: logger.LoggerMethods
DaveManager:cleanup()DaveManager:rotateDaveKeys(rosterIds: { string }, userId: string, ssrc: number?)DaveManager:initSession(protocolVersion: number, channelId: string, userId: string)DaveManager:handlePrepareTransition(payload: any) → bufferDaveManager:handleExecuteTransition(_payload: any)DaveManager:handlePrepareEpoch(payload: any, channelId: string, userId: string)DaveManager:handleExternalSender(payload: any) → buffer?DaveManager:handleProposals(payload: any, userId: string, ssrc: number?) → buffer?DaveManager:handleCommitTransition(payload: any, userId: string, ssrc: number?) → { string }?DaveManager:handleWelcome(payload: any, userId: string, ssrc: number?) → { string }?Properties
Section titled “Properties”daveSession
Section titled “daveSession”pendingDaveProtocolVersion
Section titled “pendingDaveProtocolVersion”isPendingCommitter
Section titled “isPendingCommitter”daveEncryptor
Section titled “daveEncryptor”daveDecryptors
Section titled “daveDecryptors”{ [string]: dave.Decryptor } }
recognizedUserIds
Section titled “recognizedUserIds”ssrcToUserId
Section titled “ssrcToUserId”{ [number]: string } }
logger
Section titled “logger”Methods
Section titled “Methods”cleanup
Section titled “cleanup”DaveManager : cleanup ( ) -> ()
Destroys the active DAVE session, encryptor, and all per-user decryptors, then resets all state.
rotateDaveKeys
Section titled “rotateDaveKeys”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? |
initSession
Section titled “initSession”DaveManager : initSession ( protocolVersion , channelId , userId ) -> ()
Creates and initialises a new DAVE MLS session for the given protocol version, channel, and user.
handlePrepareTransition
Section titled “handlePrepareTransition”DaveManager : handlePrepareTransition ( payload ) -> buffer
Stores the incoming protocol version and returns a DaveProtocolTransitionReady frame to send to the server.
Parameters
| payload: any |
Returns
| buffer |
handleExecuteTransition
Section titled “handleExecuteTransition”DaveManager : handleExecuteTransition ( _payload ) -> ()
Applies the pending protocol version to the active session and clears the pending state.
Parameters
| _payload: any |
handlePrepareEpoch
Section titled “handlePrepareEpoch”DaveManager : handlePrepareEpoch ( payload , channelId , userId ) -> ()
Resets or creates the DAVE session in preparation for a new MLS epoch, then initialises it.
handleExternalSender
Section titled “handleExternalSender”DaveManager : handleExternalSender ( payload ) -> buffer?
Sets the MLS external sender and returns a DaveMlsKeyPackage frame for the server.
Parameters
| payload: any |
Returns
| buffer? |
handleProposals
Section titled “handleProposals”DaveManager : handleProposals ( payload , userId , ssrc ) -> buffer?
Processes incoming MLS proposals and returns a commit+welcome frame and the current roster snapshot.
Returns
| buffer? | |
| { string }? |
handleCommitTransition
Section titled “handleCommitTransition”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.
Returns
| { string }? |
handleWelcome
Section titled “handleWelcome”DaveManager : handleWelcome ( payload , userId , ssrc ) -> { string }?
Processes an MLS welcome for clients being added to an existing epoch, then rotates keys for the roster.
Returns
| { string }? |
Functions
Section titled “Functions”DaveManager . new ( loggerInstance ) -> DaveManager
Responsible for constructing this class.
Parameters
| loggerInstance: Logger |
Returns
| DaveManager |