@dongdev/fca-unofficial 3.0.29 → 3.0.31

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 (100) hide show
  1. package/CHANGELOG.md +232 -132
  2. package/DOCS.md +82 -3
  3. package/README.md +524 -632
  4. package/func/logAdapter.js +33 -0
  5. package/index.d.ts +6 -0
  6. package/module/config.js +11 -1
  7. package/module/loginHelper.js +63 -4
  8. package/package.json +89 -81
  9. package/src/api/action/changeAvatar.js +1 -1
  10. package/src/api/action/changeBio.js +1 -1
  11. package/src/api/action/handleFriendRequest.js +1 -1
  12. package/src/api/action/logout.js +1 -1
  13. package/src/api/action/refreshFb_dtsg.js +1 -1
  14. package/src/api/action/setPostReaction.js +1 -1
  15. package/src/api/action/unfriend.js +1 -1
  16. package/src/api/http/httpGet.js +2 -2
  17. package/src/api/http/postFormData.js +1 -1
  18. package/src/api/messaging/addUserToGroup.js +1 -1
  19. package/src/api/messaging/changeArchivedStatus.js +1 -1
  20. package/src/api/messaging/changeBlockedStatus.js +1 -1
  21. package/src/api/messaging/changeGroupImage.js +2 -2
  22. package/src/api/messaging/changeNickname.js +2 -2
  23. package/src/api/messaging/changeThreadColor.js +1 -1
  24. package/src/api/messaging/changeThreadEmoji.js +1 -1
  25. package/src/api/messaging/createNewGroup.js +1 -1
  26. package/src/api/messaging/createThemeAI.js +1 -1
  27. package/src/api/messaging/deleteMessage.js +1 -1
  28. package/src/api/messaging/deleteThread.js +1 -1
  29. package/src/api/messaging/editMessage.js +1 -1
  30. package/src/api/messaging/getFriendsList.js +1 -1
  31. package/src/api/messaging/getMessage.js +1 -1
  32. package/src/api/messaging/getThemePictures.js +1 -1
  33. package/src/api/messaging/handleMessageRequest.js +1 -1
  34. package/src/api/messaging/markAsDelivered.js +1 -1
  35. package/src/api/messaging/markAsRead.js +1 -1
  36. package/src/api/messaging/markAsReadAll.js +1 -1
  37. package/src/api/messaging/markAsSeen.js +1 -1
  38. package/src/api/messaging/muteThread.js +1 -1
  39. package/src/api/messaging/resolvePhotoUrl.js +1 -1
  40. package/src/api/messaging/searchForThread.js +2 -1
  41. package/src/api/messaging/sendMessage.js +1 -1
  42. package/src/api/messaging/sendTypingIndicator.js +1 -1
  43. package/src/api/messaging/setMessageReaction.js +3 -4
  44. package/src/api/messaging/setTitle.js +1 -1
  45. package/src/api/messaging/unsendMessage.js +2 -2
  46. package/src/api/messaging/uploadAttachment.js +1 -1
  47. package/src/api/socket/core/connectMqtt.js +16 -8
  48. package/src/api/socket/core/emitAuth.js +4 -0
  49. package/src/api/socket/core/getSeqID.js +6 -8
  50. package/src/api/socket/core/getTaskResponseData.js +3 -0
  51. package/src/api/socket/core/parseDelta.js +9 -0
  52. package/src/api/socket/detail/buildStream.js +11 -4
  53. package/src/api/socket/detail/constants.js +4 -0
  54. package/src/api/socket/listenMqtt.js +11 -5
  55. package/src/api/threads/getThreadHistory.js +1 -1
  56. package/src/api/threads/getThreadInfo.js +246 -388
  57. package/src/api/threads/getThreadList.js +1 -1
  58. package/src/api/threads/getThreadPictures.js +1 -1
  59. package/src/api/users/getUserID.js +1 -1
  60. package/src/api/users/getUserInfo.js +87 -12
  61. package/src/database/helpers.js +53 -0
  62. package/src/database/models/index.js +2 -1
  63. package/src/database/models/thread.js +5 -0
  64. package/src/database/threadData.js +49 -53
  65. package/src/database/userData.js +46 -37
  66. package/src/remote/remoteClient.js +123 -0
  67. package/src/utils/broadcast.js +51 -0
  68. package/src/utils/format/attachment.js +357 -0
  69. package/src/utils/format/cookie.js +9 -0
  70. package/src/utils/format/date.js +50 -0
  71. package/src/utils/format/decode.js +44 -0
  72. package/src/utils/format/delta.js +194 -0
  73. package/src/utils/format/ids.js +64 -0
  74. package/src/utils/format/index.js +64 -0
  75. package/src/utils/format/message.js +88 -0
  76. package/src/utils/format/presence.js +132 -0
  77. package/src/utils/format/readTyp.js +44 -0
  78. package/src/utils/format/thread.js +42 -0
  79. package/src/utils/format/utils.js +141 -0
  80. package/src/utils/loginParser/autoLogin.js +125 -0
  81. package/src/utils/loginParser/helpers.js +43 -0
  82. package/src/utils/loginParser/index.js +10 -0
  83. package/src/utils/loginParser/parseAndCheckLogin.js +220 -0
  84. package/src/utils/loginParser/textUtils.js +28 -0
  85. package/src/utils/request/client.js +26 -0
  86. package/src/utils/request/config.js +23 -0
  87. package/src/utils/request/defaults.js +46 -0
  88. package/src/utils/request/helpers.js +46 -0
  89. package/src/utils/request/index.js +17 -0
  90. package/src/utils/request/methods.js +163 -0
  91. package/src/utils/request/proxy.js +21 -0
  92. package/src/utils/request/retry.js +77 -0
  93. package/src/utils/request/sanitize.js +49 -0
  94. package/.gitattributes +0 -2
  95. package/Fca_Database/database.sqlite +0 -0
  96. package/LICENSE-MIT +0 -21
  97. package/src/utils/format.js +0 -1174
  98. package/src/utils/loginParser.js +0 -347
  99. package/src/utils/messageFormat.js +0 -1173
  100. package/src/utils/request.js +0 -305
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+ const { delay } = require("./client");
4
+
5
+ async function requestWithRetry(fn, retries = 3, baseDelay = 1000, ctx) {
6
+ let lastError;
7
+ const emit = (event, payload) => {
8
+ try {
9
+ if (ctx && ctx._emitter && typeof ctx._emitter.emit === "function") {
10
+ ctx._emitter.emit(event, payload);
11
+ }
12
+ } catch {}
13
+ };
14
+ for (let i = 0; i < retries; i++) {
15
+ try {
16
+ return await fn();
17
+ } catch (e) {
18
+ lastError = e;
19
+
20
+ if (
21
+ e?.code === "ERR_INVALID_CHAR" ||
22
+ (e?.message && e.message.includes("Invalid character in header"))
23
+ ) {
24
+ const err = new Error(
25
+ "Invalid header content detected. Request aborted to prevent crash."
26
+ );
27
+ err.error = "Invalid header content";
28
+ err.originalError = e;
29
+ err.code = "ERR_INVALID_CHAR";
30
+ return Promise.reject(err);
31
+ }
32
+
33
+ const status = e?.response?.status || e?.statusCode || 0;
34
+ const url = e?.config?.url || "";
35
+ const method = String(e?.config?.method || "").toUpperCase();
36
+ if (status === 429) {
37
+ emit("rateLimit", { status, url, method });
38
+ }
39
+ if (status >= 400 && status < 500 && status !== 429) {
40
+ return e.response || Promise.reject(e);
41
+ }
42
+ if (i === retries - 1) {
43
+ return e.response || Promise.reject(e);
44
+ }
45
+ const netCode = e?.code || "";
46
+ const msg = e && e.message ? e.message : String(e || "");
47
+ if (
48
+ !status &&
49
+ (netCode === "UND_ERR_CONNECT_TIMEOUT" ||
50
+ netCode === "ETIMEDOUT" ||
51
+ netCode === "ECONNRESET" ||
52
+ netCode === "ECONNREFUSED" ||
53
+ netCode === "ENOTFOUND" ||
54
+ /timeout|connect timeout|network error|fetch failed/i.test(msg))
55
+ ) {
56
+ emit("networkError", {
57
+ code: netCode,
58
+ message: msg,
59
+ url,
60
+ method,
61
+ });
62
+ }
63
+
64
+ const backoffDelay = Math.min(
65
+ baseDelay * Math.pow(2, i) + Math.floor(Math.random() * 200),
66
+ 30000
67
+ );
68
+ await delay(backoffDelay);
69
+ }
70
+ }
71
+ const finalError = lastError || new Error("Request failed after retries");
72
+ return Promise.reject(finalError);
73
+ }
74
+
75
+ module.exports = {
76
+ requestWithRetry,
77
+ };
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ function sanitizeHeaderValue(value) {
4
+ if (value === null || value === undefined) return "";
5
+ const str = String(value);
6
+ return str.replace(/[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F\r\n]/g, "").trim();
7
+ }
8
+
9
+ function sanitizeHeaderName(name) {
10
+ if (!name || typeof name !== "string") return "";
11
+ return name.replace(/[^\x21-\x7E]/g, "").trim();
12
+ }
13
+
14
+ function sanitizeHeaders(headers) {
15
+ if (!headers || typeof headers !== "object") return {};
16
+ const sanitized = {};
17
+ for (const [key, value] of Object.entries(headers)) {
18
+ const sanitizedKey = sanitizeHeaderName(key);
19
+ if (!sanitizedKey) continue;
20
+
21
+ if (Array.isArray(value)) continue;
22
+ if (value !== null && typeof value === "object") continue;
23
+ if (typeof value === "function") continue;
24
+
25
+ if (typeof value === "string") {
26
+ const trimmed = value.trim();
27
+ if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
28
+ try {
29
+ const parsed = JSON.parse(trimmed);
30
+ if (Array.isArray(parsed)) continue;
31
+ } catch {
32
+ // continue with normal sanitization
33
+ }
34
+ }
35
+ }
36
+
37
+ const sanitizedValue = sanitizeHeaderValue(value);
38
+ if (sanitizedValue !== "") {
39
+ sanitized[sanitizedKey] = sanitizedValue;
40
+ }
41
+ }
42
+ return sanitized;
43
+ }
44
+
45
+ module.exports = {
46
+ sanitizeHeaderValue,
47
+ sanitizeHeaderName,
48
+ sanitizeHeaders,
49
+ };
package/.gitattributes DELETED
@@ -1,2 +0,0 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
Binary file
package/LICENSE-MIT DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 DongDev (Donix-VN)
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.