1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-04 10:43:47 +00:00

update abstraction

This commit is contained in:
rr-bw
2025-10-17 10:07:09 -07:00
parent ade20dde77
commit 02a04de1d5
5 changed files with 23 additions and 5 deletions

View File

@@ -39,6 +39,7 @@ import { DefaultPolicyService } from "@bitwarden/common/admin-console/services/p
import { PolicyApiService } from "@bitwarden/common/admin-console/services/policy/policy-api.service";
import { ProviderService } from "@bitwarden/common/admin-console/services/provider.service";
import { AccountService as AccountServiceAbstraction } from "@bitwarden/common/auth/abstractions/account.service";
import { AuthRequestAnsweringService } from "@bitwarden/common/auth/abstractions/auth-request-answering/auth-request-answering.service.abstraction";
import { AuthService as AuthServiceAbstraction } from "@bitwarden/common/auth/abstractions/auth.service";
import { AvatarService as AvatarServiceAbstraction } from "@bitwarden/common/auth/abstractions/avatar.service";
import { DevicesServiceAbstraction } from "@bitwarden/common/auth/abstractions/devices/devices.service.abstraction";
@@ -374,7 +375,7 @@ export default class MainBackground {
serverNotificationsService: ServerNotificationsService;
systemNotificationService: SystemNotificationsService;
actionsService: ActionsService;
authRequestAnsweringService: ExtensionAuthRequestAnsweringService;
authRequestAnsweringService: AuthRequestAnsweringService;
stateService: StateServiceAbstraction;
userNotificationSettingsService: UserNotificationSettingsServiceAbstraction;
autofillSettingsService: AutofillSettingsServiceAbstraction;

View File

@@ -1,3 +1,4 @@
import { SystemNotificationEvent } from "@bitwarden/common/platform/system-notifications/system-notifications.service";
import { UserId } from "@bitwarden/user-core";
export abstract class AuthRequestAnsweringService {
@@ -27,6 +28,14 @@ export abstract class AuthRequestAnsweringService {
*/
abstract userMeetsConditionsToShowApprovalDialog(userId: UserId): Promise<boolean>;
/**
* When a system notification is clicked, this function is used to process that event.
* - Implemented in Extension only
*
* @param event The event passed in. Check initNotificationSubscriptions in main.background.ts.
*/
abstract handleAuthRequestNotificationClicked(event: SystemNotificationEvent): Promise<void>;
/**
* Process notifications that have been received but didn't meet the conditions to display the
* approval dialog.

View File

@@ -7,6 +7,7 @@ import { ForceSetPasswordReason } from "@bitwarden/common/auth/models/domain/for
import { getOptionalUserId, getUserId } from "@bitwarden/common/auth/services/account.service";
import { MasterPasswordServiceAbstraction } from "@bitwarden/common/key-management/master-password/abstractions/master-password.service.abstraction";
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
import { SystemNotificationEvent } from "@bitwarden/common/platform/system-notifications/system-notifications.service";
import { UserId } from "@bitwarden/user-core";
import { AuthRequestAnsweringService } from "../../abstractions/auth-request-answering/auth-request-answering.service.abstraction";
@@ -53,6 +54,10 @@ export class DefaultAuthRequestAnsweringService implements AuthRequestAnsweringS
return meetsConditions;
}
async handleAuthRequestNotificationClicked(event: SystemNotificationEvent) {
throw new Error("handleAuthRequestNotificationClicked() not implemented for this client");
}
async processPendingAuthRequests(): Promise<void> {
// Prune any stale pending requests (older than 15 minutes)
// This comes from GlobalSettings.cs

View File

@@ -1,3 +1,4 @@
import { SystemNotificationEvent } from "@bitwarden/common/platform/system-notifications/system-notifications.service";
import { UserId } from "@bitwarden/user-core";
import { AuthRequestAnsweringService } from "../../abstractions/auth-request-answering/auth-request-answering.service.abstraction";
@@ -8,8 +9,10 @@ export class NoopAuthRequestAnsweringService implements AuthRequestAnsweringServ
async receivedPendingAuthRequest(userId: UserId, notificationId: string): Promise<void> {}
async userMeetsConditionsToShowApprovalDialog(userId: UserId): Promise<boolean> {
return false;
throw new Error("userMeetsConditionsToShowApprovalDialog() not implemented for this client");
}
async handleAuthRequestNotificationClicked(event: SystemNotificationEvent) {}
async processPendingAuthRequests(): Promise<void> {}
}

View File

@@ -293,9 +293,9 @@ export class DefaultServerNotificationsService implements ServerNotificationsSer
* pending auth request to process at a time, so this second call will not cause any
* duplicate processing conflicts on Extension.
*/
// this.messagingService.send("openLoginApproval", {
// notificationId: notification.payload.id,
// });
this.messagingService.send("openLoginApproval", {
notificationId: notification.payload.id,
});
break;
case NotificationType.SyncOrganizationStatusChanged:
await this.syncService.fullSync(true);