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

x/otpauth/dist/otpauth.esm.min.js>TOTP

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

TOTP: Time-Based One-Time Password Algorithm.

Constructors

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

Creates a TOTP object.

Properties

algorithm: string

HMAC hashing algorithm.

digits: number

Token length.

issuer: string

Account provider.

issuerInLabel: boolean

Include issuer prefix in label.

label: string

Account label.

period: number

Token time-step duration.

secret: Secret

Secret key.

Methods

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

Generates a TOTP token.

toString(): string

Returns a Google Authenticator key URI.

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

Validates a TOTP token.

Static Properties

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

Default configuration.

Static Methods

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

Generates a TOTP token.

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

Validates a TOTP token.