UNPKG

@streambird/streambird-js

Version:
66 lines (65 loc) 2.48 kB
import { DeviceFingerprint } from '../models'; import { AbstractService } from './abstract-service'; declare type SMSLoginOrCreateRequest = { /** * E.164 formatted mobile phone number that uniquely identifies the user. */ phoneNumber: string; /** * Expiration time of the OTP in minutes. Must be between 1 to 10 minutes, defaults to 1 minute. */ expiresIn?: string; }; declare type SMSLoginOrCreateResponse = { user_id: string; phone_number_id: string; user_created: boolean; status: 'active'; }; declare type EmailLoginOrCreateRequest = { /** * E.164 Email that uniquely identifies the user. */ email: string; /** * Expiration time of the OTP in minutes. Must be between 1 to 10 minutes, defaults to 1 minute. */ expiresIn?: string; /** * Device fingerprinting metadata for fraud detection during magic link token verification step. * This is useful to ensure that the user who originated the request matches the user that verifies the token. * Verification requirements can be enabled in the Verify Token step by matching fieldsin the * device_fingerprint such as IP, User Agent or the combination of them * (more fraud detection features coming soon!) */ deviceFingerprint: Partial<DeviceFingerprint>; }; declare type EmailLoginOrCreateResponse = { email_id: string; phone_number_id: string; user_created: boolean; status: 'active'; }; export declare class OTPService extends AbstractService { url: string; sms: { /** * Create an SMS OTP (one-time passcode) to the provided phone number for login verification. * If no user account exists for the provided phone number, a new user will be created and * OTP sent by SMS. * @returns Email login status data */ loginOrCreate: (body: SMSLoginOrCreateRequest) => Promise<SMSLoginOrCreateResponse>; }; email: { /** * Create an OTP (one-time passcode) to the provided email for login verification. * If no user account exists for the provided email, a new user will be created and email * OTP sent. This public endpoint can be called directly from the browser using the * PublicToken or our Auth SDK. * @returns SMS login status data */ loginOrCreate: (body: EmailLoginOrCreateRequest) => Promise<EmailLoginOrCreateResponse>; }; } export {};