@poe-platform/safe-js 0.1.185 → 0.1.187
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-BWM5IA32.js → chunk-RGGF6OJD.js} +2 -2
- package/dist/safe-js/chunks/{chunk-ZOPU6AKV.js → chunk-XUGJEUQ7.js} +80 -20
- package/dist/safe-js/chunks/chunk-XUGJEUQ7.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-ZOPU6AKV.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-BWM5IA32.js.map → chunk-RGGF6OJD.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-XUGJEUQ7.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-RGGF6OJD.js.map
|
|
@@ -7495,6 +7495,8 @@ var functionProperties = /* @__PURE__ */ new WeakMap();
|
|
|
7495
7495
|
var prototypes = /* @__PURE__ */ new WeakMap();
|
|
7496
7496
|
var intrinsicPrototypes = /* @__PURE__ */ new WeakMap();
|
|
7497
7497
|
var boxedPrototypes = /* @__PURE__ */ new WeakMap();
|
|
7498
|
+
var regexPrototypes = /* @__PURE__ */ new WeakMap();
|
|
7499
|
+
var initialRegexDescriptors = /* @__PURE__ */ new WeakMap();
|
|
7498
7500
|
var intrinsicPrototypeRoots = /* @__PURE__ */ new WeakMap();
|
|
7499
7501
|
var intrinsicConstructors = /* @__PURE__ */ new WeakMap();
|
|
7500
7502
|
var initialBoxedMethods = /* @__PURE__ */ new WeakMap();
|
|
@@ -7557,6 +7559,21 @@ function installBoxedPrototype(budget, prototype, constructor, kind = typeof box
|
|
|
7557
7559
|
function getBoxedPrototype(value, budget) {
|
|
7558
7560
|
return boxedPrototypes.get(budget)?.get(typeof value);
|
|
7559
7561
|
}
|
|
7562
|
+
function installRegexPrototype(budget, prototype, constructor) {
|
|
7563
|
+
regexPrototypes.set(budget, prototype);
|
|
7564
|
+
initialRegexDescriptors.set(budget, Object.getOwnPropertyDescriptors(prototype));
|
|
7565
|
+
registerIntrinsicPrototype(budget, prototype, constructor);
|
|
7566
|
+
}
|
|
7567
|
+
function hasRegexPropertyOverride(value, keys, budget) {
|
|
7568
|
+
const initial = initialRegexDescriptors.get(budget);
|
|
7569
|
+
const prototype = regexPrototypes.get(budget);
|
|
7570
|
+
const defaultPrototype = isSandboxRegex(value) && prototype !== void 0 && getSandboxPrototype(value, budget) === prototype;
|
|
7571
|
+
return keys.some((key) => {
|
|
7572
|
+
const current = defaultPrototype ? Object.getOwnPropertyDescriptor(getRegexProperties(value), key) ?? Object.getOwnPropertyDescriptor(prototype, key) : getSandboxPropertyDescriptor(value, key, budget);
|
|
7573
|
+
const expected = initial?.[key];
|
|
7574
|
+
return expected === void 0 ? current !== void 0 : current === void 0 || current.value !== expected.value || current.get !== expected.get || current.set !== expected.set;
|
|
7575
|
+
});
|
|
7576
|
+
}
|
|
7560
7577
|
function isDefaultBoxedMethod(value, key, budget) {
|
|
7561
7578
|
const prototype = getBoxedPrototype(value, budget);
|
|
7562
7579
|
return prototype !== void 0 && initialBoxedMethods.get(prototype)?.has(key) === true && Object.getOwnPropertyDescriptor(prototype, key)?.value === initialBoxedMethods.get(prototype)?.get(key);
|
|
@@ -7575,23 +7592,24 @@ function registerIntrinsicPrototype(budget, prototype, constructor) {
|
|
|
7575
7592
|
explicit: hasExplicitSandboxPrototype(target)
|
|
7576
7593
|
})).map((record2) => ({
|
|
7577
7594
|
...record2,
|
|
7578
|
-
descriptors: new Map(
|
|
7595
|
+
descriptors: new Map(Reflect.ownKeys(record2.value).map((key) => [key, Object.getOwnPropertyDescriptor(record2.value, key)]))
|
|
7579
7596
|
}));
|
|
7580
7597
|
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;
|
|
7581
7598
|
intrinsicConstructors.set(
|
|
7582
7599
|
constructor,
|
|
7583
7600
|
() => records.every(({ target, value, descriptors, prototype: parent, explicit }) => {
|
|
7584
7601
|
const current = Object.getOwnPropertyDescriptors(value);
|
|
7585
|
-
return getSandboxPrototype(target) === parent && hasExplicitSandboxPrototype(target) === explicit &&
|
|
7602
|
+
return getSandboxPrototype(target) === parent && hasExplicitSandboxPrototype(target) === explicit && Reflect.ownKeys(current).length === descriptors.size && Reflect.ownKeys(value).every((key) => unchanged(descriptors.get(key), Object.getOwnPropertyDescriptor(value, key)));
|
|
7586
7603
|
})
|
|
7587
7604
|
);
|
|
7588
7605
|
budget.setRetainedValues(
|
|
7589
7606
|
prototype,
|
|
7590
7607
|
() => records.flatMap(({ target, value, descriptors, prototype: parent }) => [
|
|
7591
7608
|
...getSandboxPrototype(target) === parent ? [] : [getSandboxPrototype(target)],
|
|
7592
|
-
...
|
|
7593
|
-
|
|
7594
|
-
|
|
7609
|
+
...Reflect.ownKeys(value).flatMap((key) => {
|
|
7610
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
7611
|
+
return unchanged(descriptors.get(key), descriptor) ? [] : [key, descriptor.value, ...retainedAccessorClosures(descriptor)];
|
|
7612
|
+
})
|
|
7595
7613
|
])
|
|
7596
7614
|
);
|
|
7597
7615
|
}
|
|
@@ -7599,10 +7617,13 @@ function releaseObjectPrototype(budget) {
|
|
|
7599
7617
|
for (const prototype of intrinsicPrototypeRoots.get(budget) ?? []) budget.setRetainedValues(prototype, void 0);
|
|
7600
7618
|
intrinsicPrototypeRoots.delete(budget);
|
|
7601
7619
|
boxedPrototypes.delete(budget);
|
|
7620
|
+
regexPrototypes.delete(budget);
|
|
7621
|
+
initialRegexDescriptors.delete(budget);
|
|
7602
7622
|
intrinsicPrototypes.delete(budget);
|
|
7603
7623
|
}
|
|
7604
7624
|
function getSandboxPrototype(value, budget) {
|
|
7605
7625
|
if (prototypes.has(value)) return prototypes.get(value) ?? null;
|
|
7626
|
+
if (budget !== void 0 && isSandboxRegex(value)) return regexPrototypes.get(budget) ?? null;
|
|
7606
7627
|
if (budget !== void 0 && isSandboxBox(value)) {
|
|
7607
7628
|
const prototype = getBoxedPrototype(boxedValue(value), budget);
|
|
7608
7629
|
if (prototype !== void 0 && prototype !== value) return prototype;
|
|
@@ -7658,13 +7679,13 @@ function setSandboxPrototype(value, prototype, budget) {
|
|
|
7658
7679
|
if (budget !== void 0 && intrinsicPrototypes.get(budget) === value && prototype !== null) {
|
|
7659
7680
|
throw new TypeError("Object.prototype has an immutable null prototype.");
|
|
7660
7681
|
}
|
|
7661
|
-
if (!Array.isArray(value) && !isPrototypeRecord(value) || prototype !== null && !Array.isArray(prototype) && !isPrototypeRecord(prototype)) {
|
|
7682
|
+
if (!Array.isArray(value) && !isSandboxRegex(value) && !isPrototypeRecord(value) || prototype !== null && !Array.isArray(prototype) && !isPrototypeRecord(prototype)) {
|
|
7662
7683
|
throw new TypeError(
|
|
7663
7684
|
"Prototype links require ordinary sandbox objects, arrays, or guest functions."
|
|
7664
7685
|
);
|
|
7665
7686
|
}
|
|
7666
7687
|
if (prototypes.has(value) && getSandboxPrototype(value, budget) === prototype) return;
|
|
7667
|
-
if (!Object.isExtensible(isGuestClosure(value) ? materializeFunctionProperties(value) : value)) {
|
|
7688
|
+
if (!Object.isExtensible(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : value)) {
|
|
7668
7689
|
throw new TypeError("Cannot change the prototype of a non-extensible object.");
|
|
7669
7690
|
}
|
|
7670
7691
|
let depth = 0;
|
|
@@ -9571,9 +9592,9 @@ function escapeRegexSource(source, budget) {
|
|
|
9571
9592
|
text = text === "" ? "(?:)" : text;
|
|
9572
9593
|
return budget === void 0 ? text : budget.allocateString(text);
|
|
9573
9594
|
}
|
|
9574
|
-
function setRegexMember(target, property, value) {
|
|
9595
|
+
function setRegexMember(target, property, value, budget) {
|
|
9575
9596
|
const properties = getRegexProperties(target);
|
|
9576
|
-
if (!Object.hasOwn(properties, property) && (property === "source" || property === "flags" || Object.hasOwn(regexFlagProperties, property))) {
|
|
9597
|
+
if (!hasExplicitSandboxPrototype(target) && getSandboxPrototype(target, budget) === null && !Object.hasOwn(properties, property) && (property === "source" || property === "flags" || Object.hasOwn(regexFlagProperties, property))) {
|
|
9577
9598
|
throw new TypeError(`RegExp#${String(property)} is not writable.`);
|
|
9578
9599
|
}
|
|
9579
9600
|
if (!Reflect.set(properties, property, value)) throw new TypeError(`RegExp#${String(property)} is not writable.`);
|
|
@@ -10658,9 +10679,9 @@ function callStringMethodBody(value, methodName, args, budget, parent, context)
|
|
|
10658
10679
|
return budget.allocateString(result + value.slice(spanStart));
|
|
10659
10680
|
}
|
|
10660
10681
|
const regex = args[0];
|
|
10661
|
-
if (methodName === "search" && isSandboxRegex(regex) &&
|
|
10682
|
+
if (methodName === "search" && isSandboxRegex(regex) && hasRegexPropertyOverride(regex, ["exec"], budget))
|
|
10662
10683
|
return callCustomRegexSearch(value, regex, budget, context);
|
|
10663
|
-
if (methodName === "match" && isSandboxRegex(regex) && ["exec", "flags", ...Object.keys(regexFlagProperties)]
|
|
10684
|
+
if (methodName === "match" && isSandboxRegex(regex) && hasRegexPropertyOverride(regex, ["exec", "flags", ...Object.keys(regexFlagProperties)], budget))
|
|
10664
10685
|
return callObservableRegexMatch(value, regex, budget, context);
|
|
10665
10686
|
if (isSandboxRegex(regex) && (methodName === "matchAll" || methodName === "match" && !regex.flags.includes("g") && regex.lastIndex !== null && typeof regex.lastIndex === "object")) {
|
|
10666
10687
|
return callStringRegexCursor(value, methodName, regex, budget, parent, context);
|
|
@@ -10832,7 +10853,7 @@ function callReplaceLikeMethod(value, methodName, args, budget, callClosure, use
|
|
|
10832
10853
|
);
|
|
10833
10854
|
}
|
|
10834
10855
|
async function replaceRegex(value, regex, replacement, budget, callClosure, context) {
|
|
10835
|
-
if (["exec", "flags", ...Object.keys(regexFlagProperties)]
|
|
10856
|
+
if (hasRegexPropertyOverride(regex, ["exec", "flags", ...Object.keys(regexFlagProperties)], budget))
|
|
10836
10857
|
return replaceObservableRegex(value, regex, replacement, budget, callClosure, context);
|
|
10837
10858
|
if (regex.flags.includes("g")) regex.lastIndex = 0;
|
|
10838
10859
|
const cursor = regex.lastIndex;
|
|
@@ -16155,7 +16176,7 @@ function getPropertyValue(target, property, context, receiver = target) {
|
|
|
16155
16176
|
if (isSandboxGenerator(target)) return getGeneratorMember(target, property, context.budget);
|
|
16156
16177
|
if (isSandboxClosure(target)) return getClosureMemberValue(target, property, context);
|
|
16157
16178
|
if (isSandboxPromise(target)) return getPromiseMember(property, context.budget);
|
|
16158
|
-
if (isSandboxRegex(target)) return getRegexMember(target, property, context.budget, createCoercionContext(context));
|
|
16179
|
+
if (isSandboxRegex(target)) return hasExplicitSandboxPrototype(target) || getSandboxPrototype(target, context.budget) !== null ? void 0 : getRegexMember(target, property, context.budget, createCoercionContext(context));
|
|
16159
16180
|
if (!isIndexableSandboxValue(target)) {
|
|
16160
16181
|
throw new TypeError("Attempted to read a property from a non-object value.");
|
|
16161
16182
|
}
|
|
@@ -16711,7 +16732,7 @@ function hasSandboxProperty(value, key, context) {
|
|
|
16711
16732
|
while (typeof current === "object" && current !== null) {
|
|
16712
16733
|
if (isGuestHostObject(current)) return typeof key === "symbol" ? false : hasHostObjectMember(current, String(key));
|
|
16713
16734
|
if (hasOwnSandboxProperty(current, key, false)) return true;
|
|
16714
|
-
if (!((isGuestClosure(current) || Array.isArray(current)) && hasExplicitSandboxPrototype(current)) && (Array.isArray(current) || !isPlainSandboxObject(current) || isSandboxDate(current) || isFloat32Array(current) || isSandboxGenerator(current) || isSandboxCollectionIterator(current) || isSandboxRegExpIterator(current))) {
|
|
16735
|
+
if (!isSandboxRegex(current) && !((isGuestClosure(current) || Array.isArray(current)) && hasExplicitSandboxPrototype(current)) && (Array.isArray(current) || !isPlainSandboxObject(current) || isSandboxDate(current) || isFloat32Array(current) || isSandboxGenerator(current) || isSandboxCollectionIterator(current) || isSandboxRegExpIterator(current))) {
|
|
16715
16736
|
return getPropertyValue(current, key, context) !== void 0;
|
|
16716
16737
|
}
|
|
16717
16738
|
current = getSandboxPrototype(current, context.budget);
|
|
@@ -16949,7 +16970,7 @@ function setSandboxProperty(target, property, value, budget, checkInherited = tr
|
|
|
16949
16970
|
return;
|
|
16950
16971
|
}
|
|
16951
16972
|
if (isSandboxRegex(target)) {
|
|
16952
|
-
setRegexMember(target, property, value);
|
|
16973
|
+
setRegexMember(target, property, value, budget);
|
|
16953
16974
|
return;
|
|
16954
16975
|
}
|
|
16955
16976
|
if (!isIndexableSandboxValue(target)) {
|
|
@@ -19222,7 +19243,7 @@ async function objectToPrimitive(value, budget, context, joining, hint, ordinary
|
|
|
19222
19243
|
}
|
|
19223
19244
|
}
|
|
19224
19245
|
function conversionHook(value, name, budget, context) {
|
|
19225
|
-
const implicitBuiltin = !hasExplicitSandboxPrototype(value) && (Array.isArray(value) || isSandboxDate(value) || isFloat32Array(value) || sandboxErrorTypes.has(value) || isSandboxClosure(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxCollectionIterator(value) || isSandboxRegExpIterator(value) || isSandboxPromise(value) || isSandboxRegex(value) || isSandboxGenerator(value) || isGuestHostObject(value));
|
|
19246
|
+
const implicitBuiltin = !hasExplicitSandboxPrototype(value) && (Array.isArray(value) || isSandboxDate(value) || isFloat32Array(value) || sandboxErrorTypes.has(value) || isSandboxClosure(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxCollectionIterator(value) || isSandboxRegExpIterator(value) || isSandboxPromise(value) || isSandboxRegex(value) && getSandboxPrototype(value, budget) === null || isSandboxGenerator(value) || isGuestHostObject(value));
|
|
19226
19247
|
let current = value;
|
|
19227
19248
|
let depth = 0;
|
|
19228
19249
|
while (current !== null) {
|
|
@@ -34347,14 +34368,14 @@ function createRegexGlobals(options) {
|
|
|
34347
34368
|
let source = "";
|
|
34348
34369
|
let retainedSource;
|
|
34349
34370
|
let retainedFlags;
|
|
34371
|
+
let retainedPrototype;
|
|
34350
34372
|
const retained = {};
|
|
34351
|
-
options.budget.setRetainedValues(retained, () => [...args, source, retainedSource, retainedFlags]);
|
|
34373
|
+
options.budget.setRetainedValues(retained, () => [...args, source, retainedSource, retainedFlags, retainedPrototype]);
|
|
34352
34374
|
try {
|
|
34353
34375
|
const pattern = args[0];
|
|
34354
34376
|
const flags = args[1];
|
|
34355
34377
|
const read = (key) => {
|
|
34356
34378
|
const descriptor = getSandboxPropertyDescriptor(pattern, key, options.budget);
|
|
34357
|
-
if (key === "constructor" && descriptor === void 0 && isSandboxRegex(pattern)) return constructor;
|
|
34358
34379
|
if (context?.getProperty !== void 0) return context.getProperty(pattern, key);
|
|
34359
34380
|
return descriptor === void 0 ? void 0 : readPropertyDescriptor(descriptor, pattern, context);
|
|
34360
34381
|
};
|
|
@@ -34373,6 +34394,9 @@ function createRegexGlobals(options) {
|
|
|
34373
34394
|
sourceValue = retainedSource = await read("source");
|
|
34374
34395
|
if (flags === void 0) flagsValue = retainedFlags = await read("flags");
|
|
34375
34396
|
}
|
|
34397
|
+
if (construct && context?.newTarget !== void 0 && context.newTarget !== constructor) {
|
|
34398
|
+
retainedPrototype = context.getProperty !== void 0 ? await context.getProperty(context.newTarget, "prototype") : await readPropertyDescriptor(getSandboxPropertyDescriptor(context.newTarget, "prototype", options.budget) ?? { value: void 0 }, context.newTarget, context);
|
|
34399
|
+
}
|
|
34376
34400
|
source = sourceValue === void 0 ? "" : await sandboxString(sourceValue, options.budget, context);
|
|
34377
34401
|
retainedSource = void 0;
|
|
34378
34402
|
const flagText = flagsValue === void 0 ? "" : await sandboxString(flagsValue, options.budget, context);
|
|
@@ -34383,6 +34407,8 @@ function createRegexGlobals(options) {
|
|
|
34383
34407
|
0,
|
|
34384
34408
|
compilation
|
|
34385
34409
|
);
|
|
34410
|
+
if (typeof retainedPrototype === "object" && retainedPrototype !== null)
|
|
34411
|
+
setSandboxPrototype(regex, retainedPrototype, options.budget);
|
|
34386
34412
|
if (compilation !== context?.compilation) {
|
|
34387
34413
|
reconcileCompiledValues(options.budget, [regex], compilation);
|
|
34388
34414
|
}
|
|
@@ -34393,7 +34419,41 @@ function createRegexGlobals(options) {
|
|
|
34393
34419
|
operation.release();
|
|
34394
34420
|
}
|
|
34395
34421
|
};
|
|
34396
|
-
const constructor = createSandboxClosure({ sandbox: true, name: "RegExp", call: invoke(false), construct: invoke(true) });
|
|
34422
|
+
const constructor = createSandboxClosure({ guest: true, sandbox: true, name: "RegExp", length: 2, call: invoke(false), construct: invoke(true) });
|
|
34423
|
+
const prototype = /* @__PURE__ */ Object.create(null);
|
|
34424
|
+
Object.defineProperty(materializeFunctionProperties(constructor), "prototype", { value: prototype, writable: false });
|
|
34425
|
+
Object.defineProperty(prototype, "constructor", { value: constructor, writable: true, configurable: true });
|
|
34426
|
+
for (const name of ["exec", "test", "toString"]) {
|
|
34427
|
+
Object.defineProperty(prototype, name, {
|
|
34428
|
+
value: createSandboxClosure({
|
|
34429
|
+
sandbox: true,
|
|
34430
|
+
name,
|
|
34431
|
+
length: name === "toString" ? 0 : 1,
|
|
34432
|
+
call: (args, context) => callRegexMethod(context?.thisValue, name, args, options.budget, context)
|
|
34433
|
+
}),
|
|
34434
|
+
writable: true,
|
|
34435
|
+
configurable: true
|
|
34436
|
+
});
|
|
34437
|
+
}
|
|
34438
|
+
for (const name of ["source", "flags", ...Object.keys(regexFlagProperties)]) {
|
|
34439
|
+
const getter = createSandboxClosure({
|
|
34440
|
+
sandbox: true,
|
|
34441
|
+
name: `get ${name}`,
|
|
34442
|
+
length: 0,
|
|
34443
|
+
call: (_args, context) => {
|
|
34444
|
+
const receiver = context?.thisValue;
|
|
34445
|
+
if (name === "flags") {
|
|
34446
|
+
if (receiver === null || typeof receiver !== "object") throw new TypeError("RegExp flags requires an object receiver.");
|
|
34447
|
+
return getRegexMember(receiver, name, options.budget, context);
|
|
34448
|
+
}
|
|
34449
|
+
if (receiver === prototype) return name === "source" ? "(?:)" : void 0;
|
|
34450
|
+
if (!isSandboxRegex(receiver)) throw new TypeError("RegExp accessor requires a regex receiver.");
|
|
34451
|
+
return getRegexMember(receiver, name, options.budget, context);
|
|
34452
|
+
}
|
|
34453
|
+
});
|
|
34454
|
+
Object.defineProperty(prototype, name, { get: accessorAdapter(getter, "get"), configurable: true });
|
|
34455
|
+
}
|
|
34456
|
+
installRegexPrototype(options.budget, prototype, constructor);
|
|
34397
34457
|
return { RegExp: constructor };
|
|
34398
34458
|
}
|
|
34399
34459
|
|
|
@@ -36707,4 +36767,4 @@ export {
|
|
|
36707
36767
|
FileSnapshotBackend,
|
|
36708
36768
|
run
|
|
36709
36769
|
};
|
|
36710
|
-
//# sourceMappingURL=chunk-
|
|
36770
|
+
//# sourceMappingURL=chunk-XUGJEUQ7.js.map
|