All files / apps/server/src/utils otp.ts

100% Statements 25/25
100% Branches 7/7
100% Functions 1/1
100% Lines 25/25

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 262x 2x 2x 5x 5x 5x 5x 5x 5x 4x 5x 5x 5x 5x 5x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import * as OTPAuth from "otpauth";
 
const generateTOTP = (options: {
  issuer?: string;
  label?: string;
  algorithm?: string;
  digits?: number;
  period?: number;
  secret: string;
}) => {
  const totp = new OTPAuth.TOTP({
    issuer: options.issuer || "FlashApp",
    label: options.label || "user@example.com",
    algorithm: options.algorithm || "SHA1",
    digits: options.digits || 6,
    period: options.period || 30,
    secret: options.secret,
  });
 
  return totp.generate();
};
 
export const OTPUtils = {
  generateTOTP,
};