@dongdev/fca-unofficial 3.0.5 → 3.0.6

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
@@ -143,3 +143,6 @@ Too lazy to write changelog, sorry! (will write changelog in the next release, t
143
143
 
144
144
  ## v3.0.4 - 2025-11-27
145
145
  - Hotfix / auto bump
146
+
147
+ ## v3.0.5 - 2025-11-27
148
+ - Hotfix / auto bump
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dongdev/fca-unofficial",
3
- "version": "3.0.5",
3
+ "version": "3.0.6",
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",
@@ -34,7 +34,28 @@ function getHeaders(url, options, ctx, customHeader) {
34
34
  "Cache-Control": "no-cache"
35
35
  };
36
36
  if (ctx?.region) headers["X-MSGR-Region"] = ctx.region;
37
- if (customHeader && typeof customHeader === "object") Object.assign(headers, customHeader);
37
+ if (customHeader && typeof customHeader === "object") {
38
+ // Filter customHeader to only include valid HTTP header values (strings, numbers, booleans)
39
+ // Exclude functions, objects, arrays, and other non-serializable values
40
+ for (const [key, value] of Object.entries(customHeader)) {
41
+ // Skip null, undefined, functions, objects, and arrays
42
+ if (value === null || value === undefined || typeof value === "function") {
43
+ continue;
44
+ }
45
+ if (typeof value === "object") {
46
+ // Arrays are objects in JavaScript, so check for arrays explicitly
47
+ if (Array.isArray(value)) {
48
+ continue;
49
+ }
50
+ // Skip plain objects (but allow null which is already handled above)
51
+ continue;
52
+ }
53
+ // Only allow strings, numbers, and booleans - convert to string
54
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
55
+ headers[key] = String(value);
56
+ }
57
+ }
58
+ }
38
59
  return headers;
39
60
  }
40
61