A function to generate TOTP values using a base64 encoded token
This is a fork of @md/totp
.
This version uses globalThis
instead of window
which adds Bun and Deno compatibility while being backwards compatible with browsers.
(Cloudflare workers compatibility is unknown -- let me know if you have the chance to test it!)
import getTotp from "jsr:@clouedoc/totp";
const token = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
const totp = getTotp(token); // e.g. "431987"