Repository navigation
Sign attachment URLs instead of putting the file token in them (GRYT-1549) - #281
Merged
Merged
Conversation
…1549) The phone's copy of the desktop change. attachmentUrl signs each URL per file with a key the server hands over after its identity proof, held in memory. A refused server loses it, and an older server's stored token is only used after that server has proved itself. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Sep 28, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GRYT-1549, the phone half.
attachmentUrlput the file token in?t=for anImagesource, and those loads can't wait for the identity proof (#268). This is the phone's copy of Gryt-chat/client#724. The findings and options are in Gryt-chat/server#251.What changes
src/connection/fileAccess.tsreplacesfileToken.ts. It holds each server's signing key in memory and signs with@noble/hashes.attachmentUrladdsu,k,eandsin place oft, and no caller changed.server:joined,token:refreshedand the newfile:key(a restored session), throughapplyFileAccessintokens.ts.guard.refuse()drops the key when the host counts as refused.markRefusednow returns that.clearTokensdrops it too.fileTokenstill works through?t=. That token stays in SecureStore, butreadTokensno longer puts it in memory.restoreFileTokendoes that right afterguard.release(), so never before the proof. Once a server sends a key, its stored token is deleted.What changes behaviour
Checked
npx tsc --noEmit,yarn test(1279) andyarn test:comment-lengthpass.fileAccess.test.ts: the server's vector, nothing before a key, 5 to 10 minutes, one file each, stable within a step, the server's clock, forgetting, and the old-server token (kept, restored after the proof, deleted once a key arrives, never taken over a key).proofGate.test.ts: an impostor's refusal takes the key away. Mutation-checked: withoutforgetFileAccessinrefuse, it fails.Review-required: none. This is all in the mobile repo.
🤖 Generated with Claude Code