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

[deps] Autofill: Update prettier to v3 (#7014)

* [deps] Autofill: Update prettier to v3

* prettier formatting updates

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
This commit is contained in:
renovate[bot]
2023-11-29 16:15:20 -05:00
committed by GitHub
parent 4ff5f38e89
commit 28de9439be
1145 changed files with 5898 additions and 5612 deletions

View File

@@ -31,7 +31,10 @@ export class FilePasswordPromptComponent {
filePassword: ["", Validators.required],
});
constructor(public dialogRef: DialogRef, protected formBuilder: FormBuilder) {}
constructor(
public dialogRef: DialogRef,
protected formBuilder: FormBuilder,
) {}
submit = () => {
this.formGroup.markAsTouched();

View File

@@ -18,7 +18,10 @@ export interface ErrorListItem {
export class ImportErrorDialogComponent implements OnInit {
protected dataSource = new TableDataSource<ErrorListItem>();
constructor(public dialogRef: DialogRef, @Inject(DIALOG_DATA) public data: Error) {}
constructor(
public dialogRef: DialogRef,
@Inject(DIALOG_DATA) public data: Error,
) {}
ngOnInit(): void {
const split = this.data.message.split("\n\n");

View File

@@ -4,7 +4,7 @@
</span>
<div bitDialogContent>
<span>{{ "importSuccessNumberOfItems" | i18n : this.data.ciphers.length }}</span>
<span>{{ "importSuccessNumberOfItems" | i18n: this.data.ciphers.length }}</span>
<bit-table [dataSource]="dataSource">
<ng-container header>
<tr>

View File

@@ -22,7 +22,10 @@ export interface ResultList {
export class ImportSuccessDialogComponent implements OnInit {
protected dataSource = new TableDataSource<ResultList>();
constructor(public dialogRef: DialogRef, @Inject(DIALOG_DATA) public data: ImportResult) {}
constructor(
public dialogRef: DialogRef,
@Inject(DIALOG_DATA) public data: ImportResult,
) {}
ngOnInit(): void {
if (this.data != null) {

View File

@@ -54,8 +54,7 @@
</bit-select>
<bit-hint>{{
"importTargetHint"
| i18n
: (organizationId ? ("collection" | i18n | lowercase) : ("folder" | i18n | lowercase))
| i18n: (organizationId ? ("collection" | i18n | lowercase) : ("folder" | i18n | lowercase))
}}</bit-hint>
</bit-form-field>

View File

@@ -178,7 +178,7 @@ export class ImportComponent implements OnInit, OnDestroy {
protected folderService: FolderService,
protected collectionService: CollectionService,
protected organizationService: OrganizationService,
protected formBuilder: FormBuilder
protected formBuilder: FormBuilder,
) {}
protected get importBlockedByPolicy(): boolean {
@@ -202,8 +202,8 @@ export class ImportComponent implements OnInit, OnDestroy {
this.organizations$ = concat(
this.organizationService.memberOrganizations$.pipe(
canAccessImportExport(this.i18nService),
map((orgs) => orgs.sort(Utils.getSortFunction(this.i18nService, "name")))
)
map((orgs) => orgs.sort(Utils.getSortFunction(this.i18nService, "name"))),
),
);
combineLatest([
@@ -225,12 +225,12 @@ export class ImportComponent implements OnInit, OnDestroy {
this.collections$ = Utils.asyncToObservable(() =>
this.collectionService
.getAllDecrypted()
.then((c) => c.filter((c2) => c2.organizationId === this.organizationId))
.then((c) => c.filter((c2) => c2.organizationId === this.organizationId)),
);
} else {
// Filter out the `no folder`-item from folderViews$
this.folders$ = this.folderService.folderViews$.pipe(
map((folders) => folders.filter((f) => f.id != null))
map((folders) => folders.filter((f) => f.id != null)),
);
this.formGroup.controls.targetSelector.disable();
@@ -245,7 +245,7 @@ export class ImportComponent implements OnInit, OnDestroy {
this.collections$ = Utils.asyncToObservable(() =>
this.collectionService
.getAllDecrypted()
.then((c) => c.filter((c2) => c2.organizationId === value))
.then((c) => c.filter((c2) => c2.organizationId === value)),
);
}
});
@@ -273,7 +273,7 @@ export class ImportComponent implements OnInit, OnDestroy {
private async asyncValidatorsFinished() {
if (this.formGroup.pending) {
await firstValueFrom(
this.formGroup.statusChanges.pipe(filter((status) => status !== "PENDING"))
this.formGroup.statusChanges.pipe(filter((status) => status !== "PENDING")),
);
}
}
@@ -295,7 +295,7 @@ export class ImportComponent implements OnInit, OnDestroy {
this.platformUtilsService.showToast(
"error",
null,
this.i18nService.t("personalOwnershipPolicyInEffectImports")
this.i18nService.t("personalOwnershipPolicyInEffectImports"),
);
return;
}
@@ -307,14 +307,14 @@ export class ImportComponent implements OnInit, OnDestroy {
const importer = this.importService.getImporter(
this.format,
promptForPassword_callback,
this.organizationId
this.organizationId,
);
if (importer === null) {
this.platformUtilsService.showToast(
"error",
this.i18nService.t("errorOccurred"),
this.i18nService.t("selectFormat")
this.i18nService.t("selectFormat"),
);
return;
}
@@ -326,7 +326,7 @@ export class ImportComponent implements OnInit, OnDestroy {
this.platformUtilsService.showToast(
"error",
this.i18nService.t("errorOccurred"),
this.i18nService.t("selectFile")
this.i18nService.t("selectFile"),
);
return;
}
@@ -346,7 +346,7 @@ export class ImportComponent implements OnInit, OnDestroy {
this.platformUtilsService.showToast(
"error",
this.i18nService.t("errorOccurred"),
this.i18nService.t("selectFile")
this.i18nService.t("selectFile"),
);
return;
}
@@ -361,7 +361,7 @@ export class ImportComponent implements OnInit, OnDestroy {
fileContents,
this.organizationId,
this.formGroup.controls.targetSelector.value,
this.canAccessImportExport(this.organizationId)
this.canAccessImportExport(this.organizationId),
);
//No errors, display success message
@@ -486,7 +486,7 @@ export class ImportComponent implements OnInit, OnDestroy {
},
function error(e) {
return "";
}
},
);
}

View File

@@ -59,7 +59,7 @@ export class LastPassMultifactorPromptComponent {
constructor(
public dialogRef: DialogRef,
@Inject(DIALOG_DATA) protected data: LastPassMultifactorPromptData
@Inject(DIALOG_DATA) protected data: LastPassMultifactorPromptData,
) {}
submit = () => {

View File

@@ -56,7 +56,7 @@ export class ImportLastPassComponent implements OnInit, OnDestroy {
if (status === "PENDING") {
return this.i18nService.t("importingYourAccount");
}
})
}),
);
@Output() csvDataLoaded = new EventEmitter<string>();
@@ -66,7 +66,7 @@ export class ImportLastPassComponent implements OnInit, OnDestroy {
private controlContainer: ControlContainer,
private logService: LogService,
private lastPassDirectImportService: LastPassDirectImportService,
private i18nService: I18nService
private i18nService: I18nService,
) {}
ngOnInit(): void {
@@ -88,7 +88,7 @@ export class ImportLastPassComponent implements OnInit, OnDestroy {
try {
const csvData = await this.lastPassDirectImportService.handleImport(
this.formGroup.controls.email.value,
this.formGroup.controls.includeSharedFolders.value
this.formGroup.controls.includeSharedFolders.value,
);
this.csvDataLoaded.emit(csvData);
return null;

View File

@@ -41,7 +41,7 @@ export class LastPassDirectImportService {
private passwordGenerationService: PasswordGenerationServiceAbstraction,
private broadcasterService: BroadcasterService,
private ngZone: NgZone,
private dialogService: DialogService
private dialogService: DialogService,
) {
this.vault = new Vault(this.cryptoFunctionService, this.tokenService);
@@ -73,7 +73,7 @@ export class LastPassDirectImportService {
const csvData = await this.handleFederatedImport(
oidc.oidcCode,
oidc.oidcState,
includeSharedFolders
includeSharedFolders,
);
return csvData;
}
@@ -155,7 +155,7 @@ export class LastPassDirectImportService {
private async handleStandardImport(
email: string,
password: string,
includeSharedFolders: boolean
includeSharedFolders: boolean,
): Promise<string> {
const clientInfo = await this.createClientInfo(email);
await this.vault.open(email, password, clientInfo, this.lastPassDirectImportUIService, {
@@ -168,10 +168,10 @@ export class LastPassDirectImportService {
private async handleFederatedImport(
oidcCode: string,
oidcState: string,
includeSharedFolders: boolean
includeSharedFolders: boolean,
): Promise<string> {
const response = await this.oidcClient.processSigninResponse(
this.getOidcRedirectUrlWithParams(oidcCode, oidcState)
this.getOidcRedirectUrlWithParams(oidcCode, oidcState),
);
const userState = response.userState as any;

View File

@@ -16,7 +16,7 @@ export class AviraCsvImporter extends BaseImporter implements Importer {
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(
value.name,
this.getValueOrDefault(this.nameFromUrl(value.website), "--")
this.getValueOrDefault(this.nameFromUrl(value.website), "--"),
);
cipher.login.uris = this.makeUriArray(value.website);
cipher.login.password = this.getValueOrDefault(value.password);

View File

@@ -146,7 +146,7 @@ export abstract class BaseImporter {
const parseOptions: papa.ParseConfig<string> = Object.assign(
{ header: header },
this.parseCsvOptions,
options
options,
);
data = this.splitNewLine(data).join("\n").trim();
const result = papa.parse(data, parseOptions);
@@ -321,7 +321,7 @@ export abstract class BaseImporter {
cipher: CipherView,
key: string,
value: string,
type: FieldType = FieldType.Text
type: FieldType = FieldType.Text,
) {
if (this.isNullOrWhitespace(value)) {
return;

View File

@@ -55,7 +55,7 @@ export class BitwardenCsvImporter extends BaseImporter implements Importer {
try {
cipher.reprompt = parseInt(
this.getValueOrDefault(value.reprompt, CipherRepromptType.None.toString()),
10
10,
);
} catch (e) {
// eslint-disable-next-line

View File

@@ -27,7 +27,7 @@ export class BitwardenJsonImporter extends BaseImporter implements Importer {
protected constructor(
protected cryptoService: CryptoService,
protected i18nService: I18nService,
protected cipherService: CipherService
protected cipherService: CipherService,
) {
super();
}
@@ -50,14 +50,14 @@ export class BitwardenJsonImporter extends BaseImporter implements Importer {
}
private async parseEncrypted(
results: BitwardenEncryptedIndividualJsonExport | BitwardenEncryptedOrgJsonExport
results: BitwardenEncryptedIndividualJsonExport | BitwardenEncryptedOrgJsonExport,
) {
if (results.encKeyValidation_DO_NOT_EDIT != null) {
const orgKey = await this.cryptoService.getOrgKey(this.organizationId);
const encKeyValidation = new EncString(results.encKeyValidation_DO_NOT_EDIT);
const encKeyValidationDecrypt = await this.cryptoService.decryptToUtf8(
encKeyValidation,
orgKey
orgKey,
);
if (encKeyValidationDecrypt === null) {
this.result.success = false;
@@ -99,7 +99,7 @@ export class BitwardenJsonImporter extends BaseImporter implements Importer {
}
const view = await cipher.decrypt(
await this.cipherService.getKeyForCipherKeyDecryption(cipher)
await this.cipherService.getKeyForCipherKeyDecryption(cipher),
);
this.cleanupCipher(view);
this.result.ciphers.push(view);
@@ -109,7 +109,7 @@ export class BitwardenJsonImporter extends BaseImporter implements Importer {
}
private async parseDecrypted(
results: BitwardenUnEncryptedIndividualJsonExport | BitwardenUnEncryptedOrgJsonExport
results: BitwardenUnEncryptedIndividualJsonExport | BitwardenUnEncryptedOrgJsonExport,
) {
const groupingsMap = this.organization
? await this.parseCollections(results as BitwardenUnEncryptedOrgJsonExport)
@@ -151,7 +151,7 @@ export class BitwardenJsonImporter extends BaseImporter implements Importer {
}
private async parseFolders(
data: BitwardenUnEncryptedIndividualJsonExport | BitwardenEncryptedIndividualJsonExport
data: BitwardenUnEncryptedIndividualJsonExport | BitwardenEncryptedIndividualJsonExport,
): Promise<Map<string, number>> | null {
if (data.folders == null) {
return null;
@@ -179,7 +179,7 @@ export class BitwardenJsonImporter extends BaseImporter implements Importer {
}
private async parseCollections(
data: BitwardenUnEncryptedOrgJsonExport | BitwardenEncryptedOrgJsonExport
data: BitwardenUnEncryptedOrgJsonExport | BitwardenEncryptedOrgJsonExport,
): Promise<Map<string, number>> | null {
if (data.collections == null) {
return null;

View File

@@ -19,7 +19,7 @@ export class BitwardenPasswordProtectedImporter extends BitwardenJsonImporter im
cryptoService: CryptoService,
i18nService: I18nService,
cipherService: CipherService,
private promptForPassword_callback: () => Promise<string>
private promptForPassword_callback: () => Promise<string>,
) {
super(cryptoService, i18nService, cipherService);
}
@@ -63,7 +63,7 @@ export class BitwardenPasswordProtectedImporter extends BitwardenJsonImporter im
private async checkPassword(
jdoc: BitwardenPasswordProtectedFileFormat,
password: string
password: string,
): Promise<boolean> {
if (this.isNullOrWhitespace(password)) {
return false;
@@ -73,14 +73,14 @@ export class BitwardenPasswordProtectedImporter extends BitwardenJsonImporter im
password,
jdoc.salt,
jdoc.kdfType,
new KdfConfig(jdoc.kdfIterations, jdoc.kdfMemory, jdoc.kdfParallelism)
new KdfConfig(jdoc.kdfIterations, jdoc.kdfMemory, jdoc.kdfParallelism),
);
const encKeyValidation = new EncString(jdoc.encKeyValidation_DO_NOT_EDIT);
const encKeyValidationDecrypt = await this.cryptoService.decryptToUtf8(
encKeyValidation,
this.key
this.key,
);
if (encKeyValidationDecrypt === null) {
return false;

View File

@@ -19,7 +19,7 @@ export class BlurCsvImporter extends BaseImporter implements Importer {
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(
value.label,
this.getValueOrDefault(this.nameFromUrl(value.domain), "--")
this.getValueOrDefault(this.nameFromUrl(value.domain), "--"),
);
cipher.login.uris = this.makeUriArray(value.domain);
cipher.login.password = this.getValueOrDefault(value.password);

View File

@@ -67,7 +67,7 @@ export class DashlaneJsonImporter extends BaseImporter implements Importer {
cipher.login.username = this.getValueOrDefault(
credential.login,
this.getValueOrDefault(credential.secondaryLogin)
this.getValueOrDefault(credential.secondaryLogin),
);
if (this.isNullOrWhitespace(cipher.login.username)) {
cipher.login.username = this.getValueOrDefault(credential.email);

View File

@@ -102,7 +102,7 @@ export class EnpassJsonImporter extends BaseImporter implements Importer {
cipher,
field.label,
field.value,
field.sensitive === 1 ? FieldType.Hidden : FieldType.Text
field.sensitive === 1 ? FieldType.Hidden : FieldType.Text,
);
}
});
@@ -134,7 +134,7 @@ export class EnpassJsonImporter extends BaseImporter implements Importer {
cipher,
field.label,
field.value,
field.sensitive === 1 ? FieldType.Hidden : FieldType.Text
field.sensitive === 1 ? FieldType.Hidden : FieldType.Text,
);
}
} else {
@@ -142,7 +142,7 @@ export class EnpassJsonImporter extends BaseImporter implements Importer {
cipher,
field.label,
field.value,
field.sensitive === 1 ? FieldType.Hidden : FieldType.Text
field.sensitive === 1 ? FieldType.Hidden : FieldType.Text,
);
}
});
@@ -157,7 +157,7 @@ export class EnpassJsonImporter extends BaseImporter implements Importer {
cipher,
field.label,
field.value,
field.sensitive === 1 ? FieldType.Hidden : FieldType.Text
field.sensitive === 1 ? FieldType.Hidden : FieldType.Text,
);
});
}
@@ -185,7 +185,7 @@ export class EnpassJsonImporter extends BaseImporter implements Importer {
private flattenFolderTree(
titlePrefix: string,
tree: EnpassFolderTreeItem[],
map: Map<string, string>
map: Map<string, string>,
) {
if (tree == null) {
return;

View File

@@ -4,7 +4,7 @@ export class OobResult {
constructor(
public waitForOutOfBand: boolean,
public passcode: string,
public rememberMe: boolean
public rememberMe: boolean,
) {}
waitForApproval(rememberMe: boolean) {

View File

@@ -1,5 +1,8 @@
export class OtpResult {
static cancel = new OtpResult("cancel", false);
constructor(public passcode: string, public rememberMe: boolean) {}
constructor(
public passcode: string,
public rememberMe: boolean,
) {}
}

View File

@@ -31,14 +31,17 @@ const KnownOtpMethods = new Map<string, OtpMethod>([
]);
export class Client {
constructor(private parser: Parser, private cryptoUtils: CryptoUtils) {}
constructor(
private parser: Parser,
private cryptoUtils: CryptoUtils,
) {}
async openVault(
username: string,
password: string,
clientInfo: ClientInfo,
ui: Ui,
options: ParserOptions
options: ParserOptions,
): Promise<Account[]> {
const lowercaseUsername = username.toLowerCase();
const [session, rest] = await this.login(lowercaseUsername, password, clientInfo, ui);
@@ -47,7 +50,7 @@ export class Client {
const key = await this.cryptoUtils.deriveKey(
lowercaseUsername,
password,
session.keyIterationCount
session.keyIterationCount,
);
let privateKey: Uint8Array = null;
@@ -65,7 +68,7 @@ export class Client {
blob: Uint8Array,
encryptionKey: Uint8Array,
privateKey: Uint8Array,
options: ParserOptions
options: ParserOptions,
): Promise<Account[]> {
const reader = new BinaryReader(blob);
const chunks = this.parser.extractChunks(reader);
@@ -79,7 +82,7 @@ export class Client {
chunks: Chunk[],
encryptionKey: Uint8Array,
privateKey: Uint8Array,
options: ParserOptions
options: ParserOptions,
): Promise<Account[]> {
const accounts = new Array<Account>();
let folder: SharedFolder = null;
@@ -109,7 +112,7 @@ export class Client {
username: string,
password: string,
clientInfo: ClientInfo,
ui: Ui
ui: Ui,
): Promise<[Session, RestClient]> {
const rest = new RestClient();
rest.baseUrl = "https://lastpass.com";
@@ -142,7 +145,7 @@ export class Client {
keyIterationCount,
new Map<string, any>(),
clientInfo,
rest
rest,
);
session = this.extractSessionFromLoginResponse(response, keyIterationCount, clientInfo);
@@ -192,7 +195,7 @@ export class Client {
optMethod,
clientInfo,
ui,
rest
rest,
);
} else if (cause === "outofbandrequired") {
// 3.2. Some out-of-bound authentication is enabled. This does not require any
@@ -204,7 +207,7 @@ export class Client {
this.getAllErrorAttributes(response),
clientInfo,
ui,
rest
rest,
);
}
@@ -224,7 +227,7 @@ export class Client {
method: OtpMethod,
clientInfo: ClientInfo,
ui: Ui,
rest: RestClient
rest: RestClient,
): Promise<Session> {
let passcode: OtpResult = null;
switch (method) {
@@ -251,7 +254,7 @@ export class Client {
keyIterationCount,
new Map<string, string>([["otp", passcode.passcode]]),
clientInfo,
rest
rest,
);
const session = this.extractSessionFromLoginResponse(response, keyIterationCount, clientInfo);
@@ -271,7 +274,7 @@ export class Client {
parameters: Map<string, string>,
clientInfo: ClientInfo,
ui: Ui,
rest: RestClient
rest: RestClient,
): Promise<Session> {
// In case of the OOB auth the server doesn't respond instantly. This works more like a long poll.
// The server times out in about 10 seconds so there's no need to back off.
@@ -282,7 +285,7 @@ export class Client {
keyIterationCount,
extraParameters,
clientInfo,
rest
rest,
);
const session = this.extractSessionFromLoginResponse(response, keyIterationCount, clientInfo);
@@ -335,7 +338,7 @@ export class Client {
username: string,
parameters: Map<string, string>,
ui: Ui,
rest: RestClient
rest: RestClient,
): Promise<OobResult> {
const method = parameters.get("outofbandtype");
if (method == null) {
@@ -357,7 +360,7 @@ export class Client {
username: string,
parameters: Map<string, string>,
ui: Ui,
rest: RestClient
rest: RestClient,
): Promise<OobResult> {
return parameters.get("preferduowebsdk") == "1"
? this.approveDuoWebSdk(username, parameters, ui, rest)
@@ -368,7 +371,7 @@ export class Client {
username: string,
parameters: Map<string, string>,
ui: Ui,
rest: RestClient
rest: RestClient,
): Promise<OobResult> {
// TODO: implement this instead of calling `approveDuo`
return ui.approveDuo();
@@ -384,7 +387,7 @@ export class Client {
"trust.php",
parameters,
null,
this.getSessionCookies(session)
this.getSessionCookies(session),
);
if (response.status == HttpStatusCode.Ok) {
return;
@@ -401,7 +404,7 @@ export class Client {
"logout.php",
parameters,
null,
this.getSessionCookies(session)
this.getSessionCookies(session),
);
if (response.status == HttpStatusCode.Ok) {
return;
@@ -460,7 +463,7 @@ export class Client {
private extractSessionFromLoginResponse(
response: Document,
keyIterationCount: number,
clientInfo: ClientInfo
clientInfo: ClientInfo,
): Session {
const ok = response.querySelector("response > ok");
if (ok == null) {
@@ -494,7 +497,7 @@ export class Client {
keyIterationCount: number,
extraParameters: Map<string, any>,
clientInfo: ClientInfo,
rest: RestClient
rest: RestClient,
) {
const hash = await this.cryptoUtils.deriveKeyHash(username, password, keyIterationCount);
@@ -526,7 +529,7 @@ export class Client {
private makeError(response: Response) {
// TODO: error parsing
throw new Error(
"HTTP request to " + response.url + " failed with status " + response.status + "."
"HTTP request to " + response.url + " failed with status " + response.status + ".",
);
}

View File

@@ -19,7 +19,7 @@ export class CryptoUtils {
if (iterationCount == 1) {
return await this.cryptoFunctionService.hash(
Utils.fromBufferToHex(key.buffer) + password,
"sha256"
"sha256",
);
}
return await this.cryptoFunctionService.pbkdf2(key, password, "sha256", 1);
@@ -39,7 +39,7 @@ export class CryptoUtils {
async decryptAes256PlainWithDefault(
data: Uint8Array,
encryptionKey: Uint8Array,
defaultValue: string
defaultValue: string,
) {
try {
return this.decryptAes256Plain(data, encryptionKey);
@@ -51,7 +51,7 @@ export class CryptoUtils {
async decryptAes256Base64WithDefault(
data: Uint8Array,
encryptionKey: Uint8Array,
defaultValue: string
defaultValue: string,
) {
try {
return this.decryptAes256Base64(data, encryptionKey);
@@ -86,7 +86,7 @@ export class CryptoUtils {
data: Uint8Array,
encryptionKey: Uint8Array,
mode: "cbc" | "ecb",
iv: Uint8Array = new Uint8Array(16)
iv: Uint8Array = new Uint8Array(16),
): Promise<string> {
if (data.length === 0) {
return "";

View File

@@ -16,7 +16,7 @@ const AllowedSecureNoteTypes = new Set<string>([
export class Parser {
constructor(
private cryptoFunctionService: CryptoFunctionService,
private cryptoUtils: CryptoUtils
private cryptoUtils: CryptoUtils,
) {}
/*
@@ -30,7 +30,7 @@ export class Parser {
chunk: Chunk,
encryptionKey: Uint8Array,
folder: SharedFolder,
options: ParserOptions
options: ParserOptions,
): Promise<Account> {
const placeholder = "decryption failed";
const reader = new BinaryReader(chunk.payload);
@@ -43,19 +43,19 @@ export class Parser {
const name = await this.cryptoUtils.decryptAes256PlainWithDefault(
this.readItem(reader),
encryptionKey,
placeholder
placeholder,
);
// 2: group
const group = await this.cryptoUtils.decryptAes256PlainWithDefault(
this.readItem(reader),
encryptionKey,
placeholder
placeholder,
);
// 3: url
let url = Utils.fromBufferToUtf8(
Utils.fromHexToArray(Utils.fromBufferToUtf8(this.readItem(reader)))
Utils.fromHexToArray(Utils.fromBufferToUtf8(this.readItem(reader))),
);
// Ignore "group" accounts. They have no credentials.
@@ -67,7 +67,7 @@ export class Parser {
const notes = await this.cryptoUtils.decryptAes256PlainWithDefault(
this.readItem(reader),
encryptionKey,
placeholder
placeholder,
);
// 5: fav (is favorite)
@@ -80,14 +80,14 @@ export class Parser {
let username = await this.cryptoUtils.decryptAes256PlainWithDefault(
this.readItem(reader),
encryptionKey,
placeholder
placeholder,
);
// 8: password
let password = await this.cryptoUtils.decryptAes256PlainWithDefault(
this.readItem(reader),
encryptionKey,
placeholder
placeholder,
);
// 9: pwprotect (?)
@@ -215,7 +215,7 @@ export class Parser {
const totp = await this.cryptoUtils.decryptAes256PlainWithDefault(
this.readItem(reader),
encryptionKey,
placeholder
placeholder,
);
// 3 more left. Don't even bother skipping them.
@@ -244,7 +244,7 @@ export class Parser {
async parseShar(
chunk: Chunk,
encryptionKey: Uint8Array,
rsaKey: Uint8Array
rsaKey: Uint8Array,
): Promise<SharedFolder> {
const reader = new BinaryReader(chunk.payload);
@@ -257,7 +257,7 @@ export class Parser {
const decFolderKey = await this.cryptoFunctionService.rsaDecrypt(
rsaEncryptedFolderKey,
rsaKey,
"sha1"
"sha1",
);
const key = Utils.fromHexToArray(Utils.fromBufferToUtf8(decFolderKey));
@@ -277,7 +277,7 @@ export class Parser {
Utils.fromHexToArray(encryptedPrivateKey),
encryptionKey,
"cbc",
encryptionKey.subarray(0, 16)
encryptionKey.subarray(0, 16),
);
const header = "LastPassPrivateKey<";

View File

@@ -5,7 +5,7 @@ export class RestClient {
async get(
endpoint: string,
headers: Map<string, string> = null,
cookies: Map<string, string> = null
cookies: Map<string, string> = null,
): Promise<Response> {
const requestInit: RequestInit = {
method: "GET",
@@ -21,7 +21,7 @@ export class RestClient {
endpoint: string,
parameters: Map<string, any> = null,
headers: Map<string, string> = null,
cookies: Map<string, string> = null
cookies: Map<string, string> = null,
): Promise<Response> {
const setBody = (requestInit: RequestInit, headerMap: Map<string, string>) => {
if (parameters != null && parameters.size > 0) {
@@ -39,7 +39,7 @@ export class RestClient {
endpoint: string,
body: any,
headers: Map<string, string> = null,
cookies: Map<string, string> = null
cookies: Map<string, string> = null,
): Promise<Response> {
const setBody = (requestInit: RequestInit, headerMap: Map<string, string>) => {
if (body != null) {
@@ -54,7 +54,7 @@ export class RestClient {
endpoint: string,
setBody: (requestInit: RequestInit, headers: Map<string, string>) => void,
headers: Map<string, string> = null,
cookies: Map<string, string> = null
cookies: Map<string, string> = null,
) {
const requestInit: RequestInit = {
method: "POST",
@@ -73,7 +73,7 @@ export class RestClient {
private setHeaders(
requestInit: RequestInit,
headers: Map<string, string> = null,
cookies: Map<string, string> = null
cookies: Map<string, string> = null,
) {
const requestHeaders = new Headers();
let setHeaders = false;

View File

@@ -26,7 +26,7 @@ export class Vault {
constructor(
private cryptoFunctionService: CryptoFunctionService,
private tokenService: TokenService
private tokenService: TokenService,
) {
this.cryptoUtils = new CryptoUtils(cryptoFunctionService);
const parser = new Parser(cryptoFunctionService, this.cryptoUtils);
@@ -38,7 +38,7 @@ export class Vault {
password: string,
clientInfo: ClientInfo,
ui: Ui,
parserOptions: ParserOptions = ParserOptions.default
parserOptions: ParserOptions = ParserOptions.default,
): Promise<void> {
this.accounts = await this.client.openVault(username, password, clientInfo, ui, parserOptions);
}
@@ -47,7 +47,7 @@ export class Vault {
federatedUser: FederatedUserContext,
clientInfo: ClientInfo,
ui: Ui,
parserOptions: ParserOptions = ParserOptions.default
parserOptions: ParserOptions = ParserOptions.default,
): Promise<void> {
if (federatedUser == null) {
throw new Error("Federated user context is not set.");
@@ -56,7 +56,7 @@ export class Vault {
const k2 = await this.getK2(federatedUser);
const hiddenPasswordArr = await this.cryptoFunctionService.hash(
this.cryptoUtils.ExclusiveOr(k1, k2),
"sha256"
"sha256",
);
const hiddenPassword = Utils.fromBufferToB64(hiddenPasswordArr);
await this.open(federatedUser.username, hiddenPassword, clientInfo, ui, parserOptions);
@@ -138,7 +138,7 @@ export class Vault {
rest.baseUrl = "https://graph.microsoft.com";
const response = await rest.get(
"v1.0/me?$select=id,displayName,mail&$expand=extensions",
new Map([["Authorization", "Bearer " + federatedUser.accessToken]])
new Map([["Authorization", "Bearer " + federatedUser.accessToken]]),
);
if (response.status === HttpStatusCode.Ok) {
const json = await response.json();
@@ -164,7 +164,7 @@ export class Vault {
"&q=name%20%3D%20%27k1.lp%27" +
"&spaces=appDataFolder" +
"&fields=nextPageToken%2C%20files(id%2C%20name)",
accessTokenAuthHeader
accessTokenAuthHeader,
);
if (response.status === HttpStatusCode.Ok) {
const json = await response.json();
@@ -174,7 +174,7 @@ export class Vault {
rest.baseUrl = "https://www.googleapis.com";
const response = await rest.get(
"drive/v3/files/" + files[0].id + "?alt=media",
accessTokenAuthHeader
accessTokenAuthHeader,
);
if (response.status === HttpStatusCode.Ok) {
const k1 = await response.text();

View File

@@ -11,10 +11,10 @@ import { Importer } from "./importer";
const mappedBaseColumns = ["nickname", "additionalInfo"];
const _mappedUserAccountColumns = new Set(
mappedBaseColumns.concat(["url", "username", "password", "twofaSecret"])
mappedBaseColumns.concat(["url", "username", "password", "twofaSecret"]),
);
const _mappedCreditCardColumns = new Set(
mappedBaseColumns.concat(["cardNumber", "cardName", "exp_month", "exp_year", "cvv"])
mappedBaseColumns.concat(["cardNumber", "cardName", "exp_month", "exp_year", "cvv"]),
);
const _mappedIdentityColumns = new Set(
@@ -29,7 +29,7 @@ const _mappedIdentityColumns = new Set(
"city",
"country",
"zipCode",
])
]),
);
const _mappedIdCardColumns = new Set(mappedBaseColumns.concat(["idName", "idNumber", "idCountry"]));

View File

@@ -2,7 +2,11 @@ import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
export class CipherImportContext {
lowerProperty: string;
constructor(public importRecord: any, public property: string, public cipher: CipherView) {
constructor(
public importRecord: any,
public property: string,
public cipher: CipherView,
) {
this.lowerProperty = property.toLowerCase();
}
}

View File

@@ -161,7 +161,7 @@ export class OnePassword1PifImporter extends BaseImporter implements Importer {
cipher: CipherView,
designationKey: string,
valueKey: string,
nameKey: string
nameKey: string,
) {
fields.forEach((field: any) => {
if (field[valueKey] == null || field[valueKey].toString().trim() === "") {

View File

@@ -451,7 +451,7 @@ export class OnePassword1PuxImporter extends BaseImporter implements Importer {
field: FieldsEntity,
fieldValue: string,
cipher: CipherView,
valueKey: string
valueKey: string,
): boolean {
if (this.isNullOrWhitespace(cipher.identity.firstName) && field.id === "firstname") {
cipher.identity.firstName = fieldValue;

View File

@@ -189,7 +189,7 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
context.lowerProperty === "modified date"
) {
const readableDate = new Date(
parseInt(context.importRecord[context.property], 10) * 1000
parseInt(context.importRecord[context.property], 10) * 1000,
).toUTCString();
this.processKvp(context.cipher, "1Password " + context.property, readableDate);
return null;
@@ -203,7 +203,7 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
context.cipher,
context.property,
context.importRecord[context.property],
FieldType.Hidden
FieldType.Hidden,
);
} else {
this.processKvp(context.cipher, context.property, context.importRecord[context.property]);
@@ -331,7 +331,7 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
) {
context.cipher.card.expMonth = (context.importRecord[context.property] as string).substr(
0,
2
2,
);
if (context.cipher.card.expMonth[0] === "0") {
context.cipher.card.expMonth = context.cipher.card.expMonth.substr(1, 1);

View File

@@ -56,7 +56,7 @@ export class ProtonPassJsonImporter extends BaseImporter implements Importer {
cipher,
extraField.fieldName,
extraField.type == "totp" ? extraField.data.totpUri : extraField.data.content,
extraField.type == "text" ? FieldType.Text : FieldType.Hidden
extraField.type == "text" ? FieldType.Text : FieldType.Hidden,
);
}
break;

View File

@@ -131,7 +131,7 @@ export class PsonoJsonImporter extends BaseImporter implements Importer {
cipher,
"website_password_auto_submit",
entry.website_password_auto_submit?.toString(),
FieldType.Boolean
FieldType.Boolean,
);
this.processKvp(cipher, "website_password_url_filter", entry.website_password_url_filter);
@@ -260,7 +260,7 @@ export class PsonoJsonImporter extends BaseImporter implements Importer {
cipher,
"mail_gpg_own_key_private",
entry.mail_gpg_own_key_private,
FieldType.Hidden
FieldType.Hidden,
);
this.importUnmappedFields(cipher, entry, this.GPG_mappedValues);
@@ -269,7 +269,7 @@ export class PsonoJsonImporter extends BaseImporter implements Importer {
private importUnmappedFields(
cipher: CipherView,
entry: PsonoItemTypes,
mappedValues: Set<string>
mappedValues: Set<string>,
) {
const unmappedFields = Object.keys(entry).filter((x) => !mappedValues.has(x));
unmappedFields.forEach((key) => {

View File

@@ -31,7 +31,7 @@ export class StickyPasswordXmlImporter extends BaseImporter implements Importer
"root > Database > Accounts > Account > " +
'LoginLinks > Login[SourceLoginID="' +
accountId +
'"]'
'"]',
);
if (accountLogin != null) {
const account = accountLogin.parentElement.parentElement;

View File

@@ -27,10 +27,10 @@ export class ZohoVaultCsvImporter extends BaseImporter implements Importer {
cipher.notes = this.getValueOrDefault(value.Notes);
cipher.name = this.getValueOrDefault(
value["Password Name"],
this.getValueOrDefault(value["Secret Name"], "--")
this.getValueOrDefault(value["Secret Name"], "--"),
);
cipher.login.uris = this.makeUriArray(
this.getValueOrDefault(value["Password URL"], this.getValueOrDefault(value["Secret URL"]))
this.getValueOrDefault(value["Password URL"], this.getValueOrDefault(value["Secret URL"])),
);
this.parseData(cipher, value.SecretData);
this.parseData(cipher, value.CustomData);

View File

@@ -5,6 +5,6 @@ export abstract class ImportApiServiceAbstraction {
postImportCiphers: (request: ImportCiphersRequest) => Promise<any>;
postImportOrganizationCiphers: (
organizationId: string,
request: ImportOrganizationCiphersRequest
request: ImportOrganizationCiphersRequest,
) => Promise<any>;
}

View File

@@ -13,14 +13,14 @@ export class ImportApiService implements ImportApiServiceAbstraction {
async postImportOrganizationCiphers(
organizationId: string,
request: ImportOrganizationCiphersRequest
request: ImportOrganizationCiphersRequest,
): Promise<any> {
return await this.apiService.send(
"POST",
"/ciphers/import-organization?organizationId=" + organizationId,
request,
true,
false
false,
);
}
}

View File

@@ -11,11 +11,11 @@ export abstract class ImportServiceAbstraction {
fileContents: string,
organizationId?: string,
selectedImportTarget?: string,
canAccessImportExport?: boolean
canAccessImportExport?: boolean,
) => Promise<ImportResult>;
getImporter: (
format: ImportType | "bitwardenpasswordprotected",
promptForPassword_callback: () => Promise<string>,
organizationId: string
organizationId: string,
) => Importer;
}

View File

@@ -39,7 +39,7 @@ describe("ImportService", () => {
importApiService,
i18nService,
collectionService,
cryptoService
cryptoService,
);
});
@@ -56,7 +56,7 @@ describe("ImportService", () => {
importer = importService.getImporter(
"bitwardenpasswordprotected",
promptForPassword_callback,
organizationId
organizationId,
);
});
@@ -96,7 +96,7 @@ describe("ImportService", () => {
it("passing importTarget adds it to folders", async () => {
folderService.getAllDecryptedFromState.mockReturnValue(
Promise.resolve([mockImportTargetFolder])
Promise.resolve([mockImportTargetFolder]),
);
await importService["setImportTarget"](importResult, null, "myImportTarget");

View File

@@ -99,7 +99,7 @@ export class ImportService implements ImportServiceAbstraction {
private importApiService: ImportApiServiceAbstraction,
private i18nService: I18nService,
private collectionService: CollectionService,
private cryptoService: CryptoService
private cryptoService: CryptoService,
) {}
getImportOptions(): ImportOption[] {
@@ -111,7 +111,7 @@ export class ImportService implements ImportServiceAbstraction {
fileContents: string,
organizationId: string = null,
selectedImportTarget: string = null,
canAccessImportExport: boolean
canAccessImportExport: boolean,
): Promise<ImportResult> {
let importResult: ImportResult;
try {
@@ -153,7 +153,7 @@ export class ImportService implements ImportServiceAbstraction {
!canAccessImportExport
) {
const hasUnassignedCollections = importResult.ciphers.some(
(c) => !Array.isArray(c.collectionIds) || c.collectionIds.length == 0
(c) => !Array.isArray(c.collectionIds) || c.collectionIds.length == 0,
);
if (hasUnassignedCollections) {
throw new Error(this.i18nService.t("importUnassignedItemsError"));
@@ -177,7 +177,7 @@ export class ImportService implements ImportServiceAbstraction {
getImporter(
format: ImportType | "bitwardenpasswordprotected",
promptForPassword_callback: () => Promise<string>,
organizationId: string = null
organizationId: string = null,
): Importer {
if (promptForPassword_callback == null) {
return null;
@@ -193,7 +193,7 @@ export class ImportService implements ImportServiceAbstraction {
private getImporterInstance(
format: ImportType | "bitwardenpasswordprotected",
promptForPassword_callback: () => Promise<string>
promptForPassword_callback: () => Promise<string>,
) {
if (format == null) {
return null;
@@ -208,7 +208,7 @@ export class ImportService implements ImportServiceAbstraction {
this.cryptoService,
this.i18nService,
this.cipherService,
promptForPassword_callback
promptForPassword_callback,
);
case "lastpasscsv":
case "passboltcsv":
@@ -346,7 +346,7 @@ export class ImportService implements ImportServiceAbstraction {
}
if (importResult.folderRelationships != null) {
importResult.folderRelationships.forEach((r) =>
request.folderRelationships.push(new KvpRequest(r[0], r[1]))
request.folderRelationships.push(new KvpRequest(r[0], r[1])),
);
}
return await this.importApiService.postImportCiphers(request);
@@ -368,7 +368,7 @@ export class ImportService implements ImportServiceAbstraction {
}
if (importResult.collectionRelationships != null) {
importResult.collectionRelationships.forEach((r) =>
request.collectionRelationships.push(new KvpRequest(r[0], r[1]))
request.collectionRelationships.push(new KvpRequest(r[0], r[1])),
);
}
return await this.importApiService.postImportOrganizationCiphers(organizationId, request);
@@ -429,7 +429,7 @@ export class ImportService implements ImportServiceAbstraction {
private async setImportTarget(
importResult: ImportResult,
organizationId: string,
importTarget: string
importTarget: string,
) {
if (Utils.isNullOrWhitespace(importTarget)) {
return;