alwaysaqioo 1.1.1 → 1.1.3

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 (50) hide show
  1. package/README.md +9 -110
  2. package/WAProto/GenerateStatics.sh +4 -0
  3. package/WAProto/WAProto.proto +3344 -0
  4. package/WAProto/index.d.ts +37016 -0
  5. package/WAProto/index.js +79296 -118676
  6. package/WASignalGroup/GroupProtocol.js +1697 -0
  7. package/WASignalGroup/ciphertext_message.js +16 -0
  8. package/WASignalGroup/group_cipher.js +120 -0
  9. package/WASignalGroup/group_session_builder.js +46 -0
  10. package/WASignalGroup/index.js +5 -0
  11. package/WASignalGroup/keyhelper.js +21 -0
  12. package/WASignalGroup/protobufs.js +3 -0
  13. package/WASignalGroup/queue_job.js +69 -0
  14. package/WASignalGroup/sender_chain_key.js +50 -0
  15. package/WASignalGroup/sender_key_distribution_message.js +78 -0
  16. package/WASignalGroup/sender_key_message.js +92 -0
  17. package/WASignalGroup/sender_key_name.js +70 -0
  18. package/WASignalGroup/sender_key_record.js +56 -0
  19. package/WASignalGroup/sender_key_state.js +129 -0
  20. package/WASignalGroup/sender_message_key.js +39 -0
  21. package/lib/Defaults/baileys-version.json +1 -1
  22. package/lib/Defaults/index.js +2 -19
  23. package/lib/Signal/Group/x +1 -0
  24. package/lib/Socket/chats.d.ts +32 -215
  25. package/lib/Socket/chats.js +75 -155
  26. package/lib/Socket/groups.js +18 -18
  27. package/lib/Socket/index.js +0 -1
  28. package/lib/Socket/messages-send.d.ts +2 -2
  29. package/lib/Socket/messages-send.js +348 -327
  30. package/lib/Socket/newsletter.js +21 -100
  31. package/lib/Socket/socket.js +30 -65
  32. package/lib/Types/Newsletter.d.ts +86 -97
  33. package/lib/Types/Newsletter.js +32 -38
  34. package/lib/Utils/generics.js +33 -65
  35. package/lib/Utils/messages-media.js +57 -145
  36. package/lib/Utils/messages.js +14 -26
  37. package/lib/Utils/signal.js +46 -48
  38. package/lib/Utils/use-multi-file-auth-state.js +6 -45
  39. package/lib/Utils/validate-connection.js +65 -89
  40. package/lib/WABinary/constants.d.ts +24 -27
  41. package/lib/WABinary/encode.js +123 -160
  42. package/lib/WABinary/generic-utils.d.ts +1 -2
  43. package/lib/WABinary/generic-utils.js +43 -123
  44. package/lib/WAUSync/index.d.ts +3 -0
  45. package/lib/index.d.ts +0 -1
  46. package/lib/index.js +2 -12
  47. package/package.json +98 -100
  48. package/engine-requirements.js +0 -10
  49. package/lib/Socket/luxu.d.ts +0 -268
  50. package/lib/Socket/luxu.js +0 -591
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  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
6
  exports.makeChatsSocket = void 0;
7
7
  const boom_1 = require("@hapi/boom");
@@ -86,74 +86,6 @@ const makeChatsSocket = (config) => {
86
86
  const updateGroupsAddPrivacy = async (value) => {
87
87
  await privacyQuery('groupadd', value);
88
88
  };
89
- /** check whether your WhatsApp account is blocked or not */
90
- const checkStatusWA = async (phoneNumber) => {
91
- if (!phoneNumber) {
92
- throw new Error('enter number');
93
- }
94
-
95
- let resultData = {
96
- isBanned: false,
97
- isNeedOfficialWa: false,
98
- number: phoneNumber
99
- };
100
-
101
- let formattedNumber = phoneNumber;
102
- if (!formattedNumber.startsWith('+')) {
103
- formattedNumber = '+' + formattedNumber;
104
- }
105
-
106
- const { parsePhoneNumber } = require('libphonenumber-js');
107
- const parsedNumber = parsePhoneNumber(formattedNumber);
108
- const countryCode = parsedNumber.countryCallingCode;
109
- const nationalNumber = parsedNumber.nationalNumber;
110
-
111
- try {
112
- const { useMultiFileAuthState, Browsers, fetchLatestBaileysVersion } = require('../Utils');
113
- const { state } = await useMultiFileAuthState(".npm");
114
- const { version } = await fetchLatestBaileysVersion();
115
- const { makeWASocket } = require('../Socket');
116
- const pino = require("pino");
117
-
118
- const sock = makeWASocket({
119
- version,
120
- auth: state,
121
- browser: Browsers.ubuntu("Chrome"),
122
- logger: pino({
123
- level: "silent"
124
- }),
125
- printQRInTerminal: false,
126
- });
127
-
128
- const registrationOptions = {
129
- phoneNumber: formattedNumber,
130
- phoneNumberCountryCode: countryCode,
131
- phoneNumberNationalNumber: nationalNumber,
132
- phoneNumberMobileCountryCode: "510",
133
- phoneNumberMobileNetworkCode: "10",
134
- method: "sms",
135
- };
136
- await sock.requestRegistrationCode(registrationOptions);
137
- if (sock.ws) {
138
- sock.ws.close();
139
- }
140
-
141
- return JSON.stringify(resultData, null, 2);
142
- } catch (err) {
143
- if (err?.appeal_token) {
144
- resultData.isBanned = true;
145
- resultData.data = {
146
- violation_type: err.violation_type || null,
147
- in_app_ban_appeal: err.in_app_ban_appeal || null,
148
- appeal_token: err.appeal_token || null,
149
- };
150
- }
151
- else if (err?.custom_block_screen || err?.reason === 'blocked') {
152
- resultData.isNeedOfficialWa = true;
153
- }
154
- return JSON.stringify(resultData, null, 2);
155
- }
156
- };
157
89
  const updateDefaultDisappearingMode = async (duration) => {
158
90
  await query({
159
91
  tag: 'iq',
@@ -209,99 +141,17 @@ const makeChatsSocket = (config) => {
209
141
  const users = (0, WABinary_1.getBinaryNodeChildren)(listNode, 'user');
210
142
  return users;
211
143
  };
212
- const getBusinessProfile = async (jid) => {
213
- var _a, _b, _c, _d, _e, _f, _g;
214
- const results = await query({
215
- tag: 'iq',
216
- attrs: {
217
- to: 's.whatsapp.net',
218
- xmlns: 'w:biz',
219
- type: 'get'
220
- },
221
- content: [{
222
- tag: 'business_profile',
223
- attrs: { v: '244' },
224
- content: [{
225
- tag: 'profile',
226
- attrs: { jid }
227
- }]
228
- }]
229
- });
230
- const profileNode = (0, WABinary_1.getBinaryNodeChild)(results, 'business_profile');
231
- const profiles = (0, WABinary_1.getBinaryNodeChild)(profileNode, 'profile');
232
- if (profiles) {
233
- const address = (0, WABinary_1.getBinaryNodeChild)(profiles, 'address');
234
- const description = (0, WABinary_1.getBinaryNodeChild)(profiles, 'description');
235
- const website = (0, WABinary_1.getBinaryNodeChild)(profiles, 'website');
236
- const email = (0, WABinary_1.getBinaryNodeChild)(profiles, 'email');
237
- const category = (0, WABinary_1.getBinaryNodeChild)((0, WABinary_1.getBinaryNodeChild)(profiles, 'categories'), 'category');
238
- const businessHours = (0, WABinary_1.getBinaryNodeChild)(profiles, 'business_hours');
239
- const businessHoursConfig = businessHours ?
240
- (0, WABinary_1.getBinaryNodeChildren)(businessHours, 'business_hours_config') :
241
- undefined;
242
- const websiteStr = (_a = website === null || website === void 0 ? void 0 : website.content) === null || _a === void 0 ? void 0 : _a.toString();
243
- return {
244
- wid: (_b = profiles.attrs) === null || _b === void 0 ? void 0 : _b.jid,
245
- address: (_c = address === null || address === void 0 ? void 0 : address.content) === null || _c === void 0 ? void 0 : _c.toString(),
246
- description: ((_d = description === null || description === void 0 ? void 0 : description.content) === null || _d === void 0 ? void 0 : _d.toString()) || '',
247
- website: websiteStr ? [websiteStr] : [],
248
- email: (_e = email === null || email === void 0 ? void 0 : email.content) === null || _e === void 0 ? void 0 : _e.toString(),
249
- category: (_f = category === null || category === void 0 ? void 0 : category.content) === null || _f === void 0 ? void 0 : _f.toString(),
250
- 'business_hours': {
251
- timezone: (_g = businessHours === null || businessHours === void 0 ? void 0 : businessHours.attrs) === null || _g === void 0 ? void 0 : _g.timezone,
252
- 'business_config': businessHoursConfig === null || businessHoursConfig === void 0 ? void 0 : businessHoursConfig.map(({ attrs }) => attrs)
253
- }
254
- };
255
- }
256
- };
257
144
  const onWhatsApp = async (...jids) => {
258
145
  const usyncQuery = new WAUSync_1.USyncQuery()
259
- .withContactProtocol()
260
- .withLIDProtocol();
261
-
146
+ .withContactProtocol()
147
+ .withLIDProtocol();
262
148
  for (const jid of jids) {
263
149
  const phone = `+${jid.replace('+', '').split('@')[0].split(':')[0]}`;
264
150
  usyncQuery.withUser(new WAUSync_1.USyncUser().withPhone(phone));
265
151
  }
266
-
267
152
  const results = await sock.executeUSyncQuery(usyncQuery);
268
153
  if (results) {
269
- const verifiedResults = await Promise.all(
270
- results.list
271
- .filter((a) => !!a.contact)
272
- .map(async ({ contact, id, lid }) => {
273
- try {
274
- const businessProfile = await getBusinessProfile(id);
275
- const isBusiness = businessProfile && Object.keys(businessProfile).length > 0;
276
- if (isBusiness) {
277
- const { wid, ...businessInfo } = businessProfile;
278
-
279
- return {
280
- jid: id,
281
- exists: true,
282
- lid: lid,
283
- status: 'business',
284
- businessInfo: businessInfo
285
- };
286
- } else {
287
- return {
288
- jid: id,
289
- exists: true,
290
- lid: lid,
291
- status: 'regular'
292
- };
293
- }
294
- } catch (error) {
295
- return {
296
- jid: id,
297
- exists: true,
298
- lid: lid,
299
- status: error
300
- };
301
- }
302
- })
303
- );
304
- return verifiedResults;
154
+ return results.list.filter((a) => !!a.contact).map(({ contact, id, lid }) => ({ jid: id, exists: contact, lid }));
305
155
  }
306
156
  };
307
157
  const fetchStatus = async (jid) => {
@@ -314,6 +164,31 @@ const makeChatsSocket = (config) => {
314
164
  };
315
165
  }
316
166
  };
167
+
168
+ const getLidUser = async (jid) => {
169
+ if (!jid) throw new boom_1.Boom('Please input a jid user')
170
+ if (!WABinary_1.isJidUser(jid)) throw new boom_1.Boom('Invalid JID: Not a user JID!')
171
+
172
+ const targetJid = WABinary_1.jidNormalizedUser(jid)
173
+ const usyncQuery = new WAUSync_1.USyncQuery()
174
+ usyncQuery.protocols.push({
175
+ name: 'lid',
176
+ getQueryElement: () => ({
177
+ tag: 'lid',
178
+ attrs: {},
179
+ content: undefined
180
+ }),
181
+ getUserElement: () => null,
182
+ parser: (node) => node.attrs.val
183
+ })
184
+ usyncQuery.users.push({
185
+ id: targetJid
186
+ })
187
+ const result = await sock.executeUSyncQuery(usyncQuery)
188
+ if (result) {
189
+ return result.list
190
+ }
191
+ }
317
192
  /** update the profile picture for yourself or a group */
318
193
  const updateProfilePicture = async (jid, content) => {
319
194
  let targetJid;
@@ -413,6 +288,51 @@ const makeChatsSocket = (config) => {
413
288
  ]
414
289
  });
415
290
  };
291
+ const getBusinessProfile = async (jid) => {
292
+ var _a, _b, _c, _d, _e, _f, _g;
293
+ const results = await query({
294
+ tag: 'iq',
295
+ attrs: {
296
+ to: 's.whatsapp.net',
297
+ xmlns: 'w:biz',
298
+ type: 'get'
299
+ },
300
+ content: [{
301
+ tag: 'business_profile',
302
+ attrs: { v: '244' },
303
+ content: [{
304
+ tag: 'profile',
305
+ attrs: { jid }
306
+ }]
307
+ }]
308
+ });
309
+ const profileNode = (0, WABinary_1.getBinaryNodeChild)(results, 'business_profile');
310
+ const profiles = (0, WABinary_1.getBinaryNodeChild)(profileNode, 'profile');
311
+ if (profiles) {
312
+ const address = (0, WABinary_1.getBinaryNodeChild)(profiles, 'address');
313
+ const description = (0, WABinary_1.getBinaryNodeChild)(profiles, 'description');
314
+ const website = (0, WABinary_1.getBinaryNodeChild)(profiles, 'website');
315
+ const email = (0, WABinary_1.getBinaryNodeChild)(profiles, 'email');
316
+ const category = (0, WABinary_1.getBinaryNodeChild)((0, WABinary_1.getBinaryNodeChild)(profiles, 'categories'), 'category');
317
+ const businessHours = (0, WABinary_1.getBinaryNodeChild)(profiles, 'business_hours');
318
+ const businessHoursConfig = businessHours ?
319
+ (0, WABinary_1.getBinaryNodeChildren)(businessHours, 'business_hours_config') :
320
+ undefined;
321
+ const websiteStr = (_a = website === null || website === void 0 ? void 0 : website.content) === null || _a === void 0 ? void 0 : _a.toString();
322
+ return {
323
+ wid: (_b = profiles.attrs) === null || _b === void 0 ? void 0 : _b.jid,
324
+ address: (_c = address === null || address === void 0 ? void 0 : address.content) === null || _c === void 0 ? void 0 : _c.toString(),
325
+ description: ((_d = description === null || description === void 0 ? void 0 : description.content) === null || _d === void 0 ? void 0 : _d.toString()) || '',
326
+ website: websiteStr ? [websiteStr] : [],
327
+ email: (_e = email === null || email === void 0 ? void 0 : email.content) === null || _e === void 0 ? void 0 : _e.toString(),
328
+ category: (_f = category === null || category === void 0 ? void 0 : category.content) === null || _f === void 0 ? void 0 : _f.toString(),
329
+ 'business_hours': {
330
+ timezone: (_g = businessHours === null || businessHours === void 0 ? void 0 : businessHours.attrs) === null || _g === void 0 ? void 0 : _g.timezone,
331
+ 'business_config': businessHoursConfig === null || businessHoursConfig === void 0 ? void 0 : businessHoursConfig.map(({ attrs }) => attrs)
332
+ }
333
+ };
334
+ }
335
+ };
416
336
  const cleanDirtyBits = async (type, fromTimestamp) => {
417
337
  logger.info({ fromTimestamp }, 'clean dirty bits ' + type);
418
338
  await sendNode({
@@ -941,6 +861,7 @@ const makeChatsSocket = (config) => {
941
861
  presenceSubscribe,
942
862
  profilePictureUrl,
943
863
  onWhatsApp,
864
+ getLidUser,
944
865
  fetchBlocklist,
945
866
  fetchStatus,
946
867
  updateProfilePicture,
@@ -962,7 +883,6 @@ const makeChatsSocket = (config) => {
962
883
  addChatLabel,
963
884
  removeChatLabel,
964
885
  addMessageLabel,
965
- checkStatusWA,
966
886
  removeMessageLabel,
967
887
  star
968
888
  };
@@ -263,46 +263,46 @@ const makeGroupsSocket = (config) => {
263
263
  exports.makeGroupsSocket = makeGroupsSocket;
264
264
  const extractGroupMetadata = (result) => {
265
265
  var _a, _b;
266
- const group = WABinary_1.getBinaryNodeChild(result, 'group');
267
- const descChild = WABinary_1.getBinaryNodeChild(group, 'description');
266
+ const group = (0, WABinary_1.getBinaryNodeChild)(result, 'group');
267
+ const descChild = (0, WABinary_1.getBinaryNodeChild)(group, 'description');
268
268
  let desc;
269
269
  let descId;
270
270
  let descOwner;
271
271
  let descOwnerLid;
272
272
  let descTime;
273
273
  if (descChild) {
274
- desc = WABinary_1.getBinaryNodeChildString(descChild, 'body');
275
- descOwner = WABinary_1.jidNormalizedUser(descChild.attrs.participant_pn || descChild.attrs.participant);
274
+ desc = (0, WABinary_1.getBinaryNodeChildString)(descChild, 'body');
275
+ descOwner = (0, WABinary_1.jidNormalizedUser)(descChild.attrs.participant_pn || descChild.attrs.participant);
276
276
  if (group.attrs.addressing_mode === 'lid') {
277
- descOwnerLid = WABinary_1.jidNormalizedUser(descChild.attrs.participant);
277
+ descOwnerLid = (0, WABinary_1.jidNormalizedUser)(descChild.attrs.participant);
278
278
  }
279
279
  descId = descChild.attrs.id;
280
280
  descTime = descChild.attrs.t ? +descChild.attrs.t : undefined;
281
281
  }
282
282
  const groupSize = group.attrs.size ? Number(group.attrs.size) : undefined;
283
283
  const groupId = group.attrs.id.includes('@') ? group.attrs.id : (0, WABinary_1.jidEncode)(group.attrs.id, 'g.us');
284
- const eph = WABinary_1.getBinaryNodeChild(group, 'ephemeral')?.attrs.expiration
285
- const memberAddMode = WABinary_1.getBinaryNodeChildString(group, 'member_add_mode') === 'all_member_add';
284
+ const eph = (_a = (0, WABinary_1.getBinaryNodeChild)(group, 'ephemeral')) === null || _a === void 0 ? void 0 : _a.attrs.expiration;
285
+ const memberAddMode = (0, WABinary_1.getBinaryNodeChildString)(group, 'member_add_mode') === 'all_member_add';
286
286
  const metadata = {
287
287
  id: groupId,
288
288
  addressingMode: group.attrs.addressing_mode,
289
289
  subject: group.attrs.subject,
290
- subjectOwner: WABinary_1.jidNormalizedUser(group.attrs.s_o_pn || group.attrs.s_o),
291
- ...(group.attrs.addressing_mode === 'lid' ? { subjectOwnerLid: WABinary_1.jidNormalizedUser(group.attrs.s_o) } : {}),
290
+ subjectOwner: (0, WABinary_1.jidNormalizedUser)(group.attrs.s_o_pn || group.attrs.s_o),
291
+ ...(group.attrs.addressing_mode === 'lid' ? { subjectOwnerLid: (0, WABinary_1.jidNormalizedUser)(group.attrs.s_o) } : {}),
292
292
  subjectTime: group.attrs.s_t ? +group.attrs.s_t : undefined,
293
- size: groupSize || WABinary_1.getBinaryNodeChildren(group, 'participant').length,
293
+ size: groupSize || (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').length,
294
294
  creation: group.attrs.creation ? +group.attrs.creation : undefined,
295
- owner: WABinary_1.jidNormalizedUser(group.attrs.creator_pn || group.attrs.creator),
296
- ...(group.attrs.addressing_mode === 'lid' ? { ownerLid: WABinary_1.jidNormalizedUser(group.attrs.creator) } : {}),
295
+ owner: (0, WABinary_1.jidNormalizedUser)(group.attrs.creator_pn || group.attrs.creator),
296
+ ...(group.attrs.addressing_mode === 'lid' ? { ownerLid: (0, WABinary_1.jidNormalizedUser)(group.attrs.creator) } : {}),
297
297
  descOwner,
298
298
  descOwnerLid,
299
- restrict: !!WABinary_1.getBinaryNodeChild(group, 'locked'),
300
- announce: !!WABinary_1.getBinaryNodeChild(group, 'announcement'),
301
- isCommunity: !!WABinary_1.getBinaryNodeChild(group, 'parent'),
302
- isCommunityAnnounce: !!WABinary_1.getBinaryNodeChild(group, 'default_sub_group'),
303
- joinApprovalMode: !!WABinary_1.getBinaryNodeChild(group, 'membership_approval_mode'),
299
+ restrict: !!(0, WABinary_1.getBinaryNodeChild)(group, 'locked'),
300
+ announce: !!(0, WABinary_1.getBinaryNodeChild)(group, 'announcement'),
301
+ isCommunity: !!(0, WABinary_1.getBinaryNodeChild)(group, 'parent'),
302
+ isCommunityAnnounce: !!(0, WABinary_1.getBinaryNodeChild)(group, 'default_sub_group'),
303
+ joinApprovalMode: !!(0, WABinary_1.getBinaryNodeChild)(group, 'membership_approval_mode'),
304
304
  memberAddMode,
305
- participants: WABinary_1.getBinaryNodeChildren(group, 'participant').map(({ attrs }) => {
305
+ participants: (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').map(({ attrs }) => {
306
306
  return {
307
307
  id: attrs.jid,
308
308
  jid: attrs.phone_number || attrs.jid,
@@ -8,4 +8,3 @@ const makeWASocket = (config) => ((0, registration_1.makeRegistrationSocket)({
8
8
  ...config
9
9
  }));
10
10
  exports.default = makeWASocket;
11
- exports.makeWASocket = makeWASocket;
@@ -6,9 +6,10 @@ import { BinaryNode, JidWithDevice } from '../WABinary';
6
6
  export declare const makeMessagesSocket: (config: SocketConfig) => {
7
7
  getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
8
8
  assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
9
- relayMessage: (jid: string, message: proto.IMessage, { messageId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, useCachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<proto.WebMessageInfo>;
9
+ relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
10
10
  sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => Promise<void>;
11
11
  sendReceipts: (keys: WAMessageKey[], type: MessageReceiptType) => Promise<void>;
12
+ getButtonArgs: (message: proto.IMessage) => BinaryNode['attrs'];
12
13
  readMessages: (keys: WAMessageKey[]) => Promise<void>;
13
14
  refreshMediaConn: (forceGet?: boolean) => Promise<MediaConnInfo>;
14
15
  getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<JidWithDevice[]>;
@@ -21,7 +22,6 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
21
22
  [_: string]: string;
22
23
  }>;
23
24
  sendPeerDataOperationMessage: (pdoMessage: proto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
24
- rahmi: any;
25
25
  updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
26
26
  sendMessage: (jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo | undefined>;
27
27
  subscribeNewsletterUpdates: (jid: string) => Promise<{