feat: Update voice encryption modes
https://discord.com/developers/docs/change-log#voice-encryption-modes #10451 djs
This commit is contained in:
@@ -2,25 +2,32 @@
|
||||
|
||||
const libs = {
|
||||
sodium: sodium => ({
|
||||
/** @deprecated */
|
||||
open: sodium.api.crypto_secretbox_open_easy,
|
||||
/** @deprecated */
|
||||
close: sodium.api.crypto_secretbox_easy,
|
||||
random: n => sodium.randombytes_buf(n),
|
||||
crypto_aead_xchacha20poly1305_ietf_encrypt: (message, additionalData, nonce, key) =>
|
||||
sodium.api.crypto_aead_xchacha20poly1305_ietf_encrypt(message, additionalData, null, nonce, key),
|
||||
crypto_aead_xchacha20poly1305_ietf_decrypt: (message, additionalData, nonce, key) =>
|
||||
sodium.api.crypto_aead_xchacha20poly1305_ietf_decrypt(message, additionalData, null, nonce, key),
|
||||
}),
|
||||
'libsodium-wrappers': sodium => ({
|
||||
/** @deprecated */
|
||||
open: sodium.crypto_secretbox_open_easy,
|
||||
/** @deprecated */
|
||||
close: sodium.crypto_secretbox_easy,
|
||||
random: n => sodium.randombytes_buf(n),
|
||||
}),
|
||||
tweetnacl: tweetnacl => ({
|
||||
open: tweetnacl.secretbox.open,
|
||||
close: tweetnacl.secretbox,
|
||||
random: n => tweetnacl.randomBytes(n),
|
||||
crypto_aead_xchacha20poly1305_ietf_encrypt: (message, additionalData, nonce, key) =>
|
||||
sodium.crypto_aead_xchacha20poly1305_ietf_encrypt(message, additionalData, null, nonce, key),
|
||||
crypto_aead_xchacha20poly1305_ietf_decrypt: (message, additionalData, nonce, key) =>
|
||||
sodium.crypto_aead_xchacha20poly1305_ietf_decrypt(null, message, additionalData, nonce, key),
|
||||
}),
|
||||
};
|
||||
|
||||
function NoLib() {
|
||||
throw new Error(
|
||||
'Cannot play audio as no valid encryption package is installed.\n- Install sodium, libsodium-wrappers, or tweetnacl.',
|
||||
'Cannot play audio as no valid encryption package is installed.\n- Install sodium or libsodium-wrappers.',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -28,6 +35,8 @@ exports.methods = {
|
||||
open: NoLib,
|
||||
close: NoLib,
|
||||
random: NoLib,
|
||||
crypto_aead_xchacha20poly1305_ietf_encrypt: NoLib,
|
||||
crypto_aead_xchacha20poly1305_ietf_decrypt: NoLib,
|
||||
};
|
||||
|
||||
(async () => {
|
||||
|
||||
Reference in New Issue
Block a user