@everymatrix/nuts-inbox-widget 1.94.69 → 1.94.71
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.
|
@@ -2389,7 +2389,7 @@ function deconstructPacket(packet) {
|
|
|
2389
2389
|
pack.attachments = buffers.length; // number of binary 'attachments'
|
|
2390
2390
|
return { packet: pack, buffers: buffers };
|
|
2391
2391
|
}
|
|
2392
|
-
function _deconstructPacket(data, buffers) {
|
|
2392
|
+
function _deconstructPacket(data, buffers, toJSON) {
|
|
2393
2393
|
if (!data)
|
|
2394
2394
|
return data;
|
|
2395
2395
|
if (isBinary(data)) {
|
|
@@ -2405,6 +2405,9 @@ function _deconstructPacket(data, buffers) {
|
|
|
2405
2405
|
return newData;
|
|
2406
2406
|
}
|
|
2407
2407
|
else if (typeof data === "object" && !(data instanceof Date)) {
|
|
2408
|
+
if (data.toJSON && typeof data.toJSON === "function" && !toJSON) {
|
|
2409
|
+
return _deconstructPacket(data.toJSON(), buffers, true);
|
|
2410
|
+
}
|
|
2408
2411
|
const newData = {};
|
|
2409
2412
|
for (const key in data) {
|
|
2410
2413
|
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
@@ -2589,10 +2592,6 @@ class Decoder extends Emitter {
|
|
|
2589
2592
|
packet.type = isBinaryEvent ? PacketType.EVENT : PacketType.ACK;
|
|
2590
2593
|
// binary packet's json
|
|
2591
2594
|
this.reconstructor = new BinaryReconstructor(packet);
|
|
2592
|
-
// no attachments, labeled binary but no binary data to follow
|
|
2593
|
-
if (packet.attachments === 0) {
|
|
2594
|
-
super.emitReserved("decoded", packet);
|
|
2595
|
-
}
|
|
2596
2595
|
}
|
|
2597
2596
|
else {
|
|
2598
2597
|
// non-binary full packet
|
|
@@ -2642,7 +2641,7 @@ class Decoder extends Emitter {
|
|
|
2642
2641
|
throw new Error("Illegal attachments");
|
|
2643
2642
|
}
|
|
2644
2643
|
const n = Number(buf);
|
|
2645
|
-
if (!isInteger(n) || n <
|
|
2644
|
+
if (!isInteger(n) || n < 1) {
|
|
2646
2645
|
throw new Error("Illegal attachments");
|
|
2647
2646
|
}
|
|
2648
2647
|
else if (n > this.opts.maxAttachments) {
|
|
@@ -2385,7 +2385,7 @@ function deconstructPacket(packet) {
|
|
|
2385
2385
|
pack.attachments = buffers.length; // number of binary 'attachments'
|
|
2386
2386
|
return { packet: pack, buffers: buffers };
|
|
2387
2387
|
}
|
|
2388
|
-
function _deconstructPacket(data, buffers) {
|
|
2388
|
+
function _deconstructPacket(data, buffers, toJSON) {
|
|
2389
2389
|
if (!data)
|
|
2390
2390
|
return data;
|
|
2391
2391
|
if (isBinary(data)) {
|
|
@@ -2401,6 +2401,9 @@ function _deconstructPacket(data, buffers) {
|
|
|
2401
2401
|
return newData;
|
|
2402
2402
|
}
|
|
2403
2403
|
else if (typeof data === "object" && !(data instanceof Date)) {
|
|
2404
|
+
if (data.toJSON && typeof data.toJSON === "function" && !toJSON) {
|
|
2405
|
+
return _deconstructPacket(data.toJSON(), buffers, true);
|
|
2406
|
+
}
|
|
2404
2407
|
const newData = {};
|
|
2405
2408
|
for (const key in data) {
|
|
2406
2409
|
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
@@ -2585,10 +2588,6 @@ class Decoder extends Emitter {
|
|
|
2585
2588
|
packet.type = isBinaryEvent ? PacketType.EVENT : PacketType.ACK;
|
|
2586
2589
|
// binary packet's json
|
|
2587
2590
|
this.reconstructor = new BinaryReconstructor(packet);
|
|
2588
|
-
// no attachments, labeled binary but no binary data to follow
|
|
2589
|
-
if (packet.attachments === 0) {
|
|
2590
|
-
super.emitReserved("decoded", packet);
|
|
2591
|
-
}
|
|
2592
2591
|
}
|
|
2593
2592
|
else {
|
|
2594
2593
|
// non-binary full packet
|
|
@@ -2638,7 +2637,7 @@ class Decoder extends Emitter {
|
|
|
2638
2637
|
throw new Error("Illegal attachments");
|
|
2639
2638
|
}
|
|
2640
2639
|
const n = Number(buf);
|
|
2641
|
-
if (!isInteger(n) || n <
|
|
2640
|
+
if (!isInteger(n) || n < 1) {
|
|
2642
2641
|
throw new Error("Illegal attachments");
|
|
2643
2642
|
}
|
|
2644
2643
|
else if (n > this.opts.maxAttachments) {
|