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