@skyzopedia/baileys-mod 5.0.8 → 6.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 (210) hide show
  1. package/WAProto/index.js +133384 -57814
  2. package/engine-requirements.js +10 -0
  3. package/lib/Defaults/baileys-version.json +3 -0
  4. package/lib/Defaults/index.d.ts +53 -0
  5. package/lib/Defaults/index.js +141 -117
  6. package/lib/Defaults/phonenumber-mcc.json +223 -0
  7. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  8. package/lib/Signal/Group/ciphertext-message.js +14 -12
  9. package/lib/Signal/Group/group-session-builder.d.ts +14 -0
  10. package/lib/Signal/Group/group-session-builder.js +42 -10
  11. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  12. package/lib/Signal/Group/group_cipher.js +87 -75
  13. package/lib/Signal/Group/index.d.ts +11 -0
  14. package/lib/Signal/Group/index.js +57 -13
  15. package/lib/Signal/Group/keyhelper.d.ts +10 -0
  16. package/lib/Signal/Group/keyhelper.js +52 -17
  17. package/lib/Signal/Group/queue-job.d.ts +1 -0
  18. package/lib/Signal/Group/queue-job.js +57 -0
  19. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  20. package/lib/Signal/Group/sender-chain-key.js +33 -27
  21. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  22. package/lib/Signal/Group/sender-key-distribution-message.js +63 -62
  23. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  24. package/lib/Signal/Group/sender-key-message.js +66 -65
  25. package/lib/Signal/Group/sender-key-name.d.ts +17 -0
  26. package/lib/Signal/Group/sender-key-name.js +44 -45
  27. package/lib/Signal/Group/sender-key-record.d.ts +30 -0
  28. package/lib/Signal/Group/sender-key-record.js +49 -39
  29. package/lib/Signal/Group/sender-key-state.d.ts +38 -0
  30. package/lib/Signal/Group/sender-key-state.js +93 -80
  31. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  32. package/lib/Signal/Group/sender-message-key.js +28 -27
  33. package/lib/Signal/libsignal.d.ts +3 -0
  34. package/lib/Signal/libsignal.js +163 -313
  35. package/lib/Socket/Client/abstract-socket-client.d.ts +17 -0
  36. package/lib/Socket/Client/abstract-socket-client.js +13 -0
  37. package/lib/Socket/Client/index.d.ts +3 -0
  38. package/lib/Socket/Client/index.js +19 -4
  39. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  40. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  41. package/lib/Socket/Client/web-socket-client.d.ts +12 -0
  42. package/lib/Socket/Client/web-socket-client.js +62 -0
  43. package/lib/Socket/business.d.ts +171 -0
  44. package/lib/Socket/business.js +242 -359
  45. package/lib/Socket/chats.d.ts +267 -0
  46. package/lib/Socket/chats.js +935 -846
  47. package/lib/Socket/dugong.d.ts +254 -0
  48. package/lib/Socket/dugong.js +484 -0
  49. package/lib/Socket/groups.d.ts +115 -0
  50. package/lib/Socket/groups.js +309 -304
  51. package/lib/Socket/index.d.ts +173 -0
  52. package/lib/Socket/index.js +10 -15
  53. package/lib/Socket/messages-recv.d.ts +161 -0
  54. package/lib/Socket/messages-recv.js +1054 -1107
  55. package/lib/Socket/messages-send.d.ts +149 -0
  56. package/lib/Socket/messages-send.js +447 -706
  57. package/lib/Socket/newsletter.d.ts +134 -0
  58. package/lib/Socket/newsletter.js +314 -199
  59. package/lib/Socket/registration.d.ts +267 -0
  60. package/lib/Socket/registration.js +166 -0
  61. package/lib/Socket/socket.d.ts +43 -0
  62. package/lib/Socket/socket.js +650 -777
  63. package/lib/Socket/usync.d.ts +36 -0
  64. package/lib/Socket/usync.js +70 -0
  65. package/lib/Store/index.d.ts +3 -0
  66. package/lib/Store/index.js +10 -6
  67. package/lib/Store/make-cache-manager-store.d.ts +13 -0
  68. package/lib/Store/make-cache-manager-store.js +81 -73
  69. package/lib/Store/make-in-memory-store.d.ts +118 -0
  70. package/lib/Store/make-in-memory-store.js +423 -286
  71. package/lib/Store/make-ordered-dictionary.d.ts +13 -0
  72. package/lib/Store/make-ordered-dictionary.js +79 -77
  73. package/lib/Store/object-repository.d.ts +10 -0
  74. package/lib/Store/object-repository.js +26 -24
  75. package/lib/Types/Auth.d.ts +110 -0
  76. package/lib/Types/Auth.js +2 -3
  77. package/lib/Types/Call.d.ts +13 -0
  78. package/lib/Types/Call.js +2 -3
  79. package/lib/Types/Chat.d.ts +102 -0
  80. package/lib/Types/Chat.js +4 -9
  81. package/lib/Types/Contact.d.ts +19 -0
  82. package/lib/Types/Contact.js +2 -3
  83. package/lib/Types/Events.d.ts +157 -0
  84. package/lib/Types/Events.js +2 -3
  85. package/lib/Types/GroupMetadata.d.ts +55 -0
  86. package/lib/Types/GroupMetadata.js +2 -3
  87. package/lib/Types/Label.d.ts +35 -0
  88. package/lib/Types/Label.js +26 -24
  89. package/lib/Types/LabelAssociation.d.ts +29 -0
  90. package/lib/Types/LabelAssociation.js +8 -6
  91. package/lib/Types/Message.d.ts +273 -0
  92. package/lib/Types/Message.js +9 -12
  93. package/lib/Types/Newsletter.d.ts +103 -0
  94. package/lib/Types/Newsletter.js +38 -33
  95. package/lib/Types/Product.d.ts +78 -0
  96. package/lib/Types/Product.js +2 -3
  97. package/lib/Types/Signal.d.ts +57 -0
  98. package/lib/Types/Signal.js +2 -3
  99. package/lib/Types/Socket.d.ts +111 -0
  100. package/lib/Types/Socket.js +2 -4
  101. package/lib/Types/State.d.ts +27 -0
  102. package/lib/Types/State.js +2 -11
  103. package/lib/Types/USync.d.ts +25 -0
  104. package/lib/Types/USync.js +2 -3
  105. package/lib/Types/index.d.ts +57 -0
  106. package/lib/Types/index.js +41 -27
  107. package/lib/Utils/auth-utils.d.ts +18 -0
  108. package/lib/Utils/auth-utils.js +198 -211
  109. package/lib/Utils/baileys-event-stream.d.ts +16 -0
  110. package/lib/Utils/baileys-event-stream.js +61 -42
  111. package/lib/Utils/business.d.ts +22 -0
  112. package/lib/Utils/business.js +214 -213
  113. package/lib/Utils/chat-utils.d.ts +71 -0
  114. package/lib/Utils/chat-utils.js +687 -710
  115. package/lib/Utils/crypto.d.ts +41 -0
  116. package/lib/Utils/crypto.js +133 -112
  117. package/lib/Utils/decode-wa-message.d.ts +19 -0
  118. package/lib/Utils/decode-wa-message.js +183 -252
  119. package/lib/Utils/event-buffer.d.ts +35 -0
  120. package/lib/Utils/event-buffer.js +496 -510
  121. package/lib/Utils/generics.d.ts +92 -0
  122. package/lib/Utils/generics.js +387 -319
  123. package/lib/Utils/history.d.ts +15 -0
  124. package/lib/Utils/history.js +92 -83
  125. package/lib/Utils/index.d.ts +17 -0
  126. package/lib/Utils/index.js +33 -21
  127. package/lib/Utils/link-preview.d.ts +21 -0
  128. package/lib/Utils/link-preview.js +83 -71
  129. package/lib/Utils/logger.d.ts +4 -0
  130. package/lib/Utils/logger.js +7 -5
  131. package/lib/Utils/lt-hash.d.ts +12 -0
  132. package/lib/Utils/lt-hash.js +46 -40
  133. package/lib/Utils/make-mutex.d.ts +7 -0
  134. package/lib/Utils/make-mutex.js +41 -34
  135. package/lib/Utils/messages-media.d.ts +116 -0
  136. package/lib/Utils/messages-media.js +768 -550
  137. package/lib/Utils/messages.d.ts +77 -0
  138. package/lib/Utils/messages.js +263 -362
  139. package/lib/Utils/noise-handler.d.ts +21 -0
  140. package/lib/Utils/noise-handler.js +149 -138
  141. package/lib/Utils/process-message.d.ts +41 -0
  142. package/lib/Utils/process-message.js +303 -323
  143. package/lib/Utils/signal.d.ts +32 -0
  144. package/lib/Utils/signal.js +141 -149
  145. package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
  146. package/lib/Utils/use-multi-file-auth-state.js +103 -95
  147. package/lib/Utils/validate-connection.d.ts +11 -0
  148. package/lib/Utils/validate-connection.js +220 -183
  149. package/lib/WABinary/constants.d.ts +30 -0
  150. package/lib/WABinary/constants.js +35 -1298
  151. package/lib/WABinary/decode.d.ts +7 -0
  152. package/lib/WABinary/decode.js +249 -237
  153. package/lib/WABinary/encode.d.ts +3 -0
  154. package/lib/WABinary/encode.js +260 -213
  155. package/lib/WABinary/generic-utils.d.ts +17 -0
  156. package/lib/WABinary/generic-utils.js +65 -56
  157. package/lib/WABinary/index.d.ts +5 -0
  158. package/lib/WABinary/index.js +21 -7
  159. package/lib/WABinary/jid-utils.d.ts +31 -0
  160. package/lib/WABinary/jid-utils.js +58 -89
  161. package/lib/WABinary/types.d.ts +18 -0
  162. package/lib/WABinary/types.js +2 -3
  163. package/lib/WAM/BinaryInfo.d.ts +17 -0
  164. package/lib/WAM/BinaryInfo.js +12 -10
  165. package/lib/WAM/constants.d.ts +38 -0
  166. package/lib/WAM/constants.js +15348 -22851
  167. package/lib/WAM/encode.d.ts +3 -0
  168. package/lib/WAM/encode.js +136 -135
  169. package/lib/WAM/index.d.ts +3 -0
  170. package/lib/WAM/index.js +19 -5
  171. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
  172. package/lib/WAUSync/Protocols/USyncContactProtocol.js +30 -28
  173. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
  174. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +53 -49
  175. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  176. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +28 -27
  177. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  178. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +39 -36
  179. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
  180. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -50
  181. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
  182. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +20 -26
  183. package/lib/WAUSync/Protocols/index.d.ts +4 -0
  184. package/lib/WAUSync/Protocols/index.js +20 -6
  185. package/lib/WAUSync/USyncQuery.d.ts +28 -0
  186. package/lib/WAUSync/USyncQuery.js +85 -86
  187. package/lib/WAUSync/USyncUser.d.ts +12 -0
  188. package/lib/WAUSync/USyncUser.js +25 -23
  189. package/lib/WAUSync/index.d.ts +3 -0
  190. package/lib/WAUSync/index.js +19 -5
  191. package/lib/index.d.ts +12 -0
  192. package/lib/index.js +36 -24
  193. package/package.json +106 -98
  194. package/LICENSE +0 -21
  195. package/WAProto/WAProto.proto +0 -5311
  196. package/lib/KeyDB/BinarySearch.js +0 -20
  197. package/lib/KeyDB/KeyedDB.js +0 -167
  198. package/lib/KeyDB/index.js +0 -4
  199. package/lib/Signal/lid-mapping.js +0 -155
  200. package/lib/Socket/Client/types.js +0 -13
  201. package/lib/Socket/Client/websocket.js +0 -52
  202. package/lib/Socket/Client/websocket.js.bak +0 -53
  203. package/lib/Socket/communities.js +0 -413
  204. package/lib/Socket/mex.js +0 -45
  205. package/lib/Types/Bussines.js +0 -3
  206. package/lib/Types/Newsletter.js.bak +0 -33
  207. package/lib/Utils/browser-utils.js +0 -25
  208. package/lib/Utils/message-retry-manager.js +0 -113
  209. package/lib/Utils/messages.js.bak +0 -907
  210. package/lib/Utils/pre-key-manager.js +0 -85
@@ -0,0 +1,13 @@
1
+ declare function makeOrderedDictionary<T>(idGetter: (item: T) => string): {
2
+ array: T[];
3
+ get: (id: string) => T | undefined;
4
+ upsert: (item: T, mode: 'append' | 'prepend') => void;
5
+ update: (item: T) => boolean;
6
+ remove: (item: T) => boolean;
7
+ updateAssign: (id: string, update: Partial<T>) => boolean;
8
+ clear: () => void;
9
+ filter: (contain: (item: T) => boolean) => void;
10
+ toJSON: () => T[];
11
+ fromJSON: (newItems: T[]) => void;
12
+ };
13
+ export default makeOrderedDictionary;
@@ -1,79 +1,81 @@
1
- //===================================//
2
- export function makeOrderedDictionary(idGetter) {
3
- const array = []
4
- const dict = {}
5
- const get = (id) => dict[id]
6
- const update = (item) => {
7
- const id = idGetter(item)
8
- const idx = array.findIndex(i => idGetter(i) === id)
9
- if (idx >= 0) {
10
- array[idx] = item
11
- dict[id] = item
12
- }
13
- return false
14
- }
15
- const upsert = (item, mode) => {
16
- const id = idGetter(item)
17
- if (get(id)) {
18
- update(item)
19
- }
20
- else {
21
- if (mode === "append") {
22
- array.push(item)
23
- }
24
- else {
25
- array.splice(0, 0, item)
26
- }
27
- dict[id] = item
28
- }
29
- }
30
- const remove = (item) => {
31
- const id = idGetter(item)
32
- const idx = array.findIndex(i => idGetter(i) === id)
33
- if (idx >= 0) {
34
- array.splice(idx, 1)
35
- delete dict[id]
36
- return true
37
- }
38
- return false
39
- }
40
- return {
41
- array,
42
- get,
43
- upsert,
44
- update,
45
- remove,
46
- updateAssign: (id, update) => {
47
- const item = get(id)
48
- if (item) {
49
- Object.assign(item, update)
50
- delete dict[id]
51
- dict[idGetter(item)] = item
52
- return true
53
- }
54
- return false
55
- },
56
- clear: () => {
57
- array.splice(0, array.length)
58
- for (const key of Object.keys(dict)) {
59
- delete dict[key]
60
- }
61
- },
62
- filter: (contain) => {
63
- let i = 0
64
- while (i < array.length) {
65
- if (!contain(array[i])) {
66
- delete dict[idGetter(array[i])]
67
- array.splice(i, 1)
68
- } else {
69
- i += 1
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function makeOrderedDictionary(idGetter) {
4
+ const array = [];
5
+ const dict = {};
6
+ const get = (id) => dict[id];
7
+ const update = (item) => {
8
+ const id = idGetter(item);
9
+ const idx = array.findIndex(i => idGetter(i) === id);
10
+ if (idx >= 0) {
11
+ array[idx] = item;
12
+ dict[id] = item;
70
13
  }
71
- }
72
- },
73
- toJSON: () => array,
74
- fromJSON: (newItems) => {
75
- array.splice(0, array.length, ...newItems)
76
- }
77
- }
14
+ return false;
15
+ };
16
+ const upsert = (item, mode) => {
17
+ const id = idGetter(item);
18
+ if (get(id)) {
19
+ update(item);
20
+ }
21
+ else {
22
+ if (mode === 'append') {
23
+ array.push(item);
24
+ }
25
+ else {
26
+ array.splice(0, 0, item);
27
+ }
28
+ dict[id] = item;
29
+ }
30
+ };
31
+ const remove = (item) => {
32
+ const id = idGetter(item);
33
+ const idx = array.findIndex(i => idGetter(i) === id);
34
+ if (idx >= 0) {
35
+ array.splice(idx, 1);
36
+ delete dict[id];
37
+ return true;
38
+ }
39
+ return false;
40
+ };
41
+ return {
42
+ array,
43
+ get,
44
+ upsert,
45
+ update,
46
+ remove,
47
+ updateAssign: (id, update) => {
48
+ const item = get(id);
49
+ if (item) {
50
+ Object.assign(item, update);
51
+ delete dict[id];
52
+ dict[idGetter(item)] = item;
53
+ return true;
54
+ }
55
+ return false;
56
+ },
57
+ clear: () => {
58
+ array.splice(0, array.length);
59
+ Object.keys(dict).forEach(key => {
60
+ delete dict[key];
61
+ });
62
+ },
63
+ filter: (contain) => {
64
+ let i = 0;
65
+ while (i < array.length) {
66
+ if (!contain(array[i])) {
67
+ delete dict[idGetter(array[i])];
68
+ array.splice(i, 1);
69
+ }
70
+ else {
71
+ i += 1;
72
+ }
73
+ }
74
+ },
75
+ toJSON: () => array,
76
+ fromJSON: (newItems) => {
77
+ array.splice(0, array.length, ...newItems);
78
+ }
79
+ };
78
80
  }
79
- //===================================//
81
+ exports.default = makeOrderedDictionary;
@@ -0,0 +1,10 @@
1
+ export declare class ObjectRepository<T extends object> {
2
+ readonly entityMap: Map<string, T>;
3
+ constructor(entities?: Record<string, T>);
4
+ findById(id: string): T | undefined;
5
+ findAll(): T[];
6
+ upsertById(id: string, entity: T): Map<string, T>;
7
+ deleteById(id: string): boolean;
8
+ count(): number;
9
+ toJSON(): T[];
10
+ }
@@ -1,25 +1,27 @@
1
- //===================================//
2
- export class ObjectRepository {
3
- constructor(entities = {}) {
4
- this.entityMap = new Map(Object.entries(entities))
5
- }
6
- findById(id) {
7
- return this.entityMap.get(id)
8
- }
9
- findAll() {
10
- return Array.from(this.entityMap.values())
11
- }
12
- upsertById(id, entity) {
13
- return this.entityMap.set(id, { ...entity })
14
- }
15
- deleteById(id) {
16
- return this.entityMap.delete(id)
17
- }
18
- count() {
19
- return this.entityMap.size
20
- }
21
- toJSON() {
22
- return this.findAll()
23
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ObjectRepository = void 0;
4
+ class ObjectRepository {
5
+ constructor(entities = {}) {
6
+ this.entityMap = new Map(Object.entries(entities));
7
+ }
8
+ findById(id) {
9
+ return this.entityMap.get(id);
10
+ }
11
+ findAll() {
12
+ return Array.from(this.entityMap.values());
13
+ }
14
+ upsertById(id, entity) {
15
+ return this.entityMap.set(id, { ...entity });
16
+ }
17
+ deleteById(id) {
18
+ return this.entityMap.delete(id);
19
+ }
20
+ count() {
21
+ return this.entityMap.size;
22
+ }
23
+ toJSON() {
24
+ return this.findAll();
25
+ }
24
26
  }
25
- //===================================//
27
+ exports.ObjectRepository = ObjectRepository;
@@ -0,0 +1,110 @@
1
+ /// <reference types="node" />
2
+ import type { proto } from '../../WAProto';
3
+ import { RegistrationOptions } from '../Socket/registration';
4
+ import type { Contact } from './Contact';
5
+ import type { MinimalMessage } from './Message';
6
+ export type KeyPair = {
7
+ public: Uint8Array;
8
+ private: Uint8Array;
9
+ };
10
+ export type SignedKeyPair = {
11
+ keyPair: KeyPair;
12
+ signature: Uint8Array;
13
+ keyId: number;
14
+ timestampS?: number;
15
+ };
16
+ export type ProtocolAddress = {
17
+ name: string;
18
+ deviceId: number;
19
+ };
20
+ export type SignalIdentity = {
21
+ identifier: ProtocolAddress;
22
+ identifierKey: Uint8Array;
23
+ };
24
+ export type LTHashState = {
25
+ version: number;
26
+ hash: Buffer;
27
+ indexValueMap: {
28
+ [indexMacBase64: string]: {
29
+ valueMac: Uint8Array | Buffer;
30
+ };
31
+ };
32
+ };
33
+ export type SignalCreds = {
34
+ readonly signedIdentityKey: KeyPair;
35
+ readonly signedPreKey: SignedKeyPair;
36
+ readonly registrationId: number;
37
+ };
38
+ export type AccountSettings = {
39
+ /** unarchive chats when a new message is received */
40
+ unarchiveChats: boolean;
41
+ /** the default mode to start new conversations with */
42
+ defaultDisappearingMode?: Pick<proto.IConversation, 'ephemeralExpiration' | 'ephemeralSettingTimestamp'>;
43
+ };
44
+ export type AuthenticationCreds = SignalCreds & {
45
+ readonly noiseKey: KeyPair;
46
+ readonly pairingEphemeralKeyPair: KeyPair;
47
+ advSecretKey: string;
48
+ me?: Contact;
49
+ account?: proto.IADVSignedDeviceIdentity;
50
+ signalIdentities?: SignalIdentity[];
51
+ myAppStateKeyId?: string;
52
+ firstUnuploadedPreKeyId: number;
53
+ nextPreKeyId: number;
54
+ lastAccountSyncTimestamp?: number;
55
+ platform?: string;
56
+ processedHistoryMessages: MinimalMessage[];
57
+ /** number of times history & app state has been synced */
58
+ accountSyncCounter: number;
59
+ accountSettings: AccountSettings;
60
+ deviceId: string;
61
+ phoneId: string;
62
+ identityId: Buffer;
63
+ registered: boolean;
64
+ backupToken: Buffer;
65
+ registration: RegistrationOptions;
66
+ pairingCode: string | undefined;
67
+ lastPropHash: string | undefined;
68
+ routingInfo: Buffer | undefined;
69
+ };
70
+ export type SignalDataTypeMap = {
71
+ 'pre-key': KeyPair;
72
+ 'session': Uint8Array;
73
+ 'sender-key': Uint8Array;
74
+ 'sender-key-memory': {
75
+ [jid: string]: boolean;
76
+ };
77
+ 'app-state-sync-key': proto.Message.IAppStateSyncKeyData;
78
+ 'app-state-sync-version': LTHashState;
79
+ };
80
+ export type SignalDataSet = {
81
+ [T in keyof SignalDataTypeMap]?: {
82
+ [id: string]: SignalDataTypeMap[T] | null;
83
+ };
84
+ };
85
+ type Awaitable<T> = T | Promise<T>;
86
+ export type SignalKeyStore = {
87
+ get<T extends keyof SignalDataTypeMap>(type: T, ids: string[]): Awaitable<{
88
+ [id: string]: SignalDataTypeMap[T];
89
+ }>;
90
+ set(data: SignalDataSet): Awaitable<void>;
91
+ /** clear all the data in the store */
92
+ clear?(): Awaitable<void>;
93
+ };
94
+ export type SignalKeyStoreWithTransaction = SignalKeyStore & {
95
+ isInTransaction: () => boolean;
96
+ transaction<T>(exec: () => Promise<T>): Promise<T>;
97
+ };
98
+ export type TransactionCapabilityOptions = {
99
+ maxCommitRetries: number;
100
+ delayBetweenTriesMs: number;
101
+ };
102
+ export type SignalAuthState = {
103
+ creds: SignalCreds;
104
+ keys: SignalKeyStore | SignalKeyStoreWithTransaction;
105
+ };
106
+ export type AuthenticationState = {
107
+ creds: AuthenticationCreds;
108
+ keys: SignalKeyStore;
109
+ };
110
+ export {};
package/lib/Types/Auth.js CHANGED
@@ -1,3 +1,2 @@
1
- //=======================================================//
2
- export {};
3
- //=======================================================//
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept';
2
+ export type WACallEvent = {
3
+ chatId: string;
4
+ from: string;
5
+ isGroup?: boolean;
6
+ groupJid?: string;
7
+ id: string;
8
+ date: Date;
9
+ isVideo?: boolean;
10
+ status: WACallUpdateType;
11
+ offline: boolean;
12
+ latencyMs?: number;
13
+ };
package/lib/Types/Call.js CHANGED
@@ -1,3 +1,2 @@
1
- //=======================================================//
2
- export {};
3
- //=======================================================//
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,102 @@
1
+ import type { proto } from '../../WAProto';
2
+ import type { AccountSettings } from './Auth';
3
+ import type { BufferedEventData } from './Events';
4
+ import type { ChatLabelAssociationActionBody } from './LabelAssociation';
5
+ import type { MessageLabelAssociationActionBody } from './LabelAssociation';
6
+ import type { MinimalMessage } from './Message';
7
+ /** privacy settings in WhatsApp Web */
8
+ export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none';
9
+ export type WAPrivacyOnlineValue = 'all' | 'match_last_seen';
10
+ export type WAReadReceiptsValue = 'all' | 'none';
11
+ /** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
12
+ export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
13
+ export declare const ALL_WA_PATCH_NAMES: readonly ["critical_block", "critical_unblock_low", "regular_high", "regular_low", "regular"];
14
+ export type WAPatchName = typeof ALL_WA_PATCH_NAMES[number];
15
+ export interface PresenceData {
16
+ lastKnownPresence: WAPresence;
17
+ lastSeen?: number;
18
+ }
19
+ export type ChatMutation = {
20
+ syncAction: proto.ISyncActionData;
21
+ index: string[];
22
+ };
23
+ export type WAPatchCreate = {
24
+ syncAction: proto.ISyncActionValue;
25
+ index: string[];
26
+ type: WAPatchName;
27
+ apiVersion: number;
28
+ operation: proto.SyncdMutation.SyncdOperation;
29
+ };
30
+ export type Chat = proto.IConversation & {
31
+ /** unix timestamp of when the last message was received in the chat */
32
+ lastMessageRecvTimestamp?: number;
33
+ };
34
+ export type ChatUpdate = Partial<Chat & {
35
+ /**
36
+ * if specified in the update,
37
+ * the EV buffer will check if the condition gets fulfilled before applying the update
38
+ * Right now, used to determine when to release an app state sync event
39
+ *
40
+ * @returns true, if the update should be applied;
41
+ * false if it can be discarded;
42
+ * undefined if the condition is not yet fulfilled
43
+ * */
44
+ conditional: (bufferedData: BufferedEventData) => boolean | undefined;
45
+ }>;
46
+ /**
47
+ * the last messages in a chat, sorted reverse-chronologically. That is, the latest message should be first in the chat
48
+ * for MD modifications, the last message in the array (i.e. the earlist message) must be the last message recv in the chat
49
+ * */
50
+ export type LastMessageList = MinimalMessage[] | proto.SyncActionValue.ISyncActionMessageRange;
51
+ export type ChatModification = {
52
+ archive: boolean;
53
+ lastMessages: LastMessageList;
54
+ } | {
55
+ pushNameSetting: string;
56
+ } | {
57
+ pin: boolean;
58
+ } | {
59
+ /** mute for duration, or provide timestamp of mute to remove*/
60
+ mute: number | null;
61
+ } | {
62
+ clear: 'all' | {
63
+ messages: {
64
+ id: string;
65
+ fromMe?: boolean;
66
+ timestamp: number;
67
+ }[];
68
+ };
69
+ } | {
70
+ star: {
71
+ messages: {
72
+ id: string;
73
+ fromMe?: boolean;
74
+ }[];
75
+ star: boolean;
76
+ };
77
+ } | {
78
+ markRead: boolean;
79
+ lastMessages: LastMessageList;
80
+ } | {
81
+ delete: true;
82
+ lastMessages: LastMessageList;
83
+ } | {
84
+ addChatLabel: ChatLabelAssociationActionBody;
85
+ } | {
86
+ removeChatLabel: ChatLabelAssociationActionBody;
87
+ } | {
88
+ addMessageLabel: MessageLabelAssociationActionBody;
89
+ } | {
90
+ removeMessageLabel: MessageLabelAssociationActionBody;
91
+ };
92
+ export type InitialReceivedChatsState = {
93
+ [jid: string]: {
94
+ /** the last message received from the other party */
95
+ lastMsgRecvTimestamp?: number;
96
+ /** the absolute last message in the chat */
97
+ lastMsgTimestamp: number;
98
+ };
99
+ };
100
+ export type InitialAppStateSyncOptions = {
101
+ accountSettings: AccountSettings;
102
+ };
package/lib/Types/Chat.js CHANGED
@@ -1,9 +1,4 @@
1
- //=======================================================//
2
- export const ALL_WA_PATCH_NAMES = [
3
- "critical_block",
4
- "critical_unblock_low",
5
- "regular_high",
6
- "regular_low",
7
- "regular"
8
- ];
9
- //=======================================================//
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ALL_WA_PATCH_NAMES = void 0;
4
+ exports.ALL_WA_PATCH_NAMES = ['critical_block', 'critical_unblock_low', 'regular_high', 'regular_low', 'regular'];
@@ -0,0 +1,19 @@
1
+ export interface Contact {
2
+ id: string;
3
+ lid?: string;
4
+ /** name of the contact, you have saved on your WA */
5
+ name?: string;
6
+ /** name of the contact, the contact has set on their own on WA */
7
+ notify?: string;
8
+ /** I have no idea */
9
+ verifiedName?: string;
10
+ /**
11
+ * Url of the profile picture of the contact
12
+ *
13
+ * 'changed' => if the profile picture has changed
14
+ * null => if the profile picture has not been set (default profile picture)
15
+ * any other string => url of the profile picture
16
+ */
17
+ imgUrl?: string | null | 'changed';
18
+ status?: string;
19
+ }
@@ -1,3 +1,2 @@
1
- //=======================================================//
2
- export {};
3
- //=======================================================//
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,157 @@
1
+ import type { Boom } from '@hapi/boom';
2
+ import { proto } from '../../WAProto';
3
+ import { AuthenticationCreds } from './Auth';
4
+ import { WACallEvent } from './Call';
5
+ import { Chat, ChatUpdate, PresenceData } from './Chat';
6
+ import { Contact } from './Contact';
7
+ import { GroupMetadata, ParticipantAction } from './GroupMetadata';
8
+ import { Label } from './Label';
9
+ import { LabelAssociation } from './LabelAssociation';
10
+ import { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message';
11
+ import { ConnectionState } from './State';
12
+ export type BaileysEventMap = {
13
+ /** connection state has been updated -- WS closed, opened, connecting etc. */
14
+ 'connection.update': Partial<ConnectionState>;
15
+ /** credentials updated -- some metadata, keys or something */
16
+ 'creds.update': Partial<AuthenticationCreds>;
17
+ /** set chats (history sync), everything is reverse chronologically sorted */
18
+ 'messaging-history.set': {
19
+ chats: Chat[];
20
+ contacts: Contact[];
21
+ messages: WAMessage[];
22
+ isLatest: boolean;
23
+ };
24
+ /** upsert chats */
25
+ 'chats.upsert': Chat[];
26
+ /** update the given chats */
27
+ 'chats.update': ChatUpdate[];
28
+ 'chats.phoneNumberShare': {
29
+ lid: string;
30
+ jid: string;
31
+ };
32
+ /** delete chats with given ID */
33
+ 'chats.delete': string[];
34
+ /** presence of contact in a chat updated */
35
+ 'presence.update': {
36
+ id: string;
37
+ presences: {
38
+ [participant: string]: PresenceData;
39
+ };
40
+ };
41
+ 'contacts.upsert': Contact[];
42
+ 'contacts.update': Partial<Contact>[];
43
+ 'messages.delete': {
44
+ keys: WAMessageKey[];
45
+ } | {
46
+ jid: string;
47
+ all: true;
48
+ };
49
+ 'messages.update': WAMessageUpdate[];
50
+ 'messages.media-update': {
51
+ key: WAMessageKey;
52
+ media?: {
53
+ ciphertext: Uint8Array;
54
+ iv: Uint8Array;
55
+ };
56
+ error?: Boom;
57
+ }[];
58
+ /**
59
+ * add/update the given messages. If they were received while the connection was online,
60
+ * the update will have type: "notify"
61
+ * */
62
+ 'messages.upsert': {
63
+ messages: WAMessage[];
64
+ type: MessageUpsertType;
65
+ };
66
+ /** message was reacted to. If reaction was removed -- then "reaction.text" will be falsey */
67
+ 'messages.reaction': {
68
+ key: WAMessageKey;
69
+ reaction: proto.IReaction;
70
+ }[];
71
+ 'message-receipt.update': MessageUserReceiptUpdate[];
72
+ 'groups.upsert': GroupMetadata[];
73
+ 'groups.update': Partial<GroupMetadata>[];
74
+ /** apply an action to participants in a group */
75
+ 'group-participants.update': {
76
+ id: string;
77
+ author: string;
78
+ participants: string[];
79
+ action: ParticipantAction;
80
+ };
81
+ 'blocklist.set': {
82
+ blocklist: string[];
83
+ };
84
+ 'blocklist.update': {
85
+ blocklist: string[];
86
+ type: 'add' | 'remove';
87
+ };
88
+ /** Receive an update on a call, including when the call was received, rejected, accepted */
89
+ 'call': WACallEvent[];
90
+ 'labels.edit': Label;
91
+ 'labels.association': {
92
+ association: LabelAssociation;
93
+ type: 'add' | 'remove';
94
+ };
95
+ };
96
+ export type BufferedEventData = {
97
+ historySets: {
98
+ chats: {
99
+ [jid: string]: Chat;
100
+ };
101
+ contacts: {
102
+ [jid: string]: Contact;
103
+ };
104
+ messages: {
105
+ [uqId: string]: WAMessage;
106
+ };
107
+ empty: boolean;
108
+ isLatest: boolean;
109
+ };
110
+ chatUpserts: {
111
+ [jid: string]: Chat;
112
+ };
113
+ chatUpdates: {
114
+ [jid: string]: ChatUpdate;
115
+ };
116
+ chatDeletes: Set<string>;
117
+ contactUpserts: {
118
+ [jid: string]: Contact;
119
+ };
120
+ contactUpdates: {
121
+ [jid: string]: Partial<Contact>;
122
+ };
123
+ messageUpserts: {
124
+ [key: string]: {
125
+ type: MessageUpsertType;
126
+ message: WAMessage;
127
+ };
128
+ };
129
+ messageUpdates: {
130
+ [key: string]: WAMessageUpdate;
131
+ };
132
+ messageDeletes: {
133
+ [key: string]: WAMessageKey;
134
+ };
135
+ messageReactions: {
136
+ [key: string]: {
137
+ key: WAMessageKey;
138
+ reactions: proto.IReaction[];
139
+ };
140
+ };
141
+ messageReceipts: {
142
+ [key: string]: {
143
+ key: WAMessageKey;
144
+ userReceipt: proto.IUserReceipt[];
145
+ };
146
+ };
147
+ groupUpdates: {
148
+ [jid: string]: Partial<GroupMetadata>;
149
+ };
150
+ };
151
+ export type BaileysEvent = keyof BaileysEventMap;
152
+ export interface BaileysEventEmitter {
153
+ on<T extends keyof BaileysEventMap>(event: T, listener: (arg: BaileysEventMap[T]) => void): void;
154
+ off<T extends keyof BaileysEventMap>(event: T, listener: (arg: BaileysEventMap[T]) => void): void;
155
+ removeAllListeners<T extends keyof BaileysEventMap>(event: T): void;
156
+ emit<T extends keyof BaileysEventMap>(event: T, arg: BaileysEventMap[T]): boolean;
157
+ }
@@ -1,3 +1,2 @@
1
- //=======================================================//
2
- import { proto } from "../../WAProto/index.js";
3
- //=======================================================//
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });