angularsockets 1.0.3 → 1.4.1
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.
- package/LICENSE +21 -0
- package/README.MD +170 -0
- package/README.md +163 -1813
- package/WAProto/GenerateStatics.sh +4 -0
- package/WAProto/WAProto.proto +4775 -0
- package/WAProto/index.d.ts +4798 -124
- package/WAProto/index.js +14270 -302
- package/WAProto/index.ts.ts +53473 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +4 -6
- package/lib/Defaults/index.js +4 -6
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.d.ts +14 -0
- package/lib/Signal/Group/group-session-builder.js +64 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.js +96 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/index.js +57 -0
- package/lib/Signal/Group/keyhelper.d.ts +10 -0
- package/lib/Signal/Group/keyhelper.js +55 -0
- package/lib/Signal/Group/queue-job.d.ts +1 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-chain-key.js +34 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-message.js +69 -0
- package/lib/Signal/Group/sender-key-name.d.ts +17 -0
- package/lib/Signal/Group/sender-key-name.js +51 -0
- package/lib/Signal/Group/sender-key-record.d.ts +30 -0
- package/lib/Signal/Group/sender-key-record.js +53 -0
- package/lib/Signal/Group/sender-key-state.d.ts +38 -0
- package/lib/Signal/Group/sender-key-state.js +99 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/{WASignalGroup/sender_message_key.js → lib/Signal/Group/sender-message-key.js} +6 -16
- package/lib/Signal/libsignal.js +51 -29
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +2 -3
- package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +1 -2
- package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +2 -1
- package/lib/Socket/Client/{web-socket-client.js → websocket.js} +54 -5
- package/lib/Socket/RHandler.d.ts +416 -0
- package/lib/Socket/RHandler.js +530 -0
- package/lib/Socket/business.d.ts +39 -37
- package/lib/Socket/chats.d.ts +36 -23
- package/lib/Socket/chats.js +74 -116
- package/lib/Socket/groups.d.ts +42 -33
- package/lib/Socket/groups.js +26 -9
- package/lib/Socket/index.d.ts +39 -39
- package/lib/Socket/index.js +2 -2
- package/lib/Socket/messages-recv.d.ts +37 -34
- package/lib/Socket/messages-recv.js +111 -29
- package/lib/Socket/messages-send.d.ts +50 -53
- package/lib/Socket/messages-send.js +213 -397
- package/lib/Socket/newsletter.d.ts +25 -21
- package/lib/Socket/newsletter.js +92 -25
- package/lib/Socket/socket.d.ts +10 -11
- package/lib/Socket/socket.js +34 -23
- package/lib/Socket/usync.d.ts +11 -12
- package/lib/Store/index.d.ts +1 -2
- package/lib/Store/index.js +1 -3
- package/lib/Store/make-in-memory-store.d.ts +22 -22
- package/lib/Store/make-in-memory-store.js +21 -13
- package/lib/Store/make-ordered-dictionary.d.ts +1 -1
- package/lib/Types/Auth.d.ts +0 -6
- package/lib/Types/Chat.d.ts +6 -4
- package/lib/Types/Contact.d.ts +5 -1
- package/lib/Types/Events.d.ts +27 -0
- package/lib/Types/GroupMetadata.d.ts +8 -0
- package/lib/Types/Label.d.ts +0 -11
- package/lib/Types/Message.d.ts +59 -90
- package/lib/Types/Message.js +0 -2
- package/lib/Types/Newsletter.d.ts +97 -86
- package/lib/Types/Newsletter.js +38 -32
- package/lib/Types/Socket.d.ts +10 -7
- package/lib/Types/index.d.ts +1 -3
- package/lib/Types/index.js +1 -1
- package/lib/Utils/audioToBuffer.js +29 -0
- package/lib/Utils/auth-utils.d.ts +3 -3
- package/lib/Utils/auth-utils.js +13 -41
- package/lib/Utils/business.d.ts +1 -1
- package/lib/Utils/chat-utils.d.ts +12 -12
- package/lib/Utils/chat-utils.js +4 -19
- package/lib/Utils/crypto.d.ts +15 -15
- package/lib/Utils/crypto.js +6 -12
- package/lib/Utils/decode-wa-message.d.ts +5 -6
- package/lib/Utils/decode-wa-message.js +28 -55
- package/lib/Utils/event-buffer.d.ts +2 -2
- package/lib/Utils/event-buffer.js +2 -1
- package/lib/Utils/generics.d.ts +12 -11
- package/lib/Utils/generics.js +64 -38
- package/lib/Utils/history.d.ts +2 -2
- package/lib/Utils/history.js +1 -1
- package/lib/Utils/index.d.ts +2 -0
- package/lib/Utils/index.js +3 -0
- package/lib/Utils/link-preview.d.ts +2 -2
- package/lib/Utils/link-preview.js +34 -1
- package/lib/Utils/logger.d.ts +10 -1
- package/lib/Utils/lt-hash.d.ts +2 -2
- package/lib/Utils/lt-hash.js +6 -6
- package/lib/Utils/messages-media.d.ts +40 -29
- package/lib/Utils/messages-media.js +276 -110
- package/lib/Utils/messages.d.ts +8 -10
- package/lib/Utils/messages.js +126 -317
- package/lib/Utils/noise-handler.d.ts +10 -11
- package/lib/Utils/noise-handler.js +3 -13
- package/lib/Utils/process-message.d.ts +3 -2
- package/lib/Utils/process-message.js +17 -5
- package/lib/Utils/signal.js +2 -8
- package/lib/Utils/streamToBuffer.js +15 -0
- package/lib/Utils/use-multi-file-auth-state.js +72 -242
- package/lib/Utils/validate-connection.d.ts +2 -3
- package/lib/Utils/validate-connection.js +19 -51
- package/lib/WABinary/constants.d.ts +4 -4
- package/lib/WABinary/constants.js +1276 -13
- package/lib/WABinary/decode.d.ts +2 -2
- package/lib/WABinary/decode.js +3 -2
- package/lib/WABinary/encode.js +5 -7
- package/lib/WABinary/generic-utils.d.ts +2 -2
- package/lib/WABinary/jid-utils.d.ts +9 -4
- package/lib/WABinary/jid-utils.js +26 -5
- package/lib/WABinary/jid-utils.js.bak +83 -0
- package/lib/WAM/encode.d.ts +1 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -3
- package/lib/WAUSync/USyncUser.d.ts +2 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +48 -4
- package/lib/index.js.bak +56 -0
- package/package.json +43 -35
- package/WASignalGroup/GroupProtocol.js +0 -1697
- package/WASignalGroup/ciphertext_message.js +0 -16
- package/WASignalGroup/group_cipher.js +0 -120
- package/WASignalGroup/group_session_builder.js +0 -46
- package/WASignalGroup/index.js +0 -5
- package/WASignalGroup/keyhelper.js +0 -21
- package/WASignalGroup/protobufs.js +0 -3
- package/WASignalGroup/queue_job.js +0 -69
- package/WASignalGroup/sender_chain_key.js +0 -50
- package/WASignalGroup/sender_key_distribution_message.js +0 -78
- package/WASignalGroup/sender_key_message.js +0 -92
- package/WASignalGroup/sender_key_name.js +0 -70
- package/WASignalGroup/sender_key_record.js +0 -56
- package/WASignalGroup/sender_key_state.js +0 -129
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/registration.d.ts +0 -264
- package/lib/Socket/registration.js +0 -166
- package/lib/Store/make-cache-manager-store.d.ts +0 -14
- package/lib/Store/make-cache-manager-store.js +0 -83
- package/lib/Utils/use-single-file-auth-state.d.ts +0 -12
- package/lib/Utils/use-single-file-auth-state.js +0 -75
- /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
|
@@ -191,16 +191,14 @@ exports.default = (config) => {
|
|
|
191
191
|
const jid = (0, WABinary_1.jidNormalizedUser)(msg.key.remoteJid);
|
|
192
192
|
const list = assertMessageList(jid);
|
|
193
193
|
list.upsert(msg, 'append');
|
|
194
|
-
if (type === 'notify') {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
]);
|
|
203
|
-
}
|
|
194
|
+
if (type === 'notify' && !chats.get(jid)) {
|
|
195
|
+
ev.emit('chats.upsert', [
|
|
196
|
+
{
|
|
197
|
+
id: jid,
|
|
198
|
+
conversationTimestamp: (0, Utils_1.toNumber)(msg.messageTimestamp),
|
|
199
|
+
unreadCount: 1
|
|
200
|
+
}
|
|
201
|
+
]);
|
|
204
202
|
}
|
|
205
203
|
}
|
|
206
204
|
break;
|
|
@@ -422,9 +420,19 @@ exports.default = (config) => {
|
|
|
422
420
|
const { readFileSync, existsSync } = require('fs');
|
|
423
421
|
if (existsSync(path)) {
|
|
424
422
|
logger.debug({ path }, 'reading from file');
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
423
|
+
try {
|
|
424
|
+
const jsonStr = readFileSync(path, { encoding: 'utf-8' });
|
|
425
|
+
if (jsonStr.trim().length) {
|
|
426
|
+
const json = JSON.parse(jsonStr);
|
|
427
|
+
fromJSON(json);
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
logger.warn({ path }, 'skipping empty json file');
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
catch (err) {
|
|
434
|
+
logger.warn({ path, err }, 'failed to parse json from file');
|
|
435
|
+
}
|
|
428
436
|
}
|
|
429
437
|
}
|
|
430
438
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare function makeOrderedDictionary<T>(idGetter: (item: T) => string): {
|
|
2
2
|
array: T[];
|
|
3
3
|
get: (id: string) => T | undefined;
|
|
4
|
-
upsert: (item: T, mode:
|
|
4
|
+
upsert: (item: T, mode: "append" | "prepend") => void;
|
|
5
5
|
update: (item: T) => boolean;
|
|
6
6
|
remove: (item: T) => boolean;
|
|
7
7
|
updateAssign: (id: string, update: Partial<T>) => boolean;
|
package/lib/Types/Auth.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { proto } from '../../WAProto';
|
|
2
|
-
import { RegistrationOptions } from '../Socket/registration';
|
|
3
2
|
import type { Contact } from './Contact';
|
|
4
3
|
import type { MinimalMessage } from './Message';
|
|
5
4
|
export type KeyPair = {
|
|
@@ -56,12 +55,7 @@ export type AuthenticationCreds = SignalCreds & {
|
|
|
56
55
|
/** number of times history & app state has been synced */
|
|
57
56
|
accountSyncCounter: number;
|
|
58
57
|
accountSettings: AccountSettings;
|
|
59
|
-
deviceId: string;
|
|
60
|
-
phoneId: string;
|
|
61
|
-
identityId: Buffer;
|
|
62
58
|
registered: boolean;
|
|
63
|
-
backupToken: Buffer;
|
|
64
|
-
registration: RegistrationOptions;
|
|
65
59
|
pairingCode: string | undefined;
|
|
66
60
|
lastPropHash: string | undefined;
|
|
67
61
|
routingInfo: Buffer | undefined;
|
package/lib/Types/Chat.d.ts
CHANGED
|
@@ -1,16 +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';
|
|
5
4
|
import type { ChatLabelAssociationActionBody } from './LabelAssociation';
|
|
6
5
|
import type { MessageLabelAssociationActionBody } from './LabelAssociation';
|
|
7
6
|
import type { MinimalMessage, WAMessageKey } from './Message';
|
|
8
7
|
/** privacy settings in WhatsApp Web */
|
|
9
8
|
export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none';
|
|
9
|
+
export type WAPrivacyCallValue = 'all' | 'known';
|
|
10
|
+
export type WAPrivacyMessagesValue = 'all' | 'contacts';
|
|
10
11
|
export type WAPrivacyOnlineValue = 'all' | 'match_last_seen';
|
|
11
12
|
export type WAPrivacyGroupAddValue = 'all' | 'contacts' | 'contact_blacklist';
|
|
12
13
|
export type WAReadReceiptsValue = 'all' | 'none';
|
|
13
|
-
export type WAPrivacyCallValue = 'all' | 'known';
|
|
14
14
|
/** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
|
|
15
15
|
export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
|
|
16
16
|
export declare const ALL_WA_PATCH_NAMES: readonly ["critical_block", "critical_unblock_low", "regular_high", "regular_low", "regular"];
|
|
@@ -19,6 +19,10 @@ export interface PresenceData {
|
|
|
19
19
|
lastKnownPresence: WAPresence;
|
|
20
20
|
lastSeen?: number;
|
|
21
21
|
}
|
|
22
|
+
export type BotListInfo = {
|
|
23
|
+
jid: string;
|
|
24
|
+
personaId: string;
|
|
25
|
+
};
|
|
22
26
|
export type ChatMutation = {
|
|
23
27
|
syncAction: proto.ISyncActionData;
|
|
24
28
|
index: string[];
|
|
@@ -83,8 +87,6 @@ export type ChatModification = {
|
|
|
83
87
|
} | {
|
|
84
88
|
delete: true;
|
|
85
89
|
lastMessages: LastMessageList;
|
|
86
|
-
} | {
|
|
87
|
-
addLabel: LabelActionBody;
|
|
88
90
|
} | {
|
|
89
91
|
addChatLabel: ChatLabelAssociationActionBody;
|
|
90
92
|
} | {
|
package/lib/Types/Contact.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export interface Contact {
|
|
2
|
+
/** ID either in lid or jid format **/
|
|
2
3
|
id: string;
|
|
4
|
+
/** ID in Lid (anonymous) format (@lid) **/
|
|
3
5
|
lid?: string;
|
|
6
|
+
/** ID in Phone Number format (@s.whatsapp.net) **/
|
|
7
|
+
jid?: string;
|
|
4
8
|
/** name of the contact, you have saved on your WA */
|
|
5
9
|
name?: string;
|
|
6
10
|
/** name of the contact, the contact has set on their own on WA */
|
|
@@ -14,6 +18,6 @@ export interface Contact {
|
|
|
14
18
|
* null => if the profile picture has not been set (default profile picture)
|
|
15
19
|
* any other string => url of the profile picture
|
|
16
20
|
*/
|
|
17
|
-
imgUrl?: string | null
|
|
21
|
+
imgUrl?: string | null;
|
|
18
22
|
status?: string;
|
|
19
23
|
}
|
package/lib/Types/Events.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { Label } from './Label';
|
|
|
9
9
|
import { LabelAssociation } from './LabelAssociation';
|
|
10
10
|
import { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message';
|
|
11
11
|
import { ConnectionState } from './State';
|
|
12
|
+
import { NewsletterSettingsUpdate, SubscriberAction, NewsletterViewRole } from './Newsletter';
|
|
12
13
|
export type BaileysEventMap = {
|
|
13
14
|
/** connection state has been updated -- WS closed, opened, connecting etc. */
|
|
14
15
|
'connection.update': Partial<ConnectionState>;
|
|
@@ -90,6 +91,32 @@ export type BaileysEventMap = {
|
|
|
90
91
|
action: RequestJoinAction;
|
|
91
92
|
method: RequestJoinMethod;
|
|
92
93
|
};
|
|
94
|
+
'newsletter.reaction': {
|
|
95
|
+
id: string;
|
|
96
|
+
server_id: string;
|
|
97
|
+
reaction: {
|
|
98
|
+
code?: string;
|
|
99
|
+
count?: number;
|
|
100
|
+
removed?: boolean;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
'newsletter.view': {
|
|
104
|
+
id: string;
|
|
105
|
+
server_id: string;
|
|
106
|
+
count: number;
|
|
107
|
+
};
|
|
108
|
+
/**don't handles subscribe/unsubscribe actions */
|
|
109
|
+
'newsletter-participants.update': {
|
|
110
|
+
id: string;
|
|
111
|
+
author: string;
|
|
112
|
+
user: string;
|
|
113
|
+
new_role: NewsletterViewRole;
|
|
114
|
+
action: SubscriberAction;
|
|
115
|
+
};
|
|
116
|
+
'newsletter-settings.update': {
|
|
117
|
+
id: string;
|
|
118
|
+
update: NewsletterSettingsUpdate;
|
|
119
|
+
};
|
|
93
120
|
'blocklist.set': {
|
|
94
121
|
blocklist: string[];
|
|
95
122
|
};
|
|
@@ -3,22 +3,30 @@ export type GroupParticipant = (Contact & {
|
|
|
3
3
|
isAdmin?: boolean;
|
|
4
4
|
isSuperAdmin?: boolean;
|
|
5
5
|
admin?: 'admin' | 'superadmin' | null;
|
|
6
|
+
jid?: string;
|
|
7
|
+
lid?: string;
|
|
6
8
|
});
|
|
7
9
|
export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' | 'modify';
|
|
8
10
|
export type RequestJoinAction = 'created' | 'revoked' | 'rejected';
|
|
9
11
|
export type RequestJoinMethod = 'invite_link' | 'linked_group_join' | 'non_admin_add' | undefined;
|
|
10
12
|
export interface GroupMetadata {
|
|
11
13
|
id: string;
|
|
14
|
+
/** group uses 'lid' or 'pn' to send messages */
|
|
15
|
+
addressingMode: 'pn' | 'lid';
|
|
12
16
|
owner: string | undefined;
|
|
17
|
+
ownerLid?: string | undefined;
|
|
13
18
|
subject: string;
|
|
14
19
|
/** group subject owner */
|
|
15
20
|
subjectOwner?: string;
|
|
21
|
+
subjectOwnerLid?: string;
|
|
16
22
|
/** group subject modification date */
|
|
17
23
|
subjectTime?: number;
|
|
18
24
|
creation?: number;
|
|
19
25
|
desc?: string;
|
|
20
26
|
descOwner?: string;
|
|
27
|
+
descOwnerLid?: string;
|
|
21
28
|
descId?: string;
|
|
29
|
+
descTime?: number;
|
|
22
30
|
/** if this group is part of a community, it returns the jid of the community to which it belongs */
|
|
23
31
|
linkedParent?: string;
|
|
24
32
|
/** is set when the group only allows admins to change group settings */
|
package/lib/Types/Label.d.ts
CHANGED
|
@@ -10,17 +10,6 @@ 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
|
-
}
|
|
24
13
|
/** WhatsApp has 20 predefined colors */
|
|
25
14
|
export declare enum LabelColor {
|
|
26
15
|
Color1 = 0,
|
package/lib/Types/Message.d.ts
CHANGED
|
@@ -1,34 +1,39 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
1
|
import { AxiosRequestConfig } from 'axios';
|
|
5
|
-
import type { Logger } from 'pino';
|
|
6
2
|
import type { Readable } from 'stream';
|
|
7
3
|
import type { URL } from 'url';
|
|
8
|
-
import { BinaryNode } from '../WABinary';
|
|
9
4
|
import { proto } from '../../WAProto';
|
|
10
5
|
import { MEDIA_HKDF_KEY_MAPPING } from '../Defaults';
|
|
6
|
+
import { BinaryNode } from '../WABinary';
|
|
11
7
|
import type { GroupMetadata } from './GroupMetadata';
|
|
12
8
|
import { CacheStore } from './Socket';
|
|
9
|
+
import { ILogger } from '../Utils/logger';
|
|
13
10
|
export { proto as WAProto };
|
|
14
|
-
export type WAMessage = proto.IWebMessageInfo
|
|
11
|
+
export type WAMessage = proto.IWebMessageInfo & {
|
|
12
|
+
key: WAMessageKey;
|
|
13
|
+
};
|
|
15
14
|
export type WAMessageContent = proto.IMessage;
|
|
16
15
|
export type WAContactMessage = proto.Message.IContactMessage;
|
|
17
16
|
export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
|
|
18
|
-
export type WAMessageKey = proto.IMessageKey
|
|
17
|
+
export type WAMessageKey = proto.IMessageKey & {
|
|
18
|
+
senderPn?: string;
|
|
19
|
+
senderLid?: string;
|
|
20
|
+
participantLid?: string;
|
|
21
|
+
server_id?: string;
|
|
22
|
+
isViewOnce?: boolean;
|
|
23
|
+
};
|
|
19
24
|
export type WATextMessage = proto.Message.IExtendedTextMessage;
|
|
20
25
|
export type WAContextInfo = proto.IContextInfo;
|
|
21
26
|
export type WALocationMessage = proto.Message.ILocationMessage;
|
|
22
|
-
export type WALiveLocationMessage = proto.Message.ILiveLocationMessage;
|
|
23
27
|
export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export type
|
|
28
|
+
export declare const WAMessageStubType: typeof proto.WebMessageInfo.StubType;
|
|
29
|
+
export declare const WAMessageStatus: typeof proto.WebMessageInfo.Status;
|
|
30
|
+
export type WAMediaPayloadURL = {
|
|
27
31
|
url: URL | string;
|
|
28
|
-
}
|
|
32
|
+
};
|
|
33
|
+
export type WAMediaPayloadStream = {
|
|
29
34
|
stream: Readable;
|
|
30
35
|
};
|
|
31
|
-
export
|
|
36
|
+
export type WAMediaUpload = Buffer | WAMediaPayloadStream | WAMediaPayloadURL;
|
|
32
37
|
/** Set of message types that are supported by the library */
|
|
33
38
|
export type MessageType = keyof proto.Message;
|
|
34
39
|
export type DownloadableMessage = {
|
|
@@ -55,19 +60,6 @@ export interface WAUrlInfo {
|
|
|
55
60
|
highQualityThumbnail?: proto.Message.IImageMessage;
|
|
56
61
|
originalThumbnailUrl?: string;
|
|
57
62
|
}
|
|
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
|
-
}
|
|
71
63
|
type Mentionable = {
|
|
72
64
|
/** list of jids that are mentioned in the accompanying text */
|
|
73
65
|
mentions?: string[];
|
|
@@ -89,7 +81,7 @@ type Templatable = {
|
|
|
89
81
|
footer?: string;
|
|
90
82
|
};
|
|
91
83
|
type Interactiveable = {
|
|
92
|
-
/** add buttons to the message
|
|
84
|
+
/** add buttons to the message */
|
|
93
85
|
interactiveButtons?: proto.Message.InteractiveMessage.NativeFlowMessage.NativeFlowButton[];
|
|
94
86
|
title?: string;
|
|
95
87
|
subtitle?: string;
|
|
@@ -102,19 +94,8 @@ type Shopable = {
|
|
|
102
94
|
subtitle?: string;
|
|
103
95
|
media?: boolean;
|
|
104
96
|
};
|
|
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
97
|
type Cardsable = {
|
|
116
|
-
cards?:
|
|
117
|
-
title?: string;
|
|
98
|
+
cards?: string[];
|
|
118
99
|
subtitle?: string;
|
|
119
100
|
};
|
|
120
101
|
type Editable = {
|
|
@@ -127,6 +108,8 @@ type Listable = {
|
|
|
127
108
|
title?: string;
|
|
128
109
|
/** Text of the button on the list (required) */
|
|
129
110
|
buttonText?: string;
|
|
111
|
+
/** ListType of a List Message only */
|
|
112
|
+
listType?: proto.Message.ListMessage.ListType;
|
|
130
113
|
};
|
|
131
114
|
type WithDimensions = {
|
|
132
115
|
width?: number;
|
|
@@ -140,60 +123,47 @@ export type PollMessageOptions = {
|
|
|
140
123
|
messageSecret?: Uint8Array;
|
|
141
124
|
toAnnouncementGroup?: boolean;
|
|
142
125
|
};
|
|
143
|
-
export type PollResultMessage = {
|
|
144
|
-
name: string;
|
|
145
|
-
votes: proto.Message.PollResultSnapshotMessage.PollVote[];
|
|
146
|
-
messageSecret?: Uint8Array;
|
|
147
|
-
};
|
|
148
126
|
type SharePhoneNumber = {
|
|
149
127
|
sharePhoneNumber: boolean;
|
|
150
128
|
};
|
|
151
129
|
type RequestPhoneNumber = {
|
|
152
130
|
requestPhoneNumber: boolean;
|
|
153
131
|
};
|
|
154
|
-
export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
|
|
155
|
-
productImage: WAMediaUpload;
|
|
156
|
-
};
|
|
157
132
|
export type MediaType = keyof typeof MEDIA_HKDF_KEY_MAPPING;
|
|
158
133
|
export type AnyMediaMessageContent = (({
|
|
159
134
|
image: WAMediaUpload;
|
|
160
135
|
caption?: string;
|
|
161
136
|
jpegThumbnail?: string;
|
|
162
|
-
|
|
163
|
-
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Collectionable & Cardsable & WithDimensions) | ({
|
|
137
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & WithDimensions) | ({
|
|
164
138
|
video: WAMediaUpload;
|
|
165
139
|
caption?: string;
|
|
166
140
|
gifPlayback?: boolean;
|
|
167
141
|
jpegThumbnail?: string;
|
|
168
142
|
/** if set to true, will send as a `video note` */
|
|
169
143
|
ptv?: boolean;
|
|
170
|
-
|
|
171
|
-
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Collectionable & Cardsable & WithDimensions) | {
|
|
144
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & WithDimensions) | {
|
|
172
145
|
audio: WAMediaUpload;
|
|
173
146
|
/** if set to true, will send as a `voice note` */
|
|
174
147
|
ptt?: boolean;
|
|
175
148
|
/** optionally tell the duration of the audio */
|
|
176
149
|
seconds?: number;
|
|
177
|
-
|
|
150
|
+
/** waveform for rendering audio waves in the chat */
|
|
151
|
+
waveform?: Uint8Array;
|
|
178
152
|
} | ({
|
|
179
153
|
sticker: WAMediaUpload;
|
|
180
154
|
isAnimated?: boolean;
|
|
181
|
-
annotations?: Annotations;
|
|
182
155
|
} & WithDimensions) | ({
|
|
183
156
|
document: WAMediaUpload;
|
|
184
157
|
mimetype: string;
|
|
185
158
|
fileName?: string;
|
|
186
159
|
caption?: string;
|
|
187
|
-
|
|
188
|
-
} & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Collectionable & Cardsable)) & {
|
|
160
|
+
} & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable)) & {
|
|
189
161
|
mimetype?: string;
|
|
190
162
|
} & Editable;
|
|
191
163
|
export type ButtonReplyInfo = {
|
|
192
164
|
displayText: string;
|
|
193
165
|
id: string;
|
|
194
166
|
index: number;
|
|
195
|
-
text: string;
|
|
196
|
-
nativeFlow: proto.Message.InteractiveResponseMessage.NativeFlowResponseMessage;
|
|
197
167
|
};
|
|
198
168
|
export type GroupInviteInfo = {
|
|
199
169
|
inviteCode: string;
|
|
@@ -201,23 +171,19 @@ export type GroupInviteInfo = {
|
|
|
201
171
|
text: string;
|
|
202
172
|
jid: string;
|
|
203
173
|
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
174
|
};
|
|
216
175
|
export type CallCreationInfo = {
|
|
217
176
|
time?: number;
|
|
218
177
|
title?: string;
|
|
219
178
|
type?: number;
|
|
220
179
|
};
|
|
180
|
+
export type AdminInviteInfo = {
|
|
181
|
+
inviteExpiration: number;
|
|
182
|
+
text: string;
|
|
183
|
+
jid: string;
|
|
184
|
+
subject: string;
|
|
185
|
+
thumbnail: Buffer;
|
|
186
|
+
};
|
|
221
187
|
export type PaymentInviteInfo = {
|
|
222
188
|
type?: number;
|
|
223
189
|
expiry?: number;
|
|
@@ -241,13 +207,6 @@ export type EventsInfo = {
|
|
|
241
207
|
startTime?: number;
|
|
242
208
|
messageSecret?: Uint8Array;
|
|
243
209
|
};
|
|
244
|
-
export type AdminInviteInfo = {
|
|
245
|
-
inviteExpiration: number;
|
|
246
|
-
text: string;
|
|
247
|
-
jid: string;
|
|
248
|
-
subject: string;
|
|
249
|
-
thumbnail: Buffer;
|
|
250
|
-
};
|
|
251
210
|
export type OrderInfo = {
|
|
252
211
|
id: number;
|
|
253
212
|
thumbnail: string;
|
|
@@ -261,13 +220,22 @@ export type OrderInfo = {
|
|
|
261
220
|
amount: number;
|
|
262
221
|
currency: string;
|
|
263
222
|
};
|
|
223
|
+
export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
|
|
224
|
+
productImage: WAMediaUpload;
|
|
225
|
+
};
|
|
226
|
+
export type AlbumMedia = {
|
|
227
|
+
image: WAMediaUpload;
|
|
228
|
+
caption?: string;
|
|
229
|
+
} | {
|
|
230
|
+
video: WAMediaUpload;
|
|
231
|
+
caption?: string;
|
|
232
|
+
gifPlayback?: boolean;
|
|
233
|
+
};
|
|
264
234
|
export type AnyRegularMessageContent = (({
|
|
265
235
|
text: string;
|
|
266
236
|
linkPreview?: WAUrlInfo | null;
|
|
267
|
-
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable &
|
|
237
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Interactiveable & Shopable & Cardsable & Listable & Editable) | AnyMediaMessageContent | ({
|
|
268
238
|
poll: PollMessageOptions;
|
|
269
|
-
} | {
|
|
270
|
-
pollResult: PollResultMessage;
|
|
271
239
|
} & Mentionable & Contextable & Buttonable & Templatable & Editable) | {
|
|
272
240
|
contacts: {
|
|
273
241
|
displayName?: string;
|
|
@@ -275,15 +243,15 @@ export type AnyRegularMessageContent = (({
|
|
|
275
243
|
};
|
|
276
244
|
} | {
|
|
277
245
|
location: WALocationMessage;
|
|
278
|
-
} | {
|
|
279
|
-
liveLocation: WALiveLocationMessage;
|
|
280
246
|
} | {
|
|
281
247
|
react: proto.Message.IReactionMessage;
|
|
282
248
|
} | {
|
|
283
249
|
buttonReply: ButtonReplyInfo;
|
|
284
|
-
type: 'template' | 'plain'
|
|
250
|
+
type: 'template' | 'plain';
|
|
285
251
|
} | {
|
|
286
252
|
groupInvite: GroupInviteInfo;
|
|
253
|
+
} | {
|
|
254
|
+
listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
|
|
287
255
|
} | {
|
|
288
256
|
pin: WAMessageKey;
|
|
289
257
|
type: proto.PinInChat.Type;
|
|
@@ -317,7 +285,10 @@ export type AnyRegularMessageContent = (({
|
|
|
317
285
|
businessOwnerJid?: string;
|
|
318
286
|
body?: string;
|
|
319
287
|
footer?: string;
|
|
320
|
-
} & Mentionable & Contextable & Interactiveable & Shopable &
|
|
288
|
+
} & Mentionable & Contextable & Interactiveable & Shopable & Cardsable & WithDimensions) | SharePhoneNumber | RequestPhoneNumber | ({
|
|
289
|
+
album: AlbumMedia[];
|
|
290
|
+
caption?: string;
|
|
291
|
+
} & Mentionable & Contextable & Editable)) & ViewOnce;
|
|
321
292
|
export type AnyMessageContent = AnyRegularMessageContent | {
|
|
322
293
|
forward: WAMessage;
|
|
323
294
|
force?: boolean;
|
|
@@ -331,8 +302,8 @@ export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>;
|
|
|
331
302
|
type MinimalRelayOptions = {
|
|
332
303
|
/** override the message ID with a custom provided string */
|
|
333
304
|
messageId?: string;
|
|
334
|
-
/**
|
|
335
|
-
|
|
305
|
+
/** should we use group metadata cache, or fetch afresh from the server; default assumed to be "true" */
|
|
306
|
+
useCachedGroupMetadata?: boolean;
|
|
336
307
|
};
|
|
337
308
|
export type MessageRelayOptions = MinimalRelayOptions & {
|
|
338
309
|
/** only send to a specific participant; used when a message decryption fails for a single user */
|
|
@@ -349,13 +320,13 @@ export type MessageRelayOptions = MinimalRelayOptions & {
|
|
|
349
320
|
useUserDevicesCache?: boolean;
|
|
350
321
|
/** jid list of participants for status@broadcast */
|
|
351
322
|
statusJidList?: string[];
|
|
323
|
+
newsletter?: boolean;
|
|
352
324
|
};
|
|
353
325
|
export type MiscMessageGenerationOptions = MinimalRelayOptions & {
|
|
354
326
|
/** optional, if you want to manually set the timestamp of the message */
|
|
355
327
|
timestamp?: Date;
|
|
356
328
|
/** the message you want to quote */
|
|
357
329
|
quoted?: WAMessage;
|
|
358
|
-
additionalNodes?: BinaryNode[];
|
|
359
330
|
/** disappearing messages settings */
|
|
360
331
|
ephemeralExpiration?: number | string;
|
|
361
332
|
/** timeout for media upload to WA server */
|
|
@@ -368,8 +339,8 @@ export type MiscMessageGenerationOptions = MinimalRelayOptions & {
|
|
|
368
339
|
font?: number;
|
|
369
340
|
/** if it is broadcast */
|
|
370
341
|
broadcast?: boolean;
|
|
371
|
-
|
|
372
|
-
|
|
342
|
+
newsletter?: boolean;
|
|
343
|
+
additionalNodes?: BinaryNode[];
|
|
373
344
|
};
|
|
374
345
|
export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & {
|
|
375
346
|
userJid: string;
|
|
@@ -386,15 +357,13 @@ export type WAMediaUploadFunction = (readStream: Readable | Buffer, opts: WAMedi
|
|
|
386
357
|
handle?: string;
|
|
387
358
|
}>;
|
|
388
359
|
export type MediaGenerationOptions = {
|
|
389
|
-
logger?:
|
|
360
|
+
logger?: ILogger;
|
|
390
361
|
mediaTypeOverride?: MediaType;
|
|
391
362
|
upload: WAMediaUploadFunction;
|
|
392
363
|
/** cache media so it does not have to be uploaded again */
|
|
393
364
|
mediaCache?: CacheStore;
|
|
394
365
|
mediaUploadTimeoutMs?: number;
|
|
395
366
|
options?: AxiosRequestConfig;
|
|
396
|
-
/** the message you want to quote */
|
|
397
|
-
quoted?: WAMessage;
|
|
398
367
|
backgroundColor?: string;
|
|
399
368
|
font?: number;
|
|
400
369
|
/** The message is for newsletter? */
|
package/lib/Types/Message.js
CHANGED
|
@@ -3,7 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.WAMessageStatus = exports.WAMessageStubType = exports.WAProto = void 0;
|
|
4
4
|
const WAProto_1 = require("../../WAProto");
|
|
5
5
|
Object.defineProperty(exports, "WAProto", { enumerable: true, get: function () { return WAProto_1.proto; } });
|
|
6
|
-
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
7
6
|
exports.WAMessageStubType = WAProto_1.proto.WebMessageInfo.StubType;
|
|
8
|
-
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
9
7
|
exports.WAMessageStatus = WAProto_1.proto.WebMessageInfo.Status;
|