@poe-platform/safe-js 0.1.375 → 0.1.376
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-M22DVZY3.js → chunk-7UITTELW.js} +200 -12
- package/dist/safe-js/chunks/chunk-7UITTELW.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-UZHOTID6.js → chunk-HRCDXQXK.js} +2 -2
- 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-M22DVZY3.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-UZHOTID6.js.map → chunk-HRCDXQXK.js.map} +0 -0
|
@@ -8411,8 +8411,9 @@ function getSandboxDataProperty(value, key, budget) {
|
|
|
8411
8411
|
}
|
|
8412
8412
|
return void 0;
|
|
8413
8413
|
}
|
|
8414
|
-
function setSandboxPrototype(value, prototype, budget) {
|
|
8414
|
+
function setSandboxPrototype(value, prototype, budget, throwOnFailure = true) {
|
|
8415
8415
|
if (budget !== void 0 && intrinsicPrototypes.get(budget) === value && prototype !== null) {
|
|
8416
|
+
if (!throwOnFailure) return false;
|
|
8416
8417
|
throw new TypeError("Object.prototype has an immutable null prototype.");
|
|
8417
8418
|
}
|
|
8418
8419
|
if (!Array.isArray(value) && !isSandboxGenerator(value) && !isSandboxDate(value) && !isSandboxPromise(value) && !isSandboxRegex(value) && !isSandboxMap(value) && !isSandboxSet(value) && !isPrototypeRecord(value) || prototype !== null && !Array.isArray(prototype) && !isSandboxGenerator(prototype) && !isSandboxDate(prototype) && !isSandboxPromise(prototype) && !isSandboxRegex(prototype) && !isSandboxMap(prototype) && !isSandboxSet(prototype) && !isPrototypeRecord(prototype)) {
|
|
@@ -8422,18 +8423,23 @@ function setSandboxPrototype(value, prototype, budget) {
|
|
|
8422
8423
|
}
|
|
8423
8424
|
if (getSandboxPrototype(value, budget) === prototype) {
|
|
8424
8425
|
if (prototype === null) prototypes.set(value, null);
|
|
8425
|
-
return;
|
|
8426
|
+
return true;
|
|
8426
8427
|
}
|
|
8427
8428
|
if (!Object.isExtensible(isSandboxGenerator(value) ? getGeneratorProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value)) {
|
|
8429
|
+
if (!throwOnFailure) return false;
|
|
8428
8430
|
throw new TypeError("Cannot change the prototype of a non-extensible object.");
|
|
8429
8431
|
}
|
|
8430
8432
|
let depth = 0;
|
|
8431
8433
|
for (let current = prototype; current !== null; current = getSandboxPrototype(current, budget)) {
|
|
8432
8434
|
budget?.visitNode();
|
|
8433
8435
|
assertSandboxDataDepth(depth++);
|
|
8434
|
-
if (current === value)
|
|
8436
|
+
if (current === value) {
|
|
8437
|
+
if (!throwOnFailure) return false;
|
|
8438
|
+
throw new TypeError("Cyclic prototype value.");
|
|
8439
|
+
}
|
|
8435
8440
|
}
|
|
8436
8441
|
prototypes.set(value, prototype);
|
|
8442
|
+
return true;
|
|
8437
8443
|
}
|
|
8438
8444
|
function isPrototypeRecord(value) {
|
|
8439
8445
|
if (isSandboxDataView(value)) return true;
|
|
@@ -8458,6 +8464,12 @@ function hasGuestObjectState(value) {
|
|
|
8458
8464
|
if (isLiveCapability(value)) return true;
|
|
8459
8465
|
if (functionProperties.has(value) || prototypes.has(value) && !hasNullObjectPrototype(value)) return true;
|
|
8460
8466
|
if (isSandboxBox(value) || isSandboxDate(value)) return false;
|
|
8467
|
+
if (Array.isArray(value) && descriptorObjects.has(value)) {
|
|
8468
|
+
return Object.getOwnPropertyNames(value).some((key) => {
|
|
8469
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
8470
|
+
return key === "length" ? descriptor.writable !== true : !descriptor.enumerable || !descriptor.configurable || !descriptor.writable;
|
|
8471
|
+
});
|
|
8472
|
+
}
|
|
8461
8473
|
return descriptorObjects.has(value) && (isNumericTypedArray(value) ? typedArrayProperties(value).map(([, descriptor]) => descriptor) : Object.values(Object.getOwnPropertyDescriptors(value))).some(
|
|
8462
8474
|
(descriptor) => !descriptor.enumerable || !descriptor.configurable || !descriptor.writable
|
|
8463
8475
|
);
|
|
@@ -15156,17 +15168,19 @@ async function definePropertiesFromObject(target, descriptors2, budget, context)
|
|
|
15156
15168
|
release();
|
|
15157
15169
|
}
|
|
15158
15170
|
}
|
|
15159
|
-
function defineDataProperty(target, key, descriptor, budget, context) {
|
|
15171
|
+
function defineDataProperty(target, key, descriptor, budget, context, throwOnFailure = true) {
|
|
15160
15172
|
budget.visitNode();
|
|
15161
15173
|
if (isNumericTypedArray(target) && typeof key !== "symbol" && isTypedArrayIndex(String(key)) && "value" in descriptor) {
|
|
15162
15174
|
const { value, ...attributes } = descriptor;
|
|
15163
|
-
Object.defineProperty(target, key, attributes);
|
|
15175
|
+
if (throwOnFailure) Object.defineProperty(target, key, attributes);
|
|
15176
|
+
else if (!Reflect.defineProperty(target, key, attributes)) return false;
|
|
15164
15177
|
return (async () => {
|
|
15165
15178
|
const release = retainValues(budget, () => [target, value]);
|
|
15166
15179
|
try {
|
|
15167
15180
|
const number = await typedArrayElement(value, typedArrayStorage(target).Native, budget, context);
|
|
15168
15181
|
Reflect.set(target, key, number);
|
|
15169
15182
|
markDescriptorObject(target);
|
|
15183
|
+
return throwOnFailure ? void 0 : true;
|
|
15170
15184
|
} finally {
|
|
15171
15185
|
release();
|
|
15172
15186
|
}
|
|
@@ -15174,17 +15188,43 @@ function defineDataProperty(target, key, descriptor, budget, context) {
|
|
|
15174
15188
|
}
|
|
15175
15189
|
const properties = objectProperties(target, true);
|
|
15176
15190
|
if (Array.isArray(properties)) {
|
|
15177
|
-
if (key === "length" && "value" in descriptor)
|
|
15178
|
-
|
|
15179
|
-
|
|
15191
|
+
if (key === "length" && "value" in descriptor) {
|
|
15192
|
+
const applyLength = (first, second) => {
|
|
15193
|
+
const length = first >>> 0;
|
|
15194
|
+
if (length !== second) throw new RangeError("Invalid array length.");
|
|
15195
|
+
budget.allocateArrayLength(length);
|
|
15196
|
+
const normalized = { ...descriptor, value: length };
|
|
15197
|
+
if (throwOnFailure) Object.defineProperty(properties, key, normalized);
|
|
15198
|
+
else {
|
|
15199
|
+
const success = Reflect.defineProperty(properties, key, normalized);
|
|
15200
|
+
markDescriptorObject(properties);
|
|
15201
|
+
return success;
|
|
15202
|
+
}
|
|
15203
|
+
markDescriptorObject(properties);
|
|
15204
|
+
return void 0;
|
|
15205
|
+
};
|
|
15206
|
+
if (typeof descriptor.value === "number") return applyLength(descriptor.value, descriptor.value);
|
|
15207
|
+
return (async () => {
|
|
15208
|
+
const release = retainValues(budget, () => [target, descriptor.value]);
|
|
15209
|
+
try {
|
|
15210
|
+
const first = await sandboxNumber(descriptor.value, budget, context);
|
|
15211
|
+
const second = await sandboxNumber(descriptor.value, budget, context);
|
|
15212
|
+
return applyLength(first, second);
|
|
15213
|
+
} finally {
|
|
15214
|
+
release();
|
|
15215
|
+
}
|
|
15216
|
+
})();
|
|
15217
|
+
} else if (typeof key !== "symbol") {
|
|
15180
15218
|
const index = Number(key);
|
|
15181
15219
|
if (Number.isInteger(index) && index >= 0 && index < 4294967295 && String(index) === key) {
|
|
15182
15220
|
budget.allocateArrayLength(index + 1);
|
|
15183
15221
|
}
|
|
15184
15222
|
}
|
|
15185
15223
|
}
|
|
15186
|
-
Object.defineProperty(properties, key, descriptor);
|
|
15224
|
+
if (throwOnFailure) Object.defineProperty(properties, key, descriptor);
|
|
15225
|
+
else if (!Reflect.defineProperty(properties, key, descriptor)) return false;
|
|
15187
15226
|
markDescriptorObject(properties);
|
|
15227
|
+
return throwOnFailure ? void 0 : true;
|
|
15188
15228
|
}
|
|
15189
15229
|
function isAssignableSandboxTarget(value) {
|
|
15190
15230
|
return typeof value === "object" && value !== null && !isSandboxClosure(value) && !isSandboxGenerator(value) && !isSandboxMap(value) && !isSandboxSet(value) && !isSandboxPromise(value) && !isSandboxRegex(value);
|
|
@@ -15728,8 +15768,21 @@ function callFunctionMethod(target, methodName, args, options, stack, context) {
|
|
|
15728
15768
|
if (typeof applyArgs !== "object") {
|
|
15729
15769
|
throw new TypeError("Function#apply requires an object or nullish arguments value.");
|
|
15730
15770
|
}
|
|
15731
|
-
if (context?.getProperty === void 0 && Array.isArray(applyArgs))
|
|
15732
|
-
|
|
15771
|
+
if (context?.getProperty === void 0 && Array.isArray(applyArgs)) {
|
|
15772
|
+
const budget = options.budget ?? new Budget();
|
|
15773
|
+
const length = applyArgs.length;
|
|
15774
|
+
budget.allocateArrayLength(length);
|
|
15775
|
+
const values = [];
|
|
15776
|
+
for (let index = 0; index < length; index++) {
|
|
15777
|
+
const descriptor = getSandboxPropertyDescriptor(applyArgs, String(index), budget);
|
|
15778
|
+
if (descriptor !== void 0 && !("value" in descriptor)) break;
|
|
15779
|
+
values.push(descriptor?.value);
|
|
15780
|
+
}
|
|
15781
|
+
if (values.length === length) {
|
|
15782
|
+
for (let index = 0; index < length; index++) budget.visitNode();
|
|
15783
|
+
return options.callClosure(target, values, stack, thisValue);
|
|
15784
|
+
}
|
|
15785
|
+
}
|
|
15733
15786
|
return (async () => {
|
|
15734
15787
|
const budget = options.budget ?? new Budget();
|
|
15735
15788
|
const invocationContext = {
|
|
@@ -26519,6 +26572,139 @@ async function dataViewIndex(value, budget, context) {
|
|
|
26519
26572
|
return index;
|
|
26520
26573
|
}
|
|
26521
26574
|
|
|
26575
|
+
// packages/safe-js/src/interp/globals/reflect.ts
|
|
26576
|
+
var nativeReflectPropertyNames = Object.getOwnPropertyNames(Reflect);
|
|
26577
|
+
function createReflectGlobal(budget) {
|
|
26578
|
+
const methods2 = {
|
|
26579
|
+
ownKeys: { length: 1, call: ([target]) => {
|
|
26580
|
+
const properties = objectProperties(target);
|
|
26581
|
+
return allocateProducedSandboxValue([...Object.getOwnPropertyNames(properties), ...ownSandboxSymbolKeys(target)], budget);
|
|
26582
|
+
} },
|
|
26583
|
+
getOwnPropertyDescriptor: { length: 2, call: async ([target, key], context) => {
|
|
26584
|
+
objectProperties(target);
|
|
26585
|
+
const property = await toPropertyKey(key, budget, context);
|
|
26586
|
+
const descriptor = Object.getOwnPropertyDescriptor(objectProperties(target), property);
|
|
26587
|
+
return descriptor === void 0 ? void 0 : allocateProducedSandboxValue(exposePropertyDescriptor(descriptor), budget);
|
|
26588
|
+
} },
|
|
26589
|
+
getPrototypeOf: { length: 1, call: ([target]) => {
|
|
26590
|
+
objectProperties(target);
|
|
26591
|
+
return getSandboxPrototype(target, budget);
|
|
26592
|
+
} },
|
|
26593
|
+
has: { length: 2, call: async ([target, key], context) => {
|
|
26594
|
+
objectProperties(target);
|
|
26595
|
+
return getSandboxPropertyDescriptor(target, await toPropertyKey(key, budget, context), budget) !== void 0;
|
|
26596
|
+
} },
|
|
26597
|
+
isExtensible: { length: 1, call: ([target]) => Object.isExtensible(objectProperties(target)) },
|
|
26598
|
+
preventExtensions: { length: 1, call: ([target]) => Reflect.preventExtensions(objectProperties(target, true)) },
|
|
26599
|
+
deleteProperty: { length: 2, call: async ([target, key], context) => {
|
|
26600
|
+
objectProperties(target, true);
|
|
26601
|
+
const property = await toPropertyKey(key, budget, context);
|
|
26602
|
+
return Reflect.deleteProperty(objectProperties(target, true), property);
|
|
26603
|
+
} },
|
|
26604
|
+
get: { length: 2, call: async (args, context) => {
|
|
26605
|
+
const [target, key] = args;
|
|
26606
|
+
objectProperties(target);
|
|
26607
|
+
const property = await toPropertyKey(key, budget, context);
|
|
26608
|
+
const descriptor = getSandboxPropertyDescriptor(target, property, budget);
|
|
26609
|
+
return descriptor === void 0 ? void 0 : readPropertyDescriptor(descriptor, args.length > 2 ? args[2] : target, context);
|
|
26610
|
+
} },
|
|
26611
|
+
defineProperty: { length: 3, call: async ([target, key, input], context) => {
|
|
26612
|
+
objectProperties(target, true);
|
|
26613
|
+
const property = await toPropertyKey(key, budget, context);
|
|
26614
|
+
const descriptor = await propertyDescriptor(input, budget, context);
|
|
26615
|
+
return await defineDataProperty(target, property, descriptor, budget, context, false);
|
|
26616
|
+
} },
|
|
26617
|
+
setPrototypeOf: { length: 2, call: ([target, prototype]) => {
|
|
26618
|
+
objectProperties(target, true);
|
|
26619
|
+
if (prototype !== null) objectProperties(prototype);
|
|
26620
|
+
return setSandboxPrototype(target, prototype, budget, false);
|
|
26621
|
+
} },
|
|
26622
|
+
set: { length: 3, call: async (args, context) => {
|
|
26623
|
+
const [target, key, value] = args;
|
|
26624
|
+
objectProperties(target, true);
|
|
26625
|
+
const property = await toPropertyKey(key, budget, context);
|
|
26626
|
+
const receiver = args.length > 3 ? args[3] : target;
|
|
26627
|
+
let descriptor;
|
|
26628
|
+
let depth = 0;
|
|
26629
|
+
for (let current = target; current !== null; current = getSandboxPrototype(current, budget)) {
|
|
26630
|
+
budget.visitNode();
|
|
26631
|
+
assertSandboxDataDepth(depth++);
|
|
26632
|
+
if (isNumericTypedArray(current) && typeof property === "string" && isTypedArrayIndex(property)) {
|
|
26633
|
+
if (current === receiver) {
|
|
26634
|
+
await setTypedArrayMember(current, property, value, budget, context);
|
|
26635
|
+
return true;
|
|
26636
|
+
}
|
|
26637
|
+
if (Object.getOwnPropertyDescriptor(current, property) === void 0) return true;
|
|
26638
|
+
}
|
|
26639
|
+
descriptor = Object.getOwnPropertyDescriptor(objectProperties(current), property);
|
|
26640
|
+
if (descriptor !== void 0) break;
|
|
26641
|
+
}
|
|
26642
|
+
if (descriptor !== void 0 && !("value" in descriptor)) {
|
|
26643
|
+
const setter = accessorClosure(descriptor.set);
|
|
26644
|
+
if (setter === void 0) return false;
|
|
26645
|
+
await context.invokeClosure(setter, [value], receiver);
|
|
26646
|
+
return true;
|
|
26647
|
+
}
|
|
26648
|
+
if (descriptor !== void 0 && !descriptor.writable) return false;
|
|
26649
|
+
if (receiver === null || typeof receiver !== "object") return false;
|
|
26650
|
+
const existing = Object.getOwnPropertyDescriptor(objectProperties(receiver, true), property);
|
|
26651
|
+
if (existing !== void 0 && (!("value" in existing) || !existing.writable)) return false;
|
|
26652
|
+
return await defineDataProperty(receiver, property, existing === void 0 ? { value, writable: true, enumerable: true, configurable: true } : { value }, budget, context, false);
|
|
26653
|
+
} },
|
|
26654
|
+
apply: { length: 3, call: ([target, receiver, values], context) => {
|
|
26655
|
+
if (!isSandboxClosure(target)) throw new TypeError("Reflect.apply requires a callable target.");
|
|
26656
|
+
objectProperties(values);
|
|
26657
|
+
return callFunctionMethod(target, "apply", [receiver, values], {
|
|
26658
|
+
budget,
|
|
26659
|
+
callClosure: (callee, args, _stack, thisValue) => context.invokeClosure(callee, args, thisValue)
|
|
26660
|
+
}, context.stack, context);
|
|
26661
|
+
} },
|
|
26662
|
+
construct: { length: 2, call: (args, context) => {
|
|
26663
|
+
const [target, values] = args;
|
|
26664
|
+
const newTarget = args.length > 2 ? args[2] : target;
|
|
26665
|
+
if (!isSandboxClosure(target) || target.construct === void 0 || !isSandboxClosure(newTarget) || newTarget.construct === void 0)
|
|
26666
|
+
throw new TypeError("Reflect.construct requires constructor targets.");
|
|
26667
|
+
objectProperties(values);
|
|
26668
|
+
return callFunctionMethod(target, "apply", [void 0, values], {
|
|
26669
|
+
budget,
|
|
26670
|
+
callClosure: (callee, items) => context.invokeClosure(callee, items, void 0, true, newTarget)
|
|
26671
|
+
}, context.stack, context);
|
|
26672
|
+
} }
|
|
26673
|
+
};
|
|
26674
|
+
const reflect = {};
|
|
26675
|
+
for (const name of nativeReflectPropertyNames) {
|
|
26676
|
+
const method = methods2[name];
|
|
26677
|
+
if (method === void 0) continue;
|
|
26678
|
+
const closure = createSandboxClosure({
|
|
26679
|
+
guest: true,
|
|
26680
|
+
sandbox: true,
|
|
26681
|
+
name,
|
|
26682
|
+
length: method.length,
|
|
26683
|
+
call: async (args, context) => {
|
|
26684
|
+
const release = retainValues(budget, () => args);
|
|
26685
|
+
try {
|
|
26686
|
+
return await method.call(args, {
|
|
26687
|
+
...context,
|
|
26688
|
+
stack: context?.stack ?? [],
|
|
26689
|
+
thisValue: context?.thisValue,
|
|
26690
|
+
invokeClosure: context?.invokeClosure ?? ((target, values, receiver, construct, newTarget) => invokeBuiltinClosure(target, values, budget, { ...context, stack: context?.stack ?? [], thisValue: receiver, newTarget }, receiver, construct))
|
|
26691
|
+
});
|
|
26692
|
+
} finally {
|
|
26693
|
+
release();
|
|
26694
|
+
}
|
|
26695
|
+
}
|
|
26696
|
+
});
|
|
26697
|
+
Object.defineProperty(reflect, name, { value: closure, writable: true, configurable: true });
|
|
26698
|
+
}
|
|
26699
|
+
Object.defineProperty(reflect, Symbol.toStringTag, { value: "Reflect", configurable: true });
|
|
26700
|
+
registerBuiltinIdentities(budget, { Reflect: reflect });
|
|
26701
|
+
for (const descriptor of Object.values(Object.getOwnPropertyDescriptors(reflect))) {
|
|
26702
|
+
if (isSandboxClosure(descriptor.value)) registerIntrinsicFunction(budget, descriptor.value);
|
|
26703
|
+
}
|
|
26704
|
+
registerIntrinsicObject(budget, reflect);
|
|
26705
|
+
return reflect;
|
|
26706
|
+
}
|
|
26707
|
+
|
|
26522
26708
|
// packages/safe-js/src/interp/globals.ts
|
|
26523
26709
|
function createBuiltinBindings(options) {
|
|
26524
26710
|
const bindings = {
|
|
@@ -26531,6 +26717,7 @@ function createBuiltinBindings(options) {
|
|
|
26531
26717
|
...createErrorGlobals({ ...options, errorPrototypes: options.errorPrototypes !== false }),
|
|
26532
26718
|
...createMathGlobals({ random: options.random, budget: options.budget }),
|
|
26533
26719
|
...createObjectArrayGlobals(options),
|
|
26720
|
+
Reflect: createReflectGlobal(options.budget),
|
|
26534
26721
|
ArrayBuffer: createArrayBufferGlobal(options.budget),
|
|
26535
26722
|
DataView: createDataViewGlobal(options.budget),
|
|
26536
26723
|
...createMiscGlobals(options),
|
|
@@ -31211,6 +31398,7 @@ var KNOWN_RUNTIME_GLOBALS = [
|
|
|
31211
31398
|
"Promise",
|
|
31212
31399
|
"RangeError",
|
|
31213
31400
|
"ReferenceError",
|
|
31401
|
+
"Reflect",
|
|
31214
31402
|
"RegExp",
|
|
31215
31403
|
"Set",
|
|
31216
31404
|
"String",
|
|
@@ -43700,4 +43888,4 @@ export {
|
|
|
43700
43888
|
FileSnapshotBackend,
|
|
43701
43889
|
run
|
|
43702
43890
|
};
|
|
43703
|
-
//# sourceMappingURL=chunk-
|
|
43891
|
+
//# sourceMappingURL=chunk-7UITTELW.js.map
|