violetics 7.0.5-alpha → 7.0.6-alpha

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.
@@ -132,24 +132,23 @@ export async function promiseTimeout(ms, promise) {
132
132
  // inspired from whatsmeow code
133
133
  // https://github.com/tulir/whatsmeow/blob/64bc969fbe78d31ae0dd443b8d4c80a5d026d07a/send.go#L42
134
134
  export const generateMessageIDV2 = (userId) => {
135
- const data = Buffer.allocUnsafe(8 + 20 + 16);
136
- data.writeBigUInt64BE(BigInt(unixTimestampSeconds()));
137
- if (userId) {
138
- const id = jidDecode(userId);
139
- if (id?.user) {
140
- const len = data.write(id.user, 8);
141
- data.write('@c.us', 8 + len);
142
- }
143
- }
144
- randomBytes(16).copy(data, 28);
145
- const hash = createHash('sha256').update(data).digest();
146
- const hex = hash.toString('hex').toUpperCase();
147
- const baseId = '3EB0' + hex.substring(0, 18);
148
- const pos = 4 + (hash[0] & 15);
149
- return baseId.slice(0, pos) + 'STARFALL' + baseId.slice(pos);
135
+ const data = Buffer.alloc(8 + 20 + 16);
136
+ data.writeBigUInt64BE(BigInt(Math.floor(Date.now() / 1000)));
137
+ if (userId) {
138
+ const id = jidDecode(userId);
139
+ if (id?.user) {
140
+ data.write(id.user, 8);
141
+ data.write('@c.us', 8 + id.user.length);
142
+ }
143
+ }
144
+ const random = randomBytes(16);
145
+ random.copy(data, 28);
146
+ const hash = createHash('sha256').update(data).digest();
147
+ return '3EB0' + hash.toString('hex').toUpperCase().substring(0, 18);
150
148
  };
151
149
  // generate a random ID to attach to a message
152
150
  export const generateMessageID = () => '3EB0' + randomBytes(18).toString('hex').toUpperCase();
151
+
153
152
  export function bindWaitForEvent(ev, event) {
154
153
  return async (check, timeoutMs) => {
155
154
  let listener;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "violetics",
3
- "version": "7.0.5-alpha",
3
+ "version": "7.0.6-alpha",
4
4
  "description": "A simple fork of Baileys for WhatsApp automation",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",