@poe-platform/safe-js 0.1.196 → 0.1.197

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.
@@ -7694,6 +7694,9 @@ function getSandboxPrototype(value, budget) {
7694
7694
  function hasExplicitSandboxPrototype(value) {
7695
7695
  return prototypes.has(value);
7696
7696
  }
7697
+ function hasNullObjectPrototype(value) {
7698
+ return prototypes.get(value) === null && !Array.isArray(value) && !isSandboxClosure(value) && !isSandboxRegex(value);
7699
+ }
7697
7700
  function getSandboxPropertyDescriptor(value, key, budget) {
7698
7701
  const hostProperties = isSandboxClosure(value) ? value.properties : void 0;
7699
7702
  if (isSandboxClosure(value) && !isGuestClosure(value))
@@ -7775,7 +7778,7 @@ function hasGuestObjectState(value) {
7775
7778
  const intrinsicUnchanged = intrinsicConstructors.get(value);
7776
7779
  if (intrinsicUnchanged !== void 0) return !intrinsicUnchanged();
7777
7780
  if (isLiveCapability(value)) return true;
7778
- if (functionProperties.has(value) || prototypes.has(value)) return true;
7781
+ if (functionProperties.has(value) || prototypes.has(value) && !hasNullObjectPrototype(value)) return true;
7779
7782
  if (isSandboxBox(value) || isSandboxDate(value)) return false;
7780
7783
  return descriptorObjects.has(value) && Object.values(Object.getOwnPropertyDescriptors(value)).some(
7781
7784
  (descriptor) => !descriptor.enumerable || !descriptor.configurable || !descriptor.writable
@@ -8096,6 +8099,7 @@ function serializeHeapReference(value, path, state) {
8096
8099
  });
8097
8100
  state.heap[String(id)] = {
8098
8101
  kind: "object",
8102
+ ...hasNullObjectPrototype(value) ? { sandboxNullPrototype: true } : {},
8099
8103
  entries: serializeObjectEntries(value, path, state),
8100
8104
  ...symbolEntries.length === 0 ? {} : { symbolEntries },
8101
8105
  ...errorType === void 0 ? {} : { errorType }
@@ -8129,7 +8133,7 @@ function indexHeapContainers(snapshot) {
8129
8133
  const heapIds = /* @__PURE__ */ new Map();
8130
8134
  let nextId = 1;
8131
8135
  for (const [value, stat2] of stats.entries()) {
8132
- if (stat2.count > 1 || stat2.cyclic || ownSerializableSymbolKeys(value).length > 0 || isSandboxBox(value) || isSandboxRegExpIterator(value) || isSandboxRegex(value) && hasCustomRegexProperties(value) || isSandboxDate(value) || isFloat32Array(value) || Array.isArray(value) && requiresArrayEntries(value) || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
8136
+ if (stat2.count > 1 || stat2.cyclic || hasNullObjectPrototype(value) || ownSerializableSymbolKeys(value).length > 0 || isSandboxBox(value) || isSandboxRegExpIterator(value) || isSandboxRegex(value) && hasCustomRegexProperties(value) || isSandboxDate(value) || isFloat32Array(value) || Array.isArray(value) && requiresArrayEntries(value) || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
8133
8137
  heapIds.set(value, nextId);
8134
8138
  nextId += 1;
8135
8139
  }
@@ -8315,6 +8319,8 @@ function validateDumpHeap(root, state) {
8315
8319
  continue;
8316
8320
  }
8317
8321
  if (entry.kind === "object") {
8322
+ if (Object.hasOwn(entry, "sandboxNullPrototype") && entry.sandboxNullPrototype !== true)
8323
+ fail("invalidValue", `${path}.sandboxNullPrototype`, "invalid object prototype");
8318
8324
  requireRecord(entry.entries, `${path}.entries`);
8319
8325
  continue;
8320
8326
  }
@@ -8435,7 +8441,11 @@ function validateTaggedValue(record2, path, state) {
8435
8441
  return;
8436
8442
  case "array":
8437
8443
  case "arguments":
8444
+ return;
8438
8445
  case "object":
8446
+ if (Object.hasOwn(record2, "sandboxNullPrototype") && record2.sandboxNullPrototype !== true)
8447
+ fail("invalidValue", `${path}.sandboxNullPrototype`, "invalid object prototype");
8448
+ return;
8439
8449
  case "map":
8440
8450
  case "set":
8441
8451
  case "collection-iterator":
@@ -17970,6 +17980,7 @@ function encodeReplayData(value, options = {}) {
17970
17980
  nodes[id] = {
17971
17981
  kind: Array.isArray(entry) ? "array" : "object",
17972
17982
  nullPrototype: prototype === null,
17983
+ ...hasNullObjectPrototype(entry) ? { sandboxNullPrototype: true } : {},
17973
17984
  ...errorType === void 0 ? {} : { errorType },
17974
17985
  extensible: Object.isExtensible(entry),
17975
17986
  properties,
@@ -18192,6 +18203,10 @@ function decodeReplayData(input, options = {}, parent) {
18192
18203
  throw new TypeError("Invalid replay object metadata.");
18193
18204
  }
18194
18205
  const result2 = kind === "array" ? [] : Object.create(node.nullPrototype ? null : Object.prototype);
18206
+ if (Object.hasOwn(node, "sandboxNullPrototype")) {
18207
+ if (kind !== "object" || node.sandboxNullPrototype !== true) throw new TypeError("Invalid replay object prototype.");
18208
+ setSandboxPrototype(result2, null);
18209
+ }
18195
18210
  if (Object.hasOwn(node, "errorType")) {
18196
18211
  sandboxErrorTypes.set(result2, node.errorType);
18197
18212
  }
@@ -21827,6 +21842,7 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
21827
21842
  const copy = createPlainObject(
21828
21843
  !cloneSandboxCollections || Object.getPrototypeOf(value) === null
21829
21844
  );
21845
+ if (!state.structuredClone && hasNullObjectPrototype(value)) setSandboxPrototype(copy, null);
21830
21846
  state.seen.set(value, copy);
21831
21847
  const errorType = sandboxErrorTypes.get(value);
21832
21848
  if (errorType !== void 0) sandboxErrorTypes.set(copy, errorType);
@@ -22038,7 +22054,7 @@ function copyFromSandbox(value, state, path = "<root>", options, depth = 0) {
22038
22054
  if (existing !== void 0) {
22039
22055
  return existing;
22040
22056
  }
22041
- const copy = createPlainObject(Object.getPrototypeOf(value) === null);
22057
+ const copy = createPlainObject(hasNullObjectPrototype(value) || Object.getPrototypeOf(value) === null);
22042
22058
  state.seen.set(value, copy);
22043
22059
  for (const entry of getEnumerableObjectEntries(value, path)) {
22044
22060
  defineOwnDataProperty(
@@ -37166,4 +37182,4 @@ export {
37166
37182
  FileSnapshotBackend,
37167
37183
  run
37168
37184
  };
37169
- //# sourceMappingURL=chunk-KMQUDIYF.js.map
37185
+ //# sourceMappingURL=chunk-7KLRGTR4.js.map