1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-27 17:18:04 +01:00

Add importing of 1passwords 1pux files (#440)

* Pull in jslib

* Install jszip

* Add method in utils to unzip and extract 1pux file

* Add importing/extracting of 1pux files to import command

* Update jslib

* Update package-lock.json
This commit is contained in:
Daniel James Smith 2022-03-03 15:32:49 +01:00 committed by GitHub
parent bc4bd664b6
commit caf6a1173b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 474 additions and 152 deletions

2
jslib

@ -1 +1 @@
Subproject commit e47eb5e74fd8ff5537149ca033fb395bb0f6295b
Subproject commit 4c408f05242bb0ae00c6c6b7330f1c07a92bdf13

598
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -106,6 +106,7 @@
"https-proxy-agent": "5.0.0",
"inquirer": "8.0.0",
"jsdom": "^16.5.3",
"jszip": "^3.7.1",
"koa": "^2.13.4",
"koa-bodyparser": "^4.3.0",
"koa-json": "^2.0.2",

View File

@ -61,7 +61,13 @@ export class ImportCommand {
}
try {
const contents = await CliUtils.readFile(filepath);
let contents;
if (format === "1password1pux") {
contents = await CliUtils.extract1PuxContent(filepath);
} else {
contents = await CliUtils.readFile(filepath);
}
if (contents === null || contents === "") {
return Response.badRequest("Import file was empty.");
}

View File

@ -3,6 +3,8 @@ import * as fs from "fs";
import * as inquirer from "inquirer";
import * as path from "path";
import * as JSZip from "jszip";
import { Response } from "jslib-node/cli/models/response";
import { MessageResponse } from "jslib-node/cli/models/response/messageResponse";
@ -48,6 +50,21 @@ export class CliUtils {
});
}
static extract1PuxContent(input: string): Promise<string> {
return new JSZip()
.loadAsync(input)
.then((zip) => {
return zip.file("export.data").async("string");
})
.then(
function success(content) {
return content;
},
function error(e) {
return "";
}
);
}
/**
* 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