# rn-otp

> OTP utility for Google Authenticator compatible with React Native

Latest version **1.0.1** (published 2021-10-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install rn-otp
pnpm add rn-otp
yarn add rn-otp
bun add rn-otp
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-10-14 |
| First published | 2021-10-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 17.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nate Bosscher |
| Maintainers | nbosscher |
| Keywords | one-time-password, google authenticator, hotp, totp, otp, react native |

## Links

- npm: https://www.npmjs.com/package/rn-otp
- Repository: https://github.com/ntbosscher/otp
- Homepage: https://github.com/ntbosscher/otp#readme
- Issues: https://github.com/ntbosscher/otp/issues
- npm.io page: https://npm.io/package/rn-otp

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@oxyhq/services](https://npm.io/package/@oxyhq/services.md) — 2.3K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2021-10-14

## README

# React Native OTP

Works out of the box with React Native

> Adapted from [github.com/pipobscure/otp](https://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](http://tools.ietf.org/html/rfc4226)
- TOTP (Time-Based One-Time Password Algorithm): [RFC 6238](http://tools.ietf.org/html/rfc6238)

## Usage

```js
// 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
```

---
_Source: https://npm.io/package/rn-otp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
