mirror of
https://github.com/SrIzan10/next-auth.git
synced 2026-05-01 10:55:20 +00:00
Compare commits
14 Commits
@auth/core
...
@auth/svel
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6abccd9a0 | ||
|
|
2f35daae37 | ||
|
|
a0f3b04c43 | ||
|
|
c7dec376a1 | ||
|
|
925a52e0ec | ||
|
|
2318e44de4 | ||
|
|
d73812bce5 | ||
|
|
ee36d09a08 | ||
|
|
0cb7fd2e7c | ||
|
|
3b414bd7b5 | ||
|
|
37bb6ebd2c | ||
|
|
2ecf52c342 | ||
|
|
cda07c239e | ||
|
|
fa60b79abe |
4
.github/ISSUE_TEMPLATE/3_bug_adapter.yml
vendored
4
.github/ISSUE_TEMPLATE/3_bug_adapter.yml
vendored
@@ -29,10 +29,10 @@ body:
|
|||||||
- "@next-auth/mongodb-adapter"
|
- "@next-auth/mongodb-adapter"
|
||||||
- "@next-auth/neo4j-adapter"
|
- "@next-auth/neo4j-adapter"
|
||||||
- "@next-auth/pouchdb-adapter"
|
- "@next-auth/pouchdb-adapter"
|
||||||
- "@next-auth/prisma-adapter"
|
- "@auth/prisma-adapter"
|
||||||
- "@next-auth/sequelize-adapter"
|
- "@next-auth/sequelize-adapter"
|
||||||
- "@next-auth/supabase-adapter"
|
- "@next-auth/supabase-adapter"
|
||||||
- "@next-auth/typeorm-legacy-adapter"
|
- "@auth/typeorm-adapter"
|
||||||
- "@next-auth/upstash-redis-adapter"
|
- "@next-auth/upstash-redis-adapter"
|
||||||
- "@next-auth/xata-adapter"
|
- "@next-auth/xata-adapter"
|
||||||
validations:
|
validations:
|
||||||
|
|||||||
6
.github/issue-labeler.yml
vendored
6
.github/issue-labeler.yml
vendored
@@ -25,7 +25,7 @@ pouchdb:
|
|||||||
- "@next-auth/pouchdb-adapter"
|
- "@next-auth/pouchdb-adapter"
|
||||||
|
|
||||||
prisma:
|
prisma:
|
||||||
- "@next-auth/prisma-adapter"
|
- "@auth/prisma-adapter"
|
||||||
|
|
||||||
sequelize:
|
sequelize:
|
||||||
- "@next-auth/sequelize-adapter"
|
- "@next-auth/sequelize-adapter"
|
||||||
@@ -33,8 +33,8 @@ sequelize:
|
|||||||
supabase:
|
supabase:
|
||||||
- "@next-auth/supabase-adapter"
|
- "@next-auth/supabase-adapter"
|
||||||
|
|
||||||
typeorm-legacy:
|
typeorm:
|
||||||
- "@next-auth/typeorm-legacy-adapter"
|
- "@auth/typeorm-adapter"
|
||||||
|
|
||||||
upstash-redis:
|
upstash-redis:
|
||||||
- "@next-auth/upstash-redis-adapter"
|
- "@next-auth/upstash-redis-adapter"
|
||||||
|
|||||||
2
.github/pr-labeler.yml
vendored
2
.github/pr-labeler.yml
vendored
@@ -21,6 +21,6 @@ solidjs: ["packages/frameworks-solid-start/**/*"]
|
|||||||
supabase: ["packages/adapter-supabase/**/*"]
|
supabase: ["packages/adapter-supabase/**/*"]
|
||||||
svelte: ["packages/frameworks-sveltekit/**/*"]
|
svelte: ["packages/frameworks-sveltekit/**/*"]
|
||||||
test: ["**test**/*"]
|
test: ["**test**/*"]
|
||||||
typeorm-legacy: ["packages/adapter-typeorm-legacy/**/*"]
|
typeorm: ["packages/adapter-typeorm/**/*"]
|
||||||
upstash-redis: ["packages/adapter-upstash-redis/**/*"]
|
upstash-redis: ["packages/adapter-upstash-redis/**/*"]
|
||||||
xata: ["packages/adapter-xata/**/*"]
|
xata: ["packages/adapter-xata/**/*"]
|
||||||
|
|||||||
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@@ -29,7 +29,7 @@ on:
|
|||||||
- "@auth/prisma-adapter"
|
- "@auth/prisma-adapter"
|
||||||
- "@auth/sequelize-adapter"
|
- "@auth/sequelize-adapter"
|
||||||
- "@auth/supabase-adapter"
|
- "@auth/supabase-adapter"
|
||||||
- "@auth/typeorm-legacy-adapter"
|
- "@auth/typeorm-adapter"
|
||||||
- "@auth/upstash-redis-adapter"
|
- "@auth/upstash-redis-adapter"
|
||||||
- "@auth/xata-adapter"
|
- "@auth/xata-adapter"
|
||||||
- "next-auth"
|
- "next-auth"
|
||||||
@@ -52,7 +52,7 @@ on:
|
|||||||
- "adapter-prisma"
|
- "adapter-prisma"
|
||||||
- "adapter-sequelize"
|
- "adapter-sequelize"
|
||||||
- "adapter-supabase"
|
- "adapter-supabase"
|
||||||
- "adapter-typeorm-legacy"
|
- "adapter-typeorm"
|
||||||
- "adapter-upstash-redis"
|
- "adapter-upstash-redis"
|
||||||
- "adapter-xata"
|
- "adapter-xata"
|
||||||
- "next-auth"
|
- "next-auth"
|
||||||
|
|||||||
@@ -15,9 +15,9 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@next-auth/fauna-adapter": "workspace:*",
|
"@next-auth/fauna-adapter": "workspace:*",
|
||||||
"@next-auth/prisma-adapter": "workspace:*",
|
"@auth/prisma-adapter": "workspace:*",
|
||||||
"@next-auth/supabase-adapter": "workspace:*",
|
"@next-auth/supabase-adapter": "workspace:*",
|
||||||
"@next-auth/typeorm-legacy-adapter": "workspace:*",
|
"@auth/typeorm-adapter": "workspace:*",
|
||||||
"@prisma/client": "^3",
|
"@prisma/client": "^3",
|
||||||
"@supabase/supabase-js": "^2.0.5",
|
"@supabase/supabase-js": "^2.0.5",
|
||||||
"faunadb": "^4",
|
"faunadb": "^4",
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import WorkOS from "next-auth/providers/workos"
|
|||||||
|
|
||||||
// // Prisma
|
// // Prisma
|
||||||
// import { PrismaClient } from "@prisma/client"
|
// import { PrismaClient } from "@prisma/client"
|
||||||
// import { PrismaAdapter } from "@next-auth/prisma-adapter"
|
// import { PrismaAdapter } from "@auth/prisma-adapter"
|
||||||
// const client = globalThis.prisma || new PrismaClient()
|
// const client = globalThis.prisma || new PrismaClient()
|
||||||
// if (process.env.NODE_ENV !== "production") globalThis.prisma = client
|
// if (process.env.NODE_ENV !== "production") globalThis.prisma = client
|
||||||
// const adapter = PrismaAdapter(client)
|
// const adapter = PrismaAdapter(client)
|
||||||
@@ -51,8 +51,8 @@ import WorkOS from "next-auth/providers/workos"
|
|||||||
// const adapter = FaunaAdapter(client)
|
// const adapter = FaunaAdapter(client)
|
||||||
|
|
||||||
// // TypeORM
|
// // TypeORM
|
||||||
// import { TypeORMLegacyAdapter } from "@next-auth/typeorm-legacy-adapter"
|
// import { TypeORMAdapter } from "@auth/typeorm-adapter"
|
||||||
// const adapter = TypeORMLegacyAdapter({
|
// const adapter = TypeORMAdapter({
|
||||||
// type: "sqlite",
|
// type: "sqlite",
|
||||||
// name: "next-auth-test-memory",
|
// name: "next-auth-test-memory",
|
||||||
// database: "./typeorm/dev.db",
|
// database: "./typeorm/dev.db",
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@auth/core": "workspace:*",
|
"@auth/core": "workspace:*",
|
||||||
"@next-auth/fauna-adapter": "workspace:*",
|
"@next-auth/fauna-adapter": "workspace:*",
|
||||||
"@next-auth/prisma-adapter": "workspace:*",
|
"@auth/prisma-adapter": "workspace:*",
|
||||||
"@next-auth/supabase-adapter": "workspace:*",
|
"@next-auth/supabase-adapter": "workspace:*",
|
||||||
"@next-auth/typeorm-legacy-adapter": "workspace:*",
|
"@auth/typeorm-adapter": "workspace:*",
|
||||||
"@prisma/client": "^3",
|
"@prisma/client": "^3",
|
||||||
"@supabase/supabase-js": "^2.0.5",
|
"@supabase/supabase-js": "^2.0.5",
|
||||||
"faunadb": "^4",
|
"faunadb": "^4",
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import WorkOS from "@auth/core/providers/workos"
|
|||||||
|
|
||||||
// // Prisma
|
// // Prisma
|
||||||
// import { PrismaClient } from "@prisma/client"
|
// import { PrismaClient } from "@prisma/client"
|
||||||
// import { PrismaAdapter } from "@next-auth/prisma-adapter"
|
// import { PrismaAdapter } from "@auth/prisma-adapter"
|
||||||
// const client = globalThis.prisma || new PrismaClient()
|
// const client = globalThis.prisma || new PrismaClient()
|
||||||
// if (process.env.NODE_ENV !== "production") globalThis.prisma = client
|
// if (process.env.NODE_ENV !== "production") globalThis.prisma = client
|
||||||
// const adapter = PrismaAdapter(client)
|
// const adapter = PrismaAdapter(client)
|
||||||
@@ -55,8 +55,8 @@ import WorkOS from "@auth/core/providers/workos"
|
|||||||
// const adapter = FaunaAdapter(client)
|
// const adapter = FaunaAdapter(client)
|
||||||
|
|
||||||
// // TypeORM
|
// // TypeORM
|
||||||
// import { TypeORMLegacyAdapter } from "@next-auth/typeorm-legacy-adapter"
|
// import { TypeORMAdapter } from "@auth/typeorm-adapter"
|
||||||
// const adapter = TypeORMLegacyAdapter({
|
// const adapter = TypeORMAdapter({
|
||||||
// type: "sqlite",
|
// type: "sqlite",
|
||||||
// name: "next-auth-test-memory",
|
// name: "next-auth-test-memory",
|
||||||
// database: "./typeorm/dev.db",
|
// database: "./typeorm/dev.db",
|
||||||
|
|||||||
@@ -3,10 +3,9 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "nuxt build",
|
"build": "nuxt build",
|
||||||
"dev": "nuxt dev",
|
"dev": "nuxt prepare && nuxt dev",
|
||||||
"generate": "nuxt generate",
|
"generate": "nuxt generate",
|
||||||
"preview": "nuxt preview",
|
"preview": "nuxt preview"
|
||||||
"postinstall": "nuxt prepare"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nuxt/eslint-config": "^0.1.1",
|
"@nuxt/eslint-config": "^0.1.1",
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ Finally, we'll need to set up a database adapter to store verification tokens th
|
|||||||
|
|
||||||
An **Adapter** in Auth.js connects your application to whatever database or backend system you want to use to store data for users, their accounts, sessions, etc...
|
An **Adapter** in Auth.js connects your application to whatever database or backend system you want to use to store data for users, their accounts, sessions, etc...
|
||||||
|
|
||||||
For this tutorial, we're going to use the **MongoDB** adapter, other any of the other adapters will work just fine.
|
For this tutorial, we're going to use the **MongoDB** adapter, but any of the other adapters will work just fine.
|
||||||
|
|
||||||
First, let's start by installing the adapter package:
|
First, let's start by installing the adapter package:
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ Using the database strategy is very similar, but instead of preserving the `acce
|
|||||||
import { Auth } from "@auth/core"
|
import { Auth } from "@auth/core"
|
||||||
import { type TokenSet } from "@auth/core/types"
|
import { type TokenSet } from "@auth/core/types"
|
||||||
import Google from "@auth/core/providers/google"
|
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"
|
import { PrismaClient } from "@prisma/client"
|
||||||
|
|
||||||
const prisma = new PrismaClient()
|
const prisma = new PrismaClient()
|
||||||
|
|||||||
@@ -22,11 +22,18 @@ Next you will have to create some configuration files for Cypress.
|
|||||||
|
|
||||||
First, the primary cypress config:
|
First, the primary cypress config:
|
||||||
|
|
||||||
```js title="cypress.json"
|
```ts title="cypress.config.ts"
|
||||||
{
|
import { defineConfig } from 'cypress'
|
||||||
"baseUrl": "http://localhost:3000",
|
|
||||||
"chromeWebSecurity": false
|
export default defineConfig({
|
||||||
}
|
e2e: {
|
||||||
|
baseUrl: 'http://localhost:3000',
|
||||||
|
chromeWebSecurity: false,
|
||||||
|
setupNodeEvents(on, config) {
|
||||||
|
// implement node event listeners here
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
This initial Cypress config will tell Cypress where to find your site on initial launch as well as allow it to open up URLs at domains that aren't your page, for example to be able to login to a social provider.
|
This initial Cypress config will tell Cypress where to find your site on initial launch as well as allow it to open up URLs at domains that aren't your page, for example to be able to login to a social provider.
|
||||||
@@ -46,14 +53,24 @@ You must change the login credentials you want to use, but you can also redefine
|
|||||||
|
|
||||||
Third, if you're using the `cypress-social-login` plugin, you must add this to your `/cypress/plugins/index.js` file like so:
|
Third, if you're using the `cypress-social-login` plugin, you must add this to your `/cypress/plugins/index.js` file like so:
|
||||||
|
|
||||||
```js title="cypress/plugins/index.js"
|
```js title="cypress.config.ts" {3-4,10-14}
|
||||||
const { GoogleSocialLogin } = require("cypress-social-logins").plugins
|
import { defineConfig } from 'cypress'
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
|
const { GoogleSocialLogin } = require('cypress-social-logins').plugins
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
e2e: {
|
||||||
|
baseUrl: 'http://localhost:3000',
|
||||||
|
chromeWebSecurity: false,
|
||||||
|
setupNodeEvents(on, config) {
|
||||||
|
on('task', {
|
||||||
|
GoogleSocialLogin,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = (on, config) => {
|
|
||||||
on("task", {
|
|
||||||
GoogleSocialLogin: GoogleSocialLogin,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Finally, you can also add the following npm scripts to your `package.json`:
|
Finally, you can also add the following npm scripts to your `package.json`:
|
||||||
|
|||||||
@@ -273,19 +273,7 @@ const docusaurusConfig = {
|
|||||||
typedocAdapter("Neo4j"),
|
typedocAdapter("Neo4j"),
|
||||||
typedocAdapter("PouchDB"),
|
typedocAdapter("PouchDB"),
|
||||||
typedocAdapter("Prisma"),
|
typedocAdapter("Prisma"),
|
||||||
[
|
typedocAdapter("TypeORM"),
|
||||||
"docusaurus-plugin-typedoc",
|
|
||||||
{
|
|
||||||
...typedocConfig,
|
|
||||||
id: "typeorm",
|
|
||||||
plugin: [require.resolve("./typedoc-mdn-links")],
|
|
||||||
watch: process.env.TYPEDOC_WATCH,
|
|
||||||
entryPoints: [`../packages/adapter-typeorm-legacy/src/index.ts`],
|
|
||||||
tsconfig: `../packages/adapter-typeorm-legacy/tsconfig.json`,
|
|
||||||
out: `reference/adapter/typeorm`,
|
|
||||||
sidebar: { indexLabel: "TypeORM" },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
typedocAdapter("Sequelize"),
|
typedocAdapter("Sequelize"),
|
||||||
typedocAdapter("Supabase"),
|
typedocAdapter("Supabase"),
|
||||||
typedocAdapter("Upstash Redis"),
|
typedocAdapter("Upstash Redis"),
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
"eslint-plugin-svelte3": "^4.0.0",
|
"eslint-plugin-svelte3": "^4.0.0",
|
||||||
"prettier": "2.8.1",
|
"prettier": "2.8.1",
|
||||||
"prettier-plugin-svelte": "^2.8.1",
|
"prettier-plugin-svelte": "^2.8.1",
|
||||||
"turbo": "1.8.8",
|
"turbo": "1.10.1",
|
||||||
"typescript": "4.9.4"
|
"typescript": "4.9.4"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@@ -8,14 +8,14 @@
|
|||||||
</a>
|
</a>
|
||||||
<h3 align="center"><b>Prisma Adapter</b> - NextAuth.js / Auth.js</a></h3>
|
<h3 align="center"><b>Prisma Adapter</b> - NextAuth.js / Auth.js</a></h3>
|
||||||
<p align="center" style="align: center;">
|
<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" />
|
<img src="https://img.shields.io/badge/TypeScript-blue?style=flat-square" alt="TypeScript" />
|
||||||
</a>
|
</a>
|
||||||
<a href="https://npm.im/@next-auth/prisma-adapter">
|
<a href="https://npm.im/@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">
|
<img alt="npm" src="https://img.shields.io/npm/v/@auth/prisma-adapter?color=green&label=@auth/prisma-adapter&style=flat-square">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://www.npmtrends.com/@next-auth/prisma-adapter">
|
<a href="https://www.npmtrends.com/@auth/prisma-adapter">
|
||||||
<img src="https://img.shields.io/npm/dm/@next-auth/prisma-adapter?label=%20downloads&style=flat-square" alt="Downloads" />
|
<img src="https://img.shields.io/npm/dm/@auth/prisma-adapter?label=%20downloads&style=flat-square" alt="Downloads" />
|
||||||
</a>
|
</a>
|
||||||
<a href="https://github.com/nextauthjs/next-auth/stargazers">
|
<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" />
|
<img src="https://img.shields.io/github/stars/nextauthjs/next-auth?style=flat-square" alt="Github Stars" />
|
||||||
|
|||||||
@@ -1,14 +1,29 @@
|
|||||||
{
|
{
|
||||||
"name": "@next-auth/prisma-adapter",
|
"name": "@auth/prisma-adapter",
|
||||||
"version": "1.0.7",
|
"version": "1.0.0",
|
||||||
"description": "Prisma adapter for next-auth.",
|
"description": "Prisma adapter for Auth.js",
|
||||||
"homepage": "https://authjs.dev",
|
"homepage": "https://authjs.dev/reference/adapter/prisma",
|
||||||
"repository": "https://github.com/nextauthjs/next-auth",
|
"repository": "https://github.com/nextauthjs/next-auth",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/nextauthjs/next-auth/issues"
|
"url": "https://github.com/nextauthjs/next-auth/issues"
|
||||||
},
|
},
|
||||||
"author": "William Luke",
|
"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",
|
"license": "ISC",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"next-auth",
|
"next-auth",
|
||||||
@@ -32,22 +47,19 @@
|
|||||||
"dev": "prisma generate && tsc -w",
|
"dev": "prisma generate && tsc -w",
|
||||||
"studio": "prisma studio"
|
"studio": "prisma studio"
|
||||||
},
|
},
|
||||||
"files": [
|
"dependencies": {
|
||||||
"README.md",
|
"@auth/core": "workspace:*"
|
||||||
"dist"
|
},
|
||||||
],
|
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@prisma/client": ">=2.26.0 || >=3",
|
"@prisma/client": ">=2.26.0 || >=3 || >=4"
|
||||||
"next-auth": "^4"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@next-auth/adapter-test": "workspace:*",
|
"@next-auth/adapter-test": "workspace:*",
|
||||||
"@next-auth/tsconfig": "workspace:*",
|
"@next-auth/tsconfig": "workspace:*",
|
||||||
"@prisma/client": "^3.10.0",
|
"@prisma/client": "^4.15.0",
|
||||||
"jest": "^27.4.3",
|
"jest": "^27.4.3",
|
||||||
"mongodb": "^4.4.0",
|
"mongodb": "^4.4.0",
|
||||||
"next-auth": "workspace:*",
|
"prisma": "^4.15.0"
|
||||||
"prisma": "^3.10.0"
|
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"preset": "@next-auth/adapter-test/jest"
|
"preset": "@next-auth/adapter-test/jest"
|
||||||
|
|||||||
@@ -9,14 +9,14 @@
|
|||||||
* ## Installation
|
* ## Installation
|
||||||
*
|
*
|
||||||
* ```bash npm2yarn2pnpm
|
* ```bash npm2yarn2pnpm
|
||||||
* npm install next-auth @prisma/client @next-auth/prisma-adapter
|
* npm install @prisma/client @auth/prisma-adapter
|
||||||
* npm install prisma --save-dev
|
* npm install prisma --save-dev
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @module @next-auth/prisma-adapter
|
* @module @auth/prisma-adapter
|
||||||
*/
|
*/
|
||||||
import type { PrismaClient, Prisma } from "@prisma/client"
|
import type { PrismaClient, Prisma } from "@prisma/client"
|
||||||
import type { Adapter, AdapterAccount } from "next-auth/adapters"
|
import type { Adapter, AdapterAccount } from "@auth/core/adapters"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ## Setup
|
* ## Setup
|
||||||
@@ -26,7 +26,7 @@ import type { Adapter, AdapterAccount } from "next-auth/adapters"
|
|||||||
* ```js title="pages/api/auth/[...nextauth].js"
|
* ```js title="pages/api/auth/[...nextauth].js"
|
||||||
* import NextAuth from "next-auth"
|
* import NextAuth from "next-auth"
|
||||||
* import GoogleProvider from "next-auth/providers/google"
|
* 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"
|
* import { PrismaClient } from "@prisma/client"
|
||||||
*
|
*
|
||||||
* const prisma = new PrismaClient()
|
* const prisma = new PrismaClient()
|
||||||
|
|||||||
@@ -1,9 +1,25 @@
|
|||||||
{
|
{
|
||||||
"extends": "@next-auth/tsconfig/tsconfig.adapters.json",
|
"extends": "@next-auth/tsconfig/tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"allowJs": true,
|
||||||
|
"baseUrl": ".",
|
||||||
|
"isolatedModules": true,
|
||||||
|
"target": "ES2020",
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"outDir": ".",
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist"
|
"skipDefaultLibCheck": true,
|
||||||
|
"strictNullChecks": true,
|
||||||
|
"stripInternal": true,
|
||||||
|
"declarationMap": true,
|
||||||
|
"declaration": true
|
||||||
},
|
},
|
||||||
"include": ["."],
|
"include": [
|
||||||
"exclude": ["tests", "dist", "jest.config.js"]
|
"src/**/*"
|
||||||
}
|
],
|
||||||
|
"exclude": [
|
||||||
|
"*.js",
|
||||||
|
"*.d.ts",
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { Adapter } from "next-auth/adapters"
|
import type { Adapter } from "@auth/core/adapters"
|
||||||
import { createHash, randomUUID } from "crypto"
|
import { createHash, randomUUID } from "crypto"
|
||||||
|
|
||||||
const requiredMethods = [
|
const requiredMethods = [
|
||||||
@@ -58,7 +58,8 @@ export async function runBasicTests(options: TestOptions) {
|
|||||||
await options.db.connect?.()
|
await options.db.connect?.()
|
||||||
})
|
})
|
||||||
|
|
||||||
const { adapter, db, skipTests } = options
|
const { adapter: _adapter, db, skipTests } = options
|
||||||
|
const adapter = _adapter as Required<Adapter>
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
// @ts-expect-error This is only used for the TypeORM adapter
|
// @ts-expect-error This is only used for the TypeORM adapter
|
||||||
@@ -88,7 +89,7 @@ export async function runBasicTests(options: TestOptions) {
|
|||||||
providerAccountId: randomUUID(),
|
providerAccountId: randomUUID(),
|
||||||
type: "oauth",
|
type: "oauth",
|
||||||
access_token: randomUUID(),
|
access_token: randomUUID(),
|
||||||
expires_at: ONE_MONTH,
|
expires_at: ONE_MONTH / 1000,
|
||||||
id_token: randomUUID(),
|
id_token: randomUUID(),
|
||||||
refresh_token: randomUUID(),
|
refresh_token: randomUUID(),
|
||||||
token_type: "bearer",
|
token_type: "bearer",
|
||||||
|
|||||||
@@ -12,13 +12,13 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@auth/core": "workspace:*",
|
||||||
"@babel/cli": "^7.14.3",
|
"@babel/cli": "^7.14.3",
|
||||||
"@babel/plugin-transform-runtime": "^7.14.3",
|
"@babel/plugin-transform-runtime": "^7.14.3",
|
||||||
"@babel/preset-env": "^7.14.2",
|
"@babel/preset-env": "^7.14.2",
|
||||||
"@types/jest": "^26.0.23",
|
"@types/jest": "^26.0.23",
|
||||||
"@types/nodemailer": "^6.4.4",
|
"@types/nodemailer": "^6.4.4",
|
||||||
"jest": "^27.0.3",
|
"jest": "^27.0.3",
|
||||||
"next-auth": "workspace:*",
|
|
||||||
"ts-jest": "^27.0.3",
|
"ts-jest": "^27.0.3",
|
||||||
"typescript": "^4.2.4"
|
"typescript": "^4.2.4"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "@next-auth/tsconfig/tsconfig.adapters.json",
|
|
||||||
"compilerOptions": {
|
|
||||||
"rootDir": "src",
|
|
||||||
"outDir": "dist",
|
|
||||||
"experimentalDecorators": true,
|
|
||||||
"emitDecoratorMetadata": true,
|
|
||||||
"stripInternal": true
|
|
||||||
},
|
|
||||||
"include": ["."],
|
|
||||||
"exclude": ["tests", "dist", "jest.config.js"]
|
|
||||||
}
|
|
||||||
@@ -8,14 +8,14 @@
|
|||||||
</a>
|
</a>
|
||||||
<h3 align="center"><b>TypeORM Adapter</b> - NextAuth.js / Auth.js</a></h3>
|
<h3 align="center"><b>TypeORM Adapter</b> - NextAuth.js / Auth.js</a></h3>
|
||||||
<p align="center" style="align: center;">
|
<p align="center" style="align: center;">
|
||||||
<a href="https://npm.im/@next-auth/typeorm-legacy-adapter">
|
<a href="https://npm.im/@auth/typeorm-adapter">
|
||||||
<img src="https://img.shields.io/badge/TypeScript-blue?style=flat-square" alt="TypeScript" />
|
<img src="https://img.shields.io/badge/TypeScript-blue?style=flat-square" alt="TypeScript" />
|
||||||
</a>
|
</a>
|
||||||
<a href="https://npm.im/@next-auth/typeorm-legacy-adapter">
|
<a href="https://npm.im/@auth/typeorm-adapter">
|
||||||
<img alt="npm" src="https://img.shields.io/npm/v/@next-auth/typeorm-legacy-adapter?color=green&label=@next-auth/typeorm-legacy-adapter&style=flat-square">
|
<img alt="npm" src="https://img.shields.io/npm/v/@auth/typeorm-adapter?color=green&label=@auth/typeorm-adapter&style=flat-square">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://www.npmtrends.com/@next-auth/typeorm-legacy-adapter">
|
<a href="https://www.npmtrends.com/@auth/typeorm-adapter">
|
||||||
<img src="https://img.shields.io/npm/dm/@next-auth/typeorm-legacy-adapter?label=%20downloads&style=flat-square" alt="Downloads" />
|
<img src="https://img.shields.io/npm/dm/@auth/typeorm-adapter?label=%20downloads&style=flat-square" alt="Downloads" />
|
||||||
</a>
|
</a>
|
||||||
<a href="https://github.com/nextauthjs/next-auth/stargazers">
|
<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" />
|
<img src="https://img.shields.io/github/stars/nextauthjs/next-auth?style=flat-square" alt="Github Stars" />
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@next-auth/typeorm-legacy-adapter",
|
"name": "@auth/typeorm-adapter",
|
||||||
"version": "2.0.2",
|
"version": "1.0.0",
|
||||||
"description": "TypeORM (legacy) adapter for next-auth.",
|
"description": "TypeORM adapter for Auth.js.",
|
||||||
"homepage": "https://authjs.dev",
|
"homepage": "https://authjs.dev/reference/adapter/typeorm",
|
||||||
"repository": "https://github.com/nextauthjs/next-auth",
|
"repository": "https://github.com/nextauthjs/next-auth",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/nextauthjs/next-auth/issues"
|
"url": "https://github.com/nextauthjs/next-auth/issues"
|
||||||
@@ -11,11 +11,19 @@
|
|||||||
"contributors": [
|
"contributors": [
|
||||||
"Balázs Orbán <info@balazsorban.com>"
|
"Balázs Orbán <info@balazsorban.com>"
|
||||||
],
|
],
|
||||||
"main": "dist/index.js",
|
"type": "module",
|
||||||
|
"types": "./index.d.ts",
|
||||||
"files": [
|
"files": [
|
||||||
"README.md",
|
"*.js",
|
||||||
"dist"
|
"*.d.ts*",
|
||||||
|
"src"
|
||||||
],
|
],
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./index.d.ts",
|
||||||
|
"import": "./index.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"next-auth",
|
"next-auth",
|
||||||
@@ -38,26 +46,27 @@
|
|||||||
"test:containers": "tests/test.sh",
|
"test:containers": "tests/test.sh",
|
||||||
"test": "tests/test.sh"
|
"test": "tests/test.sh"
|
||||||
},
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@auth/core": "workspace:*"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@next-auth/adapter-test": "workspace:*",
|
"@next-auth/adapter-test": "workspace:*",
|
||||||
"@next-auth/tsconfig": "workspace:*",
|
"@next-auth/tsconfig": "workspace:*",
|
||||||
"jest": "^27.4.3",
|
"jest": "^27.4.3",
|
||||||
"mssql": "^7.2.1",
|
"mssql": "^7.2.1",
|
||||||
"mysql": "^2.18.1",
|
"mysql": "^2.18.1",
|
||||||
"next-auth": "workspace:*",
|
|
||||||
"pg": "^8.7.3",
|
"pg": "^8.7.3",
|
||||||
"sqlite3": "^5.0.8",
|
"sqlite3": "^5.0.8",
|
||||||
"typeorm": "0.3.7",
|
"typeorm": "0.3.15",
|
||||||
"typeorm-naming-strategies": "^4.1.0",
|
"typeorm-naming-strategies": "^4.1.0",
|
||||||
"typescript": "^4.7.4"
|
"typescript": "^4.7.4"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"mssql": "^6.2.1 || 7",
|
"mssql": "^6.2.1 || 7",
|
||||||
"mysql": "^2.18.1",
|
"mysql": "^2.18.1",
|
||||||
"next-auth": "^4",
|
|
||||||
"pg": "^8.2.1",
|
"pg": "^8.2.1",
|
||||||
"sqlite3": "^5.0.2",
|
"sqlite3": "^5.0.2",
|
||||||
"typeorm": "0.3.7"
|
"typeorm": "^0.3.7"
|
||||||
},
|
},
|
||||||
"peerDependenciesMeta": {
|
"peerDependenciesMeta": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
@@ -9,17 +9,17 @@
|
|||||||
* ## Installation
|
* ## Installation
|
||||||
*
|
*
|
||||||
* ```bash npm2yarn2pnpm
|
* ```bash npm2yarn2pnpm
|
||||||
* npm install next-auth @next-auth/typeorm-legacy-adapter typeorm
|
* npm install @auth/typeorm-adapter typeorm
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @module @next-auth/typeorm-legacy-adapter
|
* @module @auth/typeorm-adapter
|
||||||
*/
|
*/
|
||||||
import type {
|
import type {
|
||||||
Adapter,
|
Adapter,
|
||||||
AdapterUser,
|
AdapterUser,
|
||||||
AdapterAccount,
|
AdapterAccount,
|
||||||
AdapterSession,
|
AdapterSession,
|
||||||
} from "next-auth/adapters"
|
} from "@auth/core/adapters"
|
||||||
import { DataSourceOptions, DataSource, EntityManager } from "typeorm"
|
import { DataSourceOptions, DataSource, EntityManager } from "typeorm"
|
||||||
import * as defaultEntities from "./entities"
|
import * as defaultEntities from "./entities"
|
||||||
import { parseDataSourceConfig, updateConnectionEntities } from "./utils"
|
import { parseDataSourceConfig, updateConnectionEntities } from "./utils"
|
||||||
@@ -29,7 +29,7 @@ export const entities = defaultEntities
|
|||||||
export type Entities = typeof entities
|
export type Entities = typeof entities
|
||||||
|
|
||||||
/** This is the interface for the TypeORM adapter options. */
|
/** This is the interface for the TypeORM adapter options. */
|
||||||
export interface TypeORMLegacyAdapterOptions {
|
export interface TypeORMAdapterOptions {
|
||||||
/**
|
/**
|
||||||
* The {@link https://orkhan.gitbook.io/typeorm/docs/entities TypeORM entities} to create the database tables from.
|
* The {@link https://orkhan.gitbook.io/typeorm/docs/entities TypeORM entities} to create the database tables from.
|
||||||
*/
|
*/
|
||||||
@@ -70,16 +70,16 @@ export async function getManager(options: {
|
|||||||
*
|
*
|
||||||
* ```javascript title="pages/api/auth/[...nextauth].js"
|
* ```javascript title="pages/api/auth/[...nextauth].js"
|
||||||
* import NextAuth from "next-auth"
|
* import NextAuth from "next-auth"
|
||||||
* import { TypeORMLegacyAdapter } from "@next-auth/typeorm-legacy-adapter"
|
* import { TypeORMAdapter } from "@auth/typeorm-adapter"
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* export default NextAuth({
|
* export default NextAuth({
|
||||||
* adapter: TypeORMLegacyAdapter("yourconnectionstring"),
|
* adapter: TypeORMAdapter("yourconnectionstring"),
|
||||||
* ...
|
* ...
|
||||||
* })
|
* })
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* `TypeORMLegacyAdapter` takes either a connection string, or a [`ConnectionOptions`](https://github.com/typeorm/typeorm/blob/master/docs/connection-options.md) object as its first parameter.
|
* `TypeORMAdapter` takes either a connection string, or a [`ConnectionOptions`](https://github.com/typeorm/typeorm/blob/master/docs/connection-options.md) object as its first parameter.
|
||||||
*
|
*
|
||||||
* ## Advanced usage
|
* ## Advanced usage
|
||||||
*
|
*
|
||||||
@@ -93,7 +93,7 @@ export async function getManager(options: {
|
|||||||
*
|
*
|
||||||
* 1. Create a file containing your modified entities:
|
* 1. Create a file containing your modified entities:
|
||||||
*
|
*
|
||||||
* (The file below is based on the [default entities](https://github.com/nextauthjs/next-auth/blob/main/packages/adapter-typeorm-legacy/src/entities.ts))
|
* (The file below is based on the [default entities](https://github.com/nextauthjs/next-auth/blob/main/packages/adapter-typeorm/src/entities.ts))
|
||||||
*
|
*
|
||||||
* ```diff title="lib/entities.ts"
|
* ```diff title="lib/entities.ts"
|
||||||
* import {
|
* import {
|
||||||
@@ -231,15 +231,15 @@ export async function getManager(options: {
|
|||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* 2. Pass them to `TypeORMLegacyAdapter`
|
* 2. Pass them to `TypeORMAdapter`
|
||||||
*
|
*
|
||||||
* ```javascript title="pages/api/auth/[...nextauth].js"
|
* ```javascript title="pages/api/auth/[...nextauth].js"
|
||||||
* import NextAuth from "next-auth"
|
* import NextAuth from "next-auth"
|
||||||
* import { TypeORMLegacyAdapter } from "@next-auth/typeorm-legacy-adapter"
|
* import { TypeORMAdapter } from "@auth/typeorm-adapter"
|
||||||
* import * as entities from "lib/entities"
|
* import * as entities from "lib/entities"
|
||||||
*
|
*
|
||||||
* export default NextAuth({
|
* export default NextAuth({
|
||||||
* adapter: TypeORMLegacyAdapter("yourconnectionstring", { entities }),
|
* adapter: TypeORMAdapter("yourconnectionstring", { entities }),
|
||||||
* ...
|
* ...
|
||||||
* })
|
* })
|
||||||
* ```
|
* ```
|
||||||
@@ -260,7 +260,7 @@ export async function getManager(options: {
|
|||||||
*
|
*
|
||||||
* ```javascript title="pages/api/auth/[...nextauth].js"
|
* ```javascript title="pages/api/auth/[...nextauth].js"
|
||||||
* import NextAuth from "next-auth"
|
* import NextAuth from "next-auth"
|
||||||
* import { TypeORMLegacyAdapter } from "@next-auth/typeorm-legacy-adapter"
|
* import { TypeORMAdapter } from "@auth/typeorm-adapter"
|
||||||
* import { SnakeNamingStrategy } from 'typeorm-naming-strategies'
|
* import { SnakeNamingStrategy } from 'typeorm-naming-strategies'
|
||||||
* import { ConnectionOptions } from "typeorm"
|
* import { ConnectionOptions } from "typeorm"
|
||||||
*
|
*
|
||||||
@@ -275,14 +275,14 @@ export async function getManager(options: {
|
|||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* export default NextAuth({
|
* export default NextAuth({
|
||||||
* adapter: TypeORMLegacyAdapter(connection),
|
* adapter: TypeORMAdapter(connection),
|
||||||
* ...
|
* ...
|
||||||
* })
|
* })
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
export function TypeORMLegacyAdapter(
|
export function TypeORMAdapter(
|
||||||
dataSource: string | DataSourceOptions,
|
dataSource: string | DataSourceOptions,
|
||||||
options?: TypeORMLegacyAdapterOptions
|
options?: TypeORMAdapterOptions
|
||||||
): Adapter {
|
): Adapter {
|
||||||
const entities = options?.entities
|
const entities = options?.entities
|
||||||
const c = {
|
const c = {
|
||||||
@@ -328,8 +328,10 @@ export function TypeORMLegacyAdapter(
|
|||||||
},
|
},
|
||||||
async getUserByAccount(provider_providerAccountId) {
|
async getUserByAccount(provider_providerAccountId) {
|
||||||
const m = await getManager(c)
|
const m = await getManager(c)
|
||||||
|
// @ts-expect-error
|
||||||
const account = await m.findOne<AdapterAccount & { user: AdapterUser }>(
|
const account = await m.findOne<AdapterAccount & { user: AdapterUser }>(
|
||||||
"AccountEntity",
|
"AccountEntity",
|
||||||
|
// @ts-expect-error
|
||||||
{ where: provider_providerAccountId, relations: ["user"] }
|
{ where: provider_providerAccountId, relations: ["user"] }
|
||||||
)
|
)
|
||||||
if (!account) return null
|
if (!account) return null
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { runBasicTests } from "../../../adapter-test"
|
import { runBasicTests } from "../../../adapter-test"
|
||||||
import { TypeORMLegacyAdapter } from "../../src"
|
import { TypeORMAdapter } from "../../src"
|
||||||
import * as entities from "../custom-entities"
|
import * as entities from "../custom-entities"
|
||||||
import { db } from "../helpers"
|
import { db } from "../helpers"
|
||||||
import { SnakeNamingStrategy } from "typeorm-naming-strategies"
|
import { SnakeNamingStrategy } from "typeorm-naming-strategies"
|
||||||
@@ -18,7 +18,7 @@ const mysqlConfig: ConnectionOptions = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runBasicTests({
|
runBasicTests({
|
||||||
adapter: TypeORMLegacyAdapter(mysqlConfig, {
|
adapter: TypeORMAdapter(mysqlConfig, {
|
||||||
entities,
|
entities,
|
||||||
}),
|
}),
|
||||||
db: db(mysqlConfig, entities),
|
db: db(mysqlConfig, entities),
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { runBasicTests } from "../../../adapter-test"
|
import { runBasicTests } from "../../../adapter-test"
|
||||||
import { TypeORMLegacyAdapter } from "../../src"
|
import { TypeORMAdapter } from "../../src"
|
||||||
import { db } from "../helpers"
|
import { db } from "../helpers"
|
||||||
|
|
||||||
const mysqlConfig = {
|
const mysqlConfig = {
|
||||||
@@ -13,6 +13,6 @@ const mysqlConfig = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runBasicTests({
|
runBasicTests({
|
||||||
adapter: TypeORMLegacyAdapter(mysqlConfig),
|
adapter: TypeORMAdapter(mysqlConfig),
|
||||||
db: db(mysqlConfig),
|
db: db(mysqlConfig),
|
||||||
})
|
})
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { runBasicTests } from "../../../adapter-test"
|
import { runBasicTests } from "../../../adapter-test"
|
||||||
import { TypeORMLegacyAdapter } from "../../src"
|
import { TypeORMAdapter } from "../../src"
|
||||||
import * as entities from "../custom-entities"
|
import * as entities from "../custom-entities"
|
||||||
import { db } from "../helpers"
|
import { db } from "../helpers"
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@ const postgresConfig =
|
|||||||
"postgres://nextauth:password@localhost:5432/nextauth?synchronize=true"
|
"postgres://nextauth:password@localhost:5432/nextauth?synchronize=true"
|
||||||
|
|
||||||
runBasicTests({
|
runBasicTests({
|
||||||
adapter: TypeORMLegacyAdapter(postgresConfig, {
|
adapter: TypeORMAdapter(postgresConfig, {
|
||||||
entities,
|
entities,
|
||||||
}),
|
}),
|
||||||
db: db(postgresConfig, entities),
|
db: db(postgresConfig, entities),
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import { runBasicTests } from "../../../adapter-test"
|
import { runBasicTests } from "../../../adapter-test"
|
||||||
import { TypeORMLegacyAdapter } from "../../src"
|
import { TypeORMAdapter } from "../../src"
|
||||||
import { db } from "../helpers"
|
import { db } from "../helpers"
|
||||||
|
|
||||||
const postgresConfig =
|
const postgresConfig =
|
||||||
"postgres://nextauth:password@localhost:5432/nextauth?synchronize=true"
|
"postgres://nextauth:password@localhost:5432/nextauth?synchronize=true"
|
||||||
|
|
||||||
runBasicTests({
|
runBasicTests({
|
||||||
adapter: TypeORMLegacyAdapter(postgresConfig),
|
adapter: TypeORMAdapter(postgresConfig),
|
||||||
db: db(postgresConfig),
|
db: db(postgresConfig),
|
||||||
})
|
})
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { runBasicTests } from "../../../adapter-test"
|
import { runBasicTests } from "../../../adapter-test"
|
||||||
import { TypeORMLegacyAdapter } from "../../src"
|
import { TypeORMAdapter } from "../../src"
|
||||||
import * as entities from "../custom-entities"
|
import * as entities from "../custom-entities"
|
||||||
import { db } from "../helpers"
|
import { db } from "../helpers"
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ const sqliteConfig = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runBasicTests({
|
runBasicTests({
|
||||||
adapter: TypeORMLegacyAdapter(sqliteConfig, {
|
adapter: TypeORMAdapter(sqliteConfig, {
|
||||||
entities,
|
entities,
|
||||||
}),
|
}),
|
||||||
db: db(sqliteConfig, entities),
|
db: db(sqliteConfig, entities),
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { runBasicTests } from "../../../adapter-test"
|
import { runBasicTests } from "../../../adapter-test"
|
||||||
import { TypeORMLegacyAdapter } from "../../src"
|
import { TypeORMAdapter } from "../../src"
|
||||||
import { db } from "../helpers"
|
import { db } from "../helpers"
|
||||||
import { SnakeNamingStrategy } from "typeorm-naming-strategies"
|
import { SnakeNamingStrategy } from "typeorm-naming-strategies"
|
||||||
|
|
||||||
@@ -14,6 +14,6 @@ const sqliteConfig: DataSourceOptions = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runBasicTests({
|
runBasicTests({
|
||||||
adapter: TypeORMLegacyAdapter(sqliteConfig),
|
adapter: TypeORMAdapter(sqliteConfig),
|
||||||
db: db(sqliteConfig),
|
db: db(sqliteConfig),
|
||||||
})
|
})
|
||||||
27
packages/adapter-typeorm/tsconfig.json
Normal file
27
packages/adapter-typeorm/tsconfig.json
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"extends": "@next-auth/tsconfig/tsconfig.base.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"allowJs": true,
|
||||||
|
"baseUrl": ".",
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"target": "ES2020",
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"outDir": ".",
|
||||||
|
"rootDir": "src",
|
||||||
|
"skipDefaultLibCheck": true,
|
||||||
|
"strictNullChecks": true,
|
||||||
|
"stripInternal": true,
|
||||||
|
"declarationMap": true,
|
||||||
|
"declaration": true
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"*.js",
|
||||||
|
"*.d.ts",
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@auth/core",
|
"name": "@auth/core",
|
||||||
"version": "0.8.0",
|
"version": "0.8.2",
|
||||||
"description": "Authentication for the Web.",
|
"description": "Authentication for the Web.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"authentication",
|
"authentication",
|
||||||
|
|||||||
@@ -71,7 +71,7 @@
|
|||||||
*
|
*
|
||||||
* ```ts title=my-adapter.ts
|
* ```ts title=my-adapter.ts
|
||||||
* import { type Adapter } from "@auth/core/adapters"
|
* 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"
|
* import { PrismaClient } from "@prisma/client"
|
||||||
*
|
*
|
||||||
* const prisma = new PrismaClient()
|
* const prisma = new PrismaClient()
|
||||||
|
|||||||
@@ -159,8 +159,17 @@ export class SessionStore {
|
|||||||
* The JWT Session or database Session ID
|
* The JWT Session or database Session ID
|
||||||
* constructed from the cookie chunks.
|
* constructed from the cookie chunks.
|
||||||
*/
|
*/
|
||||||
get value() {
|
get value() {
|
||||||
return Object.values(this.#chunks)?.join("")
|
// 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");
|
||||||
|
|
||||||
|
return aSuffix - bSuffix;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Use the sorted keys to join the chunks in the correct order
|
||||||
|
return sortedKeys.map(key => this.#chunks[key]).join("");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Given a cookie, return a list of cookies, chunked to fit the allowed cookie size. */
|
/** Given a cookie, return a list of cookies, chunked to fit the allowed cookie size. */
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@auth/sveltekit",
|
"name": "@auth/sveltekit",
|
||||||
"version": "0.3.1",
|
"version": "0.3.2",
|
||||||
"description": "Authentication for SvelteKit.",
|
"description": "Authentication for SvelteKit.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"authentication",
|
"authentication",
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export async function signIn<
|
|||||||
const data = await res.clone().json()
|
const data = await res.clone().json()
|
||||||
const error = new URL(data.url).searchParams.get("error")
|
const error = new URL(data.url).searchParams.get("error")
|
||||||
|
|
||||||
if (redirect || !isSupportingReturn || !error) {
|
if (redirect || !isSupportingReturn) {
|
||||||
// TODO: Do not redirect for Credentials and Email providers by default in next major
|
// TODO: Do not redirect for Credentials and Email providers by default in next major
|
||||||
window.location.href = data.url ?? callbackUrl
|
window.location.href = data.url ?? callbackUrl
|
||||||
// If url contains a hash, the browser does not reload the page. We reload manually
|
// If url contains a hash, the browser does not reload the page. We reload manually
|
||||||
|
|||||||
514
pnpm-lock.yaml
generated
514
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
10
turbo.json
10
turbo.json
@@ -3,7 +3,7 @@
|
|||||||
"pipeline": {
|
"pipeline": {
|
||||||
"build": {
|
"build": {
|
||||||
"dependsOn": ["^build"],
|
"dependsOn": ["^build"],
|
||||||
"outputs": ["dist/**/*"]
|
"outputs": ["dist/**/*", "*.js", "*.d.ts", "*.d.ts.map"]
|
||||||
},
|
},
|
||||||
"next-auth#build": {
|
"next-auth#build": {
|
||||||
"dependsOn": ["^build"],
|
"dependsOn": ["^build"],
|
||||||
@@ -53,6 +53,7 @@
|
|||||||
"docs#dev": {
|
"docs#dev": {
|
||||||
"dependsOn": [
|
"dependsOn": [
|
||||||
"@auth/core#build",
|
"@auth/core#build",
|
||||||
|
"@auth/prisma-adapter#build",
|
||||||
"@auth/sveltekit#build",
|
"@auth/sveltekit#build",
|
||||||
"@next-auth/dgraph-adapter#build",
|
"@next-auth/dgraph-adapter#build",
|
||||||
"@next-auth/dynamodb-adapter#build",
|
"@next-auth/dynamodb-adapter#build",
|
||||||
@@ -62,10 +63,9 @@
|
|||||||
"@next-auth/mongodb-adapter#build",
|
"@next-auth/mongodb-adapter#build",
|
||||||
"@next-auth/neo4j-adapter#build",
|
"@next-auth/neo4j-adapter#build",
|
||||||
"@next-auth/pouchdb-adapter#build",
|
"@next-auth/pouchdb-adapter#build",
|
||||||
"@next-auth/prisma-adapter#build",
|
|
||||||
"@next-auth/sequelize-adapter#build",
|
"@next-auth/sequelize-adapter#build",
|
||||||
"@next-auth/supabase-adapter#build",
|
"@next-auth/supabase-adapter#build",
|
||||||
"@next-auth/typeorm-legacy-adapter#build",
|
"@auth/typeorm-adapter#build",
|
||||||
"@next-auth/upstash-redis-adapter#build",
|
"@next-auth/upstash-redis-adapter#build",
|
||||||
"@next-auth/xata-adapter#build",
|
"@next-auth/xata-adapter#build",
|
||||||
"^build",
|
"^build",
|
||||||
@@ -76,6 +76,7 @@
|
|||||||
"docs#build": {
|
"docs#build": {
|
||||||
"dependsOn": [
|
"dependsOn": [
|
||||||
"@auth/core#build",
|
"@auth/core#build",
|
||||||
|
"@auth/prisma-adapter#build",
|
||||||
"@auth/sveltekit#build",
|
"@auth/sveltekit#build",
|
||||||
"@next-auth/dgraph-adapter#build",
|
"@next-auth/dgraph-adapter#build",
|
||||||
"@next-auth/dynamodb-adapter#build",
|
"@next-auth/dynamodb-adapter#build",
|
||||||
@@ -85,10 +86,9 @@
|
|||||||
"@next-auth/mongodb-adapter#build",
|
"@next-auth/mongodb-adapter#build",
|
||||||
"@next-auth/neo4j-adapter#build",
|
"@next-auth/neo4j-adapter#build",
|
||||||
"@next-auth/pouchdb-adapter#build",
|
"@next-auth/pouchdb-adapter#build",
|
||||||
"@next-auth/prisma-adapter#build",
|
|
||||||
"@next-auth/sequelize-adapter#build",
|
"@next-auth/sequelize-adapter#build",
|
||||||
"@next-auth/supabase-adapter#build",
|
"@next-auth/supabase-adapter#build",
|
||||||
"@next-auth/typeorm-legacy-adapter#build",
|
"@auth/typeorm-adapter#build",
|
||||||
"@next-auth/upstash-redis-adapter#build",
|
"@next-auth/upstash-redis-adapter#build",
|
||||||
"@next-auth/xata-adapter#build",
|
"@next-auth/xata-adapter#build",
|
||||||
"^build",
|
"^build",
|
||||||
|
|||||||
Reference in New Issue
Block a user