Skip to content

Commit

Permalink
Refactor velzie's global proxy refactor in a way that doesn't break t…
Browse files Browse the repository at this point in the history
…hings (i think)
  • Loading branch information
wearrrrr committed Oct 13, 2024
1 parent 4128bc7 commit a3cb21a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/client/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { ScramjetClient } from "./client";
// import { config } from "../shared";
import { getOwnPropertyDescriptorHandler } from "./helpers";
import { indirectEval } from "./shared/eval";

export const UNSAFE_GLOBALS = [
"window",
Expand All @@ -20,11 +21,15 @@ export function createGlobalProxy(
): typeof globalThis {
return new Proxy(self, {
get(target, prop) {
const value = Reflect.get(target, prop);
if (prop === "location") return client.locationProxy;
if (typeof prop === "string" && UNSAFE_GLOBALS.includes(prop)) return client.wrapfn(self[prop]);
if (prop === "$scramjet") return;
if (prop === "eval") return indirectEval.bind(client);

const value = Reflect.get(target, prop);
if (typeof prop === "string" && UNSAFE_GLOBALS.includes(prop))
return client.wrapfn(value);

return value;
},

Expand Down

0 comments on commit a3cb21a

Please sign in to comment.