• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Unleash / unleash / 32378987277
87%
master: 91%

Build:
Build:
LAST BUILD BRANCH: main
DEFAULT BRANCH: master
Ran 20 Aug 2026 02:19PM UTC
Jobs 1
Files 1210
Run time 4min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

20 Aug 2026 02:14PM UTC coverage: 87.437% (-0.01%) from 87.447%
32378987277

push

github

web-flow
fix(tokens): replace linear token scan with a Map lookup

_Stacked on
[feat/revision-probe-metrics](https://github.com/bricks-software/unleash-enterprise/pull/1544),
will merge that one first._

### Issue:

Token lookup was a O(n) scan over every active token:

```ts
	this.activeTokens.find(t => constantTimeCompare(t.secret, secret))
```

Every req walked the whole array. If the token had an alias, that was
twice.


### 🔨 What changed:

Now we have two maps, one for secret and one for alias, so lookup is
O(1).

We keep two maps because the store only queries `tokens.secret`. 
An alias is unqueryable in SQL, so it resolves from memory or not at
all.

What we discovered on the way: The scan compared the presented secret
against every other token, which is what timing attacks target, thus the
`constantTimeCompare` call.

But, as now we have a `map`, it never does that: the key is the secret,
so a hit is already an exact match and the compare could only ever
return true. So, there's no point to keep the `constantTimeCompare`
validation.

### What is 🆕 

- now a token that expires inside the 60s refresh stops authenticating
right away, instead of living until the next refresh
- refactored `getTokenWithCache` - it was 4 nested ifs
- now a token created between refreshes doesn't hit the db on every
request
- added unit tests `token-lookup.test`: scenarios of read-through
indexing, expiry check, etc.

### 🧪 Testing 

From ~28µs to  ~0.0004µs per lookup at 2000 tokens

---------

Co-authored-by: irstavr <irini.stavrakantonaki@getunleash.io>
Co-authored-by: irstavr <irstavr@gmail.com>

3865 of 5031 branches covered (76.82%)

54 of 59 new or added lines in 1 file covered. (91.53%)

5 existing lines in 3 files now uncovered.

15924 of 18212 relevant lines covered (87.44%)

752.59 hits per line

Uncovered Changes

Lines Coverage ∆ File
5
89.47
-0.25% src/lib/services/api-token-service.ts

Coverage Regressions

Lines Coverage ∆ File
3
80.51
-0.77% src/lib/metrics.ts
1
92.16
-1.96% src/lib/features/feature-toggle/configuration-revision-service.ts
1
83.9
1.69% src/lib/features/playground/feature-evaluator/constraint.ts
Jobs
ID Job ID Ran Files Coverage
1 32378987277.1 20 Aug 2026 02:19PM UTC 1210
87.44
GitHub Action Run
Source Files on build 32378987277
  • Tree
  • List 1210
  • Changed 5
  • Source Changed 2
  • Coverage Changed 5
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #32378987277
  • ba444a3b on github
  • Prev Build on main (#32377185107)
  • Next Build on main (#32383510676)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc