Class HOTP

HOTP: An HMAC-based One-time Password Algorithm.

Constructors

  • Creates an HOTP object.

    Parameters

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

      Configuration options.

      • Optionalalgorithm?: string

        HMAC hashing algorithm.

      • Optionalcounter?: number

        Initial counter value.

      • Optionaldigits?: number

        Token length.

      • Optionalissuer?: string

        Account provider.

      • OptionalissuerInLabel?: boolean

        Include issuer prefix in label.

      • Optionallabel?: string

        Account label.

      • Optionalsecret?: string | Secret

        Secret key.

    Returns HOTP

Properties

algorithm: string

HMAC hashing algorithm.

counter: number

Initial counter value.

digits: number

Token length.

issuer: string

Account provider.

issuerInLabel: boolean

Include issuer prefix in label.

label: string

Account label.

secret: Secret

Secret key.

Accessors

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

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

Methods

  • Generates an HOTP token.

    Parameters

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

      Configuration options.

      • Optionalcounter?: number

        Counter value.

    Returns string

    Token.

  • Returns a Google Authenticator key URI.

    Returns string

    URI.

  • Validates an HOTP token.

    Parameters

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

      Configuration options.

      • Optionalcounter?: number

        Counter value.

      • 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 an HOTP token.

    Parameters

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

      Configuration options.

      • Optionalalgorithm?: string

        HMAC hashing algorithm.

      • Optionalcounter?: number

        Counter value.

      • Optionaldigits?: number

        Token length.

      • secret: Secret

        Secret key.

    Returns string

    Token.

  • Validates an HOTP token.

    Parameters

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

      Configuration options.

      • Optionalalgorithm?: string

        HMAC hashing algorithm.

      • Optionalcounter?: number

        Counter value.

      • Optionaldigits?: number

        Token length.

      • secret: Secret

        Secret key.

      • 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