@d0v3riz/baileys 6.7.12 → 6.7.17

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 (161) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +35 -1267
  3. package/WAProto/index.d.ts +16106 -2739
  4. package/WAProto/index.js +128593 -73944
  5. package/engine-requirements.js +10 -0
  6. package/lib/Defaults/baileys-version.json +3 -3
  7. package/lib/Defaults/index.d.ts +51 -53
  8. package/lib/Defaults/index.js +105 -106
  9. package/lib/Signal/libsignal.d.ts +3 -3
  10. package/lib/Signal/libsignal.js +161 -152
  11. package/lib/Socket/Client/index.d.ts +2 -2
  12. package/lib/Socket/Client/index.js +18 -18
  13. package/lib/Socket/Client/types.d.ts +15 -17
  14. package/lib/Socket/Client/types.js +13 -13
  15. package/lib/Socket/Client/websocket.d.ts +12 -12
  16. package/lib/Socket/Client/websocket.js +62 -62
  17. package/lib/Socket/business.d.ts +146 -148
  18. package/lib/Socket/business.js +260 -260
  19. package/lib/Socket/chats.d.ts +85 -84
  20. package/lib/Socket/chats.js +880 -846
  21. package/lib/Socket/groups.d.ts +124 -123
  22. package/lib/Socket/groups.js +314 -314
  23. package/lib/Socket/index.d.ts +146 -148
  24. package/lib/Socket/index.js +10 -10
  25. package/lib/Socket/messages-recv.d.ts +135 -135
  26. package/lib/Socket/messages-recv.js +920 -913
  27. package/lib/Socket/messages-send.d.ts +130 -129
  28. package/lib/Socket/messages-send.js +683 -673
  29. package/lib/Socket/socket.d.ts +42 -45
  30. package/lib/Socket/socket.js +622 -622
  31. package/lib/Socket/usync.d.ts +36 -38
  32. package/lib/Socket/usync.js +70 -70
  33. package/lib/Types/Auth.d.ts +103 -105
  34. package/lib/Types/Auth.js +2 -2
  35. package/lib/Types/Call.d.ts +13 -13
  36. package/lib/Types/Call.js +2 -2
  37. package/lib/Types/Chat.d.ts +112 -107
  38. package/lib/Types/Chat.js +4 -4
  39. package/lib/Types/Contact.d.ts +19 -19
  40. package/lib/Types/Contact.js +2 -2
  41. package/lib/Types/Events.d.ts +172 -172
  42. package/lib/Types/Events.js +2 -2
  43. package/lib/Types/GroupMetadata.d.ts +56 -56
  44. package/lib/Types/GroupMetadata.js +2 -2
  45. package/lib/Types/Label.d.ts +46 -46
  46. package/lib/Types/Label.js +27 -27
  47. package/lib/Types/LabelAssociation.d.ts +29 -29
  48. package/lib/Types/LabelAssociation.js +9 -9
  49. package/lib/Types/Message.d.ts +269 -273
  50. package/lib/Types/Message.js +7 -9
  51. package/lib/Types/Product.d.ts +78 -78
  52. package/lib/Types/Product.js +2 -2
  53. package/lib/Types/Signal.d.ts +57 -57
  54. package/lib/Types/Signal.js +2 -2
  55. package/lib/Types/Socket.d.ts +121 -118
  56. package/lib/Types/Socket.js +2 -2
  57. package/lib/Types/State.d.ts +27 -27
  58. package/lib/Types/State.js +2 -2
  59. package/lib/Types/USync.d.ts +25 -25
  60. package/lib/Types/USync.js +2 -2
  61. package/lib/Types/index.d.ts +63 -63
  62. package/lib/Types/index.js +41 -41
  63. package/lib/Utils/auth-utils.d.ts +18 -18
  64. package/lib/Utils/auth-utils.js +200 -200
  65. package/lib/Utils/baileys-event-stream.d.ts +16 -16
  66. package/lib/Utils/baileys-event-stream.js +63 -63
  67. package/lib/Utils/business.d.ts +22 -22
  68. package/lib/Utils/business.js +234 -234
  69. package/lib/Utils/chat-utils.d.ts +70 -72
  70. package/lib/Utils/chat-utils.js +745 -745
  71. package/lib/Utils/crypto.d.ts +40 -42
  72. package/lib/Utils/crypto.js +193 -153
  73. package/lib/Utils/decode-wa-message.d.ts +36 -36
  74. package/lib/Utils/decode-wa-message.js +205 -205
  75. package/lib/Utils/event-buffer.d.ts +35 -35
  76. package/lib/Utils/event-buffer.js +520 -520
  77. package/lib/Utils/generics.d.ts +90 -94
  78. package/lib/Utils/generics.js +398 -421
  79. package/lib/Utils/history.d.ts +19 -19
  80. package/lib/Utils/history.js +94 -94
  81. package/lib/Utils/index.d.ts +17 -17
  82. package/lib/Utils/index.js +33 -33
  83. package/lib/Utils/link-preview.d.ts +21 -21
  84. package/lib/Utils/link-preview.js +126 -116
  85. package/lib/Utils/logger.d.ts +11 -4
  86. package/lib/Utils/logger.js +7 -7
  87. package/lib/Utils/lt-hash.d.ts +12 -12
  88. package/lib/Utils/lt-hash.js +51 -51
  89. package/lib/Utils/make-mutex.d.ts +7 -7
  90. package/lib/Utils/make-mutex.js +44 -44
  91. package/lib/Utils/messages-media.d.ts +104 -108
  92. package/lib/Utils/messages-media.js +677 -667
  93. package/lib/Utils/messages.d.ts +75 -78
  94. package/lib/Utils/messages.js +765 -762
  95. package/lib/Utils/noise-handler.d.ts +19 -21
  96. package/lib/Utils/noise-handler.js +150 -150
  97. package/lib/Utils/process-message.d.ts +41 -42
  98. package/lib/Utils/process-message.js +382 -371
  99. package/lib/Utils/signal.d.ts +33 -33
  100. package/lib/Utils/signal.js +153 -153
  101. package/lib/Utils/use-multi-file-auth-state.d.ts +12 -12
  102. package/lib/Utils/use-multi-file-auth-state.js +125 -94
  103. package/lib/Utils/validate-connection.d.ts +10 -10
  104. package/lib/Utils/validate-connection.js +175 -175
  105. package/lib/WABinary/constants.d.ts +27 -27
  106. package/lib/WABinary/constants.js +40 -40
  107. package/lib/WABinary/decode.d.ts +6 -8
  108. package/lib/WABinary/decode.js +264 -254
  109. package/lib/WABinary/encode.d.ts +2 -4
  110. package/lib/WABinary/encode.js +252 -234
  111. package/lib/WABinary/generic-utils.d.ts +14 -16
  112. package/lib/WABinary/generic-utils.js +110 -110
  113. package/lib/WABinary/index.d.ts +5 -5
  114. package/lib/WABinary/index.js +21 -21
  115. package/lib/WABinary/jid-utils.d.ts +33 -31
  116. package/lib/WABinary/jid-utils.js +66 -62
  117. package/lib/WABinary/types.d.ts +18 -18
  118. package/lib/WABinary/types.js +2 -2
  119. package/lib/WAM/BinaryInfo.d.ts +8 -18
  120. package/lib/WAM/BinaryInfo.js +13 -13
  121. package/lib/WAM/constants.d.ts +39 -39
  122. package/lib/WAM/constants.js +15350 -15350
  123. package/lib/WAM/encode.d.ts +2 -4
  124. package/lib/WAM/encode.js +155 -155
  125. package/lib/WAM/index.d.ts +3 -3
  126. package/lib/WAM/index.js +19 -19
  127. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -9
  128. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -32
  129. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -22
  130. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -57
  131. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -12
  132. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -30
  133. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -12
  134. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -42
  135. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
  136. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  137. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
  138. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  139. package/lib/WAUSync/Protocols/index.d.ts +4 -4
  140. package/lib/WAUSync/Protocols/index.js +20 -20
  141. package/lib/WAUSync/USyncQuery.d.ts +28 -26
  142. package/lib/WAUSync/USyncQuery.js +89 -79
  143. package/lib/WAUSync/USyncUser.d.ts +12 -10
  144. package/lib/WAUSync/USyncUser.js +26 -22
  145. package/lib/WAUSync/index.d.ts +3 -3
  146. package/lib/WAUSync/index.js +19 -19
  147. package/lib/index.d.ts +11 -12
  148. package/lib/index.js +30 -31
  149. package/package.json +27 -35
  150. package/WAProto/GenerateStatics.sh +0 -4
  151. package/WAProto/WAProto.proto +0 -3344
  152. package/lib/Store/index.d.ts +0 -3
  153. package/lib/Store/index.js +0 -10
  154. package/lib/Store/make-cache-manager-store.d.ts +0 -14
  155. package/lib/Store/make-cache-manager-store.js +0 -83
  156. package/lib/Store/make-in-memory-store.d.ts +0 -118
  157. package/lib/Store/make-in-memory-store.js +0 -420
  158. package/lib/Store/make-ordered-dictionary.d.ts +0 -13
  159. package/lib/Store/make-ordered-dictionary.js +0 -81
  160. package/lib/Store/object-repository.d.ts +0 -10
  161. package/lib/Store/object-repository.js +0 -27
@@ -1,78 +1,78 @@
1
- import { WAMediaUpload } from './Message';
2
- export type CatalogResult = {
3
- data: {
4
- paging: {
5
- cursors: {
6
- before: string;
7
- after: string;
8
- };
9
- };
10
- data: any[];
11
- };
12
- };
13
- export type ProductCreateResult = {
14
- data: {
15
- product: {};
16
- };
17
- };
18
- export type CatalogStatus = {
19
- status: string;
20
- canAppeal: boolean;
21
- };
22
- export type CatalogCollection = {
23
- id: string;
24
- name: string;
25
- products: Product[];
26
- status: CatalogStatus;
27
- };
28
- export type ProductAvailability = 'in stock';
29
- export type ProductBase = {
30
- name: string;
31
- retailerId?: string;
32
- url?: string;
33
- description: string;
34
- price: number;
35
- currency: string;
36
- isHidden?: boolean;
37
- };
38
- export type ProductCreate = ProductBase & {
39
- /** ISO country code for product origin. Set to undefined for no country */
40
- originCountryCode: string | undefined;
41
- /** images of the product */
42
- images: WAMediaUpload[];
43
- };
44
- export type ProductUpdate = Omit<ProductCreate, 'originCountryCode'>;
45
- export type Product = ProductBase & {
46
- id: string;
47
- imageUrls: {
48
- [_: string]: string;
49
- };
50
- reviewStatus: {
51
- [_: string]: string;
52
- };
53
- availability: ProductAvailability;
54
- };
55
- export type OrderPrice = {
56
- currency: string;
57
- total: number;
58
- };
59
- export type OrderProduct = {
60
- id: string;
61
- imageUrl: string;
62
- name: string;
63
- quantity: number;
64
- currency: string;
65
- price: number;
66
- };
67
- export type OrderDetails = {
68
- price: OrderPrice;
69
- products: OrderProduct[];
70
- };
71
- export type CatalogCursor = string;
72
- export type GetCatalogOptions = {
73
- /** cursor to start from */
74
- cursor?: CatalogCursor;
75
- /** number of products to fetch */
76
- limit?: number;
77
- jid?: string;
78
- };
1
+ import { WAMediaUpload } from './Message';
2
+ export type CatalogResult = {
3
+ data: {
4
+ paging: {
5
+ cursors: {
6
+ before: string;
7
+ after: string;
8
+ };
9
+ };
10
+ data: any[];
11
+ };
12
+ };
13
+ export type ProductCreateResult = {
14
+ data: {
15
+ product: {};
16
+ };
17
+ };
18
+ export type CatalogStatus = {
19
+ status: string;
20
+ canAppeal: boolean;
21
+ };
22
+ export type CatalogCollection = {
23
+ id: string;
24
+ name: string;
25
+ products: Product[];
26
+ status: CatalogStatus;
27
+ };
28
+ export type ProductAvailability = 'in stock';
29
+ export type ProductBase = {
30
+ name: string;
31
+ retailerId?: string;
32
+ url?: string;
33
+ description: string;
34
+ price: number;
35
+ currency: string;
36
+ isHidden?: boolean;
37
+ };
38
+ export type ProductCreate = ProductBase & {
39
+ /** ISO country code for product origin. Set to undefined for no country */
40
+ originCountryCode: string | undefined;
41
+ /** images of the product */
42
+ images: WAMediaUpload[];
43
+ };
44
+ export type ProductUpdate = Omit<ProductCreate, 'originCountryCode'>;
45
+ export type Product = ProductBase & {
46
+ id: string;
47
+ imageUrls: {
48
+ [_: string]: string;
49
+ };
50
+ reviewStatus: {
51
+ [_: string]: string;
52
+ };
53
+ availability: ProductAvailability;
54
+ };
55
+ export type OrderPrice = {
56
+ currency: string;
57
+ total: number;
58
+ };
59
+ export type OrderProduct = {
60
+ id: string;
61
+ imageUrl: string;
62
+ name: string;
63
+ quantity: number;
64
+ currency: string;
65
+ price: number;
66
+ };
67
+ export type OrderDetails = {
68
+ price: OrderPrice;
69
+ products: OrderProduct[];
70
+ };
71
+ export type CatalogCursor = string;
72
+ export type GetCatalogOptions = {
73
+ /** cursor to start from */
74
+ cursor?: CatalogCursor;
75
+ /** number of products to fetch */
76
+ limit?: number;
77
+ jid?: string;
78
+ };
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,57 +1,57 @@
1
- import { proto } from '../../WAProto';
2
- type DecryptGroupSignalOpts = {
3
- group: string;
4
- authorJid: string;
5
- msg: Uint8Array;
6
- };
7
- type ProcessSenderKeyDistributionMessageOpts = {
8
- item: proto.Message.ISenderKeyDistributionMessage;
9
- authorJid: string;
10
- };
11
- type DecryptSignalProtoOpts = {
12
- jid: string;
13
- type: 'pkmsg' | 'msg';
14
- ciphertext: Uint8Array;
15
- };
16
- type EncryptMessageOpts = {
17
- jid: string;
18
- data: Uint8Array;
19
- };
20
- type EncryptGroupMessageOpts = {
21
- group: string;
22
- data: Uint8Array;
23
- meId: string;
24
- };
25
- type PreKey = {
26
- keyId: number;
27
- publicKey: Uint8Array;
28
- };
29
- type SignedPreKey = PreKey & {
30
- signature: Uint8Array;
31
- };
32
- type E2ESession = {
33
- registrationId: number;
34
- identityKey: Uint8Array;
35
- signedPreKey: SignedPreKey;
36
- preKey: PreKey;
37
- };
38
- type E2ESessionOpts = {
39
- jid: string;
40
- session: E2ESession;
41
- };
42
- export type SignalRepository = {
43
- decryptGroupMessage(opts: DecryptGroupSignalOpts): Promise<Uint8Array>;
44
- processSenderKeyDistributionMessage(opts: ProcessSenderKeyDistributionMessageOpts): Promise<void>;
45
- decryptMessage(opts: DecryptSignalProtoOpts): Promise<Uint8Array>;
46
- encryptMessage(opts: EncryptMessageOpts): Promise<{
47
- type: 'pkmsg' | 'msg';
48
- ciphertext: Uint8Array;
49
- }>;
50
- encryptGroupMessage(opts: EncryptGroupMessageOpts): Promise<{
51
- senderKeyDistributionMessage: Uint8Array;
52
- ciphertext: Uint8Array;
53
- }>;
54
- injectE2ESession(opts: E2ESessionOpts): Promise<void>;
55
- jidToSignalProtocolAddress(jid: string): string;
56
- };
57
- export {};
1
+ import { proto } from '../../WAProto';
2
+ type DecryptGroupSignalOpts = {
3
+ group: string;
4
+ authorJid: string;
5
+ msg: Uint8Array;
6
+ };
7
+ type ProcessSenderKeyDistributionMessageOpts = {
8
+ item: proto.Message.ISenderKeyDistributionMessage;
9
+ authorJid: string;
10
+ };
11
+ type DecryptSignalProtoOpts = {
12
+ jid: string;
13
+ type: 'pkmsg' | 'msg';
14
+ ciphertext: Uint8Array;
15
+ };
16
+ type EncryptMessageOpts = {
17
+ jid: string;
18
+ data: Uint8Array;
19
+ };
20
+ type EncryptGroupMessageOpts = {
21
+ group: string;
22
+ data: Uint8Array;
23
+ meId: string;
24
+ };
25
+ type PreKey = {
26
+ keyId: number;
27
+ publicKey: Uint8Array;
28
+ };
29
+ type SignedPreKey = PreKey & {
30
+ signature: Uint8Array;
31
+ };
32
+ type E2ESession = {
33
+ registrationId: number;
34
+ identityKey: Uint8Array;
35
+ signedPreKey: SignedPreKey;
36
+ preKey: PreKey;
37
+ };
38
+ type E2ESessionOpts = {
39
+ jid: string;
40
+ session: E2ESession;
41
+ };
42
+ export type SignalRepository = {
43
+ decryptGroupMessage(opts: DecryptGroupSignalOpts): Promise<Uint8Array>;
44
+ processSenderKeyDistributionMessage(opts: ProcessSenderKeyDistributionMessageOpts): Promise<void>;
45
+ decryptMessage(opts: DecryptSignalProtoOpts): Promise<Uint8Array>;
46
+ encryptMessage(opts: EncryptMessageOpts): Promise<{
47
+ type: 'pkmsg' | 'msg';
48
+ ciphertext: Uint8Array;
49
+ }>;
50
+ encryptGroupMessage(opts: EncryptGroupMessageOpts): Promise<{
51
+ senderKeyDistributionMessage: Uint8Array;
52
+ ciphertext: Uint8Array;
53
+ }>;
54
+ injectE2ESession(opts: E2ESessionOpts): Promise<void>;
55
+ jidToSignalProtocolAddress(jid: string): string;
56
+ };
57
+ export {};
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,118 +1,121 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { AxiosRequestConfig } from 'axios';
4
- import type { Agent } from 'https';
5
- import type { Logger } from 'pino';
6
- import type { URL } from 'url';
7
- import { proto } from '../../WAProto';
8
- import { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth';
9
- import { GroupMetadata } from './GroupMetadata';
10
- import { MediaConnInfo } from './Message';
11
- import { SignalRepository } from './Signal';
12
- export type WAVersion = [number, number, number];
13
- export type WABrowserDescription = [string, string, string];
14
- export type CacheStore = {
15
- /** get a cached key and change the stats */
16
- get<T>(key: string): T | undefined;
17
- /** set a key in the cache */
18
- set<T>(key: string, value: T): void;
19
- /** delete a key from the cache */
20
- del(key: string): void;
21
- /** flush all data */
22
- flushAll(): void;
23
- };
24
- export type SocketConfig = {
25
- /** the WS url to connect to WA */
26
- waWebSocketUrl: string | URL;
27
- /** Fails the connection if the socket times out in this interval */
28
- connectTimeoutMs: number;
29
- /** Default timeout for queries, undefined for no timeout */
30
- defaultQueryTimeoutMs: number | undefined;
31
- /** ping-pong interval for WS connection */
32
- keepAliveIntervalMs: number;
33
- /** should baileys use the mobile api instead of the multi device api
34
- * @deprecated This feature has been removed
35
- */
36
- mobile?: boolean;
37
- /** proxy agent */
38
- agent?: Agent;
39
- /** pino logger */
40
- logger: Logger;
41
- /** version to connect with */
42
- version: WAVersion;
43
- /** override browser config */
44
- browser: WABrowserDescription;
45
- /** agent used for fetch requests -- uploading/downloading media */
46
- fetchAgent?: Agent;
47
- /** should the QR be printed in the terminal */
48
- printQRInTerminal: boolean;
49
- /** should events be emitted for actions done by this socket connection */
50
- emitOwnEvents: boolean;
51
- /** custom upload hosts to upload media to */
52
- customUploadHosts: MediaConnInfo['hosts'];
53
- /** time to wait between sending new retry requests */
54
- retryRequestDelayMs: number;
55
- /** max retry count */
56
- maxMsgRetryCount: number;
57
- /** time to wait for the generation of the next QR in ms */
58
- qrTimeout?: number;
59
- /** provide an auth state object to maintain the auth state */
60
- auth: AuthenticationState;
61
- /** manage history processing with this control; by default will sync up everything */
62
- shouldSyncHistoryMessage: (msg: proto.Message.IHistorySyncNotification) => boolean;
63
- /** transaction capability options for SignalKeyStore */
64
- transactionOpts: TransactionCapabilityOptions;
65
- /** marks the client as online whenever the socket successfully connects */
66
- markOnlineOnConnect: boolean;
67
- /** alphanumeric country code (USA -> US) for the number used */
68
- countryCode: string;
69
- /** provide a cache to store media, so does not have to be re-uploaded */
70
- mediaCache?: CacheStore;
71
- /**
72
- * map to store the retry counts for failed messages;
73
- * used to determine whether to retry a message or not */
74
- msgRetryCounterCache?: CacheStore;
75
- /** provide a cache to store a user's device list */
76
- userDevicesCache?: CacheStore;
77
- /** cache to store call offers */
78
- callOfferCache?: CacheStore;
79
- /** cache to track placeholder resends */
80
- placeholderResendCache?: CacheStore;
81
- /** width for link preview images */
82
- linkPreviewImageThumbnailWidth: number;
83
- /** Should Baileys ask the phone for full history, will be received async */
84
- syncFullHistory: boolean;
85
- /** Should baileys fire init queries automatically, default true */
86
- fireInitQueries: boolean;
87
- /**
88
- * generate a high quality link preview,
89
- * entails uploading the jpegThumbnail to WA
90
- * */
91
- generateHighQualityLinkPreview: boolean;
92
- /**
93
- * Returns if a jid should be ignored,
94
- * no event for that jid will be triggered.
95
- * Messages from that jid will also not be decrypted
96
- * */
97
- shouldIgnoreJid: (jid: string) => boolean | undefined;
98
- /**
99
- * Optionally patch the message before sending out
100
- * */
101
- patchMessageBeforeSending: (msg: proto.IMessage, recipientJids: string[]) => Promise<proto.IMessage> | proto.IMessage;
102
- /** verify app state MACs */
103
- appStateMacVerification: {
104
- patch: boolean;
105
- snapshot: boolean;
106
- };
107
- /** options for axios */
108
- options: AxiosRequestConfig<{}>;
109
- /**
110
- * fetch a message from your store
111
- * implement this so that messages failed to send
112
- * (solves the "this message can take a while" issue) can be retried
113
- * */
114
- getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>;
115
- /** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
116
- cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>;
117
- makeSignalRepository: (auth: SignalAuthState) => SignalRepository;
118
- };
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import type { Agent } from 'https';
3
+ import type { URL } from 'url';
4
+ import { proto } from '../../WAProto';
5
+ import { ILogger } from '../Utils/logger';
6
+ import { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth';
7
+ import { GroupMetadata } from './GroupMetadata';
8
+ import { MediaConnInfo } from './Message';
9
+ import { SignalRepository } from './Signal';
10
+ export type WAVersion = [number, number, number];
11
+ export type WABrowserDescription = [string, string, string];
12
+ export type CacheStore = {
13
+ /** get a cached key and change the stats */
14
+ get<T>(key: string): T | undefined;
15
+ /** set a key in the cache */
16
+ set<T>(key: string, value: T): void;
17
+ /** delete a key from the cache */
18
+ del(key: string): void;
19
+ /** flush all data */
20
+ flushAll(): void;
21
+ };
22
+ export type PatchedMessageWithRecipientJID = proto.IMessage & {
23
+ recipientJid?: string;
24
+ };
25
+ export type SocketConfig = {
26
+ /** the WS url to connect to WA */
27
+ waWebSocketUrl: string | URL;
28
+ /** Fails the connection if the socket times out in this interval */
29
+ connectTimeoutMs: number;
30
+ /** Default timeout for queries, undefined for no timeout */
31
+ defaultQueryTimeoutMs: number | undefined;
32
+ /** ping-pong interval for WS connection */
33
+ keepAliveIntervalMs: number;
34
+ /** should baileys use the mobile api instead of the multi device api
35
+ * @deprecated This feature has been removed
36
+ */
37
+ mobile?: boolean;
38
+ /** proxy agent */
39
+ agent?: Agent;
40
+ /** logger */
41
+ logger: ILogger;
42
+ /** version to connect with */
43
+ version: WAVersion;
44
+ /** override browser config */
45
+ browser: WABrowserDescription;
46
+ /** agent used for fetch requests -- uploading/downloading media */
47
+ fetchAgent?: Agent;
48
+ /** should the QR be printed in the terminal
49
+ * @deprecated This feature has been removed
50
+ */
51
+ printQRInTerminal?: boolean;
52
+ /** should events be emitted for actions done by this socket connection */
53
+ emitOwnEvents: boolean;
54
+ /** custom upload hosts to upload media to */
55
+ customUploadHosts: MediaConnInfo['hosts'];
56
+ /** time to wait between sending new retry requests */
57
+ retryRequestDelayMs: number;
58
+ /** max retry count */
59
+ maxMsgRetryCount: number;
60
+ /** time to wait for the generation of the next QR in ms */
61
+ qrTimeout?: number;
62
+ /** provide an auth state object to maintain the auth state */
63
+ auth: AuthenticationState;
64
+ /** manage history processing with this control; by default will sync up everything */
65
+ shouldSyncHistoryMessage: (msg: proto.Message.IHistorySyncNotification) => boolean;
66
+ /** transaction capability options for SignalKeyStore */
67
+ transactionOpts: TransactionCapabilityOptions;
68
+ /** marks the client as online whenever the socket successfully connects */
69
+ markOnlineOnConnect: boolean;
70
+ /** alphanumeric country code (USA -> US) for the number used */
71
+ countryCode: string;
72
+ /** provide a cache to store media, so does not have to be re-uploaded */
73
+ mediaCache?: CacheStore;
74
+ /**
75
+ * map to store the retry counts for failed messages;
76
+ * used to determine whether to retry a message or not */
77
+ msgRetryCounterCache?: CacheStore;
78
+ /** provide a cache to store a user's device list */
79
+ userDevicesCache?: CacheStore;
80
+ /** cache to store call offers */
81
+ callOfferCache?: CacheStore;
82
+ /** cache to track placeholder resends */
83
+ placeholderResendCache?: CacheStore;
84
+ /** width for link preview images */
85
+ linkPreviewImageThumbnailWidth: number;
86
+ /** Should Baileys ask the phone for full history, will be received async */
87
+ syncFullHistory: boolean;
88
+ /** Should baileys fire init queries automatically, default true */
89
+ fireInitQueries: boolean;
90
+ /**
91
+ * generate a high quality link preview,
92
+ * entails uploading the jpegThumbnail to WA
93
+ * */
94
+ generateHighQualityLinkPreview: boolean;
95
+ /**
96
+ * Returns if a jid should be ignored,
97
+ * no event for that jid will be triggered.
98
+ * Messages from that jid will also not be decrypted
99
+ * */
100
+ shouldIgnoreJid: (jid: string) => boolean | undefined;
101
+ /**
102
+ * Optionally patch the message before sending out
103
+ * */
104
+ patchMessageBeforeSending: (msg: proto.IMessage, recipientJids?: string[]) => Promise<PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID> | PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID;
105
+ /** verify app state MACs */
106
+ appStateMacVerification: {
107
+ patch: boolean;
108
+ snapshot: boolean;
109
+ };
110
+ /** options for axios */
111
+ options: AxiosRequestConfig<{}>;
112
+ /**
113
+ * fetch a message from your store
114
+ * implement this so that messages failed to send
115
+ * (solves the "this message can take a while" issue) can be retried
116
+ * */
117
+ getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>;
118
+ /** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
119
+ cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>;
120
+ makeSignalRepository: (auth: SignalAuthState) => SignalRepository;
121
+ };
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,27 +1,27 @@
1
- import { Contact } from './Contact';
2
- export type WAConnectionState = 'open' | 'connecting' | 'close';
3
- export type ConnectionState = {
4
- /** connection is now open, connecting or closed */
5
- connection: WAConnectionState;
6
- /** the error that caused the connection to close */
7
- lastDisconnect?: {
8
- error: Error | undefined;
9
- date: Date;
10
- };
11
- /** is this a new login */
12
- isNewLogin?: boolean;
13
- /** the current QR code */
14
- qr?: string;
15
- /** has the device received all pending notifications while it was offline */
16
- receivedPendingNotifications?: boolean;
17
- /** legacy connection options */
18
- legacy?: {
19
- phoneConnected: boolean;
20
- user?: Contact;
21
- };
22
- /**
23
- * if the client is shown as an active, online client.
24
- * If this is false, the primary phone and other devices will receive notifs
25
- * */
26
- isOnline?: boolean;
27
- };
1
+ import { Contact } from './Contact';
2
+ export type WAConnectionState = 'open' | 'connecting' | 'close';
3
+ export type ConnectionState = {
4
+ /** connection is now open, connecting or closed */
5
+ connection: WAConnectionState;
6
+ /** the error that caused the connection to close */
7
+ lastDisconnect?: {
8
+ error: Error | undefined;
9
+ date: Date;
10
+ };
11
+ /** is this a new login */
12
+ isNewLogin?: boolean;
13
+ /** the current QR code */
14
+ qr?: string;
15
+ /** has the device received all pending notifications while it was offline */
16
+ receivedPendingNotifications?: boolean;
17
+ /** legacy connection options */
18
+ legacy?: {
19
+ phoneConnected: boolean;
20
+ user?: Contact;
21
+ };
22
+ /**
23
+ * if the client is shown as an active, online client.
24
+ * If this is false, the primary phone and other devices will receive notifs
25
+ * */
26
+ isOnline?: boolean;
27
+ };
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,25 +1,25 @@
1
- import { BinaryNode } from '../WABinary';
2
- import { USyncUser } from '../WAUSync';
3
- /**
4
- * Defines the interface for a USyncQuery protocol
5
- */
6
- export interface USyncQueryProtocol {
7
- /**
8
- * The name of the protocol
9
- */
10
- name: string;
11
- /**
12
- * Defines what goes inside the query part of a USyncQuery
13
- */
14
- getQueryElement: () => BinaryNode;
15
- /**
16
- * Defines what goes inside the user part of a USyncQuery
17
- */
18
- getUserElement: (user: USyncUser) => BinaryNode | null;
19
- /**
20
- * Parse the result of the query
21
- * @param data Data from the result
22
- * @returns Whatever the protocol is supposed to return
23
- */
24
- parser: (data: BinaryNode) => unknown;
25
- }
1
+ import { BinaryNode } from '../WABinary';
2
+ import { USyncUser } from '../WAUSync';
3
+ /**
4
+ * Defines the interface for a USyncQuery protocol
5
+ */
6
+ export interface USyncQueryProtocol {
7
+ /**
8
+ * The name of the protocol
9
+ */
10
+ name: string;
11
+ /**
12
+ * Defines what goes inside the query part of a USyncQuery
13
+ */
14
+ getQueryElement: () => BinaryNode;
15
+ /**
16
+ * Defines what goes inside the user part of a USyncQuery
17
+ */
18
+ getUserElement: (user: USyncUser) => BinaryNode | null;
19
+ /**
20
+ * Parse the result of the query
21
+ * @param data Data from the result
22
+ * @returns Whatever the protocol is supposed to return
23
+ */
24
+ parser: (data: BinaryNode) => unknown;
25
+ }
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });