mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
fix: if present, wait for libsodium-wrappers' ready to support v0.7.3
This commit is contained in:
@@ -44,7 +44,7 @@
|
||||
"node-opus": "^0.2.7",
|
||||
"opusscript": "^0.0.6",
|
||||
"sodium": "^2.0.3",
|
||||
"libsodium-wrappers": "^0.5.4",
|
||||
"libsodium-wrappers": "^0.7.3",
|
||||
"uws": "^9.14.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -163,7 +163,7 @@ class StreamDispatcher extends VolumeInterface {
|
||||
packetBuffer.writeUIntBE(this.player.voiceConnection.authentication.ssrc, 8, 4);
|
||||
|
||||
packetBuffer.copy(nonce, 0, 0, 12);
|
||||
buffer = secretbox.close(buffer, nonce, this.player.voiceConnection.authentication.secretKey.key);
|
||||
buffer = secretbox.methods.close(buffer, nonce, this.player.voiceConnection.authentication.secretKey.key);
|
||||
for (let i = 0; i < buffer.length; i++) packetBuffer[i + 12] = buffer[i];
|
||||
|
||||
return packetBuffer;
|
||||
|
||||
@@ -147,7 +147,7 @@ class VoiceReceiver extends EventEmitter {
|
||||
|
||||
handlePacket(msg, user) {
|
||||
msg.copy(nonce, 0, 0, 12);
|
||||
let data = secretbox.open(msg.slice(12), nonce, this.voiceConnection.authentication.secretKey.key);
|
||||
let data = secretbox.methods.open(msg.slice(12), nonce, this.voiceConnection.authentication.secretKey.key);
|
||||
if (!data) {
|
||||
/**
|
||||
* Emitted whenever a voice packet experiences a problem.
|
||||
|
||||
@@ -13,10 +13,21 @@ const libs = {
|
||||
}),
|
||||
};
|
||||
|
||||
exports.methods = {};
|
||||
|
||||
for (const libName of Object.keys(libs)) {
|
||||
try {
|
||||
const lib = require(libName);
|
||||
module.exports = libs[libName](lib);
|
||||
if (libName === 'libsodium-wrappers' && lib.ready) {
|
||||
lib.ready.then(() => {
|
||||
exports.methods = libs[libName](lib);
|
||||
}).catch(() => {
|
||||
const tweetnacl = require('tweetnacl');
|
||||
exports.methods = libs.tweetnacl(tweetnacl);
|
||||
}).catch(() => undefined);
|
||||
} else {
|
||||
exports.methods = libs[libName](lib);
|
||||
}
|
||||
break;
|
||||
} catch (err) {} // eslint-disable-line no-empty
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user