@hbmodsofc/baileys 1.7.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/WAProto/index.js +157084 -24729
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +8 -12
- package/lib/Defaults/index.js +124 -90
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/group_cipher.d.ts +1 -0
- package/lib/Signal/Group/group_cipher.js +39 -28
- 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 +1 -1
- package/lib/Signal/Group/sender-chain-key.js +2 -9
- package/lib/Signal/Group/sender-key-distribution-message.js +3 -3
- package/lib/Signal/Group/sender-key-message.js +3 -3
- package/lib/Signal/Group/sender-key-state.d.ts +4 -4
- package/lib/Signal/Group/sender-key-state.js +16 -47
- package/lib/Signal/libsignal.d.ts +3 -7
- package/lib/Signal/libsignal.js +39 -224
- package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +3 -1
- package/lib/Socket/Client/index.d.ts +3 -2
- package/lib/Socket/Client/index.js +3 -2
- package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -1
- package/lib/Socket/Client/{websocket.js → web-socket-client.js} +16 -10
- package/lib/Socket/business.d.ts +78 -94
- package/lib/Socket/business.js +11 -130
- package/lib/Socket/chats.d.ts +233 -63
- package/lib/Socket/chats.js +184 -234
- package/lib/Socket/groups.d.ts +41 -62
- package/lib/Socket/groups.js +64 -76
- package/lib/Socket/hbmods.d.ts +253 -0
- package/lib/Socket/hbmods.js +1 -0
- package/lib/Socket/index.d.ts +83 -129
- package/lib/Socket/index.js +6 -13
- package/lib/Socket/messages-recv.d.ts +48 -59
- package/lib/Socket/messages-recv.js +371 -516
- package/lib/Socket/messages-send.d.ts +67 -86
- package/lib/Socket/messages-send.js +1 -1091
- package/lib/Socket/newsletter.d.ts +64 -76
- package/lib/Socket/newsletter.js +1 -184
- package/lib/Socket/registration.d.ts +267 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +13 -19
- package/lib/Socket/socket.js +1 -805
- package/lib/Socket/usync.d.ts +36 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Types/Auth.d.ts +10 -4
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +9 -29
- package/lib/Types/Chat.js +1 -7
- package/lib/Types/Contact.d.ts +1 -5
- package/lib/Types/Events.d.ts +14 -55
- package/lib/Types/GroupMetadata.d.ts +5 -15
- package/lib/Types/Label.d.ts +0 -11
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Message.d.ts +49 -75
- package/lib/Types/Message.js +7 -10
- package/lib/Types/Newsletter.d.ts +98 -129
- package/lib/Types/Newsletter.js +38 -33
- package/lib/Types/Product.d.ts +1 -1
- package/lib/Types/Signal.d.ts +1 -29
- package/lib/Types/Socket.d.ts +22 -48
- package/lib/Types/State.d.ts +2 -13
- package/lib/Types/State.js +0 -12
- package/lib/Types/USync.d.ts +1 -1
- package/lib/Types/index.d.ts +3 -10
- package/lib/Types/index.js +2 -2
- package/lib/Utils/auth-utils.d.ts +3 -3
- package/lib/Utils/auth-utils.js +102 -378
- package/lib/Utils/baileys-event-stream.js +1 -1
- package/lib/Utils/business.d.ts +2 -2
- package/lib/Utils/business.js +13 -19
- package/lib/Utils/chat-utils.d.ts +22 -21
- package/lib/Utils/chat-utils.js +154 -201
- package/lib/Utils/crypto.d.ts +19 -18
- package/lib/Utils/crypto.js +37 -78
- package/lib/Utils/decode-wa-message.d.ts +7 -34
- package/lib/Utils/decode-wa-message.js +66 -138
- package/lib/Utils/event-buffer.d.ts +8 -6
- package/lib/Utils/event-buffer.js +43 -81
- package/lib/Utils/generics.d.ts +27 -27
- package/lib/Utils/generics.js +133 -128
- package/lib/Utils/history.d.ts +5 -9
- package/lib/Utils/history.js +23 -17
- package/lib/Utils/index.d.ts +0 -2
- package/lib/Utils/index.js +0 -2
- package/lib/Utils/link-preview.d.ts +4 -4
- package/lib/Utils/link-preview.js +12 -40
- package/lib/Utils/logger.d.ts +3 -11
- package/lib/Utils/lt-hash.d.ts +8 -8
- package/lib/Utils/lt-hash.js +24 -23
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/make-mutex.js +2 -3
- package/lib/Utils/messages-media.d.ts +41 -37
- package/lib/Utils/messages-media.js +368 -252
- package/lib/Utils/messages.d.ts +15 -13
- package/lib/Utils/messages.js +261 -274
- package/lib/Utils/noise-handler.d.ts +15 -13
- package/lib/Utils/noise-handler.js +26 -20
- package/lib/Utils/process-message.d.ts +8 -9
- package/lib/Utils/process-message.js +93 -157
- package/lib/Utils/signal.d.ts +5 -6
- package/lib/Utils/signal.js +29 -37
- package/lib/Utils/use-multi-file-auth-state.d.ts +2 -1
- package/lib/Utils/use-multi-file-auth-state.js +7 -12
- package/lib/Utils/validate-connection.d.ts +6 -5
- package/lib/Utils/validate-connection.js +97 -39
- package/lib/WABinary/constants.d.ts +27 -24
- package/lib/WABinary/constants.js +13 -1276
- package/lib/WABinary/decode.d.ts +4 -3
- package/lib/WABinary/decode.js +14 -28
- package/lib/WABinary/encode.d.ts +2 -1
- package/lib/WABinary/encode.js +147 -134
- package/lib/WABinary/generic-utils.d.ts +7 -4
- package/lib/WABinary/generic-utils.js +125 -40
- package/lib/WABinary/jid-utils.d.ts +8 -13
- package/lib/WABinary/jid-utils.js +16 -27
- package/lib/WAM/BinaryInfo.d.ts +11 -2
- package/lib/WAM/constants.d.ts +2 -3
- package/lib/WAM/constants.js +2359 -2252
- package/lib/WAM/encode.d.ts +2 -1
- package/lib/WAM/encode.js +11 -8
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +4 -3
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +5 -5
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +5 -5
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +6 -5
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +3 -4
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +3 -11
- package/lib/WAUSync/USyncQuery.d.ts +2 -2
- package/lib/WAUSync/USyncQuery.js +15 -19
- package/lib/WAUSync/USyncUser.d.ts +5 -5
- package/lib/WAUSync/index.d.ts +1 -1
- package/lib/WAUSync/index.js +1 -1
- package/package.json +102 -104
- package/lib/Signal/lid-mapping.d.ts +0 -26
- package/lib/Signal/lid-mapping.js +0 -146
- package/lib/Socket/communities.d.ts +0 -232
- package/lib/Socket/communities.js +0 -402
- package/lib/Socket/mex.d.ts +0 -2
- package/lib/Socket/mex.js +0 -45
- package/lib/Types/Bussines.d.ts +0 -24
- package/lib/Types/Bussines.js +0 -2
- package/lib/Utils/lidToJid-test.d.ts +0 -11
- package/lib/Utils/lidToJid-test.js +0 -27
- package/lib/Utils/message-retry-manager.d.ts +0 -81
- package/lib/Utils/message-retry-manager.js +0 -152
- /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
|
@@ -0,0 +1,36 @@
|
|
|
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<BinaryNode>;
|
|
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, customPairingCode?: string) => Promise<string>;
|
|
34
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
35
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
|
|
36
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeUSyncSocket = void 0;
|
|
4
|
+
const boom_1 = require("@hapi/boom");
|
|
5
|
+
const WABinary_1 = require("../WABinary");
|
|
6
|
+
const socket_1 = require("./socket");
|
|
7
|
+
const makeUSyncSocket = (config) => {
|
|
8
|
+
const sock = (0, socket_1.makeSocket)(config);
|
|
9
|
+
const { generateMessageTag, query, } = sock;
|
|
10
|
+
const executeUSyncQuery = async (usyncQuery) => {
|
|
11
|
+
if (usyncQuery.protocols.length === 0) {
|
|
12
|
+
throw new boom_1.Boom('USyncQuery must have at least one protocol');
|
|
13
|
+
}
|
|
14
|
+
// todo: validate users, throw WARNING on no valid users
|
|
15
|
+
// variable below has only validated users
|
|
16
|
+
const validUsers = usyncQuery.users;
|
|
17
|
+
const userNodes = validUsers.map((user) => {
|
|
18
|
+
return {
|
|
19
|
+
tag: 'user',
|
|
20
|
+
attrs: {
|
|
21
|
+
jid: !user.phone ? user.id : undefined,
|
|
22
|
+
},
|
|
23
|
+
content: usyncQuery.protocols
|
|
24
|
+
.map((a) => a.getUserElement(user))
|
|
25
|
+
.filter(a => a !== null)
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
const listNode = {
|
|
29
|
+
tag: 'list',
|
|
30
|
+
attrs: {},
|
|
31
|
+
content: userNodes
|
|
32
|
+
};
|
|
33
|
+
const queryNode = {
|
|
34
|
+
tag: 'query',
|
|
35
|
+
attrs: {},
|
|
36
|
+
content: usyncQuery.protocols.map((a) => a.getQueryElement())
|
|
37
|
+
};
|
|
38
|
+
const iq = {
|
|
39
|
+
tag: 'iq',
|
|
40
|
+
attrs: {
|
|
41
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
42
|
+
type: 'get',
|
|
43
|
+
xmlns: 'usync',
|
|
44
|
+
},
|
|
45
|
+
content: [
|
|
46
|
+
{
|
|
47
|
+
tag: 'usync',
|
|
48
|
+
attrs: {
|
|
49
|
+
context: usyncQuery.context,
|
|
50
|
+
mode: usyncQuery.mode,
|
|
51
|
+
sid: generateMessageTag(),
|
|
52
|
+
last: 'true',
|
|
53
|
+
index: '0',
|
|
54
|
+
},
|
|
55
|
+
content: [
|
|
56
|
+
queryNode,
|
|
57
|
+
listNode
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
const result = await query(iq);
|
|
63
|
+
return usyncQuery.parseUSyncQueryResult(result);
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
...sock,
|
|
67
|
+
executeUSyncQuery,
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
exports.makeUSyncSocket = makeUSyncSocket;
|
package/lib/Types/Auth.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { proto } from '../../WAProto';
|
|
3
|
+
import { RegistrationOptions } from '../Socket/registration';
|
|
2
4
|
import type { Contact } from './Contact';
|
|
3
5
|
import type { MinimalMessage } from './Message';
|
|
4
6
|
export type KeyPair = {
|
|
@@ -55,21 +57,25 @@ export type AuthenticationCreds = SignalCreds & {
|
|
|
55
57
|
/** number of times history & app state has been synced */
|
|
56
58
|
accountSyncCounter: number;
|
|
57
59
|
accountSettings: AccountSettings;
|
|
60
|
+
deviceId: string;
|
|
61
|
+
phoneId: string;
|
|
62
|
+
identityId: Buffer;
|
|
58
63
|
registered: boolean;
|
|
64
|
+
backupToken: Buffer;
|
|
65
|
+
registration: RegistrationOptions;
|
|
59
66
|
pairingCode: string | undefined;
|
|
60
67
|
lastPropHash: string | undefined;
|
|
61
68
|
routingInfo: Buffer | undefined;
|
|
62
69
|
};
|
|
63
70
|
export type SignalDataTypeMap = {
|
|
64
71
|
'pre-key': KeyPair;
|
|
65
|
-
session: Uint8Array;
|
|
72
|
+
'session': Uint8Array;
|
|
66
73
|
'sender-key': Uint8Array;
|
|
67
74
|
'sender-key-memory': {
|
|
68
75
|
[jid: string]: boolean;
|
|
69
76
|
};
|
|
70
77
|
'app-state-sync-key': proto.Message.IAppStateSyncKeyData;
|
|
71
78
|
'app-state-sync-version': LTHashState;
|
|
72
|
-
'lid-mapping': string;
|
|
73
79
|
};
|
|
74
80
|
export type SignalDataSet = {
|
|
75
81
|
[T in keyof SignalDataTypeMap]?: {
|
|
@@ -87,7 +93,7 @@ export type SignalKeyStore = {
|
|
|
87
93
|
};
|
|
88
94
|
export type SignalKeyStoreWithTransaction = SignalKeyStore & {
|
|
89
95
|
isInTransaction: () => boolean;
|
|
90
|
-
transaction<T>(exec: () => Promise<T
|
|
96
|
+
transaction<T>(exec: () => Promise<T>): Promise<T>;
|
|
91
97
|
};
|
|
92
98
|
export type TransactionCapabilityOptions = {
|
|
93
99
|
maxCommitRetries: number;
|
package/lib/Types/Call.d.ts
CHANGED
package/lib/Types/Chat.d.ts
CHANGED
|
@@ -1,30 +1,21 @@
|
|
|
1
|
-
import type { proto } from '../../WAProto
|
|
1
|
+
import type { proto } from '../../WAProto';
|
|
2
2
|
import type { AccountSettings } from './Auth';
|
|
3
|
-
import type { QuickReplyAction } from './Bussines.js';
|
|
4
3
|
import type { BufferedEventData } from './Events';
|
|
5
|
-
import type { LabelActionBody } from './Label';
|
|
6
4
|
import type { ChatLabelAssociationActionBody } from './LabelAssociation';
|
|
7
5
|
import type { MessageLabelAssociationActionBody } from './LabelAssociation';
|
|
8
|
-
import type { MinimalMessage
|
|
6
|
+
import type { MinimalMessage } from './Message';
|
|
9
7
|
/** privacy settings in WhatsApp Web */
|
|
10
8
|
export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none';
|
|
11
9
|
export type WAPrivacyOnlineValue = 'all' | 'match_last_seen';
|
|
12
|
-
export type WAPrivacyGroupAddValue = 'all' | 'contacts' | 'contact_blacklist';
|
|
13
10
|
export type WAReadReceiptsValue = 'all' | 'none';
|
|
14
|
-
export type WAPrivacyCallValue = 'all' | 'known';
|
|
15
|
-
export type WAPrivacyMessagesValue = 'all' | 'contacts';
|
|
16
11
|
/** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
|
|
17
12
|
export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
|
|
18
13
|
export declare const ALL_WA_PATCH_NAMES: readonly ["critical_block", "critical_unblock_low", "regular_high", "regular_low", "regular"];
|
|
19
|
-
export type WAPatchName =
|
|
14
|
+
export type WAPatchName = typeof ALL_WA_PATCH_NAMES[number];
|
|
20
15
|
export interface PresenceData {
|
|
21
16
|
lastKnownPresence: WAPresence;
|
|
22
17
|
lastSeen?: number;
|
|
23
18
|
}
|
|
24
|
-
export type BotListInfo = {
|
|
25
|
-
jid: string;
|
|
26
|
-
personaId: string;
|
|
27
|
-
};
|
|
28
19
|
export type ChatMutation = {
|
|
29
20
|
syncAction: proto.ISyncActionData;
|
|
30
21
|
index: string[];
|
|
@@ -51,8 +42,6 @@ export type ChatUpdate = Partial<Chat & {
|
|
|
51
42
|
* undefined if the condition is not yet fulfilled
|
|
52
43
|
* */
|
|
53
44
|
conditional: (bufferedData: BufferedEventData) => boolean | undefined;
|
|
54
|
-
/** last update time */
|
|
55
|
-
timestamp?: number;
|
|
56
45
|
}>;
|
|
57
46
|
/**
|
|
58
47
|
* the last messages in a chat, sorted reverse-chronologically. That is, the latest message should be first in the chat
|
|
@@ -70,13 +59,12 @@ export type ChatModification = {
|
|
|
70
59
|
/** mute for duration, or provide timestamp of mute to remove*/
|
|
71
60
|
mute: number | null;
|
|
72
61
|
} | {
|
|
73
|
-
clear:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
timestamp: number;
|
|
62
|
+
clear: 'all' | {
|
|
63
|
+
messages: {
|
|
64
|
+
id: string;
|
|
65
|
+
fromMe?: boolean;
|
|
66
|
+
timestamp: number;
|
|
67
|
+
}[];
|
|
80
68
|
};
|
|
81
69
|
} | {
|
|
82
70
|
star: {
|
|
@@ -92,12 +80,6 @@ export type ChatModification = {
|
|
|
92
80
|
} | {
|
|
93
81
|
delete: true;
|
|
94
82
|
lastMessages: LastMessageList;
|
|
95
|
-
} | {
|
|
96
|
-
contact: proto.SyncActionValue.IContactAction | null;
|
|
97
|
-
} | {
|
|
98
|
-
disableLinkPreviews: proto.SyncActionValue.IPrivacySettingDisableLinkPreviewsAction;
|
|
99
|
-
} | {
|
|
100
|
-
addLabel: LabelActionBody;
|
|
101
83
|
} | {
|
|
102
84
|
addChatLabel: ChatLabelAssociationActionBody;
|
|
103
85
|
} | {
|
|
@@ -106,8 +88,6 @@ export type ChatModification = {
|
|
|
106
88
|
addMessageLabel: MessageLabelAssociationActionBody;
|
|
107
89
|
} | {
|
|
108
90
|
removeMessageLabel: MessageLabelAssociationActionBody;
|
|
109
|
-
} | {
|
|
110
|
-
quickReply: QuickReplyAction;
|
|
111
91
|
};
|
|
112
92
|
export type InitialReceivedChatsState = {
|
|
113
93
|
[jid: string]: {
|
package/lib/Types/Chat.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ALL_WA_PATCH_NAMES = void 0;
|
|
4
|
-
exports.ALL_WA_PATCH_NAMES = [
|
|
5
|
-
'critical_block',
|
|
6
|
-
'critical_unblock_low',
|
|
7
|
-
'regular_high',
|
|
8
|
-
'regular_low',
|
|
9
|
-
'regular'
|
|
10
|
-
];
|
|
4
|
+
exports.ALL_WA_PATCH_NAMES = ['critical_block', 'critical_unblock_low', 'regular_high', 'regular_low', 'regular'];
|
package/lib/Types/Contact.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
export interface Contact {
|
|
2
|
-
/** ID either in lid or jid format (preferred) **/
|
|
3
2
|
id: string;
|
|
4
|
-
/** ID in LID format (@lid) **/
|
|
5
3
|
lid?: string;
|
|
6
|
-
/** ID in PN format (@s.whatsapp.net) **/
|
|
7
|
-
phoneNumber?: string;
|
|
8
4
|
/** name of the contact, you have saved on your WA */
|
|
9
5
|
name?: string;
|
|
10
6
|
/** name of the contact, the contact has set on their own on WA */
|
|
@@ -18,6 +14,6 @@ export interface Contact {
|
|
|
18
14
|
* null => if the profile picture has not been set (default profile picture)
|
|
19
15
|
* any other string => url of the profile picture
|
|
20
16
|
*/
|
|
21
|
-
imgUrl?: string | null;
|
|
17
|
+
imgUrl?: string | null | 'changed';
|
|
22
18
|
status?: string;
|
|
23
19
|
}
|
package/lib/Types/Events.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Boom } from '@hapi/boom';
|
|
2
|
-
import { proto } from '../../WAProto
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
2
|
+
import { proto } from '../../WAProto';
|
|
3
|
+
import { AuthenticationCreds } from './Auth';
|
|
4
|
+
import { WACallEvent } from './Call';
|
|
5
|
+
import { Chat, ChatUpdate, PresenceData } from './Chat';
|
|
6
|
+
import { Contact } from './Contact';
|
|
7
|
+
import { GroupMetadata, ParticipantAction } from './GroupMetadata';
|
|
8
|
+
import { Label } from './Label';
|
|
9
|
+
import { LabelAssociation } from './LabelAssociation';
|
|
10
|
+
import { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message';
|
|
11
|
+
import { ConnectionState } from './State';
|
|
12
12
|
export type BaileysEventMap = {
|
|
13
13
|
/** connection state has been updated -- WS closed, opened, connecting etc. */
|
|
14
14
|
'connection.update': Partial<ConnectionState>;
|
|
@@ -19,18 +19,15 @@ export type BaileysEventMap = {
|
|
|
19
19
|
chats: Chat[];
|
|
20
20
|
contacts: Contact[];
|
|
21
21
|
messages: WAMessage[];
|
|
22
|
-
isLatest
|
|
23
|
-
progress?: number | null;
|
|
24
|
-
syncType?: proto.HistorySync.HistorySyncType;
|
|
25
|
-
peerDataRequestSessionId?: string | null;
|
|
22
|
+
isLatest: boolean;
|
|
26
23
|
};
|
|
27
24
|
/** upsert chats */
|
|
28
25
|
'chats.upsert': Chat[];
|
|
29
26
|
/** update the given chats */
|
|
30
27
|
'chats.update': ChatUpdate[];
|
|
31
|
-
'
|
|
28
|
+
'chats.phoneNumberShare': {
|
|
32
29
|
lid: string;
|
|
33
|
-
|
|
30
|
+
jid: string;
|
|
34
31
|
};
|
|
35
32
|
/** delete chats with given ID */
|
|
36
33
|
'chats.delete': string[];
|
|
@@ -61,12 +58,10 @@ export type BaileysEventMap = {
|
|
|
61
58
|
/**
|
|
62
59
|
* add/update the given messages. If they were received while the connection was online,
|
|
63
60
|
* the update will have type: "notify"
|
|
64
|
-
* if requestId is provided, then the messages was received from the phone due to it being unavailable
|
|
65
61
|
* */
|
|
66
62
|
'messages.upsert': {
|
|
67
63
|
messages: WAMessage[];
|
|
68
64
|
type: MessageUpsertType;
|
|
69
|
-
requestId?: string;
|
|
70
65
|
};
|
|
71
66
|
/** message was reacted to. If reaction was removed -- then "reaction.text" will be falsey */
|
|
72
67
|
'messages.reaction': {
|
|
@@ -83,13 +78,6 @@ export type BaileysEventMap = {
|
|
|
83
78
|
participants: string[];
|
|
84
79
|
action: ParticipantAction;
|
|
85
80
|
};
|
|
86
|
-
'group.join-request': {
|
|
87
|
-
id: string;
|
|
88
|
-
author: string;
|
|
89
|
-
participant: string;
|
|
90
|
-
action: RequestJoinAction;
|
|
91
|
-
method: RequestJoinMethod;
|
|
92
|
-
};
|
|
93
81
|
'blocklist.set': {
|
|
94
82
|
blocklist: string[];
|
|
95
83
|
};
|
|
@@ -98,38 +86,12 @@ export type BaileysEventMap = {
|
|
|
98
86
|
type: 'add' | 'remove';
|
|
99
87
|
};
|
|
100
88
|
/** Receive an update on a call, including when the call was received, rejected, accepted */
|
|
101
|
-
call: WACallEvent[];
|
|
89
|
+
'call': WACallEvent[];
|
|
102
90
|
'labels.edit': Label;
|
|
103
91
|
'labels.association': {
|
|
104
92
|
association: LabelAssociation;
|
|
105
93
|
type: 'add' | 'remove';
|
|
106
94
|
};
|
|
107
|
-
/** Newsletter-related events */
|
|
108
|
-
'newsletter.reaction': {
|
|
109
|
-
id: string;
|
|
110
|
-
server_id: string;
|
|
111
|
-
reaction: {
|
|
112
|
-
code?: string;
|
|
113
|
-
count?: number;
|
|
114
|
-
removed?: boolean;
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
'newsletter.view': {
|
|
118
|
-
id: string;
|
|
119
|
-
server_id: string;
|
|
120
|
-
count: number;
|
|
121
|
-
};
|
|
122
|
-
'newsletter-participants.update': {
|
|
123
|
-
id: string;
|
|
124
|
-
author: string;
|
|
125
|
-
user: string;
|
|
126
|
-
new_role: string;
|
|
127
|
-
action: string;
|
|
128
|
-
};
|
|
129
|
-
'newsletter-settings.update': {
|
|
130
|
-
id: string;
|
|
131
|
-
update: any;
|
|
132
|
-
};
|
|
133
95
|
};
|
|
134
96
|
export type BufferedEventData = {
|
|
135
97
|
historySets: {
|
|
@@ -144,9 +106,6 @@ export type BufferedEventData = {
|
|
|
144
106
|
};
|
|
145
107
|
empty: boolean;
|
|
146
108
|
isLatest: boolean;
|
|
147
|
-
progress?: number | null;
|
|
148
|
-
syncType?: proto.HistorySync.HistorySyncType;
|
|
149
|
-
peerDataRequestSessionId?: string;
|
|
150
109
|
};
|
|
151
110
|
chatUpserts: {
|
|
152
111
|
[jid: string]: Chat;
|
|
@@ -1,33 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export type GroupParticipant = Contact & {
|
|
1
|
+
import { Contact } from './Contact';
|
|
2
|
+
export type GroupParticipant = (Contact & {
|
|
4
3
|
isAdmin?: boolean;
|
|
5
4
|
isSuperAdmin?: boolean;
|
|
6
5
|
admin?: 'admin' | 'superadmin' | null;
|
|
7
|
-
};
|
|
8
|
-
export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote'
|
|
9
|
-
export type RequestJoinAction = 'created' | 'revoked' | 'rejected';
|
|
10
|
-
export type RequestJoinMethod = 'invite_link' | 'linked_group_join' | 'non_admin_add' | undefined;
|
|
6
|
+
});
|
|
7
|
+
export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote';
|
|
11
8
|
export interface GroupMetadata {
|
|
12
9
|
id: string;
|
|
13
|
-
notify?: string;
|
|
14
|
-
/** group uses 'lid' or 'pn' to send messages */
|
|
15
|
-
addressingMode?: WAMessageAddressingMode;
|
|
16
10
|
owner: string | undefined;
|
|
17
|
-
ownerPn?: string | undefined;
|
|
18
|
-
owner_country_code?: string | undefined;
|
|
19
11
|
subject: string;
|
|
12
|
+
addressingMode: "pn" | "lid";
|
|
20
13
|
/** group subject owner */
|
|
21
14
|
subjectOwner?: string;
|
|
22
|
-
subjectOwnerPn?: string;
|
|
23
15
|
/** group subject modification date */
|
|
24
16
|
subjectTime?: number;
|
|
25
17
|
creation?: number;
|
|
26
18
|
desc?: string;
|
|
27
19
|
descOwner?: string;
|
|
28
|
-
descOwnerPn?: string;
|
|
29
20
|
descId?: string;
|
|
30
|
-
descTime?: number;
|
|
31
21
|
/** if this group is part of a community, it returns the jid of the community to which it belongs */
|
|
32
22
|
linkedParent?: string;
|
|
33
23
|
/** 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/Label.js
CHANGED
|
@@ -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
|
|
27
|
+
})(LabelColor = exports.LabelColor || (exports.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
|
|
9
|
+
})(LabelAssociationType = exports.LabelAssociationType || (exports.LabelAssociationType = {}));
|