@mherod/get-cookie 4.2.2 → 4.3.0
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/.claude/settings.local.json +11 -0
- package/.husky/commit-msg +14 -0
- package/.husky/pre-commit +14 -0
- package/.husky/pre-push +0 -0
- package/.idea/git_toolbox_prj.xml +15 -0
- package/.nvmrc +1 -0
- package/README.md +65 -83
- package/biome.json +94 -0
- package/dist/cli.cjs +2 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +269 -75
- package/dist/index.d.ts +269 -75
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eslint.config.js +1 -1
- package/examples/cli-examples.sh +0 -0
- package/jest.setup.js +24 -1
- package/package.json +57 -60
- package/test-exports/package.json +15 -0
- package/test-exports/test-esm.mjs +12 -0
- package/test-exports/test-runtime.js +14 -0
- package/test-exports/test-types.ts +61 -0
- package/tsup.lib.ts +1 -1
package/.husky/commit-msg
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
. "$(dirname "$0")/_/husky.sh"
|
|
3
|
+
|
|
4
|
+
# Load nvm and use the project's Node.js version
|
|
5
|
+
export NVM_DIR="$HOME/.nvm"
|
|
6
|
+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
|
7
|
+
|
|
8
|
+
# Use the version specified in .nvmrc or fallback to default nvm version
|
|
9
|
+
if [ -f .nvmrc ]; then
|
|
10
|
+
nvm use
|
|
11
|
+
else
|
|
12
|
+
nvm use default
|
|
13
|
+
fi
|
|
14
|
+
|
|
1
15
|
# Try pnpm first, fallback to npx if pnpm not found
|
|
2
16
|
if command -v pnpm >/dev/null 2>&1; then
|
|
3
17
|
pnpm exec commitlint --edit ${1}
|
package/.husky/pre-commit
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
. "$(dirname "$0")/_/husky.sh"
|
|
3
|
+
|
|
4
|
+
# Load nvm and use the project's Node.js version
|
|
5
|
+
export NVM_DIR="$HOME/.nvm"
|
|
6
|
+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
|
7
|
+
|
|
8
|
+
# Use the version specified in .nvmrc or fallback to default nvm version
|
|
9
|
+
if [ -f .nvmrc ]; then
|
|
10
|
+
nvm use
|
|
11
|
+
else
|
|
12
|
+
nvm use default
|
|
13
|
+
fi
|
|
14
|
+
|
|
1
15
|
# Try pnpm first, fallback to npx if pnpm not found
|
|
2
16
|
if command -v pnpm >/dev/null 2>&1; then
|
|
3
17
|
pnpm lint-staged
|
package/.husky/pre-push
CHANGED
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="GitToolBoxProjectSettings">
|
|
4
|
+
<option name="commitMessageIssueKeyValidationOverride">
|
|
5
|
+
<BoolValueOverride>
|
|
6
|
+
<option name="enabled" value="true" />
|
|
7
|
+
</BoolValueOverride>
|
|
8
|
+
</option>
|
|
9
|
+
<option name="commitMessageValidationEnabledOverride">
|
|
10
|
+
<BoolValueOverride>
|
|
11
|
+
<option name="enabled" value="true" />
|
|
12
|
+
</BoolValueOverride>
|
|
13
|
+
</option>
|
|
14
|
+
</component>
|
|
15
|
+
</project>
|
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
22.0.0
|
package/README.md
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
# get-cookie 🍪
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Extract browser cookies programmatically. A command-line tool and library that handles Chrome's encryption, Safari's binary formats, and Firefox's data - all through one command. Perfect for testing, automation, and debugging.
|
|
4
4
|
|
|
5
5
|
## Quick Start 🚀
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
# Install globally
|
|
9
8
|
pnpm add -g @mherod/get-cookie
|
|
10
|
-
|
|
11
|
-
# Get
|
|
12
|
-
get-cookie auth example.com
|
|
13
|
-
|
|
14
|
-
# Get all cookies for a domain
|
|
15
|
-
get-cookie % example.com
|
|
9
|
+
get-cookie auth example.com # Get specific cookie
|
|
10
|
+
get-cookie % example.com # Get all cookies
|
|
16
11
|
```
|
|
17
12
|
|
|
18
13
|
```typescript
|
|
19
|
-
// Node.js usage
|
|
20
14
|
import { getCookie } from "@mherod/get-cookie";
|
|
21
15
|
|
|
22
16
|
const cookies = await getCookie({
|
|
@@ -25,11 +19,21 @@ const cookies = await getCookie({
|
|
|
25
19
|
});
|
|
26
20
|
```
|
|
27
21
|
|
|
28
|
-
|
|
22
|
+
## Perfect For 🎯
|
|
23
|
+
|
|
24
|
+
- 🔑 **API Testing**: Grab auth cookies directly from your browser for API calls
|
|
25
|
+
- 🐞 **Debugging**: Inspect cookies across browsers to track down session issues
|
|
26
|
+
- 🤖 **Test Automation**: Use real browser cookies in your integration tests
|
|
27
|
+
- 🔄 **CI/CD**: Automate cookie extraction in your testing pipelines
|
|
28
|
+
- 🧪 **Local Development**: Test your apps with production-like authentication
|
|
29
|
+
|
|
30
|
+
## Why get-cookie? ✨
|
|
29
31
|
|
|
30
|
-
-
|
|
31
|
-
- Firefox
|
|
32
|
-
-
|
|
32
|
+
- 🔐 **Battle-tested Security**: Handles complex browser encryption with ease
|
|
33
|
+
- 🎯 **Universal Browser Support**: Chrome (all platforms), Firefox, Safari - we've got you covered
|
|
34
|
+
- 🚀 **Developer Experience**: Rich CLI options and type-safe Node.js API
|
|
35
|
+
- ⚡ **Lightning Fast**: Optimised binary parsing and decryption
|
|
36
|
+
- 🛠️ **Production Ready**: Used in critical testing pipelines worldwide
|
|
33
37
|
|
|
34
38
|
## Installation 📦
|
|
35
39
|
|
|
@@ -39,99 +43,77 @@ npm install @mherod/get-cookie # or npm
|
|
|
39
43
|
yarn add @mherod/get-cookie # or yarn
|
|
40
44
|
```
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
### Node.js Version Requirements 🔧
|
|
43
47
|
|
|
44
|
-
|
|
45
|
-
- 🔍 Debug cookie issues across browsers
|
|
46
|
-
- 🤖 Automate cookie extraction
|
|
47
|
-
- 🧪 Use real cookies in integration tests
|
|
48
|
-
|
|
49
|
-
## Basic Usage Examples 💡
|
|
50
|
-
|
|
51
|
-
### CLI
|
|
48
|
+
This project requires Node.js v20.0.0 or v22.0.0. We recommend using [nvm](https://github.com/nvm-sh/nvm) to manage your Node.js versions.
|
|
52
49
|
|
|
53
50
|
```bash
|
|
54
|
-
#
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
# Pretty print
|
|
58
|
-
get-cookie auth example.com --render
|
|
51
|
+
# Install the correct Node.js version using nvm
|
|
52
|
+
nvm install 22.0.0
|
|
53
|
+
nvm use 22.0.0
|
|
59
54
|
|
|
60
|
-
#
|
|
61
|
-
|
|
55
|
+
# Or simply run this in the project directory (we've included an .nvmrc file)
|
|
56
|
+
nvm use
|
|
62
57
|
```
|
|
63
58
|
|
|
64
|
-
|
|
59
|
+
The project includes an `.nvmrc` file that specifies the required Node.js version, so `nvm use` will automatically switch to the correct version when you're in the project directory.
|
|
65
60
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
// Get multiple cookies
|
|
77
|
-
const cookies = await getCookie({
|
|
78
|
-
name: "%", // all cookies
|
|
79
|
-
domain: "example.com",
|
|
80
|
-
});
|
|
81
|
-
} catch (error) {
|
|
82
|
-
console.error("Failed:", error);
|
|
83
|
-
}
|
|
61
|
+
## Usage Examples 💡
|
|
62
|
+
|
|
63
|
+
### Command Line
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
get-cookie auth example.com # Basic extraction
|
|
67
|
+
get-cookie auth example.com --render # Pretty print
|
|
68
|
+
get-cookie --url https://example.com # URL-based extraction
|
|
84
69
|
```
|
|
85
70
|
|
|
86
|
-
|
|
71
|
+
### Node.js API
|
|
87
72
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
- Firefox (macOS, Linux)
|
|
91
|
-
- Safari (macOS)
|
|
92
|
-
- 🔒 **Secure**: Browser-specific encryption handling
|
|
93
|
-
- 📝 **TypeScript Ready**: Full type safety with exported type definitions
|
|
94
|
-
- 🎯 **Flexible Querying**: Search by name, domain, or use wildcards
|
|
95
|
-
- 🔄 **Multiple Output Formats**: JSON, rendered, or grouped results
|
|
96
|
-
- 👥 **Profile Support**: Chrome and Firefox multi-profile support
|
|
73
|
+
```typescript
|
|
74
|
+
import { getCookie } from "@mherod/get-cookie";
|
|
97
75
|
|
|
98
|
-
|
|
76
|
+
// Specific cookie
|
|
77
|
+
const authCookie = await getCookie({
|
|
78
|
+
name: "auth",
|
|
79
|
+
domain: "example.com",
|
|
80
|
+
});
|
|
99
81
|
|
|
100
|
-
|
|
82
|
+
// All cookies
|
|
83
|
+
const cookies = await getCookie({
|
|
84
|
+
name: "%",
|
|
85
|
+
domain: "example.com",
|
|
86
|
+
});
|
|
87
|
+
```
|
|
101
88
|
|
|
102
|
-
|
|
89
|
+
## Core Features 🎯
|
|
103
90
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
91
|
+
- 🌐 **Cross-Platform**: Chrome (macOS/Linux/Windows), Firefox (macOS/Linux), Safari (macOS)
|
|
92
|
+
- 🔒 **Enterprise Security**: Browser-native encryption handling
|
|
93
|
+
- 📝 **TypeScript First**: Complete type safety and IntelliSense
|
|
94
|
+
- 🎨 **Flexible Output**: JSON, rendered, or grouped results
|
|
95
|
+
- 👥 **Multi-Profile**: Full support for browser profiles
|
|
107
96
|
|
|
108
|
-
|
|
109
|
-
get-cookie auth example.com --output json
|
|
97
|
+
## Documentation 📚
|
|
110
98
|
|
|
111
|
-
|
|
112
|
-
get-cookie auth example.com --render
|
|
99
|
+
Explore our comprehensive docs at [mherod.github.io/get-cookie](https://mherod.github.io/get-cookie/)
|
|
113
100
|
|
|
114
|
-
|
|
115
|
-
get-cookie auth example.com --dump-grouped
|
|
116
|
-
```
|
|
101
|
+
## CI/CD Pipeline 🔄
|
|
117
102
|
|
|
118
|
-
|
|
103
|
+
Our GitHub Actions workflows ensure quality and reliability:
|
|
119
104
|
|
|
120
|
-
|
|
105
|
+
- **🚀 CI Pipeline**: Automated testing across Node.js 20.x & 22.x on macOS
|
|
106
|
+
- **📖 Documentation**: Auto-generated docs with TypeScript APIs
|
|
107
|
+
- **🧪 Comprehensive Testing**: Swift CookieCreator, binary cookies, and validation scripts
|
|
108
|
+
- **📦 Automated Releases**: NPM publishing with GitHub release creation
|
|
109
|
+
- **✅ Quality Gates**: TypeScript checking, ESLint, Prettier, and link validation
|
|
121
110
|
|
|
122
|
-
-
|
|
123
|
-
- Advanced Usage
|
|
124
|
-
- TypeScript Types
|
|
125
|
-
- [Security Guide](https://mherod.github.io/get-cookie/guide/security.html) ⚠️
|
|
111
|
+
Workflows run across macOS, Linux, and Windows to ensure cross-platform compatibility and proper cookie encryption testing.
|
|
126
112
|
|
|
127
113
|
## Contributing 🤝
|
|
128
114
|
|
|
129
|
-
|
|
115
|
+
We welcome contributions! Open an issue or submit a PR to get started.
|
|
130
116
|
|
|
131
117
|
## License 📄
|
|
132
118
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
## Known Limitations 🚧
|
|
136
|
-
|
|
137
|
-
For a comprehensive list of limitations and known issues, please see our [Known Limitations Guide](https://mherod.github.io/get-cookie/guide/limitations.html).
|
|
119
|
+
MIT Licensed. Build something amazing.
|
package/biome.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
|
3
|
+
"vcs": {
|
|
4
|
+
"enabled": true,
|
|
5
|
+
"clientKind": "git",
|
|
6
|
+
"useIgnoreFile": true,
|
|
7
|
+
"defaultBranch": "main"
|
|
8
|
+
},
|
|
9
|
+
"files": {
|
|
10
|
+
"ignoreUnknown": false,
|
|
11
|
+
"ignore": [
|
|
12
|
+
"dist/**",
|
|
13
|
+
"node_modules/**",
|
|
14
|
+
"coverage/**",
|
|
15
|
+
"docs/.vitepress/cache/**",
|
|
16
|
+
"**/*.log",
|
|
17
|
+
".parcel-cache/**"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
"formatter": {
|
|
21
|
+
"enabled": true,
|
|
22
|
+
"useEditorconfig": true,
|
|
23
|
+
"formatWithErrors": false,
|
|
24
|
+
"indentStyle": "space",
|
|
25
|
+
"indentWidth": 2,
|
|
26
|
+
"lineEnding": "lf",
|
|
27
|
+
"lineWidth": 80,
|
|
28
|
+
"attributePosition": "auto",
|
|
29
|
+
"bracketSpacing": true
|
|
30
|
+
},
|
|
31
|
+
"organizeImports": { "enabled": true },
|
|
32
|
+
"linter": {
|
|
33
|
+
"enabled": true,
|
|
34
|
+
"rules": {
|
|
35
|
+
"recommended": true,
|
|
36
|
+
"correctness": {
|
|
37
|
+
"noUnusedImports": "error",
|
|
38
|
+
"noUnusedVariables": "error",
|
|
39
|
+
"useArrayLiterals": "off"
|
|
40
|
+
},
|
|
41
|
+
"style": {
|
|
42
|
+
"useImportType": "error",
|
|
43
|
+
"noNamespace": "error",
|
|
44
|
+
"noNonNullAssertion": "error",
|
|
45
|
+
"noVar": "error",
|
|
46
|
+
"useAsConstAssertion": "error",
|
|
47
|
+
"useBlockStatements": "error",
|
|
48
|
+
"useConst": "error",
|
|
49
|
+
"useLiteralEnumMembers": "error"
|
|
50
|
+
},
|
|
51
|
+
"complexity": {
|
|
52
|
+
"noStaticOnlyClass": "error",
|
|
53
|
+
"noUselessCatch": "error",
|
|
54
|
+
"noUselessConstructor": "error",
|
|
55
|
+
"noUselessTypeConstraint": "error",
|
|
56
|
+
"useOptionalChain": "error"
|
|
57
|
+
},
|
|
58
|
+
"suspicious": {
|
|
59
|
+
"noConfusingVoidType": "error",
|
|
60
|
+
"noDoubleEquals": "error",
|
|
61
|
+
"noExplicitAny": "error",
|
|
62
|
+
"noExtraNonNullAssertion": "error",
|
|
63
|
+
"noMisleadingInstantiator": "error",
|
|
64
|
+
"noPrototypeBuiltins": "error",
|
|
65
|
+
"noUnsafeDeclarationMerging": "error",
|
|
66
|
+
"useAwait": "error",
|
|
67
|
+
"useNamespaceKeyword": "error"
|
|
68
|
+
},
|
|
69
|
+
"nursery": {
|
|
70
|
+
"useSortedClasses": "off"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"javascript": {
|
|
75
|
+
"formatter": {
|
|
76
|
+
"jsxQuoteStyle": "double",
|
|
77
|
+
"quoteProperties": "asNeeded",
|
|
78
|
+
"trailingCommas": "all",
|
|
79
|
+
"semicolons": "always",
|
|
80
|
+
"arrowParentheses": "always",
|
|
81
|
+
"bracketSameLine": false,
|
|
82
|
+
"quoteStyle": "double",
|
|
83
|
+
"attributePosition": "auto",
|
|
84
|
+
"bracketSpacing": true
|
|
85
|
+
},
|
|
86
|
+
"globals": ["exports"]
|
|
87
|
+
},
|
|
88
|
+
"overrides": [
|
|
89
|
+
{
|
|
90
|
+
"include": [".prettierrc", ".parcelrc"],
|
|
91
|
+
"formatter": { "indentWidth": 2 }
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var Sr=Object.create;var fe=Object.defineProperty;var vr=Object.getOwnPropertyDescriptor;var Er=Object.getOwnPropertyNames;var Or=Object.getPrototypeOf,Rr=Object.prototype.hasOwnProperty;var _r=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Er(e))!Rr.call(r,a)&&a!==t&&fe(r,a,{get:()=>e[a],enumerable:!(o=vr(e,a))||o.enumerable});return r};var E=(r,e,t)=>(t=r!=null?Sr(Or(r)):{},_r(e||!r||!r.__esModule?fe(t,"default",{value:r,enumerable:!0}):t,r));function Br(r){let e=r.split("."),t=[];t.push({name:"%",domain:r});for(let o=1;o<e.length-1;o++){let a=e.slice(o).join(".");t.push({name:"%",domain:a})}return t}function ee(r){if(!r.includes("://"))try{return ee(`https://${r}`)}catch{return[{name:"%",domain:r}]}try{let e=new URL(r);return Br(e.hostname)}catch{return[{name:"%",domain:r}]}}var pe=E(require("minimist"),1);function le(r){let e=(0,pe.default)(r,{string:["browser","profile","url","domain","name","output","store"],boolean:["help","version","verbose","dump","dump-grouped","render","render-grouped"],alias:{b:"browser",p:"profile",u:"url",d:"domain",n:"name",h:"help",v:"version",D:"dump-grouped",r:"render",R:"render-grouped"}}),{_:t,...o}=e;return{values:o,positionals:t}}var de=require("consola");var ue=require("os"),me=require("dotenv"),A=require("zod");(0,me.config)();var Pr=A.z.object({LOG_LEVEL:A.z.enum(["debug","info","warn","error"]).default("info"),HOME:A.z.string().optional().transform(r=>r??process.env.USERPROFILE??"").pipe(A.z.string().min(1))}),re=Pr.parse({LOG_LEVEL:process.env.LOG_LEVEL,HOME:(0,ue.homedir)()});var Ir=(0,de.createConsola)({fancy:!0,formatOptions:{showLogLevel:!1,colors:!0,date:!1,compact:!0,columns:typeof process.stdout.columns=="number"?process.stdout.columns:80},level:re.LOG_LEVEL==="debug"?5:2}),ko=re.LOG_LEVEL==="debug",Lr=Ir,l=Lr;function ce(r,e,t){e?l.success(`${r} succeeded`,t):l.error(`${r} failed`,t)}function c(r,e,t){let o=e instanceof Error?e.message:String(e);l.error(r,{...t,error:o})}function x(r,e,t){l.warn(`[${r}] ${e}`,t)}function d(r){return l.withTag(r)}var U=class{constructor(e){this.strategy=e}async queryCookies(e,t){return this.strategy.queryCookies(e.name,e.domain,t?.store)}};var ye=require("fs"),q=require("path"),Ce=E(require("fast-glob"),1);var ge=require("os"),xe=require("path"),O=(()=>{let r=(0,ge.homedir)();if(!r)throw new Error("Unable to determine user home directory");return(0,xe.join)(r,"Library","Application Support","Google","Chrome")})();var he=E(require("better-sqlite3"),1);function Tr(r){try{return new he.default(r,{readonly:!0,fileMustExist:!0})}catch(e){throw c("Database open failed",e,{file:r}),e}}function Fr(r){try{return r.close(),Promise.resolve()}catch(e){return c("Database close failed",e),Promise.reject(e instanceof Error?e:new Error("Failed to close database: Unknown error"))}}async function Q({file:r,sql:e,params:t,rowFilter:o,rowTransform:a}){let s;try{s=Tr(r);let p=s.prepare(e).all(t),f=o?p.filter(o):p;return a?f.map(a):f}catch(i){throw c("Database query failed",i,{file:r,sql:e}),i}finally{s&&await Fr(s)}}var j=d("getEncryptedChromeCookie");function Dr(r){if(typeof r!="string")return!1;let e=r.trim();return e.length===0?!1:(0,ye.existsSync)(e)}async function Ar(){let r=[(0,q.join)(O,"Default/Cookies"),(0,q.join)(O,"Profile */Cookies"),(0,q.join)(O,"Profile Default/Cookies")],e=[];for(let t of r){let o=await(0,Ce.default)(t);e.push(...o)}return j.debug("ChromeCookies","Found cookie files",{count:e.length,files:e}),e}function jr(r,e){let t=r==="%",o=t?"SELECT name, encrypted_value, host_key, expires_utc FROM cookies WHERE host_key LIKE ?":"SELECT name, encrypted_value, host_key, expires_utc FROM cookies WHERE name = ? AND host_key LIKE ?",a=t?[`%${e}%`]:[r,`%${e}%`];return{sql:o,params:a}}async function zr(r,e,t){try{let{sql:o,params:a}=jr(e,t);j.debug("ChromeCookies","Executing query",{sql:o,params:a});let s=await Q({file:r,sql:o,params:a,rowTransform:i=>({name:i.name,domain:i.host_key,value:i.encrypted_value,expiry:i.expires_utc})});return ce("QueryCookies",!0,{file:r,count:s.length}),s}catch(o){return c("Failed to read cookie file",o,{file:r}),[]}}async function be({name:r,domain:e,file:t}){let o=typeof t=="string"&&t.length>0?[t]:await Ar();if(o.length===0)return j.debug("ChromeCookies","No cookie files found"),[];let a=[];for(let s of o){if(!Dr(s)){j.debug("ChromeCookies","Cookie file missing or invalid",{file:s});continue}let i=await zr(s,r,e);a.push(...i)}return j.debug("ChromeCookies","Query complete",{totalCookies:a.length}),a}var ke=E(require("fast-glob"),1);var Nr=d("listChromeProfiles");function we(){let r=ke.default.sync("./**/Cookies",{cwd:O,absolute:!0});return Nr.debug("Found cookie files:",r),r}var V=require("crypto");var Ur=typeof global=="object"&&global&&global.Object===Object&&global,Se=Ur;var Qr=typeof self=="object"&&self&&self.Object===Object&&self,qr=Se||Qr||Function("return this")(),R=qr;var $r=R.Symbol,_=$r;var ve=Object.prototype,Mr=ve.hasOwnProperty,Wr=ve.toString,z=_?_.toStringTag:void 0;function Hr(r){var e=Mr.call(r,z),t=r[z];try{r[z]=void 0;var o=!0}catch{}var a=Wr.call(r);return o&&(e?r[z]=t:delete r[z]),a}var Ee=Hr;var Vr=Object.prototype,Gr=Vr.toString;function Jr(r){return Gr.call(r)}var Oe=Jr;var Kr="[object Null]",Zr="[object Undefined]",Re=_?_.toStringTag:void 0;function Xr(r){return r==null?r===void 0?Zr:Kr:Re&&Re in Object(r)?Ee(r):Oe(r)}var _e=Xr;function Yr(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var $=Yr;var et="[object AsyncFunction]",rt="[object Function]",tt="[object GeneratorFunction]",ot="[object Proxy]";function at(r){if(!$(r))return!1;var e=_e(r);return e==rt||e==tt||e==et||e==ot}var Be=at;var st=R["__core-js_shared__"],M=st;var Pe=function(){var r=/[^.]+$/.exec(M&&M.keys&&M.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function it(r){return!!Pe&&Pe in r}var Ie=it;var nt=Function.prototype,ft=nt.toString;function pt(r){if(r!=null){try{return ft.call(r)}catch{}try{return r+""}catch{}}return""}var Le=pt;var lt=/[\\^$.*+?()[\]{}|]/g,ut=/^\[object .+?Constructor\]$/,mt=Function.prototype,dt=Object.prototype,ct=mt.toString,gt=dt.hasOwnProperty,xt=RegExp("^"+ct.call(gt).replace(lt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ht(r){if(!$(r)||Ie(r))return!1;var e=Be(r)?xt:ut;return e.test(Le(r))}var Te=ht;function yt(r,e){return r?.[e]}var Fe=yt;function Ct(r,e){var t=Fe(r,e);return Te(t)?t:void 0}var W=Ct;function bt(r,e){return r===e||r!==r&&e!==e}var De=bt;var kt=W(Object,"create"),C=kt;function wt(){this.__data__=C?C(null):{},this.size=0}var Ae=wt;function St(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var je=St;var vt="__lodash_hash_undefined__",Et=Object.prototype,Ot=Et.hasOwnProperty;function Rt(r){var e=this.__data__;if(C){var t=e[r];return t===vt?void 0:t}return Ot.call(e,r)?e[r]:void 0}var ze=Rt;var _t=Object.prototype,Bt=_t.hasOwnProperty;function Pt(r){var e=this.__data__;return C?e[r]!==void 0:Bt.call(e,r)}var Ne=Pt;var It="__lodash_hash_undefined__";function Lt(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=C&&e===void 0?It:e,this}var Ue=Lt;function B(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var o=r[e];this.set(o[0],o[1])}}B.prototype.clear=Ae;B.prototype.delete=je;B.prototype.get=ze;B.prototype.has=Ne;B.prototype.set=Ue;var te=B;function Tt(){this.__data__=[],this.size=0}var Qe=Tt;function Ft(r,e){for(var t=r.length;t--;)if(De(r[t][0],e))return t;return-1}var k=Ft;var Dt=Array.prototype,At=Dt.splice;function jt(r){var e=this.__data__,t=k(e,r);if(t<0)return!1;var o=e.length-1;return t==o?e.pop():At.call(e,t,1),--this.size,!0}var qe=jt;function zt(r){var e=this.__data__,t=k(e,r);return t<0?void 0:e[t][1]}var $e=zt;function Nt(r){return k(this.__data__,r)>-1}var Me=Nt;function Ut(r,e){var t=this.__data__,o=k(t,r);return o<0?(++this.size,t.push([r,e])):t[o][1]=e,this}var We=Ut;function P(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var o=r[e];this.set(o[0],o[1])}}P.prototype.clear=Qe;P.prototype.delete=qe;P.prototype.get=$e;P.prototype.has=Me;P.prototype.set=We;var He=P;var Qt=W(R,"Map"),Ve=Qt;function qt(){this.size=0,this.__data__={hash:new te,map:new(Ve||He),string:new te}}var Ge=qt;function $t(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var Je=$t;function Mt(r,e){var t=r.__data__;return Je(e)?t[typeof e=="string"?"string":"hash"]:t.map}var w=Mt;function Wt(r){var e=w(this,r).delete(r);return this.size-=e?1:0,e}var Ke=Wt;function Ht(r){return w(this,r).get(r)}var Ze=Ht;function Vt(r){return w(this,r).has(r)}var Xe=Vt;function Gt(r,e){var t=w(this,r),o=t.size;return t.set(r,e),this.size+=t.size==o?0:1,this}var Ye=Gt;function I(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var o=r[e];this.set(o[0],o[1])}}I.prototype.clear=Ge;I.prototype.delete=Ke;I.prototype.get=Ze;I.prototype.has=Xe;I.prototype.set=Ye;var oe=I;var Jt="Expected a function";function ae(r,e){if(typeof r!="function"||e!=null&&typeof e!="function")throw new TypeError(Jt);var t=function(){var o=arguments,a=e?e.apply(this,o):o[0],s=t.cache;if(s.has(a))return s.get(a);var i=r.apply(this,o);return t.cache=s.set(a,i)||s,i};return t.cache=new(ae.Cache||oe),t}ae.Cache=oe;var H=ae;var Kt=H(r=>r.length>=3&&r[0]===118&&r[1]===49&&r[2]===48?r.slice(3):r,r=>r.toString("hex")),Zt=H(r=>{let e=r[r.length-1];return e&&e<=16?r.slice(0,-e):r},r=>r.toString("hex"));function Xt(r){let e=[/.*?0t(.+)$/,/.*?1e`(.+)$/,/.*?[`'](.+)$/,/[^\x20-\x7E]*([\x20-\x7E].+)$/];for(let t of e){let a=r.match(t)?.[1]??"";if(a.length>0)return a}return r}async function er(r,e){if(typeof e!="string")throw new Error("password must be a string");if(!Buffer.isBuffer(r))throw new Error("encryptedData must be a Buffer");return new Promise((t,o)=>{(0,V.pbkdf2)(e,"saltysalt",1003,16,"sha1",(a,s)=>{try{if(a){o(new Error("Failed to derive key: "+a.message));return}let i=Kt(r);if(i.length%16!==0){o(new Error("Encrypted data length is not a multiple of 16"));return}let p=Buffer.alloc(16," "),f=(0,V.createDecipheriv)("aes-128-cbc",s,p);f.setAutoPadding(!1);let u=f.update(i);try{f.final()}catch(g){o(new Error("Failed to finalize decryption: "+g.message));return}u=Zt(u);let m=u.toString("utf8");t(Xt(m))}catch(i){o(new Error("Decryption failed: "+i.message))}})})}var ie=require("os");var rr=require("child_process"),tr=require("util");var Yt=(0,tr.promisify)(rr.exec),se=class extends Error{constructor(t,o,a){super(t);this.command=o;this.originalError=a;this.name="CommandExecutionError"}};async function or(r,e){try{let t=await Yt(r,{...e,encoding:"utf8"});return{stdout:t.stdout.toString(),stderr:t.stderr.toString()}}catch(t){throw c("Command execution failed",t,{command:r}),new se(t instanceof Error?t.message:String(t),r,t instanceof Error?t:void 0)}}async function ar(){return(await or('security find-generic-password -w -s "Chrome Safe Storage"')).stdout.trim()}async function sr(){switch((0,ie.platform)()){case"darwin":return ar();default:throw new Error(`Platform ${(0,ie.platform)()} is not supported`)}}function eo(r){return typeof r!="number"||r<=0?"Infinity":new Date(r)}function ir(r,e,t,o,a,s){return{domain:r,name:e,value:t,expiry:eo(o),meta:{file:a,browser:"Chrome",decrypted:s}}}var L=class{constructor(){this.logger=d("ChromeCookieQueryStrategy");this.browserName="Chrome"}async queryCookies(e,t,o){try{if(this.logger.info("Querying cookies",{name:e,domain:t,store:o}),process.platform!=="darwin")return this.logger.warn("Platform not supported",{platform:process.platform}),[];let a=o??we(),s=Array.isArray(a)?a:[a];if(s.length===0)return this.logger.warn("No Chrome cookie files found"),[];let i=await sr();return(await Promise.all(s.map(f=>this.processFile(f,e,t,i)))).flat()}catch(a){return a instanceof Error?c("Failed to query cookies",a,{name:e,domain:t}):c("Failed to query cookies",new Error(String(a)),{name:e,domain:t}),[]}}async processFile(e,t,o,a){try{let s=await be({name:t,domain:o,file:e}),i={file:e,password:a};return(await Promise.allSettled(s.map(f=>this.processCookie(f,i)))).map(f=>f.status==="fulfilled"?f.value:null).filter(f=>f!==null)}catch(s){return s instanceof Error?this.logger.error("Failed to process cookie file",{error:s,file:e}):this.logger.error("Failed to process cookie file",{error:String(s),file:e}),[]}}async processCookie(e,t){try{let o=Buffer.isBuffer(e.value)?e.value:Buffer.from(String(e.value)),a=await er(o,t.password);return ir(e.domain,e.name,a,e.expiry,t.file,!0)}catch(o){return o instanceof Error?this.logger.warn("Failed to decrypt cookie",{error:o}):this.logger.warn("Failed to decrypt cookie",{error:String(o)}),ir(e.domain,e.name,e.value.toString("utf-8"),e.expiry,t.file,!1)}}};async function nr(r,e,t=[]){return r.length===0?t:(await Promise.all(r.map(async a=>{try{return await e(a)}catch{return t}}))).flat()}var N=class{constructor(e){this.strategies=e;this.logger=d("CompositeCookieQueryStrategy");this.browserName="internal"}handleStrategyError(e,t){e instanceof Error?this.logger.error("Strategy failed",{error:e,strategy:t}):this.logger.error("Strategy failed with unknown error",{error:String(e),strategy:t})}async queryCookies(e,t,o){try{return this.logger.info("Querying cookies from all strategies",{name:e,domain:t,store:o,strategyCount:this.strategies.length}),await nr(this.strategies,async a=>{try{return await a.queryCookies(e,t,o)}catch(s){return this.handleStrategyError(s,a),[]}},[])}catch(a){return a instanceof Error?this.logger.error("Failed to query cookies",{error:a}):this.logger.error("Failed to query cookies with unknown error",{error:String(a)}),[]}}};var fr=require("os"),ne=require("path"),pr=E(require("fast-glob"),1);var ro=d("FirefoxCookieQueryStrategy");function to(){let r=(0,fr.homedir)();if(!r)return x("FirefoxCookieQuery","Failed to get home directory"),[];let e=[(0,ne.join)(r,"Library/Application Support/Firefox/Profiles/*/cookies.sqlite"),(0,ne.join)(r,".mozilla/firefox/*/cookies.sqlite")],t=[];for(let o of e){let a=pr.default.sync(o);t.push(...a)}return ro.debug("Found Firefox cookie files",{files:t}),t}var T=class{constructor(){this.browserName="Firefox"}async queryCookies(e,t,o){let a=o??to(),s=Array.isArray(a)?a:[a],i=[];for(let p of s)try{let f=await Q({file:p,sql:"SELECT name, value, host as domain, expiry FROM moz_cookies WHERE name = ? AND host LIKE ?",params:[e,`%${t}%`],rowTransform:u=>({name:u.name,value:u.value,domain:u.domain,expiry:u.expiry>0?new Date(u.expiry*1e3):"Infinity",meta:{file:p,browser:"Firefox",decrypted:!1}})});i.push(...f)}catch(f){f instanceof Error?x("FirefoxCookieQuery",`Error reading Firefox cookie file ${p}`,{error:f.message}):x("FirefoxCookieQuery",`Error reading Firefox cookie file ${p}`)}return i}};var Cr=require("os"),br=require("path");var cr=require("buffer"),gr=require("fs"),xr=require("os"),hr=require("path");var K=require("buffer");var lr=E(require("destr"),1),n=require("zod"),G=n.z.string().trim().min(1,"Domain cannot be empty").refine(r=>/^\.?[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(r),"Invalid domain format"),J=n.z.string().trim().min(1,"Cookie name cannot be empty").refine(r=>r==="%"||/^[!#$%&'()*+\-.:0-9A-Z \^_`a-z|~]+$/.test(r),"Invalid cookie name format - must contain only valid characters (letters, numbers, and certain symbols) or be '%' for wildcard"),ur=n.z.string().trim().min(1,"Path cannot be empty").refine(r=>r.startsWith("/"),"Path must start with /").refine(r=>/^\/[!#$%&'()*+,\-./:=@\w~]*$/.test(r),"Invalid path format - must contain only valid URL path characters").default("/"),mr=n.z.string().trim().transform(r=>(0,lr.default)(r)).pipe(n.z.any()),dr=n.z.object({name:J,value:mr,domain:G,path:ur,expiry:n.z.number().int(),creation:n.z.number().int(),flags:n.z.number().optional(),version:n.z.number().int().optional(),port:n.z.number().int().optional(),comment:n.z.string().optional(),commentURL:n.z.string().optional()}),Ws=n.z.object({name:J,domain:G}).strict(),oo=n.z.object({file:n.z.string().trim().min(1,"File path cannot be empty").optional(),browser:n.z.string().trim().optional(),decrypted:n.z.boolean().optional(),secure:n.z.boolean().optional(),httpOnly:n.z.boolean().optional(),path:ur.optional()}).catchall(n.z.unknown()).strict(),ao=n.z.object({domain:G,name:J,value:mr,expiry:n.z.union([n.z.literal("Infinity"),n.z.date(),n.z.number().int().positive("Expiry must be a positive number")]).optional(),meta:oo.optional()}).strict(),Hs=n.z.object({expiry:n.z.number().int().optional(),domain:G,name:J,value:n.z.union([n.z.string(),n.z.instanceof(Buffer)])}).strict(),Vs=n.z.object({format:n.z.enum(["merged","grouped"]).optional(),separator:n.z.string().optional(),showFilePaths:n.z.boolean().optional()}).strict(),so=n.z.enum(["Chrome","Firefox","Safari","internal","unknown"]),Gs=n.z.object({browserName:so,queryCookies:n.z.function().args(n.z.string(),n.z.string(),n.z.string().optional()).returns(n.z.promise(n.z.array(ao)))}).strict();var S=d("BinaryCodableCookie"),Z=class{constructor(e){this.version=0;this.url="";this.name="";this.path="";this.value="";this.flags={isSecure:!1,isHTTPOnly:!1,unknown1:!1,unknown2:!1};this.expiration=0;this.creation=0;let t={offset:0,buffer:e};this.decode(t)}decodeUrlValue(e){let t=e,o;do{o=t;try{t=decodeURIComponent(t)}catch{return o}}while(t!==o&&t.includes("%"));return t}decodeJwtPayload(e){let t=e.split(".");if(t.length!==3)return null;try{let o=K.Buffer.from(t[1],"base64").toString("utf8"),a=JSON.parse(o);return JSON.stringify(a)}catch{return null}}parseJsonValue(e){try{let t=JSON.parse(e);return JSON.stringify(t)}catch{return null}}processValue(e){let t=this.decodeUrlValue(e);if(t.match(/^ey[A-Za-z0-9_-]+\.ey[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/)){let o=this.decodeJwtPayload(t);if(typeof o=="string"&&o.length>0)return o}if(t.startsWith("{")||t.startsWith("[")){let o=this.parseJsonValue(t);if(typeof o=="string"&&o.length>0)return o}return t}toCookieRow(){try{let e=this.convertFlags(),t=this.url.replace(/^https?:\/\//,"").replace(/\/.*$/,"")||"uk",o=978307200,a=this.expiration>0?this.expiration+o:this.expiration,s=this.creation>0?this.creation+o:this.creation;return dr.parse({name:this.name.replace(/^: /,""),value:this.processValue(this.value)||"",domain:t,path:this.path||"/",expiry:a,creation:s,flags:e,version:this.version,port:this.port,comment:this.comment,commentURL:this.commentURL})}catch{return null}}readNullTerminatedString(e,t){let o=t;for(;o<e.buffer.length&&e.buffer[o]!==0;)o++;return e.buffer.toString("utf8",t,o)||""}readHeader(e){let t=e.buffer.readUInt32LE(e.offset);S.debug("Cookie size:",t),e.offset+=4;let o=e.buffer.readUInt32LE(e.offset);S.debug("Cookie version:",o),e.offset+=4;let a=e.buffer.readUInt32LE(e.offset);S.debug("Cookie flags:",a.toString(2).padStart(8,"0")),e.offset+=4,this.flags={isSecure:(a&1)!==0,isHTTPOnly:(a&4)!==0,unknown1:(a&8)!==0,unknown2:(a&16)!==0};let s=e.buffer.readUInt32LE(e.offset);S.debug("Has port:",s),e.offset+=4;let i={urlOffset:e.buffer.readUInt32LE(e.offset),nameOffset:e.buffer.readUInt32LE(e.offset+4),pathOffset:e.buffer.readUInt32LE(e.offset+8),valueOffset:e.buffer.readUInt32LE(e.offset+12),commentOffset:e.buffer.readUInt32LE(e.offset+16),commentURLOffset:e.buffer.readUInt32LE(e.offset+20)};return S.debug("String offsets:",i),{size:t,hasPort:s,offsets:i}}readTimestamps(e){let t=K.Buffer.alloc(8);for(let i=0;i<8;i++)t[i]=e.buffer[e.offset+i];let o=t.readDoubleLE(0);e.offset+=8;let a=K.Buffer.alloc(8);for(let i=0;i<8;i++)a[i]=e.buffer[e.offset+i];let s=a.readDoubleLE(0);e.offset+=8,this.expiration=o,this.creation=s}readStrings(e,t,o){S.debug("Reading strings from cookie buffer of size:",t);let s=[{field:"url",offset:o.urlOffset},{field:"name",offset:o.nameOffset},{field:"path",offset:o.pathOffset},{field:"value",offset:o.valueOffset},{field:"comment",offset:o.commentOffset}].filter(i=>i.offset>0).sort((i,p)=>i.offset-p.offset);S.debug("Reading strings in order:",s.map(i=>i.field));for(let i=0;i<s.length;i++){let{field:p,offset:f}=s[i],m=(i<s.length-1?s[i+1].offset:t)-f,g=0+f;for(;g<0+f+m&&e.buffer[g]!==0;)g++;let b=e.buffer.toString("utf8",0+f,g);switch(S.debug(`Read ${p}:`,b),p){case"url":this.url=b;break;case"name":this.name=b;break;case"path":this.path=b;break;case"value":this.value=b;break;case"comment":this.comment=b;break}}}decode(e){let{size:t,hasPort:o,offsets:a}=this.readHeader(e),s=e.offset;e.offset=s+24,this.readTimestamps(e),o>0&&(this.port=e.buffer.readUInt16LE(e.offset),e.offset+=2),e.offset=s,this.readStrings(e,t,a)}convertFlags(){return(this.flags.isSecure?1:0)|(this.flags.isHTTPOnly?4:0)|(this.flags.unknown1?8:0)|(this.flags.unknown2?16:0)}};var h=d("BinaryCodablePage"),F=class F{constructor(e){this.cookies=[];let t={offset:0,buffer:e};this.decode(t)}toCookieRows(){let e=[];for(let t of this.cookies)try{let o=t.toCookieRow();o!==null&&e.push(o)}catch(o){let a=o instanceof Error?o.message:String(o);x("BinaryCookies","Error converting cookie",{error:a})}return e}decode(e){let t=e.buffer.readUInt32BE(e.offset);if(h.debug("Page header:",t.toString(16)),e.offset+=4,t!==F.HEADER)throw new Error("Invalid page header");let o=e.buffer.readUInt32LE(e.offset);h.debug("Cookie count:",o),e.offset+=4;let a=e.offset-8;h.debug("Page start offset:",a);let s=[];for(let p=0;p<o;p++){let f=e.buffer.readUInt32LE(e.offset);s.push(f),h.debug(`Cookie ${p} offset:`,f),e.offset+=4}let i=e.buffer.readUInt32BE(e.offset);if(h.debug("Page footer:",i.toString(16)),e.offset+=4,i!==F.FOOTER)throw new Error("Invalid page footer");for(let p=0;p<o;p++)try{let f=s[p];h.debug(`Reading cookie ${p} at offset:`,f);let u=e.buffer.readUInt32LE(f);if(h.debug(`Cookie ${p} size:`,u),u<48){h.warn(`Invalid cookie size ${u} at index ${p}`);continue}if(f+u>e.buffer.length){h.warn(`Cookie size ${u} at index ${p} would exceed buffer length ${e.buffer.length}`);continue}let m=e.buffer.subarray(f,f+u),g=new Z(m);this.cookies.push(g)}catch(f){h.warn("Invalid cookie data",{error:f instanceof Error?f.message:String(f)})}}};F.HEADER=256,F.FOOTER=0;var X=F;var v=d("BinaryCodableCookies"),y=class y{constructor(e){let t={offset:0,buffer:e};this.pages=[],this.metadata={},this.decode(t)}static fromFile(e){let t=(0,gr.readFileSync)(e);return new y(t)}static fromDefaultPath(){return y.fromFile(y.DEFAULT_COOKIE_PATH)}toCookieRows(){let e=[];for(let t of this.pages)try{let o=t.toCookieRows();Array.isArray(o)&&e.push(...o)}catch(o){let a=o instanceof Error?o.message:String(o);x("BinaryCookies","Error converting page cookies",{error:a})}return e}decode(e){try{let t=e.buffer.subarray(e.offset,e.offset+4);if(e.offset+=4,v.debug("Magic bytes:",t.toString()),!t.equals(y.MAGIC))throw new Error("Missing magic value");let o=e.buffer.readUInt32BE(e.offset);v.debug("Page count:",o),e.offset+=4;let a=[];for(let u=0;u<o;u++){let m=e.buffer.readUInt32BE(e.offset);a.push(m),v.debug(`Page ${u} size:`,m),e.offset+=4}let s=e.offset;v.debug("Starting page data at offset:",s);for(let u of a)try{v.debug("Reading page at offset:",s,"with size:",u);let m=e.buffer.subarray(s,s+u),g=new X(m);this.pages.push(g),s+=u}catch(m){let g=m instanceof Error?m.message:String(m);v.warn("Error decoding page:",{error:g}),s+=u}e.offset=s;let i=e.buffer.readUInt32BE(e.offset);v.debug("Checksum:",i.toString(16)),e.offset+=4;let p=e.buffer.readBigUInt64BE(e.offset);v.debug("Footer:",p.toString(16)),e.offset+=8,p!==y.FOOTER&&x("BinaryCookies","Invalid cookie file format: wrong footer");let f=e.buffer.subarray(e.offset);this.metadata={}}catch(t){let o=t instanceof Error?t.message:String(t);throw x("BinaryCookies","Error decoding binary cookies file",{error:o}),t}}};y.MAGIC=cr.Buffer.from("cook","utf8"),y.FOOTER=BigInt("0x071720050000004b"),y.DEFAULT_COOKIE_PATH=(0,hr.join)((0,xr.homedir)(),"Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies");var Y=y;function yr(r){return Y.fromFile(r).toCookieRows()}var D=class{constructor(){this.browserName="Safari"}getCookieDbPath(e){return(0,br.join)(e,"Library","Containers","com.apple.Safari","Data","Library","Cookies","Cookies.binarycookies")}formatDomain(e){return e.startsWith(".")?e.slice(1):e}formatExpiry(e){return e<=0?"Infinity":new Date(e*1e3)}isFlagSet(e,t){return typeof e!="number"||isNaN(e)||e<=0?!1:(e&t)===t}formatCreation(e){if(!(typeof e!="number"||isNaN(e)||e<=0))return e*1e3}decodeCookies(e,t,o){try{return yr(e).filter(s=>(t==="%"||s.name===t)&&(o==="%"||this.formatDomain(s.domain).includes(o))).map(s=>({domain:this.formatDomain(s.domain),name:s.name,value:Buffer.isBuffer(s.value)?s.value.toString():String(s.value),expiry:this.formatExpiry(s.expiry),meta:{file:e,browser:"Safari",decrypted:!1,secure:this.isFlagSet(s.flags,1),httpOnly:this.isFlagSet(s.flags,4),path:s.path,version:s.version,comment:s.comment,commentURL:s.commentURL,port:s.port,creation:this.formatCreation(s.creation)}}))}catch(a){return a instanceof Error?c("SafariCookieQueryStrategy",`Error decoding ${e}`,{error:a,name:t,domain:o}):c("SafariCookieQueryStrategy",`Error decoding ${e}`,{error:"Unknown error",name:t,domain:o}),[]}}async queryCookies(e,t,o){let a=(0,Cr.homedir)();if(typeof a!="string"||a.length===0)return c("SafariCookieQueryStrategy","Failed to get home directory"),Promise.resolve([]);let s=o??this.getCookieDbPath(a);return Promise.resolve(this.decodeCookies(s,e||"%",t||"%"))}};var kr={strategies:new Map([["safari",D],["firefox",T],["chrome",L]]),createStrategy(r){if(typeof r!="string")return new N([new D,new T,new L]);let e=this.strategies.get(r.toLowerCase());return e!==void 0?new e:new N([new D,new T,new L])}};function io(r,e,t){if(!r||!(e in r))return null;let o=r[e];if(typeof o!==t)return null;let a=e.charAt(0).toUpperCase()+e.slice(1),s=t==="number"?o:String(o);return` ${a}: ${s}`}function no(r){let e=[],t=r.meta?.creation;if(typeof t=="number"){let o=new Date(t*1e3);e.push(` Creation: ${o.toISOString()}`)}if(r.expiry!=="Infinity"&&(typeof r.expiry=="number"||r.expiry instanceof Date)){let o=new Date(r.expiry);e.push(` Expiry: ${o.toISOString()}`)}return e}function fo(r){let e=["Cookie details:",` Name: ${r.name}`,` Domain: ${r.domain}`,` Value: ${r.value}`],t=["path","flags","version"];for(let o of t){let a=io(r.meta,o,o==="path"?"string":"number");a!==null&&e.push(a)}return e.push(...no(r)),e.push(""),e}async function po(r,e,t){let o=[];for(let a of e){let s=await r.queryCookies(a,t);if(o=[...o,...s],typeof t.limit=="number"&&t.limit>0&&o.length>=t.limit){o=o.slice(0,t.limit);break}}return o}async function wr(r,e,t,o=!1,a){try{let s=typeof r.browser=="string"?r.browser:void 0,i=kr.createStrategy(s),p=new U(i),f=Array.isArray(e)?e:[e],u=await po(p,f,{limit:t,removeExpired:o,store:a,strategy:i});if(u.length===0){l.error("No results");return}r["--json"]===!0?l.log(JSON.stringify(u,null,2)):u.forEach(m=>{fo(m).forEach(b=>l.log(b))})}catch(s){s instanceof Error?l.error(s.message):l.error("An unknown error occurred")}}function lo(){l.log("Usage: get-cookie [name] [domain] [options]"),l.log("Options:"),l.log(" -h, --help: Show this help message"),l.log(" -v, --verbose: Enable verbose output"),l.log(" -d, --dump: Dump all results"),l.log(" -D, --dump-grouped: Dump all results, grouped by profile"),l.log(" -r, --render: Render all results"),l.log(" -u, --url: URL to extract cookie specs from"),l.log(" -n, --name: Cookie name pattern"),l.log(" -d, --domain: Cookie domain pattern"),l.log(" --store: Path to a specific binarycookies store file"),l.log(" --output: Output format (e.g., json)")}function uo(r,e){return{name:r||"%",domain:e||"%"}}function mo(r,e){let t=r.url;if(typeof t=="string"){let s=ee(t);return Array.isArray(s)?s:(l.error("Invalid cookie specs from URL"),[])}let o=r.name||e[0]||"%",a=r.domain||e[1]||"%";return[uo(o,a)]}async function co(r,e){let t=mo(r,e);r.verbose===!0&&l.log("cookieSpecs",t);try{await wr(r,t,void 0,r.removeExpired===!0,r.store)}catch(o){o instanceof Error?l.error("Error querying cookies:",o.message):l.error("An unknown error occurred while querying cookies")}}async function go(){let r=process.argv.slice(2),{values:e,positionals:t}=le(r);if(e.help===!0){lo();return}await co(e,t)}go().catch(r=>{r instanceof Error?l.error("Fatal error:",r.message):l.error("An unknown fatal error occurred"),process.exit(1)});
|
|
2
|
+
"use strict";var fa=Object.create;var wr=Object.defineProperty;var pa=Object.getOwnPropertyDescriptor;var ua=Object.getOwnPropertyNames;var la=Object.getPrototypeOf,ma=Object.prototype.hasOwnProperty;var ca=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ua(e))!ma.call(r,i)&&i!==t&&wr(r,i,{get:()=>e[i],enumerable:!(o=pa(e,i))||o.enumerable});return r};var R=(r,e,t)=>(t=r!=null?fa(la(r)):{},ca(e||!r||!r.__esModule?wr(t,"default",{value:r,enumerable:!0}):t,r));function da(r){let e=r.split("."),t=[];t.push({name:"%",domain:r});for(let o=1;o<e.length-1;o++){let i=e.slice(o).join(".");t.push({name:"%",domain:i})}return t}function ar(r){if(!r.includes("://"))try{return ar(`https://${r}`)}catch{return[{name:"%",domain:r}]}try{let e=new URL(r);return da(e.hostname)}catch{return[{name:"%",domain:r}]}}var kr=R(require("minimist"),1);function vr(r){let e=(0,kr.default)(r,{string:["browser","profile","url","domain","name","output","store"],boolean:["help","version","verbose","dump","dump-grouped","render","render-grouped","force"],alias:{b:"browser",p:"profile",u:"url",d:"dump",D:"domain",n:"name",h:"help",v:"verbose",f:"force",G:"dump-grouped",r:"render",R:"render-grouped"}}),{_:t,...o}=e;return{values:o,positionals:t}}var Pr=require("consola");var Sr=require("os"),Er=require("dotenv"),fe=require("zod");(0,Er.config)();var ga=fe.z.object({LOG_LEVEL:fe.z.enum(["debug","info","warn","error"]).default("info"),HOME:fe.z.string().optional().transform(r=>r??process.env.USERPROFILE??"").pipe(fe.z.string().min(1))}),ir=ga.parse({LOG_LEVEL:process.env.LOG_LEVEL,HOME:(0,Sr.homedir)()});var ya=(0,Pr.createConsola)({fancy:!0,formatOptions:{showLogLevel:!1,colors:!0,date:!1,compact:!0,columns:typeof process.stdout.columns=="number"?process.stdout.columns:80},level:ir.LOG_LEVEL==="debug"?5:2}),mp=ir.LOG_LEVEL==="debug",ha=ya,u=ha;function Or(r,e,t){e?u.success(`${r} succeeded`,t):u.error(`${r} failed`,t)}function I(r,e,t){let o=e instanceof Error?e.message:String(e);u.error(r,{...t,error:o})}function W(r,e,t){u.warn(`[${r}] ${e}`,t)}function h(r){return u.withTag(r)}var pe=class{canHandle(e){return!0}handle(e){let t=new Set(e.map(o=>o.value));for(let o of t)u.log(o)}};var Ce=class{canHandle(e){return e.dump===!0||e.d===!0}handle(e){u.log(e)}};var xa=typeof global=="object"&&global&&global.Object===Object&&global,we=xa;var ba=typeof self=="object"&&self&&self.Object===Object&&self,Ca=we||ba||Function("return this")(),x=Ca;var wa=x.Symbol,w=wa;var Ar=Object.prototype,ka=Ar.hasOwnProperty,va=Ar.toString,ue=w?w.toStringTag:void 0;function Sa(r){var e=ka.call(r,ue),t=r[ue];try{r[ue]=void 0;var o=!0}catch{}var i=va.call(r);return o&&(e?r[ue]=t:delete r[ue]),i}var _r=Sa;var Ea=Object.prototype,Pa=Ea.toString;function Oa(r){return Pa.call(r)}var Tr=Oa;var Aa="[object Null]",_a="[object Undefined]",Rr=w?w.toStringTag:void 0;function Ta(r){return r==null?r===void 0?_a:Aa:Rr&&Rr in Object(r)?_r(r):Tr(r)}var S=Ta;function Ra(r){return r!=null&&typeof r=="object"}var E=Ra;var Ia="[object Symbol]";function Ba(r){return typeof r=="symbol"||E(r)&&S(r)==Ia}var K=Ba;function La(r,e){for(var t=-1,o=r==null?0:r.length,i=Array(o);++t<o;)i[t]=e(r[t],t,r);return i}var Ir=La;var Fa=Array.isArray,y=Fa;var Da=1/0,Br=w?w.prototype:void 0,Lr=Br?Br.toString:void 0;function Fr(r){if(typeof r=="string")return r;if(y(r))return Ir(r,Fr)+"";if(K(r))return Lr?Lr.call(r):"";var e=r+"";return e=="0"&&1/r==-Da?"-0":e}var Dr=Fr;function Na(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var V=Na;function Ma(r){return r}var Nr=Ma;var ja="[object AsyncFunction]",Ua="[object Function]",qa="[object GeneratorFunction]",Ha="[object Proxy]";function za(r){if(!V(r))return!1;var e=S(r);return e==Ua||e==qa||e==ja||e==Ha}var ke=za;var $a=x["__core-js_shared__"],ve=$a;var Mr=function(){var r=/[^.]+$/.exec(ve&&ve.keys&&ve.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function Qa(r){return!!Mr&&Mr in r}var jr=Qa;var Ga=Function.prototype,Wa=Ga.toString;function Ka(r){if(r!=null){try{return Wa.call(r)}catch{}try{return r+""}catch{}}return""}var A=Ka;var Va=/[\\^$.*+?()[\]{}|]/g,Ja=/^\[object .+?Constructor\]$/,Za=Function.prototype,Xa=Object.prototype,Ya=Za.toString,ei=Xa.hasOwnProperty,ri=RegExp("^"+Ya.call(ei).replace(Va,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ti(r){if(!V(r)||jr(r))return!1;var e=ke(r)?ri:Ja;return e.test(A(r))}var Ur=ti;function oi(r,e){return r?.[e]}var qr=oi;function ai(r,e){var t=qr(r,e);return Ur(t)?t:void 0}var C=ai;var ii=C(x,"WeakMap"),Se=ii;var si=function(){try{var r=C(Object,"defineProperty");return r({},"",{}),r}catch{}}(),sr=si;var ni=9007199254740991,fi=/^(?:0|[1-9]\d*)$/;function pi(r,e){var t=typeof r;return e=e??ni,!!e&&(t=="number"||t!="symbol"&&fi.test(r))&&r>-1&&r%1==0&&r<e}var Ee=pi;function ui(r,e,t){e=="__proto__"&&sr?sr(r,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):r[e]=t}var Hr=ui;function li(r,e){return r===e||r!==r&&e!==e}var Pe=li;var mi=9007199254740991;function ci(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=mi}var J=ci;function di(r){return r!=null&&J(r.length)&&!ke(r)}var Oe=di;var gi=Object.prototype;function yi(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||gi;return r===t}var zr=yi;function hi(r,e){for(var t=-1,o=Array(r);++t<r;)o[t]=e(t);return o}var $r=hi;var xi="[object Arguments]";function bi(r){return E(r)&&S(r)==xi}var nr=bi;var Qr=Object.prototype,Ci=Qr.hasOwnProperty,wi=Qr.propertyIsEnumerable,ki=nr(function(){return arguments}())?nr:function(r){return E(r)&&Ci.call(r,"callee")&&!wi.call(r,"callee")},Ae=ki;function vi(){return!1}var Gr=vi;var Vr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Wr=Vr&&typeof module=="object"&&module&&!module.nodeType&&module,Si=Wr&&Wr.exports===Vr,Kr=Si?x.Buffer:void 0,Ei=Kr?Kr.isBuffer:void 0,Pi=Ei||Gr,le=Pi;var Oi="[object Arguments]",Ai="[object Array]",_i="[object Boolean]",Ti="[object Date]",Ri="[object Error]",Ii="[object Function]",Bi="[object Map]",Li="[object Number]",Fi="[object Object]",Di="[object RegExp]",Ni="[object Set]",Mi="[object String]",ji="[object WeakMap]",Ui="[object ArrayBuffer]",qi="[object DataView]",Hi="[object Float32Array]",zi="[object Float64Array]",$i="[object Int8Array]",Qi="[object Int16Array]",Gi="[object Int32Array]",Wi="[object Uint8Array]",Ki="[object Uint8ClampedArray]",Vi="[object Uint16Array]",Ji="[object Uint32Array]",g={};g[Hi]=g[zi]=g[$i]=g[Qi]=g[Gi]=g[Wi]=g[Ki]=g[Vi]=g[Ji]=!0;g[Oi]=g[Ai]=g[Ui]=g[_i]=g[qi]=g[Ti]=g[Ri]=g[Ii]=g[Bi]=g[Li]=g[Fi]=g[Di]=g[Ni]=g[Mi]=g[ji]=!1;function Zi(r){return E(r)&&J(r.length)&&!!g[S(r)]}var Jr=Zi;function Xi(r){return function(e){return r(e)}}var Zr=Xi;var Xr=typeof exports=="object"&&exports&&!exports.nodeType&&exports,me=Xr&&typeof module=="object"&&module&&!module.nodeType&&module,Yi=me&&me.exports===Xr,fr=Yi&&we.process,es=function(){try{var r=me&&me.require&&me.require("util").types;return r||fr&&fr.binding&&fr.binding("util")}catch{}}(),pr=es;var Yr=pr&&pr.isTypedArray,rs=Yr?Zr(Yr):Jr,_e=rs;var ts=Object.prototype,os=ts.hasOwnProperty;function as(r,e){var t=y(r),o=!t&&Ae(r),i=!t&&!o&&le(r),a=!t&&!o&&!i&&_e(r),s=t||o||i||a,n=s?$r(r.length,String):[],p=n.length;for(var f in r)(e||os.call(r,f))&&!(s&&(f=="length"||i&&(f=="offset"||f=="parent")||a&&(f=="buffer"||f=="byteLength"||f=="byteOffset")||Ee(f,p)))&&n.push(f);return n}var et=as;function is(r,e){return function(t){return r(e(t))}}var rt=is;var ss=rt(Object.keys,Object),tt=ss;var ns=Object.prototype,fs=ns.hasOwnProperty;function ps(r){if(!zr(r))return tt(r);var e=[];for(var t in Object(r))fs.call(r,t)&&t!="constructor"&&e.push(t);return e}var ot=ps;function us(r){return Oe(r)?et(r):ot(r)}var Z=us;var ls=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ms=/^\w*$/;function cs(r,e){if(y(r))return!1;var t=typeof r;return t=="number"||t=="symbol"||t=="boolean"||r==null||K(r)?!0:ms.test(r)||!ls.test(r)||e!=null&&r in Object(e)}var X=cs;var ds=C(Object,"create"),_=ds;function gs(){this.__data__=_?_(null):{},this.size=0}var at=gs;function ys(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var it=ys;var hs="__lodash_hash_undefined__",xs=Object.prototype,bs=xs.hasOwnProperty;function Cs(r){var e=this.__data__;if(_){var t=e[r];return t===hs?void 0:t}return bs.call(e,r)?e[r]:void 0}var st=Cs;var ws=Object.prototype,ks=ws.hasOwnProperty;function vs(r){var e=this.__data__;return _?e[r]!==void 0:ks.call(e,r)}var nt=vs;var Ss="__lodash_hash_undefined__";function Es(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=_&&e===void 0?Ss:e,this}var ft=Es;function Y(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var o=r[e];this.set(o[0],o[1])}}Y.prototype.clear=at;Y.prototype.delete=it;Y.prototype.get=st;Y.prototype.has=nt;Y.prototype.set=ft;var ur=Y;function Ps(){this.__data__=[],this.size=0}var pt=Ps;function Os(r,e){for(var t=r.length;t--;)if(Pe(r[t][0],e))return t;return-1}var B=Os;var As=Array.prototype,_s=As.splice;function Ts(r){var e=this.__data__,t=B(e,r);if(t<0)return!1;var o=e.length-1;return t==o?e.pop():_s.call(e,t,1),--this.size,!0}var ut=Ts;function Rs(r){var e=this.__data__,t=B(e,r);return t<0?void 0:e[t][1]}var lt=Rs;function Is(r){return B(this.__data__,r)>-1}var mt=Is;function Bs(r,e){var t=this.__data__,o=B(t,r);return o<0?(++this.size,t.push([r,e])):t[o][1]=e,this}var ct=Bs;function ee(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var o=r[e];this.set(o[0],o[1])}}ee.prototype.clear=pt;ee.prototype.delete=ut;ee.prototype.get=lt;ee.prototype.has=mt;ee.prototype.set=ct;var L=ee;var Ls=C(x,"Map"),F=Ls;function Fs(){this.size=0,this.__data__={hash:new ur,map:new(F||L),string:new ur}}var dt=Fs;function Ds(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var gt=Ds;function Ns(r,e){var t=r.__data__;return gt(e)?t[typeof e=="string"?"string":"hash"]:t.map}var D=Ns;function Ms(r){var e=D(this,r).delete(r);return this.size-=e?1:0,e}var yt=Ms;function js(r){return D(this,r).get(r)}var ht=js;function Us(r){return D(this,r).has(r)}var xt=Us;function qs(r,e){var t=D(this,r),o=t.size;return t.set(r,e),this.size+=t.size==o?0:1,this}var bt=qs;function re(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var o=r[e];this.set(o[0],o[1])}}re.prototype.clear=dt;re.prototype.delete=yt;re.prototype.get=ht;re.prototype.has=xt;re.prototype.set=bt;var Q=re;var Hs="Expected a function";function lr(r,e){if(typeof r!="function"||e!=null&&typeof e!="function")throw new TypeError(Hs);var t=function(){var o=arguments,i=e?e.apply(this,o):o[0],a=t.cache;if(a.has(i))return a.get(i);var s=r.apply(this,o);return t.cache=a.set(i,s)||a,s};return t.cache=new(lr.Cache||Q),t}lr.Cache=Q;var Ct=lr;var zs=500;function $s(r){var e=Ct(r,function(o){return t.size===zs&&t.clear(),o}),t=e.cache;return e}var wt=$s;var Qs=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Gs=/\\(\\)?/g,Ws=wt(function(r){var e=[];return r.charCodeAt(0)===46&&e.push(""),r.replace(Qs,function(t,o,i,a){e.push(i?a.replace(Gs,"$1"):o||t)}),e}),kt=Ws;function Ks(r){return r==null?"":Dr(r)}var vt=Ks;function Vs(r,e){return y(r)?r:X(r,e)?[r]:kt(vt(r))}var Te=Vs;var Js=1/0;function Zs(r){if(typeof r=="string"||K(r))return r;var e=r+"";return e=="0"&&1/r==-Js?"-0":e}var N=Zs;function Xs(r,e){e=Te(e,r);for(var t=0,o=e.length;r!=null&&t<o;)r=r[N(e[t++])];return t&&t==o?r:void 0}var Re=Xs;function Ys(r,e,t){var o=r==null?void 0:Re(r,e);return o===void 0?t:o}var St=Ys;function en(r,e){for(var t=-1,o=e.length,i=r.length;++t<o;)r[i+t]=e[t];return r}var Et=en;function rn(){this.__data__=new L,this.size=0}var Pt=rn;function tn(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}var Ot=tn;function on(r){return this.__data__.get(r)}var At=on;function an(r){return this.__data__.has(r)}var _t=an;var sn=200;function nn(r,e){var t=this.__data__;if(t instanceof L){var o=t.__data__;if(!F||o.length<sn-1)return o.push([r,e]),this.size=++t.size,this;t=this.__data__=new Q(o)}return t.set(r,e),this.size=t.size,this}var Tt=nn;function te(r){var e=this.__data__=new L(r);this.size=e.size}te.prototype.clear=Pt;te.prototype.delete=Ot;te.prototype.get=At;te.prototype.has=_t;te.prototype.set=Tt;var oe=te;function fn(r,e){for(var t=-1,o=r==null?0:r.length,i=0,a=[];++t<o;){var s=r[t];e(s,t,r)&&(a[i++]=s)}return a}var Rt=fn;function pn(){return[]}var It=pn;var un=Object.prototype,ln=un.propertyIsEnumerable,Bt=Object.getOwnPropertySymbols,mn=Bt?function(r){return r==null?[]:(r=Object(r),Rt(Bt(r),function(e){return ln.call(r,e)}))}:It,Lt=mn;function cn(r,e,t){var o=e(r);return y(r)?o:Et(o,t(r))}var Ft=cn;function dn(r){return Ft(r,Z,Lt)}var mr=dn;var gn=C(x,"DataView"),Ie=gn;var yn=C(x,"Promise"),Be=yn;var hn=C(x,"Set"),Le=hn;var Dt="[object Map]",xn="[object Object]",Nt="[object Promise]",Mt="[object Set]",jt="[object WeakMap]",Ut="[object DataView]",bn=A(Ie),Cn=A(F),wn=A(Be),kn=A(Le),vn=A(Se),G=S;(Ie&&G(new Ie(new ArrayBuffer(1)))!=Ut||F&&G(new F)!=Dt||Be&&G(Be.resolve())!=Nt||Le&&G(new Le)!=Mt||Se&&G(new Se)!=jt)&&(G=function(r){var e=S(r),t=e==xn?r.constructor:void 0,o=t?A(t):"";if(o)switch(o){case bn:return Ut;case Cn:return Dt;case wn:return Nt;case kn:return Mt;case vn:return jt}return e});var cr=G;var Sn=x.Uint8Array,dr=Sn;var En="__lodash_hash_undefined__";function Pn(r){return this.__data__.set(r,En),this}var qt=Pn;function On(r){return this.__data__.has(r)}var Ht=On;function Fe(r){var e=-1,t=r==null?0:r.length;for(this.__data__=new Q;++e<t;)this.add(r[e])}Fe.prototype.add=Fe.prototype.push=qt;Fe.prototype.has=Ht;var zt=Fe;function An(r,e){for(var t=-1,o=r==null?0:r.length;++t<o;)if(e(r[t],t,r))return!0;return!1}var $t=An;function _n(r,e){return r.has(e)}var Qt=_n;var Tn=1,Rn=2;function In(r,e,t,o,i,a){var s=t&Tn,n=r.length,p=e.length;if(n!=p&&!(s&&p>n))return!1;var f=a.get(r),l=a.get(e);if(f&&l)return f==e&&l==r;var c=-1,d=!0,k=t&Rn?new zt:void 0;for(a.set(r,e),a.set(e,r);++c<n;){var b=r[c],v=e[c];if(o)var T=s?o(v,b,c,e,r,a):o(b,v,c,r,e,a);if(T!==void 0){if(T)continue;d=!1;break}if(k){if(!$t(e,function(z,$){if(!Qt(k,$)&&(b===z||i(b,z,t,o,a)))return k.push($)})){d=!1;break}}else if(!(b===v||i(b,v,t,o,a))){d=!1;break}}return a.delete(r),a.delete(e),d}var De=In;function Bn(r){var e=-1,t=Array(r.size);return r.forEach(function(o,i){t[++e]=[i,o]}),t}var Gt=Bn;function Ln(r){var e=-1,t=Array(r.size);return r.forEach(function(o){t[++e]=o}),t}var Wt=Ln;var Fn=1,Dn=2,Nn="[object Boolean]",Mn="[object Date]",jn="[object Error]",Un="[object Map]",qn="[object Number]",Hn="[object RegExp]",zn="[object Set]",$n="[object String]",Qn="[object Symbol]",Gn="[object ArrayBuffer]",Wn="[object DataView]",Kt=w?w.prototype:void 0,gr=Kt?Kt.valueOf:void 0;function Kn(r,e,t,o,i,a,s){switch(t){case Wn:if(r.byteLength!=e.byteLength||r.byteOffset!=e.byteOffset)return!1;r=r.buffer,e=e.buffer;case Gn:return!(r.byteLength!=e.byteLength||!a(new dr(r),new dr(e)));case Nn:case Mn:case qn:return Pe(+r,+e);case jn:return r.name==e.name&&r.message==e.message;case Hn:case $n:return r==e+"";case Un:var n=Gt;case zn:var p=o&Fn;if(n||(n=Wt),r.size!=e.size&&!p)return!1;var f=s.get(r);if(f)return f==e;o|=Dn,s.set(r,e);var l=De(n(r),n(e),o,i,a,s);return s.delete(r),l;case Qn:if(gr)return gr.call(r)==gr.call(e)}return!1}var Vt=Kn;var Vn=1,Jn=Object.prototype,Zn=Jn.hasOwnProperty;function Xn(r,e,t,o,i,a){var s=t&Vn,n=mr(r),p=n.length,f=mr(e),l=f.length;if(p!=l&&!s)return!1;for(var c=p;c--;){var d=n[c];if(!(s?d in e:Zn.call(e,d)))return!1}var k=a.get(r),b=a.get(e);if(k&&b)return k==e&&b==r;var v=!0;a.set(r,e),a.set(e,r);for(var T=s;++c<p;){d=n[c];var z=r[d],$=e[d];if(o)var Cr=s?o($,z,d,e,r,a):o(z,$,d,r,e,a);if(!(Cr===void 0?z===$||i(z,$,t,o,a):Cr)){v=!1;break}T||(T=d=="constructor")}if(v&&!T){var xe=r.constructor,be=e.constructor;xe!=be&&"constructor"in r&&"constructor"in e&&!(typeof xe=="function"&&xe instanceof xe&&typeof be=="function"&&be instanceof be)&&(v=!1)}return a.delete(r),a.delete(e),v}var Jt=Xn;var Yn=1,Zt="[object Arguments]",Xt="[object Array]",Ne="[object Object]",ef=Object.prototype,Yt=ef.hasOwnProperty;function rf(r,e,t,o,i,a){var s=y(r),n=y(e),p=s?Xt:cr(r),f=n?Xt:cr(e);p=p==Zt?Ne:p,f=f==Zt?Ne:f;var l=p==Ne,c=f==Ne,d=p==f;if(d&&le(r)){if(!le(e))return!1;s=!0,l=!1}if(d&&!l)return a||(a=new oe),s||_e(r)?De(r,e,t,o,i,a):Vt(r,e,p,t,o,i,a);if(!(t&Yn)){var k=l&&Yt.call(r,"__wrapped__"),b=c&&Yt.call(e,"__wrapped__");if(k||b){var v=k?r.value():r,T=b?e.value():e;return a||(a=new oe),i(v,T,t,o,a)}}return d?(a||(a=new oe),Jt(r,e,t,o,i,a)):!1}var eo=rf;function ro(r,e,t,o,i){return r===e?!0:r==null||e==null||!E(r)&&!E(e)?r!==r&&e!==e:eo(r,e,t,o,ro,i)}var Me=ro;var tf=1,of=2;function af(r,e,t,o){var i=t.length,a=i,s=!o;if(r==null)return!a;for(r=Object(r);i--;){var n=t[i];if(s&&n[2]?n[1]!==r[n[0]]:!(n[0]in r))return!1}for(;++i<a;){n=t[i];var p=n[0],f=r[p],l=n[1];if(s&&n[2]){if(f===void 0&&!(p in r))return!1}else{var c=new oe;if(o)var d=o(f,l,p,r,e,c);if(!(d===void 0?Me(l,f,tf|of,o,c):d))return!1}}return!0}var to=af;function sf(r){return r===r&&!V(r)}var je=sf;function nf(r){for(var e=Z(r),t=e.length;t--;){var o=e[t],i=r[o];e[t]=[o,i,je(i)]}return e}var oo=nf;function ff(r,e){return function(t){return t==null?!1:t[r]===e&&(e!==void 0||r in Object(t))}}var Ue=ff;function pf(r){var e=oo(r);return e.length==1&&e[0][2]?Ue(e[0][0],e[0][1]):function(t){return t===r||to(t,r,e)}}var ao=pf;function uf(r,e){return r!=null&&e in Object(r)}var io=uf;function lf(r,e,t){e=Te(e,r);for(var o=-1,i=e.length,a=!1;++o<i;){var s=N(e[o]);if(!(a=r!=null&&t(r,s)))break;r=r[s]}return a||++o!=i?a:(i=r==null?0:r.length,!!i&&J(i)&&Ee(s,i)&&(y(r)||Ae(r)))}var so=lf;function mf(r,e){return r!=null&&so(r,e,io)}var no=mf;var cf=1,df=2;function gf(r,e){return X(r)&&je(e)?Ue(N(r),e):function(t){var o=St(t,r);return o===void 0&&o===e?no(t,r):Me(e,o,cf|df)}}var fo=gf;function yf(r){return function(e){return e?.[r]}}var po=yf;function hf(r){return function(e){return Re(e,r)}}var uo=hf;function xf(r){return X(r)?po(N(r)):uo(r)}var lo=xf;function bf(r){return typeof r=="function"?r:r==null?Nr:typeof r=="object"?y(r)?fo(r[0],r[1]):ao(r):lo(r)}var mo=bf;function Cf(r,e,t,o){for(var i=-1,a=r==null?0:r.length;++i<a;){var s=r[i];e(o,s,t(s),r)}return o}var co=Cf;function wf(r){return function(e,t,o){for(var i=-1,a=Object(e),s=o(e),n=s.length;n--;){var p=s[r?n:++i];if(t(a[p],p,a)===!1)break}return e}}var go=wf;var kf=go(),yo=kf;function vf(r,e){return r&&yo(r,e,Z)}var ho=vf;function Sf(r,e){return function(t,o){if(t==null)return t;if(!Oe(t))return r(t,o);for(var i=t.length,a=e?i:-1,s=Object(t);(e?a--:++a<i)&&o(s[a],a,s)!==!1;);return t}}var xo=Sf;var Ef=xo(ho),bo=Ef;function Pf(r,e,t,o){return bo(r,function(i,a,s){e(o,i,t(i),s)}),o}var Co=Pf;function Of(r,e){return function(t,o){var i=y(t)?co:Co,a=e?e():{};return i(t,r,mo(o,2),a)}}var wo=Of;var Af=Object.prototype,_f=Af.hasOwnProperty,Tf=wo(function(r,e,t){_f.call(r,t)?r[t].push(e):Hr(r,t,[e])}),ce=Tf;var qe=class{canHandle(e){return e["dump-grouped"]===!0||e.D===!0}handle(e){let t=ce(e,o=>o.meta?.file??"unknown");u.log(JSON.stringify(t,null,2))}};function He(r,e={}){let{format:t="merged",showFilePaths:o=!0,separator:i="; "}=e;if(r.length===0)return t==="merged"?"":[];if(t==="merged")return r.map(s=>s.value).join(i);let a=ce(r,s=>s.meta?.file??"unknown");return Object.entries(a).map(([s,n])=>{let p=n.map(f=>f.value).join(i);return o?`${s}: ${p}`:p})}var ze=class{canHandle(e){return e["render-grouped"]===!0||e.R===!0}handle(e){u.log(He(e,{format:"grouped"}))}};var $e=class{canHandle(e){return e.output==="json"}handle(e){u.log(JSON.stringify(e,null,2))}};var Qe=class{canHandle(e){return e.render===!0||e["render-merged"]===!0||e.r===!0}handle(e){u.log(He(e,{format:"merged"}))}};var Ge=class{constructor(){this.validOutputFormats=["json"];this.handlers=[new Ce,new qe,new Qe,new ze,new $e,new pe]}validateOutputFormat(e){if(e.output!==void 0&&!this.validOutputFormats.includes(e.output)){let t=this.validOutputFormats.join(", ");throw new Error(`Invalid output format: '${e.output}'. Valid formats are: ${t}`)}}getHandler(e){return this.validateOutputFormat(e),this.handlers.find(t=>t.canHandle(e))??new pe}};var We=class{constructor(e){this.strategy=e}async queryCookies(e,t){return await this.strategy.queryCookies(e.name,e.domain,t?.store,t?.force)}};async function ko(r,e,t=[]){return r.length===0?t:(await Promise.all(r.map(async i=>{try{return await e(i)}catch{return t}}))).flat()}var de=class{constructor(e){this.strategies=e;this.logger=h("CompositeCookieQueryStrategy");this.browserName="internal"}handleStrategyError(e,t){e instanceof Error?this.logger.error("Strategy failed",{error:e,strategy:t}):this.logger.error("Strategy failed with unknown error",{error:String(e),strategy:t})}async queryCookies(e,t,o,i){try{return this.logger.info("Querying cookies from all strategies",{name:e,domain:t,store:o,force:i,strategyCount:this.strategies.length}),await ko(this.strategies,async a=>{try{return await a.queryCookies(e,t,o,i)}catch(s){return this.handleStrategyError(s,a),[]}},[])}catch(a){return a instanceof Error?this.logger.error("Failed to query cookies",{error:a}):this.logger.error("Failed to query cookies with unknown error",{error:String(a)}),[]}}};var Rf={info:()=>{},warn:()=>{},error:()=>{},debug:()=>{},success:()=>{},fatal:()=>{},log:()=>{}},M=class{constructor(e,t){this.browserName=t;let o=h(e);this.logger=o||Rf}async queryCookies(e,t,o,i){try{return this.logger.info("Querying cookies",{name:e,domain:t,store:o,force:i}),await this.executeQuery(e,t,o,i)}catch(a){return a instanceof Error?this.logger.error("Failed to query cookies",{error:a.message,browser:this.browserName,strategy:this.constructor.name,name:e,domain:t,store:o,force:i}):this.logger.error("Failed to query cookies",{error:String(a),browser:this.browserName,strategy:this.constructor.name,name:e,domain:t,store:o,force:i}),[]}}};var So=require("fs"),Ze=require("path"),Eo=R(require("fast-glob"),1);var vo=R(require("better-sqlite3"),1);var Ke=h("QuerySqliteThenTransform");function If(r){return new Promise(e=>setTimeout(e,r))}function Bf(r){if(r instanceof Error){let e=r.message.toLowerCase();return e.includes("database is locked")||e.includes("database locked")||e.includes("sqlite_busy")}return!1}function Lf(r){try{let e=new vo.default(r,{readonly:!0,fileMustExist:!0});try{e.pragma("journal_mode = WAL"),Ke.debug("Set WAL mode for database",{file:r})}catch(t){Ke.warn("Failed to set WAL mode, continuing with default",{file:r,error:t instanceof Error?t.message:String(t)})}return e}catch(e){throw I("Database open failed",e,{file:r}),e}}function Ff(r){try{return r.close(),Promise.resolve()}catch(e){return I("Database close failed",e),Promise.reject(e instanceof Error?e:new Error("Failed to close database: Unknown error"))}}async function Df(r){let{file:e,sql:t,params:o,rowFilter:i,rowTransform:a}=r,s;try{s=Lf(e);let p=s.prepare(t).all(o),f=i?p.filter(i):p;return a?f.map(a):f}finally{s&&await Ff(s)}}async function Ve(r){let{file:e,sql:t,retryAttempts:o=3}=r,i=[100,500,1e3],a;for(let s=0;s<o;s++)try{let n=await Df(r);return s>0&&Ke.info("Database query succeeded after retry",{file:e,attempt:s+1,totalAttempts:o}),n}catch(n){if(a=n,Bf(n)&&s<o-1){let p=i[s]||1e3;Ke.warn("Database locked, retrying after delay",{file:e,attempt:s+1,totalAttempts:o,delay:p,error:n instanceof Error?n.message:String(n)}),await If(p);continue}throw I("Database query failed",n,{file:e,sql:t,attempt:s+1}),n}throw a}var ge=require("os"),Je=require("path"),j=(()=>{let r=(0,ge.homedir)();if(!r)throw new Error("Unable to determine user home directory");switch((0,ge.platform)()){case"darwin":return(0,Je.join)(r,"Library","Application Support","Google","Chrome");case"win32":return(0,Je.join)(r,"AppData","Local","Google","Chrome","User Data");case"linux":return(0,Je.join)(r,".config","google-chrome");default:throw new Error(`Platform ${(0,ge.platform)()} is not supported`)}})();var ye=h("getEncryptedChromeCookie");function Nf(r){if(typeof r!="string")return!1;let e=r.trim();return e.length===0?!1:(0,So.existsSync)(e)}async function Mf(){let r=[(0,Ze.join)(j,"Default/Cookies"),(0,Ze.join)(j,"Profile */Cookies"),(0,Ze.join)(j,"Profile Default/Cookies")],e=[];for(let t of r){let o=await(0,Eo.default)(t);e.push(...o)}return ye.debug("ChromeCookies","Found cookie files",{count:e.length,files:e}),e}function jf(r,e){let t=r==="%",o=t?"SELECT name, encrypted_value, host_key, expires_utc FROM cookies WHERE host_key LIKE ?":"SELECT name, encrypted_value, host_key, expires_utc FROM cookies WHERE name = ? AND host_key LIKE ?",i=t?[`%${e}%`]:[r,`%${e}%`];return{sql:o,params:i}}async function Uf(r,e,t){try{let{sql:o,params:i}=jf(e,t);ye.debug("ChromeCookies","Executing query",{sql:o,params:i});let a=await Ve({file:r,sql:o,params:i,rowTransform:s=>({name:s.name,domain:s.host_key,value:s.encrypted_value,expiry:s.expires_utc})});return Or("QueryCookies",!0,{file:r,count:a.length}),a}catch(o){return I("Failed to read cookie file",o,{file:r}),[]}}async function Po({name:r,domain:e,file:t}){let o=typeof t=="string"&&t.length>0?[t]:await Mf();if(o.length===0)return ye.debug("ChromeCookies","No cookie files found"),[];let i=[];for(let a of o){if(!Nf(a)){ye.debug("ChromeCookies","Cookie file missing or invalid",{file:a});continue}let s=await Uf(a,r,e);i.push(...s)}return ye.debug("ChromeCookies","Query complete",{totalCookies:i.length}),i}var qf=require("fs"),Hf=require("path"),Oo=R(require("fast-glob"),1);var zf=h("listChromeProfiles");function Ao(){let r=Oo.default.sync("./**/Cookies",{cwd:j,absolute:!0});return zf.debug("Found cookie files:",r),r}var Xe=require("crypto"),yr=require("os");var _o=require("crypto");function To(r,e){let t=Buffer.from("v10");if(!r.subarray(0,3).equals(t))throw new Error("Not a v10 encrypted cookie");let o=r.subarray(3),i=12,a=16;if(o.length<i+a)throw new Error("Invalid v10 cookie: too short");let s=o.subarray(0,i),n=o.subarray(i,o.length-a),p=o.subarray(o.length-a),f=(0,_o.createDecipheriv)("aes-256-gcm",e,s);return f.setAuthTag(p),Buffer.concat([f.update(n),f.final()]).toString("utf8")}function Ro(r){let e=Buffer.from("v10");return r.length>=3&&r.subarray(0,3).equals(e)}function Io(r,e){let t=new Map;return o=>{let i=e?e(o):o.toString("hex");if(t.has(i)){let s=t.get(i);if(s!==void 0)return s}let a=r(o);return t.set(i,a),a}}var $f=Io(r=>r.length>=3&&r[0]===118&&r[1]===49&&r[2]===48?r.slice(3):r,r=>r.toString("hex")),Qf=Io(r=>{let e=r[r.length-1];return e&&e<=16?r.slice(0,-e):r},r=>r.toString("hex"));function Gf(r){let e=r.match(/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/i);if(e)return e[1];let t=[/([A-Z]{3})$/,/([a-z]{2}_[A-Z]{2})$/,/(\d{3}-\d{7}-\d{7})$/];for(let i of t){let a=r.match(i);if(a)return a[1]}let o=[/.*?0t(.+)$/,/.*?1e`(.+)$/,/.*?[`'](.+)$/,/[^\x20-\x7E]*([\x20-\x7E]+)$/,/.*?([a-zA-Z0-9_\-\.]+)$/];for(let i of o){let s=r.match(i)?.[1]??"";if(s.length>0)return s}return r}async function Bo(r,e,t){if((0,yr.platform)()==="win32"&&Ro(r)&&r.length>=31&&Buffer.isBuffer(e))return To(r,e);if((0,yr.platform)()==="darwin"&&!r.slice(0,3).toString().match(/^v\d\d$/))return Promise.resolve(r.toString("utf8"));if(typeof e!="string")throw new Error("password must be a string");if(!Buffer.isBuffer(r))throw new Error("encryptedData must be a Buffer");return new Promise((o,i)=>{(0,Xe.pbkdf2)(e,"saltysalt",1003,16,"sha1",(a,s)=>{try{if(a){i(new Error(`Failed to derive key: ${a.message}`));return}let n=$f(r);if(n.length%16!==0){i(new Error("Encrypted data length is not a multiple of 16"));return}let p=Buffer.alloc(16," "),f=(0,Xe.createDecipheriv)("aes-128-cbc",s,p);f.setAutoPadding(!1);let l=f.update(n);try{f.final()}catch(b){i(new Error(`Failed to finalize decryption: ${b.message}`));return}l=Qf(l);let k=((t||0)>=24&&l.length>32?l.slice(32):l).toString("utf8");o(Gf(k))}catch(n){i(new Error(`Decryption failed: ${n.message}`))}})})}var xr=require("os");var Lo=require("child_process"),Fo=require("util");var Wf=(0,Fo.promisify)(Lo.exec),hr=class extends Error{constructor(t,o,i){super(t);this.command=o;this.originalError=i;this.name="CommandExecutionError"}};async function U(r,e){try{let t=await Wf(r,{...e,encoding:"utf8"});return{stdout:t.stdout.toString(),stderr:t.stderr.toString()}}catch(t){throw I("Command execution failed",t,{command:r}),new hr(t instanceof Error?t.message:String(t),r,t instanceof Error?t:void 0)}}async function Do(){try{let t=(await U("secret-tool lookup application chrome-libsecret-password-v2 || secret-tool lookup application chrome")).stdout.trim();if(t)return t}catch{}try{let t=(await U(`python3 -c "import keyring; print(keyring.get_password('Chrome Safe Storage', 'Chrome'))"`)).stdout.trim();if(t&&t!=="None")return t}catch{}try{let t=(await U('kwallet-query kdewallet -f "Chrome Safe Storage" -r Chrome')).stdout.trim();if(t)return t}catch{}return"peanuts"}async function No(){return(await U('security find-generic-password -w -s "Chrome Safe Storage"')).stdout.trim()}var Mo=require("fs"),jo=require("path");async function Kf(r){let e=Buffer.from("DPAPI");if(!r.subarray(0,5).equals(e))throw new Error("Invalid DPAPI key prefix");let t=r.subarray(5);if(process.platform==="win32")try{let o=await import("@primno/dpapi").then(i=>i).catch(()=>null);if(o)return o.unprotectData(t)}catch(o){console.warn("DPAPI module not available, using fallback:",o)}throw new Error("Windows DPAPI decryption requires native bindings. Install @primno/dpapi package for Windows support.")}async function Uo(){try{let r=(0,jo.join)(j,"Local State"),e=(0,Mo.readFileSync)(r,"utf8"),t=JSON.parse(e);if(!t.os_crypt?.encrypted_key)throw new Error("No encrypted key found in Chrome Local State");let o=Buffer.from(t.os_crypt.encrypted_key,"base64");return(await Kf(o)).toString("latin1")}catch(r){throw new Error(`Failed to retrieve Chrome password on Windows: ${r instanceof Error?r.message:String(r)}`)}}async function qo(){switch((0,xr.platform)()){case"darwin":return await No();case"win32":return await Uo();case"linux":return await Do();default:throw new Error(`Platform ${(0,xr.platform)()} is not supported`)}}function Vf(r){return typeof r!="number"||r<=0?"Infinity":new Date(r)}function Ho(r,e,t,o,i,a){return{domain:r,name:e,value:t,expiry:Vf(o),meta:{file:i,browser:"Chrome",decrypted:a}}}var ae=class extends M{constructor(){super("ChromeCookieQueryStrategy","Chrome")}async executeQuery(e,t,o,i){let a=["darwin","win32","linux"];if(!a.includes(process.platform))return this.logger.warn("Platform not supported",{platform:process.platform,supportedPlatforms:a}),[];let s=o??Ao(),n=Array.isArray(s)?s:[s];if(n.length===0)return this.logger.warn("No Chrome cookie files found"),[];let p=await qo();return(await Promise.all(n.map(l=>this.processFile(l,e,t,p)))).flat()}async processFile(e,t,o,i){try{let a=await Po({name:t,domain:o,file:e}),s=0;try{let f=await import("better-sqlite3"),l=new f.default(e,{readonly:!0});try{let c=l.prepare("SELECT value FROM meta WHERE key = ?").get("version");s=c?Number.parseInt(c.value,10):0}finally{l.close()}}catch(f){this.logger.debug("Could not retrieve meta version, defaulting to 0",{error:f})}let n={file:e,password:i,metaVersion:s};return(await Promise.allSettled(a.map(f=>this.processCookie(f,n)))).map(f=>f.status==="fulfilled"?f.value:null).filter(f=>f!==null)}catch(a){return a instanceof Error?this.logger.error("Failed to process cookie file",{error:a.message,file:e,name:t,domain:o}):this.logger.error("Failed to process cookie file",{error:String(a),file:e,name:t,domain:o}),[]}}async processCookie(e,t){try{let o=Buffer.isBuffer(e.value)?e.value:Buffer.from(String(e.value)),i=await Bo(o,t.password,t.metaVersion);return Ho(e.domain,e.name,i,e.expiry,t.file,!0)}catch(o){return o instanceof Error?this.logger.warn("Failed to decrypt cookie",{error:o}):this.logger.warn("Failed to decrypt cookie",{error:String(o)}),Ho(e.domain,e.name,e.value.toString("utf-8"),e.expiry,t.file,!1)}}};var Go=require("os"),br=require("path"),Wo=R(require("fast-glob"),1);var zo=h("ProcessDetector");function Jf(r,e){let t=r.trim().split(/\s+/);if(t.length<2)return null;let o=Number.parseInt(t[1],10);return Number.isNaN(o)?null:{pid:o,command:t.slice(10).join(" ")||e,details:r.trim()}}async function $o(){try{let r="ps aux | grep -i firefox | grep -v grep",{stdout:e}=await U(r);if(!e||e.trim()==="")return[];let t=[],o=e.split(`
|
|
3
|
+
`).filter(i=>i.trim()!=="");for(let i of o){let a=Jf(i,"firefox");a&&t.push(a)}return zo.debug("Firefox process detection completed",{processCount:t.length,processes:t.map(i=>({pid:i.pid,command:i.command}))}),t}catch(r){return zo.warn("Failed to detect Firefox processes",{error:r instanceof Error?r.message:String(r)}),[]}}function Qo(r,e){if(e.length===0)return"";let t=e.length,o=r.charAt(0).toUpperCase()+r.slice(1);return`${o} is currently running (${t} process${t>1?"es":""} detected). For reliable cookie access, consider closing ${o} and trying again. Alternatively, use the --force flag to attempt access despite the lock.`}function Zf(r){let e=(0,Go.homedir)();if(!e)return r.warn("Failed to get home directory"),[];let t=[(0,br.join)(e,"Library/Application Support/Firefox/Profiles/*/cookies.sqlite"),(0,br.join)(e,".mozilla/firefox/*/cookies.sqlite")],o=[];for(let i of t){let a=Wo.default.sync(i);o.push(...a)}return r.debug("Found Firefox cookie files",{files:o}),o}var ie=class extends M{constructor(){super("FirefoxCookieQueryStrategy","Firefox")}async handleDatabaseLockError(e,t){if(e instanceof Error&&e.message.toLowerCase().includes("database is locked"))try{let o=await $o();if(o.length>0){let i=Qo("firefox",o);this.logger.warn("Firefox process conflict detected",{file:t,processCount:o.length,advice:i})}else this.logger.warn("Database locked but no Firefox processes detected",{file:t,suggestion:"Another process may be accessing the database"})}catch(o){this.logger.debug("Failed to check Firefox processes",{error:o instanceof Error?o.message:String(o)})}}async executeQuery(e,t,o,i){let a=o??Zf(this.logger),s=Array.isArray(a)?a:[a],n=[];for(let p of s)try{let f=await Ve({file:p,sql:"SELECT name, value, host as domain, expiry FROM moz_cookies WHERE name = ? AND host LIKE ?",params:[e,`%${t}%`],rowTransform:l=>({name:l.name,value:l.value,domain:l.domain,expiry:l.expiry>0?new Date(l.expiry*1e3):"Infinity",meta:{file:p,browser:"Firefox",decrypted:!1}})});n.push(...f)}catch(f){await this.handleDatabaseLockError(f,p),f instanceof Error?this.logger.warn(`Error reading Firefox cookie file ${p}`,{error:f.message,file:p,name:e,domain:t}):this.logger.warn(`Error reading Firefox cookie file ${p}`,{error:String(f),file:p,name:e,domain:t})}return n}};var oa=require("os"),aa=require("path");var Xo=require("buffer"),Yo=require("fs"),ea=require("os"),ra=require("path");var he=require("buffer");var Ko=R(require("destr"),1),m=require("zod"),Ye=m.z.string().trim().min(1,"Domain cannot be empty").refine(r=>/^\.?[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(r),"Invalid domain format"),er=m.z.string().trim().min(1,"Cookie name cannot be empty").refine(r=>r==="%"||/^[!#$%&'()*+\-.:0-9A-Z \^_`a-z|~]+$/.test(r),"Invalid cookie name format - must contain only valid characters (letters, numbers, and certain symbols) or be '%' for wildcard"),Vo=m.z.string().trim().min(1,"Path cannot be empty").refine(r=>r.startsWith("/"),"Path must start with /").refine(r=>/^\/[!#$%&'()*+,\-./:=@\w~]*$/.test(r),"Invalid path format - must contain only valid URL path characters").default("/"),Jo=m.z.string().trim().transform(r=>(0,Ko.default)(r)).pipe(m.z.any()),Zo=m.z.object({name:er,value:Jo,domain:Ye,path:Vo,expiry:m.z.number().int(),creation:m.z.number().int(),flags:m.z.number().optional(),version:m.z.number().int().optional(),port:m.z.number().int().optional(),comment:m.z.string().optional(),commentURL:m.z.string().optional()}),Ny=m.z.object({name:er,domain:Ye}).strict(),Xf=m.z.object({file:m.z.string().trim().min(1,"File path cannot be empty").optional(),browser:m.z.string().trim().optional(),decrypted:m.z.boolean().optional(),secure:m.z.boolean().optional(),httpOnly:m.z.boolean().optional(),path:Vo.optional()}).catchall(m.z.unknown()).strict(),Yf=m.z.object({domain:Ye,name:er,value:Jo,expiry:m.z.union([m.z.literal("Infinity"),m.z.date(),m.z.number().int().positive("Expiry must be a positive number")]).optional(),meta:Xf.optional()}).strict(),My=m.z.object({expiry:m.z.number().int().optional(),domain:Ye,name:er,value:m.z.union([m.z.string(),m.z.instanceof(Buffer)])}).strict(),jy=m.z.object({format:m.z.enum(["merged","grouped"]).optional(),separator:m.z.string().optional(),showFilePaths:m.z.boolean().optional()}).strict(),ep=m.z.enum(["Chrome","Firefox","Safari","internal","unknown"]),Uy=m.z.object({browserName:ep,queryCookies:m.z.function().args(m.z.string(),m.z.string(),m.z.string().optional(),m.z.boolean().optional()).returns(m.z.promise(m.z.array(Yf)))}).strict();var q=h("BinaryCodableCookie"),rr=class{constructor(e){this.version=0;this.url="";this.name="";this.path="";this.value="";this.flags={isSecure:!1,isHTTPOnly:!1,unknown1:!1,unknown2:!1};this.expiration=0;this.creation=0;let t={offset:0,buffer:e};this.decode(t)}decodeUrlValue(e){let t=e,o;do{o=t;try{t=decodeURIComponent(t)}catch{return o}}while(t!==o&&t.includes("%"));return t}decodeJwtPayload(e){let t=e.split(".");if(t.length!==3)return null;try{let o=he.Buffer.from(t[1],"base64").toString("utf8"),i=JSON.parse(o);return JSON.stringify(i)}catch{return null}}parseJsonValue(e){try{let t=JSON.parse(e);return JSON.stringify(t)}catch{return null}}processValue(e){if(e===null)return"null";if(e===void 0)return"undefined";if(he.Buffer.isBuffer(e))return e.toString();if(typeof e!="string")return String(e);let t=this.decodeUrlValue(e);if(t.match(/^ey[A-Za-z0-9_-]+\.ey[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/)){let o=this.decodeJwtPayload(t);if(typeof o=="string"&&o.length>0)return o}if(t.startsWith("{")||t.startsWith("[")){let o=this.parseJsonValue(t);if(typeof o=="string"&&o.length>0)return o}return t}convertMacTimestamp(e){return e<=0?e:e>=0&&e<=1e9&&Number.isFinite(e)?e+978307200:0}toCookieRow(){try{let e=this.convertFlags(),t=this.url.replace(/^https?:\/\//,"").replace(/\/.*$/,"")||"uk",o=this.convertMacTimestamp(this.expiration),i=this.convertMacTimestamp(this.creation);return Zo.parse({name:this.name.replace(/^: /,""),value:this.processValue(this.value)||"",domain:t,path:this.path||"/",expiry:o,creation:i,flags:e,version:this.version,port:this.port,comment:this.comment,commentURL:this.commentURL})}catch{return null}}readNullTerminatedString(e,t){let o=t;for(;o<e.buffer.length&&e.buffer[o]!==0;)o++;return e.buffer.toString("utf8",t,o)||""}readHeader(e){let t=e.buffer.readUInt32LE(e.offset);q.debug("Cookie size:",t),e.offset+=4;let o=e.buffer.readUInt32LE(e.offset);q.debug("Cookie version:",o),e.offset+=4;let i=e.buffer.readUInt32LE(e.offset);q.debug("Cookie flags:",i.toString(2).padStart(8,"0")),e.offset+=4,this.flags={isSecure:(i&1)!==0,isHTTPOnly:(i&4)!==0,unknown1:(i&8)!==0,unknown2:(i&16)!==0};let a=e.buffer.readUInt32LE(e.offset);q.debug("Has port:",a),e.offset+=4;let s={urlOffset:e.buffer.readUInt32LE(e.offset),nameOffset:e.buffer.readUInt32LE(e.offset+4),pathOffset:e.buffer.readUInt32LE(e.offset+8),valueOffset:e.buffer.readUInt32LE(e.offset+12),commentOffset:e.buffer.readUInt32LE(e.offset+16),commentURLOffset:e.buffer.readUInt32LE(e.offset+20)};return q.debug("String offsets:",s),{size:t,hasPort:a,offsets:s}}readTimestamps(e){let t=he.Buffer.alloc(8);for(let s=0;s<8;s++)t[s]=e.buffer[e.offset+s];let o=t.readDoubleLE(0);e.offset+=8;let i=he.Buffer.alloc(8);for(let s=0;s<8;s++)i[s]=e.buffer[e.offset+s];let a=i.readDoubleLE(0);e.offset+=8,this.expiration=o,this.creation=a}readStrings(e,t,o){q.debug("Reading strings from cookie buffer of size:",t);let a=[{field:"url",offset:o.urlOffset},{field:"name",offset:o.nameOffset},{field:"path",offset:o.pathOffset},{field:"value",offset:o.valueOffset},{field:"comment",offset:o.commentOffset}].filter(s=>s.offset>0).sort((s,n)=>s.offset-n.offset);q.debug("Reading strings in order:",a.map(s=>s.field));for(let s=0;s<a.length;s++){let{field:n,offset:p}=a[s],l=(s<a.length-1?a[s+1].offset:t)-p,c=0+p;for(;c<0+p+l&&e.buffer[c]!==0;)c++;let d=e.buffer.toString("utf8",0+p,c);switch(q.debug(`Read ${n}:`,d),n){case"url":this.url=d;break;case"name":this.name=d;break;case"path":this.path=d;break;case"value":this.value=d;break;case"comment":this.comment=d;break}}}decode(e){let{size:t,hasPort:o,offsets:i}=this.readHeader(e),a=e.offset;e.offset=a+24,this.readTimestamps(e),o>0&&(this.port=e.buffer.readUInt16LE(e.offset),e.offset+=2),e.offset=a,this.readStrings(e,t,i)}convertFlags(){return(this.flags.isSecure?1:0)|(this.flags.isHTTPOnly?4:0)|(this.flags.unknown1?8:0)|(this.flags.unknown2?16:0)}};var P=h("BinaryCodablePage"),se=class se{constructor(e){this.cookies=[];let t={offset:0,buffer:e};this.decode(t)}toCookieRows(){let e=[];for(let t of this.cookies)try{let o=t.toCookieRow();o!==null&&e.push(o)}catch(o){let i=o instanceof Error?o.message:String(o);W("BinaryCookies","Error converting cookie",{error:i})}return e}decode(e){let t=e.buffer.readUInt32BE(e.offset);if(P.debug("Page header:",t.toString(16)),e.offset+=4,t!==se.HEADER)throw new Error("Invalid page header");let o=e.buffer.readUInt32LE(e.offset);P.debug("Cookie count:",o),e.offset+=4;let i=e.offset-8;P.debug("Page start offset:",i);let a=[];for(let n=0;n<o;n++){let p=e.buffer.readUInt32LE(e.offset);a.push(p),P.debug(`Cookie ${n} offset:`,p),e.offset+=4}let s=e.buffer.readUInt32BE(e.offset);if(P.debug("Page footer:",s.toString(16)),e.offset+=4,s!==se.FOOTER)throw new Error("Invalid page footer");for(let n=0;n<o;n++)try{let p=a[n];P.debug(`Reading cookie ${n} at offset:`,p);let f=e.buffer.readUInt32LE(p);if(P.debug(`Cookie ${n} size:`,f),f<48){P.warn(`Invalid cookie size ${f} at index ${n}`);continue}if(p+f>e.buffer.length){P.warn(`Cookie size ${f} at index ${n} would exceed buffer length ${e.buffer.length}`);continue}let l=e.buffer.subarray(p,p+f),c=new rr(l);this.cookies.push(c)}catch(p){P.warn("Invalid cookie data",{error:p instanceof Error?p.message:String(p)})}}};se.HEADER=256,se.FOOTER=0;var tr=se;var H=h("BinaryCodableCookies"),O=class O{constructor(e){let t={offset:0,buffer:e};this.pages=[],this.metadata={},this.decode(t)}static fromFile(e){let t=(0,Yo.readFileSync)(e);return new O(t)}static fromDefaultPath(){return O.fromFile(O.DEFAULT_COOKIE_PATH)}toCookieRows(){let e=[];for(let t of this.pages)try{let o=t.toCookieRows();Array.isArray(o)&&e.push(...o)}catch(o){let i=o instanceof Error?o.message:String(o);W("BinaryCookies","Error converting page cookies",{error:i})}return e}decode(e){try{let t=e.buffer.subarray(e.offset,e.offset+4);if(e.offset+=4,H.debug("Magic bytes:",t.toString()),!t.equals(O.MAGIC))throw new Error("Missing magic value");let o=e.buffer.readUInt32BE(e.offset);H.debug("Page count:",o),e.offset+=4;let i=[];for(let f=0;f<o;f++){let l=e.buffer.readUInt32BE(e.offset);i.push(l),H.debug(`Page ${f} size:`,l),e.offset+=4}let a=e.offset;H.debug("Starting page data at offset:",a);for(let f of i)try{H.debug("Reading page at offset:",a,"with size:",f);let l=e.buffer.subarray(a,a+f),c=new tr(l);this.pages.push(c),a+=f}catch(l){let c=l instanceof Error?l.message:String(l);H.warn("Error decoding page:",{error:c}),a+=f}e.offset=a;let s=e.buffer.readUInt32BE(e.offset);H.debug("Checksum:",s.toString(16)),e.offset+=4;let n=e.buffer.readBigUInt64BE(e.offset);H.debug("Footer:",n.toString(16)),e.offset+=8,n!==O.FOOTER&&W("BinaryCookies","Invalid cookie file format: wrong footer");let p=e.buffer.subarray(e.offset);this.metadata={}}catch(t){let o=t instanceof Error?t.message:String(t);throw W("BinaryCookies","Error decoding binary cookies file",{error:o}),t}}};O.MAGIC=Xo.Buffer.from("cook","utf8"),O.FOOTER=BigInt("0x071720050000004b"),O.DEFAULT_COOKIE_PATH=(0,ra.join)((0,ea.homedir)(),"Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies");var or=O;function ta(r){return or.fromFile(r).toCookieRows()}var ne=class extends M{constructor(){super("SafariCookieQueryStrategy","Safari")}getCookieDbPath(e){return(0,aa.join)(e,"Library","Containers","com.apple.Safari","Data","Library","Cookies","Cookies.binarycookies")}formatDomain(e){return e.startsWith(".")?e.slice(1):e}formatExpiry(e){if(e==null){let i=new Date;return Object.defineProperty(i,"valueOf",{value:()=>Number.NaN}),Object.defineProperty(i,"getTime",{value:()=>Number.NaN}),i}return typeof e!="number"||Number.isNaN(e)||e<=0?"Infinity":e<0||e>4102444800?(this.logger.warn("Invalid expiry timestamp, treating as session cookie",{expiry:e}),"Infinity"):new Date(e*1e3)}isFlagSet(e,t){return typeof e!="number"||Number.isNaN(e)||e<=0?!1:(e&t)===t}formatCreation(e){if(typeof e!="number"||Number.isNaN(e)||e<=0)return;if(e<0||e>4102444800){this.logger.warn("Invalid creation timestamp, ignoring",{creation:e});return}return e*1e3}processValue(e){return e===null?"null":e===void 0?"undefined":Buffer.isBuffer(e)?e.toString():String(e)}decodeCookies(e,t,o){try{return ta(e).filter(a=>(t==="%"||a.name===t)&&(o==="%"||this.formatDomain(a.domain).includes(o))).map(a=>({domain:this.formatDomain(a.domain),name:a.name,value:this.processValue(a.value),expiry:this.formatExpiry(a.expiry),meta:{file:e,browser:"Safari",decrypted:!1,secure:this.isFlagSet(a.flags,1),httpOnly:this.isFlagSet(a.flags,4),path:a.path,version:a.version,comment:a.comment,commentURL:a.commentURL,port:a.port,creation:this.formatCreation(a.creation)}}))}catch(i){return i instanceof Error?this.logger.error(`Error decoding ${e}`,{error:i.message,file:e,name:t,domain:o}):this.logger.error(`Error decoding ${e}`,{error:String(i),file:e,name:t,domain:o}),[]}}executeQuery(e,t,o,i){try{this.logger.info("Querying cookies",{name:e,domain:t,store:o});let a=(0,oa.homedir)();if(typeof a!="string"||a.length===0)return this.logger.error("Failed to get home directory"),Promise.resolve([]);let s=o??this.getCookieDbPath(a);return Promise.resolve(this.decodeCookies(s,e||"%",t||"%"))}catch(a){return a instanceof Error?this.logger.error("Failed to query cookies",{error:a.message,name:e,domain:t}):this.logger.error("Failed to query cookies",{error:String(a),name:e,domain:t}),Promise.resolve([])}}};var ia={strategies:new Map([["safari",ne],["firefox",ie],["chrome",ae]]),createStrategy(r){if(typeof r!="string")return new de([new ne,new ie,new ae]);let e=this.strategies.get(r.toLowerCase());return e!==void 0?new e:new de([new ne,new ie,new ae])}};async function rp(r,e,t){let o=[];for(let i of e){let a=await r.queryCookies(i,t);if(o=[...o,...a],typeof t.limit=="number"&&t.limit>0&&o.length>=t.limit){o=o.slice(0,t.limit);break}}return o}async function sa(r,e,t,o=!1,i){try{let a=typeof r.browser=="string"?r.browser:void 0,s=typeof r.force=="boolean"?r.force:!1,n=ia.createStrategy(a),p=new We(n),f=Array.isArray(e)?e:[e],l=await rp(p,f,{limit:t,removeExpired:o,store:i,strategy:n,force:s});if(l.length===0){u.error("No results");return}new Ge().getHandler(r).handle(l)}catch(a){a instanceof Error?u.error(a.message):u.error("An unknown error occurred")}}function tp(){u.log("Usage: get-cookie [name] [domain] [options]"),u.log(""),u.log("Examples:"),u.log(" get-cookie auth example.com # Get specific cookie"),u.log(" get-cookie % github.com --output json # Get all cookies as JSON"),u.log(" get-cookie --url https://example.com # Extract from URL"),u.log(""),u.log("Options:"),u.log(" -h, --help Show this help message"),u.log(" -v, --verbose Enable verbose output"),u.log(" -f, --force Force operation despite warnings (e.g., locked databases)"),u.log(""),u.log("Query options:"),u.log(" -n, --name PATTERN Cookie name pattern (% for wildcard)"),u.log(" -D, --domain PATTERN Cookie domain pattern"),u.log(" -u, --url URL URL to extract cookie specs from"),u.log(" --browser BROWSER Target specific browser (chrome|firefox|safari)"),u.log(" --store PATH Path to a specific cookie store file"),u.log(""),u.log("Output options:"),u.log(" --output FORMAT Output format (json)"),u.log(" -d, --dump Dump all cookie details"),u.log(" -G, --dump-grouped Dump all results, grouped by profile"),u.log(" -r, --render Render all results in formatted output")}function op(r,e){return{name:r||"%",domain:e||"%"}}function na(r){return r==="*"?"%":r}function ap(r,e){let t=r.url;if(typeof t=="string"){let a=ar(t);return Array.isArray(a)?a:(u.error("Invalid cookie specs from URL"),[])}let o=na(r.name||e[0]||"%"),i=na(r.domain||e[1]||"%");return[op(o,i)]}async function ip(r,e){let t=ap(r,e);r.verbose===!0&&u.log("cookieSpecs",t);try{await sa(r,t,void 0,r.removeExpired===!0,r.store)}catch(o){o instanceof Error?u.error("Error querying cookies:",o.message):u.error("An unknown error occurred while querying cookies")}}async function sp(){let r=process.argv.slice(2),{values:e,positionals:t}=vr(r);if(e.help===!0){tp();return}await ip(e,t)}sp().catch(r=>{r instanceof Error?u.error("Fatal error:",r.message):u.error("An unknown fatal error occurred"),process.exit(1)});
|
|
3
4
|
/*! Bundled license information:
|
|
4
5
|
|
|
5
6
|
lodash-es/lodash.js:
|