@jkt48connect-corp/baileys 7.3.1 → 7.3.2

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 (80) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1119 -1407
  3. package/lib/Defaults/baileys-version.json +1 -1
  4. package/lib/Defaults/index.d.ts +7 -9
  5. package/lib/Defaults/index.js +4 -6
  6. package/lib/Socket/Client/index.d.ts +3 -2
  7. package/lib/Socket/Client/index.js +3 -2
  8. package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -1
  9. package/lib/Socket/Client/{websocket.js → web-socket-client.js} +2 -2
  10. package/lib/Socket/business.d.ts +3 -8
  11. package/lib/Socket/chats.d.ts +19 -21
  12. package/lib/Socket/chats.js +48 -51
  13. package/lib/Socket/groups.d.ts +26 -28
  14. package/lib/Socket/groups.js +1 -2
  15. package/lib/Socket/index.d.ts +3 -6
  16. package/lib/Socket/messages-recv.d.ts +3 -8
  17. package/lib/Socket/messages-recv.js +149 -308
  18. package/lib/Socket/messages-send.d.ts +26 -23
  19. package/lib/Socket/messages-send.js +166 -193
  20. package/lib/Socket/newsletter.d.ts +2 -2
  21. package/lib/Socket/newsletter.js +3 -3
  22. package/lib/Socket/registration.d.ts +3 -8
  23. package/lib/Socket/socket.d.ts +6 -8
  24. package/lib/Socket/socket.js +14 -19
  25. package/lib/Store/make-cache-manager-store.d.ts +2 -2
  26. package/lib/Store/make-ordered-dictionary.d.ts +1 -1
  27. package/lib/Types/Call.d.ts +1 -1
  28. package/lib/Types/Chat.d.ts +7 -12
  29. package/lib/Types/Events.d.ts +2 -17
  30. package/lib/Types/GroupMetadata.d.ts +1 -3
  31. package/lib/Types/Label.d.ts +0 -11
  32. package/lib/Types/Message.d.ts +328 -324
  33. package/lib/Types/Socket.d.ts +0 -7
  34. package/lib/Types/index.d.ts +0 -9
  35. package/lib/Utils/chat-utils.d.ts +4 -4
  36. package/lib/Utils/chat-utils.js +20 -41
  37. package/lib/Utils/crypto.d.ts +1 -1
  38. package/lib/Utils/crypto.js +2 -4
  39. package/lib/Utils/decode-wa-message.d.ts +0 -17
  40. package/lib/Utils/decode-wa-message.js +14 -42
  41. package/lib/Utils/generics.d.ts +10 -4
  42. package/lib/Utils/generics.js +14 -30
  43. package/lib/Utils/history.d.ts +2 -6
  44. package/lib/Utils/history.js +0 -3
  45. package/lib/Utils/messages.d.ts +1 -0
  46. package/lib/Utils/messages.js +39 -247
  47. package/lib/Utils/signal.d.ts +1 -2
  48. package/lib/Utils/signal.js +19 -11
  49. package/lib/Utils/use-multi-file-auth-state.js +3 -11
  50. package/lib/Utils/validate-connection.d.ts +2 -2
  51. package/lib/Utils/validate-connection.js +1 -1
  52. package/lib/WABinary/encode.d.ts +1 -1
  53. package/lib/WABinary/encode.js +10 -16
  54. package/lib/index.d.ts +11 -0
  55. package/lib/index.js +0 -1
  56. package/lib/index.ts +13 -0
  57. package/package.json +15 -27
  58. package/lib/Socket/Client/types.d.ts +0 -17
  59. package/lib/Socket/Client/types.js +0 -13
  60. package/lib/Socket/usync.d.ts +0 -37
  61. package/lib/Socket/usync.js +0 -70
  62. package/lib/Types/USync.d.ts +0 -25
  63. package/lib/Types/USync.js +0 -2
  64. package/lib/Utils/messages.js.bak +0 -1249
  65. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
  66. package/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -32
  67. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
  68. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +0 -57
  69. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
  70. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -30
  71. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
  72. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +0 -42
  73. package/lib/WAUSync/Protocols/index.d.ts +0 -4
  74. package/lib/WAUSync/Protocols/index.js +0 -20
  75. package/lib/WAUSync/USyncQuery.d.ts +0 -26
  76. package/lib/WAUSync/USyncQuery.js +0 -79
  77. package/lib/WAUSync/USyncUser.d.ts +0 -10
  78. package/lib/WAUSync/USyncUser.js +0 -22
  79. package/lib/WAUSync/index.d.ts +0 -3
  80. package/lib/WAUSync/index.js +0 -19
@@ -4,7 +4,6 @@ import type { Logger } from 'pino';
4
4
  import type { URL } from 'url';
5
5
  import { proto } from '../../WAProto';
6
6
  import { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth';
7
- import { GroupMetadata } from './GroupMetadata';
8
7
  import { MediaConnInfo } from './Message';
9
8
  import { SignalRepository } from './Signal';
10
9
  export type WAVersion = [number, number, number];
@@ -60,8 +59,6 @@ export type SocketConfig = {
60
59
  transactionOpts: TransactionCapabilityOptions;
61
60
  /** marks the client as online whenever the socket successfully connects */
62
61
  markOnlineOnConnect: boolean;
63
- /** alphanumeric country code (USA -> US) for the number used */
64
- countryCode: string;
65
62
  /** provide a cache to store media, so does not have to be re-uploaded */
66
63
  mediaCache?: CacheStore;
67
64
  /**
@@ -72,8 +69,6 @@ export type SocketConfig = {
72
69
  userDevicesCache?: CacheStore;
73
70
  /** cache to store call offers */
74
71
  callOfferCache?: CacheStore;
75
- /** cache to track placeholder resends */
76
- placeholderResendCache?: CacheStore;
77
72
  /** width for link preview images */
78
73
  linkPreviewImageThumbnailWidth: number;
79
74
  /** Should Baileys ask the phone for full history, will be received async */
@@ -108,8 +103,6 @@ export type SocketConfig = {
108
103
  * (solves the "this message can take a while" issue) can be retried
109
104
  * */
110
105
  getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>;
111
- /** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
112
- cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>;
113
106
  makeSignalRepository: (auth: SignalAuthState) => SignalRepository;
114
107
  /** Socket passthrough */
115
108
  socket?: any;
@@ -15,15 +15,6 @@ import { SocketConfig } from './Socket';
15
15
  export type UserFacingSocketConfig = Partial<SocketConfig> & {
16
16
  auth: AuthenticationState;
17
17
  };
18
- export type BrowsersMap = {
19
- ubuntu(browser: string): [string, string, string];
20
- macOS(browser: string): [string, string, string];
21
- baileys(browser: string): [string, string, string];
22
- windows(browser: string): [string, string, string];
23
- iOS(browser: string): [string, string, string];
24
- linux(browser: string): [string, string, string];
25
- appropriate(browser: string): [string, string, string];
26
- };
27
18
  export declare enum DisconnectReason {
28
19
  connectionClosed = 428,
29
20
  connectionLost = 408,
@@ -28,7 +28,7 @@ export declare const decodeSyncdPatch: (msg: proto.ISyncdPatch, name: WAPatchNam
28
28
  };
29
29
  };
30
30
  }>;
31
- export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosRequestConfig<{}>) => Promise<{
31
+ export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosRequestConfig<any>) => Promise<{
32
32
  critical_block: {
33
33
  patches: proto.ISyncdPatch[];
34
34
  hasMorePatches: boolean;
@@ -55,13 +55,13 @@ export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosReq
55
55
  snapshot?: proto.ISyncdSnapshot;
56
56
  };
57
57
  }>;
58
- export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<{}>) => Promise<any>;
59
- export declare const downloadExternalPatch: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<{}>) => Promise<proto.SyncdMutations>;
58
+ export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<any>) => Promise<any>;
59
+ export declare const downloadExternalPatch: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<any>) => Promise<proto.SyncdMutations>;
60
60
  export declare const decodeSyncdSnapshot: (name: WAPatchName, snapshot: proto.ISyncdSnapshot, getAppStateSyncKey: FetchAppStateSyncKey, minimumVersionNumber: number | undefined, validateMacs?: boolean) => Promise<{
61
61
  state: LTHashState;
62
62
  mutationMap: ChatMutationMap;
63
63
  }>;
64
- export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatch[], initial: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, options: AxiosRequestConfig<{}>, minimumVersionNumber?: number, logger?: Logger, validateMacs?: boolean) => Promise<{
64
+ export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatch[], initial: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, options: AxiosRequestConfig<any>, minimumVersionNumber?: number, logger?: Logger, validateMacs?: boolean) => Promise<{
65
65
  state: LTHashState;
66
66
  mutationMap: ChatMutationMap;
67
67
  }>;
@@ -305,7 +305,8 @@ const decodePatches = async (name, syncds, initial, getAppStateSyncKey, options,
305
305
  indexValueMap: { ...initial.indexValueMap }
306
306
  };
307
307
  const mutationMap = {};
308
- for (const syncd of syncds) {
308
+ for (let i = 0; i < syncds.length; i++) {
309
+ const syncd = syncds[i];
309
310
  const { version, keyId, snapshotMac } = syncd;
310
311
  if (syncd.externalMutations) {
311
312
  logger === null || logger === void 0 ? void 0 : logger.trace({ name, version }, 'downloading external patch');
@@ -417,31 +418,25 @@ const chatModificationToAppPatch = (mod, jid) => {
417
418
  operation: OP.SET
418
419
  };
419
420
  }
420
- else if ('deleteForMe' in mod) {
421
- const { timestamp, key, deleteMedia } = mod.deleteForMe;
422
- patch = {
423
- syncAction: {
424
- deleteMessageForMeAction: {
425
- deleteMedia,
426
- messageTimestamp: timestamp
427
- }
428
- },
429
- index: ['deleteMessageForMe', jid, key.id, key.fromMe ? '1' : '0', '0'],
430
- type: 'regular_high',
431
- apiVersion: 3,
432
- operation: OP.SET
433
- };
434
- }
435
421
  else if ('clear' in mod) {
436
- patch = {
437
- syncAction: {
438
- clearChatAction: {} // add message range later
439
- },
440
- index: ['clearChat', jid, '1' /*the option here is 0 when keep starred messages is enabled*/, '0'],
441
- type: 'regular_high',
442
- apiVersion: 6,
443
- operation: OP.SET
444
- };
422
+ if (mod.clear === 'all') {
423
+ throw new boom_1.Boom('not supported');
424
+ }
425
+ else {
426
+ const key = mod.clear.messages[0];
427
+ patch = {
428
+ syncAction: {
429
+ deleteMessageForMeAction: {
430
+ deleteMedia: false,
431
+ messageTimestamp: key.timestamp
432
+ }
433
+ },
434
+ index: ['deleteMessageForMe', jid, key.id, key.fromMe ? '1' : '0', '0'],
435
+ type: 'regular_high',
436
+ apiVersion: 3,
437
+ operation: OP.SET
438
+ };
439
+ }
445
440
  }
446
441
  else if ('pin' in mod) {
447
442
  patch = {
@@ -496,22 +491,6 @@ const chatModificationToAppPatch = (mod, jid) => {
496
491
  operation: OP.SET,
497
492
  };
498
493
  }
499
- else if ('addLabel' in mod) {
500
- patch = {
501
- syncAction: {
502
- labelEditAction: {
503
- name: mod.addLabel.name,
504
- color: mod.addLabel.color,
505
- predefinedId: mod.addLabel.predefinedId,
506
- deleted: mod.addLabel.deleted
507
- }
508
- },
509
- index: ['label_edit', mod.addLabel.id],
510
- type: 'regular',
511
- apiVersion: 3,
512
- operation: OP.SET,
513
- };
514
- }
515
494
  else if ('addChatLabel' in mod) {
516
495
  patch = {
517
496
  syncAction: {
@@ -37,4 +37,4 @@ export declare function hkdf(buffer: Uint8Array | Buffer, expandedLength: number
37
37
  salt?: Buffer;
38
38
  info?: string;
39
39
  }): any;
40
- export declare function derivePairingCodeKey(pairingCode: string, salt: Buffer): Promise<any>;
40
+ export declare function derivePairingCodeKey(pairingCode: string, salt: Buffer): any;
@@ -53,9 +53,7 @@ exports.derivePairingCodeKey = derivePairingCodeKey;
53
53
  const crypto_1 = require("crypto");
54
54
  const futoin_hkdf_1 = __importDefault(require("futoin-hkdf"));
55
55
  const libsignal = __importStar(require("libsignal"));
56
- const util_1 = require("util");
57
56
  const Defaults_1 = require("../Defaults");
58
- const pbkdf2Promise = (0, util_1.promisify)(crypto_1.pbkdf2);
59
57
  /** prefix version byte to the pub keys, required for some curve crypto functions */
60
58
  const generateSignalPubKey = (pubKey) => (pubKey.length === 33
61
59
  ? pubKey
@@ -158,6 +156,6 @@ function md5(buffer) {
158
156
  function hkdf(buffer, expandedLength, info) {
159
157
  return (0, futoin_hkdf_1.default)(!Buffer.isBuffer(buffer) ? Buffer.from(buffer) : buffer, expandedLength, info);
160
158
  }
161
- async function derivePairingCodeKey(pairingCode, salt) {
162
- return await pbkdf2Promise(pairingCode, salt, 2 << 16, 32, 'sha256');
159
+ function derivePairingCodeKey(pairingCode, salt) {
160
+ return (0, crypto_1.pbkdf2Sync)(pairingCode, salt, 2 << 16, 32, 'sha256');
163
161
  }
@@ -2,23 +2,6 @@ import { Logger } from 'pino';
2
2
  import { proto } from '../../WAProto';
3
3
  import { SignalRepository } from '../Types';
4
4
  import { BinaryNode } from '../WABinary';
5
- export declare const NO_MESSAGE_FOUND_ERROR_TEXT = "Message absent from node";
6
- export declare const MISSING_KEYS_ERROR_TEXT = "Key used already or never filled";
7
- export declare const NACK_REASONS: {
8
- ParsingError: number;
9
- UnrecognizedStanza: number;
10
- UnrecognizedStanzaClass: number;
11
- UnrecognizedStanzaType: number;
12
- InvalidProtobuf: number;
13
- InvalidHostedCompanionStanza: number;
14
- MissingMessageSecret: number;
15
- SignalErrorOldCounter: number;
16
- MessageDeletedOnPeer: number;
17
- UnhandledError: number;
18
- UnsupportedAdminRevoke: number;
19
- UnsupportedLIDGroup: number;
20
- DBOperationFailed: number;
21
- };
22
5
  /**
23
6
  * Decode the received node as a message.
24
7
  * @note this will only parse the message, not decrypt it
@@ -1,28 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decryptMessageNode = exports.NACK_REASONS = exports.MISSING_KEYS_ERROR_TEXT = exports.NO_MESSAGE_FOUND_ERROR_TEXT = void 0;
3
+ exports.decryptMessageNode = void 0;
4
4
  exports.decodeMessageNode = decodeMessageNode;
5
5
  const boom_1 = require("@hapi/boom");
6
6
  const WAProto_1 = require("../../WAProto");
7
7
  const WABinary_1 = require("../WABinary");
8
8
  const generics_1 = require("./generics");
9
- exports.NO_MESSAGE_FOUND_ERROR_TEXT = 'Message absent from node';
10
- exports.MISSING_KEYS_ERROR_TEXT = 'Key used already or never filled';
11
- exports.NACK_REASONS = {
12
- ParsingError: 487,
13
- UnrecognizedStanza: 488,
14
- UnrecognizedStanzaClass: 489,
15
- UnrecognizedStanzaType: 490,
16
- InvalidProtobuf: 491,
17
- InvalidHostedCompanionStanza: 493,
18
- MissingMessageSecret: 495,
19
- SignalErrorOldCounter: 496,
20
- MessageDeletedOnPeer: 499,
21
- UnhandledError: 500,
22
- UnsupportedAdminRevoke: 550,
23
- UnsupportedLIDGroup: 551,
24
- DBOperationFailed: 552
25
- };
9
+ const NO_MESSAGE_FOUND_ERROR_TEXT = 'Message absent from node';
26
10
  /**
27
11
  * Decode the received node as a message.
28
12
  * @note this will only parse the message, not decrypt it
@@ -129,11 +113,8 @@ const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
129
113
  async decrypt() {
130
114
  var _a;
131
115
  let decryptables = 0;
132
- if ((0, WABinary_1.isJidNewsLetter)(fullMessage.key.remoteJid)) {
133
- const node = (0, WABinary_1.getBinaryNodeChild)(stanza, 'plaintext');
134
- const msg = WAProto_1.proto.Message.decode(node === null || node === void 0 ? void 0 : node.content);
116
+ async function processSenderKeyDistribution(msg) {
135
117
  if (msg.senderKeyDistributionMessage) {
136
- //eslint-disable-next-line max-depth
137
118
  try {
138
119
  await repository.processSenderKeyDistributionMessage({
139
120
  authorJid: author,
@@ -141,9 +122,14 @@ const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
141
122
  });
142
123
  }
143
124
  catch (err) {
144
- logger.error({ key: fullMessage.key, err }, 'failed to decrypt message');
125
+ logger.error({ key: fullMessage.key, err }, 'failed to process senderKeyDistribution');
145
126
  }
146
127
  }
128
+ }
129
+ if ((0, WABinary_1.isJidNewsLetter)(fullMessage.key.remoteJid)) {
130
+ const node = (0, WABinary_1.getBinaryNodeChild)(stanza, 'plaintext');
131
+ const msg = WAProto_1.proto.Message.decode(node === null || node === void 0 ? void 0 : node.content);
132
+ await processSenderKeyDistribution(msg);
147
133
  fullMessage.message = msg;
148
134
  decryptables += 1;
149
135
  }
@@ -154,7 +140,7 @@ const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
154
140
  const details = WAProto_1.proto.VerifiedNameCertificate.Details.decode(cert.details);
155
141
  fullMessage.verifiedBizName = details.verifiedName;
156
142
  }
157
- if (tag !== 'enc' && tag !== 'plaintext') {
143
+ if (tag !== 'enc') {
158
144
  continue;
159
145
  }
160
146
  if (!(content instanceof Uint8Array)) {
@@ -163,7 +149,7 @@ const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
163
149
  decryptables += 1;
164
150
  let msgBuffer;
165
151
  try {
166
- const e2eType = tag === 'plaintext' ? 'plaintext' : attrs.type;
152
+ const e2eType = attrs.type;
167
153
  switch (e2eType) {
168
154
  case 'skmsg':
169
155
  msgBuffer = await repository.decryptGroupMessage({
@@ -181,26 +167,12 @@ const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
181
167
  ciphertext: content
182
168
  });
183
169
  break;
184
- case 'plaintext':
185
- msgBuffer = content;
186
- break;
187
170
  default:
188
171
  throw new Error(`Unknown e2e type: ${e2eType}`);
189
172
  }
190
- let msg = WAProto_1.proto.Message.decode(e2eType !== 'plaintext' ? (0, generics_1.unpadRandomMax16)(msgBuffer) : msgBuffer);
173
+ let msg = WAProto_1.proto.Message.decode((0, generics_1.unpadRandomMax16)(msgBuffer));
191
174
  msg = ((_a = msg.deviceSentMessage) === null || _a === void 0 ? void 0 : _a.message) || msg;
192
- if (msg.senderKeyDistributionMessage) {
193
- //eslint-disable-next-line max-depth
194
- try {
195
- await repository.processSenderKeyDistributionMessage({
196
- authorJid: author,
197
- item: msg.senderKeyDistributionMessage
198
- });
199
- }
200
- catch (err) {
201
- logger.error({ key: fullMessage.key, err }, 'failed to decrypt message');
202
- }
203
- }
175
+ await processSenderKeyDistribution(msg);
204
176
  if (fullMessage.message) {
205
177
  Object.assign(fullMessage.message, msg);
206
178
  }
@@ -218,7 +190,7 @@ const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
218
190
  // if nothing was found to decrypt
219
191
  if (!decryptables) {
220
192
  fullMessage.messageStubType = WAProto_1.proto.WebMessageInfo.StubType.CIPHERTEXT;
221
- fullMessage.messageStubParameters = [exports.NO_MESSAGE_FOUND_ERROR_TEXT];
193
+ fullMessage.messageStubParameters = [NO_MESSAGE_FOUND_ERROR_TEXT, JSON.stringify(stanza, generics_1.BufferJSON.replacer)];
222
194
  }
223
195
  }
224
196
  };
@@ -1,10 +1,16 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
2
  import { Logger } from 'pino';
3
3
  import { proto } from '../../WAProto';
4
- import { BaileysEventEmitter, BaileysEventMap, BrowsersMap, ConnectionState, WACallUpdateType, WAVersion } from '../Types';
4
+ import { BaileysEventEmitter, BaileysEventMap, WACallUpdateType, WAVersion } from '../Types';
5
5
  import { BinaryNode } from '../WABinary';
6
- export declare const Browsers: BrowsersMap;
7
- export declare const getPlatformId: (browser: string) => any;
6
+ export declare const Browsers: {
7
+ ubuntu: (browser: any) => [string, string, string];
8
+ macOS: (browser: any) => [string, string, string];
9
+ baileys: (browser: any) => [string, string, string];
10
+ windows: (browser: any) => [string, string, string];
11
+ /** The appropriate browser based on your OS & release */
12
+ appropriate: (browser: any) => [string, string, string];
13
+ };
8
14
  export declare const BufferJSON: {
9
15
  replacer: (k: any, value: any) => any;
10
16
  reviver: (_: any, value: any) => any;
@@ -34,7 +40,7 @@ export declare function promiseTimeout<T>(ms: number | undefined, promise: (reso
34
40
  export declare const generateMessageIDV2: (userId?: string) => string;
35
41
  export declare const generateMessageID: () => string;
36
42
  export declare function bindWaitForEvent<T extends keyof BaileysEventMap>(ev: BaileysEventEmitter, event: T): (check: (u: BaileysEventMap[T]) => boolean | undefined, timeoutMs?: number) => Promise<void>;
37
- export declare const bindWaitForConnectionUpdate: (ev: BaileysEventEmitter) => (check: (u: Partial<ConnectionState>) => boolean | undefined, timeoutMs?: number) => Promise<void>;
43
+ export declare const bindWaitForConnectionUpdate: (ev: BaileysEventEmitter) => (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number) => Promise<void>;
38
44
  export declare const printQRIfNecessaryListener: (ev: BaileysEventEmitter, logger: Logger) => void;
39
45
  /**
40
46
  * utility that fetches latest baileys version from the master branch.
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isWABusinessPlatform = exports.getCodeFromWSError = exports.getCallStatusFromNode = exports.getErrorCodeFromStreamError = exports.getStatusFromReceiptType = exports.generateMdTagPrefix = exports.fetchLatestWaWebVersion = exports.fetchLatestBaileysVersion = exports.printQRIfNecessaryListener = exports.bindWaitForConnectionUpdate = exports.generateMessageID = exports.generateMessageIDV2 = exports.delayCancellable = exports.delay = exports.debouncedTimeout = exports.unixTimestampSeconds = exports.toNumber = exports.encodeBigEndian = exports.generateRegistrationId = exports.encodeWAMessage = exports.unpadRandomMax16 = exports.writeRandomPadMax16 = exports.getKeyAuthor = exports.BufferJSON = exports.getPlatformId = exports.Browsers = void 0;
6
+ exports.isWABusinessPlatform = exports.getCodeFromWSError = exports.getCallStatusFromNode = exports.getErrorCodeFromStreamError = exports.getStatusFromReceiptType = exports.generateMdTagPrefix = exports.fetchLatestWaWebVersion = exports.fetchLatestBaileysVersion = exports.printQRIfNecessaryListener = exports.bindWaitForConnectionUpdate = exports.generateMessageID = exports.generateMessageIDV2 = exports.delayCancellable = exports.delay = exports.debouncedTimeout = exports.unixTimestampSeconds = exports.toNumber = exports.encodeBigEndian = exports.generateRegistrationId = exports.encodeWAMessage = exports.unpadRandomMax16 = exports.writeRandomPadMax16 = exports.getKeyAuthor = exports.BufferJSON = exports.Browsers = void 0;
7
7
  exports.promiseTimeout = promiseTimeout;
8
8
  exports.bindWaitForEvent = bindWaitForEvent;
9
9
  exports.trimUndefined = trimUndefined;
@@ -16,37 +16,20 @@ const WAProto_1 = require("../../WAProto");
16
16
  const baileys_version_json_1 = require("../Defaults/baileys-version.json");
17
17
  const Types_1 = require("../Types");
18
18
  const WABinary_1 = require("../WABinary");
19
- const COMPANION_PLATFORM_MAP = {
20
- 'Chrome': '49',
21
- 'Edge': '50',
22
- 'Firefox': '51',
23
- 'Opera': '53',
24
- 'Safari': '54'
25
- };
26
19
  const PLATFORM_MAP = {
27
20
  'aix': 'AIX',
28
21
  'darwin': 'Mac OS',
29
22
  'win32': 'Windows',
30
- 'android': 'Android',
31
- 'freebsd': 'FreeBSD',
32
- 'openbsd': 'OpenBSD',
33
- 'sunos': 'Solaris'
23
+ 'android': 'Android'
34
24
  };
35
25
  exports.Browsers = {
36
- ubuntu: (browser) => ['Ubuntu', browser, '22.04.4'],
37
- macOS: (browser) => ['Mac OS', browser, '14.4.1'],
38
- baileys: (browser) => ['Baileys', browser, '6.5.0'],
39
- windows: (browser) => ['Windows', browser, '10.0.22631'],
40
- iOS: (browser) => ['iOS', browser, '18.2'],
41
- linux: (browser) => ['Linux', browser, '6.12.6'],
26
+ ubuntu: browser => ['Ubuntu', browser, '20.0.04'],
27
+ macOS: browser => ['Mac OS', browser, '10.15.7'],
28
+ baileys: browser => ['Baileys', browser, '4.0.0'],
29
+ windows: browser => ['Windows', browser, '10.0.22621'],
42
30
  /** The appropriate browser based on your OS & release */
43
- appropriate: (browser) => [PLATFORM_MAP[(0, os_1.platform)()] || 'Ubuntu', browser, (0, os_1.release)()]
44
- };
45
- const getPlatformId = (browser) => {
46
- const platformType = WAProto_1.proto.DeviceProps.PlatformType[browser.toUpperCase()];
47
- return platformType ? platformType.toString().charCodeAt(0).toString() : '49'; //chrome
31
+ appropriate: browser => [PLATFORM_MAP[(0, os_1.platform)()] || 'Ubuntu', browser, (0, os_1.release)()]
48
32
  };
49
- exports.getPlatformId = getPlatformId;
50
33
  exports.BufferJSON = {
51
34
  replacer: (k, value) => {
52
35
  if (Buffer.isBuffer(value) || value instanceof Uint8Array || (value === null || value === void 0 ? void 0 : value.type) === 'Buffer') {
@@ -167,6 +150,7 @@ async function promiseTimeout(ms, promise) {
167
150
  .finally(cancel);
168
151
  return p;
169
152
  }
153
+ // ngapain? nyolong kah? wkwkwk minimal punya skill sendiri, gak modal nyolong!!
170
154
  const generateMessageIDV2 = (userId) => {
171
155
  const data = Buffer.alloc(8 + 20 + 16);
172
156
  data.writeBigUInt64BE(BigInt(Math.floor(Date.now() / 1000)));
@@ -177,14 +161,15 @@ const generateMessageIDV2 = (userId) => {
177
161
  data.write('@c.us', 8 + id.user.length);
178
162
  }
179
163
  }
180
- const random = (0, crypto_1.randomBytes)(16);
164
+ const random = (0, crypto_1.randomBytes)(20);
181
165
  random.copy(data, 28);
182
166
  const hash = (0, crypto_1.createHash)('sha256').update(data).digest();
183
- return 'FTG-' + hash.toString('hex').toUpperCase().substring(0, 18);
167
+ return hash.toString('hex').toUpperCase().substring(0, 18);
184
168
  };
185
169
  exports.generateMessageIDV2 = generateMessageIDV2;
186
- // generate a random ID to attach to a message
187
- const generateMessageID = () => 'FTG-' + (0, crypto_1.randomBytes)(6).toString('hex').toUpperCase();
170
+ const generateMessageID = () => {
171
+ return (0, crypto_1.randomBytes)(9).toString('hex').toUpperCase();
172
+ };
188
173
  exports.generateMessageID = generateMessageID;
189
174
  function bindWaitForEvent(ev, event) {
190
175
  return async (check, timeoutMs) => {
@@ -331,8 +316,7 @@ const getCallStatusFromNode = ({ tag, attrs }) => {
331
316
  status = 'timeout';
332
317
  }
333
318
  else {
334
- //fired when accepted/rejected/timeout/caller hangs up
335
- status = 'terminate';
319
+ status = 'reject';
336
320
  }
337
321
  break;
338
322
  case 'reject':
@@ -1,19 +1,15 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
2
  import { proto } from '../../WAProto';
3
3
  import { Chat, Contact } from '../Types';
4
- export declare const downloadHistory: (msg: proto.Message.IHistorySyncNotification, options: AxiosRequestConfig<{}>) => Promise<proto.HistorySync>;
4
+ export declare const downloadHistory: (msg: proto.Message.IHistorySyncNotification, options: AxiosRequestConfig<any>) => Promise<proto.HistorySync>;
5
5
  export declare const processHistoryMessage: (item: proto.IHistorySync) => {
6
6
  chats: Chat[];
7
7
  contacts: Contact[];
8
8
  messages: proto.IWebMessageInfo[];
9
- syncType: proto.HistorySync.HistorySyncType;
10
- progress: number | null | undefined;
11
9
  };
12
- export declare const downloadAndProcessHistorySyncNotification: (msg: proto.Message.IHistorySyncNotification, options: AxiosRequestConfig<{}>) => Promise<{
10
+ export declare const downloadAndProcessHistorySyncNotification: (msg: proto.Message.IHistorySyncNotification, options: AxiosRequestConfig<any>) => Promise<{
13
11
  chats: Chat[];
14
12
  contacts: Contact[];
15
13
  messages: proto.IWebMessageInfo[];
16
- syncType: proto.HistorySync.HistorySyncType;
17
- progress: number | null | undefined;
18
14
  }>;
19
15
  export declare const getHistoryMsg: (message: proto.IMessage) => proto.Message.IHistorySyncNotification | null | undefined;
@@ -32,7 +32,6 @@ const processHistoryMessage = (item) => {
32
32
  case WAProto_1.proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP:
33
33
  case WAProto_1.proto.HistorySync.HistorySyncType.RECENT:
34
34
  case WAProto_1.proto.HistorySync.HistorySyncType.FULL:
35
- case WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND:
36
35
  for (const chat of item.conversations) {
37
36
  contacts.push({ id: chat.id, name: chat.name || undefined });
38
37
  const msgs = chat.messages || [];
@@ -75,8 +74,6 @@ const processHistoryMessage = (item) => {
75
74
  chats,
76
75
  contacts,
77
76
  messages,
78
- syncType: item.syncType,
79
- progress: item.progress
80
77
  };
81
78
  };
82
79
  exports.processHistoryMessage = processHistoryMessage;
@@ -1,5 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
+ /// <reference types="node" />
3
4
  import { Logger } from 'pino';
4
5
  import { type Transform } from 'stream';
5
6
  import { proto } from '../../WAProto';