@poe-platform/safe-js 0.1.195 → 0.1.197
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-37QJBJ72.js → chunk-7KLRGTR4.js} +76 -6
- package/dist/safe-js/chunks/chunk-7KLRGTR4.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-6TZXNW5P.js → chunk-GMRA5QVS.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/dist/safe-js/interp/regex/parse.d.ts +3 -0
- package/dist/safe-js/snapshot/replay-data.d.ts +1 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-37QJBJ72.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-6TZXNW5P.js.map → chunk-GMRA5QVS.js.map} +0 -0
|
@@ -739,6 +739,7 @@ function measureNode(node) {
|
|
|
739
739
|
return 3 + node.value.length;
|
|
740
740
|
case "anchor":
|
|
741
741
|
case "wordBoundary":
|
|
742
|
+
case "backreference":
|
|
742
743
|
return 3;
|
|
743
744
|
case "characterClass": {
|
|
744
745
|
let usage = 5 + node.items.length;
|
|
@@ -2074,6 +2075,7 @@ var RegexParser = class {
|
|
|
2074
2075
|
guard;
|
|
2075
2076
|
captureCount = 0;
|
|
2076
2077
|
cursor = 0;
|
|
2078
|
+
totalCaptureCount;
|
|
2077
2079
|
get position() {
|
|
2078
2080
|
return this.cursor;
|
|
2079
2081
|
}
|
|
@@ -2267,8 +2269,29 @@ var RegexParser = class {
|
|
|
2267
2269
|
this.fail("Trailing escape", start);
|
|
2268
2270
|
}
|
|
2269
2271
|
const escaped = this.take();
|
|
2270
|
-
if (escaped
|
|
2271
|
-
|
|
2272
|
+
if (isDecimalDigit2(escaped)) {
|
|
2273
|
+
if (!inCharacterClass && escaped !== "0") {
|
|
2274
|
+
let end = this.position;
|
|
2275
|
+
let index = Number(escaped);
|
|
2276
|
+
while (isDecimalDigit2(this.source[end] ?? "")) {
|
|
2277
|
+
this.guard.work(1);
|
|
2278
|
+
index = index * 10 + Number(this.source[end++]);
|
|
2279
|
+
}
|
|
2280
|
+
this.totalCaptureCount ??= this.countAllCaptures();
|
|
2281
|
+
if (index <= this.totalCaptureCount) {
|
|
2282
|
+
this.position = end;
|
|
2283
|
+
this.guard.allocate(3);
|
|
2284
|
+
return { type: "backreference", index };
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
this.guard.allocate(4);
|
|
2288
|
+
if (escaped === "8" || escaped === "9") return { type: "literal", value: escaped };
|
|
2289
|
+
let code = Number(escaped);
|
|
2290
|
+
const maximum = escaped <= "3" ? 3 : 2;
|
|
2291
|
+
for (let digits = 1; digits < maximum && this.peek() >= "0" && this.peek() <= "7"; digits++) {
|
|
2292
|
+
code = code * 8 + Number(this.take());
|
|
2293
|
+
}
|
|
2294
|
+
return { type: "literal", value: String.fromCharCode(code) };
|
|
2272
2295
|
}
|
|
2273
2296
|
if (escaped === "p" || escaped === "P") {
|
|
2274
2297
|
this.fail("Unicode property escapes are not supported", start);
|
|
@@ -2324,6 +2347,21 @@ var RegexParser = class {
|
|
|
2324
2347
|
this.position = end;
|
|
2325
2348
|
return String.fromCharCode(Number.parseInt(digits, 16));
|
|
2326
2349
|
}
|
|
2350
|
+
countAllCaptures() {
|
|
2351
|
+
let count = 0;
|
|
2352
|
+
let escaped = false;
|
|
2353
|
+
let characterClass = false;
|
|
2354
|
+
for (let index = 0; index < this.source.length; index++) {
|
|
2355
|
+
this.guard.work(1);
|
|
2356
|
+
const character = this.source[index];
|
|
2357
|
+
if (escaped) escaped = false;
|
|
2358
|
+
else if (character === "\\") escaped = true;
|
|
2359
|
+
else if (character === "[") characterClass = true;
|
|
2360
|
+
else if (character === "]") characterClass = false;
|
|
2361
|
+
else if (!characterClass && character === "(" && this.source[index + 1] !== "?") count++;
|
|
2362
|
+
}
|
|
2363
|
+
return count;
|
|
2364
|
+
}
|
|
2327
2365
|
parseQuantifier() {
|
|
2328
2366
|
const character = this.peek();
|
|
2329
2367
|
if (character === "*") {
|
|
@@ -7656,6 +7694,9 @@ function getSandboxPrototype(value, budget) {
|
|
|
7656
7694
|
function hasExplicitSandboxPrototype(value) {
|
|
7657
7695
|
return prototypes.has(value);
|
|
7658
7696
|
}
|
|
7697
|
+
function hasNullObjectPrototype(value) {
|
|
7698
|
+
return prototypes.get(value) === null && !Array.isArray(value) && !isSandboxClosure(value) && !isSandboxRegex(value);
|
|
7699
|
+
}
|
|
7659
7700
|
function getSandboxPropertyDescriptor(value, key, budget) {
|
|
7660
7701
|
const hostProperties = isSandboxClosure(value) ? value.properties : void 0;
|
|
7661
7702
|
if (isSandboxClosure(value) && !isGuestClosure(value))
|
|
@@ -7737,7 +7778,7 @@ function hasGuestObjectState(value) {
|
|
|
7737
7778
|
const intrinsicUnchanged = intrinsicConstructors.get(value);
|
|
7738
7779
|
if (intrinsicUnchanged !== void 0) return !intrinsicUnchanged();
|
|
7739
7780
|
if (isLiveCapability(value)) return true;
|
|
7740
|
-
if (functionProperties.has(value) || prototypes.has(value)) return true;
|
|
7781
|
+
if (functionProperties.has(value) || prototypes.has(value) && !hasNullObjectPrototype(value)) return true;
|
|
7741
7782
|
if (isSandboxBox(value) || isSandboxDate(value)) return false;
|
|
7742
7783
|
return descriptorObjects.has(value) && Object.values(Object.getOwnPropertyDescriptors(value)).some(
|
|
7743
7784
|
(descriptor) => !descriptor.enumerable || !descriptor.configurable || !descriptor.writable
|
|
@@ -8058,6 +8099,7 @@ function serializeHeapReference(value, path, state) {
|
|
|
8058
8099
|
});
|
|
8059
8100
|
state.heap[String(id)] = {
|
|
8060
8101
|
kind: "object",
|
|
8102
|
+
...hasNullObjectPrototype(value) ? { sandboxNullPrototype: true } : {},
|
|
8061
8103
|
entries: serializeObjectEntries(value, path, state),
|
|
8062
8104
|
...symbolEntries.length === 0 ? {} : { symbolEntries },
|
|
8063
8105
|
...errorType === void 0 ? {} : { errorType }
|
|
@@ -8091,7 +8133,7 @@ function indexHeapContainers(snapshot) {
|
|
|
8091
8133
|
const heapIds = /* @__PURE__ */ new Map();
|
|
8092
8134
|
let nextId = 1;
|
|
8093
8135
|
for (const [value, stat2] of stats.entries()) {
|
|
8094
|
-
if (stat2.count > 1 || stat2.cyclic || ownSerializableSymbolKeys(value).length > 0 || isSandboxBox(value) || isSandboxRegExpIterator(value) || isSandboxRegex(value) && hasCustomRegexProperties(value) || isSandboxDate(value) || isFloat32Array(value) || Array.isArray(value) && requiresArrayEntries(value) || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
|
|
8136
|
+
if (stat2.count > 1 || stat2.cyclic || hasNullObjectPrototype(value) || ownSerializableSymbolKeys(value).length > 0 || isSandboxBox(value) || isSandboxRegExpIterator(value) || isSandboxRegex(value) && hasCustomRegexProperties(value) || isSandboxDate(value) || isFloat32Array(value) || Array.isArray(value) && requiresArrayEntries(value) || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
|
|
8095
8137
|
heapIds.set(value, nextId);
|
|
8096
8138
|
nextId += 1;
|
|
8097
8139
|
}
|
|
@@ -8277,6 +8319,8 @@ function validateDumpHeap(root, state) {
|
|
|
8277
8319
|
continue;
|
|
8278
8320
|
}
|
|
8279
8321
|
if (entry.kind === "object") {
|
|
8322
|
+
if (Object.hasOwn(entry, "sandboxNullPrototype") && entry.sandboxNullPrototype !== true)
|
|
8323
|
+
fail("invalidValue", `${path}.sandboxNullPrototype`, "invalid object prototype");
|
|
8280
8324
|
requireRecord(entry.entries, `${path}.entries`);
|
|
8281
8325
|
continue;
|
|
8282
8326
|
}
|
|
@@ -8397,7 +8441,11 @@ function validateTaggedValue(record2, path, state) {
|
|
|
8397
8441
|
return;
|
|
8398
8442
|
case "array":
|
|
8399
8443
|
case "arguments":
|
|
8444
|
+
return;
|
|
8400
8445
|
case "object":
|
|
8446
|
+
if (Object.hasOwn(record2, "sandboxNullPrototype") && record2.sandboxNullPrototype !== true)
|
|
8447
|
+
fail("invalidValue", `${path}.sandboxNullPrototype`, "invalid object prototype");
|
|
8448
|
+
return;
|
|
8401
8449
|
case "map":
|
|
8402
8450
|
case "set":
|
|
8403
8451
|
case "collection-iterator":
|
|
@@ -9351,6 +9399,22 @@ function* matchNode(node, state, context) {
|
|
|
9351
9399
|
yield { ...state, position: state.position + context.direction };
|
|
9352
9400
|
}
|
|
9353
9401
|
return;
|
|
9402
|
+
case "backreference": {
|
|
9403
|
+
const capture = state.captures[node.index - 1];
|
|
9404
|
+
if (capture === void 0) {
|
|
9405
|
+
yield state;
|
|
9406
|
+
return;
|
|
9407
|
+
}
|
|
9408
|
+
const length = capture.end - capture.start;
|
|
9409
|
+
const start = context.direction === 1 ? state.position : state.position - length;
|
|
9410
|
+
if (start < 0 || start + length > context.input.length) return;
|
|
9411
|
+
for (let offset = 0; offset < length; offset++) {
|
|
9412
|
+
charge(context);
|
|
9413
|
+
if (!charactersEqual(context.input[start + offset], context.input[capture.start + offset], context.flags.ignoreCase)) return;
|
|
9414
|
+
}
|
|
9415
|
+
yield { ...state, position: state.position + context.direction * length };
|
|
9416
|
+
return;
|
|
9417
|
+
}
|
|
9354
9418
|
case "dot":
|
|
9355
9419
|
if (characterIndex >= 0 && characterIndex < context.input.length && (context.flags.dotAll || !isLineTerminator(context.input[characterIndex]))) {
|
|
9356
9420
|
yield { ...state, position: state.position + context.direction };
|
|
@@ -17916,6 +17980,7 @@ function encodeReplayData(value, options = {}) {
|
|
|
17916
17980
|
nodes[id] = {
|
|
17917
17981
|
kind: Array.isArray(entry) ? "array" : "object",
|
|
17918
17982
|
nullPrototype: prototype === null,
|
|
17983
|
+
...hasNullObjectPrototype(entry) ? { sandboxNullPrototype: true } : {},
|
|
17919
17984
|
...errorType === void 0 ? {} : { errorType },
|
|
17920
17985
|
extensible: Object.isExtensible(entry),
|
|
17921
17986
|
properties,
|
|
@@ -18138,6 +18203,10 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
18138
18203
|
throw new TypeError("Invalid replay object metadata.");
|
|
18139
18204
|
}
|
|
18140
18205
|
const result2 = kind === "array" ? [] : Object.create(node.nullPrototype ? null : Object.prototype);
|
|
18206
|
+
if (Object.hasOwn(node, "sandboxNullPrototype")) {
|
|
18207
|
+
if (kind !== "object" || node.sandboxNullPrototype !== true) throw new TypeError("Invalid replay object prototype.");
|
|
18208
|
+
setSandboxPrototype(result2, null);
|
|
18209
|
+
}
|
|
18141
18210
|
if (Object.hasOwn(node, "errorType")) {
|
|
18142
18211
|
sandboxErrorTypes.set(result2, node.errorType);
|
|
18143
18212
|
}
|
|
@@ -21773,6 +21842,7 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
|
|
|
21773
21842
|
const copy = createPlainObject(
|
|
21774
21843
|
!cloneSandboxCollections || Object.getPrototypeOf(value) === null
|
|
21775
21844
|
);
|
|
21845
|
+
if (!state.structuredClone && hasNullObjectPrototype(value)) setSandboxPrototype(copy, null);
|
|
21776
21846
|
state.seen.set(value, copy);
|
|
21777
21847
|
const errorType = sandboxErrorTypes.get(value);
|
|
21778
21848
|
if (errorType !== void 0) sandboxErrorTypes.set(copy, errorType);
|
|
@@ -21984,7 +22054,7 @@ function copyFromSandbox(value, state, path = "<root>", options, depth = 0) {
|
|
|
21984
22054
|
if (existing !== void 0) {
|
|
21985
22055
|
return existing;
|
|
21986
22056
|
}
|
|
21987
|
-
const copy = createPlainObject(Object.getPrototypeOf(value) === null);
|
|
22057
|
+
const copy = createPlainObject(hasNullObjectPrototype(value) || Object.getPrototypeOf(value) === null);
|
|
21988
22058
|
state.seen.set(value, copy);
|
|
21989
22059
|
for (const entry of getEnumerableObjectEntries(value, path)) {
|
|
21990
22060
|
defineOwnDataProperty(
|
|
@@ -37112,4 +37182,4 @@ export {
|
|
|
37112
37182
|
FileSnapshotBackend,
|
|
37113
37183
|
run
|
|
37114
37184
|
};
|
|
37115
|
-
//# sourceMappingURL=chunk-
|
|
37185
|
+
//# sourceMappingURL=chunk-7KLRGTR4.js.map
|