All files / apps/host/src/services e2eService.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 2/2
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30                                              1x 1x 1x 1x      
import { REQUEST_POLICY, runRequestEffect } from '@repo/services/effectRequest';
 
import { ENDPOINTS } from '@/constants/apis';
 
import { e2eHttps } from '@/services/mainHttpClient';
 
export interface OTPGenerateParams {
  issuer?: string;
  label?: string;
  algorithm?: 'SHA1' | 'SHA256' | 'SHA512';
  digits?: number;
  period?: number;
  secret: string;
}
 
export interface OTPGenerateResponse {
  token: string;
  timestamp: string;
}
 
/**
 * Generate a TOTP token from the E2E server
 */
export const generateOTP = async (params: OTPGenerateParams): Promise<OTPGenerateResponse> => {
  return runRequestEffect(async () => {
    const response = await e2eHttps.post<OTPGenerateResponse>(ENDPOINTS.OTP_GENERATE, params);
    return response.data;
  }, REQUEST_POLICY.IDEMPOTENT_WRITE);
};