diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-01-21 22:40:55 +0100 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2019-01-25 07:24:22 +0100 |
commit | 0f5c14c43e5e79d40726ce6907caf2a76b510be2 (patch) | |
tree | 4db1818376e2f4259547afb59f8836853427a0cf /lib/internal/process/policy.js | |
parent | 399ef4f5369ea3e7a7edf5f8bb09e889e3715ba0 (diff) | |
download | android-node-v8-0f5c14c43e5e79d40726ce6907caf2a76b510be2.tar.gz android-node-v8-0f5c14c43e5e79d40726ce6907caf2a76b510be2.tar.bz2 android-node-v8-0f5c14c43e5e79d40726ce6907caf2a76b510be2.zip |
lib: refactor policy code for readability
Simplify a few particularly quirky bits of code, and add
whitespace for readability.
PR-URL: https://github.com/nodejs/node/pull/25629
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Diffstat (limited to 'lib/internal/process/policy.js')
-rw-r--r-- | lib/internal/process/policy.js | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/internal/process/policy.js b/lib/internal/process/policy.js index f5ca4eeb07..0b037d4ef5 100644 --- a/lib/internal/process/policy.js +++ b/lib/internal/process/policy.js @@ -5,6 +5,7 @@ const { } = require('internal/errors').codes; const { Manifest } = require('internal/policy/manifest'); let manifest; + module.exports = Object.freeze({ __proto__: null, setup(src, url) { @@ -12,6 +13,7 @@ module.exports = Object.freeze({ manifest = null; return; } + const json = JSON.parse(src, (_, o) => { if (o && typeof o === 'object') { Reflect.setPrototypeOf(o, null); @@ -21,12 +23,14 @@ module.exports = Object.freeze({ }); manifest = new Manifest(json, url); }, + get manifest() { if (typeof manifest === 'undefined') { throw new ERR_MANIFEST_TDZ(); } return manifest; }, + assertIntegrity(moduleURL, content) { this.manifest.matchesIntegrity(moduleURL, content); } |