1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 18:23:31 +00:00

[PM-2899] Implement ProtonPass json importer (#5766)

* Implement ProtonPass json importer

* Add protonpass-importer json type definition

* Fix alphabetical order in importer imports

* Add importer error message for encrypted protonpass imports

* Add i18n to protonpass importer

* Add protonpass (zip) importer

* Fix protonpass importer

* Add unit tests for protonpass importer

* Make protonpass importer not discard totp codes

* Merge protonpass json & zip importers

* Add protonpass creditcard import & fix note import

* Fix protonpass zip import not recognizing zip files on windows/chrome

* Make protonpass importer use vault types

* Make protonpass importer treat vaults as folders

* Make protonpass importer treat folders as collections for organizations

Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>

* Add types to protonpass test data

* Fix protonpass importer's moveFoldersToCollections

* Add tests for folders/collections

* Remove unecessary type cast in protonpass importer

* Remove unecessary type annotations in protonpass importer

* Add assertion for credit card cvv in protonpass importer

* Handle trashed items in protonpass importer

* Fix setting expiry month on credit cards

* Fix wrong folder-assignment

Only the first item of a "vault" was getting assigned to a folder

Extend unit tests to verify behaviour

---------

Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
Co-authored-by: Daniel James Smith <djsmith@web.de>
This commit is contained in:
Bernd Schoolmann
2023-08-16 16:17:03 +02:00
committed by GitHub
parent a4fcd62c99
commit e016ed001e
12 changed files with 498 additions and 7 deletions

View File

@@ -46,5 +46,8 @@
},
"ssoKeyConnectorError": {
"message": "Key Connector error: make sure Key Connector is available and working correctly."
},
"unsupportedEncryptedImport": {
"message": "Importing encrypted files is currently not supported."
}
}

View File

@@ -67,7 +67,9 @@ export class ImportCommand {
try {
let contents;
if (format === "1password1pux") {
contents = await CliUtils.extract1PuxContent(filepath);
contents = await CliUtils.extractZipContent(filepath, "export.data");
} else if (format === "protonpass" && filepath.endsWith(".zip")) {
contents = await CliUtils.extractZipContent(filepath, "Proton Pass/data.json");
} else {
contents = await CliUtils.readFile(filepath);
}

View File

@@ -46,7 +46,7 @@ export class CliUtils {
});
}
static extract1PuxContent(input: string): Promise<string> {
static extractZipContent(input: string, filepath: string): Promise<string> {
return new Promise<string>((resolve, reject) => {
let p: string = null;
if (input != null && input !== "") {
@@ -65,7 +65,7 @@ export class CliUtils {
}
JSZip.loadAsync(data).then(
(zip) => {
resolve(zip.file("export.data").async("string"));
resolve(zip.file(filepath).async("string"));
},
(reason) => {
reject(reason);
@@ -74,6 +74,7 @@ export class CliUtils {
});
});
}
/**
* Save the given data to a file and determine the target file if necessary.
* If output is non-empty, it is used as target filename. Otherwise the target filename is

View File

@@ -341,6 +341,10 @@
Log in to "https://vault.passky.org" &rarr; "Import & Export" &rarr; "Export" in the Passky
section. ("Backup" is unsupported as it is encrypted).
</ng-container>
<ng-container *ngIf="format === 'protonpass'">
In the ProtonPass browser extension, go to Settings > Export. Export without PGP encryption
and save the zip file.
</ng-container>
</bit-callout>
<bit-form-field>
<bit-label>{{ "selectImportFile" | i18n }}</bit-label>

View File

@@ -326,7 +326,15 @@ export class ImportComponent implements OnInit, OnDestroy {
private getFileContents(file: File): Promise<string> {
if (this.format === "1password1pux") {
return this.extract1PuxContent(file);
return this.extractZipContent(file, "export.data");
}
if (
this.format === "protonpass" &&
(file.type === "application/zip" ||
file.type == "application/x-zip-compressed" ||
file.name.endsWith(".zip"))
) {
return this.extractZipContent(file, "Proton Pass/data.json");
}
return new Promise((resolve, reject) => {
@@ -353,11 +361,11 @@ export class ImportComponent implements OnInit, OnDestroy {
});
}
private extract1PuxContent(file: File): Promise<string> {
private extractZipContent(zipFile: File, contentFilePath: string): Promise<string> {
return new JSZip()
.loadAsync(file)
.loadAsync(zipFile)
.then((zip) => {
return zip.file("export.data").async("string");
return zip.file(contentFilePath).async("string");
})
.then(
function success(content) {