mirror of
https://github.com/SrIzan10/next-auth.git
synced 2026-05-01 10:55:20 +00:00
Compare commits
2 Commits
@auth/svel
...
@auth/svel
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57b176840e | ||
|
|
6298d955df |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@auth/sveltekit",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"description": "Authentication for SvelteKit.",
|
||||
"homepage": "https://sveltekit.authjs.dev",
|
||||
"repository": "https://github.com/nextauthjs/next-auth.git",
|
||||
@@ -15,7 +15,7 @@
|
||||
"scripts": {
|
||||
"dev": "svelte-package -w",
|
||||
"clean": "rm -rf client.* index.* package",
|
||||
"build": "pnpm clean && svelte-package && node ./scripts/postbuild.js && rm -rf package",
|
||||
"build": "pnpm clean && pnpm check && svelte-package && node ./scripts/postbuild.js && rm -rf package",
|
||||
"preview": "vite preview",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
|
||||
@@ -2,6 +2,7 @@ import { AUTH_SECRET, AUTH_TRUST_HOST, VERCEL } from "$env/static/private"
|
||||
import { dev } from "$app/environment"
|
||||
|
||||
import { AuthHandler, type AuthOptions, type AuthAction } from "@auth/core"
|
||||
import type { Handle } from "@sveltejs/kit"
|
||||
|
||||
export async function getServerSession(
|
||||
req: Request,
|
||||
@@ -48,11 +49,14 @@ const actions: AuthAction[] = [
|
||||
]
|
||||
|
||||
/** The main entry point to @auth/sveltekit */
|
||||
function SvelteKitAuth({ prefix = "/auth", ...options }: SvelteKitAuthOptions) {
|
||||
function SvelteKitAuth({
|
||||
prefix = "/auth",
|
||||
...options
|
||||
}: SvelteKitAuthOptions): Handle {
|
||||
options.secret ??= AUTH_SECRET
|
||||
options.trustHost ??= !!(AUTH_TRUST_HOST ?? VERCEL ?? dev)
|
||||
|
||||
return (({ event, resolve }) => {
|
||||
return ({ event, resolve }) => {
|
||||
const [action] = event.url.pathname.slice(prefix.length + 1).split("/")
|
||||
const isAuth = actions.includes(action as AuthAction)
|
||||
|
||||
@@ -65,7 +69,7 @@ function SvelteKitAuth({ prefix = "/auth", ...options }: SvelteKitAuthOptions) {
|
||||
}
|
||||
|
||||
return AuthHandler(event.request, options)
|
||||
}) satisfies Handle
|
||||
}
|
||||
}
|
||||
|
||||
export default SvelteKitAuth
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
// "extends": "./.svelte-kit/tsconfig.json",
|
||||
"extends": "./.svelte-kit/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
@@ -8,8 +8,7 @@
|
||||
"resolveJsonModule": true,
|
||||
"skipLibCheck": true,
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"moduleResolution": "node"
|
||||
"strict": true
|
||||
},
|
||||
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user