From 5d3abfa3c5234888b0a4309d3c97e194cb519f9f Mon Sep 17 00:00:00 2001 From: backryun Date: Sun, 26 Jul 2026 16:16:03 +0900 Subject: [PATCH] refactor(sse): retag the Adobe Firefly IMS token-check union MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All 6 diagnostics in adobeFireflyClient.ts are one cause — the `strictNullChecks: false` limitation this campaign has hit repeatedly (#8483, #8499, #8531): a boolean-literal discriminant narrows the positive branch but leaves the negative one as the full union, so the `else` after `if (authed.ok)` could not see `status` or `error`. imsCheckToken(): { ok: true; token; data } | { ok: false; status; error } -> { state: "ok"; … } | { state: "failed"; … } Retagged rather than fixed with a predicate: `imsCheckToken` is module-private (no export, no test reference), which is the rule recorded on #8499 — predicates exist to avoid churning an exported shape, and there is none here. 208 -> 202, zero new, on a line-number-agnostic diff of the full tsc error set. Kept the union inline in the return position instead of extracting a named type: adobeFireflyClient.ts is frozen at 2317 lines with no headroom, and extracting it (plus a doc comment) pushed the file to 2325 and failed check:file-size. The diff is 7 lines changed, 0 added; the reasoning lives here. No test added, and no gap to fill. "cookie exchange rejects guest IMS tokens" already drives both arms in one flow: `guest_allowed=false` returns HTTP 400, taking the failed arm and reading `status`/`error` (its assertion depends on the "All session cookies are empty" text), then `guest_allowed=true` returns 200 and takes the ok arm. 50/50 across the three Adobe Firefly suites; the same suites pass on the parent commit, confirming the retag changes nothing observable. --- open-sse/services/adobeFireflyClient.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/open-sse/services/adobeFireflyClient.ts b/open-sse/services/adobeFireflyClient.ts index 888c28b4ed5..777416a29e8 100644 --- a/open-sse/services/adobeFireflyClient.ts +++ b/open-sse/services/adobeFireflyClient.ts @@ -1569,8 +1569,8 @@ async function imsCheckToken(opts: { guestAllowed: boolean; fetchImpl: typeof fetch; }): Promise< - | { ok: true; token: string; data: ImsTokenResponse } - | { ok: false; status: number; error: string } + | { state: "ok"; token: string; data: ImsTokenResponse } + | { state: "failed"; status: number; error: string } > { const form = new URLSearchParams({ client_id: opts.clientId, @@ -1602,7 +1602,7 @@ async function imsCheckToken(opts: { if (!resp.ok) { return { - ok: false, + state: "failed", status: resp.status, error: sanitizeErrorMessage( data?.error_description || data?.error || text.slice(0, 200) || `HTTP ${resp.status}` @@ -1613,14 +1613,14 @@ async function imsCheckToken(opts: { const token = String(data?.access_token || "").trim(); if (!token) { return { - ok: false, + state: "failed", status: 401, error: sanitizeErrorMessage( data?.error_description || data?.error || "IMS response missing access_token" ), }; } - return { ok: true, token, data: data || {} }; + return { state: "ok", token, data: data || {} }; } /** @@ -1667,7 +1667,7 @@ export async function exchangeAdobeCookieForAccessToken( guestAllowed: false, fetchImpl, }); - if (authed.ok) { + if (authed.state === "ok") { if ( isAdobeGuestAccessToken(authed.token) || authed.data.account_type === "guest" || @@ -1690,7 +1690,7 @@ export async function exchangeAdobeCookieForAccessToken( guestAllowed: true, fetchImpl, }); - if (guest.ok) { + if (guest.state === "ok") { if ( guest.data.account_type === "guest" || guest.data.guestId ||