node-totp
    Preparing search index...

    Interface TotpApi

    interface TotpApi {
        base32: Base32Api;
        helpers: TotpHelpers;
        validate: TotpValidation;
        generateToken(
            secret: Buffer,
            counter: number,
            digits: TotpDigits,
            algorithm: TotpAlgorithm,
        ): string;
        generateURI(options: GenerateUriOptions): GenerateUriResult;
        verifyToken(
            token: string,
            secret: string,
            options?: Partial<VerifyTokenOptions>,
        ): boolean;
    }
    Index

    Properties

    base32: Base32Api

    RFC 4648 Base32 helpers.

    helpers: TotpHelpers

    Internal helper utilities exposed on the default export.

    validate: TotpValidation

    Input validation helpers exposed on the default export.

    Methods

    • Generates a token for a specific counter value.

      Parameters

      • secret: Buffer

        Decoded secret bytes.

      • counter: number

        Time-step counter.

      • digits: TotpDigits

        Number of digits to return.

      • algorithm: TotpAlgorithm

        HMAC algorithm.

      Returns string

      A zero-padded TOTP token.

    • Verifies a token against a shared secret.

      Parameters

      • token: string

        User-provided token.

      • secret: string

        Canonical unpadded Base32 secret.

      • Optionaloptions: Partial<VerifyTokenOptions>

        Verification overrides.

      Returns boolean

      true when the token is valid for the given window.