diff --git a/apps/browser/src/background/main.background.ts b/apps/browser/src/background/main.background.ts index e89e8144d35..854a70cdea3 100644 --- a/apps/browser/src/background/main.background.ts +++ b/apps/browser/src/background/main.background.ts @@ -44,9 +44,9 @@ import { AccountServiceImplementation } from "@bitwarden/common/auth/services/ac import { AuthService } from "@bitwarden/common/auth/services/auth.service"; import { AvatarService } from "@bitwarden/common/auth/services/avatar.service"; import { - DeviceManagementApprovalService, - DevicesManagementApprovalAbstraction, -} from "@bitwarden/common/auth/services/devices/device-management-approval.service"; + ChromeBrowserExtensionAuthRequestApprovalService, + AuthRequestLoginApprovalAbstraction, +} from "@bitwarden/common/auth/services/devices/chrome-browser-extension-auth-request-approval.service"; import { DevicesServiceImplementation } from "@bitwarden/common/auth/services/devices/devices.service.implementation"; import { DevicesApiServiceImplementation } from "@bitwarden/common/auth/services/devices-api.service.implementation"; import { SsoLoginService } from "@bitwarden/common/auth/services/sso-login.service"; @@ -337,7 +337,7 @@ export default class MainBackground { exportService: VaultExportServiceAbstraction; searchService: SearchServiceAbstraction; notificationsService: NotificationsService; - deviceManagementApprovalService: DevicesManagementApprovalAbstraction; + deviceManagementApprovalService: AuthRequestLoginApprovalAbstraction; systemNotificationService: SystemNotificationServiceAbstraction; stateService: StateServiceAbstraction; userNotificationSettingsService: UserNotificationSettingsServiceAbstraction; @@ -1091,7 +1091,7 @@ export default class MainBackground { this.platformUtilsService, ); - this.deviceManagementApprovalService = new DeviceManagementApprovalService( + this.deviceManagementApprovalService = new ChromeBrowserExtensionAuthRequestApprovalService( this.platformUtilsService, this.logService, this.systemNotificationService, diff --git a/libs/angular/src/services/jslib-services.module.ts b/libs/angular/src/services/jslib-services.module.ts index f416544d1d8..f92d5dc6b81 100644 --- a/libs/angular/src/services/jslib-services.module.ts +++ b/libs/angular/src/services/jslib-services.module.ts @@ -106,9 +106,9 @@ import { AnonymousHubService } from "@bitwarden/common/auth/services/anonymous-h import { AuthService } from "@bitwarden/common/auth/services/auth.service"; import { AvatarService } from "@bitwarden/common/auth/services/avatar.service"; import { - DeviceManagementApprovalService, - DevicesManagementApprovalAbstraction, -} from "@bitwarden/common/auth/services/devices/device-management-approval.service"; + ChromeBrowserExtensionAuthRequestApprovalService, + AuthRequestLoginApprovalAbstraction, +} from "@bitwarden/common/auth/services/devices/chrome-browser-extension-auth-request-approval.service"; import { DevicesServiceImplementation } from "@bitwarden/common/auth/services/devices/devices.service.implementation"; import { DevicesApiServiceImplementation } from "@bitwarden/common/auth/services/devices-api.service.implementation"; import { MasterPasswordApiService } from "@bitwarden/common/auth/services/master-password/master-password-api.service.implementation"; @@ -904,8 +904,8 @@ const safeProviders: SafeProvider[] = [ deps: [LogService, PlatformUtilsServiceAbstraction], }), safeProvider({ - provide: DevicesManagementApprovalAbstraction, - useClass: DeviceManagementApprovalService, + provide: AuthRequestLoginApprovalAbstraction, + useClass: ChromeBrowserExtensionAuthRequestApprovalService, deps: [PlatformUtilsServiceAbstraction, LogService, SystemNotificationServiceAbstraction], }), safeProvider({ @@ -924,7 +924,7 @@ const safeProviders: SafeProvider[] = [ SignalRConnectionService, AuthServiceAbstraction, WebPushConnectionService, - DevicesManagementApprovalAbstraction, + AuthRequestLoginApprovalAbstraction, ], }), safeProvider({ diff --git a/libs/common/src/auth/services/devices/device-management-approval.service.ts b/libs/common/src/auth/services/devices/chrome-browser-extension-auth-request-approval.service.ts similarity index 87% rename from libs/common/src/auth/services/devices/device-management-approval.service.ts rename to libs/common/src/auth/services/devices/chrome-browser-extension-auth-request-approval.service.ts index 0aaa0ffa0d8..b9b8245112b 100644 --- a/libs/common/src/auth/services/devices/device-management-approval.service.ts +++ b/libs/common/src/auth/services/devices/chrome-browser-extension-auth-request-approval.service.ts @@ -9,12 +9,14 @@ import { ButtonLocation, } from "@bitwarden/common/platform/abstractions/system-notification-service.abstraction"; -export abstract class DevicesManagementApprovalAbstraction { +export abstract class AuthRequestLoginApprovalAbstraction { abstract receivedPendingAuthRequest(notificationId: string): Promise; abstract checkForPendingAuthRequestsToApprove(notificationId: string): Promise; } -export class DeviceManagementApprovalService implements DevicesManagementApprovalAbstraction { +export class ChromeBrowserExtensionAuthRequestApprovalService + implements AuthRequestLoginApprovalAbstraction +{ constructor( private platformUtilsService: PlatformUtilsService, private logService: LogService, @@ -55,10 +57,13 @@ export class DeviceManagementApprovalService implements DevicesManagementApprova } /** - * This will be used probably in a guard to route the user - * This is a function because it could cache auth requests coming - * in the background, or it could query the server for any outstanding - * requests. + * Use new device service's endpoint to query for all devices with pending + * auth requests. + * + * This should be used on the application load. + * + * Navigates user to the devices management screen and opens a dialog + * per pending login request. */ async checkForPendingAuthRequestsToApprove(): Promise { // STUB diff --git a/libs/common/src/platform/notifications/internal/default-notifications.service.ts b/libs/common/src/platform/notifications/internal/default-notifications.service.ts index 00334a74ad6..e1d9b80cce2 100644 --- a/libs/common/src/platform/notifications/internal/default-notifications.service.ts +++ b/libs/common/src/platform/notifications/internal/default-notifications.service.ts @@ -12,7 +12,7 @@ import { } from "rxjs"; import { LogoutReason } from "@bitwarden/auth/common"; -import { DevicesManagementApprovalAbstraction } from "@bitwarden/common/auth/services/devices/device-management-approval.service"; +import { AuthRequestLoginApprovalAbstraction } from "@bitwarden/common/auth/services/devices/chrome-browser-extension-auth-request-approval.service"; import { AccountService } from "../../../auth/abstractions/account.service"; import { AuthService } from "../../../auth/abstractions/auth.service"; @@ -55,7 +55,7 @@ export class DefaultNotificationsService implements NotificationsServiceAbstract private readonly signalRConnectionService: SignalRConnectionService, private readonly authService: AuthService, private readonly webPushConnectionService: WebPushConnectionService, - private deviceManagementApprovalService: DevicesManagementApprovalAbstraction, + private deviceManagementApprovalService: AuthRequestLoginApprovalAbstraction, ) { this.notifications$ = this.accountService.activeAccount$.pipe( map((account) => account?.id),