From 2836609da138f1fbb1b40a99b82ec29467035f39 Mon Sep 17 00:00:00 2001 From: Sander Adamse Date: Thu, 16 Apr 2026 23:36:23 +0200 Subject: [PATCH] feat: auto-close sso tab after authentication completes --- .../src/background/runtime.background.ts | 44 +++++++++++-------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/apps/browser/src/background/runtime.background.ts b/apps/browser/src/background/runtime.background.ts index 5c43a54aed69..a5153a7a5ef7 100644 --- a/apps/browser/src/background/runtime.background.ts +++ b/apps/browser/src/background/runtime.background.ts @@ -224,6 +224,31 @@ export default class RuntimeBackground { case "getUrlAutofillTargetingRules": { return await this.main.domainSettingsService.getTargetingRulesForUrl(sender.tab?.url); } + case "authResult": { + if (!(await this.isValidVaultReferrer(msg.referrer))) { + return; + } + + if (msg.lastpass) { + this.messagingService.send("importCallbackLastPass", { + code: msg.code, + state: msg.state, + }); + } else { + try { + await openSsoAuthResultPopout(msg); + } catch { + this.logService.error("Unable to open sso popout tab"); + } + } + + if (sender.tab?.id) { + await BrowserApi.closeTab(sender.tab.id).catch((error) => { + this.logService.error("Unable to close SSO tab", error); + }); + } + break; + } } } @@ -354,25 +379,6 @@ export default class RuntimeBackground { await this.main.reseedStorage(); break; } - case "authResult": { - if (!(await this.isValidVaultReferrer(msg.referrer))) { - return; - } - - if (msg.lastpass) { - this.messagingService.send("importCallbackLastPass", { - code: msg.code, - state: msg.state, - }); - } else { - try { - await openSsoAuthResultPopout(msg); - } catch { - this.logService.error("Unable to open sso popout tab"); - } - } - break; - } case "webAuthnResult": { if (!(await this.isValidVaultReferrer(msg.referrer))) { return;