Skip to content

~.dave

DAVE

DAVETransition dataclass

DAVETransition(
    transition_id: int, epoch_id: int | None = None
)

Represents a pending DAVE protocol transition.

transition_id instance-attribute

transition_id: int

The unique identifier for this transition.

epoch_id class-attribute instance-attribute

epoch_id: int | None = None

The MLS epoch ID for epoch transitions - None for downgrades.

DAVEManager

DAVEManager(gateway: VoiceGateway)

Manages DAVE protocol operations.

Create a DAVE protocol manager.

PARAMETER DESCRIPTION
gateway

The voice gateway connection.

TYPE: VoiceGateway

ready property

ready: bool

Check if DAVE is ready for encryption/decryption.

session property

session: davey.DaveSession | None

Get the current DAVE session.

voice_privacy_code property

voice_privacy_code: str | None

Get the voice privacy code for the current group.

parse_frame staticmethod

parse_frame(frame: bytes) -> tuple[int, Opcode, bytes]

Parse a DAVE frame into a sequence, opcode, and payload.

PARAMETER DESCRIPTION
frame

The raw payload from the gateway.

TYPE: bytes

RETURNS DESCRIPTION
tuple[int, Opcode, bytes]

The sequence, operation code, and payload from the frame.

RAISES DESCRIPTION
GatewayError

If the frame was too short to parse.

decrypt

decrypt(user_id: int, packet: bytes) -> bytes

Decrypt a DAVE E2EE encrypted packet.

PARAMETER DESCRIPTION
user_id

The ID of the user that sent the packet.

TYPE: int

packet

The encrypted audio packet.

TYPE: bytes

RETURNS DESCRIPTION
bytes

The decrypted packet - Untouched if DAVE not ready.

encrypt_opus

encrypt_opus(opus: bytes) -> bytes

Encrypt an Opus audio packet with DAVE E2EE.

PARAMETER DESCRIPTION
opus

The Opus audio to encrypt.

TYPE: bytes

RETURNS DESCRIPTION
bytes

The encrypted Opus audio - Untouched if DAVE not ready.

get_verification_code

get_verification_code(user_id: int) -> str | None

Get the verification code for another user in the group.

PARAMETER DESCRIPTION
user_id

The ID of the user to verify.

TYPE: int

RETURNS DESCRIPTION
str | None

The verification code, or None if not available.

handle_commit async

handle_commit(payload: bytes) -> None

Handle an announced MLS commit.

PARAMETER DESCRIPTION
payload

The serialized commit data.

TYPE: bytes

handle_execute_transition async

handle_execute_transition(transition_id: int) -> None

Handle execution of a prepared transition.

PARAMETER DESCRIPTION
transition_id

The transition identifier.

TYPE: int

handle_prepare_epoch async

handle_prepare_epoch(
    transition_id: int, epoch_id: int
) -> None

Handle an epoch transition preparation.

PARAMETER DESCRIPTION
transition_id

The transition identifier.

TYPE: int

epoch_id

The MLS epoch identifier.

TYPE: int

handle_prepare_transition async

handle_prepare_transition(
    transition_id: int, protocol_version: int
) -> None

Handle a downgrade transition preparation.

PARAMETER DESCRIPTION
transition_id

The transition identifier.

TYPE: int

protocol_version

The protocol version to transition to.

TYPE: int

handle_proposals async

handle_proposals(
    payload: bytes,
    expected_user_ids: list[int] | None = None,
) -> None

Handle MLS proposals from the voice gateway.

PARAMETER DESCRIPTION
payload

The raw proposals payload including operation type.

TYPE: bytes

expected_user_ids

Expected user IDs for validation.

TYPE: list[int] | None DEFAULT: None

handle_welcome async

handle_welcome(payload: bytes) -> None

Handle an MLS welcome message.

PARAMETER DESCRIPTION
payload

The raw payload including transition_id.

TYPE: bytes

initialize_session async

initialize_session(protocol_version: int) -> None

Initialize a new DAVE session.

PARAMETER DESCRIPTION
protocol_version

The DAVE protocol version to use.

TYPE: int

set_external_sender async

set_external_sender(external_sender_data: bytes) -> None

Set the external sender for the MLS group.

PARAMETER DESCRIPTION
external_sender_data

The serialized external sender data from the voice gateway.

TYPE: bytes