@mrlegendbot/baileys 1.2.3 → 1.2.4

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 (212) hide show
  1. package/README.upstream.md +1312 -0
  2. package/WAProto/WAProto.json +1 -0
  3. package/WAProto/WAProto.proto +6275 -0
  4. package/WAProto/compiler.js +550 -0
  5. package/WAProto/index.js +2 -97691
  6. package/lib/Defaults/index.js +89 -92
  7. package/lib/Signal/Group/ciphertext-message.js +9 -10
  8. package/lib/Signal/Group/group-session-builder.js +21 -22
  9. package/lib/Signal/Group/group_cipher.js +75 -69
  10. package/lib/Signal/Group/index.js +0 -1
  11. package/lib/Signal/Group/keyhelper.js +9 -10
  12. package/lib/Signal/Group/sender-chain-key.js +21 -22
  13. package/lib/Signal/Group/sender-key-distribution-message.js +51 -60
  14. package/lib/Signal/Group/sender-key-message.js +56 -62
  15. package/lib/Signal/Group/sender-key-name.js +38 -40
  16. package/lib/Signal/Group/sender-key-record.js +33 -34
  17. package/lib/Signal/Group/sender-key-state.js +72 -76
  18. package/lib/Signal/Group/sender-message-key.js +22 -23
  19. package/lib/Signal/libsignal.js +506 -405
  20. package/lib/Signal/lid-mapping.js +276 -258
  21. package/lib/Socket/Client/index.js +0 -1
  22. package/lib/Socket/Client/types.js +6 -7
  23. package/lib/Socket/Client/websocket.js +48 -49
  24. package/lib/Socket/business.js +349 -369
  25. package/lib/Socket/chats.js +1172 -1148
  26. package/lib/Socket/communities.js +473 -413
  27. package/lib/Socket/groups.js +387 -331
  28. package/lib/Socket/index.js +6 -8
  29. package/lib/Socket/messages-recv.js +1782 -1719
  30. package/lib/Socket/messages-send.js +1503 -2450
  31. package/lib/Socket/mex.js +40 -35
  32. package/lib/Socket/newsletter.js +239 -191
  33. package/lib/Socket/socket.js +992 -923
  34. package/lib/Store/index.js +8 -0
  35. package/lib/Store/keyed-db.js +108 -0
  36. package/lib/Store/make-cache-manager-store.js +70 -0
  37. package/lib/Store/make-in-memory-store.js +417 -0
  38. package/lib/Store/make-ordered-dictionary.js +69 -0
  39. package/lib/Store/object-repository.js +27 -0
  40. package/lib/Types/Auth.js +0 -1
  41. package/lib/Types/Bussines.js +0 -1
  42. package/lib/Types/Call.js +0 -1
  43. package/lib/Types/Chat.js +1 -8
  44. package/lib/Types/Contact.js +0 -1
  45. package/lib/Types/Events.js +1 -2
  46. package/lib/Types/GroupMetadata.js +0 -1
  47. package/lib/Types/Label.js +20 -22
  48. package/lib/Types/LabelAssociation.js +2 -4
  49. package/lib/Types/Message.js +3 -5
  50. package/lib/Types/Mex.js +26 -31
  51. package/lib/Types/Product.js +0 -1
  52. package/lib/Types/Signal.js +1 -2
  53. package/lib/Types/Socket.js +2 -3
  54. package/lib/Types/State.js +4 -52
  55. package/lib/Types/USync.js +0 -1
  56. package/lib/Types/index.js +10 -11
  57. package/lib/Utils/auth-utils.js +240 -277
  58. package/lib/Utils/browser-utils.js +20 -23
  59. package/lib/Utils/business.js +200 -204
  60. package/lib/Utils/chat-utils.js +836 -810
  61. package/lib/Utils/companion-reg-client-utils.js +23 -25
  62. package/lib/Utils/crypto.js +70 -86
  63. package/lib/Utils/decode-wa-message.js +277 -284
  64. package/lib/Utils/event-buffer.js +592 -595
  65. package/lib/Utils/generics.js +312 -335
  66. package/lib/Utils/history.js +123 -115
  67. package/lib/Utils/index.js +1 -2
  68. package/lib/Utils/link-preview.js +74 -73
  69. package/lib/Utils/logger.js +3 -2
  70. package/lib/Utils/lt-hash.js +0 -6
  71. package/lib/Utils/make-mutex.js +27 -27
  72. package/lib/Utils/message-retry-manager.js +213 -254
  73. package/lib/Utils/messages-media.js +741 -715
  74. package/lib/Utils/messages.js +791 -827
  75. package/lib/Utils/noise-handler.js +215 -187
  76. package/lib/Utils/pre-key-manager.js +69 -98
  77. package/lib/Utils/process-message.js +617 -586
  78. package/lib/Utils/reporting-utils.js +553 -234
  79. package/lib/Utils/signal.js +217 -170
  80. package/lib/Utils/stanza-ack.js +27 -35
  81. package/lib/Utils/sync-action-utils.js +37 -41
  82. package/lib/Utils/tc-token-utils.js +120 -141
  83. package/lib/Utils/use-multi-file-auth-state.js +87 -105
  84. package/lib/Utils/use-sqlite-auth-state.js +162 -0
  85. package/lib/Utils/validate-connection.js +190 -188
  86. package/lib/WABinary/constants.js +28 -1294
  87. package/lib/WABinary/decode.js +245 -249
  88. package/lib/WABinary/encode.js +201 -206
  89. package/lib/WABinary/generic-utils.js +86 -89
  90. package/lib/WABinary/index.js +0 -1
  91. package/lib/WABinary/jid-utils.js +68 -77
  92. package/lib/WABinary/types.js +0 -1
  93. package/lib/WAM/BinaryInfo.js +7 -8
  94. package/lib/WAM/constants.js +19892 -22853
  95. package/lib/WAM/encode.js +121 -132
  96. package/lib/WAM/index.js +0 -1
  97. package/lib/WAUSync/Protocols/USyncContactProtocol.js +46 -43
  98. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +47 -48
  99. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +22 -23
  100. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +30 -33
  101. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +19 -20
  102. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -44
  103. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -24
  104. package/lib/WAUSync/Protocols/index.js +0 -1
  105. package/lib/WAUSync/USyncQuery.js +79 -88
  106. package/lib/WAUSync/USyncUser.js +28 -29
  107. package/lib/WAUSync/index.js +0 -1
  108. package/lib/index.js +2 -2
  109. package/package.json +22 -86
  110. package/WAProto/GenerateStatics.sh +0 -3
  111. package/WAProto/fix-imports.js +0 -85
  112. package/WAProto/index.d.ts +0 -14017
  113. package/lib/Defaults/index.d.ts +0 -75
  114. package/lib/Signal/Group/ciphertext-message.d.ts +0 -10
  115. package/lib/Signal/Group/group-session-builder.d.ts +0 -15
  116. package/lib/Signal/Group/group_cipher.d.ts +0 -17
  117. package/lib/Signal/Group/index.d.ts +0 -12
  118. package/lib/Signal/Group/keyhelper.d.ts +0 -11
  119. package/lib/Signal/Group/sender-chain-key.d.ts +0 -14
  120. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -17
  121. package/lib/Signal/Group/sender-key-message.d.ts +0 -19
  122. package/lib/Signal/Group/sender-key-name.d.ts +0 -18
  123. package/lib/Signal/Group/sender-key-record.d.ts +0 -31
  124. package/lib/Signal/Group/sender-key-state.d.ts +0 -39
  125. package/lib/Signal/Group/sender-message-key.d.ts +0 -12
  126. package/lib/Signal/libsignal.d.ts +0 -5
  127. package/lib/Signal/lid-mapping.d.ts +0 -23
  128. package/lib/Socket/Client/index.d.ts +0 -3
  129. package/lib/Socket/Client/types.d.ts +0 -16
  130. package/lib/Socket/Client/websocket.d.ts +0 -13
  131. package/lib/Socket/business.d.ts +0 -217
  132. package/lib/Socket/chats.d.ts +0 -125
  133. package/lib/Socket/communities.d.ts +0 -273
  134. package/lib/Socket/groups.d.ts +0 -161
  135. package/lib/Socket/index.d.ts +0 -260
  136. package/lib/Socket/messages-recv.d.ts +0 -203
  137. package/lib/Socket/messages-send.d.ts +0 -199
  138. package/lib/Socket/mex.d.ts +0 -3
  139. package/lib/Socket/newsletter.d.ts +0 -170
  140. package/lib/Socket/socket.d.ts +0 -59
  141. package/lib/Types/Auth.d.ts +0 -117
  142. package/lib/Types/Bussines.d.ts +0 -25
  143. package/lib/Types/Call.d.ts +0 -15
  144. package/lib/Types/Chat.d.ts +0 -124
  145. package/lib/Types/Contact.d.ts +0 -26
  146. package/lib/Types/Events.d.ts +0 -256
  147. package/lib/Types/GroupMetadata.d.ts +0 -71
  148. package/lib/Types/Label.d.ts +0 -47
  149. package/lib/Types/LabelAssociation.d.ts +0 -30
  150. package/lib/Types/Message.d.ts +0 -320
  151. package/lib/Types/Mex.d.ts +0 -141
  152. package/lib/Types/Product.d.ts +0 -79
  153. package/lib/Types/Signal.d.ts +0 -87
  154. package/lib/Types/Socket.d.ts +0 -136
  155. package/lib/Types/State.d.ts +0 -97
  156. package/lib/Types/USync.d.ts +0 -26
  157. package/lib/Types/index.d.ts +0 -66
  158. package/lib/Utils/auth-utils.d.ts +0 -24
  159. package/lib/Utils/browser-utils.d.ts +0 -4
  160. package/lib/Utils/business.d.ts +0 -23
  161. package/lib/Utils/chat-utils.d.ts +0 -100
  162. package/lib/Utils/companion-reg-client-utils.d.ts +0 -17
  163. package/lib/Utils/crypto.d.ts +0 -37
  164. package/lib/Utils/decode-wa-message.d.ts +0 -66
  165. package/lib/Utils/event-buffer.d.ts +0 -36
  166. package/lib/Utils/generics.d.ts +0 -92
  167. package/lib/Utils/history.d.ts +0 -24
  168. package/lib/Utils/identity-change-handler.d.ts +0 -44
  169. package/lib/Utils/identity-change-handler.js +0 -50
  170. package/lib/Utils/index.d.ts +0 -22
  171. package/lib/Utils/link-preview.d.ts +0 -21
  172. package/lib/Utils/logger.d.ts +0 -12
  173. package/lib/Utils/lt-hash.d.ts +0 -8
  174. package/lib/Utils/make-mutex.d.ts +0 -9
  175. package/lib/Utils/message-retry-manager.d.ts +0 -115
  176. package/lib/Utils/messages-media.d.ts +0 -133
  177. package/lib/Utils/messages.d.ts +0 -91
  178. package/lib/Utils/noise-handler.d.ts +0 -20
  179. package/lib/Utils/offline-node-processor.d.ts +0 -17
  180. package/lib/Utils/offline-node-processor.js +0 -40
  181. package/lib/Utils/pre-key-manager.d.ts +0 -28
  182. package/lib/Utils/process-message.d.ts +0 -60
  183. package/lib/Utils/reporting-utils.d.ts +0 -11
  184. package/lib/Utils/signal.d.ts +0 -47
  185. package/lib/Utils/stanza-ack.d.ts +0 -11
  186. package/lib/Utils/sync-action-utils.d.ts +0 -19
  187. package/lib/Utils/tc-token-utils.d.ts +0 -37
  188. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
  189. package/lib/Utils/validate-connection.d.ts +0 -11
  190. package/lib/WABinary/constants.d.ts +0 -28
  191. package/lib/WABinary/decode.d.ts +0 -7
  192. package/lib/WABinary/encode.d.ts +0 -3
  193. package/lib/WABinary/generic-utils.d.ts +0 -15
  194. package/lib/WABinary/index.d.ts +0 -6
  195. package/lib/WABinary/jid-utils.d.ts +0 -48
  196. package/lib/WABinary/types.d.ts +0 -19
  197. package/lib/WAM/BinaryInfo.d.ts +0 -9
  198. package/lib/WAM/constants.d.ts +0 -40
  199. package/lib/WAM/encode.d.ts +0 -3
  200. package/lib/WAM/index.d.ts +0 -4
  201. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -10
  202. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -23
  203. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -13
  204. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -13
  205. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +0 -10
  206. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -26
  207. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -10
  208. package/lib/WAUSync/Protocols/index.d.ts +0 -6
  209. package/lib/WAUSync/USyncQuery.d.ts +0 -30
  210. package/lib/WAUSync/USyncUser.d.ts +0 -17
  211. package/lib/WAUSync/index.d.ts +0 -4
  212. package/lib/index.d.ts +0 -12
@@ -1,51 +1,60 @@
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
- //# sourceMappingURL=UsyncBotProfileProtocol.js.map
@@ -1,29 +1,29 @@
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(user) {
12
- if (user.lid) {
13
- return {
14
- tag: 'lid',
15
- attrs: { jid: user.lid }
16
- };
17
- }
18
- else {
19
- return null;
2
+ constructor() {
3
+ this.name = 'lid';
4
+ }
5
+ getQueryElement() {
6
+ return {
7
+ tag: 'lid',
8
+ attrs: {}
9
+ };
10
+ }
11
+ getUserElement(user) {
12
+ if (user.lid) {
13
+ return {
14
+ tag: 'lid',
15
+ attrs: {
16
+ jid: user.lid
20
17
  }
18
+ };
19
+ } else {
20
+ return null;
21
21
  }
22
- parser(node) {
23
- if (node.tag === 'lid') {
24
- return node.attrs.val;
25
- }
26
- return null;
22
+ }
23
+ parser(node) {
24
+ if (node.tag === 'lid') {
25
+ return node.attrs.val;
27
26
  }
27
+ return null;
28
+ }
28
29
  }
29
- //# sourceMappingURL=UsyncLIDProtocol.js.map
@@ -3,4 +3,3 @@ export * from './USyncContactProtocol.js';
3
3
  export * from './USyncStatusProtocol.js';
4
4
  export * from './USyncDisappearingModeProtocol.js';
5
5
  export * from './USyncUsernameProtocol.js';
6
- //# sourceMappingURL=index.js.map
@@ -4,95 +4,86 @@ import { USyncLIDProtocol } from './Protocols/UsyncLIDProtocol.js';
4
4
  import { USyncContactProtocol, USyncDeviceProtocol, USyncDisappearingModeProtocol, USyncStatusProtocol, USyncUsernameProtocol } from './Protocols/index.js';
5
5
  import { USyncUser } from './USyncUser.js';
6
6
  export class USyncQuery {
7
- constructor() {
8
- this.protocols = [];
9
- this.users = [];
10
- this.context = 'interactive';
11
- this.mode = 'query';
7
+ constructor() {
8
+ this.protocols = [];
9
+ this.users = [];
10
+ this.context = 'interactive';
11
+ this.mode = 'query';
12
+ }
13
+ withMode(mode) {
14
+ this.mode = mode;
15
+ return this;
16
+ }
17
+ withContext(context) {
18
+ this.context = context;
19
+ return this;
20
+ }
21
+ withUser(user) {
22
+ this.users.push(user);
23
+ return this;
24
+ }
25
+ parseUSyncQueryResult(result) {
26
+ if (result?.attrs.type !== 'result') {
27
+ return;
12
28
  }
13
- withMode(mode) {
14
- this.mode = mode;
15
- return this;
16
- }
17
- withContext(context) {
18
- this.context = context;
19
- return this;
20
- }
21
- withUser(user) {
22
- this.users.push(user);
23
- return this;
24
- }
25
- parseUSyncQueryResult(result) {
26
- if (result?.attrs.type !== 'result') {
27
- return;
29
+ const protocolMap = Object.fromEntries(this.protocols.map(protocol => {
30
+ return [protocol.name, protocol.parser];
31
+ }));
32
+ const queryResult = {
33
+ list: [],
34
+ sideList: []
35
+ };
36
+ const usyncNode = getBinaryNodeChild(result, 'usync');
37
+ const listNode = usyncNode ? getBinaryNodeChild(usyncNode, 'list') : undefined;
38
+ if (listNode?.content && Array.isArray(listNode.content)) {
39
+ queryResult.list = listNode.content.reduce((acc, node) => {
40
+ const id = node?.attrs.jid;
41
+ if (id) {
42
+ const data = Array.isArray(node?.content) ? Object.fromEntries(node.content.map(content => {
43
+ const protocol = content.tag;
44
+ const parser = protocolMap[protocol];
45
+ if (parser) {
46
+ return [protocol, parser(content)];
47
+ } else {
48
+ return [protocol, null];
49
+ }
50
+ }).filter(([, b]) => b !== null)) : {};
51
+ acc.push({
52
+ ...data,
53
+ id
54
+ });
28
55
  }
29
- const protocolMap = Object.fromEntries(this.protocols.map(protocol => {
30
- return [protocol.name, protocol.parser];
31
- }));
32
- const queryResult = {
33
- // TODO: implement errors etc.
34
- list: [],
35
- sideList: []
36
- };
37
- const usyncNode = getBinaryNodeChild(result, 'usync');
38
- //TODO: implement error backoff, refresh etc.
39
- //TODO: see if there are any errors in the result node
40
- //const resultNode = getBinaryNodeChild(usyncNode, 'result')
41
- const listNode = usyncNode ? getBinaryNodeChild(usyncNode, 'list') : undefined;
42
- if (listNode?.content && Array.isArray(listNode.content)) {
43
- queryResult.list = listNode.content.reduce((acc, node) => {
44
- const id = node?.attrs.jid;
45
- if (id) {
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
- acc.push({ ...data, id });
61
- }
62
- return acc;
63
- }, []);
64
- }
65
- //TODO: implement side list
66
- //const sideListNode = getBinaryNodeChild(usyncNode, 'side_list')
67
- return queryResult;
68
- }
69
- withDeviceProtocol() {
70
- this.protocols.push(new USyncDeviceProtocol());
71
- return this;
72
- }
73
- withContactProtocol() {
74
- this.protocols.push(new USyncContactProtocol());
75
- return this;
76
- }
77
- withStatusProtocol() {
78
- this.protocols.push(new USyncStatusProtocol());
79
- return this;
80
- }
81
- withDisappearingModeProtocol() {
82
- this.protocols.push(new USyncDisappearingModeProtocol());
83
- return this;
84
- }
85
- withBotProfileProtocol() {
86
- this.protocols.push(new USyncBotProfileProtocol());
87
- return this;
88
- }
89
- withLIDProtocol() {
90
- this.protocols.push(new USyncLIDProtocol());
91
- return this;
92
- }
93
- withUsernameProtocol() {
94
- this.protocols.push(new USyncUsernameProtocol());
95
- return this;
56
+ return acc;
57
+ }, []);
96
58
  }
59
+ return queryResult;
60
+ }
61
+ withDeviceProtocol() {
62
+ this.protocols.push(new USyncDeviceProtocol());
63
+ return this;
64
+ }
65
+ withContactProtocol() {
66
+ this.protocols.push(new USyncContactProtocol());
67
+ return this;
68
+ }
69
+ withStatusProtocol() {
70
+ this.protocols.push(new USyncStatusProtocol());
71
+ return this;
72
+ }
73
+ withDisappearingModeProtocol() {
74
+ this.protocols.push(new USyncDisappearingModeProtocol());
75
+ return this;
76
+ }
77
+ withBotProfileProtocol() {
78
+ this.protocols.push(new USyncBotProfileProtocol());
79
+ return this;
80
+ }
81
+ withLIDProtocol() {
82
+ this.protocols.push(new USyncLIDProtocol());
83
+ return this;
84
+ }
85
+ withUsernameProtocol() {
86
+ this.protocols.push(new USyncUsernameProtocol());
87
+ return this;
88
+ }
97
89
  }
98
- //# sourceMappingURL=USyncQuery.js.map
@@ -1,31 +1,30 @@
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
- withUsername(username) {
15
- this.username = username;
16
- return this;
17
- }
18
- withUsernameKey(usernameKey) {
19
- this.usernameKey = usernameKey;
20
- return this;
21
- }
22
- withType(type) {
23
- this.type = type;
24
- return this;
25
- }
26
- withPersonaId(personaId) {
27
- this.personaId = personaId;
28
- return this;
29
- }
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
+ withUsername(username) {
15
+ this.username = username;
16
+ return this;
17
+ }
18
+ withUsernameKey(usernameKey) {
19
+ this.usernameKey = usernameKey;
20
+ return this;
21
+ }
22
+ withType(type) {
23
+ this.type = type;
24
+ return this;
25
+ }
26
+ withPersonaId(personaId) {
27
+ this.personaId = personaId;
28
+ return this;
29
+ }
30
30
  }
31
- //# sourceMappingURL=USyncUser.js.map
@@ -1,4 +1,3 @@
1
1
  export * from './Protocols/index.js';
2
2
  export * from './USyncQuery.js';
3
3
  export * from './USyncUser.js';
4
- //# sourceMappingURL=index.js.map
package/lib/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import makeWASocket from './Socket/index.js';
2
- export * from '../WAProto/index.js';
2
+ export * from '../WAProto/compiler.js';
3
3
  export * from './Utils/index.js';
4
4
  export * from './Types/index.js';
5
5
  export * from './Defaults/index.js';
6
6
  export * from './WABinary/index.js';
7
7
  export * from './WAM/index.js';
8
8
  export * from './WAUSync/index.js';
9
+ export * from './Store/index.js';
9
10
  export { makeWASocket };
10
11
  export default makeWASocket;
11
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,124 +1,57 @@
1
1
  {
2
2
  "name": "@mrlegendbot/baileys",
3
3
  "type": "module",
4
- "version": "1.2.3",
5
- "description": "A WebSockets library for interacting with WhatsApp Web",
4
+ "version": "1.2.4",
5
+ "description": "Self-modified fork of Baileys (based on @whiskeysockets/baileys 7.0.0-rc13) — ships prebuilt, installable as a normal semver dependency.",
6
6
  "keywords": [
7
7
  "whatsapp",
8
- "automation"
8
+ "automation",
9
+ "baileys"
9
10
  ],
10
- "homepage": "https://github.com/mrlegendbot/baileys",
11
+ "homepage": "https://github.com/vanSnowi/baileys",
11
12
  "repository": {
12
- "url": "git@github.com:mrlegendbot/baileys.git"
13
+ "type": "git",
14
+ "url": "git+https://github.com/vanSnowi/baileys.git"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/vanSnowi/baileys/issues"
13
18
  },
14
19
  "license": "MIT",
15
- "author": "mrlegendbot",
20
+ "author": "Rajeh Taher",
16
21
  "main": "lib/index.js",
17
- "types": "lib/index.d.ts",
18
22
  "files": [
19
23
  "lib/**/*",
20
24
  "WAProto/**/*",
21
25
  "engine-requirements.js"
22
26
  ],
23
27
  "scripts": {
24
- "build:all": "npm run build && npm run build:docs",
25
- "build:docs": "typedoc",
26
- "build": "tsc -P tsconfig.build.json && tsc-esm-fix --tsconfig=tsconfig.build.json --ext=.js",
27
- "changelog:last": "conventional-changelog -p angular -r 2",
28
- "changelog:preview": "conventional-changelog -p angular -u",
29
- "changelog:update": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
30
- "example": "tsx ./Example/example.ts",
31
- "gen:protobuf": "sh WAProto/GenerateStatics.sh",
32
- "format": "prettier --write \"src/**/*.{ts,js,json,md}\"",
33
- "lint": "tsc && eslint src --ext .js,.ts",
34
- "lint:fix": "npm run format && npm run lint -- --fix",
35
28
  "preinstall": "node ./engine-requirements.js",
36
- "release": "release-it",
37
- "test": "node --experimental-vm-modules ./node_modules/.bin/jest --testMatch '**/*.test.ts'",
38
- "test:e2e": "NODE_TLS_REJECT_UNAUTHORIZED=0 node --experimental-vm-modules ./node_modules/.bin/jest --runInBand --forceExit --testMatch '**/*.test-e2e.ts'",
39
- "update:version": "tsx ./scripts/update-version.ts"
29
+ "prepare": "node WAProto/compiler.js"
40
30
  },
41
31
  "dependencies": {
42
32
  "@cacheable/node-cache": "^1.4.0",
43
33
  "@hapi/boom": "^9.1.3",
44
34
  "async-mutex": "^0.5.0",
45
- "libsignal": "npm:@mrlegendbot/libsignal-node@1.1.0",
35
+ "axios": "^1.7.9",
36
+ "cache-manager": "^7.2.4",
37
+ "futoin-hkdf": "^1.5.3",
38
+ "libsignal": "^6.0.0",
39
+ "long": "^5.2.3",
46
40
  "lru-cache": "^11.1.0",
47
41
  "music-metadata": "^11.12.3",
48
42
  "p-queue": "^9.0.0",
49
43
  "pino": "^9.6",
50
44
  "protobufjs": "^7.5.6",
45
+ "uuid": "^11.0.5",
51
46
  "whatsapp-rust-bridge": "0.5.4",
52
47
  "ws": "^8.13.0"
53
48
  },
54
- "devDependencies": {
55
- "@eslint/eslintrc": "^3.3.1",
56
- "@eslint/js": "^9.31.0",
57
- "@types/jest": "^30.0.0",
58
- "@types/node": "^20.9.0",
59
- "@types/ws": "^8.0.0",
60
- "@typescript-eslint/eslint-plugin": "^8",
61
- "@typescript-eslint/parser": "^8",
62
- "@whiskeysockets/eslint-config": "^1.0.0",
63
- "conventional-changelog": "^7.1.1",
64
- "conventional-changelog-angular": "^8.0.0",
65
- "esbuild-register": "^3.6.0",
66
- "eslint": "^9",
67
- "eslint-config-prettier": "^10.1.2",
68
- "eslint-plugin-prettier": "^5.4.0",
69
- "jest": "^30.0.5",
70
- "jimp": "^1.6.1",
71
- "jiti": "^2.4.2",
72
- "json": "^11.0.0",
73
- "link-preview-js": "^3.0.0",
74
- "lru-cache": "^11.1.0",
75
- "open": "^8.4.2",
76
- "pino-pretty": "^13.1.1",
77
- "prettier": "^3.5.3",
78
- "protobufjs-cli": "^1.1.3",
79
- "release-it": "^20.0.1",
80
- "ts-jest": "^29.4.0",
81
- "tsc-esm-fix": "^3.1.2",
82
- "tsx": "^4.20.3",
83
- "typedoc": "^0.27.9",
84
- "typedoc-plugin-markdown": "4.4.2",
85
- "typescript": "^5.8.2"
86
- },
87
49
  "peerDependencies": {
88
50
  "audio-decode": "^2.1.3",
89
51
  "jimp": "^1.6.1",
90
52
  "link-preview-js": "^3.0.0",
91
53
  "sharp": "*"
92
54
  },
93
- "resolutions": {
94
- "ajv@npm:^6.12.4": "^6.14.0",
95
- "basic-ftp": "^5.2.4",
96
- "brace-expansion@npm:^1.1.7": "^1.1.13",
97
- "brace-expansion@npm:^2.0.1": "^2.0.3",
98
- "flatted": "^3.4.2",
99
- "glob@npm:^10.2.2": "^10.5.0",
100
- "glob@npm:^10.3.10": "^10.5.0",
101
- "glob@npm:^10.5.0": "^10.5.0",
102
- "handlebars": "^4.7.9",
103
- "ip-address": "^10.1.1",
104
- "js-yaml@npm:^3.13.1": "^3.14.2",
105
- "js-yaml@npm:^4.1.0": "^4.1.1",
106
- "markdown-it": "^14.1.1",
107
- "minimatch@npm:^3.0.4": "^3.1.5",
108
- "minimatch@npm:^3.1.2": "^3.1.5",
109
- "minimatch@npm:^5.0.1": "^5.1.8",
110
- "minimatch@npm:^9.0.4": "^9.0.9",
111
- "minimatch@npm:^9.0.5": "^9.0.9",
112
- "picomatch@npm:^2.0.4": "^2.3.2",
113
- "picomatch@npm:^2.3.1": "^2.3.2",
114
- "picomatch@npm:^4.0.0": "^4.0.4",
115
- "picomatch@npm:^4.0.2": "^4.0.4",
116
- "socks": "^2.8.8",
117
- "tar": "^7.5.11",
118
- "tmp": "^0.2.5",
119
- "underscore": "^1.13.8",
120
- "yaml@npm:^2.6.1": "^2.8.4"
121
- },
122
55
  "peerDependenciesMeta": {
123
56
  "audio-decode": {
124
57
  "optional": true
@@ -130,7 +63,10 @@
130
63
  "optional": true
131
64
  }
132
65
  },
133
- "packageManager": "yarn@4.9.2",
66
+ "publishConfig": {
67
+ "registry": "https://registry.npmjs.org",
68
+ "access": "public"
69
+ },
134
70
  "engines": {
135
71
  "node": ">=20.0.0"
136
72
  }
@@ -1,3 +0,0 @@
1
- yarn pbjs -t static-module --no-beautify -w es6 --no-bundle --no-delimited --no-verify --no-comments -o ./index.js ./WAProto.proto;
2
- yarn pbjs -t static-module --no-beautify -w es6 --no-bundle --no-delimited --no-verify ./WAProto.proto | yarn pbts --no-comments -o ./index.d.ts -;
3
- node ./fix-imports.js
@@ -1,85 +0,0 @@
1
- import { readFileSync, writeFileSync } from 'fs';
2
- import { exit } from 'process';
3
-
4
- const filePath = './index.js'
5
-
6
- try {
7
- let content = readFileSync(filePath, 'utf8')
8
-
9
- content = content.replace(/import \* as (\$protobuf) from/g, 'import $1 from')
10
- content = content.replace(/(['"])protobufjs\/minimal(['"])/g, '$1protobufjs/minimal.js$2')
11
-
12
- const marker = 'const $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});\n\n'
13
- const longToStringHelper =
14
- 'function longToString(value, unsigned) {\n' +
15
- '\tif (typeof value === "string") {\n' +
16
- '\t\treturn value;\n' +
17
- '\t}\n' +
18
- '\tif (typeof value === "number") {\n' +
19
- '\t\treturn String(value);\n' +
20
- '\t}\n' +
21
- '\t// Fast path: convert Long {low, high} directly via native BigInt\n' +
22
- '\t// BigInt.toString() is a native C++ operation, much faster than Long\'s pure JS division loops\n' +
23
- '\tif (value && typeof value.low === "number" && typeof value.high === "number") {\n' +
24
- '\t\tconst lo = BigInt(value.low >>> 0);\n' +
25
- '\t\tconst hi = BigInt(value.high >>> 0);\n' +
26
- '\t\tconst combined = (hi << 32n) | lo;\n' +
27
- '\t\tif (!unsigned && value.high < 0) {\n' +
28
- '\t\t\treturn (combined - (1n << 64n)).toString();\n' +
29
- '\t\t}\n' +
30
- '\t\treturn combined.toString();\n' +
31
- '\t}\n' +
32
- '\treturn String(value);\n' +
33
- '}\n\n'
34
- const longToNumberHelper =
35
- 'function longToNumber(value, unsigned) {\n' +
36
- '\tif (typeof value === "number") {\n' +
37
- '\t\treturn value;\n' +
38
- '\t}\n' +
39
- '\tif (typeof value === "string") {\n' +
40
- '\t\treturn Number(value);\n' +
41
- '\t}\n' +
42
- '\t// Fast path: convert Long {low, high} directly via native BigInt\n' +
43
- '\tif (value && typeof value.low === "number" && typeof value.high === "number") {\n' +
44
- '\t\tconst lo = BigInt(value.low >>> 0);\n' +
45
- '\t\tconst hi = BigInt(value.high >>> 0);\n' +
46
- '\t\tconst combined = (hi << 32n) | lo;\n' +
47
- '\t\tif (!unsigned && value.high < 0) {\n' +
48
- '\t\t\treturn Number(combined - (1n << 64n));\n' +
49
- '\t\t}\n' +
50
- '\t\treturn Number(combined);\n' +
51
- '\t}\n' +
52
- '\treturn Number(value);\n' +
53
- '}\n\n'
54
-
55
- if (!content.includes('function longToString(')) {
56
- const markerIndex = content.indexOf(marker)
57
- if (markerIndex === -1) {
58
- throw new Error('Unable to inject Long helpers: marker not found in WAProto index output')
59
- }
60
-
61
- content = content.replace(marker, `${marker}${longToStringHelper}${longToNumberHelper}`)
62
- } else {
63
- const longToStringRegex = /function longToString\(value, unsigned\) {\n[\s\S]*?\n}\n\n/
64
- const longToNumberRegex = /function longToNumber\(value, unsigned\) {\n[\s\S]*?\n}\n\n/
65
-
66
- if (!longToStringRegex.test(content) || !longToNumberRegex.test(content)) {
67
- throw new Error('Unable to update Long helpers: existing definitions not found')
68
- }
69
-
70
- content = content.replace(longToStringRegex, longToStringHelper)
71
- content = content.replace(longToNumberRegex, longToNumberHelper)
72
- }
73
-
74
- const longPattern = /([ \t]+d\.(\w+) = )o\.longs === String \? \$util\.Long\.prototype\.toString\.call\(m\.\2\) : o\.longs === Number \? new \$util\.LongBits\(m\.\2\.low >>> 0, m\.\2\.high >>> 0\)\.toNumber\((true)?\) : m\.\2;/g
75
- content = content.replace(longPattern, (_match, prefix, field, unsignedFlag) => {
76
- const unsignedArg = unsignedFlag ? ', true' : ''
77
- return `${prefix}o.longs === String ? longToString(m.${field}${unsignedArg}) : o.longs === Number ? longToNumber(m.${field}${unsignedArg}) : m.${field};`
78
- })
79
-
80
- writeFileSync(filePath, content, 'utf8')
81
- console.log(`✅ Fixed imports in ${filePath}`)
82
- } catch (error) {
83
- console.error(`❌ Error fixing imports: ${error.message}`)
84
- exit(1)
85
- }