// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../core/resource'; import * as WhatsappAPI from '../../auth/whatsapp/whatsapp'; import * as VerificationAPI from './verification'; import { APIPromise } from '../../../core/api-promise'; import { buildHeaders } from '../../../internal/headers'; import { RequestOptions } from '../../../internal/request-options'; import { path } from '../../../internal/utils/path'; export class StepUp extends APIResource { /** * Request OTP for step-up authentication before a sensitive action (e.g. data * export). */ requestVerification( params: StepUpRequestVerificationParams, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.post('/users/verification/step-up/request-verification', { body, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Resend OTP for an active step-up verification challenge. * * @deprecated */ resend( challengeID: string, params: StepUpResendParams, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.post(path`/users/verification/step-up/${challengeID}/resend`, { body, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Verify step-up OTP and receive a one-time token for sensitive actions. */ verify( challengeID: string, params: StepUpVerifyParams, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.post(path`/users/verification/step-up/${challengeID}/verify`, { body, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } } /** * Phone and email verification resend model. * * Attributes: channel: Channel to resend verification (SMS, WhatsApp, or email) */ export interface VerificationResendModel { /** * Channel to resend verification */ channel: VerificationAPI.VerificationChannel; } /** * Phone and email verification resend response model. * * Attributes: cooldown: Cooldown period in seconds before next resend is allowed */ export interface VerificationResendResponseModel { /** * Cooldown period in seconds */ cooldown: number; } /** * Step-up OTP verified; short-lived token for sensitive endpoints. */ export interface StepUpVerifyResponse { /** * Seconds until the step-up token expires. */ expires_in_seconds: number; /** * One-time token for sensitive actions (e.g. data export). */ otp_verification_token: string; } export interface StepUpRequestVerificationParams { /** * Body param: Delivery channel for the step-up OTP. */ channel?: VerificationAPI.VerificationChannel; /** * Body param: Optional contact override; defaults to the authenticated user's * email. */ contact?: string | null; /** * Header param */ 'Accept-Language'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } export interface StepUpResendParams { /** * Body param: Channel to resend verification */ channel: VerificationAPI.VerificationChannel; /** * Header param */ 'Accept-Language'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } export interface StepUpVerifyParams { /** * Body param: OTP code to verify */ code: string; /** * Header param */ 'Accept-Language'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } export declare namespace StepUp { export { type VerificationResendModel as VerificationResendModel, type VerificationResendResponseModel as VerificationResendResponseModel, type StepUpVerifyResponse as StepUpVerifyResponse, type StepUpRequestVerificationParams as StepUpRequestVerificationParams, type StepUpResendParams as StepUpResendParams, type StepUpVerifyParams as StepUpVerifyParams, }; }