@badzz88/baileys 8.5.4 → 8.5.5
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 +1 -1
- package/WAProto/WAProto.proto +75 -1256
- package/WAProto/index.d.ts +19729 -36122
- package/WAProto/index.js +132193 -178538
- package/engine-requirements.js +15 -7
- package/lib/Defaults/index.js +14 -22
- package/lib/Signal/Group/group_cipher.js +5 -5
- package/lib/Signal/Group/keyhelper.js +4 -4
- package/lib/Signal/Group/sender-chain-key.js +2 -2
- package/lib/Signal/Group/sender-key-distribution-message.js +1 -1
- package/lib/Signal/Group/sender-key-message.js +3 -3
- package/lib/Signal/Group/sender-key-record.js +1 -1
- package/lib/Signal/Group/sender-message-key.js +5 -5
- package/lib/Signal/libsignal.js +28 -39
- package/lib/Signal/lid-mapping.js +8 -28
- package/lib/Socket/aigroups.js +5 -5
- package/lib/Socket/business.js +11 -3
- package/lib/Socket/chats.js +319 -668
- package/lib/Socket/communities.js +89 -85
- package/lib/Socket/graphql.js +228 -435
- package/lib/Socket/groups.js +211 -132
- package/lib/Socket/index.js +7 -9
- package/lib/Socket/interactive-handler.js +60 -117
- package/lib/Socket/interop.js +175 -56
- package/lib/Socket/luxu.js +387 -0
- package/lib/Socket/managed-account.js +48 -79
- package/lib/Socket/messages-recv.js +340 -898
- package/lib/Socket/messages-send.js +160 -462
- package/lib/Socket/mex.js +53 -40
- package/lib/Socket/newsletter.js +295 -291
- package/lib/Socket/privacy.js +265 -77
- package/lib/Socket/registration.js +157 -164
- package/lib/Socket/socket.js +199 -181
- package/lib/Socket/text-router.js +83 -0
- package/lib/Socket/username.js +227 -144
- package/lib/Store/keyed-db.js +108 -0
- package/lib/Store/make-cache-manager-store.js +2 -2
- package/lib/Store/make-in-memory-store.js +141 -25
- package/lib/Types/Auth.js +3 -3
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Mex.js +112 -0
- package/lib/Types/Newsletter.js +65 -96
- package/lib/Types/State.js +4 -4
- package/lib/Types/index.js +1 -1
- package/lib/Utils/auth-utils.js +57 -52
- package/lib/Utils/browser-utils.js +1 -1
- package/lib/Utils/business.js +6 -2
- package/lib/Utils/chat-utils.js +38 -102
- package/lib/Utils/command-loader.d.ts +31 -0
- package/lib/Utils/command-loader.js +100 -0
- package/lib/Utils/companion-reg-client-utils.js +42 -0
- package/lib/Utils/crypto.js +84 -54
- package/lib/Utils/curve25519-js.js +275 -0
- package/lib/Utils/decode-wa-message.js +83 -316
- package/lib/Utils/event-buffer.js +61 -37
- package/lib/Utils/generics.js +103 -157
- package/lib/Utils/group-history.js +12 -3
- package/lib/Utils/history.js +15 -15
- package/lib/Utils/index.js +5 -1
- package/lib/Utils/link-preview.js +8 -3
- package/lib/Utils/lt-hash.js +35 -2
- package/lib/Utils/make-mutex.js +1 -1
- package/lib/Utils/message-retry-manager.js +92 -27
- package/lib/Utils/messages-media.js +130 -159
- package/lib/Utils/messages.js +566 -144
- package/lib/Utils/meta-ai-msmsg.js +202 -62
- package/lib/Utils/native-bridge.js +82 -0
- package/lib/Utils/noise-handler.js +21 -19
- package/lib/Utils/offline-node-processor.js +8 -3
- package/lib/Utils/pre-key-manager.js +23 -13
- package/lib/Utils/process-message.js +106 -197
- package/lib/Utils/reporting-utils.js +2 -2
- package/lib/Utils/session-pool.d.ts +16 -0
- package/lib/Utils/session-pool.js +94 -0
- package/lib/Utils/signal.js +63 -28
- package/lib/Utils/stanza-ack.js +12 -39
- package/lib/Utils/sticker.d.ts +17 -0
- package/lib/Utils/sticker.js +145 -0
- package/lib/Utils/sync-action-utils.js +7 -4
- package/lib/Utils/tc-token-utils.js +25 -20
- package/lib/Utils/use-multi-file-auth-state.js +14 -30
- package/lib/Utils/validate-connection.js +19 -59
- package/lib/Utils/view-once-cache.d.ts +9 -0
- package/lib/Utils/view-once-cache.js +79 -0
- package/lib/WABinary/decode.js +16 -50
- package/lib/WABinary/encode.js +224 -54
- package/lib/WABinary/generic-utils.js +97 -7
- package/lib/WABinary/jid-utils.js +14 -27
- package/lib/WAM/encode.js +7 -7
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +1 -58
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +1 -7
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +5 -13
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +4 -1
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +7 -20
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -7
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +1 -2
- package/lib/WAUSync/Protocols/index.js +0 -1
- package/lib/WAUSync/USyncQuery.js +6 -77
- package/lib/WAUSync/USyncUser.js +8 -16
- package/lib/WAUSync/index.js +0 -1
- package/lib/antiban.js +854 -608
- package/lib/index.js +1 -1
- package/package.json +20 -16
package/lib/Types/Newsletter.js
CHANGED
|
@@ -1,37 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
-
exports.QueryIds =
|
|
4
|
-
exports.XWAPaths =
|
|
5
|
-
exports.NewsletterReactionSetting =
|
|
6
|
-
exports.NewsletterState =
|
|
7
|
-
exports.NewsletterRole =
|
|
8
|
-
void 0
|
|
9
|
-
var NewsletterRole
|
|
10
|
-
;(function (NewsletterRole) {
|
|
11
|
-
NewsletterRole['SUBSCRIBER'] = 'SUBSCRIBER'
|
|
12
|
-
NewsletterRole['ADMIN'] = 'ADMIN'
|
|
13
|
-
NewsletterRole['OWNER'] = 'OWNER'
|
|
14
|
-
NewsletterRole['GUEST'] = 'GUEST'
|
|
15
|
-
})(NewsletterRole || (exports.NewsletterRole = NewsletterRole = {}))
|
|
16
|
-
var NewsletterState
|
|
17
|
-
;(function (NewsletterState) {
|
|
18
|
-
NewsletterState['ACTIVE'] = 'ACTIVE'
|
|
19
|
-
NewsletterState['SUSPENDED'] = 'SUSPENDED'
|
|
20
|
-
NewsletterState['GEO_SUSPENDED'] = 'GEO_SUSPENDED'
|
|
21
|
-
NewsletterState['UNKNOWN'] = 'UNKNOWN'
|
|
22
|
-
})(NewsletterState || (exports.NewsletterState = NewsletterState = {}))
|
|
23
|
-
var NewsletterReactionSetting
|
|
24
|
-
;(function (NewsletterReactionSetting) {
|
|
25
|
-
NewsletterReactionSetting['ALLOWLIST'] = 'ALLOWLIST'
|
|
26
|
-
NewsletterReactionSetting['BLOCKLIST'] = 'BLOCKLIST'
|
|
27
|
-
NewsletterReactionSetting['NONE'] = 'NONE'
|
|
28
|
-
})(NewsletterReactionSetting || (exports.NewsletterReactionSetting = NewsletterReactionSetting = {}))
|
|
3
|
+
exports.QueryIds = exports.XWAPaths = void 0
|
|
29
4
|
var XWAPaths
|
|
30
5
|
;(function (XWAPaths) {
|
|
31
6
|
XWAPaths['xwa2_newsletter_create'] = 'xwa2_newsletter_create'
|
|
32
|
-
|
|
33
7
|
XWAPaths['xwa2_newsletter_subscribers'] = 'xwa2_newsletter_subscribers'
|
|
34
|
-
XWAPaths['xwa2_newsletter_followers'] = 'xwa2_newsletter_followers'
|
|
35
8
|
XWAPaths['xwa2_newsletter_view'] = 'xwa2_newsletter_view'
|
|
36
9
|
XWAPaths['xwa2_newsletter_metadata'] = 'xwa2_newsletter'
|
|
37
10
|
XWAPaths['xwa2_newsletter_admin_count'] = 'xwa2_newsletter_admin'
|
|
@@ -41,19 +14,18 @@ var XWAPaths
|
|
|
41
14
|
XWAPaths['xwa2_newsletter_unfollow'] = 'xwa2_newsletter_unfollow'
|
|
42
15
|
XWAPaths['xwa2_newsletter_change_owner'] = 'xwa2_newsletter_change_owner'
|
|
43
16
|
XWAPaths['xwa2_newsletter_demote'] = 'xwa2_newsletter_demote'
|
|
44
|
-
XWAPaths['xwa2_newsletter_admin_demote'] = 'xwa2_newsletter_admin_demote'
|
|
45
17
|
XWAPaths['xwa2_newsletter_delete_v2'] = 'xwa2_newsletter_delete_v2'
|
|
46
18
|
XWAPaths['xwa2_newsletter_join_v2'] = 'xwa2_newsletter_join_v2'
|
|
47
19
|
XWAPaths['xwa2_newsletter_leave_v2'] = 'xwa2_newsletter_leave_v2'
|
|
48
20
|
XWAPaths['xwa2_fetch_account_reachout_timelock'] = 'xwa2_fetch_account_reachout_timelock'
|
|
49
21
|
XWAPaths['xwa2_message_capping_info'] = 'xwa2_message_capping_info'
|
|
50
|
-
|
|
22
|
+
// Newsletter admin/invite paths
|
|
51
23
|
XWAPaths['xwa2_newsletter_admin_invite_create'] = 'xwa2_newsletter_admin_invite_create'
|
|
52
24
|
XWAPaths['xwa2_newsletter_admin_invite_revoke'] = 'xwa2_newsletter_admin_invite_revoke'
|
|
53
25
|
XWAPaths['xwa2_newsletter_admin_invite_accept'] = 'xwa2_newsletter_admin_invite_accept'
|
|
54
26
|
XWAPaths['xwa2_newsletter_admin'] = 'xwa2_newsletter_admin'
|
|
55
27
|
XWAPaths['xwa2_newsletter_admin_profile_update'] = 'xwa2_newsletter_admin_profile_update'
|
|
56
|
-
|
|
28
|
+
// Newsletter directory/search paths
|
|
57
29
|
XWAPaths['xwa2_newsletters_directory_list'] = 'xwa2_newsletters_directory_list'
|
|
58
30
|
XWAPaths['xwa2_newsletters_directory_search'] = 'xwa2_newsletters_directory_search'
|
|
59
31
|
XWAPaths['xwa2_newsletters_directory_category_preview'] = 'xwa2_newsletters_directory_category_preview'
|
|
@@ -61,24 +33,23 @@ var XWAPaths
|
|
|
61
33
|
XWAPaths['xwa2_newsletters_recommended'] = 'xwa2_newsletters_recommended'
|
|
62
34
|
XWAPaths['xwa2_newsletters_similar'] = 'xwa2_newsletters_similar'
|
|
63
35
|
XWAPaths['xwa2_newsletter_following'] = 'xwa2_newsletter_following'
|
|
64
|
-
|
|
36
|
+
// Newsletter engagement paths
|
|
65
37
|
XWAPaths['xwa2_newsletter_admin_insights'] = 'xwa2_newsletter_admin_insights'
|
|
66
38
|
XWAPaths['xwa2_newsletters_poll_voter_list'] = 'xwa2_newsletters_poll_voter_list'
|
|
67
39
|
XWAPaths['xwa2_newsletters_reaction_sender_list'] = 'xwa2_newsletters_reaction_sender_list'
|
|
68
|
-
|
|
40
|
+
// Newsletter moderation
|
|
69
41
|
XWAPaths['xwa2_newsletter_enforcements'] = 'xwa2_newsletter_enforcements'
|
|
70
42
|
XWAPaths['xwa2_newsletter_user_reports'] = 'xwa2_newsletter_user_reports'
|
|
71
43
|
XWAPaths['xwa2_newsletter_create_report_appeal'] = 'xwa2_newsletter_create_report_appeal'
|
|
72
44
|
XWAPaths['xwa2_newsletter_link_preview_check'] = 'xwa2_newsletter_link_preview_check'
|
|
73
45
|
XWAPaths['xwa2_newsletter_update_verification'] = 'xwa2_newsletter_update_verification'
|
|
74
46
|
XWAPaths['xwa2_newsletter_label_paid_partnership'] = 'xwa2_newsletter_label_paid_partnership'
|
|
75
|
-
|
|
47
|
+
// Newsletter log/user
|
|
76
48
|
XWAPaths['xwa2_newsletter_log_exposures'] = 'xwa2_newsletter_log_exposures'
|
|
77
49
|
XWAPaths['xwa2_newsletter_update_user_setting'] = 'xwa2_newsletter_update_user_setting'
|
|
78
50
|
XWAPaths['xwa2_newsletter_create_verified'] = 'xwa2_newsletter_create_verified'
|
|
79
51
|
XWAPaths['xwa2_newsletter_ranking_features'] = 'xwa2_newsletter_ranking_features'
|
|
80
|
-
|
|
81
|
-
|
|
52
|
+
// Wamo paths
|
|
82
53
|
XWAPaths['xwa2_wamo_afs_age_collection'] = 'xwa2_wamo_afs_age_collection'
|
|
83
54
|
XWAPaths['xwa2_wamo_asset_collection'] = 'xwa2_wamo_asset_collection'
|
|
84
55
|
XWAPaths['xwa2_wamo_fetch_adhoc_notice_by_id'] = 'xwa2_wamo_fetch_adhoc_notice_by_id'
|
|
@@ -89,64 +60,62 @@ var XWAPaths
|
|
|
89
60
|
})(XWAPaths || (exports.XWAPaths = XWAPaths = {}))
|
|
90
61
|
var QueryIds
|
|
91
62
|
;(function (QueryIds) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
QueryIds['
|
|
96
|
-
QueryIds['
|
|
97
|
-
QueryIds['
|
|
98
|
-
QueryIds['
|
|
99
|
-
QueryIds['
|
|
100
|
-
QueryIds['
|
|
101
|
-
QueryIds['
|
|
102
|
-
QueryIds['
|
|
103
|
-
QueryIds['
|
|
104
|
-
QueryIds['
|
|
105
|
-
QueryIds['
|
|
106
|
-
QueryIds['
|
|
107
|
-
QueryIds['
|
|
108
|
-
QueryIds['
|
|
109
|
-
QueryIds['
|
|
110
|
-
|
|
111
|
-
QueryIds['
|
|
112
|
-
|
|
113
|
-
QueryIds['
|
|
114
|
-
QueryIds['
|
|
115
|
-
QueryIds['
|
|
116
|
-
|
|
117
|
-
QueryIds['
|
|
118
|
-
|
|
119
|
-
QueryIds['
|
|
120
|
-
QueryIds['
|
|
121
|
-
QueryIds['
|
|
122
|
-
QueryIds['
|
|
123
|
-
QueryIds['
|
|
124
|
-
|
|
125
|
-
QueryIds['
|
|
126
|
-
|
|
127
|
-
QueryIds['
|
|
128
|
-
QueryIds['
|
|
129
|
-
QueryIds['
|
|
130
|
-
QueryIds['
|
|
131
|
-
|
|
132
|
-
QueryIds['
|
|
133
|
-
|
|
134
|
-
QueryIds['
|
|
135
|
-
QueryIds['
|
|
136
|
-
QueryIds['
|
|
137
|
-
QueryIds['
|
|
138
|
-
QueryIds['
|
|
139
|
-
|
|
140
|
-
QueryIds['
|
|
141
|
-
|
|
142
|
-
QueryIds['
|
|
143
|
-
QueryIds['
|
|
144
|
-
QueryIds['
|
|
145
|
-
QueryIds['
|
|
146
|
-
QueryIds['
|
|
147
|
-
QueryIds['
|
|
148
|
-
QueryIds['
|
|
149
|
-
QueryIds['
|
|
150
|
-
QueryIds['WAMO_USER_ID_VERSION'] = '24958410737155269'
|
|
151
|
-
QueryIds['WAMO_SET_USER_ID_VERSION'] = '8148672891859281'
|
|
63
|
+
// Newsletter core
|
|
64
|
+
QueryIds['CREATE'] = '26278417231751160' // NewsletterCreate
|
|
65
|
+
QueryIds['CREATE_VERIFIED'] = '25691091733891788' // NewsletterCreateVerified
|
|
66
|
+
QueryIds['UPDATE_METADATA'] = '25976052865358570' // NewsletterMetadataUpdate
|
|
67
|
+
QueryIds['METADATA'] = '26099060629688650' // NewsletterMetadata
|
|
68
|
+
QueryIds['SUBSCRIBERS'] = '25646542368289350' // NewsletterFollowers
|
|
69
|
+
QueryIds['FOLLOW'] = '24658527423838740' // NewsletterJoin
|
|
70
|
+
QueryIds['LEAVE'] = '25758579043742316' // NewsletterLeave
|
|
71
|
+
QueryIds['UNFOLLOW'] = '25757497553878990' // NewsletterFollowing (used for unfollow path)
|
|
72
|
+
QueryIds['MUTE'] = '25033614912931370' // NewsletterHide
|
|
73
|
+
QueryIds['UNMUTE'] = '24551592861177484' // NewsletterUnhide
|
|
74
|
+
QueryIds['ADMIN_COUNT'] = '27579307995002556' // NewslettersAdminCapabilitiesQuery
|
|
75
|
+
QueryIds['CHANGE_OWNER'] = '24737692515842080' // NewsletterChangeOwner
|
|
76
|
+
QueryIds['DEMOTE'] = '25054538847517280' // NewsletterAdminDemote
|
|
77
|
+
QueryIds['DELETE'] = '31838460859131916' // NewsletterDelete
|
|
78
|
+
QueryIds['REACHOUT_TIMELOCK'] = '25627902213558772' // FetchReachoutTimelockQuery
|
|
79
|
+
QueryIds['MESSAGE_CAPPING_INFO'] = '25311901238461920' // XWA2MessageCappingInfoQuery
|
|
80
|
+
QueryIds['UPDATE_USER_SETTING'] = '24935528202764690' // NewsletterUpdateUserSetting
|
|
81
|
+
// Newsletter admin/invite
|
|
82
|
+
QueryIds['ADMIN_INVITE'] = '26278681041745440' // NewsletterAdminInvite
|
|
83
|
+
QueryIds['ADMIN_INVITE_REVOKE'] = '24369392486051948' // NewsletterAdminInviteRevoke
|
|
84
|
+
QueryIds['ADMIN_INVITE_ACCEPT'] = '24934958956134856' // NewsletterAcceptAdminInvite
|
|
85
|
+
QueryIds['ADMIN_METADATA'] = '26882701001369256' // NewsletterAdminMetadataQuery
|
|
86
|
+
QueryIds['ADMIN_PROFILE_UPDATE'] = '25959584293627630' // NewsletterAdminProfileUpdate
|
|
87
|
+
// Newsletter directory/search
|
|
88
|
+
QueryIds['DIRECTORY_LIST'] = '35420207774244120' // NewsletterDirectoryList
|
|
89
|
+
QueryIds['DIRECTORY_SEARCH'] = '26545699395089024' // NewsletterDirectorySearch
|
|
90
|
+
QueryIds['DIRECTORY_CATEGORY_PREVIEW'] = '25554326764266960' // NewsletterDirectoryCategoryPreview
|
|
91
|
+
QueryIds['SEARCH'] = '25909596625362196' // NewsletterSearch
|
|
92
|
+
QueryIds['RECOMMENDED'] = '26234104032880280' // NewsletterRecommended
|
|
93
|
+
QueryIds['SIMILAR'] = '33639678252347084' // NewsletterSimilar
|
|
94
|
+
QueryIds['FOLLOWING_LIST'] = '25757497553878990' // NewsletterFollowing
|
|
95
|
+
// Newsletter engagement
|
|
96
|
+
QueryIds['INSIGHTS'] = '24672564052397920' // NewsletterInsights
|
|
97
|
+
QueryIds['POLL_VOTER_LIST'] = '24803802869271956' // NewsletterPollVoterList
|
|
98
|
+
QueryIds['REACTION_SENDERS_LIST'] = '25219734117717030' // NewsletterReactionSendersList
|
|
99
|
+
QueryIds['QUESTION_RESPONSE_STATE_UPDATE'] = '24896618076668076' // NewsletterQuestionResponseStateUpdate
|
|
100
|
+
QueryIds['LOG_EXPOSURES'] = '24606408825709910' // NewsletterLogExposures
|
|
101
|
+
QueryIds['RANKING_FEATURES'] = '24742757908756090' // FetchNewsletterRankingFeatures
|
|
102
|
+
// Newsletter moderation
|
|
103
|
+
QueryIds['BLOCK_USER'] = '25106066249006236' // NewsletterBlockUser
|
|
104
|
+
QueryIds['USER_REPORTS'] = '26334442806191824' // NewsletterUserReports
|
|
105
|
+
QueryIds['CREATE_REPORT_APPEAL'] = '26787508127520150' // NewsletterCreateReportAppeal
|
|
106
|
+
QueryIds['ENFORCEMENTS'] = '25956852020603264' // NewsletterEnforcements
|
|
107
|
+
QueryIds['LINK_PREVIEW_CHECK'] = '24188786150796508' // NewsletterLinkPreviewCheck
|
|
108
|
+
QueryIds['UPDATE_VERIFICATION'] = '33965625006384290' // NewsletterUpdateVerification
|
|
109
|
+
QueryIds['LABEL_PAID_PARTNERSHIP'] = '26221505494211176' // NewsletterLabelPaidPartnership
|
|
110
|
+
// Newsletter Wamo (paid subscription)
|
|
111
|
+
QueryIds['WAMO_CHANGE_SUB'] = '25201342542835864' // NewsletterChangeWamoSub
|
|
112
|
+
QueryIds['WAMO_ENABLE_SUB'] = '25122474967344830' // NewsletterEnableWamoSub
|
|
113
|
+
QueryIds['WAMO_DISABLE_SUB'] = '31916794074578680' // NewsletterDisableWamoSub
|
|
114
|
+
QueryIds['WAMO_AFS_AGE_COLLECTION'] = '25012618978387376' // WamoAfsAgeCollection
|
|
115
|
+
QueryIds['WAMO_ASSET_COLLECTION'] = '24347085218298772' // WamoAssetCollection
|
|
116
|
+
QueryIds['WAMO_FETCH_ADHOC_NOTICE'] = '24758534413802424' // WamoFetchAdhocNoticeById
|
|
117
|
+
QueryIds['WAMO_FETCH_IDENTITY_TOKEN'] = '24677346488597664' // WamoFetchIdentityToken
|
|
118
|
+
QueryIds['WAMO_SUB_COMPLIANCE_INFO'] = '25105596879072480' // WamoSubGetComplianceInfo
|
|
119
|
+
QueryIds['WAMO_USER_ID_VERSION'] = '24958410737155268' // WamoUserIdVersion
|
|
120
|
+
QueryIds['WAMO_SET_USER_ID_VERSION'] = '8148672891859281' // SetWamoUserIdVersion
|
|
152
121
|
})(QueryIds || (exports.QueryIds = QueryIds = {}))
|
package/lib/Types/State.js
CHANGED
|
@@ -8,13 +8,13 @@ exports.NewChatMessageCappingOTEStatusType =
|
|
|
8
8
|
void 0
|
|
9
9
|
var SyncState
|
|
10
10
|
;(function (SyncState) {
|
|
11
|
-
|
|
11
|
+
/** The socket is connecting, but we haven't received pending notifications yet. */
|
|
12
12
|
SyncState[(SyncState['Connecting'] = 0)] = 'Connecting'
|
|
13
|
-
|
|
13
|
+
/** Pending notifications received. Buffering events until we decide whether to sync or not. */
|
|
14
14
|
SyncState[(SyncState['AwaitingInitialSync'] = 1)] = 'AwaitingInitialSync'
|
|
15
|
-
|
|
15
|
+
/** The initial app state sync (history, etc.) is in progress. Buffering continues. */
|
|
16
16
|
SyncState[(SyncState['Syncing'] = 2)] = 'Syncing'
|
|
17
|
-
|
|
17
|
+
/** Initial sync is complete, or was skipped. The socket is fully operational and events are processed in real-time. */
|
|
18
18
|
SyncState[(SyncState['Online'] = 3)] = 'Online'
|
|
19
19
|
})(SyncState || (exports.SyncState = SyncState = {}))
|
|
20
20
|
var ReachoutTimelockEnforcementType
|
package/lib/Types/index.js
CHANGED
|
@@ -39,7 +39,7 @@ __exportStar(require('./Product'), exports)
|
|
|
39
39
|
__exportStar(require('./Call'), exports)
|
|
40
40
|
__exportStar(require('./Signal'), exports)
|
|
41
41
|
__exportStar(require('./Newsletter'), exports)
|
|
42
|
-
__exportStar(require('./
|
|
42
|
+
__exportStar(require('./Mex'), exports)
|
|
43
43
|
var DisconnectReason
|
|
44
44
|
;(function (DisconnectReason) {
|
|
45
45
|
DisconnectReason[(DisconnectReason['connectionClosed'] = 428)] = 'connectionClosed'
|
package/lib/Utils/auth-utils.js
CHANGED
|
@@ -16,25 +16,21 @@ const Defaults_1 = require('../Defaults')
|
|
|
16
16
|
const crypto_2 = require('./crypto')
|
|
17
17
|
const generics_1 = require('./generics')
|
|
18
18
|
const pre_key_manager_1 = require('./pre-key-manager')
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const sharedTxStorage = new async_hooks_1.AsyncLocalStorage()
|
|
28
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Adds caching capability to a SignalKeyStore
|
|
21
|
+
* @param store the store to add caching to
|
|
22
|
+
* @param logger to log trace events
|
|
23
|
+
* @param _cache cache store to use
|
|
24
|
+
*/
|
|
29
25
|
function makeCacheableSignalKeyStore(store, logger, _cache) {
|
|
30
26
|
const cache =
|
|
31
27
|
_cache ||
|
|
32
28
|
new node_cache_1.default({
|
|
33
|
-
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.SIGNAL_STORE,
|
|
29
|
+
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.SIGNAL_STORE, // 5 minutes
|
|
34
30
|
useClones: false,
|
|
35
31
|
deleteOnExpire: true
|
|
36
32
|
})
|
|
37
|
-
|
|
33
|
+
// Mutex for protecting cache operations
|
|
38
34
|
const cacheMutex = new async_mutex_1.Mutex()
|
|
39
35
|
function getUniqueId(type, id) {
|
|
40
36
|
return `${type}.${id}`
|
|
@@ -59,7 +55,7 @@ function makeCacheableSignalKeyStore(store, logger, _cache) {
|
|
|
59
55
|
const item = fetched[id]
|
|
60
56
|
if (item) {
|
|
61
57
|
data[id] = item
|
|
62
|
-
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
63
59
|
await cache.set(getUniqueId(type, id), item)
|
|
64
60
|
}
|
|
65
61
|
}
|
|
@@ -86,32 +82,34 @@ function makeCacheableSignalKeyStore(store, logger, _cache) {
|
|
|
86
82
|
}
|
|
87
83
|
}
|
|
88
84
|
}
|
|
89
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Adds DB-like transaction capability to the SignalKeyStore
|
|
87
|
+
* Uses AsyncLocalStorage for automatic context management
|
|
88
|
+
* @param state the key store to apply this capability to
|
|
89
|
+
* @param logger logger to log events
|
|
90
|
+
* @returns SignalKeyStore with transaction capability
|
|
91
|
+
*/
|
|
90
92
|
const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetweenTriesMs }) => {
|
|
91
|
-
const txStorage =
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const storeToken = Symbol('addTransactionCapability')
|
|
96
|
-
const getOwnStore = () => {
|
|
97
|
-
const ctx = txStorage.getStore()
|
|
98
|
-
return ctx && ctx.token === storeToken ? ctx : undefined
|
|
99
|
-
}
|
|
100
|
-
|
|
93
|
+
const txStorage = new async_hooks_1.AsyncLocalStorage()
|
|
94
|
+
// Queues for concurrency control (keyed by signal data type - bounded set)
|
|
101
95
|
const keyQueues = new Map()
|
|
102
|
-
|
|
96
|
+
// Transaction mutexes with reference counting for cleanup
|
|
103
97
|
const txMutexes = new Map()
|
|
104
98
|
const txMutexRefCounts = new Map()
|
|
105
|
-
|
|
99
|
+
// Pre-key manager for specialized operations
|
|
106
100
|
const preKeyManager = new pre_key_manager_1.PreKeyManager(state, logger)
|
|
107
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Get or create a queue for a specific key type
|
|
103
|
+
*/
|
|
108
104
|
function getQueue(key) {
|
|
109
105
|
if (!keyQueues.has(key)) {
|
|
110
106
|
keyQueues.set(key, new p_queue_1.default({ concurrency: 1 }))
|
|
111
107
|
}
|
|
112
108
|
return keyQueues.get(key)
|
|
113
109
|
}
|
|
114
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Get or create a transaction mutex
|
|
112
|
+
*/
|
|
115
113
|
function getTxMutex(key) {
|
|
116
114
|
if (!txMutexes.has(key)) {
|
|
117
115
|
txMutexes.set(key, new async_mutex_1.Mutex())
|
|
@@ -119,16 +117,20 @@ const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetwee
|
|
|
119
117
|
}
|
|
120
118
|
return txMutexes.get(key)
|
|
121
119
|
}
|
|
122
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Acquire a reference to a transaction mutex
|
|
122
|
+
*/
|
|
123
123
|
function acquireTxMutexRef(key) {
|
|
124
124
|
const count = txMutexRefCounts.get(key) ?? 0
|
|
125
125
|
txMutexRefCounts.set(key, count + 1)
|
|
126
126
|
}
|
|
127
|
-
|
|
127
|
+
/**
|
|
128
|
+
* Release a reference to a transaction mutex and cleanup if no longer needed
|
|
129
|
+
*/
|
|
128
130
|
function releaseTxMutexRef(key) {
|
|
129
131
|
const count = (txMutexRefCounts.get(key) ?? 1) - 1
|
|
130
132
|
txMutexRefCounts.set(key, count)
|
|
131
|
-
|
|
133
|
+
// Cleanup if no more references and mutex is not locked
|
|
132
134
|
if (count <= 0) {
|
|
133
135
|
const mutex = txMutexes.get(key)
|
|
134
136
|
if (mutex && !mutex.isLocked()) {
|
|
@@ -137,11 +139,15 @@ const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetwee
|
|
|
137
139
|
}
|
|
138
140
|
}
|
|
139
141
|
}
|
|
140
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Check if currently in a transaction
|
|
144
|
+
*/
|
|
141
145
|
function isInTransaction() {
|
|
142
|
-
return !!
|
|
146
|
+
return !!txStorage.getStore()
|
|
143
147
|
}
|
|
144
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Commit transaction with retries
|
|
150
|
+
*/
|
|
145
151
|
async function commitWithRetry(mutations) {
|
|
146
152
|
if (Object.keys(mutations).length === 0) {
|
|
147
153
|
logger.trace('no mutations in transaction')
|
|
@@ -165,23 +171,23 @@ const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetwee
|
|
|
165
171
|
}
|
|
166
172
|
return {
|
|
167
173
|
get: async (type, ids) => {
|
|
168
|
-
const ctx =
|
|
174
|
+
const ctx = txStorage.getStore()
|
|
169
175
|
if (!ctx) {
|
|
170
|
-
|
|
176
|
+
// No transaction - direct read without exclusive lock for concurrency
|
|
171
177
|
return state.get(type, ids)
|
|
172
178
|
}
|
|
173
|
-
|
|
179
|
+
// In transaction - check cache first
|
|
174
180
|
const cached = ctx.cache[type] || {}
|
|
175
181
|
const missing = ids.filter(id => !(id in cached))
|
|
176
182
|
if (missing.length > 0) {
|
|
177
183
|
ctx.dbQueries++
|
|
178
184
|
logger.trace({ type, count: missing.length }, 'fetching missing keys in transaction')
|
|
179
185
|
const fetched = await getTxMutex(type).runExclusive(() => state.get(type, missing))
|
|
180
|
-
|
|
186
|
+
// Update cache
|
|
181
187
|
ctx.cache[type] = ctx.cache[type] || {}
|
|
182
188
|
Object.assign(ctx.cache[type], fetched)
|
|
183
189
|
}
|
|
184
|
-
|
|
190
|
+
// Return requested ids from cache
|
|
185
191
|
const result = {}
|
|
186
192
|
for (const id of ids) {
|
|
187
193
|
const value = ctx.cache[type]?.[id]
|
|
@@ -192,18 +198,18 @@ const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetwee
|
|
|
192
198
|
return result
|
|
193
199
|
},
|
|
194
200
|
set: async data => {
|
|
195
|
-
const ctx =
|
|
201
|
+
const ctx = txStorage.getStore()
|
|
196
202
|
if (!ctx) {
|
|
197
|
-
|
|
203
|
+
// No transaction - direct write with queue protection
|
|
198
204
|
const types = Object.keys(data)
|
|
199
|
-
|
|
205
|
+
// Process pre-keys with validation
|
|
200
206
|
for (const type_ of types) {
|
|
201
207
|
const type = type_
|
|
202
208
|
if (type === 'pre-key') {
|
|
203
209
|
await preKeyManager.validateDeletions(data, type)
|
|
204
210
|
}
|
|
205
211
|
}
|
|
206
|
-
|
|
212
|
+
// Write all data in parallel
|
|
207
213
|
await Promise.all(
|
|
208
214
|
types.map(type =>
|
|
209
215
|
getQueue(type).add(async () => {
|
|
@@ -214,18 +220,18 @@ const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetwee
|
|
|
214
220
|
)
|
|
215
221
|
return
|
|
216
222
|
}
|
|
217
|
-
|
|
223
|
+
// In transaction - update cache and mutations
|
|
218
224
|
logger.trace({ types: Object.keys(data) }, 'caching in transaction')
|
|
219
225
|
for (const key_ in data) {
|
|
220
226
|
const key = key_
|
|
221
|
-
|
|
227
|
+
// Ensure structures exist
|
|
222
228
|
ctx.cache[key] = ctx.cache[key] || {}
|
|
223
229
|
ctx.mutations[key] = ctx.mutations[key] || {}
|
|
224
|
-
|
|
230
|
+
// Special handling for pre-keys
|
|
225
231
|
if (key === 'pre-key') {
|
|
226
232
|
await preKeyManager.processOperations(data, key, ctx.cache, ctx.mutations, true)
|
|
227
233
|
} else {
|
|
228
|
-
|
|
234
|
+
// Normal key types
|
|
229
235
|
Object.assign(ctx.cache[key], data[key])
|
|
230
236
|
Object.assign(ctx.mutations[key], data[key])
|
|
231
237
|
}
|
|
@@ -233,19 +239,18 @@ const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetwee
|
|
|
233
239
|
},
|
|
234
240
|
isInTransaction,
|
|
235
241
|
transaction: async (work, key) => {
|
|
236
|
-
const existing =
|
|
237
|
-
|
|
242
|
+
const existing = txStorage.getStore()
|
|
243
|
+
// Nested transaction - reuse existing context
|
|
238
244
|
if (existing) {
|
|
239
245
|
logger.trace('reusing existing transaction context')
|
|
240
246
|
return work()
|
|
241
247
|
}
|
|
242
|
-
|
|
248
|
+
// New transaction - acquire mutex and create context
|
|
243
249
|
const mutex = getTxMutex(key)
|
|
244
250
|
acquireTxMutexRef(key)
|
|
245
251
|
try {
|
|
246
252
|
return await mutex.runExclusive(async () => {
|
|
247
253
|
const ctx = {
|
|
248
|
-
token: storeToken,
|
|
249
254
|
cache: {},
|
|
250
255
|
mutations: {},
|
|
251
256
|
dbQueries: 0
|
|
@@ -253,7 +258,7 @@ const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetwee
|
|
|
253
258
|
logger.trace('entering transaction')
|
|
254
259
|
try {
|
|
255
260
|
const result = await txStorage.run(ctx, work)
|
|
256
|
-
|
|
261
|
+
// Commit mutations
|
|
257
262
|
await commitWithRetry(ctx.mutations)
|
|
258
263
|
logger.trace({ dbQueries: ctx.dbQueries }, 'transaction completed')
|
|
259
264
|
return result
|
|
@@ -109,6 +109,6 @@ exports.Browsers = {
|
|
|
109
109
|
}
|
|
110
110
|
const getPlatformId = browser => {
|
|
111
111
|
const platformType = index_js_1.proto.DeviceProps.PlatformType[browser.toUpperCase()]
|
|
112
|
-
return platformType ? platformType.toString() : '1'
|
|
112
|
+
return platformType ? platformType.toString() : '1' //chrome
|
|
113
113
|
}
|
|
114
114
|
exports.getPlatformId = getPlatformId
|
package/lib/Utils/business.js
CHANGED
|
@@ -186,7 +186,9 @@ const parseProductNode = productNode => {
|
|
|
186
186
|
return product
|
|
187
187
|
}
|
|
188
188
|
exports.parseProductNode = parseProductNode
|
|
189
|
-
|
|
189
|
+
/**
|
|
190
|
+
* Uploads images not already uploaded to WA's servers
|
|
191
|
+
*/
|
|
190
192
|
async function uploadingNecessaryImagesOfProduct(product, waUploadToServer, timeoutMs = 30000) {
|
|
191
193
|
product = {
|
|
192
194
|
...product,
|
|
@@ -196,7 +198,9 @@ async function uploadingNecessaryImagesOfProduct(product, waUploadToServer, time
|
|
|
196
198
|
}
|
|
197
199
|
return product
|
|
198
200
|
}
|
|
199
|
-
|
|
201
|
+
/**
|
|
202
|
+
* Uploads images not already uploaded to WA's servers
|
|
203
|
+
*/
|
|
200
204
|
const uploadingNecessaryImages = async (images, waUploadToServer, timeoutMs = 30000) => {
|
|
201
205
|
const results = await Promise.all(
|
|
202
206
|
images.map(async img => {
|