rn-otp
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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

Package Sidebar

Install

npm i rn-otp

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

18.1 kB

Total Files

5

Last publish

Collaborators

  • nbosscher