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