@vinzsocket/baileys 2.8.9 → 2.8.20
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/lib/Defaults/index.js +75 -73
- package/lib/Signal/Group/ciphertext-message.js +9 -9
- package/lib/Signal/Group/group-session-builder.js +21 -21
- package/lib/Signal/Group/group_cipher.js +79 -81
- package/lib/Signal/Group/index.js +2 -2
- package/lib/Signal/Group/keyhelper.js +9 -9
- package/lib/Signal/Group/queue-job.js +43 -46
- package/lib/Signal/Group/sender-chain-key.js +24 -25
- package/lib/Signal/Group/sender-key-distribution-message.js +50 -58
- package/lib/Signal/Group/sender-key-message.js +55 -60
- package/lib/Signal/Group/sender-key-name.js +38 -39
- package/lib/Signal/Group/sender-key-record.js +39 -41
- package/lib/Signal/Group/sender-key-state.js +85 -89
- package/lib/Signal/Group/sender-message-key.js +22 -22
- package/lib/Signal/libsignal.js +387 -292
- package/lib/Signal/lid-mapping.js +98 -93
- package/lib/Socket/Client/types.js +6 -6
- package/lib/Socket/Client/websocket.js +44 -44
- package/lib/Socket/business.js +350 -365
- package/lib/Socket/chats.js +1019 -914
- package/lib/Socket/communities.js +454 -376
- package/lib/Socket/groups.js +378 -310
- package/lib/Socket/index.js +11 -11
- package/lib/Socket/messages-recv.js +1355 -1182
- package/lib/Socket/messages-send.js +1224 -1081
- package/lib/Socket/mex.js +40 -34
- package/lib/Socket/newsletter.js +212 -169
- package/lib/Socket/socket.js +896 -757
- package/lib/Store/index.js +1 -1
- package/lib/Store/make-cache-manager-store.js +75 -79
- package/lib/Store/make-in-memory-store.js +450 -389
- package/lib/Store/make-ordered-dictionary.js +73 -76
- package/lib/Store/object-repository.js +24 -22
- package/lib/Types/Chat.js +1 -7
- package/lib/Types/Label.js +20 -20
- package/lib/Types/LabelAssociation.js +2 -2
- package/lib/Types/Message.js +2 -2
- package/lib/Types/Newsletter.js +24 -24
- package/lib/Types/Socket.js +1 -1
- package/lib/Types/State.js +8 -8
- package/lib/Types/index.js +10 -10
- package/lib/Utils/auth-utils.js +408 -401
- package/lib/Utils/baileys-event-stream.js +44 -35
- package/lib/Utils/business.js +200 -197
- package/lib/Utils/chat-utils.js +775 -708
- package/lib/Utils/crypto.js +97 -85
- package/lib/Utils/decode-wa-message.js +240 -227
- package/lib/Utils/event-buffer.js +547 -518
- package/lib/Utils/extended-messages.js +250 -203
- package/lib/Utils/generics.js +300 -289
- package/lib/Utils/history.js +76 -69
- package/lib/Utils/lid-resolver.js +47 -42
- package/lib/Utils/link-preview.js +75 -65
- package/lib/Utils/logger.js +3 -1
- package/lib/Utils/lt-hash.js +38 -34
- package/lib/Utils/make-mutex.js +32 -34
- package/lib/Utils/mention.js +79 -86
- package/lib/Utils/message-retry-manager.js +148 -136
- package/lib/Utils/messages-media.js +652 -562
- package/lib/Utils/messages.js +753 -707
- package/lib/Utils/noise-handler.js +156 -135
- package/lib/Utils/process-message.js +404 -341
- package/lib/Utils/signal.js +180 -118
- package/lib/Utils/use-multi-file-auth-state.js +87 -91
- package/lib/Utils/validate-connection.js +167 -142
- package/lib/WABinary/constants.js +28 -1293
- package/lib/WABinary/decode.js +220 -218
- package/lib/WABinary/encode.js +199 -201
- package/lib/WABinary/generic-utils.js +80 -77
- package/lib/WABinary/jid-utils.js +41 -35
- package/lib/WAM/BinaryInfo.js +7 -7
- package/lib/WAM/constants.js +1 -15241
- package/lib/WAM/encode.js +124 -131
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +23 -23
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +51 -47
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +22 -22
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +30 -32
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +19 -19
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -43
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +17 -17
- package/lib/WAUSync/USyncQuery.js +82 -84
- package/lib/WAUSync/USyncUser.js +20 -20
- package/package.json +4 -1
|
@@ -1,51 +1,61 @@
|
|
|
1
1
|
import { getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString } from '../../WABinary/index.js';
|
|
2
2
|
import { USyncUser } from '../USyncUser.js';
|
|
3
3
|
export class USyncBotProfileProtocol {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
tag: 'bot',
|
|
17
|
-
attrs: {},
|
|
18
|
-
content: [{ tag: 'profile', attrs: { persona_id: user.personaId } }]
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
parser(node) {
|
|
22
|
-
const botNode = getBinaryNodeChild(node, 'bot');
|
|
23
|
-
const profile = getBinaryNodeChild(botNode, 'profile');
|
|
24
|
-
const commandsNode = getBinaryNodeChild(profile, 'commands');
|
|
25
|
-
const promptsNode = getBinaryNodeChild(profile, 'prompts');
|
|
26
|
-
const commands = [];
|
|
27
|
-
const prompts = [];
|
|
28
|
-
for (const command of getBinaryNodeChildren(commandsNode, 'command')) {
|
|
29
|
-
commands.push({
|
|
30
|
-
name: getBinaryNodeChildString(command, 'name'),
|
|
31
|
-
description: getBinaryNodeChildString(command, 'description')
|
|
32
|
-
});
|
|
4
|
+
constructor() {
|
|
5
|
+
this.name = 'bot';
|
|
6
|
+
}
|
|
7
|
+
getQueryElement() {
|
|
8
|
+
return {
|
|
9
|
+
tag: 'bot',
|
|
10
|
+
attrs: {},
|
|
11
|
+
content: [{
|
|
12
|
+
tag: 'profile',
|
|
13
|
+
attrs: {
|
|
14
|
+
v: '1'
|
|
33
15
|
}
|
|
34
|
-
|
|
35
|
-
|
|
16
|
+
}]
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
getUserElement(user) {
|
|
20
|
+
return {
|
|
21
|
+
tag: 'bot',
|
|
22
|
+
attrs: {},
|
|
23
|
+
content: [{
|
|
24
|
+
tag: 'profile',
|
|
25
|
+
attrs: {
|
|
26
|
+
persona_id: user.personaId
|
|
36
27
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
28
|
+
}]
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
parser(node) {
|
|
32
|
+
const botNode = getBinaryNodeChild(node, 'bot');
|
|
33
|
+
const profile = getBinaryNodeChild(botNode, 'profile');
|
|
34
|
+
const commandsNode = getBinaryNodeChild(profile, 'commands');
|
|
35
|
+
const promptsNode = getBinaryNodeChild(profile, 'prompts');
|
|
36
|
+
const commands = [];
|
|
37
|
+
const prompts = [];
|
|
38
|
+
for (const command of getBinaryNodeChildren(commandsNode, 'command')) {
|
|
39
|
+
commands.push({
|
|
40
|
+
name: getBinaryNodeChildString(command, 'name'),
|
|
41
|
+
description: getBinaryNodeChildString(command, 'description')
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
for (const prompt of getBinaryNodeChildren(promptsNode, 'prompt')) {
|
|
45
|
+
prompts.push(`${getBinaryNodeChildString(prompt, 'emoji')} ${getBinaryNodeChildString(prompt, 'text')}`);
|
|
49
46
|
}
|
|
47
|
+
return {
|
|
48
|
+
isDefault: !!getBinaryNodeChild(profile, 'default'),
|
|
49
|
+
jid: node.attrs.jid,
|
|
50
|
+
name: getBinaryNodeChildString(profile, 'name'),
|
|
51
|
+
attributes: getBinaryNodeChildString(profile, 'attributes'),
|
|
52
|
+
description: getBinaryNodeChildString(profile, 'description'),
|
|
53
|
+
category: getBinaryNodeChildString(profile, 'category'),
|
|
54
|
+
personaId: profile.attrs['persona_id'],
|
|
55
|
+
commandsDescription: getBinaryNodeChildString(commandsNode, 'description'),
|
|
56
|
+
commands,
|
|
57
|
+
prompts
|
|
58
|
+
};
|
|
59
|
+
}
|
|
50
60
|
}
|
|
51
61
|
//# sourceMappingURL=UsyncBotProfileProtocol.js.map
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
export class USyncLIDProtocol {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
return null;
|
|
2
|
+
constructor() {
|
|
3
|
+
this.name = 'lid';
|
|
4
|
+
}
|
|
5
|
+
getQueryElement() {
|
|
6
|
+
return {
|
|
7
|
+
tag: 'lid',
|
|
8
|
+
attrs: {}
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
getUserElement() {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
parser(node) {
|
|
15
|
+
if (node.tag === 'lid') {
|
|
16
|
+
return node.attrs.val;
|
|
19
17
|
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
20
|
}
|
|
21
21
|
//# sourceMappingURL=UsyncLIDProtocol.js.map
|
|
@@ -5,92 +5,90 @@ import { USyncUsernameProtocol } from './Protocols/USyncUsernameProtocol.js';
|
|
|
5
5
|
import { USyncContactProtocol, USyncDeviceProtocol, USyncDisappearingModeProtocol, USyncStatusProtocol } from './Protocols/index.js';
|
|
6
6
|
import { USyncUser } from './USyncUser.js';
|
|
7
7
|
export class USyncQuery {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
constructor() {
|
|
9
|
+
this.protocols = [];
|
|
10
|
+
this.users = [];
|
|
11
|
+
this.context = 'interactive';
|
|
12
|
+
this.mode = 'query';
|
|
13
|
+
}
|
|
14
|
+
withMode(mode) {
|
|
15
|
+
this.mode = mode;
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
withContext(context) {
|
|
19
|
+
this.context = context;
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
withUser(user) {
|
|
23
|
+
this.users.push(user);
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
parseUSyncQueryResult(result) {
|
|
27
|
+
if (result.attrs.type !== 'result') {
|
|
28
|
+
return;
|
|
13
29
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
const protocolMap = Object.fromEntries(this.protocols.map(protocol => {
|
|
31
|
+
return [protocol.name, protocol.parser];
|
|
32
|
+
}));
|
|
33
|
+
const queryResult = {
|
|
34
|
+
// TODO: implement errors etc.
|
|
35
|
+
list: [],
|
|
36
|
+
sideList: []
|
|
37
|
+
};
|
|
38
|
+
const usyncNode = getBinaryNodeChild(result, 'usync');
|
|
39
|
+
//TODO: implement error backoff, refresh etc.
|
|
40
|
+
//TODO: see if there are any errors in the result node
|
|
41
|
+
//const resultNode = getBinaryNodeChild(usyncNode, 'result')
|
|
42
|
+
const listNode = getBinaryNodeChild(usyncNode, 'list');
|
|
43
|
+
if (Array.isArray(listNode?.content) && typeof listNode !== 'undefined') {
|
|
44
|
+
queryResult.list = listNode.content.map(node => {
|
|
45
|
+
const id = node?.attrs.jid;
|
|
46
|
+
const data = Array.isArray(node?.content) ? Object.fromEntries(node.content.map(content => {
|
|
47
|
+
const protocol = content.tag;
|
|
48
|
+
const parser = protocolMap[protocol];
|
|
49
|
+
if (parser) {
|
|
50
|
+
return [protocol, parser(content)];
|
|
51
|
+
} else {
|
|
52
|
+
return [protocol, null];
|
|
53
|
+
}
|
|
54
|
+
}).filter(([, b]) => b !== null)) : {};
|
|
55
|
+
return {
|
|
56
|
+
...data,
|
|
57
|
+
id
|
|
37
58
|
};
|
|
38
|
-
|
|
39
|
-
//TODO: implement error backoff, refresh etc.
|
|
40
|
-
//TODO: see if there are any errors in the result node
|
|
41
|
-
//const resultNode = getBinaryNodeChild(usyncNode, 'result')
|
|
42
|
-
const listNode = getBinaryNodeChild(usyncNode, 'list');
|
|
43
|
-
if (Array.isArray(listNode?.content) && typeof listNode !== 'undefined') {
|
|
44
|
-
queryResult.list = listNode.content.map(node => {
|
|
45
|
-
const id = node?.attrs.jid;
|
|
46
|
-
const data = Array.isArray(node?.content)
|
|
47
|
-
? Object.fromEntries(node.content
|
|
48
|
-
.map(content => {
|
|
49
|
-
const protocol = content.tag;
|
|
50
|
-
const parser = protocolMap[protocol];
|
|
51
|
-
if (parser) {
|
|
52
|
-
return [protocol, parser(content)];
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
return [protocol, null];
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
.filter(([, b]) => b !== null))
|
|
59
|
-
: {};
|
|
60
|
-
return { ...data, id };
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
//TODO: implement side list
|
|
64
|
-
//const sideListNode = getBinaryNodeChild(usyncNode, 'side_list')
|
|
65
|
-
return queryResult;
|
|
66
|
-
}
|
|
67
|
-
withDeviceProtocol() {
|
|
68
|
-
this.protocols.push(new USyncDeviceProtocol());
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
withContactProtocol() {
|
|
72
|
-
this.protocols.push(new USyncContactProtocol());
|
|
73
|
-
return this;
|
|
74
|
-
}
|
|
75
|
-
withStatusProtocol() {
|
|
76
|
-
this.protocols.push(new USyncStatusProtocol());
|
|
77
|
-
return this;
|
|
78
|
-
}
|
|
79
|
-
withDisappearingModeProtocol() {
|
|
80
|
-
this.protocols.push(new USyncDisappearingModeProtocol());
|
|
81
|
-
return this;
|
|
82
|
-
}
|
|
83
|
-
withBotProfileProtocol() {
|
|
84
|
-
this.protocols.push(new USyncBotProfileProtocol());
|
|
85
|
-
return this;
|
|
86
|
-
}
|
|
87
|
-
withLIDProtocol() {
|
|
88
|
-
this.protocols.push(new USyncLIDProtocol());
|
|
89
|
-
return this;
|
|
90
|
-
}
|
|
91
|
-
withUsernameProtocol() {
|
|
92
|
-
this.protocols.push(new USyncUsernameProtocol());
|
|
93
|
-
return this;
|
|
59
|
+
});
|
|
94
60
|
}
|
|
61
|
+
//TODO: implement side list
|
|
62
|
+
//const sideListNode = getBinaryNodeChild(usyncNode, 'side_list')
|
|
63
|
+
return queryResult;
|
|
64
|
+
}
|
|
65
|
+
withDeviceProtocol() {
|
|
66
|
+
this.protocols.push(new USyncDeviceProtocol());
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
withContactProtocol() {
|
|
70
|
+
this.protocols.push(new USyncContactProtocol());
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
withStatusProtocol() {
|
|
74
|
+
this.protocols.push(new USyncStatusProtocol());
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
withDisappearingModeProtocol() {
|
|
78
|
+
this.protocols.push(new USyncDisappearingModeProtocol());
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
withBotProfileProtocol() {
|
|
82
|
+
this.protocols.push(new USyncBotProfileProtocol());
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
withLIDProtocol() {
|
|
86
|
+
this.protocols.push(new USyncLIDProtocol());
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
withUsernameProtocol() {
|
|
90
|
+
this.protocols.push(new USyncUsernameProtocol());
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
95
93
|
}
|
|
96
94
|
//# sourceMappingURL=USyncQuery.js.map
|
package/lib/WAUSync/USyncUser.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
export class USyncUser {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
withId(id) {
|
|
3
|
+
this.id = id;
|
|
4
|
+
return this;
|
|
5
|
+
}
|
|
6
|
+
withLid(lid) {
|
|
7
|
+
this.lid = lid;
|
|
8
|
+
return this;
|
|
9
|
+
}
|
|
10
|
+
withPhone(phone) {
|
|
11
|
+
this.phone = phone;
|
|
12
|
+
return this;
|
|
13
|
+
}
|
|
14
|
+
withType(type) {
|
|
15
|
+
this.type = type;
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
withPersonaId(personaId) {
|
|
19
|
+
this.personaId = personaId;
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
22
|
}
|
|
23
23
|
//# sourceMappingURL=USyncUser.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vinzsocket/baileys",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.8.
|
|
4
|
+
"version": "2.8.20",
|
|
5
5
|
"description": "A WebSockets library for interacting with WhatsApp Web",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"whatsapp",
|
|
@@ -41,6 +41,9 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@adiwajshing/keyed-db": "^0.2.4",
|
|
44
|
+
"@babel/cli": "^8.0.1",
|
|
45
|
+
"@babel/core": "^8.0.1",
|
|
46
|
+
"@babel/preset-env": "^8.0.2",
|
|
44
47
|
"@cacheable/node-cache": "^1.4.0",
|
|
45
48
|
"@hapi/boom": "^9.1.3",
|
|
46
49
|
"async-mutex": "^0.5.0",
|