@elrayyxml/baileys 1.0.1 → 1.0.3

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 (95) hide show
  1. package/README.MD +22 -4
  2. package/lib/Defaults/index.js +1 -1
  3. package/lib/Utils/validate-connection.js +30 -4
  4. package/package.json +1 -8
  5. package/lib/Defaults/index.d.ts +0 -51
  6. package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
  7. package/lib/Signal/Group/group-session-builder.d.ts +0 -14
  8. package/lib/Signal/Group/group_cipher.d.ts +0 -17
  9. package/lib/Signal/Group/index.d.ts +0 -11
  10. package/lib/Signal/Group/keyhelper.d.ts +0 -10
  11. package/lib/Signal/Group/queue-job.d.ts +0 -1
  12. package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
  13. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
  14. package/lib/Signal/Group/sender-key-message.d.ts +0 -18
  15. package/lib/Signal/Group/sender-key-name.d.ts +0 -17
  16. package/lib/Signal/Group/sender-key-record.d.ts +0 -30
  17. package/lib/Signal/Group/sender-key-state.d.ts +0 -38
  18. package/lib/Signal/Group/sender-message-key.d.ts +0 -11
  19. package/lib/Signal/libsignal.d.ts +0 -3
  20. package/lib/Socket/Client/index.d.ts +0 -2
  21. package/lib/Socket/Client/types.d.ts +0 -16
  22. package/lib/Socket/Client/websocket.d.ts +0 -13
  23. package/lib/Socket/business.d.ts +0 -172
  24. package/lib/Socket/chats.d.ts +0 -82
  25. package/lib/Socket/groups.d.ts +0 -124
  26. package/lib/Socket/index.d.ts +0 -172
  27. package/lib/Socket/messages-recv.d.ts +0 -161
  28. package/lib/Socket/messages-send.d.ts +0 -151
  29. package/lib/Socket/newsletter.d.ts +0 -136
  30. package/lib/Socket/socket.d.ts +0 -43
  31. package/lib/Socket/type.d.ts +0 -253
  32. package/lib/Socket/usync.d.ts +0 -36
  33. package/lib/Store/index.d.ts +0 -2
  34. package/lib/Store/make-in-memory-store.d.ts +0 -118
  35. package/lib/Store/make-ordered-dictionary.d.ts +0 -13
  36. package/lib/Store/object-repository.d.ts +0 -10
  37. package/lib/Types/Auth.d.ts +0 -103
  38. package/lib/Types/Call.d.ts +0 -13
  39. package/lib/Types/Chat.d.ts +0 -109
  40. package/lib/Types/Contact.d.ts +0 -23
  41. package/lib/Types/Events.d.ts +0 -199
  42. package/lib/Types/GroupMetadata.d.ts +0 -64
  43. package/lib/Types/Label.d.ts +0 -35
  44. package/lib/Types/LabelAssociation.d.ts +0 -29
  45. package/lib/Types/Message.d.ts +0 -400
  46. package/lib/Types/Newsletter.d.ts +0 -79
  47. package/lib/Types/Product.d.ts +0 -78
  48. package/lib/Types/Signal.d.ts +0 -57
  49. package/lib/Types/Socket.d.ts +0 -119
  50. package/lib/Types/State.d.ts +0 -27
  51. package/lib/Types/USync.d.ts +0 -25
  52. package/lib/Types/index.d.ts +0 -64
  53. package/lib/Utils/auth-utils.d.ts +0 -18
  54. package/lib/Utils/baileys-event-stream.d.ts +0 -16
  55. package/lib/Utils/business.d.ts +0 -22
  56. package/lib/Utils/chat-utils.d.ts +0 -70
  57. package/lib/Utils/crypto.d.ts +0 -40
  58. package/lib/Utils/decode-wa-message.d.ts +0 -35
  59. package/lib/Utils/event-buffer.d.ts +0 -35
  60. package/lib/Utils/generics.d.ts +0 -89
  61. package/lib/Utils/history.d.ts +0 -19
  62. package/lib/Utils/index.d.ts +0 -17
  63. package/lib/Utils/link-preview.d.ts +0 -21
  64. package/lib/Utils/logger.d.ts +0 -11
  65. package/lib/Utils/lt-hash.d.ts +0 -12
  66. package/lib/Utils/make-mutex.d.ts +0 -7
  67. package/lib/Utils/messages-media.d.ts +0 -120
  68. package/lib/Utils/messages.d.ts +0 -75
  69. package/lib/Utils/noise-handler.d.ts +0 -19
  70. package/lib/Utils/process-message.d.ts +0 -42
  71. package/lib/Utils/signal.d.ts +0 -33
  72. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -12
  73. package/lib/Utils/validate-connection.d.ts +0 -10
  74. package/lib/WABinary/constants.d.ts +0 -27
  75. package/lib/WABinary/decode.d.ts +0 -6
  76. package/lib/WABinary/encode.d.ts +0 -2
  77. package/lib/WABinary/generic-utils.d.ts +0 -14
  78. package/lib/WABinary/index.d.ts +0 -5
  79. package/lib/WABinary/jid-utils.d.ts +0 -36
  80. package/lib/WABinary/types.d.ts +0 -18
  81. package/lib/WAM/BinaryInfo.d.ts +0 -8
  82. package/lib/WAM/constants.d.ts +0 -38
  83. package/lib/WAM/encode.d.ts +0 -2
  84. package/lib/WAM/index.d.ts +0 -3
  85. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
  86. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
  87. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
  88. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
  89. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
  90. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
  91. package/lib/WAUSync/Protocols/index.d.ts +0 -4
  92. package/lib/WAUSync/USyncQuery.d.ts +0 -28
  93. package/lib/WAUSync/USyncUser.d.ts +0 -12
  94. package/lib/WAUSync/index.d.ts +0 -3
  95. package/lib/index.d.ts +0 -13
@@ -1,253 +0,0 @@
1
- import { proto } from '../../WAProto';
2
-
3
- declare namespace elrayyxml {
4
- interface MediaUploadOptions {
5
- fileEncSha256?: Buffer;
6
- mediaType?: string;
7
- newsletter?: boolean;
8
- }
9
-
10
- type WAMediaUploadFunction = (
11
- stream: Buffer | NodeJS.ReadableStream,
12
- options?: MediaUploadOptions
13
- ) => Promise<{ url: string; directPath: string }>;
14
-
15
- interface WAMessageContentGenerationOptions {
16
- upload?: WAMediaUploadFunction;
17
- mediaCache?: any;
18
- options?: any;
19
- logger?: any;
20
- }
21
-
22
- interface StickerMessage {
23
- url: string;
24
- fileSha256: Buffer | string;
25
- fileEncSha256: Buffer | string;
26
- mediaKey: Buffer | string;
27
- mimetype: string;
28
- directPath: string;
29
- fileLength: number | string;
30
- mediaKeyTimestamp: number | string;
31
- isAnimated?: boolean;
32
- stickerSentTs?: number | string;
33
- isAvatar?: boolean;
34
- isAiSticker?: boolean;
35
- isLottie?: boolean;
36
- }
37
-
38
- interface PaymentMessage {
39
- amount: number;
40
- currency?: string;
41
- from?: string;
42
- expiry?: number;
43
- sticker?: { stickerMessage: StickerMessage };
44
- note?: string;
45
- background?: {
46
- id?: string;
47
- fileLength?: string;
48
- width?: number;
49
- height?: number;
50
- mimetype?: string;
51
- placeholderArgb?: number;
52
- textArgb?: number;
53
- subtextArgb?: number;
54
- };
55
- }
56
-
57
- interface ProductMessage {
58
- title: string;
59
- description: string;
60
- thumbnail: Buffer | { url: string };
61
- productId: string;
62
- retailerId: string;
63
- url: string;
64
- body?: string;
65
- footer?: string;
66
- buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
67
- priceAmount1000?: number | null;
68
- currencyCode?: string;
69
- }
70
-
71
- interface InteractiveMessage {
72
- header?: string;
73
- title: string;
74
- footer?: string;
75
- thumbnail?: string;
76
- image?: string | Buffer | { url: string };
77
- video?: string | Buffer | { url: string };
78
- document?: string | Buffer | { url: string };
79
- mimetype?: string;
80
- fileName?: string;
81
- jpegThumbnail?: string | Buffer | { url: string };
82
- contextInfo?: {
83
- mentionedJid?: string[];
84
- forwardingScore?: number;
85
- isForwarded?: boolean;
86
- externalAdReply?: {
87
- title?: string;
88
- body?: string;
89
- mediaType?: number;
90
- thumbnailUrl?: string;
91
- mediaUrl?: string;
92
- sourceUrl?: string;
93
- showAdAttribution?: boolean;
94
- renderLargerThumbnail?: boolean;
95
- [key: string]: any;
96
- };
97
- [key: string]: any;
98
- };
99
- externalAdReply?: {
100
- title?: string;
101
- body?: string;
102
- mediaType?: number;
103
- thumbnailUrl?: string;
104
- mediaUrl?: string;
105
- sourceUrl?: string;
106
- showAdAttribution?: boolean;
107
- renderLargerThumbnail?: boolean;
108
- [key: string]: any;
109
- };
110
- buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
111
- nativeFlowMessage?: {
112
- messageParamsJson?: string;
113
- buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
114
- [key: string]: any;
115
- };
116
- }
117
-
118
- interface AlbumItem {
119
- image?: string | Buffer | { url: string; caption?: string };
120
- video?: string | Buffer | { url: string; caption?: string };
121
- }
122
-
123
- interface EventMessageLocation {
124
- degreesLatitude: number;
125
- degreesLongitude: number;
126
- name: string;
127
- }
128
-
129
- interface EventMessage {
130
- isCanceled?: boolean;
131
- name: string;
132
- description: string;
133
- location?: EventMessageLocation;
134
- joinLink?: string;
135
- startTime?: string | number;
136
- endTime?: string | number;
137
- extraGuestsAllowed?: boolean;
138
- }
139
-
140
- interface PollVote {
141
- optionName: string;
142
- optionVoteCount: string | number;
143
- }
144
-
145
- interface PollResultMessage {
146
- name: string;
147
- pollVotes: PollVote[];
148
- }
149
-
150
- interface GroupStatusMessage {
151
- message?: any;
152
- image?: string | Buffer | { url: string };
153
- video?: string | Buffer | { url: string };
154
- text?: string;
155
- caption?: string;
156
- document?: string | Buffer | { url: string };
157
- [key: string]: any;
158
- }
159
-
160
- interface MessageContent {
161
- requestPaymentMessage?: PaymentMessage;
162
- productMessage?: ProductMessage;
163
- interactiveMessage?: InteractiveMessage;
164
- albumMessage?: AlbumItem[];
165
- eventMessage?: EventMessage;
166
- pollResultMessage?: PollResultMessage;
167
- groupStatusMessage?: GroupStatusMessage;
168
- sender?: string;
169
- }
170
-
171
- interface MessageOptions {
172
- quoted?: proto.IWebMessageInfo;
173
- filter?: boolean;
174
- }
175
-
176
- interface Utils {
177
- prepareWAMessageMedia: (media: any, options: WAMessageContentGenerationOptions) => Promise<any>;
178
- generateWAMessageContent: (content: any, options: WAMessageContentGenerationOptions) => Promise<any>;
179
- generateWAMessageFromContent: (jid: string, content: any, options?: any) => Promise<any>;
180
- generateWAMessage: (jid: string, content: any, options?: any) => Promise<any>;
181
- generateMessageID: () => string;
182
- prepareMessageContent?: (content: any, options?: any) => Promise<any>;
183
- }
184
-
185
- interface BailUtils {
186
- generateWAMessageContent?: (content: any, options: WAMessageContentGenerationOptions) => Promise<any>;
187
- generateMessageID: () => string;
188
- getContentType: (msg: any) => string;
189
- }
190
- }
191
-
192
- declare class elrayyxml {
193
- constructor(
194
- utils: elrayyxml.Utils,
195
- waUploadToServer: elrayyxml.WAMediaUploadFunction,
196
- relayMessageFn?: (jid: string, content: any, options?: any) => Promise<any>
197
- );
198
-
199
- detectType(content: elrayyxml.MessageContent): 'PAYMENT' | 'PRODUCT' | 'INTERACTIVE' | 'ALBUM' | 'EVENT' | 'POLL_RESULT' | 'GROUP_STORY' | null;
200
-
201
- handlePayment(
202
- content: { requestPaymentMessage: elrayyxml.PaymentMessage },
203
- quoted?: proto.IWebMessageInfo
204
- ): Promise<{ requestPaymentMessage: proto.Message.RequestPaymentMessage }>;
205
-
206
- handleProduct(
207
- content: { productMessage: elrayyxml.ProductMessage },
208
- jid: string,
209
- quoted?: proto.IWebMessageInfo
210
- ): Promise<{ viewOnceMessage: proto.Message.ViewOnceMessage }>;
211
-
212
- handleInteractive(
213
- content: { interactiveMessage: elrayyxml.InteractiveMessage },
214
- jid: string,
215
- quoted?: proto.IWebMessageInfo
216
- ): Promise<{ interactiveMessage: proto.Message.InteractiveMessage }>;
217
-
218
- handleAlbum(
219
- content: { albumMessage: elrayyxml.AlbumItem[] },
220
- jid: string,
221
- quoted?: proto.IWebMessageInfo
222
- ): Promise<any>;
223
-
224
- handleEvent(
225
- content: { eventMessage: elrayyxml.EventMessage },
226
- jid: string,
227
- quoted?: proto.IWebMessageInfo
228
- ): Promise<any>;
229
-
230
- handlePollResult(
231
- content: { pollResultMessage: elrayyxml.PollResultMessage },
232
- jid: string,
233
- quoted?: proto.IWebMessageInfo
234
- ): Promise<any>;
235
-
236
- handleGroupStory(
237
- content: { groupStatusMessage: elrayyxml.GroupStatusMessage },
238
- jid: string,
239
- quoted?: proto.IWebMessageInfo
240
- ): Promise<any>;
241
-
242
- buildMessageContent(
243
- content: any,
244
- opts?: elrayyxml.WAMessageContentGenerationOptions
245
- ): Promise<any>;
246
-
247
- utils: elrayyxml.Utils;
248
- relayMessage: (jid: string, content: any, options?: any) => Promise<any>;
249
- waUploadToServer: elrayyxml.WAMediaUploadFunction;
250
- bail: elrayyxml.BailUtils;
251
- }
252
-
253
- export = elrayyxml;
@@ -1,36 +0,0 @@
1
- import { Boom } from '@hapi/boom';
2
- import { SocketConfig } from '../Types';
3
- import { BinaryNode } from '../WABinary';
4
- import { USyncQuery } from '../WAUSync';
5
- export declare const makeUSyncSocket: (config: SocketConfig) => {
6
- executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
7
- type: "md";
8
- ws: import("./Client").WebSocketClient;
9
- ev: import("../Types").BaileysEventEmitter & {
10
- process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
11
- buffer(): void;
12
- createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
13
- flush(force?: boolean): boolean;
14
- isBuffering(): boolean;
15
- };
16
- authState: {
17
- creds: import("../Types").AuthenticationCreds;
18
- keys: import("../Types").SignalKeyStoreWithTransaction;
19
- };
20
- signalRepository: import("../Types").SignalRepository;
21
- user: import("../Types").Contact | undefined;
22
- generateMessageTag: () => string;
23
- query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
24
- waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
25
- waitForSocketOpen: () => Promise<void>;
26
- sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
27
- sendNode: (frame: BinaryNode) => Promise<void>;
28
- logout: (msg?: string) => Promise<void>;
29
- end: (error: Error | undefined) => void;
30
- onUnexpectedError: (err: Error | Boom, msg: string) => void;
31
- uploadPreKeys: (count?: number) => Promise<void>;
32
- uploadPreKeysToServerIfRequired: () => Promise<void>;
33
- requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
34
- waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
35
- sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
36
- };
@@ -1,2 +0,0 @@
1
- import makeInMemoryStore from './make-in-memory-store';
2
- export { makeInMemoryStore };
@@ -1,118 +0,0 @@
1
- import type KeyedDB from '@adiwajshing/keyed-db';
2
- import type { Comparable } from '@adiwajshing/keyed-db/lib/Types';
3
- import { proto } from '../../WAProto';
4
- import type makeMDSocket from '../Socket';
5
- import type { BaileysEventEmitter, Chat, ConnectionState, Contact, GroupMetadata, PresenceData, WAMessage, WAMessageCursor, WAMessageKey } from '../Types';
6
- import { Label } from '../Types/Label';
7
- import { LabelAssociation } from '../Types/LabelAssociation';
8
- import { ILogger } from '../Utils/logger';
9
- import { ObjectRepository } from './object-repository';
10
- type WASocket = ReturnType<typeof makeMDSocket>;
11
- export declare const waChatKey: (pin: boolean) => {
12
- key: (c: Chat) => string;
13
- compare: (k1: string, k2: string) => number;
14
- };
15
- export declare const waMessageID: (m: WAMessage) => string;
16
- export declare const waLabelAssociationKey: Comparable<LabelAssociation, string>;
17
- export type BaileysInMemoryStoreConfig = {
18
- chatKey?: Comparable<Chat, string>;
19
- labelAssociationKey?: Comparable<LabelAssociation, string>;
20
- logger?: ILogger;
21
- socket?: WASocket;
22
- };
23
- declare const _default: (config: BaileysInMemoryStoreConfig) => {
24
- chats: KeyedDB<Chat, string>;
25
- contacts: {
26
- [_: string]: Contact;
27
- };
28
- messages: {
29
- [_: string]: {
30
- array: WAMessage[];
31
- get: (id: string) => WAMessage | undefined;
32
- upsert: (item: WAMessage, mode: "append" | "prepend") => void;
33
- update: (item: WAMessage) => boolean;
34
- remove: (item: WAMessage) => boolean;
35
- updateAssign: (id: string, update: Partial<WAMessage>) => boolean;
36
- clear: () => void;
37
- filter: (contain: (item: WAMessage) => boolean) => void;
38
- toJSON: () => WAMessage[];
39
- fromJSON: (newItems: WAMessage[]) => void;
40
- };
41
- };
42
- groupMetadata: {
43
- [_: string]: GroupMetadata;
44
- };
45
- state: ConnectionState;
46
- presences: {
47
- [id: string]: {
48
- [participant: string]: PresenceData;
49
- };
50
- };
51
- labels: ObjectRepository<Label>;
52
- labelAssociations: KeyedDB<LabelAssociation, string>;
53
- bind: (ev: BaileysEventEmitter) => void;
54
- /** loads messages from the store, if not found -- uses the legacy connection */
55
- loadMessages: (jid: string, count: number, cursor: WAMessageCursor) => Promise<WAMessage[]>;
56
- /**
57
- * Get all available labels for profile
58
- *
59
- * Keep in mind that the list is formed from predefined tags and tags
60
- * that were "caught" during their editing.
61
- */
62
- getLabels: () => ObjectRepository<Label>;
63
- /**
64
- * Get labels for chat
65
- *
66
- * @returns Label IDs
67
- **/
68
- getChatLabels: (chatId: string) => LabelAssociation[];
69
- /**
70
- * Get labels for message
71
- *
72
- * @returns Label IDs
73
- **/
74
- getMessageLabels: (messageId: string) => string[];
75
- loadMessage: (jid: string, id: string) => Promise<WAMessage | undefined>;
76
- mostRecentMessage: (jid: string) => Promise<WAMessage>;
77
- fetchImageUrl: (jid: string, sock: WASocket | undefined) => Promise<string | null | undefined>;
78
- fetchGroupMetadata: (jid: string, sock: WASocket | undefined) => Promise<GroupMetadata>;
79
- fetchMessageReceipts: ({ remoteJid, id }: WAMessageKey) => Promise<proto.IUserReceipt[] | null | undefined>;
80
- toJSON: () => {
81
- chats: KeyedDB<Chat, string>;
82
- contacts: {
83
- [_: string]: Contact;
84
- };
85
- messages: {
86
- [_: string]: {
87
- array: WAMessage[];
88
- get: (id: string) => WAMessage | undefined;
89
- upsert: (item: WAMessage, mode: "append" | "prepend") => void;
90
- update: (item: WAMessage) => boolean;
91
- remove: (item: WAMessage) => boolean;
92
- updateAssign: (id: string, update: Partial<WAMessage>) => boolean;
93
- clear: () => void;
94
- filter: (contain: (item: WAMessage) => boolean) => void;
95
- toJSON: () => WAMessage[];
96
- fromJSON: (newItems: WAMessage[]) => void;
97
- };
98
- };
99
- labels: ObjectRepository<Label>;
100
- labelAssociations: KeyedDB<LabelAssociation, string>;
101
- };
102
- fromJSON: (json: {
103
- chats: Chat[];
104
- contacts: {
105
- [id: string]: Contact;
106
- };
107
- messages: {
108
- [id: string]: WAMessage[];
109
- };
110
- labels: {
111
- [labelId: string]: Label;
112
- };
113
- labelAssociations: LabelAssociation[];
114
- }) => void;
115
- writeToFile: (path: string) => void;
116
- readFromFile: (path: string) => void;
117
- };
118
- export default _default;
@@ -1,13 +0,0 @@
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,10 +0,0 @@
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,103 +0,0 @@
1
- import type { proto } from '../../WAProto';
2
- import type { Contact } from './Contact';
3
- import type { MinimalMessage } from './Message';
4
- export type KeyPair = {
5
- public: Uint8Array;
6
- private: Uint8Array;
7
- };
8
- export type SignedKeyPair = {
9
- keyPair: KeyPair;
10
- signature: Uint8Array;
11
- keyId: number;
12
- timestampS?: number;
13
- };
14
- export type ProtocolAddress = {
15
- name: string;
16
- deviceId: number;
17
- };
18
- export type SignalIdentity = {
19
- identifier: ProtocolAddress;
20
- identifierKey: Uint8Array;
21
- };
22
- export type LTHashState = {
23
- version: number;
24
- hash: Buffer;
25
- indexValueMap: {
26
- [indexMacBase64: string]: {
27
- valueMac: Uint8Array | Buffer;
28
- };
29
- };
30
- };
31
- export type SignalCreds = {
32
- readonly signedIdentityKey: KeyPair;
33
- readonly signedPreKey: SignedKeyPair;
34
- readonly registrationId: number;
35
- };
36
- export type AccountSettings = {
37
- /** unarchive chats when a new message is received */
38
- unarchiveChats: boolean;
39
- /** the default mode to start new conversations with */
40
- defaultDisappearingMode?: Pick<proto.IConversation, 'ephemeralExpiration' | 'ephemeralSettingTimestamp'>;
41
- };
42
- export type AuthenticationCreds = SignalCreds & {
43
- readonly noiseKey: KeyPair;
44
- readonly pairingEphemeralKeyPair: KeyPair;
45
- advSecretKey: string;
46
- me?: Contact;
47
- account?: proto.IADVSignedDeviceIdentity;
48
- signalIdentities?: SignalIdentity[];
49
- myAppStateKeyId?: string;
50
- firstUnuploadedPreKeyId: number;
51
- nextPreKeyId: number;
52
- lastAccountSyncTimestamp?: number;
53
- platform?: string;
54
- processedHistoryMessages: MinimalMessage[];
55
- /** number of times history & app state has been synced */
56
- accountSyncCounter: number;
57
- accountSettings: AccountSettings;
58
- registered: boolean;
59
- pairingCode: string | undefined;
60
- lastPropHash: string | undefined;
61
- routingInfo: Buffer | undefined;
62
- };
63
- export type SignalDataTypeMap = {
64
- 'pre-key': KeyPair;
65
- 'session': Uint8Array;
66
- 'sender-key': Uint8Array;
67
- 'sender-key-memory': {
68
- [jid: string]: boolean;
69
- };
70
- 'app-state-sync-key': proto.Message.IAppStateSyncKeyData;
71
- 'app-state-sync-version': LTHashState;
72
- };
73
- export type SignalDataSet = {
74
- [T in keyof SignalDataTypeMap]?: {
75
- [id: string]: SignalDataTypeMap[T] | null;
76
- };
77
- };
78
- type Awaitable<T> = T | Promise<T>;
79
- export type SignalKeyStore = {
80
- get<T extends keyof SignalDataTypeMap>(type: T, ids: string[]): Awaitable<{
81
- [id: string]: SignalDataTypeMap[T];
82
- }>;
83
- set(data: SignalDataSet): Awaitable<void>;
84
- /** clear all the data in the store */
85
- clear?(): Awaitable<void>;
86
- };
87
- export type SignalKeyStoreWithTransaction = SignalKeyStore & {
88
- isInTransaction: () => boolean;
89
- transaction<T>(exec: () => Promise<T>): Promise<T>;
90
- };
91
- export type TransactionCapabilityOptions = {
92
- maxCommitRetries: number;
93
- delayBetweenTriesMs: number;
94
- };
95
- export type SignalAuthState = {
96
- creds: SignalCreds;
97
- keys: SignalKeyStore | SignalKeyStoreWithTransaction;
98
- };
99
- export type AuthenticationState = {
100
- creds: AuthenticationCreds;
101
- keys: SignalKeyStore;
102
- };
103
- export {};
@@ -1,13 +0,0 @@
1
- export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept' | 'terminate';
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
- };
@@ -1,109 +0,0 @@
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, WAMessageKey } from './Message';
7
- /** privacy settings in WhatsApp Web */
8
- export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none';
9
- export type WAPrivacyCallValue = 'all' | 'known';
10
- export type WAPrivacyMessagesValue = 'all' | 'contacts';
11
- export type WAPrivacyOnlineValue = 'all' | 'match_last_seen';
12
- export type WAPrivacyGroupAddValue = 'all' | 'contacts' | 'contact_blacklist';
13
- export type WAReadReceiptsValue = 'all' | 'none';
14
- /** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
15
- export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
16
- export declare const ALL_WA_PATCH_NAMES: readonly ["critical_block", "critical_unblock_low", "regular_high", "regular_low", "regular"];
17
- export type WAPatchName = typeof ALL_WA_PATCH_NAMES[number];
18
- export interface PresenceData {
19
- lastKnownPresence: WAPresence;
20
- lastSeen?: number;
21
- }
22
- export type BotListInfo = {
23
- jid: string;
24
- personaId: string;
25
- };
26
- export type ChatMutation = {
27
- syncAction: proto.ISyncActionData;
28
- index: string[];
29
- };
30
- export type WAPatchCreate = {
31
- syncAction: proto.ISyncActionValue;
32
- index: string[];
33
- type: WAPatchName;
34
- apiVersion: number;
35
- operation: proto.SyncdMutation.SyncdOperation;
36
- };
37
- export type Chat = proto.IConversation & {
38
- /** unix timestamp of when the last message was received in the chat */
39
- lastMessageRecvTimestamp?: number;
40
- };
41
- export type ChatUpdate = Partial<Chat & {
42
- /**
43
- * if specified in the update,
44
- * the EV buffer will check if the condition gets fulfilled before applying the update
45
- * Right now, used to determine when to release an app state sync event
46
- *
47
- * @returns true, if the update should be applied;
48
- * false if it can be discarded;
49
- * undefined if the condition is not yet fulfilled
50
- * */
51
- conditional: (bufferedData: BufferedEventData) => boolean | undefined;
52
- }>;
53
- /**
54
- * the last messages in a chat, sorted reverse-chronologically. That is, the latest message should be first in the chat
55
- * for MD modifications, the last message in the array (i.e. the earlist message) must be the last message recv in the chat
56
- * */
57
- export type LastMessageList = MinimalMessage[] | proto.SyncActionValue.ISyncActionMessageRange;
58
- export type ChatModification = {
59
- archive: boolean;
60
- lastMessages: LastMessageList;
61
- } | {
62
- pushNameSetting: string;
63
- } | {
64
- pin: boolean;
65
- } | {
66
- /** mute for duration, or provide timestamp of mute to remove*/
67
- mute: number | null;
68
- } | {
69
- clear: boolean;
70
- } | {
71
- deleteForMe: {
72
- deleteMedia: boolean;
73
- key: WAMessageKey;
74
- timestamp: number;
75
- };
76
- } | {
77
- star: {
78
- messages: {
79
- id: string;
80
- fromMe?: boolean;
81
- }[];
82
- star: boolean;
83
- };
84
- } | {
85
- markRead: boolean;
86
- lastMessages: LastMessageList;
87
- } | {
88
- delete: true;
89
- lastMessages: LastMessageList;
90
- } | {
91
- addChatLabel: ChatLabelAssociationActionBody;
92
- } | {
93
- removeChatLabel: ChatLabelAssociationActionBody;
94
- } | {
95
- addMessageLabel: MessageLabelAssociationActionBody;
96
- } | {
97
- removeMessageLabel: MessageLabelAssociationActionBody;
98
- };
99
- export type InitialReceivedChatsState = {
100
- [jid: string]: {
101
- /** the last message received from the other party */
102
- lastMsgRecvTimestamp?: number;
103
- /** the absolute last message in the chat */
104
- lastMsgTimestamp: number;
105
- };
106
- };
107
- export type InitialAppStateSyncOptions = {
108
- accountSettings: AccountSettings;
109
- };
@@ -1,23 +0,0 @@
1
- export interface Contact {
2
- /** ID either in lid or jid format **/
3
- id: string;
4
- /** ID in Lid (anonymous) format (@lid) **/
5
- lid?: string;
6
- /** ID in Phone Number format (@s.whatsapp.net) **/
7
- jid?: string;
8
- /** name of the contact, you have saved on your WA */
9
- name?: string;
10
- /** name of the contact, the contact has set on their own on WA */
11
- notify?: string;
12
- /** I have no idea */
13
- verifiedName?: string;
14
- /**
15
- * Url of the profile picture of the contact
16
- *
17
- * 'changed' => if the profile picture has changed
18
- * null => if the profile picture has not been set (default profile picture)
19
- * any other string => url of the profile picture
20
- */
21
- imgUrl?: string | null;
22
- status?: string;
23
- }