angularsockets 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1880 -36
- package/WAProto/index.d.ts +50383 -0
- package/WAProto/index.js +37203 -11791
- package/WASignalGroup/GroupProtocol.js +1697 -0
- package/WASignalGroup/ciphertext_message.js +16 -0
- package/WASignalGroup/group_cipher.js +120 -0
- package/WASignalGroup/group_session_builder.js +46 -0
- package/WASignalGroup/index.js +5 -0
- package/WASignalGroup/keyhelper.js +21 -0
- package/WASignalGroup/protobufs.js +3 -0
- package/WASignalGroup/queue_job.js +69 -0
- package/WASignalGroup/sender_chain_key.js +50 -0
- package/WASignalGroup/sender_key_distribution_message.js +78 -0
- package/WASignalGroup/sender_key_message.js +92 -0
- package/WASignalGroup/sender_key_name.js +70 -0
- package/WASignalGroup/sender_key_record.js +56 -0
- package/WASignalGroup/sender_key_state.js +129 -0
- package/{lib/Signal/Group/sender-message-key.js → WASignalGroup/sender_message_key.js} +16 -6
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.js +79 -101
- package/lib/Signal/libsignal.js +29 -51
- package/lib/Socket/Client/web-socket-client.js +0 -2
- package/lib/Socket/business.d.ts +42 -43
- package/lib/Socket/chats.d.ts +9 -8
- package/lib/Socket/chats.js +107 -21
- package/lib/Socket/groups.d.ts +7 -7
- package/lib/Socket/groups.js +24 -25
- package/lib/Socket/index.d.ts +51 -52
- package/lib/Socket/messages-recv.d.ts +34 -37
- package/lib/Socket/messages-recv.js +37 -175
- package/lib/Socket/messages-send.d.ts +16 -10
- package/lib/Socket/messages-send.js +540 -346
- package/lib/Socket/newsletter.d.ts +26 -28
- package/lib/Socket/newsletter.js +4 -4
- package/lib/Socket/registration.d.ts +49 -52
- package/lib/Socket/registration.js +7 -7
- package/lib/Socket/socket.d.ts +1 -0
- package/lib/Socket/socket.js +36 -23
- package/lib/Socket/usync.d.ts +11 -10
- package/lib/Store/make-cache-manager-store.d.ts +2 -1
- package/lib/Store/make-in-memory-store.d.ts +2 -2
- package/lib/Store/make-in-memory-store.js +5 -1
- package/lib/Store/make-ordered-dictionary.js +2 -2
- package/lib/Types/Auth.d.ts +0 -1
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +12 -7
- package/lib/Types/Events.d.ts +17 -2
- package/lib/Types/GroupMetadata.d.ts +3 -2
- package/lib/Types/Label.d.ts +11 -0
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Message.d.ts +170 -10
- package/lib/Types/Newsletter.js +3 -3
- package/lib/Types/Socket.d.ts +7 -2
- package/lib/Types/index.d.ts +9 -0
- package/lib/Types/index.js +1 -1
- package/lib/Utils/auth-utils.js +35 -14
- package/lib/Utils/business.d.ts +1 -1
- package/lib/Utils/business.js +2 -2
- package/lib/Utils/chat-utils.d.ts +11 -12
- package/lib/Utils/chat-utils.js +52 -36
- package/lib/Utils/crypto.d.ts +15 -16
- package/lib/Utils/crypto.js +74 -26
- package/lib/Utils/decode-wa-message.d.ts +17 -0
- package/lib/Utils/decode-wa-message.js +53 -17
- package/lib/Utils/event-buffer.js +10 -7
- package/lib/Utils/generics.d.ts +13 -17
- package/lib/Utils/generics.js +26 -15
- package/lib/Utils/history.d.ts +6 -2
- package/lib/Utils/history.js +4 -6
- package/lib/Utils/logger.d.ts +1 -3
- package/lib/Utils/lt-hash.js +12 -12
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/messages-media.d.ts +25 -28
- package/lib/Utils/messages-media.js +47 -57
- package/lib/Utils/messages.js +461 -44
- package/lib/Utils/noise-handler.d.ts +4 -5
- package/lib/Utils/noise-handler.js +19 -14
- package/lib/Utils/process-message.d.ts +5 -5
- package/lib/Utils/process-message.js +75 -23
- package/lib/Utils/signal.d.ts +2 -1
- package/lib/Utils/signal.js +43 -35
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -1
- package/lib/Utils/use-multi-file-auth-state.js +251 -36
- package/lib/Utils/use-single-file-auth-state.d.ts +12 -0
- package/lib/Utils/use-single-file-auth-state.js +75 -0
- package/lib/Utils/validate-connection.d.ts +1 -1
- package/lib/Utils/validate-connection.js +1 -1
- package/lib/WABinary/decode.d.ts +1 -2
- package/lib/WABinary/decode.js +23 -11
- package/lib/WABinary/encode.d.ts +1 -2
- package/lib/WABinary/encode.js +46 -22
- package/lib/WABinary/generic-utils.d.ts +2 -4
- package/lib/WABinary/generic-utils.js +2 -10
- package/lib/WABinary/jid-utils.d.ts +1 -1
- package/lib/WAM/BinaryInfo.d.ts +2 -11
- package/lib/WAM/encode.d.ts +1 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -3
- package/lib/WAUSync/USyncUser.d.ts +0 -2
- package/lib/index.js +0 -6
- package/package.json +96 -104
- package/engine-requirements.js +0 -10
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
- package/lib/Signal/Group/ciphertext-message.js +0 -15
- package/lib/Signal/Group/group-session-builder.d.ts +0 -14
- package/lib/Signal/Group/group-session-builder.js +0 -64
- package/lib/Signal/Group/group_cipher.d.ts +0 -17
- package/lib/Signal/Group/group_cipher.js +0 -96
- package/lib/Signal/Group/index.d.ts +0 -11
- package/lib/Signal/Group/index.js +0 -57
- package/lib/Signal/Group/keyhelper.d.ts +0 -10
- package/lib/Signal/Group/keyhelper.js +0 -55
- package/lib/Signal/Group/queue-job.d.ts +0 -1
- package/lib/Signal/Group/queue-job.js +0 -57
- package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
- package/lib/Signal/Group/sender-chain-key.js +0 -34
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
- package/lib/Signal/Group/sender-key-distribution-message.js +0 -66
- package/lib/Signal/Group/sender-key-message.d.ts +0 -18
- package/lib/Signal/Group/sender-key-message.js +0 -69
- package/lib/Signal/Group/sender-key-name.d.ts +0 -17
- package/lib/Signal/Group/sender-key-name.js +0 -51
- package/lib/Signal/Group/sender-key-record.d.ts +0 -30
- package/lib/Signal/Group/sender-key-record.js +0 -53
- package/lib/Signal/Group/sender-key-state.d.ts +0 -38
- package/lib/Signal/Group/sender-key-state.js +0 -99
- package/lib/Signal/Group/sender-message-key.d.ts +0 -11
- package/lib/Socket/dugong.d.ts +0 -175
- package/lib/Socket/dugong.js +0 -342
- package/lib/index.d.ts +0 -12
package/lib/Socket/business.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { GetCatalogOptions, ProductCreate, ProductUpdate, SocketConfig } from '../Types';
|
|
3
2
|
import { BinaryNode } from '../WABinary';
|
|
4
3
|
export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
5
|
-
logger:
|
|
4
|
+
logger: Logger;
|
|
6
5
|
getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
|
|
7
6
|
getCatalog: ({ jid, limit, cursor }: GetCatalogOptions) => Promise<{
|
|
8
7
|
products: import("../Types").Product[];
|
|
9
|
-
nextPageCursor:
|
|
8
|
+
nextPageCursor: any;
|
|
10
9
|
}>;
|
|
11
10
|
getCollections: (jid?: string, limit?: number) => Promise<{
|
|
12
11
|
collections: import("../Types").CatalogCollection[];
|
|
@@ -16,27 +15,26 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
16
15
|
deleted: number;
|
|
17
16
|
}>;
|
|
18
17
|
productUpdate: (productId: string, update: ProductUpdate) => Promise<import("../Types").Product>;
|
|
19
|
-
sendMessageAck: ({ tag, attrs, content }: BinaryNode) => Promise<void>;
|
|
18
|
+
sendMessageAck: ({ tag, attrs, content }: BinaryNode, errorCode?: number) => Promise<void>;
|
|
20
19
|
sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
|
|
21
20
|
offerCall: (toJid: string, isVideo?: boolean) => Promise<{
|
|
22
|
-
id:
|
|
21
|
+
id: any;
|
|
23
22
|
to: string;
|
|
24
23
|
}>;
|
|
25
24
|
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
|
25
|
+
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number) => Promise<string>;
|
|
26
|
+
requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
|
|
26
27
|
getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
|
|
27
28
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
28
29
|
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
|
29
30
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
30
|
-
sendReceipts: (keys: import("../Types").
|
|
31
|
-
getButtonArgs: (message: import("../Types").WAProto.IMessage) =>
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;
|
|
31
|
+
sendReceipts: (keys: import("../Types").WAMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
32
|
+
getButtonArgs: (message: import("../Types").WAProto.IMessage) => BinaryNode["attrs"];
|
|
33
|
+
readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
|
|
35
34
|
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
|
36
35
|
getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
} | undefined) => Promise<{
|
|
36
|
+
sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
37
|
+
createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: BinaryNode["attrs"]) => Promise<{
|
|
40
38
|
nodes: BinaryNode[];
|
|
41
39
|
shouldIncludeDeviceIdentity: boolean;
|
|
42
40
|
}>;
|
|
@@ -45,12 +43,14 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
45
43
|
[_: string]: string;
|
|
46
44
|
}>;
|
|
47
45
|
updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
|
|
46
|
+
sendStatusMentions: (content: import("../Types").AnyMessageContent, jids?: string[]) => Promise<import("../Types").WAProto.WebMessageInfo>;
|
|
47
|
+
sendAlbumMessage: (jid: string, medias: import("../Types").Media[], options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo>;
|
|
48
48
|
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
|
|
49
49
|
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
50
50
|
duration: string;
|
|
51
51
|
}>;
|
|
52
52
|
newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
|
|
53
|
-
newsletterUpdateDescription: (jid: string, description?: string
|
|
53
|
+
newsletterUpdateDescription: (jid: string, description?: string) => Promise<void>;
|
|
54
54
|
newsletterUpdateName: (jid: string, name: string) => Promise<void>;
|
|
55
55
|
newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
56
56
|
newsletterRemovePicture: (jid: string) => Promise<void>;
|
|
@@ -58,16 +58,16 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
58
58
|
newsletterFollow: (jid: string) => Promise<void>;
|
|
59
59
|
newsletterUnmute: (jid: string) => Promise<void>;
|
|
60
60
|
newsletterMute: (jid: string) => Promise<void>;
|
|
61
|
-
newsletterAction: (jid: string, type: "
|
|
62
|
-
newsletterCreate: (name: string, description: string
|
|
63
|
-
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole
|
|
61
|
+
newsletterAction: (jid: string, type: "follow" | "unfollow" | "mute" | "unmute") => Promise<void>;
|
|
62
|
+
newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
|
|
63
|
+
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole) => Promise<import("../Types").NewsletterMetadata>;
|
|
64
64
|
newsletterAdminCount: (jid: string) => Promise<number>;
|
|
65
65
|
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
|
66
66
|
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
|
67
67
|
newsletterDelete: (jid: string) => Promise<void>;
|
|
68
|
-
newsletterReactMessage: (jid: string, serverId: string, code?: string
|
|
69
|
-
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number
|
|
70
|
-
newsletterFetchUpdates: (jid: string, count: number, after?: number
|
|
68
|
+
newsletterReactMessage: (jid: string, serverId: string, code?: string) => Promise<void>;
|
|
69
|
+
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
70
|
+
newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
71
71
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
72
72
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
73
73
|
groupLeave: (id: string) => Promise<void>;
|
|
@@ -75,7 +75,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
75
75
|
groupRequestParticipantsList: (jid: string) => Promise<{
|
|
76
76
|
[key: string]: string;
|
|
77
77
|
}[]>;
|
|
78
|
-
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "
|
|
78
|
+
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
|
|
79
79
|
status: string;
|
|
80
80
|
jid: string;
|
|
81
81
|
}[]>;
|
|
@@ -84,32 +84,31 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
84
84
|
jid: string;
|
|
85
85
|
content: BinaryNode;
|
|
86
86
|
}[]>;
|
|
87
|
-
groupUpdateDescription: (jid: string, description?: string
|
|
87
|
+
groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
|
|
88
88
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
89
89
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
90
90
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
91
91
|
groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
|
|
92
92
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
93
93
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
94
|
-
groupSettingUpdate: (jid: string, setting: "announcement" | "
|
|
95
|
-
groupMemberAddMode: (jid: string, mode: "
|
|
94
|
+
groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
|
|
95
|
+
groupMemberAddMode: (jid: string, mode: "admin_add" | "all_member_add") => Promise<void>;
|
|
96
96
|
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
|
|
97
97
|
groupFetchAllParticipating: () => Promise<{
|
|
98
98
|
[_: string]: import("../Types").GroupMetadata;
|
|
99
99
|
}>;
|
|
100
100
|
processingMutex: {
|
|
101
|
-
mutex<T>(code: () => T |
|
|
101
|
+
mutex<T>(code: () => Promise<T> | T): Promise<T>;
|
|
102
102
|
};
|
|
103
103
|
upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
|
|
104
104
|
appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
|
|
105
|
-
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string
|
|
106
|
-
presenceSubscribe: (toJid: string, tcToken?: Buffer
|
|
107
|
-
profilePictureUrl: (jid: string, type?: "
|
|
105
|
+
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
|
|
106
|
+
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
|
|
107
|
+
profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
|
|
108
108
|
onWhatsApp: (...jids: string[]) => Promise<{
|
|
109
|
+
exists: boolean;
|
|
109
110
|
jid: string;
|
|
110
|
-
|
|
111
|
-
lid: unknown;
|
|
112
|
-
}[] | undefined>;
|
|
111
|
+
}[]>;
|
|
113
112
|
fetchBlocklist: () => Promise<string[]>;
|
|
114
113
|
fetchStatus: (jid: string) => Promise<{
|
|
115
114
|
status: string | undefined;
|
|
@@ -127,25 +126,25 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
127
126
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
128
127
|
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
129
128
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
130
|
-
getBusinessProfile: (jid: string) => Promise<
|
|
129
|
+
getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
|
|
131
130
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
132
131
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
133
|
-
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?:
|
|
132
|
+
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
|
|
134
133
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
135
134
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
136
135
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
137
136
|
removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
138
137
|
star: (jid: string, messages: {
|
|
139
138
|
id: string;
|
|
140
|
-
fromMe?: boolean
|
|
139
|
+
fromMe?: boolean;
|
|
141
140
|
}[], star: boolean) => Promise<void>;
|
|
142
141
|
type: "md";
|
|
143
142
|
ws: any;
|
|
144
143
|
ev: import("../Types").BaileysEventEmitter & {
|
|
145
|
-
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
|
144
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
146
145
|
buffer(): void;
|
|
147
|
-
createBufferedFunction<A extends any[],
|
|
148
|
-
flush(force?: boolean
|
|
146
|
+
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
147
|
+
flush(force?: boolean): boolean;
|
|
149
148
|
isBuffering(): boolean;
|
|
150
149
|
};
|
|
151
150
|
authState: {
|
|
@@ -155,17 +154,17 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
155
154
|
signalRepository: import("../Types").SignalRepository;
|
|
156
155
|
user: import("../Types").Contact | undefined;
|
|
157
156
|
generateMessageTag: () => string;
|
|
158
|
-
query: (node: BinaryNode, timeoutMs?: number
|
|
159
|
-
waitForMessage: <
|
|
157
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<BinaryNode>;
|
|
158
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<T>;
|
|
160
159
|
waitForSocketOpen: () => Promise<void>;
|
|
161
160
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
162
161
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
163
|
-
logout: (msg?: string
|
|
162
|
+
logout: (msg?: string) => Promise<void>;
|
|
164
163
|
end: (error: Error | undefined) => void;
|
|
165
|
-
onUnexpectedError: (err: Error |
|
|
164
|
+
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
166
165
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
167
166
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
168
|
-
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
169
|
-
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number
|
|
167
|
+
requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
|
|
168
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number) => Promise<void>;
|
|
170
169
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
|
|
171
170
|
};
|
package/lib/Socket/chats.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ import { Boom } from '@hapi/boom';
|
|
|
3
3
|
import { proto } from '../../WAProto';
|
|
4
4
|
import { ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAPatchCreate, WAPresence, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types';
|
|
5
5
|
import { BinaryNode } from '../WABinary';
|
|
6
|
+
import { USyncQuery } from '../WAUSync';
|
|
6
7
|
export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
8
|
+
interactiveQuery: (userNodes: BinaryNode[], queryNode: BinaryNode) => Promise<BinaryNode[]>;
|
|
7
9
|
processingMutex: {
|
|
8
10
|
mutex<T>(code: () => T | Promise<T>): Promise<T>;
|
|
9
11
|
};
|
|
@@ -12,18 +14,16 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
12
14
|
}>;
|
|
13
15
|
upsertMessage: (msg: proto.IWebMessageInfo, type: MessageUpsertType) => Promise<void>;
|
|
14
16
|
appPatch: (patchCreate: WAPatchCreate) => Promise<void>;
|
|
17
|
+
fetchUserLid: (jid: string) => Promise<string | undefined>;
|
|
15
18
|
sendPresenceUpdate: (type: WAPresence, toJid?: string) => Promise<void>;
|
|
16
19
|
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
|
|
17
|
-
profilePictureUrl: (jid: string, type?: 'preview' | 'image', timeoutMs?: number) => Promise<string | undefined>;
|
|
18
20
|
onWhatsApp: (...jids: string[]) => Promise<{
|
|
19
|
-
exists: boolean;
|
|
20
21
|
jid: string;
|
|
21
|
-
|
|
22
|
+
exists: unknown;
|
|
23
|
+
}[] | undefined>;
|
|
22
24
|
fetchBlocklist: () => Promise<string[]>;
|
|
23
|
-
fetchStatus: (
|
|
24
|
-
|
|
25
|
-
setAt: Date;
|
|
26
|
-
} | undefined>;
|
|
25
|
+
fetchStatus: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
|
|
26
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
|
|
27
27
|
updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>;
|
|
28
28
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
29
29
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
@@ -48,6 +48,7 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
48
48
|
id: string;
|
|
49
49
|
fromMe?: boolean;
|
|
50
50
|
}[], star: boolean) => Promise<void>;
|
|
51
|
+
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
|
|
51
52
|
type: "md";
|
|
52
53
|
ws: any;
|
|
53
54
|
ev: import("../Types").BaileysEventEmitter & {
|
|
@@ -74,7 +75,7 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
74
75
|
onUnexpectedError: (err: Error | Boom<any>, msg: string) => void;
|
|
75
76
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
76
77
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
77
|
-
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
78
|
+
requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
|
|
78
79
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
|
|
79
80
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
|
|
80
81
|
};
|
package/lib/Socket/chats.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.makeChatsSocket = void 0;
|
|
7
|
+
const node_cache_1 = __importDefault(require("node-cache"));
|
|
7
8
|
const boom_1 = require("@hapi/boom");
|
|
8
9
|
const WAProto_1 = require("../../WAProto");
|
|
9
10
|
const Defaults_1 = require("../Defaults");
|
|
@@ -12,19 +13,25 @@ const Utils_1 = require("../Utils");
|
|
|
12
13
|
const make_mutex_1 = require("../Utils/make-mutex");
|
|
13
14
|
const process_message_1 = __importDefault(require("../Utils/process-message"));
|
|
14
15
|
const WABinary_1 = require("../WABinary");
|
|
15
|
-
const socket_1 = require("./socket");
|
|
16
16
|
const WAUSync_1 = require("../WAUSync");
|
|
17
17
|
const usync_1 = require("./usync");
|
|
18
18
|
const MAX_SYNC_ATTEMPTS = 2;
|
|
19
19
|
const makeChatsSocket = (config) => {
|
|
20
20
|
const { logger, markOnlineOnConnect, fireInitQueries, appStateMacVerification, shouldIgnoreJid, shouldSyncHistoryMessage, } = config;
|
|
21
21
|
const sock = (0, usync_1.makeUSyncSocket)(config);
|
|
22
|
-
const { ev, ws, authState, generateMessageTag, sendNode, query, onUnexpectedError
|
|
22
|
+
const { ev, ws, authState, generateMessageTag, sendNode, query, onUnexpectedError } = sock;
|
|
23
23
|
let privacySettings;
|
|
24
24
|
let needToFlushWithAppStateSync = false;
|
|
25
25
|
let pendingAppStateSync = false;
|
|
26
26
|
/** this mutex ensures that the notifications (receipts, messages etc.) are processed in order */
|
|
27
27
|
const processingMutex = (0, make_mutex_1.makeMutex)();
|
|
28
|
+
const placeholderResendCache = config.placeholderResendCache || new node_cache_1.default({
|
|
29
|
+
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY, // 1 hour
|
|
30
|
+
useClones: false
|
|
31
|
+
});
|
|
32
|
+
if (!config.placeholderResendCache) {
|
|
33
|
+
config.placeholderResendCache = placeholderResendCache;
|
|
34
|
+
}
|
|
28
35
|
/** helper function to fetch the given app state sync key */
|
|
29
36
|
const getAppStateSyncKey = async (keyId) => {
|
|
30
37
|
const { [keyId]: key } = await authState.keys.get('app-state-sync-key', [keyId]);
|
|
@@ -68,6 +75,12 @@ const makeChatsSocket = (config) => {
|
|
|
68
75
|
}]
|
|
69
76
|
});
|
|
70
77
|
};
|
|
78
|
+
const updateMessagesPrivacy = async (value) => {
|
|
79
|
+
await privacyQuery('messages', value);
|
|
80
|
+
};
|
|
81
|
+
const updateCallPrivacy = async (value) => {
|
|
82
|
+
await privacyQuery('calladd', value);
|
|
83
|
+
};
|
|
71
84
|
const updateLastSeenPrivacy = async (value) => {
|
|
72
85
|
await privacyQuery('last', value);
|
|
73
86
|
};
|
|
@@ -102,6 +115,35 @@ const makeChatsSocket = (config) => {
|
|
|
102
115
|
}]
|
|
103
116
|
});
|
|
104
117
|
};
|
|
118
|
+
const getBotListV2 = async () => {
|
|
119
|
+
const resp = await query({
|
|
120
|
+
tag: 'iq',
|
|
121
|
+
attrs: {
|
|
122
|
+
xmlns: 'bot',
|
|
123
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
124
|
+
type: 'get'
|
|
125
|
+
},
|
|
126
|
+
content: [{
|
|
127
|
+
tag: 'bot',
|
|
128
|
+
attrs: {
|
|
129
|
+
v: '2'
|
|
130
|
+
}
|
|
131
|
+
}]
|
|
132
|
+
});
|
|
133
|
+
const botNode = (0, WABinary_1.getBinaryNodeChild)(resp, 'bot');
|
|
134
|
+
const botList = [];
|
|
135
|
+
for (const section of (0, WABinary_1.getBinaryNodeChildren)(botNode, 'section')) {
|
|
136
|
+
if (section.attrs.type === 'all') {
|
|
137
|
+
for (const bot of (0, WABinary_1.getBinaryNodeChildren)(section, 'bot')) {
|
|
138
|
+
botList.push({
|
|
139
|
+
jid: bot.attrs.jid,
|
|
140
|
+
personaId: bot.attrs['persona_id']
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return botList;
|
|
146
|
+
};
|
|
105
147
|
/** helper function to run a generic IQ query */
|
|
106
148
|
const interactiveQuery = async (userNodes, queryNode) => {
|
|
107
149
|
const result = await query({
|
|
@@ -141,6 +183,21 @@ const makeChatsSocket = (config) => {
|
|
|
141
183
|
const users = (0, WABinary_1.getBinaryNodeChildren)(listNode, 'user');
|
|
142
184
|
return users;
|
|
143
185
|
};
|
|
186
|
+
const fetchUserLid = async (jid) => {
|
|
187
|
+
const [result] = await interactiveQuery([
|
|
188
|
+
{
|
|
189
|
+
tag: 'user',
|
|
190
|
+
attrs: { jid }
|
|
191
|
+
}
|
|
192
|
+
], {
|
|
193
|
+
tag: 'lid',
|
|
194
|
+
attrs: {}
|
|
195
|
+
});
|
|
196
|
+
if (result) {
|
|
197
|
+
const lid = (0, WABinary_1.getBinaryNodeChild)(result, 'lid');
|
|
198
|
+
return lid.attrs.val;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
144
201
|
const onWhatsApp = async (...jids) => {
|
|
145
202
|
const usyncQuery = new WAUSync_1.USyncQuery()
|
|
146
203
|
.withContactProtocol()
|
|
@@ -154,14 +211,26 @@ const makeChatsSocket = (config) => {
|
|
|
154
211
|
return results.list.filter((a) => !!a.contact).map(({ contact, id, lid }) => ({ jid: id, exists: contact, lid }));
|
|
155
212
|
}
|
|
156
213
|
};
|
|
157
|
-
const fetchStatus = async (
|
|
158
|
-
const
|
|
214
|
+
const fetchStatus = async (...jids) => {
|
|
215
|
+
const usyncQuery = new WAUSync_1.USyncQuery()
|
|
216
|
+
.withStatusProtocol();
|
|
217
|
+
for (const jid of jids) {
|
|
218
|
+
usyncQuery.withUser(new WAUSync_1.USyncUser().withId(jid));
|
|
219
|
+
}
|
|
220
|
+
const result = await sock.executeUSyncQuery(usyncQuery);
|
|
159
221
|
if (result) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
222
|
+
return result.list;
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
const fetchDisappearingDuration = async (...jids) => {
|
|
226
|
+
const usyncQuery = new WAUSync_1.USyncQuery()
|
|
227
|
+
.withDisappearingModeProtocol();
|
|
228
|
+
for (const jid of jids) {
|
|
229
|
+
usyncQuery.withUser(new WAUSync_1.USyncUser().withId(jid));
|
|
230
|
+
}
|
|
231
|
+
const result = await sock.executeUSyncQuery(usyncQuery);
|
|
232
|
+
if (result) {
|
|
233
|
+
return result.list;
|
|
165
234
|
}
|
|
166
235
|
};
|
|
167
236
|
/** update the profile picture for yourself or a group */
|
|
@@ -451,7 +520,7 @@ const makeChatsSocket = (config) => {
|
|
|
451
520
|
* fetch the profile picture of a user/group
|
|
452
521
|
* type = "preview" for a low res picture
|
|
453
522
|
* type = "image for the high res picture"
|
|
454
|
-
|
|
523
|
+
*/;
|
|
455
524
|
const profilePictureUrl = async (jid, type = 'preview', timeoutMs) => {
|
|
456
525
|
var _a;
|
|
457
526
|
jid = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
@@ -487,12 +556,10 @@ const makeChatsSocket = (config) => {
|
|
|
487
556
|
});
|
|
488
557
|
}
|
|
489
558
|
else {
|
|
490
|
-
const { server } = (0, WABinary_1.jidDecode)(toJid);
|
|
491
|
-
const isLid = server === 'lid';
|
|
492
559
|
await sendNode({
|
|
493
560
|
tag: 'chatstate',
|
|
494
561
|
attrs: {
|
|
495
|
-
from:
|
|
562
|
+
from: me.id,
|
|
496
563
|
to: toJid,
|
|
497
564
|
},
|
|
498
565
|
content: [
|
|
@@ -643,8 +710,10 @@ const makeChatsSocket = (config) => {
|
|
|
643
710
|
const propsNode = (0, WABinary_1.getBinaryNodeChild)(resultNode, 'props');
|
|
644
711
|
let props = {};
|
|
645
712
|
if (propsNode) {
|
|
646
|
-
|
|
647
|
-
|
|
713
|
+
if ((_b = propsNode.attrs) === null || _b === void 0 ? void 0 : _b.hash) { // on some clients, the hash is returning as undefined
|
|
714
|
+
authState.creds.lastPropHash = (_c = propsNode === null || propsNode === void 0 ? void 0 : propsNode.attrs) === null || _c === void 0 ? void 0 : _c.hash;
|
|
715
|
+
ev.emit('creds.update', authState.creds);
|
|
716
|
+
}
|
|
648
717
|
props = (0, WABinary_1.reduceBinaryNodeToDictionary)(propsNode, 'prop');
|
|
649
718
|
}
|
|
650
719
|
logger.debug('fetched props');
|
|
@@ -670,6 +739,16 @@ const makeChatsSocket = (config) => {
|
|
|
670
739
|
}
|
|
671
740
|
}, jid);
|
|
672
741
|
};
|
|
742
|
+
/**
|
|
743
|
+
* Adds label
|
|
744
|
+
*/
|
|
745
|
+
const addLabel = (jid, labels) => {
|
|
746
|
+
return chatModify({
|
|
747
|
+
addLabel: {
|
|
748
|
+
...labels
|
|
749
|
+
}
|
|
750
|
+
}, jid);
|
|
751
|
+
};
|
|
673
752
|
/**
|
|
674
753
|
* Adds label for the chats
|
|
675
754
|
*/
|
|
@@ -756,6 +835,7 @@ const makeChatsSocket = (config) => {
|
|
|
756
835
|
})(),
|
|
757
836
|
(0, process_message_1.default)(msg, {
|
|
758
837
|
shouldProcessHistoryMsg,
|
|
838
|
+
placeholderResendCache,
|
|
759
839
|
ev,
|
|
760
840
|
creds: authState.creds,
|
|
761
841
|
keyStore: authState.keys,
|
|
@@ -816,33 +896,38 @@ const makeChatsSocket = (config) => {
|
|
|
816
896
|
sendPresenceUpdate(markOnlineOnConnect ? 'available' : 'unavailable')
|
|
817
897
|
.catch(error => onUnexpectedError(error, 'presence update requests'));
|
|
818
898
|
}
|
|
819
|
-
if (receivedPendingNotifications
|
|
820
|
-
// if we don't have the app state key
|
|
899
|
+
if (receivedPendingNotifications && // if we don't have the app state key
|
|
821
900
|
// we keep buffering events until we finally have
|
|
822
901
|
// the key and can sync the messages
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
902
|
+
// todo scrutinize
|
|
903
|
+
!((_a = authState.creds) === null || _a === void 0 ? void 0 : _a.myAppStateKeyId)) {
|
|
904
|
+
ev.buffer();
|
|
905
|
+
needToFlushWithAppStateSync = true;
|
|
827
906
|
}
|
|
828
907
|
});
|
|
829
908
|
return {
|
|
830
909
|
...sock,
|
|
910
|
+
interactiveQuery,
|
|
911
|
+
getBotListV2,
|
|
831
912
|
processingMutex,
|
|
832
913
|
fetchPrivacySettings,
|
|
833
914
|
upsertMessage,
|
|
834
915
|
appPatch,
|
|
916
|
+
fetchUserLid,
|
|
835
917
|
sendPresenceUpdate,
|
|
836
918
|
presenceSubscribe,
|
|
837
919
|
profilePictureUrl,
|
|
838
920
|
onWhatsApp,
|
|
839
921
|
fetchBlocklist,
|
|
840
922
|
fetchStatus,
|
|
923
|
+
fetchDisappearingDuration,
|
|
841
924
|
updateProfilePicture,
|
|
842
925
|
removeProfilePicture,
|
|
843
926
|
updateProfileStatus,
|
|
844
927
|
updateProfileName,
|
|
845
928
|
updateBlockStatus,
|
|
929
|
+
updateCallPrivacy,
|
|
930
|
+
updateMessagesPrivacy,
|
|
846
931
|
updateLastSeenPrivacy,
|
|
847
932
|
updateOnlinePrivacy,
|
|
848
933
|
updateProfilePicturePrivacy,
|
|
@@ -854,6 +939,7 @@ const makeChatsSocket = (config) => {
|
|
|
854
939
|
resyncAppState,
|
|
855
940
|
chatModify,
|
|
856
941
|
cleanDirtyBits,
|
|
942
|
+
addLabel,
|
|
857
943
|
addChatLabel,
|
|
858
944
|
removeChatLabel,
|
|
859
945
|
addMessageLabel,
|
package/lib/Socket/groups.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { proto } from '../../WAProto';
|
|
|
3
3
|
import { GroupMetadata, ParticipantAction, SocketConfig } from '../Types';
|
|
4
4
|
import { BinaryNode } from '../WABinary';
|
|
5
5
|
export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
6
|
+
groupQuery: (jid: string, type: 'get' | 'set', content: BinaryNode[]) => Promise<BinaryNode>;
|
|
6
7
|
groupMetadata: (jid: string) => Promise<GroupMetadata>;
|
|
7
8
|
groupCreate: (subject: string, participants: string[]) => Promise<GroupMetadata>;
|
|
8
9
|
groupLeave: (id: string) => Promise<void>;
|
|
@@ -37,6 +38,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
37
38
|
groupFetchAllParticipating: () => Promise<{
|
|
38
39
|
[_: string]: GroupMetadata;
|
|
39
40
|
}>;
|
|
41
|
+
interactiveQuery: (userNodes: BinaryNode[], queryNode: BinaryNode) => Promise<BinaryNode[]>;
|
|
40
42
|
processingMutex: {
|
|
41
43
|
mutex<T>(code: () => T | Promise<T>): Promise<T>;
|
|
42
44
|
};
|
|
@@ -45,19 +47,16 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
45
47
|
}>;
|
|
46
48
|
upsertMessage: (msg: proto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
|
|
47
49
|
appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
|
|
50
|
+
fetchUserLid: (jid: string) => Promise<string | undefined>;
|
|
48
51
|
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
|
|
49
52
|
presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
|
|
50
|
-
profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;
|
|
51
53
|
onWhatsApp: (...jids: string[]) => Promise<{
|
|
52
54
|
jid: string;
|
|
53
55
|
exists: unknown;
|
|
54
|
-
lid: unknown;
|
|
55
56
|
}[] | undefined>;
|
|
56
57
|
fetchBlocklist: () => Promise<string[]>;
|
|
57
|
-
fetchStatus: (
|
|
58
|
-
|
|
59
|
-
setAt: Date;
|
|
60
|
-
} | undefined>;
|
|
58
|
+
fetchStatus: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>;
|
|
59
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>;
|
|
61
60
|
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
62
61
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
63
62
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
@@ -82,6 +81,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
82
81
|
id: string;
|
|
83
82
|
fromMe?: boolean | undefined;
|
|
84
83
|
}[], star: boolean) => Promise<void>;
|
|
84
|
+
executeUSyncQuery: (usyncQuery: import("../index").USyncQuery) => Promise<import("../index").USyncQueryResult | undefined>;
|
|
85
85
|
type: "md";
|
|
86
86
|
ws: any;
|
|
87
87
|
ev: import("../Types").BaileysEventEmitter & {
|
|
@@ -108,7 +108,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
108
108
|
onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
|
|
109
109
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
110
110
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
111
|
-
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
111
|
+
requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
|
|
112
112
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
|
|
113
113
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
|
|
114
114
|
};
|