protobufjs 7.5.9 → 7.6.1

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 CHANGED
@@ -184,7 +184,7 @@ With that in mind and again for performance reasons, each message class provides
184
184
  ```js
185
185
  var object = AwesomeMessage.toObject(message, {
186
186
  enums: String, // enums as string names
187
- longs: String, // longs as strings (requires long.js)
187
+ longs: String, // longs as strings (or BigInt for bigint values)
188
188
  bytes: String, // bytes as base64 encoded strings
189
189
  defaults: true, // includes default values
190
190
  arrays: true, // populates empty arrays (repeated fields) even if defaults=false
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * protobuf.js v7.5.9 (c) 2016, daniel wirtz
3
- * compiled sun, 17 may 2026 16:51:59 utc
2
+ * protobuf.js v7.6.1 (c) 2016, daniel wirtz
3
+ * compiled fri, 22 may 2026 02:52:08 utc
4
4
  * licensed under the bsd-3-clause license
5
5
  * see: https://github.com/dcodeio/protobuf.js for details
6
6
  */
@@ -363,15 +363,23 @@ function EventEmitter() {
363
363
  * @type {Object.<string,*>}
364
364
  * @private
365
365
  */
366
- this._listeners = {};
366
+ this._listeners = Object.create(null);
367
367
  }
368
368
 
369
+ /**
370
+ * Event listener as used by {@link util.EventEmitter}.
371
+ * @typedef EventEmitterListener
372
+ * @type {function}
373
+ * @param {...*} args Arguments
374
+ * @returns {undefined}
375
+ */
376
+
369
377
  /**
370
378
  * Registers an event listener.
371
379
  * @param {string} evt Event name
372
- * @param {function} fn Listener
380
+ * @param {EventEmitterListener} fn Listener
373
381
  * @param {*} [ctx] Listener context
374
- * @returns {util.EventEmitter} `this`
382
+ * @returns {this} `this`
375
383
  */
376
384
  EventEmitter.prototype.on = function on(evt, fn, ctx) {
377
385
  (this._listeners[evt] || (this._listeners[evt] = [])).push({
@@ -384,17 +392,19 @@ EventEmitter.prototype.on = function on(evt, fn, ctx) {
384
392
  /**
385
393
  * Removes an event listener or any matching listeners if arguments are omitted.
386
394
  * @param {string} [evt] Event name. Removes all listeners if omitted.
387
- * @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted.
388
- * @returns {util.EventEmitter} `this`
395
+ * @param {EventEmitterListener} [fn] Listener to remove. Removes all listeners of `evt` if omitted.
396
+ * @returns {this} `this`
389
397
  */
390
398
  EventEmitter.prototype.off = function off(evt, fn) {
391
399
  if (evt === undefined)
392
- this._listeners = {};
400
+ this._listeners = Object.create(null);
393
401
  else {
394
402
  if (fn === undefined)
395
403
  this._listeners[evt] = [];
396
404
  else {
397
405
  var listeners = this._listeners[evt];
406
+ if (!listeners)
407
+ return this;
398
408
  for (var i = 0; i < listeners.length;)
399
409
  if (listeners[i].fn === fn)
400
410
  listeners.splice(i, 1);
@@ -409,7 +419,7 @@ EventEmitter.prototype.off = function off(evt, fn) {
409
419
  * Emits an event by calling its listeners with the specified arguments.
410
420
  * @param {string} evt Event name
411
421
  * @param {...*} args Arguments
412
- * @returns {util.EventEmitter} `this`
422
+ * @returns {this} `this`
413
423
  */
414
424
  EventEmitter.prototype.emit = function emit(evt) {
415
425
  var listeners = this._listeners[evt];
@@ -1217,14 +1227,14 @@ function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
1217
1227
  ("m%s=d%s|0", prop, prop);
1218
1228
  break;
1219
1229
  case "uint64":
1230
+ case "fixed64":
1220
1231
  isUnsigned = true;
1221
1232
  // eslint-disable-next-line no-fallthrough
1222
1233
  case "int64":
1223
1234
  case "sint64":
1224
- case "fixed64":
1225
1235
  case "sfixed64": gen
1226
1236
  ("if(util.Long)")
1227
- ("(m%s=util.Long.fromValue(d%s)).unsigned=%j", prop, prop, isUnsigned)
1237
+ ("m%s=util.Long.fromValue(d%s,%j)", prop, prop, isUnsigned)
1228
1238
  ("else if(typeof d%s===\"string\")", prop)
1229
1239
  ("m%s=parseInt(d%s,10)", prop, prop)
1230
1240
  ("else if(typeof d%s===\"number\")", prop)
@@ -1328,7 +1338,7 @@ function genValuePartial_toObject(gen, field, fieldIndex, prop) {
1328
1338
  if (field.resolvedType instanceof Enum) gen
1329
1339
  ("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s", prop, fieldIndex, prop, prop, fieldIndex, prop, prop);
1330
1340
  else gen
1331
- ("d%s=types[%i].toObject(m%s,o)", prop, fieldIndex, prop);
1341
+ ("d%s=types[%i].toObject(m%s,o,q+1)", prop, fieldIndex, prop);
1332
1342
  } else {
1333
1343
  var isUnsigned = false;
1334
1344
  switch (field.type) {
@@ -1337,13 +1347,15 @@ function genValuePartial_toObject(gen, field, fieldIndex, prop) {
1337
1347
  ("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s", prop, prop, prop, prop);
1338
1348
  break;
1339
1349
  case "uint64":
1350
+ case "fixed64":
1340
1351
  isUnsigned = true;
1341
1352
  // eslint-disable-next-line no-fallthrough
1342
1353
  case "int64":
1343
1354
  case "sint64":
1344
- case "fixed64":
1345
1355
  case "sfixed64": gen
1346
- ("if(typeof m%s===\"number\")", prop)
1356
+ ("if(typeof BigInt!==\"undefined\"&&o.longs===BigInt)")
1357
+ ("d%s=typeof m%s===\"number\"?BigInt(m%s):util.Long.fromBits(m%s.low>>>0,m%s.high>>>0,%j).toBigInt()", prop, prop, prop, prop, prop, isUnsigned)
1358
+ ("else if(typeof m%s===\"number\")", prop)
1347
1359
  ("d%s=o.longs===String?String(m%s):m%s", prop, prop, prop)
1348
1360
  ("else") // Long-like
1349
1361
  ("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s", prop, prop, prop, prop, isUnsigned ? "true": "", prop);
@@ -1370,9 +1382,12 @@ converter.toObject = function toObject(mtype) {
1370
1382
  var fields = mtype.fieldsArray.slice().sort(util.compareFieldsById);
1371
1383
  if (!fields.length)
1372
1384
  return util.codegen()("return {}");
1373
- var gen = util.codegen(["m", "o"], mtype.name + "$toObject")
1385
+ var gen = util.codegen(["m", "o", "q"], mtype.name + "$toObject")
1374
1386
  ("if(!o)")
1375
1387
  ("o={}")
1388
+ ("if(q===undefined)q=0")
1389
+ ("if(q>util.recursionLimit)")
1390
+ ("throw Error(\"max depth exceeded\")")
1376
1391
  ("var d={}");
1377
1392
 
1378
1393
  var repeatedFields = [],
@@ -1411,9 +1426,9 @@ converter.toObject = function toObject(mtype) {
1411
1426
  else if (field.long) gen
1412
1427
  ("if(util.Long){")
1413
1428
  ("var n=new util.Long(%i,%i,%j)", field.typeDefault.low, field.typeDefault.high, field.typeDefault.unsigned)
1414
- ("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n", prop)
1429
+ ("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():typeof BigInt!==\"undefined\"&&o.longs===BigInt?n.toBigInt():n", prop)
1415
1430
  ("}else")
1416
- ("d%s=o.longs===String?%j:%i", prop, field.typeDefault.toString(), field.typeDefault.toNumber());
1431
+ ("d%s=o.longs===String?%j:typeof BigInt!==\"undefined\"&&o.longs===BigInt?BigInt(%j):%i", prop, field.typeDefault.toString(), field.typeDefault.toString(), field.typeDefault.toNumber());
1417
1432
  else if (field.bytes) {
1418
1433
  var arrayDefault = Array.prototype.slice.call(field.typeDefault);
1419
1434
  gen
@@ -1621,8 +1636,8 @@ var Enum = require(16),
1621
1636
  */
1622
1637
  function genTypePartial(gen, field, fieldIndex, ref) {
1623
1638
  return field.delimited
1624
- ? gen("types[%i].encode(%s,w.uint32(%i)).uint32(%i)", fieldIndex, ref, (field.id << 3 | 3) >>> 0, (field.id << 3 | 4) >>> 0)
1625
- : gen("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()", fieldIndex, ref, (field.id << 3 | 2) >>> 0);
1639
+ ? gen("types[%i].encode(%s,w.uint32(%i),q+1).uint32(%i)", fieldIndex, ref, (field.id << 3 | 3) >>> 0, (field.id << 3 | 4) >>> 0)
1640
+ : gen("types[%i].encode(%s,w.uint32(%i).fork(),q+1).ldelim()", fieldIndex, ref, (field.id << 3 | 2) >>> 0);
1626
1641
  }
1627
1642
 
1628
1643
  /**
@@ -1632,9 +1647,12 @@ function genTypePartial(gen, field, fieldIndex, ref) {
1632
1647
  */
1633
1648
  function encoder(mtype) {
1634
1649
  /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */
1635
- var gen = util.codegen(["m", "w"], mtype.name + "$encode")
1650
+ var gen = util.codegen(["m", "w", "q"], mtype.name + "$encode")
1636
1651
  ("if(!w)")
1637
- ("w=Writer.create()");
1652
+ ("w=Writer.create()")
1653
+ ("if(q===undefined)q=0")
1654
+ ("if(q>util.recursionLimit)")
1655
+ ("throw Error(\"max depth exceeded\")");
1638
1656
 
1639
1657
  var i, ref;
1640
1658
 
@@ -1655,7 +1673,7 @@ function encoder(mtype) {
1655
1673
  ("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){", ref)
1656
1674
  ("w.uint32(%i).fork().uint32(%i).%s(ks[i])", (field.id << 3 | 2) >>> 0, 8 | types.mapKey[field.keyType], field.keyType);
1657
1675
  if (wireType === undefined) gen
1658
- ("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()", index, ref); // can't be groups
1676
+ ("types[%i].encode(%s[ks[i]],w.uint32(18).fork(),q+1).ldelim().ldelim()", index, ref); // can't be groups
1659
1677
  else gen
1660
1678
  (".uint32(%i).%s(%s[ks[i]]).ldelim()", 16 | wireType, type, ref);
1661
1679
  gen
@@ -1793,8 +1811,8 @@ Enum.prototype._resolveFeatures = function _resolveFeatures(edition) {
1793
1811
  ReflectionObject.prototype._resolveFeatures.call(this, edition);
1794
1812
 
1795
1813
  Object.keys(this.values).forEach(key => {
1796
- var parentFeaturesCopy = Object.assign({}, this._features);
1797
- this._valuesFeatures[key] = Object.assign(parentFeaturesCopy, this.valuesOptions && this.valuesOptions[key] && this.valuesOptions[key].features);
1814
+ var parentFeaturesCopy = util.merge({}, this._features);
1815
+ this._valuesFeatures[key] = util.merge(parentFeaturesCopy, this.valuesOptions && this.valuesOptions[key] && this.valuesOptions[key].features || {});
1798
1816
  });
1799
1817
 
1800
1818
  return this;
@@ -2263,7 +2281,7 @@ Field.prototype.resolve = function resolve() {
2263
2281
 
2264
2282
  // convert to internal data type if necesssary
2265
2283
  if (this.long) {
2266
- this.typeDefault = util.Long.fromNumber(this.typeDefault, this.type.charAt(0) === "u");
2284
+ this.typeDefault = util.Long.fromNumber(this.typeDefault, this.type === "uint64" || this.type === "fixed64");
2267
2285
 
2268
2286
  /* istanbul ignore else */
2269
2287
  if (Object.freeze)
@@ -3306,6 +3324,8 @@ Namespace.prototype.define = function define(path, json) {
3306
3324
  throw TypeError("illegal path");
3307
3325
  if (path && path.length && path[0] === "")
3308
3326
  throw Error("path must be relative");
3327
+ if (path.length > util.recursionLimit)
3328
+ throw Error("max depth exceeded");
3309
3329
 
3310
3330
  var ptr = this;
3311
3331
  while (path.length > 0) {
@@ -3740,7 +3760,7 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
3740
3760
  throw new Error("Unknown edition for " + this.fullName);
3741
3761
  }
3742
3762
 
3743
- var protoFeatures = Object.assign(this.options ? Object.assign({}, this.options.features) : {},
3763
+ var protoFeatures = util.merge({}, this.options && this.options.features,
3744
3764
  this._inferLegacyProtoFeatures(edition));
3745
3765
 
3746
3766
  if (this._edition) {
@@ -3755,7 +3775,7 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
3755
3775
  } else {
3756
3776
  throw new Error("Unknown edition: " + edition);
3757
3777
  }
3758
- this._features = Object.assign(defaults, protoFeatures || {});
3778
+ this._features = util.merge(defaults, protoFeatures);
3759
3779
  this._featuresResolved = true;
3760
3780
  return;
3761
3781
  }
@@ -3764,13 +3784,13 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
3764
3784
  // special-case it
3765
3785
  /* istanbul ignore else */
3766
3786
  if (this.partOf instanceof OneOf) {
3767
- var lexicalParentFeaturesCopy = Object.assign({}, this.partOf._features);
3768
- this._features = Object.assign(lexicalParentFeaturesCopy, protoFeatures || {});
3787
+ var lexicalParentFeaturesCopy = util.merge({}, this.partOf._features);
3788
+ this._features = util.merge(lexicalParentFeaturesCopy, protoFeatures);
3769
3789
  } else if (this.declaringField) {
3770
3790
  // Skip feature resolution of sister fields.
3771
3791
  } else if (this.parent) {
3772
- var parentFeaturesCopy = Object.assign({}, this.parent._features);
3773
- this._features = Object.assign(parentFeaturesCopy, protoFeatures || {});
3792
+ var parentFeaturesCopy = util.merge({}, this.parent._features);
3793
+ this._features = util.merge(parentFeaturesCopy, protoFeatures);
3774
3794
  } else {
3775
3795
  throw new Error("Unable to find a parent for " + this.fullName);
3776
3796
  }
@@ -4754,8 +4774,12 @@ Root.prototype.load = function load(filename, options, callback) {
4754
4774
  }
4755
4775
 
4756
4776
  // Processes a single file
4757
- function process(filename, source) {
4777
+ function process(filename, source, depth) {
4778
+ if (depth === undefined)
4779
+ depth = 0;
4758
4780
  try {
4781
+ if (depth > util.recursionLimit)
4782
+ throw Error("max depth exceeded");
4759
4783
  if (util.isString(source) && source.charAt(0) === "{")
4760
4784
  source = JSON.parse(source);
4761
4785
  if (!util.isString(source))
@@ -4768,11 +4792,11 @@ Root.prototype.load = function load(filename, options, callback) {
4768
4792
  if (parsed.imports)
4769
4793
  for (; i < parsed.imports.length; ++i)
4770
4794
  if (resolved = getBundledFileName(parsed.imports[i]) || self.resolvePath(filename, parsed.imports[i]))
4771
- fetch(resolved);
4795
+ fetch(resolved, false, depth + 1);
4772
4796
  if (parsed.weakImports)
4773
4797
  for (i = 0; i < parsed.weakImports.length; ++i)
4774
4798
  if (resolved = getBundledFileName(parsed.weakImports[i]) || self.resolvePath(filename, parsed.weakImports[i]))
4775
- fetch(resolved, true);
4799
+ fetch(resolved, true, depth + 1);
4776
4800
  }
4777
4801
  } catch (err) {
4778
4802
  finish(err);
@@ -4783,7 +4807,9 @@ Root.prototype.load = function load(filename, options, callback) {
4783
4807
  }
4784
4808
 
4785
4809
  // Fetches a single file
4786
- function fetch(filename, weak) {
4810
+ function fetch(filename, weak, depth) {
4811
+ if (depth === undefined)
4812
+ depth = 0;
4787
4813
  filename = getBundledFileName(filename) || filename;
4788
4814
 
4789
4815
  // Skip if already loaded / attempted
@@ -4795,12 +4821,12 @@ Root.prototype.load = function load(filename, options, callback) {
4795
4821
  // Shortcut bundled definitions
4796
4822
  if (filename in common) {
4797
4823
  if (sync) {
4798
- process(filename, common[filename]);
4824
+ process(filename, common[filename], depth);
4799
4825
  } else {
4800
4826
  ++queued;
4801
4827
  setTimeout(function() {
4802
4828
  --queued;
4803
- process(filename, common[filename]);
4829
+ process(filename, common[filename], depth);
4804
4830
  });
4805
4831
  }
4806
4832
  return;
@@ -4816,7 +4842,7 @@ Root.prototype.load = function load(filename, options, callback) {
4816
4842
  finish(err);
4817
4843
  return;
4818
4844
  }
4819
- process(filename, source);
4845
+ process(filename, source, depth);
4820
4846
  } else {
4821
4847
  ++queued;
4822
4848
  self.fetch(filename, function(err, source) {
@@ -4833,7 +4859,7 @@ Root.prototype.load = function load(filename, options, callback) {
4833
4859
  finish(null, self);
4834
4860
  return;
4835
4861
  }
4836
- process(filename, source);
4862
+ process(filename, source, depth);
4837
4863
  });
4838
4864
  }
4839
4865
  }
@@ -5660,7 +5686,10 @@ function clearCache(type) {
5660
5686
  * @returns {Type} Created message type
5661
5687
  */
5662
5688
  Type.fromJSON = function fromJSON(name, json, depth) {
5663
- depth = util.checkDepth(depth);
5689
+ if (depth === undefined)
5690
+ depth = 0;
5691
+ if (depth > util.nestingLimit)
5692
+ throw Error("max depth exceeded");
5664
5693
  var type = new Type(name, json.options);
5665
5694
  type.extensions = json.extensions;
5666
5695
  type.reserved = json.reserved;
@@ -5938,8 +5967,8 @@ Type.prototype.setup = function setup() {
5938
5967
  * @param {Writer} [writer] Writer to encode to
5939
5968
  * @returns {Writer} writer
5940
5969
  */
5941
- Type.prototype.encode = function encode_setup(message, writer) {
5942
- return this.setup().encode(message, writer); // overrides this method
5970
+ Type.prototype.encode = function encode_setup(message, writer) { // eslint-disable-line no-unused-vars
5971
+ return this.setup().encode.apply(this, arguments); // overrides this method
5943
5972
  };
5944
5973
 
5945
5974
  /**
@@ -6003,7 +6032,7 @@ Type.prototype.fromObject = function fromObject(object, depth) {
6003
6032
  * Conversion options as used by {@link Type#toObject} and {@link Message.toObject}.
6004
6033
  * @interface IConversionOptions
6005
6034
  * @property {Function} [longs] Long conversion type.
6006
- * Valid values are `String` and `Number` (the global types).
6035
+ * Valid values are `BigInt`, `String` and `Number` (the global types).
6007
6036
  * Defaults to copy the present value, which is a possibly unsafe number without and a {@link Long} with a long library.
6008
6037
  * @property {Function} [enums] Enum value conversion type.
6009
6038
  * Only valid value is `String` (the global type).
@@ -6024,8 +6053,8 @@ Type.prototype.fromObject = function fromObject(object, depth) {
6024
6053
  * @param {IConversionOptions} [options] Conversion options
6025
6054
  * @returns {Object.<string,*>} Plain object
6026
6055
  */
6027
- Type.prototype.toObject = function toObject(message, options) {
6028
- return this.setup().toObject(message, options);
6056
+ Type.prototype.toObject = function toObject(message, options) { // eslint-disable-line no-unused-vars
6057
+ return this.setup().toObject.apply(this, arguments);
6029
6058
  };
6030
6059
 
6031
6060
  /**
@@ -6266,8 +6295,7 @@ util.fetch = require(5);
6266
6295
  util.path = require(9);
6267
6296
  util.patterns = require(39);
6268
6297
 
6269
- var reservedRe = util.patterns.reservedRe,
6270
- unsafePropertyRe = util.patterns.unsafePropertyRe;
6298
+ var reservedRe = util.patterns.reservedRe;
6271
6299
 
6272
6300
  /**
6273
6301
  * Node's fs module if available.
@@ -6442,7 +6470,7 @@ util.decorateEnum = function decorateEnum(object) {
6442
6470
  util.setProperty = function setProperty(dst, path, value, ifNotSet) {
6443
6471
  function setProp(dst, path, value) {
6444
6472
  var part = path.shift();
6445
- if (unsafePropertyRe.test(part))
6473
+ if (util.isUnsafeProperty(part))
6446
6474
  return dst;
6447
6475
  if (path.length > 0) {
6448
6476
  dst[part] = setProp(dst[part] || {}, path, value);
@@ -6463,6 +6491,8 @@ util.setProperty = function setProperty(dst, path, value, ifNotSet) {
6463
6491
  throw TypeError("path must be specified");
6464
6492
 
6465
6493
  path = path.split(".");
6494
+ if (path.length > util.recursionLimit)
6495
+ throw Error("max depth exceeded");
6466
6496
  return setProp(dst, path, value);
6467
6497
  };
6468
6498
 
@@ -6721,6 +6751,18 @@ util.pool = require(10);
6721
6751
  // utility to work with the low and high bits of a 64 bit value
6722
6752
  util.LongBits = require(37);
6723
6753
 
6754
+ /**
6755
+ * Tests if the specified key can affect object prototypes.
6756
+ * @memberof util
6757
+ * @param {string} key Key to test
6758
+ * @returns {boolean} `true` if the key is unsafe
6759
+ */
6760
+ function isUnsafeProperty(key) {
6761
+ return key === "__proto__" || key === "prototype" || key === "constructor";
6762
+ }
6763
+
6764
+ util.isUnsafeProperty = isUnsafeProperty;
6765
+
6724
6766
  /**
6725
6767
  * Whether running within node or not.
6726
6768
  * @memberof util
@@ -6934,26 +6976,39 @@ util.longFromHash = function longFromHash(hash, unsigned) {
6934
6976
  * Merges the properties of the source object into the destination object.
6935
6977
  * @memberof util
6936
6978
  * @param {Object.<string,*>} dst Destination object
6937
- * @param {Object.<string,*>} src Source object
6938
- * @param {boolean} [ifNotSet=false] Merges only if the key is not already set
6979
+ * @param {...(Object.<string,*>|boolean)} src Source objects, optionally followed by an `ifNotSet` flag
6939
6980
  * @returns {Object.<string,*>} Destination object
6940
6981
  */
6941
- function merge(dst, src, ifNotSet) { // used by converters
6942
- for (var keys = Object.keys(src), i = 0; i < keys.length; ++i)
6943
- if (dst[keys[i]] === undefined || !ifNotSet)
6944
- if (keys[i] !== "__proto__")
6982
+ function merge(dst) { // used by converters
6983
+ var ifNotSet = typeof arguments[arguments.length - 1] === "boolean",
6984
+ limit = ifNotSet ? arguments.length - 1 : arguments.length;
6985
+ ifNotSet = ifNotSet && arguments[arguments.length - 1];
6986
+ for (var a = 1; a < limit; ++a) {
6987
+ var src = arguments[a];
6988
+ if (!src)
6989
+ continue;
6990
+ for (var keys = Object.keys(src), i = 0; i < keys.length; ++i)
6991
+ if (!isUnsafeProperty(keys[i]) && (dst[keys[i]] === undefined || !ifNotSet))
6945
6992
  dst[keys[i]] = src[keys[i]];
6993
+ }
6946
6994
  return dst;
6947
6995
  }
6948
6996
 
6949
6997
  util.merge = merge;
6950
6998
 
6999
+ /**
7000
+ * Schema declaration nesting limit.
7001
+ * @memberof util
7002
+ * @type {number}
7003
+ */
7004
+ util.nestingLimit = 32; // protoc: MaxMessageDeclarationNestingDepth
7005
+
6951
7006
  /**
6952
7007
  * Recursion limit.
6953
7008
  * @memberof util
6954
7009
  * @type {number}
6955
7010
  */
6956
- util.recursionLimit = 100;
7011
+ util.recursionLimit = 100; // protoc: CodedInputStream::default_recursion_limit_
6957
7012
 
6958
7013
  /**
6959
7014
  * Makes a property safe for assignment as an own property.
@@ -7172,7 +7227,6 @@ var patterns = exports;
7172
7227
  patterns.numberRe = /^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/;
7173
7228
  patterns.typeRefRe = /^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/;
7174
7229
  patterns.reservedRe = /^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/;
7175
- patterns.unsafePropertyRe = /^(?:__proto__|prototype|constructor)$/;
7176
7230
 
7177
7231
  },{}],40:[function(require,module,exports){
7178
7232
  "use strict";
@@ -7366,7 +7420,8 @@ function verifier(mtype) {
7366
7420
  */
7367
7421
  var wrappers = exports;
7368
7422
 
7369
- var Message = require(21);
7423
+ var Message = require(21),
7424
+ util = require(38);
7370
7425
 
7371
7426
  /**
7372
7427
  * From object converter part of an {@link IWrapper}.
@@ -7413,10 +7468,9 @@ wrappers[".google.protobuf.Any"] = {
7413
7468
  if (type_url.indexOf("/") === -1) {
7414
7469
  type_url = "/" + type_url;
7415
7470
  }
7416
- var nextDepth = depth === undefined ? 1 : depth + 1;
7417
7471
  return this.create({
7418
7472
  type_url: type_url,
7419
- value: type.encode(type.fromObject(object, nextDepth)).finish()
7473
+ value: type.encode(type.fromObject(object, depth === undefined ? 1 : depth + 1)).finish()
7420
7474
  });
7421
7475
  }
7422
7476
  }
@@ -7424,7 +7478,11 @@ wrappers[".google.protobuf.Any"] = {
7424
7478
  return this.fromObject(object, depth);
7425
7479
  },
7426
7480
 
7427
- toObject: function(message, options) {
7481
+ toObject: function(message, options, depth) {
7482
+ if (depth === undefined)
7483
+ depth = 0;
7484
+ if (depth > util.recursionLimit)
7485
+ throw Error("max depth exceeded");
7428
7486
 
7429
7487
  // Default prefix
7430
7488
  var googleApi = "type.googleapis.com/";
@@ -7440,12 +7498,12 @@ wrappers[".google.protobuf.Any"] = {
7440
7498
  var type = this.lookup(name);
7441
7499
  /* istanbul ignore else */
7442
7500
  if (type)
7443
- message = type.decode(message.value);
7501
+ message = type.decode(message.value, undefined, undefined, depth + 1);
7444
7502
  }
7445
7503
 
7446
7504
  // wrap value if unmapped
7447
7505
  if (!(message instanceof this.ctor) && message instanceof Message) {
7448
- var object = message.$type.toObject(message, options);
7506
+ var object = message.$type.toObject(message, options, depth + 1);
7449
7507
  var messageName = message.$type.fullName[0] === "." ?
7450
7508
  message.$type.fullName.slice(1) : message.$type.fullName;
7451
7509
  // Default to type.googleapis.com prefix if no prefix is used
@@ -7457,11 +7515,11 @@ wrappers[".google.protobuf.Any"] = {
7457
7515
  return object;
7458
7516
  }
7459
7517
 
7460
- return this.toObject(message, options);
7518
+ return this.toObject(message, options, depth);
7461
7519
  }
7462
7520
  };
7463
7521
 
7464
- },{"21":21}],42:[function(require,module,exports){
7522
+ },{"21":21,"38":38}],42:[function(require,module,exports){
7465
7523
  "use strict";
7466
7524
  module.exports = Writer;
7467
7525
 
@@ -7689,7 +7747,7 @@ Writer.prototype.uint32 = function write_uint32(value) {
7689
7747
  * @returns {Writer} `this`
7690
7748
  */
7691
7749
  Writer.prototype.int32 = function write_int32(value) {
7692
- return value < 0
7750
+ return (value |= 0) < 0
7693
7751
  ? this._push(writeVarint64, 10, LongBits.fromNumber(value)) // 10 bytes per spec
7694
7752
  : this.uint32(value);
7695
7753
  };
@@ -7704,16 +7762,18 @@ Writer.prototype.sint32 = function write_sint32(value) {
7704
7762
  };
7705
7763
 
7706
7764
  function writeVarint64(val, buf, pos) {
7707
- while (val.hi) {
7708
- buf[pos++] = val.lo & 127 | 128;
7709
- val.lo = (val.lo >>> 7 | val.hi << 25) >>> 0;
7710
- val.hi >>>= 7;
7765
+ var lo = val.lo,
7766
+ hi = val.hi;
7767
+ while (hi) {
7768
+ buf[pos++] = lo & 127 | 128;
7769
+ lo = (lo >>> 7 | hi << 25) >>> 0;
7770
+ hi >>>= 7;
7711
7771
  }
7712
- while (val.lo > 127) {
7713
- buf[pos++] = val.lo & 127 | 128;
7714
- val.lo = val.lo >>> 7;
7772
+ while (lo > 127) {
7773
+ buf[pos++] = lo & 127 | 128;
7774
+ lo = lo >>> 7;
7715
7775
  }
7716
- buf[pos++] = val.lo;
7776
+ buf[pos++] = lo;
7717
7777
  }
7718
7778
 
7719
7779
  /**