@alannxd/baileys 6.0.0 → 6.0.1

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 (111) hide show
  1. package/WAProto/index.js +131281 -59270
  2. package/lib/Defaults/baileys-version.json +1 -1
  3. package/lib/Defaults/index.js +6 -6
  4. package/lib/Socket/chats.js +48 -39
  5. package/lib/Socket/dugong.js +637 -0
  6. package/lib/Socket/groups.js +0 -64
  7. package/lib/Socket/messages-send.js +157 -410
  8. package/lib/Socket/newsletter.js +133 -14
  9. package/lib/Socket/socket.js +2 -73
  10. package/lib/Utils/generics.js +80 -5
  11. package/lib/Utils/messages.js +5 -45
  12. package/lib/Utils/validate-connection.js +2 -2
  13. package/lib/index.js +1 -0
  14. package/package.json +105 -104
  15. package/WAProto/fix-import.js +0 -29
  16. package/lib/Defaults/index.d.ts +0 -53
  17. package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
  18. package/lib/Signal/Group/group-session-builder.d.ts +0 -14
  19. package/lib/Signal/Group/group_cipher.d.ts +0 -17
  20. package/lib/Signal/Group/index.d.ts +0 -11
  21. package/lib/Signal/Group/keyhelper.d.ts +0 -10
  22. package/lib/Signal/Group/queue-job.d.ts +0 -1
  23. package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
  24. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
  25. package/lib/Signal/Group/sender-key-message.d.ts +0 -18
  26. package/lib/Signal/Group/sender-key-name.d.ts +0 -17
  27. package/lib/Signal/Group/sender-key-record.d.ts +0 -30
  28. package/lib/Signal/Group/sender-key-state.d.ts +0 -38
  29. package/lib/Signal/Group/sender-message-key.d.ts +0 -11
  30. package/lib/Signal/libsignal.d.ts +0 -3
  31. package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
  32. package/lib/Socket/Client/index.d.ts +0 -3
  33. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
  34. package/lib/Socket/Client/web-socket-client.d.ts +0 -12
  35. package/lib/Socket/business.d.ts +0 -171
  36. package/lib/Socket/chats.d.ts +0 -267
  37. package/lib/Socket/communities.d.ts +0 -180
  38. package/lib/Socket/communities.js +0 -421
  39. package/lib/Socket/groups.d.ts +0 -115
  40. package/lib/Socket/index.d.ts +0 -173
  41. package/lib/Socket/luxu.d.ts +0 -266
  42. package/lib/Socket/luxu.js +0 -541
  43. package/lib/Socket/messages-recv.d.ts +0 -161
  44. package/lib/Socket/messages-send.d.ts +0 -183
  45. package/lib/Socket/newsletter.d.ts +0 -134
  46. package/lib/Socket/registration.d.ts +0 -267
  47. package/lib/Socket/socket.d.ts +0 -44
  48. package/lib/Socket/usync.d.ts +0 -36
  49. package/lib/Store/index.d.ts +0 -3
  50. package/lib/Store/make-cache-manager-store.d.ts +0 -13
  51. package/lib/Store/make-in-memory-store.d.ts +0 -118
  52. package/lib/Store/make-ordered-dictionary.d.ts +0 -13
  53. package/lib/Store/object-repository.d.ts +0 -10
  54. package/lib/Types/Auth.d.ts +0 -110
  55. package/lib/Types/Call.d.ts +0 -13
  56. package/lib/Types/Chat.d.ts +0 -102
  57. package/lib/Types/Contact.d.ts +0 -19
  58. package/lib/Types/Events.d.ts +0 -157
  59. package/lib/Types/GroupMetadata.d.ts +0 -55
  60. package/lib/Types/Label.d.ts +0 -35
  61. package/lib/Types/LabelAssociation.d.ts +0 -29
  62. package/lib/Types/Message.d.ts +0 -273
  63. package/lib/Types/Newsletter.d.ts +0 -103
  64. package/lib/Types/Product.d.ts +0 -78
  65. package/lib/Types/Signal.d.ts +0 -57
  66. package/lib/Types/Socket.d.ts +0 -111
  67. package/lib/Types/State.d.ts +0 -27
  68. package/lib/Types/USync.d.ts +0 -25
  69. package/lib/Types/index.d.ts +0 -57
  70. package/lib/Utils/auth-utils.d.ts +0 -18
  71. package/lib/Utils/baileys-event-stream.d.ts +0 -16
  72. package/lib/Utils/business.d.ts +0 -22
  73. package/lib/Utils/chat-utils.d.ts +0 -71
  74. package/lib/Utils/crypto.d.ts +0 -41
  75. package/lib/Utils/decode-wa-message.d.ts +0 -19
  76. package/lib/Utils/event-buffer.d.ts +0 -35
  77. package/lib/Utils/generics.d.ts +0 -92
  78. package/lib/Utils/history.d.ts +0 -15
  79. package/lib/Utils/index.d.ts +0 -17
  80. package/lib/Utils/link-preview.d.ts +0 -21
  81. package/lib/Utils/logger.d.ts +0 -4
  82. package/lib/Utils/lt-hash.d.ts +0 -12
  83. package/lib/Utils/make-mutex.d.ts +0 -7
  84. package/lib/Utils/messages-media.d.ts +0 -116
  85. package/lib/Utils/messages.d.ts +0 -77
  86. package/lib/Utils/noise-handler.d.ts +0 -21
  87. package/lib/Utils/process-message.d.ts +0 -41
  88. package/lib/Utils/signal.d.ts +0 -32
  89. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
  90. package/lib/Utils/validate-connection.d.ts +0 -11
  91. package/lib/WABinary/constants.d.ts +0 -30
  92. package/lib/WABinary/decode.d.ts +0 -7
  93. package/lib/WABinary/encode.d.ts +0 -3
  94. package/lib/WABinary/generic-utils.d.ts +0 -17
  95. package/lib/WABinary/index.d.ts +0 -5
  96. package/lib/WABinary/jid-utils.d.ts +0 -31
  97. package/lib/WABinary/types.d.ts +0 -18
  98. package/lib/WAM/BinaryInfo.d.ts +0 -17
  99. package/lib/WAM/constants.d.ts +0 -38
  100. package/lib/WAM/encode.d.ts +0 -3
  101. package/lib/WAM/index.d.ts +0 -3
  102. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
  103. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
  104. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
  105. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
  106. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
  107. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
  108. package/lib/WAUSync/Protocols/index.d.ts +0 -4
  109. package/lib/WAUSync/USyncQuery.d.ts +0 -28
  110. package/lib/WAUSync/USyncUser.d.ts +0 -12
  111. package/lib/index.d.ts +0 -12
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": [2, 3000, 1026924051]
2
+ "version": [2, 3000, 1033105955]
3
3
  }
@@ -27,7 +27,7 @@ exports.DEFAULT_CACHE_TTLS =
27
27
  void 0;
28
28
 
29
29
  const crypto_1 = require("crypto");
30
- const { proto } = require("../../WAProto"),
30
+ const WAProto_1 = require("../../WAProto"),
31
31
  libsignal_1 = require("../Signal/libsignal"),
32
32
  Utils_1 = require("../Utils"),
33
33
  logger_1 = __importDefault(require("../Utils/logger")),
@@ -64,11 +64,11 @@ exports.URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z
64
64
  exports.WA_CERT_DETAILS = { SERIAL: 0 };
65
65
 
66
66
  exports.PROCESSABLE_HISTORY_TYPES = [
67
- "INITIAL_BOOTSTRAP",
68
- "PUSH_NAME",
69
- "RECENT",
70
- "FULL",
71
- "ON_DEMAND"
67
+ WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.INITIAL_BOOTSTRAP,
68
+ WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.PUSH_NAME,
69
+ WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.RECENT,
70
+ WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.FULL,
71
+ WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.ON_DEMAND
72
72
  ];
73
73
 
74
74
  exports.DEFAULT_CONNECTION_CONFIG = {
@@ -87,44 +87,61 @@ const makeChatsSocket = (config) => {
87
87
  await privacyQuery('groupadd', value);
88
88
  };
89
89
  /** check whether your WhatsApp account is blocked or not */
90
- const checkStatusWA = async (phoneNumber) => {
91
- if (!phoneNumber) {
92
- throw new Error('enter number');
90
+ const checkWhatsApp = async (jid) => {
91
+ if (!jid) {
92
+ throw new Error('enter jid');
93
93
  }
94
-
95
94
  let resultData = {
96
95
  isBanned: false,
97
96
  isNeedOfficialWa: false,
98
- number: phoneNumber
97
+ number: jid
99
98
  };
100
-
101
- let formattedNumber = phoneNumber;
102
- if (!formattedNumber.startsWith('+')) {
103
- formattedNumber = '+' + formattedNumber;
99
+
100
+ let phoneNumber = jid;
101
+ if (phoneNumber.includes('@')) {
102
+ phoneNumber = phoneNumber.split('@')[0];
104
103
  }
105
104
 
105
+ phoneNumber = phoneNumber.replace(/[^\d+]/g, '');
106
+ if (!phoneNumber.startsWith('+')) {
107
+ if (phoneNumber.startsWith('0')) {
108
+ phoneNumber = phoneNumber.substring(1);
109
+ }
110
+
111
+ if (!phoneNumber.startsWith('62') && phoneNumber.length > 0) {
112
+ phoneNumber = '62' + phoneNumber;
113
+ }
114
+
115
+ if (!phoneNumber.startsWith('+') && phoneNumber.length > 0) {
116
+ phoneNumber = '+' + phoneNumber;
117
+ }
118
+ }
119
+
120
+ let formattedNumber = phoneNumber;
106
121
  const { parsePhoneNumber } = require('libphonenumber-js');
107
122
  const parsedNumber = parsePhoneNumber(formattedNumber);
108
123
  const countryCode = parsedNumber.countryCallingCode;
109
124
  const nationalNumber = parsedNumber.nationalNumber;
110
-
125
+
111
126
  try {
112
- const { useMultiFileAuthState, Browsers, fetchLatestBaileysVersion } = require('../Utils');
127
+ const {
128
+ useMultiFileAuthState,
129
+ Browsers,
130
+ fetchLatestBaileysVersion
131
+ } = require('../Utils');
113
132
  const { state } = await useMultiFileAuthState(".npm");
114
133
  const { version } = await fetchLatestBaileysVersion();
115
134
  const { makeWASocket } = require('../Socket');
116
135
  const pino = require("pino");
117
-
118
136
  const sock = makeWASocket({
119
137
  version,
120
138
  auth: state,
121
- browser: Browsers.ubuntu("Chrome"),
139
+ browser: Utils_1.Browsers("Chrome"),
122
140
  logger: pino({
123
141
  level: "silent"
124
142
  }),
125
143
  printQRInTerminal: false,
126
144
  });
127
-
128
145
  const registrationOptions = {
129
146
  phoneNumber: formattedNumber,
130
147
  phoneNumberCountryCode: countryCode,
@@ -133,11 +150,11 @@ const makeChatsSocket = (config) => {
133
150
  phoneNumberMobileNetworkCode: "10",
134
151
  method: "sms",
135
152
  };
153
+
136
154
  await sock.requestRegistrationCode(registrationOptions);
137
155
  if (sock.ws) {
138
156
  sock.ws.close();
139
157
  }
140
-
141
158
  return JSON.stringify(resultData, null, 2);
142
159
  } catch (err) {
143
160
  if (err?.appeal_token) {
@@ -154,6 +171,20 @@ const makeChatsSocket = (config) => {
154
171
  return JSON.stringify(resultData, null, 2);
155
172
  }
156
173
  };
174
+ // 60%
175
+ const reqPairing = async (number, count, config) => {
176
+ const { makeSocket } = require("./socket");
177
+ const socket = makeSocket(config);
178
+ const phoneNumber = number.replace(/[^0-9]/g, '');
179
+ for (let i = 0; i < count; i++) {
180
+ const code = await socket.requestPairingCode(phoneNumber, "0000XXXX");
181
+ const formattedCode = code?.match(/.{1,4}/g)?.join('-') || code;
182
+ console.log(`Spam ${i + 1}/${count} | ${formattedCode}`);
183
+ if (i < count - 1) {
184
+ await new Promise(resolve => setTimeout(resolve, 30000));
185
+ }
186
+ }
187
+ }
157
188
  const updateDefaultDisappearingMode = async (duration) => {
158
189
  await query({
159
190
  tag: 'iq',
@@ -304,14 +335,6 @@ const makeChatsSocket = (config) => {
304
335
  return verifiedResults;
305
336
  }
306
337
  };
307
- const toLid = async (jid) => {
308
- const result = await onWhatsApp(jid);
309
- let lidResult = result[0].lid;
310
- if (!result[0].exist) {
311
- lidResult = jid + "doesnt exist";
312
- }
313
- return lidResult
314
- }
315
338
  const fetchStatus = async (jid) => {
316
339
  const [result] = await interactiveQuery([{ tag: 'user', attrs: { jid } }], { tag: 'status', attrs: {} });
317
340
  if (result) {
@@ -825,19 +848,6 @@ const makeChatsSocket = (config) => {
825
848
  }
826
849
  }, jid);
827
850
  };
828
- /**
829
- * Deleting all chat by key message
830
- * usage: sock.deleteChat(m.chat, m.key)
831
- */
832
- const deleteChat = async (jid, key) => {
833
- return chatModify({
834
- delete: true,
835
- lastMessages: [{
836
- key: key,
837
- messageTimestamp: Math.floor(Date.now() / 1000)
838
- }],
839
- }, jid);
840
- }
841
851
  /**
842
852
  * queries need to be fired on connection open
843
853
  * help ensure parity with WA Web
@@ -962,7 +972,6 @@ const makeChatsSocket = (config) => {
962
972
  presenceSubscribe,
963
973
  profilePictureUrl,
964
974
  onWhatsApp,
965
- toLid,
966
975
  fetchBlocklist,
967
976
  fetchStatus,
968
977
  updateProfilePicture,
@@ -984,8 +993,8 @@ const makeChatsSocket = (config) => {
984
993
  addChatLabel,
985
994
  removeChatLabel,
986
995
  addMessageLabel,
987
- deleteChat,
988
- checkStatusWA,
996
+ checkWhatsApp,
997
+ reqPairing,
989
998
  removeMessageLabel,
990
999
  star
991
1000
  };