@imtf/auth 0.0.1-alpha.2 → 1.0.0

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,12 +1,12 @@
1
- "use client";
2
1
  import { useCallback } from "react";
3
2
  function useSignOut({
4
3
  postSignOutRedirectPath = "/auth/sign-in?sign-out=success",
5
4
  retrieveSignOutUrlPath = "/api/auth/sign-out-url",
6
5
  onSignOutSuccess,
7
6
  authClient,
8
- origin = window.location.origin
7
+ origin: providedOrigin
9
8
  }) {
9
+ const origin = providedOrigin ?? (typeof window !== "undefined" ? window.location.origin : "");
10
10
  const standardSignOut = useCallback(() => {
11
11
  void authClient.signOut({
12
12
  fetchOptions: {
@@ -30,6 +30,9 @@ function useSignOut({
30
30
  return;
31
31
  }
32
32
  await authClient.signOut();
33
+ if (typeof window === "undefined") {
34
+ return;
35
+ }
33
36
  window.location.href = url;
34
37
  } catch (error) {
35
38
  console.error(
@@ -1,8 +1,8 @@
1
- import { getBetterAuthOptions } from "./options/auth.js";
2
- import { getBetterAuthClientOptions } from "./options/auth-client.js";
3
- import { getSignOutUrlRoute } from "./routes/getSignOutUrlRoute.js";
4
- import { PROVIDER_ID } from "./constants.js";
5
- import { useSignOut } from "./hooks/useSignOut.js";
1
+ import { getBetterAuthOptions } from "./options/auth.esm.js";
2
+ import { getBetterAuthClientOptions } from "./options/auth-client.esm.js";
3
+ import { getSignOutUrlRoute } from "./routes/getSignOutUrlRoute.esm.js";
4
+ import { PROVIDER_ID } from "./constants.esm.js";
5
+ import { useSignOut } from "./hooks/useSignOut.esm.js";
6
6
  export {
7
7
  PROVIDER_ID,
8
8
  getBetterAuthClientOptions,
@@ -1,4 +1,3 @@
1
- "use client";
2
1
  import { genericOAuthClient } from "better-auth/client/plugins";
3
2
  function getBetterAuthClientOptions() {
4
3
  return {
@@ -1,6 +1,6 @@
1
1
  import { nextCookies } from "better-auth/next-js";
2
2
  import { genericOAuth } from "better-auth/plugins";
3
- import { PROVIDER_ID } from "../constants.js";
3
+ import { PROVIDER_ID } from "../constants.esm.js";
4
4
  function getBetterAuthOptions({
5
5
  oidcDiscoveryUrl,
6
6
  authSecret,
@@ -1,4 +1,4 @@
1
- import { PROVIDER_ID } from "../constants.js";
1
+ import { PROVIDER_ID } from "../constants.esm.js";
2
2
  function getSignOutUrlRoute({
3
3
  auth,
4
4
  discoveryUrl,
@@ -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": "1.0.0",
4
4
  "description": "Better auth wrapper for imtf usage",
5
5
  "license": "UNLICENSED",
6
6
  "author": "",
@@ -33,7 +33,7 @@
33
33
  }
34
34
  },
35
35
  "dependencies": {
36
- "@imtf/panache": "^5.5.0"
36
+ "@imtf/panache": "^5.6.0-beta.0"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@mui/lab": "^7.0.1-beta.18",
File without changes