mirror of
https://github.com/SrIzan10/next-auth.git
synced 2026-05-01 10:55:20 +00:00
Compare commits
40 Commits
@auth/svel
...
@auth/svel
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bcf909b69e | ||
|
|
4dcdd21242 | ||
|
|
137d993a13 | ||
|
|
8dda662cd6 | ||
|
|
8a438bab32 | ||
|
|
4aaad03e9c | ||
|
|
4fa0d1fa2a | ||
|
|
c081773667 | ||
|
|
1ab0a2aed4 | ||
|
|
cac9816d32 | ||
|
|
65defc709e | ||
|
|
1601626d31 | ||
|
|
8c4f439279 | ||
|
|
a3cc9cb5f8 | ||
|
|
0ad4be2809 | ||
|
|
aea4aaf25f | ||
|
|
9bd7bc8a47 | ||
|
|
bf8fc9ca94 | ||
|
|
7116248e87 | ||
|
|
ef8f353d94 | ||
|
|
01620f9b7c | ||
|
|
87d41aff94 | ||
|
|
2d21f5ea5e | ||
|
|
adf7cae7a0 | ||
|
|
f9b75e0a39 | ||
|
|
9d6f54539d | ||
|
|
0e51c66e11 | ||
|
|
e47c3c81f1 | ||
|
|
d69edb8501 | ||
|
|
e5c0e3513b | ||
|
|
ca208ce732 | ||
|
|
dcb601987b | ||
|
|
7fd799a9ac | ||
|
|
fdd5e2390d | ||
|
|
fdecbb59c4 | ||
|
|
677d8a346f | ||
|
|
aad0b8db0e | ||
|
|
137bbb8d84 | ||
|
|
d7fbd05eba | ||
|
|
532aa24495 |
70
.eslintignore
Normal file
70
.eslintignore
Normal file
@@ -0,0 +1,70 @@
|
||||
.eslintrc.js
|
||||
.cache-loader
|
||||
.DS_Store
|
||||
.pnpm-debug.log
|
||||
.turbo
|
||||
.vscode/generated*
|
||||
/_work
|
||||
/actions-runner
|
||||
node_modules
|
||||
patches
|
||||
pnpm-lock.yaml
|
||||
.github/actions/issue-validator/index.mjs
|
||||
*.cjs
|
||||
*.js
|
||||
*.d.ts
|
||||
*.d.ts.map
|
||||
|
||||
.svelte-kit
|
||||
.next
|
||||
.nuxt
|
||||
|
||||
# --------------- Docs ---------------
|
||||
|
||||
.docusaurus
|
||||
build
|
||||
docs/docs/reference/03-core
|
||||
docs/docs/reference/04-sveltekit
|
||||
static
|
||||
|
||||
# --------------- Packages ---------------
|
||||
|
||||
coverage
|
||||
dist
|
||||
|
||||
# @auth/core
|
||||
packages/core/src/providers/oauth-types.ts
|
||||
packages/core/src/lib/pages/styles.ts
|
||||
|
||||
# @auth/sveltekit
|
||||
packages/frameworks-sveltekit/package
|
||||
packages/frameworks-sveltekit/vite.config.{js,ts}.timestamp-*
|
||||
|
||||
# next-auth
|
||||
packages/next-auth/src/providers/oauth-types.ts
|
||||
packages/next-auth/css/index.css
|
||||
|
||||
|
||||
# Adapters
|
||||
.branches
|
||||
db.sqlite
|
||||
dev.db
|
||||
dynamodblocal-bin
|
||||
firebase-debug.log
|
||||
firestore-debug.log
|
||||
migrations
|
||||
test.schema.gql
|
||||
|
||||
# --------------- Apps ---------------
|
||||
|
||||
|
||||
# Examples should have their own Prettier config since they are templates too
|
||||
apps/example-sveltekit
|
||||
|
||||
# Development app
|
||||
apps
|
||||
|
||||
|
||||
# --------------- Tests ---------------
|
||||
# TODO: these should be linted
|
||||
packages/**/*test*
|
||||
66
.eslintrc.js
66
.eslintrc.js
@@ -1,31 +1,37 @@
|
||||
// @ts-check
|
||||
const path = require("path")
|
||||
|
||||
/** @type {import("eslint").ESLint.ConfigData} */
|
||||
module.exports = {
|
||||
root: true,
|
||||
parser: "@typescript-eslint/parser",
|
||||
extends: ["standard-with-typescript", "prettier"],
|
||||
rules: {
|
||||
camelcase: "off",
|
||||
"@typescript-eslint/naming-convention": "off",
|
||||
"@typescript-eslint/strict-boolean-expressions": "off",
|
||||
"@typescript-eslint/explicit-function-return-type": "off",
|
||||
"@typescript-eslint/restrict-template-expressions": "off",
|
||||
},
|
||||
env: { browser: true, es2022: true, node: true },
|
||||
extends: ["eslint:recommended", "prettier"],
|
||||
overrides: [
|
||||
{
|
||||
files: ["*.ts", "*.tsx"],
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
project: [
|
||||
path.resolve(__dirname, "./packages/**/tsconfig.eslint.json"),
|
||||
path.resolve(__dirname, "./packages/frameworks/**/tsconfig.json"),
|
||||
path.resolve(__dirname, "./apps/**/tsconfig.json"),
|
||||
],
|
||||
project: ["./packages/**/tsconfig.json", "./apps/**/tsconfig.json"],
|
||||
},
|
||||
settings: { react: { version: "18" } },
|
||||
extends: [
|
||||
"plugin:react/recommended",
|
||||
"plugin:react/jsx-runtime",
|
||||
"standard-with-typescript",
|
||||
"prettier",
|
||||
],
|
||||
rules: {
|
||||
"@typescript-eslint/explicit-function-return-type": "off",
|
||||
"@typescript-eslint/method-signature-style": "off",
|
||||
"@typescript-eslint/naming-convention": "off",
|
||||
"@typescript-eslint/no-non-null-assertion": "off",
|
||||
"@typescript-eslint/restrict-template-expressions": "off",
|
||||
"@typescript-eslint/strict-boolean-expressions": "off",
|
||||
"react/prop-types": "off",
|
||||
"react/no-unescaped-entities": "off",
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["*.test.ts", "*.test.js"],
|
||||
extends: ["plugin:jest/recommended"],
|
||||
env: { jest: true },
|
||||
},
|
||||
{
|
||||
@@ -34,7 +40,8 @@ module.exports = {
|
||||
extends: ["plugin:@docusaurus/recommended"],
|
||||
},
|
||||
{
|
||||
files: ["packages/core/src/**/*"],
|
||||
// TODO: Expand to all packages
|
||||
files: ["packages/{core,sveltekit}/*.ts"],
|
||||
plugins: ["jsdoc"],
|
||||
extends: ["plugin:jsdoc/recommended"],
|
||||
rules: {
|
||||
@@ -49,19 +56,20 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["packages/core/src/adapters.ts"],
|
||||
rules: {
|
||||
"@typescript-eslint/method-signature-style": "off",
|
||||
files: ["packages/frameworks-sveltekit"],
|
||||
plugins: ["svelte3"],
|
||||
overrides: [{ files: ["*.svelte"], processor: "svelte3/svelte3" }],
|
||||
settings: {
|
||||
"svelte3/typescript": () => require("typescript"),
|
||||
},
|
||||
parserOptions: { sourceType: "module", ecmaVersion: 2020 },
|
||||
env: { browser: true, es2017: true, node: true },
|
||||
},
|
||||
],
|
||||
plugins: ["jest"],
|
||||
ignorePatterns: [
|
||||
"**/dist/**",
|
||||
"**/node_modules/**",
|
||||
".eslintrc.js",
|
||||
"**/.turbo/**",
|
||||
"**/coverage/**",
|
||||
"**/build/**",
|
||||
],
|
||||
parserOptions: {
|
||||
sourceType: "module",
|
||||
ecmaVersion: "latest",
|
||||
ecmaFeatures: { jsx: true },
|
||||
},
|
||||
root: true,
|
||||
}
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/config.yml
vendored
2
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1 +1 @@
|
||||
blank_issues_enabled: false
|
||||
blank_issues_enabled: false
|
||||
|
||||
2
.github/actions/issue-validator/index.mjs
vendored
2
.github/actions/issue-validator/index.mjs
vendored
File diff suppressed because one or more lines are too long
3
.github/actions/issue-validator/licenses.txt
vendored
3
.github/actions/issue-validator/licenses.txt
vendored
@@ -526,7 +526,7 @@ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
root
|
||||
ISC License
|
||||
|
||||
Copyright (c) 2018-2021, Iain Collins
|
||||
Copyright (c) 2022-2023, Balázs Orbán
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -540,6 +540,7 @@ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
|
||||
tr46
|
||||
MIT
|
||||
|
||||
|
||||
1
.github/actions/issue-validator/repro.md
vendored
1
.github/actions/issue-validator/repro.md
vendored
@@ -35,4 +35,3 @@ Upvoting issues to show your interest will help us prioritize and address them a
|
||||
- [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve)
|
||||
- [Reporting a NextAuth.js bug](https://github.com/nextauthjs/next-auth/blob/main/.github/ISSUE_TEMPLATE/1_bug_framework.yml)
|
||||
- [How to Contribute to Open Source (Next.js)](https://www.youtube.com/watch?v=cuoNzXFLitc)
|
||||
|
||||
|
||||
14
.github/actions/issue-validator/src/index.mjs
vendored
14
.github/actions/issue-validator/src/index.mjs
vendored
@@ -4,6 +4,7 @@ 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"
|
||||
|
||||
@@ -40,7 +41,13 @@ async function run() {
|
||||
label: { name: newLabel },
|
||||
} = payload
|
||||
|
||||
if (pull_request || !issue?.body || !process.env.GITHUB_TOKEN) return
|
||||
if (
|
||||
pull_request ||
|
||||
!issue?.body ||
|
||||
!process.env.GITHUB_TOKEN ||
|
||||
!process.env.GITHUB_ACTION_PATH
|
||||
)
|
||||
return
|
||||
|
||||
const labels = issue.labels.map((l) => l.name)
|
||||
// const isBugReport =
|
||||
@@ -70,7 +77,10 @@ async function run() {
|
||||
}),
|
||||
client.issues.createComment({
|
||||
...issueCommon,
|
||||
body: readFileSync("repro.md", "utf8"),
|
||||
body: readFileSync(
|
||||
join(process.env.GITHUB_ACTION_PATH, "repro.md"),
|
||||
"utf8"
|
||||
),
|
||||
}),
|
||||
])
|
||||
return core.info(
|
||||
|
||||
13
.github/workflows/release.yml
vendored
13
.github/workflows/release.yml
vendored
@@ -20,8 +20,6 @@ jobs:
|
||||
fetch-depth: 2
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2.2.4
|
||||
with:
|
||||
version: 7.5.1
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
@@ -50,10 +48,9 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GH_PAT_CLASSIC }}
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2.2.4
|
||||
with:
|
||||
version: 7.5.1
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
@@ -64,9 +61,10 @@ jobs:
|
||||
- name: Publish to npm and GitHub
|
||||
run: pnpm release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
||||
# Use GH_PAT when this is fixed:
|
||||
# https://github.com/github/roadmap/issues/622
|
||||
GITHUB_TOKEN: ${{ secrets.GH_PAT_CLASSIC }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
NO_VERIFY: 1
|
||||
release-pr:
|
||||
name: Publish PR
|
||||
runs-on: ubuntu-latest
|
||||
@@ -78,8 +76,6 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2.2.4
|
||||
with:
|
||||
version: 7.5.1
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
@@ -110,4 +106,3 @@ jobs:
|
||||
env:
|
||||
VERSION: ${{ steps.determine-version.outputs.version }}
|
||||
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
||||
|
||||
|
||||
2
.github/workflows/sync-examples.yml
vendored
2
.github/workflows/sync-examples.yml
vendored
@@ -14,6 +14,6 @@ jobs:
|
||||
# Can update to v1 when https://github.com/BetaHuhn/repo-file-sync-action/issues/168 is resolved
|
||||
uses: BetaHuhn/repo-file-sync-action@v1.16.5
|
||||
with:
|
||||
GH_PAT: ${{ secrets.SYNC_EXAMPLE_PAT }}
|
||||
GH_PAT: ${{ secrets.GH_PAT_CLASSIC }}
|
||||
SKIP_PR: true
|
||||
ORIGINAL_MESSAGE: true
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,7 +1,7 @@
|
||||
# Misc
|
||||
.DS_Store
|
||||
.npmrc
|
||||
|
||||
.eslintcache
|
||||
.env
|
||||
.env.local
|
||||
.env.development.local
|
||||
|
||||
1
.husky/.gitignore
vendored
1
.husky/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
_
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
# npx pretty-quick --staged
|
||||
67
.prettierignore
Normal file
67
.prettierignore
Normal file
@@ -0,0 +1,67 @@
|
||||
.cache-loader
|
||||
.DS_Store
|
||||
.pnpm-debug.log
|
||||
.turbo
|
||||
.vscode/generated*
|
||||
/_work
|
||||
/actions-runner
|
||||
node_modules
|
||||
patches
|
||||
pnpm-lock.yaml
|
||||
.github/actions/issue-validator/index.mjs
|
||||
*.d.ts
|
||||
*.d.ts.map
|
||||
|
||||
.svelte-kit
|
||||
.next
|
||||
.nuxt
|
||||
|
||||
# --------------- Docs ---------------
|
||||
|
||||
.docusaurus
|
||||
build
|
||||
docs/docs/reference/03-core
|
||||
docs/docs/reference/04-sveltekit
|
||||
static
|
||||
docs/providers.json
|
||||
|
||||
# --------------- Packages ---------------
|
||||
|
||||
coverage
|
||||
dist
|
||||
packages/**/*.cjs
|
||||
packages/**/*.js
|
||||
|
||||
# @auth/core
|
||||
packages/core/src/providers/oauth-types.ts
|
||||
packages/core/src/lib/pages/styles.ts
|
||||
|
||||
# @auth/sveltekit
|
||||
packages/frameworks-sveltekit/package
|
||||
packages/frameworks-sveltekit/vite.config.{js,ts}.timestamp-*
|
||||
|
||||
# next-auth
|
||||
packages/next-auth/src/providers/oauth-types.ts
|
||||
packages/next-auth/css/index.css
|
||||
|
||||
|
||||
# Adapters
|
||||
.branches
|
||||
db.sqlite
|
||||
dev.db
|
||||
dynamodblocal-bin
|
||||
firebase-debug.log
|
||||
firestore-debug.log
|
||||
migrations
|
||||
test.schema.gql
|
||||
|
||||
# --------------- Apps ---------------
|
||||
|
||||
|
||||
# Examples should have their own Prettier config since they are templates too
|
||||
apps/example-sveltekit
|
||||
|
||||
# Development app
|
||||
apps/dev/prisma
|
||||
apps/dev/migrations
|
||||
apps/dev/typeorm
|
||||
@@ -12,5 +12,11 @@ module.exports = {
|
||||
],
|
||||
options: { printWidth: 150 },
|
||||
},
|
||||
{
|
||||
files: ["**/*package.json"],
|
||||
options: {
|
||||
trailingComma: "none",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
14
.vscode/settings.json
vendored
14
.vscode/settings.json
vendored
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"files.exclude": {
|
||||
"packages/core/{lib,providers,*.js,*.d.ts,*.d.ts.map}": true,
|
||||
"packages/next-auth/{client,core,css,jwt,next,providers,react,utils,*.js,*.d.ts}": true
|
||||
},
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"openInGitHub.remote.branch": "main",
|
||||
}
|
||||
"files.exclude": {
|
||||
"packages/core/{lib,providers,*.js,*.d.ts,*.d.ts.map}": true,
|
||||
"packages/next-auth/{client,core,css,jwt,next,providers,react,utils,*.js,*.d.ts}": true
|
||||
},
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"openInGitHub.remote.branch": "main"
|
||||
}
|
||||
|
||||
12
.vscode/snippets.code-snippets
vendored
12
.vscode/snippets.code-snippets
vendored
@@ -3,16 +3,12 @@
|
||||
"description": "Markdown link to OAuth 2 specification",
|
||||
"scope": "typescript",
|
||||
"prefix": "oauth2",
|
||||
"body": [
|
||||
"[OAuth 2](https://datatracker.ietf.org/doc/html/rfc6749)"
|
||||
]
|
||||
"body": ["[OAuth 2](https://datatracker.ietf.org/doc/html/rfc6749)"]
|
||||
},
|
||||
"oidc-spec": {
|
||||
"description": "Markdown link to OpenID Connect specification",
|
||||
"scope": "typescript",
|
||||
"prefix": "oidc",
|
||||
"body": [
|
||||
"[OIDC](https://openid.net/specs/openid-connect-core-1_0.html)"
|
||||
]
|
||||
},
|
||||
}
|
||||
"body": ["[OIDC](https://openid.net/specs/openid-connect-core-1_0.html)"]
|
||||
}
|
||||
}
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -12,4 +12,4 @@ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
2
apps/dev/.vscode/settings.json
vendored
2
apps/dev/.vscode/settings.json
vendored
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"typescript.tsdk": "../../node_modules/.pnpm/typescript@4.8.4/node_modules/typescript/lib",
|
||||
"typescript.tsdk": "../../node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib",
|
||||
"typescript.enablePromptUseWorkspaceTsdk": true
|
||||
}
|
||||
@@ -3,4 +3,4 @@
|
||||
This folder contains a Next.js app using NextAuth.js for local development. See the following section on how to start:
|
||||
|
||||
[Setting up local environment
|
||||
](https://github.com/nextauthjs/next-auth/blob/main/CONTRIBUTING.md#setting-up-local-environment)
|
||||
](https://github.com/nextauthjs/next-auth/blob/main/CONTRIBUTING.md#setting-up-local-environment)
|
||||
|
||||
@@ -11,4 +11,4 @@
|
||||
.navItem {
|
||||
display: inline-block;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
top: 0;
|
||||
opacity: 1;
|
||||
overflow: hidden;
|
||||
border-radius: 0 0 .6rem .6rem;
|
||||
padding: .6rem 1rem;
|
||||
border-radius: 0 0 0.6rem 0.6rem;
|
||||
padding: 0.6rem 1rem;
|
||||
margin: 0;
|
||||
background-color: rgba(0,0,0,.05);
|
||||
background-color: rgba(0, 0, 0, 0.05);
|
||||
transition: all 0.2s ease-in;
|
||||
}
|
||||
|
||||
@@ -26,13 +26,13 @@
|
||||
.signedInText,
|
||||
.notSignedInText {
|
||||
position: absolute;
|
||||
padding-top: .8rem;
|
||||
padding-top: 0.8rem;
|
||||
left: 1rem;
|
||||
right: 6.5rem;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
display: inherit;
|
||||
display: inherit;
|
||||
z-index: 1;
|
||||
line-height: 1.3rem;
|
||||
}
|
||||
@@ -55,13 +55,13 @@
|
||||
.button,
|
||||
.buttonPrimary {
|
||||
float: right;
|
||||
margin-right: -.4rem;
|
||||
margin-right: -0.4rem;
|
||||
font-weight: 500;
|
||||
border-radius: .3rem;
|
||||
border-radius: 0.3rem;
|
||||
cursor: pointer;
|
||||
font-size: 1rem;
|
||||
line-height: 1.4rem;
|
||||
padding: .7rem .8rem;
|
||||
padding: 0.7rem 0.8rem;
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
background-color: transparent;
|
||||
@@ -73,11 +73,11 @@
|
||||
border-color: #346df1;
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
padding: .7rem 1.4rem;
|
||||
padding: 0.7rem 1.4rem;
|
||||
}
|
||||
|
||||
.buttonPrimary:hover {
|
||||
box-shadow: inset 0 0 5rem rgba(0,0,0,0.2)
|
||||
box-shadow: inset 0 0 5rem rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.navItems {
|
||||
@@ -89,4 +89,4 @@
|
||||
.navItem {
|
||||
display: inline-block;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import Header from 'components/header'
|
||||
import Footer from 'components/footer'
|
||||
import Header from "components/header"
|
||||
import Footer from "components/footer"
|
||||
|
||||
export default function Layout ({ children }) {
|
||||
export default function Layout({ children }) {
|
||||
return (
|
||||
<>
|
||||
<Header />
|
||||
<main>
|
||||
{children}
|
||||
</main>
|
||||
<main>{children}</main>
|
||||
<Footer />
|
||||
</>
|
||||
)
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"@prisma/client": "^3",
|
||||
"@supabase/supabase-js": "^2.0.5",
|
||||
"faunadb": "^4",
|
||||
"next": "13.0.6",
|
||||
"next": "13.1.1",
|
||||
"next-auth": "workspace:*",
|
||||
"@auth/core": "workspace:*",
|
||||
"nodemailer": "^6",
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
import Layout from '../components/layout'
|
||||
import Layout from "../components/layout"
|
||||
|
||||
export default function Page () {
|
||||
export default function Page() {
|
||||
return (
|
||||
<Layout>
|
||||
<h1>API Example</h1>
|
||||
<p>The examples below show responses from the example API endpoints.</p>
|
||||
<p><em>You must be signed in to see responses.</em></p>
|
||||
<p>
|
||||
<em>You must be signed in to see responses.</em>
|
||||
</p>
|
||||
<h2>Session</h2>
|
||||
<p>/api/examples/session</p>
|
||||
<iframe src='/api/examples/session' />
|
||||
<iframe src="/api/examples/session" />
|
||||
<h2>JSON Web Token</h2>
|
||||
<p>/api/examples/jwt</p>
|
||||
<iframe src='/api/examples/jwt' />
|
||||
<iframe src="/api/examples/jwt" />
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,21 +1,26 @@
|
||||
import Layout from '../components/layout'
|
||||
import Layout from "../components/layout"
|
||||
|
||||
export default function Page () {
|
||||
export default function Page() {
|
||||
return (
|
||||
<Layout>
|
||||
<h1>Client Side Rendering</h1>
|
||||
<p>
|
||||
This page uses the <strong>useSession()</strong> React Hook in the <strong></Header></strong> component.
|
||||
This page uses the <strong>useSession()</strong> React Hook in the{" "}
|
||||
<strong></Header></strong> component.
|
||||
</p>
|
||||
<p>
|
||||
The <strong>useSession()</strong> React Hook easy to use and allows pages to render very quickly.
|
||||
The <strong>useSession()</strong> React Hook easy to use and allows
|
||||
pages to render very quickly.
|
||||
</p>
|
||||
<p>
|
||||
The advantage of this approach is that session state is shared between pages by using the <strong>Provider</strong> in <strong>_app.js</strong> so
|
||||
that navigation between pages using <strong>useSession()</strong> is very fast.
|
||||
The advantage of this approach is that session state is shared between
|
||||
pages by using the <strong>Provider</strong> in <strong>_app.js</strong>{" "}
|
||||
so that navigation between pages using <strong>useSession()</strong> is
|
||||
very fast.
|
||||
</p>
|
||||
<p>
|
||||
The disadvantage of <strong>useSession()</strong> is that it requires client side JavaScript.
|
||||
The disadvantage of <strong>useSession()</strong> is that it requires
|
||||
client side JavaScript.
|
||||
</p>
|
||||
</Layout>
|
||||
)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import Layout from 'components/layout'
|
||||
import Layout from "components/layout"
|
||||
|
||||
export default function Page () {
|
||||
export default function Page() {
|
||||
return (
|
||||
<Layout>
|
||||
<h1>NextAuth.js Example</h1>
|
||||
<p>
|
||||
This is an example site to demonstrate how to use{' '}
|
||||
This is an example site to demonstrate how to use{" "}
|
||||
<a href="https://authjs.dev">NextAuth.js</a> for authentication.
|
||||
</p>
|
||||
</Layout>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { unstable_getServerSession } from "next-auth/next"
|
||||
import Layout from "../components/layout"
|
||||
import { authOptions } from './api/auth/[...nextauth]';
|
||||
import { authOptions } from "./api/auth/[...nextauth]"
|
||||
|
||||
export default function Page() {
|
||||
// As this page uses Server Side Rendering, the `session` will be already
|
||||
|
||||
@@ -27,6 +27,6 @@ iframe {
|
||||
border: 1px solid #ccc;
|
||||
height: 10rem;
|
||||
width: 100%;
|
||||
border-radius: .5rem;
|
||||
border-radius: 0.5rem;
|
||||
filter: invert(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": false,
|
||||
@@ -25,14 +21,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
".next/types/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"jest.config.js"
|
||||
]
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
||||
"exclude": ["node_modules", "jest.config.js"]
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ NextAuth.js is an easy to implement, full-stack (client/server) open source auth
|
||||
|
||||
Go to [next-auth.js.org](https://next-auth.js.org) for more information and documentation.
|
||||
|
||||
> *NextAuth.js is not officially associated with Vercel or Next.js.*
|
||||
> _NextAuth.js is not officially associated with Vercel or Next.js._
|
||||
|
||||
## Getting Started
|
||||
|
||||
@@ -67,7 +67,7 @@ You **can** skip configuring a database and come back to it later if you want.
|
||||
|
||||
For more information about setting up a database, please check out the following links:
|
||||
|
||||
* Docs: [next-auth.js.org/adapters/overview](https://next-auth.js.org/adapters/overview)
|
||||
- Docs: [next-auth.js.org/adapters/overview](https://next-auth.js.org/adapters/overview)
|
||||
|
||||
### 3. Configure Authentication Providers
|
||||
|
||||
@@ -75,9 +75,9 @@ For more information about setting up a database, please check out the following
|
||||
|
||||
2. When setting up OAuth, in the developer admin page for each of your OAuth services, you should configure the callback URL to use a callback path of `{server}/api/auth/callback/{provider}`.
|
||||
|
||||
e.g. For Google OAuth you would use: `http://localhost:3000/api/auth/callback/google`
|
||||
e.g. For Google OAuth you would use: `http://localhost:3000/api/auth/callback/google`
|
||||
|
||||
A list of configured providers and their callback URLs is available from the endpoint `/api/auth/providers`. You can find more information at https://next-auth.js.org/configuration/providers/oauth
|
||||
A list of configured providers and their callback URLs is available from the endpoint `/api/auth/providers`. You can find more information at https://next-auth.js.org/configuration/providers/oauth
|
||||
|
||||
3. You can also choose to specify an SMTP server for passwordless sign in via email.
|
||||
|
||||
@@ -110,4 +110,3 @@ Follow the [Deployment documentation](https://next-auth.js.org/deployment)
|
||||
## License
|
||||
|
||||
ISC
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ export default function ProtectedPage() {
|
||||
}
|
||||
fetchData()
|
||||
}, [session])
|
||||
|
||||
|
||||
// If no session exists, display access denied message
|
||||
if (!session) {
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
@@ -19,6 +15,12 @@
|
||||
"jsx": "preserve",
|
||||
"incremental": true
|
||||
},
|
||||
"include": ["process.d.ts", "next-env.d.ts", "next-auth.d.ts", "**/*.ts", "**/*.tsx"],
|
||||
"include": [
|
||||
"process.d.ts",
|
||||
"next-env.d.ts",
|
||||
"next-auth.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx"
|
||||
],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SvelteKitAuth from "@auth/sveltekit"
|
||||
import { SvelteKitAuth } from "@auth/sveltekit"
|
||||
import GitHub from "@auth/core/providers/github"
|
||||
import { GITHUB_ID, GITHUB_SECRET } from "$env/static/private"
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ Auth.js is an easy to implement, full-stack (client/server) open source authenti
|
||||
|
||||
Go to [authjs.dev](https://authjs.dev) for more information and documentation.
|
||||
|
||||
> Auth.js is not officially associated with Vercel or Next.js._
|
||||
> Auth.js is not officially associated with Vercel or Next.js.\_
|
||||
|
||||
## Getting Started
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: ['@nuxt/eslint-config'],
|
||||
extends: ["@nuxt/eslint-config"],
|
||||
rules: {
|
||||
'vue/multi-word-component-names': 'off'
|
||||
}
|
||||
"vue/multi-word-component-names": "off",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ Here's an example of what it looks like:
|
||||
```ts
|
||||
// server/api/auth/[...].ts
|
||||
|
||||
import { NuxtAuthHandler } from '@/lib/auth/server'
|
||||
import GithubProvider from '@auth/core/providers/github'
|
||||
import type { AuthOptions } from '@auth/core'
|
||||
import { NuxtAuthHandler } from "@/lib/auth/server"
|
||||
import GithubProvider from "@auth/core/providers/github"
|
||||
import type { AuthOptions } from "@auth/core"
|
||||
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
|
||||
@@ -39,9 +39,9 @@ export const authOptions: AuthOptions = {
|
||||
providers: [
|
||||
GithubProvider({
|
||||
clientId: runtimeConfig.github.clientId,
|
||||
clientSecret: runtimeConfig.github.clientSecret
|
||||
})
|
||||
]
|
||||
clientSecret: runtimeConfig.github.clientSecret,
|
||||
}),
|
||||
],
|
||||
}
|
||||
|
||||
export default NuxtAuthHandler(authOptions)
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
|
||||
<style>
|
||||
body {
|
||||
font-family: -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
||||
font-family: -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans,
|
||||
sans-serif, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif,
|
||||
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
||||
padding: 0 1rem 1rem 1rem;
|
||||
max-width: 680px;
|
||||
margin: 0 auto;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { signIn, signOut } from '@/lib/auth/client'
|
||||
import { signIn, signOut } from "@/lib/auth/client"
|
||||
|
||||
const session = useSession()
|
||||
</script>
|
||||
@@ -9,30 +9,37 @@ const session = useSession()
|
||||
<div class="signedInStatus">
|
||||
<p :class="['nojs-show', 'loaded']">
|
||||
<template v-if="session">
|
||||
<span v-if="session.user?.image" :style="{ backgroundImage: `url(${session.user.image})` }" class="avatar" />
|
||||
<span
|
||||
v-if="session.user?.image"
|
||||
:style="{ backgroundImage: `url(${session.user.image})` }"
|
||||
class="avatar"
|
||||
/>
|
||||
<span class="signedInText">
|
||||
<small>Signed in as</small><br>
|
||||
<small>Signed in as</small><br />
|
||||
<strong>{{ session.user?.email || session.user?.name }}</strong>
|
||||
</span>
|
||||
<a href="/api/auth/signout" class="button" @click.prevent="signOut">Sign out</a>
|
||||
<a href="/api/auth/signout" class="button" @click.prevent="signOut"
|
||||
>Sign out</a
|
||||
>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span class="notSignedInText">You are not signed in</span>
|
||||
<a href="/api/auth/signin" class="buttonPrimary" @click.prevent="signIn">Sign in</a>
|
||||
<a
|
||||
href="/api/auth/signin"
|
||||
class="buttonPrimary"
|
||||
@click.prevent="signIn"
|
||||
>Sign in</a
|
||||
>
|
||||
</template>
|
||||
</p>
|
||||
</div>
|
||||
<nav>
|
||||
<ul class="navItems">
|
||||
<li class="navItem">
|
||||
<NuxtLink to="/">
|
||||
Home
|
||||
</NuxtLink>
|
||||
<NuxtLink to="/"> Home </NuxtLink>
|
||||
</li>
|
||||
<li class="navItem">
|
||||
<NuxtLink to="/protected">
|
||||
Protected
|
||||
</NuxtLink>
|
||||
<NuxtLink to="/protected"> Protected </NuxtLink>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
@@ -57,10 +64,10 @@ const session = useSession()
|
||||
top: 0;
|
||||
opacity: 1;
|
||||
overflow: hidden;
|
||||
border-radius: 0 0 .6rem .6rem;
|
||||
padding: .6rem 1rem;
|
||||
border-radius: 0 0 0.6rem 0.6rem;
|
||||
padding: 0.6rem 1rem;
|
||||
margin: 0;
|
||||
background-color: rgba(0,0,0,.05);
|
||||
background-color: rgba(0, 0, 0, 0.05);
|
||||
transition: all 0.2s ease-in;
|
||||
}
|
||||
|
||||
@@ -72,7 +79,7 @@ const session = useSession()
|
||||
.signedInText,
|
||||
.notSignedInText {
|
||||
position: absolute;
|
||||
padding-top: .8rem;
|
||||
padding-top: 0.8rem;
|
||||
left: 1rem;
|
||||
right: 6.5rem;
|
||||
white-space: nowrap;
|
||||
@@ -101,13 +108,13 @@ const session = useSession()
|
||||
.button,
|
||||
.buttonPrimary {
|
||||
float: right;
|
||||
margin-right: -.4rem;
|
||||
margin-right: -0.4rem;
|
||||
font-weight: 500;
|
||||
border-radius: .3rem;
|
||||
border-radius: 0.3rem;
|
||||
cursor: pointer;
|
||||
font-size: 1rem;
|
||||
line-height: 1.4rem;
|
||||
padding: .7rem .8rem;
|
||||
padding: 0.7rem 0.8rem;
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
background-color: transparent;
|
||||
@@ -119,11 +126,11 @@ const session = useSession()
|
||||
border-color: #346df1;
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
padding: .7rem 1.4rem;
|
||||
padding: 0.7rem 1.4rem;
|
||||
}
|
||||
|
||||
.buttonPrimary:hover {
|
||||
box-shadow: inset 0 0 5rem rgba(0,0,0,0.2)
|
||||
box-shadow: inset 0 0 5rem rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.navItems {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Session } from '@auth/core'
|
||||
import { Session } from "@auth/core"
|
||||
|
||||
export default function useSession() {
|
||||
return useState<Session | null>('session', () => null)
|
||||
return useState<Session | null>("session", () => null)
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ import type {
|
||||
SignInOptions,
|
||||
SignInAuthorizationParams,
|
||||
SignOutParams,
|
||||
} from './types'
|
||||
} from "./types"
|
||||
import type {
|
||||
BuiltInProviderType,
|
||||
RedirectableProviderType,
|
||||
} from '@auth/core/providers'
|
||||
} from "@auth/core/providers"
|
||||
|
||||
/**
|
||||
* Client-side method to initiate a signin flow
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { AuthHandler, AuthOptions, Session } from '@auth/core'
|
||||
import { fromNodeMiddleware, H3Event } from 'h3'
|
||||
import getURL from 'requrl'
|
||||
import { createMiddleware } from "@hattip/adapter-node";
|
||||
import { AuthHandler, AuthOptions, Session } from "@auth/core"
|
||||
import { fromNodeMiddleware, H3Event } from "h3"
|
||||
import getURL from "requrl"
|
||||
import { createMiddleware } from "@hattip/adapter-node"
|
||||
|
||||
export function NuxtAuthHandler (options: AuthOptions) {
|
||||
export function NuxtAuthHandler(options: AuthOptions) {
|
||||
async function handler(ctx: { request: Request }) {
|
||||
options.trustHost ??= true
|
||||
|
||||
@@ -24,7 +24,7 @@ export async function getSession(
|
||||
const headers = getRequestHeaders(event)
|
||||
const nodeHeaders = new Headers()
|
||||
|
||||
const url = new URL('/api/auth/session', getURL(event.node.req))
|
||||
const url = new URL("/api/auth/session", getURL(event.node.req))
|
||||
|
||||
Object.keys(headers).forEach((key) => {
|
||||
nodeHeaders.append(key, headers[key] as any)
|
||||
|
||||
@@ -1,42 +1,48 @@
|
||||
// Taken from next-auth/react
|
||||
import type { BuiltInProviderType, ProviderType } from '@auth/core/providers'
|
||||
import type { BuiltInProviderType, ProviderType } from "@auth/core/providers"
|
||||
/**
|
||||
* 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 declare type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);
|
||||
export declare type LiteralUnion<T extends U, U = string> =
|
||||
| T
|
||||
| (U & Record<never, never>)
|
||||
export interface ClientSafeProvider {
|
||||
id: LiteralUnion<BuiltInProviderType>;
|
||||
name: string;
|
||||
type: ProviderType;
|
||||
signinUrl: string;
|
||||
callbackUrl: string;
|
||||
id: LiteralUnion<BuiltInProviderType>
|
||||
name: string
|
||||
type: ProviderType
|
||||
signinUrl: string
|
||||
callbackUrl: string
|
||||
}
|
||||
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;
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
export interface SignInResponse {
|
||||
error: string | undefined;
|
||||
status: number;
|
||||
ok: boolean;
|
||||
url: string | null;
|
||||
error: string | undefined
|
||||
status: number
|
||||
ok: boolean
|
||||
url: string | null
|
||||
}
|
||||
/** Match `inputType` of `new URLSearchParams(inputType)` */
|
||||
export declare type SignInAuthorizationParams = string | string[][] | Record<string, string> | URLSearchParams;
|
||||
export declare type SignInAuthorizationParams =
|
||||
| string
|
||||
| string[][]
|
||||
| Record<string, string>
|
||||
| URLSearchParams
|
||||
/** [Documentation](https://next-auth.js.org/getting-started/client#using-the-redirect-false-option-1) */
|
||||
export interface SignOutResponse {
|
||||
url: string;
|
||||
url: string
|
||||
}
|
||||
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;
|
||||
/** [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
|
||||
}
|
||||
|
||||
@@ -4,14 +4,16 @@ export default defineNuxtConfig({
|
||||
secret: process.env.NEXTAUTH_SECRET,
|
||||
github: {
|
||||
clientId: process.env.GITHUB_CLIENT_ID,
|
||||
clientSecret: process.env.GITHUB_CLIENT_SECRET
|
||||
}
|
||||
clientSecret: process.env.GITHUB_CLIENT_SECRET,
|
||||
},
|
||||
},
|
||||
vite: {
|
||||
define: {
|
||||
'process.env.NEXTAUTH_URL': JSON.stringify(process.env.NEXTAUTH_URL),
|
||||
'process.env.AUTH_TRUST_HOST': JSON.stringify(process.env.AUTH_TRUST_HOST),
|
||||
'process.env.VERCEL_URL': JSON.stringify(process.env.VERCEL_URL),
|
||||
}
|
||||
}
|
||||
"process.env.NEXTAUTH_URL": JSON.stringify(process.env.NEXTAUTH_URL),
|
||||
"process.env.AUTH_TRUST_HOST": JSON.stringify(
|
||||
process.env.AUTH_TRUST_HOST
|
||||
),
|
||||
"process.env.VERCEL_URL": JSON.stringify(process.env.VERCEL_URL),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
<div>
|
||||
<h1>Nuxt Auth Example</h1>
|
||||
<p>
|
||||
This is an example site to demonstrate how to use <a href="https://v3.nuxtjs.org/">Nuxt 3</a> with <a href="https://authjs.dev/">Auth.js</a> for authentication.
|
||||
This is an example site to demonstrate how to use
|
||||
<a href="https://v3.nuxtjs.org/">Nuxt 3</a> with
|
||||
<a href="https://authjs.dev/">Auth.js</a> for authentication.
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
const session = useSession()
|
||||
|
||||
definePageMeta({
|
||||
middleware: 'auth'
|
||||
middleware: "auth",
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { Session } from '@auth/core'
|
||||
import { Session } from "@auth/core"
|
||||
|
||||
export default defineNuxtPlugin(async () => {
|
||||
const session = useSession()
|
||||
|
||||
addRouteMiddleware('auth', () => {
|
||||
if (!session.value) return navigateTo('/')
|
||||
addRouteMiddleware("auth", () => {
|
||||
if (!session.value) return navigateTo("/")
|
||||
})
|
||||
|
||||
if (process.server) {
|
||||
const data = await $fetch<Session>('/api/auth/session', {
|
||||
headers: useRequestHeaders() as any
|
||||
const data = await $fetch<Session>("/api/auth/session", {
|
||||
headers: useRequestHeaders() as any,
|
||||
})
|
||||
|
||||
|
||||
const hasSession = data && Object.keys(data).length
|
||||
|
||||
session.value = hasSession ? data : null
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { NuxtAuthHandler } from '@/lib/auth/server'
|
||||
import GithubProvider from '@auth/core/providers/github'
|
||||
import type { AuthOptions } from '@auth/core'
|
||||
import { NuxtAuthHandler } from "@/lib/auth/server"
|
||||
import GithubProvider from "@auth/core/providers/github"
|
||||
import type { AuthOptions } from "@auth/core"
|
||||
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
|
||||
@@ -9,9 +9,9 @@ export const authOptions: AuthOptions = {
|
||||
providers: [
|
||||
GithubProvider({
|
||||
clientId: runtimeConfig.github.clientId,
|
||||
clientSecret: runtimeConfig.github.clientSecret
|
||||
})
|
||||
]
|
||||
clientSecret: runtimeConfig.github.clientSecret,
|
||||
}),
|
||||
],
|
||||
}
|
||||
|
||||
export default NuxtAuthHandler(authOptions)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
// https://v3.nuxtjs.org/concepts/typescript
|
||||
"extends": "./.nuxt/tsconfig.json",
|
||||
"extends": "./.nuxt/tsconfig.json"
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
node_modules
|
||||
.docusaurus
|
||||
build
|
||||
.turbo
|
||||
static
|
||||
@@ -39,6 +39,8 @@ const docusaurusConfig = {
|
||||
apiKey: "97c0894508f2d1d4a2fef4fe6db28448",
|
||||
indexName: "next-auth",
|
||||
searchParameters: {},
|
||||
contextualSearch: false,
|
||||
externalUrlRegex: "authjs\\.dev|next-auth\\.js\\.org",
|
||||
},
|
||||
navbar: {
|
||||
title: "Auth.js",
|
||||
@@ -223,16 +225,75 @@ const docusaurusConfig = {
|
||||
}
|
||||
|
||||
docusaurusConfig.headTags = [
|
||||
{ tagName: "meta", attributes: { charSet: "utf-8" } },
|
||||
{ tagName: "link", attributes: { rel: "canonical", href: docusaurusConfig.url } },
|
||||
{ tagName: "meta", attributes: { property: "og:title", content: docusaurusConfig.title } },
|
||||
{ tagName: "meta", attributes: { property: "og:description", content: docusaurusConfig.tagline } },
|
||||
{ tagName: "meta", attributes: { property: "og:image", content: `${docusaurusConfig.url}/img/og-image.png` } },
|
||||
{ tagName: "meta", attributes: { property: "og:url", content: docusaurusConfig.url } },
|
||||
{ tagName: "meta", attributes: { name: "twitter:card", content: "summary_large_image" } },
|
||||
{ tagName: "meta", attributes: { name: "twitter:title", content: docusaurusConfig.title } },
|
||||
{ tagName: "meta", attributes: { name: "twitter:description", content: docusaurusConfig.tagline } },
|
||||
{ tagName: "meta", attributes: { name: "twitter:image", content: `${docusaurusConfig.url}/img/og-image.png` } },
|
||||
{
|
||||
tagName: "meta",
|
||||
attributes: {
|
||||
charSet: "utf-8",
|
||||
},
|
||||
},
|
||||
{
|
||||
tagName: "link",
|
||||
attributes: {
|
||||
rel: "canonical",
|
||||
href: docusaurusConfig.url,
|
||||
},
|
||||
},
|
||||
{
|
||||
tagName: "meta",
|
||||
attributes: {
|
||||
property: "og:title",
|
||||
content: docusaurusConfig.title,
|
||||
},
|
||||
},
|
||||
{
|
||||
tagName: "meta",
|
||||
attributes: {
|
||||
property: "og:description",
|
||||
content: docusaurusConfig.tagline,
|
||||
},
|
||||
},
|
||||
{
|
||||
tagName: "meta",
|
||||
attributes: {
|
||||
property: "og:image",
|
||||
content: `${docusaurusConfig.url}/img/og-image.png`,
|
||||
},
|
||||
},
|
||||
{
|
||||
tagName: "meta",
|
||||
attributes: {
|
||||
property: "og:url",
|
||||
content: docusaurusConfig.url,
|
||||
},
|
||||
},
|
||||
{
|
||||
tagName: "meta",
|
||||
attributes: {
|
||||
name: "twitter:card",
|
||||
content: "summary_large_image",
|
||||
},
|
||||
},
|
||||
{
|
||||
tagName: "meta",
|
||||
attributes: {
|
||||
name: "twitter:title",
|
||||
content: docusaurusConfig.title,
|
||||
},
|
||||
},
|
||||
{
|
||||
tagName: "meta",
|
||||
attributes: {
|
||||
name: "twitter:description",
|
||||
content: docusaurusConfig.tagline,
|
||||
},
|
||||
},
|
||||
{
|
||||
tagName: "meta",
|
||||
attributes: {
|
||||
name: "twitter:image",
|
||||
content: `${docusaurusConfig.url}/img/og-image.png`,
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
module.exports = docusaurusConfig
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
"deploy": "docusaurus deploy",
|
||||
"serve": "docusaurus serve",
|
||||
"clear": "docusaurus clear",
|
||||
"lint": "eslint .",
|
||||
"format": "prettier --write .",
|
||||
"providers": "node ./scripts/generate-providers",
|
||||
"snippets": "node ./scripts/generate-snippets"
|
||||
"providers": "node scripts/generate-providers.mjs",
|
||||
"snippets": "node scripts/generate-snippets.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@auth/core": "workspace:*",
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
const path = require("path")
|
||||
const fs = require("fs")
|
||||
|
||||
// TODO: generate from core package
|
||||
const providersPath = path.join(
|
||||
process.cwd(),
|
||||
"/docs/reference/05-oauth-providers"
|
||||
)
|
||||
|
||||
const files = fs.readdirSync(providersPath, "utf8")
|
||||
|
||||
const result = files.reduce((acc, file) => {
|
||||
if (file === "index.md" || file === "_category_.json") return acc
|
||||
const provider = fs.readFileSync(path.join(providersPath, file), "utf8")
|
||||
const { id, title } = provider.match(
|
||||
/id: (?<id>.+)\ntitle: (?<title>.+)\n/
|
||||
).groups
|
||||
acc[id] = title
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(process.cwd(), "providers.json"),
|
||||
JSON.stringify(result, null, 2)
|
||||
)
|
||||
22
docs/scripts/generate-providers.mjs
Normal file
22
docs/scripts/generate-providers.mjs
Normal file
@@ -0,0 +1,22 @@
|
||||
import { join } from "path"
|
||||
import { readdirSync, readFileSync, writeFileSync } from "fs"
|
||||
|
||||
// TODO: generate from core package
|
||||
const providersPath = join(process.cwd(), "/docs/reference/05-oauth-providers")
|
||||
|
||||
const files = readdirSync(providersPath, "utf8")
|
||||
|
||||
const result = files.reduce((acc, file) => {
|
||||
if (file === "index.md" || file === "_category_.json") return acc
|
||||
const provider = readFileSync(join(providersPath, file), "utf8")
|
||||
const { id, title } = provider.match(
|
||||
/id: (?<id>.+)\ntitle: (?<title>.+)\n/
|
||||
).groups
|
||||
acc[id] = title
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
writeFileSync(
|
||||
join(process.cwd(), "providers.json"),
|
||||
JSON.stringify(result, null, 2)
|
||||
)
|
||||
@@ -1,13 +1,13 @@
|
||||
const path = require("path")
|
||||
const fs = require("fs")
|
||||
import { join } from "path"
|
||||
import { readdirSync, readFileSync, writeFileSync } from "fs"
|
||||
|
||||
const snippetsPath = path.join(process.cwd(), "snippets")
|
||||
const snippetsPath = join(process.cwd(), "snippets")
|
||||
|
||||
const files = fs.readdirSync(snippetsPath, "utf8")
|
||||
const files = readdirSync(snippetsPath, "utf8")
|
||||
|
||||
const result = {}
|
||||
for (const file of files) {
|
||||
const snippet = fs.readFileSync(path.join(snippetsPath, file), "utf-8")
|
||||
const snippet = readFileSync(join(snippetsPath, file), "utf-8")
|
||||
const body = snippet
|
||||
.replace(/\n/g, "\n * ")
|
||||
.split("\n")
|
||||
@@ -25,7 +25,7 @@ for (const file of files) {
|
||||
}
|
||||
}
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(process.cwd(), "../.vscode/generated-snippets.code-snippets"),
|
||||
writeFileSync(
|
||||
join(process.cwd(), "../.vscode/generated-snippets.code-snippets"),
|
||||
JSON.stringify(result, null, 2)
|
||||
)
|
||||
@@ -1,4 +1,3 @@
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
import * as React from "react"
|
||||
import Link from "@docusaurus/Link"
|
||||
import useBaseUrl from "@docusaurus/useBaseUrl"
|
||||
|
||||
41
package.json
41
package.json
@@ -6,8 +6,6 @@
|
||||
"scripts": {
|
||||
"build:app": "turbo run build --filter=next-auth-app",
|
||||
"build": "turbo run build --filter=next-auth --filter=@next-auth/* --filter=@auth/* --no-deps",
|
||||
"lint": "turbo run lint --parallel",
|
||||
"format": "turbo run format --parallel",
|
||||
"test": "turbo run test --concurrency=1 --filter=[HEAD^1] --filter=./packages/* --filter=!*pouchdb-* --filter=!@*upstash* --filter=!*dynamodb-*",
|
||||
"clean": "turbo run clean --no-cache",
|
||||
"dev:db": "turbo run dev --parallel --continue --filter=next-auth-app...",
|
||||
@@ -15,44 +13,40 @@
|
||||
"dev:kit": "turbo run dev --parallel --continue --filter=sveltekit-nextauth...",
|
||||
"dev:docs": "turbo run dev --filter=docs",
|
||||
"email": "cd apps/dev && pnpm email",
|
||||
"eslint": "eslint --cache .",
|
||||
"lint": "prettier --check .",
|
||||
"format": "prettier --write .",
|
||||
"release": "release",
|
||||
"version:pr": "node ./config/version-pr"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@actions/core": "^1.6.0",
|
||||
"@balazsorban/monorepo-release": "0.1.1",
|
||||
"@actions/core": "^1.10.0",
|
||||
"@balazsorban/monorepo-release": "0.1.8",
|
||||
"@types/jest": "^28.1.3",
|
||||
"@types/node": "^17.0.25",
|
||||
"@typescript-eslint/eslint-plugin": "^5.10.2",
|
||||
"@typescript-eslint/parser": "^4.33.0",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"@typescript-eslint/eslint-plugin": "5.47.0",
|
||||
"@typescript-eslint/parser": "5.47.0",
|
||||
"eslint": "8.30.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-config-standard-with-typescript": "^21.0.1",
|
||||
"eslint-plugin-import": "^2.25.4",
|
||||
"eslint-plugin-jest": "^27.0.1",
|
||||
"eslint-plugin-jsdoc": "^39.6.4",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^6.0.0",
|
||||
"husky": "^7.0.4",
|
||||
"eslint-plugin-react": "^7.31.11",
|
||||
"eslint-plugin-svelte3": "^4.0.0",
|
||||
"prettier": "2.8.1",
|
||||
"pretty-quick": "^3.1.2",
|
||||
"semver": "7.3.5",
|
||||
"stream-to-array": "2.3.0",
|
||||
"ts-node": "10.5.0",
|
||||
"turbo": "1.3.1",
|
||||
"prettier-plugin-svelte": "^2.8.1",
|
||||
"turbo": "1.6.3",
|
||||
"typedoc": "^0.23.22",
|
||||
"typedoc-plugin-markdown": "^3.14.0",
|
||||
"typescript": "4.8.4"
|
||||
},
|
||||
"release": {
|
||||
"packageDirectories": [
|
||||
"packages"
|
||||
]
|
||||
"typescript": "4.9.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.19.0 || ^14.15.0 || ^16.13.0 || ^18.12.0"
|
||||
"node": "^16.13.0 || ^18.12.0"
|
||||
},
|
||||
"packageManager": "pnpm@7.13.3",
|
||||
"packageManager": "pnpm@7.19.0",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
@@ -68,7 +62,8 @@
|
||||
"undici": "5.11.0"
|
||||
},
|
||||
"patchedDependencies": {
|
||||
"typedoc-plugin-markdown@3.14.0": "patches/typedoc-plugin-markdown@3.14.0.patch"
|
||||
"typedoc-plugin-markdown@3.14.0": "patches/typedoc-plugin-markdown@3.14.0.patch",
|
||||
"@balazsorban/monorepo-release@0.1.8": "patches/@balazsorban__monorepo-release@0.1.8.patch"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["tests", "src"],
|
||||
"exclude": [
|
||||
"./*.js",
|
||||
"./*.d.ts",
|
||||
]
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["tests", "src"],
|
||||
"exclude": [
|
||||
"./*.js",
|
||||
"./*.d.ts",
|
||||
]
|
||||
}
|
||||
@@ -69,7 +69,7 @@ export const format = {
|
||||
const newObject: Record<string, unknown> = {}
|
||||
for (const key in object) {
|
||||
const value = object[key]
|
||||
if (value?.value && typeof value.value === 'string') {
|
||||
if (value?.value && typeof value.value === "string") {
|
||||
newObject[key] = new Date(value.value)
|
||||
} else {
|
||||
newObject[key] = value
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["tests", "src"],
|
||||
"exclude": [
|
||||
"./*.js",
|
||||
"./*.d.ts",
|
||||
]
|
||||
}
|
||||
@@ -250,12 +250,8 @@ export function FirestoreAdapter({
|
||||
const verificationTokenSnapshot = await getDoc(verificationTokenRef)
|
||||
|
||||
if (verificationTokenSnapshot.exists() && VerificationTokens.converter) {
|
||||
const {
|
||||
id,
|
||||
...verificationToken
|
||||
} = VerificationTokens.converter.fromFirestore(
|
||||
verificationTokenSnapshot
|
||||
)
|
||||
const { id, ...verificationToken } =
|
||||
VerificationTokens.converter.fromFirestore(verificationTokenSnapshot)
|
||||
|
||||
return verificationToken
|
||||
}
|
||||
@@ -274,12 +270,8 @@ export function FirestoreAdapter({
|
||||
if (verificationTokenSnapshot?.exists() && VerificationTokens.converter) {
|
||||
await deleteDoc(verificationTokenSnapshot.ref)
|
||||
|
||||
const {
|
||||
id,
|
||||
...verificationToken
|
||||
} = VerificationTokens.converter.fromFirestore(
|
||||
verificationTokenSnapshot
|
||||
)
|
||||
const { id, ...verificationToken } =
|
||||
VerificationTokens.converter.fromFirestore(verificationTokenSnapshot)
|
||||
|
||||
return verificationToken
|
||||
}
|
||||
|
||||
@@ -1,76 +1,117 @@
|
||||
import { runBasicTests } from "@next-auth/adapter-test"
|
||||
import { FirestoreAdapter } from "../src"
|
||||
|
||||
import { getFirestore, connectFirestoreEmulator, terminate, collection, query, where, limit, getDocs, getDoc, doc } from "firebase/firestore"
|
||||
import { initializeApp } from "firebase/app";
|
||||
import { getConverter } from "../src/converter";
|
||||
import type { AdapterSession, AdapterUser, VerificationToken } from "next-auth/adapters";
|
||||
import type { Account } from "next-auth";
|
||||
import {
|
||||
getFirestore,
|
||||
connectFirestoreEmulator,
|
||||
terminate,
|
||||
collection,
|
||||
query,
|
||||
where,
|
||||
limit,
|
||||
getDocs,
|
||||
getDoc,
|
||||
doc,
|
||||
} from "firebase/firestore"
|
||||
import { initializeApp } from "firebase/app"
|
||||
import { getConverter } from "../src/converter"
|
||||
import type {
|
||||
AdapterSession,
|
||||
AdapterUser,
|
||||
VerificationToken,
|
||||
} from "next-auth/adapters"
|
||||
import type { Account } from "next-auth"
|
||||
|
||||
const app = initializeApp({ projectId: "next-auth-test" });
|
||||
const firestore = getFirestore(app);
|
||||
const app = initializeApp({ projectId: "next-auth-test" })
|
||||
const firestore = getFirestore(app)
|
||||
|
||||
connectFirestoreEmulator(firestore, 'localhost', 8080);
|
||||
connectFirestoreEmulator(firestore, "localhost", 8080)
|
||||
|
||||
type IndexableObject = Record<string, unknown>;
|
||||
type IndexableObject = Record<string, unknown>
|
||||
|
||||
const Users = collection(firestore, 'users').withConverter(getConverter<AdapterUser & IndexableObject>());
|
||||
const Sessions = collection(firestore, 'sessions').withConverter(getConverter<AdapterSession & IndexableObject>());
|
||||
const Accounts = collection(firestore, 'accounts').withConverter(getConverter<Account>());
|
||||
const VerificationTokens = collection(firestore, 'verificationTokens').withConverter(getConverter<VerificationToken & IndexableObject>({ excludeId: true }));
|
||||
const Users = collection(firestore, "users").withConverter(
|
||||
getConverter<AdapterUser & IndexableObject>()
|
||||
)
|
||||
const Sessions = collection(firestore, "sessions").withConverter(
|
||||
getConverter<AdapterSession & IndexableObject>()
|
||||
)
|
||||
const Accounts = collection(firestore, "accounts").withConverter(
|
||||
getConverter<Account>()
|
||||
)
|
||||
const VerificationTokens = collection(
|
||||
firestore,
|
||||
"verificationTokens"
|
||||
).withConverter(
|
||||
getConverter<VerificationToken & IndexableObject>({ excludeId: true })
|
||||
)
|
||||
|
||||
runBasicTests({
|
||||
adapter: FirestoreAdapter({ projectId: "next-auth-test" }),
|
||||
db: {
|
||||
async disconnect() {
|
||||
await terminate(firestore);
|
||||
await terminate(firestore)
|
||||
},
|
||||
async session(sessionToken) {
|
||||
const snapshotQuery = query(Sessions, where("sessionToken", "==", sessionToken), limit(1));
|
||||
const snapshots = await getDocs(snapshotQuery);
|
||||
const snapshot = snapshots.docs[0];
|
||||
const snapshotQuery = query(
|
||||
Sessions,
|
||||
where("sessionToken", "==", sessionToken),
|
||||
limit(1)
|
||||
)
|
||||
const snapshots = await getDocs(snapshotQuery)
|
||||
const snapshot = snapshots.docs[0]
|
||||
|
||||
if (snapshot?.exists() && Sessions.converter) {
|
||||
const session = Sessions.converter.fromFirestore(snapshot);
|
||||
const session = Sessions.converter.fromFirestore(snapshot)
|
||||
|
||||
return session;
|
||||
return session
|
||||
}
|
||||
|
||||
return null;
|
||||
return null
|
||||
},
|
||||
async user(id) {
|
||||
const snapshot = await getDoc(doc(Users, id));
|
||||
const snapshot = await getDoc(doc(Users, id))
|
||||
|
||||
if (snapshot?.exists() && Users.converter) {
|
||||
const user = Users.converter.fromFirestore(snapshot);
|
||||
const user = Users.converter.fromFirestore(snapshot)
|
||||
|
||||
return user;
|
||||
return user
|
||||
}
|
||||
|
||||
return null;
|
||||
return null
|
||||
},
|
||||
async account({ provider, providerAccountId }) {
|
||||
const snapshotQuery = query(Accounts, where("provider", "==", provider), where("providerAccountId", "==", providerAccountId), limit(1));
|
||||
const snapshots = await getDocs(snapshotQuery);
|
||||
const snapshot = snapshots.docs[0];
|
||||
const snapshotQuery = query(
|
||||
Accounts,
|
||||
where("provider", "==", provider),
|
||||
where("providerAccountId", "==", providerAccountId),
|
||||
limit(1)
|
||||
)
|
||||
const snapshots = await getDocs(snapshotQuery)
|
||||
const snapshot = snapshots.docs[0]
|
||||
|
||||
if (snapshot?.exists() && Accounts.converter) {
|
||||
const account = Accounts.converter.fromFirestore(snapshot);
|
||||
const account = Accounts.converter.fromFirestore(snapshot)
|
||||
|
||||
return account;
|
||||
return account
|
||||
}
|
||||
|
||||
return null;
|
||||
return null
|
||||
},
|
||||
async verificationToken({ identifier, token }) {
|
||||
const snapshotQuery = query(VerificationTokens, where("identifier", "==", identifier), where("token", "==", token), limit(1));
|
||||
const snapshots = await getDocs(snapshotQuery);
|
||||
const snapshot = snapshots.docs[0];
|
||||
const snapshotQuery = query(
|
||||
VerificationTokens,
|
||||
where("identifier", "==", identifier),
|
||||
where("token", "==", token),
|
||||
limit(1)
|
||||
)
|
||||
const snapshots = await getDocs(snapshotQuery)
|
||||
const snapshot = snapshots.docs[0]
|
||||
|
||||
if (snapshot?.exists() && VerificationTokens.converter) {
|
||||
const verificationToken = VerificationTokens.converter.fromFirestore(snapshot);
|
||||
const verificationToken =
|
||||
VerificationTokens.converter.fromFirestore(snapshot)
|
||||
|
||||
return verificationToken;
|
||||
return verificationToken
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["tests", "src"],
|
||||
"exclude": [
|
||||
"./*.js",
|
||||
"./*.d.ts",
|
||||
]
|
||||
}
|
||||
@@ -1,28 +1,28 @@
|
||||
import { MikroORM, Options } from "@mikro-orm/core";
|
||||
import { SqliteDriver } from "@mikro-orm/sqlite";
|
||||
import { defaultEntities } from "../src";
|
||||
import { MikroORM, Options } from "@mikro-orm/core"
|
||||
import { SqliteDriver } from "@mikro-orm/sqlite"
|
||||
import { defaultEntities } from "../src"
|
||||
|
||||
const config: Options<SqliteDriver> = {
|
||||
dbName: "./db.sqlite",
|
||||
type: "sqlite",
|
||||
entities: [
|
||||
defaultEntities.User,
|
||||
defaultEntities.Account,
|
||||
defaultEntities.Session,
|
||||
defaultEntities.VerificationToken,
|
||||
],
|
||||
dbName: "./db.sqlite",
|
||||
type: "sqlite",
|
||||
entities: [
|
||||
defaultEntities.User,
|
||||
defaultEntities.Account,
|
||||
defaultEntities.Session,
|
||||
defaultEntities.VerificationToken,
|
||||
],
|
||||
}
|
||||
|
||||
it("run migrations", async () => {
|
||||
const orm = await MikroORM.init(config)
|
||||
await orm.getSchemaGenerator().dropSchema()
|
||||
const orm = await MikroORM.init(config)
|
||||
await orm.getSchemaGenerator().dropSchema()
|
||||
|
||||
const createSchemaSQL = await orm.getSchemaGenerator().getCreateSchemaSQL()
|
||||
expect(createSchemaSQL).toMatchSnapshot('createSchemaSQL')
|
||||
const createSchemaSQL = await orm.getSchemaGenerator().getCreateSchemaSQL()
|
||||
expect(createSchemaSQL).toMatchSnapshot("createSchemaSQL")
|
||||
|
||||
const targetSchema = await orm.getSchemaGenerator().getTargetSchema()
|
||||
expect(targetSchema).toMatchSnapshot('targetSchema')
|
||||
const targetSchema = await orm.getSchemaGenerator().getTargetSchema()
|
||||
expect(targetSchema).toMatchSnapshot("targetSchema")
|
||||
|
||||
await orm.getSchemaGenerator().dropSchema()
|
||||
await orm.close().catch(() => null)
|
||||
await orm.getSchemaGenerator().dropSchema()
|
||||
await orm.close().catch(() => null)
|
||||
})
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["tests", "src"],
|
||||
"exclude": [
|
||||
"./*.js",
|
||||
"./*.d.ts",
|
||||
]
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["tests", "src"],
|
||||
"exclude": [
|
||||
"./*.js",
|
||||
"./*.d.ts",
|
||||
]
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["tests", "src"],
|
||||
"exclude": [
|
||||
"./*.js",
|
||||
"./*.d.ts",
|
||||
]
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["tests", "src"],
|
||||
"exclude": [
|
||||
"./*.js",
|
||||
"./*.d.ts",
|
||||
]
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["tests", "src"],
|
||||
"exclude": [
|
||||
"./*.js",
|
||||
"./*.d.ts",
|
||||
]
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["tests", "src"],
|
||||
"exclude": [
|
||||
"./*.js",
|
||||
"./*.d.ts",
|
||||
]
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@next-auth/supabase-adapter",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.1",
|
||||
"description": "Supabase adapter for next-auth.",
|
||||
"homepage": "https://authjs.dev",
|
||||
"repository": "https://github.com/nextauthjs/next-auth",
|
||||
@@ -25,7 +25,7 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@supabase/supabase-js": "^2.0.5",
|
||||
"next-auth": "workspace:*"
|
||||
"next-auth": "^4.18.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@next-auth/adapter-test": "workspace:^0.0.0",
|
||||
@@ -37,4 +37,4 @@
|
||||
"jest": {
|
||||
"preset": "@next-auth/adapter-test/jest"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,4 +137,3 @@ export interface Database {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,17 +17,8 @@
|
||||
"@babel/preset-env": "^7.14.2",
|
||||
"@types/jest": "^26.0.23",
|
||||
"@types/nodemailer": "^6.4.4",
|
||||
"@typescript-eslint/eslint-plugin": "^4.24.0",
|
||||
"@typescript-eslint/parser": "^4.24.0",
|
||||
"eslint": "^7.27.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-config-standard-with-typescript": "^20.0.0",
|
||||
"eslint-plugin-import": "^2.23.3",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^5.1.0",
|
||||
"jest": "^27.0.3",
|
||||
"next-auth": "workspace:*",
|
||||
"prettier": "^2.3.0",
|
||||
"ts-jest": "^27.0.3",
|
||||
"typescript": "^4.2.4"
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["tests", "src"],
|
||||
"exclude": [
|
||||
"./*.js",
|
||||
"./*.d.ts",
|
||||
]
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["tests", "src"],
|
||||
"exclude": [
|
||||
"./*.js",
|
||||
"./*.d.ts",
|
||||
]
|
||||
}
|
||||
@@ -1,3 +1,24 @@
|
||||
# Auth.js
|
||||
<p align="center">
|
||||
<br/>
|
||||
<a href="https://authjs.dev" target="_blank"><img width="150px" src="https://authjs.dev/img/logo/logo-sm.png" /></a>
|
||||
<h3 align="center">Auth.js core library</a></h3>
|
||||
<h4 align="center">Authentication for the Web.</h4>
|
||||
<p align="center" style="align: center;">
|
||||
<a href="https://npm.im/next-auth">
|
||||
<img src="https://img.shields.io/badge/TypeScript-blue?style=flat-square" alt="TypeScript" />
|
||||
</a>
|
||||
<a href="https://npm.im/@auth/core">
|
||||
<img alt="npm" src="https://img.shields.io/npm/v/@auth/core?color=green&label=@auth/core&style=flat-square">
|
||||
</a>
|
||||
<a href="https://www.npmtrends.com/@auth/core">
|
||||
<img src="https://img.shields.io/npm/dm/@auth/core?label=%20downloads&style=flat-square" alt="Downloads" />
|
||||
</a>
|
||||
<a href="https://github.com/nextauthjs/next-auth/stargazers">
|
||||
<img src="https://img.shields.io/github/stars/nextauthjs/next-auth?style=flat-square" alt="Github Stars" />
|
||||
</a>
|
||||
</p>
|
||||
</p>
|
||||
|
||||
Authentication for the web.
|
||||
---
|
||||
|
||||
Check out the documentation at [authjs.dev](https://authjs.dev/reference/core/modules/main).
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
{
|
||||
"name": "@auth/core",
|
||||
"version": "0.2.0",
|
||||
"description": "Authentication for the web.",
|
||||
"version": "0.2.3",
|
||||
"description": "Authentication for the Web.",
|
||||
"keywords": [
|
||||
"authentication",
|
||||
"authjs",
|
||||
"jwt",
|
||||
"oauth",
|
||||
"oidc",
|
||||
"passwordless",
|
||||
"standard",
|
||||
"vanilla",
|
||||
"webapi"
|
||||
],
|
||||
"homepage": "https://authjs.dev",
|
||||
"repository": "https://github.com/nextauthjs/next-auth.git",
|
||||
"author": "Balázs Orbán <info@balazsorban.com>",
|
||||
@@ -69,8 +80,6 @@
|
||||
"build": "pnpm clean && pnpm css && tsc",
|
||||
"clean": "rm -rf *.js *.d.ts lib providers",
|
||||
"css": "node ./scripts/generate-css.js",
|
||||
"lint": "pnpm prettier --check src && eslint src",
|
||||
"format": "pnpm prettier --write . && eslint src --fix",
|
||||
"dev": "pnpm css && tsc -w"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -158,7 +158,6 @@ export async function Auth(
|
||||
*
|
||||
* const request = new Request("https://example.com")
|
||||
* const resposne = await AuthHandler(request, authConfig)
|
||||
*
|
||||
* ```
|
||||
*
|
||||
* @see [Initiailzation](https://authjs.dev/reference/configuration/auth-options)
|
||||
@@ -168,10 +167,8 @@ export interface AuthConfig {
|
||||
* List of authentication providers for signing in
|
||||
* (e.g. Google, Facebook, Twitter, GitHub, Email, etc) in any order.
|
||||
* This can be one of the built-in providers or an object with a custom provider.
|
||||
* * **Default value**: `[]`
|
||||
* * **Required**: *Yes*
|
||||
*
|
||||
* [Documentation](https://next-auth.js.org/configuration/options#providers) | [Providers documentation](https://next-auth.js.org/configuration/providers)
|
||||
* @default []
|
||||
*/
|
||||
providers: Provider[]
|
||||
/**
|
||||
@@ -181,36 +178,23 @@ export interface AuthConfig {
|
||||
*
|
||||
* On Unix systems: `openssl rand -hex 32`
|
||||
* Or go to https://generate-secret.vercel.app/32
|
||||
*
|
||||
* @default process.env.AUTH_SECRET ?? process.env.NEXTAUTH_SECRET
|
||||
*
|
||||
* [Documentation](https://next-auth.js.org/configuration/options#secret)
|
||||
*/
|
||||
secret?: string
|
||||
/**
|
||||
* Configure your session like if you want to use JWT or a database,
|
||||
* how long until an idle session expires, or to throttle write operations in case you are using a database.
|
||||
* * **Default value**: See the documentation page
|
||||
* * **Required**: No
|
||||
*
|
||||
* [Documentation](https://next-auth.js.org/configuration/options#session)
|
||||
*/
|
||||
session?: Partial<SessionOptions>
|
||||
/**
|
||||
* JSON Web Tokens are enabled by default if you have not specified an adapter.
|
||||
* JSON Web Tokens are enabled by default if you have not specified an {@link AuthConfig.adapter}.
|
||||
* JSON Web Tokens are encrypted (JWE) by default. We recommend you keep this behaviour.
|
||||
* * **Default value**: See the documentation page
|
||||
* * **Required**: *No*
|
||||
*
|
||||
* [Documentation](https://next-auth.js.org/configuration/options#jwt)
|
||||
*/
|
||||
jwt?: Partial<JWTOptions>
|
||||
/**
|
||||
* Specify URLs to be used if you want to create custom sign in, sign out and error pages.
|
||||
* Pages specified will override the corresponding built-in page.
|
||||
* * **Default value**: `{}`
|
||||
* * **Required**: *No*
|
||||
*
|
||||
* @default {}
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
@@ -222,18 +206,12 @@ export interface AuthConfig {
|
||||
* newUser: '/auth/new-user'
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* [Documentation](https://next-auth.js.org/configuration/options#pages) | [Pages documentation](https://next-auth.js.org/configuration/pages)
|
||||
*/
|
||||
pages?: Partial<PagesOptions>
|
||||
/**
|
||||
* Callbacks are asynchronous functions you can use to control what happens when an action is performed.
|
||||
* Callbacks are *extremely powerful*, especially in scenarios involving JSON Web Tokens
|
||||
* as they **allow you to implement access controls without a database** and to **integrate with external databases or APIs**.
|
||||
* * **Default value**: See the Callbacks documentation
|
||||
* * **Required**: *No*
|
||||
*
|
||||
* [Documentation](https://next-auth.js.org/configuration/options#callbacks) | [Callbacks documentation](https://next-auth.js.org/configuration/callbacks)
|
||||
*/
|
||||
callbacks?: Partial<CallbacksOptions>
|
||||
/**
|
||||
@@ -243,36 +221,23 @@ export interface AuthConfig {
|
||||
* (e.g. OAuth or Email authentication flow, JWT or database sessions, etc),
|
||||
* but typically contains a user object and/or contents of the JSON Web Token
|
||||
* and other information relevant to the event.
|
||||
* * **Default value**: `{}`
|
||||
* * **Required**: *No*
|
||||
*
|
||||
* [Documentation](https://next-auth.js.org/configuration/options#events) | [Events documentation](https://next-auth.js.org/configuration/events)
|
||||
* @default {}
|
||||
*/
|
||||
events?: Partial<EventCallbacks>
|
||||
/**
|
||||
* You can use the adapter option to pass in your database adapter.
|
||||
*
|
||||
* * **Required**: *No*
|
||||
*
|
||||
* [Documentation](https://next-auth.js.org/configuration/options#adapter) |
|
||||
* [Adapters Overview](https://next-auth.js.org/adapters/overview)
|
||||
*/
|
||||
/** You can use the adapter option to pass in your database adapter. */
|
||||
adapter?: Adapter
|
||||
/**
|
||||
* Set debug to true to enable debug messages for authentication and database operations.
|
||||
* * **Default value**: `false`
|
||||
* * **Required**: *No*
|
||||
*
|
||||
* - ⚠ If you added a custom `logger`, this setting is ignored.
|
||||
* - ⚠ If you added a custom {@link AuthConfig.logger}, this setting is ignored.
|
||||
*
|
||||
* [Documentation](https://next-auth.js.org/configuration/options#debug) | [Logger documentation](https://next-auth.js.org/configuration/options#logger)
|
||||
* @default false
|
||||
*/
|
||||
debug?: boolean
|
||||
/**
|
||||
* Override any of the logger levels (`undefined` levels will use the built-in logger),
|
||||
* and intercept logs in NextAuth. You can use this option to send NextAuth logs to a third-party logging service.
|
||||
* * **Default value**: `console`
|
||||
* * **Required**: *No*
|
||||
*
|
||||
* @example
|
||||
*
|
||||
@@ -294,36 +259,24 @@ export interface AuthConfig {
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* - ⚠ When set, the `debug` option is ignored
|
||||
* - ⚠ When set, the {@link AuthConfig.debug} option is ignored
|
||||
*
|
||||
* [Documentation](https://next-auth.js.org/configuration/options#logger) |
|
||||
* [Debug documentation](https://next-auth.js.org/configuration/options#debug)
|
||||
* @default console
|
||||
*/
|
||||
logger?: Partial<LoggerInstance>
|
||||
/**
|
||||
* Changes the theme of pages.
|
||||
* Set to `"light"` if you want to force pages to always be light.
|
||||
* Set to `"dark"` if you want to force pages to always be dark.
|
||||
* Set to `"auto"`, (or leave this option out)if you want the pages to follow the preferred system theme.
|
||||
* * **Default value**: `"auto"`
|
||||
* * **Required**: *No*
|
||||
*
|
||||
* [Documentation](https://next-auth.js.org/configuration/options#theme) | [Pages documentation]("https://next-auth.js.org/configuration/pages")
|
||||
*/
|
||||
/** Changes the theme of built-in {@link AuthConfig.pages}. */
|
||||
theme?: Theme
|
||||
/**
|
||||
* When set to `true` then all cookies set by NextAuth.js will only be accessible from HTTPS URLs.
|
||||
* This option defaults to `false` on URLs that start with `http://` (e.g. http://localhost:3000) for developer convenience.
|
||||
* You can manually set this option to `false` to disable this security feature and allow cookies
|
||||
* to be accessible from non-secured URLs (this is not recommended).
|
||||
* * **Default value**: `true` for HTTPS and `false` for HTTP sites
|
||||
* * **Required**: No
|
||||
*
|
||||
* [Documentation](https://next-auth.js.org/configuration/options#usesecurecookies)
|
||||
*
|
||||
* - ⚠ **This is an advanced option.** Advanced options are passed the same way as basic options,
|
||||
* but **may have complex implications** or side effects.
|
||||
* You should **try to avoid using advanced options** unless you are very comfortable using them.
|
||||
*
|
||||
* The default is `false` HTTP and `true` for HTTPS sites.
|
||||
*/
|
||||
useSecureCookies?: boolean
|
||||
/**
|
||||
@@ -333,25 +286,14 @@ export interface AuthConfig {
|
||||
* If you use this feature, you will likely want to create conditional behavior
|
||||
* to support setting different cookies policies in development and production builds,
|
||||
* as you will be opting out of the built-in dynamic policy.
|
||||
* * **Default value**: `{}`
|
||||
* * **Required**: No
|
||||
*
|
||||
* - ⚠ **This is an advanced option.** Advanced options are passed the same way as basic options,
|
||||
* but **may have complex implications** or side effects.
|
||||
* You should **try to avoid using advanced options** unless you are very comfortable using them.
|
||||
*
|
||||
* [Documentation](https://next-auth.js.org/configuration/options#cookies) | [Usage example](https://next-auth.js.org/configuration/options#example)
|
||||
* @default {}
|
||||
*/
|
||||
cookies?: Partial<CookiesOptions>
|
||||
/**
|
||||
* If set to `true`, NextAuth.js will use either the `x-forwarded-host` or `host` headers,
|
||||
* instead of `NEXTAUTH_URL`
|
||||
* Make sure that reading `x-forwarded-host` on your hosting platform can be trusted.
|
||||
* - ⚠ **This is an advanced option.** Advanced options are passed the same way as basic options,
|
||||
* but **may have complex implications** or side effects.
|
||||
* You should **try to avoid using advanced options** unless you are very comfortable using them.
|
||||
*
|
||||
* @default Boolean(process.env.NEXTAUTH_URL ?? process.env.AUTH_TRUST_HOST ?? process.env.VERCEL)
|
||||
*/
|
||||
/** @todo */
|
||||
trustHost?: boolean
|
||||
}
|
||||
|
||||
@@ -97,5 +97,5 @@ function normalizeEndpoint(
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||
for (const k in e.params) url.searchParams.set(k, e.params[k] as any)
|
||||
|
||||
return { url }
|
||||
return { ...e, url }
|
||||
}
|
||||
|
||||
@@ -146,6 +146,7 @@ export default function Twitter<
|
||||
id: "twitter",
|
||||
name: "Twitter",
|
||||
type: "oauth",
|
||||
checks: ["pkce", "state"],
|
||||
authorization: {
|
||||
url: "https://twitter.com/i/oauth2/authorize",
|
||||
params: { scope: "users.read tweet.read offline.access" },
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"watch": true,
|
||||
"emitDeclarationOnly": false
|
||||
},
|
||||
"watchOptions": {
|
||||
"excludeDirectories": ["jwt", "lib", "providers"],
|
||||
"excludeFiles": ["./*.d.ts", "./*.js"]
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": ["./*.js", "./*.d.ts"]
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
/build
|
||||
/.svelte-kit
|
||||
/package
|
||||
/index.*
|
||||
/client.*
|
||||
@@ -1,3 +1,24 @@
|
||||
# SvelteKit Auth
|
||||
<p align="center">
|
||||
<br/>
|
||||
<a href="https://authjs.dev" target="_blank"><img width="150px" src="https://authjs.dev/img/logo/logo-sm.png" /></a>
|
||||
<h3 align="center">SvelteKit Auth</a></h3>
|
||||
<h4 align="center">Authentication for SvelteKit.</h4>
|
||||
<p align="center" style="align: center;">
|
||||
<a href="https://npm.im/next-auth">
|
||||
<img src="https://img.shields.io/badge/TypeScript-blue?style=flat-square" alt="TypeScript" />
|
||||
</a>
|
||||
<a href="https://npm.im/@auth/sveltekit">
|
||||
<img alt="npm" src="https://img.shields.io/npm/v/@auth/sveltekit?color=green&label=@auth/sveltekit&style=flat-square">
|
||||
</a>
|
||||
<a href="https://www.npmtrends.com/@auth/sveltekit">
|
||||
<img src="https://img.shields.io/npm/dm/@auth/sveltekit?label=%20downloads&style=flat-square" alt="Downloads" />
|
||||
</a>
|
||||
<a href="https://github.com/nextauthjs/next-auth/stargazers">
|
||||
<img src="https://img.shields.io/github/stars/nextauthjs/next-auth?style=flat-square" alt="Github Stars" />
|
||||
</a>
|
||||
</p>
|
||||
</p>
|
||||
|
||||
Authentication for SvelteKit.
|
||||
---
|
||||
|
||||
Check out the documentation at [sveltekit.authjs.dev](https://sveltekit.authjs.dev).
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
{
|
||||
"name": "@auth/sveltekit",
|
||||
"version": "0.1.7",
|
||||
"version": "0.1.10",
|
||||
"description": "Authentication for SvelteKit.",
|
||||
"keywords": [
|
||||
"authentication",
|
||||
"authjs",
|
||||
"jwt",
|
||||
"sveltekit",
|
||||
"oauth",
|
||||
"oidc",
|
||||
"passwordless",
|
||||
"svelte"
|
||||
],
|
||||
"homepage": "https://sveltekit.authjs.dev",
|
||||
"repository": "https://github.com/nextauthjs/next-auth.git",
|
||||
"author": "Thang Huu Vu <hi@thvu.dev>",
|
||||
@@ -19,23 +29,14 @@
|
||||
"preview": "vite preview",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
"test:unit": "vitest",
|
||||
"lint": "prettier --plugin-search-dir . --check . && eslint .",
|
||||
"format": "prettier --plugin-search-dir . --write ."
|
||||
"test:unit": "vitest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.28.1",
|
||||
"@sveltejs/adapter-auto": "next",
|
||||
"@sveltejs/kit": "next",
|
||||
"@sveltejs/package": "1.0.0-next.6",
|
||||
"@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",
|
||||
"@sveltejs/adapter-auto": "^1.0.0",
|
||||
"@sveltejs/kit": "^1.0.0",
|
||||
"@sveltejs/package": "^1.0.0",
|
||||
"next-auth": "workspace:*",
|
||||
"prettier": "2.8.1",
|
||||
"prettier-plugin-svelte": "^2.8.1",
|
||||
"svelte": "^3.54.0",
|
||||
"svelte-check": "^2.9.2",
|
||||
"tslib": "^2.4.1",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module.exports = {
|
||||
plugins: [
|
||||
require('autoprefixer'),
|
||||
require('postcss-nested'),
|
||||
require('cssnano')({ preset: 'default' })
|
||||
]
|
||||
require("autoprefixer"),
|
||||
require("postcss-nested"),
|
||||
require("cssnano")({ preset: "default" }),
|
||||
],
|
||||
}
|
||||
|
||||
@@ -42,12 +42,11 @@
|
||||
"clean": "rm -rf coverage client css utils providers core jwt react next index.d.ts index.js adapters.d.ts middleware.d.ts middleware.js",
|
||||
"build:css": "postcss --config config/postcss.config.js src/**/*.css --base src --dir . && node config/wrap-css.js",
|
||||
"dev": "pnpm clean && pnpm generate-providers && concurrently \"pnpm watch:css\" \"pnpm watch:ts\"",
|
||||
"watch:ts": "pnpm tsc --project tsconfig.dev.json",
|
||||
"watch:ts": "pnpm tsc",
|
||||
"watch:css": "postcss --config config/postcss.config.js --watch src/**/*.css --base src --dir .",
|
||||
"test": "jest --config ./config/jest.config.js",
|
||||
"prepublishOnly": "pnpm build",
|
||||
"generate-providers": "node ./config/generate-providers.js",
|
||||
"lint": "eslint src config tests"
|
||||
"generate-providers": "node ./config/generate-providers.js"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
@@ -103,7 +102,7 @@
|
||||
"@testing-library/dom": "^8.13.0",
|
||||
"@testing-library/jest-dom": "^5.16.4",
|
||||
"@testing-library/react": "^13.3.0",
|
||||
"@testing-library/react-hooks": "^8.0.0",
|
||||
"@testing-library/react-hooks": "^8.0.1",
|
||||
"@testing-library/user-event": "^14.2.0",
|
||||
"@types/jest": "^28.1.3",
|
||||
"@types/node": "^17.0.42",
|
||||
@@ -120,7 +119,7 @@
|
||||
"jest-environment-jsdom": "^28.1.1",
|
||||
"jest-watch-typeahead": "^1.1.0",
|
||||
"msw": "^0.42.3",
|
||||
"next": "13.0.6",
|
||||
"next": "13.1.1",
|
||||
"postcss": "^8.4.14",
|
||||
"postcss-cli": "^9.1.0",
|
||||
"postcss-nested": "^5.0.6",
|
||||
@@ -131,4 +130,4 @@
|
||||
"engines": {
|
||||
"node": "^12.19.0 || ^14.15.0 || ^16.13.0 || ^18.12.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,11 +181,11 @@ export default async function callbackHandler(params: {
|
||||
? await getUserByEmail(profile.email)
|
||||
: null
|
||||
if (userByEmail) {
|
||||
const provider = options.provider as OAuthConfig<any>;
|
||||
const provider = options.provider as OAuthConfig<any>
|
||||
if (provider?.allowDangerousEmailAccountLinking) {
|
||||
// If you trust the oauth provider to correctly verify email addresses, you can opt-in to
|
||||
// If you trust the oauth provider to correctly verify email addresses, you can opt-in to
|
||||
// account linking even when the user is not signed-in.
|
||||
user = userByEmail;
|
||||
user = userByEmail
|
||||
} else {
|
||||
// We end up here when we don't have an account with the same [provider].id *BUT*
|
||||
// we do already have an account with the same email address as the one in the
|
||||
|
||||
@@ -114,7 +114,7 @@ export function defaultCookies(useSecureCookies: boolean): CookiesOptions {
|
||||
path: "/",
|
||||
secure: useSecureCookies,
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { Cookie } from "../cookie"
|
||||
|
||||
const NONCE_MAX_AGE = 60 * 15 // 15 minutes in seconds
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns nonce if the provider supports it
|
||||
* and saves it in a cookie */
|
||||
export async function createNonce(options: InternalOptions<"oauth">): Promise<
|
||||
@@ -62,7 +62,7 @@ export async function useNonce(
|
||||
return
|
||||
}
|
||||
|
||||
const value = (await jwt.decode({...options.jwt, token: nonce })) as any
|
||||
const value = (await jwt.decode({ ...options.jwt, token: nonce })) as any
|
||||
|
||||
return {
|
||||
value: value?.nonce ?? undefined,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export { default as callback } from './callback'
|
||||
export { default as signin } from './signin'
|
||||
export { default as signout } from './signout'
|
||||
export { default as session } from './session'
|
||||
export { default as providers } from './providers'
|
||||
export { default as callback } from "./callback"
|
||||
export { default as signin } from "./signin"
|
||||
export { default as signout } from "./signout"
|
||||
export { default as session } from "./session"
|
||||
export { default as providers } from "./providers"
|
||||
|
||||
@@ -4,7 +4,12 @@
|
||||
import fs from "fs"
|
||||
import path from "path"
|
||||
|
||||
const pathToCss = path.join(process.cwd(), process.env.NODE_ENV === "development" ? "node_modules/next-auth/css/index.css" : "/src/css/index.css")
|
||||
const pathToCss = path.join(
|
||||
process.cwd(),
|
||||
process.env.NODE_ENV === "development"
|
||||
? "node_modules/next-auth/css/index.css"
|
||||
: "/src/css/index.css"
|
||||
)
|
||||
|
||||
export default function css() {
|
||||
return fs.readFileSync(pathToCss, "utf8")
|
||||
|
||||
@@ -118,8 +118,9 @@ export default function Apple<P extends AppleProfile>(
|
||||
},
|
||||
checks: ["pkce"],
|
||||
style: {
|
||||
logo: 'https://raw.githubusercontent.com/nextauthjs/next-auth/main/packages/next-auth/provider-logos/apple.svg',
|
||||
logoDark: 'https://raw.githubusercontent.com/nextauthjs/next-auth/main/packages/next-auth/provider-logos/apple-dark.svg',
|
||||
logo: "https://raw.githubusercontent.com/nextauthjs/next-auth/main/packages/next-auth/provider-logos/apple.svg",
|
||||
logoDark:
|
||||
"https://raw.githubusercontent.com/nextauthjs/next-auth/main/packages/next-auth/provider-logos/apple-dark.svg",
|
||||
bg: "#fff",
|
||||
text: "#000",
|
||||
bgDark: "#000",
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -34,8 +34,9 @@ export default function LINE<P extends LineProfile>(
|
||||
id_token_signed_response_alg: "HS256",
|
||||
},
|
||||
style: {
|
||||
logo: 'https://raw.githubusercontent.com/nextauthjs/next-auth/main/packages/next-auth/provider-logos/line.svg',
|
||||
logoDark: 'https://raw.githubusercontent.com/nextauthjs/next-auth/main/packages/next-auth/provider-logos/line.svg',
|
||||
logo: "https://raw.githubusercontent.com/nextauthjs/next-auth/main/packages/next-auth/provider-logos/line.svg",
|
||||
logoDark:
|
||||
"https://raw.githubusercontent.com/nextauthjs/next-auth/main/packages/next-auth/provider-logos/line.svg",
|
||||
bg: "#fff",
|
||||
text: "#00C300",
|
||||
bgDark: "#00C300",
|
||||
|
||||
@@ -28,4 +28,4 @@ export default function UnitedEffects<P extends UnitedEffectsProfile>(
|
||||
},
|
||||
options,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"watch": true,
|
||||
"emitDeclarationOnly": false
|
||||
},
|
||||
"watchOptions": {
|
||||
"excludeDirectories": [
|
||||
"lib",
|
||||
"css",
|
||||
"jwt",
|
||||
"react",
|
||||
"next",
|
||||
"client",
|
||||
"providers",
|
||||
"core",
|
||||
"utils"
|
||||
],
|
||||
"excludeFiles": [
|
||||
"index.d.ts",
|
||||
"index.js",
|
||||
"adapters.d.ts",
|
||||
"middleware.d.ts",
|
||||
"middleware.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"types": ["@types/jest"],
|
||||
"typeRoots": ["./node_modules/@types"]
|
||||
},
|
||||
"exclude": ["./coverage", "./*.js", "./*.d.ts"]
|
||||
}
|
||||
@@ -4,6 +4,6 @@
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"esModuleInterop": true,
|
||||
"declaration": true,
|
||||
"skipLibCheck": true,
|
||||
"skipLibCheck": true
|
||||
}
|
||||
}
|
||||
|
||||
16
patches/@balazsorban__monorepo-release@0.1.8.patch
Normal file
16
patches/@balazsorban__monorepo-release@0.1.8.patch
Normal file
@@ -0,0 +1,16 @@
|
||||
diff --git a/dist/publish.js b/dist/publish.js
|
||||
index 1d39a76a5625a10637e3cf23f3a652441702cfb2..4b69b30645db1d1e84c8b6987a23b53c06f66438 100644
|
||||
--- a/dist/publish.js
|
||||
+++ b/dist/publish.js
|
||||
@@ -54,8 +54,9 @@ export async function publish(packages, options) {
|
||||
console.log(`Creating git tag...`);
|
||||
execSync(`git tag ${gitTag}`);
|
||||
execSync("git push --tags");
|
||||
- console.log(`Creating GitHub release notes...`);
|
||||
- execSync(`gh release create ${gitTag} --notes '${changelog}'`);
|
||||
+ const prerelease = name.startsWith("@auth") ? "--prerelease " : ""
|
||||
+ console.log(`Creating GitHub release notes${prerelease ? " (as prerelease)" : ""}...`);
|
||||
+ execSync(`gh release create ${gitTag} ${prerelease}--notes '${changelog}'`);
|
||||
}
|
||||
}
|
||||
console.log("Pushing commits");
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user