UNPKG

@frank-auth/react

Version:

Flexible and customizable React UI components for Frank Authentication

89 lines 4.2 kB
import { AuthMethod, Organization, Session, User, XID } from '../types'; export interface DecodedJWT { header: { alg: string; typ: string; kid?: string; }; payload: { sub: XID; aud: string; iss: string; exp: number; iat: number; nbf?: number; jti?: XID; user_type?: string; organization_id?: XID; permissions?: string[]; roles?: string[]; mfa_verified?: boolean; device_id?: string; client_id?: string; }; signature: string; } export declare const decodeJWT: (token: string) => DecodedJWT | null; export declare const isTokenExpired: (token: string) => boolean; export declare const getTokenExpiration: (token: string) => Date | null; export declare const getTokenTimeToExpiry: (token: string) => number; export declare const isSessionActive: (session: Session) => boolean; export declare const getSessionTimeRemaining: (session: Session) => number; export declare const formatSessionDuration: (session: Session) => string; export declare const getUserDisplayName: (user: User) => string; export declare const getUserInitials: (user: User) => string; export declare const isUserVerified: (user: User) => boolean; export declare const getUserVerificationStatus: (user: User) => { isVerified: boolean; emailVerified: boolean; phoneVerified: boolean; missingVerifications: string[]; }; export declare const canUserAccessOrganization: (user: User, organizationId: XID) => boolean; export declare const getUserRoleInOrganization: (user: User, organizationId: XID) => string | null; export declare const getUserPermissionsInOrganization: (user: User, organizationId: XID) => string[]; export declare const hasPermission: (user: User, permission: string, organizationId?: XID) => boolean; export declare const hasRole: (user: User, role: string, organizationId?: XID) => boolean; export declare const isUserOrganizationOwner: (user: User, organization: Organization) => boolean; export declare const canUserManageOrganization: (user: User, organization: Organization) => boolean; export declare const canUserInviteMembers: (user: User, organization: Organization) => boolean; export declare const getRequiredAuthMethods: (methods: AuthMethod[]) => AuthMethod[]; export declare const isAuthMethodAvailable: (method: AuthMethod, enabledMethods: AuthMethod[]) => boolean; export declare const getAuthMethodDisplayName: (method: AuthMethod) => string; export declare const validatePasswordStrength: (password: string) => { score: number; feedback: string[]; isValid: boolean; }; export declare const getPasswordStrengthLabel: (score: number) => string; export declare const isCommonPassword: (password: string) => boolean; export declare const formatBackupCode: (code: string) => string; export declare const validateTOTPCode: (code: string) => boolean; export declare const validateSMSCode: (code: string) => boolean; export declare const validateBackupCode: (code: string) => boolean; export declare const getDeviceInfo: () => { deviceType: "desktop" | "mobile" | "tablet" | "unknown"; browser?: string; operatingSystem?: string; userAgent: string; }; export declare const isPasskeySupported: () => boolean; export declare const getPasskeySupport: () => Promise<{ supported: boolean; conditionalUI: boolean; platformAuthenticator: boolean; }>; export declare const buildRedirectUrl: (baseUrl: string, params: Record<string, string | undefined>) => string; export declare const parseAuthCallback: (url: string) => { code?: string; state?: string; error?: string; error_description?: string; }; export declare const generateRandomState: () => string; export declare const isSecureContext: () => boolean; export declare const requireSecureContext: () => void; export declare const sanitizeRedirectUrl: (url: string, allowedDomains: string[]) => string | null; export declare const createAuthEvent: (type: string, data?: Record<string, any>) => CustomEvent; export declare const dispatchAuthEvent: (type: string, data?: Record<string, any>) => void; //# sourceMappingURL=auth.d.ts.map