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.
- package/lib/Utils/generics.js +14 -15
- package/package.json +1 -1
package/lib/Utils/generics.js
CHANGED
|
@@ -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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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;
|