{"_id":"@anbuinfosec/fca-unofficial","_rev":"4-8ea16152640b5bdb9649aaeff36072bd","name":"@anbuinfosec/fca-unofficial","dist-tags":{"latest":"2.0.0"},"versions":{"1.3.32":{"name":"@anbuinfosec/fca-unofficial","version":"1.3.32","keywords":["facebook","chat","api","fca"],"author":{"name":"Avery, David, Maude, Benjamin, UIRI, RFS-ADRENO"},"license":"MIT","_id":"@anbuinfosec/fca-unofficial@1.3.32","maintainers":[{"name":"anbuinfosec","email":"anbuinfosec@gmail.com"}],"homepage":"https://github.com/anbuinfosec/fca-unofficial#readme","bugs":{"url":"https://github.com/anbuinfosec/fca-unofficial/issues"},"dist":{"shasum":"8eee58c1dd90e259ef699165e3bbdcb232abbe90","tarball":"https://registry.npmjs.org/@anbuinfosec/fca-unofficial/-/fca-unofficial-1.3.32.tgz","fileCount":68,"integrity":"sha512-3fguIWjgKK5sp4I3zLQq7+IlLddLQEYqsMsfhdkrZfZ/XlwLkMRhwKH6zXTElSf8Uk2qyT+TCDX8k3HkEc/meA==","signatures":[{"sig":"MEUCIQClAiwKkEBGkaha4F3Q9jT2MNgV4Z8zXLjetY6uQeUhtgIgYQpzKpETIsmfSIBF+z6zbV8nnwrdwcoHWSc4c9K2+Jg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":617578},"types":"index.d.ts","engines":{"node":">=10.x"},"gitHead":"e120b6d3de084060eded952b2d82de56cca103e7","scripts":{"lint":"eslint **.js","test":"mocha","prettier":"prettier utils.js src/* --write"},"_npmUser":{"name":"anbuinfosec","email":"anbuinfosec@gmail.com"},"repository":{"url":"git://github.com/anbuinfosec/fca-unofficial.git","type":"git"},"_npmVersion":"10.2.5","description":"A Facebook chat API that doesn't rely on XMPP. Will NOT be deprecated after April 30th 2015.","directories":{},"_nodeVersion":"21.5.0","dependencies":{"mqtt":"^4.3.7","npmlog":"^1.2.0","cheerio":"^1.0.0-rc.12","request":"^2.53.0","bluebird":"^2.11.0","websocket-stream":"^5.5.0","https-proxy-agent":"^4.0.0"},"eslintConfig":{"env":{"es6":true,"node":true,"es2017":true},"rules":{"semi":["error","always"],"no-empty":["error",{"allowEmptyCatch":true}],"no-unused-vars":[1,{"argsIgnorePattern":"^_","varsIgnorePattern":"^_"}],"linebreak-style":["error","unix"]},"extends":"eslint:recommended","parserOptions":{"sourceType":"module"}},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^10.2.0","eslint":"^7.5.0","prettier":"^1.11.1"},"_npmOperationalInternal":{"tmp":"tmp/fca-unofficial_1.3.32_1704442154156_0.5923091437340218","host":"s3://npm-registry-packages"}},"1.3.33":{"name":"@anbuinfosec/fca-unofficial","version":"1.3.33","keywords":["facebook","chat","api","fca"],"author":{"name":"Avery, David, Maude, Benjamin, UIRI, RFS-ADRENO"},"license":"MIT","_id":"@anbuinfosec/fca-unofficial@1.3.33","maintainers":[{"name":"anbuinfosec","email":"anbuinfosec@gmail.com"}],"homepage":"https://github.com/anbuinfosec/fca-unofficial#readme","bugs":{"url":"https://github.com/anbuinfosec/fca-unofficial/issues"},"dist":{"shasum":"439c6a06e724d9b92d846bcfc5904e29792676e2","tarball":"https://registry.npmjs.org/@anbuinfosec/fca-unofficial/-/fca-unofficial-1.3.33.tgz","fileCount":70,"integrity":"sha512-0VRLobuJAGCXrmcSTWcWGvf+SgMyUrYPbFTY3BNW6MIIcfoHTMc0FmewlQ1HCcw5YfkTjjGqvdvp5J+m6Mpuqw==","signatures":[{"sig":"MEUCIDWCvvXb6OdMKPQdCBeoKtR32bgTQPMkYtRVRH3KG5iWAiEAw8xkYoyLNSVlUXMtfSHdOhuB1IyfY+jxVC+mBN8mvIA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":620820},"types":"index.d.ts","engines":{"node":">=10.x"},"gitHead":"82ac9392ac26899e7481f87f4fbe62b6e5ae5d16","scripts":{"lint":"eslint **.js","test":"mocha","prettier":"prettier utils.js src/* --write"},"_npmUser":{"name":"anbuinfosec","email":"anbuinfosec@gmail.com"},"repository":{"url":"git://github.com/anbuinfosec/fca-unofficial.git","type":"git"},"_npmVersion":"8.19.4","description":"A Facebook chat API that doesn't rely on XMPP. Will NOT be deprecated after April 30th 2015.","directories":{},"_nodeVersion":"16.20.2","dependencies":{"mqtt":"^4.3.7","npmlog":"^1.2.0","cheerio":"^1.0.0-rc.12","request":"^2.53.0","bluebird":"^2.11.0","websocket-stream":"^5.5.0","https-proxy-agent":"^4.0.0"},"eslintConfig":{"env":{"es6":true,"node":true,"es2017":true},"rules":{"semi":["error","always"],"no-empty":["error",{"allowEmptyCatch":true}],"no-unused-vars":[1,{"argsIgnorePattern":"^_","varsIgnorePattern":"^_"}],"linebreak-style":["error","unix"]},"extends":"eslint:recommended","parserOptions":{"sourceType":"module"}},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^10.2.0","eslint":"^7.5.0","prettier":"^1.11.1"},"_npmOperationalInternal":{"tmp":"tmp/fca-unofficial_1.3.33_1704906422765_0.6637082617722017","host":"s3://npm-registry-packages"}},"1.4.0":{"name":"@anbuinfosec/fca-unofficial","version":"1.4.0","keywords":["facebook","chat","api","fca"],"author":{"name":"Avery, David, Maude, Benjamin, UIRI, RFS-ADRENO"},"license":"MIT","_id":"@anbuinfosec/fca-unofficial@1.4.0","maintainers":[{"name":"anbuinfosec","email":"anbuinfosec@gmail.com"}],"homepage":"https://github.com/anbuinfosec/fca-unofficial#readme","bugs":{"url":"https://github.com/anbuinfosec/fca-unofficial/issues"},"dist":{"shasum":"93348080d59fd33458fa0c55ce91f644e846d252","tarball":"https://registry.npmjs.org/@anbuinfosec/fca-unofficial/-/fca-unofficial-1.4.0.tgz","fileCount":69,"integrity":"sha512-OH1A1PmtTI3T55kVlJgPjkBspEiQjprvOEMYE8rwSyEvGsi9NKF526fnsLoHBGwsmfC93Uh/lGTZM+jLY+brCw==","signatures":[{"sig":"MEUCIEQtyrZntVAQsj80pjURFOHankGmGiXnc8BC7Iik1V9fAiEApCy7dCJ4ROdj/u0GcHrnVcBCo+7LS+JmT3Ta6eimcF0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":618957},"types":"index.d.ts","engines":{"node":">=10.x"},"gitHead":"82ac9392ac26899e7481f87f4fbe62b6e5ae5d16","scripts":{"lint":"eslint **.js","test":"mocha","prettier":"prettier utils.js src/* --write"},"_npmUser":{"name":"anbuinfosec","email":"anbuinfosec@gmail.com"},"repository":{"url":"git://github.com/anbuinfosec/fca-unofficial.git","type":"git"},"_npmVersion":"8.19.4","description":"A Facebook chat API that doesn't rely on XMPP. Will NOT be deprecated after April 30th 2015.","directories":{},"_nodeVersion":"16.20.2","dependencies":{"mqtt":"^4.3.7","npmlog":"^1.2.0","cheerio":"^1.0.0-rc.12","request":"^2.53.0","bluebird":"^2.11.0","websocket-stream":"^5.5.0","https-proxy-agent":"^4.0.0"},"eslintConfig":{"env":{"es6":true,"node":true,"es2017":true},"rules":{"semi":["error","always"],"no-empty":["error",{"allowEmptyCatch":true}],"no-unused-vars":[1,{"argsIgnorePattern":"^_","varsIgnorePattern":"^_"}],"linebreak-style":["error","unix"]},"extends":"eslint:recommended","parserOptions":{"sourceType":"module"}},"_hasShrinkwrap":false,"devDependencies":{"mocha":"^10.2.0","eslint":"^7.5.0","prettier":"^1.11.1"},"_npmOperationalInternal":{"tmp":"tmp/fca-unofficial_1.4.0_1708886519310_0.45516493714146056","host":"s3://npm-registry-packages"}},"2.0.0":{"name":"@anbuinfosec/fca-unofficial","version":"2.0.0","description":"@anbuinfosec/fca-unofficial 2.0 – stable, low-risk Facebook Messenger automation API with integrated secure login (ID / Password / 2FA), adaptive MQTT core, safety orchestration, metrics, and TypeScript support.","main":"index.js","repository":{"type":"git","url":"git+https://github.com/anbuinfosec/fca-unofficial.git"},"author":{"name":"anbuinfosec"},"license":"MIT","dependencies":{"axios":"^1.8.4","bluebird":"^3.7.2","chalk":"^4.1.2","cheerio":"^1.0.0-rc.10","duplexify":"^4.1.3","got":"^11.8.6","gradient-string":"^2.0.2","https-proxy-agent":"^7.0.5","lodash":"^4.17.21","mqtt":"^4.3.8","node-cache":"^5.1.2","npmlog":"^7.0.1","request":"^2.88.2","semver":"^7.5.0","sequelize":"^6.37.6","sqlite":"^5.1.1","sqlite3":"^5.1.7","totp-generator":"^1.0.0","uuid":"^9.0.1","ws":"^8.18.1"},"devDependencies":{"@types/node":"^20.0.0","eslint":"^7.5.0","mocha":"^10.2.0","prettier":"^1.11.1","ts-node":"^10.9.0","typescript":"^5.0.0"},"scripts":{"test":"mocha","lint":"eslint **.js","prettier":"prettier utils.js src/* --write"},"keywords":["facebook","chat","api","@anbuinfosec/fca-unofficial","messenger","bot","automation","login","2fa","appstate","integrated","npm","typescript","performance","caching","mqtt","advanced","safe","secure","fca","fca-unofficial","fca2","fca-unofficial2","fca2.0","fca-unofficial2.0","fca2.0.0","fca-unofficial2.0.0","anbuinfosec"],"engines":{"node":">=14.x"},"eslintConfig":{"env":{"es6":true,"es2017":true,"node":true},"extends":"eslint:recommended","parserOptions":{"sourceType":"module"},"rules":{"linebreak-style":["error","unix"],"semi":["error","always"],"no-unused-vars":[1,{"argsIgnorePattern":"^_","varsIgnorePattern":"^_"}],"no-empty":["error",{"allowEmptyCatch":true}]}},"types":"index.d.ts","homepage":"https://github.com/anbuinfosec/fca-unofficial#readme","bugs":{"url":"https://github.com/anbuinfosec/fca-unofficial/issues"},"directories":{"test":"test","lib":"lib","examples":"examples"},"_id":"@anbuinfosec/fca-unofficial@2.0.0","gitHead":"06d9d59e6aba50a2bf8ba6823befb7d70b1f78fe","_nodeVersion":"20.19.4","_npmVersion":"11.6.0","dist":{"integrity":"sha512-+rLEldvdkfgx96Yv6PS0Wh3VIl9CtRuhrR9cNze9EhIAcRRTeXJgXrepD3F+IqhnoXkeYbuU1gnW0W2m9sktUA==","shasum":"508852005fb30f36d23e0fa7bfaa37ad67eca939","tarball":"https://registry.npmjs.org/@anbuinfosec/fca-unofficial/-/fca-unofficial-2.0.0.tgz","fileCount":118,"unpackedSize":746710,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDxArCXL1HroyKOp2NlGVjLEvqOlgoy1UGpOBoZU/pFuwIhAOwHCoXZFMEq5tKnjfr0lwReabnJjPNCxW+crKBovOzp"}]},"_npmUser":{"name":"anbuinfosec","email":"anbuinfosec@gmail.com"},"maintainers":[{"name":"anbuinfosec","email":"anbuinfosec@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/fca-unofficial_2.0.0_1758833493063_0.7361785095386959"},"_hasShrinkwrap":false}},"time":{"created":"2024-01-05T08:09:14.047Z","modified":"2025-09-25T20:51:33.487Z","1.3.32":"2024-01-05T08:09:14.418Z","1.3.33":"2024-01-10T17:07:03.016Z","1.4.0":"2024-02-25T18:41:59.533Z","2.0.0":"2025-09-25T20:51:33.293Z"},"bugs":{"url":"https://github.com/anbuinfosec/fca-unofficial/issues"},"author":{"name":"anbuinfosec"},"license":"MIT","homepage":"https://github.com/anbuinfosec/fca-unofficial#readme","keywords":["facebook","chat","api","@anbuinfosec/fca-unofficial","messenger","bot","automation","login","2fa","appstate","integrated","npm","typescript","performance","caching","mqtt","advanced","safe","secure","fca","fca-unofficial","fca2","fca-unofficial2","fca2.0","fca-unofficial2.0","fca2.0.0","fca-unofficial2.0.0","anbuinfosec"],"repository":{"type":"git","url":"git+https://github.com/anbuinfosec/fca-unofficial.git"},"description":"@anbuinfosec/fca-unofficial 2.0 – stable, low-risk Facebook Messenger automation API with integrated secure login (ID / Password / 2FA), adaptive MQTT core, safety orchestration, metrics, and TypeScript support.","maintainers":[{"name":"anbuinfosec","email":"anbuinfosec@gmail.com"}],"readme":"# Unofficial Facebook Chat API\n\n<a href=\"https://www.npmjs.com/package/@anbuinfosec/fca-unofficial\"><img alt=\"npm version\" src=\"https://img.shields.io/npm/v/@anbuinfosec/fca-unofficial.svg?style=flat-square\"></a>\n<a href=\"https://www.npmjs.com/package/@anbuinfosec/fca-unofficial\"><img src=\"https://img.shields.io/npm/dm/@anbuinfosec/fca-unofficial.svg?style=flat-square\" alt=\"npm downloads\"></a>\n\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n\n## 📦 Install & Usage (Fork)\n\nThis is a maintained fork of the original `@anbuinfosec/fca-unofficial` Messenger API, adapted for my **Chika Shirogane** bot and compatible with **GoatBot-V2** (with modified source).\n\n### Install directly from GitHub\n```bash\nnpm install @anbuinfosec/fca-unofficial\n```\n\nOr add to your `package.json`:\n```json\n\"dependencies\": {\n    \"@anbuinfosec/fca-unofficial\": \"^1.4.0\"\n}\n```\n\n### Usage\nImport and use as you would the main module:\n```js\nconst login = require('@anbuinfosec/fca-unofficial');\n(async () => {\n  const api = await login({ appState: require('./appstate.json') });\n  // ...\n})();\n```\n\n### About this fork\n- Based on the main [@anbuinfosec/fca-unofficial](https://github.com/anbuinfosec/fca-unofficial) source\n- Adapted for Chika Shirogane bot and GoatBot-V2 integration\n- Includes enhancements, async/await support, and compatibility fixes\n\n---\n---\n\n# @anbuinfosec/fca-unofficial v3.0.0 – Advanced Core Release\n\nModern, safe, production‑ready Messenger (Facebook Chat) API layer with integrated secure login (credentials + 2FA), adaptive session & connection resilience, delivery reliability safeguards, memory protection, and rich runtime metrics. Promise + callback compatible, TypeScript typed, minimal friction.\n\n---\n## ✅ Core Value\n| Pillar | What You Get |\n|--------|--------------|\n| Integrated Secure Login | Username / Password / TOTP 2FA → stable appstate generation & reuse |\n| Session Resilience | Anchored User‑Agent continuity, adaptive safe refresh, lightweight token poke, periodic recycle |\n| Connection Stability | Adaptive MQTT backoff, idle & ghost detection, layered post-refresh health probes, synthetic keepalives |\n| Delivery Reliability | Multi-path message send fallback (MQTT → HTTP → direct) + delivery receipt timeout suppression |\n| Memory Guard | Bounded queues, edit TTL sweeps, controlled resend limits |\n| Observability | Health + memory + delivery metrics (`api.getHealthMetrics()`, `api.getMemoryMetrics()`) |\n| Edit Safety | Pending edit buffer, ACK watchdog, p95 ACK latency tracking |\n| Type Definitions | First-class `index.d.ts` with modern Promise signatures |\n\n---\n## 🔄 What Changed in 3.0.0\nMajor version signals maturity & consolidation. No breaking public API changes versus late 2.1.x – upgrade is drop‑in. Temporary diagnostic harness removed; internal instrumentation formalized. Delivery receipt timeouts now intelligently retried & optionally auto-suppressed to protect outbound responsiveness.\n\n---\n## 🚀 Quick Start (Appstate Preferred)\n```js\nconst login = require('@anbuinfosec/fca-unofficial');\n\n(async () => {\n  const api = await login({ appState: require('./appstate.json') });\n  console.log('Logged in as', api.getCurrentUserID());\n  api.listen((err, evt) => {\n    if (err) return console.error('Listen error:', err);\n    if (evt.body) api.sendMessage('Echo: ' + evt.body, evt.threadID);\n  });\n})();\n```\n\n### Credentials + 2FA Flow\n```js\nconst login = require('@anbuinfosec/fca-unofficial');\n(async () => {\n  const api = await login({\n    email: process.env.FB_EMAIL,\n    password: process.env.FB_PASS,\n    twofactor: process.env.FB_2FA_SECRET // optional TOTP secret\n  });\n  api.listen((err, msg) => {\n    if (err) return console.error(err);\n    if (msg.body === 'ping') api.sendMessage('pong', msg.threadID);\n  });\n})();\n```\n\n---\n## 🧪 Key Runtime APIs\n```js\napi.setEditOptions({ maxPendingEdits, editTTLms, ackTimeoutMs, maxResendAttempts });\napi.setBackoffOptions({ base, factor, max, jitter });\napi.enableLazyPreflight(true);       // Skip heavy validation if recent success\napi.getHealthMetrics();              // uptime, reconnects, ack latency, delivery stats\napi.getMemoryMetrics();              // queue sizes & guard counters\n```\n\n### Monitoring Snippet\n```js\nsetInterval(() => {\n  const h = api.getHealthMetrics();\n  const m = api.getMemoryMetrics();\n  console.log('[HEALTH]', h?.status, 'acks', h?.ackCount, 'p95Ack', h?.p95AckLatencyMs);\n  console.log('[DELIVERY]', {\n    attempts: h?.deliveryAttempts,\n    success: h?.deliverySuccess,\n    failed: h?.deliveryFailed,\n    timeouts: h?.deliveryTimeouts,\n    disabledSince: h?.deliveryDisabledSince\n  });\n  console.log('[MEM]', m);\n}, 60000);\n```\n\n---\n## 🛡️ Safety & Stability Architecture\n| Layer | Mechanism | Purpose |\n|-------|-----------|---------|\n| UA Continuity | Single anchored fingerprint | Avoid heuristic expiry & drift |\n| Adaptive Refresh | Risk-aware timing bands | Token longevity without bursts |\n| Lightweight Poke | Subtle `fb_dtsg` renewal | Keeps session warm quietly |\n| Collision Guard | 45m spacing window | Prevent clustered maintenance events |\n| Idle / Ghost Probe | Timed silent detection | Force reconnect on stale sockets |\n| Periodic Recycle | Randomized (~6h ±30m) | Pre-empt silent degradation |\n| Backoff Strategy | Exponential + jitter | Graceful network recovery |\n| Delivery Suppression | Disable after repeated timeouts | Preserve send latency |\n\nDisable heavy preflight if embedding inside a framework already doing checks:\n```js\nawait login({ appState }, { disablePreflight: true });\n```\n\n---\n## 🛰️ MQTT Enhancements (Since 2.1.x)\n- Adaptive reconnect curve (caps 5m)\n- Layered post-refresh probes (1s / 10s / 30s)\n- Synthetic randomized keepalives (55–75s)\n- Structured error classification feeding metrics\n\n---\n## ✉️ Delivery Reliability\n- Multi-path send fallback (MQTT publish → HTTP send → direct fallback)\n- Per-attempt timeout & retry for message delivery receipts\n- Automatic classification of transient timeouts (ETIMEDOUT / ECONNRESET / EAI_AGAIN)\n- Adaptive suppression of delivery receipt calls when environment unstable (protects primary send throughput)\n\n---\n## 🧠 Long Session Best Practices\n1. Prefer appstate reuse (minimal credential logins).\n2. Preserve `persistent-device.json` (only delete if forced challenge).\n3. Don’t manually rotate User-Agent – built-in continuity handles it.\n4. Inspect metrics before forcing reconnect; let backoff work.\n5. Keep dependencies updated; review CHANGELOG for operational notes.\n\n---\n## 🐐 Using with GoatBot V2 (Summary)\n| Goal | Steps |\n|------|-------|\n| Generate appstate | Run credential login script → save `appstate.json` → configure GoatBot |\n| Full replacement | Install `@anbuinfosec/fca-unofficial` → shim `fb-chat-api/index.js` exporting module |\n| Direct require swap | Replace `require('fb-chat-api')` with `require('@anbuinfosec/fca-unofficial')` |\n\nMinimal example:\n```js\nconst login = require('@anbuinfosec/fca-unofficial');\n(async () => {\n  const api = await login({ appState: require('./appstate.json') });\n  api.listen((err, event) => {\n    if (err) return console.error(err);\n    if (event.body === '!ping') api.sendMessage('pong', event.threadID);\n  });\n})();\n```\n\n---\n## 📚 Documentation Map\n| Resource | Location |\n|----------|----------|\n| Full API Reference | `DOCS.md` |\n| Feature Guides | `docs/*.md` |\n| Configuration Reference | `docs/configuration-reference.md` |\n| Safety Details | `docs/account-safety.md` |\n| Examples | `examples/` |\n\n---\n## � Migrating 2.1.x → 3.0.0\n| Area | Action Needed |\n|------|---------------|\n| Public API | None (fully compatible) |\n| Diagnostics Harness | Removed (no action) |\n| Delivery Metrics | Optionally surface in dashboards |\n| Safety Manager (legacy) | Keep removed / unused |\n\n---\n## 🗂 Previous 2.1.x Highlights (Condensed)\n| Version | Focus | Key Additions |\n|---------|-------|---------------|\n| 2.1.10 | Stabilization | Final 2.1.x meta adjustments |\n| 2.1.8 | Safety Consolidation | Unified orchestrator, collision spacing, recycle suppression |\n| 2.1.7 | Session Longevity | UA continuity, lightweight poke |\n| 2.1.6 | Memory Guard | Queue pruning, edit TTL sweeps |\n| 2.1.5 | Edit Reliability | PendingEdits buffer, ACK watchdog |\n\nFull details remain in `CHANGELOG.md`.\n\n---\n## ⚠️ Disclaimer\nNot affiliated with Facebook. Use responsibly and comply with platform terms & local laws.\n\n---\n## 🤝 Contributing\nFocused PRs improving stability, safety heuristics, protocol coverage, or typings are welcome.\n\n---\n\n# 📋 API Methods Quick Reference & Code Examples\n\n## Login Methods\n| Method | Description | Example |\n|--------|-------------|---------|\n| `fcaLogin()` | Advanced login with ID/pass/2FA | `await fcaLogin({username, password, twofactor})` |\n| `login()` | Traditional login | `login({email, password}, callback)` |\n\n```js\n// Login with appstate\nconst login = require('@anbuinfosec/fca-unofficial');\n(async () => {\n  const api = await login({ appState: require('./appstate.json') });\n  api.listen((err, evt) => {\n    if (err) return console.error(err);\n    if (evt.body) api.sendMessage('Echo: ' + evt.body, evt.threadID);\n  });\n})();\n```\n\n## Message Methods\n| Method | Description | Example |\n|--------|-------------|---------|\n| `sendMessage()` | Send text/media message | `api.sendMessage('Hello!', threadID)` |\n| `sendMessageMqtt()` | Send message via MQTT (faster) | `api.sendMessageMqtt('Hello!', threadID)` |\n| `editMessage()` | Edit existing message | `api.editMessage('New text', messageID)` |\n| `unsendMessage()` | Delete/unsend message | `api.unsendMessage(messageID)` |\n| `markAsRead()` | Mark messages as read | `api.markAsRead(threadID)` |\n| `markAsDelivered()` | Mark as delivered | `api.markAsDelivered(threadID)` |\n| `markAsReadAll()` | Mark all threads as read | `api.markAsReadAll()` |\n| `markAsSeen()` | Mark as seen | `api.markAsSeen()` |\n| `setMessageReaction()` | React to message | `api.setMessageReaction('😍', messageID)` |\n| `setMessageReactionMqtt()` | React via MQTT | `api.setMessageReactionMqtt('👍', messageID)` |\n| `pinMessage()` | Pin message in chat | `api.pinMessage(messageID)` |\n\n```js\n// Send a message\napi.sendMessage('Hello World!', threadID);\n\n// Send with attachment\nconst fs = require('fs');\napi.sendMessage({\n  body: 'Check this image!',\n  attachment: fs.createReadStream('./image.jpg')\n}, threadID);\n```\n\n## Thread/Chat Methods\n| Method | Description | Example |\n|--------|-------------|---------|\n| `getThreadList()` | Get list of chats | `api.getThreadList(20, null, [], callback)` |\n| `getThreadInfo()` | Get chat information | `api.getThreadInfo(threadID, callback)` |\n| `getThreadHistory()` | Get message history | `api.getThreadHistory(threadID, 50, null, callback)` |\n| `getThreadPictures()` | Get shared pictures | `api.getThreadPictures(threadID, 0, 10, callback)` |\n| `searchForThread()` | Search for chats | `api.searchForThread('name', callback)` |\n| `setTitle()` | Change chat name | `api.setTitle('New Name', threadID)` |\n| `changeThreadColor()` | Change chat color | `api.changeThreadColor('#ff0000', threadID)` |\n| `changeThreadEmoji()` | Change chat emoji | `api.changeThreadEmoji('🎉', threadID)` |\n| `changeArchivedStatus()` | Archive/unarchive chat | `api.changeArchivedStatus(threadID, true)` |\n| `muteThread()` | Mute/unmute chat | `api.muteThread(threadID, 3600)` |\n| `deleteThread()` | Delete chat | `api.deleteThread(threadID)` |\n\n```js\n// Get thread list\napi.getThreadList(20, null, [], (err, list) => {\n  if (err) return console.error(err);\n  list.forEach(thread => {\n    console.log(`${thread.name}: ${thread.threadID}`);\n  });\n});\n```\n\n## Group Management\n| Method | Description | Example |\n|--------|-------------|---------|\n| `createNewGroup()` | Create new group | `api.createNewGroup([userID1, userID2], 'Name', callback)` |\n| `addUserToGroup()` | Add user to group | `api.addUserToGroup(userID, threadID)` |\n| `removeUserFromGroup()` | Remove user from group | `api.removeUserFromGroup(userID, threadID)` |\n| `changeAdminStatus()` | Make/remove admin | `api.changeAdminStatus(threadID, userID, true)` |\n| `changeGroupImage()` | Change group picture | `api.changeGroupImage(stream, threadID)` |\n\n## User Methods\n| Method | Description | Example |\n|--------|-------------|---------|\n| `getUserInfo()` | Get user information | `api.getUserInfo(userID, callback)` |\n| `getCurrentUserID()` | Get bot's user ID | `const myID = api.getCurrentUserID()` |\n| `getUserID()` | Get user ID by username | `api.getUserID('username', callback)` |\n| `getAvatarUser()` | Get user avatar URL | `api.getAvatarUser(userID, callback)` |\n| `changeUsername()` | Change username | `api.changeUsername('new_username')` |\n| `changeBio()` | Change bio | `api.changeBio('New bio')` |\n| `changeAvatar()` | Change profile picture | `api.changeAvatar(stream)` |\n| `changeAvatarV2()` | Change avatar (enhanced) | `api.changeAvatarV2(stream)` |\n| `changeCover()` | Change cover photo | `api.changeCover(stream)` |\n| `changeName()` | Change display name | `api.changeName('New Name')` |\n| `changeNickname()` | Change nickname in chat | `api.changeNickname('Nick', threadID, userID)` |\n| `setProfileGuard()` | Enable/disable profile guard | `api.setProfileGuard(true)` |\n\n## Friends & Social\n| Method | Description | Example |\n|--------|-------------|---------|\n| `getFriendsList()` | Get friends list | `api.getFriendsList(callback)` |\n| `handleFriendRequest()` | Accept/decline friend request | `api.handleFriendRequest(userID, true)` |\n| `follow()` | Send friend request/follow | `api.follow(userID)` |\n| `unfriend()` | Remove friend | `api.unfriend(userID)` |\n| `handleMessageRequest()` | Accept/decline message request | `api.handleMessageRequest(threadID, true)` |\n| `changeBlockedStatus()` | Block/unblock user | `api.changeBlockedStatus(userID, true)` |\n| `changeBlockedStatusMqtt()` | Block/unblock via MQTT | `api.changeBlockedStatusMqtt(userID, true)` |\n\n## Posts & Social Media\n| Method | Description | Example |\n|--------|-------------|---------|\n| `createPost()` | Create Facebook post | `api.createPost('Hello Facebook!', callback)` |\n| `createPoll()` | Create poll in group | `api.createPoll('Question?', ['A', 'B'], threadID)` |\n| `setPostReaction()` | React to post | `api.setPostReaction(postID, 'LOVE')` |\n| `setStoryReaction()` | React to story | `api.setStoryReaction(storyID, 'LOVE')` |\n| `sendComment()` | Comment on post | `api.sendComment('Great!', postID)` |\n| `createCommentPost()` | Create comment post | `api.createCommentPost('Comment', postID)` |\n\n## File & Media Methods\n| Method | Description | Example |\n|--------|-------------|---------|\n| `uploadAttachment()` | Upload file | `api.uploadAttachment(stream, callback)` |\n| `forwardAttachment()` | Forward attachment | `api.forwardAttachment(attachmentID, threadID)` |\n| `shareContact()` | Share contact | `api.shareContact('Message', userID, threadID)` |\n| `shareLink()` | Share link | `api.shareLink('https://example.com', threadID)` |\n| `resolvePhotoUrl()` | Get photo URL | `api.resolvePhotoUrl(photoID, callback)` |\n\n## Search Methods\n| Method | Description | Example |\n|--------|-------------|---------|\n| `searchStickers()` | Search stickers | `api.searchStickers('happy', callback)` |\n| `getEmojiUrl()` | Get emoji image URL | `api.getEmojiUrl('😍', 'large', callback)` |\n\n## HTTP Methods\n| Method | Description | Example |\n|--------|-------------|---------|\n| `httpGet()` | HTTP GET request | `api.httpGet(url, {}, {}, callback)` |\n| `httpPost()` | HTTP POST request | `api.httpPost(url, data, {}, callback)` |\n| `httpPostFormData()` | POST form data | `api.httpPostFormData(url, formData, {}, callback)` |\n\n## Advanced Features\n| Method | Description | Example |\n|--------|-------------|---------|\n| `listenMqtt()` | Listen via MQTT | `api.listenMqtt(callback)` |\n| `stopListenMqtt()` | Stop MQTT listening | `api.stopListenMqtt()` |\n| `listenNotification()` | Listen to notifications | `api.listenNotification(callback)` |\n| `sendTypingIndicator()` | Show typing indicator | `api.sendTypingIndicator(threadID)` |\n| `listen()` | Listen to all events | `api.listen(callback)` |\n\n## Configuration\n| Method | Description | Example |\n|--------|-------------|---------|\n| `setOptions()` | Set API options | `api.setOptions({listenEvents: true})` |\n| `getOptions()` | Get current options | `const opts = api.getOptions()` |\n| `getCtx()` | Get bot context | `const ctx = api.getCtx()` |\n| `getAccess()` | Get access info | `const access = api.getAccess()` |\n| `getBotInitialData()` | Get initial data | `const data = api.getBotInitialData()` |\n| `getRegion()` | Get current region | `api.getRegion(callback)` |\n| `refreshFb_dtsg()` | Refresh security token | `api.refreshFb_dtsg(callback)` |\n\n## Security & Session\n| Method | Description | Example |\n|--------|-------------|---------|\n| `logout()` | Logout properly | `api.logout(callback)` |\n| `getAppState()` | Get session appstate | `const appstate = api.getAppState()` |\n\n## UI Customization\n| Method | Description | Example |\n|--------|-------------|---------|\n| `threadColors()` | Get available colors | `api.threadColors(callback)` |\n\n---\n\nFor more code examples and advanced usage, see `COMPLETE-API-DOCS.md` and `DOCS.md`.\n","readmeFilename":"README.md"}