@hbmodsofc/baileys 1.7.7 → 2.0.0

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.
Files changed (155) hide show
  1. package/LICENSE +1 -1
  2. package/WAProto/index.js +157084 -24729
  3. package/lib/Defaults/baileys-version.json +3 -0
  4. package/lib/Defaults/index.d.ts +8 -12
  5. package/lib/Defaults/index.js +124 -90
  6. package/lib/Defaults/phonenumber-mcc.json +223 -0
  7. package/lib/Signal/Group/group_cipher.d.ts +1 -0
  8. package/lib/Signal/Group/group_cipher.js +39 -28
  9. package/lib/Signal/Group/queue-job.d.ts +1 -0
  10. package/lib/Signal/Group/queue-job.js +57 -0
  11. package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
  12. package/lib/Signal/Group/sender-chain-key.js +2 -9
  13. package/lib/Signal/Group/sender-key-distribution-message.js +3 -3
  14. package/lib/Signal/Group/sender-key-message.js +3 -3
  15. package/lib/Signal/Group/sender-key-state.d.ts +4 -4
  16. package/lib/Signal/Group/sender-key-state.js +16 -47
  17. package/lib/Signal/libsignal.d.ts +3 -7
  18. package/lib/Signal/libsignal.js +39 -224
  19. package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +3 -1
  20. package/lib/Socket/Client/index.d.ts +3 -2
  21. package/lib/Socket/Client/index.js +3 -2
  22. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  23. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  24. package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -1
  25. package/lib/Socket/Client/{websocket.js → web-socket-client.js} +16 -10
  26. package/lib/Socket/business.d.ts +78 -94
  27. package/lib/Socket/business.js +11 -130
  28. package/lib/Socket/chats.d.ts +233 -63
  29. package/lib/Socket/chats.js +184 -234
  30. package/lib/Socket/groups.d.ts +41 -62
  31. package/lib/Socket/groups.js +64 -76
  32. package/lib/Socket/hbmods.d.ts +253 -0
  33. package/lib/Socket/hbmods.js +1 -0
  34. package/lib/Socket/index.d.ts +83 -129
  35. package/lib/Socket/index.js +6 -13
  36. package/lib/Socket/messages-recv.d.ts +48 -59
  37. package/lib/Socket/messages-recv.js +371 -516
  38. package/lib/Socket/messages-send.d.ts +67 -86
  39. package/lib/Socket/messages-send.js +1 -1091
  40. package/lib/Socket/newsletter.d.ts +64 -76
  41. package/lib/Socket/newsletter.js +1 -184
  42. package/lib/Socket/registration.d.ts +267 -0
  43. package/lib/Socket/registration.js +166 -0
  44. package/lib/Socket/socket.d.ts +13 -19
  45. package/lib/Socket/socket.js +1 -805
  46. package/lib/Socket/usync.d.ts +36 -0
  47. package/lib/Socket/usync.js +70 -0
  48. package/lib/Types/Auth.d.ts +10 -4
  49. package/lib/Types/Call.d.ts +1 -1
  50. package/lib/Types/Chat.d.ts +9 -29
  51. package/lib/Types/Chat.js +1 -7
  52. package/lib/Types/Contact.d.ts +1 -5
  53. package/lib/Types/Events.d.ts +14 -55
  54. package/lib/Types/GroupMetadata.d.ts +5 -15
  55. package/lib/Types/Label.d.ts +0 -11
  56. package/lib/Types/Label.js +1 -1
  57. package/lib/Types/LabelAssociation.js +1 -1
  58. package/lib/Types/Message.d.ts +49 -75
  59. package/lib/Types/Message.js +7 -10
  60. package/lib/Types/Newsletter.d.ts +98 -129
  61. package/lib/Types/Newsletter.js +38 -33
  62. package/lib/Types/Product.d.ts +1 -1
  63. package/lib/Types/Signal.d.ts +1 -29
  64. package/lib/Types/Socket.d.ts +22 -48
  65. package/lib/Types/State.d.ts +2 -13
  66. package/lib/Types/State.js +0 -12
  67. package/lib/Types/USync.d.ts +1 -1
  68. package/lib/Types/index.d.ts +3 -10
  69. package/lib/Types/index.js +2 -2
  70. package/lib/Utils/auth-utils.d.ts +3 -3
  71. package/lib/Utils/auth-utils.js +102 -378
  72. package/lib/Utils/baileys-event-stream.js +1 -1
  73. package/lib/Utils/business.d.ts +2 -2
  74. package/lib/Utils/business.js +13 -19
  75. package/lib/Utils/chat-utils.d.ts +22 -21
  76. package/lib/Utils/chat-utils.js +154 -201
  77. package/lib/Utils/crypto.d.ts +19 -18
  78. package/lib/Utils/crypto.js +37 -78
  79. package/lib/Utils/decode-wa-message.d.ts +7 -34
  80. package/lib/Utils/decode-wa-message.js +66 -138
  81. package/lib/Utils/event-buffer.d.ts +8 -6
  82. package/lib/Utils/event-buffer.js +43 -81
  83. package/lib/Utils/generics.d.ts +27 -27
  84. package/lib/Utils/generics.js +133 -128
  85. package/lib/Utils/history.d.ts +5 -9
  86. package/lib/Utils/history.js +23 -17
  87. package/lib/Utils/index.d.ts +0 -2
  88. package/lib/Utils/index.js +0 -2
  89. package/lib/Utils/link-preview.d.ts +4 -4
  90. package/lib/Utils/link-preview.js +12 -40
  91. package/lib/Utils/logger.d.ts +3 -11
  92. package/lib/Utils/lt-hash.d.ts +8 -8
  93. package/lib/Utils/lt-hash.js +24 -23
  94. package/lib/Utils/make-mutex.d.ts +2 -2
  95. package/lib/Utils/make-mutex.js +2 -3
  96. package/lib/Utils/messages-media.d.ts +41 -37
  97. package/lib/Utils/messages-media.js +368 -252
  98. package/lib/Utils/messages.d.ts +15 -13
  99. package/lib/Utils/messages.js +261 -274
  100. package/lib/Utils/noise-handler.d.ts +15 -13
  101. package/lib/Utils/noise-handler.js +26 -20
  102. package/lib/Utils/process-message.d.ts +8 -9
  103. package/lib/Utils/process-message.js +93 -157
  104. package/lib/Utils/signal.d.ts +5 -6
  105. package/lib/Utils/signal.js +29 -37
  106. package/lib/Utils/use-multi-file-auth-state.d.ts +2 -1
  107. package/lib/Utils/use-multi-file-auth-state.js +7 -12
  108. package/lib/Utils/validate-connection.d.ts +6 -5
  109. package/lib/Utils/validate-connection.js +97 -39
  110. package/lib/WABinary/constants.d.ts +27 -24
  111. package/lib/WABinary/constants.js +13 -1276
  112. package/lib/WABinary/decode.d.ts +4 -3
  113. package/lib/WABinary/decode.js +14 -28
  114. package/lib/WABinary/encode.d.ts +2 -1
  115. package/lib/WABinary/encode.js +147 -134
  116. package/lib/WABinary/generic-utils.d.ts +7 -4
  117. package/lib/WABinary/generic-utils.js +125 -40
  118. package/lib/WABinary/jid-utils.d.ts +8 -13
  119. package/lib/WABinary/jid-utils.js +16 -27
  120. package/lib/WAM/BinaryInfo.d.ts +11 -2
  121. package/lib/WAM/constants.d.ts +2 -3
  122. package/lib/WAM/constants.js +2359 -2252
  123. package/lib/WAM/encode.d.ts +2 -1
  124. package/lib/WAM/encode.js +11 -8
  125. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +2 -2
  126. package/lib/WAUSync/Protocols/USyncContactProtocol.js +4 -3
  127. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
  128. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +5 -5
  129. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
  130. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +5 -5
  131. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
  132. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +6 -5
  133. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +2 -2
  134. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
  135. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +3 -4
  136. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +3 -11
  137. package/lib/WAUSync/USyncQuery.d.ts +2 -2
  138. package/lib/WAUSync/USyncQuery.js +15 -19
  139. package/lib/WAUSync/USyncUser.d.ts +5 -5
  140. package/lib/WAUSync/index.d.ts +1 -1
  141. package/lib/WAUSync/index.js +1 -1
  142. package/package.json +102 -102
  143. package/lib/Signal/lid-mapping.d.ts +0 -26
  144. package/lib/Signal/lid-mapping.js +0 -146
  145. package/lib/Socket/communities.d.ts +0 -232
  146. package/lib/Socket/communities.js +0 -402
  147. package/lib/Socket/mex.d.ts +0 -2
  148. package/lib/Socket/mex.js +0 -45
  149. package/lib/Types/Bussines.d.ts +0 -24
  150. package/lib/Types/Bussines.js +0 -2
  151. package/lib/Utils/lidToJid-test.d.ts +0 -11
  152. package/lib/Utils/lidToJid-test.js +0 -27
  153. package/lib/Utils/message-retry-manager.d.ts +0 -81
  154. package/lib/Utils/message-retry-manager.js +0 -152
  155. /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.getUrlInfo = void 0;
37
4
  const messages_1 = require("./messages");
@@ -53,11 +20,12 @@ const getUrlInfo = async (text, opts = {
53
20
  thumbnailWidth: THUMBNAIL_WIDTH_PX,
54
21
  fetchOpts: { timeout: 3000 }
55
22
  }) => {
23
+ var _a;
56
24
  try {
57
25
  // retries
58
26
  const retries = 0;
59
27
  const maxRetry = 5;
60
- const { getLinkPreview } = await Promise.resolve().then(() => __importStar(require('link-preview-js')));
28
+ const { getLinkPreview } = await import('link-preview-js');
61
29
  let previewLink = text;
62
30
  if (!text.startsWith('https://') && !text.startsWith('http://')) {
63
31
  previewLink = 'https://' + previewLink;
@@ -71,9 +39,9 @@ const getUrlInfo = async (text, opts = {
71
39
  if (retries >= maxRetry) {
72
40
  return false;
73
41
  }
74
- if (forwardedURLObj.hostname === urlObj.hostname ||
75
- forwardedURLObj.hostname === 'www.' + urlObj.hostname ||
76
- 'www.' + forwardedURLObj.hostname === urlObj.hostname) {
42
+ if (forwardedURLObj.hostname === urlObj.hostname
43
+ || forwardedURLObj.hostname === 'www.' + urlObj.hostname
44
+ || 'www.' + forwardedURLObj.hostname === urlObj.hostname) {
77
45
  retries + 1;
78
46
  return true;
79
47
  }
@@ -98,15 +66,19 @@ const getUrlInfo = async (text, opts = {
98
66
  mediaTypeOverride: 'thumbnail-link',
99
67
  options: opts.fetchOpts
100
68
  });
101
- urlInfo.jpegThumbnail = imageMessage?.jpegThumbnail ? Buffer.from(imageMessage.jpegThumbnail) : undefined;
69
+ urlInfo.jpegThumbnail = (imageMessage === null || imageMessage === void 0 ? void 0 : imageMessage.jpegThumbnail)
70
+ ? Buffer.from(imageMessage.jpegThumbnail)
71
+ : undefined;
102
72
  urlInfo.highQualityThumbnail = imageMessage || undefined;
103
73
  }
104
74
  else {
105
75
  try {
106
- urlInfo.jpegThumbnail = image ? (await getCompressedJpegThumbnail(image, opts)).buffer : undefined;
76
+ urlInfo.jpegThumbnail = image
77
+ ? (await getCompressedJpegThumbnail(image, opts)).buffer
78
+ : undefined;
107
79
  }
108
80
  catch (error) {
109
- opts.logger?.debug({ err: error.stack, url: previewLink }, 'error in generating thumbnail');
81
+ (_a = opts.logger) === null || _a === void 0 ? void 0 : _a.debug({ err: error.stack, url: previewLink }, 'error in generating thumbnail');
110
82
  }
111
83
  }
112
84
  return urlInfo;
@@ -1,12 +1,4 @@
1
- import P from 'pino';
2
- export interface ILogger {
3
- level: string;
4
- child(obj: Record<string, unknown>): ILogger;
5
- trace(obj: unknown, msg?: string): void;
6
- debug(obj: unknown, msg?: string): void;
7
- info(obj: unknown, msg?: string): void;
8
- warn(obj: unknown, msg?: string): void;
9
- error(obj: unknown, msg?: string): void;
10
- }
11
- declare const _default: P.Logger<never, boolean>;
1
+ declare const _default: import("pino").Logger<{
2
+ timestamp: () => string;
3
+ }>;
12
4
  export default _default;
@@ -1,12 +1,12 @@
1
- declare class LTHash {
1
+ declare class d {
2
2
  salt: string;
3
3
  constructor(e: string);
4
- add(e: ArrayBuffer, t: ArrayBuffer[]): Promise<ArrayBuffer>;
5
- subtract(e: ArrayBuffer, t: ArrayBuffer[]): Promise<ArrayBuffer>;
6
- subtractThenAdd(e: ArrayBuffer, addList: ArrayBuffer[], subtractList: ArrayBuffer[]): Promise<ArrayBuffer>;
7
- private _addSingle;
8
- private _subtractSingle;
9
- private performPointwiseWithOverflow;
4
+ add(e: any, t: any): any;
5
+ subtract(e: any, t: any): any;
6
+ subtractThenAdd(e: any, t: any, r: any): any;
7
+ _addSingle(e: any, t: any): ArrayBuffer;
8
+ _subtractSingle(e: any, t: any): ArrayBuffer;
9
+ performPointwiseWithOverflow(e: any, t: any, r: any): ArrayBuffer;
10
10
  }
11
- export declare const LT_HASH_ANTI_TAMPERING: LTHash;
11
+ export declare const LT_HASH_ANTI_TAMPERING: d;
12
12
  export {};
@@ -8,43 +8,44 @@ const crypto_1 = require("./crypto");
8
8
  * if the same series of mutations was made sequentially.
9
9
  */
10
10
  const o = 128;
11
- class LTHash {
11
+ class d {
12
12
  constructor(e) {
13
13
  this.salt = e;
14
14
  }
15
- async add(e, t) {
15
+ add(e, t) {
16
+ var r = this;
16
17
  for (const item of t) {
17
- e = await this._addSingle(e, item);
18
+ e = r._addSingle(e, item);
18
19
  }
19
20
  return e;
20
21
  }
21
- async subtract(e, t) {
22
+ subtract(e, t) {
23
+ var r = this;
22
24
  for (const item of t) {
23
- e = await this._subtractSingle(e, item);
25
+ e = r._subtractSingle(e, item);
24
26
  }
25
27
  return e;
26
28
  }
27
- async subtractThenAdd(e, addList, subtractList) {
28
- const subtracted = await this.subtract(e, subtractList);
29
- return this.add(subtracted, addList);
29
+ subtractThenAdd(e, t, r) {
30
+ var n = this;
31
+ return n.add(n.subtract(e, r), t);
30
32
  }
31
- async _addSingle(e, t) {
32
- const derived = new Uint8Array(await (0, crypto_1.hkdf)(Buffer.from(t), o, { info: this.salt })).buffer;
33
- return this.performPointwiseWithOverflow(e, derived, (a, b) => a + b);
33
+ _addSingle(e, t) {
34
+ var r = this;
35
+ const n = new Uint8Array((0, crypto_1.hkdf)(Buffer.from(t), o, { info: r.salt })).buffer;
36
+ return r.performPointwiseWithOverflow(e, n, ((e, t) => e + t));
34
37
  }
35
- async _subtractSingle(e, t) {
36
- const derived = new Uint8Array(await (0, crypto_1.hkdf)(Buffer.from(t), o, { info: this.salt })).buffer;
37
- return this.performPointwiseWithOverflow(e, derived, (a, b) => a - b);
38
+ _subtractSingle(e, t) {
39
+ var r = this;
40
+ const n = new Uint8Array((0, crypto_1.hkdf)(Buffer.from(t), o, { info: r.salt })).buffer;
41
+ return r.performPointwiseWithOverflow(e, n, ((e, t) => e - t));
38
42
  }
39
- performPointwiseWithOverflow(e, t, op) {
40
- const n = new DataView(e);
41
- const i = new DataView(t);
42
- const out = new ArrayBuffer(n.byteLength);
43
- const s = new DataView(out);
44
- for (let offset = 0; offset < n.byteLength; offset += 2) {
45
- s.setUint16(offset, op(n.getUint16(offset, true), i.getUint16(offset, true)), true);
43
+ performPointwiseWithOverflow(e, t, r) {
44
+ const n = new DataView(e), i = new DataView(t), a = new ArrayBuffer(n.byteLength), s = new DataView(a);
45
+ for (let e = 0; e < n.byteLength; e += 2) {
46
+ s.setUint16(e, r(n.getUint16(e, !0), i.getUint16(e, !0)), !0);
46
47
  }
47
- return out;
48
+ return a;
48
49
  }
49
50
  }
50
- exports.LT_HASH_ANTI_TAMPERING = new LTHash('WhatsApp Patch Integrity');
51
+ exports.LT_HASH_ANTI_TAMPERING = new d('WhatsApp Patch Integrity');
@@ -1,7 +1,7 @@
1
1
  export declare const makeMutex: () => {
2
- mutex<T>(code: () => Promise<T> | T): Promise<T>;
2
+ mutex<T>(code: () => T | Promise<T>): Promise<T>;
3
3
  };
4
4
  export type Mutex = ReturnType<typeof makeMutex>;
5
5
  export declare const makeKeyedMutex: () => {
6
- mutex<T>(key: string, task: () => Promise<T> | T): Promise<T>;
6
+ mutex<T>(key: string, task: () => T | Promise<T>): Promise<T>;
7
7
  };
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeKeyedMutex = exports.makeMutex = void 0;
4
4
  const makeMutex = () => {
5
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
5
  let task = Promise.resolve();
7
6
  let taskTimeout;
8
7
  return {
@@ -13,7 +12,7 @@ const makeMutex = () => {
13
12
  try {
14
13
  await task;
15
14
  }
16
- catch { }
15
+ catch (_a) { }
17
16
  try {
18
17
  // execute the current task
19
18
  const result = await code();
@@ -26,7 +25,7 @@ const makeMutex = () => {
26
25
  // we replace the existing task, appending the new piece of execution to it
27
26
  // so the next task will have to wait for this one to finish
28
27
  return task;
29
- }
28
+ },
30
29
  };
31
30
  };
32
31
  exports.makeMutex = makeMutex;
@@ -1,33 +1,27 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
1
4
  import { Boom } from '@hapi/boom';
2
- import { type AxiosRequestConfig } from 'axios';
5
+ import { AxiosRequestConfig } from 'axios';
6
+ import type { Logger } from 'pino';
3
7
  import { Readable, Transform } from 'stream';
4
8
  import { URL } from 'url';
5
- import { proto } from '../../WAProto/index.js';
6
- import { type MediaType } from '../Defaults';
7
- import type { DownloadableMessage, MediaConnInfo, MediaDecryptionKeyInfo, SocketConfig, WAMediaUpload, WAMediaUploadFunction, WAMessageContent } from '../Types';
8
- import { type BinaryNode } from '../WABinary';
9
- import type { ILogger } from './logger';
9
+ import { proto } from '../../WAProto';
10
+ import { DownloadableMessage, MediaConnInfo, MediaDecryptionKeyInfo, MediaType, SocketConfig, WAMediaUpload, WAMediaUploadFunction, WAMessageContent } from '../Types';
11
+ import { BinaryNode } from '../WABinary';
10
12
  export declare const hkdfInfoKey: (type: MediaType) => string;
11
- export declare const getRawMediaUploadData: (media: WAMediaUpload, mediaType: MediaType, logger?: ILogger) => Promise<{
12
- filePath: string;
13
- fileSha256: Buffer<ArrayBufferLike>;
14
- fileLength: number;
15
- }>;
16
13
  /** generates all the keys required to encrypt/decrypt & sign a media message */
17
- export declare function getMediaKeys(buffer: Uint8Array | string | null | undefined, mediaType: MediaType): Promise<MediaDecryptionKeyInfo>;
14
+ export declare function getMediaKeys(buffer: Uint8Array | string | null | undefined, mediaType: MediaType): MediaDecryptionKeyInfo;
18
15
  export declare const extractImageThumb: (bufferOrFilePath: Readable | Buffer | string, width?: number) => Promise<{
19
- buffer: any;
16
+ buffer: Buffer;
20
17
  original: {
21
- width: any;
22
- height: any;
18
+ width: number | undefined;
19
+ height: number | undefined;
23
20
  };
24
21
  }>;
25
22
  export declare const encodeBase64EncodedStringForUpload: (b64: string) => string;
26
- export declare const generateProfilePicture: (mediaUpload: WAMediaUpload, dimensions?: {
27
- width: number;
28
- height: number;
29
- }) => Promise<{
30
- img: Buffer<ArrayBufferLike>;
23
+ export declare const generateProfilePicture: (mediaUpload: WAMediaUpload) => Promise<{
24
+ img: Buffer;
31
25
  }>;
32
26
  /** gets the SHA256 of the given media message */
33
27
  export declare const mediaMessageSHA256B64: (message: WAMessageContent) => string | null | undefined;
@@ -35,9 +29,9 @@ export declare function getAudioDuration(buffer: Buffer | string | Readable): Pr
35
29
  /**
36
30
  referenced from and modifying https://github.com/wppconnect-team/wa-js/blob/main/src/chat/functions/prepareAudioWaveform.ts
37
31
  */
38
- export declare function getAudioWaveform(buffer: Buffer | string | Readable, logger?: ILogger): Promise<Uint8Array<ArrayBuffer> | undefined>;
32
+ export declare function getAudioWaveform(buffer: Buffer | string | Readable, logger?: Logger): Promise<Uint8Array | undefined>;
39
33
  export declare const toReadable: (buffer: Buffer) => Readable;
40
- export declare const toBuffer: (stream: Readable) => Promise<Buffer<ArrayBuffer>>;
34
+ export declare const toBuffer: (stream: Readable) => Promise<Buffer>;
41
35
  export declare const getStream: (item: WAMediaUpload, opts?: AxiosRequestConfig) => Promise<{
42
36
  readonly stream: Readable;
43
37
  readonly type: "buffer";
@@ -53,7 +47,7 @@ export declare const getStream: (item: WAMediaUpload, opts?: AxiosRequestConfig)
53
47
  }>;
54
48
  /** generates a thumbnail for a given media, if required */
55
49
  export declare function generateThumbnail(file: string, mediaType: 'video' | 'image', options: {
56
- logger?: ILogger;
50
+ logger?: Logger;
57
51
  }): Promise<{
58
52
  thumbnail: string | undefined;
59
53
  originalImageDimensions: {
@@ -66,22 +60,32 @@ export declare const getHttpStream: (url: string | URL, options?: AxiosRequestCo
66
60
  }) => Promise<Readable>;
67
61
  type EncryptedStreamOptions = {
68
62
  saveOriginalFileIfRequired?: boolean;
69
- logger?: ILogger;
63
+ logger?: Logger;
70
64
  opts?: AxiosRequestConfig;
71
65
  };
66
+ export declare const prepareStream: (media: WAMediaUpload, mediaType: MediaType, { logger, saveOriginalFileIfRequired, opts }?: EncryptedStreamOptions) => Promise<{
67
+ mediaKey: undefined;
68
+ encWriteStream: Buffer;
69
+ fileLength: number;
70
+ fileSha256: Buffer;
71
+ fileEncSha256: undefined;
72
+ bodyPath: string | undefined;
73
+ didSaveToTmpPath: boolean;
74
+ }>;
72
75
  export declare const encryptedStream: (media: WAMediaUpload, mediaType: MediaType, { logger, saveOriginalFileIfRequired, opts }?: EncryptedStreamOptions) => Promise<{
73
- mediaKey: Buffer<ArrayBufferLike>;
74
- originalFilePath: string | undefined;
75
- encFilePath: string;
76
- mac: Buffer<ArrayBuffer>;
77
- fileEncSha256: Buffer<ArrayBufferLike>;
78
- fileSha256: Buffer<ArrayBufferLike>;
76
+ mediaKey: Buffer;
77
+ encWriteStream: Readable;
78
+ bodyPath: string | undefined;
79
+ mac: Buffer;
80
+ fileEncSha256: Buffer;
81
+ fileSha256: Buffer;
79
82
  fileLength: number;
83
+ didSaveToTmpPath: boolean;
80
84
  }>;
81
85
  export type MediaDownloadOptions = {
82
86
  startByte?: number;
83
87
  endByte?: number;
84
- options?: AxiosRequestConfig<{}>;
88
+ options?: AxiosRequestConfig<any>;
85
89
  };
86
90
  export declare const getUrlFromDirectPath: (directPath: string) => string;
87
91
  export declare const downloadContentFromMessage: ({ mediaKey, directPath, url }: DownloadableMessage, type: MediaType, opts?: MediaDownloadOptions) => Promise<Transform>;
@@ -95,18 +99,18 @@ export declare const getWAUploadToServer: ({ customUploadHosts, fetchAgent, logg
95
99
  /**
96
100
  * Generate a binary node that will request the phone to re-upload the media & return the newly uploaded URL
97
101
  */
98
- export declare const encryptMediaRetryRequest: (key: proto.IMessageKey, mediaKey: Buffer | Uint8Array, meId: string) => Promise<BinaryNode>;
102
+ export declare const encryptMediaRetryRequest: (key: proto.IMessageKey, mediaKey: Buffer | Uint8Array, meId: string) => BinaryNode;
99
103
  export declare const decodeMediaRetryNode: (node: BinaryNode) => {
100
- key: import("../Types").WAMessageKey;
104
+ key: proto.IMessageKey;
101
105
  media?: {
102
106
  ciphertext: Uint8Array;
103
107
  iv: Uint8Array;
104
- };
105
- error?: Boom;
108
+ } | undefined;
109
+ error?: Boom<any> | undefined;
106
110
  };
107
111
  export declare const decryptMediaRetryData: ({ ciphertext, iv }: {
108
112
  ciphertext: Uint8Array;
109
113
  iv: Uint8Array;
110
- }, mediaKey: Uint8Array, msgId: string) => Promise<proto.MediaRetryNotification>;
111
- export declare const getStatusCodeForMediaRetry: (code: number) => 200 | 412 | 404 | 418;
114
+ }, mediaKey: Uint8Array, msgId: string) => proto.MediaRetryNotification;
115
+ export declare const getStatusCodeForMediaRetry: (code: number) => any;
112
116
  export {};