payloadcms_otp_plugin
Version:
A comprehensive One-Time Password (OTP) authentication plugin for Payload CMS that enables secure passwordless authentication via SMS and email
33 lines (32 loc) • 1.58 kB
TypeScript
export type SupportedLanguage = 'en' | 'ar';
/**
* Parse Accept-Language header and return the best matching supported language
* @param acceptLanguageHeader - The Accept-Language header value
* @returns The best matching supported language, defaults to 'en'
*/
export declare function parseAcceptLanguage(acceptLanguageHeader?: string): SupportedLanguage;
/**
* Get translated message based on language and key path
* @param language - The target language
* @param keyPath - Dot notation path to the translation key (e.g., "otp.expired_message")
* @param fallbackMessage - Fallback message if translation not found
* @returns Translated message or fallback
*/
export declare function getTranslation(language: SupportedLanguage, keyPath: string, fallbackMessage?: string): string;
/**
* Get translated message from request headers
* @param headers - Request headers containing Accept-Language
* @param keyPath - Dot notation path to the translation key
* @param fallbackMessage - Fallback message if translation not found
* @returns Translated message
*/
export declare function getTranslationFromHeaders(headers: Headers | Record<string, string>, keyPath: string, fallbackMessage?: string): string;
/**
* Create a translation helper bound to specific request headers
* @param headers - Request headers containing Accept-Language
* @returns Translation helper function
*/
export declare function createTranslationHelper(headers: Headers | Record<string, string>): {
language: SupportedLanguage;
t: (keyPath: string, fallbackMessage?: string) => string;
};