1.0.1 • Published 3 years ago

rn-otp v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

React Native OTP

Works out of the box with React Native

Adapted from github.com/pipobscure/otp to work with React Native and to be completely RFC compliant.

This is a utility to work with Google-Authenticator and compatible OTP-Mechanisms.

  • HOTP (HMAC-Based One-Time Password Algorithm): RFC 4226
  • TOTP (Time-Based One-Time Password Algorithm): RFC 6238

Usage

// create with Authenticator URL
var otp = new OTP("otpauth://totp/...:....?algorithm=SHA1&digits=6&period=30&secret=....");

// create with options
var otp = new OTP({
    secret: ""     // base-32 encoded string, required
    timeSlice: 30, // totp period in seconds
})

otp.totp();              // computes totp using current timestamp (i.e. Date.current())
otp.totp(1634239933751); // use a specific unix timestamp (ms)

otp.hotp(counter); // Generates an OTP using HTOP method