@mrlegendbot/baileys 1.2.5 → 1.2.6

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 (214) hide show
  1. package/WAProto/GenerateStatics.sh +3 -0
  2. package/WAProto/fix-imports.js +85 -0
  3. package/WAProto/index.d.ts +14017 -0
  4. package/WAProto/index.js +97691 -2
  5. package/lib/Defaults/index.d.ts +75 -0
  6. package/lib/Defaults/index.js +92 -89
  7. package/lib/Menu/index.d.ts +42 -0
  8. package/lib/Menu/index.js +283 -0
  9. package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
  10. package/lib/Signal/Group/ciphertext-message.js +10 -9
  11. package/lib/Signal/Group/group-session-builder.d.ts +15 -0
  12. package/lib/Signal/Group/group-session-builder.js +22 -21
  13. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  14. package/lib/Signal/Group/group_cipher.js +69 -75
  15. package/lib/Signal/Group/index.d.ts +12 -0
  16. package/lib/Signal/Group/index.js +1 -0
  17. package/lib/Signal/Group/keyhelper.d.ts +11 -0
  18. package/lib/Signal/Group/keyhelper.js +10 -9
  19. package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
  20. package/lib/Signal/Group/sender-chain-key.js +22 -21
  21. package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
  22. package/lib/Signal/Group/sender-key-distribution-message.js +60 -51
  23. package/lib/Signal/Group/sender-key-message.d.ts +19 -0
  24. package/lib/Signal/Group/sender-key-message.js +62 -56
  25. package/lib/Signal/Group/sender-key-name.d.ts +18 -0
  26. package/lib/Signal/Group/sender-key-name.js +40 -38
  27. package/lib/Signal/Group/sender-key-record.d.ts +31 -0
  28. package/lib/Signal/Group/sender-key-record.js +34 -33
  29. package/lib/Signal/Group/sender-key-state.d.ts +39 -0
  30. package/lib/Signal/Group/sender-key-state.js +76 -72
  31. package/lib/Signal/Group/sender-message-key.d.ts +12 -0
  32. package/lib/Signal/Group/sender-message-key.js +23 -22
  33. package/lib/Signal/libsignal.d.ts +5 -0
  34. package/lib/Signal/libsignal.js +405 -506
  35. package/lib/Signal/lid-mapping.d.ts +23 -0
  36. package/lib/Signal/lid-mapping.js +258 -276
  37. package/lib/Socket/Client/index.d.ts +3 -0
  38. package/lib/Socket/Client/index.js +1 -0
  39. package/lib/Socket/Client/types.d.ts +16 -0
  40. package/lib/Socket/Client/types.js +7 -6
  41. package/lib/Socket/Client/websocket.d.ts +13 -0
  42. package/lib/Socket/Client/websocket.js +49 -48
  43. package/lib/Socket/business.d.ts +217 -0
  44. package/lib/Socket/business.js +369 -349
  45. package/lib/Socket/chats.d.ts +125 -0
  46. package/lib/Socket/chats.js +1148 -1172
  47. package/lib/Socket/communities.d.ts +273 -0
  48. package/lib/Socket/communities.js +413 -473
  49. package/lib/Socket/groups.d.ts +161 -0
  50. package/lib/Socket/groups.js +331 -387
  51. package/lib/Socket/index.d.ts +267 -0
  52. package/lib/Socket/index.js +19 -6
  53. package/lib/Socket/messages-recv.d.ts +203 -0
  54. package/lib/Socket/messages-recv.js +1719 -1782
  55. package/lib/Socket/messages-send.d.ts +199 -0
  56. package/lib/Socket/messages-send.js +2451 -1555
  57. package/lib/Socket/mex.d.ts +3 -0
  58. package/lib/Socket/mex.js +35 -40
  59. package/lib/Socket/newsletter.d.ts +170 -0
  60. package/lib/Socket/newsletter.js +191 -239
  61. package/lib/Socket/socket.d.ts +59 -0
  62. package/lib/Socket/socket.js +923 -992
  63. package/lib/Types/Auth.d.ts +117 -0
  64. package/lib/Types/Auth.js +1 -0
  65. package/lib/Types/Bussines.d.ts +25 -0
  66. package/lib/Types/Bussines.js +1 -0
  67. package/lib/Types/Call.d.ts +15 -0
  68. package/lib/Types/Call.js +1 -0
  69. package/lib/Types/Chat.d.ts +124 -0
  70. package/lib/Types/Chat.js +8 -1
  71. package/lib/Types/Contact.d.ts +26 -0
  72. package/lib/Types/Contact.js +1 -0
  73. package/lib/Types/Events.d.ts +256 -0
  74. package/lib/Types/Events.js +2 -1
  75. package/lib/Types/GroupMetadata.d.ts +71 -0
  76. package/lib/Types/GroupMetadata.js +1 -0
  77. package/lib/Types/Label.d.ts +47 -0
  78. package/lib/Types/Label.js +22 -20
  79. package/lib/Types/LabelAssociation.d.ts +30 -0
  80. package/lib/Types/LabelAssociation.js +4 -2
  81. package/lib/Types/Message.d.ts +320 -0
  82. package/lib/Types/Message.js +5 -3
  83. package/lib/Types/Mex.d.ts +141 -0
  84. package/lib/Types/Mex.js +31 -26
  85. package/lib/Types/Product.d.ts +79 -0
  86. package/lib/Types/Product.js +1 -0
  87. package/lib/Types/Signal.d.ts +87 -0
  88. package/lib/Types/Signal.js +2 -1
  89. package/lib/Types/Socket.d.ts +136 -0
  90. package/lib/Types/Socket.js +3 -2
  91. package/lib/Types/State.d.ts +97 -0
  92. package/lib/Types/State.js +52 -4
  93. package/lib/Types/USync.d.ts +26 -0
  94. package/lib/Types/USync.js +1 -0
  95. package/lib/Types/index.d.ts +66 -0
  96. package/lib/Types/index.js +11 -10
  97. package/lib/Utils/auth-utils.d.ts +24 -0
  98. package/lib/Utils/auth-utils.js +277 -240
  99. package/lib/Utils/browser-utils.d.ts +4 -0
  100. package/lib/Utils/browser-utils.js +23 -20
  101. package/lib/Utils/business.d.ts +23 -0
  102. package/lib/Utils/business.js +204 -200
  103. package/lib/Utils/chat-utils.d.ts +100 -0
  104. package/lib/Utils/chat-utils.js +810 -836
  105. package/lib/Utils/companion-reg-client-utils.d.ts +17 -0
  106. package/lib/Utils/companion-reg-client-utils.js +25 -23
  107. package/lib/Utils/crypto.d.ts +37 -0
  108. package/lib/Utils/crypto.js +86 -70
  109. package/lib/Utils/decode-wa-message.d.ts +66 -0
  110. package/lib/Utils/decode-wa-message.js +284 -277
  111. package/lib/Utils/event-buffer.d.ts +36 -0
  112. package/lib/Utils/event-buffer.js +595 -592
  113. package/lib/Utils/generics.d.ts +92 -0
  114. package/lib/Utils/generics.js +335 -312
  115. package/lib/Utils/history.d.ts +24 -0
  116. package/lib/Utils/history.js +115 -123
  117. package/lib/Utils/identity-change-handler.d.ts +44 -0
  118. package/lib/Utils/identity-change-handler.js +50 -0
  119. package/lib/Utils/index.d.ts +22 -0
  120. package/lib/Utils/index.js +2 -1
  121. package/lib/Utils/link-preview.d.ts +21 -0
  122. package/lib/Utils/link-preview.js +73 -74
  123. package/lib/Utils/logger.d.ts +12 -0
  124. package/lib/Utils/logger.js +2 -3
  125. package/lib/Utils/lt-hash.d.ts +8 -0
  126. package/lib/Utils/lt-hash.js +6 -0
  127. package/lib/Utils/make-mutex.d.ts +9 -0
  128. package/lib/Utils/make-mutex.js +27 -27
  129. package/lib/Utils/message-retry-manager.d.ts +115 -0
  130. package/lib/Utils/message-retry-manager.js +254 -213
  131. package/lib/Utils/messages-media.d.ts +133 -0
  132. package/lib/Utils/messages-media.js +715 -741
  133. package/lib/Utils/messages.d.ts +91 -0
  134. package/lib/Utils/messages.js +827 -791
  135. package/lib/Utils/noise-handler.d.ts +20 -0
  136. package/lib/Utils/noise-handler.js +187 -215
  137. package/lib/Utils/offline-node-processor.d.ts +17 -0
  138. package/lib/Utils/offline-node-processor.js +40 -0
  139. package/lib/Utils/pre-key-manager.d.ts +28 -0
  140. package/lib/Utils/pre-key-manager.js +98 -69
  141. package/lib/Utils/process-message.d.ts +60 -0
  142. package/lib/Utils/process-message.js +586 -617
  143. package/lib/Utils/reporting-utils.d.ts +11 -0
  144. package/lib/Utils/reporting-utils.js +234 -553
  145. package/lib/Utils/signal.d.ts +47 -0
  146. package/lib/Utils/signal.js +170 -217
  147. package/lib/Utils/stanza-ack.d.ts +11 -0
  148. package/lib/Utils/stanza-ack.js +35 -27
  149. package/lib/Utils/sync-action-utils.d.ts +19 -0
  150. package/lib/Utils/sync-action-utils.js +41 -37
  151. package/lib/Utils/tc-token-utils.d.ts +37 -0
  152. package/lib/Utils/tc-token-utils.js +141 -120
  153. package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
  154. package/lib/Utils/use-multi-file-auth-state.js +105 -87
  155. package/lib/Utils/validate-connection.d.ts +11 -0
  156. package/lib/Utils/validate-connection.js +188 -190
  157. package/lib/WABinary/constants.d.ts +28 -0
  158. package/lib/WABinary/constants.js +1294 -28
  159. package/lib/WABinary/decode.d.ts +7 -0
  160. package/lib/WABinary/decode.js +249 -245
  161. package/lib/WABinary/encode.d.ts +3 -0
  162. package/lib/WABinary/encode.js +206 -201
  163. package/lib/WABinary/generic-utils.d.ts +15 -0
  164. package/lib/WABinary/generic-utils.js +89 -86
  165. package/lib/WABinary/index.d.ts +6 -0
  166. package/lib/WABinary/index.js +1 -0
  167. package/lib/WABinary/jid-utils.d.ts +48 -0
  168. package/lib/WABinary/jid-utils.js +77 -68
  169. package/lib/WABinary/types.d.ts +19 -0
  170. package/lib/WABinary/types.js +1 -0
  171. package/lib/WAM/BinaryInfo.d.ts +9 -0
  172. package/lib/WAM/BinaryInfo.js +8 -7
  173. package/lib/WAM/constants.d.ts +40 -0
  174. package/lib/WAM/constants.js +22853 -19892
  175. package/lib/WAM/encode.d.ts +3 -0
  176. package/lib/WAM/encode.js +132 -121
  177. package/lib/WAM/index.d.ts +4 -0
  178. package/lib/WAM/index.js +1 -0
  179. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
  180. package/lib/WAUSync/Protocols/USyncContactProtocol.js +43 -46
  181. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
  182. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +48 -47
  183. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
  184. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +23 -22
  185. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
  186. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +33 -30
  187. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
  188. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +20 -19
  189. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
  190. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +44 -53
  191. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
  192. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -24
  193. package/lib/WAUSync/Protocols/index.d.ts +6 -0
  194. package/lib/WAUSync/Protocols/index.js +1 -0
  195. package/lib/WAUSync/USyncQuery.d.ts +30 -0
  196. package/lib/WAUSync/USyncQuery.js +88 -79
  197. package/lib/WAUSync/USyncUser.d.ts +17 -0
  198. package/lib/WAUSync/USyncUser.js +29 -28
  199. package/lib/WAUSync/index.d.ts +4 -0
  200. package/lib/WAUSync/index.js +1 -0
  201. package/lib/index.d.ts +12 -0
  202. package/lib/index.js +2 -2
  203. package/package.json +86 -22
  204. package/README.upstream.md +0 -1312
  205. package/WAProto/WAProto.json +0 -1
  206. package/WAProto/WAProto.proto +0 -6275
  207. package/WAProto/compiler.js +0 -550
  208. package/lib/Store/index.js +0 -8
  209. package/lib/Store/keyed-db.js +0 -108
  210. package/lib/Store/make-cache-manager-store.js +0 -70
  211. package/lib/Store/make-in-memory-store.js +0 -417
  212. package/lib/Store/make-ordered-dictionary.js +0 -69
  213. package/lib/Store/object-repository.js +0 -27
  214. package/lib/Utils/use-sqlite-auth-state.js +0 -162
@@ -1,35 +1,38 @@
1
1
  import { assertNodeErrorFree } from '../../WABinary/index.js';
2
2
  export class USyncStatusProtocol {
3
- constructor() {
4
- this.name = 'status';
5
- }
6
- getQueryElement() {
7
- return {
8
- tag: 'status',
9
- attrs: {}
10
- };
11
- }
12
- getUserElement() {
13
- return null;
14
- }
15
- parser(node) {
16
- if (node.tag === 'status') {
17
- assertNodeErrorFree(node);
18
- let status = node?.content?.toString() ?? null;
19
- const setAt = new Date(+(node?.attrs.t || 0) * 1000);
20
- if (!status) {
21
- if (node.attrs?.code && +node.attrs.code === 401) {
22
- status = '';
23
- } else {
24
- status = null;
3
+ constructor() {
4
+ this.name = 'status';
5
+ }
6
+ getQueryElement() {
7
+ return {
8
+ tag: 'status',
9
+ attrs: {}
10
+ };
11
+ }
12
+ getUserElement() {
13
+ return null;
14
+ }
15
+ parser(node) {
16
+ if (node.tag === 'status') {
17
+ assertNodeErrorFree(node);
18
+ let status = node?.content?.toString() ?? null;
19
+ const setAt = new Date(+(node?.attrs.t || 0) * 1000);
20
+ if (!status) {
21
+ if (node.attrs?.code && +node.attrs.code === 401) {
22
+ status = '';
23
+ }
24
+ else {
25
+ status = null;
26
+ }
27
+ }
28
+ else if (typeof status === 'string' && status.length === 0) {
29
+ status = null;
30
+ }
31
+ return {
32
+ status,
33
+ setAt
34
+ };
25
35
  }
26
- } else if (typeof status === 'string' && status.length === 0) {
27
- status = null;
28
- }
29
- return {
30
- status,
31
- setAt
32
- };
33
36
  }
34
- }
35
37
  }
38
+ //# sourceMappingURL=USyncStatusProtocol.js.map
@@ -0,0 +1,10 @@
1
+ import type { USyncQueryProtocol } from '../../Types/USync.js';
2
+ import { type BinaryNode } from '../../WABinary/index.js';
3
+ import { USyncUser } from '../USyncUser.js';
4
+ export declare class USyncUsernameProtocol implements USyncQueryProtocol {
5
+ name: string;
6
+ getQueryElement(): BinaryNode;
7
+ getUserElement(user: USyncUser): BinaryNode | null;
8
+ parser(node: BinaryNode): string | null;
9
+ }
10
+ //# sourceMappingURL=USyncUsernameProtocol.d.ts.map
@@ -1,24 +1,25 @@
1
1
  import { assertNodeErrorFree } from '../../WABinary/index.js';
2
2
  import { USyncUser } from '../USyncUser.js';
3
3
  export class USyncUsernameProtocol {
4
- constructor() {
5
- this.name = 'username';
6
- }
7
- getQueryElement() {
8
- return {
9
- tag: 'username',
10
- attrs: {}
11
- };
12
- }
13
- getUserElement(user) {
14
- void user;
15
- return null;
16
- }
17
- parser(node) {
18
- if (node.tag === 'username') {
19
- assertNodeErrorFree(node);
20
- return typeof node.content === 'string' ? node.content : null;
4
+ constructor() {
5
+ this.name = 'username';
6
+ }
7
+ getQueryElement() {
8
+ return {
9
+ tag: 'username',
10
+ attrs: {}
11
+ };
12
+ }
13
+ getUserElement(user) {
14
+ void user;
15
+ return null;
16
+ }
17
+ parser(node) {
18
+ if (node.tag === 'username') {
19
+ assertNodeErrorFree(node);
20
+ return typeof node.content === 'string' ? node.content : null;
21
+ }
22
+ return null;
21
23
  }
22
- return null;
23
- }
24
24
  }
25
+ //# sourceMappingURL=USyncUsernameProtocol.js.map
@@ -0,0 +1,26 @@
1
+ import type { USyncQueryProtocol } from '../../Types/USync.js';
2
+ import { type BinaryNode } from '../../WABinary/index.js';
3
+ import { USyncUser } from '../USyncUser.js';
4
+ export type BotProfileCommand = {
5
+ name: string;
6
+ description: string;
7
+ };
8
+ export type BotProfileInfo = {
9
+ jid: string;
10
+ name: string;
11
+ attributes: string;
12
+ description: string;
13
+ category: string;
14
+ isDefault: boolean;
15
+ prompts: string[];
16
+ personaId: string;
17
+ commands: BotProfileCommand[];
18
+ commandsDescription: string;
19
+ };
20
+ export declare class USyncBotProfileProtocol implements USyncQueryProtocol {
21
+ name: string;
22
+ getQueryElement(): BinaryNode;
23
+ getUserElement(user: USyncUser): BinaryNode;
24
+ parser(node: BinaryNode): BotProfileInfo;
25
+ }
26
+ //# sourceMappingURL=UsyncBotProfileProtocol.d.ts.map
@@ -1,60 +1,51 @@
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: [{
12
- tag: 'profile',
13
- attrs: {
14
- v: '1'
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
+ });
15
33
  }
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
34
+ for (const prompt of getBinaryNodeChildren(promptsNode, 'prompt')) {
35
+ prompts.push(`${getBinaryNodeChildString(prompt, 'emoji')} ${getBinaryNodeChildString(prompt, 'text')}`);
27
36
  }
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')}`);
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
+ };
46
49
  }
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
- }
60
50
  }
51
+ //# sourceMappingURL=UsyncBotProfileProtocol.js.map
@@ -0,0 +1,10 @@
1
+ import type { USyncQueryProtocol } from '../../Types/USync.js';
2
+ import type { BinaryNode } from '../../WABinary/index.js';
3
+ import type { USyncUser } from '../USyncUser.js';
4
+ export declare class USyncLIDProtocol implements USyncQueryProtocol {
5
+ name: string;
6
+ getQueryElement(): BinaryNode;
7
+ getUserElement(user: USyncUser): BinaryNode | null;
8
+ parser(node: BinaryNode): string | null;
9
+ }
10
+ //# sourceMappingURL=UsyncLIDProtocol.d.ts.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: {
16
- jid: user.lid
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;
17
20
  }
18
- };
19
- } else {
20
- return null;
21
21
  }
22
- }
23
- parser(node) {
24
- if (node.tag === 'lid') {
25
- return node.attrs.val;
22
+ parser(node) {
23
+ if (node.tag === 'lid') {
24
+ return node.attrs.val;
25
+ }
26
+ return null;
26
27
  }
27
- return null;
28
- }
29
28
  }
29
+ //# sourceMappingURL=UsyncLIDProtocol.js.map
@@ -0,0 +1,6 @@
1
+ export * from './USyncDeviceProtocol.js';
2
+ export * from './USyncContactProtocol.js';
3
+ export * from './USyncStatusProtocol.js';
4
+ export * from './USyncDisappearingModeProtocol.js';
5
+ export * from './USyncUsernameProtocol.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -3,3 +3,4 @@ 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
@@ -0,0 +1,30 @@
1
+ import type { USyncQueryProtocol } from '../Types/USync.js';
2
+ import { type BinaryNode } from '../WABinary/index.js';
3
+ import { USyncUser } from './USyncUser.js';
4
+ export type USyncQueryResultList = {
5
+ [protocol: string]: unknown;
6
+ id: string;
7
+ };
8
+ export type USyncQueryResult = {
9
+ list: USyncQueryResultList[];
10
+ sideList: USyncQueryResultList[];
11
+ };
12
+ export declare class USyncQuery {
13
+ protocols: USyncQueryProtocol[];
14
+ users: USyncUser[];
15
+ context: string;
16
+ mode: string;
17
+ constructor();
18
+ withMode(mode: string): this;
19
+ withContext(context: string): this;
20
+ withUser(user: USyncUser): this;
21
+ parseUSyncQueryResult(result: BinaryNode | undefined): USyncQueryResult | undefined;
22
+ withDeviceProtocol(): this;
23
+ withContactProtocol(): this;
24
+ withStatusProtocol(): this;
25
+ withDisappearingModeProtocol(): this;
26
+ withBotProfileProtocol(): this;
27
+ withLIDProtocol(): this;
28
+ withUsernameProtocol(): this;
29
+ }
30
+ //# sourceMappingURL=USyncQuery.d.ts.map
@@ -4,86 +4,95 @@ 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';
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;
7
+ constructor() {
8
+ this.protocols = [];
9
+ this.users = [];
10
+ this.context = 'interactive';
11
+ this.mode = 'query';
28
12
  }
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
- });
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;
55
28
  }
56
- return acc;
57
- }, []);
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;
58
96
  }
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
- }
89
97
  }
98
+ //# sourceMappingURL=USyncQuery.js.map
@@ -0,0 +1,17 @@
1
+ export declare class USyncUser {
2
+ id?: string;
3
+ lid?: string;
4
+ phone?: string;
5
+ username?: string;
6
+ usernameKey?: string;
7
+ type?: string;
8
+ personaId?: string;
9
+ withId(id: string): this;
10
+ withLid(lid: string): this;
11
+ withPhone(phone: string): this;
12
+ withUsername(username: string): this;
13
+ withUsernameKey(usernameKey: string): this;
14
+ withType(type: string): this;
15
+ withPersonaId(personaId: string): this;
16
+ }
17
+ //# sourceMappingURL=USyncUser.d.ts.map
@@ -1,30 +1,31 @@
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
@@ -0,0 +1,4 @@
1
+ export * from './Protocols/index.js';
2
+ export * from './USyncQuery.js';
3
+ export * from './USyncUser.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,4 @@
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.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import makeWASocket from './Socket/index.js';
2
+ export * from '../WAProto/index.js';
3
+ export * from './Utils/index.js';
4
+ export * from './Types/index.js';
5
+ export * from './Defaults/index.js';
6
+ export * from './WABinary/index.js';
7
+ export * from './WAM/index.js';
8
+ export * from './WAUSync/index.js';
9
+ export type WASocket = ReturnType<typeof makeWASocket>;
10
+ export { makeWASocket };
11
+ export default makeWASocket;
12
+ //# sourceMappingURL=index.d.ts.map
package/lib/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import makeWASocket from './Socket/index.js';
2
- export * from '../WAProto/compiler.js';
2
+ export * from '../WAProto/index.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';
10
9
  export { makeWASocket };
11
10
  export default makeWASocket;
11
+ //# sourceMappingURL=index.js.mapexport * from './Menu/index.js';