@poe-platform/safe-js 0.1.244 → 0.1.246
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.
- package/dist/safe-js/chunks/{chunk-IBQE6MEC.js → chunk-KQJOGTEH.js} +2 -2
- package/dist/safe-js/chunks/{chunk-LQ57UIVW.js → chunk-SIFD2ANX.js} +161 -8
- package/dist/safe-js/chunks/chunk-SIFD2ANX.js.map +7 -0
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.js +1 -1
- package/dist/safe-js/index.js +2 -2
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-LQ57UIVW.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-IBQE6MEC.js.map → chunk-KQJOGTEH.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-SIFD2ANX.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-
|
|
8252
|
+
//# sourceMappingURL=chunk-KQJOGTEH.js.map
|
|
@@ -8096,11 +8096,19 @@ function isIntrinsicFunction(value) {
|
|
|
8096
8096
|
function registerIntrinsicPrototype(budget, prototype, constructor) {
|
|
8097
8097
|
if (constructor.name === void 0) throw new TypeError("Intrinsic constructors require an installation name.");
|
|
8098
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) {
|
|
8099
8108
|
let roots = intrinsicPrototypeRoots.get(budget);
|
|
8100
8109
|
if (roots === void 0) intrinsicPrototypeRoots.set(budget, roots = /* @__PURE__ */ new Set());
|
|
8101
|
-
roots.add(
|
|
8102
|
-
const
|
|
8103
|
-
const records = [.../* @__PURE__ */ new Set([prototype, constructor, ...methods])].map((target) => ({
|
|
8110
|
+
roots.add(root);
|
|
8111
|
+
const records = [...new Set(targets)].map((target) => ({
|
|
8104
8112
|
target,
|
|
8105
8113
|
value: isGuestClosure(target) ? materializeFunctionProperties(target) : target,
|
|
8106
8114
|
prototype: getSandboxPrototype(target),
|
|
@@ -8114,14 +8122,14 @@ function registerIntrinsicPrototype(budget, prototype, constructor) {
|
|
|
8114
8122
|
if (isGuestClosure(target)) intrinsicFunctions.add(target);
|
|
8115
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;
|
|
8116
8124
|
intrinsicConstructors.set(
|
|
8117
|
-
|
|
8125
|
+
owner,
|
|
8118
8126
|
() => records.every(({ target, value, descriptors: descriptors2, prototype: parent, explicit, extensible }) => {
|
|
8119
8127
|
const current = Object.getOwnPropertyDescriptors(value);
|
|
8120
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)));
|
|
8121
8129
|
})
|
|
8122
8130
|
);
|
|
8123
8131
|
budget.setRetainedValues(
|
|
8124
|
-
|
|
8132
|
+
root,
|
|
8125
8133
|
() => records.flatMap(({ target, value, descriptors: descriptors2, prototype: parent }) => [
|
|
8126
8134
|
...getSandboxPrototype(target) === parent ? [] : [getSandboxPrototype(target)],
|
|
8127
8135
|
...Reflect.ownKeys(value).flatMap((key) => {
|
|
@@ -21558,6 +21566,120 @@ function getEnumerableDataValues(value) {
|
|
|
21558
21566
|
return getEnumerableDataEntries(value).map(([, entry]) => entry);
|
|
21559
21567
|
}
|
|
21560
21568
|
|
|
21569
|
+
// packages/safe-js/src/interp/globals/json-parse.ts
|
|
21570
|
+
async function parseJsonWithReviver(text, reviver, budget, context) {
|
|
21571
|
+
budget.visitNode(text.length);
|
|
21572
|
+
JSON.parse(text);
|
|
21573
|
+
const originalValues = [];
|
|
21574
|
+
let position = 0;
|
|
21575
|
+
const root = readValue();
|
|
21576
|
+
const holder = { "": root.value };
|
|
21577
|
+
const release = retainValues(budget, () => [holder, reviver, text, ...originalValues]);
|
|
21578
|
+
try {
|
|
21579
|
+
return await internalize(holder, "", root);
|
|
21580
|
+
} finally {
|
|
21581
|
+
release();
|
|
21582
|
+
}
|
|
21583
|
+
function skipWhitespace2() {
|
|
21584
|
+
while (position < text.length && " \r\n".includes(text[position])) position++;
|
|
21585
|
+
}
|
|
21586
|
+
function readToken() {
|
|
21587
|
+
const start = position;
|
|
21588
|
+
if (text[position] === '"') {
|
|
21589
|
+
position++;
|
|
21590
|
+
while (text[position] !== '"') position += text[position] === "\\" ? 2 : 1;
|
|
21591
|
+
position++;
|
|
21592
|
+
} else {
|
|
21593
|
+
while (position < text.length && !",]} \r\n".includes(text[position])) position++;
|
|
21594
|
+
}
|
|
21595
|
+
return text.slice(start, position);
|
|
21596
|
+
}
|
|
21597
|
+
function readValue() {
|
|
21598
|
+
budget.visitNode();
|
|
21599
|
+
const leave = budget.enterCall();
|
|
21600
|
+
try {
|
|
21601
|
+
skipWhitespace2();
|
|
21602
|
+
const opening = text[position];
|
|
21603
|
+
if (opening !== "[" && opening !== "{") {
|
|
21604
|
+
const source = readToken();
|
|
21605
|
+
const value2 = JSON.parse(source);
|
|
21606
|
+
if (typeof value2 === "string") budget.allocateString(value2);
|
|
21607
|
+
originalValues.push(value2);
|
|
21608
|
+
return { value: value2, source };
|
|
21609
|
+
}
|
|
21610
|
+
const array2 = opening === "[";
|
|
21611
|
+
const value = array2 ? [] : /* @__PURE__ */ Object.create(null);
|
|
21612
|
+
const children = /* @__PURE__ */ new Map();
|
|
21613
|
+
position++;
|
|
21614
|
+
skipWhitespace2();
|
|
21615
|
+
let index = 0;
|
|
21616
|
+
while (text[position] !== (array2 ? "]" : "}")) {
|
|
21617
|
+
let key;
|
|
21618
|
+
if (array2) {
|
|
21619
|
+
budget.allocateArrayLength(index + 1);
|
|
21620
|
+
key = String(index++);
|
|
21621
|
+
} else {
|
|
21622
|
+
key = JSON.parse(readToken());
|
|
21623
|
+
skipWhitespace2();
|
|
21624
|
+
position++;
|
|
21625
|
+
}
|
|
21626
|
+
const child = readValue();
|
|
21627
|
+
children.set(key, child);
|
|
21628
|
+
Object.defineProperty(value, key, { value: child.value, configurable: true, enumerable: true, writable: true });
|
|
21629
|
+
skipWhitespace2();
|
|
21630
|
+
if (text[position] === ",") {
|
|
21631
|
+
position++;
|
|
21632
|
+
skipWhitespace2();
|
|
21633
|
+
}
|
|
21634
|
+
}
|
|
21635
|
+
position++;
|
|
21636
|
+
originalValues.push(value);
|
|
21637
|
+
return { value, children };
|
|
21638
|
+
} finally {
|
|
21639
|
+
leave();
|
|
21640
|
+
}
|
|
21641
|
+
}
|
|
21642
|
+
async function internalize(holder2, key, record3) {
|
|
21643
|
+
budget.visitNode();
|
|
21644
|
+
const leave = budget.enterCall();
|
|
21645
|
+
let value;
|
|
21646
|
+
const callbackContext = {};
|
|
21647
|
+
const release2 = retainValues(budget, () => [holder2, value, callbackContext]);
|
|
21648
|
+
try {
|
|
21649
|
+
if (context?.getProperty !== void 0) value = await context.getProperty(holder2, key);
|
|
21650
|
+
else {
|
|
21651
|
+
const descriptor = getSandboxPropertyDescriptor(holder2, key, budget);
|
|
21652
|
+
value = descriptor === void 0 ? void 0 : await readPropertyDescriptor(descriptor, holder2, context);
|
|
21653
|
+
}
|
|
21654
|
+
const original = record3 !== void 0 && Object.is(value, record3.value) ? record3 : void 0;
|
|
21655
|
+
if (original?.source !== void 0) callbackContext.source = budget.allocateString(original.source);
|
|
21656
|
+
if (typeof value === "object" && value !== null) {
|
|
21657
|
+
if (Array.isArray(value)) budget.allocateArrayLength(value.length);
|
|
21658
|
+
const keys = Array.isArray(value) ? Array.from({ length: value.length }, (_, index) => String(index)) : ownEnumerableSandboxKeys(value);
|
|
21659
|
+
budget.allocateArrayLength(keys.length);
|
|
21660
|
+
for (const name of keys) {
|
|
21661
|
+
const replacement = await internalize(value, name, original?.children?.get(name));
|
|
21662
|
+
const properties = isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : value;
|
|
21663
|
+
if (replacement === void 0) Reflect.deleteProperty(properties, name);
|
|
21664
|
+
else Reflect.defineProperty(properties, name, {
|
|
21665
|
+
value: replacement,
|
|
21666
|
+
configurable: true,
|
|
21667
|
+
enumerable: true,
|
|
21668
|
+
writable: true
|
|
21669
|
+
});
|
|
21670
|
+
context?.reconcileData?.(value);
|
|
21671
|
+
}
|
|
21672
|
+
}
|
|
21673
|
+
const result = await reviver.call([key, value, callbackContext], { stack: [], thisValue: holder2 });
|
|
21674
|
+
if (isSandboxPromise(result) && result.synchronousPrefix !== void 0) await result.synchronousPrefix;
|
|
21675
|
+
return allocateProducedSandboxValue(result, budget);
|
|
21676
|
+
} finally {
|
|
21677
|
+
release2();
|
|
21678
|
+
leave();
|
|
21679
|
+
}
|
|
21680
|
+
}
|
|
21681
|
+
}
|
|
21682
|
+
|
|
21561
21683
|
// packages/safe-js/src/interp/globals/console-json.ts
|
|
21562
21684
|
function createConsoleJsonGlobals(options) {
|
|
21563
21685
|
const sink = options.sink ?? console;
|
|
@@ -21565,10 +21687,13 @@ function createConsoleJsonGlobals(options) {
|
|
|
21565
21687
|
JSON: {
|
|
21566
21688
|
parse: createSandboxClosure({
|
|
21567
21689
|
sandbox: true,
|
|
21568
|
-
|
|
21690
|
+
length: 2,
|
|
21691
|
+
call: async ([text, reviver], context) => {
|
|
21569
21692
|
const converted = sandboxString(text, options.budget, context);
|
|
21693
|
+
const source = converted instanceof Promise ? await converted : converted;
|
|
21694
|
+
if (isSandboxClosure(reviver)) return parseJsonWithReviver(source, reviver, options.budget, context);
|
|
21570
21695
|
return copyJsonToSandbox(
|
|
21571
|
-
JSON.parse(
|
|
21696
|
+
JSON.parse(source),
|
|
21572
21697
|
options.budget
|
|
21573
21698
|
);
|
|
21574
21699
|
},
|
|
@@ -22401,6 +22526,29 @@ function assertStructuredCloneable(value, seen) {
|
|
|
22401
22526
|
}
|
|
22402
22527
|
}
|
|
22403
22528
|
|
|
22529
|
+
// packages/safe-js/src/interp/globals/uri.ts
|
|
22530
|
+
var conversions = { encodeURI, encodeURIComponent, decodeURI, decodeURIComponent };
|
|
22531
|
+
function createUriGlobals(budget) {
|
|
22532
|
+
return Object.fromEntries(Object.entries(conversions).map(([name, conversion]) => {
|
|
22533
|
+
const closure = createSandboxClosure({
|
|
22534
|
+
sandbox: true,
|
|
22535
|
+
guest: true,
|
|
22536
|
+
name,
|
|
22537
|
+
length: 1,
|
|
22538
|
+
call: ([value], context) => {
|
|
22539
|
+
const convert = (text2) => {
|
|
22540
|
+
budget.visitNode(text2.length);
|
|
22541
|
+
return budget.allocateString(conversion(text2));
|
|
22542
|
+
};
|
|
22543
|
+
const text = sandboxString(value, budget, context);
|
|
22544
|
+
return typeof text === "string" ? convert(text) : text.then(convert);
|
|
22545
|
+
}
|
|
22546
|
+
});
|
|
22547
|
+
registerIntrinsicFunction(budget, closure);
|
|
22548
|
+
return [name, closure];
|
|
22549
|
+
}));
|
|
22550
|
+
}
|
|
22551
|
+
|
|
22404
22552
|
// packages/safe-js/src/interp/globals/symbol.ts
|
|
22405
22553
|
var registries = /* @__PURE__ */ new WeakMap();
|
|
22406
22554
|
function createSymbolGlobal(budget) {
|
|
@@ -22616,6 +22764,7 @@ function createBuiltinBindings(options) {
|
|
|
22616
22764
|
...createMathGlobals({ random: options.random }),
|
|
22617
22765
|
...createObjectArrayGlobals(options),
|
|
22618
22766
|
...createMiscGlobals(options),
|
|
22767
|
+
...createUriGlobals(options.budget),
|
|
22619
22768
|
...createPromiseGlobals(options),
|
|
22620
22769
|
...createRegexGlobals(options)
|
|
22621
22770
|
};
|
|
@@ -26807,6 +26956,10 @@ var KNOWN_RUNTIME_GLOBALS = [
|
|
|
26807
26956
|
"Boolean",
|
|
26808
26957
|
"BigInt",
|
|
26809
26958
|
"Date",
|
|
26959
|
+
"decodeURI",
|
|
26960
|
+
"decodeURIComponent",
|
|
26961
|
+
"encodeURI",
|
|
26962
|
+
"encodeURIComponent",
|
|
26810
26963
|
"Error",
|
|
26811
26964
|
"EvalError",
|
|
26812
26965
|
"Infinity",
|
|
@@ -39311,4 +39464,4 @@ export {
|
|
|
39311
39464
|
FileSnapshotBackend,
|
|
39312
39465
|
run
|
|
39313
39466
|
};
|
|
39314
|
-
//# sourceMappingURL=chunk-
|
|
39467
|
+
//# sourceMappingURL=chunk-SIFD2ANX.js.map
|