@dongdev/fca-unofficial 3.0.27 → 3.0.28

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.
@@ -1,68 +1,68 @@
1
- "use strict";
2
-
3
- // Cookie helpers extracted from client.js
4
-
5
- function saveCookies(jar) {
6
- return res => {
7
- try {
8
- const setCookie = res?.headers?.["set-cookie"];
9
- if (Array.isArray(setCookie) && setCookie.length) {
10
- const url =
11
- res?.request?.res?.responseUrl ||
12
- (res?.config?.baseURL
13
- ? new URL(res.config.url || "/", res.config.baseURL).toString()
14
- : res?.config?.url || "https://www.facebook.com");
15
- for (const c of setCookie) {
16
- try {
17
- jar.setCookieSync(c, url);
18
- } catch {
19
- // ignore per-cookie errors
20
- }
21
- }
22
- }
23
- } catch {
24
- // ignore unexpected cookie parsing errors
25
- }
26
- return res;
27
- };
28
- }
29
-
30
- function getAppState(jar) {
31
- if (!jar || typeof jar.getCookiesSync !== "function") return [];
32
- const urls = ["https://www.facebook.com"];
33
- const all = urls.flatMap(u => {
34
- try {
35
- return jar.getCookiesSync(u) || [];
36
- } catch {
37
- return [];
38
- }
39
- });
40
- const seen = new Set();
41
- const out = [];
42
- for (const c of all) {
43
- const key = c.key || c.name;
44
- if (!key) continue;
45
- const id = key + "|" + (c.domain || "") + "|" + (c.path || "/");
46
- if (seen.has(id)) continue;
47
- seen.add(id);
48
- out.push({
49
- key,
50
- value: c.value,
51
- domain: c.domain || ".facebook.com",
52
- path: c.path || "/",
53
- hostOnly: !!c.hostOnly,
54
- creation: c.creation || new Date(),
55
- lastAccessed: c.lastAccessed || new Date(),
56
- secure: !!c.secure,
57
- httpOnly: !!c.httpOnly,
58
- expires: c.expires && c.expires !== "Infinity" ? c.expires : "Infinity"
59
- });
60
- }
61
- return out;
62
- }
63
-
64
- module.exports = {
65
- saveCookies,
66
- getAppState
67
- };
68
-
1
+ "use strict";
2
+
3
+ // Cookie helpers extracted from client.js
4
+
5
+ function saveCookies(jar) {
6
+ return res => {
7
+ try {
8
+ const setCookie = res?.headers?.["set-cookie"];
9
+ if (Array.isArray(setCookie) && setCookie.length) {
10
+ const url =
11
+ res?.request?.res?.responseUrl ||
12
+ (res?.config?.baseURL
13
+ ? new URL(res.config.url || "/", res.config.baseURL).toString()
14
+ : res?.config?.url || "https://www.facebook.com");
15
+ for (const c of setCookie) {
16
+ try {
17
+ jar.setCookieSync(c, url);
18
+ } catch {
19
+ // ignore per-cookie errors
20
+ }
21
+ }
22
+ }
23
+ } catch {
24
+ // ignore unexpected cookie parsing errors
25
+ }
26
+ return res;
27
+ };
28
+ }
29
+
30
+ function getAppState(jar) {
31
+ if (!jar || typeof jar.getCookiesSync !== "function") return [];
32
+ const urls = ["https://www.facebook.com"];
33
+ const all = urls.flatMap(u => {
34
+ try {
35
+ return jar.getCookiesSync(u) || [];
36
+ } catch {
37
+ return [];
38
+ }
39
+ });
40
+ const seen = new Set();
41
+ const out = [];
42
+ for (const c of all) {
43
+ const key = c.key || c.name;
44
+ if (!key) continue;
45
+ const id = key + "|" + (c.domain || "") + "|" + (c.path || "/");
46
+ if (seen.has(id)) continue;
47
+ seen.add(id);
48
+ out.push({
49
+ key,
50
+ value: c.value,
51
+ domain: c.domain || ".facebook.com",
52
+ path: c.path || "/",
53
+ hostOnly: !!c.hostOnly,
54
+ creation: c.creation || new Date(),
55
+ lastAccessed: c.lastAccessed || new Date(),
56
+ secure: !!c.secure,
57
+ httpOnly: !!c.httpOnly,
58
+ expires: c.expires && c.expires !== "Infinity" ? c.expires : "Infinity"
59
+ });
60
+ }
61
+ return out;
62
+ }
63
+
64
+ module.exports = {
65
+ saveCookies,
66
+ getAppState
67
+ };
68
+