fca-nx 7.2.0 → 7.2.5

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/README.md CHANGED
@@ -138,29 +138,15 @@ api.stopAutoSave();
138
138
  api.sendMessage("Hello world!", threadID);
139
139
 
140
140
  ```
141
- ### Message Effects
142
- ```javascript
143
- api.sendMessage(
144
- {
145
- body: "I love you! ❤️",
146
- textEffect: "love"
147
- },
148
- threadID
149
- );
150
- ```
151
-
152
- Built-in effect names are `heart`, `hearts`, `love`, `gift`, `present`, `fire`,
153
- `flame`, `confetti`, `confecti`, `party`, `sparkles`, `sparkle`, `star`, and
154
- `magic`. You can also pass a custom numeric effect ID:
155
-
156
- ```javascript
157
- api.sendMessage({ body: "Party time!", effect: "confetti" }, threadID);
158
- api.sendMessage({ body: "Custom effect", textEffect: 27 }, threadID);
159
- ```
160
-
161
- The aliases `textEffect`, `text_effect`, `effect`, `effectName`, and their
162
- snake/camel-case ID variants are accepted. Effects are applied through both
163
- the MQTT sender and the legacy fallback sender.
141
+ ### Message effects removed (7.2.5)
142
+ Bubble effects (`gift`, `fire`, `love`, `textEffect`, `text_effect_ids`) are no longer sent.
143
+ Passing those keys is ignored. Sending them was a non-browser payload and a common checkpoint/suspend trigger.
144
+
145
+ ### Session safety (7.2.5)
146
+ - Default `online` is `false` (MQTT `chat_on` stays off unless you opt in).
147
+ - `mark_thread_read` is sent only when `autoMarkRead: true`.
148
+ - Outgoing sends are slower by default (about 2.8s + jitter, max 8/min).
149
+ - MQTT reconnect backs off harder (8s → 120s, then a 20 minute cooldown) instead of hammering the socket.
164
150
 
165
151
  ### Send Attachment
166
152
  ```javascript
package/module/login.js CHANGED
@@ -135,7 +135,9 @@ function login(loginData, options, callback) {
135
135
  forceLogin: false,
136
136
  autoMarkRead: false,
137
137
  autoReconnect: true,
138
- online: true,
138
+ // Appear offline by default. chat_on:true on the MQTT hello is a strong
139
+ // always-online bot signal and is a common cause of forced logout / suspend.
140
+ online: false,
139
141
  emitReady: false,
140
142
  // Single source of truth for the default identity - see src/utils/clientIdentity.js.
141
143
  // This used to be hard-coded independently here (Chrome/121), in
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fca-nx",
3
- "version": "7.2.0",
3
+ "version": "7.2.5",
4
4
  "description": "Facebook Messenger API for Node.js — Fast, Secure, and Feature-Rich",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -162,7 +162,7 @@ module.exports = function (defaultFuncs, api, ctx) {
162
162
  source: 2097153,
163
163
  send_type: 1,
164
164
  sync_group: 1,
165
- mark_thread_read: 1,
165
+ mark_thread_read: ctx.globalOptions && ctx.globalOptions.autoMarkRead ? 1 : 0,
166
166
  text: baseBody === "" ? null : baseBody,
167
167
  initiating_source: 0,
168
168
  skip_url_preview_gen: 1,
@@ -171,19 +171,6 @@ module.exports = function (defaultFuncs, api, ctx) {
171
171
  metadata_dataclass: JSON.stringify({ media_accessibility_metadata: { alt_text: null } })
172
172
  };
173
173
 
174
- // --- TEXT EFFECTS SUPPORT FOR MQTT ---
175
- if (m.text_effect_ids) {
176
- let effectArray = [];
177
- if (Array.isArray(m.text_effect_ids)) {
178
- effectArray = m.text_effect_ids;
179
- } else if (typeof m.text_effect_ids === "string" || typeof m.text_effect_ids === "number") {
180
- effectArray = [m.text_effect_ids];
181
- }
182
- if (effectArray.length > 0) {
183
- payload0.text_effect_ids = effectArray.map(id => String(id));
184
- }
185
- }
186
-
187
174
  const mentionData = buildMentionData(m, baseBody);
188
175
  if (mentionData) payload0.mention_data = mentionData;
189
176
 
@@ -3,14 +3,15 @@
3
3
  var utils = require("../../utils/utils");
4
4
  var logger = require("../../utils/logger");
5
5
  var bluebird = require("bluebird");
6
- var { getTextEffectId } = require("../../utils/textEffects");
7
-
8
6
  var allowedProperties = {
9
7
  attachment: true, url: true, sticker: true, emoji: true,
10
- emojiSize: true, body: true, mentions: true, location: true, text_effect_ids: true,
11
- textEffect: true, text_effect: true, text_effect_id: true, textEffectId: true,
12
- textEffectID: true, effect: true, effect_id: true, effectID: true,
13
- text_effect_name: true, effectName: true, effect_name: true,
8
+ emojiSize: true, body: true, mentions: true, location: true
9
+ };
10
+ // Effect keys are ignored (effect system removed in 7.2.5) so older callers do not throw.
11
+ var ignoredEffectKeys = {
12
+ text_effect_ids: true, textEffect: true, text_effect: true, text_effect_id: true,
13
+ textEffectId: true, textEffectID: true, effect: true, effect_id: true, effectID: true,
14
+ text_effect_name: true, effectName: true, effect_name: true
14
15
  };
15
16
 
16
17
  module.exports = function (defaultFuncs, api, ctx) {
@@ -131,6 +132,7 @@ module.exports = function (defaultFuncs, api, ctx) {
131
132
  }
132
133
 
133
134
  for (var key in msg) {
135
+ if (ignoredEffectKeys[key]) { delete msg[key]; continue; }
134
136
  if (!allowedProperties[key]) {
135
137
  return callback({ error: "OldMessage: Unknown property '" + key + "'" });
136
138
  }
@@ -138,8 +140,6 @@ module.exports = function (defaultFuncs, api, ctx) {
138
140
 
139
141
  var form = {};
140
142
  if (msg.body) form.body = msg.body;
141
- var textEffectId = getTextEffectId(msg);
142
- if (textEffectId) form.text_effect_id = textEffectId;
143
143
 
144
144
  if (msg.mentions && Array.isArray(msg.mentions)) {
145
145
  form.body = msg.body || "";
@@ -6,10 +6,10 @@
6
6
  const { formatID } = require("../../../utils/format");
7
7
  const { getSessionIdentity } = require("../../../utils/clientIdentity");
8
8
 
9
- const DEFAULT_RECONNECT_DELAY_MS = 2000;
10
- const MAX_RECONNECT_DELAY_MS = 60000;
11
- const MAX_RECONNECT_ATTEMPTS = 10; // cap consecutive network-failure reconnects; does not apply to confirmed auth failures (those never reconnect)
12
- const MAX_RECONNECT_COOLDOWN_MS = 10 * 60 * 1000; // after exhausting fast retries, wait this long before trying again (never give up permanently)
9
+ const DEFAULT_RECONNECT_DELAY_MS = 8000;
10
+ const MAX_RECONNECT_DELAY_MS = 120000;
11
+ const MAX_RECONNECT_ATTEMPTS = 5; // cap consecutive network-failure reconnects; does not apply to confirmed auth failures (those never reconnect)
12
+ const MAX_RECONNECT_COOLDOWN_MS = 20 * 60 * 1000; // after exhausting fast retries, wait this long before trying again (never give up permanently)
13
13
  const T_MS_WAIT_TIMEOUT_MS = 5000;
14
14
 
15
15
  // Exponential backoff with jitter, based on how many *consecutive* reconnect
@@ -136,10 +136,10 @@ module.exports = function createListenMqtt(deps) {
136
136
  protocolVersion: 13,
137
137
  binaryType: "arraybuffer"
138
138
  },
139
- keepalive: 30,
139
+ keepalive: 60,
140
140
  reschedulePings: true,
141
141
  reconnectPeriod: 0,
142
- connectTimeout: 5000
142
+ connectTimeout: 12000
143
143
  };
144
144
  if (ctx.globalOptions.proxy !== undefined) {
145
145
  const agent = new HttpsProxyAgent(ctx.globalOptions.proxy);
@@ -157,7 +157,7 @@ module.exports = function (defaultFuncs, api, ctx) {
157
157
  source: 2097153,
158
158
  send_type: 1,
159
159
  sync_group: 1,
160
- mark_thread_read: 1,
160
+ mark_thread_read: ctx.globalOptions && ctx.globalOptions.autoMarkRead ? 1 : 0,
161
161
  text: baseBody === "" ? null : baseBody,
162
162
  initiating_source: 0,
163
163
  skip_url_preview_gen: 1,
@@ -241,8 +241,12 @@ module.exports = function (defaultFuncs, api, ctx) {
241
241
  queue_name: String(threadID),
242
242
  task_id: 400,
243
243
  failure_count: null
244
- },
245
- {
244
+ }
245
+ ];
246
+ // Label 21 is a read-watermark. Sending it on every message looks like a bot
247
+ // and is a frequent forced-logout trigger. Only when the caller opted in.
248
+ if (ctx.globalOptions && ctx.globalOptions.autoMarkRead) {
249
+ tasks.push({
246
250
  label: "21",
247
251
  payload: JSON.stringify({
248
252
  thread_id: String(threadID),
@@ -252,8 +256,8 @@ module.exports = function (defaultFuncs, api, ctx) {
252
256
  queue_name: String(threadID),
253
257
  task_id: 401,
254
258
  failure_count: null
255
- }
256
- ];
259
+ });
260
+ }
257
261
 
258
262
  var content = {
259
263
  app_id: "2220391788200892",
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var utils = require("../../utils/utils");
4
- var { getTextEffectId, getTextEffectIds } = require("../../utils/textEffects");
5
-
6
4
  module.exports = function (defaultFuncs, api, ctx) {
7
5
  return function sendMessageMqtt(msg, threadID, callback, replyToMessage) {
8
6
  if (typeof msg === "string") msg = { body: msg };
@@ -26,7 +24,7 @@ module.exports = function (defaultFuncs, api, ctx) {
26
24
  source: 2097153,
27
25
  send_type: 1,
28
26
  sync_group: 1,
29
- mark_thread_read: 1,
27
+ mark_thread_read: ctx.globalOptions && ctx.globalOptions.autoMarkRead ? 1 : 0,
30
28
  text: baseBody === "" ? null : baseBody,
31
29
  initiating_source: 0,
32
30
  skip_url_preview_gen: 1,
@@ -34,11 +32,6 @@ module.exports = function (defaultFuncs, api, ctx) {
34
32
  multitab_env: 0
35
33
  };
36
34
 
37
- var textEffectId = getTextEffectId(msg);
38
- if (textEffectId) payload0.text_effect_id = textEffectId;
39
- var effectArray = getTextEffectIds(msg);
40
- if (effectArray.length) payload0.text_effect_ids = effectArray;
41
-
42
35
  if (msg.sticker) { payload0.send_type = 2; payload0.sticker_id = msg.sticker; }
43
36
  if (replyToMessage || msg.replyToMessage) {
44
37
  payload0.reply_metadata = {
@@ -7,16 +7,16 @@
7
7
  * released no sooner than `delay` ms after the previous one. This avoids sending bursts that
8
8
  * look like a script and that Facebook's rate limiting reacts to.
9
9
  *
10
- * FCA_NX_SEND_DELAY_MS base gap between sends, default 1500 (set 0 to disable)
11
- * FCA_NX_SEND_JITTER_MS extra random 0..N ms added to each gap, default 600
10
+ * FCA_NX_SEND_DELAY_MS base gap between sends, default 2800 (set 0 to disable)
11
+ * FCA_NX_SEND_JITTER_MS extra random 0..N ms added to each gap, default 1400
12
12
  * or at runtime: api.setSendDelay(ms, jitterMs)
13
13
  */
14
14
 
15
15
  const state = { last: 0, chain: Promise.resolve(), delay: null, jitter: null, stamps: [] };
16
- // Hard ceiling per rolling minute (FCA_NX_SEND_MAX_PER_MIN, default 12, 0 = off).
16
+ // Hard ceiling per rolling minute (FCA_NX_SEND_MAX_PER_MIN, default 8, 0 = off).
17
17
  function maxPerMin() {
18
18
  const n = Number(process.env.FCA_NX_SEND_MAX_PER_MIN);
19
- return Number.isFinite(n) && n >= 0 ? n : 12;
19
+ return Number.isFinite(n) && n >= 0 ? n : 8;
20
20
  }
21
21
 
22
22
  function readNum(v, d) {
@@ -25,10 +25,10 @@ function readNum(v, d) {
25
25
  }
26
26
 
27
27
  function getDelay() {
28
- return state.delay != null ? state.delay : readNum(process.env.FCA_NX_SEND_DELAY_MS, 1500);
28
+ return state.delay != null ? state.delay : readNum(process.env.FCA_NX_SEND_DELAY_MS, 2800);
29
29
  }
30
30
  function getJitter() {
31
- return state.jitter != null ? state.jitter : readNum(process.env.FCA_NX_SEND_JITTER_MS, 600);
31
+ return state.jitter != null ? state.jitter : readNum(process.env.FCA_NX_SEND_JITTER_MS, 1400);
32
32
  }
33
33
 
34
34
  function setSendDelay(ms, jitterMs) {