angularsockets 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 (131) hide show
  1. package/README.md +1880 -36
  2. package/WAProto/index.d.ts +50383 -0
  3. package/WAProto/index.js +37203 -11791
  4. package/WASignalGroup/GroupProtocol.js +1697 -0
  5. package/WASignalGroup/ciphertext_message.js +16 -0
  6. package/WASignalGroup/group_cipher.js +120 -0
  7. package/WASignalGroup/group_session_builder.js +46 -0
  8. package/WASignalGroup/index.js +5 -0
  9. package/WASignalGroup/keyhelper.js +21 -0
  10. package/WASignalGroup/protobufs.js +3 -0
  11. package/WASignalGroup/queue_job.js +69 -0
  12. package/WASignalGroup/sender_chain_key.js +50 -0
  13. package/WASignalGroup/sender_key_distribution_message.js +78 -0
  14. package/WASignalGroup/sender_key_message.js +92 -0
  15. package/WASignalGroup/sender_key_name.js +70 -0
  16. package/WASignalGroup/sender_key_record.js +56 -0
  17. package/WASignalGroup/sender_key_state.js +129 -0
  18. package/{lib/Signal/Group/sender-message-key.js → WASignalGroup/sender_message_key.js} +16 -6
  19. package/lib/Defaults/baileys-version.json +1 -1
  20. package/lib/Defaults/index.js +79 -101
  21. package/lib/Signal/libsignal.js +29 -51
  22. package/lib/Socket/Client/web-socket-client.js +0 -2
  23. package/lib/Socket/business.d.ts +42 -43
  24. package/lib/Socket/chats.d.ts +9 -8
  25. package/lib/Socket/chats.js +107 -21
  26. package/lib/Socket/groups.d.ts +7 -7
  27. package/lib/Socket/groups.js +24 -25
  28. package/lib/Socket/index.d.ts +51 -52
  29. package/lib/Socket/messages-recv.d.ts +34 -37
  30. package/lib/Socket/messages-recv.js +37 -175
  31. package/lib/Socket/messages-send.d.ts +16 -10
  32. package/lib/Socket/messages-send.js +540 -346
  33. package/lib/Socket/newsletter.d.ts +26 -28
  34. package/lib/Socket/newsletter.js +4 -4
  35. package/lib/Socket/registration.d.ts +49 -52
  36. package/lib/Socket/registration.js +7 -7
  37. package/lib/Socket/socket.d.ts +1 -0
  38. package/lib/Socket/socket.js +36 -23
  39. package/lib/Socket/usync.d.ts +11 -10
  40. package/lib/Store/make-cache-manager-store.d.ts +2 -1
  41. package/lib/Store/make-in-memory-store.d.ts +2 -2
  42. package/lib/Store/make-in-memory-store.js +5 -1
  43. package/lib/Store/make-ordered-dictionary.js +2 -2
  44. package/lib/Types/Auth.d.ts +0 -1
  45. package/lib/Types/Call.d.ts +1 -1
  46. package/lib/Types/Chat.d.ts +12 -7
  47. package/lib/Types/Events.d.ts +17 -2
  48. package/lib/Types/GroupMetadata.d.ts +3 -2
  49. package/lib/Types/Label.d.ts +11 -0
  50. package/lib/Types/Label.js +1 -1
  51. package/lib/Types/LabelAssociation.js +1 -1
  52. package/lib/Types/Message.d.ts +170 -10
  53. package/lib/Types/Newsletter.js +3 -3
  54. package/lib/Types/Socket.d.ts +7 -2
  55. package/lib/Types/index.d.ts +9 -0
  56. package/lib/Types/index.js +1 -1
  57. package/lib/Utils/auth-utils.js +35 -14
  58. package/lib/Utils/business.d.ts +1 -1
  59. package/lib/Utils/business.js +2 -2
  60. package/lib/Utils/chat-utils.d.ts +11 -12
  61. package/lib/Utils/chat-utils.js +52 -36
  62. package/lib/Utils/crypto.d.ts +15 -16
  63. package/lib/Utils/crypto.js +74 -26
  64. package/lib/Utils/decode-wa-message.d.ts +17 -0
  65. package/lib/Utils/decode-wa-message.js +53 -17
  66. package/lib/Utils/event-buffer.js +10 -7
  67. package/lib/Utils/generics.d.ts +13 -17
  68. package/lib/Utils/generics.js +26 -15
  69. package/lib/Utils/history.d.ts +6 -2
  70. package/lib/Utils/history.js +4 -6
  71. package/lib/Utils/logger.d.ts +1 -3
  72. package/lib/Utils/lt-hash.js +12 -12
  73. package/lib/Utils/make-mutex.d.ts +2 -2
  74. package/lib/Utils/messages-media.d.ts +25 -28
  75. package/lib/Utils/messages-media.js +47 -57
  76. package/lib/Utils/messages.js +461 -44
  77. package/lib/Utils/noise-handler.d.ts +4 -5
  78. package/lib/Utils/noise-handler.js +19 -14
  79. package/lib/Utils/process-message.d.ts +5 -5
  80. package/lib/Utils/process-message.js +75 -23
  81. package/lib/Utils/signal.d.ts +2 -1
  82. package/lib/Utils/signal.js +43 -35
  83. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -1
  84. package/lib/Utils/use-multi-file-auth-state.js +251 -36
  85. package/lib/Utils/use-single-file-auth-state.d.ts +12 -0
  86. package/lib/Utils/use-single-file-auth-state.js +75 -0
  87. package/lib/Utils/validate-connection.d.ts +1 -1
  88. package/lib/Utils/validate-connection.js +1 -1
  89. package/lib/WABinary/decode.d.ts +1 -2
  90. package/lib/WABinary/decode.js +23 -11
  91. package/lib/WABinary/encode.d.ts +1 -2
  92. package/lib/WABinary/encode.js +46 -22
  93. package/lib/WABinary/generic-utils.d.ts +2 -4
  94. package/lib/WABinary/generic-utils.js +2 -10
  95. package/lib/WABinary/jid-utils.d.ts +1 -1
  96. package/lib/WAM/BinaryInfo.d.ts +2 -11
  97. package/lib/WAM/encode.d.ts +1 -2
  98. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -3
  99. package/lib/WAUSync/USyncUser.d.ts +0 -2
  100. package/lib/index.js +0 -6
  101. package/package.json +96 -104
  102. package/engine-requirements.js +0 -10
  103. package/lib/Defaults/phonenumber-mcc.json +0 -223
  104. package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
  105. package/lib/Signal/Group/ciphertext-message.js +0 -15
  106. package/lib/Signal/Group/group-session-builder.d.ts +0 -14
  107. package/lib/Signal/Group/group-session-builder.js +0 -64
  108. package/lib/Signal/Group/group_cipher.d.ts +0 -17
  109. package/lib/Signal/Group/group_cipher.js +0 -96
  110. package/lib/Signal/Group/index.d.ts +0 -11
  111. package/lib/Signal/Group/index.js +0 -57
  112. package/lib/Signal/Group/keyhelper.d.ts +0 -10
  113. package/lib/Signal/Group/keyhelper.js +0 -55
  114. package/lib/Signal/Group/queue-job.d.ts +0 -1
  115. package/lib/Signal/Group/queue-job.js +0 -57
  116. package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
  117. package/lib/Signal/Group/sender-chain-key.js +0 -34
  118. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
  119. package/lib/Signal/Group/sender-key-distribution-message.js +0 -66
  120. package/lib/Signal/Group/sender-key-message.d.ts +0 -18
  121. package/lib/Signal/Group/sender-key-message.js +0 -69
  122. package/lib/Signal/Group/sender-key-name.d.ts +0 -17
  123. package/lib/Signal/Group/sender-key-name.js +0 -51
  124. package/lib/Signal/Group/sender-key-record.d.ts +0 -30
  125. package/lib/Signal/Group/sender-key-record.js +0 -53
  126. package/lib/Signal/Group/sender-key-state.d.ts +0 -38
  127. package/lib/Signal/Group/sender-key-state.js +0 -99
  128. package/lib/Signal/Group/sender-message-key.d.ts +0 -11
  129. package/lib/Socket/dugong.d.ts +0 -175
  130. package/lib/Socket/dugong.js +0 -342
  131. package/lib/index.d.ts +0 -12
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { Boom } from '@hapi/boom';
2
3
  import { SocketConfig } from '../Types';
3
4
  import { BinaryNode } from '../WABinary';
@@ -5,12 +6,12 @@ import { USyncQuery } from '../WAUSync';
5
6
  export declare const makeUSyncSocket: (config: SocketConfig) => {
6
7
  executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
7
8
  type: "md";
8
- ws: import("./Client").WebSocketClient;
9
+ ws: any;
9
10
  ev: import("../Types").BaileysEventEmitter & {
10
- process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
11
+ process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
11
12
  buffer(): void;
12
- createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
13
- flush(force?: boolean): boolean;
13
+ createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>;
14
+ flush(force?: boolean | undefined): boolean;
14
15
  isBuffering(): boolean;
15
16
  };
16
17
  authState: {
@@ -20,17 +21,17 @@ export declare const makeUSyncSocket: (config: SocketConfig) => {
20
21
  signalRepository: import("../Types").SignalRepository;
21
22
  user: import("../Types").Contact | undefined;
22
23
  generateMessageTag: () => string;
23
- query: (node: BinaryNode, timeoutMs?: number) => Promise<BinaryNode>;
24
- waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
24
+ query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
25
+ waitForMessage: <T_1>(msgId: string, timeoutMs?: number | undefined) => Promise<T_1>;
25
26
  waitForSocketOpen: () => Promise<void>;
26
27
  sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
27
28
  sendNode: (frame: BinaryNode) => Promise<void>;
28
- logout: (msg?: string) => Promise<void>;
29
+ logout: (msg?: string | undefined) => Promise<void>;
29
30
  end: (error: Error | undefined) => void;
30
- onUnexpectedError: (err: Error | Boom, msg: string) => void;
31
+ onUnexpectedError: (err: Error | Boom<any>, msg: string) => void;
31
32
  uploadPreKeys: (count?: number) => Promise<void>;
32
33
  uploadPreKeysToServerIfRequired: () => Promise<void>;
33
- requestPairingCode: (phoneNumber: string, customPairingCode?: string) => Promise<string>;
34
- waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
34
+ requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
35
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
35
36
  sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
36
37
  };
@@ -1,5 +1,6 @@
1
+ import { Store } from 'cache-manager';
1
2
  import { AuthenticationCreds } from '../Types';
2
- declare const makeCacheManagerAuthState: (store: Storage, sessionKey: string) => Promise<{
3
+ declare const makeCacheManagerAuthState: (store: Store, sessionKey: string) => Promise<{
3
4
  clearState: () => Promise<void>;
4
5
  saveCreds: () => Promise<void>;
5
6
  state: {
@@ -1,11 +1,11 @@
1
1
  import type KeyedDB from '@adiwajshing/keyed-db';
2
2
  import type { Comparable } from '@adiwajshing/keyed-db/lib/Types';
3
- import type { Logger } from 'pino';
4
3
  import { proto } from '../../WAProto';
5
4
  import type makeMDSocket from '../Socket';
6
5
  import type { BaileysEventEmitter, Chat, ConnectionState, Contact, GroupMetadata, PresenceData, WAMessage, WAMessageCursor, WAMessageKey } from '../Types';
7
6
  import { Label } from '../Types/Label';
8
7
  import { LabelAssociation } from '../Types/LabelAssociation';
8
+ import { ILogger } from '../Utils/logger';
9
9
  import { ObjectRepository } from './object-repository';
10
10
  type WASocket = ReturnType<typeof makeMDSocket>;
11
11
  export declare const waChatKey: (pin: boolean) => {
@@ -17,7 +17,7 @@ export declare const waLabelAssociationKey: Comparable<LabelAssociation, string>
17
17
  export type BaileysInMemoryStoreConfig = {
18
18
  chatKey?: Comparable<Chat, string>;
19
19
  labelAssociationKey?: Comparable<LabelAssociation, string>;
20
- logger?: Logger;
20
+ logger?: ILogger;
21
21
  socket?: WASocket;
22
22
  };
23
23
  declare const _default: (config: BaileysInMemoryStoreConfig) => {
@@ -74,7 +74,11 @@ exports.default = (config) => {
74
74
  ev.on('connection.update', update => {
75
75
  Object.assign(state, update);
76
76
  });
77
- ev.on('messaging-history.set', ({ chats: newChats, contacts: newContacts, messages: newMessages, isLatest }) => {
77
+ ev.on('messaging-history.set', ({ chats: newChats, contacts: newContacts, messages: newMessages, isLatest, syncType }) => {
78
+ if (syncType === WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND) {
79
+ return; // FOR NOW,
80
+ //TODO: HANDLE
81
+ }
78
82
  if (isLatest) {
79
83
  chats.clear();
80
84
  for (const id in messages) {
@@ -56,9 +56,9 @@ function makeOrderedDictionary(idGetter) {
56
56
  },
57
57
  clear: () => {
58
58
  array.splice(0, array.length);
59
- Object.keys(dict).forEach(key => {
59
+ for (const key of Object.keys(dict)) {
60
60
  delete dict[key];
61
- });
61
+ }
62
62
  },
63
63
  filter: (contain) => {
64
64
  let i = 0;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { proto } from '../../WAProto';
3
2
  import { RegistrationOptions } from '../Socket/registration';
4
3
  import type { Contact } from './Contact';
@@ -1,4 +1,4 @@
1
- export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept';
1
+ export type WACallUpdateType = 'offer' | 'ringing' | 'timeout' | 'reject' | 'accept' | 'terminate';
2
2
  export type WACallEvent = {
3
3
  chatId: string;
4
4
  from: string;
@@ -1,13 +1,16 @@
1
1
  import type { proto } from '../../WAProto';
2
2
  import type { AccountSettings } from './Auth';
3
3
  import type { BufferedEventData } from './Events';
4
+ import type { LabelActionBody } from './Label';
4
5
  import type { ChatLabelAssociationActionBody } from './LabelAssociation';
5
6
  import type { MessageLabelAssociationActionBody } from './LabelAssociation';
6
- import type { MinimalMessage } from './Message';
7
+ import type { MinimalMessage, WAMessageKey } from './Message';
7
8
  /** privacy settings in WhatsApp Web */
8
9
  export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none';
9
10
  export type WAPrivacyOnlineValue = 'all' | 'match_last_seen';
11
+ export type WAPrivacyGroupAddValue = 'all' | 'contacts' | 'contact_blacklist';
10
12
  export type WAReadReceiptsValue = 'all' | 'none';
13
+ export type WAPrivacyCallValue = 'all' | 'known';
11
14
  /** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
12
15
  export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
13
16
  export declare const ALL_WA_PATCH_NAMES: readonly ["critical_block", "critical_unblock_low", "regular_high", "regular_low", "regular"];
@@ -59,12 +62,12 @@ export type ChatModification = {
59
62
  /** mute for duration, or provide timestamp of mute to remove*/
60
63
  mute: number | null;
61
64
  } | {
62
- clear: 'all' | {
63
- messages: {
64
- id: string;
65
- fromMe?: boolean;
66
- timestamp: number;
67
- }[];
65
+ clear: boolean;
66
+ } | {
67
+ deleteForMe: {
68
+ deleteMedia: boolean;
69
+ key: WAMessageKey;
70
+ timestamp: number;
68
71
  };
69
72
  } | {
70
73
  star: {
@@ -80,6 +83,8 @@ export type ChatModification = {
80
83
  } | {
81
84
  delete: true;
82
85
  lastMessages: LastMessageList;
86
+ } | {
87
+ addLabel: LabelActionBody;
83
88
  } | {
84
89
  addChatLabel: ChatLabelAssociationActionBody;
85
90
  } | {
@@ -4,7 +4,7 @@ import { AuthenticationCreds } from './Auth';
4
4
  import { WACallEvent } from './Call';
5
5
  import { Chat, ChatUpdate, PresenceData } from './Chat';
6
6
  import { Contact } from './Contact';
7
- import { GroupMetadata, ParticipantAction } from './GroupMetadata';
7
+ import { GroupMetadata, ParticipantAction, RequestJoinAction, RequestJoinMethod } from './GroupMetadata';
8
8
  import { Label } from './Label';
9
9
  import { LabelAssociation } from './LabelAssociation';
10
10
  import { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message';
@@ -19,7 +19,10 @@ export type BaileysEventMap = {
19
19
  chats: Chat[];
20
20
  contacts: Contact[];
21
21
  messages: WAMessage[];
22
- isLatest: boolean;
22
+ isLatest?: boolean;
23
+ progress?: number | null;
24
+ syncType?: proto.HistorySync.HistorySyncType;
25
+ peerDataRequestSessionId?: string | null;
23
26
  };
24
27
  /** upsert chats */
25
28
  'chats.upsert': Chat[];
@@ -58,10 +61,12 @@ export type BaileysEventMap = {
58
61
  /**
59
62
  * add/update the given messages. If they were received while the connection was online,
60
63
  * the update will have type: "notify"
64
+ * if requestId is provided, then the messages was received from the phone due to it being unavailable
61
65
  * */
62
66
  'messages.upsert': {
63
67
  messages: WAMessage[];
64
68
  type: MessageUpsertType;
69
+ requestId?: string;
65
70
  };
66
71
  /** message was reacted to. If reaction was removed -- then "reaction.text" will be falsey */
67
72
  'messages.reaction': {
@@ -78,6 +83,13 @@ export type BaileysEventMap = {
78
83
  participants: string[];
79
84
  action: ParticipantAction;
80
85
  };
86
+ 'group.join-request': {
87
+ id: string;
88
+ author: string;
89
+ participant: string;
90
+ action: RequestJoinAction;
91
+ method: RequestJoinMethod;
92
+ };
81
93
  'blocklist.set': {
82
94
  blocklist: string[];
83
95
  };
@@ -106,6 +118,9 @@ export type BufferedEventData = {
106
118
  };
107
119
  empty: boolean;
108
120
  isLatest: boolean;
121
+ progress?: number | null;
122
+ syncType?: proto.HistorySync.HistorySyncType;
123
+ peerDataRequestSessionId?: string;
109
124
  };
110
125
  chatUpserts: {
111
126
  [jid: string]: Chat;
@@ -4,12 +4,13 @@ export type GroupParticipant = (Contact & {
4
4
  isSuperAdmin?: boolean;
5
5
  admin?: 'admin' | 'superadmin' | null;
6
6
  });
7
- export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote';
7
+ export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' | 'modify';
8
+ export type RequestJoinAction = 'created' | 'revoked' | 'rejected';
9
+ export type RequestJoinMethod = 'invite_link' | 'linked_group_join' | 'non_admin_add' | undefined;
8
10
  export interface GroupMetadata {
9
11
  id: string;
10
12
  owner: string | undefined;
11
13
  subject: string;
12
- addressingMode: "pn" | "lid";
13
14
  /** group subject owner */
14
15
  subjectOwner?: string;
15
16
  /** group subject modification date */
@@ -10,6 +10,17 @@ export interface Label {
10
10
  /** WhatsApp has 5 predefined labels (New customer, New order & etc) */
11
11
  predefinedId?: string;
12
12
  }
13
+ export interface LabelActionBody {
14
+ id: string;
15
+ /** Label name */
16
+ name?: string;
17
+ /** Label color ID */
18
+ color?: number;
19
+ /** Is label has been deleted */
20
+ deleted?: boolean;
21
+ /** WhatsApp has 5 predefined labels (New customer, New order & etc) */
22
+ predefinedId?: number;
23
+ }
13
24
  /** WhatsApp has 20 predefined colors */
14
25
  export declare enum LabelColor {
15
26
  Color1 = 0,
@@ -24,4 +24,4 @@ var LabelColor;
24
24
  LabelColor[LabelColor["Color18"] = 17] = "Color18";
25
25
  LabelColor[LabelColor["Color19"] = 18] = "Color19";
26
26
  LabelColor[LabelColor["Color20"] = 19] = "Color20";
27
- })(LabelColor = exports.LabelColor || (exports.LabelColor = {}));
27
+ })(LabelColor || (exports.LabelColor = LabelColor = {}));
@@ -6,4 +6,4 @@ var LabelAssociationType;
6
6
  (function (LabelAssociationType) {
7
7
  LabelAssociationType["Chat"] = "label_jid";
8
8
  LabelAssociationType["Message"] = "label_message";
9
- })(LabelAssociationType = exports.LabelAssociationType || (exports.LabelAssociationType = {}));
9
+ })(LabelAssociationType || (exports.LabelAssociationType = LabelAssociationType = {}));
@@ -19,6 +19,7 @@ export type WAMessageKey = proto.IMessageKey;
19
19
  export type WATextMessage = proto.Message.IExtendedTextMessage;
20
20
  export type WAContextInfo = proto.IContextInfo;
21
21
  export type WALocationMessage = proto.Message.ILocationMessage;
22
+ export type WALiveLocationMessage = proto.Message.ILiveLocationMessage;
22
23
  export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
23
24
  export import WAMessageStubType = proto.WebMessageInfo.StubType;
24
25
  export import WAMessageStatus = proto.WebMessageInfo.Status;
@@ -27,6 +28,7 @@ export type WAMediaUpload = Buffer | {
27
28
  } | {
28
29
  stream: Readable;
29
30
  };
31
+ export import Annotations = proto.IInteractiveAnnotation;
30
32
  /** Set of message types that are supported by the library */
31
33
  export type MessageType = keyof proto.Message;
32
34
  export type DownloadableMessage = {
@@ -53,6 +55,19 @@ export interface WAUrlInfo {
53
55
  highQualityThumbnail?: proto.Message.IImageMessage;
54
56
  originalThumbnailUrl?: string;
55
57
  }
58
+ export interface Media {
59
+ image?: WAMediaUpload;
60
+ video?: WAMediaUpload;
61
+ }
62
+ export interface Carousel {
63
+ image?: WAMediaUpload;
64
+ video?: WAMediaUpload;
65
+ product?: WASendableProduct;
66
+ title?: string;
67
+ caption?: string;
68
+ footer?: string;
69
+ buttons?: proto.Message.InteractiveMessage.NativeFlowMessage.NativeFlowButton[];
70
+ }
56
71
  type Mentionable = {
57
72
  /** list of jids that are mentioned in the accompanying text */
58
73
  mentions?: string[];
@@ -73,6 +88,35 @@ type Templatable = {
73
88
  templateButtons?: proto.IHydratedTemplateButton[];
74
89
  footer?: string;
75
90
  };
91
+ type Interactiveable = {
92
+ /** add buttons to the message (conflicts with normal buttons)*/
93
+ interactiveButtons?: proto.Message.InteractiveMessage.NativeFlowMessage.NativeFlowButton[];
94
+ title?: string;
95
+ subtitle?: string;
96
+ media?: boolean;
97
+ };
98
+ type Shopable = {
99
+ shop?: proto.Message.InteractiveMessage.ShopMessage.Surface;
100
+ id?: string;
101
+ title?: string;
102
+ subtitle?: string;
103
+ media?: boolean;
104
+ };
105
+ type Collectionable = {
106
+ collection?: {
107
+ bizJid?: string;
108
+ id?: string;
109
+ version?: number;
110
+ };
111
+ title?: string;
112
+ subtitle?: string;
113
+ media?: boolean;
114
+ };
115
+ type Cardsable = {
116
+ cards?: Carousel[];
117
+ title?: string;
118
+ subtitle?: string;
119
+ };
76
120
  type Editable = {
77
121
  edit?: WAMessageKey;
78
122
  };
@@ -81,7 +125,7 @@ type Listable = {
81
125
  sections?: proto.Message.ListMessage.ISection[];
82
126
  /** Title of a List Message only */
83
127
  title?: string;
84
- /** Text of the bnutton on the list (required) */
128
+ /** Text of the button on the list (required) */
85
129
  buttonText?: string;
86
130
  };
87
131
  type WithDimensions = {
@@ -94,6 +138,12 @@ export type PollMessageOptions = {
94
138
  values: string[];
95
139
  /** 32 byte message secret to encrypt poll selections */
96
140
  messageSecret?: Uint8Array;
141
+ toAnnouncementGroup?: boolean;
142
+ };
143
+ export type PollResultMessage = {
144
+ name: string;
145
+ votes: proto.Message.PollResultSnapshotMessage.PollVote[];
146
+ messageSecret?: Uint8Array;
97
147
  };
98
148
  type SharePhoneNumber = {
99
149
  sharePhoneNumber: boolean;
@@ -101,48 +151,123 @@ type SharePhoneNumber = {
101
151
  type RequestPhoneNumber = {
102
152
  requestPhoneNumber: boolean;
103
153
  };
154
+ export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
155
+ productImage: WAMediaUpload;
156
+ };
104
157
  export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
105
158
  export type AnyMediaMessageContent = (({
106
159
  image: WAMediaUpload;
107
160
  caption?: string;
108
161
  jpegThumbnail?: string;
109
- } & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | ({
162
+ annotations?: Annotations;
163
+ } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Collectionable & Cardsable & WithDimensions) | ({
110
164
  video: WAMediaUpload;
111
165
  caption?: string;
112
166
  gifPlayback?: boolean;
113
167
  jpegThumbnail?: string;
114
168
  /** if set to true, will send as a `video note` */
115
169
  ptv?: boolean;
116
- } & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | {
170
+ annotations?: Annotations;
171
+ } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Collectionable & Cardsable & WithDimensions) | {
117
172
  audio: WAMediaUpload;
118
173
  /** if set to true, will send as a `voice note` */
119
174
  ptt?: boolean;
120
175
  /** optionally tell the duration of the audio */
121
176
  seconds?: number;
177
+ annotations?: Annotations;
122
178
  } | ({
123
179
  sticker: WAMediaUpload;
124
180
  isAnimated?: boolean;
181
+ annotations?: Annotations;
125
182
  } & WithDimensions) | ({
126
183
  document: WAMediaUpload;
127
184
  mimetype: string;
128
185
  fileName?: string;
129
186
  caption?: string;
130
- } & Contextable & Buttonable & Templatable)) & {
187
+ annotations?: Annotations;
188
+ } & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Collectionable & Cardsable)) & {
131
189
  mimetype?: string;
132
190
  } & Editable;
133
191
  export type ButtonReplyInfo = {
134
192
  displayText: string;
135
193
  id: string;
136
194
  index: number;
195
+ text: string;
196
+ nativeFlow: proto.Message.InteractiveResponseMessage.NativeFlowResponseMessage;
137
197
  };
138
- export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
139
- productImage: WAMediaUpload;
198
+ export type GroupInviteInfo = {
199
+ inviteCode: string;
200
+ inviteExpiration: number;
201
+ text: string;
202
+ jid: string;
203
+ subject: string;
204
+ thumbnail: Buffer;
205
+ };
206
+ export type PinInChatInfo = {
207
+ key: WAMessageKey;
208
+ type?: number;
209
+ time?: number;
210
+ };
211
+ export type KeepInChatInfo = {
212
+ key: WAMessageKey;
213
+ type?: number;
214
+ time?: number;
215
+ };
216
+ export type CallCreationInfo = {
217
+ time?: number;
218
+ title?: string;
219
+ type?: number;
220
+ };
221
+ export type PaymentInviteInfo = {
222
+ type?: number;
223
+ expiry?: number;
224
+ };
225
+ export type RequestPaymentInfo = {
226
+ expiry: number;
227
+ amount: number;
228
+ currency: string;
229
+ from: string;
230
+ note?: string;
231
+ sticker?: WAMediaUpload;
232
+ background: string;
233
+ /** add contextInfo to the message */
234
+ contextInfo?: proto.IContextInfo;
235
+ };
236
+ export type EventsInfo = {
237
+ isCanceled?: boolean;
238
+ name: string;
239
+ description: string;
240
+ joinLink?: string;
241
+ startTime?: number;
242
+ messageSecret?: Uint8Array;
243
+ };
244
+ export type AdminInviteInfo = {
245
+ inviteExpiration: number;
246
+ text: string;
247
+ jid: string;
248
+ subject: string;
249
+ thumbnail: Buffer;
250
+ };
251
+ export type OrderInfo = {
252
+ id: number;
253
+ thumbnail: string;
254
+ itemCount: number;
255
+ status: number;
256
+ surface: number;
257
+ title: string;
258
+ text: string;
259
+ seller: string;
260
+ token: string;
261
+ amount: number;
262
+ currency: string;
140
263
  };
141
264
  export type AnyRegularMessageContent = (({
142
265
  text: string;
143
266
  linkPreview?: WAUrlInfo | null;
144
- } & Mentionable & Contextable & Buttonable & Templatable & Listable & Editable) | AnyMediaMessageContent | ({
267
+ } & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Collectionable & Cardsable & Listable & Editable) | AnyMediaMessageContent | ({
145
268
  poll: PollMessageOptions;
269
+ } | {
270
+ pollResult: PollResultMessage;
146
271
  } & Mentionable & Contextable & Buttonable & Templatable & Editable) | {
147
272
  contacts: {
148
273
  displayName?: string;
@@ -150,19 +275,49 @@ export type AnyRegularMessageContent = (({
150
275
  };
151
276
  } | {
152
277
  location: WALocationMessage;
278
+ } | {
279
+ liveLocation: WALiveLocationMessage;
153
280
  } | {
154
281
  react: proto.Message.IReactionMessage;
155
282
  } | {
156
283
  buttonReply: ButtonReplyInfo;
157
- type: 'template' | 'plain';
284
+ type: 'template' | 'plain' | 'interactive';
158
285
  } | {
159
- listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
286
+ groupInvite: GroupInviteInfo;
287
+ } | {
288
+ pin: WAMessageKey;
289
+ type: proto.PinInChat.Type;
290
+ /**
291
+ * 24 hours, 7 days, 30 days
292
+ */
293
+ time?: 86400 | 604800 | 2592000;
294
+ } | {
295
+ keep: WAMessageKey;
296
+ type: number;
297
+ /**
298
+ * 24 hours, 7 days, 90 days
299
+ */
300
+ time?: 86400 | 604800 | 7776000;
301
+ } | {
302
+ paymentInvite: PaymentInviteInfo;
303
+ } | {
304
+ requestPayment: RequestPaymentInfo;
305
+ } | {
306
+ event: EventsInfo;
160
307
  } | {
308
+ order: OrderInfo;
309
+ } | {
310
+ call: CallCreationInfo;
311
+ } | {
312
+ inviteAdmin: AdminInviteInfo;
313
+ } | {
314
+ listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
315
+ } | ({
161
316
  product: WASendableProduct;
162
317
  businessOwnerJid?: string;
163
318
  body?: string;
164
319
  footer?: string;
165
- } | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
320
+ } & Mentionable & Contextable & Interactiveable & Shopable & Collectionable & Cardsable & WithDimensions) | SharePhoneNumber | RequestPhoneNumber) & ViewOnce;
166
321
  export type AnyMessageContent = AnyRegularMessageContent | {
167
322
  forward: WAMessage;
168
323
  force?: boolean;
@@ -213,6 +368,8 @@ export type MiscMessageGenerationOptions = MinimalRelayOptions & {
213
368
  font?: number;
214
369
  /** if it is broadcast */
215
370
  broadcast?: boolean;
371
+ /** delay of message time */
372
+ delay?: number;
216
373
  };
217
374
  export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
218
375
  userJid: string;
@@ -236,6 +393,8 @@ export type MediaGenerationOptions = {
236
393
  mediaCache?: CacheStore;
237
394
  mediaUploadTimeoutMs?: number;
238
395
  options?: AxiosRequestConfig;
396
+ /** the message you want to quote */
397
+ quoted?: WAMessage;
239
398
  backgroundColor?: string;
240
399
  font?: number;
241
400
  /** The message is for newsletter? */
@@ -243,6 +402,7 @@ export type MediaGenerationOptions = {
243
402
  };
244
403
  export type MessageContentGenerationOptions = MediaGenerationOptions & {
245
404
  getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
405
+ getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>;
246
406
  };
247
407
  export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
248
408
  /**
@@ -6,7 +6,7 @@ var MexOperations;
6
6
  MexOperations["PROMOTE"] = "NotificationNewsletterAdminPromote";
7
7
  MexOperations["DEMOTE"] = "NotificationNewsletterAdminDemote";
8
8
  MexOperations["UPDATE"] = "NotificationNewsletterUpdate";
9
- })(MexOperations = exports.MexOperations || (exports.MexOperations = {}));
9
+ })(MexOperations || (exports.MexOperations = MexOperations = {}));
10
10
  var XWAPaths;
11
11
  (function (XWAPaths) {
12
12
  XWAPaths["PROMOTE"] = "xwa2_notify_newsletter_admin_promote";
@@ -15,7 +15,7 @@ var XWAPaths;
15
15
  XWAPaths["CREATE"] = "xwa2_newsletter_create";
16
16
  XWAPaths["NEWSLETTER"] = "xwa2_newsletter";
17
17
  XWAPaths["METADATA_UPDATE"] = "xwa2_notify_newsletter_on_metadata_update";
18
- })(XWAPaths = exports.XWAPaths || (exports.XWAPaths = {}));
18
+ })(XWAPaths || (exports.XWAPaths = XWAPaths = {}));
19
19
  var QueryIds;
20
20
  (function (QueryIds) {
21
21
  QueryIds["JOB_MUTATION"] = "7150902998257522";
@@ -29,4 +29,4 @@ var QueryIds;
29
29
  QueryIds["CHANGE_OWNER"] = "7341777602580933";
30
30
  QueryIds["DELETE"] = "8316537688363079";
31
31
  QueryIds["DEMOTE"] = "6551828931592903";
32
- })(QueryIds = exports.QueryIds || (exports.QueryIds = {}));
32
+ })(QueryIds || (exports.QueryIds = QueryIds = {}));
@@ -1,11 +1,10 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { AxiosRequestConfig } from 'axios';
4
2
  import type { Agent } from 'https';
5
3
  import type { Logger } from 'pino';
6
4
  import type { URL } from 'url';
7
5
  import { proto } from '../../WAProto';
8
6
  import { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth';
7
+ import { GroupMetadata } from './GroupMetadata';
9
8
  import { MediaConnInfo } from './Message';
10
9
  import { SignalRepository } from './Signal';
11
10
  export type WAVersion = [number, number, number];
@@ -61,6 +60,8 @@ export type SocketConfig = {
61
60
  transactionOpts: TransactionCapabilityOptions;
62
61
  /** marks the client as online whenever the socket successfully connects */
63
62
  markOnlineOnConnect: boolean;
63
+ /** alphanumeric country code (USA -> US) for the number used */
64
+ countryCode: string;
64
65
  /** provide a cache to store media, so does not have to be re-uploaded */
65
66
  mediaCache?: CacheStore;
66
67
  /**
@@ -71,6 +72,8 @@ export type SocketConfig = {
71
72
  userDevicesCache?: CacheStore;
72
73
  /** cache to store call offers */
73
74
  callOfferCache?: CacheStore;
75
+ /** cache to track placeholder resends */
76
+ placeholderResendCache?: CacheStore;
74
77
  /** width for link preview images */
75
78
  linkPreviewImageThumbnailWidth: number;
76
79
  /** Should Baileys ask the phone for full history, will be received async */
@@ -105,6 +108,8 @@ export type SocketConfig = {
105
108
  * (solves the "this message can take a while" issue) can be retried
106
109
  * */
107
110
  getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>;
111
+ /** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
112
+ cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>;
108
113
  makeSignalRepository: (auth: SignalAuthState) => SignalRepository;
109
114
  /** Socket passthrough */
110
115
  socket?: any;
@@ -15,6 +15,15 @@ import { SocketConfig } from './Socket';
15
15
  export type UserFacingSocketConfig = Partial<SocketConfig> & {
16
16
  auth: AuthenticationState;
17
17
  };
18
+ export type BrowsersMap = {
19
+ ubuntu(browser: string): [string, string, string];
20
+ macOS(browser: string): [string, string, string];
21
+ baileys(browser: string): [string, string, string];
22
+ windows(browser: string): [string, string, string];
23
+ iOS(browser: string): [string, string, string];
24
+ linux(browser: string): [string, string, string];
25
+ appropriate(browser: string): [string, string, string];
26
+ };
18
27
  export declare enum DisconnectReason {
19
28
  connectionClosed = 428,
20
29
  connectionLost = 408,
@@ -39,4 +39,4 @@ var DisconnectReason;
39
39
  DisconnectReason[DisconnectReason["multideviceMismatch"] = 411] = "multideviceMismatch";
40
40
  DisconnectReason[DisconnectReason["forbidden"] = 403] = "forbidden";
41
41
  DisconnectReason[DisconnectReason["unavailableService"] = 503] = "unavailableService";
42
- })(DisconnectReason = exports.DisconnectReason || (exports.DisconnectReason = {}));
42
+ })(DisconnectReason || (exports.DisconnectReason = DisconnectReason = {}));