@mamans2973/maman 0.0.0-stage → 1.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 (164) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1275 -2
  3. package/WAProto/index.d.ts +37016 -0
  4. package/WAProto/index.js +2972 -0
  5. package/WASignalGroup/GroupProtocol.js +1697 -0
  6. package/WASignalGroup/ciphertext_message.js +16 -0
  7. package/WASignalGroup/group_cipher.js +120 -0
  8. package/WASignalGroup/group_session_builder.js +46 -0
  9. package/WASignalGroup/index.js +5 -0
  10. package/WASignalGroup/keyhelper.js +21 -0
  11. package/WASignalGroup/protobufs.js +3 -0
  12. package/WASignalGroup/queue_job.js +69 -0
  13. package/WASignalGroup/sender_chain_key.js +50 -0
  14. package/WASignalGroup/sender_key_distribution_message.js +78 -0
  15. package/WASignalGroup/sender_key_message.js +92 -0
  16. package/WASignalGroup/sender_key_name.js +70 -0
  17. package/WASignalGroup/sender_key_record.js +56 -0
  18. package/WASignalGroup/sender_key_state.js +129 -0
  19. package/WASignalGroup/sender_message_key.js +39 -0
  20. package/engine-requirements.js +1 -0
  21. package/lib/Defaults/baileys-version.json +3 -0
  22. package/lib/Defaults/index.d.ts +51 -0
  23. package/lib/Defaults/index.js +10 -0
  24. package/lib/Signal/libsignal.d.ts +3 -0
  25. package/lib/Signal/libsignal.js +9 -0
  26. package/lib/Socket/Client/index.d.ts +2 -0
  27. package/lib/Socket/Client/index.js +2 -0
  28. package/lib/Socket/Client/types.d.ts +15 -0
  29. package/lib/Socket/Client/types.js +1 -0
  30. package/lib/Socket/Client/websocket.d.ts +12 -0
  31. package/lib/Socket/Client/websocket.js +4 -0
  32. package/lib/Socket/business.d.ts +146 -0
  33. package/lib/Socket/business.js +8 -0
  34. package/lib/Socket/chats.d.ts +85 -0
  35. package/lib/Socket/chats.js +29 -0
  36. package/lib/Socket/groups.d.ts +124 -0
  37. package/lib/Socket/groups.js +14 -0
  38. package/lib/Socket/index.d.ts +146 -0
  39. package/lib/Socket/index.js +1 -0
  40. package/lib/Socket/messages-recv.d.ts +135 -0
  41. package/lib/Socket/messages-recv.js +39 -0
  42. package/lib/Socket/messages-send.d.ts +130 -0
  43. package/lib/Socket/messages-send.js +26 -0
  44. package/lib/Socket/socket.d.ts +42 -0
  45. package/lib/Socket/socket.js +25 -0
  46. package/lib/Socket/usync.d.ts +36 -0
  47. package/lib/Socket/usync.js +3 -0
  48. package/lib/Types/Auth.d.ts +103 -0
  49. package/lib/Types/Auth.js +1 -0
  50. package/lib/Types/Call.d.ts +13 -0
  51. package/lib/Types/Call.js +1 -0
  52. package/lib/Types/Chat.d.ts +112 -0
  53. package/lib/Types/Chat.js +1 -0
  54. package/lib/Types/Contact.d.ts +19 -0
  55. package/lib/Types/Contact.js +1 -0
  56. package/lib/Types/Events.d.ts +172 -0
  57. package/lib/Types/Events.js +1 -0
  58. package/lib/Types/GroupMetadata.d.ts +58 -0
  59. package/lib/Types/GroupMetadata.js +1 -0
  60. package/lib/Types/Label.d.ts +46 -0
  61. package/lib/Types/Label.js +3 -0
  62. package/lib/Types/LabelAssociation.d.ts +29 -0
  63. package/lib/Types/LabelAssociation.js +1 -0
  64. package/lib/Types/Message.d.ts +267 -0
  65. package/lib/Types/Message.js +1 -0
  66. package/lib/Types/Product.d.ts +78 -0
  67. package/lib/Types/Product.js +1 -0
  68. package/lib/Types/Signal.d.ts +57 -0
  69. package/lib/Types/Signal.js +1 -0
  70. package/lib/Types/Socket.d.ts +121 -0
  71. package/lib/Types/Socket.js +1 -0
  72. package/lib/Types/State.d.ts +27 -0
  73. package/lib/Types/State.js +1 -0
  74. package/lib/Types/USync.d.ts +25 -0
  75. package/lib/Types/USync.js +1 -0
  76. package/lib/Types/index.d.ts +63 -0
  77. package/lib/Types/index.js +4 -0
  78. package/lib/Utils/auth-utils.d.ts +18 -0
  79. package/lib/Utils/auth-utils.js +8 -0
  80. package/lib/Utils/baileys-event-stream.d.ts +16 -0
  81. package/lib/Utils/baileys-event-stream.js +3 -0
  82. package/lib/Utils/business.d.ts +22 -0
  83. package/lib/Utils/business.js +14 -0
  84. package/lib/Utils/chat-utils.d.ts +70 -0
  85. package/lib/Utils/chat-utils.js +36 -0
  86. package/lib/Utils/crypto.d.ts +40 -0
  87. package/lib/Utils/crypto.js +11 -0
  88. package/lib/Utils/decode-wa-message.d.ts +36 -0
  89. package/lib/Utils/decode-wa-message.js +9 -0
  90. package/lib/Utils/event-buffer.d.ts +35 -0
  91. package/lib/Utils/event-buffer.js +19 -0
  92. package/lib/Utils/generics.d.ts +90 -0
  93. package/lib/Utils/generics.js +22 -0
  94. package/lib/Utils/history.d.ts +19 -0
  95. package/lib/Utils/history.js +7 -0
  96. package/lib/Utils/index.d.ts +17 -0
  97. package/lib/Utils/index.js +3 -0
  98. package/lib/Utils/link-preview.d.ts +21 -0
  99. package/lib/Utils/link-preview.js +5 -0
  100. package/lib/Utils/logger.d.ts +11 -0
  101. package/lib/Utils/logger.js +1 -0
  102. package/lib/Utils/lt-hash.d.ts +12 -0
  103. package/lib/Utils/lt-hash.js +3 -0
  104. package/lib/Utils/make-mutex.d.ts +7 -0
  105. package/lib/Utils/make-mutex.js +1 -0
  106. package/lib/Utils/messages-media.d.ts +103 -0
  107. package/lib/Utils/messages-media.js +35 -0
  108. package/lib/Utils/messages.d.ts +75 -0
  109. package/lib/Utils/messages.js +43 -0
  110. package/lib/Utils/noise-handler.d.ts +19 -0
  111. package/lib/Utils/noise-handler.js +6 -0
  112. package/lib/Utils/process-message.d.ts +41 -0
  113. package/lib/Utils/process-message.js +19 -0
  114. package/lib/Utils/signal.d.ts +33 -0
  115. package/lib/Utils/signal.js +10 -0
  116. package/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
  117. package/lib/Utils/use-multi-file-auth-state.js +5 -0
  118. package/lib/Utils/validate-connection.d.ts +10 -0
  119. package/lib/Utils/validate-connection.js +10 -0
  120. package/lib/WABinary/constants.d.ts +27 -0
  121. package/lib/WABinary/constants.js +6 -0
  122. package/lib/WABinary/decode.d.ts +6 -0
  123. package/lib/WABinary/decode.js +9 -0
  124. package/lib/WABinary/encode.d.ts +2 -0
  125. package/lib/WABinary/encode.js +9 -0
  126. package/lib/WABinary/generic-utils.d.ts +14 -0
  127. package/lib/WABinary/generic-utils.js +7 -0
  128. package/lib/WABinary/index.d.ts +5 -0
  129. package/lib/WABinary/index.js +2 -0
  130. package/lib/WABinary/jid-utils.d.ts +35 -0
  131. package/lib/WABinary/jid-utils.js +5 -0
  132. package/lib/WABinary/types.d.ts +18 -0
  133. package/lib/WABinary/types.js +1 -0
  134. package/lib/WAM/BinaryInfo.d.ts +8 -0
  135. package/lib/WAM/BinaryInfo.js +1 -0
  136. package/lib/WAM/constants.d.ts +39 -0
  137. package/lib/WAM/constants.js +492 -0
  138. package/lib/WAM/encode.d.ts +2 -0
  139. package/lib/WAM/encode.js +7 -0
  140. package/lib/WAM/index.d.ts +3 -0
  141. package/lib/WAM/index.js +2 -0
  142. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
  143. package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -0
  144. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
  145. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +3 -0
  146. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  147. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -0
  148. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  149. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -0
  150. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
  151. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +4 -0
  152. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
  153. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +1 -0
  154. package/lib/WAUSync/Protocols/index.d.ts +4 -0
  155. package/lib/WAUSync/Protocols/index.js +2 -0
  156. package/lib/WAUSync/USyncQuery.d.ts +28 -0
  157. package/lib/WAUSync/USyncQuery.js +4 -0
  158. package/lib/WAUSync/USyncUser.d.ts +12 -0
  159. package/lib/WAUSync/USyncUser.js +1 -0
  160. package/lib/WAUSync/index.d.ts +3 -0
  161. package/lib/WAUSync/index.js +2 -0
  162. package/lib/index.d.ts +11 -0
  163. package/lib/index.js +3 -0
  164. package/package.json +94 -4
@@ -0,0 +1,124 @@
1
+ import { proto } from '../../WAProto';
2
+ import { GroupMetadata, ParticipantAction, SocketConfig } from '../Types';
3
+ import { BinaryNode } from '../WABinary';
4
+ export declare const makeGroupsSocket: (config: SocketConfig) => {
5
+ groupMetadata: (jid: string) => Promise<GroupMetadata>;
6
+ groupCreate: (subject: string, participants: string[]) => Promise<GroupMetadata>;
7
+ groupLeave: (id: string) => Promise<void>;
8
+ groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
9
+ groupRequestParticipantsList: (jid: string) => Promise<{
10
+ [key: string]: string;
11
+ }[]>;
12
+ groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
13
+ status: string;
14
+ jid: string;
15
+ }[]>;
16
+ groupParticipantsUpdate: (jid: string, participants: string[], action: ParticipantAction) => Promise<{
17
+ status: string;
18
+ jid: string;
19
+ content: BinaryNode;
20
+ }[]>;
21
+ groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
22
+ groupInviteCode: (jid: string) => Promise<string | undefined>;
23
+ groupRevokeInvite: (jid: string) => Promise<string | undefined>;
24
+ groupAcceptInvite: (code: string) => Promise<string | undefined>;
25
+ /**
26
+ * revoke a v4 invite for someone
27
+ * @param groupJid group jid
28
+ * @param invitedJid jid of person you invited
29
+ * @returns true if successful
30
+ */
31
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
32
+ /**
33
+ * accept a GroupInviteMessage
34
+ * @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
35
+ * @param inviteMessage the message to accept
36
+ */
37
+ groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<any>;
38
+ groupGetInviteInfo: (code: string) => Promise<GroupMetadata>;
39
+ groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
40
+ groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
41
+ groupMemberAddMode: (jid: string, mode: "admin_add" | "all_member_add") => Promise<void>;
42
+ groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
43
+ groupFetchAllParticipating: () => Promise<{
44
+ [_: string]: GroupMetadata;
45
+ }>;
46
+ getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
47
+ processingMutex: {
48
+ mutex<T>(code: () => Promise<T> | T): Promise<T>;
49
+ };
50
+ fetchPrivacySettings: (force?: boolean) => Promise<{
51
+ [_: string]: string;
52
+ }>;
53
+ upsertMessage: (msg: proto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
54
+ appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
55
+ sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
56
+ presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
57
+ profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
58
+ onWhatsApp: (...jids: string[]) => Promise<{
59
+ jid: string;
60
+ exists: unknown;
61
+ lid: unknown;
62
+ }[] | undefined>;
63
+ fetchBlocklist: () => Promise<string[]>;
64
+ fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
65
+ fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
66
+ updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
67
+ removeProfilePicture: (jid: string) => Promise<void>;
68
+ updateProfileStatus: (status: string) => Promise<void>;
69
+ updateProfileName: (name: string) => Promise<void>;
70
+ updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
71
+ updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
72
+ updateMessagesPrivacy: (value: import("../Types").WAPrivacyMessagesValue) => Promise<void>;
73
+ updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
74
+ updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
75
+ updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
76
+ updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
77
+ updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
78
+ updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
79
+ updateDefaultDisappearingMode: (duration: number) => Promise<void>;
80
+ getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
81
+ resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
82
+ chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
83
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
84
+ addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
85
+ addChatLabel: (jid: string, labelId: string) => Promise<void>;
86
+ removeChatLabel: (jid: string, labelId: string) => Promise<void>;
87
+ addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
88
+ removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
89
+ star: (jid: string, messages: {
90
+ id: string;
91
+ fromMe?: boolean;
92
+ }[], star: boolean) => Promise<void>;
93
+ executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
94
+ type: "md";
95
+ ws: import("./Client").WebSocketClient;
96
+ ev: import("../Types").BaileysEventEmitter & {
97
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
98
+ buffer(): void;
99
+ createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
100
+ flush(force?: boolean): boolean;
101
+ isBuffering(): boolean;
102
+ };
103
+ authState: {
104
+ creds: import("../Types").AuthenticationCreds;
105
+ keys: import("../Types").SignalKeyStoreWithTransaction;
106
+ };
107
+ signalRepository: import("../Types").SignalRepository;
108
+ user: import("../Types").Contact | undefined;
109
+ generateMessageTag: () => string;
110
+ query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
111
+ waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
112
+ waitForSocketOpen: () => Promise<void>;
113
+ sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
114
+ sendNode: (frame: BinaryNode) => Promise<void>;
115
+ logout: (msg?: string) => Promise<void>;
116
+ end: (error: Error | undefined) => void;
117
+ onUnexpectedError: (err: Error | import("@hapi/boom").Boom, msg: string) => void;
118
+ uploadPreKeys: (count?: number) => Promise<void>;
119
+ uploadPreKeysToServerIfRequired: () => Promise<void>;
120
+ requestPairingCode: (phoneNumber: string) => Promise<string>;
121
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
122
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
123
+ };
124
+ export declare const extractGroupMetadata: (result: BinaryNode) => GroupMetadata;
@@ -0,0 +1,14 @@
1
+ Object.defineProperty(exports,"__esModule",{value:!0});exports.extractGroupMetadata=exports.makeGroupsSocket=void 0;
2
+ const WAProto_1=require("../../WAProto"),Types_1=require("../Types"),Utils_1=require("../Utils"),WABinary_1=require("../WABinary"),chats_1=require("./chats"),makeGroupsSocket=c=>{const g=(0,chats_1.makeChatsSocket)(c),{authState:k,ev:h,query:l,upsertMessage:n}=g,e=async(a,b,d)=>l({tag:"iq",attrs:{type:b,xmlns:"w:g2",to:a},content:d}),m=async a=>{a=await e(a,"get",[{tag:"query",attrs:{request:"interactive"}}]);return(0,exports.extractGroupMetadata)(a)},p=async()=>{var a=await l({tag:"iq",attrs:{to:"@g.us",
3
+ xmlns:"w:g2",type:"get"},content:[{tag:"participating",attrs:{},content:[{tag:"participants",attrs:{}},{tag:"description",attrs:{}}]}]});const b={};if(a=(0,WABinary_1.getBinaryNodeChild)(a,"groups")){a=(0,WABinary_1.getBinaryNodeChildren)(a,"group");for(const d of a)a=(0,exports.extractGroupMetadata)({tag:"result",attrs:{},content:[d]}),b[a.id]=a}g.ev.emit("groups.update",Object.values(b));return b};g.ws.on("CB:ib,,dirty",async a=>{({attrs:a}=(0,WABinary_1.getBinaryNodeChild)(a,"dirty"));"groups"===
4
+ a.type&&(await p(),await g.cleanDirtyBits("groups"))});return{...g,groupMetadata:m,groupCreate:async(a,b)=>{const d=(0,Utils_1.generateMessageIDV2)();a=await e("@g.us","set",[{tag:"create",attrs:{subject:a,key:d},content:b.map(f=>({tag:"participant",attrs:{jid:f}}))}]);return(0,exports.extractGroupMetadata)(a)},groupLeave:async a=>{await e("@g.us","set",[{tag:"leave",attrs:{},content:[{tag:"group",attrs:{id:a}}]}])},groupUpdateSubject:async(a,b)=>{await e(a,"set",[{tag:"subject",attrs:{},content:Buffer.from(b,
5
+ "utf-8")}])},groupRequestParticipantsList:async a=>{a=await e(a,"get",[{tag:"membership_approval_requests",attrs:{}}]);a=(0,WABinary_1.getBinaryNodeChild)(a,"membership_approval_requests");return(0,WABinary_1.getBinaryNodeChildren)(a,"membership_approval_request").map(b=>b.attrs)},groupRequestParticipantsUpdate:async(a,b,d)=>{a=await e(a,"set",[{tag:"membership_requests_action",attrs:{},content:[{tag:d,attrs:{},content:b.map(f=>({tag:"participant",attrs:{jid:f}}))}]}]);a=(0,WABinary_1.getBinaryNodeChild)(a,
6
+ "membership_requests_action");d=(0,WABinary_1.getBinaryNodeChild)(a,d);return(0,WABinary_1.getBinaryNodeChildren)(d,"participant").map(f=>({status:f.attrs.error||"200",jid:f.attrs.jid}))},groupParticipantsUpdate:async(a,b,d)=>{a=await e(a,"set",[{tag:d,attrs:{},content:b.map(f=>({tag:"participant",attrs:{jid:f}}))}]);d=(0,WABinary_1.getBinaryNodeChild)(a,d);return(0,WABinary_1.getBinaryNodeChildren)(d,"participant").map(f=>({status:f.attrs.error||"200",jid:f.attrs.jid,content:f}))},groupUpdateDescription:async(a,
7
+ b)=>{var d;const f=null!==(d=(await m(a)).descId)&&void 0!==d?d:null;await e(a,"set",[{tag:"description",attrs:{...(b?{id:(0,Utils_1.generateMessageIDV2)()}:{delete:"true"}),...(f?{prev:f}:{})},content:b?[{tag:"body",attrs:{},content:Buffer.from(b,"utf-8")}]:void 0}])},groupInviteCode:async a=>{a=await e(a,"get",[{tag:"invite",attrs:{}}]);a=(0,WABinary_1.getBinaryNodeChild)(a,"invite");return null===a||void 0===a?void 0:a.attrs.code},groupRevokeInvite:async a=>{a=await e(a,"set",[{tag:"invite",attrs:{}}]);
8
+ a=(0,WABinary_1.getBinaryNodeChild)(a,"invite");return null===a||void 0===a?void 0:a.attrs.code},groupAcceptInvite:async a=>{a=await e("@g.us","set",[{tag:"invite",attrs:{code:a}}]);a=(0,WABinary_1.getBinaryNodeChild)(a,"group");return null===a||void 0===a?void 0:a.attrs.jid},groupRevokeInviteV4:async(a,b)=>!!await e(a,"set",[{tag:"revoke",attrs:{},content:[{tag:"participant",attrs:{jid:b}}]}]),groupAcceptInviteV4:h.createBufferedFunction(async(a,b)=>{var d;a="string"===typeof a?{remoteJid:a}:a;const f=
9
+ await e(b.groupJid,"set",[{tag:"accept",attrs:{code:b.inviteCode,expiration:b.inviteExpiration.toString(),admin:a.remoteJid}}]);a.id&&(b=WAProto_1.proto.Message.GroupInviteMessage.fromObject(b),b.inviteExpiration=0,b.inviteCode="",h.emit("messages.update",[{key:a,update:{message:{groupInviteMessage:b}}}]));await n({key:{remoteJid:b.groupJid,id:(0,Utils_1.generateMessageIDV2)(null===(d=g.user)||void 0===d?void 0:d.id),fromMe:!1,participant:a.remoteJid},messageStubType:Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD,
10
+ messageStubParameters:[k.creds.me.id],participant:a.remoteJid,messageTimestamp:(0,Utils_1.unixTimestampSeconds)()},"notify");return f.attrs.from}),groupGetInviteInfo:async a=>{a=await e("@g.us","get",[{tag:"invite",attrs:{code:a}}]);return(0,exports.extractGroupMetadata)(a)},groupToggleEphemeral:async(a,b)=>{await e(a,"set",[b?{tag:"ephemeral",attrs:{expiration:b.toString()}}:{tag:"not_ephemeral",attrs:{}}])},groupSettingUpdate:async(a,b)=>{await e(a,"set",[{tag:b,attrs:{}}])},groupMemberAddMode:async(a,
11
+ b)=>{await e(a,"set",[{tag:"member_add_mode",attrs:{},content:b}])},groupJoinApprovalMode:async(a,b)=>{await e(a,"set",[{tag:"membership_approval_mode",attrs:{},content:[{tag:"group_join",attrs:{state:b}}]}])},groupFetchAllParticipating:p}};exports.makeGroupsSocket=makeGroupsSocket;
12
+ const extractGroupMetadata=c=>{var g,k;c=(0,WABinary_1.getBinaryNodeChild)(c,"group");var h=(0,WABinary_1.getBinaryNodeChild)(c,"description");let l,n;h&&(l=(0,WABinary_1.getBinaryNodeChildString)(h,"body"),n=h.attrs.id);h=c.attrs.id.includes("@")?c.attrs.id:(0,WABinary_1.jidEncode)(c.attrs.id,"g.us");const e=null===(g=(0,WABinary_1.getBinaryNodeChild)(c,"ephemeral"))||void 0===g?void 0:g.attrs.expiration;g="all_member_add"===(0,WABinary_1.getBinaryNodeChildString)(c,"member_add_mode");return{id:h,
13
+ addressingMode:c.attrs.addressing_mode,subject:c.attrs.subject,subjectOwner:c.attrs.s_o,subjectTime:+c.attrs.s_t,size:(0,WABinary_1.getBinaryNodeChildren)(c,"participant").length,creation:+c.attrs.creation,owner:c.attrs.creator?(0,WABinary_1.jidNormalizedUser)(c.attrs.creator):void 0,desc:l,descId:n,linkedParent:(null===(k=(0,WABinary_1.getBinaryNodeChild)(c,"linked_parent"))||void 0===k?void 0:k.attrs.jid)||void 0,restrict:!!(0,WABinary_1.getBinaryNodeChild)(c,"locked"),announce:!!(0,WABinary_1.getBinaryNodeChild)(c,
14
+ "announcement"),isCommunity:!!(0,WABinary_1.getBinaryNodeChild)(c,"parent"),isCommunityAnnounce:!!(0,WABinary_1.getBinaryNodeChild)(c,"default_sub_group"),joinApprovalMode:!!(0,WABinary_1.getBinaryNodeChild)(c,"membership_approval_mode"),memberAddMode:g,participants:(0,WABinary_1.getBinaryNodeChildren)(c,"participant").map(({attrs:m})=>({id:m.jid,admin:m.type||null})),ephemeralDuration:e?+e:void 0}};exports.extractGroupMetadata=extractGroupMetadata;
@@ -0,0 +1,146 @@
1
+ import { UserFacingSocketConfig } from '../Types';
2
+ declare const makeWASocket: (config: UserFacingSocketConfig) => {
3
+ logger: import("../Utils/logger").ILogger;
4
+ getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
5
+ getCatalog: ({ jid, limit, cursor }: import("../Types").GetCatalogOptions) => Promise<{
6
+ products: import("../Types").Product[];
7
+ nextPageCursor: string | undefined;
8
+ }>;
9
+ getCollections: (jid?: string, limit?: number) => Promise<{
10
+ collections: import("../Types").CatalogCollection[];
11
+ }>;
12
+ productCreate: (create: import("../Types").ProductCreate) => Promise<import("../Types").Product>;
13
+ productDelete: (productIds: string[]) => Promise<{
14
+ deleted: number;
15
+ }>;
16
+ productUpdate: (productId: string, update: import("../Types").ProductUpdate) => Promise<import("../Types").Product>;
17
+ sendMessageAck: ({ tag, attrs, content }: import("..").BinaryNode, errorCode?: number) => Promise<void>;
18
+ sendRetryRequest: (node: import("..").BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
19
+ rejectCall: (callId: string, callFrom: string) => Promise<void>;
20
+ fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | import("long").default) => Promise<string>;
21
+ requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
22
+ getPrivacyTokens: (jids: string[]) => Promise<any>;
23
+ assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
24
+ relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
25
+ sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
26
+ sendReceipts: (keys: import("../Types").WAMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
27
+ readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
28
+ refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
29
+ waUploadToServer: import("../Types").WAMediaUploadFunction;
30
+ fetchPrivacySettings: (force?: boolean) => Promise<{
31
+ [_: string]: string;
32
+ }>;
33
+ sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
34
+ createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: import("..").BinaryNode["attrs"]) => Promise<{
35
+ nodes: import("..").BinaryNode[];
36
+ shouldIncludeDeviceIdentity: boolean;
37
+ }>;
38
+ getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("..").JidWithDevice[]>;
39
+ updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
40
+ sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
41
+ groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
42
+ groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
43
+ groupLeave: (id: string) => Promise<void>;
44
+ groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
45
+ groupRequestParticipantsList: (jid: string) => Promise<{
46
+ [key: string]: string;
47
+ }[]>;
48
+ groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
49
+ status: string;
50
+ jid: string;
51
+ }[]>;
52
+ groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
53
+ status: string;
54
+ jid: string;
55
+ content: import("..").BinaryNode;
56
+ }[]>;
57
+ groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
58
+ groupInviteCode: (jid: string) => Promise<string | undefined>;
59
+ groupRevokeInvite: (jid: string) => Promise<string | undefined>;
60
+ groupAcceptInvite: (code: string) => Promise<string | undefined>;
61
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
62
+ groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<any>;
63
+ groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
64
+ groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
65
+ groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
66
+ groupMemberAddMode: (jid: string, mode: "admin_add" | "all_member_add") => Promise<void>;
67
+ groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
68
+ groupFetchAllParticipating: () => Promise<{
69
+ [_: string]: import("../Types").GroupMetadata;
70
+ }>;
71
+ getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
72
+ processingMutex: {
73
+ mutex<T>(code: () => Promise<T> | T): Promise<T>;
74
+ };
75
+ upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
76
+ appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
77
+ sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
78
+ presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
79
+ profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
80
+ onWhatsApp: (...jids: string[]) => Promise<{
81
+ jid: string;
82
+ exists: unknown;
83
+ lid: unknown;
84
+ }[] | undefined>;
85
+ fetchBlocklist: () => Promise<string[]>;
86
+ fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
87
+ fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
88
+ updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
89
+ removeProfilePicture: (jid: string) => Promise<void>;
90
+ updateProfileStatus: (status: string) => Promise<void>;
91
+ updateProfileName: (name: string) => Promise<void>;
92
+ updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
93
+ updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
94
+ updateMessagesPrivacy: (value: import("../Types").WAPrivacyMessagesValue) => Promise<void>;
95
+ updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
96
+ updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
97
+ updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
98
+ updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
99
+ updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
100
+ updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
101
+ updateDefaultDisappearingMode: (duration: number) => Promise<void>;
102
+ getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
103
+ resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
104
+ chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
105
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
106
+ addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
107
+ addChatLabel: (jid: string, labelId: string) => Promise<void>;
108
+ removeChatLabel: (jid: string, labelId: string) => Promise<void>;
109
+ addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
110
+ removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
111
+ star: (jid: string, messages: {
112
+ id: string;
113
+ fromMe?: boolean;
114
+ }[], star: boolean) => Promise<void>;
115
+ executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
116
+ type: "md";
117
+ ws: import("./Client").WebSocketClient;
118
+ ev: import("../Types").BaileysEventEmitter & {
119
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
120
+ buffer(): void;
121
+ createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
122
+ flush(force?: boolean): boolean;
123
+ isBuffering(): boolean;
124
+ };
125
+ authState: {
126
+ creds: import("../Types").AuthenticationCreds;
127
+ keys: import("../Types").SignalKeyStoreWithTransaction;
128
+ };
129
+ signalRepository: import("../Types").SignalRepository;
130
+ user: import("../Types").Contact | undefined;
131
+ generateMessageTag: () => string;
132
+ query: (node: import("..").BinaryNode, timeoutMs?: number) => Promise<any>;
133
+ waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
134
+ waitForSocketOpen: () => Promise<void>;
135
+ sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
136
+ sendNode: (frame: import("..").BinaryNode) => Promise<void>;
137
+ logout: (msg?: string) => Promise<void>;
138
+ end: (error: Error | undefined) => void;
139
+ onUnexpectedError: (err: Error | import("@hapi/boom").Boom, msg: string) => void;
140
+ uploadPreKeys: (count?: number) => Promise<void>;
141
+ uploadPreKeysToServerIfRequired: () => Promise<void>;
142
+ requestPairingCode: (phoneNumber: string) => Promise<string>;
143
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
144
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
145
+ };
146
+ export default makeWASocket;
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,"__esModule",{value:!0});const Defaults_1=require("../Defaults"),business_1=require("./business"),makeWASocket=a=>(0,business_1.makeBusinessSocket)({...Defaults_1.DEFAULT_CONNECTION_CONFIG,...a});exports.default=makeWASocket;
@@ -0,0 +1,135 @@
1
+ import { Boom } from '@hapi/boom';
2
+ import Long = require('long');
3
+ import { proto } from '../../WAProto';
4
+ import { MessageReceiptType, MessageRelayOptions, SocketConfig, WAMessageKey } from '../Types';
5
+ import { BinaryNode } from '../WABinary';
6
+ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
7
+ sendMessageAck: ({ tag, attrs, content }: BinaryNode, errorCode?: number) => Promise<void>;
8
+ sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
9
+ rejectCall: (callId: string, callFrom: string) => Promise<void>;
10
+ fetchMessageHistory: (count: number, oldestMsgKey: WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
11
+ requestPlaceholderResend: (messageKey: WAMessageKey) => Promise<string | undefined>;
12
+ getPrivacyTokens: (jids: string[]) => Promise<any>;
13
+ assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
14
+ relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
15
+ sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => Promise<void>;
16
+ sendReceipts: (keys: WAMessageKey[], type: MessageReceiptType) => Promise<void>;
17
+ readMessages: (keys: WAMessageKey[]) => Promise<void>;
18
+ refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
19
+ waUploadToServer: import("../Types").WAMediaUploadFunction;
20
+ fetchPrivacySettings: (force?: boolean) => Promise<{
21
+ [_: string]: string;
22
+ }>;
23
+ sendPeerDataOperationMessage: (pdoMessage: proto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
24
+ createParticipantNodes: (jids: string[], message: proto.IMessage, extraAttrs?: BinaryNode["attrs"]) => Promise<{
25
+ nodes: BinaryNode[];
26
+ shouldIncludeDeviceIdentity: boolean;
27
+ }>;
28
+ getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
29
+ updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
30
+ sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo | undefined>;
31
+ groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
32
+ groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
33
+ groupLeave: (id: string) => Promise<void>;
34
+ groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
35
+ groupRequestParticipantsList: (jid: string) => Promise<{
36
+ [key: string]: string;
37
+ }[]>;
38
+ groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
39
+ status: string;
40
+ jid: string;
41
+ }[]>;
42
+ groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
43
+ status: string;
44
+ jid: string;
45
+ content: BinaryNode;
46
+ }[]>;
47
+ groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
48
+ groupInviteCode: (jid: string) => Promise<string | undefined>;
49
+ groupRevokeInvite: (jid: string) => Promise<string | undefined>;
50
+ groupAcceptInvite: (code: string) => Promise<string | undefined>;
51
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
52
+ groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<any>;
53
+ groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
54
+ groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
55
+ groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
56
+ groupMemberAddMode: (jid: string, mode: "admin_add" | "all_member_add") => Promise<void>;
57
+ groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
58
+ groupFetchAllParticipating: () => Promise<{
59
+ [_: string]: import("../Types").GroupMetadata;
60
+ }>;
61
+ getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
62
+ processingMutex: {
63
+ mutex<T>(code: () => Promise<T> | T): Promise<T>;
64
+ };
65
+ upsertMessage: (msg: proto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
66
+ appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
67
+ sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
68
+ presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
69
+ profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
70
+ onWhatsApp: (...jids: string[]) => Promise<{
71
+ jid: string;
72
+ exists: unknown;
73
+ lid: unknown;
74
+ }[] | undefined>;
75
+ fetchBlocklist: () => Promise<string[]>;
76
+ fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
77
+ fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
78
+ updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
79
+ removeProfilePicture: (jid: string) => Promise<void>;
80
+ updateProfileStatus: (status: string) => Promise<void>;
81
+ updateProfileName: (name: string) => Promise<void>;
82
+ updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
83
+ updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
84
+ updateMessagesPrivacy: (value: import("../Types").WAPrivacyMessagesValue) => Promise<void>;
85
+ updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
86
+ updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
87
+ updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
88
+ updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
89
+ updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
90
+ updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
91
+ updateDefaultDisappearingMode: (duration: number) => Promise<void>;
92
+ getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
93
+ resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
94
+ chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
95
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
96
+ addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
97
+ addChatLabel: (jid: string, labelId: string) => Promise<void>;
98
+ removeChatLabel: (jid: string, labelId: string) => Promise<void>;
99
+ addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
100
+ removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
101
+ star: (jid: string, messages: {
102
+ id: string;
103
+ fromMe?: boolean;
104
+ }[], star: boolean) => Promise<void>;
105
+ executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
106
+ type: "md";
107
+ ws: import("./Client").WebSocketClient;
108
+ ev: import("../Types").BaileysEventEmitter & {
109
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
110
+ buffer(): void;
111
+ createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
112
+ flush(force?: boolean): boolean;
113
+ isBuffering(): boolean;
114
+ };
115
+ authState: {
116
+ creds: import("../Types").AuthenticationCreds;
117
+ keys: import("../Types").SignalKeyStoreWithTransaction;
118
+ };
119
+ signalRepository: import("../Types").SignalRepository;
120
+ user: import("../Types").Contact | undefined;
121
+ generateMessageTag: () => string;
122
+ query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
123
+ waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
124
+ waitForSocketOpen: () => Promise<void>;
125
+ sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
126
+ sendNode: (frame: BinaryNode) => Promise<void>;
127
+ logout: (msg?: string) => Promise<void>;
128
+ end: (error: Error | undefined) => void;
129
+ onUnexpectedError: (err: Error | Boom, msg: string) => void;
130
+ uploadPreKeys: (count?: number) => Promise<void>;
131
+ uploadPreKeysToServerIfRequired: () => Promise<void>;
132
+ requestPairingCode: (phoneNumber: string) => Promise<string>;
133
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
134
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
135
+ };
@@ -0,0 +1,39 @@
1
+ var __importDefault=this&&this.__importDefault||function(u){return u&&u.__esModule?u:{"default":u}};Object.defineProperty(exports,"__esModule",{value:!0});exports.makeMessagesRecvSocket=void 0;
2
+ const node_cache_1=__importDefault(require("@cacheable/node-cache")),boom_1=require("@hapi/boom"),crypto_1=require("crypto"),WAProto_1=require("../../WAProto"),Defaults_1=require("../Defaults"),Types_1=require("../Types"),Utils_1=require("../Utils"),make_mutex_1=require("../Utils/make-mutex"),WABinary_1=require("../WABinary"),groups_1=require("./groups"),messages_send_1=require("./messages-send"),makeMessagesRecvSocket=u=>{async function W(a){a=z(a);var b=a.slice(0,32);b=await (0,Utils_1.derivePairingCodeKey)(k.creds.pairingCode,
3
+ b);const c=a.slice(32,48);a=a.slice(48,80);return(0,Utils_1.aesDecryptCTR)(a,b,c)}function z(a){if(void 0===a)throw new boom_1.Boom("Invalid buffer",{statusCode:400});return a instanceof Buffer?a:Buffer.from(a)}const {logger:m,retryRequestDelayMs:K,maxMsgRetryCount:L,getMessage:X,shouldIgnoreJid:D}=u,E=(0,messages_send_1.makeMessagesSocket)(u),{ev:p,authState:k,ws:v,processingMutex:F,signalRepository:Y,query:M,upsertMessage:G,resyncAppState:Z,onUnexpectedError:A,assertSessions:aa,sendNode:N,relayMessage:ba,
4
+ sendReceipt:O,uploadPreKeys:ca,sendPeerDataOperationMessage:P}=E,da=(0,make_mutex_1.makeMutex)(),x=u.msgRetryCounterCache||new node_cache_1.default({stdTTL:Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,useClones:!1}),H=u.callOfferCache||new node_cache_1.default({stdTTL:Defaults_1.DEFAULT_CACHE_TTLS.CALL_OFFER,useClones:!1}),w=u.placeholderResendCache||new node_cache_1.default({stdTTL:Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,useClones:!1});let I=!1;const t=async({tag:a,attrs:b,content:c},d)=>{const f={tag:"ack",
5
+ attrs:{id:b.id,to:b.from,class:a}};d&&(f.attrs.error=d.toString());b.participant&&(f.attrs.participant=b.participant);b.recipient&&(f.attrs.recipient=b.recipient);b.type&&("message"!==a||(0,WABinary_1.getBinaryNodeChild)({tag:a,attrs:b,content:c},"unavailable")||0!==d)&&(f.attrs.type=b.type);"message"===a&&(0,WABinary_1.getBinaryNodeChild)({tag:a,attrs:b,content:c},"unavailable")&&(f.attrs.from=k.creds.me.id);m.debug({recv:{tag:a,attrs:b},sent:f.attrs},"sent ack");await N(f)},R=async(a,b=!1)=>{var {fullMessage:c}=
6
+ (0,Utils_1.decodeMessageNode)(a,k.creds.me.id,k.creds.me.lid||"");({key:c}=c);const d=c.id,f=`${d}:${null===c||void 0===c?void 0:c.participant}`;let e=x.get(f)||0;if(e>=L)m.debug({retryCount:e,msgId:d},"reached retry limit, clearing"),x.del(f);else{e+=1;x.set(f,e);var {account:g,signedPreKey:l,signedIdentityKey:h}=k.creds;1===e&&(c=await J(c),m.debug(`sendRetryRequest: requested placeholder resend for message ${c}`));var q=(0,Utils_1.encodeSignedDeviceIdentity)(g,!0);await k.keys.transaction(async()=>
7
+ {const n={tag:"receipt",attrs:{id:d,type:"retry",to:a.attrs.from},content:[{tag:"retry",attrs:{count:e.toString(),id:a.attrs.id,t:a.attrs.t,v:"1"}},{tag:"registration",attrs:{},content:(0,Utils_1.encodeBigEndian)(k.creds.registrationId)}]};a.attrs.recipient&&(n.attrs.recipient=a.attrs.recipient);a.attrs.participant&&(n.attrs.participant=a.attrs.participant);if(1<e||b){const {update:r,preKeys:y}=await (0,Utils_1.getNextPreKeys)(k,1),[Q]=Object.keys(y),ea=y[+Q];n.content.push({tag:"keys",attrs:{},content:[{tag:"type",
8
+ attrs:{},content:Buffer.from(Defaults_1.KEY_BUNDLE_TYPE)},{tag:"identity",attrs:{},content:h.public},(0,Utils_1.xmppPreKey)(ea,+Q),(0,Utils_1.xmppSignedPreKey)(l),{tag:"device-identity",attrs:{},content:q}]});p.emit("creds.update",r)}await N(n);m.info({msgAttrs:a.attrs,retryCount:e},"sent retry receipt")})}},fa=async a=>{var b=a.attrs.from;b===WABinary_1.S_WHATSAPP_NET?(a=+(0,WABinary_1.getBinaryNodeChild)(a,"count").attrs.value,b=a<Defaults_1.MIN_PREKEY_COUNT,m.debug({count:a,shouldUploadMorePreKeys:b},
9
+ "recv pre-key count"),b&&await ca()):(0,WABinary_1.getBinaryNodeChild)(a,"identity")?m.info({jid:b},"identity changed"):m.info({node:a},"unknown encrypt notification")},ha=(a,b,c)=>{var d,f,e;const g=(null===(f=null===(d=(0,WABinary_1.getBinaryNodeChild)(b,"participant"))||void 0===d?void 0:d.attrs)||void 0===f?void 0:f.jid)||a;switch(null===b||void 0===b?void 0:b.tag){case "create":b=(0,groups_1.extractGroupMetadata)(b);c.messageStubType=Types_1.WAMessageStubType.GROUP_CREATE;c.messageStubParameters=
10
+ [b.subject];c.key={participant:b.owner};p.emit("chats.upsert",[{id:b.id,name:b.subject,conversationTimestamp:b.creation}]);p.emit("groups.upsert",[{...b,author:a}]);break;case "ephemeral":case "not_ephemeral":c.message={protocolMessage:{type:WAProto_1.proto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING,ephemeralExpiration:+(b.attrs.expiration||0)}};break;case "modify":a=(0,WABinary_1.getBinaryNodeChildren)(b,"participant").map(h=>h.attrs.jid);c.messageStubParameters=a||[];c.messageStubType=Types_1.WAMessageStubType.GROUP_PARTICIPANT_CHANGE_NUMBER;
11
+ break;case "promote":case "demote":case "remove":case "add":case "leave":var l=`GROUP_PARTICIPANT_${b.tag.toUpperCase()}`;c.messageStubType=Types_1.WAMessageStubType[l];l=(0,WABinary_1.getBinaryNodeChildren)(b,"participant").map(h=>h.attrs.jid);1===l.length&&(0,WABinary_1.areJidsSameUser)(l[0],a)&&"remove"===b.tag&&(c.messageStubType=Types_1.WAMessageStubType.GROUP_PARTICIPANT_LEAVE);c.messageStubParameters=l;break;case "subject":c.messageStubType=Types_1.WAMessageStubType.GROUP_CHANGE_SUBJECT;c.messageStubParameters=
12
+ [b.attrs.subject];break;case "description":a=null===(e=null===(l=(0,WABinary_1.getBinaryNodeChild)(b,"body"))||void 0===l?void 0:l.content)||void 0===e?void 0:e.toString();c.messageStubType=Types_1.WAMessageStubType.GROUP_CHANGE_DESCRIPTION;c.messageStubParameters=a?[a]:void 0;break;case "announcement":case "not_announcement":c.messageStubType=Types_1.WAMessageStubType.GROUP_CHANGE_ANNOUNCE;c.messageStubParameters=["announcement"===b.tag?"on":"off"];break;case "locked":case "unlocked":c.messageStubType=
13
+ Types_1.WAMessageStubType.GROUP_CHANGE_RESTRICT;c.messageStubParameters=["locked"===b.tag?"on":"off"];break;case "invite":c.messageStubType=Types_1.WAMessageStubType.GROUP_CHANGE_INVITE_LINK;c.messageStubParameters=[b.attrs.code];break;case "member_add_mode":if(a=b.content)c.messageStubType=Types_1.WAMessageStubType.GROUP_MEMBER_ADD_MODE,c.messageStubParameters=[a.toString()];break;case "membership_approval_mode":if(a=(0,WABinary_1.getBinaryNodeChild)(b,"group_join"))c.messageStubType=Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_MODE,
14
+ c.messageStubParameters=[a.attrs.state];break;case "created_membership_requests":c.messageStubType=Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD;c.messageStubParameters=[g,"created",b.attrs.request_method];break;case "revoked_membership_requests":a=(0,WABinary_1.areJidsSameUser)(g,a),c.messageStubType=Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD,c.messageStubParameters=[g,a?"revoked":"rejected"]}},ia=async a=>{var b,c,d;const f={};
15
+ var [e]=(0,WABinary_1.getAllBinaryNodeChildren)(a),g=a.attrs.type,l=(0,WABinary_1.jidNormalizedUser)(a.attrs.from);switch(g){case "privacy_token":a=(0,WABinary_1.getBinaryNodeChildren)(e,"token");for(const {attrs:q,content:n}of a)a=q.jid,p.emit("chats.update",[{id:a,tcToken:n}]),m.debug({jid:a},"got privacy token update");break;case "w:gp2":ha(a.attrs.participant,e,f);break;case "mediaretry":a=(0,Utils_1.decodeMediaRetryNode)(a);p.emit("messages.media-update",[a]);break;case "encrypt":await fa(a);
16
+ break;case "devices":a=(0,WABinary_1.getBinaryNodeChildren)(e,"device");(0,WABinary_1.areJidsSameUser)(e.attrs.jid,k.creds.me.id)&&(a=a.map(q=>q.attrs.jid),m.info({deviceJids:a},"got my own devices"));break;case "server_sync":(a=(0,WABinary_1.getBinaryNodeChild)(a,"collection"))&&await Z([a.attrs.name],!1);break;case "picture":e=(0,WABinary_1.getBinaryNodeChild)(a,"set");var h=(0,WABinary_1.getBinaryNodeChild)(a,"delete");p.emit("contacts.update",[{id:(0,WABinary_1.jidNormalizedUser)(null===(b=null===
17
+ a||void 0===a?void 0:a.attrs)||void 0===b?void 0:b.from)||(null===(d=null===(c=e||h)||void 0===c?void 0:c.attrs)||void 0===d?void 0:d.hash)||"",imgUrl:e?"changed":"removed"}]);(0,WABinary_1.isJidGroup)(l)&&(a=e||h,f.messageStubType=Types_1.WAMessageStubType.GROUP_CHANGE_ICON,e&&(f.messageStubParameters=[e.attrs.id]),f.participant=null===a||void 0===a?void 0:a.attrs.author,f.key={...(f.key||{}),participant:null===e||void 0===e?void 0:e.attrs.author});break;case "account_sync":if("disappearing_mode"===
18
+ e.tag)a=+e.attrs.duration,b=+e.attrs.t,m.info({newDuration:a},"updated account disappearing mode"),p.emit("creds.update",{accountSettings:{...k.creds.accountSettings,defaultDisappearingMode:{ephemeralExpiration:a,ephemeralSettingTimestamp:b}}});else if("blocklist"===e.tag){a=(0,WABinary_1.getBinaryNodeChildren)(e,"item");for({attrs:h}of a)p.emit("blocklist.update",{blocklist:[h.jid],type:"block"===h.action?"add":"remove"})}break;case "link_code_companion_reg":c=(0,WABinary_1.getBinaryNodeChild)(a,
19
+ "link_code_companion_reg"),a=z((0,WABinary_1.getBinaryNodeChildBuffer)(c,"link_code_pairing_ref")),b=z((0,WABinary_1.getBinaryNodeChildBuffer)(c,"primary_identity_pub")),c=z((0,WABinary_1.getBinaryNodeChildBuffer)(c,"link_code_pairing_wrapped_primary_ephemeral_pub")),c=await W(c),c=Utils_1.Curve.sharedKey(k.creds.pairingEphemeralKeyPair.private,c),d=(0,crypto_1.randomBytes)(32),e=(0,crypto_1.randomBytes)(32),h=await (0,Utils_1.hkdf)(c,32,{salt:e,info:"link_code_pairing_key_bundle_encryption_key"}),
20
+ g=Buffer.concat([Buffer.from(k.creds.signedIdentityKey.public),b,d]),l=(0,crypto_1.randomBytes)(12),h=(0,Utils_1.aesEncryptGCM)(g,h,l,Buffer.alloc(0)),e=Buffer.concat([e,l,h]),b=Utils_1.Curve.sharedKey(k.creds.signedIdentityKey.private,b),b=Buffer.concat([c,b,d]),k.creds.advSecretKey=(await (0,Utils_1.hkdf)(b,32,{info:"adv_secret"})).toString("base64"),await M({tag:"iq",attrs:{to:WABinary_1.S_WHATSAPP_NET,type:"set",id:E.generateMessageTag(),xmlns:"md"},content:[{tag:"link_code_companion_reg",attrs:{jid:k.creds.me.id,
21
+ stage:"companion_finish"},content:[{tag:"link_code_pairing_wrapped_key_bundle",attrs:{},content:e},{tag:"companion_identity_public",attrs:{},content:k.creds.signedIdentityKey.public},{tag:"link_code_pairing_ref",attrs:{},content:a}]}]}),k.creds.registered=!0,p.emit("creds.update",k.creds)}if(Object.keys(f).length)return f},ja=(a,b)=>{a=`${a}:${b}`;b=(x.get(a)||0)+1;x.set(a,b)},ka=async(a,b,c)=>{var d;const f=await Promise.all(b.map(h=>X({...a,id:h}))),e=a.remoteJid,g=a.participant||e,l=!(null===(d=
22
+ (0,WABinary_1.jidDecode)(g))||void 0===d?0:d.device);await aa([g],!0);(0,WABinary_1.isJidGroup)(e)&&await k.keys.set({"sender-key-memory":{[e]:null}});m.debug({participant:g,sendToAll:l},"forced new session for retry recp");for(const [h,q]of f.entries())q?(ja(b[h],g),d={messageId:b[h]},l?d.useUserDevicesCache=!1:d.participant={jid:g,count:+c.attrs.count},await ba(a.remoteJid,q,d)):m.debug({jid:a.remoteJid,id:b[h]},"recv retry request, but message not available")},S=async a=>{var b,c;const {attrs:d,
23
+ content:f}=a,e=d.from.includes("lid"),g=(0,WABinary_1.areJidsSameUser)(d.participant||d.from,e?null===(b=k.creds.me)||void 0===b?void 0:b.lid:null===(c=k.creds.me)||void 0===c?void 0:c.id),l=!g||(0,WABinary_1.isJidGroup)(d.from)?d.from:d.recipient,h={remoteJid:l,id:"",fromMe:!d.recipient||("retry"===d.type||"sender"===d.type)&&g,participant:d.participant};if(D(l)&&"@s.whatsapp.net"!==l)m.debug({remoteJid:l},"ignoring receipt from jid"),await t(a);else{var q=[d.id];Array.isArray(f)&&(b=(0,WABinary_1.getBinaryNodeChildren)(f[0],
24
+ "item"),q.push(...b.map(n=>n.attrs.id)));try{await Promise.all([F.mutex(async()=>{const n=(0,Utils_1.getStatusFromReceiptType)(d.type);if("undefined"!==typeof n&&(n>=WAProto_1.proto.WebMessageInfo.Status.SERVER_ACK||!g))if((0,WABinary_1.isJidGroup)(l)||(0,WABinary_1.isJidStatusBroadcast)(l)){if(d.participant){const r=n===WAProto_1.proto.WebMessageInfo.Status.DELIVERY_ACK?"receiptTimestamp":"readTimestamp";p.emit("message-receipt.update",q.map(y=>({key:{...h,id:y},receipt:{userJid:(0,WABinary_1.jidNormalizedUser)(d.participant),
25
+ [r]:+d.t}})))}}else p.emit("messages.update",q.map(r=>({key:{...h,id:r},update:{status:n}})));if("retry"===d.type){h.participant=h.participant||d.from;const r=(0,WABinary_1.getBinaryNodeChild)(a,"retry");if((x.get(`${q[0]}:${h.participant}`)||0)<L)if(h.fromMe)try{m.debug({attrs:d,key:h},"recv retry request"),await ka(h,q,r)}catch(y){m.error({key:h,ids:q,trace:y.stack},"error in sending message again")}else m.info({attrs:d,key:h},"recv retry for not fromMe message");else m.info({attrs:d,key:h},"will not send message again, as sent too many times")}})])}finally{await t(a)}}},
26
+ T=async a=>{const b=a.attrs.from;if(D(b)&&"@s.whatsapp.net"!==b)m.debug({remoteJid:b,id:a.attrs.id},"ignored notification"),await t(a);else try{await Promise.all([F.mutex(async()=>{var c;const d=await ia(a);if(d){const f=(0,WABinary_1.areJidsSameUser)(a.attrs.participant||b,k.creds.me.id);d.key={remoteJid:b,fromMe:f,participant:a.attrs.participant,id:a.attrs.id,...(d.key||{})};null!==(c=d.participant)&&void 0!==c?c:d.participant=a.attrs.participant;d.messageTimestamp=+a.attrs.t;c=WAProto_1.proto.WebMessageInfo.fromObject(d);
27
+ await G(c,"append")}})])}finally{await t(a)}},U=async a=>{var b,c,d;if(D(a.attrs.from)&&"@s.whatsapp.net"!==a.attrs.from)m.debug({key:a.attrs.key},"ignored message"),await t(a);else{var f=(0,WABinary_1.getBinaryNodeChild)(a,"enc");if(f&&"msmsg"===f.attrs.type)m.debug({key:a.attrs.key},"ignored msmsg"),await t(a);else{if((0,WABinary_1.getBinaryNodeChild)(a,"unavailable")&&!f){await t(a);({key:f}=(0,Utils_1.decodeMessageNode)(a,k.creds.me.id,k.creds.me.lid||"").fullMessage);var e=await J(f);if("RESOLVED"===
28
+ e)return;m.debug("received unavailable message, acked and requested resend from phone")}else w.get(a.attrs.id)&&w.del(a.attrs.id);var {fullMessage:g,category:l,author:h,decrypt:q}=(0,Utils_1.decryptMessageNode)(a,k.creds.me.id,k.creds.me.lid||"",Y,m);e&&(null===(b=null===g||void 0===g?void 0:g.messageStubParameters)||void 0===b?void 0:b[0])===Utils_1.NO_MESSAGE_FOUND_ERROR_TEXT&&(g.messageStubParameters=[Utils_1.NO_MESSAGE_FOUND_ERROR_TEXT,e]);(null===(d=null===(c=g.message)||void 0===c?void 0:c.protocolMessage)||
29
+ void 0===d?void 0:d.type)===WAProto_1.proto.Message.ProtocolMessage.Type.SHARE_PHONE_NUMBER&&a.attrs.sender_pn&&p.emit("chats.phoneNumberShare",{lid:a.attrs.from,jid:a.attrs.sender_pn});try{await Promise.all([F.mutex(async()=>{var n;await q();if(g.messageStubType===WAProto_1.proto.WebMessageInfo.StubType.CIPHERTEXT){if((null===(n=null===g||void 0===g?void 0:g.messageStubParameters)||void 0===n?void 0:n[0])===Utils_1.MISSING_KEYS_ERROR_TEXT)return t(a,Utils_1.NACK_REASONS.ParsingError);da.mutex(async()=>
30
+ {if(v.isOpen){if(!(0,WABinary_1.getBinaryNodeChild)(a,"unavailable")){var r=(0,WABinary_1.getBinaryNodeChild)(a,"enc");await R(a,!r);K&&await (0,Utils_1.delay)(K)}}else m.debug({node:a},"connection closed, ignoring retry req")})}else{n=void 0;let r=g.key.participant;"peer"===l?n="peer_msg":g.key.fromMe?(n="sender",(0,WABinary_1.isJidUser)(g.key.remoteJid)&&(r=h)):I||(n="inactive");await O(g.key.remoteJid,r,[g.key.id],n);(0,Utils_1.getHistoryMsg)(g.message)&&(n=(0,WABinary_1.jidNormalizedUser)(g.key.remoteJid),
31
+ await O(n,void 0,[g.key.id],"hist_sync"))}(0,Utils_1.cleanMessage)(g,k.creds.me.id);await t(a);await G(g,a.attrs.offline?"append":"notify")})])}catch(n){m.error({error:n,node:a},"error in handling message")}}}},J=async a=>{var b;if(null===(b=k.creds.me)||void 0===b||!b.id)throw new boom_1.Boom("Not authenticated");if(w.get(null===a||void 0===a?void 0:a.id))m.debug({messageKey:a},"already requested resend");else{w.set(null===a||void 0===a?void 0:a.id,!0);await (0,Utils_1.delay)(5E3);if(!w.get(null===
32
+ a||void 0===a?void 0:a.id))return m.debug({messageKey:a},"message received while resend requested"),"RESOLVED";b={placeholderMessageResendRequest:[{messageKey:a}],peerDataOperationRequestType:WAProto_1.proto.Message.PeerDataOperationRequestType.PLACEHOLDER_MESSAGE_RESEND};setTimeout(()=>{w.get(null===a||void 0===a?void 0:a.id)&&(m.debug({messageKey:a},"PDO message without response after 15 seconds. Phone possibly offline"),w.del(null===a||void 0===a?void 0:a.id))},15E3);return P(b)}},V=async a=>{var {attrs:b}=
33
+ a,[c]=(0,WABinary_1.getAllBinaryNodeChildren)(a);const d=c.attrs["call-id"],f=c.attrs.from||c.attrs["call-creator"],e=(0,Utils_1.getCallStatusFromNode)(c);b={chatId:b.from,from:f,id:d,date:new Date(1E3*+b.t),offline:!!b.offline,status:e};"offer"===e&&(b.isVideo=!!(0,WABinary_1.getBinaryNodeChild)(c,"video"),b.isGroup="group"===c.attrs.type||!!c.attrs["group-jid"],b.groupJid=c.attrs["group-jid"],H.set(b.id,b));if(c=H.get(b.id))b.isVideo=c.isVideo,b.isGroup=c.isGroup;"reject"!==e&&"accept"!==e&&"timeout"!==
34
+ e&&"terminate"!==e||H.del(b.id);p.emit("call",[b]);await t(a)},la=async({attrs:a})=>{const b={remoteJid:a.from,fromMe:!0,id:a.id};a.error&&(m.warn({attrs:a},"received error in ack"),p.emit("messages.update",[{key:b,update:{status:Types_1.WAMessageStatus.ERROR,messageStubParameters:[a.error]}}]))},B=async(a,b,c)=>{p.buffer();await function(){return c(a,!1).catch(d=>A(d,b))}();p.flush()},C=(()=>{const a=new Map([["message",U],["call",V],["receipt",S],["notification",T]]),b=[];let c=!1;return{enqueue:(d,
35
+ f)=>{b.push({type:d,node:f});c||(c=!0,(async()=>{for(;b.length&&v.isOpen;){const {type:e,node:g}=b.shift(),l=a.get(e);l?await l(g):A(Error(`unknown offline node type: ${e}`),"processing offline node")}c=!1})().catch(e=>A(e,"processing offline nodes")))}}})();v.on("CB:message",a=>{a.attrs.offline?C.enqueue("message",a):B(a,"processing message",U)});v.on("CB:call",async a=>{a.attrs.offline?C.enqueue("call",a):B(a,"handling call",V)});v.on("CB:receipt",a=>{a.attrs.offline?C.enqueue("receipt",a):B(a,
36
+ "handling receipt",S)});v.on("CB:notification",async a=>{a.attrs.offline?C.enqueue("notification",a):B(a,"handling notification",T)});v.on("CB:ack,class:message",a=>{la(a).catch(b=>A(b,"handling bad ack"))});p.on("call",([a])=>{if("timeout"===a.status||"offer"===a.status&&a.isGroup){var b={key:{remoteJid:a.chatId,id:a.id,fromMe:!1},messageTimestamp:(0,Utils_1.unixTimestampSeconds)(a.date)};"timeout"===a.status?b.messageStubType=a.isGroup?a.isVideo?Types_1.WAMessageStubType.CALL_MISSED_GROUP_VIDEO:
37
+ Types_1.WAMessageStubType.CALL_MISSED_GROUP_VOICE:a.isVideo?Types_1.WAMessageStubType.CALL_MISSED_VIDEO:Types_1.WAMessageStubType.CALL_MISSED_VOICE:b.message={call:{callKey:Buffer.from(a.id)}};b=WAProto_1.proto.WebMessageInfo.fromObject(b);G(b,a.offline?"append":"notify")}});p.on("connection.update",({isOnline:a})=>{"undefined"!==typeof a&&(I=a,m.trace(`sendActiveReceipts set to "${I}"`))});return{...E,sendMessageAck:t,sendRetryRequest:R,rejectCall:async(a,b)=>{await M({tag:"call",attrs:{from:k.creds.me.id,
38
+ to:b},content:[{tag:"reject",attrs:{"call-id":a,"call-creator":b,count:"0"},content:void 0}]})},fetchMessageHistory:async(a,b,c)=>{var d;if(null===(d=k.creds.me)||void 0===d||!d.id)throw new boom_1.Boom("Not authenticated");return P({historySyncOnDemandRequest:{chatJid:b.remoteJid,oldestMsgFromMe:b.fromMe,oldestMsgId:b.id,oldestMsgTimestampMs:c,onDemandMsgCount:a},peerDataOperationRequestType:WAProto_1.proto.Message.PeerDataOperationRequestType.HISTORY_SYNC_ON_DEMAND})},requestPlaceholderResend:J}};
39
+ exports.makeMessagesRecvSocket=makeMessagesRecvSocket;