react-native-nitro-totp
Version:
React Native module for TOTP (Time-based One-Time Password) and HOTP (HMAC-based One-Time Password) authentication.
47 lines • 1.79 kB
TypeScript
import type { NitroTotpGenerateOptions, NitroTotpValidateOptions, OTPAuthURLOptions } from './types';
/**
* NitroTotp (Time-based One-Time Password) class that provides methods for generating and validating TOTPs.
*/
export declare class NitroTotp {
private nitroTotp;
constructor();
/**
* Generates a TOTP code based on the secret key and options.
*
* @param secret - The secret key to use for generating the TOTP.
* @param options - Optional parameters for TOTP generation.
* @returns The generated TOTP code as a string.
*/
generate(secret: string, options?: NitroTotpGenerateOptions): string;
/**
* Validates a TOTP code against the secret key and options.
*
* @param secret - The secret key to validate against.
* @param otp - The TOTP code to validate.
* @param options - Optional parameters for TOTP validation.
* @returns True if the TOTP code is valid, false otherwise.
*/
validate(secret: string, otp: string, options?: NitroTotpValidateOptions): boolean;
/**
* Generates an OTP Auth URL for TOTP that can be used to set up authenticator apps.
*
* @param options - The options for generating the auth URL.
* @returns The generated OTP Auth URL as a string.
*/
generateAuthURL(options: OTPAuthURLOptions): string;
/**
* Gets the algorithm name as a string.
*
* @param algorithm - The algorithm enum value.
* @returns The algorithm name.
*/
private getAlgorithmName;
/**
* Generates an OTP Auth URL for TOTP.
*
* @param options - The options for generating the auth URL.
* @returns The generated OTP Auth URL as a string.
*/
private generateTotpAuthURL;
}
//# sourceMappingURL=NitroTotp.d.ts.map