@dongdev/fca-unofficial 3.0.30 → 4.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.
- package/LICENSE +191 -0
- package/README.md +224 -406
- package/dist/index.d.mts +1241 -0
- package/dist/index.d.ts +1241 -0
- package/dist/index.js +27749 -0
- package/dist/index.mjs +27713 -0
- package/docs/ARCHITECTURE.md +467 -0
- package/docs/DOCS.md +686 -0
- package/fca-config.example.json +33 -0
- package/package.json +33 -22
- package/test/fca.test.cjs +533 -0
- package/CHANGELOG.md +0 -293
- package/DOCS.md +0 -2712
- package/func/checkUpdate.js +0 -222
- package/func/logAdapter.js +0 -33
- package/func/logger.js +0 -48
- package/index.d.ts +0 -751
- package/index.js +0 -8
- package/module/config.js +0 -40
- package/module/login.js +0 -133
- package/module/loginHelper.js +0 -1296
- package/module/options.js +0 -44
- package/src/api/action/addExternalModule.js +0 -25
- package/src/api/action/changeAvatar.js +0 -137
- package/src/api/action/changeBio.js +0 -75
- package/src/api/action/enableAutoSaveAppState.js +0 -73
- package/src/api/action/getCurrentUserID.js +0 -7
- package/src/api/action/handleFriendRequest.js +0 -57
- package/src/api/action/logout.js +0 -76
- package/src/api/action/refreshFb_dtsg.js +0 -48
- package/src/api/action/setPostReaction.js +0 -106
- package/src/api/action/unfriend.js +0 -54
- package/src/api/http/httpGet.js +0 -46
- package/src/api/http/httpPost.js +0 -52
- package/src/api/http/postFormData.js +0 -47
- package/src/api/messaging/addUserToGroup.js +0 -68
- package/src/api/messaging/changeAdminStatus.js +0 -126
- package/src/api/messaging/changeArchivedStatus.js +0 -55
- package/src/api/messaging/changeBlockedStatus.js +0 -48
- package/src/api/messaging/changeGroupImage.js +0 -91
- package/src/api/messaging/changeNickname.js +0 -70
- package/src/api/messaging/changeThreadColor.js +0 -79
- package/src/api/messaging/changeThreadEmoji.js +0 -111
- package/src/api/messaging/createNewGroup.js +0 -88
- package/src/api/messaging/createPoll.js +0 -46
- package/src/api/messaging/createThemeAI.js +0 -98
- package/src/api/messaging/deleteMessage.js +0 -136
- package/src/api/messaging/deleteThread.js +0 -56
- package/src/api/messaging/editMessage.js +0 -68
- package/src/api/messaging/forwardAttachment.js +0 -57
- package/src/api/messaging/getEmojiUrl.js +0 -29
- package/src/api/messaging/getFriendsList.js +0 -82
- package/src/api/messaging/getMessage.js +0 -829
- package/src/api/messaging/getThemePictures.js +0 -62
- package/src/api/messaging/handleMessageRequest.js +0 -65
- package/src/api/messaging/markAsDelivered.js +0 -57
- package/src/api/messaging/markAsRead.js +0 -88
- package/src/api/messaging/markAsReadAll.js +0 -49
- package/src/api/messaging/markAsSeen.js +0 -61
- package/src/api/messaging/muteThread.js +0 -50
- package/src/api/messaging/removeUserFromGroup.js +0 -62
- package/src/api/messaging/resolvePhotoUrl.js +0 -43
- package/src/api/messaging/scheduler.js +0 -264
- package/src/api/messaging/searchForThread.js +0 -52
- package/src/api/messaging/sendMessage.js +0 -270
- package/src/api/messaging/sendTypingIndicator.js +0 -74
- package/src/api/messaging/setMessageReaction.js +0 -91
- package/src/api/messaging/setTitle.js +0 -124
- package/src/api/messaging/shareContact.js +0 -49
- package/src/api/messaging/threadColors.js +0 -128
- package/src/api/messaging/unsendMessage.js +0 -81
- package/src/api/messaging/uploadAttachment.js +0 -492
- package/src/api/socket/core/connectMqtt.js +0 -258
- package/src/api/socket/core/emitAuth.js +0 -103
- package/src/api/socket/core/getSeqID.js +0 -320
- package/src/api/socket/core/getTaskResponseData.js +0 -25
- package/src/api/socket/core/parseDelta.js +0 -377
- package/src/api/socket/detail/buildStream.js +0 -215
- package/src/api/socket/detail/constants.js +0 -28
- package/src/api/socket/listenMqtt.js +0 -377
- package/src/api/socket/middleware/index.js +0 -216
- package/src/api/threads/getThreadHistory.js +0 -664
- package/src/api/threads/getThreadInfo.js +0 -295
- package/src/api/threads/getThreadList.js +0 -293
- package/src/api/threads/getThreadPictures.js +0 -78
- package/src/api/users/getUserID.js +0 -65
- package/src/api/users/getUserInfo.js +0 -399
- package/src/api/users/getUserInfoV2.js +0 -134
- package/src/core/sendReqMqtt.js +0 -96
- package/src/database/models/index.js +0 -87
- package/src/database/models/thread.js +0 -50
- package/src/database/models/user.js +0 -46
- package/src/database/threadData.js +0 -98
- package/src/database/userData.js +0 -89
- package/src/remote/remoteClient.js +0 -123
- package/src/utils/broadcast.js +0 -51
- package/src/utils/client.js +0 -10
- package/src/utils/constants.js +0 -23
- package/src/utils/cookies.js +0 -68
- package/src/utils/format.js +0 -1174
- package/src/utils/headers.js +0 -115
- package/src/utils/loginParser.js +0 -365
- package/src/utils/messageFormat.js +0 -1173
- package/src/utils/request.js +0 -332
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1241 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
|
|
3
|
+
interface FcaOptions {
|
|
4
|
+
logLevel?: "silly" | "info" | "warn" | "error" | "silent";
|
|
5
|
+
listenEvents?: boolean;
|
|
6
|
+
selfListen?: boolean;
|
|
7
|
+
selfListenEvent?: boolean;
|
|
8
|
+
listenTyping?: boolean;
|
|
9
|
+
updatePresence?: boolean;
|
|
10
|
+
forceLogin?: boolean;
|
|
11
|
+
autoMarkRead?: boolean;
|
|
12
|
+
autoReconnect?: boolean;
|
|
13
|
+
online?: boolean;
|
|
14
|
+
emitReady?: boolean;
|
|
15
|
+
userAgent?: string;
|
|
16
|
+
proxy?: string;
|
|
17
|
+
pageID?: string;
|
|
18
|
+
}
|
|
19
|
+
interface FcaContext {
|
|
20
|
+
fbid: string;
|
|
21
|
+
clientId: string;
|
|
22
|
+
cookieString: string;
|
|
23
|
+
mqttClient: Loose | null;
|
|
24
|
+
options: FcaOptions;
|
|
25
|
+
globalOptions?: FcaOptions;
|
|
26
|
+
jar?: Loose;
|
|
27
|
+
userID?: string;
|
|
28
|
+
access_token?: string;
|
|
29
|
+
fb_dtsg?: string;
|
|
30
|
+
ttstamp?: string;
|
|
31
|
+
lastSeqId?: string | number | null;
|
|
32
|
+
syncToken?: string;
|
|
33
|
+
mqttEndpoint?: string;
|
|
34
|
+
region?: string;
|
|
35
|
+
firstListen?: boolean;
|
|
36
|
+
clientID?: string;
|
|
37
|
+
wsReqNumber?: number;
|
|
38
|
+
wsTaskNumber?: number;
|
|
39
|
+
tasks?: Map<string | number, Loose>;
|
|
40
|
+
_emitter?: {
|
|
41
|
+
emit: (event: string, payload?: Loose) => void;
|
|
42
|
+
};
|
|
43
|
+
[key: string]: Loose;
|
|
44
|
+
}
|
|
45
|
+
declare const createDefaultContext: () => FcaContext;
|
|
46
|
+
declare function createFcaState(input: Record<string, Loose>): FcaContext;
|
|
47
|
+
declare function createApiFacade(params: {
|
|
48
|
+
globalOptions: FcaOptions;
|
|
49
|
+
jar: Loose;
|
|
50
|
+
userID: string;
|
|
51
|
+
emitter: Loose;
|
|
52
|
+
setOptions: (globalOptions: FcaOptions, options: Record<string, Loose>) => void;
|
|
53
|
+
getAppState: (jar: Loose) => Loose;
|
|
54
|
+
cookieHeaderFromJar: (jar: Loose) => string;
|
|
55
|
+
getLatestBackup: (uid: string, type: string) => Promise<string | null>;
|
|
56
|
+
}): {
|
|
57
|
+
setOptions: (options: Record<string, any>) => void;
|
|
58
|
+
getCookies: () => string;
|
|
59
|
+
getAppState: () => any;
|
|
60
|
+
getLatestAppStateFromDB: (uid?: string) => Promise<any>;
|
|
61
|
+
getLatestCookieFromDB: (uid?: string) => Promise<string | null>;
|
|
62
|
+
on: any;
|
|
63
|
+
once: any;
|
|
64
|
+
off: any;
|
|
65
|
+
removeAllListeners: any;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
interface LoginCredentials$1 {
|
|
69
|
+
appState?: Loose[];
|
|
70
|
+
email?: string;
|
|
71
|
+
password?: string;
|
|
72
|
+
Cookie?: string | string[] | Record<string, string>;
|
|
73
|
+
}
|
|
74
|
+
declare const login: (credentials: LoginCredentials$1, customOptions?: FcaOptions) => Promise<FcaContext>;
|
|
75
|
+
declare function loginLegacy(credentials: LoginCredentials$1, options?: FcaOptions | ((err: Error | null, ctx?: FcaContext) => void), callback?: (err: Error | null, ctx?: FcaContext) => void): Promise<FcaContext> | undefined;
|
|
76
|
+
interface TokensApiResponse {
|
|
77
|
+
status?: boolean;
|
|
78
|
+
ok?: boolean;
|
|
79
|
+
uid?: string;
|
|
80
|
+
access_token?: string;
|
|
81
|
+
cookies?: Loose[] | string;
|
|
82
|
+
cookie?: Loose[] | string;
|
|
83
|
+
message?: string;
|
|
84
|
+
}
|
|
85
|
+
declare const tokensViaAPI: (email: string, password: string, twoFactor?: string | null, apiBaseUrl?: string | null) => Promise<TokensApiResponse>;
|
|
86
|
+
declare const loginViaAPI: (email: string, password: string, twoFactor?: string | null, apiBaseUrl?: string | null, apiKey?: string | null) => Promise<TokensApiResponse>;
|
|
87
|
+
declare const normalizeCookieHeaderString: (cookieHeader: string) => string[];
|
|
88
|
+
declare const setJarFromPairs: (jar: {
|
|
89
|
+
setCookieSync?: (cookie: string, url: string) => void;
|
|
90
|
+
setCookie?: (cookie: string, url: string, cb?: (err?: Error | null) => void) => void;
|
|
91
|
+
}, pairs: string[], domain: string) => void;
|
|
92
|
+
|
|
93
|
+
interface RequestHelper {
|
|
94
|
+
get: (url: string, config?: Loose) => Promise<Loose>;
|
|
95
|
+
post: (url: string, data?: Loose, config?: Loose) => Promise<Loose>;
|
|
96
|
+
postFormData: (url: string, formData: Loose, config?: Loose) => Promise<Loose>;
|
|
97
|
+
}
|
|
98
|
+
declare const createRequestHelper: (ctx: FcaContext) => RequestHelper;
|
|
99
|
+
|
|
100
|
+
type FcaID = string;
|
|
101
|
+
interface FcaGlobalOptions {
|
|
102
|
+
selfListen: boolean;
|
|
103
|
+
selfListenEvent: boolean;
|
|
104
|
+
listenEvents: boolean;
|
|
105
|
+
listenTyping: boolean;
|
|
106
|
+
updatePresence: boolean;
|
|
107
|
+
forceLogin: boolean;
|
|
108
|
+
autoMarkRead: boolean;
|
|
109
|
+
autoReconnect: boolean;
|
|
110
|
+
online: boolean;
|
|
111
|
+
emitReady: boolean;
|
|
112
|
+
userAgent: string;
|
|
113
|
+
proxy?: string;
|
|
114
|
+
pageID?: string;
|
|
115
|
+
}
|
|
116
|
+
interface FcaState {
|
|
117
|
+
userID: FcaID;
|
|
118
|
+
jar: Loose;
|
|
119
|
+
globalOptions: FcaGlobalOptions;
|
|
120
|
+
loggedIn: boolean;
|
|
121
|
+
access_token?: string;
|
|
122
|
+
fb_dtsg?: string;
|
|
123
|
+
ttstamp?: string;
|
|
124
|
+
mqttClient?: Loose;
|
|
125
|
+
lastSeqId?: string | number | null;
|
|
126
|
+
syncToken?: string;
|
|
127
|
+
mqttEndpoint?: string;
|
|
128
|
+
region?: string;
|
|
129
|
+
firstListen?: boolean;
|
|
130
|
+
clientID?: string;
|
|
131
|
+
clientId?: string;
|
|
132
|
+
wsReqNumber?: number;
|
|
133
|
+
wsTaskNumber?: number;
|
|
134
|
+
tasks?: Map<string | number, Loose>;
|
|
135
|
+
_emitter?: {
|
|
136
|
+
emit: (event: string, payload?: Loose) => void;
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
interface LoginCredentials {
|
|
140
|
+
email?: string;
|
|
141
|
+
password?: string;
|
|
142
|
+
appState?: Loose;
|
|
143
|
+
Cookie?: string | string[] | Record<string, string>;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
interface EventBase {
|
|
147
|
+
threadID?: FcaID;
|
|
148
|
+
senderID?: FcaID;
|
|
149
|
+
timestamp?: number;
|
|
150
|
+
}
|
|
151
|
+
interface MessageEvent extends EventBase {
|
|
152
|
+
type: "message" | "message_reply";
|
|
153
|
+
messageID: string;
|
|
154
|
+
body?: string;
|
|
155
|
+
attachments?: Loose[];
|
|
156
|
+
}
|
|
157
|
+
interface ReactionEvent extends EventBase {
|
|
158
|
+
type: "message_reaction";
|
|
159
|
+
messageID: string;
|
|
160
|
+
reaction: string;
|
|
161
|
+
userID: FcaID;
|
|
162
|
+
}
|
|
163
|
+
interface MessageUnsendEvent extends EventBase {
|
|
164
|
+
type: "message_unsend";
|
|
165
|
+
messageID: string;
|
|
166
|
+
senderID: FcaID;
|
|
167
|
+
deletionTimestamp?: number;
|
|
168
|
+
timestamp?: number;
|
|
169
|
+
}
|
|
170
|
+
interface ReadEvent extends EventBase {
|
|
171
|
+
type: "read" | "read_receipt";
|
|
172
|
+
reader: FcaID;
|
|
173
|
+
}
|
|
174
|
+
interface PresenceEvent extends EventBase {
|
|
175
|
+
type: "presence";
|
|
176
|
+
userID?: FcaID;
|
|
177
|
+
statuses?: Loose;
|
|
178
|
+
}
|
|
179
|
+
interface TypingEvent extends EventBase {
|
|
180
|
+
type: "typ";
|
|
181
|
+
isTyping: boolean;
|
|
182
|
+
from?: FcaID;
|
|
183
|
+
}
|
|
184
|
+
interface FriendRequestReceivedEvent extends EventBase {
|
|
185
|
+
type: "friend_request_received";
|
|
186
|
+
actorFbId: FcaID;
|
|
187
|
+
}
|
|
188
|
+
interface FriendRequestCancelEvent extends EventBase {
|
|
189
|
+
type: "friend_request_cancel";
|
|
190
|
+
actorFbId: FcaID;
|
|
191
|
+
}
|
|
192
|
+
interface ReadyEvent extends EventBase {
|
|
193
|
+
type: "ready";
|
|
194
|
+
error: null;
|
|
195
|
+
}
|
|
196
|
+
interface ThreadEvent extends EventBase {
|
|
197
|
+
type: "event";
|
|
198
|
+
logMessageType?: string;
|
|
199
|
+
logMessageData?: Record<string, Loose>;
|
|
200
|
+
logMessageBody?: string;
|
|
201
|
+
author?: FcaID;
|
|
202
|
+
eventType?: string;
|
|
203
|
+
eventData?: Record<string, Loose>;
|
|
204
|
+
}
|
|
205
|
+
interface AccountInactiveEvent extends EventBase {
|
|
206
|
+
type: "account_inactive";
|
|
207
|
+
reason: string;
|
|
208
|
+
error: string;
|
|
209
|
+
}
|
|
210
|
+
interface StopListenEvent extends EventBase {
|
|
211
|
+
type: "stop_listen";
|
|
212
|
+
error: string;
|
|
213
|
+
}
|
|
214
|
+
type MqttEvent = MessageEvent | ReactionEvent | MessageUnsendEvent | ReadEvent | PresenceEvent | TypingEvent | FriendRequestReceivedEvent | FriendRequestCancelEvent | ReadyEvent | ThreadEvent | AccountInactiveEvent | StopListenEvent;
|
|
215
|
+
type ListenMqttError = Error | AccountInactiveEvent | StopListenEvent;
|
|
216
|
+
|
|
217
|
+
type MqttStreamEvent = MqttEvent | {
|
|
218
|
+
type: "error";
|
|
219
|
+
error: ListenMqttError;
|
|
220
|
+
};
|
|
221
|
+
declare const listenMqtt: (ctx: FcaContext, callback?: (event: MqttStreamEvent) => void) => Loose;
|
|
222
|
+
|
|
223
|
+
declare const DEFAULT_REGIONS: {
|
|
224
|
+
code: string;
|
|
225
|
+
name: string;
|
|
226
|
+
location: string;
|
|
227
|
+
}[];
|
|
228
|
+
declare function createAuthCore(opts?: {
|
|
229
|
+
logger?: (message: string, type?: string) => void;
|
|
230
|
+
config?: Record<string, Loose>;
|
|
231
|
+
axiosBase?: Loose;
|
|
232
|
+
regions?: typeof DEFAULT_REGIONS;
|
|
233
|
+
}): {
|
|
234
|
+
REGION_MAP: Map<string, {
|
|
235
|
+
code: string;
|
|
236
|
+
name: string;
|
|
237
|
+
location: string;
|
|
238
|
+
}>;
|
|
239
|
+
parseRegion: (html: string) => string;
|
|
240
|
+
loginViaAPI: (email: string, password: string, twoFactor?: string | null, apiBaseUrl?: string | null, apiKey?: string | null) => Promise<{
|
|
241
|
+
ok: boolean;
|
|
242
|
+
message: any;
|
|
243
|
+
uid?: undefined;
|
|
244
|
+
access_token?: undefined;
|
|
245
|
+
cookies?: undefined;
|
|
246
|
+
cookie?: undefined;
|
|
247
|
+
} | {
|
|
248
|
+
ok: boolean;
|
|
249
|
+
uid: any;
|
|
250
|
+
access_token: any;
|
|
251
|
+
cookies: Record<string, string>[];
|
|
252
|
+
cookie: string | null;
|
|
253
|
+
message?: undefined;
|
|
254
|
+
}>;
|
|
255
|
+
tokensViaAPI: (email: string, password: string, twoFactor?: string | null, apiBaseUrl?: string | null) => Promise<{
|
|
256
|
+
status: boolean;
|
|
257
|
+
cookies: any;
|
|
258
|
+
uid: any;
|
|
259
|
+
access_token: any;
|
|
260
|
+
cookie: any;
|
|
261
|
+
message?: undefined;
|
|
262
|
+
} | {
|
|
263
|
+
status: boolean;
|
|
264
|
+
message: any;
|
|
265
|
+
cookies?: undefined;
|
|
266
|
+
uid?: undefined;
|
|
267
|
+
access_token?: undefined;
|
|
268
|
+
cookie?: undefined;
|
|
269
|
+
}>;
|
|
270
|
+
normalizeCookieHeaderString: (s: string) => string[];
|
|
271
|
+
setJarFromPairs: (j: Loose, pairs: string[], domain: string) => void;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
interface FcaUpdateCheckConfig {
|
|
275
|
+
enabled: boolean;
|
|
276
|
+
install: boolean;
|
|
277
|
+
notifyIfCurrent: boolean;
|
|
278
|
+
packageName: string;
|
|
279
|
+
registryUrl: string;
|
|
280
|
+
timeoutMs: number;
|
|
281
|
+
}
|
|
282
|
+
interface FcaConfig {
|
|
283
|
+
autoUpdate: boolean;
|
|
284
|
+
checkUpdate: FcaUpdateCheckConfig;
|
|
285
|
+
mqtt: {
|
|
286
|
+
enabled: boolean;
|
|
287
|
+
reconnectInterval: number;
|
|
288
|
+
};
|
|
289
|
+
autoLogin: boolean;
|
|
290
|
+
apiServer: string;
|
|
291
|
+
apiKey: string;
|
|
292
|
+
credentials: {
|
|
293
|
+
email: string;
|
|
294
|
+
password: string;
|
|
295
|
+
twofactor: string;
|
|
296
|
+
};
|
|
297
|
+
antiGetInfo: {
|
|
298
|
+
AntiGetThreadInfo: boolean;
|
|
299
|
+
AntiGetUserInfo: boolean;
|
|
300
|
+
};
|
|
301
|
+
remoteControl: {
|
|
302
|
+
enabled: boolean;
|
|
303
|
+
url: string;
|
|
304
|
+
token: string;
|
|
305
|
+
autoReconnect: boolean;
|
|
306
|
+
};
|
|
307
|
+
[key: string]: Loose;
|
|
308
|
+
}
|
|
309
|
+
interface LoadedFcaConfig {
|
|
310
|
+
config: FcaConfig;
|
|
311
|
+
configPath: string;
|
|
312
|
+
exists: boolean;
|
|
313
|
+
}
|
|
314
|
+
declare const defaultConfig: FcaConfig;
|
|
315
|
+
declare function resolveConfig(input?: Loose): FcaConfig;
|
|
316
|
+
declare function loadConfig(): LoadedFcaConfig;
|
|
317
|
+
declare function writeConfigTemplate(targetPath?: string): string;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Gắn vào ctx sau login (cần Sequelize Thread model). Không có DB → bỏ qua.
|
|
321
|
+
*/
|
|
322
|
+
declare function attachThreadInfoRealtimeSync(ctx: Loose, models: Loose, logger: (msg: string, level?: string) => void, api?: Loose): boolean;
|
|
323
|
+
|
|
324
|
+
interface PackageUpdateCheckResult {
|
|
325
|
+
packageName: string;
|
|
326
|
+
currentVersion: string;
|
|
327
|
+
latestVersion: string;
|
|
328
|
+
updateAvailable: boolean;
|
|
329
|
+
installed: boolean;
|
|
330
|
+
}
|
|
331
|
+
declare function checkForPackageUpdate(input?: FcaConfig | FcaUpdateCheckConfig, logger?: (text: string, type?: string) => void): Promise<PackageUpdateCheckResult | null>;
|
|
332
|
+
declare function runConfiguredUpdateCheck(config: FcaConfig, logger?: (text: string, type?: string) => void): Promise<PackageUpdateCheckResult | null>;
|
|
333
|
+
|
|
334
|
+
type LegacyApiLike = Record<string, Loose>;
|
|
335
|
+
interface FcaClientNamespace {
|
|
336
|
+
[key: string]: Loose;
|
|
337
|
+
}
|
|
338
|
+
interface FcaClientFacade {
|
|
339
|
+
raw: LegacyApiLike;
|
|
340
|
+
messages: FcaClientNamespace;
|
|
341
|
+
threads: FcaClientNamespace;
|
|
342
|
+
users: FcaClientNamespace;
|
|
343
|
+
account: FcaClientNamespace;
|
|
344
|
+
realtime: FcaClientNamespace;
|
|
345
|
+
http: FcaClientNamespace;
|
|
346
|
+
scheduler: FcaClientNamespace;
|
|
347
|
+
}
|
|
348
|
+
interface FcaClientNamespaces {
|
|
349
|
+
messages: FcaClientNamespace;
|
|
350
|
+
threads: FcaClientNamespace;
|
|
351
|
+
users: FcaClientNamespace;
|
|
352
|
+
account: FcaClientNamespace;
|
|
353
|
+
realtime: FcaClientNamespace;
|
|
354
|
+
http: FcaClientNamespace;
|
|
355
|
+
scheduler: FcaClientNamespace;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
declare function createFcaClient(api: LegacyApiLike): FcaClientFacade;
|
|
359
|
+
|
|
360
|
+
/** Tối thiểu để `MessengerContext.reply` gọi `sendMessage`. */
|
|
361
|
+
interface MessengerBotLike {
|
|
362
|
+
readonly api: Loose;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Ngữ cảnh tin nhắn (tương tự `ctx` trong Telegraf): trả lời thread hiện tại, đọc `text` / `senderID`.
|
|
366
|
+
*/
|
|
367
|
+
declare class MessengerContext {
|
|
368
|
+
readonly bot: MessengerBotLike;
|
|
369
|
+
readonly event: MessageEvent;
|
|
370
|
+
constructor(bot: MessengerBotLike, event: MessageEvent);
|
|
371
|
+
get threadID(): MessageEvent["threadID"];
|
|
372
|
+
get senderID(): MessageEvent["senderID"];
|
|
373
|
+
get messageID(): string;
|
|
374
|
+
/** Nội dung text đã trim (Messenger thường dùng `body`). */
|
|
375
|
+
get text(): string;
|
|
376
|
+
get body(): MessageEvent["body"];
|
|
377
|
+
get message(): MessageEvent;
|
|
378
|
+
/**
|
|
379
|
+
* Gửi tin vào đúng thread của sự kiện (callback-style như API legacy).
|
|
380
|
+
*/
|
|
381
|
+
reply(payload: Loose, callback?: Loose): Loose;
|
|
382
|
+
/** `reply` nhưng luôn trả về Promise khi `sendMessage` hỗ trợ promise. */
|
|
383
|
+
replyAsync(payload: Loose): Promise<Loose>;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
interface MessengerBotOptions extends FcaOptions {
|
|
387
|
+
/** Gọi `listenMqtt` ngay sau login. Mặc định `true`. */
|
|
388
|
+
autoListen?: boolean;
|
|
389
|
+
/** Bật chuỗi `use` / `command` / `hears`. Mặc định `true`. */
|
|
390
|
+
enableComposer?: boolean;
|
|
391
|
+
/** Tiền tố lệnh cho `command()`. Mặc định `/`. */
|
|
392
|
+
commandPrefix?: string;
|
|
393
|
+
/** `process.once('SIGINT'|'SIGTERM')` → `stop()`. Mặc định `false`. */
|
|
394
|
+
stopOnSignals?: boolean;
|
|
395
|
+
/**
|
|
396
|
+
* Giới hạn listener trên bot (EventEmitter). Mặc định 64.
|
|
397
|
+
* Dùng 0 nếu cần không giới hạn (tốn RAM hơn khi gắn rất nhiều handler).
|
|
398
|
+
*/
|
|
399
|
+
maxEventListeners?: number;
|
|
400
|
+
}
|
|
401
|
+
type MessengerNext = () => Promise<void>;
|
|
402
|
+
type MessengerMiddleware = (ctx: MessengerContext, next: MessengerNext) => void | Promise<void>;
|
|
403
|
+
/**
|
|
404
|
+
* Client kiểu Discord.js / Telegraf:
|
|
405
|
+
* - Sự kiện: `messageCreate`, `raw`, `messageReactionAdd`, `messageDelete`, `typingStart` / `typingStop`, `threadUpdate`, `ready`, …
|
|
406
|
+
* - Composer: `use`, `command`, `hears`, `catch` (chuỗi middleware + khớp lệnh / text).
|
|
407
|
+
*/
|
|
408
|
+
declare class MessengerBot extends EventEmitter implements MessengerBotLike {
|
|
409
|
+
readonly ctx: FcaContext;
|
|
410
|
+
readonly api: Loose;
|
|
411
|
+
private _facade;
|
|
412
|
+
private _mqtt;
|
|
413
|
+
private _listening;
|
|
414
|
+
private readonly _enableComposer;
|
|
415
|
+
private _commandPrefix;
|
|
416
|
+
private readonly _stopOnSignals;
|
|
417
|
+
private readonly _middlewares;
|
|
418
|
+
private _catchHandler?;
|
|
419
|
+
private _signalsBound;
|
|
420
|
+
private _onStopSignal?;
|
|
421
|
+
private constructor();
|
|
422
|
+
get commandPrefix(): string;
|
|
423
|
+
set commandPrefix(value: string);
|
|
424
|
+
get client(): FcaClientFacade;
|
|
425
|
+
/**
|
|
426
|
+
* Middleware toàn cục (Telegraf-style). Gọi `next()` để chuyển sang lớp sau.
|
|
427
|
+
*/
|
|
428
|
+
use(middleware: MessengerMiddleware): this;
|
|
429
|
+
/**
|
|
430
|
+
* Khớp `/{name}` hoặc `{prefix}{name}` ở đầu nội dung (không phân biệt hoa thường tên lệnh).
|
|
431
|
+
*/
|
|
432
|
+
command(name: string, handler: (ctx: MessengerContext) => void | Promise<void>): this;
|
|
433
|
+
/**
|
|
434
|
+
* Chuỗi khớp toàn bộ text (RegExp) hoặc chứa substring (string).
|
|
435
|
+
*/
|
|
436
|
+
hears(trigger: string | RegExp, handler: (ctx: MessengerContext) => void | Promise<void>): this;
|
|
437
|
+
/**
|
|
438
|
+
* Bắt lỗi ném ra trong composer (middleware / command / hears).
|
|
439
|
+
*/
|
|
440
|
+
catch(handler: (err: unknown, ctx?: MessengerContext) => void): this;
|
|
441
|
+
/** Bắt đầu MQTT (idempotent). */
|
|
442
|
+
startListening(): this;
|
|
443
|
+
/**
|
|
444
|
+
* `startListening` + tùy chọn gắn SIGINT/SIGTERM (Telegraf `launch` gần tương đương).
|
|
445
|
+
*/
|
|
446
|
+
launch(opts?: {
|
|
447
|
+
stopOnSignals?: boolean;
|
|
448
|
+
}): Promise<this>;
|
|
449
|
+
private attachStopSignals;
|
|
450
|
+
/** Gỡ handler SIGINT/SIGTERM để process không giữ reference bot (tối ưu RAM khi stop sớm). */
|
|
451
|
+
private detachStopSignals;
|
|
452
|
+
stop(): Promise<void>;
|
|
453
|
+
private enqueueComposerIfNeeded;
|
|
454
|
+
private runComposer;
|
|
455
|
+
static connect(credentials: LoginCredentials$1, options?: MessengerBotOptions): Promise<MessengerBot>;
|
|
456
|
+
}
|
|
457
|
+
declare function createMessengerBot(credentials: LoginCredentials$1, options?: MessengerBotOptions): Promise<MessengerBot>;
|
|
458
|
+
|
|
459
|
+
declare function attachClientFacade(api: LegacyApiLike, namespaces?: FcaClientNamespaces): FcaClientFacade;
|
|
460
|
+
|
|
461
|
+
type NodeStyleCallback<T> = (err?: Loose, data?: T) => void;
|
|
462
|
+
|
|
463
|
+
interface LegacyDefaultFuncs {
|
|
464
|
+
post: (url: string, jar?: Loose, form?: Loose, qs?: Loose, options?: Loose, customHeader?: Loose) => Promise<Loose>;
|
|
465
|
+
}
|
|
466
|
+
interface MqttPublishClient {
|
|
467
|
+
publish: (topic: string, payload: string, options: {
|
|
468
|
+
qos: number;
|
|
469
|
+
retain: boolean;
|
|
470
|
+
}, callback?: (err?: Loose) => void) => void;
|
|
471
|
+
}
|
|
472
|
+
interface MqttRequestClient extends MqttPublishClient {
|
|
473
|
+
on: (event: "message", listener: (topic: string, message: Buffer | string) => void) => void;
|
|
474
|
+
removeListener: (event: "message", listener: (topic: string, message: Buffer | string) => void) => void;
|
|
475
|
+
setMaxListeners?: (count: number) => void;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
type MessageReaction = string | null;
|
|
479
|
+
interface SetMessageReactionResult {
|
|
480
|
+
success: boolean;
|
|
481
|
+
}
|
|
482
|
+
interface ChangeThreadEmojiResult {
|
|
483
|
+
success: true;
|
|
484
|
+
}
|
|
485
|
+
interface ShareContactResult {
|
|
486
|
+
success: true;
|
|
487
|
+
}
|
|
488
|
+
type ChangeThreadColorResult = {
|
|
489
|
+
success: true;
|
|
490
|
+
} | {
|
|
491
|
+
body: string;
|
|
492
|
+
messageID: string;
|
|
493
|
+
};
|
|
494
|
+
interface ChangeGroupImageResult {
|
|
495
|
+
success: true;
|
|
496
|
+
response: Loose;
|
|
497
|
+
}
|
|
498
|
+
interface EditMessageResult {
|
|
499
|
+
body: string;
|
|
500
|
+
messageID: string;
|
|
501
|
+
}
|
|
502
|
+
interface DeleteMessageResult {
|
|
503
|
+
success: true;
|
|
504
|
+
response: Loose;
|
|
505
|
+
}
|
|
506
|
+
type UnsendMessageResult = {
|
|
507
|
+
success: true;
|
|
508
|
+
} | {
|
|
509
|
+
body: string;
|
|
510
|
+
messageID: string;
|
|
511
|
+
};
|
|
512
|
+
interface ForwardAttachmentResult {
|
|
513
|
+
success: true;
|
|
514
|
+
}
|
|
515
|
+
type ThreadColorMap = Record<string, string>;
|
|
516
|
+
interface SendTypingOptions {
|
|
517
|
+
duration?: number;
|
|
518
|
+
autoStop?: boolean;
|
|
519
|
+
type?: number;
|
|
520
|
+
}
|
|
521
|
+
interface SendMessageMention {
|
|
522
|
+
id: string | number;
|
|
523
|
+
tag: string;
|
|
524
|
+
fromIndex?: number;
|
|
525
|
+
}
|
|
526
|
+
interface MentionPayload {
|
|
527
|
+
mentions?: SendMessageMention[];
|
|
528
|
+
}
|
|
529
|
+
interface SendMessageLocation {
|
|
530
|
+
latitude: number;
|
|
531
|
+
longitude: number;
|
|
532
|
+
current?: boolean;
|
|
533
|
+
live?: boolean;
|
|
534
|
+
}
|
|
535
|
+
interface LocationPayload {
|
|
536
|
+
location: SendMessageLocation;
|
|
537
|
+
}
|
|
538
|
+
type SendMessageEmojiSize = "small" | "medium" | "large" | number;
|
|
539
|
+
interface EmojiPayload {
|
|
540
|
+
emoji: string;
|
|
541
|
+
emojiSize?: SendMessageEmojiSize;
|
|
542
|
+
}
|
|
543
|
+
type StreamAttachment = NodeJS.ReadableStream | Buffer;
|
|
544
|
+
type PreUploadedAttachment = [string, string | number];
|
|
545
|
+
type SendMessageAttachment = StreamAttachment | PreUploadedAttachment;
|
|
546
|
+
interface UploadAttachmentDescriptor {
|
|
547
|
+
buffer?: Buffer;
|
|
548
|
+
data?: Buffer;
|
|
549
|
+
stream?: NodeJS.ReadableStream;
|
|
550
|
+
url?: string;
|
|
551
|
+
path?: string;
|
|
552
|
+
filename?: string;
|
|
553
|
+
contentType?: string;
|
|
554
|
+
}
|
|
555
|
+
type UploadAttachmentInput = StreamAttachment | string | UploadAttachmentDescriptor;
|
|
556
|
+
interface UploadAttachmentOptions {
|
|
557
|
+
concurrency?: number;
|
|
558
|
+
mode?: "single" | "parallel";
|
|
559
|
+
}
|
|
560
|
+
type UploadAttachmentMetadata = Record<string, string | number> & {
|
|
561
|
+
filename?: string;
|
|
562
|
+
filetype?: string;
|
|
563
|
+
thumbnail_src?: string;
|
|
564
|
+
};
|
|
565
|
+
type UploadAttachmentResult = UploadAttachmentMetadata[];
|
|
566
|
+
interface TextPayload {
|
|
567
|
+
body: string;
|
|
568
|
+
}
|
|
569
|
+
interface AttachmentPayload {
|
|
570
|
+
attachment: SendMessageAttachment | SendMessageAttachment[];
|
|
571
|
+
}
|
|
572
|
+
interface StickerPayload {
|
|
573
|
+
sticker: string | number;
|
|
574
|
+
}
|
|
575
|
+
interface UrlPayload {
|
|
576
|
+
url?: string;
|
|
577
|
+
}
|
|
578
|
+
interface ReplyPayload {
|
|
579
|
+
replyToMessage: string;
|
|
580
|
+
}
|
|
581
|
+
interface ForwardPayload {
|
|
582
|
+
forwardAttachmentIds: Array<string | number>;
|
|
583
|
+
}
|
|
584
|
+
type SendMessageContentPayload = TextPayload | AttachmentPayload | EmojiPayload | LocationPayload | StickerPayload | (TextPayload & AttachmentPayload);
|
|
585
|
+
type SendMessageObjectPayload = SendMessageContentPayload & MentionPayload & UrlPayload & Partial<ReplyPayload> & Partial<ForwardPayload>;
|
|
586
|
+
type SendMessagePayload = string | SendMessageObjectPayload | null | undefined;
|
|
587
|
+
interface SendMessageResult {
|
|
588
|
+
body: string | null;
|
|
589
|
+
messageID: string | null;
|
|
590
|
+
threadID: string | null;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
interface SendMessageContext {
|
|
594
|
+
mqttClient?: MqttRequestClient | null;
|
|
595
|
+
wsReqNumber?: number;
|
|
596
|
+
wsTaskNumber?: number;
|
|
597
|
+
userID?: string;
|
|
598
|
+
}
|
|
599
|
+
interface SendMessageCommandDeps {
|
|
600
|
+
ctx: SendMessageContext;
|
|
601
|
+
uploadAttachment: (attachments: StreamAttachment[]) => Promise<UploadAttachmentResult>;
|
|
602
|
+
generateOfflineThreadingID: () => string;
|
|
603
|
+
isReadableStream: (value: Loose) => boolean;
|
|
604
|
+
logError?: (scope: string, error: Loose) => void;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
interface MarkReadCommandDeps {
|
|
608
|
+
defaultFuncs: LegacyDefaultFuncs;
|
|
609
|
+
ctx: FcaContext;
|
|
610
|
+
logError?: (scope: string, error: Loose) => void;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
interface SendTypingIndicatorCommandDeps {
|
|
614
|
+
ctx: FcaContext;
|
|
615
|
+
logError?: (scope: string, error: Loose) => void;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
interface MarkSeenCommandDeps {
|
|
619
|
+
defaultFuncs: LegacyDefaultFuncs;
|
|
620
|
+
ctx: FcaContext;
|
|
621
|
+
logError?: (scope: string, error: Loose) => void;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
interface MarkDeliveredCommandDeps {
|
|
625
|
+
defaultFuncs: LegacyDefaultFuncs;
|
|
626
|
+
ctx: FcaContext;
|
|
627
|
+
logError?: (scope: string, error: Loose) => void;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
interface MarkReadAllCommandDeps {
|
|
631
|
+
defaultFuncs: LegacyDefaultFuncs;
|
|
632
|
+
ctx: FcaContext;
|
|
633
|
+
logError?: (scope: string, error: Loose) => void;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
interface SetMessageReactionCommandDeps {
|
|
637
|
+
ctx: FcaContext;
|
|
638
|
+
generateOfflineThreadingID: () => string;
|
|
639
|
+
getCurrentTimestamp: () => string | number;
|
|
640
|
+
logError?: (scope: string, error: Loose) => void;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
interface ShareContactCommandDeps {
|
|
644
|
+
ctx: FcaContext;
|
|
645
|
+
generateOfflineThreadingID: () => string;
|
|
646
|
+
logError?: (scope: string, error: Loose) => void;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
interface EditMessageCommandDeps {
|
|
650
|
+
ctx: FcaContext;
|
|
651
|
+
generateOfflineThreadingID: () => string;
|
|
652
|
+
logError?: (scope: string, error: Loose) => void;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
interface DeleteMessageCommandDeps {
|
|
656
|
+
ctx: FcaContext;
|
|
657
|
+
generateOfflineThreadingID: () => string;
|
|
658
|
+
logError?: (scope: string, error: Loose) => void;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
interface UnsendMessageCommandDeps {
|
|
662
|
+
ctx: FcaContext;
|
|
663
|
+
generateOfflineThreadingID: () => string;
|
|
664
|
+
logError?: (scope: string, error: Loose) => void;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
interface ForwardAttachmentCommandDeps {
|
|
668
|
+
ctx: FcaContext;
|
|
669
|
+
generateOfflineThreadingID: () => string;
|
|
670
|
+
logError?: (scope: string, error: Loose) => void;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
interface UploadAttachmentLogger {
|
|
674
|
+
info?: (message: string) => void;
|
|
675
|
+
warn?: (message: string) => void;
|
|
676
|
+
error?: (message: string) => void;
|
|
677
|
+
}
|
|
678
|
+
interface UploadAttachmentCommandDeps {
|
|
679
|
+
ctx: {
|
|
680
|
+
jar?: Loose;
|
|
681
|
+
options?: {
|
|
682
|
+
userAgent?: string;
|
|
683
|
+
};
|
|
684
|
+
userID?: string;
|
|
685
|
+
userId?: string;
|
|
686
|
+
};
|
|
687
|
+
logger?: UploadAttachmentLogger;
|
|
688
|
+
logError?: (scope: string, error: Loose) => void;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
interface ChangeThreadColorCommandDeps {
|
|
692
|
+
ctx: FcaContext;
|
|
693
|
+
generateOfflineThreadingID: () => string;
|
|
694
|
+
logError?: (scope: string, error: Loose) => void;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
interface ChangeThreadEmojiCommandDeps {
|
|
698
|
+
defaultFuncs: {
|
|
699
|
+
post: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
700
|
+
};
|
|
701
|
+
ctx: FcaContext;
|
|
702
|
+
generateOfflineThreadingID: () => string;
|
|
703
|
+
logError?: (scope: string, error: Loose) => void;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
interface ResolvePhotoUrlQueryDeps {
|
|
707
|
+
defaultFuncs: {
|
|
708
|
+
get: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
709
|
+
};
|
|
710
|
+
ctx: {
|
|
711
|
+
jar: Loose;
|
|
712
|
+
};
|
|
713
|
+
logError?: (scope: string, error: Loose) => void;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
interface GetMessageQueryDeps {
|
|
717
|
+
defaultFuncs: {
|
|
718
|
+
post: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
719
|
+
};
|
|
720
|
+
ctx: {
|
|
721
|
+
jar: Loose;
|
|
722
|
+
userID?: string;
|
|
723
|
+
globalOptions?: {
|
|
724
|
+
pageID?: string;
|
|
725
|
+
};
|
|
726
|
+
};
|
|
727
|
+
logError?: (scope: string, error: Loose) => void;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
interface MessagesDomainDeps {
|
|
731
|
+
send: SendMessageCommandDeps;
|
|
732
|
+
markRead: MarkReadCommandDeps;
|
|
733
|
+
typing: SendTypingIndicatorCommandDeps;
|
|
734
|
+
markSeen?: MarkSeenCommandDeps;
|
|
735
|
+
markDelivered?: MarkDeliveredCommandDeps;
|
|
736
|
+
markReadAll?: MarkReadAllCommandDeps;
|
|
737
|
+
reaction: SetMessageReactionCommandDeps;
|
|
738
|
+
uploadAttachment?: UploadAttachmentCommandDeps;
|
|
739
|
+
edit?: EditMessageCommandDeps;
|
|
740
|
+
delete?: DeleteMessageCommandDeps;
|
|
741
|
+
unsend?: UnsendMessageCommandDeps;
|
|
742
|
+
forwardAttachment?: ForwardAttachmentCommandDeps;
|
|
743
|
+
shareContact?: ShareContactCommandDeps;
|
|
744
|
+
threadColor: ChangeThreadColorCommandDeps;
|
|
745
|
+
threadEmoji: ChangeThreadEmojiCommandDeps;
|
|
746
|
+
get?: GetMessageQueryDeps;
|
|
747
|
+
photoUrl?: ResolvePhotoUrlQueryDeps;
|
|
748
|
+
}
|
|
749
|
+
declare function createMessagesDomain(deps: MessagesDomainDeps): {
|
|
750
|
+
[k: string]: any;
|
|
751
|
+
};
|
|
752
|
+
|
|
753
|
+
interface GetThreadInfoQueryDeps {
|
|
754
|
+
defaultFuncs: {
|
|
755
|
+
post: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
756
|
+
};
|
|
757
|
+
api: Loose;
|
|
758
|
+
ctx: {
|
|
759
|
+
jar: Loose;
|
|
760
|
+
};
|
|
761
|
+
logError?: (scope: string, error: Loose) => void;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
interface GetThreadListQueryDeps {
|
|
765
|
+
defaultFuncs: {
|
|
766
|
+
post: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
767
|
+
};
|
|
768
|
+
ctx: {
|
|
769
|
+
jar: Loose;
|
|
770
|
+
userID?: string;
|
|
771
|
+
};
|
|
772
|
+
logError?: (scope: string, error: Loose) => void;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
interface GetThreadHistoryQueryDeps {
|
|
776
|
+
defaultFuncs: {
|
|
777
|
+
post: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
778
|
+
};
|
|
779
|
+
ctx: {
|
|
780
|
+
jar: Loose;
|
|
781
|
+
userID?: string;
|
|
782
|
+
};
|
|
783
|
+
logError?: (scope: string, error: Loose) => void;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
interface GetThreadPicturesQueryDeps {
|
|
787
|
+
defaultFuncs: {
|
|
788
|
+
post: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
789
|
+
};
|
|
790
|
+
ctx: {
|
|
791
|
+
jar: Loose;
|
|
792
|
+
};
|
|
793
|
+
logError?: (scope: string, error: Loose) => void;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
interface MuteThreadCommandDeps {
|
|
797
|
+
defaultFuncs: LegacyDefaultFuncs;
|
|
798
|
+
ctx: FcaContext;
|
|
799
|
+
logError?: (scope: string, error: Loose) => void;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
interface ChangeArchivedStatusCommandDeps {
|
|
803
|
+
defaultFuncs: LegacyDefaultFuncs;
|
|
804
|
+
ctx: FcaContext;
|
|
805
|
+
logError?: (scope: string, error: Loose) => void;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
interface AddUsersToGroupCommandDeps {
|
|
809
|
+
ctx: FcaContext;
|
|
810
|
+
generateOfflineThreadingID: () => string;
|
|
811
|
+
logError?: (scope: string, error: Loose) => void;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
interface RemoveUserFromGroupCommandDeps {
|
|
815
|
+
ctx: FcaContext;
|
|
816
|
+
generateOfflineThreadingID: () => string;
|
|
817
|
+
logError?: (scope: string, error: Loose) => void;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
interface ChangeAdminStatusCommandDeps {
|
|
821
|
+
ctx: FcaContext;
|
|
822
|
+
generateOfflineThreadingID: () => string;
|
|
823
|
+
logError?: (scope: string, error: Loose) => void;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
interface ChangeGroupImageCommandDeps {
|
|
827
|
+
defaultFuncs: {
|
|
828
|
+
postFormData: (url: string, jar: Loose, form: Record<string, Loose>, query?: Record<string, Loose>) => Promise<Loose>;
|
|
829
|
+
};
|
|
830
|
+
ctx: FcaContext;
|
|
831
|
+
generateOfflineThreadingID: () => string;
|
|
832
|
+
logError?: (scope: string, error: Loose) => void;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
interface ChangeNicknameCommandDeps {
|
|
836
|
+
ctx: FcaContext;
|
|
837
|
+
generateOfflineThreadingID: () => string;
|
|
838
|
+
logError?: (scope: string, error: Loose) => void;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
interface CreateNewGroupCommandDeps {
|
|
842
|
+
defaultFuncs: {
|
|
843
|
+
post: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
844
|
+
};
|
|
845
|
+
ctx: FcaContext & {
|
|
846
|
+
jar: Loose;
|
|
847
|
+
};
|
|
848
|
+
logError?: (scope: string, error: Loose) => void;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
interface CreatePollCommandDeps {
|
|
852
|
+
ctx: FcaContext;
|
|
853
|
+
generateOfflineThreadingID: () => string;
|
|
854
|
+
logError?: (scope: string, error: Loose) => void;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
interface ThemeAssetImage {
|
|
858
|
+
url: string | null;
|
|
859
|
+
}
|
|
860
|
+
interface ThemeBackgroundAsset {
|
|
861
|
+
id: string | null;
|
|
862
|
+
image: ThemeAssetImage;
|
|
863
|
+
}
|
|
864
|
+
interface CreateThemeAIResult {
|
|
865
|
+
id: string;
|
|
866
|
+
accessibility_label: string | null;
|
|
867
|
+
background_asset: ThemeBackgroundAsset;
|
|
868
|
+
}
|
|
869
|
+
type ThemePicturesResult = Loose;
|
|
870
|
+
|
|
871
|
+
interface CreateThemeAICommandDeps {
|
|
872
|
+
defaultFuncs: {
|
|
873
|
+
post: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
874
|
+
};
|
|
875
|
+
ctx: {
|
|
876
|
+
jar: Loose;
|
|
877
|
+
userID?: string;
|
|
878
|
+
};
|
|
879
|
+
createClientMutationId?: () => string;
|
|
880
|
+
logError?: (scope: string, error: Loose) => void;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
interface HandleMessageRequestCommandDeps {
|
|
884
|
+
defaultFuncs: LegacyDefaultFuncs;
|
|
885
|
+
ctx: FcaContext;
|
|
886
|
+
logError?: (scope: string, error: Loose) => void;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
interface DeleteThreadCommandDeps {
|
|
890
|
+
defaultFuncs: LegacyDefaultFuncs;
|
|
891
|
+
ctx: FcaContext;
|
|
892
|
+
logError?: (scope: string, error: Loose) => void;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
interface SetTitleCommandDeps {
|
|
896
|
+
defaultFuncs: LegacyDefaultFuncs;
|
|
897
|
+
ctx: FcaContext;
|
|
898
|
+
generateOfflineThreadingID: () => string;
|
|
899
|
+
generateTimestampRelative: () => string;
|
|
900
|
+
generateThreadingID: (clientID: string) => string;
|
|
901
|
+
logError?: (scope: string, error: Loose) => void;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
interface SearchForThreadQueryDeps {
|
|
905
|
+
defaultFuncs: LegacyDefaultFuncs;
|
|
906
|
+
ctx: FcaContext;
|
|
907
|
+
logError?: (scope: string, error: Loose) => void;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
interface GetThemePicturesQueryDeps {
|
|
911
|
+
defaultFuncs: {
|
|
912
|
+
post: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
913
|
+
};
|
|
914
|
+
ctx: {
|
|
915
|
+
jar: Loose;
|
|
916
|
+
userID?: string;
|
|
917
|
+
};
|
|
918
|
+
logError?: (scope: string, error: Loose) => void;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
interface ThreadsDomainDeps {
|
|
922
|
+
info: GetThreadInfoQueryDeps;
|
|
923
|
+
list: GetThreadListQueryDeps;
|
|
924
|
+
history: GetThreadHistoryQueryDeps;
|
|
925
|
+
pictures: GetThreadPicturesQueryDeps;
|
|
926
|
+
color?: ChangeThreadColorCommandDeps;
|
|
927
|
+
emoji?: ChangeThreadEmojiCommandDeps;
|
|
928
|
+
mute?: MuteThreadCommandDeps;
|
|
929
|
+
archive?: ChangeArchivedStatusCommandDeps;
|
|
930
|
+
addUsers?: AddUsersToGroupCommandDeps;
|
|
931
|
+
removeUser?: RemoveUserFromGroupCommandDeps;
|
|
932
|
+
adminStatus?: ChangeAdminStatusCommandDeps;
|
|
933
|
+
groupImage?: ChangeGroupImageCommandDeps;
|
|
934
|
+
nickname?: ChangeNicknameCommandDeps;
|
|
935
|
+
createGroup?: CreateNewGroupCommandDeps;
|
|
936
|
+
createPoll?: CreatePollCommandDeps;
|
|
937
|
+
createThemeAI?: CreateThemeAICommandDeps;
|
|
938
|
+
messageRequest?: HandleMessageRequestCommandDeps;
|
|
939
|
+
deleteThread?: DeleteThreadCommandDeps;
|
|
940
|
+
title?: SetTitleCommandDeps;
|
|
941
|
+
search?: SearchForThreadQueryDeps;
|
|
942
|
+
themePictures?: GetThemePicturesQueryDeps;
|
|
943
|
+
}
|
|
944
|
+
declare function createThreadsDomain(deps: ThreadsDomainDeps): {
|
|
945
|
+
[k: string]: any;
|
|
946
|
+
};
|
|
947
|
+
|
|
948
|
+
type ListenerCallback = (error: ListenMqttError | null, event?: MqttEvent | null) => void;
|
|
949
|
+
interface RealtimeMessageEmitter {
|
|
950
|
+
stopListening: (callback?: () => void) => void;
|
|
951
|
+
stopListeningAsync: () => Promise<void>;
|
|
952
|
+
[key: string]: Loose;
|
|
953
|
+
}
|
|
954
|
+
interface RealtimeListenerDeps {
|
|
955
|
+
EventEmitter: Loose;
|
|
956
|
+
logger: (text: string, type?: string) => void;
|
|
957
|
+
emitAuth: (ctx: Loose, api: Loose, globalCallback: ListenerCallback, reason: string, detail?: string) => void;
|
|
958
|
+
createMiddlewareSystem: () => {
|
|
959
|
+
use: (middleware: Loose, fn?: Loose) => Loose;
|
|
960
|
+
remove: (identifier: Loose) => boolean;
|
|
961
|
+
clear: () => void;
|
|
962
|
+
list: () => string[];
|
|
963
|
+
setEnabled: (name: string, enabled: boolean) => boolean;
|
|
964
|
+
wrapCallback: (callback: ListenerCallback) => ListenerCallback;
|
|
965
|
+
count: number;
|
|
966
|
+
};
|
|
967
|
+
topics: readonly string[];
|
|
968
|
+
listenMqttCore: (defaultFuncs: Loose, api: Loose, ctx: Loose, globalCallback: ListenerCallback) => void;
|
|
969
|
+
getSeqIDFactory: (defaultFuncs: Loose, api: Loose, ctx: Loose, globalCallback: ListenerCallback, form: Record<string, Loose>, retryCount?: number) => Promise<void>;
|
|
970
|
+
}
|
|
971
|
+
declare function createRealtimeListener(deps: RealtimeListenerDeps): (defaultFuncs: Loose, api: Loose, ctx: Loose, opts?: Record<string, Loose>) => (callback?: ListenerCallback) => RealtimeMessageEmitter;
|
|
972
|
+
|
|
973
|
+
declare function createRealtimeDomain(deps: Parameters<typeof createRealtimeListener>[0]): {
|
|
974
|
+
listen: (defaultFuncs: Loose, api: Loose, ctx: Loose, opts?: Record<string, Loose>) => (callback?: (error: ListenMqttError | null, event?: MqttEvent | null) => void) => RealtimeMessageEmitter;
|
|
975
|
+
};
|
|
976
|
+
|
|
977
|
+
interface GetUserInfoQueryDeps {
|
|
978
|
+
defaultFuncs: {
|
|
979
|
+
post: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
980
|
+
};
|
|
981
|
+
api: Loose;
|
|
982
|
+
ctx: Loose;
|
|
983
|
+
logger?: (text: string, type?: string) => void;
|
|
984
|
+
logError?: (scope: string, error: Loose) => void;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
interface GetUserInfoV2QueryDeps {
|
|
988
|
+
defaultFuncs: {
|
|
989
|
+
post: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
990
|
+
};
|
|
991
|
+
ctx: Loose;
|
|
992
|
+
logger?: (text: string, type?: string) => void;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
interface GetUserIdQueryDeps {
|
|
996
|
+
defaultFuncs: {
|
|
997
|
+
get: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
998
|
+
};
|
|
999
|
+
ctx: {
|
|
1000
|
+
userID: string;
|
|
1001
|
+
clientId: string;
|
|
1002
|
+
jar: Loose;
|
|
1003
|
+
};
|
|
1004
|
+
logError?: (scope: string, error: Loose) => void;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
interface GetFriendsListQueryDeps {
|
|
1008
|
+
defaultFuncs: {
|
|
1009
|
+
postFormData: (url: string, jar: Loose, form: Record<string, Loose>, query?: Record<string, Loose>) => Promise<Loose>;
|
|
1010
|
+
};
|
|
1011
|
+
ctx: {
|
|
1012
|
+
jar: Loose;
|
|
1013
|
+
userID?: string;
|
|
1014
|
+
};
|
|
1015
|
+
logError?: (scope: string, error: Loose) => void;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
interface UsersDomainDeps {
|
|
1019
|
+
info: GetUserInfoQueryDeps;
|
|
1020
|
+
infoV2: GetUserInfoV2QueryDeps;
|
|
1021
|
+
idLookup: GetUserIdQueryDeps;
|
|
1022
|
+
friendsList?: GetFriendsListQueryDeps;
|
|
1023
|
+
}
|
|
1024
|
+
declare function createUsersDomain(deps: UsersDomainDeps): {
|
|
1025
|
+
[k: string]: any;
|
|
1026
|
+
};
|
|
1027
|
+
|
|
1028
|
+
interface GetCurrentUserIdCommandDeps {
|
|
1029
|
+
ctx: {
|
|
1030
|
+
userID?: string;
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
interface LogoutCommandDeps {
|
|
1035
|
+
defaultFuncs: {
|
|
1036
|
+
get: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
1037
|
+
post: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
1038
|
+
};
|
|
1039
|
+
ctx: Loose;
|
|
1040
|
+
logInfo?: (scope: string, message: string) => void;
|
|
1041
|
+
logError?: (scope: string, error: Loose) => void;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
interface RefreshFbDtsgCommandDeps {
|
|
1045
|
+
ctx: Loose;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
interface AddExternalModuleCommandDeps {
|
|
1049
|
+
defaultFuncs: Loose;
|
|
1050
|
+
api: Loose;
|
|
1051
|
+
ctx: Loose;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
interface EnableAutoSaveAppStateCommandDeps {
|
|
1055
|
+
api: {
|
|
1056
|
+
getAppState: () => Loose;
|
|
1057
|
+
};
|
|
1058
|
+
ctx: Loose;
|
|
1059
|
+
logger?: (text: string, type?: string) => void;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
interface ChangeBioCommandDeps {
|
|
1063
|
+
defaultFuncs: {
|
|
1064
|
+
post: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
1065
|
+
};
|
|
1066
|
+
ctx: Loose;
|
|
1067
|
+
logError?: (scope: string, error: Loose) => void;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
interface ChangeAvatarCommandDeps {
|
|
1071
|
+
defaultFuncs: {
|
|
1072
|
+
post: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
1073
|
+
postFormData: (url: string, jar: Loose, form: Record<string, Loose>, query?: Record<string, Loose>) => Promise<Loose>;
|
|
1074
|
+
};
|
|
1075
|
+
ctx: Loose;
|
|
1076
|
+
isReadableStream: (value: Loose) => value is NodeJS.ReadableStream;
|
|
1077
|
+
logError?: (scope: string, error: Loose) => void;
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
interface HandleFriendRequestCommandDeps {
|
|
1081
|
+
defaultFuncs: {
|
|
1082
|
+
post: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
1083
|
+
};
|
|
1084
|
+
ctx: Loose;
|
|
1085
|
+
logError?: (scope: string, error: Loose) => void;
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
interface UnfriendCommandDeps {
|
|
1089
|
+
defaultFuncs: {
|
|
1090
|
+
post: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
1091
|
+
};
|
|
1092
|
+
ctx: Loose;
|
|
1093
|
+
logError?: (scope: string, error: Loose) => void;
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
interface SetPostReactionCommandDeps {
|
|
1097
|
+
defaultFuncs: {
|
|
1098
|
+
post: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
1099
|
+
};
|
|
1100
|
+
ctx: Loose;
|
|
1101
|
+
logError?: (scope: string, error: Loose) => void;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
interface ChangeBlockedStatusCommandDeps {
|
|
1105
|
+
defaultFuncs: {
|
|
1106
|
+
post: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<Loose>;
|
|
1107
|
+
};
|
|
1108
|
+
ctx: Loose;
|
|
1109
|
+
logError?: (scope: string, error: Loose) => void;
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
interface AccountDomainDeps {
|
|
1113
|
+
addExternalModule: AddExternalModuleCommandDeps;
|
|
1114
|
+
currentUserId: GetCurrentUserIdCommandDeps;
|
|
1115
|
+
enableAutoSaveAppState: EnableAutoSaveAppStateCommandDeps;
|
|
1116
|
+
logout: LogoutCommandDeps;
|
|
1117
|
+
refreshFbDtsg: RefreshFbDtsgCommandDeps;
|
|
1118
|
+
changeAvatar: ChangeAvatarCommandDeps;
|
|
1119
|
+
changeBio: ChangeBioCommandDeps;
|
|
1120
|
+
handleFriendRequest: HandleFriendRequestCommandDeps;
|
|
1121
|
+
unfriend: UnfriendCommandDeps;
|
|
1122
|
+
setPostReaction: SetPostReactionCommandDeps;
|
|
1123
|
+
changeBlockedStatus?: ChangeBlockedStatusCommandDeps;
|
|
1124
|
+
}
|
|
1125
|
+
declare function createAccountDomain(deps: AccountDomainDeps): {
|
|
1126
|
+
[k: string]: any;
|
|
1127
|
+
};
|
|
1128
|
+
|
|
1129
|
+
interface HttpGetQueryDeps {
|
|
1130
|
+
defaultFuncs: {
|
|
1131
|
+
get: (url: string, jar: Loose, form?: Record<string, Loose>) => Promise<{
|
|
1132
|
+
data: Loose;
|
|
1133
|
+
}>;
|
|
1134
|
+
};
|
|
1135
|
+
ctx: {
|
|
1136
|
+
jar: Loose;
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
interface HttpPostCommandDeps {
|
|
1141
|
+
defaultFuncs: {
|
|
1142
|
+
post: (url: string, jar: Loose, form?: Record<string, Loose>, options?: Record<string, Loose>) => Promise<{
|
|
1143
|
+
data: Loose;
|
|
1144
|
+
}>;
|
|
1145
|
+
};
|
|
1146
|
+
ctx: {
|
|
1147
|
+
jar: Loose;
|
|
1148
|
+
globalOptions?: Record<string, Loose>;
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
interface PostFormDataCommandDeps {
|
|
1153
|
+
defaultFuncs: {
|
|
1154
|
+
postFormData: (url: string, jar: Loose, form: Record<string, Loose>, query?: Record<string, Loose>) => Promise<Loose>;
|
|
1155
|
+
};
|
|
1156
|
+
ctx: Loose;
|
|
1157
|
+
logError?: (scope: string, error: Loose) => void;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
interface HttpDomainDeps {
|
|
1161
|
+
get: HttpGetQueryDeps;
|
|
1162
|
+
post: HttpPostCommandDeps;
|
|
1163
|
+
postFormData: PostFormDataCommandDeps;
|
|
1164
|
+
}
|
|
1165
|
+
declare function createHttpDomain(deps: HttpDomainDeps): {
|
|
1166
|
+
get: (url: string, form?: Record<string, Loose> | NodeStyleCallback<Loose>, callback?: NodeStyleCallback<Loose>, notAPI?: boolean) => Promise<any>;
|
|
1167
|
+
post: (url: string, form?: Record<string, Loose> | NodeStyleCallback<Loose>, callback?: NodeStyleCallback<Loose>, notAPI?: boolean) => Promise<any>;
|
|
1168
|
+
postFormData: (url: string, form?: Record<string, Loose> | NodeStyleCallback<Loose>, callback?: NodeStyleCallback<Loose>) => Promise<any>;
|
|
1169
|
+
};
|
|
1170
|
+
|
|
1171
|
+
interface SchedulerOptions {
|
|
1172
|
+
replyMessageID?: string;
|
|
1173
|
+
isGroup?: boolean;
|
|
1174
|
+
callback?: (...args: Loose[]) => void;
|
|
1175
|
+
}
|
|
1176
|
+
interface ScheduledMessageInfo {
|
|
1177
|
+
id: string;
|
|
1178
|
+
message: Loose;
|
|
1179
|
+
threadID: Loose;
|
|
1180
|
+
timestamp: number;
|
|
1181
|
+
createdAt: number;
|
|
1182
|
+
options: SchedulerOptions;
|
|
1183
|
+
timeUntilSend: number;
|
|
1184
|
+
}
|
|
1185
|
+
interface SchedulerDomain {
|
|
1186
|
+
scheduleMessage: (message: Loose, threadID: Loose, when: Date | number | string, options?: SchedulerOptions) => string;
|
|
1187
|
+
cancelScheduledMessage: (id: string) => boolean;
|
|
1188
|
+
getScheduledMessage: (id: string) => ScheduledMessageInfo | null;
|
|
1189
|
+
listScheduledMessages: () => ScheduledMessageInfo[];
|
|
1190
|
+
cancelAllScheduledMessages: () => number;
|
|
1191
|
+
getScheduledCount: () => number;
|
|
1192
|
+
cleanup: () => void;
|
|
1193
|
+
destroy: () => number;
|
|
1194
|
+
_cleanupInterval: ReturnType<typeof setInterval>;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
interface SchedulerDomainDeps {
|
|
1198
|
+
sendMessage: (...args: Loose[]) => Promise<Loose> | Loose;
|
|
1199
|
+
logger?: (message: string, level?: string) => void;
|
|
1200
|
+
now?: () => number;
|
|
1201
|
+
setTimeoutFn?: typeof setTimeout;
|
|
1202
|
+
clearTimeoutFn?: typeof clearTimeout;
|
|
1203
|
+
setIntervalFn?: typeof setInterval;
|
|
1204
|
+
clearIntervalFn?: typeof clearInterval;
|
|
1205
|
+
}
|
|
1206
|
+
declare function createSchedulerDomain(deps: SchedulerDomainDeps): SchedulerDomain;
|
|
1207
|
+
|
|
1208
|
+
interface RequestCore {
|
|
1209
|
+
get: (...args: Loose[]) => Promise<Loose>;
|
|
1210
|
+
post: (...args: Loose[]) => Promise<Loose>;
|
|
1211
|
+
postFormData: (...args: Loose[]) => Promise<Loose>;
|
|
1212
|
+
jar: Loose;
|
|
1213
|
+
makeDefaults: (...args: Loose[]) => Loose;
|
|
1214
|
+
client?: Loose;
|
|
1215
|
+
setProxy?: (proxyUrl?: string) => void;
|
|
1216
|
+
}
|
|
1217
|
+
interface AuthCore {
|
|
1218
|
+
REGION_MAP: Map<string, {
|
|
1219
|
+
code: string;
|
|
1220
|
+
name: string;
|
|
1221
|
+
location: string;
|
|
1222
|
+
}>;
|
|
1223
|
+
parseRegion: (html: string) => string;
|
|
1224
|
+
loginViaAPI: (email: string, password: string, twoFactor?: string | null, apiBaseUrl?: string | null, apiKey?: string | null) => Promise<Loose>;
|
|
1225
|
+
tokensViaAPI: (email: string, password: string, twoFactor?: string | null, apiBaseUrl?: string | null) => Promise<Loose>;
|
|
1226
|
+
normalizeCookieHeaderString: (cookieHeader: string) => string[];
|
|
1227
|
+
setJarFromPairs: (jar: Loose, pairs: string[], domain: string) => void;
|
|
1228
|
+
}
|
|
1229
|
+
interface StateCore {
|
|
1230
|
+
createFcaState: (input: Record<string, Loose>) => FcaState;
|
|
1231
|
+
createApiFacade: (params: Record<string, Loose>) => Record<string, Loose>;
|
|
1232
|
+
attachThreadUpdater: (ctx: FcaState, models: Loose, logger: (text: string, type?: string) => void) => boolean;
|
|
1233
|
+
}
|
|
1234
|
+
interface MqttCore {
|
|
1235
|
+
attachMqttCompatibility: (api: Record<string, Loose>, options?: {
|
|
1236
|
+
logger?: (text: string, type?: string) => void;
|
|
1237
|
+
refreshIntervalMs?: number;
|
|
1238
|
+
}) => NodeJS.Timeout | null;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
export { type AccountInactiveEvent, type AttachmentPayload, type AuthCore, type ChangeGroupImageResult, type ChangeThreadColorResult, type ChangeThreadEmojiResult, type CreateThemeAIResult, type DeleteMessageResult, type EditMessageResult, type EmojiPayload, type EventBase, type FcaClientFacade, type FcaClientNamespace, type FcaClientNamespaces, type FcaGlobalOptions, type FcaID, type FcaState, type ForwardAttachmentResult, type ForwardPayload, type FriendRequestCancelEvent, type FriendRequestReceivedEvent, type LegacyApiLike, type ListenMqttError, type LocationPayload, type LoginCredentials, type MentionPayload, type MessageEvent, type MessageReaction, type MessageUnsendEvent, MessengerBot, type MessengerBotLike, type MessengerBotOptions, MessengerContext, type MessengerMiddleware, type MessengerNext, type MqttCore, type MqttEvent, type PreUploadedAttachment, type PresenceEvent, type ReactionEvent, type ReadEvent, type ReadyEvent, type ReplyPayload, type RequestCore, type ScheduledMessageInfo, type SchedulerDomain, type SchedulerOptions, type SendMessageAttachment, type SendMessageContentPayload, type SendMessageEmojiSize, type SendMessageLocation, type SendMessageMention, type SendMessageObjectPayload, type SendMessagePayload, type SendMessageResult, type SendTypingOptions, type SetMessageReactionResult, type ShareContactResult, type StateCore, type StickerPayload, type StopListenEvent, type StreamAttachment, type TextPayload, type ThemeAssetImage, type ThemeBackgroundAsset, type ThemePicturesResult, type ThreadColorMap, type ThreadEvent, type TypingEvent, type UnsendMessageResult, type UploadAttachmentDescriptor, type UploadAttachmentInput, type UploadAttachmentMetadata, type UploadAttachmentOptions, type UploadAttachmentResult, type UrlPayload, attachClientFacade, attachThreadInfoRealtimeSync, checkForPackageUpdate, createAccountDomain, createApiFacade, createAuthCore, createDefaultContext, createFcaClient, createFcaState, createHttpDomain, createMessagesDomain, createMessengerBot, createRealtimeDomain, createRequestHelper, createSchedulerDomain, createThreadsDomain, createUsersDomain, login as default, defaultConfig, listenMqtt, loadConfig, login, loginLegacy, loginViaAPI, normalizeCookieHeaderString, resolveConfig, runConfiguredUpdateCheck, setJarFromPairs, tokensViaAPI, writeConfigTemplate };
|