@xbibzlibrary/whatsbibz 1.4.0 → 1.4.4
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/CHANGELOG.md +28 -0
- package/README.cn.md +5 -5
- package/README.id.md +5 -5
- package/README.md +5 -5
- package/SECURITY.md +6 -6
- package/WAProto/WAProto.proto +1 -0
- package/WAProto/index.d.ts +1 -0
- package/WAProto/index.js +1 -0
- package/lib/BibzWhats/banner.d.ts +1 -0
- package/lib/BibzWhats/banner.js +1 -0
- package/lib/BibzWhats/client.d.ts +1 -0
- package/lib/BibzWhats/client.js +1 -0
- package/lib/BibzWhats/device-identity.d.ts +1 -0
- package/lib/BibzWhats/device-identity.js +1 -0
- package/lib/BibzWhats/extract.d.ts +1 -0
- package/lib/BibzWhats/extract.js +1 -0
- package/lib/BibzWhats/index.d.ts +1 -0
- package/lib/BibzWhats/index.js +1 -0
- package/lib/BibzWhats/jid.d.ts +1 -0
- package/lib/BibzWhats/jid.js +1 -0
- package/lib/BibzWhats/pairing.d.ts +1 -0
- package/lib/BibzWhats/pairing.js +1 -0
- package/lib/BibzWhats/send.d.ts +1 -0
- package/lib/BibzWhats/send.js +1 -0
- package/lib/BibzWhats/version.js +5 -4
- package/lib/Defaults/index.d.ts +3 -0
- package/lib/Defaults/index.js +4 -6
- package/lib/Modded/message_builder.d.ts +1 -0
- package/lib/Modded/message_builder.js +13 -36
- package/lib/Signal/Group/ciphertext-message.d.ts +1 -0
- package/lib/Signal/Group/ciphertext-message.js +1 -0
- package/lib/Signal/Group/group-session-builder.d.ts +1 -0
- package/lib/Signal/Group/group-session-builder.js +1 -0
- package/lib/Signal/Group/group_cipher.d.ts +1 -0
- package/lib/Signal/Group/group_cipher.js +1 -0
- package/lib/Signal/Group/index.d.ts +1 -0
- package/lib/Signal/Group/index.js +1 -0
- package/lib/Signal/Group/keyhelper.d.ts +1 -0
- package/lib/Signal/Group/keyhelper.js +1 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +1 -0
- package/lib/Signal/Group/sender-chain-key.js +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +1 -0
- package/lib/Signal/Group/sender-key-message.d.ts +1 -0
- package/lib/Signal/Group/sender-key-message.js +1 -0
- package/lib/Signal/Group/sender-key-name.d.ts +1 -0
- package/lib/Signal/Group/sender-key-name.js +1 -0
- package/lib/Signal/Group/sender-key-record.d.ts +1 -0
- package/lib/Signal/Group/sender-key-record.js +1 -0
- package/lib/Signal/Group/sender-key-state.d.ts +1 -0
- package/lib/Signal/Group/sender-key-state.js +1 -0
- package/lib/Signal/Group/sender-message-key.d.ts +1 -0
- package/lib/Signal/Group/sender-message-key.js +1 -0
- package/lib/Signal/libsignal.d.ts +1 -0
- package/lib/Signal/libsignal.js +1 -0
- package/lib/Signal/lid-mapping.d.ts +1 -0
- package/lib/Signal/lid-mapping.js +1 -0
- package/lib/Socket/Client/index.d.ts +1 -0
- package/lib/Socket/Client/index.js +1 -0
- package/lib/Socket/Client/types.d.ts +1 -0
- package/lib/Socket/Client/types.js +1 -0
- package/lib/Socket/Client/websocket.d.ts +1 -0
- package/lib/Socket/Client/websocket.js +1 -0
- package/lib/Socket/business.d.ts +1 -2
- package/lib/Socket/business.js +1 -0
- package/lib/Socket/chats.d.ts +1 -0
- package/lib/Socket/chats.js +1 -0
- package/lib/Socket/communities.d.ts +1 -2
- package/lib/Socket/communities.js +12 -2
- package/lib/Socket/engine.d.ts +1 -0
- package/lib/Socket/engine.js +1 -0
- package/lib/Socket/groups.d.ts +1 -0
- package/lib/Socket/groups.js +1 -0
- package/lib/Socket/index.d.ts +1 -2
- package/lib/Socket/index.js +12 -11
- package/lib/Socket/messages-recv.d.ts +1 -2
- package/lib/Socket/messages-recv.js +13 -4
- package/lib/Socket/messages-send.d.ts +7 -2
- package/lib/Socket/messages-send.js +59 -23
- package/lib/Socket/mex.d.ts +1 -0
- package/lib/Socket/mex.js +1 -0
- package/lib/Socket/newsletter.d.ts +1 -1
- package/lib/Socket/newsletter.js +255 -432
- package/lib/Socket/socket.d.ts +1 -0
- package/lib/Socket/socket.js +20 -1
- package/lib/Types/Auth.d.ts +2 -0
- package/lib/Types/Auth.js +1 -0
- package/lib/Types/Bussines.d.ts +1 -0
- package/lib/Types/Bussines.js +1 -0
- package/lib/Types/Call.d.ts +1 -0
- package/lib/Types/Call.js +1 -0
- package/lib/Types/Chat.d.ts +1 -0
- package/lib/Types/Chat.js +1 -0
- package/lib/Types/Contact.d.ts +1 -0
- package/lib/Types/Contact.js +1 -0
- package/lib/Types/Events.d.ts +1 -0
- package/lib/Types/Events.js +1 -0
- package/lib/Types/GroupMetadata.d.ts +1 -0
- package/lib/Types/GroupMetadata.js +1 -0
- package/lib/Types/Label.d.ts +1 -0
- package/lib/Types/Label.js +1 -0
- package/lib/Types/LabelAssociation.d.ts +1 -0
- package/lib/Types/LabelAssociation.js +1 -0
- package/lib/Types/Message.d.ts +1 -0
- package/lib/Types/Message.js +1 -0
- package/lib/Types/Newsletter.d.ts +1 -0
- package/lib/Types/Newsletter.js +1 -0
- package/lib/Types/Product.d.ts +1 -0
- package/lib/Types/Product.js +1 -0
- package/lib/Types/Signal.d.ts +1 -0
- package/lib/Types/Signal.js +1 -0
- package/lib/Types/Socket.d.ts +1 -6
- package/lib/Types/Socket.js +1 -0
- package/lib/Types/State.d.ts +1 -0
- package/lib/Types/State.js +1 -0
- package/lib/Types/USync.d.ts +1 -0
- package/lib/Types/USync.js +1 -0
- package/lib/Types/index.d.ts +1 -0
- package/lib/Types/index.js +1 -0
- package/lib/Utils/auth-utils.d.ts +1 -0
- package/lib/Utils/auth-utils.js +4 -0
- package/lib/Utils/browser-utils.d.ts +1 -0
- package/lib/Utils/browser-utils.js +3 -2
- package/lib/Utils/business.d.ts +1 -0
- package/lib/Utils/business.js +1 -0
- package/lib/Utils/chat-utils.d.ts +1 -0
- package/lib/Utils/chat-utils.js +1 -0
- package/lib/Utils/companion-reg-client-utils.d.ts +1 -0
- package/lib/Utils/companion-reg-client-utils.js +1 -0
- package/lib/Utils/crypto.d.ts +1 -0
- package/lib/Utils/crypto.js +1 -0
- package/lib/Utils/decode-wa-message.d.ts +1 -0
- package/lib/Utils/decode-wa-message.js +1 -0
- package/lib/Utils/event-buffer.d.ts +1 -0
- package/lib/Utils/event-buffer.js +9 -0
- package/lib/Utils/generics.d.ts +1 -0
- package/lib/Utils/generics.js +5 -3
- package/lib/Utils/history.d.ts +1 -0
- package/lib/Utils/history.js +1 -0
- package/lib/Utils/identity-change-handler.d.ts +1 -0
- package/lib/Utils/identity-change-handler.js +1 -0
- package/lib/Utils/index.d.ts +2 -0
- package/lib/Utils/index.js +2 -0
- package/lib/Utils/link-preview.d.ts +1 -0
- package/lib/Utils/link-preview.js +18 -13
- package/lib/Utils/logger.d.ts +1 -0
- package/lib/Utils/logger.js +1 -0
- package/lib/Utils/lt-hash.d.ts +1 -0
- package/lib/Utils/lt-hash.js +1 -0
- package/lib/Utils/make-mutex.d.ts +1 -0
- package/lib/Utils/make-mutex.js +1 -0
- package/lib/Utils/message-retry-manager.d.ts +1 -0
- package/lib/Utils/message-retry-manager.js +1 -0
- package/lib/Utils/messages-media.d.ts +1 -0
- package/lib/Utils/messages-media.js +31 -94
- package/lib/Utils/messages.d.ts +5 -0
- package/lib/Utils/messages.js +50 -5
- package/lib/Utils/node-security-2026-10.d.ts +18 -0
- package/lib/Utils/node-security-2026-10.js +236 -0
- package/lib/Utils/noise-handler.d.ts +1 -0
- package/lib/Utils/noise-handler.js +1 -0
- package/lib/Utils/offline-node-processor.d.ts +2 -0
- package/lib/Utils/offline-node-processor.js +6 -0
- package/lib/Utils/platform-identity.d.ts +1 -0
- package/lib/Utils/platform-identity.js +1 -0
- package/lib/Utils/pre-key-manager.d.ts +1 -0
- package/lib/Utils/pre-key-manager.js +1 -0
- package/lib/Utils/process-message.d.ts +1 -0
- package/lib/Utils/process-message.js +1 -0
- package/lib/Utils/reporting-utils.d.ts +1 -0
- package/lib/Utils/reporting-utils.js +1 -0
- package/lib/Utils/rich-messages.d.ts +1 -0
- package/lib/Utils/rich-messages.js +1 -0
- package/lib/Utils/signal.d.ts +1 -0
- package/lib/Utils/signal.js +1 -0
- package/lib/Utils/stanza-ack.d.ts +1 -0
- package/lib/Utils/stanza-ack.js +1 -0
- package/lib/Utils/sticker-pack.d.ts +1 -0
- package/lib/Utils/sticker-pack.js +1 -0
- package/lib/Utils/sync-action-utils.d.ts +1 -0
- package/lib/Utils/sync-action-utils.js +1 -0
- package/lib/Utils/tc-token-utils.d.ts +1 -0
- package/lib/Utils/tc-token-utils.js +1 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +1 -0
- package/lib/Utils/validate-connection.d.ts +1 -0
- package/lib/Utils/validate-connection.js +1 -0
- package/lib/VoIP/audio-feeder.d.ts +1 -0
- package/lib/VoIP/audio-feeder.js +1 -0
- package/lib/VoIP/index.d.ts +1 -0
- package/lib/VoIP/index.js +1 -0
- package/lib/VoIP/relay-transport.d.ts +1 -0
- package/lib/VoIP/relay-transport.js +1 -0
- package/lib/VoIP/signaling.js +1 -0
- package/lib/VoIP/types.d.ts +1 -0
- package/lib/VoIP/types.js +1 -0
- package/lib/VoIP/wasm-engine.d.ts +1 -0
- package/lib/VoIP/wasm-engine.js +1 -0
- package/lib/VoIP/worker-bootstrap.js +2 -1
- package/lib/WABinary/constants.d.ts +1 -0
- package/lib/WABinary/constants.js +1 -0
- package/lib/WABinary/decode.d.ts +1 -0
- package/lib/WABinary/decode.js +1 -0
- package/lib/WABinary/encode.d.ts +1 -0
- package/lib/WABinary/encode.js +1 -0
- package/lib/WABinary/generic-utils.d.ts +1 -0
- package/lib/WABinary/generic-utils.js +1 -0
- package/lib/WABinary/index.d.ts +1 -0
- package/lib/WABinary/index.js +1 -0
- package/lib/WABinary/jid-utils.d.ts +1 -0
- package/lib/WABinary/jid-utils.js +1 -0
- package/lib/WABinary/types.d.ts +1 -0
- package/lib/WABinary/types.js +1 -0
- package/lib/WAM/BinaryInfo.d.ts +1 -0
- package/lib/WAM/BinaryInfo.js +1 -0
- package/lib/WAM/constants.d.ts +1 -0
- package/lib/WAM/constants.js +1 -0
- package/lib/WAM/encode.d.ts +1 -0
- package/lib/WAM/encode.js +1 -0
- package/lib/WAM/index.d.ts +1 -0
- package/lib/WAM/index.js +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +1 -0
- package/lib/WAUSync/Protocols/index.d.ts +1 -0
- package/lib/WAUSync/Protocols/index.js +1 -0
- package/lib/WAUSync/USyncQuery.d.ts +1 -0
- package/lib/WAUSync/USyncQuery.js +1 -0
- package/lib/WAUSync/USyncUser.d.ts +1 -0
- package/lib/WAUSync/USyncUser.js +1 -0
- package/lib/WAUSync/index.d.ts +1 -0
- package/lib/WAUSync/index.js +1 -0
- package/lib/assets/wasm/loader.js +1 -0
- package/lib/assets/wasm/worker-modules.js +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -1
- package/package.json +33 -14
- package/WAProto/GenerateStatics.sh +0 -3
- package/WAProto/fix-imports.js +0 -81
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @module @xbibzlibrary/whatsbibz/lib/Utils/messages-media */
|
|
1
2
|
import { Boom } from '@hapi/boom';
|
|
2
3
|
import { exec } from 'child_process';
|
|
3
4
|
import * as Crypto from 'crypto';
|
|
@@ -12,6 +13,7 @@ import { DEFAULT_ORIGIN, MEDIA_HKDF_KEY_MAPPING, MEDIA_PATH_MAP } from '../Defau
|
|
|
12
13
|
import { getBinaryNodeChild, getBinaryNodeChildBuffer, jidNormalizedUser } from '../WABinary/index.js';
|
|
13
14
|
import { aesDecryptGCM, aesEncryptGCM, hkdf } from './crypto.js';
|
|
14
15
|
import { generateMessageIDV2 } from './generics.js';
|
|
16
|
+
import { safeFetch } from './node-security-2026-10.js';
|
|
15
17
|
const getTmpFilesDirectory = () => tmpdir();
|
|
16
18
|
const getImageProcessingLibrary = async () => {
|
|
17
19
|
//@ts-ignore
|
|
@@ -295,7 +297,7 @@ export async function generateThumbnail(file, mediaType, options) {
|
|
|
295
297
|
};
|
|
296
298
|
}
|
|
297
299
|
export const getHttpStream = async (url, options = {}) => {
|
|
298
|
-
const response = await
|
|
300
|
+
const response = await safeFetch(url.toString(), {
|
|
299
301
|
dispatcher: options.dispatcher,
|
|
300
302
|
method: 'GET',
|
|
301
303
|
headers: options.headers
|
|
@@ -491,6 +493,7 @@ export const downloadEncryptedContent = async (downloadUrl, { cipherKey, iv }, {
|
|
|
491
493
|
}
|
|
492
494
|
}
|
|
493
495
|
});
|
|
496
|
+
fetched.on('error', error => output.destroy(error));
|
|
494
497
|
return fetched.pipe(output, { end: true });
|
|
495
498
|
};
|
|
496
499
|
export function extensionForMediaMessage(message) {
|
|
@@ -512,72 +515,13 @@ const isNodeRuntime = () => {
|
|
|
512
515
|
typeof process.versions.bun === 'undefined' &&
|
|
513
516
|
typeof globalThis.Deno === 'undefined');
|
|
514
517
|
};
|
|
515
|
-
export const uploadWithNodeHttp = async ({ url, filePath, headers, timeoutMs, agent }, redirectCount = 0) => {
|
|
516
|
-
if (redirectCount > 5) {
|
|
517
|
-
throw new Error('Too many redirects');
|
|
518
|
-
}
|
|
519
|
-
const parsedUrl = new URL(url);
|
|
520
|
-
const httpModule = parsedUrl.protocol === 'https:' ? await import('https') : await import('http');
|
|
521
|
-
// Get file size for Content-Length header (required for Node.js streaming)
|
|
522
|
-
const fileStats = await fs.stat(filePath);
|
|
523
|
-
const fileSize = fileStats.size;
|
|
524
|
-
return new Promise((resolve, reject) => {
|
|
525
|
-
const req = httpModule.request({
|
|
526
|
-
hostname: parsedUrl.hostname,
|
|
527
|
-
port: parsedUrl.port || (parsedUrl.protocol === 'https:' ? 443 : 80),
|
|
528
|
-
path: parsedUrl.pathname + parsedUrl.search,
|
|
529
|
-
method: 'POST',
|
|
530
|
-
headers: {
|
|
531
|
-
...headers,
|
|
532
|
-
'Content-Length': fileSize
|
|
533
|
-
},
|
|
534
|
-
agent,
|
|
535
|
-
timeout: timeoutMs
|
|
536
|
-
}, res => {
|
|
537
|
-
// Handle redirects (3xx)
|
|
538
|
-
if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
539
|
-
res.resume(); // Consume response to free resources
|
|
540
|
-
const newUrl = new URL(res.headers.location, url).toString();
|
|
541
|
-
resolve(uploadWithNodeHttp({
|
|
542
|
-
url: newUrl,
|
|
543
|
-
filePath,
|
|
544
|
-
headers,
|
|
545
|
-
timeoutMs,
|
|
546
|
-
agent
|
|
547
|
-
}, redirectCount + 1));
|
|
548
|
-
return;
|
|
549
|
-
}
|
|
550
|
-
let body = '';
|
|
551
|
-
res.on('data', chunk => (body += chunk));
|
|
552
|
-
res.on('end', () => {
|
|
553
|
-
try {
|
|
554
|
-
resolve(JSON.parse(body));
|
|
555
|
-
}
|
|
556
|
-
catch {
|
|
557
|
-
resolve(undefined);
|
|
558
|
-
}
|
|
559
|
-
});
|
|
560
|
-
});
|
|
561
|
-
req.on('error', reject);
|
|
562
|
-
req.on('timeout', () => {
|
|
563
|
-
req.destroy();
|
|
564
|
-
reject(new Error('Upload timeout'));
|
|
565
|
-
});
|
|
566
|
-
const stream = createReadStream(filePath);
|
|
567
|
-
stream.pipe(req);
|
|
568
|
-
stream.on('error', err => {
|
|
569
|
-
req.destroy();
|
|
570
|
-
reject(err);
|
|
571
|
-
});
|
|
572
|
-
});
|
|
573
|
-
};
|
|
574
518
|
const uploadWithFetch = async ({ url, filePath, headers, timeoutMs, agent }) => {
|
|
575
519
|
// Convert Node.js Readable to Web ReadableStream
|
|
576
520
|
const nodeStream = createReadStream(filePath);
|
|
577
521
|
const webStream = Readable.toWeb(nodeStream);
|
|
578
522
|
// Native fetch hanya menerima dispatcher gaya Undici, bukan https.Agent biasa (upstream #2557)
|
|
579
523
|
const dispatcher = typeof agent?.dispatch === 'function' ? agent : undefined;
|
|
580
|
-
const response = await
|
|
524
|
+
const response = await safeFetch(url, {
|
|
581
525
|
...(dispatcher ? { dispatcher } : {}),
|
|
582
526
|
method: 'POST',
|
|
583
527
|
body: webStream,
|
|
@@ -592,32 +536,15 @@ const uploadWithFetch = async ({ url, filePath, headers, timeoutMs, agent }) =>
|
|
|
592
536
|
return undefined;
|
|
593
537
|
}
|
|
594
538
|
};
|
|
539
|
+
export const uploadWithNodeHttp = async (params) => {
|
|
540
|
+
return uploadWithFetch(params);
|
|
541
|
+
};
|
|
595
542
|
/**
|
|
596
|
-
* Uploads media to WhatsApp servers.
|
|
597
|
-
*
|
|
598
|
-
* ## Why we have two upload implementations:
|
|
599
|
-
*
|
|
600
|
-
* Node.js's native `fetch` (powered by undici) has a known bug where it buffers
|
|
601
|
-
* the entire request body in memory before sending, even when using streams.
|
|
602
|
-
* This causes memory issues with large files (e.g., 1GB file = 1GB+ memory usage).
|
|
603
|
-
* See: https://github.com/nodejs/undici/issues/4058
|
|
604
|
-
*
|
|
605
|
-
* Other runtimes (Bun, Deno, browsers) correctly stream the request body without
|
|
606
|
-
* buffering, so we can use the web-standard Fetch API there.
|
|
607
|
-
*
|
|
608
|
-
* ## Future considerations:
|
|
609
|
-
* Once the undici bug is fixed, we can simplify this to use only the Fetch API
|
|
610
|
-
* across all runtimes. Monitor the GitHub issue for updates.
|
|
543
|
+
* Uploads media to WhatsApp servers using Web-standard Fetch API.
|
|
611
544
|
*/
|
|
612
545
|
const uploadMedia = async (params, logger) => {
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
return uploadWithNodeHttp(params);
|
|
616
|
-
}
|
|
617
|
-
else {
|
|
618
|
-
logger?.debug('Using web-standard Fetch API for upload');
|
|
619
|
-
return uploadWithFetch(params);
|
|
620
|
-
}
|
|
546
|
+
logger?.debug('Using web-standard Fetch API for upload');
|
|
547
|
+
return uploadWithFetch(params);
|
|
621
548
|
};
|
|
622
549
|
export const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, options }, refreshMediaConn) => {
|
|
623
550
|
return async (streamOrPath, { mediaType, fileEncSha256B64, newsletter, timeoutMs }) => {
|
|
@@ -651,22 +578,29 @@ export const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, opt
|
|
|
651
578
|
if (newsletter && mediaPath) {
|
|
652
579
|
mediaPath = mediaPath.replace('/mms/', '/newsletter/newsletter-');
|
|
653
580
|
}
|
|
581
|
+
const dispatcher = typeof fetchAgent?.dispatch === 'function' ? fetchAgent : undefined;
|
|
654
582
|
for (const { hostname } of hosts) {
|
|
655
583
|
logger.debug(`uploading to "${hostname}"`);
|
|
656
584
|
const auth = encodeURIComponent(uploadInfo.auth);
|
|
657
585
|
const url = `https://${hostname}${mediaPath}/${fileEncSha256B64}?auth=${auth}&token=${fileEncSha256B64}`;
|
|
658
586
|
let result;
|
|
659
587
|
try {
|
|
660
|
-
const
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
588
|
+
const response = await safeFetch(url, {
|
|
589
|
+
...(dispatcher ? { dispatcher } : {}),
|
|
590
|
+
method: 'POST',
|
|
591
|
+
body: reqBuffer,
|
|
592
|
+
headers: {
|
|
593
|
+
...headers,
|
|
594
|
+
'Content-Length': String(reqBuffer.length)
|
|
595
|
+
},
|
|
596
|
+
signal: timeoutMs ? AbortSignal.timeout(timeoutMs) : undefined
|
|
668
597
|
});
|
|
669
|
-
|
|
598
|
+
try {
|
|
599
|
+
result = await response.json();
|
|
600
|
+
}
|
|
601
|
+
catch {
|
|
602
|
+
result = undefined;
|
|
603
|
+
}
|
|
670
604
|
if (result?.url || result?.direct_path) {
|
|
671
605
|
urls = {
|
|
672
606
|
mediaUrl: result.url,
|
|
@@ -696,7 +630,10 @@ export const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, opt
|
|
|
696
630
|
};
|
|
697
631
|
|
|
698
632
|
const getMediaRetryKey = (mediaKey) => {
|
|
699
|
-
|
|
633
|
+
const keyBuf = typeof mediaKey === 'string'
|
|
634
|
+
? Buffer.from(mediaKey.replace('data:;base64,', ''), 'base64')
|
|
635
|
+
: mediaKey;
|
|
636
|
+
return hkdf(keyBuf, 32, { info: 'WhatsApp Media Retry Notification' });
|
|
700
637
|
};
|
|
701
638
|
/**
|
|
702
639
|
* Generate a binary node that will request the phone to re-upload the media & return the newly uploaded URL
|
package/lib/Utils/messages.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @module @xbibzlibrary/whatsbibz/lib/Utils/messages */
|
|
1
2
|
import { type Transform } from 'stream';
|
|
2
3
|
import { proto } from '../../WAProto/index.js';
|
|
3
4
|
import type { AnyMediaMessageContent, AnyMessageContent, MessageContentGenerationOptions, MessageGenerationOptions, MessageGenerationOptionsFromContent, MessageUserReceipt, WAMessage, WAMessageContent, WAMessageKey } from '../Types/index.js';
|
|
@@ -32,6 +33,10 @@ export declare const getContentType: (content: proto.IMessage | undefined) => ke
|
|
|
32
33
|
* @returns
|
|
33
34
|
*/
|
|
34
35
|
export declare const normalizeMessageContent: (content: WAMessageContent | null | undefined) => WAMessageContent | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Checks whether a message content (or any of its wrappers) is a view-once message
|
|
38
|
+
*/
|
|
39
|
+
export declare const isViewOnceMessage: (content: WAMessageContent | null | undefined) => boolean;
|
|
35
40
|
/**
|
|
36
41
|
* Extract the true message content from a message
|
|
37
42
|
* Eg. extracts the inner message from a disappearing message/view once message
|
package/lib/Utils/messages.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @module @xbibzlibrary/whatsbibz/lib/Utils/messages */
|
|
1
2
|
import { Boom } from "@hapi/boom";
|
|
2
3
|
import { randomBytes } from "crypto";
|
|
3
4
|
import { promises as fs } from "fs";
|
|
@@ -974,6 +975,43 @@ export const normalizeMessageContent = (content) => {
|
|
|
974
975
|
);
|
|
975
976
|
}
|
|
976
977
|
};
|
|
978
|
+
/**
|
|
979
|
+
* Checks whether a message content (or any of its wrappers) is a view-once message
|
|
980
|
+
*/
|
|
981
|
+
export const isViewOnceMessage = (content) => {
|
|
982
|
+
if (!content) {
|
|
983
|
+
return false;
|
|
984
|
+
}
|
|
985
|
+
const hasViewOnceFlag = (msg) =>
|
|
986
|
+
Boolean(
|
|
987
|
+
msg?.imageMessage?.viewOnce ||
|
|
988
|
+
msg?.videoMessage?.viewOnce ||
|
|
989
|
+
msg?.audioMessage?.viewOnce,
|
|
990
|
+
);
|
|
991
|
+
for (let i = 0; i < 5 && content; i++) {
|
|
992
|
+
if (
|
|
993
|
+
content.viewOnceMessage ||
|
|
994
|
+
content.viewOnceMessageV2 ||
|
|
995
|
+
content.viewOnceMessageV2Extension ||
|
|
996
|
+
content.viewOnceMessageV3 ||
|
|
997
|
+
hasViewOnceFlag(content)
|
|
998
|
+
) {
|
|
999
|
+
return true;
|
|
1000
|
+
}
|
|
1001
|
+
const inner =
|
|
1002
|
+
content.ephemeralMessage ||
|
|
1003
|
+
content.documentWithCaptionMessage ||
|
|
1004
|
+
content.editedMessage ||
|
|
1005
|
+
content.associatedChildMessage ||
|
|
1006
|
+
content.groupStatusMessage ||
|
|
1007
|
+
content.groupStatusMessageV2;
|
|
1008
|
+
if (!inner) {
|
|
1009
|
+
break;
|
|
1010
|
+
}
|
|
1011
|
+
content = inner.message;
|
|
1012
|
+
}
|
|
1013
|
+
return false;
|
|
1014
|
+
};
|
|
977
1015
|
/**
|
|
978
1016
|
* Extract the true message content from a message
|
|
979
1017
|
* Eg. extracts the inner message from a disappearing message/view once message
|
|
@@ -1158,16 +1196,17 @@ export const aggregateMessageKeysNotFromMe = (keys) => {
|
|
|
1158
1196
|
}
|
|
1159
1197
|
return Object.values(keyMap);
|
|
1160
1198
|
};
|
|
1161
|
-
const REUPLOAD_REQUIRED_STATUS = [
|
|
1199
|
+
const REUPLOAD_REQUIRED_STATUS = [403, 404, 410];
|
|
1162
1200
|
/**
|
|
1163
1201
|
* Downloads the given message. Throws an error if it's not a media message
|
|
1164
1202
|
*/
|
|
1165
1203
|
export const downloadMediaMessage = async (message, type, options, ctx) => {
|
|
1166
1204
|
const result = await downloadMsg().catch(async (error) => {
|
|
1205
|
+
const status = error?.output?.statusCode ?? error?.status;
|
|
1167
1206
|
if (
|
|
1168
1207
|
ctx &&
|
|
1169
|
-
typeof
|
|
1170
|
-
REUPLOAD_REQUIRED_STATUS.includes(
|
|
1208
|
+
typeof status === "number" && // treat errors with status as HTTP failures requiring reupload
|
|
1209
|
+
REUPLOAD_REQUIRED_STATUS.includes(status)
|
|
1171
1210
|
) {
|
|
1172
1211
|
ctx.logger.info(
|
|
1173
1212
|
{ key: message.key },
|
|
@@ -1192,12 +1231,18 @@ export const downloadMediaMessage = async (message, type, options, ctx) => {
|
|
|
1192
1231
|
if (
|
|
1193
1232
|
!media ||
|
|
1194
1233
|
typeof media !== "object" ||
|
|
1195
|
-
(!("url" in media) &&
|
|
1234
|
+
(!("url" in media) &&
|
|
1235
|
+
!("directPath" in media) &&
|
|
1236
|
+
!("thumbnailDirectPath" in media))
|
|
1196
1237
|
) {
|
|
1197
1238
|
throw new Boom(`"${contentType}" message is not a media message`);
|
|
1198
1239
|
}
|
|
1199
1240
|
let download;
|
|
1200
|
-
if (
|
|
1241
|
+
if (
|
|
1242
|
+
"thumbnailDirectPath" in media &&
|
|
1243
|
+
!("url" in media) &&
|
|
1244
|
+
!("directPath" in media)
|
|
1245
|
+
) {
|
|
1201
1246
|
download = {
|
|
1202
1247
|
directPath: media.thumbnailDirectPath,
|
|
1203
1248
|
mediaKey: media.mediaKey,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** @module @xbibzlibrary/whatsbibz/lib/Utils/node-security-2026-10 */
|
|
2
|
+
export declare const SAFE_ACCEPT_ENCODING = "gzip, deflate";
|
|
3
|
+
export declare const NODE_OCT_2026_CVES: readonly string[];
|
|
4
|
+
export declare const PATCHED_NODE_MIN_VERSIONS: Readonly<Record<number, readonly [number, number, number]>>;
|
|
5
|
+
export declare const parseNodeVersion: (versionStr?: string) => [number, number, number] | null;
|
|
6
|
+
export declare const isNodePatchedOct2026: (versionStr?: string) => boolean;
|
|
7
|
+
export declare const getNodeSecurityStatus: (versionStr?: string) => {
|
|
8
|
+
currentVersion: string;
|
|
9
|
+
patched: boolean;
|
|
10
|
+
eolLine: boolean;
|
|
11
|
+
recommendedVersion: string;
|
|
12
|
+
mitigatedByBibzWhats: boolean;
|
|
13
|
+
cves: readonly string[];
|
|
14
|
+
};
|
|
15
|
+
export declare const isNonCanonicalIpv4Host: (hostname?: string) => boolean;
|
|
16
|
+
export declare const assertSafeUrl: (inputUrl: string | URL) => URL;
|
|
17
|
+
export declare const withSafeFetchHeaders: (headers?: Record<string, string> | [string, string][] | Headers) => Record<string, string>;
|
|
18
|
+
export declare const safeFetch: (inputUrl: string | URL, init?: RequestInit & { dispatcher?: unknown }) => Promise<Response>;
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @xbibzlibrary/whatsbibz/lib/Utils/node-security-2026-10
|
|
3
|
+
* Runtime mitigations & URL/HTTP hardening for the Node.js October 21, 2026
|
|
4
|
+
* Security Release (CVE-2026-111497 Brotli RCE, CVE-2026-105482 DNS NUL truncation,
|
|
5
|
+
* CVE-2026-105483 Fullwidth-IP TLS bypass, CVE-2026-106069 & CVE-2026-106072
|
|
6
|
+
* Non-canonical IPv4 TLS hostname bypass, CVE-2026-105481, CVE-2026-106074).
|
|
7
|
+
*/
|
|
8
|
+
import { Boom } from '@hapi/boom';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Safe Accept-Encoding header value that disables automatic Brotli (`br`)
|
|
12
|
+
* decompression on outgoing HTTP/HTTPS requests to mitigate CVE-2026-111497
|
|
13
|
+
* on unpatched Node.js runtimes.
|
|
14
|
+
*/
|
|
15
|
+
export const SAFE_ACCEPT_ENCODING = 'gzip, deflate';
|
|
16
|
+
|
|
17
|
+
export const NODE_OCT_2026_CVES = Object.freeze([
|
|
18
|
+
'CVE-2026-111497',
|
|
19
|
+
'CVE-2026-105482',
|
|
20
|
+
'CVE-2026-105483',
|
|
21
|
+
'CVE-2026-106069',
|
|
22
|
+
'CVE-2026-105481',
|
|
23
|
+
'CVE-2026-106072',
|
|
24
|
+
'CVE-2026-106074',
|
|
25
|
+
'CVE-2026-106070',
|
|
26
|
+
'CVE-2026-106071',
|
|
27
|
+
'CVE-2026-106073'
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
export const PATCHED_NODE_MIN_VERSIONS = Object.freeze({
|
|
31
|
+
22: Object.freeze([22, 23, 4]),
|
|
32
|
+
24: Object.freeze([24, 22, 1]),
|
|
33
|
+
26: Object.freeze([26, 12, 1])
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const FULLWIDTH_DIGIT_OR_DOT_RE = /[\uFF10-\uFF19\uFF0E\u3002\uFF61]/;
|
|
37
|
+
const NUL_BYTE_RE = /\x00|%00/i;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Parses a Node.js semver string like "22.23.4" or "v24.22.1" into [major, minor, patch].
|
|
41
|
+
*/
|
|
42
|
+
export const parseNodeVersion = (versionStr = process?.versions?.node || '') => {
|
|
43
|
+
const cleaned = String(versionStr).trim().replace(/^v/i, '').split('-')[0];
|
|
44
|
+
const parts = cleaned.split('.').map(n => Number.parseInt(n, 10));
|
|
45
|
+
if (parts.length < 3 || parts.some(n => !Number.isFinite(n) || n < 0)) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return [parts[0], parts[1], parts[2]];
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Returns true if the given Node.js version includes the October 21, 2026 security patches
|
|
53
|
+
* (v22.23.4+, v24.22.1+, v26.12.1+, or v27+). Node 20.x and 25.x are End-of-Life and unpatched.
|
|
54
|
+
*/
|
|
55
|
+
export const isNodePatchedOct2026 = (versionStr = process?.versions?.node) => {
|
|
56
|
+
const tuple = parseNodeVersion(versionStr);
|
|
57
|
+
if (!tuple) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
const [major, minor, patch] = tuple;
|
|
61
|
+
if (major >= 27) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
const minTuple = PATCHED_NODE_MIN_VERSIONS[major];
|
|
65
|
+
if (!minTuple) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
if (minor !== minTuple[1]) {
|
|
69
|
+
return minor > minTuple[1];
|
|
70
|
+
}
|
|
71
|
+
return patch >= minTuple[2];
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Returns a structured security assessment for the current or specified Node.js runtime.
|
|
76
|
+
*/
|
|
77
|
+
export const getNodeSecurityStatus = (versionStr = process?.versions?.node) => {
|
|
78
|
+
const tuple = parseNodeVersion(versionStr);
|
|
79
|
+
const patched = isNodePatchedOct2026(versionStr);
|
|
80
|
+
const major = tuple?.[0] ?? 0;
|
|
81
|
+
let recommendedVersion = '>=22.23.4 / >=24.22.1 / >=26.12.1';
|
|
82
|
+
if (major === 22) {
|
|
83
|
+
recommendedVersion = '22.23.4';
|
|
84
|
+
}
|
|
85
|
+
else if (major === 24) {
|
|
86
|
+
recommendedVersion = '24.22.1';
|
|
87
|
+
}
|
|
88
|
+
else if (major === 26) {
|
|
89
|
+
recommendedVersion = '26.12.1';
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
currentVersion: String(versionStr || 'unknown'),
|
|
93
|
+
patched,
|
|
94
|
+
eolLine: major > 0 && major < 22 || major === 23 || major === 25,
|
|
95
|
+
recommendedVersion,
|
|
96
|
+
mitigatedByBibzWhats: true,
|
|
97
|
+
cves: NODE_OCT_2026_CVES
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Detects non-canonical IPv4 hostnames (octal 0177.0.0.1, hex 0x7f.0.0.1 / 0x7f000001,
|
|
103
|
+
* integer 2130706433, or 2/3-part shorthand 127.1 / 127.0.1) that trigger
|
|
104
|
+
* CVE-2026-106069 and CVE-2026-106072 in TLS hostname verification.
|
|
105
|
+
*/
|
|
106
|
+
export const isNonCanonicalIpv4Host = (hostname = '') => {
|
|
107
|
+
const host = String(hostname).trim().replace(/\.$/, '').toLowerCase();
|
|
108
|
+
if (!host || host.startsWith('[')) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
const labels = host.split('.');
|
|
112
|
+
const isNumericOrHexLabel = (part) => /^(?:0x[0-9a-f]+|\d+)$/i.test(part);
|
|
113
|
+
if (!labels.every(isNumericOrHexLabel)) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
// All labels are numeric or hex -> this is an IPv4 representation, not a normal domain name
|
|
117
|
+
if (labels.length !== 4) {
|
|
118
|
+
// 1-part integer (2130706433), 2-part (127.1), or 3-part (127.0.1) IPv4
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
for (const label of labels) {
|
|
122
|
+
if (/^0x/i.test(label)) {
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
if (label.length > 1 && label.startsWith('0')) {
|
|
126
|
+
// Leading zero = octal IPv4 label (e.g. 0177.0.0.1)
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
const num = Number(label);
|
|
130
|
+
if (!Number.isInteger(num) || num < 0 || num > 255) {
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Validates a URL against October 2026 Node.js DNS/TLS vulnerabilities:
|
|
139
|
+
* - Rejects NUL bytes / %00 (CVE-2026-105482)
|
|
140
|
+
* - Rejects fullwidth Unicode digits/dots in URL or hostname (CVE-2026-105483)
|
|
141
|
+
* - Rejects non-canonical IPv4 hostnames (CVE-2026-106069 & CVE-2026-106072)
|
|
142
|
+
*/
|
|
143
|
+
export const assertSafeUrl = (inputUrl) => {
|
|
144
|
+
const raw = inputUrl instanceof URL ? inputUrl.toString() : String(inputUrl ?? '');
|
|
145
|
+
if (!raw || NUL_BYTE_RE.test(raw)) {
|
|
146
|
+
throw new Boom('Unsafe URL blocked: contains NUL byte (CVE-2026-105482)', { statusCode: 400 });
|
|
147
|
+
}
|
|
148
|
+
if (FULLWIDTH_DIGIT_OR_DOT_RE.test(raw)) {
|
|
149
|
+
throw new Boom('Unsafe URL blocked: contains fullwidth IP digits/dots (CVE-2026-105483)', { statusCode: 400 });
|
|
150
|
+
}
|
|
151
|
+
const rawHostMatch = raw.match(/^[a-z][a-z0-9+.-]*:\/\/(?:[^/?#@]*@)?([^/?#:]+)/i);
|
|
152
|
+
if (rawHostMatch?.[1] && isNonCanonicalIpv4Host(rawHostMatch[1])) {
|
|
153
|
+
throw new Boom(`Unsafe non-canonical IPv4 hostname blocked: ${rawHostMatch[1]} (CVE-2026-106069 / CVE-2026-106072)`, {
|
|
154
|
+
statusCode: 400
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
let parsed;
|
|
158
|
+
try {
|
|
159
|
+
parsed = inputUrl instanceof URL ? inputUrl : new URL(raw);
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
throw new Boom(`Invalid URL: ${raw}`, { statusCode: 400 });
|
|
163
|
+
}
|
|
164
|
+
const hostname = parsed.hostname || '';
|
|
165
|
+
let decodedHost = hostname;
|
|
166
|
+
try {
|
|
167
|
+
decodedHost = decodeURIComponent(hostname);
|
|
168
|
+
}
|
|
169
|
+
catch { }
|
|
170
|
+
if (NUL_BYTE_RE.test(hostname) || NUL_BYTE_RE.test(decodedHost)) {
|
|
171
|
+
throw new Boom('Unsafe URL hostname blocked: contains NUL byte (CVE-2026-105482)', { statusCode: 400 });
|
|
172
|
+
}
|
|
173
|
+
if (FULLWIDTH_DIGIT_OR_DOT_RE.test(hostname) || FULLWIDTH_DIGIT_OR_DOT_RE.test(decodedHost)) {
|
|
174
|
+
throw new Boom('Unsafe URL hostname blocked: contains fullwidth digits (CVE-2026-105483)', { statusCode: 400 });
|
|
175
|
+
}
|
|
176
|
+
if (isNonCanonicalIpv4Host(hostname) || isNonCanonicalIpv4Host(decodedHost)) {
|
|
177
|
+
throw new Boom(`Unsafe non-canonical IPv4 hostname blocked: ${hostname} (CVE-2026-106069 / CVE-2026-106072)`, {
|
|
178
|
+
statusCode: 400
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
return parsed;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Returns a plain headers object with `accept-encoding: gzip, deflate` enforced
|
|
186
|
+
* (removing `br` / Brotli to prevent CVE-2026-111497 RCE on unpatched runtimes).
|
|
187
|
+
*/
|
|
188
|
+
export const withSafeFetchHeaders = (headers) => {
|
|
189
|
+
const out = {};
|
|
190
|
+
if (headers) {
|
|
191
|
+
if (typeof headers.entries === 'function') {
|
|
192
|
+
for (const [k, v] of headers.entries()) {
|
|
193
|
+
out[k] = v;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
else if (Array.isArray(headers)) {
|
|
197
|
+
for (const [k, v] of headers) {
|
|
198
|
+
out[k] = v;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
else if (typeof headers === 'object') {
|
|
202
|
+
Object.assign(out, headers);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
const existingKey = Object.keys(out).find(k => k.toLowerCase() === 'accept-encoding');
|
|
206
|
+
if (existingKey) {
|
|
207
|
+
const cleaned = String(out[existingKey])
|
|
208
|
+
.split(',')
|
|
209
|
+
.map(s => s.trim())
|
|
210
|
+
.filter(s => s && !/^br(?:;|$)/i.test(s))
|
|
211
|
+
.join(', ');
|
|
212
|
+
out[existingKey] = cleaned || SAFE_ACCEPT_ENCODING;
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
out['accept-encoding'] = SAFE_ACCEPT_ENCODING;
|
|
216
|
+
}
|
|
217
|
+
return out;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Hardened `fetch()` wrapper that validates the target URL (and any redirect URL)
|
|
222
|
+
* against CVE-2026-105482, CVE-2026-105483, CVE-2026-106069, CVE-2026-106072
|
|
223
|
+
* and disables Brotli (`br`) negotiation to mitigate CVE-2026-111497.
|
|
224
|
+
*/
|
|
225
|
+
export const safeFetch = async (inputUrl, init = {}) => {
|
|
226
|
+
const parsed = assertSafeUrl(inputUrl);
|
|
227
|
+
const headers = withSafeFetchHeaders(init.headers);
|
|
228
|
+
const response = await fetch(parsed.toString(), {
|
|
229
|
+
...init,
|
|
230
|
+
headers
|
|
231
|
+
});
|
|
232
|
+
if (response.url) {
|
|
233
|
+
assertSafeUrl(response.url);
|
|
234
|
+
}
|
|
235
|
+
return response;
|
|
236
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @module @xbibzlibrary/whatsbibz/lib/Utils/offline-node-processor */
|
|
1
2
|
import type { BinaryNode } from '../WABinary/index.js';
|
|
2
3
|
export type MessageType = 'message' | 'call' | 'receipt' | 'notification';
|
|
3
4
|
export type OfflineNodeProcessorDeps = {
|
|
@@ -5,6 +6,7 @@ export type OfflineNodeProcessorDeps = {
|
|
|
5
6
|
onUnexpectedError: (error: Error, msg: string) => void;
|
|
6
7
|
yieldToEventLoop: () => Promise<void>;
|
|
7
8
|
};
|
|
9
|
+
export declare const isOfflineNode: (node: BinaryNode) => boolean;
|
|
8
10
|
/**
|
|
9
11
|
* Creates a processor for offline stanza nodes that:
|
|
10
12
|
* - Queues nodes for sequential processing
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/** @module @xbibzlibrary/whatsbibz/lib/Utils/offline-node-processor */
|
|
2
|
+
/**
|
|
3
|
+
* Determines whether a binary stanza was queued on the server while the client was offline.
|
|
4
|
+
* WhatsApp sets `offline="1"` for queued stanzas and `offline="0"` for live stanzas.
|
|
5
|
+
*/
|
|
6
|
+
export const isOfflineNode = (node) => node?.attrs?.offline === '1';
|
|
1
7
|
/**
|
|
2
8
|
* Creates a processor for offline stanza nodes that:
|
|
3
9
|
* - Queues nodes for sequential processing
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @module @xbibzlibrary/whatsbibz/lib/Utils/process-message */
|
|
1
2
|
import { proto } from '../../WAProto/index.js';
|
|
2
3
|
import type { AuthenticationCreds, BaileysEventEmitter, CacheStore, SignalKeyStoreWithTransaction, SignalRepositoryWithLIDStore, SocketConfig, WAMessage, WAMessageKey } from '../Types/index.js';
|
|
3
4
|
import type { ILogger } from './logger.js';
|
package/lib/Utils/signal.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @module @xbibzlibrary/whatsbibz/lib/Utils/signal */
|
|
1
2
|
import type { SignalRepositoryWithLIDStore } from '../Types/index.js';
|
|
2
3
|
import type { AuthenticationCreds, AuthenticationState, KeyPair, SignalIdentity, SignalKeyStore, SignedKeyPair } from '../Types/Auth.js';
|
|
3
4
|
import { type BinaryNode, type FullJid } from '../WABinary/index.js';
|
package/lib/Utils/signal.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @module @xbibzlibrary/whatsbibz/lib/Utils/signal */
|
|
1
2
|
import { KEY_BUNDLE_TYPE } from '../Defaults/index.js';
|
|
2
3
|
import { assertNodeErrorFree, getBinaryNodeChild, getBinaryNodeChildBuffer, getBinaryNodeChildren, getBinaryNodeChildUInt, getServerFromDomainType, jidDecode, S_WHATSAPP_NET, WAJIDDomains } from '../WABinary/index.js';
|
|
3
4
|
import { Curve, generateSignalPubKey } from './crypto.js';
|