Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@auth/edgedb-adapter

Package Overview
Dependencies
Maintainers
2
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@auth/edgedb-adapter - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

218

index.d.ts
/**
* <div style={{display: "flex", justifyContent: "space-between", alignItems: "center", padding: "16px"}}>
* <p style={{fontWeight: "300"}}>Official <a href="https://www.edgedb.com/">Edge DB</a> adapter for Auth.js / NextAuth.js.</p>
* <p>Official <a href="https://www.edgedb.com/">Edge DB</a> adapter for Auth.js / NextAuth.js.</p>
* <a href="https://www.edgedb.com/">

@@ -20,219 +20,3 @@ * <img style={{display: "block"}} src="/img/adapters/edgedb.svg" width="38" />

import type { Client } from "edgedb";
/**
*
* To use this Adapter, you need to install `edgedb`, `@edgedb/generate`, and the separate `@auth/edgedb-adapter` package:
*
* ```bash npm2yarn
* npm install edgedb @auth/edgedb-adapter
* npm install @edgedb/generate --save-dev
* ```
*
* ## Installation
*
* First, ensure you have the EdgeDB CLI installed.
*
* Follow the instructions below, or read the [EdgeDB quickstart](https://www.edgedb.com/docs/intro/quickstart) to install the EdgeDB CLI and initialize a project
*
* ### Linux or macOS
*
* ```bash
* curl --proto '=https' --tlsv1.2 -sSf https://sh.edgedb.com | sh
* ```
*
* ### Windows
*
* ```powershell
* iwr https://ps1.edgedb.com -useb | iex
* ```
*
* Check that the CLI is available with the `edgedb --version` command. If you get a `Command not found` error, you may need to open a new terminal window before the `edgedb` command is available.
*
* Once the CLI is installed, initialize a project from the application’s root directory. You’ll be presented with a series of prompts.
*
* ```bash
* edgedb project init
* ```
*
* This process will spin up an EdgeDB instance and [“link”](https://www.edgedb.com/docs/cli/edgedb_instance/edgedb_instance_link#edgedb-instance-link) it with your current directory. As long as you’re inside that directory, CLI commands and client libraries will be able to connect to the linked instance automatically, without additional configuration.
*
* ## Setup
*
* ### NextAuth.js configuration
*
* Configure your NextAuth.js to use the EdgeDB Adapter:
*
* ```js title="pages/api/auth/[...nextauth].js"
* import NextAuth from "next-auth"
* import GoogleProvider from "next-auth/providers/google"
* import { EdgeDBAdapter } from "@auth/edgedb-adapter"
* import { createClient } from "edgedb"
*
* const client = createClient()
*
* export default NextAuth({
* adapter: EdgeDBAdapter(client),
* providers: [
* GoogleProvider({
* clientId: process.env.GOOGLE_CLIENT_ID,
* clientSecret: process.env.GOOGLE_CLIENT_SECRET,
* }),
* ],
* })
* ```
*
* ### Create the EdgeDB schema
*
* Replace the contents of the auto-generated file in `dbschema/default.esdl` with the following:
*
* > This schema is adapted for use in EdgeDB and based upon our main [schema](https://authjs.dev/getting-started/adapters#models)
*
* ```json title="default.esdl"
* module default {
* type User {
* property name -> str;
* required property email -> str {
* constraint exclusive;
* };
* property emailVerified -> datetime;
* property image -> str;
* multi link accounts := .<user[is Account];
* multi link sessions := .<user[is Session];
* property createdAt -> datetime {
* default := datetime_current();
* };
* }
*
* type Account {
* required property userId := .user.id;
* required property type -> str;
* required property provider -> str;
* required property providerAccountId -> str {
* constraint exclusive;
* };
* property refresh_token -> str;
* property access_token -> str;
* property expires_at -> int64;
* property token_type -> str;
* property scope -> str;
* property id_token -> str;
* property session_state -> str;
* required link user -> User {
* on target delete delete source;
* };
* property createdAt -> datetime {
* default := datetime_current();
* };
* constraint exclusive on ((.provider, .providerAccountId));
* }
*
* type Session {
* required property sessionToken -> str {
* constraint exclusive;
* };
* required property userId := .user.id;
* required property expires -> datetime;
* required link user -> User {
* on target delete delete source;
* };
* property createdAt -> datetime {
* default := datetime_current();
* };
* }
*
* type VerificationToken {
* required property identifier -> str;
* required property token -> str {
* constraint exclusive;
* };
* required property expires -> datetime;
* property createdAt -> datetime {
* default := datetime_current();
* };
*
* constraint exclusive on ((.identifier, .token));
* }
* }
*
* # Disable the application of access policies within access policies
* # themselves. This behavior will become the default in EdgeDB 3.0.
* # See: https://www.edgedb.com/docs/reference/ddl/access_policies#nonrecursive
*
* using future nonrecursive_access_policies;
* ```
*
* ### Migrate the database schema
*
* 1. Create a migration
*
* ```bash
* edgedb migration create
* ```
*
* 2. Apply the migration
*
* ```bash
* edgedb migrate
* ```
*
* To learn more about [EdgeDB migrations](https://www.edgedb.com/docs/intro/migrations#generate-a-migration) check out the [Migrations docs](https://www.edgedb.com/docs/intro/migrations).
*
* ### Generate the query builder
*
* ```bash
* npx @edgedb/generate edgeql-js
* ```
*
* This will generate the [query builder](https://www.edgedb.com/docs/clients/js/querybuilder) so that you can write fully typed EdgeQL queries with TypeScript in a code-first way.
*
* ```ts
* const query = e.select(e.User, () => ({
* id: true,
* email: true,
* emailVerified: true,
* name: true,
* image: true,
* filter_single: { email: "johndoe@example.com" },
* }));
*
* return await query.run(client);
* ```
*
* ## Deploying
*
* ### Deploy EdgeDB
*
* First deploy an EdgeDB instance on your preferred cloud provider:
*
* - [AWS](https://www.edgedb.com/docs/guides/deployment/aws_aurora_ecs)
* - [Google Cloud](https://www.edgedb.com/docs/guides/deployment/gcp)
* - [Azure](https://www.edgedb.com/docs/guides/deployment/azure_flexibleserver)
* - [DigitalOcean](https://www.edgedb.com/docs/guides/deployment/digitalocean)
* - [Fly.io](https://www.edgedb.com/docs/guides/deployment/fly_io)
* - [Docker](https://www.edgedb.com/docs/guides/deployment/docker) (cloud-agnostic)
*
* ### Find your instance’s DSN
*
* The DSN is also known as a connection string. It will have the format `edgedb://username:password@hostname:port`. The exact instructions for this depend on which cloud provider your'e deploying to.
*
* ### Set an environment variable
*
* ```
* EDGEDB_DSN="edgedb://johndoe:supersecure@myhost.com:420"
* ```
*
* ### Apply migrations
*
* Use the DSN to apply migrations against your remote instance.
*
* ```bash
* edgedb migrate --dsn <your-instance-dsn>
* ```
*
* ### Set up a `prebuild` script
*
* Add the following `prebuild` script to your `package.json`. When your hosting provider initializes the build, it will trigger this script which will generate the query builder. The `npx @edgedb/generate edgeql-js` command will read the value of the `EDGEDB_DSN` environment variable, connect to the database, and generate the query builder before your hosting provider starts building the project.
*
*
*/
export declare function EdgeDBAdapter(client: Client): Adapter;
//# sourceMappingURL=index.d.ts.map
/**
* <div style={{display: "flex", justifyContent: "space-between", alignItems: "center", padding: "16px"}}>
* <p style={{fontWeight: "300"}}>Official <a href="https://www.edgedb.com/">Edge DB</a> adapter for Auth.js / NextAuth.js.</p>
* <p>Official <a href="https://www.edgedb.com/">Edge DB</a> adapter for Auth.js / NextAuth.js.</p>
* <a href="https://www.edgedb.com/">

@@ -18,218 +18,2 @@ * <img style={{display: "block"}} src="/img/adapters/edgedb.svg" width="38" />

*/
/**
*
* To use this Adapter, you need to install `edgedb`, `@edgedb/generate`, and the separate `@auth/edgedb-adapter` package:
*
* ```bash npm2yarn
* npm install edgedb @auth/edgedb-adapter
* npm install @edgedb/generate --save-dev
* ```
*
* ## Installation
*
* First, ensure you have the EdgeDB CLI installed.
*
* Follow the instructions below, or read the [EdgeDB quickstart](https://www.edgedb.com/docs/intro/quickstart) to install the EdgeDB CLI and initialize a project
*
* ### Linux or macOS
*
* ```bash
* curl --proto '=https' --tlsv1.2 -sSf https://sh.edgedb.com | sh
* ```
*
* ### Windows
*
* ```powershell
* iwr https://ps1.edgedb.com -useb | iex
* ```
*
* Check that the CLI is available with the `edgedb --version` command. If you get a `Command not found` error, you may need to open a new terminal window before the `edgedb` command is available.
*
* Once the CLI is installed, initialize a project from the application’s root directory. You’ll be presented with a series of prompts.
*
* ```bash
* edgedb project init
* ```
*
* This process will spin up an EdgeDB instance and [“link”](https://www.edgedb.com/docs/cli/edgedb_instance/edgedb_instance_link#edgedb-instance-link) it with your current directory. As long as you’re inside that directory, CLI commands and client libraries will be able to connect to the linked instance automatically, without additional configuration.
*
* ## Setup
*
* ### NextAuth.js configuration
*
* Configure your NextAuth.js to use the EdgeDB Adapter:
*
* ```js title="pages/api/auth/[...nextauth].js"
* import NextAuth from "next-auth"
* import GoogleProvider from "next-auth/providers/google"
* import { EdgeDBAdapter } from "@auth/edgedb-adapter"
* import { createClient } from "edgedb"
*
* const client = createClient()
*
* export default NextAuth({
* adapter: EdgeDBAdapter(client),
* providers: [
* GoogleProvider({
* clientId: process.env.GOOGLE_CLIENT_ID,
* clientSecret: process.env.GOOGLE_CLIENT_SECRET,
* }),
* ],
* })
* ```
*
* ### Create the EdgeDB schema
*
* Replace the contents of the auto-generated file in `dbschema/default.esdl` with the following:
*
* > This schema is adapted for use in EdgeDB and based upon our main [schema](https://authjs.dev/getting-started/adapters#models)
*
* ```json title="default.esdl"
* module default {
* type User {
* property name -> str;
* required property email -> str {
* constraint exclusive;
* };
* property emailVerified -> datetime;
* property image -> str;
* multi link accounts := .<user[is Account];
* multi link sessions := .<user[is Session];
* property createdAt -> datetime {
* default := datetime_current();
* };
* }
*
* type Account {
* required property userId := .user.id;
* required property type -> str;
* required property provider -> str;
* required property providerAccountId -> str {
* constraint exclusive;
* };
* property refresh_token -> str;
* property access_token -> str;
* property expires_at -> int64;
* property token_type -> str;
* property scope -> str;
* property id_token -> str;
* property session_state -> str;
* required link user -> User {
* on target delete delete source;
* };
* property createdAt -> datetime {
* default := datetime_current();
* };
* constraint exclusive on ((.provider, .providerAccountId));
* }
*
* type Session {
* required property sessionToken -> str {
* constraint exclusive;
* };
* required property userId := .user.id;
* required property expires -> datetime;
* required link user -> User {
* on target delete delete source;
* };
* property createdAt -> datetime {
* default := datetime_current();
* };
* }
*
* type VerificationToken {
* required property identifier -> str;
* required property token -> str {
* constraint exclusive;
* };
* required property expires -> datetime;
* property createdAt -> datetime {
* default := datetime_current();
* };
*
* constraint exclusive on ((.identifier, .token));
* }
* }
*
* # Disable the application of access policies within access policies
* # themselves. This behavior will become the default in EdgeDB 3.0.
* # See: https://www.edgedb.com/docs/reference/ddl/access_policies#nonrecursive
*
* using future nonrecursive_access_policies;
* ```
*
* ### Migrate the database schema
*
* 1. Create a migration
*
* ```bash
* edgedb migration create
* ```
*
* 2. Apply the migration
*
* ```bash
* edgedb migrate
* ```
*
* To learn more about [EdgeDB migrations](https://www.edgedb.com/docs/intro/migrations#generate-a-migration) check out the [Migrations docs](https://www.edgedb.com/docs/intro/migrations).
*
* ### Generate the query builder
*
* ```bash
* npx @edgedb/generate edgeql-js
* ```
*
* This will generate the [query builder](https://www.edgedb.com/docs/clients/js/querybuilder) so that you can write fully typed EdgeQL queries with TypeScript in a code-first way.
*
* ```ts
* const query = e.select(e.User, () => ({
* id: true,
* email: true,
* emailVerified: true,
* name: true,
* image: true,
* filter_single: { email: "johndoe@example.com" },
* }));
*
* return await query.run(client);
* ```
*
* ## Deploying
*
* ### Deploy EdgeDB
*
* First deploy an EdgeDB instance on your preferred cloud provider:
*
* - [AWS](https://www.edgedb.com/docs/guides/deployment/aws_aurora_ecs)
* - [Google Cloud](https://www.edgedb.com/docs/guides/deployment/gcp)
* - [Azure](https://www.edgedb.com/docs/guides/deployment/azure_flexibleserver)
* - [DigitalOcean](https://www.edgedb.com/docs/guides/deployment/digitalocean)
* - [Fly.io](https://www.edgedb.com/docs/guides/deployment/fly_io)
* - [Docker](https://www.edgedb.com/docs/guides/deployment/docker) (cloud-agnostic)
*
* ### Find your instance’s DSN
*
* The DSN is also known as a connection string. It will have the format `edgedb://username:password@hostname:port`. The exact instructions for this depend on which cloud provider your'e deploying to.
*
* ### Set an environment variable
*
* ```
* EDGEDB_DSN="edgedb://johndoe:supersecure@myhost.com:420"
* ```
*
* ### Apply migrations
*
* Use the DSN to apply migrations against your remote instance.
*
* ```bash
* edgedb migrate --dsn <your-instance-dsn>
* ```
*
* ### Set up a `prebuild` script
*
* Add the following `prebuild` script to your `package.json`. When your hosting provider initializes the build, it will trigger this script which will generate the query builder. The `npx @edgedb/generate edgeql-js` command will read the value of the `EDGEDB_DSN` environment variable, connect to the database, and generate the query builder before your hosting provider starts building the project.
*
*
*/
export function EdgeDBAdapter(client) {

@@ -236,0 +20,0 @@ return {

4

package.json
{
"name": "@auth/edgedb-adapter",
"version": "1.0.0",
"version": "1.1.0",
"description": "EdgeDB adapter for next-auth.",

@@ -40,3 +40,3 @@ "homepage": "https://authjs.dev",

"dependencies": {
"@auth/core": "0.30.0"
"@auth/core": "0.31.0"
},

@@ -43,0 +43,0 @@ "peerDependencies": {

@@ -21,3 +21,3 @@ <p align="center">

<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" />
</a>

@@ -24,0 +24,0 @@ </p>

/**
* <div style={{display: "flex", justifyContent: "space-between", alignItems: "center", padding: "16px"}}>
* <p style={{fontWeight: "300"}}>Official <a href="https://www.edgedb.com/">Edge DB</a> adapter for Auth.js / NextAuth.js.</p>
* <p>Official <a href="https://www.edgedb.com/">Edge DB</a> adapter for Auth.js / NextAuth.js.</p>
* <a href="https://www.edgedb.com/">

@@ -27,218 +27,2 @@ * <img style={{display: "block"}} src="/img/adapters/edgedb.svg" width="38" />

/**
*
* To use this Adapter, you need to install `edgedb`, `@edgedb/generate`, and the separate `@auth/edgedb-adapter` package:
*
* ```bash npm2yarn
* npm install edgedb @auth/edgedb-adapter
* npm install @edgedb/generate --save-dev
* ```
*
* ## Installation
*
* First, ensure you have the EdgeDB CLI installed.
*
* Follow the instructions below, or read the [EdgeDB quickstart](https://www.edgedb.com/docs/intro/quickstart) to install the EdgeDB CLI and initialize a project
*
* ### Linux or macOS
*
* ```bash
* curl --proto '=https' --tlsv1.2 -sSf https://sh.edgedb.com | sh
* ```
*
* ### Windows
*
* ```powershell
* iwr https://ps1.edgedb.com -useb | iex
* ```
*
* Check that the CLI is available with the `edgedb --version` command. If you get a `Command not found` error, you may need to open a new terminal window before the `edgedb` command is available.
*
* Once the CLI is installed, initialize a project from the application’s root directory. You’ll be presented with a series of prompts.
*
* ```bash
* edgedb project init
* ```
*
* This process will spin up an EdgeDB instance and [“link”](https://www.edgedb.com/docs/cli/edgedb_instance/edgedb_instance_link#edgedb-instance-link) it with your current directory. As long as you’re inside that directory, CLI commands and client libraries will be able to connect to the linked instance automatically, without additional configuration.
*
* ## Setup
*
* ### NextAuth.js configuration
*
* Configure your NextAuth.js to use the EdgeDB Adapter:
*
* ```js title="pages/api/auth/[...nextauth].js"
* import NextAuth from "next-auth"
* import GoogleProvider from "next-auth/providers/google"
* import { EdgeDBAdapter } from "@auth/edgedb-adapter"
* import { createClient } from "edgedb"
*
* const client = createClient()
*
* export default NextAuth({
* adapter: EdgeDBAdapter(client),
* providers: [
* GoogleProvider({
* clientId: process.env.GOOGLE_CLIENT_ID,
* clientSecret: process.env.GOOGLE_CLIENT_SECRET,
* }),
* ],
* })
* ```
*
* ### Create the EdgeDB schema
*
* Replace the contents of the auto-generated file in `dbschema/default.esdl` with the following:
*
* > This schema is adapted for use in EdgeDB and based upon our main [schema](https://authjs.dev/getting-started/adapters#models)
*
* ```json title="default.esdl"
* module default {
* type User {
* property name -> str;
* required property email -> str {
* constraint exclusive;
* };
* property emailVerified -> datetime;
* property image -> str;
* multi link accounts := .<user[is Account];
* multi link sessions := .<user[is Session];
* property createdAt -> datetime {
* default := datetime_current();
* };
* }
*
* type Account {
* required property userId := .user.id;
* required property type -> str;
* required property provider -> str;
* required property providerAccountId -> str {
* constraint exclusive;
* };
* property refresh_token -> str;
* property access_token -> str;
* property expires_at -> int64;
* property token_type -> str;
* property scope -> str;
* property id_token -> str;
* property session_state -> str;
* required link user -> User {
* on target delete delete source;
* };
* property createdAt -> datetime {
* default := datetime_current();
* };
* constraint exclusive on ((.provider, .providerAccountId));
* }
*
* type Session {
* required property sessionToken -> str {
* constraint exclusive;
* };
* required property userId := .user.id;
* required property expires -> datetime;
* required link user -> User {
* on target delete delete source;
* };
* property createdAt -> datetime {
* default := datetime_current();
* };
* }
*
* type VerificationToken {
* required property identifier -> str;
* required property token -> str {
* constraint exclusive;
* };
* required property expires -> datetime;
* property createdAt -> datetime {
* default := datetime_current();
* };
*
* constraint exclusive on ((.identifier, .token));
* }
* }
*
* # Disable the application of access policies within access policies
* # themselves. This behavior will become the default in EdgeDB 3.0.
* # See: https://www.edgedb.com/docs/reference/ddl/access_policies#nonrecursive
*
* using future nonrecursive_access_policies;
* ```
*
* ### Migrate the database schema
*
* 1. Create a migration
*
* ```bash
* edgedb migration create
* ```
*
* 2. Apply the migration
*
* ```bash
* edgedb migrate
* ```
*
* To learn more about [EdgeDB migrations](https://www.edgedb.com/docs/intro/migrations#generate-a-migration) check out the [Migrations docs](https://www.edgedb.com/docs/intro/migrations).
*
* ### Generate the query builder
*
* ```bash
* npx @edgedb/generate edgeql-js
* ```
*
* This will generate the [query builder](https://www.edgedb.com/docs/clients/js/querybuilder) so that you can write fully typed EdgeQL queries with TypeScript in a code-first way.
*
* ```ts
* const query = e.select(e.User, () => ({
* id: true,
* email: true,
* emailVerified: true,
* name: true,
* image: true,
* filter_single: { email: "johndoe@example.com" },
* }));
*
* return await query.run(client);
* ```
*
* ## Deploying
*
* ### Deploy EdgeDB
*
* First deploy an EdgeDB instance on your preferred cloud provider:
*
* - [AWS](https://www.edgedb.com/docs/guides/deployment/aws_aurora_ecs)
* - [Google Cloud](https://www.edgedb.com/docs/guides/deployment/gcp)
* - [Azure](https://www.edgedb.com/docs/guides/deployment/azure_flexibleserver)
* - [DigitalOcean](https://www.edgedb.com/docs/guides/deployment/digitalocean)
* - [Fly.io](https://www.edgedb.com/docs/guides/deployment/fly_io)
* - [Docker](https://www.edgedb.com/docs/guides/deployment/docker) (cloud-agnostic)
*
* ### Find your instance’s DSN
*
* The DSN is also known as a connection string. It will have the format `edgedb://username:password@hostname:port`. The exact instructions for this depend on which cloud provider your'e deploying to.
*
* ### Set an environment variable
*
* ```
* EDGEDB_DSN="edgedb://johndoe:supersecure@myhost.com:420"
* ```
*
* ### Apply migrations
*
* Use the DSN to apply migrations against your remote instance.
*
* ```bash
* edgedb migrate --dsn <your-instance-dsn>
* ```
*
* ### Set up a `prebuild` script
*
* Add the following `prebuild` script to your `package.json`. When your hosting provider initializes the build, it will trigger this script which will generate the query builder. The `npx @edgedb/generate edgeql-js` command will read the value of the `EDGEDB_DSN` environment variable, connect to the database, and generate the query builder before your hosting provider starts building the project.
*
*
*/
export function EdgeDBAdapter(client: Client): Adapter {

@@ -245,0 +29,0 @@ return {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc