Compare commits

..

24 Commits

Author SHA1 Message Date
Nico Domino
a6ac48314e chore(actions): issue-validator path to 'repro.md' (#6051) 2022-12-14 15:36:30 +01:00
Balázs Orbán
f8675bc245 fix(sveltekit): add svelte as peer dependency, fix env vars 2022-12-14 15:32:19 +01:00
Balázs Orbán
3d4842dcc9 fix(core): change imports 2022-12-14 15:31:57 +01:00
Balázs Orbán
7d7d1b2f80 chore(release): bump package version(s) [skip ci] 2022-12-14 13:27:31 +01:00
Balázs Orbán
9a4f3db7b0 chore: format 2022-12-14 13:10:13 +01:00
Balázs Orbán
6aad07a95c chore: update lock file 2022-12-14 13:10:13 +01:00
Balázs Orbán
cfed5b976f fix(sveltekit): include module augmentation 2022-12-14 13:10:13 +01:00
Balázs Orbán
d34108091f fix(core): use preact as JSX runtime 2022-12-14 13:10:13 +01:00
Balázs Orbán
7bf79b89a8 chore(sveltekit): clean up playground 2022-12-14 13:10:13 +01:00
Balázs Orbán
4cd688703a fix(core): drop "in production" from missing secret error 2022-12-14 13:10:13 +01:00
Balázs Orbán
57b176840e chore(release): bump package version(s) [skip ci] 2022-12-14 09:49:43 +01:00
Thang Vu
6298d955df fix(frameworks): run check before building for @auth/sveltekit (#6044)
* fix(frameworks): run check before building for @auth/sveltekit

* run format
2022-12-14 15:44:08 +07:00
Balázs Orbán
2ad1cb3f8c chore(release): bump package version(s) [skip ci] 2022-12-14 02:51:15 +01:00
Balázs Orbán
98707282eb fix(release): tweak package metadata 2022-12-14 02:45:57 +01:00
Balázs Orbán
f4a2430891 fix(release): build packages before publish 2022-12-14 02:45:18 +01:00
Balázs Orbán
575bcb5710 chore: format sveltekit playground 2022-12-13 23:45:32 +01:00
Balázs Orbán
e7af366a3b chore(release): bump package version(s) [skip ci] 2022-12-13 22:04:43 +01:00
Balázs Orbán
3bdf7f56f0 fix(core): update README 2022-12-13 21:57:30 +01:00
Balázs Orbán
b00a694a4f fix(frameworks): update @auth/sveltekit README 2022-12-13 21:56:53 +01:00
Balázs Orbán
6ffecfb87d chore(release): bump package version(s) [skip ci] 2022-12-13 21:53:56 +01:00
Balázs Orbán
22c29361e5 feat(frameworks): Introduce SvelteKit Auth 2022-12-13 21:48:15 +01:00
Balázs Orbán
b157554a5f chore: move 2022-12-13 21:33:27 +01:00
Balázs Orbán
08fed7eddd chore: empty commit 2022-12-13 21:21:22 +01:00
Thang Vu
b5e1b19771 feat(frameworks): Introduce SvelteKit Auth (#6041)
* WIP use `Request` and `Response` for core

* bump Next.js

* rename ts types

* refactor

* simplify

* upgrade Next.js

* implement body reader

* use `Request`/`Response` in `next-auth/next`

* make linter happy

* revert

* fix tests

* remove workaround for middleware return type

* return session in protected api route example

* don't export internal handler

* fall back host to localhost

* refactor `getBody`

* refactor `next-auth/next`

* chore: add `@edge-runtime/jest-environment`

* fix tests, using Node 18 as runtime

* fix test

* remove patch

* upgrade/add dependencies

* type and default import on one line

* don't import all adapters by default in dev

* simplify internal endpoint config

Instead of passing url and params around as a string and an object,
we parse them into a `URL` instance.

* assert if both endpoint and issuer config is missing

* allow internal redirect to be `URL`

* mark clientId as always internally, fix comments

* add web-compatible authorization URL handling

* fix type

* fix neo4j build

* remove new-line

* reduce file changes in the PR

* simplify types

* refactor `crypto` usage

In Node.js, inject `globalThis.crypto` instead of import

* add `next-auth/web`

* refactor

* send header instead of body to indicate redirect response

* fix eslint

* fix tests

* chore: upgrade dep

* fix import

* refactor: more renames

* wip core

* support OIDC

* remove `openid-client`

* temprarily remove duplicate logos

* revert

* move redirect logic to core

* feat: add sveltekit auth

* wip fix css

* revert Logo component

* output ESM

* fix logout

* deprecate OAuth 1,  simplify internals, improve defaults

* refactor providers, test facebook

* fix providers

* target es2020

* fix CSS

* fix AuthHandler, add getServerSession

* update lock file

* make logos optional

* sync with `next-auth`

* clean up `next-auth/edge`

* sync

* Sync (#2)

* fix(core): properly construct url (#5984)

* chore(release): bump package version(s) [skip ci]

* fix(core): add protocol if missing

* fix(core): throw error if no action can be determined

* test(core): fix test

* chore(release): bump package version(s) [skip ci]

* chore(docs): add new tutorial (#5604)

Co-authored-by: Nico Domino <yo@ndo.dev>

* fix(core): handle `Request` -> `Response` regressions  (#5991)

* fix(next): don't override `Content-Type` by `unstable_getServerSession`

* fix(core): handle `,` while setting `set-cookie`

* chore(release): bump package version(s) [skip ci]

* fix(sequelize): increase sequelize `id_token` column length (#5929)

Co-authored-by: Nico Domino <yo@ndo.dev>

* fix(core): correct status code when returning redirects (#6004)

* fix(core): correctly set status when returning redirect

* update tests

* forward other headers

* update test

* remove default 200 status

* fix(core): host detection/NEXTAUTH_URL (#6007)

* rename `host` to `origin` internally

* rename `userOptions` to `authOptions` internally

* use object for `headers` internally

* default `method` to GET

* simplify `unstable_getServerSession`

* allow optional headers

* revert middleware

* wip getURL

* revert host detection

* use old `detectHost`

* fix/add some tests wip

* move more to core, refactor getURL

* better type auth actions

* fix custom path support (w/ api/auth)

* add `getURL` tests

* fix email tests

* fix assert tests

* custom base without api/auth, with trailing slash

* remove parseUrl from assert.ts

* return 400 when wrong url

* fix tests

* refactor

* fix protocol in dev

* fix tests

* fix custom url handling

* add todo comments

* chore(release): bump package version(s) [skip ci]

* update lock file

* fix(next): correctly bundle next-auth/middleware
fixes #6025

* fix(core): preserve incoming set cookies (#6029)

* fix(core): preserve `set-cookie` by the user

* add test

* improve req/res mocking

* refactor

* fix comment typo

* chore(release): bump package version(s) [skip ci]

* make logos optional

* sync with `next-auth`

* clean up `next-auth/edge`

* sync

Co-authored-by: Balázs Orbán <balazsorban44@users.noreply.github.com>
Co-authored-by: Thomas Desmond <24610108+thomas-desmond@users.noreply.github.com>
Co-authored-by: Nico Domino <yo@ndo.dev>
Co-authored-by: Cyril Perraud <perraud.cyril@gmail.com>

* merge

* clean up sveltekit auth handler

* upgrade playground to latest

* upgrade sveltekit auth to latest

* Some more refactoring

* feat: extract type to core and reuse in sveltekit

* remove uuid

* make secret required in dev

* remove todo comments

* pass through OAuth client options

* generate declaration map

* default env secret to AUTH_SECRET

* temporary Headers fix

* move pages to lib

* move errors to lib

* move pages/index to lib

* move routes to lib

* move init to lib

* move styles to lib

* move types to lib

* move utils to lib

* fix imports

* update ignore/clean patterns

* fix imports

* update styles ts

* update gitignore

* update exports field

* revert `next-auth`

* remove extra tsconfig files

* remove `private` from package.json

* revert

* feat sveltekit

* commit

* remove unused file, expose type

* remove nextauth_url, memoize locals.getSession

* move to dependency

* fix

* format

* fix post build

* simplify

* fix lock file

* add packages/frameworks

* update package.json

* update gitignore

* Delete .gitignore

* Update types.ts

* Update tsconfig.dev.json

* skip test

* format

* skip format/lint

Co-authored-by: Balázs Orbán <info@balazsorban.com>
Co-authored-by: Balázs Orbán <balazsorban44@users.noreply.github.com>
Co-authored-by: Thomas Desmond <24610108+thomas-desmond@users.noreply.github.com>
Co-authored-by: Nico Domino <yo@ndo.dev>
Co-authored-by: Cyril Perraud <perraud.cyril@gmail.com>
2022-12-13 20:10:53 +00:00
122 changed files with 2673 additions and 2891 deletions

View File

@@ -18,6 +18,7 @@ module.exports = {
parserOptions: {
project: [
path.resolve(__dirname, "./packages/**/tsconfig.eslint.json"),
path.resolve(__dirname, "./packages/frameworks/**/tsconfig.json"),
path.resolve(__dirname, "./apps/**/tsconfig.json"),
],
},

View File

@@ -4,11 +4,8 @@ import * as github from "@actions/github"
// @ts-expect-error
import * as core from "@actions/core"
import { readFileSync } from "node:fs"
import { join } from "node:path"
const addReproductionLabel = "incomplete"
const __dirname =
"/home/runner/work/nextauthjs/next-auth/.github/actions/issue-validator"
/**
* @typedef {{
@@ -73,7 +70,7 @@ async function run() {
}),
client.issues.createComment({
...issueCommon,
body: readFileSync(join(__dirname, "repro.md"), "utf8"),
body: readFileSync("repro.md", "utf8"),
}),
])
return core.info(

11
.gitignore vendored
View File

@@ -85,4 +85,13 @@ packages/core/adapters.*
packages/core/index.*
packages/core/jwt
packages/core/lib
packages/core/providers
packages/core/providers
# SvelteKit
packages/frameworks-sveltekit/index.*
packages/frameworks-sveltekit/client.*
packages/frameworks-sveltekit/.svelte-kit
packages/frameworks-sveltekit/package
packages/frameworks-sveltekit/vite.config.js.timestamp-*
packages/frameworks-sveltekit/vite.config.ts.timestamp-*

View File

@@ -1,4 +1,5 @@
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
NEXTAUTH_SECRET=
PUBLIC_NEXTAUTH_URL=http://localhost:5173
GITHUB_ID=
GITHUB_SECRET=
# On UNIX systems you can use `openssl rand -hex 32` or
# https://generate-secret.vercel.app/32 to generate a secret.
AUTH_SECRET=

View File

@@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock

View File

@@ -1,24 +1,20 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
],
plugins: ["svelte3", "@typescript-eslint"],
ignorePatterns: ["*.cjs", "build/**/*"],
overrides: [{ files: ["*.svelte"], processor: "svelte3/svelte3" }],
settings: {
"svelte3/typescript": () => require("typescript"),
},
parserOptions: {
sourceType: "module",
ecmaVersion: 2020,
},
env: {
browser: true,
es2017: true,
node: true,
},
}
root: true,
parser: '@typescript-eslint/parser',
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
plugins: ['svelte3', '@typescript-eslint'],
ignorePatterns: ['*.cjs'],
overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
settings: {
'svelte3/typescript': () => require('typescript')
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020
},
env: {
browser: true,
es2017: true,
node: true
}
};

View File

@@ -6,3 +6,7 @@ node_modules
.env
.env.*
!.env.example
.vercel
.output
vite.config.js.timestamp-*
vite.config.ts.timestamp-*

View File

@@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock

View File

@@ -0,0 +1,6 @@
{
"semi": false,
"plugins": ["prettier-plugin-svelte"],
"pluginSearchDirs": ["."],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}

View File

@@ -1,43 +1,23 @@
{
"name": "sveltekit-nextauth",
"private": true,
"version": "0.0.1",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"start": "HOST=127.0.0.1 PORT=5173 ORIGIN=http://localhost:5173 node ./build",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"format": "prettier --write ."
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^1.0.0-next.80",
"@sveltejs/adapter-node": "1.0.0-next.96",
"@sveltejs/kit": "1.0.0-next.511",
"@types/cookie": "^0.5.1",
"@typescript-eslint/eslint-plugin": "^5.35.1",
"@typescript-eslint/parser": "^5.35.1",
"eslint": "^8.22.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-svelte3": "^4.0.0",
"prettier": "^2.7.1",
"prettier-plugin-svelte": "^2.7.0",
"svelte": "^3.49.0",
"svelte-check": "^2.8.1",
"svelte-preprocess": "^4.10.7",
"tslib": "^2.4.0",
"typescript": "~4.8.2",
"vite": "^3.1.0"
"@sveltejs/adapter-auto": "next",
"@sveltejs/kit": "next",
"svelte": "3.55.0",
"svelte-check": "2.10.2",
"typescript": "4.9.4",
"vite": "4.0.1"
},
"type": "module",
"dependencies": {
"cookie": "0.5.0",
"next-auth": "latest"
"@auth/core": "workspace:*",
"@auth/sveltekit": "workspace:*"
},
"prettier": {
"semi": false,
"singleQuote": false
}
"type": "module"
}

View File

@@ -1,30 +1 @@
/// <reference types="@sveltejs/kit" />
import type {
User as NextAuthUser,
Session as NextAuthSession,
} from "next-auth"
// optionally extend the `user`
interface User extends NextAuthUser {
// add custom fields here
}
interface AppSession extends NextAuthSession {
user: User
}
// See https://kit.svelte.dev/docs/typescript
// for information about these interfaces
declare global {
declare namespace App {
interface Locals {
session: AppSession
}
interface Platform {}
interface Session extends AppSession {}
interface Stuff {}
}
}
/// <reference types="@auth/sveltekit" />

View File

@@ -2,10 +2,11 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<link rel="icon" href="%sveltekit.assets%/favicon.ico" />
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
</head>
<body>
<div>%sveltekit.body%</div>
</body>

View File

@@ -1,14 +1,7 @@
import type { Handle } from "@sveltejs/kit"
import { getServerSession, options as nextAuthOptions } from "$lib/next-auth"
import SvelteKitAuth from "@auth/sveltekit"
import GitHub from "@auth/core/providers/github"
import { GITHUB_ID, GITHUB_SECRET } from "$env/static/private"
export const handle: Handle = async function handle({
event,
resolve,
}): Promise<Response> {
const session = await getServerSession(event.request, nextAuthOptions)
if (session) {
event.locals.session = session
}
return resolve(event)
}
export const handle = SvelteKitAuth({
providers: [GitHub({ clientId: GITHUB_ID, clientSecret: GITHUB_SECRET })],
})

View File

@@ -0,0 +1,12 @@
<script lang="ts">
export let provider: any
</script>
<form action={provider.signinUrl} method="POST">
{#if provider.callbackUrl}
<input type="hidden" name="callbackUrl" value={provider.callbackUrl} />
{/if}
<button type="submit" class="button">
<slot>Sign in with {provider.name}</slot>
</button>
</form>

View File

@@ -1,144 +0,0 @@
import type { ServerLoadEvent } from "@sveltejs/kit"
import type { RequestInternal } from "next-auth"
import type { NextAuthAction, NextAuthOptions } from "next-auth/core/types"
import type { OutgoingResponse as NextAuthResponse } from "next-auth/core"
import { NextAuthHandler } from "next-auth/core"
import GithubProvider from "next-auth/providers/github"
import cookie from "cookie"
import {
GITHUB_CLIENT_ID,
GITHUB_CLIENT_SECRET,
NEXTAUTH_SECRET,
} from "$env/static/private"
import { PUBLIC_NEXTAUTH_URL } from "$env/static/public"
// @ts-expect-error import is exported on .default during SSR
const github = GithubProvider?.default || GithubProvider
export const options: NextAuthOptions = {
providers: [
github({
clientId: GITHUB_CLIENT_ID,
clientSecret: GITHUB_CLIENT_SECRET,
}),
],
}
const toSvelteKitResponse = async <
T extends string | any[] | Record<string, any>
>(
request: Request,
nextAuthResponse: NextAuthResponse<T>
): Promise<Response> => {
const { cookies, redirect } = nextAuthResponse
const headers = new Headers()
for (const header of nextAuthResponse?.headers || []) {
// pass headers along from next-auth
headers.set(header.key, header.value)
}
// set-cookie header
if (cookies?.length) {
headers.set(
"set-cookie",
cookies
?.map((item) => cookie.serialize(item.name, item.value, item.options))
.join(",") as string
)
}
let body = undefined
let status = nextAuthResponse.status || 200
if (redirect) {
let formData: FormData | null = null
try {
formData = await request.formData()
} catch {
// no formData passed
}
const { json } = Object.fromEntries(formData ?? [])
if (json !== "true") {
status = 302
headers.set("Location", redirect)
} else {
body = { url: redirect }
}
} else {
body = nextAuthResponse.body
}
// @ts-expect-error - body is a known HTML document or JSON object
return new Response(body, {
status,
headers,
})
}
const SKNextAuthHandler = async (
{ request, url, params }: ServerLoadEvent,
options: NextAuthOptions
): Promise<Response> => {
const [action, provider] = params.nextauth!.split("/")
let body: FormData | undefined
try {
body = await request.formData()
} catch {
// no formData passed
}
options.secret = NEXTAUTH_SECRET
const req: RequestInternal = {
host: PUBLIC_NEXTAUTH_URL,
body: Object.fromEntries(body ?? []),
query: Object.fromEntries(url.searchParams),
headers: request.headers,
method: request.method,
cookies: cookie.parse(request.headers.get("cookie") || ""),
action: action as NextAuthAction,
providerId: provider,
error: provider,
}
const response = await NextAuthHandler({
req,
options,
})
return toSvelteKitResponse(request, response)
}
export const getServerSession = async (
request: Request,
options: NextAuthOptions
): Promise<App.Session | null> => {
options.secret = NEXTAUTH_SECRET
const session = await NextAuthHandler<App.Session>({
req: {
host: PUBLIC_NEXTAUTH_URL,
action: "session",
method: "GET",
cookies: cookie.parse(request.headers.get("cookie") || ""),
headers: request.headers,
},
options,
})
const { body } = session
if (body && Object.keys(body).length) {
return body as App.Session
}
return null
}
export const NextAuth = (
options: NextAuthOptions
): {
GET: (event: ServerLoadEvent) => Promise<unknown>
POST: (event: ServerLoadEvent) => Promise<unknown>
} => ({
GET: (event) => SKNextAuthHandler(event, options),
POST: (event) => SKNextAuthHandler(event, options),
})

View File

@@ -1,7 +1,7 @@
import type { LayoutServerLoad } from "./$types"
export const load: LayoutServerLoad = ({ locals }) => {
export const load: LayoutServerLoad = async (event) => {
return {
session: locals.session,
session: await event.locals.getSession(),
}
}

View File

@@ -6,8 +6,8 @@
<header>
<div class="signedInStatus">
<p class="nojs-show loaded">
{#if Object.keys($page.data.session || {}).length}
{#if $page.data.session.user.image}
{#if $page.data.session}
{#if $page.data.session.user?.image}
<span
style="background-image: url('{$page.data.session.user.image}')"
class="avatar"
@@ -16,14 +16,14 @@
<span class="signedInText">
<small>Signed in as</small><br />
<strong
>{$page.data.session.user.email ||
$page.data.session.user.name}</strong
>{$page.data.session.user?.email ??
$page.data.session.user?.name}</strong
>
</span>
<a href="/api/auth/signout" class="button">Sign out</a>
<a href="/auth/signout" class="button">Sign out</a>
{:else}
<span class="notSignedInText">You are not signed in</span>
<a href="/api/auth/signin" class="buttonPrimary">Sign in</a>
<a href="/auth/signin" class="buttonPrimary">Sign in</a>
{/if}
</p>
</div>

View File

@@ -1,7 +1,33 @@
<h1>SvelteKit + NextAuth.js Example</h1>
<script>
import { signIn, signOut } from "@auth/sveltekit/client"
import { page } from "$app/stores"
</script>
<h1>SvelteKit Auth Example</h1>
<p>
This is an example site to demonstrate how to use <a
href="https://kit.svelte.dev/">SvelteKit</a
>
with <a href="https://next-auth.js.org">NextAuth.js</a> for authentication.
with <a href="https://sveltekit.authjs.dev">SvelteKit Auth</a> for
authentication.
{#if $page.data.session}
{#if $page.data.session.user?.image}
<span
style="background-image: url('{$page.data.session.user.image}')"
class="avatar"
/>
{/if}
<span class="signedInText">
<small>Signed in as</small><br />
<strong
>{$page.data.session.user?.email ??
$page.data.session.user?.name}</strong
>
</span>
<button on:click={() => signOut()} class="button">Sign out</button>
{:else}
<span class="notSignedInText">You are not signed in</span>
<button on:click={() => signIn("github")}>Sign In with GitHub</button>
{/if}
</p>

View File

@@ -1,3 +0,0 @@
import { NextAuth, options } from "$lib/next-auth"
export const { GET, POST } = NextAuth(options)

View File

@@ -7,4 +7,4 @@
This is a protected content. You can access this content because you are
signed in.
</p>
<p>Session expiry: {$page.data.session.expires}</p>
<p>Session expiry: {$page.data.session?.expires}</p>

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -1,14 +1,15 @@
import adapter from "@sveltejs/adapter-node" // or use https://github.com/sveltejs/kit/tree/master/packages/adapter-auto
import preprocess from "svelte-preprocess"
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/kit/vite';
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors
preprocess: preprocess(),
kit: {
adapter: adapter(),
},
}
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: vitePreprocess(),
export default config
kit: {
adapter: adapter()
}
};
export default config;

View File

@@ -1,17 +1,17 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true
}
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
//
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in
}
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true
}
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
//
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in
}

View File

@@ -1,7 +1,7 @@
import { sveltekit } from "@sveltejs/kit/vite"
import type { UserConfig } from "vite"
const config: UserConfig = {
/** @type {import('vite').UserConfig} */
const config = {
plugins: [sveltekit()],
}

File diff suppressed because it is too large Load Diff

View File

@@ -5,12 +5,13 @@
"repository": "https://github.com/nextauthjs/next-auth.git",
"scripts": {
"build:app": "turbo run build --filter=next-auth-app",
"build": "turbo run build --filter=next-auth --filter=@next-auth/* --no-deps",
"build": "turbo run build --filter=next-auth --filter=@next-auth/* --filter=@auth/* --no-deps",
"lint": "turbo run lint --filter=!next-auth-docs --parallel",
"test": "turbo run test --concurrency=1 --filter=!@next-auth/pouchdb-adapter --filter=!@next-auth/upstash-redis-adapter --filter=!next-auth-* --filter=[HEAD^1]",
"clean": "turbo run clean --no-cache",
"dev:db": "turbo run dev --parallel --continue --filter=next-auth-app...",
"dev": "turbo run dev --parallel --continue --filter=next-auth-app... --filter=!./packages/adapter-*",
"dev:kit": "turbo run dev --parallel --continue --filter=sveltekit-nextauth...",
"dev:docs": "turbo run dev --filter=next-auth-docs",
"email": "cd apps/dev && pnpm email",
"release": "release",
@@ -31,7 +32,7 @@
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.0.0",
"husky": "^7.0.4",
"prettier": "2.7.1",
"prettier": "2.8.1",
"pretty-quick": "^3.1.2",
"semver": "7.3.5",
"stream-to-array": "2.3.0",
@@ -69,5 +70,10 @@
"type": "opencollective",
"url": "https://opencollective.com/nextauth"
}
]
],
"pnpm": {
"overrides": {
"undici": "5.11.0"
}
}
}

3
packages/core/README.md Normal file
View File

@@ -0,0 +1,3 @@
# Auth.js
Authentication for the web.

View File

@@ -1,8 +1,8 @@
{
"name": "@auth/core",
"version": "0.1.0",
"version": "0.1.3",
"description": "Authentication for the web.",
"homepage": "https://next-auth.js.org",
"homepage": "https://authjs.dev",
"repository": "https://github.com/nextauthjs/next-auth.git",
"author": "Balázs Orbán <info@balazsorban.com>",
"contributors": [
@@ -44,7 +44,7 @@
"@panva/hkdf": "1.0.2",
"cookie": "0.5.0",
"jose": "4.11.1",
"oauth4webapi": "2.0.4",
"oauth4webapi": "2.0.5",
"preact": "10.11.3",
"preact-render-to-string": "5.2.3"
},

View File

@@ -1,4 +1,4 @@
import type { Account, Awaitable, User } from "."
import type { Account, Awaitable, User } from "./index.js"
export interface AdapterUser extends User {
id: string

View File

@@ -1,20 +1,20 @@
import { init } from "./lib/init"
import { assertConfig } from "./lib/assert"
import { SessionStore } from "./lib/cookie"
import { toInternalRequest, toResponse } from "./lib/web"
import renderPage from "./lib/pages"
import * as routes from "./lib/routes"
import logger, { setLogger } from "./lib/utils/logger"
import { init } from "./lib/init.js"
import { assertConfig } from "./lib/assert.js"
import { SessionStore } from "./lib/cookie.js"
import { toInternalRequest, toResponse } from "./lib/web.js"
import renderPage from "./lib/pages/index.js"
import * as routes from "./lib/routes/index.js"
import logger, { setLogger } from "./lib/utils/logger.js"
import type { ErrorType } from "./lib/pages/error"
import type { ErrorType } from "./lib/pages/error.js"
import type {
AuthOptions,
RequestInternal,
ResponseInternal,
} from "./lib/types"
import { UntrustedHost } from "./lib/errors"
} from "./lib/types.js"
import { UntrustedHost } from "./lib/errors.js"
export * from "./lib/types"
export * from "./lib/types.js"
const configErrorMessage =
"There is a problem with the server configuration. Check the server logs for more information."
@@ -35,7 +35,7 @@ async function AuthHandlerInternal<
assertionResult.forEach(logger.warn)
} else if (assertionResult instanceof Error) {
// Bail out early if there's an error in the user config
logger.error(assertionResult.code, assertionResult)
logger.error((assertionResult as any).code, assertionResult)
const htmlPages = ["signin", "signout", "error", "verify-request"]
if (!htmlPages.includes(req.action) || req.method !== "GET") {

View File

@@ -1,10 +1,15 @@
import { EncryptJWT, jwtDecrypt } from "jose"
import hkdf from "@panva/hkdf"
import { SessionStore } from "../lib/cookie"
import type { JWT, JWTDecodeParams, JWTEncodeParams, JWTOptions } from "./types"
import type { LoggerInstance } from ".."
import { hkdf } from "@panva/hkdf"
import { SessionStore } from "../lib/cookie.js"
import type {
JWT,
JWTDecodeParams,
JWTEncodeParams,
JWTOptions,
} from "./types.js"
import type { LoggerInstance } from "../index.js"
export * from "./types"
export * from "./types.js"
const DEFAULT_MAX_AGE = 30 * 24 * 60 * 60 // 30 days

View File

@@ -1,4 +1,4 @@
import type { Awaitable } from ".."
import type { Awaitable } from "../index.js"
export interface DefaultJWT extends Record<string, unknown> {
name?: string | null

View File

@@ -7,11 +7,11 @@ import {
MissingAuthorize,
MissingSecret,
UnsupportedStrategy,
} from "./errors"
import { defaultCookies } from "./cookie"
} from "./errors.js"
import { defaultCookies } from "./cookie.js"
import type { AuthOptions, RequestInternal } from ".."
import type { WarningCode } from "./utils/logger"
import type { AuthOptions, RequestInternal } from "../index.js"
import type { WarningCode } from "./utils/logger.js"
type ConfigError =
| MissingAdapter
@@ -56,7 +56,7 @@ export function assertConfig(params: {
}
if (!options.secret) {
return new MissingSecret("Please define a `secret` in production.")
return new MissingSecret("Please define a `secret`.")
}
// req.query isn't defined when asserting `unstable_getServerSession` for example

View File

@@ -1,11 +1,11 @@
import { AccountNotLinkedError } from "./errors"
import { fromDate } from "./utils/date"
import { AccountNotLinkedError } from "./errors.js"
import { fromDate } from "./utils/date.js"
import type { Account, InternalOptions, User } from ".."
import type { AdapterSession, AdapterUser } from "../adapters"
import type { JWT } from "../jwt"
import type { OAuthConfig } from "../providers"
import type { SessionToken } from "./cookie"
import type { Account, InternalOptions, User } from "../index.js"
import type { AdapterSession, AdapterUser } from "../adapters.js"
import type { JWT } from "../jwt/index.js"
import type { OAuthConfig } from "../providers/index.js"
import type { SessionToken } from "./cookie.js"
/**
* This function handles the complex flow of signing users in, and either creating,

View File

@@ -1,4 +1,4 @@
import type { InternalOptions } from ".."
import type { InternalOptions } from "../index.js"
interface CreateCallbackUrlParams {
options: InternalOptions

View File

@@ -3,7 +3,7 @@ import type {
CookiesOptions,
LoggerInstance,
SessionStrategy,
} from ".."
} from "../index.js"
// Uncomment to recalculate the estimated size
// of an empty session cookie

View File

@@ -1,5 +1,5 @@
import { createHash, randomString } from "./web"
import type { InternalOptions } from "./types"
import { createHash, randomString } from "./web.js"
import type { InternalOptions } from "./types.js"
interface CreateCSRFTokenParams {
options: InternalOptions

View File

@@ -1,4 +1,4 @@
import type { CallbacksOptions } from ".."
import type { CallbacksOptions } from "../index.js"
export const defaultCallbacks: CallbacksOptions = {
signIn() {

View File

@@ -1,5 +1,5 @@
import type { AdapterUser } from "../../adapters"
import type { InternalOptions } from "../.."
import type { AdapterUser } from "../../adapters.js"
import type { InternalOptions } from "../../index.js"
/**
* Query the database for a user by email address.

View File

@@ -1,5 +1,5 @@
import { randomString, createHash } from "../web"
import type { InternalOptions } from "../.."
import { randomString, createHash } from "../web.js"
import type { InternalOptions } from "../../index.js"
/**
* Starts an e-mail login flow, by generating a token,

View File

@@ -1,4 +1,4 @@
import type { EventCallbacks, LoggerInstance } from "./types"
import type { EventCallbacks, LoggerInstance } from "./types.js"
/**
* Same as the default `Error`, but it is JSON serializable.

View File

@@ -1,14 +1,14 @@
import { adapterErrorHandler, eventsErrorHandler } from "./errors"
import * as jwt from "../jwt"
import { createCallbackUrl } from "./callback-url"
import * as cookie from "./cookie"
import { createCSRFToken } from "./csrf-token"
import { defaultCallbacks } from "./default-callbacks"
import parseProviders from "./providers"
import logger from "./utils/logger"
import parseUrl from "./utils/parse-url"
import { adapterErrorHandler, eventsErrorHandler } from "./errors.js"
import * as jwt from "../jwt/index.js"
import { createCallbackUrl } from "./callback-url.js"
import * as cookie from "./cookie.js"
import { createCSRFToken } from "./csrf-token.js"
import { defaultCallbacks } from "./default-callbacks.js"
import parseProviders from "./providers.js"
import logger from "./utils/logger.js"
import parseUrl from "./utils/parse-url.js"
import type { AuthOptions, InternalOptions, RequestInternal } from ".."
import type { AuthOptions, InternalOptions, RequestInternal } from "../index.js"
interface InitParams {
url: URL

View File

@@ -5,8 +5,8 @@ import type {
InternalOptions,
RequestInternal,
ResponseInternal,
} from "../.."
import type { Cookie } from "../cookie"
} from "../../index.js"
import type { Cookie } from "../cookie.js"
/**
* Generates an authorization/request token URL.

View File

@@ -1,7 +1,7 @@
import { OAuthCallbackError } from "../errors"
import { useNonce } from "./nonce-handler"
import { usePKCECodeVerifier } from "./pkce-handler"
import { useState } from "./state-handler"
import { OAuthCallbackError } from "../errors.js"
import { useNonce } from "./nonce-handler.js"
import { usePKCECodeVerifier } from "./pkce-handler.js"
import { useState } from "./state-handler.js"
import * as o from "oauth4webapi"
import type {
@@ -10,9 +10,9 @@ import type {
Profile,
RequestInternal,
TokenSet,
} from "../.."
import type { OAuthConfigInternal } from "../../providers"
import type { Cookie } from "../cookie"
} from "../../index.js"
import type { OAuthConfigInternal } from "../../providers/index.js"
import type { Cookie } from "../cookie.js"
export async function handleOAuthCallback(params: {
options: InternalOptions<"oauth">

View File

@@ -1,8 +1,8 @@
import * as o from "oauth4webapi"
import * as jwt from "../../jwt"
import * as jwt from "../../jwt/index.js"
import type { InternalOptions } from "../.."
import type { Cookie } from "../cookie"
import type { InternalOptions } from "../../index.js"
import type { Cookie } from "../cookie.js"
const NONCE_MAX_AGE = 60 * 15 // 15 minutes in seconds

View File

@@ -1,8 +1,8 @@
import * as o from "oauth4webapi"
import * as jwt from "../../jwt"
import * as jwt from "../../jwt/index.js"
import type { InternalOptions } from "../.."
import type { Cookie } from "../cookie"
import type { InternalOptions } from "../../index.js"
import type { Cookie } from "../cookie.js"
const PKCE_CODE_CHALLENGE_METHOD = "S256"
const PKCE_MAX_AGE = 60 * 15 // 15 minutes in seconds

View File

@@ -1,5 +1,5 @@
import type { InternalOptions } from "../.."
import type { Cookie } from "../cookie"
import type { InternalOptions } from "../../index.js"
import type { Cookie } from "../cookie.js"
import * as o from "oauth4webapi"
const STATE_MAX_AGE = 60 * 15 // 15 minutes in seconds

View File

@@ -1,4 +1,4 @@
import type { Theme } from "../.."
import type { Theme } from "../../index.js"
/**
* The following errors are passed as error query parameters to the default or overridden error page.

View File

@@ -1,13 +1,17 @@
import renderToString from "preact-render-to-string"
import css from "../styles"
import ErrorPage from "./error"
import SigninPage from "./signin"
import SignoutPage from "./signout"
import VerifyRequestPage from "./verify-request"
import { renderToString } from "preact-render-to-string"
import css from "../styles/index.js"
import ErrorPage from "./error.js"
import SigninPage from "./signin.js"
import SignoutPage from "./signout.js"
import VerifyRequestPage from "./verify-request.js"
import type { InternalOptions, RequestInternal, ResponseInternal } from "../.."
import type { Cookie } from "../cookie"
import type { ErrorType } from "./error"
import type {
InternalOptions,
RequestInternal,
ResponseInternal,
} from "../../index.js"
import type { Cookie } from "../cookie.js"
import type { ErrorType } from "./error.js"
type RenderPageParams = {
query?: RequestInternal["query"]

View File

@@ -1,5 +1,4 @@
import type { InternalProvider, Theme } from "../.."
import type { CSSProperties } from "react"
import type { InternalProvider, Theme } from "../../index.js"
/**
* The following errors are passed as error query parameters to the default or overridden sign-in page.
@@ -92,15 +91,12 @@ export default function SigninPage(props: SignInServerPageParams) {
<button
type="submit"
className="button"
style={
// eslint-disable-next-line
{
"--provider-bg": provider.style?.bg ?? "",
"--provider-dark-bg": provider.style?.bgDark ?? "",
"--provider-color": provider.style?.text ?? "",
"--provider-dark-color": provider.style?.textDark ?? "",
} as CSSProperties
}
style={{
"--provider-bg": provider.style?.bg ?? "",
"--provider-dark-bg": provider.style?.bgDark ?? "",
"--provider-color": provider.style?.text ?? "",
"--provider-dark-color": provider.style?.textDark ?? "",
}}
>
{provider.style?.logo && (
<img

View File

@@ -1,4 +1,4 @@
import type { Theme } from "../.."
import type { Theme } from "../../index.js"
export interface SignoutProps {
url: URL

View File

@@ -1,4 +1,4 @@
import type { Theme } from "../.."
import type { Theme } from "../../index.js"
interface VerifyRequestPageProps {
url: URL

View File

@@ -1,13 +1,13 @@
import { merge } from "./utils/merge"
import { merge } from "./utils/merge.js"
import type { InternalProvider } from ".."
import type { InternalProvider } from "../index.js"
import type {
OAuthConfig,
OAuthConfigInternal,
OAuthEndpointType,
OAuthUserConfig,
Provider,
} from "../providers"
} from "../providers/index.js"
/**
* Adds `signinUrl` and `callbackUrl` to each provider

View File

@@ -1,12 +1,12 @@
import callbackHandler from "../callback-handler"
import getAdapterUserFromEmail from "../email/getUserFromEmail"
import { handleOAuthCallback } from "../oauth/callback"
import { createHash } from "../web"
import callbackHandler from "../callback-handler.js"
import getAdapterUserFromEmail from "../email/getUserFromEmail.js"
import { handleOAuthCallback } from "../oauth/callback.js"
import { createHash } from "../web.js"
import type { RequestInternal, ResponseInternal, User } from "../.."
import type { AdapterSession } from "../../adapters"
import type { Cookie, SessionStore } from "../cookie"
import type { InternalOptions } from "../types"
import type { RequestInternal, ResponseInternal, User } from "../../index.js"
import type { AdapterSession } from "../../adapters.js"
import type { Cookie, SessionStore } from "../cookie.js"
import type { InternalOptions } from "../types.js"
/** Handle callbacks from login services */
export async function callback(params: {

View File

@@ -1,5 +1,5 @@
export { callback } from "./callback"
export { providers } from "./providers"
export { session } from "./session"
export { signin } from "./signin"
export { signout } from "./signout"
export { callback } from "./callback.js"
export { providers } from "./providers.js"
export { session } from "./session.js"
export { signin } from "./signin.js"
export { signout } from "./signout.js"

View File

@@ -1,4 +1,4 @@
import type { InternalProvider, ResponseInternal } from "../.."
import type { InternalProvider, ResponseInternal } from "../../index.js"
export interface PublicProvider {
id: string

View File

@@ -1,8 +1,8 @@
import { fromDate } from "../utils/date"
import { fromDate } from "../utils/date.js"
import type { InternalOptions, ResponseInternal, Session } from "../.."
import type { Adapter } from "../../adapters"
import type { SessionStore } from "../cookie"
import type { InternalOptions, ResponseInternal, Session } from "../../index.js"
import type { Adapter } from "../../adapters.js"
import type { SessionStore } from "../cookie.js"
interface SessionParams {
options: InternalOptions

View File

@@ -1,13 +1,13 @@
import getAdapterUserFromEmail from "../email/getUserFromEmail"
import emailSignin from "../email/signin"
import { getAuthorizationUrl } from "../oauth/authorization-url"
import getAdapterUserFromEmail from "../email/getUserFromEmail.js"
import emailSignin from "../email/signin.js"
import { getAuthorizationUrl } from "../oauth/authorization-url.js"
import type {
Account,
InternalOptions,
RequestInternal,
ResponseInternal,
} from "../.."
} from "../../index.js"
/** Handle requests to /api/auth/signin */
export async function signin(params: {

View File

@@ -1,6 +1,6 @@
import type { InternalOptions, ResponseInternal } from "../.."
import type { Adapter } from "../../adapters"
import type { SessionStore } from "../cookie"
import type { InternalOptions, ResponseInternal } from "../../index.js"
import type { Adapter } from "../../adapters.js"
import type { SessionStore } from "../cookie.js"
/** Handle requests to /api/auth/signout */
export async function signout(params: {

View File

@@ -1,5 +1,5 @@
import type { CookieSerializeOptions } from "cookie"
import type { Adapter, AdapterUser } from "../adapters"
import type { Adapter, AdapterUser } from "../adapters.js"
import type {
CredentialInput,
CredentialsConfig,
@@ -7,16 +7,15 @@ import type {
OAuthConfigInternal,
Provider,
ProviderType,
} from "../providers"
} from "../providers/index.js"
import type {
OAuth2TokenEndpointResponse,
OpenIDTokenEndpointResponse,
} from "oauth4webapi"
import type { JWT, JWTOptions } from "../jwt"
import type { Cookie } from "./cookie"
import type { LoggerInstance } from "./utils/logger"
import type { JWT, JWTOptions } from "../jwt/types.js"
import type { Cookie } from "./cookie.js"
import type { LoggerInstance } from "./utils/logger.js"
/** @internal */
export type Awaitable<T> = T | PromiseLike<T>
export type { LoggerInstance }

View File

@@ -1,4 +1,4 @@
import { UnknownError } from "../errors"
import { UnknownError } from "../errors.js"
/** Makes sure that error is always serializable */
function formatError(o: unknown): unknown {

View File

@@ -1,7 +1,7 @@
import { parse as parseCookie, serialize } from "cookie"
import type { RequestInternal, ResponseInternal } from ".."
import { UnknownAction } from "./errors"
import type { AuthAction } from "./types"
import type { RequestInternal, ResponseInternal } from "../index.js"
import { UnknownAction } from "./errors.js"
import type { AuthAction } from "./types.js"
async function getBody(req: Request): Promise<Record<string, any> | undefined> {
if (!("body" in req) || !req.body || req.method !== "POST") return

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface UserData {
id: number

View File

@@ -1,4 +1,4 @@
import { OAuthConfig, OAuthUserConfig } from "."
import { OAuthConfig, OAuthUserConfig } from "./index.js"
/**
* See more at:

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
interface AtlassianProfile extends Record<string, any> {
account_id: string

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface Auth0Profile extends Record<string, any> {
sub: string

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface AuthentikProfile extends Record<string, any> {
iss: string

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface AzureB2CProfile extends Record<string, any> {
exp: number

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface AzureADProfile extends Record<string, any> {
sub: string

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface BattleNetProfile extends Record<string, any> {
sub: string

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface BoxyHQSAMLProfile extends Record<string, any> {
id: string

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface CognitoProfile extends Record<string, any> {
sub: string

View File

@@ -1,5 +1,5 @@
import type { CommonProviderOptions } from "."
import type { Awaitable, RequestInternal, User } from ".."
import type { CommonProviderOptions } from "./index.js"
import type { Awaitable, RequestInternal, User } from "../index.js"
export interface CredentialInput {
label?: string

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface DiscordProfile extends Record<string, any> {
accent_color: number

View File

@@ -1,8 +1,8 @@
import { createTransport } from "nodemailer"
import type { CommonProviderOptions } from "."
import type { CommonProviderOptions } from "./index.js"
import type { Options as SMTPTransportOptions } from "nodemailer/lib/smtp-transport"
import type { Awaitable, Theme } from ".."
import type { Awaitable, Theme } from "../index.js"
export interface SendVerificationRequestParams {
identifier: string

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface EVEOnlineProfile extends Record<string, any> {
CharacterID: number
@@ -17,7 +17,8 @@ export default function EVEOnline<P extends EVEOnlineProfile>(
id: "eveonline",
name: "EVE Online",
type: "oauth",
authorization: "https://login.eveonline.com/v2/oauth/authorize?scope=publicData",
authorization:
"https://login.eveonline.com/v2/oauth/authorize?scope=publicData",
token: "https://login.eveonline.com/v2/oauth/token",
userinfo: "https://login.eveonline.com/oauth/verify",
profile(profile) {

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
interface FacebookPictureData {
url: string

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
/** @see https://docs.github.com/en/rest/users/users#get-the-authenticated-user */
export interface GithubProfile extends Record<string, any> {

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface GitLabProfile extends Record<string, any> {
id: number

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface GoogleProfile extends Record<string, any> {
aud: string

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
interface HubSpotProfile extends Record<string, any> {
// https://legacydocs.hubspot.com/docs/methods/oauth2/get-access-token-information

View File

@@ -1,14 +1,14 @@
import type { OAuthConfig, OAuthProvider, OAuthProviderType } from "./oauth"
import type { EmailConfig, EmailProvider, EmailProviderType } from "./email"
import type { OAuthConfig, OAuthProvider, OAuthProviderType } from "./oauth.js"
import type { EmailConfig, EmailProvider, EmailProviderType } from "./email.js"
import type {
CredentialsConfig,
CredentialsProvider,
CredentialsProviderType,
} from "./credentials"
} from "./credentials.js"
export * from "./credentials"
export * from "./email"
export * from "./oauth"
export * from "./credentials.js"
export * from "./email.js"
export * from "./oauth.js"
export type ProviderType = "oidc" | "oauth" | "email" | "credentials"

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export type DateTime = string
export type Gender = "female" | "male"

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface KeycloakProfile extends Record<string, any> {
exp: number

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface LineProfile extends Record<string, any> {
iss: string

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
interface Identifier {
identifier: string

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
/** https://developers.naver.com/docs/login/profile/profile.md */
export interface NaverProfile extends Record<string, any> {

View File

@@ -1,5 +1,5 @@
import type { CommonProviderOptions } from "../providers"
import type { Profile, TokenSet, User, Awaitable } from ".."
import type { CommonProviderOptions } from "../providers/index.js"
import type { Profile, TokenSet, User, Awaitable } from "../index.js"
import type { Client } from "oauth4webapi"
// TODO:
@@ -9,7 +9,7 @@ type IssuerMetadata = any
type OAuthCallbackChecks = any
type OpenIDCallbackChecks = any
export type { OAuthProviderType } from "./oauth-types"
export type { OAuthProviderType } from "./oauth-types.js"
type ChecksType = "pkce" | "state" | "none" | "nonce"
@@ -96,6 +96,17 @@ export interface OAuthProviderButtonStyles {
}
export interface OAuth2Config<P> extends CommonProviderOptions, PartialIssuer {
/**
* Identifies the provider when you want to sign in to
* a specific provider.
* @example
* ```js
* signIn('github') // "github" is the provider ID
* ```
*/
id: string
/** The name of the provider. shown on the default sign in page. */
name: string
/**
* OpenID Connect (OIDC) compliant providers can configure
* this instead of `authorize`/`token`/`userinfo` options

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface OktaProfile extends Record<string, any> {
iss: string

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface OsuUserCompact {
avatar_url: string

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface PatreonProfile extends Record<string, any> {
sub: string

View File

@@ -1,4 +1,4 @@
import { OAuthConfig, OAuthUserConfig } from "."
import { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface PinterestProfile extends Record<string, any> {
account_type: "BUSINESS" | "PINNER"

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface PipedriveProfile extends Record<string, any> {
success: boolean

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface SalesforceProfile extends Record<string, any> {
sub: string

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface SlackProfile extends Record<string, any> {
ok: boolean

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface SpotifyImage {
url: string

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface StravaProfile extends Record<string, any> {
id: string // this is really a number

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
/**
* @see https://developer.todoist.com/sync/v9/#user

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface TraktUser extends Record<string, any> {
username: string

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "."
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
export interface TwitchProfile extends Record<string, any> {
sub: string

Some files were not shown because too many files have changed in this diff Show More