react-native-nitro-totp
Version:
React Native module for TOTP (Time-based One-Time Password) and HOTP (HMAC-based One-Time Password) authentication.
39 lines (38 loc) • 1.61 kB
TypeScript
import type { BaseGenerateOptions, GenerateSecretKeyOptions } from './types';
/**
* Checks if the given OTP (One-Time Password) has a valid format.
*
* @param {string} otp - The OTP to check.
* @param {GenerateOptions} [options=defaultOptions] - The options for OTP generation (optional).
* @returns {boolean} True if the OTP format is valid, false otherwise.
*/
export declare const isOTPValid: (otp: string, options?: BaseGenerateOptions) => boolean;
/**
* Checks if the given secret key has a valid format.
*
* @param {string} secretKey - The secret key to check.
* @param {GenerateSecretKeyOptions} [options=defaultOptions] - The options for secret key generation (optional).
* @returns {boolean} True if the secret key format is valid, false otherwise.
*/
export declare const isSecretKeyValid: (secretKey: string, options?: GenerateSecretKeyOptions) => boolean;
/**
* Formats the secret key for display by inserting hyphens every 4 characters.
*
* @param {string} secretKey - The secret key to format.
* @returns {string} The formatted secret key.
*/
export declare const formatSecretKey: (secretKey: string) => string;
/**
* Formats an OTP (One-Time Password) by grouping digits for readability.
*
* @param {string} otp - The OTP to format.
* @returns {string} The formatted OTP.
*/
export declare const formatOTP: (otp: string) => string;
/**
* Parses the secret key by removing any hyphens from it.
*
* @param {string} secretKey - The secret key to parse.
* @returns {string} The parsed secret key.
*/
export declare const parseSecretKey: (secretKey: string) => string;