Skip to content

otplib API Documentation / @otplib/core / utils / HASH_ALGORITHMS

Variable: HASH_ALGORITHMS

const HASH_ALGORITHMS: readonly ("sha1" | "sha256" | "sha512")[]

Defined in: packages/core/src/utils.ts:350

The hash algorithms supported for HMAC operations

Derived from HASH_ALGORITHM_ALIASES rather than written out again, so the runtime allowlist cannot disagree with the names that resolve to it. That matters because this array is both the default supported set and the intersection base in normalizeHashAlgorithm: an algorithm missing here is rejected at runtime no matter what the types say.

Frozen because it is a runtime allowlist, not merely a type-level constant - types are erased at compile time and would leave the exported array mutable, allowing in-process code to corrupt the validation policy and its reported supported set globally.

Released under the MIT License.