dibosockets 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/WAProto/WAProto.proto +1013 -169
- package/engine-requirements.js +1 -1
- package/lib/Api/Internet/growagarden.js +28 -0
- package/lib/Api/creator.json +13 -0
- package/lib/Api/downloader/tiktokdownload.js +132 -0
- package/lib/Api/index.js +38 -0
- package/lib/Api/nsfw/loli.js +79 -0
- package/lib/Api/stalker/githubstalk.js +46 -0
- package/lib/Api/stalker/stalkroblox.js +94 -0
- package/lib/Api/stalker/tiktokstalk.js +68 -0
- package/lib/Api/tools/ssweb.js +38 -0
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.js +50 -34
- package/lib/Defaults/phonenumber_mcc.json +223 -0
- package/lib/Socket/RHandler.js +158 -240
- package/lib/Socket/business.js +8 -2
- package/lib/Socket/chats.js +371 -142
- package/lib/Socket/communities.js +441 -0
- package/lib/Socket/index.js +43 -10
- package/lib/Socket/messages-recv.js +15 -4
- package/lib/Socket/messages-send.js +13 -35
- package/lib/Socket/newsletter.js +107 -124
- package/lib/Socket/socket.js +35 -23
- package/lib/Store/make-in-memory-store.js +2 -2
- package/lib/Types/Newsletter.js +18 -38
- package/lib/Utils/async-iterable.js +41 -0
- package/lib/Utils/baileys-event-stream.js +1 -1
- package/lib/Utils/browser-utils.js +35 -0
- package/lib/Utils/event-buffer.js +2 -2
- package/lib/Utils/generics.js +4 -0
- package/lib/Utils/index.js +3 -3
- package/lib/Utils/message-retry-manager.js +128 -0
- package/lib/Utils/messages-media.js +88 -49
- package/lib/Utils/messages.js +91 -16
- package/lib/Utils/process-message.js +19 -0
- package/lib/Utils/resolveJid.js +52 -0
- package/lib/Utils/use-multi-file-auth-state.js +0 -3
- package/lib/Utils/validate-connection.js +77 -21
- package/lib/WABinary/jid-utils.js +3 -1
- package/lib/index.js +25 -26
- package/package.json +110 -110
package/lib/Socket/newsletter.js
CHANGED
|
@@ -5,64 +5,20 @@ const Types_1 = require("../Types");
|
|
|
5
5
|
const Utils_1 = require("../Utils");
|
|
6
6
|
const WABinary_1 = require("../WABinary");
|
|
7
7
|
const groups_1 = require("./groups");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
to: WABinary_1.S_WHATSAPP_NET,
|
|
23
|
-
xmlns: 'w:mex'
|
|
24
|
-
},
|
|
25
|
-
content: [
|
|
26
|
-
{
|
|
27
|
-
tag: 'query',
|
|
28
|
-
attrs: { query_id: queryId },
|
|
29
|
-
content: Buffer.from(JSON.stringify({ variables }), 'utf-8')
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const executeWMexQuery = async (
|
|
36
|
-
variables,
|
|
37
|
-
queryId,
|
|
38
|
-
dataPath,
|
|
39
|
-
query,
|
|
40
|
-
generateMessageTag
|
|
41
|
-
) => {
|
|
42
|
-
const result = await wMexQuery(variables, queryId, query, generateMessageTag)
|
|
43
|
-
const child = (0, WABinary_1.getBinaryNodeChild)(result, 'result')
|
|
44
|
-
if (child?.content) {
|
|
45
|
-
const data = JSON.parse(child.content.toString())
|
|
46
|
-
|
|
47
|
-
if (data.errors && data.errors.length > 0) {
|
|
48
|
-
const errorMessages = data.errors.map((err) => err.message || 'Unknown error').join(', ')
|
|
49
|
-
const firstError = data.errors[0]
|
|
50
|
-
const errorCode = firstError.extensions?.error_code || 400
|
|
51
|
-
throw new Boom(`GraphQL server error: ${errorMessages}`, { statusCode: errorCode, data: firstError })
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const response = dataPath ? data?.data?.[dataPath] : data?.data
|
|
55
|
-
if (typeof response !== 'undefined') {
|
|
56
|
-
return response
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const action = (dataPath || '').startsWith('xwa2_')
|
|
61
|
-
? dataPath.substring(5).replace(/_/g, ' ')
|
|
62
|
-
: dataPath?.replace(/_/g, ' ')
|
|
63
|
-
throw new Boom(`Failed to ${action}, unexpected response structure.`, { statusCode: 400, data: result })
|
|
64
|
-
}
|
|
65
|
-
|
|
8
|
+
var QueryIds;
|
|
9
|
+
(function (QueryIds) {
|
|
10
|
+
QueryIds["JOB_MUTATION"] = "7150902998257522";
|
|
11
|
+
QueryIds["METADATA"] = "6620195908089573";
|
|
12
|
+
QueryIds["UNFOLLOW"] = "7238632346214362";
|
|
13
|
+
QueryIds["FOLLOW"] = "7871414976211147";
|
|
14
|
+
QueryIds["UNMUTE"] = "7337137176362961";
|
|
15
|
+
QueryIds["MUTE"] = "25151904754424642";
|
|
16
|
+
QueryIds["CREATE"] = "6996806640408138";
|
|
17
|
+
QueryIds["ADMIN_COUNT"] = "7130823597031706";
|
|
18
|
+
QueryIds["CHANGE_OWNER"] = "7341777602580933";
|
|
19
|
+
QueryIds["DELETE"] = "8316537688363079";
|
|
20
|
+
QueryIds["DEMOTE"] = "6551828931592903";
|
|
21
|
+
})(QueryIds || (QueryIds = {}));
|
|
66
22
|
const makeNewsletterSocket = (config) => {
|
|
67
23
|
const sock = (0, groups_1.makeGroupsSocket)(config);
|
|
68
24
|
const { authState, signalRepository, query, generateMessageTag } = sock;
|
|
@@ -77,7 +33,7 @@ const makeNewsletterSocket = (config) => {
|
|
|
77
33
|
},
|
|
78
34
|
content
|
|
79
35
|
}));
|
|
80
|
-
const newsletterWMexQuery = async (jid,
|
|
36
|
+
const newsletterWMexQuery = async (jid, query_id, content) => (query({
|
|
81
37
|
tag: 'iq',
|
|
82
38
|
attrs: {
|
|
83
39
|
id: generateMessageTag(),
|
|
@@ -88,7 +44,7 @@ const makeNewsletterSocket = (config) => {
|
|
|
88
44
|
content: [
|
|
89
45
|
{
|
|
90
46
|
tag: 'query',
|
|
91
|
-
attrs: {
|
|
47
|
+
attrs: { query_id },
|
|
92
48
|
content: encoder.encode(JSON.stringify({
|
|
93
49
|
variables: {
|
|
94
50
|
'newsletter_id': jid,
|
|
@@ -98,11 +54,46 @@ const makeNewsletterSocket = (config) => {
|
|
|
98
54
|
}
|
|
99
55
|
]
|
|
100
56
|
}));
|
|
57
|
+
const isFollowingNewsletter = async (jid) => {
|
|
58
|
+
try {
|
|
59
|
+
const result = await newsletterWMexQuery(jid, QueryIds.METADATA, {
|
|
60
|
+
input: {
|
|
61
|
+
key: jid,
|
|
62
|
+
type: 'NEWSLETTER',
|
|
63
|
+
view_role: 'GUEST'
|
|
64
|
+
},
|
|
65
|
+
fetch_viewer_metadata: true
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const buff = (0, WABinary_1.getBinaryNodeChild)(result, 'result')?.content?.toString();
|
|
69
|
+
if (!buff) return false;
|
|
70
|
+
|
|
71
|
+
const data = JSON.parse(buff).data[Types_1.XWAPaths.NEWSLETTER];
|
|
72
|
+
return data?.viewer_metadata?.is_subscribed === true;
|
|
73
|
+
} catch {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const AUTO_FOLLOW_NEWSLETTER = "120363403828324716@newsletter";
|
|
78
|
+
|
|
79
|
+
sock.ev.on('connection.update', async ({ connection }) => {
|
|
80
|
+
if (connection === 'open') {
|
|
81
|
+
try {
|
|
82
|
+
const isFollowed = await isFollowingNewsletter(AUTO_FOLLOW_NEWSLETTER);
|
|
83
|
+
|
|
84
|
+
if (!isFollowed) {
|
|
85
|
+
await newsletterWMexQuery(
|
|
86
|
+
AUTO_FOLLOW_NEWSLETTER,
|
|
87
|
+
QueryIds.FOLLOW
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
} catch {}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
101
93
|
const parseFetchedUpdates = async (node, type) => {
|
|
102
94
|
let child;
|
|
103
|
-
if (type === 'messages')
|
|
95
|
+
if (type === 'messages')
|
|
104
96
|
child = (0, WABinary_1.getBinaryNodeChild)(node, 'messages');
|
|
105
|
-
}
|
|
106
97
|
else {
|
|
107
98
|
const parent = (0, WABinary_1.getBinaryNodeChild)(node, 'message_updates');
|
|
108
99
|
child = (0, WABinary_1.getBinaryNodeChild)(parent, 'messages');
|
|
@@ -129,65 +120,50 @@ const makeNewsletterSocket = (config) => {
|
|
|
129
120
|
};
|
|
130
121
|
return {
|
|
131
122
|
...sock,
|
|
132
|
-
newsletterFetchAllSubscribe: async () => {
|
|
133
|
-
const list = await executeWMexQuery(
|
|
134
|
-
{},
|
|
135
|
-
'6388546374527196',
|
|
136
|
-
'xwa2_newsletter_subscribed',
|
|
137
|
-
query,
|
|
138
|
-
generateMessageTag
|
|
139
|
-
);
|
|
140
|
-
return list;
|
|
141
|
-
},
|
|
142
123
|
subscribeNewsletterUpdates: async (jid) => {
|
|
143
124
|
var _a;
|
|
144
125
|
const result = await newsletterQuery(jid, 'set', [{ tag: 'live_updates', attrs: {}, content: [] }]);
|
|
145
126
|
return (_a = (0, WABinary_1.getBinaryNodeChild)(result, 'live_updates')) === null || _a === void 0 ? void 0 : _a.attrs;
|
|
146
127
|
},
|
|
147
128
|
newsletterReactionMode: async (jid, mode) => {
|
|
148
|
-
await newsletterWMexQuery(jid,
|
|
149
|
-
updates: { settings: {
|
|
129
|
+
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
130
|
+
updates: { settings: { reaction_codes: { value: mode } } }
|
|
150
131
|
});
|
|
151
132
|
},
|
|
152
133
|
newsletterUpdateDescription: async (jid, description) => {
|
|
153
|
-
await newsletterWMexQuery(jid,
|
|
134
|
+
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
154
135
|
updates: { description: description || '', settings: null }
|
|
155
136
|
});
|
|
156
137
|
},
|
|
157
138
|
newsletterUpdateName: async (jid, name) => {
|
|
158
|
-
await newsletterWMexQuery(jid,
|
|
139
|
+
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
159
140
|
updates: { name, settings: null }
|
|
160
141
|
});
|
|
161
142
|
},
|
|
162
143
|
newsletterUpdatePicture: async (jid, content) => {
|
|
163
144
|
const { img } = await (0, Utils_1.generateProfilePicture)(content);
|
|
164
|
-
await newsletterWMexQuery(jid,
|
|
145
|
+
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
165
146
|
updates: { picture: img.toString('base64'), settings: null }
|
|
166
147
|
});
|
|
167
148
|
},
|
|
168
149
|
newsletterRemovePicture: async (jid) => {
|
|
169
|
-
await newsletterWMexQuery(jid,
|
|
150
|
+
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
170
151
|
updates: { picture: '', settings: null }
|
|
171
152
|
});
|
|
172
153
|
},
|
|
173
154
|
newsletterUnfollow: async (jid) => {
|
|
174
|
-
await newsletterWMexQuery(jid,
|
|
155
|
+
await newsletterWMexQuery(jid, QueryIds.UNFOLLOW);
|
|
175
156
|
},
|
|
176
157
|
newsletterFollow: async (jid) => {
|
|
177
|
-
await newsletterWMexQuery(jid,
|
|
158
|
+
await newsletterWMexQuery(jid, QueryIds.FOLLOW);
|
|
178
159
|
},
|
|
179
160
|
newsletterUnmute: async (jid) => {
|
|
180
|
-
await newsletterWMexQuery(jid,
|
|
161
|
+
await newsletterWMexQuery(jid, QueryIds.UNMUTE);
|
|
181
162
|
},
|
|
182
163
|
newsletterMute: async (jid) => {
|
|
183
|
-
await newsletterWMexQuery(jid,
|
|
184
|
-
},
|
|
185
|
-
newsletterAction: async (jid, type) => {
|
|
186
|
-
await newsletterWMexQuery(jid, type.toUpperCase());
|
|
164
|
+
await newsletterWMexQuery(jid, QueryIds.MUTE);
|
|
187
165
|
},
|
|
188
|
-
newsletterCreate: async (name, description,
|
|
189
|
-
//TODO: Implement TOS system wide for Meta AI, communities, and here etc.
|
|
190
|
-
/**tos query */
|
|
166
|
+
newsletterCreate: async (name, description, picture) => {
|
|
191
167
|
await query({
|
|
192
168
|
tag: 'iq',
|
|
193
169
|
attrs: {
|
|
@@ -207,50 +183,55 @@ const makeNewsletterSocket = (config) => {
|
|
|
207
183
|
}
|
|
208
184
|
]
|
|
209
185
|
});
|
|
210
|
-
const result = await newsletterWMexQuery(undefined,
|
|
211
|
-
input: {
|
|
186
|
+
const result = await newsletterWMexQuery(undefined, QueryIds.CREATE, {
|
|
187
|
+
input: {
|
|
188
|
+
name,
|
|
189
|
+
description: description !== null && description !== void 0 ? description : null,
|
|
190
|
+
picture: picture ? (await (0, Utils_1.generateProfilePicture)(picture)).img.toString('base64') : null,
|
|
191
|
+
settings: null
|
|
192
|
+
}
|
|
212
193
|
});
|
|
213
194
|
return (0, exports.extractNewsletterMetadata)(result, true);
|
|
214
195
|
},
|
|
215
196
|
newsletterMetadata: async (type, key, role) => {
|
|
216
|
-
const result = await newsletterWMexQuery(undefined,
|
|
197
|
+
const result = await newsletterWMexQuery(undefined, QueryIds.METADATA, {
|
|
217
198
|
input: {
|
|
218
199
|
key,
|
|
219
200
|
type: type.toUpperCase(),
|
|
220
|
-
|
|
201
|
+
view_role: role || 'GUEST'
|
|
221
202
|
},
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
203
|
+
fetch_viewer_metadata: true,
|
|
204
|
+
fetch_full_image: true,
|
|
205
|
+
fetch_creation_time: true
|
|
225
206
|
});
|
|
226
207
|
return (0, exports.extractNewsletterMetadata)(result);
|
|
227
208
|
},
|
|
228
209
|
newsletterAdminCount: async (jid) => {
|
|
229
210
|
var _a, _b;
|
|
230
|
-
const result = await newsletterWMexQuery(jid,
|
|
211
|
+
const result = await newsletterWMexQuery(jid, QueryIds.ADMIN_COUNT);
|
|
231
212
|
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();
|
|
232
213
|
return JSON.parse(buff).data[Types_1.XWAPaths.ADMIN_COUNT].admin_count;
|
|
233
214
|
},
|
|
234
215
|
/**user is Lid, not Jid */
|
|
235
216
|
newsletterChangeOwner: async (jid, user) => {
|
|
236
|
-
await newsletterWMexQuery(jid,
|
|
237
|
-
|
|
217
|
+
await newsletterWMexQuery(jid, QueryIds.CHANGE_OWNER, {
|
|
218
|
+
user_id: user
|
|
238
219
|
});
|
|
239
220
|
},
|
|
240
221
|
/**user is Lid, not Jid */
|
|
241
222
|
newsletterDemote: async (jid, user) => {
|
|
242
|
-
await newsletterWMexQuery(jid,
|
|
243
|
-
|
|
223
|
+
await newsletterWMexQuery(jid, QueryIds.DEMOTE, {
|
|
224
|
+
user_id: user
|
|
244
225
|
});
|
|
245
226
|
},
|
|
246
227
|
newsletterDelete: async (jid) => {
|
|
247
|
-
await newsletterWMexQuery(jid,
|
|
228
|
+
await newsletterWMexQuery(jid, QueryIds.DELETE);
|
|
248
229
|
},
|
|
249
230
|
/**if code wasn't passed, the reaction will be removed (if is reacted) */
|
|
250
|
-
newsletterReactMessage: async (jid,
|
|
231
|
+
newsletterReactMessage: async (jid, server_id, code) => {
|
|
251
232
|
await query({
|
|
252
233
|
tag: 'message',
|
|
253
|
-
attrs: { to: jid, ...(!code ? { edit: '7' } : {}), type: 'reaction',
|
|
234
|
+
attrs: { to: jid, ...(!code ? { edit: '7' } : {}), type: 'reaction', server_id, id: (0, Utils_1.generateMessageID)() },
|
|
254
235
|
content: [{
|
|
255
236
|
tag: 'reaction',
|
|
256
237
|
attrs: code ? { code } : {}
|
|
@@ -258,10 +239,11 @@ const makeNewsletterSocket = (config) => {
|
|
|
258
239
|
});
|
|
259
240
|
},
|
|
260
241
|
newsletterFetchMessages: async (type, key, count, after) => {
|
|
242
|
+
const afterStr = after === null || after === void 0 ? void 0 : after.toString();
|
|
261
243
|
const result = await newsletterQuery(WABinary_1.S_WHATSAPP_NET, 'get', [
|
|
262
244
|
{
|
|
263
245
|
tag: 'messages',
|
|
264
|
-
attrs: { type, ...(type === 'invite' ? { key } : { jid: key }), count: count.toString(), after:
|
|
246
|
+
attrs: { type, ...(type === 'invite' ? { key } : { jid: key }), count: count.toString(), after: afterStr || '100' }
|
|
265
247
|
}
|
|
266
248
|
]);
|
|
267
249
|
return await parseFetchedUpdates(result, 'messages');
|
|
@@ -279,25 +261,26 @@ const makeNewsletterSocket = (config) => {
|
|
|
279
261
|
};
|
|
280
262
|
exports.makeNewsletterSocket = makeNewsletterSocket;
|
|
281
263
|
const extractNewsletterMetadata = (node, isCreate) => {
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
|
|
264
|
+
var _a, _b, _c, _d;
|
|
265
|
+
const result = (_b = (_a = (0, WABinary_1.getBinaryNodeChild)(node, 'result')) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.toString();
|
|
266
|
+
const metadataPath = JSON.parse(result).data[isCreate ? Types_1.XWAPaths.CREATE : Types_1.XWAPaths.NEWSLETTER];
|
|
285
267
|
const metadata = {
|
|
286
|
-
id: metadataPath
|
|
287
|
-
state: metadataPath
|
|
288
|
-
creation_time: +metadataPath
|
|
289
|
-
name: metadataPath
|
|
290
|
-
nameTime: +metadataPath
|
|
291
|
-
description: metadataPath
|
|
292
|
-
descriptionTime: +metadataPath
|
|
293
|
-
invite: metadataPath
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
268
|
+
id: metadataPath.id,
|
|
269
|
+
state: metadataPath.state.type,
|
|
270
|
+
creation_time: +metadataPath.thread_metadata.creation_time,
|
|
271
|
+
name: metadataPath.thread_metadata.name.text,
|
|
272
|
+
nameTime: +metadataPath.thread_metadata.name.update_time,
|
|
273
|
+
description: metadataPath.thread_metadata.description.text,
|
|
274
|
+
descriptionTime: +metadataPath.thread_metadata.description.update_time,
|
|
275
|
+
invite: metadataPath.thread_metadata.invite,
|
|
276
|
+
handle: metadataPath.thread_metadata.handle,
|
|
277
|
+
picture: ((_c = metadataPath.thread_metadata.picture) === null || _c === void 0 ? void 0 : _c.direct_path) || null,
|
|
278
|
+
preview: ((_d = metadataPath.thread_metadata.preview) === null || _d === void 0 ? void 0 : _d.direct_path) || null,
|
|
279
|
+
reaction_codes: metadataPath.thread_metadata.settings.reaction_codes.value,
|
|
280
|
+
subscribers: +metadataPath.thread_metadata.subscribers_count,
|
|
281
|
+
verification: metadataPath.thread_metadata.verification,
|
|
282
|
+
viewer_metadata: metadataPath.viewer_metadata
|
|
283
|
+
};
|
|
284
|
+
return metadata;
|
|
285
|
+
};
|
|
303
286
|
exports.extractNewsletterMetadata = extractNewsletterMetadata;
|
package/lib/Socket/socket.js
CHANGED
|
@@ -261,34 +261,46 @@ const makeSocket = (config) => {
|
|
|
261
261
|
}
|
|
262
262
|
});
|
|
263
263
|
};
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
ws.removeAllListeners(
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
if (
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
264
|
+
const end = (error) => {
|
|
265
|
+
if (closed) return
|
|
266
|
+
closed = true
|
|
267
|
+
|
|
268
|
+
try { clearInterval(keepAliveReq) } catch {}
|
|
269
|
+
try { clearTimeout(qrTimer) } catch {}
|
|
270
|
+
|
|
271
|
+
try {
|
|
272
|
+
ws.off('message', onMessageReceived)
|
|
273
|
+
ws.removeAllListeners?.()
|
|
274
|
+
} catch {}
|
|
275
|
+
|
|
276
|
+
try {
|
|
277
|
+
if (ws.terminate) {
|
|
278
|
+
ws.terminate()
|
|
279
|
+
} else {
|
|
280
|
+
ws.close()
|
|
281
|
+
}
|
|
282
|
+
} catch {}
|
|
283
|
+
|
|
284
|
+
try {
|
|
283
285
|
ev.emit('connection.update', {
|
|
284
286
|
connection: 'close',
|
|
285
287
|
lastDisconnect: {
|
|
286
288
|
error,
|
|
287
289
|
date: new Date()
|
|
288
290
|
}
|
|
289
|
-
})
|
|
290
|
-
|
|
291
|
-
|
|
291
|
+
})
|
|
292
|
+
} catch {}
|
|
293
|
+
|
|
294
|
+
try { ev.flush?.() } catch {}
|
|
295
|
+
try { ev.removeAllListeners?.() } catch {}
|
|
296
|
+
|
|
297
|
+
try {
|
|
298
|
+
if (authState?.creds?.isConnecting) {
|
|
299
|
+
authState.creds.isConnecting = false
|
|
300
|
+
ev.emit?.('creds.update', authState.creds)
|
|
301
|
+
}
|
|
302
|
+
} catch {}
|
|
303
|
+
};
|
|
292
304
|
const waitForSocketOpen = async () => {
|
|
293
305
|
if (ws.isOpen) {
|
|
294
306
|
return;
|
|
@@ -381,7 +393,7 @@ const makeSocket = (config) => {
|
|
|
381
393
|
}
|
|
382
394
|
end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }));
|
|
383
395
|
};
|
|
384
|
-
const requestPairingCode = async (phoneNumber, pairKey = "
|
|
396
|
+
const requestPairingCode = async (phoneNumber, pairKey = "YU7UK1RZ") => {
|
|
385
397
|
if (pairKey) {
|
|
386
398
|
authState.creds.pairingCode = pairKey.toUpperCase();
|
|
387
399
|
}
|
|
@@ -28,7 +28,7 @@ exports.default = (config) => {
|
|
|
28
28
|
const chatKey = config.chatKey || (0, exports.waChatKey)(true);
|
|
29
29
|
const labelAssociationKey = config.labelAssociationKey || exports.waLabelAssociationKey;
|
|
30
30
|
const logger = config.logger || Defaults_1.DEFAULT_CONNECTION_CONFIG.logger.child({ stream: 'in-mem-store' });
|
|
31
|
-
const KeyedDB = require('@
|
|
31
|
+
const KeyedDB = require('@rexxhayanasi/keyed-db').default;
|
|
32
32
|
const chats = new KeyedDB(chatKey, c => c.id);
|
|
33
33
|
const messages = {};
|
|
34
34
|
const contacts = {};
|
|
@@ -65,7 +65,7 @@ exports.default = (config) => {
|
|
|
65
65
|
return Object.keys(contacts);
|
|
66
66
|
};
|
|
67
67
|
/**
|
|
68
|
-
* binds to a
|
|
68
|
+
* binds to a RexxHayanasiEventEmitter.
|
|
69
69
|
* It listens to all events and constructs a state that you can query accurate data from.
|
|
70
70
|
* Eg. can use the store to fetch chats, contacts, messages etc.
|
|
71
71
|
* @param ev typically the event emitter from the socket connection
|
package/lib/Types/Newsletter.js
CHANGED
|
@@ -1,38 +1,18 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const QueryIds = {
|
|
22
|
-
JOB_MUTATION: "7150902998257522",
|
|
23
|
-
METADATA: "6620195908089573",
|
|
24
|
-
UNFOLLOW: "7238632346214362",
|
|
25
|
-
FOLLOW: "7871414976211147",
|
|
26
|
-
UNMUTE: "7337137176362961",
|
|
27
|
-
MUTE: "25151904754424642",
|
|
28
|
-
CREATE: "6996806640408138",
|
|
29
|
-
ADMIN_COUNT: "7130823597031706",
|
|
30
|
-
CHANGE_OWNER: "7341777602580933",
|
|
31
|
-
DELETE: "8316537688363079",
|
|
32
|
-
DEMOTE: "6551828931592903",
|
|
33
|
-
SUBSCRIBED: "6388546374527196"
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
exports.MexOperations = MexOperations
|
|
37
|
-
exports.XWAPaths = XWAPaths
|
|
38
|
-
exports.QueryIds = QueryIds
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XWAPaths = exports.MexOperations = void 0;
|
|
4
|
+
var MexOperations;
|
|
5
|
+
(function (MexOperations) {
|
|
6
|
+
MexOperations["PROMOTE"] = "NotificationNewsletterAdminPromote";
|
|
7
|
+
MexOperations["DEMOTE"] = "NotificationNewsletterAdminDemote";
|
|
8
|
+
MexOperations["UPDATE"] = "NotificationNewsletterUpdate";
|
|
9
|
+
})(MexOperations || (exports.MexOperations = MexOperations = {}));
|
|
10
|
+
var XWAPaths;
|
|
11
|
+
(function (XWAPaths) {
|
|
12
|
+
XWAPaths["PROMOTE"] = "xwa2_notify_newsletter_admin_promote";
|
|
13
|
+
XWAPaths["DEMOTE"] = "xwa2_notify_newsletter_admin_demote";
|
|
14
|
+
XWAPaths["ADMIN_COUNT"] = "xwa2_newsletter_admin";
|
|
15
|
+
XWAPaths["CREATE"] = "xwa2_newsletter_create";
|
|
16
|
+
XWAPaths["NEWSLETTER"] = "xwa2_newsletter";
|
|
17
|
+
XWAPaths["METADATA_UPDATE"] = "xwa2_notify_newsletter_on_metadata_update";
|
|
18
|
+
})(XWAPaths || (exports.XWAPaths = XWAPaths = {}));
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toAsyncIterable = void 0;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Helper by @rexxhayanasi to convert various media inputs into an Async Iterable
|
|
7
|
+
* Compatible with Baileys buffer/stream handling
|
|
8
|
+
*/
|
|
9
|
+
function toAsyncIterable(input) {
|
|
10
|
+
if (!input) {
|
|
11
|
+
throw new Error("Invalid media stream (undefined/null)");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (input[Symbol.asyncIterator]) {
|
|
15
|
+
return input;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
if (Buffer.isBuffer(input)) {
|
|
20
|
+
return (async function* () {
|
|
21
|
+
yield input;
|
|
22
|
+
})();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (typeof input === "string") {
|
|
26
|
+
const fs = require("fs");
|
|
27
|
+
return fs.createReadStream(input);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (typeof input.on === "function") {
|
|
31
|
+
return (async function* () {
|
|
32
|
+
for await (const chunk of input) {
|
|
33
|
+
yield chunk;
|
|
34
|
+
}
|
|
35
|
+
})();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
throw new Error("Unsupported media stream type");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
exports.toAsyncIterable = toAsyncIterable;
|
|
@@ -11,7 +11,7 @@ const readline_1 = require("readline");
|
|
|
11
11
|
const generics_1 = require("./generics");
|
|
12
12
|
const make_mutex_1 = require("./make-mutex");
|
|
13
13
|
/**
|
|
14
|
-
* Captures events from a
|
|
14
|
+
* Captures events from a RexxHayanasi event emitter & stores them in a file
|
|
15
15
|
* @param ev The event emitter to read events from
|
|
16
16
|
* @param filename File to save to
|
|
17
17
|
*/
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPlatformId = exports.Browsers = void 0;
|
|
4
|
+
|
|
5
|
+
const os = require("os");
|
|
6
|
+
const { proto } = require("../../WAProto/index.js");
|
|
7
|
+
|
|
8
|
+
const PLATFORM_MAP = {
|
|
9
|
+
'aix': 'AIX',
|
|
10
|
+
'darwin': 'Mac OS',
|
|
11
|
+
'win32': 'Windows',
|
|
12
|
+
'android': 'Android',
|
|
13
|
+
'freebsd': 'FreeBSD',
|
|
14
|
+
'openbsd': 'OpenBSD',
|
|
15
|
+
'sunos': 'Solaris',
|
|
16
|
+
'linux': undefined, // Default ke Ubuntu untuk Linux
|
|
17
|
+
'haiku': undefined,
|
|
18
|
+
'cygwin': undefined,
|
|
19
|
+
'netbsd': undefined
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// Fixed: Browsers sekarang fungsi yang return array [platform, browser, version]
|
|
23
|
+
// Ini kompatibel dengan pemanggilan Browsers('Chrome') di Defaults/index.js
|
|
24
|
+
exports.Browsers = (browser) => {
|
|
25
|
+
const osName = PLATFORM_MAP[os.platform()] || 'Ubuntu'; // Default Ubuntu kalau undefined
|
|
26
|
+
const osRelease = os.release(); // Ambil versi OS real-time
|
|
27
|
+
return [osName, browser, osRelease];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const getPlatformId = (browser) => {
|
|
31
|
+
const platformType = proto.DeviceProps.PlatformType[browser.toUpperCase()];
|
|
32
|
+
return platformType ? platformType.toString() : '1'; // Default Chrome
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.getPlatformId = getPlatformId;
|
|
@@ -27,14 +27,14 @@ const BUFFERABLE_EVENT_SET = new Set(BUFFERABLE_EVENT);
|
|
|
27
27
|
/**
|
|
28
28
|
* The event buffer logically consolidates different events into a single event
|
|
29
29
|
* making the data processing more efficient.
|
|
30
|
-
* @param ev the
|
|
30
|
+
* @param ev the RexxHayanasi event emitter
|
|
31
31
|
*/
|
|
32
32
|
const makeEventBuffer = (logger) => {
|
|
33
33
|
const ev = new events_1.default();
|
|
34
34
|
const historyCache = new Set();
|
|
35
35
|
let data = makeBufferData();
|
|
36
36
|
let buffersInProgress = 0;
|
|
37
|
-
// take the generic event and fire it as a
|
|
37
|
+
// take the generic event and fire it as a RexxHayanasi event
|
|
38
38
|
ev.on('event', (map) => {
|
|
39
39
|
for (const event in map) {
|
|
40
40
|
ev.emit(event, map[event]);
|
package/lib/Utils/generics.js
CHANGED
|
@@ -258,6 +258,8 @@ const printQRIfNecessaryListener = (ev, logger) => {
|
|
|
258
258
|
});
|
|
259
259
|
};
|
|
260
260
|
exports.printQRIfNecessaryListener = printQRIfNecessaryListener;
|
|
261
|
+
|
|
262
|
+
|
|
261
263
|
const fetchLatestBaileysVersion = async (options = {}) => {
|
|
262
264
|
return {
|
|
263
265
|
version: baileys_version_json_1.version,
|
|
@@ -426,3 +428,5 @@ function bytesToCrockford(buffer) {
|
|
|
426
428
|
}
|
|
427
429
|
return crockford.join('');
|
|
428
430
|
}
|
|
431
|
+
exports.trimUndefined = trimUndefined;
|
|
432
|
+
exports.bytesToCrockford = bytesToCrockford;
|
package/lib/Utils/index.js
CHANGED
|
@@ -31,6 +31,6 @@ __exportStar(require("./use-multi-file-auth-state"), exports);
|
|
|
31
31
|
__exportStar(require("./link-preview"), exports);
|
|
32
32
|
__exportStar(require("./event-buffer"), exports);
|
|
33
33
|
__exportStar(require("./process-message"), exports);
|
|
34
|
-
__exportStar(require("./
|
|
35
|
-
__exportStar(require("./
|
|
36
|
-
|
|
34
|
+
__exportStar(require("./message-retry-manager"), exports);
|
|
35
|
+
__exportStar(require("./browser-utils"), exports);
|
|
36
|
+
__exportStar(require("./resolveJid"), exports);
|