@discordjs/voice 0.19.1 → 0.19.2-dev.1773403496-fe5e3c2a8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1865,6 +1865,8 @@ interface JoinVoiceChannelOptions {
1865
1865
  */
1866
1866
  declare function joinVoiceChannel(options: CreateVoiceConnectionOptions & JoinVoiceChannelOptions): VoiceConnection;
1867
1867
 
1868
+ declare const RTP_OPUS_PAYLOAD_TYPE = 120;
1869
+
1868
1870
  /**
1869
1871
  * Generates a report of the dependencies used by the \@discordjs/voice module.
1870
1872
  * Useful for debugging.
@@ -1925,4 +1927,4 @@ declare function demuxProbe(stream: Readable, probeSize?: number, validator?: ty
1925
1927
  */
1926
1928
  declare const version: string;
1927
1929
 
1928
- export { AudioPlayer, type AudioPlayerBufferingState, AudioPlayerError, type AudioPlayerIdleState, type AudioPlayerPausedState, type AudioPlayerPlayingState, type AudioPlayerState, AudioPlayerStatus, AudioReceiveStream, type AudioReceiveStreamOptions, AudioResource, type ConnectionData, type ConnectionOptions, type CreateAudioPlayerOptions, type CreateAudioResourceOptions, type CreateVoiceConnectionOptions, DAVESession, type DiscordGatewayAdapterCreator, type DiscordGatewayAdapterImplementerMethods, type DiscordGatewayAdapterLibraryMethods, type Edge, type EndBehavior, EndBehaviorType, type JoinConfig, type JoinVoiceChannelOptions, Networking, type NetworkingClosedState, type NetworkingIdentifyingState, type NetworkingOpeningWsState, type NetworkingReadyState, type NetworkingResumingState, type NetworkingSelectingProtocolState, type NetworkingState, NetworkingStatusCode, type NetworkingUdpHandshakingState, NoSubscriberBehavior, Node, PlayerSubscription, type ProbeInfo, SSRCMap, type SocketConfig, SpeakingMap, StreamType, TransformerType, VoiceConnection, type VoiceConnectionConnectingState, type VoiceConnectionDestroyedState, VoiceConnectionDisconnectReason, type VoiceConnectionDisconnectedBaseState, type VoiceConnectionDisconnectedOtherState, type VoiceConnectionDisconnectedState, type VoiceConnectionDisconnectedWebSocketState, type VoiceConnectionReadyState, type VoiceConnectionSignallingState, type VoiceConnectionState, VoiceConnectionStatus, VoiceReceiver, VoiceUDPSocket, type VoiceUserData, VoiceWebSocket, createAudioPlayer, createAudioResource, createDefaultAudioReceiveStreamOptions, demuxProbe, entersState, generateDependencyReport, getGroups, getVoiceConnection, getVoiceConnections, joinVoiceChannel, validateDiscordOpusHead, version };
1930
+ export { AudioPlayer, type AudioPlayerBufferingState, AudioPlayerError, type AudioPlayerIdleState, type AudioPlayerPausedState, type AudioPlayerPlayingState, type AudioPlayerState, AudioPlayerStatus, AudioReceiveStream, type AudioReceiveStreamOptions, AudioResource, type ConnectionData, type ConnectionOptions, type CreateAudioPlayerOptions, type CreateAudioResourceOptions, type CreateVoiceConnectionOptions, DAVESession, type DiscordGatewayAdapterCreator, type DiscordGatewayAdapterImplementerMethods, type DiscordGatewayAdapterLibraryMethods, type Edge, type EndBehavior, EndBehaviorType, type JoinConfig, type JoinVoiceChannelOptions, Networking, type NetworkingClosedState, type NetworkingIdentifyingState, type NetworkingOpeningWsState, type NetworkingReadyState, type NetworkingResumingState, type NetworkingSelectingProtocolState, type NetworkingState, NetworkingStatusCode, type NetworkingUdpHandshakingState, NoSubscriberBehavior, Node, PlayerSubscription, type ProbeInfo, RTP_OPUS_PAYLOAD_TYPE, SSRCMap, type SocketConfig, SpeakingMap, StreamType, TransformerType, VoiceConnection, type VoiceConnectionConnectingState, type VoiceConnectionDestroyedState, VoiceConnectionDisconnectReason, type VoiceConnectionDisconnectedBaseState, type VoiceConnectionDisconnectedOtherState, type VoiceConnectionDisconnectedState, type VoiceConnectionDisconnectedWebSocketState, type VoiceConnectionReadyState, type VoiceConnectionSignallingState, type VoiceConnectionState, VoiceConnectionStatus, VoiceReceiver, VoiceUDPSocket, type VoiceUserData, VoiceWebSocket, createAudioPlayer, createAudioResource, createDefaultAudioReceiveStreamOptions, demuxProbe, entersState, generateDependencyReport, getGroups, getVoiceConnection, getVoiceConnections, joinVoiceChannel, validateDiscordOpusHead, version };
package/dist/index.d.ts CHANGED
@@ -1865,6 +1865,8 @@ interface JoinVoiceChannelOptions {
1865
1865
  */
1866
1866
  declare function joinVoiceChannel(options: CreateVoiceConnectionOptions & JoinVoiceChannelOptions): VoiceConnection;
1867
1867
 
1868
+ declare const RTP_OPUS_PAYLOAD_TYPE = 120;
1869
+
1868
1870
  /**
1869
1871
  * Generates a report of the dependencies used by the \@discordjs/voice module.
1870
1872
  * Useful for debugging.
@@ -1925,4 +1927,4 @@ declare function demuxProbe(stream: Readable, probeSize?: number, validator?: ty
1925
1927
  */
1926
1928
  declare const version: string;
1927
1929
 
1928
- export { AudioPlayer, type AudioPlayerBufferingState, AudioPlayerError, type AudioPlayerIdleState, type AudioPlayerPausedState, type AudioPlayerPlayingState, type AudioPlayerState, AudioPlayerStatus, AudioReceiveStream, type AudioReceiveStreamOptions, AudioResource, type ConnectionData, type ConnectionOptions, type CreateAudioPlayerOptions, type CreateAudioResourceOptions, type CreateVoiceConnectionOptions, DAVESession, type DiscordGatewayAdapterCreator, type DiscordGatewayAdapterImplementerMethods, type DiscordGatewayAdapterLibraryMethods, type Edge, type EndBehavior, EndBehaviorType, type JoinConfig, type JoinVoiceChannelOptions, Networking, type NetworkingClosedState, type NetworkingIdentifyingState, type NetworkingOpeningWsState, type NetworkingReadyState, type NetworkingResumingState, type NetworkingSelectingProtocolState, type NetworkingState, NetworkingStatusCode, type NetworkingUdpHandshakingState, NoSubscriberBehavior, Node, PlayerSubscription, type ProbeInfo, SSRCMap, type SocketConfig, SpeakingMap, StreamType, TransformerType, VoiceConnection, type VoiceConnectionConnectingState, type VoiceConnectionDestroyedState, VoiceConnectionDisconnectReason, type VoiceConnectionDisconnectedBaseState, type VoiceConnectionDisconnectedOtherState, type VoiceConnectionDisconnectedState, type VoiceConnectionDisconnectedWebSocketState, type VoiceConnectionReadyState, type VoiceConnectionSignallingState, type VoiceConnectionState, VoiceConnectionStatus, VoiceReceiver, VoiceUDPSocket, type VoiceUserData, VoiceWebSocket, createAudioPlayer, createAudioResource, createDefaultAudioReceiveStreamOptions, demuxProbe, entersState, generateDependencyReport, getGroups, getVoiceConnection, getVoiceConnections, joinVoiceChannel, validateDiscordOpusHead, version };
1930
+ export { AudioPlayer, type AudioPlayerBufferingState, AudioPlayerError, type AudioPlayerIdleState, type AudioPlayerPausedState, type AudioPlayerPlayingState, type AudioPlayerState, AudioPlayerStatus, AudioReceiveStream, type AudioReceiveStreamOptions, AudioResource, type ConnectionData, type ConnectionOptions, type CreateAudioPlayerOptions, type CreateAudioResourceOptions, type CreateVoiceConnectionOptions, DAVESession, type DiscordGatewayAdapterCreator, type DiscordGatewayAdapterImplementerMethods, type DiscordGatewayAdapterLibraryMethods, type Edge, type EndBehavior, EndBehaviorType, type JoinConfig, type JoinVoiceChannelOptions, Networking, type NetworkingClosedState, type NetworkingIdentifyingState, type NetworkingOpeningWsState, type NetworkingReadyState, type NetworkingResumingState, type NetworkingSelectingProtocolState, type NetworkingState, NetworkingStatusCode, type NetworkingUdpHandshakingState, NoSubscriberBehavior, Node, PlayerSubscription, type ProbeInfo, RTP_OPUS_PAYLOAD_TYPE, SSRCMap, type SocketConfig, SpeakingMap, StreamType, TransformerType, VoiceConnection, type VoiceConnectionConnectingState, type VoiceConnectionDestroyedState, VoiceConnectionDisconnectReason, type VoiceConnectionDisconnectedBaseState, type VoiceConnectionDisconnectedOtherState, type VoiceConnectionDisconnectedState, type VoiceConnectionDisconnectedWebSocketState, type VoiceConnectionReadyState, type VoiceConnectionSignallingState, type VoiceConnectionState, VoiceConnectionStatus, VoiceReceiver, VoiceUDPSocket, type VoiceUserData, VoiceWebSocket, createAudioPlayer, createAudioResource, createDefaultAudioReceiveStreamOptions, demuxProbe, entersState, generateDependencyReport, getGroups, getVoiceConnection, getVoiceConnections, joinVoiceChannel, validateDiscordOpusHead, version };
package/dist/index.js CHANGED
@@ -43,6 +43,7 @@ __export(index_exports, {
43
43
  NoSubscriberBehavior: () => NoSubscriberBehavior,
44
44
  Node: () => Node,
45
45
  PlayerSubscription: () => PlayerSubscription,
46
+ RTP_OPUS_PAYLOAD_TYPE: () => RTP_OPUS_PAYLOAD_TYPE,
46
47
  SSRCMap: () => SSRCMap,
47
48
  SpeakingMap: () => SpeakingMap,
48
49
  StreamType: () => StreamType,
@@ -248,6 +249,9 @@ var secretboxLoadPromise = new Promise(async (resolve2) => {
248
249
  resolve2();
249
250
  });
250
251
 
252
+ // src/util/constants.ts
253
+ var RTP_OPUS_PAYLOAD_TYPE = 120;
254
+
251
255
  // src/util/util.ts
252
256
  var noop = /* @__PURE__ */ __name(() => {
253
257
  }, "noop");
@@ -1774,7 +1778,7 @@ to ${stringifyState2(newState)}`);
1774
1778
  createAudioPacket(opusPacket, connectionData, daveSession) {
1775
1779
  const rtpHeader = import_node_buffer6.Buffer.alloc(12);
1776
1780
  rtpHeader[0] = 128;
1777
- rtpHeader[1] = 120;
1781
+ rtpHeader[1] = RTP_OPUS_PAYLOAD_TYPE;
1778
1782
  const { sequence, timestamp, ssrc } = connectionData;
1779
1783
  rtpHeader.writeUIntBE(sequence, 2, 2);
1780
1784
  rtpHeader.writeUIntBE(timestamp, 4, 4);
@@ -2089,6 +2093,13 @@ var VoiceReceiver = class {
2089
2093
  parsePacket(buffer, mode, nonce2, secretKey, userId) {
2090
2094
  let packet = this.decrypt(buffer, mode, nonce2, secretKey);
2091
2095
  if (!packet) throw new Error("Failed to parse packet");
2096
+ const hasPadding = buffer[0] && Boolean(buffer[0] & 32);
2097
+ if (hasPadding) {
2098
+ const paddingAmount = packet[packet.length - 1];
2099
+ if (paddingAmount < packet.length) {
2100
+ packet = packet.subarray(0, packet.length - paddingAmount);
2101
+ }
2102
+ }
2092
2103
  if (buffer.subarray(12, 14).compare(HEADER_EXTENSION_BYTE) === 0) {
2093
2104
  const headerExtensionLength = buffer.subarray(14).readUInt16BE();
2094
2105
  packet = packet.subarray(4 * headerExtensionLength);
@@ -2114,6 +2125,9 @@ var VoiceReceiver = class {
2114
2125
  const stream = this.subscriptions.get(userData.userId);
2115
2126
  if (!stream) return;
2116
2127
  if (this.connectionData.encryptionMode && this.connectionData.nonceBuffer && this.connectionData.secretKey) {
2128
+ if ((msg[1] & 127) !== RTP_OPUS_PAYLOAD_TYPE) return;
2129
+ const rtpVersion = msg[0] >> 6;
2130
+ if (rtpVersion !== 2) return;
2117
2131
  try {
2118
2132
  const packet = this.parsePacket(
2119
2133
  msg,
@@ -3037,7 +3051,7 @@ __name(findPackageJSON, "findPackageJSON");
3037
3051
  function version(name) {
3038
3052
  try {
3039
3053
  if (name === "@discordjs/voice") {
3040
- return "0.19.1";
3054
+ return "0.19.2-dev.1773403496-fe5e3c2a8";
3041
3055
  }
3042
3056
  const pkg = findPackageJSON((0, import_node_path.dirname)(require.resolve(name)), name, 3);
3043
3057
  return pkg?.version ?? "not found";
@@ -3185,7 +3199,7 @@ async function demuxProbe(stream, probeSize = 1024, validator = validateDiscordO
3185
3199
  __name(demuxProbe, "demuxProbe");
3186
3200
 
3187
3201
  // src/index.ts
3188
- var version2 = "0.19.1";
3202
+ var version2 = "0.19.2-dev.1773403496-fe5e3c2a8";
3189
3203
  // Annotate the CommonJS export names for ESM import in node:
3190
3204
  0 && (module.exports = {
3191
3205
  AudioPlayer,
@@ -3200,6 +3214,7 @@ var version2 = "0.19.1";
3200
3214
  NoSubscriberBehavior,
3201
3215
  Node,
3202
3216
  PlayerSubscription,
3217
+ RTP_OPUS_PAYLOAD_TYPE,
3203
3218
  SSRCMap,
3204
3219
  SpeakingMap,
3205
3220
  StreamType,