https://github.com/snazzah/davey
Discord DAVE implementation for Node environments
https://github.com/snazzah/davey
discord discord-bot discord-dave e2ee mls nodejs rust
Last synced: 11 months ago
JSON representation
Discord DAVE implementation for Node environments
- Host: GitHub
- URL: https://github.com/snazzah/davey
- Owner: Snazzah
- License: mit
- Created: 2024-10-07T00:01:38.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-06-10T21:01:50.000Z (about 1 year ago)
- Last Synced: 2025-08-08T22:32:13.846Z (11 months ago)
- Topics: discord, discord-bot, discord-dave, e2ee, mls, nodejs, rust
- Language: Rust
- Homepage:
- Size: 330 KB
- Stars: 11
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Davey! [How ya doin?](https://www.youtube.com/watch?v=TBbxlP6NXXs)
[](https://www.npmjs.com/package/@snazzah/davey) [](https://packagephobia.com/result?p=@snazzah/davey) [](https://www.npmjs.com/package/@snazzah/davey) [](https://snaz.in/discord)
A [Discord Audio & Video End-to-End Encryption (DAVE) Protocol](https://daveprotocol.com/) implementation using [OpenMLS](https://openmls.tech/) built with [NAPI-RS](https://napi.rs/).
> Proper documentation does not exist yet, but you can [read the usage document](https://github.com/Snazzah/davey/blob/master/docs/USAGE.md) and review the [type definitions](https://github.com/Snazzah/davey/blob/master/index.d.ts) for available methods.
```ts
import { DAVESession, ProposalsOperationType, MediaType, Codec } from '@snazzah/davey';
const session = new DAVESession(
1, // dave version
'158049329150427136', // user id
'927310423890473011', // channel id
);
// Set the external sender of the session from opcode 25
session.setExternalSender(externalSenderBuffer);
// Get the key package buffer to send to Discord
session.getSerializedKeyPackage();
// Process a proposals
session.processProposals(
ProposalsOperationType.APPEND, // the type of proposals operation
proposalsBuffer, // proposals or proposal refs buffer
recognizedUserIds, // an array of user IDs in the session, optional but recommended
);
// Process a commit
session.processCommit(commitBuffer);
// Process a welcome
session.processWelcome(welcomeBuffer);
// The current voice privacy code of the session, updated after a commit/welcome
session.voicePrivacyCode; // a 30 digit string or an empty string for not started sessions
// Encrypt/decrypt voice packets
if (session.ready) {
// Encrypt packets with a specified media type and codec, use this before transport encryption
session.encrypt(MediaType.AUDIO, Codec.OPUS, packet);
// Really only opus is supported right now so just use the shorthand method
session.encrypt_opus(packet);
// Decrypt a packet from a user, use this after transport decryption
session.decrypt(userId, MediaType.AUDIO, incomingPacket);
}
```
#### References
- [daveprotocol.com](https://daveprotocol.com/)
- [discord/libdave](https://github.com/discord/libdave)
- [Discord Dev Docs - Voice - E2EE](https://discord.com/developers/docs/topics/voice-connections#endtoend-encryption-dave-protocol)
- [NAPI-RS](https://napi.rs/docs/introduction/getting-started)
- [OpenMLS Book](https://book.openmls.tech/introduction.html)
- [Voice Model - High Level Summary - DPP](https://dpp.dev/voice-model.html)