@rizzxdc/baileys 8.0.10 → 8.1.0

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 (220) hide show
  1. package/LICENSE +4 -2
  2. package/README.md +107 -245
  3. package/WAProto/index.d.ts +15795 -0
  4. package/WAProto/index.js +25587 -4867
  5. package/lib/Defaults/index.d.ts +147 -0
  6. package/lib/Defaults/index.js +134 -104
  7. package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
  8. package/lib/Signal/Group/ciphertext-message.js +9 -11
  9. package/lib/Signal/Group/group-session-builder.d.ts +8 -0
  10. package/lib/Signal/Group/group-session-builder.js +5 -8
  11. package/lib/Signal/Group/group_cipher.d.ts +11 -0
  12. package/lib/Signal/Group/group_cipher.js +72 -75
  13. package/lib/Signal/Group/index.d.ts +12 -0
  14. package/lib/Signal/Group/index.js +11 -13
  15. package/lib/Signal/Group/keyhelper.d.ts +7 -0
  16. package/lib/Signal/Group/keyhelper.js +11 -14
  17. package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
  18. package/lib/Signal/Group/sender-chain-key.js +23 -26
  19. package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
  20. package/lib/Signal/Group/sender-key-distribution-message.js +58 -61
  21. package/lib/Signal/Group/sender-key-message.d.ts +19 -0
  22. package/lib/Signal/Group/sender-key-message.js +61 -64
  23. package/lib/Signal/Group/sender-key-name.d.ts +12 -0
  24. package/lib/Signal/Group/sender-key-name.js +39 -44
  25. package/lib/Signal/Group/sender-key-record.d.ts +13 -0
  26. package/lib/Signal/Group/sender-key-record.js +35 -38
  27. package/lib/Signal/Group/sender-key-state.d.ts +17 -0
  28. package/lib/Signal/Group/sender-key-state.js +76 -79
  29. package/lib/Signal/Group/sender-message-key.d.ts +12 -0
  30. package/lib/Signal/Group/sender-message-key.js +23 -26
  31. package/lib/Signal/libsignal.d.ts +55 -0
  32. package/lib/Signal/libsignal.js +414 -308
  33. package/lib/Signal/lid-mapping.d.ts +21 -0
  34. package/lib/Signal/lid-mapping.js +270 -149
  35. package/lib/Socket/Client/index.d.ts +3 -0
  36. package/lib/Socket/Client/index.js +2 -4
  37. package/lib/Socket/Client/types.d.ts +6 -0
  38. package/lib/Socket/Client/types.js +8 -11
  39. package/lib/Socket/Client/websocket.d.ts +13 -0
  40. package/lib/Socket/Client/websocket.js +51 -50
  41. package/lib/Socket/business.d.ts +395 -0
  42. package/lib/Socket/business.js +357 -355
  43. package/lib/Socket/chats.d.ts +137 -0
  44. package/lib/Socket/chats.js +1195 -867
  45. package/lib/Socket/communities.d.ts +562 -0
  46. package/lib/Socket/communities.js +416 -398
  47. package/lib/Socket/dugong.js +8 -1
  48. package/lib/Socket/groups.d.ts +286 -0
  49. package/lib/Socket/groups.js +336 -301
  50. package/lib/Socket/index.d.ts +530 -0
  51. package/lib/Socket/index.js +8 -13
  52. package/lib/Socket/messages-recv.d.ts +334 -0
  53. package/lib/Socket/messages-recv.js +1729 -1121
  54. package/lib/Socket/messages-send.d.ts +330 -0
  55. package/lib/Socket/messages-send.js +684 -462
  56. package/lib/Socket/mex.d.ts +2 -0
  57. package/lib/Socket/mex.js +36 -40
  58. package/lib/Socket/newsletter.d.ts +284 -0
  59. package/lib/Socket/newsletter.js +247 -237
  60. package/lib/Socket/socket.d.ts +61 -0
  61. package/lib/Socket/socket.js +968 -790
  62. package/lib/Store/index.d.ts +4 -0
  63. package/lib/Store/index.js +4 -6
  64. package/lib/Store/make-cache-manager-store.js +2 -2
  65. package/lib/Store/make-in-memory-store.d.ts +63 -0
  66. package/lib/Store/make-in-memory-store.js +414 -284
  67. package/lib/Store/make-ordered-dictionary.d.ts +13 -0
  68. package/lib/Store/make-ordered-dictionary.js +75 -76
  69. package/lib/Store/object-repository.d.ts +11 -0
  70. package/lib/Store/object-repository.js +21 -23
  71. package/lib/Types/Auth.d.ts +2 -0
  72. package/lib/Types/Auth.js +0 -2
  73. package/lib/Types/Bussines.d.ts +2 -0
  74. package/lib/Types/Bussines.js +0 -2
  75. package/lib/Types/Call.d.ts +2 -0
  76. package/lib/Types/Call.js +0 -2
  77. package/lib/Types/Chat.d.ts +2 -0
  78. package/lib/Types/Chat.js +5 -7
  79. package/lib/Types/Contact.d.ts +2 -0
  80. package/lib/Types/Contact.js +0 -2
  81. package/lib/Types/Events.d.ts +2 -0
  82. package/lib/Types/Events.js +1 -3
  83. package/lib/Types/GroupMetadata.d.ts +2 -0
  84. package/lib/Types/GroupMetadata.js +0 -2
  85. package/lib/Types/Label.d.ts +3 -0
  86. package/lib/Types/Label.js +21 -22
  87. package/lib/Types/LabelAssociation.d.ts +3 -0
  88. package/lib/Types/LabelAssociation.js +3 -4
  89. package/lib/Types/Message.d.ts +12 -0
  90. package/lib/Types/Message.js +11 -6
  91. package/lib/Types/Mex.d.ts +3 -0
  92. package/lib/Types/Mex.js +38 -0
  93. package/lib/Types/Product.d.ts +2 -0
  94. package/lib/Types/Product.js +0 -2
  95. package/lib/Types/RichType.d.ts +3 -0
  96. package/lib/Types/RichType.js +22 -0
  97. package/lib/Types/Signal.d.ts +2 -0
  98. package/lib/Types/Signal.js +1 -3
  99. package/lib/Types/Socket.d.ts +2 -0
  100. package/lib/Types/Socket.js +1 -4
  101. package/lib/Types/State.d.ts +6 -0
  102. package/lib/Types/State.js +52 -8
  103. package/lib/Types/USync.d.ts +2 -0
  104. package/lib/Types/USync.js +1 -3
  105. package/lib/Types/index.d.ts +14 -0
  106. package/lib/Types/index.js +22 -25
  107. package/lib/Utils/auth-utils.d.ts +58 -0
  108. package/lib/Utils/auth-utils.js +285 -203
  109. package/lib/Utils/browser-utils.d.ts +9 -0
  110. package/lib/Utils/browser-utils.js +21 -19
  111. package/lib/Utils/business.d.ts +50 -0
  112. package/lib/Utils/business.js +206 -209
  113. package/lib/Utils/chat-utils.d.ts +409 -0
  114. package/lib/Utils/chat-utils.js +825 -706
  115. package/lib/Utils/companion-reg-client-utils.d.ts +5 -0
  116. package/lib/Utils/companion-reg-client-utils.js +39 -0
  117. package/lib/Utils/crypto.d.ts +40 -0
  118. package/lib/Utils/crypto.js +88 -101
  119. package/lib/Utils/decode-wa-message.d.ts +84 -0
  120. package/lib/Utils/decode-wa-message.js +287 -238
  121. package/lib/Utils/event-buffer.d.ts +13 -0
  122. package/lib/Utils/event-buffer.js +602 -509
  123. package/lib/Utils/generics.d.ts +64 -0
  124. package/lib/Utils/generics.js +334 -295
  125. package/lib/Utils/history.d.ts +76 -0
  126. package/lib/Utils/history.js +125 -79
  127. package/lib/Utils/identity-change-handler.d.ts +14 -0
  128. package/lib/Utils/identity-change-handler.js +49 -0
  129. package/lib/Utils/index.d.ts +25 -0
  130. package/lib/Utils/index.js +25 -21
  131. package/lib/Utils/link-preview.d.ts +13 -0
  132. package/lib/Utils/link-preview.js +73 -70
  133. package/lib/Utils/logger.d.ts +3 -0
  134. package/lib/Utils/logger.js +1 -4
  135. package/lib/Utils/lt-hash.d.ts +7 -0
  136. package/lib/Utils/lt-hash.js +7 -45
  137. package/lib/Utils/make-mutex.d.ts +7 -0
  138. package/lib/Utils/make-mutex.js +27 -31
  139. package/lib/Utils/message-retry-manager.d.ts +80 -0
  140. package/lib/Utils/message-retry-manager.js +165 -14
  141. package/lib/Utils/messages-media.d.ts +137 -0
  142. package/lib/Utils/messages-media.js +768 -572
  143. package/lib/Utils/messages.d.ts +46 -0
  144. package/lib/Utils/messages.js +1082 -130
  145. package/lib/Utils/noise-handler.d.ts +21 -0
  146. package/lib/Utils/noise-handler.js +191 -135
  147. package/lib/Utils/offline-node-processor.d.ts +10 -0
  148. package/lib/Utils/offline-node-processor.js +39 -0
  149. package/lib/Utils/pre-key-manager.d.ts +26 -0
  150. package/lib/Utils/pre-key-manager.js +96 -76
  151. package/lib/Utils/process-message.d.ts +84 -0
  152. package/lib/Utils/process-message.js +718 -311
  153. package/lib/Utils/reporting-utils.d.ts +13 -0
  154. package/lib/Utils/reporting-utils.js +257 -0
  155. package/lib/Utils/rich-message-utils.d.ts +49 -0
  156. package/lib/Utils/rich-message-utils.js +257 -0
  157. package/lib/Utils/signal.d.ts +83 -0
  158. package/lib/Utils/signal.js +174 -135
  159. package/lib/Utils/stanza-ack.d.ts +17 -0
  160. package/lib/Utils/stanza-ack.js +37 -0
  161. package/lib/Utils/sync-action-utils.d.ts +3 -0
  162. package/lib/Utils/sync-action-utils.js +48 -0
  163. package/lib/Utils/tc-token-utils.d.ts +30 -0
  164. package/lib/Utils/tc-token-utils.js +162 -0
  165. package/lib/Utils/use-multi-file-auth-state.d.ts +11 -0
  166. package/lib/Utils/use-multi-file-auth-state.js +104 -95
  167. package/lib/Utils/use-single-file-auth-state.d.ts +11 -0
  168. package/lib/Utils/use-single-file-auth-state.js +108 -0
  169. package/lib/Utils/use-sqlite-auth-state.d.ts +11 -0
  170. package/lib/Utils/use-sqlite-auth-state.js +108 -0
  171. package/lib/Utils/validate-connection.d.ts +44 -0
  172. package/lib/Utils/validate-connection.js +182 -180
  173. package/lib/WABinary/constants.d.ts +62 -0
  174. package/lib/WABinary/constants.js +1455 -1292
  175. package/lib/WABinary/decode.d.ts +10 -0
  176. package/lib/WABinary/decode.js +249 -228
  177. package/lib/WABinary/encode.d.ts +3 -0
  178. package/lib/WABinary/encode.js +207 -206
  179. package/lib/WABinary/generic-utils.d.ts +77 -0
  180. package/lib/WABinary/generic-utils.js +135 -99
  181. package/lib/WABinary/index.d.ts +6 -0
  182. package/lib/WABinary/index.js +5 -7
  183. package/lib/WABinary/jid-utils.d.ts +29 -0
  184. package/lib/WABinary/jid-utils.js +80 -78
  185. package/lib/WABinary/types.d.ts +2 -0
  186. package/lib/WABinary/types.js +1 -3
  187. package/lib/WAM/BinaryInfo.d.ts +8 -0
  188. package/lib/WAM/BinaryInfo.js +7 -9
  189. package/lib/WAM/constants.d.ts +34927 -0
  190. package/lib/WAM/constants.js +22847 -22848
  191. package/lib/WAM/encode.d.ts +2 -0
  192. package/lib/WAM/encode.js +129 -134
  193. package/lib/WAM/index.d.ts +4 -0
  194. package/lib/WAM/index.js +3 -5
  195. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +37 -0
  196. package/lib/WAUSync/Protocols/USyncContactProtocol.js +48 -27
  197. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
  198. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +48 -48
  199. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
  200. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +23 -26
  201. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
  202. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +33 -35
  203. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
  204. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
  205. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +39 -0
  206. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +46 -49
  207. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +15 -0
  208. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +23 -25
  209. package/lib/WAUSync/Protocols/index.d.ts +6 -0
  210. package/lib/WAUSync/Protocols/index.js +5 -6
  211. package/lib/WAUSync/USyncQuery.d.ts +21 -0
  212. package/lib/WAUSync/USyncQuery.js +92 -85
  213. package/lib/WAUSync/USyncUser.d.ts +17 -0
  214. package/lib/WAUSync/USyncUser.js +28 -22
  215. package/lib/WAUSync/index.d.ts +4 -0
  216. package/lib/WAUSync/index.js +3 -5
  217. package/lib/index.d.ts +12 -0
  218. package/lib/index.js +31 -19
  219. package/package.json +12 -6
  220. package/lib/Types/Newsletter.js +0 -33
@@ -1,39 +1,37 @@
1
- //=======================================================//
2
- import { assertNodeErrorFree } from "../../WABinary/index.js";
1
+ import { assertNodeErrorFree } from '../../WABinary/index.js';
3
2
  export class USyncStatusProtocol {
4
- constructor() {
5
- this.name = "status";
6
- }
7
- getQueryElement() {
8
- return {
9
- tag: "status",
10
- attrs: {}
11
- };
12
- }
13
- getUserElement() {
14
- return null;
15
- }
16
- parser(node) {
17
- if (node.tag === "status") {
18
- assertNodeErrorFree(node);
19
- let status = node?.content?.toString() ?? null;
20
- const setAt = new Date(+(node?.attrs.t || 0) * 1000);
21
- if (!status) {
22
- if (node.attrs?.code && +node.attrs.code === 401) {
23
- status = "";
24
- }
25
- else {
26
- 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
+ };
27
35
  }
28
- }
29
- else if (typeof status === "string" && status.length === 0) {
30
- status = null;
31
- }
32
- return {
33
- status,
34
- setAt
35
- };
36
36
  }
37
- }
38
37
  }
39
- //=======================================================//
@@ -0,0 +1,10 @@
1
+ export class USyncUsernameProtocol {
2
+ name: string;
3
+ getQueryElement(): {
4
+ tag: string;
5
+ attrs: {};
6
+ };
7
+ getUserElement(user: any): null;
8
+ parser(node: any): any;
9
+ }
10
+ //# sourceMappingURL=USyncUsernameProtocol.d.ts.map
@@ -0,0 +1,24 @@
1
+ import { assertNodeErrorFree } from '../../WABinary/index.js';
2
+ import { USyncUser } from '../USyncUser.js';
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;
21
+ }
22
+ return null;
23
+ }
24
+ }
@@ -0,0 +1,39 @@
1
+ export class USyncBotProfileProtocol {
2
+ name: string;
3
+ getQueryElement(): {
4
+ tag: string;
5
+ attrs: {};
6
+ content: {
7
+ tag: string;
8
+ attrs: {
9
+ v: string;
10
+ };
11
+ }[];
12
+ };
13
+ getUserElement(user: any): {
14
+ tag: string;
15
+ attrs: {};
16
+ content: {
17
+ tag: string;
18
+ attrs: {
19
+ persona_id: any;
20
+ };
21
+ }[];
22
+ };
23
+ parser(node: any): {
24
+ isDefault: boolean;
25
+ jid: any;
26
+ name: any;
27
+ attributes: any;
28
+ description: any;
29
+ category: any;
30
+ personaId: any;
31
+ commandsDescription: any;
32
+ commands: {
33
+ name: any;
34
+ description: any;
35
+ }[];
36
+ prompts: string[];
37
+ };
38
+ }
39
+ //# sourceMappingURL=UsyncBotProfileProtocol.d.ts.map
@@ -1,53 +1,50 @@
1
- //=======================================================//
2
- import { getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString } from "../../WABinary/index.js";
3
- import { USyncUser } from "../USyncUser.js";
4
- //=======================================================//
1
+ import { getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString } from '../../WABinary/index.js';
2
+ import { USyncUser } from '../USyncUser.js';
5
3
  export class USyncBotProfileProtocol {
6
- constructor() {
7
- this.name = "bot";
8
- }
9
- getQueryElement() {
10
- return {
11
- tag: "bot",
12
- attrs: {},
13
- content: [{ tag: "profile", attrs: { v: "1" } }]
14
- };
15
- }
16
- getUserElement(user) {
17
- return {
18
- tag: "bot",
19
- attrs: {},
20
- content: [{ tag: "profile", attrs: { persona_id: user.personaId } }]
21
- };
22
- }
23
- parser(node) {
24
- const botNode = getBinaryNodeChild(node, "bot");
25
- const profile = getBinaryNodeChild(botNode, "profile");
26
- const commandsNode = getBinaryNodeChild(profile, "commands");
27
- const promptsNode = getBinaryNodeChild(profile, "prompts");
28
- const commands = [];
29
- const prompts = [];
30
- for (const command of getBinaryNodeChildren(commandsNode, "command")) {
31
- commands.push({
32
- name: getBinaryNodeChildString(command, "name"),
33
- description: getBinaryNodeChildString(command, "description")
34
- });
4
+ constructor() {
5
+ this.name = 'bot';
35
6
  }
36
- for (const prompt of getBinaryNodeChildren(promptsNode, "prompt")) {
37
- prompts.push(`${getBinaryNodeChildString(prompt, "emoji")} ${getBinaryNodeChildString(prompt, "text")}`);
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
+ });
33
+ }
34
+ for (const prompt of getBinaryNodeChildren(promptsNode, 'prompt')) {
35
+ prompts.push(`${getBinaryNodeChildString(prompt, 'emoji')} ${getBinaryNodeChildString(prompt, 'text')}`);
36
+ }
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
+ };
38
49
  }
39
- return {
40
- isDefault: !!getBinaryNodeChild(profile, "default"),
41
- jid: node.attrs.jid,
42
- name: getBinaryNodeChildString(profile, "name"),
43
- attributes: getBinaryNodeChildString(profile, "attributes"),
44
- description: getBinaryNodeChildString(profile, "description"),
45
- category: getBinaryNodeChildString(profile, "category"),
46
- personaId: profile.attrs["persona_id"],
47
- commandsDescription: getBinaryNodeChildString(commandsNode, "description"),
48
- commands,
49
- prompts
50
- };
51
- }
52
50
  }
53
- //=======================================================//
@@ -0,0 +1,15 @@
1
+ export class USyncLIDProtocol {
2
+ name: string;
3
+ getQueryElement(): {
4
+ tag: string;
5
+ attrs: {};
6
+ };
7
+ getUserElement(user: any): {
8
+ tag: string;
9
+ attrs: {
10
+ jid: any;
11
+ };
12
+ } | null;
13
+ parser(node: any): any;
14
+ }
15
+ //# sourceMappingURL=UsyncLIDProtocol.d.ts.map
@@ -1,30 +1,28 @@
1
- //=======================================================//
2
1
  export class USyncLIDProtocol {
3
- constructor() {
4
- this.name = "lid";
5
- }
6
- getQueryElement() {
7
- return {
8
- tag: "lid",
9
- attrs: {}
10
- };
11
- }
12
- getUserElement(user) {
13
- if (user.lid) {
14
- return {
15
- tag: "lid",
16
- attrs: { jid: user.lid }
17
- };
2
+ constructor() {
3
+ this.name = 'lid';
18
4
  }
19
- else {
20
- return null;
5
+ getQueryElement() {
6
+ return {
7
+ tag: 'lid',
8
+ attrs: {}
9
+ };
21
10
  }
22
- }
23
- parser(node) {
24
- if (node.tag === "lid") {
25
- return node.attrs.val;
11
+ getUserElement(user) {
12
+ if (user.lid) {
13
+ return {
14
+ tag: 'lid',
15
+ attrs: { jid: user.lid }
16
+ };
17
+ }
18
+ else {
19
+ return null;
20
+ }
21
+ }
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
  }
30
- //=======================================================//
@@ -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
@@ -1,6 +1,5 @@
1
- //=======================================================//
2
- export * from "./USyncDisappearingModeProtocol.js";
3
- export * from "./USyncContactProtocol.js";
4
- export * from "./USyncDeviceProtocol.js";
5
- export * from "./USyncStatusProtocol.js";
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';
@@ -0,0 +1,21 @@
1
+ export class USyncQuery {
2
+ protocols: any[];
3
+ users: any[];
4
+ context: string;
5
+ mode: string;
6
+ withMode(mode: any): this;
7
+ withContext(context: any): this;
8
+ withUser(user: any): this;
9
+ parseUSyncQueryResult(result: any): {
10
+ list: never[];
11
+ sideList: never[];
12
+ } | undefined;
13
+ withDeviceProtocol(): this;
14
+ withContactProtocol(): this;
15
+ withStatusProtocol(): this;
16
+ withDisappearingModeProtocol(): this;
17
+ withBotProfileProtocol(): this;
18
+ withLIDProtocol(): this;
19
+ withUsernameProtocol(): this;
20
+ }
21
+ //# sourceMappingURL=USyncQuery.d.ts.map
@@ -1,90 +1,97 @@
1
- //=======================================================//
2
- import { USyncContactProtocol, USyncDeviceProtocol, USyncDisappearingModeProtocol, USyncStatusProtocol } from "./Protocols/index.js";
3
- import { USyncBotProfileProtocol } from "./Protocols/UsyncBotProfileProtocol.js";
4
- import { USyncLIDProtocol } from "./Protocols/UsyncLIDProtocol.js";
5
- import { getBinaryNodeChild } from "../WABinary/index.js";
6
- import { USyncUser } from "./USyncUser.js";
7
- //=======================================================//
1
+ import { getBinaryNodeChild } from '../WABinary/index.js';
2
+ import { USyncBotProfileProtocol } from './Protocols/UsyncBotProfileProtocol.js';
3
+ import { USyncLIDProtocol } from './Protocols/UsyncLIDProtocol.js';
4
+ import { USyncContactProtocol, USyncDeviceProtocol, USyncDisappearingModeProtocol, USyncStatusProtocol, USyncUsernameProtocol } from './Protocols/index.js';
5
+ import { USyncUser } from './USyncUser.js';
8
6
  export class USyncQuery {
9
- constructor() {
10
- this.protocols = [];
11
- this.users = [];
12
- this.context = "interactive";
13
- this.mode = "query";
14
- }
15
- withMode(mode) {
16
- this.mode = mode;
17
- return this;
18
- }
19
- withContext(context) {
20
- this.context = context;
21
- return this;
22
- }
23
- withUser(user) {
24
- this.users.push(user);
25
- return this;
26
- }
27
- parseUSyncQueryResult(result) {
28
- if (!result || result.attrs.type !== "result") {
29
- return;
7
+ constructor() {
8
+ this.protocols = [];
9
+ this.users = [];
10
+ this.context = 'interactive';
11
+ this.mode = 'query';
30
12
  }
31
- const protocolMap = Object.fromEntries(this.protocols.map(protocol => {
32
- return [protocol.name, protocol.parser];
33
- }));
34
- const queryResult = {
35
- list: [],
36
- sideList: []
37
- };
38
- const usyncNode = getBinaryNodeChild(result, "usync");
39
- const listNode = usyncNode ? getBinaryNodeChild(usyncNode, "list") : undefined;
40
- if (listNode?.content && Array.isArray(listNode.content)) {
41
- queryResult.list = listNode.content.reduce((acc, node) => {
42
- const id = node?.attrs.jid;
43
- if (id) {
44
- const data = Array.isArray(node?.content)
45
- ? Object.fromEntries(node.content
46
- .map(content => {
47
- const protocol = content.tag;
48
- const parser = protocolMap[protocol];
49
- if (parser) {
50
- return [protocol, parser(content)];
51
- }
52
- else {
53
- return [protocol, null];
54
- }
55
- })
56
- .filter(([, b]) => b !== null))
57
- : {};
58
- acc.push({ ...data, id });
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;
59
28
  }
60
- return acc;
61
- }, []);
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;
62
96
  }
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
97
  }
90
- //=======================================================//
@@ -0,0 +1,17 @@
1
+ export class USyncUser {
2
+ withId(id: any): this;
3
+ id: any;
4
+ withLid(lid: any): this;
5
+ lid: any;
6
+ withPhone(phone: any): this;
7
+ phone: any;
8
+ withUsername(username: any): this;
9
+ username: any;
10
+ withUsernameKey(usernameKey: any): this;
11
+ usernameKey: any;
12
+ withType(type: any): this;
13
+ type: any;
14
+ withPersonaId(personaId: any): this;
15
+ personaId: any;
16
+ }
17
+ //# sourceMappingURL=USyncUser.d.ts.map
@@ -1,24 +1,30 @@
1
- //=======================================================//
2
1
  export class USyncUser {
3
- withId(id) {
4
- this.id = id;
5
- return this;
6
- }
7
- withLid(lid) {
8
- this.lid = lid;
9
- return this;
10
- }
11
- withPhone(phone) {
12
- this.phone = phone;
13
- return this;
14
- }
15
- withType(type) {
16
- this.type = type;
17
- return this;
18
- }
19
- withPersonaId(personaId) {
20
- this.personaId = personaId;
21
- return this;
22
- }
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
+ }
23
30
  }
24
- //=======================================================//
@@ -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,5 +1,3 @@
1
- //=======================================================//
2
- export * from "./Protocols/index.js";
3
- export * from "./USyncQuery.js";
4
- export * from "./USyncUser.js";
5
- //=======================================================//
1
+ export * from './Protocols/index.js';
2
+ export * from './USyncQuery.js';
3
+ export * from './USyncUser.js';
package/lib/index.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ export * from "../WAProto/index.js";
2
+ export * from "./Utils/index.js";
3
+ export * from "./Types/index.js";
4
+ export * from "./Store/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 { makeWASocket };
10
+ export default makeWASocket;
11
+ import makeWASocket from './Socket/index.js';
12
+ //# sourceMappingURL=index.d.ts.map