From 2fbfd074cb5d42d22dd1be59cfa9fe8960e7aec7 Mon Sep 17 00:00:00 2001 From: Juan Cardenas Date: Sun, 11 Aug 2024 09:44:14 -0500 Subject: [PATCH] fix: fix type, remove unused imports, define AuthEvent type --- src/createServerClient.ts | 13 +++---------- src/types.ts | 8 ++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/createServerClient.ts b/src/createServerClient.ts index c59edb1..a803759 100644 --- a/src/createServerClient.ts +++ b/src/createServerClient.ts @@ -5,19 +5,12 @@ import type { } from "@supabase/supabase-js/dist/module/lib/types"; import { VERSION } from "./version"; -import { - DEFAULT_COOKIE_OPTIONS, - combineChunks, - createChunks, - deleteChunks, - isBrowser, - isChunkLike, -} from "./utils"; import { createStorageFromOptions, applyServerStorage } from "./cookies"; import type { CookieOptionsWithName, CookieMethodsServer, CookieMethodsServerDeprecated, + AuthEvent, } from "./types"; /** @@ -75,7 +68,7 @@ export function createServerClient< * **Use in pages, components or routes.** * * To use Supabase features server-side rendered in pages, components or routes - * (a.k.a. actions / APIs) you must create a client with this funciton. Not all + * (a.k.a. actions / APIs) you must create a client with this function. Not all * frameworks allow the ability to set cookies or response headers when pages * or components are rendered. In those cases you _can omit `setAll` (or the * deprecated `set`, `remove`) cookie option methods_. **It is strongly @@ -180,7 +173,7 @@ export function createServerClient< }, ); - client.auth.onAuthStateChange(async (event) => { + client.auth.onAuthStateChange(async (event: AuthEvent) => { // The SIGNED_IN event is fired very often, but we don't need to // apply the storage each time it fires, only if there are changes // that need to be set -- which is if setItems / removeItems have diff --git a/src/types.ts b/src/types.ts index 043f363..460b43a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -47,3 +47,11 @@ export type CookieMethodsServer = { getAll: GetAllCookies; setAll?: SetAllCookies; }; + +export type AuthEvent = + | "SIGNED_IN" + | "TOKEN_REFRESHED" + | "USER_UPDATED" + | "PASSWORD_RECOVERY" + | "SIGNED_OUT" + | "MFA_CHALLENGE_VERIFIED";