mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +01:00
Remove useless SecretKey class
This commit is contained in:
@@ -90,7 +90,6 @@
|
|||||||
"src/client/voice/receiver/VoiceReadable.js": false,
|
"src/client/voice/receiver/VoiceReadable.js": false,
|
||||||
"src/client/voice/receiver/VoiceReceiver.js": false,
|
"src/client/voice/receiver/VoiceReceiver.js": false,
|
||||||
"src/client/voice/util/Secretbox.js": false,
|
"src/client/voice/util/Secretbox.js": false,
|
||||||
"src/client/voice/util/SecretKey.js": false,
|
|
||||||
"src/client/voice/util/VolumeInterface.js": false,
|
"src/client/voice/util/VolumeInterface.js": false,
|
||||||
"src/client/voice/VoiceBroadcast.js": false
|
"src/client/voice/VoiceBroadcast.js": false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
const { OPCodes, VoiceOPCodes } = require('../../util/Constants');
|
const { OPCodes, VoiceOPCodes } = require('../../util/Constants');
|
||||||
const SecretKey = require('./util/SecretKey');
|
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
const { Error } = require('../../errors');
|
const { Error } = require('../../errors');
|
||||||
const WebSocket = require('../../WebSocket');
|
const WebSocket = require('../../WebSocket');
|
||||||
@@ -164,14 +163,17 @@ class VoiceWebSocket extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
this.emit('ready', packet.d);
|
this.emit('ready', packet.d);
|
||||||
break;
|
break;
|
||||||
|
/* eslint-disable no-case-declarations */
|
||||||
case VoiceOPCodes.SESSION_DESCRIPTION:
|
case VoiceOPCodes.SESSION_DESCRIPTION:
|
||||||
|
const key = new Uint8Array(new ArrayBuffer(packet.d.secret_key.length));
|
||||||
|
for (const i in packet.d.secret_key) key[i] = packet.d.secret_key[i];
|
||||||
/**
|
/**
|
||||||
* Emitted once the Voice Websocket receives a description of this voice session.
|
* Emitted once the Voice Websocket receives a description of this voice session.
|
||||||
* @param {string} encryptionMode The type of encryption being used
|
* @param {string} encryptionMode The type of encryption being used
|
||||||
* @param {SecretKey} secretKey The secret key used for encryption
|
* @param {Uint8Array} secretKey The secret key used for encryption
|
||||||
* @event VoiceWebSocket#sessionDescription
|
* @event VoiceWebSocket#sessionDescription
|
||||||
*/
|
*/
|
||||||
this.emit('sessionDescription', packet.d.mode, new SecretKey(packet.d.secret_key));
|
this.emit('sessionDescription', packet.d.mode, key);
|
||||||
break;
|
break;
|
||||||
case VoiceOPCodes.SPEAKING:
|
case VoiceOPCodes.SPEAKING:
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class StreamDispatcher extends Writable {
|
|||||||
packetBuffer.writeUIntBE(this.player.voiceConnection.authentication.ssrc, 8, 4);
|
packetBuffer.writeUIntBE(this.player.voiceConnection.authentication.ssrc, 8, 4);
|
||||||
|
|
||||||
packetBuffer.copy(nonce, 0, 0, 12);
|
packetBuffer.copy(nonce, 0, 0, 12);
|
||||||
buffer = secretbox.methods.close(buffer, nonce, this.player.voiceConnection.authentication.secretKey.key);
|
buffer = secretbox.methods.close(buffer, nonce, this.player.voiceConnection.authentication.secretKey);
|
||||||
for (let i = 0; i < buffer.length; i++) packetBuffer[i + 12] = buffer[i];
|
for (let i = 0; i < buffer.length; i++) packetBuffer[i + 12] = buffer[i];
|
||||||
|
|
||||||
return packetBuffer;
|
return packetBuffer;
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ class VoiceReceiver extends EventEmitter {
|
|||||||
|
|
||||||
handlePacket(msg, user) {
|
handlePacket(msg, user) {
|
||||||
msg.copy(nonce, 0, 0, 12);
|
msg.copy(nonce, 0, 0, 12);
|
||||||
let data = secretbox.methods.open(msg.slice(12), nonce, this.voiceConnection.authentication.secretKey.key);
|
let data = secretbox.methods.open(msg.slice(12), nonce, this.voiceConnection.authentication.secretKey);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
/**
|
/**
|
||||||
* Emitted whenever a voice packet experiences a problem.
|
* Emitted whenever a voice packet experiences a problem.
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
/**
|
|
||||||
* Represents a Secret Key used in encryption over voice.
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
class SecretKey {
|
|
||||||
constructor(key) {
|
|
||||||
/**
|
|
||||||
* The key used for encryption
|
|
||||||
* @type {Uint8Array}
|
|
||||||
*/
|
|
||||||
this.key = new Uint8Array(new ArrayBuffer(key.length));
|
|
||||||
for (const index in key) this.key[index] = key[index];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = SecretKey;
|
|
||||||
Reference in New Issue
Block a user