@d0v3riz/baileys 6.7.6 → 6.7.8
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/README.md +0 -10
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +1 -231
- package/lib/Defaults/index.js +1 -17
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +2 -3
- package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +1 -1
- package/lib/Socket/Client/{web-socket-client.js → websocket.js} +2 -2
- package/lib/Socket/business.d.ts +10 -1
- package/lib/Socket/chats.d.ts +4 -1
- package/lib/Socket/chats.js +39 -11
- package/lib/Socket/groups.d.ts +3 -1
- package/lib/Socket/index.d.ts +17 -10
- package/lib/Socket/index.js +2 -2
- package/lib/Socket/messages-recv.d.ts +11 -2
- package/lib/Socket/messages-recv.js +127 -118
- package/lib/Socket/messages-send.d.ts +9 -2
- package/lib/Socket/messages-send.js +26 -9
- package/lib/Socket/socket.d.ts +3 -1
- package/lib/Socket/socket.js +9 -14
- package/lib/Store/make-cache-manager-store.d.ts +2 -1
- package/lib/Store/make-in-memory-store.js +8 -10
- package/lib/Store/make-ordered-dictionary.js +2 -2
- package/lib/Types/Auth.d.ts +1 -6
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +10 -7
- package/lib/Types/Contact.d.ts +1 -1
- package/lib/Types/Events.d.ts +4 -0
- package/lib/Types/Label.d.ts +11 -0
- package/lib/Types/Message.d.ts +5 -2
- package/lib/Types/Socket.d.ts +3 -3
- package/lib/Utils/auth-utils.js +1 -7
- package/lib/Utils/chat-utils.d.ts +5 -4
- package/lib/Utils/chat-utils.js +41 -20
- package/lib/Utils/crypto.d.ts +1 -0
- package/lib/Utils/decode-wa-message.js +1 -0
- package/lib/Utils/event-buffer.js +14 -8
- package/lib/Utils/generics.d.ts +10 -5
- package/lib/Utils/generics.js +35 -7
- package/lib/Utils/history.d.ts +2 -2
- package/lib/Utils/history.js +1 -1
- package/lib/Utils/link-preview.js +24 -1
- package/lib/Utils/make-mutex.js +1 -0
- package/lib/Utils/messages-media.d.ts +2 -1
- package/lib/Utils/messages-media.js +8 -15
- package/lib/Utils/messages.d.ts +1 -0
- package/lib/Utils/messages.js +7 -11
- package/lib/Utils/noise-handler.d.ts +2 -2
- package/lib/Utils/noise-handler.js +5 -10
- package/lib/Utils/process-message.js +3 -1
- package/lib/Utils/signal.js +2 -0
- package/lib/Utils/use-multi-file-auth-state.js +1 -0
- package/lib/Utils/validate-connection.d.ts +0 -1
- package/lib/Utils/validate-connection.js +10 -44
- package/lib/WABinary/constants.js +5 -5
- package/lib/WABinary/decode.d.ts +1 -0
- package/lib/WABinary/encode.d.ts +1 -0
- package/lib/WABinary/encode.js +7 -5
- package/lib/WABinary/generic-utils.d.ts +1 -0
- package/lib/WABinary/jid-utils.d.ts +2 -2
- package/lib/WABinary/jid-utils.js +1 -1
- package/lib/WAM/BinaryInfo.d.ts +3 -2
- package/lib/WAM/constants.d.ts +3 -2
- package/lib/WAM/encode.d.ts +1 -0
- package/lib/WAM/encode.js +2 -2
- package/package.json +5 -6
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/registration.d.ts +0 -234
- package/lib/Socket/registration.js +0 -166
- /package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +0 -0
- /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
|
@@ -45,13 +45,11 @@ const getTmpFilesDirectory = () => (0, os_1.tmpdir)();
|
|
|
45
45
|
const getImageProcessingLibrary = async () => {
|
|
46
46
|
const [_jimp, sharp] = await Promise.all([
|
|
47
47
|
(async () => {
|
|
48
|
-
const jimp = await (
|
|
49
|
-
.catch(() => { }));
|
|
48
|
+
const jimp = await (Promise.resolve().then(() => __importStar(require('jimp'))).catch(() => { }));
|
|
50
49
|
return jimp;
|
|
51
50
|
})(),
|
|
52
51
|
(async () => {
|
|
53
|
-
const sharp = await (
|
|
54
|
-
.catch(() => { }));
|
|
52
|
+
const sharp = await (Promise.resolve().then(() => __importStar(require('sharp'))).catch(() => { }));
|
|
55
53
|
return sharp;
|
|
56
54
|
})()
|
|
57
55
|
]);
|
|
@@ -192,7 +190,7 @@ const mediaMessageSHA256B64 = (message) => {
|
|
|
192
190
|
};
|
|
193
191
|
exports.mediaMessageSHA256B64 = mediaMessageSHA256B64;
|
|
194
192
|
async function getAudioDuration(buffer) {
|
|
195
|
-
const musicMetadata = await
|
|
193
|
+
const musicMetadata = await Promise.resolve().then(() => __importStar(require('music-metadata')));
|
|
196
194
|
let metadata;
|
|
197
195
|
if (Buffer.isBuffer(buffer)) {
|
|
198
196
|
metadata = await musicMetadata.parseBuffer(buffer, undefined, { duration: true });
|
|
@@ -217,7 +215,7 @@ exports.getAudioDuration = getAudioDuration;
|
|
|
217
215
|
*/
|
|
218
216
|
async function getAudioWaveform(buffer, logger) {
|
|
219
217
|
try {
|
|
220
|
-
const audioDecode = (buffer) =>
|
|
218
|
+
const audioDecode = (buffer) => Promise.resolve().then(() => __importStar(require('audio-decode'))).then(({ default: audioDecode }) => audioDecode(buffer));
|
|
221
219
|
let audioData;
|
|
222
220
|
if (Buffer.isBuffer(buffer)) {
|
|
223
221
|
audioData = buffer;
|
|
@@ -331,7 +329,7 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
|
|
|
331
329
|
let writeStream;
|
|
332
330
|
let didSaveToTmpPath = false;
|
|
333
331
|
if (type === 'file') {
|
|
334
|
-
bodyPath = media.url;
|
|
332
|
+
bodyPath = media.url.toString();
|
|
335
333
|
}
|
|
336
334
|
else if (saveOriginalFileIfRequired) {
|
|
337
335
|
bodyPath = (0, path_1.join)(getTmpFilesDirectory(), mediaType + (0, generics_1.generateMessageID)());
|
|
@@ -354,10 +352,8 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
|
|
|
354
352
|
});
|
|
355
353
|
}
|
|
356
354
|
sha256Plain = sha256Plain.update(data);
|
|
357
|
-
if (writeStream) {
|
|
358
|
-
|
|
359
|
-
await (0, events_1.once)(writeStream, 'drain');
|
|
360
|
-
}
|
|
355
|
+
if (writeStream && !writeStream.write(data)) {
|
|
356
|
+
await (0, events_1.once)(writeStream, 'drain');
|
|
361
357
|
}
|
|
362
358
|
onChunk(aes.update(data));
|
|
363
359
|
}
|
|
@@ -537,6 +533,7 @@ const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, options },
|
|
|
537
533
|
logger.debug(`uploading to "${hostname}"`);
|
|
538
534
|
const auth = encodeURIComponent(uploadInfo.auth); // the auth token
|
|
539
535
|
const url = `https://${hostname}${Defaults_1.MEDIA_PATH_MAP[mediaType]}/${fileEncSha256B64}?auth=${auth}&token=${fileEncSha256B64}`;
|
|
536
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
540
537
|
let result;
|
|
541
538
|
try {
|
|
542
539
|
const body = await axios_1.default.post(url, stream, {
|
|
@@ -668,7 +665,3 @@ const MEDIA_RETRY_STATUS_MAP = {
|
|
|
668
665
|
[WAProto_1.proto.MediaRetryNotification.ResultType.NOT_FOUND]: 404,
|
|
669
666
|
[WAProto_1.proto.MediaRetryNotification.ResultType.GENERAL_ERROR]: 418,
|
|
670
667
|
};
|
|
671
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
672
|
-
function __importStar(arg0) {
|
|
673
|
-
throw new Error('Function not implemented.');
|
|
674
|
-
}
|
package/lib/Utils/messages.d.ts
CHANGED
package/lib/Utils/messages.js
CHANGED
|
@@ -699,17 +699,13 @@ const downloadMediaMessage = async (message, type, options, ctx) => {
|
|
|
699
699
|
const result = await downloadMsg()
|
|
700
700
|
.catch(async (error) => {
|
|
701
701
|
var _a;
|
|
702
|
-
if (ctx)
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
const result = await downloadMsg();
|
|
710
|
-
return result;
|
|
711
|
-
}
|
|
712
|
-
}
|
|
702
|
+
if (ctx && axios_1.default.isAxiosError(error) && // check if the message requires a reupload
|
|
703
|
+
REUPLOAD_REQUIRED_STATUS.includes((_a = error.response) === null || _a === void 0 ? void 0 : _a.status)) {
|
|
704
|
+
ctx.logger.info({ key: message.key }, 'sending reupload media request...');
|
|
705
|
+
// request reupload
|
|
706
|
+
message = await ctx.reuploadRequest(message);
|
|
707
|
+
const result = await downloadMsg();
|
|
708
|
+
return result;
|
|
713
709
|
}
|
|
714
710
|
throw error;
|
|
715
711
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import { Logger } from 'pino';
|
|
3
4
|
import { proto } from '../../WAProto';
|
|
4
5
|
import { KeyPair } from '../Types';
|
|
5
6
|
import { BinaryNode } from '../WABinary';
|
|
6
|
-
export declare const makeNoiseHandler: ({ keyPair: { private: privateKey, public: publicKey }, NOISE_HEADER,
|
|
7
|
+
export declare const makeNoiseHandler: ({ keyPair: { private: privateKey, public: publicKey }, NOISE_HEADER, logger, routingInfo }: {
|
|
7
8
|
keyPair: KeyPair;
|
|
8
9
|
NOISE_HEADER: Uint8Array;
|
|
9
|
-
mobile: boolean;
|
|
10
10
|
logger: Logger;
|
|
11
11
|
routingInfo?: Buffer | undefined;
|
|
12
12
|
}) => {
|
|
@@ -11,7 +11,7 @@ const generateIV = (counter) => {
|
|
|
11
11
|
new DataView(iv).setUint32(8, counter);
|
|
12
12
|
return new Uint8Array(iv);
|
|
13
13
|
};
|
|
14
|
-
const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey }, NOISE_HEADER,
|
|
14
|
+
const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey }, NOISE_HEADER, logger, routingInfo }) => {
|
|
15
15
|
logger = logger.child({ class: 'ns' });
|
|
16
16
|
const authenticate = (data) => {
|
|
17
17
|
if (!isFinished) {
|
|
@@ -83,15 +83,10 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
|
|
|
83
83
|
const decStaticContent = decrypt(serverHello.static);
|
|
84
84
|
mixIntoKey(crypto_1.Curve.sharedKey(privateKey, decStaticContent));
|
|
85
85
|
const certDecoded = decrypt(serverHello.payload);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const { intermediate: certIntermediate } = WAProto_1.proto.CertChain.decode(certDecoded);
|
|
91
|
-
const { issuerSerial } = WAProto_1.proto.CertChain.NoiseCertificate.Details.decode(certIntermediate.details);
|
|
92
|
-
if (issuerSerial !== Defaults_1.WA_CERT_DETAILS.SERIAL) {
|
|
93
|
-
throw new boom_1.Boom('certification match failed', { statusCode: 400 });
|
|
94
|
-
}
|
|
86
|
+
const { intermediate: certIntermediate } = WAProto_1.proto.CertChain.decode(certDecoded);
|
|
87
|
+
const { issuerSerial } = WAProto_1.proto.CertChain.NoiseCertificate.Details.decode(certIntermediate.details);
|
|
88
|
+
if (issuerSerial !== Defaults_1.WA_CERT_DETAILS.SERIAL) {
|
|
89
|
+
throw new boom_1.Boom('certification match failed', { statusCode: 400 });
|
|
95
90
|
}
|
|
96
91
|
const keyEnc = encrypt(noiseKey.public);
|
|
97
92
|
mixIntoKey(crypto_1.Curve.sharedKey(noiseKey.private, serverHello.ephemeral));
|
|
@@ -150,7 +150,8 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
150
150
|
...data,
|
|
151
151
|
isLatest: histNotification.syncType !== WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND
|
|
152
152
|
? isLatest
|
|
153
|
-
: undefined
|
|
153
|
+
: undefined,
|
|
154
|
+
peerDataRequestSessionId: histNotification.peerDataRequestSessionId
|
|
154
155
|
});
|
|
155
156
|
}
|
|
156
157
|
break;
|
|
@@ -199,6 +200,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
|
|
|
199
200
|
const { peerDataOperationResult } = response;
|
|
200
201
|
for (const result of peerDataOperationResult) {
|
|
201
202
|
const { placeholderMessageResendResponse: retryResponse } = result;
|
|
203
|
+
//eslint-disable-next-line max-depth
|
|
202
204
|
if (retryResponse) {
|
|
203
205
|
const webMessageInfo = WAProto_1.proto.WebMessageInfo.decode(retryResponse.webMessageInfoBytes);
|
|
204
206
|
// wait till another upsert event is available, don't want it to be part of the PDO response message
|
package/lib/Utils/signal.js
CHANGED
|
@@ -106,8 +106,10 @@ const extractDeviceJids = (result, myJid, excludeZeroDevices) => {
|
|
|
106
106
|
const devicesNode = (0, WABinary_1.getBinaryNodeChild)(item, 'devices');
|
|
107
107
|
const deviceListNode = (0, WABinary_1.getBinaryNodeChild)(devicesNode, 'device-list');
|
|
108
108
|
if (Array.isArray(deviceListNode === null || deviceListNode === void 0 ? void 0 : deviceListNode.content)) {
|
|
109
|
+
//eslint-disable-next-line max-depth
|
|
109
110
|
for (const { tag, attrs } of deviceListNode.content) {
|
|
110
111
|
const device = +attrs.id;
|
|
112
|
+
//eslint-disable-next-line max-depth
|
|
111
113
|
if (tag === 'device' && // ensure the "device" tag
|
|
112
114
|
(!excludeZeroDevices || device !== 0) && // if zero devices are not-excluded, or device is non zero
|
|
113
115
|
(myUser !== user || myDevice !== device) && // either different user or if me user, not this device
|
|
@@ -24,6 +24,7 @@ const fileLock = new async_lock_1.default({ maxPending: Infinity });
|
|
|
24
24
|
* Would recommend writing an auth state for use with a proper SQL or No-SQL DB
|
|
25
25
|
* */
|
|
26
26
|
const useMultiFileAuthState = async (folder) => {
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
28
|
const writeData = (data, file) => {
|
|
28
29
|
const filePath = (0, path_1.join)(folder, fixFileName(file));
|
|
29
30
|
return fileLock.acquire(filePath, () => (0, promises_1.writeFile)((0, path_1.join)(filePath), JSON.stringify(data, generics_1.BufferJSON.replacer)));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { proto } from '../../WAProto';
|
|
2
2
|
import type { AuthenticationCreds, SignalCreds, SocketConfig } from '../Types';
|
|
3
3
|
import { BinaryNode } from '../WABinary';
|
|
4
|
-
export declare const generateMobileNode: (config: SocketConfig) => proto.IClientPayload;
|
|
5
4
|
export declare const generateLoginNode: (userJid: string, config: SocketConfig) => proto.IClientPayload;
|
|
6
5
|
export declare const generateRegistrationNode: ({ registrationId, signedPreKey, signedIdentityKey }: SignalCreds, config: SocketConfig) => proto.ClientPayload;
|
|
7
6
|
export declare const configureSuccessfulPairing: (stanza: BinaryNode, { advSecretKey, signedIdentityKey, signalIdentities }: Pick<AuthenticationCreds, 'advSecretKey' | 'signedIdentityKey' | 'signalIdentities'>) => {
|
|
@@ -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");
|
|
@@ -10,30 +10,19 @@ const crypto_2 = require("./crypto");
|
|
|
10
10
|
const generics_1 = require("./generics");
|
|
11
11
|
const signal_1 = require("./signal");
|
|
12
12
|
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
13
|
return {
|
|
21
14
|
appVersion: {
|
|
22
|
-
primary: version[0],
|
|
23
|
-
secondary: version[1],
|
|
24
|
-
tertiary: version[2],
|
|
15
|
+
primary: config.version[0],
|
|
16
|
+
secondary: config.version[1],
|
|
17
|
+
tertiary: config.version[2],
|
|
25
18
|
},
|
|
26
|
-
platform,
|
|
19
|
+
platform: WAProto_1.proto.ClientPayload.UserAgent.Platform.WEB,
|
|
27
20
|
releaseChannel: WAProto_1.proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
manufacturer,
|
|
32
|
-
device,
|
|
33
|
-
osBuildNumber: osVersion,
|
|
21
|
+
osVersion: '0.1',
|
|
22
|
+
device: 'Desktop',
|
|
23
|
+
osBuildNumber: '0.1',
|
|
34
24
|
localeLanguageIso6391: 'en',
|
|
35
|
-
localeCountryIso31661Alpha2: 'US'
|
|
36
|
-
...phoneId
|
|
25
|
+
localeCountryIso31661Alpha2: 'US'
|
|
37
26
|
};
|
|
38
27
|
};
|
|
39
28
|
const PLATFORM_MAP = {
|
|
@@ -53,32 +42,9 @@ const getClientPayload = (config) => {
|
|
|
53
42
|
connectReason: WAProto_1.proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
|
54
43
|
userAgent: getUserAgent(config),
|
|
55
44
|
};
|
|
56
|
-
|
|
57
|
-
payload.webInfo = getWebInfo(config);
|
|
58
|
-
}
|
|
45
|
+
payload.webInfo = getWebInfo(config);
|
|
59
46
|
return payload;
|
|
60
47
|
};
|
|
61
|
-
const generateMobileNode = (config) => {
|
|
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;
|
|
82
48
|
const generateLoginNode = (userJid, config) => {
|
|
83
49
|
const { user, device } = (0, WABinary_1.jidDecode)(userJid);
|
|
84
50
|
const payload = {
|
|
@@ -30,11 +30,11 @@ exports.SINGLE_BYTE_TOKENS = [
|
|
|
30
30
|
'', 'xmlstreamstart', 'xmlstreamend', 's.whatsapp.net', 'type', 'participant', 'from', 'receipt', 'id', 'broadcast', 'status', 'message', 'notification', 'notify', 'to', 'jid', 'user', 'class', 'offline', 'g.us', 'result', 'mediatype', 'enc', 'skmsg', 'off_cnt', 'xmlns', 'presence', 'participants', 'ack', 't', 'iq', 'device_hash', 'read', 'value', 'media', 'picture', 'chatstate', 'unavailable', 'text', 'urn:xmpp:whatsapp:push', 'devices', 'verified_name', 'contact', 'composing', 'edge_routing', 'routing_info', 'item', 'image', 'verified_level', 'get', 'fallback_hostname', '2', 'media_conn', '1', 'v', 'handshake', 'fallback_class', 'count', 'config', 'offline_preview', 'download_buckets', 'w:profile:picture', 'set', 'creation', 'location', 'fallback_ip4', 'msg', 'urn:xmpp:ping', 'fallback_ip6', 'call-creator', 'relaylatency', 'success', 'subscribe', 'video', 'business_hours_config', 'platform', 'hostname', 'version', 'unknown', '0', 'ping', 'hash', 'edit', 'subject', 'max_buckets', 'download', 'delivery', 'props', 'sticker', 'name', 'last', 'contacts', 'business', 'primary', 'preview', 'w:p', 'pkmsg', 'call-id', 'retry', 'prop', 'call', 'auth_ttl', 'available', 'relay_id', 'last_id', 'day_of_week', 'w', 'host', 'seen', 'bits', 'list', 'atn', 'upload', 'is_new', 'w:stats', 'key', 'paused', 'specific_hours', 'multicast', 'stream:error', 'mmg.whatsapp.net', 'code', 'deny', 'played', 'profile', 'fna', 'device-list', 'close_time', 'latency', 'gcm', 'pop', 'audio', '26', 'w:web', 'open_time', 'error', 'auth', 'ip4', 'update', 'profile_options', 'config_value', 'category', 'catalog_not_created', '00', 'config_code', 'mode', 'catalog_status', 'ip6', 'blocklist', 'registration', '7', 'web', 'fail', 'w:m', 'cart_enabled', 'ttl', 'gif', '300', 'device_orientation', 'identity', 'query', '401', 'media-gig2-1.cdn.whatsapp.net', 'in', '3', 'te2', 'add', 'fallback', 'categories', 'ptt', 'encrypt', 'notice', 'thumbnail-document', 'item-not-found', '12', 'thumbnail-image', 'stage', 'thumbnail-link', 'usync', 'out', 'thumbnail-video', '8', '01', 'context', 'sidelist', 'thumbnail-gif', 'terminate', 'not-authorized', 'orientation', 'dhash', 'capability', 'side_list', 'md-app-state', 'description', 'serial', 'readreceipts', 'te', 'business_hours', 'md-msg-hist', 'tag', 'attribute_padding', 'document', 'open_24h', 'delete', 'expiration', 'active', 'prev_v_id', 'true', 'passive', 'index', '4', 'conflict', 'remove', 'w:gp2', 'config_expo_key', 'screen_height', 'replaced', '02', 'screen_width', 'uploadfieldstat', '2:47DEQpj8', 'media-bog1-1.cdn.whatsapp.net', 'encopt', 'url', 'catalog_exists', 'keygen', 'rate', 'offer', 'opus', 'media-mia3-1.cdn.whatsapp.net', 'privacy', 'media-mia3-2.cdn.whatsapp.net', 'signature', 'preaccept', 'token_id', 'media-eze1-1.cdn.whatsapp.net'
|
|
31
31
|
];
|
|
32
32
|
exports.TOKEN_MAP = {};
|
|
33
|
-
for (
|
|
34
|
-
exports.TOKEN_MAP[
|
|
33
|
+
for (const [i, SINGLE_BYTE_TOKEN] of exports.SINGLE_BYTE_TOKENS.entries()) {
|
|
34
|
+
exports.TOKEN_MAP[SINGLE_BYTE_TOKEN] = { index: i };
|
|
35
35
|
}
|
|
36
|
-
for (
|
|
37
|
-
for (
|
|
38
|
-
exports.TOKEN_MAP[
|
|
36
|
+
for (const [i, DOUBLE_BYTE_TOKEN] of exports.DOUBLE_BYTE_TOKENS.entries()) {
|
|
37
|
+
for (const [j, element] of DOUBLE_BYTE_TOKEN.entries()) {
|
|
38
|
+
exports.TOKEN_MAP[element] = { dict: i, index: j };
|
|
39
39
|
}
|
|
40
40
|
}
|
package/lib/WABinary/decode.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import type { BinaryNode, BinaryNodeCodingOptions } from './types';
|
|
3
4
|
export declare const decompressingIfRequired: (buffer: Buffer) => Promise<Buffer>;
|
|
4
5
|
export declare const decodeDecompressedBinaryNode: (buffer: Buffer, opts: Pick<BinaryNodeCodingOptions, 'DOUBLE_BYTE_TOKENS' | 'SINGLE_BYTE_TOKENS' | 'TAGS'>, indexRef?: {
|
package/lib/WABinary/encode.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import type { BinaryNode, BinaryNodeCodingOptions } from './types';
|
|
3
4
|
export declare const encodeBinaryNode: (node: BinaryNode, opts?: Pick<BinaryNodeCodingOptions, 'TAGS' | 'TOKEN_MAP'>, buffer?: number[]) => Buffer;
|
package/lib/WABinary/encode.js
CHANGED
|
@@ -40,7 +40,11 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
|
|
|
40
40
|
buffer.push((value >> (curShift * 8)) & 0xff);
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
const pushBytes = (bytes) =>
|
|
43
|
+
const pushBytes = (bytes) => {
|
|
44
|
+
for (const b of bytes) {
|
|
45
|
+
buffer.push(b);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
44
48
|
const pushInt16 = (value) => {
|
|
45
49
|
pushBytes([(value >> 8) & 0xff, value & 0xff]);
|
|
46
50
|
};
|
|
@@ -142,8 +146,7 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
|
|
|
142
146
|
if (str.length > TAGS.PACKED_MAX) {
|
|
143
147
|
return false;
|
|
144
148
|
}
|
|
145
|
-
for (
|
|
146
|
-
const char = str[i];
|
|
149
|
+
for (const char of str) {
|
|
147
150
|
const isInNibbleRange = char >= '0' && char <= '9';
|
|
148
151
|
if (!isInNibbleRange && char !== '-' && char !== '.') {
|
|
149
152
|
return false;
|
|
@@ -155,8 +158,7 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
|
|
|
155
158
|
if (str.length > TAGS.PACKED_MAX) {
|
|
156
159
|
return false;
|
|
157
160
|
}
|
|
158
|
-
for (
|
|
159
|
-
const char = str[i];
|
|
161
|
+
for (const char of str) {
|
|
160
162
|
const isInNibbleRange = char >= '0' && char <= '9';
|
|
161
163
|
if (!isInNibbleRange && !(char >= 'A' && char <= 'F') && !(char >= 'a' && char <= 'f')) {
|
|
162
164
|
return false;
|
|
@@ -3,13 +3,13 @@ export declare const OFFICIAL_BIZ_JID = "16505361212@c.us";
|
|
|
3
3
|
export declare const SERVER_JID = "server@c.us";
|
|
4
4
|
export declare const PSA_WID = "0@c.us";
|
|
5
5
|
export declare const STORIES_JID = "status@broadcast";
|
|
6
|
-
export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call' | 'lid';
|
|
6
|
+
export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call' | 'lid' | 'newsletter';
|
|
7
7
|
export type JidWithDevice = {
|
|
8
8
|
user: string;
|
|
9
9
|
device?: number;
|
|
10
10
|
};
|
|
11
11
|
export type FullJid = JidWithDevice & {
|
|
12
|
-
server: JidServer
|
|
12
|
+
server: JidServer;
|
|
13
13
|
domainType?: number;
|
|
14
14
|
};
|
|
15
15
|
export declare const jidEncode: (user: string | number | null, server: JidServer, device?: number, agent?: number) => string;
|
package/lib/WAM/BinaryInfo.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
export declare class BinaryInfo {
|
|
3
4
|
protocolVersion: number;
|
|
4
5
|
sequence: number;
|
|
5
6
|
events: {
|
|
6
7
|
[x: string]: {
|
|
7
8
|
props: {
|
|
8
|
-
[x: string]:
|
|
9
|
+
[x: string]: import("./constants").Value;
|
|
9
10
|
};
|
|
10
11
|
globals: {
|
|
11
|
-
[x: string]:
|
|
12
|
+
[x: string]: import("./constants").Value;
|
|
12
13
|
};
|
|
13
14
|
};
|
|
14
15
|
}[];
|
package/lib/WAM/constants.d.ts
CHANGED
|
@@ -28,11 +28,12 @@ type EventByName<T extends Event['name']> = Extract<Event, {
|
|
|
28
28
|
export type EventInputType = {
|
|
29
29
|
[key in Event['name']]: {
|
|
30
30
|
props: {
|
|
31
|
-
[k in keyof EventByName<key>['props']]:
|
|
31
|
+
[k in keyof EventByName<key>['props']]: Value;
|
|
32
32
|
};
|
|
33
33
|
globals: {
|
|
34
|
-
[x: string]:
|
|
34
|
+
[x: string]: Value;
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
37
|
} & {};
|
|
38
|
+
export type Value = number | null | string;
|
|
38
39
|
export {};
|
package/lib/WAM/encode.d.ts
CHANGED
package/lib/WAM/encode.js
CHANGED
|
@@ -13,10 +13,10 @@ const encodeWAM = (binaryInfo) => {
|
|
|
13
13
|
.reduce((a, b) => a + b);
|
|
14
14
|
const buffer = Buffer.alloc(totalSize);
|
|
15
15
|
let offset = 0;
|
|
16
|
-
binaryInfo.buffer
|
|
16
|
+
for (const buffer_ of binaryInfo.buffer) {
|
|
17
17
|
buffer_.copy(buffer, offset);
|
|
18
18
|
offset += buffer_.length;
|
|
19
|
-
}
|
|
19
|
+
}
|
|
20
20
|
return buffer;
|
|
21
21
|
};
|
|
22
22
|
exports.encodeWAM = encodeWAM;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d0v3riz/baileys",
|
|
3
|
-
"version": "6.7.
|
|
3
|
+
"version": "6.7.8",
|
|
4
4
|
"description": "WhatsApp API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"whatsapp",
|
|
@@ -33,10 +33,9 @@
|
|
|
33
33
|
"changelog:preview": "conventional-changelog -p angular -u",
|
|
34
34
|
"changelog:update": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
|
|
35
35
|
"example": "node --inspect -r ts-node/register Example/example.ts",
|
|
36
|
-
"example:mobile": "node --inspect -r ts-node/register Example/example.ts --mobile",
|
|
37
36
|
"gen:protobuf": "sh WAProto/GenerateStatics.sh",
|
|
38
|
-
"lint": "eslint src --ext .js,.ts
|
|
39
|
-
"lint:fix": "
|
|
37
|
+
"lint": "eslint src --ext .js,.ts",
|
|
38
|
+
"lint:fix": "yarn lint --fix",
|
|
40
39
|
"prepack": "tsc",
|
|
41
40
|
"prepare": "tsc",
|
|
42
41
|
"release": "release-it",
|
|
@@ -46,10 +45,11 @@
|
|
|
46
45
|
"@adiwajshing/keyed-db": "^0.2.4",
|
|
47
46
|
"@d0v3riz/ws": "^8.13.0",
|
|
48
47
|
"@hapi/boom": "^9.1.3",
|
|
48
|
+
"@whiskeysockets/eslint-config": "github:whiskeysockets/eslint-config",
|
|
49
49
|
"async-lock": "^1.4.1",
|
|
50
50
|
"audio-decode": "^2.1.3",
|
|
51
51
|
"axios": "^1.6.0",
|
|
52
|
-
"cache-manager": "
|
|
52
|
+
"cache-manager": "^5.7.6",
|
|
53
53
|
"futoin-hkdf": "^1.5.1",
|
|
54
54
|
"libphonenumber-js": "^1.10.20",
|
|
55
55
|
"libsignal": "https://github.com/d0v3riz/libsignal-node.git",
|
|
@@ -62,7 +62,6 @@
|
|
|
62
62
|
"ws": "^8.13.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@adiwajshing/eslint-config": "github:adiwajshing/eslint-config",
|
|
66
65
|
"@types/got": "^9.6.11",
|
|
67
66
|
"@types/jest": "^27.5.1",
|
|
68
67
|
"@types/node": "^16.0.0",
|