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

41 lines (40 loc) 1.17 kB
import { PayloadRequest } from "payload"; import { AfterSetOtpHook } from "../index.js"; interface OTPCredentials { mobile?: string; email?: string; } interface LoginCredentials extends OTPCredentials { otp: string; } interface ServiceResponse<T = null> { success: boolean; message: string; data?: T; } interface LoginResponse { token: string; user: any; } export declare class OTPService { private payload; private authCollection; private request; private afterSetOtpHook?; constructor(request: PayloadRequest, collection: string, afterSetOtpHook?: AfterSetOtpHook); generateOTP(length?: number): string; private cleanupExpiredOTPs; private storeOTP; sendOTP(credentials: OTPCredentials, headers?: Headers): Promise<ServiceResponse>; private verifyOTP; private findOrCreateUser; private generateAuthToken; loginWithOTP(credentials: LoginCredentials, headers?: Headers): Promise<ServiceResponse<LoginResponse>>; loginWithMobile(credentials: LoginCredentials): Promise<{ success: boolean; token?: string; user?: any; message: string; }>; } export {};