1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-21 18:53:29 +00:00

[PM-6302, PM-6303] Add duo state and connector message on browser/desktop (#7957)

* pass state for clients

* use redirect connector to set cookie with translations

* simplify duo redirect url validation
This commit is contained in:
Jake Fink
2024-02-14 18:00:38 -05:00
committed by GitHub
parent 973b95fe38
commit 6562875a23
9 changed files with 121 additions and 17 deletions

View File

@@ -493,6 +493,12 @@
"newAccountCreated": {
"message": "Your new account has been created! You may now log in."
},
"youSuccessfullyLoggedIn": {
"message": "You successfully logged in"
},
"youMayCloseThisWindow": {
"message": "You may close this window"
},
"masterPassSent": {
"message": "We've sent you an email with your master password hint."
},

View File

@@ -203,7 +203,6 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
}
duoResultSubscription: Subscription;
protected override setupDuoResultListener() {
if (!this.duoResultSubscription) {
this.duoResultSubscription = this.browserMessagingApi
@@ -212,12 +211,31 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
filter((msg: any) => msg.command === "duoResult"),
takeUntil(this.destroy$),
)
.subscribe((msg: { command: string; code: string }) => {
this.token = msg.code;
.subscribe((msg: { command: string; code: string; state: string }) => {
this.token = msg.code + "|" + msg.state;
// This floating promise is intentional. We don't need to await the submit + awaiting in a subscription is not recommended.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.submit();
});
}
}
override launchDuoFrameless() {
const duoHandOffMessage = {
title: this.i18nService.t("youSuccessfullyLoggedIn"),
message: this.i18nService.t("youMayCloseThisWindow"),
isCountdown: false,
};
// we're using the connector here as a way to set a cookie with translations
// before continuing to the duo frameless url
const launchUrl =
this.environmentService.getWebVaultUrl() +
"/duo-redirect-connector.html" +
"?duoFramelessUrl=" +
encodeURIComponent(this.duoFramelessUrl) +
"&handOffMessage=" +
encodeURIComponent(JSON.stringify(duoHandOffMessage));
this.platformUtilsService.launchUri(launchUrl);
}
}

View File

@@ -46,8 +46,8 @@ async function handleAuthResultMessage(data: ContentMessageWindowData, referrer:
* @param referrer - The referrer of the window
*/
async function handleDuoResultMessage(data: ContentMessageWindowData, referrer: string) {
const { command, code } = data;
await chrome.runtime.sendMessage({ command, code: code, referrer });
const { command, code, state } = data;
await chrome.runtime.sendMessage({ command, code, state, referrer });
}
/**