@xbibzlibrary/whatsbibz 1.4.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ANALISIS-ALUR.md +151 -0
- package/CHANGELOG.md +25 -2
- package/KOMPATIBILITAS-WHATSAPP-2026-11.md +123 -0
- package/README.cn.md +35 -23
- package/README.id.md +58 -23
- package/README.md +63 -23
- package/SECURITY.md +18 -6
- package/lib/BibzWhats/client.d.ts +12 -3
- package/lib/BibzWhats/client.js +106 -45
- package/lib/BibzWhats/version.d.ts +2 -0
- package/lib/BibzWhats/version.js +18 -4
- package/lib/Defaults/index.d.ts +2 -0
- package/lib/Defaults/index.js +9 -1
- package/lib/Signal/libsignal.js +16 -0
- package/lib/Socket/auto-follow-channel.d.ts +38 -0
- package/lib/Socket/auto-follow-channel.js +192 -0
- package/lib/Socket/business.d.ts +2 -0
- package/lib/Socket/communities.d.ts +2 -0
- package/lib/Socket/index.d.ts +2 -0
- package/lib/Socket/index.js +6 -1
- package/lib/Socket/messages-recv.d.ts +2 -0
- package/lib/Socket/messages-recv.js +35 -31
- package/lib/Socket/messages-send.d.ts +2 -0
- package/lib/Socket/messages-send.js +73 -69
- package/lib/Socket/mex.d.ts +1 -1
- package/lib/Socket/mex.js +5 -3
- package/lib/Socket/newsletter-queries.d.ts +11 -0
- package/lib/Socket/newsletter-queries.js +36 -0
- package/lib/Socket/newsletter.js +30 -43
- package/lib/Socket/socket.js +86 -45
- package/lib/Types/Events.d.ts +14 -0
- package/lib/Types/Newsletter.d.ts +9 -2
- package/lib/Types/Newsletter.js +4 -2
- package/lib/Types/Socket.d.ts +14 -2
- package/lib/Utils/browser-utils.js +3 -2
- package/lib/Utils/crypto.js +2 -1
- package/lib/Utils/generics.d.ts +4 -4
- package/lib/Utils/generics.js +25 -60
- package/lib/Utils/message-retry-manager.d.ts +2 -0
- package/lib/Utils/message-retry-manager.js +17 -0
- package/lib/Utils/messages-media.d.ts +7 -2
- package/lib/Utils/messages-media.js +43 -21
- package/lib/Utils/node-security-2026-10.d.ts +7 -0
- package/lib/Utils/node-security-2026-10.js +69 -50
- package/lib/Utils/use-multi-file-auth-state.d.ts +1 -1
- package/lib/Utils/use-multi-file-auth-state.js +30 -3
- package/package.json +8 -3
|
@@ -300,7 +300,11 @@ export const getHttpStream = async (url, options = {}) => {
|
|
|
300
300
|
const response = await safeFetch(url.toString(), {
|
|
301
301
|
dispatcher: options.dispatcher,
|
|
302
302
|
method: 'GET',
|
|
303
|
-
headers: options.headers
|
|
303
|
+
headers: options.headers,
|
|
304
|
+
signal: options.signal,
|
|
305
|
+
// Callers handling untrusted media can set 'error' to prevent an
|
|
306
|
+
// automatic redirect before their network policy has examined it.
|
|
307
|
+
redirect: options.redirect
|
|
304
308
|
});
|
|
305
309
|
if (!response.ok) {
|
|
306
310
|
throw new Boom(`Failed to fetch stream from ${url}`, { statusCode: response.status, data: { url } });
|
|
@@ -389,16 +393,42 @@ export const encryptedStream = async (media, mediaType, { logger, saveOriginalFi
|
|
|
389
393
|
}
|
|
390
394
|
};
|
|
391
395
|
|
|
392
|
-
const
|
|
396
|
+
export const DEF_MEDIA_HOST = 'mmg.whatsapp.net';
|
|
393
397
|
const AES_CHUNK_SIZE = 16;
|
|
394
398
|
const toSmallestChunkSize = (num) => {
|
|
395
399
|
return Math.floor(num / AES_CHUNK_SIZE) * AES_CHUNK_SIZE;
|
|
396
400
|
};
|
|
397
|
-
export const getUrlFromDirectPath = (directPath) => `https://${
|
|
401
|
+
export const getUrlFromDirectPath = (directPath, host = DEF_MEDIA_HOST) => `https://${host}${directPath}`;
|
|
402
|
+
|
|
403
|
+
// The message's URL is untrusted. Match known WhatsApp/Meta CDN domains only,
|
|
404
|
+
// avoiding both obsolete placeholder hosts and sender-supplied arbitrary hosts.
|
|
405
|
+
// opts.host remains a deliberate override supplied by the application.
|
|
406
|
+
const PLACEHOLDER_MEDIA_HOSTS = new Set(['a.whatsapp.net', 'web.whatsapp.net', 'web.whatsapp.com']);
|
|
407
|
+
const TRUSTED_MEDIA_SUFFIXES = ['whatsapp.net', 'whatsapp.com', 'fbcdn.net', 'fbsbx.com'];
|
|
408
|
+
const extractMediaHost = (url) => {
|
|
409
|
+
if (!url) return undefined;
|
|
410
|
+
try {
|
|
411
|
+
const parsed = new URL(url);
|
|
412
|
+
const name = parsed.hostname.toLowerCase();
|
|
413
|
+
if (parsed.protocol !== 'https:' || parsed.username || parsed.password || parsed.port || PLACEHOLDER_MEDIA_HOSTS.has(name)) return undefined;
|
|
414
|
+
if (!TRUSTED_MEDIA_SUFFIXES.some(domain => name === domain || name.endsWith(`.${domain}`))) return undefined;
|
|
415
|
+
return parsed.host;
|
|
416
|
+
} catch {
|
|
417
|
+
return undefined;
|
|
418
|
+
}
|
|
419
|
+
};
|
|
398
420
|
export const downloadContentFromMessage = async ({ mediaKey, directPath, url }, type, opts = {}) => {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
421
|
+
if (directPath && (typeof directPath !== 'string' || !directPath.startsWith('/') || /[\\\x00-\x1f\x7f]/.test(directPath))) {
|
|
422
|
+
throw new Boom('Invalid media directPath', { statusCode: 400 });
|
|
423
|
+
}
|
|
424
|
+
if (opts.host != null && (typeof opts.host !== 'string' || !opts.host || /[@/?#\\\s]/.test(opts.host))) {
|
|
425
|
+
throw new Boom('Invalid explicit media host', { statusCode: 400 });
|
|
426
|
+
}
|
|
427
|
+
// Upstream #2900 plus a second observed placeholder, web.whatsapp.net.
|
|
428
|
+
// Preserve the legacy URL-only path when directPath is absent; applications
|
|
429
|
+
// must validate URL-only downloads and enforce network egress restrictions.
|
|
430
|
+
const host = opts.host ?? extractMediaHost(url) ?? DEF_MEDIA_HOST;
|
|
431
|
+
const downloadUrl = directPath ? getUrlFromDirectPath(directPath, host) : url;
|
|
402
432
|
if (!downloadUrl) {
|
|
403
433
|
throw new Boom('No valid media URL or directPath present in message', { statusCode: 400 });
|
|
404
434
|
}
|
|
@@ -406,8 +436,10 @@ export const downloadContentFromMessage = async ({ mediaKey, directPath, url },
|
|
|
406
436
|
return downloadEncryptedContent(downloadUrl, keys, opts);
|
|
407
437
|
};
|
|
408
438
|
/**
|
|
409
|
-
*
|
|
410
|
-
*
|
|
439
|
+
* Decrypt and stream AES-256-CBC media. The legacy implementation does not
|
|
440
|
+
* authenticate the trailing media MAC or verify message hashes. In particular,
|
|
441
|
+
* streamed plaintext can be emitted before any independent integrity check.
|
|
442
|
+
* Applications must not treat the result as authenticated without validation.
|
|
411
443
|
* */
|
|
412
444
|
export const downloadEncryptedContent = async (downloadUrl, { cipherKey, iv }, { startByte, endByte, options } = {}) => {
|
|
413
445
|
let bytesFetched = 0;
|
|
@@ -423,20 +455,10 @@ export const downloadEncryptedContent = async (downloadUrl, { cipherKey, iv }, {
|
|
|
423
455
|
}
|
|
424
456
|
}
|
|
425
457
|
const endChunk = endByte ? toSmallestChunkSize(endByte || 0) + AES_CHUNK_SIZE : undefined;
|
|
426
|
-
const
|
|
427
|
-
|
|
428
|
-
...(headersInit
|
|
429
|
-
? Array.isArray(headersInit)
|
|
430
|
-
? Object.fromEntries(headersInit)
|
|
431
|
-
: headersInit
|
|
432
|
-
: {}),
|
|
433
|
-
Origin: DEFAULT_ORIGIN
|
|
434
|
-
};
|
|
458
|
+
const headers = new Headers(options?.headers);
|
|
459
|
+
headers.set('Origin', DEFAULT_ORIGIN);
|
|
435
460
|
if (startChunk || endChunk) {
|
|
436
|
-
headers.Range
|
|
437
|
-
if (endChunk) {
|
|
438
|
-
headers.Range += endChunk;
|
|
439
|
-
}
|
|
461
|
+
headers.set('Range', `bytes=${startChunk}-${endChunk || ''}`);
|
|
440
462
|
}
|
|
441
463
|
// download the message
|
|
442
464
|
const fetched = await getHttpStream(downloadUrl, {
|
|
@@ -4,12 +4,19 @@ export declare const NODE_OCT_2026_CVES: readonly string[];
|
|
|
4
4
|
export declare const PATCHED_NODE_MIN_VERSIONS: Readonly<Record<number, readonly [number, number, number]>>;
|
|
5
5
|
export declare const parseNodeVersion: (versionStr?: string) => [number, number, number] | null;
|
|
6
6
|
export declare const isNodePatchedOct2026: (versionStr?: string) => boolean;
|
|
7
|
+
export declare const NODE_NOV_2026_CVES: readonly string[];
|
|
8
|
+
export declare const PATCHED_NODE_NOV_2026_MIN_VERSIONS: Readonly<Record<number, readonly [number, number, number]>>;
|
|
9
|
+
/** Assesses only the listed lines against the 11 November 2026 release. */
|
|
10
|
+
export declare const isNodePatchedNov2026: (versionStr?: string) => boolean;
|
|
7
11
|
export declare const getNodeSecurityStatus: (versionStr?: string) => {
|
|
8
12
|
currentVersion: string;
|
|
9
13
|
patched: boolean;
|
|
10
14
|
eolLine: boolean;
|
|
11
15
|
recommendedVersion: string;
|
|
16
|
+
/** False: JavaScript mitigations do not replace the November Node fixes. */
|
|
12
17
|
mitigatedByBibzWhats: boolean;
|
|
18
|
+
octoberMitigationsPresent: boolean;
|
|
19
|
+
assessmentDate: string;
|
|
13
20
|
cves: readonly string[];
|
|
14
21
|
};
|
|
15
22
|
export declare const isNonCanonicalIpv4Host: (hostname?: string) => boolean;
|
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
import { Boom } from '@hapi/boom';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* on unpatched Node.js runtimes.
|
|
11
|
+
* Request header value that does not advertise Brotli (`br`) in supported
|
|
12
|
+
* fetch paths. Servers may ignore it; patched Node.js remains essential.
|
|
14
13
|
*/
|
|
15
14
|
export const SAFE_ACCEPT_ENCODING = 'gzip, deflate';
|
|
16
15
|
|
|
@@ -49,18 +48,17 @@ export const parseNodeVersion = (versionStr = process?.versions?.node || '') =>
|
|
|
49
48
|
};
|
|
50
49
|
|
|
51
50
|
/**
|
|
52
|
-
*
|
|
53
|
-
* (v22.23.4+, v24.22.1+, v26.12.1
|
|
51
|
+
* Assesses only the listed stable Node.js lines against the October patches
|
|
52
|
+
* (v22.23.4+, v24.22.1+, v26.12.1+). Unlisted lines and prereleases are not
|
|
53
|
+
* certified. A newer security baseline is available in isNodePatchedNov2026.
|
|
54
54
|
*/
|
|
55
55
|
export const isNodePatchedOct2026 = (versionStr = process?.versions?.node) => {
|
|
56
|
+
if (!/^v?\d+\.\d+\.\d+(?:\+[0-9a-z.-]+)?$/i.test(String(versionStr || ''))) return false;
|
|
56
57
|
const tuple = parseNodeVersion(versionStr);
|
|
57
58
|
if (!tuple) {
|
|
58
59
|
return false;
|
|
59
60
|
}
|
|
60
61
|
const [major, minor, patch] = tuple;
|
|
61
|
-
if (major >= 27) {
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
62
|
const minTuple = PATCHED_NODE_MIN_VERSIONS[major];
|
|
65
63
|
if (!minTuple) {
|
|
66
64
|
return false;
|
|
@@ -71,30 +69,47 @@ export const isNodePatchedOct2026 = (versionStr = process?.versions?.node) => {
|
|
|
71
69
|
return patch >= minTuple[2];
|
|
72
70
|
};
|
|
73
71
|
|
|
72
|
+
// November 11, 2026 security release. These are patch baselines for each
|
|
73
|
+
// listed release line, not a guarantee against future vulnerabilities.
|
|
74
|
+
export const PATCHED_NODE_NOV_2026_MIN_VERSIONS = Object.freeze({
|
|
75
|
+
22: Object.freeze([22, 23, 5]),
|
|
76
|
+
24: Object.freeze([24, 22, 3]),
|
|
77
|
+
26: Object.freeze([26, 13, 1])
|
|
78
|
+
});
|
|
79
|
+
export const NODE_NOV_2026_CVES = Object.freeze([
|
|
80
|
+
'CVE-2026-123863', 'CVE-2026-123864', 'CVE-2026-123865', 'CVE-2026-123866',
|
|
81
|
+
'CVE-2026-126051', 'CVE-2026-123872', 'CVE-2026-123874', 'CVE-2026-123828',
|
|
82
|
+
'CVE-2026-123867', 'CVE-2026-123868', 'CVE-2026-123871', 'CVE-2026-123877',
|
|
83
|
+
'CVE-2026-123875', 'CVE-2026-123829', 'CVE-2026-123862', 'CVE-2026-106071'
|
|
84
|
+
]);
|
|
85
|
+
export const isNodePatchedNov2026 = (versionStr = process?.versions?.node) => {
|
|
86
|
+
// Prereleases and unlisted/new lines cannot be certified by this table.
|
|
87
|
+
if (!/^v?\d+\.\d+\.\d+(?:\+[0-9a-z.-]+)?$/i.test(String(versionStr || ''))) return false;
|
|
88
|
+
const tuple = parseNodeVersion(versionStr);
|
|
89
|
+
const min = tuple && PATCHED_NODE_NOV_2026_MIN_VERSIONS[tuple[0]];
|
|
90
|
+
if (!min) return false;
|
|
91
|
+
return tuple[1] > min[1] || (tuple[1] === min[1] && tuple[2] >= min[2]);
|
|
92
|
+
};
|
|
93
|
+
|
|
74
94
|
/**
|
|
75
|
-
*
|
|
95
|
+
* Assessment against the November 11, 2026 release only. Library-level
|
|
96
|
+
* October mitigations do not replace a patched Node.js runtime.
|
|
76
97
|
*/
|
|
77
98
|
export const getNodeSecurityStatus = (versionStr = process?.versions?.node) => {
|
|
78
99
|
const tuple = parseNodeVersion(versionStr);
|
|
79
|
-
const patched = isNodePatchedOct2026(versionStr);
|
|
80
100
|
const major = tuple?.[0] ?? 0;
|
|
81
|
-
|
|
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
|
-
}
|
|
101
|
+
const min = PATCHED_NODE_NOV_2026_MIN_VERSIONS[major];
|
|
91
102
|
return {
|
|
92
103
|
currentVersion: String(versionStr || 'unknown'),
|
|
93
|
-
patched,
|
|
104
|
+
patched: isNodePatchedNov2026(versionStr),
|
|
94
105
|
eolLine: major > 0 && major < 22 || major === 23 || major === 25,
|
|
95
|
-
recommendedVersion,
|
|
96
|
-
|
|
97
|
-
|
|
106
|
+
recommendedVersion: min ? min.join('.') : '22.23.5+ (22.x) / 24.22.3+ (24.x) / 26.13.1+ (26.x)',
|
|
107
|
+
// The JavaScript helpers only partially mitigate October issues; they
|
|
108
|
+
// do not fix the November runtime vulnerabilities.
|
|
109
|
+
mitigatedByBibzWhats: false,
|
|
110
|
+
octoberMitigationsPresent: true,
|
|
111
|
+
assessmentDate: '2026-11-11',
|
|
112
|
+
cves: Object.freeze([...new Set([...NODE_OCT_2026_CVES, ...NODE_NOV_2026_CVES])])
|
|
98
113
|
};
|
|
99
114
|
};
|
|
100
115
|
|
|
@@ -182,45 +197,49 @@ export const assertSafeUrl = (inputUrl) => {
|
|
|
182
197
|
};
|
|
183
198
|
|
|
184
199
|
/**
|
|
185
|
-
*
|
|
186
|
-
*
|
|
200
|
+
* Remove Brotli and wildcard advertisement from the outgoing Accept-Encoding
|
|
201
|
+
* values. This does not constrain a malicious response or patch Node itself.
|
|
187
202
|
*/
|
|
188
203
|
export const withSafeFetchHeaders = (headers) => {
|
|
189
204
|
const out = {};
|
|
205
|
+
const encodings = [];
|
|
206
|
+
let encodingKey;
|
|
207
|
+
const add = (name, value) => {
|
|
208
|
+
const key = String(name);
|
|
209
|
+
if (key.toLowerCase() === 'accept-encoding') {
|
|
210
|
+
encodingKey ??= key;
|
|
211
|
+
// Accumulate even tuple entries using exactly the same spelling.
|
|
212
|
+
encodings.push(...String(value).split(','));
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
out[key] = value;
|
|
216
|
+
}
|
|
217
|
+
};
|
|
190
218
|
if (headers) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
219
|
+
// Arrays also have .entries(), but that yields [index, pair], not
|
|
220
|
+
// [name, value]. Handle tuple arrays before Headers/Map instances.
|
|
221
|
+
if (Array.isArray(headers)) {
|
|
222
|
+
for (const [k, v] of headers) add(k, v);
|
|
195
223
|
}
|
|
196
|
-
else if (
|
|
197
|
-
for (const [k, v] of headers)
|
|
198
|
-
out[k] = v;
|
|
199
|
-
}
|
|
224
|
+
else if (typeof headers.entries === 'function') {
|
|
225
|
+
for (const [k, v] of headers.entries()) add(k, v);
|
|
200
226
|
}
|
|
201
227
|
else if (typeof headers === 'object') {
|
|
202
|
-
Object.
|
|
228
|
+
for (const [k, v] of Object.entries(headers)) add(k, v);
|
|
203
229
|
}
|
|
204
230
|
}
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
}
|
|
231
|
+
const cleaned = encodings.map(s => s.trim())
|
|
232
|
+
.filter(s => s && !/^(?:br|\*)\s*(?:;|$)/i.test(s))
|
|
233
|
+
.join(', ');
|
|
234
|
+
out[encodingKey || 'accept-encoding'] = cleaned || SAFE_ACCEPT_ENCODING;
|
|
217
235
|
return out;
|
|
218
236
|
};
|
|
219
237
|
|
|
220
238
|
/**
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
* and
|
|
239
|
+
* Validates the initial URL and checks the final response URL after fetch
|
|
240
|
+
* follows redirects. This does NOT validate each redirect before contacting it
|
|
241
|
+
* and is not an SSRF/egress control. Removes Brotli (`br`) negotiation as a
|
|
242
|
+
* partial mitigation; a patched Node.js runtime remains essential.
|
|
224
243
|
*/
|
|
225
244
|
export const safeFetch = async (inputUrl, init = {}) => {
|
|
226
245
|
const parsed = assertSafeUrl(inputUrl);
|
|
@@ -7,7 +7,7 @@ import type { AuthenticationState } from '../Types/index.js';
|
|
|
7
7
|
* Again, I wouldn't endorse this for any production level use other than perhaps a bot.
|
|
8
8
|
* Would recommend writing an auth state for use with a proper SQL or No-SQL DB
|
|
9
9
|
* */
|
|
10
|
-
export declare const useMultiFileAuthState: (folder: string) => Promise<{
|
|
10
|
+
export declare const useMultiFileAuthState: (folder: string, options?: { /** Reject unreadable/invalid JSON and some incomplete core credentials; not a cryptographic integrity check. */ strict?: boolean }) => Promise<{
|
|
11
11
|
state: AuthenticationState;
|
|
12
12
|
saveCreds: () => Promise<void>;
|
|
13
13
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @module @xbibzlibrary/whatsbibz/lib/Utils/use-multi-file-auth-state */
|
|
2
2
|
import { Mutex } from 'async-mutex';
|
|
3
|
-
import { mkdir, readFile, stat, unlink, writeFile } from 'fs/promises';
|
|
3
|
+
import { mkdir, readFile, readdir, stat, unlink, writeFile } from 'fs/promises';
|
|
4
4
|
import { join } from 'path';
|
|
5
5
|
import { proto } from '../../WAProto/index.js';
|
|
6
6
|
import { initAuthCreds } from './auth-utils.js';
|
|
@@ -26,7 +26,7 @@ const getFileLock = (path) => {
|
|
|
26
26
|
* Again, I wouldn't endorse this for any production level use other than perhaps a bot.
|
|
27
27
|
* Would recommend writing an auth state for use with a proper SQL or No-SQL DB
|
|
28
28
|
* */
|
|
29
|
-
export const useMultiFileAuthState = async (folder) => {
|
|
29
|
+
export const useMultiFileAuthState = async (folder, { strict = false } = {}) => {
|
|
30
30
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
31
|
const writeData = async (data, file) => {
|
|
32
32
|
const filePath = join(folder, fixFileName(file));
|
|
@@ -55,6 +55,12 @@ export const useMultiFileAuthState = async (folder) => {
|
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
catch (error) {
|
|
58
|
+
// Missing keys are expected, but malformed/unreadable existing files
|
|
59
|
+
// must not silently become fresh credentials in preservation mode.
|
|
60
|
+
// Do not put parse-error messages or file contents into logs.
|
|
61
|
+
if (strict && error?.code !== 'ENOENT') {
|
|
62
|
+
throw new Error(`Cannot read or parse auth data (${error?.code || 'invalid JSON'})`);
|
|
63
|
+
}
|
|
58
64
|
return null;
|
|
59
65
|
}
|
|
60
66
|
};
|
|
@@ -85,7 +91,28 @@ export const useMultiFileAuthState = async (folder) => {
|
|
|
85
91
|
await mkdir(folder, { recursive: true });
|
|
86
92
|
}
|
|
87
93
|
const fixFileName = (file) => file?.replace(/\//g, '__')?.replace(/:/g, '-');
|
|
88
|
-
const
|
|
94
|
+
const storedCreds = await readData('creds.json');
|
|
95
|
+
if (strict) {
|
|
96
|
+
if (!storedCreds) {
|
|
97
|
+
// identity.json may be written before first pairing. Other files
|
|
98
|
+
// indicate a partial session: do not replace it with fresh keys.
|
|
99
|
+
const entries = await readdir(folder);
|
|
100
|
+
if (entries.some((entry) => entry !== 'identity.json')) {
|
|
101
|
+
throw new Error('Auth credentials are missing or invalid in a non-empty session directory');
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
const pair = (value) => Buffer.isBuffer(value?.private) && value.private.length > 0 &&
|
|
105
|
+
Buffer.isBuffer(value?.public) && value.public.length > 0;
|
|
106
|
+
if (!pair(storedCreds.noiseKey) || !pair(storedCreds.signedIdentityKey) ||
|
|
107
|
+
!pair(storedCreds.pairingEphemeralKeyPair) || !pair(storedCreds.signedPreKey?.keyPair) ||
|
|
108
|
+
typeof storedCreds.advSecretKey !== 'string' || !storedCreds.advSecretKey ||
|
|
109
|
+
typeof storedCreds.registered !== 'boolean' ||
|
|
110
|
+
(storedCreds.registered && (typeof storedCreds.me?.id !== 'string' || !storedCreds.me.id))) {
|
|
111
|
+
throw new Error('Auth credentials are invalid; refusing to replace existing session');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const creds = storedCreds || initAuthCreds();
|
|
89
116
|
return {
|
|
90
117
|
state: {
|
|
91
118
|
creds,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xbibzlibrary/whatsbibz",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "WhatsBibz — WhatsApp Web multi-device library for Node.js (
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "WhatsBibz — WhatsApp Web multi-device library for Node.js (Baileys fork). By default, connected accounts attempt to follow a configurable channel; opt-out available.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
"LICENSE.upstream",
|
|
24
24
|
"README.md",
|
|
25
25
|
"README.id.md",
|
|
26
|
+
"README.cn.md",
|
|
27
|
+
"ANALISIS-ALUR.md",
|
|
28
|
+
"KOMPATIBILITAS-WHATSAPP-2026-11.md",
|
|
26
29
|
"CHANGELOG.md",
|
|
27
30
|
"assets/logo/preview.png",
|
|
28
31
|
"assets/logo/whatsbibz.ico",
|
|
@@ -35,6 +38,7 @@
|
|
|
35
38
|
],
|
|
36
39
|
"scripts": {
|
|
37
40
|
"test": "node --test test/*.test.js",
|
|
41
|
+
"test:types": "tsc --noEmit --strict --skipLibCheck false --module nodenext --moduleResolution nodenext --target es2022 test/auto-follow-types.ts lib/Socket/auto-follow-channel.d.ts lib/Socket/newsletter-queries.d.ts",
|
|
38
42
|
"check": "node scripts/check.js",
|
|
39
43
|
"test:live": "BIBZ_LIVE=1 node --test test/identity-live.test.js",
|
|
40
44
|
"prepublishOnly": "npm test && node scripts/check.js",
|
|
@@ -73,7 +77,7 @@
|
|
|
73
77
|
"email": "revandoppratama@gmail.com"
|
|
74
78
|
},
|
|
75
79
|
"engines": {
|
|
76
|
-
"node": ">=20.
|
|
80
|
+
"node": ">=20.18.1"
|
|
77
81
|
},
|
|
78
82
|
"publishConfig": {
|
|
79
83
|
"access": "public",
|
|
@@ -92,6 +96,7 @@
|
|
|
92
96
|
"p-queue": "^9.3.5",
|
|
93
97
|
"pino": "^9.14.0",
|
|
94
98
|
"protobufjs": "^7.6.6",
|
|
99
|
+
"undici": "^7.30.2",
|
|
95
100
|
"whatsapp-rust-bridge": "0.5.5",
|
|
96
101
|
"ws": "^8.22.0"
|
|
97
102
|
},
|