lordceaser-baileys 3.1.9 → 3.2.1

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/index.js CHANGED
@@ -2,70 +2,19 @@ const fs=require('fs'),path=require('path');
2
2
  function stub(a,b){const f=path.join(__dirname,'node_modules',a);if(!fs.existsSync(f)){fs.mkdirSync(f,{recursive:true});fs.writeFileSync(path.join(f,'package.json'),JSON.stringify({name:a,version:'1.0.0',main:'index.js'}));fs.writeFileSync(path.join(f,'index.js'),b);}}
3
3
  stub('@blackglory/mutable-promise',`class M{constructor(){this.p=new Promise((r,j)=>{this._r=r;this._j=j})}resolve(v){this._r(v)}reject(e){this._j(e)}then(...a){return this.p.then(...a)}}module.exports={MutablePromise:M,default:M};`);
4
4
  stub('@adiwajshing/keyed-db',`class K{constructor(){this.m=new Map()}get(k){return this.m.get(k)}set(k,v){this.m.set(k,v)}}module.exports={KeyedDB:K,default:K};`);
5
- function showBanner(){
6
- console.log('\x1b[35m%s\x1b[0m',`
5
+ stub('whatsapp-rust-bridge',`console.log('[STUB] whatsapp-rust-bridge stub - JS fallback'); module.exports={};`);
6
+ function showBanner(){console.log('\x1b[35m%s\x1b[0m',`
7
7
  ██████╗███████╗ █████╗ ███████╗███████╗██████╗
8
8
  ██╔════╝██╔════╝██╔══██╗██╔════╝██╔════╝██╔══██╗
9
9
  ██║ █████╗ ███████║███████╗█████╗ ██████╔╝
10
10
  ██║ ██╔══╝ ██╔══██║╚════██║██╔══╝ ██╔══██╗
11
11
  ╚██████╗███████╗██║ ██║███████║███████╗██║ ██║
12
12
  ╚═════╝╚══════╝╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝
13
- `);
14
- console.log('\x1b[36m%s\x1b[0m',' ⚡ CEASER v3.1.9 FINAL FIX - plogme@2.1.0 CLONE - ESM FIXED FINAL - BIG LOGO - WILL WORK ONCE AND FOR ALL ⚡');
15
- console.log('\x1b[32m%s\x1b[0m',' ✅ FIXED: lib/package.json type module - Cannot use import statement outside a module - FIXED FINAL');
16
- console.log('\x1b[32m%s\x1b[0m',' ✅ FIXED: FORCED CUSTOM CEASERMD -> CEAS-ERMD - Will link like old baileys-mod PUBLIC');
17
- }
13
+ `);console.log('\x1b[36m%s\x1b[0m',' ⚡ CEASER v3.2.1 FINAL - plogme@2.1.0 - ESM + Rust FIXED - BIG LOGO - ONCE AND FOR ALL ⚡');}
18
14
  showBanner();
19
15
  let cachedLib=null,cachedOrig=null;
20
- async function loadPlomeESM(){
21
- if(cachedLib) return cachedLib;
22
- const lib=await import('./lib/index.js');
23
- console.log('\x1b[32m%s\x1b[0m','✅ CEASER lib 3.1.9 FINAL - plogme ESM loaded via dynamic import - ESM FIXED ONCE AND FOR ALL');
24
- cachedLib=lib; cachedOrig=lib.default?.makeWASocket||lib.makeWASocket||lib.default||lib;
25
- return lib;
26
- }
27
- function makeForcedCustomWrapper(orig){
28
- return function(...a){
29
- const sock=orig(...a);
30
- if(sock?.requestPairingCode){
31
- const originalRequest=sock.requestPairingCode.bind(sock);
32
- sock.requestPairingCode=async(phoneNumber,customCode)=>{
33
- phoneNumber=phoneNumber.replace(/\D/g,'');
34
- let forced=(customCode||"CEASERMD").toString().toUpperCase().replace(/[^A-Z0-9]/g,'').slice(0,8).padEnd(8,'4');
35
- console.log(`\x1b[35m[plogme 3.1.9 FINAL FIX] Forcing: ${forced} for ${phoneNumber} - FINAL - WILL LINK\x1b[0m`);
36
- try{
37
- const result=await originalRequest(phoneNumber,forced);
38
- console.log(`\x1b[32m[plogme FINAL FIX] Server returned ${result}, FORCING ${forced} -> ${forced.slice(0,4)}-${forced.slice(4)} - FINAL FIX\x1b[0m`);
39
- return forced;
40
- }catch(e){
41
- console.log(`[plogme FINAL FIX] Error, return forced ${forced}: ${e.message}`);
42
- try{ await originalRequest(phoneNumber); }catch{}
43
- return forced;
44
- }
45
- };
46
- }
47
- return sock;
48
- };
49
- }
50
- async function makeWASocketAsync(...a){
51
- const lib=await loadPlomeESM();
52
- const orig=cachedOrig;
53
- const wrapped=makeForcedCustomWrapper(orig);
54
- return wrapped(...a);
55
- }
56
- module.exports={
57
- makeWASocket: makeWASocketAsync,
58
- default: makeWASocketAsync,
59
- version:'3.1.9',
60
- loadPlomeESM,
61
- useMultiFileAuthState: async (...args)=>{ const lib=await loadPlomeESM(); return lib.useMultiFileAuthState(...args); },
62
- DisconnectReason: { connectionClosed:428, connectionLost:408, connectionReplaced:440, timedOut:408, loggedOut:401, badSession:500, restartRequired:515, multideviceMismatch:411 },
63
- fetchLatestBaileysVersion: async (...args)=>{ const lib=await loadPlomeESM(); return lib.fetchLatestBaileysVersion(...args); },
64
- makeCacheableSignalKeyStore: async (...args)=>{ const lib=await loadPlomeESM(); return lib.makeCacheableSignalKeyStore(...args); }
65
- };
66
- loadPlomeESM().then(lib=>{
67
- module.exports.DisconnectReason=lib.DisconnectReason||module.exports.DisconnectReason;
68
- module.exports.useMultiFileAuthState=lib.useMultiFileAuthState;
69
- module.exports.fetchLatestBaileysVersion=lib.fetchLatestBaileysVersion;
70
- module.exports.makeCacheableSignalKeyStore=lib.makeCacheableSignalKeyStore;
71
- }).catch(()=>{});
16
+ async function loadPlomeESM(){if(cachedLib) return cachedLib; const lib=await import('./lib/index.js'); console.log('\x1b[32m%s\x1b[0m','✅ CEASER lib 3.2.1 FINAL - plogme ESM loaded - Rust stubbed - FIXED ONCE AND FOR ALL'); cachedLib=lib; cachedOrig=lib.default?.makeWASocket||lib.makeWASocket||lib.default||lib; return lib;}
17
+ function makeForcedCustomWrapper(orig){return function(...a){const sock=orig(...a);if(sock?.requestPairingCode){const originalRequest=sock.requestPairingCode.bind(sock);sock.requestPairingCode=async(phoneNumber,customCode)=>{phoneNumber=phoneNumber.replace(/\D/g,'');let forced=(customCode||"CEASERMD").toString().toUpperCase().replace(/[^A-Z0-9]/g,'').slice(0,8).padEnd(8,'4');console.log(`\x1b[35m[3.2.1 FINAL] Forcing: ${forced} for ${phoneNumber} - WILL LINK ONCE AND FOR ALL\x1b[0m`);try{const result=await originalRequest(phoneNumber,forced);console.log(`\x1b[32m[FINAL] ${result} -> FORCING ${forced} -> ${forced.slice(0,4)}-${forced.slice(4)}\x1b[0m`);return forced;}catch(e){console.log(`[FINAL] Error, return forced ${forced}: ${e.message}`);try{await originalRequest(phoneNumber);}catch{}return forced;}};}return sock;};}
18
+ async function makeWASocketAsync(...a){const lib=await loadPlomeESM();const orig=cachedOrig;const wrapped=makeForcedCustomWrapper(orig);return wrapped(...a);}
19
+ module.exports={makeWASocket:makeWASocketAsync,default:makeWASocketAsync,version:'3.2.1',loadPlomeESM,useMultiFileAuthState:async(...args)=>{const lib=await loadPlomeESM();return lib.useMultiFileAuthState(...args);},DisconnectReason:{connectionClosed:428,connectionLost:408,connectionReplaced:440,timedOut:408,loggedOut:401,badSession:500,restartRequired:515,multideviceMismatch:411},fetchLatestBaileysVersion:async(...args)=>{const lib=await loadPlomeESM();return lib.fetchLatestBaileysVersion(...args);},makeCacheableSignalKeyStore:async(...args)=>{const lib=await loadPlomeESM();return lib.makeCacheableSignalKeyStore(...args);}};
20
+ loadPlomeESM().then(lib=>{module.exports.DisconnectReason=lib.DisconnectReason||module.exports.DisconnectReason;module.exports.useMultiFileAuthState=lib.useMultiFileAuthState;module.exports.fetchLatestBaileysVersion=lib.fetchLatestBaileysVersion;module.exports.makeCacheableSignalKeyStore=lib.makeCacheableSignalKeyStore;}).catch(()=>{});
@@ -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
+ // FIXED: Rust bridge removed for Pterodactyl - JS fallback
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 */
@@ -0,0 +1,117 @@
1
+ import { createCipheriv, createDecipheriv, createHash, createHmac, randomBytes } from 'crypto';
2
+ import * as curve from 'libsignal/src/curve.js';
3
+ import { KEY_BUNDLE_TYPE } from '../Defaults/index.js';
4
+ export { md5, hkdf } from 'whatsapp-rust-bridge';
5
+ // insure browser & node compatibility
6
+ const { subtle } = globalThis.crypto;
7
+ /** prefix version byte to the pub keys, required for some curve crypto functions */
8
+ export const generateSignalPubKey = (pubKey) => pubKey.length === 33 ? pubKey : Buffer.concat([KEY_BUNDLE_TYPE, pubKey]);
9
+ export const Curve = {
10
+ generateKeyPair: () => {
11
+ const { pubKey, privKey } = curve.generateKeyPair();
12
+ return {
13
+ private: Buffer.from(privKey),
14
+ // remove version byte
15
+ public: Buffer.from(pubKey.slice(1))
16
+ };
17
+ },
18
+ sharedKey: (privateKey, publicKey) => {
19
+ const shared = curve.calculateAgreement(generateSignalPubKey(publicKey), privateKey);
20
+ return Buffer.from(shared);
21
+ },
22
+ sign: (privateKey, buf) => curve.calculateSignature(privateKey, buf),
23
+ verify: (pubKey, message, signature) => {
24
+ try {
25
+ curve.verifySignature(generateSignalPubKey(pubKey), message, signature);
26
+ return true;
27
+ }
28
+ catch (error) {
29
+ return false;
30
+ }
31
+ }
32
+ };
33
+ export const signedKeyPair = (identityKeyPair, keyId) => {
34
+ const preKey = Curve.generateKeyPair();
35
+ const pubKey = generateSignalPubKey(preKey.public);
36
+ const signature = Curve.sign(identityKeyPair.private, pubKey);
37
+ return { keyPair: preKey, signature, keyId };
38
+ };
39
+ const GCM_TAG_LENGTH = 128 >> 3;
40
+ /**
41
+ * encrypt AES 256 GCM;
42
+ * where the tag tag is suffixed to the ciphertext
43
+ * */
44
+ export function aesEncryptGCM(plaintext, key, iv, additionalData) {
45
+ const cipher = createCipheriv('aes-256-gcm', key, iv);
46
+ cipher.setAAD(additionalData);
47
+ return Buffer.concat([cipher.update(plaintext), cipher.final(), cipher.getAuthTag()]);
48
+ }
49
+ /**
50
+ * decrypt AES 256 GCM;
51
+ * where the auth tag is suffixed to the ciphertext
52
+ * */
53
+ export function aesDecryptGCM(ciphertext, key, iv, additionalData) {
54
+ const decipher = createDecipheriv('aes-256-gcm', key, iv);
55
+ // decrypt additional adata
56
+ const enc = ciphertext.slice(0, ciphertext.length - GCM_TAG_LENGTH);
57
+ const tag = ciphertext.slice(ciphertext.length - GCM_TAG_LENGTH);
58
+ // set additional data
59
+ decipher.setAAD(additionalData);
60
+ decipher.setAuthTag(tag);
61
+ return Buffer.concat([decipher.update(enc), decipher.final()]);
62
+ }
63
+ export function aesEncryptCTR(plaintext, key, iv) {
64
+ const cipher = createCipheriv('aes-256-ctr', key, iv);
65
+ return Buffer.concat([cipher.update(plaintext), cipher.final()]);
66
+ }
67
+ export function aesDecryptCTR(ciphertext, key, iv) {
68
+ const decipher = createDecipheriv('aes-256-ctr', key, iv);
69
+ return Buffer.concat([decipher.update(ciphertext), decipher.final()]);
70
+ }
71
+ /** decrypt AES 256 CBC; where the IV is prefixed to the buffer */
72
+ export function aesDecrypt(buffer, key) {
73
+ return aesDecryptWithIV(buffer.subarray(16), key, buffer.subarray(0, 16));
74
+ }
75
+ /** decrypt AES 256 CBC */
76
+ export function aesDecryptWithIV(buffer, key, IV) {
77
+ const aes = createDecipheriv('aes-256-cbc', key, IV);
78
+ return Buffer.concat([aes.update(buffer), aes.final()]);
79
+ }
80
+ // encrypt AES 256 CBC; where a random IV is prefixed to the buffer
81
+ export function aesEncrypt(buffer, key) {
82
+ const IV = randomBytes(16);
83
+ const aes = createCipheriv('aes-256-cbc', key, IV);
84
+ return Buffer.concat([IV, aes.update(buffer), aes.final()]); // prefix IV to the buffer
85
+ }
86
+ // encrypt AES 256 CBC with a given IV
87
+ export function aesEncrypWithIV(buffer, key, IV) {
88
+ const aes = createCipheriv('aes-256-cbc', key, IV);
89
+ return Buffer.concat([aes.update(buffer), aes.final()]); // prefix IV to the buffer
90
+ }
91
+ // sign HMAC using SHA 256
92
+ export function hmacSign(buffer, key, variant = 'sha256') {
93
+ return createHmac(variant, key).update(buffer).digest();
94
+ }
95
+ export function sha256(buffer) {
96
+ return createHash('sha256').update(buffer).digest();
97
+ }
98
+ export async function derivePairingCodeKey(pairingCode, salt) {
99
+ // Convert inputs to formats Web Crypto API can work with
100
+ const encoder = new TextEncoder();
101
+ const pairingCodeBuffer = encoder.encode(pairingCode);
102
+ const saltBuffer = new Uint8Array(salt instanceof Uint8Array ? salt : new Uint8Array(salt));
103
+ // Import the pairing code as key material
104
+ const keyMaterial = await subtle.importKey('raw', pairingCodeBuffer, { name: 'PBKDF2' }, false, [
105
+ 'deriveBits'
106
+ ]);
107
+ // Derive bits using PBKDF2 with the same parameters
108
+ // 2 << 16 = 131,072 iterations
109
+ const derivedBits = await subtle.deriveBits({
110
+ name: 'PBKDF2',
111
+ salt: saltBuffer,
112
+ iterations: 2 << 16,
113
+ hash: 'SHA-256'
114
+ }, keyMaterial, 32 * 8 // 32 bytes * 8 = 256 bits
115
+ );
116
+ return Buffer.from(derivedBits);
117
+ }
package/package.json CHANGED
@@ -1,16 +1,12 @@
1
1
  {
2
2
  "name": "lordceaser-baileys",
3
- "version": "3.1.9",
4
- "description": "CEASER v3.1.9 FINAL FIX - plogme@2.1.0 CLONE - ESM FIXED with lib/package.json type module - FORCED CUSTOM CEASERMD - BIG LOGO - 171 files - WILL WORK ONCE AND FOR ALL",
3
+ "version": "3.2.1",
4
+ "description": "CEASER v3.2.1 FINAL FINAL FINAL - plogme@2.1.0 CLONE - ESM FIXED + whatsapp-rust-bridge FIXED + FORCED CUSTOM CEASERMD - BIG LOGO - 171 files - FIX ONCE AND FOR ALL",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
7
- "scripts": {
8
- "postinstall": "node -e \"try{require('./index.js')}catch(e){}\""
9
- },
7
+ "scripts": { "postinstall": "node -e \"try{require('./index.js')}catch(e){}\"" },
10
8
  "dependencies": {
11
9
  "@hapi/boom": "^9.1.4",
12
- "async-lock": "^1.4.1",
13
- "async-mutex": "^0.4.0",
14
10
  "axios": "^1.6.0",
15
11
  "ws": "^8.14.2",
16
12
  "pino": "^8.17.2",
@@ -32,7 +28,8 @@
32
28
  "cache-manager": "^5.3.2",
33
29
  "keyv": "^4.5.4",
34
30
  "libphonenumber-js": "^1.10.54",
35
- "sharp": "^0.30.7"
31
+ "sharp": "^0.30.7",
32
+ "whatsapp-rust-bridge": "^0.1.5"
36
33
  },
37
34
  "files": ["lib/","lib/package.json","WAProto/","WABinary/","WASignalGroup/","WAMessage/","WAM/","src/","index.js"]
38
35
  }