Oslo

createHOTPKeyURI()

Creates a new key URI for HOTP.

Definition

function createHOTPKeyURI(
	issuer: string,
	accountName: string,
	secret: ArrayBuffer | TypedArray,
	options?: {
		counter?: number;
		digits?: number;
	}
): string;

Parameters

  • issuer: Your company/website name
  • accountName: Account identifier (e.g. username)
  • secret: HOTP secret key
  • options
    • counter (default: 0): Counter count
    • digits (default: 6): OTP digits

Example

import { createHOTPKeyURI } 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 = createHOTPKeyURI(issuer, accountName, secret);