1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-22 11:45:59 +01:00

[PM-5739] Remove Usage of Angular within Background Script (#7659)

This commit is contained in:
Cesar Gonzalez 2024-02-06 16:24:14 -06:00 committed by GitHub
parent c285a07e16
commit fb17cb7b99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 34 additions and 37 deletions

View File

@ -24,7 +24,7 @@ import { DialogService } from "@bitwarden/components";
import { BiometricErrors, BiometricErrorTypes } from "../../models/biometricErrors";
import { BrowserRouterService } from "../../platform/popup/services/browser-router.service";
import { fido2PopoutSessionData$ } from "../../vault/fido2/browser-fido2-user-interface.service";
import { fido2PopoutSessionData$ } from "../../vault/popup/utils/fido2-popout-session-data";
@Component({
selector: "app-lock",

View File

@ -24,7 +24,10 @@
},
{
"all_frames": true,
"js": ["content/trigger-autofill-script-injection.js"],
"js": [
"content/trigger-autofill-script-injection.js",
"content/fido2/trigger-fido2-content-script-injection.js"
],
"matches": ["http://*/*", "https://*/*", "file:///*"],
"run_at": "document_start"
},
@ -108,7 +111,7 @@
"web_accessible_resources": [
{
"resources": [
"content/webauthn/page-script.js",
"content/fido2/page-script.js",
"notification/bar.html",
"images/icon38.png",
"images/icon38_locked.png",

View File

@ -86,7 +86,7 @@ class BrowserPopupUtils {
* Identifies if the background page needs to be initialized.
*/
static backgroundInitializationRequired() {
return BrowserApi.getBackgroundPage() === null;
return !BrowserApi.getBackgroundPage();
}
/**

View File

@ -1,5 +1,3 @@
import { inject } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import {
BehaviorSubject,
EmptyError,
@ -7,7 +5,6 @@ import {
firstValueFrom,
fromEvent,
fromEventPattern,
map,
merge,
Observable,
Subject,
@ -33,24 +30,6 @@ import { closeFido2Popout, openFido2Popout } from "../popup/utils/vault-popout-w
const BrowserFido2MessageName = "BrowserFido2UserInterfaceServiceMessage";
/**
* Function to retrieve FIDO2 session data from query parameters.
* Expected to be used within components tied to routes with these query parameters.
*/
export function fido2PopoutSessionData$() {
const route = inject(ActivatedRoute);
return route.queryParams.pipe(
map((queryParams) => ({
isFido2Session: queryParams.sessionId != null,
sessionId: queryParams.sessionId as string,
fallbackSupported: queryParams.fallbackSupported === "true",
userVerification: queryParams.userVerification === "true",
senderUrl: queryParams.senderUrl as string,
})),
);
}
export class SessionClosedError extends Error {
constructor() {
super("Fido2UserInterfaceSession was closed");

View File

@ -8,10 +8,8 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import {
BrowserFido2UserInterfaceSession,
fido2PopoutSessionData$,
} from "../../../fido2/browser-fido2-user-interface.service";
import { BrowserFido2UserInterfaceSession } from "../../../fido2/browser-fido2-user-interface.service";
import { fido2PopoutSessionData$ } from "../../utils/fido2-popout-session-data";
@Component({
selector: "app-fido2-use-browser-link",

View File

@ -27,10 +27,8 @@ import { PasswordRepromptService } from "@bitwarden/vault";
import { BrowserApi } from "../../../../platform/browser/browser-api";
import BrowserPopupUtils from "../../../../platform/popup/browser-popup-utils";
import { PopupCloseWarningService } from "../../../../popup/services/popup-close-warning.service";
import {
BrowserFido2UserInterfaceSession,
fido2PopoutSessionData$,
} from "../../../fido2/browser-fido2-user-interface.service";
import { BrowserFido2UserInterfaceSession } from "../../../fido2/browser-fido2-user-interface.service";
import { fido2PopoutSessionData$ } from "../../utils/fido2-popout-session-data";
import { VaultPopoutType, closeAddEditVaultItemPopout } from "../../utils/vault-popout-window";
@Component({

View File

@ -29,10 +29,8 @@ import { PasswordRepromptService } from "@bitwarden/vault";
import { AutofillService } from "../../../../autofill/services/abstractions/autofill.service";
import { BrowserApi } from "../../../../platform/browser/browser-api";
import BrowserPopupUtils from "../../../../platform/popup/browser-popup-utils";
import {
BrowserFido2UserInterfaceSession,
fido2PopoutSessionData$,
} from "../../../fido2/browser-fido2-user-interface.service";
import { BrowserFido2UserInterfaceSession } from "../../../fido2/browser-fido2-user-interface.service";
import { fido2PopoutSessionData$ } from "../../utils/fido2-popout-session-data";
import { closeViewVaultItemPopout, VaultPopoutType } from "../../utils/vault-popout-window";
const BroadcasterSubscriptionId = "ChildViewComponent";

View File

@ -0,0 +1,21 @@
import { inject } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { map } from "rxjs";
/**
* Function to retrieve FIDO2 session data from query parameters.
* Expected to be used within components tied to routes with these query parameters.
*/
export function fido2PopoutSessionData$() {
const route = inject(ActivatedRoute);
return route.queryParams.pipe(
map((queryParams) => ({
isFido2Session: queryParams.sessionId != null,
sessionId: queryParams.sessionId as string,
fallbackSupported: queryParams.fallbackSupported === "true",
userVerification: queryParams.userVerification === "true",
senderUrl: queryParams.senderUrl as string,
})),
);
}