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