diff --git a/.github/ISSUE_TEMPLATE/3_bug_adapter.yml b/.github/ISSUE_TEMPLATE/3_bug_adapter.yml
index 172852bff3..34373abfff 100644
--- a/.github/ISSUE_TEMPLATE/3_bug_adapter.yml
+++ b/.github/ISSUE_TEMPLATE/3_bug_adapter.yml
@@ -27,7 +27,7 @@ body:
- "@auth/firebase-adapter"
- "@auth/mikro-orm-adapter"
- "@auth/mongodb-adapter"
- - "@next-auth/neo4j-adapter"
+ - "@auth/neo4j-adapter"
- "@next-auth/pouchdb-adapter"
- "@auth/prisma-adapter"
- "@next-auth/sequelize-adapter"
diff --git a/.github/issue-labeler.yml b/.github/issue-labeler.yml
index 9450ddd7d8..dea8f8d97b 100644
--- a/.github/issue-labeler.yml
+++ b/.github/issue-labeler.yml
@@ -19,7 +19,7 @@ mongodb:
- "@auth/mongodb-adapter"
neo4j:
- - "@next-auth/neo4j-adapter"
+ - "@auth/neo4j-adapter"
pouchdb:
- "@next-auth/pouchdb-adapter"
diff --git a/packages/adapter-neo4j/README.md b/packages/adapter-neo4j/README.md
index e6c0ed9326..8a599f8864 100644
--- a/packages/adapter-neo4j/README.md
+++ b/packages/adapter-neo4j/README.md
@@ -8,14 +8,14 @@
Neo4j Adapter - NextAuth.js / Auth.js
-
+
-
-
+
+
-
-
+
+
diff --git a/packages/adapter-neo4j/package.json b/packages/adapter-neo4j/package.json
index 0133bdc8a4..f3d9639dc4 100644
--- a/packages/adapter-neo4j/package.json
+++ b/packages/adapter-neo4j/package.json
@@ -1,7 +1,7 @@
{
- "name": "@next-auth/neo4j-adapter",
- "version": "1.0.6",
- "description": "neo4j adapter for next-auth.",
+ "name": "@auth/neo4j-adapter",
+ "version": "0.0.0",
+ "description": "neo4j adapter for Auth.js",
"homepage": "https://authjs.dev",
"repository": "https://github.com/nextauthjs/next-auth",
"bugs": {
@@ -11,7 +11,19 @@
"contributors": [
"Balázs Orbán "
],
- "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",
"keywords": [
"next-auth",
@@ -28,26 +40,20 @@
"test": "./tests/test.sh",
"build": "tsc"
},
- "files": [
- "README.md",
- "dist"
- ],
"peerDependencies": {
- "neo4j-driver": "^4.0.0 || ^5.7.0",
- "next-auth": "^4"
+ "neo4j-driver": "^4.0.0 || ^5.7.0"
},
"devDependencies": {
"@next-auth/adapter-test": "workspace:*",
"@next-auth/tsconfig": "workspace:*",
"@types/uuid": "^8.3.3",
"jest": "^27.4.3",
- "neo4j-driver": "^5.7.0",
- "next-auth": "workspace:*"
+ "neo4j-driver": "^5.7.0"
},
"dependencies": {
- "uuid": "^8.3.2"
+ "@auth/core": "workspace:*"
},
"jest": {
"preset": "@next-auth/adapter-test/jest"
}
-}
\ No newline at end of file
+}
diff --git a/packages/adapter-neo4j/src/index.ts b/packages/adapter-neo4j/src/index.ts
index 7d85d06d09..1044440410 100644
--- a/packages/adapter-neo4j/src/index.ts
+++ b/packages/adapter-neo4j/src/index.ts
@@ -9,17 +9,13 @@
* ## Installation
*
* ```bash npm2yarn2pnpm
- * npm install next-auth @next-auth/neo4j-adapter neo4j-driver
+ * npm install @auth/neo4j-adapter neo4j-driver
* ```
*
- * @module @next-auth/neo4j-adapter
+ * @module @auth/neo4j-adapter
*/
-import type { Session } from "neo4j-driver"
-import type { Adapter } from "next-auth/adapters"
-import { v4 as uuid } from "uuid"
-
-import { client, format } from "./utils"
-export { format }
+import { type Session, isInt, integer } from "neo4j-driver"
+import type { Adapter } from "@auth/core/adapters"
/** This is the interface of the Neo4j adapter options. The Neo4j adapter takes a {@link https://neo4j.com/docs/bolt/current/driver-api/#driver-session Neo4j session} as its only argument. */
export interface Neo4jOptions extends Session {}
@@ -31,7 +27,7 @@ export interface Neo4jOptions extends Session {}
*
* ```javascript title="pages/api/auth/[...nextauth].js"
* import neo4j from "neo4j-driver"
- * import { Neo4jAdapter } from "@next-auth/neo4j-adapter"
+ * import { Neo4jAdapter } from "@auth/neo4j-adapter"
*
* const driver = neo4j.driver(
* "bolt://localhost",
@@ -134,7 +130,7 @@ export function Neo4jAdapter(session: Session): Adapter {
return {
async createUser(data) {
- const user: any = { id: uuid(), ...data }
+ const user = { id: crypto.randomUUID(), ...data }
await write(`CREATE (u:User $data)`, user)
return user
},
@@ -288,3 +284,69 @@ export function Neo4jAdapter(session: Session): Adapter {
},
}
}
+
+// https://github.com/honeinc/is-iso-date/blob/master/index.js
+const isoDateRE =
+ /(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/
+
+function isDate(value: any) {
+ return value && isoDateRE.test(value) && !isNaN(Date.parse(value))
+}
+
+export const format = {
+ /** Takes a plain old JavaScript object and turns it into a Neo4j compatible object */
+ to(object: Record) {
+ const newObject: Record = {}
+ for (const key in object) {
+ const value = object[key]
+ if (value instanceof Date) newObject[key] = value.toISOString()
+ else newObject[key] = value
+ }
+ return newObject
+ },
+ /** Takes a Neo4j object and returns a plain old JavaScript object */
+ from>(object?: Record): T | null {
+ const newObject: Record = {}
+ if (!object) return null
+ for (const key in object) {
+ const value = object[key]
+ if (isDate(value)) {
+ newObject[key] = new Date(value)
+ } else if (isInt(value)) {
+ if (integer.inSafeRange(value)) newObject[key] = value.toNumber()
+ else newObject[key] = value.toString()
+ } else {
+ newObject[key] = value
+ }
+ }
+
+ return newObject as T
+ },
+}
+
+function client(session: Session) {
+ return {
+ /** Reads values from the database */
+ async read(statement: string, values?: any): Promise {
+ const result = await session.readTransaction((tx) =>
+ tx.run(statement, values)
+ )
+
+ return format.from(result?.records[0]?.get(0)) ?? null
+ },
+ /**
+ * Reads/writes values from/to the database.
+ * Properties are available under `$data`
+ */
+ async write>(
+ statement: string,
+ values: T
+ ): Promise {
+ const result = await session.writeTransaction((tx) =>
+ tx.run(statement, { data: format.to(values) })
+ )
+
+ return format.from(result?.records[0]?.toObject())
+ },
+ }
+}
diff --git a/packages/adapter-neo4j/src/utils.ts b/packages/adapter-neo4j/src/utils.ts
deleted file mode 100644
index df6f43976c..0000000000
--- a/packages/adapter-neo4j/src/utils.ts
+++ /dev/null
@@ -1,68 +0,0 @@
-import type { Session } from "neo4j-driver"
-import { isInt, integer } from "neo4j-driver"
-
-// https://github.com/honeinc/is-iso-date/blob/master/index.js
-const isoDateRE =
- /(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/
-
-function isDate(value: any) {
- return value && isoDateRE.test(value) && !isNaN(Date.parse(value))
-}
-
-export const format = {
- /** Takes a plain old JavaScript object and turns it into a Neo4j compatible object */
- to(object: Record) {
- const newObject: Record = {}
- for (const key in object) {
- const value = object[key]
- if (value instanceof Date) newObject[key] = value.toISOString()
- else newObject[key] = value
- }
- return newObject
- },
- /** Takes a Neo4j object and returns a plain old JavaScript object */
- from>(object?: Record): T | null {
- const newObject: Record = {}
- if (!object) return null
- for (const key in object) {
- const value = object[key]
- if (isDate(value)) {
- newObject[key] = new Date(value)
- } else if (isInt(value)) {
- if (integer.inSafeRange(value)) newObject[key] = value.toNumber()
- else newObject[key] = value.toString()
- } else {
- newObject[key] = value
- }
- }
-
- return newObject as T
- },
-}
-
-export function client(session: Session) {
- return {
- /** Reads values from the database */
- async read(statement: string, values?: any): Promise {
- const result = await session.readTransaction((tx) =>
- tx.run(statement, values)
- )
-
- return format.from(result?.records[0]?.get(0)) ?? null
- },
- /**
- * Reads/writes values from/to the database.
- * Properties are available under `$data`
- */
- async write>(
- statement: string,
- values: T
- ): Promise {
- const result = await session.writeTransaction((tx) =>
- tx.run(statement, { data: format.to(values) })
- )
-
- return format.from(result?.records[0]?.toObject())
- },
- }
-}
diff --git a/packages/adapter-neo4j/tests/index.test.ts b/packages/adapter-neo4j/tests/index.test.ts
index 59bcc75578..7dd8c36a95 100644
--- a/packages/adapter-neo4j/tests/index.test.ts
+++ b/packages/adapter-neo4j/tests/index.test.ts
@@ -4,6 +4,8 @@ import statements from "./resources/statements"
import { Neo4jAdapter, format } from "../src"
+globalThis.crypto ??= require("node:crypto").webcrypto
+
const driver = neo4j.driver(
"bolt://localhost",
neo4j.auth.basic("neo4j", "password")
diff --git a/packages/adapter-neo4j/tsconfig.json b/packages/adapter-neo4j/tsconfig.json
index 0b19a117e6..726c2dc177 100644
--- a/packages/adapter-neo4j/tsconfig.json
+++ b/packages/adapter-neo4j/tsconfig.json
@@ -1,8 +1,25 @@
{
- "extends": "@next-auth/tsconfig/tsconfig.adapters.json",
+ "extends": "@next-auth/tsconfig/tsconfig.base.json",
"compilerOptions": {
+ "allowJs": true,
+ "baseUrl": ".",
+ "isolatedModules": true,
+ "target": "ES2020",
+ "module": "ESNext",
+ "moduleResolution": "node",
+ "outDir": ".",
"rootDir": "src",
- "outDir": "dist"
+ "skipDefaultLibCheck": true,
+ "strictNullChecks": true,
+ "stripInternal": true,
+ "declarationMap": true,
+ "declaration": true
},
- "exclude": ["tests", "dist", "jest.config.js"]
-}
+ "include": [
+ "src/**/*"
+ ],
+ "exclude": [
+ "*.js",
+ "*.d.ts",
+ ]
+}
\ No newline at end of file
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 1189359136..2747dcbe62 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -54,9 +54,9 @@ importers:
apps/dev/nextjs:
specifiers:
'@auth/core': workspace:*
+ '@auth/fauna-adapter': workspace:*
'@auth/prisma-adapter': workspace:*
'@auth/typeorm-adapter': workspace:*
- '@auth/fauna-adapter': workspace:*
'@next-auth/supabase-adapter': workspace:*
'@playwright/test': 1.29.2
'@prisma/client': ^3
@@ -78,9 +78,9 @@ importers:
typeorm: 0.3.7
dependencies:
'@auth/core': link:../../../packages/core
+ '@auth/fauna-adapter': link:../../../packages/adapter-fauna
'@auth/prisma-adapter': link:../../../packages/adapter-prisma
'@auth/typeorm-adapter': link:../../../packages/adapter-typeorm
- '@auth/fauna-adapter': link:../../../packages/adapter-fauna
'@next-auth/supabase-adapter': link:../../../packages/adapter-supabase
'@prisma/client': 3.15.2_prisma@3.15.2
'@supabase/supabase-js': 2.0.5
@@ -104,9 +104,9 @@ importers:
apps/dev/nextjs-v4:
specifiers:
+ '@auth/fauna-adapter': workspace:*
'@auth/prisma-adapter': workspace:*
'@auth/typeorm-adapter': workspace:*
- '@auth/fauna-adapter': workspace:*
'@next-auth/supabase-adapter': workspace:*
'@prisma/client': ^3
'@supabase/supabase-js': ^2.0.5
@@ -125,9 +125,9 @@ importers:
sqlite3: ^5.0.8
typeorm: 0.3.7
dependencies:
+ '@auth/fauna-adapter': link:../../../packages/adapter-fauna
'@auth/prisma-adapter': link:../../../packages/adapter-prisma
'@auth/typeorm-adapter': link:../../../packages/adapter-typeorm
- '@auth/fauna-adapter': link:../../../packages/adapter-fauna
'@next-auth/supabase-adapter': link:../../../packages/adapter-supabase
'@prisma/client': 3.15.2_prisma@3.15.2
'@supabase/supabase-js': 2.0.5
@@ -361,22 +361,20 @@ importers:
packages/adapter-neo4j:
specifiers:
+ '@auth/core': workspace:*
'@next-auth/adapter-test': workspace:*
'@next-auth/tsconfig': workspace:*
'@types/uuid': ^8.3.3
jest: ^27.4.3
neo4j-driver: ^5.7.0
- next-auth: workspace:*
- uuid: ^8.3.2
dependencies:
- uuid: 8.3.2
+ '@auth/core': link:../core
devDependencies:
'@next-auth/adapter-test': link:../adapter-test
'@next-auth/tsconfig': link:../tsconfig
'@types/uuid': 8.3.4
jest: 27.5.1
neo4j-driver: 5.7.0
- next-auth: link:../next-auth
packages/adapter-pouchdb:
specifiers:
diff --git a/turbo.json b/turbo.json
index 6532a9d3aa..e18f3886c7 100644
--- a/turbo.json
+++ b/turbo.json
@@ -61,7 +61,7 @@
"@auth/firebase-adapter#build",
"@auth/mikro-orm-adapter#build",
"@auth/mongodb-adapter#build",
- "@next-auth/neo4j-adapter#build",
+ "@auth/neo4j-adapter#build",
"@next-auth/pouchdb-adapter#build",
"@next-auth/sequelize-adapter#build",
"@next-auth/supabase-adapter#build",
@@ -84,7 +84,7 @@
"@auth/firebase-adapter#build",
"@auth/mikro-orm-adapter#build",
"@auth/mongodb-adapter#build",
- "@next-auth/neo4j-adapter#build",
+ "@auth/neo4j-adapter#build",
"@next-auth/pouchdb-adapter#build",
"@next-auth/sequelize-adapter#build",
"@next-auth/supabase-adapter#build",