@steipete/sweet-cookie
v0.3.0
Published
Inline-first browser cookie extraction for local tooling (no native addons).
Readme
@steipete/sweet-cookie
Inline-first browser cookie extraction for local tooling (no native addons).
Supports:
- Inline payloads (JSON / base64 / file) — most reliable path.
- Local browser reads (best effort): Chrome, Edge, Firefox, Safari (macOS).
- On macOS, the
chromebackend checks Chrome and Brave roots by default. - Default browser order is
chrome,safari,firefoxunlessbrowsersor env overrides it.
Install:
npm i @steipete/sweet-cookieUsage:
import { getCookies, toCookieHeader } from "@steipete/sweet-cookie";
const { cookies, warnings } = await getCookies({
url: "https://example.com/",
names: ["session", "csrf"],
browsers: ["chrome", "edge", "firefox", "safari"],
});
for (const w of warnings) console.warn(w);
const cookieHeader = toCookieHeader(cookies, { dedupeByName: true });macOS-specific Chromium targeting:
await getCookies({
url: "https://example.com/",
browsers: ["chrome"],
chromiumBrowser: "brave",
});Linux/Windows Brave or other Chromium-family profiles:
await getCookies({
url: "https://example.com/",
browsers: ["chrome"],
chromeProfile: "~/.config/BraveSoftware/Brave-Browser/Default",
});Notes:
profileis a shared alias forchromeProfile/edgeProfile.chromiumBrowserpins the macOSchromebackend tochrome,brave,arc, orchromium.- Inline payloads win first; otherwise local backends run in declared order.
- On Linux/Windows, Brave and other Chromium-family profiles work via an explicit
chromeProfilepath. edgeProfilefalls back toSWEET_COOKIE_CHROME_PROFILEwhenSWEET_COOKIE_EDGE_PROFILEis unset.- On Linux, Chromium safe-storage overrides also support
SWEET_COOKIE_BRAVE_SAFE_STORAGE_PASSWORD.
Docs + extension exporter: see the repo root README.
