@imtf/auth 0.0.1-alpha.2 → 0.0.1-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,8 +5,9 @@ function useSignOut({
5
5
  retrieveSignOutUrlPath = "/api/auth/sign-out-url",
6
6
  onSignOutSuccess,
7
7
  authClient,
8
- origin = window.location.origin
8
+ origin: providedOrigin
9
9
  }) {
10
+ const origin = providedOrigin ?? (typeof window !== "undefined" ? window.location.origin : "");
10
11
  const standardSignOut = useCallback(() => {
11
12
  void authClient.signOut({
12
13
  fetchOptions: {
@@ -30,6 +31,9 @@ function useSignOut({
30
31
  return;
31
32
  }
32
33
  await authClient.signOut();
34
+ if (typeof window === "undefined") {
35
+ return;
36
+ }
33
37
  window.location.href = url;
34
38
  } catch (error) {
35
39
  console.error(
@@ -3,15 +3,15 @@ import type { createAuthClient } from "better-auth/react";
3
3
  * Custom hook for handling user sign-out with support for federated logout.
4
4
  *
5
5
  * @param params - Configuration options
6
- * @param params.postSignOutRedirectPath - Path to redirect to after logout (defaults to "/auth/sign-in")
7
- * @returns Object containing handleSignOut function to initiate the logout process
6
+ * @param params.postSignOutRedirectPath - Path to redirect to after sign-out (defaults to "/auth/sign-in?sign-out=success")
7
+ * @returns Object containing handleSignOut function to initiate the sign-out process
8
8
  *
9
9
  * @example
10
10
  * ```tsx
11
- * const { handleSignOut } = useSignOut({ postSignOutRedirectPath: "/auth/sign-in" });
11
+ * const { handleSignOut } = useSignOut({ postSignOutRedirectPath: "/auth/sign-in?sign-out=success" });
12
12
  * ```
13
13
  */
14
- export declare function useSignOut({ postSignOutRedirectPath, retrieveSignOutUrlPath, onSignOutSuccess, authClient, origin, }: {
14
+ export declare function useSignOut({ postSignOutRedirectPath, retrieveSignOutUrlPath, onSignOutSuccess, authClient, origin: providedOrigin, }: {
15
15
  postSignOutRedirectPath?: string;
16
16
  retrieveSignOutUrlPath?: string;
17
17
  onSignOutSuccess?: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imtf/auth",
3
- "version": "0.0.1-alpha.2",
3
+ "version": "0.0.1-alpha.3",
4
4
  "description": "Better auth wrapper for imtf usage",
5
5
  "license": "UNLICENSED",
6
6
  "author": "",