createTOTPKeyURI()
Creates a new key URI for TOTP. Only supports HMAC SHA-1.
Definition
function createTOTPKeyURI(
issuer: string,
accountName: string,
secret: ArrayBuffer | TypedArray,
options?: {
digits?: number;
period?: TimeSpan;
}
): string;
Parameters
issuer: Your company/website nameaccountName: Account identifier (e.g. username)secret: TOTP secret keyoptionsdigits(default:6): OTP digitsperiod(default:30s): How long the OTP is valid for at max
Example
import { createTOTPKeyURI } from "oslo/otp";
import { HMAC } from "oslo/crypto";
const secret = await new HMAC("SHA-1").generateKey();
const issuer = "My website";
const accountName = "user@example.com";
const uri = createTOTPKeyURI(issuer, accountName, secret);