open-index/open-npm huggingface dataset:
npm package: @otp-forge/otp-forge
Description: A nodejs library that handles the generation, storage and verification of OTPs.
Author: Rushabh Javeri
Latest version: 1.0.5

# OTP Forge

A simple library for managing OTPs for all your applications. It helps with the generation, storage and verification of OTPs.

## Getting Started

These instructions will give you a copy of the project up and running on
your local machine for development and testing purposes.

### Installing

Requirements:

- Node.js (version >= 16.0.0)

Install with:

NPM:

```bash
npm install @otp-forge/otp-forge
```

Yarn:

```bash
yarn add @otp-forge/otp-forge
```

PNPM:

```bash
pnpm add @otp-forge/otp-forge
```

pnpm

### How To Use

Initialize the OTPManager with the required configuration options:

```javascript
const OTPManager = require("@otp-forge/otp-forge");

// In memory storage
const passwordResetOTPManager = new OTPManager({
  // Configuration options
  purpose: "password-reset", // Purpose of the OTP
  otpLength: 6, // Length of the OTP
  expirationTime: 300, // Time to live in seconds
});
```

Generate an OTP:

```typescript
const otp: number = await passwordResetOTPManager.generateOTP();
```

Verify an OTP:

```typescript
const isValid: boolean = await passwordResetOTPManager.verifyOTP(otp);
```

**Warning**: The default store is in-memory, which means that the OTPs will be lost when the application is restarted. To use a persistent store, you can use one of the supported stores or build your own.

## Versioning

We use [Semantic Versioning](http://semver.org/) for versioning.

## Authors

- **Rushabh Javeri** - [GitHub](https://github.com/rushabhhere)
- **Manan Gandhi** - [GitHub](https://github.com/MananGandhi1810)

## License

This project is licensed under the [MIT License](https://license.md/licenses/mit-license/)
npm package: @otp-service/core
Description: Framework-agnostic OTP domain logic for Node.js services.
Latest version: 0.1.2

# @otp-service/core

Framework-agnostic OTP challenge lifecycle for Node.js: generate a challenge, deliver the OTP out-of-band, verify attempts with policy (TTL, length, max attempts), and persist state behind a small store interface.

**ESM only** · **Node.js ≥ 22** · **License:** MIT

## Install

```bash
npm install @otp-service/core
```

## When to use this package

Use `**@otp-service/core**` when you want full control over storage, delivery, signing, and OTP generation. Pair it with:

- `[@otp-service/redis-store](https://www.npmjs.com/package/@otp-service/redis-store)` for Redis persistence
- `[@otp-service/provider-email-resend](https://www.npmjs.com/package/@otp-service/provider-email-resend)` or `[@otp-service/provider-sms-twilio](https://www.npmjs.com/package/@otp-service/provider-sms-twilio)` for delivery
- `[@otp-service/express](https://www.npmjs.com/package/@otp-service/express)`, `[@otp-service/fastify](https://www.npmjs.com/package/@otp-service/fastify)`, or `[@otp-service/nest](https://www.npmjs.com/package/@otp-service/nest)` for HTTP routes

For a pre-wired Redis + provider path, see `[@otp-service/starter](https://www.npmjs.com/package/@otp-service/starter)`.

## Minimal usage

You must supply a `**ChallengeStore**`, `**OtpDelivery**`, `**OtpSigner**`, and `**OtpPolicy**`. The service exposes `**generateChallenge**` and `**verifyChallenge**`.

```ts
import { createOtpService, hmacOtpSigner } from "@otp-service/core";

const otpService = createOtpService({
  delivery: myDelivery,
  otpGenerator: (length) => {
    /* return numeric string of length */
  },
  policy: {
    maxVerifyAttempts: 3,
    otpLength: 6,
    ttlSeconds: 600
  },
  signer: hmacOtpSigner({ secret: process.env.OTP_SECRET! }),
  store: myStore
});

await otpService.generateChallenge({
  channel: "email",
  purpose: "LOGIN",
  recipient: "user@example.com"
});
```

## Main exports


| Export                                                  | Role                                 |
| ------------------------------------------------------- | ------------------------------------ |
| `createOtpService`                                      | Build the headless OTP service       |
| `hmacOtpSigner`                                         | HMAC-based OTP hashing for storage   |
| `OtpDeliveryError`                                      | Typed delivery failure from adapters |
| Types: `ChallengeStore`, `OtpDelivery`, `OtpService`, … | Implement or consume contracts       |


See **TypeScript definitions** in the published `dist/` for full shapes.

## Documentation

- Monorepo overview: [github.com/Suraj-H/otp-service-package](https://github.com/Suraj-H/otp-service-package)
- Security notes: [docs/guides/security.md](https://github.com/Suraj-H/otp-service-package/blob/main/docs/guides/security.md)
- Issues: [github.com/Suraj-H/otp-service-package/issues](https://github.com/Suraj-H/otp-service-package/issues)

## Stability

**0.x** — APIs may evolve; pin versions in production until you are comfortable with upgrades.
npm package: @otp-service/express
Description: Express route helpers for OTP generate and verify flows.
Latest version: 0.1.2

# @otp-service/express

Express **`RequestHandler`** factories for OTP **generate** and **verify** JSON endpoints, wired to an [`@otp-service/core`](https://www.npmjs.com/package/@otp-service/core) **`OtpService`**.

**ESM only** · **Node.js ≥ 22** · **License:** MIT

## Install

```bash
npm install @otp-service/express @otp-service/core express
```

`express` is a **peer dependency** (`^4.21.0 || ^5.0.0`).

## Usage

```ts
import express from "express";
import {
  createGenerateChallengeHandler,
  createVerifyChallengeHandler
} from "@otp-service/express";

app.use(express.json());
app.post("/otp/generate", createGenerateChallengeHandler({ otpService }));
app.post("/otp/verify", createVerifyChallengeHandler({ otpService }));
```

### Request bodies

- **POST generate** — `{ "channel": "email" | "sms", "purpose": string, "recipient": string }` → **201** with challenge metadata.
- **POST verify** — `{ "challengeId": string, "otp": string }` → **200** / **400** / **410** / **429** depending on outcome.

Optional **`mapBody`** in handler options adapts your API shape to these inputs.

## Exports

| Export | Purpose |
|--------|---------|
| `createGenerateChallengeHandler` | Express handler for generate |
| `createVerifyChallengeHandler` | Express handler for verify |
| `ExpressOtpValidationError` | Thrown for malformed JSON (mapped to **422** by handlers) |

## Related packages

- [`@otp-service/core`](https://www.npmjs.com/package/@otp-service/core) — build `otpService`
- [`@otp-service/starter`](https://www.npmjs.com/package/@otp-service/starter) — Redis + provider composition
- Framework guides: [docs/guides/frameworks/express.md](https://github.com/Suraj-H/otp-service-package/blob/main/docs/guides/frameworks/express.md)

## Links

- Repository: [github.com/Suraj-H/otp-service-package](https://github.com/Suraj-H/otp-service-package)
- Issues: [github.com/Suraj-H/otp-service-package/issues](https://github.com/Suraj-H/otp-service-package/issues)
npm package: @otp-service/fastify
Description: Fastify route helpers for OTP generate and verify flows.
Latest version: 0.1.2

# @otp-service/fastify

Fastify route handlers for OTP **generate** and **verify**, plus a small **error handler** helper, using an [`@otp-service/core`](https://www.npmjs.com/package/@otp-service/core) **`OtpService`**.

**ESM only** · **Node.js ≥ 22** · **License:** MIT

## Install

```bash
npm install @otp-service/fastify @otp-service/core fastify
```

`fastify` is a **peer dependency** (`^5.0.0`).

## Usage

```ts
import Fastify from "fastify";
import {
  createGenerateChallengeHandler,
  createVerifyChallengeHandler,
  fastifyOtpErrorHandler
} from "@otp-service/fastify";

const app = Fastify();
app.post("/otp/generate", createGenerateChallengeHandler({ otpService }));
app.post("/otp/verify", createVerifyChallengeHandler({ otpService }));
app.setErrorHandler(fastifyOtpErrorHandler);
```

### Request bodies

Same contract as Express helpers: **generate** expects `channel`, `purpose`, `recipient`; **verify** expects `challengeId`, `otp`. Optional **`mapBody`** customizes parsing.

## Exports

| Export | Purpose |
|--------|---------|
| `createGenerateChallengeHandler` | Fastify route handler |
| `createVerifyChallengeHandler` | Fastify route handler |
| `fastifyOtpErrorHandler` | Maps validation errors to HTTP responses |
| `FastifyOtpValidationError` | Validation error type |

## Related packages

- [`@otp-service/core`](https://www.npmjs.com/package/@otp-service/core)
- [`@otp-service/express`](https://www.npmjs.com/package/@otp-service/express) — same HTTP semantics on Express
- Guide: [docs/guides/frameworks/fastify.md](https://github.com/Suraj-H/otp-service-package/blob/main/docs/guides/frameworks/fastify.md)

## Links

- Repository: [github.com/Suraj-H/otp-service-package](https://github.com/Suraj-H/otp-service-package)
- Issues: [github.com/Suraj-H/otp-service-package/issues](https://github.com/Suraj-H/otp-service-package/issues)
npm package: @otp-service/nest
Description: Nest module and controller helpers for OTP flows.
Latest version: 0.1.2

# @otp-service/nest

NestJS **`DynamicModule`** factory and controller helper to expose OTP **generate** / **verify** routes backed by an [`@otp-service/core`](https://www.npmjs.com/package/@otp-service/core) **`OtpService`**.

**ESM only** · **Node.js ≥ 22** · **License:** MIT

## Install

```bash
npm install @otp-service/nest @otp-service/core @nestjs/common @nestjs/core reflect-metadata rxjs
```

Peers: **`@nestjs/common`** and **`@nestjs/core`** `^11.0.0`. Use **`reflect-metadata`** and **`rxjs`** as required by your Nest app.

## Usage

Pass a ready-built **`OtpService`** from [`@otp-service/core`](https://www.npmjs.com/package/@otp-service/core). The dynamic module registers the controller and the service token internally.

```ts
import { Module } from "@nestjs/common";
import { createNestOtpModule } from "@otp-service/nest";

@Module({
  imports: [createNestOtpModule({ otpService, pathPrefix: "otp" })]
})
export class AppModule {}
```

For tests or advanced wiring you can also use **`createOtpController(pathPrefix)`** and **`OTP_SERVICE_TOKEN`**; see **`CreateNestOtpModuleOptions`** in **`dist/index.d.ts`**.

## Exports

| Export | Purpose |
|--------|---------|
| `createNestOtpModule` | `DynamicModule` with controller + `OtpService` provider |
| `createOtpController` | Standalone controller class factory |
| `OTP_SERVICE_TOKEN` | DI token for `OtpService` |

## Related packages

- [`@otp-service/core`](https://www.npmjs.com/package/@otp-service/core)
- Guide: [docs/guides/frameworks/nest.md](https://github.com/Suraj-H/otp-service-package/blob/main/docs/guides/frameworks/nest.md)

## Links

- Repository: [github.com/Suraj-H/otp-service-package](https://github.com/Suraj-H/otp-service-package)
- Issues: [github.com/Suraj-H/otp-service-package/issues](https://github.com/Suraj-H/otp-service-package/issues)
npm package: @otp-service/provider-email-resend
Description: Resend email delivery adapter for OTP challenges.
Latest version: 0.1.2

# @otp-service/provider-email-resend

**`OtpDelivery`** adapter that sends OTP challenges via the [Resend](https://resend.com/) HTTP API. Implements [`@otp-service/core`](https://www.npmjs.com/package/@otp-service/core) delivery contract.

**ESM only** · **Node.js ≥ 22** · **License:** MIT

## Install

```bash
npm install @otp-service/provider-email-resend @otp-service/core
```

## Usage

You supply a thin **`ResendHttpClient`** (typically `fetch`) and API configuration. The factory returns an **`OtpDelivery`** you pass to **`createOtpService`**.

```ts
import { createResendEmailProvider } from "@otp-service/provider-email-resend";

const delivery = createResendEmailProvider({
  apiKey: process.env.RESEND_API_KEY!,
  from: "OTP <otp@yourdomain.com>",
  httpClient: {
    post: (url, input) =>
      fetch(url, {
        method: "POST",
        headers: input.headers,
        body: input.body
      }).then(async (response) => ({
        json: () => response.json(),
        status: response.status
      }))
  }
});
```

See **`CreateResendEmailProviderOptions`** in **`dist/index.d.ts`** for full fields (subject template, etc.).

## Security

- Store **`apiKey`** in secrets, never in client-side code.
- Use a verified sending domain in Resend.

## Related packages

- [`@otp-service/core`](https://www.npmjs.com/package/@otp-service/core)
- [`@otp-service/starter`](https://www.npmjs.com/package/@otp-service/starter) — **`createResendEmailOtpService`** composition

## Links

- Repository: [github.com/Suraj-H/otp-service-package](https://github.com/Suraj-H/otp-service-package)
- Issues: [github.com/Suraj-H/otp-service-package/issues](https://github.com/Suraj-H/otp-service-package/issues)
npm package: @otp-service/provider-sms-twilio
Description: Twilio SMS delivery adapter for OTP challenges.
Latest version: 0.1.2

# @otp-service/provider-sms-twilio

**`OtpDelivery`** adapter that sends OTP challenges via **Twilio Programmable SMS**. Implements [`@otp-service/core`](https://www.npmjs.com/package/@otp-service/core) delivery contract.

**ESM only** · **Node.js ≥ 22** · **License:** MIT

## Install

```bash
npm install @otp-service/provider-sms-twilio @otp-service/core
```

## Usage

Provide **`TwilioHttpClient`** (usually `fetch` to Twilio’s API), account credentials, and **`from`** number.

```ts
import { createTwilioSmsProvider } from "@otp-service/provider-sms-twilio";

const delivery = createTwilioSmsProvider({
  accountSid: process.env.TWILIO_ACCOUNT_SID!,
  authToken: process.env.TWILIO_AUTH_TOKEN!,
  from: process.env.TWILIO_FROM!,
  httpClient: {
    post: (url, input) =>
      fetch(url, {
        method: "POST",
        headers: input.headers,
        body: input.body
      }).then(async (response) => ({
        json: () => response.json(),
        status: response.status
      }))
  }
});
```

See **`CreateTwilioSmsProviderOptions`** in **`dist/index.d.ts`** for details.

## Security

- Keep **`authToken`** server-side only.
- Prefer Twilio-segmented secrets and least-privilege API keys where available.

## Related packages

- [`@otp-service/core`](https://www.npmjs.com/package/@otp-service/core)
- [`@otp-service/starter`](https://www.npmjs.com/package/@otp-service/starter) — **`createTwilioSmsOtpService`** composition

## Links

- Repository: [github.com/Suraj-H/otp-service-package](https://github.com/Suraj-H/otp-service-package)
- Issues: [github.com/Suraj-H/otp-service-package/issues](https://github.com/Suraj-H/otp-service-package/issues)
npm package: @otp-service/redis-store
Description: Redis-backed challenge state storage for OTP services.
Latest version: 0.1.2

# @otp-service/redis-store

Redis-backed implementation of [`@otp-service/core`](https://www.npmjs.com/package/@otp-service/core) **`ChallengeStore`** for OTP challenge records (create, get, update, delete).

**ESM only** · **Node.js ≥ 22** · **License:** MIT

## Install

```bash
npm install @otp-service/redis-store @otp-service/core
```

Bring your own **Redis client** that matches the small **`RedisStoreClient`** interface (string get/set/del with optional TTL on set).

## Usage

```ts
import { createRedisChallengeStore } from "@otp-service/redis-store";

const store = createRedisChallengeStore({
  client: redisClient,
  keyPrefix: "otp:myapp"
});

const otpService = createOtpService({
  store,
  delivery,
  signer,
  policy,
  /* ... */
});
```

Implement **`RedisStoreClient`** for **`ioredis`**, **`node-redis`**, or any client that can implement **`get`**, **`set`** (with expiration), and **`del`**.

## Exports

| Export | Purpose |
|--------|---------|
| `createRedisChallengeStore` | Factory returning a `ChallengeStore` |
| `RedisStoreClient` | Port your Redis driver implements |
| `CreateRedisChallengeStoreOptions` | Configuration type |

## Related packages

- [`@otp-service/core`](https://www.npmjs.com/package/@otp-service/core)
- [`@otp-service/starter`](https://www.npmjs.com/package/@otp-service/starter) — wires Redis + providers for you

## Links

- Repository: [github.com/Suraj-H/otp-service-package](https://github.com/Suraj-H/otp-service-package)
- Issues: [github.com/Suraj-H/otp-service-package/issues](https://github.com/Suraj-H/otp-service-package/issues)
npm package: @otp-service/starter
Description: Thin starter composition helpers for the common OTP adoption path.
Latest version: 0.1.2

# @otp-service/starter

Opinionated factories that compose **[`@otp-service/core`](https://www.npmjs.com/package/@otp-service/core)** with **[`@otp-service/redis-store`](https://www.npmjs.com/package/@otp-service/redis-store)** and a real delivery adapter (**Twilio** SMS or **Resend** email) for the common production path.

**ESM only** · **Node.js ≥ 22** · **License:** MIT

## Install

Install **starter** plus the **framework** package you use for HTTP:

```bash
npm install @otp-service/starter @otp-service/express express
# or: @otp-service/fastify fastify
# or: @otp-service/nest @nestjs/common @nestjs/core
```

Starter already depends on **`@otp-service/core`**, **`redis-store`**, and both provider packages; npm will install them as transitive dependencies.

## When to use

- You want **Redis** for challenge state and a **supported** email/SMS provider with minimal wiring.
- You are okay with starter defaults for policy (length, TTL, max attempts); override via options where exposed.

**Avoid** starter if you need a custom store, custom signer design, or non-Resend/Twilio delivery — assemble **`createOtpService`** manually from **`@otp-service/core`** instead.

## Express example

```ts
import express from "express";
import { createTwilioSmsOtpService } from "@otp-service/starter";
import {
  createGenerateChallengeHandler,
  createVerifyChallengeHandler
} from "@otp-service/express";

const otpService = createTwilioSmsOtpService({
  redis: { client: redisClient, keyPrefix: "otp:login" },
  signerSecret: process.env.OTP_SECRET!,
  twilio: {
    accountSid: process.env.TWILIO_ACCOUNT_SID!,
    authToken: process.env.TWILIO_AUTH_TOKEN!,
    from: process.env.TWILIO_FROM!,
    httpClient: { post: (url, i) => fetch(url, { method: "POST", headers: i.headers, body: i.body }).then(...) }
  }
});

const app = express();
app.use(express.json());
app.post("/otp/generate", createGenerateChallengeHandler({ otpService }));
app.post("/otp/verify", createVerifyChallengeHandler({ otpService }));
```

Email path: **`createResendEmailOtpService`** with **`resend`** options — see types in **`dist/index.d.ts`**.

## Exports

| Export | Purpose |
|--------|---------|
| `createTwilioSmsOtpService` | Redis + Twilio + core |
| `createResendEmailOtpService` | Redis + Resend + core |
| `resolvePolicy` / `DEFAULT_OTP_POLICY` | Policy helpers |
| Re-exported **types** from core / redis / providers | Narrow surface for apps |

## More documentation

- [Starter quickstart (monorepo)](https://github.com/Suraj-H/otp-service-package/blob/main/docs/guides/starter-quickstart.md)
- [Security](https://github.com/Suraj-H/otp-service-package/blob/main/docs/guides/security.md)

## Links

- Repository: [github.com/Suraj-H/otp-service-package](https://github.com/Suraj-H/otp-service-package)
- Issues: [github.com/Suraj-H/otp-service-package/issues](https://github.com/Suraj-H/otp-service-package/issues)
npm package: @otp-service/testkit
Description: Test doubles and deterministic fixtures for OTP package testing.
Latest version: 0.1.2

# @otp-service/testkit

In-memory **`ChallengeStore`**, recording **`OtpDelivery`**, deterministic OTP generator, and fixed clock helper — intended for **tests and local examples**, not production.

**ESM only** · **Node.js ≥ 22** · **License:** MIT

## Install

```bash
npm install --save-dev @otp-service/testkit @otp-service/core
```

Use **`--save-dev`** so test doubles are not pulled into production installs unless you intend to.

## Usage

```ts
import { createOtpService, hmacOtpSigner } from "@otp-service/core";
import {
  InMemoryChallengeStore,
  RecordingDelivery,
  createDeterministicOtpGenerator
} from "@otp-service/testkit";

const delivery = new RecordingDelivery();
const generator = createDeterministicOtpGenerator(["123456"]);
const otpService = createOtpService({
  store: new InMemoryChallengeStore(),
  delivery,
  otpGenerator: () => generator.nextOtp(),
  signer: hmacOtpSigner({ secret: "test-secret" }),
  policy: { maxVerifyAttempts: 3, otpLength: 6, ttlSeconds: 600 }
});

// After generateChallenge:
expect(delivery.lastRequest().otp).toBe("123456");
```

## Exports

| Export | Purpose |
|--------|---------|
| `InMemoryChallengeStore` | Volatile `ChallengeStore` |
| `RecordingDelivery` | Captures `DeliveryRequest[]` / `lastRequest()` |
| `createDeterministicOtpGenerator` | Predictable OTP sequence |
| `createFixedClock` | Time-dependent tests |

## Related packages

- [`@otp-service/core`](https://www.npmjs.com/package/@otp-service/core)

## Links

- Repository: [github.com/Suraj-H/otp-service-package](https://github.com/Suraj-H/otp-service-package)
- Issues: [github.com/Suraj-H/otp-service-package/issues](https://github.com/Suraj-H/otp-service-package/issues)
npm package: @otpjs/epmd-client
Description: Node.js EPMD client
Author: Michael Weibel
Latest version: 0.1.0

# node-epmd-client

[![Build Status](https://travis-ci.org/mweibel/node-epmd-client.svg)](https://travis-ci.org/mweibel/node-epmd-client)
[![Coverage Status](https://coveralls.io/repos/mweibel/node-epmd-client/badge.svg?branch=master)](https://coveralls.io/r/mweibel/node-epmd-client?branch=master)

[EPMD](http://www.erlang.org/doc/man/epmd.html) is the abbreviation for **Erlang Port Mapper Daemon** and
this is a client implementing the [EPMD protocol](http://www.erlang.org/doc/apps/erts/erl_dist_protocol.html).
Using this client, you're able to register yourself as a node on EPMD or you can also find out about
ports Erlang nodes listen on. It doesn't however make it possible to actually connect to an Erlang node,
this is will be implemented as part of another repository.

## Installation

```
npm install --save epmd-client
```

## Usage

Please have a look in the examples directory.

## License
MIT
npm package: @otpjs/supervisor
Description: Supervisor implementation for OTP-JS
Author: Zachary Hueras
Latest version: 1.0.0-next.0

# supervisor

A limited OTP `supervisor` implementation.

Currently supported strategies include:

* `one_for_one`
* `simple_one_for_one`

## Install

``` sh
npm i @otpjs/supervisor
```

#### Usage

``` javascript
import * as supervisor from '@otpjs/supervisor';
import * as argumentServer from './arguments';
import * as numberServer from './numbers';

const callbacks = {init};

export function startLink(ctx, arg) {
    return supervisor.startLink(ctx, callbacks, [arg, 123])
}

function init(ctx, arg, number) {
    return [
        ok,
        [
            {strategy: one_for_one},
            [
                {
                    id: 'arg-processor',
                    start: [argumentServer.startLink, [arg]]
                },
                {
                    id: 'number-processor',
                    start: [numberServer.startLink, [number]]
                }
            ]
        ]
    ]
}
```
npm package: @otplib/hotp
Description: RFC 4226 HOTP implementation for otplib
Author: Gerald Yeo
Latest version: 13.4.0

# @otplib/hotp

RFC 4226 HOTP implementation for otplib.

## Installation

```bash
npm install @otplib/hotp
pnpm install @otplib/hotp
yarn add @otplib/hotp
```

## Usage

### generate

Generate an HOTP code for a specific counter:

```typescript
import { generate } from "@otplib/hotp";
import { crypto } from "@otplib/plugin-crypto-node";

const secret = new Uint8Array([
  0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,
  0x37, 0x38, 0x39, 0x30,
]); // 20-byte HMAC key

const token = await generate({
  secret, // Required: Uint8Array or Base32 string
  counter: 0, // Required: counter value
  crypto, // Required: crypto plugin
  algorithm: "sha1", // Optional: 'sha1' | 'sha256' | 'sha512'
  digits: 6, // Optional: 6 | 7 | 8
});
```

#### With Base32 secrets

If your secret is a Base32 string (e.g., from Google Authenticator), provide a `base32` plugin to decode it:

```typescript
import { generate } from "@otplib/hotp";
import { crypto } from "@otplib/plugin-crypto-node";
import { base32 } from "@otplib/plugin-base32-scure";

const token = await generate({
  secret: "GEZDGNBVGY3TQOJQGEZDGNBVGY",
  counter: 0,
  crypto,
  base32, // Required when secret is a string
});
```

### verify

Verify an HOTP code:

```typescript
import { verify } from "@otplib/hotp";
import { crypto } from "@otplib/plugin-crypto-node";

const result = await verify({
  secret, // Required: Uint8Array or Base32 string
  token: "123456", // Required: token to verify
  counter: 0, // Required: expected counter
  crypto, // Required: crypto plugin
  algorithm: "sha1", // Optional: hash algorithm
  digits: 6, // Optional: expected digits
  counterTolerance: 5, // Optional: number or [past, future] tuple
});

// Returns: { valid: true, delta: number } | { valid: false }
```

`counterTolerance` accepts a plain number (creates a look-ahead-only window `[0, n]`, the secure default per RFC 4226) or a `[past, future]` tuple for explicit control (e.g., `[2, 5]`).

### Sync Variants

`generateSync` and `verifySync` are synchronous alternatives with the same signatures. They require a crypto plugin that supports sync HMAC operations, such as `@otplib/plugin-crypto-node` or `@otplib/plugin-crypto-noble`. Using them with `@otplib/plugin-crypto-web` will throw.

```typescript
import { generateSync, verifySync } from "@otplib/hotp";
import { crypto } from "@otplib/plugin-crypto-node";

const secret = new Uint8Array([
  0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,
  0x37, 0x38, 0x39, 0x30,
]);

const token = generateSync({ secret, counter: 0, crypto });
const result = verifySync({ secret, token, counter: 0, crypto });
```

## Documentation

Full documentation available at [otplib.yeojz.dev](https://otplib.yeojz.dev):

- [Getting Started Guide](https://otplib.yeojz.dev/guide/getting-started)
- [API Reference](https://otplib.yeojz.dev/api/)

## License

[MIT](./LICENSE)
npm package: @otplib/plugin-base32-alt
Description: Alternative encoding plugins for otplib
Author: Gerald Yeo
Latest version: 13.2.1

# @otplib/plugin-base32-alt

Alternative encoding plugins for otplib that accept raw string secrets without
Base32 encoding.

## Installation

```bash
npm install @otplib/plugin-base32-alt
pnpm add @otplib/plugin-base32-alt
yarn add @otplib/plugin-base32-alt
```

## Overview

`otplib` treats string secrets as Base32 by default because authenticator apps
and otpauth URIs expect RFC 4648 encoding.

This plugin bypasses Base32 and converts the provided string directly into
bytes (for example, passphrases or secrets stored as hex/base64).

> [!Note]
>
> - Otpauth URI generation still expects Base32 secrets.
> - Errors are still surfaced as `Base32DecodeError` or `Base32EncodeError`.
>   The underlying cause is returned under the error's `cause` property

## Usage

### UTF-8 string secrets

```typescript
import { generate } from "otplib";
import { crypto } from "@otplib/plugin-crypto-node";
import { bypassAsString } from "@otplib/plugin-base32-alt";

const token = await generate({
  secret: "mysecretkey",
  base32: bypassAsString,
  crypto,
});
```

### Hex-encoded secrets

```typescript
import { generate } from "otplib";
import { crypto } from "@otplib/plugin-crypto-node";
import { bypassAsHex } from "@otplib/plugin-base32-alt";

const token = await generate({
  secret: "48656c6c6f", // "Hello" in hex
  base32: bypassAsHex,
  crypto,
});
```

The hex bypass:

- Accepts both lowercase (`abcdef`) and uppercase (`ABCDEF`) hex characters
- Validates input: throws `Base32DecodeError` for odd-length strings or invalid
  characters
- Produces lowercase hex output when encoding

Note: `bypassAsBase16` is available as an alias for `bypassAsHex`.

### Base64-encoded secrets

```typescript
import { generate } from "otplib";
import { crypto } from "@otplib/plugin-crypto-node";
import { bypassAsBase64 } from "@otplib/plugin-base32-alt";

const token = await generate({
  secret: "SGVsbG8=", // "Hello" in base64
  base32: bypassAsBase64,
  crypto,
});
```

### Custom Transformations

For other formats, `createBase32Plugin` can be paired with custom functions:

```typescript
import { createBase32Plugin } from "@otplib/plugin-base32-alt";

// Custom encoding bypass
const customBypass = createBase32Plugin({
  name: "custom-bypass",
  encode: (data) => /* bytes to string */,
  decode: (str) => /* string to bytes */,
});
```

## API

### Exports

- `bypassAsString` - Frozen plugin for UTF-8 string to bytes conversion
- `bypassAsHex` - Frozen plugin for hex string to bytes conversion
- `bypassAsBase16` - Alias for `bypassAsHex`
- `bypassAsBase64` - Frozen plugin for base64 string to bytes conversion
- `createBase32Plugin` - Factory for custom bypass plugins (re-exported from
  `@otplib/core`)

### Types

- `CreateBase32PluginOptions` - Options for `createBase32Plugin`

## License

[MIT](./LICENSE) © 2026 Gerald Yeo
npm package: @otplib/plugin-base32-enc-dec
Description: base32-encode / base32-decode plugin for otplib
Author: Gerald Yeo
Latest version: 12.0.1
Deprecated: Please upgrade to v13 of otplib. Refer to otplib docs for migration paths

# @otplib/plugin-base32-enc-dec

> base32-encoder / base32-decoder adapter for otplib

See our [project readme][project-v-readme] for more information
or visit the [demo website][project-v-site].

## Install

```bash
npm install --save @otplib/plugin-base32-enc-dec
```

## License

`@otplib/plugin-base32-enc-dec` is [MIT licensed][project-license]

[project-license]: https://github.com/yeojz/otplib/blob/master/LICENSE
[project-v-readme]: https://github.com/yeojz/otplib/blob/master/README.md
[project-v-site]: https://otplib.yeojz.dev
npm package: @otplib/plugin-crypto
Description: node crypto plugin for otplib
Author: Gerald Yeo
Latest version: 12.0.1
Deprecated: Please upgrade to v13 of otplib. Refer to otplib docs for migration paths

# @otplib/plugin-crypto

> node native crypto adapter for otplib

See our [project readme][project-v-readme] for more information
or visit the [demo website][project-v-site].

## Install

```bash
npm install --save @otplib/plugin-crypto
```

## License

`@otplib/plugin-crypto` is [MIT licensed][project-license]

[project-license]: https://github.com/yeojz/otplib/blob/master/LICENSE
[project-v-readme]: https://github.com/yeojz/otplib/blob/master/README.md
[project-v-site]: https://otplib.yeojz.dev
npm package: @otplib/plugin-crypto-async-ronomon
Description: crypto-async plugin for otplib
Author: Gerald Yeo
Latest version: 12.0.1
Deprecated: Please upgrade to v13 of otplib. Refer to otplib docs for migration paths

# @otplib/plugin-crypto-async-ronomon

> @ronomon/crypto-async adapter for otplib

See our [project readme][project-v-readme] for more information
or visit the [demo website][project-v-site].

## Install

```bash
npm install --save @otplib/plugin-crypto-async-ronomon
```

## License

`@otplib/plugin-crypto-async-ronomon` is [MIT licensed][project-license]

[project-license]: https://github.com/yeojz/otplib/blob/master/LICENSE
[project-v-readme]: https://github.com/yeojz/otplib/blob/master/README.md
[project-v-site]: https://otplib.yeojz.dev
npm package: @otplib/plugin-crypto-js
Description: crypto-js plugin for otplib
Author: Gerald Yeo
Latest version: 12.0.1
Deprecated: Please upgrade to v13 of otplib. Refer to otplib docs for migration paths

# @otplib/plugin-crypto-js

> crypto-js adapter for otplib

See our [project readme][project-v-readme] for more information
or visit the [demo website][project-v-site].

## Install

```bash
npm install --save @otplib/plugin-crypto-js
```

## License

`@otplib/plugin-crypto-js` is [MIT licensed][project-license]

[project-license]: https://github.com/yeojz/otplib/blob/master/LICENSE
[project-v-readme]: https://github.com/yeojz/otplib/blob/master/README.md
[project-v-site]: https://otplib.yeojz.dev
npm package: @otplib/plugin-crypto-node
Description: Node.js crypto module adapter for otplib
Author: Gerald Yeo
Latest version: 13.4.0

# @otplib/plugin-crypto-node

Node.js crypto plugin for otplib using the built-in `crypto` module.

## Installation

```bash
npm install @otplib/plugin-crypto-node
pnpm add @otplib/plugin-crypto-node
yarn add @otplib/plugin-crypto-node
```

## Overview

This plugin provides HMAC and random byte generation using Node.js's built-in `crypto` module. It supports all hash algorithms available in Node.js:

- `sha1`
- `sha256`
- `sha512`

## Usage

### Basic Usage

```typescript
import { generateSecret, generate } from "otplib";
import { crypto } from "@otplib/plugin-crypto-node";
import { base32 } from "@otplib/plugin-base32-scure";

// Generate a secret
const secret = generateSecret({ crypto, base32 });

// Generate a token
const token = await generate({
  secret,
  crypto,
  base32,
});
```

### With Custom Algorithm

```typescript
import { generate } from "otplib";
import { crypto } from "@otplib/plugin-crypto-node";
import { base32 } from "@otplib/plugin-base32-scure";

const token = await generate({
  secret: "GEZDGNBVGY3TQOJQGEZDGNBVGY",
  algorithm: "sha256",
  crypto,
  base32,
});
```

### Synchronous HMAC

The Node.js crypto plugin supports both synchronous and asynchronous HMAC operations:

```typescript
import { crypto } from "@otplib/plugin-crypto-node";

// Sync HMAC (faster, but blocks event loop)
const digest = crypto.hmacSync("sha1", key, data);

// Async HMAC (doesn't block event loop)
const digest = await crypto.hmac("sha1", key, data);
```

## When to Use

Use this plugin when:

- Running in Node.js environment
- Need maximum performance
- Want to use Node.js built-in crypto (no external dependencies)
- Need synchronous HMAC operations

## Platform Support

- Node.js (all versions)
- Not available in browsers (use `@otplib/plugin-crypto-web` instead)
- Not available in edge runtimes (use `@otplib/plugin-crypto-web` instead)

## Documentation

Full documentation available at [otplib.yeojz.dev](https://otplib.yeojz.dev):

- [Getting Started Guide](https://otplib.yeojz.dev/guide/getting-started)
- [API Reference](https://otplib.yeojz.dev/api/)

## License

[MIT](./LICENSE)
npm package: @otplib/plugin-crypto-web
Description: Web Crypto API adapter for otplib
Author: Gerald Yeo
Latest version: 13.4.0

# @otplib/plugin-crypto-web

Web Crypto API plugin for otplib, compatible with browsers and edge runtimes.

## Installation

```bash
npm install @otplib/plugin-crypto-web
pnpm add @otplib/plugin-crypto-web
yarn add @otplib/plugin-crypto-web
```

## Overview

This plugin provides HMAC and random byte generation using the Web Crypto API. It supports all hash algorithms available in modern browsers:

- `sha1`
- `sha256`
- `sha512`

## Usage

### Basic Usage

```typescript
import { generateSecret, generate } from "otplib";
import { crypto } from "@otplib/plugin-crypto-web";
import { base32 } from "@otplib/plugin-base32-scure";

// Generate a secret
const secret = await generateSecret({ crypto, base32 });

// Generate a token
const token = await generate({
  secret,
  crypto,
  base32,
});
```

### With Custom Algorithm

```typescript
import { generate } from "otplib";
import { crypto } from "@otplib/plugin-crypto-web";
import { base32 } from "@otplib/plugin-base32-scure";

const token = await generate({
  secret: "GEZDGNBVGY3TQOJQGEZDGNBVGY",
  algorithm: "sha256",
  crypto,
  base32,
});
```

### Asynchronous Operations

The Web Crypto API only supports asynchronous operations:

```typescript
import { crypto } from "@otplib/plugin-crypto-web";

// Async HMAC (required by Web Crypto API)
const digest = await crypto.hmac("sha1", key, data);

// Synchronous random bytes
const bytes = crypto.randomBytes(20); // synchronous
```

## Edge Runtime Support

Should also work in runtimes which implements Web Crypto API:

```typescript
// Cloudflare Worker example
import { crypto } from "@otplib/plugin-crypto-web";

export default {
  async fetch(request) {
    // Use crypto for OTP operations
  },
};
```

## When to Use

Use this plugin when:

- Running in browsers (eg: Chrome, Firefox, Safari, Edge)
- Using edge runtimes (eg: Cloudflare Workers, Vercel Edge Functions)
- Building web applications with React, Vue, etc.
- Need cross-platform crypto support
- Want modern browser-native crypto (no external dependencies)

## Performance

- HMAC operations are asynchronous (returns `Promise`)
- `randomBytes` is synchronous (uses `crypto.getRandomValues`)
- Uses native browser crypto implementations backed by OS-level primitives

## Limitations

- Only supports asynchronous operations (no sync HMAC)
- Not available in Node.js (use `@otplib/plugin-crypto-node` instead)
- Requires modern browser with Web Crypto API support

## Documentation

Full documentation available at [otplib.yeojz.dev](https://otplib.yeojz.dev):

- [Getting Started Guide](https://otplib.yeojz.dev/guide/getting-started)
- [API Reference](https://otplib.yeojz.dev/api/)

## License

[MIT](./LICENSE)
npm package: @otplib/plugin-thirty-two
Description: thirty-two plugin for otplib
Author: Gerald Yeo
Latest version: 12.0.1
Deprecated: Please upgrade to v13 of otplib. Refer to otplib docs for migration paths

# @otplib/plugin-thirty-two

> thirty-two adapter for otplib

See our [project readme][project-v-readme] for more information
or visit the [demo website][project-v-site].

## Install

```bash
npm install --save @otplib/plugin-thirty-two
```

## License

`@otplib/plugin-thirty-two` is [MIT licensed][project-license]

[project-license]: https://github.com/yeojz/otplib/blob/master/LICENSE
[project-v-readme]: https://github.com/yeojz/otplib/blob/master/README.md
[project-v-site]: https://otplib.yeojz.dev
npm package: @otplib/preset-browser
Description: browser compatible preset for otplib
Author: Gerald Yeo
Latest version: 12.0.1
Deprecated: Please upgrade to v13 of otplib. Refer to otplib docs for migration paths

# @otplib/preset-browser

> Independent otplib browser bundle containing browser-compatible plugins

`@otplib/preset-browser` is a self-contained `umd` bundle, with `Buffer` split out
as an external dependency and certain defaults chosen to reduce the browser size.

<!-- TOC depthFrom:2 -->

- [Getting Started](#getting-started)
- [Plugins Used](#plugins-used)
- [Bundle Size](#bundle-size)
- [License](#license)

<!-- /TOC -->

## Getting Started

> Check out the main [project documentation][project-v-readme] for
> more information on the library.

There are 2 scripts required: `@otplib/preset-browser/index.js` and `@otplib/preset-browser/buffer.js`.

```html
<script src="https://unpkg.com/@otplib/preset-browser@^12.0.0/buffer.js"></script>
<script src="https://unpkg.com/@otplib/preset-browser@^12.0.0/index.js"></script>

<script type="text/javascript">
  // window.otplib.authenticator
  // window.otplib.hotp
  // window.otplib.totp
</script>
```

The `buffer.js` provided by this library is a cached copy
from [https://www.npmjs.com/package/buffer][link-npm-buffer].
You can also download and include the latest version via their project page.

In the above example, we are directly using the scripts hosted by `unpkg.com`.

You can also `npm install @otplib/preset-browser` and get the bundle
from the `node_modules/@otplib/preset-browser` folder.

## Plugins Used

The following plugins were used as default:

- **crypto**: `crypto-js`
- **encoder**: `base32-encode`
- **decoder**: `base32-decode`

For more details, you can take a look at [packages/otplib-preset-browser/src/index.ts][docs-preset-browser-src].

## Bundle Size

The approximate **bundle sizes** are as follows:

| Bundle Type                       | Size       |
| --------------------------------- | ---------- |
| original                          | 324KB      |
| original, minified + gzipped      | 102KB      |
| optimised                         | 30.9KB     |
| **optimised, minified + gzipped** | **9.53KB** |

Paired with the gzipped browser `buffer.js` module, it would be about `7.65KB + 9.53KB = 17.18KB`.

## License

`@otplib/preset-browser` is [MIT licensed][project-license]

[docs-preset-browser-src]: https://github.com/yeojz/otplib/blob/master/packages/otplib-preset-browser/src/index.ts
[link-npm-buffer]: https://www.npmjs.com/package/buffer
[project-license]: https://github.com/yeojz/otplib/blob/master/LICENSE
[project-v-readme]: https://github.com/yeojz/otplib/blob/master/README.md
npm package: @otplib/preset-default
Description: basic preset for otplib
Author: Gerald Yeo
Latest version: 12.0.1
Deprecated: Please upgrade to v13 of otplib. Refer to otplib docs for migration paths

# @otplib/preset-default

> otplib node bundle with pre-configured plugins to get started quickly.

See our [project readme][project-v-readme] for more information
or visit the [demo website][project-v-site].

## Install

```bash
npm install --save @otplib/preset-default
```

## License

`@otplib/preset-default` is [MIT licensed][project-license]

[project-license]: https://github.com/yeojz/otplib/blob/master/LICENSE
[project-v-readme]: https://github.com/yeojz/otplib/blob/master/README.md
[project-v-site]: https://otplib.yeojz.dev
npm package: @otplib/preset-default-async
Description: async aware basic preset for otplib
Author: Gerald Yeo
Latest version: 12.0.1
Deprecated: Please upgrade to v13 of otplib. Refer to otplib docs for migration paths

# @otplib/preset-default-async

> Async version of otplib node bundle with pre-configured plugins to get started quickly.

See our [project readme][project-v-readme] for more information
or visit the [demo website][project-v-site].

## Install

```bash
npm install --save @otplib/preset-default-async
```

## License

`@otplib/preset-default-async` is [MIT licensed][project-license]

[project-license]: https://github.com/yeojz/otplib/blob/master/LICENSE
[project-v-readme]: https://github.com/yeojz/otplib/blob/master/README.md
[project-v-site]: https://otplib.yeojz.dev
npm package: @otplib/preset-v11
Description: v11 compatibility preset for otplib
Author: Gerald Yeo
Latest version: 13.4.0

# @otplib/preset-v11

> Drop-in replacement adapter for migrating `otplib` from v11 to v13.

This adapter mimics the v11 API while using v13's plugins under the hood. However, some fundamental changes from v13 may carry over.

**Note:** This is intended as a temporary bridge to help you upgrade to v13 without rewriting your entire application immediately. We strongly recommend fully migrating to the new v13 API when possible.

## Installation

```bash
npm install @otplib/preset-v11
pnpm add @otplib/preset-v11
yarn add @otplib/preset-v11
```

## Usage

This package provides a drop-in replacement for `otplib` v11, using the v13 core.

```javascript
import { authenticator, hotp, totp } from "@otplib/preset-v11";

const secret = authenticator.generateSecret();
const token = authenticator.generate(secret);
const isValid = authenticator.check(token, secret);
```

## Compatibility Notes

- **Epoch**: Uses seconds (UNIX timestamp), same as v11.
- **Error Handling**: `check` and `verify` methods swallow errors and return `false`, matching v11 behavior.
- **Secret Length**: Enforces strict secret length (> 16 bytes) due to v13 core security requirements.

## Migration Guide

For a full guide on migrating to v13 refer to the [Migration Guide](https://otplib.yeojz.dev/guide/v11-adapter).

## License

[MIT](./LICENSE)
npm package: @otplib/v12-adapter
Description: Drop-in replacement adapter for migrating from otplib v12 to v13
Author: Gerald Yeo
Latest version: 13.4.0

# @otplib/v12-adapter

> Drop-in replacement adapter for migrating `otplib` from v12 to v13.

This adapter mimics the v12 synchronous API while using v13's plugins under the hood. However, some fundamental changes from v13 may carry over.

**Note:** This is intended as a temporary bridge to help you upgrade to v13 without rewriting your entire application immediately. We strongly recommend fully migrating to the new v13 API when possible.

## Installation

```bash
npm install @otplib/v12-adapter
pnpm add @otplib/v12-adapter
yarn add @otplib/v12-adapter
```

## Usage

Simply update your imports from `otplib` to `@otplib/v12-adapter`.

### Before (v12)

```typescript
import { authenticator } from "otplib";

const secret = authenticator.generateSecret();
const token = authenticator.generate(secret);
const isValid = authenticator.verify({ token, secret });
```

### After (v13 with Adapter)

```typescript
import { authenticator } from "@otplib/v12-adapter";

// API remains exactly the same
const secret = authenticator.generateSecret();
const token = authenticator.generate(secret);
const isValid = authenticator.verify({ token, secret });
```

## Limitations

- **Class/Instance API Only**: This adapter only exports the `authenticator`, `totp`, and `hotp` singleton instances and their classes. If you were importing specific utility functions directly from `otplib/core` or other internal paths in v12, those are not covered by this adapter.
- **Sync/Async**: While this adapter provides a synchronous-looking API (like v12), it uses v13's plugins under the hood. For standard Node.js usage with the default `crypto` module, this works seamlessly.

## Migration Guide

For a full guide on migrating to v13, including the benefits of the new architecture and how to use the new features, please see the [Migration Guide](https://otplib.yeojz.dev/guide/v12-adapter).

## License

[MIT](./LICENSE)
npm package: @otr-app/branch-sdk
Description: Branch Metrics Deep Linking/Smart Banner Web SDK
Author: Dmitri Gaskin
Latest version: 2.74.1

![Latest NPM Version](https://img.shields.io/npm/v/branch-sdk)
![NPM Downloads](https://img.shields.io/npm/dm/branch-sdk)
![License](https://img.shields.io/npm/l/branch-sdk)
![CircleCI](https://img.shields.io/circleci/build/github/BranchMetrics/web-branch-deep-linking-attribution)

[Web Demo App]: https://help.branch.io/developers-hub/docs/web-sdk-overview#section-web-demo-app
[Basic Integration]: https://help.branch.io/developers-hub/docs/web-basic-integration
[Advanced Features]: https://help.branch.io/developers-hub/docs/web-advanced-features
[Testing]: https://help.branch.io/developers-hub/docs/web-testing
[Troubleshooting]: https://help.branch.io/developers-hub/docs/web-troubleshooting
[Web Full Reference]: https://help.branch.io/developers-hub/docs/web-full-reference

# Branch Web SDK

Branch Metrics Deep Linking/Smart Banner Web SDK. Please see
[the SDK documentation](https://help.branch.io/developers-hub/docs/web-sdk-overview)
for full details.

- [Web Demo App]
- [Basic Integration]
- [Advanced Features]
- [Testing]
- [Troubleshooting]
- [Web Full Reference]