@hbmodsofc/baileys 1.5.2 → 1.7.6
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 +1 -1
- package/WAProto/index.js +19671 -152026
- package/engine-requirements.js +4 -4
- package/lib/Defaults/index.d.ts +12 -8
- package/lib/Defaults/index.js +90 -124
- package/lib/Signal/Group/group_cipher.d.ts +0 -1
- package/lib/Signal/Group/group_cipher.js +28 -39
- package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
- package/lib/Signal/Group/sender-chain-key.js +9 -2
- package/lib/Signal/Group/sender-key-distribution-message.js +3 -3
- package/lib/Signal/Group/sender-key-message.js +3 -3
- package/lib/Signal/Group/sender-key-state.d.ts +4 -4
- package/lib/Signal/Group/sender-key-state.js +47 -16
- package/lib/Signal/libsignal.d.ts +7 -3
- package/lib/Signal/libsignal.js +224 -39
- package/lib/Signal/lid-mapping.d.ts +26 -0
- package/lib/Signal/lid-mapping.js +146 -0
- 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 -3
- package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +1 -1
- package/lib/Socket/Client/{web-socket-client.js → websocket.js} +10 -16
- package/lib/Socket/business.d.ts +94 -78
- package/lib/Socket/business.js +130 -11
- package/lib/Socket/chats.d.ts +63 -233
- package/lib/Socket/chats.js +234 -184
- package/lib/Socket/communities.d.ts +232 -0
- package/lib/Socket/communities.js +402 -0
- package/lib/Socket/groups.d.ts +62 -41
- package/lib/Socket/groups.js +76 -64
- package/lib/Socket/index.d.ts +129 -83
- package/lib/Socket/index.js +13 -6
- package/lib/Socket/messages-recv.d.ts +59 -48
- package/lib/Socket/messages-recv.js +516 -371
- package/lib/Socket/messages-send.d.ts +86 -67
- package/lib/Socket/messages-send.js +1091 -1
- package/lib/Socket/mex.d.ts +2 -0
- package/lib/Socket/mex.js +45 -0
- package/lib/Socket/newsletter.d.ts +76 -64
- package/lib/Socket/newsletter.js +184 -1
- package/lib/Socket/socket.d.ts +19 -13
- package/lib/Socket/socket.js +805 -1
- package/lib/Types/Auth.d.ts +4 -10
- package/lib/Types/Bussines.d.ts +24 -0
- package/lib/Types/Bussines.js +2 -0
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +29 -9
- package/lib/Types/Chat.js +7 -1
- package/lib/Types/Contact.d.ts +5 -1
- package/lib/Types/Events.d.ts +55 -14
- package/lib/Types/GroupMetadata.d.ts +15 -5
- 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 +75 -49
- package/lib/Types/Message.js +10 -7
- package/lib/Types/Newsletter.d.ts +129 -98
- package/lib/Types/Newsletter.js +33 -38
- package/lib/Types/Product.d.ts +1 -1
- package/lib/Types/Signal.d.ts +29 -1
- package/lib/Types/Socket.d.ts +48 -22
- package/lib/Types/State.d.ts +13 -2
- package/lib/Types/State.js +12 -0
- package/lib/Types/USync.d.ts +1 -1
- package/lib/Types/index.d.ts +10 -3
- package/lib/Types/index.js +2 -2
- package/lib/Utils/auth-utils.d.ts +3 -3
- package/lib/Utils/auth-utils.js +378 -102
- package/lib/Utils/baileys-event-stream.js +1 -1
- package/lib/Utils/business.d.ts +2 -2
- package/lib/Utils/business.js +19 -13
- package/lib/Utils/chat-utils.d.ts +21 -22
- package/lib/Utils/chat-utils.js +201 -154
- package/lib/Utils/crypto.d.ts +18 -19
- package/lib/Utils/crypto.js +78 -37
- package/lib/Utils/decode-wa-message.d.ts +34 -7
- package/lib/Utils/decode-wa-message.js +138 -66
- package/lib/Utils/event-buffer.d.ts +6 -8
- package/lib/Utils/event-buffer.js +81 -43
- package/lib/Utils/generics.d.ts +27 -27
- package/lib/Utils/generics.js +128 -133
- package/lib/Utils/history.d.ts +9 -5
- package/lib/Utils/history.js +17 -23
- package/lib/Utils/index.d.ts +2 -0
- package/lib/Utils/index.js +2 -0
- package/lib/Utils/lidToJid-test.d.ts +11 -0
- package/lib/Utils/lidToJid-test.js +27 -0
- package/lib/Utils/link-preview.d.ts +4 -4
- package/lib/Utils/link-preview.js +40 -12
- package/lib/Utils/logger.d.ts +11 -3
- package/lib/Utils/lt-hash.d.ts +8 -8
- package/lib/Utils/lt-hash.js +23 -24
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/make-mutex.js +3 -2
- package/lib/Utils/message-retry-manager.d.ts +81 -0
- package/lib/Utils/message-retry-manager.js +152 -0
- package/lib/Utils/messages-media.d.ts +37 -41
- package/lib/Utils/messages-media.js +252 -368
- package/lib/Utils/messages.d.ts +13 -15
- package/lib/Utils/messages.js +274 -261
- package/lib/Utils/noise-handler.d.ts +13 -15
- package/lib/Utils/noise-handler.js +20 -26
- package/lib/Utils/process-message.d.ts +9 -8
- package/lib/Utils/process-message.js +157 -93
- package/lib/Utils/signal.d.ts +6 -5
- package/lib/Utils/signal.js +37 -29
- package/lib/Utils/use-multi-file-auth-state.d.ts +1 -2
- package/lib/Utils/use-multi-file-auth-state.js +12 -7
- package/lib/Utils/validate-connection.d.ts +5 -6
- package/lib/Utils/validate-connection.js +39 -97
- package/lib/WABinary/constants.d.ts +24 -27
- package/lib/WABinary/constants.js +1276 -13
- package/lib/WABinary/decode.d.ts +3 -4
- package/lib/WABinary/decode.js +28 -14
- package/lib/WABinary/encode.d.ts +1 -2
- package/lib/WABinary/encode.js +134 -147
- package/lib/WABinary/generic-utils.d.ts +4 -7
- package/lib/WABinary/generic-utils.js +40 -125
- package/lib/WABinary/jid-utils.d.ts +13 -8
- package/lib/WABinary/jid-utils.js +27 -16
- package/lib/WAM/BinaryInfo.d.ts +2 -11
- package/lib/WAM/constants.d.ts +3 -2
- package/lib/WAM/constants.js +2252 -2359
- package/lib/WAM/encode.d.ts +1 -2
- package/lib/WAM/encode.js +8 -11
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +3 -4
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +5 -5
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +5 -5
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +5 -6
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +4 -3
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +11 -3
- package/lib/WAUSync/USyncQuery.d.ts +2 -2
- package/lib/WAUSync/USyncQuery.js +19 -15
- package/lib/WAUSync/USyncUser.d.ts +5 -5
- package/lib/WAUSync/index.d.ts +1 -1
- package/lib/WAUSync/index.js +1 -1
- package/package.json +102 -102
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Signal/Group/queue-job.d.ts +0 -1
- package/lib/Signal/Group/queue-job.js +0 -57
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/hbmods.d.ts +0 -253
- package/lib/Socket/hbmods.js +0 -1
- package/lib/Socket/registration.d.ts +0 -267
- package/lib/Socket/registration.js +0 -166
- package/lib/Socket/usync.d.ts +0 -36
- package/lib/Socket/usync.js +0 -70
- /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
package/lib/Socket/groups.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { BinaryNode } from '../WABinary';
|
|
1
|
+
import { proto } from '../../WAProto/index.js';
|
|
2
|
+
import type { GroupMetadata, ParticipantAction, SocketConfig, WAMessageKey } from '../Types';
|
|
3
|
+
import { type BinaryNode } from '../WABinary';
|
|
5
4
|
export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
6
5
|
groupMetadata: (jid: string) => Promise<GroupMetadata>;
|
|
7
6
|
groupCreate: (subject: string, participants: string[]) => Promise<GroupMetadata>;
|
|
@@ -10,7 +9,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
10
9
|
groupRequestParticipantsList: (jid: string) => Promise<{
|
|
11
10
|
[key: string]: string;
|
|
12
11
|
}[]>;
|
|
13
|
-
groupRequestParticipantsUpdate: (jid: string, participants: string[], action:
|
|
12
|
+
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
|
|
14
13
|
status: string;
|
|
15
14
|
jid: string;
|
|
16
15
|
}[]>;
|
|
@@ -23,93 +22,115 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
23
22
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
24
23
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
25
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>;
|
|
26
32
|
/**
|
|
27
33
|
* accept a GroupInviteMessage
|
|
28
34
|
* @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
|
|
29
35
|
* @param inviteMessage the message to accept
|
|
30
36
|
*/
|
|
31
|
-
groupAcceptInviteV4: (key: string |
|
|
37
|
+
groupAcceptInviteV4: (key: string | WAMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<any>;
|
|
32
38
|
groupGetInviteInfo: (code: string) => Promise<GroupMetadata>;
|
|
33
39
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
34
|
-
groupSettingUpdate: (jid: string, setting:
|
|
35
|
-
groupMemberAddMode: (jid: string, mode:
|
|
36
|
-
groupJoinApprovalMode: (jid: string, mode:
|
|
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>;
|
|
37
43
|
groupFetchAllParticipating: () => Promise<{
|
|
38
44
|
[_: string]: GroupMetadata;
|
|
39
45
|
}>;
|
|
46
|
+
createCallLink: (type: "audio" | "video", event?: {
|
|
47
|
+
startTime: number;
|
|
48
|
+
}, timeoutMs?: number) => Promise<string | undefined>;
|
|
49
|
+
getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
|
|
40
50
|
processingMutex: {
|
|
41
|
-
mutex<T>(code: () => T |
|
|
51
|
+
mutex<T>(code: () => Promise<T> | T): Promise<T>;
|
|
42
52
|
};
|
|
43
53
|
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
44
54
|
[_: string]: string;
|
|
45
55
|
}>;
|
|
46
|
-
upsertMessage: (msg:
|
|
56
|
+
upsertMessage: (msg: import("../Types").WAMessage, type: import("../Types").MessageUpsertType) => Promise<void>;
|
|
47
57
|
appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
|
|
48
|
-
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string
|
|
49
|
-
presenceSubscribe: (toJid: string, tcToken?: Buffer
|
|
50
|
-
profilePictureUrl: (jid: string, type?: "
|
|
51
|
-
onWhatsApp: (...jids: string[]) => Promise<{
|
|
52
|
-
jid: string;
|
|
53
|
-
exists: unknown;
|
|
54
|
-
lid: unknown;
|
|
55
|
-
}[] | undefined>;
|
|
58
|
+
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
|
|
59
|
+
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
|
|
60
|
+
profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
|
|
56
61
|
fetchBlocklist: () => Promise<string[]>;
|
|
57
|
-
fetchStatus: (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
fetchStatus: (...jids: string[]) => Promise<import("../index.js").USyncQueryResultList[] | undefined>;
|
|
63
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<import("../index.js").USyncQueryResultList[] | undefined>;
|
|
64
|
+
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload, dimensions?: {
|
|
65
|
+
width: number;
|
|
66
|
+
height: number;
|
|
67
|
+
}) => Promise<void>;
|
|
62
68
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
63
69
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
64
70
|
updateProfileName: (name: string) => Promise<void>;
|
|
65
71
|
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
|
72
|
+
updateDisableLinkPreviewsPrivacy: (isPreviewsDisabled: boolean) => Promise<void>;
|
|
73
|
+
updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
|
|
74
|
+
updateMessagesPrivacy: (value: import("../Types").WAPrivacyMessagesValue) => Promise<void>;
|
|
66
75
|
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
67
76
|
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
|
68
77
|
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
69
78
|
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
70
79
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
71
|
-
updateGroupsAddPrivacy: (value: import("../Types").
|
|
80
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
72
81
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
73
|
-
getBusinessProfile: (jid: string) => Promise<
|
|
74
|
-
resyncAppState: (collections: readonly ("
|
|
82
|
+
getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
|
|
83
|
+
resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
75
84
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
76
|
-
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?:
|
|
85
|
+
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
|
|
86
|
+
addOrEditContact: (jid: string, contact: proto.SyncActionValue.IContactAction) => Promise<void>;
|
|
87
|
+
removeContact: (jid: string) => Promise<void>;
|
|
88
|
+
addLabel: (jid: string, labels: import("../Types/Label.js").LabelActionBody) => Promise<void>;
|
|
77
89
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
78
90
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
79
91
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
80
92
|
removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
81
93
|
star: (jid: string, messages: {
|
|
82
94
|
id: string;
|
|
83
|
-
fromMe?: boolean
|
|
95
|
+
fromMe?: boolean;
|
|
84
96
|
}[], star: boolean) => Promise<void>;
|
|
97
|
+
addOrEditQuickReply: (quickReply: import("../Types/Bussines.js").QuickReplyAction) => Promise<void>;
|
|
98
|
+
removeQuickReply: (timestamp: string) => Promise<void>;
|
|
85
99
|
type: "md";
|
|
86
|
-
ws:
|
|
100
|
+
ws: import("./Client/websocket.js").WebSocketClient;
|
|
87
101
|
ev: import("../Types").BaileysEventEmitter & {
|
|
88
102
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
|
89
103
|
buffer(): void;
|
|
90
|
-
createBufferedFunction<A extends any[],
|
|
91
|
-
flush(
|
|
104
|
+
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>;
|
|
105
|
+
flush(): boolean;
|
|
92
106
|
isBuffering(): boolean;
|
|
93
107
|
};
|
|
94
108
|
authState: {
|
|
95
109
|
creds: import("../Types").AuthenticationCreds;
|
|
96
110
|
keys: import("../Types").SignalKeyStoreWithTransaction;
|
|
97
111
|
};
|
|
98
|
-
signalRepository: import("../Types").
|
|
112
|
+
signalRepository: import("../Types").SignalRepositoryWithLIDStore;
|
|
99
113
|
user: import("../Types").Contact | undefined;
|
|
100
114
|
generateMessageTag: () => string;
|
|
101
|
-
query: (node: BinaryNode, timeoutMs?: number
|
|
102
|
-
waitForMessage: <
|
|
115
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
116
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<T | undefined>;
|
|
103
117
|
waitForSocketOpen: () => Promise<void>;
|
|
104
118
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
105
119
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
106
|
-
logout: (msg?: string
|
|
120
|
+
logout: (msg?: string) => Promise<void>;
|
|
107
121
|
end: (error: Error | undefined) => void;
|
|
108
|
-
onUnexpectedError: (err: Error | import("@hapi/boom").Boom
|
|
109
|
-
uploadPreKeys: (count?: number) => Promise<void>;
|
|
122
|
+
onUnexpectedError: (err: Error | import("@hapi/boom").Boom, msg: string) => void;
|
|
123
|
+
uploadPreKeys: (count?: number, retryCount?: number) => Promise<void>;
|
|
110
124
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
111
|
-
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
112
|
-
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined
|
|
113
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<
|
|
125
|
+
requestPairingCode: (phoneNumber: string, customPairingCode?: string) => Promise<string>;
|
|
126
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
127
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
128
|
+
executeUSyncQuery: (usyncQuery: import("../index.js").USyncQuery) => Promise<import("../index.js").USyncQueryResult | undefined>;
|
|
129
|
+
onWhatsApp: (...jids: string[]) => Promise<{
|
|
130
|
+
jid: string;
|
|
131
|
+
exists: boolean;
|
|
132
|
+
lid: string;
|
|
133
|
+
}[] | undefined>;
|
|
114
134
|
};
|
|
115
135
|
export declare const extractGroupMetadata: (result: BinaryNode) => GroupMetadata;
|
|
136
|
+
export type GroupsSocket = ReturnType<typeof makeGroupsSocket>;
|
package/lib/Socket/groups.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extractGroupMetadata = exports.makeGroupsSocket = void 0;
|
|
4
|
-
const
|
|
4
|
+
const index_js_1 = require("../../WAProto/index.js");
|
|
5
5
|
const Types_1 = require("../Types");
|
|
6
6
|
const Utils_1 = require("../Utils");
|
|
7
7
|
const WABinary_1 = require("../WABinary");
|
|
8
8
|
const chats_1 = require("./chats");
|
|
9
|
-
const WAUSync_1 = require("../WAUSync");
|
|
10
9
|
const makeGroupsSocket = (config) => {
|
|
11
10
|
const sock = (0, chats_1.makeChatsSocket)(config);
|
|
12
11
|
const { authState, ev, query, upsertMessage } = sock;
|
|
13
|
-
const groupQuery = async (jid, type, content) =>
|
|
12
|
+
const groupQuery = async (jid, type, content) => query({
|
|
14
13
|
tag: 'iq',
|
|
15
14
|
attrs: {
|
|
16
15
|
type,
|
|
17
16
|
xmlns: 'w:g2',
|
|
18
|
-
to: jid
|
|
17
|
+
to: jid
|
|
19
18
|
},
|
|
20
19
|
content
|
|
21
|
-
})
|
|
20
|
+
});
|
|
22
21
|
const groupMetadata = async (jid) => {
|
|
23
22
|
const result = await groupQuery(jid, 'get', [{ tag: 'query', attrs: { request: 'interactive' } }]);
|
|
24
23
|
return (0, exports.extractGroupMetadata)(result);
|
|
@@ -29,7 +28,7 @@ const makeGroupsSocket = (config) => {
|
|
|
29
28
|
attrs: {
|
|
30
29
|
to: '@g.us',
|
|
31
30
|
xmlns: 'w:g2',
|
|
32
|
-
type: 'get'
|
|
31
|
+
type: 'get'
|
|
33
32
|
},
|
|
34
33
|
content: [
|
|
35
34
|
{
|
|
@@ -70,7 +69,7 @@ const makeGroupsSocket = (config) => {
|
|
|
70
69
|
...sock,
|
|
71
70
|
groupMetadata,
|
|
72
71
|
groupCreate: async (subject, participants) => {
|
|
73
|
-
const key = (0, Utils_1.
|
|
72
|
+
const key = (0, Utils_1.generateMessageIDV2)();
|
|
74
73
|
const result = await groupQuery('@g.us', 'set', [
|
|
75
74
|
{
|
|
76
75
|
tag: 'create',
|
|
@@ -91,9 +90,7 @@ const makeGroupsSocket = (config) => {
|
|
|
91
90
|
{
|
|
92
91
|
tag: 'leave',
|
|
93
92
|
attrs: {},
|
|
94
|
-
content: [
|
|
95
|
-
{ tag: 'group', attrs: { id } }
|
|
96
|
-
]
|
|
93
|
+
content: [{ tag: 'group', attrs: { id } }]
|
|
97
94
|
}
|
|
98
95
|
]);
|
|
99
96
|
},
|
|
@@ -118,7 +115,8 @@ const makeGroupsSocket = (config) => {
|
|
|
118
115
|
return participants.map(v => v.attrs);
|
|
119
116
|
},
|
|
120
117
|
groupRequestParticipantsUpdate: async (jid, participants, action) => {
|
|
121
|
-
const result = await groupQuery(jid, 'set', [
|
|
118
|
+
const result = await groupQuery(jid, 'set', [
|
|
119
|
+
{
|
|
122
120
|
tag: 'membership_requests_action',
|
|
123
121
|
attrs: {},
|
|
124
122
|
content: [
|
|
@@ -131,7 +129,8 @@ const makeGroupsSocket = (config) => {
|
|
|
131
129
|
}))
|
|
132
130
|
}
|
|
133
131
|
]
|
|
134
|
-
}
|
|
132
|
+
}
|
|
133
|
+
]);
|
|
135
134
|
const node = (0, WABinary_1.getBinaryNodeChild)(result, 'membership_requests_action');
|
|
136
135
|
const nodeAction = (0, WABinary_1.getBinaryNodeChild)(node, action);
|
|
137
136
|
const participantsAffected = (0, WABinary_1.getBinaryNodeChildren)(nodeAction, 'participant');
|
|
@@ -157,36 +156,45 @@ const makeGroupsSocket = (config) => {
|
|
|
157
156
|
});
|
|
158
157
|
},
|
|
159
158
|
groupUpdateDescription: async (jid, description) => {
|
|
160
|
-
var _a;
|
|
161
159
|
const metadata = await groupMetadata(jid);
|
|
162
|
-
const prev =
|
|
160
|
+
const prev = metadata.descId ?? null;
|
|
163
161
|
await groupQuery(jid, 'set', [
|
|
164
162
|
{
|
|
165
163
|
tag: 'description',
|
|
166
164
|
attrs: {
|
|
167
|
-
...(description ? { id: (0, Utils_1.
|
|
165
|
+
...(description ? { id: (0, Utils_1.generateMessageIDV2)() } : { delete: 'true' }),
|
|
168
166
|
...(prev ? { prev } : {})
|
|
169
167
|
},
|
|
170
|
-
content: description ? [
|
|
171
|
-
{ tag: 'body', attrs: {}, content: Buffer.from(description, 'utf-8') }
|
|
172
|
-
] : undefined
|
|
168
|
+
content: description ? [{ tag: 'body', attrs: {}, content: Buffer.from(description, 'utf-8') }] : undefined
|
|
173
169
|
}
|
|
174
170
|
]);
|
|
175
171
|
},
|
|
176
172
|
groupInviteCode: async (jid) => {
|
|
177
173
|
const result = await groupQuery(jid, 'get', [{ tag: 'invite', attrs: {} }]);
|
|
178
174
|
const inviteNode = (0, WABinary_1.getBinaryNodeChild)(result, 'invite');
|
|
179
|
-
return inviteNode
|
|
175
|
+
return inviteNode?.attrs.code;
|
|
180
176
|
},
|
|
181
177
|
groupRevokeInvite: async (jid) => {
|
|
182
178
|
const result = await groupQuery(jid, 'set', [{ tag: 'invite', attrs: {} }]);
|
|
183
179
|
const inviteNode = (0, WABinary_1.getBinaryNodeChild)(result, 'invite');
|
|
184
|
-
return inviteNode
|
|
180
|
+
return inviteNode?.attrs.code;
|
|
185
181
|
},
|
|
186
182
|
groupAcceptInvite: async (code) => {
|
|
187
183
|
const results = await groupQuery('@g.us', 'set', [{ tag: 'invite', attrs: { code } }]);
|
|
188
184
|
const result = (0, WABinary_1.getBinaryNodeChild)(results, 'group');
|
|
189
|
-
return result
|
|
185
|
+
return result?.attrs.jid;
|
|
186
|
+
},
|
|
187
|
+
/**
|
|
188
|
+
* revoke a v4 invite for someone
|
|
189
|
+
* @param groupJid group jid
|
|
190
|
+
* @param invitedJid jid of person you invited
|
|
191
|
+
* @returns true if successful
|
|
192
|
+
*/
|
|
193
|
+
groupRevokeInviteV4: async (groupJid, invitedJid) => {
|
|
194
|
+
const result = await groupQuery(groupJid, 'set', [
|
|
195
|
+
{ tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }
|
|
196
|
+
]);
|
|
197
|
+
return !!result;
|
|
190
198
|
},
|
|
191
199
|
/**
|
|
192
200
|
* accept a GroupInviteMessage
|
|
@@ -195,19 +203,21 @@ const makeGroupsSocket = (config) => {
|
|
|
195
203
|
*/
|
|
196
204
|
groupAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => {
|
|
197
205
|
key = typeof key === 'string' ? { remoteJid: key } : key;
|
|
198
|
-
const results = await groupQuery(inviteMessage.groupJid, 'set', [
|
|
206
|
+
const results = await groupQuery(inviteMessage.groupJid, 'set', [
|
|
207
|
+
{
|
|
199
208
|
tag: 'accept',
|
|
200
209
|
attrs: {
|
|
201
210
|
code: inviteMessage.inviteCode,
|
|
202
211
|
expiration: inviteMessage.inviteExpiration.toString(),
|
|
203
212
|
admin: key.remoteJid
|
|
204
213
|
}
|
|
205
|
-
}
|
|
214
|
+
}
|
|
215
|
+
]);
|
|
206
216
|
// if we have the full message key
|
|
207
217
|
// update the invite message to be expired
|
|
208
218
|
if (key.id) {
|
|
209
219
|
// create new invite message that is expired
|
|
210
|
-
inviteMessage =
|
|
220
|
+
inviteMessage = index_js_1.proto.Message.GroupInviteMessage.create(inviteMessage);
|
|
211
221
|
inviteMessage.inviteExpiration = 0;
|
|
212
222
|
inviteMessage.inviteCode = '';
|
|
213
223
|
ev.emit('messages.update', [
|
|
@@ -225,14 +235,12 @@ const makeGroupsSocket = (config) => {
|
|
|
225
235
|
await upsertMessage({
|
|
226
236
|
key: {
|
|
227
237
|
remoteJid: inviteMessage.groupJid,
|
|
228
|
-
id: (0, Utils_1.
|
|
238
|
+
id: (0, Utils_1.generateMessageIDV2)(sock.user?.id),
|
|
229
239
|
fromMe: false,
|
|
230
|
-
participant: key.remoteJid
|
|
240
|
+
participant: key.remoteJid
|
|
231
241
|
},
|
|
232
242
|
messageStubType: Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD,
|
|
233
|
-
messageStubParameters: [
|
|
234
|
-
authState.creds.me.id
|
|
235
|
-
],
|
|
243
|
+
messageStubParameters: [authState.creds.me.id],
|
|
236
244
|
participant: key.remoteJid,
|
|
237
245
|
messageTimestamp: (0, Utils_1.unixTimestampSeconds)()
|
|
238
246
|
}, 'notify');
|
|
@@ -243,9 +251,9 @@ const makeGroupsSocket = (config) => {
|
|
|
243
251
|
return (0, exports.extractGroupMetadata)(results);
|
|
244
252
|
},
|
|
245
253
|
groupToggleEphemeral: async (jid, ephemeralExpiration) => {
|
|
246
|
-
const content = ephemeralExpiration
|
|
247
|
-
{ tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } }
|
|
248
|
-
{ tag: 'not_ephemeral', attrs: {} };
|
|
254
|
+
const content = ephemeralExpiration
|
|
255
|
+
? { tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } }
|
|
256
|
+
: { tag: 'not_ephemeral', attrs: {} };
|
|
249
257
|
await groupQuery(jid, 'set', [content]);
|
|
250
258
|
},
|
|
251
259
|
groupSettingUpdate: async (jid, setting) => {
|
|
@@ -255,58 +263,63 @@ const makeGroupsSocket = (config) => {
|
|
|
255
263
|
await groupQuery(jid, 'set', [{ tag: 'member_add_mode', attrs: {}, content: mode }]);
|
|
256
264
|
},
|
|
257
265
|
groupJoinApprovalMode: async (jid, mode) => {
|
|
258
|
-
await groupQuery(jid, 'set', [
|
|
266
|
+
await groupQuery(jid, 'set', [
|
|
267
|
+
{ tag: 'membership_approval_mode', attrs: {}, content: [{ tag: 'group_join', attrs: { state: mode } }] }
|
|
268
|
+
]);
|
|
259
269
|
},
|
|
260
270
|
groupFetchAllParticipating
|
|
261
271
|
};
|
|
262
272
|
};
|
|
263
273
|
exports.makeGroupsSocket = makeGroupsSocket;
|
|
264
274
|
const extractGroupMetadata = (result) => {
|
|
265
|
-
|
|
266
|
-
const
|
|
267
|
-
const descChild = WABinary_1.getBinaryNodeChild(group, 'description');
|
|
275
|
+
const group = (0, WABinary_1.getBinaryNodeChild)(result, 'group');
|
|
276
|
+
const descChild = (0, WABinary_1.getBinaryNodeChild)(group, 'description');
|
|
268
277
|
let desc;
|
|
269
278
|
let descId;
|
|
270
279
|
let descOwner;
|
|
271
|
-
let
|
|
280
|
+
let descOwnerPn;
|
|
272
281
|
let descTime;
|
|
273
282
|
if (descChild) {
|
|
274
|
-
desc = WABinary_1.getBinaryNodeChildString(descChild, 'body');
|
|
275
|
-
descOwner =
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
283
|
+
desc = (0, WABinary_1.getBinaryNodeChildString)(descChild, 'body');
|
|
284
|
+
descOwner = descChild.attrs.participant ? (0, WABinary_1.jidNormalizedUser)(descChild.attrs.participant) : undefined;
|
|
285
|
+
descOwnerPn = descChild.attrs.participant_pn ? (0, WABinary_1.jidNormalizedUser)(descChild.attrs.participant_pn) : undefined;
|
|
286
|
+
descTime = +descChild.attrs.t;
|
|
279
287
|
descId = descChild.attrs.id;
|
|
280
|
-
descTime = descChild.attrs.t ? +descChild.attrs.t : undefined;
|
|
281
288
|
}
|
|
282
|
-
const groupSize = group.attrs.size ? Number(group.attrs.size) : undefined;
|
|
283
289
|
const groupId = group.attrs.id.includes('@') ? group.attrs.id : (0, WABinary_1.jidEncode)(group.attrs.id, 'g.us');
|
|
284
|
-
const eph = WABinary_1.getBinaryNodeChild(group, 'ephemeral')?.attrs.expiration
|
|
285
|
-
const memberAddMode = WABinary_1.getBinaryNodeChildString(group, 'member_add_mode') === 'all_member_add';
|
|
290
|
+
const eph = (0, WABinary_1.getBinaryNodeChild)(group, 'ephemeral')?.attrs.expiration;
|
|
291
|
+
const memberAddMode = (0, WABinary_1.getBinaryNodeChildString)(group, 'member_add_mode') === 'all_member_add';
|
|
286
292
|
const metadata = {
|
|
287
293
|
id: groupId,
|
|
288
|
-
|
|
294
|
+
notify: group.attrs.notify,
|
|
295
|
+
addressingMode: group.attrs.addressing_mode === 'lid' ? Types_1.WAMessageAddressingMode.LID : Types_1.WAMessageAddressingMode.PN,
|
|
289
296
|
subject: group.attrs.subject,
|
|
290
|
-
subjectOwner:
|
|
291
|
-
|
|
292
|
-
subjectTime:
|
|
293
|
-
size:
|
|
294
|
-
creation:
|
|
295
|
-
owner:
|
|
296
|
-
|
|
297
|
+
subjectOwner: group.attrs.s_o,
|
|
298
|
+
subjectOwnerPn: group.attrs.s_o_pn,
|
|
299
|
+
subjectTime: +group.attrs.s_t,
|
|
300
|
+
size: group.attrs.size ? +group.attrs.size : (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').length,
|
|
301
|
+
creation: +group.attrs.creation,
|
|
302
|
+
owner: group.attrs.creator ? (0, WABinary_1.jidNormalizedUser)(group.attrs.creator) : undefined,
|
|
303
|
+
ownerPn: group.attrs.creator_pn ? (0, WABinary_1.jidNormalizedUser)(group.attrs.creator_pn) : undefined,
|
|
304
|
+
owner_country_code: group.attrs.creator_country_code,
|
|
305
|
+
desc,
|
|
306
|
+
descId,
|
|
297
307
|
descOwner,
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
308
|
+
descOwnerPn,
|
|
309
|
+
descTime,
|
|
310
|
+
linkedParent: (0, WABinary_1.getBinaryNodeChild)(group, 'linked_parent')?.attrs.jid || undefined,
|
|
311
|
+
restrict: !!(0, WABinary_1.getBinaryNodeChild)(group, 'locked'),
|
|
312
|
+
announce: !!(0, WABinary_1.getBinaryNodeChild)(group, 'announcement'),
|
|
313
|
+
isCommunity: !!(0, WABinary_1.getBinaryNodeChild)(group, 'parent'),
|
|
314
|
+
isCommunityAnnounce: !!(0, WABinary_1.getBinaryNodeChild)(group, 'default_sub_group'),
|
|
315
|
+
joinApprovalMode: !!(0, WABinary_1.getBinaryNodeChild)(group, 'membership_approval_mode'),
|
|
304
316
|
memberAddMode,
|
|
305
|
-
participants: WABinary_1.getBinaryNodeChildren(group, 'participant').map(({ attrs }) => {
|
|
317
|
+
participants: (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').map(({ attrs }) => {
|
|
306
318
|
return {
|
|
307
319
|
id: attrs.jid,
|
|
308
|
-
|
|
309
|
-
|
|
320
|
+
phoneNumber: (0, WABinary_1.isLidUser)(attrs.jid) && (0, WABinary_1.isPnUser)(attrs.phone_number) ? attrs.phone_number : undefined,
|
|
321
|
+
lid: (0, WABinary_1.isPnUser)(attrs.jid) && (0, WABinary_1.isLidUser)(attrs.lid) ? attrs.lid : undefined,
|
|
322
|
+
admin: (attrs.type || null)
|
|
310
323
|
};
|
|
311
324
|
}),
|
|
312
325
|
ephemeralDuration: eph ? +eph : undefined
|
|
@@ -314,4 +327,3 @@ const extractGroupMetadata = (result) => {
|
|
|
314
327
|
return metadata;
|
|
315
328
|
};
|
|
316
329
|
exports.extractGroupMetadata = extractGroupMetadata;
|
|
317
|
-
|