@mherod/get-cookie 4.4.1 → 4.4.2
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/.husky/commit-msg +0 -0
- package/.husky/pre-commit +10 -0
- package/.husky/pre-push +15 -0
- package/dist/cli.cjs +10 -10
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +11 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/examples/README.md +40 -6
- package/examples/cli-examples.sh +0 -0
- package/examples/curl-integration.sh +195 -160
- package/examples/features-demo.sh +260 -0
- package/examples/github-auth.sh +295 -0
- package/examples/quick-start.sh +115 -0
- package/package.json +36 -45
- package/tsup.cli.ts +1 -0
- package/tsup.lib.ts +9 -1
- package/examples/chrome-cookies-demo.sh +0 -117
- package/examples/chrome-profile-demo.sh +0 -126
- package/examples/curl-demo.sh +0 -102
- package/examples/curl-with-url.sh +0 -136
- package/examples/deduplication-demo.sh +0 -110
- package/examples/final-chrome-demo.sh +0 -115
- package/examples/github-api.sh +0 -101
- package/examples/github-private-access.sh +0 -118
- package/examples/list-profiles-demo.sh +0 -120
- package/examples/proper-curl-usage.sh +0 -120
- package/examples/simple-curl.sh +0 -95
- package/examples/test-expired-filtering.sh +0 -68
- package/examples/test-github-access.sh +0 -245
- package/examples/test-github-auth-improved.sh +0 -136
- package/examples/working-curl.sh +0 -117
- package/examples/working-github-auth.sh +0 -87
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Demonstration of the new cookie deduplication feature
|
|
4
|
-
echo "🍪 Cookie Deduplication Feature Demo"
|
|
5
|
-
echo "===================================="
|
|
6
|
-
echo ""
|
|
7
|
-
echo "This demo shows how get-cookie now handles duplicate cookies"
|
|
8
|
-
echo "from Chrome profiles by default, keeping the most valid one."
|
|
9
|
-
echo ""
|
|
10
|
-
|
|
11
|
-
# Show the problem
|
|
12
|
-
echo "1️⃣ The Problem: Chrome Duplicate Cookies"
|
|
13
|
-
echo "────────────────────────────────────────"
|
|
14
|
-
echo "Chrome can store duplicate cookies from different profiles."
|
|
15
|
-
echo "Let's see what happens with --include-all (old behavior):"
|
|
16
|
-
echo ""
|
|
17
|
-
|
|
18
|
-
echo "Command: get-cookie user_session github.com --browser chrome --output json --include-all"
|
|
19
|
-
echo ""
|
|
20
|
-
get-cookie user_session github.com --browser chrome --output json --include-all 2>/dev/null | \
|
|
21
|
-
jq -r '.[] | " • Value: \(.value[0:20])... (\(.value | length) chars)"'
|
|
22
|
-
echo ""
|
|
23
|
-
|
|
24
|
-
# Show the solution
|
|
25
|
-
echo "2️⃣ The Solution: Automatic Deduplication (Default)"
|
|
26
|
-
echo "──────────────────────────────────────────────────"
|
|
27
|
-
echo "By default, get-cookie now keeps only the most valid cookie:"
|
|
28
|
-
echo ""
|
|
29
|
-
|
|
30
|
-
echo "Command: get-cookie user_session github.com --browser chrome --output json"
|
|
31
|
-
echo ""
|
|
32
|
-
get-cookie user_session github.com --browser chrome --output json 2>/dev/null | \
|
|
33
|
-
jq -r '.[] | " • Value: \(.value[0:20])... (\(.value | length) chars)"'
|
|
34
|
-
echo ""
|
|
35
|
-
|
|
36
|
-
# Demonstrate the render difference
|
|
37
|
-
echo "3️⃣ Impact on --render Output"
|
|
38
|
-
echo "───────────────────────────"
|
|
39
|
-
echo ""
|
|
40
|
-
|
|
41
|
-
echo "With --include-all (all duplicates):"
|
|
42
|
-
RENDER_ALL=$(get-cookie user_session github.com --browser chrome --render --include-all 2>/dev/null)
|
|
43
|
-
echo " ${RENDER_ALL:0:60}..."
|
|
44
|
-
echo " Length: $(echo "$RENDER_ALL" | wc -c) chars"
|
|
45
|
-
echo ""
|
|
46
|
-
|
|
47
|
-
echo "Default (deduplicated):"
|
|
48
|
-
RENDER_DEDUP=$(get-cookie user_session github.com --browser chrome --render 2>/dev/null)
|
|
49
|
-
echo " $RENDER_DEDUP"
|
|
50
|
-
echo " Length: $(echo "$RENDER_DEDUP" | wc -c) chars"
|
|
51
|
-
echo ""
|
|
52
|
-
|
|
53
|
-
# Show how it works with curl
|
|
54
|
-
echo "4️⃣ Using with curl"
|
|
55
|
-
echo "────────────────"
|
|
56
|
-
echo "The deduplication ensures curl gets the valid cookie:"
|
|
57
|
-
echo ""
|
|
58
|
-
|
|
59
|
-
echo "Command: curl -H \"Cookie: \$(get-cookie --url <URL> --browser chrome --render)\" <URL>"
|
|
60
|
-
echo ""
|
|
61
|
-
echo "Example for GitHub:"
|
|
62
|
-
COOKIES=$(get-cookie --url https://github.com --browser chrome --render 2>/dev/null)
|
|
63
|
-
echo " Cookie count: $(echo "$COOKIES" | grep -o ';' | wc -l | xargs expr 1 +)"
|
|
64
|
-
echo " user_session value length: $(echo "$COOKIES" | grep -o 'user_session=[^;]*' | cut -d'=' -f2 | wc -c) chars"
|
|
65
|
-
echo ""
|
|
66
|
-
|
|
67
|
-
# Show all duplicates
|
|
68
|
-
echo "5️⃣ Viewing All Duplicates"
|
|
69
|
-
echo "───────────────────────"
|
|
70
|
-
echo "To see all duplicate cookies (for debugging), use --include-all:"
|
|
71
|
-
echo ""
|
|
72
|
-
|
|
73
|
-
echo "Command: get-cookie % github.com --browser chrome --output json --include-all"
|
|
74
|
-
echo ""
|
|
75
|
-
echo "Duplicate cookie names found:"
|
|
76
|
-
get-cookie % github.com --browser chrome --output json --include-all 2>/dev/null | \
|
|
77
|
-
jq -r '[.[] | .name] | group_by(.) | map(select(length > 1)) | map(.[0]) | .[]' | \
|
|
78
|
-
sort | uniq | while read name; do
|
|
79
|
-
COUNT=$(get-cookie "$name" github.com --browser chrome --output json --include-all 2>/dev/null | jq 'length')
|
|
80
|
-
if [ "$COUNT" -gt 1 ]; then
|
|
81
|
-
echo " • $name: $COUNT copies"
|
|
82
|
-
fi
|
|
83
|
-
done
|
|
84
|
-
echo ""
|
|
85
|
-
|
|
86
|
-
# Summary
|
|
87
|
-
echo "📊 Summary"
|
|
88
|
-
echo "────────"
|
|
89
|
-
echo ""
|
|
90
|
-
|
|
91
|
-
# Count cookies with and without deduplication
|
|
92
|
-
TOTAL_ALL=$(get-cookie % github.com --browser chrome --output json --include-all 2>/dev/null | jq 'length')
|
|
93
|
-
TOTAL_DEDUP=$(get-cookie % github.com --browser chrome --output json 2>/dev/null | jq 'length')
|
|
94
|
-
REMOVED=$((TOTAL_ALL - TOTAL_DEDUP))
|
|
95
|
-
|
|
96
|
-
echo "Chrome cookies for github.com:"
|
|
97
|
-
echo " • With --include-all: $TOTAL_ALL cookies"
|
|
98
|
-
echo " • Default (deduplicated): $TOTAL_DEDUP cookies"
|
|
99
|
-
echo " • Duplicates removed: $REMOVED"
|
|
100
|
-
echo ""
|
|
101
|
-
|
|
102
|
-
echo "💡 Key Points:"
|
|
103
|
-
echo "────────────"
|
|
104
|
-
echo "• Deduplication is ON by default (keeps longest/newest cookie)"
|
|
105
|
-
echo "• Use --include-all to see all duplicates"
|
|
106
|
-
echo "• Combines with --include-expired for complete control"
|
|
107
|
-
echo "• Solves the Chrome \"truncated cookie\" problem"
|
|
108
|
-
echo ""
|
|
109
|
-
|
|
110
|
-
echo "✅ The deduplication feature ensures you get valid cookies for authentication!"
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Final demonstration of Chrome cookie extraction with deduplication
|
|
4
|
-
echo "🍪 get-cookie Chrome Integration Demo"
|
|
5
|
-
echo "====================================="
|
|
6
|
-
echo ""
|
|
7
|
-
|
|
8
|
-
echo "✨ New Features Implemented:"
|
|
9
|
-
echo "──────────────────────────"
|
|
10
|
-
echo "1. Automatic cookie deduplication (keeps longest/most valid)"
|
|
11
|
-
echo "2. --include-all flag to see all duplicates"
|
|
12
|
-
echo "3. --include-expired flag to include expired cookies"
|
|
13
|
-
echo ""
|
|
14
|
-
|
|
15
|
-
# Show the improved Chrome cookie extraction
|
|
16
|
-
echo "📊 Chrome Cookie Extraction:"
|
|
17
|
-
echo "──────────────────────────"
|
|
18
|
-
echo ""
|
|
19
|
-
|
|
20
|
-
echo "Default behavior (deduplicated, non-expired only):"
|
|
21
|
-
echo "$ get-cookie --url https://github.com --browser chrome --render"
|
|
22
|
-
echo ""
|
|
23
|
-
COOKIES=$(get-cookie --url https://github.com --browser chrome --render 2>/dev/null)
|
|
24
|
-
echo "${COOKIES:0:100}..."
|
|
25
|
-
echo "Total length: $(echo "$COOKIES" | wc -c) chars"
|
|
26
|
-
echo ""
|
|
27
|
-
|
|
28
|
-
# Show the cookie stats
|
|
29
|
-
echo "Cookie Statistics:"
|
|
30
|
-
DEFAULT_COUNT=$(get-cookie --url https://github.com --browser chrome --output json 2>/dev/null | jq 'length')
|
|
31
|
-
ALL_COUNT=$(get-cookie --url https://github.com --browser chrome --output json --include-all 2>/dev/null | jq 'length')
|
|
32
|
-
echo " • Deduplicated cookies: $DEFAULT_COUNT"
|
|
33
|
-
echo " • All cookies (--include-all): $ALL_COUNT"
|
|
34
|
-
echo " • Duplicates removed: $((ALL_COUNT - DEFAULT_COUNT))"
|
|
35
|
-
echo ""
|
|
36
|
-
|
|
37
|
-
# Demonstrate the key improvement
|
|
38
|
-
echo "🔑 Key Improvement: Session Cookie Handling"
|
|
39
|
-
echo "──────────────────────────────────────────"
|
|
40
|
-
echo ""
|
|
41
|
-
echo "Problem: Chrome stores duplicate session cookies"
|
|
42
|
-
echo " • Invalid truncated: 'AJW' (3 chars)"
|
|
43
|
-
echo " • Valid full session: 'SgOohLA29269kO...' (48 chars)"
|
|
44
|
-
echo ""
|
|
45
|
-
echo "Solution: Automatic deduplication keeps the valid one:"
|
|
46
|
-
SESSION=$(get-cookie user_session github.com --browser chrome --output json 2>/dev/null | jq -r '.[0].value')
|
|
47
|
-
echo " • Selected: ${SESSION:0:20}... (${#SESSION} chars) ✅"
|
|
48
|
-
echo ""
|
|
49
|
-
|
|
50
|
-
# Show practical usage patterns
|
|
51
|
-
echo "💻 Practical Usage Patterns:"
|
|
52
|
-
echo "──────────────────────────"
|
|
53
|
-
echo ""
|
|
54
|
-
|
|
55
|
-
echo "1. Simple cookie extraction for curl:"
|
|
56
|
-
echo ' curl -H "Cookie: $(get-cookie --url <URL> --browser chrome --render)" <URL>'
|
|
57
|
-
echo ""
|
|
58
|
-
|
|
59
|
-
echo "2. JSON output for precise control:"
|
|
60
|
-
echo ' get-cookie --url <URL> --browser chrome --output json | jq ...'
|
|
61
|
-
echo ""
|
|
62
|
-
|
|
63
|
-
echo "3. Debug duplicate cookies:"
|
|
64
|
-
echo ' get-cookie --url <URL> --browser chrome --output json --include-all'
|
|
65
|
-
echo ""
|
|
66
|
-
|
|
67
|
-
echo "4. Include expired cookies (if needed):"
|
|
68
|
-
echo ' get-cookie --url <URL> --browser chrome --render --include-expired'
|
|
69
|
-
echo ""
|
|
70
|
-
|
|
71
|
-
# Test with a simpler site
|
|
72
|
-
echo "🧪 Testing with httpbin.org:"
|
|
73
|
-
echo "──────────────────────────"
|
|
74
|
-
echo ""
|
|
75
|
-
|
|
76
|
-
# Set a test cookie in Chrome (this would need to be done manually)
|
|
77
|
-
echo "Setting a test cookie and retrieving it:"
|
|
78
|
-
echo '$ curl -c - "https://httpbin.org/cookies/set?test_cookie=hello_world"'
|
|
79
|
-
echo ""
|
|
80
|
-
|
|
81
|
-
# Try to get any httpbin cookies
|
|
82
|
-
HTTPBIN_COOKIES=$(get-cookie % httpbin.org --browser chrome --output json 2>/dev/null | jq 'length')
|
|
83
|
-
if [ "$HTTPBIN_COOKIES" -gt 0 ]; then
|
|
84
|
-
echo "Found $HTTPBIN_COOKIES httpbin.org cookies in Chrome"
|
|
85
|
-
get-cookie % httpbin.org --browser chrome --render
|
|
86
|
-
else
|
|
87
|
-
echo "No httpbin.org cookies found (visit httpbin.org in Chrome to set some)"
|
|
88
|
-
fi
|
|
89
|
-
echo ""
|
|
90
|
-
|
|
91
|
-
# Summary
|
|
92
|
-
echo "📈 Performance Improvements:"
|
|
93
|
-
echo "─────────────────────────"
|
|
94
|
-
echo "• Eliminates duplicate cookies automatically"
|
|
95
|
-
echo "• Filters expired cookies by default"
|
|
96
|
-
echo "• Prioritizes valid cookies (longer values)"
|
|
97
|
-
echo "• Backwards compatible with --include-all flag"
|
|
98
|
-
echo ""
|
|
99
|
-
|
|
100
|
-
echo "🔒 Note on GitHub Authentication:"
|
|
101
|
-
echo "────────────────────────────────"
|
|
102
|
-
echo "GitHub uses additional security measures beyond cookies:"
|
|
103
|
-
echo "• IP address verification"
|
|
104
|
-
echo "• User-Agent fingerprinting"
|
|
105
|
-
echo "• Session binding to browser instance"
|
|
106
|
-
echo "• CORS and referer checking"
|
|
107
|
-
echo ""
|
|
108
|
-
echo "For GitHub API access, use:"
|
|
109
|
-
echo "• GitHub CLI: gh auth login"
|
|
110
|
-
echo "• Personal Access Tokens"
|
|
111
|
-
echo "• OAuth apps"
|
|
112
|
-
echo ""
|
|
113
|
-
|
|
114
|
-
echo "✅ Chrome cookie extraction is working perfectly!"
|
|
115
|
-
echo " The deduplication ensures you get valid, usable cookies."
|
package/examples/github-api.sh
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Real-world example: Using get-cookie to access GitHub's authenticated endpoints
|
|
4
|
-
# This demonstrates how browser cookies can be used for API automation
|
|
5
|
-
|
|
6
|
-
echo "🔐 GitHub API Authentication with get-cookie"
|
|
7
|
-
echo "============================================"
|
|
8
|
-
|
|
9
|
-
# Get all relevant GitHub cookies using --render
|
|
10
|
-
echo -e "\nExtracting GitHub cookies..."
|
|
11
|
-
COOKIES=$(get-cookie % github.com --render 2>/dev/null | grep -E "(user_session|dotcom_user|__Host)" | paste -sd '; ')
|
|
12
|
-
|
|
13
|
-
if [ -z "$COOKIES" ]; then
|
|
14
|
-
echo "❌ No GitHub cookies found. Please log into GitHub in your browser."
|
|
15
|
-
exit 1
|
|
16
|
-
fi
|
|
17
|
-
|
|
18
|
-
echo "✅ Found GitHub cookies"
|
|
19
|
-
echo " Cookie count: $(echo "$COOKIES" | grep -o ';' | wc -l | xargs expr 1 +)"
|
|
20
|
-
|
|
21
|
-
# Test authentication with various GitHub endpoints
|
|
22
|
-
echo -e "\n📊 Testing GitHub API endpoints:\n"
|
|
23
|
-
|
|
24
|
-
# 1. User profile (public API, but returns more data when authenticated)
|
|
25
|
-
echo "1. Fetching user profile..."
|
|
26
|
-
USER_DATA=$(curl -s -H "Cookie: $COOKIES" https://api.github.com/user)
|
|
27
|
-
LOGIN=$(echo "$USER_DATA" | jq -r '.login // empty')
|
|
28
|
-
if [ -n "$LOGIN" ]; then
|
|
29
|
-
echo " ✅ Authenticated as: @$LOGIN"
|
|
30
|
-
echo " • Name: $(echo "$USER_DATA" | jq -r '.name // "N/A"')"
|
|
31
|
-
echo " • Public repos: $(echo "$USER_DATA" | jq -r '.public_repos // 0')"
|
|
32
|
-
echo " • Followers: $(echo "$USER_DATA" | jq -r '.followers // 0')"
|
|
33
|
-
else
|
|
34
|
-
echo " ⚠️ API authentication failed (cookies may not work for API)"
|
|
35
|
-
fi
|
|
36
|
-
|
|
37
|
-
# 2. Check notifications (requires authentication)
|
|
38
|
-
echo -e "\n2. Checking notifications..."
|
|
39
|
-
NOTIFICATIONS=$(curl -s -H "Cookie: $COOKIES" \
|
|
40
|
-
-H "Accept: application/vnd.github.v3+json" \
|
|
41
|
-
"https://api.github.com/notifications" | jq '. | length')
|
|
42
|
-
if [ "$NOTIFICATIONS" != "null" ]; then
|
|
43
|
-
echo " 📬 Unread notifications: $NOTIFICATIONS"
|
|
44
|
-
else
|
|
45
|
-
echo " ⚠️ Could not fetch notifications"
|
|
46
|
-
fi
|
|
47
|
-
|
|
48
|
-
# 3. List private repos (if any)
|
|
49
|
-
echo -e "\n3. Checking private repositories..."
|
|
50
|
-
PRIVATE_REPOS=$(curl -s -H "Cookie: $COOKIES" \
|
|
51
|
-
"https://api.github.com/user/repos?type=private" | jq '. | length')
|
|
52
|
-
if [ "$PRIVATE_REPOS" != "null" ] && [ "$PRIVATE_REPOS" != "0" ]; then
|
|
53
|
-
echo " 🔒 Private repositories: $PRIVATE_REPOS"
|
|
54
|
-
else
|
|
55
|
-
echo " ℹ️ No private repositories accessible"
|
|
56
|
-
fi
|
|
57
|
-
|
|
58
|
-
# 4. Recent activity
|
|
59
|
-
echo -e "\n4. Fetching recent activity..."
|
|
60
|
-
EVENTS=$(curl -s -H "Cookie: $COOKIES" \
|
|
61
|
-
"https://api.github.com/users/$LOGIN/events?per_page=5" | jq -r '.[] | "\(.type) in \(.repo.name)"' 2>/dev/null | head -5)
|
|
62
|
-
if [ -n "$EVENTS" ]; then
|
|
63
|
-
echo " Recent activity:"
|
|
64
|
-
echo "$EVENTS" | while read event; do
|
|
65
|
-
echo " • $event"
|
|
66
|
-
done
|
|
67
|
-
else
|
|
68
|
-
echo " ⚠️ Could not fetch activity"
|
|
69
|
-
fi
|
|
70
|
-
|
|
71
|
-
# Practical example: Create a gist
|
|
72
|
-
echo -e "\n💡 Example: Creating a gist with authentication"
|
|
73
|
-
echo "──────────────────────────────────────────────"
|
|
74
|
-
cat << 'EOF'
|
|
75
|
-
curl -X POST \
|
|
76
|
-
-H "Cookie: $(get-cookie % github.com --render | grep -E 'user_session|__Host' | paste -sd '; ')" \
|
|
77
|
-
-H "Content-Type: application/json" \
|
|
78
|
-
-d '{
|
|
79
|
-
"description": "Created via get-cookie + curl",
|
|
80
|
-
"public": false,
|
|
81
|
-
"files": {
|
|
82
|
-
"test.md": {
|
|
83
|
-
"content": "# Hello from get-cookie!\nThis gist was created using browser cookies."
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}' \
|
|
87
|
-
https://api.github.com/gists
|
|
88
|
-
EOF
|
|
89
|
-
|
|
90
|
-
echo -e "\n🔍 Debugging tip:"
|
|
91
|
-
echo "──────────────────"
|
|
92
|
-
echo "If authentication fails, GitHub cookies might not work with the API."
|
|
93
|
-
echo "GitHub's API primarily uses OAuth tokens, not browser session cookies."
|
|
94
|
-
echo ""
|
|
95
|
-
echo "To see what cookies you have:"
|
|
96
|
-
echo " get-cookie % github.com --dump"
|
|
97
|
-
echo ""
|
|
98
|
-
echo "To get just the cookie values:"
|
|
99
|
-
echo " get-cookie user_session github.com --render"
|
|
100
|
-
echo ""
|
|
101
|
-
echo "✅ Script complete!"
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Accessing GitHub private content with browser cookies
|
|
4
|
-
echo "🔓 GitHub Private Repository Access with get-cookie"
|
|
5
|
-
echo "=================================================="
|
|
6
|
-
echo ""
|
|
7
|
-
|
|
8
|
-
# Get the full session cookie (not truncated ones)
|
|
9
|
-
echo "Extracting valid GitHub session cookies..."
|
|
10
|
-
FULL_SESSION=$(get-cookie user_session github.com --output json 2>/dev/null | jq -r '.[] | select(.value | length > 10) | .value' | head -1)
|
|
11
|
-
|
|
12
|
-
if [ -z "$FULL_SESSION" ]; then
|
|
13
|
-
echo "❌ No valid GitHub session found. Please log into GitHub in Chrome."
|
|
14
|
-
exit 1
|
|
15
|
-
fi
|
|
16
|
-
|
|
17
|
-
echo "✅ Found valid session cookie (${#FULL_SESSION} characters)"
|
|
18
|
-
echo ""
|
|
19
|
-
|
|
20
|
-
# Build the cookie header with both required cookies
|
|
21
|
-
COOKIE_HEADER="user_session=$FULL_SESSION; __Host-user_session_same_site=$FULL_SESSION"
|
|
22
|
-
|
|
23
|
-
# Get username
|
|
24
|
-
USERNAME=$(get-cookie dotcom_user github.com --output json 2>/dev/null | jq -r '.[0].value' | cut -d';' -f1)
|
|
25
|
-
echo "👤 Logged in as: $USERNAME"
|
|
26
|
-
echo ""
|
|
27
|
-
|
|
28
|
-
echo "📊 Repository Statistics:"
|
|
29
|
-
echo "────────────────────────"
|
|
30
|
-
|
|
31
|
-
# Count repositories
|
|
32
|
-
REPOS_HTML=$(curl -s -L \
|
|
33
|
-
-H "Cookie: $COOKIE_HEADER" \
|
|
34
|
-
-H "User-Agent: Mozilla/5.0" \
|
|
35
|
-
"https://github.com/$USERNAME?tab=repositories")
|
|
36
|
-
|
|
37
|
-
PUBLIC_COUNT=$(echo "$REPOS_HTML" | grep -o '>Public<' | wc -l | xargs)
|
|
38
|
-
PRIVATE_COUNT=$(echo "$REPOS_HTML" | grep -o '>Private<' | wc -l | xargs)
|
|
39
|
-
|
|
40
|
-
echo "• Public repositories: $PUBLIC_COUNT"
|
|
41
|
-
echo "• Private repositories: $PRIVATE_COUNT"
|
|
42
|
-
echo "• Total: $((PUBLIC_COUNT + PRIVATE_COUNT))"
|
|
43
|
-
echo ""
|
|
44
|
-
|
|
45
|
-
echo "🔒 Private Repositories (first 5):"
|
|
46
|
-
echo "──────────────────────────────────"
|
|
47
|
-
|
|
48
|
-
# Extract private repo names
|
|
49
|
-
echo "$REPOS_HTML" | grep -B3 '>Private<' | grep 'itemprop="name codeRepository"' | head -5 | while read line; do
|
|
50
|
-
REPO_NAME=$(echo "$line" | sed -n 's/.*href="[^"]*\/\([^"]*\)".*/\1/p')
|
|
51
|
-
if [ -n "$REPO_NAME" ]; then
|
|
52
|
-
echo "• $REPO_NAME"
|
|
53
|
-
|
|
54
|
-
# Get repo details
|
|
55
|
-
REPO_PAGE=$(curl -s -L \
|
|
56
|
-
-H "Cookie: $COOKIE_HEADER" \
|
|
57
|
-
-H "User-Agent: Mozilla/5.0" \
|
|
58
|
-
"https://github.com/$USERNAME/$REPO_NAME")
|
|
59
|
-
|
|
60
|
-
# Extract language if available
|
|
61
|
-
LANGUAGE=$(echo "$REPO_PAGE" | grep -o 'programmingLanguage">[^<]*' | head -1 | cut -d'>' -f2)
|
|
62
|
-
[ -n "$LANGUAGE" ] && echo " Language: $LANGUAGE"
|
|
63
|
-
|
|
64
|
-
# Count files
|
|
65
|
-
FILE_COUNT=$(echo "$REPO_PAGE" | grep -o 'js-navigation-open Link--primary' | wc -l | xargs)
|
|
66
|
-
[ "$FILE_COUNT" -gt 0 ] && echo " Files/Folders visible: $FILE_COUNT"
|
|
67
|
-
fi
|
|
68
|
-
done
|
|
69
|
-
|
|
70
|
-
echo ""
|
|
71
|
-
echo "🔑 Testing Access Levels:"
|
|
72
|
-
echo "────────────────────────"
|
|
73
|
-
|
|
74
|
-
# Test various authenticated endpoints
|
|
75
|
-
test_access() {
|
|
76
|
-
local name=$1
|
|
77
|
-
local url=$2
|
|
78
|
-
echo -n "• $name: "
|
|
79
|
-
|
|
80
|
-
CODE=$(curl -s -o /dev/null -w "%{http_code}" \
|
|
81
|
-
-H "Cookie: $COOKIE_HEADER" \
|
|
82
|
-
-H "User-Agent: Mozilla/5.0" \
|
|
83
|
-
"$url")
|
|
84
|
-
|
|
85
|
-
if [ "$CODE" = "200" ]; then
|
|
86
|
-
echo "✅ Full access"
|
|
87
|
-
elif [ "$CODE" = "404" ]; then
|
|
88
|
-
echo "❌ Not found"
|
|
89
|
-
else
|
|
90
|
-
echo "⚠️ Limited access (HTTP $CODE)"
|
|
91
|
-
fi
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
test_access "Settings" "https://github.com/settings/profile"
|
|
95
|
-
test_access "SSH Keys" "https://github.com/settings/keys"
|
|
96
|
-
test_access "Security" "https://github.com/settings/security"
|
|
97
|
-
test_access "Billing" "https://github.com/settings/billing"
|
|
98
|
-
test_access "New Repository" "https://github.com/new"
|
|
99
|
-
|
|
100
|
-
echo ""
|
|
101
|
-
echo "💡 Practical Examples:"
|
|
102
|
-
echo "────────────────────"
|
|
103
|
-
echo ""
|
|
104
|
-
echo "# Clone a private repository (using gh CLI):"
|
|
105
|
-
echo "gh repo clone $USERNAME/<private-repo-name>"
|
|
106
|
-
echo ""
|
|
107
|
-
echo "# Download a file from a private repo:"
|
|
108
|
-
echo "curl -H \"Cookie: user_session=\$SESSION; __Host-user_session_same_site=\$SESSION\" \\"
|
|
109
|
-
echo " https://github.com/$USERNAME/<private-repo>/raw/main/file.txt"
|
|
110
|
-
echo ""
|
|
111
|
-
echo "# Access private gist:"
|
|
112
|
-
echo "curl -H \"Cookie: user_session=\$SESSION; __Host-user_session_same_site=\$SESSION\" \\"
|
|
113
|
-
echo " https://gist.github.com/$USERNAME/<gist-id>"
|
|
114
|
-
echo ""
|
|
115
|
-
echo "⚠️ Note: While we can VIEW private repos via the web interface,"
|
|
116
|
-
echo " cloning still requires proper Git authentication (SSH key or token)."
|
|
117
|
-
echo ""
|
|
118
|
-
echo "✅ Authentication successful! You have full web access to your private repos."
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Demonstration of the --list-profiles feature
|
|
4
|
-
echo "🍪 Profile Listing Feature Demo"
|
|
5
|
-
echo "==============================="
|
|
6
|
-
echo ""
|
|
7
|
-
|
|
8
|
-
echo "The new --list-profiles option helps you discover available browser profiles"
|
|
9
|
-
echo "before using them with the --profile option."
|
|
10
|
-
echo ""
|
|
11
|
-
|
|
12
|
-
# Basic usage
|
|
13
|
-
echo "📋 Basic Usage:"
|
|
14
|
-
echo "─────────────"
|
|
15
|
-
echo "$ get-cookie --browser chrome --list-profiles"
|
|
16
|
-
echo ""
|
|
17
|
-
get-cookie --browser chrome --list-profiles
|
|
18
|
-
echo ""
|
|
19
|
-
|
|
20
|
-
# Show how it integrates with profile selection
|
|
21
|
-
echo "🔗 Integration with Profile Selection:"
|
|
22
|
-
echo "────────────────────────────────────"
|
|
23
|
-
echo ""
|
|
24
|
-
echo "Step 1: List available profiles"
|
|
25
|
-
echo "$ get-cookie --browser chrome --list-profiles"
|
|
26
|
-
echo ""
|
|
27
|
-
echo "Step 2: Use a specific profile name from the list"
|
|
28
|
-
echo "$ get-cookie --url https://github.com --browser chrome --profile \"plugg.in\" --render"
|
|
29
|
-
echo ""
|
|
30
|
-
|
|
31
|
-
# Demonstrate actual usage
|
|
32
|
-
echo "Example: Getting cookies from a specific profile"
|
|
33
|
-
echo ""
|
|
34
|
-
PROFILE_NAME="plugg.in"
|
|
35
|
-
if get-cookie --browser chrome --list-profiles 2>/dev/null | grep -q "$PROFILE_NAME"; then
|
|
36
|
-
echo "✓ Profile '$PROFILE_NAME' found"
|
|
37
|
-
echo ""
|
|
38
|
-
echo "Getting GitHub session from '$PROFILE_NAME' profile:"
|
|
39
|
-
SESSION=$(get-cookie user_session github.com --browser chrome --profile "$PROFILE_NAME" --render 2>/dev/null)
|
|
40
|
-
if [ -n "$SESSION" ]; then
|
|
41
|
-
VALUE=$(echo "$SESSION" | cut -d'=' -f2)
|
|
42
|
-
echo " user_session=${VALUE:0:20}... (${#VALUE} chars)"
|
|
43
|
-
else
|
|
44
|
-
echo " No session cookie found"
|
|
45
|
-
fi
|
|
46
|
-
else
|
|
47
|
-
echo "Profile '$PROFILE_NAME' not found"
|
|
48
|
-
fi
|
|
49
|
-
echo ""
|
|
50
|
-
|
|
51
|
-
# Show error handling
|
|
52
|
-
echo "⚠️ Error Handling:"
|
|
53
|
-
echo "────────────────"
|
|
54
|
-
echo ""
|
|
55
|
-
echo "Without --browser flag:"
|
|
56
|
-
echo "$ get-cookie --list-profiles"
|
|
57
|
-
get-cookie --list-profiles 2>&1 | head -2
|
|
58
|
-
echo ""
|
|
59
|
-
|
|
60
|
-
echo "With unsupported browser:"
|
|
61
|
-
echo "$ get-cookie --browser safari --list-profiles"
|
|
62
|
-
get-cookie --browser safari --list-profiles 2>&1
|
|
63
|
-
echo ""
|
|
64
|
-
|
|
65
|
-
# Show all supported browsers
|
|
66
|
-
echo "🌐 Supported Browsers:"
|
|
67
|
-
echo "───────────────────"
|
|
68
|
-
echo ""
|
|
69
|
-
echo "Chromium-based browsers with profile support:"
|
|
70
|
-
echo " • chrome - Google Chrome"
|
|
71
|
-
echo " • edge - Microsoft Edge"
|
|
72
|
-
echo " • arc - Arc Browser"
|
|
73
|
-
echo " • opera - Opera"
|
|
74
|
-
echo " • opera-gx - Opera GX"
|
|
75
|
-
echo ""
|
|
76
|
-
echo "Other browsers:"
|
|
77
|
-
echo " • firefox - Profile listing coming soon"
|
|
78
|
-
echo " • safari - No profile support (uses system keychain)"
|
|
79
|
-
echo ""
|
|
80
|
-
|
|
81
|
-
# Practical workflow
|
|
82
|
-
echo "💼 Practical Workflow:"
|
|
83
|
-
echo "───────────────────"
|
|
84
|
-
echo ""
|
|
85
|
-
cat << 'EOF'
|
|
86
|
-
# 1. Check which profiles are available
|
|
87
|
-
get-cookie --browser chrome --list-profiles
|
|
88
|
-
|
|
89
|
-
# 2. Choose the profile with the right session
|
|
90
|
-
# (e.g., "Work" for company repos, "Personal" for personal)
|
|
91
|
-
|
|
92
|
-
# 3. Extract cookies from that specific profile
|
|
93
|
-
COOKIES=$(get-cookie --url https://github.com \
|
|
94
|
-
--browser chrome \
|
|
95
|
-
--profile "Work" \
|
|
96
|
-
--render)
|
|
97
|
-
|
|
98
|
-
# 4. Use with curl for authenticated requests
|
|
99
|
-
curl -H "Cookie: $COOKIES" https://github.com/company/private-repo
|
|
100
|
-
EOF
|
|
101
|
-
echo ""
|
|
102
|
-
|
|
103
|
-
# Show JSON output option
|
|
104
|
-
echo "📊 JSON Output Option:"
|
|
105
|
-
echo "──────────────────"
|
|
106
|
-
echo ""
|
|
107
|
-
echo "For scripting, combine with JSON output:"
|
|
108
|
-
echo '$ get-cookie --url https://example.com --browser chrome --profile "Work" --output json | jq ...'
|
|
109
|
-
echo ""
|
|
110
|
-
|
|
111
|
-
# Summary
|
|
112
|
-
echo "✨ Summary:"
|
|
113
|
-
echo "─────────"
|
|
114
|
-
echo "• Use --list-profiles to discover available profiles"
|
|
115
|
-
echo "• Profile names are shown with their directory mappings"
|
|
116
|
-
echo "• User email is displayed when available"
|
|
117
|
-
echo "• Works with all Chromium-based browsers"
|
|
118
|
-
echo "• Essential for managing multiple logged-in sessions"
|
|
119
|
-
echo ""
|
|
120
|
-
echo "✅ The --list-profiles feature makes profile selection easy and discoverable!"
|