UNPKG

@3kjos/fortress

Version:

3kjos fortress is an authentification ecosystem.

55 lines (50 loc) 2.24 kB
import { AxiosRequestConfig } from 'axios'; import { PropsWithChildren } from 'react'; interface FortressProps { base_route_url: string | URL; base_api_route_url?: string | URL; ping_route_url: string; csrf_cookies_route_url?: string | undefined; allowed_path?: string[]; after_login_path?: string; disallowed_path?: string[]; login_path: string; signup_path: string; desallowed_redirect_path?: string; session_storage_name?: string; http_request_config?: AxiosRequestConfig<any> | undefined; } interface FortressEntryProps extends PropsWithChildren<ConfigInterface> { } interface ConfigInterface { config: FortressProps; } interface UseFortressHttpInterface { httpPost: UseFortressHttpFunctionType; httpGet: UseFortressHttpFunctionType; httpPut: UseFortressHttpFunctionType; httpDelete: UseFortressHttpFunctionType; httpSubmitForm: UseFortressHttpPropsInterface; } type UseFortressHttpPropsInterface = (route_url: string, data: object) => Promise<void>; type UseFortressHttpFunctionType = (url: string, data: object) => Promise<any | void>; /** * Renders the main application component. * * @param {FortressEntryProps} props - The props for the Fortress component. * @return {JSX.Element} The rendered application component. */ declare const Fortress: (props: FortressEntryProps) => JSX.Element; /** * Custom hook that provides functions for making HTTP requests using Axios. * * @return {UseFortressHttpInterface} An object containing functions for making HTTP requests: * - httpPost: Asynchronous function that sends a POST request to the specified URL with the provided data. * - httpGet: Asynchronous function that sends a GET request to the specified URL. * - httpPut: Asynchronous function that sends a PUT request to the specified URL with the provided data. * - httpDelete: Asynchronous function that sends a DELETE request to the specified URL. * - httpSubmitForm: Asynchronous function that sends a POST request to the specified URL with the provided data, * and handles CSRF token retrieval and session storage. */ declare function useFortressHttp(): UseFortressHttpInterface; export { Fortress as default, useFortressHttp };