1 import { base32 } from '@scure/base';
3 export const generateSharedSecret = (length = 20) => {
4 const randomBytes = crypto.getRandomValues(new Uint8Array(length));
5 return base32.encode(randomBytes);
8 interface GetUriArguments {
17 export const getUri = ({
20 issuer = 'ProtonMail',
24 }: GetUriArguments) => {
25 return `otpauth://totp/${identifier}?secret=${sharedSecret}&issuer=${issuer}&algorithm=${algorithm}&digits=${digits}&period=${period}`;