Skip to content

πŸͺπŸ– Node.js tool for querying local browser Chrome, Firefox or Safari cookies

Notifications You must be signed in to change notification settings

mherod/get-cookie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

get-cookie πŸͺ

Tired of manually copying cookies for API testing? get-cookie extracts authentication cookies directly from Chrome, Firefox, and Safari - perfect for testing, debugging, and automation.

Quick Start πŸš€

# Install globally
pnpm add -g @mherod/get-cookie

# Get a cookie
get-cookie auth example.com

# Get all cookies for a domain
get-cookie % example.com
// Node.js usage
import { getCookie } from "@mherod/get-cookie";

const cookies = await getCookie({
  name: "auth",
  domain: "example.com",
});

⚠️ Platform Support:

  • Chrome: macOS only
  • Firefox: macOS and Linux
  • Safari: macOS only

Installation πŸ“¦

pnpm add @mherod/get-cookie    # recommended
npm install @mherod/get-cookie # or npm
yarn add @mherod/get-cookie    # or yarn

Common Use Cases 🎯

  • πŸ” Get auth cookies for API testing
  • πŸ” Debug cookie issues across browsers
  • πŸ€– Automate cookie extraction
  • πŸ§ͺ Use real cookies in integration tests

Basic Usage Examples πŸ’‘

CLI

# Get specific cookie
get-cookie auth example.com

# Pretty print
get-cookie auth example.com --render

# From URL
get-cookie --url https://example.com/path

Node.js

import { getCookie, type CookieSpec } from "@mherod/get-cookie";

try {
  // Get specific cookie
  const authCookie = await getCookie({
    name: "auth",
    domain: "example.com",
  });

  // Get multiple cookies
  const cookies = await getCookie({
    name: "%", // all cookies
    domain: "example.com",
  });
} catch (error) {
  console.error("Failed:", error);
}

Features ✨

  • 🌐 Multi-Browser Support:
    • Chrome (macOS)
    • Firefox (macOS, Linux)
    • Safari (macOS)
  • πŸ”’ Secure: Browser-specific encryption handling
  • πŸ“ TypeScript Ready: Full type safety with exported type definitions
  • 🎯 Flexible Querying: Search by name, domain, or use wildcards
  • πŸ”„ Multiple Output Formats: JSON, rendered, or grouped results
  • πŸ‘₯ Profile Support: Chrome and Firefox multi-profile support

⚠️ Note: Platform support varies by browser. See our Platform Support Guide for details.

Output Formats πŸ“Š

The CLI supports various output formats:

# Default output (just values)
get-cookie auth example.com

# JSON output
get-cookie auth example.com --output json

# Rendered output (human-readable)
get-cookie auth example.com --render

# Grouped by browser/profile
get-cookie auth example.com --dump-grouped

Documentation πŸ“š

Full docs at mherod.github.io/get-cookie

  • API Reference
  • Advanced Usage
  • TypeScript Types
  • Security Guide ⚠️

Contributing 🀝

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

License πŸ“„

This project is licensed under the MIT License - see the LICENSE file for details.

Known Limitations 🚧

For a comprehensive list of limitations and known issues, please see our Known Limitations Guide.