mirror of
https://github.com/bitwarden/browser
synced 2026-03-01 19:11:22 +00:00
Merge branch 'auth/pm-14943/auth-request-extension-dialog-approve' into auth/pm-14943/auth-request-extension-dialog-approve-debug
This commit is contained in:
@@ -11,8 +11,6 @@ import {
|
||||
Observable,
|
||||
share,
|
||||
switchMap,
|
||||
tap,
|
||||
finalize,
|
||||
} from "rxjs";
|
||||
|
||||
// This import has been flagged as unallowed for this class. It may be involved in a circular dependency loop.
|
||||
@@ -72,19 +70,12 @@ export class DefaultServerNotificationsService implements ServerNotificationsSer
|
||||
this.notifications$ = this.configService
|
||||
.getFeatureFlag$(FeatureFlag.InactiveUserServerNotification)
|
||||
.pipe(
|
||||
tap((value) => {
|
||||
console.debug(`[DefaultServerNotificationsService] feature flag value for inactive user server notifications: ${value}`);
|
||||
}),
|
||||
distinctUntilChanged(),
|
||||
switchMap((inactiveUserServerNotificationEnabled) => {
|
||||
if (inactiveUserServerNotificationEnabled) {
|
||||
console.debug("[DefaultServerNotificationsService] inactive notification processing");
|
||||
return this.accountService.accounts$.pipe(
|
||||
map((accounts) => Object.keys(accounts) as UserId[]),
|
||||
distinctUntilChanged(),
|
||||
tap((value) => {
|
||||
console.debug(`[DefaultServerNotificationsService] new accounts: ${value}`);
|
||||
}),
|
||||
switchMap((userIds) => {
|
||||
if (userIds.length === 0) {
|
||||
return EMPTY;
|
||||
@@ -101,7 +92,6 @@ export class DefaultServerNotificationsService implements ServerNotificationsSer
|
||||
);
|
||||
}
|
||||
|
||||
console.debug("[DefaultServerNotificationsService] NOT inactive notification processing");
|
||||
return this.accountService.activeAccount$.pipe(
|
||||
map((account) => account?.id),
|
||||
distinctUntilChanged(),
|
||||
@@ -128,18 +118,9 @@ export class DefaultServerNotificationsService implements ServerNotificationsSer
|
||||
private userNotifications$(userId: UserId) {
|
||||
return this.environmentService.getEnvironment$(userId).pipe(
|
||||
map((env) => env.getNotificationsUrl()),
|
||||
tap((value) => {
|
||||
console.debug(`[DefaultServerNotificationsService] userNotifications$ before: ${value}`);
|
||||
}),
|
||||
distinctUntilChanged(),
|
||||
tap((value) => {
|
||||
console.debug(`[DefaultServerNotificationsService] userNotifications$ after: ${value}`);
|
||||
}),
|
||||
switchMap((notificationsUrl) => {
|
||||
if (notificationsUrl === DISABLED_NOTIFICATIONS_URL) {
|
||||
console.debug(
|
||||
`[DefaultServerNotificationsService] notifications disabled via URL for user ${userId}`,
|
||||
);
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
@@ -153,18 +134,12 @@ export class DefaultServerNotificationsService implements ServerNotificationsSer
|
||||
distinctUntilChanged(),
|
||||
switchMap((hasAccessToken) => {
|
||||
if (!hasAccessToken) {
|
||||
console.debug(
|
||||
`[DefaultServerNotificationsService] no access token for user ${userId}, skipping notifications`,
|
||||
);
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
return this.activitySubject;
|
||||
}),
|
||||
switchMap((activityStatus) => {
|
||||
console.debug(
|
||||
`[DefaultServerNotificationsService] activity status for user ${userId}: ${activityStatus}`,
|
||||
);
|
||||
if (activityStatus === "inactive") {
|
||||
return EMPTY;
|
||||
}
|
||||
@@ -174,24 +149,15 @@ export class DefaultServerNotificationsService implements ServerNotificationsSer
|
||||
supportSwitch({
|
||||
supported: (service) => {
|
||||
this.logService.info("Using WebPush for server notifications");
|
||||
console.debug(
|
||||
`[DefaultServerNotificationsService] WebPush supported for user ${userId}`,
|
||||
);
|
||||
return service.notifications$.pipe(
|
||||
catchError((err: unknown) => {
|
||||
this.logService.warning("Issue with web push, falling back to SignalR", err);
|
||||
console.debug(
|
||||
`[DefaultServerNotificationsService] WebPush error for user ${userId}, falling back to SignalR`,
|
||||
);
|
||||
return this.connectSignalR$(userId, notificationsUrl);
|
||||
}),
|
||||
);
|
||||
},
|
||||
notSupported: () => {
|
||||
this.logService.info("Using SignalR for server notifications");
|
||||
console.debug(
|
||||
`[DefaultServerNotificationsService] WebPush not supported for user ${userId}, using SignalR`,
|
||||
);
|
||||
return this.connectSignalR$(userId, notificationsUrl);
|
||||
},
|
||||
}),
|
||||
@@ -199,17 +165,9 @@ export class DefaultServerNotificationsService implements ServerNotificationsSer
|
||||
}
|
||||
|
||||
private connectSignalR$(userId: UserId, notificationsUrl: string) {
|
||||
console.debug(
|
||||
`[DefaultServerNotificationsService] Connecting SignalR for user ${userId} to ${notificationsUrl}`,
|
||||
);
|
||||
return this.signalRConnectionService.connect$(userId, notificationsUrl).pipe(
|
||||
filter((n) => n.type === "ReceiveMessage"),
|
||||
map((n) => (n as ReceiveMessage).message),
|
||||
finalize(() =>
|
||||
console.debug(
|
||||
`[DefaultServerNotificationsService] SignalR stream finalized for user ${userId}`,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -322,7 +280,7 @@ export class DefaultServerNotificationsService implements ServerNotificationsSer
|
||||
case NotificationType.AuthRequest:
|
||||
if (
|
||||
await firstValueFrom(
|
||||
this.configService.getFeatureFlag$(FeatureFlag.PM14938_BrowserExtensionLoginApproval)
|
||||
this.configService.getFeatureFlag$(FeatureFlag.PM14938_BrowserExtensionLoginApproval),
|
||||
)
|
||||
) {
|
||||
await this.authRequestAnsweringService.receivedPendingAuthRequest(
|
||||
@@ -346,14 +304,8 @@ export class DefaultServerNotificationsService implements ServerNotificationsSer
|
||||
}
|
||||
|
||||
startListening() {
|
||||
console.debug("[DefaultServerNotificationsService] startListening subscribe");
|
||||
return this.notifications$
|
||||
.pipe(
|
||||
tap(([notification, userId]) =>
|
||||
console.debug(
|
||||
`[DefaultServerNotificationsService] received notification type ${notification.type} for user ${userId}`,
|
||||
),
|
||||
),
|
||||
mergeMap(async ([notification, userId]) => this.processNotification(notification, userId)),
|
||||
)
|
||||
.subscribe({
|
||||
@@ -363,12 +315,10 @@ export class DefaultServerNotificationsService implements ServerNotificationsSer
|
||||
}
|
||||
|
||||
reconnectFromActivity(): void {
|
||||
console.debug("[DefaultServerNotificationsService] reconnectFromActivity called");
|
||||
this.activitySubject.next("active");
|
||||
}
|
||||
|
||||
disconnectFromInactivity(): void {
|
||||
console.debug("[DefaultServerNotificationsService] disconnectFromInactivity called");
|
||||
this.activitySubject.next("inactive");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user