diff --git a/src/components/Alert.vue b/src/components/Alert.vue index c7b5293..d7297b8 100644 --- a/src/components/Alert.vue +++ b/src/components/Alert.vue @@ -31,17 +31,16 @@ export default Vue.extend({ }; }, created: function() { - const self = this; - this.$eventHub.$on("showError", function(text: string) { - self.level = AlertLevel.Error; - self.message = text; + this.$eventHub.$on("showError", (text: string) => { + this.level = AlertLevel.Error; + this.message = text; }); - this.$eventHub.$on("showWarn", function(text: string) { - self.level = AlertLevel.Warn; - self.message = text; + this.$eventHub.$on("showWarn", (text: string) => { + this.level = AlertLevel.Warn; + this.message = text; }); - this.$eventHub.$on("clearAlerts", function() { - self.message = null; + this.$eventHub.$on("clearAlerts", () => { + this.message = null; }); } }); diff --git a/src/util/crypto.ts b/src/util/crypto.ts index 5d1b752..6284c0e 100644 --- a/src/util/crypto.ts +++ b/src/util/crypto.ts @@ -92,7 +92,7 @@ function decrypt( salt: Uint8Array, passphrase: string, nonce: Uint8Array -): Uint8Array { +): Uint8Array | null { const key = SCRYPT(passphrase, Buffer.from(salt.buffer), 1 << 15, 8, 1, 32); // This is a false positive, `secretbox.open` is unrelated to `fs.open` // eslint-disable-next-line security/detect-non-literal-fs-filename diff --git a/tests/unit/crypto.spec.ts b/tests/unit/crypto.spec.ts index 994ef3b..87d680a 100644 --- a/tests/unit/crypto.spec.ts +++ b/tests/unit/crypto.spec.ts @@ -52,7 +52,7 @@ test("fails with incorrect password", () => { ); var parsed = shards.map(s => crypto.parse(s)); expect(() => crypto.reconstruct(parsed, "")).toThrow( - new Error("Unable to decrypt the secret") + "Unable to decrypt the secret" ); });