@pontalabs/baileys 1.0.6 → 1.0.7

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 (185) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +839 -267
  3. package/WAProto/GenerateStatics.sh +4 -3
  4. package/WAProto/WAProto.proto +511 -1215
  5. package/WAProto/index.d.ts +55 -14017
  6. package/WAProto/index.js +29 -97689
  7. package/lib/Defaults/index.d.ts +74 -72
  8. package/lib/Defaults/index.js +108 -94
  9. package/lib/Signal/Group/ciphertext-message.d.ts +7 -8
  10. package/lib/Signal/Group/ciphertext-message.js +16 -9
  11. package/lib/Signal/Group/group-session-builder.d.ts +13 -11
  12. package/lib/Signal/Group/group-session-builder.js +61 -19
  13. package/lib/Signal/Group/group_cipher.d.ts +16 -14
  14. package/lib/Signal/Group/group_cipher.js +70 -41
  15. package/lib/Signal/Group/index.d.ts +11 -12
  16. package/lib/Signal/Group/index.js +61 -12
  17. package/lib/Signal/Group/keyhelper.d.ts +14 -9
  18. package/lib/Signal/Group/keyhelper.js +58 -10
  19. package/lib/Signal/Group/sender-chain-key.d.ts +13 -13
  20. package/lib/Signal/Group/sender-chain-key.js +34 -13
  21. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -16
  22. package/lib/Signal/Group/sender-key-distribution-message.js +36 -28
  23. package/lib/Signal/Group/sender-key-message.d.ts +18 -18
  24. package/lib/Signal/Group/sender-key-message.js +45 -38
  25. package/lib/Signal/Group/sender-key-name.d.ts +15 -14
  26. package/lib/Signal/Group/sender-key-name.js +31 -20
  27. package/lib/Signal/Group/sender-key-record.d.ts +25 -24
  28. package/lib/Signal/Group/sender-key-record.js +35 -18
  29. package/lib/Signal/Group/sender-key-state.d.ts +34 -29
  30. package/lib/Signal/Group/sender-key-state.js +100 -37
  31. package/lib/Signal/Group/sender-message-key.d.ts +10 -11
  32. package/lib/Signal/Group/sender-message-key.js +22 -15
  33. package/lib/Signal/libsignal.d.ts +8 -5
  34. package/lib/Signal/libsignal.js +142 -288
  35. package/lib/Signal/lid-mapping.d.ts +28 -23
  36. package/lib/Signal/lid-mapping.js +184 -277
  37. package/lib/Socket/Client/index.d.ts +2 -3
  38. package/lib/Socket/Client/index.js +22 -3
  39. package/lib/Socket/Client/types.d.ts +15 -15
  40. package/lib/Socket/Client/types.js +15 -8
  41. package/lib/Socket/Client/websocket.d.ts +12 -12
  42. package/lib/Socket/Client/websocket.js +37 -29
  43. package/lib/Socket/business.d.ts +178 -208
  44. package/lib/Socket/business.js +127 -91
  45. package/lib/Socket/chats.d.ts +93 -120
  46. package/lib/Socket/chats.js +652 -727
  47. package/lib/Socket/community.js +10 -2
  48. package/lib/Socket/groups.d.ts +111 -143
  49. package/lib/Socket/groups.js +186 -165
  50. package/lib/Socket/index.d.ts +183 -252
  51. package/lib/Socket/index.js +18 -38
  52. package/lib/Socket/messages-recv.d.ts +167 -196
  53. package/lib/Socket/messages-recv.js +1567 -1443
  54. package/lib/Socket/messages-send.d.ts +158 -192
  55. package/lib/Socket/messages-send.js +1208 -1102
  56. package/lib/Socket/newsletter.d.ts +138 -163
  57. package/lib/Socket/newsletter.js +249 -153
  58. package/lib/Socket/socket.d.ts +36 -50
  59. package/lib/Socket/socket.js +820 -749
  60. package/lib/Store/index.d.ts +4 -4
  61. package/lib/Store/index.js +24 -4
  62. package/lib/Store/make-in-memory-store.d.ts +104 -44
  63. package/lib/Store/make-in-memory-store.js +213 -199
  64. package/lib/Store/make-ordered-dictionary.d.ts +12 -13
  65. package/lib/Store/make-ordered-dictionary.js +45 -38
  66. package/lib/Store/object-repository.d.ts +10 -11
  67. package/lib/Store/object-repository.js +16 -9
  68. package/lib/Types/Auth.d.ts +97 -93
  69. package/lib/Types/Auth.js +3 -2
  70. package/lib/Types/Bussines.js +3 -2
  71. package/lib/Types/Call.d.ts +13 -14
  72. package/lib/Types/Call.js +3 -2
  73. package/lib/Types/Chat.d.ts +97 -78
  74. package/lib/Types/Chat.js +9 -8
  75. package/lib/Types/Contact.d.ts +9 -12
  76. package/lib/Types/Contact.js +3 -2
  77. package/lib/Types/Events.d.ts +176 -206
  78. package/lib/Types/Events.js +3 -2
  79. package/lib/Types/GroupMetadata.d.ts +48 -53
  80. package/lib/Types/GroupMetadata.js +3 -2
  81. package/lib/Types/Label.d.ts +14 -13
  82. package/lib/Types/Label.js +30 -24
  83. package/lib/Types/LabelAssociation.d.ts +20 -15
  84. package/lib/Types/LabelAssociation.js +12 -6
  85. package/lib/Types/Message.d.ts +412 -248
  86. package/lib/Types/Message.js +19 -17
  87. package/lib/Types/Product.d.ts +71 -58
  88. package/lib/Types/Product.js +3 -2
  89. package/lib/Types/Signal.d.ts +82 -71
  90. package/lib/Types/Signal.js +3 -2
  91. package/lib/Types/Socket.d.ts +81 -76
  92. package/lib/Types/Socket.js +3 -3
  93. package/lib/Types/State.d.ts +19 -75
  94. package/lib/Types/State.js +14 -56
  95. package/lib/Types/USync.d.ts +8 -8
  96. package/lib/Types/USync.js +3 -2
  97. package/lib/Types/index.d.ts +62 -47
  98. package/lib/Types/index.js +50 -26
  99. package/lib/Utils/auth-utils.d.ts +10 -13
  100. package/lib/Utils/auth-utils.js +472 -213
  101. package/lib/Utils/business.d.ts +20 -14
  102. package/lib/Utils/business.js +134 -110
  103. package/lib/Utils/chat-utils.d.ts +70 -88
  104. package/lib/Utils/chat-utils.js +403 -466
  105. package/lib/Utils/crypto.d.ts +46 -27
  106. package/lib/Utils/crypto.js +188 -117
  107. package/lib/Utils/decode-wa-message.d.ts +45 -58
  108. package/lib/Utils/decode-wa-message.js +311 -212
  109. package/lib/Utils/event-buffer.d.ts +17 -14
  110. package/lib/Utils/event-buffer.js +296 -321
  111. package/lib/Utils/generics.d.ts +92 -66
  112. package/lib/Utils/generics.js +436 -270
  113. package/lib/Utils/history.d.ts +23 -24
  114. package/lib/Utils/history.js +76 -106
  115. package/lib/Utils/index.d.ts +21 -24
  116. package/lib/Utils/index.js +41 -24
  117. package/lib/Utils/link-preview.d.ts +14 -12
  118. package/lib/Utils/link-preview.js +75 -40
  119. package/lib/Utils/logger.d.ts +11 -10
  120. package/lib/Utils/logger.js +7 -3
  121. package/lib/Utils/lt-hash.d.ts +14 -8
  122. package/lib/Utils/lt-hash.js +53 -3
  123. package/lib/Utils/make-mutex.d.ts +7 -7
  124. package/lib/Utils/make-mutex.js +44 -28
  125. package/lib/Utils/message-retry-manager.d.ts +88 -115
  126. package/lib/Utils/message-retry-manager.js +160 -265
  127. package/lib/Utils/messages-media.d.ts +107 -105
  128. package/lib/Utils/messages-media.js +619 -548
  129. package/lib/Utils/messages.d.ts +66 -52
  130. package/lib/Utils/messages.js +1558 -1730
  131. package/lib/Utils/noise-handler.d.ts +18 -18
  132. package/lib/Utils/noise-handler.js +130 -176
  133. package/lib/Utils/process-message.d.ts +32 -43
  134. package/lib/Utils/process-message.js +282 -484
  135. package/lib/Utils/rich-message-utils.js +724 -1220
  136. package/lib/Utils/signal.d.ts +32 -37
  137. package/lib/Utils/signal.js +105 -140
  138. package/lib/Utils/use-multi-file-auth-state.d.ts +5 -5
  139. package/lib/Utils/use-multi-file-auth-state.js +120 -70
  140. package/lib/Utils/use-single-file-auth-state.d.ts +13 -11
  141. package/lib/Utils/use-single-file-auth-state.js +66 -92
  142. package/lib/Utils/validate-connection.d.ts +13 -11
  143. package/lib/Utils/validate-connection.js +113 -128
  144. package/lib/WABinary/constants.d.ts +27 -25
  145. package/lib/WABinary/constants.js +1292 -1451
  146. package/lib/WABinary/decode.d.ts +9 -7
  147. package/lib/WABinary/decode.js +189 -163
  148. package/lib/WABinary/encode.d.ts +3 -3
  149. package/lib/WABinary/encode.js +155 -110
  150. package/lib/WABinary/generic-utils.d.ts +27 -14
  151. package/lib/WABinary/generic-utils.js +105 -177
  152. package/lib/WABinary/index.d.ts +5 -6
  153. package/lib/WABinary/index.js +25 -6
  154. package/lib/WABinary/jid-utils.d.ts +54 -41
  155. package/lib/WABinary/jid-utils.js +152 -83
  156. package/lib/WABinary/types.d.ts +13 -10
  157. package/lib/WABinary/types.js +3 -2
  158. package/lib/WAM/BinaryInfo.d.ts +15 -8
  159. package/lib/WAM/BinaryInfo.js +14 -7
  160. package/lib/WAM/constants.d.ts +37 -30
  161. package/lib/WAM/constants.js +11983 -19465
  162. package/lib/WAM/encode.d.ts +3 -3
  163. package/lib/WAM/encode.js +109 -95
  164. package/lib/WAM/index.d.ts +3 -4
  165. package/lib/WAM/index.js +23 -4
  166. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -9
  167. package/lib/WAUSync/Protocols/USyncContactProtocol.js +21 -37
  168. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -19
  169. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +26 -18
  170. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -11
  171. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +20 -12
  172. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -11
  173. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +24 -16
  174. package/lib/WAUSync/Protocols/index.d.ts +6 -6
  175. package/lib/WAUSync/Protocols/index.js +26 -6
  176. package/lib/WAUSync/USyncQuery.d.ts +28 -27
  177. package/lib/WAUSync/USyncQuery.js +62 -68
  178. package/lib/WAUSync/USyncUser.d.ts +10 -15
  179. package/lib/WAUSync/USyncUser.js +19 -20
  180. package/lib/WAUSync/index.d.ts +3 -4
  181. package/lib/WAUSync/index.js +23 -4
  182. package/lib/index.d.ts +12 -11
  183. package/lib/index.js +39 -12
  184. package/package.json +42 -86
  185. package/engine-requirements.js +0 -10
@@ -1,17 +1,19 @@
1
- import { proto } from '../../WAProto/index.js';
2
- // export the WAMessage Prototypes
3
- export { proto as WAProto };
4
- export const AssociationType = proto.MessageAssociation.AssociationType;
5
- export const WAMessageStubType = proto.WebMessageInfo.StubType;
6
- export const WAMessageStatus = proto.WebMessageInfo.Status;
7
- export const ButtonHeaderType = proto.Message.ButtonsMessage.HeaderType;
8
- export const ButtonType = proto.Message.ButtonsMessage.Button.Type;
9
- export const CarouselCardType = proto.Message.InteractiveMessage.CarouselMessage.CarouselCardType;
10
- export const ListType = proto.Message.ListMessage.ListType;
11
- export const ProtocolType = proto.Message.ProtocolMessage.Type;
12
- export var WAMessageAddressingMode;
13
- (function (WAMessageAddressingMode) {
14
- WAMessageAddressingMode["PN"] = "pn";
15
- WAMessageAddressingMode["LID"] = "lid";
16
- })(WAMessageAddressingMode || (WAMessageAddressingMode = {}));
17
- //# sourceMappingURL=Message.js.map
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const WAProto_1 = require("../../WAProto")
6
+
7
+ Object.defineProperty(exports, "__esModule", { value: true })
8
+
9
+ const WAMessageAddressingMode = {
10
+ PN: 'pn',
11
+ LID: 'lid'
12
+ }
13
+
14
+ module.exports = {
15
+ WAMessageAddressingMode,
16
+ WAMessageStubType: WAProto_1.proto.WebMessageInfo.StubType,
17
+ WAMessageStatus: WAProto_1.proto.WebMessageInfo.Status,
18
+ WAProto: WAProto_1.proto
19
+ }
@@ -1,79 +1,92 @@
1
- import type { WAMediaUpload } from './Message.js';
1
+ import { WAMediaUpload } from './Message'
2
+
2
3
  export type CatalogResult = {
3
4
  data: {
4
5
  paging: {
5
6
  cursors: {
6
- before: string;
7
- after: string;
8
- };
9
- };
10
- data: any[];
11
- };
12
- };
7
+ before: string
8
+ after: string
9
+ }
10
+ }
11
+ data: any[]
12
+ }
13
+ }
14
+
13
15
  export type ProductCreateResult = {
14
16
  data: {
15
- product: {};
16
- };
17
- };
17
+ product: {}
18
+ }
19
+ }
20
+
18
21
  export type CatalogStatus = {
19
- status: string;
20
- canAppeal: boolean;
21
- };
22
+ status: string
23
+ canAppeal: boolean
24
+ }
25
+
22
26
  export type CatalogCollection = {
23
- id: string;
24
- name: string;
25
- products: Product[];
26
- status: CatalogStatus;
27
- };
28
- export type ProductAvailability = 'in stock';
27
+ id: string
28
+ name: string
29
+ products: Product[]
30
+ status: CatalogStatus
31
+ }
32
+
33
+ export type ProductAvailability = 'in stock'
34
+
29
35
  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
- };
36
+ name: string
37
+ retailerId?: string
38
+ url?: string
39
+ description: string
40
+ price: number
41
+ currency: string
42
+ isHidden?: boolean
43
+ }
44
+
38
45
  export type ProductCreate = ProductBase & {
39
46
  /** ISO country code for product origin. Set to undefined for no country */
40
- originCountryCode: string | undefined;
47
+ originCountryCode: string | undefined
41
48
  /** images of the product */
42
- images: WAMediaUpload[];
43
- };
44
- export type ProductUpdate = Omit<ProductCreate, 'originCountryCode'>;
49
+ images: WAMediaUpload[]
50
+ }
51
+
52
+ export type ProductUpdate = Omit<ProductCreate, 'originCountryCode'>
53
+
45
54
  export type Product = ProductBase & {
46
- id: string;
55
+ id: string
47
56
  imageUrls: {
48
- [_: string]: string;
49
- };
57
+ [_: string]: string
58
+ }
50
59
  reviewStatus: {
51
- [_: string]: string;
52
- };
53
- availability: ProductAvailability;
54
- };
60
+ [_: string]: string
61
+ }
62
+ availability: ProductAvailability
63
+ }
64
+
55
65
  export type OrderPrice = {
56
- currency: string;
57
- total: number;
58
- };
66
+ currency: string
67
+ total: number
68
+ }
69
+
59
70
  export type OrderProduct = {
60
- id: string;
61
- imageUrl: string;
62
- name: string;
63
- quantity: number;
64
- currency: string;
65
- price: number;
66
- };
71
+ id: string
72
+ imageUrl: string
73
+ name: string
74
+ quantity: number
75
+ currency: string
76
+ price: number
77
+ }
78
+
67
79
  export type OrderDetails = {
68
- price: OrderPrice;
69
- products: OrderProduct[];
70
- };
71
- export type CatalogCursor = string;
80
+ price: OrderPrice
81
+ products: OrderProduct[]
82
+ }
83
+
84
+ export type CatalogCursor = string
85
+
72
86
  export type GetCatalogOptions = {
73
87
  /** cursor to start from */
74
- cursor?: CatalogCursor;
88
+ cursor?: CatalogCursor
75
89
  /** number of products to fetch */
76
- limit?: number;
77
- jid?: string;
78
- };
79
- //# sourceMappingURL=Product.d.ts.map
90
+ limit?: number
91
+ jid?: string
92
+ }
@@ -1,2 +1,3 @@
1
- export {};
2
- //# sourceMappingURL=Product.js.map
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
@@ -1,87 +1,98 @@
1
- import { proto } from '../../WAProto/index.js';
2
- import type { LIDMappingStore } from '../Signal/lid-mapping.js';
1
+ import { proto } from '../../WAProto'
2
+ import { LIDMappingStore } from '../Signal/lid-mapping'
3
+
3
4
  type DecryptGroupSignalOpts = {
4
- group: string;
5
- authorJid: string;
6
- msg: Uint8Array;
7
- };
5
+ group: string
6
+ authorJid: string
7
+ msg: Uint8Array
8
+ }
9
+
10
+ type EncryptMessageWithWireOpts = {
11
+ encryptionJid: string
12
+ wireJid: string
13
+ data: Uint8Array
14
+ }
15
+
8
16
  type ProcessSenderKeyDistributionMessageOpts = {
9
- item: proto.Message.ISenderKeyDistributionMessage;
10
- authorJid: string;
11
- };
17
+ item: proto.Message.ISenderKeyDistributionMessage
18
+ authorJid: string
19
+ }
20
+
12
21
  type DecryptSignalProtoOpts = {
13
- jid: string;
14
- type: 'pkmsg' | 'msg';
15
- ciphertext: Uint8Array;
16
- };
22
+ jid: string
23
+ type: 'pkmsg' | 'msg'
24
+ ciphertext: Uint8Array
25
+ }
26
+
17
27
  type EncryptMessageOpts = {
18
- jid: string;
19
- data: Uint8Array;
20
- };
28
+ jid: string
29
+ data: Uint8Array
30
+ }
31
+
21
32
  type EncryptGroupMessageOpts = {
22
- group: string;
23
- data: Uint8Array;
24
- meId: string;
25
- };
26
- type GetSenderKeyDistributionMessageOpts = {
27
- group: string;
28
- meId: string;
29
- };
33
+ group: string
34
+ data: Uint8Array
35
+ meId: string
36
+ }
37
+
30
38
  type PreKey = {
31
- keyId: number;
32
- publicKey: Uint8Array;
33
- };
39
+ keyId: number
40
+ publicKey: Uint8Array
41
+ }
42
+
34
43
  type SignedPreKey = PreKey & {
35
- signature: Uint8Array;
36
- };
44
+ signature: Uint8Array
45
+ }
46
+
37
47
  type E2ESession = {
38
- registrationId: number;
39
- identityKey: Uint8Array;
40
- signedPreKey: SignedPreKey;
41
- preKey?: PreKey;
42
- };
48
+ registrationId: number
49
+ identityKey: Uint8Array
50
+ signedPreKey: SignedPreKey
51
+ preKey: PreKey
52
+ }
53
+
43
54
  type E2ESessionOpts = {
44
- jid: string;
45
- session: E2ESession;
46
- };
55
+ jid: string
56
+ session: E2ESession
57
+ }
58
+
47
59
  export type SignalRepository = {
48
- decryptGroupMessage(opts: DecryptGroupSignalOpts): Promise<Uint8Array>;
49
- processSenderKeyDistributionMessage(opts: ProcessSenderKeyDistributionMessageOpts): Promise<void>;
50
- decryptMessage(opts: DecryptSignalProtoOpts): Promise<Uint8Array>;
60
+ decryptGroupMessage(opts: DecryptGroupSignalOpts): Promise<Uint8Array>
61
+ processSenderKeyDistributionMessage(opts: ProcessSenderKeyDistributionMessageOpts): Promise<void>
62
+ decryptMessage(opts: DecryptSignalProtoOpts): Promise<Uint8Array>
51
63
  encryptMessage(opts: EncryptMessageOpts): Promise<{
52
- type: 'pkmsg' | 'msg';
53
- ciphertext: Uint8Array;
54
- }>;
64
+ type: 'pkmsg' | 'msg'
65
+ ciphertext: Uint8Array
66
+ }>
67
+ encryptMessageWithWire(opts: EncryptMessageWithWireOpts): Promise<{
68
+ type: 'pkmsg' | 'msg'
69
+ ciphertext: Uint8Array
70
+ wireJid: string
71
+ }>
55
72
  encryptGroupMessage(opts: EncryptGroupMessageOpts): Promise<{
56
- senderKeyDistributionMessage: Uint8Array;
57
- ciphertext: Uint8Array;
58
- }>;
59
- getSenderKeyDistributionMessage(opts: GetSenderKeyDistributionMessageOpts): Promise<Uint8Array>;
60
- hasSenderKey(opts: GetSenderKeyDistributionMessageOpts): Promise<boolean>;
61
- getSessionInfo(jid: string): Promise<{
62
- baseKey: Uint8Array;
63
- registrationId: number;
64
- } | null>;
65
- injectE2ESession(opts: E2ESessionOpts): Promise<void>;
73
+ senderKeyDistributionMessage: Uint8Array
74
+ ciphertext: Uint8Array
75
+ }>
76
+ injectE2ESession(opts: E2ESessionOpts): Promise<void>
66
77
  validateSession(jid: string): Promise<{
67
- exists: boolean;
68
- reason?: string;
69
- }>;
70
- jidToSignalProtocolAddress(jid: string): string;
71
- migrateSession(fromJid: string, toJid: string): Promise<{
72
- migrated: number;
73
- skipped: number;
74
- total: number;
75
- }>;
78
+ exists: boolean
79
+ reason?: string
80
+ }>
81
+ jidToSignalProtocolAddress(jid: string): string
82
+ migrateSession(fromJids: string[], toJid: string): Promise<{
83
+ migrated: number
84
+ skipped: number
85
+ total: number
86
+ }>
76
87
  validateSession(jid: string): Promise<{
77
- exists: boolean;
78
- reason?: string;
79
- }>;
80
- deleteSession(jids: string[]): Promise<void>;
81
- };
88
+ exists: boolean
89
+ reason?: string
90
+ }>
91
+ deleteSession(jids: string[]): Promise<void>
92
+ }
93
+
82
94
  export interface SignalRepositoryWithLIDStore extends SignalRepository {
83
- lidMapping: LIDMappingStore;
84
- close?: () => void;
95
+ lidMapping: LIDMappingStore
85
96
  }
86
- export {};
87
- //# sourceMappingURL=Signal.d.ts.map
97
+
98
+ export {}
@@ -1,2 +1,3 @@
1
- import { proto } from '../../WAProto/index.js';
2
- //# sourceMappingURL=Signal.js.map
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
@@ -1,136 +1,141 @@
1
- import type { Agent } from 'https';
2
- import type { URL } from 'url';
3
- import { proto } from '../../WAProto/index.js';
4
- import type { ILogger } from '../Utils/logger.js';
5
- import type { AuthenticationState, LIDMapping, SignalAuthState, TransactionCapabilityOptions } from './Auth.js';
6
- import type { GroupMetadata } from './GroupMetadata.js';
7
- import { type MediaConnInfo, type WAMessageKey } from './Message.js';
8
- import type { SignalRepositoryWithLIDStore } from './Signal.js';
9
- export type WAVersion = [number, number, number];
10
- export type WABrowserDescription = [string, string, string];
1
+ import { AxiosRequestConfig } from 'axios'
2
+ import type { Agent } from 'https'
3
+ import { ILogger } from '../Utils/logger'
4
+ import type { URL } from 'url'
5
+ import { proto } from '../../WAProto'
6
+ import { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth'
7
+ import { GroupMetadata } from './GroupMetadata'
8
+ import { MediaConnInfo } from './Message'
9
+ import { SignalRepositoryWithLIDStore } from './Signal'
10
+
11
+ export type WAVersion = [number, number, number]
12
+
13
+ export type WABrowserDescription = [string, string, string]
14
+
11
15
  export type CacheStore = {
12
16
  /** get a cached key and change the stats */
13
- get<T>(key: string): Promise<T> | T | undefined;
17
+ get<T>(key: string): Promise<T> | T | undefined
14
18
  /** set a key in the cache */
15
- set<T>(key: string, value: T): Promise<void> | void | number | boolean;
19
+ set<T>(key: string, value: T): Promise<void> | void | number | boolean
16
20
  /** delete a key from the cache */
17
- del(key: string): void | Promise<void> | number | boolean;
21
+ del(key: string): void | Promise<void> | number | boolean
18
22
  /** flush all data */
19
- flushAll(): void | Promise<void>;
20
- close?: () => void;
21
- };
23
+ flushAll(): void | Promise<void>
24
+ }
25
+
22
26
  export type PossiblyExtendedCacheStore = CacheStore & {
23
- mget?: <T>(keys: string[]) => Promise<Record<string, T | undefined>>;
27
+ mget?: <T>(keys: string[]) => Promise<Record<string, T | undefined>>
24
28
  mset?: <T>(entries: {
25
- key: string;
26
- value: T;
27
- }[]) => Promise<void> | void | number | boolean;
28
- mdel?: (keys: string[]) => void | Promise<void> | number | boolean;
29
- };
29
+ key: string
30
+ value: T
31
+ }[]) => Promise<void> | void | number | boolean
32
+ mdel?: (keys: string[]) => void | Promise<void> | number | boolean
33
+ }
34
+
30
35
  export type PatchedMessageWithRecipientJID = proto.IMessage & {
31
- recipientJid?: string;
32
- };
36
+ recipientJid?: string
37
+ }
38
+
33
39
  export type SocketConfig = {
34
40
  /** the WS url to connect to WA */
35
- waWebSocketUrl: string | URL;
41
+ waWebSocketUrl: string | URL
36
42
  /** Fails the connection if the socket times out in this interval */
37
- connectTimeoutMs: number;
43
+ connectTimeoutMs: number
38
44
  /** Default timeout for queries, undefined for no timeout */
39
- defaultQueryTimeoutMs: number | undefined;
45
+ defaultQueryTimeoutMs: number | undefined
40
46
  /** ping-pong interval for WS connection */
41
- keepAliveIntervalMs: number;
47
+ keepAliveIntervalMs: number
42
48
  /** should baileys use the mobile api instead of the multi device api
43
49
  * @deprecated This feature has been removed
44
- */
45
- mobile?: boolean;
50
+ */
51
+ mobile?: boolean
46
52
  /** proxy agent */
47
- agent?: Agent;
53
+ agent?: Agent
48
54
  /** logger */
49
- logger: ILogger;
55
+ logger: ILogger
50
56
  /** version to connect with */
51
- version: WAVersion;
57
+ version: WAVersion
52
58
  /** override browser config */
53
- browser: WABrowserDescription;
54
- /** Initial pushName carried in the registration ClientPayload (used by mock servers for deterministic phone assignment). */
55
- pushName?: string;
59
+ browser: WABrowserDescription
56
60
  /** agent used for fetch requests -- uploading/downloading media */
57
- fetchAgent?: Agent;
58
- /** should the QR be printed in the terminal
59
- * @deprecated This feature has been removed
60
- */
61
- printQRInTerminal?: boolean;
61
+ fetchAgent?: Agent
62
+ /** should the QR be printed in the terminal */
63
+ printQRInTerminal: boolean
62
64
  /** should events be emitted for actions done by this socket connection */
63
- emitOwnEvents: boolean;
65
+ emitOwnEvents: boolean
64
66
  /** custom upload hosts to upload media to */
65
- customUploadHosts: MediaConnInfo['hosts'];
67
+ customUploadHosts: MediaConnInfo['hosts']
66
68
  /** time to wait between sending new retry requests */
67
- retryRequestDelayMs: number;
69
+ retryRequestDelayMs: number
68
70
  /** max retry count */
69
- maxMsgRetryCount: number;
71
+ maxMsgRetryCount: number
70
72
  /** time to wait for the generation of the next QR in ms */
71
- qrTimeout?: number;
73
+ qrTimeout?: number
72
74
  /** provide an auth state object to maintain the auth state */
73
- auth: AuthenticationState;
74
- /** manage history processing with this control; by default will sync up everything */
75
- shouldSyncHistoryMessage: (msg: proto.Message.IHistorySyncNotification) => boolean;
75
+ auth: AuthenticationState
76
+ /** manage history processing with this control by default will sync up everything */
77
+ shouldSyncHistoryMessage: (msg: proto.Message.IHistorySyncNotification) => boolean
76
78
  /** transaction capability options for SignalKeyStore */
77
- transactionOpts: TransactionCapabilityOptions;
79
+ transactionOpts: TransactionCapabilityOptions
78
80
  /** marks the client as online whenever the socket successfully connects */
79
- markOnlineOnConnect: boolean;
81
+ markOnlineOnConnect: boolean
80
82
  /** alphanumeric country code (USA -> US) for the number used */
81
- countryCode: string;
83
+ countryCode: string
82
84
  /** provide a cache to store media, so does not have to be re-uploaded */
83
- mediaCache?: CacheStore;
85
+ mediaCache?: CacheStore
84
86
  /**
85
- * map to store the retry counts for failed messages;
87
+ * map to store the retry counts for failed messages
86
88
  * used to determine whether to retry a message or not */
87
- msgRetryCounterCache?: CacheStore;
89
+ msgRetryCounterCache?: CacheStore
88
90
  /** provide a cache to store a user's device list */
89
- userDevicesCache?: PossiblyExtendedCacheStore;
91
+ userDevicesCache?: PossiblyExtendedCacheStore
90
92
  /** cache to store call offers */
91
- callOfferCache?: CacheStore;
93
+ callOfferCache?: CacheStore
92
94
  /** cache to track placeholder resends */
93
- placeholderResendCache?: CacheStore;
95
+ placeholderResendCache?: CacheStore
94
96
  /** width for link preview images */
95
- linkPreviewImageThumbnailWidth: number;
97
+ linkPreviewImageThumbnailWidth: number
96
98
  /** Should Baileys ask the phone for full history, will be received async */
97
- syncFullHistory: boolean;
99
+ syncFullHistory: boolean
98
100
  /** Should baileys fire init queries automatically, default true */
99
- fireInitQueries: boolean;
101
+ fireInitQueries: boolean
100
102
  /**
101
103
  * generate a high quality link preview,
102
104
  * entails uploading the jpegThumbnail to WA
103
105
  * */
104
- generateHighQualityLinkPreview: boolean;
106
+ generateHighQualityLinkPreview: boolean
105
107
  /** Enable automatic session recreation for failed messages */
106
- enableAutoSessionRecreation: boolean;
108
+ enableAutoSessionRecreation: boolean
107
109
  /** Enable recent message caching for retry handling */
108
- enableRecentMessageCache: boolean;
110
+ enableRecentMessageCache: boolean
109
111
  /**
110
112
  * Returns if a jid should be ignored,
111
113
  * no event for that jid will be triggered.
112
114
  * Messages from that jid will also not be decrypted
113
115
  * */
114
- shouldIgnoreJid: (jid: string) => boolean | undefined;
116
+ shouldIgnoreJid: (jid: string) => boolean | undefined
115
117
  /**
116
118
  * Optionally patch the message before sending out
117
119
  * */
118
- patchMessageBeforeSending: (msg: proto.IMessage, recipientJids?: string[]) => Promise<PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID> | PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID;
120
+ patchMessageBeforeSending: (msg: proto.IMessage, recipientJids?: string[]) => Promise<PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID> | PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID
119
121
  /** verify app state MACs */
120
122
  appStateMacVerification: {
121
- patch: boolean;
122
- snapshot: boolean;
123
- };
124
- /** options for HTTP fetch requests */
125
- options: RequestInit;
123
+ patch: boolean
124
+ snapshot: boolean
125
+ }
126
+ /** options for axios */
127
+ options: AxiosRequestConfig<{}>
126
128
  /**
127
129
  * fetch a message from your store
128
130
  * implement this so that messages failed to send
129
131
  * (solves the "this message can take a while" issue) can be retried
130
132
  * */
131
- getMessage: (key: WAMessageKey) => Promise<proto.IMessage | undefined>;
133
+ getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>
132
134
  /** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
133
- cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>;
134
- makeSignalRepository: (auth: SignalAuthState, logger: ILogger, pnToLIDFunc?: (jids: string[]) => Promise<LIDMapping[] | undefined>) => SignalRepositoryWithLIDStore;
135
- };
136
- //# sourceMappingURL=Socket.d.ts.map
135
+ cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>
136
+ makeSignalRepository: (auth: SignalAuthState, onWhatsAppFunc?: (...jids: string[]) => Promise<{
137
+ jid: string
138
+ exists: boolean
139
+ lid: string
140
+ }[] | undefined>) => SignalRepositoryWithLIDStore
141
+ }
@@ -1,3 +1,3 @@
1
- import { proto } from '../../WAProto/index.js';
2
- import {} from './Message.js';
3
- //# sourceMappingURL=Socket.js.map
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })