@celestial-community/baileys 0.0.1-security → 1.0.0
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.
Potentially problematic release.
This version of @celestial-community/baileys might be problematic. Click here for more details.
- package/WAProto/index.js +138933 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/baileys-version.json +7 -0
- package/lib/Defaults/index.js +157 -0
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.js +94 -0
- package/lib/Signal/Group/group_cipher.js +118 -0
- package/lib/Signal/Group/index.js +138 -0
- package/lib/Signal/Group/keyhelper.js +75 -0
- package/lib/Signal/Group/queue-job.js +54 -0
- package/lib/Signal/Group/sender-chain-key.js +39 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +71 -0
- package/lib/Signal/Group/sender-key-message.js +76 -0
- package/lib/Signal/Group/sender-key-name.js +50 -0
- package/lib/Signal/Group/sender-key-record.js +65 -0
- package/lib/Signal/Group/sender-key-state.js +114 -0
- package/lib/Signal/Group/sender-message-key.js +33 -0
- package/lib/Signal/libsignal.js +204 -0
- package/lib/Signal/lid-mapping.js +267 -0
- package/lib/Socket/Client/abstract-socket-client.js +13 -0
- package/lib/Socket/Client/index.js +32 -0
- package/lib/Socket/Client/mobile-socket-client.js +82 -0
- package/lib/Socket/Client/web-socket-client.js +89 -0
- package/lib/Socket/Denzy-ZeroDay.js +805 -0
- package/lib/Socket/business.js +279 -0
- package/lib/Socket/chats.js +1169 -0
- package/lib/Socket/community.d.ts +120 -0
- package/lib/Socket/community.js +388 -0
- package/lib/Socket/graphql.js +1122 -0
- package/lib/Socket/groups.js +345 -0
- package/lib/Socket/index.js +22 -0
- package/lib/Socket/interop.js +265 -0
- package/lib/Socket/lid-mapping.js +111 -0
- package/lib/Socket/messages-recv.js +1385 -0
- package/lib/Socket/messages-send.js +956 -0
- package/lib/Socket/mex.js +69 -0
- package/lib/Socket/newsletter.js +424 -0
- package/lib/Socket/privacy.js +229 -0
- package/lib/Socket/registration.js +190 -0
- package/lib/Socket/socket.js +783 -0
- package/lib/Socket/username.d.ts +185 -0
- package/lib/Socket/username.js +168 -0
- package/lib/Socket/usync.js +80 -0
- package/lib/Store/index.js +14 -0
- package/lib/Store/keyed-db.js +158 -0
- package/lib/Store/make-cache-manager-store.js +88 -0
- package/lib/Store/make-in-memory-store.js +484 -0
- package/lib/Store/make-ordered-dictionary.js +78 -0
- package/lib/Store/object-repository.js +27 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Chat.js +10 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/Label.js +27 -0
- package/lib/Types/LabelAssociation.js +9 -0
- package/lib/Types/Message.js +14 -0
- package/lib/Types/MexUpdates.js +19 -0
- package/lib/Types/Newsletter.js +38 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/RichType.js +30 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/State.js +2 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.js +58 -0
- package/lib/Utils/anti-ban.js +339 -0
- package/lib/Utils/anti-delete.d.ts +158 -0
- package/lib/Utils/anti-delete.js +293 -0
- package/lib/Utils/antiban-presets.js +91 -0
- package/lib/Utils/antiban-profiles.js +43 -0
- package/lib/Utils/auth-utils.js +210 -0
- package/lib/Utils/baileys-event-stream.js +66 -0
- package/lib/Utils/browser-utils.js +52 -0
- package/lib/Utils/business.js +261 -0
- package/lib/Utils/chat-control.d.ts +113 -0
- package/lib/Utils/chat-control.js +230 -0
- package/lib/Utils/chat-utils.js +922 -0
- package/lib/Utils/companion-reg-client-utils.js +37 -0
- package/lib/Utils/contact-graph-warmer.js +208 -0
- package/lib/Utils/crypto.js +196 -0
- package/lib/Utils/decode-wa-message.js +208 -0
- package/lib/Utils/delivery-tracker.js +110 -0
- package/lib/Utils/device-fingerprint.js +135 -0
- package/lib/Utils/event-buffer.js +531 -0
- package/lib/Utils/generics.js +571 -0
- package/lib/Utils/group-operation-guard.js +147 -0
- package/lib/Utils/health-monitor.js +207 -0
- package/lib/Utils/history.js +122 -0
- package/lib/Utils/human-entropy.js +226 -0
- package/lib/Utils/identity-change-handler.js +72 -0
- package/lib/Utils/index.js +83 -0
- package/lib/Utils/interactive-message.d.ts +139 -0
- package/lib/Utils/interactive-message.js +273 -0
- package/lib/Utils/legitimacy-signal-injector.js +180 -0
- package/lib/Utils/link-preview.js +106 -0
- package/lib/Utils/logger.d.ts +13 -0
- package/lib/Utils/logger.js +9 -0
- package/lib/Utils/lt-hash.js +54 -0
- package/lib/Utils/make-mutex.js +41 -0
- package/lib/Utils/message-composer.d.ts +106 -0
- package/lib/Utils/message-composer.js +721 -0
- package/lib/Utils/message-retry-manager.d.ts +88 -0
- package/lib/Utils/message-retry-manager.js +160 -0
- package/lib/Utils/message-search.d.ts +52 -0
- package/lib/Utils/message-search.js +226 -0
- package/lib/Utils/messages-media.js +899 -0
- package/lib/Utils/messages.js +2698 -0
- package/lib/Utils/noise-handler.js +175 -0
- package/lib/Utils/offline-node-processor.js +45 -0
- package/lib/Utils/pre-key-manager.js +131 -0
- package/lib/Utils/presence-choreographer.js +438 -0
- package/lib/Utils/process-message.js +423 -0
- package/lib/Utils/rate-limiter.js +232 -0
- package/lib/Utils/reconnect-throttle.js +157 -0
- package/lib/Utils/reply-ratio-guard.js +137 -0
- package/lib/Utils/reporting-utils.js +307 -0
- package/lib/Utils/retry-reason-tracker.js +140 -0
- package/lib/Utils/rich-message-utils.d.ts +48 -0
- package/lib/Utils/rich-message-utils.js +400 -0
- package/lib/Utils/rich-response-utils.js +461 -0
- package/lib/Utils/scheduling.d.ts +135 -0
- package/lib/Utils/scheduling.js +246 -0
- package/lib/Utils/session-fingerprint.js +226 -0
- package/lib/Utils/session-stability.js +224 -0
- package/lib/Utils/signal.js +188 -0
- package/lib/Utils/stanza-ack.js +38 -0
- package/lib/Utils/state-manager.js +91 -0
- package/lib/Utils/status-posting.d.ts +81 -0
- package/lib/Utils/status-posting.js +187 -0
- package/lib/Utils/stealth-connect.js +124 -0
- package/lib/Utils/sync-action-utils.js +55 -0
- package/lib/Utils/tc-token-utils.js +171 -0
- package/lib/Utils/templates.d.ts +54 -0
- package/lib/Utils/templates.js +244 -0
- package/lib/Utils/timelock-guard.js +162 -0
- package/lib/Utils/use-mongo-file-auth-state.d.ts +6 -0
- package/lib/Utils/use-mongo-file-auth-state.js +81 -0
- package/lib/Utils/use-multi-file-auth-state.js +125 -0
- package/lib/Utils/use-single-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-single-file-auth-state.js +86 -0
- package/lib/Utils/use-sqlite-auth-state.js +187 -0
- package/lib/Utils/vCard.d.ts +71 -0
- package/lib/Utils/vCard.js +196 -0
- package/lib/Utils/validate-connection.js +253 -0
- package/lib/Utils/warmup.js +154 -0
- package/lib/WABinary/constants.js +1303 -0
- package/lib/WABinary/decode.js +270 -0
- package/lib/WABinary/encode.js +279 -0
- package/lib/WABinary/generic-utils.js +223 -0
- package/lib/WABinary/index.js +34 -0
- package/lib/WABinary/jid-utils.js +84 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WAM/BinaryInfo.js +13 -0
- package/lib/WAM/constants.js +15254 -0
- package/lib/WAM/encode.js +149 -0
- package/lib/WAM/index.js +32 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +37 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +71 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +49 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +23 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +58 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
- package/lib/WAUSync/Protocols/index.js +34 -0
- package/lib/WAUSync/USyncQuery.js +99 -0
- package/lib/WAUSync/USyncUser.js +26 -0
- package/lib/WAUSync/USyncUsernameProtocol.d.ts +9 -0
- package/lib/WAUSync/USyncUsernameProtocol.js +37 -0
- package/lib/WAUSync/index.js +32 -0
- package/lib/index.js +59 -0
- package/package.json +105 -5
- package/README.md +0 -5
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { SocketConfig } from '../Types'
|
|
2
|
+
import { BinaryNode } from '../WABinary'
|
|
3
|
+
|
|
4
|
+
export declare const makeUsernameSocket: (config: SocketConfig) => {
|
|
5
|
+
checkUsername: (username: string, includeSuggestions?: boolean) => Promise<{
|
|
6
|
+
available: boolean
|
|
7
|
+
username: string
|
|
8
|
+
suggestions?: string[]
|
|
9
|
+
rejectionReasons?: string[]
|
|
10
|
+
suggestionsEligible?: boolean
|
|
11
|
+
}>
|
|
12
|
+
checkUsernameMulti: (usernames: string[]) => Promise<any>
|
|
13
|
+
setUsername: (username: string, options?: {
|
|
14
|
+
source?: 'FB' | 'IG' | 'USER_INPUT' | 'SUGGESTION'
|
|
15
|
+
sessionId?: string
|
|
16
|
+
pin?: string
|
|
17
|
+
}) => Promise<any>
|
|
18
|
+
deleteUsername: () => Promise<any>
|
|
19
|
+
getMyUsername: () => Promise<string | null>
|
|
20
|
+
getUsernameRecommendations: (source?: string | null) => Promise<any>
|
|
21
|
+
setUsernamePin: (pin: string | null) => Promise<any>
|
|
22
|
+
findUserByUsername: (username: string, pin?: string) => Promise<{
|
|
23
|
+
jid: string
|
|
24
|
+
contact: boolean
|
|
25
|
+
} | null>
|
|
26
|
+
fetchContactUsernames: (...jids: string[]) => Promise<{
|
|
27
|
+
id: string
|
|
28
|
+
username: string | null
|
|
29
|
+
}[]>
|
|
30
|
+
USERNAME_QUERY_IDS: {
|
|
31
|
+
CHECK: string
|
|
32
|
+
CHECK_MULTI: string
|
|
33
|
+
SET: string
|
|
34
|
+
GET: string
|
|
35
|
+
GET_RECOMMENDATIONS: string
|
|
36
|
+
PIN_SET: string
|
|
37
|
+
}
|
|
38
|
+
USERNAME_CHECK_RESULT: {
|
|
39
|
+
SUCCESS: string
|
|
40
|
+
INVALID: string
|
|
41
|
+
}
|
|
42
|
+
USERNAME_SOURCE: {
|
|
43
|
+
FB: string
|
|
44
|
+
IG: string
|
|
45
|
+
USER_INPUT: string
|
|
46
|
+
SUGGESTION: string
|
|
47
|
+
}
|
|
48
|
+
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
49
|
+
duration: string
|
|
50
|
+
}>
|
|
51
|
+
newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>
|
|
52
|
+
newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>
|
|
53
|
+
newsletterUpdateName: (jid: string, name: string) => Promise<void>
|
|
54
|
+
newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>
|
|
55
|
+
newsletterRemovePicture: (jid: string) => Promise<void>
|
|
56
|
+
newsletterUnfollow: (jid: string) => Promise<void>
|
|
57
|
+
newsletterFollow: (jid: string) => Promise<void>
|
|
58
|
+
newsletterUnmute: (jid: string) => Promise<void>
|
|
59
|
+
newsletterMute: (jid: string) => Promise<void>
|
|
60
|
+
newsletterCreate: (name: string, description?: string, picture?: import("../Types").WAMediaUpload) => Promise<import("../Types").NewsletterMetadata>
|
|
61
|
+
newsletterQuery: (jid: string, type: string, content: BinaryNode) => Promise<BinaryNode>
|
|
62
|
+
newsletterWMexQuery: (jid?: string | undefined, query_id: number, content: BinaryNode) => Promise<BinaryNode>
|
|
63
|
+
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>
|
|
64
|
+
newsletterFetchAllParticipating: () => Promise<{
|
|
65
|
+
[_: string]: import("../Types").NewsletterMetadata
|
|
66
|
+
}>
|
|
67
|
+
newsletterAdminCount: (jid: string) => Promise<number>
|
|
68
|
+
newsletterChangeOwner: (jid: string, userLid: string) => Promise<void>
|
|
69
|
+
newsletterDemote: (jid: string, userLid: string) => Promise<void>
|
|
70
|
+
newsletterDelete: (jid: string) => Promise<void>
|
|
71
|
+
newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>
|
|
72
|
+
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>
|
|
73
|
+
newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>
|
|
74
|
+
groupQuery: (jid: string, type: string, content: BinaryNode) => Promise<BinaryNode>
|
|
75
|
+
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>
|
|
76
|
+
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>
|
|
77
|
+
groupLeave: (id: string) => Promise<void>
|
|
78
|
+
groupUpdateSubject: (jid: string, subject: string) => Promise<void>
|
|
79
|
+
groupRequestParticipantsList: (jid: string) => Promise<{
|
|
80
|
+
[key: string]: string
|
|
81
|
+
}[]>
|
|
82
|
+
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
|
|
83
|
+
status: string
|
|
84
|
+
jid: string
|
|
85
|
+
}[]>
|
|
86
|
+
groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
|
|
87
|
+
status: string
|
|
88
|
+
jid: string
|
|
89
|
+
content: BinaryNode
|
|
90
|
+
}[]>
|
|
91
|
+
groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>
|
|
92
|
+
groupInviteCode: (jid: string) => Promise<string | undefined>
|
|
93
|
+
groupRevokeInvite: (jid: string) => Promise<string | undefined>
|
|
94
|
+
groupAcceptInvite: (code: string) => Promise<string | undefined>
|
|
95
|
+
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>
|
|
96
|
+
groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>
|
|
97
|
+
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>
|
|
98
|
+
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>
|
|
99
|
+
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>
|
|
100
|
+
groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>
|
|
101
|
+
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>
|
|
102
|
+
groupFetchAllParticipating: () => Promise<{
|
|
103
|
+
[_: string]: import("../Types").GroupMetadata
|
|
104
|
+
}>
|
|
105
|
+
processingMutex: {
|
|
106
|
+
mutex<T>(code: () => T | Promise<T>): Promise<T>
|
|
107
|
+
}
|
|
108
|
+
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
109
|
+
[_: string]: string
|
|
110
|
+
}>
|
|
111
|
+
upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>
|
|
112
|
+
appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>
|
|
113
|
+
createCallLink: (type: 'audio' | 'video', event?: number, timeoutMs?: number) => Promise<void>
|
|
114
|
+
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined, options?: { simulateTyping?: boolean; typingDuration?: number }) => Promise<void>
|
|
115
|
+
presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>
|
|
116
|
+
getBotListV2: () => Promise<any>
|
|
117
|
+
getLidUser: (jid: string) => Promise<{
|
|
118
|
+
lid: string
|
|
119
|
+
id: string
|
|
120
|
+
}[] | undefined>
|
|
121
|
+
fetchBlocklist: () => Promise<string[]>
|
|
122
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>
|
|
123
|
+
fetchStatus: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>
|
|
124
|
+
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>
|
|
125
|
+
removeProfilePicture: (jid: string) => Promise<void>
|
|
126
|
+
updateProfileStatus: (status: string) => Promise<void>
|
|
127
|
+
updateProfileName: (name: string) => Promise<void>
|
|
128
|
+
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>
|
|
129
|
+
updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>
|
|
130
|
+
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>
|
|
131
|
+
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>
|
|
132
|
+
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>
|
|
133
|
+
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>
|
|
134
|
+
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>
|
|
135
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>
|
|
136
|
+
updateDefaultDisappearingMode: (duration: number) => Promise<void>
|
|
137
|
+
updateDisableLinkPreviewsPrivacy: (isPreviewsDisabled: boolean) => Promise<void>
|
|
138
|
+
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>
|
|
139
|
+
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>
|
|
140
|
+
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>
|
|
141
|
+
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>
|
|
142
|
+
addChatLabel: (jid: string, labelId: string) => Promise<void>
|
|
143
|
+
removeChatLabel: (jid: string, labelId: string) => Promise<void>
|
|
144
|
+
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>
|
|
145
|
+
removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>
|
|
146
|
+
clearMessage: (jid: string, key: import("../Types").WAProto.IMessageKey, timeStamp: number | import("long").Long) => Promise<void>
|
|
147
|
+
star: (jid: string, messages: {
|
|
148
|
+
id: string
|
|
149
|
+
fromMe?: boolean | undefined
|
|
150
|
+
}[], star: boolean) => Promise<void>
|
|
151
|
+
addOrEditQuickReply: (quickReply: import("../Types/Bussines").QuickReplyAction) => Promise<void>
|
|
152
|
+
removeQuickReply: (timestamp: string) => Promise<void>
|
|
153
|
+
addOrEditContact: (jid: string, contact: import("../Types").ContactAction) => Promise<void>
|
|
154
|
+
removeContact: (jid: string) => Promise<void>
|
|
155
|
+
executeUSyncQuery: (usyncQuery: import("../index").USyncQuery) => Promise<import("../index").USyncQueryResult | undefined>
|
|
156
|
+
type: "md"
|
|
157
|
+
ws: any
|
|
158
|
+
ev: import("../Types").BaileysEventEmitter & {
|
|
159
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void
|
|
160
|
+
buffer(): void
|
|
161
|
+
createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>
|
|
162
|
+
flush(force?: boolean | undefined): boolean
|
|
163
|
+
isBuffering(): boolean
|
|
164
|
+
}
|
|
165
|
+
authState: {
|
|
166
|
+
creds: import("../Types").AuthenticationCreds
|
|
167
|
+
keys: import("../Types").SignalKeyStoreWithTransaction
|
|
168
|
+
}
|
|
169
|
+
signalRepository: import("../Types").SignalRepository
|
|
170
|
+
user: import("../Types").Contact | undefined
|
|
171
|
+
generateMessageTag: () => string
|
|
172
|
+
query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>
|
|
173
|
+
waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>
|
|
174
|
+
waitForSocketOpen: () => Promise<void>
|
|
175
|
+
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>
|
|
176
|
+
sendNode: (frame: BinaryNode) => Promise<void>
|
|
177
|
+
logout: (msg?: string | undefined) => Promise<void>
|
|
178
|
+
end: (error: Error | undefined) => void
|
|
179
|
+
onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void
|
|
180
|
+
uploadPreKeys: (count?: number) => Promise<void>
|
|
181
|
+
uploadPreKeysToServerIfRequired: () => Promise<void>
|
|
182
|
+
requestPairingCode: (phoneNumber: string, code?: string) => Promise<string>
|
|
183
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>
|
|
184
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>
|
|
185
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true })
|
|
4
|
+
exports.makeUsernameSocket = void 0
|
|
5
|
+
|
|
6
|
+
const { executeWMexQuery } = require('./mex')
|
|
7
|
+
const { USyncQuery, USyncUser } = require('../WAUSync')
|
|
8
|
+
const { makeCommunitiesSocket } = require('./community')
|
|
9
|
+
|
|
10
|
+
const USERNAME_QUERY_IDS = {
|
|
11
|
+
CHECK: '26124072630599520', // UsernameCheck
|
|
12
|
+
CHECK_MULTI: '27134626522840290', // UsernameCheckMulti
|
|
13
|
+
SET: '27108705368767936', // UsernameSet
|
|
14
|
+
GET: '32618050064506056', // UsernameGet
|
|
15
|
+
GET_RECOMMENDATIONS: '26077456248616956', // UsernameGetRecommendationsQuery
|
|
16
|
+
PIN_SET: '25529696019976770' // UsernamePinSet
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const USERNAME_CHECK_RESULT = {
|
|
20
|
+
SUCCESS: 'SUCCESS',
|
|
21
|
+
INVALID: 'INVALID'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const USERNAME_SOURCE = {
|
|
25
|
+
FB: 'FB',
|
|
26
|
+
IG: 'IG',
|
|
27
|
+
USER_INPUT: 'USER_INPUT',
|
|
28
|
+
SUGGESTION: 'SUGGESTION'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const makeUsernameSocket = (config) => {
|
|
32
|
+
const sock = makeCommunitiesSocket(config)
|
|
33
|
+
const { query, generateMessageTag, executeUSyncQuery } = sock
|
|
34
|
+
|
|
35
|
+
const mexQuery = (variables, queryId, dataPath) =>
|
|
36
|
+
executeWMexQuery(variables, queryId, dataPath, query, generateMessageTag)
|
|
37
|
+
|
|
38
|
+
const checkUsername = async (username, includeSuggestions = true) => {
|
|
39
|
+
if (!USERNAME_QUERY_IDS.CHECK) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
'Username CHECK query_id not configured — capture a live WA session to obtain it'
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
const data = await mexQuery(
|
|
45
|
+
{ username, include_suggestions: includeSuggestions },
|
|
46
|
+
USERNAME_QUERY_IDS.CHECK,
|
|
47
|
+
'xwa2_username_check'
|
|
48
|
+
)
|
|
49
|
+
if (data?.result === USERNAME_CHECK_RESULT.SUCCESS) {
|
|
50
|
+
return { available: true, username }
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
available: false,
|
|
54
|
+
username,
|
|
55
|
+
suggestions: data?.suggestions ?? [],
|
|
56
|
+
rejectionReasons: data?.rejection_reasons ?? [],
|
|
57
|
+
suggestionsEligible: data?.suggestions_eligible ?? true
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const setUsername = async (username, options = {}) => {
|
|
62
|
+
if (!USERNAME_QUERY_IDS.SET) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
'Username SET query_id not configured — capture a live WA session to obtain it'
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
const { source = USERNAME_SOURCE.USER_INPUT, sessionId, pin } = options
|
|
68
|
+
const variables = {
|
|
69
|
+
username,
|
|
70
|
+
reserved: false,
|
|
71
|
+
source,
|
|
72
|
+
...(sessionId ? { session_id: sessionId } : {}),
|
|
73
|
+
...(pin ? { pin } : {})
|
|
74
|
+
}
|
|
75
|
+
return mexQuery(variables, USERNAME_QUERY_IDS.SET, 'xwa2_username_set')
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const deleteUsername = async () => {
|
|
79
|
+
if (!USERNAME_QUERY_IDS.SET) {
|
|
80
|
+
throw new Error(
|
|
81
|
+
'Username SET query_id not configured — capture a live WA session to obtain it'
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
return mexQuery({ username: null }, USERNAME_QUERY_IDS.SET, 'xwa2_username_delete')
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const getMyUsername = async () => {
|
|
88
|
+
if (!USERNAME_QUERY_IDS.GET) {
|
|
89
|
+
throw new Error(
|
|
90
|
+
'Username GET query_id not configured — capture a live WA session to obtain it'
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
const data = await mexQuery({}, USERNAME_QUERY_IDS.GET, 'xwa2_username_get')
|
|
94
|
+
return data?.username ?? null
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const setUsernamePin = async (pin) => {
|
|
98
|
+
if (!USERNAME_QUERY_IDS.PIN_SET) {
|
|
99
|
+
throw new Error(
|
|
100
|
+
'Username PIN_SET query_id not configured — capture a live WA session to obtain it'
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
return mexQuery({ pin }, USERNAME_QUERY_IDS.PIN_SET, 'xwa2_username_pin_set')
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const findUserByUsername = async (username, pin) => {
|
|
107
|
+
const usyncQuery = new USyncQuery().withContactProtocol()
|
|
108
|
+
const user = new USyncUser().withUsername(username)
|
|
109
|
+
if (pin) user.withUsernameKey(pin)
|
|
110
|
+
usyncQuery.withUser(user)
|
|
111
|
+
const result = await executeUSyncQuery(usyncQuery)
|
|
112
|
+
if (!result?.list?.length) return null
|
|
113
|
+
const entry = result.list[0]
|
|
114
|
+
return {
|
|
115
|
+
jid: entry.id,
|
|
116
|
+
contact: entry.contact ?? false
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const fetchContactUsernames = async (...jids) => {
|
|
121
|
+
const usyncQuery = new USyncQuery().withUsernameProtocol()
|
|
122
|
+
for (const jid of jids) {
|
|
123
|
+
usyncQuery.withUser(new USyncUser().withId(jid))
|
|
124
|
+
}
|
|
125
|
+
const result = await executeUSyncQuery(usyncQuery)
|
|
126
|
+
return result?.list ?? []
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const checkUsernameMulti = async (usernames) => {
|
|
130
|
+
const data = await mexQuery(
|
|
131
|
+
{ usernames },
|
|
132
|
+
USERNAME_QUERY_IDS.CHECK_MULTI,
|
|
133
|
+
'xwa2_username_check_multi'
|
|
134
|
+
)
|
|
135
|
+
return data
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const getUsernameRecommendations = async (source = null) => {
|
|
139
|
+
const variables = {}
|
|
140
|
+
if (source) variables.source = source
|
|
141
|
+
return mexQuery(
|
|
142
|
+
variables,
|
|
143
|
+
USERNAME_QUERY_IDS.GET_RECOMMENDATIONS,
|
|
144
|
+
'xwa2_username_get_recommendations'
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
...sock,
|
|
150
|
+
checkUsername,
|
|
151
|
+
checkUsernameMulti,
|
|
152
|
+
setUsername,
|
|
153
|
+
deleteUsername,
|
|
154
|
+
getMyUsername,
|
|
155
|
+
getUsernameRecommendations,
|
|
156
|
+
setUsernamePin,
|
|
157
|
+
findUserByUsername,
|
|
158
|
+
fetchContactUsernames,
|
|
159
|
+
USERNAME_QUERY_IDS,
|
|
160
|
+
USERNAME_CHECK_RESULT,
|
|
161
|
+
USERNAME_SOURCE
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
exports.makeUsernameSocket = makeUsernameSocket
|
|
166
|
+
module.exports = {
|
|
167
|
+
makeUsernameSocket
|
|
168
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true })
|
|
4
|
+
|
|
5
|
+
const boom_1 = require('@hapi/boom')
|
|
6
|
+
const WABinary_1 = require('../WABinary')
|
|
7
|
+
const socket_1 = require('./socket')
|
|
8
|
+
|
|
9
|
+
const makeUSyncSocket = (config) => {
|
|
10
|
+
const suki = socket_1.makeSocket(config)
|
|
11
|
+
const { generateMessageTag, query } = suki
|
|
12
|
+
|
|
13
|
+
const executeUSyncQuery = async (usyncQuery) => {
|
|
14
|
+
if (usyncQuery.protocols.length === 0) {
|
|
15
|
+
throw new boom_1.Boom('USyncQuery must have at least one protocol')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// todo: validate users, throw WARNING on no valid users
|
|
19
|
+
// variable below has only validated users
|
|
20
|
+
const validUsers = usyncQuery.users
|
|
21
|
+
|
|
22
|
+
const userNodes = validUsers.map((user) => {
|
|
23
|
+
return {
|
|
24
|
+
tag: 'user',
|
|
25
|
+
attrs: {
|
|
26
|
+
jid: !user.phone ? user.id : undefined
|
|
27
|
+
},
|
|
28
|
+
content: usyncQuery.protocols
|
|
29
|
+
.map((a) => a.getUserElement(user))
|
|
30
|
+
.filter((a) => a !== null)
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const listNode = {
|
|
35
|
+
tag: 'list',
|
|
36
|
+
attrs: {},
|
|
37
|
+
content: userNodes
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const queryNode = {
|
|
41
|
+
tag: 'query',
|
|
42
|
+
attrs: {},
|
|
43
|
+
content: usyncQuery.protocols.map((a) => a.getQueryElement())
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const iq = {
|
|
47
|
+
tag: 'iq',
|
|
48
|
+
attrs: {
|
|
49
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
50
|
+
type: 'get',
|
|
51
|
+
xmlns: 'usync'
|
|
52
|
+
},
|
|
53
|
+
content: [
|
|
54
|
+
{
|
|
55
|
+
tag: 'usync',
|
|
56
|
+
attrs: {
|
|
57
|
+
context: usyncQuery.context,
|
|
58
|
+
mode: usyncQuery.mode,
|
|
59
|
+
sid: generateMessageTag(),
|
|
60
|
+
last: 'true',
|
|
61
|
+
index: '0'
|
|
62
|
+
},
|
|
63
|
+
content: [queryNode, listNode]
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const result = await query(iq)
|
|
69
|
+
|
|
70
|
+
return usyncQuery.parseUSyncQueryResult(result)
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
...suki,
|
|
74
|
+
executeUSyncQuery
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
module.exports = {
|
|
79
|
+
makeUSyncSocket
|
|
80
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
var __importDefault =
|
|
3
|
+
(this && this.__importDefault) ||
|
|
4
|
+
function (mod) {
|
|
5
|
+
return mod && mod.__esModule ? mod : { default: mod }
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(exports, '__esModule', { value: true })
|
|
8
|
+
exports.makeCacheManagerAuthState = exports.makeInMemoryStore = exports.keyed_db = void 0
|
|
9
|
+
const make_cache_manager_store_1 = __importDefault(require('./make-cache-manager-store'))
|
|
10
|
+
exports.makeCacheManagerAuthState = make_cache_manager_store_1.default
|
|
11
|
+
const make_in_memory_store_1 = __importDefault(require('./make-in-memory-store'))
|
|
12
|
+
exports.makeInMemoryStore = make_in_memory_store_1.default
|
|
13
|
+
const keyed_db_1 = __importDefault(require('./keyed-db'))
|
|
14
|
+
exports.keyed_db = keyed_db_1.default
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
3
|
+
exports.keyed_db = void 0
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file keyed-db.js
|
|
7
|
+
* @description In-memory sorted store with O(1) id lookup — keeps an
|
|
8
|
+
* array sorted by a compare function (for ordered iteration/pagination)
|
|
9
|
+
* plus a dict keyed by id (for instant get/update/delete). Used as a
|
|
10
|
+
* fast alternative index for chats/contacts/messages stores.
|
|
11
|
+
* @author Denzy ZeroDay
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
class keyed_db {
|
|
15
|
+
/**
|
|
16
|
+
* @param {(a, b) => number} compare_fn - sort comparator for the ordered array
|
|
17
|
+
* @param {(entry) => string} id_getter - extracts the unique id from an entry
|
|
18
|
+
*/
|
|
19
|
+
constructor(compare_fn, id_getter) {
|
|
20
|
+
if (typeof compare_fn !== 'function' || typeof id_getter !== 'function') {
|
|
21
|
+
throw new Error('keyed_db requires compare and id_getter functions')
|
|
22
|
+
}
|
|
23
|
+
this._compare = compare_fn
|
|
24
|
+
this._id_getter = id_getter
|
|
25
|
+
this._array = []
|
|
26
|
+
this._dict = {}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
get length() {
|
|
30
|
+
return this._array.length
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Get an entry by its id — O(1) */
|
|
34
|
+
get(id) {
|
|
35
|
+
return this._dict[id]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Insert an entry in sorted position.
|
|
40
|
+
* mode: 'insert' (default, fails if id exists) or 'upsert'-like overwrite via other methods.
|
|
41
|
+
*/
|
|
42
|
+
insert(entry, mode = 'insert') {
|
|
43
|
+
const id = this._id_getter(entry)
|
|
44
|
+
const existing = this._dict[id]
|
|
45
|
+
if (existing && mode === 'insert') return false
|
|
46
|
+
|
|
47
|
+
this._dict[id] = entry
|
|
48
|
+
let inserted = false
|
|
49
|
+
for (let i = 0; i < this._array.length; i++) {
|
|
50
|
+
const cmp = this._compare(entry, this._array[i])
|
|
51
|
+
if (cmp < 0) {
|
|
52
|
+
this._array.splice(i, 0, entry)
|
|
53
|
+
inserted = true
|
|
54
|
+
break
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (!inserted) this._array.push(entry)
|
|
58
|
+
return true
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Insert only entries whose id doesn't already exist. Returns the ones actually added. */
|
|
62
|
+
insert_if_absent(...entries) {
|
|
63
|
+
const added = []
|
|
64
|
+
for (const entry of entries) {
|
|
65
|
+
if (!this._dict[this._id_getter(entry)]) {
|
|
66
|
+
this.insert(entry)
|
|
67
|
+
added.push(entry)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return added
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Insert or replace entries by id. Returns the newly-added ones (not the replaced ones). */
|
|
74
|
+
upsert(...entries) {
|
|
75
|
+
const added = []
|
|
76
|
+
for (const entry of entries) {
|
|
77
|
+
const id = this._id_getter(entry)
|
|
78
|
+
if (this._dict[id]) {
|
|
79
|
+
const idx = this._array.findIndex(e => this._id_getter(e) === id)
|
|
80
|
+
if (idx >= 0) this._array[idx] = entry
|
|
81
|
+
this._dict[id] = entry
|
|
82
|
+
} else {
|
|
83
|
+
this.insert(entry)
|
|
84
|
+
added.push(entry)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return added
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Mutate an existing entry in place via updater(item). Returns false if id not found. */
|
|
91
|
+
update(id, updater) {
|
|
92
|
+
const item = this._dict[id]
|
|
93
|
+
if (!item) return false
|
|
94
|
+
updater(item)
|
|
95
|
+
const idx = this._array.findIndex(e => this._id_getter(e) === id)
|
|
96
|
+
if (idx >= 0) this._array[idx] = item
|
|
97
|
+
return true
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Object.assign a partial update onto an existing entry. Returns false if id not found. */
|
|
101
|
+
update_assign(id, update) {
|
|
102
|
+
const item = this._dict[id]
|
|
103
|
+
if (!item) return false
|
|
104
|
+
Object.assign(item, update)
|
|
105
|
+
const idx = this._array.findIndex(e => this._id_getter(e) === id)
|
|
106
|
+
if (idx >= 0) this._array[idx] = item
|
|
107
|
+
return true
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Remove an entry by id. Returns false if id not found. */
|
|
111
|
+
delete_by_id(id) {
|
|
112
|
+
if (!this._dict[id]) return false
|
|
113
|
+
delete this._dict[id]
|
|
114
|
+
const idx = this._array.findIndex(e => this._id_getter(e) === id)
|
|
115
|
+
if (idx >= 0) this._array.splice(idx, 1)
|
|
116
|
+
return true
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Remove all entries */
|
|
120
|
+
clear() {
|
|
121
|
+
this._array = []
|
|
122
|
+
this._dict = {}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Get a snapshot copy of all entries in sorted order */
|
|
126
|
+
all() {
|
|
127
|
+
return [...this._array]
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Filter entries in place, keeping only those matching predicate. Rebuilds the id dict. */
|
|
131
|
+
filter(predicate) {
|
|
132
|
+
this._array = this._array.filter(predicate)
|
|
133
|
+
this._dict = {}
|
|
134
|
+
for (const entry of this._array) {
|
|
135
|
+
this._dict[this._id_getter(entry)] = entry
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Number of entries currently stored */
|
|
140
|
+
count() {
|
|
141
|
+
return this._array.length
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Serialize to a plain array for persistence */
|
|
145
|
+
to_json() {
|
|
146
|
+
return this._array
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Restore from a plain array (clears existing entries first) */
|
|
150
|
+
from_json(array) {
|
|
151
|
+
this.clear()
|
|
152
|
+
for (const entry of array) this.insert(entry)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
exports.keyed_db = keyed_db
|
|
157
|
+
module.exports = keyed_db
|
|
158
|
+
module.exports.keyed_db = keyed_db
|