From 7f7f3851109399ec7281ca9d9532cef5da68d753 Mon Sep 17 00:00:00 2001 From: Dijana Pavlovic Date: Wed, 11 Dec 2024 10:30:50 +0100 Subject: [PATCH] auth-remix: rename edgedb to gel --- packages/auth-remix/package.json | 14 +++++++------- packages/auth-remix/readme.md | 23 ++++++++++++----------- packages/auth-remix/src/client.ts | 8 ++++---- packages/auth-remix/src/server.ts | 10 +++++----- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/packages/auth-remix/package.json b/packages/auth-remix/package.json index 1db864d26..1dd301a93 100644 --- a/packages/auth-remix/package.json +++ b/packages/auth-remix/package.json @@ -1,12 +1,12 @@ { - "name": "@edgedb/auth-remix", - "description": "Helper library to integrate the EdgeDB Auth extension with Remix", + "name": "@gel/auth-remix", + "description": "Helper library to integrate the Gel Auth extension with Remix", "version": "0.2.2", - "author": "EdgeDB ", + "author": "Gel ", "type": "module", "repository": { "type": "git", - "url": "https://github.com/edgedb/edgedb-js.git", + "url": "https://github.com/gel/gel-js.git", "directory": "packages/auth-remix" }, "license": "Apache-2.0", @@ -23,14 +23,14 @@ "devDependencies": { "@repo/tsconfig": "*", "@types/node": "^20.12.13", - "edgedb": "*", + "gel": "*", "typescript": "^5.5.2" }, "peerDependencies": { - "edgedb": "^1.3.6" + "gel": "^1.3.6" }, "dependencies": { - "@edgedb/auth-core": "^0.2.1", + "@gel/auth-core": "^0.2.1", "@remix-run/server-runtime": "^2.9.2", "cookie": "^0.6.0" }, diff --git a/packages/auth-remix/readme.md b/packages/auth-remix/readme.md index 05d5b5783..71fd29b3d 100644 --- a/packages/auth-remix/readme.md +++ b/packages/auth-remix/readme.md @@ -1,4 +1,4 @@ -# @edgedb/auth-remix +# @gel/auth-remix This library provides a set of utilities to help you integrate authentication into your [Remix](https://remix.run/) application. It supports authentication with various OAuth providers, as well as email/password authentication. @@ -8,15 +8,16 @@ It supports authentication with various OAuth providers, as well as email/passwo This package is published on npm and can be installed with your package manager of choice. ```bash -npm install @edgedb/auth-remix +npm install @gel/auth-remix ``` ## Setup **Prerequisites**: + - Node v18+ - **Note**: Due to using the `crypto` global, you will need to start Node with `--experimental-global-webcrypto`. You can add this option to your `NODE_OPTIONS` environment variable, like `NODE_OPTIONS='--experimental-global-webcrypto'` in the appropriate `.env` file. -- Before adding EdgeDB auth to your Remix app, you will first need to enable the `auth` extension in your EdgeDB schema, and have configured the extension with some providers (you can do this in CLI or EdgeDB UI). Refer to the auth extension docs for details on how to do this. +- Before adding Gel auth to your Remix app, you will first need to enable the `auth` extension in your Gel schema, and have configured the extension with some providers (you can do this in CLI or Gel UI). Refer to the auth extension docs for details on how to do this. 1. Initialize the client auth helper by passing configuration options to `createClientAuth()`. This will return a `RemixClientAuth` object which you can use in your components. You can skip this part if you find it unnecessary and provide all your data through the loader (the next step), but we suggest having the client auth too and use it directly in your components to get OAuth, BuiltinUI and signout URLs. @@ -25,7 +26,7 @@ npm install @edgedb/auth-remix import createClientAuth, { type RemixAuthOptions, -} from "@edgedb/auth-remix/client"; +} from "@gel/auth-remix/client"; export const options: RemixAuthOptions = { baseUrl: "http://localhost:3000", @@ -37,13 +38,13 @@ const auth = createClientAuth(options); export default auth; ``` -2. Initialize the server auth helper by passing an EdgeDB `Client` object to `createServerAuth()`, along with configuration options. This will return a `RemixServerAuth` object which you can use across your app on the server side. +2. Initialize the server auth helper by passing an Gel `Client` object to `createServerAuth()`, along with configuration options. This will return a `RemixServerAuth` object which you can use across your app on the server side. ```ts // app/services/auth.server.ts - import createServerAuth from "@edgedb/auth-remix/server"; - import { createClient } from "edgedb"; + import createServerAuth from "@gel/auth-remix/server"; + import { createClient } from "gel"; import { options } from "./auth"; export const client = createClient({ @@ -58,8 +59,8 @@ export default auth; - `baseUrl: string`, _required_, The url of your application; needed for various auth flows (eg. OAuth) to redirect back to. - `authRoutesPath?: string`, The path to the auth route handlers, defaults to `'auth'`, see below for more details. - - `authCookieName?: string`, The name of the cookie where the auth token will be stored, defaults to `'edgedb-session'`. - - `pkceVerifierCookieName?: string`: The name of the cookie where the verifier for the PKCE flow will be stored, defaults to `'edgedb-pkce-verifier'` + - `authCookieName?: string`, The name of the cookie where the auth token will be stored, defaults to `'gel-session'`. + - `pkceVerifierCookieName?: string`: The name of the cookie where the verifier for the PKCE flow will be stored, defaults to `'gel-pkce-verifier'` - `passwordResetUrl?: string`: The url of the the password reset page; needed if you want to enable password reset emails in your app. 3. Setup the auth route handlers, with `auth.createAuthRouteHandlers()`. Callback functions can be provided to handle various auth events, where you can define what to do in the case of successful signin's or errors. You only need to configure callback functions for the types of auth you wish to use in your app. @@ -89,7 +90,7 @@ export default auth; By default the handlers expect to exist under the `/routes/auth` path in your app, however if you want to place them elsewhere, you will also need to configure the `authRoutesPath` option of `createServerAuth` to match. -4. Now we just need to setup the UI to allow your users to sign in/up, etc. The easiest way to get started is to use the EdgeDB Auth's builtin UI. Or alternatively you can implement your own custom UI. +4. Now we just need to setup the UI to allow your users to sign in/up, etc. The easiest way to get started is to use the Gel Auth's builtin UI. Or alternatively you can implement your own custom UI. **Builtin UI** @@ -108,7 +109,7 @@ export default auth; - `emailPasswordResetPassword` - `signout` - `isPasswordResetTokenValid(resetToken: string)`: Checks if a password reset token is still valid. - - `getOAuthUrl(providerName: string)`: This method takes the name of an OAuth provider (make sure you configure providers you need in the auth ext config first using CLI or EdgeDB UI) and returns a link that will initiate the OAuth sign in flow for that provider. You will also need to configure the `onOAuthCallback` auth route handler. + - `getOAuthUrl(providerName: string)`: This method takes the name of an OAuth provider (make sure you configure providers you need in the auth ext config first using CLI or Gel UI) and returns a link that will initiate the OAuth sign in flow for that provider. You will also need to configure the `onOAuthCallback` auth route handler. ## Usage diff --git a/packages/auth-remix/src/client.ts b/packages/auth-remix/src/client.ts index fd81c9ea9..5440d88f3 100644 --- a/packages/auth-remix/src/client.ts +++ b/packages/auth-remix/src/client.ts @@ -1,5 +1,5 @@ -import type { BuiltinOAuthProviderNames } from "@edgedb/auth-core"; -import { WebAuthnClient } from "@edgedb/auth-core/webauthn"; +import type { BuiltinOAuthProviderNames } from "@gel/auth-core"; +import { WebAuthnClient } from "@gel/auth-core/webauthn"; export interface RemixAuthOptions { baseUrl: string; @@ -27,8 +27,8 @@ export class RemixClientAuth { /** @internal */ constructor(options: RemixAuthOptions) { this.options = { - authCookieName: "edgedb-session", - pkceVerifierCookieName: "edgedb-pkce-verifier", + authCookieName: "gel-session", + pkceVerifierCookieName: "gel-pkce-verifier", ...options, baseUrl: options.baseUrl.replace(/\/$/, ""), authRoutesPath: options.authRoutesPath?.replace(/^\/|\/$/g, "") ?? "auth", diff --git a/packages/auth-remix/src/server.ts b/packages/auth-remix/src/server.ts index d55941ccb..fd47afe06 100644 --- a/packages/auth-remix/src/server.ts +++ b/packages/auth-remix/src/server.ts @@ -1,6 +1,6 @@ import { redirect, json, type TypedResponse } from "@remix-run/server-runtime"; import * as cookie from "cookie"; -import type { Client } from "edgedb"; +import type { Client } from "gel"; import { Auth, builtinOAuthProviderNames, @@ -12,14 +12,14 @@ import { PKCEError, BackendError, OAuthProviderFailureError, - EdgeDBAuthError, + GelAuthError, MagicLinkFailureError, type AuthenticationResponseJSON, type RegistrationResponseJSON, -} from "@edgedb/auth-core"; +} from "@gel/auth-core"; import { type RemixAuthOptions, RemixClientAuth } from "./client.js"; -export * from "@edgedb/auth-core/errors"; +export * from "@gel/auth-core/errors"; export type { TokenData, RemixAuthOptions }; export type BuiltinProviderNames = @@ -334,7 +334,7 @@ export class RemixServerAuth extends RemixClientAuth { if (error) { const desc = searchParams.get("error_description"); return cbCall(onBuiltinUICallback, { - error: new EdgeDBAuthError(error + (desc ? `: ${desc}` : "")), + error: new GelAuthError(error + (desc ? `: ${desc}` : "")), }); } const code = searchParams.get("code");