@genuxofficial/baileys 2.0.0 → 4.0.0

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 (108) hide show
  1. package/WAProto/WAProto.proto +4451 -0
  2. package/WAProto/index.d.ts +219 -2233
  3. package/WAProto/index.js +525 -6773
  4. package/WAProto/shizo.x +1 -0
  5. package/engine-requirements.js +1 -1
  6. package/lib/Defaults/baileys-version.json +1 -1
  7. package/lib/Defaults/index.d.ts +236 -3
  8. package/lib/Defaults/index.js +24 -8
  9. package/lib/Defaults/phonenumber-mcc.json +223 -0
  10. package/lib/Signal/libsignal.js +9 -18
  11. package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +2 -0
  12. package/lib/Socket/Client/index.d.ts +3 -2
  13. package/lib/Socket/Client/index.js +3 -2
  14. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  15. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  16. package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -1
  17. package/lib/Socket/Client/{websocket.js → web-socket-client.js} +3 -3
  18. package/lib/Socket/business.d.ts +43 -43
  19. package/lib/Socket/chats.d.ts +17 -23
  20. package/lib/Socket/chats.js +9 -123
  21. package/lib/Socket/groups.d.ts +27 -32
  22. package/lib/Socket/groups.js +5 -18
  23. package/lib/Socket/index.d.ts +51 -49
  24. package/lib/Socket/index.js +2 -2
  25. package/lib/Socket/messages-recv.d.ts +41 -42
  26. package/lib/Socket/messages-recv.js +20 -39
  27. package/lib/Socket/messages-send.d.ts +33 -38
  28. package/lib/Socket/messages-send.js +16 -37
  29. package/lib/Socket/newsletter.d.ts +30 -35
  30. package/lib/Socket/newsletter.js +22 -26
  31. package/lib/Socket/registration.d.ts +271 -0
  32. package/lib/Socket/registration.js +166 -0
  33. package/lib/Socket/socket.d.ts +10 -9
  34. package/lib/Socket/socket.js +19 -16
  35. package/lib/Socket/usync.d.ts +12 -10
  36. package/lib/Socket/usync.js +15 -10
  37. package/lib/Store/index.d.ts +2 -1
  38. package/lib/Store/index.js +3 -1
  39. package/lib/Store/make-in-memory-store.d.ts +1 -1
  40. package/lib/Store/make-in-memory-store.js +10 -8
  41. package/lib/Store/make-ordered-dictionary.d.ts +1 -1
  42. package/lib/Store/make-ordered-dictionary.js +2 -2
  43. package/lib/Types/Auth.d.ts +8 -0
  44. package/lib/Types/Chat.d.ts +2 -12
  45. package/lib/Types/Contact.d.ts +1 -6
  46. package/lib/Types/GroupMetadata.d.ts +0 -7
  47. package/lib/Types/Label.d.ts +0 -11
  48. package/lib/Types/Label.js +1 -1
  49. package/lib/Types/LabelAssociation.js +1 -1
  50. package/lib/Types/Message.d.ts +8 -7
  51. package/lib/Types/Message.js +2 -0
  52. package/lib/Types/Newsletter.js +2 -2
  53. package/lib/Types/Socket.d.ts +6 -7
  54. package/lib/Types/index.js +1 -1
  55. package/lib/Utils/auth-utils.d.ts +1 -1
  56. package/lib/Utils/auth-utils.js +12 -5
  57. package/lib/Utils/business.js +2 -2
  58. package/lib/Utils/chat-utils.d.ts +13 -11
  59. package/lib/Utils/chat-utils.js +2 -28
  60. package/lib/Utils/crypto.d.ts +16 -14
  61. package/lib/Utils/crypto.js +22 -34
  62. package/lib/Utils/decode-wa-message.d.ts +2 -4
  63. package/lib/Utils/decode-wa-message.js +24 -160
  64. package/lib/Utils/event-buffer.js +6 -4
  65. package/lib/Utils/generics.d.ts +12 -40
  66. package/lib/Utils/generics.js +25 -103
  67. package/lib/Utils/link-preview.js +1 -34
  68. package/lib/Utils/lt-hash.d.ts +3 -3
  69. package/lib/Utils/lt-hash.js +45 -11
  70. package/lib/Utils/make-mutex.d.ts +2 -2
  71. package/lib/Utils/messages-media.d.ts +16 -26
  72. package/lib/Utils/messages-media.js +26 -102
  73. package/lib/Utils/messages.d.ts +8 -5
  74. package/lib/Utils/messages.js +15 -17
  75. package/lib/Utils/noise-handler.d.ts +8 -5
  76. package/lib/Utils/noise-handler.js +10 -5
  77. package/lib/Utils/process-message.js +2 -2
  78. package/lib/Utils/use-multi-file-auth-state.js +11 -48
  79. package/lib/Utils/validate-connection.d.ts +3 -2
  80. package/lib/Utils/validate-connection.js +44 -10
  81. package/lib/WABinary/constants.js +5 -5
  82. package/lib/WABinary/decode.d.ts +4 -2
  83. package/lib/WABinary/decode.js +7 -17
  84. package/lib/WABinary/encode.d.ts +3 -1
  85. package/lib/WABinary/encode.js +17 -40
  86. package/lib/WABinary/generic-utils.d.ts +3 -1
  87. package/lib/WABinary/generic-utils.js +2 -2
  88. package/lib/WABinary/jid-utils.d.ts +3 -8
  89. package/lib/WABinary/jid-utils.js +2 -23
  90. package/lib/WAM/BinaryInfo.d.ts +12 -2
  91. package/lib/WAM/constants.d.ts +2 -3
  92. package/lib/WAM/encode.d.ts +3 -1
  93. package/lib/WAM/encode.js +2 -2
  94. package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
  95. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +2 -2
  96. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -2
  97. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +5 -5
  98. package/lib/WAUSync/USyncQuery.d.ts +0 -2
  99. package/lib/WAUSync/USyncQuery.js +13 -27
  100. package/lib/WAUSync/USyncUser.d.ts +0 -2
  101. package/lib/WAUSync/USyncUser.js +0 -4
  102. package/package.json +60 -55
  103. package/LICENSE +0 -21
  104. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
  105. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -53
  106. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
  107. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +0 -24
  108. /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
@@ -1,3 +1,5 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
1
3
  import Long = require('long');
2
4
  import { Boom } from '@hapi/boom';
3
5
  import { proto } from '../../WAProto';
@@ -13,13 +15,15 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
13
15
  isVideo: boolean;
14
16
  }>;
15
17
  fetchMessageHistory: (count: number, oldestMsgKey: WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
16
- requestPlaceholderResend: (messageKey: WAMessageKey) => Promise<string | undefined>;
17
- getPrivacyTokens: (jids: string[]) => Promise<any>;
18
+ requestPlaceholderResend: (messageKey: WAMessageKey) => Promise<'RESOLVED' | string | undefined>;
19
+ getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
18
20
  assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
19
21
  relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
20
22
  sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => Promise<void>;
21
23
  sendReceipts: (keys: WAMessageKey[], type: MessageReceiptType) => Promise<void>;
22
- getButtonArgs: (message: proto.IMessage) => BinaryNode["attrs"];
24
+ getButtonArgs: (message: proto.IMessage) => {
25
+ [key: string]: string;
26
+ };
23
27
  readMessages: (keys: WAMessageKey[]) => Promise<void>;
24
28
  refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
25
29
  waUploadToServer: import("../Types").WAMediaUploadFunction;
@@ -27,7 +31,9 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
27
31
  [_: string]: string;
28
32
  }>;
29
33
  getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
30
- createParticipantNodes: (jids: string[], message: proto.IMessage, extraAttrs?: BinaryNode["attrs"]) => Promise<{
34
+ createParticipantNodes: (jids: string[], message: proto.IMessage, extraAttrs?: {
35
+ [key: string]: string;
36
+ } | undefined) => Promise<{
31
37
  nodes: BinaryNode[];
32
38
  shouldIncludeDeviceIdentity: boolean;
33
39
  }>;
@@ -38,7 +44,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
38
44
  duration: string;
39
45
  }>;
40
46
  newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
41
- newsletterUpdateDescription: (jid: string, description?: string) => Promise<void>;
47
+ newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
42
48
  newsletterUpdateName: (jid: string, name: string) => Promise<void>;
43
49
  newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
44
50
  newsletterRemovePicture: (jid: string) => Promise<void>;
@@ -46,15 +52,15 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
46
52
  newsletterFollow: (jid: string) => Promise<void>;
47
53
  newsletterUnmute: (jid: string) => Promise<void>;
48
54
  newsletterMute: (jid: string) => Promise<void>;
49
- newsletterCreate: (name: string, description?: string, picture?: import("../Types").WAMediaUpload) => Promise<import("../Types").NewsletterMetadata>;
50
- newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole) => Promise<import("../Types").NewsletterMetadata>;
55
+ newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
56
+ newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
51
57
  newsletterAdminCount: (jid: string) => Promise<number>;
52
58
  newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
53
59
  newsletterDemote: (jid: string, user: string) => Promise<void>;
54
60
  newsletterDelete: (jid: string) => Promise<void>;
55
- newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
56
- newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
57
- newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
61
+ newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>;
62
+ newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
63
+ newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
58
64
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
59
65
  groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
60
66
  groupLeave: (id: string) => Promise<void>;
@@ -62,7 +68,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
62
68
  groupRequestParticipantsList: (jid: string) => Promise<{
63
69
  [key: string]: string;
64
70
  }[]>;
65
- groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
71
+ groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
66
72
  status: string;
67
73
  jid: string;
68
74
  }[]>;
@@ -71,40 +77,36 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
71
77
  jid: string;
72
78
  content: BinaryNode;
73
79
  }[]>;
74
- groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
80
+ groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
75
81
  groupInviteCode: (jid: string) => Promise<string | undefined>;
76
82
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
77
83
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
78
84
  groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
79
- groupAcceptInviteV4: (key: string | WAMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<any>;
85
+ groupAcceptInviteV4: (key: string | WAMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
80
86
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
81
87
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
82
- groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
83
- groupMemberAddMode: (jid: string, mode: "admin_add" | "all_member_add") => Promise<void>;
88
+ groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
89
+ groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
84
90
  groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
85
91
  groupFetchAllParticipating: () => Promise<{
86
92
  [_: string]: import("../Types").GroupMetadata;
87
93
  }>;
88
- getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
89
94
  processingMutex: {
90
- mutex<T>(code: () => Promise<T> | T): Promise<T>;
95
+ mutex<T>(code: () => T | Promise<T>): Promise<T>;
91
96
  };
92
97
  upsertMessage: (msg: proto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
93
98
  appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
94
- sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
95
- presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
96
- profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
99
+ sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
100
+ presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
101
+ profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;
97
102
  onWhatsApp: (...jids: string[]) => Promise<{
98
103
  jid: string;
99
104
  exists: unknown;
100
- lid: unknown;
101
105
  }[] | undefined>;
102
106
  fetchBlocklist: () => Promise<string[]>;
103
- fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
104
- fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
107
+ fetchDisappearingDuration: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>;
108
+ fetchStatus: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>;
105
109
  updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
106
- updateProfilePictureFull: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
107
- updateProfilePictureFull2: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
108
110
  removeProfilePicture: (jid: string) => Promise<void>;
109
111
  updateProfileStatus: (status: string) => Promise<void>;
110
112
  updateProfileName: (name: string) => Promise<void>;
@@ -118,29 +120,26 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
118
120
  updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
119
121
  updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
120
122
  updateDefaultDisappearingMode: (duration: number) => Promise<void>;
121
- getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
123
+ getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
122
124
  resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
123
125
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
124
- cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
125
- addOrEditContact: (jid: string, contact: import("../Types").ContactAction) => Promise<void>;
126
- removeContact: (jid: string) => Promise<void>;
127
- addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
126
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
128
127
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
129
128
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
130
129
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
131
130
  removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
132
131
  star: (jid: string, messages: {
133
132
  id: string;
134
- fromMe?: boolean;
133
+ fromMe?: boolean | undefined;
135
134
  }[], star: boolean) => Promise<void>;
136
- executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
135
+ executeUSyncQuery: (usyncQuery: import("../index").USyncQuery) => Promise<import("../index").USyncQueryResult | undefined>;
137
136
  type: "md";
138
- ws: import("./Client").WebSocketClient;
137
+ ws: any;
139
138
  ev: import("../Types").BaileysEventEmitter & {
140
- process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
139
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
141
140
  buffer(): void;
142
- createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
143
- flush(force?: boolean): boolean;
141
+ createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>;
142
+ flush(force?: boolean | undefined): boolean;
144
143
  isBuffering(): boolean;
145
144
  };
146
145
  authState: {
@@ -150,17 +149,17 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
150
149
  signalRepository: import("../Types").SignalRepository;
151
150
  user: import("../Types").Contact | undefined;
152
151
  generateMessageTag: () => string;
153
- query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
154
- waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
152
+ query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
153
+ waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
155
154
  waitForSocketOpen: () => Promise<void>;
156
155
  sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
157
156
  sendNode: (frame: BinaryNode) => Promise<void>;
158
- logout: (msg?: string) => Promise<void>;
157
+ logout: (msg?: string | undefined) => Promise<void>;
159
158
  end: (error: Error | undefined) => void;
160
- onUnexpectedError: (err: Error | Boom, msg: string) => void;
159
+ onUnexpectedError: (err: Error | Boom<any>, msg: string) => void;
161
160
  uploadPreKeys: (count?: number) => Promise<void>;
162
161
  uploadPreKeysToServerIfRequired: () => Promise<void>;
163
162
  requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
164
- waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
165
- sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
163
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number | undefined) => Promise<void>;
164
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
166
165
  };
@@ -22,24 +22,19 @@ const makeMessagesRecvSocket = (config) => {
22
22
  /** this mutex ensures that each retryRequest will wait for the previous one to finish */
23
23
  const retryMutex = (0, make_mutex_1.makeMutex)();
24
24
  const msgRetryCache = config.msgRetryCounterCache || new node_cache_1.default({
25
- stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY, // 1 hour
25
+ stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
26
26
  useClones: false
27
27
  });
28
28
  const callOfferCache = config.callOfferCache || new node_cache_1.default({
29
- stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.CALL_OFFER, // 5 mins
29
+ stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.CALL_OFFER,
30
30
  useClones: false
31
31
  });
32
32
  const placeholderResendCache = config.placeholderResendCache || new node_cache_1.default({
33
- stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY, // 1 hour
33
+ stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
34
34
  useClones: false
35
35
  });
36
36
  let sendActiveReceipts = false;
37
37
  const sendMessageAck = async ({ tag, attrs, content }, errorCode) => {
38
- // If ws not connected - logs it and return
39
- if (!ws.isOpen) {
40
- logger.warn({ attrs: attrs }, 'Client not connected, cannot send ack');
41
- return;
42
- }
43
38
  const stanza = {
44
39
  tag: 'ack',
45
40
  attrs: {
@@ -67,7 +62,6 @@ const makeMessagesRecvSocket = (config) => {
67
62
  await sendNode(stanza);
68
63
  };
69
64
  const offerCall = async (toJid, isVideo = false) => {
70
- const ToJidm = `${toJid}`;
71
65
  const callId = (0, crypto_1.randomBytes)(16).toString('hex').toUpperCase().substring(0, 64);
72
66
  const offerContent = [];
73
67
  offerContent.push({ tag: 'audio', attrs: { enc: 'opus', rate: '16000' }, content: undefined });
@@ -89,9 +83,7 @@ const makeMessagesRecvSocket = (config) => {
89
83
  offerContent.push({ tag: 'capability', attrs: { ver: '1' }, content: new Uint8Array([1, 4, 255, 131, 207, 4]) });
90
84
  offerContent.push({ tag: 'encopt', attrs: { keygen: '2' }, content: undefined });
91
85
  const encKey = (0, crypto_1.randomBytes)(32);
92
- const usrr = toJid.split('@')[0];
93
- const srvr = toJid.split('@')[1];
94
- const devices = (await getUSyncDevices([toJid], true, false)).map(({ user, device }) => toJid);
86
+ const devices = (await getUSyncDevices([toJid], true, false)).map(({ user, device }) => (0, WABinary_1.jidEncode)(user, 's.whatsapp.net', device));
95
87
  await assertSessions(devices, true);
96
88
  const { nodes: destinations, shouldIncludeDeviceIdentity } = await createParticipantNodes(devices, {
97
89
  call: {
@@ -192,7 +184,7 @@ const makeMessagesRecvSocket = (config) => {
192
184
  ]
193
185
  };
194
186
  if (node.attrs.recipient) {
195
- receipt.attrs.recipient = (0, WABinary_1.getBotJid)(node.attrs.recipient);
187
+ receipt.attrs.recipient = node.attrs.recipient;
196
188
  }
197
189
  if (node.attrs.participant) {
198
190
  receipt.attrs.participant = node.attrs.participant;
@@ -346,22 +338,22 @@ const makeMessagesRecvSocket = (config) => {
346
338
  const handleNewsletterNotification = (id, node) => {
347
339
  const messages = (0, WABinary_1.getBinaryNodeChild)(node, 'messages');
348
340
  const message = (0, WABinary_1.getBinaryNodeChild)(messages, 'message');
349
- const serverId = message.attrs.server_id;
341
+ const server_id = message.attrs.server_id;
350
342
  const reactionsList = (0, WABinary_1.getBinaryNodeChild)(message, 'reactions');
351
343
  const viewsList = (0, WABinary_1.getBinaryNodeChildren)(message, 'views_count');
352
344
  if (reactionsList) {
353
345
  const reactions = (0, WABinary_1.getBinaryNodeChildren)(reactionsList, 'reaction');
354
346
  if (reactions.length === 0) {
355
- ev.emit('newsletter.reaction', { id, 'server_id': serverId, reaction: { removed: true } });
347
+ ev.emit('newsletter.reaction', { id, server_id, reaction: { removed: true } });
356
348
  }
357
349
  reactions.forEach(item => {
358
350
  var _a, _b;
359
- ev.emit('newsletter.reaction', { id, 'server_id': serverId, reaction: { code: (_a = item.attrs) === null || _a === void 0 ? void 0 : _a.code, count: +((_b = item.attrs) === null || _b === void 0 ? void 0 : _b.count) } });
351
+ ev.emit('newsletter.reaction', { id, server_id, reaction: { code: (_a = item.attrs) === null || _a === void 0 ? void 0 : _a.code, count: +((_b = item.attrs) === null || _b === void 0 ? void 0 : _b.count) } });
360
352
  });
361
353
  }
362
354
  if (viewsList.length) {
363
355
  viewsList.forEach(item => {
364
- ev.emit('newsletter.view', { id, 'server_id': serverId, count: +item.attrs.count });
356
+ ev.emit('newsletter.view', { id, server_id, count: +item.attrs.count });
365
357
  });
366
358
  }
367
359
  };
@@ -423,9 +415,6 @@ const makeMessagesRecvSocket = (config) => {
423
415
  case 'encrypt':
424
416
  await handleEncryptNotification(node);
425
417
  break;
426
- case 'newsletter':
427
- // TO DO
428
- break;
429
418
  case 'devices':
430
419
  const devices = (0, WABinary_1.getBinaryNodeChildren)(child, 'device');
431
420
  if ((0, WABinary_1.areJidsSameUser)(child.attrs.jid, authState.creds.me.id)) {
@@ -572,7 +561,6 @@ const makeMessagesRecvSocket = (config) => {
572
561
  };
573
562
  const sendMessagesAgain = async (key, ids, retryNode) => {
574
563
  var _a;
575
- // todo: implement a cache to store the last 256 sent messages (copy whatsmeow)
576
564
  const msgs = await Promise.all(ids.map(id => getMessage({ ...key, id })));
577
565
  const remoteJid = key.remoteJid;
578
566
  const participant = key.participant || remoteJid;
@@ -585,7 +573,8 @@ const makeMessagesRecvSocket = (config) => {
585
573
  await authState.keys.set({ 'sender-key-memory': { [remoteJid]: null } });
586
574
  }
587
575
  logger.debug({ participant, sendToAll }, 'forced new session for retry recp');
588
- for (const [i, msg] of msgs.entries()) {
576
+ for (let i = 0; i < msgs.length; i++) {
577
+ const msg = msgs[i];
589
578
  if (msg) {
590
579
  updateSendMessageAgainCount(ids[i], participant);
591
580
  const msgRelayOpts = { messageId: ids[i] };
@@ -611,7 +600,7 @@ const makeMessagesRecvSocket = (config) => {
611
600
  const isLid = attrs.from.includes('lid');
612
601
  const isNodeFromMe = (0, WABinary_1.areJidsSameUser)(attrs.participant || attrs.from, isLid ? (_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.lid : (_b = authState.creds.me) === null || _b === void 0 ? void 0 : _b.id);
613
602
  const remoteJid = !isNodeFromMe || (0, WABinary_1.isJidGroup)(attrs.from) ? attrs.from : attrs.recipient;
614
- const fromMe = !attrs.recipient || ((attrs.type === 'retry' || attrs.type === 'sender') && isNodeFromMe);
603
+ const fromMe = !attrs.recipient || (attrs.type === 'retry' && isNodeFromMe);
615
604
  const key = {
616
605
  remoteJid,
617
606
  id: '',
@@ -731,15 +720,8 @@ const makeMessagesRecvSocket = (config) => {
731
720
  await sendMessageAck(node);
732
721
  return;
733
722
  }
734
- const encNode = (0, WABinary_1.getBinaryNodeChild)(node, 'enc');
735
- // TODO: temporary fix for crashes and issues resulting of failed msmsg decryption
736
- if (encNode && encNode.attrs.type === 'msmsg') {
737
- logger.debug({ key: node.attrs.key }, 'ignored msmsg');
738
- await sendMessageAck(node);
739
- return;
740
- }
741
723
  let response;
742
- if ((0, WABinary_1.getBinaryNodeChild)(node, 'unavailable') && !encNode) {
724
+ if ((0, WABinary_1.getBinaryNodeChild)(node, 'unavailable') && !(0, WABinary_1.getBinaryNodeChild)(node, 'enc')) {
743
725
  await sendMessageAck(node);
744
726
  const { key } = (0, Utils_1.decodeMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '').fullMessage;
745
727
  response = await requestPlaceholderResend(key);
@@ -753,17 +735,19 @@ const makeMessagesRecvSocket = (config) => {
753
735
  placeholderResendCache.del(node.attrs.id);
754
736
  }
755
737
  }
756
- const { fullMessage: msg, category, author, decrypt } = (0, Utils_1.decryptMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, logger, getMessage);
738
+ const { fullMessage: msg, category, author, decrypt } = (0, Utils_1.decryptMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, logger);
757
739
  if (response && ((_a = msg === null || msg === void 0 ? void 0 : msg.messageStubParameters) === null || _a === void 0 ? void 0 : _a[0]) === Utils_1.NO_MESSAGE_FOUND_ERROR_TEXT) {
758
740
  msg.messageStubParameters = [Utils_1.NO_MESSAGE_FOUND_ERROR_TEXT, response];
759
741
  }
760
- if (((_c = (_b = msg.message) === null || _b === void 0 ? void 0 : _b.protocolMessage) === null || _c === void 0 ? void 0 : _c.type) === WAProto_1.proto.Message.ProtocolMessage.Type.SHARE_PHONE_NUMBER && node.attrs.sender_pn) {
761
- ev.emit('chats.phoneNumberShare', { lid: node.attrs.from, jid: node.attrs.sender_pn });
742
+ if (((_c = (_b = msg.message) === null || _b === void 0 ? void 0 : _b.protocolMessage) === null || _c === void 0 ? void 0 : _c.type) === WAProto_1.proto.Message.ProtocolMessage.Type.SHARE_PHONE_NUMBER) {
743
+ if (node.attrs.sender_pn) {
744
+ ev.emit('chats.phoneNumberShare', { lid: node.attrs.from, jid: node.attrs.sender_pn });
745
+ }
762
746
  }
763
747
  try {
764
748
  await Promise.all([
765
749
  processingMutex.mutex(async () => {
766
- var _a, _b, _c;
750
+ var _a;
767
751
  await decrypt();
768
752
  // message failed to decrypt
769
753
  if (msg.messageStubType === WAProto_1.proto.WebMessageInfo.StubType.CIPHERTEXT) {
@@ -811,9 +795,6 @@ const makeMessagesRecvSocket = (config) => {
811
795
  await sendReceipt(jid, undefined, [msg.key.id], 'hist_sync');
812
796
  }
813
797
  }
814
- if (((_b = node.attrs) === null || _b === void 0 ? void 0 : _b.addressing_mode) === 'lid' && ((_c = node.attrs) === null || _c === void 0 ? void 0 : _c.participant_pn)) {
815
- msg.key.participant = (0, WABinary_1.jidNormalizedUser)(node.attrs.participant_pn);
816
- }
817
798
  (0, Utils_1.cleanMessage)(msg, authState.creds.me.id);
818
799
  await sendMessageAck(node);
819
800
  await upsertMessage(msg, node.attrs.offline ? 'append' : 'notify');
@@ -906,7 +887,7 @@ const makeMessagesRecvSocket = (config) => {
906
887
  await sendMessageAck(node);
907
888
  };
908
889
  const handleBadAck = async ({ attrs }) => {
909
- const key = { remoteJid: attrs.from, fromMe: true, id: attrs.id, 'server_id': attrs === null || attrs === void 0 ? void 0 : attrs.server_id };
890
+ const key = { remoteJid: attrs.from, fromMe: true, id: attrs.id, server_id: attrs === null || attrs === void 0 ? void 0 : attrs.server_id };
910
891
  // current hypothesis is that if pash is sent in the ack
911
892
  // it means -- the message hasn't reached all devices yet
912
893
  // we'll retry sending the message here
@@ -1,15 +1,17 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
1
3
  import { Boom } from '@hapi/boom';
2
4
  import { proto } from '../../WAProto';
3
5
  import { AnyMessageContent, MediaConnInfo, MessageReceiptType, MessageRelayOptions, MiscMessageGenerationOptions, SocketConfig, WAMessageKey } from '../Types';
4
6
  import { BinaryNode, JidWithDevice } from '../WABinary';
5
7
  import { USyncQuery } from '../WAUSync';
6
8
  export declare const makeMessagesSocket: (config: SocketConfig) => {
7
- getPrivacyTokens: (jids: string[]) => Promise<any>;
9
+ getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
8
10
  assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
9
11
  relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
10
12
  sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => Promise<void>;
11
13
  sendReceipts: (keys: WAMessageKey[], type: MessageReceiptType) => Promise<void>;
12
- getButtonArgs: (message: proto.IMessage) => BinaryNode["attrs"];
14
+ getButtonArgs: (message: proto.IMessage) => BinaryNode['attrs'];
13
15
  readMessages: (keys: WAMessageKey[]) => Promise<void>;
14
16
  refreshMediaConn: (forceGet?: boolean) => Promise<MediaConnInfo>;
15
17
  waUploadToServer: import("../Types").WAMediaUploadFunction;
@@ -17,7 +19,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
17
19
  [_: string]: string;
18
20
  }>;
19
21
  getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<JidWithDevice[]>;
20
- createParticipantNodes: (jids: string[], message: proto.IMessage, extraAttrs?: BinaryNode["attrs"]) => Promise<{
22
+ createParticipantNodes: (jids: string[], message: proto.IMessage, extraAttrs?: BinaryNode['attrs']) => Promise<{
21
23
  nodes: BinaryNode[];
22
24
  shouldIncludeDeviceIdentity: boolean;
23
25
  }>;
@@ -28,7 +30,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
28
30
  duration: string;
29
31
  }>;
30
32
  newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
31
- newsletterUpdateDescription: (jid: string, description?: string) => Promise<void>;
33
+ newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
32
34
  newsletterUpdateName: (jid: string, name: string) => Promise<void>;
33
35
  newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
34
36
  newsletterRemovePicture: (jid: string) => Promise<void>;
@@ -36,15 +38,15 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
36
38
  newsletterFollow: (jid: string) => Promise<void>;
37
39
  newsletterUnmute: (jid: string) => Promise<void>;
38
40
  newsletterMute: (jid: string) => Promise<void>;
39
- newsletterCreate: (name: string, description?: string, picture?: import("../Types").WAMediaUpload) => Promise<import("../Types").NewsletterMetadata>;
40
- newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole) => Promise<import("../Types").NewsletterMetadata>;
41
+ newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
42
+ newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
41
43
  newsletterAdminCount: (jid: string) => Promise<number>;
42
44
  newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
43
45
  newsletterDemote: (jid: string, user: string) => Promise<void>;
44
46
  newsletterDelete: (jid: string) => Promise<void>;
45
- newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
46
- newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
47
- newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
47
+ newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>;
48
+ newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
49
+ newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
48
50
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
49
51
  groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
50
52
  groupLeave: (id: string) => Promise<void>;
@@ -52,7 +54,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
52
54
  groupRequestParticipantsList: (jid: string) => Promise<{
53
55
  [key: string]: string;
54
56
  }[]>;
55
- groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
57
+ groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
56
58
  status: string;
57
59
  jid: string;
58
60
  }[]>;
@@ -61,40 +63,36 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
61
63
  jid: string;
62
64
  content: BinaryNode;
63
65
  }[]>;
64
- groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
66
+ groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
65
67
  groupInviteCode: (jid: string) => Promise<string | undefined>;
66
68
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
67
69
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
68
70
  groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
69
- groupAcceptInviteV4: (key: string | WAMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<any>;
71
+ groupAcceptInviteV4: (key: string | WAMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
70
72
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
71
73
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
72
- groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
73
- groupMemberAddMode: (jid: string, mode: "admin_add" | "all_member_add") => Promise<void>;
74
+ groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
75
+ groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
74
76
  groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
75
77
  groupFetchAllParticipating: () => Promise<{
76
78
  [_: string]: import("../Types").GroupMetadata;
77
79
  }>;
78
- getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
79
80
  processingMutex: {
80
- mutex<T>(code: () => Promise<T> | T): Promise<T>;
81
+ mutex<T>(code: () => T | Promise<T>): Promise<T>;
81
82
  };
82
83
  upsertMessage: (msg: proto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
83
84
  appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
84
- sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
85
- presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
86
- profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
85
+ sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
86
+ presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
87
+ profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;
87
88
  onWhatsApp: (...jids: string[]) => Promise<{
88
89
  jid: string;
89
90
  exists: unknown;
90
- lid: unknown;
91
91
  }[] | undefined>;
92
92
  fetchBlocklist: () => Promise<string[]>;
93
93
  fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
94
94
  fetchStatus: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
95
95
  updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
96
- updateProfilePictureFull: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
97
- updateProfilePictureFull2: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
98
96
  removeProfilePicture: (jid: string) => Promise<void>;
99
97
  updateProfileStatus: (status: string) => Promise<void>;
100
98
  updateProfileName: (name: string) => Promise<void>;
@@ -108,29 +106,26 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
108
106
  updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
109
107
  updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
110
108
  updateDefaultDisappearingMode: (duration: number) => Promise<void>;
111
- getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
109
+ getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
112
110
  resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
113
111
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
114
- cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
115
- addOrEditContact: (jid: string, contact: import("../Types").ContactAction) => Promise<void>;
116
- removeContact: (jid: string) => Promise<void>;
117
- addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
112
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
118
113
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
119
114
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
120
115
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
121
116
  removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
122
117
  star: (jid: string, messages: {
123
118
  id: string;
124
- fromMe?: boolean;
119
+ fromMe?: boolean | undefined;
125
120
  }[], star: boolean) => Promise<void>;
126
121
  executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
127
122
  type: "md";
128
- ws: import("./Client").WebSocketClient;
123
+ ws: any;
129
124
  ev: import("../Types").BaileysEventEmitter & {
130
- process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
125
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
131
126
  buffer(): void;
132
- createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
133
- flush(force?: boolean): boolean;
127
+ createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>;
128
+ flush(force?: boolean | undefined): boolean;
134
129
  isBuffering(): boolean;
135
130
  };
136
131
  authState: {
@@ -140,17 +135,17 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
140
135
  signalRepository: import("../Types").SignalRepository;
141
136
  user: import("../Types").Contact | undefined;
142
137
  generateMessageTag: () => string;
143
- query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
144
- waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
138
+ query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
139
+ waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
145
140
  waitForSocketOpen: () => Promise<void>;
146
141
  sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
147
142
  sendNode: (frame: BinaryNode) => Promise<void>;
148
- logout: (msg?: string) => Promise<void>;
143
+ logout: (msg?: string | undefined) => Promise<void>;
149
144
  end: (error: Error | undefined) => void;
150
- onUnexpectedError: (err: Error | Boom, msg: string) => void;
145
+ onUnexpectedError: (err: Error | Boom<any>, msg: string) => void;
151
146
  uploadPreKeys: (count?: number) => Promise<void>;
152
147
  uploadPreKeysToServerIfRequired: () => Promise<void>;
153
148
  requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
154
- waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
155
- sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
149
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number | undefined) => Promise<void>;
150
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
156
151
  };