@zelynskybail/baileys 2.6.34 → 2.6.35

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zelynskybail/baileys",
3
3
  "type": "module",
4
- "version": "2.6.34",
4
+ "version": "2.6.35",
5
5
  "description": "Adaptive Baileys v7 fork with interactive builders, media tools, and experimental shared-socket VoIP/group-call support.",
6
6
  "license": "SEE LICENSE IN LICENSE",
7
7
  "main": "lib/index.js",
@@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url';
4
4
 
5
5
  const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
6
6
  const pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
7
- if (!pkg.version || !/^2\.6\.34$/.test(pkg.version)) {
7
+ if (!pkg.version || !/^2\.6\.35$/.test(pkg.version)) {
8
8
  throw new Error(`Unexpected release version: ${pkg.version}`);
9
9
  }
10
10
  for (const file of ['README.md', 'CHANGELOG.md', 'NOTICE.md', 'THIRD_PARTY_NOTICES.md', 'LICENSE-JAPOFC-VOIP']) {
@@ -12,7 +12,7 @@
12
12
  * CALL_CHROME_DEBUGGER_JSON_URL=http://127.0.0.1:9222/json/list \
13
13
  * node --experimental-websocket scripts/fetch-wasm-resources.mjs
14
14
  */
15
- import { writeFileSync, readFileSync, existsSync } from "fs";
15
+ import { writeFileSync, readFileSync, existsSync, mkdirSync } from "fs";
16
16
  import { createHash } from "crypto";
17
17
  import { resolve, dirname } from "path";
18
18
  import { fileURLToPath, pathToFileURL } from "url";
@@ -256,6 +256,9 @@ async function resolveResourceInfo() {
256
256
  }
257
257
 
258
258
  async function main() {
259
+ // npm tarballs and some package managers omit empty directories. Always
260
+ // create the destination before writing fetched WASM resources.
261
+ mkdirSync(RESOURCES_DIR, { recursive: true });
259
262
  const resourceInfo = await resolveResourceInfo();
260
263
  console.log("Resource source:", resourceInfo.source);
261
264
  if (resourceInfo.clientRevision) console.log("Client revision:", resourceInfo.clientRevision);
@@ -275,13 +278,21 @@ async function main() {
275
278
  loaderCode = await fetchText(resourceInfo.loaderUrl);
276
279
  }
277
280
  if (loaderCode) {
278
- if (!loaderCode.includes(BOOTLOADER_MODULE)) {
279
- throw new Error(`fetched loader bundle does not contain ${BOOTLOADER_MODULE} — refusing to overwrite`);
281
+ const escapedModuleName = BOOTLOADER_MODULE.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
282
+ const loaderDefinition = new RegExp(
283
+ `(?:__d|__registerModule)\\s*\\(\\s*["']${escapedModuleName}["']`
284
+ );
285
+ if (!loaderDefinition.test(loaderCode)) {
286
+ throw new Error(`fetched loader bundle does not define ${BOOTLOADER_MODULE} — refusing to overwrite`);
280
287
  }
281
288
  writeFileSync(resolve(RESOURCES_DIR, "loader.js"), loaderCode);
282
289
  console.log(` Written: loader.js (${loaderCode.length} bytes)`);
283
290
  } else {
284
- console.log(" loader.js unchanged (browser-debugger mode did not expose a standalone loader URL)");
291
+ const existingLoader = resolve(RESOURCES_DIR, "loader.js");
292
+ if (!existsSync(existingLoader)) {
293
+ throw new Error("loader.js is unavailable. Use CALL_WASM_FETCH_MODE=auto or direct so the standalone WASM loader can be downloaded.");
294
+ }
295
+ console.log(" loader.js unchanged (using the existing bundled loader)");
285
296
  }
286
297
 
287
298
  console.log("Fetching whatsapp.wasm from:", resourceInfo.wasmUrl);
@@ -1,3 +1,4 @@
1
+ import { createHash } from 'node:crypto';
1
2
  import fs from 'node:fs';
2
3
  import path from 'node:path';
3
4
  import { fileURLToPath } from 'node:url';
@@ -6,7 +7,7 @@ const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
6
7
  const pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
7
8
  const errors = [];
8
9
 
9
- if (pkg.version !== '2.6.34') errors.push(`Expected package version 2.6.34, got ${pkg.version}`);
10
+ if (pkg.version !== '2.6.35') errors.push(`Expected package version 2.6.35, got ${pkg.version}`);
10
11
  for (const file of [
11
12
  'lib/VoIP/group-call.js',
12
13
  'lib/VoIP/signaling.js',
@@ -20,12 +21,36 @@ for (const file of [
20
21
  if (!fs.existsSync(path.join(root, file))) errors.push(`Missing required file: ${file}`);
21
22
  }
22
23
 
24
+ const wasmDir = path.join(root, 'lib/assets/wasm');
25
+ const wasmManifestPath = path.join(wasmDir, 'integrity.json');
26
+ if (!fs.existsSync(wasmManifestPath)) {
27
+ errors.push('Missing bundled WASM integrity manifest: lib/assets/wasm/integrity.json');
28
+ } else {
29
+ try {
30
+ const manifest = JSON.parse(fs.readFileSync(wasmManifestPath, 'utf8'));
31
+ for (const [name, metadata] of Object.entries(manifest.files || {})) {
32
+ const filePath = path.join(wasmDir, name);
33
+ if (!fs.existsSync(filePath)) {
34
+ errors.push(`Missing bundled WASM resource: ${name}`);
35
+ continue;
36
+ }
37
+ const buffer = fs.readFileSync(filePath);
38
+ const digest = createHash('sha256').update(buffer).digest('hex');
39
+ if (metadata.size != null && buffer.length !== metadata.size) errors.push(`WASM resource size mismatch: ${name}`);
40
+ if (metadata.sha256 && digest !== metadata.sha256) errors.push(`WASM resource SHA-256 mismatch: ${name}`);
41
+ }
42
+ for (const name of ['whatsapp.wasm', 'worker-modules.js', 'loader.js']) {
43
+ if (!manifest.files?.[name]) errors.push(`WASM manifest does not include ${name}`);
44
+ }
45
+ } catch (error) {
46
+ errors.push(`Invalid WASM integrity manifest: ${error.message}`);
47
+ }
48
+ }
49
+
23
50
  if (errors.length) {
24
51
  for (const error of errors) console.error(`ERROR: ${error}`);
25
52
  process.exitCode = 1;
26
53
  } else {
27
54
  console.log(`Verified ${pkg.name}@${pkg.version}: VoIP/Group Call modules are present.`);
28
- if (!fs.existsSync(path.join(root, 'lib/assets/wasm/whatsapp.wasm'))) {
29
- console.warn('WASM assets are not bundled. Run: npm run voip:fetch-wasm');
30
- }
55
+ console.log('Bundled WASM assets and integrity manifest verified.');
31
56
  }