fix(oauth-providers): oauth-middleware: load `env.SECRETS` with hono/adapter (#588)
* load env with hono/adapter * add changeset * update changeset typepull/592/head
parent
352e74fcbe
commit
69eca66e4d
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@hono/oauth-providers': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
load env.SECRET with hono/adapter, to support non-worker
|
|
@ -1,5 +1,6 @@
|
||||||
import type { MiddlewareHandler } from 'hono'
|
import type { MiddlewareHandler } from 'hono'
|
||||||
import { setCookie, getCookie } from 'hono/cookie'
|
import { setCookie, getCookie } from 'hono/cookie'
|
||||||
|
import { env } from 'hono/adapter'
|
||||||
import { HTTPException } from 'hono/http-exception'
|
import { HTTPException } from 'hono/http-exception'
|
||||||
|
|
||||||
import { getRandomState } from '../../utils/getRandomState'
|
import { getRandomState } from '../../utils/getRandomState'
|
||||||
|
@ -17,8 +18,8 @@ export function discordAuth(options: {
|
||||||
|
|
||||||
// Create new Auth instance
|
// Create new Auth instance
|
||||||
const auth = new AuthFlow({
|
const auth = new AuthFlow({
|
||||||
client_id: options.client_id || (c.env?.DISCORD_ID as string),
|
client_id: options.client_id || (env(c).DISCORD_ID as string),
|
||||||
client_secret: options.client_secret || (c.env?.DISCORD_SECRET as string),
|
client_secret: options.client_secret || (env(c).DISCORD_SECRET as string),
|
||||||
redirect_uri: c.req.url.split('?')[0],
|
redirect_uri: c.req.url.split('?')[0],
|
||||||
scope: options.scope,
|
scope: options.scope,
|
||||||
state: newState,
|
state: newState,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import type { MiddlewareHandler } from 'hono'
|
import type { MiddlewareHandler } from 'hono'
|
||||||
import { setCookie, getCookie } from 'hono/cookie'
|
import { setCookie, getCookie } from 'hono/cookie'
|
||||||
|
import { env } from 'hono/adapter'
|
||||||
import { HTTPException } from 'hono/http-exception'
|
import { HTTPException } from 'hono/http-exception'
|
||||||
|
|
||||||
import { getRandomState } from '../../utils/getRandomState'
|
import { getRandomState } from '../../utils/getRandomState'
|
||||||
|
@ -16,8 +17,8 @@ export function facebookAuth(options: {
|
||||||
const newState = getRandomState()
|
const newState = getRandomState()
|
||||||
// Create new Auth instance
|
// Create new Auth instance
|
||||||
const auth = new AuthFlow({
|
const auth = new AuthFlow({
|
||||||
client_id: options.client_id || (c.env?.FACEBOOK_ID as string),
|
client_id: options.client_id || (env(c).FACEBOOK_ID as string),
|
||||||
client_secret: options.client_secret || (c.env?.FACEBOOK_SECRET as string),
|
client_secret: options.client_secret || (env(c).FACEBOOK_SECRET as string),
|
||||||
redirect_uri: c.req.url.split('?')[0],
|
redirect_uri: c.req.url.split('?')[0],
|
||||||
scope: options.scope,
|
scope: options.scope,
|
||||||
fields: options.fields,
|
fields: options.fields,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import type { MiddlewareHandler } from 'hono'
|
import type { MiddlewareHandler } from 'hono'
|
||||||
import { getCookie, setCookie } from 'hono/cookie'
|
import { getCookie, setCookie } from 'hono/cookie'
|
||||||
|
import { env } from 'hono/adapter'
|
||||||
import { HTTPException } from 'hono/http-exception'
|
import { HTTPException } from 'hono/http-exception'
|
||||||
|
|
||||||
import { getRandomState } from '../../utils/getRandomState'
|
import { getRandomState } from '../../utils/getRandomState'
|
||||||
|
@ -16,8 +17,8 @@ export function githubAuth(options: {
|
||||||
const newState = getRandomState()
|
const newState = getRandomState()
|
||||||
// Create new Auth instance
|
// Create new Auth instance
|
||||||
const auth = new AuthFlow({
|
const auth = new AuthFlow({
|
||||||
client_id: options.client_id || (c.env?.GITHUB_ID as string),
|
client_id: options.client_id || (env(c).GITHUB_ID as string),
|
||||||
client_secret: options.client_secret || (c.env?.GITHUB_SECRET as string),
|
client_secret: options.client_secret || (env(c).GITHUB_SECRET as string),
|
||||||
scope: options.scope,
|
scope: options.scope,
|
||||||
state: newState,
|
state: newState,
|
||||||
oauthApp: options.oauthApp || false,
|
oauthApp: options.oauthApp || false,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import type { MiddlewareHandler } from 'hono'
|
import type { MiddlewareHandler } from 'hono'
|
||||||
import { getCookie, setCookie } from 'hono/cookie'
|
import { getCookie, setCookie } from 'hono/cookie'
|
||||||
|
import { env } from 'hono/adapter'
|
||||||
import { HTTPException } from 'hono/http-exception'
|
import { HTTPException } from 'hono/http-exception'
|
||||||
|
|
||||||
import { getRandomState } from '../../utils/getRandomState'
|
import { getRandomState } from '../../utils/getRandomState'
|
||||||
|
@ -17,8 +18,8 @@ export function googleAuth(options: {
|
||||||
const newState = options.state || 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 || (c.env?.GOOGLE_ID as string),
|
client_id: options.client_id || (env(c).GOOGLE_ID as string),
|
||||||
client_secret: options.client_secret || (c.env?.GOOGLE_SECRET as string),
|
client_secret: options.client_secret || (env(c).GOOGLE_SECRET as string),
|
||||||
redirect_uri: c.req.url.split('?')[0],
|
redirect_uri: c.req.url.split('?')[0],
|
||||||
login_hint: options.login_hint,
|
login_hint: options.login_hint,
|
||||||
prompt: options.prompt,
|
prompt: options.prompt,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import type { MiddlewareHandler } from 'hono'
|
import type { MiddlewareHandler } from 'hono'
|
||||||
import { getCookie, setCookie } from 'hono/cookie'
|
import { getCookie, setCookie } from 'hono/cookie'
|
||||||
|
import { env } from 'hono/adapter'
|
||||||
import { HTTPException } from 'hono/http-exception'
|
import { HTTPException } from 'hono/http-exception'
|
||||||
|
|
||||||
import { getRandomState } from '../../utils/getRandomState'
|
import { getRandomState } from '../../utils/getRandomState'
|
||||||
|
@ -16,8 +17,8 @@ export function linkedinAuth(options: {
|
||||||
const newState = getRandomState()
|
const newState = getRandomState()
|
||||||
// Create new Auth instance
|
// Create new Auth instance
|
||||||
const auth = new AuthFlow({
|
const auth = new AuthFlow({
|
||||||
client_id: options.client_id || (c.env?.LINKEDIN_ID as string),
|
client_id: options.client_id || (env(c).LINKEDIN_ID as string),
|
||||||
client_secret: options.client_secret || (c.env?.LINKEDIN_SECRET as string),
|
client_secret: options.client_secret || (env(c).LINKEDIN_SECRET as string),
|
||||||
redirect_uri: c.req.url.split('?')[0],
|
redirect_uri: c.req.url.split('?')[0],
|
||||||
scope: options.scope,
|
scope: options.scope,
|
||||||
state: newState,
|
state: newState,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import type { MiddlewareHandler } from 'hono'
|
import type { MiddlewareHandler } from 'hono'
|
||||||
import { getCookie, setCookie } from 'hono/cookie'
|
import { getCookie, setCookie } from 'hono/cookie'
|
||||||
|
import { env } from 'hono/adapter'
|
||||||
import { HTTPException } from 'hono/http-exception'
|
import { HTTPException } from 'hono/http-exception'
|
||||||
|
|
||||||
import { getCodeChallenge } from '../../utils/getCodeChallenge'
|
import { getCodeChallenge } from '../../utils/getCodeChallenge'
|
||||||
|
@ -19,8 +20,8 @@ export function xAuth(options: {
|
||||||
const challenge = await getCodeChallenge()
|
const challenge = await getCodeChallenge()
|
||||||
|
|
||||||
const auth = new AuthFlow({
|
const auth = new AuthFlow({
|
||||||
client_id: options.client_id || (c.env?.X_ID as string),
|
client_id: options.client_id || (env(c).X_ID as string),
|
||||||
client_secret: options.client_secret || (c.env?.X_SECRET as string),
|
client_secret: options.client_secret || (env(c).X_SECRET as string),
|
||||||
redirect_uri: c.req.url.split('?')[0],
|
redirect_uri: c.req.url.split('?')[0],
|
||||||
scope: options.scope,
|
scope: options.scope,
|
||||||
fields: options.fields,
|
fields: options.fields,
|
||||||
|
|
Loading…
Reference in New Issue