UNPKG

bento-auth-js

Version:

Authentication library for web applications of Bento-Platform

31 lines (30 loc) 1.92 kB
import { MutableRefObject } from "react"; import { Resource } from "./resources"; import { AuthSliceState } from "./redux/authSlice"; import { type OIDCSliceState } from "./redux/openIdConfigSlice"; type MessageHandlerFunc = (e: MessageEvent) => void; export declare const useAuthState: () => AuthSliceState; export declare const useIsAuthenticated: () => boolean; export declare const useAccessToken: () => string | undefined; export declare const useAuthorizationHeader: () => Record<string, string>; export declare const useIsAutoAuthenticating: () => boolean; type BaseResourcePermissionsState = { isFetching: boolean; hasAttempted: boolean; error: string; }; type ResourcePermissionsState = BaseResourcePermissionsState & { permissions: string[]; }; type ResourceHasPermissionState = BaseResourcePermissionsState & { hasPermission: boolean; }; export declare const useResourcesPermissions: (resources: Resource[], authzUrl: string | undefined) => Record<string, ResourcePermissionsState>; export declare const useResourcePermissions: (resource: Resource, authzUrl: string | undefined) => ResourcePermissionsState; export declare const useHasResourcePermission: (resource: Resource, authzUrl: string | undefined, permission: string) => ResourceHasPermissionState; export declare const useOpenIdConfig: () => OIDCSliceState; export declare const useSignInPopupTokenHandoff: (windowMessageHandler: MutableRefObject<null | MessageHandlerFunc>) => void; export declare const useSessionWorkerTokenRefresh: (sessionWorkerRef: MutableRefObject<null | Worker>, createWorker: () => Worker, fetchUserDependentData?: (() => unknown) | undefined) => void; export declare const useOpenSignInWindowCallback: (signInWindow: MutableRefObject<null | Window>, windowFeatures?: string) => () => void; export declare const usePopupOpenerAuthCallback: () => (code: string, verifier: string) => Promise<void>; export {};