angularsockets 1.0.3 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.MD +170 -0
- package/README.md +163 -1813
- package/WAProto/GenerateStatics.sh +4 -0
- package/WAProto/WAProto.proto +4775 -0
- package/WAProto/index.d.ts +4798 -124
- package/WAProto/index.js +14270 -302
- package/WAProto/index.ts.ts +53473 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +4 -6
- package/lib/Defaults/index.js +4 -6
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.d.ts +14 -0
- package/lib/Signal/Group/group-session-builder.js +64 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.js +96 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/index.js +57 -0
- package/lib/Signal/Group/keyhelper.d.ts +10 -0
- package/lib/Signal/Group/keyhelper.js +55 -0
- package/lib/Signal/Group/queue-job.d.ts +1 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-chain-key.js +34 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-message.js +69 -0
- package/lib/Signal/Group/sender-key-name.d.ts +17 -0
- package/lib/Signal/Group/sender-key-name.js +51 -0
- package/lib/Signal/Group/sender-key-record.d.ts +30 -0
- package/lib/Signal/Group/sender-key-record.js +53 -0
- package/lib/Signal/Group/sender-key-state.d.ts +38 -0
- package/lib/Signal/Group/sender-key-state.js +99 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/{WASignalGroup/sender_message_key.js → lib/Signal/Group/sender-message-key.js} +6 -16
- package/lib/Signal/libsignal.js +51 -29
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +2 -3
- package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +1 -2
- package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +2 -1
- package/lib/Socket/Client/{web-socket-client.js → websocket.js} +54 -5
- package/lib/Socket/RHandler.d.ts +416 -0
- package/lib/Socket/RHandler.js +530 -0
- package/lib/Socket/business.d.ts +39 -37
- package/lib/Socket/chats.d.ts +36 -23
- package/lib/Socket/chats.js +74 -116
- package/lib/Socket/groups.d.ts +42 -33
- package/lib/Socket/groups.js +26 -9
- package/lib/Socket/index.d.ts +39 -39
- package/lib/Socket/index.js +2 -2
- package/lib/Socket/messages-recv.d.ts +37 -34
- package/lib/Socket/messages-recv.js +111 -29
- package/lib/Socket/messages-send.d.ts +50 -53
- package/lib/Socket/messages-send.js +213 -397
- package/lib/Socket/newsletter.d.ts +25 -21
- package/lib/Socket/newsletter.js +92 -25
- package/lib/Socket/socket.d.ts +10 -11
- package/lib/Socket/socket.js +34 -23
- package/lib/Socket/usync.d.ts +11 -12
- package/lib/Store/index.d.ts +1 -2
- package/lib/Store/index.js +1 -3
- package/lib/Store/make-in-memory-store.d.ts +22 -22
- package/lib/Store/make-in-memory-store.js +21 -13
- package/lib/Store/make-ordered-dictionary.d.ts +1 -1
- package/lib/Types/Auth.d.ts +0 -6
- package/lib/Types/Chat.d.ts +6 -4
- package/lib/Types/Contact.d.ts +5 -1
- package/lib/Types/Events.d.ts +27 -0
- package/lib/Types/GroupMetadata.d.ts +8 -0
- package/lib/Types/Label.d.ts +0 -11
- package/lib/Types/Message.d.ts +59 -90
- package/lib/Types/Message.js +0 -2
- package/lib/Types/Newsletter.d.ts +97 -86
- package/lib/Types/Newsletter.js +38 -32
- package/lib/Types/Socket.d.ts +10 -7
- package/lib/Types/index.d.ts +1 -3
- package/lib/Types/index.js +1 -1
- package/lib/Utils/audioToBuffer.js +29 -0
- package/lib/Utils/auth-utils.d.ts +3 -3
- package/lib/Utils/auth-utils.js +13 -41
- package/lib/Utils/business.d.ts +1 -1
- package/lib/Utils/chat-utils.d.ts +12 -12
- package/lib/Utils/chat-utils.js +4 -19
- package/lib/Utils/crypto.d.ts +15 -15
- package/lib/Utils/crypto.js +6 -12
- package/lib/Utils/decode-wa-message.d.ts +5 -6
- package/lib/Utils/decode-wa-message.js +28 -55
- package/lib/Utils/event-buffer.d.ts +2 -2
- package/lib/Utils/event-buffer.js +2 -1
- package/lib/Utils/generics.d.ts +12 -11
- package/lib/Utils/generics.js +64 -38
- package/lib/Utils/history.d.ts +2 -2
- package/lib/Utils/history.js +1 -1
- package/lib/Utils/index.d.ts +2 -0
- package/lib/Utils/index.js +3 -0
- package/lib/Utils/link-preview.d.ts +2 -2
- package/lib/Utils/link-preview.js +34 -1
- package/lib/Utils/logger.d.ts +10 -1
- package/lib/Utils/lt-hash.d.ts +2 -2
- package/lib/Utils/lt-hash.js +6 -6
- package/lib/Utils/messages-media.d.ts +40 -29
- package/lib/Utils/messages-media.js +276 -110
- package/lib/Utils/messages.d.ts +8 -10
- package/lib/Utils/messages.js +126 -317
- package/lib/Utils/noise-handler.d.ts +10 -11
- package/lib/Utils/noise-handler.js +3 -13
- package/lib/Utils/process-message.d.ts +3 -2
- package/lib/Utils/process-message.js +17 -5
- package/lib/Utils/signal.js +2 -8
- package/lib/Utils/streamToBuffer.js +15 -0
- package/lib/Utils/use-multi-file-auth-state.js +72 -242
- package/lib/Utils/validate-connection.d.ts +2 -3
- package/lib/Utils/validate-connection.js +19 -51
- package/lib/WABinary/constants.d.ts +4 -4
- package/lib/WABinary/constants.js +1276 -13
- package/lib/WABinary/decode.d.ts +2 -2
- package/lib/WABinary/decode.js +3 -2
- package/lib/WABinary/encode.js +5 -7
- package/lib/WABinary/generic-utils.d.ts +2 -2
- package/lib/WABinary/jid-utils.d.ts +9 -4
- package/lib/WABinary/jid-utils.js +26 -5
- package/lib/WABinary/jid-utils.js.bak +83 -0
- package/lib/WAM/encode.d.ts +1 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -3
- package/lib/WAUSync/USyncUser.d.ts +2 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +48 -4
- package/lib/index.js.bak +56 -0
- package/package.json +43 -35
- package/WASignalGroup/GroupProtocol.js +0 -1697
- package/WASignalGroup/ciphertext_message.js +0 -16
- package/WASignalGroup/group_cipher.js +0 -120
- package/WASignalGroup/group_session_builder.js +0 -46
- package/WASignalGroup/index.js +0 -5
- package/WASignalGroup/keyhelper.js +0 -21
- package/WASignalGroup/protobufs.js +0 -3
- package/WASignalGroup/queue_job.js +0 -69
- package/WASignalGroup/sender_chain_key.js +0 -50
- package/WASignalGroup/sender_key_distribution_message.js +0 -78
- package/WASignalGroup/sender_key_message.js +0 -92
- package/WASignalGroup/sender_key_name.js +0 -70
- package/WASignalGroup/sender_key_record.js +0 -56
- package/WASignalGroup/sender_key_state.js +0 -129
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/registration.d.ts +0 -264
- package/lib/Socket/registration.js +0 -166
- package/lib/Store/make-cache-manager-store.d.ts +0 -14
- package/lib/Store/make-cache-manager-store.js +0 -83
- package/lib/Utils/use-single-file-auth-state.d.ts +0 -12
- package/lib/Utils/use-single-file-auth-state.js +0 -75
- /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
package/lib/Socket/index.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { UserFacingSocketConfig } from '../Types';
|
|
2
2
|
declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
3
|
-
|
|
4
|
-
requestRegistrationCode: (registrationOptions?: import("./registration").RegistrationOptions) => Promise<import("./registration").ExistsResponse>;
|
|
5
|
-
logger: Logger;
|
|
3
|
+
logger: import("../Utils/logger").ILogger;
|
|
6
4
|
getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
|
|
7
5
|
getCatalog: ({ jid, limit, cursor }: import("../Types").GetCatalogOptions) => Promise<{
|
|
8
6
|
products: import("../Types").Product[];
|
|
9
|
-
nextPageCursor:
|
|
7
|
+
nextPageCursor: string | undefined;
|
|
10
8
|
}>;
|
|
11
9
|
getCollections: (jid?: string, limit?: number) => Promise<{
|
|
12
10
|
collections: import("../Types").CatalogCollection[];
|
|
@@ -18,35 +16,33 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
18
16
|
productUpdate: (productId: string, update: import("../Types").ProductUpdate) => Promise<import("../Types").Product>;
|
|
19
17
|
sendMessageAck: ({ tag, attrs, content }: import("..").BinaryNode, errorCode?: number) => Promise<void>;
|
|
20
18
|
sendRetryRequest: (node: import("..").BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
|
|
19
|
+
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
|
21
20
|
offerCall: (toJid: string, isVideo?: boolean) => Promise<{
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
callId: string;
|
|
22
|
+
toJid: string;
|
|
23
|
+
isVideo: boolean;
|
|
24
24
|
}>;
|
|
25
|
-
|
|
26
|
-
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number) => Promise<string>;
|
|
25
|
+
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
|
|
27
26
|
requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
|
|
28
|
-
getPrivacyTokens: (jids: string[]) => Promise<
|
|
27
|
+
getPrivacyTokens: (jids: string[]) => Promise<any>;
|
|
29
28
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
30
|
-
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache,
|
|
29
|
+
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
|
31
30
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
32
31
|
sendReceipts: (keys: import("../Types").WAMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
33
|
-
getButtonArgs: (message: import("../Types").WAProto.IMessage) => import("..").BinaryNode["attrs"];
|
|
34
32
|
readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
|
|
35
33
|
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
|
34
|
+
waUploadToServer: import("../Types").WAMediaUploadFunction;
|
|
35
|
+
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
36
|
+
[_: string]: string;
|
|
37
|
+
}>;
|
|
36
38
|
getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("..").JidWithDevice[]>;
|
|
37
|
-
sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
38
39
|
createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: import("..").BinaryNode["attrs"]) => Promise<{
|
|
39
40
|
nodes: import("..").BinaryNode[];
|
|
40
41
|
shouldIncludeDeviceIdentity: boolean;
|
|
41
42
|
}>;
|
|
42
|
-
|
|
43
|
-
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
44
|
-
[_: string]: string;
|
|
45
|
-
}>;
|
|
43
|
+
sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
46
44
|
updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
|
|
47
|
-
|
|
48
|
-
sendAlbumMessage: (jid: string, medias: import("../Types").Media[], options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo>;
|
|
49
|
-
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
|
|
45
|
+
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo>;
|
|
50
46
|
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
51
47
|
duration: string;
|
|
52
48
|
}>;
|
|
@@ -59,16 +55,16 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
59
55
|
newsletterFollow: (jid: string) => Promise<void>;
|
|
60
56
|
newsletterUnmute: (jid: string) => Promise<void>;
|
|
61
57
|
newsletterMute: (jid: string) => Promise<void>;
|
|
62
|
-
|
|
63
|
-
newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
|
|
58
|
+
newsletterCreate: (name: string, description?: string, picture?: import("../Types").WAMediaUpload) => Promise<import("../Types").NewsletterMetadata>;
|
|
64
59
|
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole) => Promise<import("../Types").NewsletterMetadata>;
|
|
65
60
|
newsletterAdminCount: (jid: string) => Promise<number>;
|
|
66
61
|
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
|
67
62
|
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
|
68
63
|
newsletterDelete: (jid: string) => Promise<void>;
|
|
69
|
-
newsletterReactMessage: (jid: string,
|
|
64
|
+
newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
|
|
70
65
|
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
71
66
|
newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
67
|
+
groupQuery: (jid: string, type: "get" | "set", content: import("..").BinaryNode[]) => Promise<any>;
|
|
72
68
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
73
69
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
74
70
|
groupLeave: (id: string) => Promise<void>;
|
|
@@ -89,7 +85,8 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
89
85
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
90
86
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
91
87
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
92
|
-
|
|
88
|
+
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
89
|
+
groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<any>;
|
|
93
90
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
94
91
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
95
92
|
groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
|
|
@@ -98,37 +95,39 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
98
95
|
groupFetchAllParticipating: () => Promise<{
|
|
99
96
|
[_: string]: import("../Types").GroupMetadata;
|
|
100
97
|
}>;
|
|
98
|
+
getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
|
|
101
99
|
processingMutex: {
|
|
102
100
|
mutex<T>(code: () => Promise<T> | T): Promise<T>;
|
|
103
101
|
};
|
|
104
|
-
upsertMessage: (msg: import("../Types").
|
|
102
|
+
upsertMessage: (msg: import("../Types").WAMessage, type: import("../Types").MessageUpsertType) => Promise<void>;
|
|
105
103
|
appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
|
|
106
104
|
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
|
|
107
105
|
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
|
|
108
106
|
profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
|
|
109
107
|
onWhatsApp: (...jids: string[]) => Promise<{
|
|
110
|
-
exists: boolean;
|
|
111
108
|
jid: string;
|
|
112
|
-
|
|
109
|
+
exists: unknown;
|
|
110
|
+
lid: unknown;
|
|
111
|
+
}[] | undefined>;
|
|
113
112
|
fetchBlocklist: () => Promise<string[]>;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
setAt: Date;
|
|
117
|
-
} | undefined>;
|
|
113
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
114
|
+
fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
118
115
|
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
119
116
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
120
117
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
121
118
|
updateProfileName: (name: string) => Promise<void>;
|
|
122
119
|
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
|
120
|
+
updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
|
|
121
|
+
updateMessagesPrivacy: (value: import("../Types").WAPrivacyMessagesValue) => Promise<void>;
|
|
123
122
|
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
124
123
|
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
|
125
124
|
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
126
125
|
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
127
126
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
128
|
-
updateGroupsAddPrivacy: (value: import("../Types").
|
|
127
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
129
128
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
130
129
|
getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
|
|
131
|
-
resyncAppState: (collections: readonly ("
|
|
130
|
+
resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
132
131
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
133
132
|
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
|
|
134
133
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
@@ -139,8 +138,9 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
139
138
|
id: string;
|
|
140
139
|
fromMe?: boolean;
|
|
141
140
|
}[], star: boolean) => Promise<void>;
|
|
141
|
+
executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
|
|
142
142
|
type: "md";
|
|
143
|
-
ws:
|
|
143
|
+
ws: import("./Client").WebSocketClient;
|
|
144
144
|
ev: import("../Types").BaileysEventEmitter & {
|
|
145
145
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
146
146
|
buffer(): void;
|
|
@@ -155,18 +155,18 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
155
155
|
signalRepository: import("../Types").SignalRepository;
|
|
156
156
|
user: import("../Types").Contact | undefined;
|
|
157
157
|
generateMessageTag: () => string;
|
|
158
|
-
query: (node: import("..").BinaryNode, timeoutMs?: number) => Promise<
|
|
159
|
-
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<
|
|
158
|
+
query: (node: import("..").BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
159
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
160
160
|
waitForSocketOpen: () => Promise<void>;
|
|
161
161
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
162
162
|
sendNode: (frame: import("..").BinaryNode) => Promise<void>;
|
|
163
163
|
logout: (msg?: string) => Promise<void>;
|
|
164
164
|
end: (error: Error | undefined) => void;
|
|
165
|
-
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
165
|
+
onUnexpectedError: (err: Error | import("@hapi/boom").Boom, msg: string) => void;
|
|
166
166
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
167
167
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
168
|
-
requestPairingCode: (phoneNumber:
|
|
169
|
-
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined
|
|
170
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<
|
|
168
|
+
requestPairingCode: (phoneNumber: any, pairKey?: string) => Promise<string>;
|
|
169
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
170
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
171
171
|
};
|
|
172
172
|
export default makeWASocket;
|
package/lib/Socket/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const Defaults_1 = require("../Defaults");
|
|
4
|
-
const
|
|
4
|
+
const business_1 = require("./business");
|
|
5
5
|
// export the last socket layer
|
|
6
|
-
const makeWASocket = (config) => ((0,
|
|
6
|
+
const makeWASocket = (config) => ((0, business_1.makeBusinessSocket)({
|
|
7
7
|
...Defaults_1.DEFAULT_CONNECTION_CONFIG,
|
|
8
8
|
...config
|
|
9
9
|
}));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Long = require('long');
|
|
1
2
|
import { Boom } from '@hapi/boom';
|
|
2
3
|
import { proto } from '../../WAProto';
|
|
3
4
|
import { MessageReceiptType, MessageRelayOptions, SocketConfig, WAMessageKey } from '../Types';
|
|
@@ -5,35 +6,33 @@ import { BinaryNode } from '../WABinary';
|
|
|
5
6
|
export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
6
7
|
sendMessageAck: ({ tag, attrs, content }: BinaryNode, errorCode?: number) => Promise<void>;
|
|
7
8
|
sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
|
|
9
|
+
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
|
8
10
|
offerCall: (toJid: string, isVideo?: boolean) => Promise<{
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
callId: string;
|
|
12
|
+
toJid: string;
|
|
13
|
+
isVideo: boolean;
|
|
11
14
|
}>;
|
|
12
|
-
|
|
13
|
-
fetchMessageHistory: (count: number, oldestMsgKey: WAMessageKey, oldestMsgTimestamp: number) => Promise<string>;
|
|
15
|
+
fetchMessageHistory: (count: number, oldestMsgKey: WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
|
|
14
16
|
requestPlaceholderResend: (messageKey: WAMessageKey) => Promise<string | undefined>;
|
|
15
|
-
getPrivacyTokens: (jids: string[]) => Promise<
|
|
17
|
+
getPrivacyTokens: (jids: string[]) => Promise<any>;
|
|
16
18
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
17
|
-
relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache,
|
|
19
|
+
relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
|
|
18
20
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => Promise<void>;
|
|
19
21
|
sendReceipts: (keys: WAMessageKey[], type: MessageReceiptType) => Promise<void>;
|
|
20
|
-
getButtonArgs: (message: proto.IMessage) => BinaryNode["attrs"];
|
|
21
22
|
readMessages: (keys: WAMessageKey[]) => Promise<void>;
|
|
22
23
|
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
|
24
|
+
waUploadToServer: import("../Types").WAMediaUploadFunction;
|
|
25
|
+
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
26
|
+
[_: string]: string;
|
|
27
|
+
}>;
|
|
23
28
|
getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
|
|
24
|
-
sendPeerDataOperationMessage: (pdoMessage: proto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
25
29
|
createParticipantNodes: (jids: string[], message: proto.IMessage, extraAttrs?: BinaryNode["attrs"]) => Promise<{
|
|
26
30
|
nodes: BinaryNode[];
|
|
27
31
|
shouldIncludeDeviceIdentity: boolean;
|
|
28
32
|
}>;
|
|
29
|
-
|
|
30
|
-
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
31
|
-
[_: string]: string;
|
|
32
|
-
}>;
|
|
33
|
+
sendPeerDataOperationMessage: (pdoMessage: proto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
33
34
|
updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
|
|
34
|
-
|
|
35
|
-
sendAlbumMessage: (jid: string, medias: import("../Types").Media[], options?: import("../Types").MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo>;
|
|
36
|
-
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo | undefined>;
|
|
35
|
+
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo>;
|
|
37
36
|
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
38
37
|
duration: string;
|
|
39
38
|
}>;
|
|
@@ -46,16 +45,16 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
46
45
|
newsletterFollow: (jid: string) => Promise<void>;
|
|
47
46
|
newsletterUnmute: (jid: string) => Promise<void>;
|
|
48
47
|
newsletterMute: (jid: string) => Promise<void>;
|
|
49
|
-
|
|
50
|
-
newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
|
|
48
|
+
newsletterCreate: (name: string, description?: string, picture?: import("../Types").WAMediaUpload) => Promise<import("../Types").NewsletterMetadata>;
|
|
51
49
|
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole) => Promise<import("../Types").NewsletterMetadata>;
|
|
52
50
|
newsletterAdminCount: (jid: string) => Promise<number>;
|
|
53
51
|
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
|
54
52
|
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
|
55
53
|
newsletterDelete: (jid: string) => Promise<void>;
|
|
56
|
-
newsletterReactMessage: (jid: string,
|
|
54
|
+
newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
|
|
57
55
|
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
58
56
|
newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
57
|
+
groupQuery: (jid: string, type: "get" | "set", content: BinaryNode[]) => Promise<any>;
|
|
59
58
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
60
59
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
61
60
|
groupLeave: (id: string) => Promise<void>;
|
|
@@ -76,7 +75,8 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
76
75
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
77
76
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
78
77
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
79
|
-
|
|
78
|
+
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
79
|
+
groupAcceptInviteV4: (key: string | WAMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<any>;
|
|
80
80
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
81
81
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
82
82
|
groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
|
|
@@ -85,37 +85,39 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
85
85
|
groupFetchAllParticipating: () => Promise<{
|
|
86
86
|
[_: string]: import("../Types").GroupMetadata;
|
|
87
87
|
}>;
|
|
88
|
+
getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
|
|
88
89
|
processingMutex: {
|
|
89
90
|
mutex<T>(code: () => Promise<T> | T): Promise<T>;
|
|
90
91
|
};
|
|
91
|
-
upsertMessage: (msg:
|
|
92
|
+
upsertMessage: (msg: import("../Types").WAMessage, type: import("../Types").MessageUpsertType) => Promise<void>;
|
|
92
93
|
appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
|
|
93
94
|
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
|
|
94
95
|
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
|
|
95
96
|
profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
|
|
96
97
|
onWhatsApp: (...jids: string[]) => Promise<{
|
|
97
|
-
exists: boolean;
|
|
98
98
|
jid: string;
|
|
99
|
-
|
|
99
|
+
exists: unknown;
|
|
100
|
+
lid: unknown;
|
|
101
|
+
}[] | undefined>;
|
|
100
102
|
fetchBlocklist: () => Promise<string[]>;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
setAt: Date;
|
|
104
|
-
} | undefined>;
|
|
103
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
104
|
+
fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
105
105
|
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
106
106
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
107
107
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
108
108
|
updateProfileName: (name: string) => Promise<void>;
|
|
109
109
|
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
|
110
|
+
updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
|
|
111
|
+
updateMessagesPrivacy: (value: import("../Types").WAPrivacyMessagesValue) => Promise<void>;
|
|
110
112
|
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
111
113
|
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
|
112
114
|
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
113
115
|
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
114
116
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
115
|
-
updateGroupsAddPrivacy: (value: import("../Types").
|
|
117
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
116
118
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
117
119
|
getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
|
|
118
|
-
resyncAppState: (collections: readonly ("
|
|
120
|
+
resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
119
121
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
120
122
|
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
|
|
121
123
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
@@ -126,8 +128,9 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
126
128
|
id: string;
|
|
127
129
|
fromMe?: boolean;
|
|
128
130
|
}[], star: boolean) => Promise<void>;
|
|
131
|
+
executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
|
|
129
132
|
type: "md";
|
|
130
|
-
ws:
|
|
133
|
+
ws: import("./Client").WebSocketClient;
|
|
131
134
|
ev: import("../Types").BaileysEventEmitter & {
|
|
132
135
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
133
136
|
buffer(): void;
|
|
@@ -142,8 +145,8 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
142
145
|
signalRepository: import("../Types").SignalRepository;
|
|
143
146
|
user: import("../Types").Contact | undefined;
|
|
144
147
|
generateMessageTag: () => string;
|
|
145
|
-
query: (node: BinaryNode, timeoutMs?: number) => Promise<
|
|
146
|
-
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<
|
|
148
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
149
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
147
150
|
waitForSocketOpen: () => Promise<void>;
|
|
148
151
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
149
152
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
@@ -152,7 +155,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
152
155
|
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
153
156
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
154
157
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
155
|
-
requestPairingCode: (phoneNumber:
|
|
156
|
-
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined
|
|
157
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<
|
|
158
|
+
requestPairingCode: (phoneNumber: any, pairKey?: string) => Promise<string>;
|
|
159
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
160
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
158
161
|
};
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.makeMessagesRecvSocket = void 0;
|
|
7
7
|
const boom_1 = require("@hapi/boom");
|
|
8
8
|
const crypto_1 = require("crypto");
|
|
9
|
-
const node_cache_1 = __importDefault(require("node-cache"));
|
|
9
|
+
const node_cache_1 = __importDefault(require("@cacheable/node-cache"));
|
|
10
10
|
const WAProto_1 = require("../../WAProto");
|
|
11
11
|
const Defaults_1 = require("../Defaults");
|
|
12
12
|
const Types_1 = require("../Types");
|
|
@@ -18,7 +18,7 @@ const messages_send_1 = require("./messages-send");
|
|
|
18
18
|
const makeMessagesRecvSocket = (config) => {
|
|
19
19
|
const { logger, retryRequestDelayMs, maxMsgRetryCount, getMessage, shouldIgnoreJid } = config;
|
|
20
20
|
const sock = (0, messages_send_1.makeMessagesSocket)(config);
|
|
21
|
-
const { ev, authState, ws, processingMutex, signalRepository, query, upsertMessage, resyncAppState, onUnexpectedError, assertSessions, sendNode, relayMessage, sendReceipt, uploadPreKeys, getUSyncDevices, sendPeerDataOperationMessage,
|
|
21
|
+
const { ev, authState, ws, processingMutex, signalRepository, query, upsertMessage, resyncAppState, groupMetadata, onUnexpectedError, assertSessions, sendNode, relayMessage, sendReceipt, uploadPreKeys, createParticipantNodes, getUSyncDevices, sendPeerDataOperationMessage, } = sock;
|
|
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({
|
|
@@ -69,8 +69,14 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
69
69
|
if (isVideo) {
|
|
70
70
|
offerContent.push({
|
|
71
71
|
tag: 'video',
|
|
72
|
-
attrs: {
|
|
73
|
-
|
|
72
|
+
attrs: {
|
|
73
|
+
orientation: '0',
|
|
74
|
+
'screen_width': '1920',
|
|
75
|
+
'screen_height': '1080',
|
|
76
|
+
'device_orientation': '0',
|
|
77
|
+
enc: 'vp8',
|
|
78
|
+
dec: 'vp8',
|
|
79
|
+
}
|
|
74
80
|
});
|
|
75
81
|
}
|
|
76
82
|
offerContent.push({ tag: 'net', attrs: { medium: '3' }, content: undefined });
|
|
@@ -81,9 +87,9 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
81
87
|
await assertSessions(devices, true);
|
|
82
88
|
const { nodes: destinations, shouldIncludeDeviceIdentity } = await createParticipantNodes(devices, {
|
|
83
89
|
call: {
|
|
84
|
-
callKey:
|
|
90
|
+
callKey: encKey
|
|
85
91
|
}
|
|
86
|
-
}
|
|
92
|
+
});
|
|
87
93
|
offerContent.push({ tag: 'destination', attrs: {}, content: destinations });
|
|
88
94
|
if (shouldIncludeDeviceIdentity) {
|
|
89
95
|
offerContent.push({
|
|
@@ -95,7 +101,6 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
95
101
|
const stanza = ({
|
|
96
102
|
tag: 'call',
|
|
97
103
|
attrs: {
|
|
98
|
-
id: await config.generateMessageIDV2() ?? (0, Utils_1.generateMessageIDV2)(),
|
|
99
104
|
to: toJid,
|
|
100
105
|
},
|
|
101
106
|
content: [{
|
|
@@ -109,8 +114,9 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
109
114
|
});
|
|
110
115
|
await query(stanza);
|
|
111
116
|
return {
|
|
112
|
-
|
|
113
|
-
|
|
117
|
+
callId,
|
|
118
|
+
toJid,
|
|
119
|
+
isVideo,
|
|
114
120
|
};
|
|
115
121
|
};
|
|
116
122
|
const rejectCall = async (callId, callFrom) => {
|
|
@@ -324,10 +330,57 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
324
330
|
msg.messageStubType = Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD;
|
|
325
331
|
msg.messageStubParameters = [participantJid, isDenied ? 'revoked' : 'rejected'];
|
|
326
332
|
break;
|
|
333
|
+
break;
|
|
334
|
+
default:
|
|
335
|
+
// console.log("BAILEYS-DEBUG:", JSON.stringify({ ...child, content: Buffer.isBuffer(child.content) ? child.content.toString() : child.content, participant }, null, 2))
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
const handleNewsletterNotification = (id, node) => {
|
|
339
|
+
const messages = (0, WABinary_1.getBinaryNodeChild)(node, 'messages');
|
|
340
|
+
const message = (0, WABinary_1.getBinaryNodeChild)(messages, 'message');
|
|
341
|
+
const serverId = message.attrs.server_id;
|
|
342
|
+
const reactionsList = (0, WABinary_1.getBinaryNodeChild)(message, 'reactions');
|
|
343
|
+
const viewsList = (0, WABinary_1.getBinaryNodeChildren)(message, 'views_count');
|
|
344
|
+
if (reactionsList) {
|
|
345
|
+
const reactions = (0, WABinary_1.getBinaryNodeChildren)(reactionsList, 'reaction');
|
|
346
|
+
if (reactions.length === 0) {
|
|
347
|
+
ev.emit('newsletter.reaction', { id, 'server_id': serverId, reaction: { removed: true } });
|
|
348
|
+
}
|
|
349
|
+
reactions.forEach(item => {
|
|
350
|
+
var _a, _b;
|
|
351
|
+
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) } });
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
if (viewsList.length) {
|
|
355
|
+
viewsList.forEach(item => {
|
|
356
|
+
ev.emit('newsletter.view', { id, 'server_id': serverId, count: +item.attrs.count });
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
const handleMexNewsletterNotification = (id, node) => {
|
|
361
|
+
var _a;
|
|
362
|
+
const operation = node === null || node === void 0 ? void 0 : node.attrs.op_name;
|
|
363
|
+
const content = JSON.parse((_a = node === null || node === void 0 ? void 0 : node.content) === null || _a === void 0 ? void 0 : _a.toString());
|
|
364
|
+
let contentPath;
|
|
365
|
+
if (operation === Types_1.MexOperations.PROMOTE || operation === Types_1.MexOperations.DEMOTE) {
|
|
366
|
+
let action;
|
|
367
|
+
if (operation === Types_1.MexOperations.PROMOTE) {
|
|
368
|
+
action = 'promote';
|
|
369
|
+
contentPath = content.data[Types_1.XWAPaths.PROMOTE];
|
|
370
|
+
}
|
|
371
|
+
if (operation === Types_1.MexOperations.DEMOTE) {
|
|
372
|
+
action = 'demote';
|
|
373
|
+
contentPath = content.data[Types_1.XWAPaths.DEMOTE];
|
|
374
|
+
}
|
|
375
|
+
ev.emit('newsletter-participants.update', { id, author: contentPath.actor.pn, user: contentPath.user.pn, new_role: contentPath.user_new_role, action });
|
|
376
|
+
}
|
|
377
|
+
if (operation === Types_1.MexOperations.UPDATE) {
|
|
378
|
+
contentPath = content.data[Types_1.XWAPaths.METADATA_UPDATE];
|
|
379
|
+
ev.emit('newsletter-settings.update', { id, update: contentPath.thread_metadata.settings });
|
|
327
380
|
}
|
|
328
381
|
};
|
|
329
382
|
const processNotification = async (node) => {
|
|
330
|
-
var _a, _b
|
|
383
|
+
var _a, _b;
|
|
331
384
|
const result = {};
|
|
332
385
|
const [child] = (0, WABinary_1.getAllBinaryNodeChildren)(node);
|
|
333
386
|
const nodeType = node.attrs.type;
|
|
@@ -346,6 +399,12 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
346
399
|
logger.debug({ jid }, 'got privacy token update');
|
|
347
400
|
}
|
|
348
401
|
break;
|
|
402
|
+
case 'newsletter':
|
|
403
|
+
handleNewsletterNotification(node.attrs.from, child);
|
|
404
|
+
break;
|
|
405
|
+
case 'mex':
|
|
406
|
+
handleMexNewsletterNotification(node.attrs.from, child);
|
|
407
|
+
break;
|
|
349
408
|
case 'w:gp2':
|
|
350
409
|
handleGroupNotification(node.attrs.participant, child, result);
|
|
351
410
|
break;
|
|
@@ -374,7 +433,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
374
433
|
const setPicture = (0, WABinary_1.getBinaryNodeChild)(node, 'set');
|
|
375
434
|
const delPicture = (0, WABinary_1.getBinaryNodeChild)(node, 'delete');
|
|
376
435
|
ev.emit('contacts.update', [{
|
|
377
|
-
id:
|
|
436
|
+
id: from || ((_b = (_a = (setPicture || delPicture)) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b.hash) || '',
|
|
378
437
|
imgUrl: setPicture ? 'changed' : 'removed'
|
|
379
438
|
}]);
|
|
380
439
|
if ((0, WABinary_1.isJidGroup)(from)) {
|
|
@@ -502,6 +561,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
502
561
|
};
|
|
503
562
|
const sendMessagesAgain = async (key, ids, retryNode) => {
|
|
504
563
|
var _a;
|
|
564
|
+
// todo: implement a cache to store the last 256 sent messages (copy whatsmeow)
|
|
505
565
|
const msgs = await Promise.all(ids.map(id => getMessage({ ...key, id })));
|
|
506
566
|
const remoteJid = key.remoteJid;
|
|
507
567
|
const participant = key.participant || remoteJid;
|
|
@@ -540,7 +600,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
540
600
|
const isLid = attrs.from.includes('lid');
|
|
541
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);
|
|
542
602
|
const remoteJid = !isNodeFromMe || (0, WABinary_1.isJidGroup)(attrs.from) ? attrs.from : attrs.recipient;
|
|
543
|
-
const fromMe = !attrs.recipient || (attrs.type === 'retry' && isNodeFromMe);
|
|
603
|
+
const fromMe = !attrs.recipient || ((attrs.type === 'retry' || attrs.type === 'sender') && isNodeFromMe);
|
|
544
604
|
const key = {
|
|
545
605
|
remoteJid,
|
|
546
606
|
id: '',
|
|
@@ -565,7 +625,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
565
625
|
(
|
|
566
626
|
// basically, we only want to know when a message from us has been delivered to/read by the other person
|
|
567
627
|
// or another device of ours has read some messages
|
|
568
|
-
status >= WAProto_1.proto.WebMessageInfo.Status.
|
|
628
|
+
status >= WAProto_1.proto.WebMessageInfo.Status.SERVER_ACK ||
|
|
569
629
|
!isNodeFromMe)) {
|
|
570
630
|
if ((0, WABinary_1.isJidGroup)(remoteJid) || (0, WABinary_1.isJidStatusBroadcast)(remoteJid)) {
|
|
571
631
|
if (attrs.participant) {
|
|
@@ -687,7 +747,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
687
747
|
try {
|
|
688
748
|
await Promise.all([
|
|
689
749
|
processingMutex.mutex(async () => {
|
|
690
|
-
var _a;
|
|
750
|
+
var _a, _b, _c, _d, _e, _f;
|
|
691
751
|
await decrypt();
|
|
692
752
|
// message failed to decrypt
|
|
693
753
|
if (msg.messageStubType === WAProto_1.proto.WebMessageInfo.StubType.CIPHERTEXT) {
|
|
@@ -713,6 +773,20 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
713
773
|
else {
|
|
714
774
|
// no type in the receipt => message delivered
|
|
715
775
|
let type = undefined;
|
|
776
|
+
if ((_b = msg.key.participant) === null || _b === void 0 ? void 0 : _b.endsWith('@lid')) {
|
|
777
|
+
msg.key.participant = node.attrs.participant_pn || authState.creds.me.id;
|
|
778
|
+
}
|
|
779
|
+
if ((0, WABinary_1.isJidGroup)(msg.key.remoteJid) && ((_f = (_e = (_d = (_c = msg.message) === null || _c === void 0 ? void 0 : _c.extendedTextMessage) === null || _d === void 0 ? void 0 : _d.contextInfo) === null || _e === void 0 ? void 0 : _e.participant) === null || _f === void 0 ? void 0 : _f.endsWith('@lid'))) {
|
|
780
|
+
if (msg.message.extendedTextMessage.contextInfo) {
|
|
781
|
+
const metadata = await groupMetadata(msg.key.remoteJid);
|
|
782
|
+
const sender = msg.message.extendedTextMessage.contextInfo.participant;
|
|
783
|
+
const found = metadata.participants.find(p => p.id === sender);
|
|
784
|
+
msg.message.extendedTextMessage.contextInfo.participant = (found === null || found === void 0 ? void 0 : found.jid) || sender;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
if (!(0, WABinary_1.isJidGroup)(msg.key.remoteJid) && (0, WABinary_1.isLidUser)(msg.key.remoteJid)) {
|
|
788
|
+
msg.key.remoteJid = node.attrs.sender_pn || node.attrs.peer_recipient_pn;
|
|
789
|
+
}
|
|
716
790
|
let participant = msg.key.participant;
|
|
717
791
|
if (category === 'peer') { // special peer message
|
|
718
792
|
type = 'peer_msg';
|
|
@@ -827,20 +901,28 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
827
901
|
await sendMessageAck(node);
|
|
828
902
|
};
|
|
829
903
|
const handleBadAck = async ({ attrs }) => {
|
|
830
|
-
const key = { remoteJid: attrs.from, fromMe: true, id: attrs.id };
|
|
831
|
-
//
|
|
832
|
-
//
|
|
833
|
-
//
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
904
|
+
const key = { remoteJid: attrs.from, fromMe: true, id: attrs.id, 'server_id': attrs === null || attrs === void 0 ? void 0 : attrs.server_id };
|
|
905
|
+
// current hypothesis is that if pash is sent in the ack
|
|
906
|
+
// it means -- the message hasn't reached all devices yet
|
|
907
|
+
// we'll retry sending the message here
|
|
908
|
+
if (attrs.phash) {
|
|
909
|
+
logger.info({ attrs }, 'received phash in ack, resending message...');
|
|
910
|
+
const cacheKey = `${key.remoteJid}:${key.id}`;
|
|
911
|
+
if ((msgRetryCache.get(cacheKey) || 0) >= maxMsgRetryCount) {
|
|
912
|
+
logger.warn({ attrs }, 'reached max retry count, not sending message again');
|
|
913
|
+
msgRetryCache.del(cacheKey);
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
const retryCount = msgRetryCache.get(cacheKey) || 0;
|
|
917
|
+
const msg = await getMessage(key);
|
|
918
|
+
if (msg) {
|
|
919
|
+
await relayMessage(key.remoteJid, msg, { messageId: key.id, useUserDevicesCache: false });
|
|
920
|
+
msgRetryCache.set(cacheKey, retryCount + 1);
|
|
921
|
+
}
|
|
922
|
+
else {
|
|
923
|
+
logger.warn({ attrs }, 'could not send message again, as it was not found');
|
|
924
|
+
}
|
|
925
|
+
}
|
|
844
926
|
// error in acknowledgement,
|
|
845
927
|
// device could not display the message
|
|
846
928
|
if (attrs.error) {
|
|
@@ -963,8 +1045,8 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
963
1045
|
...sock,
|
|
964
1046
|
sendMessageAck,
|
|
965
1047
|
sendRetryRequest,
|
|
966
|
-
offerCall,
|
|
967
1048
|
rejectCall,
|
|
1049
|
+
offerCall,
|
|
968
1050
|
fetchMessageHistory,
|
|
969
1051
|
requestPlaceholderResend,
|
|
970
1052
|
};
|