@badzz88/baileys 8.5.7 → 8.5.8
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 +337 -1055
- package/WAProto/WAProto.proto +284 -264
- package/WAProto/index.js +5 -5
- package/engine-requirements.js +7 -15
- package/lib/Defaults/index.js +130 -187
- package/lib/Signal/Group/ciphertext-message.js +11 -14
- package/lib/Signal/Group/group-session-builder.js +29 -91
- package/lib/Signal/Group/group_cipher.js +81 -88
- package/lib/Signal/Group/index.js +12 -136
- package/lib/Signal/Group/keyhelper.js +15 -70
- package/lib/Signal/Group/sender-chain-key.js +25 -31
- package/lib/Signal/Group/sender-key-distribution-message.js +62 -65
- package/lib/Signal/Group/sender-key-message.js +65 -68
- package/lib/Signal/Group/sender-key-name.js +41 -43
- package/lib/Signal/Group/sender-key-record.js +40 -43
- package/lib/Signal/Group/sender-key-state.js +83 -96
- package/lib/Signal/Group/sender-message-key.js +25 -29
- package/lib/Signal/libsignal.js +425 -453
- package/lib/Signal/lid-mapping.js +276 -259
- package/lib/Socket/Client/index.js +3 -30
- package/lib/Socket/Client/types.js +10 -12
- package/lib/Socket/Client/websocket.js +53 -61
- package/lib/Socket/business.js +379 -422
- package/lib/Socket/chats.js +1193 -1816
- package/lib/Socket/communities.js +431 -549
- package/lib/Socket/graphql.js +672 -612
- package/lib/Socket/groups.js +374 -764
- package/lib/Socket/index.js +17 -38
- package/lib/Socket/interop.js +417 -503
- package/lib/Socket/messages-recv.js +1915 -2441
- package/lib/Socket/messages-send.js +1213 -1630
- package/lib/Socket/mex.js +9 -15
- package/lib/Socket/newsletter.js +747 -808
- package/lib/Socket/privacy.js +310 -441
- package/lib/Socket/socket.js +1025 -1022
- package/lib/Socket/username.js +8 -15
- package/lib/Store/index.js +10 -36
- package/lib/Store/make-cache-manager-store.js +80 -85
- package/lib/Store/make-in-memory-store.js +231 -591
- package/lib/Store/make-ordered-dictionary.js +72 -78
- package/lib/Store/object-repository.js +28 -25
- package/lib/Types/Auth.js +2 -38
- package/lib/Types/Bussines.js +2 -2
- package/lib/Types/Call.js +2 -2
- package/lib/Types/Chat.js +8 -4
- package/lib/Types/Contact.js +2 -2
- package/lib/Types/Events.js +2 -2
- package/lib/Types/GroupMetadata.js +2 -2
- package/lib/Types/Label.js +24 -26
- package/lib/Types/LabelAssociation.js +6 -8
- package/lib/Types/Message.js +11 -95
- package/lib/Types/Mex.js +111 -112
- package/lib/Types/Product.js +2 -2
- package/lib/Types/Signal.js +2 -2
- package/lib/Types/Socket.js +3 -2
- package/lib/Types/State.js +56 -70
- package/lib/Types/USync.js +2 -2
- package/lib/Types/index.js +26 -55
- package/lib/Utils/auth-utils.js +288 -292
- package/lib/Utils/browser-utils.js +47 -113
- package/lib/Utils/business.js +224 -240
- package/lib/Utils/chat-utils.js +869 -1205
- package/lib/Utils/companion-reg-client-utils.js +34 -41
- package/lib/Utils/crypto.js +107 -144
- package/lib/Utils/decode-wa-message.js +308 -518
- package/lib/Utils/event-buffer.js +611 -596
- package/lib/Utils/generics.js +355 -515
- package/lib/Utils/history.js +134 -244
- package/lib/Utils/identity-change-handler.js +49 -51
- package/lib/Utils/index.js +23 -57
- package/lib/Utils/link-preview.js +77 -135
- package/lib/Utils/logger.js +3 -9
- package/lib/Utils/lt-hash.js +6 -37
- package/lib/Utils/make-mutex.js +33 -36
- package/lib/Utils/message-composer.js +233 -439
- package/lib/Utils/message-retry-manager.js +260 -265
- package/lib/Utils/messages-media.js +829 -855
- package/lib/Utils/messages.js +961 -2528
- package/lib/Utils/noise-handler.js +200 -195
- package/lib/Utils/offline-node-processor.js +33 -35
- package/lib/Utils/pre-key-manager.js +102 -103
- package/lib/Utils/process-message.js +560 -978
- package/lib/Utils/reporting-utils.js +253 -257
- package/lib/Utils/signal.js +195 -218
- package/lib/Utils/stanza-ack.js +29 -31
- package/lib/Utils/sticker.js +109 -144
- package/lib/Utils/sync-action-utils.js +45 -50
- package/lib/Utils/tc-token-utils.js +139 -137
- package/lib/Utils/use-multi-file-auth-state.js +109 -109
- package/lib/Utils/validate-connection.js +202 -218
- package/lib/WABinary/constants.js +1299 -1302
- package/lib/WABinary/decode.js +262 -343
- package/lib/WABinary/encode.js +4 -12
- package/lib/WABinary/generic-utils.js +187 -223
- package/lib/WABinary/index.js +6 -33
- package/lib/WABinary/jid-utils.js +88 -351
- package/lib/WABinary/types.js +2 -2
- package/lib/WAM/BinaryInfo.js +9 -12
- package/lib/WAM/constants.js +22853 -39486
- package/lib/WAM/encode.js +140 -132
- package/lib/WAM/index.js +4 -31
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +21 -23
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +9 -9
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +7 -7
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +10 -10
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +7 -7
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +11 -12
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +4 -5
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +7 -7
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +7 -8
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +7 -7
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +8 -8
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +7 -7
- package/lib/WAUSync/Protocols/index.js +12 -39
- package/lib/WAUSync/USyncQuery.js +67 -49
- package/lib/WAUSync/USyncUser.js +11 -5
- package/lib/WAUSync/index.js +3 -31
- package/lib/index.js +15 -48
- package/package.json +129 -99
- package/LICENSE +0 -21
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Socket/aigroups.js +0 -240
- package/lib/Socket/interactive-handler.js +0 -522
- package/lib/Socket/managed-account.js +0 -183
- package/lib/Socket/registration.js +0 -427
- package/lib/Socket/text-router.js +0 -83
- package/lib/Types/Newsletter.js +0 -121
- package/lib/Utils/command-loader.d.ts +0 -31
- package/lib/Utils/command-loader.js +0 -100
- package/lib/Utils/consumer-application.js +0 -107
- package/lib/Utils/curve25519-js.js +0 -275
- package/lib/Utils/group-history.js +0 -60
- package/lib/Utils/jid-display-normalization.js +0 -218
- package/lib/Utils/meta-ai-msmsg.js +0 -262
- package/lib/Utils/native-bridge.js +0 -82
- package/lib/Utils/session-pool.d.ts +0 -16
- package/lib/Utils/session-pool.js +0 -94
- package/lib/Utils/sticker.d.ts +0 -17
- package/lib/Utils/view-once-cache.d.ts +0 -9
- package/lib/Utils/view-once-cache.js +0 -79
- package/lib/Utils/voip-rekey.js +0 -22
- package/lib/antiban.js +0 -4637
|
@@ -1,361 +1,98 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
['245886058483988', '13135550009'],
|
|
61
|
-
['3509905702656130', '13135550012'],
|
|
62
|
-
['1059680132034576', '13135550013'],
|
|
63
|
-
['715681030623646', '13135550014'],
|
|
64
|
-
['1644971366323052', '13135550015'],
|
|
65
|
-
['582497970646566', '13135550019'],
|
|
66
|
-
['645459357769306', '13135550022'],
|
|
67
|
-
['294997126699143', '13135550023'],
|
|
68
|
-
['1522631578502677', '13135550027'],
|
|
69
|
-
['719421926276396', '13135550030'],
|
|
70
|
-
['1788488635002167', '13135550031'],
|
|
71
|
-
['24232338603080193', '13135550033'],
|
|
72
|
-
['689289903143209', '13135550035'],
|
|
73
|
-
['871626054177096', '13135550039'],
|
|
74
|
-
['362351902849370', '13135550042'],
|
|
75
|
-
['1744617646041527', '13135550043'],
|
|
76
|
-
['893887762270570', '13135550046'],
|
|
77
|
-
['1155032702135830', '13135550047'],
|
|
78
|
-
['333931965993883', '13135550048'],
|
|
79
|
-
['853748013058752', '13135550049'],
|
|
80
|
-
['1559068611564819', '13135550053'],
|
|
81
|
-
['890487432705716', '13135550054'],
|
|
82
|
-
['240254602395494', '13135550055'],
|
|
83
|
-
['1578420349663261', '13135550062'],
|
|
84
|
-
['322908887140421', '13135550065'],
|
|
85
|
-
['3713961535514771', '13135550067'],
|
|
86
|
-
['997884654811738', '13135550070'],
|
|
87
|
-
['403157239387035', '13135550081'],
|
|
88
|
-
['535242369074963', '13135550082'],
|
|
89
|
-
['946293427247659', '13135550083'],
|
|
90
|
-
['3664707673802291', '13135550084'],
|
|
91
|
-
['1821827464894892', '13135550085'],
|
|
92
|
-
['1760312477828757', '13135550086'],
|
|
93
|
-
['439480398712216', '13135550087'],
|
|
94
|
-
['1876735582800984', '13135550088'],
|
|
95
|
-
['984025089825661', '13135550089'],
|
|
96
|
-
['1001336351558186', '13135550090'],
|
|
97
|
-
['3739346336347061', '13135550091'],
|
|
98
|
-
['3632749426974980', '13135550092'],
|
|
99
|
-
['427864203481615', '13135550093'],
|
|
100
|
-
['1434734570493055', '13135550094'],
|
|
101
|
-
['992873449225921', '13135550095'],
|
|
102
|
-
['813087747426445', '13135550096'],
|
|
103
|
-
['806369104931434', '13135550098'],
|
|
104
|
-
['1220982902403148', '13135550099'],
|
|
105
|
-
['1365893374104393', '13135550100'],
|
|
106
|
-
['686482033622048', '13135550200'],
|
|
107
|
-
['1454999838411253', '13135550201'],
|
|
108
|
-
['718584497008509', '13135550202'],
|
|
109
|
-
['743520384213443', '13135550301'],
|
|
110
|
-
['1147715789823789', '13135550302'],
|
|
111
|
-
['1173034540372201', '13135550303'],
|
|
112
|
-
['974785541030953', '13135550304'],
|
|
113
|
-
['1122200255531507', '13135550305'],
|
|
114
|
-
['899669714813162', '13135550306'],
|
|
115
|
-
['631880108970650', '13135550307'],
|
|
116
|
-
['435816149330026', '13135550308'],
|
|
117
|
-
['1368717161184556', '13135550309'],
|
|
118
|
-
['7849963461784891', '13135550310'],
|
|
119
|
-
['3609617065968984', '13135550312'],
|
|
120
|
-
['356273980574602', '13135550313'],
|
|
121
|
-
['1043447920539760', '13135550314'],
|
|
122
|
-
['1052764336525346', '13135550315'],
|
|
123
|
-
['2631118843732685', '13135550316'],
|
|
124
|
-
['510505411332176', '13135550317'],
|
|
125
|
-
['1945664239227513', '13135550318'],
|
|
126
|
-
['1518594378764656', '13135550319'],
|
|
127
|
-
['1378821579456138', '13135550320'],
|
|
128
|
-
['490214716896013', '13135550321'],
|
|
129
|
-
['1028577858870699', '13135550322'],
|
|
130
|
-
['308915665545959', '13135550323'],
|
|
131
|
-
['845884253678900', '13135550324'],
|
|
132
|
-
['995031308616442', '13135550325'],
|
|
133
|
-
['2787365464763437', '13135550326'],
|
|
134
|
-
['1532790990671645', '13135550327'],
|
|
135
|
-
['302617036180485', '13135550328'],
|
|
136
|
-
['723376723197227', '13135550329'],
|
|
137
|
-
['8393570407377966', '13135550330'],
|
|
138
|
-
['1931159970680725', '13135550331'],
|
|
139
|
-
['401073885688605', '13135550332'],
|
|
140
|
-
['2234478453565422', '13135550334'],
|
|
141
|
-
['814748673882312', '13135550335'],
|
|
142
|
-
['26133635056281592', '13135550336'],
|
|
143
|
-
['1439804456676119', '13135550337'],
|
|
144
|
-
['889851503172161', '13135550338'],
|
|
145
|
-
['1018283232836879', '13135550339'],
|
|
146
|
-
['1012781386779537', '13135559000'],
|
|
147
|
-
['823280953239532', '13135559001'],
|
|
148
|
-
['1597090934573334', '13135559002'],
|
|
149
|
-
['485965054020343', '13135559003'],
|
|
150
|
-
['1033381648363446', '13135559004'],
|
|
151
|
-
['491802010206446', '13135559005'],
|
|
152
|
-
['1017139033184870', '13135559006'],
|
|
153
|
-
['499638325922174', '13135559008'],
|
|
154
|
-
['468946335863664', '13135559009'],
|
|
155
|
-
['1570389776875816', '13135559010'],
|
|
156
|
-
['1004342694328995', '13135559011'],
|
|
157
|
-
['1012240323971229', '13135559012'],
|
|
158
|
-
['392171787222419', '13135559013'],
|
|
159
|
-
['952081212945019', '13135559016'],
|
|
160
|
-
['444507875070178', '13135559017'],
|
|
161
|
-
['1274819440594668', '13135559018'],
|
|
162
|
-
['1397041101147050', '13135559019'],
|
|
163
|
-
['425657699872640', '13135559020'],
|
|
164
|
-
['532292852562549', '13135559021'],
|
|
165
|
-
['705863241720292', '13135559022'],
|
|
166
|
-
['476449815183959', '13135559023'],
|
|
167
|
-
['488071553854222', '13135559024'],
|
|
168
|
-
['468693832665397', '13135559025'],
|
|
169
|
-
['517422564037340', '13135559026'],
|
|
170
|
-
['819805466613825', '13135559027'],
|
|
171
|
-
['1847708235641382', '13135559028'],
|
|
172
|
-
['716282970644228', '13135559029'],
|
|
173
|
-
['521655380527741', '13135559030'],
|
|
174
|
-
['476193631941905', '13135559031'],
|
|
175
|
-
['485600497445562', '13135559032'],
|
|
176
|
-
['440217235683910', '13135559033'],
|
|
177
|
-
['523342446758478', '13135559034'],
|
|
178
|
-
['514784864360240', '13135559035'],
|
|
179
|
-
['505790121814530', '13135559036'],
|
|
180
|
-
['420008964419580', '13135559037'],
|
|
181
|
-
['492141680204555', '13135559038'],
|
|
182
|
-
['388462787271952', '13135559039'],
|
|
183
|
-
['423473920752072', '13135559040'],
|
|
184
|
-
['489574180468229', '13135559041'],
|
|
185
|
-
['432360635854105', '13135559042'],
|
|
186
|
-
['477878201669248', '13135559043'],
|
|
187
|
-
['351656951234045', '13135559044'],
|
|
188
|
-
['430178036732582', '13135559045'],
|
|
189
|
-
['434537312944552', '13135559046'],
|
|
190
|
-
['1240614300631808', '13135559047'],
|
|
191
|
-
['473135945605128', '13135559048'],
|
|
192
|
-
['423669800729310', '13135559049'],
|
|
193
|
-
['3685666705015792', '13135559050'],
|
|
194
|
-
['504196509016638', '13135559051'],
|
|
195
|
-
['346844785189449', '13135559052'],
|
|
196
|
-
['504823088911074', '13135559053'],
|
|
197
|
-
['402669415797083', '13135559054'],
|
|
198
|
-
['490939640234431', '13135559055'],
|
|
199
|
-
['875124128063715', '13135559056'],
|
|
200
|
-
['468788962654605', '13135559057'],
|
|
201
|
-
['562386196354570', '13135559058'],
|
|
202
|
-
['372159285928791', '13135559059'],
|
|
203
|
-
['531017479591050', '13135559060'],
|
|
204
|
-
['1328873881401826', '13135559061'],
|
|
205
|
-
['1608363646390484', '13135559062'],
|
|
206
|
-
['1229628561554232', '13135559063'],
|
|
207
|
-
['348802211530364', '13135559064'],
|
|
208
|
-
['3708535859420184', '13135559065'],
|
|
209
|
-
['415517767742187', '13135559066'],
|
|
210
|
-
['479330341612638', '13135559067'],
|
|
211
|
-
['480785414723083', '13135559068'],
|
|
212
|
-
['387299107507991', '13135559069'],
|
|
213
|
-
['333389813188944', '13135559070'],
|
|
214
|
-
['391794130316996', '13135559071'],
|
|
215
|
-
['457893470576314', '13135559072'],
|
|
216
|
-
['435550496166469', '13135559073'],
|
|
217
|
-
['1620162702100689', '13135559074'],
|
|
218
|
-
['867491058616043', '13135559075'],
|
|
219
|
-
['816224117357759', '13135559076'],
|
|
220
|
-
['334065176362830', '13135559077'],
|
|
221
|
-
['489973170554709', '13135559078'],
|
|
222
|
-
['473060669049665', '13135559079'],
|
|
223
|
-
['1221505815643060', '13135559080'],
|
|
224
|
-
['889000703096359', '13135559081'],
|
|
225
|
-
['475235961979883', '13135559082'],
|
|
226
|
-
['3434445653519934', '13135559084'],
|
|
227
|
-
['524503026827421', '13135559085'],
|
|
228
|
-
['1179639046403856', '13135559086'],
|
|
229
|
-
['471563305859144', '13135559087'],
|
|
230
|
-
['533896609192881', '13135559088'],
|
|
231
|
-
['365443583168041', '13135559089'],
|
|
232
|
-
['836082305329393', '13135559090'],
|
|
233
|
-
['1056787705969916', '13135559091'],
|
|
234
|
-
['503312598958357', '13135559092'],
|
|
235
|
-
['3718606738453460', '13135559093'],
|
|
236
|
-
['826066052850902', '13135559094'],
|
|
237
|
-
['1033611345091888', '13135559095'],
|
|
238
|
-
['3868390816783240', '13135559096'],
|
|
239
|
-
['7462677740498860', '13135559097'],
|
|
240
|
-
['436288576108573', '13135559098'],
|
|
241
|
-
['1047559746718900', '13135559099'],
|
|
242
|
-
['1099299455255491', '13135559100'],
|
|
243
|
-
['1202037301040633', '13135559101'],
|
|
244
|
-
['1720619402074074', '13135559102'],
|
|
245
|
-
['1030422235101467', '13135559103'],
|
|
246
|
-
['827238979523502', '13135559104'],
|
|
247
|
-
['1516443722284921', '13135559105'],
|
|
248
|
-
['1174442747196709', '13135559106'],
|
|
249
|
-
['1653165225503842', '13135559107'],
|
|
250
|
-
['1037648777635013', '13135559108'],
|
|
251
|
-
['551617757299900', '13135559109'],
|
|
252
|
-
['1158813558718726', '13135559110'],
|
|
253
|
-
['2463236450542262', '13135559111'],
|
|
254
|
-
['1550393252501466', '13135559112'],
|
|
255
|
-
['2057065188042796', '13135559113'],
|
|
256
|
-
['506163028760735', '13135559114'],
|
|
257
|
-
['2065249100538481', '13135559115'],
|
|
258
|
-
['1041382867195858', '13135559116'],
|
|
259
|
-
['886500209499603', '13135559117'],
|
|
260
|
-
['1491615624892655', '13135559118'],
|
|
261
|
-
['486563697299617', '13135559119'],
|
|
262
|
-
['1175736513679463', '13135559120'],
|
|
263
|
-
['491811473512352', '13165550064']
|
|
264
|
-
])
|
|
265
|
-
const sepIdx = typeof jid === 'string' ? jid.indexOf('@') : -1
|
|
266
|
-
if (sepIdx < 0) {
|
|
267
|
-
return jid
|
|
268
|
-
}
|
|
269
|
-
const server = jid.slice(sepIdx + 1)
|
|
270
|
-
if (server !== 'bot') return jid
|
|
271
|
-
const user = jid.slice(0, sepIdx)
|
|
272
|
-
const mappedNumber = BOT_MAP.get(user)
|
|
273
|
-
return mappedNumber ? `${mappedNumber}@s.whatsapp.net` : jid
|
|
274
|
-
}
|
|
275
|
-
exports.getBotJid = getBotJid
|
|
276
|
-
|
|
277
|
-
const jidEncode = (user, server, device, agent) => {
|
|
278
|
-
const isInterop = server === 'interop'
|
|
279
|
-
return `${user || ''}${!!agent ? `_${agent}` : ''}${!!device || (device === 0 && !isInterop) ? `:${device}` : ''}@${server}`
|
|
280
|
-
}
|
|
281
|
-
exports.jidEncode = jidEncode
|
|
282
|
-
const jidDecode = jid => {
|
|
283
|
-
// todo: investigate how to implement hosted ids in this case
|
|
284
|
-
const sepIdx = typeof jid === 'string' ? jid.indexOf('@') : -1
|
|
285
|
-
if (sepIdx < 0) {
|
|
286
|
-
return undefined
|
|
287
|
-
}
|
|
288
|
-
const server = jid.slice(sepIdx + 1)
|
|
289
|
-
const userCombined = jid.slice(0, sepIdx)
|
|
290
|
-
const [userAgent, device] = userCombined.split(':')
|
|
291
|
-
const [user, agent] = userAgent.split('_')
|
|
292
|
-
let domainType = WAJIDDomains.WHATSAPP
|
|
293
|
-
if (server === 'lid') {
|
|
294
|
-
domainType = WAJIDDomains.LID
|
|
295
|
-
} else if (server === 'hosted') {
|
|
296
|
-
domainType = WAJIDDomains.HOSTED
|
|
297
|
-
} else if (server === 'hosted.lid') {
|
|
298
|
-
domainType = WAJIDDomains.HOSTED_LID
|
|
299
|
-
} else if (agent) {
|
|
300
|
-
domainType = parseInt(agent)
|
|
301
|
-
}
|
|
302
|
-
return {
|
|
303
|
-
server: server,
|
|
304
|
-
user: user,
|
|
305
|
-
domainType,
|
|
306
|
-
device: device ? +device : undefined
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
exports.jidDecode = jidDecode
|
|
1
|
+
export const S_WHATSAPP_NET = '@s.whatsapp.net';
|
|
2
|
+
export const OFFICIAL_BIZ_JID = '16505361212@c.us';
|
|
3
|
+
export const SERVER_JID = 'server@c.us';
|
|
4
|
+
export const PSA_WID = '0@c.us';
|
|
5
|
+
export const STORIES_JID = 'status@broadcast';
|
|
6
|
+
export const META_AI_JID = '13135550002@c.us';
|
|
7
|
+
export var WAJIDDomains;
|
|
8
|
+
(function (WAJIDDomains) {
|
|
9
|
+
WAJIDDomains[WAJIDDomains["WHATSAPP"] = 0] = "WHATSAPP";
|
|
10
|
+
WAJIDDomains[WAJIDDomains["LID"] = 1] = "LID";
|
|
11
|
+
WAJIDDomains[WAJIDDomains["HOSTED"] = 128] = "HOSTED";
|
|
12
|
+
WAJIDDomains[WAJIDDomains["HOSTED_LID"] = 129] = "HOSTED_LID";
|
|
13
|
+
})(WAJIDDomains || (WAJIDDomains = {}));
|
|
14
|
+
export const getServerFromDomainType = (initialServer, domainType) => {
|
|
15
|
+
switch (domainType) {
|
|
16
|
+
case WAJIDDomains.LID:
|
|
17
|
+
return 'lid';
|
|
18
|
+
case WAJIDDomains.HOSTED:
|
|
19
|
+
return 'hosted';
|
|
20
|
+
case WAJIDDomains.HOSTED_LID:
|
|
21
|
+
return 'hosted.lid';
|
|
22
|
+
case WAJIDDomains.WHATSAPP:
|
|
23
|
+
default:
|
|
24
|
+
return initialServer;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export const jidEncode = (user, server, device, agent) => {
|
|
28
|
+
return `${user || ''}${!!agent ? `_${agent}` : ''}${!!device ? `:${device}` : ''}@${server}`;
|
|
29
|
+
};
|
|
30
|
+
export const jidDecode = (jid) => {
|
|
31
|
+
// todo: investigate how to implement hosted ids in this case
|
|
32
|
+
const sepIdx = typeof jid === 'string' ? jid.indexOf('@') : -1;
|
|
33
|
+
if (sepIdx < 0) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
const server = jid.slice(sepIdx + 1);
|
|
37
|
+
const userCombined = jid.slice(0, sepIdx);
|
|
38
|
+
const [userAgent, device] = userCombined.split(':');
|
|
39
|
+
const [user, agent] = userAgent.split('_');
|
|
40
|
+
let domainType = WAJIDDomains.WHATSAPP;
|
|
41
|
+
if (server === 'lid') {
|
|
42
|
+
domainType = WAJIDDomains.LID;
|
|
43
|
+
}
|
|
44
|
+
else if (server === 'hosted') {
|
|
45
|
+
domainType = WAJIDDomains.HOSTED;
|
|
46
|
+
}
|
|
47
|
+
else if (server === 'hosted.lid') {
|
|
48
|
+
domainType = WAJIDDomains.HOSTED_LID;
|
|
49
|
+
}
|
|
50
|
+
else if (agent) {
|
|
51
|
+
domainType = parseInt(agent);
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
server: server,
|
|
55
|
+
user: user,
|
|
56
|
+
domainType,
|
|
57
|
+
device: device ? +device : undefined
|
|
58
|
+
};
|
|
59
|
+
};
|
|
310
60
|
/** is the jid a user */
|
|
311
|
-
const areJidsSameUser = (jid1, jid2) =>
|
|
312
|
-
exports.areJidsSameUser = areJidsSameUser
|
|
61
|
+
export const areJidsSameUser = (jid1, jid2) => jidDecode(jid1)?.user === jidDecode(jid2)?.user;
|
|
313
62
|
/** is the jid Meta AI */
|
|
314
|
-
const isJidMetaAI = jid => jid?.endsWith('@bot')
|
|
315
|
-
exports.isJidMetaAI = isJidMetaAI
|
|
63
|
+
export const isJidMetaAI = (jid) => jid?.endsWith('@bot');
|
|
316
64
|
/** is the jid a PN user */
|
|
317
|
-
const isPnUser = jid => jid?.endsWith('@s.whatsapp.net')
|
|
318
|
-
exports.isPnUser = isPnUser
|
|
319
|
-
/** is the jid an interop (BirdyChat/Haiket) user */
|
|
320
|
-
const isInteropUser = jid => jid?.endsWith('@interop')
|
|
321
|
-
exports.isInteropUser = isInteropUser
|
|
65
|
+
export const isPnUser = (jid) => jid?.endsWith('@s.whatsapp.net');
|
|
322
66
|
/** is the jid a LID */
|
|
323
|
-
const isLidUser = jid => jid?.endsWith('@lid')
|
|
324
|
-
exports.isLidUser = isLidUser
|
|
67
|
+
export const isLidUser = (jid) => jid?.endsWith('@lid');
|
|
325
68
|
/** is the jid a broadcast */
|
|
326
|
-
const isJidBroadcast = jid => jid?.endsWith('@broadcast')
|
|
327
|
-
exports.isJidBroadcast = isJidBroadcast
|
|
69
|
+
export const isJidBroadcast = (jid) => jid?.endsWith('@broadcast');
|
|
328
70
|
/** is the jid a group */
|
|
329
|
-
const isJidGroup = jid => jid?.endsWith('@g.us')
|
|
330
|
-
exports.isJidGroup = isJidGroup
|
|
71
|
+
export const isJidGroup = (jid) => jid?.endsWith('@g.us');
|
|
331
72
|
/** is the jid the status broadcast */
|
|
332
|
-
const isJidStatusBroadcast = jid => jid === 'status@broadcast'
|
|
333
|
-
exports.isJidStatusBroadcast = isJidStatusBroadcast
|
|
73
|
+
export const isJidStatusBroadcast = (jid) => jid === 'status@broadcast';
|
|
334
74
|
/** is the jid a newsletter */
|
|
335
|
-
const isJidNewsletter = jid => jid?.endsWith('@newsletter')
|
|
336
|
-
exports.isJidNewsletter = isJidNewsletter
|
|
75
|
+
export const isJidNewsletter = (jid) => jid?.endsWith('@newsletter');
|
|
337
76
|
/** is the jid a hosted PN */
|
|
338
|
-
const isHostedPnUser = jid => jid?.endsWith('@hosted')
|
|
339
|
-
exports.isHostedPnUser = isHostedPnUser
|
|
77
|
+
export const isHostedPnUser = (jid) => jid?.endsWith('@hosted');
|
|
340
78
|
/** is the jid a hosted LID */
|
|
341
|
-
const isHostedLidUser = jid => jid?.endsWith('@hosted.lid')
|
|
342
|
-
|
|
343
|
-
const
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
const jidNormalizedUser = jid => {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
exports.transferDevice = transferDevice
|
|
79
|
+
export const isHostedLidUser = (jid) => jid?.endsWith('@hosted.lid');
|
|
80
|
+
/** is the jid a interop */
|
|
81
|
+
export const isInteropUser = (jid) => jid?.endsWith('@interop');
|
|
82
|
+
const botRegexp = /^1313555\d{4}$|^131655500\d{2}$/;
|
|
83
|
+
export const isJidBot = (jid) => jid && botRegexp.test(jid.split('@')[0]) && jid.endsWith('@c.us');
|
|
84
|
+
export const jidNormalizedUser = (jid) => {
|
|
85
|
+
const result = jidDecode(jid);
|
|
86
|
+
if (!result) {
|
|
87
|
+
return '';
|
|
88
|
+
}
|
|
89
|
+
const { user, server } = result;
|
|
90
|
+
return jidEncode(user, server === 'c.us' ? 's.whatsapp.net' : server);
|
|
91
|
+
};
|
|
92
|
+
export const transferDevice = (fromJid, toJid) => {
|
|
93
|
+
const fromDecoded = jidDecode(fromJid);
|
|
94
|
+
const deviceId = fromDecoded?.device || 0;
|
|
95
|
+
const { server, user } = jidDecode(toJid);
|
|
96
|
+
return jidEncode(user, server, deviceId);
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=jid-utils.js.map
|
package/lib/WABinary/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as constants from './constants.js';
|
|
2
|
+
//# sourceMappingURL=types.js.map
|
package/lib/WAM/BinaryInfo.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this.buffer = []
|
|
10
|
-
Object.assign(this, options)
|
|
11
|
-
}
|
|
1
|
+
export class BinaryInfo {
|
|
2
|
+
constructor(options = {}) {
|
|
3
|
+
this.protocolVersion = 5;
|
|
4
|
+
this.sequence = 0;
|
|
5
|
+
this.events = [];
|
|
6
|
+
this.buffer = [];
|
|
7
|
+
Object.assign(this, options);
|
|
8
|
+
}
|
|
12
9
|
}
|
|
13
|
-
|
|
10
|
+
//# sourceMappingURL=BinaryInfo.js.map
|