1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 15:53:27 +00:00

[PM-20032] Give option to skip token refresh on fullSync (#14423)

* Give option to skip token refresh on fullSync

* Fix listener
This commit is contained in:
Justin Baur
2025-05-01 09:32:10 -04:00
committed by GitHub
parent abf7c949d9
commit 1d00495078
8 changed files with 355 additions and 20 deletions

View File

@@ -54,6 +54,7 @@ import { MessageSender } from "../messaging";
import { StateProvider } from "../state";
import { CoreSyncService } from "./core-sync.service";
import { SyncOptions } from "./sync.service";
export class DefaultSyncService extends CoreSyncService {
syncInProgress = false;
@@ -102,7 +103,15 @@ export class DefaultSyncService extends CoreSyncService {
);
}
override async fullSync(forceSync: boolean, allowThrowOnError = false): Promise<boolean> {
override async fullSync(
forceSync: boolean,
allowThrowOnErrorOrOptions?: boolean | SyncOptions,
): Promise<boolean> {
const { allowThrowOnError = false, skipTokenRefresh = false } =
typeof allowThrowOnErrorOrOptions === "boolean"
? { allowThrowOnError: allowThrowOnErrorOrOptions }
: (allowThrowOnErrorOrOptions ?? {});
const userId = await firstValueFrom(this.accountService.activeAccount$.pipe(map((a) => a?.id)));
this.syncStarted();
const authStatus = await firstValueFrom(this.authService.authStatusFor$(userId));
@@ -127,7 +136,9 @@ export class DefaultSyncService extends CoreSyncService {
}
try {
await this.apiService.refreshIdentityToken();
if (!skipTokenRefresh) {
await this.apiService.refreshIdentityToken();
}
const response = await this.apiService.getSync();
await this.syncProfile(response.profile);