import { Base32Plugin, CryptoPlugin, Digits, HashAlgorithm, OTPGuardrails, OTPHooks } from "@otplib/core";
import { VerifyResult } from "@otplib/hotp";
import { TOTPOptions, VerifyResult as VerifyResult$1 } from "@otplib/totp";
//#region src/types.d.ts
/**
 * OTP Strategy Type
 */
type OTPStrategy = "totp" | "hotp";
/**
 * Options with plugin overrides
 */
type OTPAuthOptions = {
  /**
   * Crypto plugin to use (default: NobleCryptoPlugin)
   */
  readonly crypto?: CryptoPlugin;
  /**
   * Base32 plugin to use (default: ScureBase32Plugin)
   */
  readonly base32?: Base32Plugin;
};
/**
 * Common options for OTP generation
 *
 * These options apply to both TOTP and HOTP strategies.
 */
type OTPGenerateOptions = {
  /**
   * Base32-encoded secret key
   *
   * **Note**: By default, strings are assumed to be Base32 encoded.
   * If you have a raw string/passphrase, you must convert it to Uint8Array first.
   */
  secret: string | Uint8Array;
  /**
   * OTP strategy to use (default: 'totp')
   * - 'totp': Time-based OTP
   * - 'hotp': HMAC-based OTP
   */
  strategy?: OTPStrategy;
  /**
   * Crypto plugin to use (default: NobleCryptoPlugin)
   */
  crypto?: CryptoPlugin;
  /**
   * Base32 plugin to use (default: ScureBase32Plugin)
   */
  base32?: Base32Plugin;
  /**
   * Validation guardrails
   */
  guardrails?: OTPGuardrails;
  /**
   * Hash algorithm (default: 'sha1')
   */
  algorithm?: HashAlgorithm;
  /**
   * Number of digits (default: 6)
   */
  digits?: Digits;
  /**
   * Time step in seconds (default: 30)
   * Used by TOTP strategy
   */
  period?: number;
  /**
   * Current Unix epoch timestamp in seconds (default: now)
   * Used by TOTP strategy
   */
  epoch?: number;
  /**
   * Initial Unix time to start counting time steps (default: 0)
   * Used by TOTP strategy
   */
  t0?: number;
  /**
   * Counter value
   * Used by HOTP strategy (required)
   */
  counter?: number;
  /**
   * Hooks for customizing token encoding and validation.
   * Allows non-standard OTP variants (e.g., Steam Guard) to replace
   * the default numeric encoding with custom schemes.
   */
  hooks?: OTPHooks;
};
/**
 * Options for OTP verification
 *
 * Extends OTPFunctionalOptions with token and tolerance parameters.
 */
type OTPVerifyOptions = OTPGenerateOptions & {
  /**
   * OTP code to verify
   */
  token: string;
  /**
   * Time tolerance in seconds for TOTP verification (default: 0)
   * - Number: symmetric tolerance (same for past and future)
   * - Tuple [past, future]: asymmetric tolerance
   *   Use [5, 0] for RFC-compliant past-only verification.
   */
  epochTolerance?: number | [number, number];
  /**
   * Counter tolerance for HOTP verification (default: 0)
   * - Number: creates look-ahead only tolerance [0, n]
   * - Tuple [past, future]: explicit window control
   */
  counterTolerance?: number | [number, number];
  /**
   * Minimum allowed TOTP time step for replay protection (optional)
   *
   * Rejects tokens with timeStep <= afterTimeStep.
   * Only used by TOTP strategy.
   */
  afterTimeStep?: number;
};
//#endregion
//#region src/functional.d.ts
type VerifyResult$2 = VerifyResult$1 | VerifyResult;
/**
 * Generate a random secret key for use with OTP
 *
 * The secret is encoded in Base32 format for compatibility with
 * Google Authenticator and other authenticator apps.
 *
 * @param options - Secret generation options
 * @returns Base32-encoded secret key
 *
 * @example
 * ```ts
 * import { generateSecret } from 'otplib';
 *
 * const secret = generateSecret();
 * // Returns: 'JBSWY3DPEHPK3PXP'
 * ```
 *
 * @example With custom plugins
 * ```ts
 * import { generateSecret, NodeCryptoPlugin } from 'otplib';
 *
 * const secret = generateSecret({
 *   crypto: new NodeCryptoPlugin(),
 * });
 * ```
 */
declare function generateSecret(options?: {
  /**
   * Number of random bytes to generate (default: 20)
   * 20 bytes = 160 bits, which provides a good security margin
   */
  length?: number;
  /**
   * Crypto plugin to use (default: NobleCryptoPlugin)
   */
  crypto?: CryptoPlugin;
  /**
   * Base32 plugin to use (default: ScureBase32Plugin)
   */
  base32?: Base32Plugin;
}): string;
/**
 * Generate an otpauth:// URI for QR code generation
 *
 * This URI can be used to generate a QR code that can be scanned
 * by Google Authenticator and other authenticator apps.
 *
 * @param options - URI generation options
 * @returns otpauth:// URI string
 * @throws {AlgorithmUnsupportedError} If a non-empty algorithm is not supported
 *
 * @example TOTP
 * ```ts
 * import { generateURI } from 'otplib';
 *
 * const uri = generateURI({
 *   issuer: 'ACME Co',
 *   label: 'john@example.com',
 *   secret: 'JBSWY3DPEHPK3PXP',
 * });
 * // Returns: 'otpauth://totp/ACME%20Co:john%40example.com?secret=...'
 * ```
 *
 * @example HOTP
 * ```ts
 * import { generateURI } from 'otplib';
 *
 * const uri = generateURI({
 *   strategy: 'hotp',
 *   issuer: 'ACME Co',
 *   label: 'john@example.com',
 *   secret: 'JBSWY3DPEHPK3PXP',
 *   counter: 5,
 * });
 * // Returns: 'otpauth://hotp/ACME%20Co:john%40example.com?secret=...&counter=5'
 * ```
 */
declare function generateURI(options: {
  /**
   * OTP strategy to use (default: 'totp')
   */
  strategy?: OTPStrategy;
  issuer: string;
  label: string;
  /**
   * Base32-encoded secret key
   *
   * **Note**: By default, strings are assumed to be Base32 encoded.
   * If you have a raw string/passphrase, you must convert it to Uint8Array first.
   */
  secret: string;
  algorithm?: HashAlgorithm;
  digits?: Digits;
  period?: number;
  counter?: number;
}): string;
/**
 * Generate an OTP code
 *
 * Generates a one-time password based on the specified strategy.
 * - 'totp': Time-based OTP (default)
 * - 'hotp': HMAC-based OTP
 *
 * @param options - OTP generation options
 * @returns OTP code
 * @throws {AlgorithmUnsupportedError} If the algorithm is invalid or unsupported by the plugin
 * @throws {HMACError} If HMAC computation fails in the crypto plugin
 *
 * @example TOTP
 * ```ts
 * import { generate } from 'otplib';
 *
 * const token = await generate({
 *   secret: 'JBSWY3DPEHPK3PXP',
 * });
 * // Returns: '123456'
 * ```
 *
 * @example HOTP
 * ```ts
 * import { generate } from 'otplib';
 *
 * const token = await generate({
 *   secret: 'JBSWY3DPEHPK3PXP',
 *   strategy: 'hotp',
 *   counter: 0,
 * });
 * ```
 *
 * @example With custom plugins
 * ```ts
 * import { generate, NodeCryptoPlugin } from 'otplib';
 *
 * const token = await generate({
 *   secret: 'JBSWY3DPEHPK3PXP',
 *   crypto: new NodeCryptoPlugin(),
 * });
 * ```
 */
declare function generate(options: OTPGenerateOptions): Promise<string>;
/**
 * Generate an OTP code synchronously
 *
 * This is the synchronous version of {@link generate}. It requires a crypto
 * plugin that supports synchronous HMAC operations.
 *
 * @param options - OTP generation options
 * @returns OTP code
 * @throws {AlgorithmUnsupportedError} If the algorithm is invalid or unsupported by the plugin
 * @throws {HMACError} If HMAC computation fails or the plugin does not support sync operations
 *
 * @example
 * ```ts
 * import { generateSync } from 'otplib';
 *
 * const token = generateSync({
 *   secret: 'JBSWY3DPEHPK3PXP',
 * });
 * ```
 */
declare function generateSync(options: OTPGenerateOptions): string;
/**
 * Verify an OTP code
 *
 * Verifies a provided OTP code against the expected value based on the strategy.
 * - 'totp': Time-based OTP (default, Google Authenticator compatible)
 * - 'hotp': HMAC-based OTP
 *
 * Uses constant-time comparison to prevent timing attacks.
 *
 * @param options - OTP verification options
 * @returns Verification result with validity and optional delta
 * @throws {AlgorithmUnsupportedError} If the algorithm is invalid or unsupported by the plugin
 * @throws {HMACError} If HMAC computation fails in the crypto plugin
 *
 * @example TOTP
 * ```ts
 * import { verify } from 'otplib';
 *
 * const result = await verify({
 *   secret: 'JBSWY3DPEHPK3PXP',
 *   token: '123456',
 * });
 * // Returns: { valid: true, delta: 0 }
 * ```
 *
 * @example HOTP
 * ```ts
 * import { verify } from 'otplib';
 *
 * const result = await verify({
 *   secret: 'JBSWY3DPEHPK3PXP',
 *   token: '123456',
 *   strategy: 'hotp',
 *   counter: 0,
 * });
 * ```
 *
 * @example With epochTolerance for TOTP
 * ```ts
 * import { verify, NodeCryptoPlugin } from 'otplib';
 *
 * const result = await verify({
 *   secret: 'JBSWY3DPEHPK3PXP',
 *   token: '123456',
 *   epochTolerance: 30,
 *   crypto: new NodeCryptoPlugin(),
 * });
 * ```
 */
declare function verify(options: OTPVerifyOptions): Promise<VerifyResult$2>;
/**
 * Verify an OTP code synchronously
 *
 * This is the synchronous version of {@link verify}. It requires a crypto
 * plugin that supports synchronous HMAC operations.
 *
 * @param options - OTP verification options
 * @returns Verification result with validity and optional delta
 * @throws {AlgorithmUnsupportedError} If the algorithm is invalid or unsupported by the plugin
 * @throws {HMACError} If HMAC computation fails or the plugin does not support sync operations
 *
 * @example
 * ```ts
 * import { verifySync } from 'otplib';
 *
 * const result = verifySync({
 *   secret: 'JBSWY3DPEHPK3PXP',
 *   token: '123456',
 * });
 * ```
 */
declare function verifySync(options: OTPVerifyOptions): VerifyResult$2;
//#endregion
export { generateURI as a, OTPAuthOptions as c, OTPVerifyOptions as d, TOTPOptions as f, generateSync as i, OTPGenerateOptions as l, generate as n, verify as o, generateSecret as r, verifySync as s, VerifyResult$2 as t, OTPStrategy as u };
export {};