protobufjs 7.5.5 → 7.5.7

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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * protobuf.js v7.5.5 (c) 2016, daniel wirtz
3
- * compiled wed, 15 apr 2026 04:40:15 utc
2
+ * protobuf.js v7.5.7 (c) 2016, daniel wirtz
3
+ * compiled sat, 09 may 2026 05:45:39 utc
4
4
  * licensed under the bsd-3-clause license
5
5
  * see: https://github.com/dcodeio/protobuf.js for details
6
6
  */
@@ -236,6 +236,8 @@ base64.test = function test(string) {
236
236
  "use strict";
237
237
  module.exports = codegen;
238
238
 
239
+ var 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)$/;
240
+
239
241
  /**
240
242
  * Begins generating a function.
241
243
  * @memberof util
@@ -310,7 +312,7 @@ function codegen(functionParams, functionName) {
310
312
  }
311
313
 
312
314
  function toString(functionNameOverride) {
313
- return "function " + (functionNameOverride || functionName || "") + "(" + (functionParams && functionParams.join(",") || "") + "){\n " + body.join("\n ") + "\n}";
315
+ return "function " + safeFunctionName(functionNameOverride || functionName) + "(" + (functionParams && functionParams.join(",") || "") + "){\n " + body.join("\n ") + "\n}";
314
316
  }
315
317
 
316
318
  Codegen.toString = toString;
@@ -332,6 +334,17 @@ function codegen(functionParams, functionName) {
332
334
  * @type {boolean}
333
335
  */
334
336
  codegen.verbose = false;
337
+
338
+ function safeFunctionName(name) {
339
+ if (!name)
340
+ return "";
341
+ name = String(name).replace(/[^\w$]/g, "");
342
+ if (!name)
343
+ return "";
344
+ if (/^\d/.test(name))
345
+ name = "_" + name;
346
+ return reservedRe.test(name) ? name + "_" : name;
347
+ }
335
348
 
336
349
  },{}],4:[function(require,module,exports){
337
350
  "use strict";
@@ -876,13 +889,33 @@ module.exports = inquire;
876
889
  * @returns {?Object} Required module if available and not empty, otherwise `null`
877
890
  */
878
891
  function inquire(moduleName) {
879
- try {
880
- var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval
881
- if (mod && (mod.length || Object.keys(mod).length))
882
- return mod;
883
- } catch (e) {} // eslint-disable-line no-empty
892
+ try {
893
+ if (typeof require !== "function") {
894
+ return null;
895
+ }
896
+ var mod = require(moduleName);
897
+ if (mod && (mod.length || Object.keys(mod).length)) return mod;
898
+ return null;
899
+ } catch (err) {
900
+ // ignore
884
901
  return null;
902
+ }
885
903
  }
904
+
905
+ /*
906
+ // maybe worth a shot to prevent renaming issues:
907
+ // see: https://github.com/webpack/webpack/blob/master/lib/dependencies/CommonJsRequireDependencyParserPlugin.js
908
+ // triggers on:
909
+ // - expression require.cache
910
+ // - expression require (???)
911
+ // - call require
912
+ // - call require:commonjs:item
913
+ // - call require:commonjs:context
914
+
915
+ Object.defineProperty(Function.prototype, "__self", { get: function() { return this; } });
916
+ var r = require.__self;
917
+ delete Function.prototype.__self;
918
+ */
886
919
 
887
920
  },{}],8:[function(require,module,exports){
888
921
  "use strict";
@@ -1009,7 +1042,8 @@ function pool(alloc, slice, size) {
1009
1042
  * @memberof util
1010
1043
  * @namespace
1011
1044
  */
1012
- var utf8 = exports;
1045
+ var utf8 = exports,
1046
+ replacementChar = "\ufffd";
1013
1047
 
1014
1048
  /**
1015
1049
  * Calculates the UTF8 byte length of a string.
@@ -1042,36 +1076,34 @@ utf8.length = function utf8_length(string) {
1042
1076
  * @returns {string} String read
1043
1077
  */
1044
1078
  utf8.read = function utf8_read(buffer, start, end) {
1045
- var len = end - start;
1046
- if (len < 1)
1079
+ if (end - start < 1) {
1047
1080
  return "";
1048
- var parts = null,
1049
- chunk = [],
1050
- i = 0, // char offset
1051
- t; // temporary
1052
- while (start < end) {
1053
- t = buffer[start++];
1054
- if (t < 128)
1055
- chunk[i++] = t;
1056
- else if (t > 191 && t < 224)
1057
- chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
1058
- else if (t > 239 && t < 365) {
1059
- t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
1060
- chunk[i++] = 0xD800 + (t >> 10);
1061
- chunk[i++] = 0xDC00 + (t & 1023);
1062
- } else
1063
- chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
1064
- if (i > 8191) {
1065
- (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
1066
- i = 0;
1067
- }
1068
1081
  }
1069
- if (parts) {
1070
- if (i)
1071
- parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
1072
- return parts.join("");
1082
+
1083
+ var str = "";
1084
+ for (var i = start; i < end;) {
1085
+ var t = buffer[i++];
1086
+ if (t <= 0x7F) {
1087
+ str += String.fromCharCode(t);
1088
+ } else if (t >= 0xC0 && t < 0xE0) {
1089
+ var c2 = (t & 0x1F) << 6 | buffer[i++] & 0x3F;
1090
+ str += c2 >= 0x80 ? String.fromCharCode(c2) : replacementChar;
1091
+ } else if (t >= 0xE0 && t < 0xF0) {
1092
+ var c3 = (t & 0xF) << 12 | (buffer[i++] & 0x3F) << 6 | buffer[i++] & 0x3F;
1093
+ str += c3 >= 0x800 ? String.fromCharCode(c3) : replacementChar;
1094
+ } else if (t >= 0xF0) {
1095
+ var t2 = (t & 7) << 18 | (buffer[i++] & 0x3F) << 12 | (buffer[i++] & 0x3F) << 6 | buffer[i++] & 0x3F;
1096
+ if (t2 < 0x10000 || t2 > 0x10FFFF)
1097
+ str += replacementChar;
1098
+ else {
1099
+ t2 -= 0x10000;
1100
+ str += String.fromCharCode(0xD800 + (t2 >> 10));
1101
+ str += String.fromCharCode(0xDC00 + (t2 & 0x3FF));
1102
+ }
1103
+ }
1073
1104
  }
1074
- return String.fromCharCode.apply(String, chunk.slice(0, i));
1105
+
1106
+ return str;
1075
1107
  };
1076
1108
 
1077
1109
  /**
@@ -1154,7 +1186,7 @@ function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
1154
1186
  } else gen
1155
1187
  ("if(typeof d%s!==\"object\")", prop)
1156
1188
  ("throw TypeError(%j)", field.fullName + ": object expected")
1157
- ("m%s=types[%i].fromObject(d%s)", prop, fieldIndex, prop);
1189
+ ("m%s=types[%i].fromObject(d%s,n+1)", prop, fieldIndex, prop);
1158
1190
  } else {
1159
1191
  var isUnsigned = false;
1160
1192
  switch (field.type) {
@@ -1216,9 +1248,12 @@ function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
1216
1248
  converter.fromObject = function fromObject(mtype) {
1217
1249
  /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */
1218
1250
  var fields = mtype.fieldsArray;
1219
- var gen = util.codegen(["d"], mtype.name + "$fromObject")
1251
+ var gen = util.codegen(["d", "n"], mtype.name + "$fromObject")
1220
1252
  ("if(d instanceof this.ctor)")
1221
- ("return d");
1253
+ ("return d")
1254
+ ("if(n===undefined)n=0")
1255
+ ("if(n>util.recursionLimit)")
1256
+ ("throw Error(\"maximum nesting depth exceeded\")");
1222
1257
  if (!fields.length) return gen
1223
1258
  ("return new this.ctor");
1224
1259
  gen
@@ -1234,6 +1269,9 @@ converter.fromObject = function fromObject(mtype) {
1234
1269
  ("throw TypeError(%j)", field.fullName + ": object expected")
1235
1270
  ("m%s={}", prop)
1236
1271
  ("for(var ks=Object.keys(d%s),i=0;i<ks.length;++i){", prop);
1272
+ gen
1273
+ ("if(ks[i]===\"__proto__\")")
1274
+ ("util.makeProp(m%s,ks[i])", prop);
1237
1275
  genValuePartial_fromObject(gen, field, /* not sorted */ i, prop + "[ks[i]]")
1238
1276
  ("}")
1239
1277
  ("}");
@@ -1364,11 +1402,11 @@ converter.toObject = function toObject(mtype) {
1364
1402
  ("}else")
1365
1403
  ("d%s=o.longs===String?%j:%i", prop, field.typeDefault.toString(), field.typeDefault.toNumber());
1366
1404
  else if (field.bytes) {
1367
- var arrayDefault = "[" + Array.prototype.slice.call(field.typeDefault).join(",") + "]";
1405
+ var arrayDefault = Array.prototype.slice.call(field.typeDefault);
1368
1406
  gen
1369
1407
  ("if(o.bytes===String)d%s=%j", prop, String.fromCharCode.apply(String, field.typeDefault))
1370
1408
  ("else{")
1371
- ("d%s=%s", prop, arrayDefault)
1409
+ ("d%s=%j", prop, arrayDefault)
1372
1410
  ("if(o.bytes!==Array)d%s=util.newBuffer(d%s)", prop, prop)
1373
1411
  ("}");
1374
1412
  } else gen
@@ -1388,6 +1426,9 @@ converter.toObject = function toObject(mtype) {
1388
1426
  ("if(m%s&&(ks2=Object.keys(m%s)).length){", prop, prop)
1389
1427
  ("d%s={}", prop)
1390
1428
  ("for(var j=0;j<ks2.length;++j){");
1429
+ gen
1430
+ ("if(ks2[j]===\"__proto__\")")
1431
+ ("util.makeProp(d%s,ks2[j])", prop);
1391
1432
  genValuePartial_toObject(gen, field, /* sorted */ index, prop + "[ks2[j]]")
1392
1433
  ("}");
1393
1434
  } else if (field.repeated) { gen
@@ -1430,9 +1471,12 @@ function missing(field) {
1430
1471
  */
1431
1472
  function decoder(mtype) {
1432
1473
  /* eslint-disable no-unexpected-multiline */
1433
- var gen = util.codegen(["r", "l", "e"], mtype.name + "$decode")
1474
+ var gen = util.codegen(["r", "l", "e", "n"], mtype.name + "$decode")
1434
1475
  ("if(!(r instanceof Reader))")
1435
1476
  ("r=Reader.create(r)")
1477
+ ("if(n===undefined)n=0")
1478
+ ("if(n>Reader.recursionLimit)")
1479
+ ("throw Error(\"maximum nesting depth exceeded\")")
1436
1480
  ("var c=l===undefined?r.len:r.pos+l,m=new this.ctor" + (mtype.fieldsArray.filter(function(field) { return field.map; }).length ? ",k,value" : ""))
1437
1481
  ("while(r.pos<c){")
1438
1482
  ("var t=r.uint32()")
@@ -1471,22 +1515,27 @@ function decoder(mtype) {
1471
1515
  ("case 2:");
1472
1516
 
1473
1517
  if (types.basic[type] === undefined) gen
1474
- ("value=types[%i].decode(r,r.uint32())", i); // can't be groups
1518
+ ("value=types[%i].decode(r,r.uint32(),undefined,n+1)", i); // can't be groups
1475
1519
  else gen
1476
1520
  ("value=r.%s()", type);
1477
1521
 
1478
1522
  gen
1479
1523
  ("break")
1480
1524
  ("default:")
1481
- ("r.skipType(tag2&7)")
1525
+ ("r.skipType(tag2&7,n)")
1482
1526
  ("break")
1483
1527
  ("}")
1484
1528
  ("}");
1485
1529
 
1486
1530
  if (types.long[field.keyType] !== undefined) gen
1487
1531
  ("%s[typeof k===\"object\"?util.longToHash(k):k]=value", ref);
1488
- else gen
1532
+ else {
1533
+ if (field.keyType === "string") gen
1534
+ ("if(k===\"__proto__\")")
1535
+ ("util.makeProp(%s,k)", ref);
1536
+ gen
1489
1537
  ("%s[k]=value", ref);
1538
+ }
1490
1539
 
1491
1540
  // Repeated fields
1492
1541
  } else if (field.repeated) { gen
@@ -1504,15 +1553,15 @@ function decoder(mtype) {
1504
1553
 
1505
1554
  // Non-packed
1506
1555
  if (types.basic[type] === undefined) gen(field.delimited
1507
- ? "%s.push(types[%i].decode(r,undefined,((t&~7)|4)))"
1508
- : "%s.push(types[%i].decode(r,r.uint32()))", ref, i);
1556
+ ? "%s.push(types[%i].decode(r,undefined,((t&~7)|4),n+1))"
1557
+ : "%s.push(types[%i].decode(r,r.uint32(),undefined,n+1))", ref, i);
1509
1558
  else gen
1510
1559
  ("%s.push(r.%s())", ref, type);
1511
1560
 
1512
1561
  // Non-repeated
1513
1562
  } else if (types.basic[type] === undefined) gen(field.delimited
1514
- ? "%s=types[%i].decode(r,undefined,((t&~7)|4))"
1515
- : "%s=types[%i].decode(r,r.uint32())", ref, i);
1563
+ ? "%s=types[%i].decode(r,undefined,((t&~7)|4),n+1)"
1564
+ : "%s=types[%i].decode(r,r.uint32(),undefined,n+1)", ref, i);
1516
1565
  else gen
1517
1566
  ("%s=r.%s()", ref, type);
1518
1567
  gen
@@ -1521,7 +1570,7 @@ function decoder(mtype) {
1521
1570
  // Unknown fields
1522
1571
  } gen
1523
1572
  ("default:")
1524
- ("r.skipType(t&7)")
1573
+ ("r.skipType(t&7,n)")
1525
1574
  ("break")
1526
1575
 
1527
1576
  ("}")
@@ -1719,7 +1768,7 @@ function Enum(name, values, options, comment, comments, valuesOptions) {
1719
1768
 
1720
1769
  if (values)
1721
1770
  for (var keys = Object.keys(values), i = 0; i < keys.length; ++i)
1722
- if (typeof values[keys[i]] === "number") // use forward entries only
1771
+ if (keys[i] !== "__proto__" && typeof values[keys[i]] === "number") // use forward entries only
1723
1772
  this.valuesById[ this.values[keys[i]] = values[keys[i]] ] = keys[i];
1724
1773
  }
1725
1774
 
@@ -1798,6 +1847,9 @@ Enum.prototype.add = function add(name, id, comment, options) {
1798
1847
  if (!util.isInteger(id))
1799
1848
  throw TypeError("id must be an integer");
1800
1849
 
1850
+ if (name === "__proto__")
1851
+ return this;
1852
+
1801
1853
  if (this.values[name] !== undefined)
1802
1854
  throw Error("duplicate name '" + name + "' in " + this);
1803
1855
 
@@ -2399,7 +2451,7 @@ protobuf.loadSync = loadSync;
2399
2451
  // Serialization
2400
2452
  protobuf.encoder = require(13);
2401
2453
  protobuf.decoder = require(12);
2402
- protobuf.verifier = require(36);
2454
+ protobuf.verifier = require(37);
2403
2455
  protobuf.converter = require(11);
2404
2456
 
2405
2457
  // Reflection
@@ -2416,7 +2468,7 @@ protobuf.Method = require(20);
2416
2468
 
2417
2469
  // Runtime
2418
2470
  protobuf.Message = require(19);
2419
- protobuf.wrappers = require(37);
2471
+ protobuf.wrappers = require(38);
2420
2472
 
2421
2473
  // Utility
2422
2474
  protobuf.types = require(32);
@@ -2428,7 +2480,7 @@ protobuf.Namespace._configure(protobuf.Type, protobuf.Service, protobuf.Enum);
2428
2480
  protobuf.Root._configure(protobuf.Type);
2429
2481
  protobuf.Field._configure(protobuf.Type);
2430
2482
 
2431
- },{"11":11,"12":12,"13":13,"14":14,"15":15,"17":17,"18":18,"19":19,"20":20,"21":21,"22":22,"23":23,"26":26,"30":30,"31":31,"32":32,"33":33,"36":36,"37":37}],17:[function(require,module,exports){
2483
+ },{"11":11,"12":12,"13":13,"14":14,"15":15,"17":17,"18":18,"19":19,"20":20,"21":21,"22":22,"23":23,"26":26,"30":30,"31":31,"32":32,"33":33,"37":37,"38":38}],17:[function(require,module,exports){
2432
2484
  "use strict";
2433
2485
  var protobuf = exports;
2434
2486
 
@@ -2441,8 +2493,8 @@ var protobuf = exports;
2441
2493
  protobuf.build = "minimal";
2442
2494
 
2443
2495
  // Serialization
2444
- protobuf.Writer = require(38);
2445
- protobuf.BufferWriter = require(39);
2496
+ protobuf.Writer = require(39);
2497
+ protobuf.BufferWriter = require(40);
2446
2498
  protobuf.Reader = require(24);
2447
2499
  protobuf.BufferReader = require(25);
2448
2500
 
@@ -2466,7 +2518,7 @@ function configure() {
2466
2518
  // Set up buffer utility according to the environment
2467
2519
  configure();
2468
2520
 
2469
- },{"24":24,"25":25,"27":27,"28":28,"35":35,"38":38,"39":39}],18:[function(require,module,exports){
2521
+ },{"24":24,"25":25,"27":27,"28":28,"35":35,"39":39,"40":40}],18:[function(require,module,exports){
2470
2522
  "use strict";
2471
2523
  module.exports = MapField;
2472
2524
 
@@ -3020,7 +3072,7 @@ function Namespace(name, options) {
3020
3072
  * @type {Object.<string,ReflectionObject|null>}
3021
3073
  * @private
3022
3074
  */
3023
- this._lookupCache = {};
3075
+ this._lookupCache = Object.create(null);
3024
3076
 
3025
3077
  /**
3026
3078
  * Whether or not objects contained in this namespace need feature resolution.
@@ -3039,12 +3091,12 @@ function Namespace(name, options) {
3039
3091
 
3040
3092
  function clearCache(namespace) {
3041
3093
  namespace._nestedArray = null;
3042
- namespace._lookupCache = {};
3094
+ namespace._lookupCache = Object.create(null);
3043
3095
 
3044
3096
  // Also clear parent caches, since they include nested lookups.
3045
3097
  var parent = namespace;
3046
3098
  while(parent = parent.parent) {
3047
- parent._lookupCache = {};
3099
+ parent._lookupCache = Object.create(null);
3048
3100
  }
3049
3101
  return namespace;
3050
3102
  }
@@ -3125,8 +3177,9 @@ Namespace.prototype.addJSON = function addJSON(nestedJson) {
3125
3177
  * @returns {ReflectionObject|null} The reflection object or `null` if it doesn't exist
3126
3178
  */
3127
3179
  Namespace.prototype.get = function get(name) {
3128
- return this.nested && this.nested[name]
3129
- || null;
3180
+ return this.nested && Object.prototype.hasOwnProperty.call(this.nested, name)
3181
+ ? this.nested[name]
3182
+ : null;
3130
3183
  };
3131
3184
 
3132
3185
  /**
@@ -3137,7 +3190,7 @@ Namespace.prototype.get = function get(name) {
3137
3190
  * @throws {Error} If there is no such enum
3138
3191
  */
3139
3192
  Namespace.prototype.getEnum = function getEnum(name) {
3140
- if (this.nested && this.nested[name] instanceof Enum)
3193
+ if (this.nested && Object.prototype.hasOwnProperty.call(this.nested, name) && this.nested[name] instanceof Enum)
3141
3194
  return this.nested[name].values;
3142
3195
  throw Error("no such enum: " + name);
3143
3196
  };
@@ -3154,6 +3207,9 @@ Namespace.prototype.add = function add(object) {
3154
3207
  if (!(object instanceof Field && object.extend !== undefined || object instanceof Type || object instanceof OneOf || object instanceof Enum || object instanceof Service || object instanceof Namespace))
3155
3208
  throw TypeError("object must be a valid nested object");
3156
3209
 
3210
+ if (object.name === "__proto__")
3211
+ return this;
3212
+
3157
3213
  if (!this.nested)
3158
3214
  this.nested = {};
3159
3215
  else {
@@ -3366,8 +3422,10 @@ Namespace.prototype._lookupImpl = function lookup(path, flatPath) {
3366
3422
  // Otherwise try each nested namespace
3367
3423
  } else {
3368
3424
  for (var i = 0; i < this.nestedArray.length; ++i)
3369
- if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i]._lookupImpl(path, flatPath)))
3425
+ if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i]._lookupImpl(path, flatPath))) {
3370
3426
  exact = found;
3427
+ break;
3428
+ }
3371
3429
  }
3372
3430
 
3373
3431
  // Set this even when null, so that when we walk up the tree we can quickly bail on repeated checks back down.
@@ -3735,6 +3793,8 @@ ReflectionObject.prototype.getOption = function getOption(name) {
3735
3793
  * @returns {ReflectionObject} `this`
3736
3794
  */
3737
3795
  ReflectionObject.prototype.setOption = function setOption(name, value, ifNotSet) {
3796
+ if (name === "__proto__")
3797
+ return this;
3738
3798
  if (!this.options)
3739
3799
  this.options = {};
3740
3800
  if (/^features\./.test(name)) {
@@ -3755,6 +3815,8 @@ ReflectionObject.prototype.setOption = function setOption(name, value, ifNotSet)
3755
3815
  * @returns {ReflectionObject} `this`
3756
3816
  */
3757
3817
  ReflectionObject.prototype.setParsedOption = function setParsedOption(name, value, propName) {
3818
+ if (name === "__proto__")
3819
+ return this;
3758
3820
  if (!this.parsedOptions) {
3759
3821
  this.parsedOptions = [];
3760
3822
  }
@@ -4408,12 +4470,22 @@ Reader.prototype.skip = function skip(length) {
4408
4470
  return this;
4409
4471
  };
4410
4472
 
4473
+ /**
4474
+ * Recursion limit.
4475
+ * @type {number}
4476
+ */
4477
+ Reader.recursionLimit = util.recursionLimit;
4478
+
4411
4479
  /**
4412
4480
  * Skips the next element of the specified wire type.
4413
4481
  * @param {number} wireType Wire type received
4482
+ * @param {number} [depth] Depth of recursion to control nested calls; 0 if omitted
4414
4483
  * @returns {Reader} `this`
4415
4484
  */
4416
- Reader.prototype.skipType = function(wireType) {
4485
+ Reader.prototype.skipType = function(wireType, depth) {
4486
+ if (depth === undefined) depth = 0;
4487
+ if (depth > Reader.recursionLimit)
4488
+ throw Error("maximum nesting depth exceeded");
4417
4489
  switch (wireType) {
4418
4490
  case 0:
4419
4491
  this.skip();
@@ -4426,7 +4498,7 @@ Reader.prototype.skipType = function(wireType) {
4426
4498
  break;
4427
4499
  case 3:
4428
4500
  while ((wireType = this.uint32() & 7) !== 4) {
4429
- this.skipType(wireType);
4501
+ this.skipType(wireType, depth + 1);
4430
4502
  }
4431
4503
  break;
4432
4504
  case 5:
@@ -5144,6 +5216,8 @@ var Method = require(20),
5144
5216
  util = require(33),
5145
5217
  rpc = require(28);
5146
5218
 
5219
+ var reservedRe = util.patterns.reservedRe;
5220
+
5147
5221
  /**
5148
5222
  * Constructs a new service instance.
5149
5223
  * @classdesc Reflected service.
@@ -5237,8 +5311,9 @@ function clearCache(service) {
5237
5311
  * @override
5238
5312
  */
5239
5313
  Service.prototype.get = function get(name) {
5240
- return this.methods[name]
5241
- || Namespace.prototype.get.call(this, name);
5314
+ return Object.prototype.hasOwnProperty.call(this.methods, name)
5315
+ ? this.methods[name]
5316
+ : Namespace.prototype.get.call(this, name);
5242
5317
  };
5243
5318
 
5244
5319
  /**
@@ -5273,12 +5348,13 @@ Service.prototype._resolveFeaturesRecursive = function _resolveFeaturesRecursive
5273
5348
  * @override
5274
5349
  */
5275
5350
  Service.prototype.add = function add(object) {
5276
-
5277
5351
  /* istanbul ignore if */
5278
5352
  if (this.get(object.name))
5279
5353
  throw Error("duplicate name '" + object.name + "' in " + this);
5280
5354
 
5281
5355
  if (object instanceof Method) {
5356
+ if (object.name === "__proto__")
5357
+ return this;
5282
5358
  this.methods[object.name] = object;
5283
5359
  object.parent = this;
5284
5360
  return clearCache(this);
@@ -5314,7 +5390,7 @@ Service.prototype.create = function create(rpcImpl, requestDelimited, responseDe
5314
5390
  var rpcService = new rpc.Service(rpcImpl, requestDelimited, responseDelimited);
5315
5391
  for (var i = 0, method; i < /* initializes */ this.methodsArray.length; ++i) {
5316
5392
  var methodName = util.lcFirst((method = this._methodsArray[i]).resolve().name).replace(/[^$\w_]/g, "");
5317
- rpcService[methodName] = util.codegen(["r","c"], util.isReserved(methodName) ? methodName + "_" : methodName)("return this.rpcCall(m,q,s,r,c)")({
5393
+ rpcService[methodName] = util.codegen(["r","c"], reservedRe.test(methodName) ? methodName + "_" : methodName)("return this.rpcCall(m,q,s,r,c)")({
5318
5394
  m: method,
5319
5395
  q: method.resolvedRequestType.ctor,
5320
5396
  s: method.resolvedResponseType.ctor
@@ -5338,13 +5414,13 @@ var Enum = require(14),
5338
5414
  Service = require(30),
5339
5415
  Message = require(19),
5340
5416
  Reader = require(24),
5341
- Writer = require(38),
5417
+ Writer = require(39),
5342
5418
  util = require(33),
5343
5419
  encoder = require(13),
5344
5420
  decoder = require(12),
5345
- verifier = require(36),
5421
+ verifier = require(37),
5346
5422
  converter = require(11),
5347
- wrappers = require(37);
5423
+ wrappers = require(38);
5348
5424
 
5349
5425
  /**
5350
5426
  * Constructs a new reflected message type instance.
@@ -5531,7 +5607,7 @@ Type.generateConstructor = function generateConstructor(mtype) {
5531
5607
  else if (field.repeated) gen
5532
5608
  ("this%s=[]", util.safeProp(field.name));
5533
5609
  return gen
5534
- ("if(p)for(var ks=Object.keys(p),i=0;i<ks.length;++i)if(p[ks[i]]!=null)") // omit undefined or null
5610
+ ("if(p)for(var ks=Object.keys(p),i=0;i<ks.length;++i)if(p[ks[i]]!=null&&ks[i]!==\"__proto__\")") // omit undefined or null
5535
5611
  ("this[ks[i]]=p[ks[i]]");
5536
5612
  /* eslint-enable no-unexpected-multiline */
5537
5613
  };
@@ -5664,10 +5740,13 @@ Type.prototype._resolveFeaturesRecursive = function _resolveFeaturesRecursive(ed
5664
5740
  * @override
5665
5741
  */
5666
5742
  Type.prototype.get = function get(name) {
5667
- return this.fields[name]
5668
- || this.oneofs && this.oneofs[name]
5669
- || this.nested && this.nested[name]
5670
- || null;
5743
+ if (Object.prototype.hasOwnProperty.call(this.fields, name))
5744
+ return this.fields[name];
5745
+ if (this.oneofs && Object.prototype.hasOwnProperty.call(this.oneofs, name))
5746
+ return this.oneofs[name];
5747
+ if (this.nested && Object.prototype.hasOwnProperty.call(this.nested, name))
5748
+ return this.nested[name];
5749
+ return null;
5671
5750
  };
5672
5751
 
5673
5752
  /**
@@ -5678,7 +5757,6 @@ Type.prototype.get = function get(name) {
5678
5757
  * @throws {Error} If there is already a nested object with this name or, if a field, when there is already a field with this id
5679
5758
  */
5680
5759
  Type.prototype.add = function add(object) {
5681
-
5682
5760
  if (this.get(object.name))
5683
5761
  throw Error("duplicate name '" + object.name + "' in " + this);
5684
5762
 
@@ -5694,6 +5772,8 @@ Type.prototype.add = function add(object) {
5694
5772
  throw Error("id " + object.id + " is reserved in " + this);
5695
5773
  if (this.isReservedName(object.name))
5696
5774
  throw Error("name '" + object.name + "' is reserved in " + this);
5775
+ if (object.name === "__proto__")
5776
+ return this;
5697
5777
 
5698
5778
  if (object.parent)
5699
5779
  object.parent.remove(object);
@@ -5703,6 +5783,8 @@ Type.prototype.add = function add(object) {
5703
5783
  return clearCache(this);
5704
5784
  }
5705
5785
  if (object instanceof OneOf) {
5786
+ if (object.name === "__proto__")
5787
+ return this;
5706
5788
  if (!this.oneofs)
5707
5789
  this.oneofs = {};
5708
5790
  this.oneofs[object.name] = object;
@@ -5851,12 +5933,14 @@ Type.prototype.encodeDelimited = function encodeDelimited(message, writer) {
5851
5933
  * Decodes a message of this type.
5852
5934
  * @param {Reader|Uint8Array} reader Reader or buffer to decode from
5853
5935
  * @param {number} [length] Length of the message, if known beforehand
5936
+ * @param {number} [end] Expected group end tag, if decoding a group
5937
+ * @param {number} [depth] Current nesting depth
5854
5938
  * @returns {Message<{}>} Decoded message
5855
5939
  * @throws {Error} If the payload is not a reader or valid buffer
5856
5940
  * @throws {util.ProtocolError<{}>} If required fields are missing
5857
5941
  */
5858
- Type.prototype.decode = function decode_setup(reader, length) {
5859
- return this.setup().decode(reader, length); // overrides this method
5942
+ Type.prototype.decode = function decode_setup(reader, length, end, depth) {
5943
+ return this.setup().decode(reader, length, end, depth); // overrides this method
5860
5944
  };
5861
5945
 
5862
5946
  /**
@@ -5875,19 +5959,21 @@ Type.prototype.decodeDelimited = function decodeDelimited(reader) {
5875
5959
  /**
5876
5960
  * Verifies that field values are valid and that required fields are present.
5877
5961
  * @param {Object.<string,*>} message Plain object to verify
5962
+ * @param {number} [depth] Current nesting depth
5878
5963
  * @returns {null|string} `null` if valid, otherwise the reason why it is not
5879
5964
  */
5880
- Type.prototype.verify = function verify_setup(message) {
5881
- return this.setup().verify(message); // overrides this method
5965
+ Type.prototype.verify = function verify_setup(message, depth) {
5966
+ return this.setup().verify(message, depth); // overrides this method
5882
5967
  };
5883
5968
 
5884
5969
  /**
5885
5970
  * Creates a new message of this type from a plain object. Also converts values to their respective internal types.
5886
5971
  * @param {Object.<string,*>} object Plain object to convert
5972
+ * @param {number} [depth] Current nesting depth
5887
5973
  * @returns {Message<{}>} Message instance
5888
5974
  */
5889
- Type.prototype.fromObject = function fromObject(object) {
5890
- return this.setup().fromObject(object);
5975
+ Type.prototype.fromObject = function fromObject(object, depth) {
5976
+ return this.setup().fromObject(object, depth);
5891
5977
  };
5892
5978
 
5893
5979
  /**
@@ -5940,7 +6026,7 @@ Type.d = function decorateType(typeName) {
5940
6026
  };
5941
6027
  };
5942
6028
 
5943
- },{"11":11,"12":12,"13":13,"14":14,"15":15,"18":18,"19":19,"21":21,"23":23,"24":24,"30":30,"33":33,"36":36,"37":37,"38":38}],32:[function(require,module,exports){
6029
+ },{"11":11,"12":12,"13":13,"14":14,"15":15,"18":18,"19":19,"21":21,"23":23,"24":24,"30":30,"33":33,"37":37,"38":38,"39":39}],32:[function(require,module,exports){
5944
6030
  "use strict";
5945
6031
 
5946
6032
  /**
@@ -5970,7 +6056,7 @@ var s = [
5970
6056
  ];
5971
6057
 
5972
6058
  function bake(values, offset) {
5973
- var i = 0, o = {};
6059
+ var i = 0, o = Object.create(null);
5974
6060
  offset |= 0;
5975
6061
  while (i < values.length) o[s[i + offset]] = values[i++];
5976
6062
  return o;
@@ -6155,6 +6241,10 @@ var Type, // cyclic
6155
6241
  util.codegen = require(3);
6156
6242
  util.fetch = require(5);
6157
6243
  util.path = require(8);
6244
+ util.patterns = require(36);
6245
+
6246
+ var reservedRe = util.patterns.reservedRe,
6247
+ unsafePropertyRe = util.patterns.unsafePropertyRe;
6158
6248
 
6159
6249
  /**
6160
6250
  * Node's fs module if available.
@@ -6196,16 +6286,13 @@ util.toObject = function toObject(array) {
6196
6286
  return object;
6197
6287
  };
6198
6288
 
6199
- var safePropBackslashRe = /\\/g,
6200
- safePropQuoteRe = /"/g;
6201
-
6202
6289
  /**
6203
6290
  * Tests whether the specified name is a reserved word in JS.
6204
6291
  * @param {string} name Name to test
6205
6292
  * @returns {boolean} `true` if reserved, otherwise `false`
6206
6293
  */
6207
6294
  util.isReserved = function isReserved(name) {
6208
- return /^(?: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)$/.test(name);
6295
+ return reservedRe.test(name);
6209
6296
  };
6210
6297
 
6211
6298
  /**
@@ -6214,8 +6301,8 @@ util.isReserved = function isReserved(name) {
6214
6301
  * @returns {string} Safe accessor
6215
6302
  */
6216
6303
  util.safeProp = function safeProp(prop) {
6217
- if (!/^[$\w_]+$/.test(prop) || util.isReserved(prop))
6218
- return "[\"" + prop.replace(safePropBackslashRe, "\\\\").replace(safePropQuoteRe, "\\\"") + "\"]";
6304
+ if (!/^[$\w_]+$/.test(prop) || reservedRe.test(prop))
6305
+ return "[" + JSON.stringify(prop) + "]";
6219
6306
  return "." + prop;
6220
6307
  };
6221
6308
 
@@ -6318,9 +6405,8 @@ util.decorateEnum = function decorateEnum(object) {
6318
6405
  util.setProperty = function setProperty(dst, path, value, ifNotSet) {
6319
6406
  function setProp(dst, path, value) {
6320
6407
  var part = path.shift();
6321
- if (part === "__proto__" || part === "prototype") {
6322
- return dst;
6323
- }
6408
+ if (unsafePropertyRe.test(part))
6409
+ return dst;
6324
6410
  if (path.length > 0) {
6325
6411
  dst[part] = setProp(dst[part] || {}, path, value);
6326
6412
  } else {
@@ -6355,7 +6441,7 @@ Object.defineProperty(util, "decorateRoot", {
6355
6441
  }
6356
6442
  });
6357
6443
 
6358
- },{"14":14,"26":26,"27":27,"3":3,"31":31,"35":35,"5":5,"8":8}],34:[function(require,module,exports){
6444
+ },{"14":14,"26":26,"27":27,"3":3,"31":31,"35":35,"36":36,"5":5,"8":8}],34:[function(require,module,exports){
6359
6445
  "use strict";
6360
6446
  module.exports = LongBits;
6361
6447
 
@@ -6797,12 +6883,35 @@ util.longFromHash = function longFromHash(hash, unsigned) {
6797
6883
  function merge(dst, src, ifNotSet) { // used by converters
6798
6884
  for (var keys = Object.keys(src), i = 0; i < keys.length; ++i)
6799
6885
  if (dst[keys[i]] === undefined || !ifNotSet)
6800
- dst[keys[i]] = src[keys[i]];
6886
+ if (keys[i] !== "__proto__")
6887
+ dst[keys[i]] = src[keys[i]];
6801
6888
  return dst;
6802
6889
  }
6803
6890
 
6804
6891
  util.merge = merge;
6805
6892
 
6893
+ /**
6894
+ * Recursion limit.
6895
+ * @memberof util
6896
+ * @type {number}
6897
+ */
6898
+ util.recursionLimit = 100;
6899
+
6900
+ /**
6901
+ * Makes a property safe for assignment as an own property.
6902
+ * @memberof util
6903
+ * @param {Object.<string,*>} obj Object
6904
+ * @param {string} key Property key
6905
+ * @returns {undefined}
6906
+ */
6907
+ util.makeProp = function makeProp(obj, key) {
6908
+ Object.defineProperty(obj, key, {
6909
+ enumerable: true,
6910
+ configurable: true,
6911
+ writable: true
6912
+ });
6913
+ };
6914
+
6806
6915
  /**
6807
6916
  * Converts the first character of a string to lower case.
6808
6917
  * @param {string} str String to convert
@@ -6999,6 +7108,16 @@ util._configure = function() {
6999
7108
 
7000
7109
  },{"1":1,"10":10,"2":2,"34":34,"4":4,"6":6,"7":7,"9":9}],36:[function(require,module,exports){
7001
7110
  "use strict";
7111
+
7112
+ var patterns = exports;
7113
+
7114
+ patterns.numberRe = /^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/;
7115
+ patterns.typeRefRe = /^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/;
7116
+ 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)$/;
7117
+ patterns.unsafePropertyRe = /^(?:__proto__|prototype|constructor)$/;
7118
+
7119
+ },{}],37:[function(require,module,exports){
7120
+ "use strict";
7002
7121
  module.exports = verifier;
7003
7122
 
7004
7123
  var Enum = require(14),
@@ -7032,7 +7151,7 @@ function genVerifyValue(gen, field, fieldIndex, ref) {
7032
7151
  } else {
7033
7152
  gen
7034
7153
  ("{")
7035
- ("var e=types[%i].verify(%s);", fieldIndex, ref)
7154
+ ("var e=types[%i].verify(%s,n+1);", fieldIndex, ref)
7036
7155
  ("if(e)")
7037
7156
  ("return%j+e", field.name + ".")
7038
7157
  ("}");
@@ -7122,9 +7241,12 @@ function genVerifyKey(gen, field, ref) {
7122
7241
  function verifier(mtype) {
7123
7242
  /* eslint-disable no-unexpected-multiline */
7124
7243
 
7125
- var gen = util.codegen(["m"], mtype.name + "$verify")
7244
+ var gen = util.codegen(["m", "n"], mtype.name + "$verify")
7126
7245
  ("if(typeof m!==\"object\"||m===null)")
7127
- ("return%j", "object expected");
7246
+ ("return%j", "object expected")
7247
+ ("if(n===undefined)n=0")
7248
+ ("if(n>util.recursionLimit)")
7249
+ ("return%j", "maximum nesting depth exceeded");
7128
7250
  var oneofs = mtype.oneofsArray,
7129
7251
  seenFirstField = {};
7130
7252
  if (oneofs.length) gen
@@ -7175,7 +7297,8 @@ function verifier(mtype) {
7175
7297
  ("return null");
7176
7298
  /* eslint-enable no-unexpected-multiline */
7177
7299
  }
7178
- },{"14":14,"33":33}],37:[function(require,module,exports){
7300
+
7301
+ },{"14":14,"33":33}],38:[function(require,module,exports){
7179
7302
  "use strict";
7180
7303
 
7181
7304
  /**
@@ -7216,7 +7339,7 @@ var Message = require(19);
7216
7339
  // Custom wrapper for Any
7217
7340
  wrappers[".google.protobuf.Any"] = {
7218
7341
 
7219
- fromObject: function(object) {
7342
+ fromObject: function(object, depth) {
7220
7343
 
7221
7344
  // unwrap value type if mapped
7222
7345
  if (object && object["@type"]) {
@@ -7232,14 +7355,15 @@ wrappers[".google.protobuf.Any"] = {
7232
7355
  if (type_url.indexOf("/") === -1) {
7233
7356
  type_url = "/" + type_url;
7234
7357
  }
7358
+ var nextDepth = depth === undefined ? 1 : depth + 1;
7235
7359
  return this.create({
7236
7360
  type_url: type_url,
7237
- value: type.encode(type.fromObject(object)).finish()
7361
+ value: type.encode(type.fromObject(object, nextDepth)).finish()
7238
7362
  });
7239
7363
  }
7240
7364
  }
7241
7365
 
7242
- return this.fromObject(object);
7366
+ return this.fromObject(object, depth);
7243
7367
  },
7244
7368
 
7245
7369
  toObject: function(message, options) {
@@ -7279,7 +7403,7 @@ wrappers[".google.protobuf.Any"] = {
7279
7403
  }
7280
7404
  };
7281
7405
 
7282
- },{"19":19}],38:[function(require,module,exports){
7406
+ },{"19":19}],39:[function(require,module,exports){
7283
7407
  "use strict";
7284
7408
  module.exports = Writer;
7285
7409
 
@@ -7746,12 +7870,12 @@ Writer._configure = function(BufferWriter_) {
7746
7870
  BufferWriter._configure();
7747
7871
  };
7748
7872
 
7749
- },{"35":35}],39:[function(require,module,exports){
7873
+ },{"35":35}],40:[function(require,module,exports){
7750
7874
  "use strict";
7751
7875
  module.exports = BufferWriter;
7752
7876
 
7753
7877
  // extends Writer
7754
- var Writer = require(38);
7878
+ var Writer = require(39);
7755
7879
  (BufferWriter.prototype = Object.create(Writer.prototype)).constructor = BufferWriter;
7756
7880
 
7757
7881
  var util = require(35);
@@ -7833,7 +7957,7 @@ BufferWriter.prototype.string = function write_string_buffer(value) {
7833
7957
 
7834
7958
  BufferWriter._configure();
7835
7959
 
7836
- },{"35":35,"38":38}]},{},[16])
7960
+ },{"35":35,"39":39}]},{},[16])
7837
7961
 
7838
7962
  })();
7839
7963
  //# sourceMappingURL=protobuf.js.map