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(auth): accept equivalencies when comparing scopes #343

Merged
merged 5 commits into from Mar 29, 2022

Conversation

iProdigy
Copy link
Contributor

@iProdigy iProdigy commented Mar 26, 2022

Type: Bugfix

Fixes #342
Fixes #323
Closes #335

  • Changes compareScopes from an O(n*m) operation to O(n+m)
  • Accept kraken/helix scope equivalencies for compareScopes
  • Accept user:edit:broadcast for channel:manage:broadcast in compareScopes
  • channel_subscriptions => channel:read:subscriptions for channel-subscribe-events-v1
  • user:edit:broadcast => channel:manage:broadcast for updateChannelInfo, createStreamMarker, and replaceStreamTags

@theca11
Copy link
Contributor

theca11 commented Mar 26, 2022

Could this be used to fix #323 too? (user:edit:broadcast -> channel:manage:broadcast)

@iProdigy
Copy link
Contributor Author

iProdigy commented Mar 26, 2022

Could this be used to fix #323 too? (user:edit:broadcast -> channel:manage:broadcast)

Yes, but extra care would be needed to not accept the reverse (for example in helix Update User Extensions) -- that said, the library doesn't appear to currently implement this endpoint so it may be a non-issue

Edit: depending on what scope validation the chat package does, the reverse mappings could be eliminated

Edit2: looks like there's already a legacyScopes flag for the chat package, so a helix => legacy mapping doesn't seem to be necessary

@d-fischer
Copy link
Member

d-fischer commented Mar 26, 2022

Could this be used to fix #323 too? (user:edit:broadcast -> channel:manage:broadcast)

Yes, this fixes #323 and supersedes #335 now. I think this is much more elegant and accomplishes the same without ever requiring a breaking change.

@d-fischer
Copy link
Member

Edit: depending on what scope validation the chat package does, the reverse mappings could be eliminated

Edit2: looks like there's already a legacyScopes flag for the chat package, so a helix => legacy mapping doesn't seem to be necessary

Indeed, chat has to do a very strict validation here, since the required scope depends entirely on when the application was created on the Twitch dev portal. From my tests back when the change was introduced, "new" apps don't support the "old" scopes and vice versa.

@d-fischer d-fischer merged commit 21cc341 into twurple:main Mar 29, 2022
@iProdigy iProdigy deleted the fix/compare-scope-equivalents branch March 29, 2022 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pubsub channel subscription scope has changed Improvement Request: update some endpoints to newest scope
3 participants