authera 1.2.8-test-9 → 1.2.8-test-10

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,5 @@
1
1
  import { userBaseData } from "../helper/context";
2
2
  export declare function useAuth<T extends string>(): {
3
- backendUrl: string;
4
- storage: import("../helper/storage").storagesNames | import("../helper/storage").customeFunc;
5
- tokenType: "jwt";
6
- refreshStrategy: "silent";
7
- fallback_401_url: string;
8
- on_after_login?: (response_data: any) => void;
9
- on_after_step?: (step_key: string) => void;
10
3
  permits: T[];
11
4
  isPermitted: (perm: T) => boolean;
12
5
  on: (perm: T, callback: () => void, fallback?: () => void) => void;
@@ -68,6 +68,6 @@ export function useAuth() {
68
68
  setAccessToken,
69
69
  setRefreshToken,
70
70
  logout,
71
- ...authera_props,
71
+ // ...authera_props,
72
72
  };
73
73
  }
package/dist/index.d.ts CHANGED
@@ -1,15 +1,7 @@
1
- import { customeFunc, storagesNames } from "./helper/storage";
2
1
  import { type AuthHookSettings } from "./helper/types";
3
2
  export default function AuthHook<T extends string>(props: AuthHookSettings<T>): {
4
3
  createAuthProvider: (children: React.ReactNode) => React.ReactNode;
5
4
  useAuth: () => {
6
- backendUrl: string;
7
- storage: storagesNames | customeFunc;
8
- tokenType: "jwt";
9
- refreshStrategy: "silent";
10
- fallback_401_url: string;
11
- on_after_login?: (response_data: any) => void;
12
- on_after_step?: (step_key: string) => void;
13
5
  permits: T[];
14
6
  isPermitted: (perm: T) => boolean;
15
7
  on: (perm: T, callback: () => void, fallback?: (() => void) | undefined) => void;
@@ -4,4 +4,4 @@ export interface AuthGuardProps {
4
4
  permits: string[];
5
5
  action: "show" | "hide" | "redirect";
6
6
  }
7
- export default function AuthGuard({ children, permits, action, }: AuthGuardProps): import("react/jsx-runtime").JSX.Element | null | undefined;
7
+ export default function AuthGuard({ children, permits, action, }: AuthGuardProps): void;
package/dist/web/guard.js CHANGED
@@ -1,23 +1,18 @@
1
1
  "use client";
2
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
3
- import { useAuth } from "../hooks/useAuth";
4
2
  export default function AuthGuard({ children, permits, action, }) {
5
- const { isPermittedAll: isPermittedHook, fallback_401_url } = useAuth();
6
- const isPermitted = isPermittedHook(permits);
7
- if (action === "redirect" && !isPermitted) {
8
- window.location.href = fallback_401_url;
9
- return null;
10
- }
11
- if (action === "show") {
12
- if (isPermitted)
13
- return _jsx(_Fragment, { children: children });
14
- else
15
- return null;
16
- }
17
- if (action === "hide") {
18
- if (isPermitted)
19
- return null;
20
- else
21
- return _jsx(_Fragment, { children: children });
22
- }
3
+ // const { isPermittedAll: isPermittedHook, fallback_401_url } =
4
+ // useAuth<string>();
5
+ // const isPermitted = isPermittedHook(permits);
6
+ // if (action === "redirect" && !isPermitted) {
7
+ // window.location.href = fallback_401_url;
8
+ // return null;
9
+ // }
10
+ // if (action === "show") {
11
+ // if (isPermitted) return <>{children}</>;
12
+ // else return null;
13
+ // }
14
+ // if (action === "hide") {
15
+ // if (isPermitted) return null;
16
+ // else return <>{children}</>;
17
+ // }
23
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authera",
3
- "version": "1.2.8-test-9",
3
+ "version": "1.2.8-test-10",
4
4
  "description": "this project is a simple auth hook for react",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",