Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eighty-pandas-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hono/oauth-providers': minor
---

Optionally pass state as an option to oauth provider
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ export function discordAuth(options: {
client_id?: string
client_secret?: string
redirect_uri?: string
state?: string
}): MiddlewareHandler {
return async (c, next) => {
// Generate encoded "keys"
const newState = getRandomState()
const newState = options.state || getRandomState()

// Create new Auth instance
const auth = new AuthFlow({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ export function facebookAuth(options: {
client_id?: string
client_secret?: string
redirect_uri?: string
state?: string
}): MiddlewareHandler {
return async (c, next) => {
const newState = getRandomState()
const newState = options.state || getRandomState()
// Create new Auth instance
const auth = new AuthFlow({
client_id: options.client_id || (env(c).FACEBOOK_ID as string),
Expand Down
3 changes: 2 additions & 1 deletion packages/oauth-providers/src/providers/github/githubAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ export function githubAuth(options: {
scope?: GitHubScope[]
oauthApp?: boolean
redirect_uri?: string
state?: string
}): MiddlewareHandler {
return async (c, next) => {
const newState = getRandomState()
const newState = options.state || getRandomState()
// Create new Auth instance
const auth = new AuthFlow({
client_id: options.client_id || (env(c).GITHUB_ID as string),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ export function linkedinAuth(options: {
scope?: LinkedInScope[]
appAuth?: boolean
redirect_uri?: string
state?: string
}): MiddlewareHandler {
return async (c, next) => {
const newState = getRandomState()
const newState = options.state || getRandomState()
// Create new Auth instance
const auth = new AuthFlow({
client_id: options.client_id || (env(c).LINKEDIN_ID as string),
Expand Down
3 changes: 2 additions & 1 deletion packages/oauth-providers/src/providers/x/xAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ export function xAuth(options: {
client_id?: string
client_secret?: string
redirect_uri?: string
state?: string
}): MiddlewareHandler {
return async (c, next) => {
// Generate encoded "keys"
const newState = getRandomState()
const newState = options.state || getRandomState()
const challenge = await getCodeChallenge()

const auth = new AuthFlow({
Expand Down