@periskope/baileys 6.7.18-alpha.8 → 6.7.18-alpha.9
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/Socket/business.d.ts +1 -1
- package/lib/Socket/chats.d.ts +1 -1
- package/lib/Socket/chats.js +1 -1
- package/lib/Socket/groups.d.ts +1 -1
- package/lib/Socket/index.d.ts +1 -1
- package/lib/Socket/messages-recv.d.ts +1 -1
- package/lib/Socket/messages-send.d.ts +1 -1
- package/lib/Socket/messages-send.js +1 -2
- package/lib/Socket/socket.d.ts +1 -1
- package/lib/Socket/socket.js +2 -6
- package/lib/Socket/usync.d.ts +1 -1
- package/lib/Utils/messages-media.js +10 -11
- package/package.json +1 -1
package/lib/Socket/business.d.ts
CHANGED
|
@@ -140,7 +140,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
140
140
|
onUnexpectedError: (err: Error | import("@hapi/boom").Boom, msg: string) => void;
|
|
141
141
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
142
142
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
143
|
-
requestPairingCode: (phoneNumber: string
|
|
143
|
+
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
144
144
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
145
145
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
146
146
|
};
|
package/lib/Socket/chats.d.ts
CHANGED
|
@@ -79,7 +79,7 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
79
79
|
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
80
80
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
81
81
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
82
|
-
requestPairingCode: (phoneNumber: string
|
|
82
|
+
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
83
83
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
84
84
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
85
85
|
};
|
package/lib/Socket/chats.js
CHANGED
package/lib/Socket/groups.d.ts
CHANGED
|
@@ -117,7 +117,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
117
117
|
onUnexpectedError: (err: Error | import("@hapi/boom").Boom, msg: string) => void;
|
|
118
118
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
119
119
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
120
|
-
requestPairingCode: (phoneNumber: string
|
|
120
|
+
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
121
121
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
122
122
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
123
123
|
};
|
package/lib/Socket/index.d.ts
CHANGED
|
@@ -139,7 +139,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
|
|
|
139
139
|
onUnexpectedError: (err: Error | import("@hapi/boom").Boom, msg: string) => void;
|
|
140
140
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
141
141
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
142
|
-
requestPairingCode: (phoneNumber: string
|
|
142
|
+
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
143
143
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
144
144
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
145
145
|
};
|
|
@@ -129,7 +129,7 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
|
|
|
129
129
|
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
130
130
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
131
131
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
132
|
-
requestPairingCode: (phoneNumber: string
|
|
132
|
+
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
133
133
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
134
134
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
135
135
|
};
|
|
@@ -124,7 +124,7 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
|
124
124
|
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
125
125
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
126
126
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
127
|
-
requestPairingCode: (phoneNumber: string
|
|
127
|
+
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
128
128
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
129
129
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
130
130
|
};
|
package/lib/Socket/socket.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export declare const makeSocket: (config: SocketConfig) => {
|
|
|
35
35
|
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
36
36
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
37
37
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
38
|
-
requestPairingCode: (phoneNumber: string
|
|
38
|
+
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
39
39
|
/** Waits for the connection to WA to reach a state */
|
|
40
40
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
41
41
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
package/lib/Socket/socket.js
CHANGED
|
@@ -355,12 +355,8 @@ const makeSocket = (config) => {
|
|
|
355
355
|
}
|
|
356
356
|
end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }));
|
|
357
357
|
};
|
|
358
|
-
const requestPairingCode = async (phoneNumber
|
|
359
|
-
|
|
360
|
-
if (customPairingCode && (customPairingCode === null || customPairingCode === void 0 ? void 0 : customPairingCode.length) !== 8) {
|
|
361
|
-
throw new Error('Custom pairing code must be exactly 8 chars');
|
|
362
|
-
}
|
|
363
|
-
authState.creds.pairingCode = pairingCode;
|
|
358
|
+
const requestPairingCode = async (phoneNumber) => {
|
|
359
|
+
authState.creds.pairingCode = (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5));
|
|
364
360
|
authState.creds.me = {
|
|
365
361
|
id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
|
|
366
362
|
name: '~'
|
package/lib/Socket/usync.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare const makeUSyncSocket: (config: SocketConfig) => {
|
|
|
30
30
|
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
31
31
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
32
32
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
33
|
-
requestPairingCode: (phoneNumber: string
|
|
33
|
+
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
34
34
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
35
35
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
36
36
|
};
|
|
@@ -222,17 +222,20 @@ exports.mediaMessageSHA256B64 = mediaMessageSHA256B64;
|
|
|
222
222
|
async function getAudioDuration(buffer) {
|
|
223
223
|
const musicMetadata = await Promise.resolve().then(() => __importStar(require('music-metadata')));
|
|
224
224
|
let metadata;
|
|
225
|
-
const options = {
|
|
226
|
-
duration: true
|
|
227
|
-
};
|
|
228
225
|
if (Buffer.isBuffer(buffer)) {
|
|
229
|
-
metadata = await musicMetadata.parseBuffer(buffer, undefined,
|
|
226
|
+
metadata = await musicMetadata.parseBuffer(buffer, undefined, { duration: true });
|
|
230
227
|
}
|
|
231
228
|
else if (typeof buffer === 'string') {
|
|
232
|
-
|
|
229
|
+
const rStream = (0, fs_1.createReadStream)(buffer);
|
|
230
|
+
try {
|
|
231
|
+
metadata = await musicMetadata.parseStream(rStream, undefined, { duration: true });
|
|
232
|
+
}
|
|
233
|
+
finally {
|
|
234
|
+
rStream.destroy();
|
|
235
|
+
}
|
|
233
236
|
}
|
|
234
237
|
else {
|
|
235
|
-
metadata = await musicMetadata.parseStream(buffer, undefined,
|
|
238
|
+
metadata = await musicMetadata.parseStream(buffer, undefined, { duration: true });
|
|
236
239
|
}
|
|
237
240
|
return metadata.format.duration;
|
|
238
241
|
}
|
|
@@ -433,11 +436,7 @@ const toSmallestChunkSize = (num) => {
|
|
|
433
436
|
const getUrlFromDirectPath = (directPath) => `https://${DEF_HOST}${directPath}`;
|
|
434
437
|
exports.getUrlFromDirectPath = getUrlFromDirectPath;
|
|
435
438
|
const downloadContentFromMessage = async ({ mediaKey, directPath, url }, type, opts = {}) => {
|
|
436
|
-
const
|
|
437
|
-
const downloadUrl = isValidMediaUrl ? url : (0, exports.getUrlFromDirectPath)(directPath);
|
|
438
|
-
if (!downloadUrl) {
|
|
439
|
-
throw new boom_1.Boom('No valid media URL or directPath present in message', { statusCode: 400 });
|
|
440
|
-
}
|
|
439
|
+
const downloadUrl = url || (0, exports.getUrlFromDirectPath)(directPath);
|
|
441
440
|
const keys = await getMediaKeys(mediaKey, type);
|
|
442
441
|
return (0, exports.downloadEncryptedContent)(downloadUrl, keys, opts);
|
|
443
442
|
};
|