-
Notifications
You must be signed in to change notification settings - Fork 206
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
feat(oauth-providers): Add Twitch OAuth Provider #981
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: b673173 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@Younis-Ahmed thank you for the PR. Hey @monoald, can you review this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍🏻
Thank you for the review, appreciate it |
Changed version from patch to minor
Add Twitch OAuth Provider
Which middleware is the feature for?
@hono/oauth-providers
What is the feature you are proposing?
This PR introduces a Twitch OAuth provider, expanding the middleware's OAuth offerings. It includes a new middleware for Twitch authentication, a dedicated
AuthFlow
class, token refreshing/revocation/validation, and comprehensive type definitions. Detailed tests ensure correct behavior and error handling. resolves #983Key Changes
Twitch OAuth Middleware src/providers/twitch/twitchAuth.ts: Implements the core authentication flow, handling state management, redirects, and context variable setting (
token
,refresh-token
,user-twitch
,granted-scopes
).AuthFlow Class src/providers/twitch/authFlow.ts: Encapsulates token exchange and user data retrieval, with robust error handling.
Token Operations src/providers/twitch/refreshToken.ts,
src/providers/twitch/revokeToken.ts
): Provides functions for refreshing and revoking tokens.Type Definitions src/providers/twitch/types.ts: Defines comprehensive types for Twitch API responses.
Extensive Testing (
test/handlers.ts
,test/index.test.ts
): Includes unit tests covering redirection, valid code flow, error handling, refresh/revoke token, custom and built-in state scenarios, using a mock server.Validate Token src/providers/twitch/validateToken: That hit
/validate
endpoint to verify that the access token is still valid for reasons other than token expiring.Checklist
validateToken
that hit/validate
endpoint to verify that the access token is still valid for reasons other than token exirpingyarn changeset
with summary