🌳
pt0/serverF/authF/genTotpF.mts
1// @ts-ignore - totp-generator lacks type declarations
2import totp from 'totp-generator'
3import base32 from 'hi-base32'
4import * as _ from 'lodash-es'
8export const genEmailOtp = ({email, appSecret = getPlainMappedSec(tsSecs.appSecret)}: {email: string, appSecret?: string}) => {
10 const stripped = base32.encode(appSecret + email)
12 const token = totp(stripped, {
13 timestamp: _.now(),
14 period: 60 * 60 * 12,
15 digits: 9,
16 })
18 return token