@dongdev/fca-unofficial 2.0.26 → 2.0.28
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/CHANGELOG.md +6 -0
- package/index.d.ts +13 -6
- package/index.js +8 -1
- package/package.json +9 -1
- package/src/api/socket/core/connectMqtt.js +1 -1
- package/src/api/socket/core/getSeqID.js +2 -1
- package/src/api/socket/listenMqtt.js +5 -2
package/CHANGELOG.md
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Origin: NOCOM-BOT/mod_fbmsg_legacy
|
|
1
|
+
// Origin: NOCOM-BOT/mod_fbmsg_legacy
|
|
2
2
|
|
|
3
3
|
declare module '@dongdev/fca-unofficial' {
|
|
4
4
|
import type { Readable, Duplex, Transform } from "stream";
|
|
@@ -8,25 +8,30 @@ declare module '@dongdev/fca-unofficial' {
|
|
|
8
8
|
function login(credentials: Partial<{
|
|
9
9
|
email: string,
|
|
10
10
|
password: string,
|
|
11
|
-
appState: AppstateData
|
|
11
|
+
appState: AppstateData,
|
|
12
|
+
Cookie?: string | string[] | Record<string,string>
|
|
12
13
|
}>, options: Partial<IFCAU_Options>, callback: (err: Error | null, api: IFCAU_API) => void): void;
|
|
13
14
|
function login(credentials: Partial<{
|
|
14
15
|
email: string,
|
|
15
16
|
password: string,
|
|
16
|
-
appState: AppstateData
|
|
17
|
+
appState: AppstateData,
|
|
18
|
+
Cookie?: string | string[] | Record<string,string>
|
|
17
19
|
}>, options: Partial<IFCAU_Options>): Promise<IFCAU_API>;
|
|
18
20
|
function login(credentials: Partial<{
|
|
19
21
|
email: string,
|
|
20
22
|
password: string,
|
|
21
|
-
appState: AppstateData
|
|
23
|
+
appState: AppstateData,
|
|
24
|
+
Cookie?: string | string[] | Record<string,string>
|
|
22
25
|
}>, callback: (err: Error | null, api: IFCAU_API) => void): void;
|
|
23
26
|
function login(credentials: Partial<{
|
|
24
27
|
email: string,
|
|
25
28
|
password: string,
|
|
26
|
-
appState: AppstateData
|
|
29
|
+
appState: AppstateData,
|
|
30
|
+
Cookie?: string | string[] | Record<string,string>
|
|
27
31
|
}>): Promise<IFCAU_API>;
|
|
28
32
|
|
|
29
|
-
export default login;
|
|
33
|
+
export default login;
|
|
34
|
+
export { login };
|
|
30
35
|
|
|
31
36
|
export type Cookie = {
|
|
32
37
|
key: string,
|
|
@@ -613,3 +618,5 @@ declare module '@dongdev/fca-unofficial' {
|
|
|
613
618
|
name: string
|
|
614
619
|
};
|
|
615
620
|
}
|
|
621
|
+
|
|
622
|
+
|
package/index.js
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
const login = require("./module/login");
|
|
2
|
+
|
|
3
|
+
// CommonJS default export
|
|
4
|
+
module.exports = login;
|
|
5
|
+
// Support require('{ login }') named import pattern
|
|
6
|
+
module.exports.login = login;
|
|
7
|
+
// Support ESM default import interop
|
|
8
|
+
module.exports.default = login;
|
package/package.json
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dongdev/fca-unofficial",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.28",
|
|
4
4
|
"description": "Unofficial Facebook Chat API for Node.js - Interact with Facebook Messenger programmatically",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"require": "./index.js",
|
|
10
|
+
"default": "./index.js",
|
|
11
|
+
"types": "./index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
6
14
|
"scripts": {
|
|
7
15
|
"test": "mocha",
|
|
8
16
|
"lint": "eslint .",
|
|
@@ -4,7 +4,7 @@ const uuid = require("uuid");
|
|
|
4
4
|
"use strict";
|
|
5
5
|
module.exports = function createListenMqtt(deps) {
|
|
6
6
|
const { WebSocket, mqtt, HttpsProxyAgent, buildStream, buildProxy,
|
|
7
|
-
topics, parseDelta, getTaskResponseData, logger
|
|
7
|
+
topics, parseDelta, getTaskResponseData, logger, emitAuth
|
|
8
8
|
} = deps;
|
|
9
9
|
|
|
10
10
|
return function listenMqtt(defaultFuncs, api, ctx, globalCallback) {
|
|
@@ -25,7 +25,8 @@ module.exports = function createGetSeqID(deps) {
|
|
|
25
25
|
}
|
|
26
26
|
})
|
|
27
27
|
.catch(err => {
|
|
28
|
-
const
|
|
28
|
+
const detail = (err && err.detail && err.detail.message) ? ` | detail=${err.detail.message}` : "";
|
|
29
|
+
const msg = ((err && err.error) || (err && err.message) || String(err || "")) + detail;
|
|
29
30
|
if (/Not logged in/i.test(msg)) {
|
|
30
31
|
return emitAuth(ctx, api, globalCallback, "not_logged_in", msg);
|
|
31
32
|
}
|
|
@@ -14,9 +14,12 @@ const markDelivery = require("./core/markDelivery");
|
|
|
14
14
|
const getTaskResponseData = require("./core/getTaskResponseData");
|
|
15
15
|
const createEmitAuth = require("./core/emitAuth");
|
|
16
16
|
const parseDelta = createParseDelta({ markDelivery, parseAndCheckLogin });
|
|
17
|
-
|
|
18
|
-
const getSeqIDFactory = createGetSeqID({ parseAndCheckLogin, listenMqtt, logger });
|
|
17
|
+
// Create emitAuth first so it can be injected into both factories
|
|
19
18
|
const emitAuth = createEmitAuth({ logger });
|
|
19
|
+
// Pass emitAuth into connectMqtt so errors there can signal auth state
|
|
20
|
+
const listenMqtt = createListenMqtt({ WebSocket, mqtt, HttpsProxyAgent, buildStream, buildProxy, topics, parseDelta, getTaskResponseData, logger, emitAuth });
|
|
21
|
+
// Inject emitAuth into getSeqID so its catch handler can notify properly
|
|
22
|
+
const getSeqIDFactory = createGetSeqID({ parseAndCheckLogin, listenMqtt, logger, emitAuth });
|
|
20
23
|
|
|
21
24
|
const MQTT_DEFAULTS = { cycleMs: 60 * 60 * 1000, reconnectDelayMs: 2000, autoReconnect: true, reconnectAfterStop: false };
|
|
22
25
|
function mqttConf(ctx, overrides) {
|