UNPKG

payloadcms_otp_plugin

Version:

A comprehensive One-Time Password (OTP) authentication plugin for Payload CMS that enables secure passwordless authentication via SMS and email

37 lines (36 loc) 942 B
import type { CollectionSlug, Config } from 'payload'; declare module 'payload' { interface BasePayload { otpPluginHooks?: { afterSetOtp?: AfterSetOtpHook; }; otpPluginConfig?: OtpPluginConfig; } } export type AfterSetOtpHook = (args: { otp: string; credentials: { mobile?: string; email?: string; }; otpRecord: any; payload: any; req: any; }) => Promise<void> | void; export type OtpPluginConfig = { /** * List of collections to add a custom field */ collections?: Partial<Record<CollectionSlug, true>>; disabled?: boolean; expiredTime: number; /** * Length of the OTP code (default: 6) */ otpLength?: number; /** * Hook executed after OTP is created and stored */ afterSetOtp?: AfterSetOtpHook; }; export declare const otpPlugin: (pluginOptions: OtpPluginConfig) => (config: Config) => Config;