Compare commits

...

3 Commits

Author SHA1 Message Date
ms 337842370b
Merge f962d29eda into 0debb59474 2025-05-02 10:52:13 +02:00
Shotaro Nakamura 0debb59474
ci: add codestyle ci (#1149) 2025-05-02 16:51:42 +09:00
mani f962d29eda Pass optional state as parameter, so we can link other state info to it 2025-02-24 01:48:30 +02:00
7 changed files with 33 additions and 5 deletions

View File

@ -0,0 +1,5 @@
---
'@hono/oauth-providers': minor
---
Optionally pass state as an option to oauth provider

18
.github/workflows/codestyle.yml vendored 100644
View File

@ -0,0 +1,18 @@
name: codestyle
on:
push:
branches: [main]
pull_request:
branches: ['*']
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn
- run: yarn format
- run: yarn lint

View File

@ -12,10 +12,11 @@ export function discordAuth(options: {
client_id?: string client_id?: string
client_secret?: string client_secret?: string
redirect_uri?: string redirect_uri?: string
state?: string
}): MiddlewareHandler { }): MiddlewareHandler {
return async (c, next) => { return async (c, next) => {
// Generate encoded "keys" // Generate encoded "keys"
const newState = getRandomState() const newState = options.state || getRandomState()
// Create new Auth instance // Create new Auth instance
const auth = new AuthFlow({ const auth = new AuthFlow({

View File

@ -13,9 +13,10 @@ export function facebookAuth(options: {
client_id?: string client_id?: string
client_secret?: string client_secret?: string
redirect_uri?: string redirect_uri?: string
state?: string
}): MiddlewareHandler { }): MiddlewareHandler {
return async (c, next) => { return async (c, next) => {
const newState = getRandomState() const newState = options.state || getRandomState()
// Create new Auth instance // Create new Auth instance
const auth = new AuthFlow({ const auth = new AuthFlow({
client_id: options.client_id || (env(c).FACEBOOK_ID as string), client_id: options.client_id || (env(c).FACEBOOK_ID as string),

View File

@ -13,9 +13,10 @@ export function githubAuth(options: {
scope?: GitHubScope[] scope?: GitHubScope[]
oauthApp?: boolean oauthApp?: boolean
redirect_uri?: string redirect_uri?: string
state?: string
}): MiddlewareHandler { }): MiddlewareHandler {
return async (c, next) => { return async (c, next) => {
const newState = getRandomState() const newState = options.state || getRandomState()
// Create new Auth instance // Create new Auth instance
const auth = new AuthFlow({ const auth = new AuthFlow({
client_id: options.client_id || (env(c).GITHUB_ID as string), client_id: options.client_id || (env(c).GITHUB_ID as string),

View File

@ -13,9 +13,10 @@ export function linkedinAuth(options: {
scope?: LinkedInScope[] scope?: LinkedInScope[]
appAuth?: boolean appAuth?: boolean
redirect_uri?: string redirect_uri?: string
state?: string
}): MiddlewareHandler { }): MiddlewareHandler {
return async (c, next) => { return async (c, next) => {
const newState = getRandomState() const newState = options.state || getRandomState()
// Create new Auth instance // Create new Auth instance
const auth = new AuthFlow({ const auth = new AuthFlow({
client_id: options.client_id || (env(c).LINKEDIN_ID as string), client_id: options.client_id || (env(c).LINKEDIN_ID as string),

View File

@ -14,10 +14,11 @@ export function xAuth(options: {
client_id?: string client_id?: string
client_secret?: string client_secret?: string
redirect_uri?: string redirect_uri?: string
state?: string
}): MiddlewareHandler { }): MiddlewareHandler {
return async (c, next) => { return async (c, next) => {
// Generate encoded "keys" // Generate encoded "keys"
const newState = getRandomState() const newState = options.state || getRandomState()
const challenge = await getCodeChallenge() const challenge = await getCodeChallenge()
const auth = new AuthFlow({ const auth = new AuthFlow({