From 3630bf99a97fbbfc3314d69a80e0da836ab33555 Mon Sep 17 00:00:00 2001 From: John Bartos Date: Fri, 15 Jun 2018 14:07:26 -0400 Subject: [PATCH] Avoid accessing undefined variable, avoid reassigning window, cleanup redundant window code --- src/crypt/decrypter.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/crypt/decrypter.js b/src/crypt/decrypter.js index cb352f6b459..db2633b47d9 100644 --- a/src/crypt/decrypter.js +++ b/src/crypt/decrypter.js @@ -11,9 +11,7 @@ import { getSelfScope } from '../utils/get-self-scope'; // see https://stackoverflow.com/a/11237259/589493 /* eslint-disable-next-line no-undef */ -const window = getSelfScope(); // safeguard for code that might run both on worker and main thread - -const { performance, crypto } = window; +const global = getSelfScope(); // safeguard for code that might run both on worker and main thread class Decrypter { constructor (observer, config, { removePKCS7Padding = true } = {}) { @@ -24,7 +22,7 @@ class Decrypter { // built in decryptor expects PKCS7 padding if (removePKCS7Padding) { try { - const browserCrypto = crypto || window.crypto; + const browserCrypto = global.crypto; this.subtle = browserCrypto.subtle || browserCrypto.webkitSubtle; } catch (e) {} }