feat(frontend): pass session token to the crypto worker (#170) #213
All Vouch review confidence checks passed
Residual risk 0.29 = Change Risk (0.66) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.66 · 369 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.354
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.066
Real PR Conversation Timeline
1 comments
"Review active on #213"
general
weight: 0.35
abendrothj
What and why
Closes #170. The crypto worker read a build-time
VITE_DEV_JWTand kept one vault, with a fixed token, for its whole life. Binding browser keys to the signed-in identity (#175) needs the session identity inside the worker.sessionworker message (protocol.ts) delivers the bearer token.DriveWorkerClientsends the dev token as its first message in development, andsetSession(token)delivers refreshed tokens (and later the real session tokens from P32).iss/sub/tidclaims in memory only (neverlocalStorageor IndexedDB) and no longer readsvaultConfig.devJwt.HttpVaultreads the current token on every request, so a refreshed token applies without restarting the worker.decodeSessionClaims()decodes the claims without verifying the signature (the browser cannot check HS256). The API verifies every request; the API accepting the same token is what makestidauthoritative.typ,expandaudare left to the API.httpvault mode, vault calls are refused before any request leaves the worker when no token is set.DriveContext.sessionfield when each operation starts, so one operation never mixes identities. #175 will use it to switch the key store and AAD from the random UUID to the sessiontid. That work should also checktidagainst the current token, so a mid-upload refresh can't move chunks to another tenant.How it was tested
protocol.test.ts: parser accepts and rejects session messages. The decoder readsiss/sub/tidand rejects malformed tokens (wrong number of segments, bad base64, invalid JSON, missing, empty or non-string claims).worker.test.ts(new) sends messages through the worker:- delivering a token exposes its claims to the crypto core and sends the matching
Authorizationheader- a refreshed token is used for the next request without a restart
- a malformed token is refused, the earlier session is cleared, and no claims are exposed
- in
httpmode without a token, vault calls are refused andfetchis never called- the token never appears in a worker response
httpmode with adevtokentoken (upload, list, download, delete), then withVITE_DEV_JWTcleared (the drive reports "no session token").Checklist
scripts/check.shpasses locallySECURITY_AUDIT_EVENTcovered byaudit_coverage.rsdocs/DATA_POLICY.md)CHANGELOG.mdupdated for user-visible changesdocs/adr/if one was made