Compare commits

...

12 Commits

Author SHA1 Message Date
GitHub Actions
0681531627 chore(release): bump package version(s) [skip ci] 2023-08-11 10:29:05 +00:00
Balázs Orbán
ea81c467e9 fix(ts): compatibility with next-auth v4 types (#8294)
* fix(ts): compatibility with `next-auth` v4

* revert

* stricter types
2023-08-11 11:26:03 +01:00
GitHub Actions
bf2835d38f chore(release): bump package version(s) [skip ci] 2023-08-11 08:26:58 +00:00
Simon Sardorf
89d230666b feat(adapters): standardize default table names to be singular (#8282)
standardize all table names in drizzle adapter to be singular
2023-08-10 12:18:21 +01:00
Jonathan Edenström
f86e56f78a fix: sort cookie chunks correctly (#8278)
* fix: sort cookie chunks correctly

* chore: remove v4 next-auth change
2023-08-10 12:18:00 +01:00
Balázs Orbán
fe20b943ae docs: Update README.md 2023-08-10 00:57:02 +02:00
Balázs Orbán
4678c4d4fc docs: Update README.md 2023-08-10 00:56:24 +02:00
Balázs Orbán
3eb3f8f107 docs: typo 2023-08-09 23:15:35 +02:00
Balázs Orbán
7fd03f38e3 docs: remove heading from README.md 2023-08-09 23:14:53 +02:00
Balázs Orbán
ae44b72765 Merge branch 'main' of github.com:nextauthjs/next-auth 2023-08-09 23:08:13 +02:00
Balázs Orbán
a996ab57e8 🤖 lazy commit 2023-08-09 23:07:28 +02:00
Thang Vu
ebdeaf740d chore: move Turbo env vars to top level 2023-08-09 19:07:01 +07:00
10 changed files with 195 additions and 36 deletions

View File

@@ -57,6 +57,8 @@ on:
- "adapter-xata"
- "next-auth"
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
FORCE_COLOR: true
jobs:
@@ -79,22 +81,12 @@ jobs:
run: pnpm install
- name: Build
run: pnpm build
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
- name: Run tests
run: pnpm test
timeout-minutes: 15
env:
UPSTASH_REDIS_URL: ${{ secrets.UPSTASH_REDIS_URL }}
UPSTASH_REDIS_KEY: ${{ secrets.UPSTASH_REDIS_KEY }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
- name: Upload Turbo artifacts
uses: actions/upload-artifact@v3
with:
name: turbo-report
path: .turbo/runs/
# - name: Run E2E tests
# if: github.repository == 'nextauthjs/next-auth'
# run: pnpm e2e

View File

@@ -1 +0,0 @@
packages/next-auth/README.md

153
README.md Normal file
View File

@@ -0,0 +1,153 @@
<p align="center">
<br/>
<a href="https://authjs.dev" target="_blank"><img width="96px" src="https://authjs.dev/img/logo/logo-sm.png" /></a>
<h3 align="center">Auth.js</h3>
<p align="center">Authentication for the Web.</p>
<p align="center">Open Source. Full Stack. Own Your Data.</p>
<p align="center" style="align: center;">
<a href="https://npm.im/@auth/prisma-adapter">
<img src="https://img.shields.io/badge/TypeScript-blue?style=flat-square" alt="TypeScript" />
</a>
<a href="https://www.npmtrends.com/next-auth">
<img src="https://img.shields.io/npm/dm/next-auth?style=flat-square" alt="Downloads" />
</a>
<a href="https://github.com/nextauthjs/next-auth/stargazers">
<img src="https://img.shields.io/github/stars/nextauthjs/next-auth?style=flat-square" alt="Github Stars" />
</a>
<a href="https://www.npmjs.com/package/next-auth">
<img src="https://img.shields.io/github/v/release/nextauthjs/next-auth?label=latest&style=flat-square" alt="Github Stable Release" />
</a>
</p>
</p>
Auth.js is a set of open-source packages that are built on Web Standard APIs for authentication in modern applications with any framework on any platform in any JS runtime.
See [authjs.dev](https://authjs.dev) for our framework-specific libraries, or check out [next-auth.js.org](https://next-auth.js.org) for `next-auth` (Next.js).
## Features
### Flexible and easy to use
- Designed to work with any OAuth service, it supports 2.0+, OIDC
- Built-in support for [many popular sign-in services](https://github.com/nextauthjs/next-auth/tree/main/packages/core/src/providers)
- Email/Passwordless authentication
- Bring Your Database - or none! - stateless authentication with any backend (Active Directory, LDAP, etc.)
- Runtime-agnostic, runs anywhere! (Vercel Edge Functions, Node.js, Serverless, etc.)
### Own your data
Auth.js can be used with or without a database.
- An open-source solution that allows you to keep control of your data
- Built-in support for [MySQL, MariaDB, Postgres, Microsoft SQL Server, MongoDB, SQLite, etc.](https://adapters.authjs.dev)
- Works great with databases from popular hosting providers
### Secure by default
- Promotes the use of passwordless sign-in mechanisms
- Designed to be secure by default and encourage best practices for safeguarding user data
- Uses Cross-Site Request Forgery (CSRF) Tokens on POST routes (sign in, sign out)
- Default cookie policy aims for the most restrictive policy appropriate for each cookie
- When JSON Web Tokens are used, they are encrypted by default (JWE) with A256GCM
- Features tab/window syncing and session polling to support short-lived sessions
- Attempts to implement the latest guidance published by [Open Web Application Security Project](https://owasp.org)
Advanced configuration allows you to define your routines to handle controlling what accounts are allowed to sign in, for encoding and decoding JSON Web Tokens and to set custom cookie security policies and session properties, so you can control who can sign in and how often sessions have to be re-validated.
### TypeScript
Auth.js libraries are written with type safety in mind. [Check out the docs](https://authjs.dev/getting-started/typescript) for more information.
## Security
If you think you have found a vulnerability (or are not sure) in Auth.js or any of the related packages (i.e. Adapters), we ask you to read our [Security Policy](https://authjs.dev/security) to reach out responsibly. Please do not open Pull Requests/Issues/Discussions before consulting with us.
## Acknowledgments
[Auth.js is made possible thanks to all of its contributors.](https://authjs.dev/contributors)
<a href="https://github.com/nextauthjs/next-auth/graphs/contributors">
<img width="500px" src="https://contrib.rocks/image?repo=nextauthjs/next-auth" />
</a>
<div>
<a href="https://vercel.com?utm_source=nextauthjs&utm_campaign=oss"></a>
</div>
### Support
We have an [OpenCollective](https://opencollective.com/nextauth) for individuals and companies looking to contribute financially to the project!
<!--sponsors start-->
<table>
<tbody>
<tr>
<td align="center" valign="top">
<a href="https://vercel.com" target="_blank">
<img width="128px" src="https://avatars.githubusercontent.com/u/14985020?v=4" alt="Vercel Logo" />
</a><br />
<div>Vercel</div><br />
<sub>🥉 Bronze Financial Sponsor <br /> ☁️ Infrastructure Support</sub>
</td>
<td align="center" valign="top">
<a href="https://prisma.io" target="_blank">
<img width="128px" src="https://avatars.githubusercontent.com/u/17219288?v=4" alt="Prisma Logo" />
</a><br />
<div>Prisma</div><br />
<sub>🥉 Bronze Financial Sponsor</sub>
</td>
<td align="center" valign="top">
<a href="https://clerk.com" target="_blank">
<img width="128px" src="https://avatars.githubusercontent.com/u/49538330?s=200&v=4" alt="Clerk Logo" />
</a><br />
<div>Clerk</div><br />
<sub>🥉 Bronze Financial Sponsor</sub>
</td>
<td align="center" valign="top">
<a href="https://lowdefy.com" target="_blank">
<img width="128px" src="https://avatars.githubusercontent.com/u/47087496?s=200&v=4" alt="Lowdefy Logo" />
</a><br />
<div>Lowdefy</div><br />
<sub>🥉 Bronze Financial Sponsor</sub>
</td>
<td align="center" valign="top">
<a href="https://workos.com" target="_blank">
<img width="128px" src="https://avatars.githubusercontent.com/u/47638084?s=200&v=4" alt="WorkOS Logo" />
</a><br />
<div>WorkOS</div><br />
<sub>🥉 Bronze Financial Sponsor</sub>
</td>
<td align="center" valign="top">
<a href="https://www.descope.com" target="_blank">
<img width="128px" src="https://avatars.githubusercontent.com/u/97479186?v=4" alt="Descope Logo" />
</a><br />
<div>Descope</div><br />
<sub>🥉 Bronze Financial Sponsor</sub>
</td>
<td align="center" valign="top">
<a href="https://checklyhq.com" target="_blank">
<img width="128px" src="https://avatars.githubusercontent.com/u/25982255?v=4" alt="Checkly Logo" />
</a><br />
<div>Checkly</div><br />
<sub>☁️ Infrastructure Support</sub>
</td>
<td align="center" valign="top">
<a href="https://superblog.ai/" target="_blank">
<img width="128px" src="https://d33wubrfki0l68.cloudfront.net/cdc4a3833bd878933fcc131655878dbf226ac1c5/10cd6/images/logo_bolt_small.png" alt="superblog Logo" />
</a><br />
<div>superblog</div><br />
<sub>☁️ Infrastructure Support</sub>
</td>
</tr><tr></tr>
</tbody>
</table>
<br />
<!--sponsors end-->
## Contributing
We're open to all community contributions! If you'd like to contribute in any way, please first read
our [Contributing Guide](https://github.com/nextauthjs/.github/blob/main/CONTRIBUTING.md).
## License
ISC

View File

@@ -1,6 +1,6 @@
{
"name": "@auth/drizzle-adapter",
"version": "0.2.1",
"version": "0.3.0",
"description": "Drizzle adapter for Auth.js.",
"homepage": "https://authjs.dev",
"repository": "https://github.com/nextauthjs/next-auth",

View File

@@ -77,7 +77,7 @@ import type { Adapter } from "@auth/core/adapters"
* } from "drizzle-orm/pg-core"
* import type { AdapterAccount } from '@auth/core/adapters'
*
* export const users = pgTable("users", {
* export const users = pgTable("user", {
* id: text("id").notNull().primaryKey(),
* name: text("name"),
* email: text("email").notNull(),
@@ -86,7 +86,7 @@ import type { Adapter } from "@auth/core/adapters"
* })
*
* export const accounts = pgTable(
* "accounts",
* "account",
* {
* userId: text("userId")
* .notNull()
@@ -107,7 +107,7 @@ import type { Adapter } from "@auth/core/adapters"
* })
* )
*
* export const sessions = pgTable("sessions", {
* export const sessions = pgTable("session", {
* sessionToken: text("sessionToken").notNull().primaryKey(),
* userId: text("userId")
* .notNull()
@@ -140,7 +140,7 @@ import type { Adapter } from "@auth/core/adapters"
* } from "drizzle-orm/mysql-core"
* import type { AdapterAccount } from "@auth/core/adapters"
*
* export const users = mysqlTable("users", {
* export const users = mysqlTable("user", {
* id: varchar("id", { length: 255 }).notNull().primaryKey(),
* name: varchar("name", { length: 255 }),
* email: varchar("email", { length: 255 }).notNull(),
@@ -149,7 +149,7 @@ import type { Adapter } from "@auth/core/adapters"
* })
*
* export const accounts = mysqlTable(
* "accounts",
* "account",
* {
* userId: varchar("userId", { length: 255 })
* .notNull()
@@ -170,7 +170,7 @@ import type { Adapter } from "@auth/core/adapters"
* })
* )
*
* export const sessions = mysqlTable("sessions", {
* export const sessions = mysqlTable("session", {
* sessionToken: varchar("sessionToken", { length: 255 }).notNull().primaryKey(),
* userId: varchar("userId", { length: 255 })
* .notNull()
@@ -197,7 +197,7 @@ import type { Adapter } from "@auth/core/adapters"
* import { integer, sqliteTable, text, primaryKey } from "drizzle-orm/sqlite-core"
* import type { AdapterAccount } from "@auth/core/adapters"
*
* export const users = sqliteTable("users", {
* export const users = sqliteTable("user", {
* id: text("id").notNull().primaryKey(),
* name: text("name"),
* email: text("email").notNull(),
@@ -206,7 +206,7 @@ import type { Adapter } from "@auth/core/adapters"
* })
*
* export const accounts = sqliteTable(
* "accounts",
* "account",
* {
* userId: text("userId")
* .notNull()
@@ -227,7 +227,7 @@ import type { Adapter } from "@auth/core/adapters"
* })
* )
*
* export const sessions = sqliteTable("sessions", {
* export const sessions = sqliteTable("session", {
* sessionToken: text("sessionToken").notNull().primaryKey(),
* userId: text("userId")
* .notNull()

View File

@@ -12,7 +12,7 @@ import type { Adapter, AdapterAccount } from "@auth/core/adapters"
import type { MySql2Database } from "drizzle-orm/mysql2"
export function createTables(mySqlTable: MySqlTableFn) {
const users = mySqlTable("users", {
const users = mySqlTable("user", {
id: varchar("id", { length: 255 }).notNull().primaryKey(),
name: varchar("name", { length: 255 }),
email: varchar("email", { length: 255 }).notNull(),
@@ -24,7 +24,7 @@ export function createTables(mySqlTable: MySqlTableFn) {
})
const accounts = mySqlTable(
"accounts",
"account",
{
userId: varchar("userId", { length: 255 })
.notNull()
@@ -49,7 +49,7 @@ export function createTables(mySqlTable: MySqlTableFn) {
})
)
const sessions = mySqlTable("sessions", {
const sessions = mySqlTable("session", {
sessionToken: varchar("sessionToken", { length: 255 })
.notNull()
.primaryKey(),
@@ -187,7 +187,7 @@ export function mySqlDrizzleAdapter(
return null
}
return dbAccount.users
return dbAccount.user
},
async deleteSession(sessionToken) {
const session =

View File

@@ -12,7 +12,7 @@ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js"
import type { Adapter, AdapterAccount } from "@auth/core/adapters"
export function createTables(pgTable: PgTableFn) {
const users = pgTable("users", {
const users = pgTable("user", {
id: text("id").notNull().primaryKey(),
name: text("name"),
email: text("email").notNull(),
@@ -21,7 +21,7 @@ export function createTables(pgTable: PgTableFn) {
})
const accounts = pgTable(
"accounts",
"account",
{
userId: text("userId")
.notNull()
@@ -42,7 +42,7 @@ export function createTables(pgTable: PgTableFn) {
})
)
const sessions = pgTable("sessions", {
const sessions = pgTable("session", {
sessionToken: text("sessionToken").notNull().primaryKey(),
userId: text("userId")
.notNull()
@@ -174,7 +174,7 @@ export function pgDrizzleAdapter(
return null
}
return dbAccount.users
return dbAccount.user
},
async deleteSession(sessionToken) {
const session = await client

View File

@@ -11,7 +11,7 @@ import {
import type { Adapter, AdapterAccount } from "@auth/core/adapters"
export function createTables(sqliteTable: SQLiteTableFn) {
const users = sqliteTable("users", {
const users = sqliteTable("user", {
id: text("id").notNull().primaryKey(),
name: text("name"),
email: text("email").notNull(),
@@ -20,7 +20,7 @@ export function createTables(sqliteTable: SQLiteTableFn) {
})
const accounts = sqliteTable(
"accounts",
"account",
{
userId: text("userId")
.notNull()
@@ -41,7 +41,7 @@ export function createTables(sqliteTable: SQLiteTableFn) {
})
)
const sessions = sqliteTable("sessions", {
const sessions = sqliteTable("session", {
sessionToken: text("sessionToken").notNull().primaryKey(),
userId: text("userId")
.notNull()
@@ -159,7 +159,7 @@ export function SQLiteDrizzleAdapter(
)
.get()
return results?.users ?? null
return results?.user ?? null
},
deleteSession(sessionToken) {
return (

View File

@@ -1,6 +1,6 @@
{
"name": "@auth/core",
"version": "0.10.2",
"version": "0.10.4",
"description": "Authentication for the Web.",
"keywords": [
"authentication",

View File

@@ -270,3 +270,18 @@ export interface Adapter {
token: string
}): Awaitable<VerificationToken | null>
}
// For compatibility with older versions of NextAuth.js
// @ts-expect-error
declare module "next-auth/adapters" {
type JsonObject = {
[Key in string]?: JsonValue
}
type JsonArray = JsonValue[]
type JsonPrimitive = string | number | boolean | null
type JsonValue = JsonPrimitive | JsonObject | JsonArray
interface AdapterAccount {
type: "oauth" | "email" | "oidc"
[key: string]: JsonValue | undefined
}
}

View File

@@ -162,8 +162,8 @@ export class SessionStore {
get value() {
// Sort the chunks by their keys before joining
const sortedKeys = Object.keys(this.#chunks).sort((a, b) => {
const aSuffix = parseInt(a.split(".")[1] || "0");
const bSuffix = parseInt(b.split(".")[1] || "0");
const aSuffix = parseInt(a.split(".").pop() || "0");
const bSuffix = parseInt(b.split(".").pop() || "0");
return aSuffix - bSuffix;
});