MCPcopy Create free account
hub / github.com/ICBNetwork/web3-Wallet / assertDirectEvalAvailable

Function assertDirectEvalAvailable

ses.cjs:9978–10008  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9976// the quality of audits.
9977
9978const assertDirectEvalAvailable= ()=> {
9979 let allowed= false;
9980 try {
9981 allowed= FERAL_FUNCTION(
9982 'eval',
9983 'SES_changed',
9984 `\
9985 eval("SES_changed = true");
9986 return SES_changed;
9987 `)(
9988 FERAL_EVAL, false);
9989 // If we get here and SES_changed stayed false, that means the eval was sloppy
9990 // and indirect, which generally creates a new global.
9991 // We are going to throw an exception for failing to initialize SES, but
9992 // good neighbors clean up.
9993 if( !allowed) {
9994 delete globalThis.SES_changed;
9995 }
9996 }catch( _error) {
9997 // We reach here if eval is outright forbidden by a Content Security Policy.
9998 // We allow this for SES usage that delegates the responsibility to isolate
9999 // guest code to production code generation.
10000 allowed= true;
10001 }
10002 if( !allowed) {
10003 // See https://github.com/endojs/endo/blob/master/packages/ses/error-codes/SES_DIRECT_EVAL.md
10004 throw TypeError(
10005 `SES cannot initialize unless 'eval' is the original intrinsic 'eval', suitable for direct-eval (dynamically scoped eval) (SES_DIRECT_EVAL)`);
10006
10007 }
10008 };
10009
10010/**
10011 * @param {LockdownOptions} [options]

Callers 1

repairIntrinsicsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected