@cdteam/cdwa 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +112 -2
- package/dist/auth/index.cjs +191 -0
- package/dist/auth/index.cjs.map +1 -0
- package/dist/auth/index.d.cts +25 -0
- package/dist/auth/index.d.ts +25 -0
- package/dist/auth/index.js +183 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/binary/index.cjs +414 -0
- package/dist/binary/index.cjs.map +1 -0
- package/dist/binary/index.d.cts +92 -0
- package/dist/binary/index.d.ts +92 -0
- package/dist/binary/index.js +407 -0
- package/dist/binary/index.js.map +1 -0
- package/dist/crypto/index.cjs +207 -0
- package/dist/crypto/index.cjs.map +1 -0
- package/dist/crypto/index.d.cts +91 -0
- package/dist/crypto/index.d.ts +91 -0
- package/dist/crypto/index.js +201 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/index-CcMoHfPz.d.cts +70 -0
- package/dist/index-CcMoHfPz.d.ts +70 -0
- package/dist/index.cjs +1254 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +97 -0
- package/dist/index.d.ts +97 -0
- package/dist/index.js +1224 -0
- package/dist/index.js.map +1 -0
- package/dist/messages/index.cjs +662 -0
- package/dist/messages/index.cjs.map +1 -0
- package/dist/messages/index.d.cts +122 -0
- package/dist/messages/index.d.ts +122 -0
- package/dist/messages/index.js +659 -0
- package/dist/messages/index.js.map +1 -0
- package/dist/signal/index.cjs +38 -0
- package/dist/signal/index.cjs.map +1 -0
- package/dist/signal/index.d.cts +30 -0
- package/dist/signal/index.d.ts +30 -0
- package/dist/signal/index.js +36 -0
- package/dist/signal/index.js.map +1 -0
- package/package.json +91 -4
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/binary/constants.ts
|
|
4
|
+
var WABinaryConstants = {
|
|
5
|
+
LIST_EMPTY: 0,
|
|
6
|
+
STREAM_END: 2,
|
|
7
|
+
DICTIONARY_0: 236,
|
|
8
|
+
DICTIONARY_1: 237,
|
|
9
|
+
DICTIONARY_2: 238,
|
|
10
|
+
DICTIONARY_3: 239,
|
|
11
|
+
LIST_8: 248,
|
|
12
|
+
LIST_16: 249,
|
|
13
|
+
JID_PAIR: 250,
|
|
14
|
+
HEX_8: 251,
|
|
15
|
+
BINARY_8: 252,
|
|
16
|
+
BINARY_20: 253,
|
|
17
|
+
BINARY_32: 254,
|
|
18
|
+
NIBBLE_8: 255,
|
|
19
|
+
SINGLE_BYTE_MAX: 256
|
|
20
|
+
};
|
|
21
|
+
var SINGLE_BYTE_TOKENS = [
|
|
22
|
+
"",
|
|
23
|
+
"",
|
|
24
|
+
"",
|
|
25
|
+
"200",
|
|
26
|
+
"400",
|
|
27
|
+
"404",
|
|
28
|
+
"500",
|
|
29
|
+
"501",
|
|
30
|
+
"502",
|
|
31
|
+
"action",
|
|
32
|
+
"add",
|
|
33
|
+
"after",
|
|
34
|
+
"archive",
|
|
35
|
+
"author",
|
|
36
|
+
"available",
|
|
37
|
+
"battery",
|
|
38
|
+
"before",
|
|
39
|
+
"body",
|
|
40
|
+
"broadcast",
|
|
41
|
+
"chat",
|
|
42
|
+
"clear",
|
|
43
|
+
"code",
|
|
44
|
+
"composing",
|
|
45
|
+
"config",
|
|
46
|
+
"contacts",
|
|
47
|
+
"count",
|
|
48
|
+
"create",
|
|
49
|
+
"debug",
|
|
50
|
+
"delete",
|
|
51
|
+
"demote",
|
|
52
|
+
"duplicate",
|
|
53
|
+
"encoding",
|
|
54
|
+
"error",
|
|
55
|
+
"false",
|
|
56
|
+
"filehash",
|
|
57
|
+
"from",
|
|
58
|
+
"g.us",
|
|
59
|
+
"group",
|
|
60
|
+
"groups_v2",
|
|
61
|
+
"height",
|
|
62
|
+
"ib",
|
|
63
|
+
"id",
|
|
64
|
+
"image",
|
|
65
|
+
"in",
|
|
66
|
+
"index",
|
|
67
|
+
"invis",
|
|
68
|
+
"item",
|
|
69
|
+
"jid",
|
|
70
|
+
"kind",
|
|
71
|
+
"last",
|
|
72
|
+
"leave",
|
|
73
|
+
"live",
|
|
74
|
+
"log",
|
|
75
|
+
"media",
|
|
76
|
+
"message",
|
|
77
|
+
"mimetype",
|
|
78
|
+
"missing",
|
|
79
|
+
"modify",
|
|
80
|
+
"name",
|
|
81
|
+
"notification",
|
|
82
|
+
"notify",
|
|
83
|
+
"out",
|
|
84
|
+
"owner",
|
|
85
|
+
"participant",
|
|
86
|
+
"paused",
|
|
87
|
+
"picture",
|
|
88
|
+
"played",
|
|
89
|
+
"presence",
|
|
90
|
+
"preview",
|
|
91
|
+
"promote",
|
|
92
|
+
"query",
|
|
93
|
+
"raw",
|
|
94
|
+
"read",
|
|
95
|
+
"receipt",
|
|
96
|
+
"received",
|
|
97
|
+
"recipient",
|
|
98
|
+
"recording",
|
|
99
|
+
"relay",
|
|
100
|
+
"remove",
|
|
101
|
+
"response",
|
|
102
|
+
"resume",
|
|
103
|
+
"retry",
|
|
104
|
+
"s.whatsapp.net",
|
|
105
|
+
"seconds",
|
|
106
|
+
"set",
|
|
107
|
+
"size",
|
|
108
|
+
"status",
|
|
109
|
+
"subject",
|
|
110
|
+
"subscribe",
|
|
111
|
+
"t",
|
|
112
|
+
"text",
|
|
113
|
+
"to",
|
|
114
|
+
"true",
|
|
115
|
+
"type",
|
|
116
|
+
"unarchive",
|
|
117
|
+
"unavailable",
|
|
118
|
+
"url",
|
|
119
|
+
"user",
|
|
120
|
+
"value",
|
|
121
|
+
"web",
|
|
122
|
+
"width",
|
|
123
|
+
"mute",
|
|
124
|
+
"read_only",
|
|
125
|
+
"admin",
|
|
126
|
+
"creator",
|
|
127
|
+
"short",
|
|
128
|
+
"update",
|
|
129
|
+
"powersave",
|
|
130
|
+
"rich",
|
|
131
|
+
"modify_tag",
|
|
132
|
+
"message_info",
|
|
133
|
+
"opaque",
|
|
134
|
+
"contact",
|
|
135
|
+
"unlink",
|
|
136
|
+
"iq",
|
|
137
|
+
"ping",
|
|
138
|
+
"version",
|
|
139
|
+
"client",
|
|
140
|
+
"pair-device",
|
|
141
|
+
"pair-success",
|
|
142
|
+
"success",
|
|
143
|
+
"failure"
|
|
144
|
+
];
|
|
145
|
+
var TOKEN_MAP = /* @__PURE__ */ new Map();
|
|
146
|
+
SINGLE_BYTE_TOKENS.forEach((token, index) => {
|
|
147
|
+
if (token) {
|
|
148
|
+
TOKEN_MAP.set(token, index);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// src/binary/encoder.ts
|
|
153
|
+
var BinaryEncoder = class {
|
|
154
|
+
buffer = [];
|
|
155
|
+
encode(node) {
|
|
156
|
+
this.buffer = [];
|
|
157
|
+
this.writeNode(node);
|
|
158
|
+
return new Uint8Array(this.buffer);
|
|
159
|
+
}
|
|
160
|
+
writeByte(byte) {
|
|
161
|
+
this.buffer.push(byte & 255);
|
|
162
|
+
}
|
|
163
|
+
writeBytes(bytes) {
|
|
164
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
165
|
+
this.writeByte(bytes[i]);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
writeInt16(value) {
|
|
169
|
+
this.writeByte(value >> 8 & 255);
|
|
170
|
+
this.writeByte(value & 255);
|
|
171
|
+
}
|
|
172
|
+
writeInt32(value) {
|
|
173
|
+
this.writeByte(value >> 24 & 255);
|
|
174
|
+
this.writeByte(value >> 16 & 255);
|
|
175
|
+
this.writeByte(value >> 8 & 255);
|
|
176
|
+
this.writeByte(value & 255);
|
|
177
|
+
}
|
|
178
|
+
writeListStart(size) {
|
|
179
|
+
if (size === 0) {
|
|
180
|
+
this.writeByte(WABinaryConstants.LIST_EMPTY);
|
|
181
|
+
} else if (size < 256) {
|
|
182
|
+
this.writeByte(WABinaryConstants.LIST_8);
|
|
183
|
+
this.writeByte(size);
|
|
184
|
+
} else {
|
|
185
|
+
this.writeByte(WABinaryConstants.LIST_16);
|
|
186
|
+
this.writeInt16(size);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
writeString(str) {
|
|
190
|
+
const tokenIndex = TOKEN_MAP.get(str);
|
|
191
|
+
if (tokenIndex !== void 0) {
|
|
192
|
+
this.writeByte(tokenIndex);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const encoded = new TextEncoder().encode(str);
|
|
196
|
+
if (encoded.length < 256) {
|
|
197
|
+
this.writeByte(WABinaryConstants.BINARY_8);
|
|
198
|
+
this.writeByte(encoded.length);
|
|
199
|
+
} else {
|
|
200
|
+
this.writeByte(WABinaryConstants.BINARY_32);
|
|
201
|
+
this.writeInt32(encoded.length);
|
|
202
|
+
}
|
|
203
|
+
this.writeBytes(encoded);
|
|
204
|
+
}
|
|
205
|
+
writeNode(node) {
|
|
206
|
+
const numAttrs = Object.keys(node.attrs).length;
|
|
207
|
+
const hasContent = node.content !== void 0;
|
|
208
|
+
const listSize = 1 + numAttrs * 2 + (hasContent ? 1 : 0);
|
|
209
|
+
this.writeListStart(listSize);
|
|
210
|
+
this.writeString(node.tag);
|
|
211
|
+
for (const [key, value] of Object.entries(node.attrs)) {
|
|
212
|
+
if (value !== void 0) {
|
|
213
|
+
this.writeString(key);
|
|
214
|
+
this.writeString(String(value));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (hasContent) {
|
|
218
|
+
if (Array.isArray(node.content)) {
|
|
219
|
+
this.writeListStart(node.content.length);
|
|
220
|
+
for (const child of node.content) {
|
|
221
|
+
this.writeNode(child);
|
|
222
|
+
}
|
|
223
|
+
} else if (typeof node.content === "string") {
|
|
224
|
+
this.writeString(node.content);
|
|
225
|
+
} else if (node.content instanceof Uint8Array) {
|
|
226
|
+
if (node.content.length < 256) {
|
|
227
|
+
this.writeByte(WABinaryConstants.BINARY_8);
|
|
228
|
+
this.writeByte(node.content.length);
|
|
229
|
+
} else {
|
|
230
|
+
this.writeByte(WABinaryConstants.BINARY_32);
|
|
231
|
+
this.writeInt32(node.content.length);
|
|
232
|
+
}
|
|
233
|
+
this.writeBytes(node.content);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
// src/binary/decoder.ts
|
|
240
|
+
var BinaryDecoder = class {
|
|
241
|
+
buffer = new Uint8Array(0);
|
|
242
|
+
offset = 0;
|
|
243
|
+
decode(buffer) {
|
|
244
|
+
this.buffer = buffer;
|
|
245
|
+
this.offset = 0;
|
|
246
|
+
return this.readNode();
|
|
247
|
+
}
|
|
248
|
+
readByte() {
|
|
249
|
+
if (this.offset >= this.buffer.length) {
|
|
250
|
+
throw new Error(`Unexpected EOF in WABinary stream at offset ${this.offset}`);
|
|
251
|
+
}
|
|
252
|
+
const b = this.buffer[this.offset];
|
|
253
|
+
this.offset += 1;
|
|
254
|
+
return b;
|
|
255
|
+
}
|
|
256
|
+
readBytes(length) {
|
|
257
|
+
if (this.offset + length > this.buffer.length) {
|
|
258
|
+
throw new Error(`Buffer underrun: requested ${length} bytes, have ${this.buffer.length - this.offset}`);
|
|
259
|
+
}
|
|
260
|
+
const slice = this.buffer.slice(this.offset, this.offset + length);
|
|
261
|
+
this.offset += length;
|
|
262
|
+
return slice;
|
|
263
|
+
}
|
|
264
|
+
readInt16() {
|
|
265
|
+
const b0 = this.readByte();
|
|
266
|
+
const b1 = this.readByte();
|
|
267
|
+
return b0 << 8 | b1;
|
|
268
|
+
}
|
|
269
|
+
readInt32() {
|
|
270
|
+
const b0 = this.readByte();
|
|
271
|
+
const b1 = this.readByte();
|
|
272
|
+
const b2 = this.readByte();
|
|
273
|
+
const b3 = this.readByte();
|
|
274
|
+
return b0 << 24 | b1 << 16 | b2 << 8 | b3;
|
|
275
|
+
}
|
|
276
|
+
readListSize() {
|
|
277
|
+
const tag = this.readByte();
|
|
278
|
+
if (tag === WABinaryConstants.LIST_EMPTY) {
|
|
279
|
+
return 0;
|
|
280
|
+
}
|
|
281
|
+
if (tag === WABinaryConstants.LIST_8) {
|
|
282
|
+
return this.readByte();
|
|
283
|
+
}
|
|
284
|
+
if (tag === WABinaryConstants.LIST_16) {
|
|
285
|
+
return this.readInt16();
|
|
286
|
+
}
|
|
287
|
+
throw new Error(`Invalid list tag byte: ${tag}`);
|
|
288
|
+
}
|
|
289
|
+
readString() {
|
|
290
|
+
const tag = this.readByte();
|
|
291
|
+
if (tag < SINGLE_BYTE_TOKENS.length && SINGLE_BYTE_TOKENS[tag]) {
|
|
292
|
+
return SINGLE_BYTE_TOKENS[tag];
|
|
293
|
+
}
|
|
294
|
+
if (tag === WABinaryConstants.BINARY_8) {
|
|
295
|
+
const length = this.readByte();
|
|
296
|
+
const bytes = this.readBytes(length);
|
|
297
|
+
return new TextDecoder().decode(bytes);
|
|
298
|
+
}
|
|
299
|
+
if (tag === WABinaryConstants.BINARY_32) {
|
|
300
|
+
const length = this.readInt32();
|
|
301
|
+
const bytes = this.readBytes(length);
|
|
302
|
+
return new TextDecoder().decode(bytes);
|
|
303
|
+
}
|
|
304
|
+
throw new Error(`Unsupported string tag: ${tag} at offset ${this.offset - 1}`);
|
|
305
|
+
}
|
|
306
|
+
readNode() {
|
|
307
|
+
const listSize = this.readListSize();
|
|
308
|
+
if (listSize === 0) {
|
|
309
|
+
throw new Error("Invalid empty node");
|
|
310
|
+
}
|
|
311
|
+
const tag = this.readString();
|
|
312
|
+
const attrs = {};
|
|
313
|
+
let remaining = listSize - 1;
|
|
314
|
+
while (remaining > 1) {
|
|
315
|
+
const key = this.readString();
|
|
316
|
+
const val = this.readString();
|
|
317
|
+
attrs[key] = val;
|
|
318
|
+
remaining -= 2;
|
|
319
|
+
}
|
|
320
|
+
let content;
|
|
321
|
+
if (remaining === 1) {
|
|
322
|
+
const peekByte = this.buffer[this.offset];
|
|
323
|
+
if (peekByte === WABinaryConstants.LIST_EMPTY || peekByte === WABinaryConstants.LIST_8 || peekByte === WABinaryConstants.LIST_16) {
|
|
324
|
+
const childCount = this.readListSize();
|
|
325
|
+
const children = [];
|
|
326
|
+
for (let i = 0; i < childCount; i++) {
|
|
327
|
+
children.push(this.readNode());
|
|
328
|
+
}
|
|
329
|
+
content = children;
|
|
330
|
+
} else if (peekByte === WABinaryConstants.BINARY_8 || peekByte === WABinaryConstants.BINARY_32) {
|
|
331
|
+
const nextTag = this.readByte();
|
|
332
|
+
const length = nextTag === WABinaryConstants.BINARY_8 ? this.readByte() : this.readInt32();
|
|
333
|
+
content = this.readBytes(length);
|
|
334
|
+
} else {
|
|
335
|
+
content = this.readString();
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return { tag, attrs, content };
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
// src/binary/index.ts
|
|
343
|
+
var BinaryProtocol = class {
|
|
344
|
+
static encoder = new BinaryEncoder();
|
|
345
|
+
static decoder = new BinaryDecoder();
|
|
346
|
+
/**
|
|
347
|
+
* Converte um BinaryNode para bytes WABinary
|
|
348
|
+
*/
|
|
349
|
+
static encode(node) {
|
|
350
|
+
return this.encoder.encode(node);
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Converte bytes WABinary de volta para um BinaryNode estruturado
|
|
354
|
+
*/
|
|
355
|
+
static decode(buffer) {
|
|
356
|
+
return this.decoder.decode(buffer);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Constrói um nó binário com validação de formato
|
|
360
|
+
*/
|
|
361
|
+
static createNode(tag, attrs = {}, content) {
|
|
362
|
+
return {
|
|
363
|
+
tag,
|
|
364
|
+
attrs,
|
|
365
|
+
content
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Localiza o primeiro filho correspondente à tag fornecida
|
|
370
|
+
*/
|
|
371
|
+
static getChildNode(node, childTag) {
|
|
372
|
+
if (Array.isArray(node.content)) {
|
|
373
|
+
return node.content.find((child) => child.tag === childTag);
|
|
374
|
+
}
|
|
375
|
+
return void 0;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Extrai todos os nós filhos que batem com uma determinada tag
|
|
379
|
+
*/
|
|
380
|
+
static getChildrenNodes(node, childTag) {
|
|
381
|
+
if (Array.isArray(node.content)) {
|
|
382
|
+
return node.content.filter((child) => child.tag === childTag);
|
|
383
|
+
}
|
|
384
|
+
return [];
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Converte o nó para representação em string legível para debug
|
|
388
|
+
*/
|
|
389
|
+
static stringify(node, indent = 0) {
|
|
390
|
+
const spaces = " ".repeat(indent);
|
|
391
|
+
const attrsStr = Object.entries(node.attrs).map(([k, v]) => `${k}="${v}"`).join(" ");
|
|
392
|
+
const openTag = attrsStr ? `<${node.tag} ${attrsStr}>` : `<${node.tag}>`;
|
|
393
|
+
if (!node.content) {
|
|
394
|
+
return `${spaces}<${node.tag} ${attrsStr} />`;
|
|
395
|
+
}
|
|
396
|
+
if (Array.isArray(node.content)) {
|
|
397
|
+
const children = node.content.map((c) => this.stringify(c, indent + 1)).join("\n");
|
|
398
|
+
return `${spaces}${openTag}
|
|
399
|
+
${children}
|
|
400
|
+
${spaces}</${node.tag}>`;
|
|
401
|
+
}
|
|
402
|
+
const contentStr = node.content instanceof Uint8Array ? `[Buffer ${node.content.length}b]` : String(node.content);
|
|
403
|
+
return `${spaces}${openTag}${contentStr}</${node.tag}>`;
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
exports.BinaryDecoder = BinaryDecoder;
|
|
408
|
+
exports.BinaryEncoder = BinaryEncoder;
|
|
409
|
+
exports.BinaryProtocol = BinaryProtocol;
|
|
410
|
+
exports.SINGLE_BYTE_TOKENS = SINGLE_BYTE_TOKENS;
|
|
411
|
+
exports.TOKEN_MAP = TOKEN_MAP;
|
|
412
|
+
exports.WABinaryConstants = WABinaryConstants;
|
|
413
|
+
//# sourceMappingURL=index.cjs.map
|
|
414
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/binary/constants.ts","../../src/binary/encoder.ts","../../src/binary/decoder.ts","../../src/binary/index.ts"],"names":[],"mappings":";;;AAIO,IAAM,iBAAA,GAAoB;AAAA,EAC/B,UAAA,EAAY,CAAA;AAAA,EACZ,UAAA,EAAY,CAAA;AAAA,EACZ,YAAA,EAAc,GAAA;AAAA,EACd,YAAA,EAAc,GAAA;AAAA,EACd,YAAA,EAAc,GAAA;AAAA,EACd,YAAA,EAAc,GAAA;AAAA,EACd,MAAA,EAAQ,GAAA;AAAA,EACR,OAAA,EAAS,GAAA;AAAA,EACT,QAAA,EAAU,GAAA;AAAA,EACV,KAAA,EAAO,GAAA;AAAA,EACP,QAAA,EAAU,GAAA;AAAA,EACV,SAAA,EAAW,GAAA;AAAA,EACX,SAAA,EAAW,GAAA;AAAA,EACX,QAAA,EAAU,GAAA;AAAA,EACV,eAAA,EAAiB;AACnB;AAKO,IAAM,kBAAA,GAAqB;AAAA,EAChC,EAAA;AAAA,EACA,EAAA;AAAA,EACA,EAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,WAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,E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ent":["/**\n * Constantes e tokens de indexação do protocolo WABinary do WhatsApp\n */\n\nexport const WABinaryConstants = {\n LIST_EMPTY: 0,\n STREAM_END: 2,\n DICTIONARY_0: 236,\n DICTIONARY_1: 237,\n DICTIONARY_2: 238,\n DICTIONARY_3: 239,\n LIST_8: 248,\n LIST_16: 249,\n JID_PAIR: 250,\n HEX_8: 251,\n BINARY_8: 252,\n BINARY_20: 253,\n BINARY_32: 254,\n NIBBLE_8: 255,\n SINGLE_BYTE_MAX: 256,\n}\n\n/**\n * Tabela de tokens simples comuns do WhatsApp\n */\nexport const SINGLE_BYTE_TOKENS = [\n '',\n '',\n '',\n '200',\n '400',\n '404',\n '500',\n '501',\n '502',\n 'action',\n 'add',\n 'after',\n 'archive',\n 'author',\n 'available',\n 'battery',\n 'before',\n 'body',\n 'broadcast',\n 'chat',\n 'clear',\n 'code',\n 'composing',\n 'config',\n 'contacts',\n 'count',\n 'create',\n 'debug',\n 'delete',\n 'demote',\n 'duplicate',\n 'encoding',\n 'error',\n 'false',\n 'filehash',\n 'from',\n 'g.us',\n 'group',\n 'groups_v2',\n 'height',\n 'ib',\n 'id',\n 'image',\n 'in',\n 'index',\n 'invis',\n 'item',\n 'jid',\n 'kind',\n 'last',\n 'leave',\n 'live',\n 'log',\n 'media',\n 'message',\n 'mimetype',\n 'missing',\n 'modify',\n 'name',\n 'notification',\n 'notify',\n 'out',\n 'owner',\n 'participant',\n 'paused',\n 'picture',\n 'played',\n 'presence',\n 'preview',\n 'promote',\n 'query',\n 'raw',\n 'read',\n 'receipt',\n 'received',\n 'recipient',\n 'recording',\n 'relay',\n 'remove',\n 'response',\n 'resume',\n 'retry',\n 's.whatsapp.net',\n 'seconds',\n 'set',\n 'size',\n 'status',\n 'subject',\n 'subscribe',\n 't',\n 'text',\n 'to',\n 'true',\n 'type',\n 'unarchive',\n 'unavailable',\n 'url',\n 'user',\n 'value',\n 'web',\n 'width',\n 'mute',\n 'read_only',\n 'admin',\n 'creator',\n 'short',\n 'update',\n 'powersave',\n 'rich',\n 'modify_tag',\n 'message_info',\n 'opaque',\n 'contact',\n 'unlink',\n 'iq',\n 'ping',\n 'version',\n 'client',\n 'pair-device',\n 'pair-success',\n 'success',\n 'failure',\n]\n\n// Mapa reverso para encoding ultra veloz O(1)\nexport const TOKEN_MAP = new Map<string, number>()\nSINGLE_BYTE_TOKENS.forEach((token, index) => {\n if (token) {\n TOKEN_MAP.set(token, index)\n }\n})\n","import { WABinaryConstants, TOKEN_MAP } from './constants.js'\nimport type { BinaryNode } from '../types/index.js'\n\n/**\n * Codificador de stanzas XML em bytes compatíveis com o WhatsApp Web (WABinary)\n */\nexport class BinaryEncoder {\n private buffer: number[] = []\n\n encode(node: BinaryNode): Uint8Array {\n this.buffer = []\n this.writeNode(node)\n return new Uint8Array(this.buffer)\n }\n\n private writeByte(byte: number) {\n this.buffer.push(byte & 0xff)\n }\n\n private writeBytes(bytes: Uint8Array | number[]) {\n for (let i = 0; i < bytes.length; i++) {\n this.writeByte(bytes[i]!)\n }\n }\n\n private writeInt16(value: number) {\n this.writeByte((value >> 8) & 0xff)\n this.writeByte(value & 0xff)\n }\n\n private writeInt32(value: number) {\n this.writeByte((value >> 24) & 0xff)\n this.writeByte((value >> 16) & 0xff)\n this.writeByte((value >> 8) & 0xff)\n this.writeByte(value & 0xff)\n }\n\n private writeListStart(size: number) {\n if (size === 0) {\n this.writeByte(WABinaryConstants.LIST_EMPTY)\n } else if (size < 256) {\n this.writeByte(WABinaryConstants.LIST_8)\n this.writeByte(size)\n } else {\n this.writeByte(WABinaryConstants.LIST_16)\n this.writeInt16(size)\n }\n }\n\n private writeString(str: string) {\n const tokenIndex = TOKEN_MAP.get(str)\n if (tokenIndex !== undefined) {\n this.writeByte(tokenIndex)\n return\n }\n\n const encoded = new TextEncoder().encode(str)\n if (encoded.length < 256) {\n this.writeByte(WABinaryConstants.BINARY_8)\n this.writeByte(encoded.length)\n } else {\n this.writeByte(WABinaryConstants.BINARY_32)\n this.writeInt32(encoded.length)\n }\n this.writeBytes(encoded)\n }\n\n private writeNode(node: BinaryNode) {\n const numAttrs = Object.keys(node.attrs).length\n const hasContent = node.content !== undefined\n\n // Um nó é serializado como uma lista de:\n // [tag, attrs, content (se houver)] -> tamanho total = 1 + (numAttrs * 2) + (hasContent ? 1 : 0)\n const listSize = 1 + numAttrs * 2 + (hasContent ? 1 : 0)\n this.writeListStart(listSize)\n\n // Escreve a Tag\n this.writeString(node.tag)\n\n // Escreve os Atributos (Pares chave=valor)\n for (const [key, value] of Object.entries(node.attrs)) {\n if (value !== undefined) {\n this.writeString(key)\n this.writeString(String(value))\n }\n }\n\n // Escreve o Conteúdo (Nós filhos, string ou buffer)\n if (hasContent) {\n if (Array.isArray(node.content)) {\n this.writeListStart(node.content.length)\n for (const child of node.content) {\n this.writeNode(child)\n }\n } else if (typeof node.content === 'string') {\n this.writeString(node.content)\n } else if (node.content instanceof Uint8Array) {\n if (node.content.length < 256) {\n this.writeByte(WABinaryConstants.BINARY_8)\n this.writeByte(node.content.length)\n } else {\n this.writeByte(WABinaryConstants.BINARY_32)\n this.writeInt32(node.content.length)\n }\n this.writeBytes(node.content)\n }\n }\n }\n}\n","import { WABinaryConstants, SINGLE_BYTE_TOKENS } from './constants.js'\nimport type { BinaryNode, BinaryNodeAttributes } from '../types/index.js'\n\n/**\n * Decodificador de stanzas do WhatsApp a partir de fluxos de bytes WABinary\n */\nexport class BinaryDecoder {\n private buffer: Uint8Array = new Uint8Array(0)\n private offset = 0\n\n decode(buffer: Uint8Array): BinaryNode {\n this.buffer = buffer\n this.offset = 0\n return this.readNode()\n }\n\n private readByte(): number {\n if (this.offset >= this.buffer.length) {\n throw new Error(`Unexpected EOF in WABinary stream at offset ${this.offset}`)\n }\n const b = this.buffer[this.offset]!\n this.offset += 1\n return b\n }\n\n private readBytes(length: number): Uint8Array {\n if (this.offset + length > this.buffer.length) {\n throw new Error(`Buffer underrun: requested ${length} bytes, have ${this.buffer.length - this.offset}`)\n }\n const slice = this.buffer.slice(this.offset, this.offset + length)\n this.offset += length\n return slice\n }\n\n private readInt16(): number {\n const b0 = this.readByte()\n const b1 = this.readByte()\n return (b0 << 8) | b1\n }\n\n private readInt32(): number {\n const b0 = this.readByte()\n const b1 = this.readByte()\n const b2 = this.readByte()\n const b3 = this.readByte()\n return (b0 << 24) | (b1 << 16) | (b2 << 8) | b3\n }\n\n private readListSize(): number {\n const tag = this.readByte()\n if (tag === WABinaryConstants.LIST_EMPTY) {\n return 0\n }\n if (tag === WABinaryConstants.LIST_8) {\n return this.readByte()\n }\n if (tag === WABinaryConstants.LIST_16) {\n return this.readInt16()\n }\n throw new Error(`Invalid list tag byte: ${tag}`)\n }\n\n private readString(): string {\n const tag = this.readByte()\n\n if (tag < SINGLE_BYTE_TOKENS.length && SINGLE_BYTE_TOKENS[tag]) {\n return SINGLE_BYTE_TOKENS[tag]!\n }\n\n if (tag === WABinaryConstants.BINARY_8) {\n const length = this.readByte()\n const bytes = this.readBytes(length)\n return new TextDecoder().decode(bytes)\n }\n\n if (tag === WABinaryConstants.BINARY_32) {\n const length = this.readInt32()\n const bytes = this.readBytes(length)\n return new TextDecoder().decode(bytes)\n }\n\n throw new Error(`Unsupported string tag: ${tag} at offset ${this.offset - 1}`)\n }\n\n private readNode(): BinaryNode {\n const listSize = this.readListSize()\n if (listSize === 0) {\n throw new Error('Invalid empty node')\n }\n\n const tag = this.readString()\n const attrs: BinaryNodeAttributes = {}\n let remaining = listSize - 1\n\n // Lê pares de chave e valor de atributos\n while (remaining > 1) {\n const key = this.readString()\n const val = this.readString()\n attrs[key] = val\n remaining -= 2\n }\n\n let content: BinaryNode[] | string | Uint8Array | undefined\n\n if (remaining === 1) {\n const peekByte = this.buffer[this.offset]\n if (\n peekByte === WABinaryConstants.LIST_EMPTY ||\n peekByte === WABinaryConstants.LIST_8 ||\n peekByte === WABinaryConstants.LIST_16\n ) {\n const childCount = this.readListSize()\n const children: BinaryNode[] = []\n for (let i = 0; i < childCount; i++) {\n children.push(this.readNode())\n }\n content = children\n } else if (peekByte === WABinaryConstants.BINARY_8 || peekByte === WABinaryConstants.BINARY_32) {\n const nextTag = this.readByte()\n const length = nextTag === WABinaryConstants.BINARY_8 ? this.readByte() : this.readInt32()\n content = this.readBytes(length)\n } else {\n content = this.readString()\n }\n }\n\n return { tag, attrs, content }\n }\n}\n","import type { BinaryNode } from '../types/index.js'\nimport { BinaryEncoder } from './encoder.js'\nimport { BinaryDecoder } from './decoder.js'\n\nexport * from './constants.js'\nexport * from './encoder.js'\nexport * from './decoder.js'\n\n/**\n * Utilitários para manipulação de stanzas e nós binários (WABinary)\n */\nexport class BinaryProtocol {\n private static encoder = new BinaryEncoder()\n private static decoder = new BinaryDecoder()\n\n /**\n * Converte um BinaryNode para bytes WABinary\n */\n static encode(node: BinaryNode): Uint8Array {\n return this.encoder.encode(node)\n }\n\n /**\n * Converte bytes WABinary de volta para um BinaryNode estruturado\n */\n static decode(buffer: Uint8Array): BinaryNode {\n return this.decoder.decode(buffer)\n }\n\n /**\n * Constrói um nó binário com validação de formato\n */\n static createNode(\n tag: string,\n attrs: Record<string, string | number | undefined> = {},\n content?: BinaryNode[] | string | Uint8Array\n ): BinaryNode {\n return {\n tag,\n attrs,\n content,\n }\n }\n\n /**\n * Localiza o primeiro filho correspondente à tag fornecida\n */\n static getChildNode(node: BinaryNode, childTag: string): BinaryNode | undefined {\n if (Array.isArray(node.content)) {\n return node.content.find((child) => child.tag === childTag)\n }\n return undefined\n }\n\n /**\n * Extrai todos os nós filhos que batem com uma determinada tag\n */\n static getChildrenNodes(node: BinaryNode, childTag: string): BinaryNode[] {\n if (Array.isArray(node.content)) {\n return node.content.filter((child) => child.tag === childTag)\n }\n return []\n }\n\n /**\n * Converte o nó para representação em string legível para debug\n */\n static stringify(node: BinaryNode, indent = 0): string {\n const spaces = ' '.repeat(indent)\n const attrsStr = Object.entries(node.attrs)\n .map(([k, v]) => `${k}=\"${v}\"`)\n .join(' ')\n\n const openTag = attrsStr ? `<${node.tag} ${attrsStr}>` : `<${node.tag}>`\n\n if (!node.content) {\n return `${spaces}<${node.tag} ${attrsStr} />`\n }\n\n if (Array.isArray(node.content)) {\n const children = node.content.map((c) => this.stringify(c, indent + 1)).join('\\n')\n return `${spaces}${openTag}\\n${children}\\n${spaces}</${node.tag}>`\n }\n\n const contentStr =\n node.content instanceof Uint8Array\n ? `[Buffer ${node.content.length}b]`\n : String(node.content)\n\n return `${spaces}${openTag}${contentStr}</${node.tag}>`\n }\n}\n"]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { B as BinaryNode } from '../index-CcMoHfPz.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Constantes e tokens de indexação do protocolo WABinary do WhatsApp
|
|
5
|
+
*/
|
|
6
|
+
declare const WABinaryConstants: {
|
|
7
|
+
LIST_EMPTY: number;
|
|
8
|
+
STREAM_END: number;
|
|
9
|
+
DICTIONARY_0: number;
|
|
10
|
+
DICTIONARY_1: number;
|
|
11
|
+
DICTIONARY_2: number;
|
|
12
|
+
DICTIONARY_3: number;
|
|
13
|
+
LIST_8: number;
|
|
14
|
+
LIST_16: number;
|
|
15
|
+
JID_PAIR: number;
|
|
16
|
+
HEX_8: number;
|
|
17
|
+
BINARY_8: number;
|
|
18
|
+
BINARY_20: number;
|
|
19
|
+
BINARY_32: number;
|
|
20
|
+
NIBBLE_8: number;
|
|
21
|
+
SINGLE_BYTE_MAX: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Tabela de tokens simples comuns do WhatsApp
|
|
25
|
+
*/
|
|
26
|
+
declare const SINGLE_BYTE_TOKENS: string[];
|
|
27
|
+
declare const TOKEN_MAP: Map<string, number>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Codificador de stanzas XML em bytes compatíveis com o WhatsApp Web (WABinary)
|
|
31
|
+
*/
|
|
32
|
+
declare class BinaryEncoder {
|
|
33
|
+
private buffer;
|
|
34
|
+
encode(node: BinaryNode): Uint8Array;
|
|
35
|
+
private writeByte;
|
|
36
|
+
private writeBytes;
|
|
37
|
+
private writeInt16;
|
|
38
|
+
private writeInt32;
|
|
39
|
+
private writeListStart;
|
|
40
|
+
private writeString;
|
|
41
|
+
private writeNode;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Decodificador de stanzas do WhatsApp a partir de fluxos de bytes WABinary
|
|
46
|
+
*/
|
|
47
|
+
declare class BinaryDecoder {
|
|
48
|
+
private buffer;
|
|
49
|
+
private offset;
|
|
50
|
+
decode(buffer: Uint8Array): BinaryNode;
|
|
51
|
+
private readByte;
|
|
52
|
+
private readBytes;
|
|
53
|
+
private readInt16;
|
|
54
|
+
private readInt32;
|
|
55
|
+
private readListSize;
|
|
56
|
+
private readString;
|
|
57
|
+
private readNode;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Utilitários para manipulação de stanzas e nós binários (WABinary)
|
|
62
|
+
*/
|
|
63
|
+
declare class BinaryProtocol {
|
|
64
|
+
private static encoder;
|
|
65
|
+
private static decoder;
|
|
66
|
+
/**
|
|
67
|
+
* Converte um BinaryNode para bytes WABinary
|
|
68
|
+
*/
|
|
69
|
+
static encode(node: BinaryNode): Uint8Array;
|
|
70
|
+
/**
|
|
71
|
+
* Converte bytes WABinary de volta para um BinaryNode estruturado
|
|
72
|
+
*/
|
|
73
|
+
static decode(buffer: Uint8Array): BinaryNode;
|
|
74
|
+
/**
|
|
75
|
+
* Constrói um nó binário com validação de formato
|
|
76
|
+
*/
|
|
77
|
+
static createNode(tag: string, attrs?: Record<string, string | number | undefined>, content?: BinaryNode[] | string | Uint8Array): BinaryNode;
|
|
78
|
+
/**
|
|
79
|
+
* Localiza o primeiro filho correspondente à tag fornecida
|
|
80
|
+
*/
|
|
81
|
+
static getChildNode(node: BinaryNode, childTag: string): BinaryNode | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* Extrai todos os nós filhos que batem com uma determinada tag
|
|
84
|
+
*/
|
|
85
|
+
static getChildrenNodes(node: BinaryNode, childTag: string): BinaryNode[];
|
|
86
|
+
/**
|
|
87
|
+
* Converte o nó para representação em string legível para debug
|
|
88
|
+
*/
|
|
89
|
+
static stringify(node: BinaryNode, indent?: number): string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { BinaryDecoder, BinaryEncoder, BinaryProtocol, SINGLE_BYTE_TOKENS, TOKEN_MAP, WABinaryConstants };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { B as BinaryNode } from '../index-CcMoHfPz.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Constantes e tokens de indexação do protocolo WABinary do WhatsApp
|
|
5
|
+
*/
|
|
6
|
+
declare const WABinaryConstants: {
|
|
7
|
+
LIST_EMPTY: number;
|
|
8
|
+
STREAM_END: number;
|
|
9
|
+
DICTIONARY_0: number;
|
|
10
|
+
DICTIONARY_1: number;
|
|
11
|
+
DICTIONARY_2: number;
|
|
12
|
+
DICTIONARY_3: number;
|
|
13
|
+
LIST_8: number;
|
|
14
|
+
LIST_16: number;
|
|
15
|
+
JID_PAIR: number;
|
|
16
|
+
HEX_8: number;
|
|
17
|
+
BINARY_8: number;
|
|
18
|
+
BINARY_20: number;
|
|
19
|
+
BINARY_32: number;
|
|
20
|
+
NIBBLE_8: number;
|
|
21
|
+
SINGLE_BYTE_MAX: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Tabela de tokens simples comuns do WhatsApp
|
|
25
|
+
*/
|
|
26
|
+
declare const SINGLE_BYTE_TOKENS: string[];
|
|
27
|
+
declare const TOKEN_MAP: Map<string, number>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Codificador de stanzas XML em bytes compatíveis com o WhatsApp Web (WABinary)
|
|
31
|
+
*/
|
|
32
|
+
declare class BinaryEncoder {
|
|
33
|
+
private buffer;
|
|
34
|
+
encode(node: BinaryNode): Uint8Array;
|
|
35
|
+
private writeByte;
|
|
36
|
+
private writeBytes;
|
|
37
|
+
private writeInt16;
|
|
38
|
+
private writeInt32;
|
|
39
|
+
private writeListStart;
|
|
40
|
+
private writeString;
|
|
41
|
+
private writeNode;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Decodificador de stanzas do WhatsApp a partir de fluxos de bytes WABinary
|
|
46
|
+
*/
|
|
47
|
+
declare class BinaryDecoder {
|
|
48
|
+
private buffer;
|
|
49
|
+
private offset;
|
|
50
|
+
decode(buffer: Uint8Array): BinaryNode;
|
|
51
|
+
private readByte;
|
|
52
|
+
private readBytes;
|
|
53
|
+
private readInt16;
|
|
54
|
+
private readInt32;
|
|
55
|
+
private readListSize;
|
|
56
|
+
private readString;
|
|
57
|
+
private readNode;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Utilitários para manipulação de stanzas e nós binários (WABinary)
|
|
62
|
+
*/
|
|
63
|
+
declare class BinaryProtocol {
|
|
64
|
+
private static encoder;
|
|
65
|
+
private static decoder;
|
|
66
|
+
/**
|
|
67
|
+
* Converte um BinaryNode para bytes WABinary
|
|
68
|
+
*/
|
|
69
|
+
static encode(node: BinaryNode): Uint8Array;
|
|
70
|
+
/**
|
|
71
|
+
* Converte bytes WABinary de volta para um BinaryNode estruturado
|
|
72
|
+
*/
|
|
73
|
+
static decode(buffer: Uint8Array): BinaryNode;
|
|
74
|
+
/**
|
|
75
|
+
* Constrói um nó binário com validação de formato
|
|
76
|
+
*/
|
|
77
|
+
static createNode(tag: string, attrs?: Record<string, string | number | undefined>, content?: BinaryNode[] | string | Uint8Array): BinaryNode;
|
|
78
|
+
/**
|
|
79
|
+
* Localiza o primeiro filho correspondente à tag fornecida
|
|
80
|
+
*/
|
|
81
|
+
static getChildNode(node: BinaryNode, childTag: string): BinaryNode | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* Extrai todos os nós filhos que batem com uma determinada tag
|
|
84
|
+
*/
|
|
85
|
+
static getChildrenNodes(node: BinaryNode, childTag: string): BinaryNode[];
|
|
86
|
+
/**
|
|
87
|
+
* Converte o nó para representação em string legível para debug
|
|
88
|
+
*/
|
|
89
|
+
static stringify(node: BinaryNode, indent?: number): string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { BinaryDecoder, BinaryEncoder, BinaryProtocol, SINGLE_BYTE_TOKENS, TOKEN_MAP, WABinaryConstants };
|