@propelauth/react
Version:
A React library for managing authentication, backed by PropelAuth
44 lines (43 loc) • 2.4 kB
TypeScript
import { AccessTokenForActiveOrg, AuthenticationInfo, RedirectToAccountOptions, RedirectToCreateOrgOptions, RedirectToLoginOptions, RedirectToOrgPageOptions, RedirectToSetupSAMLPageOptions, RedirectToSignupOptions } from "@propelauth/javascript";
import React from "react";
export interface Tokens {
getAccessTokenForOrg: (orgId: string) => Promise<AccessTokenForActiveOrg>;
getAccessToken: () => Promise<string | undefined>;
}
export interface InternalAuthState {
loading: boolean;
authInfo: AuthenticationInfo | null;
logout: (redirectOnLogout: boolean) => Promise<void>;
activeOrgFn: () => string | null;
redirectToLoginPage: (options?: RedirectToLoginOptions) => void;
redirectToSignupPage: (options?: RedirectToSignupOptions) => void;
redirectToAccountPage: (options?: RedirectToAccountOptions) => void;
redirectToOrgPage: (orgId?: string, options?: RedirectToOrgPageOptions) => void;
redirectToCreateOrgPage: (options?: RedirectToCreateOrgOptions) => void;
redirectToSetupSAMLPage: (orgId: string, options?: RedirectToSetupSAMLPageOptions) => void;
getSignupPageUrl(options?: RedirectToSignupOptions): string;
getLoginPageUrl(options?: RedirectToLoginOptions): string;
getAccountPageUrl(options?: RedirectToAccountOptions): string;
getOrgPageUrl(orgId?: string, options?: RedirectToOrgPageOptions): string;
getCreateOrgPageUrl(options?: RedirectToCreateOrgOptions): string;
getSetupSAMLPageUrl(orgId: string, options?: RedirectToSetupSAMLPageOptions): string;
authUrl: string;
tokens: Tokens;
refreshAuthInfo: () => Promise<void>;
defaultDisplayWhileLoading?: React.ReactElement;
defaultDisplayIfLoggedOut?: React.ReactElement;
}
export declare type AuthProviderProps = {
authUrl: string;
defaultDisplayWhileLoading?: React.ReactElement;
defaultDisplayIfLoggedOut?: React.ReactElement;
getActiveOrgFn?: () => string | null;
children?: React.ReactNode;
minSecondsBeforeRefresh?: number;
};
export interface RequiredAuthProviderProps extends Omit<AuthProviderProps, "defaultDisplayWhileLoading" | "defaultDisplayIfLoggedOut"> {
displayWhileLoading?: React.ReactElement;
displayIfLoggedOut?: React.ReactElement;
}
export declare const AuthContext: React.Context<InternalAuthState | undefined>;
export declare const AuthProvider: (props: AuthProviderProps) => JSX.Element;