otplib API Documentation / @otplib/core / Base32Secret
Type Alias: Base32Secret
Base32Secret =
Brand<string,"Base32Secret">
Defined in: packages/core/src/utility-types.ts:42
Branded string type for Base32-encoded secrets
Use this type to distinguish Base32-encoded secrets from regular strings at compile time, preventing accidental misuse.
Example
ts
import type { Base32Secret } from '@otplib/core';
function processSecret(secret: Base32Secret): void {
// TypeScript ensures only Base32Secret values are passed
}
const secret = generateSecret() as Base32Secret;
processSecret(secret); // OK
processSecret('random-string'); // Type error