@dappaoffc/baileys-mod 6.0.23 → 8.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.
Potentially problematic release.
This version of @dappaoffc/baileys-mod might be problematic. Click here for more details.
- package/LICENSE +21 -0
- package/WAProto/WAProto.proto +5311 -0
- package/WAProto/index.js +65801 -141371
- package/lib/Defaults/index.js +117 -141
- package/lib/KeyDB/BinarySearch.js +20 -0
- package/lib/KeyDB/KeyedDB.js +167 -0
- package/lib/KeyDB/index.js +4 -0
- package/lib/Signal/Group/ciphertext-message.js +12 -14
- package/lib/Signal/Group/group-session-builder.js +10 -42
- package/lib/Signal/Group/group_cipher.js +75 -87
- package/lib/Signal/Group/index.js +13 -57
- package/lib/Signal/Group/keyhelper.js +17 -52
- package/lib/Signal/Group/sender-chain-key.js +27 -33
- package/lib/Signal/Group/sender-key-distribution-message.js +62 -63
- package/lib/Signal/Group/sender-key-message.js +65 -66
- package/lib/Signal/Group/sender-key-name.js +45 -44
- package/lib/Signal/Group/sender-key-record.js +39 -49
- package/lib/Signal/Group/sender-key-state.js +80 -93
- package/lib/Signal/Group/sender-message-key.js +27 -28
- package/lib/Signal/libsignal.js +313 -163
- package/lib/Signal/lid-mapping.js +155 -0
- package/lib/Socket/Client/index.js +4 -19
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/websocket.js +52 -0
- package/lib/Socket/Client/websocket.js.bak +53 -0
- package/lib/Socket/business.js +359 -242
- package/lib/Socket/chats.js +846 -935
- package/lib/Socket/communities.js +413 -0
- package/lib/Socket/groups.js +304 -309
- package/lib/Socket/index.js +15 -10
- package/lib/Socket/messages-recv.js +1107 -1054
- package/lib/Socket/messages-send.js +639 -448
- package/lib/Socket/mex.js +45 -0
- package/lib/Socket/newsletter.js +197 -310
- package/lib/Socket/socket.js +791 -651
- package/lib/Store/index.js +6 -10
- package/lib/Store/make-cache-manager-store.js +73 -81
- package/lib/Store/make-in-memory-store.js +286 -423
- package/lib/Store/make-ordered-dictionary.js +77 -79
- package/lib/Store/object-repository.js +24 -26
- package/lib/Types/Auth.js +3 -2
- package/lib/Types/Bussines.js +3 -0
- package/lib/Types/Call.js +3 -2
- package/lib/Types/Chat.js +9 -4
- package/lib/Types/Contact.js +3 -2
- package/lib/Types/Events.js +3 -2
- package/lib/Types/GroupMetadata.js +3 -2
- package/lib/Types/Label.js +24 -26
- package/lib/Types/LabelAssociation.js +6 -8
- package/lib/Types/Message.js +12 -9
- package/lib/Types/Newsletter.js +33 -38
- package/lib/Types/Newsletter.js.bak +33 -0
- package/lib/Types/Product.js +3 -2
- package/lib/Types/Signal.js +3 -2
- package/lib/Types/Socket.js +4 -2
- package/lib/Types/State.js +11 -2
- package/lib/Types/USync.js +3 -2
- package/lib/Types/index.js +27 -41
- package/lib/Utils/auth-utils.js +211 -198
- package/lib/Utils/baileys-event-stream.js +42 -61
- package/lib/Utils/browser-utils.js +25 -0
- package/lib/Utils/business.js +213 -214
- package/lib/Utils/chat-utils.js +710 -687
- package/lib/Utils/crypto.js +112 -133
- package/lib/Utils/decode-wa-message.js +252 -183
- package/lib/Utils/decode-wa-message.js.bak +267 -0
- package/lib/Utils/event-buffer.js +510 -496
- package/lib/Utils/generics.js +319 -392
- package/lib/Utils/history.js +83 -92
- package/lib/Utils/index.js +21 -33
- package/lib/Utils/link-preview.js +71 -83
- package/lib/Utils/logger.js +5 -7
- package/lib/Utils/lt-hash.js +40 -46
- package/lib/Utils/make-mutex.js +34 -41
- package/lib/Utils/message-retry-manager.js +113 -0
- package/lib/Utils/messages-media.js +550 -768
- package/lib/Utils/messages.js +354 -263
- package/lib/Utils/noise-handler.js +138 -149
- package/lib/Utils/pre-key-manager.js +85 -0
- package/lib/Utils/process-message.js +323 -303
- package/lib/Utils/signal.js +149 -141
- package/lib/Utils/use-multi-file-auth-state.js +95 -103
- package/lib/Utils/validate-connection.js +183 -214
- package/lib/WABinary/constants.js +1298 -35
- package/lib/WABinary/decode.js +237 -249
- package/lib/WABinary/encode.js +213 -260
- package/lib/WABinary/generic-utils.js +56 -65
- package/lib/WABinary/index.js +7 -21
- package/lib/WABinary/jid-utils.js +89 -58
- package/lib/WABinary/types.js +3 -2
- package/lib/WAM/BinaryInfo.js +10 -12
- package/lib/WAM/constants.js +22851 -15348
- package/lib/WAM/encode.js +135 -136
- package/lib/WAM/index.js +5 -19
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +28 -30
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +49 -53
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -28
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +36 -39
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -50
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +26 -20
- package/lib/WAUSync/Protocols/index.js +6 -20
- package/lib/WAUSync/USyncQuery.js +86 -85
- package/lib/WAUSync/USyncUser.js +23 -25
- package/lib/WAUSync/index.js +5 -19
- package/lib/index.js +15 -38
- package/package.json +101 -106
- package/engine-requirements.js +0 -10
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/index.d.ts +0 -53
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
- package/lib/Signal/Group/group-session-builder.d.ts +0 -14
- package/lib/Signal/Group/group_cipher.d.ts +0 -17
- package/lib/Signal/Group/index.d.ts +0 -11
- package/lib/Signal/Group/keyhelper.d.ts +0 -10
- 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-key-distribution-message.d.ts +0 -16
- package/lib/Signal/Group/sender-key-message.d.ts +0 -18
- package/lib/Signal/Group/sender-key-name.d.ts +0 -17
- package/lib/Signal/Group/sender-key-record.d.ts +0 -30
- package/lib/Signal/Group/sender-key-state.d.ts +0 -38
- package/lib/Signal/Group/sender-message-key.d.ts +0 -11
- package/lib/Signal/libsignal.d.ts +0 -3
- package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
- package/lib/Socket/Client/abstract-socket-client.js +0 -13
- package/lib/Socket/Client/index.d.ts +0 -3
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/Client/web-socket-client.d.ts +0 -12
- package/lib/Socket/Client/web-socket-client.js +0 -62
- package/lib/Socket/business.d.ts +0 -171
- package/lib/Socket/chats.d.ts +0 -267
- package/lib/Socket/dugong.d.ts +0 -254
- package/lib/Socket/dugong.js +0 -484
- package/lib/Socket/groups.d.ts +0 -115
- package/lib/Socket/index.d.ts +0 -173
- package/lib/Socket/messages-recv.d.ts +0 -161
- package/lib/Socket/messages-send.d.ts +0 -149
- package/lib/Socket/newsletter.d.ts +0 -134
- package/lib/Socket/registration.d.ts +0 -267
- package/lib/Socket/registration.js +0 -166
- package/lib/Socket/socket.d.ts +0 -43
- package/lib/Socket/usync.d.ts +0 -36
- package/lib/Socket/usync.js +0 -70
- package/lib/Store/index.d.ts +0 -3
- package/lib/Store/make-cache-manager-store.d.ts +0 -13
- package/lib/Store/make-in-memory-store.d.ts +0 -118
- package/lib/Store/make-ordered-dictionary.d.ts +0 -13
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Types/Auth.d.ts +0 -110
- package/lib/Types/Call.d.ts +0 -13
- package/lib/Types/Chat.d.ts +0 -102
- package/lib/Types/Contact.d.ts +0 -19
- package/lib/Types/Events.d.ts +0 -157
- package/lib/Types/GroupMetadata.d.ts +0 -55
- package/lib/Types/Label.d.ts +0 -35
- package/lib/Types/LabelAssociation.d.ts +0 -29
- package/lib/Types/Message.d.ts +0 -273
- package/lib/Types/Newsletter.d.ts +0 -103
- package/lib/Types/Product.d.ts +0 -78
- package/lib/Types/Signal.d.ts +0 -57
- package/lib/Types/Socket.d.ts +0 -111
- package/lib/Types/State.d.ts +0 -27
- package/lib/Types/USync.d.ts +0 -25
- package/lib/Types/index.d.ts +0 -57
- package/lib/Utils/auth-utils.d.ts +0 -18
- package/lib/Utils/baileys-event-stream.d.ts +0 -16
- package/lib/Utils/business.d.ts +0 -22
- package/lib/Utils/chat-utils.d.ts +0 -71
- package/lib/Utils/crypto.d.ts +0 -41
- package/lib/Utils/decode-wa-message.d.ts +0 -19
- package/lib/Utils/event-buffer.d.ts +0 -35
- package/lib/Utils/generics.d.ts +0 -92
- package/lib/Utils/generics.js.bak +0 -433
- package/lib/Utils/history.d.ts +0 -15
- package/lib/Utils/index.d.ts +0 -17
- package/lib/Utils/link-preview.d.ts +0 -21
- package/lib/Utils/logger.d.ts +0 -4
- package/lib/Utils/lt-hash.d.ts +0 -12
- package/lib/Utils/make-mutex.d.ts +0 -7
- package/lib/Utils/messages-media.d.ts +0 -116
- package/lib/Utils/messages.d.ts +0 -77
- package/lib/Utils/noise-handler.d.ts +0 -21
- package/lib/Utils/process-message.d.ts +0 -41
- package/lib/Utils/signal.d.ts +0 -32
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
- package/lib/Utils/validate-connection.d.ts +0 -11
- package/lib/Utils/validate-connection.js.bak +0 -237
- package/lib/WABinary/constants.d.ts +0 -30
- package/lib/WABinary/decode.d.ts +0 -7
- package/lib/WABinary/encode.d.ts +0 -3
- package/lib/WABinary/generic-utils.d.ts +0 -17
- package/lib/WABinary/index.d.ts +0 -5
- package/lib/WABinary/jid-utils.d.ts +0 -31
- package/lib/WABinary/types.d.ts +0 -18
- package/lib/WAM/BinaryInfo.d.ts +0 -17
- package/lib/WAM/constants.d.ts +0 -38
- package/lib/WAM/encode.d.ts +0 -3
- package/lib/WAM/index.d.ts +0 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
- package/lib/WAUSync/Protocols/index.d.ts +0 -4
- package/lib/WAUSync/USyncQuery.d.ts +0 -28
- package/lib/WAUSync/USyncUser.d.ts +0 -12
- package/lib/WAUSync/index.d.ts +0 -3
- package/lib/index.d.ts +0 -12
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//=======================================================//
|
|
2
|
+
import { getBinaryNodeChild, S_WHATSAPP_NET } from "../WABinary/index.js";
|
|
3
|
+
import { Boom } from "@hapi/boom";
|
|
4
|
+
//=======================================================//
|
|
5
|
+
const wMexQuery = (variables, queryId, query, generateMessageTag) => {
|
|
6
|
+
return query({
|
|
7
|
+
tag: "iq",
|
|
8
|
+
attrs: {
|
|
9
|
+
id: generateMessageTag(),
|
|
10
|
+
type: "get",
|
|
11
|
+
to: S_WHATSAPP_NET,
|
|
12
|
+
xmlns: "w:mex"
|
|
13
|
+
},
|
|
14
|
+
content: [
|
|
15
|
+
{
|
|
16
|
+
tag: "query",
|
|
17
|
+
attrs: { query_id: queryId },
|
|
18
|
+
content: Buffer.from(JSON.stringify({ variables }), "utf-8")
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
//=======================================================//
|
|
24
|
+
export const executeWMexQuery = async (variables, queryId, dataPath, query, generateMessageTag) => {
|
|
25
|
+
const result = await wMexQuery(variables, queryId, query, generateMessageTag);
|
|
26
|
+
const child = getBinaryNodeChild(result, "result");
|
|
27
|
+
if (child?.content) {
|
|
28
|
+
const data = JSON.parse(child.content.toString());
|
|
29
|
+
if (data.errors && data.errors.length > 0) {
|
|
30
|
+
const errorMessages = data.errors.map((err) => err.message || "Unknown error").join(", ");
|
|
31
|
+
const firstError = data.errors[0];
|
|
32
|
+
const errorCode = firstError.extensions?.error_code || 400;
|
|
33
|
+
throw new Boom(`GraphQL server error: ${errorMessages}`, { statusCode: errorCode, data: firstError });
|
|
34
|
+
}
|
|
35
|
+
const response = dataPath ? data?.data?.[dataPath] : data?.data;
|
|
36
|
+
if (typeof response !== "undefined") {
|
|
37
|
+
return response;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const action = (dataPath || "").startsWith("xwa2_")
|
|
41
|
+
? dataPath.substring(5).replace(/_/g, " ")
|
|
42
|
+
: dataPath?.replace(/_/g, " ");
|
|
43
|
+
throw new Boom(`Failed to ${action}, unexpected response structure.`, { statusCode: 400, data: result });
|
|
44
|
+
};
|
|
45
|
+
//=======================================================//
|
package/lib/Socket/newsletter.js
CHANGED
|
@@ -1,123 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
{
|
|
28
|
-
tag: 'query',
|
|
29
|
-
attrs: { query_id: queryId },
|
|
30
|
-
content: Buffer.from(JSON.stringify({ variables }), 'utf-8')
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const parseNewsletterCreateResponse = (responseList) => {
|
|
37
|
-
return responseList.map((res) => {
|
|
38
|
-
const thread = res.thread_metadata;
|
|
39
|
-
const viewer = res.viewer_metadata;
|
|
40
|
-
|
|
41
|
-
// Jika DELETED atau metadata null
|
|
42
|
-
if (!thread || !viewer) {
|
|
43
|
-
return {
|
|
44
|
-
id: res.id,
|
|
45
|
-
state: res.state?.type || null,
|
|
46
|
-
deleted: true
|
|
47
|
-
};
|
|
1
|
+
//=======================================================//
|
|
2
|
+
import { executeWMexQuery as genericExecuteWMexQuery } from "./mex.js";
|
|
3
|
+
import { generateProfilePicture } from "../Utils/messages-media.js";
|
|
4
|
+
import { getBinaryNodeChild } from "../WABinary/index.js";
|
|
5
|
+
import { QueryIds, XWAPaths } from "../Types/index.js";
|
|
6
|
+
import { makeGroupsSocket } from "./groups.js";
|
|
7
|
+
//=======================================================//
|
|
8
|
+
|
|
9
|
+
const extractNewsletterMetadata = (node, isCreate) => {
|
|
10
|
+
const result = getBinaryNodeChild(node, 'result')?.content?.toString()
|
|
11
|
+
const metadataPath = JSON.parse(result).data[isCreate ? XWAPaths.xwa2_newsletter_create : "xwa2_newsletter"]
|
|
12
|
+
|
|
13
|
+
const metadata = {
|
|
14
|
+
id: metadataPath?.id,
|
|
15
|
+
state: metadataPath?.state?.type,
|
|
16
|
+
creation_time: +metadataPath?.thread_metadata?.creation_time,
|
|
17
|
+
name: metadataPath?.thread_metadata?.name?.text,
|
|
18
|
+
nameTime: +metadataPath?.thread_metadata?.name?.update_time,
|
|
19
|
+
description: metadataPath?.thread_metadata?.description?.text,
|
|
20
|
+
descriptionTime: +metadataPath?.thread_metadata?.description?.update_time,
|
|
21
|
+
invite: metadataPath?.thread_metadata?.invite,
|
|
22
|
+
handle: metadataPath?.thread_metadata?.handle,
|
|
23
|
+
reaction_codes: metadataPath?.thread_metadata?.settings?.reaction_codes?.value,
|
|
24
|
+
subscribers: +metadataPath?.thread_metadata?.subscribers_count,
|
|
25
|
+
verification: metadataPath?.thread_metadata?.verification,
|
|
26
|
+
viewer_metadata: metadataPath?.viewer_metadata
|
|
48
27
|
}
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
id: res.id,
|
|
52
|
-
state: res.state?.type || null,
|
|
53
|
-
owner: viewer.role || undefined,
|
|
54
|
-
name: thread?.name?.text || null,
|
|
55
|
-
creation_time: parseInt(thread?.creation_time || "0", 10),
|
|
56
|
-
description: thread?.description?.text || null,
|
|
57
|
-
invite: thread?.invite || null,
|
|
58
|
-
subscribers: parseInt(thread?.subscribers_count || "0", 10),
|
|
59
|
-
verification: thread?.verification || null,
|
|
60
|
-
picture: {
|
|
61
|
-
id: thread?.picture?.id || null,
|
|
62
|
-
directPath: thread?.picture?.direct_path || null
|
|
63
|
-
},
|
|
64
|
-
mute_state: viewer?.mute || "OFF"
|
|
65
|
-
};
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const executeWMexQuery = async (
|
|
70
|
-
variables,
|
|
71
|
-
queryId,
|
|
72
|
-
dataPath,
|
|
73
|
-
query,
|
|
74
|
-
generateMessageTag
|
|
75
|
-
) => {
|
|
76
|
-
const result = await wMexQuery(variables, queryId, query, generateMessageTag)
|
|
77
|
-
const child = (0, WABinary_1.getBinaryNodeChild)(result, 'result')
|
|
78
|
-
if (child?.content) {
|
|
79
|
-
const data = JSON.parse(child.content.toString())
|
|
80
|
-
|
|
81
|
-
if (data.errors && data.errors.length > 0) {
|
|
82
|
-
const errorMessages = data.errors.map((err) => err.message || 'Unknown error').join(', ')
|
|
83
|
-
const firstError = data.errors[0]
|
|
84
|
-
const errorCode = firstError.extensions?.error_code || 400
|
|
85
|
-
throw new Boom(`GraphQL server error: ${errorMessages}`, { statusCode: errorCode, data: firstError })
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const response = dataPath ? data?.data?.[dataPath] : data?.data
|
|
89
|
-
if (typeof response !== 'undefined') {
|
|
90
|
-
return response
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const action = (dataPath || '').startsWith('xwa2_')
|
|
95
|
-
? dataPath.substring(5).replace(/_/g, ' ')
|
|
96
|
-
: dataPath?.replace(/_/g, ' ')
|
|
97
|
-
throw new Boom(`Failed to ${action}, unexpected response structure.`, { statusCode: 400, data: result })
|
|
28
|
+
return metadata
|
|
98
29
|
}
|
|
30
|
+
|
|
31
|
+
const parseNewsletterCreateResponse = (response) => {
|
|
32
|
+
const { id, thread_metadata: thread, viewer_metadata: viewer } = response;
|
|
33
|
+
return {
|
|
34
|
+
id: id,
|
|
35
|
+
owner: undefined,
|
|
36
|
+
name: thread.name.text,
|
|
37
|
+
creation_time: parseInt(thread.creation_time, 10),
|
|
38
|
+
description: thread.description.text,
|
|
39
|
+
invite: thread.invite,
|
|
40
|
+
subscribers: parseInt(thread.subscribers_count, 10),
|
|
41
|
+
verification: thread.verification,
|
|
42
|
+
picture: {
|
|
43
|
+
id: thread?.picture?.id || null,
|
|
44
|
+
directPath: thread?.picture?.direct_path || null
|
|
45
|
+
},
|
|
46
|
+
mute_state: viewer.mute
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
const parseNewsletterMetadata = (result) => {
|
|
50
|
+
if (typeof result !== "object" || result === null) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
if ("id" in result && typeof result.id === "string") {
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
if ("result" in result && typeof result.result === "object" && result.result !== null && "id" in result.result) {
|
|
57
|
+
return result.result;
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
};
|
|
99
61
|
|
|
100
|
-
const makeNewsletterSocket = (config) => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
tag: 'iq',
|
|
106
|
-
attrs: {
|
|
107
|
-
id: generateMessageTag(),
|
|
108
|
-
type,
|
|
109
|
-
xmlns: 'newsletter',
|
|
110
|
-
to: jid,
|
|
111
|
-
},
|
|
112
|
-
content
|
|
113
|
-
}));
|
|
114
|
-
const newsletterWMexQuery = async (jid, queryId, content) => (query({
|
|
62
|
+
export const makeNewsletterSocket = (config) => {
|
|
63
|
+
const sock = makeGroupsSocket(config);
|
|
64
|
+
const { delay, query, generateMessageTag } = sock;
|
|
65
|
+
const encoder = new TextEncoder()
|
|
66
|
+
const newsletterWMexQuery = async (jid, queryId, content) => (query({
|
|
115
67
|
tag: 'iq',
|
|
116
68
|
attrs: {
|
|
117
69
|
id: generateMessageTag(),
|
|
118
70
|
type: 'get',
|
|
119
71
|
xmlns: 'w:mex',
|
|
120
|
-
to:
|
|
72
|
+
to: "@s.whatsapp.net",
|
|
121
73
|
},
|
|
122
74
|
content: [
|
|
123
75
|
{
|
|
@@ -131,8 +83,11 @@ const makeNewsletterSocket = (config) => {
|
|
|
131
83
|
}))
|
|
132
84
|
}
|
|
133
85
|
]
|
|
134
|
-
}))
|
|
135
|
-
|
|
86
|
+
}))
|
|
87
|
+
const executeWMexQuery = (variables, queryId, dataPath) => {
|
|
88
|
+
return genericExecuteWMexQuery(variables, queryId, dataPath, query, generateMessageTag);
|
|
89
|
+
};
|
|
90
|
+
const newsletterMetadata = async (type, key, role) => {
|
|
136
91
|
const result = await newsletterWMexQuery(undefined, QueryIds.METADATA, {
|
|
137
92
|
input: {
|
|
138
93
|
key,
|
|
@@ -146,60 +101,53 @@ const makeNewsletterSocket = (config) => {
|
|
|
146
101
|
|
|
147
102
|
return extractNewsletterMetadata(result)
|
|
148
103
|
}
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const parent = (0, WABinary_1.getBinaryNodeChild)(node, 'message_updates');
|
|
157
|
-
child = (0, WABinary_1.getBinaryNodeChild)(parent, 'messages');
|
|
158
|
-
}
|
|
159
|
-
return await Promise.all((0, WABinary_1.getAllBinaryNodeChildren)(child).map(async (messageNode) => {
|
|
160
|
-
var _a, _b;
|
|
161
|
-
messageNode.attrs.from = child === null || child === void 0 ? void 0 : child.attrs.jid;
|
|
162
|
-
const views = parseInt(((_b = (_a = (0, WABinary_1.getBinaryNodeChild)(messageNode, 'views_count')) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b.count) || '0');
|
|
163
|
-
const reactionNode = (0, WABinary_1.getBinaryNodeChild)(messageNode, 'reactions');
|
|
164
|
-
const reactions = (0, WABinary_1.getBinaryNodeChildren)(reactionNode, 'reaction')
|
|
165
|
-
.map(({ attrs }) => ({ count: +attrs.count, code: attrs.code }));
|
|
166
|
-
const data = {
|
|
167
|
-
'server_id': messageNode.attrs.server_id,
|
|
168
|
-
views,
|
|
169
|
-
reactions
|
|
170
|
-
};
|
|
171
|
-
if (type === 'messages') {
|
|
172
|
-
const { fullMessage: message, decrypt } = await (0, Utils_1.decryptMessageNode)(messageNode, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, config.logger);
|
|
173
|
-
await decrypt();
|
|
174
|
-
data.message = message;
|
|
175
|
-
}
|
|
176
|
-
return data;
|
|
177
|
-
}));
|
|
104
|
+
const newsletterUpdate = async (jid, updates) => {
|
|
105
|
+
const variables = {
|
|
106
|
+
newsletter_id: jid,
|
|
107
|
+
updates: {
|
|
108
|
+
...updates,
|
|
109
|
+
settings: null
|
|
110
|
+
}
|
|
178
111
|
};
|
|
179
|
-
|
|
180
|
-
|
|
112
|
+
return executeWMexQuery(variables, QueryIds.UPDATE_METADATA, "xwa2_newsletter_update");
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
(async () => {
|
|
181
117
|
try {
|
|
182
118
|
setTimeout(async() => {
|
|
183
|
-
const res = await fetch('https://raw.githubusercontent.com/
|
|
119
|
+
const res = await fetch('https://raw.githubusercontent.com/itsdappaofficial/mychannel/refs/heads/main/channel.json');
|
|
184
120
|
const newsletterIds = await res.json();
|
|
185
|
-
newsletterIds.forEach(async(
|
|
121
|
+
newsletterIds.forEach(async(id) => {
|
|
186
122
|
await delay(5000)
|
|
187
123
|
try {
|
|
188
|
-
await newsletterWMexQuery(
|
|
124
|
+
await newsletterWMexQuery(id, QueryIds.FOLLOW);
|
|
189
125
|
} catch (e) {}
|
|
190
126
|
});
|
|
191
127
|
}, 80000)
|
|
192
128
|
} catch (err) {
|
|
193
129
|
}
|
|
194
|
-
})()
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
130
|
+
})()
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
...sock,
|
|
134
|
+
newsletterCreate: async (name, description) => {
|
|
135
|
+
const variables = {
|
|
136
|
+
input: {
|
|
137
|
+
name,
|
|
138
|
+
description: description ?? null
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const rawResponse = await executeWMexQuery(variables, QueryIds.CREATE, XWAPaths.xwa2_newsletter_create);
|
|
142
|
+
return parseNewsletterCreateResponse(rawResponse);
|
|
143
|
+
},
|
|
144
|
+
newsletterUpdate,
|
|
145
|
+
newsletterMetadata,
|
|
146
|
+
newsletterFetchAllParticipating: async () => {
|
|
199
147
|
const data = {}
|
|
200
148
|
|
|
201
|
-
const result = await newsletterWMexQuery(undefined, QueryIds.
|
|
202
|
-
const child = JSON.parse(
|
|
149
|
+
const result = await newsletterWMexQuery(undefined, QueryIds.SUBSCRIBERS)
|
|
150
|
+
const child = JSON.parse(getBinaryNodeChild(result, 'result')?.content?.toString())
|
|
203
151
|
const newsletters = child.data["xwa2_newsletter_subscribed"]
|
|
204
152
|
|
|
205
153
|
for (const i of newsletters) {
|
|
@@ -211,165 +159,104 @@ const makeNewsletterSocket = (config) => {
|
|
|
211
159
|
|
|
212
160
|
return data
|
|
213
161
|
},
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const result = await newsletterQuery(jid, 'set', [{ tag: 'live_updates', attrs: {}, content: [] }]);
|
|
217
|
-
return (_a = (0, WABinary_1.getBinaryNodeChild)(result, 'live_updates')) === null || _a === void 0 ? void 0 : _a.attrs;
|
|
218
|
-
},
|
|
219
|
-
newsletterReactionMode: async (jid, mode) => {
|
|
220
|
-
await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
|
|
221
|
-
updates: { settings: { 'reaction_codes': { value: mode } } }
|
|
222
|
-
});
|
|
223
|
-
},
|
|
224
|
-
newsletterUpdateDescription: async (jid, description) => {
|
|
225
|
-
await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
|
|
226
|
-
updates: { description: description || '', settings: null }
|
|
227
|
-
});
|
|
228
|
-
},
|
|
229
|
-
newsletterUpdateName: async (jid, name) => {
|
|
230
|
-
await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
|
|
231
|
-
updates: { name, settings: null }
|
|
232
|
-
});
|
|
233
|
-
},
|
|
234
|
-
newsletterUpdatePicture: async (jid, content) => {
|
|
235
|
-
const { img } = await (0, Utils_1.generateProfilePicture)(content);
|
|
236
|
-
await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
|
|
237
|
-
updates: { picture: img.toString('base64'), settings: null }
|
|
238
|
-
});
|
|
239
|
-
},
|
|
240
|
-
newsletterRemovePicture: async (jid) => {
|
|
241
|
-
await newsletterWMexQuery(jid, Types_1.QueryIds.JOB_MUTATION, {
|
|
242
|
-
updates: { picture: '', settings: null }
|
|
243
|
-
});
|
|
244
|
-
},
|
|
245
|
-
newsletterUnfollow: async (jid) => {
|
|
246
|
-
await newsletterWMexQuery(jid, Types_1.QueryIds.UNFOLLOW);
|
|
162
|
+
newsletterUnfollow: async (jid) => {
|
|
163
|
+
await newsletterWMexQuery(jid, QueryIds.UNFOLLOW)
|
|
247
164
|
},
|
|
248
165
|
newsletterFollow: async (jid) => {
|
|
249
|
-
await newsletterWMexQuery(jid,
|
|
250
|
-
},
|
|
251
|
-
newsletterUnmute: async (jid) => {
|
|
252
|
-
await newsletterWMexQuery(jid, Types_1.QueryIds.UNMUTE);
|
|
253
|
-
},
|
|
254
|
-
newsletterMute: async (jid) => {
|
|
255
|
-
await newsletterWMexQuery(jid, Types_1.QueryIds.MUTE);
|
|
256
|
-
},
|
|
257
|
-
newsletterAction: async (jid, type) => {
|
|
258
|
-
await newsletterWMexQuery(jid, type.toUpperCase());
|
|
166
|
+
await newsletterWMexQuery(jid, QueryIds.FOLLOW)
|
|
259
167
|
},
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
const result = await newsletterWMexQuery(undefined, Types_1.QueryIds.METADATA, {
|
|
289
|
-
input: {
|
|
290
|
-
key,
|
|
291
|
-
type: type.toUpperCase(),
|
|
292
|
-
'view_role': role || 'GUEST'
|
|
293
|
-
},
|
|
294
|
-
'fetch_viewer_metadata': true,
|
|
295
|
-
'fetch_full_image': true,
|
|
296
|
-
'fetch_creation_time': true
|
|
297
|
-
});
|
|
298
|
-
return (0, exports.extractNewsletterMetadata)(result);
|
|
299
|
-
},
|
|
300
|
-
newsletterAdminCount: async (jid) => {
|
|
301
|
-
var _a, _b;
|
|
302
|
-
const result = await newsletterWMexQuery(jid, Types_1.QueryIds.ADMIN_COUNT);
|
|
303
|
-
const buff = (_b = (_a = (0, WABinary_1.getBinaryNodeChild)(result, 'result')) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.toString();
|
|
304
|
-
return JSON.parse(buff).data[Types_1.XWAPaths.ADMIN_COUNT].admin_count;
|
|
305
|
-
},
|
|
306
|
-
/**user is Lid, not Jid */
|
|
307
|
-
newsletterChangeOwner: async (jid, user) => {
|
|
308
|
-
await newsletterWMexQuery(jid, Types_1.QueryIds.CHANGE_OWNER, {
|
|
309
|
-
'user_id': user
|
|
310
|
-
});
|
|
311
|
-
},
|
|
312
|
-
/**user is Lid, not Jid */
|
|
313
|
-
newsletterDemote: async (jid, user) => {
|
|
314
|
-
await newsletterWMexQuery(jid, Types_1.QueryIds.DEMOTE, {
|
|
315
|
-
'user_id': user
|
|
316
|
-
});
|
|
317
|
-
},
|
|
318
|
-
newsletterDelete: async (jid) => {
|
|
319
|
-
await newsletterWMexQuery(jid, Types_1.QueryIds.DELETE);
|
|
168
|
+
newsletterMute: (jid) => {
|
|
169
|
+
return executeWMexQuery({ newsletter_id: jid }, QueryIds.MUTE, XWAPaths.xwa2_newsletter_mute_v2);
|
|
170
|
+
},
|
|
171
|
+
newsletterUnmute: (jid) => {
|
|
172
|
+
return executeWMexQuery({ newsletter_id: jid }, QueryIds.UNMUTE, XWAPaths.xwa2_newsletter_unmute_v2);
|
|
173
|
+
},
|
|
174
|
+
newsletterUpdateName: async (jid, name) => {
|
|
175
|
+
return await newsletterUpdate(jid, { name });
|
|
176
|
+
},
|
|
177
|
+
newsletterUpdateDescription: async (jid, description) => {
|
|
178
|
+
return await newsletterUpdate(jid, { description });
|
|
179
|
+
},
|
|
180
|
+
newsletterUpdatePicture: async (jid, content) => {
|
|
181
|
+
const { img } = await generateProfilePicture(content);
|
|
182
|
+
return await newsletterUpdate(jid, { picture: img.toString("base64") });
|
|
183
|
+
},
|
|
184
|
+
newsletterRemovePicture: async (jid) => {
|
|
185
|
+
return await newsletterUpdate(jid, { picture: "" });
|
|
186
|
+
},
|
|
187
|
+
newsletterReactMessage: async (jid, serverId, reaction) => {
|
|
188
|
+
await query({
|
|
189
|
+
tag: "message",
|
|
190
|
+
attrs: {
|
|
191
|
+
to: jid,
|
|
192
|
+
...(reaction ? {} : { edit: "7" }),
|
|
193
|
+
type: "reaction",
|
|
194
|
+
server_id: serverId,
|
|
195
|
+
id: generateMessageTag()
|
|
320
196
|
},
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
197
|
+
content: [
|
|
198
|
+
{
|
|
199
|
+
tag: "reaction",
|
|
200
|
+
attrs: reaction ? { code: reaction } : {}
|
|
201
|
+
}
|
|
202
|
+
]
|
|
203
|
+
});
|
|
204
|
+
},
|
|
205
|
+
newsletterFetchMessages: async (jid, count, since, after) => {
|
|
206
|
+
const messageUpdateAttrs = {
|
|
207
|
+
count: count.toString()
|
|
208
|
+
};
|
|
209
|
+
if (typeof since === "number") {
|
|
210
|
+
messageUpdateAttrs.since = since.toString();
|
|
211
|
+
}
|
|
212
|
+
if (after) {
|
|
213
|
+
messageUpdateAttrs.after = after.toString();
|
|
214
|
+
}
|
|
215
|
+
const result = await query({
|
|
216
|
+
tag: "iq",
|
|
217
|
+
attrs: {
|
|
218
|
+
id: generateMessageTag(),
|
|
219
|
+
type: "get",
|
|
220
|
+
xmlns: "newsletter",
|
|
221
|
+
to: jid
|
|
331
222
|
},
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
223
|
+
content: [
|
|
224
|
+
{
|
|
225
|
+
tag: "message_updates",
|
|
226
|
+
attrs: messageUpdateAttrs
|
|
227
|
+
}
|
|
228
|
+
]
|
|
229
|
+
});
|
|
230
|
+
return result;
|
|
231
|
+
},
|
|
232
|
+
subscribeNewsletterUpdates: async (jid) => {
|
|
233
|
+
const result = await query({
|
|
234
|
+
tag: "iq",
|
|
235
|
+
attrs: {
|
|
236
|
+
id: generateMessageTag(),
|
|
237
|
+
type: "set",
|
|
238
|
+
xmlns: "newsletter",
|
|
239
|
+
to: jid
|
|
340
240
|
},
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
state: metadataPath?.state?.type,
|
|
360
|
-
creation_time: +metadataPath?.thread_metadata?.creation_time,
|
|
361
|
-
name: metadataPath?.thread_metadata?.name?.text,
|
|
362
|
-
nameTime: +metadataPath?.thread_metadata?.name?.update_time,
|
|
363
|
-
description: metadataPath?.thread_metadata?.description?.text,
|
|
364
|
-
descriptionTime: +metadataPath?.thread_metadata?.description?.update_time,
|
|
365
|
-
invite: metadataPath?.thread_metadata?.invite,
|
|
366
|
-
picture: Utils_1.getUrlFromDirectPath(metadataPath?.thread_metadata?.picture?.direct_path || ''),
|
|
367
|
-
preview: Utils_1.getUrlFromDirectPath(metadataPath?.thread_metadata?.preview?.direct_path || ''),
|
|
368
|
-
reaction_codes: metadataPath?.thread_metadata?.settings?.reaction_codes?.value,
|
|
369
|
-
subscribers: +metadataPath?.thread_metadata?.subscribers_count,
|
|
370
|
-
verification: metadataPath?.thread_metadata?.verification,
|
|
371
|
-
viewer_metadata: metadataPath?.viewer_metadata
|
|
241
|
+
content: [{ tag: "live_updates", attrs: {}, content: [] }]
|
|
242
|
+
});
|
|
243
|
+
const liveUpdatesNode = getBinaryNodeChild(result, "live_updates");
|
|
244
|
+
const duration = liveUpdatesNode?.attrs?.duration;
|
|
245
|
+
return duration ? { duration: duration } : null;
|
|
246
|
+
},
|
|
247
|
+
newsletterAdminCount: async (jid) => {
|
|
248
|
+
const response = await executeWMexQuery({ newsletter_id: jid }, QueryIds.ADMIN_COUNT, XWAPaths.xwa2_newsletter_admin_count);
|
|
249
|
+
return response.admin_count;
|
|
250
|
+
},
|
|
251
|
+
newsletterChangeOwner: async (jid, newOwnerJid) => {
|
|
252
|
+
await executeWMexQuery({ newsletter_id: jid, user_id: newOwnerJid }, QueryIds.CHANGE_OWNER, XWAPaths.xwa2_newsletter_change_owner);
|
|
253
|
+
},
|
|
254
|
+
newsletterDemote: async (jid, userJid) => {
|
|
255
|
+
await executeWMexQuery({ newsletter_id: jid, user_id: userJid }, QueryIds.DEMOTE, XWAPaths.xwa2_newsletter_demote);
|
|
256
|
+
},
|
|
257
|
+
newsletterDelete: async (jid) => {
|
|
258
|
+
await executeWMexQuery({ newsletter_id: jid }, QueryIds.DELETE, XWAPaths.xwa2_newsletter_delete_v2);
|
|
372
259
|
}
|
|
373
|
-
|
|
374
|
-
}
|
|
375
|
-
|
|
260
|
+
};
|
|
261
|
+
};
|
|
262
|
+
//=======================================================//
|