Skip to content

Commit

Permalink
Avoid accessing undefined variable, avoid reassigning window, cleanup…
Browse files Browse the repository at this point in the history
… redundant window code
  • Loading branch information
John Bartos committed Jun 15, 2018
1 parent 480078f commit 3630bf9
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/crypt/decrypter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 } = {}) {
Expand All @@ -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) {}
}
Expand Down

0 comments on commit 3630bf9

Please sign in to comment.