Add anonymous session mode with redacted user data#13
Open
CS-5 wants to merge 1 commit into
Open
Conversation
A "Continue anonymously" button on the AccessGate issues a Turnstile-gated anonymous session token. The worker tracks session mode in the bearer auth middleware and redacts displayName + avatarUrl in stats responses for anonymous sessions, so PII never reaches the client. In the web UI, names render as a pixelated redaction pill of deterministic hash-based width, and avatars render as a 5x5 symmetric identicon derived from the userId. A small bottom-right banner lets anonymous visitors exit back to the password gate. The analytics route's cache namespace varies by session mode so authed and anonymous responses can't share entries. https://claude.ai/code/session_01Dw3UaAP1QDLQU47ZJhMNvX
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.
Summary
Adds support for anonymous browsing mode, allowing users to access statistics without providing a password. Anonymous sessions display redacted user information (hidden names and avatars) while maintaining full access to emoji reaction data.
Key Changes
Backend (Worker)
createAnonymousSessionToken()andverifyAnonymousSessionToken()functions with distinct token prefix (catalyst-anon-v1) to distinguish from password-authenticated sessionsverifyAnySessionToken()that checks both token types and returns the session mode ("full"or"anonymous")/api/auth/anonymousendpoint that creates anonymous sessions after Turnstile verification (no password required)verifyTurnstile()helper functionAppEnvtype withsessionModevariable to track authentication type across requestsisAnonymous()helperFrontend (Web)
AnonymousAvatarcomponent: generates deterministic, colorful identicons from user IDs using FNV-1a hashingAnonymousNamecomponent: displays variable-length redaction bars (4-9 characters) based on user ID hashUserNamecomponent: unified display that shows real names for authenticated users or redacted names for anonymous usersAvatarcomponent to support anonymous mode with identicon fallbackAccessGatewith visual separatorAnonymousBannercomponent: fixed bottom-right banner showing anonymous mode status with sign-in optionSESSION_ANON_KEYlocalStorage flag andisAnonymousMode()helper to track anonymous sessionsUserNameandAnonymousAvatarfor consistent redactionUtilities
packages/web/src/lib/anonymous.ts: FNV-1a hash function, redaction length calculation, and identicon seed generationpackages/worker/src/lib/types.ts:AppEnvtype definition andisAnonymous()helperImplementation Details
https://claude.ai/code/session_01Dw3UaAP1QDLQU47ZJhMNvX