1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-23 16:13:21 +00:00

Merge branch 'main' into km/beeep/fido2-rust-v2

This commit is contained in:
Bernd Schoolmann
2024-12-11 13:12:59 +01:00
1830 changed files with 11555 additions and 2858 deletions

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import {
OrganizationUserApiService,
OrganizationUserConfirmRequest,

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { firstValueFrom, map } from "rxjs";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { CollectionExport } from "@bitwarden/common/models/export/collection.export";
import { SelectionReadOnly } from "../selection-read-only";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import {
OrganizationUserStatusType,
OrganizationUserType,

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { VaultTimeoutService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout.service";
import { Response } from "../../models/response";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import * as http from "http";
import { OptionValues } from "commander";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { firstValueFrom, map } from "rxjs";
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/organization/organization-api.service.abstraction";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import * as chalk from "chalk";
import { firstValueFrom, map } from "rxjs";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { program, OptionValues, Command } from "commander";
import { Response } from "../models/response";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import * as inquirer from "inquirer";
import { firstValueFrom } from "rxjs";

View File

@@ -1,5 +1,6 @@
import * as fet from "node-fetch";
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
import { EncArrayBuffer } from "@bitwarden/common/platform/models/domain/enc-array-buffer";
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
@@ -8,16 +9,36 @@ import { Response } from "../models/response";
import { FileResponse } from "../models/response/file.response";
import { CliUtils } from "../utils";
/**
* Used to download and save attachments
*/
export abstract class DownloadCommand {
constructor(protected encryptService: EncryptService) {}
/**
* @param encryptService - Needed for decryption of the retrieved attachment
* @param apiService - Needed to override the existing nativeFetch which is available as of Node 18, to support proxies
*/
constructor(
protected encryptService: EncryptService,
protected apiService: ApiService,
) {}
/**
* Fetches an attachment via the url, decrypts it's content and saves it to a file
* @param url - url used to retrieve the attachment
* @param key - SymmetricCryptoKey to decrypt the file contents
* @param fileName - filename used when written to disk
* @param output - If output is empty or `--raw` was passed to the initial command the content is output onto stdout
* @returns Promise<FileResponse>
*/
protected async saveAttachmentToFile(
url: string,
key: SymmetricCryptoKey,
fileName: string,
output?: string,
) {
const response = await fet.default(new fet.Request(url, { headers: { cache: "no-cache" } }));
const response = await this.apiService.nativeFetch(
new Request(url, { headers: { cache: "no-cache" } }),
);
if (response.status !== 200) {
return Response.error(
"A " + response.status + " error occurred while downloading the attachment.",

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { firstValueFrom, map } from "rxjs";
import { CollectionRequest } from "@bitwarden/admin-console/common";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { firstValueFrom, map } from "rxjs";
import { CollectionService, CollectionView } from "@bitwarden/admin-console/common";
@@ -21,7 +23,6 @@ import { LoginExport } from "@bitwarden/common/models/export/login.export";
import { SecureNoteExport } from "@bitwarden/common/models/export/secure-note.export";
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
@@ -58,15 +59,14 @@ export class GetCommand extends DownloadCommand {
private auditService: AuditService,
private keyService: KeyService,
encryptService: EncryptService,
private stateService: StateService,
private searchService: SearchService,
private apiService: ApiService,
protected apiService: ApiService,
private organizationService: OrganizationService,
private eventCollectionService: EventCollectionService,
private accountProfileService: BillingAccountProfileStateService,
private accountService: AccountService,
) {
super(encryptService);
super(encryptService, apiService);
}
async run(object: string, id: string, cmdOptions: Record<string, any>): Promise<Response> {

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { firstValueFrom, map } from "rxjs";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";

View File

@@ -1,5 +1,6 @@
import * as fetch from "node-fetch";
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { Response } from "../models/response";
@@ -12,12 +13,15 @@ const UPDATE_COMMAND = "npm install -g @bitwarden/cli";
export class UpdateCommand {
inPkg = false;
constructor(private platformUtilsService: PlatformUtilsService) {
constructor(
private platformUtilsService: PlatformUtilsService,
protected apiService: ApiService,
) {
this.inPkg = !!(process as any).pkg;
}
async run(): Promise<Response> {
const response = await fetch.default(CLIENTS_RELEASE_LIST_ENDPOINT);
const response = await this.apiService.nativeFetch(new Request(CLIENTS_RELEASE_LIST_ENDPOINT));
if (response.status !== 200) {
return Response.error("Error contacting update API: " + response.status);
}

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { BaseResponse } from "./response/base.response";
export class Response {

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { LoginExport } from "@bitwarden/common/models/export/login.export";
import { LoginView } from "@bitwarden/common/vault/models/view/login.view";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { BaseResponse } from "./base.response";
export class MessageResponse implements BaseResponse {

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import * as koaMulter from "@koa/multer";
import * as koaRouter from "@koa/router";
import * as koa from "koa";
@@ -58,7 +60,6 @@ export class OssServeConfigurator {
this.serviceContainer.auditService,
this.serviceContainer.keyService,
this.serviceContainer.encryptService,
this.serviceContainer.stateService,
this.serviceContainer.searchService,
this.serviceContainer.apiService,
this.serviceContainer.organizationService,
@@ -156,6 +157,7 @@ export class OssServeConfigurator {
this.serviceContainer.environmentService,
this.serviceContainer.searchService,
this.serviceContainer.encryptService,
this.serviceContainer.apiService,
);
this.sendEditCommand = new SendEditCommand(
this.serviceContainer.sendService,

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { OptionValues } from "commander";
import { firstValueFrom } from "rxjs";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import * as child_process from "child_process";
import { ClientType, DeviceType } from "@bitwarden/common/enums";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { LogLevelType } from "@bitwarden/common/platform/enums/log-level-type.enum";
import { ConsoleLogService as BaseConsoleLogService } from "@bitwarden/common/platform/services/console-log.service";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import * as fs from "fs";
import * as path from "path";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import * as FormData from "form-data";
import { HttpsProxyAgent } from "https-proxy-agent";
import * as fe from "node-fetch";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { throwError } from "rxjs";
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import * as chalk from "chalk";
import { program, Command, OptionValues } from "commander";
import { firstValueFrom } from "rxjs";
@@ -426,7 +428,10 @@ export class Program extends BaseProgram {
writeLn("", true);
})
.action(async () => {
const command = new UpdateCommand(this.serviceContainer.platformUtilsService);
const command = new UpdateCommand(
this.serviceContainer.platformUtilsService,
this.serviceContainer.apiService,
);
const response = await command.run();
this.processResponse(response);
});

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import * as fs from "fs";
import * as path from "path";
@@ -483,7 +485,7 @@ export class ServiceContainer {
this.domainSettingsService = new DefaultDomainSettingsService(this.stateProvider);
this.fileUploadService = new FileUploadService(this.logService);
this.fileUploadService = new FileUploadService(this.logService, this.apiService);
this.sendStateProvider = new SendStateProvider(this.stateProvider);

View File

@@ -1,7 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"strictNullChecks": true,
"strictPropertyInitialization": true
}
}

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { OptionValues } from "commander";
import * as inquirer from "inquirer";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import {
DefaultPasswordGenerationOptions,
@@ -33,7 +35,7 @@ export class GenerateCommand {
includeNumber: normalizedOptions.includeNumber,
minNumber: normalizedOptions.minNumber,
minSpecial: normalizedOptions.minSpecial,
ambiguous: normalizedOptions.ambiguous,
ambiguous: !normalizedOptions.ambiguous,
};
const enforcedOptions = (await this.stateService.getIsAuthenticated())

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { OptionValues } from "commander";
import * as inquirer from "inquirer";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import * as fs from "fs";
import * as path from "path";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { firstValueFrom } from "rxjs";
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";

View File

@@ -1,6 +1,9 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { OptionValues } from "commander";
import { firstValueFrom } from "rxjs";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
@@ -18,8 +21,9 @@ export class SendGetCommand extends DownloadCommand {
private environmentService: EnvironmentService,
private searchService: SearchService,
encryptService: EncryptService,
apiService: ApiService,
) {
super(encryptService);
super(encryptService, apiService);
}
async run(id: string, options: OptionValues) {

View File

@@ -1,7 +1,10 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
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";
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
@@ -33,8 +36,9 @@ export class SendReceiveCommand extends DownloadCommand {
private platformUtilsService: PlatformUtilsService,
private environmentService: EnvironmentService,
private sendApiService: SendApiService,
apiService: ApiService,
) {
super(encryptService);
super(encryptService, apiService);
}
async run(url: string, options: OptionValues): Promise<Response> {

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { firstValueFrom } from "rxjs";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
import { SendAccessView } from "@bitwarden/common/tools/send/models/view/send-access.view";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { SendFileView } from "@bitwarden/common/tools/send/models/view/send-file.view";
export class SendFileResponse {

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { SendTextView } from "@bitwarden/common/tools/send/models/view/send-text.view";
export class SendTextResponse {

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
import { SendView } from "@bitwarden/common/tools/send/models/view/send.view";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import * as fs from "fs";
import * as path from "path";
@@ -106,6 +108,7 @@ export class SendProgram extends BaseProgram {
this.serviceContainer.platformUtilsService,
this.serviceContainer.environmentService,
this.serviceContainer.sendApiService,
this.serviceContainer.apiService,
);
const response = await cmd.run(url, options);
this.processResponse(response);
@@ -144,7 +147,6 @@ export class SendProgram extends BaseProgram {
this.serviceContainer.auditService,
this.serviceContainer.keyService,
this.serviceContainer.encryptService,
this.serviceContainer.stateService,
this.serviceContainer.searchService,
this.serviceContainer.apiService,
this.serviceContainer.organizationService,
@@ -189,6 +191,7 @@ export class SendProgram extends BaseProgram {
this.serviceContainer.environmentService,
this.serviceContainer.searchService,
this.serviceContainer.encryptService,
this.serviceContainer.apiService,
);
const response = await cmd.run(id, options);
this.processResponse(response);
@@ -248,6 +251,7 @@ export class SendProgram extends BaseProgram {
this.serviceContainer.environmentService,
this.serviceContainer.searchService,
this.serviceContainer.encryptService,
this.serviceContainer.apiService,
);
const cmd = new SendEditCommand(
this.serviceContainer.sendService,

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import * as fs from "fs";
import * as path from "path";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { program, Command } from "commander";
import { ConfirmCommand } from "./admin-console/commands/confirm.command";
@@ -179,7 +181,6 @@ export class VaultProgram extends BaseProgram {
this.serviceContainer.auditService,
this.serviceContainer.keyService,
this.serviceContainer.encryptService,
this.serviceContainer.stateService,
this.serviceContainer.searchService,
this.serviceContainer.apiService,
this.serviceContainer.organizationService,

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import * as fs from "fs";
import * as path from "path";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { CipherWithIdExport } from "@bitwarden/common/models/export/cipher-with-ids.export";
import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";

View File

@@ -1,3 +1,5 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { SyncService } from "@bitwarden/common/platform/sync";
import { Response } from "../models/response";