@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.
@@ -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, customPairingCode?: string) => Promise<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
  };
@@ -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, customPairingCode?: string) => Promise<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
  };
@@ -493,7 +493,7 @@ const makeChatsSocket = (config) => {
493
493
  await sendNode({
494
494
  tag: 'presence',
495
495
  attrs: {
496
- name: me.name.replace(/@/g, ''),
496
+ name: me.name,
497
497
  type
498
498
  }
499
499
  });
@@ -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, customPairingCode?: string) => Promise<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
  };
@@ -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, customPairingCode?: string) => Promise<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, customPairingCode?: string) => Promise<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, customPairingCode?: string) => Promise<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
  };
@@ -276,8 +276,7 @@ const makeMessagesSocket = (config) => {
276
276
  deviceSentMessage: {
277
277
  destinationJid,
278
278
  message
279
- },
280
- messageContextInfo: message.messageContextInfo
279
+ }
281
280
  };
282
281
  const extraAttrs = {};
283
282
  if (participant) {
@@ -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, customPairingCode?: string) => Promise<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>;
@@ -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, customPairingCode) => {
359
- const pairingCode = customPairingCode !== null && customPairingCode !== void 0 ? customPairingCode : (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5));
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: '~'
@@ -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, customPairingCode?: string) => Promise<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, options);
226
+ metadata = await musicMetadata.parseBuffer(buffer, undefined, { duration: true });
230
227
  }
231
228
  else if (typeof buffer === 'string') {
232
- metadata = await musicMetadata.parseFile(buffer, options);
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, options);
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 isValidMediaUrl = url === null || url === void 0 ? void 0 : url.startsWith('https://mmg.whatsapp.net/');
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@periskope/baileys",
3
- "version": "6.7.18-alpha.8",
3
+ "version": "6.7.18-alpha.9",
4
4
  "description": "WhatsApp API", "keywords": [
5
5
  "whatsapp",
6
6
  "automation"