UNPKG

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
import type { NitroHotpGenerateOptions, NitroHotpValidateOptions, OTPAuthURLOptions } from './types'; /** * NitroHotp (HMAC-based One-Time Password) class that provides methods for generating and validating HOTPs. */ export declare class NitroHotp { private nitroHotp; constructor(); /** * Generates an HOTP code based on the secret key and options. * * @param secret - The secret key to use for generating the HOTP. * @param options - Optional parameters for HOTP generation. * @returns The generated HOTP code as a string. */ generate(secret: string, options?: NitroHotpGenerateOptions): string; /** * Validates an HOTP code against the secret key and options. * * @param secret - The secret key to validate against. * @param otp - The HOTP code to validate. * @param options - Optional parameters for HOTP validation. * @returns True if the HOTP code is valid, false otherwise. */ validate(secret: string, otp: string, options?: NitroHotpValidateOptions): boolean; /** * Generates an OTP Auth URL for HOTP 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 HOTP. * * @param options - The options for generating the auth URL. * @returns The generated OTP Auth URL as a string. */ private generateHotpAuthURL; } //# sourceMappingURL=NitroHotp.d.ts.map