lowlighter / libs

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

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

Closed imcotton closed 2 months ago

imcotton commented 2 months 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 2 months 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