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 +1 -1
- package/dist/light/protobuf.js +133 -73
- package/dist/light/protobuf.js.map +1 -1
- package/dist/light/protobuf.min.js +3 -3
- package/dist/light/protobuf.min.js.map +1 -1
- package/dist/minimal/protobuf.js +62 -25
- package/dist/minimal/protobuf.js.map +1 -1
- package/dist/minimal/protobuf.min.js +3 -3
- package/dist/minimal/protobuf.min.js.map +1 -1
- package/dist/protobuf.js +154 -80
- package/dist/protobuf.js.map +1 -1
- package/dist/protobuf.min.js +3 -3
- package/dist/protobuf.min.js.map +1 -1
- package/ext/descriptor/index.js +7 -2
- package/index.d.ts +14 -4
- package/package.json +3 -3
- package/src/converter.js +13 -8
- package/src/encoder.js +8 -5
- package/src/enum.js +2 -2
- package/src/field.js +1 -1
- package/src/namespace.js +2 -0
- package/src/object.js +6 -6
- package/src/parse.js +19 -5
- package/src/root.js +14 -8
- package/src/type.js +9 -6
- package/src/util/minimal.js +32 -7
- package/src/util/patterns.js +0 -1
- package/src/util.js +4 -3
- package/src/wrappers.js +11 -7
- package/src/writer.js +11 -9
package/dist/protobuf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* protobuf.js v7.
|
|
3
|
-
* compiled
|
|
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 {
|
|
380
|
+
* @param {EventEmitterListener} fn Listener
|
|
373
381
|
* @param {*} [ctx] Listener context
|
|
374
|
-
* @returns {
|
|
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 {
|
|
388
|
-
* @returns {
|
|
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 {
|
|
422
|
+
* @returns {this} `this`
|
|
413
423
|
*/
|
|
414
424
|
EventEmitter.prototype.emit = function emit(evt) {
|
|
415
425
|
var listeners = this._listeners[evt];
|
|
@@ -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
|
-
("
|
|
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)
|
|
@@ -1729,7 +1739,7 @@ function genValuePartial_toObject(gen, field, fieldIndex, prop) {
|
|
|
1729
1739
|
if (field.resolvedType instanceof Enum) gen
|
|
1730
1740
|
("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
1741
|
else gen
|
|
1732
|
-
("d%s=types[%i].toObject(m%s,o)", prop, fieldIndex, prop);
|
|
1742
|
+
("d%s=types[%i].toObject(m%s,o,q+1)", prop, fieldIndex, prop);
|
|
1733
1743
|
} else {
|
|
1734
1744
|
var isUnsigned = false;
|
|
1735
1745
|
switch (field.type) {
|
|
@@ -1738,13 +1748,15 @@ function genValuePartial_toObject(gen, field, fieldIndex, prop) {
|
|
|
1738
1748
|
("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s", prop, prop, prop, prop);
|
|
1739
1749
|
break;
|
|
1740
1750
|
case "uint64":
|
|
1751
|
+
case "fixed64":
|
|
1741
1752
|
isUnsigned = true;
|
|
1742
1753
|
// eslint-disable-next-line no-fallthrough
|
|
1743
1754
|
case "int64":
|
|
1744
1755
|
case "sint64":
|
|
1745
|
-
case "fixed64":
|
|
1746
1756
|
case "sfixed64": gen
|
|
1747
|
-
("if(typeof
|
|
1757
|
+
("if(typeof BigInt!==\"undefined\"&&o.longs===BigInt)")
|
|
1758
|
+
("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)
|
|
1759
|
+
("else if(typeof m%s===\"number\")", prop)
|
|
1748
1760
|
("d%s=o.longs===String?String(m%s):m%s", prop, prop, prop)
|
|
1749
1761
|
("else") // Long-like
|
|
1750
1762
|
("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);
|
|
@@ -1771,9 +1783,12 @@ converter.toObject = function toObject(mtype) {
|
|
|
1771
1783
|
var fields = mtype.fieldsArray.slice().sort(util.compareFieldsById);
|
|
1772
1784
|
if (!fields.length)
|
|
1773
1785
|
return util.codegen()("return {}");
|
|
1774
|
-
var gen = util.codegen(["m", "o"], mtype.name + "$toObject")
|
|
1786
|
+
var gen = util.codegen(["m", "o", "q"], mtype.name + "$toObject")
|
|
1775
1787
|
("if(!o)")
|
|
1776
1788
|
("o={}")
|
|
1789
|
+
("if(q===undefined)q=0")
|
|
1790
|
+
("if(q>util.recursionLimit)")
|
|
1791
|
+
("throw Error(\"max depth exceeded\")")
|
|
1777
1792
|
("var d={}");
|
|
1778
1793
|
|
|
1779
1794
|
var repeatedFields = [],
|
|
@@ -1812,9 +1827,9 @@ converter.toObject = function toObject(mtype) {
|
|
|
1812
1827
|
else if (field.long) gen
|
|
1813
1828
|
("if(util.Long){")
|
|
1814
1829
|
("var n=new util.Long(%i,%i,%j)", field.typeDefault.low, field.typeDefault.high, field.typeDefault.unsigned)
|
|
1815
|
-
("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n", prop)
|
|
1830
|
+
("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():typeof BigInt!==\"undefined\"&&o.longs===BigInt?n.toBigInt():n", prop)
|
|
1816
1831
|
("}else")
|
|
1817
|
-
("d%s=o.longs===String?%j:%i", prop, field.typeDefault.toString(), field.typeDefault.toNumber());
|
|
1832
|
+
("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());
|
|
1818
1833
|
else if (field.bytes) {
|
|
1819
1834
|
var arrayDefault = Array.prototype.slice.call(field.typeDefault);
|
|
1820
1835
|
gen
|
|
@@ -2022,8 +2037,8 @@ var Enum = require(17),
|
|
|
2022
2037
|
*/
|
|
2023
2038
|
function genTypePartial(gen, field, fieldIndex, ref) {
|
|
2024
2039
|
return field.delimited
|
|
2025
|
-
? gen("types[%i].encode(%s,w.uint32(%i)).uint32(%i)", fieldIndex, ref, (field.id << 3 | 3) >>> 0, (field.id << 3 | 4) >>> 0)
|
|
2026
|
-
: gen("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()", fieldIndex, ref, (field.id << 3 | 2) >>> 0);
|
|
2040
|
+
? gen("types[%i].encode(%s,w.uint32(%i),q+1).uint32(%i)", fieldIndex, ref, (field.id << 3 | 3) >>> 0, (field.id << 3 | 4) >>> 0)
|
|
2041
|
+
: gen("types[%i].encode(%s,w.uint32(%i).fork(),q+1).ldelim()", fieldIndex, ref, (field.id << 3 | 2) >>> 0);
|
|
2027
2042
|
}
|
|
2028
2043
|
|
|
2029
2044
|
/**
|
|
@@ -2033,9 +2048,12 @@ function genTypePartial(gen, field, fieldIndex, ref) {
|
|
|
2033
2048
|
*/
|
|
2034
2049
|
function encoder(mtype) {
|
|
2035
2050
|
/* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */
|
|
2036
|
-
var gen = util.codegen(["m", "w"], mtype.name + "$encode")
|
|
2051
|
+
var gen = util.codegen(["m", "w", "q"], mtype.name + "$encode")
|
|
2037
2052
|
("if(!w)")
|
|
2038
|
-
("w=Writer.create()")
|
|
2053
|
+
("w=Writer.create()")
|
|
2054
|
+
("if(q===undefined)q=0")
|
|
2055
|
+
("if(q>util.recursionLimit)")
|
|
2056
|
+
("throw Error(\"max depth exceeded\")");
|
|
2039
2057
|
|
|
2040
2058
|
var i, ref;
|
|
2041
2059
|
|
|
@@ -2056,7 +2074,7 @@ function encoder(mtype) {
|
|
|
2056
2074
|
("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){", ref)
|
|
2057
2075
|
("w.uint32(%i).fork().uint32(%i).%s(ks[i])", (field.id << 3 | 2) >>> 0, 8 | types.mapKey[field.keyType], field.keyType);
|
|
2058
2076
|
if (wireType === undefined) gen
|
|
2059
|
-
("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()", index, ref); // can't be groups
|
|
2077
|
+
("types[%i].encode(%s[ks[i]],w.uint32(18).fork(),q+1).ldelim().ldelim()", index, ref); // can't be groups
|
|
2060
2078
|
else gen
|
|
2061
2079
|
(".uint32(%i).%s(%s[ks[i]]).ldelim()", 16 | wireType, type, ref);
|
|
2062
2080
|
gen
|
|
@@ -2194,8 +2212,8 @@ Enum.prototype._resolveFeatures = function _resolveFeatures(edition) {
|
|
|
2194
2212
|
ReflectionObject.prototype._resolveFeatures.call(this, edition);
|
|
2195
2213
|
|
|
2196
2214
|
Object.keys(this.values).forEach(key => {
|
|
2197
|
-
var parentFeaturesCopy =
|
|
2198
|
-
this._valuesFeatures[key] =
|
|
2215
|
+
var parentFeaturesCopy = util.merge({}, this._features);
|
|
2216
|
+
this._valuesFeatures[key] = util.merge(parentFeaturesCopy, this.valuesOptions && this.valuesOptions[key] && this.valuesOptions[key].features || {});
|
|
2199
2217
|
});
|
|
2200
2218
|
|
|
2201
2219
|
return this;
|
|
@@ -2664,7 +2682,7 @@ Field.prototype.resolve = function resolve() {
|
|
|
2664
2682
|
|
|
2665
2683
|
// convert to internal data type if necesssary
|
|
2666
2684
|
if (this.long) {
|
|
2667
|
-
this.typeDefault = util.Long.fromNumber(this.typeDefault, this.type.
|
|
2685
|
+
this.typeDefault = util.Long.fromNumber(this.typeDefault, this.type === "uint64" || this.type === "fixed64");
|
|
2668
2686
|
|
|
2669
2687
|
/* istanbul ignore else */
|
|
2670
2688
|
if (Object.freeze)
|
|
@@ -3721,6 +3739,8 @@ Namespace.prototype.define = function define(path, json) {
|
|
|
3721
3739
|
throw TypeError("illegal path");
|
|
3722
3740
|
if (path && path.length && path[0] === "")
|
|
3723
3741
|
throw Error("path must be relative");
|
|
3742
|
+
if (path.length > util.recursionLimit)
|
|
3743
|
+
throw Error("max depth exceeded");
|
|
3724
3744
|
|
|
3725
3745
|
var ptr = this;
|
|
3726
3746
|
while (path.length > 0) {
|
|
@@ -4155,7 +4175,7 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
|
|
|
4155
4175
|
throw new Error("Unknown edition for " + this.fullName);
|
|
4156
4176
|
}
|
|
4157
4177
|
|
|
4158
|
-
var protoFeatures =
|
|
4178
|
+
var protoFeatures = util.merge({}, this.options && this.options.features,
|
|
4159
4179
|
this._inferLegacyProtoFeatures(edition));
|
|
4160
4180
|
|
|
4161
4181
|
if (this._edition) {
|
|
@@ -4170,7 +4190,7 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
|
|
|
4170
4190
|
} else {
|
|
4171
4191
|
throw new Error("Unknown edition: " + edition);
|
|
4172
4192
|
}
|
|
4173
|
-
this._features =
|
|
4193
|
+
this._features = util.merge(defaults, protoFeatures);
|
|
4174
4194
|
this._featuresResolved = true;
|
|
4175
4195
|
return;
|
|
4176
4196
|
}
|
|
@@ -4179,13 +4199,13 @@ ReflectionObject.prototype._resolveFeatures = function _resolveFeatures(edition)
|
|
|
4179
4199
|
// special-case it
|
|
4180
4200
|
/* istanbul ignore else */
|
|
4181
4201
|
if (this.partOf instanceof OneOf) {
|
|
4182
|
-
var lexicalParentFeaturesCopy =
|
|
4183
|
-
this._features =
|
|
4202
|
+
var lexicalParentFeaturesCopy = util.merge({}, this.partOf._features);
|
|
4203
|
+
this._features = util.merge(lexicalParentFeaturesCopy, protoFeatures);
|
|
4184
4204
|
} else if (this.declaringField) {
|
|
4185
4205
|
// Skip feature resolution of sister fields.
|
|
4186
4206
|
} else if (this.parent) {
|
|
4187
|
-
var parentFeaturesCopy =
|
|
4188
|
-
this._features =
|
|
4207
|
+
var parentFeaturesCopy = util.merge({}, this.parent._features);
|
|
4208
|
+
this._features = util.merge(parentFeaturesCopy, protoFeatures);
|
|
4189
4209
|
} else {
|
|
4190
4210
|
throw new Error("Unable to find a parent for " + this.fullName);
|
|
4191
4211
|
}
|
|
@@ -4852,7 +4872,9 @@ function parse(source, root, options) {
|
|
|
4852
4872
|
|
|
4853
4873
|
|
|
4854
4874
|
function parseCommon(parent, token, depth) {
|
|
4855
|
-
depth
|
|
4875
|
+
if (depth === undefined)
|
|
4876
|
+
depth = 0;
|
|
4877
|
+
// depth is checked by dispatched functions
|
|
4856
4878
|
switch (token) {
|
|
4857
4879
|
|
|
4858
4880
|
case "option":
|
|
@@ -4902,7 +4924,10 @@ function parse(source, root, options) {
|
|
|
4902
4924
|
}
|
|
4903
4925
|
|
|
4904
4926
|
function parseType(parent, token, depth) {
|
|
4905
|
-
depth
|
|
4927
|
+
if (depth === undefined)
|
|
4928
|
+
depth = 0;
|
|
4929
|
+
if (depth > util.nestingLimit)
|
|
4930
|
+
throw Error("max depth exceeded");
|
|
4906
4931
|
|
|
4907
4932
|
/* istanbul ignore if */
|
|
4908
4933
|
if (!nameRe.test(token = next()))
|
|
@@ -5028,7 +5053,10 @@ function parse(source, root, options) {
|
|
|
5028
5053
|
}
|
|
5029
5054
|
|
|
5030
5055
|
function parseGroup(parent, rule, depth) {
|
|
5031
|
-
depth
|
|
5056
|
+
if (depth === undefined)
|
|
5057
|
+
depth = 0;
|
|
5058
|
+
if (depth > util.nestingLimit)
|
|
5059
|
+
throw Error("max depth exceeded");
|
|
5032
5060
|
if (edition >= 2023) {
|
|
5033
5061
|
throw illegal("group");
|
|
5034
5062
|
}
|
|
@@ -5247,7 +5275,10 @@ function parse(source, root, options) {
|
|
|
5247
5275
|
}
|
|
5248
5276
|
|
|
5249
5277
|
function parseOptionValue(parent, name, depth) {
|
|
5250
|
-
depth
|
|
5278
|
+
if (depth === undefined)
|
|
5279
|
+
depth = 0;
|
|
5280
|
+
if (depth > util.recursionLimit)
|
|
5281
|
+
throw Error("max depth exceeded");
|
|
5251
5282
|
// { a: "foo" b { c: "bar" } }
|
|
5252
5283
|
if (skip("{", true)) {
|
|
5253
5284
|
var objectResult = {};
|
|
@@ -5336,7 +5367,10 @@ function parse(source, root, options) {
|
|
|
5336
5367
|
}
|
|
5337
5368
|
|
|
5338
5369
|
function parseService(parent, token, depth) {
|
|
5339
|
-
depth
|
|
5370
|
+
if (depth === undefined)
|
|
5371
|
+
depth = 0;
|
|
5372
|
+
if (depth > util.recursionLimit)
|
|
5373
|
+
throw Error("max depth exceeded");
|
|
5340
5374
|
|
|
5341
5375
|
/* istanbul ignore if */
|
|
5342
5376
|
if (!nameRe.test(token = next()))
|
|
@@ -6146,8 +6180,12 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
6146
6180
|
}
|
|
6147
6181
|
|
|
6148
6182
|
// Processes a single file
|
|
6149
|
-
function process(filename, source) {
|
|
6183
|
+
function process(filename, source, depth) {
|
|
6184
|
+
if (depth === undefined)
|
|
6185
|
+
depth = 0;
|
|
6150
6186
|
try {
|
|
6187
|
+
if (depth > util.recursionLimit)
|
|
6188
|
+
throw Error("max depth exceeded");
|
|
6151
6189
|
if (util.isString(source) && source.charAt(0) === "{")
|
|
6152
6190
|
source = JSON.parse(source);
|
|
6153
6191
|
if (!util.isString(source))
|
|
@@ -6160,11 +6198,11 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
6160
6198
|
if (parsed.imports)
|
|
6161
6199
|
for (; i < parsed.imports.length; ++i)
|
|
6162
6200
|
if (resolved = getBundledFileName(parsed.imports[i]) || self.resolvePath(filename, parsed.imports[i]))
|
|
6163
|
-
fetch(resolved);
|
|
6201
|
+
fetch(resolved, false, depth + 1);
|
|
6164
6202
|
if (parsed.weakImports)
|
|
6165
6203
|
for (i = 0; i < parsed.weakImports.length; ++i)
|
|
6166
6204
|
if (resolved = getBundledFileName(parsed.weakImports[i]) || self.resolvePath(filename, parsed.weakImports[i]))
|
|
6167
|
-
fetch(resolved, true);
|
|
6205
|
+
fetch(resolved, true, depth + 1);
|
|
6168
6206
|
}
|
|
6169
6207
|
} catch (err) {
|
|
6170
6208
|
finish(err);
|
|
@@ -6175,7 +6213,9 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
6175
6213
|
}
|
|
6176
6214
|
|
|
6177
6215
|
// Fetches a single file
|
|
6178
|
-
function fetch(filename, weak) {
|
|
6216
|
+
function fetch(filename, weak, depth) {
|
|
6217
|
+
if (depth === undefined)
|
|
6218
|
+
depth = 0;
|
|
6179
6219
|
filename = getBundledFileName(filename) || filename;
|
|
6180
6220
|
|
|
6181
6221
|
// Skip if already loaded / attempted
|
|
@@ -6187,12 +6227,12 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
6187
6227
|
// Shortcut bundled definitions
|
|
6188
6228
|
if (filename in common) {
|
|
6189
6229
|
if (sync) {
|
|
6190
|
-
process(filename, common[filename]);
|
|
6230
|
+
process(filename, common[filename], depth);
|
|
6191
6231
|
} else {
|
|
6192
6232
|
++queued;
|
|
6193
6233
|
setTimeout(function() {
|
|
6194
6234
|
--queued;
|
|
6195
|
-
process(filename, common[filename]);
|
|
6235
|
+
process(filename, common[filename], depth);
|
|
6196
6236
|
});
|
|
6197
6237
|
}
|
|
6198
6238
|
return;
|
|
@@ -6208,7 +6248,7 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
6208
6248
|
finish(err);
|
|
6209
6249
|
return;
|
|
6210
6250
|
}
|
|
6211
|
-
process(filename, source);
|
|
6251
|
+
process(filename, source, depth);
|
|
6212
6252
|
} else {
|
|
6213
6253
|
++queued;
|
|
6214
6254
|
self.fetch(filename, function(err, source) {
|
|
@@ -6225,7 +6265,7 @@ Root.prototype.load = function load(filename, options, callback) {
|
|
|
6225
6265
|
finish(null, self);
|
|
6226
6266
|
return;
|
|
6227
6267
|
}
|
|
6228
|
-
process(filename, source);
|
|
6268
|
+
process(filename, source, depth);
|
|
6229
6269
|
});
|
|
6230
6270
|
}
|
|
6231
6271
|
}
|
|
@@ -7470,7 +7510,10 @@ function clearCache(type) {
|
|
|
7470
7510
|
* @returns {Type} Created message type
|
|
7471
7511
|
*/
|
|
7472
7512
|
Type.fromJSON = function fromJSON(name, json, depth) {
|
|
7473
|
-
depth
|
|
7513
|
+
if (depth === undefined)
|
|
7514
|
+
depth = 0;
|
|
7515
|
+
if (depth > util.nestingLimit)
|
|
7516
|
+
throw Error("max depth exceeded");
|
|
7474
7517
|
var type = new Type(name, json.options);
|
|
7475
7518
|
type.extensions = json.extensions;
|
|
7476
7519
|
type.reserved = json.reserved;
|
|
@@ -7748,8 +7791,8 @@ Type.prototype.setup = function setup() {
|
|
|
7748
7791
|
* @param {Writer} [writer] Writer to encode to
|
|
7749
7792
|
* @returns {Writer} writer
|
|
7750
7793
|
*/
|
|
7751
|
-
Type.prototype.encode = function encode_setup(message, writer) {
|
|
7752
|
-
return this.setup().encode(
|
|
7794
|
+
Type.prototype.encode = function encode_setup(message, writer) { // eslint-disable-line no-unused-vars
|
|
7795
|
+
return this.setup().encode.apply(this, arguments); // overrides this method
|
|
7753
7796
|
};
|
|
7754
7797
|
|
|
7755
7798
|
/**
|
|
@@ -7813,7 +7856,7 @@ Type.prototype.fromObject = function fromObject(object, depth) {
|
|
|
7813
7856
|
* Conversion options as used by {@link Type#toObject} and {@link Message.toObject}.
|
|
7814
7857
|
* @interface IConversionOptions
|
|
7815
7858
|
* @property {Function} [longs] Long conversion type.
|
|
7816
|
-
* Valid values are `String` and `Number` (the global types).
|
|
7859
|
+
* Valid values are `BigInt`, `String` and `Number` (the global types).
|
|
7817
7860
|
* Defaults to copy the present value, which is a possibly unsafe number without and a {@link Long} with a long library.
|
|
7818
7861
|
* @property {Function} [enums] Enum value conversion type.
|
|
7819
7862
|
* Only valid value is `String` (the global type).
|
|
@@ -7834,8 +7877,8 @@ Type.prototype.fromObject = function fromObject(object, depth) {
|
|
|
7834
7877
|
* @param {IConversionOptions} [options] Conversion options
|
|
7835
7878
|
* @returns {Object.<string,*>} Plain object
|
|
7836
7879
|
*/
|
|
7837
|
-
Type.prototype.toObject = function toObject(message, options) {
|
|
7838
|
-
return this.setup().toObject(
|
|
7880
|
+
Type.prototype.toObject = function toObject(message, options) { // eslint-disable-line no-unused-vars
|
|
7881
|
+
return this.setup().toObject.apply(this, arguments);
|
|
7839
7882
|
};
|
|
7840
7883
|
|
|
7841
7884
|
/**
|
|
@@ -8076,8 +8119,7 @@ util.fetch = require(5);
|
|
|
8076
8119
|
util.path = require(9);
|
|
8077
8120
|
util.patterns = require(43);
|
|
8078
8121
|
|
|
8079
|
-
var reservedRe = util.patterns.reservedRe
|
|
8080
|
-
unsafePropertyRe = util.patterns.unsafePropertyRe;
|
|
8122
|
+
var reservedRe = util.patterns.reservedRe;
|
|
8081
8123
|
|
|
8082
8124
|
/**
|
|
8083
8125
|
* Node's fs module if available.
|
|
@@ -8252,7 +8294,7 @@ util.decorateEnum = function decorateEnum(object) {
|
|
|
8252
8294
|
util.setProperty = function setProperty(dst, path, value, ifNotSet) {
|
|
8253
8295
|
function setProp(dst, path, value) {
|
|
8254
8296
|
var part = path.shift();
|
|
8255
|
-
if (
|
|
8297
|
+
if (util.isUnsafeProperty(part))
|
|
8256
8298
|
return dst;
|
|
8257
8299
|
if (path.length > 0) {
|
|
8258
8300
|
dst[part] = setProp(dst[part] || {}, path, value);
|
|
@@ -8273,6 +8315,8 @@ util.setProperty = function setProperty(dst, path, value, ifNotSet) {
|
|
|
8273
8315
|
throw TypeError("path must be specified");
|
|
8274
8316
|
|
|
8275
8317
|
path = path.split(".");
|
|
8318
|
+
if (path.length > util.recursionLimit)
|
|
8319
|
+
throw Error("max depth exceeded");
|
|
8276
8320
|
return setProp(dst, path, value);
|
|
8277
8321
|
};
|
|
8278
8322
|
|
|
@@ -8531,6 +8575,18 @@ util.pool = require(10);
|
|
|
8531
8575
|
// utility to work with the low and high bits of a 64 bit value
|
|
8532
8576
|
util.LongBits = require(41);
|
|
8533
8577
|
|
|
8578
|
+
/**
|
|
8579
|
+
* Tests if the specified key can affect object prototypes.
|
|
8580
|
+
* @memberof util
|
|
8581
|
+
* @param {string} key Key to test
|
|
8582
|
+
* @returns {boolean} `true` if the key is unsafe
|
|
8583
|
+
*/
|
|
8584
|
+
function isUnsafeProperty(key) {
|
|
8585
|
+
return key === "__proto__" || key === "prototype" || key === "constructor";
|
|
8586
|
+
}
|
|
8587
|
+
|
|
8588
|
+
util.isUnsafeProperty = isUnsafeProperty;
|
|
8589
|
+
|
|
8534
8590
|
/**
|
|
8535
8591
|
* Whether running within node or not.
|
|
8536
8592
|
* @memberof util
|
|
@@ -8744,26 +8800,39 @@ util.longFromHash = function longFromHash(hash, unsigned) {
|
|
|
8744
8800
|
* Merges the properties of the source object into the destination object.
|
|
8745
8801
|
* @memberof util
|
|
8746
8802
|
* @param {Object.<string,*>} dst Destination object
|
|
8747
|
-
* @param {Object.<string
|
|
8748
|
-
* @param {boolean} [ifNotSet=false] Merges only if the key is not already set
|
|
8803
|
+
* @param {...(Object.<string,*>|boolean)} src Source objects, optionally followed by an `ifNotSet` flag
|
|
8749
8804
|
* @returns {Object.<string,*>} Destination object
|
|
8750
8805
|
*/
|
|
8751
|
-
function merge(dst
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
|
|
8806
|
+
function merge(dst) { // used by converters
|
|
8807
|
+
var ifNotSet = typeof arguments[arguments.length - 1] === "boolean",
|
|
8808
|
+
limit = ifNotSet ? arguments.length - 1 : arguments.length;
|
|
8809
|
+
ifNotSet = ifNotSet && arguments[arguments.length - 1];
|
|
8810
|
+
for (var a = 1; a < limit; ++a) {
|
|
8811
|
+
var src = arguments[a];
|
|
8812
|
+
if (!src)
|
|
8813
|
+
continue;
|
|
8814
|
+
for (var keys = Object.keys(src), i = 0; i < keys.length; ++i)
|
|
8815
|
+
if (!isUnsafeProperty(keys[i]) && (dst[keys[i]] === undefined || !ifNotSet))
|
|
8755
8816
|
dst[keys[i]] = src[keys[i]];
|
|
8817
|
+
}
|
|
8756
8818
|
return dst;
|
|
8757
8819
|
}
|
|
8758
8820
|
|
|
8759
8821
|
util.merge = merge;
|
|
8760
8822
|
|
|
8823
|
+
/**
|
|
8824
|
+
* Schema declaration nesting limit.
|
|
8825
|
+
* @memberof util
|
|
8826
|
+
* @type {number}
|
|
8827
|
+
*/
|
|
8828
|
+
util.nestingLimit = 32; // protoc: MaxMessageDeclarationNestingDepth
|
|
8829
|
+
|
|
8761
8830
|
/**
|
|
8762
8831
|
* Recursion limit.
|
|
8763
8832
|
* @memberof util
|
|
8764
8833
|
* @type {number}
|
|
8765
8834
|
*/
|
|
8766
|
-
util.recursionLimit = 100;
|
|
8835
|
+
util.recursionLimit = 100; // protoc: CodedInputStream::default_recursion_limit_
|
|
8767
8836
|
|
|
8768
8837
|
/**
|
|
8769
8838
|
* Makes a property safe for assignment as an own property.
|
|
@@ -8982,7 +9051,6 @@ var patterns = exports;
|
|
|
8982
9051
|
patterns.numberRe = /^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/;
|
|
8983
9052
|
patterns.typeRefRe = /^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/;
|
|
8984
9053
|
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)$/;
|
|
8985
|
-
patterns.unsafePropertyRe = /^(?:__proto__|prototype|constructor)$/;
|
|
8986
9054
|
|
|
8987
9055
|
},{}],44:[function(require,module,exports){
|
|
8988
9056
|
"use strict";
|
|
@@ -9176,7 +9244,8 @@ function verifier(mtype) {
|
|
|
9176
9244
|
*/
|
|
9177
9245
|
var wrappers = exports;
|
|
9178
9246
|
|
|
9179
|
-
var Message = require(23)
|
|
9247
|
+
var Message = require(23),
|
|
9248
|
+
util = require(42);
|
|
9180
9249
|
|
|
9181
9250
|
/**
|
|
9182
9251
|
* From object converter part of an {@link IWrapper}.
|
|
@@ -9223,10 +9292,9 @@ wrappers[".google.protobuf.Any"] = {
|
|
|
9223
9292
|
if (type_url.indexOf("/") === -1) {
|
|
9224
9293
|
type_url = "/" + type_url;
|
|
9225
9294
|
}
|
|
9226
|
-
var nextDepth = depth === undefined ? 1 : depth + 1;
|
|
9227
9295
|
return this.create({
|
|
9228
9296
|
type_url: type_url,
|
|
9229
|
-
value: type.encode(type.fromObject(object,
|
|
9297
|
+
value: type.encode(type.fromObject(object, depth === undefined ? 1 : depth + 1)).finish()
|
|
9230
9298
|
});
|
|
9231
9299
|
}
|
|
9232
9300
|
}
|
|
@@ -9234,7 +9302,11 @@ wrappers[".google.protobuf.Any"] = {
|
|
|
9234
9302
|
return this.fromObject(object, depth);
|
|
9235
9303
|
},
|
|
9236
9304
|
|
|
9237
|
-
toObject: function(message, options) {
|
|
9305
|
+
toObject: function(message, options, depth) {
|
|
9306
|
+
if (depth === undefined)
|
|
9307
|
+
depth = 0;
|
|
9308
|
+
if (depth > util.recursionLimit)
|
|
9309
|
+
throw Error("max depth exceeded");
|
|
9238
9310
|
|
|
9239
9311
|
// Default prefix
|
|
9240
9312
|
var googleApi = "type.googleapis.com/";
|
|
@@ -9250,12 +9322,12 @@ wrappers[".google.protobuf.Any"] = {
|
|
|
9250
9322
|
var type = this.lookup(name);
|
|
9251
9323
|
/* istanbul ignore else */
|
|
9252
9324
|
if (type)
|
|
9253
|
-
message = type.decode(message.value);
|
|
9325
|
+
message = type.decode(message.value, undefined, undefined, depth + 1);
|
|
9254
9326
|
}
|
|
9255
9327
|
|
|
9256
9328
|
// wrap value if unmapped
|
|
9257
9329
|
if (!(message instanceof this.ctor) && message instanceof Message) {
|
|
9258
|
-
var object = message.$type.toObject(message, options);
|
|
9330
|
+
var object = message.$type.toObject(message, options, depth + 1);
|
|
9259
9331
|
var messageName = message.$type.fullName[0] === "." ?
|
|
9260
9332
|
message.$type.fullName.slice(1) : message.$type.fullName;
|
|
9261
9333
|
// Default to type.googleapis.com prefix if no prefix is used
|
|
@@ -9267,11 +9339,11 @@ wrappers[".google.protobuf.Any"] = {
|
|
|
9267
9339
|
return object;
|
|
9268
9340
|
}
|
|
9269
9341
|
|
|
9270
|
-
return this.toObject(message, options);
|
|
9342
|
+
return this.toObject(message, options, depth);
|
|
9271
9343
|
}
|
|
9272
9344
|
};
|
|
9273
9345
|
|
|
9274
|
-
},{"23":23}],46:[function(require,module,exports){
|
|
9346
|
+
},{"23":23,"42":42}],46:[function(require,module,exports){
|
|
9275
9347
|
"use strict";
|
|
9276
9348
|
module.exports = Writer;
|
|
9277
9349
|
|
|
@@ -9499,7 +9571,7 @@ Writer.prototype.uint32 = function write_uint32(value) {
|
|
|
9499
9571
|
* @returns {Writer} `this`
|
|
9500
9572
|
*/
|
|
9501
9573
|
Writer.prototype.int32 = function write_int32(value) {
|
|
9502
|
-
return value < 0
|
|
9574
|
+
return (value |= 0) < 0
|
|
9503
9575
|
? this._push(writeVarint64, 10, LongBits.fromNumber(value)) // 10 bytes per spec
|
|
9504
9576
|
: this.uint32(value);
|
|
9505
9577
|
};
|
|
@@ -9514,16 +9586,18 @@ Writer.prototype.sint32 = function write_sint32(value) {
|
|
|
9514
9586
|
};
|
|
9515
9587
|
|
|
9516
9588
|
function writeVarint64(val, buf, pos) {
|
|
9517
|
-
|
|
9518
|
-
|
|
9519
|
-
|
|
9520
|
-
|
|
9521
|
-
|
|
9522
|
-
|
|
9523
|
-
|
|
9524
|
-
|
|
9525
|
-
|
|
9526
|
-
|
|
9589
|
+
var lo = val.lo,
|
|
9590
|
+
hi = val.hi;
|
|
9591
|
+
while (hi) {
|
|
9592
|
+
buf[pos++] = lo & 127 | 128;
|
|
9593
|
+
lo = (lo >>> 7 | hi << 25) >>> 0;
|
|
9594
|
+
hi >>>= 7;
|
|
9595
|
+
}
|
|
9596
|
+
while (lo > 127) {
|
|
9597
|
+
buf[pos++] = lo & 127 | 128;
|
|
9598
|
+
lo = lo >>> 7;
|
|
9599
|
+
}
|
|
9600
|
+
buf[pos++] = lo;
|
|
9527
9601
|
}
|
|
9528
9602
|
|
|
9529
9603
|
/**
|