@baileys-md/baileys 12.0.0 → 12.2.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.
Files changed (109) hide show
  1. package/LICENSE +21 -13
  2. package/WAProto/WAProto.proto +769 -233
  3. package/WAProto/index.js +65813 -141372
  4. package/lib/Defaults/index.js +128 -113
  5. package/lib/KeyDB/BinarySearch.js +30 -0
  6. package/lib/KeyDB/KeyedDB.js +178 -0
  7. package/lib/KeyDB/index.js +14 -0
  8. package/lib/Signal/Group/ciphertext-message.js +22 -14
  9. package/lib/Signal/Group/group-session-builder.js +21 -42
  10. package/lib/Signal/Group/group_cipher.js +85 -87
  11. package/lib/Signal/Group/index.js +23 -57
  12. package/lib/Signal/Group/keyhelper.js +28 -52
  13. package/lib/Signal/Group/sender-chain-key.js +37 -33
  14. package/lib/Signal/Group/sender-key-distribution-message.js +73 -63
  15. package/lib/Signal/Group/sender-key-message.js +75 -66
  16. package/lib/Signal/Group/sender-key-name.js +55 -44
  17. package/lib/Signal/Group/sender-key-record.js +49 -49
  18. package/lib/Signal/Group/sender-key-state.js +90 -93
  19. package/lib/Signal/Group/sender-message-key.js +37 -28
  20. package/lib/Signal/libsignal.js +324 -163
  21. package/lib/Signal/lid-mapping.js +166 -0
  22. package/lib/Socket/Client/index.js +14 -18
  23. package/lib/Socket/Client/types.js +12 -12
  24. package/lib/Socket/Client/websocket.js +60 -109
  25. package/lib/Socket/business.js +359 -242
  26. package/lib/Socket/chats.js +857 -898
  27. package/lib/Socket/communities.js +413 -0
  28. package/lib/Socket/groups.js +304 -324
  29. package/lib/Socket/index.js +25 -9
  30. package/lib/Socket/messages-recv.js +1109 -1000
  31. package/lib/Socket/messages-send.js +615 -387
  32. package/lib/Socket/mex.js +45 -0
  33. package/lib/Socket/newsletter.js +231 -227
  34. package/lib/Socket/socket.js +803 -628
  35. package/lib/Store/index.js +18 -8
  36. package/lib/Store/make-cache-manager-store.js +75 -0
  37. package/lib/Store/make-in-memory-store.js +286 -435
  38. package/lib/Store/make-ordered-dictionary.js +77 -79
  39. package/lib/Store/object-repository.js +24 -26
  40. package/lib/Types/Auth.js +13 -2
  41. package/lib/Types/Bussines.js +13 -0
  42. package/lib/Types/Call.js +13 -2
  43. package/lib/Types/Chat.js +19 -4
  44. package/lib/Types/Contact.js +13 -2
  45. package/lib/Types/Events.js +13 -2
  46. package/lib/Types/GroupMetadata.js +13 -2
  47. package/lib/Types/Label.js +43 -26
  48. package/lib/Types/LabelAssociation.js +16 -8
  49. package/lib/Types/Message.js +22 -7
  50. package/lib/Types/Newsletter.js +42 -17
  51. package/lib/Types/Product.js +13 -2
  52. package/lib/Types/Signal.js +13 -2
  53. package/lib/Types/Socket.js +14 -2
  54. package/lib/Types/State.js +21 -2
  55. package/lib/Types/USync.js +13 -2
  56. package/lib/Types/index.js +37 -41
  57. package/lib/Utils/auth-utils.js +219 -189
  58. package/lib/Utils/baileys-event-stream.js +54 -0
  59. package/lib/Utils/browser-utils.js +21 -31
  60. package/lib/Utils/business.js +213 -214
  61. package/lib/Utils/chat-utils.js +711 -689
  62. package/lib/Utils/crypto.js +112 -175
  63. package/lib/Utils/decode-wa-message.js +254 -194
  64. package/lib/Utils/event-buffer.js +510 -500
  65. package/lib/Utils/generics.js +318 -430
  66. package/lib/Utils/history.js +83 -90
  67. package/lib/Utils/index.js +31 -35
  68. package/lib/Utils/link-preview.js +71 -116
  69. package/lib/Utils/logger.js +5 -7
  70. package/lib/Utils/lt-hash.js +40 -46
  71. package/lib/Utils/make-mutex.js +34 -41
  72. package/lib/Utils/message-retry-manager.js +33 -48
  73. package/lib/Utils/messages-media.js +516 -784
  74. package/lib/Utils/messages.js +347 -489
  75. package/lib/Utils/noise-handler.js +138 -144
  76. package/lib/Utils/pre-key-manager.js +95 -0
  77. package/lib/Utils/process-message.js +331 -384
  78. package/lib/Utils/signal.js +157 -139
  79. package/lib/Utils/use-multi-file-auth-state.js +119 -91
  80. package/lib/Utils/validate-connection.js +184 -203
  81. package/lib/WABinary/constants.js +1308 -1298
  82. package/lib/WABinary/decode.js +241 -256
  83. package/lib/WABinary/encode.js +217 -239
  84. package/lib/WABinary/generic-utils.js +131 -40
  85. package/lib/WABinary/index.js +17 -21
  86. package/lib/WABinary/jid-utils.js +97 -79
  87. package/lib/WABinary/types.js +13 -2
  88. package/lib/WAM/BinaryInfo.js +20 -12
  89. package/lib/WAM/constants.js +22863 -15348
  90. package/lib/WAM/encode.js +145 -136
  91. package/lib/WAM/index.js +15 -19
  92. package/lib/WAUSync/Protocols/USyncContactProtocol.js +39 -31
  93. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +61 -54
  94. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +39 -29
  95. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +48 -40
  96. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +62 -51
  97. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +38 -21
  98. package/lib/WAUSync/Protocols/index.js +17 -20
  99. package/lib/WAUSync/USyncQuery.js +98 -86
  100. package/lib/WAUSync/USyncUser.js +35 -26
  101. package/lib/WAUSync/index.js +16 -19
  102. package/lib/index.js +23 -41
  103. package/package.json +46 -56
  104. package/README.md +0 -113
  105. package/WAProto/GenerateStatics.sh +0 -4
  106. package/lib/Defaults/wileys-version.json +0 -3
  107. package/lib/Signal/Group/queue-job.js +0 -57
  108. package/lib/Socket/usync.js +0 -70
  109. package/lib/Utils/wileys-event-stream.js +0 -63
@@ -1,250 +1,228 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.encodeBinaryNode = void 0;
37
- const constants = __importStar(require("./constants"));
38
- const jid_utils_1 = require("./jid-utils");
39
- const encodeBinaryNode = (node, opts = constants, buffer = [0]) => {
40
- const encoded = encodeBinaryNodeInner(node, opts, buffer);
41
- return Buffer.from(encoded);
1
+ //========================================//
2
+ /**
3
+ * @project @sixcore/baileys
4
+ * @author Sixx.js </>🌿
5
+ * @version 1.0.3
6
+ * @license MIT
7
+ * @country Mozambique 🇲🇿♥️
8
+ * @chamadas || sms +258860817689
9
+ * @whatsApp +55889616-2417 || +258851907875
10
+ * @description Biblioteca Node.js para integração e automação no WhatsApp usando Baileys
11
+ */
12
+
13
+ import * as constants from "./constants.js";
14
+ import { jidDecode } from "./jid-utils.js";
15
+
16
+ export const encodeBinaryNode = (node, opts = constants, buffer = [0]) => {
17
+ const encoded = encodeBinaryNodeInner(node, opts, buffer);
18
+ return Buffer.from(encoded);
42
19
  };
43
- exports.encodeBinaryNode = encodeBinaryNode;
20
+
44
21
  const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
45
- const { TAGS, TOKEN_MAP } = opts;
46
- const pushByte = (value) => buffer.push(value & 0xff);
47
- const pushInt = (value, n, littleEndian = false) => {
48
- for (let i = 0; i < n; i++) {
49
- const curShift = littleEndian ? i : n - 1 - i;
50
- buffer.push((value >> (curShift * 8)) & 0xff);
51
- }
52
- };
53
- const pushBytes = (bytes) => (bytes.forEach(b => buffer.push(b)));
54
- const pushInt16 = (value) => {
55
- pushBytes([(value >> 8) & 0xff, value & 0xff]);
56
- };
57
- const pushInt20 = (value) => (pushBytes([(value >> 16) & 0x0f, (value >> 8) & 0xff, value & 0xff]));
58
- const writeByteLength = (length) => {
59
- if (length >= 4294967296) {
60
- throw new Error('string too large to encode: ' + length);
61
- }
62
- if (length >= 1 << 20) {
63
- pushByte(TAGS.BINARY_32);
64
- pushInt(length, 4); // 32 bit integer
65
- }
66
- else if (length >= 256) {
67
- pushByte(TAGS.BINARY_20);
68
- pushInt20(length);
69
- }
70
- else {
71
- pushByte(TAGS.BINARY_8);
72
- pushByte(length);
73
- }
74
- };
75
- const writeStringRaw = (str) => {
76
- const bytes = Buffer.from(str, 'utf-8');
77
- writeByteLength(bytes.length);
78
- pushBytes(bytes);
79
- };
80
- const writeJid = ({ domainType, device, user, server }) => {
81
- if (typeof device !== 'undefined') {
82
- pushByte(TAGS.AD_JID);
83
- pushByte(domainType || 0);
84
- pushByte(device || 0);
85
- writeString(user);
86
- }
87
- else {
88
- pushByte(TAGS.JID_PAIR);
89
- if (user.length) {
90
- writeString(user);
91
- }
92
- else {
93
- pushByte(TAGS.LIST_EMPTY);
94
- }
95
- writeString(server);
96
- }
97
- };
98
- const packNibble = (char) => {
99
- switch (char) {
100
- case '-':
101
- return 10;
102
- case '.':
103
- return 11;
104
- case '\0':
105
- return 15;
106
- default:
107
- if (char >= '0' && char <= '9') {
108
- return char.charCodeAt(0) - '0'.charCodeAt(0);
109
- }
110
- throw new Error(`invalid byte for nibble "${char}"`);
111
- }
112
- };
113
- const packHex = (char) => {
114
- if (char >= '0' && char <= '9') {
115
- return char.charCodeAt(0) - '0'.charCodeAt(0);
116
- }
117
- if (char >= 'A' && char <= 'F') {
118
- return 10 + char.charCodeAt(0) - 'A'.charCodeAt(0);
119
- }
120
- if (char >= 'a' && char <= 'f') {
121
- return 10 + char.charCodeAt(0) - 'a'.charCodeAt(0);
122
- }
123
- if (char === '\0') {
124
- return 15;
125
- }
126
- throw new Error(`Invalid hex char "${char}"`);
127
- };
128
- const writePackedBytes = (str, type) => {
129
- if (str.length > TAGS.PACKED_MAX) {
130
- throw new Error('Too many bytes to pack');
131
- }
132
- pushByte(type === 'nibble' ? TAGS.NIBBLE_8 : TAGS.HEX_8);
133
- let roundedLength = Math.ceil(str.length / 2.0);
134
- if (str.length % 2 !== 0) {
135
- roundedLength |= 128;
136
- }
137
- pushByte(roundedLength);
138
- const packFunction = type === 'nibble' ? packNibble : packHex;
139
- const packBytePair = (v1, v2) => {
140
- const result = (packFunction(v1) << 4) | packFunction(v2);
141
- return result;
142
- };
143
- const strLengthHalf = Math.floor(str.length / 2);
144
- for (let i = 0; i < strLengthHalf; i++) {
145
- pushByte(packBytePair(str[2 * i], str[2 * i + 1]));
146
- }
147
- if (str.length % 2 !== 0) {
148
- pushByte(packBytePair(str[str.length - 1], '\x00'));
149
- }
150
- };
151
- const isNibble = (str) => {
152
- if (!str || str.length > TAGS.PACKED_MAX) {
153
- return false;
154
- }
155
- for (let i = 0; i < str.length; i++) {
156
- const char = str[i];
157
- const isInNibbleRange = char >= '0' && char <= '9';
158
- if (!isInNibbleRange && char !== '-' && char !== '.') {
159
- return false;
160
- }
161
- }
162
- return true;
163
- };
164
- const isHex = (str) => {
165
- if (!str || str.length > TAGS.PACKED_MAX) {
166
- return false;
167
- }
168
- for (let i = 0; i < str.length; i++) {
169
- const char = str[i];
170
- const isInNibbleRange = char >= '0' && char <= '9';
171
- if (!isInNibbleRange && !(char >= 'A' && char <= 'F')) {
172
- return false;
173
- }
174
- }
175
- return true;
176
- };
177
- const writeString = (str) => {
178
- if (str === undefined || str === null) {
179
- pushByte(TAGS.LIST_EMPTY);
180
- return;
181
- }
182
- const tokenIndex = TOKEN_MAP[str];
183
- if (tokenIndex) {
184
- if (typeof tokenIndex.dict === 'number') {
185
- pushByte(TAGS.DICTIONARY_0 + tokenIndex.dict);
186
- }
187
- pushByte(tokenIndex.index);
188
- }
189
- else if (isNibble(str)) {
190
- writePackedBytes(str, 'nibble');
191
- }
192
- else if (isHex(str)) {
193
- writePackedBytes(str, 'hex');
194
- }
195
- else if (str) {
196
- const decodedJid = (0, jid_utils_1.jidDecode)(str);
197
- if (decodedJid) {
198
- writeJid(decodedJid);
199
- }
200
- else {
201
- writeStringRaw(str);
202
- }
203
- }
204
- };
205
- const writeListStart = (listSize) => {
206
- if (listSize === 0) {
207
- pushByte(TAGS.LIST_EMPTY);
208
- }
209
- else if (listSize < 256) {
210
- pushBytes([TAGS.LIST_8, listSize]);
211
- }
212
- else {
213
- pushByte(TAGS.LIST_16);
214
- pushInt16(listSize);
215
- }
22
+ const { TAGS, TOKEN_MAP } = opts;
23
+ const pushByte = (value) => buffer.push(value & 0xff);
24
+ const pushInt = (value, n, littleEndian = false) => {
25
+ for (let i = 0; i < n; i++) {
26
+ const curShift = littleEndian ? i : n - 1 - i;
27
+ buffer.push((value >> (curShift * 8)) & 0xff);
28
+ }
29
+ };
30
+ const pushBytes = (bytes) => {
31
+ for (const b of bytes) {
32
+ buffer.push(b);
33
+ }
34
+ };
35
+ const pushInt16 = (value) => {
36
+ pushBytes([(value >> 8) & 0xff, value & 0xff]);
37
+ };
38
+ const pushInt20 = (value) => pushBytes([(value >> 16) & 0x0f, (value >> 8) & 0xff, value & 0xff]);
39
+ const writeByteLength = (length) => {
40
+ if (length >= 4294967296) {
41
+ throw new Error("string muito grande para codificar: " + length);
42
+ }
43
+ if (length >= 1 << 20) {
44
+ pushByte(TAGS.BINARY_32);
45
+ pushInt(length, 4);
46
+ }
47
+ else if (length >= 256) {
48
+ pushByte(TAGS.BINARY_20);
49
+ pushInt20(length);
50
+ }
51
+ else {
52
+ pushByte(TAGS.BINARY_8);
53
+ pushByte(length);
54
+ }
55
+ };
56
+ const writeStringRaw = (str) => {
57
+ const bytes = Buffer.from(str, "utf-8");
58
+ writeByteLength(bytes.length);
59
+ pushBytes(bytes);
60
+ };
61
+ const writeJid = ({ domainType, device, user, server }) => {
62
+ if (typeof device !== "undefined") {
63
+ pushByte(TAGS.AD_JID);
64
+ pushByte(domainType || 0);
65
+ pushByte(device || 0);
66
+ writeString(user);
67
+ }
68
+ else {
69
+ pushByte(TAGS.JID_PAIR);
70
+ if (user.length) {
71
+ writeString(user);
72
+ }
73
+ else {
74
+ pushByte(TAGS.LIST_EMPTY);
75
+ }
76
+ writeString(server);
77
+ }
78
+ };
79
+ const packNibble = (char) => {
80
+ switch (char) {
81
+ case "-":
82
+ return 10;
83
+ case ".":
84
+ return 11;
85
+ case "\0":
86
+ return 15;
87
+ default:
88
+ if (char >= "0" && char <= "9") {
89
+ return char.charCodeAt(0) - "0".charCodeAt(0);
90
+ }
91
+ throw new Error(`byte inválido para mordidela "${char}"`);
92
+ }
93
+ };
94
+ const packHex = (char) => {
95
+ if (char >= "0" && char <= "9") {
96
+ return char.charCodeAt(0) - "0".charCodeAt(0);
97
+ }
98
+ if (char >= "A" && char <= "F") {
99
+ return 10 + char.charCodeAt(0) - "A".charCodeAt(0);
100
+ }
101
+ if (char >= "a" && char <= "f") {
102
+ return 10 + char.charCodeAt(0) - "a".charCodeAt(0);
103
+ }
104
+ if (char === "\0") {
105
+ return 15;
106
+ }
107
+ throw new Error(`Caractere hexadecimal inválido "${char}"`);
108
+ };
109
+ const writePackedBytes = (str, type) => {
110
+ if (str.length > TAGS.PACKED_MAX) {
111
+ throw new Error("Muitos bytes para empacotar");
112
+ }
113
+ pushByte(type === "nibble" ? TAGS.NIBBLE_8 : TAGS.HEX_8);
114
+ let roundedLength = Math.ceil(str.length / 2.0);
115
+ if (str.length % 2 !== 0) {
116
+ roundedLength |= 128;
117
+ }
118
+ pushByte(roundedLength);
119
+ const packFunction = type === "nibble" ? packNibble : packHex;
120
+ const packBytePair = (v1, v2) => {
121
+ const result = (packFunction(v1) << 4) | packFunction(v2);
122
+ return result;
216
123
  };
217
- if (!tag) {
218
- throw new Error('Invalid node: tag cannot be undefined');
219
- }
220
- const validAttributes = Object.keys(attrs || {}).filter(k => (typeof attrs[k] !== 'undefined' && attrs[k] !== null));
221
- writeListStart(2 * validAttributes.length + 1 + (typeof content !== 'undefined' ? 1 : 0));
222
- writeString(tag);
223
- for (const key of validAttributes) {
224
- if (typeof attrs[key] === 'string') {
225
- writeString(key);
226
- writeString(attrs[key]);
227
- }
124
+ const strLengthHalf = Math.floor(str.length / 2);
125
+ for (let i = 0; i < strLengthHalf; i++) {
126
+ pushByte(packBytePair(str[2 * i], str[2 * i + 1]));
228
127
  }
229
- if (typeof content === 'string') {
230
- writeString(content);
128
+ if (str.length % 2 !== 0) {
129
+ pushByte(packBytePair(str[str.length - 1], "\x00"));
231
130
  }
232
- else if (Buffer.isBuffer(content) || content instanceof Uint8Array) {
233
- writeByteLength(content.length);
234
- pushBytes(content);
131
+ };
132
+ const isNibble = (str) => {
133
+ if (!str || str.length > TAGS.PACKED_MAX) {
134
+ return false;
235
135
  }
236
- else if (Array.isArray(content)) {
237
- const validContent = content.filter(item => item && (item.tag || Buffer.isBuffer(item) || item instanceof Uint8Array || typeof item === 'string'));
238
- writeListStart(validContent.length);
239
- for (const item of validContent) {
240
- encodeBinaryNodeInner(item, opts, buffer);
241
- }
136
+ for (const char of str) {
137
+ const isInNibbleRange = char >= "0" && char <= "9";
138
+ if (!isInNibbleRange && char !== "-" && char !== ".") {
139
+ return false;
140
+ }
141
+ }
142
+ return true;
143
+ };
144
+ const isHex = (str) => {
145
+ if (!str || str.length > TAGS.PACKED_MAX) {
146
+ return false;
147
+ }
148
+ for (const char of str) {
149
+ const isInNibbleRange = char >= "0" && char <= "9";
150
+ if (!isInNibbleRange && !(char >= "A" && char <= "F")) {
151
+ return false;
152
+ }
242
153
  }
243
- else if (typeof content === 'undefined') {
244
- // do nothing
154
+ return true;
155
+ };
156
+ const writeString = (str) => {
157
+ if (str === undefined || str === null) {
158
+ pushByte(TAGS.LIST_EMPTY);
159
+ return;
160
+ }
161
+ const tokenIndex = TOKEN_MAP[str];
162
+ if (tokenIndex) {
163
+ if (typeof tokenIndex.dict === "number") {
164
+ pushByte(TAGS.DICTIONARY_0 + tokenIndex.dict);
165
+ }
166
+ pushByte(tokenIndex.index);
167
+ }
168
+ else if (isNibble(str)) {
169
+ writePackedBytes(str, "nibble");
170
+ }
171
+ else if (isHex(str)) {
172
+ writePackedBytes(str, "hex");
173
+ }
174
+ else if (str) {
175
+ const decodedJid = jidDecode(str);
176
+ if (decodedJid) {
177
+ writeJid(decodedJid);
178
+ }
179
+ else {
180
+ writeStringRaw(str);
181
+ }
182
+ }
183
+ };
184
+ const writeListStart = (listSize) => {
185
+ if (listSize === 0) {
186
+ pushByte(TAGS.LIST_EMPTY);
187
+ }
188
+ else if (listSize < 256) {
189
+ pushBytes([TAGS.LIST_8, listSize]);
245
190
  }
246
191
  else {
247
- throw new Error(`invalid children for header "${tag}": ${content} (${typeof content})`);
192
+ pushByte(TAGS.LIST_16);
193
+ pushInt16(listSize);
194
+ }
195
+ };
196
+ if (!tag) {
197
+ throw new Error("Nó inválido: a tag não pode ser indefinida");
198
+ }
199
+ const validAttributes = Object.keys(attrs || {}).filter(k => typeof attrs[k] !== "undefined" && attrs[k] !== null);
200
+ writeListStart(2 * validAttributes.length + 1 + (typeof content !== "undefined" ? 1 : 0));
201
+ writeString(tag);
202
+ for (const key of validAttributes) {
203
+ if (typeof attrs[key] === "string") {
204
+ writeString(key);
205
+ writeString(attrs[key]);
206
+ }
207
+ }
208
+ if (typeof content === "string") {
209
+ writeString(content);
210
+ }
211
+ else if (Buffer.isBuffer(content) || content instanceof Uint8Array) {
212
+ writeByteLength(content.length);
213
+ pushBytes(content);
214
+ }
215
+ else if (Array.isArray(content)) {
216
+ const validContent = content.filter(item => item && (item.tag || Buffer.isBuffer(item) || item instanceof Uint8Array || typeof item === "string"));
217
+ writeListStart(validContent.length);
218
+ for (const item of validContent) {
219
+ encodeBinaryNodeInner(item, opts, buffer);
248
220
  }
249
- return buffer;
221
+ }
222
+ else if (typeof content === "undefined") {
223
+ }
224
+ else {
225
+ throw new Error(`filhos inválidos para cabeçalho "${tag}": ${content} (${typeof content})`);
226
+ }
227
+ return buffer;
250
228
  };