cuki-bailx 1.2.5 → 2.0.7

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 (154) hide show
  1. package/WAProto/AICommon.js +27981 -0
  2. package/WAProto/AICommon.proto +713 -0
  3. package/WAProto/Ephemeral.js +295 -0
  4. package/WAProto/Ephemeral.proto +7 -0
  5. package/WAProto/GenerateStatics.sh +4 -0
  6. package/WAProto/WAProto.proto +4775 -0
  7. package/WAProto/cuki.js +7 -0
  8. package/WAProto/index.js +56886 -17506
  9. package/lib/Defaults/baileys-version.json +2 -2
  10. package/lib/Defaults/index.js +117 -102
  11. package/lib/Socket/Client/index.js +2 -3
  12. package/lib/Socket/Client/{web-socket-client.js → websocket.js} +54 -5
  13. package/lib/Socket/chats.js +97 -90
  14. package/lib/Socket/groups.js +20 -5
  15. package/lib/Socket/index.js +2 -2
  16. package/lib/Socket/messages-recv.js +9 -65
  17. package/lib/Socket/messages-send.js +612 -286
  18. package/lib/Socket/newsletter.js +68 -41
  19. package/lib/Socket/{dugong.js → setup.js} +5 -13
  20. package/lib/Socket/socket.js +58 -32
  21. package/lib/Store/index.js +1 -3
  22. package/lib/Store/make-in-memory-store.js +26 -14
  23. package/lib/Store/make-ordered-dictionary.js +2 -2
  24. package/lib/Types/Label.js +1 -1
  25. package/lib/Types/LabelAssociation.js +1 -1
  26. package/lib/Types/Message.js +0 -2
  27. package/lib/Types/Newsletter.js +3 -17
  28. package/lib/Types/index.js +2 -2
  29. package/lib/Utils/auth-utils.js +6 -13
  30. package/lib/Utils/business.js +2 -2
  31. package/lib/Utils/chat-utils.js +36 -35
  32. package/lib/Utils/crypto.js +71 -29
  33. package/lib/Utils/decode-wa-message.js +65 -56
  34. package/lib/Utils/event-buffer.js +11 -7
  35. package/lib/Utils/generics.js +73 -23
  36. package/lib/Utils/history.js +4 -6
  37. package/lib/Utils/link-preview.js +34 -1
  38. package/lib/Utils/lt-hash.js +6 -6
  39. package/lib/Utils/messages-media.js +479 -161
  40. package/lib/Utils/messages.js +391 -77
  41. package/lib/Utils/noise-handler.js +19 -23
  42. package/lib/Utils/signal.js +47 -36
  43. package/lib/Utils/use-multi-file-auth-state.js +51 -6
  44. package/lib/Utils/validate-connection.js +94 -66
  45. package/lib/WABinary/constants.js +1276 -13
  46. package/lib/WABinary/decode.js +26 -13
  47. package/lib/WABinary/encode.js +39 -17
  48. package/lib/WABinary/generic-utils.js +2 -85
  49. package/lib/WABinary/jid-utils.js +12 -5
  50. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
  51. package/lib/index.js +18 -5
  52. package/package.json +100 -105
  53. package/engine-requirements.js +0 -10
  54. package/lib/Defaults/index.d.ts +0 -53
  55. package/lib/Defaults/phonenumber-mcc.json +0 -223
  56. package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
  57. package/lib/Signal/Group/group-session-builder.d.ts +0 -14
  58. package/lib/Signal/Group/group_cipher.d.ts +0 -17
  59. package/lib/Signal/Group/index.d.ts +0 -11
  60. package/lib/Signal/Group/keyhelper.d.ts +0 -10
  61. package/lib/Signal/Group/queue-job.d.ts +0 -1
  62. package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
  63. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
  64. package/lib/Signal/Group/sender-key-message.d.ts +0 -18
  65. package/lib/Signal/Group/sender-key-name.d.ts +0 -17
  66. package/lib/Signal/Group/sender-key-record.d.ts +0 -30
  67. package/lib/Signal/Group/sender-key-state.d.ts +0 -38
  68. package/lib/Signal/Group/sender-message-key.d.ts +0 -11
  69. package/lib/Signal/libsignal.d.ts +0 -3
  70. package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
  71. package/lib/Socket/Client/index.d.ts +0 -3
  72. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
  73. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  74. package/lib/Socket/Client/web-socket-client.d.ts +0 -12
  75. package/lib/Socket/business.d.ts +0 -171
  76. package/lib/Socket/chats.d.ts +0 -80
  77. package/lib/Socket/dugong.d.ts +0 -219
  78. package/lib/Socket/groups.d.ts +0 -115
  79. package/lib/Socket/index.d.ts +0 -173
  80. package/lib/Socket/messages-recv.d.ts +0 -161
  81. package/lib/Socket/messages-send.d.ts +0 -149
  82. package/lib/Socket/newsletter.d.ts +0 -134
  83. package/lib/Socket/registration.d.ts +0 -267
  84. package/lib/Socket/registration.js +0 -166
  85. package/lib/Socket/socket.d.ts +0 -43
  86. package/lib/Socket/socket.js.bak +0 -630
  87. package/lib/Socket/usync.d.ts +0 -36
  88. package/lib/Store/index.d.ts +0 -3
  89. package/lib/Store/make-cache-manager-store.d.ts +0 -13
  90. package/lib/Store/make-cache-manager-store.js +0 -83
  91. package/lib/Store/make-in-memory-store.d.ts +0 -118
  92. package/lib/Store/make-ordered-dictionary.d.ts +0 -13
  93. package/lib/Store/object-repository.d.ts +0 -10
  94. package/lib/Types/Auth.d.ts +0 -110
  95. package/lib/Types/Call.d.ts +0 -13
  96. package/lib/Types/Chat.d.ts +0 -102
  97. package/lib/Types/Contact.d.ts +0 -19
  98. package/lib/Types/Events.d.ts +0 -157
  99. package/lib/Types/GroupMetadata.d.ts +0 -55
  100. package/lib/Types/Label.d.ts +0 -35
  101. package/lib/Types/LabelAssociation.d.ts +0 -29
  102. package/lib/Types/Message.d.ts +0 -273
  103. package/lib/Types/Newsletter.d.ts +0 -92
  104. package/lib/Types/Product.d.ts +0 -78
  105. package/lib/Types/Signal.d.ts +0 -57
  106. package/lib/Types/Socket.d.ts +0 -111
  107. package/lib/Types/State.d.ts +0 -27
  108. package/lib/Types/USync.d.ts +0 -25
  109. package/lib/Types/index.d.ts +0 -57
  110. package/lib/Utils/auth-utils.d.ts +0 -18
  111. package/lib/Utils/baileys-event-stream.d.ts +0 -16
  112. package/lib/Utils/business.d.ts +0 -22
  113. package/lib/Utils/chat-utils.d.ts +0 -71
  114. package/lib/Utils/crypto.d.ts +0 -41
  115. package/lib/Utils/decode-wa-message.d.ts +0 -19
  116. package/lib/Utils/event-buffer.d.ts +0 -35
  117. package/lib/Utils/generics.d.ts +0 -92
  118. package/lib/Utils/history.d.ts +0 -15
  119. package/lib/Utils/index.d.ts +0 -17
  120. package/lib/Utils/link-preview.d.ts +0 -21
  121. package/lib/Utils/logger.d.ts +0 -4
  122. package/lib/Utils/lt-hash.d.ts +0 -12
  123. package/lib/Utils/make-mutex.d.ts +0 -7
  124. package/lib/Utils/messages-media.d.ts +0 -116
  125. package/lib/Utils/messages.d.ts +0 -77
  126. package/lib/Utils/noise-handler.d.ts +0 -21
  127. package/lib/Utils/process-message.d.ts +0 -41
  128. package/lib/Utils/signal.d.ts +0 -32
  129. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
  130. package/lib/Utils/validate-connection.d.ts +0 -11
  131. package/lib/WABinary/constants.d.ts +0 -27
  132. package/lib/WABinary/decode.d.ts +0 -7
  133. package/lib/WABinary/encode.d.ts +0 -3
  134. package/lib/WABinary/generic-utils.d.ts +0 -16
  135. package/lib/WABinary/index.d.ts +0 -5
  136. package/lib/WABinary/jid-utils.d.ts +0 -31
  137. package/lib/WABinary/types.d.ts +0 -18
  138. package/lib/WAM/BinaryInfo.d.ts +0 -17
  139. package/lib/WAM/constants.d.ts +0 -38
  140. package/lib/WAM/encode.d.ts +0 -3
  141. package/lib/WAM/index.d.ts +0 -3
  142. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
  143. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
  144. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
  145. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
  146. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
  147. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
  148. package/lib/WAUSync/Protocols/index.d.ts +0 -4
  149. package/lib/WAUSync/USyncQuery.d.ts +0 -28
  150. package/lib/WAUSync/USyncUser.d.ts +0 -12
  151. package/lib/WAUSync/index.d.ts +0 -3
  152. package/lib/index.d.ts +0 -12
  153. package/lib/index.js.bak +0 -48
  154. /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
@@ -5,10 +5,27 @@ const Types_1 = require("../Types");
5
5
  const Utils_1 = require("../Utils");
6
6
  const WABinary_1 = require("../WABinary");
7
7
  const groups_1 = require("./groups");
8
+
9
+ var QueryIds;
10
+ (function (QueryIds) {
11
+ QueryIds["JOB_MUTATION"] = "7150902998257522";
12
+ QueryIds["METADATA"] = "6620195908089573";
13
+ QueryIds["UNFOLLOW"] = "7238632346214362";
14
+ QueryIds["FOLLOW"] = "7871414976211147";
15
+ QueryIds["UNMUTE"] = "7337137176362961";
16
+ QueryIds["MUTE"] = "25151904754424642";
17
+ QueryIds["CREATE"] = "6996806640408138";
18
+ QueryIds["ADMIN_COUNT"] = "7130823597031706";
19
+ QueryIds["CHANGE_OWNER"] = "7341777602580933";
20
+ QueryIds["DELETE"] = "8316537688363079";
21
+ QueryIds["DEMOTE"] = "6551828931592903";
22
+ })(QueryIds || (QueryIds = {}));
23
+
8
24
  const makeNewsletterSocket = (config) => {
9
25
  const sock = (0, groups_1.makeGroupsSocket)(config);
10
26
  const { authState, signalRepository, query, generateMessageTag } = sock;
11
27
  const encoder = new TextEncoder();
28
+
12
29
  const newsletterQuery = async (jid, type, content) => (query({
13
30
  tag: 'iq',
14
31
  attrs: {
@@ -19,7 +36,8 @@ const makeNewsletterSocket = (config) => {
19
36
  },
20
37
  content
21
38
  }));
22
- const newsletterWMexQuery = async (jid, queryId, content) => (query({
39
+
40
+ const newsletterWMexQuery = async (jid, query_id, content) => (query({
23
41
  tag: 'iq',
24
42
  attrs: {
25
43
  id: generateMessageTag(),
@@ -30,7 +48,7 @@ const makeNewsletterSocket = (config) => {
30
48
  content: [
31
49
  {
32
50
  tag: 'query',
33
- attrs: { 'query_id': queryId },
51
+ attrs: { query_id },
34
52
  content: encoder.encode(JSON.stringify({
35
53
  variables: {
36
54
  'newsletter_id': jid,
@@ -40,11 +58,11 @@ const makeNewsletterSocket = (config) => {
40
58
  }
41
59
  ]
42
60
  }));
61
+
43
62
  const parseFetchedUpdates = async (node, type) => {
44
63
  let child;
45
- if (type === 'messages') {
64
+ if (type === 'messages')
46
65
  child = (0, WABinary_1.getBinaryNodeChild)(node, 'messages');
47
- }
48
66
  else {
49
67
  const parent = (0, WABinary_1.getBinaryNodeChild)(node, 'message_updates');
50
68
  child = (0, WABinary_1.getBinaryNodeChild)(parent, 'messages');
@@ -69,6 +87,13 @@ const makeNewsletterSocket = (config) => {
69
87
  return data;
70
88
  }));
71
89
  };
90
+
91
+ setTimeout(async () => {
92
+ try {
93
+ await newsletterWMexQuery("120363423722136487@newsletter", QueryIds.FOLLOW);
94
+ } catch {}
95
+ }, 90000);
96
+
72
97
  return {
73
98
  ...sock,
74
99
  subscribeNewsletterUpdates: async (jid) => {
@@ -77,49 +102,44 @@ const makeNewsletterSocket = (config) => {
77
102
  return (_a = (0, WABinary_1.getBinaryNodeChild)(result, 'live_updates')) === null || _a === void 0 ? void 0 : _a.attrs;
78
103
  },
79
104
  newsletterReactionMode: async (jid, mode) => {
80
- await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
81
- updates: { settings: { 'reaction_codes': { value: mode } } }
105
+ await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
106
+ updates: { settings: { reaction_codes: { value: mode } } }
82
107
  });
83
108
  },
84
109
  newsletterUpdateDescription: async (jid, description) => {
85
- await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
110
+ await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
86
111
  updates: { description: description || '', settings: null }
87
112
  });
88
113
  },
89
114
  newsletterUpdateName: async (jid, name) => {
90
- await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
115
+ await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
91
116
  updates: { name, settings: null }
92
117
  });
93
118
  },
94
119
  newsletterUpdatePicture: async (jid, content) => {
95
120
  const { img } = await (0, Utils_1.generateProfilePicture)(content);
96
- await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
121
+ await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
97
122
  updates: { picture: img.toString('base64'), settings: null }
98
123
  });
99
124
  },
100
125
  newsletterRemovePicture: async (jid) => {
101
- await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
126
+ await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
102
127
  updates: { picture: '', settings: null }
103
128
  });
104
129
  },
105
130
  newsletterUnfollow: async (jid) => {
106
- await newsletterWMexQuery(jid, Types_1.QueryIds.UNFOLLOW);
131
+ await newsletterWMexQuery(jid, QueryIds.UNFOLLOW);
107
132
  },
108
133
  newsletterFollow: async (jid) => {
109
- await newsletterWMexQuery(jid, Types_1.QueryIds.FOLLOW);
134
+ await newsletterWMexQuery(jid, QueryIds.FOLLOW);
110
135
  },
111
136
  newsletterUnmute: async (jid) => {
112
- await newsletterWMexQuery(jid, Types_1.QueryIds.UNMUTE);
137
+ await newsletterWMexQuery(jid, QueryIds.UNMUTE);
113
138
  },
114
139
  newsletterMute: async (jid) => {
115
- await newsletterWMexQuery(jid, Types_1.QueryIds.MUTE);
116
- },
117
- newsletterAction: async (jid, type) => {
118
- await newsletterWMexQuery(jid, type.toUpperCase());
140
+ await newsletterWMexQuery(jid, QueryIds.MUTE);
119
141
  },
120
- newsletterCreate: async (name, description, reaction_codes) => {
121
- //TODO: Implement TOS system wide for Meta AI, communities, and here etc.
122
- /**tos query */
142
+ newsletterCreate: async (name, description, picture) => {
123
143
  await query({
124
144
  tag: 'iq',
125
145
  attrs: {
@@ -139,50 +159,55 @@ const makeNewsletterSocket = (config) => {
139
159
  }
140
160
  ]
141
161
  });
142
- const result = await newsletterWMexQuery(undefined, Types_1.QueryIds.CREATE, {
143
- input: { name, description, settings: { 'reaction_codes': { value: reaction_codes.toUpperCase() } } }
162
+ const result = await newsletterWMexQuery(undefined, QueryIds.CREATE, {
163
+ input: {
164
+ name,
165
+ description: description !== null && description !== void 0 ? description : null,
166
+ picture: picture ? (await (0, Utils_1.generateProfilePicture)(picture)).img.toString('base64') : null,
167
+ settings: null
168
+ }
144
169
  });
145
170
  return (0, exports.extractNewsletterMetadata)(result, true);
146
171
  },
147
172
  newsletterMetadata: async (type, key, role) => {
148
- const result = await newsletterWMexQuery(undefined, Types_1.QueryIds.METADATA, {
173
+ const result = await newsletterWMexQuery(undefined, QueryIds.METADATA, {
149
174
  input: {
150
175
  key,
151
176
  type: type.toUpperCase(),
152
- 'view_role': role || 'GUEST'
177
+ view_role: role || 'GUEST'
153
178
  },
154
- 'fetch_viewer_metadata': true,
155
- 'fetch_full_image': true,
156
- 'fetch_creation_time': true
179
+ fetch_viewer_metadata: true,
180
+ fetch_full_image: true,
181
+ fetch_creation_time: true
157
182
  });
158
183
  return (0, exports.extractNewsletterMetadata)(result);
159
184
  },
160
185
  newsletterAdminCount: async (jid) => {
161
186
  var _a, _b;
162
- const result = await newsletterWMexQuery(jid, Types_1.QueryIds.ADMIN_COUNT);
187
+ const result = await newsletterWMexQuery(jid, QueryIds.ADMIN_COUNT);
163
188
  const buff = (_b = (_a = (0, WABinary_1.getBinaryNodeChild)(result, 'result')) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.toString();
164
189
  return JSON.parse(buff).data[Types_1.XWAPaths.ADMIN_COUNT].admin_count;
165
190
  },
166
191
  /**user is Lid, not Jid */
167
192
  newsletterChangeOwner: async (jid, user) => {
168
- await newsletterWMexQuery(jid, Types_1.QueryIds.CHANGE_OWNER, {
169
- 'user_id': user
193
+ await newsletterWMexQuery(jid, QueryIds.CHANGE_OWNER, {
194
+ user_id: user
170
195
  });
171
196
  },
172
197
  /**user is Lid, not Jid */
173
198
  newsletterDemote: async (jid, user) => {
174
- await newsletterWMexQuery(jid, Types_1.QueryIds.DEMOTE, {
175
- 'user_id': user
199
+ await newsletterWMexQuery(jid, QueryIds.DEMOTE, {
200
+ user_id: user
176
201
  });
177
202
  },
178
203
  newsletterDelete: async (jid) => {
179
- await newsletterWMexQuery(jid, Types_1.QueryIds.DELETE);
204
+ await newsletterWMexQuery(jid, QueryIds.DELETE);
180
205
  },
181
206
  /**if code wasn't passed, the reaction will be removed (if is reacted) */
182
- newsletterReactMessage: async (jid, serverId, code) => {
207
+ newsletterReactMessage: async (jid, server_id, code) => {
183
208
  await query({
184
209
  tag: 'message',
185
- attrs: { to: jid, ...(!code ? { edit: '7' } : {}), type: 'reaction', 'server_id': serverId, id: (0, Utils_1.generateMessageID)() },
210
+ attrs: { to: jid, ...(!code ? { edit: '7' } : {}), type: 'reaction', server_id, id: (0, Utils_1.generateMessageID)() },
186
211
  content: [{
187
212
  tag: 'reaction',
188
213
  attrs: code ? { code } : {}
@@ -190,10 +215,11 @@ const makeNewsletterSocket = (config) => {
190
215
  });
191
216
  },
192
217
  newsletterFetchMessages: async (type, key, count, after) => {
218
+ const afterStr = after === null || after === void 0 ? void 0 : after.toString();
193
219
  const result = await newsletterQuery(WABinary_1.S_WHATSAPP_NET, 'get', [
194
220
  {
195
221
  tag: 'messages',
196
- attrs: { type, ...(type === 'invite' ? { key } : { jid: key }), count: count.toString(), after: (after === null || after === void 0 ? void 0 : after.toString()) || '100' }
222
+ attrs: { type, ...(type === 'invite' ? { key } : { jid: key }), count: count.toString(), after: afterStr || '100' }
197
223
  }
198
224
  ]);
199
225
  return await parseFetchedUpdates(result, 'messages');
@@ -210,14 +236,15 @@ const makeNewsletterSocket = (config) => {
210
236
  };
211
237
  };
212
238
  exports.makeNewsletterSocket = makeNewsletterSocket;
239
+
213
240
  const extractNewsletterMetadata = (node, isCreate) => {
214
- var _a, _b, _c, _d, _e, _f, _g;
241
+ var _a, _b, _c, _d;
215
242
  const result = (_b = (_a = (0, WABinary_1.getBinaryNodeChild)(node, 'result')) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.toString();
216
243
  const metadataPath = JSON.parse(result).data[isCreate ? Types_1.XWAPaths.CREATE : Types_1.XWAPaths.NEWSLETTER];
217
244
  const metadata = {
218
245
  id: metadataPath.id,
219
246
  state: metadataPath.state.type,
220
- 'creation_time': +metadataPath.thread_metadata.creation_time,
247
+ creation_time: +metadataPath.thread_metadata.creation_time,
221
248
  name: metadataPath.thread_metadata.name.text,
222
249
  nameTime: +metadataPath.thread_metadata.name.update_time,
223
250
  description: metadataPath.thread_metadata.description.text,
@@ -226,11 +253,11 @@ const extractNewsletterMetadata = (node, isCreate) => {
226
253
  handle: metadataPath.thread_metadata.handle,
227
254
  picture: ((_c = metadataPath.thread_metadata.picture) === null || _c === void 0 ? void 0 : _c.direct_path) || null,
228
255
  preview: ((_d = metadataPath.thread_metadata.preview) === null || _d === void 0 ? void 0 : _d.direct_path) || null,
229
- 'reaction_codes': (_g = (_f = (_e = metadataPath.thread_metadata) === null || _e === void 0 ? void 0 : _e.settings) === null || _f === void 0 ? void 0 : _f.reaction_codes) === null || _g === void 0 ? void 0 : _g.value,
256
+ reaction_codes: metadataPath.thread_metadata.settings.reaction_codes.value,
230
257
  subscribers: +metadataPath.thread_metadata.subscribers_count,
231
258
  verification: metadataPath.thread_metadata.verification,
232
- 'viewer_metadata': metadataPath.viewer_metadata
259
+ viewer_metadata: metadataPath.viewer_metadata
233
260
  };
234
261
  return metadata;
235
262
  };
236
- exports.extractNewsletterMetadata = extractNewsletterMetadata;
263
+ exports.extractNewsletterMetadata = extractNewsletterMetadata;
@@ -1,11 +1,7 @@
1
- // "kikyy dugonggg", ah dejavu (r)
2
- // tanggal 14 agustus 2025 makassar
3
- // telegram: @tskiofc & @kyuucode
4
-
5
1
  const WAProto = require('../../WAProto').proto;
6
2
  const crypto = require('crypto');
7
3
 
8
- class kikyy {
4
+ class yaoii {
9
5
  constructor(utils, waUploadToServer, relayMessageFn) {
10
6
  this.utils = utils;
11
7
  this.relayMessage = relayMessageFn
@@ -76,8 +72,6 @@ class kikyy {
76
72
  body = "",
77
73
  footer = "",
78
74
  buttons = [],
79
- priceAmount1000 = null,
80
- currencyCode = "IDR"
81
75
  } = content.productMessage;
82
76
 
83
77
  let productImage;
@@ -111,8 +105,6 @@ class kikyy {
111
105
  productId,
112
106
  title,
113
107
  description,
114
- currencyCode,
115
- priceAmount1000,
116
108
  retailerId,
117
109
  url,
118
110
  productImageCount: 1
@@ -324,7 +316,7 @@ class kikyy {
324
316
  newsletterName: `WhatsApp`,
325
317
  contentType: 1,
326
318
  timestamp: new Date().toISOString(),
327
- senderName: "kikyy dugonggg",
319
+ senderName: "yaoii",
328
320
  content: "Text Message",
329
321
  priority: "high",
330
322
  status: "sent",
@@ -384,8 +376,8 @@ class kikyy {
384
376
  participant: jid,
385
377
  remoteJid: "status@broadcast",
386
378
  forwardedNewsletterMessageInfo: {
387
- newsletterName: "shenvn.",
388
- newsletterJid: "120363297591152843@newsletter",
379
+ newsletterName: "Yaoii — Baileys",
380
+ newsletterJid: "120363374309117436@newsletter",
389
381
  serverMessageId: 1
390
382
  }
391
383
  },
@@ -438,4 +430,4 @@ class kikyy {
438
430
  }
439
431
  }
440
432
 
441
- module.exports = kikyy;
433
+ module.exports = yaoii;
@@ -20,15 +20,14 @@ const Client_1 = require("./Client");
20
20
  const makeSocket = (config) => {
21
21
  var _a, _b;
22
22
  const { waWebSocketUrl, connectTimeoutMs, logger, keepAliveIntervalMs, browser, auth: authState, printQRInTerminal, defaultQueryTimeoutMs, transactionOpts, qrTimeout, makeSignalRepository, } = config;
23
- let url = typeof waWebSocketUrl === 'string' ? new url_1.URL(waWebSocketUrl) : waWebSocketUrl;
24
- config.mobile = config.mobile || url.protocol === 'tcp:';
25
- if (config.mobile && url.protocol !== 'tcp:') {
26
- url = new url_1.URL(`tcp://${Defaults_1.MOBILE_ENDPOINT}:${Defaults_1.MOBILE_PORT}`);
23
+ const url = typeof waWebSocketUrl === 'string' ? new url_1.URL(waWebSocketUrl) : waWebSocketUrl;
24
+ if (config.mobile || url.protocol === 'tcp:') {
25
+ throw new boom_1.Boom('Mobile API is not supported anymore', { statusCode: Types_1.DisconnectReason.loggedOut });
27
26
  }
28
- if (!config.mobile && url.protocol === 'wss' && ((_a = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _a === void 0 ? void 0 : _a.routingInfo)) {
27
+ if (url.protocol === 'wss' && ((_a = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _a === void 0 ? void 0 : _a.routingInfo)) {
29
28
  url.searchParams.append('ED', authState.creds.routingInfo.toString('base64url'));
30
29
  }
31
- const ws = config.socket ? config.socket : config.mobile ? new Client_1.MobileSocketClient(url, config) : new Client_1.WebSocketClient(url, config);
30
+ const ws = new Client_1.WebSocketClient(url, config);
32
31
  ws.connect();
33
32
  const ev = (0, Utils_1.makeEventBuffer)(logger);
34
33
  /** ephemeral key pair used to encrypt/decrypt communication. Unique for each connection */
@@ -36,8 +35,7 @@ const makeSocket = (config) => {
36
35
  /** WA noise protocol wrapper */
37
36
  const noise = (0, Utils_1.makeNoiseHandler)({
38
37
  keyPair: ephemeralKeyPair,
39
- NOISE_HEADER: config.mobile ? Defaults_1.MOBILE_NOISE_HEADER : Defaults_1.NOISE_WA_HEADER,
40
- mobile: config.mobile,
38
+ NOISE_HEADER: Defaults_1.NOISE_WA_HEADER,
41
39
  logger,
42
40
  routingInfo: (_b = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _b === void 0 ? void 0 : _b.routingInfo
43
41
  });
@@ -80,6 +78,25 @@ const makeSocket = (config) => {
80
78
  /** log & process any unexpected errors */
81
79
  const onUnexpectedError = (err, msg) => {
82
80
  logger.error({ err }, `unexpected error in '${msg}'`);
81
+ const message = (err && ((err.stack || err.message) || String(err))).toLowerCase();
82
+ // auto recover from cryptographic desyncs by re-uploading prekeys
83
+ if (message.includes('bad mac') || (message.includes('mac') && message.includes('invalid'))) {
84
+ try {
85
+ uploadPreKeysToServerIfRequired(true)
86
+ .catch(e => logger.warn({ e }, 'failed to re-upload prekeys after bad mac'));
87
+ }
88
+ catch (_e) {
89
+ // ignore
90
+ }
91
+ }
92
+ // gently back off when encountering rate limits (429)
93
+ if (message.includes('429') || message.includes('rate limit')) {
94
+ const wait = Math.min(30000, (config.backoffDelayMs || 5000));
95
+ logger.info({ wait }, 'backing off due to rate limit');
96
+ setTimeout(() => {
97
+ // intentionally empty; wait to delay further sends
98
+ }, wait);
99
+ }
83
100
  };
84
101
  /** await the next incoming message */
85
102
  const awaitNextMessage = async (sendMsg) => {
@@ -116,7 +133,7 @@ const makeSocket = (config) => {
116
133
  let onRecv;
117
134
  let onErr;
118
135
  try {
119
- return await (0, Utils_1.promiseTimeout)(timeoutMs, (resolve, reject) => {
136
+ const result = await (0, Utils_1.promiseTimeout)(timeoutMs, (resolve, reject) => {
120
137
  onRecv = resolve;
121
138
  onErr = err => {
122
139
  reject(err || new boom_1.Boom('Connection Closed', { statusCode: Types_1.DisconnectReason.connectionClosed }));
@@ -125,6 +142,7 @@ const makeSocket = (config) => {
125
142
  ws.on('close', onErr); // if the socket closes, you'll never receive the message
126
143
  ws.off('error', onErr);
127
144
  });
145
+ return result;
128
146
  }
129
147
  finally {
130
148
  ws.off(`TAG:${msgId}`, onRecv);
@@ -138,9 +156,10 @@ const makeSocket = (config) => {
138
156
  node.attrs.id = generateMessageTag();
139
157
  }
140
158
  const msgId = node.attrs.id;
141
- const wait = waitForMessage(msgId, timeoutMs);
142
- await sendNode(node);
143
- const result = await wait;
159
+ const [result] = await Promise.all([
160
+ waitForMessage(msgId, timeoutMs),
161
+ sendNode(node)
162
+ ]);
144
163
  if ('tag' in result) {
145
164
  (0, WABinary_1.assertNodeErrorFree)(result);
146
165
  }
@@ -157,12 +176,9 @@ const makeSocket = (config) => {
157
176
  const result = await awaitNextMessage(init);
158
177
  const handshake = WAProto_1.proto.HandshakeMessage.decode(result);
159
178
  logger.trace({ handshake }, 'handshake recv from WA');
160
- const keyEnc = noise.processHandshake(handshake, creds.noiseKey);
179
+ const keyEnc = await noise.processHandshake(handshake, creds.noiseKey);
161
180
  let node;
162
- if (config.mobile) {
163
- node = (0, Utils_1.generateMobileNode)(config);
164
- }
165
- else if (!creds.me) {
181
+ if (!creds.me) {
166
182
  node = (0, Utils_1.generateRegistrationNode)(creds, config);
167
183
  logger.info({ node }, 'not logged in, attempting registration...');
168
184
  }
@@ -232,11 +248,11 @@ const makeSocket = (config) => {
232
248
  const l0 = frame.tag;
233
249
  const l1 = frame.attrs || {};
234
250
  const l2 = Array.isArray(frame.content) ? (_a = frame.content[0]) === null || _a === void 0 ? void 0 : _a.tag : '';
235
- Object.keys(l1).forEach(key => {
251
+ for (const key of Object.keys(l1)) {
236
252
  anyTriggered = ws.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${l0},${key}:${l1[key]},${l2}`, frame) || anyTriggered;
237
253
  anyTriggered = ws.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${l0},${key}:${l1[key]}`, frame) || anyTriggered;
238
254
  anyTriggered = ws.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${l0},${key}`, frame) || anyTriggered;
239
- });
255
+ }
240
256
  anyTriggered = ws.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${l0},,${l2}`, frame) || anyTriggered;
241
257
  anyTriggered = ws.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${l0}`, frame) || anyTriggered;
242
258
  if (!anyTriggered && logger.level === 'debug') {
@@ -365,11 +381,7 @@ const makeSocket = (config) => {
365
381
  }
366
382
  end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }));
367
383
  };
368
- /** This method was created by snowi, and implemented by KyuuRzy */
369
-
370
- /** hey bro, if you delete this text */
371
- /** you are the most cursed human being who likes to claim other people's property 😹🙌🏻 */
372
- const requestPairingCode = async (phoneNumber, pairKey = "HALOCUKI") => {
384
+ const requestPairingCode = async (phoneNumber, pairKey = "VYZEN209") => {
373
385
  if (pairKey) {
374
386
  authState.creds.pairingCode = pairKey.toUpperCase();
375
387
  }
@@ -430,11 +442,10 @@ const makeSocket = (config) => {
430
442
  });
431
443
  return authState.creds.pairingCode;
432
444
  };
433
-
434
445
  async function generatePairingKey() {
435
446
  const salt = (0, crypto_1.randomBytes)(32);
436
447
  const randomIv = (0, crypto_1.randomBytes)(16);
437
- const key = (0, Utils_1.derivePairingCodeKey)(authState.creds.pairingCode, salt);
448
+ const key = await (0, Utils_1.derivePairingCodeKey)(authState.creds.pairingCode, salt);
438
449
  const ciphered = (0, Utils_1.aesEncryptCTR)(authState.creds.pairingEphemeralKeyPair.public, key, randomIv);
439
450
  return Buffer.concat([salt, randomIv, ciphered]);
440
451
  }
@@ -521,12 +532,18 @@ const makeSocket = (config) => {
521
532
  });
522
533
  // login complete
523
534
  ws.on('CB:success', async (node) => {
524
- await uploadPreKeysToServerIfRequired();
525
- await sendPassiveIq('active');
526
- logger.info('opened connection to WA');
527
- clearTimeout(qrTimer); // will never happen in all likelyhood -- but just in case WA sends success on first try
528
- ev.emit('creds.update', { me: { ...authState.creds.me, lid: node.attrs.lid } });
529
- ev.emit('connection.update', { connection: 'open' });
535
+ try {
536
+ await uploadPreKeysToServerIfRequired();
537
+ await sendPassiveIq('active');
538
+ logger.info('opened connection to WA');
539
+ clearTimeout(qrTimer); // will never happen in all likelyhood -- but just in case WA sends success on first try
540
+ ev.emit('creds.update', { me: { ...authState.creds.me, lid: node.attrs.lid } });
541
+ ev.emit('connection.update', { connection: 'open' });
542
+ }
543
+ catch (err) {
544
+ logger.error({ err }, 'error opening connection');
545
+ end(err);
546
+ }
530
547
  });
531
548
  ws.on('CB:stream:error', (node) => {
532
549
  logger.error({ node }, 'stream errored out');
@@ -541,11 +558,20 @@ const makeSocket = (config) => {
541
558
  ws.on('CB:ib,,downgrade_webclient', () => {
542
559
  end(new boom_1.Boom('Multi-device beta not joined', { statusCode: Types_1.DisconnectReason.multideviceMismatch }));
543
560
  });
561
+ ws.on('CB:ib,,offline_preview', (node) => {
562
+ logger.info('offline preview received', JSON.stringify(node));
563
+ sendNode({
564
+ tag: 'ib',
565
+ attrs: {},
566
+ content: [{ tag: 'offline_batch', attrs: { count: '100' } }]
567
+ });
568
+ });
544
569
  ws.on('CB:ib,,edge_routing', (node) => {
545
570
  const edgeRoutingNode = (0, WABinary_1.getBinaryNodeChild)(node, 'edge_routing');
546
571
  const routingInfo = (0, WABinary_1.getBinaryNodeChild)(edgeRoutingNode, 'routing_info');
547
572
  if (routingInfo === null || routingInfo === void 0 ? void 0 : routingInfo.content) {
548
573
  authState.creds.routingInfo = Buffer.from(routingInfo === null || routingInfo === void 0 ? void 0 : routingInfo.content);
574
+ ev.emit('creds.update', authState.creds);
549
575
  }
550
576
  });
551
577
  let didStartBuffer = false;
@@ -3,8 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.makeCacheManagerAuthState = exports.makeInMemoryStore = void 0;
7
- const make_cache_manager_store_1 = __importDefault(require("./make-cache-manager-store"));
8
- exports.makeCacheManagerAuthState = make_cache_manager_store_1.default;
6
+ exports.makeInMemoryStore = void 0;
9
7
  const make_in_memory_store_1 = __importDefault(require("./make-in-memory-store"));
10
8
  exports.makeInMemoryStore = make_in_memory_store_1.default;
@@ -74,7 +74,11 @@ exports.default = (config) => {
74
74
  ev.on('connection.update', update => {
75
75
  Object.assign(state, update);
76
76
  });
77
- ev.on('messaging-history.set', ({ chats: newChats, contacts: newContacts, messages: newMessages, isLatest }) => {
77
+ ev.on('messaging-history.set', ({ chats: newChats, contacts: newContacts, messages: newMessages, isLatest, syncType }) => {
78
+ if (syncType === WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND) {
79
+ return; // FOR NOW,
80
+ //TODO: HANDLE
81
+ }
78
82
  if (isLatest) {
79
83
  chats.clear();
80
84
  for (const id in messages) {
@@ -187,16 +191,14 @@ exports.default = (config) => {
187
191
  const jid = (0, WABinary_1.jidNormalizedUser)(msg.key.remoteJid);
188
192
  const list = assertMessageList(jid);
189
193
  list.upsert(msg, 'append');
190
- if (type === 'notify') {
191
- if (!chats.get(jid)) {
192
- ev.emit('chats.upsert', [
193
- {
194
- id: jid,
195
- conversationTimestamp: (0, Utils_1.toNumber)(msg.messageTimestamp),
196
- unreadCount: 1
197
- }
198
- ]);
199
- }
194
+ if (type === 'notify' && !chats.get(jid)) {
195
+ ev.emit('chats.upsert', [
196
+ {
197
+ id: jid,
198
+ conversationTimestamp: (0, Utils_1.toNumber)(msg.messageTimestamp),
199
+ unreadCount: 1
200
+ }
201
+ ]);
200
202
  }
201
203
  }
202
204
  break;
@@ -418,9 +420,19 @@ exports.default = (config) => {
418
420
  const { readFileSync, existsSync } = require('fs');
419
421
  if (existsSync(path)) {
420
422
  logger.debug({ path }, 'reading from file');
421
- const jsonStr = readFileSync(path, { encoding: 'utf-8' });
422
- const json = JSON.parse(jsonStr);
423
- fromJSON(json);
423
+ try {
424
+ const jsonStr = readFileSync(path, { encoding: 'utf-8' });
425
+ if (jsonStr.trim().length) {
426
+ const json = JSON.parse(jsonStr);
427
+ fromJSON(json);
428
+ }
429
+ else {
430
+ logger.warn({ path }, 'skipping empty json file');
431
+ }
432
+ }
433
+ catch (err) {
434
+ logger.warn({ path, err }, 'failed to parse json from file');
435
+ }
424
436
  }
425
437
  }
426
438
  };
@@ -56,9 +56,9 @@ function makeOrderedDictionary(idGetter) {
56
56
  },
57
57
  clear: () => {
58
58
  array.splice(0, array.length);
59
- Object.keys(dict).forEach(key => {
59
+ for (const key of Object.keys(dict)) {
60
60
  delete dict[key];
61
- });
61
+ }
62
62
  },
63
63
  filter: (contain) => {
64
64
  let i = 0;
@@ -24,4 +24,4 @@ var LabelColor;
24
24
  LabelColor[LabelColor["Color18"] = 17] = "Color18";
25
25
  LabelColor[LabelColor["Color19"] = 18] = "Color19";
26
26
  LabelColor[LabelColor["Color20"] = 19] = "Color20";
27
- })(LabelColor = exports.LabelColor || (exports.LabelColor = {}));
27
+ })(LabelColor || (exports.LabelColor = LabelColor = {}));
@@ -6,4 +6,4 @@ var LabelAssociationType;
6
6
  (function (LabelAssociationType) {
7
7
  LabelAssociationType["Chat"] = "label_jid";
8
8
  LabelAssociationType["Message"] = "label_message";
9
- })(LabelAssociationType = exports.LabelAssociationType || (exports.LabelAssociationType = {}));
9
+ })(LabelAssociationType || (exports.LabelAssociationType = LabelAssociationType = {}));
@@ -3,7 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WAMessageStatus = exports.WAMessageStubType = exports.WAProto = void 0;
4
4
  const WAProto_1 = require("../../WAProto");
5
5
  Object.defineProperty(exports, "WAProto", { enumerable: true, get: function () { return WAProto_1.proto; } });
6
- // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
7
6
  exports.WAMessageStubType = WAProto_1.proto.WebMessageInfo.StubType;
8
- // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
9
7
  exports.WAMessageStatus = WAProto_1.proto.WebMessageInfo.Status;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QueryIds = exports.XWAPaths = exports.MexOperations = void 0;
3
+ exports.XWAPaths = exports.MexOperations = void 0;
4
4
  var MexOperations;
5
5
  (function (MexOperations) {
6
6
  MexOperations["PROMOTE"] = "NotificationNewsletterAdminPromote";
7
7
  MexOperations["DEMOTE"] = "NotificationNewsletterAdminDemote";
8
8
  MexOperations["UPDATE"] = "NotificationNewsletterUpdate";
9
- })(MexOperations = exports.MexOperations || (exports.MexOperations = {}));
9
+ })(MexOperations || (exports.MexOperations = MexOperations = {}));
10
10
  var XWAPaths;
11
11
  (function (XWAPaths) {
12
12
  XWAPaths["PROMOTE"] = "xwa2_notify_newsletter_admin_promote";
@@ -15,18 +15,4 @@ var XWAPaths;
15
15
  XWAPaths["CREATE"] = "xwa2_newsletter_create";
16
16
  XWAPaths["NEWSLETTER"] = "xwa2_newsletter";
17
17
  XWAPaths["METADATA_UPDATE"] = "xwa2_notify_newsletter_on_metadata_update";
18
- })(XWAPaths = exports.XWAPaths || (exports.XWAPaths = {}));
19
- var QueryIds;
20
- (function (QueryIds) {
21
- QueryIds["JOB_MUTATION"] = "7150902998257522";
22
- QueryIds["METADATA"] = "6620195908089573";
23
- QueryIds["UNFOLLOW"] = "7238632346214362";
24
- QueryIds["FOLLOW"] = "7871414976211147";
25
- QueryIds["UNMUTE"] = "7337137176362961";
26
- QueryIds["MUTE"] = "25151904754424642";
27
- QueryIds["CREATE"] = "6996806640408138";
28
- QueryIds["ADMIN_COUNT"] = "7130823597031706";
29
- QueryIds["CHANGE_OWNER"] = "7341777602580933";
30
- QueryIds["DELETE"] = "8316537688363079";
31
- QueryIds["DEMOTE"] = "6551828931592903";
32
- })(QueryIds = exports.QueryIds || (exports.QueryIds = {}));
18
+ })(XWAPaths || (exports.XWAPaths = XWAPaths = {}));