protobufjs 8.7.2 → 8.8.0
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 +24 -17
- package/dist/light/protobuf.js +124 -14
- 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 +63 -9
- 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 +133 -18
- 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.generated.d.ts +7 -0
- package/ext/descriptor.js +24 -0
- package/ext/protojson.js +14 -4
- package/ext/textformat.js +8 -4
- package/google/protobuf/descriptor.json +20 -1
- package/google/protobuf/descriptor.proto +14 -1
- package/index.d.ts +12 -0
- package/package.json +1 -1
- package/src/decoder.js +31 -2
- package/src/enum.js +10 -0
- package/src/object.js +5 -2
- package/src/parse.js +9 -4
- package/src/reader.js +61 -7
- package/src/type.js +10 -0
- package/src/wrappers.js +5 -1
package/dist/minimal/protobuf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* protobuf.js v8.
|
|
3
|
-
* compiled
|
|
2
|
+
* protobuf.js v8.8.0 (c) 2016, daniel wirtz
|
|
3
|
+
* compiled thu, 27 aug 2026 00:01:05 utc
|
|
4
4
|
* licensed under the bsd-3-clause license
|
|
5
5
|
* see: https://github.com/dcodeio/protobuf.js for details
|
|
6
6
|
*/
|
|
@@ -171,12 +171,32 @@ Reader.prototype.raw = function read_raw(start, end) {
|
|
|
171
171
|
return this.buf.subarray(start, end);
|
|
172
172
|
};
|
|
173
173
|
|
|
174
|
+
function readVarint32NearEnd(reader) {
|
|
175
|
+
// Safely read up to four bytes of a varint32 near the reader limit
|
|
176
|
+
var value = 0;
|
|
177
|
+
for (var i = 0; i < 4; ++i) {
|
|
178
|
+
if (reader.pos >= reader.len)
|
|
179
|
+
throw indexOutOfRange(reader);
|
|
180
|
+
var b = reader.buf[reader.pos++];
|
|
181
|
+
value = (value | (b & 127) << i * 7) >>> 0;
|
|
182
|
+
if (b < 128)
|
|
183
|
+
return value;
|
|
184
|
+
}
|
|
185
|
+
throw indexOutOfRange(reader);
|
|
186
|
+
}
|
|
187
|
+
|
|
174
188
|
/**
|
|
175
189
|
* Reads a varint as an unsigned 32 bit value.
|
|
176
190
|
* @function
|
|
177
191
|
* @returns {number} Value read
|
|
178
192
|
*/
|
|
179
193
|
Reader.prototype.uint32 = function read_uint32() {
|
|
194
|
+
if (this.len - this.pos < 5) {
|
|
195
|
+
if (this.pos >= this.len)
|
|
196
|
+
throw indexOutOfRange(this);
|
|
197
|
+
if (this.buf[this.pos] >= 128)
|
|
198
|
+
return readVarint32NearEnd(this);
|
|
199
|
+
}
|
|
180
200
|
var buf = this.buf,
|
|
181
201
|
pos = this.pos,
|
|
182
202
|
value = (buf[pos] & 127) >>> 0;
|
|
@@ -227,6 +247,12 @@ Reader.prototype.uint32 = function read_uint32() {
|
|
|
227
247
|
* @returns {number} Tag read
|
|
228
248
|
*/
|
|
229
249
|
Reader.prototype.tag = function read_tag() {
|
|
250
|
+
if (this.len - this.pos < 5) {
|
|
251
|
+
if (this.pos >= this.len)
|
|
252
|
+
throw indexOutOfRange(this);
|
|
253
|
+
if (this.buf[this.pos] >= 128)
|
|
254
|
+
return readVarint32NearEnd(this);
|
|
255
|
+
}
|
|
230
256
|
var buf = this.buf,
|
|
231
257
|
pos = this.pos,
|
|
232
258
|
value = (buf[pos] & 127) >>> 0;
|
|
@@ -472,7 +498,9 @@ Reader.prototype.double = function read_double() {
|
|
|
472
498
|
*/
|
|
473
499
|
Reader.prototype.uint32s = function read_uint32s(array) {
|
|
474
500
|
if (array === undefined) array = [];
|
|
475
|
-
var end = this.uint32() + this.pos, buf = this.buf, pos = this.pos, value;
|
|
501
|
+
var end = this.uint32() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
|
|
502
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
503
|
+
this.len = end;
|
|
476
504
|
while (pos < end) {
|
|
477
505
|
value = buf[pos++];
|
|
478
506
|
if (value < 128)
|
|
@@ -484,6 +512,8 @@ Reader.prototype.uint32s = function read_uint32s(array) {
|
|
|
484
512
|
}
|
|
485
513
|
}
|
|
486
514
|
this.pos = pos;
|
|
515
|
+
if (pos !== end) throw RangeError("index out of range");
|
|
516
|
+
this.len = len;
|
|
487
517
|
return array;
|
|
488
518
|
};
|
|
489
519
|
|
|
@@ -494,7 +524,9 @@ Reader.prototype.uint32s = function read_uint32s(array) {
|
|
|
494
524
|
*/
|
|
495
525
|
Reader.prototype.int32s = function read_int32s(array) {
|
|
496
526
|
if (array === undefined) array = [];
|
|
497
|
-
var end = this.uint32() + this.pos, buf = this.buf, pos = this.pos, value;
|
|
527
|
+
var end = this.uint32() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
|
|
528
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
529
|
+
this.len = end;
|
|
498
530
|
while (pos < end) {
|
|
499
531
|
value = buf[pos++];
|
|
500
532
|
if (value < 128)
|
|
@@ -506,6 +538,8 @@ Reader.prototype.int32s = function read_int32s(array) {
|
|
|
506
538
|
}
|
|
507
539
|
}
|
|
508
540
|
this.pos = pos;
|
|
541
|
+
if (pos !== end) throw RangeError("index out of range");
|
|
542
|
+
this.len = len;
|
|
509
543
|
return array;
|
|
510
544
|
};
|
|
511
545
|
|
|
@@ -516,9 +550,13 @@ Reader.prototype.int32s = function read_int32s(array) {
|
|
|
516
550
|
*/
|
|
517
551
|
Reader.prototype.sint32s = function read_sint32s(array) {
|
|
518
552
|
if (array === undefined) array = [];
|
|
519
|
-
var end = this.uint32() + this.pos;
|
|
553
|
+
var end = this.uint32() + this.pos, len = this.len;
|
|
554
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
555
|
+
this.len = end;
|
|
520
556
|
while (this.pos < end)
|
|
521
557
|
array.push(this.sint32());
|
|
558
|
+
if (this.pos !== end) throw RangeError("index out of range");
|
|
559
|
+
this.len = len;
|
|
522
560
|
return array;
|
|
523
561
|
};
|
|
524
562
|
|
|
@@ -529,7 +567,9 @@ Reader.prototype.sint32s = function read_sint32s(array) {
|
|
|
529
567
|
*/
|
|
530
568
|
Reader.prototype.bools = function read_bools(array) {
|
|
531
569
|
if (array === undefined) array = [];
|
|
532
|
-
var end = this.uint32() + this.pos, buf = this.buf, pos = this.pos, value;
|
|
570
|
+
var end = this.uint32() + this.pos, len = this.len, buf = this.buf, pos = this.pos, value;
|
|
571
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
572
|
+
this.len = end;
|
|
533
573
|
while (pos < end) {
|
|
534
574
|
value = buf[pos++];
|
|
535
575
|
if (value < 128)
|
|
@@ -541,6 +581,8 @@ Reader.prototype.bools = function read_bools(array) {
|
|
|
541
581
|
}
|
|
542
582
|
}
|
|
543
583
|
this.pos = pos;
|
|
584
|
+
if (pos !== end) throw RangeError("index out of range");
|
|
585
|
+
this.len = len;
|
|
544
586
|
return array;
|
|
545
587
|
};
|
|
546
588
|
|
|
@@ -659,9 +701,13 @@ Reader.prototype.doubles = function read_doubles(array) {
|
|
|
659
701
|
*/
|
|
660
702
|
Reader.prototype.uint64s = function read_uint64s(array) {
|
|
661
703
|
if (array === undefined) array = [];
|
|
662
|
-
var end = this.uint32() + this.pos;
|
|
704
|
+
var end = this.uint32() + this.pos, len = this.len;
|
|
705
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
706
|
+
this.len = end;
|
|
663
707
|
while (this.pos < end)
|
|
664
708
|
array.push(this.uint64());
|
|
709
|
+
if (this.pos !== end) throw RangeError("index out of range");
|
|
710
|
+
this.len = len;
|
|
665
711
|
return array;
|
|
666
712
|
};
|
|
667
713
|
|
|
@@ -672,9 +718,13 @@ Reader.prototype.uint64s = function read_uint64s(array) {
|
|
|
672
718
|
*/
|
|
673
719
|
Reader.prototype.int64s = function read_int64s(array) {
|
|
674
720
|
if (array === undefined) array = [];
|
|
675
|
-
var end = this.uint32() + this.pos;
|
|
721
|
+
var end = this.uint32() + this.pos, len = this.len;
|
|
722
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
723
|
+
this.len = end;
|
|
676
724
|
while (this.pos < end)
|
|
677
725
|
array.push(this.int64());
|
|
726
|
+
if (this.pos !== end) throw RangeError("index out of range");
|
|
727
|
+
this.len = len;
|
|
678
728
|
return array;
|
|
679
729
|
};
|
|
680
730
|
|
|
@@ -685,9 +735,13 @@ Reader.prototype.int64s = function read_int64s(array) {
|
|
|
685
735
|
*/
|
|
686
736
|
Reader.prototype.sint64s = function read_sint64s(array) {
|
|
687
737
|
if (array === undefined) array = [];
|
|
688
|
-
var end = this.uint32() + this.pos;
|
|
738
|
+
var end = this.uint32() + this.pos, len = this.len;
|
|
739
|
+
if (end > len) throw indexOutOfRange(this, end - this.pos);
|
|
740
|
+
this.len = end;
|
|
689
741
|
while (this.pos < end)
|
|
690
742
|
array.push(this.sint64());
|
|
743
|
+
if (this.pos !== end) throw RangeError("index out of range");
|
|
744
|
+
this.len = len;
|
|
691
745
|
return array;
|
|
692
746
|
};
|
|
693
747
|
|