Commit 4de79e4
committed
fix(auth): offset TOTP delta histogram to avoid negative StatsD values
Because:
* Telegraf's statsd input plugin only accepts non-negative values for
histograms
* The delta from otplib's checkDelta can be negative (e.g. -1 when the
user enters a code from the previous time window)
* The previous guard `if (type && delta)` skipped recording when
delta === 0, silently dropping the most common exact-match case
This commit:
* Offsets delta by the configured window size so values are always
non-negative (with window=1: -1→0, 0→1, 1→2)
* Fixes the falsy check to use `delta !== undefined && delta !== null`
so delta=0 is recorded
* Guards against undefined otpOptions with optional chaining
Fixes #133561 parent 3b34b9c commit 4de79e4
1 file changed
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
60 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
61 | 65 | | |
62 | 66 | | |
63 | 67 | | |
| |||
0 commit comments