Skip to content

Commit

Permalink
fix: fix type, remove unused imports, define AuthEvent type
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Cardenas authored and cardenasj97 committed Sep 4, 2024
1 parent 549fe62 commit 2fbfd07
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/createServerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

0 comments on commit 2fbfd07

Please sign in to comment.