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

x/otpauth/dist/otpauth.d.cts>TOTP

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

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; period?: number | undefined; timestamp?: number | undefined; window?: number | undefined; }): number | null

Validates a TOTP token.