sweetlink 0.2.0 → 0.2.1
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 +6 -2
- package/LICENSE +1 -1
- package/README.md +6 -6
- package/dist/daemon/src/codename.d.ts.map +1 -1
- package/dist/daemon/src/codename.js +11 -11
- package/dist/daemon/src/codename.js.map +1 -1
- package/dist/daemon/src/index.d.ts +1 -1
- package/dist/daemon/src/index.js +131 -122
- package/dist/daemon/src/index.js.map +1 -1
- package/dist/shared/src/env.d.ts.map +1 -1
- package/dist/shared/src/env.js +12 -12
- package/dist/shared/src/env.js.map +1 -1
- package/dist/shared/src/index.d.ts +30 -30
- package/dist/shared/src/index.d.ts.map +1 -1
- package/dist/shared/src/index.js +17 -17
- package/dist/shared/src/index.js.map +1 -1
- package/dist/shared/src/node.d.ts +1 -1
- package/dist/shared/src/node.d.ts.map +1 -1
- package/dist/shared/src/node.js +18 -18
- package/dist/shared/src/node.js.map +1 -1
- package/dist/src/codex.d.ts +1 -1
- package/dist/src/codex.js +19 -19
- package/dist/src/codex.js.map +1 -1
- package/dist/src/commands/click.d.ts +1 -1
- package/dist/src/commands/click.d.ts.map +1 -1
- package/dist/src/commands/click.js +32 -24
- package/dist/src/commands/click.js.map +1 -1
- package/dist/src/commands/run-js.d.ts +1 -1
- package/dist/src/commands/run-js.d.ts.map +1 -1
- package/dist/src/commands/run-js.js +10 -10
- package/dist/src/commands/run-js.js.map +1 -1
- package/dist/src/commands/trust-ca.d.ts +1 -1
- package/dist/src/commands/trust-ca.js +15 -15
- package/dist/src/core/config-file.d.ts.map +1 -1
- package/dist/src/core/config-file.js +49 -41
- package/dist/src/core/config-file.js.map +1 -1
- package/dist/src/core/config.d.ts +2 -2
- package/dist/src/core/config.d.ts.map +1 -1
- package/dist/src/core/config.js +22 -18
- package/dist/src/core/config.js.map +1 -1
- package/dist/src/core/dev-bootstrap.d.ts +1 -1
- package/dist/src/core/dev-bootstrap.d.ts.map +1 -1
- package/dist/src/core/dev-bootstrap.js +12 -12
- package/dist/src/core/dev-bootstrap.js.map +1 -1
- package/dist/src/core/env.d.ts +1 -1
- package/dist/src/core/env.d.ts.map +1 -1
- package/dist/src/core/env.js +3 -3
- package/dist/src/core/env.js.map +1 -1
- package/dist/src/devtools-registry.d.ts.map +1 -1
- package/dist/src/devtools-registry.js +48 -46
- package/dist/src/devtools-registry.js.map +1 -1
- package/dist/src/env.d.ts +1 -1
- package/dist/src/env.js +1 -1
- package/dist/src/http.d.ts.map +1 -1
- package/dist/src/http.js +7 -6
- package/dist/src/http.js.map +1 -1
- package/dist/src/index.d.ts +7 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +399 -367
- package/dist/src/index.js.map +1 -1
- package/dist/src/runtime/browser/client.d.ts +3 -3
- package/dist/src/runtime/browser/client.d.ts.map +1 -1
- package/dist/src/runtime/browser/client.js +79 -72
- package/dist/src/runtime/browser/client.js.map +1 -1
- package/dist/src/runtime/browser/commands/index.d.ts +2 -2
- package/dist/src/runtime/browser/commands/index.js +17 -17
- package/dist/src/runtime/browser/commands/index.js.map +1 -1
- package/dist/src/runtime/browser/dom-to-image-loader.d.ts.map +1 -1
- package/dist/src/runtime/browser/dom-to-image-loader.js +7 -7
- package/dist/src/runtime/browser/dom-to-image-loader.js.map +1 -1
- package/dist/src/runtime/browser/index.d.ts +3 -3
- package/dist/src/runtime/browser/index.js +2 -2
- package/dist/src/runtime/browser/module-loader.js +2 -2
- package/dist/src/runtime/browser/screenshot/hooks.d.ts +5 -5
- package/dist/src/runtime/browser/screenshot/hooks.d.ts.map +1 -1
- package/dist/src/runtime/browser/screenshot/hooks.js +32 -29
- package/dist/src/runtime/browser/screenshot/hooks.js.map +1 -1
- package/dist/src/runtime/browser/screenshot/index.d.ts +3 -3
- package/dist/src/runtime/browser/screenshot/index.d.ts.map +1 -1
- package/dist/src/runtime/browser/screenshot/index.js +17 -15
- package/dist/src/runtime/browser/screenshot/index.js.map +1 -1
- package/dist/src/runtime/browser/screenshot/renderers/dom-to-image.d.ts +1 -1
- package/dist/src/runtime/browser/screenshot/renderers/dom-to-image.js +13 -13
- package/dist/src/runtime/browser/screenshot/renderers/dom-to-image.js.map +1 -1
- package/dist/src/runtime/browser/screenshot/renderers/html2canvas.d.ts +1 -1
- package/dist/src/runtime/browser/screenshot/renderers/html2canvas.d.ts.map +1 -1
- package/dist/src/runtime/browser/screenshot/renderers/html2canvas.js +24 -24
- package/dist/src/runtime/browser/screenshot/renderers/html2canvas.js.map +1 -1
- package/dist/src/runtime/browser/screenshot/targets.d.ts +2 -2
- package/dist/src/runtime/browser/screenshot/targets.js +9 -9
- package/dist/src/runtime/browser/screenshot/utils.d.ts +1 -1
- package/dist/src/runtime/browser/screenshot/utils.d.ts.map +1 -1
- package/dist/src/runtime/browser/screenshot/utils.js +73 -71
- package/dist/src/runtime/browser/screenshot/utils.js.map +1 -1
- package/dist/src/runtime/browser/selector-discovery.d.ts +1 -1
- package/dist/src/runtime/browser/selector-discovery.d.ts.map +1 -1
- package/dist/src/runtime/browser/selector-discovery.js +24 -22
- package/dist/src/runtime/browser/selector-discovery.js.map +1 -1
- package/dist/src/runtime/browser/storage/session-storage.d.ts +1 -1
- package/dist/src/runtime/browser/storage/session-storage.d.ts.map +1 -1
- package/dist/src/runtime/browser/storage/session-storage.js +12 -10
- package/dist/src/runtime/browser/storage/session-storage.js.map +1 -1
- package/dist/src/runtime/browser/types.d.ts +7 -7
- package/dist/src/runtime/browser/types.js +1 -1
- package/dist/src/runtime/browser/utils/console.d.ts +1 -1
- package/dist/src/runtime/browser/utils/console.js +16 -16
- package/dist/src/runtime/browser/utils/console.js.map +1 -1
- package/dist/src/runtime/browser/utils/environment.js +2 -2
- package/dist/src/runtime/browser/utils/errors.d.ts.map +1 -1
- package/dist/src/runtime/browser/utils/errors.js +11 -11
- package/dist/src/runtime/browser/utils/number.d.ts.map +1 -1
- package/dist/src/runtime/browser/utils/number.js.map +1 -1
- package/dist/src/runtime/browser/utils/object.d.ts.map +1 -1
- package/dist/src/runtime/browser/utils/object.js +2 -2
- package/dist/src/runtime/browser/utils/object.js.map +1 -1
- package/dist/src/runtime/browser/utils/sanitize.js +2 -2
- package/dist/src/runtime/browser/utils/time.d.ts.map +1 -1
- package/dist/src/runtime/browser/utils/time.js +1 -1
- package/dist/src/runtime/chrome/cookies.d.ts +4 -4
- package/dist/src/runtime/chrome/cookies.d.ts.map +1 -1
- package/dist/src/runtime/chrome/cookies.js +31 -31
- package/dist/src/runtime/chrome/cookies.js.map +1 -1
- package/dist/src/runtime/chrome/deep-link.d.ts +1 -1
- package/dist/src/runtime/chrome/deep-link.d.ts.map +1 -1
- package/dist/src/runtime/chrome/deep-link.js +46 -36
- package/dist/src/runtime/chrome/deep-link.js.map +1 -1
- package/dist/src/runtime/chrome/diagnostics.d.ts.map +1 -1
- package/dist/src/runtime/chrome/diagnostics.js +13 -11
- package/dist/src/runtime/chrome/diagnostics.js.map +1 -1
- package/dist/src/runtime/chrome/focus.d.ts.map +1 -1
- package/dist/src/runtime/chrome/focus.js +5 -5
- package/dist/src/runtime/chrome/focus.js.map +1 -1
- package/dist/src/runtime/chrome/launch.d.ts.map +1 -1
- package/dist/src/runtime/chrome/launch.js +30 -30
- package/dist/src/runtime/chrome/launch.js.map +1 -1
- package/dist/src/runtime/chrome/puppeteer.d.ts +2 -2
- package/dist/src/runtime/chrome/puppeteer.d.ts.map +1 -1
- package/dist/src/runtime/chrome/puppeteer.js +16 -11
- package/dist/src/runtime/chrome/puppeteer.js.map +1 -1
- package/dist/src/runtime/chrome/reuse.d.ts.map +1 -1
- package/dist/src/runtime/chrome/reuse.js +38 -35
- package/dist/src/runtime/chrome/reuse.js.map +1 -1
- package/dist/src/runtime/chrome/session.d.ts +1 -1
- package/dist/src/runtime/chrome/session.d.ts.map +1 -1
- package/dist/src/runtime/chrome/session.js +12 -10
- package/dist/src/runtime/chrome/session.js.map +1 -1
- package/dist/src/runtime/chrome.d.ts +8 -8
- package/dist/src/runtime/chrome.js +8 -8
- package/dist/src/runtime/cookies.d.ts +1 -16
- package/dist/src/runtime/cookies.d.ts.map +1 -1
- package/dist/src/runtime/cookies.js +175 -286
- package/dist/src/runtime/cookies.js.map +1 -1
- package/dist/src/runtime/devstack.d.ts +1 -1
- package/dist/src/runtime/devstack.d.ts.map +1 -1
- package/dist/src/runtime/devstack.js +31 -28
- package/dist/src/runtime/devstack.js.map +1 -1
- package/dist/src/runtime/devtools/background.js +22 -22
- package/dist/src/runtime/devtools/cdp.d.ts +3 -3
- package/dist/src/runtime/devtools/cdp.d.ts.map +1 -1
- package/dist/src/runtime/devtools/cdp.js +59 -55
- package/dist/src/runtime/devtools/cdp.js.map +1 -1
- package/dist/src/runtime/devtools/config.d.ts.map +1 -1
- package/dist/src/runtime/devtools/config.js +15 -15
- package/dist/src/runtime/devtools/config.js.map +1 -1
- package/dist/src/runtime/devtools/constants.d.ts.map +1 -1
- package/dist/src/runtime/devtools/constants.js +18 -10
- package/dist/src/runtime/devtools/constants.js.map +1 -1
- package/dist/src/runtime/devtools/diagnostics.d.ts +4 -4
- package/dist/src/runtime/devtools/diagnostics.d.ts.map +1 -1
- package/dist/src/runtime/devtools/diagnostics.js +40 -38
- package/dist/src/runtime/devtools/diagnostics.js.map +1 -1
- package/dist/src/runtime/devtools/oauth.d.ts +1 -1
- package/dist/src/runtime/devtools/oauth.d.ts.map +1 -1
- package/dist/src/runtime/devtools/oauth.js +35 -28
- package/dist/src/runtime/devtools/oauth.js.map +1 -1
- package/dist/src/runtime/devtools/types.d.ts +3 -3
- package/dist/src/runtime/devtools/types.d.ts.map +1 -1
- package/dist/src/runtime/devtools.d.ts +7 -7
- package/dist/src/runtime/devtools.js +7 -7
- package/dist/src/runtime/next-devtools.d.ts.map +1 -1
- package/dist/src/runtime/next-devtools.js +12 -12
- package/dist/src/runtime/next-devtools.js.map +1 -1
- package/dist/src/runtime/screenshot.d.ts +9 -9
- package/dist/src/runtime/screenshot.d.ts.map +1 -1
- package/dist/src/runtime/screenshot.js +65 -46
- package/dist/src/runtime/screenshot.js.map +1 -1
- package/dist/src/runtime/scripts.d.ts +1 -1
- package/dist/src/runtime/scripts.d.ts.map +1 -1
- package/dist/src/runtime/scripts.js +28 -28
- package/dist/src/runtime/scripts.js.map +1 -1
- package/dist/src/runtime/session.d.ts +6 -6
- package/dist/src/runtime/session.d.ts.map +1 -1
- package/dist/src/runtime/session.js +35 -35
- package/dist/src/runtime/session.js.map +1 -1
- package/dist/src/runtime/smoke.d.ts +3 -3
- package/dist/src/runtime/smoke.d.ts.map +1 -1
- package/dist/src/runtime/smoke.js +85 -79
- package/dist/src/runtime/smoke.js.map +1 -1
- package/dist/src/runtime/url.d.ts +2 -2
- package/dist/src/runtime/url.d.ts.map +1 -1
- package/dist/src/runtime/url.js +20 -20
- package/dist/src/runtime/url.js.map +1 -1
- package/dist/src/screenshot-hooks.d.ts +1 -1
- package/dist/src/screenshot-hooks.d.ts.map +1 -1
- package/dist/src/screenshot-hooks.js +12 -12
- package/dist/src/screenshot-hooks.js.map +1 -1
- package/dist/src/shared/env.d.ts.map +1 -1
- package/dist/src/shared/env.js +11 -11
- package/dist/src/shared/env.js.map +1 -1
- package/dist/src/shared/index.d.ts +30 -30
- package/dist/src/shared/index.d.ts.map +1 -1
- package/dist/src/shared/index.js +17 -17
- package/dist/src/shared/index.js.map +1 -1
- package/dist/src/shared/node.d.ts +1 -1
- package/dist/src/shared/node.d.ts.map +1 -1
- package/dist/src/shared/node.js +18 -18
- package/dist/src/shared/node.js.map +1 -1
- package/dist/src/token.d.ts +1 -1
- package/dist/src/token.d.ts.map +1 -1
- package/dist/src/token.js +16 -16
- package/dist/src/token.js.map +1 -1
- package/dist/src/types.d.ts +1 -1
- package/dist/src/util/app-label.js +4 -4
- package/dist/src/util/errors.d.ts.map +1 -1
- package/dist/src/util/errors.js +12 -10
- package/dist/src/util/errors.js.map +1 -1
- package/dist/src/util/path.js +2 -2
- package/dist/src/util/regex.js +4 -4
- package/package.json +45 -39
|
@@ -1,58 +1,74 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { regex } from "arkregex";
|
|
5
|
+
import { getCookies } from "@steipete/sweet-cookie";
|
|
6
|
+
import { loadSweetLinkFileConfig } from "../core/config-file.js";
|
|
7
|
+
import { cliEnv } from "../env.js";
|
|
8
|
+
import { describeUnknown } from "../util/errors.js";
|
|
7
9
|
let tldPatchedForLocalhost;
|
|
8
|
-
|
|
9
|
-
const PROTOCOL_PREFIX_PATTERN = regex.as('^[a-z]+://', 'i');
|
|
10
|
+
const PROTOCOL_PREFIX_PATTERN = regex.as("^[a-z]+://", "i");
|
|
10
11
|
const LEADING_DOT_PATTERN = regex.as(String.raw `^\.`);
|
|
11
|
-
const SECURE_PREFIX_PATTERN = regex.as(
|
|
12
|
-
const HOST_PREFIX_PATTERN = regex.as(
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
12
|
+
const SECURE_PREFIX_PATTERN = regex.as("^__Secure-");
|
|
13
|
+
const HOST_PREFIX_PATTERN = regex.as("^__Host-");
|
|
14
|
+
const ORACLE_COOKIE_FILES = ["cookies.base64", "cookies.json"];
|
|
15
|
+
const resolveOracleInlineCookiesFile = () => {
|
|
16
|
+
const oracleDir = path.join(os.homedir(), ".oracle");
|
|
17
|
+
for (const filename of ORACLE_COOKIE_FILES) {
|
|
18
|
+
const candidate = path.join(oracleDir, filename);
|
|
19
|
+
if (existsSync(candidate)) {
|
|
20
|
+
return candidate;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return;
|
|
24
|
+
};
|
|
16
25
|
/** Collects cookies from the main Chrome profile matching the provided URL. */
|
|
17
26
|
export async function collectChromeCookies(targetUrl) {
|
|
18
27
|
await ensureTldPatchedForLocalhost();
|
|
19
|
-
const secureModule = await loadChromeCookiesModule();
|
|
20
|
-
if (!secureModule) {
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
const profileOverride = cliEnv.chromeProfilePath ?? undefined;
|
|
24
|
-
const origins = buildCookieOrigins(targetUrl);
|
|
25
|
-
const collected = new Map();
|
|
26
28
|
const debugCookies = cliEnv.cookieDebug;
|
|
27
|
-
const targetBaseUrl = new URL(targetUrl);
|
|
28
29
|
if (debugCookies) {
|
|
29
|
-
console.log(
|
|
30
|
+
console.log("Cookie sync debug enabled.");
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
const origins = buildCookieOrigins(targetUrl);
|
|
33
|
+
const expandedOrigins = expandCookieOriginsForFallbacks(origins);
|
|
34
|
+
const targetBaseUrl = new URL(targetUrl);
|
|
35
|
+
const inlineCookiesFile = resolveOracleInlineCookiesFile();
|
|
36
|
+
if (debugCookies && inlineCookiesFile) {
|
|
37
|
+
console.log(`[SweetLink] Using inline cookie fallback from ${inlineCookiesFile}.`);
|
|
38
|
+
}
|
|
39
|
+
const { cookies, warnings } = await getCookies({
|
|
40
|
+
url: targetUrl,
|
|
41
|
+
origins: expandedOrigins,
|
|
42
|
+
browsers: ["chrome"],
|
|
43
|
+
chromeProfile: cliEnv.chromeProfilePath ?? undefined,
|
|
44
|
+
debug: debugCookies,
|
|
45
|
+
...(inlineCookiesFile ? { inlineCookiesFile } : {}),
|
|
46
|
+
mode: "first",
|
|
47
|
+
});
|
|
48
|
+
if (debugCookies && warnings.length > 0) {
|
|
49
|
+
for (const warning of warnings) {
|
|
50
|
+
console.warn("[SweetLink] Cookie warning:", warning);
|
|
51
|
+
}
|
|
42
52
|
}
|
|
53
|
+
const collected = new Map();
|
|
54
|
+
ingestSweetCookieCookies({
|
|
55
|
+
cookies,
|
|
56
|
+
targetBaseUrl,
|
|
57
|
+
collected,
|
|
58
|
+
debug: debugCookies,
|
|
59
|
+
});
|
|
43
60
|
pruneIncompatibleCookies(targetBaseUrl, collected);
|
|
44
61
|
return [...collected.values()];
|
|
45
62
|
}
|
|
46
63
|
/** Collects cookies for each domain and groups them by the originating host. */
|
|
47
64
|
export async function collectChromeCookiesForDomains(domains) {
|
|
48
65
|
await ensureTldPatchedForLocalhost();
|
|
49
|
-
const secureModule = await loadChromeCookiesModule();
|
|
50
|
-
if (!secureModule) {
|
|
51
|
-
return {};
|
|
52
|
-
}
|
|
53
|
-
const profileOverride = cliEnv.chromeProfilePath ?? undefined;
|
|
54
66
|
const debugCookies = cliEnv.cookieDebug;
|
|
55
67
|
const results = {};
|
|
68
|
+
const inlineCookiesFile = resolveOracleInlineCookiesFile();
|
|
69
|
+
if (debugCookies && inlineCookiesFile) {
|
|
70
|
+
console.log(`[SweetLink] Using inline cookie fallback from ${inlineCookiesFile}.`);
|
|
71
|
+
}
|
|
56
72
|
for (const domainCandidate of domains) {
|
|
57
73
|
if (!domainCandidate) {
|
|
58
74
|
continue;
|
|
@@ -65,22 +81,35 @@ export async function collectChromeCookiesForDomains(domains) {
|
|
|
65
81
|
origins.add(extra);
|
|
66
82
|
}
|
|
67
83
|
}
|
|
84
|
+
const expandedOrigins = expandCookieOriginsForFallbacks([...origins.values()]);
|
|
68
85
|
const collected = new Map();
|
|
69
|
-
const originList = [...origins.values()].filter((origin) => Boolean(origin));
|
|
70
|
-
for (const origin of originList) {
|
|
71
|
-
// biome-ignore lint/performance/noAwaitInLoops: cookie reads must stay sequential for reliability.
|
|
72
|
-
await collectCookiesForOrigin({
|
|
73
|
-
origin,
|
|
74
|
-
secureModule,
|
|
75
|
-
profileOverride,
|
|
76
|
-
collected,
|
|
77
|
-
debugCookies,
|
|
78
|
-
targetBaseUrl: new URL(origin),
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
86
|
const targetIterator = origins.values().next();
|
|
82
87
|
const targetCandidate = targetIterator.done ? domain : targetIterator.value;
|
|
83
88
|
const targetBase = targetCandidate ? tryParseUrl(targetCandidate) : null;
|
|
89
|
+
const targetBaseUrl = targetBase ?? (targetCandidate ? tryParseUrl(`https://${targetCandidate}`) : null);
|
|
90
|
+
if (targetCandidate && targetBaseUrl) {
|
|
91
|
+
// biome-ignore lint/performance/noAwaitInLoops: cookie reads should stay sequential for predictable prompts/logging.
|
|
92
|
+
const { cookies, warnings } = await getCookies({
|
|
93
|
+
url: targetCandidate,
|
|
94
|
+
origins: expandedOrigins,
|
|
95
|
+
browsers: ["chrome"],
|
|
96
|
+
chromeProfile: cliEnv.chromeProfilePath ?? undefined,
|
|
97
|
+
debug: debugCookies,
|
|
98
|
+
...(inlineCookiesFile ? { inlineCookiesFile } : {}),
|
|
99
|
+
mode: "first",
|
|
100
|
+
});
|
|
101
|
+
if (debugCookies && warnings.length > 0) {
|
|
102
|
+
for (const warning of warnings) {
|
|
103
|
+
console.warn("[SweetLink] Cookie warning:", warning);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
ingestSweetCookieCookies({
|
|
107
|
+
cookies,
|
|
108
|
+
targetBaseUrl,
|
|
109
|
+
collected,
|
|
110
|
+
debug: debugCookies,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
84
113
|
if (targetBase) {
|
|
85
114
|
pruneIncompatibleCookies(targetBase, collected);
|
|
86
115
|
}
|
|
@@ -98,147 +127,68 @@ export function buildCookieOrigins(targetUrl) {
|
|
|
98
127
|
}
|
|
99
128
|
return [...origins];
|
|
100
129
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
let sourceBaseUrl = null;
|
|
104
|
-
try {
|
|
105
|
-
sourceBaseUrl = new URL(cookieOrigin);
|
|
106
|
-
}
|
|
107
|
-
catch {
|
|
108
|
-
if (debugCookies) {
|
|
109
|
-
console.log(`Skipping malformed cookie origin candidate ${cookieOrigin}`);
|
|
110
|
-
}
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
const fallbackOrigins = deriveCookieOriginFallbacks(sourceBaseUrl);
|
|
114
|
-
const attemptCookieRead = async (candidateOrigin, reason) => {
|
|
115
|
-
if (debugCookies) {
|
|
116
|
-
if (reason === 'primary') {
|
|
117
|
-
console.log(`Reading Chrome cookies for ${candidateOrigin}`);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
console.log(`Retrying cookie collection for ${cookieOrigin} using fallback ${candidateOrigin}`);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
try {
|
|
124
|
-
let candidateBase = null;
|
|
125
|
-
try {
|
|
126
|
-
candidateBase = new URL(candidateOrigin);
|
|
127
|
-
}
|
|
128
|
-
catch {
|
|
129
|
-
candidateBase = null;
|
|
130
|
-
}
|
|
131
|
-
if (!candidateBase) {
|
|
132
|
-
return 'parse-error';
|
|
133
|
-
}
|
|
134
|
-
sourceBaseUrl = candidateBase;
|
|
135
|
-
const beforeSize = collected.size;
|
|
136
|
-
const raw = (await secureModule.getCookiesPromised(candidateOrigin, 'puppeteer', profileOverride));
|
|
137
|
-
if (raw && raw.length > 0) {
|
|
138
|
-
ingestChromeCookies({
|
|
139
|
-
rawCookies: raw,
|
|
140
|
-
sourceBaseUrl: candidateBase,
|
|
141
|
-
targetBaseUrl,
|
|
142
|
-
collected,
|
|
143
|
-
sourceOrigin: candidateOrigin,
|
|
144
|
-
debug: debugCookies,
|
|
145
|
-
});
|
|
146
|
-
return collected.size > beforeSize ? 'added' : 'empty';
|
|
147
|
-
}
|
|
148
|
-
return 'empty';
|
|
149
|
-
}
|
|
150
|
-
catch (error) {
|
|
151
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
152
|
-
if (message.includes('Could not parse domain from URI')) {
|
|
153
|
-
if (reason === 'fallback' && debugCookies) {
|
|
154
|
-
console.log(`Fallback cookie origin ${candidateOrigin} also failed: ${message}`);
|
|
155
|
-
}
|
|
156
|
-
return 'parse-error';
|
|
157
|
-
}
|
|
158
|
-
if (reason === 'primary') {
|
|
159
|
-
console.warn(`Failed to read cookies from Chrome for ${candidateOrigin}:`, message);
|
|
160
|
-
console.warn('If this persists, ensure Chrome is running and you are logged in, then rerun the command.');
|
|
161
|
-
}
|
|
162
|
-
else if (debugCookies) {
|
|
163
|
-
console.log(`Fallback cookie origin ${candidateOrigin} also failed: ${message}`);
|
|
164
|
-
}
|
|
165
|
-
return 'failed';
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
const primaryResult = await attemptCookieRead(cookieOrigin, 'primary');
|
|
169
|
-
const shouldAttemptFallback = fallbackOrigins.length > 0 && (primaryResult === 'empty' || primaryResult === 'parse-error');
|
|
170
|
-
if (!shouldAttemptFallback) {
|
|
171
|
-
if (primaryResult === 'parse-error' && debugCookies) {
|
|
172
|
-
console.log(`Giving up on cookie sync for ${cookieOrigin}; chrome-cookies-secure cannot parse the host.`);
|
|
173
|
-
}
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
let sawParseError = primaryResult === 'parse-error';
|
|
177
|
-
for (const fallbackOrigin of fallbackOrigins) {
|
|
178
|
-
// biome-ignore lint/performance/noAwaitInLoops: fallback attempts must run sequentially to stop on the first success.
|
|
179
|
-
const result = await attemptCookieRead(fallbackOrigin, 'fallback');
|
|
180
|
-
if (result === 'added') {
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
if (result === 'parse-error') {
|
|
184
|
-
sawParseError = true;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
if (debugCookies) {
|
|
188
|
-
const reasonMessage = sawParseError
|
|
189
|
-
? 'chrome-cookies-secure cannot parse the host.'
|
|
190
|
-
: 'no cookies were found after fallback candidates.';
|
|
191
|
-
console.log(`Giving up on cookie sync for ${cookieOrigin}; ${reasonMessage}`);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
function ingestChromeCookies({ rawCookies, sourceBaseUrl, targetBaseUrl, collected, sourceOrigin, debug, }) {
|
|
195
|
-
if (!rawCookies?.length) {
|
|
130
|
+
function ingestSweetCookieCookies({ cookies, targetBaseUrl, collected, debug, }) {
|
|
131
|
+
if (!cookies?.length) {
|
|
196
132
|
return;
|
|
197
133
|
}
|
|
198
|
-
for (const cookie of
|
|
134
|
+
for (const cookie of cookies) {
|
|
199
135
|
if (debug) {
|
|
200
|
-
console.log(`Saw cookie ${describeUnknown(cookie.name,
|
|
136
|
+
console.log(`Saw cookie ${describeUnknown(cookie.name, "unknown")} from Sweet Cookie`);
|
|
201
137
|
}
|
|
202
|
-
const mapped = normalizePuppeteerCookie(cookie, {
|
|
203
|
-
sourceBase:
|
|
138
|
+
const mapped = normalizePuppeteerCookie(sweetCookieToChromeCookieRecord(cookie), {
|
|
139
|
+
sourceBase: resolveCookieSourceBase(cookie, targetBaseUrl),
|
|
204
140
|
targetBase: targetBaseUrl,
|
|
205
141
|
});
|
|
206
142
|
if (!mapped) {
|
|
207
143
|
continue;
|
|
208
144
|
}
|
|
209
|
-
const key = `${mapped.domain ?? mapped.url ??
|
|
145
|
+
const key = `${mapped.domain ?? mapped.url ?? targetBaseUrl.origin}|${mapped.path ?? "/"}|${mapped.name}`;
|
|
210
146
|
if (!collected.has(key)) {
|
|
211
147
|
collected.set(key, mapped);
|
|
212
148
|
}
|
|
213
149
|
}
|
|
214
150
|
if (debug) {
|
|
215
|
-
console.log(`${collected.size} cookies captured so far
|
|
151
|
+
console.log(`${collected.size} cookies captured so far`);
|
|
216
152
|
}
|
|
217
153
|
}
|
|
218
154
|
function deriveCookieOriginFallbacks(baseUrl) {
|
|
219
155
|
if (!baseUrl) {
|
|
220
156
|
return [];
|
|
221
157
|
}
|
|
222
|
-
const protocol = baseUrl.protocol ||
|
|
158
|
+
const protocol = baseUrl.protocol || "https:";
|
|
223
159
|
const host = baseUrl.hostname;
|
|
224
160
|
if (!host) {
|
|
225
161
|
return [];
|
|
226
162
|
}
|
|
227
163
|
const candidates = new Set();
|
|
228
164
|
const originWithSlash = `${protocol}//${host}/`;
|
|
229
|
-
if (host ===
|
|
165
|
+
if (host === "localhost" || host === "127.0.0.1") {
|
|
230
166
|
candidates.add(originWithSlash);
|
|
231
|
-
candidates.add(
|
|
232
|
-
candidates.add(
|
|
233
|
-
candidates.add(
|
|
234
|
-
candidates.add(
|
|
235
|
-
if (host ===
|
|
167
|
+
candidates.add("http://localhost/");
|
|
168
|
+
candidates.add("http://127.0.0.1/");
|
|
169
|
+
candidates.add("https://localhost/");
|
|
170
|
+
candidates.add("https://127.0.0.1/");
|
|
171
|
+
if (host === "localhost") {
|
|
236
172
|
candidates.add(`${protocol}//${host}.localdomain/`);
|
|
237
173
|
}
|
|
238
174
|
}
|
|
239
175
|
candidates.delete(`${baseUrl.origin}/`);
|
|
240
176
|
return [...candidates];
|
|
241
177
|
}
|
|
178
|
+
function expandCookieOriginsForFallbacks(origins) {
|
|
179
|
+
const expanded = new Set();
|
|
180
|
+
for (const origin of origins) {
|
|
181
|
+
expanded.add(origin);
|
|
182
|
+
const base = tryParseUrl(origin.endsWith("/") ? origin : `${origin}/`);
|
|
183
|
+
if (!base) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
for (const fallback of deriveCookieOriginFallbacks(base)) {
|
|
187
|
+
expanded.add(fallback);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return [...expanded.values()];
|
|
191
|
+
}
|
|
242
192
|
function normalizeDomainToOrigins(domain) {
|
|
243
193
|
const trimmed = domain.trim();
|
|
244
194
|
if (!trimmed) {
|
|
@@ -269,7 +219,7 @@ function extractHostCandidate(domain) {
|
|
|
269
219
|
return null;
|
|
270
220
|
}
|
|
271
221
|
try {
|
|
272
|
-
const url = new URL(trimmed.includes(
|
|
222
|
+
const url = new URL(trimmed.includes("://") ? trimmed : `https://${trimmed}`);
|
|
273
223
|
return url.hostname.toLowerCase();
|
|
274
224
|
}
|
|
275
225
|
catch {
|
|
@@ -318,7 +268,7 @@ function isConfiguredCookieDomain(host) {
|
|
|
318
268
|
function isHostMatch(host, pattern) {
|
|
319
269
|
const normalizedHost = host.toLowerCase();
|
|
320
270
|
let normalizedPattern = pattern.toLowerCase();
|
|
321
|
-
if (normalizedPattern.startsWith(
|
|
271
|
+
if (normalizedPattern.startsWith("*.")) {
|
|
322
272
|
normalizedPattern = normalizedPattern.slice(2);
|
|
323
273
|
}
|
|
324
274
|
if (!normalizedPattern) {
|
|
@@ -348,8 +298,8 @@ function normalizeOrigin(value) {
|
|
|
348
298
|
}
|
|
349
299
|
}
|
|
350
300
|
export function normalizePuppeteerCookie(cookie, bases) {
|
|
351
|
-
const originalName = typeof cookie.name ===
|
|
352
|
-
const value = typeof cookie.value ===
|
|
301
|
+
const originalName = typeof cookie.name === "string" ? cookie.name : null;
|
|
302
|
+
const value = typeof cookie.value === "string" ? cookie.value : null;
|
|
353
303
|
if (!originalName || value === null) {
|
|
354
304
|
return null;
|
|
355
305
|
}
|
|
@@ -357,17 +307,19 @@ export function normalizePuppeteerCookie(cookie, bases) {
|
|
|
357
307
|
name: originalName,
|
|
358
308
|
value,
|
|
359
309
|
};
|
|
360
|
-
const domain = typeof cookie.domain ===
|
|
361
|
-
const path = typeof cookie.path ===
|
|
310
|
+
const domain = typeof cookie.domain === "string" && cookie.domain.length > 0 ? cookie.domain : null;
|
|
311
|
+
const path = typeof cookie.path === "string" && cookie.path.length > 0 ? cookie.path : "/";
|
|
362
312
|
const targetHost = bases.targetBase.hostname;
|
|
363
|
-
const isLocalTarget = targetHost ===
|
|
364
|
-
const normalizedDomain = domain?.replace(LEADING_DOT_PATTERN,
|
|
313
|
+
const isLocalTarget = targetHost === "localhost" || targetHost === "127.0.0.1";
|
|
314
|
+
const normalizedDomain = domain?.replace(LEADING_DOT_PATTERN, "") ?? null;
|
|
365
315
|
const isConfiguredDomain = normalizedDomain ? isConfiguredCookieDomain(normalizedDomain) : false;
|
|
366
|
-
const isLocalDomain = normalizedDomain ===
|
|
367
|
-
|
|
368
|
-
|
|
316
|
+
const isLocalDomain = normalizedDomain === "localhost" ||
|
|
317
|
+
normalizedDomain === "127.0.0.1" ||
|
|
318
|
+
normalizedDomain === "::1";
|
|
319
|
+
if (isLocalTarget && result.name.startsWith("__Secure-better-auth.")) {
|
|
320
|
+
result.name = result.name.replace(SECURE_PREFIX_PATTERN, "");
|
|
369
321
|
}
|
|
370
|
-
if (domain && domain !==
|
|
322
|
+
if (domain && domain !== "localhost") {
|
|
371
323
|
if (isLocalTarget && (isConfiguredDomain || isLocalDomain)) {
|
|
372
324
|
result.url = bases.targetBase.origin;
|
|
373
325
|
}
|
|
@@ -387,60 +339,62 @@ export function normalizePuppeteerCookie(cookie, bases) {
|
|
|
387
339
|
if (cookie.HttpOnly === true || cookie.httpOnly === true) {
|
|
388
340
|
result.httpOnly = true;
|
|
389
341
|
}
|
|
390
|
-
const sameSiteSource = typeof cookie.sameSite ===
|
|
342
|
+
const sameSiteSource = typeof cookie.sameSite === "string" ? cookie.sameSite : undefined;
|
|
391
343
|
const sameSite = normalizeSameSite(sameSiteSource);
|
|
392
344
|
if (sameSite) {
|
|
393
345
|
result.sameSite = sameSite;
|
|
394
346
|
}
|
|
395
|
-
if (sameSite ===
|
|
347
|
+
if (sameSite === "None" && !result.secure) {
|
|
396
348
|
result.secure = true;
|
|
397
349
|
}
|
|
398
|
-
if (typeof cookie.expires ===
|
|
350
|
+
if (typeof cookie.expires === "number" && Number.isFinite(cookie.expires) && cookie.expires > 0) {
|
|
399
351
|
result.expires = Math.round(cookie.expires);
|
|
400
352
|
}
|
|
401
|
-
const rehomedToTarget = typeof result.url ===
|
|
402
|
-
|
|
353
|
+
const rehomedToTarget = typeof result.url === "string" &&
|
|
354
|
+
result.url.length > 0 &&
|
|
355
|
+
result.url === bases.targetBase.origin;
|
|
356
|
+
if (rehomedToTarget && bases.targetBase.protocol === "http:") {
|
|
403
357
|
if (result.secure) {
|
|
404
358
|
result.secure = false;
|
|
405
359
|
}
|
|
406
|
-
if (result.sameSite ===
|
|
407
|
-
result.sameSite =
|
|
360
|
+
if (result.sameSite === "None") {
|
|
361
|
+
result.sameSite = "Lax";
|
|
408
362
|
}
|
|
409
|
-
if (result.name.startsWith(
|
|
410
|
-
result.name = result.name.replace(SECURE_PREFIX_PATTERN,
|
|
363
|
+
if (result.name.startsWith("__Secure-")) {
|
|
364
|
+
result.name = result.name.replace(SECURE_PREFIX_PATTERN, "");
|
|
411
365
|
}
|
|
412
|
-
if (result.name.startsWith(
|
|
413
|
-
result.name = result.name.replace(HOST_PREFIX_PATTERN,
|
|
414
|
-
result.path =
|
|
366
|
+
if (result.name.startsWith("__Host-")) {
|
|
367
|
+
result.name = result.name.replace(HOST_PREFIX_PATTERN, "");
|
|
368
|
+
result.path = "/";
|
|
415
369
|
}
|
|
416
370
|
}
|
|
417
371
|
return result;
|
|
418
372
|
}
|
|
419
373
|
function normalizeSameSite(value) {
|
|
420
374
|
if (!value) {
|
|
421
|
-
return;
|
|
375
|
+
return undefined;
|
|
422
376
|
}
|
|
423
377
|
const normalized = value.toLowerCase();
|
|
424
|
-
if (normalized ===
|
|
425
|
-
return
|
|
378
|
+
if (normalized === "strict") {
|
|
379
|
+
return "Strict";
|
|
426
380
|
}
|
|
427
|
-
if (normalized ===
|
|
428
|
-
return
|
|
381
|
+
if (normalized === "lax") {
|
|
382
|
+
return "Lax";
|
|
429
383
|
}
|
|
430
|
-
if (normalized ===
|
|
431
|
-
return
|
|
384
|
+
if (normalized === "no_restriction" || normalized === "none") {
|
|
385
|
+
return "None";
|
|
432
386
|
}
|
|
433
|
-
return;
|
|
387
|
+
return undefined;
|
|
434
388
|
}
|
|
435
389
|
function pruneIncompatibleCookies(targetBaseUrl, collected) {
|
|
436
390
|
if (collected.size === 0) {
|
|
437
391
|
return;
|
|
438
392
|
}
|
|
439
|
-
const localHosts = new Set([
|
|
393
|
+
const localHosts = new Set(["localhost", "127.0.0.1", "::1"]);
|
|
440
394
|
if (!localHosts.has(targetBaseUrl.hostname)) {
|
|
441
395
|
return;
|
|
442
396
|
}
|
|
443
|
-
const disallowedNames = new Set([
|
|
397
|
+
const disallowedNames = new Set(["_vercel_session", "_vercel_jwt"]);
|
|
444
398
|
for (const [key, cookie] of collected.entries()) {
|
|
445
399
|
const name = cookie.name?.toLowerCase();
|
|
446
400
|
if (name && disallowedNames.has(name)) {
|
|
@@ -454,7 +408,7 @@ function tryParseUrl(candidate) {
|
|
|
454
408
|
}
|
|
455
409
|
catch {
|
|
456
410
|
try {
|
|
457
|
-
return new URL(candidate.includes(
|
|
411
|
+
return new URL(candidate.includes("://") ? candidate : `http://${candidate}`);
|
|
458
412
|
}
|
|
459
413
|
catch {
|
|
460
414
|
return null;
|
|
@@ -466,9 +420,9 @@ async function ensureTldPatchedForLocalhost() {
|
|
|
466
420
|
return;
|
|
467
421
|
}
|
|
468
422
|
try {
|
|
469
|
-
const importedModule = await import(
|
|
423
|
+
const importedModule = await import("tldjs");
|
|
470
424
|
const tld = resolveTldModule(importedModule);
|
|
471
|
-
if (tld && typeof tld.getDomain ===
|
|
425
|
+
if (tld && typeof tld.getDomain === "function") {
|
|
472
426
|
const originalGetDomain = tld.getDomain.bind(tld);
|
|
473
427
|
tld.getDomain = (uri) => {
|
|
474
428
|
const domain = originalGetDomain(uri);
|
|
@@ -486,114 +440,49 @@ async function ensureTldPatchedForLocalhost() {
|
|
|
486
440
|
}
|
|
487
441
|
}
|
|
488
442
|
catch (error) {
|
|
489
|
-
console.warn(
|
|
443
|
+
console.warn("Failed to patch tldjs for localhost support:", error);
|
|
490
444
|
}
|
|
491
445
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
SQLITE_SELF_REGISTER_PATTERN.test(message));
|
|
505
|
-
};
|
|
506
|
-
async function loadChromeCookiesModule() {
|
|
507
|
-
let imported;
|
|
508
|
-
try {
|
|
509
|
-
imported = await import('chrome-cookies-secure');
|
|
510
|
-
}
|
|
511
|
-
catch (error) {
|
|
512
|
-
console.warn('Failed to load chrome-cookies-secure to copy cookies:', error);
|
|
513
|
-
if (isSqliteBindingError(error)) {
|
|
514
|
-
const rebuilt = await attemptSqliteRebuild();
|
|
515
|
-
if (rebuilt) {
|
|
516
|
-
return loadChromeCookiesModule();
|
|
517
|
-
}
|
|
518
|
-
console.warn(SQLITE_BINDING_HINT);
|
|
519
|
-
}
|
|
520
|
-
else {
|
|
521
|
-
console.warn('If this persists, run `pnpm rebuild chrome-cookies-secure sqlite3 keytar --workspace-root`.');
|
|
522
|
-
}
|
|
523
|
-
return null;
|
|
524
|
-
}
|
|
525
|
-
const secureModule = resolveChromeCookieModule(imported);
|
|
526
|
-
if (!secureModule) {
|
|
527
|
-
console.warn('chrome-cookies-secure does not expose getCookiesPromised(); skipping cookie copy.');
|
|
528
|
-
return null;
|
|
529
|
-
}
|
|
530
|
-
return secureModule;
|
|
446
|
+
function sweetCookieToChromeCookieRecord(cookie) {
|
|
447
|
+
const record = {
|
|
448
|
+
name: cookie.name,
|
|
449
|
+
value: cookie.value,
|
|
450
|
+
domain: cookie.domain,
|
|
451
|
+
path: cookie.path,
|
|
452
|
+
secure: cookie.secure,
|
|
453
|
+
httpOnly: cookie.httpOnly,
|
|
454
|
+
sameSite: cookie.sameSite,
|
|
455
|
+
expires: cookie.expires,
|
|
456
|
+
};
|
|
457
|
+
return record;
|
|
531
458
|
}
|
|
532
|
-
function
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
return
|
|
459
|
+
function resolveCookieSourceBase(cookie, fallback) {
|
|
460
|
+
const origin = cookie.source?.origin;
|
|
461
|
+
if (typeof origin === "string" && origin.length > 0) {
|
|
462
|
+
try {
|
|
463
|
+
return new URL(origin);
|
|
464
|
+
}
|
|
465
|
+
catch {
|
|
466
|
+
return fallback;
|
|
540
467
|
}
|
|
541
468
|
}
|
|
542
|
-
return
|
|
543
|
-
}
|
|
544
|
-
function hasGetCookiesPromised(value) {
|
|
545
|
-
return Boolean(value && typeof value.getCookiesPromised === 'function');
|
|
469
|
+
return fallback;
|
|
546
470
|
}
|
|
547
471
|
function resolveTldModule(value) {
|
|
548
|
-
if (typeof value !==
|
|
472
|
+
if (typeof value !== "object" || value === null) {
|
|
549
473
|
return null;
|
|
550
474
|
}
|
|
551
475
|
const record = value;
|
|
552
|
-
if (typeof record.getDomain ===
|
|
476
|
+
if (typeof record.getDomain === "function") {
|
|
553
477
|
return record;
|
|
554
478
|
}
|
|
555
479
|
const defaultExport = record.default;
|
|
556
|
-
if (typeof defaultExport ===
|
|
480
|
+
if (typeof defaultExport === "object" && defaultExport !== null) {
|
|
557
481
|
const defaultRecord = defaultExport;
|
|
558
|
-
if (typeof defaultRecord.getDomain ===
|
|
482
|
+
if (typeof defaultRecord.getDomain === "function") {
|
|
559
483
|
return defaultRecord;
|
|
560
484
|
}
|
|
561
485
|
}
|
|
562
486
|
return null;
|
|
563
487
|
}
|
|
564
|
-
function attemptSqliteRebuild() {
|
|
565
|
-
if (attemptedSqliteRebuild) {
|
|
566
|
-
return Promise.resolve(false);
|
|
567
|
-
}
|
|
568
|
-
attemptedSqliteRebuild = true;
|
|
569
|
-
const pnpmCommand = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm';
|
|
570
|
-
const args = ['rebuild', 'chrome-cookies-secure', 'sqlite3', 'keytar', '--workspace-root'];
|
|
571
|
-
const childEnv = cloneProcessEnv();
|
|
572
|
-
const pythonBinary = childEnv.PYTHON ?? '/usr/bin/python3';
|
|
573
|
-
const rebuildCommand = `${pnpmCommand} ${args.join(' ')}`;
|
|
574
|
-
console.warn('[SweetLink] Attempting to rebuild sqlite3 bindings automatically…');
|
|
575
|
-
console.warn(`[SweetLink] Running: npm_config_build_from_source=1 PYTHON=${pythonBinary} ${rebuildCommand}`);
|
|
576
|
-
return new Promise((resolve) => {
|
|
577
|
-
childEnv.npm_config_build_from_source = '1';
|
|
578
|
-
childEnv.PYTHON = childEnv.PYTHON ?? '/usr/bin/python3';
|
|
579
|
-
const child = spawn(pnpmCommand, args, {
|
|
580
|
-
stdio: 'inherit',
|
|
581
|
-
env: childEnv,
|
|
582
|
-
});
|
|
583
|
-
child.on('exit', (code) => {
|
|
584
|
-
if (code === 0) {
|
|
585
|
-
console.warn('[SweetLink] sqlite3 rebuild completed successfully.');
|
|
586
|
-
resolve(true);
|
|
587
|
-
}
|
|
588
|
-
else {
|
|
589
|
-
console.warn('[SweetLink] sqlite3 rebuild failed with exit code', code ?? 0);
|
|
590
|
-
resolve(false);
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
child.on('error', (spawnError) => {
|
|
594
|
-
console.warn('[SweetLink] Unable to spawn pnpm to rebuild sqlite3:', spawnError);
|
|
595
|
-
resolve(false);
|
|
596
|
-
});
|
|
597
|
-
});
|
|
598
|
-
}
|
|
599
488
|
//# sourceMappingURL=cookies.js.map
|