chore: format (includes other middleware)
parent
ef318bef47
commit
16b4462014
|
@ -66,7 +66,6 @@ export interface SignOutParams<R extends boolean = true> {
|
||||||
redirect?: R
|
redirect?: R
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface SessionProviderProps {
|
export interface SessionProviderProps {
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
session?: Session | null
|
session?: Session | null
|
||||||
|
@ -136,11 +135,11 @@ export function now() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseUrl(url?: string) {
|
export function parseUrl(url?: string) {
|
||||||
const defaultUrl = 'http://localhost:3000/api/auth';
|
const defaultUrl = 'http://localhost:3000/api/auth'
|
||||||
const parsedUrl = new URL(url?.startsWith('http') ? url : `https://${url}` || defaultUrl);
|
const parsedUrl = new URL(url?.startsWith('http') ? url : `https://${url}` || defaultUrl)
|
||||||
|
|
||||||
const path = parsedUrl.pathname === '/' ? '/api/auth' : parsedUrl.pathname.replace(/\/$/, '');
|
const path = parsedUrl.pathname === '/' ? '/api/auth' : parsedUrl.pathname.replace(/\/$/, '')
|
||||||
const base = `${parsedUrl.origin}${path}`;
|
const base = `${parsedUrl.origin}${path}`
|
||||||
|
|
||||||
return {
|
return {
|
||||||
origin: parsedUrl.origin,
|
origin: parsedUrl.origin,
|
||||||
|
@ -148,5 +147,5 @@ export function parseUrl(url?: string) {
|
||||||
path,
|
path,
|
||||||
base,
|
base,
|
||||||
toString: () => base,
|
toString: () => base,
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ export function authHandler(): MiddlewareHandler {
|
||||||
return async (c) => {
|
return async (c) => {
|
||||||
const config = c.get('authConfig')
|
const config = c.get('authConfig')
|
||||||
let ctxEnv = env(c) as AuthEnv
|
let ctxEnv = env(c) as AuthEnv
|
||||||
|
|
||||||
setEnvDefaults(ctxEnv, config)
|
setEnvDefaults(ctxEnv, config)
|
||||||
|
|
||||||
if (!config.secret || config.secret.length === 0) {
|
if (!config.secret || config.secret.length === 0) {
|
||||||
|
@ -128,4 +128,4 @@ export function authHandler(): MiddlewareHandler {
|
||||||
const res = await Auth(reqWithEnvUrl(c.req.raw, ctxEnv.AUTH_URL), config)
|
const res = await Auth(reqWithEnvUrl(c.req.raw, ctxEnv.AUTH_URL), config)
|
||||||
return new Response(res.body, res)
|
return new Response(res.body, res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,8 +192,8 @@ describe('Credentials Provider', () => {
|
||||||
|
|
||||||
it('Should respect x-forwarded-proto and x-forwarded-host', async () => {
|
it('Should respect x-forwarded-proto and x-forwarded-host', async () => {
|
||||||
const headers = new Headers()
|
const headers = new Headers()
|
||||||
headers.append('x-forwarded-proto', "https")
|
headers.append('x-forwarded-proto', 'https')
|
||||||
headers.append('x-forwarded-host', "example.com")
|
headers.append('x-forwarded-host', 'example.com')
|
||||||
const res = await app.request('http://localhost/api/auth/signin', {
|
const res = await app.request('http://localhost/api/auth/signin', {
|
||||||
headers,
|
headers,
|
||||||
})
|
})
|
||||||
|
|
|
@ -20,7 +20,7 @@ export interface NodeWebSocketInit {
|
||||||
* @returns NodeWebSocket
|
* @returns NodeWebSocket
|
||||||
*/
|
*/
|
||||||
export const createNodeWebSocket = (init: NodeWebSocketInit): NodeWebSocket => {
|
export const createNodeWebSocket = (init: NodeWebSocketInit): NodeWebSocket => {
|
||||||
const wss = new WebSocketServer({noServer: true})
|
const wss = new WebSocketServer({ noServer: true })
|
||||||
|
|
||||||
return {
|
return {
|
||||||
injectWebSocket(server) {
|
injectWebSocket(server) {
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
import { Hono } from 'hono'
|
import { Hono } from 'hono'
|
||||||
import type { Equal, Expect } from 'hono/utils/types'
|
import type { Equal, Expect } from 'hono/utils/types'
|
||||||
import { number, object, string, optional, numberAsync, objectAsync, stringAsync, optionalAsync } from 'valibot'
|
import {
|
||||||
|
number,
|
||||||
|
object,
|
||||||
|
string,
|
||||||
|
optional,
|
||||||
|
numberAsync,
|
||||||
|
objectAsync,
|
||||||
|
stringAsync,
|
||||||
|
optionalAsync,
|
||||||
|
} from 'valibot'
|
||||||
import { vValidator } from '../src'
|
import { vValidator } from '../src'
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
|
Loading…
Reference in New Issue