mirror of
https://github.com/SrIzan10/next-auth.git
synced 2026-05-01 10:55:20 +00:00
Compare commits
20 Commits
@auth/neo4
...
ndom91/web
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
307ca24cb8 | ||
|
|
b96f01319c | ||
|
|
8f416b68ec | ||
|
|
eaf5080721 | ||
|
|
e0b5f18c5b | ||
|
|
99247ce446 | ||
|
|
d6bc65f0d8 | ||
|
|
6f5a50313f | ||
|
|
e3bdb38df2 | ||
|
|
92a0fc42fa | ||
|
|
62e2ad115c | ||
|
|
542c35d729 | ||
|
|
5400645221 | ||
|
|
d739e8e04e | ||
|
|
c2eb9b3ad4 | ||
|
|
5e6b461908 | ||
|
|
2f7f9ccfe3 | ||
|
|
65ee6756bc | ||
|
|
963e407d5f | ||
|
|
4e294edec1 |
9
.github/version-pr/index.js
vendored
9
.github/version-pr/index.js
vendored
@@ -5,14 +5,15 @@ const core = require("@actions/core")
|
||||
try {
|
||||
const packageJSONPath = path.join(
|
||||
process.cwd(),
|
||||
"packages/next-auth/package.json"
|
||||
`packages/${process.env.PACKAGE_PATH || "next-auth"}/package.json`
|
||||
)
|
||||
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, "utf8"))
|
||||
|
||||
const sha8 = process.env.GITHUB_SHA.substring(0, 8)
|
||||
const prNumber = process.env.PR_NUMBER
|
||||
|
||||
const packageVersion = `0.0.0-pr.${prNumber}.${sha8}`
|
||||
const prefix = "0.0.0-"
|
||||
const pr = process.env.PR_NUMBER
|
||||
const source = pr ? `pr.${pr}` : "manual"
|
||||
const packageVersion = `${prefix}${source}.${sha8}`
|
||||
packageJSON.version = packageVersion
|
||||
core.setOutput("version", packageVersion)
|
||||
fs.writeFileSync(packageJSONPath, JSON.stringify(packageJSON))
|
||||
|
||||
49
.github/workflows/release.yml
vendored
49
.github/workflows/release.yml
vendored
@@ -8,6 +8,24 @@ on:
|
||||
- next
|
||||
- 3.x
|
||||
pull_request:
|
||||
# TODO: Support latest releases
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
name:
|
||||
type: choice
|
||||
description: Package name (npm)
|
||||
options:
|
||||
- "@auth/nextjs"
|
||||
- "@auth/core"
|
||||
- "next-auth"
|
||||
# TODO: Infer from package name
|
||||
path:
|
||||
type: choice
|
||||
description: Directory name (packages/*)
|
||||
options:
|
||||
- "frameworks-nextjs"
|
||||
- "core"
|
||||
- "next-auth"
|
||||
|
||||
jobs:
|
||||
test:
|
||||
@@ -122,3 +140,34 @@ jobs:
|
||||
env:
|
||||
VERSION: ${{ steps.determine-version.outputs.version }}
|
||||
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
||||
release-manual:
|
||||
name: Publish manually
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||
steps:
|
||||
- name: Init
|
||||
uses: actions/checkout@v3
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2.2.4
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
- name: Determine version
|
||||
uses: ./.github/version-pr
|
||||
id: determine-version
|
||||
env:
|
||||
PACKAGE_PATH: ${{ github.event.inputs.path }}
|
||||
- name: Publish to npm
|
||||
run: |
|
||||
cd packages/$PACKAGE_PATH
|
||||
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
|
||||
pnpm publish --no-git-checks --access public --tag experimental
|
||||
echo "🎉 Experimental release published 📦️ on npm: https://npmjs.com/package/${{ github.event.inputs.name }}/v/${{ env.VERSION }}"
|
||||
echo "Install via: pnpm add ${{ github.event.inputs.name }}@${{ env.VERSION }}"
|
||||
env:
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
PACKAGE_PATH: ${{ github.event.inputs.path }}
|
||||
VERSION: ${{ steps.determine-version.outputs.version }}
|
||||
|
||||
@@ -6,26 +6,24 @@ import Asgardeo from "@auth/core/providers/asgardeo"
|
||||
import Auth0 from "@auth/core/providers/auth0"
|
||||
import AzureAD from "@auth/core/providers/azure-ad"
|
||||
import AzureB2C from "@auth/core/providers/azure-ad-b2c"
|
||||
import BeyondIdentity from "@auth/core/providers/beyondidentity"
|
||||
import BoxyHQSAML from "@auth/core/providers/boxyhq-saml"
|
||||
// import Cognito from "@auth/core/providers/cognito"
|
||||
import Credentials from "@auth/core/providers/credentials"
|
||||
import Discord from "@auth/core/providers/discord"
|
||||
import DuendeIDS6 from "@auth/core/providers/duende-identity-server6"
|
||||
// import Discord from "@auth/core/providers/discord"
|
||||
// import DuendeIDS6 from "@auth/core/providers/duende-identity-server6"
|
||||
// import Email from "@auth/core/providers/email"
|
||||
import Facebook from "@auth/core/providers/facebook"
|
||||
import Foursquare from "@auth/core/providers/foursquare"
|
||||
import Freshbooks from "@auth/core/providers/freshbooks"
|
||||
import GitHub from "@auth/core/providers/github"
|
||||
import Gitlab from "@auth/core/providers/gitlab"
|
||||
import Google from "@auth/core/providers/google"
|
||||
// import Facebook from "@auth/core/providers/facebook"
|
||||
// import Foursquare from "@auth/core/providers/foursquare"
|
||||
// import Freshbooks from "@auth/core/providers/freshbooks"
|
||||
// import GitHub from "@auth/core/providers/github"
|
||||
// import Gitlab from "@auth/core/providers/gitlab"
|
||||
// import Google from "@auth/core/providers/google"
|
||||
// import IDS4 from "@auth/core/providers/identity-server4"
|
||||
import Instagram from "@auth/core/providers/instagram"
|
||||
// import Instagram from "@auth/core/providers/instagram"
|
||||
// import Keycloak from "@auth/core/providers/keycloak"
|
||||
import Line from "@auth/core/providers/line"
|
||||
import LinkedIn from "@auth/core/providers/linkedin"
|
||||
import Mailchimp from "@auth/core/providers/mailchimp"
|
||||
import Notion from "@auth/core/providers/notion"
|
||||
// import Line from "@auth/core/providers/line"
|
||||
// import LinkedIn from "@auth/core/providers/linkedin"
|
||||
// import Mailchimp from "@auth/core/providers/mailchimp"
|
||||
// import Okta from "@auth/core/providers/okta"
|
||||
import Osu from "@auth/core/providers/osu"
|
||||
import Patreon from "@auth/core/providers/patreon"
|
||||
@@ -77,12 +75,21 @@ export const authConfig: AuthConfig = {
|
||||
logo: "https://next-auth.js.org/img/logo/logo-sm.png",
|
||||
brandColor: "#1786fb",
|
||||
},
|
||||
pages: {
|
||||
signIn: "/auth/signin",
|
||||
},
|
||||
providers: [
|
||||
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: "" }
|
||||
// if (credentials.password !== "pw") return null
|
||||
return {
|
||||
name: "Fill Murray",
|
||||
email: "bill@fillmurray.com",
|
||||
image: "https://www.fillmurray.com/64/64",
|
||||
id: "1",
|
||||
foo: "",
|
||||
}
|
||||
},
|
||||
}),
|
||||
Apple({ clientId: process.env.APPLE_ID, clientSecret: process.env.APPLE_SECRET }),
|
||||
|
||||
196
apps/dev/nextjs/pages/auth/signin.js
Normal file
196
apps/dev/nextjs/pages/auth/signin.js
Normal file
@@ -0,0 +1,196 @@
|
||||
import { useEffect, useState } from "react"
|
||||
import "./style.css"
|
||||
|
||||
export default function() {
|
||||
const [email, setEmail] = useState("")
|
||||
const [name, setName] = useState("")
|
||||
const [credentialId, setCredentialId] = useState()
|
||||
const [challenge, setChallenge] = useState(new Uint8Array(32))
|
||||
const [loginResponse, setLoginResponse] = useState()
|
||||
|
||||
const isWebAuthnSupported = () => {
|
||||
return !!window.PublicKeyCredential
|
||||
}
|
||||
|
||||
const isPlatformAuthenticatorSupported = () => {
|
||||
if (!isWebAuthnSupported()) {
|
||||
throw new Error("WebAuthn API is not available")
|
||||
}
|
||||
|
||||
if (!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable) {
|
||||
return false
|
||||
} else {
|
||||
return PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
isPlatformAuthenticatorSupported()
|
||||
}, [])
|
||||
|
||||
const registerDevice = () => {
|
||||
const publicKey = {
|
||||
challenge,
|
||||
rp: {
|
||||
name: ".domino",
|
||||
icon: "https://next-auth.js.org/img/logo/logo-sm.png",
|
||||
},
|
||||
user: {
|
||||
id: new Uint8Array(16),
|
||||
name: email,
|
||||
displayName: name,
|
||||
},
|
||||
pubKeyCredParams: [
|
||||
{ type: "public-key", alg: -7 },
|
||||
{ type: "public-key", alg: -257 },
|
||||
],
|
||||
authenticatorSelection: {
|
||||
userVerification: "required",
|
||||
},
|
||||
status: "ok",
|
||||
}
|
||||
navigator.credentials
|
||||
.create({ publicKey })
|
||||
.then((newCredentialInfo) => {
|
||||
console.log("** REGISTRATION SUCCESS", newCredentialInfo)
|
||||
setCredentialId(newCredentialInfo.id)
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("FAIL", error)
|
||||
})
|
||||
}
|
||||
|
||||
const login = () => {
|
||||
const publicKey = {
|
||||
challenge: challenge,
|
||||
allowCredentials: [
|
||||
{ type: "public-key", id: Buffer.from(credentialId, "base64") },
|
||||
],
|
||||
userVerification: "required",
|
||||
status: "ok",
|
||||
}
|
||||
|
||||
navigator.credentials
|
||||
.get({ publicKey })
|
||||
.then((getAssertionResponse) => {
|
||||
console.log("** ASSERTION RECEIVED", getAssertionResponse)
|
||||
console.log(getAssertionResponse.response.authenticatorData.toString('base64'))
|
||||
console.log(getAssertionResponse.response.clientDataJSON.toString('base64'))
|
||||
console.log(getAssertionResponse.response.signature.toString('base64'))
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("FAIL", error)
|
||||
})
|
||||
}
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
position: "absolute",
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: "100vw",
|
||||
height: "100vh",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
gap: "2rem",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
marginTop: "10vh",
|
||||
backgroundColor: "#0d1117",
|
||||
padding: "3rem",
|
||||
borderRadius: "0.5rem",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
gap: "1rem",
|
||||
}}
|
||||
>
|
||||
<img src="https://next-auth.js.org/img/logo/logo-sm.png" width="64" />
|
||||
<div>WebAuthn Auth.js Demo</div>
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: "#0d1117",
|
||||
padding: "3rem",
|
||||
borderRadius: "0.5rem",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
gap: "1rem",
|
||||
maxWidth: "400px",
|
||||
}}
|
||||
>
|
||||
<h2 style={{ margin: "0" }}>Step 1</h2>
|
||||
|
||||
<label htmlFor="email">
|
||||
Email <span style={{ color: "red" }}>*</span>
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
name="email"
|
||||
placeholder="user@company.com"
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
value={email}
|
||||
/>
|
||||
<label htmlFor="displayName">
|
||||
Name <span style={{ color: "red" }}>*</span>
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
name="displayName"
|
||||
placeholder="Joe"
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
value={name}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => registerDevice()}
|
||||
disabled={!email || !name}
|
||||
>
|
||||
Register
|
||||
</button>
|
||||
{credentialId && (
|
||||
<pre
|
||||
style={{
|
||||
wordBreak: "break-all",
|
||||
wordWrap: "break-word",
|
||||
whiteSpace: "break-spaces",
|
||||
}}
|
||||
>
|
||||
Credential Id: {credentialId}
|
||||
</pre>
|
||||
)}
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: "#0d1117",
|
||||
padding: "3rem",
|
||||
borderRadius: "0.5rem",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
gap: "1rem",
|
||||
}}
|
||||
>
|
||||
<h2>Step 2</h2>
|
||||
<button type="button" onClick={() => login()} disabled={!credentialId}>
|
||||
Login
|
||||
</button>
|
||||
{loginResponse && (
|
||||
<pre
|
||||
style={{
|
||||
wordBreak: "break-all",
|
||||
wordWrap: "break-word",
|
||||
whiteSpace: "break-spaces",
|
||||
}}
|
||||
>
|
||||
Credential Id: {credentialId}
|
||||
</pre>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
50
apps/dev/nextjs/pages/auth/style.css
Normal file
50
apps/dev/nextjs/pages/auth/style.css
Normal file
@@ -0,0 +1,50 @@
|
||||
body {
|
||||
background-color: #161b22;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
button {
|
||||
margin: 0 0 0.75rem 0;
|
||||
padding: 0.75rem 2rem;
|
||||
color: white;
|
||||
background-color: orange;
|
||||
font-size: 1.1rem;
|
||||
border-color: rgba(0, 0, 0, 0.1);
|
||||
border-radius: 0.5rem;
|
||||
transition: all 0.1s ease-in-out;
|
||||
font-weight: 900;
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
button:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
button:active {
|
||||
cursor: pointer;
|
||||
}
|
||||
button:disabled {
|
||||
filter: grayscale(0.9);
|
||||
}
|
||||
button:disabled:hover {
|
||||
cursor: auto !important;
|
||||
}
|
||||
|
||||
label {
|
||||
text-align: left;
|
||||
}
|
||||
input {
|
||||
box-sizing: border-box;
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 0.5rem 1rem;
|
||||
border: 1px solid #555;
|
||||
background: white;
|
||||
font-size: 1rem;
|
||||
border-radius: 0.5rem;
|
||||
color: black;
|
||||
}
|
||||
input:focus {
|
||||
box-shadow: none;
|
||||
}
|
||||
@@ -269,7 +269,7 @@ Ultimately if your request is not accepted or is not actively in development, yo
|
||||
</summary>
|
||||
<p>
|
||||
|
||||
Auth.js by default uses JSON Web Tokens for saving the user's session. However, if you use a [database adapter](/guides/adapters/using-a-database-adapter), the database will be used to persist the user's session. You can force the usage of JWT when using a database [through the configuration options](/reference/configuration/auth-config#session). Since v4 all our JWT tokens are now encrypted by default with A256GCM.
|
||||
Auth.js by default uses JSON Web Tokens for saving the user's session. However, if you use a [database adapter](/guides/adapters/using-a-database-adapter), the database will be used to persist the user's session. You can force the usage of JWT when using a database [through the configuration options](/reference/configuration/auth-config#session). Since v4 all our JWTs are now encrypted by default with A256GCM.
|
||||
|
||||
</p>
|
||||
</details>
|
||||
|
||||
@@ -29,7 +29,7 @@ Sent when the user signs out.
|
||||
|
||||
The message object will contain one of these depending on if you use JWT or database persisted sessions:
|
||||
|
||||
- `token`: The JWT token for this session.
|
||||
- `token`: The JWT for this session.
|
||||
- `session`: The session object from your adapter that is being ended
|
||||
|
||||
### createUser
|
||||
@@ -60,5 +60,5 @@ Sent at the end of a request for the current session.
|
||||
|
||||
The message object will contain one of these depending on if you use JWT or database persisted sessions:
|
||||
|
||||
- `token`: The JWT token for this session.
|
||||
- `token`: The JWT for this session.
|
||||
- `session`: The session object from your adapter.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
title: Overview
|
||||
---
|
||||
|
||||
Using a Auth.js / NextAuth.js adapter you can connect to any database service or even several different services at the same time. The following listed official adapters are created and maintained by the community:
|
||||
Using an Auth.js / NextAuth.js adapter you can connect to any database service or even several different services at the same time. The following listed official adapters are created and maintained by the community:
|
||||
|
||||
<div class="adapter-card-list">
|
||||
<a href="/reference/adapter/dgraph" class="adapter-card">
|
||||
@@ -71,7 +71,7 @@ If you don't find an adapter for the database or service you use, you can always
|
||||
## Models
|
||||
|
||||
|
||||
Auth.js can be used with any database. Models tell you what structures Auth.js expects from your database. Models will vary slightly depending on which adapter you use, but in general, will look something like this. Each adapter's model/schema will be slightly adapted for its needs, but will look very much like this schema below:
|
||||
Auth.js can be used with any database. Models tell you what structures Auth.js expects from your database. Models will vary slightly depending on which adapter you use, but in general, will look something like this:
|
||||
|
||||
```mermaid
|
||||
erDiagram
|
||||
@@ -96,15 +96,8 @@ erDiagram
|
||||
string type
|
||||
string provider
|
||||
string providerAccountId
|
||||
string refresh_token
|
||||
string access_token
|
||||
int expires_at
|
||||
string token_type
|
||||
string scope
|
||||
string id_token
|
||||
string session_state
|
||||
string oauth_token_secret
|
||||
string oauth_token
|
||||
}
|
||||
VerificationToken {
|
||||
string identifier
|
||||
@@ -113,10 +106,10 @@ erDiagram
|
||||
}
|
||||
```
|
||||
|
||||
More information about each Model / Table can be found below.
|
||||
More information about each Model/Table can be found below.
|
||||
|
||||
:::note
|
||||
You can [create your own adapter](/guides/adapters/creating-a-database-adapter) if you want to use Auth.js with a database that is not supported out of the box, or you have to change fields on any of the models.
|
||||
You can [create your adapter](/guides/adapters/creating-a-database-adapter) if you want to use Auth.js with a database that is not supported out of the box, or you have to change fields on any of the models.
|
||||
:::
|
||||
|
||||
---
|
||||
@@ -125,30 +118,31 @@ You can [create your own adapter](/guides/adapters/creating-a-database-adapter)
|
||||
|
||||
The User model is for information such as the user's name and email address.
|
||||
|
||||
Email address is optional, but if one is specified for a User then it must be unique.
|
||||
Email address is optional, but if one is specified for a User, then it must be unique.
|
||||
|
||||
:::note
|
||||
If a user first signs in with OAuth then their email address is automatically populated using the one from their OAuth profile, if the OAuth provider returns one.
|
||||
If a user first signs in with an OAuth provider, then their email address is automatically populated using the one from their OAuth profile if the OAuth provider returns one.
|
||||
|
||||
This provides a way to contact users and for users to maintain access to their account and sign in using email in the event they are unable to sign in with the OAuth provider in future (if the [Email Provider](/getting-started/email-tutorial) is configured).
|
||||
This provides a way to contact users and for users to maintain access to their account and sign in using email in the event they are unable to sign in with the OAuth provider in the future (if the [Email Provider](/reference/core/providers_email) is configured).
|
||||
:::
|
||||
|
||||
User creation in the database is automatic, and happens when the user is logging in for the first time with a provider. The default data saved is `id`, `name`, `email` and `image`. You can add more profile data by returning extra fields in your [OAuth provider](/guides/providers/custom-provider)'s [`profile()`](/reference/core/providers#profile) callback.
|
||||
User creation in the database is automatic and happens when the user is logging in for the first time with a provider.
|
||||
If the first sign-in is via the [OAuth Provider](/reference/core/providers_oauth), the default data saved is `id`, `name`, `email` and `image`. You can add more profile data by returning extra fields in your [OAuth provider](/guides/providers/custom-provider)'s [`profile()`](/reference/core/providers#profile) callback.
|
||||
|
||||
If the first sign-in is via the [Email Provider](/reference/core/providers_email), then the saved user will have `id`, `email`, `emailVerified`, where `emailVerified` is the timestamp of when the user was created.
|
||||
|
||||
### Account
|
||||
|
||||
The Account model is for information about OAuth accounts associated with a User. It will usually contain `access_token`, `id_token` and other OAuth specific data. [`TokenSet`](https://github.com/panva/node-openid-client/blob/main/docs/README.md#new-tokensetinput) from `openid-client` might give you an idea of all the fields.
|
||||
|
||||
:::note
|
||||
In case of an OAuth 1.0 provider (like Twitter), you will have to look for `oauth_token` and `oauth_token_secret` string fields. GitHub also has an extra `refresh_token_expires_in` integer field. You have to make sure that your database schema includes these fields.
|
||||
:::
|
||||
The Account model is for information about OAuth accounts associated with a User
|
||||
|
||||
A single User can have multiple Accounts, but each Account can only have one User.
|
||||
|
||||
Linking Accounts to Users happen automatically, only when they have the same e-mail address, and the user is currently signed in. Check the [FAQ](/concepts/faq#security) for more information why this is a requirement.
|
||||
Account creation in the database is automatic and happens when the user is logging in for the first time with a provider, or the [`Adapter.linkAccount`](/reference/core/adapters#linkaccount) method is invoked. The default data saved is `access_token`, `refresh_token`, `id_token` and `expires_at`. You can save other fields by returning them in the [OAuth provider](/guides/providers/custom-provider)'s [`account()`](/reference/core/providers#account) callback.
|
||||
|
||||
Linking Accounts to Users happen automatically, only when they have the same e-mail address, and the user is currently signed in. Check the [FAQ](/concepts/faq#security) for more information on why this is a requirement.
|
||||
|
||||
:::tip
|
||||
You can manually unlink accounts, if your adapter implements the `unlinkAccount` method. Make sure to take all the necessary security steps to avoid data loss.
|
||||
You can manually unlink accounts if your adapter implements the `unlinkAccount` method. Make sure to take all the necessary security steps to avoid data loss.
|
||||
:::
|
||||
|
||||
:::note
|
||||
@@ -162,7 +156,7 @@ The Session model is used for database sessions. It is not used if JSON Web Toke
|
||||
A single User can have multiple Sessions, each Session can only have one User.
|
||||
|
||||
:::tip
|
||||
When a Session is read, we check if it's `expires` field indicates an invalid session, and delete it from the database. You can also do this clean-up periodically in the background to avoid our extra delete call to the database during an active session retrieval. This might result in a slight performance increase in a few cases.
|
||||
When a Session is read, we check if its `expires` field indicates an invalid session, and delete it from the database. You can also do this clean-up periodically in the background to avoid our extra delete call to the database during an active session retrieval. This might result in a slight performance increase in a few cases.
|
||||
:::
|
||||
|
||||
### Verification Token
|
||||
@@ -171,7 +165,7 @@ The Verification Token model is used to store tokens for passwordless sign in.
|
||||
|
||||
A single User can have multiple open Verification Tokens (e.g. to sign in to different devices).
|
||||
|
||||
It has been designed to be extendable for other verification purposes in the future (e.g. 2FA / short codes).
|
||||
It has been designed to be extendable for other verification purposes in the future (e.g. 2FA / magic codes, etc.).
|
||||
|
||||
:::note
|
||||
Auth.js makes sure that every token is usable only once, and by default has a short (1 day, can be configured by [`maxAge`](/guides/providers/email)) lifetime. If your user did not manage to finish the sign-in flow in time, they will have to start the sign-in process again.
|
||||
@@ -183,8 +177,7 @@ Due to users forgetting or failing at the sign-in flow, you might end up with un
|
||||
|
||||
## RDBMS Naming Convention
|
||||
|
||||
Auth.js / NextAuth.js uses `camelCase` for its own database rows, while respecting the conventional `snake_case` formatting for OAuth related values. If mixed casing is an issue for you, most adapters have a dedicated section on how to use a single naming convention.
|
||||
|
||||
Auth.js / NextAuth.js uses `camelCase` for its database rows while respecting the conventional `snake_case` formatting for OAuth-related values. If the mixed casing is an issue for you, most adapters have a dedicated documentation section on how to force a casing convention.
|
||||
|
||||
## TypeScript
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ const path = require("path")
|
||||
const coreSrc = "../packages/core/src"
|
||||
const providers = fs
|
||||
.readdirSync(path.join(__dirname, coreSrc, "/providers"))
|
||||
.filter((file) => file.endsWith(".ts") && !file.startsWith("oauth"))
|
||||
.filter((file) => file.endsWith(".ts"))
|
||||
.map((p) => `${coreSrc}/providers/${p}`)
|
||||
|
||||
const typedocConfig = require("./typedoc.json")
|
||||
|
||||
@@ -42,8 +42,6 @@ import type { Adapter, AdapterAccount } from "next-auth/adapters"
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* ## Advanced usage
|
||||
*
|
||||
* ### Create the Prisma schema from scratch
|
||||
*
|
||||
* You need to use at least Prisma 2.26.0. Create a schema file in `prisma/schema.prisma` similar to this one:
|
||||
|
||||
@@ -228,6 +228,10 @@ export interface Adapter {
|
||||
deleteUser?(
|
||||
userId: string
|
||||
): Promise<void> | Awaitable<AdapterUser | null | undefined>
|
||||
/**
|
||||
* This method is invoked internally (but optionally can be used for manual linking).
|
||||
* It creates an [Account](https://authjs.dev/reference/adapters#models) in the database.
|
||||
*/
|
||||
linkAccount?(
|
||||
account: AdapterAccount
|
||||
): Promise<void> | Awaitable<AdapterAccount | null | undefined>
|
||||
|
||||
@@ -20,13 +20,6 @@ export class AuthError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo
|
||||
* Thrown when an Email address is already associated with an account
|
||||
* but the user is trying an OAuth account that is not linked to it.
|
||||
*/
|
||||
export class AccountNotLinked extends AuthError {}
|
||||
|
||||
/**
|
||||
* @todo
|
||||
* One of the database `Adapter` methods failed.
|
||||
@@ -37,8 +30,8 @@ export class AdapterError extends AuthError {}
|
||||
export class AuthorizedCallbackError extends AuthError {}
|
||||
|
||||
/**
|
||||
* There was an error while trying to finish up authenticating the user.
|
||||
* Depending on the type of provider, this could be for multiple reasons.
|
||||
* This error occurs when the user cannot finish the sign-in process.
|
||||
* Depending on the provider type, this could have happened for multiple reasons.
|
||||
*
|
||||
* :::tip
|
||||
* Check out `[auth][details]` in the error message to know which provider failed.
|
||||
@@ -48,7 +41,7 @@ export class AuthorizedCallbackError extends AuthError {}
|
||||
* ```
|
||||
* :::
|
||||
*
|
||||
* For an **OAuth provider**, possible causes are:
|
||||
* For an [OAuth provider](https://authjs.dev/reference/core/providers_oauth), possible causes are:
|
||||
* - The user denied access to the application
|
||||
* - There was an error parsing the OAuth Profile:
|
||||
* Check out the provider's `profile` or `userinfo.request` method to make sure
|
||||
@@ -56,7 +49,7 @@ export class AuthorizedCallbackError extends AuthError {}
|
||||
* - The `signIn` or `jwt` callback methods threw an uncaught error:
|
||||
* Check the callback method implementations.
|
||||
*
|
||||
* For an **Email provider**, possible causes are:
|
||||
* For an [Email provider](https://authjs.dev/reference/core/providers_email), possible causes are:
|
||||
* - The provided email/token combination was invalid/missing:
|
||||
* Check if the provider's `sendVerificationRequest` method correctly sends the email.
|
||||
* - The provided email/token combination has expired:
|
||||
@@ -64,7 +57,7 @@ export class AuthorizedCallbackError extends AuthError {}
|
||||
* - There was an error with the database:
|
||||
* Check the database logs.
|
||||
*
|
||||
* For a **Credentials provider**, possible causes are:
|
||||
* For a [Credentials provider](https://authjs.dev/reference/core/providers_credentials), possible causes are:
|
||||
* - The `authorize` method threw an uncaught error:
|
||||
* Check the provider's `authorize` method.
|
||||
* - The `signIn` or `jwt` callback methods threw an uncaught error:
|
||||
@@ -107,31 +100,87 @@ export class MissingAPIRoute extends AuthError {}
|
||||
/** @todo */
|
||||
export class MissingAuthorize extends AuthError {}
|
||||
|
||||
/** @todo */
|
||||
/**
|
||||
* Auth.js requires a secret to be set, but none was not found. This is used to encrypt cookies, JWTs and other sensitive data.
|
||||
*
|
||||
* :::note
|
||||
* If you are using a framework like Next.js, we try to automatically infer the secret from the `AUTH_SECRET` environment variable.
|
||||
* Alternatively, you can also explicitly set the [`AuthConfig.secret`](https://authjs.dev/reference/core#secret).
|
||||
* :::
|
||||
*
|
||||
*
|
||||
* :::tip
|
||||
* You can generate a good secret value:
|
||||
* - On Unix systems: type `openssl rand -hex 32` in the terminal
|
||||
* - Or generate one [online](https://generate-secret.vercel.app/32)
|
||||
*
|
||||
* :::
|
||||
*/
|
||||
export class MissingSecret extends AuthError {}
|
||||
|
||||
/** @todo */
|
||||
export class OAuthSignInError extends AuthError {}
|
||||
/**
|
||||
* @todo
|
||||
* Thrown when an Email address is already associated with an account
|
||||
* but the user is trying an OAuth account that is not linked to it.
|
||||
*/
|
||||
export class OAuthAccountNotLinked extends AuthError {}
|
||||
|
||||
/** @todo */
|
||||
/**
|
||||
* Thrown when an OAuth provider returns an error during the sign in process.
|
||||
* This could happen for example if the user denied access to the application or there was a configuration error.
|
||||
*
|
||||
* For a full list of possible reasons, check out the specification [Authorization Code Grant: Error Response](https://www.rfc-editor.org/rfc/rfc6749#section-4.1.2.1)
|
||||
*/
|
||||
export class OAuthCallbackError extends AuthError {}
|
||||
|
||||
/** @todo */
|
||||
export class OAuthCreateUserError extends AuthError {}
|
||||
|
||||
/** @todo */
|
||||
/**
|
||||
* This error occurs during an OAuth sign in attempt when the provdier's
|
||||
* response could not be parsed. This could for example happen if the provider's API
|
||||
* changed, or the [`OAuth2Config.profile`](https://authjs.dev/reference/core/providers_oauth#profile) method is not implemented correctly.
|
||||
*/
|
||||
export class OAuthProfileParseError extends AuthError {}
|
||||
|
||||
/** @todo */
|
||||
export class SessionTokenError extends AuthError {}
|
||||
|
||||
/** @todo */
|
||||
/**
|
||||
* This error occurs when the user cannot initiate the sign-in process.
|
||||
* Depending on the provider type, this could have happened for multiple reasons.
|
||||
*
|
||||
* :::tip
|
||||
* Check out `[auth][details]` in the error message to know which provider failed.
|
||||
* @example
|
||||
* ```sh
|
||||
* [auth][details]: { "provider": "github" }
|
||||
* ```
|
||||
* :::
|
||||
*
|
||||
* For an [OAuth provider](https://authjs.dev/reference/core/providers_oauth), possible causes are:
|
||||
* - The Authorization Server is not compliant with the [OAuth 2.0 specifcation](https://www.ietf.org/rfc/rfc6749.html)
|
||||
* Check the details in the error message.
|
||||
* - A runtime error occurred in Auth.js. This should be reported as a bug.
|
||||
*
|
||||
* For an [Email provider](https://authjs.dev/reference/core/providers_email), possible causes are:
|
||||
* - The email sent from the client is invalid, could not be normalized by [`EmailConfig.normalizeIdentifier`](https://authjs.dev/reference/core/providers_email#normalizeidentifier)
|
||||
* - The provided email/token combination has expired:
|
||||
* Ask the user to log in again.
|
||||
* - There was an error with the database:
|
||||
* Check the database logs.
|
||||
*
|
||||
*/
|
||||
export class SignInError extends AuthError {}
|
||||
|
||||
/** @todo */
|
||||
export class SignOutError extends AuthError {}
|
||||
|
||||
/** @todo */
|
||||
/**
|
||||
* Auth.js was requested to handle an operation that it does not support.
|
||||
*
|
||||
* See [`AuthAction`](https://authjs.dev/reference/core/types#authaction) for the supported actions.
|
||||
*/
|
||||
export class UnknownAction extends AuthError {}
|
||||
|
||||
/** @todo */
|
||||
|
||||
@@ -190,7 +190,7 @@ export interface JWTEncodeParams<Payload = JWT> {
|
||||
/**
|
||||
* The maximum age of the Auth.js issued JWT in seconds.
|
||||
*
|
||||
* @default 30 * 24 * 30 * 60 // 30 days
|
||||
* @default 30 * 24 * 60 * 60 // 30 days
|
||||
*/
|
||||
maxAge?: number
|
||||
}
|
||||
@@ -213,7 +213,7 @@ export interface JWTOptions {
|
||||
/**
|
||||
* The maximum age of the Auth.js issued JWT in seconds.
|
||||
*
|
||||
* @default 30 * 24 * 30 * 60 // 30 days
|
||||
* @default 30 * 24 * 60 * 60 // 30 days
|
||||
*/
|
||||
maxAge: number
|
||||
/** Override this method to control the Auth.js issued JWT encoding. */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AccountNotLinked } from "../errors.js"
|
||||
import { OAuthAccountNotLinked } from "../errors.js"
|
||||
import { fromDate } from "./utils/date.js"
|
||||
|
||||
import type {
|
||||
@@ -49,7 +49,7 @@ export async function handleLogin(
|
||||
}
|
||||
|
||||
const profile = _profile as AdapterUser
|
||||
const account = _account as AdapterAccount
|
||||
let account = _account as AdapterAccount
|
||||
|
||||
const {
|
||||
createUser,
|
||||
@@ -122,113 +122,116 @@ export async function handleLogin(
|
||||
})
|
||||
|
||||
return { session, user, isNewUser }
|
||||
} else if (account.type === "oauth" || account.type === "oidc") {
|
||||
// If signing in with OAuth account, check to see if the account exists already
|
||||
const userByAccount = await getUserByAccount({
|
||||
providerAccountId: account.providerAccountId,
|
||||
provider: account.provider,
|
||||
})
|
||||
if (userByAccount) {
|
||||
if (user) {
|
||||
// If the user is already signed in with this account, we don't need to do anything
|
||||
if (userByAccount.id === user.id) {
|
||||
return { session, user, isNewUser }
|
||||
}
|
||||
// If the user is currently signed in, but the new account they are signing in
|
||||
// with is already associated with another user, then we cannot link them
|
||||
// and need to return an error.
|
||||
throw new AccountNotLinked(
|
||||
"The account is already associated with another user",
|
||||
{ provider: account.provider }
|
||||
)
|
||||
}
|
||||
// If there is no active session, but the account being signed in with is already
|
||||
// associated with a valid user then create session to sign the user in.
|
||||
session = useJwtSession
|
||||
? {}
|
||||
: await createSession({
|
||||
sessionToken: generateSessionToken(),
|
||||
userId: userByAccount.id,
|
||||
expires: fromDate(options.session.maxAge),
|
||||
})
|
||||
}
|
||||
|
||||
return { session, user: userByAccount, isNewUser }
|
||||
} else {
|
||||
if (user) {
|
||||
// If the user is already signed in and the OAuth account isn't already associated
|
||||
// with another user account then we can go ahead and link the accounts safely.
|
||||
await linkAccount({ ...account, userId: user.id })
|
||||
await events.linkAccount?.({ user, account, profile })
|
||||
|
||||
// As they are already signed in, we don't need to do anything after linking them
|
||||
// If signing in with OAuth account, check to see if the account exists already
|
||||
const userByAccount = await getUserByAccount({
|
||||
providerAccountId: account.providerAccountId,
|
||||
provider: account.provider,
|
||||
})
|
||||
if (userByAccount) {
|
||||
if (user) {
|
||||
// If the user is already signed in with this account, we don't need to do anything
|
||||
if (userByAccount.id === user.id) {
|
||||
return { session, user, isNewUser }
|
||||
}
|
||||
// If the user is currently signed in, but the new account they are signing in
|
||||
// with is already associated with another user, then we cannot link them
|
||||
// and need to return an error.
|
||||
throw new OAuthAccountNotLinked(
|
||||
"The account is already associated with another user",
|
||||
{ provider: account.provider }
|
||||
)
|
||||
}
|
||||
// If there is no active session, but the account being signed in with is already
|
||||
// associated with a valid user then create session to sign the user in.
|
||||
session = useJwtSession
|
||||
? {}
|
||||
: await createSession({
|
||||
sessionToken: generateSessionToken(),
|
||||
userId: userByAccount.id,
|
||||
expires: fromDate(options.session.maxAge),
|
||||
})
|
||||
|
||||
// If the user is not signed in and it looks like a new OAuth account then we
|
||||
// check there also isn't an user account already associated with the same
|
||||
// email address as the one in the OAuth profile.
|
||||
//
|
||||
// This step is often overlooked in OAuth implementations, but covers the following cases:
|
||||
//
|
||||
// 1. It makes it harder for someone to accidentally create two accounts.
|
||||
// e.g. by signin in with email, then again with an oauth account connected to the same email.
|
||||
// 2. It makes it harder to hijack a user account using a 3rd party OAuth account.
|
||||
// e.g. by creating an oauth account then changing the email address associated with it.
|
||||
//
|
||||
// It's quite common for services to automatically link accounts in this case, but it's
|
||||
// better practice to require the user to sign in *then* link accounts to be sure
|
||||
// someone is not exploiting a problem with a third party OAuth service.
|
||||
//
|
||||
// OAuth providers should require email address verification to prevent this, but in
|
||||
// practice that is not always the case; this helps protect against that.
|
||||
const userByEmail = profile.email
|
||||
? await getUserByEmail(profile.email)
|
||||
: null
|
||||
if (userByEmail) {
|
||||
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
|
||||
// account linking even when the user is not signed-in.
|
||||
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
|
||||
// OAuth profile the user has just tried to sign in with.
|
||||
//
|
||||
// We don't want to have two accounts with the same email address, and we don't
|
||||
// want to link them in case it's not safe to do so, so instead we prompt the user
|
||||
// to sign in via email to verify their identity and then link the accounts.
|
||||
throw new AccountNotLinked(
|
||||
"Another account already exists with the same e-mail address",
|
||||
{ provider: account.provider }
|
||||
)
|
||||
}
|
||||
} else {
|
||||
// If the current user is not logged in and the profile isn't linked to any user
|
||||
// accounts (by email or provider account id)...
|
||||
//
|
||||
// If no account matching the same [provider].id or .email exists, we can
|
||||
// create a new account for the user, link it to the OAuth account and
|
||||
// create a new session for them so they are signed in with it.
|
||||
const { id: _, ...newUser } = { ...profile, emailVerified: null }
|
||||
user = await createUser(newUser)
|
||||
}
|
||||
await events.createUser?.({ user })
|
||||
return { session, user: userByAccount, isNewUser }
|
||||
} else {
|
||||
const { provider: p } = options as InternalOptions<"oauth" | "oidc">
|
||||
const { type, provider, providerAccountId, userId, ...tokenSet } = account
|
||||
const defaults = { providerAccountId, provider, type, userId }
|
||||
account = Object.assign(p.account(tokenSet), defaults)
|
||||
|
||||
if (user) {
|
||||
// If the user is already signed in and the OAuth account isn't already associated
|
||||
// with another user account then we can go ahead and link the accounts safely.
|
||||
await linkAccount({ ...account, userId: user.id })
|
||||
await events.linkAccount?.({ user, account, profile })
|
||||
|
||||
session = useJwtSession
|
||||
? {}
|
||||
: await createSession({
|
||||
sessionToken: generateSessionToken(),
|
||||
userId: user.id,
|
||||
expires: fromDate(options.session.maxAge),
|
||||
})
|
||||
|
||||
return { session, user, isNewUser: true }
|
||||
// As they are already signed in, we don't need to do anything after linking them
|
||||
return { session, user, isNewUser }
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error("Unsupported account type")
|
||||
// If the user is not signed in and it looks like a new OAuth account then we
|
||||
// check there also isn't an user account already associated with the same
|
||||
// email address as the one in the OAuth profile.
|
||||
//
|
||||
// This step is often overlooked in OAuth implementations, but covers the following cases:
|
||||
//
|
||||
// 1. It makes it harder for someone to accidentally create two accounts.
|
||||
// e.g. by signin in with email, then again with an oauth account connected to the same email.
|
||||
// 2. It makes it harder to hijack a user account using a 3rd party OAuth account.
|
||||
// e.g. by creating an oauth account then changing the email address associated with it.
|
||||
//
|
||||
// It's quite common for services to automatically link accounts in this case, but it's
|
||||
// better practice to require the user to sign in *then* link accounts to be sure
|
||||
// someone is not exploiting a problem with a third party OAuth service.
|
||||
//
|
||||
// OAuth providers should require email address verification to prevent this, but in
|
||||
// practice that is not always the case; this helps protect against that.
|
||||
const userByEmail = profile.email
|
||||
? await getUserByEmail(profile.email)
|
||||
: null
|
||||
if (userByEmail) {
|
||||
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
|
||||
// account linking even when the user is not signed-in.
|
||||
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
|
||||
// OAuth profile the user has just tried to sign in with.
|
||||
//
|
||||
// We don't want to have two accounts with the same email address, and we don't
|
||||
// want to link them in case it's not safe to do so, so instead we prompt the user
|
||||
// to sign in via email to verify their identity and then link the accounts.
|
||||
throw new OAuthAccountNotLinked(
|
||||
"Another account already exists with the same e-mail address",
|
||||
{ provider: account.provider }
|
||||
)
|
||||
}
|
||||
} else {
|
||||
// If the current user is not logged in and the profile isn't linked to any user
|
||||
// accounts (by email or provider account id)...
|
||||
//
|
||||
// If no account matching the same [provider].id or .email exists, we can
|
||||
// create a new account for the user, link it to the OAuth account and
|
||||
// create a new session for them so they are signed in with it.
|
||||
const { id: _, ...newUser } = { ...profile, emailVerified: null }
|
||||
user = await createUser(newUser)
|
||||
}
|
||||
await events.createUser?.({ user })
|
||||
|
||||
await linkAccount({ ...account, userId: user.id })
|
||||
await events.linkAccount?.({ user, account, profile })
|
||||
|
||||
session = useJwtSession
|
||||
? {}
|
||||
: await createSession({
|
||||
sessionToken: generateSessionToken(),
|
||||
userId: user.id,
|
||||
expires: fromDate(options.session.maxAge),
|
||||
})
|
||||
|
||||
return { session, user, isNewUser: true }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,14 +110,10 @@ export async function AuthInternal<
|
||||
if (
|
||||
[
|
||||
"Signin",
|
||||
"OAuthSignin",
|
||||
"OAuthCallback",
|
||||
"OAuthCreateAccount",
|
||||
"EmailCreateAccount",
|
||||
"Callback",
|
||||
"OAuthAccountNotLinked",
|
||||
"EmailSignin",
|
||||
"CredentialsSignin",
|
||||
"SessionRequired",
|
||||
].includes(error as string)
|
||||
) {
|
||||
|
||||
@@ -3,6 +3,7 @@ import * as o from "oauth4webapi"
|
||||
import { OAuthCallbackError, OAuthProfileParseError } from "../../errors.js"
|
||||
|
||||
import type {
|
||||
Account,
|
||||
InternalOptions,
|
||||
LoggerInstance,
|
||||
Profile,
|
||||
@@ -88,11 +89,9 @@ export async function handleOAuth(
|
||||
|
||||
/** https://www.rfc-editor.org/rfc/rfc6749#section-4.1.2.1 */
|
||||
if (o.isOAuth2Error(codeGrantParams)) {
|
||||
logger.debug("OAuthCallbackError", {
|
||||
providerId: provider.id,
|
||||
...codeGrantParams,
|
||||
})
|
||||
throw new OAuthCallbackError(codeGrantParams.error)
|
||||
const cause = { providerId: provider.id, ...codeGrantParams }
|
||||
logger.debug("OAuthCallbackError", cause)
|
||||
throw new OAuthCallbackError("OAuth Provider returned an error", cause)
|
||||
}
|
||||
|
||||
const codeVerifier = await checks.pkce.use(cookies, resCookies, options)
|
||||
@@ -123,8 +122,8 @@ export async function handleOAuth(
|
||||
throw new Error("TODO: Handle www-authenticate challenges as needed")
|
||||
}
|
||||
|
||||
let profile: Profile = {}
|
||||
let tokens: TokenSet
|
||||
let profile: Profile
|
||||
let tokens: TokenSet & Pick<Account, "expires_at">
|
||||
|
||||
if (provider.type === "oidc") {
|
||||
const nonce = await checks.nonce.use(cookies, resCookies, options)
|
||||
@@ -162,37 +161,49 @@ export async function handleOAuth(
|
||||
(tokens as any).access_token
|
||||
)
|
||||
profile = await userinfoResponse.json()
|
||||
} else {
|
||||
throw new TypeError("No userinfo endpoint configured")
|
||||
}
|
||||
}
|
||||
|
||||
const profileResult = await getProfile(profile, provider, tokens, logger)
|
||||
if (tokens.expires_in) {
|
||||
tokens.expires_at =
|
||||
Math.floor(Date.now() / 1000) + Number(tokens.expires_in)
|
||||
}
|
||||
|
||||
const profileResult = await getUserAndProfile(
|
||||
profile,
|
||||
provider,
|
||||
tokens,
|
||||
logger
|
||||
)
|
||||
|
||||
return { ...profileResult, cookies: resCookies }
|
||||
}
|
||||
|
||||
/** Returns profile, raw profile and auth provider details */
|
||||
async function getProfile(
|
||||
async function getUserAndProfile(
|
||||
OAuthProfile: Profile,
|
||||
provider: OAuthConfigInternal<any>,
|
||||
tokens: TokenSet,
|
||||
logger: LoggerInstance
|
||||
) {
|
||||
try {
|
||||
const profile = await provider.profile(OAuthProfile, tokens)
|
||||
profile.email = profile.email?.toLowerCase()
|
||||
const user = await provider.profile(OAuthProfile, tokens)
|
||||
user.email = user.email?.toLowerCase()
|
||||
|
||||
if (!profile.id) {
|
||||
if (!user.id) {
|
||||
throw new TypeError(
|
||||
`Profile id is missing in ${provider.name} OAuth profile response`
|
||||
`User id is missing in ${provider.name} OAuth profile response`
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
profile,
|
||||
user,
|
||||
account: {
|
||||
provider: provider.id,
|
||||
type: provider.type,
|
||||
providerAccountId: profile.id.toString(),
|
||||
providerAccountId: user.id.toString(),
|
||||
...tokens,
|
||||
},
|
||||
OAuthProfile,
|
||||
@@ -206,6 +217,8 @@ async function getProfile(
|
||||
// redirected back to the sign up page. We log the error to help developers
|
||||
// who might be trying to debug this when configuring a new provider.
|
||||
logger.debug("getProfile error details", OAuthProfile)
|
||||
logger.error(new OAuthProfileParseError(e as Error))
|
||||
logger.error(
|
||||
new OAuthProfileParseError(e as Error, { provider: provider.id })
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ const signinErrors: Record<
|
||||
default: "Unable to sign in.",
|
||||
signin: "Try signing in with a different account.",
|
||||
oauthsignin: "Try signing in with a different account.",
|
||||
oauthcallback: "Try signing in with a different account.",
|
||||
oauthcallbackerror: "Try signing in with a different account.",
|
||||
oauthcreateaccount: "Try signing in with a different account.",
|
||||
emailcreateaccount: "Try signing in with a different account.",
|
||||
callback: "Try signing in with a different account.",
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
import { OAuthProfileParseError } from "../errors.js"
|
||||
import { merge } from "./utils/merge.js"
|
||||
|
||||
import type {
|
||||
AccountCallback,
|
||||
OAuthConfig,
|
||||
OAuthConfigInternal,
|
||||
OAuthEndpointType,
|
||||
OAuthUserConfig,
|
||||
ProfileCallback,
|
||||
Provider,
|
||||
} from "../providers/index.js"
|
||||
import type { AuthConfig, InternalProvider } from "../types.js"
|
||||
import type { AuthConfig, InternalProvider, Profile } from "../types.js"
|
||||
|
||||
/**
|
||||
* Adds `signinUrl` and `callbackUrl` to each provider
|
||||
@@ -77,18 +80,49 @@ function normalizeOAuth(
|
||||
checks,
|
||||
userinfo,
|
||||
profile: c.profile ?? defaultProfile,
|
||||
account: c.account ?? defaultAccount,
|
||||
}
|
||||
}
|
||||
|
||||
function defaultProfile(profile: any) {
|
||||
return {
|
||||
id: profile.sub ?? profile.id,
|
||||
name:
|
||||
profile.name ?? profile.nickname ?? profile.preferred_username ?? null,
|
||||
email: profile.email ?? null,
|
||||
image: profile.picture ?? null,
|
||||
}
|
||||
/**
|
||||
* Returns basic user profile from the userinfo response/`id_token` claims.
|
||||
* @see https://authjs.dev/reference/adapters#user
|
||||
* @see https://openid.net/specs/openid-connect-core-1_0.html#IDToken
|
||||
* @see https://openid.net/specs/openid-connect-core-1_0.html#UserInfo
|
||||
*/
|
||||
const defaultProfile: ProfileCallback<Profile> = (profile) => {
|
||||
const id = profile.sub ?? profile.id
|
||||
if (!id) throw new OAuthProfileParseError("Missing user id")
|
||||
return stripUndefined({
|
||||
id: id.toString(),
|
||||
name: profile.name ?? profile.nickname ?? profile.preferred_username,
|
||||
email: profile.email,
|
||||
image: profile.picture,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns basic OAuth/OIDC values from the token response.
|
||||
* @see https://www.ietf.org/rfc/rfc6749.html#section-5.1
|
||||
* @see https://openid.net/specs/openid-connect-core-1_0.html#TokenResponse
|
||||
* @see https://authjs.dev/reference/adapters#account
|
||||
*
|
||||
* @todo Return `refresh_token` and `expires_at` as well when built-in
|
||||
* refresh token support is added. (Can make it opt-in first with a flag).
|
||||
*/
|
||||
const defaultAccount: AccountCallback = (account) => {
|
||||
return stripUndefined({
|
||||
access_token: account.access_token,
|
||||
id_token: account.id_token,
|
||||
})
|
||||
}
|
||||
|
||||
function stripUndefined<T extends object>(o: T): T {
|
||||
const result = {} as any
|
||||
for (let [k, v] of Object.entries(o)) v !== undefined && (result[k] = v)
|
||||
return result as T
|
||||
}
|
||||
|
||||
function normalizeEndpoint(
|
||||
e?: OAuthConfig<any>[OAuthEndpointType],
|
||||
issuer?: string
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { CallbackRouteError, Verification } from "../../errors.js"
|
||||
import {
|
||||
CallbackRouteError,
|
||||
OAuthCallbackError,
|
||||
Verification,
|
||||
} from "../../errors.js"
|
||||
import { handleLogin } from "../callback-handler.js"
|
||||
import { handleOAuth } from "../oauth/callback.js"
|
||||
import { handleState } from "../oauth/handle-state.js"
|
||||
@@ -68,14 +72,18 @@ export async function callback(params: {
|
||||
|
||||
logger.debug("authorization result", authorizationResult)
|
||||
|
||||
const { profile, account, OAuthProfile } = authorizationResult
|
||||
const {
|
||||
user: userFromProvider,
|
||||
account,
|
||||
OAuthProfile,
|
||||
} = authorizationResult
|
||||
|
||||
// If we don't have a profile object then either something went wrong
|
||||
// or the user cancelled signing in. We don't know which, so we just
|
||||
// direct the user to the signin page for now. We could do something
|
||||
// else in future.
|
||||
// TODO: Handle user cancelling signin
|
||||
if (!profile || !account || !OAuthProfile) {
|
||||
if (!userFromProvider || !account || !OAuthProfile) {
|
||||
return { redirect: `${url}/signin`, cookies }
|
||||
}
|
||||
|
||||
@@ -83,7 +91,7 @@ export async function callback(params: {
|
||||
// Attempt to get Profile from OAuth provider details before invoking
|
||||
// signIn callback - but if no user object is returned, that is fine
|
||||
// (that just means it's a new user signing in for the first time).
|
||||
let userOrProfile = profile
|
||||
let userByAccountOrFromProvider
|
||||
if (adapter) {
|
||||
const { getUserByAccount } = adapter
|
||||
const userByAccount = await getUserByAccount({
|
||||
@@ -91,11 +99,15 @@ export async function callback(params: {
|
||||
provider: provider.id,
|
||||
})
|
||||
|
||||
if (userByAccount) userOrProfile = userByAccount
|
||||
if (userByAccount) userByAccountOrFromProvider = userByAccount
|
||||
}
|
||||
|
||||
const unauthorizedOrError = await handleAuthorized(
|
||||
{ user: userOrProfile, account, profile: OAuthProfile },
|
||||
{
|
||||
user: userByAccountOrFromProvider,
|
||||
account,
|
||||
profile: OAuthProfile,
|
||||
},
|
||||
options
|
||||
)
|
||||
|
||||
@@ -104,7 +116,7 @@ export async function callback(params: {
|
||||
// Sign user in
|
||||
const { user, session, isNewUser } = await handleLogin(
|
||||
sessionStore.value,
|
||||
profile,
|
||||
userFromProvider,
|
||||
account,
|
||||
options
|
||||
)
|
||||
@@ -152,7 +164,7 @@ export async function callback(params: {
|
||||
})
|
||||
}
|
||||
|
||||
await events.signIn?.({ user, account, profile, isNewUser })
|
||||
await events.signIn?.({ user, account, profile: OAuthProfile, isNewUser })
|
||||
|
||||
// Handle first logins on new accounts
|
||||
// e.g. option to send users to a new account landing page on initial login
|
||||
@@ -360,8 +372,18 @@ export async function callback(params: {
|
||||
cookies,
|
||||
}
|
||||
} catch (e) {
|
||||
if (e instanceof OAuthCallbackError) {
|
||||
logger.error(e)
|
||||
// REVIEW: Should we expose original error= and error_description=
|
||||
// Should we use a different name for error= then, since we already use it for all kind of errors?
|
||||
url.searchParams.set("error", OAuthCallbackError.name)
|
||||
url.pathname += "/signin"
|
||||
return { redirect: url.toString(), cookies }
|
||||
}
|
||||
|
||||
const error = new CallbackRouteError(e as Error, { provider: provider.id })
|
||||
|
||||
logger.debug("callback route error details", { method, query, body })
|
||||
logger.error(error)
|
||||
url.searchParams.set("error", CallbackRouteError.name)
|
||||
url.pathname += "/error"
|
||||
|
||||
@@ -55,8 +55,9 @@ export async function signin(
|
||||
} catch (e) {
|
||||
const error = new SignInError(e as Error, { provider: provider.id })
|
||||
logger.error(error)
|
||||
url.searchParams.set("error", error.name)
|
||||
url.pathname += "/error"
|
||||
const code = provider.type === "email" ? "EmailSignin" : "OAuthSignin"
|
||||
url.searchParams.set("error", code)
|
||||
url.pathname += "/signin"
|
||||
return { redirect: url.toString() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ export async function toInternalRequest(
|
||||
// TODO: url.toString() should not include action and providerId
|
||||
// see init.ts
|
||||
const url = new URL(req.url.replace(/\/$/, ""))
|
||||
// FIXME: Upstream issue in Next.js, pathname segments get included as part of the query string
|
||||
url.searchParams.delete("nextauth")
|
||||
const { pathname } = url
|
||||
|
||||
const action = actions.find((a) => pathname.includes(a))
|
||||
|
||||
@@ -29,7 +29,7 @@ export interface SendVerificationRequestParams {
|
||||
export interface EmailConfig extends CommonProviderOptions {
|
||||
type: "email"
|
||||
// TODO: Make use of https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html
|
||||
server: string | SMTPTransportOptions
|
||||
server?: string | SMTPTransportOptions
|
||||
/** @default `"Auth.js <no-reply@authjs.dev>"` */
|
||||
from?: string
|
||||
/**
|
||||
@@ -72,7 +72,7 @@ export interface EmailConfig extends CommonProviderOptions {
|
||||
* By default, we treat email addresses as all lower case,
|
||||
* but you can override this function to change this behavior.
|
||||
*
|
||||
* [Documentation](https://authjs.dev/guides/providers/email#normalizing-the-e-mail-address) | [RFC 2821](https://tools.ietf.org/html/rfc2821) | [Email syntax](https://en.wikipedia.org/wiki/Email_address#Syntax)
|
||||
* [Normalizing the email address](https://authjs.dev/reference/core/providers_email#normalizing-the-email-address) | [RFC 2821](https://tools.ietf.org/html/rfc2821) | [Email syntax](https://en.wikipedia.org/wiki/Email_address#Syntax)
|
||||
*/
|
||||
normalizeIdentifier?: (identifier: string) => string
|
||||
}
|
||||
@@ -287,7 +287,7 @@ export type EmailProviderType = "email"
|
||||
*
|
||||
* ## Normalizing the email address
|
||||
*
|
||||
* By default, NextAuth.js will normalize the email address. It treats values as case-insensitive (which is technically not compliant to the [RFC 2821 spec](https://datatracker.ietf.org/doc/html/rfc2821), but in practice this causes more problems than it solves, eg. when looking up users by e-mail from databases.) and also removes any secondary email address that was passed in as a comma-separated list. You can apply your own normalization via the `normalizeIdentifier` method on the `EmailProvider`. The following example shows the default behavior:
|
||||
* By default, Auth.js will normalize the email address. It treats values as case-insensitive (which is technically not compliant to the [RFC 2821 spec](https://datatracker.ietf.org/doc/html/rfc2821), but in practice this causes more problems than it solves, eg. when looking up users by e-mail from databases.) and also removes any secondary email address that was passed in as a comma-separated list. You can apply your own normalization via the `normalizeIdentifier` method on the `EmailProvider`. The following example shows the default behavior:
|
||||
* ```ts
|
||||
* EmailProvider({
|
||||
* // ...
|
||||
@@ -301,7 +301,7 @@ export type EmailProviderType = "email"
|
||||
* return `${local}@${domain}`
|
||||
*
|
||||
* // You can also throw an error, which will redirect the user
|
||||
* // to the error page with error=EmailSignin in the URL
|
||||
* // to the sign-in page with error=EmailSignin in the URL
|
||||
* // if (identifier.split("@").length > 2) {
|
||||
* // throw new Error("Only one email allowed")
|
||||
* // }
|
||||
|
||||
@@ -52,7 +52,7 @@ export interface EVEOnlineProfile extends Record<string, any> {
|
||||
* :::
|
||||
*
|
||||
* :::tip
|
||||
* If using JWT for the session, you can add the `CharacterID` to the JWT token and session. Example:
|
||||
* If using JWT for the session, you can add the `CharacterID` to the JWT and session. Example:
|
||||
* ```js
|
||||
* options: {
|
||||
* jwt: {
|
||||
|
||||
@@ -65,6 +65,7 @@ export interface GitHubProfile {
|
||||
space: number
|
||||
private_repos: number
|
||||
}
|
||||
[claim: string]: unknown
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,7 +52,10 @@ interface AdvancedEndpointHandler<P extends UrlParams, C, R> {
|
||||
conform?: (response: Response) => Awaitable<Response | undefined>
|
||||
}
|
||||
|
||||
/** Either an URL (containing all the parameters) or an object with more granular control. */
|
||||
/**
|
||||
* Either an URL (containing all the parameters) or an object with more granular control.
|
||||
* @internal
|
||||
*/
|
||||
export type EndpointHandler<
|
||||
P extends UrlParams,
|
||||
C = any,
|
||||
@@ -92,6 +95,8 @@ export type ProfileCallback<Profile> = (
|
||||
tokens: TokenSet
|
||||
) => Awaitable<User>
|
||||
|
||||
export type AccountCallback = (account: TokenSet) => TokenSet
|
||||
|
||||
export interface OAuthProviderButtonStyles {
|
||||
logo: string
|
||||
logoDark: string
|
||||
@@ -138,13 +143,25 @@ export interface OAuth2Config<Profile>
|
||||
userinfo?: string | UserinfoEndpointHandler
|
||||
type: "oauth"
|
||||
/**
|
||||
* Receives the profile object returned by the OAuth provider, and returns the user object.
|
||||
* This will be used to create the user in the database.
|
||||
* Receives the full {@link Profile} returned by the OAuth provider, and returns a subset.
|
||||
* It is used to create the user in the database.
|
||||
*
|
||||
* Defaults to: `id`, `email`, `name`, `image`
|
||||
*
|
||||
* [Documentation](https://authjs.dev/reference/adapters/models#user)
|
||||
* @see [Database Adapter: User model](https://authjs.dev/reference/adapters#user)
|
||||
*/
|
||||
profile?: ProfileCallback<Profile>
|
||||
/**
|
||||
* Receives the full {@link TokenSet} returned by the OAuth provider, and returns a subset.
|
||||
* It is used to create the account associated with a user in the database.
|
||||
*
|
||||
* Defaults to: `access_token` and `id_token`
|
||||
*
|
||||
* @see [Database Adapter: Account model](https://authjs.dev/reference/adapters#account)
|
||||
* @see https://openid.net/specs/openid-connect-core-1_0.html#TokenResponse
|
||||
* @see https://www.ietf.org/rfc/rfc6749.html#section-5.1
|
||||
*/
|
||||
account?: AccountCallback
|
||||
/**
|
||||
* The CSRF protection performed on the callback endpoint.
|
||||
* @default ["pkce"]
|
||||
@@ -190,7 +207,11 @@ export interface OAuth2Config<Profile>
|
||||
options?: OAuthUserConfig<Profile>
|
||||
}
|
||||
|
||||
/** TODO: Document */
|
||||
/**
|
||||
* Extension of the {@link OAuth2Config}.
|
||||
*
|
||||
* @see https://openid.net/specs/openid-connect-core-1_0.html
|
||||
*/
|
||||
export interface OIDCConfig<Profile>
|
||||
extends Omit<OAuth2Config<Profile>, "type" | "checks"> {
|
||||
type: "oidc"
|
||||
@@ -204,6 +225,7 @@ export type OAuthEndpointType = "authorization" | "token" | "userinfo"
|
||||
/**
|
||||
* We parsed `authorization`, `token` and `userinfo`
|
||||
* to always contain a valid `URL`, with the params
|
||||
* @internal
|
||||
*/
|
||||
export type OAuthConfigInternal<Profile> = Omit<
|
||||
OAuthConfig<Profile>,
|
||||
@@ -229,7 +251,10 @@ export type OAuthConfigInternal<Profile> = Omit<
|
||||
*
|
||||
*/
|
||||
redirectProxyUrl?: OAuth2Config<Profile>["redirectProxyUrl"]
|
||||
} & Pick<Required<OAuthConfig<Profile>>, "clientId" | "checks" | "profile">
|
||||
} & Pick<
|
||||
Required<OAuthConfig<Profile>>,
|
||||
"clientId" | "checks" | "profile" | "account"
|
||||
>
|
||||
|
||||
export type OIDCConfigInternal<Profile> = OAuthConfigInternal<Profile> & {
|
||||
checks: OIDCConfig<Profile>["checks"]
|
||||
@@ -238,11 +263,9 @@ export type OIDCConfigInternal<Profile> = OAuthConfigInternal<Profile> & {
|
||||
export type OAuthUserConfig<Profile> = Omit<
|
||||
Partial<OAuthConfig<Profile>>,
|
||||
"options" | "type"
|
||||
> &
|
||||
Required<Pick<OAuthConfig<Profile>, "clientId" | "clientSecret">>
|
||||
>
|
||||
|
||||
export type OIDCUserConfig<Profile> = Omit<
|
||||
Partial<OIDCConfig<Profile>>,
|
||||
"options" | "type"
|
||||
> &
|
||||
Required<Pick<OIDCConfig<Profile>, "clientId" | "clientSecret">>
|
||||
>
|
||||
|
||||
@@ -99,6 +99,7 @@ export interface TwitterProfile {
|
||||
text: string
|
||||
}>
|
||||
}
|
||||
[claims: string]: unknown
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -116,16 +116,58 @@ export interface Account extends Partial<OpenIDTokenEndpointResponse> {
|
||||
providerAccountId: string
|
||||
/** Provider's type for this account */
|
||||
type: ProviderType
|
||||
/** id of the user this account belongs to */
|
||||
/**
|
||||
* id of the user this account belongs to
|
||||
*
|
||||
* @see https://authjs.dev/reference/adapters#user
|
||||
*/
|
||||
userId?: string
|
||||
/**
|
||||
* Calculated value based on {@link OAuth2TokenEndpointResponse.expires_in}.
|
||||
*
|
||||
* It is the absolute timestamp (in seconds) when the {@link OAuth2TokenEndpointResponse.access_token} expires.
|
||||
*
|
||||
* This value can be used for implementing token rotation together with {@link OAuth2TokenEndpointResponse.refresh_token}.
|
||||
*
|
||||
* @see https://authjs.dev/guides/basics/refresh-token-rotation#database-strategy
|
||||
* @see https://www.rfc-editor.org/rfc/rfc6749#section-5.1
|
||||
*/
|
||||
expires_at?: number
|
||||
}
|
||||
|
||||
/** The OAuth profile returned from your provider */
|
||||
/**
|
||||
* The user info returned from your OAuth provider.
|
||||
*
|
||||
* @see https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims
|
||||
*/
|
||||
export interface Profile {
|
||||
sub?: string | null
|
||||
name?: string | null
|
||||
given_name?: string | null
|
||||
family_name?: string | null
|
||||
middle_name?: string | null
|
||||
nickname?: string | null
|
||||
preferred_username?: string | null
|
||||
profile?: string | null
|
||||
picture?: string | null | any
|
||||
website?: string | null
|
||||
email?: string | null
|
||||
image?: string | null
|
||||
email_verified?: boolean | null
|
||||
gender?: string | null
|
||||
birthdate?: string | null
|
||||
zoneinfo?: string | null
|
||||
locale?: string | null
|
||||
phone_number?: string | null
|
||||
updated_at?: Date | string | number | null
|
||||
address?: {
|
||||
formatted?: string | null
|
||||
street_address?: string | null
|
||||
locality?: string | null
|
||||
region?: string | null
|
||||
postal_code?: string | null
|
||||
country?: string | null
|
||||
} | null
|
||||
[claim: string]: unknown
|
||||
}
|
||||
|
||||
/** [Documentation](https://authjs.dev/guides/basics/callbacks) */
|
||||
@@ -262,7 +304,7 @@ export interface EventCallbacks {
|
||||
/**
|
||||
* The message object will contain one of these depending on
|
||||
* if you use JWT or database persisted sessions:
|
||||
* - `token`: The JWT token for this session.
|
||||
* - `token`: The JWT for this session.
|
||||
* - `session`: The session object from your adapter that is being ended.
|
||||
*/
|
||||
signOut: (
|
||||
@@ -280,7 +322,7 @@ export interface EventCallbacks {
|
||||
/**
|
||||
* The message object will contain one of these depending on
|
||||
* if you use JWT or database persisted sessions:
|
||||
* - `token`: The JWT token for this session.
|
||||
* - `token`: The JWT for this session.
|
||||
* - `session`: The session object from your adapter.
|
||||
*/
|
||||
session: (message: { session: Session; token: JWT }) => Awaitable<void>
|
||||
@@ -295,7 +337,7 @@ export type ErrorPageParam = "Configuration" | "AccessDenied" | "Verification"
|
||||
export type SignInPageErrorParam =
|
||||
| "Signin"
|
||||
| "OAuthSignin"
|
||||
| "OAuthCallback"
|
||||
| "OAuthCallbackError"
|
||||
| "OAuthCreateAccount"
|
||||
| "EmailCreateAccount"
|
||||
| "Callback"
|
||||
@@ -385,15 +427,40 @@ export type InternalProvider<T = ProviderType> = (T extends "oauth"
|
||||
callbackUrl: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Supported actions by Auth.js. Each action map to a REST API endpoint.
|
||||
* Some actions have a `GET` and `POST` variant, depending on if the action
|
||||
* changes the state of the server.
|
||||
*
|
||||
* - **`"callback"`**:
|
||||
* - **`GET`**: Handles the callback from an [OAuth provider](https://authjs.dev/reference/core/providers_oauth).
|
||||
* - **`POST`**: Handles the callback from a [Credentials provider](https://authjs.dev/reference/core/providers_credentials).
|
||||
* - **`"csrf"`**: Returns the raw CSRF token, which is saved in a cookie (encrypted).
|
||||
* It is used for CSRF protection, implementing the [double submit cookie](https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#double-submit-cookie) technique.
|
||||
* :::note
|
||||
* Some frameworks have built-in CSRF protection and can therefore disable this action. In this case, the corresponding endpoint will return a 404 response. Read more at [`skipCSRFCheck`](https://authjs.dev/reference/core#skipcsrfcheck).
|
||||
* _⚠ We don't recommend manually disabling CSRF protection, unless you know what you're doing._
|
||||
* :::
|
||||
* - **`"error"`**: Renders the built-in error page.
|
||||
* - **`"providers"`**: Returns a client-safe list of all configured providers.
|
||||
* - **`"session"`**: Returns the user's session if it exists, otherwise `null`.
|
||||
* - **`"signin"`**:
|
||||
* - **`GET`**: Renders the built-in sign-in page.
|
||||
* - **`POST`**: Initiates the sign-in flow.
|
||||
* - **`"signout"`**:
|
||||
* - **`GET`**: Renders the built-in sign-out page.
|
||||
* - **`POST`**: Initiates the sign-out flow. This will invalidate the user's session (deleting the cookie, and if there is a session in the database, it will be deleted as well).
|
||||
* - **`"verify-request"`**: Renders the built-in verification request page.
|
||||
*/
|
||||
export type AuthAction =
|
||||
| "callback"
|
||||
| "csrf"
|
||||
| "error"
|
||||
| "providers"
|
||||
| "session"
|
||||
| "csrf"
|
||||
| "signin"
|
||||
| "signout"
|
||||
| "callback"
|
||||
| "verify-request"
|
||||
| "error"
|
||||
|
||||
/** @internal */
|
||||
export interface RequestInternal {
|
||||
|
||||
@@ -51,7 +51,7 @@ export async function signIn<
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"X-Auth-Return-Redirect": "1",
|
||||
},
|
||||
// @ts-expect-error -- ignore
|
||||
// @ts-ignore
|
||||
body: new URLSearchParams({
|
||||
...options,
|
||||
csrfToken,
|
||||
|
||||
@@ -52,7 +52,7 @@ export async function signIn<
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"X-Auth-Return-Redirect": "1",
|
||||
},
|
||||
// @ts-expect-error -- ignore
|
||||
// @ts-ignore
|
||||
body: new URLSearchParams({
|
||||
...options,
|
||||
csrfToken,
|
||||
|
||||
@@ -65,8 +65,10 @@
|
||||
],
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.20.13",
|
||||
"@panva/hkdf": "^1.0.2",
|
||||
"@babel/runtime": "^7.16.3",
|
||||
"@panva/hkdf": "^1.0.1",
|
||||
"@simplewebauthn/browser": "^6.2.2",
|
||||
"@simplewebauthn/server": "^6.2.2",
|
||||
"cookie": "^0.5.0",
|
||||
"jose": "^4.11.4",
|
||||
"oauth": "^0.9.15",
|
||||
@@ -96,6 +98,7 @@
|
||||
"@babel/preset-typescript": "^7.17.12",
|
||||
"@edge-runtime/jest-environment": "1.1.0-beta.35",
|
||||
"@next-auth/tsconfig": "workspace:*",
|
||||
"@simplewebauthn/typescript-types": "6.3.0-alpha.1",
|
||||
"@swc/core": "^1.2.198",
|
||||
"@swc/jest": "^0.2.21",
|
||||
"@testing-library/dom": "^8.13.0",
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import {
|
||||
generateAuthenticationOptions,
|
||||
verifyAuthenticationResponse,
|
||||
} from '@simplewebauthn/server';
|
||||
import { getUserFromDb } from "./helpers"
|
||||
|
||||
import type { } from '@simplewebauthn/typescript-types'
|
||||
|
||||
/*
|
||||
* @desc GET /api/auth/webauthn/authenticate
|
||||
* @type object
|
||||
**/
|
||||
const generateAuthOptions = (userId) => {
|
||||
// (Pseudocode) Retrieve the logged-in user
|
||||
const user: UserModel = getUserFromDb(userId)
|
||||
// (Pseudocode) Retrieve any of the user's previously-
|
||||
// registered authenticators
|
||||
const userAuthenticators: Authenticator[] = getUserAuthenticators(user)
|
||||
|
||||
const options = generateAuthenticationOptions({
|
||||
// Require users to use a previously-registered authenticator
|
||||
allowCredentials: userAuthenticators.map((authenticator) => ({
|
||||
id: authenticator.credentialID,
|
||||
type: "public-key",
|
||||
// Optional
|
||||
transports: authenticator.transports,
|
||||
})),
|
||||
userVerification: "preferred",
|
||||
})
|
||||
|
||||
// (Pseudocode) Remember this challenge for this user
|
||||
setUserCurrentChallenge(user, options.challenge)
|
||||
|
||||
return options
|
||||
}
|
||||
|
||||
/*
|
||||
* @desc POST to /api/auth/webauthn/authenticate
|
||||
* @type object
|
||||
* @param body: AuthenticationCredentialJSON
|
||||
**/
|
||||
const verifyAuthResponse = (req) => {
|
||||
const { body } = req;
|
||||
|
||||
// (Pseudocode) Retrieve the logged-in user
|
||||
const user: UserModel = getUserFromDB(loggedInUserId);
|
||||
// (Pseudocode) Get `options.challenge` that was saved above
|
||||
const expectedChallenge: string = getUserCurrentChallenge(user);
|
||||
// (Pseudocode} Retrieve an authenticator from the DB that
|
||||
// should match the `id` in the returned credential
|
||||
const authenticator = getUserAuthenticator(user, body.id);
|
||||
|
||||
if (!authenticator) {
|
||||
throw new Error(`Could not find authenticator ${body.id} for user ${user.id}`);
|
||||
}
|
||||
|
||||
let verification;
|
||||
try {
|
||||
verification = await verifyAuthenticationResponse({
|
||||
credential: body,
|
||||
expectedChallenge,
|
||||
expectedOrigin: origin,
|
||||
expectedRPID: rpID,
|
||||
authenticator,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return res.status(400).send({ error: error.message });
|
||||
}
|
||||
|
||||
const { verified } = verification;
|
||||
return verified
|
||||
}
|
||||
27
packages/next-auth/src/core/lib/webauthn/helpers.ts
Normal file
27
packages/next-auth/src/core/lib/webauthn/helpers.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
export const saveRegistrationInfo = ({ verification, registrationInfo }) => {
|
||||
const { registrationInfo } = verification
|
||||
const { credentialPublicKey, credentialID, counter } = registrationInfo
|
||||
|
||||
const newAuthenticator: Authenticator = {
|
||||
credentialID,
|
||||
credentialPublicKey,
|
||||
counter,
|
||||
}
|
||||
|
||||
// (Pseudocode) Save the authenticator info so that we can
|
||||
// get it by user ID later
|
||||
saveNewUserAuthenticatorInDB(user, newAuthenticator)
|
||||
}
|
||||
|
||||
// TODO:
|
||||
// (Pseudocode) Fetch User from adapter
|
||||
export const getUserFromDb = (userId) => {
|
||||
return db.query('Users').where({ userId })
|
||||
}
|
||||
|
||||
export const updateRegistrationCounter = ({ verification, authenticationInfo }) = {
|
||||
const { authenticationInfo } = verification;
|
||||
const { newCounter } = authenticationInfo;
|
||||
|
||||
saveUpdatedAuthenticatorCounter(authenticator, newCounter);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
import SimpleWebAuthnServer from "@simplewebauthn/server"
|
||||
import { saveRegistrationInfo } from './helpers'
|
||||
|
||||
import type { Authenticator } from '../../types'
|
||||
|
||||
/*
|
||||
* @desc GET - /api/auth/webauthn/register
|
||||
* @type object
|
||||
**/
|
||||
const generateRegistration = () => {
|
||||
// Human-readable title for your website
|
||||
const rpName = "SimpleWebAuthn Example"
|
||||
// A unique identifier for your website
|
||||
const rpID = "localhost"
|
||||
// The URL at which registrations and authentications should occur
|
||||
const origin = `https://${rpID}`
|
||||
|
||||
// (Pseudocode) Retrieve the user from the database
|
||||
// after they've logged in
|
||||
const user: UserModel = getUserFromDB(loggedInUserId)
|
||||
// (Pseudocode) Retrieve any of the user's previously-
|
||||
// registered authenticators
|
||||
const userAuthenticators: Authenticator[] = getUserAuthenticators(user)
|
||||
|
||||
const options = generateRegistrationOptions({
|
||||
rpName,
|
||||
rpID,
|
||||
userID: user.id,
|
||||
userName: user.username,
|
||||
// Don't prompt users for additional information about the authenticator
|
||||
// (Recommended for smoother UX)
|
||||
attestationType: "none",
|
||||
// Prevent users from re-registering existing authenticators
|
||||
excludeCredentials: userAuthenticators.map((authenticator) => ({
|
||||
id: authenticator.credentialID,
|
||||
type: "public-key",
|
||||
// Optional
|
||||
transports: authenticator.transports,
|
||||
})),
|
||||
})
|
||||
|
||||
// (Pseudocode) Remember the challenge for this user
|
||||
setUserCurrentChallenge(user, options.challenge)
|
||||
|
||||
return options
|
||||
}
|
||||
|
||||
/*
|
||||
* @desc POST /api/auth/webauthn/register
|
||||
* @type object
|
||||
**/
|
||||
const verifyRegistration = (req) => {
|
||||
const { body } = req
|
||||
|
||||
// (Pseudocode) Retrieve the logged-in user
|
||||
const user: UserModel = getUserFromDB(loggedInUserId)
|
||||
// (Pseudocode) Get `options.challenge` that was saved above
|
||||
const expectedChallenge: string = getUserCurrentChallenge(user)
|
||||
|
||||
let verification
|
||||
try {
|
||||
verification = await verifyRegistrationResponse({
|
||||
credential: body,
|
||||
expectedChallenge,
|
||||
expectedOrigin: origin,
|
||||
expectedRPID: rpID,
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
return res.status(400).send({ error: error.message })
|
||||
}
|
||||
|
||||
const { verified } = verification
|
||||
if (verified) {
|
||||
saveRegistrationInfo({ verification, registrationInfo })
|
||||
}
|
||||
return { verified }
|
||||
}
|
||||
7
packages/next-auth/src/core/routes/webauthn.ts
Normal file
7
packages/next-auth/src/core/routes/webauthn.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { ResponseInternal } from ".."
|
||||
|
||||
export default function webauthn(): ResponseInternal<> {
|
||||
// TODO:
|
||||
// Assign `/core/lib/webauthn/{authentication-handler,registration-handler}.ts`
|
||||
// handler functions to the endpoint/http verb combo listed in their @desc
|
||||
}
|
||||
@@ -625,3 +625,36 @@ export type NextAuthApiHandler<Result = void, Response = any> = (
|
||||
req: NextAuthRequest,
|
||||
res: NextAuthResponse<Response>
|
||||
) => Awaitable<Result>
|
||||
|
||||
/** @internal */
|
||||
export type UserModel = {
|
||||
id: string
|
||||
username: string
|
||||
currentChallenge?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* It is strongly advised that authenticators get their own DB
|
||||
* table, ideally with a foreign key to a specific UserModel.
|
||||
*
|
||||
* "SQL" tags below are suggestions for column data types and
|
||||
* how best to store data received during registration for use
|
||||
* in subsequent authentications.
|
||||
* @internal
|
||||
*/
|
||||
export type Authenticator = {
|
||||
// SQL: Encode to base64url then store as `TEXT`. Index this column
|
||||
credentialID: Buffer
|
||||
// SQL: Store raw bytes as `BYTEA`/`BLOB`/etc...
|
||||
credentialPublicKey: Buffer
|
||||
// SQL: Consider `BIGINT` since some authenticators return atomic timestamps as counters
|
||||
counter: number
|
||||
// SQL: `VARCHAR(32)` or similar, longest possible value is currently 12 characters
|
||||
// Ex: 'singleDevice' | 'multiDevice'
|
||||
credentialDeviceType: CredentialDeviceType
|
||||
// SQL: `BOOL` or whatever similar type is supported
|
||||
credentialBackedUp: boolean
|
||||
// SQL: `VARCHAR(255)` and store string array as a CSV string
|
||||
// Ex: ['usb' | 'ble' | 'nfc' | 'internal']
|
||||
transports?: AuthenticatorTransport[]
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export interface JWTEncodeParams {
|
||||
secret: string | Buffer
|
||||
/**
|
||||
* The maximum age of the NextAuth.js issued JWT in seconds.
|
||||
* @default 30 * 24 * 30 * 60 // 30 days
|
||||
* @default 30 * 24 * 60 * 60 // 30 days
|
||||
*/
|
||||
maxAge?: number
|
||||
}
|
||||
@@ -42,7 +42,7 @@ export interface JWTOptions {
|
||||
secret: string
|
||||
/**
|
||||
* The maximum age of the NextAuth.js issued JWT in seconds.
|
||||
* @default 30 * 24 * 30 * 60 // 30 days
|
||||
* @default 30 * 24 * 60 * 60 // 30 days
|
||||
*/
|
||||
maxAge: number
|
||||
/** Override this method to control the NextAuth.js issued JWT encoding. */
|
||||
|
||||
163
pnpm-lock.yaml
generated
163
pnpm-lock.yaml
generated
@@ -228,8 +228,8 @@ importers:
|
||||
react-dom: 18.2.0
|
||||
vercel: 23.1.2
|
||||
dependencies:
|
||||
dotenv: 16.0.0
|
||||
gatsby: 5.8.0-next.3_biqbaboplfbrettd7655fr4n2y
|
||||
dotenv: 16.0.3
|
||||
gatsby: 5.7.0-next.1_biqbaboplfbrettd7655fr4n2y
|
||||
next-auth: link:../../../packages/next-auth
|
||||
react: 18.2.0
|
||||
react-dom: 18.2.0_react@18.2.0
|
||||
@@ -684,7 +684,10 @@ importers:
|
||||
'@babel/runtime': ^7.20.13
|
||||
'@edge-runtime/jest-environment': 1.1.0-beta.35
|
||||
'@next-auth/tsconfig': workspace:*
|
||||
'@panva/hkdf': ^1.0.2
|
||||
'@panva/hkdf': ^1.0.1
|
||||
'@simplewebauthn/browser': ^6.2.2
|
||||
'@simplewebauthn/server': ^6.2.2
|
||||
'@simplewebauthn/typescript-types': 6.3.0-alpha.1
|
||||
'@swc/core': ^1.2.198
|
||||
'@swc/jest': ^0.2.21
|
||||
'@testing-library/dom': ^8.13.0
|
||||
@@ -722,8 +725,10 @@ importers:
|
||||
uuid: ^8.3.2
|
||||
whatwg-fetch: ^3.6.2
|
||||
dependencies:
|
||||
'@babel/runtime': 7.20.13
|
||||
'@panva/hkdf': 1.0.4
|
||||
'@babel/runtime': 7.18.3
|
||||
'@panva/hkdf': 1.0.2
|
||||
'@simplewebauthn/browser': 6.2.2
|
||||
'@simplewebauthn/server': 6.2.2
|
||||
cookie: 0.5.0
|
||||
jose: 4.14.0
|
||||
oauth: 0.9.15
|
||||
@@ -741,6 +746,7 @@ importers:
|
||||
'@babel/preset-typescript': 7.17.12_@babel+core@7.18.5
|
||||
'@edge-runtime/jest-environment': 1.1.0-beta.35
|
||||
'@next-auth/tsconfig': link:../tsconfig
|
||||
'@simplewebauthn/typescript-types': 6.3.0-alpha.1
|
||||
'@swc/core': 1.2.204
|
||||
'@swc/jest': 0.2.21_@swc+core@1.2.204
|
||||
'@testing-library/dom': 8.14.0
|
||||
@@ -8412,6 +8418,10 @@ packages:
|
||||
eslint-scope: 5.1.1
|
||||
dev: false
|
||||
|
||||
/@noble/ed25519/1.7.1:
|
||||
resolution: {integrity: sha512-Rk4SkJFaXZiznFyC/t77Q0NKS4FL7TLJJsVG2V2oiEq3kJVeTdxysEe/yRWSpnWMe808XRDJ+VFh5pt/FN5plw==}
|
||||
dev: false
|
||||
|
||||
/@nodelib/fs.scandir/2.1.5:
|
||||
resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==}
|
||||
engines: {node: '>= 8'}
|
||||
@@ -9037,6 +9047,32 @@ packages:
|
||||
nullthrows: 1.1.1
|
||||
dev: false
|
||||
|
||||
/@peculiar/asn1-android/2.3.3:
|
||||
resolution: {integrity: sha512-/jg6EicInJV7bkonYl4Ka1UmO0VIIE2lzkrgY7VbFoaTCP8GtEXGV8BUWVrF6rvitCqI1BE2POmak1iRiCHZTg==}
|
||||
dependencies:
|
||||
'@peculiar/asn1-schema': 2.3.3
|
||||
asn1js: 3.0.5
|
||||
tslib: 2.4.1
|
||||
dev: false
|
||||
|
||||
/@peculiar/asn1-schema/2.3.3:
|
||||
resolution: {integrity: sha512-6GptMYDMyWBHTUKndHaDsRZUO/XMSgIns2krxcm2L7SEExRHwawFvSwNBhqNPR9HJwv3MruAiF1bhN0we6j6GQ==}
|
||||
dependencies:
|
||||
asn1js: 3.0.5
|
||||
pvtsutils: 1.3.2
|
||||
tslib: 2.4.1
|
||||
dev: false
|
||||
|
||||
/@peculiar/asn1-x509/2.3.4:
|
||||
resolution: {integrity: sha512-NhA6U76kiGKTQG2WQyGfRS/piYHt7HxUsGb0IvQaiJheuucKb2CYu0/tOk1dayZcvFf6Pnf9HjFGQ/5ud/ndRQ==}
|
||||
dependencies:
|
||||
'@peculiar/asn1-schema': 2.3.3
|
||||
asn1js: 3.0.5
|
||||
ipaddr.js: 2.0.1
|
||||
pvtsutils: 1.3.2
|
||||
tslib: 2.4.1
|
||||
dev: false
|
||||
|
||||
/@playwright/test/1.29.2:
|
||||
resolution: {integrity: sha512-+3/GPwOgcoF0xLz/opTnahel1/y42PdcgZ4hs+BZGIUjtmEFSXGg+nFoaH3NSmuc7a6GSFwXDJ5L7VXpqzigNg==}
|
||||
engines: {node: '>=14'}
|
||||
@@ -9361,6 +9397,33 @@ packages:
|
||||
/@sideway/pinpoint/2.0.0:
|
||||
resolution: {integrity: sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==}
|
||||
|
||||
/@simplewebauthn/browser/6.2.2:
|
||||
resolution: {integrity: sha512-VUtne7+s6BmW4usnbitjZEI1VNT/PNh6bYg+AI4OMdfpo5z+yAq+6iVAWBJlIUGVk5InetEQvTUp6OefBam8qg==}
|
||||
dev: false
|
||||
|
||||
/@simplewebauthn/server/6.2.2:
|
||||
resolution: {integrity: sha512-c7vM8rocz9N5ndaWpu9nOmKQVF7PXd4/R620klVAAoP7UQJwOpGJKSmIOdmg87lNMMk5/V38Mp/5g6kYz34+0g==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
dependencies:
|
||||
'@noble/ed25519': 1.7.1
|
||||
'@peculiar/asn1-android': 2.3.3
|
||||
'@peculiar/asn1-schema': 2.3.3
|
||||
'@peculiar/asn1-x509': 2.3.4
|
||||
base64url: 3.0.1
|
||||
cbor: 5.2.0
|
||||
debug: 4.3.4
|
||||
jsrsasign: 10.6.1
|
||||
jwk-to-pem: 2.0.5
|
||||
node-fetch: 2.6.7
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
- supports-color
|
||||
dev: false
|
||||
|
||||
/@simplewebauthn/typescript-types/6.3.0-alpha.1:
|
||||
resolution: {integrity: sha512-NdVVJMSSqco21MvNrttbRGms1oNL6HvoiRKNFEZ8zB3MdqMecBeicQ7YlKDd4MdJrkAKcwXKwH+cjlzIDU5uhg==}
|
||||
dev: true
|
||||
|
||||
/@sinclair/typebox/0.23.5:
|
||||
resolution: {integrity: sha512-AFBVi/iT4g20DHoujvMH1aEDn8fGJh4xsRGCP6d8RpLPMqsNPvW01Jcn0QysXTsg++/xj25NmJsGyH9xug/wKg==}
|
||||
dev: true
|
||||
@@ -12060,12 +12123,30 @@ packages:
|
||||
/asap/2.0.6:
|
||||
resolution: {integrity: sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==}
|
||||
|
||||
/asn1.js/5.4.1:
|
||||
resolution: {integrity: sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==}
|
||||
dependencies:
|
||||
bn.js: 4.12.0
|
||||
inherits: 2.0.4
|
||||
minimalistic-assert: 1.0.1
|
||||
safer-buffer: 2.1.2
|
||||
dev: false
|
||||
|
||||
/asn1/0.2.6:
|
||||
resolution: {integrity: sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==}
|
||||
dependencies:
|
||||
safer-buffer: 2.1.2
|
||||
dev: true
|
||||
|
||||
/asn1js/3.0.5:
|
||||
resolution: {integrity: sha512-FVnvrKJwpt9LP2lAMl8qZswRNm3T4q9CON+bxldk2iwk3FFpuwhx2FfinyitizWHsVYyaY+y5JzDR0rCMV5yTQ==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
dependencies:
|
||||
pvtsutils: 1.3.2
|
||||
pvutils: 1.1.3
|
||||
tslib: 2.4.1
|
||||
dev: false
|
||||
|
||||
/assert-plus/1.0.0:
|
||||
resolution: {integrity: sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==}
|
||||
engines: {node: '>=0.8'}
|
||||
@@ -12205,7 +12286,7 @@ packages:
|
||||
/axios/0.21.4_debug@4.3.4:
|
||||
resolution: {integrity: sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==}
|
||||
dependencies:
|
||||
follow-redirects: 1.15.1
|
||||
follow-redirects: 1.15.1_debug@4.3.4
|
||||
transitivePeerDependencies:
|
||||
- debug
|
||||
|
||||
@@ -12732,6 +12813,11 @@ packages:
|
||||
engines: {node: ^4.5.0 || >= 5.9}
|
||||
dev: false
|
||||
|
||||
/base64url/3.0.1:
|
||||
resolution: {integrity: sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
dev: false
|
||||
|
||||
/basic-auth-connect/1.0.0:
|
||||
resolution: {integrity: sha512-kiV+/DTgVro4aZifY/hwRwALBISViL5NP4aReaR2EVJEObpbUBHIkdJh/YpcoEiYt7nBodZ6U2ajZeZvSxUCCg==}
|
||||
dev: true
|
||||
@@ -12774,7 +12860,6 @@ packages:
|
||||
|
||||
/bignumber.js/9.0.2:
|
||||
resolution: {integrity: sha512-GAcQvbpsM0pUb0zw1EI0KhQEZ+lRwR5fYaAp3vPOYuP7aDvGy6cVN6XHLauvF8SOga2y0dcLcjt3iQDTSEliyw==}
|
||||
dev: true
|
||||
|
||||
/binary-extensions/2.2.0:
|
||||
resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==}
|
||||
@@ -12815,6 +12900,10 @@ packages:
|
||||
/bluebird/3.7.2:
|
||||
resolution: {integrity: sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==}
|
||||
|
||||
/bn.js/4.12.0:
|
||||
resolution: {integrity: sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==}
|
||||
dev: false
|
||||
|
||||
/body-parser/1.20.0:
|
||||
resolution: {integrity: sha512-DfJ+q6EPcGKZD1QWUjSpqp+Q7bDQTsQIF4zfUAtZ6qk+H/3/QRhg9CEp39ss+/T2vw0+HaidC0ecJj/DRLIaKg==}
|
||||
engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16}
|
||||
@@ -12929,6 +13018,10 @@ packages:
|
||||
dependencies:
|
||||
fill-range: 7.0.1
|
||||
|
||||
/brorand/1.1.0:
|
||||
resolution: {integrity: sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==}
|
||||
dev: false
|
||||
|
||||
/browser-process-hrtime/1.0.0:
|
||||
resolution: {integrity: sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==}
|
||||
dev: true
|
||||
@@ -13259,6 +13352,14 @@ packages:
|
||||
lodash: 4.17.21
|
||||
dev: true
|
||||
|
||||
/cbor/5.2.0:
|
||||
resolution: {integrity: sha512-5IMhi9e1QU76ppa5/ajP1BmMWZ2FHkhAhjeVKQ/EFCgYSEaeVaoGtL7cxJskf9oCCk+XjzaIdc3IuU/dbA/o2A==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
dependencies:
|
||||
bignumber.js: 9.0.2
|
||||
nofilter: 1.0.4
|
||||
dev: false
|
||||
|
||||
/ccount/1.1.0:
|
||||
resolution: {integrity: sha512-vlNK021QdI7PNeiUh/lKkC/mNHHfV0m/Ad5JoI0TYtlBnJAslM/JIkm/tGC88bkLIwO6OQ5uV6ztS6kVAtCDlg==}
|
||||
dev: true
|
||||
@@ -17939,6 +18040,7 @@ packages:
|
||||
peerDependenciesMeta:
|
||||
debug:
|
||||
optional: true
|
||||
dev: true
|
||||
|
||||
/follow-redirects/1.15.1_debug@4.3.4:
|
||||
resolution: {integrity: sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==}
|
||||
@@ -17950,7 +18052,6 @@ packages:
|
||||
optional: true
|
||||
dependencies:
|
||||
debug: 4.3.4
|
||||
dev: true
|
||||
|
||||
/for-each/0.3.3:
|
||||
resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==}
|
||||
@@ -19409,6 +19510,13 @@ packages:
|
||||
resolution: {integrity: sha512-7SW7ejyfnRxuOc7ptQHSf4LDoZaWOivfzqw+5rpcQku0nHfmicPKE51ra9BiRLAmT8+gGLestr1XroUkqdjL6w==}
|
||||
dev: false
|
||||
|
||||
/hash.js/1.1.7:
|
||||
resolution: {integrity: sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==}
|
||||
dependencies:
|
||||
inherits: 2.0.4
|
||||
minimalistic-assert: 1.0.1
|
||||
dev: false
|
||||
|
||||
/hasha/5.2.2:
|
||||
resolution: {integrity: sha512-Hrp5vIK/xr5SkeN2onO32H0MgNZ0f17HRNH39WfL0SYUNOTZ5Lz1TJ8Pajo/87dYGEFlLMm7mIc/k/s6Bvz9HQ==}
|
||||
engines: {node: '>=8'}
|
||||
@@ -19518,6 +19626,14 @@ packages:
|
||||
value-equal: 1.0.1
|
||||
dev: true
|
||||
|
||||
/hmac-drbg/1.0.1:
|
||||
resolution: {integrity: sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==}
|
||||
dependencies:
|
||||
hash.js: 1.1.7
|
||||
minimalistic-assert: 1.0.1
|
||||
minimalistic-crypto-utils: 1.0.1
|
||||
dev: false
|
||||
|
||||
/hoist-non-react-statics/3.3.2:
|
||||
resolution: {integrity: sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==}
|
||||
dependencies:
|
||||
@@ -19739,7 +19855,7 @@ packages:
|
||||
engines: {node: '>=8.0.0'}
|
||||
dependencies:
|
||||
eventemitter3: 4.0.7
|
||||
follow-redirects: 1.15.1
|
||||
follow-redirects: 1.15.1_debug@4.3.4
|
||||
requires-port: 1.0.0
|
||||
transitivePeerDependencies:
|
||||
- debug
|
||||
@@ -20086,7 +20202,6 @@ packages:
|
||||
/ipaddr.js/2.0.1:
|
||||
resolution: {integrity: sha512-1qTgH9NG+IIJ4yfKs2e6Pp1bZg8wbDbKHT21HrLIeYBTRLgMYKnMTPAuI3Lcs61nfx5h1xlXnbJtH1kX5/d/ng==}
|
||||
engines: {node: '>= 10'}
|
||||
dev: true
|
||||
|
||||
/ipv6-normalize/1.0.1:
|
||||
resolution: {integrity: sha512-Bm6H79i01DjgGTCWjUuCjJ6QDo1HB96PT/xCYuyJUP9WFbVDrLSbG4EZCvOCun2rNswZb0c3e4Jt/ws795esHA==}
|
||||
@@ -22892,6 +23007,10 @@ packages:
|
||||
verror: 1.10.0
|
||||
dev: true
|
||||
|
||||
/jsrsasign/10.6.1:
|
||||
resolution: {integrity: sha512-emiQ05haY9CRj1Ho/LiuCqr/+8RgJuWdiHYNglIg2Qjfz0n+pnUq9I2QHplXuOMO2EnAW1oCGC1++aU5VoWSlw==}
|
||||
dev: false
|
||||
|
||||
/jsx-ast-utils/3.3.3:
|
||||
resolution: {integrity: sha512-fYQHZTZ8jSfmWZ0iyzfwiU4WDX4HpHbMCZ3gPlWYiCl3BoeOTsqKBqnTVfH2rYT7eP5c3sVbeSPHnnJOaTrWiw==}
|
||||
engines: {node: '>=4.0'}
|
||||
@@ -22914,6 +23033,14 @@ packages:
|
||||
safe-buffer: 5.2.1
|
||||
dev: true
|
||||
|
||||
/jwk-to-pem/2.0.5:
|
||||
resolution: {integrity: sha512-L90jwellhO8jRKYwbssU9ifaMVqajzj3fpRjDKcsDzrslU9syRbFqfkXtT4B89HYAap+xsxNcxgBSB09ig+a7A==}
|
||||
dependencies:
|
||||
asn1.js: 5.4.1
|
||||
elliptic: 6.5.4
|
||||
safe-buffer: 5.2.1
|
||||
dev: false
|
||||
|
||||
/jwks-rsa/2.1.5:
|
||||
resolution: {integrity: sha512-IODtn1SwEm7n6GQZnQLY0oxKDrMh7n/jRH1MzE8mlxWMrh2NnMyOsXTebu8vJ1qCpmuTJcL4DdiE0E4h8jnwsA==}
|
||||
engines: {node: '>=10 < 13 || >=14'}
|
||||
@@ -24137,7 +24264,10 @@ packages:
|
||||
|
||||
/minimalistic-assert/1.0.1:
|
||||
resolution: {integrity: sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==}
|
||||
dev: true
|
||||
|
||||
/minimalistic-crypto-utils/1.0.1:
|
||||
resolution: {integrity: sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==}
|
||||
dev: false
|
||||
|
||||
/minimatch/3.0.4:
|
||||
resolution: {integrity: sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==}
|
||||
@@ -27290,6 +27420,17 @@ packages:
|
||||
resolution: {integrity: sha512-QFADYnsVoBMw1srW7OVKEYjG+MbIa49s54w1MA1EDY6r2r/sTcKKYqRX1f4GYvnXP7eN/Pe9HFcX+hwzmrXRHA==}
|
||||
dev: true
|
||||
|
||||
/pvtsutils/1.3.2:
|
||||
resolution: {integrity: sha512-+Ipe2iNUyrZz+8K/2IOo+kKikdtfhRKzNpQbruF2URmqPtoqAs8g3xS7TJvFF2GcPXjh7DkqMnpVveRFq4PgEQ==}
|
||||
dependencies:
|
||||
tslib: 2.4.1
|
||||
dev: false
|
||||
|
||||
/pvutils/1.1.3:
|
||||
resolution: {integrity: sha512-pMpnA0qRdFp32b1sJl1wOJNxZLQ2cbQx+k6tjNtZ8CpvVhNqEPRgivZ2WOUev2YMajecdH7ctUPDvEe87nariQ==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
dev: false
|
||||
|
||||
/q/1.4.1:
|
||||
resolution: {integrity: sha512-/CdEdaw49VZVmyIDGUQKDDT53c7qBkO6g5CefWz91Ae+l4+cRtcDYwMTXh6me4O8TMldeGHG3N2Bl84V78Ywbg==}
|
||||
engines: {node: '>=0.6.0', teleport: '>=0.2.0'}
|
||||
|
||||
Reference in New Issue
Block a user