@poe-platform/safe-js 0.1.135 → 0.1.136
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-SPSQUTGG.js → chunk-T55F5CLZ.js} +2 -2
- package/dist/safe-js/chunks/{chunk-RU2BCN4G.js → chunk-XO7B4P27.js} +48 -25
- package/dist/safe-js/chunks/chunk-XO7B4P27.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-RU2BCN4G.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-SPSQUTGG.js.map → chunk-T55F5CLZ.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-XO7B4P27.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-T55F5CLZ.js.map
|
|
@@ -7163,16 +7163,24 @@ function registerIntrinsicPrototype(budget, prototype, constructor) {
|
|
|
7163
7163
|
let roots = intrinsicPrototypeRoots.get(budget);
|
|
7164
7164
|
if (roots === void 0) intrinsicPrototypeRoots.set(budget, roots = /* @__PURE__ */ new Set());
|
|
7165
7165
|
roots.add(prototype);
|
|
7166
|
-
const records = [prototype,
|
|
7167
|
-
|
|
7168
|
-
|
|
7166
|
+
const records = [prototype, constructor].map((target) => ({
|
|
7167
|
+
target,
|
|
7168
|
+
value: isGuestClosure(target) ? materializeFunctionProperties(target) : target,
|
|
7169
|
+
prototype: getSandboxPrototype(target),
|
|
7170
|
+
explicit: hasExplicitSandboxPrototype(target)
|
|
7171
|
+
})).map((record2) => ({
|
|
7172
|
+
...record2,
|
|
7173
|
+
descriptors: new Map(Object.entries(Object.getOwnPropertyDescriptors(record2.value)))
|
|
7169
7174
|
}));
|
|
7170
7175
|
const unchanged = (before, after) => before !== void 0 && after !== void 0 && Object.is(before.value, after.value) && before.writable === after.writable && before.configurable === after.configurable && before.enumerable === after.enumerable;
|
|
7171
|
-
intrinsicConstructors.set(constructor, () => records.every(({ value, descriptors }) => {
|
|
7176
|
+
intrinsicConstructors.set(constructor, () => records.every(({ target, value, descriptors, prototype: parent, explicit }) => {
|
|
7172
7177
|
const current = Object.getOwnPropertyDescriptors(value);
|
|
7173
|
-
return Object.keys(current).length === descriptors.size && Object.keys(current).every((key) => unchanged(descriptors.get(key), current[key]));
|
|
7178
|
+
return getSandboxPrototype(target) === parent && hasExplicitSandboxPrototype(target) === explicit && Object.keys(current).length === descriptors.size && Object.keys(current).every((key) => unchanged(descriptors.get(key), current[key]));
|
|
7174
7179
|
}));
|
|
7175
|
-
budget.setRetainedValues(prototype, () => records.flatMap(({
|
|
7180
|
+
budget.setRetainedValues(prototype, () => records.flatMap(({ target, value, descriptors, prototype: parent }) => [
|
|
7181
|
+
...getSandboxPrototype(target) === parent ? [] : [getSandboxPrototype(target)],
|
|
7182
|
+
...Object.entries(Object.getOwnPropertyDescriptors(value)).flatMap(([key, descriptor]) => unchanged(descriptors.get(key), descriptor) ? [] : [key, descriptor.value])
|
|
7183
|
+
]));
|
|
7176
7184
|
}
|
|
7177
7185
|
function releaseObjectPrototype(budget) {
|
|
7178
7186
|
for (const prototype of intrinsicPrototypeRoots.get(budget) ?? []) budget.setRetainedValues(prototype, void 0);
|
|
@@ -7186,7 +7194,7 @@ function getSandboxPrototype(value, budget) {
|
|
|
7186
7194
|
const prototype = getBoxedPrototype(boxedValue(value), budget);
|
|
7187
7195
|
if (prototype !== void 0 && prototype !== value) return prototype;
|
|
7188
7196
|
}
|
|
7189
|
-
return budget !== void 0 && isPrototypeRecord(value) ? intrinsicPrototypes.get(budget) ?? null : null;
|
|
7197
|
+
return budget !== void 0 && !isSandboxClosure(value) && isPrototypeRecord(value) ? intrinsicPrototypes.get(budget) ?? null : null;
|
|
7190
7198
|
}
|
|
7191
7199
|
function hasExplicitSandboxPrototype(value) {
|
|
7192
7200
|
return prototypes.has(value);
|
|
@@ -7196,14 +7204,16 @@ function getSandboxDataProperty(value, key, budget) {
|
|
|
7196
7204
|
let depth = 0;
|
|
7197
7205
|
while (typeof current === "object" && current !== null) {
|
|
7198
7206
|
if (isGuestHostObject(current)) return getHostObjectMember(current, String(key));
|
|
7199
|
-
if (isGuestClosure(current))
|
|
7200
|
-
|
|
7207
|
+
if (isGuestClosure(current)) {
|
|
7208
|
+
const entry = getGuestFunctionProperty(current, String(key));
|
|
7209
|
+
if (entry !== void 0 || Object.hasOwn(current.properties ?? {}, String(key))) return entry;
|
|
7210
|
+
} else if (isSandboxClosure(current)) {
|
|
7201
7211
|
const properties = current.properties;
|
|
7202
7212
|
return properties !== void 0 && Object.hasOwn(properties, String(key)) ? properties[String(key)] : void 0;
|
|
7203
7213
|
}
|
|
7204
7214
|
if (isSandboxMap(current) || isSandboxSet(current) || isSandboxPromise(current) || isSandboxRegex(current) || isSandboxGenerator(current))
|
|
7205
7215
|
return void 0;
|
|
7206
|
-
if (Object.hasOwn(current, String(key))) return current[String(key)];
|
|
7216
|
+
if (!isSandboxClosure(current) && Object.hasOwn(current, String(key))) return current[String(key)];
|
|
7207
7217
|
current = getSandboxPrototype(current, budget);
|
|
7208
7218
|
if (current !== null) {
|
|
7209
7219
|
budget?.visitNode();
|
|
@@ -7218,7 +7228,7 @@ function setSandboxPrototype(value, prototype, budget) {
|
|
|
7218
7228
|
}
|
|
7219
7229
|
if (!isPrototypeRecord(value) || prototype !== null && !isPrototypeRecord(prototype)) {
|
|
7220
7230
|
throw new TypeError(
|
|
7221
|
-
"Prototype links require ordinary sandbox objects
|
|
7231
|
+
"Prototype links require ordinary sandbox objects or guest functions."
|
|
7222
7232
|
);
|
|
7223
7233
|
}
|
|
7224
7234
|
if (prototypes.has(value) && getSandboxPrototype(value, budget) === prototype) return;
|
|
@@ -7234,6 +7244,7 @@ function setSandboxPrototype(value, prototype, budget) {
|
|
|
7234
7244
|
prototypes.set(value, prototype);
|
|
7235
7245
|
}
|
|
7236
7246
|
function isPrototypeRecord(value) {
|
|
7247
|
+
if (isGuestClosure(value)) return true;
|
|
7237
7248
|
if (isGuestHostObject(value)) return false;
|
|
7238
7249
|
if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxPromise(value) || isSandboxRegex(value) || isSandboxSet(value))
|
|
7239
7250
|
return false;
|
|
@@ -25030,18 +25041,27 @@ function toIntegerOrInfinity(value) {
|
|
|
25030
25041
|
// packages/safe-js/src/interp/methods/function.ts
|
|
25031
25042
|
var functionMethodNames = /* @__PURE__ */ new Set(["apply", "bind", "call", "toString"]);
|
|
25032
25043
|
function getFunctionMember(target, property, options) {
|
|
25033
|
-
|
|
25034
|
-
|
|
25035
|
-
|
|
25036
|
-
if (
|
|
25037
|
-
|
|
25038
|
-
|
|
25039
|
-
|
|
25040
|
-
|
|
25041
|
-
|
|
25042
|
-
|
|
25043
|
-
|
|
25044
|
+
let current = target;
|
|
25045
|
+
let depth = 0;
|
|
25046
|
+
while (current !== null) {
|
|
25047
|
+
if (isGuestClosure(current)) {
|
|
25048
|
+
const value = getGuestFunctionProperty(current, String(property));
|
|
25049
|
+
if (value !== void 0 || Object.hasOwn(current.properties ?? {}, String(property))) return value;
|
|
25050
|
+
} else if (isSandboxClosure(current)) {
|
|
25051
|
+
if (current.properties !== void 0 && Object.hasOwn(current.properties, String(property)))
|
|
25052
|
+
return current.properties[String(property)];
|
|
25053
|
+
if (property === "length") return current.length;
|
|
25054
|
+
} else if (Object.hasOwn(current, String(property))) {
|
|
25055
|
+
return current[String(property)];
|
|
25056
|
+
}
|
|
25057
|
+
if (isSandboxClosure(current) && !hasExplicitSandboxPrototype(current)) break;
|
|
25058
|
+
current = getSandboxPrototype(current, options.budget);
|
|
25059
|
+
if (current !== null) {
|
|
25060
|
+
options.budget?.visitNode();
|
|
25061
|
+
assertSandboxDataDepth(++depth);
|
|
25062
|
+
}
|
|
25044
25063
|
}
|
|
25064
|
+
if (current === null) return void 0;
|
|
25045
25065
|
if (property === "toString" && runResources.getStore()?.functionSourceText === false) return void 0;
|
|
25046
25066
|
if (!isFunctionMethodName(property)) {
|
|
25047
25067
|
return void 0;
|
|
@@ -25067,7 +25087,7 @@ function callFunctionMethod(target, methodName, args, options, stack) {
|
|
|
25067
25087
|
const thisValue = args[0];
|
|
25068
25088
|
if (methodName === "bind") {
|
|
25069
25089
|
const boundArgs = args.slice(1);
|
|
25070
|
-
|
|
25090
|
+
const bound = createSandboxClosure({
|
|
25071
25091
|
guest: true,
|
|
25072
25092
|
sandbox: true,
|
|
25073
25093
|
name: `bound ${target.name ?? ""}`,
|
|
@@ -25085,6 +25105,9 @@ function callFunctionMethod(target, methodName, args, options, stack) {
|
|
|
25085
25105
|
)
|
|
25086
25106
|
}
|
|
25087
25107
|
});
|
|
25108
|
+
if (hasExplicitSandboxPrototype(target))
|
|
25109
|
+
setSandboxPrototype(bound, getSandboxPrototype(target, options.budget), options.budget);
|
|
25110
|
+
return bound;
|
|
25088
25111
|
}
|
|
25089
25112
|
if (methodName === "call") {
|
|
25090
25113
|
return options.callClosure(target, args.slice(1), stack, thisValue);
|
|
@@ -28935,7 +28958,7 @@ function hasSandboxProperty(value, key, context) {
|
|
|
28935
28958
|
while (typeof current === "object" && current !== null) {
|
|
28936
28959
|
if (isGuestHostObject(current)) return hasHostObjectMember(current, key);
|
|
28937
28960
|
if (hasOwnSandboxProperty(current, key, false)) return true;
|
|
28938
|
-
if (Array.isArray(current) || !isPlainSandboxObject(current) || isSandboxDate(current) || isFloat32Array(current) || isSandboxGenerator(current) || isSandboxCollectionIterator(current)) {
|
|
28961
|
+
if (!(isGuestClosure(current) && hasExplicitSandboxPrototype(current)) && (Array.isArray(current) || !isPlainSandboxObject(current) || isSandboxDate(current) || isFloat32Array(current) || isSandboxGenerator(current) || isSandboxCollectionIterator(current))) {
|
|
28939
28962
|
return getPropertyValue(current, key, context) !== void 0;
|
|
28940
28963
|
}
|
|
28941
28964
|
current = getSandboxPrototype(current, context.budget);
|
|
@@ -33992,4 +34015,4 @@ export {
|
|
|
33992
34015
|
FileSnapshotBackend,
|
|
33993
34016
|
run
|
|
33994
34017
|
};
|
|
33995
|
-
//# sourceMappingURL=chunk-
|
|
34018
|
+
//# sourceMappingURL=chunk-XO7B4P27.js.map
|