Class TOTP

TOTP: Time-Based One-Time Password Algorithm.

Constructors

  • Creates a TOTP object.

    Parameters

    • Optionalconfig: {
          algorithm?: string;
          digits?: number;
          issuer?: string;
          issuerInLabel?: boolean;
          label?: string;
          period?: number;
          secret?: string | Secret;
      } = {}

      Configuration options.

      • Optionalalgorithm?: string

        HMAC hashing algorithm.

      • Optionaldigits?: number

        Token length.

      • Optionalissuer?: string

        Account provider.

      • OptionalissuerInLabel?: boolean

        Include issuer prefix in label.

      • Optionallabel?: string

        Account label.

      • Optionalperiod?: number

        Token time-step duration.

      • Optionalsecret?: string | Secret

        Secret key.

    Returns TOTP

Properties

algorithm: string

HMAC hashing algorithm.

digits: number

Token length.

issuer: string

Account provider.

issuerInLabel: boolean

Include issuer prefix in label.

label: string

Account label.

period: number

Token time-step duration.

secret: Secret

Secret key.

Accessors

  • get defaults(): {
        algorithm: string;
        digits: number;
        issuer: string;
        issuerInLabel: boolean;
        label: string;
        period: number;
        window: number;
    }
  • Default configuration.

    Returns {
        algorithm: string;
        digits: number;
        issuer: string;
        issuerInLabel: boolean;
        label: string;
        period: number;
        window: number;
    }

Methods

  • Generates a TOTP token.

    Parameters

    • Optionalconfig: { timestamp?: number } = {}

      Configuration options.

      • Optionaltimestamp?: number

        Timestamp value in milliseconds.

    Returns string

    Token.

  • Returns a Google Authenticator key URI.

    Returns string

    URI.

  • Validates a TOTP token.

    Parameters

    • config: { timestamp?: number; token: string; window?: number }

      Configuration options.

      • Optionaltimestamp?: number

        Timestamp value in milliseconds.

      • token: string

        Token value.

      • Optionalwindow?: number

        Window of counter values to test.

    Returns null | number

    Token delta or null if it is not found in the search window, in which case it should be considered invalid.

  • Generates a TOTP token.

    Parameters

    • config: {
          algorithm?: string;
          digits?: number;
          period?: number;
          secret: Secret;
          timestamp?: number;
      }

      Configuration options.

      • Optionalalgorithm?: string

        HMAC hashing algorithm.

      • Optionaldigits?: number

        Token length.

      • Optionalperiod?: number

        Token time-step duration.

      • secret: Secret

        Secret key.

      • Optionaltimestamp?: number

        Timestamp value in milliseconds.

    Returns string

    Token.

  • Validates a TOTP token.

    Parameters

    • config: {
          algorithm?: string;
          digits?: number;
          period?: number;
          secret: Secret;
          timestamp?: number;
          token: string;
          window?: number;
      }

      Configuration options.

      • Optionalalgorithm?: string

        HMAC hashing algorithm.

      • Optionaldigits?: number

        Token length.

      • Optionalperiod?: number

        Token time-step duration.

      • secret: Secret

        Secret key.

      • Optionaltimestamp?: number

        Timestamp value in milliseconds.

      • token: string

        Token value.

      • Optionalwindow?: number

        Window of counter values to test.

    Returns null | number

    Token delta or null if it is not found in the search window, in which case it should be considered invalid.

MMNEPVFCICPMFPCPTTAAATR