@lynovratech/baileys 1.0.7 → 1.0.8

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.
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processSyncAction = exports.chatModificationToAppPatch = exports.decodePatches = exports.decodeSyncdSnapshot = exports.downloadExternalPatch = exports.downloadExternalBlob = exports.extractSyncdPatches = exports.decodeSyncdPatch = exports.decodeSyncdMutations = exports.encodeSyncdPatch = exports.newLTHashState = void 0;
4
4
  const boom_1 = require("@hapi/boom");
5
- const whatsapp_rust_bridge_1 = require("whatsapp-rust-bridge");
5
+ const whatsapp_rust_bridge_1 = require("../vendor/whatsapp-rust-bridge.js");
6
6
  const index_js_1 = require("../../WAProto/index.js");
7
7
  const LabelAssociation_1 = require("../Types/LabelAssociation");
8
8
  const WABinary_1 = require("../WABinary");
@@ -48,7 +48,7 @@ exports.derivePairingCodeKey = derivePairingCodeKey;
48
48
  const crypto_1 = require("crypto");
49
49
  const curve = __importStar(require("libsignal/src/curve"));
50
50
  const Defaults_1 = require("../Defaults");
51
- var whatsapp_rust_bridge_1 = require("whatsapp-rust-bridge");
51
+ var whatsapp_rust_bridge_1 = require("../vendor/whatsapp-rust-bridge.js");
52
52
  Object.defineProperty(exports, "md5", { enumerable: true, get: function () { return whatsapp_rust_bridge_1.md5; } });
53
53
  Object.defineProperty(exports, "hkdf", { enumerable: true, get: function () { return whatsapp_rust_bridge_1.hkdf; } });
54
54
  // insure browser & node compatibility
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LT_HASH_ANTI_TAMPERING = void 0;
4
- const whatsapp_rust_bridge_1 = require("whatsapp-rust-bridge");
4
+ const whatsapp_rust_bridge_1 = require("../vendor/whatsapp-rust-bridge.js");
5
5
  /**
6
6
  * LT Hash is a summation based hash algorithm that maintains the integrity of a piece of data
7
7
  * over a series of mutations. You can add/remove mutations and it'll return a hash equal to
@@ -1,5 +1,5 @@
1
1
  import { Boom } from '@hapi/boom';
2
- import { expandAppStateKeys } from 'whatsapp-rust-bridge';
2
+ import { expandAppStateKeys } from "../vendor/whatsapp-rust-bridge.js";
3
3
  import { proto } from '../../WAProto/index.js';
4
4
  import { LabelAssociationType } from '../Types/LabelAssociation.js';
5
5
  import { getBinaryNodeChild, getBinaryNodeChildren, isJidGroup, jidNormalizedUser } from '../WABinary/index.js';
@@ -1,7 +1,7 @@
1
1
  import { createCipheriv, createDecipheriv, createHash, createHmac, randomBytes } from 'crypto';
2
2
  import * as curve from 'libsignal/src/curve.js';
3
3
  import { KEY_BUNDLE_TYPE } from '../Defaults/index.js';
4
- export { md5, hkdf } from 'whatsapp-rust-bridge';
4
+ export { md5, hkdf } from "../vendor/whatsapp-rust-bridge.js";
5
5
  // insure browser & node compatibility
6
6
  const { subtle } = globalThis.crypto;
7
7
  /** prefix version byte to the pub keys, required for some curve crypto functions */
@@ -1,4 +1,4 @@
1
- import { LTHashAntiTampering } from 'whatsapp-rust-bridge';
1
+ import { LTHashAntiTampering } from "../vendor/whatsapp-rust-bridge.js";
2
2
  /**
3
3
  * LT Hash is a summation based hash algorithm that maintains the integrity of a piece of data
4
4
  * over a series of mutations. You can add/remove mutations and it'll return a hash equal to
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lynovratech/baileys",
3
3
  "type": "module",
4
- "version": "1.0.7",
4
+ "version": "1.0.8",
5
5
  "description": "A WebSockets library for interacting with WhatsApp Web - lynovra fork with JID-first and dual ESM/CJS support",
6
6
  "keywords": [
7
7
  "whatsapp",
@@ -58,7 +58,8 @@
58
58
  "test": "node --experimental-vm-modules ./node_modules/.bin/jest --testMatch '**/*.test.ts'",
59
59
  "test:e2e": "node --experimental-vm-modules ./node_modules/.bin/jest --testMatch '**/*.test-e2e.ts'",
60
60
  "update:version": "tsx ./scripts/update-version.ts",
61
- "postinstall": "node scripts/patch-rust-bridge.cjs"
61
+ "postinstall": "node scripts/patch-rust-bridge.cjs",
62
+ "postbuild": "node scripts/fix-rust-bridge-import.cjs"
62
63
  },
63
64
  "dependencies": {
64
65
  "@cacheable/node-cache": "^1.4.0",
@@ -1,20 +1,25 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
 
4
- function fixDir(dir, relPath) {
4
+ function getDepth(filePath, baseDir) {
5
+ const rel = path.relative(baseDir, path.dirname(filePath));
6
+ return rel === '' ? 0 : rel.split(path.sep).length;
7
+ }
8
+
9
+ function fixDir(dir, baseDir) {
5
10
  const files = fs.readdirSync(dir);
6
11
  for(const file of files) {
7
12
  const full = path.join(dir, file);
8
13
  const stat = fs.statSync(full);
9
14
  if(stat.isDirectory()) {
10
- fixDir(full, relPath + '../');
15
+ fixDir(full, baseDir);
11
16
  } else if(file.endsWith('.js')) {
12
17
  let c = fs.readFileSync(full, 'utf8');
13
- if(c.includes('whatsapp-rust-bridge')) {
14
- c = c.replace(/require\(['"]whatsapp-rust-bridge['"]\)/g,
15
- `require('${relPath}vendor/whatsapp-rust-bridge.js')`);
16
- c = c.replace(/from ['"]whatsapp-rust-bridge['"]/g,
17
- `from '${relPath}vendor/whatsapp-rust-bridge.js'`);
18
+ if(c.includes("'whatsapp-rust-bridge'") || c.includes('"whatsapp-rust-bridge"')) {
19
+ const depth = getDepth(full, baseDir);
20
+ const rel = '../'.repeat(depth) + 'vendor/whatsapp-rust-bridge.js';
21
+ c = c.replace(/require\(["']whatsapp-rust-bridge["']\)/g, `require("${rel}")`);
22
+ c = c.replace(/from ["']whatsapp-rust-bridge["']/g, `from "${rel}"`);
18
23
  fs.writeFileSync(full, c);
19
24
  console.log('Fixed:', full);
20
25
  }
@@ -22,6 +27,9 @@ function fixDir(dir, relPath) {
22
27
  }
23
28
  }
24
29
 
25
- fixDir('lib/cjs', './');
26
- fixDir('lib/esm', './');
30
+ const cjsDir = path.resolve(__dirname, '../lib/cjs');
31
+ const esmDir = path.resolve(__dirname, '../lib/esm');
32
+
33
+ fixDir(cjsDir, cjsDir);
34
+ fixDir(esmDir, esmDir);
27
35
  console.log('All done!');