Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): keep the native preview User-Agent so Turnstile passes #7110

Mergedakriaueno(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/7110/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 45 additions and 6 deletions.

x
0 of 2 viewed, 2 left
39 additions and 1 deletionapps/desktop/src/preview/BrowserSession.test.tsModified
View file
@@ -13,7 +13,7 @@
readonly clearCache: ReturnType<typeof vi.fn>;
readonly clearStorageData: ReturnType<typeof vi.fn>;
- readonly getUserAgent: ReturnType<typeof vi.fn>;
+ readonly getUserAgent: ReturnType<typeof vi.fn<() => string>>;
readonly setPermissionRequestHandler: ReturnType<typeof vi.fn>;
readonly setPermissionCheckHandler: ReturnType<typeof vi.fn>;
readonly setUserAgent: ReturnType<typeof vi.fn>;
@@ -102,6 +102,44 @@
}).pipe(Effect.provide(layer)),
​
+ // A rewritten session UA — any variant, even ones that keep the Electron
+ // token — makes Cloudflare Turnstile loop with error 600010 (#5002), so
+ // the guest must end up with Electron's native User-Agent. The mock applies
+ // setUserAgent calls, so this fails on any reintroduced rewrite while still
+ // permitting a harmless re-set of the unchanged native string.
+ it.effect("keeps the guest's effective User-Agent equal to Electron's native one", () =>
+ Effect.gen(function* () {
+ // Electron's real UA shape: app token, then Chrome, then Electron, then
+ // Safari — the token order and casing matter to any strip regex.
+ const nativeUserAgent =
+ "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) T3Code(Alpha)/0.0.33 Chrome/146.0.7680.216 Electron/41.5.0 Safari/537.36";
+ fromPartition.mockReset();
+ fromPartition.mockImplementation((partition: string) => {
+ let userAgent = nativeUserAgent;
+ const browserSession = {
+ clearCache: vi.fn(() => Promise.resolve()),