File tree Expand file tree Collapse file tree 4 files changed +9
-28
lines changed Expand file tree Collapse file tree 4 files changed +9
-28
lines changed Original file line number Diff line number Diff line change @@ -269,7 +269,8 @@ async function getTotp(text: string, silent = false) {
269269 entryData [ hash ] . algorithm = algorithm ;
270270 }
271271 if (
272- ( await EntryStorage . hasEncryptedEntry ( ) ) !==
272+ // If the entries are encrypted and we aren't unlocked, error.
273+ ( await EntryStorage . hasEncryptionKey ( ) ) !==
273274 encryption . getEncryptionStatus ( )
274275 ) {
275276 ! silent && chrome . tabs . sendMessage ( id , { action : "errorenc" } ) ;
Original file line number Diff line number Diff line change @@ -260,21 +260,8 @@ export class EntryStorage {
260260 }
261261 }
262262
263- static hasEncryptedEntry ( ) {
264- return new Promise ( ( resolve : ( value : boolean ) => void ) => {
265- BrowserStorage . get ( ( _data : { [ hash : string ] : OTPStorage } ) => {
266- for ( const hash of Object . keys ( _data ) ) {
267- if ( ! this . isValidEntry ( _data , hash ) ) {
268- continue ;
269- }
270- if ( _data [ hash ] . encrypted ) {
271- return resolve ( true ) ;
272- }
273- }
274- return resolve ( false ) ;
275- } ) ;
276- return ;
277- } ) ;
263+ static async hasEncryptionKey ( ) : Promise < boolean > {
264+ return Boolean ( await BrowserStorage . getKey ( ) ) ;
278265 }
279266
280267 static getExport ( data : OTPEntryInterface [ ] , encrypted ?: boolean ) {
Original file line number Diff line number Diff line change 11import { EntryStorage , BrowserStorage } from "../models/storage" ;
22import { Encryption } from "../models/encryption" ;
33import * as CryptoJS from "crypto-js" ;
4- import { OTPType , OTPAlgorithm , CodeState } from "../models/otp" ;
4+ import { OTPType , OTPAlgorithm } from "../models/otp" ;
55import { ActionContext } from "vuex" ;
66
77export class Accounts implements Module {
88 async getModule ( ) {
99 const cachedPassphrase = await this . getCachedPassphrase ( ) ;
1010 const encryption : Encryption = new Encryption ( cachedPassphrase ) ;
11- let shouldShowPassphrase = cachedPassphrase
11+ const shouldShowPassphrase = cachedPassphrase
1212 ? false
13- : await EntryStorage . hasEncryptedEntry ( ) ;
13+ : await EntryStorage . hasEncryptionKey ( ) ;
1414 const entries = shouldShowPassphrase ? [ ] : await this . getEntries ( ) ;
1515
16- for ( let i = 0 ; i < entries . length ; i ++ ) {
17- if ( entries [ i ] . code === CodeState . Encrypted ) {
18- shouldShowPassphrase = true ;
19- break ;
20- }
21- }
22-
2316 return {
2417 state : {
2518 entries,
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ const insightsData: AdvisorInsightInterface[] = [
77 level : InsightLevel . danger ,
88 description : chrome . i18n . getMessage ( "advisor_insight_password_not_set" ) ,
99 validation : async ( ) => {
10- const hasEncryptedEntry = await EntryStorage . hasEncryptedEntry ( ) ;
10+ const hasEncryptedEntry = await EntryStorage . hasEncryptionKey ( ) ;
1111 return ! hasEncryptedEntry ;
1212 } ,
1313 } ,
@@ -16,7 +16,7 @@ const insightsData: AdvisorInsightInterface[] = [
1616 level : InsightLevel . warning ,
1717 description : chrome . i18n . getMessage ( "advisor_insight_auto_lock_not_set" ) ,
1818 validation : async ( ) => {
19- const hasEncryptedEntry = await EntryStorage . hasEncryptedEntry ( ) ;
19+ const hasEncryptedEntry = await EntryStorage . hasEncryptionKey ( ) ;
2020 return hasEncryptedEntry && ! Number ( localStorage . autolock ) ;
2121 } ,
2222 } ,
You can’t perform that action at this time.
0 commit comments