mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 13:23:34 +00:00
[PM-10791] Set favorite on import from ProtonPass (#10480)
* Update import test data with new fields Add new fields to the types file * Set favorites when importing from ProtonPass --------- Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
a3d2bb60d1
commit
3ef1080754
@@ -116,4 +116,14 @@ describe("Protonpass Json Importer", () => {
|
|||||||
|
|
||||||
expect(ciphers.length).toBe(4);
|
expect(ciphers.length).toBe(4);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should set favorites", async () => {
|
||||||
|
const testDataJson = JSON.stringify(testData);
|
||||||
|
const result = await importer.parse(testDataJson);
|
||||||
|
|
||||||
|
const ciphers = result.ciphers;
|
||||||
|
expect(ciphers[0].favorite).toBe(true);
|
||||||
|
expect(ciphers[1].favorite).toBe(false);
|
||||||
|
expect(ciphers[2].favorite).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ProtonPassJsonFile } from "../../../src/importers/protonpass/types/protonpass-json-type";
|
import { ProtonPassJsonFile } from "../../../src/importers/protonpass/types/protonpass-json-type";
|
||||||
|
|
||||||
export const testData: ProtonPassJsonFile = {
|
export const testData: ProtonPassJsonFile = {
|
||||||
version: "1.3.1",
|
version: "1.21.2",
|
||||||
userId: "REDACTED_USER_ID",
|
userId: "REDACTED_USER_ID",
|
||||||
encrypted: false,
|
encrypted: false,
|
||||||
vaults: {
|
vaults: {
|
||||||
@@ -54,6 +54,7 @@ export const testData: ProtonPassJsonFile = {
|
|||||||
urls: ["https://example.com/", "https://example2.com/"],
|
urls: ["https://example.com/", "https://example2.com/"],
|
||||||
totpUri:
|
totpUri:
|
||||||
"otpauth://totp/Test%20Login%20-%20Personal%20Vault:Username?issuer=Test%20Login%20-%20Personal%20Vault&secret=TOTPCODE&algorithm=SHA1&digits=6&period=30",
|
"otpauth://totp/Test%20Login%20-%20Personal%20Vault:Username?issuer=Test%20Login%20-%20Personal%20Vault&secret=TOTPCODE&algorithm=SHA1&digits=6&period=30",
|
||||||
|
passkeys: [],
|
||||||
itemUsername: "Username",
|
itemUsername: "Username",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -62,6 +63,7 @@ export const testData: ProtonPassJsonFile = {
|
|||||||
contentFormatVersion: 1,
|
contentFormatVersion: 1,
|
||||||
createTime: 1689182868,
|
createTime: 1689182868,
|
||||||
modifyTime: 1689182868,
|
modifyTime: 1689182868,
|
||||||
|
pinned: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
itemId:
|
itemId:
|
||||||
@@ -83,6 +85,7 @@ export const testData: ProtonPassJsonFile = {
|
|||||||
contentFormatVersion: 1,
|
contentFormatVersion: 1,
|
||||||
createTime: 1689182908,
|
createTime: 1689182908,
|
||||||
modifyTime: 1689182908,
|
modifyTime: 1689182908,
|
||||||
|
pinned: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
itemId:
|
itemId:
|
||||||
@@ -111,6 +114,7 @@ export const testData: ProtonPassJsonFile = {
|
|||||||
contentFormatVersion: 1,
|
contentFormatVersion: 1,
|
||||||
createTime: 1691001643,
|
createTime: 1691001643,
|
||||||
modifyTime: 1691001643,
|
modifyTime: 1691001643,
|
||||||
|
pinned: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
itemId:
|
itemId:
|
||||||
@@ -132,6 +136,7 @@ export const testData: ProtonPassJsonFile = {
|
|||||||
contentFormatVersion: 1,
|
contentFormatVersion: 1,
|
||||||
createTime: 1689182908,
|
createTime: 1689182908,
|
||||||
modifyTime: 1689182908,
|
modifyTime: 1689182908,
|
||||||
|
pinned: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -161,6 +166,7 @@ export const testData: ProtonPassJsonFile = {
|
|||||||
password: "other vault password",
|
password: "other vault password",
|
||||||
urls: [],
|
urls: [],
|
||||||
totpUri: "JBSWY3DPEHPK3PXP",
|
totpUri: "JBSWY3DPEHPK3PXP",
|
||||||
|
passkeys: [],
|
||||||
itemUsername: "",
|
itemUsername: "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -169,6 +175,7 @@ export const testData: ProtonPassJsonFile = {
|
|||||||
contentFormatVersion: 1,
|
contentFormatVersion: 1,
|
||||||
createTime: 1689182949,
|
createTime: 1689182949,
|
||||||
modifyTime: 1689182949,
|
modifyTime: 1689182949,
|
||||||
|
pinned: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export class ProtonPassJsonImporter extends BaseImporter implements Importer {
|
|||||||
const cipher = this.initLoginCipher();
|
const cipher = this.initLoginCipher();
|
||||||
cipher.name = this.getValueOrDefault(item.data.metadata.name, "--");
|
cipher.name = this.getValueOrDefault(item.data.metadata.name, "--");
|
||||||
cipher.notes = this.getValueOrDefault(item.data.metadata.note);
|
cipher.notes = this.getValueOrDefault(item.data.metadata.note);
|
||||||
|
cipher.favorite = item.pinned;
|
||||||
|
|
||||||
switch (item.data.type) {
|
switch (item.data.type) {
|
||||||
case "login": {
|
case "login": {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export type ProtonPassItem = {
|
|||||||
contentFormatVersion: number;
|
contentFormatVersion: number;
|
||||||
createTime: number;
|
createTime: number;
|
||||||
modifyTime: number;
|
modifyTime: number;
|
||||||
|
pinned: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export enum ProtonPassItemState {
|
export enum ProtonPassItemState {
|
||||||
@@ -34,6 +35,7 @@ export enum ProtonPassItemState {
|
|||||||
export type ProtonPassItemData = {
|
export type ProtonPassItemData = {
|
||||||
metadata: ProtonPassItemMetadata;
|
metadata: ProtonPassItemMetadata;
|
||||||
extraFields: ProtonPassItemExtraField[];
|
extraFields: ProtonPassItemExtraField[];
|
||||||
|
platformSpecific?: any;
|
||||||
type: "login" | "alias" | "creditCard" | "note";
|
type: "login" | "alias" | "creditCard" | "note";
|
||||||
content: ProtonPassLoginItemContent | ProtonPassCreditCardItemContent;
|
content: ProtonPassLoginItemContent | ProtonPassCreditCardItemContent;
|
||||||
};
|
};
|
||||||
@@ -60,6 +62,7 @@ export type ProtonPassLoginItemContent = {
|
|||||||
password?: string;
|
password?: string;
|
||||||
urls?: string[];
|
urls?: string[];
|
||||||
totpUri?: string;
|
totpUri?: string;
|
||||||
|
passkeys: [];
|
||||||
itemUsername?: string;
|
itemUsername?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user