@vinzsocket/baileys 2.8.10 → 2.8.30

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