lowlighter / libs

🍱 Collection of carefully crafted TypeScript standalone libraries. Minimal, unbloated, convenient.
https://jsr.io/@libs
MIT License
104 stars 12 forks source link

`otpsecret` from `totp` to support customized size #75

Open imcotton opened 1 week ago

imcotton commented 1 week ago

e.g.

export function otpsecret(n = 20): string { 
  return encodeBase32(crypto.getRandomValues(new Uint8Array(n))).replaceAll("=", "") 
} 

This is backwards compatible addition, any thoughts?

lowlighter commented 1 day ago

Yes I don't think there's any restriction about the secret length according to: https://github.com/google/google-authenticator/wiki/Key-Uri-Format#secret so we could allow a customized size