Skip to content

Commit 7a0a28e

Browse files
authored
fix #372 (#376)
fix #372
2 parents 7d3a3b9 + 8ddfae0 commit 7a0a28e

File tree

6 files changed

+62
-41
lines changed

6 files changed

+62
-41
lines changed

_locales/en/messages.json

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
"description": "Account Name."
5757
},
5858
"issuer": {
59-
"message": "Issuer",
60-
"description": "Issuer."
59+
"message": "Issuer",
60+
"description": "Issuer."
6161
},
6262
"secret": {
6363
"message": "Secret",
@@ -224,52 +224,52 @@
224224
"description": "Remove password."
225225
},
226226
"download_enc_backup": {
227-
"message": "Download Password-Protected Backup",
228-
"description": "Download Encrypted Backup"
227+
"message": "Download Password-Protected Backup",
228+
"description": "Download Encrypted Backup"
229229
},
230230
"search": {
231-
"message": "Search",
232-
"description": "Search"
231+
"message": "Search",
232+
"description": "Search"
233233
},
234234
"popout": {
235-
"message": "Popup mode",
236-
"description": "Make window turn into persistent popup"
235+
"message": "Popup mode",
236+
"description": "Make window turn into persistent popup"
237237
},
238238
"lock": {
239-
"message": "Lock",
240-
"description": "Lock accounts"
239+
"message": "Lock",
240+
"description": "Lock accounts"
241241
},
242242
"edit": {
243-
"message": "Edit",
244-
"description": "Edit"
243+
"message": "Edit",
244+
"description": "Edit"
245245
},
246246
"manual_dropbox": {
247-
"message": "Manual Sync",
248-
"description": "Manual sync"
247+
"message": "Manual Sync",
248+
"description": "Manual sync"
249249
},
250250
"use_autofill": {
251-
"message": "Use Autofill",
252-
"description": "Use Autofill"
251+
"message": "Use Autofill",
252+
"description": "Use Autofill"
253253
},
254254
"use_high_contrast": {
255-
"message": "Use High Contrast",
256-
"description": "Use High Contrast"
255+
"message": "Use High Contrast",
256+
"description": "Use High Contrast"
257257
},
258258
"storage_menu": {
259-
"message": "Storage & Backup",
260-
"description": "Storage and sync menu title"
259+
"message": "Storage & Backup",
260+
"description": "Storage and sync menu title"
261261
},
262262
"storage_location_info": {
263-
"message": "Choose where your data is stored. Using 'local' stores your data on your PC. Using 'sync' lets your browser sync your data to the cloud if you are signed into a sync account.",
264-
"description": "Message explaning the diffrences between sync and local storage spaces."
263+
"message": "Choose where your data is stored. Using 'local' stores your data on your PC. Using 'sync' lets your browser sync your data to the cloud if you are signed into a sync account.",
264+
"description": "Message explaning the diffrences between sync and local storage spaces."
265265
},
266266
"storage_sync_info": {
267-
"message": "Automatically backup your data to 3rd party storage services.",
268-
"description": "3rd party backup info"
267+
"message": "Automatically backup your data to 3rd party storage services.",
268+
"description": "3rd party backup info"
269269
},
270270
"storage_location": {
271-
"message": "Storage Location",
272-
"description": "Storage location"
271+
"message": "Storage Location",
272+
"description": "Storage location"
273273
},
274274
"sign_in": {
275275
"message": "Sign in",
@@ -312,5 +312,8 @@
312312
},
313313
"type": {
314314
"message": "Type"
315+
},
316+
"invalid": {
317+
"message": "Invalid"
315318
}
316319
}

src/components/Popup/EntryComponent.vue

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
timeout: entry.period - (second % entry.period) < 5
4545
}"
4646
v-on:click="copyCode(entry)"
47-
v-html="style.isEditing ? showBulls(entry.code) : entry.code"
47+
v-html="style.isEditing ? showBulls(entry.code) : showCode(entry.code)"
4848
></div>
4949
<div class="issuer">{{ entry.account }}</div>
5050
<div class="issuerEdit">
@@ -71,7 +71,7 @@
7171
import Vue from "vue";
7272
import { mapState } from "vuex";
7373
import * as QRGen from "qrcode-generator";
74-
import { OTPEntry, OTPType } from "../../models/otp";
74+
import { OTPEntry, OTPType, CodeState } from "../../models/otp";
7575
7676
import IconMinusCircle from "../../../svg/minus-circle.svg";
7777
import IconRedo from "../../../svg/redo.svg";
@@ -103,7 +103,9 @@ export default Vue.extend({
103103
methods: {
104104
noCopy(code: string) {
105105
return (
106-
code === "Encrypted" || code === "Invalid" || code.startsWith("&bull;")
106+
code === CodeState.Encrypted ||
107+
code === CodeState.Invalid ||
108+
code.startsWith("&bull;")
107109
);
108110
},
109111
shouldShowQrIcon(entry: OTPEntry) {
@@ -113,6 +115,15 @@ export default Vue.extend({
113115
entry.type !== OTPType.steam
114116
);
115117
},
118+
showCode(code: string) {
119+
if (code === CodeState.Encrypted) {
120+
return this.i18n.encrypted;
121+
} else if (code === CodeState.Invalid) {
122+
return this.i18n.invalid;
123+
} else {
124+
return code;
125+
}
126+
},
116127
showBulls(code: string) {
117128
if (code.startsWith("&bull;")) {
118129
return code;
@@ -150,13 +161,13 @@ export default Vue.extend({
150161
async copyCode(entry: OTPEntry) {
151162
if (
152163
this.$store.state.style.style.isEditing ||
153-
entry.code === "Invalid" ||
164+
entry.code === CodeState.Invalid ||
154165
entry.code.startsWith("&bull;")
155166
) {
156167
return;
157168
}
158169
159-
if (entry.code === "Encrypted") {
170+
if (entry.code === CodeState.Encrypted) {
160171
this.$store.commit("style/showInfo");
161172
this.$store.commit("currentView/changeView", "EnterPasswordPage");
162173
return;

src/models/encryption.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ export class Encryption implements IEncryption {
6868
}
6969

7070
console.warn(
71-
`Account ${entry.hash} may have secret ${decryptedSecret}, but hash did not match.`
71+
`Account ${
72+
entry.hash
73+
} may have secret ${decryptedSecret}, but hash did not match.`
7274
);
7375
return null;
7476
} catch (error) {

src/models/otp.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ export enum OTPType {
1111
hhex
1212
}
1313

14+
export enum CodeState {
15+
Invalid = "-1",
16+
Encrypted = "-2"
17+
}
18+
1419
export class OTPEntry implements IOTPEntry {
1520
type: OTPType;
1621
index: number;
@@ -97,9 +102,9 @@ export class OTPEntry implements IOTPEntry {
97102

98103
generate() {
99104
if (!this.secret && !this.encSecret) {
100-
this.code = "Invalid";
105+
this.code = CodeState.Invalid;
101106
} else if (!this.secret) {
102-
this.code = "Encrypted";
107+
this.code = CodeState.Encrypted;
103108
} else {
104109
try {
105110
this.code = KeyUtilities.generate(
@@ -109,10 +114,8 @@ export class OTPEntry implements IOTPEntry {
109114
this.period
110115
);
111116
} catch (error) {
112-
this.code = "Invalid";
113-
if (parent) {
114-
parent.postMessage(`Invalid secret: [${this.secret}]`, "*");
115-
}
117+
this.code = CodeState.Invalid;
118+
console.log("Invalid secret.", error);
116119
}
117120
}
118121
}

src/qrdebug.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ function getQrDebug(
6060
`Screen Height: ${window.screen.height}<br>` +
6161
`Capture Width: ${qr.width}<br>` +
6262
`Capture Height: ${qr.height}<br>` +
63-
`Device Pixel Ratio: ${devicePixelRatio} / ${window.devicePixelRatio}<br>` +
63+
`Device Pixel Ratio: ${devicePixelRatio} / ${
64+
window.devicePixelRatio
65+
}<br>` +
6466
`Tab ID: ${tab.id}<br>` +
6567
"<br>" +
6668
"<b>Captured Screenshot:</b>";

src/store/Accounts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { EntryStorage } from "../models/storage";
22
import { Encryption } from "../models/encryption";
33
import * as CryptoJS from "crypto-js";
4-
import { OTPType } from "../models/otp";
4+
import { OTPType, CodeState } from "../models/otp";
55
import { ActionContext } from "vuex";
66

77
export class Accounts implements IModule {
@@ -16,7 +16,7 @@ export class Accounts implements IModule {
1616
: await this.getEntries(encryption);
1717

1818
for (let i = 0; i < entries.length; i++) {
19-
if (entries[i].code === "Encrypted") {
19+
if (entries[i].code === CodeState.Encrypted) {
2020
shouldShowPassphrase = true;
2121
break;
2222
}

0 commit comments

Comments
 (0)