seroval 1.6.3 → 1.6.5

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.
@@ -1382,6 +1382,7 @@ function deserializeTypedArray(ctx, depth, node) {
1382
1382
  var _node$b;
1383
1383
  const construct = getTypedArrayConstructor(node.c);
1384
1384
  const source = deserialize$1(ctx, depth, node.f);
1385
+ if (!(source instanceof ArrayBuffer)) throw new SerovalMalformedNodeError(node);
1385
1386
  const offset = (_node$b = node.b) !== null && _node$b !== void 0 ? _node$b : 0;
1386
1387
  if (offset < 0 || offset > source.byteLength || node.l > MAX_BASE64_LENGTH) throw new SerovalMalformedNodeError(node);
1387
1388
  return assignIndexedValue$1(ctx, node.i, new construct(source, offset, node.l));
@@ -1389,6 +1390,7 @@ function deserializeTypedArray(ctx, depth, node) {
1389
1390
  function deserializeDataView(ctx, depth, node) {
1390
1391
  var _node$b2;
1391
1392
  const source = deserialize$1(ctx, depth, node.f);
1393
+ if (!(source instanceof ArrayBuffer)) throw new SerovalMalformedNodeError(node);
1392
1394
  const offset = (_node$b2 = node.b) !== null && _node$b2 !== void 0 ? _node$b2 : 0;
1393
1395
  if (offset < 0 || offset > source.byteLength || node.l > MAX_BASE64_LENGTH) throw new SerovalMalformedNodeError(node);
1394
1396
  return assignIndexedValue$1(ctx, node.i, new DataView(source, offset, node.l));
@@ -1449,11 +1451,17 @@ function deserializePromiseFulfill(ctx, depth, node) {
1449
1451
  }
1450
1452
  function deserializeIteratorFactoryInstance(ctx, depth, node) {
1451
1453
  deserialize$1(ctx, depth, node.a[0]);
1452
- return sequenceToIterator(deserialize$1(ctx, depth, node.a[1]));
1454
+ const source = deserialize$1(ctx, depth, node.a[1]);
1455
+ validateNodeType(ctx, node, node.a[1].i, 35);
1456
+ if (!source) throw new SerovalMalformedNodeError(node.a[1]);
1457
+ return sequenceToIterator(source);
1453
1458
  }
1454
1459
  function deserializeAsyncIteratorFactoryInstance(ctx, depth, node) {
1455
1460
  deserialize$1(ctx, depth, node.a[0]);
1456
- return streamToAsyncIterable(deserialize$1(ctx, depth, node.a[1]));
1461
+ const source = deserialize$1(ctx, depth, node.a[1]);
1462
+ validateNodeType(ctx, node, node.a[1].i, 31);
1463
+ if (!source) throw new SerovalMalformedNodeError(node.a[1]);
1464
+ return streamToAsyncIterable(source);
1457
1465
  }
1458
1466
  function deserializeStreamConstructor(ctx, depth, node) {
1459
1467
  const result = assignIndexedValue$1(ctx, node.i, createStream());
@@ -1498,6 +1506,7 @@ function deserializeAsyncIteratorFactory(ctx, depth, node) {
1498
1506
  }
1499
1507
  function deserializeSequence(ctx, depth, node) {
1500
1508
  const result = assignIndexedValue$1(ctx, node.i, createSequence([], node.s, node.l));
1509
+ assignNodeType(ctx, node.i, 35);
1501
1510
  for (let i = 0, len = node.a.length; i < len; i++) result.v[i] = deserialize$1(ctx, depth, node.a[i]);
1502
1511
  return result;
1503
1512
  }
@@ -2943,6 +2952,7 @@ exports.deserialize = deserialize;
2943
2952
  exports.fromCrossJSON = fromCrossJSON;
2944
2953
  exports.fromJSON = fromJSON;
2945
2954
  exports.getCrossReferenceHeader = getCrossReferenceHeader;
2955
+ exports.isStream = isStream;
2946
2956
  exports.resolvePlugins = resolvePlugins;
2947
2957
  exports.serialize = serialize;
2948
2958
  exports.serializeAsync = serializeAsync;
@@ -737,6 +737,7 @@ interface Stream<T> {
737
737
  throw(value: unknown): void;
738
738
  return(value: T): void;
739
739
  }
740
+ declare function isStream<T>(value: object): value is Stream<T>;
740
741
  declare function createStream<T>(): Stream<T>;
741
742
  //#endregion
742
743
  //#region src/core/tree/index.d.ts
@@ -758,4 +759,4 @@ declare function toJSONAsync<T>(source: T, options?: AsyncParserContextOptions$1
758
759
  declare function compileJSON(source: SerovalJSON, options?: PluginAccessOptions): string;
759
760
  declare function fromJSON<T>(source: SerovalJSON, options?: FromJSONOptions): T;
760
761
  //#endregion
761
- export { type AsyncParsePluginContext, AsyncParserContextOptions, type BaseDeserializerContextOptions, type BaseParserContextOptions, type BaseSerializerContextOptions, type CrossContextOptions, type CrossDeserializerContextOptions, CrossSerializeAsyncOptions, CrossSerializeOptions, CrossSerializeStreamOptions, type CrossSerializerContextOptions, type DeserializePluginContext, Feature, FromCrossJSONOptions, FromJSONOptions, OpaqueReference, Plugin, PluginAccessOptions, PluginData, PluginInfo, type SerializePluginContext, Serializer, SerovalConflictedNodeIdError, SerovalDepthLimitError, SerovalDeserializationError, SerovalError, SerovalJSON, SerovalMalformedNodeError, SerovalMissingInstanceError, SerovalMissingPluginError, SerovalMissingReferenceError, SerovalMissingReferenceForIdError, SerovalMode, type SerovalNode, SerovalParserError, SerovalSerializationError, SerovalUnknownTypedArrayError, SerovalUnsupportedNodeError, SerovalUnsupportedTypeError, type Stream, type StreamListener, type StreamParsePluginContext, type StreamParserContextOptions, type SyncParsePluginContext, SyncParserContextOptions, ToCrossJSONAsyncOptions, ToCrossJSONOptions, ToCrossJSONStreamOptions, type VanillaDeserializerContextOptions, type VanillaSerializerContextOptions, compileJSON, createPlugin, createReference, createStream, crossSerialize, crossSerializeAsync, crossSerializeStream, deserialize, fromCrossJSON, fromJSON, getCrossReferenceHeader, resolvePlugins, serialize, serializeAsync, toCrossJSON, toCrossJSONAsync, toCrossJSONStream, toJSON, toJSONAsync };
762
+ export { type AsyncParsePluginContext, AsyncParserContextOptions, type BaseDeserializerContextOptions, type BaseParserContextOptions, type BaseSerializerContextOptions, type CrossContextOptions, type CrossDeserializerContextOptions, CrossSerializeAsyncOptions, CrossSerializeOptions, CrossSerializeStreamOptions, type CrossSerializerContextOptions, type DeserializePluginContext, Feature, FromCrossJSONOptions, FromJSONOptions, OpaqueReference, Plugin, PluginAccessOptions, PluginData, PluginInfo, type SerializePluginContext, Serializer, SerovalConflictedNodeIdError, SerovalDepthLimitError, SerovalDeserializationError, SerovalError, SerovalJSON, SerovalMalformedNodeError, SerovalMissingInstanceError, SerovalMissingPluginError, SerovalMissingReferenceError, SerovalMissingReferenceForIdError, SerovalMode, type SerovalNode, SerovalParserError, SerovalSerializationError, SerovalUnknownTypedArrayError, SerovalUnsupportedNodeError, SerovalUnsupportedTypeError, type Stream, type StreamListener, type StreamParsePluginContext, type StreamParserContextOptions, type SyncParsePluginContext, SyncParserContextOptions, ToCrossJSONAsyncOptions, ToCrossJSONOptions, ToCrossJSONStreamOptions, type VanillaDeserializerContextOptions, type VanillaSerializerContextOptions, compileJSON, createPlugin, createReference, createStream, crossSerialize, crossSerializeAsync, crossSerializeStream, deserialize, fromCrossJSON, fromJSON, getCrossReferenceHeader, isStream, resolvePlugins, serialize, serializeAsync, toCrossJSON, toCrossJSONAsync, toCrossJSONStream, toJSON, toJSONAsync };
@@ -737,6 +737,7 @@ interface Stream<T> {
737
737
  throw(value: unknown): void;
738
738
  return(value: T): void;
739
739
  }
740
+ declare function isStream<T>(value: object): value is Stream<T>;
740
741
  declare function createStream<T>(): Stream<T>;
741
742
  //#endregion
742
743
  //#region src/core/tree/index.d.ts
@@ -758,4 +759,4 @@ declare function toJSONAsync<T>(source: T, options?: AsyncParserContextOptions$1
758
759
  declare function compileJSON(source: SerovalJSON, options?: PluginAccessOptions): string;
759
760
  declare function fromJSON<T>(source: SerovalJSON, options?: FromJSONOptions): T;
760
761
  //#endregion
761
- export { type AsyncParsePluginContext, AsyncParserContextOptions, type BaseDeserializerContextOptions, type BaseParserContextOptions, type BaseSerializerContextOptions, type CrossContextOptions, type CrossDeserializerContextOptions, CrossSerializeAsyncOptions, CrossSerializeOptions, CrossSerializeStreamOptions, type CrossSerializerContextOptions, type DeserializePluginContext, Feature, FromCrossJSONOptions, FromJSONOptions, OpaqueReference, Plugin, PluginAccessOptions, PluginData, PluginInfo, type SerializePluginContext, Serializer, SerovalConflictedNodeIdError, SerovalDepthLimitError, SerovalDeserializationError, SerovalError, SerovalJSON, SerovalMalformedNodeError, SerovalMissingInstanceError, SerovalMissingPluginError, SerovalMissingReferenceError, SerovalMissingReferenceForIdError, SerovalMode, type SerovalNode, SerovalParserError, SerovalSerializationError, SerovalUnknownTypedArrayError, SerovalUnsupportedNodeError, SerovalUnsupportedTypeError, type Stream, type StreamListener, type StreamParsePluginContext, type StreamParserContextOptions, type SyncParsePluginContext, SyncParserContextOptions, ToCrossJSONAsyncOptions, ToCrossJSONOptions, ToCrossJSONStreamOptions, type VanillaDeserializerContextOptions, type VanillaSerializerContextOptions, compileJSON, createPlugin, createReference, createStream, crossSerialize, crossSerializeAsync, crossSerializeStream, deserialize, fromCrossJSON, fromJSON, getCrossReferenceHeader, resolvePlugins, serialize, serializeAsync, toCrossJSON, toCrossJSONAsync, toCrossJSONStream, toJSON, toJSONAsync };
762
+ export { type AsyncParsePluginContext, AsyncParserContextOptions, type BaseDeserializerContextOptions, type BaseParserContextOptions, type BaseSerializerContextOptions, type CrossContextOptions, type CrossDeserializerContextOptions, CrossSerializeAsyncOptions, CrossSerializeOptions, CrossSerializeStreamOptions, type CrossSerializerContextOptions, type DeserializePluginContext, Feature, FromCrossJSONOptions, FromJSONOptions, OpaqueReference, Plugin, PluginAccessOptions, PluginData, PluginInfo, type SerializePluginContext, Serializer, SerovalConflictedNodeIdError, SerovalDepthLimitError, SerovalDeserializationError, SerovalError, SerovalJSON, SerovalMalformedNodeError, SerovalMissingInstanceError, SerovalMissingPluginError, SerovalMissingReferenceError, SerovalMissingReferenceForIdError, SerovalMode, type SerovalNode, SerovalParserError, SerovalSerializationError, SerovalUnknownTypedArrayError, SerovalUnsupportedNodeError, SerovalUnsupportedTypeError, type Stream, type StreamListener, type StreamParsePluginContext, type StreamParserContextOptions, type SyncParsePluginContext, SyncParserContextOptions, ToCrossJSONAsyncOptions, ToCrossJSONOptions, ToCrossJSONStreamOptions, type VanillaDeserializerContextOptions, type VanillaSerializerContextOptions, compileJSON, createPlugin, createReference, createStream, crossSerialize, crossSerializeAsync, crossSerializeStream, deserialize, fromCrossJSON, fromJSON, getCrossReferenceHeader, isStream, resolvePlugins, serialize, serializeAsync, toCrossJSON, toCrossJSONAsync, toCrossJSONStream, toJSON, toJSONAsync };
package/dist/dev/index.js CHANGED
@@ -1381,6 +1381,7 @@ function deserializeTypedArray(ctx, depth, node) {
1381
1381
  var _node$b;
1382
1382
  const construct = getTypedArrayConstructor(node.c);
1383
1383
  const source = deserialize$1(ctx, depth, node.f);
1384
+ if (!(source instanceof ArrayBuffer)) throw new SerovalMalformedNodeError(node);
1384
1385
  const offset = (_node$b = node.b) !== null && _node$b !== void 0 ? _node$b : 0;
1385
1386
  if (offset < 0 || offset > source.byteLength || node.l > MAX_BASE64_LENGTH) throw new SerovalMalformedNodeError(node);
1386
1387
  return assignIndexedValue$1(ctx, node.i, new construct(source, offset, node.l));
@@ -1388,6 +1389,7 @@ function deserializeTypedArray(ctx, depth, node) {
1388
1389
  function deserializeDataView(ctx, depth, node) {
1389
1390
  var _node$b2;
1390
1391
  const source = deserialize$1(ctx, depth, node.f);
1392
+ if (!(source instanceof ArrayBuffer)) throw new SerovalMalformedNodeError(node);
1391
1393
  const offset = (_node$b2 = node.b) !== null && _node$b2 !== void 0 ? _node$b2 : 0;
1392
1394
  if (offset < 0 || offset > source.byteLength || node.l > MAX_BASE64_LENGTH) throw new SerovalMalformedNodeError(node);
1393
1395
  return assignIndexedValue$1(ctx, node.i, new DataView(source, offset, node.l));
@@ -1448,11 +1450,17 @@ function deserializePromiseFulfill(ctx, depth, node) {
1448
1450
  }
1449
1451
  function deserializeIteratorFactoryInstance(ctx, depth, node) {
1450
1452
  deserialize$1(ctx, depth, node.a[0]);
1451
- return sequenceToIterator(deserialize$1(ctx, depth, node.a[1]));
1453
+ const source = deserialize$1(ctx, depth, node.a[1]);
1454
+ validateNodeType(ctx, node, node.a[1].i, 35);
1455
+ if (!source) throw new SerovalMalformedNodeError(node.a[1]);
1456
+ return sequenceToIterator(source);
1452
1457
  }
1453
1458
  function deserializeAsyncIteratorFactoryInstance(ctx, depth, node) {
1454
1459
  deserialize$1(ctx, depth, node.a[0]);
1455
- return streamToAsyncIterable(deserialize$1(ctx, depth, node.a[1]));
1460
+ const source = deserialize$1(ctx, depth, node.a[1]);
1461
+ validateNodeType(ctx, node, node.a[1].i, 31);
1462
+ if (!source) throw new SerovalMalformedNodeError(node.a[1]);
1463
+ return streamToAsyncIterable(source);
1456
1464
  }
1457
1465
  function deserializeStreamConstructor(ctx, depth, node) {
1458
1466
  const result = assignIndexedValue$1(ctx, node.i, createStream());
@@ -1497,6 +1505,7 @@ function deserializeAsyncIteratorFactory(ctx, depth, node) {
1497
1505
  }
1498
1506
  function deserializeSequence(ctx, depth, node) {
1499
1507
  const result = assignIndexedValue$1(ctx, node.i, createSequence([], node.s, node.l));
1508
+ assignNodeType(ctx, node.i, 35);
1500
1509
  for (let i = 0, len = node.a.length; i < len; i++) result.v[i] = deserialize$1(ctx, depth, node.a[i]);
1501
1510
  return result;
1502
1511
  }
@@ -2913,4 +2922,4 @@ function fromJSON(source, options = {}) {
2913
2922
  }), source.t);
2914
2923
  }
2915
2924
  //#endregion
2916
- export { Feature, OpaqueReference, Serializer, SerovalConflictedNodeIdError, SerovalDepthLimitError, SerovalDeserializationError, SerovalError, SerovalMalformedNodeError, SerovalMissingInstanceError, SerovalMissingPluginError, SerovalMissingReferenceError, SerovalMissingReferenceForIdError, SerovalMode, SerovalParserError, SerovalSerializationError, SerovalUnknownTypedArrayError, SerovalUnsupportedNodeError, SerovalUnsupportedTypeError, compileJSON, createPlugin, createReference, createStream, crossSerialize, crossSerializeAsync, crossSerializeStream, deserialize, fromCrossJSON, fromJSON, getCrossReferenceHeader, resolvePlugins, serialize, serializeAsync, toCrossJSON, toCrossJSONAsync, toCrossJSONStream, toJSON, toJSONAsync };
2925
+ export { Feature, OpaqueReference, Serializer, SerovalConflictedNodeIdError, SerovalDepthLimitError, SerovalDeserializationError, SerovalError, SerovalMalformedNodeError, SerovalMissingInstanceError, SerovalMissingPluginError, SerovalMissingReferenceError, SerovalMissingReferenceForIdError, SerovalMode, SerovalParserError, SerovalSerializationError, SerovalUnknownTypedArrayError, SerovalUnsupportedNodeError, SerovalUnsupportedTypeError, compileJSON, createPlugin, createReference, createStream, crossSerialize, crossSerializeAsync, crossSerializeStream, deserialize, fromCrossJSON, fromJSON, getCrossReferenceHeader, isStream, resolvePlugins, serialize, serializeAsync, toCrossJSON, toCrossJSONAsync, toCrossJSONStream, toJSON, toJSONAsync };
package/dist/index.cjs CHANGED
@@ -1375,6 +1375,7 @@ function deserializeTypedArray(ctx, depth, node) {
1375
1375
  var _node$b;
1376
1376
  const construct = getTypedArrayConstructor(node.c);
1377
1377
  const source = deserialize$1(ctx, depth, node.f);
1378
+ if (!(source instanceof ArrayBuffer)) throw new SerovalMalformedNodeError(node);
1378
1379
  const offset = (_node$b = node.b) !== null && _node$b !== void 0 ? _node$b : 0;
1379
1380
  if (offset < 0 || offset > source.byteLength || node.l > MAX_BASE64_LENGTH) throw new SerovalMalformedNodeError(node);
1380
1381
  return assignIndexedValue$1(ctx, node.i, new construct(source, offset, node.l));
@@ -1382,6 +1383,7 @@ function deserializeTypedArray(ctx, depth, node) {
1382
1383
  function deserializeDataView(ctx, depth, node) {
1383
1384
  var _node$b2;
1384
1385
  const source = deserialize$1(ctx, depth, node.f);
1386
+ if (!(source instanceof ArrayBuffer)) throw new SerovalMalformedNodeError(node);
1385
1387
  const offset = (_node$b2 = node.b) !== null && _node$b2 !== void 0 ? _node$b2 : 0;
1386
1388
  if (offset < 0 || offset > source.byteLength || node.l > MAX_BASE64_LENGTH) throw new SerovalMalformedNodeError(node);
1387
1389
  return assignIndexedValue$1(ctx, node.i, new DataView(source, offset, node.l));
@@ -1442,11 +1444,17 @@ function deserializePromiseFulfill(ctx, depth, node) {
1442
1444
  }
1443
1445
  function deserializeIteratorFactoryInstance(ctx, depth, node) {
1444
1446
  deserialize$1(ctx, depth, node.a[0]);
1445
- return sequenceToIterator(deserialize$1(ctx, depth, node.a[1]));
1447
+ const source = deserialize$1(ctx, depth, node.a[1]);
1448
+ validateNodeType(ctx, node, node.a[1].i, 35);
1449
+ if (!source) throw new SerovalMalformedNodeError(node.a[1]);
1450
+ return sequenceToIterator(source);
1446
1451
  }
1447
1452
  function deserializeAsyncIteratorFactoryInstance(ctx, depth, node) {
1448
1453
  deserialize$1(ctx, depth, node.a[0]);
1449
- return streamToAsyncIterable(deserialize$1(ctx, depth, node.a[1]));
1454
+ const source = deserialize$1(ctx, depth, node.a[1]);
1455
+ validateNodeType(ctx, node, node.a[1].i, 31);
1456
+ if (!source) throw new SerovalMalformedNodeError(node.a[1]);
1457
+ return streamToAsyncIterable(source);
1450
1458
  }
1451
1459
  function deserializeStreamConstructor(ctx, depth, node) {
1452
1460
  const result = assignIndexedValue$1(ctx, node.i, createStream());
@@ -1491,6 +1499,7 @@ function deserializeAsyncIteratorFactory(ctx, depth, node) {
1491
1499
  }
1492
1500
  function deserializeSequence(ctx, depth, node) {
1493
1501
  const result = assignIndexedValue$1(ctx, node.i, createSequence([], node.s, node.l));
1502
+ assignNodeType(ctx, node.i, 35);
1494
1503
  for (let i = 0, len = node.a.length; i < len; i++) result.v[i] = deserialize$1(ctx, depth, node.a[i]);
1495
1504
  return result;
1496
1505
  }
@@ -2936,6 +2945,7 @@ exports.deserialize = deserialize;
2936
2945
  exports.fromCrossJSON = fromCrossJSON;
2937
2946
  exports.fromJSON = fromJSON;
2938
2947
  exports.getCrossReferenceHeader = getCrossReferenceHeader;
2948
+ exports.isStream = isStream;
2939
2949
  exports.resolvePlugins = resolvePlugins;
2940
2950
  exports.serialize = serialize;
2941
2951
  exports.serializeAsync = serializeAsync;
package/dist/index.d.cts CHANGED
@@ -737,6 +737,7 @@ interface Stream<T> {
737
737
  throw(value: unknown): void;
738
738
  return(value: T): void;
739
739
  }
740
+ declare function isStream<T>(value: object): value is Stream<T>;
740
741
  declare function createStream<T>(): Stream<T>;
741
742
  //#endregion
742
743
  //#region src/core/tree/index.d.ts
@@ -758,4 +759,4 @@ declare function toJSONAsync<T>(source: T, options?: AsyncParserContextOptions$1
758
759
  declare function compileJSON(source: SerovalJSON, options?: PluginAccessOptions): string;
759
760
  declare function fromJSON<T>(source: SerovalJSON, options?: FromJSONOptions): T;
760
761
  //#endregion
761
- export { type AsyncParsePluginContext, AsyncParserContextOptions, type BaseDeserializerContextOptions, type BaseParserContextOptions, type BaseSerializerContextOptions, type CrossContextOptions, type CrossDeserializerContextOptions, CrossSerializeAsyncOptions, CrossSerializeOptions, CrossSerializeStreamOptions, type CrossSerializerContextOptions, type DeserializePluginContext, Feature, FromCrossJSONOptions, FromJSONOptions, OpaqueReference, Plugin, PluginAccessOptions, PluginData, PluginInfo, type SerializePluginContext, Serializer, SerovalConflictedNodeIdError, SerovalDepthLimitError, SerovalDeserializationError, SerovalError, SerovalJSON, SerovalMalformedNodeError, SerovalMissingInstanceError, SerovalMissingPluginError, SerovalMissingReferenceError, SerovalMissingReferenceForIdError, SerovalMode, type SerovalNode, SerovalParserError, SerovalSerializationError, SerovalUnknownTypedArrayError, SerovalUnsupportedNodeError, SerovalUnsupportedTypeError, type Stream, type StreamListener, type StreamParsePluginContext, type StreamParserContextOptions, type SyncParsePluginContext, SyncParserContextOptions, ToCrossJSONAsyncOptions, ToCrossJSONOptions, ToCrossJSONStreamOptions, type VanillaDeserializerContextOptions, type VanillaSerializerContextOptions, compileJSON, createPlugin, createReference, createStream, crossSerialize, crossSerializeAsync, crossSerializeStream, deserialize, fromCrossJSON, fromJSON, getCrossReferenceHeader, resolvePlugins, serialize, serializeAsync, toCrossJSON, toCrossJSONAsync, toCrossJSONStream, toJSON, toJSONAsync };
762
+ export { type AsyncParsePluginContext, AsyncParserContextOptions, type BaseDeserializerContextOptions, type BaseParserContextOptions, type BaseSerializerContextOptions, type CrossContextOptions, type CrossDeserializerContextOptions, CrossSerializeAsyncOptions, CrossSerializeOptions, CrossSerializeStreamOptions, type CrossSerializerContextOptions, type DeserializePluginContext, Feature, FromCrossJSONOptions, FromJSONOptions, OpaqueReference, Plugin, PluginAccessOptions, PluginData, PluginInfo, type SerializePluginContext, Serializer, SerovalConflictedNodeIdError, SerovalDepthLimitError, SerovalDeserializationError, SerovalError, SerovalJSON, SerovalMalformedNodeError, SerovalMissingInstanceError, SerovalMissingPluginError, SerovalMissingReferenceError, SerovalMissingReferenceForIdError, SerovalMode, type SerovalNode, SerovalParserError, SerovalSerializationError, SerovalUnknownTypedArrayError, SerovalUnsupportedNodeError, SerovalUnsupportedTypeError, type Stream, type StreamListener, type StreamParsePluginContext, type StreamParserContextOptions, type SyncParsePluginContext, SyncParserContextOptions, ToCrossJSONAsyncOptions, ToCrossJSONOptions, ToCrossJSONStreamOptions, type VanillaDeserializerContextOptions, type VanillaSerializerContextOptions, compileJSON, createPlugin, createReference, createStream, crossSerialize, crossSerializeAsync, crossSerializeStream, deserialize, fromCrossJSON, fromJSON, getCrossReferenceHeader, isStream, resolvePlugins, serialize, serializeAsync, toCrossJSON, toCrossJSONAsync, toCrossJSONStream, toJSON, toJSONAsync };
package/dist/index.d.ts CHANGED
@@ -737,6 +737,7 @@ interface Stream<T> {
737
737
  throw(value: unknown): void;
738
738
  return(value: T): void;
739
739
  }
740
+ declare function isStream<T>(value: object): value is Stream<T>;
740
741
  declare function createStream<T>(): Stream<T>;
741
742
  //#endregion
742
743
  //#region src/core/tree/index.d.ts
@@ -758,4 +759,4 @@ declare function toJSONAsync<T>(source: T, options?: AsyncParserContextOptions$1
758
759
  declare function compileJSON(source: SerovalJSON, options?: PluginAccessOptions): string;
759
760
  declare function fromJSON<T>(source: SerovalJSON, options?: FromJSONOptions): T;
760
761
  //#endregion
761
- export { type AsyncParsePluginContext, AsyncParserContextOptions, type BaseDeserializerContextOptions, type BaseParserContextOptions, type BaseSerializerContextOptions, type CrossContextOptions, type CrossDeserializerContextOptions, CrossSerializeAsyncOptions, CrossSerializeOptions, CrossSerializeStreamOptions, type CrossSerializerContextOptions, type DeserializePluginContext, Feature, FromCrossJSONOptions, FromJSONOptions, OpaqueReference, Plugin, PluginAccessOptions, PluginData, PluginInfo, type SerializePluginContext, Serializer, SerovalConflictedNodeIdError, SerovalDepthLimitError, SerovalDeserializationError, SerovalError, SerovalJSON, SerovalMalformedNodeError, SerovalMissingInstanceError, SerovalMissingPluginError, SerovalMissingReferenceError, SerovalMissingReferenceForIdError, SerovalMode, type SerovalNode, SerovalParserError, SerovalSerializationError, SerovalUnknownTypedArrayError, SerovalUnsupportedNodeError, SerovalUnsupportedTypeError, type Stream, type StreamListener, type StreamParsePluginContext, type StreamParserContextOptions, type SyncParsePluginContext, SyncParserContextOptions, ToCrossJSONAsyncOptions, ToCrossJSONOptions, ToCrossJSONStreamOptions, type VanillaDeserializerContextOptions, type VanillaSerializerContextOptions, compileJSON, createPlugin, createReference, createStream, crossSerialize, crossSerializeAsync, crossSerializeStream, deserialize, fromCrossJSON, fromJSON, getCrossReferenceHeader, resolvePlugins, serialize, serializeAsync, toCrossJSON, toCrossJSONAsync, toCrossJSONStream, toJSON, toJSONAsync };
762
+ export { type AsyncParsePluginContext, AsyncParserContextOptions, type BaseDeserializerContextOptions, type BaseParserContextOptions, type BaseSerializerContextOptions, type CrossContextOptions, type CrossDeserializerContextOptions, CrossSerializeAsyncOptions, CrossSerializeOptions, CrossSerializeStreamOptions, type CrossSerializerContextOptions, type DeserializePluginContext, Feature, FromCrossJSONOptions, FromJSONOptions, OpaqueReference, Plugin, PluginAccessOptions, PluginData, PluginInfo, type SerializePluginContext, Serializer, SerovalConflictedNodeIdError, SerovalDepthLimitError, SerovalDeserializationError, SerovalError, SerovalJSON, SerovalMalformedNodeError, SerovalMissingInstanceError, SerovalMissingPluginError, SerovalMissingReferenceError, SerovalMissingReferenceForIdError, SerovalMode, type SerovalNode, SerovalParserError, SerovalSerializationError, SerovalUnknownTypedArrayError, SerovalUnsupportedNodeError, SerovalUnsupportedTypeError, type Stream, type StreamListener, type StreamParsePluginContext, type StreamParserContextOptions, type SyncParsePluginContext, SyncParserContextOptions, ToCrossJSONAsyncOptions, ToCrossJSONOptions, ToCrossJSONStreamOptions, type VanillaDeserializerContextOptions, type VanillaSerializerContextOptions, compileJSON, createPlugin, createReference, createStream, crossSerialize, crossSerializeAsync, crossSerializeStream, deserialize, fromCrossJSON, fromJSON, getCrossReferenceHeader, isStream, resolvePlugins, serialize, serializeAsync, toCrossJSON, toCrossJSONAsync, toCrossJSONStream, toJSON, toJSONAsync };
package/dist/index.js CHANGED
@@ -1374,6 +1374,7 @@ function deserializeTypedArray(ctx, depth, node) {
1374
1374
  var _node$b;
1375
1375
  const construct = getTypedArrayConstructor(node.c);
1376
1376
  const source = deserialize$1(ctx, depth, node.f);
1377
+ if (!(source instanceof ArrayBuffer)) throw new SerovalMalformedNodeError(node);
1377
1378
  const offset = (_node$b = node.b) !== null && _node$b !== void 0 ? _node$b : 0;
1378
1379
  if (offset < 0 || offset > source.byteLength || node.l > MAX_BASE64_LENGTH) throw new SerovalMalformedNodeError(node);
1379
1380
  return assignIndexedValue$1(ctx, node.i, new construct(source, offset, node.l));
@@ -1381,6 +1382,7 @@ function deserializeTypedArray(ctx, depth, node) {
1381
1382
  function deserializeDataView(ctx, depth, node) {
1382
1383
  var _node$b2;
1383
1384
  const source = deserialize$1(ctx, depth, node.f);
1385
+ if (!(source instanceof ArrayBuffer)) throw new SerovalMalformedNodeError(node);
1384
1386
  const offset = (_node$b2 = node.b) !== null && _node$b2 !== void 0 ? _node$b2 : 0;
1385
1387
  if (offset < 0 || offset > source.byteLength || node.l > MAX_BASE64_LENGTH) throw new SerovalMalformedNodeError(node);
1386
1388
  return assignIndexedValue$1(ctx, node.i, new DataView(source, offset, node.l));
@@ -1441,11 +1443,17 @@ function deserializePromiseFulfill(ctx, depth, node) {
1441
1443
  }
1442
1444
  function deserializeIteratorFactoryInstance(ctx, depth, node) {
1443
1445
  deserialize$1(ctx, depth, node.a[0]);
1444
- return sequenceToIterator(deserialize$1(ctx, depth, node.a[1]));
1446
+ const source = deserialize$1(ctx, depth, node.a[1]);
1447
+ validateNodeType(ctx, node, node.a[1].i, 35);
1448
+ if (!source) throw new SerovalMalformedNodeError(node.a[1]);
1449
+ return sequenceToIterator(source);
1445
1450
  }
1446
1451
  function deserializeAsyncIteratorFactoryInstance(ctx, depth, node) {
1447
1452
  deserialize$1(ctx, depth, node.a[0]);
1448
- return streamToAsyncIterable(deserialize$1(ctx, depth, node.a[1]));
1453
+ const source = deserialize$1(ctx, depth, node.a[1]);
1454
+ validateNodeType(ctx, node, node.a[1].i, 31);
1455
+ if (!source) throw new SerovalMalformedNodeError(node.a[1]);
1456
+ return streamToAsyncIterable(source);
1449
1457
  }
1450
1458
  function deserializeStreamConstructor(ctx, depth, node) {
1451
1459
  const result = assignIndexedValue$1(ctx, node.i, createStream());
@@ -1490,6 +1498,7 @@ function deserializeAsyncIteratorFactory(ctx, depth, node) {
1490
1498
  }
1491
1499
  function deserializeSequence(ctx, depth, node) {
1492
1500
  const result = assignIndexedValue$1(ctx, node.i, createSequence([], node.s, node.l));
1501
+ assignNodeType(ctx, node.i, 35);
1493
1502
  for (let i = 0, len = node.a.length; i < len; i++) result.v[i] = deserialize$1(ctx, depth, node.a[i]);
1494
1503
  return result;
1495
1504
  }
@@ -2906,4 +2915,4 @@ function fromJSON(source, options = {}) {
2906
2915
  }), source.t);
2907
2916
  }
2908
2917
  //#endregion
2909
- export { Feature, OpaqueReference, Serializer, SerovalConflictedNodeIdError, SerovalDepthLimitError, SerovalDeserializationError, SerovalError, SerovalMalformedNodeError, SerovalMissingInstanceError, SerovalMissingPluginError, SerovalMissingReferenceError, SerovalMissingReferenceForIdError, SerovalMode, SerovalParserError, SerovalSerializationError, SerovalUnknownTypedArrayError, SerovalUnsupportedNodeError, SerovalUnsupportedTypeError, compileJSON, createPlugin, createReference, createStream, crossSerialize, crossSerializeAsync, crossSerializeStream, deserialize, fromCrossJSON, fromJSON, getCrossReferenceHeader, resolvePlugins, serialize, serializeAsync, toCrossJSON, toCrossJSONAsync, toCrossJSONStream, toJSON, toJSONAsync };
2918
+ export { Feature, OpaqueReference, Serializer, SerovalConflictedNodeIdError, SerovalDepthLimitError, SerovalDeserializationError, SerovalError, SerovalMalformedNodeError, SerovalMissingInstanceError, SerovalMissingPluginError, SerovalMissingReferenceError, SerovalMissingReferenceForIdError, SerovalMode, SerovalParserError, SerovalSerializationError, SerovalUnknownTypedArrayError, SerovalUnsupportedNodeError, SerovalUnsupportedTypeError, compileJSON, createPlugin, createReference, createStream, crossSerialize, crossSerializeAsync, crossSerializeStream, deserialize, fromCrossJSON, fromJSON, getCrossReferenceHeader, isStream, resolvePlugins, serialize, serializeAsync, toCrossJSON, toCrossJSONAsync, toCrossJSONStream, toJSON, toJSONAsync };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "seroval",
3
3
  "type": "module",
4
- "version": "1.6.3",
4
+ "version": "1.6.5",
5
5
  "files": [
6
6
  "dist"
7
7
  ],
@@ -19,7 +19,7 @@
19
19
  "@types/node": "^26.2.0",
20
20
  "@vitest/ui": "^4.1.10",
21
21
  "esbuild": "^0.28.2",
22
- "temporal-polyfill": "^1.0.3",
22
+ "temporal-polyfill": "^1.0.4",
23
23
  "ts-prune": "^0.10.3",
24
24
  "tsdown": "^0.22.14",
25
25
  "tslib": "^2.8.1",