@poe-platform/safe-js 0.1.724 → 0.1.726
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/README.md +15 -0
- package/dist/safe-js/chunks/{chunk-ZHJPXLUJ.js → chunk-4VWGTW5F.js} +69 -11
- package/dist/safe-js/chunks/{chunk-ZHJPXLUJ.js.map → chunk-4VWGTW5F.js.map} +2 -2
- package/dist/safe-js/chunks/{chunk-TMRO2MK6.js → chunk-EYIWCEOM.js} +4 -4
- package/dist/safe-js/chunks/{chunk-BYX6GUCC.js → chunk-JVWED75K.js} +2 -2
- package/dist/safe-js/chunks/{chunk-5M2P3GUC.js → chunk-LAULA6ZA.js} +37 -10
- package/dist/safe-js/chunks/chunk-LAULA6ZA.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-GYT2ECWI.js → chunk-MFPMOTC3.js} +2 -2
- package/dist/safe-js/chunks/{chunk-WYY65M7Z.js → chunk-MLXEO7D4.js} +3 -3
- package/dist/safe-js/chunks/{chunk-2DISWAVU.js → chunk-QPG4Q7NQ.js} +3 -3
- package/dist/safe-js/chunks/{chunk-KOO6YGQG.js → chunk-T2HKPVB3.js} +77 -29
- package/dist/safe-js/chunks/chunk-T2HKPVB3.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-6OE64YMG.js → chunk-TVAZK5TQ.js} +2 -2
- package/dist/safe-js/chunks/{chunk-CSRNI5HI.js → chunk-UBLJ5GBD.js} +3 -3
- package/dist/safe-js/chunks/{chunk-GM32LIKF.js → chunk-ZB7G7QNP.js} +4 -4
- package/dist/safe-js/chunks/{chunk-E5VQVLWF.js → chunk-ZI6RZ6ZM.js} +2 -2
- package/dist/safe-js/chunks/{chunk-HG5QP5UC.js → chunk-ZUWFLRFV.js} +2 -2
- package/dist/safe-js/chunks/{cli-runtime-PHNOLXPN.js → cli-runtime-BUNU5UJA.js} +13 -13
- package/dist/safe-js/chunks/{dump-HAU2HFBZ.js → dump-NJBLBIHN.js} +4 -4
- package/dist/safe-js/chunks/{fs-6PHK3Q3V.js → fs-KSDQMVL3.js} +4 -4
- package/dist/safe-js/chunks/harness-4TVG72ZC.js +10 -0
- package/dist/safe-js/chunks/mcp-ABD5LZLV.js +11 -0
- package/dist/safe-js/chunks/migration-file-S6N7VAXE.js +12 -0
- package/dist/safe-js/chunks/restore-R2BQQ743.js +13 -0
- package/dist/safe-js/chunks/run-4W5TVAD4.js +17 -0
- package/dist/safe-js/chunks/runtime-modules-XRIAOBSC.js +10 -0
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.js +7 -7
- package/dist/safe-js/extensions.d.ts +2 -0
- package/dist/safe-js/index.js +13 -13
- package/dist/safe-js/interp/host-bridge.d.ts +1 -1
- package/dist/safe-js/parse/tokenizer.d.ts +1 -1
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-5M2P3GUC.js.map +0 -7
- package/dist/safe-js/chunks/chunk-KOO6YGQG.js.map +0 -7
- package/dist/safe-js/chunks/harness-E3FVGKIR.js +0 -10
- package/dist/safe-js/chunks/mcp-HGLB4YOP.js +0 -11
- package/dist/safe-js/chunks/migration-file-4GNB4HDL.js +0 -12
- package/dist/safe-js/chunks/restore-ZFU4NJOM.js +0 -13
- package/dist/safe-js/chunks/run-AAOCYT5M.js +0 -17
- package/dist/safe-js/chunks/runtime-modules-OPLHKWMC.js +0 -10
- /package/dist/safe-js/chunks/{chunk-TMRO2MK6.js.map → chunk-EYIWCEOM.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-BYX6GUCC.js.map → chunk-JVWED75K.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-GYT2ECWI.js.map → chunk-MFPMOTC3.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-WYY65M7Z.js.map → chunk-MLXEO7D4.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-2DISWAVU.js.map → chunk-QPG4Q7NQ.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-6OE64YMG.js.map → chunk-TVAZK5TQ.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-CSRNI5HI.js.map → chunk-UBLJ5GBD.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-GM32LIKF.js.map → chunk-ZB7G7QNP.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-E5VQVLWF.js.map → chunk-ZI6RZ6ZM.js.map} +0 -0
- /package/dist/safe-js/chunks/{chunk-HG5QP5UC.js.map → chunk-ZUWFLRFV.js.map} +0 -0
- /package/dist/safe-js/chunks/{cli-runtime-PHNOLXPN.js.map → cli-runtime-BUNU5UJA.js.map} +0 -0
- /package/dist/safe-js/chunks/{dump-HAU2HFBZ.js.map → dump-NJBLBIHN.js.map} +0 -0
- /package/dist/safe-js/chunks/{fs-6PHK3Q3V.js.map → fs-KSDQMVL3.js.map} +0 -0
- /package/dist/safe-js/chunks/{harness-E3FVGKIR.js.map → harness-4TVG72ZC.js.map} +0 -0
- /package/dist/safe-js/chunks/{mcp-HGLB4YOP.js.map → mcp-ABD5LZLV.js.map} +0 -0
- /package/dist/safe-js/chunks/{migration-file-4GNB4HDL.js.map → migration-file-S6N7VAXE.js.map} +0 -0
- /package/dist/safe-js/chunks/{restore-ZFU4NJOM.js.map → restore-R2BQQ743.js.map} +0 -0
- /package/dist/safe-js/chunks/{run-AAOCYT5M.js.map → run-4W5TVAD4.js.map} +0 -0
- /package/dist/safe-js/chunks/{runtime-modules-OPLHKWMC.js.map → runtime-modules-XRIAOBSC.js.map} +0 -0
package/README.md
CHANGED
|
@@ -53,6 +53,18 @@ console.log(result.returnValue);
|
|
|
53
53
|
|
|
54
54
|
Scripts have no ambient `process`, `require`, `fetch`, or filesystem access. Host functions still execute with the host's privileges. Register only the capabilities the script needs; this is not OS or process isolation.
|
|
55
55
|
|
|
56
|
+
`new Promise(executor)` is supported, as are the Promise static helpers and
|
|
57
|
+
`then`, `catch`, and `finally`. The executor runs synchronously with `resolve`
|
|
58
|
+
and `reject`; its return value is ignored, thrown errors reject the promise,
|
|
59
|
+
and the first resolve or reject call wins. Resolving adopts promises and
|
|
60
|
+
thenables; resolving a promise with itself rejects with a `TypeError`.
|
|
61
|
+
Executor work uses the interpreter's existing budgets, and budget exhaustion
|
|
62
|
+
remains fatal even after settlement. For example,
|
|
63
|
+
`await run("return await new Promise(resolve => resolve(42));")` returns a
|
|
64
|
+
successful result with `returnValue: 42`. Browser event and timer adapters
|
|
65
|
+
require the host to grant those capabilities; Promise construction does not
|
|
66
|
+
provide ambient browser APIs.
|
|
67
|
+
|
|
56
68
|
```js
|
|
57
69
|
const result = await run(`
|
|
58
70
|
function Counter(value) { this.value = value; }
|
|
@@ -324,6 +336,7 @@ Supply your own bounded `journal`; this does not add browser console behavior. W
|
|
|
324
336
|
| `invokeCallback(callback, { thisValue?, args? })` | Invoke a captured guest function with the realm's state, cancellation and budgets. Same operation as on the realm. |
|
|
325
337
|
| `startCallback(callback, { thisValue?, args? })` | Return separate `synchronous` and `result` promises for the same realm-owned invocation. Also available on the realm. |
|
|
326
338
|
| `releaseCallback(callback)` | Revoke the callback and release its retained guest state. |
|
|
339
|
+
| `retainCallbackArguments(operation)` | During setup, give each call independent callback wrappers in its copied arguments. Requires declared and granted `guest:retain`. The host owns these wrappers and releases each with `releaseCallback`; aliases within one call still share a wrapper. |
|
|
327
340
|
| `retainGuestArguments(operation, from)` | During setup, opt an operation into opaque argument references starting at the zero-based index `from`. Requires declared and granted `guest:retain`. Earlier arguments keep normal conversion; live host methods preserve the declaration. |
|
|
328
341
|
| `releaseGuestReference(reference)` | Revoke one reference and release its retained state. Also available on the realm. |
|
|
329
342
|
| `nestedOperation(fn)` | During setup, mark a host operation authorized to run nested source. Requires declared and granted `source:nested`. |
|
|
@@ -333,6 +346,8 @@ Use `expandos: { maxKeys, maxKeyCodeUnits, assertActive? }` to allow guest assig
|
|
|
333
346
|
|
|
334
347
|
For a timer-shaped `schedule(callback, delay, ...args)`, register `context.retainGuestArguments(schedule, 2)`. The host receives normal callback/delay values and opaque `GuestReference` handles for the remaining arguments. Pass those handles to `context.invokeCallback(callback, { args })` to recover the original guest objects and observe mutations made after scheduling. References also work as callback receivers and host return values, including cycles, closures, primitives and live host objects.
|
|
335
348
|
|
|
349
|
+
Also register `context.retainCallbackArguments(schedule)` when each scheduled task owns its callback. Different calls then receive independently releasable wrappers, even for the same guest function; normal exports keep their shared callback identity. Release a timer's wrapper after cancellation or after all its invocation phases settle. Copied callbacks count against `limits.callbacks` and data budgets. Argument-copy failure or synchronous host failure revokes that call's owned wrappers; asynchronous operations must release theirs in host cleanup. Returning a wrapper to guest code preserves the original function identity and does not release it.
|
|
350
|
+
|
|
336
351
|
For a trusted native buffer such as WebAssembly memory, use `context.createArrayBufferReference(buffer)` and return the handle from a host property or operation. Guest ArrayBuffer views then share its bytes with the host, preserving identity and bidirectional writes. Ordinary host buffers still copy. Shared, resizable, detached, subclassed and proxy buffers reject, as do buffers with own properties or symbols. After native memory growth detaches the old buffer, create a new reference to the new buffer; the old reference continues to denote the detached buffer.
|
|
337
352
|
|
|
338
353
|
Release each reference when the host no longer needs it; returning it does not release it. Retained graphs count against data budgets and `limits.guestReferences`. Synchronous native failure releases references captured for that call; asynchronous operations must release theirs in host cleanup. Close revokes all remaining references. Handles cannot be inspected, used in another realm, or serialized into replay/error data. Unmarked operations still copy values.
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
sandboxErrorTypes,
|
|
40
40
|
syntaxDiagnostics,
|
|
41
41
|
templateRealms
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-T2HKPVB3.js";
|
|
43
43
|
|
|
44
44
|
// packages/safe-js/src/interp/native-promise-properties.ts
|
|
45
45
|
import { types } from "node:util";
|
|
@@ -6440,11 +6440,30 @@ async function evaluateFunctionExpression(node, context, evaluateNode2) {
|
|
|
6440
6440
|
value: closure
|
|
6441
6441
|
};
|
|
6442
6442
|
}
|
|
6443
|
+
var captureContextHasOwn = Object.hasOwn;
|
|
6444
|
+
function createOwnedCaptureCollector(scope, sourceReference, environment, constructionState) {
|
|
6445
|
+
return (append) => {
|
|
6446
|
+
visitScopeDataRoots(scope, append);
|
|
6447
|
+
append(sourceReference);
|
|
6448
|
+
append(environment?.homeObject);
|
|
6449
|
+
append(environment?.newTarget);
|
|
6450
|
+
if (constructionState !== void 0) {
|
|
6451
|
+
append(constructionState.constructor);
|
|
6452
|
+
append(constructionState.newTarget);
|
|
6453
|
+
append(constructionState.prototype);
|
|
6454
|
+
append(constructionState.thisValue);
|
|
6455
|
+
if (constructionState.thisScope !== void 0)
|
|
6456
|
+
visitScopeDataRoots(constructionState.thisScope, append);
|
|
6457
|
+
}
|
|
6458
|
+
};
|
|
6459
|
+
}
|
|
6443
6460
|
function createInterpretedClosure(node, context, evaluateNode2, homeObject, initializeGeneratorPrototype = true) {
|
|
6461
|
+
let ownsCaptureContext = false;
|
|
6444
6462
|
if (context.callee !== void 0 || context.evalCompletion)
|
|
6445
6463
|
context = { ...context, callee: void 0, evalCompletion: void 0 };
|
|
6446
6464
|
if (node.type !== "ArrowFunctionExpression") {
|
|
6447
6465
|
context = { ...context, functionEnvironment: { homeObject } };
|
|
6466
|
+
ownsCaptureContext = true;
|
|
6448
6467
|
}
|
|
6449
6468
|
if (node.type !== "ArrowFunctionExpression" && node.generator) {
|
|
6450
6469
|
return createGeneratorClosure(node, context, evaluateNode2, initializeGeneratorPrototype);
|
|
@@ -6560,10 +6579,13 @@ function createInterpretedClosure(node, context, evaluateNode2, homeObject, init
|
|
|
6560
6579
|
}, context.budget, callContext, context.signal);
|
|
6561
6580
|
}
|
|
6562
6581
|
});
|
|
6563
|
-
registerIndexedClosureCaptures(
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6582
|
+
registerIndexedClosureCaptures(
|
|
6583
|
+
closure,
|
|
6584
|
+
ownsCaptureContext && captureContextHasOwn(context, "scope") && captureContextHasOwn(context, "sourceReference") && captureContextHasOwn(context, "functionEnvironment") ? createOwnedCaptureCollector(context.scope, context.sourceReference, context.functionEnvironment, constructionState) : (append) => {
|
|
6585
|
+
visitScopeDataRoots(context.scope, append);
|
|
6586
|
+
appendCapturedValues(append);
|
|
6587
|
+
}
|
|
6588
|
+
);
|
|
6567
6589
|
registerClosureOrigin(closure, node, context);
|
|
6568
6590
|
return closure;
|
|
6569
6591
|
}
|
|
@@ -21993,19 +22015,19 @@ function wrapCallerInjectedFunction(name, value, options, state) {
|
|
|
21993
22015
|
restored: []
|
|
21994
22016
|
};
|
|
21995
22017
|
const exportedSharedArguments = [];
|
|
21996
|
-
const copyArguments = (values) => deepCopyFromSandbox([...values], {
|
|
22018
|
+
const copyArguments = (values, wrapClosure) => deepCopyFromSandbox([...values], {
|
|
21997
22019
|
compilation,
|
|
21998
22020
|
onSharedBuffer: (value2) => {
|
|
21999
22021
|
exportedSharedArguments.push(value2);
|
|
22000
22022
|
},
|
|
22001
22023
|
unwrapHostObject: options.realm === void 0 ? void 0 : (object) => exportHostCapability(object, options.realm.owner),
|
|
22002
|
-
wrapClosure: (closure) => options.realm?.wrapCallback(closure) ?? wrapSandboxClosureForHost(
|
|
22024
|
+
wrapClosure: wrapClosure ?? ((closure) => options.realm?.wrapCallback(closure) ?? wrapSandboxClosureForHost(
|
|
22003
22025
|
closure,
|
|
22004
22026
|
stackFrames,
|
|
22005
22027
|
options.budget,
|
|
22006
22028
|
operationLease.owner,
|
|
22007
22029
|
callbacks
|
|
22008
|
-
)
|
|
22030
|
+
))
|
|
22009
22031
|
});
|
|
22010
22032
|
const captured = options.realm?.captureArguments(callable, args, copyArguments);
|
|
22011
22033
|
const hostArgs = captured?.args ?? copyArguments(args);
|
|
@@ -46493,11 +46515,35 @@ function measureSandboxDataWithSeen(values, options, seen, retainCode = false) {
|
|
|
46493
46515
|
let secondSeenCapture;
|
|
46494
46516
|
let thirdSeenCapture;
|
|
46495
46517
|
let fourthSeenCapture;
|
|
46518
|
+
let fifthSeenCapture;
|
|
46519
|
+
let sixthSeenCapture;
|
|
46520
|
+
let seventhSeenCapture;
|
|
46521
|
+
let eighthSeenCapture;
|
|
46522
|
+
let ninthSeenCapture;
|
|
46523
|
+
let tenthSeenCapture;
|
|
46524
|
+
let eleventhSeenCapture;
|
|
46525
|
+
let twelfthSeenCapture;
|
|
46526
|
+
let thirteenthSeenCapture;
|
|
46527
|
+
let fourteenthSeenCapture;
|
|
46528
|
+
let fifteenthSeenCapture;
|
|
46529
|
+
let sixteenthSeenCapture;
|
|
46496
46530
|
const appendNativeCapture = (value) => {
|
|
46497
46531
|
if (value === void 0) return;
|
|
46498
46532
|
if (typeof value === "object" && value !== null) {
|
|
46499
|
-
if (value === firstSeenCapture || value === secondSeenCapture || value === thirdSeenCapture || value === fourthSeenCapture) return;
|
|
46533
|
+
if (value === firstSeenCapture || value === secondSeenCapture || value === thirdSeenCapture || value === fourthSeenCapture || value === fifthSeenCapture || value === sixthSeenCapture || value === seventhSeenCapture || value === eighthSeenCapture || value === ninthSeenCapture || value === tenthSeenCapture || value === eleventhSeenCapture || value === twelfthSeenCapture || value === thirteenthSeenCapture || value === fourteenthSeenCapture || value === fifteenthSeenCapture || value === sixteenthSeenCapture) return;
|
|
46500
46534
|
if (seen.has(value)) {
|
|
46535
|
+
sixteenthSeenCapture = fifteenthSeenCapture;
|
|
46536
|
+
fifteenthSeenCapture = fourteenthSeenCapture;
|
|
46537
|
+
fourteenthSeenCapture = thirteenthSeenCapture;
|
|
46538
|
+
thirteenthSeenCapture = twelfthSeenCapture;
|
|
46539
|
+
twelfthSeenCapture = eleventhSeenCapture;
|
|
46540
|
+
eleventhSeenCapture = tenthSeenCapture;
|
|
46541
|
+
tenthSeenCapture = ninthSeenCapture;
|
|
46542
|
+
ninthSeenCapture = eighthSeenCapture;
|
|
46543
|
+
eighthSeenCapture = seventhSeenCapture;
|
|
46544
|
+
seventhSeenCapture = sixthSeenCapture;
|
|
46545
|
+
sixthSeenCapture = fifthSeenCapture;
|
|
46546
|
+
fifthSeenCapture = fourthSeenCapture;
|
|
46501
46547
|
fourthSeenCapture = thirdSeenCapture;
|
|
46502
46548
|
thirdSeenCapture = secondSeenCapture;
|
|
46503
46549
|
secondSeenCapture = firstSeenCapture;
|
|
@@ -47300,6 +47346,18 @@ function measureSandboxDataWithSeen(values, options, seen, retainCode = false) {
|
|
|
47300
47346
|
secondSeenCapture = void 0;
|
|
47301
47347
|
thirdSeenCapture = void 0;
|
|
47302
47348
|
fourthSeenCapture = void 0;
|
|
47349
|
+
fifthSeenCapture = void 0;
|
|
47350
|
+
sixthSeenCapture = void 0;
|
|
47351
|
+
seventhSeenCapture = void 0;
|
|
47352
|
+
eighthSeenCapture = void 0;
|
|
47353
|
+
ninthSeenCapture = void 0;
|
|
47354
|
+
tenthSeenCapture = void 0;
|
|
47355
|
+
eleventhSeenCapture = void 0;
|
|
47356
|
+
twelfthSeenCapture = void 0;
|
|
47357
|
+
thirteenthSeenCapture = void 0;
|
|
47358
|
+
fourteenthSeenCapture = void 0;
|
|
47359
|
+
fifteenthSeenCapture = void 0;
|
|
47360
|
+
sixteenthSeenCapture = void 0;
|
|
47303
47361
|
while (pendingCount > 0) {
|
|
47304
47362
|
const frame = pending[--pendingCount];
|
|
47305
47363
|
if (frame.capture !== void 0) releaseCaptures(frame.capture);
|
|
@@ -48603,7 +48661,7 @@ function materializeFunctionProperties(closure, initialProperties) {
|
|
|
48603
48661
|
name: { value: closure.name ?? "", configurable: true }
|
|
48604
48662
|
});
|
|
48605
48663
|
if (isGuestClosure(closure) && closure.construct !== void 0 && closure.boundTarget === void 0) {
|
|
48606
|
-
const prototype =
|
|
48664
|
+
const prototype = createIntrinsicObject();
|
|
48607
48665
|
nativePropertyDefineOne(prototype, "constructor", {
|
|
48608
48666
|
value: closure,
|
|
48609
48667
|
writable: true,
|
|
@@ -49280,4 +49338,4 @@ authorization of the copyright holder.
|
|
|
49280
49338
|
SPDX-License-Identifier: Unicode-3.0
|
|
49281
49339
|
|
|
49282
49340
|
*/
|
|
49283
|
-
//# sourceMappingURL=chunk-
|
|
49341
|
+
//# sourceMappingURL=chunk-4VWGTW5F.js.map
|