File tree Expand file tree Collapse file tree 6 files changed +15
-5
lines changed
packages/oauth-providers/src/providers Expand file tree Collapse file tree 6 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @hono/oauth-providers ' : minor
3+ ---
4+
5+ Optionally pass state as an option to oauth provider
Original file line number Diff line number Diff line change @@ -12,10 +12,11 @@ export function discordAuth(options: {
1212 client_id ?: string
1313 client_secret ?: string
1414 redirect_uri ?: string
15+ state ?: string
1516} ) : MiddlewareHandler {
1617 return async ( c , next ) => {
1718 // Generate encoded "keys"
18- const newState = getRandomState ( )
19+ const newState = options . state || getRandomState ( )
1920
2021 // Create new Auth instance
2122 const auth = new AuthFlow ( {
Original file line number Diff line number Diff line change @@ -13,9 +13,10 @@ export function facebookAuth(options: {
1313 client_id ?: string
1414 client_secret ?: string
1515 redirect_uri ?: string
16+ state ?: string
1617} ) : MiddlewareHandler {
1718 return async ( c , next ) => {
18- const newState = getRandomState ( )
19+ const newState = options . state || getRandomState ( )
1920 // Create new Auth instance
2021 const auth = new AuthFlow ( {
2122 client_id : options . client_id || ( env ( c ) . FACEBOOK_ID as string ) ,
Original file line number Diff line number Diff line change @@ -13,9 +13,10 @@ export function githubAuth(options: {
1313 scope ?: GitHubScope [ ]
1414 oauthApp ?: boolean
1515 redirect_uri ?: string
16+ state ?: string
1617} ) : MiddlewareHandler {
1718 return async ( c , next ) => {
18- const newState = getRandomState ( )
19+ const newState = options . state || getRandomState ( )
1920 // Create new Auth instance
2021 const auth = new AuthFlow ( {
2122 client_id : options . client_id || ( env ( c ) . GITHUB_ID as string ) ,
Original file line number Diff line number Diff line change @@ -13,9 +13,10 @@ export function linkedinAuth(options: {
1313 scope ?: LinkedInScope [ ]
1414 appAuth ?: boolean
1515 redirect_uri ?: string
16+ state ?: string
1617} ) : MiddlewareHandler {
1718 return async ( c , next ) => {
18- const newState = getRandomState ( )
19+ const newState = options . state || getRandomState ( )
1920 // Create new Auth instance
2021 const auth = new AuthFlow ( {
2122 client_id : options . client_id || ( env ( c ) . LINKEDIN_ID as string ) ,
Original file line number Diff line number Diff line change @@ -14,10 +14,11 @@ export function xAuth(options: {
1414 client_id ?: string
1515 client_secret ?: string
1616 redirect_uri ?: string
17+ state ?: string
1718} ) : MiddlewareHandler {
1819 return async ( c , next ) => {
1920 // Generate encoded "keys"
20- const newState = getRandomState ( )
21+ const newState = options . state || getRandomState ( )
2122 const challenge = await getCodeChallenge ( )
2223
2324 const auth = new AuthFlow ( {
You can’t perform that action at this time.
0 commit comments