igpapi — Instagram private API Simulator for Node.js (API reference) 4.14.0
    Preparing search index...

    Function totpCodeOf

    • The six-digit code an authenticator app shows for secret at the moment at (now by default): RFC 6238 time-based one-time password, HMAC-SHA-1, a 30-second step and six digits, over the base32 setup key Instagram shows when an account sets its authenticator app up.

      A code is valid for its 30-second step only, so compute it where it is submitted (codeScreen.submitCode(totpCodeOf(secret))), never once at startup. A secret that is not base32 throws a RangeError: it is the program's own configuration, not an answer of Instagram.

      Parameters

      • secret: string
      • at: Date = ...

      Returns string

      // RFC 6238 Appendix B: its SHA-1 key (given there in ASCII, here in base32) at 59 seconds is 94287082; the last six digits.
      totpCodeOf('GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ', new Date(59_000)); // '287082'