@mherod/get-cookie 4.4.0 โ 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 -1
- package/.husky/pre-commit +10 -1
- 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 +31 -174
- package/dist/index.d.ts +31 -174
- 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 +62 -68
- 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
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mherod/get-cookie",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.2",
|
|
4
4
|
"description": "Node.js module for querying cookies from Chrome, Firefox, and Safari browsers",
|
|
5
|
-
"packageManager": "pnpm@9.15.2",
|
|
6
5
|
"type": "module",
|
|
7
6
|
"source": "src/index.ts",
|
|
8
7
|
"bin": {
|
|
@@ -25,101 +24,65 @@
|
|
|
25
24
|
"publishConfig": {
|
|
26
25
|
"access": "public"
|
|
27
26
|
},
|
|
28
|
-
"scripts": {
|
|
29
|
-
"clean": "rm -rf dist",
|
|
30
|
-
"build:lib": "tsup --config tsup.lib.ts",
|
|
31
|
-
"build:cli": "tsup --config tsup.cli.ts",
|
|
32
|
-
"build": "pnpm run build:lib && pnpm run build:cli",
|
|
33
|
-
"test": "jest",
|
|
34
|
-
"type-check": "tsc --noEmit --skipLibCheck",
|
|
35
|
-
"lint": "biome check --diagnostic-level=error .",
|
|
36
|
-
"lint:eslint": "eslint --config eslint.config.js \"src/**/*.{ts,js}\"",
|
|
37
|
-
"lint:all": "pnpm run lint && pnpm run lint:eslint",
|
|
38
|
-
"lint:fix": "biome check --write --unsafe . && eslint --config eslint.config.js --fix \"src/**/*.{ts,js}\"",
|
|
39
|
-
"lint:staged": "biome check --staged --write .",
|
|
40
|
-
"format": "biome format --write .",
|
|
41
|
-
"format:check": "biome check --diagnostic-level=error .",
|
|
42
|
-
"validate": "pnpm run type-check && pnpm run lint && pnpm run test && pnpm run check-links && pnpm run format:check",
|
|
43
|
-
"prepack": "pnpm run validate",
|
|
44
|
-
"prepublishOnly": "pnpm run clean && pnpm run validate && pnpm run build",
|
|
45
|
-
"dev": "tsc -w -p tsconfig.json & tsc-alias -w -p tsconfig.json",
|
|
46
|
-
"read-github": "NODE_OPTIONS=\"-r tsconfig-paths/register\" tsx scripts/read-github-cookies.ts",
|
|
47
|
-
"prepare": "husky install",
|
|
48
|
-
"docs": "typedoc && ./scripts/fix-typedoc.sh && vitepress build docs",
|
|
49
|
-
"docs:dev": "vitepress dev docs",
|
|
50
|
-
"docs:preview": "vitepress preview docs",
|
|
51
|
-
"check-links": "./scripts/check-vitepress-links.sh",
|
|
52
|
-
"deps": "madge --ts-config ./tsconfig.json src/index.ts",
|
|
53
|
-
"deps:circular": "madge --circular --ts-config ./tsconfig.json src/",
|
|
54
|
-
"deps:orphans": "madge --orphans --ts-config ./tsconfig.json src/",
|
|
55
|
-
"deps:text": "depcruise src --include-only \"^src\" --output-type text",
|
|
56
|
-
"deps:html": "depcruise src --include-only \"^src\" --output-type html --output-to dependency-report.html",
|
|
57
|
-
"deps:validate": "depcruise src --config .dependency-cruiser.js"
|
|
58
|
-
},
|
|
59
27
|
"engines": {
|
|
60
|
-
"node": "^20.0.0 || ^22.0.0 || ^24.0.0"
|
|
28
|
+
"node": "^20.0.0 || ^22.0.0 || ^24.0.0 || ^25.0.0"
|
|
61
29
|
},
|
|
62
30
|
"keywords": [],
|
|
63
31
|
"author": "Matthew Herod",
|
|
64
32
|
"license": "ISC",
|
|
65
33
|
"dependencies": {
|
|
66
|
-
"better-sqlite3": "^12.
|
|
34
|
+
"better-sqlite3": "^12.4.1",
|
|
67
35
|
"consola": "^3.4.2",
|
|
68
36
|
"date-fns": "4.1.0",
|
|
69
37
|
"destr": "^2.0.5",
|
|
70
|
-
"dotenv": "
|
|
38
|
+
"dotenv": "17.2.3",
|
|
71
39
|
"fast-glob": "^3.3.3",
|
|
72
|
-
"jsonwebtoken": "^9.0.
|
|
73
|
-
"lodash-es": "^4.17.
|
|
40
|
+
"jsonwebtoken": "^9.0.3",
|
|
41
|
+
"lodash-es": "^4.17.23",
|
|
74
42
|
"minimist": "^1.2.8",
|
|
75
43
|
"tsconfig-paths": "^4.2.0",
|
|
76
|
-
"zod": "^
|
|
44
|
+
"zod": "^4.1.11"
|
|
77
45
|
},
|
|
78
46
|
"optionalDependencies": {
|
|
79
47
|
"@primno/dpapi": "^2.0.1"
|
|
80
48
|
},
|
|
81
49
|
"devDependencies": {
|
|
82
|
-
"@biomejs/biome": "2.
|
|
83
|
-
"@commitlint/cli": "
|
|
84
|
-
"@commitlint/config-conventional": "
|
|
85
|
-
"@jest/globals": "^30.
|
|
50
|
+
"@biomejs/biome": "2.3.8",
|
|
51
|
+
"@commitlint/cli": "20.1.0",
|
|
52
|
+
"@commitlint/config-conventional": "20.0.0",
|
|
53
|
+
"@jest/globals": "^30.1.2",
|
|
86
54
|
"@types/better-sqlite3": "^7.6.13",
|
|
87
|
-
"@types/jest": "^
|
|
55
|
+
"@types/jest": "^30.0.0",
|
|
88
56
|
"@types/jsonwebtoken": "^9.0.10",
|
|
89
|
-
"@types/lodash": "^4.17.
|
|
57
|
+
"@types/lodash": "^4.17.20",
|
|
90
58
|
"@types/lodash-es": "4.17.12",
|
|
91
59
|
"@types/minimist": "^1.2.5",
|
|
92
|
-
"@types/node": "^24.
|
|
93
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
94
|
-
"@typescript-eslint/parser": "^8.
|
|
95
|
-
"dependency-cruiser": "17.
|
|
96
|
-
"eslint": "^9.
|
|
60
|
+
"@types/node": "^24.5.2",
|
|
61
|
+
"@typescript-eslint/eslint-plugin": "^8.44.1",
|
|
62
|
+
"@typescript-eslint/parser": "^8.44.1",
|
|
63
|
+
"dependency-cruiser": "17.3.2",
|
|
64
|
+
"eslint": "^9.36.0",
|
|
97
65
|
"eslint-formatter-codeframe": "^7.32.1",
|
|
98
66
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
99
|
-
"eslint-plugin-import": "^2.
|
|
100
|
-
"eslint-plugin-jsdoc": "^
|
|
101
|
-
"globals": "16.
|
|
67
|
+
"eslint-plugin-import": "^2.32.0",
|
|
68
|
+
"eslint-plugin-jsdoc": "^61.2.1",
|
|
69
|
+
"globals": "16.5.0",
|
|
102
70
|
"husky": "^9.1.7",
|
|
103
|
-
"jest": "^
|
|
104
|
-
"lint-staged": "^
|
|
71
|
+
"jest": "^30.1.3",
|
|
72
|
+
"lint-staged": "^16.2.1",
|
|
105
73
|
"lodash": "4.17.21",
|
|
106
74
|
"madge": "8.0.0",
|
|
107
|
-
"pnpm": "10.
|
|
75
|
+
"pnpm": "10.24.0",
|
|
108
76
|
"prettier": "^3.6.2",
|
|
109
|
-
"ts-jest": "^29.4.
|
|
77
|
+
"ts-jest": "^29.4.4",
|
|
110
78
|
"ts-node": "^10.9.2",
|
|
111
79
|
"tsc-alias": "^1.8.16",
|
|
112
80
|
"tsup": "^8.5.0",
|
|
113
|
-
"tsx": "4.
|
|
114
|
-
"typedoc": "^0.28.
|
|
115
|
-
"typedoc-plugin-markdown": "^4.
|
|
116
|
-
"typescript": "^5.
|
|
117
|
-
"vitepress": "^1.6.
|
|
118
|
-
},
|
|
119
|
-
"pnpm": {
|
|
120
|
-
"overrides": {
|
|
121
|
-
"esbuild": "^0.25.0"
|
|
122
|
-
}
|
|
81
|
+
"tsx": "4.21.0",
|
|
82
|
+
"typedoc": "^0.28.13",
|
|
83
|
+
"typedoc-plugin-markdown": "^4.9.0",
|
|
84
|
+
"typescript": "^5.9.2",
|
|
85
|
+
"vitepress": "^1.6.4"
|
|
123
86
|
},
|
|
124
87
|
"lint-staged": {
|
|
125
88
|
"*.{js,ts}": [
|
|
@@ -132,5 +95,36 @@
|
|
|
132
95
|
"biome format --write --no-errors-on-unmatched",
|
|
133
96
|
"./scripts/check-vitepress-links.sh"
|
|
134
97
|
]
|
|
98
|
+
},
|
|
99
|
+
"scripts": {
|
|
100
|
+
"clean": "rm -rf dist",
|
|
101
|
+
"build:lib": "tsup --config tsup.lib.ts",
|
|
102
|
+
"build:cli": "tsup --config tsup.cli.ts",
|
|
103
|
+
"build": "pnpm run build:lib && pnpm run build:cli",
|
|
104
|
+
"test": "jest",
|
|
105
|
+
"type-check": "tsc --noEmit --skipLibCheck",
|
|
106
|
+
"lint": "biome check --diagnostic-level=error .",
|
|
107
|
+
"lint:eslint": "eslint --config eslint.config.js \"src/**/*.{ts,js}\"",
|
|
108
|
+
"lint:all": "pnpm run lint && pnpm run lint:eslint",
|
|
109
|
+
"lint:fix": "biome check --write --unsafe . && eslint --config eslint.config.js --fix \"src/**/*.{ts,js}\"",
|
|
110
|
+
"lint:staged": "biome check --staged --write .",
|
|
111
|
+
"format": "biome format --write .",
|
|
112
|
+
"format:check": "biome check --diagnostic-level=error .",
|
|
113
|
+
"validate": "pnpm run type-check && pnpm run lint && pnpm run test && pnpm run check-links && pnpm run format:check",
|
|
114
|
+
"audit": "pnpm audit --audit-level moderate",
|
|
115
|
+
"audit:fix": "pnpm audit --fix",
|
|
116
|
+
"outdated": "pnpm outdated",
|
|
117
|
+
"dev": "tsc -w -p tsconfig.json & tsc-alias -w -p tsconfig.json",
|
|
118
|
+
"read-github": "NODE_OPTIONS=\"-r tsconfig-paths/register\" tsx scripts/read-github-cookies.ts",
|
|
119
|
+
"docs": "typedoc && ./scripts/fix-typedoc.sh && vitepress build docs",
|
|
120
|
+
"docs:dev": "vitepress dev docs",
|
|
121
|
+
"docs:preview": "vitepress preview docs",
|
|
122
|
+
"check-links": "./scripts/check-vitepress-links.sh",
|
|
123
|
+
"deps": "madge --ts-config ./tsconfig.json src/index.ts",
|
|
124
|
+
"deps:circular": "madge --circular --ts-config ./tsconfig.json src/",
|
|
125
|
+
"deps:orphans": "madge --orphans --ts-config ./tsconfig.json src/",
|
|
126
|
+
"deps:text": "depcruise src --include-only \"^src\" --output-type text",
|
|
127
|
+
"deps:html": "depcruise src --include-only \"^src\" --output-type html --output-to dependency-report.html",
|
|
128
|
+
"deps:validate": "depcruise src --config .dependency-cruiser.js"
|
|
135
129
|
}
|
|
136
|
-
}
|
|
130
|
+
}
|
package/tsup.cli.ts
CHANGED
package/tsup.lib.ts
CHANGED
|
@@ -26,7 +26,15 @@ export default defineConfig({
|
|
|
26
26
|
platform: "node",
|
|
27
27
|
bundle: true,
|
|
28
28
|
tsconfig: "./tsconfig.tsup.json",
|
|
29
|
-
external: [
|
|
29
|
+
external: [
|
|
30
|
+
"fs",
|
|
31
|
+
"path",
|
|
32
|
+
"crypto",
|
|
33
|
+
"os",
|
|
34
|
+
"child_process",
|
|
35
|
+
"lodash-es",
|
|
36
|
+
"bun:sqlite",
|
|
37
|
+
],
|
|
30
38
|
treeshake: true,
|
|
31
39
|
splitting: false,
|
|
32
40
|
skipNodeModulesBundle: true,
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Chrome-specific cookie extraction demo
|
|
4
|
-
echo "๐ช Chrome Cookie Extraction with get-cookie"
|
|
5
|
-
echo "==========================================="
|
|
6
|
-
echo ""
|
|
7
|
-
|
|
8
|
-
# Basic Chrome cookie extraction
|
|
9
|
-
echo "1๏ธโฃ Basic Chrome cookie extraction:"
|
|
10
|
-
echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
|
|
11
|
-
echo "Command: get-cookie --url https://github.com --browser chrome --render"
|
|
12
|
-
echo ""
|
|
13
|
-
COOKIES=$(get-cookie --url https://github.com --browser chrome --render 2>/dev/null | head -c 100)
|
|
14
|
-
echo "Output (truncated): $COOKIES..."
|
|
15
|
-
echo ""
|
|
16
|
-
|
|
17
|
-
# JSON output for debugging
|
|
18
|
-
echo "2๏ธโฃ Chrome cookies in JSON format:"
|
|
19
|
-
echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
|
|
20
|
-
echo "Command: get-cookie --url https://github.com --browser chrome --output json"
|
|
21
|
-
echo ""
|
|
22
|
-
get-cookie --url https://github.com --browser chrome --output json 2>/dev/null | jq '.[:2]'
|
|
23
|
-
echo ""
|
|
24
|
-
|
|
25
|
-
# Filtering duplicates
|
|
26
|
-
echo "3๏ธโฃ Handling duplicate cookies:"
|
|
27
|
-
echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
|
|
28
|
-
echo "Chrome may have duplicate cookies from different profiles."
|
|
29
|
-
echo ""
|
|
30
|
-
echo "Session cookies found:"
|
|
31
|
-
get-cookie --url https://github.com --browser chrome --output json 2>/dev/null | \
|
|
32
|
-
jq -r '.[] | select(.name == "user_session") | " โข \(.value[0:20])... (\(.value | length) chars)"'
|
|
33
|
-
echo ""
|
|
34
|
-
|
|
35
|
-
# Smart filtering
|
|
36
|
-
echo "4๏ธโฃ Smart cookie filtering (recommended):"
|
|
37
|
-
echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
|
|
38
|
-
echo "Filter to get the longest (most likely valid) cookie value:"
|
|
39
|
-
echo ""
|
|
40
|
-
cat << 'EOF'
|
|
41
|
-
VALID_SESSION=$(get-cookie --url https://github.com --browser chrome --output json | \
|
|
42
|
-
jq -r '.[] | select(.name == "user_session" and (.value | length) > 20) | .value' | \
|
|
43
|
-
head -1)
|
|
44
|
-
EOF
|
|
45
|
-
echo ""
|
|
46
|
-
|
|
47
|
-
# Using with curl
|
|
48
|
-
echo "5๏ธโฃ Using Chrome cookies with curl:"
|
|
49
|
-
echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
|
|
50
|
-
echo "Simple approach (may fail with duplicates):"
|
|
51
|
-
echo 'curl -H "Cookie: $(get-cookie --url <URL> --browser chrome --render)" <URL>'
|
|
52
|
-
echo ""
|
|
53
|
-
echo "Robust approach (with filtering):"
|
|
54
|
-
cat << 'EOF'
|
|
55
|
-
# Get deduplicated cookies (longest value wins)
|
|
56
|
-
COOKIES=$(get-cookie --url <URL> --browser chrome --output json | \
|
|
57
|
-
jq -r 'group_by(.name) | map(max_by(.value | length)) |
|
|
58
|
-
.[] | "\(.name)=\(.value)"' | tr '\n' ';')
|
|
59
|
-
|
|
60
|
-
curl -H "Cookie: $COOKIES" <URL>
|
|
61
|
-
EOF
|
|
62
|
-
echo ""
|
|
63
|
-
|
|
64
|
-
# Testing authentication
|
|
65
|
-
echo "6๏ธโฃ Testing GitHub authentication with Chrome cookies:"
|
|
66
|
-
echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
|
|
67
|
-
COOKIES=$(get-cookie --url https://github.com --browser chrome --output json 2>/dev/null | \
|
|
68
|
-
jq -r 'group_by(.name) | map(max_by(.value | length)) | .[] | "\(.name)=\(.value)"' | tr '\n' ';')
|
|
69
|
-
|
|
70
|
-
echo -n "Testing with deduplicated cookies: "
|
|
71
|
-
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
|
|
72
|
-
-H "Cookie: $COOKIES" \
|
|
73
|
-
-H "User-Agent: Mozilla/5.0" \
|
|
74
|
-
"https://github.com/settings/profile")
|
|
75
|
-
|
|
76
|
-
if [ "$HTTP_CODE" = "200" ]; then
|
|
77
|
-
echo "โ
Success (HTTP 200)"
|
|
78
|
-
elif [ "$HTTP_CODE" = "302" ]; then
|
|
79
|
-
echo "โ Redirected to login (HTTP 302)"
|
|
80
|
-
else
|
|
81
|
-
echo "โ ๏ธ HTTP $HTTP_CODE"
|
|
82
|
-
fi
|
|
83
|
-
echo ""
|
|
84
|
-
|
|
85
|
-
# Check cookie counts
|
|
86
|
-
echo "7๏ธโฃ Cookie statistics:"
|
|
87
|
-
echo "โโโโโโโโโโโโโโโโโโ"
|
|
88
|
-
TOTAL=$(get-cookie --url https://github.com --browser chrome --output json 2>/dev/null | jq 'length')
|
|
89
|
-
UNIQUE=$(get-cookie --url https://github.com --browser chrome --output json 2>/dev/null | jq '[.[] | .name] | unique | length')
|
|
90
|
-
echo "โข Total cookies: $TOTAL"
|
|
91
|
-
echo "โข Unique cookie names: $UNIQUE"
|
|
92
|
-
echo "โข Duplicates: $((TOTAL - UNIQUE))"
|
|
93
|
-
echo ""
|
|
94
|
-
|
|
95
|
-
# Expired cookie filtering
|
|
96
|
-
echo "8๏ธโฃ Expired cookie filtering:"
|
|
97
|
-
echo "โโโโโโโโโโโโโโโโโโโโโโโโโโ"
|
|
98
|
-
WITHOUT=$(get-cookie --url https://github.com --browser chrome --output json 2>/dev/null | jq 'length')
|
|
99
|
-
WITH=$(get-cookie --url https://github.com --browser chrome --output json --include-expired 2>/dev/null | jq 'length')
|
|
100
|
-
echo "โข Without --include-expired: $WITHOUT cookies"
|
|
101
|
-
echo "โข With --include-expired: $WITH cookies"
|
|
102
|
-
if [ "$WITH" -gt "$WITHOUT" ]; then
|
|
103
|
-
echo "โข โ
Filtered out $((WITH - WITHOUT)) expired cookies"
|
|
104
|
-
else
|
|
105
|
-
echo "โข โน๏ธ No expired cookies found"
|
|
106
|
-
fi
|
|
107
|
-
echo ""
|
|
108
|
-
|
|
109
|
-
echo "๐ก Key Insights:"
|
|
110
|
-
echo "โโโโโโโโโโโโโโ"
|
|
111
|
-
echo "โข Chrome may store duplicate cookies from different profiles"
|
|
112
|
-
echo "โข The --render flag outputs all cookies, including duplicates"
|
|
113
|
-
echo "โข For authentication, deduplicate by taking the longest value"
|
|
114
|
-
echo "โข Expired cookies are filtered by default (use --include-expired to see all)"
|
|
115
|
-
echo "โข Use JSON output + jq for precise cookie control"
|
|
116
|
-
echo ""
|
|
117
|
-
echo "โ
Chrome cookie extraction complete!"
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Chrome Profile Selection Demo
|
|
4
|
-
echo "๐ช Chrome Profile Selection with get-cookie"
|
|
5
|
-
echo "==========================================="
|
|
6
|
-
echo ""
|
|
7
|
-
echo "The new --profile option allows targeting specific Chrome profiles by name."
|
|
8
|
-
echo ""
|
|
9
|
-
|
|
10
|
-
# List available Chrome profiles
|
|
11
|
-
echo "๐ Available Chrome Profiles:"
|
|
12
|
-
echo "โโโโโโโโโโโโโโโโโโโโโโโโโโ"
|
|
13
|
-
if [ -f ~/Library/Application\ Support/Google/Chrome/Local\ State ]; then
|
|
14
|
-
cat ~/Library/Application\ Support/Google/Chrome/Local\ State | \
|
|
15
|
-
jq -r '.profile.info_cache | to_entries | .[] | " โข \(.value.name) (directory: \(.key))"'
|
|
16
|
-
else
|
|
17
|
-
echo " Chrome Local State file not found"
|
|
18
|
-
fi
|
|
19
|
-
echo ""
|
|
20
|
-
|
|
21
|
-
# Demonstrate profile-specific extraction
|
|
22
|
-
echo "๐ฏ Profile-Specific Cookie Extraction:"
|
|
23
|
-
echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
|
|
24
|
-
echo ""
|
|
25
|
-
|
|
26
|
-
echo "1๏ธโฃ Extract from a specific profile by name:"
|
|
27
|
-
echo " Command: get-cookie --url https://github.com --browser chrome --profile \"plugg.in\" --render"
|
|
28
|
-
echo ""
|
|
29
|
-
COOKIES=$(get-cookie --url https://github.com --browser chrome --profile "plugg.in" --render 2>/dev/null | head -c 80)
|
|
30
|
-
echo " Output: $COOKIES..."
|
|
31
|
-
echo ""
|
|
32
|
-
|
|
33
|
-
echo "2๏ธโฃ Compare different profiles for the same cookie:"
|
|
34
|
-
echo ""
|
|
35
|
-
echo " Default/Personal profile:"
|
|
36
|
-
echo " $ get-cookie user_session github.com --browser chrome --profile \"Personal\" --render"
|
|
37
|
-
PERSONAL=$(get-cookie user_session github.com --browser chrome --profile "Personal" --render 2>/dev/null)
|
|
38
|
-
if [ -n "$PERSONAL" ]; then
|
|
39
|
-
VALUE=$(echo "$PERSONAL" | cut -d'=' -f2)
|
|
40
|
-
echo " Result: user_session=${VALUE:0:20}... (${#VALUE} chars)"
|
|
41
|
-
else
|
|
42
|
-
echo " Result: No user_session cookie found"
|
|
43
|
-
fi
|
|
44
|
-
echo ""
|
|
45
|
-
|
|
46
|
-
echo " Profile 9/plugg.in profile:"
|
|
47
|
-
echo " $ get-cookie user_session github.com --browser chrome --profile \"plugg.in\" --render"
|
|
48
|
-
PLUGIN=$(get-cookie user_session github.com --browser chrome --profile "plugg.in" --render 2>/dev/null)
|
|
49
|
-
if [ -n "$PLUGIN" ]; then
|
|
50
|
-
VALUE=$(echo "$PLUGIN" | cut -d'=' -f2)
|
|
51
|
-
echo " Result: user_session=${VALUE:0:20}... (${#VALUE} chars)"
|
|
52
|
-
else
|
|
53
|
-
echo " Result: No user_session cookie found"
|
|
54
|
-
fi
|
|
55
|
-
echo ""
|
|
56
|
-
|
|
57
|
-
# Show the benefit
|
|
58
|
-
echo "๐ก Benefits of Profile Selection:"
|
|
59
|
-
echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
|
|
60
|
-
echo "โข Avoid cookie conflicts between profiles"
|
|
61
|
-
echo "โข Target the correct logged-in session"
|
|
62
|
-
echo "โข No need for deduplication when using specific profile"
|
|
63
|
-
echo "โข Faster queries (only searches one profile)"
|
|
64
|
-
echo ""
|
|
65
|
-
|
|
66
|
-
# Practical curl example
|
|
67
|
-
echo "๐ง Practical Example with curl:"
|
|
68
|
-
echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"
|
|
69
|
-
echo ""
|
|
70
|
-
echo "Use the correct profile for authenticated requests:"
|
|
71
|
-
echo ""
|
|
72
|
-
cat << 'EOF'
|
|
73
|
-
# Get cookies from your work profile
|
|
74
|
-
COOKIES=$(get-cookie --url https://github.com --browser chrome --profile "Work" --render)
|
|
75
|
-
curl -H "Cookie: $COOKIES" https://github.com/settings/profile
|
|
76
|
-
|
|
77
|
-
# Get cookies from your personal profile
|
|
78
|
-
COOKIES=$(get-cookie --url https://github.com --browser chrome --profile "Personal" --render)
|
|
79
|
-
curl -H "Cookie: $COOKIES" https://github.com/settings/profile
|
|
80
|
-
EOF
|
|
81
|
-
echo ""
|
|
82
|
-
|
|
83
|
-
# Test with curl
|
|
84
|
-
echo "๐งช Live Test with GitHub:"
|
|
85
|
-
echo "โโโโโโโโโโโโโโโโโโโโโโ"
|
|
86
|
-
echo ""
|
|
87
|
-
|
|
88
|
-
test_profile() {
|
|
89
|
-
local profile=$1
|
|
90
|
-
echo -n "Testing profile '$profile': "
|
|
91
|
-
|
|
92
|
-
COOKIES=$(get-cookie --url https://github.com/settings/profile --browser chrome --profile "$profile" --render 2>/dev/null)
|
|
93
|
-
|
|
94
|
-
if [ -z "$COOKIES" ]; then
|
|
95
|
-
echo "โ No cookies found"
|
|
96
|
-
return
|
|
97
|
-
fi
|
|
98
|
-
|
|
99
|
-
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
|
|
100
|
-
-H "Cookie: $COOKIES" \
|
|
101
|
-
-H "User-Agent: Mozilla/5.0" \
|
|
102
|
-
"https://github.com/settings/profile")
|
|
103
|
-
|
|
104
|
-
if [ "$HTTP_CODE" = "200" ]; then
|
|
105
|
-
echo "โ
Authenticated (HTTP 200)"
|
|
106
|
-
elif [ "$HTTP_CODE" = "302" ]; then
|
|
107
|
-
echo "๐ Redirected to login (HTTP 302)"
|
|
108
|
-
else
|
|
109
|
-
echo "โ ๏ธ HTTP $HTTP_CODE"
|
|
110
|
-
fi
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
# Test each profile that might have GitHub cookies
|
|
114
|
-
test_profile "Personal"
|
|
115
|
-
test_profile "plugg.in"
|
|
116
|
-
echo ""
|
|
117
|
-
|
|
118
|
-
echo "๐ Usage Notes:"
|
|
119
|
-
echo "โโโโโโโโโโโโ"
|
|
120
|
-
echo "โข Profile names are case-insensitive"
|
|
121
|
-
echo "โข You can use either the display name (e.g., \"Personal\") or directory name (e.g., \"Default\")"
|
|
122
|
-
echo "โข If no --profile is specified, all profiles are queried"
|
|
123
|
-
echo "โข Combine with --include-all to see cookies from all profiles even when one is selected"
|
|
124
|
-
echo ""
|
|
125
|
-
|
|
126
|
-
echo "โ
Profile selection feature is working perfectly!"
|
package/examples/curl-demo.sh
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Simple demonstration of get-cookie + curl integration
|
|
4
|
-
echo "๐ช get-cookie + curl Integration Demo"
|
|
5
|
-
echo "======================================"
|
|
6
|
-
|
|
7
|
-
# First, let's verify we have cookies
|
|
8
|
-
echo -e "\n1๏ธโฃ Checking available cookies..."
|
|
9
|
-
COOKIE_COUNT=$(get-cookie % github.com --output json 2>/dev/null | jq 'length')
|
|
10
|
-
echo " Found $COOKIE_COUNT GitHub cookies"
|
|
11
|
-
|
|
12
|
-
# Extract a specific cookie value
|
|
13
|
-
echo -e "\n2๏ธโฃ Extracting user_session cookie..."
|
|
14
|
-
USER_SESSION=$(get-cookie user_session github.com --output json 2>/dev/null | jq -r '.[0].value' 2>/dev/null)
|
|
15
|
-
|
|
16
|
-
if [ -n "$USER_SESSION" ] && [ "$USER_SESSION" != "null" ]; then
|
|
17
|
-
echo " โ
Got user_session cookie"
|
|
18
|
-
echo " Value: ${USER_SESSION:0:20}... (truncated for security)"
|
|
19
|
-
|
|
20
|
-
# Use the cookie with curl
|
|
21
|
-
echo -e "\n3๏ธโฃ Making authenticated GitHub API request..."
|
|
22
|
-
RESPONSE=$(curl -s \
|
|
23
|
-
-H "Cookie: user_session=$USER_SESSION" \
|
|
24
|
-
-H "User-Agent: get-cookie-demo" \
|
|
25
|
-
"https://api.github.com/user")
|
|
26
|
-
|
|
27
|
-
# Check if we got user data
|
|
28
|
-
LOGIN=$(echo "$RESPONSE" | jq -r '.login' 2>/dev/null)
|
|
29
|
-
if [ -n "$LOGIN" ] && [ "$LOGIN" != "null" ]; then
|
|
30
|
-
echo " โ
Authenticated as: @$LOGIN"
|
|
31
|
-
|
|
32
|
-
# Get more user info
|
|
33
|
-
NAME=$(echo "$RESPONSE" | jq -r '.name' 2>/dev/null)
|
|
34
|
-
COMPANY=$(echo "$RESPONSE" | jq -r '.company' 2>/dev/null)
|
|
35
|
-
PUBLIC_REPOS=$(echo "$RESPONSE" | jq -r '.public_repos' 2>/dev/null)
|
|
36
|
-
|
|
37
|
-
echo " Name: $NAME"
|
|
38
|
-
[ "$COMPANY" != "null" ] && echo " Company: $COMPANY"
|
|
39
|
-
echo " Public repos: $PUBLIC_REPOS"
|
|
40
|
-
else
|
|
41
|
-
echo " โ ๏ธ API did not return user data (cookie might not work for API)"
|
|
42
|
-
fi
|
|
43
|
-
else
|
|
44
|
-
echo " โ No user_session cookie found"
|
|
45
|
-
fi
|
|
46
|
-
|
|
47
|
-
# Example with multiple cookies
|
|
48
|
-
echo -e "\n4๏ธโฃ Building multi-cookie header..."
|
|
49
|
-
COOKIES=""
|
|
50
|
-
|
|
51
|
-
# Extract multiple cookies and combine them
|
|
52
|
-
for cookie_name in "user_session" "dotcom_user" "__Host-user_session_same_site"; do
|
|
53
|
-
COOKIE_VALUE=$(get-cookie "$cookie_name" github.com --output json 2>/dev/null | jq -r '.[0].value' 2>/dev/null)
|
|
54
|
-
if [ -n "$COOKIE_VALUE" ] && [ "$COOKIE_VALUE" != "null" ]; then
|
|
55
|
-
[ -n "$COOKIES" ] && COOKIES="$COOKIES; "
|
|
56
|
-
COOKIES="$COOKIES$cookie_name=$COOKIE_VALUE"
|
|
57
|
-
echo " โ
Added $cookie_name"
|
|
58
|
-
fi
|
|
59
|
-
done
|
|
60
|
-
|
|
61
|
-
if [ -n "$COOKIES" ]; then
|
|
62
|
-
echo -e "\n5๏ธโฃ Testing page access with cookies..."
|
|
63
|
-
# Test accessing a protected page
|
|
64
|
-
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
|
|
65
|
-
-H "Cookie: $COOKIES" \
|
|
66
|
-
-H "User-Agent: Mozilla/5.0" \
|
|
67
|
-
"https://github.com/settings/profile")
|
|
68
|
-
|
|
69
|
-
if [ "$HTTP_CODE" = "200" ]; then
|
|
70
|
-
echo " โ
Successfully accessed settings page (HTTP 200)"
|
|
71
|
-
elif [ "$HTTP_CODE" = "302" ] || [ "$HTTP_CODE" = "301" ]; then
|
|
72
|
-
echo " โ ๏ธ Redirected (HTTP $HTTP_CODE) - might need more cookies"
|
|
73
|
-
else
|
|
74
|
-
echo " โ Access failed (HTTP $HTTP_CODE)"
|
|
75
|
-
fi
|
|
76
|
-
fi
|
|
77
|
-
|
|
78
|
-
# Practical example: Download with authentication
|
|
79
|
-
echo -e "\n6๏ธโฃ Example: Downloading with authentication..."
|
|
80
|
-
echo " Command to download your GitHub avatar:"
|
|
81
|
-
if [ -n "$LOGIN" ]; then
|
|
82
|
-
echo " curl -H \"Cookie: user_session=\$COOKIE\" -o avatar.png https://github.com/$LOGIN.png"
|
|
83
|
-
else
|
|
84
|
-
echo " curl -H \"Cookie: user_session=\$COOKIE\" -o avatar.png https://github.com/USERNAME.png"
|
|
85
|
-
fi
|
|
86
|
-
|
|
87
|
-
# One-liner examples
|
|
88
|
-
echo -e "\n๐ Useful one-liners:"
|
|
89
|
-
echo "โโโโโโโโโโโโโโโโโโโโ"
|
|
90
|
-
echo "# Get cookie value only:"
|
|
91
|
-
echo "get-cookie user_session github.com --output json | jq -r '.[0].value'"
|
|
92
|
-
echo ""
|
|
93
|
-
echo "# Direct pipe to curl:"
|
|
94
|
-
echo "curl -H \"Cookie: user_session=\$(get-cookie user_session github.com --output json | jq -r '.[0].value')\" https://api.github.com/user"
|
|
95
|
-
echo ""
|
|
96
|
-
echo "# Save all cookies to file:"
|
|
97
|
-
echo "get-cookie % github.com --output json > github-cookies.json"
|
|
98
|
-
echo ""
|
|
99
|
-
echo "# Use with HTTPie instead of curl:"
|
|
100
|
-
echo "http https://api.github.com/user \"Cookie:user_session=\$(get-cookie user_session github.com --output json | jq -r '.[0].value')\""
|
|
101
|
-
|
|
102
|
-
echo -e "\nโ
Demo complete!"
|