Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce @auth/prisma-adapter #7703

Merged
merged 45 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c2eb9b3
fix(docs): fix default `maxAge` formula (#7406)
vixeven Apr 30, 2023
d739e8e
feat(adapters): add Account mapping before database write (#7369)
balazsorban44 Apr 30, 2023
5400645
chore: improve errors, add more docs (#7415)
balazsorban44 May 1, 2023
542c35d
fix: loosen profile types
balazsorban44 May 1, 2023
62e2ad1
chore: type fixes
balazsorban44 May 1, 2023
92a0fc4
fix: allow handling OAuth callback error response
balazsorban44 May 1, 2023
e3bdb38
fix(docs): remove extra heading
balazsorban44 May 3, 2023
6f5a503
chore: use `@ts-ignore`
balazsorban44 May 4, 2023
d6bc65f
chore: support release any package as experimental
balazsorban44 May 4, 2023
99247ce
chore: separate manual release job
balazsorban44 May 4, 2023
e0b5f18
chore: skip test for manual release
balazsorban44 May 4, 2023
eaf5080
chore: tweak
balazsorban44 May 4, 2023
8f416b6
chore: tweaks
balazsorban44 May 4, 2023
b96f013
chore: tweak manual release version
balazsorban44 May 5, 2023
f00ac78
chore: reduce breaking changes on Account mapping
balazsorban44 May 10, 2023
7ffd361
chore: add build to manual publish
balazsorban44 May 10, 2023
c336b10
chore: move build to root
balazsorban44 May 10, 2023
f5de6cf
docs(example): update broken link (#7504)
remirobichet May 10, 2023
cca94bf
feat: add update session to core (#7505)
balazsorban44 May 10, 2023
f62c016
chore: revert `picture` to `image`
balazsorban44 May 12, 2023
220ee41
chore: Move next.config.js file into the correct directory (#7580)
ghoshnirmalya May 18, 2023
4baf2c8
docs: Cypress.Cookies.defaults removed (#7574)
roy9495 May 18, 2023
8373bc9
feat: allow empty `account` mapper
balazsorban44 May 19, 2023
7711eb0
Merge branch 'main' of github.com:nextauthjs/next-auth
balazsorban44 May 19, 2023
527fff6
chore: Add Descope as a 🥉 bronze financial sponsor (#7615)
dorsha May 21, 2023
461b52e
chore(playgrounds): Nuxt 3.5.1 (#7626)
wobsoriano May 22, 2023
17e2c2f
docs: adapter card text color on hover when on dark mode (#7672)
anampartho May 29, 2023
a47b4ce
docs: fix info card rendering in oauth-tutorial.mdx (#7662)
grahampcharles May 29, 2023
26a1bc5
feat: introduce `@auth/prisma-adapter`
balazsorban44 Jun 1, 2023
ec933f4
chore: update lock file
balazsorban44 Jun 1, 2023
395020c
Merge branch 'main' into feat/authjs-prisma
balazsorban44 Jun 1, 2023
70f2982
update lock file
balazsorban44 Jun 1, 2023
e362e8f
update adapter test suite
balazsorban44 Jun 1, 2023
da8007f
chore: allow manual release of any `@auth/*` package
balazsorban44 Jun 1, 2023
d7b9879
revert line changes
balazsorban44 Jun 1, 2023
909956f
revert line changes
balazsorban44 Jun 1, 2023
39ffb90
revert line changes
balazsorban44 Jun 1, 2023
050e484
fix syntax error
balazsorban44 Jun 1, 2023
18b8ae2
Merge branch 'main' into feat/authjs-prisma
balazsorban44 Jun 1, 2023
210375b
chore: re-add pnpm caching
balazsorban44 Jun 1, 2023
f177471
Merge branch 'main' into feat/authjs-prisma
balazsorban44 Jun 1, 2023
137572d
Merge branch 'main' into feat/authjs-prisma
balazsorban44 Jun 1, 2023
87b2ff9
Merge branch 'main' into feat/authjs-prisma
balazsorban44 Jun 1, 2023
b3ca695
tweak turbo
balazsorban44 Jun 1, 2023
21286ea
Merge branch 'main' into feat/authjs-prisma
balazsorban44 Jun 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/3_bug_adapter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ body:
- "@next-auth/mongodb-adapter"
- "@next-auth/neo4j-adapter"
- "@next-auth/pouchdb-adapter"
- "@next-auth/prisma-adapter"
- "@auth/prisma-adapter"
- "@next-auth/sequelize-adapter"
- "@next-auth/supabase-adapter"
- "@next-auth/typeorm-legacy-adapter"
Expand Down
2 changes: 1 addition & 1 deletion .github/issue-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pouchdb:
- "@next-auth/pouchdb-adapter"

prisma:
- "@next-auth/prisma-adapter"
- "@auth/prisma-adapter"

sequelize:
- "@next-auth/sequelize-adapter"
Expand Down
2 changes: 1 addition & 1 deletion apps/dev/nextjs-v4/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"license": "ISC",
"dependencies": {
"@next-auth/fauna-adapter": "workspace:*",
"@next-auth/prisma-adapter": "workspace:*",
"@auth/prisma-adapter": "workspace:*",
"@next-auth/supabase-adapter": "workspace:*",
"@next-auth/typeorm-legacy-adapter": "workspace:*",
"@prisma/client": "^3",
Expand Down
2 changes: 1 addition & 1 deletion apps/dev/nextjs-v4/pages/api/auth-old/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import WorkOS from "next-auth/providers/workos"

// // Prisma
// import { PrismaClient } from "@prisma/client"
// import { PrismaAdapter } from "@next-auth/prisma-adapter"
// import { PrismaAdapter } from "@auth/prisma-adapter"
// const client = globalThis.prisma || new PrismaClient()
// if (process.env.NODE_ENV !== "production") globalThis.prisma = client
// const adapter = PrismaAdapter(client)
Expand Down
2 changes: 1 addition & 1 deletion apps/dev/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@auth/core": "workspace:*",
"@next-auth/fauna-adapter": "workspace:*",
"@next-auth/prisma-adapter": "workspace:*",
"@auth/prisma-adapter": "workspace:*",
"@next-auth/supabase-adapter": "workspace:*",
"@next-auth/typeorm-legacy-adapter": "workspace:*",
"@prisma/client": "^3",
Expand Down
2 changes: 1 addition & 1 deletion apps/dev/nextjs/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import WorkOS from "@auth/core/providers/workos"

// // Prisma
// import { PrismaClient } from "@prisma/client"
// import { PrismaAdapter } from "@next-auth/prisma-adapter"
// import { PrismaAdapter } from "@auth/prisma-adapter"
// const client = globalThis.prisma || new PrismaClient()
// if (process.env.NODE_ENV !== "production") globalThis.prisma = client
// const adapter = PrismaAdapter(client)
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/guides/basics/refresh-token-rotation.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Using the database strategy is very similar, but instead of preserving the `acce
import { Auth } from "@auth/core"
import { type TokenSet } from "@auth/core/types"
import Google from "@auth/core/providers/google"
import { PrismaAdapter } from "@next-auth/prisma-adapter"
import { PrismaAdapter } from "@auth/prisma-adapter"
import { PrismaClient } from "@prisma/client"

const prisma = new PrismaClient()
Expand Down
10 changes: 5 additions & 5 deletions packages/adapter-prisma/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
</a>
<h3 align="center"><b>Prisma Adapter</b> - NextAuth.js / Auth.js</a></h3>
<p align="center" style="align: center;">
<a href="https://npm.im/@next-auth/prisma-adapter">
<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://npm.im/@next-auth/prisma-adapter">
<img alt="npm" src="https://img.shields.io/npm/v/@next-auth/prisma-adapter?color=green&label=@next-auth/prisma-adapter&style=flat-square">
<a href="https://npm.im/@auth/prisma-adapter">
<img alt="npm" src="https://img.shields.io/npm/v/@auth/prisma-adapter?color=green&label=@auth/prisma-adapter&style=flat-square">
</a>
<a href="https://www.npmtrends.com/@next-auth/prisma-adapter">
<img src="https://img.shields.io/npm/dm/@next-auth/prisma-adapter?label=%20downloads&style=flat-square" alt="Downloads" />
<a href="https://www.npmtrends.com/@auth/prisma-adapter">
<img src="https://img.shields.io/npm/dm/@auth/prisma-adapter?label=%20downloads&style=flat-square" alt="Downloads" />
</a>
<a href="https://github.com/nextauthjs/next-auth/stargazers">
<img src="https://img.shields.io/github/stars/nextauthjs/next-auth?style=flat-square" alt="Github Stars" />
Expand Down
42 changes: 27 additions & 15 deletions packages/adapter-prisma/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
{
"name": "@next-auth/prisma-adapter",
"version": "1.0.7",
"description": "Prisma adapter for next-auth.",
"homepage": "https://authjs.dev",
"name": "@auth/prisma-adapter",
"version": "1.0.0",
"description": "Prisma adapter for Auth.js",
"homepage": "https://authjs.dev/reference/adapter/prisma",
"repository": "https://github.com/nextauthjs/next-auth",
"bugs": {
"url": "https://github.com/nextauthjs/next-auth/issues"
},
"author": "William Luke",
"main": "dist/index.js",
"contributors": [
"Balázs Orbán <info@balazsorban.com>"
],
"type": "module",
"types": "./index.d.ts",
"files": [
"*.js",
"*.d.ts*",
"src"
],
"exports": {
".": {
"types": "./index.d.ts",
"import": "./index.js"
}
},
"license": "ISC",
"keywords": [
"next-auth",
Expand All @@ -32,24 +47,21 @@
"dev": "prisma generate && tsc -w",
"studio": "prisma studio"
},
"files": [
"README.md",
"dist"
],
"dependencies": {
"@auth/core": "workspace:*"
},
"peerDependencies": {
"@prisma/client": ">=2.26.0 || >=3",
"next-auth": "^4"
"@prisma/client": ">=2.26.0 || >=3 || >=4"
},
"devDependencies": {
"@next-auth/adapter-test": "workspace:*",
"@next-auth/tsconfig": "workspace:*",
"@prisma/client": "^3.10.0",
"@prisma/client": "^4.15.0",
"jest": "^27.4.3",
"mongodb": "^4.4.0",
"next-auth": "workspace:*",
"prisma": "^3.10.0"
"prisma": "^4.15.0"
},
"jest": {
"preset": "@next-auth/adapter-test/jest"
}
}
}
8 changes: 4 additions & 4 deletions packages/adapter-prisma/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
* ## Installation
*
* ```bash npm2yarn2pnpm
* npm install next-auth @prisma/client @next-auth/prisma-adapter
* npm install @prisma/client @auth/prisma-adapter
* npm install prisma --save-dev
* ```
*
* @module @next-auth/prisma-adapter
* @module @auth/prisma-adapter
*/
import type { PrismaClient, Prisma } from "@prisma/client"
import type { Adapter, AdapterAccount } from "next-auth/adapters"
import type { Adapter, AdapterAccount } from "@auth/core/adapters"

/**
* ## Setup
Expand All @@ -26,7 +26,7 @@ import type { Adapter, AdapterAccount } from "next-auth/adapters"
* ```js title="pages/api/auth/[...nextauth].js"
* import NextAuth from "next-auth"
* import GoogleProvider from "next-auth/providers/google"
* import { PrismaAdapter } from "@next-auth/prisma-adapter"
* import { PrismaAdapter } from "@auth/prisma-adapter"
* import { PrismaClient } from "@prisma/client"
*
* const prisma = new PrismaClient()
Expand Down
26 changes: 21 additions & 5 deletions packages/adapter-prisma/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
{
"extends": "@next-auth/tsconfig/tsconfig.adapters.json",
"extends": "@next-auth/tsconfig/tsconfig.base.json",
"compilerOptions": {
"allowJs": true,
"baseUrl": ".",
"isolatedModules": true,
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "node",
"outDir": ".",
"rootDir": "src",
"outDir": "dist"
"skipDefaultLibCheck": true,
"strictNullChecks": true,
"stripInternal": true,
"declarationMap": true,
"declaration": true
},
"include": ["."],
"exclude": ["tests", "dist", "jest.config.js"]
}
"include": [
"src/**/*"
],
"exclude": [
"*.js",
"*.d.ts",
]
}
7 changes: 4 additions & 3 deletions packages/adapter-test/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Adapter } from "next-auth/adapters"
import type { Adapter } from "@auth/core/adapters"
import { createHash, randomUUID } from "crypto"

const requiredMethods = [
Expand Down Expand Up @@ -58,7 +58,8 @@ export async function runBasicTests(options: TestOptions) {
await options.db.connect?.()
})

const { adapter, db, skipTests } = options
const { adapter: _adapter, db, skipTests } = options
const adapter = _adapter as Required<Adapter>

afterAll(async () => {
// @ts-expect-error This is only used for the TypeORM adapter
Expand Down Expand Up @@ -88,7 +89,7 @@ export async function runBasicTests(options: TestOptions) {
providerAccountId: randomUUID(),
type: "oauth",
access_token: randomUUID(),
expires_at: ONE_MONTH,
expires_at: ONE_MONTH / 1000,
id_token: randomUUID(),
refresh_token: randomUUID(),
token_type: "bearer",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
"license": "ISC",
"private": true,
"devDependencies": {
"@auth/core": "workspace:*",
"@babel/cli": "^7.14.3",
"@babel/plugin-transform-runtime": "^7.14.3",
"@babel/preset-env": "^7.14.2",
"@types/jest": "^26.0.23",
"@types/nodemailer": "^6.4.4",
"jest": "^27.0.3",
"next-auth": "workspace:*",
"ts-jest": "^27.0.3",
"typescript": "^4.2.4"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/adapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
*
* ```ts title=my-adapter.ts
* import { type Adapter } from "@auth/core/adapters"
* import { PrismaAdapter } from "@next-auth/prisma-adapter"
* import { PrismaAdapter } from "@auth/prisma-adapter"
* import { PrismaClient } from "@prisma/client"
*
* const prisma = new PrismaClient()
Expand Down
Loading