Skip to content

feat(voice)!: add new encryption methods, remove old methods #10451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Nov 17, 2024

Conversation

nyapat
Copy link
Contributor

@nyapat nyapat commented Aug 19, 2024

Please describe the changes this PR makes and why it should be merged:

  • aes256gcm encryption
  • xchacha20 encryption
  • aes256gcm decryption
  • xchacha20 decryption
  • test if alternative sodiums work for above
  • alternative for tweetnacl
  • remove old encryption, decryption methods
  • tests (waiting on test: replace jest with vitest #10472)

Added the new encryption methods that Discord will enforce for all voice users in November. Since the older methods are being deprecated entirely, I am removing them as well. Because tweetnacl does not support the cipher methods necessary for xchacha, I have removed it and replaced it with @stablelib/xchacha20poly1305 (aes256gcm does not require anything other than node:crypto, so that could theoretically be the only one needed if the vc always requested that)

Testing has been added for the encryption methods aswell, and I have changed some older tests to properly remove the RTP header based on the original encrypted data.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating
  • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)

Copy link

vercel bot commented Aug 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview Nov 17, 2024 8:54pm
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Nov 17, 2024 8:54pm

@nyapat nyapat force-pushed the feat/voice-encryption branch 2 times, most recently from 47606c3 to 4879a69 Compare August 19, 2024 13:53
@vladfrangu vladfrangu added this to the voice 0.18.0 milestone Aug 20, 2024
@nyapat
Copy link
Contributor Author

nyapat commented Sep 2, 2024

when #10472 is ready i will update tests for this (tweetnacl is being swapped out for stablelib & jest utterly hates it)

@nyapat nyapat force-pushed the feat/voice-encryption branch from 52469d5 to 846b594 Compare October 7, 2024 09:49
Copy link

codecov bot commented Oct 7, 2024

Codecov Report

Attention: Patch coverage is 35.03185% with 102 lines in your changes missing coverage. Please review.

Project coverage is 38.14%. Comparing base (51a017a) to head (bbbcf85).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/voice/src/util/Secretbox.ts 18.18% 62 Missing and 1 partial ⚠️
packages/voice/src/networking/Networking.ts 15.00% 34 Missing ⚠️
packages/voice/src/receive/VoiceReceiver.ts 92.10% 3 Missing ⚠️
...ackages/voice/src/util/generateDependencyReport.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10451      +/-   ##
==========================================
- Coverage   38.17%   38.14%   -0.03%     
==========================================
  Files         239      239              
  Lines       15495    15578      +83     
  Branches     1369     1376       +7     
==========================================
+ Hits         5915     5943      +28     
- Misses       9565     9620      +55     
  Partials       15       15              
Flag Coverage Δ
brokers 31.44% <ø> (ø)
builders 82.43% <ø> (ø)
collection 100.00% <ø> (ø)
formatters 97.47% <ø> (ø)
guide 0.54% <ø> (ø)
proxy 66.27% <ø> (ø)
rest 87.37% <ø> (ø)
util 41.42% <ø> (ø)
utilities 100.00% <ø> (ø)
voice 70.60% <35.03%> (-1.63%) ⬇️
website 0.00% <ø> (ø)
ws 36.21% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nyapat nyapat marked this pull request as ready for review October 7, 2024 10:07
@nyapat nyapat requested review from a team and iCrawl as code owners October 7, 2024 10:07
@nyapat nyapat requested a review from vladfrangu October 7, 2024 10:07
@nyapat nyapat requested review from kyranet and SpaceEEC October 7, 2024 10:07
@nyapat nyapat changed the title feat(voice): aes-256-gcm, xchacha20-poly1305 encryption feat(voice)!: add new encryption methods, remove old methods Oct 7, 2024
Copy link
Member

@SpaceEEC SpaceEEC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small nit of mine, otherwise this looks good.
Thank you for this PR. 🙇

@vladfrangu vladfrangu requested a review from SpaceEEC November 17, 2024 20:34
@vladfrangu vladfrangu merged commit 9f8b9b1 into discordjs:main Nov 17, 2024
24 checks passed
@Jiralite Jiralite removed the blocked label Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

9 participants