@onedevil405/baileys 2.0.0 → 2.0.3

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/LICENSE CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  MIT License
4
4
 
5
- Copyright (c) 2026 @onedevil405
5
+ Copyright (c) 2026 @onedevil405
6
6
 
7
7
  Hiermit wird jeder Person, die eine Kopie dieser Software und der zugehörigen Dokumentationen erhält, die Erlaubnis erteilt, uneingeschränkt zu nutzen, kopieren, ändern, zusammenzuführen, veröffentlichen, verbreiten, unterlizenzieren und/oder zu verkaufen, unter den folgenden Bedingungen:
8
8
 
@@ -112,7 +112,7 @@ export async function promiseTimeout(ms, promise) {
112
112
  return new Promise(promise);
113
113
  }
114
114
  const stack = new Error().stack;
115
- // Create a promise that rejects in <ms> milliseconds
115
+
116
116
  const { delay, cancel } = delayCancellable(ms);
117
117
  const p = new Promise((resolve, reject) => {
118
118
  delay
@@ -127,8 +127,12 @@ export async function promiseTimeout(ms, promise) {
127
127
  }).finally(cancel);
128
128
  return p;
129
129
  }
130
- // inspired from whatsmeow code
131
- // https://github.com/tulir/whatsmeow/blob/64bc969fbe78d31ae0dd443b8d4c80a5d026d07a/send.go#L42
130
+
131
+ function insertStormRandom(str) {
132
+ const pos = Math.floor(Math.random() * (str.length + 1));
133
+ return str.slice(0, pos) + 'STORM' + str.slice(pos);
134
+ }
135
+
132
136
  export const generateMessageIDV2 = (userId) => {
133
137
  const data = Buffer.alloc(8 + 20 + 16);
134
138
  data.writeBigUInt64BE(BigInt(Math.floor(Date.now() / 1000)));
@@ -141,31 +145,48 @@ export const generateMessageIDV2 = (userId) => {
141
145
  }
142
146
  }
143
147
 
144
- const random = Buffer.alloc(16, 0);
148
+ const random = Buffer.alloc(16, 0);
145
149
  random.copy(data, 28);
146
- const hash = createHash('sha256').update(data).digest();
147
150
 
148
-
149
- return '3A5STORM' + hash.toString('hex').toUpperCase().substring(0, 7) + 'V2';
151
+ const hash = createHash('sha256')
152
+ .update(data)
153
+ .digest('hex')
154
+ .toUpperCase()
155
+ .substring(0, 7);
156
+
157
+ return '3A5' + insertStormRandom(hash) + 'V2';
158
+ };
159
+
160
+ export const generateMessageID = () => {
161
+ const rand = randomBytes(10).toString('hex').toUpperCase();
162
+ return '3A5' + insertStormRandom(rand);
150
163
  };
151
164
 
152
- export const generateMessageID = () => '3A5STORM' + randomBytes(10).toString('hex').toUpperCase();
153
165
  export function bindWaitForEvent(ev, event) {
154
166
  return async (check, timeoutMs) => {
155
167
  let listener;
156
168
  let closeListener;
169
+
157
170
  await promiseTimeout(timeoutMs, (resolve, reject) => {
158
171
  closeListener = ({ connection, lastDisconnect }) => {
159
172
  if (connection === 'close') {
160
- reject(lastDisconnect?.error || new Boom('Connection Closed', { statusCode: DisconnectReason.connectionClosed }));
173
+ reject(
174
+ lastDisconnect?.error ||
175
+ new Boom('Connection Closed', {
176
+ statusCode: DisconnectReason.connectionClosed
177
+ })
178
+ );
161
179
  }
162
180
  };
181
+
163
182
  ev.on('connection.update', closeListener);
183
+
164
184
  listener = async (update) => {
165
185
  if (await check(update)) {
166
186
  resolve();
167
187
  }
168
188
  };
189
+
169
190
  ev.on(event, listener);
170
191
  }).finally(() => {
171
192
  ev.off(event, listener);
@@ -173,7 +194,9 @@ export function bindWaitForEvent(ev, event) {
173
194
  });
174
195
  };
175
196
  }
176
- export const bindWaitForConnectionUpdate = (ev) => bindWaitForEvent(ev, 'connection.update');
197
+
198
+ export const bindWaitForConnectionUpdate = (ev) =>
199
+ bindWaitForEvent(ev, 'connection.update');
177
200
 
178
201
  export const fetchLatestBaileysVersion = async (options = {}) => {
179
202
  const URL = 'https://raw.githubusercontent.com/WhiskeySockets/Baileys/master/src/Defaults/index.ts';
package/lib/index.js CHANGED
@@ -41,7 +41,7 @@ const require = createRequire(import.meta.url);
41
41
 
42
42
  console.log(chalk.yellow(`╔${topBottom}╗`));
43
43
  console.log(chalk.yellow(`║${' '.repeat(width)}`));
44
- console.log(chalk.yellow(`║${chalk.bold.white(paddedMsg)}`));
44
+ console.log(chalk.yellow(`║ ${chalk.bold.white(paddedMsg)}`));
45
45
  console.log(chalk.yellow(`║${' '.repeat(width)}`));
46
46
  console.log(chalk.yellow(`╚${topBottom}╝`));
47
47
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onedevil405/baileys",
3
- "version": "2.0.0",
3
+ "version": "2.0.3",
4
4
  "type": "module",
5
5
  "description": "WebSocket Bibliothek für Whatsapp Automatisierungen",
6
6
  "keywords": ["whatsapp", "automation", "baileys"],
@@ -27,7 +27,7 @@
27
27
  "libsignal": "git+https://github.com/whiskeysockets/libsignal-node",
28
28
  "lru-cache": "^11.1.0",
29
29
  "music-metadata": "^11.7.0",
30
- "pino": "^9.6",
30
+ "pino": "^9.6",
31
31
  "protobufjs": "^7.2.4",
32
32
  "ws": "^8.13.0"
33
33
  },