@awangxcode/qiro-baileys 7.0.0-rc25.6 → 7.0.0-rc26.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/README.md +1445 -1041
- package/WAProto/WAProto.proto +4 -0
- package/WAProto/index.d.ts +4067 -243
- package/WAProto/index.js +74957 -43330
- package/assets/branding/qiro-logo.svg +24 -0
- package/assets/branding/qiro-mark.png +0 -0
- package/assets/branding/qiro-mark.svg +34 -0
- package/assets/branding/qiro-social-preview.png +0 -0
- package/lib/Defaults/index.d.ts +15 -0
- package/lib/Defaults/index.d.ts.map +1 -1
- package/lib/Defaults/index.js +40 -7
- package/lib/Defaults/index.js.map +1 -1
- package/lib/Extensions/experimental.d.ts +0 -2
- package/lib/Extensions/experimental.d.ts.map +1 -1
- package/lib/Extensions/experimental.js +0 -2
- package/lib/Extensions/experimental.js.map +1 -1
- package/lib/MessageBuilder/index.d.ts.map +1 -1
- package/lib/MessageBuilder/index.js +10 -1
- package/lib/MessageBuilder/index.js.map +1 -1
- package/lib/Signal/lid-mapping.js +3 -3
- package/lib/Signal/lid-mapping.js.map +1 -1
- package/lib/Socket/business.d.ts +283 -1
- package/lib/Socket/business.d.ts.map +1 -1
- package/lib/Socket/chats.d.ts +114 -1
- package/lib/Socket/chats.d.ts.map +1 -1
- package/lib/Socket/chats.js +285 -10
- package/lib/Socket/chats.js.map +1 -1
- package/lib/Socket/communities.d.ts +283 -1
- package/lib/Socket/communities.d.ts.map +1 -1
- package/lib/Socket/groups.d.ts +106 -0
- package/lib/Socket/groups.d.ts.map +1 -1
- package/lib/Socket/index.d.ts +283 -1
- package/lib/Socket/index.d.ts.map +1 -1
- package/lib/Socket/index.js +4 -1
- package/lib/Socket/index.js.map +1 -1
- package/lib/Socket/messages-recv.d.ts +284 -1
- package/lib/Socket/messages-recv.d.ts.map +1 -1
- package/lib/Socket/messages-recv.js +73 -22
- package/lib/Socket/messages-recv.js.map +1 -1
- package/lib/Socket/messages-send.d.ts +297 -1
- package/lib/Socket/messages-send.d.ts.map +1 -1
- package/lib/Socket/messages-send.js +164 -28
- package/lib/Socket/messages-send.js.map +1 -1
- package/lib/Socket/newsletter.d.ts +322 -37
- package/lib/Socket/newsletter.d.ts.map +1 -1
- package/lib/Socket/newsletter.js +341 -1
- package/lib/Socket/newsletter.js.map +1 -1
- package/lib/Socket/socket.d.ts +13 -0
- package/lib/Socket/socket.d.ts.map +1 -1
- package/lib/Socket/socket.js +84 -31
- package/lib/Socket/socket.js.map +1 -1
- package/lib/Store/index.d.ts +4 -0
- package/lib/Store/index.js +4 -0
- package/lib/Store/make-in-memory-store.d.ts +63 -0
- package/lib/Store/make-in-memory-store.js +397 -0
- package/lib/Store/make-ordered-dictionary.d.ts +13 -0
- package/lib/Store/make-ordered-dictionary.js +79 -0
- package/lib/Store/object-repository.d.ts +11 -0
- package/lib/Store/object-repository.js +24 -0
- package/lib/Types/Chat.d.ts +13 -0
- package/lib/Types/Chat.d.ts.map +1 -1
- package/lib/Types/Chat.js +7 -0
- package/lib/Types/Chat.js.map +1 -1
- package/lib/Types/Message.d.ts +65 -1
- package/lib/Types/Message.d.ts.map +1 -1
- package/lib/Types/Message.js +11 -0
- package/lib/Types/Message.js.map +1 -1
- package/lib/Types/Mex.d.ts +68 -39
- package/lib/Types/Mex.d.ts.map +1 -1
- package/lib/Types/Mex.js +66 -0
- package/lib/Types/Mex.js.map +1 -1
- package/lib/Types/Socket.d.ts +45 -0
- package/lib/Types/Socket.d.ts.map +1 -1
- package/lib/Utils/audio-sticker.d.ts +14 -0
- package/lib/Utils/audio-sticker.js +172 -0
- package/lib/Utils/auth-store.d.ts +30 -0
- package/lib/Utils/auth-store.js +77 -0
- package/lib/Utils/chat-theme.d.ts +34 -0
- package/lib/Utils/chat-theme.js +336 -0
- package/lib/Utils/chat-utils.js +2 -2
- package/lib/Utils/chat-utils.js.map +1 -1
- package/lib/Utils/decode-wa-message.d.ts +14 -0
- package/lib/Utils/decode-wa-message.d.ts.map +1 -1
- package/lib/Utils/decode-wa-message.js +55 -0
- package/lib/Utils/decode-wa-message.js.map +1 -1
- package/lib/Utils/event-buffer.d.ts +2 -1
- package/lib/Utils/event-buffer.d.ts.map +1 -1
- package/lib/Utils/event-buffer.js +3 -4
- package/lib/Utils/event-buffer.js.map +1 -1
- package/lib/Utils/generics.d.ts +3 -2
- package/lib/Utils/generics.d.ts.map +1 -1
- package/lib/Utils/generics.js +10 -19
- package/lib/Utils/generics.js.map +1 -1
- package/lib/Utils/group-metadata-cache.d.ts +4 -0
- package/lib/Utils/group-metadata-cache.js +25 -0
- package/lib/Utils/history.js +1 -1
- package/lib/Utils/history.js.map +1 -1
- package/lib/Utils/html-app.d.ts +19 -0
- package/lib/Utils/html-app.js +96 -0
- package/lib/Utils/html-multiplayer.d.ts +10 -0
- package/lib/Utils/html-multiplayer.js +94 -0
- package/lib/Utils/index.d.ts +25 -0
- package/lib/Utils/index.d.ts.map +1 -1
- package/lib/Utils/index.js +27 -0
- package/lib/Utils/index.js.map +1 -1
- package/lib/Utils/link-preview-metadata.d.ts +47 -0
- package/lib/Utils/link-preview-metadata.js +88 -0
- package/lib/Utils/messages-media.d.ts +31 -2
- package/lib/Utils/messages-media.d.ts.map +1 -1
- package/lib/Utils/messages-media.js +66 -19
- package/lib/Utils/messages-media.js.map +1 -1
- package/lib/Utils/messages.d.ts +42 -2
- package/lib/Utils/messages.d.ts.map +1 -1
- package/lib/Utils/messages.js +117 -26
- package/lib/Utils/messages.js.map +1 -1
- package/lib/Utils/modern-messages.d.ts +150 -0
- package/lib/Utils/modern-messages.js +496 -0
- package/lib/Utils/native-flow.d.ts +11 -0
- package/lib/Utils/native-flow.js +116 -0
- package/lib/Utils/newsletter-status.d.ts +158 -0
- package/lib/Utils/newsletter-status.js +651 -0
- package/lib/Utils/optional-media.d.ts +3 -0
- package/lib/Utils/optional-media.js +46 -0
- package/lib/Utils/payment-messages.d.ts +38 -0
- package/lib/Utils/payment-messages.js +160 -0
- package/lib/Utils/process-message.d.ts +11 -0
- package/lib/Utils/process-message.d.ts.map +1 -1
- package/lib/Utils/process-message.js +80 -0
- package/lib/Utils/process-message.js.map +1 -1
- package/lib/Utils/scheduled-message.d.ts +51 -0
- package/lib/Utils/scheduled-message.js +113 -0
- package/lib/Utils/sender-key-memory.d.ts +19 -0
- package/lib/Utils/sender-key-memory.js +51 -0
- package/lib/Utils/status-stickers.d.ts +127 -0
- package/lib/Utils/status-stickers.js +261 -0
- package/lib/Utils/ttl-cache.d.ts +29 -0
- package/lib/Utils/ttl-cache.js +121 -0
- package/lib/Utils/use-mongo-auth-state.d.ts +22 -0
- package/lib/Utils/use-mongo-auth-state.js +68 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +1 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -1
- package/lib/Utils/use-multi-file-auth-state.js +26 -13
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -1
- package/lib/Utils/use-mysql-auth-state.d.ts +20 -0
- package/lib/Utils/use-mysql-auth-state.js +80 -0
- package/lib/Utils/use-nekodb-auth.d.ts +19 -0
- package/lib/Utils/use-nekodb-auth.js +111 -0
- package/lib/Utils/use-postgres-auth-state.d.ts +20 -0
- package/lib/Utils/use-postgres-auth-state.js +80 -0
- package/lib/Utils/use-redis-auth-state.d.ts +20 -0
- package/lib/Utils/use-redis-auth-state.js +90 -0
- package/lib/Utils/use-single-file-auth-state.d.ts +11 -0
- package/lib/Utils/use-single-file-auth-state.js +109 -0
- package/lib/Utils/use-sqlite-auth-state.d.ts +13 -0
- package/lib/Utils/use-sqlite-auth-state.js +121 -0
- package/lib/Utils/username.d.ts +12 -0
- package/lib/Utils/username.js +59 -0
- package/lib/Utils/voice-recognition.d.ts +53 -0
- package/lib/Utils/voice-recognition.js +219 -0
- package/lib/VoIP/audio-feeder.d.ts +24 -0
- package/lib/VoIP/audio-feeder.js +276 -0
- package/lib/VoIP/index.d.ts +93 -0
- package/lib/VoIP/index.js +998 -0
- package/lib/VoIP/relay-transport.d.ts +5 -0
- package/lib/VoIP/relay-transport.js +824 -0
- package/lib/VoIP/signaling.d.ts +11 -0
- package/lib/VoIP/signaling.js +1099 -0
- package/lib/VoIP/types.d.ts +2 -0
- package/lib/VoIP/types.js +12 -0
- package/lib/VoIP/video-feeder.d.ts +24 -0
- package/lib/VoIP/video-feeder.js +276 -0
- package/lib/VoIP/wasm-engine.d.ts +26 -0
- package/lib/VoIP/wasm-engine.js +1318 -0
- package/lib/VoIP/worker-bootstrap.js +1022 -0
- package/lib/WABinary/generic-utils.d.ts +2 -0
- package/lib/WABinary/generic-utils.d.ts.map +1 -1
- package/lib/WABinary/generic-utils.js +2 -0
- package/lib/WABinary/generic-utils.js.map +1 -1
- package/lib/WABinary/jid-utils.d.ts +2 -0
- package/lib/WABinary/jid-utils.d.ts.map +1 -1
- package/lib/WABinary/jid-utils.js +3 -1
- package/lib/WABinary/jid-utils.js.map +1 -1
- package/lib/extensions/awang-MessageBuilder.js +1 -1
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/package.json +78 -31
- package/MIGRASI-QIRO-BAILEYS-RC25.md +0 -102
- package/QIRO-BAILEYS-RC25.md +0 -168
- package/THIRD_PARTY_NOTICES.md +0 -49
- /package/{engine-requirements.js → config/engine-requirements.js} +0 -0
package/lib/Socket/chats.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { Boom } from '@hapi/boom';
|
|
2
2
|
import { proto } from '../../WAProto/index.js';
|
|
3
|
-
import type { BotListInfo, CacheStore, ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAMessage, WAPatchCreate, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyMessagesValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types/index.js';
|
|
3
|
+
import type { BotListInfo, CacheStore, ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAMessage, WAPatchCreate, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyMessagesValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue, SpamReportOptions } from '../Types/index.js';
|
|
4
4
|
import type { QuickReplyAction } from '../Types/Bussines.js';
|
|
5
5
|
import type { LabelActionBody } from '../Types/Label.js';
|
|
6
6
|
import { type BinaryNode } from '../WABinary/index.js';
|
|
7
7
|
import { USyncQuery } from '../WAUSync/index.js';
|
|
8
|
+
export declare const buildSpamListNode: (jid: string, options?: SpamReportOptions) => BinaryNode;
|
|
9
|
+
export declare const readSpamReportResult: (sent: BinaryNode, result: BinaryNode) => {
|
|
10
|
+
jid: string | undefined;
|
|
11
|
+
flow: string | undefined;
|
|
12
|
+
reported: boolean;
|
|
13
|
+
node: BinaryNode;
|
|
14
|
+
};
|
|
8
15
|
export declare const buildProfilePictureQueryContent: (type: "preview" | "image", tcTokenContent?: BinaryNode[]) => BinaryNode[];
|
|
9
16
|
export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
10
17
|
serverProps: {
|
|
@@ -15,6 +22,34 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
15
22
|
/** AB prop 14303: issue tctokens to LID instead of PN. WA Web default: false. */
|
|
16
23
|
lidTrustedTokenIssueToLid: boolean;
|
|
17
24
|
};
|
|
25
|
+
fetchProps: ({ full }?: {
|
|
26
|
+
full?: boolean;
|
|
27
|
+
}) => Promise<Record<string, string>>;
|
|
28
|
+
getServerProps: ({ refresh }?: {
|
|
29
|
+
refresh?: boolean;
|
|
30
|
+
}) => Promise<Record<string, string>>;
|
|
31
|
+
findUserId: (jid: string) => Promise<{
|
|
32
|
+
lid: string | null;
|
|
33
|
+
phoneNumber: string;
|
|
34
|
+
} | {
|
|
35
|
+
lid: string;
|
|
36
|
+
phoneNumber: string | null;
|
|
37
|
+
}>;
|
|
38
|
+
checkAccountHealth: (jid: string) => Promise<{
|
|
39
|
+
jid: string;
|
|
40
|
+
exists: boolean;
|
|
41
|
+
isBusiness: boolean;
|
|
42
|
+
verifiedName: string | null;
|
|
43
|
+
about: string | null;
|
|
44
|
+
hasProfilePhoto: boolean;
|
|
45
|
+
self: {
|
|
46
|
+
capped?: boolean;
|
|
47
|
+
warned?: boolean;
|
|
48
|
+
unlimited?: boolean;
|
|
49
|
+
remaining?: number | null;
|
|
50
|
+
} | null;
|
|
51
|
+
notes: string[];
|
|
52
|
+
}>;
|
|
18
53
|
createCallLink: (type: "audio" | "video", event?: {
|
|
19
54
|
startTime: number;
|
|
20
55
|
}, timeoutMs?: number) => Promise<string | undefined>;
|
|
@@ -80,6 +115,71 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
80
115
|
}[], star: boolean) => Promise<void>;
|
|
81
116
|
addOrEditQuickReply: (quickReply: QuickReplyAction) => Promise<void>;
|
|
82
117
|
removeQuickReply: (timestamp: string) => Promise<void>;
|
|
118
|
+
getUsername: () => Promise<{
|
|
119
|
+
username: any;
|
|
120
|
+
state: any;
|
|
121
|
+
pin: any;
|
|
122
|
+
}>;
|
|
123
|
+
setUsername: (username?: string, options?: {
|
|
124
|
+
reserved?: boolean;
|
|
125
|
+
sessionId?: string;
|
|
126
|
+
source?: string;
|
|
127
|
+
}) => Promise<boolean>;
|
|
128
|
+
removeUsername: () => Promise<boolean>;
|
|
129
|
+
checkUsernameAvailability: (username: string, options?: {
|
|
130
|
+
sessionId?: string;
|
|
131
|
+
source?: string;
|
|
132
|
+
}) => Promise<{
|
|
133
|
+
available: boolean;
|
|
134
|
+
suggestions: any;
|
|
135
|
+
response: any;
|
|
136
|
+
}>;
|
|
137
|
+
setUsernamePin: (pin: string) => Promise<boolean>;
|
|
138
|
+
removeUsernamePin: () => Promise<boolean>;
|
|
139
|
+
updateTextStatus: (text: string, options?: {
|
|
140
|
+
ephemeralDurationSec?: number;
|
|
141
|
+
emoji?: string;
|
|
142
|
+
}) => Promise<any>;
|
|
143
|
+
fetchTextStatus: (jids: string | string[]) => Promise<any>;
|
|
144
|
+
fetchAbout: (jid: string) => Promise<{
|
|
145
|
+
jid: string;
|
|
146
|
+
status: any;
|
|
147
|
+
response: any;
|
|
148
|
+
}>;
|
|
149
|
+
fetchUserNotices: (since?: number) => Promise<{
|
|
150
|
+
id: string | undefined;
|
|
151
|
+
stage: string | undefined;
|
|
152
|
+
t: string | undefined;
|
|
153
|
+
version: string | undefined;
|
|
154
|
+
type: string | undefined;
|
|
155
|
+
}[]>;
|
|
156
|
+
updateUserNoticeStage: (noticeId: string | number, stage: string | number) => Promise<void>;
|
|
157
|
+
fetchOptOutList: (options?: {
|
|
158
|
+
category?: string;
|
|
159
|
+
dhash?: string;
|
|
160
|
+
}) => Promise<{
|
|
161
|
+
[key: string]: string;
|
|
162
|
+
}[]>;
|
|
163
|
+
updateOptOut: (input: {
|
|
164
|
+
jid: string;
|
|
165
|
+
category: string;
|
|
166
|
+
action: string;
|
|
167
|
+
dhash?: string;
|
|
168
|
+
reason?: string;
|
|
169
|
+
entryPoint?: string;
|
|
170
|
+
signupId?: string;
|
|
171
|
+
duration?: number;
|
|
172
|
+
}) => Promise<void>;
|
|
173
|
+
fetchPushSettings: () => Promise<{
|
|
174
|
+
[key: string]: string;
|
|
175
|
+
}>;
|
|
176
|
+
fetchServerLinkPreview: (url: string) => Promise<any>;
|
|
177
|
+
reportSpam: (jid: string, options?: SpamReportOptions) => Promise<{
|
|
178
|
+
jid: string | undefined;
|
|
179
|
+
flow: string | undefined;
|
|
180
|
+
reported: boolean;
|
|
181
|
+
node: BinaryNode;
|
|
182
|
+
}>;
|
|
83
183
|
type: "md";
|
|
84
184
|
ws: import("./Client/websocket.js").WebSocketClient;
|
|
85
185
|
ev: import("../Types/index.js").BaileysEventEmitter & {
|
|
@@ -111,6 +211,7 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
111
211
|
digestKeyBundle: () => Promise<void>;
|
|
112
212
|
rotateSignedPreKey: () => Promise<void>;
|
|
113
213
|
requestPairingCode: (phoneNumber: string, customPairingCode?: string | null) => Promise<string>;
|
|
214
|
+
cancelPairingCode: () => boolean;
|
|
114
215
|
updateServerTimeOffset: ({ attrs }: BinaryNode) => void;
|
|
115
216
|
sendUnifiedSession: () => Promise<void>;
|
|
116
217
|
wamBuffer: import("../index.js").BinaryInfo;
|
|
@@ -121,6 +222,18 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
121
222
|
jid: string;
|
|
122
223
|
exists: boolean;
|
|
123
224
|
}[] | undefined>;
|
|
225
|
+
onWhatsAppUsername: (...usernames: Array<string | {
|
|
226
|
+
username?: string;
|
|
227
|
+
pin?: string;
|
|
228
|
+
usernameKey?: string;
|
|
229
|
+
}>) => Promise<{
|
|
230
|
+
jid: string;
|
|
231
|
+
exists: boolean;
|
|
232
|
+
}[]>;
|
|
233
|
+
getUsernames: (...jids: string[]) => Promise<{
|
|
234
|
+
jid: string;
|
|
235
|
+
username: unknown;
|
|
236
|
+
}[]>;
|
|
124
237
|
fetchAccountReachoutTimelock: () => Promise<import("../Types/index.js").ReachoutTimelockState>;
|
|
125
238
|
fetchNewChatMessageCap: () => Promise<import("../Types/index.js").NewChatMessageCapInfo>;
|
|
126
239
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chats.d.ts","sourceRoot":"","sources":["../../src/Socket/chats.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAE9C,OAAO,KAAK,EACX,WAAW,EACX,UAAU,EACV,gBAAgB,EAGhB,iBAAiB,EAEjB,YAAY,EAEZ,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,aAAa,EAEb,UAAU,EACV,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACnB,MA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,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE;;;;kCAuBrI,MAAM;sBAQlB,MAAM,YAAW,iBAAiB;;;;;;;;;;;0DAzoDtD,GAAG,0BAA0B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA0RH,CAAC;WAAa,CAAC;mBACrD,CAAH;;;;;;;;;;;CA67CC,CAAA"}
|
package/lib/Socket/chats.js
CHANGED
|
@@ -2,7 +2,7 @@ import NodeCache from '@cacheable/node-cache';
|
|
|
2
2
|
import { Boom } from '@hapi/boom';
|
|
3
3
|
import { proto } from '../../WAProto/index.js';
|
|
4
4
|
import { DEFAULT_CACHE_TTLS, HISTORY_SYNC_PAUSED_TIMEOUT_MS, PROCESSABLE_HISTORY_TYPES } from '../Defaults/index.js';
|
|
5
|
-
import { ALL_WA_PATCH_NAMES } from '../Types/index.js';
|
|
5
|
+
import { ALL_WA_PATCH_NAMES, QueryIds, XWAPaths, SPAM_FLOWS } from '../Types/index.js';
|
|
6
6
|
import { SyncState } from '../Types/State.js';
|
|
7
7
|
import { chatModificationToAppPatch, decodePatches, decodeSyncdSnapshot, encodeSyncdPatch, ensureLTHashStateVersion, extractSyncdPatches, generateProfilePicture, getHistoryMsg, isAppStateSyncIrrecoverable, isMissingKeyError, MAX_SYNC_ATTEMPTS, newLTHashState, processSyncAction } from '../Utils/index.js';
|
|
8
8
|
import { makeMutex } from '../Utils/make-mutex.js';
|
|
@@ -11,6 +11,32 @@ import { buildTcTokenFromJid } from '../Utils/tc-token-utils.js';
|
|
|
11
11
|
import { getBinaryNodeChild, getBinaryNodeChildren, isHostedLidUser, isHostedPnUser, isLidUser, isPnUser, jidDecode, jidNormalizedUser, reduceBinaryNodeToDictionary, S_WHATSAPP_NET } from '../WABinary/index.js';
|
|
12
12
|
import { USyncQuery, USyncUser } from '../WAUSync/index.js';
|
|
13
13
|
import { makeSocket } from './socket.js';
|
|
14
|
+
import { executeWMexQuery as genericExecuteWMexQuery } from './mex.js';
|
|
15
|
+
import { isUsernamePin, stripUsernamePrefix, validateUsername } from '../Utils/username.js';
|
|
16
|
+
export const buildSpamListNode = (jid, options = {}) => {
|
|
17
|
+
if (typeof jid !== 'string' || !jid.includes('@'))
|
|
18
|
+
throw new Boom(`${JSON.stringify(jid)} is not a jid to report`, { statusCode: 400, data: { jid } });
|
|
19
|
+
const flow = options.flow ?? SPAM_FLOWS.OverflowMenuReport;
|
|
20
|
+
if (typeof flow !== 'string' || !flow.length)
|
|
21
|
+
throw new Boom('spam flow must be a non-empty string', { statusCode: 400, data: { flow } });
|
|
22
|
+
const attrs = { jid: jid.endsWith('@g.us') ? jid : jidNormalizedUser(jid), spam_flow: flow };
|
|
23
|
+
if (options.source)
|
|
24
|
+
attrs.source = jidNormalizedUser(options.source);
|
|
25
|
+
if (options.subject)
|
|
26
|
+
attrs.subject = options.subject;
|
|
27
|
+
if (typeof options.isKnownChat === 'boolean')
|
|
28
|
+
attrs.is_known_chat = options.isKnownChat ? 'true' : 'false';
|
|
29
|
+
return { tag: 'spam_list', attrs };
|
|
30
|
+
};
|
|
31
|
+
export const readSpamReportResult = (sent, result) => {
|
|
32
|
+
const error = getBinaryNodeChild(result, 'error');
|
|
33
|
+
if (error)
|
|
34
|
+
throw new Boom('reportSpam was rejected by the server', {
|
|
35
|
+
statusCode: Number(error.attrs?.code) || 400,
|
|
36
|
+
data: { jid: sent.attrs.jid, flow: sent.attrs.spam_flow, text: error.attrs?.text }
|
|
37
|
+
});
|
|
38
|
+
return { jid: sent.attrs.jid, flow: sent.attrs.spam_flow, reported: true, node: result };
|
|
39
|
+
};
|
|
14
40
|
export const buildProfilePictureQueryContent = (type, tcTokenContent) => {
|
|
15
41
|
const picture = { tag: 'picture', attrs: { type, query: 'url' } };
|
|
16
42
|
if (tcTokenContent?.length) {
|
|
@@ -25,6 +51,7 @@ export const makeChatsSocket = (config) => {
|
|
|
25
51
|
const getLIDForPN = signalRepository.lidMapping.getLIDForPN.bind(signalRepository.lidMapping);
|
|
26
52
|
let privacySettings;
|
|
27
53
|
/** Server-assigned AB props for protocol behavior. */
|
|
54
|
+
let lastServerProps = {};
|
|
28
55
|
const serverProps = {
|
|
29
56
|
/** AB prop 10518: gate tctoken on 1:1 messages. Default true (safe: avoids 463). */
|
|
30
57
|
privacyTokenOn1to1: true,
|
|
@@ -267,6 +294,91 @@ export const makeChatsSocket = (config) => {
|
|
|
267
294
|
const updateProfileName = async (name) => {
|
|
268
295
|
await chatModify({ pushNameSetting: name }, '');
|
|
269
296
|
};
|
|
297
|
+
const getServerProps = async ({ refresh = false } = {}) => {
|
|
298
|
+
if (refresh)
|
|
299
|
+
return fetchProps({ full: true });
|
|
300
|
+
if (!Object.keys(lastServerProps).length)
|
|
301
|
+
await fetchProps({ full: true });
|
|
302
|
+
return lastServerProps;
|
|
303
|
+
};
|
|
304
|
+
const findUserId = async (jid) => {
|
|
305
|
+
const normalizedJid = jidNormalizedUser(jid);
|
|
306
|
+
if (isPnUser(normalizedJid) || isHostedPnUser(normalizedJid)) {
|
|
307
|
+
const mapping = await signalRepository.lidMapping.getLIDsForPNs([normalizedJid]);
|
|
308
|
+
return { lid: mapping?.[0]?.lid ?? null, phoneNumber: normalizedJid };
|
|
309
|
+
}
|
|
310
|
+
if (isLidUser(normalizedJid) || isHostedLidUser(normalizedJid)) {
|
|
311
|
+
const mapping = await signalRepository.lidMapping.getPNsForLIDs([normalizedJid]);
|
|
312
|
+
return { lid: normalizedJid, phoneNumber: mapping?.[0]?.pn ?? null };
|
|
313
|
+
}
|
|
314
|
+
throw new Boom('Invalid id input to find user ids', { statusCode: 400 });
|
|
315
|
+
};
|
|
316
|
+
const checkAccountHealth = async (jid) => {
|
|
317
|
+
// JID dapat berisi nomor dengan device suffix atau PN/LID domain.
|
|
318
|
+
// Ambil bagian nomor secara aman karena noUncheckedIndexedAccess aktif.
|
|
319
|
+
const number = String(jid ?? '').trim().split('@', 1)[0]?.split(':', 1)[0] ?? '';
|
|
320
|
+
const info = { jid, exists: false, isBusiness: false, verifiedName: null, about: null, hasProfilePhoto: false, self: null, notes: [] };
|
|
321
|
+
if (!/^\+?\d{7,16}$/.test(number)) {
|
|
322
|
+
info.notes.push('Format JID atau nomor tidak valid');
|
|
323
|
+
return info;
|
|
324
|
+
}
|
|
325
|
+
// onWhatsApp() dapat menghasilkan undefined bila USync tidak mengembalikan hasil.
|
|
326
|
+
const onWaResults = (await sock.onWhatsApp(number).catch(() => [])) ?? [];
|
|
327
|
+
const onWa = onWaResults[0];
|
|
328
|
+
info.exists = Boolean(onWa?.exists);
|
|
329
|
+
if (onWa?.jid)
|
|
330
|
+
info.jid = onWa.jid;
|
|
331
|
+
if (!info.exists) {
|
|
332
|
+
info.notes.push('Nomor tidak terdaftar di WhatsApp');
|
|
333
|
+
return info;
|
|
334
|
+
}
|
|
335
|
+
const business = await getBusinessProfile(info.jid).catch(() => undefined);
|
|
336
|
+
if (business && Object.keys(business).length) {
|
|
337
|
+
info.isBusiness = true;
|
|
338
|
+
// Respons business profile menyediakan description, bukan verifiedName.
|
|
339
|
+
// Jangan salah melabeli deskripsi bisnis sebagai nama terverifikasi.
|
|
340
|
+
if (business.description)
|
|
341
|
+
info.notes.push(`Deskripsi bisnis: ${business.description}`);
|
|
342
|
+
}
|
|
343
|
+
const status = await fetchStatus(info.jid).catch(() => undefined);
|
|
344
|
+
const entry = Array.isArray(status) ? status[0] : status;
|
|
345
|
+
const statusContainer = entry && typeof entry === 'object'
|
|
346
|
+
? entry.status
|
|
347
|
+
: undefined;
|
|
348
|
+
const about = statusContainer && typeof statusContainer === 'object' && 'status' in statusContainer
|
|
349
|
+
? statusContainer.status
|
|
350
|
+
: statusContainer;
|
|
351
|
+
info.about = about == null ? null : String(about);
|
|
352
|
+
// profilePictureUrl adalah helper lokal makeChatsSocket, bukan method makeSocket.
|
|
353
|
+
const picture = await profilePictureUrl(info.jid, 'image').catch(() => undefined);
|
|
354
|
+
info.hasProfilePhoto = Boolean(picture);
|
|
355
|
+
const cap = await sock.fetchNewChatMessageCap().catch(() => undefined);
|
|
356
|
+
if (cap) {
|
|
357
|
+
// API returns raw capping status + quota counters, not precomputed booleans.
|
|
358
|
+
const capped = cap.capping_status === 'CAPPED';
|
|
359
|
+
const warned = cap.capping_status === 'FIRST_WARNING' || cap.capping_status === 'SECOND_WARNING';
|
|
360
|
+
const unlimited = cap.capping_status === 'NONE';
|
|
361
|
+
const totalQuota = typeof cap.total_quota === 'number' && Number.isFinite(cap.total_quota)
|
|
362
|
+
? cap.total_quota
|
|
363
|
+
: undefined;
|
|
364
|
+
const usedQuota = typeof cap.used_quota === 'number' && Number.isFinite(cap.used_quota)
|
|
365
|
+
? cap.used_quota
|
|
366
|
+
: 0;
|
|
367
|
+
const remaining = totalQuota === undefined ? null : Math.max(0, totalQuota - usedQuota);
|
|
368
|
+
info.self = { capped, warned, unlimited, remaining };
|
|
369
|
+
if (capped)
|
|
370
|
+
info.notes.push('Akun pemilik sedang dibatasi untuk chat baru');
|
|
371
|
+
else if (warned)
|
|
372
|
+
info.notes.push('Akun pemilik menerima peringatan untuk chat baru');
|
|
373
|
+
else if (unlimited)
|
|
374
|
+
info.notes.push('Akun pemilik tidak sedang dibatasi untuk chat baru');
|
|
375
|
+
else if (remaining !== null)
|
|
376
|
+
info.notes.push(`Sisa kuota chat baru: ${remaining}`);
|
|
377
|
+
else
|
|
378
|
+
info.notes.push('Status pembatasan chat baru diterima, tetapi kuota tidak tersedia');
|
|
379
|
+
}
|
|
380
|
+
return info;
|
|
381
|
+
};
|
|
270
382
|
const fetchBlocklist = async () => {
|
|
271
383
|
const result = await query({
|
|
272
384
|
tag: 'iq',
|
|
@@ -751,7 +863,7 @@ export const makeChatsSocket = (config) => {
|
|
|
751
863
|
}
|
|
752
864
|
};
|
|
753
865
|
/** fetch AB props */
|
|
754
|
-
const fetchProps = async () => {
|
|
866
|
+
const fetchProps = async ({ full = false } = {}) => {
|
|
755
867
|
const resultNode = await query({
|
|
756
868
|
tag: 'iq',
|
|
757
869
|
attrs: {
|
|
@@ -764,20 +876,21 @@ export const makeChatsSocket = (config) => {
|
|
|
764
876
|
tag: 'props',
|
|
765
877
|
attrs: {
|
|
766
878
|
protocol: '1',
|
|
767
|
-
...(authState?.creds?.lastPropHash ? { hash: authState.creds.lastPropHash } : {})
|
|
879
|
+
...(!full && authState?.creds?.lastPropHash ? { hash: authState.creds.lastPropHash } : {})
|
|
768
880
|
}
|
|
769
881
|
}
|
|
770
882
|
]
|
|
771
883
|
});
|
|
772
884
|
const propsNode = getBinaryNodeChild(resultNode, 'props');
|
|
773
|
-
let props =
|
|
885
|
+
let props = lastServerProps;
|
|
774
886
|
if (propsNode) {
|
|
775
887
|
if (propsNode.attrs?.hash) {
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
ev.emit('creds.update', authState.creds);
|
|
888
|
+
authState.creds.lastPropHash = propsNode.attrs.hash;
|
|
889
|
+
ev.emit('creds.update', { lastPropHash: propsNode.attrs.hash });
|
|
779
890
|
}
|
|
780
|
-
|
|
891
|
+
const delta = reduceBinaryNodeToDictionary(propsNode, 'prop');
|
|
892
|
+
lastServerProps = full ? delta : { ...lastServerProps, ...delta };
|
|
893
|
+
props = lastServerProps;
|
|
781
894
|
}
|
|
782
895
|
// Extract protocol-relevant AB props (only the ones we need)
|
|
783
896
|
const privacyTokenProp = props['10518'] ?? props['privacy_token_sending_on_all_1_on_1_messages'];
|
|
@@ -916,7 +1029,7 @@ export const makeChatsSocket = (config) => {
|
|
|
916
1029
|
};
|
|
917
1030
|
const upsertMessage = ev.createBufferedFunction(async (msg, type) => {
|
|
918
1031
|
ev.emit('messages.upsert', { messages: [msg], type });
|
|
919
|
-
if (
|
|
1032
|
+
if (msg.pushName) {
|
|
920
1033
|
let jid = msg.key.fromMe ? authState.creds.me.id : msg.key.participant || msg.key.remoteJid;
|
|
921
1034
|
jid = jidNormalizedUser(jid);
|
|
922
1035
|
if (!msg.key.fromMe) {
|
|
@@ -1145,9 +1258,155 @@ export const makeChatsSocket = (config) => {
|
|
|
1145
1258
|
syncState = SyncState.Connecting;
|
|
1146
1259
|
privacySettings = undefined;
|
|
1147
1260
|
});
|
|
1261
|
+
const executeWMexQuery = (variables, queryId, dataPath) => genericExecuteWMexQuery(variables, queryId, dataPath, query, generateMessageTag);
|
|
1262
|
+
const assertUsername = (username) => {
|
|
1263
|
+
const value = stripUsernamePrefix(username);
|
|
1264
|
+
const validation = validateUsername(value);
|
|
1265
|
+
if (!validation.isValid) {
|
|
1266
|
+
throw new Boom(`username is not accepted by WhatsApp: ${validation.errorType}`, {
|
|
1267
|
+
statusCode: 400,
|
|
1268
|
+
data: { username: value, errorType: validation.errorType }
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1271
|
+
return value;
|
|
1272
|
+
};
|
|
1273
|
+
const getUsername = async () => {
|
|
1274
|
+
const response = await executeWMexQuery({}, QueryIds.USERNAME_GET, XWAPaths.xwa2_username_get);
|
|
1275
|
+
const info = response?.username_info;
|
|
1276
|
+
return { username: info?.username ?? null, state: info?.state ?? null, pin: info?.pin ?? null };
|
|
1277
|
+
};
|
|
1278
|
+
const setUsername = async (username, options = {}) => {
|
|
1279
|
+
const variables = username ? {
|
|
1280
|
+
input: assertUsername(username),
|
|
1281
|
+
reserved: options.reserved ?? false,
|
|
1282
|
+
session_id: options.sessionId ?? generateMessageTag(),
|
|
1283
|
+
source: options.source ?? 'USER_INPUT'
|
|
1284
|
+
} : {};
|
|
1285
|
+
const response = await executeWMexQuery(variables, QueryIds.USERNAME_SET, XWAPaths.xwa2_username_set);
|
|
1286
|
+
return response?.result === 'SUCCESS';
|
|
1287
|
+
};
|
|
1288
|
+
const removeUsername = async () => setUsername(undefined);
|
|
1289
|
+
const checkUsernameAvailability = async (username, options = {}) => {
|
|
1290
|
+
const response = await executeWMexQuery({
|
|
1291
|
+
input: assertUsername(username),
|
|
1292
|
+
session_id: options.sessionId ?? generateMessageTag(),
|
|
1293
|
+
source: options.source ?? 'USER_INPUT'
|
|
1294
|
+
}, QueryIds.USERNAME_CHECK, XWAPaths.xwa2_username_check);
|
|
1295
|
+
return { available: response?.result === 'SUCCESS', suggestions: response?.suggestions ?? [], response };
|
|
1296
|
+
};
|
|
1297
|
+
const setUsernamePin = async (pin) => {
|
|
1298
|
+
const value = String(pin ?? '');
|
|
1299
|
+
if (!isUsernamePin(value))
|
|
1300
|
+
throw new Boom('username pin must be exactly 4 digits', { statusCode: 400, data: { pin: value } });
|
|
1301
|
+
const response = await executeWMexQuery({ pin: value }, QueryIds.USERNAME_PIN_SET, XWAPaths.xwa2_username_pin_set);
|
|
1302
|
+
return response?.result === 'SUCCESS';
|
|
1303
|
+
};
|
|
1304
|
+
const removeUsernamePin = async () => {
|
|
1305
|
+
const response = await executeWMexQuery({ pin: null }, QueryIds.USERNAME_PIN_SET, XWAPaths.xwa2_username_pin_set);
|
|
1306
|
+
return response?.result === 'SUCCESS';
|
|
1307
|
+
};
|
|
1308
|
+
const updateTextStatus = async (text, options = {}) => {
|
|
1309
|
+
const input = { text: text === '' ? null : text ?? null, ephemeral_duration_sec: options.ephemeralDurationSec ?? 0 };
|
|
1310
|
+
if (options.emoji)
|
|
1311
|
+
input.emoji = { content: options.emoji };
|
|
1312
|
+
return executeWMexQuery({ input }, QueryIds.UPDATE_TEXT_STATUS, XWAPaths.xwa2_update_text_status);
|
|
1313
|
+
};
|
|
1314
|
+
const fetchTextStatus = async (jids) => {
|
|
1315
|
+
const list = (Array.isArray(jids) ? jids : [jids]).map(jid => ({ jid: jidNormalizedUser(jid) }));
|
|
1316
|
+
return executeWMexQuery({ input: list }, QueryIds.TEXT_STATUS_LIST, XWAPaths.xwa2_text_status_list);
|
|
1317
|
+
};
|
|
1318
|
+
const fetchAbout = async (jid) => {
|
|
1319
|
+
const normalized = jidNormalizedUser(jid);
|
|
1320
|
+
const decoded = jidDecode(normalized);
|
|
1321
|
+
if (!decoded?.user)
|
|
1322
|
+
throw new Boom('Invalid user jid', { statusCode: 400 });
|
|
1323
|
+
const response = await executeWMexQuery({ user: { user_id: decoded.user } }, QueryIds.ABOUT_STATUS, XWAPaths.xwa2_users_updates_since);
|
|
1324
|
+
const updates = Array.isArray(response) ? response[0]?.updates : undefined;
|
|
1325
|
+
return { jid: normalized, status: updates?.[0]?.text ?? null, response };
|
|
1326
|
+
};
|
|
1327
|
+
const fetchUserNotices = async (since = 0) => {
|
|
1328
|
+
const result = await query({
|
|
1329
|
+
tag: 'iq',
|
|
1330
|
+
attrs: { to: S_WHATSAPP_NET, type: 'get', xmlns: 'tos', id: generateMessageTag() },
|
|
1331
|
+
content: [{ tag: 'get_user_disclosures', attrs: { t: String(since) } }]
|
|
1332
|
+
});
|
|
1333
|
+
return getBinaryNodeChildren(result, 'notice').map(node => ({
|
|
1334
|
+
id: node.attrs.id,
|
|
1335
|
+
stage: node.attrs.stage,
|
|
1336
|
+
t: node.attrs.t,
|
|
1337
|
+
version: node.attrs.version,
|
|
1338
|
+
type: node.attrs.type
|
|
1339
|
+
}));
|
|
1340
|
+
};
|
|
1341
|
+
const updateUserNoticeStage = async (noticeId, stage) => {
|
|
1342
|
+
await query({
|
|
1343
|
+
tag: 'iq',
|
|
1344
|
+
attrs: { to: S_WHATSAPP_NET, type: 'set', xmlns: 'tos', id: generateMessageTag() },
|
|
1345
|
+
content: [{ tag: 'notice', attrs: { id: String(noticeId), stage: String(stage) } }]
|
|
1346
|
+
});
|
|
1347
|
+
};
|
|
1348
|
+
const fetchOptOutList = async (options = {}) => {
|
|
1349
|
+
const attrs = { to: S_WHATSAPP_NET, type: 'get', xmlns: 'optoutlist', id: generateMessageTag() };
|
|
1350
|
+
if (options.category)
|
|
1351
|
+
attrs.category = options.category;
|
|
1352
|
+
const content = options.dhash ? [{ tag: 'item', attrs: { dhash: options.dhash } }] : undefined;
|
|
1353
|
+
const result = await query({ tag: 'iq', attrs, content });
|
|
1354
|
+
return getBinaryNodeChildren(result, 'item').map(node => node.attrs);
|
|
1355
|
+
};
|
|
1356
|
+
const updateOptOut = async (input) => {
|
|
1357
|
+
const attrs = { jid: jidNormalizedUser(input.jid), category: input.category, action: input.action };
|
|
1358
|
+
if (input.dhash)
|
|
1359
|
+
attrs.dhash = input.dhash;
|
|
1360
|
+
if (input.reason)
|
|
1361
|
+
attrs.reason = input.reason;
|
|
1362
|
+
if (input.entryPoint)
|
|
1363
|
+
attrs.entry_point = input.entryPoint;
|
|
1364
|
+
if (input.signupId)
|
|
1365
|
+
attrs.signup_id = input.signupId;
|
|
1366
|
+
if (input.duration !== undefined && input.duration !== null)
|
|
1367
|
+
attrs.duration = String(input.duration);
|
|
1368
|
+
await query({
|
|
1369
|
+
tag: 'iq',
|
|
1370
|
+
attrs: { to: S_WHATSAPP_NET, type: 'set', xmlns: 'optoutlist', id: generateMessageTag() },
|
|
1371
|
+
content: [{ tag: 'item', attrs }]
|
|
1372
|
+
});
|
|
1373
|
+
};
|
|
1374
|
+
const fetchPushSettings = async () => {
|
|
1375
|
+
const result = await query({
|
|
1376
|
+
tag: 'iq',
|
|
1377
|
+
attrs: { to: S_WHATSAPP_NET, type: 'get', xmlns: 'urn:xmpp:whatsapp:push', id: generateMessageTag() },
|
|
1378
|
+
content: [{ tag: 'settings', attrs: {} }]
|
|
1379
|
+
});
|
|
1380
|
+
return getBinaryNodeChild(result, 'settings')?.attrs ?? {};
|
|
1381
|
+
};
|
|
1382
|
+
const fetchServerLinkPreview = async (url) => {
|
|
1383
|
+
let parsed;
|
|
1384
|
+
try {
|
|
1385
|
+
parsed = new URL(url);
|
|
1386
|
+
}
|
|
1387
|
+
catch {
|
|
1388
|
+
throw new Boom('Invalid absolute URL', { statusCode: 400 });
|
|
1389
|
+
}
|
|
1390
|
+
if (!['http:', 'https:'].includes(parsed.protocol) || parsed.username || parsed.password)
|
|
1391
|
+
throw new Boom('Only credential-free HTTP(S) URLs are supported', { statusCode: 400 });
|
|
1392
|
+
return executeWMexQuery({ input: { url: parsed.toString() } }, QueryIds.PLAINTEXT_LINK_PREVIEW, XWAPaths.xwa2_newsletter_link_preview);
|
|
1393
|
+
};
|
|
1394
|
+
const reportSpam = async (jid, options = {}) => {
|
|
1395
|
+
const node = buildSpamListNode(jid, options);
|
|
1396
|
+
const result = await query({
|
|
1397
|
+
tag: 'iq',
|
|
1398
|
+
attrs: { to: S_WHATSAPP_NET, type: 'set', xmlns: 'spam', id: generateMessageTag() },
|
|
1399
|
+
content: [node]
|
|
1400
|
+
});
|
|
1401
|
+
return readSpamReportResult(node, result);
|
|
1402
|
+
};
|
|
1148
1403
|
return {
|
|
1149
1404
|
...sock,
|
|
1150
1405
|
serverProps,
|
|
1406
|
+
fetchProps,
|
|
1407
|
+
getServerProps,
|
|
1408
|
+
findUserId,
|
|
1409
|
+
checkAccountHealth,
|
|
1151
1410
|
createCallLink,
|
|
1152
1411
|
getBotListV2,
|
|
1153
1412
|
messageMutex,
|
|
@@ -1192,7 +1451,23 @@ export const makeChatsSocket = (config) => {
|
|
|
1192
1451
|
removeMessageLabel,
|
|
1193
1452
|
star,
|
|
1194
1453
|
addOrEditQuickReply,
|
|
1195
|
-
removeQuickReply
|
|
1454
|
+
removeQuickReply,
|
|
1455
|
+
getUsername,
|
|
1456
|
+
setUsername,
|
|
1457
|
+
removeUsername,
|
|
1458
|
+
checkUsernameAvailability,
|
|
1459
|
+
setUsernamePin,
|
|
1460
|
+
removeUsernamePin,
|
|
1461
|
+
updateTextStatus,
|
|
1462
|
+
fetchTextStatus,
|
|
1463
|
+
fetchAbout,
|
|
1464
|
+
fetchUserNotices,
|
|
1465
|
+
updateUserNoticeStage,
|
|
1466
|
+
fetchOptOutList,
|
|
1467
|
+
updateOptOut,
|
|
1468
|
+
fetchPushSettings,
|
|
1469
|
+
fetchServerLinkPreview,
|
|
1470
|
+
reportSpam
|
|
1196
1471
|
};
|
|
1197
1472
|
};
|
|
1198
1473
|
//# sourceMappingURL=chats.js.map
|