Compare commits

..

126 Commits

Author SHA1 Message Date
Thang Vu
83d12bd86d Merge remote-tracking branch 'origin/main' into thang-origin/feat/svelte-kit-auth-1 2022-12-14 01:33:10 +07:00
Thang Vu
36785dafb8 move to dependency 2022-12-14 01:25:21 +07:00
Thang Vu
2c5ac4c9cb remove nextauth_url, memoize locals.getSession 2022-12-14 00:26:11 +07:00
Thang Vu
aad5875299 Merge remote-tracking branch 'origin/feat/oauth4webapi-balazs' into thang-origin/feat/svelte-kit-auth 2022-12-13 22:38:14 +07:00
Balázs Orbán
df061b97c1 remove unused file, expose type 2022-12-13 16:37:19 +01:00
Thang Vu
c89e922256 commit 2022-12-13 22:25:59 +07:00
Thang Vu
5c27e85845 Merge remote-tracking branch 'origin/feat/oauth4webapi-balazs' into feat/svelte-kit-auth 2022-12-13 22:03:31 +07:00
Thang Vu
73e497958c Merge branch 'feat/oauth4webapi-balazs' into feat/svelte-kit-auth 2022-12-13 22:02:04 +07:00
Thang Vu
c066b711fb feat sveltekit 2022-12-13 22:01:13 +07:00
Thang Vu
0960844d2b revert 2022-12-13 22:00:46 +07:00
Balázs Orbán
369a27b5ed remove private from package.json 2022-12-13 14:09:45 +01:00
Balázs Orbán
ced1ca440a remove extra tsconfig files 2022-12-13 14:07:19 +01:00
Balázs Orbán
fef845762e revert next-auth 2022-12-13 14:04:46 +01:00
Balázs Orbán
4582348bfd update exports field 2022-12-13 13:59:42 +01:00
Balázs Orbán
2c209d7fef update gitignore 2022-12-13 13:56:07 +01:00
Balázs Orbán
249ebf4f78 update styles ts 2022-12-13 13:55:04 +01:00
Balázs Orbán
24f329a37f fix imports 2022-12-13 13:53:49 +01:00
Balázs Orbán
cea596968f update ignore/clean patterns 2022-12-13 13:52:24 +01:00
Balázs Orbán
9fcf85413c fix imports 2022-12-13 13:50:50 +01:00
Balázs Orbán
0939b13f28 move utils to lib 2022-12-13 13:50:08 +01:00
Balázs Orbán
3e3f9a92ac move types to lib 2022-12-13 13:46:57 +01:00
Balázs Orbán
cb5a2adbc1 move styles to lib 2022-12-13 13:46:19 +01:00
Balázs Orbán
1d9e5918f4 move init to lib 2022-12-13 13:42:43 +01:00
Balázs Orbán
d96947c277 move routes to lib 2022-12-13 13:42:12 +01:00
Balázs Orbán
ffee34df90 move pages/index to lib 2022-12-13 13:41:14 +01:00
Balázs Orbán
c229183d2d move errors to lib 2022-12-13 13:40:40 +01:00
Balázs Orbán
90df63efea move pages to lib 2022-12-13 13:40:14 +01:00
Balázs Orbán
f2d193b852 temporary Headers fix 2022-12-13 13:30:57 +01:00
Balázs Orbán
b2e66cc961 default env secret to AUTH_SECRET 2022-12-13 13:30:33 +01:00
Balázs Orbán
f231016913 generate declaration map 2022-12-13 13:14:35 +01:00
Balázs Orbán
e9f0828c97 pass through OAuth client options 2022-12-13 12:36:55 +01:00
Balázs Orbán
9d0c138b2d remove todo comments 2022-12-13 12:28:45 +01:00
Balázs Orbán
e651df57a0 make secret required in dev 2022-12-13 12:19:47 +01:00
Balázs Orbán
5d15ac53dd remove uuid 2022-12-13 12:08:50 +01:00
Thang Vu
afda10015e feat: extract type to core and reuse in sveltekit 2022-12-13 17:49:04 +07:00
Thang Vu
1c9d7fe955 Some more refactoring 2022-12-13 17:02:40 +07:00
Thang Vu
42ba2d1b9a upgrade sveltekit auth to latest 2022-12-13 16:56:09 +07:00
Thang Vu
801509e190 upgrade playground to latest 2022-12-13 16:55:43 +07:00
Thang Vu
29d8965e11 clean up sveltekit auth handler 2022-12-13 00:02:25 +07:00
Thang Vu
519bf6e5b0 merge 2022-12-12 22:11:56 +07:00
Balázs Orbán
e5bfbed2c4 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>
2022-12-12 21:57:24 +07:00
Balázs Orbán
73026a4cad sync 2022-12-12 15:51:31 +01:00
Balázs Orbán
0469fc65fb clean up next-auth/edge 2022-12-12 15:29:04 +01:00
Balázs Orbán
92cfb9199e sync with next-auth 2022-12-12 15:28:39 +01:00
Balázs Orbán
fa864e1753 make logos optional 2022-12-12 15:26:07 +01:00
Balázs Orbán
67c525b5b5 Merge branch 'main' into feat/oauth4webapi-balazs 2022-12-12 14:54:49 +01:00
Balázs Orbán
0b8d3fdfc6 update lock file 2022-12-11 16:06:53 +01:00
Balázs Orbán
7f3a6ca36c Merge branch 'main' into feat/oauth4webapi-balazs 2022-12-11 16:04:41 +01:00
Balázs Orbán
7444ab39c8 Merge branch 'main' into feat/oauth4webapi-balazs 2022-12-08 05:25:27 +01:00
Thang Vu
ac0dbae10a fix AuthHandler, add getServerSession 2022-12-08 11:17:52 +07:00
Balázs Orbán
59d6385d5e Merge pull request #1 from nextauthjs/feat/oauth4webapi-balazs 2022-12-08 03:35:37 +01:00
Balázs Orbán
187d38b4c1 fix CSS 2022-12-08 03:33:29 +01:00
Balázs Orbán
860c8b50b2 target es2020 2022-12-08 03:10:51 +01:00
Balázs Orbán
563395928d fix providers 2022-12-08 03:10:42 +01:00
Balázs Orbán
5945d9bc07 refactor providers, test facebook 2022-12-08 02:38:24 +01:00
Balázs Orbán
5c96c8fe68 deprecate OAuth 1, simplify internals, improve defaults 2022-12-08 02:37:49 +01:00
Balázs Orbán
104f9445f6 fix logout 2022-12-08 02:34:51 +01:00
Balázs Orbán
df616605f0 output ESM 2022-12-08 02:34:22 +01:00
Balázs Orbán
c3932f1f7b Merge branch 'main' into feat/oauth4webapi-balazs 2022-12-08 00:12:58 +01:00
Balázs Orbán
598b3efc07 revert Logo component 2022-12-07 18:14:29 +01:00
Balázs Orbán
2730249e30 wip fix css 2022-12-07 18:00:02 +01:00
Thang Vu
57facccd8f feat: add sveltekit auth 2022-12-07 23:46:01 +07:00
Balázs Orbán
8299b977f9 move redirect logic to core 2022-12-07 17:41:04 +01:00
Balázs Orbán
99abfbecfc revert 2022-12-07 12:25:20 +01:00
Balázs Orbán
808d9a27e5 temprarily remove duplicate logos 2022-12-07 12:19:09 +01:00
Balázs Orbán
cc098bd73a remove openid-client 2022-12-06 17:47:21 +01:00
Balázs Orbán
166d4a8f77 support OIDC 2022-12-06 17:03:54 +01:00
Balázs Orbán
9d079a5fcb wip core 2022-12-06 15:47:04 +01:00
Balázs Orbán
7d8f468a02 Merge branch 'main' into feat/oauth4webapi-balazs 2022-12-05 13:39:04 +01:00
Balázs Orbán
40f11edd01 Merge branch 'main' into feat/oauth4webapi-balazs 2022-12-05 13:34:59 +01:00
Balázs Orbán
9f3e33eef2 refactor: more renames 2022-12-05 13:32:37 +01:00
Balázs Orbán
5a22790673 fix import 2022-12-03 16:05:16 +01:00
Balázs Orbán
1ee62b6513 Merge branch 'main' into feat/oauth4webapi-balazs 2022-12-03 15:52:57 +01:00
Balázs Orbán
b0fb1748c5 Merge branch 'main' into feat/oauth4webapi-balazs 2022-12-03 15:42:44 +01:00
Balázs Orbán
6b46f373bd chore: upgrade dep 2022-12-03 15:37:38 +01:00
Balázs Orbán
b0b993988b Merge branch 'main' into feat/oauth4webapi-balazs 2022-12-03 15:34:37 +01:00
Balázs Orbán
9aaa058e2f Merge branch 'main' into feat/oauth4webapi-balazs 2022-12-03 15:00:40 +01:00
Balázs Orbán
7a47d68f5e fix tests 2022-10-10 05:35:43 +02:00
Balázs Orbán
119de7eeb2 fix eslint 2022-10-10 05:15:36 +02:00
Balázs Orbán
697443df7a send header instead of body to indicate redirect response 2022-10-10 05:07:30 +02:00
Balázs Orbán
a063349533 refactor 2022-10-10 04:50:34 +02:00
Balázs Orbán
68d53876ea add next-auth/web 2022-10-10 04:49:42 +02:00
Balázs Orbán
79d6299474 refactor crypto usage
In Node.js, inject `globalThis.crypto` instead of import
2022-10-10 04:47:12 +02:00
Balázs Orbán
7b46d1a3a5 simplify types 2022-10-10 04:38:10 +02:00
Balázs Orbán
49cfcf1f5e Merge remote-tracking branch 'origin/chore/core-request-response' into feat/oauth4webapi-balazs 2022-10-10 02:47:33 +02:00
Balázs Orbán
8041a59490 reduce file changes in the PR 2022-10-10 02:46:48 +02:00
Balázs Orbán
b2de56c9e6 remove new-line 2022-10-10 02:30:06 +02:00
Balázs Orbán
6d3e4af8fb Merge remote-tracking branch 'origin/chore/core-request-response' into feat/oauth4webapi-balazs 2022-10-10 02:13:46 +02:00
Balázs Orbán
6843007040 Merge branch 'main' into chore/core-request-response 2022-10-10 02:12:18 +02:00
Balázs Orbán
4a2c89d7a6 Merge remote-tracking branch 'origin/chore/core-request-response' into feat/oauth4webapi-balazs 2022-10-10 02:02:37 +02:00
Balázs Orbán
1bed1182a1 fix neo4j build 2022-10-10 02:01:57 +02:00
Balázs Orbán
0e635bd068 Merge remote-tracking branch 'origin/chore/core-request-response' into feat/oauth4webapi-balazs 2022-10-10 01:58:45 +02:00
Balázs Orbán
5d6643b6dd Merge branch 'main' into chore/core-request-response 2022-10-10 00:37:37 +02:00
Balázs Orbán
0c71f26ec1 fix type 2022-10-09 02:14:28 +02:00
Balázs Orbán
dbf42936e4 add web-compatible authorization URL handling 2022-10-09 02:06:14 +02:00
Balázs Orbán
9466f65032 mark clientId as always internally, fix comments 2022-10-09 02:04:05 +02:00
Balázs Orbán
cbd7f18b3a allow internal redirect to be URL 2022-10-09 01:51:34 +02:00
Balázs Orbán
9bea47381f assert if both endpoint and issuer config is missing 2022-10-09 01:48:15 +02:00
Balázs Orbán
b8ed7358c9 simplify internal endpoint config
Instead of passing url and params around as a string and an object,
we parse them into a `URL` instance.
2022-10-09 01:47:44 +02:00
Balázs Orbán
0723747523 don't import all adapters by default in dev 2022-10-09 01:37:26 +02:00
Balázs Orbán
bc314ef7e8 type and default import on one line 2022-10-09 01:36:05 +02:00
Balázs Orbán
3d1453682d upgrade/add dependencies 2022-10-09 01:33:43 +02:00
Balázs Orbán
57a7d3f4f8 remove patch 2022-10-07 13:32:24 +02:00
Balázs Orbán
195822ce3d fix test 2022-10-07 01:32:33 +02:00
Balázs Orbán
1a2e752c13 fix tests, using Node 18 as runtime 2022-10-07 01:00:25 +02:00
Balázs Orbán
bd4d78ba77 chore: add @edge-runtime/jest-environment 2022-10-07 00:08:20 +02:00
Balázs Orbán
8f7288a72b Merge branch 'main' into chore/core-request-response 2022-10-06 23:48:30 +02:00
Balázs Orbán
b41bdeb787 refactor next-auth/next 2022-10-05 04:10:42 +02:00
Balázs Orbán
415d299698 refactor getBody 2022-10-05 04:03:32 +02:00
Balázs Orbán
07ab4f8cd4 fall back host to localhost 2022-10-05 04:03:19 +02:00
Balázs Orbán
b63e84334e don't export internal handler 2022-10-05 04:03:03 +02:00
Balázs Orbán
1903e3c616 return session in protected api route example 2022-10-05 04:02:51 +02:00
Balázs Orbán
eb77e23f37 Merge branch 'main' into chore/core-request-response 2022-10-05 02:43:07 +02:00
Balázs Orbán
63cdea4506 remove workaround for middleware return type 2022-08-12 16:20:55 +02:00
Balázs Orbán
2cf11bbc71 fix tests 2022-08-12 14:54:04 +02:00
Balázs Orbán
a5cd972a55 revert 2022-08-12 14:50:31 +02:00
Balázs Orbán
bc9ddaeaa2 make linter happy 2022-08-12 14:49:28 +02:00
Balázs Orbán
fe9c6a5d3f use Request/Response in next-auth/next 2022-08-12 14:20:41 +02:00
Balázs Orbán
db6b1c9e96 implement body reader 2022-08-12 14:20:21 +02:00
Balázs Orbán
b9330038e5 upgrade Next.js 2022-08-12 13:45:24 +02:00
Balázs Orbán
b274e98f8b simplify 2022-08-11 12:55:29 +02:00
Balázs Orbán
c73694801f refactor 2022-08-11 12:53:03 +02:00
Balázs Orbán
504f384352 rename ts types 2022-08-11 12:52:42 +02:00
Balázs Orbán
8c21589518 bump Next.js 2022-08-11 12:09:59 +02:00
Balázs Orbán
12683017c1 Merge branch 'main' into chore/core-request-response 2022-08-11 11:56:47 +02:00
Balázs Orbán
e428b17b99 WIP use Request and Response for core 2022-06-26 21:24:49 +02:00
129 changed files with 1200 additions and 1513 deletions

View File

@@ -4,8 +4,11 @@ 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 {{
@@ -70,7 +73,7 @@ async function run() {
}),
client.issues.createComment({
...issueCommon,
body: readFileSync("repro.md", "utf8"),
body: readFileSync(join(__dirname, "repro.md"), "utf8"),
}),
])
return core.info(

12
.gitignore vendored
View File

@@ -34,6 +34,7 @@ packages/next-auth/utils
packages/next-auth/core
packages/next-auth/jwt
packages/next-auth/react
packages/next-auth/web
packages/next-auth/adapters.d.ts
packages/next-auth/adapters.js
packages/next-auth/index.d.ts
@@ -85,13 +86,4 @@ packages/core/adapters.*
packages/core/index.*
packages/core/jwt
packages/core/lib
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-*
packages/core/providers

View File

@@ -1,5 +1,4 @@
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=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
NEXTAUTH_SECRET=
PUBLIC_NEXTAUTH_URL=http://localhost:5173

View File

@@ -1,6 +1,9 @@
{
"semi": false,
"plugins": ["prettier-plugin-svelte"],
"pluginSearchDirs": ["."],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"pluginSearchDirs": ["."],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}

View File

@@ -1,23 +1,39 @@
{
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
},
"devDependencies": {
"@sveltejs/adapter-auto": "next",
"@sveltejs/kit": "next",
"svelte": "3.55.0",
"svelte-check": "2.10.2",
"typescript": "4.9.4",
"vite": "4.0.1"
},
"name": "sveltekit-nextauth",
"private": true,
"version": "0.0.1",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --plugin-search-dir . --check . && eslint .",
"format": "prettier --plugin-search-dir . --write ."
},
"devDependencies": {
"@fontsource/fira-mono": "^4.5.10",
"@neoconfetti/svelte": "^1.0.0",
"@sveltejs/adapter-auto": "next",
"@sveltejs/kit": "next",
"@types/cookie": "^0.5.1",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-svelte3": "^4.0.0",
"prettier": "^2.8.0",
"prettier-plugin-svelte": "^2.8.1",
"svelte": "^3.54.0",
"svelte-check": "^2.9.2",
"tslib": "^2.4.1",
"typescript": "^4.9.3",
"vite": "^4.0.0"
},
"dependencies": {
"cookie": "0.5.0",
"@auth/core": "workspace:*",
"@auth/sveltekit": "workspace:*"
"next-auth-core": "workspace:^0.0.1",
"next-auth-sveltekit": "workspace:^0.0.1"
},
"type": "module"
"type": "module"
}

View File

@@ -1 +1,32 @@
/// <reference types="@auth/sveltekit" />
/// <reference types="@sveltejs/kit" />
/// <reference types="next-auth-sveltekit" />
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
getSession: () => Promise<AppSession>
}
interface Platform {}
interface Session extends AppSession {}
interface Stuff {}
}
}

View File

@@ -1,13 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.ico" />
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
</head>
<body>
<div>%sveltekit.body%</div>
</body>
</html>
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.ico" />
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
</head>
<body>
<div>%sveltekit.body%</div>
</body>
</html>

View File

@@ -1,7 +1,25 @@
import SvelteKitAuth from "@auth/sveltekit"
import GitHub from "@auth/core/providers/github"
import { GITHUB_ID, GITHUB_SECRET } from "$env/static/private"
import SvelteKitAuth from "next-auth-sveltekit"
import GitHub from 'next-auth-core/providers/github';
import Google from 'next-auth-core/providers/google';
import Credentials from 'next-auth-core/providers/credentials';
import {
GITHUB_CLIENT_ID,
GITHUB_CLIENT_SECRET,
GOOGLE_CLIENT_ID,
GOOGLE_CLIENT_SECRET,
} from "$env/static/private"
export const handle = SvelteKitAuth({
providers: [GitHub({ clientId: GITHUB_ID, clientSecret: GITHUB_SECRET })],
})
providers: [
GitHub({ clientId: GITHUB_CLIENT_ID, clientSecret: GITHUB_CLIENT_SECRET }),
Google({ clientId: GOOGLE_CLIENT_ID, clientSecret: GOOGLE_CLIENT_SECRET }),
Credentials({
credentials: { password: { label: "Password", type: "password" } },
async authorize(credentials) {
if (credentials.password !== "pw") return null
return { name: "Fill Murray", email: "bill@fillmurray.com", image: "https://www.fillmurray.com/64/64", id: "1", foo: "" }
},
}),
],
debug: true,
});

View File

@@ -1,12 +1,12 @@
<script lang="ts">
export let provider: any
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>
{#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,7 +1,14 @@
import type { LayoutServerLoad } from "./$types"
export const load: LayoutServerLoad = async (event) => {
export const load: LayoutServerLoad = (event) => {
console.log('layout server load', event.locals.getSession)
let session
if (event.locals.getSession)
{
session = event.locals.getSession()
}
return {
session: await event.locals.getSession(),
session,
}
}

View File

@@ -1,151 +1,144 @@
<script lang="ts">
import { page } from "$app/stores"
import { page } from '$app/stores';
</script>
<div>
<header>
<div class="signedInStatus">
<p class="nojs-show loaded">
{#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>
<a href="/auth/signout" class="button">Sign out</a>
{:else}
<span class="notSignedInText">You are not signed in</span>
<a href="/auth/signin" class="buttonPrimary">Sign in</a>
{/if}
</p>
</div>
<nav>
<ul class="navItems">
<li class="navItem"><a href="/">Home</a></li>
<li class="navItem"><a href="/protected">Protected</a></li>
</ul>
</nav>
</header>
<slot />
<header>
<div class="signedInStatus">
<p class="nojs-show loaded">
{#if Object.keys($page.data.session || {}).length}
{#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>
<a href="/auth/signout" class="button">Sign out</a>
{:else}
<span class="notSignedInText">You are not signed in</span>
<a href="/auth/signin" class="buttonPrimary">Sign in</a>
{/if}
</p>
</div>
<nav>
<ul class="navItems">
<li class="navItem"><a href="/">Home</a></li>
<li class="navItem"><a href="/protected">Protected</a></li>
</ul>
</nav>
</header>
<slot />
</div>
<style>
:global(body) {
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif,
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
"Noto Color Emoji";
padding: 0 1rem 1rem 1rem;
max-width: 680px;
margin: 0 auto;
background: #fff;
color: #333;
}
:global(li),
:global(p) {
line-height: 1.5rem;
}
:global(a) {
font-weight: 500;
}
:global(hr) {
border: 1px solid #ddd;
}
:global(iframe) {
background: #ccc;
border: 1px solid #ccc;
height: 10rem;
width: 100%;
border-radius: 0.5rem;
filter: invert(1);
}
:global(body) {
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
'Segoe UI Symbol', 'Noto Color Emoji';
padding: 0 1rem 1rem 1rem;
max-width: 680px;
margin: 0 auto;
background: #fff;
color: #333;
}
:global(li),
:global(p) {
line-height: 1.5rem;
}
:global(a) {
font-weight: 500;
}
:global(hr) {
border: 1px solid #ddd;
}
:global(iframe) {
background: #ccc;
border: 1px solid #ccc;
height: 10rem;
width: 100%;
border-radius: 0.5rem;
filter: invert(1);
}
.nojs-show {
opacity: 1;
top: 0;
}
.signedInStatus {
display: block;
min-height: 4rem;
width: 100%;
}
.loaded {
position: relative;
top: 0;
opacity: 1;
overflow: hidden;
border-radius: 0 0 0.6rem 0.6rem;
padding: 0.6rem 1rem;
margin: 0;
background-color: rgba(0, 0, 0, 0.05);
transition: all 0.2s ease-in;
}
.signedInText,
.notSignedInText {
position: absolute;
padding-top: 0.8rem;
left: 1rem;
right: 6.5rem;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
display: inherit;
z-index: 1;
line-height: 1.3rem;
}
.signedInText {
padding-top: 0rem;
left: 4.6rem;
}
.avatar {
border-radius: 2rem;
float: left;
height: 2.8rem;
width: 2.8rem;
background-color: white;
background-size: cover;
background-repeat: no-repeat;
}
.button,
.buttonPrimary {
float: right;
margin-right: -0.4rem;
font-weight: 500;
border-radius: 0.3rem;
cursor: pointer;
font-size: 1rem;
line-height: 1.4rem;
padding: 0.7rem 0.8rem;
position: relative;
z-index: 10;
background-color: transparent;
color: #555;
}
.buttonPrimary {
background-color: #346df1;
border-color: #346df1;
color: #fff;
text-decoration: none;
padding: 0.7rem 1.4rem;
}
.buttonPrimary:hover {
box-shadow: inset 0 0 5rem rgba(0, 0, 0, 0.2);
}
.navItems {
margin-bottom: 2rem;
padding: 0;
list-style: none;
}
.navItem {
display: inline-block;
margin-right: 1rem;
}
.nojs-show {
opacity: 1;
top: 0;
}
.signedInStatus {
display: block;
min-height: 4rem;
width: 100%;
}
.loaded {
position: relative;
top: 0;
opacity: 1;
overflow: hidden;
border-radius: 0 0 0.6rem 0.6rem;
padding: 0.6rem 1rem;
margin: 0;
background-color: rgba(0, 0, 0, 0.05);
transition: all 0.2s ease-in;
}
.signedInText,
.notSignedInText {
position: absolute;
padding-top: 0.8rem;
left: 1rem;
right: 6.5rem;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
display: inherit;
z-index: 1;
line-height: 1.3rem;
}
.signedInText {
padding-top: 0rem;
left: 4.6rem;
}
.avatar {
border-radius: 2rem;
float: left;
height: 2.8rem;
width: 2.8rem;
background-color: white;
background-size: cover;
background-repeat: no-repeat;
}
.button,
.buttonPrimary {
float: right;
margin-right: -0.4rem;
font-weight: 500;
border-radius: 0.3rem;
cursor: pointer;
font-size: 1rem;
line-height: 1.4rem;
padding: 0.7rem 0.8rem;
position: relative;
z-index: 10;
background-color: transparent;
color: #555;
}
.buttonPrimary {
background-color: #346df1;
border-color: #346df1;
color: #fff;
text-decoration: none;
padding: 0.7rem 1.4rem;
}
.buttonPrimary:hover {
box-shadow: inset 0 0 5rem rgba(0, 0, 0, 0.2);
}
.navItems {
margin-bottom: 2rem;
padding: 0;
list-style: none;
}
.navItem {
display: inline-block;
margin-right: 1rem;
}
</style>

View File

@@ -1,33 +1,25 @@
<script>
import { signIn, signOut } from "@auth/sveltekit/client"
import { page } from "$app/stores"
import { signIn, signOut } from 'next-auth-sveltekit/client';
import { page } from '$app/stores';
</script>
<h1>SvelteKit Auth Example</h1>
<h1>SvelteKit + NextAuth.js 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://sveltekit.authjs.dev">SvelteKit Auth</a> for
authentication.
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.
{#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}
{#if Object.keys($page.data.session || {}).length}
{#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>
<button on:click={() => signIn('credentials', { redirect: false })}>Sign In credentials</button>
{/if}
</p>

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

@@ -14,4 +14,4 @@
//
// 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,8 +1,8 @@
import { sveltekit } from "@sveltejs/kit/vite"
import { sveltekit } from '@sveltejs/kit/vite';
/** @type {import('vite').UserConfig} */
const config = {
plugins: [sveltekit()],
}
plugins: [sveltekit()]
};
export default config
export default config;

View File

@@ -5,7 +5,7 @@
"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/* --filter=@auth/* --no-deps",
"build": "turbo run build --filter=next-auth --filter=@next-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",
@@ -32,7 +32,7 @@
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.0.0",
"husky": "^7.0.4",
"prettier": "2.8.1",
"prettier": "2.7.1",
"pretty-quick": "^3.1.2",
"semver": "7.3.5",
"stream-to-array": "2.3.0",
@@ -42,7 +42,8 @@
},
"release": {
"packageDirectories": [
"packages"
"packages",
"packages/frameworks"
]
},
"engines": {

5
packages/core/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
adapters.*
index.*
jwt
lib
providers

View File

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

View File

@@ -1,8 +1,8 @@
{
"name": "@auth/core",
"version": "0.1.3",
"version": "0.0.0",
"description": "Authentication for the web.",
"homepage": "https://authjs.dev",
"homepage": "https://next-auth.js.org",
"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.5",
"oauth4webapi": "2.0.4",
"preact": "10.11.3",
"preact-render-to-string": "5.2.3"
},

View File

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

View File

@@ -1,20 +1,20 @@
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 { 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 type { ErrorType } from "./lib/pages/error.js"
import type { ErrorType } from "./lib/pages/error"
import type {
AuthOptions,
RequestInternal,
ResponseInternal,
} from "./lib/types.js"
import { UntrustedHost } from "./lib/errors.js"
} from "./lib/types"
import { UntrustedHost } from "./lib/errors"
export * from "./lib/types.js"
export * from "./lib/types"
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 as any).code, assertionResult)
logger.error(assertionResult.code, assertionResult)
const htmlPages = ["signin", "signout", "error", "verify-request"]
if (!htmlPages.includes(req.action) || req.method !== "GET") {

View File

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

View File

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

View File

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

View File

@@ -1,11 +1,11 @@
import { AccountNotLinkedError } from "./errors.js"
import { fromDate } from "./utils/date.js"
import { AccountNotLinkedError } from "./errors"
import { fromDate } from "./utils/date"
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"
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"
/**
* This function handles the complex flow of signing users in, and either creating,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,14 +1,14 @@
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 { 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 type { AuthOptions, InternalOptions, RequestInternal } from "../index.js"
import type { AuthOptions, InternalOptions, RequestInternal } from ".."
interface InitParams {
url: URL

View File

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

View File

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

View File

@@ -1,8 +1,8 @@
import * as o from "oauth4webapi"
import * as jwt from "../../jwt/index.js"
import * as jwt from "../../jwt"
import type { InternalOptions } from "../../index.js"
import type { Cookie } from "../cookie.js"
import type { InternalOptions } from "../.."
import type { Cookie } from "../cookie"
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/index.js"
import * as jwt from "../../jwt"
import type { InternalOptions } from "../../index.js"
import type { Cookie } from "../cookie.js"
import type { InternalOptions } from "../.."
import type { Cookie } from "../cookie"
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 "../../index.js"
import type { Cookie } from "../cookie.js"
import type { InternalOptions } from "../.."
import type { Cookie } from "../cookie"
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 "../../index.js"
import type { Theme } from "../.."
/**
* The following errors are passed as error query parameters to the default or overridden error page.

View File

@@ -1,17 +1,13 @@
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 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 type {
InternalOptions,
RequestInternal,
ResponseInternal,
} from "../../index.js"
import type { Cookie } from "../cookie.js"
import type { ErrorType } from "./error.js"
import type { InternalOptions, RequestInternal, ResponseInternal } from "../.."
import type { Cookie } from "../cookie"
import type { ErrorType } from "./error"
type RenderPageParams = {
query?: RequestInternal["query"]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
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"
export { callback } from "./callback"
export { providers } from "./providers"
export { session } from "./session"
export { signin } from "./signin"
export { signout } from "./signout"

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
import type { InternalOptions, ResponseInternal } from "../../index.js"
import type { Adapter } from "../../adapters.js"
import type { SessionStore } from "../cookie.js"
import type { InternalOptions, ResponseInternal } from "../.."
import type { Adapter } from "../../adapters"
import type { SessionStore } from "../cookie"
/** 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.js"
import type { Adapter, AdapterUser } from "../adapters"
import type {
CredentialInput,
CredentialsConfig,
@@ -7,15 +7,16 @@ import type {
OAuthConfigInternal,
Provider,
ProviderType,
} from "../providers/index.js"
} from "../providers"
import type {
OAuth2TokenEndpointResponse,
OpenIDTokenEndpointResponse,
} from "oauth4webapi"
import type { JWT, JWTOptions } from "../jwt/types.js"
import type { Cookie } from "./cookie.js"
import type { LoggerInstance } from "./utils/logger.js"
import type { JWT, JWTOptions } from "../jwt"
import type { Cookie } from "./cookie"
import type { LoggerInstance } from "./utils/logger"
/** @internal */
export type Awaitable<T> = T | PromiseLike<T>
export type { LoggerInstance }
@@ -575,3 +576,37 @@ export interface InternalOptions<
cookies: CookiesOptions
callbackUrl: string
}
// Client types
/**
* Util type that matches some strings literally, but allows any other string as well.
* @source https://github.com/microsoft/TypeScript/issues/29729#issuecomment-832522611
*/
export type LiteralUnion<T extends U, U = string> =
| T
| (U & Record<never, never>)
export interface SignInOptions extends Record<string, unknown> {
/**
* Specify to which URL the user will be redirected after signing in. Defaults to the page URL the sign-in is initiated from.
*
* [Documentation](https://next-auth.js.org/getting-started/client#specifying-a-callbackurl)
*/
callbackUrl?: string
/** [Documentation](https://next-auth.js.org/getting-started/client#using-the-redirect-false-option) */
redirect?: boolean
}
/** Match `inputType` of `new URLSearchParams(inputType)` */
export type SignInAuthorizationParams =
| string
| string[][]
| Record<string, string>
| URLSearchParams
export interface SignOutParams<R extends boolean = true> {
/** [Documentation](https://next-auth.js.org/getting-started/client#specifying-a-callbackurl-1) */
callbackUrl?: string
/** [Documentation](https://next-auth.js.org/getting-started/client#using-the-redirect-false-option-1 */
redirect?: R
}

View File

@@ -1,4 +1,4 @@
import { UnknownError } from "../errors.js"
import { UnknownError } from "../errors"
/** 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 "../index.js"
import { UnknownAction } from "./errors.js"
import type { AuthAction } from "./types.js"
import type { RequestInternal, ResponseInternal } from ".."
import { UnknownAction } from "./errors"
import type { AuthAction } from "./types"
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 "./index.js"
import type { OAuthConfig, OAuthUserConfig } from "."
export interface UserData {
id: number

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
import type { OAuthConfig, OAuthUserConfig } from "."
export interface EVEOnlineProfile extends Record<string, any> {
CharacterID: number
@@ -17,8 +17,7 @@ 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 "./index.js"
import type { OAuthConfig, OAuthUserConfig } from "."
interface FacebookPictureData {
url: string

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
import type { OAuthConfig, OAuthUserConfig } from "."
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.js"
import type { EmailConfig, EmailProvider, EmailProviderType } from "./email.js"
import type { OAuthConfig, OAuthProvider, OAuthProviderType } from "./oauth"
import type { EmailConfig, EmailProvider, EmailProviderType } from "./email"
import type {
CredentialsConfig,
CredentialsProvider,
CredentialsProviderType,
} from "./credentials.js"
} from "./credentials"
export * from "./credentials.js"
export * from "./email.js"
export * from "./oauth.js"
export * from "./credentials"
export * from "./email"
export * from "./oauth"
export type ProviderType = "oidc" | "oauth" | "email" | "credentials"

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
import type { OAuthConfig, OAuthUserConfig } from "."
/** 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/index.js"
import type { Profile, TokenSet, User, Awaitable } from "../index.js"
import type { CommonProviderOptions } from "../providers"
import type { Profile, TokenSet, User, Awaitable } from ".."
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.js"
export type { OAuthProviderType } from "./oauth-types"
type ChecksType = "pkce" | "state" | "none" | "nonce"
@@ -96,17 +96,6 @@ 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 "./index.js"
import type { OAuthConfig, OAuthUserConfig } from "."
export interface OktaProfile extends Record<string, any> {
iss: string

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
// TODO: move OAuth 1.0 support or remove it?
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
import type { OAuthConfig, OAuthUserConfig } from "."
export interface TwitterLegacyProfile {
id: number

View File

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

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
import type { OAuthConfig, OAuthUserConfig } from "."
export interface VkProfile {
// https://dev.vk.com/reference/objects/user

View File

@@ -1,4 +1,4 @@
import type { OAuthConfig, OAuthUserConfig } from "./index.js"
import type { OAuthConfig, OAuthUserConfig } from "."
export type WikimediaGroup =
| "*"

View File

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

View File

@@ -1,4 +1,4 @@
import type { OIDCConfig, OAuthUserConfig } from "./index.js"
import type { OIDCConfig, OAuthUserConfig } from "."
export interface ZitadelProfile extends Record<string, any> {
amr: string // Authentication Method References as defined in RFC8176

View File

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

View File

@@ -5,7 +5,6 @@
"baseUrl": ".",
"isolatedModules": true,
"jsx": "react-jsx",
"jsxImportSource": "preact",
"lib": [
"dom",
"dom.iterable",

View File

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

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