@frank-auth/react
Version:
Flexible and customizable React UI components for Frank Authentication
239 lines • 7.59 kB
TypeScript
import { VerificationMethod, VerificationStatus } from '../types';
import { InvitationData } from '../components/auth/invitations';
/**
* Format phone number for display
*/
export declare function formatPhoneNumber(phoneNumber: string, format?: 'national' | 'international' | 'masked'): string;
/**
* Validate phone number
*/
export declare function validatePhoneNumber(phoneNumber: string): {
isValid: boolean;
error?: string;
};
/**
* Parse phone number to extract components
*/
export declare function parsePhoneNumber(phoneNumber: string): {
countryCode?: string;
areaCode?: string;
exchange?: string;
number?: string;
extension?: string;
};
/**
* Mask email address for display
*/
export declare function maskEmail(email: string): string;
/**
* Validate email address
*/
export declare function validateEmail(email: string): {
isValid: boolean;
error?: string;
};
/**
* Extract domain from email
*/
export declare function getEmailDomain(email: string): string | null;
/**
* Check if email is from a disposable email provider
*/
export declare function isDisposableEmail(email: string): boolean;
/**
* Generate verification code
*/
export declare function generateVerificationCode(length?: number): string;
/**
* Validate verification code format
*/
export declare function validateVerificationCode(code: string, expectedLength?: number): {
isValid: boolean;
error?: string;
};
/**
* Format verification code for display
*/
export declare function formatVerificationCode(code: string, separator?: string): string;
/**
* Format time remaining in human-readable format
*/
export declare function formatTimeRemaining(seconds: number): string;
/**
* Format duration in various formats
*/
export declare function formatDuration(seconds: number, format?: 'short' | 'long' | 'digital'): string;
/**
* Check if timestamp is expired
*/
export declare function isExpired(expiresAt: string | Date): boolean;
/**
* Get time until expiration
*/
export declare function getTimeUntilExpiration(expiresAt: string | Date): number;
/**
* Get verification status display properties
*/
export declare function getVerificationStatusProps(status: VerificationStatus, method: VerificationMethod): {
color: "default";
label: string;
description: string;
icon: string;
canRetry: boolean;
} | {
color: "primary";
label: string;
description: string;
icon: string;
canRetry: boolean;
} | {
color: "success";
label: string;
description: string;
icon: string;
canRetry: boolean;
} | {
color: "danger";
label: string;
description: string;
icon: string;
canRetry: boolean;
} | {
color: "warning";
label: string;
description: string;
icon: string;
canRetry: boolean;
};
/**
* Parse invitation token from URL
*/
export declare function parseInvitationToken(): string | null;
/**
* Format invitation expiration
*/
export declare function formatInvitationExpiration(expiresAt: string | Date): {
text: string;
status: 'active' | 'expiring' | 'expired';
timeRemaining: number;
};
/**
* Get invitation status display properties
*/
export declare function getInvitationStatusProps(status: InvitationStatus): {
color: "default";
label: string;
description: string;
icon: string;
canRetry: boolean;
} | {
color: "primary";
label: string;
description: string;
icon: string;
canRetry: boolean;
} | {
color: "success";
label: string;
description: string;
icon: string;
canRetry: boolean;
} | {
color: "warning";
label: string;
description: string;
icon: string;
canRetry: boolean;
} | {
color: "danger";
label: string;
description: string;
icon: string;
canRetry: boolean;
};
/**
* Validate invitation data
*/
export declare function validateInvitationData(invitation: Partial<InvitationData>): {
isValid: boolean;
errors: string[];
};
/**
* Clean authentication parameters from URL
*/
export declare function cleanAuthParams(): void;
/**
* Build redirect URL with parameters
*/
export declare function buildRedirectUrl(baseUrl: string, params: Record<string, string>): string;
/**
* Validate redirect URL for security
*/
export declare function validateRedirectUrl(redirectUrl: string, allowedDomains?: string[]): boolean;
/**
* Track verification event
*/
export declare function trackVerificationEvent(event: 'started' | 'code_sent' | 'code_resent' | 'verified' | 'failed', method: VerificationMethod, metadata?: Record<string, any>): void;
/**
* Track invitation event
*/
export declare function trackInvitationEvent(event: 'viewed' | 'accepted' | 'declined' | 'expired' | 'error', invitation?: Partial<InvitationData>, metadata?: Record<string, any>): void;
export declare const VerificationUtils: {
formatPhoneNumber: typeof formatPhoneNumber;
validatePhoneNumber: typeof validatePhoneNumber;
parsePhoneNumber: typeof parsePhoneNumber;
maskEmail: typeof maskEmail;
validateEmail: typeof validateEmail;
getEmailDomain: typeof getEmailDomain;
isDisposableEmail: typeof isDisposableEmail;
generateVerificationCode: typeof generateVerificationCode;
validateVerificationCode: typeof validateVerificationCode;
formatVerificationCode: typeof formatVerificationCode;
getVerificationStatusProps: typeof getVerificationStatusProps;
trackVerificationEvent: typeof trackVerificationEvent;
};
export declare const InvitationUtils: {
parseInvitationToken: typeof parseInvitationToken;
formatInvitationExpiration: typeof formatInvitationExpiration;
getInvitationStatusProps: typeof getInvitationStatusProps;
validateInvitationData: typeof validateInvitationData;
trackInvitationEvent: typeof trackInvitationEvent;
};
export declare const TimeUtils: {
formatTimeRemaining: typeof formatTimeRemaining;
formatDuration: typeof formatDuration;
isExpired: typeof isExpired;
getTimeUntilExpiration: typeof getTimeUntilExpiration;
};
export declare const UrlUtils: {
cleanAuthParams: typeof cleanAuthParams;
buildRedirectUrl: typeof buildRedirectUrl;
validateRedirectUrl: typeof validateRedirectUrl;
};
export declare const AllUtils: {
cleanAuthParams: typeof cleanAuthParams;
buildRedirectUrl: typeof buildRedirectUrl;
validateRedirectUrl: typeof validateRedirectUrl;
formatTimeRemaining: typeof formatTimeRemaining;
formatDuration: typeof formatDuration;
isExpired: typeof isExpired;
getTimeUntilExpiration: typeof getTimeUntilExpiration;
parseInvitationToken: typeof parseInvitationToken;
formatInvitationExpiration: typeof formatInvitationExpiration;
getInvitationStatusProps: typeof getInvitationStatusProps;
validateInvitationData: typeof validateInvitationData;
trackInvitationEvent: typeof trackInvitationEvent;
formatPhoneNumber: typeof formatPhoneNumber;
validatePhoneNumber: typeof validatePhoneNumber;
parsePhoneNumber: typeof parsePhoneNumber;
maskEmail: typeof maskEmail;
validateEmail: typeof validateEmail;
getEmailDomain: typeof getEmailDomain;
isDisposableEmail: typeof isDisposableEmail;
generateVerificationCode: typeof generateVerificationCode;
validateVerificationCode: typeof validateVerificationCode;
formatVerificationCode: typeof formatVerificationCode;
getVerificationStatusProps: typeof getVerificationStatusProps;
trackVerificationEvent: typeof trackVerificationEvent;
};
//# sourceMappingURL=invitation.d.ts.map