We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 769e5a8 + 4de79e4 commit 870b6f4Copy full SHA for 870b6f4
1 file changed
packages/fxa-auth-server/lib/routes/utils/otp.ts
@@ -56,8 +56,12 @@ export class OtpUtils {
56
const valid = otpAuthenticator.check(code, secret);
57
const delta = otpAuthenticator.checkDelta(code, secret);
58
59
- if (type && delta) {
60
- this.statsd.histogram(`${type}.totp.delta_histogram`, delta);
+ if (type && delta !== undefined && delta !== null) {
+ // Offset delta by window so the value is always non-negative.
61
+ // With window=1: delta -1 → 0, delta 0 → 1, delta 1 → 2.
62
+ // Telegraf's statsd plugin only accepts non-negative histogram values.
63
+ const window = otpOptions?.window ?? 1;
64
+ this.statsd.histogram(`${type}.totp.delta_histogram`, delta + window);
65
}
66
// Return delta for logging
67
return { valid, delta };
0 commit comments