@poe-platform/safe-js 0.1.243 → 0.1.245

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.
@@ -27,7 +27,7 @@ import {
27
27
  validateMigrationSemantics,
28
28
  validateSnapshotData,
29
29
  validateSnapshotMigration
30
- } from "./chunk-NM7QH5TW.js";
30
+ } from "./chunk-NOQSV7MP.js";
31
31
 
32
32
  // packages/safe-js/src/migrate.ts
33
33
  import { createHash } from "node:crypto";
@@ -8249,4 +8249,4 @@ export {
8249
8249
  parseMcpConfig,
8250
8250
  makeMcpModule
8251
8251
  };
8252
- //# sourceMappingURL=chunk-AVVWPQWG.js.map
8252
+ //# sourceMappingURL=chunk-ITCCCKXY.js.map
@@ -6,6 +6,8 @@ var sandboxErrorNames = [
6
6
  "RangeError",
7
7
  "ReferenceError",
8
8
  "SyntaxError",
9
+ "URIError",
10
+ "EvalError",
9
11
  "AbortError",
10
12
  "AggregateError",
11
13
  "HarnessFailure"
@@ -8094,11 +8096,19 @@ function isIntrinsicFunction(value) {
8094
8096
  function registerIntrinsicPrototype(budget, prototype, constructor) {
8095
8097
  if (constructor.name === void 0) throw new TypeError("Intrinsic constructors require an installation name.");
8096
8098
  registerBuiltinIdentities(budget, { [constructor.name]: constructor });
8099
+ const methods = [prototype, materializeFunctionProperties(constructor)].flatMap((owner) => Reflect.ownKeys(owner).map((key) => Object.getOwnPropertyDescriptor(owner, key)?.value)).filter(isGuestClosure);
8100
+ trackIntrinsicState(budget, prototype, constructor, [prototype, constructor, ...methods]);
8101
+ }
8102
+ function registerIntrinsicFunction(budget, closure) {
8103
+ if (closure.name === void 0) throw new TypeError("Intrinsic functions require an installation name.");
8104
+ registerBuiltinIdentities(budget, { [closure.name]: closure });
8105
+ trackIntrinsicState(budget, closure, closure, [closure]);
8106
+ }
8107
+ function trackIntrinsicState(budget, root, owner, targets) {
8097
8108
  let roots = intrinsicPrototypeRoots.get(budget);
8098
8109
  if (roots === void 0) intrinsicPrototypeRoots.set(budget, roots = /* @__PURE__ */ new Set());
8099
- roots.add(prototype);
8100
- const methods = [prototype, materializeFunctionProperties(constructor)].flatMap((owner) => Reflect.ownKeys(owner).map((key) => Object.getOwnPropertyDescriptor(owner, key)?.value)).filter(isGuestClosure);
8101
- const records = [.../* @__PURE__ */ new Set([prototype, constructor, ...methods])].map((target) => ({
8110
+ roots.add(root);
8111
+ const records = [...new Set(targets)].map((target) => ({
8102
8112
  target,
8103
8113
  value: isGuestClosure(target) ? materializeFunctionProperties(target) : target,
8104
8114
  prototype: getSandboxPrototype(target),
@@ -8112,14 +8122,14 @@ function registerIntrinsicPrototype(budget, prototype, constructor) {
8112
8122
  if (isGuestClosure(target)) intrinsicFunctions.add(target);
8113
8123
  const unchanged = (before, after) => before !== void 0 && after !== void 0 && Object.is(before.value, after.value) && before.get === after.get && before.set === after.set && before.writable === after.writable && before.configurable === after.configurable && before.enumerable === after.enumerable;
8114
8124
  intrinsicConstructors.set(
8115
- constructor,
8125
+ owner,
8116
8126
  () => records.every(({ target, value, descriptors: descriptors2, prototype: parent, explicit, extensible }) => {
8117
8127
  const current = Object.getOwnPropertyDescriptors(value);
8118
8128
  return getSandboxPrototype(target) === parent && Object.isExtensible(value) === extensible && hasExplicitSandboxPrototype(target) === explicit && Reflect.ownKeys(current).length === descriptors2.size && Reflect.ownKeys(value).every((key) => unchanged(descriptors2.get(key), Object.getOwnPropertyDescriptor(value, key)));
8119
8129
  })
8120
8130
  );
8121
8131
  budget.setRetainedValues(
8122
- prototype,
8132
+ root,
8123
8133
  () => records.flatMap(({ target, value, descriptors: descriptors2, prototype: parent }) => [
8124
8134
  ...getSandboxPrototype(target) === parent ? [] : [getSandboxPrototype(target)],
8125
8135
  ...Reflect.ownKeys(value).flatMap((key) => {
@@ -14633,6 +14643,8 @@ var errorNames = [
14633
14643
  "RangeError",
14634
14644
  "ReferenceError",
14635
14645
  "SyntaxError",
14646
+ "URIError",
14647
+ "EvalError",
14636
14648
  "AggregateError"
14637
14649
  ];
14638
14650
  function createErrorGlobals(options) {
@@ -22397,6 +22409,29 @@ function assertStructuredCloneable(value, seen) {
22397
22409
  }
22398
22410
  }
22399
22411
 
22412
+ // packages/safe-js/src/interp/globals/uri.ts
22413
+ var conversions = { encodeURI, encodeURIComponent, decodeURI, decodeURIComponent };
22414
+ function createUriGlobals(budget) {
22415
+ return Object.fromEntries(Object.entries(conversions).map(([name, conversion]) => {
22416
+ const closure = createSandboxClosure({
22417
+ sandbox: true,
22418
+ guest: true,
22419
+ name,
22420
+ length: 1,
22421
+ call: ([value], context) => {
22422
+ const convert = (text2) => {
22423
+ budget.visitNode(text2.length);
22424
+ return budget.allocateString(conversion(text2));
22425
+ };
22426
+ const text = sandboxString(value, budget, context);
22427
+ return typeof text === "string" ? convert(text) : text.then(convert);
22428
+ }
22429
+ });
22430
+ registerIntrinsicFunction(budget, closure);
22431
+ return [name, closure];
22432
+ }));
22433
+ }
22434
+
22400
22435
  // packages/safe-js/src/interp/globals/symbol.ts
22401
22436
  var registries = /* @__PURE__ */ new WeakMap();
22402
22437
  function createSymbolGlobal(budget) {
@@ -22612,6 +22647,7 @@ function createBuiltinBindings(options) {
22612
22647
  ...createMathGlobals({ random: options.random }),
22613
22648
  ...createObjectArrayGlobals(options),
22614
22649
  ...createMiscGlobals(options),
22650
+ ...createUriGlobals(options.budget),
22615
22651
  ...createPromiseGlobals(options),
22616
22652
  ...createRegexGlobals(options)
22617
22653
  };
@@ -26803,7 +26839,12 @@ var KNOWN_RUNTIME_GLOBALS = [
26803
26839
  "Boolean",
26804
26840
  "BigInt",
26805
26841
  "Date",
26842
+ "decodeURI",
26843
+ "decodeURIComponent",
26844
+ "encodeURI",
26845
+ "encodeURIComponent",
26806
26846
  "Error",
26847
+ "EvalError",
26807
26848
  "Infinity",
26808
26849
  "isFinite",
26809
26850
  "isNaN",
@@ -26826,6 +26867,7 @@ var KNOWN_RUNTIME_GLOBALS = [
26826
26867
  "structuredClone",
26827
26868
  "SyntaxError",
26828
26869
  "TypeError",
26870
+ "URIError",
26829
26871
  "console"
26830
26872
  ];
26831
26873
 
@@ -39305,4 +39347,4 @@ export {
39305
39347
  FileSnapshotBackend,
39306
39348
  run
39307
39349
  };
39308
- //# sourceMappingURL=chunk-NM7QH5TW.js.map
39350
+ //# sourceMappingURL=chunk-NOQSV7MP.js.map