diggylab 0.1.39 → 0.1.40

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.
Files changed (3) hide show
  1. package/README.md +16 -5
  2. package/cli.js +27 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -113,17 +113,28 @@ If the browser says the link expired, run `diggylab login` again — each run mi
113
113
  If you would rather not share a screen, log into Facebook in your own browser and import those
114
114
  cookies instead — no Xvfb, no link, no port:
115
115
 
116
- 1. Install **Cookie-Editor** (Chrome, Edge, Firefox), open `facebook.com`, then *Export → JSON*.
117
- (Or copy the `cookie:` request header from your browser's DevTools.)
116
+ 1. Get the `facebook.com` cookies, in whichever way is easiest:
117
+ - **DevTools → Network** (fastest): open facebook.com, click any request, copy the whole
118
+ `cookie:` value from *Request Headers*.
119
+ - **DevTools → Application → Cookies → `https://www.facebook.com`**: select the table and copy the
120
+ rows.
121
+ - **Cookie-Editor** (Chrome, Edge, Firefox): *Export → JSON*.
118
122
  2. On the server:
119
123
 
120
124
  ```bash
121
125
  diggylab login --cookies cookies.json # or: diggylab login --cookies - and paste, then Ctrl-D
122
126
  ```
123
127
 
124
- The agent keeps only the `facebook.com` cookies, saves them encrypted, and opens Facebook once to
125
- confirm the session before it accepts it. Cookies exported from a different account, or expired ones,
126
- are rejected with a message instead of failing during a scan.
128
+ Only `name` and `value` are required; the agent fills in the rest (`.facebook.com`, `/`, session
129
+ expiry). Every `facebook.com` cookie is kept, and at least `c_user` plus `xs` must be present — those
130
+ two carry the session, and `datr` is worth keeping too.
131
+
132
+ Do not use `document.cookie` from the Console: Facebook's `c_user` and `xs` are HttpOnly, so they
133
+ never appear there. The DevTools cookie table and the extension do show them.
134
+
135
+ The agent saves the cookies encrypted and opens Facebook once to confirm the session before it
136
+ accepts it. Cookies exported from a different account, or expired ones, are rejected with a message
137
+ instead of failing during a scan.
127
138
 
128
139
  Note: Facebook sometimes asks for a security check when a session moves to a server's IP. If that
129
140
  happens the command says so — approve the login from your phone and import again.
package/cli.js CHANGED
@@ -2386,16 +2386,30 @@ function toCookie(value) {
2386
2386
  }
2387
2387
  function parseCookieHeader(input) {
2388
2388
  const header = input.replace(/^\s*cookie\s*:/i, "");
2389
- return header.split(";").map((part) => part.trim()).filter(Boolean).map((part) => {
2389
+ return header.split(/[;\n]/).map((part) => part.trim()).filter(Boolean).map((part) => {
2390
2390
  const separator = part.indexOf("=");
2391
2391
  if (separator <= 0) return null;
2392
2392
  return { name: part.slice(0, separator).trim(), value: part.slice(separator + 1) };
2393
2393
  }).filter((cookie) => cookie !== null);
2394
2394
  }
2395
+ function parseCookieTable(input) {
2396
+ const cookies = [];
2397
+ for (const line of input.split("\n")) {
2398
+ const columns = line.split(" ");
2399
+ if (columns.length < 2) return [];
2400
+ const name = columns[0].trim();
2401
+ const value = columns[1];
2402
+ if (!name || name === "Name" || !value) continue;
2403
+ cookies.push({ name, value });
2404
+ }
2405
+ return cookies;
2406
+ }
2395
2407
  function parseCookieInput(input) {
2396
2408
  const trimmed = input.trim();
2397
2409
  if (!trimmed) return [];
2398
- if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) return parseCookieHeader(trimmed);
2410
+ if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) {
2411
+ return trimmed.includes(" ") ? parseCookieTable(trimmed) : parseCookieHeader(trimmed);
2412
+ }
2399
2413
  try {
2400
2414
  const parsed = JSON.parse(trimmed);
2401
2415
  if (Array.isArray(parsed)) {
@@ -2908,11 +2922,12 @@ async function commandLogin(runtime, options, io) {
2908
2922
  if (!needsVirtualDisplay) {
2909
2923
  io.log(process.env.DISPLAY ? `Opening the Facebook login page on display ${process.env.DISPLAY}.` : "Opening the Facebook login page in a browser window.");
2910
2924
  } else {
2911
- const access = runtime.manager.getAccessCredential();
2912
- if (!access) {
2925
+ const stored = await runtime.manager.load();
2926
+ if (!stored) {
2913
2927
  io.error("This server is not paired yet. Run `diggylab pair --code <code>` first.");
2914
2928
  return 1;
2915
2929
  }
2930
+ const access = await runtime.manager.refresh();
2916
2931
  const webUrl = options.webUrl ?? process.env.DIGGYLAB_WEB_URL?.trim();
2917
2932
  display = await startVirtualDisplay({
2918
2933
  displayNumber: options.display,
@@ -2943,6 +2958,14 @@ ${relay.url}`);
2943
2958
  io.error(MISSING_DISPLAY_HINT);
2944
2959
  return 1;
2945
2960
  }
2961
+ if (/CREDENTIAL_REVOKED|not paired/i.test(message)) {
2962
+ io.error("This server is not paired (or was unpaired). Run `diggylab pair --code <code>` again.");
2963
+ return 1;
2964
+ }
2965
+ if (/NETWORK_ERROR|SERVER_UNAVAILABLE|fetch failed/i.test(message)) {
2966
+ io.error(`Could not reach the API: ${message}`);
2967
+ return 1;
2968
+ }
2946
2969
  if (/virtual screen|login screen|DiggyLab relay|Xvfb exited|x11vnc exited/i.test(message)) {
2947
2970
  io.error(`The login screen failed: ${message}`);
2948
2971
  printDisplayLogs(join4(runtime.directory, "logs"), io);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diggylab",
3
- "version": "0.1.39",
3
+ "version": "0.1.40",
4
4
  "description": "DiggyLab Desktop Agent collects posts and information from Facebook Groups on a paired computer. (headless CLI)",
5
5
  "type": "module",
6
6
  "bin": {