Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9,962 changes: 23 additions & 9,939 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ async function getTotp(text: string, silent = false) {
entryData[hash].algorithm = algorithm;
}
if (
(await EntryStorage.hasEncryptedEntry()) !==
// If the entries are encrypted and we aren't unlocked, error.
(await EntryStorage.hasEncryptionKey()) !==
encryption.getEncryptionStatus()
) {
!silent && chrome.tabs.sendMessage(id, { action: "errorenc" });
Expand Down
4 changes: 3 additions & 1 deletion src/components/Popup/DrivePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ export default Vue.extend({
},
async backupUpload() {
const drive = new Drive();
const response = await drive.upload(this.$store.state.encryption);
const response = await drive.upload(
this.$store.state.accounts.encryption
);
if (response === true) {
this.$store.commit("notification/alert", this.i18n.updateSuccess);
} else if (localStorage.driveRevoked === "true") {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Popup/DropboxPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default Vue.extend({
},
async backupUpload() {
const dbox = new Dropbox();
const response = await dbox.upload(this.$store.state.encryption);
const response = await dbox.upload(this.$store.state.accounts.encryption);
if (response === true) {
this.$store.commit("notification/alert", this.i18n.updateSuccess);
} else if (localStorage.dropboxRevoked === "true") {
Expand Down
4 changes: 3 additions & 1 deletion src/components/Popup/OneDrivePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ export default Vue.extend({
},
async backupUpload() {
const oneDrive = new OneDrive();
const response = await oneDrive.upload(this.$store.state.encryption);
const response = await oneDrive.upload(
this.$store.state.accounts.encryption
);
if (response === true) {
this.$store.commit("notification/alert", this.i18n.updateSuccess);
} else if (localStorage.oneDriveRevoked === "true") {
Expand Down
17 changes: 2 additions & 15 deletions src/models/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,21 +260,8 @@ export class EntryStorage {
}
}

static hasEncryptedEntry() {
return new Promise((resolve: (value: boolean) => void) => {
BrowserStorage.get((_data: { [hash: string]: OTPStorage }) => {
for (const hash of Object.keys(_data)) {
if (!this.isValidEntry(_data, hash)) {
continue;
}
if (_data[hash].encrypted) {
return resolve(true);
}
}
return resolve(false);
});
return;
});
static async hasEncryptionKey(): Promise<boolean> {
return Boolean(await BrowserStorage.getKey());
}

static getExport(data: OTPEntryInterface[], encrypted?: boolean) {
Expand Down
20 changes: 2 additions & 18 deletions src/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { Notification } from "./store/Notification";
import { Qr } from "./store/Qr";
import { Advisor } from "./store/Advisor";
import { Dropbox, Drive, OneDrive } from "./models/backup";
import { EntryStorage } from "./models/storage";

async function init() {
// Add globals
Expand Down Expand Up @@ -62,27 +61,12 @@ async function init() {

// Prompt for password if needed
if (instance.$store.state.accounts.shouldShowPassphrase) {
instance.$store.commit("style/showInfo", true);
// If we have cached password, use that
if (instance.$store.state.accounts.encryption.getEncryptionStatus()) {
instance.$store.commit("currentView/changeView", "LoadingPage");
for (const entry of instance.$store.state.accounts.entries) {
await entry.applyEncryption(instance.$store.state.accounts.encryption);
}
instance.$store.commit(
"accounts/updateExport",
await EntryStorage.getExport(instance.$store.state.accounts.entries)
);
instance.$store.commit(
"accounts/updateEncExport",
await EntryStorage.getExport(
instance.$store.state.accounts.entries,
true
)
);
instance.$store.commit("accounts/updateCodes");
instance.$store.commit("style/hideInfo", true);
await instance.$store.dispatch("accounts/updateEntries");
} else {
instance.$store.commit("style/showInfo", true);
instance.$store.commit("currentView/changeView", "EnterPasswordPage");
}
}
Expand Down
13 changes: 2 additions & 11 deletions src/store/Accounts.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
import { EntryStorage, BrowserStorage } from "../models/storage";
import { Encryption } from "../models/encryption";
import * as CryptoJS from "crypto-js";
import { OTPType, OTPAlgorithm, CodeState } from "../models/otp";
import { OTPType, OTPAlgorithm } from "../models/otp";
import { ActionContext } from "vuex";

export class Accounts implements Module {
async getModule() {
const cachedPassphrase = await this.getCachedPassphrase();
const encryption: Encryption = new Encryption(cachedPassphrase);
let shouldShowPassphrase = cachedPassphrase
? false
: await EntryStorage.hasEncryptedEntry();
const shouldShowPassphrase = await EntryStorage.hasEncryptionKey();
const entries = shouldShowPassphrase ? [] : await this.getEntries();

for (let i = 0; i < entries.length; i++) {
if (entries[i].code === CodeState.Encrypted) {
shouldShowPassphrase = true;
break;
}
}

return {
state: {
entries,
Expand Down
4 changes: 2 additions & 2 deletions src/store/Advisor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const insightsData: AdvisorInsightInterface[] = [
level: InsightLevel.danger,
description: chrome.i18n.getMessage("advisor_insight_password_not_set"),
validation: async () => {
const hasEncryptedEntry = await EntryStorage.hasEncryptedEntry();
const hasEncryptedEntry = await EntryStorage.hasEncryptionKey();
return !hasEncryptedEntry;
},
},
Expand All @@ -16,7 +16,7 @@ const insightsData: AdvisorInsightInterface[] = [
level: InsightLevel.warning,
description: chrome.i18n.getMessage("advisor_insight_auto_lock_not_set"),
validation: async () => {
const hasEncryptedEntry = await EntryStorage.hasEncryptedEntry();
const hasEncryptedEntry = await EntryStorage.hasEncryptionKey();
return hasEncryptedEntry && !Number(localStorage.autolock);
},
},
Expand Down