@skyzopedia/baileys-mod 5.0.8 → 6.0.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 (210) hide show
  1. package/WAProto/index.js +133384 -57814
  2. package/engine-requirements.js +10 -0
  3. package/lib/Defaults/baileys-version.json +3 -0
  4. package/lib/Defaults/index.d.ts +53 -0
  5. package/lib/Defaults/index.js +141 -117
  6. package/lib/Defaults/phonenumber-mcc.json +223 -0
  7. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  8. package/lib/Signal/Group/ciphertext-message.js +14 -12
  9. package/lib/Signal/Group/group-session-builder.d.ts +14 -0
  10. package/lib/Signal/Group/group-session-builder.js +42 -10
  11. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  12. package/lib/Signal/Group/group_cipher.js +87 -75
  13. package/lib/Signal/Group/index.d.ts +11 -0
  14. package/lib/Signal/Group/index.js +57 -13
  15. package/lib/Signal/Group/keyhelper.d.ts +10 -0
  16. package/lib/Signal/Group/keyhelper.js +52 -17
  17. package/lib/Signal/Group/queue-job.d.ts +1 -0
  18. package/lib/Signal/Group/queue-job.js +57 -0
  19. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  20. package/lib/Signal/Group/sender-chain-key.js +33 -27
  21. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  22. package/lib/Signal/Group/sender-key-distribution-message.js +63 -62
  23. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  24. package/lib/Signal/Group/sender-key-message.js +66 -65
  25. package/lib/Signal/Group/sender-key-name.d.ts +17 -0
  26. package/lib/Signal/Group/sender-key-name.js +44 -45
  27. package/lib/Signal/Group/sender-key-record.d.ts +30 -0
  28. package/lib/Signal/Group/sender-key-record.js +49 -39
  29. package/lib/Signal/Group/sender-key-state.d.ts +38 -0
  30. package/lib/Signal/Group/sender-key-state.js +93 -80
  31. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  32. package/lib/Signal/Group/sender-message-key.js +28 -27
  33. package/lib/Signal/libsignal.d.ts +3 -0
  34. package/lib/Signal/libsignal.js +163 -313
  35. package/lib/Socket/Client/abstract-socket-client.d.ts +17 -0
  36. package/lib/Socket/Client/abstract-socket-client.js +13 -0
  37. package/lib/Socket/Client/index.d.ts +3 -0
  38. package/lib/Socket/Client/index.js +19 -4
  39. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  40. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  41. package/lib/Socket/Client/web-socket-client.d.ts +12 -0
  42. package/lib/Socket/Client/web-socket-client.js +62 -0
  43. package/lib/Socket/business.d.ts +171 -0
  44. package/lib/Socket/business.js +242 -359
  45. package/lib/Socket/chats.d.ts +267 -0
  46. package/lib/Socket/chats.js +935 -846
  47. package/lib/Socket/dugong.d.ts +254 -0
  48. package/lib/Socket/dugong.js +484 -0
  49. package/lib/Socket/groups.d.ts +115 -0
  50. package/lib/Socket/groups.js +309 -304
  51. package/lib/Socket/index.d.ts +173 -0
  52. package/lib/Socket/index.js +10 -15
  53. package/lib/Socket/messages-recv.d.ts +161 -0
  54. package/lib/Socket/messages-recv.js +1054 -1107
  55. package/lib/Socket/messages-send.d.ts +149 -0
  56. package/lib/Socket/messages-send.js +447 -706
  57. package/lib/Socket/newsletter.d.ts +134 -0
  58. package/lib/Socket/newsletter.js +314 -199
  59. package/lib/Socket/registration.d.ts +267 -0
  60. package/lib/Socket/registration.js +166 -0
  61. package/lib/Socket/socket.d.ts +43 -0
  62. package/lib/Socket/socket.js +650 -777
  63. package/lib/Socket/usync.d.ts +36 -0
  64. package/lib/Socket/usync.js +70 -0
  65. package/lib/Store/index.d.ts +3 -0
  66. package/lib/Store/index.js +10 -6
  67. package/lib/Store/make-cache-manager-store.d.ts +13 -0
  68. package/lib/Store/make-cache-manager-store.js +81 -73
  69. package/lib/Store/make-in-memory-store.d.ts +118 -0
  70. package/lib/Store/make-in-memory-store.js +423 -286
  71. package/lib/Store/make-ordered-dictionary.d.ts +13 -0
  72. package/lib/Store/make-ordered-dictionary.js +79 -77
  73. package/lib/Store/object-repository.d.ts +10 -0
  74. package/lib/Store/object-repository.js +26 -24
  75. package/lib/Types/Auth.d.ts +110 -0
  76. package/lib/Types/Auth.js +2 -3
  77. package/lib/Types/Call.d.ts +13 -0
  78. package/lib/Types/Call.js +2 -3
  79. package/lib/Types/Chat.d.ts +102 -0
  80. package/lib/Types/Chat.js +4 -9
  81. package/lib/Types/Contact.d.ts +19 -0
  82. package/lib/Types/Contact.js +2 -3
  83. package/lib/Types/Events.d.ts +157 -0
  84. package/lib/Types/Events.js +2 -3
  85. package/lib/Types/GroupMetadata.d.ts +55 -0
  86. package/lib/Types/GroupMetadata.js +2 -3
  87. package/lib/Types/Label.d.ts +35 -0
  88. package/lib/Types/Label.js +26 -24
  89. package/lib/Types/LabelAssociation.d.ts +29 -0
  90. package/lib/Types/LabelAssociation.js +8 -6
  91. package/lib/Types/Message.d.ts +273 -0
  92. package/lib/Types/Message.js +9 -12
  93. package/lib/Types/Newsletter.d.ts +103 -0
  94. package/lib/Types/Newsletter.js +38 -33
  95. package/lib/Types/Product.d.ts +78 -0
  96. package/lib/Types/Product.js +2 -3
  97. package/lib/Types/Signal.d.ts +57 -0
  98. package/lib/Types/Signal.js +2 -3
  99. package/lib/Types/Socket.d.ts +111 -0
  100. package/lib/Types/Socket.js +2 -4
  101. package/lib/Types/State.d.ts +27 -0
  102. package/lib/Types/State.js +2 -11
  103. package/lib/Types/USync.d.ts +25 -0
  104. package/lib/Types/USync.js +2 -3
  105. package/lib/Types/index.d.ts +57 -0
  106. package/lib/Types/index.js +41 -27
  107. package/lib/Utils/auth-utils.d.ts +18 -0
  108. package/lib/Utils/auth-utils.js +198 -211
  109. package/lib/Utils/baileys-event-stream.d.ts +16 -0
  110. package/lib/Utils/baileys-event-stream.js +61 -42
  111. package/lib/Utils/business.d.ts +22 -0
  112. package/lib/Utils/business.js +214 -213
  113. package/lib/Utils/chat-utils.d.ts +71 -0
  114. package/lib/Utils/chat-utils.js +687 -710
  115. package/lib/Utils/crypto.d.ts +41 -0
  116. package/lib/Utils/crypto.js +133 -112
  117. package/lib/Utils/decode-wa-message.d.ts +19 -0
  118. package/lib/Utils/decode-wa-message.js +183 -252
  119. package/lib/Utils/event-buffer.d.ts +35 -0
  120. package/lib/Utils/event-buffer.js +496 -510
  121. package/lib/Utils/generics.d.ts +92 -0
  122. package/lib/Utils/generics.js +387 -319
  123. package/lib/Utils/history.d.ts +15 -0
  124. package/lib/Utils/history.js +92 -83
  125. package/lib/Utils/index.d.ts +17 -0
  126. package/lib/Utils/index.js +33 -21
  127. package/lib/Utils/link-preview.d.ts +21 -0
  128. package/lib/Utils/link-preview.js +83 -71
  129. package/lib/Utils/logger.d.ts +4 -0
  130. package/lib/Utils/logger.js +7 -5
  131. package/lib/Utils/lt-hash.d.ts +12 -0
  132. package/lib/Utils/lt-hash.js +46 -40
  133. package/lib/Utils/make-mutex.d.ts +7 -0
  134. package/lib/Utils/make-mutex.js +41 -34
  135. package/lib/Utils/messages-media.d.ts +116 -0
  136. package/lib/Utils/messages-media.js +768 -550
  137. package/lib/Utils/messages.d.ts +77 -0
  138. package/lib/Utils/messages.js +263 -362
  139. package/lib/Utils/noise-handler.d.ts +21 -0
  140. package/lib/Utils/noise-handler.js +149 -138
  141. package/lib/Utils/process-message.d.ts +41 -0
  142. package/lib/Utils/process-message.js +303 -323
  143. package/lib/Utils/signal.d.ts +32 -0
  144. package/lib/Utils/signal.js +141 -149
  145. package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
  146. package/lib/Utils/use-multi-file-auth-state.js +103 -95
  147. package/lib/Utils/validate-connection.d.ts +11 -0
  148. package/lib/Utils/validate-connection.js +220 -183
  149. package/lib/WABinary/constants.d.ts +30 -0
  150. package/lib/WABinary/constants.js +35 -1298
  151. package/lib/WABinary/decode.d.ts +7 -0
  152. package/lib/WABinary/decode.js +249 -237
  153. package/lib/WABinary/encode.d.ts +3 -0
  154. package/lib/WABinary/encode.js +260 -213
  155. package/lib/WABinary/generic-utils.d.ts +17 -0
  156. package/lib/WABinary/generic-utils.js +65 -56
  157. package/lib/WABinary/index.d.ts +5 -0
  158. package/lib/WABinary/index.js +21 -7
  159. package/lib/WABinary/jid-utils.d.ts +31 -0
  160. package/lib/WABinary/jid-utils.js +58 -89
  161. package/lib/WABinary/types.d.ts +18 -0
  162. package/lib/WABinary/types.js +2 -3
  163. package/lib/WAM/BinaryInfo.d.ts +17 -0
  164. package/lib/WAM/BinaryInfo.js +12 -10
  165. package/lib/WAM/constants.d.ts +38 -0
  166. package/lib/WAM/constants.js +15348 -22851
  167. package/lib/WAM/encode.d.ts +3 -0
  168. package/lib/WAM/encode.js +136 -135
  169. package/lib/WAM/index.d.ts +3 -0
  170. package/lib/WAM/index.js +19 -5
  171. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
  172. package/lib/WAUSync/Protocols/USyncContactProtocol.js +30 -28
  173. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
  174. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +53 -49
  175. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  176. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +28 -27
  177. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  178. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +39 -36
  179. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
  180. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -50
  181. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
  182. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +20 -26
  183. package/lib/WAUSync/Protocols/index.d.ts +4 -0
  184. package/lib/WAUSync/Protocols/index.js +20 -6
  185. package/lib/WAUSync/USyncQuery.d.ts +28 -0
  186. package/lib/WAUSync/USyncQuery.js +85 -86
  187. package/lib/WAUSync/USyncUser.d.ts +12 -0
  188. package/lib/WAUSync/USyncUser.js +25 -23
  189. package/lib/WAUSync/index.d.ts +3 -0
  190. package/lib/WAUSync/index.js +19 -5
  191. package/lib/index.d.ts +12 -0
  192. package/lib/index.js +36 -24
  193. package/package.json +106 -98
  194. package/LICENSE +0 -21
  195. package/WAProto/WAProto.proto +0 -5311
  196. package/lib/KeyDB/BinarySearch.js +0 -20
  197. package/lib/KeyDB/KeyedDB.js +0 -167
  198. package/lib/KeyDB/index.js +0 -4
  199. package/lib/Signal/lid-mapping.js +0 -155
  200. package/lib/Socket/Client/types.js +0 -13
  201. package/lib/Socket/Client/websocket.js +0 -52
  202. package/lib/Socket/Client/websocket.js.bak +0 -53
  203. package/lib/Socket/communities.js +0 -413
  204. package/lib/Socket/mex.js +0 -45
  205. package/lib/Types/Bussines.js +0 -3
  206. package/lib/Types/Newsletter.js.bak +0 -33
  207. package/lib/Utils/browser-utils.js +0 -25
  208. package/lib/Utils/message-retry-manager.js +0 -113
  209. package/lib/Utils/messages.js.bak +0 -907
  210. package/lib/Utils/pre-key-manager.js +0 -85
@@ -1,39 +1,42 @@
1
- //=======================================================//
2
- import { assertNodeErrorFree } from "../../WABinary/index.js";
3
- 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;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.USyncStatusProtocol = void 0;
4
+ const WABinary_1 = require("../../WABinary");
5
+ class USyncStatusProtocol {
6
+ constructor() {
7
+ this.name = 'status';
8
+ }
9
+ getQueryElement() {
10
+ return {
11
+ tag: 'status',
12
+ attrs: {},
13
+ };
14
+ }
15
+ getUserElement() {
16
+ return null;
17
+ }
18
+ parser(node) {
19
+ var _a, _b, _c;
20
+ if (node.tag === 'status') {
21
+ (0, WABinary_1.assertNodeErrorFree)(node);
22
+ let status = (_b = (_a = node === null || node === void 0 ? void 0 : node.content) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : null;
23
+ const setAt = new Date(+((node === null || node === void 0 ? void 0 : node.attrs.t) || 0) * 1000);
24
+ if (!status) {
25
+ if (+((_c = node.attrs) === null || _c === void 0 ? void 0 : _c.code) === 401) {
26
+ status = '';
27
+ }
28
+ else {
29
+ status = null;
30
+ }
31
+ }
32
+ else if (typeof status === 'string' && status.length === 0) {
33
+ status = null;
34
+ }
35
+ return {
36
+ status,
37
+ setAt,
38
+ };
27
39
  }
28
- }
29
- else if (typeof status === "string" && status.length === 0) {
30
- status = null;
31
- }
32
- return {
33
- status,
34
- setAt
35
- };
36
40
  }
37
- }
38
41
  }
39
- //=======================================================//
42
+ exports.USyncStatusProtocol = USyncStatusProtocol;
@@ -0,0 +1,25 @@
1
+ import { USyncQueryProtocol } from '../../Types/USync';
2
+ import { BinaryNode } from '../../WABinary';
3
+ import { USyncUser } from '../USyncUser';
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
+ }
@@ -1,53 +1,53 @@
1
- //=======================================================//
2
- import { getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString } from "../../WABinary/index.js";
3
- import { USyncUser } from "../USyncUser.js";
4
- //=======================================================//
5
- 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
- });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.USyncBotProfileProtocol = void 0;
4
+ const WABinary_1 = require("../../WABinary");
5
+ class USyncBotProfileProtocol {
6
+ constructor() {
7
+ this.name = 'bot';
35
8
  }
36
- for (const prompt of getBinaryNodeChildren(promptsNode, "prompt")) {
37
- prompts.push(`${getBinaryNodeChildString(prompt, "emoji")} ${getBinaryNodeChildString(prompt, "text")}`);
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 = (0, WABinary_1.getBinaryNodeChild)(node, 'bot');
25
+ const profile = (0, WABinary_1.getBinaryNodeChild)(botNode, 'profile');
26
+ const commandsNode = (0, WABinary_1.getBinaryNodeChild)(profile, 'commands');
27
+ const promptsNode = (0, WABinary_1.getBinaryNodeChild)(profile, 'prompts');
28
+ const commands = [];
29
+ const prompts = [];
30
+ for (const command of (0, WABinary_1.getBinaryNodeChildren)(commandsNode, 'command')) {
31
+ commands.push({
32
+ name: (0, WABinary_1.getBinaryNodeChildString)(command, 'name'),
33
+ description: (0, WABinary_1.getBinaryNodeChildString)(command, 'description')
34
+ });
35
+ }
36
+ for (const prompt of (0, WABinary_1.getBinaryNodeChildren)(promptsNode, 'prompt')) {
37
+ prompts.push(`${(0, WABinary_1.getBinaryNodeChildString)(prompt, 'emoji')} ${(0, WABinary_1.getBinaryNodeChildString)(prompt, 'text')}`);
38
+ }
39
+ return {
40
+ isDefault: !!(0, WABinary_1.getBinaryNodeChild)(profile, 'default'),
41
+ jid: node.attrs.jid,
42
+ name: (0, WABinary_1.getBinaryNodeChildString)(profile, 'name'),
43
+ attributes: (0, WABinary_1.getBinaryNodeChildString)(profile, 'attributes'),
44
+ description: (0, WABinary_1.getBinaryNodeChildString)(profile, 'description'),
45
+ category: (0, WABinary_1.getBinaryNodeChildString)(profile, 'category'),
46
+ personaId: profile.attrs['persona_id'],
47
+ commandsDescription: (0, WABinary_1.getBinaryNodeChildString)(commandsNode, 'description'),
48
+ commands,
49
+ prompts
50
+ };
38
51
  }
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
52
  }
53
- //=======================================================//
53
+ exports.USyncBotProfileProtocol = USyncBotProfileProtocol;
@@ -0,0 +1,8 @@
1
+ import { USyncQueryProtocol } from '../../Types/USync';
2
+ import { BinaryNode } from '../../WABinary';
3
+ export declare class USyncLIDProtocol implements USyncQueryProtocol {
4
+ name: string;
5
+ getQueryElement(): BinaryNode;
6
+ getUserElement(): null;
7
+ parser(node: BinaryNode): string | null;
8
+ }
@@ -1,30 +1,24 @@
1
- //=======================================================//
2
- 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
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.USyncLIDProtocol = void 0;
4
+ class USyncLIDProtocol {
5
+ constructor() {
6
+ this.name = 'lid';
18
7
  }
19
- else {
20
- return null;
8
+ getQueryElement() {
9
+ return {
10
+ tag: 'lid',
11
+ attrs: {},
12
+ };
21
13
  }
22
- }
23
- parser(node) {
24
- if (node.tag === "lid") {
25
- return node.attrs.val;
14
+ getUserElement() {
15
+ return null;
16
+ }
17
+ parser(node) {
18
+ if (node.tag === 'lid') {
19
+ return node.attrs.val;
20
+ }
21
+ return null;
26
22
  }
27
- return null;
28
- }
29
23
  }
30
- //=======================================================//
24
+ exports.USyncLIDProtocol = USyncLIDProtocol;
@@ -0,0 +1,4 @@
1
+ export * from './USyncDeviceProtocol';
2
+ export * from './USyncContactProtocol';
3
+ export * from './USyncStatusProtocol';
4
+ export * from './USyncDisappearingModeProtocol';
@@ -1,6 +1,20 @@
1
- //=======================================================//
2
- export * from "./USyncDisappearingModeProtocol.js";
3
- export * from "./USyncContactProtocol.js";
4
- export * from "./USyncDeviceProtocol.js";
5
- export * from "./USyncStatusProtocol.js";
6
- //=======================================================//
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./USyncDeviceProtocol"), exports);
18
+ __exportStar(require("./USyncContactProtocol"), exports);
19
+ __exportStar(require("./USyncStatusProtocol"), exports);
20
+ __exportStar(require("./USyncDisappearingModeProtocol"), exports);
@@ -0,0 +1,28 @@
1
+ import { USyncQueryProtocol } from '../Types/USync';
2
+ import { BinaryNode } from '../WABinary';
3
+ import { USyncUser } from './USyncUser';
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): USyncQueryResult | undefined;
22
+ withDeviceProtocol(): this;
23
+ withContactProtocol(): this;
24
+ withStatusProtocol(): this;
25
+ withDisappearingModeProtocol(): this;
26
+ withBotProfileProtocol(): this;
27
+ withLIDProtocol(): this;
28
+ }
@@ -1,90 +1,89 @@
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
- //=======================================================//
8
- 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;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.USyncQuery = void 0;
4
+ const WABinary_1 = require("../WABinary");
5
+ const UsyncBotProfileProtocol_1 = require("./Protocols/UsyncBotProfileProtocol");
6
+ const UsyncLIDProtocol_1 = require("./Protocols/UsyncLIDProtocol");
7
+ const Protocols_1 = require("./Protocols");
8
+ class USyncQuery {
9
+ constructor() {
10
+ this.protocols = [];
11
+ this.users = [];
12
+ this.context = 'interactive';
13
+ this.mode = 'query';
30
14
  }
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 });
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.attrs.type !== 'result') {
29
+ return;
59
30
  }
60
- return acc;
61
- }, []);
31
+ const protocolMap = Object.fromEntries(this.protocols.map((protocol) => {
32
+ return [protocol.name, protocol.parser];
33
+ }));
34
+ const queryResult = {
35
+ // TODO: implement errors etc.
36
+ list: [],
37
+ sideList: [],
38
+ };
39
+ const usyncNode = (0, WABinary_1.getBinaryNodeChild)(result, 'usync');
40
+ //TODO: implement error backoff, refresh etc.
41
+ //TODO: see if there are any errors in the result node
42
+ //const resultNode = getBinaryNodeChild(usyncNode, 'result')
43
+ const listNode = (0, WABinary_1.getBinaryNodeChild)(usyncNode, 'list');
44
+ if (Array.isArray(listNode === null || listNode === void 0 ? void 0 : listNode.content) && typeof listNode !== 'undefined') {
45
+ queryResult.list = listNode.content.map((node) => {
46
+ const id = node === null || node === void 0 ? void 0 : node.attrs.jid;
47
+ const data = Array.isArray(node === null || node === void 0 ? void 0 : node.content) ? Object.fromEntries(node.content.map((content) => {
48
+ const protocol = content.tag;
49
+ const parser = protocolMap[protocol];
50
+ if (parser) {
51
+ return [protocol, parser(content)];
52
+ }
53
+ else {
54
+ return [protocol, null];
55
+ }
56
+ }).filter(([, b]) => b !== null)) : {};
57
+ return { ...data, id };
58
+ });
59
+ }
60
+ //TODO: implement side list
61
+ //const sideListNode = getBinaryNodeChild(usyncNode, 'side_list')
62
+ return queryResult;
63
+ }
64
+ withDeviceProtocol() {
65
+ this.protocols.push(new Protocols_1.USyncDeviceProtocol());
66
+ return this;
67
+ }
68
+ withContactProtocol() {
69
+ this.protocols.push(new Protocols_1.USyncContactProtocol());
70
+ return this;
71
+ }
72
+ withStatusProtocol() {
73
+ this.protocols.push(new Protocols_1.USyncStatusProtocol());
74
+ return this;
75
+ }
76
+ withDisappearingModeProtocol() {
77
+ this.protocols.push(new Protocols_1.USyncDisappearingModeProtocol());
78
+ return this;
79
+ }
80
+ withBotProfileProtocol() {
81
+ this.protocols.push(new UsyncBotProfileProtocol_1.USyncBotProfileProtocol());
82
+ return this;
83
+ }
84
+ withLIDProtocol() {
85
+ this.protocols.push(new UsyncLIDProtocol_1.USyncLIDProtocol());
86
+ return this;
62
87
  }
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
88
  }
90
- //=======================================================//
89
+ exports.USyncQuery = USyncQuery;
@@ -0,0 +1,12 @@
1
+ export declare class USyncUser {
2
+ id: string;
3
+ lid: string;
4
+ phone: string;
5
+ type: string;
6
+ personaId: string;
7
+ withId(id: string): this;
8
+ withLid(lid: string): this;
9
+ withPhone(phone: string): this;
10
+ withType(type: string): this;
11
+ withPersonaId(personaId: string): this;
12
+ }
@@ -1,24 +1,26 @@
1
- //=======================================================//
2
- 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
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.USyncUser = void 0;
4
+ class USyncUser {
5
+ withId(id) {
6
+ this.id = id;
7
+ return this;
8
+ }
9
+ withLid(lid) {
10
+ this.lid = lid;
11
+ return this;
12
+ }
13
+ withPhone(phone) {
14
+ this.phone = phone;
15
+ return this;
16
+ }
17
+ withType(type) {
18
+ this.type = type;
19
+ return this;
20
+ }
21
+ withPersonaId(personaId) {
22
+ this.personaId = personaId;
23
+ return this;
24
+ }
23
25
  }
24
- //=======================================================//
26
+ exports.USyncUser = USyncUser;
@@ -0,0 +1,3 @@
1
+ export * from './Protocols';
2
+ export * from './USyncQuery';
3
+ export * from './USyncUser';
@@ -1,5 +1,19 @@
1
- //=======================================================//
2
- export * from "./Protocols/index.js";
3
- export * from "./USyncQuery.js";
4
- export * from "./USyncUser.js";
5
- //=======================================================//
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Protocols"), exports);
18
+ __exportStar(require("./USyncQuery"), exports);
19
+ __exportStar(require("./USyncUser"), exports);
package/lib/index.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import makeWASocket from './Socket';
2
+ export * from '../WAProto';
3
+ export * from './Utils';
4
+ export * from './Types';
5
+ export * from './Store';
6
+ export * from './Defaults';
7
+ export * from './WABinary';
8
+ export * from './WAM';
9
+ export * from './WAUSync';
10
+ export type WASocket = ReturnType<typeof makeWASocket>;
11
+ export { makeWASocket };
12
+ export default makeWASocket;