Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/otpauth/dist/otpauth.esm.js>HOTP

One Time Password (HOTP/TOTP) library for Node.js, Deno, Bun and browsers.
Latest
class HOTP
import { HOTP } from "https://deno.land/x/otpauth@v9.3.5/dist/otpauth.esm.js";

HOTP: An HMAC-based One-time Password Algorithm.

Constructors

new
HOTP(unnamed 0?: { issuer?: string | undefined; label?: string | undefined; issuerInLabel?: boolean | undefined; secret?: string | Secret | undefined; algorithm?: string | undefined; digits?: number | undefined; counter?: number | undefined; } | undefined)

Creates an HOTP object.

Properties

algorithm: string

HMAC hashing algorithm.

counter: number

Initial counter value.

digits: number

Token length.

issuer: string

Account provider.

issuerInLabel: boolean

Include issuer prefix in label.

label: string

Account label.

secret: Secret

Secret key.

Methods

generate(unnamed 0?: { counter?: number | undefined; } | undefined): string

Generates an HOTP token.

toString(): string

Returns a Google Authenticator key URI.

validate(unnamed 0: { token: string; counter?: number | undefined; window?: number | undefined; }): number | null

Validates an HOTP token.

Static Properties

readonly
defaults: { issuer: string; label: string; issuerInLabel: boolean; algorithm: string; digits: number; counter: number; window: number; }

Default configuration.

Static Methods

generate(unnamed 0: { secret: Secret; algorithm?: string | undefined; digits?: number | undefined; counter?: number | undefined; }): string

Generates an HOTP token.

validate(unnamed 0: { token: string; secret: Secret; algorithm?: string | undefined; digits?: number | undefined; counter?: number | undefined; window?: number | undefined; }): number | null

Validates an HOTP token.