@poe-platform/safe-js 0.1.90 → 0.1.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7000,6 +7000,27 @@ function getSandboxPrototype(value, budget) {
7000
7000
  function hasExplicitSandboxPrototype(value) {
7001
7001
  return prototypes.has(value);
7002
7002
  }
7003
+ function getSandboxDataProperty(value, key, budget) {
7004
+ let current = value;
7005
+ let depth = 0;
7006
+ while (typeof current === "object" && current !== null) {
7007
+ if (isGuestHostObject(current)) return getHostObjectMember(current, String(key));
7008
+ if (isGuestClosure(current)) return getGuestFunctionProperty(current, String(key));
7009
+ if (isSandboxClosure(current)) {
7010
+ const properties = current.properties;
7011
+ return properties !== void 0 && Object.hasOwn(properties, String(key)) ? properties[String(key)] : void 0;
7012
+ }
7013
+ if (isSandboxMap(current) || isSandboxSet(current) || isSandboxPromise(current) || isSandboxRegex(current) || isSandboxGenerator(current))
7014
+ return void 0;
7015
+ if (Object.hasOwn(current, String(key))) return current[String(key)];
7016
+ current = getSandboxPrototype(current, budget);
7017
+ if (current !== null) {
7018
+ budget?.visitNode();
7019
+ assertSandboxDataDepth(++depth);
7020
+ }
7021
+ }
7022
+ return void 0;
7023
+ }
7003
7024
  function setSandboxPrototype(value, prototype, budget) {
7004
7025
  if (budget !== void 0 && intrinsicPrototypes.get(budget) === value && prototype !== null) {
7005
7026
  throw new TypeError("Object.prototype has an immutable null prototype.");
@@ -8940,8 +8961,8 @@ async function bindArrayPattern(pattern, value, context, evaluateNode2) {
8940
8961
  return { ok: true };
8941
8962
  }
8942
8963
  async function bindObjectPattern(pattern, value, context, evaluateNode2) {
8943
- if (typeof value !== "object" && !Array.isArray(value) || value === null) {
8944
- throw new TypeError("Object catch bindings require a non-null object value.");
8964
+ if (value === null || value === void 0) {
8965
+ throw new TypeError("Object catch bindings require a non-nullish value.");
8945
8966
  }
8946
8967
  const excludedKeys = /* @__PURE__ */ new Set();
8947
8968
  for (const property of pattern.properties) {
@@ -8960,7 +8981,7 @@ async function bindObjectPattern(pattern, value, context, evaluateNode2) {
8960
8981
  excludedKeys.add(String(key.value));
8961
8982
  const binding = await bindPattern(
8962
8983
  property.value,
8963
- getObjectPatternValue(value, key.value),
8984
+ context.getProperty === void 0 ? getSandboxDataProperty(value, key.value, context.budget) : context.getProperty(value, key.value),
8964
8985
  context,
8965
8986
  evaluateNode2
8966
8987
  );
@@ -9004,15 +9025,9 @@ function getStaticPropertyKey(property) {
9004
9025
  throw new TypeError(`Unsupported catch binding property key '${property.type}'.`);
9005
9026
  }
9006
9027
  }
9007
- function getObjectPatternValue(value, key) {
9008
- return value[key];
9009
- }
9010
9028
  function copyObjectRest(value, excludedKeys) {
9011
9029
  const rest = /* @__PURE__ */ Object.create(null);
9012
- for (const [key, entryValue] of Object.entries(value)) {
9013
- if (excludedKeys.has(key)) {
9014
- continue;
9015
- }
9030
+ for (const [key, entryValue] of ownEnumerableSandboxEntries(value, excludedKeys)) {
9016
9031
  rest[key] = entryValue;
9017
9032
  }
9018
9033
  return rest;
@@ -10217,18 +10232,21 @@ function createSandboxClosure(input) {
10217
10232
  }
10218
10233
  return Object.freeze(closure);
10219
10234
  }
10220
- function ownEnumerableSandboxEntries(value) {
10235
+ function ownEnumerableSandboxEntries(value, excludedKeys) {
10221
10236
  if (isGuestHostObject(value)) {
10222
- const entries = [];
10237
+ const entries2 = [];
10223
10238
  for (const key of getHostObjectKeys(value)) {
10224
- if (hasHostObjectMember(value, key, true)) entries.push([key, getHostObjectMember(value, key)]);
10239
+ if (excludedKeys?.has(key)) continue;
10240
+ if (hasHostObjectMember(value, key, true)) entries2.push([key, getHostObjectMember(value, key)]);
10225
10241
  }
10226
- return entries;
10242
+ return entries2;
10227
10243
  }
10228
10244
  if (value === null || value === void 0) throw new TypeError("Cannot convert undefined or null to object.");
10229
- if (isGuestClosure(value)) return Object.entries(value.properties ?? {});
10230
- if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
10231
- return Object.entries(Object(value));
10245
+ let entries;
10246
+ if (isGuestClosure(value)) entries = Object.entries(value.properties ?? {});
10247
+ else if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
10248
+ else entries = Object.entries(Object(value));
10249
+ return excludedKeys === void 0 ? entries : entries.filter(([key]) => !excludedKeys.has(key));
10232
10250
  }
10233
10251
  function createSandboxPromise(promise, metadata = {}) {
10234
10252
  const original = metadata.trackReplay === false ? promise : promiseReplayContext.getStore()?.track(promise) ?? promise;
@@ -24524,20 +24542,23 @@ var numberMethodNames = /* @__PURE__ */ new Set([
24524
24542
  "toPrecision",
24525
24543
  "toString"
24526
24544
  ]);
24527
- function getNumberMember(value, property, budget) {
24545
+ function getNumberMember(property, budget) {
24528
24546
  if (!isNumberMethodName(property)) {
24529
24547
  return void 0;
24530
24548
  }
24531
24549
  return createSandboxClosure({
24532
24550
  sandbox: true,
24533
24551
  name: `Number#${property}`,
24534
- call: (args) => callNumberMethod(value, property, args, budget)
24552
+ call: (args, context) => callNumberMethod(context?.thisValue, property, args, budget)
24535
24553
  });
24536
24554
  }
24537
24555
  function isNumberMethodName(property) {
24538
24556
  return typeof property === "string" && numberMethodNames.has(property);
24539
24557
  }
24540
24558
  function callNumberMethod(value, methodName, args, budget) {
24559
+ if (typeof value !== "number") {
24560
+ throw new TypeError(`Number#${methodName} requires a number receiver.`);
24561
+ }
24541
24562
  return budget.allocateString(callNativeNumberMethod(value, methodName, args));
24542
24563
  }
24543
24564
  function callNativeNumberMethod(value, methodName, args) {
@@ -27367,7 +27388,8 @@ async function evaluateThrowStatement2(node, context) {
27367
27388
  async function evaluateTryStatement2(node, context) {
27368
27389
  return evaluateTryStatement(node, {
27369
27390
  ...context,
27370
- toPropertyKey: (value) => toPropertyKey(value, context.budget, createCoercionContext(context))
27391
+ toPropertyKey: (value) => toPropertyKey(value, context.budget, createCoercionContext(context)),
27392
+ getProperty: (value, key) => getPropertyValue(value, key, context)
27371
27393
  }, evaluateNode);
27372
27394
  }
27373
27395
  async function evaluateUnaryExpression(node, context) {
@@ -27507,7 +27529,7 @@ async function evaluateMemberExpression(node, context) {
27507
27529
  function getPropertyValue(target, property, context) {
27508
27530
  if (isGuestHostObject(target)) return getHostObjectMember(target, String(property));
27509
27531
  if (typeof target === "string") return getStringMember(target, property, context.budget);
27510
- if (typeof target === "number") return getNumberMember(target, property, context.budget);
27532
+ if (typeof target === "number") return getNumberMember(property, context.budget);
27511
27533
  if (typeof target === "boolean") return void 0;
27512
27534
  if (isFloat32Array(target)) return getFloat32Member(target, property, context.budget);
27513
27535
  if (isSandboxDate(target)) return getDateMember(property, context.budget, context.compilation?.owner);
@@ -27714,7 +27736,7 @@ async function evaluateMemberCallExpression(node, context) {
27714
27736
  node,
27715
27737
  "Number",
27716
27738
  member.property,
27717
- getNumberMember(member.object, member.property, context.budget),
27739
+ getNumberMember(member.property, context.budget),
27718
27740
  context
27719
27741
  );
27720
27742
  }
@@ -32894,4 +32916,4 @@ export {
32894
32916
  FileSnapshotBackend,
32895
32917
  run
32896
32918
  };
32897
- //# sourceMappingURL=chunk-774EXZKX.js.map
32919
+ //# sourceMappingURL=chunk-MVOTTS35.js.map