otplib API Documentation / @otplib/core / hasGuardrailOverrides
Function: hasGuardrailOverrides()
hasGuardrailOverrides(
guardrails):boolean
Defined in: packages/core/src/utils.ts:240
Check if guardrails contain custom overrides
Returns true if the guardrails object was created with custom values, false if using RFC-recommended defaults. Useful for security auditing, compliance monitoring, and development warnings.
This function accesses a module-private Symbol property that cannot be accessed or modified outside this module, ensuring reliable detection.
Parameters
guardrails
The guardrails object to check
Returns
boolean
true if guardrails were customized, false if using defaults
Examples
ts
import { createGuardrails, hasGuardrailOverrides } from '@otplib/core';
const guardrails = createGuardrails({ MAX_WINDOW: 20 });
if (hasGuardrailOverrides(guardrails)) {
console.warn('Custom guardrails detected:', guardrails);
// Log to security audit system
}ts
function validateGuardrails(guardrails: OTPGuardrails) {
if (hasGuardrailOverrides(guardrails)) {
throw new Error('Custom guardrails not allowed in production');
}
}