diggylab 0.1.40 → 0.1.41
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/cli.js +51 -7
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -2329,6 +2329,10 @@ function parseCliArgs(argv) {
|
|
|
2329
2329
|
const spec = FLAGS[flag];
|
|
2330
2330
|
if (!spec) return { error: `Unknown option "${flag}".`, options };
|
|
2331
2331
|
const raw = inline ?? argv[index + 1];
|
|
2332
|
+
if (flag === "--cookies" && (raw === void 0 || raw.startsWith("--"))) {
|
|
2333
|
+
options.cookies = "";
|
|
2334
|
+
continue;
|
|
2335
|
+
}
|
|
2332
2336
|
if (raw === void 0 || raw.startsWith("--")) return { error: `Option "${flag}" needs a value.`, options };
|
|
2333
2337
|
if (inline === void 0) index += 1;
|
|
2334
2338
|
if (spec.type === "number") {
|
|
@@ -2340,6 +2344,10 @@ function parseCliArgs(argv) {
|
|
|
2340
2344
|
}
|
|
2341
2345
|
continue;
|
|
2342
2346
|
}
|
|
2347
|
+
if (command === "login" && token === "cookies" && options.cookies === void 0) {
|
|
2348
|
+
options.cookies = "";
|
|
2349
|
+
continue;
|
|
2350
|
+
}
|
|
2343
2351
|
if (command === void 0) {
|
|
2344
2352
|
command = token;
|
|
2345
2353
|
continue;
|
|
@@ -2767,7 +2775,8 @@ var USAGE = `DiggyLab Desktop Agent CLI
|
|
|
2767
2775
|
Usage:
|
|
2768
2776
|
diggylab pair --code <code> [--name <device name>] [--api <https://api.diggylab.com>]
|
|
2769
2777
|
diggylab login [--display <number>] [--web-url <https://diggylab.com>]
|
|
2770
|
-
diggylab login
|
|
2778
|
+
diggylab login cookies (asks you to paste facebook.com cookies)
|
|
2779
|
+
diggylab login --cookies <file> (or --cookies 'name=value; ...')
|
|
2771
2780
|
diggylab run
|
|
2772
2781
|
diggylab status
|
|
2773
2782
|
diggylab install-browser
|
|
@@ -2897,7 +2906,7 @@ async function commandPair(runtime, options, io) {
|
|
|
2897
2906
|
}
|
|
2898
2907
|
}
|
|
2899
2908
|
async function commandLogin(runtime, options, io) {
|
|
2900
|
-
if (options.cookies) return importFacebookCookies(runtime, options.cookies, io);
|
|
2909
|
+
if (options.cookies !== void 0) return importFacebookCookies(runtime, options.cookies || "-", io);
|
|
2901
2910
|
const login = new FacebookLoginService({
|
|
2902
2911
|
browserType: runtime.browserType,
|
|
2903
2912
|
clearTimer: (timer) => clearTimeout(timer),
|
|
@@ -2984,10 +2993,16 @@ ${relay.url}`);
|
|
|
2984
2993
|
}
|
|
2985
2994
|
async function importFacebookCookies(runtime, source, io) {
|
|
2986
2995
|
let input;
|
|
2987
|
-
|
|
2988
|
-
input =
|
|
2989
|
-
}
|
|
2990
|
-
|
|
2996
|
+
if (source === "-") {
|
|
2997
|
+
input = await readPastedCookies(io);
|
|
2998
|
+
} else if (existsSync2(source)) {
|
|
2999
|
+
input = readFileSync2(source, "utf8");
|
|
3000
|
+
} else if (source.includes("=")) {
|
|
3001
|
+
input = source;
|
|
3002
|
+
} else {
|
|
3003
|
+
io.error(`Could not read "${source}".`);
|
|
3004
|
+
io.error("Paste the cookies in quotes: diggylab login --cookies 'datr=...; c_user=...; xs=...'");
|
|
3005
|
+
io.error("Or save them to a file (diggylab login --cookies cookies.txt), or use --cookies - and press Ctrl-D after pasting.");
|
|
2991
3006
|
return 1;
|
|
2992
3007
|
}
|
|
2993
3008
|
const cookies = parseCookieInput(input);
|
|
@@ -2997,9 +3012,11 @@ async function importFacebookCookies(runtime, source, io) {
|
|
|
2997
3012
|
return 1;
|
|
2998
3013
|
}
|
|
2999
3014
|
const state = toFacebookStorageState(cookies);
|
|
3015
|
+
io.log(`Read ${cookies.length} cookie${cookies.length === 1 ? "" : "s"}.`);
|
|
3000
3016
|
if (!state.cookies.some((cookie) => cookie.name === "c_user")) {
|
|
3001
3017
|
io.error("Those cookies have no `c_user` value, so they are not a Facebook login.");
|
|
3002
|
-
io.error("
|
|
3018
|
+
io.error("If you pasted them on the command line, wrap the whole string in quotes so the shell keeps it together.");
|
|
3019
|
+
io.error("Open facebook.com in your browser, make sure you are logged in, then copy the `cookie:` request header again.");
|
|
3003
3020
|
return 1;
|
|
3004
3021
|
}
|
|
3005
3022
|
try {
|
|
@@ -3047,6 +3064,33 @@ function readStdin() {
|
|
|
3047
3064
|
process.stdin.on("error", reject);
|
|
3048
3065
|
});
|
|
3049
3066
|
}
|
|
3067
|
+
function readPastedCookies(io) {
|
|
3068
|
+
if (!process.stdin.isTTY) return readStdin();
|
|
3069
|
+
io.log("Paste the facebook.com cookies here, then press Enter.");
|
|
3070
|
+
io.log("In your browser: F12 \u2192 Network \u2192 click any facebook.com request \u2192 copy the whole `cookie:` value.");
|
|
3071
|
+
return new Promise((resolve) => {
|
|
3072
|
+
let value = "";
|
|
3073
|
+
let idle;
|
|
3074
|
+
const finish = () => {
|
|
3075
|
+
if (idle) clearTimeout(idle);
|
|
3076
|
+
process.stdin.off("data", handleData);
|
|
3077
|
+
process.stdin.pause();
|
|
3078
|
+
resolve(value);
|
|
3079
|
+
};
|
|
3080
|
+
const handleData = (chunk) => {
|
|
3081
|
+
value += chunk;
|
|
3082
|
+
if (idle) clearTimeout(idle);
|
|
3083
|
+
if (value.includes("\n") && value.includes("c_user")) {
|
|
3084
|
+
finish();
|
|
3085
|
+
return;
|
|
3086
|
+
}
|
|
3087
|
+
idle = setTimeout(finish, 350);
|
|
3088
|
+
};
|
|
3089
|
+
process.stdin.setEncoding("utf8");
|
|
3090
|
+
process.stdin.on("data", handleData);
|
|
3091
|
+
process.stdin.resume();
|
|
3092
|
+
});
|
|
3093
|
+
}
|
|
3050
3094
|
function playwrightCliPath() {
|
|
3051
3095
|
try {
|
|
3052
3096
|
return fileURLToPath(new URL("cli.js", import.meta.resolve("playwright")));
|