-
-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add handleAuth function to export all hooks as an array
- Loading branch information
1 parent
588d329
commit 1c95004
Showing
6 changed files
with
34 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@supabase/auth-helpers-sveltekit': patch | ||
--- | ||
|
||
Add new handleAuth function to export all hooks as an array to destructure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { COOKIE_OPTIONS, TOKEN_REFRESH_MARGIN, type CookieOptions } from "@supabase/auth-helpers-shared"; | ||
import { handleCallback } from "./callback"; | ||
import { handleLogout } from "./logout"; | ||
import { handleUser } from "./user"; | ||
|
||
export interface HandleAuthOptions { | ||
cookieOptions?: CookieOptions; | ||
logout?: { returnTo?: string }; | ||
tokenRefreshMargin?: number; | ||
} | ||
|
||
export const handleAuth = (options: HandleAuthOptions = {}) => { | ||
const { logout } = options; | ||
const cookieOptions = { ...COOKIE_OPTIONS, ...options.cookieOptions }; | ||
const tokenRefreshMargin = | ||
options.tokenRefreshMargin ?? TOKEN_REFRESH_MARGIN; | ||
return [ | ||
handleCallback({ cookieOptions }), | ||
handleUser({ cookieOptions, tokenRefreshMargin }), | ||
handleLogout({ cookieOptions, ...logout }) | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { handleCallback } from './callback'; | ||
export { handleUser } from './user'; | ||
export { handleLogout } from './logout'; | ||
export { handleAuth } from './auth'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters