Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!ls) {
utils.logWarn('Adagio Script not found');
return;
}
const hashRgx = /^(\/\/ hash: (.+)\n)(.+\n)$/;
if (!hashRgx.test(ls)) {
utils.logWarn('No hash found in Adagio script');
w.localStorage.removeItem(ADAGIO_LOCALSTORAGE_KEY);
} else {
const r = ls.match(hashRgx);
const hash = r[2];
const content = r[3];
var jsEncrypt = new JSEncrypt();
jsEncrypt.setPublicKey(ADAGIO_PUBKEY);
if (jsEncrypt.verify(content, hash, sha256)) {
utils.logInfo('Start Adagio script');
Function(ls)(); // eslint-disable-line no-new-func
} else {
utils.logWarn('Invalid Adagio script found');
w.localStorage.removeItem(ADAGIO_LOCALSTORAGE_KEY);
}
}
} catch (err) {
//
}
}