angularsockets 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1880 -36
- package/WAProto/index.d.ts +50383 -0
- package/WAProto/index.js +37203 -11791
- package/WASignalGroup/GroupProtocol.js +1697 -0
- package/WASignalGroup/ciphertext_message.js +16 -0
- package/WASignalGroup/group_cipher.js +120 -0
- package/WASignalGroup/group_session_builder.js +46 -0
- package/WASignalGroup/index.js +5 -0
- package/WASignalGroup/keyhelper.js +21 -0
- package/WASignalGroup/protobufs.js +3 -0
- package/WASignalGroup/queue_job.js +69 -0
- package/WASignalGroup/sender_chain_key.js +50 -0
- package/WASignalGroup/sender_key_distribution_message.js +78 -0
- package/WASignalGroup/sender_key_message.js +92 -0
- package/WASignalGroup/sender_key_name.js +70 -0
- package/WASignalGroup/sender_key_record.js +56 -0
- package/WASignalGroup/sender_key_state.js +129 -0
- package/{lib/Signal/Group/sender-message-key.js → WASignalGroup/sender_message_key.js} +16 -6
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.js +79 -101
- package/lib/Signal/libsignal.js +29 -51
- package/lib/Socket/Client/web-socket-client.js +0 -2
- package/lib/Socket/business.d.ts +42 -43
- package/lib/Socket/chats.d.ts +9 -8
- package/lib/Socket/chats.js +107 -21
- package/lib/Socket/groups.d.ts +7 -7
- package/lib/Socket/groups.js +24 -25
- package/lib/Socket/index.d.ts +51 -52
- package/lib/Socket/messages-recv.d.ts +34 -37
- package/lib/Socket/messages-recv.js +37 -175
- package/lib/Socket/messages-send.d.ts +16 -10
- package/lib/Socket/messages-send.js +540 -346
- package/lib/Socket/newsletter.d.ts +26 -28
- package/lib/Socket/newsletter.js +4 -4
- package/lib/Socket/registration.d.ts +49 -52
- package/lib/Socket/registration.js +7 -7
- package/lib/Socket/socket.d.ts +1 -0
- package/lib/Socket/socket.js +36 -23
- package/lib/Socket/usync.d.ts +11 -10
- package/lib/Store/make-cache-manager-store.d.ts +2 -1
- package/lib/Store/make-in-memory-store.d.ts +2 -2
- package/lib/Store/make-in-memory-store.js +5 -1
- package/lib/Store/make-ordered-dictionary.js +2 -2
- package/lib/Types/Auth.d.ts +0 -1
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +12 -7
- package/lib/Types/Events.d.ts +17 -2
- package/lib/Types/GroupMetadata.d.ts +3 -2
- package/lib/Types/Label.d.ts +11 -0
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Message.d.ts +170 -10
- package/lib/Types/Newsletter.js +3 -3
- package/lib/Types/Socket.d.ts +7 -2
- package/lib/Types/index.d.ts +9 -0
- package/lib/Types/index.js +1 -1
- package/lib/Utils/auth-utils.js +35 -14
- package/lib/Utils/business.d.ts +1 -1
- package/lib/Utils/business.js +2 -2
- package/lib/Utils/chat-utils.d.ts +11 -12
- package/lib/Utils/chat-utils.js +52 -36
- package/lib/Utils/crypto.d.ts +15 -16
- package/lib/Utils/crypto.js +74 -26
- package/lib/Utils/decode-wa-message.d.ts +17 -0
- package/lib/Utils/decode-wa-message.js +53 -17
- package/lib/Utils/event-buffer.js +10 -7
- package/lib/Utils/generics.d.ts +13 -17
- package/lib/Utils/generics.js +26 -15
- package/lib/Utils/history.d.ts +6 -2
- package/lib/Utils/history.js +4 -6
- package/lib/Utils/logger.d.ts +1 -3
- package/lib/Utils/lt-hash.js +12 -12
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/messages-media.d.ts +25 -28
- package/lib/Utils/messages-media.js +47 -57
- package/lib/Utils/messages.js +461 -44
- package/lib/Utils/noise-handler.d.ts +4 -5
- package/lib/Utils/noise-handler.js +19 -14
- package/lib/Utils/process-message.d.ts +5 -5
- package/lib/Utils/process-message.js +75 -23
- package/lib/Utils/signal.d.ts +2 -1
- package/lib/Utils/signal.js +43 -35
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -1
- package/lib/Utils/use-multi-file-auth-state.js +251 -36
- package/lib/Utils/use-single-file-auth-state.d.ts +12 -0
- package/lib/Utils/use-single-file-auth-state.js +75 -0
- package/lib/Utils/validate-connection.d.ts +1 -1
- package/lib/Utils/validate-connection.js +1 -1
- package/lib/WABinary/decode.d.ts +1 -2
- package/lib/WABinary/decode.js +23 -11
- package/lib/WABinary/encode.d.ts +1 -2
- package/lib/WABinary/encode.js +46 -22
- package/lib/WABinary/generic-utils.d.ts +2 -4
- package/lib/WABinary/generic-utils.js +2 -10
- package/lib/WABinary/jid-utils.d.ts +1 -1
- package/lib/WAM/BinaryInfo.d.ts +2 -11
- package/lib/WAM/encode.d.ts +1 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -3
- package/lib/WAUSync/USyncUser.d.ts +0 -2
- package/lib/index.js +0 -6
- package/package.json +96 -104
- package/engine-requirements.js +0 -10
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
- package/lib/Signal/Group/ciphertext-message.js +0 -15
- package/lib/Signal/Group/group-session-builder.d.ts +0 -14
- package/lib/Signal/Group/group-session-builder.js +0 -64
- package/lib/Signal/Group/group_cipher.d.ts +0 -17
- package/lib/Signal/Group/group_cipher.js +0 -96
- package/lib/Signal/Group/index.d.ts +0 -11
- package/lib/Signal/Group/index.js +0 -57
- package/lib/Signal/Group/keyhelper.d.ts +0 -10
- package/lib/Signal/Group/keyhelper.js +0 -55
- package/lib/Signal/Group/queue-job.d.ts +0 -1
- package/lib/Signal/Group/queue-job.js +0 -57
- package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
- package/lib/Signal/Group/sender-chain-key.js +0 -34
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
- package/lib/Signal/Group/sender-key-distribution-message.js +0 -66
- package/lib/Signal/Group/sender-key-message.d.ts +0 -18
- package/lib/Signal/Group/sender-key-message.js +0 -69
- package/lib/Signal/Group/sender-key-name.d.ts +0 -17
- package/lib/Signal/Group/sender-key-name.js +0 -51
- package/lib/Signal/Group/sender-key-record.d.ts +0 -30
- package/lib/Signal/Group/sender-key-record.js +0 -53
- package/lib/Signal/Group/sender-key-state.d.ts +0 -38
- package/lib/Signal/Group/sender-key-state.js +0 -99
- package/lib/Signal/Group/sender-message-key.d.ts +0 -11
- package/lib/Socket/dugong.d.ts +0 -175
- package/lib/Socket/dugong.js +0 -342
- package/lib/index.d.ts +0 -12
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { NewsletterFetchedUpdate, NewsletterMetadata, NewsletterReactionMode, NewsletterViewRole, SocketConfig, WAMediaUpload } from '../Types';
|
|
3
2
|
import { BinaryNode } from '../WABinary';
|
|
4
3
|
export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
@@ -14,9 +13,9 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
|
14
13
|
newsletterFollow: (jid: string) => Promise<void>;
|
|
15
14
|
newsletterUnmute: (jid: string) => Promise<void>;
|
|
16
15
|
newsletterMute: (jid: string) => Promise<void>;
|
|
17
|
-
newsletterAction: (jid: string, type:
|
|
18
|
-
newsletterCreate: (name: string, description: string
|
|
19
|
-
newsletterMetadata: (type:
|
|
16
|
+
newsletterAction: (jid: string, type: "follow" | "unfollow" | "mute" | "unmute") => Promise<void>;
|
|
17
|
+
newsletterCreate: (name: string, description: string) => Promise<NewsletterMetadata>;
|
|
18
|
+
newsletterMetadata: (type: "invite" | "jid", key: string, role?: NewsletterViewRole) => Promise<NewsletterMetadata>;
|
|
20
19
|
newsletterAdminCount: (jid: string) => Promise<number>;
|
|
21
20
|
/**user is Lid, not Jid */
|
|
22
21
|
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
|
@@ -25,7 +24,7 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
|
25
24
|
newsletterDelete: (jid: string) => Promise<void>;
|
|
26
25
|
/**if code wasn't passed, the reaction will be removed (if is reacted) */
|
|
27
26
|
newsletterReactMessage: (jid: string, serverId: string, code?: string) => Promise<void>;
|
|
28
|
-
newsletterFetchMessages: (type:
|
|
27
|
+
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<NewsletterFetchedUpdate[]>;
|
|
29
28
|
newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<NewsletterFetchedUpdate[]>;
|
|
30
29
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
31
30
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
@@ -34,7 +33,7 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
|
34
33
|
groupRequestParticipantsList: (jid: string) => Promise<{
|
|
35
34
|
[key: string]: string;
|
|
36
35
|
}[]>;
|
|
37
|
-
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "
|
|
36
|
+
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
|
|
38
37
|
status: string;
|
|
39
38
|
jid: string;
|
|
40
39
|
}[]>;
|
|
@@ -43,35 +42,34 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
|
43
42
|
jid: string;
|
|
44
43
|
content: BinaryNode;
|
|
45
44
|
}[]>;
|
|
46
|
-
groupUpdateDescription: (jid: string, description?: string
|
|
45
|
+
groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
|
|
47
46
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
48
47
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
49
48
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
50
49
|
groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
|
|
51
50
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
52
51
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
53
|
-
groupSettingUpdate: (jid: string, setting: "announcement" | "
|
|
54
|
-
groupMemberAddMode: (jid: string, mode: "
|
|
52
|
+
groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
|
|
53
|
+
groupMemberAddMode: (jid: string, mode: "admin_add" | "all_member_add") => Promise<void>;
|
|
55
54
|
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
|
|
56
55
|
groupFetchAllParticipating: () => Promise<{
|
|
57
56
|
[_: string]: import("../Types").GroupMetadata;
|
|
58
57
|
}>;
|
|
59
58
|
processingMutex: {
|
|
60
|
-
mutex<T>(code: () => T |
|
|
59
|
+
mutex<T>(code: () => Promise<T> | T): Promise<T>;
|
|
61
60
|
};
|
|
62
61
|
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
63
62
|
[_: string]: string;
|
|
64
63
|
}>;
|
|
65
64
|
upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
|
|
66
65
|
appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
|
|
67
|
-
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string
|
|
68
|
-
presenceSubscribe: (toJid: string, tcToken?: Buffer
|
|
69
|
-
profilePictureUrl: (jid: string, type?: "
|
|
66
|
+
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
|
|
67
|
+
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
|
|
68
|
+
profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
|
|
70
69
|
onWhatsApp: (...jids: string[]) => Promise<{
|
|
70
|
+
exists: boolean;
|
|
71
71
|
jid: string;
|
|
72
|
-
|
|
73
|
-
lid: unknown;
|
|
74
|
-
}[] | undefined>;
|
|
72
|
+
}[]>;
|
|
75
73
|
fetchBlocklist: () => Promise<string[]>;
|
|
76
74
|
fetchStatus: (jid: string) => Promise<{
|
|
77
75
|
status: string | undefined;
|
|
@@ -89,25 +87,25 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
|
89
87
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
90
88
|
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
91
89
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
92
|
-
getBusinessProfile: (jid: string) => Promise<
|
|
90
|
+
getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
|
|
93
91
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
94
92
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
95
|
-
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?:
|
|
93
|
+
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
|
|
96
94
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
97
95
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
98
96
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
99
97
|
removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
100
98
|
star: (jid: string, messages: {
|
|
101
99
|
id: string;
|
|
102
|
-
fromMe?: boolean
|
|
100
|
+
fromMe?: boolean;
|
|
103
101
|
}[], star: boolean) => Promise<void>;
|
|
104
102
|
type: "md";
|
|
105
103
|
ws: any;
|
|
106
104
|
ev: import("../Types").BaileysEventEmitter & {
|
|
107
|
-
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
|
105
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
108
106
|
buffer(): void;
|
|
109
|
-
createBufferedFunction<A extends any[],
|
|
110
|
-
flush(force?: boolean
|
|
107
|
+
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
108
|
+
flush(force?: boolean): boolean;
|
|
111
109
|
isBuffering(): boolean;
|
|
112
110
|
};
|
|
113
111
|
authState: {
|
|
@@ -117,18 +115,18 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
|
117
115
|
signalRepository: import("../Types").SignalRepository;
|
|
118
116
|
user: import("../Types").Contact | undefined;
|
|
119
117
|
generateMessageTag: () => string;
|
|
120
|
-
query: (node: BinaryNode, timeoutMs?: number
|
|
121
|
-
waitForMessage: <
|
|
118
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<BinaryNode>;
|
|
119
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<T>;
|
|
122
120
|
waitForSocketOpen: () => Promise<void>;
|
|
123
121
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
124
122
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
125
|
-
logout: (msg?: string
|
|
123
|
+
logout: (msg?: string) => Promise<void>;
|
|
126
124
|
end: (error: Error | undefined) => void;
|
|
127
|
-
onUnexpectedError: (err: Error |
|
|
125
|
+
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
128
126
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
129
127
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
130
|
-
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
131
|
-
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number
|
|
128
|
+
requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
|
|
129
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number) => Promise<void>;
|
|
132
130
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
|
|
133
131
|
};
|
|
134
132
|
export declare const extractNewsletterMetadata: (node: BinaryNode, isCreate?: boolean) => NewsletterMetadata;
|
package/lib/Socket/newsletter.js
CHANGED
|
@@ -115,9 +115,9 @@ const makeNewsletterSocket = (config) => {
|
|
|
115
115
|
await newsletterWMexQuery(jid, Types_1.QueryIds.MUTE);
|
|
116
116
|
},
|
|
117
117
|
newsletterAction: async (jid, type) => {
|
|
118
|
-
await newsletterWMexQuery(jid, type.toUpperCase());
|
|
118
|
+
await newsletterWMexQuery(jid, Types_1.QueryIds[type.toUpperCase()]);
|
|
119
119
|
},
|
|
120
|
-
newsletterCreate: async (name, description
|
|
120
|
+
newsletterCreate: async (name, description) => {
|
|
121
121
|
//TODO: Implement TOS system wide for Meta AI, communities, and here etc.
|
|
122
122
|
/**tos query */
|
|
123
123
|
await query({
|
|
@@ -140,7 +140,7 @@ const makeNewsletterSocket = (config) => {
|
|
|
140
140
|
]
|
|
141
141
|
});
|
|
142
142
|
const result = await newsletterWMexQuery(undefined, Types_1.QueryIds.CREATE, {
|
|
143
|
-
input: { name, description, settings:
|
|
143
|
+
input: { name, description, settings: null }
|
|
144
144
|
});
|
|
145
145
|
return (0, exports.extractNewsletterMetadata)(result, true);
|
|
146
146
|
},
|
|
@@ -182,7 +182,7 @@ const makeNewsletterSocket = (config) => {
|
|
|
182
182
|
newsletterReactMessage: async (jid, serverId, code) => {
|
|
183
183
|
await query({
|
|
184
184
|
tag: 'message',
|
|
185
|
-
attrs: { to: jid, ...(!code ? { edit: '7' } : {}), type: 'reaction', 'server_id': serverId, id: (0, Utils_1.generateMessageID)() },
|
|
185
|
+
attrs: { to: jid, ...(!code ? { edit: '7' } : {}), type: 'reaction', 'server_id': serverId, id: await config.generateMessageID() ?? (0, Utils_1.generateMessageID)() },
|
|
186
186
|
content: [{
|
|
187
187
|
tag: 'reaction',
|
|
188
188
|
attrs: code ? { code } : {}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import { AxiosRequestConfig } from 'axios';
|
|
1
|
+
import axios, { AxiosRequestConfig } from 'axios';
|
|
3
2
|
import { KeyPair, SignedKeyPair, SocketConfig } from '../Types';
|
|
4
3
|
export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
|
5
4
|
register: (code: string) => Promise<ExistsResponse>;
|
|
6
5
|
requestRegistrationCode: (registrationOptions?: RegistrationOptions) => Promise<ExistsResponse>;
|
|
7
|
-
logger:
|
|
6
|
+
logger: Logger;
|
|
8
7
|
getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
|
|
9
8
|
getCatalog: ({ jid, limit, cursor }: import("../Types").GetCatalogOptions) => Promise<{
|
|
10
9
|
products: import("../Types").Product[];
|
|
11
|
-
nextPageCursor:
|
|
10
|
+
nextPageCursor: any;
|
|
12
11
|
}>;
|
|
13
|
-
getCollections: (jid?: string
|
|
12
|
+
getCollections: (jid?: string, limit?: number) => Promise<{
|
|
14
13
|
collections: import("../Types").CatalogCollection[];
|
|
15
14
|
}>;
|
|
16
15
|
productCreate: (create: import("../Types").ProductCreate) => Promise<import("../Types").Product>;
|
|
@@ -18,27 +17,26 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
|
|
18
17
|
deleted: number;
|
|
19
18
|
}>;
|
|
20
19
|
productUpdate: (productId: string, update: import("../Types").ProductUpdate) => Promise<import("../Types").Product>;
|
|
21
|
-
sendMessageAck: ({ tag, attrs, content }: import("../WABinary").BinaryNode) => Promise<void>;
|
|
20
|
+
sendMessageAck: ({ tag, attrs, content }: import("../WABinary").BinaryNode, errorCode?: number) => Promise<void>;
|
|
22
21
|
sendRetryRequest: (node: import("../WABinary").BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
|
|
23
22
|
offerCall: (toJid: string, isVideo?: boolean) => Promise<{
|
|
24
|
-
id:
|
|
23
|
+
id: any;
|
|
25
24
|
to: string;
|
|
26
25
|
}>;
|
|
27
26
|
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>;
|
|
28
29
|
getPrivacyTokens: (jids: string[]) => Promise<import("../WABinary").BinaryNode>;
|
|
29
30
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
30
31
|
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
|
31
32
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
32
|
-
sendReceipts: (keys: import("../Types").
|
|
33
|
-
getButtonArgs: (message: import("../Types").WAProto.IMessage) =>
|
|
34
|
-
|
|
35
|
-
};
|
|
36
|
-
readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;
|
|
33
|
+
sendReceipts: (keys: import("../Types").WAMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
34
|
+
getButtonArgs: (message: import("../Types").WAProto.IMessage) => import("../WABinary").BinaryNode["attrs"];
|
|
35
|
+
readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
|
|
37
36
|
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
|
38
37
|
getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} | undefined) => Promise<{
|
|
38
|
+
sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
39
|
+
createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: import("../WABinary").BinaryNode["attrs"]) => Promise<{
|
|
42
40
|
nodes: import("../WABinary").BinaryNode[];
|
|
43
41
|
shouldIncludeDeviceIdentity: boolean;
|
|
44
42
|
}>;
|
|
@@ -47,12 +45,14 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
|
|
47
45
|
[_: string]: string;
|
|
48
46
|
}>;
|
|
49
47
|
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
|
|
55
|
+
newsletterUpdateDescription: (jid: string, description?: string) => 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,27 +60,24 @@ 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
|
|
65
|
-
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole
|
|
63
|
+
newsletterAction: (jid: string, type: "follow" | "unfollow" | "mute" | "unmute") => Promise<void>;
|
|
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>;
|
|
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
|
|
71
|
-
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number
|
|
72
|
-
newsletterFetchUpdates: (jid: string, count: number, after?: number
|
|
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[]>;
|
|
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
|
-
*/
|
|
79
76
|
groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
|
|
80
77
|
groupRequestParticipantsList: (jid: string) => Promise<{
|
|
81
78
|
[key: string]: string;
|
|
82
79
|
}[]>;
|
|
83
|
-
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "
|
|
80
|
+
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
|
|
84
81
|
status: string;
|
|
85
82
|
jid: string;
|
|
86
83
|
}[]>;
|
|
@@ -89,27 +86,27 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
|
|
89
86
|
jid: string;
|
|
90
87
|
content: import("../WABinary").BinaryNode;
|
|
91
88
|
}[]>;
|
|
92
|
-
groupUpdateDescription: (jid: string, description?: string
|
|
89
|
+
groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
|
|
93
90
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
94
91
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
95
92
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
96
93
|
groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
|
|
97
94
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
98
95
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
99
|
-
groupSettingUpdate: (jid: string, setting: "announcement" | "
|
|
100
|
-
groupMemberAddMode: (jid: string, mode: "
|
|
96
|
+
groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
|
|
97
|
+
groupMemberAddMode: (jid: string, mode: "admin_add" | "all_member_add") => Promise<void>;
|
|
101
98
|
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
|
|
102
99
|
groupFetchAllParticipating: () => Promise<{
|
|
103
100
|
[_: string]: import("../Types").GroupMetadata;
|
|
104
101
|
}>;
|
|
105
102
|
processingMutex: {
|
|
106
|
-
mutex<T>(code: () => T |
|
|
103
|
+
mutex<T>(code: () => Promise<T> | T): Promise<T>;
|
|
107
104
|
};
|
|
108
105
|
upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
|
|
109
106
|
appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
|
|
110
|
-
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string
|
|
111
|
-
presenceSubscribe: (toJid: string, tcToken?: Buffer
|
|
112
|
-
profilePictureUrl: (jid: string, type?: "
|
|
107
|
+
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
|
|
108
|
+
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
|
|
109
|
+
profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
|
|
113
110
|
onWhatsApp: (...jids: string[]) => Promise<{
|
|
114
111
|
exists: boolean;
|
|
115
112
|
jid: string;
|
|
@@ -131,25 +128,25 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
|
|
131
128
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
132
129
|
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
133
130
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
134
|
-
getBusinessProfile: (jid: string) => Promise<
|
|
131
|
+
getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
|
|
135
132
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
136
133
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
137
|
-
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?:
|
|
134
|
+
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
|
|
138
135
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
139
136
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
140
137
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
141
138
|
removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
142
139
|
star: (jid: string, messages: {
|
|
143
140
|
id: string;
|
|
144
|
-
fromMe?: boolean
|
|
141
|
+
fromMe?: boolean;
|
|
145
142
|
}[], star: boolean) => Promise<void>;
|
|
146
143
|
type: "md";
|
|
147
144
|
ws: any;
|
|
148
145
|
ev: import("../Types").BaileysEventEmitter & {
|
|
149
|
-
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
|
146
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
150
147
|
buffer(): void;
|
|
151
|
-
createBufferedFunction<A extends any[],
|
|
152
|
-
flush(force?: boolean
|
|
148
|
+
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
149
|
+
flush(force?: boolean): boolean;
|
|
153
150
|
isBuffering(): boolean;
|
|
154
151
|
};
|
|
155
152
|
authState: {
|
|
@@ -159,18 +156,18 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
|
|
|
159
156
|
signalRepository: import("../Types").SignalRepository;
|
|
160
157
|
user: import("../Types").Contact | undefined;
|
|
161
158
|
generateMessageTag: () => string;
|
|
162
|
-
query: (node: import("../WABinary").BinaryNode, timeoutMs?: number
|
|
163
|
-
waitForMessage: <
|
|
159
|
+
query: (node: import("../WABinary").BinaryNode, timeoutMs?: number) => Promise<import("../WABinary").BinaryNode>;
|
|
160
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<T>;
|
|
164
161
|
waitForSocketOpen: () => Promise<void>;
|
|
165
162
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
166
163
|
sendNode: (frame: import("../WABinary").BinaryNode) => Promise<void>;
|
|
167
|
-
logout: (msg?: string
|
|
164
|
+
logout: (msg?: string) => Promise<void>;
|
|
168
165
|
end: (error: Error | undefined) => void;
|
|
169
|
-
onUnexpectedError: (err: Error |
|
|
166
|
+
onUnexpectedError: (err: Error | axios, msg: string) => void;
|
|
170
167
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
171
168
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
172
|
-
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
173
|
-
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number
|
|
169
|
+
requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
|
|
170
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number) => Promise<void>;
|
|
174
171
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<import("../WABinary").BinaryNode>;
|
|
175
172
|
};
|
|
176
173
|
export interface RegistrationData {
|
|
@@ -215,13 +212,13 @@ export declare function registrationParams(params: RegistrationParams): {
|
|
|
215
212
|
lg: string;
|
|
216
213
|
lc: string;
|
|
217
214
|
mistyped: string;
|
|
218
|
-
authkey:
|
|
219
|
-
e_regid:
|
|
215
|
+
authkey: any;
|
|
216
|
+
e_regid: any;
|
|
220
217
|
e_keytype: string;
|
|
221
|
-
e_ident:
|
|
218
|
+
e_ident: any;
|
|
222
219
|
e_skey_id: string;
|
|
223
|
-
e_skey_val:
|
|
224
|
-
e_skey_sig:
|
|
220
|
+
e_skey_val: any;
|
|
221
|
+
e_skey_sig: any;
|
|
225
222
|
fdid: string;
|
|
226
223
|
network_ratio_type: string;
|
|
227
224
|
expid: string;
|
|
@@ -230,7 +227,7 @@ export declare function registrationParams(params: RegistrationParams): {
|
|
|
230
227
|
pid: string;
|
|
231
228
|
id: string;
|
|
232
229
|
backup_token: string;
|
|
233
|
-
token:
|
|
230
|
+
token: any;
|
|
234
231
|
fraud_checkpoint_code: string | undefined;
|
|
235
232
|
};
|
|
236
233
|
/**
|
|
@@ -247,7 +244,7 @@ export declare function mobileRegister(params: RegistrationParams & {
|
|
|
247
244
|
/**
|
|
248
245
|
* Encrypts the given string as AEAD aes-256-gcm with the public whatsapp key and a random keypair.
|
|
249
246
|
*/
|
|
250
|
-
export declare function mobileRegisterEncrypt(data: string):
|
|
247
|
+
export declare function mobileRegisterEncrypt(data: string): any;
|
|
251
248
|
export declare function mobileRegisterFetch(path: string, opts?: AxiosRequestConfig): Promise<ExistsResponse>;
|
|
252
249
|
export interface ExistsResponse {
|
|
253
250
|
status: 'fail' | 'sent';
|
|
@@ -3,7 +3,13 @@ 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.
|
|
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;
|
|
7
13
|
/* eslint-disable camelcase */
|
|
8
14
|
const axios_1 = __importDefault(require("axios"));
|
|
9
15
|
const Defaults_1 = require("../Defaults");
|
|
@@ -89,7 +95,6 @@ function registrationParams(params) {
|
|
|
89
95
|
fraud_checkpoint_code: params.captcha,
|
|
90
96
|
};
|
|
91
97
|
}
|
|
92
|
-
exports.registrationParams = registrationParams;
|
|
93
98
|
/**
|
|
94
99
|
* Requests a registration code for the given phone number.
|
|
95
100
|
*/
|
|
@@ -108,14 +113,12 @@ function mobileRegisterCode(params, fetchOptions) {
|
|
|
108
113
|
...fetchOptions,
|
|
109
114
|
});
|
|
110
115
|
}
|
|
111
|
-
exports.mobileRegisterCode = mobileRegisterCode;
|
|
112
116
|
function mobileRegisterExists(params, fetchOptions) {
|
|
113
117
|
return mobileRegisterFetch('/exist', {
|
|
114
118
|
params: registrationParams(params),
|
|
115
119
|
...fetchOptions
|
|
116
120
|
});
|
|
117
121
|
}
|
|
118
|
-
exports.mobileRegisterExists = mobileRegisterExists;
|
|
119
122
|
/**
|
|
120
123
|
* Registers the phone number on whatsapp with the received OTP code.
|
|
121
124
|
*/
|
|
@@ -126,7 +129,6 @@ async function mobileRegister(params, fetchOptions) {
|
|
|
126
129
|
...fetchOptions,
|
|
127
130
|
});
|
|
128
131
|
}
|
|
129
|
-
exports.mobileRegister = mobileRegister;
|
|
130
132
|
/**
|
|
131
133
|
* Encrypts the given string as AEAD aes-256-gcm with the public whatsapp key and a random keypair.
|
|
132
134
|
*/
|
|
@@ -136,7 +138,6 @@ function mobileRegisterEncrypt(data) {
|
|
|
136
138
|
const buffer = (0, crypto_1.aesEncryptGCM)(Buffer.from(data), new Uint8Array(key), Buffer.alloc(12), Buffer.alloc(0));
|
|
137
139
|
return Buffer.concat([Buffer.from(keypair.public), buffer]).toString('base64url');
|
|
138
140
|
}
|
|
139
|
-
exports.mobileRegisterEncrypt = mobileRegisterEncrypt;
|
|
140
141
|
async function mobileRegisterFetch(path, opts = {}) {
|
|
141
142
|
let url = `${Defaults_1.MOBILE_REGISTRATION_ENDPOINT}${path}`;
|
|
142
143
|
if (opts.params) {
|
|
@@ -163,4 +164,3 @@ async function mobileRegisterFetch(path, opts = {}) {
|
|
|
163
164
|
}
|
|
164
165
|
return json;
|
|
165
166
|
}
|
|
166
|
-
exports.mobileRegisterFetch = mobileRegisterFetch;
|
package/lib/Socket/socket.d.ts
CHANGED
package/lib/Socket/socket.js
CHANGED
|
@@ -28,6 +28,12 @@ const makeSocket = (config) => {
|
|
|
28
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
29
|
url.searchParams.append('ED', authState.creds.routingInfo.toString('base64url'));
|
|
30
30
|
}
|
|
31
|
+
if (config.mobile || url.protocol === 'tcp:') {
|
|
32
|
+
throw new boom_1.Boom('Mobile API is not supported anymore', { statusCode: Types_1.DisconnectReason.loggedOut });
|
|
33
|
+
}
|
|
34
|
+
if (url.protocol === 'wss' && ((_a = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _a === void 0 ? void 0 : _a.routingInfo)) {
|
|
35
|
+
url.searchParams.append('ED', authState.creds.routingInfo.toString('base64url'));
|
|
36
|
+
}
|
|
31
37
|
const ws = config.socket ? config.socket : config.mobile ? new Client_1.MobileSocketClient(url, config) : new Client_1.WebSocketClient(url, config);
|
|
32
38
|
ws.connect();
|
|
33
39
|
const ev = (0, Utils_1.makeEventBuffer)(logger);
|
|
@@ -157,7 +163,7 @@ const makeSocket = (config) => {
|
|
|
157
163
|
const result = await awaitNextMessage(init);
|
|
158
164
|
const handshake = WAProto_1.proto.HandshakeMessage.decode(result);
|
|
159
165
|
logger.trace({ handshake }, 'handshake recv from WA');
|
|
160
|
-
const keyEnc = noise.processHandshake(handshake, creds.noiseKey);
|
|
166
|
+
const keyEnc = await noise.processHandshake(handshake, creds.noiseKey);
|
|
161
167
|
let node;
|
|
162
168
|
if (config.mobile) {
|
|
163
169
|
node = (0, Utils_1.generateMobileNode)(config);
|
|
@@ -177,7 +183,7 @@ const makeSocket = (config) => {
|
|
|
177
183
|
payload: payloadEnc,
|
|
178
184
|
},
|
|
179
185
|
}).finish());
|
|
180
|
-
noise.finishInit();
|
|
186
|
+
await noise.finishInit();
|
|
181
187
|
startKeepAliveRequest();
|
|
182
188
|
};
|
|
183
189
|
const getAvailablePreKeysOnServer = async () => {
|
|
@@ -232,11 +238,11 @@ const makeSocket = (config) => {
|
|
|
232
238
|
const l0 = frame.tag;
|
|
233
239
|
const l1 = frame.attrs || {};
|
|
234
240
|
const l2 = Array.isArray(frame.content) ? (_a = frame.content[0]) === null || _a === void 0 ? void 0 : _a.tag : '';
|
|
235
|
-
Object.keys(l1)
|
|
241
|
+
for (const key of Object.keys(l1)) {
|
|
236
242
|
anyTriggered = ws.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${l0},${key}:${l1[key]},${l2}`, frame) || anyTriggered;
|
|
237
243
|
anyTriggered = ws.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${l0},${key}:${l1[key]}`, frame) || anyTriggered;
|
|
238
244
|
anyTriggered = ws.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${l0},${key}`, frame) || anyTriggered;
|
|
239
|
-
}
|
|
245
|
+
}
|
|
240
246
|
anyTriggered = ws.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${l0},,${l2}`, frame) || anyTriggered;
|
|
241
247
|
anyTriggered = ws.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${l0}`, frame) || anyTriggered;
|
|
242
248
|
if (!anyTriggered && logger.level === 'debug') {
|
|
@@ -365,24 +371,17 @@ const makeSocket = (config) => {
|
|
|
365
371
|
}
|
|
366
372
|
end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }));
|
|
367
373
|
};
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
/** hey bro, if you delete this text */
|
|
371
|
-
/** you are the most cursed human being who likes to claim other people's property 😹🙌🏻 */
|
|
372
|
-
const requestPairingCode = async (phoneNumber, pairKey) => {
|
|
374
|
+
const requestPairingCode = async (phoneNumber, pairKey = "ABCD1234") => {
|
|
373
375
|
if (pairKey) {
|
|
374
|
-
|
|
376
|
+
authState.creds.pairingCode = pairKey.toUpperCase()
|
|
375
377
|
} else {
|
|
376
378
|
authState.creds.pairingCode = (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5));
|
|
377
379
|
}
|
|
378
|
-
|
|
379
380
|
authState.creds.me = {
|
|
380
381
|
id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
|
|
381
382
|
name: '~'
|
|
382
383
|
};
|
|
383
|
-
|
|
384
384
|
ev.emit('creds.update', authState.creds);
|
|
385
|
-
|
|
386
385
|
await sendNode({
|
|
387
386
|
tag: 'iq',
|
|
388
387
|
attrs: {
|
|
@@ -397,6 +396,7 @@ const makeSocket = (config) => {
|
|
|
397
396
|
attrs: {
|
|
398
397
|
jid: authState.creds.me.id,
|
|
399
398
|
stage: 'companion_hello',
|
|
399
|
+
// eslint-disable-next-line camelcase
|
|
400
400
|
should_show_push_notification: 'true'
|
|
401
401
|
},
|
|
402
402
|
content: [
|
|
@@ -423,20 +423,18 @@ const makeSocket = (config) => {
|
|
|
423
423
|
{
|
|
424
424
|
tag: 'link_code_pairing_nonce',
|
|
425
425
|
attrs: {},
|
|
426
|
-
content:
|
|
426
|
+
content: '0'
|
|
427
427
|
}
|
|
428
428
|
]
|
|
429
429
|
}
|
|
430
430
|
]
|
|
431
431
|
});
|
|
432
|
-
|
|
433
432
|
return authState.creds.pairingCode;
|
|
434
433
|
};
|
|
435
|
-
|
|
436
434
|
async function generatePairingKey() {
|
|
437
435
|
const salt = (0, crypto_1.randomBytes)(32);
|
|
438
436
|
const randomIv = (0, crypto_1.randomBytes)(16);
|
|
439
|
-
const key = (0, Utils_1.derivePairingCodeKey)(authState.creds.pairingCode, salt);
|
|
437
|
+
const key = await (0, Utils_1.derivePairingCodeKey)(authState.creds.pairingCode, salt);
|
|
440
438
|
const ciphered = (0, Utils_1.aesEncryptCTR)(authState.creds.pairingEphemeralKeyPair.public, key, randomIv);
|
|
441
439
|
return Buffer.concat([salt, randomIv, ciphered]);
|
|
442
440
|
}
|
|
@@ -523,12 +521,18 @@ const makeSocket = (config) => {
|
|
|
523
521
|
});
|
|
524
522
|
// login complete
|
|
525
523
|
ws.on('CB:success', async (node) => {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
524
|
+
try {
|
|
525
|
+
await uploadPreKeysToServerIfRequired();
|
|
526
|
+
await sendPassiveIq('active');
|
|
527
|
+
logger.info('opened connection to WA');
|
|
528
|
+
clearTimeout(qrTimer); // will never happen in all likelyhood -- but just in case WA sends success on first try
|
|
529
|
+
ev.emit('creds.update', { me: { ...authState.creds.me, lid: node.attrs.lid } });
|
|
530
|
+
ev.emit('connection.update', { connection: 'open' });
|
|
531
|
+
}
|
|
532
|
+
catch (err) {
|
|
533
|
+
logger.error({ err }, 'error opening connection');
|
|
534
|
+
end(err);
|
|
535
|
+
}
|
|
532
536
|
});
|
|
533
537
|
ws.on('CB:stream:error', (node) => {
|
|
534
538
|
logger.error({ node }, 'stream errored out');
|
|
@@ -543,11 +547,20 @@ const makeSocket = (config) => {
|
|
|
543
547
|
ws.on('CB:ib,,downgrade_webclient', () => {
|
|
544
548
|
end(new boom_1.Boom('Multi-device beta not joined', { statusCode: Types_1.DisconnectReason.multideviceMismatch }));
|
|
545
549
|
});
|
|
550
|
+
ws.on('CB:ib,,offline_preview', (node) => {
|
|
551
|
+
logger.info('offline preview received', JSON.stringify(node));
|
|
552
|
+
sendNode({
|
|
553
|
+
tag: 'ib',
|
|
554
|
+
attrs: {},
|
|
555
|
+
content: [{ tag: 'offline_batch', attrs: { count: '100' } }]
|
|
556
|
+
});
|
|
557
|
+
});
|
|
546
558
|
ws.on('CB:ib,,edge_routing', (node) => {
|
|
547
559
|
const edgeRoutingNode = (0, WABinary_1.getBinaryNodeChild)(node, 'edge_routing');
|
|
548
560
|
const routingInfo = (0, WABinary_1.getBinaryNodeChild)(edgeRoutingNode, 'routing_info');
|
|
549
561
|
if (routingInfo === null || routingInfo === void 0 ? void 0 : routingInfo.content) {
|
|
550
562
|
authState.creds.routingInfo = Buffer.from(routingInfo === null || routingInfo === void 0 ? void 0 : routingInfo.content);
|
|
563
|
+
ev.emit('creds.update', authState.creds);
|
|
551
564
|
}
|
|
552
565
|
});
|
|
553
566
|
let didStartBuffer = false;
|