Class TOTP

TOTP: Time-Based One-Time Password Algorithm.

Constructors

  • Creates a TOTP object.

    Parameters

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

      Configuration options.

      • algorithm: undefined | string

        HMAC hashing algorithm.

      • digits: undefined | number

        Token length.

      • issuer: undefined | string

        Account provider.

      • issuerInLabel: undefined | boolean

        Include issuer prefix in label.

      • label: undefined | string

        Account label.

      • period: undefined | number

        Token time-step duration.

      • secret: undefined | 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;
    }

    • algorithm: string
    • digits: number
    • issuer: string
    • issuerInLabel: boolean
    • label: string
    • period: number
    • window: number

Methods

  • Generates a TOTP token.

    Parameters

    • Optionalconfig: {
          timestamp: undefined | number;
      } = {}

      Configuration options.

      • timestamp: undefined | number

        Timestamp value in milliseconds.

    Returns string

    Token.

  • Returns a Google Authenticator key URI.

    Returns string

    URI.

  • Validates a TOTP token.

    Parameters

    • config: {
          timestamp: undefined | number;
          token: string;
          window: undefined | number;
      }

      Configuration options.

      • timestamp: undefined | number

        Timestamp value in milliseconds.

      • token: string

        Token value.

      • window: undefined | 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: undefined | string;
          digits: undefined | number;
          period: undefined | number;
          secret: Secret;
          timestamp: undefined | number;
      }

      Configuration options.

      • algorithm: undefined | string

        HMAC hashing algorithm.

      • digits: undefined | number

        Token length.

      • period: undefined | number

        Token time-step duration.

      • secret: Secret

        Secret key.

      • timestamp: undefined | number

        Timestamp value in milliseconds.

    Returns string

    Token.

  • Validates a TOTP token.

    Parameters

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

      Configuration options.

      • algorithm: undefined | string

        HMAC hashing algorithm.

      • digits: undefined | number

        Token length.

      • period: undefined | number

        Token time-step duration.

      • secret: Secret

        Secret key.

      • timestamp: undefined | number

        Timestamp value in milliseconds.

      • token: string

        Token value.

      • window: undefined | 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