poe-code 14.0.15 → 14.0.17
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/index.js +61 -11
- package/dist/index.js.map +3 -3
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safe-bash/dist/commands/network/output.d.ts.map +1 -1
- package/packages/safe-bash/dist/commands/network/output.js +20 -7
- package/packages/safe-bash/dist/commands/network/output.js.map +1 -1
- package/packages/safe-js/dist/chunks/{chunk-LBJGHXII.js → chunk-BW4SYRDC.js} +61 -11
- package/packages/safe-js/dist/chunks/chunk-BW4SYRDC.js.map +7 -0
- package/packages/safe-js/dist/chunks/{chunk-6ET7ZJGT.js → chunk-W6AHPZCN.js} +2 -2
- package/packages/safe-js/dist/cli.js +2 -2
- package/packages/safe-js/dist/core.js +1 -1
- package/packages/safe-js/dist/index.js +2 -2
- package/packages/safe-js/dist/interp/host-capabilities.d.ts +4 -0
- package/packages/safe-js/dist/interp/host-capabilities.js +62 -5
- package/packages/safe-js/dist/interp/interpreter.js +5 -5
- package/packages/safe-js/dist/realm.js +2 -1
- package/packages/safe-js/dist/chunks/chunk-LBJGHXII.js.map +0 -7
- /package/packages/safe-js/dist/chunks/{chunk-6ET7ZJGT.js.map → chunk-W6AHPZCN.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-BW4SYRDC.js";
|
|
31
31
|
import {
|
|
32
32
|
createFileSystem,
|
|
33
33
|
createNodeFileSystemAdapterRegistry,
|
|
@@ -8245,4 +8245,4 @@ export {
|
|
|
8245
8245
|
parseMcpConfig,
|
|
8246
8246
|
makeMcpModule
|
|
8247
8247
|
};
|
|
8248
|
-
//# sourceMappingURL=chunk-
|
|
8248
|
+
//# sourceMappingURL=chunk-W6AHPZCN.js.map
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
resolveFsConfig,
|
|
23
23
|
splitFrontmatter,
|
|
24
24
|
withBrokenPipeGuard
|
|
25
|
-
} from "./chunks/chunk-
|
|
25
|
+
} from "./chunks/chunk-W6AHPZCN.js";
|
|
26
26
|
import {
|
|
27
27
|
Budget,
|
|
28
28
|
SandboxError,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
replaceErrorStack,
|
|
35
35
|
restore,
|
|
36
36
|
run
|
|
37
|
-
} from "./chunks/chunk-
|
|
37
|
+
} from "./chunks/chunk-BW4SYRDC.js";
|
|
38
38
|
import "./chunks/chunk-7M2SJPSZ.js";
|
|
39
39
|
import "./chunks/chunk-2QRYPKQQ.js";
|
|
40
40
|
import "./chunks/chunk-4YIDX44G.js";
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
runWithSpawnUsageAccumulator,
|
|
27
27
|
splitFrontmatter,
|
|
28
28
|
supportsSpawnMode
|
|
29
|
-
} from "./chunks/chunk-
|
|
29
|
+
} from "./chunks/chunk-W6AHPZCN.js";
|
|
30
30
|
import {
|
|
31
31
|
Budget,
|
|
32
32
|
FileSnapshotBackend,
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
registerPendingHostCallPolicy,
|
|
51
51
|
restore,
|
|
52
52
|
run
|
|
53
|
-
} from "./chunks/chunk-
|
|
53
|
+
} from "./chunks/chunk-BW4SYRDC.js";
|
|
54
54
|
import "./chunks/chunk-7M2SJPSZ.js";
|
|
55
55
|
import "./chunks/chunk-2QRYPKQQ.js";
|
|
56
56
|
import "./chunks/chunk-4YIDX44G.js";
|
|
@@ -30,6 +30,8 @@ export type HostObjectDefinition = {
|
|
|
30
30
|
export type HostObjectNamedDefinition = {
|
|
31
31
|
keys(): readonly string[];
|
|
32
32
|
get(name: string): unknown;
|
|
33
|
+
set?(name: string, value: unknown): void;
|
|
34
|
+
delete?(name: string): boolean;
|
|
33
35
|
maxKeys: number;
|
|
34
36
|
maxKeyCodeUnits: number;
|
|
35
37
|
enumerable?: boolean;
|
|
@@ -39,6 +41,7 @@ export type HostObjectController = {
|
|
|
39
41
|
assertActive(): void;
|
|
40
42
|
chargeWork(units?: number): void;
|
|
41
43
|
checkLength(length: number): void;
|
|
44
|
+
checkString(value: string): void;
|
|
42
45
|
checkTemporaryDataSize(size: number): void;
|
|
43
46
|
read(operation: () => unknown, validate?: (value: unknown) => unknown): SandboxValue;
|
|
44
47
|
write(operation: (value: unknown) => void, value: SandboxValue): void;
|
|
@@ -63,6 +66,7 @@ export declare function revokeGuestCallback(callback: object, owner: object): vo
|
|
|
63
66
|
export declare function revokeHostObject(value: HostObject, owner: object): void;
|
|
64
67
|
export declare function getHostObjectMember(value: SandboxObject, key: string): SandboxValue;
|
|
65
68
|
export declare function setHostObjectMember(value: SandboxObject, key: string, entry: SandboxValue): void;
|
|
69
|
+
export declare function deleteHostObjectMember(value: SandboxObject, key: string): boolean;
|
|
66
70
|
export declare function getHostObjectKeys(value: SandboxObject): string[];
|
|
67
71
|
export declare function hasHostObjectMember(value: SandboxObject, key: string, enumerableOnly?: boolean): boolean;
|
|
68
72
|
export declare function measureHostObjectData(value: SandboxObject): number;
|
|
@@ -54,10 +54,16 @@ export function createLiveHostObject(definition, controller) {
|
|
|
54
54
|
let named;
|
|
55
55
|
if (input.named !== undefined) {
|
|
56
56
|
const data = readDataRecord(input.named, "Named host capability");
|
|
57
|
-
if (Object.keys(data).some((key) => !["keys", "get", "maxKeys", "maxKeyCodeUnits", "enumerable"].includes(key)))
|
|
57
|
+
if (Object.keys(data).some((key) => !["keys", "get", "set", "delete", "maxKeys", "maxKeyCodeUnits", "enumerable"].includes(key)))
|
|
58
58
|
throw new TypeError("Unknown named host capability field.");
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
for (const name of ["keys", "get", "set", "delete"]) {
|
|
60
|
+
const operation = data[name];
|
|
61
|
+
if (operation === undefined && (name === "set" || name === "delete"))
|
|
62
|
+
continue;
|
|
63
|
+
if (typeof operation !== "function" || types.isProxy(operation) ||
|
|
64
|
+
types.isAsyncFunction(operation) || types.isGeneratorFunction(operation))
|
|
65
|
+
throw new TypeError(`Named ${name} must be a synchronous non-generator function, not a proxy.`);
|
|
66
|
+
}
|
|
61
67
|
if (typeof data.maxKeys !== "number" ||
|
|
62
68
|
!Number.isInteger(data.maxKeys) ||
|
|
63
69
|
data.maxKeys < 1 ||
|
|
@@ -73,6 +79,8 @@ export function createLiveHostObject(definition, controller) {
|
|
|
73
79
|
named = {
|
|
74
80
|
keys: data.keys,
|
|
75
81
|
get: data.get,
|
|
82
|
+
set: data.set,
|
|
83
|
+
delete: data.delete,
|
|
76
84
|
maxKeys: data.maxKeys,
|
|
77
85
|
maxKeyCodeUnits: data.maxKeyCodeUnits,
|
|
78
86
|
enumerable: data.enumerable
|
|
@@ -208,9 +216,33 @@ export function setHostObjectMember(value, key, entry) {
|
|
|
208
216
|
state.controller.assertActive();
|
|
209
217
|
state.controller.chargeWork();
|
|
210
218
|
const property = state.properties.get(key);
|
|
211
|
-
if (property
|
|
219
|
+
if (property !== undefined) {
|
|
220
|
+
if (property.set === undefined)
|
|
221
|
+
throw new TypeError(`Host property '${key}' is not writable.`);
|
|
222
|
+
state.controller.write(property.set, entry);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (state.named?.set === undefined)
|
|
212
226
|
throw new TypeError(`Host property '${key}' is not writable.`);
|
|
213
|
-
state
|
|
227
|
+
namedMutationKeys(state, key, true);
|
|
228
|
+
state.controller.write((value) => state.named.set(key, value), entry);
|
|
229
|
+
namedKeys(state);
|
|
230
|
+
}
|
|
231
|
+
export function deleteHostObjectMember(value, key) {
|
|
232
|
+
const state = guestObjects.get(value);
|
|
233
|
+
state.controller.assertActive();
|
|
234
|
+
state.controller.chargeWork();
|
|
235
|
+
if (state.named?.delete === undefined)
|
|
236
|
+
throw new TypeError("Live host properties cannot be deleted.");
|
|
237
|
+
if (!namedMutationKeys(state, key, false).includes(key))
|
|
238
|
+
return true;
|
|
239
|
+
const deleted = state.controller.read(() => state.named.delete(key), (result) => {
|
|
240
|
+
if (typeof result !== "boolean")
|
|
241
|
+
throw new TypeError("Named delete must return a boolean.");
|
|
242
|
+
return result;
|
|
243
|
+
});
|
|
244
|
+
namedKeys(state);
|
|
245
|
+
return deleted;
|
|
214
246
|
}
|
|
215
247
|
export function getHostObjectKeys(value) {
|
|
216
248
|
const state = guestObjects.get(value);
|
|
@@ -299,6 +331,31 @@ function canonicalIndex(key) {
|
|
|
299
331
|
? index
|
|
300
332
|
: undefined;
|
|
301
333
|
}
|
|
334
|
+
function namedMutationKeys(state, key, create) {
|
|
335
|
+
state.controller.chargeWork(key.length);
|
|
336
|
+
state.controller.checkString(key);
|
|
337
|
+
if (["constructor", "prototype", "__proto__"].includes(key) ||
|
|
338
|
+
state.properties.has(key) || state.methods.has(key) ||
|
|
339
|
+
(state.indexed !== undefined && (key === "length" || canonicalIndex(key) !== undefined)))
|
|
340
|
+
throw new TypeError(`Host member '${key}' is protected from named mutation.`);
|
|
341
|
+
const named = state.named;
|
|
342
|
+
if (key.length > named.maxKeyCodeUnits)
|
|
343
|
+
throw new RangeError("Named key exceeds maximum UTF-16 code units.");
|
|
344
|
+
const keys = namedKeys(state);
|
|
345
|
+
if (create && !keys.includes(key)) {
|
|
346
|
+
const length = keys.length + 1;
|
|
347
|
+
if (length > named.maxKeys)
|
|
348
|
+
throw new RangeError("Named keys exceed maxKeys.");
|
|
349
|
+
state.controller.checkLength(length);
|
|
350
|
+
let units = key.length;
|
|
351
|
+
for (const existing of keys)
|
|
352
|
+
units += existing.length;
|
|
353
|
+
if (units > named.maxKeyCodeUnits)
|
|
354
|
+
throw new RangeError("Named keys exceed maximum UTF-16 code units.");
|
|
355
|
+
state.controller.checkTemporaryDataSize(1 + length + units);
|
|
356
|
+
}
|
|
357
|
+
return keys;
|
|
358
|
+
}
|
|
302
359
|
function namedKeys(state) {
|
|
303
360
|
const named = state.named;
|
|
304
361
|
return state.controller.read(named.keys, (value) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { promiseReplayContext } from "./promise-replay.js";
|
|
2
|
-
import { getHostObjectKeys, getHostObjectMember, hasHostObjectMember, isGuestHostObject, setHostObjectMember } from "./host-capabilities.js";
|
|
2
|
+
import { deleteHostObjectMember, getHostObjectKeys, getHostObjectMember, hasHostObjectMember, isGuestHostObject, setHostObjectMember } from "./host-capabilities.js";
|
|
3
3
|
import { sandboxString } from "./string-coercion.js";
|
|
4
4
|
import { assertPromiseExecutionAllowed } from "./promise-tracker.js";
|
|
5
5
|
import { SandboxJobQueue, runAsyncPrefix, suspendJob } from "./jobs.js";
|
|
@@ -1576,11 +1576,11 @@ async function evaluateDeleteExpression(node, context) {
|
|
|
1576
1576
|
if (!isIndexableSandboxValue(member.object)) {
|
|
1577
1577
|
throw new TypeError("Unary operator 'delete' requires a sandbox object property.");
|
|
1578
1578
|
}
|
|
1579
|
-
deleteSandboxProperty(member.object, member.property);
|
|
1579
|
+
const deleted = deleteSandboxProperty(member.object, member.property);
|
|
1580
1580
|
return {
|
|
1581
1581
|
kind: "normal",
|
|
1582
1582
|
hasValue: true,
|
|
1583
|
-
value:
|
|
1583
|
+
value: deleted
|
|
1584
1584
|
};
|
|
1585
1585
|
}
|
|
1586
1586
|
async function evaluateUpdateExpression(node, context) {
|
|
@@ -2403,13 +2403,13 @@ export function setSandboxProperty(target, property, value, budget) {
|
|
|
2403
2403
|
}
|
|
2404
2404
|
function deleteSandboxProperty(target, property) {
|
|
2405
2405
|
if (isGuestHostObject(target))
|
|
2406
|
-
|
|
2406
|
+
return deleteHostObjectMember(target, String(property));
|
|
2407
2407
|
if (isGuestClosure(target))
|
|
2408
2408
|
target = materializeFunctionProperties(target);
|
|
2409
2409
|
if (Array.isArray(target)) {
|
|
2410
2410
|
assertCollectionMutable(target);
|
|
2411
2411
|
}
|
|
2412
|
-
delete target[String(property)];
|
|
2412
|
+
return delete target[String(property)];
|
|
2413
2413
|
}
|
|
2414
2414
|
function getClosureMemberValue(target, property, context) {
|
|
2415
2415
|
return getFunctionMember(target, property, createFunctionMethodOptions(context));
|
|
@@ -313,6 +313,7 @@ class RealmState {
|
|
|
313
313
|
assertActive: this.assertOpen,
|
|
314
314
|
chargeWork: this.chargeWork,
|
|
315
315
|
checkLength: (length) => this.budget.allocateArrayLength(length),
|
|
316
|
+
checkString: (value) => { this.budget.allocateString(value); },
|
|
316
317
|
checkTemporaryDataSize: (size) => {
|
|
317
318
|
const temporary = {};
|
|
318
319
|
try {
|
|
@@ -326,7 +327,7 @@ class RealmState {
|
|
|
326
327
|
const value = this.invokeHost(operation, operation);
|
|
327
328
|
if (types.isPromise(value)) {
|
|
328
329
|
void Promise.resolve(value).catch(() => undefined);
|
|
329
|
-
throw new TypeError("Live property
|
|
330
|
+
throw new TypeError("Live property operations must be synchronous.");
|
|
330
331
|
}
|
|
331
332
|
return this.importValue(validate === undefined ? value : validate(value));
|
|
332
333
|
},
|