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

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.
@@ -1,24 +1,24 @@
1
1
  "use client";
2
2
  import { useCallback } from "react";
3
3
  function useSignOut({
4
- postLogoutRedirectPath = "/auth/sign-in?logout=success",
5
- retrieveLogoutUrlPath = "/api/auth/sign-out-url",
6
- onLogoutSuccess,
4
+ postSignOutRedirectPath = "/auth/sign-in?sign-out=success",
5
+ retrieveSignOutUrlPath = "/api/auth/sign-out-url",
6
+ onSignOutSuccess,
7
7
  authClient,
8
8
  origin = window.location.origin
9
9
  }) {
10
10
  const standardSignOut = useCallback(() => {
11
11
  void authClient.signOut({
12
12
  fetchOptions: {
13
- onSuccess: onLogoutSuccess
13
+ onSuccess: onSignOutSuccess
14
14
  }
15
15
  });
16
- }, [authClient, onLogoutSuccess]);
16
+ }, [authClient, onSignOutSuccess]);
17
17
  const handleSignOut = useCallback(async () => {
18
- const postLogoutRedirectUri = `${origin}${postLogoutRedirectPath}`;
18
+ const postLogoutRedirectUri = `${origin}${postSignOutRedirectPath}`;
19
19
  try {
20
20
  const response = await fetch(
21
- `${retrieveLogoutUrlPath}?post_logout_redirect_uri=${encodeURIComponent(postLogoutRedirectUri)}`
21
+ `${retrieveSignOutUrlPath}?post_logout_redirect_uri=${encodeURIComponent(postLogoutRedirectUri)}`
22
22
  );
23
23
  if (!response.ok) {
24
24
  const { error } = await response.json().catch(() => ({ error: null }));
@@ -41,8 +41,8 @@ function useSignOut({
41
41
  }, [
42
42
  authClient,
43
43
  origin,
44
- postLogoutRedirectPath,
45
- retrieveLogoutUrlPath,
44
+ postSignOutRedirectPath,
45
+ retrieveSignOutUrlPath,
46
46
  standardSignOut
47
47
  ]);
48
48
  return { handleSignOut };
@@ -1,22 +1,21 @@
1
- import type { AuthClient } from "better-auth/client";
2
- import type { getBetterAuthClientOptions } from "../index";
1
+ import type { createAuthClient } from "better-auth/react";
3
2
  /**
4
3
  * Custom hook for handling user sign-out with support for federated logout.
5
4
  *
6
5
  * @param params - Configuration options
7
- * @param params.postLogoutRedirectPath - Path to redirect to after logout (defaults to "/auth/sign-in")
6
+ * @param params.postSignOutRedirectPath - Path to redirect to after logout (defaults to "/auth/sign-in")
8
7
  * @returns Object containing handleSignOut function to initiate the logout process
9
8
  *
10
9
  * @example
11
10
  * ```tsx
12
- * const { handleSignOut } = useSignOut({ postLogoutRedirectPath: "/auth/sign-in" });
11
+ * const { handleSignOut } = useSignOut({ postSignOutRedirectPath: "/auth/sign-in" });
13
12
  * ```
14
13
  */
15
- export declare function useSignOut({ postLogoutRedirectPath, retrieveLogoutUrlPath, onLogoutSuccess, authClient, origin, }: {
16
- postLogoutRedirectPath?: string;
17
- retrieveLogoutUrlPath?: string;
18
- onLogoutSuccess?: () => void;
19
- authClient: AuthClient<ReturnType<typeof getBetterAuthClientOptions>>;
14
+ export declare function useSignOut({ postSignOutRedirectPath, retrieveSignOutUrlPath, onSignOutSuccess, authClient, origin, }: {
15
+ postSignOutRedirectPath?: string;
16
+ retrieveSignOutUrlPath?: string;
17
+ onSignOutSuccess?: () => void;
18
+ authClient: ReturnType<typeof createAuthClient>;
20
19
  origin?: string;
21
20
  }): {
22
21
  handleSignOut: () => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imtf/auth",
3
- "version": "0.0.1-alpha.1",
3
+ "version": "0.0.1-alpha.2",
4
4
  "description": "Better auth wrapper for imtf usage",
5
5
  "license": "UNLICENSED",
6
6
  "author": "",