@poe-platform/safe-js 0.1.168 → 0.1.170
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-Y6BZO53S.js → chunk-MZW43CYT.js} +2 -2
- package/dist/safe-js/chunks/{chunk-6QBK7Y47.js → chunk-WPI4GGVU.js} +311 -136
- package/dist/safe-js/chunks/chunk-WPI4GGVU.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/dist/safe-js/interp/regexp-properties.d.ts +3 -0
- package/dist/safe-js/interp/values.d.ts +1 -0
- package/dist/safe-js/snapshot/regexp-properties.d.ts +18 -0
- package/dist/safe-js/snapshot/replay-data.d.ts +3 -2
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-6QBK7Y47.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-Y6BZO53S.js.map → chunk-MZW43CYT.js.map} +0 -0
|
@@ -6165,87 +6165,6 @@ function matchingOpeningPunctuator(value) {
|
|
|
6165
6165
|
return "{";
|
|
6166
6166
|
}
|
|
6167
6167
|
|
|
6168
|
-
// packages/safe-js/src/extensions.ts
|
|
6169
|
-
import { types } from "node:util";
|
|
6170
|
-
var definitions = /* @__PURE__ */ new WeakMap();
|
|
6171
|
-
function readDataRecord(value, label) {
|
|
6172
|
-
if (typeof value !== "object" || value === null || types.isProxy(value)) {
|
|
6173
|
-
throw new TypeError(`${label} must be a plain data record.`);
|
|
6174
|
-
}
|
|
6175
|
-
const prototype = Object.getPrototypeOf(value);
|
|
6176
|
-
if (prototype !== null && prototype !== Object.prototype) {
|
|
6177
|
-
throw new TypeError(`${label} must be a plain data record.`);
|
|
6178
|
-
}
|
|
6179
|
-
const keys = Reflect.ownKeys(value);
|
|
6180
|
-
if (keys.length > 4096) throw new RangeError(`${label} has too many fields.`);
|
|
6181
|
-
const result = /* @__PURE__ */ Object.create(null);
|
|
6182
|
-
for (const key of keys) {
|
|
6183
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
6184
|
-
if (typeof key !== "string" || !("value" in descriptor)) {
|
|
6185
|
-
throw new TypeError(`${label} requires string-keyed data properties, not accessors.`);
|
|
6186
|
-
}
|
|
6187
|
-
result[key] = descriptor.value;
|
|
6188
|
-
}
|
|
6189
|
-
return result;
|
|
6190
|
-
}
|
|
6191
|
-
function readStringList(value, label) {
|
|
6192
|
-
if (!Array.isArray(value) || types.isProxy(value) || value.length > 4096) {
|
|
6193
|
-
throw new TypeError(`${label} must be a bounded string array.`);
|
|
6194
|
-
}
|
|
6195
|
-
const result = [];
|
|
6196
|
-
for (let index = 0; index < value.length; index++) {
|
|
6197
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, String(index));
|
|
6198
|
-
if (descriptor === void 0 || !("value" in descriptor) || typeof descriptor.value !== "string" || descriptor.value.length === 0) {
|
|
6199
|
-
throw new TypeError(`${label} requires nonempty string data properties.`);
|
|
6200
|
-
}
|
|
6201
|
-
if (result.includes(descriptor.value))
|
|
6202
|
-
throw new TypeError(`${label} contains a duplicate name.`);
|
|
6203
|
-
result.push(descriptor.value);
|
|
6204
|
-
}
|
|
6205
|
-
if (Reflect.ownKeys(value).length !== result.length + 1)
|
|
6206
|
-
throw new TypeError(`${label} has unexpected fields.`);
|
|
6207
|
-
return Object.freeze(result);
|
|
6208
|
-
}
|
|
6209
|
-
function defineExtension(definition) {
|
|
6210
|
-
const input = readDataRecord(definition, "Extension definition");
|
|
6211
|
-
if (Object.keys(input).some((key) => key !== "manifest" && key !== "setup"))
|
|
6212
|
-
throw new TypeError("Unknown extension definition field.");
|
|
6213
|
-
if (typeof input.setup !== "function") throw new TypeError("Extension setup must be a function.");
|
|
6214
|
-
if (types.isAsyncFunction(input.setup))
|
|
6215
|
-
throw new TypeError("Extension setup must be synchronous.");
|
|
6216
|
-
const manifest = readDataRecord(input.manifest, "Extension manifest");
|
|
6217
|
-
if (Object.keys(manifest).some(
|
|
6218
|
-
(key) => !["version", "name", "capabilities", "globals", "modules"].includes(key)
|
|
6219
|
-
))
|
|
6220
|
-
throw new TypeError("Unknown extension manifest field.");
|
|
6221
|
-
if (manifest.version !== 1) throw new TypeError("Unsupported extension manifest version.");
|
|
6222
|
-
if (typeof manifest.name !== "string" || manifest.name.length === 0 || manifest.name.length > 256)
|
|
6223
|
-
throw new TypeError("Extension name must be a nonempty bounded string.");
|
|
6224
|
-
const modules = /* @__PURE__ */ Object.create(null);
|
|
6225
|
-
for (const [name, exports] of Object.entries(
|
|
6226
|
-
readDataRecord(manifest.modules ?? {}, "Extension modules")
|
|
6227
|
-
)) {
|
|
6228
|
-
if (name.length === 0) throw new TypeError("Module names must be nonempty.");
|
|
6229
|
-
modules[name] = readStringList(exports, `Module '${name}' exports`);
|
|
6230
|
-
}
|
|
6231
|
-
const extension = Object.freeze({
|
|
6232
|
-
manifest: Object.freeze({
|
|
6233
|
-
version: 1,
|
|
6234
|
-
name: manifest.name,
|
|
6235
|
-
capabilities: readStringList(manifest.capabilities ?? [], "Extension capabilities"),
|
|
6236
|
-
globals: readStringList(manifest.globals ?? [], "Extension globals"),
|
|
6237
|
-
modules: Object.freeze(modules)
|
|
6238
|
-
})
|
|
6239
|
-
});
|
|
6240
|
-
definitions.set(extension, input.setup);
|
|
6241
|
-
return extension;
|
|
6242
|
-
}
|
|
6243
|
-
function getExtensionSetup(extension) {
|
|
6244
|
-
const setup = definitions.get(extension);
|
|
6245
|
-
if (setup === void 0) throw new TypeError("Extensions must be created by defineExtension.");
|
|
6246
|
-
return setup;
|
|
6247
|
-
}
|
|
6248
|
-
|
|
6249
6168
|
// packages/safe-js/src/observability/otel.ts
|
|
6250
6169
|
var noopOtelSink = {
|
|
6251
6170
|
startSpan: () => noopOtelSpan,
|
|
@@ -6337,6 +6256,87 @@ function readErrorMessage(error) {
|
|
|
6337
6256
|
return error instanceof Error ? error.message : String(error);
|
|
6338
6257
|
}
|
|
6339
6258
|
|
|
6259
|
+
// packages/safe-js/src/extensions.ts
|
|
6260
|
+
import { types } from "node:util";
|
|
6261
|
+
var definitions = /* @__PURE__ */ new WeakMap();
|
|
6262
|
+
function readDataRecord(value, label) {
|
|
6263
|
+
if (typeof value !== "object" || value === null || types.isProxy(value)) {
|
|
6264
|
+
throw new TypeError(`${label} must be a plain data record.`);
|
|
6265
|
+
}
|
|
6266
|
+
const prototype = Object.getPrototypeOf(value);
|
|
6267
|
+
if (prototype !== null && prototype !== Object.prototype) {
|
|
6268
|
+
throw new TypeError(`${label} must be a plain data record.`);
|
|
6269
|
+
}
|
|
6270
|
+
const keys = Reflect.ownKeys(value);
|
|
6271
|
+
if (keys.length > 4096) throw new RangeError(`${label} has too many fields.`);
|
|
6272
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
6273
|
+
for (const key of keys) {
|
|
6274
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
6275
|
+
if (typeof key !== "string" || !("value" in descriptor)) {
|
|
6276
|
+
throw new TypeError(`${label} requires string-keyed data properties, not accessors.`);
|
|
6277
|
+
}
|
|
6278
|
+
result[key] = descriptor.value;
|
|
6279
|
+
}
|
|
6280
|
+
return result;
|
|
6281
|
+
}
|
|
6282
|
+
function readStringList(value, label) {
|
|
6283
|
+
if (!Array.isArray(value) || types.isProxy(value) || value.length > 4096) {
|
|
6284
|
+
throw new TypeError(`${label} must be a bounded string array.`);
|
|
6285
|
+
}
|
|
6286
|
+
const result = [];
|
|
6287
|
+
for (let index = 0; index < value.length; index++) {
|
|
6288
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, String(index));
|
|
6289
|
+
if (descriptor === void 0 || !("value" in descriptor) || typeof descriptor.value !== "string" || descriptor.value.length === 0) {
|
|
6290
|
+
throw new TypeError(`${label} requires nonempty string data properties.`);
|
|
6291
|
+
}
|
|
6292
|
+
if (result.includes(descriptor.value))
|
|
6293
|
+
throw new TypeError(`${label} contains a duplicate name.`);
|
|
6294
|
+
result.push(descriptor.value);
|
|
6295
|
+
}
|
|
6296
|
+
if (Reflect.ownKeys(value).length !== result.length + 1)
|
|
6297
|
+
throw new TypeError(`${label} has unexpected fields.`);
|
|
6298
|
+
return Object.freeze(result);
|
|
6299
|
+
}
|
|
6300
|
+
function defineExtension(definition) {
|
|
6301
|
+
const input = readDataRecord(definition, "Extension definition");
|
|
6302
|
+
if (Object.keys(input).some((key) => key !== "manifest" && key !== "setup"))
|
|
6303
|
+
throw new TypeError("Unknown extension definition field.");
|
|
6304
|
+
if (typeof input.setup !== "function") throw new TypeError("Extension setup must be a function.");
|
|
6305
|
+
if (types.isAsyncFunction(input.setup))
|
|
6306
|
+
throw new TypeError("Extension setup must be synchronous.");
|
|
6307
|
+
const manifest = readDataRecord(input.manifest, "Extension manifest");
|
|
6308
|
+
if (Object.keys(manifest).some(
|
|
6309
|
+
(key) => !["version", "name", "capabilities", "globals", "modules"].includes(key)
|
|
6310
|
+
))
|
|
6311
|
+
throw new TypeError("Unknown extension manifest field.");
|
|
6312
|
+
if (manifest.version !== 1) throw new TypeError("Unsupported extension manifest version.");
|
|
6313
|
+
if (typeof manifest.name !== "string" || manifest.name.length === 0 || manifest.name.length > 256)
|
|
6314
|
+
throw new TypeError("Extension name must be a nonempty bounded string.");
|
|
6315
|
+
const modules = /* @__PURE__ */ Object.create(null);
|
|
6316
|
+
for (const [name, exports] of Object.entries(
|
|
6317
|
+
readDataRecord(manifest.modules ?? {}, "Extension modules")
|
|
6318
|
+
)) {
|
|
6319
|
+
if (name.length === 0) throw new TypeError("Module names must be nonempty.");
|
|
6320
|
+
modules[name] = readStringList(exports, `Module '${name}' exports`);
|
|
6321
|
+
}
|
|
6322
|
+
const extension = Object.freeze({
|
|
6323
|
+
manifest: Object.freeze({
|
|
6324
|
+
version: 1,
|
|
6325
|
+
name: manifest.name,
|
|
6326
|
+
capabilities: readStringList(manifest.capabilities ?? [], "Extension capabilities"),
|
|
6327
|
+
globals: readStringList(manifest.globals ?? [], "Extension globals"),
|
|
6328
|
+
modules: Object.freeze(modules)
|
|
6329
|
+
})
|
|
6330
|
+
});
|
|
6331
|
+
definitions.set(extension, input.setup);
|
|
6332
|
+
return extension;
|
|
6333
|
+
}
|
|
6334
|
+
function getExtensionSetup(extension) {
|
|
6335
|
+
const setup = definitions.get(extension);
|
|
6336
|
+
if (setup === void 0) throw new TypeError("Extensions must be created by defineExtension.");
|
|
6337
|
+
return setup;
|
|
6338
|
+
}
|
|
6339
|
+
|
|
6340
6340
|
// packages/safe-js/src/snapshot/policy.ts
|
|
6341
6341
|
var MODULE_PENDING_HOST_CALL_POLICIES = Object.assign(
|
|
6342
6342
|
/* @__PURE__ */ Object.create(null),
|
|
@@ -6583,6 +6583,14 @@ function serializedDateTime(value) {
|
|
|
6583
6583
|
// packages/safe-js/src/interp/internal-symbols.ts
|
|
6584
6584
|
var internalSymbols = /* @__PURE__ */ new Set();
|
|
6585
6585
|
|
|
6586
|
+
// packages/safe-js/src/interp/regexp-properties.ts
|
|
6587
|
+
var regexGuestProperties = /* @__PURE__ */ new WeakMap();
|
|
6588
|
+
function getRegexProperties(value) {
|
|
6589
|
+
const properties = regexGuestProperties.get(value);
|
|
6590
|
+
if (properties === void 0) throw new TypeError("Invalid sandbox RegExp storage.");
|
|
6591
|
+
return properties;
|
|
6592
|
+
}
|
|
6593
|
+
|
|
6586
6594
|
// packages/safe-js/src/interp/accessors.ts
|
|
6587
6595
|
var accessorClosures = /* @__PURE__ */ new WeakMap();
|
|
6588
6596
|
var getterAdapters = /* @__PURE__ */ new WeakMap();
|
|
@@ -7236,6 +7244,96 @@ var wellKnownSymbols = Object.freeze({
|
|
|
7236
7244
|
unscopables: Symbol.unscopables
|
|
7237
7245
|
});
|
|
7238
7246
|
|
|
7247
|
+
// packages/safe-js/src/snapshot/symbols.ts
|
|
7248
|
+
function symbolData(value) {
|
|
7249
|
+
const wellKnown = Object.keys(wellKnownSymbols).find((key) => wellKnownSymbols[key] === value);
|
|
7250
|
+
return {
|
|
7251
|
+
kind: "symbol",
|
|
7252
|
+
...wellKnown === void 0 ? value.description === void 0 ? {} : { description: value.description } : { wellKnown }
|
|
7253
|
+
};
|
|
7254
|
+
}
|
|
7255
|
+
function serializeSymbol(value, heapIds, heap) {
|
|
7256
|
+
let id = heapIds.get(value);
|
|
7257
|
+
if (id === void 0) {
|
|
7258
|
+
id = heapIds.size + 1;
|
|
7259
|
+
heapIds.set(value, id);
|
|
7260
|
+
heap[String(id)] = symbolData(value);
|
|
7261
|
+
}
|
|
7262
|
+
return { kind: "ref", id };
|
|
7263
|
+
}
|
|
7264
|
+
function ownSerializableSymbolKeys(value) {
|
|
7265
|
+
return Object.getOwnPropertySymbols(value).filter((key) => !internalSymbols.has(key));
|
|
7266
|
+
}
|
|
7267
|
+
function serializeSymbolProperties(value, encode) {
|
|
7268
|
+
return ownSerializableSymbolKeys(value).map((key) => {
|
|
7269
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
7270
|
+
if (!("value" in descriptor)) throw new TypeError("Symbol accessor properties cannot be serialized.");
|
|
7271
|
+
return [encode(key), { value: encode(descriptor.value), enumerable: descriptor.enumerable === true, writable: descriptor.writable === true, configurable: descriptor.configurable === true }];
|
|
7272
|
+
});
|
|
7273
|
+
}
|
|
7274
|
+
function restoreSymbolProperties(target, entries, decode) {
|
|
7275
|
+
for (const [key, descriptor] of entries ?? []) {
|
|
7276
|
+
const symbol = decode(key);
|
|
7277
|
+
if (typeof symbol !== "symbol") throw new TypeError("Expected a symbol property key");
|
|
7278
|
+
Object.defineProperty(target, symbol, { ...descriptor, value: decode(descriptor.value) });
|
|
7279
|
+
}
|
|
7280
|
+
}
|
|
7281
|
+
|
|
7282
|
+
// packages/safe-js/src/snapshot/regexp-properties.ts
|
|
7283
|
+
function hasCustomRegexProperties(value) {
|
|
7284
|
+
const properties = getRegexProperties(value);
|
|
7285
|
+
return Reflect.ownKeys(properties).length !== 1 || !Object.isExtensible(properties) || Object.getOwnPropertyDescriptor(properties, "lastIndex")?.writable !== true;
|
|
7286
|
+
}
|
|
7287
|
+
function serializeRegexProperties(value, encode) {
|
|
7288
|
+
if (!hasCustomRegexProperties(value)) return {};
|
|
7289
|
+
const source = getRegexProperties(value);
|
|
7290
|
+
const properties = /* @__PURE__ */ Object.create(null);
|
|
7291
|
+
for (const key of Object.getOwnPropertyNames(source)) {
|
|
7292
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, key);
|
|
7293
|
+
if (!("value" in descriptor)) throw new TypeError("RegExp accessor properties cannot be serialized as data.");
|
|
7294
|
+
properties[key] = {
|
|
7295
|
+
value: encode(descriptor.value),
|
|
7296
|
+
enumerable: descriptor.enumerable === true,
|
|
7297
|
+
configurable: descriptor.configurable === true,
|
|
7298
|
+
writable: descriptor.writable === true
|
|
7299
|
+
};
|
|
7300
|
+
}
|
|
7301
|
+
const symbolEntries = serializeSymbolProperties(source, encode);
|
|
7302
|
+
return {
|
|
7303
|
+
properties,
|
|
7304
|
+
...symbolEntries.length === 0 ? {} : { symbolEntries },
|
|
7305
|
+
...Object.isExtensible(source) ? {} : { extensible: false }
|
|
7306
|
+
};
|
|
7307
|
+
}
|
|
7308
|
+
function validateRegexProperties(data) {
|
|
7309
|
+
const descriptor = (value) => {
|
|
7310
|
+
if (typeof value !== "object" || value === null || Array.isArray(value) || !Object.hasOwn(value, "value") || !["enumerable", "configurable", "writable"].every((key) => Object.hasOwn(value, key) && typeof value[key] === "boolean") || Object.keys(value).some((key) => !["value", "enumerable", "configurable", "writable"].includes(key)))
|
|
7311
|
+
throw new TypeError("Invalid RegExp data property descriptor.");
|
|
7312
|
+
};
|
|
7313
|
+
if (data.extensible !== void 0 && typeof data.extensible !== "boolean")
|
|
7314
|
+
throw new TypeError("Invalid RegExp extensibility.");
|
|
7315
|
+
if (data.properties !== void 0) {
|
|
7316
|
+
if (typeof data.properties !== "object" || data.properties === null || Array.isArray(data.properties))
|
|
7317
|
+
throw new TypeError("Invalid RegExp property data.");
|
|
7318
|
+
for (const entry of Object.values(data.properties)) descriptor(entry);
|
|
7319
|
+
}
|
|
7320
|
+
if (data.symbolEntries !== void 0) {
|
|
7321
|
+
if (!Array.isArray(data.symbolEntries)) throw new TypeError("Invalid RegExp symbol properties.");
|
|
7322
|
+
for (const entry of data.symbolEntries) {
|
|
7323
|
+
if (!Array.isArray(entry) || entry.length !== 2) throw new TypeError("Invalid RegExp symbol property.");
|
|
7324
|
+
descriptor(entry[1]);
|
|
7325
|
+
}
|
|
7326
|
+
}
|
|
7327
|
+
}
|
|
7328
|
+
function restoreRegexProperties(value, data, decode) {
|
|
7329
|
+
validateRegexProperties(data);
|
|
7330
|
+
const properties = getRegexProperties(value);
|
|
7331
|
+
for (const [key, descriptor] of Object.entries(data.properties ?? {}))
|
|
7332
|
+
Object.defineProperty(properties, key, { ...descriptor, value: decode(descriptor.value) });
|
|
7333
|
+
restoreSymbolProperties(properties, data.symbolEntries, decode);
|
|
7334
|
+
if (data.extensible === false) Object.preventExtensions(properties);
|
|
7335
|
+
}
|
|
7336
|
+
|
|
7239
7337
|
// packages/safe-js/src/snapshot/validation.ts
|
|
7240
7338
|
import { types as types5 } from "node:util";
|
|
7241
7339
|
|
|
@@ -7343,6 +7441,11 @@ function walkGraphDepth(root, rootPath, assertDepth) {
|
|
|
7343
7441
|
}
|
|
7344
7442
|
}
|
|
7345
7443
|
function graphEntries(value) {
|
|
7444
|
+
const properties = regexGuestProperties.get(value);
|
|
7445
|
+
if (properties !== void 0) return Reflect.ownKeys(properties).flatMap((key) => {
|
|
7446
|
+
const descriptor = Object.getOwnPropertyDescriptor(properties, key);
|
|
7447
|
+
return "value" in descriptor ? [[`.${String(key)}`, descriptor.value]] : [];
|
|
7448
|
+
});
|
|
7346
7449
|
if (isSandboxBox(value)) return boxedDataProperties(value).map(([key, descriptor]) => [`.${key}`, descriptor.value]);
|
|
7347
7450
|
if (isSandboxArguments(value)) {
|
|
7348
7451
|
return getSandboxArgumentEntries(value).map(([key, entry]) => [`.${key}`, entry]);
|
|
@@ -7497,8 +7600,8 @@ function getSandboxPropertyDescriptor(value, key, budget) {
|
|
|
7497
7600
|
return hostProperties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(hostProperties, key);
|
|
7498
7601
|
let current = value;
|
|
7499
7602
|
let depth = 0;
|
|
7500
|
-
while (typeof current === "object" && current !== null && (Array.isArray(current) || isSandboxDate(current) || isPrototypeRecord(current))) {
|
|
7501
|
-
const properties = isGuestClosure(current) ? getGuestFunctionProperties(current) : current;
|
|
7603
|
+
while (typeof current === "object" && current !== null && (Array.isArray(current) || isSandboxDate(current) || isSandboxRegex(current) || isPrototypeRecord(current))) {
|
|
7604
|
+
const properties = isGuestClosure(current) ? getGuestFunctionProperties(current) : isSandboxRegex(current) ? getRegexProperties(current) : current;
|
|
7502
7605
|
const descriptor = properties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(properties, key);
|
|
7503
7606
|
if (descriptor !== void 0) return descriptor;
|
|
7504
7607
|
current = getSandboxPrototype(current, budget);
|
|
@@ -7514,6 +7617,7 @@ function getSandboxDataProperty(value, key, budget) {
|
|
|
7514
7617
|
let depth = 0;
|
|
7515
7618
|
while (typeof current === "object" && current !== null) {
|
|
7516
7619
|
if (isGuestHostObject(current)) return typeof key === "symbol" ? void 0 : getHostObjectMember(current, String(key));
|
|
7620
|
+
if (isSandboxRegex(current)) return Object.getOwnPropertyDescriptor(getRegexProperties(current), key)?.value;
|
|
7517
7621
|
if (isGuestClosure(current)) {
|
|
7518
7622
|
const entry = getGuestFunctionProperty(current, key);
|
|
7519
7623
|
if (entry !== void 0 || Object.hasOwn(current.properties ?? {}, key)) return entry;
|
|
@@ -7676,34 +7780,6 @@ function decodeFloat32Storage(value, resolve) {
|
|
|
7676
7780
|
return new Float32Array(buffer, Number(value.byteOffset), Number(value.length));
|
|
7677
7781
|
}
|
|
7678
7782
|
|
|
7679
|
-
// packages/safe-js/src/snapshot/symbols.ts
|
|
7680
|
-
function symbolData(value) {
|
|
7681
|
-
const wellKnown = Object.keys(wellKnownSymbols).find((key) => wellKnownSymbols[key] === value);
|
|
7682
|
-
return {
|
|
7683
|
-
kind: "symbol",
|
|
7684
|
-
...wellKnown === void 0 ? value.description === void 0 ? {} : { description: value.description } : { wellKnown }
|
|
7685
|
-
};
|
|
7686
|
-
}
|
|
7687
|
-
function serializeSymbol(value, heapIds, heap) {
|
|
7688
|
-
let id = heapIds.get(value);
|
|
7689
|
-
if (id === void 0) {
|
|
7690
|
-
id = heapIds.size + 1;
|
|
7691
|
-
heapIds.set(value, id);
|
|
7692
|
-
heap[String(id)] = symbolData(value);
|
|
7693
|
-
}
|
|
7694
|
-
return { kind: "ref", id };
|
|
7695
|
-
}
|
|
7696
|
-
function ownSerializableSymbolKeys(value) {
|
|
7697
|
-
return Object.getOwnPropertySymbols(value).filter((key) => !internalSymbols.has(key));
|
|
7698
|
-
}
|
|
7699
|
-
function serializeSymbolProperties(value, encode) {
|
|
7700
|
-
return ownSerializableSymbolKeys(value).map((key) => {
|
|
7701
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
7702
|
-
if (!("value" in descriptor)) throw new TypeError("Symbol accessor properties cannot be serialized.");
|
|
7703
|
-
return [encode(key), { value: encode(descriptor.value), enumerable: descriptor.enumerable === true, writable: descriptor.writable === true, configurable: descriptor.configurable === true }];
|
|
7704
|
-
});
|
|
7705
|
-
}
|
|
7706
|
-
|
|
7707
7783
|
// packages/safe-js/src/snapshot/date-properties.ts
|
|
7708
7784
|
function serializeDate(value, encode) {
|
|
7709
7785
|
const properties = /* @__PURE__ */ Object.create(null);
|
|
@@ -7813,7 +7889,7 @@ function serializeDumpValue(value, path, state) {
|
|
|
7813
7889
|
if (hasGuestObjectState(value)) {
|
|
7814
7890
|
throw new TypeError("Guest function properties and prototype links cannot be serialized.");
|
|
7815
7891
|
}
|
|
7816
|
-
if (isSandboxBox(value) || isSandboxDate(value) || isFloat32Array(value)) return serializeHeapReference(value, path, state);
|
|
7892
|
+
if (isSandboxRegex(value) && hasCustomRegexProperties(value) || isSandboxBox(value) || isSandboxDate(value) || isFloat32Array(value)) return serializeHeapReference(value, path, state);
|
|
7817
7893
|
if (Array.isArray(value)) {
|
|
7818
7894
|
const reference2 = serializeHeapReference(value, path, state);
|
|
7819
7895
|
if (reference2 !== void 0) {
|
|
@@ -7837,7 +7913,20 @@ function serializeHeapReference(value, path, state) {
|
|
|
7837
7913
|
}
|
|
7838
7914
|
if (!state.serializedHeapIds.has(id)) {
|
|
7839
7915
|
state.serializedHeapIds.add(id);
|
|
7840
|
-
if (
|
|
7916
|
+
if (isSandboxRegex(value) && hasCustomRegexProperties(value)) {
|
|
7917
|
+
const encode = (entry) => {
|
|
7918
|
+
const serialized = serializeDumpValue(entry, `${path}.<regex-property>`, state);
|
|
7919
|
+
if (serialized === SKIP_VALUE) throw new TypeError("Unsupported RegExp property in public dump.");
|
|
7920
|
+
return serialized;
|
|
7921
|
+
};
|
|
7922
|
+
state.heap[String(id)] = {
|
|
7923
|
+
kind: "regex-object",
|
|
7924
|
+
source: value.source,
|
|
7925
|
+
flags: value.flags,
|
|
7926
|
+
lastIndex: encode(value.lastIndex),
|
|
7927
|
+
...serializeRegexProperties(value, encode)
|
|
7928
|
+
};
|
|
7929
|
+
} else if (isSandboxBox(value)) {
|
|
7841
7930
|
state.heap[String(id)] = encodeBoxedData(value, (entry, key) => {
|
|
7842
7931
|
if (Object.is(entry, -0)) return { kind: "number", value: "-0" };
|
|
7843
7932
|
const serialized = serializeDumpValue(entry, `${path}.${key}`, state);
|
|
@@ -7916,7 +8005,7 @@ function indexHeapContainers(snapshot) {
|
|
|
7916
8005
|
const heapIds = /* @__PURE__ */ new Map();
|
|
7917
8006
|
let nextId = 1;
|
|
7918
8007
|
for (const [value, stat2] of stats.entries()) {
|
|
7919
|
-
if (stat2.count > 1 || stat2.cyclic || ownSerializableSymbolKeys(value).length > 0 || isSandboxBox(value) || isSandboxDate(value) || isFloat32Array(value) || Array.isArray(value) && requiresArrayEntries(value) || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
|
|
8008
|
+
if (stat2.count > 1 || stat2.cyclic || ownSerializableSymbolKeys(value).length > 0 || isSandboxBox(value) || isSandboxRegex(value) && hasCustomRegexProperties(value) || isSandboxDate(value) || isFloat32Array(value) || Array.isArray(value) && requiresArrayEntries(value) || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
|
|
7920
8009
|
heapIds.set(value, nextId);
|
|
7921
8010
|
nextId += 1;
|
|
7922
8011
|
}
|
|
@@ -7949,7 +8038,10 @@ function collectContainerStats(value, stats, ancestors) {
|
|
|
7949
8038
|
}
|
|
7950
8039
|
stat2.expanded = true;
|
|
7951
8040
|
ancestors.add(value);
|
|
7952
|
-
const entries =
|
|
8041
|
+
const entries = isSandboxRegex(value) ? Reflect.ownKeys(getRegexProperties(value)).flatMap((key) => {
|
|
8042
|
+
const descriptor = Object.getOwnPropertyDescriptor(getRegexProperties(value), key);
|
|
8043
|
+
return "value" in descriptor ? [descriptor.value] : [];
|
|
8044
|
+
}) : isSandboxDate(value) ? dateDataProperties(value).flatMap(([key, descriptor]) => typeof key === "string" ? [descriptor.value] : []) : isSandboxBox(value) ? boxedDataProperties(value).map(([, descriptor]) => descriptor.value) : isSandboxArguments(value) ? getSandboxArgumentEntries(value).map(([, entry]) => entry) : getEnumerableDataValues(value);
|
|
7953
8045
|
for (const entry of entries) {
|
|
7954
8046
|
collectContainerStats(entry, stats, ancestors);
|
|
7955
8047
|
}
|
|
@@ -8069,6 +8161,10 @@ function validateDumpHeap(root, state) {
|
|
|
8069
8161
|
const entry = requireRecord(value, path);
|
|
8070
8162
|
validateErrorType(entry, path);
|
|
8071
8163
|
validateSymbolEntries(entry, path, state, heap);
|
|
8164
|
+
if (entry.kind === "regex-object") {
|
|
8165
|
+
validateTaggedValue(entry, path, state);
|
|
8166
|
+
continue;
|
|
8167
|
+
}
|
|
8072
8168
|
if (entry.kind === "boxed") {
|
|
8073
8169
|
validateBoxedRecord(entry, path, heap);
|
|
8074
8170
|
continue;
|
|
@@ -8200,6 +8296,11 @@ function validateTaggedValue(record2, path, state) {
|
|
|
8200
8296
|
requireString(record2.source, `${path}.source`, state.limits);
|
|
8201
8297
|
requireString(record2.flags, `${path}.flags`, state.limits);
|
|
8202
8298
|
if (!Object.hasOwn(record2, "lastIndex")) fail("invalidValue", `${path}.lastIndex`, "missing regex cursor");
|
|
8299
|
+
try {
|
|
8300
|
+
validateRegexProperties(record2);
|
|
8301
|
+
} catch {
|
|
8302
|
+
fail("invalidValue", path, "invalid RegExp property data");
|
|
8303
|
+
}
|
|
8203
8304
|
return;
|
|
8204
8305
|
case "array":
|
|
8205
8306
|
case "arguments":
|
|
@@ -8249,7 +8350,7 @@ function validateGeneratorShape(record2, path, state) {
|
|
|
8249
8350
|
}
|
|
8250
8351
|
function validateSymbolEntries(record2, path, state, heap) {
|
|
8251
8352
|
if (record2.symbolEntries === void 0) return;
|
|
8252
|
-
if (record2.kind !== "object" && record2.kind !== "array" && record2.kind !== "date" && record2.kind !== "boxed")
|
|
8353
|
+
if (record2.kind !== "object" && record2.kind !== "array" && record2.kind !== "date" && record2.kind !== "boxed" && record2.kind !== "regex-object")
|
|
8253
8354
|
fail("invalidValue", `${path}.symbolEntries`, "symbol properties are unsupported for this heap kind");
|
|
8254
8355
|
const entries = requireArray(record2.symbolEntries, `${path}.symbolEntries`, state);
|
|
8255
8356
|
const keys = /* @__PURE__ */ new Set();
|
|
@@ -10138,10 +10239,11 @@ function escapeRegexSource(source, budget) {
|
|
|
10138
10239
|
return budget === void 0 ? text : budget.allocateString(text);
|
|
10139
10240
|
}
|
|
10140
10241
|
function setRegexMember(target, property, value) {
|
|
10141
|
-
|
|
10242
|
+
const properties = getRegexProperties(target);
|
|
10243
|
+
if (!Object.hasOwn(properties, property) && (property === "source" || property === "flags" || Object.hasOwn(regexFlagProperties, property))) {
|
|
10142
10244
|
throw new TypeError(`RegExp#${String(property)} is not writable.`);
|
|
10143
10245
|
}
|
|
10144
|
-
|
|
10246
|
+
if (!Reflect.set(properties, property, value)) throw new TypeError(`RegExp#${String(property)} is not writable.`);
|
|
10145
10247
|
}
|
|
10146
10248
|
async function callRegexMethod(target, methodName, args, budget, context) {
|
|
10147
10249
|
if (target === null || typeof target !== "object" || methodName === "exec" && !isSandboxRegex(target)) {
|
|
@@ -10249,9 +10351,8 @@ function getStringMember(value, property, budget) {
|
|
|
10249
10351
|
const retainedReceiver = {};
|
|
10250
10352
|
budget.setRetainedValues(retainedReceiver, () => [receiver]);
|
|
10251
10353
|
try {
|
|
10252
|
-
const string = await sandboxString(receiver, budget, context);
|
|
10253
10354
|
return await callStringMethod(
|
|
10254
|
-
|
|
10355
|
+
receiver,
|
|
10255
10356
|
property,
|
|
10256
10357
|
args,
|
|
10257
10358
|
budget,
|
|
@@ -10278,6 +10379,20 @@ function isStringMethodName(property) {
|
|
|
10278
10379
|
function validateStringMethodArguments(_methodName, _args) {
|
|
10279
10380
|
}
|
|
10280
10381
|
function callStringMethod(value, methodName, args, budget, callClosure = async (closure, closureArgs) => await closure.call(closureArgs), parent, context) {
|
|
10382
|
+
if (value === null || value === void 0)
|
|
10383
|
+
throw new TypeError(`String#${methodName} requires a non-null receiver.`);
|
|
10384
|
+
const fallback = () => typeof value === "string" ? callStringMethodBody(value, methodName, args, budget, callClosure, parent, context) : Promise.resolve(sandboxString(value, budget, context)).then((string) => callStringMethodBody(string, methodName, args, budget, callClosure, parent, context));
|
|
10385
|
+
const symbol = methodName === "match" ? Symbol.match : methodName === "search" ? Symbol.search : methodName === "split" ? Symbol.split : void 0;
|
|
10386
|
+
const pattern = args[0];
|
|
10387
|
+
if (symbol === void 0 || pattern === null || pattern === void 0) return fallback();
|
|
10388
|
+
const applyHook = (hook) => {
|
|
10389
|
+
if (hook === null || hook === void 0) return fallback();
|
|
10390
|
+
if (!isSandboxClosure(hook)) throw new TypeError(`String#${methodName} symbol hook must be callable.`);
|
|
10391
|
+
return invokeBuiltinClosure(hook, methodName === "split" ? [value, args[1]] : [value], budget, context, pattern);
|
|
10392
|
+
};
|
|
10393
|
+
return context?.getProperty !== void 0 ? Promise.resolve(context.getProperty(pattern, symbol)).then(applyHook) : applyHook(getSandboxDataProperty(pattern, symbol, budget));
|
|
10394
|
+
}
|
|
10395
|
+
function callStringMethodBody(value, methodName, args, budget, callClosure = async (closure, closureArgs) => await closure.call(closureArgs), parent, context) {
|
|
10281
10396
|
if (methodName === "concat" && args.some((argument) => argument !== null && typeof argument === "object")) {
|
|
10282
10397
|
return callConcat(value, args, budget, context);
|
|
10283
10398
|
}
|
|
@@ -10940,14 +11055,14 @@ function createObjectArrayGlobals(options) {
|
|
|
10940
11055
|
call: ([value]) => {
|
|
10941
11056
|
if (isGuestHostObject(value))
|
|
10942
11057
|
throw new TypeError("Live host objects cannot be made non-extensible.");
|
|
10943
|
-
Object.preventExtensions(isGuestClosure(value) ? materializeFunctionProperties(value) : value);
|
|
11058
|
+
Object.preventExtensions(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : value);
|
|
10944
11059
|
return value;
|
|
10945
11060
|
},
|
|
10946
11061
|
name: "preventExtensions"
|
|
10947
11062
|
}),
|
|
10948
11063
|
isExtensible: createSandboxClosure({
|
|
10949
11064
|
sandbox: true,
|
|
10950
|
-
call: ([value]) => Object.isExtensible(isGuestClosure(value) ? materializeFunctionProperties(value) : value),
|
|
11065
|
+
call: ([value]) => Object.isExtensible(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : value),
|
|
10951
11066
|
name: "isExtensible"
|
|
10952
11067
|
}),
|
|
10953
11068
|
seal: createSandboxClosure({
|
|
@@ -10955,14 +11070,14 @@ function createObjectArrayGlobals(options) {
|
|
|
10955
11070
|
call: ([value]) => {
|
|
10956
11071
|
if (isGuestHostObject(value))
|
|
10957
11072
|
throw new TypeError("Live host objects cannot be sealed.");
|
|
10958
|
-
Object.seal(isGuestClosure(value) ? materializeFunctionProperties(value) : value);
|
|
11073
|
+
Object.seal(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : value);
|
|
10959
11074
|
return value;
|
|
10960
11075
|
},
|
|
10961
11076
|
name: "seal"
|
|
10962
11077
|
}),
|
|
10963
11078
|
isSealed: createSandboxClosure({
|
|
10964
11079
|
sandbox: true,
|
|
10965
|
-
call: ([value]) => Object.isSealed(isGuestClosure(value) ? materializeFunctionProperties(value) : value),
|
|
11080
|
+
call: ([value]) => Object.isSealed(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : value),
|
|
10966
11081
|
name: "isSealed"
|
|
10967
11082
|
}),
|
|
10968
11083
|
freeze: createSandboxClosure({
|
|
@@ -10971,7 +11086,7 @@ function createObjectArrayGlobals(options) {
|
|
|
10971
11086
|
if (isGuestHostObject(value))
|
|
10972
11087
|
throw new TypeError("Live host objects cannot be frozen.");
|
|
10973
11088
|
if (typeof value === "object" && value !== null) {
|
|
10974
|
-
Object.freeze(isGuestClosure(value) ? materializeFunctionProperties(value) : value);
|
|
11089
|
+
Object.freeze(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : value);
|
|
10975
11090
|
}
|
|
10976
11091
|
return value;
|
|
10977
11092
|
},
|
|
@@ -10979,7 +11094,7 @@ function createObjectArrayGlobals(options) {
|
|
|
10979
11094
|
}),
|
|
10980
11095
|
isFrozen: createSandboxClosure({
|
|
10981
11096
|
sandbox: true,
|
|
10982
|
-
call: ([value]) => Object.isFrozen(isGuestClosure(value) ? materializeFunctionProperties(value) : value),
|
|
11097
|
+
call: ([value]) => Object.isFrozen(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : value),
|
|
10983
11098
|
name: "isFrozen"
|
|
10984
11099
|
}),
|
|
10985
11100
|
assign: createSandboxClosure({
|
|
@@ -11183,6 +11298,7 @@ function assignSandboxValues(target, sources, budget, context) {
|
|
|
11183
11298
|
})();
|
|
11184
11299
|
}
|
|
11185
11300
|
function objectProperties(value, mutable = false) {
|
|
11301
|
+
if (isSandboxRegex(value)) return getRegexProperties(value);
|
|
11186
11302
|
if (isSandboxDate(value)) {
|
|
11187
11303
|
return value;
|
|
11188
11304
|
}
|
|
@@ -15451,7 +15567,7 @@ async function evaluateDeleteExpression(node, context) {
|
|
|
15451
15567
|
}
|
|
15452
15568
|
throw new TypeError("Cannot delete properties of null or undefined.");
|
|
15453
15569
|
}
|
|
15454
|
-
if (!isIndexableSandboxValue(member.object)) {
|
|
15570
|
+
if (!isIndexableSandboxValue(member.object) && !isSandboxRegex(member.object)) {
|
|
15455
15571
|
throw new TypeError("Unary operator 'delete' requires a sandbox object property.");
|
|
15456
15572
|
}
|
|
15457
15573
|
const property = await toPropertyKey(member.property, context.budget, createCoercionContext(context));
|
|
@@ -15854,10 +15970,10 @@ async function evaluateMemberCallExpression(node, context) {
|
|
|
15854
15970
|
member.object
|
|
15855
15971
|
);
|
|
15856
15972
|
}
|
|
15857
|
-
if (isSandboxRegex(member.object)
|
|
15973
|
+
if (isSandboxRegex(member.object)) {
|
|
15858
15974
|
return evaluateResolvedCallExpression(
|
|
15859
15975
|
node,
|
|
15860
|
-
|
|
15976
|
+
await getPropertyValue(member.object, member.property, context),
|
|
15861
15977
|
context,
|
|
15862
15978
|
member.object
|
|
15863
15979
|
);
|
|
@@ -16358,7 +16474,6 @@ function setSandboxProperty(target, property, value, budget, checkInherited = tr
|
|
|
16358
16474
|
return;
|
|
16359
16475
|
}
|
|
16360
16476
|
if (isSandboxRegex(target)) {
|
|
16361
|
-
if (typeof property === "symbol") throw new TypeError("RegExp symbol properties are not yet supported.");
|
|
16362
16477
|
setRegexMember(target, property, value);
|
|
16363
16478
|
return;
|
|
16364
16479
|
}
|
|
@@ -16420,6 +16535,7 @@ function setSuperProperty(base, receiver, key, value, context) {
|
|
|
16420
16535
|
function deleteSandboxProperty(target, property) {
|
|
16421
16536
|
if (isGuestHostObject(target)) return deleteHostObjectMember(target, String(property));
|
|
16422
16537
|
if (isGuestClosure(target)) target = materializeFunctionProperties(target);
|
|
16538
|
+
if (isSandboxRegex(target)) target = getRegexProperties(target);
|
|
16423
16539
|
if (Array.isArray(target)) {
|
|
16424
16540
|
assertCollectionMutable(target);
|
|
16425
16541
|
}
|
|
@@ -17128,7 +17244,8 @@ function encodeReplayData(value, options = {}) {
|
|
|
17128
17244
|
kind: "regex",
|
|
17129
17245
|
source: entry.source,
|
|
17130
17246
|
flags: entry.flags,
|
|
17131
|
-
lastIndex: child(entry.lastIndex, "lastIndex")
|
|
17247
|
+
lastIndex: child(entry.lastIndex, "lastIndex"),
|
|
17248
|
+
...serializeRegexProperties(entry, (value2) => child(value2, "<regex-property>"))
|
|
17132
17249
|
};
|
|
17133
17250
|
} else if (isSandboxArguments(entry)) {
|
|
17134
17251
|
nodes[id] = { kind: "arguments", data: serializeArguments(entry, child) };
|
|
@@ -17331,6 +17448,7 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
17331
17448
|
const result3 = createSandboxRegex(node.source, node.flags, 0, compilation);
|
|
17332
17449
|
restored.set(id, result3);
|
|
17333
17450
|
result3.lastIndex = child(own(node, "lastIndex"));
|
|
17451
|
+
restoreRegexProperties(result3, node, child);
|
|
17334
17452
|
return result3;
|
|
17335
17453
|
}
|
|
17336
17454
|
if (kind === "arguments") {
|
|
@@ -18813,7 +18931,7 @@ function hasOwnSandboxProperty(value, key, enumerable) {
|
|
|
18813
18931
|
properties = value.properties ?? /* @__PURE__ */ Object.create(null);
|
|
18814
18932
|
} else if (isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxGenerator(value))
|
|
18815
18933
|
return false;
|
|
18816
|
-
else if (isSandboxRegex(value))
|
|
18934
|
+
else if (isSandboxRegex(value)) properties = getRegexProperties(value);
|
|
18817
18935
|
else properties = Object(value);
|
|
18818
18936
|
const descriptor = Object.getOwnPropertyDescriptor(properties, key);
|
|
18819
18937
|
return descriptor !== void 0 && (!enumerable || descriptor.enumerable === true);
|
|
@@ -20360,6 +20478,7 @@ function ownEnumerableSandboxEntries(value, excludedKeys) {
|
|
|
20360
20478
|
if (value === null || value === void 0) throw new TypeError("Cannot convert undefined or null to object.");
|
|
20361
20479
|
let entries;
|
|
20362
20480
|
if (isGuestClosure(value)) entries = Object.entries(value.properties ?? {});
|
|
20481
|
+
else if (isSandboxRegex(value)) entries = Object.entries(getRegexProperties(value));
|
|
20363
20482
|
else if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
|
|
20364
20483
|
else entries = Object.entries(Object(value));
|
|
20365
20484
|
return excludedKeys === void 0 ? entries : entries.filter(([key]) => !excludedKeys.has(key));
|
|
@@ -20368,17 +20487,19 @@ function ownSandboxSymbolKeys(value) {
|
|
|
20368
20487
|
if (value === null || value === void 0) throw new TypeError("Cannot convert undefined or null to object.");
|
|
20369
20488
|
if (isGuestHostObject(value)) return [];
|
|
20370
20489
|
if (isSandboxClosure(value)) value = value.properties ?? {};
|
|
20490
|
+
else if (isSandboxRegex(value)) value = getRegexProperties(value);
|
|
20371
20491
|
else if (isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
|
|
20372
20492
|
return Object.getOwnPropertySymbols(Object(value)).filter((key) => !internalSymbols.has(key));
|
|
20373
20493
|
}
|
|
20374
20494
|
function ownEnumerableSandboxKeys(value, includeSymbols = false) {
|
|
20375
20495
|
if (includeSymbols) {
|
|
20376
|
-
const properties = isSandboxClosure(value) ? value.properties ?? {} : Object(value);
|
|
20496
|
+
const properties = isSandboxClosure(value) ? value.properties ?? {} : isSandboxRegex(value) ? getRegexProperties(value) : Object(value);
|
|
20377
20497
|
return [...ownEnumerableSandboxKeys(value), ...ownSandboxSymbolKeys(value).filter((key) => Object.getOwnPropertyDescriptor(properties, key)?.enumerable === true)];
|
|
20378
20498
|
}
|
|
20379
20499
|
if (isGuestHostObject(value)) return getHostObjectKeys(value);
|
|
20380
20500
|
if (value === null || value === void 0) throw new TypeError("Cannot convert undefined or null to object.");
|
|
20381
20501
|
if (isGuestClosure(value)) return Object.keys(value.properties ?? {});
|
|
20502
|
+
if (isSandboxRegex(value)) return Object.keys(getRegexProperties(value));
|
|
20382
20503
|
if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
|
|
20383
20504
|
return Object.keys(Object(value));
|
|
20384
20505
|
}
|
|
@@ -20470,6 +20591,28 @@ function createSandboxRegex(source, flags = "", lastIndex = 0, compilation) {
|
|
|
20470
20591
|
}
|
|
20471
20592
|
const pattern = parseRegex(source, flags, compilation, 7 + source.length + flags.length);
|
|
20472
20593
|
const regex = { kind: "regex", source, flags, lastIndex };
|
|
20594
|
+
const storage = /* @__PURE__ */ Object.create(null);
|
|
20595
|
+
Object.defineProperty(storage, "lastIndex", { value: lastIndex, writable: true });
|
|
20596
|
+
const syncCursor = () => {
|
|
20597
|
+
const descriptor = Object.getOwnPropertyDescriptor(regex, "lastIndex");
|
|
20598
|
+
Object.defineProperty(storage, "lastIndex", { value: descriptor.value, writable: descriptor.writable });
|
|
20599
|
+
};
|
|
20600
|
+
const properties = new Proxy(storage, {
|
|
20601
|
+
get: (target, key, receiver) => key === "lastIndex" ? regex.lastIndex : Reflect.get(target, key, receiver),
|
|
20602
|
+
set: (target, key, value, receiver) => key === "lastIndex" ? Reflect.set(regex, key, value) : Reflect.set(target, key, value, receiver),
|
|
20603
|
+
getOwnPropertyDescriptor(target, key) {
|
|
20604
|
+
if (key === "lastIndex") syncCursor();
|
|
20605
|
+
return Object.getOwnPropertyDescriptor(target, key);
|
|
20606
|
+
},
|
|
20607
|
+
defineProperty(target, key, descriptor) {
|
|
20608
|
+
if (key !== "lastIndex") return Reflect.defineProperty(target, key, descriptor);
|
|
20609
|
+
syncCursor();
|
|
20610
|
+
if (!Reflect.defineProperty(target, key, descriptor)) return false;
|
|
20611
|
+
const cursor = Object.getOwnPropertyDescriptor(target, key);
|
|
20612
|
+
return Reflect.defineProperty(regex, key, { value: cursor.value, writable: cursor.writable });
|
|
20613
|
+
}
|
|
20614
|
+
});
|
|
20615
|
+
regexGuestProperties.set(regex, properties);
|
|
20473
20616
|
Object.defineProperties(regex, {
|
|
20474
20617
|
[sandboxRegexBrand]: { value: true },
|
|
20475
20618
|
[sandboxRegexPattern]: { value: pattern }
|
|
@@ -20645,6 +20788,14 @@ function measureSandboxData(values, options = {}) {
|
|
|
20645
20788
|
usage += Math.max(6 + source.length + flags.length + compiled.units, staged - 1);
|
|
20646
20789
|
if (compiled.ticket !== void 0) options.compileTickets?.add(compiled.ticket);
|
|
20647
20790
|
visit(lastIndex, depth + 1);
|
|
20791
|
+
for (const key of Reflect.ownKeys(getRegexProperties(value))) {
|
|
20792
|
+
if (key === "lastIndex") continue;
|
|
20793
|
+
const descriptor = Object.getOwnPropertyDescriptor(getRegexProperties(value), key);
|
|
20794
|
+
usage += 1 + (typeof key === "string" ? key.length : 0);
|
|
20795
|
+
if (typeof key === "symbol") visit(key, depth + 1);
|
|
20796
|
+
if ("value" in descriptor) visit(descriptor.value, depth + 1);
|
|
20797
|
+
else for (const closure of retainedAccessorClosures(descriptor)) visit(closure, depth + 1);
|
|
20798
|
+
}
|
|
20648
20799
|
return;
|
|
20649
20800
|
}
|
|
20650
20801
|
if (isSandboxArguments(value)) {
|
|
@@ -20705,7 +20856,7 @@ function captureRegexData(value) {
|
|
|
20705
20856
|
"Invalid sandbox RegExp source or flags: expected own string data properties."
|
|
20706
20857
|
);
|
|
20707
20858
|
}
|
|
20708
|
-
const cursor = Object.getOwnPropertyDescriptor(value, "lastIndex");
|
|
20859
|
+
const cursor = Object.getOwnPropertyDescriptor(regexGuestProperties.get(value) ?? value, "lastIndex");
|
|
20709
20860
|
if (cursor === void 0 || !("value" in cursor)) {
|
|
20710
20861
|
throw new TypeError("Invalid sandbox RegExp lastIndex: expected an own data property.");
|
|
20711
20862
|
}
|
|
@@ -20734,6 +20885,18 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
|
|
|
20734
20885
|
const copy = createSandboxRegex(value.source, value.flags, 0, state.compilation);
|
|
20735
20886
|
state.seen.set(value, copy);
|
|
20736
20887
|
if (!state.resetRegexLastIndex) copy.lastIndex = copyToSandbox(value.lastIndex, state, `${path}.lastIndex`, true, depth + 1);
|
|
20888
|
+
if (!state.structuredClone) {
|
|
20889
|
+
const properties = getRegexProperties(value);
|
|
20890
|
+
for (const key of Reflect.ownKeys(properties)) {
|
|
20891
|
+
const descriptor = Object.getOwnPropertyDescriptor(properties, key);
|
|
20892
|
+
if (!("value" in descriptor)) throw new TypeError("RegExp accessor properties cannot be copied as data.");
|
|
20893
|
+
Object.defineProperty(getRegexProperties(copy), key, {
|
|
20894
|
+
...descriptor,
|
|
20895
|
+
value: key === "lastIndex" && state.resetRegexLastIndex ? 0 : copyToSandbox(descriptor.value, state, `${path}.${String(key)}`, true, depth + 1)
|
|
20896
|
+
});
|
|
20897
|
+
}
|
|
20898
|
+
if (!Object.isExtensible(properties)) Object.preventExtensions(getRegexProperties(copy));
|
|
20899
|
+
}
|
|
20737
20900
|
return copy;
|
|
20738
20901
|
}
|
|
20739
20902
|
if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxPromise(value)) {
|
|
@@ -20982,6 +21145,18 @@ function copyFromSandbox(value, state, path = "<root>", options, depth = 0) {
|
|
|
20982
21145
|
const regex = new RegExp(source, flags);
|
|
20983
21146
|
state.seen.set(value, regex);
|
|
20984
21147
|
Reflect.set(regex, "lastIndex", copyFromSandbox(lastIndex, state, `${path}.lastIndex`, options, depth + 1));
|
|
21148
|
+
const properties = regexGuestProperties.get(value);
|
|
21149
|
+
if (properties !== void 0) {
|
|
21150
|
+
for (const key of Reflect.ownKeys(properties)) {
|
|
21151
|
+
const descriptor = Object.getOwnPropertyDescriptor(properties, key);
|
|
21152
|
+
if (!("value" in descriptor)) throw new TypeError("RegExp accessor properties cannot be copied as data.");
|
|
21153
|
+
Object.defineProperty(regex, key, {
|
|
21154
|
+
...descriptor,
|
|
21155
|
+
value: copyFromSandbox(descriptor.value, state, `${path}.${String(key)}`, options, depth + 1)
|
|
21156
|
+
});
|
|
21157
|
+
}
|
|
21158
|
+
if (!Object.isExtensible(properties)) Object.preventExtensions(regex);
|
|
21159
|
+
}
|
|
20985
21160
|
guard.retainScratch();
|
|
20986
21161
|
return regex;
|
|
20987
21162
|
} finally {
|
|
@@ -35932,7 +36107,6 @@ export {
|
|
|
35932
36107
|
parse,
|
|
35933
36108
|
parseModule,
|
|
35934
36109
|
hashSource,
|
|
35935
|
-
defineExtension,
|
|
35936
36110
|
noopOtelSink,
|
|
35937
36111
|
bindOtelSpan,
|
|
35938
36112
|
activateOtelSpan,
|
|
@@ -35941,6 +36115,7 @@ export {
|
|
|
35941
36115
|
safeAddEvent,
|
|
35942
36116
|
safeRecordException,
|
|
35943
36117
|
safeEndSpan,
|
|
36118
|
+
defineExtension,
|
|
35944
36119
|
encodeReplayData,
|
|
35945
36120
|
HostOperationResumePolicyError,
|
|
35946
36121
|
registerPendingHostCallPolicy,
|
|
@@ -35973,4 +36148,4 @@ export {
|
|
|
35973
36148
|
FileSnapshotBackend,
|
|
35974
36149
|
run
|
|
35975
36150
|
};
|
|
35976
|
-
//# sourceMappingURL=chunk-
|
|
36151
|
+
//# sourceMappingURL=chunk-WPI4GGVU.js.map
|