1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 16:53:34 +00:00

Conflict resolution

This commit is contained in:
Carlos Gonçalves
2024-04-02 17:18:45 +01:00
parent 8a1df6671a
commit 0c0c2039ed
699 changed files with 17230 additions and 8095 deletions

View File

@@ -1,7 +1,7 @@
{
"name": "@bitwarden/cli",
"description": "A secure and free password manager for all of your devices.",
"version": "2024.3.0",
"version": "2024.3.1",
"keywords": [
"bitwarden",
"password",
@@ -71,7 +71,7 @@
"papaparse": "5.4.1",
"proper-lockfile": "4.1.2",
"rxjs": "7.8.1",
"tldts": "6.1.13",
"tldts": "6.1.16",
"zxcvbn": "4.4.2"
}
}

View File

@@ -690,6 +690,8 @@ export class LoginCommand {
codeChallenge: string,
state: string,
): Promise<{ ssoCode: string; orgIdentifier: string }> {
const env = await firstValueFrom(this.environmentService.environment$);
return new Promise((resolve, reject) => {
const callbackServer = http.createServer((req, res) => {
const urlString = "http://localhost" + req.url;
@@ -724,7 +726,7 @@ export class LoginCommand {
}
});
let foundPort = false;
const webUrl = this.environmentService.getWebVaultUrl();
const webUrl = env.getWebVaultUrl();
for (let port = 8065; port <= 8070; port++) {
try {
this.ssoRedirectUri = "http://localhost:" + port;

View File

@@ -5,11 +5,13 @@ import { program } from "commander";
import * as jsdom from "jsdom";
import {
InternalUserDecryptionOptionsServiceAbstraction,
AuthRequestService,
LoginStrategyService,
LoginStrategyServiceAbstraction,
PinCryptoService,
PinCryptoServiceAbstraction,
UserDecryptionOptionsService,
} from "@bitwarden/auth/common";
import { EventCollectionService as EventCollectionServiceAbstraction } from "@bitwarden/common/abstractions/event/event-collection.service";
import { EventUploadService as EventUploadServiceAbstraction } from "@bitwarden/common/abstractions/event/event-upload.service";
@@ -45,6 +47,8 @@ import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abs
import { DefaultBillingAccountProfileStateService } from "@bitwarden/common/billing/services/account/billing-account-profile-state.service";
import { ClientType } from "@bitwarden/common/enums";
import { ConfigApiServiceAbstraction } from "@bitwarden/common/platform/abstractions/config/config-api.service.abstraction";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
import { KeyGenerationService as KeyGenerationServiceAbstraction } from "@bitwarden/common/platform/abstractions/key-generation.service";
import {
BiometricStateService,
@@ -57,10 +61,11 @@ import { GlobalState } from "@bitwarden/common/platform/models/domain/global-sta
import { AppIdService } from "@bitwarden/common/platform/services/app-id.service";
import { BroadcasterService } from "@bitwarden/common/platform/services/broadcaster.service";
import { ConfigApiService } from "@bitwarden/common/platform/services/config/config-api.service";
import { DefaultConfigService } from "@bitwarden/common/platform/services/config/default-config.service";
import { ContainerService } from "@bitwarden/common/platform/services/container.service";
import { CryptoService } from "@bitwarden/common/platform/services/crypto.service";
import { EncryptServiceImplementation } from "@bitwarden/common/platform/services/cryptography/encrypt.service.implementation";
import { EnvironmentService } from "@bitwarden/common/platform/services/environment.service";
import { DefaultEnvironmentService } from "@bitwarden/common/platform/services/default-environment.service";
import { FileUploadService } from "@bitwarden/common/platform/services/file-upload/file-upload.service";
import { KeyGenerationService } from "@bitwarden/common/platform/services/key-generation.service";
import { MemoryStorageService } from "@bitwarden/common/platform/services/memory-storage.service";
@@ -128,7 +133,6 @@ import {
VaultExportServiceAbstraction,
} from "@bitwarden/vault-export-core";
import { CliConfigService } from "./platform/services/cli-config.service";
import { CliPlatformUtilsService } from "./platform/services/cli-platform-utils.service";
import { ConsoleLogService } from "./platform/services/console-log.service";
import { I18nService } from "./platform/services/i18n.service";
@@ -169,6 +173,7 @@ export class Main {
eventUploadService: EventUploadServiceAbstraction;
passwordGenerationService: PasswordGenerationServiceAbstraction;
passwordStrengthService: PasswordStrengthServiceAbstraction;
userDecryptionOptionsService: InternalUserDecryptionOptionsServiceAbstraction;
totpService: TotpService;
containerService: ContainerService;
auditService: AuditService;
@@ -210,7 +215,7 @@ export class Main {
deviceTrustCryptoService: DeviceTrustCryptoServiceAbstraction;
authRequestService: AuthRequestService;
configApiService: ConfigApiServiceAbstraction;
configService: CliConfigService;
configService: ConfigService;
accountService: AccountService;
globalStateProvider: GlobalStateProvider;
singleUserStateProvider: SingleUserStateProvider;
@@ -309,13 +314,21 @@ export class Main {
this.derivedStateProvider,
);
this.environmentService = new EnvironmentService(this.stateProvider, this.accountService);
this.environmentService = new DefaultEnvironmentService(
this.stateProvider,
this.accountService,
);
this.keyGenerationService = new KeyGenerationService(this.cryptoFunctionService);
this.tokenService = new TokenService(
this.singleUserStateProvider,
this.globalStateProvider,
this.platformUtilsService.supportsSecureStorage(),
this.secureStorageService,
this.keyGenerationService,
this.encryptService,
this.logService,
);
const migrationRunner = new MigrationRunner(
@@ -336,8 +349,6 @@ export class Main {
migrationRunner,
);
this.keyGenerationService = new KeyGenerationService(this.cryptoFunctionService);
this.cryptoService = new CryptoService(
this.keyGenerationService,
this.cryptoFunctionService,
@@ -416,7 +427,6 @@ export class Main {
this.policyApiService = new PolicyApiService(this.policyService, this.apiService);
this.keyConnectorService = new KeyConnectorService(
this.stateService,
this.cryptoService,
this.apiService,
this.tokenService,
@@ -424,6 +434,7 @@ export class Main {
this.organizationService,
this.keyGenerationService,
async (expired: boolean) => await this.logout(),
this.stateProvider,
);
this.twoFactorService = new TwoFactorService(this.i18nService, this.platformUtilsService);
@@ -436,17 +447,21 @@ export class Main {
this.stateService,
);
this.userDecryptionOptionsService = new UserDecryptionOptionsService(this.stateProvider);
this.devicesApiService = new DevicesApiServiceImplementation(this.apiService);
this.deviceTrustCryptoService = new DeviceTrustCryptoService(
this.keyGenerationService,
this.cryptoFunctionService,
this.cryptoService,
this.encryptService,
this.stateService,
this.appIdService,
this.devicesApiService,
this.i18nService,
this.platformUtilsService,
this.stateProvider,
this.secureStorageService,
this.userDecryptionOptionsService,
);
this.authRequestService = new AuthRequestService(
@@ -457,7 +472,7 @@ export class Main {
);
this.billingAccountProfileStateService = new DefaultBillingAccountProfileStateService(
this.activeUserStateProvider,
this.stateProvider,
);
this.loginStrategyService = new LoginStrategyService(
@@ -478,26 +493,27 @@ export class Main {
this.policyService,
this.deviceTrustCryptoService,
this.authRequestService,
this.userDecryptionOptionsService,
this.globalStateProvider,
this.billingAccountProfileStateService,
);
this.authService = new AuthService(
this.accountService,
this.messagingService,
this.cryptoService,
this.apiService,
this.stateService,
this.tokenService,
);
this.configApiService = new ConfigApiService(this.apiService, this.authService);
this.configApiService = new ConfigApiService(this.apiService, this.tokenService);
this.configService = new CliConfigService(
this.stateService,
this.configService = new DefaultConfigService(
this.configApiService,
this.authService,
this.environmentService,
this.logService,
true,
this.stateProvider,
);
this.cipherService = new CipherService(
@@ -529,6 +545,7 @@ export class Main {
this.biometricStateService = new DefaultBiometricStateService(this.stateProvider);
this.vaultTimeoutSettingsService = new VaultTimeoutSettingsService(
this.userDecryptionOptionsService,
this.cryptoService,
this.tokenService,
this.policyService,
@@ -548,6 +565,7 @@ export class Main {
this.cryptoService,
this.i18nService,
this.userVerificationApiService,
this.userDecryptionOptionsService,
this.pinCryptoService,
this.logService,
this.vaultTimeoutSettingsService,
@@ -589,6 +607,7 @@ export class Main {
this.folderApiService,
this.organizationService,
this.sendApiService,
this.userDecryptionOptionsService,
this.avatarService,
async (expired: boolean) => await this.logout(),
this.billingAccountProfileStateService,
@@ -693,16 +712,8 @@ export class Main {
await this.storageService.init();
await this.stateService.init();
this.containerService.attachToGlobal(global);
await this.environmentService.setUrlsFromStorage();
await this.i18nService.init();
this.twoFactorService.init();
this.configService.init();
const installedVersion = await this.stateService.getInstalledVersion();
const currentVersion = await this.platformUtilsService.getApplicationVersion();
if (installedVersion == null || installedVersion !== currentVersion) {
await this.stateService.setInstalledVersion(currentVersion);
}
}
}

View File

@@ -1,6 +1,10 @@
import { OptionValues } from "commander";
import { firstValueFrom } from "rxjs";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
import {
EnvironmentService,
Region,
} from "@bitwarden/common/platform/abstractions/environment.service";
import { Response } from "../models/response";
import { MessageResponse } from "../models/response/message.response";
@@ -29,16 +33,15 @@ export class ConfigCommand {
!options.notifications &&
!options.events
) {
const env = await firstValueFrom(this.environmentService.environment$);
const stringRes = new StringResponse(
this.environmentService.hasBaseUrl()
? this.environmentService.getUrls().base
: "https://bitwarden.com",
env.hasBaseUrl() ? env.getUrls().base : "https://bitwarden.com",
);
return Response.success(stringRes);
}
url = url === "null" || url === "bitwarden.com" || url === "https://bitwarden.com" ? null : url;
await this.environmentService.setUrls({
await this.environmentService.setEnvironment(Region.SelfHosted, {
base: url,
webVault: options.webVault || null,
api: options.api || null,

View File

@@ -1,8 +1,12 @@
import * as inquirer from "inquirer";
import { firstValueFrom } from "rxjs";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction";
import { KeyConnectorService } from "@bitwarden/common/auth/abstractions/key-connector.service";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
import {
EnvironmentService,
Region,
} from "@bitwarden/common/platform/abstractions/environment.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { Response } from "../models/response";
@@ -67,9 +71,10 @@ export class ConvertToKeyConnectorCommand {
await this.keyConnectorService.setUsesKeyConnector(true);
// Update environment URL - required for api key login
const urls = this.environmentService.getUrls();
const env = await firstValueFrom(this.environmentService.environment$);
const urls = env.getUrls();
urls.keyConnector = organization.keyConnectorUrl;
await this.environmentService.setUrls(urls);
await this.environmentService.setEnvironment(Region.SelfHosted, urls);
return Response.success();
} else if (answer.convert === "leave") {

View File

@@ -1,3 +1,5 @@
import { firstValueFrom } from "rxjs";
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
@@ -17,7 +19,7 @@ export class StatusCommand {
async run(): Promise<Response> {
try {
const baseUrl = this.baseUrl();
const baseUrl = await this.baseUrl();
const status = await this.status();
const lastSync = await this.syncService.getLastSync();
const userId = await this.stateService.getUserId();
@@ -37,8 +39,9 @@ export class StatusCommand {
}
}
private baseUrl(): string {
return this.envService.getUrls().base;
private async baseUrl(): Promise<string> {
const env = await firstValueFrom(this.envService.environment$);
return env.getUrls().base;
}
private async status(): Promise<"unauthenticated" | "locked" | "unlocked"> {

View File

@@ -1,9 +0,0 @@
import { NEVER } from "rxjs";
import { ConfigService } from "@bitwarden/common/platform/services/config/config.service";
export class CliConfigService extends ConfigService {
// The rxjs timer uses setTimeout/setInterval under the hood, which prevents the node process from exiting
// when the command is finished. Cli should never be alive long enough to use the timer, so we disable it.
protected refreshTimer$ = NEVER;
}

View File

@@ -127,7 +127,8 @@ export class SendCreateCommand {
await this.sendApiService.save([encSend, fileData]);
const newSend = await this.sendService.getFromState(encSend.id);
const decSend = await newSend.decrypt();
const res = new SendResponse(decSend, this.environmentService.getWebVaultUrl());
const env = await firstValueFrom(this.environmentService.environment$);
const res = new SendResponse(decSend, env.getWebVaultUrl());
return Response.success(res);
} catch (e) {
return Response.error(e);

View File

@@ -1,4 +1,5 @@
import { OptionValues } from "commander";
import { firstValueFrom } from "rxjs";
import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
@@ -32,7 +33,8 @@ export class SendGetCommand extends DownloadCommand {
return Response.notFound();
}
const webVaultUrl = this.environmentService.getWebVaultUrl();
const env = await firstValueFrom(this.environmentService.environment$);
const webVaultUrl = env.getWebVaultUrl();
let filter = (s: SendView) => true;
let selector = async (s: SendView): Promise<Response> =>
Response.success(new SendResponse(s, webVaultUrl));

View File

@@ -1,3 +1,5 @@
import { firstValueFrom } from "rxjs";
import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
import { SendService } from "@bitwarden/common/tools/send/services/send.service.abstraction";
@@ -21,7 +23,8 @@ export class SendListCommand {
sends = this.searchService.searchSends(sends, normalizedOptions.search);
}
const webVaultUrl = this.environmentService.getWebVaultUrl();
const env = await firstValueFrom(this.environmentService.environment$);
const webVaultUrl = env.getWebVaultUrl();
const res = new ListResponse(sends.map((s) => new SendResponse(s, webVaultUrl)));
return Response.success(res);
}

View File

@@ -1,5 +1,6 @@
import { OptionValues } from "commander";
import * as inquirer from "inquirer";
import { firstValueFrom } from "rxjs";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
@@ -46,7 +47,7 @@ export class SendReceiveCommand extends DownloadCommand {
return Response.badRequest("Failed to parse the provided Send url");
}
const apiUrl = this.getApiUrl(urlObject);
const apiUrl = await this.getApiUrl(urlObject);
const [id, key] = this.getIdAndKey(urlObject);
if (Utils.isNullOrWhitespace(id) || Utils.isNullOrWhitespace(key)) {
@@ -108,8 +109,9 @@ export class SendReceiveCommand extends DownloadCommand {
return [result[0], result[1]];
}
private getApiUrl(url: URL) {
const urls = this.environmentService.getUrls();
private async getApiUrl(url: URL) {
const env = await firstValueFrom(this.environmentService.environment$);
const urls = env.getUrls();
if (url.origin === "https://send.bitwarden.com") {
return "https://api.bitwarden.com";
} else if (url.origin === urls.api) {

View File

@@ -1,3 +1,5 @@
import { firstValueFrom } from "rxjs";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
import { SendService } from "@bitwarden/common/tools/send/services//send.service.abstraction";
import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service.abstraction";
@@ -18,7 +20,8 @@ export class SendRemovePasswordCommand {
const updatedSend = await this.sendService.get(id);
const decSend = await updatedSend.decrypt();
const webVaultUrl = this.environmentService.getWebVaultUrl();
const env = await firstValueFrom(this.environmentService.environment$);
const webVaultUrl = env.getWebVaultUrl();
const res = new SendResponse(decSend, webVaultUrl);
return Response.success(res);
} catch (e) {