@blckrose/baileys 2.0.3 → 2.0.5
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 +457 -539
- package/lib/Defaults/index.js +12 -2
- package/lib/Socket/messages-send.js +1 -1
- package/lib/Types/RichType.js +22 -0
- package/lib/Types/index.js +1 -0
- package/lib/Utils/companion-reg-client-utils.js +32 -0
- package/lib/Utils/index.js +4 -0
- package/lib/Utils/messages-media.js +53 -38
- package/lib/Utils/messages.js +142 -143
- package/lib/Utils/offline-node-processor.js +39 -0
- package/lib/Utils/rich-message-utils.js +392 -0
- package/lib/Utils/stanza-ack.js +37 -0
- package/lib/WABinary/constants.js +73 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +22 -0
- package/lib/WAUSync/Protocols/index.js +2 -1
- package/package.json +2 -2
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lia@Changes 09-04-26 [WIP]
|
|
3
|
+
* Adds support for tables and code blocks with richResponseMessage (wrapped inside botForwardedMessage).
|
|
4
|
+
*
|
|
5
|
+
* If you use or copy this code, please credit my name or project.
|
|
6
|
+
* @itsliaaa/baileys
|
|
7
|
+
*/
|
|
8
|
+
import { getRandomValues, randomUUID, randomBytes } from 'crypto';
|
|
9
|
+
import { BOT_RENDERING_CONFIG_METADATA, DONATE_URL, LEXER_REGEX } from '../Defaults/index.js';
|
|
10
|
+
import { LANGUAGE_KEYWORDS } from '../WABinary/constants.js';
|
|
11
|
+
import { CodeHighlightType, RichSubMessageType } from '../Types/RichType.js';
|
|
12
|
+
import { proto } from '../../WAProto/index.js';
|
|
13
|
+
import { unixTimestampSeconds } from './generics.js';
|
|
14
|
+
const NOOP = new Set([]);
|
|
15
|
+
export const tokenizeCode = (code, language = 'javascript') => {
|
|
16
|
+
const keywords = LANGUAGE_KEYWORDS[language] || NOOP;
|
|
17
|
+
const blocks = [];
|
|
18
|
+
LEXER_REGEX.lastIndex = 0;
|
|
19
|
+
let match;
|
|
20
|
+
while ((match = LEXER_REGEX.exec(code)) !== null) {
|
|
21
|
+
if (match[1]) {
|
|
22
|
+
blocks.push({ highlightType: CodeHighlightType.COMMENT, codeContent: match[1] });
|
|
23
|
+
}
|
|
24
|
+
else if (match[2]) {
|
|
25
|
+
blocks.push({ highlightType: CodeHighlightType.STRING, codeContent: match[2] });
|
|
26
|
+
}
|
|
27
|
+
else if (match[3]) {
|
|
28
|
+
blocks.push({
|
|
29
|
+
highlightType: keywords.has(match[3]) ? CodeHighlightType.KEYWORD : CodeHighlightType.METHOD,
|
|
30
|
+
codeContent: match[3],
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else if (match[4]) {
|
|
34
|
+
blocks.push({
|
|
35
|
+
highlightType: keywords.has(match[4]) ? CodeHighlightType.KEYWORD : CodeHighlightType.DEFAULT,
|
|
36
|
+
codeContent: match[4],
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else if (match[5]) {
|
|
40
|
+
blocks.push({ highlightType: CodeHighlightType.NUMBER, codeContent: match[5] });
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
blocks.push({ highlightType: CodeHighlightType.DEFAULT, codeContent: match[6] });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return blocks;
|
|
47
|
+
};
|
|
48
|
+
// Lia@Changes 09-04-26 --- Inject buffer into unifiedResponse.data to support proper rendering of rich messages (ex: tables and code blocks)
|
|
49
|
+
export const toUnified = (submessages) =>
|
|
50
|
+
({
|
|
51
|
+
response_id: randomUUID(),
|
|
52
|
+
sections: submessages.map((submessage, index) => {
|
|
53
|
+
switch (submessage.messageType) {
|
|
54
|
+
case RichSubMessageType.CODE:
|
|
55
|
+
const codeMetadata = submessage.codeMetadata;
|
|
56
|
+
return {
|
|
57
|
+
view_model: {
|
|
58
|
+
primitive: {
|
|
59
|
+
language: codeMetadata.codeLanguage,
|
|
60
|
+
code_blocks: codeMetadata.codeBlocks.map((block) => ({ content: block.codeContent, type: CodeHighlightType[block.highlightType] })),
|
|
61
|
+
__typename: 'GenAICodeUXPrimitive'
|
|
62
|
+
},
|
|
63
|
+
__typename: 'GenAISingleLayoutViewModel'
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
case RichSubMessageType.CONTENT_ITEMS:
|
|
67
|
+
return {
|
|
68
|
+
view_model: {
|
|
69
|
+
primitives: submessage.contentItemsMetadata.itemsMetadata.map((item) => {
|
|
70
|
+
const reelItem = item.reelItem
|
|
71
|
+
return {
|
|
72
|
+
reels_url: reelItem.videoUrl,
|
|
73
|
+
thumbnail_url: reelItem.thumbnailUrl,
|
|
74
|
+
creator: reelItem.creator || '@itsliaaa/baileys',
|
|
75
|
+
avatar_url: reelItem.profileIconUrl,
|
|
76
|
+
reels_title: reelItem.title,
|
|
77
|
+
likes_count: reelItem.likesCount || 0,
|
|
78
|
+
shares_count: reelItem.sharesCount || 0,
|
|
79
|
+
view_count: reelItem.viewCount || 0,
|
|
80
|
+
reel_source: reelItem.reelSource || 'IG',
|
|
81
|
+
is_verified: reelItem.isVerified || false,
|
|
82
|
+
__typename: 'GenAIReelPrimitive'
|
|
83
|
+
}
|
|
84
|
+
}),
|
|
85
|
+
__typename: 'GenAIHScrollLayoutViewModel'
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
case RichSubMessageType.LATEX:
|
|
89
|
+
const latexMetadata = submessage.latexMetadata;
|
|
90
|
+
const item = {
|
|
91
|
+
latex_expression: latexMetadata.expressions[0]?.latexExpression,
|
|
92
|
+
font_height: latexMetadata.expressions[0]?.fontHeight,
|
|
93
|
+
padding: 15,
|
|
94
|
+
latex_image: {
|
|
95
|
+
url: latexMetadata.expressions[0]?.url,
|
|
96
|
+
width: latexMetadata.expressions[0]?.width || 388,
|
|
97
|
+
height: latexMetadata.expressions[0]?.height || 160
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return {
|
|
101
|
+
view_model: {
|
|
102
|
+
primitive: {
|
|
103
|
+
item,
|
|
104
|
+
...item,
|
|
105
|
+
__typename: 'GenAILatexUXPrimitive'
|
|
106
|
+
},
|
|
107
|
+
__typename: 'GenAISingleLayoutViewModel'
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
case RichSubMessageType.TABLE:
|
|
111
|
+
const tableMetadata = submessage.tableMetadata;
|
|
112
|
+
return {
|
|
113
|
+
view_model: {
|
|
114
|
+
primitive: {
|
|
115
|
+
title: tableMetadata.title,
|
|
116
|
+
rows: tableMetadata.rows.map((row) => ({ is_header: row.isHeading, cells: row.items, markdown_cells: [] })),
|
|
117
|
+
__typename: 'GenATableUXPrimitive'
|
|
118
|
+
},
|
|
119
|
+
__typename: 'GenAISingleLayoutViewModel'
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
case RichSubMessageType.TEXT:
|
|
123
|
+
return {
|
|
124
|
+
view_model: {
|
|
125
|
+
primitive: {
|
|
126
|
+
text: submessage.messageText,
|
|
127
|
+
inline_entities: submessage.inlineEntities || [],
|
|
128
|
+
__typename: 'GenAIMarkdownTextUXPrimitive'
|
|
129
|
+
},
|
|
130
|
+
__typename: 'GenAISingleLayoutViewModel'
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
return submessage;
|
|
135
|
+
})
|
|
136
|
+
});
|
|
137
|
+
// Lia@Note 17-04-26 --- WIP
|
|
138
|
+
export const buildAdditionalBotMetadataContext = (submessages) => {
|
|
139
|
+
const sources = [];
|
|
140
|
+
const mediaDetailsMetadataList = [];
|
|
141
|
+
for (let i = 0; i < submessages.length; i++) {
|
|
142
|
+
const submessage = submessages[i];
|
|
143
|
+
switch (submessage.messageType) {
|
|
144
|
+
case RichSubMessageType.CONTENT_ITEMS:
|
|
145
|
+
const itemsMetadata = submessage.contentItemsMetadata.itemsMetadata;
|
|
146
|
+
for (let n = 0; n < itemsMetadata.length; n++) {
|
|
147
|
+
const reelItem = itemsMetadata[n].reelItem;
|
|
148
|
+
sources.push({
|
|
149
|
+
provider: 0,
|
|
150
|
+
thumbnailCdnUrl: reelItem.thumbnailUrl,
|
|
151
|
+
sourceProviderUrl: reelItem.videoUrl,
|
|
152
|
+
sourceQuery: '',
|
|
153
|
+
faviconCdnUrl: '',
|
|
154
|
+
citationNumber: i + 1,
|
|
155
|
+
sourceTitle: reelItem.title
|
|
156
|
+
});
|
|
157
|
+
mediaDetailsMetadataList.push({
|
|
158
|
+
id: randomBytes(32).toString('hex'),
|
|
159
|
+
previewMedia: {
|
|
160
|
+
fileSha256: '',
|
|
161
|
+
mediaKey: '',
|
|
162
|
+
fileEncSha256: '',
|
|
163
|
+
directPath: '',
|
|
164
|
+
mediaKeyTimestamp: unixTimestampSeconds(),
|
|
165
|
+
mimetype: 'image/jpeg'
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
break;
|
|
170
|
+
case RichSubMessageType.LATEX:
|
|
171
|
+
const expressions = submessage.latexMetadata.expressions;
|
|
172
|
+
for (let n = 0; n < expressions.length; n++) {
|
|
173
|
+
const expression = expressions[n];
|
|
174
|
+
mediaDetailsMetadataList.push({
|
|
175
|
+
id: randomBytes(32).toString('hex'),
|
|
176
|
+
previewMedia: {
|
|
177
|
+
fileSha256: '',
|
|
178
|
+
mediaKey: '',
|
|
179
|
+
fileEncSha256: '',
|
|
180
|
+
directPath: '',
|
|
181
|
+
mediaKeyTimestamp: unixTimestampSeconds(),
|
|
182
|
+
mimetype: 'image/jpeg'
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return { sources, mediaDetailsMetadataList };
|
|
190
|
+
}
|
|
191
|
+
export const prepareRichResponseMessage = (content) => {
|
|
192
|
+
const { code, contentText, expressions, footerText, headerText, items, language, links, noHeading, richResponse, table, text, title } = content;
|
|
193
|
+
let submessages = [];
|
|
194
|
+
if (Array.isArray(richResponse)) {
|
|
195
|
+
submessages = richResponse.map((submessage) => {
|
|
196
|
+
if (submessage.text) {
|
|
197
|
+
return {
|
|
198
|
+
messageType: RichSubMessageType.TEXT,
|
|
199
|
+
messageText: submessage.text,
|
|
200
|
+
inlineEntities: submessage.inlineEntities
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
else if (submessage.code) {
|
|
204
|
+
return {
|
|
205
|
+
messageType: RichSubMessageType.CODE,
|
|
206
|
+
codeMetadata: {
|
|
207
|
+
codeLanguage: submessage.language,
|
|
208
|
+
codeBlocks: submessage.code
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
else if (submessage.expressions) {
|
|
213
|
+
return {
|
|
214
|
+
messageType: RichSubMessageType.LATEX,
|
|
215
|
+
latexMetadata: {
|
|
216
|
+
text: submessage.text,
|
|
217
|
+
expressions: submessage.expressions
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
else if (submessage.items) {
|
|
222
|
+
return {
|
|
223
|
+
messageType: RichSubMessageType.CONTENT_ITEMS,
|
|
224
|
+
contentItemsMetadata: {
|
|
225
|
+
itemsMetadata: submessage.items
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
else if (submessage.table) {
|
|
230
|
+
return {
|
|
231
|
+
messageType: RichSubMessageType.TABLE,
|
|
232
|
+
tableMetadata: {
|
|
233
|
+
title: submessage.title,
|
|
234
|
+
rows: submessage.table
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
return submessage;
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
if (headerText) {
|
|
243
|
+
submessages.push({
|
|
244
|
+
messageType: RichSubMessageType.TEXT,
|
|
245
|
+
messageText: headerText
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
if (contentText) {
|
|
249
|
+
submessages.push({
|
|
250
|
+
messageType: RichSubMessageType.TEXT,
|
|
251
|
+
messageText: contentText
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
if (code) {
|
|
255
|
+
language ??= 'javascript';
|
|
256
|
+
submessages.push({
|
|
257
|
+
messageType: RichSubMessageType.CODE,
|
|
258
|
+
codeMetadata: {
|
|
259
|
+
codeLanguage: language,
|
|
260
|
+
codeBlocks: tokenizeCode(code, language)
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
else if (expressions) {
|
|
265
|
+
submessages.push({
|
|
266
|
+
messageType: RichSubMessageType.LATEX,
|
|
267
|
+
latexMetadata: {
|
|
268
|
+
text,
|
|
269
|
+
expressions
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
else if (items) {
|
|
274
|
+
submessages.push({
|
|
275
|
+
messageType: RichSubMessageType.CONTENT_ITEMS,
|
|
276
|
+
contentItemsMetadata: {
|
|
277
|
+
itemsMetadata: items.map((item) => ({ reelItem: item })),
|
|
278
|
+
contentType: proto.AIRichResponseContentItemsMetadata.ContentType.CAROUSEL
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
else if (links) {
|
|
283
|
+
links.forEach((linkField, index) => {
|
|
284
|
+
const prefix = 'SS_' + index;
|
|
285
|
+
const url = linkField.url || DONATE_URL;
|
|
286
|
+
const sources = linkField.sources?.map((sourceField) => ({
|
|
287
|
+
source_type: 'THIRD_PARTY',
|
|
288
|
+
source_display_name: sourceField.displayName || 'Donate',
|
|
289
|
+
source_subtitle: sourceField.subtitle || 'Saweria',
|
|
290
|
+
source_url: sourceField.url || url
|
|
291
|
+
}));
|
|
292
|
+
submessages.push({
|
|
293
|
+
messageType: RichSubMessageType.TEXT,
|
|
294
|
+
messageText: linkField.text + ` {{${prefix}}}¹{{/${prefix}}} `,
|
|
295
|
+
inlineEntities: [{
|
|
296
|
+
key: prefix,
|
|
297
|
+
metadata: {
|
|
298
|
+
reference_id: index + 1,
|
|
299
|
+
reference_url: url,
|
|
300
|
+
reference_title: linkField.title || 'For Donation via Saweria',
|
|
301
|
+
reference_display_name: linkField.displayName || 'Donation',
|
|
302
|
+
sources: sources || [],
|
|
303
|
+
__typename: 'GenAISearchCitationItem'
|
|
304
|
+
}
|
|
305
|
+
}]
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
else if (table) {
|
|
310
|
+
submessages.push({
|
|
311
|
+
messageType: RichSubMessageType.TABLE,
|
|
312
|
+
tableMetadata: {
|
|
313
|
+
title,
|
|
314
|
+
rows: table.map((items, index) => ({
|
|
315
|
+
isHeading: !noHeading && index == 0,
|
|
316
|
+
items
|
|
317
|
+
}))
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
if (footerText) {
|
|
322
|
+
submessages.push({
|
|
323
|
+
messageType: RichSubMessageType.TEXT,
|
|
324
|
+
messageText: footerText
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
const unified = toUnified(submessages);
|
|
329
|
+
const message = wrapToBotForwardedMessage({
|
|
330
|
+
submessages: [],
|
|
331
|
+
messageType: proto.AIRichResponseMessageType.AI_RICH_RESPONSE_TYPE_STANDARD,
|
|
332
|
+
unifiedResponse: {
|
|
333
|
+
data: Buffer.from(JSON.stringify(unified), 'utf-8') // Lia@Note 25-04-26 --- Expects "ArrayBufferLike"
|
|
334
|
+
},
|
|
335
|
+
contextInfo: {
|
|
336
|
+
isForwarded: true,
|
|
337
|
+
forwardingScore: 1,
|
|
338
|
+
forwardedAiBotMessageInfo: { botJid: '867051314767696@bot' },
|
|
339
|
+
forwardOrigin: 4,
|
|
340
|
+
botMessageSharingInfo: { forwardScore: 1 }
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
// Lia@Note 17-04-26 --- TODO: Fill mediaDetailsMetadataList and sources field
|
|
344
|
+
const { sources, mediaDetailsMetadataList } = buildAdditionalBotMetadataContext(submessages);
|
|
345
|
+
const botMetadata = message.messageContextInfo.botMetadata;
|
|
346
|
+
if (sources.length > 0) {
|
|
347
|
+
botMetadata.richResponseSourcesMetadata = { sources };
|
|
348
|
+
}
|
|
349
|
+
if (mediaDetailsMetadataList.length > 0) {
|
|
350
|
+
botMetadata.unifiedResponseMutation = { mediaDetailsMetadataList };
|
|
351
|
+
}
|
|
352
|
+
return message;
|
|
353
|
+
}
|
|
354
|
+
// Lia@Note 17-04-26 --- signature and certificateChain for proofs[] field
|
|
355
|
+
export const botMetadataSignature = () => {
|
|
356
|
+
const signature = new Uint8Array(64);
|
|
357
|
+
getRandomValues(signature);
|
|
358
|
+
return signature;
|
|
359
|
+
}
|
|
360
|
+
export const botMetadataCertificate = (length = 700) => {
|
|
361
|
+
const certificate = new Uint8Array(length);
|
|
362
|
+
certificate[0] = 48;
|
|
363
|
+
certificate[1] = 130;
|
|
364
|
+
getRandomValues(certificate.subarray(2));
|
|
365
|
+
return certificate;
|
|
366
|
+
}
|
|
367
|
+
export const wrapToBotForwardedMessage = (richResponseMessage) =>
|
|
368
|
+
({
|
|
369
|
+
messageContextInfo: {
|
|
370
|
+
botMetadata: {
|
|
371
|
+
pluginMetadata: {},
|
|
372
|
+
// Lia@Note 09-04-26 --- TODO: Fill verificationMetadata field
|
|
373
|
+
verificationMetadata: {
|
|
374
|
+
proofs: [
|
|
375
|
+
{
|
|
376
|
+
certificateChain: [
|
|
377
|
+
botMetadataCertificate(684),
|
|
378
|
+
botMetadataCertificate(892)
|
|
379
|
+
],
|
|
380
|
+
version: 1,
|
|
381
|
+
useCase: 1,
|
|
382
|
+
signature: botMetadataSignature()
|
|
383
|
+
}
|
|
384
|
+
]
|
|
385
|
+
},
|
|
386
|
+
botRenderingConfigMetadata: BOT_RENDERING_CONFIG_METADATA
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
botForwardedMessage: {
|
|
390
|
+
message: { richResponseMessage }
|
|
391
|
+
}
|
|
392
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds an ACK stanza for a received node.
|
|
3
|
+
* Pure function -- no I/O, no side effects.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors WhatsApp Web's ACK construction:
|
|
6
|
+
* - WAWebHandleMsgSendAck.sendAck / sendNack
|
|
7
|
+
* - WAWebCreateNackFromStanza.createNackFromStanza
|
|
8
|
+
*/
|
|
9
|
+
export function buildAckStanza(node, errorCode, meId) {
|
|
10
|
+
const { tag, attrs } = node;
|
|
11
|
+
const stanza = {
|
|
12
|
+
tag: 'ack',
|
|
13
|
+
attrs: {
|
|
14
|
+
id: attrs.id,
|
|
15
|
+
to: attrs.from,
|
|
16
|
+
class: tag
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
if (errorCode) {
|
|
20
|
+
stanza.attrs.error = errorCode.toString();
|
|
21
|
+
}
|
|
22
|
+
if (attrs.participant) {
|
|
23
|
+
stanza.attrs.participant = attrs.participant;
|
|
24
|
+
}
|
|
25
|
+
if (attrs.recipient) {
|
|
26
|
+
stanza.attrs.recipient = attrs.recipient;
|
|
27
|
+
}
|
|
28
|
+
// WA Web always includes type when present: `n.type || DROP_ATTR`
|
|
29
|
+
if (attrs.type) {
|
|
30
|
+
stanza.attrs.type = attrs.type;
|
|
31
|
+
}
|
|
32
|
+
// WA Web WAWebHandleMsgSendAck.sendAck/sendNack always include `from` for message-class ACKs
|
|
33
|
+
if (tag === 'message' && meId) {
|
|
34
|
+
stanza.attrs.from = meId;
|
|
35
|
+
}
|
|
36
|
+
return stanza;
|
|
37
|
+
}
|
|
@@ -1298,4 +1298,77 @@ for (const [i, DOUBLE_BYTE_TOKEN] of DOUBLE_BYTE_TOKENS.entries()) {
|
|
|
1298
1298
|
TOKEN_MAP[element] = { dict: i, index: j };
|
|
1299
1299
|
}
|
|
1300
1300
|
}
|
|
1301
|
+
|
|
1302
|
+
export const CPP_KEYWORDS = new Set([
|
|
1303
|
+
'alignas', 'alignof', 'and', 'and_eq', 'asm', 'auto', 'bitand', 'bitor', 'bool', 'break', 'case',
|
|
1304
|
+
'catch', 'char', 'class', 'compl', 'concept', 'const', 'consteval', 'constexpr', 'constinit',
|
|
1305
|
+
'const_cast', 'continue', 'co_await', 'co_return', 'co_yield', 'decltype', 'default', 'delete',
|
|
1306
|
+
'do', 'double', 'dynamic_cast', 'else', 'enum', 'explicit', 'export', 'extern', 'false', 'float',
|
|
1307
|
+
'for', 'friend', 'goto', 'if', 'inline', 'int', 'long', 'mutable', 'namespace', 'new', 'noexcept',
|
|
1308
|
+
'not', 'not_eq', 'nullptr', 'operator', 'or', 'or_eq', 'private', 'protected', 'public', 'register',
|
|
1309
|
+
'reinterpret_cast', 'requires', 'return', 'short', 'signed', 'sizeof', 'static', 'static_assert',
|
|
1310
|
+
'static_cast', 'struct', 'switch', 'template', 'this', 'thread_local', 'throw', 'true', 'try',
|
|
1311
|
+
'typedef', 'typeid', 'typename', 'union', 'unsigned', 'using', 'virtual', 'void', 'volatile',
|
|
1312
|
+
'wchar_t', 'while', 'xor', 'xor_eq'
|
|
1313
|
+
]);
|
|
1314
|
+
export const CSS_KEYWORDS = new Set([
|
|
1315
|
+
'import', 'media', 'font-face', 'keyframes', 'supports', 'charset',
|
|
1316
|
+
'important', 'root', 'hover', 'active', 'focus', 'visited', 'before', 'after',
|
|
1317
|
+
'not', 'nth-child', 'first-child', 'last-child', 'only-child',
|
|
1318
|
+
'none', 'inherit', 'initial', 'unset', 'auto', 'transparent', 'currentcolor'
|
|
1319
|
+
]);
|
|
1320
|
+
export const GO_KEYWORDS = new Set([
|
|
1321
|
+
'break', 'default', 'func', 'interface', 'select', 'case', 'defer', 'go', 'map', 'struct',
|
|
1322
|
+
'chan', 'else', 'goto', 'package', 'switch', 'const', 'fallthrough', 'if', 'range', 'type',
|
|
1323
|
+
'continue', 'for', 'import', 'return', 'var', 'true', 'false', 'nil'
|
|
1324
|
+
]);
|
|
1325
|
+
export const HTML_KEYWORDS = new Set([
|
|
1326
|
+
'html', 'head', 'body', 'title', 'meta', 'link', 'script', 'style',
|
|
1327
|
+
'header', 'footer', 'main', 'section', 'article', 'aside', 'nav',
|
|
1328
|
+
'div', 'span', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'a', 'img',
|
|
1329
|
+
'ul', 'ol', 'li', 'table', 'tr', 'td', 'th', 'thead', 'tbody',
|
|
1330
|
+
'form', 'input', 'button', 'select', 'textarea', 'label', 'option',
|
|
1331
|
+
'canvas', 'svg', 'iframe', 'video', 'audio', 'source'
|
|
1332
|
+
]);
|
|
1333
|
+
export const JS_KEYWORDS = new Set([
|
|
1334
|
+
'import', 'export', 'from', 'default', 'as',
|
|
1335
|
+
'const', 'let', 'var', 'function', 'class', 'extends', 'new',
|
|
1336
|
+
'return', 'if', 'else', 'for', 'while', 'do', 'switch', 'case', 'break', 'continue',
|
|
1337
|
+
'try', 'catch', 'finally', 'throw',
|
|
1338
|
+
'async', 'await', 'yield',
|
|
1339
|
+
'typeof', 'instanceof', 'in', 'of', 'delete', 'void',
|
|
1340
|
+
'true', 'false', 'null', 'undefined', 'NaN', 'Infinity',
|
|
1341
|
+
'this', 'super', 'static', 'get', 'set',
|
|
1342
|
+
'debugger', 'with'
|
|
1343
|
+
]);
|
|
1344
|
+
export const PYTHON_KEYWORDS = new Set([
|
|
1345
|
+
'import', 'from', 'as', 'def', 'class', 'return', 'if', 'elif', 'else',
|
|
1346
|
+
'for', 'while', 'break', 'continue', 'try', 'except', 'finally', 'raise',
|
|
1347
|
+
'with', 'yield', 'lambda', 'pass', 'del', 'global', 'nonlocal', 'assert',
|
|
1348
|
+
'True', 'False', 'None', 'and', 'or', 'not', 'in', 'is', 'async', 'await',
|
|
1349
|
+
'self', 'print'
|
|
1350
|
+
]);
|
|
1351
|
+
export const RUST_KEYWORDS = new Set([
|
|
1352
|
+
'as', 'break', 'const', 'continue', 'crate', 'else', 'enum', 'extern', 'false', 'fn', 'for',
|
|
1353
|
+
'if', 'impl', 'in', 'let', 'loop', 'match', 'mod', 'move', 'mut', 'pub', 'ref', 'return',
|
|
1354
|
+
'self', 'Self', 'static', 'struct', 'super', 'trait', 'true', 'type', 'unsafe', 'use',
|
|
1355
|
+
'where', 'while', 'async', 'await', 'dyn', 'abstract', 'become', 'box', 'do', 'final',
|
|
1356
|
+
'macro', 'override', 'priv', 'typeof', 'unsized', 'virtual', 'yield'
|
|
1357
|
+
]);
|
|
1358
|
+
export const LANGUAGE_KEYWORDS = {
|
|
1359
|
+
css: CSS_KEYWORDS,
|
|
1360
|
+
html: HTML_KEYWORDS,
|
|
1361
|
+
javascript: JS_KEYWORDS,
|
|
1362
|
+
typescript: JS_KEYWORDS,
|
|
1363
|
+
js: JS_KEYWORDS,
|
|
1364
|
+
ts: JS_KEYWORDS,
|
|
1365
|
+
python: PYTHON_KEYWORDS,
|
|
1366
|
+
py: PYTHON_KEYWORDS,
|
|
1367
|
+
go: GO_KEYWORDS,
|
|
1368
|
+
golang: GO_KEYWORDS,
|
|
1369
|
+
cpp: CPP_KEYWORDS,
|
|
1370
|
+
'c++': CPP_KEYWORDS,
|
|
1371
|
+
rust: RUST_KEYWORDS,
|
|
1372
|
+
rs: RUST_KEYWORDS,
|
|
1373
|
+
};
|
|
1301
1374
|
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { assertNodeErrorFree } from '../../WABinary/index.js';
|
|
2
|
+
import { USyncUser } from '../USyncUser.js';
|
|
3
|
+
export class USyncUsernameProtocol {
|
|
4
|
+
name = 'username';
|
|
5
|
+
getQueryElement() {
|
|
6
|
+
return {
|
|
7
|
+
tag: 'username',
|
|
8
|
+
attrs: {}
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
getUserElement(user) {
|
|
12
|
+
void user;
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
parser(node) {
|
|
16
|
+
if (node.tag === 'username') {
|
|
17
|
+
assertNodeErrorFree(node);
|
|
18
|
+
return typeof node.content === 'string' ? node.content : null;
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -3,4 +3,5 @@ export * from './USyncContactProtocol.js';
|
|
|
3
3
|
export * from './USyncStatusProtocol.js';
|
|
4
4
|
export * from './USyncDisappearingModeProtocol.js';
|
|
5
5
|
export * from './UsyncBotProfileProtocol.js';
|
|
6
|
-
export * from './UsyncLIDProtocol.js';
|
|
6
|
+
export * from './UsyncLIDProtocol.js';
|
|
7
|
+
export * from './USyncUsernameProtocol.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blckrose/baileys",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.5",
|
|
5
5
|
"description": "A WebSockets library for interacting with WhatsApp Web",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"whatsapp",
|
|
@@ -82,4 +82,4 @@
|
|
|
82
82
|
"engines": {
|
|
83
83
|
"node": ">=20.0.0"
|
|
84
84
|
}
|
|
85
|
-
}
|
|
85
|
+
}
|