@mherod/get-cookie 4.4.3 ā 4.5.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/README.md +21 -3
- package/dist/bun.cjs +77 -0
- package/dist/bun.cjs.map +1 -0
- package/dist/bun.d.cts +3 -0
- package/dist/bun.d.ts +3 -0
- package/dist/bun.js +77 -0
- package/dist/bun.js.map +1 -0
- package/dist/cli.cjs +14 -11
- 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 +98 -38
- package/dist/index.d.ts +98 -38
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/node.cjs +77 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +3 -0
- package/dist/node.d.ts +3 -0
- package/dist/node.js +77 -0
- package/dist/node.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +32 -14
- package/.claude/settings.local.json +0 -3
- package/.dependency-cruiser.js +0 -277
- package/.env.example +0 -5
- package/.husky/commit-msg +0 -19
- package/.husky/pre-commit +0 -29
- package/.husky/pre-push +0 -21
- package/.idea/codeStyles/Project.xml +0 -59
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/get-cookie.iml +0 -13
- package/.idea/git_toolbox_prj.xml +0 -15
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/prettier.xml +0 -9
- package/.idea/runConfigurations/build.xml +0 -12
- package/.idea/vcs.xml +0 -6
- package/.nvmrc +0 -1
- package/biome.json +0 -117
- package/commitlint.config.js +0 -12
- package/eslint.config.js +0 -255
- package/examples/README.md +0 -71
- package/examples/advanced-usage.ts +0 -56
- package/examples/auth-tokens.ts +0 -143
- package/examples/basic-usage.ts +0 -43
- package/examples/cli-examples.sh +0 -51
- package/examples/comprehensive-demo.ts +0 -202
- package/examples/curl-integration.sh +0 -311
- package/examples/features-demo.sh +0 -260
- package/examples/github-auth.sh +0 -295
- package/examples/quick-start.sh +0 -115
- package/jest.setup.js +0 -34
- package/tsconfig.build.json +0 -9
- package/tsconfig.cli.json +0 -16
- package/tsconfig.tsup.json +0 -12
- package/tsup.cli.ts +0 -59
- package/tsup.lib.ts +0 -46
- package/typedoc.json +0 -17
package/biome.json
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/2.0.6/schema.json",
|
|
3
|
-
"vcs": {
|
|
4
|
-
"enabled": true,
|
|
5
|
-
"clientKind": "git",
|
|
6
|
-
"useIgnoreFile": true,
|
|
7
|
-
"defaultBranch": "main"
|
|
8
|
-
},
|
|
9
|
-
"files": {
|
|
10
|
-
"ignoreUnknown": false,
|
|
11
|
-
"includes": [
|
|
12
|
-
"**",
|
|
13
|
-
"!**/dist/**",
|
|
14
|
-
"!**/node_modules/**",
|
|
15
|
-
"!**/coverage/**",
|
|
16
|
-
"!**/docs/.vitepress/cache/**",
|
|
17
|
-
"!**/*.log",
|
|
18
|
-
"!**/.parcel-cache/**"
|
|
19
|
-
]
|
|
20
|
-
},
|
|
21
|
-
"formatter": {
|
|
22
|
-
"enabled": true,
|
|
23
|
-
"useEditorconfig": true,
|
|
24
|
-
"formatWithErrors": false,
|
|
25
|
-
"indentStyle": "space",
|
|
26
|
-
"indentWidth": 2,
|
|
27
|
-
"lineEnding": "lf",
|
|
28
|
-
"lineWidth": 80,
|
|
29
|
-
"attributePosition": "auto",
|
|
30
|
-
"bracketSpacing": true
|
|
31
|
-
},
|
|
32
|
-
"assist": { "actions": { "source": { "organizeImports": "off" } } },
|
|
33
|
-
"linter": {
|
|
34
|
-
"enabled": true,
|
|
35
|
-
"rules": {
|
|
36
|
-
"recommended": true,
|
|
37
|
-
"correctness": {
|
|
38
|
-
"noUnusedImports": "error",
|
|
39
|
-
"noUnusedVariables": "error"
|
|
40
|
-
},
|
|
41
|
-
"style": {
|
|
42
|
-
"useImportType": "error",
|
|
43
|
-
"noNamespace": "error",
|
|
44
|
-
"noNonNullAssertion": "error",
|
|
45
|
-
"useAsConstAssertion": "error",
|
|
46
|
-
"useBlockStatements": "error",
|
|
47
|
-
"useConst": "error",
|
|
48
|
-
"useLiteralEnumMembers": "error",
|
|
49
|
-
"noParameterAssign": "error",
|
|
50
|
-
"useDefaultParameterLast": "error",
|
|
51
|
-
"useEnumInitializers": "error",
|
|
52
|
-
"useSelfClosingElements": "error",
|
|
53
|
-
"useSingleVarDeclarator": "error",
|
|
54
|
-
"noUnusedTemplateLiteral": "error",
|
|
55
|
-
"useNumberNamespace": "error",
|
|
56
|
-
"noInferrableTypes": "error",
|
|
57
|
-
"noUselessElse": "error",
|
|
58
|
-
"useArrayLiterals": "off"
|
|
59
|
-
},
|
|
60
|
-
"complexity": {
|
|
61
|
-
"noStaticOnlyClass": "error",
|
|
62
|
-
"noUselessCatch": "error",
|
|
63
|
-
"noUselessConstructor": "error",
|
|
64
|
-
"noUselessTypeConstraint": "error",
|
|
65
|
-
"useOptionalChain": "error"
|
|
66
|
-
},
|
|
67
|
-
"suspicious": {
|
|
68
|
-
"noConfusingVoidType": "error",
|
|
69
|
-
"noDoubleEquals": "error",
|
|
70
|
-
"noExplicitAny": "error",
|
|
71
|
-
"noExtraNonNullAssertion": "error",
|
|
72
|
-
"noMisleadingInstantiator": "error",
|
|
73
|
-
"noPrototypeBuiltins": "error",
|
|
74
|
-
"noUnsafeDeclarationMerging": "error",
|
|
75
|
-
"useAwait": "off",
|
|
76
|
-
"useNamespaceKeyword": "error",
|
|
77
|
-
"noAsyncPromiseExecutor": "error",
|
|
78
|
-
"noMisleadingCharacterClass": "error",
|
|
79
|
-
"noThenProperty": "error",
|
|
80
|
-
"noVar": "error"
|
|
81
|
-
},
|
|
82
|
-
"nursery": {
|
|
83
|
-
"useSortedClasses": "off"
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
"javascript": {
|
|
88
|
-
"formatter": {
|
|
89
|
-
"jsxQuoteStyle": "double",
|
|
90
|
-
"quoteProperties": "asNeeded",
|
|
91
|
-
"trailingCommas": "all",
|
|
92
|
-
"semicolons": "always",
|
|
93
|
-
"arrowParentheses": "always",
|
|
94
|
-
"bracketSameLine": false,
|
|
95
|
-
"quoteStyle": "double",
|
|
96
|
-
"attributePosition": "auto",
|
|
97
|
-
"bracketSpacing": true
|
|
98
|
-
},
|
|
99
|
-
"globals": ["exports"]
|
|
100
|
-
},
|
|
101
|
-
"overrides": [
|
|
102
|
-
{
|
|
103
|
-
"includes": ["**/.prettierrc/**", "**/.parcelrc/**"],
|
|
104
|
-
"formatter": { "indentWidth": 2 }
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
"includes": ["**/*.test.ts", "**/*.spec.ts", "**/BinaryCodable*.ts"],
|
|
108
|
-
"linter": {
|
|
109
|
-
"rules": {
|
|
110
|
-
"style": {
|
|
111
|
-
"noNonNullAssertion": "off"
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
]
|
|
117
|
-
}
|
package/commitlint.config.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
extends: ["@commitlint/config-conventional"],
|
|
3
|
-
rules: {
|
|
4
|
-
"body-max-line-length": [2, "always", 100],
|
|
5
|
-
"header-max-length": [2, "always", 72],
|
|
6
|
-
"subject-case": [
|
|
7
|
-
2,
|
|
8
|
-
"never",
|
|
9
|
-
["sentence-case", "start-case", "pascal-case", "upper-case"],
|
|
10
|
-
],
|
|
11
|
-
},
|
|
12
|
-
};
|
package/eslint.config.js
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import tsPlugin from "@typescript-eslint/eslint-plugin";
|
|
2
|
-
import tsParser from "@typescript-eslint/parser";
|
|
3
|
-
import importPlugin from "eslint-plugin-import";
|
|
4
|
-
import jsdocPlugin from "eslint-plugin-jsdoc";
|
|
5
|
-
import globals from "globals";
|
|
6
|
-
|
|
7
|
-
export default [
|
|
8
|
-
{
|
|
9
|
-
ignores: [
|
|
10
|
-
"dist/**/*",
|
|
11
|
-
"node_modules/**/*",
|
|
12
|
-
"coverage/**/*",
|
|
13
|
-
"docs/.vitepress/cache/**/*",
|
|
14
|
-
],
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
files: ["**/*.js", "**/*.mjs"],
|
|
18
|
-
languageOptions: {
|
|
19
|
-
ecmaVersion: "latest",
|
|
20
|
-
sourceType: "module",
|
|
21
|
-
globals: {
|
|
22
|
-
...globals.node,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
files: ["**/*.ts"],
|
|
28
|
-
languageOptions: {
|
|
29
|
-
parser: tsParser,
|
|
30
|
-
parserOptions: {
|
|
31
|
-
ecmaVersion: "latest",
|
|
32
|
-
sourceType: "module",
|
|
33
|
-
project: ["./tsconfig.json", "./tsconfig.build.json"],
|
|
34
|
-
tsconfigRootDir: import.meta.dirname,
|
|
35
|
-
},
|
|
36
|
-
globals: {
|
|
37
|
-
...globals.node,
|
|
38
|
-
...globals.es2022,
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
plugins: {
|
|
42
|
-
"@typescript-eslint": tsPlugin,
|
|
43
|
-
import: importPlugin,
|
|
44
|
-
jsdoc: jsdocPlugin,
|
|
45
|
-
},
|
|
46
|
-
rules: {
|
|
47
|
-
...tsPlugin.configs.recommended.rules,
|
|
48
|
-
...tsPlugin.configs["recommended-requiring-type-checking"].rules,
|
|
49
|
-
...tsPlugin.configs.strict.rules,
|
|
50
|
-
...importPlugin.configs.typescript.rules,
|
|
51
|
-
...jsdocPlugin.configs["recommended-typescript"].rules,
|
|
52
|
-
"@typescript-eslint/explicit-function-return-type": [
|
|
53
|
-
"error",
|
|
54
|
-
{
|
|
55
|
-
allowExpressions: true,
|
|
56
|
-
allowTypedFunctionExpressions: true,
|
|
57
|
-
},
|
|
58
|
-
],
|
|
59
|
-
"@typescript-eslint/no-explicit-any": "error",
|
|
60
|
-
"@typescript-eslint/explicit-member-accessibility": [
|
|
61
|
-
"error",
|
|
62
|
-
{
|
|
63
|
-
accessibility: "explicit",
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
"@typescript-eslint/no-floating-promises": "error",
|
|
67
|
-
"@typescript-eslint/no-misused-promises": [
|
|
68
|
-
"error",
|
|
69
|
-
{
|
|
70
|
-
checksVoidReturn: {
|
|
71
|
-
arguments: false,
|
|
72
|
-
attributes: false,
|
|
73
|
-
properties: false,
|
|
74
|
-
returns: true,
|
|
75
|
-
variables: true,
|
|
76
|
-
},
|
|
77
|
-
checksConditionals: true,
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
"@typescript-eslint/await-thenable": "error",
|
|
81
|
-
"@typescript-eslint/require-await": "error",
|
|
82
|
-
"@typescript-eslint/promise-function-async": "error",
|
|
83
|
-
"@typescript-eslint/prefer-promise-reject-errors": "error",
|
|
84
|
-
"@typescript-eslint/prefer-nullish-coalescing": "error",
|
|
85
|
-
"@typescript-eslint/prefer-optional-chain": "error",
|
|
86
|
-
"@typescript-eslint/strict-boolean-expressions": "error",
|
|
87
|
-
"@typescript-eslint/no-unnecessary-condition": "error",
|
|
88
|
-
"@typescript-eslint/no-unsafe-assignment": "error",
|
|
89
|
-
"@typescript-eslint/no-unsafe-return": "error",
|
|
90
|
-
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
91
|
-
"@typescript-eslint/no-unsafe-call": "error",
|
|
92
|
-
"@typescript-eslint/no-unsafe-argument": "error",
|
|
93
|
-
"@typescript-eslint/no-unsafe-enum-comparison": "error",
|
|
94
|
-
"@typescript-eslint/prefer-readonly": "error",
|
|
95
|
-
"import/order": [
|
|
96
|
-
"error",
|
|
97
|
-
{
|
|
98
|
-
groups: [
|
|
99
|
-
"builtin",
|
|
100
|
-
"external",
|
|
101
|
-
"internal",
|
|
102
|
-
"parent",
|
|
103
|
-
"sibling",
|
|
104
|
-
"index",
|
|
105
|
-
],
|
|
106
|
-
pathGroups: [
|
|
107
|
-
{
|
|
108
|
-
pattern: "@core/**",
|
|
109
|
-
group: "internal",
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
pattern: "@utils/**",
|
|
113
|
-
group: "internal",
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
pattern: "@/**",
|
|
117
|
-
group: "internal",
|
|
118
|
-
},
|
|
119
|
-
],
|
|
120
|
-
pathGroupsExcludedImportTypes: ["builtin"],
|
|
121
|
-
"newlines-between": "always",
|
|
122
|
-
alphabetize: { order: "asc", caseInsensitive: true },
|
|
123
|
-
},
|
|
124
|
-
],
|
|
125
|
-
"import/newline-after-import": "error",
|
|
126
|
-
"no-prototype-builtins": "error",
|
|
127
|
-
"@typescript-eslint/no-unused-vars": [
|
|
128
|
-
"error",
|
|
129
|
-
{
|
|
130
|
-
argsIgnorePattern: "^_",
|
|
131
|
-
varsIgnorePattern: "^_",
|
|
132
|
-
destructuredArrayIgnorePattern: "^_",
|
|
133
|
-
caughtErrorsIgnorePattern: "^_",
|
|
134
|
-
},
|
|
135
|
-
],
|
|
136
|
-
"no-useless-catch": "error",
|
|
137
|
-
"@typescript-eslint/ban-ts-comment": [
|
|
138
|
-
"error",
|
|
139
|
-
{
|
|
140
|
-
"ts-expect-error": "allow-with-description",
|
|
141
|
-
"ts-ignore": false,
|
|
142
|
-
"ts-nocheck": false,
|
|
143
|
-
"ts-check": false,
|
|
144
|
-
minimumDescriptionLength: 10,
|
|
145
|
-
},
|
|
146
|
-
],
|
|
147
|
-
"jsdoc/require-jsdoc": [
|
|
148
|
-
"error",
|
|
149
|
-
{
|
|
150
|
-
publicOnly: true,
|
|
151
|
-
require: {
|
|
152
|
-
ArrowFunctionExpression: true,
|
|
153
|
-
ClassDeclaration: true,
|
|
154
|
-
ClassExpression: true,
|
|
155
|
-
FunctionDeclaration: true,
|
|
156
|
-
MethodDefinition: true,
|
|
157
|
-
},
|
|
158
|
-
contexts: [
|
|
159
|
-
"ExportDefaultDeclaration",
|
|
160
|
-
"ExportNamedDeclaration",
|
|
161
|
-
"TSInterfaceDeclaration",
|
|
162
|
-
"TSTypeAliasDeclaration",
|
|
163
|
-
"TSEnumDeclaration",
|
|
164
|
-
"PropertyDefinition",
|
|
165
|
-
],
|
|
166
|
-
},
|
|
167
|
-
],
|
|
168
|
-
"jsdoc/require-description": [
|
|
169
|
-
"error",
|
|
170
|
-
{
|
|
171
|
-
contexts: ["any"],
|
|
172
|
-
checkConstructors: true,
|
|
173
|
-
checkGetters: true,
|
|
174
|
-
checkSetters: true,
|
|
175
|
-
exemptedBy: ["internal", "private", "test"],
|
|
176
|
-
},
|
|
177
|
-
],
|
|
178
|
-
"jsdoc/require-description-complete-sentence": "off",
|
|
179
|
-
"jsdoc/check-line-alignment": "error",
|
|
180
|
-
"jsdoc/check-syntax": "error",
|
|
181
|
-
"jsdoc/check-values": "error",
|
|
182
|
-
"jsdoc/check-types": "error",
|
|
183
|
-
"jsdoc/check-property-names": "error",
|
|
184
|
-
"jsdoc/check-indentation": "error",
|
|
185
|
-
"jsdoc/multiline-blocks": "error",
|
|
186
|
-
"jsdoc/require-hyphen-before-param-description": "error",
|
|
187
|
-
"jsdoc/require-throws": "error",
|
|
188
|
-
"jsdoc/require-yields": "error",
|
|
189
|
-
"jsdoc/sort-tags": "error",
|
|
190
|
-
"jsdoc/check-examples": "off",
|
|
191
|
-
"jsdoc/require-example": "off",
|
|
192
|
-
"jsdoc/check-tag-names": [
|
|
193
|
-
"error",
|
|
194
|
-
{
|
|
195
|
-
definedTags: [
|
|
196
|
-
"remarks",
|
|
197
|
-
"internal",
|
|
198
|
-
"private",
|
|
199
|
-
"test",
|
|
200
|
-
"throws",
|
|
201
|
-
"yields",
|
|
202
|
-
"example",
|
|
203
|
-
],
|
|
204
|
-
},
|
|
205
|
-
],
|
|
206
|
-
"jsdoc/require-param-type": "off",
|
|
207
|
-
"jsdoc/require-returns-type": "off",
|
|
208
|
-
"jsdoc/require-property": "error",
|
|
209
|
-
"jsdoc/require-property-description": "error",
|
|
210
|
-
"jsdoc/require-property-name": "error",
|
|
211
|
-
"jsdoc/require-property-type": "off",
|
|
212
|
-
"jsdoc/require-returns": [
|
|
213
|
-
"error",
|
|
214
|
-
{
|
|
215
|
-
checkGetters: true,
|
|
216
|
-
checkConstructors: false,
|
|
217
|
-
},
|
|
218
|
-
],
|
|
219
|
-
"jsdoc/check-param-names": [
|
|
220
|
-
"error",
|
|
221
|
-
{
|
|
222
|
-
checkRestProperty: true,
|
|
223
|
-
enableFixer: true,
|
|
224
|
-
allowExtraTrailingParamDocs: true,
|
|
225
|
-
},
|
|
226
|
-
],
|
|
227
|
-
"jsdoc/require-param-description": "error",
|
|
228
|
-
"jsdoc/require-returns-description": "error",
|
|
229
|
-
eqeqeq: ["error", "always"],
|
|
230
|
-
"no-return-await": "error",
|
|
231
|
-
"prefer-const": "error",
|
|
232
|
-
"no-var": "error",
|
|
233
|
-
curly: ["error", "all"],
|
|
234
|
-
"max-depth": ["error", 3],
|
|
235
|
-
"max-lines-per-function": ["error", { max: 50 }],
|
|
236
|
-
complexity: ["error", 10],
|
|
237
|
-
"jsdoc/no-types": "off",
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
files: [
|
|
242
|
-
"**/__tests__/**",
|
|
243
|
-
"**/__mocks__/**",
|
|
244
|
-
"**/tests/**",
|
|
245
|
-
"**/utils/**",
|
|
246
|
-
"**/types/**",
|
|
247
|
-
"**/browsers/**",
|
|
248
|
-
],
|
|
249
|
-
rules: {
|
|
250
|
-
"jsdoc/require-example": "off",
|
|
251
|
-
"jsdoc/require-description": "off",
|
|
252
|
-
"max-lines-per-function": ["error", { max: 100 }],
|
|
253
|
-
},
|
|
254
|
-
},
|
|
255
|
-
];
|
package/examples/README.md
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
# get-cookie Examples
|
|
2
|
-
|
|
3
|
-
This directory contains example scripts demonstrating various ways to use get-cookie.
|
|
4
|
-
|
|
5
|
-
## Shell Script Examples
|
|
6
|
-
|
|
7
|
-
### Quick Start
|
|
8
|
-
- **`quick-start.sh`**: Essential patterns for immediate use. Perfect for getting started quickly with basic cookie extraction and one-liner curl commands. Includes a reusable shell function for your `.bashrc/.zshrc`.
|
|
9
|
-
|
|
10
|
-
### Comprehensive Guides
|
|
11
|
-
- **`curl-integration.sh`**: Complete guide for using get-cookie with curl. Covers everything from basic single-cookie requests to complex multi-cookie authentication, POST requests, and cookie validation. Includes colored output and reusable functions.
|
|
12
|
-
|
|
13
|
-
- **`github-auth.sh`**: Complete GitHub authentication reference. Demonstrates session cookie filtering, endpoint testing, private repository access patterns, and clarifies the difference between web and API authentication.
|
|
14
|
-
|
|
15
|
-
- **`features-demo.sh`**: All CLI features in one place. Demonstrates profile listing and selection, cookie deduplication, expired cookie filtering, browser-specific extraction, and how to combine features.
|
|
16
|
-
|
|
17
|
-
### Development Examples
|
|
18
|
-
- **`cli-examples.sh`**: Basic reference for development. Shows how to use the command-line interface for common tasks using `pnpm tsx` for local development.
|
|
19
|
-
|
|
20
|
-
## TypeScript/Node.js Examples
|
|
21
|
-
|
|
22
|
-
- **`basic-usage.ts`**: Demonstrates basic Node.js module usage
|
|
23
|
-
- **`advanced-usage.ts`**: Shows advanced usage with browser-specific strategies
|
|
24
|
-
|
|
25
|
-
## Running the Examples
|
|
26
|
-
|
|
27
|
-
### Shell Script Examples
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
# Make the script executable
|
|
31
|
-
chmod +x quick-start.sh
|
|
32
|
-
chmod +x curl-integration.sh
|
|
33
|
-
chmod +x github-auth.sh
|
|
34
|
-
chmod +x features-demo.sh
|
|
35
|
-
|
|
36
|
-
# Run the examples
|
|
37
|
-
./quick-start.sh # Quick start guide
|
|
38
|
-
./curl-integration.sh # Comprehensive curl integration
|
|
39
|
-
./github-auth.sh # GitHub authentication patterns
|
|
40
|
-
./features-demo.sh # All CLI features
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### Development Examples
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
# For cli-examples.sh (uses pnpm tsx)
|
|
47
|
-
chmod +x cli-examples.sh
|
|
48
|
-
./cli-examples.sh
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### TypeScript Examples
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
# Install dependencies if you haven't already
|
|
55
|
-
pnpm install
|
|
56
|
-
|
|
57
|
-
# Run TypeScript examples
|
|
58
|
-
ts-node basic-usage.ts
|
|
59
|
-
ts-node advanced-usage.ts
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Example File Organization
|
|
63
|
-
|
|
64
|
-
The examples are organized by use case:
|
|
65
|
-
|
|
66
|
-
1. **Quick Start** ā Start here for immediate practical patterns
|
|
67
|
-
2. **curl Integration** ā For HTTP/API automation workflows
|
|
68
|
-
3. **GitHub Auth** ā For GitHub-specific authentication scenarios
|
|
69
|
-
4. **Features Demo** ā For understanding all CLI capabilities
|
|
70
|
-
|
|
71
|
-
Note: Make sure you have get-cookie installed either globally or as a project dependency before running the examples.
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @description
|
|
8
|
-
* This example demonstrates advanced usage of the cookie retrieval functions.
|
|
9
|
-
* It shows how to retrieve cookies using different patterns and filters.
|
|
10
|
-
* @internal
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* import { getCookie } from "@mherod/get-cookie";
|
|
14
|
-
*
|
|
15
|
-
* // Get all cookies for a domain
|
|
16
|
-
* const cookies = await getCookie({
|
|
17
|
-
* name: "*",
|
|
18
|
-
* domain: "github.com"
|
|
19
|
-
* });
|
|
20
|
-
*
|
|
21
|
-
* // Get specific cookies
|
|
22
|
-
* const authCookie = await getCookie({
|
|
23
|
-
* name: "auth",
|
|
24
|
-
* domain: "api.github.com"
|
|
25
|
-
* });
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
import { getCookie } from "../src";
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @description
|
|
33
|
-
* Run advanced examples of cookie retrieval.
|
|
34
|
-
* @internal
|
|
35
|
-
* @returns A promise that resolves when all examples have completed.
|
|
36
|
-
*/
|
|
37
|
-
export async function runAdvancedExamples(): Promise<void> {
|
|
38
|
-
// Example 1: Get a specific cookie by name and domain
|
|
39
|
-
const cookie = await getCookie({
|
|
40
|
-
name: "session",
|
|
41
|
-
domain: "github.com",
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
console.log("Example 1 - Specific cookie:", cookie);
|
|
45
|
-
|
|
46
|
-
// Example 2: Get all cookies for a domain using wildcard
|
|
47
|
-
const cookies = await getCookie({
|
|
48
|
-
name: "*",
|
|
49
|
-
domain: "github.com",
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
console.log("Example 2 - All domain cookies:", cookies);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Execute the examples
|
|
56
|
-
runAdvancedExamples().catch(console.error);
|
package/examples/auth-tokens.ts
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env tsx
|
|
2
|
-
/**
|
|
3
|
-
* Example: Extracting authentication tokens from browser cookies
|
|
4
|
-
* This demonstrates how to use get-cookie for extracting auth tokens
|
|
5
|
-
* for API automation or testing purposes
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { getCookie } from "../src";
|
|
9
|
-
|
|
10
|
-
interface AuthToken {
|
|
11
|
-
site: string;
|
|
12
|
-
tokenName: string;
|
|
13
|
-
value: string;
|
|
14
|
-
browser: string;
|
|
15
|
-
expiry: Date | string | number | null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async function extractAuthTokens() {
|
|
19
|
-
console.log("š Authentication Token Extraction Example\n");
|
|
20
|
-
console.log("=".repeat(50));
|
|
21
|
-
|
|
22
|
-
// Common authentication cookie patterns
|
|
23
|
-
const authPatterns = [
|
|
24
|
-
{
|
|
25
|
-
site: "github.com",
|
|
26
|
-
cookies: ["user_session", "_gh_sess", "dotcom_user"],
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
site: "google.com",
|
|
30
|
-
cookies: ["OSID", "SID", "HSID", "SSID", "APISID", "SAPISID"],
|
|
31
|
-
},
|
|
32
|
-
{ site: "twitter.com", cookies: ["auth_token", "ct0", "kdt"] },
|
|
33
|
-
{ site: "linkedin.com", cookies: ["li_at", "JSESSIONID"] },
|
|
34
|
-
{ site: "stackoverflow.com", cookies: ["acct", "prov"] },
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
const foundTokens: AuthToken[] = [];
|
|
38
|
-
|
|
39
|
-
for (const pattern of authPatterns) {
|
|
40
|
-
console.log(`\nš Checking ${pattern.site}...`);
|
|
41
|
-
|
|
42
|
-
for (const cookieName of pattern.cookies) {
|
|
43
|
-
try {
|
|
44
|
-
const cookies = await getCookie({
|
|
45
|
-
name: cookieName,
|
|
46
|
-
domain: pattern.site,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
if (cookies.length > 0) {
|
|
50
|
-
cookies.forEach((cookie) => {
|
|
51
|
-
foundTokens.push({
|
|
52
|
-
site: pattern.site,
|
|
53
|
-
tokenName: cookieName,
|
|
54
|
-
value: `${cookie.value.substring(0, 20)}...`, // Truncate for security
|
|
55
|
-
browser: cookie.meta?.browser || "Unknown",
|
|
56
|
-
expiry: cookie.expiry || null,
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
console.log(
|
|
60
|
-
` ā Found ${cookieName} in ${cookie.meta?.browser || "Unknown"}`,
|
|
61
|
-
);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
} catch (_error) {
|
|
65
|
-
// Cookie not found or error accessing
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Summary
|
|
71
|
-
console.log(`\n${"=".repeat(50)}`);
|
|
72
|
-
console.log("š Summary of Found Authentication Tokens\n");
|
|
73
|
-
|
|
74
|
-
if (foundTokens.length === 0) {
|
|
75
|
-
console.log(
|
|
76
|
-
"No authentication tokens found. Make sure you're logged into these sites.",
|
|
77
|
-
);
|
|
78
|
-
} else {
|
|
79
|
-
// Group by site
|
|
80
|
-
const bySite = foundTokens.reduce(
|
|
81
|
-
(acc, token) => {
|
|
82
|
-
if (!acc[token.site]) {
|
|
83
|
-
acc[token.site] = [];
|
|
84
|
-
}
|
|
85
|
-
acc[token.site]?.push(token);
|
|
86
|
-
return acc;
|
|
87
|
-
},
|
|
88
|
-
{} as Record<string, AuthToken[]>,
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
Object.entries(bySite).forEach(([site, tokens]) => {
|
|
92
|
-
console.log(`\n${site}:`);
|
|
93
|
-
tokens.forEach((token) => {
|
|
94
|
-
const expiryInfo =
|
|
95
|
-
token.expiry instanceof Date
|
|
96
|
-
? `expires ${new Date(token.expiry).toLocaleDateString()}`
|
|
97
|
-
: token.expiry === "Infinity"
|
|
98
|
-
? "session cookie"
|
|
99
|
-
: "unknown expiry";
|
|
100
|
-
|
|
101
|
-
console.log(` ⢠${token.tokenName} (${token.browser}, ${expiryInfo})`);
|
|
102
|
-
console.log(` Value: ${token.value}`);
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// Security reminder
|
|
107
|
-
console.log("\nā ļø Security Reminder:");
|
|
108
|
-
console.log("These are sensitive authentication tokens. Never:");
|
|
109
|
-
console.log(" - Share them publicly");
|
|
110
|
-
console.log(" - Commit them to version control");
|
|
111
|
-
console.log(" - Use them outside of their intended purpose");
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Example: Using tokens for API requests
|
|
115
|
-
console.log(`\n${"=".repeat(50)}`);
|
|
116
|
-
console.log("š” Example: Using GitHub token for API request\n");
|
|
117
|
-
|
|
118
|
-
const githubSession = foundTokens.find(
|
|
119
|
-
(t) => t.site === "github.com" && t.tokenName === "user_session",
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
if (githubSession) {
|
|
123
|
-
console.log("To use this token with GitHub API:");
|
|
124
|
-
console.log("```javascript");
|
|
125
|
-
console.log(
|
|
126
|
-
"const response = await fetch('https://api.github.com/user', {",
|
|
127
|
-
);
|
|
128
|
-
console.log(" headers: {");
|
|
129
|
-
console.log(" 'Cookie': `user_session=\\$\\{token\\}`,");
|
|
130
|
-
console.log(" 'User-Agent': 'Your-App-Name'");
|
|
131
|
-
console.log(" }");
|
|
132
|
-
console.log("});");
|
|
133
|
-
console.log("```");
|
|
134
|
-
console.log("\nNote: Most modern APIs prefer OAuth tokens over cookies.");
|
|
135
|
-
} else {
|
|
136
|
-
console.log(
|
|
137
|
-
"No GitHub session found. Log into GitHub in your browser first.",
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Run the example
|
|
143
|
-
extractAuthTokens().catch(console.error);
|
package/examples/basic-usage.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @description
|
|
8
|
-
* This example demonstrates basic usage of the getCookie function.
|
|
9
|
-
* It shows how to retrieve cookies from all supported browsers using a unified interface.
|
|
10
|
-
* @internal
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* import { getCookie } from "@mherod/get-cookie";
|
|
14
|
-
*
|
|
15
|
-
* // Get a cookie by name and domain
|
|
16
|
-
* const cookie = await getCookie({
|
|
17
|
-
* name: "session",
|
|
18
|
-
* domain: "github.com"
|
|
19
|
-
* });
|
|
20
|
-
*
|
|
21
|
-
* console.log(cookie);
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import { getCookie } from "@mherod/get-cookie";
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @description
|
|
29
|
-
* Basic example showing how to retrieve cookies from browsers.
|
|
30
|
-
* @internal
|
|
31
|
-
*/
|
|
32
|
-
async function main(): Promise<void> {
|
|
33
|
-
// Get all session cookies from github.com
|
|
34
|
-
const cookies = await getCookie({
|
|
35
|
-
name: "user_session",
|
|
36
|
-
domain: "github.com",
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
console.log("Found cookies:", cookies);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Run the example
|
|
43
|
-
void main();
|