Skip to content
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

fix(REST): strip webhook tokens #9723

Merged
merged 4 commits into from
Nov 11, 2023
Merged

fix(REST): strip webhook tokens #9723

merged 4 commits into from
Nov 11, 2023

Conversation

D4isDAVID
Copy link
Contributor

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

Strip the token from webhook routes.

Fixes #9415.

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

@vercel
Copy link

vercel bot commented Jul 17, 2023

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

Name Status Preview Comments Updated (UTC)
discord-js ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 11, 2023 6:39pm
discord-js-guide ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 11, 2023 6:39pm

@codecov
Copy link

codecov bot commented Jul 17, 2023

Codecov Report

Merging #9723 (c59b290) into main (6dca801) will increase coverage by 0.00%.
The diff coverage is 87.50%.

@@           Coverage Diff           @@
##             main    #9723   +/-   ##
=======================================
  Coverage   59.67%   59.67%           
=======================================
  Files         235      235           
  Lines       16370    16374    +4     
  Branches     1235     1235           
=======================================
+ Hits         9768     9771    +3     
  Misses       6558     6558           
- Partials       44       45    +1     
Flag Coverage Δ
next ∅ <ø> (∅)
proxy 75.00% <ø> (ø)
rest 92.74% <87.50%> (-0.03%) ⬇️
ws 52.63% <ø> (ø)

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

Files Coverage Δ
packages/rest/src/lib/REST.ts 87.87% <87.50%> (-0.12%) ⬇️

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@Jiralite Jiralite added this to the rest 2.0.0 milestone Jul 17, 2023
@Jiralite Jiralite modified the milestones: rest 2.0.0, rest 2.1.0 Jul 31, 2023
@github-actions
Copy link

github-actions bot commented Aug 2, 2023

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟢 Performance 91
🟢 Accessibility 97
🟢 Best practices 100
🟠 SEO 75
🔴 PWA 30

Lighthouse ran on https://discord-js-git-fork-d4isdavid-fix-reststrip-we-326a80-discordjs.vercel.app/

Copy link
Member

@ckohen ckohen left a comment

Choose a reason for hiding this comment

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

This actually does change behavior significantly in the supposedly impossible case where two webhooks share an id (since webhooks can be keyed on id + token). Notably this is how interaction followups work (using the application id instead of the interaction id).

What you've done is put all interaction followup requests (with the same method) in the same bucket!

We kinda got lucky with our implementation that happened to split out handlers because the route was different (because it had token in it) rather than because the major id was different.

Bonus to handling this properly would be that we don't create a bunch of duplicate hash entries in our hash cache.

In addition to what you've done (which is in the section that makes a route more generic to match how discord hashes routes), you need to edit the regex used to match major ids to include webhook tokens, so that we don't lose the uniqueness.

@D4isDAVID D4isDAVID requested a review from ckohen November 9, 2023 17:37
packages/rest/src/lib/REST.ts Outdated Show resolved Hide resolved
packages/rest/src/lib/REST.ts Outdated Show resolved Hide resolved
packages/rest/src/lib/REST.ts Outdated Show resolved Hide resolved
@D4isDAVID D4isDAVID changed the title fix(RequestManager): strip webhook tokens fix(REST): strip webhook tokens Nov 10, 2023
@kodiakhq kodiakhq bot merged commit cf49f40 into discordjs:main Nov 11, 2023
5 of 6 checks passed
@D4isDAVID D4isDAVID deleted the fix/rest/strip-webhooks-route-token branch November 16, 2023 09:02
Vylpes pushed a commit to Vylpes/card-drop that referenced this pull request Nov 27, 2023
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@discordjs/rest](https://discord.js.org) ([source](https://github.com/discordjs/discord.js)) | dependencies | minor | [`2.0.1` -> `2.2.0`](https://renovatebot.com/diffs/npm/@discordjs%2frest/2.0.1/2.2.0) |

---

### Release Notes

<details>
<summary>discordjs/discord.js (@&#8203;discordjs/rest)</summary>

### [`v2.2.0`](https://github.com/discordjs/discord.js/blob/HEAD/packages/rest/CHANGELOG.md#discordjsrest220---2023-11-17)

[Compare Source](https://github.com/discordjs/discord.js/compare/@discordjs/[email protected]...@discordjs/[email protected])

#### Bug Fixes

-   Minify mainlib docs json ([#&#8203;9963](discordjs/discord.js#9963)) ([4b88306](discordjs/discord.js@4b88306))

#### Features

-   Present x-ratelimit-scope for 429s hit ([#&#8203;9973](discordjs/discord.js#9973)) ([6df233d](discordjs/discord.js@6df233d))

#### Typings

-   Use wrapper utilities ([#&#8203;9945](discordjs/discord.js#9945)) ([4bc1dae](discordjs/discord.js@4bc1dae))

### [`v2.1.0`](https://github.com/discordjs/discord.js/blob/HEAD/packages/rest/CHANGELOG.md#discordjsrest210---2023-11-12)

[Compare Source](https://github.com/discordjs/discord.js/compare/@discordjs/[email protected]...@discordjs/[email protected])

#### Bug Fixes

-   **REST:** Strip webhook tokens ([#&#8203;9723](discordjs/discord.js#9723)) ([cf49f40](discordjs/discord.js@cf49f40))

#### Documentation

-   Fix "its" typo ([#&#8203;9825](discordjs/discord.js#9825)) ([c50809e](discordjs/discord.js@c50809e))
-   **create-discord-bot:** Support bun in create-discord-bot ([#&#8203;9798](discordjs/discord.js#9798)) ([7157748](discordjs/discord.js@7157748))

#### Features

-   Expose Retry-After and sublimit timeouts in RatelimitData ([#&#8203;9864](discordjs/discord.js#9864)) ([81e7866](discordjs/discord.js@81e7866))
-   **CDN:** Support emoji size ([#&#8203;9787](discordjs/discord.js#9787)) ([778df45](discordjs/discord.js@778df45))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=-->

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/101
Reviewed-by: Vylpes <[email protected]>
Co-authored-by: Renovate Bot <[email protected]>
Co-committed-by: Renovate Bot <[email protected]>
Vylpes pushed a commit to Vylpes/vylbot-app that referenced this pull request Dec 18, 2023
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@discordjs/rest](https://discord.js.org) ([source](https://github.com/discordjs/discord.js)) | dependencies | minor | [`2.0.1` -> `2.2.0`](https://renovatebot.com/diffs/npm/@discordjs%2frest/2.0.1/2.2.0) |

---

### Release Notes

<details>
<summary>discordjs/discord.js (@&#8203;discordjs/rest)</summary>

### [`v2.2.0`](https://github.com/discordjs/discord.js/blob/HEAD/packages/rest/CHANGELOG.md#discordjsrest220---2023-11-17)

[Compare Source](https://github.com/discordjs/discord.js/compare/@discordjs/[email protected]...@discordjs/[email protected])

#### Bug Fixes

-   Minify mainlib docs json ([#&#8203;9963](discordjs/discord.js#9963)) ([4b88306](discordjs/discord.js@4b88306))

#### Features

-   Present x-ratelimit-scope for 429s hit ([#&#8203;9973](discordjs/discord.js#9973)) ([6df233d](discordjs/discord.js@6df233d))

#### Typings

-   Use wrapper utilities ([#&#8203;9945](discordjs/discord.js#9945)) ([4bc1dae](discordjs/discord.js@4bc1dae))

### [`v2.1.0`](https://github.com/discordjs/discord.js/blob/HEAD/packages/rest/CHANGELOG.md#discordjsrest210---2023-11-12)

[Compare Source](https://github.com/discordjs/discord.js/compare/@discordjs/[email protected]...@discordjs/[email protected])

#### Bug Fixes

-   **REST:** Strip webhook tokens ([#&#8203;9723](discordjs/discord.js#9723)) ([cf49f40](discordjs/discord.js@cf49f40))

#### Documentation

-   Fix "its" typo ([#&#8203;9825](discordjs/discord.js#9825)) ([c50809e](discordjs/discord.js@c50809e))
-   **create-discord-bot:** Support bun in create-discord-bot ([#&#8203;9798](discordjs/discord.js#9798)) ([7157748](discordjs/discord.js@7157748))

#### Features

-   Expose Retry-After and sublimit timeouts in RatelimitData ([#&#8203;9864](discordjs/discord.js#9864)) ([81e7866](discordjs/discord.js@81e7866))
-   **CDN:** Support emoji size ([#&#8203;9787](discordjs/discord.js#9787)) ([778df45](discordjs/discord.js@778df45))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=-->

Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/vylbot-app/pulls/375
Reviewed-by: Vylpes <[email protected]>
Co-authored-by: Renovate Bot <[email protected]>
Co-committed-by: Renovate Bot <[email protected]>
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.

Request route for interaction response deletions includes the token
5 participants