@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,265 +1,250 @@
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]; } };
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 { jidEncode, WAJIDDomains } from "./jid-utils.js";
14
+ import * as constants from "./constants.js";
15
+ import { promisify } from "util";
16
+ import { inflate } from "zlib";
17
+
18
+ const inflatePromise = promisify(inflate);
19
+ export const decompressingIfRequired = async (buffer) => {
20
+ if (2 & buffer.readUInt8()) {
21
+ buffer = await inflatePromise(buffer.slice(1));
22
+ }
23
+ else {
24
+ buffer = buffer.slice(1);
25
+ }
26
+ return buffer;
27
+ };
28
+
29
+ export const decodeDecompressedBinaryNode = (buffer, opts, indexRef = { index: 0 }) => {
30
+ const { DOUBLE_BYTE_TOKENS, SINGLE_BYTE_TOKENS, TAGS } = opts;
31
+ const checkEOS = (length) => {
32
+ if (indexRef.index + length > buffer.length) {
33
+ throw new Error("fim do fluxo");
7
34
  }
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.decodeBinaryNode = exports.decodeDecompressedBinaryNode = exports.decompressingIfRequired = void 0;
37
- const util_1 = require("util");
38
- const zlib_1 = require("zlib");
39
- const constants = __importStar(require("./constants"));
40
- const jid_utils_1 = require("./jid-utils");
41
- const inflatePromise = (0, util_1.promisify)(zlib_1.inflate);
42
- const decompressingIfRequired = async (buffer) => {
43
- if (2 & buffer.readUInt8()) {
44
- buffer = await inflatePromise(buffer.slice(1));
35
+ };
36
+ const next = () => {
37
+ const value = buffer[indexRef.index];
38
+ indexRef.index += 1;
39
+ return value;
40
+ };
41
+ const readByte = () => {
42
+ checkEOS(1);
43
+ return next();
44
+ };
45
+ const readBytes = (n) => {
46
+ checkEOS(n);
47
+ const value = buffer.slice(indexRef.index, indexRef.index + n);
48
+ indexRef.index += n;
49
+ return value;
50
+ };
51
+ const readStringFromChars = (length) => {
52
+ return readBytes(length).toString("utf-8");
53
+ };
54
+ const readInt = (n, littleEndian = false) => {
55
+ checkEOS(n);
56
+ let val = 0;
57
+ for (let i = 0; i < n; i++) {
58
+ const shift = littleEndian ? i : n - 1 - i;
59
+ val |= next() << (shift * 8);
45
60
  }
46
- else { // nodes with no compression have a 0x00 prefix, we remove that
47
- buffer = buffer.slice(1);
61
+ return val;
62
+ };
63
+ const readInt20 = () => {
64
+ checkEOS(3);
65
+ return ((next() & 15) << 16) + (next() << 8) + next();
66
+ };
67
+ const unpackHex = (value) => {
68
+ if (value >= 0 && value < 16) {
69
+ return value < 10 ? "0".charCodeAt(0) + value : "A".charCodeAt(0) + value - 10;
48
70
  }
49
- return buffer;
50
- };
51
- exports.decompressingIfRequired = decompressingIfRequired;
52
- const decodeDecompressedBinaryNode = (buffer, opts, indexRef = { index: 0 }) => {
53
- const { DOUBLE_BYTE_TOKENS, SINGLE_BYTE_TOKENS, TAGS } = opts;
54
- const checkEOS = (length) => {
55
- if (indexRef.index + length > buffer.length) {
56
- throw new Error('end of stream');
57
- }
58
- };
59
- const next = () => {
60
- const value = buffer[indexRef.index];
61
- indexRef.index += 1;
62
- return value;
63
- };
64
- const readByte = () => {
65
- checkEOS(1);
66
- return next();
67
- };
68
- const readBytes = (n) => {
69
- checkEOS(n);
70
- const value = buffer.slice(indexRef.index, indexRef.index + n);
71
- indexRef.index += n;
72
- return value;
73
- };
74
- const readStringFromChars = (length) => {
75
- return readBytes(length).toString('utf-8');
76
- };
77
- const readInt = (n, littleEndian = false) => {
78
- checkEOS(n);
79
- let val = 0;
80
- for (let i = 0; i < n; i++) {
81
- const shift = littleEndian ? i : n - 1 - i;
82
- val |= next() << (shift * 8);
83
- }
84
- return val;
85
- };
86
- const readInt20 = () => {
87
- checkEOS(3);
88
- return ((next() & 15) << 16) + (next() << 8) + next();
89
- };
90
- const unpackHex = (value) => {
91
- if (value >= 0 && value < 16) {
92
- return value < 10 ? '0'.charCodeAt(0) + value : 'A'.charCodeAt(0) + value - 10;
93
- }
94
- throw new Error('invalid hex: ' + value);
95
- };
96
- const unpackNibble = (value) => {
97
- if (value >= 0 && value <= 9) {
98
- return '0'.charCodeAt(0) + value;
99
- }
100
- switch (value) {
101
- case 10:
102
- return '-'.charCodeAt(0);
103
- case 11:
104
- return '.'.charCodeAt(0);
105
- case 15:
106
- return '\0'.charCodeAt(0);
107
- default:
108
- throw new Error('invalid nibble: ' + value);
109
- }
110
- };
111
- const unpackByte = (tag, value) => {
112
- if (tag === TAGS.NIBBLE_8) {
113
- return unpackNibble(value);
114
- }
115
- else if (tag === TAGS.HEX_8) {
116
- return unpackHex(value);
117
- }
118
- else {
119
- throw new Error('unknown tag: ' + tag);
120
- }
121
- };
122
- const readPacked8 = (tag) => {
123
- const startByte = readByte();
124
- let value = '';
125
- for (let i = 0; i < (startByte & 127); i++) {
126
- const curByte = readByte();
127
- value += String.fromCharCode(unpackByte(tag, (curByte & 0xf0) >> 4));
128
- value += String.fromCharCode(unpackByte(tag, curByte & 0x0f));
129
- }
130
- if (startByte >> 7 !== 0) {
131
- value = value.slice(0, -1);
132
- }
133
- return value;
134
- };
135
- const isListTag = (tag) => {
136
- return tag === TAGS.LIST_EMPTY || tag === TAGS.LIST_8 || tag === TAGS.LIST_16;
137
- };
138
- const readListSize = (tag) => {
139
- switch (tag) {
140
- case TAGS.LIST_EMPTY:
141
- return 0;
142
- case TAGS.LIST_8:
143
- return readByte();
144
- case TAGS.LIST_16:
145
- return readInt(2);
146
- default:
147
- throw new Error('invalid tag for list size: ' + tag);
148
- }
149
- };
150
- const readJidPair = () => {
151
- const i = readString(readByte());
152
- const j = readString(readByte());
153
- if (j) {
154
- return (i || '') + '@' + j;
155
- }
156
- throw new Error('invalid jid pair: ' + i + ', ' + j);
157
- };
158
- const readAdJid = () => {
159
- const rawDomainType = readByte();
160
- const domainType = Number(rawDomainType);
161
- const device = readByte();
162
- const user = readString(readByte());
163
- return (0, jid_utils_1.jidEncode)(user, domainType === 0 || domainType === 128 ? 's.whatsapp.net' : 'lid', device);
164
- };
165
- const readString = (tag) => {
166
- if (tag >= 1 && tag < SINGLE_BYTE_TOKENS.length) {
167
- return SINGLE_BYTE_TOKENS[tag] || '';
168
- }
169
- switch (tag) {
170
- case TAGS.DICTIONARY_0:
171
- case TAGS.DICTIONARY_1:
172
- case TAGS.DICTIONARY_2:
173
- case TAGS.DICTIONARY_3:
174
- return getTokenDouble(tag - TAGS.DICTIONARY_0, readByte());
175
- case TAGS.LIST_EMPTY:
176
- return '';
177
- case TAGS.BINARY_8:
178
- return readStringFromChars(readByte());
179
- case TAGS.BINARY_20:
180
- return readStringFromChars(readInt20());
181
- case TAGS.BINARY_32:
182
- return readStringFromChars(readInt(4));
183
- case TAGS.JID_PAIR:
184
- return readJidPair();
185
- case TAGS.AD_JID:
186
- return readAdJid();
187
- case TAGS.HEX_8:
188
- case TAGS.NIBBLE_8:
189
- return readPacked8(tag);
190
- default:
191
- throw new Error('invalid string with tag: ' + tag);
192
- }
193
- };
194
- const readList = (tag) => {
195
- const items = [];
196
- const size = readListSize(tag);
197
- for (let i = 0; i < size; i++) {
198
- items.push((0, exports.decodeDecompressedBinaryNode)(buffer, opts, indexRef));
199
- }
200
- return items;
201
- };
202
- const getTokenDouble = (index1, index2) => {
203
- const dict = DOUBLE_BYTE_TOKENS[index1];
204
- if (!dict) {
205
- throw new Error(`Invalid double token dict (${index1})`);
206
- }
207
- const value = dict[index2];
208
- if (typeof value === 'undefined') {
209
- throw new Error(`Invalid double token (${index2})`);
210
- }
211
- return value;
212
- };
213
- const listSize = readListSize(readByte());
214
- const header = readString(readByte());
215
- if (!listSize || !header.length) {
216
- throw new Error('invalid node');
71
+ throw new Error("invalid hex: " + value);
72
+ };
73
+ const unpackNibble = (value) => {
74
+ if (value >= 0 && value <= 9) {
75
+ return "0".charCodeAt(0) + value;
76
+ }
77
+ switch (value) {
78
+ case 10:
79
+ return "-".charCodeAt(0);
80
+ case 11:
81
+ return ".".charCodeAt(0);
82
+ case 15:
83
+ return "\0".charCodeAt(0);
84
+ default:
85
+ throw new Error("invalid nibble: " + value);
86
+ }
87
+ };
88
+ const unpackByte = (tag, value) => {
89
+ if (tag === TAGS.NIBBLE_8) {
90
+ return unpackNibble(value);
91
+ }
92
+ else if (tag === TAGS.HEX_8) {
93
+ return unpackHex(value);
94
+ }
95
+ else {
96
+ throw new Error("unknown tag: " + tag);
97
+ }
98
+ };
99
+ const readPacked8 = (tag) => {
100
+ const startByte = readByte();
101
+ let value = "";
102
+ for (let i = 0; i < (startByte & 127); i++) {
103
+ const curByte = readByte();
104
+ value += String.fromCharCode(unpackByte(tag, (curByte & 0xf0) >> 4));
105
+ value += String.fromCharCode(unpackByte(tag, curByte & 0x0f));
106
+ }
107
+ if (startByte >> 7 !== 0) {
108
+ value = value.slice(0, -1);
109
+ }
110
+ return value;
111
+ };
112
+ const isListTag = (tag) => {
113
+ return tag === TAGS.LIST_EMPTY || tag === TAGS.LIST_8 || tag === TAGS.LIST_16;
114
+ };
115
+ const readListSize = (tag) => {
116
+ switch (tag) {
117
+ case TAGS.LIST_EMPTY:
118
+ return 0;
119
+ case TAGS.LIST_8:
120
+ return readByte();
121
+ case TAGS.LIST_16:
122
+ return readInt(2);
123
+ default:
124
+ throw new Error("invalid tag for list size: " + tag);
125
+ }
126
+ };
127
+ const readJidPair = () => {
128
+ const i = readString(readByte());
129
+ const j = readString(readByte());
130
+ if (j) {
131
+ return (i || "") + "@" + j;
132
+ }
133
+ throw new Error("invalid jid pair: " + i + ", " + j);
134
+ };
135
+ const readAdJid = () => {
136
+ const rawDomainType = readByte();
137
+ const domainType = Number(rawDomainType);
138
+ const device = readByte();
139
+ const user = readString(readByte());
140
+ let server = "s.whatsapp.net";
141
+ if (domainType === WAJIDDomains.LID) {
142
+ server = "lid";
143
+ }
144
+ else if (domainType === WAJIDDomains.HOSTED) {
145
+ server = "hosted";
146
+ }
147
+ else if (domainType === WAJIDDomains.HOSTED_LID) {
148
+ server = "hosted.lid";
149
+ }
150
+ return jidEncode(user, server, device);
151
+ };
152
+ const readString = (tag) => {
153
+ if (tag >= 1 && tag < SINGLE_BYTE_TOKENS.length) {
154
+ return SINGLE_BYTE_TOKENS[tag] || "";
155
+ }
156
+ switch (tag) {
157
+ case TAGS.DICTIONARY_0:
158
+ case TAGS.DICTIONARY_1:
159
+ case TAGS.DICTIONARY_2:
160
+ case TAGS.DICTIONARY_3:
161
+ return getTokenDouble(tag - TAGS.DICTIONARY_0, readByte());
162
+ case TAGS.LIST_EMPTY:
163
+ return "";
164
+ case TAGS.BINARY_8:
165
+ return readStringFromChars(readByte());
166
+ case TAGS.BINARY_20:
167
+ return readStringFromChars(readInt20());
168
+ case TAGS.BINARY_32:
169
+ return readStringFromChars(readInt(4));
170
+ case TAGS.JID_PAIR:
171
+ return readJidPair();
172
+ case TAGS.AD_JID:
173
+ return readAdJid();
174
+ case TAGS.HEX_8:
175
+ case TAGS.NIBBLE_8:
176
+ return readPacked8(tag);
177
+ default:
178
+ throw new Error("invalid string with tag: " + tag);
179
+ }
180
+ };
181
+ const readList = (tag) => {
182
+ const items = [];
183
+ const size = readListSize(tag);
184
+ for (let i = 0; i < size; i++) {
185
+ items.push(decodeDecompressedBinaryNode(buffer, opts, indexRef));
186
+ }
187
+ return items;
188
+ };
189
+ const getTokenDouble = (index1, index2) => {
190
+ const dict = DOUBLE_BYTE_TOKENS[index1];
191
+ if (!dict) {
192
+ throw new Error(`Invalid double token dict (${index1})`);
217
193
  }
218
- const attrs = {};
219
- let data;
220
- if (listSize === 0 || !header) {
221
- throw new Error('invalid node');
194
+ const value = dict[index2];
195
+ if (typeof value === "undefined") {
196
+ throw new Error(`Invalid double token (${index2})`);
222
197
  }
223
- // read the attributes in
224
- const attributesLength = (listSize - 1) >> 1;
225
- for (let i = 0; i < attributesLength; i++) {
226
- const key = readString(readByte());
227
- const value = readString(readByte());
228
- attrs[key] = value;
198
+ return value;
199
+ };
200
+ const listSize = readListSize(readByte());
201
+ const header = readString(readByte());
202
+ if (!listSize || !header.length) {
203
+ throw new Error("invalid node");
204
+ }
205
+ const attrs = {};
206
+ let data;
207
+ if (listSize === 0 || !header) {
208
+ throw new Error("invalid node");
209
+ }
210
+ const attributesLength = (listSize - 1) >> 1;
211
+ for (let i = 0; i < attributesLength; i++) {
212
+ const key = readString(readByte());
213
+ const value = readString(readByte());
214
+ attrs[key] = value;
215
+ }
216
+ if (listSize % 2 === 0) {
217
+ const tag = readByte();
218
+ if (isListTag(tag)) {
219
+ data = readList(tag);
229
220
  }
230
- if (listSize % 2 === 0) {
231
- const tag = readByte();
232
- if (isListTag(tag)) {
233
- data = readList(tag);
234
- }
235
- else {
236
- let decoded;
237
- switch (tag) {
238
- case TAGS.BINARY_8:
239
- decoded = readBytes(readByte());
240
- break;
241
- case TAGS.BINARY_20:
242
- decoded = readBytes(readInt20());
243
- break;
244
- case TAGS.BINARY_32:
245
- decoded = readBytes(readInt(4));
246
- break;
247
- default:
248
- decoded = readString(tag);
249
- break;
250
- }
251
- data = decoded;
252
- }
221
+ else {
222
+ let decoded;
223
+ switch (tag) {
224
+ case TAGS.BINARY_8:
225
+ decoded = readBytes(readByte());
226
+ break;
227
+ case TAGS.BINARY_20:
228
+ decoded = readBytes(readInt20());
229
+ break;
230
+ case TAGS.BINARY_32:
231
+ decoded = readBytes(readInt(4));
232
+ break;
233
+ default:
234
+ decoded = readString(tag);
235
+ break;
236
+ }
237
+ data = decoded;
253
238
  }
254
- return {
255
- tag: header,
256
- attrs,
257
- content: data
258
- };
239
+ }
240
+ return {
241
+ tag: header,
242
+ attrs,
243
+ content: data
244
+ };
259
245
  };
260
- exports.decodeDecompressedBinaryNode = decodeDecompressedBinaryNode;
261
- const decodeBinaryNode = async (buff) => {
262
- const decompBuff = await (0, exports.decompressingIfRequired)(buff);
263
- return (0, exports.decodeDecompressedBinaryNode)(decompBuff, constants);
246
+
247
+ export const decodeBinaryNode = async (buff) => {
248
+ const decompBuff = await decompressingIfRequired(buff);
249
+ return decodeDecompressedBinaryNode(decompBuff, constants);
264
250
  };
265
- exports.decodeBinaryNode = decodeBinaryNode;