UNPKG

xotp

Version:

One-Time Password (HOTP/TOTP) library for Node.js, Deno and Bun, with support for Google Authenticator.

64 lines (63 loc) 1.93 kB
import { TOTPOptions, Algorithm } from "@src/types"; import { Secret } from "./secret"; declare class TOTP { #private; algorithm: Algorithm; digits: number; window: number; duration: number; issuer: string; account: string; constructor({ algorithm, window, duration, digits, issuer, account, }?: Partial<TOTPOptions>); get defaults(): Readonly<TOTPOptions>; generate({ secret, timestamp, algorithm, digits, duration, }: { secret: Secret; timestamp?: number; algorithm?: Algorithm; digits?: number; duration?: number; }): string; validate({ token, secret, timestamp, algorithm, digits, duration, window, }: { token: string; secret: Secret; timestamp?: number; algorithm?: Algorithm; digits?: number; duration?: number; window?: number; }): boolean; compare({ token, secret, timestamp, algorithm, digits, duration, window, }: { token: string; secret: Secret; timestamp?: number; algorithm?: Algorithm; digits?: number; duration?: number; window?: number; }): number | null; equals({ token, secret, timestamp, algorithm, digits, duration, }: { token: string; secret: Secret; timestamp: number; algorithm?: Algorithm; digits?: number; duration: number; }): boolean; timeUsed({ timestamp, duration, }?: { timestamp?: number; duration?: number; }): number; timeRemaining({ timestamp, duration, }?: { timestamp?: number; duration?: number; }): number; keyUri({ secret, account, issuer, algorithm, duration, digits, }: { secret: Secret; account: string; issuer?: string; algorithm?: Algorithm; duration?: number; digits?: number; }): string; } export { TOTP };