@dongdev/fca-unofficial 3.0.10 → 3.0.11

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 CHANGED
@@ -158,3 +158,6 @@ Too lazy to write changelog, sorry! (will write changelog in the next release, t
158
158
 
159
159
  ## v3.0.9 - 2025-12-05
160
160
  - Hotfix / auto bump
161
+
162
+ ## v3.0.10 - 2025-12-05
163
+ - Hotfix / auto bump
@@ -281,11 +281,15 @@ function sort(obj) {
281
281
  async function setJarCookies(j, appstate) {
282
282
  const tasks = [];
283
283
  for (const c of appstate) {
284
+ const cookieName = c.name || c.key;
285
+ const cookieValue = c.value;
286
+ if (!cookieName || cookieValue === undefined) continue;
284
287
  const dom = (c.domain || ".facebook.com").replace(/^\./, "");
285
288
  const path = c.path || "/";
286
289
  const base1 = `https://${dom}${path}`;
287
290
  const base2 = `https://www.${dom}${path}`;
288
- const str = `${c.key}=${c.value}; Domain=${c.domain || ".facebook.com"}; Path=${path};`;
291
+ const domain = c.domain || ".facebook.com";
292
+ const str = `${cookieName}=${cookieValue}; Domain=${domain}; Path=${path};`;
289
293
  tasks.push(j.setCookie(str, base1));
290
294
  tasks.push(j.setCookie(str, base2));
291
295
  }
@@ -570,41 +574,41 @@ function loginHelper(appState, Cookie, email, password, globalOptions, callback)
570
574
  return null;
571
575
  };
572
576
  let userIDFromAppState = extractUIDFromAppState(appState);
573
- try {
574
- if (appState) {
575
- if (typeof appState === "string") {
576
- let parsed = appState;
577
- try {
578
- parsed = JSON.parse(appState);
579
- } catch { }
580
- if (Array.isArray(parsed)) {
581
- const pairs = parsed.map(c => [c.name || c.key, c.value].join("="));
582
- setJarFromPairs(jar, pairs, domain);
583
- } else if (typeof parsed === "string") {
584
- const pairs = normalizeCookieHeaderString(parsed);
585
- if (!pairs.length) throw new Error("Empty appState cookie header");
586
- setJarFromPairs(jar, pairs, domain);
577
+ (async () => {
578
+ try {
579
+ if (appState) {
580
+ if (typeof appState === "string") {
581
+ let parsed = appState;
582
+ try {
583
+ parsed = JSON.parse(appState);
584
+ } catch { }
585
+ if (Array.isArray(parsed)) {
586
+ // Use setJarCookies to properly handle individual cookie domains/paths
587
+ await setJarCookies(jar, parsed);
588
+ } else if (typeof parsed === "string") {
589
+ const pairs = normalizeCookieHeaderString(parsed);
590
+ if (!pairs.length) throw new Error("Empty appState cookie header");
591
+ setJarFromPairs(jar, pairs, domain);
592
+ } else {
593
+ throw new Error("Invalid appState format");
594
+ }
595
+ } else if (Array.isArray(appState)) {
596
+ // Use setJarCookies to properly handle individual cookie domains/paths
597
+ await setJarCookies(jar, appState);
587
598
  } else {
588
599
  throw new Error("Invalid appState format");
589
600
  }
590
- } else if (Array.isArray(appState)) {
591
- const pairs = appState.map(c => [c.name || c.key, c.value].join("="));
592
- setJarFromPairs(jar, pairs, domain);
593
- } else {
594
- throw new Error("Invalid appState format");
595
601
  }
602
+ if (Cookie) {
603
+ let cookiePairs = [];
604
+ if (typeof Cookie === "string") cookiePairs = normalizeCookieHeaderString(Cookie);
605
+ else if (Array.isArray(Cookie)) cookiePairs = Cookie.map(String).filter(Boolean);
606
+ else if (Cookie && typeof Cookie === "object") cookiePairs = Object.entries(Cookie).map(([k, v]) => `${k}=${v}`);
607
+ if (cookiePairs.length) setJarFromPairs(jar, cookiePairs, domain);
608
+ }
609
+ } catch (e) {
610
+ return callback(e);
596
611
  }
597
- if (Cookie) {
598
- let cookiePairs = [];
599
- if (typeof Cookie === "string") cookiePairs = normalizeCookieHeaderString(Cookie);
600
- else if (Array.isArray(Cookie)) cookiePairs = Cookie.map(String).filter(Boolean);
601
- else if (Cookie && typeof Cookie === "object") cookiePairs = Object.entries(Cookie).map(([k, v]) => `${k}=${v}`);
602
- if (cookiePairs.length) setJarFromPairs(jar, cookiePairs, domain);
603
- }
604
- } catch (e) {
605
- return callback(e);
606
- }
607
- (async () => {
608
612
  const ctx = { globalOptions, options: globalOptions, reconnectAttempts: 0 };
609
613
  ctx.bypassAutomation = async function (resp, j) {
610
614
  global.fca = global.fca || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dongdev/fca-unofficial",
3
- "version": "3.0.10",
3
+ "version": "3.0.11",
4
4
  "description": "Unofficial Facebook Chat API for Node.js - Interact with Facebook Messenger programmatically",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",