UNPKG

react-native-nitro-totp

Version:

React Native module for TOTP (Time-based One-Time Password) and HOTP (HMAC-based One-Time Password) authentication.

37 lines 1.43 kB
import type { GenerateSecretKeyOptions } from './types'; /** * NitroSecret class that provides methods for generating cryptographically secure secrets. */ export declare class NitroSecret { private nitroSecret; constructor(); /** * Generates a cryptographically secure random secret key. * @param options - Optional parameters for secret generation. * @returns The generated secret as a Base32-encoded string. */ generate(options?: GenerateSecretKeyOptions): string; /** * Validates if the given secret key has a valid format. * @param secretKey - The secret key to check. * @param options - Optional parameters for secret validation. * @returns True if the secret key format is valid, false otherwise. */ isValid(secretKey: string, options?: GenerateSecretKeyOptions): boolean; /** * Determines expected Base32 character length for validation. * Returns one of the standard lengths if no specific size is provided. */ private getExpectedLength; /** * Converts SecretSize enum or raw bytes to validated byte count. * Centralizes all size conversion and validation logic. */ private convertToBytes; /** * Validates byte size against allowed standard sizes. * Throws descriptive error for invalid sizes to guide developers. */ private validateByteSize; } //# sourceMappingURL=NitroSecret.d.ts.map