mirror of
https://github.com/SrIzan10/next-auth.git
synced 2026-05-01 10:55:20 +00:00
Compare commits
17 Commits
@auth/core
...
@auth/dgra
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65f4b9c942 | ||
|
|
1d29b0d220 | ||
|
|
cd92aa0c82 | ||
|
|
d414e01181 | ||
|
|
43deda5bfb | ||
|
|
7e79d8c509 | ||
|
|
ab051162a7 | ||
|
|
87298a0150 | ||
|
|
d6abccd9a0 | ||
|
|
2f35daae37 | ||
|
|
a0f3b04c43 | ||
|
|
c7dec376a1 | ||
|
|
925a52e0ec | ||
|
|
2318e44de4 | ||
|
|
d73812bce5 | ||
|
|
ee36d09a08 | ||
|
|
0cb7fd2e7c |
12
.github/ISSUE_TEMPLATE/3_bug_adapter.yml
vendored
12
.github/ISSUE_TEMPLATE/3_bug_adapter.yml
vendored
@@ -21,19 +21,19 @@ body:
|
|||||||
multiple: true
|
multiple: true
|
||||||
options:
|
options:
|
||||||
- "Custom adapter"
|
- "Custom adapter"
|
||||||
- "@next-auth/dgraph-adapter"
|
- "@auth/dgraph-adapter"
|
||||||
- "@next-auth/dynamodb-adapter"
|
- "@auth/dynamodb-adapter"
|
||||||
- "@next-auth/fauna-adapter"
|
- "@next-auth/fauna-adapter"
|
||||||
- "@next-auth/firebase-adapter"
|
- "@next-auth/firebase-adapter"
|
||||||
- "@next-auth/mikro-orm-adapter"
|
- "@auth/mikro-orm-adapter"
|
||||||
- "@next-auth/mongodb-adapter"
|
- "@auth/mongodb-adapter"
|
||||||
- "@next-auth/neo4j-adapter"
|
- "@next-auth/neo4j-adapter"
|
||||||
- "@next-auth/pouchdb-adapter"
|
- "@next-auth/pouchdb-adapter"
|
||||||
- "@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"
|
- "@auth/upstash-redis-adapter"
|
||||||
- "@next-auth/xata-adapter"
|
- "@next-auth/xata-adapter"
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|||||||
14
.github/issue-labeler.yml
vendored
14
.github/issue-labeler.yml
vendored
@@ -1,10 +1,10 @@
|
|||||||
# https://github.com/github/issue-labeler#basic-examples
|
# https://github.com/github/issue-labeler#basic-examples
|
||||||
|
|
||||||
dgraph:
|
dgraph:
|
||||||
- "@next-auth/dgraph-adapter"
|
- "@auth/dgraph-adapter"
|
||||||
|
|
||||||
dynamodb:
|
dynamodb:
|
||||||
- "@next-auth/dynamodb-adapter"
|
- "@auth/dynamodb-adapter"
|
||||||
|
|
||||||
fauna:
|
fauna:
|
||||||
- "@next-auth/fauna-adapter"
|
- "@next-auth/fauna-adapter"
|
||||||
@@ -13,10 +13,10 @@ firebase:
|
|||||||
- "@next-auth/firebase-adapter"
|
- "@next-auth/firebase-adapter"
|
||||||
|
|
||||||
mikro-orm:
|
mikro-orm:
|
||||||
- "@next-auth/mikro-orm-adapter"
|
- "@auth/mikro-orm-adapter"
|
||||||
|
|
||||||
mongodb:
|
mongodb:
|
||||||
- "@next-auth/mongodb-adapter"
|
- "@auth/mongodb-adapter"
|
||||||
|
|
||||||
neo4j:
|
neo4j:
|
||||||
- "@next-auth/neo4j-adapter"
|
- "@next-auth/neo4j-adapter"
|
||||||
@@ -33,11 +33,11 @@ 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"
|
- "@auth/upstash-redis-adapter"
|
||||||
|
|
||||||
xata:
|
xata:
|
||||||
- "@next-auth/xata-adapter"
|
- "@next-auth/xata-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"
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -38,6 +38,7 @@ packages/next-auth/next
|
|||||||
packages/*/*.js
|
packages/*/*.js
|
||||||
packages/*/*.d.ts
|
packages/*/*.d.ts
|
||||||
packages/*/*.d.ts.map
|
packages/*/*.d.ts.map
|
||||||
|
packages/*/lib
|
||||||
|
|
||||||
# Development app
|
# Development app
|
||||||
apps/dev/src/css
|
apps/dev/src/css
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
"@next-auth/fauna-adapter": "workspace:*",
|
"@next-auth/fauna-adapter": "workspace:*",
|
||||||
"@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",
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
"@next-auth/fauna-adapter": "workspace:*",
|
"@next-auth/fauna-adapter": "workspace:*",
|
||||||
"@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",
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
@@ -91,12 +91,12 @@ 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:
|
||||||
|
|
||||||
```bash npm2yarn2pnpm
|
```bash npm2yarn2pnpm
|
||||||
npm install -D @next-auth/mongodb-adapter mongodb
|
npm install -D @auth/mongodb-adapter mongodb
|
||||||
```
|
```
|
||||||
|
|
||||||
and create a simple MongoDB client:
|
and create a simple MongoDB client:
|
||||||
@@ -142,7 +142,7 @@ And now let's reference this new adapter from our Auth.js configuration file:
|
|||||||
```diff title="pages/api/auth/[...nextauth].ts"
|
```diff title="pages/api/auth/[...nextauth].ts"
|
||||||
import NextAuth from "next-auth"
|
import NextAuth from "next-auth"
|
||||||
import EmailProvider from "next-auth/providers/email"
|
import EmailProvider from "next-auth/providers/email"
|
||||||
+ import { MongoDBAdapter } from "@next-auth/mongodb-adapter"
|
+ import { MongoDBAdapter } from "@auth/mongodb-adapter"
|
||||||
+ import clientPromise from "../../../lib/mongodb/client"
|
+ import clientPromise from "../../../lib/mongodb/client"
|
||||||
|
|
||||||
export default NextAuth({
|
export default NextAuth({
|
||||||
|
|||||||
@@ -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"),
|
||||||
|
|||||||
@@ -8,14 +8,14 @@
|
|||||||
</a>
|
</a>
|
||||||
<h3 align="center"><b>Dgraph Adapter</b> - NextAuth.js / Auth.js</a></h3>
|
<h3 align="center"><b>Dgraph 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/dgraph-adapter">
|
<a href="https://npm.im/@auth/dgraph-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/dgraph-adapter">
|
<a href="https://npm.im/@auth/dgraph-adapter">
|
||||||
<img alt="npm" src="https://img.shields.io/npm/v/@next-auth/dgraph-adapter?color=green&label=@next-auth/dgraph-adapter&style=flat-square">
|
<img alt="npm" src="https://img.shields.io/npm/v/@auth/dgraph-adapter?color=green&label=@auth/dgraph-adapter&style=flat-square">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://www.npmtrends.com/@next-auth/dgraph-adapter">
|
<a href="https://www.npmtrends.com/@auth/dgraph-adapter">
|
||||||
<img src="https://img.shields.io/npm/dm/@next-auth/dgraph-adapter?label=%20downloads&style=flat-square" alt="Downloads" />
|
<img src="https://img.shields.io/npm/dm/@auth/dgraph-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,19 +1,30 @@
|
|||||||
{
|
{
|
||||||
"name": "@next-auth/dgraph-adapter",
|
"name": "@auth/dgraph-adapter",
|
||||||
"version": "1.0.6",
|
"version": "1.0.0",
|
||||||
"description": "Dgraph adapter for next-auth.",
|
"description": "Dgraph adapter for Auth.js",
|
||||||
"homepage": "https://authjs.dev",
|
"homepage": "https://authjs.dev",
|
||||||
"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": "Arnaud Derbey <arnaud@derbey.dev>",
|
"author": "Arnaud Derbey <arnaud@derbey.dev>",
|
||||||
"contributors": [],
|
"contributors": [
|
||||||
"main": "dist/index.js",
|
"Balázs Orbán <info@balazsorban.com>"
|
||||||
"files": [
|
|
||||||
"dist",
|
|
||||||
"index.d.ts"
|
|
||||||
],
|
],
|
||||||
|
"type": "module",
|
||||||
|
"types": "./index.d.ts",
|
||||||
|
"files": [
|
||||||
|
"*.js",
|
||||||
|
"*.d.ts*",
|
||||||
|
"lib",
|
||||||
|
"src"
|
||||||
|
],
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./index.d.ts",
|
||||||
|
"import": "./index.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"next-auth",
|
"next-auth",
|
||||||
@@ -29,10 +40,6 @@
|
|||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"test": "./tests/test.sh"
|
"test": "./tests/test.sh"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
|
||||||
"jsonwebtoken": "^8.5.1",
|
|
||||||
"next-auth": "^4"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@next-auth/adapter-test": "workspace:*",
|
"@next-auth/adapter-test": "workspace:*",
|
||||||
"@next-auth/tsconfig": "workspace:*",
|
"@next-auth/tsconfig": "workspace:*",
|
||||||
@@ -40,12 +47,12 @@
|
|||||||
"@types/jsonwebtoken": "^8.5.5",
|
"@types/jsonwebtoken": "^8.5.5",
|
||||||
"@types/node-fetch": "^2.5.11",
|
"@types/node-fetch": "^2.5.11",
|
||||||
"jest": "^27.4.3",
|
"jest": "^27.4.3",
|
||||||
"next-auth": "workspace:*",
|
"ts-jest": "^27.0.3",
|
||||||
"ts-jest": "^27.0.3"
|
"undici": "5.22.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"jsonwebtoken": "^8.5.1",
|
"@auth/core": "workspace:*",
|
||||||
"node-fetch": "^2.6.1"
|
"jsonwebtoken": "^8.5.1"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"preset": "@next-auth/adapter-test/jest"
|
"preset": "@next-auth/adapter-test/jest"
|
||||||
|
|||||||
@@ -9,18 +9,18 @@
|
|||||||
* ## Installation
|
* ## Installation
|
||||||
*
|
*
|
||||||
* ```bash npm2yarn2pnpm
|
* ```bash npm2yarn2pnpm
|
||||||
* npm install next-auth @next-auth/dgraph-adapter
|
* npm install next-auth @auth/dgraph-adapter
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @module @next-auth/dgraph-adapter
|
* @module @auth/dgraph-adapter
|
||||||
*/
|
*/
|
||||||
import { client as dgraphClient } from "./client"
|
import { client as dgraphClient } from "./lib/client"
|
||||||
import { format } from "./utils"
|
import { format } from "./lib/utils"
|
||||||
import type { Adapter } from "next-auth/adapters"
|
import type { Adapter } from "@auth/core/adapters"
|
||||||
import type { DgraphClientParams } from "./client"
|
import type { DgraphClientParams } from "./lib/client"
|
||||||
import * as defaultFragments from "./graphql/fragments"
|
import * as defaultFragments from "./lib/graphql/fragments"
|
||||||
|
|
||||||
export type { DgraphClientParams, DgraphClientError } from "./client"
|
export type { DgraphClientParams, DgraphClientError } from "./lib/client"
|
||||||
|
|
||||||
/** This is the interface of the Dgraph adapter options. */
|
/** This is the interface of the Dgraph adapter options. */
|
||||||
export interface DgraphAdapterOptions {
|
export interface DgraphAdapterOptions {
|
||||||
@@ -28,7 +28,7 @@ export interface DgraphAdapterOptions {
|
|||||||
* The GraphQL {@link https://dgraph.io/docs/query-language/fragments/ Fragments} you can supply to the adapter
|
* The GraphQL {@link https://dgraph.io/docs/query-language/fragments/ Fragments} you can supply to the adapter
|
||||||
* to define how the shapes of the `user`, `account`, `session`, `verificationToken` entities look.
|
* to define how the shapes of the `user`, `account`, `session`, `verificationToken` entities look.
|
||||||
*
|
*
|
||||||
* By default the adapter will uses the [default defined fragments](https://github.com/nextauthjs/next-auth/blob/main/packages/adapter-dgraph/src/graphql/fragments.ts)
|
* By default the adapter will uses the [default defined fragments](https://github.com/nextauthjs/next-auth/blob/main/packages/adapter-dgraph/src/lib/graphql/fragments.ts)
|
||||||
* , this config option allows to extend them.
|
* , this config option allows to extend them.
|
||||||
*/
|
*/
|
||||||
fragments?: {
|
fragments?: {
|
||||||
@@ -48,7 +48,7 @@ export { format }
|
|||||||
*
|
*
|
||||||
* ```ts title="pages/api/auth/[...nextauth].js"
|
* ```ts title="pages/api/auth/[...nextauth].js"
|
||||||
* import NextAuth from "next-auth"
|
* import NextAuth from "next-auth"
|
||||||
* import { DgraphAdapter } from "@next-auth/dgraph-adapter"
|
* import { DgraphAdapter } from "@auth/dgraph-adapter"
|
||||||
*
|
*
|
||||||
* export default NextAuth({
|
* export default NextAuth({
|
||||||
* providers: [],
|
* providers: [],
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
import * as jwt from "jsonwebtoken"
|
import * as jwt from "jsonwebtoken"
|
||||||
import fetch from "node-fetch"
|
|
||||||
|
|
||||||
import type { HeadersInit } from "node-fetch"
|
|
||||||
|
|
||||||
export interface DgraphClientParams {
|
export interface DgraphClientParams {
|
||||||
endpoint: string
|
endpoint: string
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
import { DgraphAdapter, format } from "../src"
|
import { DgraphAdapter, format } from "../src"
|
||||||
import { client as dgraphClient } from "../src/client"
|
import { client as dgraphClient } from "../src/lib/client"
|
||||||
import * as fragments from "../src/graphql/fragments"
|
import * as fragments from "../src/lib/graphql/fragments"
|
||||||
import { runBasicTests } from "@next-auth/adapter-test"
|
import { runBasicTests } from "@next-auth/adapter-test"
|
||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
|
|
||||||
import type { DgraphClientParams } from "../src"
|
import type { DgraphClientParams } from "../src"
|
||||||
|
|
||||||
|
globalThis.fetch ??= require("undici").fetch
|
||||||
|
|
||||||
const params: DgraphClientParams = {
|
const params: DgraphClientParams = {
|
||||||
endpoint: "http://localhost:8080/graphql",
|
endpoint: "http://localhost:8080/graphql",
|
||||||
authToken: "test",
|
authToken: "test",
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ dgraph/standalone
|
|||||||
|
|
||||||
echo "Waiting 15 sec for db to start..." && sleep 15
|
echo "Waiting 15 sec for db to start..." && sleep 15
|
||||||
|
|
||||||
head -n -1 src/graphql/schema.gql > tests/test.schema.gql
|
head -n -1 src/lib/graphql/schema.gql > tests/test.schema.gql
|
||||||
PUBLIC_KEY=$(sed 's/$/\\n/' tests/public.key | tr -d '\n')
|
PUBLIC_KEY=$(sed 's/$/\\n/' tests/public.key | tr -d '\n')
|
||||||
echo "# Dgraph.Authorization {\"VerificationKey\":\"$PUBLIC_KEY\",\"Namespace\":\"https://dgraph.io/jwt/claims\",\"Header\":\"Authorization\",\"Algo\":\"RS256\"}" >> tests/test.schema.gql
|
echo "# Dgraph.Authorization {\"VerificationKey\":\"$PUBLIC_KEY\",\"Namespace\":\"https://dgraph.io/jwt/claims\",\"Header\":\"Authorization\",\"Algo\":\"RS256\"}" >> tests/test.schema.gql
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +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
|
||||||
},
|
},
|
||||||
"exclude": ["tests", "dist", "jest.config.js"]
|
"include": [
|
||||||
}
|
"src/**/*"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"*.js",
|
||||||
|
"*.d.ts",
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -8,14 +8,14 @@
|
|||||||
</a>
|
</a>
|
||||||
<h3 align="center"><b>DynamoDB Adapter</b> - NextAuth.js / Auth.js</a></h3>
|
<h3 align="center"><b>DynamoDB 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/dynamodb-adapter">
|
<a href="https://npm.im/@auth/dynamodb-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/dynamodb-adapter">
|
<a href="https://npm.im/@auth/dynamodb-adapter">
|
||||||
<img alt="npm" src="https://img.shields.io/npm/v/@next-auth/dynamodb-adapter?color=green&label=@next-auth/dynamodb-adapter&style=flat-square">
|
<img alt="npm" src="https://img.shields.io/npm/v/@auth/dynamodb-adapter?color=green&label=@auth/dynamodb-adapter&style=flat-square">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://www.npmtrends.com/@next-auth/dynamodb-adapter">
|
<a href="https://www.npmtrends.com/@auth/dynamodb-adapter">
|
||||||
<img src="https://img.shields.io/npm/dm/@next-auth/dynamodb-adapter?label=%20downloads&style=flat-square" alt="Downloads" />
|
<img src="https://img.shields.io/npm/dm/@auth/dynamodb-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,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@next-auth/dynamodb-adapter",
|
"name": "@auth/dynamodb-adapter",
|
||||||
"repository": "https://github.com/nextauthjs/next-auth",
|
"repository": "https://github.com/nextauthjs/next-auth",
|
||||||
"version": "3.0.2",
|
"version": "1.0.0",
|
||||||
"description": "AWS DynamoDB adapter for next-auth.",
|
"description": "AWS DynamoDB adapter for next-auth.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"next-auth",
|
"next-auth",
|
||||||
@@ -9,18 +9,10 @@
|
|||||||
"oauth",
|
"oauth",
|
||||||
"dynamodb"
|
"dynamodb"
|
||||||
],
|
],
|
||||||
"type": "module",
|
|
||||||
"types": "./index.d.ts",
|
|
||||||
"homepage": "https://authjs.dev",
|
"homepage": "https://authjs.dev",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/nextauthjs/next-auth/issues"
|
"url": "https://github.com/nextauthjs/next-auth/issues"
|
||||||
},
|
},
|
||||||
"exports": {
|
|
||||||
".": {
|
|
||||||
"types": "./index.d.ts",
|
|
||||||
"import": "./index.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"private": false,
|
"private": false,
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
@@ -32,19 +24,27 @@
|
|||||||
"clean": "rm -rf index.*",
|
"clean": "rm -rf index.*",
|
||||||
"build": "pnpm clean && tsc"
|
"build": "pnpm clean && tsc"
|
||||||
},
|
},
|
||||||
|
"author": "Pol Marnette",
|
||||||
|
"contributors": [
|
||||||
|
"Balázs Orbán <info@balazsorban.com>"
|
||||||
|
],
|
||||||
|
"license": "ISC",
|
||||||
|
"type": "module",
|
||||||
|
"types": "./index.d.ts",
|
||||||
"files": [
|
"files": [
|
||||||
"README.md",
|
"*.js",
|
||||||
"index.js",
|
"*.d.ts*",
|
||||||
"index.d.ts",
|
|
||||||
"index.d.ts.map",
|
|
||||||
"src"
|
"src"
|
||||||
],
|
],
|
||||||
"author": "Pol Marnette",
|
"exports": {
|
||||||
"license": "ISC",
|
".": {
|
||||||
|
"types": "./index.d.ts",
|
||||||
|
"import": "./index.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@aws-sdk/client-dynamodb": "^3.36.1",
|
"@aws-sdk/client-dynamodb": "^3.36.1",
|
||||||
"@aws-sdk/lib-dynamodb": "^3.36.1",
|
"@aws-sdk/lib-dynamodb": "^3.36.1"
|
||||||
"next-auth": "^4"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@aws-sdk/client-dynamodb": "^3.36.1",
|
"@aws-sdk/client-dynamodb": "^3.36.1",
|
||||||
@@ -52,11 +52,9 @@
|
|||||||
"@next-auth/adapter-test": "workspace:*",
|
"@next-auth/adapter-test": "workspace:*",
|
||||||
"@next-auth/tsconfig": "workspace:*",
|
"@next-auth/tsconfig": "workspace:*",
|
||||||
"@shelf/jest-dynamodb": "^2.1.0",
|
"@shelf/jest-dynamodb": "^2.1.0",
|
||||||
"@types/uuid": "^9.0.0",
|
"jest": "^27.4.3"
|
||||||
"jest": "^27.4.3",
|
|
||||||
"next-auth": "workspace:*"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"uuid": "^9.0.0"
|
"@auth/core": "workspace:*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,12 +9,11 @@
|
|||||||
* ## Installation
|
* ## Installation
|
||||||
*
|
*
|
||||||
* ```bash npm2yarn2pnpm
|
* ```bash npm2yarn2pnpm
|
||||||
* npm install next-auth @next-auth/dynamodb-adapter
|
* npm install next-auth @auth/dynamodb-adapter
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @module @next-auth/dynamodb-adapter
|
* @module @auth/dynamodb-adapter
|
||||||
*/
|
*/
|
||||||
import { v4 as uuid } from "uuid"
|
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
BatchWriteCommandInput,
|
BatchWriteCommandInput,
|
||||||
@@ -26,7 +25,7 @@ import type {
|
|||||||
AdapterAccount,
|
AdapterAccount,
|
||||||
AdapterUser,
|
AdapterUser,
|
||||||
VerificationToken,
|
VerificationToken,
|
||||||
} from "next-auth/adapters"
|
} from "@auth/core/adapters"
|
||||||
|
|
||||||
export interface DynamoDBAdapterOptions {
|
export interface DynamoDBAdapterOptions {
|
||||||
tableName?: string
|
tableName?: string
|
||||||
@@ -53,7 +52,7 @@ export interface DynamoDBAdapterOptions {
|
|||||||
* import { DynamoDBDocument } from "@aws-sdk/lib-dynamodb"
|
* import { DynamoDBDocument } from "@aws-sdk/lib-dynamodb"
|
||||||
* import NextAuth from "next-auth";
|
* import NextAuth from "next-auth";
|
||||||
* import Providers from "next-auth/providers";
|
* import Providers from "next-auth/providers";
|
||||||
* import { DynamoDBAdapter } from "@next-auth/dynamodb-adapter"
|
* import { DynamoDBAdapter } from "@auth/dynamodb-adapter"
|
||||||
*
|
*
|
||||||
* const config: DynamoDBClientConfig = {
|
* const config: DynamoDBClientConfig = {
|
||||||
* credentials: {
|
* credentials: {
|
||||||
@@ -187,7 +186,7 @@ export function DynamoDBAdapter(
|
|||||||
async createUser(data) {
|
async createUser(data) {
|
||||||
const user: AdapterUser = {
|
const user: AdapterUser = {
|
||||||
...(data as any),
|
...(data as any),
|
||||||
id: uuid(),
|
id: crypto.randomUUID(),
|
||||||
}
|
}
|
||||||
|
|
||||||
await client.put({
|
await client.put({
|
||||||
@@ -312,7 +311,7 @@ export function DynamoDBAdapter(
|
|||||||
async linkAccount(data) {
|
async linkAccount(data) {
|
||||||
const item = {
|
const item = {
|
||||||
...data,
|
...data,
|
||||||
id: uuid(),
|
id: crypto.randomUUID(),
|
||||||
[pk]: `USER#${data.userId}`,
|
[pk]: `USER#${data.userId}`,
|
||||||
[sk]: `ACCOUNT#${data.provider}#${data.providerAccountId}`,
|
[sk]: `ACCOUNT#${data.provider}#${data.providerAccountId}`,
|
||||||
[GSI1PK]: `ACCOUNT#${data.provider}`,
|
[GSI1PK]: `ACCOUNT#${data.provider}`,
|
||||||
@@ -376,7 +375,7 @@ export function DynamoDBAdapter(
|
|||||||
},
|
},
|
||||||
async createSession(data) {
|
async createSession(data) {
|
||||||
const session = {
|
const session = {
|
||||||
id: uuid(),
|
id: crypto.randomUUID(),
|
||||||
...data,
|
...data,
|
||||||
}
|
}
|
||||||
await client.put({
|
await client.put({
|
||||||
|
|||||||
@@ -1,16 +1,25 @@
|
|||||||
{
|
{
|
||||||
"extends": "@next-auth/tsconfig/tsconfig.adapters.json",
|
"extends": "@next-auth/tsconfig/tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"rootDir": "src",
|
"allowJs": true,
|
||||||
"outDir": ".",
|
"baseUrl": ".",
|
||||||
|
"isolatedModules": true,
|
||||||
"target": "ES2020",
|
"target": "ES2020",
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
|
"outDir": ".",
|
||||||
|
"rootDir": "src",
|
||||||
"skipDefaultLibCheck": true,
|
"skipDefaultLibCheck": true,
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
"stripInternal": true,
|
"stripInternal": true,
|
||||||
"declarationMap": true,
|
"declarationMap": true,
|
||||||
"declaration": true
|
"declaration": true
|
||||||
},
|
},
|
||||||
"exclude": ["tests", "dist", "jest.config.js", "jest-dynamodb-config.js"]
|
"include": [
|
||||||
}
|
"src/**/*"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"*.js",
|
||||||
|
"*.d.ts",
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -8,14 +8,14 @@
|
|||||||
</a>
|
</a>
|
||||||
<h3 align="center"><b>MikroORM Adapter</b> - NextAuth.js / Auth.js</a></h3>
|
<h3 align="center"><b>MikroORM 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/mikro-orm-adapter">
|
<a href="https://npm.im/@auth/mikro-orm-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/mikro-orm-adapter">
|
<a href="https://npm.im/@auth/mikro-orm-adapter">
|
||||||
<img alt="npm" src="https://img.shields.io/npm/v/@next-auth/mikro-orm-adapter?color=green&label=@next-auth/mikro-orm-adapter&style=flat-square">
|
<img alt="npm" src="https://img.shields.io/npm/v/@auth/mikro-orm-adapter?color=green&label=@auth/mikro-orm-adapter&style=flat-square">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://www.npmtrends.com/@next-auth/mikro-orm-adapter">
|
<a href="https://www.npmtrends.com/@auth/mikro-orm-adapter">
|
||||||
<img src="https://img.shields.io/npm/dm/@next-auth/mikro-orm-adapter?label=%20downloads&style=flat-square" alt="Downloads" />
|
<img src="https://img.shields.io/npm/dm/@auth/mikro-orm-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,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@next-auth/mikro-orm-adapter",
|
"name": "@auth/mikro-orm-adapter",
|
||||||
"version": "3.0.1",
|
"version": "1.0.0",
|
||||||
"description": "MikroORM adapter for next-auth.",
|
"description": "MikroORM adapter for Auth.js",
|
||||||
"homepage": "https://authjs.dev",
|
"homepage": "https://authjs.dev",
|
||||||
"repository": "https://github.com/nextauthjs/next-auth",
|
"repository": "https://github.com/nextauthjs/next-auth",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
@@ -11,7 +11,20 @@
|
|||||||
"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": [
|
||||||
|
"*.js",
|
||||||
|
"*.d.ts*",
|
||||||
|
"lib",
|
||||||
|
"src"
|
||||||
|
],
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./index.d.ts",
|
||||||
|
"import": "./index.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"next-auth",
|
"next-auth",
|
||||||
@@ -27,27 +40,20 @@
|
|||||||
"test": "jest --runInBand",
|
"test": "jest --runInBand",
|
||||||
"build": "tsc"
|
"build": "tsc"
|
||||||
},
|
},
|
||||||
"files": [
|
|
||||||
"README.md",
|
|
||||||
"dist"
|
|
||||||
],
|
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@mikro-orm/core": "^5",
|
"@mikro-orm/core": "^5"
|
||||||
"next-auth": "^4"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@mikro-orm/core": "^5",
|
"@mikro-orm/core": "^5",
|
||||||
"@mikro-orm/sqlite": "^5",
|
"@mikro-orm/sqlite": "^5",
|
||||||
"@next-auth/adapter-test": "workspace:*",
|
"@next-auth/adapter-test": "workspace:*",
|
||||||
"@next-auth/tsconfig": "workspace:*",
|
"@next-auth/tsconfig": "workspace:*",
|
||||||
"@types/uuid": ">=8",
|
"jest": "^29"
|
||||||
"jest": "^29",
|
|
||||||
"next-auth": "workspace:*"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"uuid": "^9"
|
"@auth/core": "workspace:*"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"preset": "@next-auth/adapter-test/jest"
|
"preset": "@next-auth/adapter-test/jest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,10 +9,10 @@
|
|||||||
* ## Installation
|
* ## Installation
|
||||||
*
|
*
|
||||||
* ```bash npm2yarn2pnpm
|
* ```bash npm2yarn2pnpm
|
||||||
* npm install next-auth @next-auth/dynamodb-adapter @aws-sdk/client-dynamodb @aws-sdk/lib-dynamodb
|
* npm install @mikro-orm/core @auth/mikro-orm-adapter
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @module @next-auth/dynamodb-adapter
|
* @module @auth/mikro-orm-adapter
|
||||||
*/
|
*/
|
||||||
import type {
|
import type {
|
||||||
Connection,
|
Connection,
|
||||||
@@ -20,11 +20,11 @@ import type {
|
|||||||
Options as ORMOptions,
|
Options as ORMOptions,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
|
|
||||||
import type { Adapter } from "next-auth/adapters"
|
import type { Adapter } from "@auth/core/adapters"
|
||||||
|
|
||||||
import { MikroORM, wrap } from "@mikro-orm/core"
|
import { MikroORM, wrap } from "@mikro-orm/core"
|
||||||
|
|
||||||
import * as defaultEntities from "./entities"
|
import * as defaultEntities from "./lib/entities"
|
||||||
|
|
||||||
export { defaultEntities }
|
export { defaultEntities }
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ export { defaultEntities }
|
|||||||
*
|
*
|
||||||
* ```typescript title="pages/api/auth/[...nextauth].ts"
|
* ```typescript title="pages/api/auth/[...nextauth].ts"
|
||||||
* import NextAuth from "next-auth"
|
* import NextAuth from "next-auth"
|
||||||
* import { MikroOrmAdapter } from "@next-auth/mikro-orm-adapter"
|
* import { MikroOrmAdapter } from "@auth/mikro-orm-adapter"
|
||||||
*
|
*
|
||||||
* export default NextAuth({
|
* export default NextAuth({
|
||||||
* adapter: MikroOrmAdapter({
|
* adapter: MikroOrmAdapter({
|
||||||
@@ -67,7 +67,7 @@ export { defaultEntities }
|
|||||||
* Property,
|
* Property,
|
||||||
* Unique,
|
* Unique,
|
||||||
* } from "@mikro-orm/core"
|
* } from "@mikro-orm/core"
|
||||||
* import { defaultEntities } from "@next-auth/mikro-orm-adapter"
|
* import { defaultEntities } from "@auth/mikro-orm-adapter"
|
||||||
*
|
*
|
||||||
* const { Account, Session } = defaultEntities
|
* const { Account, Session } = defaultEntities
|
||||||
*
|
*
|
||||||
@@ -124,7 +124,7 @@ export { defaultEntities }
|
|||||||
*
|
*
|
||||||
* ```typescript title="config/mikro-orm.ts"
|
* ```typescript title="config/mikro-orm.ts"
|
||||||
* import { Options } from "@mikro-orm/core";
|
* import { Options } from "@mikro-orm/core";
|
||||||
* import { defaultEntities } from "@next-auth/mikro-orm-adapter"
|
* import { defaultEntities } from "@auth/mikro-orm-adapter"
|
||||||
*
|
*
|
||||||
* const config: Options = {
|
* const config: Options = {
|
||||||
* ...
|
* ...
|
||||||
@@ -186,7 +186,6 @@ export function MikroOrmAdapter<
|
|||||||
* Method used in testing. You won't need to call this in your app.
|
* Method used in testing. You won't need to call this in your app.
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
// @ts-expect-error
|
|
||||||
async __disconnect() {
|
async __disconnect() {
|
||||||
const em = await getEM()
|
const em = await getEM()
|
||||||
await em.getConnection().close()
|
await em.getConnection().close()
|
||||||
@@ -240,6 +239,7 @@ export function MikroOrmAdapter<
|
|||||||
|
|
||||||
return wrap(user).toObject()
|
return wrap(user).toObject()
|
||||||
},
|
},
|
||||||
|
// @ts-expect-error
|
||||||
async linkAccount(data) {
|
async linkAccount(data) {
|
||||||
const em = await getEM()
|
const em = await getEM()
|
||||||
const user = await em.findOne(UserModel, { id: data.userId })
|
const user = await em.findOne(UserModel, { id: data.userId })
|
||||||
@@ -251,6 +251,7 @@ export function MikroOrmAdapter<
|
|||||||
|
|
||||||
return wrap(account).toObject()
|
return wrap(account).toObject()
|
||||||
},
|
},
|
||||||
|
// @ts-expect-error
|
||||||
async unlinkAccount(provider_providerAccountId) {
|
async unlinkAccount(provider_providerAccountId) {
|
||||||
const em = await getEM()
|
const em = await getEM()
|
||||||
const account = await em.findOne(AccountModel, {
|
const account = await em.findOne(AccountModel, {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { v4 as randomUUID } from "uuid"
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Property,
|
Property,
|
||||||
Unique,
|
Unique,
|
||||||
@@ -16,8 +14,7 @@ import type {
|
|||||||
AdapterAccount,
|
AdapterAccount,
|
||||||
AdapterSession,
|
AdapterSession,
|
||||||
VerificationToken as AdapterVerificationToken,
|
VerificationToken as AdapterVerificationToken,
|
||||||
} from "next-auth/adapters"
|
} from "@auth/core/adapters"
|
||||||
import type { ProviderType } from "next-auth/providers"
|
|
||||||
|
|
||||||
type RemoveIndex<T> = {
|
type RemoveIndex<T> = {
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
@@ -27,7 +24,7 @@ type RemoveIndex<T> = {
|
|||||||
@Entity()
|
@Entity()
|
||||||
export class User implements RemoveIndex<AdapterUser> {
|
export class User implements RemoveIndex<AdapterUser> {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
id: string = randomUUID()
|
id: string = crypto.randomUUID()
|
||||||
|
|
||||||
@Property({ type: types.string, nullable: true })
|
@Property({ type: types.string, nullable: true })
|
||||||
name?: string
|
name?: string
|
||||||
@@ -63,7 +60,7 @@ export class User implements RemoveIndex<AdapterUser> {
|
|||||||
export class Session implements AdapterSession {
|
export class Session implements AdapterSession {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
@Property({ type: types.string })
|
@Property({ type: types.string })
|
||||||
id: string = randomUUID()
|
id: string = crypto.randomUUID()
|
||||||
|
|
||||||
@ManyToOne({
|
@ManyToOne({
|
||||||
entity: "User",
|
entity: "User",
|
||||||
@@ -88,7 +85,7 @@ export class Session implements AdapterSession {
|
|||||||
export class Account implements RemoveIndex<AdapterAccount> {
|
export class Account implements RemoveIndex<AdapterAccount> {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
@Property({ type: types.string })
|
@Property({ type: types.string })
|
||||||
id: string = randomUUID()
|
id: string = crypto.randomUUID()
|
||||||
|
|
||||||
@ManyToOne({
|
@ManyToOne({
|
||||||
entity: "User",
|
entity: "User",
|
||||||
@@ -101,7 +98,7 @@ export class Account implements RemoveIndex<AdapterAccount> {
|
|||||||
userId!: string
|
userId!: string
|
||||||
|
|
||||||
@Property({ type: types.string })
|
@Property({ type: types.string })
|
||||||
type!: ProviderType
|
type!: AdapterAccount["type"]
|
||||||
|
|
||||||
@Property({ type: types.string })
|
@Property({ type: types.string })
|
||||||
provider!: string
|
provider!: string
|
||||||
@@ -13,13 +13,15 @@ import {
|
|||||||
Options,
|
Options,
|
||||||
types,
|
types,
|
||||||
} from "@mikro-orm/core"
|
} from "@mikro-orm/core"
|
||||||
import { randomUUID, runBasicTests } from "@next-auth/adapter-test"
|
import { runBasicTests } from "@next-auth/adapter-test"
|
||||||
|
|
||||||
|
globalThis.crypto ??= require("node:crypto").webcrypto
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class User implements defaultEntities.User {
|
export class User implements defaultEntities.User {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
@Property({ type: types.string })
|
@Property({ type: types.string })
|
||||||
id: string = randomUUID()
|
id: string = crypto.randomUUID()
|
||||||
|
|
||||||
@Property({ type: types.string, nullable: true })
|
@Property({ type: types.string, nullable: true })
|
||||||
name?: string
|
name?: string
|
||||||
@@ -60,7 +62,7 @@ export class User implements defaultEntities.User {
|
|||||||
export class VeryImportantEntity {
|
export class VeryImportantEntity {
|
||||||
@PrimaryKey()
|
@PrimaryKey()
|
||||||
@Property({ type: types.string })
|
@Property({ type: types.string })
|
||||||
id: string = randomUUID()
|
id: string = crypto.randomUUID()
|
||||||
|
|
||||||
@Property({ type: types.boolean })
|
@Property({ type: types.boolean })
|
||||||
important = true
|
important = true
|
||||||
|
|||||||
@@ -1,13 +1,27 @@
|
|||||||
{
|
{
|
||||||
"extends": "@next-auth/tsconfig/tsconfig.adapters.json",
|
"extends": "@next-auth/tsconfig/tsconfig.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"experimentalDecorators": true,
|
"allowJs": true,
|
||||||
"emitDecoratorMetadata": true,
|
"baseUrl": ".",
|
||||||
"esModuleInterop": true,
|
"isolatedModules": true,
|
||||||
|
"target": "ES2020",
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"outDir": ".",
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"outDir": "dist",
|
"skipDefaultLibCheck": true,
|
||||||
"stripInternal": true
|
"strictNullChecks": true,
|
||||||
|
"stripInternal": true,
|
||||||
|
"declarationMap": true,
|
||||||
|
"declaration": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"emitDecoratorMetadata": true
|
||||||
},
|
},
|
||||||
"include": ["src"],
|
"include": [
|
||||||
"exclude": ["dist", "test", "node_modules"]
|
"src/**/*",
|
||||||
}
|
],
|
||||||
|
"exclude": [
|
||||||
|
"*.js",
|
||||||
|
"*.d.ts",
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -8,14 +8,14 @@
|
|||||||
</a>
|
</a>
|
||||||
<h3 align="center"><b>MongoDB Adapter</b> - NextAuth.js / Auth.js</a></h3>
|
<h3 align="center"><b>MongoDB 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/mongodb-adapter">
|
<a href="https://npm.im/@auth/mongodb-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/mongodb-adapter">
|
<a href="https://npm.im/@auth/mongodb-adapter">
|
||||||
<img alt="npm" src="https://img.shields.io/npm/v/@next-auth/mongodb-adapter?color=green&label=@next-auth/mongodb-adapter&style=flat-square">
|
<img alt="npm" src="https://img.shields.io/npm/v/@auth/mongodb-adapter?color=green&label=@auth/mongodb-adapter&style=flat-square">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://www.npmtrends.com/@next-auth/mongodb-adapter">
|
<a href="https://www.npmtrends.com/@auth/mongodb-adapter">
|
||||||
<img src="https://img.shields.io/npm/dm/@next-auth/mongodb-adapter?label=%20downloads&style=flat-square" alt="Downloads" />
|
<img src="https://img.shields.io/npm/dm/@auth/mongodb-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,26 @@
|
|||||||
{
|
{
|
||||||
"name": "@next-auth/mongodb-adapter",
|
"name": "@auth/mongodb-adapter",
|
||||||
"version": "1.1.3",
|
"version": "1.0.0",
|
||||||
"description": "mongoDB adapter for next-auth.",
|
"description": "MongoDB adapter for Auth.js",
|
||||||
"homepage": "https://authjs.dev",
|
"homepage": "https://authjs.dev",
|
||||||
"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": "Balázs Orbán <info@balazsorban.com>",
|
"author": "Balázs Orbán <info@balazsorban.com>",
|
||||||
"main": "dist/index.js",
|
"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",
|
||||||
@@ -26,20 +38,17 @@
|
|||||||
"test:watch": "./tests/test.sh -w",
|
"test:watch": "./tests/test.sh -w",
|
||||||
"build": "tsc"
|
"build": "tsc"
|
||||||
},
|
},
|
||||||
"files": [
|
"dependencies": {
|
||||||
"README.md",
|
"@auth/core": "workspace:*"
|
||||||
"dist"
|
},
|
||||||
],
|
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"mongodb": "^5 || ^4",
|
"mongodb": "^5 || ^4"
|
||||||
"next-auth": "^4"
|
|
||||||
},
|
},
|
||||||
"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",
|
||||||
"mongodb": "^5.1.0",
|
"mongodb": "^5.1.0"
|
||||||
"next-auth": "workspace:*"
|
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"preset": "@next-auth/adapter-test/jest"
|
"preset": "@next-auth/adapter-test/jest"
|
||||||
|
|||||||
@@ -9,10 +9,10 @@
|
|||||||
* ## Installation
|
* ## Installation
|
||||||
*
|
*
|
||||||
* ```bash npm2yarn2pnpm
|
* ```bash npm2yarn2pnpm
|
||||||
* npm install next-auth @next-auth/mongodb-adapter mongodb
|
* npm install @auth/mongodb-adapter mongodb
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @module @next-auth/mongodb-adapter
|
* @module @auth/mongodb-adapter
|
||||||
*/
|
*/
|
||||||
import { ObjectId } from "mongodb"
|
import { ObjectId } from "mongodb"
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ import type {
|
|||||||
AdapterAccount,
|
AdapterAccount,
|
||||||
AdapterSession,
|
AdapterSession,
|
||||||
VerificationToken,
|
VerificationToken,
|
||||||
} from "next-auth/adapters"
|
} from "@auth/core/adapters"
|
||||||
import type { MongoClient } from "mongodb"
|
import type { MongoClient } from "mongodb"
|
||||||
|
|
||||||
/** This is the interface of the MongoDB adapter options. */
|
/** This is the interface of the MongoDB adapter options. */
|
||||||
@@ -132,7 +132,7 @@ export function _id(hex?: string) {
|
|||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
* import NextAuth from "next-auth"
|
* import NextAuth from "next-auth"
|
||||||
* import { MongoDBAdapter } from "@next-auth/mongodb-adapter"
|
* import { MongoDBAdapter } from "@auth/mongodb-adapter"
|
||||||
* import clientPromise from "../../../lib/mongodb"
|
* import clientPromise from "../../../lib/mongodb"
|
||||||
*
|
*
|
||||||
* // For more information on each option (and a full list of options) go to
|
* // For more information on each option (and a full list of options) go to
|
||||||
|
|||||||
@@ -1,8 +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
|
||||||
},
|
},
|
||||||
"exclude": ["tests", "dist", "jest.config.js"]
|
"include": [
|
||||||
}
|
"src/**/*"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"*.js",
|
||||||
|
"*.d.ts",
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -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"]
|
|
||||||
}
|
|
||||||
1
packages/adapter-typeorm/.npmrc
Normal file
1
packages/adapter-typeorm/.npmrc
Normal file
@@ -0,0 +1 @@
|
|||||||
|
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
|
||||||
@@ -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
packages/adapter-upstash-redis/.npmrc
Normal file
1
packages/adapter-upstash-redis/.npmrc
Normal file
@@ -0,0 +1 @@
|
|||||||
|
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
|
||||||
@@ -8,14 +8,14 @@
|
|||||||
</a>
|
</a>
|
||||||
<h3 align="center"><b>Upstash Redis Adapter</b> - NextAuth.js / Auth.js</a></h3>
|
<h3 align="center"><b>Upstash Redis 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/upstash-redis-adapter">
|
<a href="https://npm.im/@auth/upstash-redis-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/upstash-redis-adapter">
|
<a href="https://npm.im/@auth/upstash-redis-adapter">
|
||||||
<img alt="npm" src="https://img.shields.io/npm/v/@next-auth/upstash-redis-adapter?color=green&label=@next-auth/upstash-redis-adapter&style=flat-square">
|
<img alt="npm" src="https://img.shields.io/npm/v/@auth/upstash-redis-adapter?color=green&label=@auth/upstash-redis-adapter&style=flat-square">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://www.npmtrends.com/@next-auth/upstash-redis-adapter">
|
<a href="https://www.npmtrends.com/@auth/upstash-redis-adapter">
|
||||||
<img src="https://img.shields.io/npm/dm/@next-auth/upstash-redis-adapter?label=%20downloads&style=flat-square" alt="Downloads" />
|
<img src="https://img.shields.io/npm/dm/@auth/upstash-redis-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,26 @@
|
|||||||
{
|
{
|
||||||
"name": "@next-auth/upstash-redis-adapter",
|
"name": "@auth/upstash-redis-adapter",
|
||||||
"version": "3.0.4",
|
"version": "1.0.0",
|
||||||
"description": "Upstash adapter for next-auth. It uses Upstash's connectionless (HTTP based) Redis client.",
|
"description": "Upstash adapter for Auth.js.",
|
||||||
"homepage": "https://authjs.dev",
|
"homepage": "https://authjs.dev",
|
||||||
"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": "github.com/kay-is",
|
"author": "github.com/kay-is",
|
||||||
"main": "dist/index.js",
|
"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",
|
||||||
@@ -25,13 +37,11 @@
|
|||||||
"test": "jest",
|
"test": "jest",
|
||||||
"build": "tsc"
|
"build": "tsc"
|
||||||
},
|
},
|
||||||
"files": [
|
"dependencies": {
|
||||||
"README.md",
|
"@auth/core": "workspace:*"
|
||||||
"dist"
|
},
|
||||||
],
|
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@upstash/redis": "^1.0.1",
|
"@upstash/redis": "^1.0.1"
|
||||||
"next-auth": "^4"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@next-auth/adapter-test": "workspace:*",
|
"@next-auth/adapter-test": "workspace:*",
|
||||||
@@ -43,9 +53,6 @@
|
|||||||
"jest": "^27.4.3",
|
"jest": "^27.4.3",
|
||||||
"next-auth": "workspace:*"
|
"next-auth": "workspace:*"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
|
||||||
"uuid": "^8.3.2"
|
|
||||||
},
|
|
||||||
"jest": {
|
"jest": {
|
||||||
"preset": "@next-auth/adapter-test/jest"
|
"preset": "@next-auth/adapter-test/jest"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,10 @@
|
|||||||
* ## Installation
|
* ## Installation
|
||||||
*
|
*
|
||||||
* ```bash npm2yarn2pnpm
|
* ```bash npm2yarn2pnpm
|
||||||
* npm install @upstash/redis @next-auth/upstash-redis-adapter
|
* npm install @upstash/redis @auth/upstash-redis-adapter
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @module @next-auth/upstash-redis-adapter
|
* @module @auth/upstash-redis-adapter
|
||||||
*/
|
*/
|
||||||
import type {
|
import type {
|
||||||
Adapter,
|
Adapter,
|
||||||
@@ -20,11 +20,9 @@ import type {
|
|||||||
AdapterAccount,
|
AdapterAccount,
|
||||||
AdapterSession,
|
AdapterSession,
|
||||||
VerificationToken,
|
VerificationToken,
|
||||||
} from "next-auth/adapters"
|
} from "@auth/core/adapters"
|
||||||
import type { Redis } from "@upstash/redis"
|
import type { Redis } from "@upstash/redis"
|
||||||
|
|
||||||
import { v4 as uuid } from "uuid"
|
|
||||||
|
|
||||||
/** This is the interface of the Upstash Redis adapter options. */
|
/** This is the interface of the Upstash Redis adapter options. */
|
||||||
export interface UpstashRedisAdapterOptions {
|
export interface UpstashRedisAdapterOptions {
|
||||||
/**
|
/**
|
||||||
@@ -93,7 +91,7 @@ export function hydrateDates(json: object) {
|
|||||||
* ```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 GoogleProvider from "next-auth/providers/google"
|
* import GoogleProvider from "next-auth/providers/google"
|
||||||
* import { UpstashRedisAdapter } from "@next-auth/upstash-redis-adapter"
|
* import { UpstashRedisAdapter } from "@auth/upstash-redis-adapter"
|
||||||
* import upstashRedisClient from "@upstash/redis"
|
* import upstashRedisClient from "@upstash/redis"
|
||||||
*
|
*
|
||||||
* const redis = upstashRedisClient(
|
* const redis = upstashRedisClient(
|
||||||
@@ -217,7 +215,7 @@ export function UpstashRedisAdapter(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
async createUser(user) {
|
async createUser(user) {
|
||||||
const id = uuid()
|
const id = crypto.randomUUID()
|
||||||
// TypeScript thinks the emailVerified field is missing
|
// TypeScript thinks the emailVerified field is missing
|
||||||
// but all fields are copied directly from user, so it's there
|
// but all fields are copied directly from user, so it's there
|
||||||
return await setUser(id, { ...user, id })
|
return await setUser(id, { ...user, id })
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import { runBasicTests } from "@next-auth/adapter-test"
|
|||||||
import { hydrateDates, UpstashRedisAdapter } from "../src"
|
import { hydrateDates, UpstashRedisAdapter } from "../src"
|
||||||
import "dotenv/config"
|
import "dotenv/config"
|
||||||
|
|
||||||
|
globalThis.crypto ??= require("node:crypto").webcrypto
|
||||||
|
|
||||||
if (!process.env.UPSTASH_REDIS_URL || !process.env.UPSTASH_REDIS_KEY) {
|
if (!process.env.UPSTASH_REDIS_URL || !process.env.UPSTASH_REDIS_KEY) {
|
||||||
test("Skipping UpstashRedisAdapter tests, since required environment variables aren't available", () => {
|
test("Skipping UpstashRedisAdapter tests, since required environment variables aren't available", () => {
|
||||||
expect(true).toBe(true)
|
expect(true).toBe(true)
|
||||||
@@ -27,6 +29,7 @@ const client = new Redis({
|
|||||||
runBasicTests({
|
runBasicTests({
|
||||||
adapter: UpstashRedisAdapter(client, { baseKeyPrefix: "testApp:" }),
|
adapter: UpstashRedisAdapter(client, { baseKeyPrefix: "testApp:" }),
|
||||||
db: {
|
db: {
|
||||||
|
disconnect: client.flushdb,
|
||||||
async user(id: string) {
|
async user(id: string) {
|
||||||
const data = await client.get<object>(`testApp:user:${id}`)
|
const data = await client.get<object>(`testApp:user:${id}`)
|
||||||
if (!data) return null
|
if (!data) return null
|
||||||
@@ -48,7 +51,7 @@ runBasicTests({
|
|||||||
},
|
},
|
||||||
async verificationToken(where) {
|
async verificationToken(where) {
|
||||||
const data = await client.get<object>(
|
const data = await client.get<object>(
|
||||||
`testApp:user:token:${where.identifier}`
|
`testApp:user:token:${where.identifier}:${where.token}`
|
||||||
)
|
)
|
||||||
if (!data) return null
|
if (!data) return null
|
||||||
return hydrateDates(data)
|
return hydrateDates(data)
|
||||||
|
|||||||
@@ -1,8 +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
|
||||||
},
|
},
|
||||||
"exclude": ["tests", "dist", "jest.config.js"]
|
"include": [
|
||||||
}
|
"src/**/*"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"*.js",
|
||||||
|
"*.d.ts",
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@auth/core",
|
"name": "@auth/core",
|
||||||
"version": "0.8.1",
|
"version": "0.8.2",
|
||||||
"description": "Authentication for the Web.",
|
"description": "Authentication for the Web.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"authentication",
|
"authentication",
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
432
pnpm-lock.yaml
generated
432
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
26
turbo.json
26
turbo.json
@@ -47,7 +47,7 @@
|
|||||||
"e2e": {
|
"e2e": {
|
||||||
"outputs": ["playwright-report/**"]
|
"outputs": ["playwright-report/**"]
|
||||||
},
|
},
|
||||||
"@next-auth/upstash-redis-adapter#test": {
|
"@auth/upstash-redis-adapter#test": {
|
||||||
"env": ["UPSTASH_REDIS_KEY", "UPSTASH_REDIS_URL"]
|
"env": ["UPSTASH_REDIS_KEY", "UPSTASH_REDIS_URL"]
|
||||||
},
|
},
|
||||||
"docs#dev": {
|
"docs#dev": {
|
||||||
@@ -55,18 +55,18 @@
|
|||||||
"@auth/core#build",
|
"@auth/core#build",
|
||||||
"@auth/prisma-adapter#build",
|
"@auth/prisma-adapter#build",
|
||||||
"@auth/sveltekit#build",
|
"@auth/sveltekit#build",
|
||||||
"@next-auth/dgraph-adapter#build",
|
"@auth/dgraph-adapter#build",
|
||||||
"@next-auth/dynamodb-adapter#build",
|
"@auth/dynamodb-adapter#build",
|
||||||
"@next-auth/fauna-adapter#build",
|
"@next-auth/fauna-adapter#build",
|
||||||
"@next-auth/firebase-adapter#build",
|
"@next-auth/firebase-adapter#build",
|
||||||
"@next-auth/mikro-orm-adapter#build",
|
"@auth/mikro-orm-adapter#build",
|
||||||
"@next-auth/mongodb-adapter#build",
|
"@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/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",
|
"@auth/upstash-redis-adapter#build",
|
||||||
"@next-auth/xata-adapter#build",
|
"@next-auth/xata-adapter#build",
|
||||||
"^build",
|
"^build",
|
||||||
"next-auth#build"
|
"next-auth#build"
|
||||||
@@ -78,18 +78,18 @@
|
|||||||
"@auth/core#build",
|
"@auth/core#build",
|
||||||
"@auth/prisma-adapter#build",
|
"@auth/prisma-adapter#build",
|
||||||
"@auth/sveltekit#build",
|
"@auth/sveltekit#build",
|
||||||
"@next-auth/dgraph-adapter#build",
|
"@auth/dgraph-adapter#build",
|
||||||
"@next-auth/dynamodb-adapter#build",
|
"@auth/dynamodb-adapter#build",
|
||||||
"@next-auth/fauna-adapter#build",
|
"@next-auth/fauna-adapter#build",
|
||||||
"@next-auth/firebase-adapter#build",
|
"@next-auth/firebase-adapter#build",
|
||||||
"@next-auth/mikro-orm-adapter#build",
|
"@auth/mikro-orm-adapter#build",
|
||||||
"@next-auth/mongodb-adapter#build",
|
"@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/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",
|
"@auth/upstash-redis-adapter#build",
|
||||||
"@next-auth/xata-adapter#build",
|
"@next-auth/xata-adapter#build",
|
||||||
"^build",
|
"^build",
|
||||||
"next-auth#build"
|
"next-auth#build"
|
||||||
|
|||||||
Reference in New Issue
Block a user