@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.
Files changed (104) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +224 -406
  3. package/dist/index.d.mts +1241 -0
  4. package/dist/index.d.ts +1241 -0
  5. package/dist/index.js +27749 -0
  6. package/dist/index.mjs +27713 -0
  7. package/docs/ARCHITECTURE.md +467 -0
  8. package/docs/DOCS.md +686 -0
  9. package/fca-config.example.json +33 -0
  10. package/package.json +33 -22
  11. package/test/fca.test.cjs +533 -0
  12. package/CHANGELOG.md +0 -293
  13. package/DOCS.md +0 -2712
  14. package/func/checkUpdate.js +0 -222
  15. package/func/logAdapter.js +0 -33
  16. package/func/logger.js +0 -48
  17. package/index.d.ts +0 -751
  18. package/index.js +0 -8
  19. package/module/config.js +0 -40
  20. package/module/login.js +0 -133
  21. package/module/loginHelper.js +0 -1296
  22. package/module/options.js +0 -44
  23. package/src/api/action/addExternalModule.js +0 -25
  24. package/src/api/action/changeAvatar.js +0 -137
  25. package/src/api/action/changeBio.js +0 -75
  26. package/src/api/action/enableAutoSaveAppState.js +0 -73
  27. package/src/api/action/getCurrentUserID.js +0 -7
  28. package/src/api/action/handleFriendRequest.js +0 -57
  29. package/src/api/action/logout.js +0 -76
  30. package/src/api/action/refreshFb_dtsg.js +0 -48
  31. package/src/api/action/setPostReaction.js +0 -106
  32. package/src/api/action/unfriend.js +0 -54
  33. package/src/api/http/httpGet.js +0 -46
  34. package/src/api/http/httpPost.js +0 -52
  35. package/src/api/http/postFormData.js +0 -47
  36. package/src/api/messaging/addUserToGroup.js +0 -68
  37. package/src/api/messaging/changeAdminStatus.js +0 -126
  38. package/src/api/messaging/changeArchivedStatus.js +0 -55
  39. package/src/api/messaging/changeBlockedStatus.js +0 -48
  40. package/src/api/messaging/changeGroupImage.js +0 -91
  41. package/src/api/messaging/changeNickname.js +0 -70
  42. package/src/api/messaging/changeThreadColor.js +0 -79
  43. package/src/api/messaging/changeThreadEmoji.js +0 -111
  44. package/src/api/messaging/createNewGroup.js +0 -88
  45. package/src/api/messaging/createPoll.js +0 -46
  46. package/src/api/messaging/createThemeAI.js +0 -98
  47. package/src/api/messaging/deleteMessage.js +0 -136
  48. package/src/api/messaging/deleteThread.js +0 -56
  49. package/src/api/messaging/editMessage.js +0 -68
  50. package/src/api/messaging/forwardAttachment.js +0 -57
  51. package/src/api/messaging/getEmojiUrl.js +0 -29
  52. package/src/api/messaging/getFriendsList.js +0 -82
  53. package/src/api/messaging/getMessage.js +0 -829
  54. package/src/api/messaging/getThemePictures.js +0 -62
  55. package/src/api/messaging/handleMessageRequest.js +0 -65
  56. package/src/api/messaging/markAsDelivered.js +0 -57
  57. package/src/api/messaging/markAsRead.js +0 -88
  58. package/src/api/messaging/markAsReadAll.js +0 -49
  59. package/src/api/messaging/markAsSeen.js +0 -61
  60. package/src/api/messaging/muteThread.js +0 -50
  61. package/src/api/messaging/removeUserFromGroup.js +0 -62
  62. package/src/api/messaging/resolvePhotoUrl.js +0 -43
  63. package/src/api/messaging/scheduler.js +0 -264
  64. package/src/api/messaging/searchForThread.js +0 -52
  65. package/src/api/messaging/sendMessage.js +0 -270
  66. package/src/api/messaging/sendTypingIndicator.js +0 -74
  67. package/src/api/messaging/setMessageReaction.js +0 -91
  68. package/src/api/messaging/setTitle.js +0 -124
  69. package/src/api/messaging/shareContact.js +0 -49
  70. package/src/api/messaging/threadColors.js +0 -128
  71. package/src/api/messaging/unsendMessage.js +0 -81
  72. package/src/api/messaging/uploadAttachment.js +0 -492
  73. package/src/api/socket/core/connectMqtt.js +0 -258
  74. package/src/api/socket/core/emitAuth.js +0 -103
  75. package/src/api/socket/core/getSeqID.js +0 -320
  76. package/src/api/socket/core/getTaskResponseData.js +0 -25
  77. package/src/api/socket/core/parseDelta.js +0 -377
  78. package/src/api/socket/detail/buildStream.js +0 -215
  79. package/src/api/socket/detail/constants.js +0 -28
  80. package/src/api/socket/listenMqtt.js +0 -377
  81. package/src/api/socket/middleware/index.js +0 -216
  82. package/src/api/threads/getThreadHistory.js +0 -664
  83. package/src/api/threads/getThreadInfo.js +0 -295
  84. package/src/api/threads/getThreadList.js +0 -293
  85. package/src/api/threads/getThreadPictures.js +0 -78
  86. package/src/api/users/getUserID.js +0 -65
  87. package/src/api/users/getUserInfo.js +0 -399
  88. package/src/api/users/getUserInfoV2.js +0 -134
  89. package/src/core/sendReqMqtt.js +0 -96
  90. package/src/database/models/index.js +0 -87
  91. package/src/database/models/thread.js +0 -50
  92. package/src/database/models/user.js +0 -46
  93. package/src/database/threadData.js +0 -98
  94. package/src/database/userData.js +0 -89
  95. package/src/remote/remoteClient.js +0 -123
  96. package/src/utils/broadcast.js +0 -51
  97. package/src/utils/client.js +0 -10
  98. package/src/utils/constants.js +0 -23
  99. package/src/utils/cookies.js +0 -68
  100. package/src/utils/format.js +0 -1174
  101. package/src/utils/headers.js +0 -115
  102. package/src/utils/loginParser.js +0 -365
  103. package/src/utils/messageFormat.js +0 -1173
  104. package/src/utils/request.js +0 -332
@@ -1,87 +0,0 @@
1
- const { Sequelize } = require("sequelize");
2
- const fs = require("fs");
3
- const path = require("path");
4
-
5
- let sequelize = null;
6
- let models = {};
7
-
8
- try {
9
- const databasePath = path.join(process.cwd(), "Fca_Database");
10
- if (!fs.existsSync(databasePath)) {
11
- fs.mkdirSync(databasePath, { recursive: true });
12
- }
13
-
14
- sequelize = new Sequelize({
15
- dialect: "sqlite",
16
- storage: path.join(databasePath, "database.sqlite"),
17
- logging: false,
18
- pool: {
19
- max: 5,
20
- min: 0,
21
- acquire: 30000,
22
- idle: 10000
23
- },
24
- retry: {
25
- max: 3
26
- },
27
- dialectOptions: {
28
- timeout: 5000
29
- },
30
- isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.READ_COMMITTED
31
- });
32
-
33
- // Load models with error handling
34
- try {
35
- const modelFiles = fs.readdirSync(__dirname)
36
- .filter(file => file.endsWith(".js") && file !== "index.js");
37
-
38
- for (const file of modelFiles) {
39
- try {
40
- const model = require(path.join(__dirname, file))(sequelize);
41
- if (model && model.name) {
42
- models[model.name] = model;
43
- }
44
- } catch (modelError) {
45
- // Log but continue loading other models
46
- console.error(`Failed to load model ${file}:`, modelError && modelError.message ? modelError.message : String(modelError));
47
- }
48
- }
49
-
50
- // Associate models
51
- Object.keys(models).forEach(modelName => {
52
- try {
53
- if (models[modelName].associate) {
54
- models[modelName].associate(models);
55
- }
56
- } catch (assocError) {
57
- console.error(`Failed to associate model ${modelName}:`, assocError && assocError.message ? assocError.message : String(assocError));
58
- }
59
- });
60
- } catch (loadError) {
61
- console.error("Failed to load models:", loadError && loadError.message ? loadError.message : String(loadError));
62
- }
63
-
64
- models.sequelize = sequelize;
65
- models.Sequelize = Sequelize;
66
- models.syncAll = async () => {
67
- try {
68
- if (!sequelize) {
69
- throw new Error("Sequelize instance not initialized");
70
- }
71
- await sequelize.sync({ force: false });
72
- } catch (error) {
73
- console.error("Failed to synchronize models:", error && error.message ? error.message : String(error));
74
- throw error;
75
- }
76
- };
77
- } catch (initError) {
78
- // If initialization fails completely, still export a valid structure
79
- console.error("Database initialization error:", initError && initError.message ? initError.message : String(initError));
80
- models.sequelize = null;
81
- models.Sequelize = Sequelize;
82
- models.syncAll = async () => {
83
- throw new Error("Database not initialized");
84
- };
85
- }
86
-
87
- module.exports = models;
@@ -1,50 +0,0 @@
1
- module.exports = function(sequelize) {
2
- const { Model, DataTypes } = require("sequelize");
3
-
4
- class Thread extends Model {}
5
-
6
- Thread.init(
7
- {
8
- num: {
9
- type: DataTypes.INTEGER,
10
- allowNull: false,
11
- autoIncrement: true,
12
- primaryKey: true
13
- },
14
- threadID: {
15
- type: DataTypes.STRING,
16
- allowNull: false,
17
- unique: true
18
- },
19
- messageCount: {
20
- type: DataTypes.INTEGER,
21
- allowNull: false,
22
- defaultValue: 0
23
- },
24
- data: {
25
- type: DataTypes.TEXT,
26
- allowNull: true,
27
- get() {
28
- const value = this.getDataValue('data');
29
- if (typeof value === 'string') {
30
- try {
31
- return JSON.parse(value);
32
- } catch {
33
- return value;
34
- }
35
- }
36
- return value;
37
- },
38
- set(value) {
39
- this.setDataValue('data', typeof value === 'string' ? value : JSON.stringify(value));
40
- }
41
- }
42
- },
43
- {
44
- sequelize,
45
- modelName: "Thread",
46
- timestamps: true
47
- }
48
- );
49
- return Thread;
50
- };
@@ -1,46 +0,0 @@
1
- module.exports = function (sequelize) {
2
- const { Model, DataTypes } = require("sequelize");
3
-
4
- class User extends Model { }
5
-
6
- User.init(
7
- {
8
- num: {
9
- type: DataTypes.INTEGER,
10
- allowNull: false,
11
- autoIncrement: true,
12
- primaryKey: true
13
- },
14
- userID: {
15
- type: DataTypes.STRING,
16
- allowNull: false,
17
- unique: true
18
- },
19
- data: {
20
- type: DataTypes.TEXT,
21
- allowNull: true,
22
- get() {
23
- const value = this.getDataValue('data');
24
- if (typeof value === 'string') {
25
- try {
26
- return JSON.parse(value);
27
- } catch {
28
- return value;
29
- }
30
- }
31
- return value;
32
- },
33
- set(value) {
34
- this.setDataValue('data', typeof value === 'string' ? value : JSON.stringify(value));
35
- }
36
- }
37
- },
38
- {
39
- sequelize,
40
- modelName: "User",
41
- timestamps: true
42
- }
43
- );
44
-
45
- return User;
46
- };
@@ -1,98 +0,0 @@
1
- const { Thread } = require("./models");
2
-
3
- const validateThreadID = threadID => {
4
- if (typeof threadID !== "string" && typeof threadID !== "number") {
5
- throw new Error("Invalid threadID: must be a string or number.");
6
- }
7
- return String(threadID);
8
- };
9
- const validateData = data => {
10
- if (!data || typeof data !== "object" || Array.isArray(data)) {
11
- throw new Error("Invalid data: must be a non-empty object.");
12
- }
13
- };
14
-
15
- module.exports = function(bot) {
16
- return {
17
- async create(threadID, data) {
18
- try {
19
- let thread = await Thread.findOne({ where: { threadID } });
20
- if (thread) {
21
- return { thread: thread.get(), created: false };
22
- }
23
- thread = await Thread.create({ threadID, ...data });
24
- return { thread: thread.get(), created: true };
25
- } catch (error) {
26
- throw new Error(`Failed to create thread: ${error.message}`);
27
- }
28
- },
29
-
30
- async get(threadID) {
31
- try {
32
- threadID = validateThreadID(threadID);
33
- const thread = await Thread.findOne({ where: { threadID } });
34
- return thread ? thread.get() : null;
35
- } catch (error) {
36
- throw new Error(`Failed to get thread: ${error.message}`);
37
- }
38
- },
39
-
40
- async update(threadID, data) {
41
- try {
42
- threadID = validateThreadID(threadID);
43
- validateData(data);
44
- const thread = await Thread.findOne({ where: { threadID } });
45
-
46
- if (thread) {
47
- await thread.update(data);
48
- return { thread: thread.get(), created: false };
49
- } else {
50
- const newThread = await Thread.create({ ...data, threadID });
51
- return { thread: newThread.get(), created: true };
52
- }
53
- } catch (error) {
54
- throw new Error(`Failed to update thread: ${error.message}`);
55
- }
56
- },
57
-
58
- async del(threadID) {
59
- try {
60
- if (!threadID) {
61
- throw new Error("threadID is required and cannot be undefined");
62
- }
63
- threadID = validateThreadID(threadID);
64
- if (!threadID) {
65
- throw new Error("Invalid threadID");
66
- }
67
- const result = await Thread.destroy({ where: { threadID } });
68
- if (result === 0) {
69
- throw new Error("No thread found with the specified threadID");
70
- }
71
- return result;
72
- } catch (error) {
73
- throw new Error(`Failed to delete thread: ${error.message}`);
74
- }
75
- },
76
- async delAll() {
77
- try {
78
- return await Thread.destroy({ where: {} });
79
- } catch (error) {
80
- throw new Error(`Failed to delete all threads: ${error.message}`);
81
- }
82
- },
83
- async getAll(keys = null) {
84
- try {
85
- const attributes =
86
- typeof keys === "string"
87
- ? [keys]
88
- : Array.isArray(keys)
89
- ? keys
90
- : undefined;
91
- const threads = await Thread.findAll({ attributes });
92
- return threads.map(thread => thread.get());
93
- } catch (error) {
94
- throw new Error(`Failed to get all threads: ${error.message}`);
95
- }
96
- }
97
- };
98
- };
@@ -1,89 +0,0 @@
1
- const { User } = require("./models");
2
-
3
- const validateUserID = userID => {
4
- if (typeof userID !== "string" && typeof userID !== "number") {
5
- throw new Error("Invalid userID: must be a string or number.");
6
- }
7
- return String(userID);
8
- };
9
- const validateData = data => {
10
- if (!data || typeof data !== "object" || Array.isArray(data)) {
11
- throw new Error("Invalid data: must be a non-empty object.");
12
- }
13
- };
14
-
15
- module.exports = function (bot) {
16
- return {
17
- async create(userID, data) {
18
- try {
19
- userID = validateUserID(userID);
20
- validateData(data);
21
- let user = await User.findOne({ where: { userID } });
22
- if (user) return { user: user.get(), created: false };
23
- const payload = Object.prototype.hasOwnProperty.call(data, "data") ? data : { data };
24
- user = await User.create({ userID, ...payload });
25
- return { user: user.get(), created: true };
26
- } catch (error) {
27
- throw new Error(`Failed to create user: ${error.message}`);
28
- }
29
- },
30
-
31
- async get(userID) {
32
- try {
33
- userID = validateUserID(userID);
34
- const user = await User.findOne({ where: { userID } });
35
- return user ? user.get() : null;
36
- } catch (error) {
37
- throw new Error(`Failed to get user: ${error.message}`);
38
- }
39
- },
40
-
41
- async update(userID, data) {
42
- try {
43
- userID = validateUserID(userID);
44
- validateData(data);
45
- const payload = Object.prototype.hasOwnProperty.call(data, "data") ? data : { data };
46
- const user = await User.findOne({ where: { userID } });
47
- if (user) {
48
- await user.update(payload);
49
- return { user: user.get(), created: false };
50
- } else {
51
- const newUser = await User.create({ userID, ...payload });
52
- return { user: newUser.get(), created: true };
53
- }
54
- } catch (error) {
55
- throw new Error(`Failed to update user: ${error.message}`);
56
- }
57
- },
58
-
59
- async del(userID) {
60
- try {
61
- if (!userID) throw new Error("userID is required and cannot be undefined");
62
- userID = validateUserID(userID);
63
- const result = await User.destroy({ where: { userID } });
64
- if (result === 0) throw new Error("No user found with the specified userID");
65
- return result;
66
- } catch (error) {
67
- throw new Error(`Failed to delete user: ${error.message}`);
68
- }
69
- },
70
-
71
- async delAll() {
72
- try {
73
- return await User.destroy({ where: {} });
74
- } catch (error) {
75
- throw new Error(`Failed to delete all users: ${error.message}`);
76
- }
77
- },
78
-
79
- async getAll(keys = null) {
80
- try {
81
- const attributes = typeof keys === "string" ? [keys] : Array.isArray(keys) ? keys : undefined;
82
- const users = await User.findAll({ attributes });
83
- return users.map(u => u.get());
84
- } catch (error) {
85
- throw new Error(`Failed to get all users: ${error.message}`);
86
- }
87
- }
88
- };
89
- };
@@ -1,123 +0,0 @@
1
- "use strict";
2
-
3
- const WebSocket = require("ws");
4
- const logger = require("../../func/logger");
5
-
6
- function createRemoteClient(api, ctx, cfg) {
7
- if (!cfg || !cfg.enabled || !cfg.url) return null;
8
-
9
- const url = String(cfg.url);
10
- const token = cfg.token ? String(cfg.token) : null;
11
- const autoReconnect = cfg.autoReconnect !== false;
12
- const emitter = ctx && ctx._emitter;
13
-
14
- let ws = null;
15
- let closed = false;
16
- let reconnectTimer = null;
17
-
18
- function log(message, level = "info") {
19
- logger(`[remote] ${message}`, level);
20
- }
21
-
22
- function scheduleReconnect() {
23
- if (!autoReconnect || closed) return;
24
- if (reconnectTimer) return;
25
- reconnectTimer = setTimeout(() => {
26
- reconnectTimer = null;
27
- if (!closed) connect();
28
- }, 5000);
29
- }
30
-
31
- function safeEmit(event, payload) {
32
- try {
33
- if (emitter && typeof emitter.emit === "function") {
34
- emitter.emit(event, payload);
35
- }
36
- } catch { }
37
- }
38
-
39
- function connect() {
40
- try {
41
- ws = new WebSocket(url, {
42
- headers: token ? { Authorization: `Bearer ${token}` } : undefined
43
- });
44
- } catch (e) {
45
- log(`connect error: ${e && e.message ? e.message : String(e)}`, "warn");
46
- scheduleReconnect();
47
- return;
48
- }
49
-
50
- ws.on("open", () => {
51
- log("connected", "info");
52
- const payload = {
53
- type: "hello",
54
- userID: ctx && ctx.userID,
55
- region: ctx && ctx.region,
56
- version: require("../../package.json").version
57
- };
58
- try {
59
- ws.send(JSON.stringify(payload));
60
- } catch { }
61
- safeEmit("remoteConnected", payload);
62
- });
63
-
64
- ws.on("message", data => {
65
- let msg;
66
- try {
67
- msg = JSON.parse(data.toString());
68
- } catch {
69
- return;
70
- }
71
- if (!msg || typeof msg !== "object") return;
72
-
73
- switch (msg.type) {
74
- case "ping":
75
- try {
76
- ws.send(JSON.stringify({ type: "pong" }));
77
- } catch { }
78
- break;
79
- case "stop":
80
- safeEmit("remoteStop", msg);
81
- break;
82
- case "broadcast":
83
- safeEmit("remoteBroadcast", msg.payload || {});
84
- break;
85
- default:
86
- safeEmit("remoteMessage", msg);
87
- break;
88
- }
89
- });
90
-
91
- ws.on("close", () => {
92
- log("disconnected", "warn");
93
- safeEmit("remoteDisconnected");
94
- if (!closed) scheduleReconnect();
95
- });
96
-
97
- ws.on("error", err => {
98
- log(`error: ${err && err.message ? err.message : String(err)}`, "warn");
99
- });
100
- }
101
-
102
- connect();
103
-
104
- return {
105
- close() {
106
- closed = true;
107
- if (reconnectTimer) {
108
- clearTimeout(reconnectTimer);
109
- reconnectTimer = null;
110
- }
111
- try {
112
- if (ws && ws.readyState === WebSocket.OPEN) {
113
- ws.close();
114
- }
115
- } catch { }
116
- }
117
- };
118
- }
119
-
120
- module.exports = {
121
- createRemoteClient
122
- };
123
-
@@ -1,51 +0,0 @@
1
- "use strict";
2
-
3
- const logger = require("../../func/logger");
4
-
5
- function delay(ms) {
6
- return new Promise(resolve => setTimeout(resolve, ms));
7
- }
8
-
9
- async function broadcast(api, threadIDs, message, options) {
10
- const opts = options || {};
11
- const delayMs = typeof opts.delayMs === "number" ? opts.delayMs : 1000;
12
- const skipBlocked = opts.skipBlocked !== false;
13
- const onResult = typeof opts.onResult === "function" ? opts.onResult : null;
14
-
15
- if (!api || typeof api.sendMessage !== "function") {
16
- throw new Error("broadcast: api.sendMessage is required.");
17
- }
18
-
19
- const ids = Array.isArray(threadIDs) ? threadIDs : [threadIDs];
20
- const results = [];
21
-
22
- for (const id of ids) {
23
- try {
24
- const res = await api.sendMessage(message, id);
25
- const item = { threadID: id, ok: true, res };
26
- results.push(item);
27
- if (onResult) onResult(null, item);
28
- } catch (e) {
29
- const msg = e && e.error ? e.error : e && e.message ? e.message : String(e);
30
- logger(`broadcast: failed for ${id}: ${msg}`, "warn");
31
- const item = { threadID: id, ok: false, error: e };
32
- results.push(item);
33
- if (onResult) onResult(e, item);
34
-
35
- if (
36
- skipBlocked &&
37
- /permission|blocked|not allowed|cannot send message|not authorized/i.test(msg)
38
- ) {
39
- // Skip only this target, continue with others
40
- }
41
- }
42
- if (delayMs > 0) {
43
- await delay(delayMs);
44
- }
45
- }
46
-
47
- return results;
48
- }
49
-
50
- module.exports = broadcast;
51
-
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- const { saveCookies, getAppState } = require("./cookies");
4
- const { parseAndCheckLogin } = require("./loginParser");
5
-
6
- module.exports = {
7
- saveCookies,
8
- getAppState,
9
- parseAndCheckLogin
10
- };
@@ -1,23 +0,0 @@
1
- "use strict";
2
- const { getType } = require("./format");
3
- const stream = require("stream");
4
- function getFrom(html, a, b) {
5
- const i = html.indexOf(a);
6
- if (i < 0) return;
7
- const start = i + a.length;
8
- const j = html.indexOf(b, start);
9
- return j < 0 ? undefined : html.slice(start, j);
10
- }
11
- function isReadableStream(obj) {
12
- return (
13
- obj instanceof stream.Stream &&
14
- (getType(obj._read) === "Function" ||
15
- getType(obj._read) === "AsyncFunction") &&
16
- getType(obj._readableState) === "Object"
17
- );
18
- }
19
-
20
- module.exports = {
21
- getFrom,
22
- isReadableStream
23
- };
@@ -1,68 +0,0 @@
1
- "use strict";
2
-
3
- // Cookie helpers extracted from client.js
4
-
5
- function saveCookies(jar) {
6
- return res => {
7
- try {
8
- const setCookie = res?.headers?.["set-cookie"];
9
- if (Array.isArray(setCookie) && setCookie.length) {
10
- const url =
11
- res?.request?.res?.responseUrl ||
12
- (res?.config?.baseURL
13
- ? new URL(res.config.url || "/", res.config.baseURL).toString()
14
- : res?.config?.url || "https://www.facebook.com");
15
- for (const c of setCookie) {
16
- try {
17
- jar.setCookieSync(c, url);
18
- } catch {
19
- // ignore per-cookie errors
20
- }
21
- }
22
- }
23
- } catch {
24
- // ignore unexpected cookie parsing errors
25
- }
26
- return res;
27
- };
28
- }
29
-
30
- function getAppState(jar) {
31
- if (!jar || typeof jar.getCookiesSync !== "function") return [];
32
- const urls = ["https://www.facebook.com"];
33
- const all = urls.flatMap(u => {
34
- try {
35
- return jar.getCookiesSync(u) || [];
36
- } catch {
37
- return [];
38
- }
39
- });
40
- const seen = new Set();
41
- const out = [];
42
- for (const c of all) {
43
- const key = c.key || c.name;
44
- if (!key) continue;
45
- const id = key + "|" + (c.domain || "") + "|" + (c.path || "/");
46
- if (seen.has(id)) continue;
47
- seen.add(id);
48
- out.push({
49
- key,
50
- value: c.value,
51
- domain: c.domain || ".facebook.com",
52
- path: c.path || "/",
53
- hostOnly: !!c.hostOnly,
54
- creation: c.creation || new Date(),
55
- lastAccessed: c.lastAccessed || new Date(),
56
- secure: !!c.secure,
57
- httpOnly: !!c.httpOnly,
58
- expires: c.expires && c.expires !== "Infinity" ? c.expires : "Infinity"
59
- });
60
- }
61
- return out;
62
- }
63
-
64
- module.exports = {
65
- saveCookies,
66
- getAppState
67
- };
68
-