diff --git a/apps/browser/src/background/main.background.ts b/apps/browser/src/background/main.background.ts index 39ae00a4ee4..915cf6cc432 100644 --- a/apps/browser/src/background/main.background.ts +++ b/apps/browser/src/background/main.background.ts @@ -38,6 +38,7 @@ import { SsoLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/ import { TokenService as TokenServiceAbstraction } from "@bitwarden/common/auth/abstractions/token.service"; import { UserVerificationApiServiceAbstraction } from "@bitwarden/common/auth/abstractions/user-verification/user-verification-api.service.abstraction"; import { UserVerificationService as UserVerificationServiceAbstraction } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction"; +import { AuthServerNotificationTags } from "@bitwarden/common/auth/enums/auth-server-notification-tags"; import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status"; import { AccountServiceImplementation } from "@bitwarden/common/auth/services/account.service"; import { AuthRequestAnsweringService } from "@bitwarden/common/auth/services/auth-request-answering/auth-request-answering.service"; @@ -168,7 +169,6 @@ import { SyncService } from "@bitwarden/common/platform/sync"; // eslint-disable-next-line no-restricted-imports -- Needed for service creation import { DefaultSyncService } from "@bitwarden/common/platform/sync/internal"; import { SystemNotificationsService } from "@bitwarden/common/platform/system-notifications/"; -import { SystemNotificationPrefixes } from "@bitwarden/common/platform/system-notifications/system-notifications.service"; import { UnsupportedSystemNotificationsService } from "@bitwarden/common/platform/system-notifications/unsupported-system-notifications.service"; import { DefaultThemeStateService } from "@bitwarden/common/platform/theming/theme-state.service"; import { ApiService } from "@bitwarden/common/services/api.service"; @@ -1798,7 +1798,7 @@ export default class MainBackground { initNotificationSubscriptions() { this.systemNotificationService.notificationClicked$ .pipe( - filter((n) => n.id.startsWith(SystemNotificationPrefixes.AuthRequest + "_")), + filter((n) => n.id.startsWith(AuthServerNotificationTags.AuthRequest + "_")), map((n) => ({ event: n, authRequestId: n.id.split("_")[1] })), switchMap(({ event }) => this.authRequestAnsweringService.handleAuthRequestNotificationClicked(event), diff --git a/libs/common/src/auth/enums/auth-server-notification-tags.ts b/libs/common/src/auth/enums/auth-server-notification-tags.ts new file mode 100644 index 00000000000..230d0d9d9de --- /dev/null +++ b/libs/common/src/auth/enums/auth-server-notification-tags.ts @@ -0,0 +1,3 @@ +export const AuthServerNotificationTags = Object.freeze({ + AuthRequest: "authRequest", +}); diff --git a/libs/common/src/auth/services/auth-request-answering/auth-request-answering.service.spec.ts b/libs/common/src/auth/services/auth-request-answering/auth-request-answering.service.spec.ts index 33f43f08e25..b0ed63d7cf1 100644 --- a/libs/common/src/auth/services/auth-request-answering/auth-request-answering.service.spec.ts +++ b/libs/common/src/auth/services/auth-request-answering/auth-request-answering.service.spec.ts @@ -3,6 +3,7 @@ import { of } from "rxjs"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service"; +import { AuthServerNotificationTags } from "@bitwarden/common/auth/enums/auth-server-notification-tags"; import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status"; import { ForceSetPasswordReason } from "@bitwarden/common/auth/models/domain/force-set-password-reason"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; @@ -11,7 +12,6 @@ import { ActionsService } from "@bitwarden/common/platform/actions"; import { ButtonLocation, SystemNotificationEvent, - SystemNotificationPrefixes, SystemNotificationsService, } from "@bitwarden/common/platform/system-notifications/system-notifications.service"; import { UserId } from "@bitwarden/user-core"; @@ -109,7 +109,7 @@ describe("AuthRequestAnsweringService", () => { expect(i18nService.t).toHaveBeenCalledWith("accountAccessRequested"); expect(i18nService.t).toHaveBeenCalledWith("confirmAccessAttempt", "user@example.com"); expect(systemNotificationsService.create).toHaveBeenCalledWith({ - id: `${SystemNotificationPrefixes.AuthRequest}_${authRequestId}`, + id: `${AuthServerNotificationTags.AuthRequest}_${authRequestId}`, title: "accountAccessRequested", body: "confirmAccessAttempt:user@example.com", buttons: [], diff --git a/libs/common/src/auth/services/auth-request-answering/auth-request-answering.service.ts b/libs/common/src/auth/services/auth-request-answering/auth-request-answering.service.ts index 3724fd798c2..a562125d1fd 100644 --- a/libs/common/src/auth/services/auth-request-answering/auth-request-answering.service.ts +++ b/libs/common/src/auth/services/auth-request-answering/auth-request-answering.service.ts @@ -2,6 +2,7 @@ import { firstValueFrom } from "rxjs"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service"; +import { AuthServerNotificationTags } from "@bitwarden/common/auth/enums/auth-server-notification-tags"; import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status"; import { ForceSetPasswordReason } from "@bitwarden/common/auth/models/domain/force-set-password-reason"; import { getUserId } from "@bitwarden/common/auth/services/account.service"; @@ -12,7 +13,6 @@ import { ActionsService } from "@bitwarden/common/platform/actions"; import { ButtonLocation, SystemNotificationEvent, - SystemNotificationPrefixes, SystemNotificationsService, } from "@bitwarden/common/platform/system-notifications/system-notifications.service"; import { UserId } from "@bitwarden/user-core"; @@ -60,7 +60,7 @@ export class AuthRequestAnsweringService implements AuthRequestAnsweringServiceA const emailForUser = accounts[userId].email; await this.systemNotificationsService.create({ - id: `${SystemNotificationPrefixes.AuthRequest}_${authRequestId}`, + id: `${AuthServerNotificationTags.AuthRequest}_${authRequestId}`, title: this.i18nService.t("accountAccessRequested"), body: this.i18nService.t("confirmAccessAttempt", emailForUser), buttons: [], diff --git a/libs/common/src/platform/system-notifications/system-notifications.service.ts b/libs/common/src/platform/system-notifications/system-notifications.service.ts index 1cafc970a06..f36e7da96ad 100644 --- a/libs/common/src/platform/system-notifications/system-notifications.service.ts +++ b/libs/common/src/platform/system-notifications/system-notifications.service.ts @@ -1,9 +1,5 @@ import { Observable } from "rxjs"; -export const SystemNotificationPrefixes = Object.freeze({ - AuthRequest: "authRequest", -}); - // This is currently tailored for Chrome extension's api, if Safari works // differently where clicking a notification button produces a different // identifier we need to reconcile that here.