mirror of
https://github.com/bitwarden/browser
synced 2026-02-09 13:10:17 +00:00
feat(extension-notification-demo): Restructured some of the files.
This commit is contained in:
@@ -114,7 +114,6 @@ import {
|
||||
AbstractStorageService,
|
||||
ObservableStorageService,
|
||||
} from "@bitwarden/common/platform/abstractions/storage.service";
|
||||
import { SystemNotificationServiceAbstraction } from "@bitwarden/common/platform/abstractions/system-notification-service.abstraction";
|
||||
import { SystemService as SystemServiceAbstraction } from "@bitwarden/common/platform/abstractions/system.service";
|
||||
import { StateFactory } from "@bitwarden/common/platform/factories/state-factory";
|
||||
import { IpcService } from "@bitwarden/common/platform/ipc";
|
||||
@@ -150,7 +149,6 @@ import { DefaultSdkClientFactory } from "@bitwarden/common/platform/services/sdk
|
||||
import { DefaultSdkService } from "@bitwarden/common/platform/services/sdk/default-sdk.service";
|
||||
import { NoopSdkClientFactory } from "@bitwarden/common/platform/services/sdk/noop-sdk-client-factory";
|
||||
import { StateService } from "@bitwarden/common/platform/services/state.service";
|
||||
import { SystemNotificationService } from "@bitwarden/common/platform/services/system-notification.service";
|
||||
import { SystemService } from "@bitwarden/common/platform/services/system.service";
|
||||
import { UserAutoUnlockKeyService } from "@bitwarden/common/platform/services/user-auto-unlock-key.service";
|
||||
import {
|
||||
@@ -174,6 +172,8 @@ import { WindowStorageService } from "@bitwarden/common/platform/storage/window-
|
||||
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 { BrowserSystemNotificationService } from "@bitwarden/common/platform/system-notifications/browser-system-notification.service";
|
||||
import { SystemNotificationServiceAbstraction } from "@bitwarden/common/platform/system-notifications/system-notification-service.abstraction";
|
||||
import { DefaultThemeStateService } from "@bitwarden/common/platform/theming/theme-state.service";
|
||||
import { ApiService } from "@bitwarden/common/services/api.service";
|
||||
import { AuditService } from "@bitwarden/common/services/audit.service";
|
||||
@@ -1086,7 +1086,7 @@ export default class MainBackground {
|
||||
this.webPushConnectionService = new UnsupportedWebPushConnectionService();
|
||||
}
|
||||
|
||||
this.systemNotificationService = new SystemNotificationService(
|
||||
this.systemNotificationService = new BrowserSystemNotificationService(
|
||||
this.logService,
|
||||
this.platformUtilsService,
|
||||
);
|
||||
|
||||
@@ -112,6 +112,8 @@ import { InlineDerivedStateProvider } from "@bitwarden/common/platform/state/imp
|
||||
import { PrimarySecondaryStorageService } from "@bitwarden/common/platform/storage/primary-secondary-storage.service";
|
||||
import { WindowStorageService } from "@bitwarden/common/platform/storage/window-storage.service";
|
||||
import { SyncService } from "@bitwarden/common/platform/sync";
|
||||
import { SystemNotificationServiceAbstraction } from "@bitwarden/common/platform/system-notifications";
|
||||
import { BrowserSystemNotificationService } from "@bitwarden/common/platform/system-notifications/browser-system-notification.service";
|
||||
import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service.abstraction";
|
||||
import { InternalSendService } from "@bitwarden/common/tools/send/services/send.service.abstraction";
|
||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||
@@ -667,6 +669,11 @@ const safeProviders: SafeProvider[] = [
|
||||
useClass: ForegroundNotificationsService,
|
||||
deps: [LogService],
|
||||
}),
|
||||
safeProvider({
|
||||
provide: SystemNotificationServiceAbstraction,
|
||||
useClass: BrowserSystemNotificationService,
|
||||
deps: [LogService, PlatformUtilsService], // Add any other dependencies your service needs
|
||||
}),
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
||||
@@ -186,7 +186,6 @@ import { SdkClientFactory } from "@bitwarden/common/platform/abstractions/sdk/sd
|
||||
import { SdkService } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
|
||||
import { StateService as StateServiceAbstraction } from "@bitwarden/common/platform/abstractions/state.service";
|
||||
import { AbstractStorageService } from "@bitwarden/common/platform/abstractions/storage.service";
|
||||
import { SystemNotificationServiceAbstraction } from "@bitwarden/common/platform/abstractions/system-notification-service.abstraction";
|
||||
import { ValidationService as ValidationServiceAbstraction } from "@bitwarden/common/platform/abstractions/validation.service";
|
||||
import { StateFactory } from "@bitwarden/common/platform/factories/state-factory";
|
||||
import { Message, MessageListener, MessageSender } from "@bitwarden/common/platform/messaging";
|
||||
@@ -223,7 +222,6 @@ import { MigrationRunner } from "@bitwarden/common/platform/services/migration-r
|
||||
import { DefaultSdkService } from "@bitwarden/common/platform/services/sdk/default-sdk.service";
|
||||
import { StateService } from "@bitwarden/common/platform/services/state.service";
|
||||
import { StorageServiceProvider } from "@bitwarden/common/platform/services/storage-service.provider";
|
||||
import { SystemNotificationService } from "@bitwarden/common/platform/services/system-notification.service";
|
||||
import { UserAutoUnlockKeyService } from "@bitwarden/common/platform/services/user-auto-unlock-key.service";
|
||||
import { ValidationService } from "@bitwarden/common/platform/services/validation.service";
|
||||
import {
|
||||
@@ -245,6 +243,8 @@ import { StateEventRunnerService } from "@bitwarden/common/platform/state/state-
|
||||
import { SyncService } from "@bitwarden/common/platform/sync";
|
||||
// eslint-disable-next-line no-restricted-imports -- Needed for DI
|
||||
import { DefaultSyncService } from "@bitwarden/common/platform/sync/internal";
|
||||
import { UnsupportedSystemNotificationService } from "@bitwarden/common/platform/system-notifications";
|
||||
import { SystemNotificationServiceAbstraction } from "@bitwarden/common/platform/system-notifications/system-notification-service.abstraction";
|
||||
import {
|
||||
DefaultThemeStateService,
|
||||
ThemeStateService,
|
||||
@@ -900,8 +900,8 @@ const safeProviders: SafeProvider[] = [
|
||||
}),
|
||||
safeProvider({
|
||||
provide: SystemNotificationServiceAbstraction,
|
||||
useClass: SystemNotificationService,
|
||||
deps: [LogService, PlatformUtilsServiceAbstraction],
|
||||
useClass: UnsupportedSystemNotificationService,
|
||||
deps: [],
|
||||
}),
|
||||
safeProvider({
|
||||
provide: AuthRequestLoginApprovalAbstraction,
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
SystemNotificationServiceAbstraction,
|
||||
SystemNotificationEvent,
|
||||
ButtonLocation,
|
||||
} from "@bitwarden/common/platform/abstractions/system-notification-service.abstraction";
|
||||
} from "@bitwarden/common/platform/system-notifications/system-notification-service.abstraction";
|
||||
|
||||
export abstract class AuthRequestLoginApprovalAbstraction {
|
||||
abstract receivedPendingAuthRequest(notificationId: string): Promise<void>;
|
||||
|
||||
@@ -9,9 +9,9 @@ import {
|
||||
SystemNotificationCreateInfo,
|
||||
SystemNotificationEvent,
|
||||
SystemNotificationServiceAbstraction as SystemNotificationServiceAbstraction,
|
||||
} from "@bitwarden/common/platform/abstractions/system-notification-service.abstraction";
|
||||
} from "@bitwarden/common/platform/system-notifications/system-notification-service.abstraction";
|
||||
|
||||
export class SystemNotificationService implements SystemNotificationServiceAbstraction {
|
||||
export class BrowserSystemNotificationService implements SystemNotificationServiceAbstraction {
|
||||
private systemNotificationClickedSubject = new Subject<SystemNotificationEvent>();
|
||||
systemNotificationClicked$: Observable<SystemNotificationEvent>;
|
||||
|
||||
2
libs/common/src/platform/system-notifications/index.ts
Normal file
2
libs/common/src/platform/system-notifications/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./system-notification-service.abstraction";
|
||||
export * from "./unsupported-system-notification.service";
|
||||
@@ -0,0 +1,29 @@
|
||||
import { Observable, Subject } from "rxjs";
|
||||
|
||||
import {
|
||||
SystemNotificationClearInfo,
|
||||
SystemNotificationCreateInfo,
|
||||
SystemNotificationEvent,
|
||||
SystemNotificationServiceAbstraction as SystemNotificationServiceAbstraction,
|
||||
} from "@bitwarden/common/platform/system-notifications/system-notification-service.abstraction";
|
||||
|
||||
export class UnsupportedSystemNotificationService implements SystemNotificationServiceAbstraction {
|
||||
private systemNotificationClickedSubject = new Subject<SystemNotificationEvent>();
|
||||
systemNotificationClicked$: Observable<SystemNotificationEvent>;
|
||||
|
||||
constructor() {
|
||||
this.systemNotificationClicked$ = this.systemNotificationClickedSubject.asObservable();
|
||||
}
|
||||
|
||||
async createOSNotification(createInfo: SystemNotificationCreateInfo): Promise<undefined> {
|
||||
throw new Error("Create OS Notification unsupported.");
|
||||
}
|
||||
|
||||
clearOSNotification(clearInfo: SystemNotificationClearInfo): undefined {
|
||||
throw new Error("Clear OS Notification unsupported.");
|
||||
}
|
||||
|
||||
isSupported(): boolean {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user