@sixcore/baileys 1.0.0 → 1.0.2
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/WAProto/index.js +14270 -302
- package/jessica.js +91 -0
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.js +117 -79
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- 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/business.d.ts +43 -42
- package/lib/Socket/chats.d.ts +222 -36
- package/lib/Socket/chats.js +173 -153
- package/lib/Socket/dugong.d.ts +254 -0
- package/lib/Socket/dugong.js +484 -0
- package/lib/Socket/groups.d.ts +7 -7
- package/lib/Socket/groups.js +37 -35
- package/lib/Socket/index.d.ts +52 -51
- package/lib/Socket/index.js +1 -0
- package/lib/Socket/messages-recv.d.ts +37 -34
- package/lib/Socket/messages-recv.js +175 -37
- package/lib/Socket/messages-send.d.ts +12 -18
- package/lib/Socket/messages-send.js +396 -574
- package/lib/Socket/newsletter.d.ts +28 -26
- package/lib/Socket/newsletter.js +132 -121
- package/lib/Socket/registration.d.ts +52 -49
- package/lib/Socket/registration.js +7 -7
- package/lib/Socket/socket.d.ts +0 -1
- package/lib/Socket/socket.js +49 -27
- package/lib/Socket/usync.d.ts +10 -11
- package/lib/Store/make-cache-manager-store.d.ts +1 -2
- package/lib/Store/make-in-memory-store.d.ts +2 -2
- package/lib/Store/make-in-memory-store.js +1 -5
- package/lib/Store/make-ordered-dictionary.js +2 -2
- package/lib/Types/Auth.d.ts +1 -0
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +7 -12
- package/lib/Types/Events.d.ts +2 -17
- package/lib/Types/GroupMetadata.d.ts +2 -3
- 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 +10 -170
- package/lib/Types/Newsletter.d.ts +97 -86
- package/lib/Types/Newsletter.js +38 -32
- package/lib/Types/Socket.d.ts +2 -7
- package/lib/Types/index.d.ts +0 -9
- package/lib/Types/index.js +1 -1
- package/lib/Utils/auth-utils.js +14 -35
- package/lib/Utils/business.d.ts +1 -1
- package/lib/Utils/business.js +2 -2
- package/lib/Utils/chat-utils.d.ts +12 -11
- package/lib/Utils/chat-utils.js +36 -52
- package/lib/Utils/crypto.d.ts +16 -15
- package/lib/Utils/crypto.js +26 -74
- package/lib/Utils/decode-wa-message.d.ts +0 -17
- package/lib/Utils/decode-wa-message.js +17 -53
- package/lib/Utils/event-buffer.js +7 -10
- package/lib/Utils/generics.d.ts +17 -13
- package/lib/Utils/generics.js +79 -58
- package/lib/Utils/history.d.ts +2 -6
- package/lib/Utils/history.js +6 -4
- package/lib/Utils/logger.d.ts +3 -1
- package/lib/Utils/lt-hash.js +12 -12
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/messages-media.d.ts +28 -25
- package/lib/Utils/messages-media.js +733 -557
- package/lib/Utils/messages.js +68 -473
- package/lib/Utils/noise-handler.d.ts +5 -4
- package/lib/Utils/noise-handler.js +14 -19
- package/lib/Utils/process-message.d.ts +5 -5
- package/lib/Utils/process-message.js +23 -75
- package/lib/Utils/signal.d.ts +1 -2
- package/lib/Utils/signal.js +26 -32
- package/lib/Utils/use-multi-file-auth-state.d.ts +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +66 -242
- package/lib/Utils/validate-connection.d.ts +1 -1
- package/lib/Utils/validate-connection.js +88 -64
- package/lib/WABinary/constants.d.ts +27 -24
- package/lib/WABinary/decode.d.ts +2 -1
- package/lib/WABinary/decode.js +11 -23
- package/lib/WABinary/encode.d.ts +2 -1
- package/lib/WABinary/encode.js +147 -134
- package/lib/WABinary/generic-utils.d.ts +5 -2
- package/lib/WABinary/generic-utils.js +125 -37
- package/lib/WABinary/jid-utils.d.ts +1 -1
- package/lib/WAM/BinaryInfo.d.ts +11 -2
- package/lib/WAM/encode.d.ts +2 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -3
- package/lib/WAUSync/USyncUser.d.ts +2 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +64 -1
- package/package.json +113 -51
- package/WAProto/GenerateStatics.sh +0 -4
- package/WAProto/WAProto.proto +0 -4357
- package/WAProto/index.d.ts +0 -50383
- package/WASignalGroup/GroupProtocol.js +0 -1697
- package/WASignalGroup/ciphertext_message.js +0 -16
- package/WASignalGroup/generate-proto.sh +0 -1
- package/WASignalGroup/group.proto +0 -42
- 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/Utils/use-single-file-auth-state.d.ts +0 -12
- package/lib/Utils/use-single-file-auth-state.js +0 -75
- package/src/Defaults/baileys-version.json +0 -3
- package/src/Defaults/index.ts +0 -133
- package/src/Signal/Group/ciphertext-message.ts +0 -9
- package/src/Signal/Group/group-session-builder.ts +0 -56
- package/src/Signal/Group/group_cipher.ts +0 -117
- package/src/Signal/Group/index.ts +0 -11
- package/src/Signal/Group/keyhelper.ts +0 -28
- package/src/Signal/Group/sender-chain-key.ts +0 -34
- package/src/Signal/Group/sender-key-distribution-message.ts +0 -95
- package/src/Signal/Group/sender-key-message.ts +0 -96
- package/src/Signal/Group/sender-key-name.ts +0 -66
- package/src/Signal/Group/sender-key-record.ts +0 -69
- package/src/Signal/Group/sender-key-state.ts +0 -134
- package/src/Signal/Group/sender-message-key.ts +0 -36
- package/src/Signal/libsignal.ts +0 -447
- package/src/Signal/lid-mapping.ts +0 -209
- package/src/Socket/Client/index.ts +0 -2
- package/src/Socket/Client/types.ts +0 -22
- package/src/Socket/Client/websocket.ts +0 -56
- package/src/Socket/business.ts +0 -421
- package/src/Socket/chats.ts +0 -1223
- package/src/Socket/communities.ts +0 -477
- package/src/Socket/groups.ts +0 -361
- package/src/Socket/index.ts +0 -22
- package/src/Socket/messages-recv.ts +0 -1563
- package/src/Socket/messages-send.ts +0 -1210
- package/src/Socket/mex.ts +0 -58
- package/src/Socket/newsletter.ts +0 -229
- package/src/Socket/socket.ts +0 -1072
- package/src/Types/Auth.ts +0 -115
- package/src/Types/Bussines.ts +0 -20
- package/src/Types/Call.ts +0 -14
- package/src/Types/Chat.ts +0 -138
- package/src/Types/Contact.ts +0 -24
- package/src/Types/Events.ts +0 -132
- package/src/Types/GroupMetadata.ts +0 -70
- package/src/Types/Label.ts +0 -48
- package/src/Types/LabelAssociation.ts +0 -35
- package/src/Types/Message.ts +0 -424
- package/src/Types/Newsletter.ts +0 -98
- package/src/Types/Product.ts +0 -85
- package/src/Types/Signal.ts +0 -76
- package/src/Types/Socket.ts +0 -150
- package/src/Types/State.ts +0 -43
- package/src/Types/USync.ts +0 -27
- package/src/Types/globals.d.ts +0 -8
- package/src/Types/index.ts +0 -67
- package/src/Utils/auth-utils.ts +0 -331
- package/src/Utils/browser-utils.ts +0 -31
- package/src/Utils/business.ts +0 -286
- package/src/Utils/chat-utils.ts +0 -933
- package/src/Utils/crypto.ts +0 -184
- package/src/Utils/decode-wa-message.ts +0 -355
- package/src/Utils/event-buffer.ts +0 -662
- package/src/Utils/generics.ts +0 -470
- package/src/Utils/history.ts +0 -114
- package/src/Utils/index.ts +0 -18
- package/src/Utils/link-preview.ts +0 -111
- package/src/Utils/logger.ts +0 -13
- package/src/Utils/lt-hash.ts +0 -65
- package/src/Utils/make-mutex.ts +0 -45
- package/src/Utils/message-retry-manager.ts +0 -229
- package/src/Utils/messages-media.ts +0 -820
- package/src/Utils/messages.ts +0 -1137
- package/src/Utils/noise-handler.ts +0 -192
- package/src/Utils/pre-key-manager.ts +0 -126
- package/src/Utils/process-message.ts +0 -622
- package/src/Utils/signal.ts +0 -214
- package/src/Utils/use-multi-file-auth-state.ts +0 -136
- package/src/Utils/validate-connection.ts +0 -253
- package/src/WABinary/constants.ts +0 -1305
- package/src/WABinary/decode.ts +0 -281
- package/src/WABinary/encode.ts +0 -253
- package/src/WABinary/generic-utils.ts +0 -127
- package/src/WABinary/index.ts +0 -5
- package/src/WABinary/jid-utils.ts +0 -128
- package/src/WABinary/types.ts +0 -17
- package/src/WAM/BinaryInfo.ts +0 -12
- package/src/WAM/constants.ts +0 -22889
- package/src/WAM/encode.ts +0 -169
- package/src/WAM/index.ts +0 -3
- package/src/WAUSync/Protocols/USyncContactProtocol.ts +0 -32
- package/src/WAUSync/Protocols/USyncDeviceProtocol.ts +0 -78
- package/src/WAUSync/Protocols/USyncDisappearingModeProtocol.ts +0 -35
- package/src/WAUSync/Protocols/USyncStatusProtocol.ts +0 -44
- package/src/WAUSync/Protocols/UsyncBotProfileProtocol.ts +0 -76
- package/src/WAUSync/Protocols/UsyncLIDProtocol.ts +0 -33
- package/src/WAUSync/Protocols/index.ts +0 -4
- package/src/WAUSync/USyncQuery.ts +0 -133
- package/src/WAUSync/USyncUser.ts +0 -32
- package/src/WAUSync/index.ts +0 -3
- package/src/index.ts +0 -13
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
3
|
import { KeyPair, SignedKeyPair, SocketConfig } from '../Types';
|
|
3
4
|
export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
|
4
5
|
register: (code: string) => Promise<ExistsResponse>;
|
|
5
6
|
requestRegistrationCode: (registrationOptions?: RegistrationOptions) => Promise<ExistsResponse>;
|
|
6
|
-
logger: Logger
|
|
7
|
+
logger: import("pino").Logger<import("pino").LoggerOptions>;
|
|
7
8
|
getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
|
|
8
9
|
getCatalog: ({ jid, limit, cursor }: import("../Types").GetCatalogOptions) => Promise<{
|
|
9
10
|
products: import("../Types").Product[];
|
|
10
|
-
nextPageCursor:
|
|
11
|
+
nextPageCursor: string | undefined;
|
|
11
12
|
}>;
|
|
12
|
-
getCollections: (jid?: string, limit?: number) => Promise<{
|
|
13
|
+
getCollections: (jid?: string | undefined, limit?: number) => Promise<{
|
|
13
14
|
collections: import("../Types").CatalogCollection[];
|
|
14
15
|
}>;
|
|
15
16
|
productCreate: (create: import("../Types").ProductCreate) => Promise<import("../Types").Product>;
|
|
@@ -17,26 +18,27 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
|
|
17
18
|
deleted: number;
|
|
18
19
|
}>;
|
|
19
20
|
productUpdate: (productId: string, update: import("../Types").ProductUpdate) => Promise<import("../Types").Product>;
|
|
20
|
-
sendMessageAck: ({ tag, attrs, content }: import("../WABinary").BinaryNode
|
|
21
|
+
sendMessageAck: ({ tag, attrs, content }: import("../WABinary").BinaryNode) => Promise<void>;
|
|
21
22
|
sendRetryRequest: (node: import("../WABinary").BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
|
|
22
23
|
offerCall: (toJid: string, isVideo?: boolean) => Promise<{
|
|
23
|
-
id:
|
|
24
|
+
id: string;
|
|
24
25
|
to: string;
|
|
25
26
|
}>;
|
|
26
27
|
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
|
27
|
-
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number) => Promise<string>;
|
|
28
|
-
requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
|
|
29
28
|
getPrivacyTokens: (jids: string[]) => Promise<import("../WABinary").BinaryNode>;
|
|
30
29
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
31
30
|
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
|
32
31
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
33
|
-
sendReceipts: (keys: import("../Types").
|
|
34
|
-
getButtonArgs: (message: import("../Types").WAProto.IMessage) =>
|
|
35
|
-
|
|
32
|
+
sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
33
|
+
getButtonArgs: (message: import("../Types").WAProto.IMessage) => {
|
|
34
|
+
[key: string]: string;
|
|
35
|
+
};
|
|
36
|
+
readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;
|
|
36
37
|
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
|
37
38
|
getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: {
|
|
40
|
+
[key: string]: string;
|
|
41
|
+
} | undefined) => Promise<{
|
|
40
42
|
nodes: import("../WABinary").BinaryNode[];
|
|
41
43
|
shouldIncludeDeviceIdentity: boolean;
|
|
42
44
|
}>;
|
|
@@ -45,14 +47,12 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
|
|
45
47
|
[_: string]: string;
|
|
46
48
|
}>;
|
|
47
49
|
updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
|
|
48
|
-
sendStatusMentions: (content: import("../Types").AnyMessageContent, jids?: string[]) => Promise<import("../Types").WAProto.WebMessageInfo>;
|
|
49
|
-
sendAlbumMessage: (jid: string, medias: import("../Types").Media[], options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo>;
|
|
50
50
|
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
|
|
51
51
|
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
52
52
|
duration: string;
|
|
53
53
|
}>;
|
|
54
54
|
newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
|
|
55
|
-
newsletterUpdateDescription: (jid: string, description?: string) => Promise<void>;
|
|
55
|
+
newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
|
|
56
56
|
newsletterUpdateName: (jid: string, name: string) => Promise<void>;
|
|
57
57
|
newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
58
58
|
newsletterRemovePicture: (jid: string) => Promise<void>;
|
|
@@ -60,24 +60,27 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
|
|
60
60
|
newsletterFollow: (jid: string) => Promise<void>;
|
|
61
61
|
newsletterUnmute: (jid: string) => Promise<void>;
|
|
62
62
|
newsletterMute: (jid: string) => Promise<void>;
|
|
63
|
-
newsletterAction: (jid: string, type: "
|
|
64
|
-
newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
|
|
65
|
-
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole) => Promise<import("../Types").NewsletterMetadata>;
|
|
63
|
+
newsletterAction: (jid: string, type: "mute" | "follow" | "unfollow" | "unmute") => Promise<void>;
|
|
64
|
+
newsletterCreate: (name: string, description: string, reaction_codes: string) => Promise<import("../Types").NewsletterMetadata>;
|
|
65
|
+
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
|
|
66
66
|
newsletterAdminCount: (jid: string) => Promise<number>;
|
|
67
67
|
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
|
68
68
|
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
|
69
69
|
newsletterDelete: (jid: string) => Promise<void>;
|
|
70
|
-
newsletterReactMessage: (jid: string, serverId: string, code?: string) => Promise<void>;
|
|
71
|
-
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
72
|
-
newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
70
|
+
newsletterReactMessage: (jid: string, serverId: string, code?: string | undefined) => Promise<void>;
|
|
71
|
+
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
72
|
+
newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
73
73
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
74
74
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
75
75
|
groupLeave: (id: string) => Promise<void>;
|
|
76
|
+
/** the network code of your mobile network
|
|
77
|
+
* @see {@link https://de.wikipedia.org/wiki/Mobile_Network_Code}
|
|
78
|
+
*/
|
|
76
79
|
groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
|
|
77
80
|
groupRequestParticipantsList: (jid: string) => Promise<{
|
|
78
81
|
[key: string]: string;
|
|
79
82
|
}[]>;
|
|
80
|
-
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "
|
|
83
|
+
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
|
|
81
84
|
status: string;
|
|
82
85
|
jid: string;
|
|
83
86
|
}[]>;
|
|
@@ -86,27 +89,27 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
|
|
86
89
|
jid: string;
|
|
87
90
|
content: import("../WABinary").BinaryNode;
|
|
88
91
|
}[]>;
|
|
89
|
-
groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
|
|
92
|
+
groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
|
|
90
93
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
91
94
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
92
95
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
93
96
|
groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
|
|
94
97
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
95
98
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
96
|
-
groupSettingUpdate: (jid: string, setting: "announcement" | "
|
|
97
|
-
groupMemberAddMode: (jid: string, mode: "
|
|
99
|
+
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
|
|
100
|
+
groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
|
|
98
101
|
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
|
|
99
102
|
groupFetchAllParticipating: () => Promise<{
|
|
100
103
|
[_: string]: import("../Types").GroupMetadata;
|
|
101
104
|
}>;
|
|
102
105
|
processingMutex: {
|
|
103
|
-
mutex<T>(code: () =>
|
|
106
|
+
mutex<T>(code: () => T | Promise<T>): Promise<T>;
|
|
104
107
|
};
|
|
105
108
|
upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
|
|
106
109
|
appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
|
|
107
|
-
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
|
|
108
|
-
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
|
|
109
|
-
profilePictureUrl: (jid: string, type?: "
|
|
110
|
+
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
|
|
111
|
+
presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
|
|
112
|
+
profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;
|
|
110
113
|
onWhatsApp: (...jids: string[]) => Promise<{
|
|
111
114
|
exists: boolean;
|
|
112
115
|
jid: string;
|
|
@@ -128,25 +131,25 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
|
|
128
131
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
129
132
|
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
130
133
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
131
|
-
getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile
|
|
134
|
+
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
|
132
135
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
133
136
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
134
|
-
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number |
|
|
137
|
+
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
|
|
135
138
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
136
139
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
137
140
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
138
141
|
removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
139
142
|
star: (jid: string, messages: {
|
|
140
143
|
id: string;
|
|
141
|
-
fromMe?: boolean;
|
|
144
|
+
fromMe?: boolean | undefined;
|
|
142
145
|
}[], star: boolean) => Promise<void>;
|
|
143
146
|
type: "md";
|
|
144
147
|
ws: any;
|
|
145
148
|
ev: import("../Types").BaileysEventEmitter & {
|
|
146
|
-
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (
|
|
149
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
|
147
150
|
buffer(): void;
|
|
148
|
-
createBufferedFunction<A extends any[],
|
|
149
|
-
flush(force?: boolean): boolean;
|
|
151
|
+
createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>;
|
|
152
|
+
flush(force?: boolean | undefined): boolean;
|
|
150
153
|
isBuffering(): boolean;
|
|
151
154
|
};
|
|
152
155
|
authState: {
|
|
@@ -156,18 +159,18 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
|
|
156
159
|
signalRepository: import("../Types").SignalRepository;
|
|
157
160
|
user: import("../Types").Contact | undefined;
|
|
158
161
|
generateMessageTag: () => string;
|
|
159
|
-
query: (node: import("../WABinary").BinaryNode, timeoutMs?: number) => Promise<import("../WABinary").BinaryNode>;
|
|
160
|
-
waitForMessage: <
|
|
162
|
+
query: (node: import("../WABinary").BinaryNode, timeoutMs?: number | undefined) => Promise<import("../WABinary").BinaryNode>;
|
|
163
|
+
waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
|
|
161
164
|
waitForSocketOpen: () => Promise<void>;
|
|
162
165
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
163
166
|
sendNode: (frame: import("../WABinary").BinaryNode) => Promise<void>;
|
|
164
|
-
logout: (msg?: string) => Promise<void>;
|
|
167
|
+
logout: (msg?: string | undefined) => Promise<void>;
|
|
165
168
|
end: (error: Error | undefined) => void;
|
|
166
|
-
onUnexpectedError: (err: Error |
|
|
169
|
+
onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
|
|
167
170
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
168
171
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
169
|
-
requestPairingCode: (phoneNumber: string
|
|
170
|
-
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number) => Promise<void>;
|
|
172
|
+
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
173
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
|
|
171
174
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<import("../WABinary").BinaryNode>;
|
|
172
175
|
};
|
|
173
176
|
export interface RegistrationData {
|
|
@@ -212,13 +215,13 @@ export declare function registrationParams(params: RegistrationParams): {
|
|
|
212
215
|
lg: string;
|
|
213
216
|
lc: string;
|
|
214
217
|
mistyped: string;
|
|
215
|
-
authkey:
|
|
216
|
-
e_regid:
|
|
218
|
+
authkey: string;
|
|
219
|
+
e_regid: string;
|
|
217
220
|
e_keytype: string;
|
|
218
|
-
e_ident:
|
|
221
|
+
e_ident: string;
|
|
219
222
|
e_skey_id: string;
|
|
220
|
-
e_skey_val:
|
|
221
|
-
e_skey_sig:
|
|
223
|
+
e_skey_val: string;
|
|
224
|
+
e_skey_sig: string;
|
|
222
225
|
fdid: string;
|
|
223
226
|
network_ratio_type: string;
|
|
224
227
|
expid: string;
|
|
@@ -227,7 +230,7 @@ export declare function registrationParams(params: RegistrationParams): {
|
|
|
227
230
|
pid: string;
|
|
228
231
|
id: string;
|
|
229
232
|
backup_token: string;
|
|
230
|
-
token:
|
|
233
|
+
token: string;
|
|
231
234
|
fraud_checkpoint_code: string | undefined;
|
|
232
235
|
};
|
|
233
236
|
/**
|
|
@@ -244,7 +247,7 @@ export declare function mobileRegister(params: RegistrationParams & {
|
|
|
244
247
|
/**
|
|
245
248
|
* Encrypts the given string as AEAD aes-256-gcm with the public whatsapp key and a random keypair.
|
|
246
249
|
*/
|
|
247
|
-
export declare function mobileRegisterEncrypt(data: string):
|
|
250
|
+
export declare function mobileRegisterEncrypt(data: string): string;
|
|
248
251
|
export declare function mobileRegisterFetch(path: string, opts?: AxiosRequestConfig): Promise<ExistsResponse>;
|
|
249
252
|
export interface ExistsResponse {
|
|
250
253
|
status: 'fail' | 'sent';
|
|
@@ -3,13 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.makeRegistrationSocket = void 0;
|
|
7
|
-
exports.registrationParams = registrationParams;
|
|
8
|
-
exports.mobileRegisterCode = mobileRegisterCode;
|
|
9
|
-
exports.mobileRegisterExists = mobileRegisterExists;
|
|
10
|
-
exports.mobileRegister = mobileRegister;
|
|
11
|
-
exports.mobileRegisterEncrypt = mobileRegisterEncrypt;
|
|
12
|
-
exports.mobileRegisterFetch = mobileRegisterFetch;
|
|
6
|
+
exports.mobileRegisterFetch = exports.mobileRegisterEncrypt = exports.mobileRegister = exports.mobileRegisterExists = exports.mobileRegisterCode = exports.registrationParams = exports.makeRegistrationSocket = void 0;
|
|
13
7
|
/* eslint-disable camelcase */
|
|
14
8
|
const axios_1 = __importDefault(require("axios"));
|
|
15
9
|
const Defaults_1 = require("../Defaults");
|
|
@@ -95,6 +89,7 @@ function registrationParams(params) {
|
|
|
95
89
|
fraud_checkpoint_code: params.captcha,
|
|
96
90
|
};
|
|
97
91
|
}
|
|
92
|
+
exports.registrationParams = registrationParams;
|
|
98
93
|
/**
|
|
99
94
|
* Requests a registration code for the given phone number.
|
|
100
95
|
*/
|
|
@@ -113,12 +108,14 @@ function mobileRegisterCode(params, fetchOptions) {
|
|
|
113
108
|
...fetchOptions,
|
|
114
109
|
});
|
|
115
110
|
}
|
|
111
|
+
exports.mobileRegisterCode = mobileRegisterCode;
|
|
116
112
|
function mobileRegisterExists(params, fetchOptions) {
|
|
117
113
|
return mobileRegisterFetch('/exist', {
|
|
118
114
|
params: registrationParams(params),
|
|
119
115
|
...fetchOptions
|
|
120
116
|
});
|
|
121
117
|
}
|
|
118
|
+
exports.mobileRegisterExists = mobileRegisterExists;
|
|
122
119
|
/**
|
|
123
120
|
* Registers the phone number on whatsapp with the received OTP code.
|
|
124
121
|
*/
|
|
@@ -129,6 +126,7 @@ async function mobileRegister(params, fetchOptions) {
|
|
|
129
126
|
...fetchOptions,
|
|
130
127
|
});
|
|
131
128
|
}
|
|
129
|
+
exports.mobileRegister = mobileRegister;
|
|
132
130
|
/**
|
|
133
131
|
* Encrypts the given string as AEAD aes-256-gcm with the public whatsapp key and a random keypair.
|
|
134
132
|
*/
|
|
@@ -138,6 +136,7 @@ function mobileRegisterEncrypt(data) {
|
|
|
138
136
|
const buffer = (0, crypto_1.aesEncryptGCM)(Buffer.from(data), new Uint8Array(key), Buffer.alloc(12), Buffer.alloc(0));
|
|
139
137
|
return Buffer.concat([Buffer.from(keypair.public), buffer]).toString('base64url');
|
|
140
138
|
}
|
|
139
|
+
exports.mobileRegisterEncrypt = mobileRegisterEncrypt;
|
|
141
140
|
async function mobileRegisterFetch(path, opts = {}) {
|
|
142
141
|
let url = `${Defaults_1.MOBILE_REGISTRATION_ENDPOINT}${path}`;
|
|
143
142
|
if (opts.params) {
|
|
@@ -164,3 +163,4 @@ async function mobileRegisterFetch(path, opts = {}) {
|
|
|
164
163
|
}
|
|
165
164
|
return json;
|
|
166
165
|
}
|
|
166
|
+
exports.mobileRegisterFetch = mobileRegisterFetch;
|
package/lib/Socket/socket.d.ts
CHANGED
package/lib/Socket/socket.js
CHANGED
|
@@ -20,21 +20,16 @@ const Client_1 = require("./Client");
|
|
|
20
20
|
const makeSocket = (config) => {
|
|
21
21
|
var _a, _b;
|
|
22
22
|
const { waWebSocketUrl, connectTimeoutMs, logger, keepAliveIntervalMs, browser, auth: authState, printQRInTerminal, defaultQueryTimeoutMs, transactionOpts, qrTimeout, makeSignalRepository, } = config;
|
|
23
|
-
|
|
24
|
-
config.mobile = config.mobile || url.protocol === 'tcp:';
|
|
25
|
-
if (config.mobile && url.protocol !== 'tcp:') {
|
|
26
|
-
url = new url_1.URL(`tcp://${Defaults_1.MOBILE_ENDPOINT}:${Defaults_1.MOBILE_PORT}`);
|
|
27
|
-
}
|
|
28
|
-
if (!config.mobile && url.protocol === 'wss' && ((_a = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _a === void 0 ? void 0 : _a.routingInfo)) {
|
|
29
|
-
url.searchParams.append('ED', authState.creds.routingInfo.toString('base64url'));
|
|
30
|
-
}
|
|
23
|
+
const url = typeof waWebSocketUrl === 'string' ? new url_1.URL(waWebSocketUrl) : waWebSocketUrl;
|
|
31
24
|
if (config.mobile || url.protocol === 'tcp:') {
|
|
32
|
-
throw new boom_1.Boom('Mobile API is not supported anymore', {
|
|
25
|
+
throw new boom_1.Boom('Mobile API is not supported anymore', {
|
|
26
|
+
statusCode: Types_1.DisconnectReason.loggedOut
|
|
27
|
+
});
|
|
33
28
|
}
|
|
34
29
|
if (url.protocol === 'wss' && ((_a = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _a === void 0 ? void 0 : _a.routingInfo)) {
|
|
35
30
|
url.searchParams.append('ED', authState.creds.routingInfo.toString('base64url'));
|
|
36
31
|
}
|
|
37
|
-
const ws =
|
|
32
|
+
const ws = new Client_1.WebSocketClient(url, config);
|
|
38
33
|
ws.connect();
|
|
39
34
|
const ev = (0, Utils_1.makeEventBuffer)(logger);
|
|
40
35
|
/** ephemeral key pair used to encrypt/decrypt communication. Unique for each connection */
|
|
@@ -42,8 +37,7 @@ const makeSocket = (config) => {
|
|
|
42
37
|
/** WA noise protocol wrapper */
|
|
43
38
|
const noise = (0, Utils_1.makeNoiseHandler)({
|
|
44
39
|
keyPair: ephemeralKeyPair,
|
|
45
|
-
NOISE_HEADER:
|
|
46
|
-
mobile: config.mobile,
|
|
40
|
+
NOISE_HEADER: Defaults_1.NOISE_WA_HEADER,
|
|
47
41
|
logger,
|
|
48
42
|
routingInfo: (_b = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _b === void 0 ? void 0 : _b.routingInfo
|
|
49
43
|
});
|
|
@@ -86,6 +80,25 @@ const makeSocket = (config) => {
|
|
|
86
80
|
/** log & process any unexpected errors */
|
|
87
81
|
const onUnexpectedError = (err, msg) => {
|
|
88
82
|
logger.error({ err }, `unexpected error in '${msg}'`);
|
|
83
|
+
const message = (err && ((err.stack || err.message) || String(err))).toLowerCase();
|
|
84
|
+
// auto recover from cryptographic desyncs by re-uploading prekeys
|
|
85
|
+
if (message.includes('bad mac') || (message.includes('mac') && message.includes('invalid'))) {
|
|
86
|
+
try {
|
|
87
|
+
uploadPreKeysToServerIfRequired(true)
|
|
88
|
+
.catch(e => logger.warn({ e }, 'failed to re-upload prekeys after bad mac'));
|
|
89
|
+
}
|
|
90
|
+
catch (_e) {
|
|
91
|
+
// ignore
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// gently back off when encountering rate limits (429)
|
|
95
|
+
if (message.includes('429') || message.includes('rate limit')) {
|
|
96
|
+
const wait = Math.min(30000, (config.backoffDelayMs || 5000));
|
|
97
|
+
logger.info({ wait }, 'backing off due to rate limit');
|
|
98
|
+
setTimeout(() => {
|
|
99
|
+
// intentionally empty; wait to delay further sends
|
|
100
|
+
}, wait);
|
|
101
|
+
}
|
|
89
102
|
};
|
|
90
103
|
/** await the next incoming message */
|
|
91
104
|
const awaitNextMessage = async (sendMsg) => {
|
|
@@ -122,7 +135,7 @@ const makeSocket = (config) => {
|
|
|
122
135
|
let onRecv;
|
|
123
136
|
let onErr;
|
|
124
137
|
try {
|
|
125
|
-
|
|
138
|
+
const result = await (0, Utils_1.promiseTimeout)(timeoutMs, (resolve, reject) => {
|
|
126
139
|
onRecv = resolve;
|
|
127
140
|
onErr = err => {
|
|
128
141
|
reject(err || new boom_1.Boom('Connection Closed', { statusCode: Types_1.DisconnectReason.connectionClosed }));
|
|
@@ -131,6 +144,7 @@ const makeSocket = (config) => {
|
|
|
131
144
|
ws.on('close', onErr); // if the socket closes, you'll never receive the message
|
|
132
145
|
ws.off('error', onErr);
|
|
133
146
|
});
|
|
147
|
+
return result;
|
|
134
148
|
}
|
|
135
149
|
finally {
|
|
136
150
|
ws.off(`TAG:${msgId}`, onRecv);
|
|
@@ -144,9 +158,10 @@ const makeSocket = (config) => {
|
|
|
144
158
|
node.attrs.id = generateMessageTag();
|
|
145
159
|
}
|
|
146
160
|
const msgId = node.attrs.id;
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
161
|
+
const [result] = await Promise.all([
|
|
162
|
+
waitForMessage(msgId, timeoutMs),
|
|
163
|
+
sendNode(node)
|
|
164
|
+
]);
|
|
150
165
|
if ('tag' in result) {
|
|
151
166
|
(0, WABinary_1.assertNodeErrorFree)(result);
|
|
152
167
|
}
|
|
@@ -165,10 +180,7 @@ const makeSocket = (config) => {
|
|
|
165
180
|
logger.trace({ handshake }, 'handshake recv from WA');
|
|
166
181
|
const keyEnc = await noise.processHandshake(handshake, creds.noiseKey);
|
|
167
182
|
let node;
|
|
168
|
-
if (
|
|
169
|
-
node = (0, Utils_1.generateMobileNode)(config);
|
|
170
|
-
}
|
|
171
|
-
else if (!creds.me) {
|
|
183
|
+
if (!creds.me) {
|
|
172
184
|
node = (0, Utils_1.generateRegistrationNode)(creds, config);
|
|
173
185
|
logger.info({ node }, 'not logged in, attempting registration...');
|
|
174
186
|
}
|
|
@@ -183,7 +195,7 @@ const makeSocket = (config) => {
|
|
|
183
195
|
payload: payloadEnc,
|
|
184
196
|
},
|
|
185
197
|
}).finish());
|
|
186
|
-
|
|
198
|
+
noise.finishInit();
|
|
187
199
|
startKeepAliveRequest();
|
|
188
200
|
};
|
|
189
201
|
const getAvailablePreKeysOnServer = async () => {
|
|
@@ -371,17 +383,24 @@ const makeSocket = (config) => {
|
|
|
371
383
|
}
|
|
372
384
|
end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }));
|
|
373
385
|
};
|
|
374
|
-
|
|
386
|
+
|
|
387
|
+
/** This method was created by snowi, and implemented by KyuuRzy */
|
|
388
|
+
/** hey bro, if you delete this text */
|
|
389
|
+
/** you are the most cursed human being who likes to claim other people's property 😹🙌🏻 */
|
|
390
|
+
const requestPairingCode = async (phoneNumber, pairKey) => {
|
|
375
391
|
if (pairKey) {
|
|
376
|
-
|
|
392
|
+
authState.creds.pairingCode = pairKey.toUpperCase();
|
|
377
393
|
} else {
|
|
378
394
|
authState.creds.pairingCode = (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5));
|
|
379
395
|
}
|
|
396
|
+
|
|
380
397
|
authState.creds.me = {
|
|
381
398
|
id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
|
|
382
399
|
name: '~'
|
|
383
400
|
};
|
|
401
|
+
|
|
384
402
|
ev.emit('creds.update', authState.creds);
|
|
403
|
+
|
|
385
404
|
await sendNode({
|
|
386
405
|
tag: 'iq',
|
|
387
406
|
attrs: {
|
|
@@ -396,7 +415,6 @@ const makeSocket = (config) => {
|
|
|
396
415
|
attrs: {
|
|
397
416
|
jid: authState.creds.me.id,
|
|
398
417
|
stage: 'companion_hello',
|
|
399
|
-
// eslint-disable-next-line camelcase
|
|
400
418
|
should_show_push_notification: 'true'
|
|
401
419
|
},
|
|
402
420
|
content: [
|
|
@@ -423,14 +441,15 @@ const makeSocket = (config) => {
|
|
|
423
441
|
{
|
|
424
442
|
tag: 'link_code_pairing_nonce',
|
|
425
443
|
attrs: {},
|
|
426
|
-
content:
|
|
444
|
+
content: "0"
|
|
427
445
|
}
|
|
428
446
|
]
|
|
429
447
|
}
|
|
430
448
|
]
|
|
431
449
|
});
|
|
450
|
+
|
|
432
451
|
return authState.creds.pairingCode;
|
|
433
|
-
}
|
|
452
|
+
}
|
|
434
453
|
async function generatePairingKey() {
|
|
435
454
|
const salt = (0, crypto_1.randomBytes)(32);
|
|
436
455
|
const randomIv = (0, crypto_1.randomBytes)(16);
|
|
@@ -609,7 +628,10 @@ const makeSocket = (config) => {
|
|
|
609
628
|
type: 'md',
|
|
610
629
|
ws,
|
|
611
630
|
ev,
|
|
612
|
-
authState: {
|
|
631
|
+
authState: {
|
|
632
|
+
creds,
|
|
633
|
+
keys
|
|
634
|
+
},
|
|
613
635
|
signalRepository,
|
|
614
636
|
get user() {
|
|
615
637
|
return authState.creds.me;
|
package/lib/Socket/usync.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Boom } from '@hapi/boom';
|
|
3
2
|
import { SocketConfig } from '../Types';
|
|
4
3
|
import { BinaryNode } from '../WABinary';
|
|
@@ -6,12 +5,12 @@ import { USyncQuery } from '../WAUSync';
|
|
|
6
5
|
export declare const makeUSyncSocket: (config: SocketConfig) => {
|
|
7
6
|
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
|
|
8
7
|
type: "md";
|
|
9
|
-
ws:
|
|
8
|
+
ws: import("./Client").WebSocketClient;
|
|
10
9
|
ev: import("../Types").BaileysEventEmitter & {
|
|
11
|
-
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
|
10
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
12
11
|
buffer(): void;
|
|
13
|
-
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T
|
|
14
|
-
flush(force?: boolean
|
|
12
|
+
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
13
|
+
flush(force?: boolean): boolean;
|
|
15
14
|
isBuffering(): boolean;
|
|
16
15
|
};
|
|
17
16
|
authState: {
|
|
@@ -21,17 +20,17 @@ export declare const makeUSyncSocket: (config: SocketConfig) => {
|
|
|
21
20
|
signalRepository: import("../Types").SignalRepository;
|
|
22
21
|
user: import("../Types").Contact | undefined;
|
|
23
22
|
generateMessageTag: () => string;
|
|
24
|
-
query: (node: BinaryNode, timeoutMs?: number
|
|
25
|
-
waitForMessage: <
|
|
23
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<BinaryNode>;
|
|
24
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
26
25
|
waitForSocketOpen: () => Promise<void>;
|
|
27
26
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
28
27
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
29
|
-
logout: (msg?: string
|
|
28
|
+
logout: (msg?: string) => Promise<void>;
|
|
30
29
|
end: (error: Error | undefined) => void;
|
|
31
|
-
onUnexpectedError: (err: Error | Boom
|
|
30
|
+
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
32
31
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
33
32
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
34
|
-
requestPairingCode: (phoneNumber: string,
|
|
35
|
-
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined
|
|
33
|
+
requestPairingCode: (phoneNumber: string, customPairingCode?: string) => Promise<string>;
|
|
34
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
36
35
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
|
|
37
36
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Store } from 'cache-manager';
|
|
2
1
|
import { AuthenticationCreds } from '../Types';
|
|
3
|
-
declare const makeCacheManagerAuthState: (store:
|
|
2
|
+
declare const makeCacheManagerAuthState: (store: Storage, sessionKey: string) => Promise<{
|
|
4
3
|
clearState: () => Promise<void>;
|
|
5
4
|
saveCreds: () => Promise<void>;
|
|
6
5
|
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';
|
|
3
4
|
import { proto } from '../../WAProto';
|
|
4
5
|
import type makeMDSocket from '../Socket';
|
|
5
6
|
import type { BaileysEventEmitter, Chat, ConnectionState, Contact, GroupMetadata, PresenceData, WAMessage, WAMessageCursor, WAMessageKey } from '../Types';
|
|
6
7
|
import { Label } from '../Types/Label';
|
|
7
8
|
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?:
|
|
20
|
+
logger?: Logger;
|
|
21
21
|
socket?: WASocket;
|
|
22
22
|
};
|
|
23
23
|
declare const _default: (config: BaileysInMemoryStoreConfig) => {
|
|
@@ -74,11 +74,7 @@ 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
|
|
78
|
-
if (syncType === WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND) {
|
|
79
|
-
return; // FOR NOW,
|
|
80
|
-
//TODO: HANDLE
|
|
81
|
-
}
|
|
77
|
+
ev.on('messaging-history.set', ({ chats: newChats, contacts: newContacts, messages: newMessages, isLatest }) => {
|
|
82
78
|
if (isLatest) {
|
|
83
79
|
chats.clear();
|
|
84
80
|
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
|
-
|
|
59
|
+
Object.keys(dict).forEach(key => {
|
|
60
60
|
delete dict[key];
|
|
61
|
-
}
|
|
61
|
+
});
|
|
62
62
|
},
|
|
63
63
|
filter: (contain) => {
|
|
64
64
|
let i = 0;
|
package/lib/Types/Auth.d.ts
CHANGED
package/lib/Types/Call.d.ts
CHANGED