From fd2735d241bdb65f48dbbc19a33b74df4758d07e Mon Sep 17 00:00:00 2001 From: Diego Imbert Date: Tue, 28 Jul 2026 13:13:26 +0200 Subject: [PATCH] fix(apps): re-prompt when an app widens its SDK scopes mid-consent Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_018Gmsk9kAG7p9t2Qy6ADRJz --- .../lib/components/apps/editor/PublicAppFrame.svelte | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/frontend/src/lib/components/apps/editor/PublicAppFrame.svelte b/frontend/src/lib/components/apps/editor/PublicAppFrame.svelte index 5aa9daaee6..a62c640667 100644 --- a/frontend/src/lib/components/apps/editor/PublicAppFrame.svelte +++ b/frontend/src/lib/components/apps/editor/PublicAppFrame.svelte @@ -298,8 +298,19 @@ * link), and failing there would make the app permanently unviewable for them. * Returns whether a token was actually obtained. */ async function mintWithConsent(): Promise { + const approved = sdkScopes ?? [] try { const resp = await fetchEmbedToken({ sdkConsent: true }) + const granted = resp.sdk_scopes ?? [] + if (!granted.every((s) => approved.includes(s))) { + // The app was redeployed with more scopes between the prompt and the + // mint. Never inject a token carrying scopes the viewer wasn't shown: + // drop it and ask again with the new set. + sdkScopes = granted + sdkToken = undefined + status = 'sdkPrompt' + return false + } sdkToken = resp.token ?? undefined } catch (e: any) { if (e?.status === 401) {