@d0v3riz/baileys 6.7.7 → 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.
Files changed (72) hide show
  1. package/README.md +0 -10
  2. package/lib/Defaults/index.d.ts +1 -231
  3. package/lib/Defaults/index.js +1 -17
  4. package/lib/Socket/Client/index.d.ts +2 -3
  5. package/lib/Socket/Client/index.js +2 -3
  6. package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +1 -1
  7. package/lib/Socket/Client/{web-socket-client.js → websocket.js} +2 -2
  8. package/lib/Socket/business.d.ts +3 -1
  9. package/lib/Socket/chats.d.ts +4 -1
  10. package/lib/Socket/chats.js +39 -11
  11. package/lib/Socket/groups.d.ts +3 -1
  12. package/lib/Socket/index.d.ts +12 -12
  13. package/lib/Socket/index.js +2 -2
  14. package/lib/Socket/messages-recv.d.ts +4 -2
  15. package/lib/Socket/messages-recv.js +126 -117
  16. package/lib/Socket/messages-send.d.ts +3 -1
  17. package/lib/Socket/messages-send.js +23 -8
  18. package/lib/Socket/socket.d.ts +3 -1
  19. package/lib/Socket/socket.js +9 -14
  20. package/lib/Store/make-cache-manager-store.d.ts +2 -1
  21. package/lib/Store/make-in-memory-store.js +8 -10
  22. package/lib/Store/make-ordered-dictionary.js +2 -2
  23. package/lib/Types/Auth.d.ts +1 -6
  24. package/lib/Types/Call.d.ts +1 -1
  25. package/lib/Types/Chat.d.ts +10 -7
  26. package/lib/Types/Contact.d.ts +1 -1
  27. package/lib/Types/Events.d.ts +4 -0
  28. package/lib/Types/Label.d.ts +11 -0
  29. package/lib/Types/Message.d.ts +5 -2
  30. package/lib/Types/Socket.d.ts +3 -3
  31. package/lib/Utils/auth-utils.js +1 -7
  32. package/lib/Utils/chat-utils.d.ts +5 -4
  33. package/lib/Utils/chat-utils.js +41 -20
  34. package/lib/Utils/crypto.d.ts +1 -0
  35. package/lib/Utils/decode-wa-message.js +1 -0
  36. package/lib/Utils/event-buffer.js +14 -8
  37. package/lib/Utils/generics.d.ts +10 -5
  38. package/lib/Utils/generics.js +35 -7
  39. package/lib/Utils/history.d.ts +2 -2
  40. package/lib/Utils/history.js +1 -1
  41. package/lib/Utils/link-preview.js +24 -1
  42. package/lib/Utils/make-mutex.js +1 -0
  43. package/lib/Utils/messages-media.d.ts +2 -1
  44. package/lib/Utils/messages-media.js +8 -15
  45. package/lib/Utils/messages.d.ts +1 -0
  46. package/lib/Utils/messages.js +7 -11
  47. package/lib/Utils/noise-handler.d.ts +2 -2
  48. package/lib/Utils/noise-handler.js +5 -10
  49. package/lib/Utils/process-message.js +3 -1
  50. package/lib/Utils/signal.js +2 -0
  51. package/lib/Utils/use-multi-file-auth-state.js +1 -0
  52. package/lib/Utils/validate-connection.d.ts +0 -1
  53. package/lib/Utils/validate-connection.js +10 -44
  54. package/lib/WABinary/constants.js +5 -5
  55. package/lib/WABinary/decode.d.ts +1 -0
  56. package/lib/WABinary/encode.d.ts +1 -0
  57. package/lib/WABinary/encode.js +7 -5
  58. package/lib/WABinary/generic-utils.d.ts +1 -0
  59. package/lib/WABinary/jid-utils.d.ts +2 -2
  60. package/lib/WABinary/jid-utils.js +1 -1
  61. package/lib/WAM/BinaryInfo.d.ts +3 -2
  62. package/lib/WAM/constants.d.ts +3 -2
  63. package/lib/WAM/encode.d.ts +1 -0
  64. package/lib/WAM/encode.js +2 -2
  65. package/package.json +5 -6
  66. package/lib/Defaults/phonenumber-mcc.json +0 -223
  67. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
  68. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  69. package/lib/Socket/registration.d.ts +0 -241
  70. package/lib/Socket/registration.js +0 -166
  71. /package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +0 -0
  72. /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
@@ -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, mobile, logger, routingInfo }: {
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, mobile, logger, routingInfo }) => {
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
- if (mobile) {
87
- WAProto_1.proto.CertChain.NoiseCertificate.decode(certDecoded);
88
- }
89
- else {
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
@@ -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 = exports.generateMobileNode = void 0;
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
- mcc: ((_a = config.auth.creds.registration) === null || _a === void 0 ? void 0 : _a.phoneNumberMobileCountryCode) || '000',
29
- mnc: ((_b = config.auth.creds.registration) === null || _b === void 0 ? void 0 : _b.phoneNumberMobileNetworkCode) || '000',
30
- osVersion: osVersion,
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
- if (!config.mobile) {
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 (let i = 0; i < exports.SINGLE_BYTE_TOKENS.length; i++) {
34
- exports.TOKEN_MAP[exports.SINGLE_BYTE_TOKENS[i]] = { index: i };
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 (let i = 0; i < exports.DOUBLE_BYTE_TOKENS.length; i++) {
37
- for (let j = 0; j < exports.DOUBLE_BYTE_TOKENS[i].length; j++) {
38
- exports.TOKEN_MAP[exports.DOUBLE_BYTE_TOKENS[i][j]] = { dict: i, index: j };
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
  }
@@ -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?: {
@@ -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;
@@ -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) => (bytes.forEach(b => buffer.push(b)));
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 (let i = 0; i < str.length; i++) {
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 (let i = 0; i < str.length; i++) {
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;
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { proto } from '../../WAProto';
3
4
  import { BinaryNode } from './types';
4
5
  export declare const getBinaryNodeChildren: (node: BinaryNode | undefined, childTag: string) => BinaryNode[];
@@ -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 | string;
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;
@@ -20,7 +20,7 @@ const jidDecode = (jid) => {
20
20
  const [userAgent, device] = userCombined.split(':');
21
21
  const user = userAgent.split('_')[0];
22
22
  return {
23
- server,
23
+ server: server,
24
24
  user,
25
25
  domainType: server === 'lid' ? 1 : 0,
26
26
  device: device ? +device : undefined
@@ -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]: any;
9
+ [x: string]: import("./constants").Value;
9
10
  };
10
11
  globals: {
11
- [x: string]: any;
12
+ [x: string]: import("./constants").Value;
12
13
  };
13
14
  };
14
15
  }[];
@@ -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']]: any;
31
+ [k in keyof EventByName<key>['props']]: Value;
32
32
  };
33
33
  globals: {
34
- [x: string]: any;
34
+ [x: string]: Value;
35
35
  };
36
36
  };
37
37
  } & {};
38
+ export type Value = number | null | string;
38
39
  export {};
@@ -1,3 +1,4 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { BinaryInfo } from './BinaryInfo';
3
4
  export declare const encodeWAM: (binaryInfo: BinaryInfo) => Buffer;
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.forEach((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.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,.jsx,.tsx",
39
- "lint:fix": "eslint src --fix --ext .js,.ts,.jsx,.tsx",
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": "4.0.1",
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",
@@ -1,223 +0,0 @@
1
- {
2
- "93": 412,
3
- "355": 276,
4
- "213": 603,
5
- "1-684": 544,
6
- "376": 213,
7
- "244": 631,
8
- "1-264": 365,
9
- "1-268": 344,
10
- "54": 722,
11
- "374": 283,
12
- "297": 363,
13
- "61": 505,
14
- "43": 232,
15
- "994": 400,
16
- "1-242": 364,
17
- "973": 426,
18
- "880": 470,
19
- "1-246": 342,
20
- "375": 257,
21
- "32": 206,
22
- "501": 702,
23
- "229": 616,
24
- "1-441": 350,
25
- "975": 402,
26
- "591": 736,
27
- "387": 218,
28
- "267": 652,
29
- "55": 724,
30
- "1-284": 348,
31
- "673": 528,
32
- "359": 284,
33
- "226": 613,
34
- "257": 642,
35
- "855": 456,
36
- "237": 624,
37
- "238": 625,
38
- "1-345": 346,
39
- "236": 623,
40
- "235": 622,
41
- "56": 730,
42
- "86": 454,
43
- "57": 732,
44
- "269": 654,
45
- "682": 548,
46
- "506": 712,
47
- "385": 219,
48
- "53": 368,
49
- "357": 280,
50
- "420": 230,
51
- "243": 630,
52
- "45": 238,
53
- "253": 638,
54
- "1-767": 366,
55
- "1-809": 370,
56
- "1-849": 370,
57
- "1-829": 370,
58
- "593": 740,
59
- "20": 602,
60
- "503": 706,
61
- "240": 627,
62
- "291": 657,
63
- "372": 248,
64
- "251": 636,
65
- "500": 750,
66
- "298": 288,
67
- "679": 542,
68
- "358": 244,
69
- "33": 208,
70
- "689": 547,
71
- "241": 628,
72
- "220": 607,
73
- "995": 282,
74
- "49": 262,
75
- "233": 620,
76
- "350": 266,
77
- "30": 202,
78
- "299": 290,
79
- "1-473": 352,
80
- "1-671": 535,
81
- "502": 704,
82
- "224": 537,
83
- "592": 738,
84
- "509": 372,
85
- "504": 708,
86
- "852": 454,
87
- "36": 216,
88
- "354": 274,
89
- "91": 404,
90
- "62": 510,
91
- "98": 432,
92
- "964": 418,
93
- "353": 234,
94
- "972": 425,
95
- "39": 222,
96
- "225": 612,
97
- "1-876": 338,
98
- "81": 440,
99
- "962": 416,
100
- "254": 639,
101
- "686": 545,
102
- "383": 221,
103
- "965": 419,
104
- "371": 247,
105
- "961": 415,
106
- "266": 651,
107
- "231": 618,
108
- "218": 606,
109
- "423": 295,
110
- "370": 246,
111
- "352": 270,
112
- "389": 294,
113
- "261": 646,
114
- "265": 650,
115
- "60": 502,
116
- "960": 472,
117
- "223": 610,
118
- "356": 278,
119
- "692": 551,
120
- "222": 609,
121
- "230": 617,
122
- "52": 334,
123
- "691": 550,
124
- "373": 259,
125
- "377": 212,
126
- "976": 428,
127
- "382": 297,
128
- "1-664": 354,
129
- "212": 604,
130
- "258": 643,
131
- "95": 414,
132
- "264": 649,
133
- "674": 536,
134
- "977": 429,
135
- "31": 204,
136
- "687": 546,
137
- "64": 530,
138
- "505": 710,
139
- "227": 614,
140
- "234": 621,
141
- "683": 555,
142
- "1-670": 534,
143
- "47": 242,
144
- "968": 226,
145
- "92": 410,
146
- "680": 552,
147
- "970": 423,
148
- "507": 714,
149
- "675": 537,
150
- "595": 744,
151
- "51": 716,
152
- "63": 515,
153
- "48": 260,
154
- "351": 268,
155
- "1-787, 1-939": 330,
156
- "974": 427,
157
- "242": 630,
158
- "40": 226,
159
- "7": 250,
160
- "250": 635,
161
- "290": 658,
162
- "1-869": 356,
163
- "1-758": 358,
164
- "508": 308,
165
- "1-784": 360,
166
- "685": 544,
167
- "378": 292,
168
- "239": 626,
169
- "966": 420,
170
- "221": 608,
171
- "381": 220,
172
- "248": 633,
173
- "232": 619,
174
- "65": 525,
175
- "386": 293,
176
- "677": 540,
177
- "27": 655,
178
- "211": 659,
179
- "34": 214,
180
- "94": 413,
181
- "249": 634,
182
- "597": 746,
183
- "268": 653,
184
- "46": 240,
185
- "41": 228,
186
- "963": 417,
187
- "886": 466,
188
- "992": 436,
189
- "255": 640,
190
- "66": 520,
191
- "228": 615,
192
- "690": 554,
193
- "676": 539,
194
- "1-868": 374,
195
- "216": 605,
196
- "90": 286,
197
- "993": 438,
198
- "1-649": 376,
199
- "688": 553,
200
- "1-340": 332,
201
- "256": 641,
202
- "380": 255,
203
- "971": 424,
204
- "44": 234,
205
- "1": 310,
206
- "598": 748,
207
- "998": 434,
208
- "678": 541,
209
- "379": 225,
210
- "58": 734,
211
- "681": 543,
212
- "967": 421,
213
- "260": 645,
214
- "263": 648,
215
- "670": 514,
216
- "245": 632,
217
- "856": 457,
218
- "599": 362,
219
- "850": 467,
220
- "262": 647,
221
- "82": 450,
222
- "84": 452
223
- }
@@ -1,13 +0,0 @@
1
- /// <reference types="node" />
2
- import { Socket } from 'net';
3
- import { AbstractSocketClient } from './abstract-socket-client';
4
- export declare class MobileSocketClient extends AbstractSocketClient {
5
- protected socket: Socket | null;
6
- get isOpen(): boolean;
7
- get isClosed(): boolean;
8
- get isClosing(): boolean;
9
- get isConnecting(): boolean;
10
- connect(): Promise<void>;
11
- close(): Promise<void>;
12
- send(str: string | Uint8Array, cb?: (err?: Error) => void): boolean;
13
- }