@hbmodsofc/baileys 1.5.2 → 1.7.7
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 +19671 -152026
- package/lib/Defaults/index.d.ts +12 -8
- package/lib/Defaults/index.js +90 -124
- package/lib/Signal/Group/group_cipher.d.ts +0 -1
- package/lib/Signal/Group/group_cipher.js +28 -39
- package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
- package/lib/Signal/Group/sender-chain-key.js +9 -2
- 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 +47 -16
- package/lib/Signal/libsignal.d.ts +7 -3
- package/lib/Signal/libsignal.js +224 -39
- package/lib/Signal/lid-mapping.d.ts +26 -0
- package/lib/Signal/lid-mapping.js +146 -0
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +2 -3
- package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +1 -3
- package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +1 -1
- package/lib/Socket/Client/{web-socket-client.js → websocket.js} +10 -16
- package/lib/Socket/business.d.ts +94 -78
- package/lib/Socket/business.js +130 -11
- package/lib/Socket/chats.d.ts +63 -233
- package/lib/Socket/chats.js +234 -184
- package/lib/Socket/communities.d.ts +232 -0
- package/lib/Socket/communities.js +402 -0
- package/lib/Socket/groups.d.ts +62 -41
- package/lib/Socket/groups.js +76 -64
- package/lib/Socket/index.d.ts +129 -83
- package/lib/Socket/index.js +13 -6
- package/lib/Socket/messages-recv.d.ts +59 -48
- package/lib/Socket/messages-recv.js +516 -371
- package/lib/Socket/messages-send.d.ts +86 -67
- package/lib/Socket/messages-send.js +1091 -1
- package/lib/Socket/mex.d.ts +2 -0
- package/lib/Socket/mex.js +45 -0
- package/lib/Socket/newsletter.d.ts +76 -64
- package/lib/Socket/newsletter.js +184 -1
- package/lib/Socket/socket.d.ts +19 -13
- package/lib/Socket/socket.js +805 -1
- package/lib/Types/Auth.d.ts +4 -10
- package/lib/Types/Bussines.d.ts +24 -0
- package/lib/Types/Bussines.js +2 -0
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +29 -9
- package/lib/Types/Chat.js +7 -1
- package/lib/Types/Contact.d.ts +5 -1
- package/lib/Types/Events.d.ts +55 -14
- package/lib/Types/GroupMetadata.d.ts +15 -5
- 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 +75 -49
- package/lib/Types/Message.js +10 -7
- package/lib/Types/Newsletter.d.ts +129 -98
- package/lib/Types/Newsletter.js +33 -38
- package/lib/Types/Product.d.ts +1 -1
- package/lib/Types/Signal.d.ts +29 -1
- package/lib/Types/Socket.d.ts +48 -22
- package/lib/Types/State.d.ts +13 -2
- package/lib/Types/State.js +12 -0
- package/lib/Types/USync.d.ts +1 -1
- package/lib/Types/index.d.ts +10 -3
- package/lib/Types/index.js +2 -2
- package/lib/Utils/auth-utils.d.ts +3 -3
- package/lib/Utils/auth-utils.js +378 -102
- package/lib/Utils/baileys-event-stream.js +1 -1
- package/lib/Utils/business.d.ts +2 -2
- package/lib/Utils/business.js +19 -13
- package/lib/Utils/chat-utils.d.ts +21 -22
- package/lib/Utils/chat-utils.js +201 -154
- package/lib/Utils/crypto.d.ts +18 -19
- package/lib/Utils/crypto.js +78 -37
- package/lib/Utils/decode-wa-message.d.ts +34 -7
- package/lib/Utils/decode-wa-message.js +138 -66
- package/lib/Utils/event-buffer.d.ts +6 -8
- package/lib/Utils/event-buffer.js +81 -43
- package/lib/Utils/generics.d.ts +27 -27
- package/lib/Utils/generics.js +128 -133
- package/lib/Utils/history.d.ts +9 -5
- package/lib/Utils/history.js +17 -23
- package/lib/Utils/index.d.ts +2 -0
- package/lib/Utils/index.js +2 -0
- package/lib/Utils/lidToJid-test.d.ts +11 -0
- package/lib/Utils/lidToJid-test.js +27 -0
- package/lib/Utils/link-preview.d.ts +4 -4
- package/lib/Utils/link-preview.js +40 -12
- package/lib/Utils/logger.d.ts +11 -3
- package/lib/Utils/lt-hash.d.ts +8 -8
- package/lib/Utils/lt-hash.js +23 -24
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/make-mutex.js +3 -2
- package/lib/Utils/message-retry-manager.d.ts +81 -0
- package/lib/Utils/message-retry-manager.js +152 -0
- package/lib/Utils/messages-media.d.ts +37 -41
- package/lib/Utils/messages-media.js +252 -368
- package/lib/Utils/messages.d.ts +13 -15
- package/lib/Utils/messages.js +274 -261
- package/lib/Utils/noise-handler.d.ts +13 -15
- package/lib/Utils/noise-handler.js +20 -26
- package/lib/Utils/process-message.d.ts +9 -8
- package/lib/Utils/process-message.js +157 -93
- package/lib/Utils/signal.d.ts +6 -5
- package/lib/Utils/signal.js +37 -29
- package/lib/Utils/use-multi-file-auth-state.d.ts +1 -2
- package/lib/Utils/use-multi-file-auth-state.js +12 -7
- package/lib/Utils/validate-connection.d.ts +5 -6
- package/lib/Utils/validate-connection.js +39 -97
- package/lib/WABinary/constants.d.ts +24 -27
- package/lib/WABinary/constants.js +1276 -13
- package/lib/WABinary/decode.d.ts +3 -4
- package/lib/WABinary/decode.js +28 -14
- package/lib/WABinary/encode.d.ts +1 -2
- package/lib/WABinary/encode.js +134 -147
- package/lib/WABinary/generic-utils.d.ts +4 -7
- package/lib/WABinary/generic-utils.js +40 -125
- package/lib/WABinary/jid-utils.d.ts +13 -8
- package/lib/WABinary/jid-utils.js +27 -16
- package/lib/WAM/BinaryInfo.d.ts +2 -11
- package/lib/WAM/constants.d.ts +3 -2
- package/lib/WAM/constants.js +2252 -2359
- package/lib/WAM/encode.d.ts +1 -2
- package/lib/WAM/encode.js +8 -11
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +3 -4
- 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 +5 -6
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +4 -3
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +11 -3
- package/lib/WAUSync/USyncQuery.d.ts +2 -2
- package/lib/WAUSync/USyncQuery.js +19 -15
- 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 -102
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Signal/Group/queue-job.d.ts +0 -1
- package/lib/Signal/Group/queue-job.js +0 -57
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/hbmods.d.ts +0 -253
- package/lib/Socket/hbmods.js +0 -1
- package/lib/Socket/registration.d.ts +0 -267
- package/lib/Socket/registration.js +0 -166
- package/lib/Socket/usync.d.ts +0 -36
- package/lib/Socket/usync.js +0 -70
- /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
|
@@ -1,103 +1,134 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
export declare enum XWAPaths {
|
|
2
|
+
xwa2_newsletter_create = "xwa2_newsletter_create",
|
|
3
|
+
xwa2_newsletter_subscribers = "xwa2_newsletter_subscribers",
|
|
4
|
+
xwa2_newsletter_view = "xwa2_newsletter_view",
|
|
5
|
+
xwa2_newsletter_metadata = "xwa2_newsletter",
|
|
6
|
+
xwa2_newsletter_admin_count = "xwa2_newsletter_admin",
|
|
7
|
+
xwa2_newsletter_mute_v2 = "xwa2_newsletter_mute_v2",
|
|
8
|
+
xwa2_newsletter_unmute_v2 = "xwa2_newsletter_unmute_v2",
|
|
9
|
+
xwa2_newsletter_follow = "xwa2_newsletter_follow",
|
|
10
|
+
xwa2_newsletter_unfollow = "xwa2_newsletter_unfollow",
|
|
11
|
+
xwa2_newsletter_change_owner = "xwa2_newsletter_change_owner",
|
|
12
|
+
xwa2_newsletter_demote = "xwa2_newsletter_demote",
|
|
13
|
+
xwa2_newsletter_delete_v2 = "xwa2_newsletter_delete_v2"
|
|
12
14
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
description: string
|
|
27
|
-
/** timestamp of last description modification of newsletter */
|
|
28
|
-
descriptionTime: number
|
|
29
|
-
/** invite code of newsletter */
|
|
30
|
-
invite: string
|
|
31
|
-
/** direct path of picture */
|
|
32
|
-
picture: string | null
|
|
33
|
-
/** direct path of picture preview (lower quality) */
|
|
34
|
-
preview: string | null
|
|
35
|
-
/** reaction mode of newsletter */
|
|
36
|
-
reaction_codes?: NewsletterReactionMode
|
|
37
|
-
/** subscribers count of newsletter */
|
|
38
|
-
subscribers: number
|
|
39
|
-
/** verification state of newsletter */
|
|
40
|
-
verification: NewsletterVerification
|
|
41
|
-
/** viewer metadata */
|
|
42
|
-
viewer_metadata: NewsletterViewerMetadata
|
|
15
|
+
export declare enum QueryIds {
|
|
16
|
+
CREATE = "8823471724422422",
|
|
17
|
+
UPDATE_METADATA = "24250201037901610",
|
|
18
|
+
METADATA = "6563316087068696",
|
|
19
|
+
SUBSCRIBERS = "9783111038412085",
|
|
20
|
+
FOLLOW = "7871414976211147",
|
|
21
|
+
UNFOLLOW = "7238632346214362",
|
|
22
|
+
MUTE = "29766401636284406",
|
|
23
|
+
UNMUTE = "9864994326891137",
|
|
24
|
+
ADMIN_COUNT = "7130823597031706",
|
|
25
|
+
CHANGE_OWNER = "7341777602580933",
|
|
26
|
+
DEMOTE = "6551828931592903",
|
|
27
|
+
DELETE = "30062808666639665"
|
|
43
28
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
29
|
+
export type NewsletterUpdate = {
|
|
30
|
+
name?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
picture?: string;
|
|
33
|
+
};
|
|
34
|
+
export interface NewsletterCreateResponse {
|
|
35
|
+
id: string;
|
|
36
|
+
state: {
|
|
37
|
+
type: string;
|
|
38
|
+
};
|
|
39
|
+
thread_metadata: {
|
|
40
|
+
creation_time: string;
|
|
41
|
+
description: {
|
|
42
|
+
id: string;
|
|
43
|
+
text: string;
|
|
44
|
+
update_time: string;
|
|
45
|
+
};
|
|
46
|
+
handle: string | null;
|
|
47
|
+
invite: string;
|
|
48
|
+
name: {
|
|
49
|
+
id: string;
|
|
50
|
+
text: string;
|
|
51
|
+
update_time: string;
|
|
52
|
+
};
|
|
53
|
+
picture: {
|
|
54
|
+
direct_path: string;
|
|
55
|
+
id: string;
|
|
56
|
+
type: string;
|
|
57
|
+
};
|
|
58
|
+
preview: {
|
|
59
|
+
direct_path: string;
|
|
60
|
+
id: string;
|
|
61
|
+
type: string;
|
|
62
|
+
};
|
|
63
|
+
subscribers_count: string;
|
|
64
|
+
verification: 'VERIFIED' | 'UNVERIFIED';
|
|
65
|
+
};
|
|
66
|
+
viewer_metadata: {
|
|
67
|
+
mute: 'ON' | 'OFF';
|
|
68
|
+
role: NewsletterViewRole;
|
|
69
|
+
};
|
|
53
70
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
71
|
+
export interface NewsletterCreateResponse {
|
|
72
|
+
id: string;
|
|
73
|
+
state: {
|
|
74
|
+
type: string;
|
|
75
|
+
};
|
|
76
|
+
thread_metadata: {
|
|
77
|
+
creation_time: string;
|
|
78
|
+
description: {
|
|
79
|
+
id: string;
|
|
80
|
+
text: string;
|
|
81
|
+
update_time: string;
|
|
82
|
+
};
|
|
83
|
+
handle: string | null;
|
|
84
|
+
invite: string;
|
|
85
|
+
name: {
|
|
86
|
+
id: string;
|
|
87
|
+
text: string;
|
|
88
|
+
update_time: string;
|
|
89
|
+
};
|
|
90
|
+
picture: {
|
|
91
|
+
direct_path: string;
|
|
92
|
+
id: string;
|
|
93
|
+
type: string;
|
|
94
|
+
};
|
|
95
|
+
preview: {
|
|
96
|
+
direct_path: string;
|
|
97
|
+
id: string;
|
|
98
|
+
type: string;
|
|
99
|
+
};
|
|
100
|
+
subscribers_count: string;
|
|
101
|
+
verification: 'VERIFIED' | 'UNVERIFIED';
|
|
102
|
+
};
|
|
103
|
+
viewer_metadata: {
|
|
104
|
+
mute: 'ON' | 'OFF';
|
|
105
|
+
role: NewsletterViewRole;
|
|
106
|
+
};
|
|
61
107
|
}
|
|
62
|
-
|
|
63
|
-
export
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
108
|
+
export type NewsletterViewRole = 'ADMIN' | 'GUEST' | 'OWNER' | 'SUBSCRIBER';
|
|
109
|
+
export interface NewsletterMetadata {
|
|
110
|
+
id: string;
|
|
111
|
+
owner?: string;
|
|
112
|
+
name: string;
|
|
113
|
+
description?: string;
|
|
114
|
+
invite?: string;
|
|
115
|
+
creation_time?: number;
|
|
116
|
+
subscribers?: number;
|
|
117
|
+
picture?: {
|
|
118
|
+
url?: string;
|
|
119
|
+
directPath?: string;
|
|
120
|
+
mediaKey?: string;
|
|
121
|
+
id?: string;
|
|
122
|
+
};
|
|
123
|
+
verification?: 'VERIFIED' | 'UNVERIFIED';
|
|
124
|
+
reaction_codes?: {
|
|
125
|
+
code: string;
|
|
126
|
+
count: number;
|
|
127
|
+
}[];
|
|
128
|
+
mute_state?: 'ON' | 'OFF';
|
|
129
|
+
thread_metadata?: {
|
|
130
|
+
creation_time?: number;
|
|
131
|
+
name?: string;
|
|
132
|
+
description?: string;
|
|
133
|
+
};
|
|
72
134
|
}
|
|
73
|
-
|
|
74
|
-
export const MexOperations = {
|
|
75
|
-
PROMOTE: "NotificationNewsletterAdminPromote",
|
|
76
|
-
DEMOTE: "NotificationNewsletterAdminDemote",
|
|
77
|
-
UPDATE: "NotificationNewsletterUpdate"
|
|
78
|
-
} as const
|
|
79
|
-
|
|
80
|
-
export const XWAPaths = {
|
|
81
|
-
PROMOTE: "xwa2_notify_newsletter_admin_promote",
|
|
82
|
-
DEMOTE: "xwa2_notify_newsletter_admin_demote",
|
|
83
|
-
ADMIN_COUNT: "xwa2_newsletter_admin",
|
|
84
|
-
CREATE: "xwa2_newsletter_create",
|
|
85
|
-
NEWSLETTER: "xwa2_newsletter",
|
|
86
|
-
SUBSCRIBED: "xwa2_newsletter_subscribed",
|
|
87
|
-
METADATA_UPDATE: "xwa2_notify_newsletter_on_metadata_update"
|
|
88
|
-
} as const
|
|
89
|
-
|
|
90
|
-
export const QueryIds = {
|
|
91
|
-
JOB_MUTATION: "7150902998257522",
|
|
92
|
-
METADATA: "6620195908089573",
|
|
93
|
-
UNFOLLOW: "7238632346214362",
|
|
94
|
-
FOLLOW: "7871414976211147",
|
|
95
|
-
UNMUTE: "7337137176362961",
|
|
96
|
-
MUTE: "25151904754424642",
|
|
97
|
-
CREATE: "6996806640408138",
|
|
98
|
-
ADMIN_COUNT: "7130823597031706",
|
|
99
|
-
CHANGE_OWNER: "7341777602580933",
|
|
100
|
-
DELETE: "8316537688363079",
|
|
101
|
-
DEMOTE: "6551828931592903",
|
|
102
|
-
SUBSCRIBED: "6388546374527196"
|
|
103
|
-
} as const
|
package/lib/Types/Newsletter.js
CHANGED
|
@@ -1,38 +1,33 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
exports.MexOperations = MexOperations
|
|
37
|
-
exports.XWAPaths = XWAPaths
|
|
38
|
-
exports.QueryIds = QueryIds
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueryIds = exports.XWAPaths = void 0;
|
|
4
|
+
var XWAPaths;
|
|
5
|
+
(function (XWAPaths) {
|
|
6
|
+
XWAPaths["xwa2_newsletter_create"] = "xwa2_newsletter_create";
|
|
7
|
+
XWAPaths["xwa2_newsletter_subscribers"] = "xwa2_newsletter_subscribers";
|
|
8
|
+
XWAPaths["xwa2_newsletter_view"] = "xwa2_newsletter_view";
|
|
9
|
+
XWAPaths["xwa2_newsletter_metadata"] = "xwa2_newsletter";
|
|
10
|
+
XWAPaths["xwa2_newsletter_admin_count"] = "xwa2_newsletter_admin";
|
|
11
|
+
XWAPaths["xwa2_newsletter_mute_v2"] = "xwa2_newsletter_mute_v2";
|
|
12
|
+
XWAPaths["xwa2_newsletter_unmute_v2"] = "xwa2_newsletter_unmute_v2";
|
|
13
|
+
XWAPaths["xwa2_newsletter_follow"] = "xwa2_newsletter_follow";
|
|
14
|
+
XWAPaths["xwa2_newsletter_unfollow"] = "xwa2_newsletter_unfollow";
|
|
15
|
+
XWAPaths["xwa2_newsletter_change_owner"] = "xwa2_newsletter_change_owner";
|
|
16
|
+
XWAPaths["xwa2_newsletter_demote"] = "xwa2_newsletter_demote";
|
|
17
|
+
XWAPaths["xwa2_newsletter_delete_v2"] = "xwa2_newsletter_delete_v2";
|
|
18
|
+
})(XWAPaths || (exports.XWAPaths = XWAPaths = {}));
|
|
19
|
+
var QueryIds;
|
|
20
|
+
(function (QueryIds) {
|
|
21
|
+
QueryIds["CREATE"] = "8823471724422422";
|
|
22
|
+
QueryIds["UPDATE_METADATA"] = "24250201037901610";
|
|
23
|
+
QueryIds["METADATA"] = "6563316087068696";
|
|
24
|
+
QueryIds["SUBSCRIBERS"] = "9783111038412085";
|
|
25
|
+
QueryIds["FOLLOW"] = "7871414976211147";
|
|
26
|
+
QueryIds["UNFOLLOW"] = "7238632346214362";
|
|
27
|
+
QueryIds["MUTE"] = "29766401636284406";
|
|
28
|
+
QueryIds["UNMUTE"] = "9864994326891137";
|
|
29
|
+
QueryIds["ADMIN_COUNT"] = "7130823597031706";
|
|
30
|
+
QueryIds["CHANGE_OWNER"] = "7341777602580933";
|
|
31
|
+
QueryIds["DEMOTE"] = "6551828931592903";
|
|
32
|
+
QueryIds["DELETE"] = "30062808666639665";
|
|
33
|
+
})(QueryIds || (exports.QueryIds = QueryIds = {}));
|
package/lib/Types/Product.d.ts
CHANGED
package/lib/Types/Signal.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { proto } from '../../WAProto';
|
|
1
|
+
import { proto } from '../../WAProto/index.js';
|
|
2
|
+
import type { LIDMappingStore } from '../Signal/lid-mapping';
|
|
2
3
|
type DecryptGroupSignalOpts = {
|
|
3
4
|
group: string;
|
|
4
5
|
authorJid: string;
|
|
@@ -17,6 +18,11 @@ type EncryptMessageOpts = {
|
|
|
17
18
|
jid: string;
|
|
18
19
|
data: Uint8Array;
|
|
19
20
|
};
|
|
21
|
+
type EncryptMessageWithWireOpts = {
|
|
22
|
+
encryptionJid: string;
|
|
23
|
+
wireJid: string;
|
|
24
|
+
data: Uint8Array;
|
|
25
|
+
};
|
|
20
26
|
type EncryptGroupMessageOpts = {
|
|
21
27
|
group: string;
|
|
22
28
|
data: Uint8Array;
|
|
@@ -47,11 +53,33 @@ export type SignalRepository = {
|
|
|
47
53
|
type: 'pkmsg' | 'msg';
|
|
48
54
|
ciphertext: Uint8Array;
|
|
49
55
|
}>;
|
|
56
|
+
encryptMessageWithWire(opts: EncryptMessageWithWireOpts): Promise<{
|
|
57
|
+
type: 'pkmsg' | 'msg';
|
|
58
|
+
ciphertext: Uint8Array;
|
|
59
|
+
wireJid: string;
|
|
60
|
+
}>;
|
|
50
61
|
encryptGroupMessage(opts: EncryptGroupMessageOpts): Promise<{
|
|
51
62
|
senderKeyDistributionMessage: Uint8Array;
|
|
52
63
|
ciphertext: Uint8Array;
|
|
53
64
|
}>;
|
|
54
65
|
injectE2ESession(opts: E2ESessionOpts): Promise<void>;
|
|
66
|
+
validateSession(jid: string): Promise<{
|
|
67
|
+
exists: boolean;
|
|
68
|
+
reason?: string;
|
|
69
|
+
}>;
|
|
55
70
|
jidToSignalProtocolAddress(jid: string): string;
|
|
71
|
+
migrateSession(fromJids: string[], toJid: string): Promise<{
|
|
72
|
+
migrated: number;
|
|
73
|
+
skipped: number;
|
|
74
|
+
total: number;
|
|
75
|
+
}>;
|
|
76
|
+
validateSession(jid: string): Promise<{
|
|
77
|
+
exists: boolean;
|
|
78
|
+
reason?: string;
|
|
79
|
+
}>;
|
|
80
|
+
deleteSession(jids: string[]): Promise<void>;
|
|
56
81
|
};
|
|
82
|
+
export interface SignalRepositoryWithLIDStore extends SignalRepository {
|
|
83
|
+
lidMapping: LIDMappingStore;
|
|
84
|
+
}
|
|
57
85
|
export {};
|
package/lib/Types/Socket.d.ts
CHANGED
|
@@ -1,24 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { AxiosRequestConfig } from 'axios';
|
|
1
|
+
import type { AxiosRequestConfig } from 'axios';
|
|
4
2
|
import type { Agent } from 'https';
|
|
5
|
-
import type { Logger } from 'pino';
|
|
6
3
|
import type { URL } from 'url';
|
|
7
|
-
import { proto } from '../../WAProto';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
4
|
+
import { proto } from '../../WAProto/index.js';
|
|
5
|
+
import type { ILogger } from '../Utils/logger';
|
|
6
|
+
import type { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth';
|
|
7
|
+
import type { GroupMetadata } from './GroupMetadata';
|
|
8
|
+
import { type MediaConnInfo } from './Message';
|
|
9
|
+
import type { SignalRepositoryWithLIDStore } from './Signal';
|
|
11
10
|
export type WAVersion = [number, number, number];
|
|
12
11
|
export type WABrowserDescription = [string, string, string];
|
|
13
12
|
export type CacheStore = {
|
|
14
13
|
/** get a cached key and change the stats */
|
|
15
|
-
get<T>(key: string): T | undefined;
|
|
14
|
+
get<T>(key: string): Promise<T> | T | undefined;
|
|
16
15
|
/** set a key in the cache */
|
|
17
|
-
set<T>(key: string, value: T): void;
|
|
16
|
+
set<T>(key: string, value: T): Promise<void> | void | number | boolean;
|
|
18
17
|
/** delete a key from the cache */
|
|
19
|
-
del(key: string): void;
|
|
18
|
+
del(key: string): void | Promise<void> | number | boolean;
|
|
20
19
|
/** flush all data */
|
|
21
|
-
flushAll(): void
|
|
20
|
+
flushAll(): void | Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
export type PossiblyExtendedCacheStore = CacheStore & {
|
|
23
|
+
mget?: <T>(keys: string[]) => Promise<Record<string, T | undefined>>;
|
|
24
|
+
mset?: <T>(entries: {
|
|
25
|
+
key: string;
|
|
26
|
+
value: T;
|
|
27
|
+
}[]) => Promise<void> | void | number | boolean;
|
|
28
|
+
mdel?: (keys: string[]) => void | Promise<void> | number | boolean;
|
|
29
|
+
};
|
|
30
|
+
export type PatchedMessageWithRecipientJID = proto.IMessage & {
|
|
31
|
+
recipientJid?: string;
|
|
22
32
|
};
|
|
23
33
|
export type SocketConfig = {
|
|
24
34
|
/** the WS url to connect to WA */
|
|
@@ -29,20 +39,24 @@ export type SocketConfig = {
|
|
|
29
39
|
defaultQueryTimeoutMs: number | undefined;
|
|
30
40
|
/** ping-pong interval for WS connection */
|
|
31
41
|
keepAliveIntervalMs: number;
|
|
32
|
-
/** should baileys use the mobile api instead of the multi device api
|
|
42
|
+
/** should baileys use the mobile api instead of the multi device api
|
|
43
|
+
* @deprecated This feature has been removed
|
|
44
|
+
*/
|
|
33
45
|
mobile?: boolean;
|
|
34
46
|
/** proxy agent */
|
|
35
47
|
agent?: Agent;
|
|
36
|
-
/**
|
|
37
|
-
logger:
|
|
48
|
+
/** logger */
|
|
49
|
+
logger: ILogger;
|
|
38
50
|
/** version to connect with */
|
|
39
51
|
version: WAVersion;
|
|
40
52
|
/** override browser config */
|
|
41
53
|
browser: WABrowserDescription;
|
|
42
54
|
/** agent used for fetch requests -- uploading/downloading media */
|
|
43
55
|
fetchAgent?: Agent;
|
|
44
|
-
/** should the QR be printed in the terminal
|
|
45
|
-
|
|
56
|
+
/** should the QR be printed in the terminal
|
|
57
|
+
* @deprecated This feature has been removed
|
|
58
|
+
*/
|
|
59
|
+
printQRInTerminal?: boolean;
|
|
46
60
|
/** should events be emitted for actions done by this socket connection */
|
|
47
61
|
emitOwnEvents: boolean;
|
|
48
62
|
/** custom upload hosts to upload media to */
|
|
@@ -61,6 +75,8 @@ export type SocketConfig = {
|
|
|
61
75
|
transactionOpts: TransactionCapabilityOptions;
|
|
62
76
|
/** marks the client as online whenever the socket successfully connects */
|
|
63
77
|
markOnlineOnConnect: boolean;
|
|
78
|
+
/** alphanumeric country code (USA -> US) for the number used */
|
|
79
|
+
countryCode: string;
|
|
64
80
|
/** provide a cache to store media, so does not have to be re-uploaded */
|
|
65
81
|
mediaCache?: CacheStore;
|
|
66
82
|
/**
|
|
@@ -68,9 +84,11 @@ export type SocketConfig = {
|
|
|
68
84
|
* used to determine whether to retry a message or not */
|
|
69
85
|
msgRetryCounterCache?: CacheStore;
|
|
70
86
|
/** provide a cache to store a user's device list */
|
|
71
|
-
userDevicesCache?:
|
|
87
|
+
userDevicesCache?: PossiblyExtendedCacheStore;
|
|
72
88
|
/** cache to store call offers */
|
|
73
89
|
callOfferCache?: CacheStore;
|
|
90
|
+
/** cache to track placeholder resends */
|
|
91
|
+
placeholderResendCache?: CacheStore;
|
|
74
92
|
/** width for link preview images */
|
|
75
93
|
linkPreviewImageThumbnailWidth: number;
|
|
76
94
|
/** Should Baileys ask the phone for full history, will be received async */
|
|
@@ -82,6 +100,10 @@ export type SocketConfig = {
|
|
|
82
100
|
* entails uploading the jpegThumbnail to WA
|
|
83
101
|
* */
|
|
84
102
|
generateHighQualityLinkPreview: boolean;
|
|
103
|
+
/** Enable automatic session recreation for failed messages */
|
|
104
|
+
enableAutoSessionRecreation: boolean;
|
|
105
|
+
/** Enable recent message caching for retry handling */
|
|
106
|
+
enableRecentMessageCache: boolean;
|
|
85
107
|
/**
|
|
86
108
|
* Returns if a jid should be ignored,
|
|
87
109
|
* no event for that jid will be triggered.
|
|
@@ -91,7 +113,7 @@ export type SocketConfig = {
|
|
|
91
113
|
/**
|
|
92
114
|
* Optionally patch the message before sending out
|
|
93
115
|
* */
|
|
94
|
-
patchMessageBeforeSending: (msg: proto.IMessage, recipientJids
|
|
116
|
+
patchMessageBeforeSending: (msg: proto.IMessage, recipientJids?: string[]) => Promise<PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID> | PatchedMessageWithRecipientJID[] | PatchedMessageWithRecipientJID;
|
|
95
117
|
/** verify app state MACs */
|
|
96
118
|
appStateMacVerification: {
|
|
97
119
|
patch: boolean;
|
|
@@ -105,7 +127,11 @@ export type SocketConfig = {
|
|
|
105
127
|
* (solves the "this message can take a while" issue) can be retried
|
|
106
128
|
* */
|
|
107
129
|
getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
130
|
+
/** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
|
|
131
|
+
cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>;
|
|
132
|
+
makeSignalRepository: (auth: SignalAuthState, onWhatsAppFunc?: (...jids: string[]) => Promise<{
|
|
133
|
+
jid: string;
|
|
134
|
+
exists: boolean;
|
|
135
|
+
lid: string;
|
|
136
|
+
}[] | undefined>) => SignalRepositoryWithLIDStore;
|
|
111
137
|
};
|
package/lib/Types/State.d.ts
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import type { Contact } from './Contact';
|
|
3
|
+
export declare enum SyncState {
|
|
4
|
+
/** The socket is connecting, but we haven't received pending notifications yet. */
|
|
5
|
+
Connecting = 0,
|
|
6
|
+
/** Pending notifications received. Buffering events until we decide whether to sync or not. */
|
|
7
|
+
AwaitingInitialSync = 1,
|
|
8
|
+
/** The initial app state sync (history, etc.) is in progress. Buffering continues. */
|
|
9
|
+
Syncing = 2,
|
|
10
|
+
/** Initial sync is complete, or was skipped. The socket is fully operational and events are processed in real-time. */
|
|
11
|
+
Online = 3
|
|
12
|
+
}
|
|
2
13
|
export type WAConnectionState = 'open' | 'connecting' | 'close';
|
|
3
14
|
export type ConnectionState = {
|
|
4
15
|
/** connection is now open, connecting or closed */
|
|
5
16
|
connection: WAConnectionState;
|
|
6
17
|
/** the error that caused the connection to close */
|
|
7
18
|
lastDisconnect?: {
|
|
8
|
-
error: Error | undefined;
|
|
19
|
+
error: Boom | Error | undefined;
|
|
9
20
|
date: Date;
|
|
10
21
|
};
|
|
11
22
|
/** is this a new login */
|
package/lib/Types/State.js
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SyncState = void 0;
|
|
4
|
+
var SyncState;
|
|
5
|
+
(function (SyncState) {
|
|
6
|
+
/** The socket is connecting, but we haven't received pending notifications yet. */
|
|
7
|
+
SyncState[SyncState["Connecting"] = 0] = "Connecting";
|
|
8
|
+
/** Pending notifications received. Buffering events until we decide whether to sync or not. */
|
|
9
|
+
SyncState[SyncState["AwaitingInitialSync"] = 1] = "AwaitingInitialSync";
|
|
10
|
+
/** The initial app state sync (history, etc.) is in progress. Buffering continues. */
|
|
11
|
+
SyncState[SyncState["Syncing"] = 2] = "Syncing";
|
|
12
|
+
/** Initial sync is complete, or was skipped. The socket is fully operational and events are processed in real-time. */
|
|
13
|
+
SyncState[SyncState["Online"] = 3] = "Online";
|
|
14
|
+
})(SyncState || (exports.SyncState = SyncState = {}));
|
package/lib/Types/USync.d.ts
CHANGED
package/lib/Types/index.d.ts
CHANGED
|
@@ -4,17 +4,24 @@ export * from './Chat';
|
|
|
4
4
|
export * from './Contact';
|
|
5
5
|
export * from './State';
|
|
6
6
|
export * from './Message';
|
|
7
|
-
export * from './Newsletter';
|
|
8
7
|
export * from './Socket';
|
|
9
8
|
export * from './Events';
|
|
10
9
|
export * from './Product';
|
|
11
10
|
export * from './Call';
|
|
12
11
|
export * from './Signal';
|
|
13
|
-
|
|
14
|
-
import {
|
|
12
|
+
export * from './Newsletter';
|
|
13
|
+
import type { AuthenticationState } from './Auth';
|
|
14
|
+
import type { SocketConfig } from './Socket';
|
|
15
15
|
export type UserFacingSocketConfig = Partial<SocketConfig> & {
|
|
16
16
|
auth: AuthenticationState;
|
|
17
17
|
};
|
|
18
|
+
export type BrowsersMap = {
|
|
19
|
+
ubuntu(browser: string): [string, string, string];
|
|
20
|
+
macOS(browser: string): [string, string, string];
|
|
21
|
+
baileys(browser: string): [string, string, string];
|
|
22
|
+
windows(browser: string): [string, string, string];
|
|
23
|
+
appropriate(browser: string): [string, string, string];
|
|
24
|
+
};
|
|
18
25
|
export declare enum DisconnectReason {
|
|
19
26
|
connectionClosed = 428,
|
|
20
27
|
connectionLost = 408,
|
package/lib/Types/index.js
CHANGED
|
@@ -21,12 +21,12 @@ __exportStar(require("./Chat"), exports);
|
|
|
21
21
|
__exportStar(require("./Contact"), exports);
|
|
22
22
|
__exportStar(require("./State"), exports);
|
|
23
23
|
__exportStar(require("./Message"), exports);
|
|
24
|
-
__exportStar(require("./Newsletter"), exports);
|
|
25
24
|
__exportStar(require("./Socket"), exports);
|
|
26
25
|
__exportStar(require("./Events"), exports);
|
|
27
26
|
__exportStar(require("./Product"), exports);
|
|
28
27
|
__exportStar(require("./Call"), exports);
|
|
29
28
|
__exportStar(require("./Signal"), exports);
|
|
29
|
+
__exportStar(require("./Newsletter"), exports);
|
|
30
30
|
var DisconnectReason;
|
|
31
31
|
(function (DisconnectReason) {
|
|
32
32
|
DisconnectReason[DisconnectReason["connectionClosed"] = 428] = "connectionClosed";
|
|
@@ -39,4 +39,4 @@ var DisconnectReason;
|
|
|
39
39
|
DisconnectReason[DisconnectReason["multideviceMismatch"] = 411] = "multideviceMismatch";
|
|
40
40
|
DisconnectReason[DisconnectReason["forbidden"] = 403] = "forbidden";
|
|
41
41
|
DisconnectReason[DisconnectReason["unavailableService"] = 503] = "unavailableService";
|
|
42
|
-
})(DisconnectReason
|
|
42
|
+
})(DisconnectReason || (exports.DisconnectReason = DisconnectReason = {}));
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { Logger } from 'pino';
|
|
2
1
|
import type { AuthenticationCreds, CacheStore, SignalKeyStore, SignalKeyStoreWithTransaction, TransactionCapabilityOptions } from '../Types';
|
|
2
|
+
import type { ILogger } from './logger';
|
|
3
3
|
/**
|
|
4
4
|
* Adds caching capability to a SignalKeyStore
|
|
5
5
|
* @param store the store to add caching to
|
|
6
6
|
* @param logger to log trace events
|
|
7
7
|
* @param _cache cache store to use
|
|
8
8
|
*/
|
|
9
|
-
export declare function makeCacheableSignalKeyStore(store: SignalKeyStore, logger
|
|
9
|
+
export declare function makeCacheableSignalKeyStore(store: SignalKeyStore, logger?: ILogger, _cache?: CacheStore): SignalKeyStore;
|
|
10
10
|
/**
|
|
11
11
|
* Adds DB like transaction capability (https://en.wikipedia.org/wiki/Database_transaction) to the SignalKeyStore,
|
|
12
12
|
* this allows batch read & write operations & improves the performance of the lib
|
|
@@ -14,5 +14,5 @@ export declare function makeCacheableSignalKeyStore(store: SignalKeyStore, logge
|
|
|
14
14
|
* @param logger logger to log events
|
|
15
15
|
* @returns SignalKeyStore with transaction capability
|
|
16
16
|
*/
|
|
17
|
-
export declare const addTransactionCapability: (state: SignalKeyStore, logger:
|
|
17
|
+
export declare const addTransactionCapability: (state: SignalKeyStore, logger: ILogger, { maxCommitRetries, delayBetweenTriesMs }: TransactionCapabilityOptions) => SignalKeyStoreWithTransaction;
|
|
18
18
|
export declare const initAuthCreds: () => AuthenticationCreds;
|