Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace HOTP

Index

Functions

Functions

Const generate

  • generate(__namedParameters: { algorithm?: string; counter?: number; key: string | Buffer }): string
  • HOTP(K,C) = Truncate(HMAC-SHA-1(K,C))

    https://datatracker.ietf.org/doc/html/rfc4226#section-5.2

    Parameters

    • __namedParameters: { algorithm?: string; counter?: number; key: string | Buffer }
      • Optional algorithm?: string

        custom algorithm for crypto.createHmac. Default: sha1

      • Optional counter?: number

        moving factor. Default: 0

      • key: string | Buffer

        unique secret key for user

    Returns string

    6 digit code as a string

Const validate

  • validate(__namedParameters: { algorithm?: string; counter?: number; key: string | Buffer; token: string; window?: number }): number
  • Parameters

    • __namedParameters: { algorithm?: string; counter?: number; key: string | Buffer; token: string; window?: number }
      • Optional algorithm?: string

        custom algorithm for crypto.createHmac. Default: sha1

      • Optional counter?: number

        moving factor. Default: 0

      • key: string | Buffer

        unique secret key for user

      • token: string

        code, provided by user

      • Optional window?: number

        counter values window. Default: 1

    Returns number

    null if nothing found or number between -window to +window if same code in steps found

Generated using TypeDoc