protobufjs 7.6.0 → 7.6.2

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/protobuf.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * protobuf.js v7.6.0 (c) 2016, daniel wirtz
3
- * compiled mon, 18 may 2026 18:11:08 utc
2
+ * protobuf.js v7.6.2 (c) 2016, daniel wirtz
3
+ * compiled sat, 30 may 2026 21:57:57 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];
@@ -1598,7 +1608,7 @@ function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
1598
1608
  } gen
1599
1609
  ("}");
1600
1610
  } else gen
1601
- ("if(typeof d%s!==\"object\")", prop)
1611
+ ("if(!util.isObject(d%s))", prop)
1602
1612
  ("throw TypeError(%j)", field.fullName + ": object expected")
1603
1613
  ("m%s=types[%i].fromObject(d%s,n+1)", prop, fieldIndex, prop);
1604
1614
  } else {
@@ -1618,14 +1628,14 @@ function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
1618
1628
  ("m%s=d%s|0", prop, prop);
1619
1629
  break;
1620
1630
  case "uint64":
1631
+ case "fixed64":
1621
1632
  isUnsigned = true;
1622
1633
  // eslint-disable-next-line no-fallthrough
1623
1634
  case "int64":
1624
1635
  case "sint64":
1625
- case "fixed64":
1626
1636
  case "sfixed64": gen
1627
1637
  ("if(util.Long)")
1628
- ("(m%s=util.Long.fromValue(d%s)).unsigned=%j", prop, prop, isUnsigned)
1638
+ ("m%s=util.Long.fromValue(d%s,%j)", prop, prop, isUnsigned)
1629
1639
  ("else if(typeof d%s===\"string\")", prop)
1630
1640
  ("m%s=parseInt(d%s,10)", prop, prop)
1631
1641
  ("else if(typeof d%s===\"number\")", prop)
@@ -1665,6 +1675,8 @@ converter.fromObject = function fromObject(mtype) {
1665
1675
  var gen = util.codegen(["d", "n"], mtype.name + "$fromObject")
1666
1676
  ("if(d instanceof this.ctor)")
1667
1677
  ("return d")
1678
+ ("if(!util.isObject(d))")
1679
+ ("throw TypeError(%j)", mtype.fullName + ": object expected")
1668
1680
  ("if(n===undefined)n=0")
1669
1681
  ("if(n>util.recursionLimit)")
1670
1682
  ("throw Error(\"maximum nesting depth exceeded\")");
@@ -1679,7 +1691,7 @@ converter.fromObject = function fromObject(mtype) {
1679
1691
  // Map fields
1680
1692
  if (field.map) { gen
1681
1693
  ("if(d%s){", prop)
1682
- ("if(typeof d%s!==\"object\")", prop)
1694
+ ("if(!util.isObject(d%s))", prop)
1683
1695
  ("throw TypeError(%j)", field.fullName + ": object expected")
1684
1696
  ("m%s={}", prop)
1685
1697
  ("for(var ks=Object.keys(d%s),i=0;i<ks.length;++i){", prop);
@@ -1729,7 +1741,7 @@ function genValuePartial_toObject(gen, field, fieldIndex, prop) {
1729
1741
  if (field.resolvedType instanceof Enum) gen
1730
1742
  ("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);
1731
1743
  else gen
1732
- ("d%s=types[%i].toObject(m%s,o)", prop, fieldIndex, prop);
1744
+ ("d%s=types[%i].toObject(m%s,o,q+1)", prop, fieldIndex, prop);
1733
1745
  } else {
1734
1746
  var isUnsigned = false;
1735
1747
  switch (field.type) {
@@ -1738,11 +1750,11 @@ function genValuePartial_toObject(gen, field, fieldIndex, prop) {
1738
1750
  ("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s", prop, prop, prop, prop);
1739
1751
  break;
1740
1752
  case "uint64":
1753
+ case "fixed64":
1741
1754
  isUnsigned = true;
1742
1755
  // eslint-disable-next-line no-fallthrough
1743
1756
  case "int64":
1744
1757
  case "sint64":
1745
- case "fixed64":
1746
1758
  case "sfixed64": gen
1747
1759
  ("if(typeof BigInt!==\"undefined\"&&o.longs===BigInt)")
1748
1760
  ("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)
@@ -1773,9 +1785,12 @@ converter.toObject = function toObject(mtype) {
1773
1785
  var fields = mtype.fieldsArray.slice().sort(util.compareFieldsById);
1774
1786
  if (!fields.length)
1775
1787
  return util.codegen()("return {}");
1776
- var gen = util.codegen(["m", "o"], mtype.name + "$toObject")
1788
+ var gen = util.codegen(["m", "o", "q"], mtype.name + "$toObject")
1777
1789
  ("if(!o)")
1778
1790
  ("o={}")
1791
+ ("if(q===undefined)q=0")
1792
+ ("if(q>util.recursionLimit)")
1793
+ ("throw Error(\"max depth exceeded\")")
1779
1794
  ("var d={}");
1780
1795
 
1781
1796
  var repeatedFields = [],
@@ -2024,8 +2039,8 @@ var Enum = require(17),
2024
2039
  */
2025
2040
  function genTypePartial(gen, field, fieldIndex, ref) {
2026
2041
  return field.delimited
2027
- ? gen("types[%i].encode(%s,w.uint32(%i)).uint32(%i)", fieldIndex, ref, (field.id << 3 | 3) >>> 0, (field.id << 3 | 4) >>> 0)
2028
- : gen("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()", fieldIndex, ref, (field.id << 3 | 2) >>> 0);
2042
+ ? gen("types[%i].encode(%s,w.uint32(%i),q+1).uint32(%i)", fieldIndex, ref, (field.id << 3 | 3) >>> 0, (field.id << 3 | 4) >>> 0)
2043
+ : gen("types[%i].encode(%s,w.uint32(%i).fork(),q+1).ldelim()", fieldIndex, ref, (field.id << 3 | 2) >>> 0);
2029
2044
  }
2030
2045
 
2031
2046
  /**
@@ -2035,9 +2050,12 @@ function genTypePartial(gen, field, fieldIndex, ref) {
2035
2050
  */
2036
2051
  function encoder(mtype) {
2037
2052
  /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */
2038
- var gen = util.codegen(["m", "w"], mtype.name + "$encode")
2053
+ var gen = util.codegen(["m", "w", "q"], mtype.name + "$encode")
2039
2054
  ("if(!w)")
2040
- ("w=Writer.create()");
2055
+ ("w=Writer.create()")
2056
+ ("if(q===undefined)q=0")
2057
+ ("if(q>util.recursionLimit)")
2058
+ ("throw Error(\"max depth exceeded\")");
2041
2059
 
2042
2060
  var i, ref;
2043
2061
 
@@ -2058,7 +2076,7 @@ function encoder(mtype) {
2058
2076
  ("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){", ref)
2059
2077
  ("w.uint32(%i).fork().uint32(%i).%s(ks[i])", (field.id << 3 | 2) >>> 0, 8 | types.mapKey[field.keyType], field.keyType);
2060
2078
  if (wireType === undefined) gen
2061
- ("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()", index, ref); // can't be groups
2079
+ ("types[%i].encode(%s[ks[i]],w.uint32(18).fork(),q+1).ldelim().ldelim()", index, ref); // can't be groups
2062
2080
  else gen
2063
2081
  (".uint32(%i).%s(%s[ks[i]]).ldelim()", 16 | wireType, type, ref);
2064
2082
  gen
@@ -2196,8 +2214,8 @@ Enum.prototype._resolveFeatures = function _resolveFeatures(edition) {
2196
2214
  ReflectionObject.prototype._resolveFeatures.call(this, edition);
2197
2215
 
2198
2216
  Object.keys(this.values).forEach(key => {
2199
- var parentFeaturesCopy = Object.assign({}, this._features);
2200
- this._valuesFeatures[key] = Object.assign(parentFeaturesCopy, this.valuesOptions && this.valuesOptions[key] && this.valuesOptions[key].features);
2217
+ var parentFeaturesCopy = util.merge({}, this._features);
2218
+ this._valuesFeatures[key] = util.merge(parentFeaturesCopy, this.valuesOptions && this.valuesOptions[key] && this.valuesOptions[key].features || {});
2201
2219
  });
2202
2220
 
2203
2221
  return this;
@@ -2666,7 +2684,7 @@ Field.prototype.resolve = function resolve() {
2666
2684
 
2667
2685
  // convert to internal data type if necesssary
2668
2686
  if (this.long) {
2669
- this.typeDefault = util.Long.fromNumber(this.typeDefault, this.type.charAt(0) === "u");
2687
+ this.typeDefault = util.Long.fromNumber(this.typeDefault, this.type === "uint64" || this.type === "fixed64");
2670
2688
 
2671
2689
  /* istanbul ignore else */
2672
2690
  if (Object.freeze)
@@ -3723,6 +3741,8 @@ Namespace.prototype.define = function define(path, json) {
3723
3741
  throw TypeError("illegal path");
3724
3742
  if (path && path.length && path[0] === "")
3725
3743
  throw Error("path must be relative");
3744
+ if (path.length > util.recursionLimit)
3745
+ throw Error("max depth exceeded");
3726
3746
 
3727
3747
  var ptr = this;
3728
3748
  while (path.length > 0) {
@@ -4157,7 +4177,7 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
4157
4177
  throw new Error("Unknown edition for " + this.fullName);
4158
4178
  }
4159
4179
 
4160
- var protoFeatures = Object.assign(this.options ? Object.assign({}, this.options.features) : {},
4180
+ var protoFeatures = util.merge({}, this.options && this.options.features,
4161
4181
  this._inferLegacyProtoFeatures(edition));
4162
4182
 
4163
4183
  if (this._edition) {
@@ -4172,7 +4192,7 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
4172
4192
  } else {
4173
4193
  throw new Error("Unknown edition: " + edition);
4174
4194
  }
4175
- this._features = Object.assign(defaults, protoFeatures || {});
4195
+ this._features = util.merge(defaults, protoFeatures);
4176
4196
  this._featuresResolved = true;
4177
4197
  return;
4178
4198
  }
@@ -4181,13 +4201,13 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
4181
4201
  // special-case it
4182
4202
  /* istanbul ignore else */
4183
4203
  if (this.partOf instanceof OneOf) {
4184
- var lexicalParentFeaturesCopy = Object.assign({}, this.partOf._features);
4185
- this._features = Object.assign(lexicalParentFeaturesCopy, protoFeatures || {});
4204
+ var lexicalParentFeaturesCopy = util.merge({}, this.partOf._features);
4205
+ this._features = util.merge(lexicalParentFeaturesCopy, protoFeatures);
4186
4206
  } else if (this.declaringField) {
4187
4207
  // Skip feature resolution of sister fields.
4188
4208
  } else if (this.parent) {
4189
- var parentFeaturesCopy = Object.assign({}, this.parent._features);
4190
- this._features = Object.assign(parentFeaturesCopy, protoFeatures || {});
4209
+ var parentFeaturesCopy = util.merge({}, this.parent._features);
4210
+ this._features = util.merge(parentFeaturesCopy, protoFeatures);
4191
4211
  } else {
4192
4212
  throw new Error("Unable to find a parent for " + this.fullName);
4193
4213
  }
@@ -4854,7 +4874,9 @@ function parse(source, root, options) {
4854
4874
 
4855
4875
 
4856
4876
  function parseCommon(parent, token, depth) {
4857
- depth = util.checkDepth(depth);
4877
+ if (depth === undefined)
4878
+ depth = 0;
4879
+ // depth is checked by dispatched functions
4858
4880
  switch (token) {
4859
4881
 
4860
4882
  case "option":
@@ -4904,7 +4926,10 @@ function parse(source, root, options) {
4904
4926
  }
4905
4927
 
4906
4928
  function parseType(parent, token, depth) {
4907
- depth = util.checkDepth(depth);
4929
+ if (depth === undefined)
4930
+ depth = 0;
4931
+ if (depth > util.nestingLimit)
4932
+ throw Error("max depth exceeded");
4908
4933
 
4909
4934
  /* istanbul ignore if */
4910
4935
  if (!nameRe.test(token = next()))
@@ -5030,7 +5055,10 @@ function parse(source, root, options) {
5030
5055
  }
5031
5056
 
5032
5057
  function parseGroup(parent, rule, depth) {
5033
- depth = util.checkDepth(depth);
5058
+ if (depth === undefined)
5059
+ depth = 0;
5060
+ if (depth > util.nestingLimit)
5061
+ throw Error("max depth exceeded");
5034
5062
  if (edition >= 2023) {
5035
5063
  throw illegal("group");
5036
5064
  }
@@ -5249,7 +5277,10 @@ function parse(source, root, options) {
5249
5277
  }
5250
5278
 
5251
5279
  function parseOptionValue(parent, name, depth) {
5252
- depth = util.checkDepth(depth);
5280
+ if (depth === undefined)
5281
+ depth = 0;
5282
+ if (depth > util.recursionLimit)
5283
+ throw Error("max depth exceeded");
5253
5284
  // { a: "foo" b { c: "bar" } }
5254
5285
  if (skip("{", true)) {
5255
5286
  var objectResult = {};
@@ -5338,7 +5369,10 @@ function parse(source, root, options) {
5338
5369
  }
5339
5370
 
5340
5371
  function parseService(parent, token, depth) {
5341
- depth = util.checkDepth(depth);
5372
+ if (depth === undefined)
5373
+ depth = 0;
5374
+ if (depth > util.recursionLimit)
5375
+ throw Error("max depth exceeded");
5342
5376
 
5343
5377
  /* istanbul ignore if */
5344
5378
  if (!nameRe.test(token = next()))
@@ -6148,8 +6182,12 @@ Root.prototype.load = function load(filename, options, callback) {
6148
6182
  }
6149
6183
 
6150
6184
  // Processes a single file
6151
- function process(filename, source) {
6185
+ function process(filename, source, depth) {
6186
+ if (depth === undefined)
6187
+ depth = 0;
6152
6188
  try {
6189
+ if (depth > util.recursionLimit)
6190
+ throw Error("max depth exceeded");
6153
6191
  if (util.isString(source) && source.charAt(0) === "{")
6154
6192
  source = JSON.parse(source);
6155
6193
  if (!util.isString(source))
@@ -6162,11 +6200,11 @@ Root.prototype.load = function load(filename, options, callback) {
6162
6200
  if (parsed.imports)
6163
6201
  for (; i < parsed.imports.length; ++i)
6164
6202
  if (resolved = getBundledFileName(parsed.imports[i]) || self.resolvePath(filename, parsed.imports[i]))
6165
- fetch(resolved);
6203
+ fetch(resolved, false, depth + 1);
6166
6204
  if (parsed.weakImports)
6167
6205
  for (i = 0; i < parsed.weakImports.length; ++i)
6168
6206
  if (resolved = getBundledFileName(parsed.weakImports[i]) || self.resolvePath(filename, parsed.weakImports[i]))
6169
- fetch(resolved, true);
6207
+ fetch(resolved, true, depth + 1);
6170
6208
  }
6171
6209
  } catch (err) {
6172
6210
  finish(err);
@@ -6177,7 +6215,9 @@ Root.prototype.load = function load(filename, options, callback) {
6177
6215
  }
6178
6216
 
6179
6217
  // Fetches a single file
6180
- function fetch(filename, weak) {
6218
+ function fetch(filename, weak, depth) {
6219
+ if (depth === undefined)
6220
+ depth = 0;
6181
6221
  filename = getBundledFileName(filename) || filename;
6182
6222
 
6183
6223
  // Skip if already loaded / attempted
@@ -6189,12 +6229,12 @@ Root.prototype.load = function load(filename, options, callback) {
6189
6229
  // Shortcut bundled definitions
6190
6230
  if (filename in common) {
6191
6231
  if (sync) {
6192
- process(filename, common[filename]);
6232
+ process(filename, common[filename], depth);
6193
6233
  } else {
6194
6234
  ++queued;
6195
6235
  setTimeout(function() {
6196
6236
  --queued;
6197
- process(filename, common[filename]);
6237
+ process(filename, common[filename], depth);
6198
6238
  });
6199
6239
  }
6200
6240
  return;
@@ -6210,7 +6250,7 @@ Root.prototype.load = function load(filename, options, callback) {
6210
6250
  finish(err);
6211
6251
  return;
6212
6252
  }
6213
- process(filename, source);
6253
+ process(filename, source, depth);
6214
6254
  } else {
6215
6255
  ++queued;
6216
6256
  self.fetch(filename, function(err, source) {
@@ -6227,7 +6267,7 @@ Root.prototype.load = function load(filename, options, callback) {
6227
6267
  finish(null, self);
6228
6268
  return;
6229
6269
  }
6230
- process(filename, source);
6270
+ process(filename, source, depth);
6231
6271
  });
6232
6272
  }
6233
6273
  }
@@ -6417,7 +6457,7 @@ Root._configure = function(Type_, parse_, common_) {
6417
6457
 
6418
6458
  },{"17":17,"18":18,"25":25,"27":27,"39":39}],32:[function(require,module,exports){
6419
6459
  "use strict";
6420
- module.exports = {};
6460
+ module.exports = Object.create(null);
6421
6461
 
6422
6462
  /**
6423
6463
  * Named roots.
@@ -7472,7 +7512,10 @@ function clearCache(type) {
7472
7512
  * @returns {Type} Created message type
7473
7513
  */
7474
7514
  Type.fromJSON = function fromJSON(name, json, depth) {
7475
- depth = util.checkDepth(depth);
7515
+ if (depth === undefined)
7516
+ depth = 0;
7517
+ if (depth > util.nestingLimit)
7518
+ throw Error("max depth exceeded");
7476
7519
  var type = new Type(name, json.options);
7477
7520
  type.extensions = json.extensions;
7478
7521
  type.reserved = json.reserved;
@@ -7750,8 +7793,8 @@ Type.prototype.setup = function setup() {
7750
7793
  * @param {Writer} [writer] Writer to encode to
7751
7794
  * @returns {Writer} writer
7752
7795
  */
7753
- Type.prototype.encode = function encode_setup(message, writer) {
7754
- return this.setup().encode(message, writer); // overrides this method
7796
+ Type.prototype.encode = function encode_setup(message, writer) { // eslint-disable-line no-unused-vars
7797
+ return this.setup().encode.apply(this, arguments); // overrides this method
7755
7798
  };
7756
7799
 
7757
7800
  /**
@@ -7836,8 +7879,8 @@ Type.prototype.fromObject = function fromObject(object, depth) {
7836
7879
  * @param {IConversionOptions} [options] Conversion options
7837
7880
  * @returns {Object.<string,*>} Plain object
7838
7881
  */
7839
- Type.prototype.toObject = function toObject(message, options) {
7840
- return this.setup().toObject(message, options);
7882
+ Type.prototype.toObject = function toObject(message, options) { // eslint-disable-line no-unused-vars
7883
+ return this.setup().toObject.apply(this, arguments);
7841
7884
  };
7842
7885
 
7843
7886
  /**
@@ -8078,8 +8121,7 @@ util.fetch = require(5);
8078
8121
  util.path = require(9);
8079
8122
  util.patterns = require(43);
8080
8123
 
8081
- var reservedRe = util.patterns.reservedRe,
8082
- unsafePropertyRe = util.patterns.unsafePropertyRe;
8124
+ var reservedRe = util.patterns.reservedRe;
8083
8125
 
8084
8126
  /**
8085
8127
  * Node's fs module if available.
@@ -8254,7 +8296,7 @@ util.decorateEnum = function decorateEnum(object) {
8254
8296
  util.setProperty = function setProperty(dst, path, value, ifNotSet) {
8255
8297
  function setProp(dst, path, value) {
8256
8298
  var part = path.shift();
8257
- if (unsafePropertyRe.test(part))
8299
+ if (util.isUnsafeProperty(part))
8258
8300
  return dst;
8259
8301
  if (path.length > 0) {
8260
8302
  dst[part] = setProp(dst[part] || {}, path, value);
@@ -8275,6 +8317,8 @@ util.setProperty = function setProperty(dst, path, value, ifNotSet) {
8275
8317
  throw TypeError("path must be specified");
8276
8318
 
8277
8319
  path = path.split(".");
8320
+ if (path.length > util.recursionLimit)
8321
+ throw Error("max depth exceeded");
8278
8322
  return setProp(dst, path, value);
8279
8323
  };
8280
8324
 
@@ -8533,6 +8577,18 @@ util.pool = require(10);
8533
8577
  // utility to work with the low and high bits of a 64 bit value
8534
8578
  util.LongBits = require(41);
8535
8579
 
8580
+ /**
8581
+ * Tests if the specified key can affect object prototypes.
8582
+ * @memberof util
8583
+ * @param {string} key Key to test
8584
+ * @returns {boolean} `true` if the key is unsafe
8585
+ */
8586
+ function isUnsafeProperty(key) {
8587
+ return key === "__proto__" || key === "prototype" || key === "constructor";
8588
+ }
8589
+
8590
+ util.isUnsafeProperty = isUnsafeProperty;
8591
+
8536
8592
  /**
8537
8593
  * Whether running within node or not.
8538
8594
  * @memberof util
@@ -8746,26 +8802,39 @@ util.longFromHash = function longFromHash(hash, unsigned) {
8746
8802
  * Merges the properties of the source object into the destination object.
8747
8803
  * @memberof util
8748
8804
  * @param {Object.<string,*>} dst Destination object
8749
- * @param {Object.<string,*>} src Source object
8750
- * @param {boolean} [ifNotSet=false] Merges only if the key is not already set
8805
+ * @param {...(Object.<string,*>|boolean)} src Source objects, optionally followed by an `ifNotSet` flag
8751
8806
  * @returns {Object.<string,*>} Destination object
8752
8807
  */
8753
- function merge(dst, src, ifNotSet) { // used by converters
8754
- for (var keys = Object.keys(src), i = 0; i < keys.length; ++i)
8755
- if (dst[keys[i]] === undefined || !ifNotSet)
8756
- if (keys[i] !== "__proto__")
8808
+ function merge(dst) { // used by converters
8809
+ var ifNotSet = typeof arguments[arguments.length - 1] === "boolean",
8810
+ limit = ifNotSet ? arguments.length - 1 : arguments.length;
8811
+ ifNotSet = ifNotSet && arguments[arguments.length - 1];
8812
+ for (var a = 1; a < limit; ++a) {
8813
+ var src = arguments[a];
8814
+ if (!src)
8815
+ continue;
8816
+ for (var keys = Object.keys(src), i = 0; i < keys.length; ++i)
8817
+ if (!isUnsafeProperty(keys[i]) && (dst[keys[i]] === undefined || !ifNotSet))
8757
8818
  dst[keys[i]] = src[keys[i]];
8819
+ }
8758
8820
  return dst;
8759
8821
  }
8760
8822
 
8761
8823
  util.merge = merge;
8762
8824
 
8825
+ /**
8826
+ * Schema declaration nesting limit.
8827
+ * @memberof util
8828
+ * @type {number}
8829
+ */
8830
+ util.nestingLimit = 32; // protoc: MaxMessageDeclarationNestingDepth
8831
+
8763
8832
  /**
8764
8833
  * Recursion limit.
8765
8834
  * @memberof util
8766
8835
  * @type {number}
8767
8836
  */
8768
- util.recursionLimit = 100;
8837
+ util.recursionLimit = 100; // protoc: CodedInputStream::default_recursion_limit_
8769
8838
 
8770
8839
  /**
8771
8840
  * Makes a property safe for assignment as an own property.
@@ -8984,7 +9053,6 @@ var patterns = exports;
8984
9053
  patterns.numberRe = /^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/;
8985
9054
  patterns.typeRefRe = /^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/;
8986
9055
  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)$/;
8987
- patterns.unsafePropertyRe = /^(?:__proto__|prototype|constructor)$/;
8988
9056
 
8989
9057
  },{}],44:[function(require,module,exports){
8990
9058
  "use strict";
@@ -9178,7 +9246,8 @@ function verifier(mtype) {
9178
9246
  */
9179
9247
  var wrappers = exports;
9180
9248
 
9181
- var Message = require(23);
9249
+ var Message = require(23),
9250
+ util = require(42);
9182
9251
 
9183
9252
  /**
9184
9253
  * From object converter part of an {@link IWrapper}.
@@ -9225,10 +9294,9 @@ wrappers[".google.protobuf.Any"] = {
9225
9294
  if (type_url.indexOf("/") === -1) {
9226
9295
  type_url = "/" + type_url;
9227
9296
  }
9228
- var nextDepth = depth === undefined ? 1 : depth + 1;
9229
9297
  return this.create({
9230
9298
  type_url: type_url,
9231
- value: type.encode(type.fromObject(object, nextDepth)).finish()
9299
+ value: type.encode(type.fromObject(object, depth === undefined ? 1 : depth + 1)).finish()
9232
9300
  });
9233
9301
  }
9234
9302
  }
@@ -9236,7 +9304,11 @@ wrappers[".google.protobuf.Any"] = {
9236
9304
  return this.fromObject(object, depth);
9237
9305
  },
9238
9306
 
9239
- toObject: function(message, options) {
9307
+ toObject: function(message, options, depth) {
9308
+ if (depth === undefined)
9309
+ depth = 0;
9310
+ if (depth > util.recursionLimit)
9311
+ throw Error("max depth exceeded");
9240
9312
 
9241
9313
  // Default prefix
9242
9314
  var googleApi = "type.googleapis.com/";
@@ -9252,12 +9324,12 @@ wrappers[".google.protobuf.Any"] = {
9252
9324
  var type = this.lookup(name);
9253
9325
  /* istanbul ignore else */
9254
9326
  if (type)
9255
- message = type.decode(message.value);
9327
+ message = type.decode(message.value, undefined, undefined, depth + 1);
9256
9328
  }
9257
9329
 
9258
9330
  // wrap value if unmapped
9259
9331
  if (!(message instanceof this.ctor) && message instanceof Message) {
9260
- var object = message.$type.toObject(message, options);
9332
+ var object = message.$type.toObject(message, options, depth + 1);
9261
9333
  var messageName = message.$type.fullName[0] === "." ?
9262
9334
  message.$type.fullName.slice(1) : message.$type.fullName;
9263
9335
  // Default to type.googleapis.com prefix if no prefix is used
@@ -9269,11 +9341,11 @@ wrappers[".google.protobuf.Any"] = {
9269
9341
  return object;
9270
9342
  }
9271
9343
 
9272
- return this.toObject(message, options);
9344
+ return this.toObject(message, options, depth);
9273
9345
  }
9274
9346
  };
9275
9347
 
9276
- },{"23":23}],46:[function(require,module,exports){
9348
+ },{"23":23,"42":42}],46:[function(require,module,exports){
9277
9349
  "use strict";
9278
9350
  module.exports = Writer;
9279
9351
 
@@ -9501,7 +9573,7 @@ Writer.prototype.uint32 = function write_uint32(value) {
9501
9573
  * @returns {Writer} `this`
9502
9574
  */
9503
9575
  Writer.prototype.int32 = function write_int32(value) {
9504
- return value < 0
9576
+ return (value |= 0) < 0
9505
9577
  ? this._push(writeVarint64, 10, LongBits.fromNumber(value)) // 10 bytes per spec
9506
9578
  : this.uint32(value);
9507
9579
  };
@@ -9516,16 +9588,18 @@ Writer.prototype.sint32 = function write_sint32(value) {
9516
9588
  };
9517
9589
 
9518
9590
  function writeVarint64(val, buf, pos) {
9519
- while (val.hi) {
9520
- buf[pos++] = val.lo & 127 | 128;
9521
- val.lo = (val.lo >>> 7 | val.hi << 25) >>> 0;
9522
- val.hi >>>= 7;
9523
- }
9524
- while (val.lo > 127) {
9525
- buf[pos++] = val.lo & 127 | 128;
9526
- val.lo = val.lo >>> 7;
9527
- }
9528
- buf[pos++] = val.lo;
9591
+ var lo = val.lo,
9592
+ hi = val.hi;
9593
+ while (hi) {
9594
+ buf[pos++] = lo & 127 | 128;
9595
+ lo = (lo >>> 7 | hi << 25) >>> 0;
9596
+ hi >>>= 7;
9597
+ }
9598
+ while (lo > 127) {
9599
+ buf[pos++] = lo & 127 | 128;
9600
+ lo = lo >>> 7;
9601
+ }
9602
+ buf[pos++] = lo;
9529
9603
  }
9530
9604
 
9531
9605
  /**