@mherod/get-cookie 2.0.0-rc.13 → 2.0.0-rc.15

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/dist/index.js CHANGED
@@ -800,16 +800,13 @@ async function $cfc07ae4aa2c7e44$export$b24a545a0b39f491(url, options = {}, fetc
800
800
  const url2 = `${url}`;
801
801
  const url1 = new URL(url2);
802
802
  const cookieSpecs = (0, $2d84054eb5f070a6$export$f266452a5050185d)(url1);
803
- const cookie = await (0, $4ffeaeb7bb3c0319$export$cfc0723de5712e57)(cookieSpecs).catch(()=>"");
804
- if (cookie.length > 0) (0, $7oI3p$lodash.merge)(headers, {
805
- Cookie: cookie
806
- });
803
+ headers["Cookie"] = await (0, $4ffeaeb7bb3c0319$export$cfc0723de5712e57)(cookieSpecs).catch(()=>"");
807
804
  if ((0, $ef3d5dc2fd8022f5$export$c348dfaf65040d9b)["dump-request-headers"]) console.log((0, $7oI3p$colorette.blue)("Request headers:"), headers);
808
- const newOptions1 = (0, $7oI3p$lodash.merge)(defaultOptions, options, {
805
+ const newOptions1 = (0, $7oI3p$lodash.merge)(defaultOptions, {
809
806
  headers: headers
810
- });
807
+ }, options);
811
808
  try {
812
- const res = await fetch(url2, newOptions1);
809
+ const res = await fetch(url1, newOptions1);
813
810
  const headers1 = [];
814
811
  res.headers.forEach((value, key)=>{
815
812
  headers1.push([
@@ -826,12 +823,13 @@ async function $cfc07ae4aa2c7e44$export$b24a545a0b39f491(url, options = {}, fetc
826
823
  // }
827
824
  }
828
825
  const newUrl = res.headers.get("location");
829
- if (res.status >= 300 && res.status < 400) {
826
+ if (res.status == 301 || res.status == 302) // const sameHost = new URL(newUrl).host === url1.host;
827
+ {
830
828
  if (newUrl && newUrl !== url2) {
831
829
  if ((0, $ef3d5dc2fd8022f5$export$c348dfaf65040d9b).verbose) console.log((0, $7oI3p$colorette.blue)(`Redirected to `), (0, $7oI3p$colorette.yellow)(newUrl));
832
830
  return $cfc07ae4aa2c7e44$export$b24a545a0b39f491(//
833
831
  newUrl, newOptions1, fetch);
834
- } else throw new Error("Redirected but no new location");
832
+ }
835
833
  }
836
834
  const arrayBuffer1 = res.arrayBuffer();
837
835
  async function arrayBuffer() {
package/package-lock.json CHANGED
@@ -1,25 +1,25 @@
1
1
  {
2
2
  "name": "@mherod/get-cookie",
3
- "version": "2.0.0-rc.11",
3
+ "version": "2.0.0-rc.14",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@mherod/get-cookie",
9
- "version": "2.0.0-rc.11",
9
+ "version": "2.0.0-rc.14",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
12
  "colorette": "^2.0.19",
13
13
  "cross-fetch": "^3.1.5",
14
- "destr": "^1.1.1",
14
+ "destr": "^1.2.0",
15
15
  "jsonwebtoken": "^8.5.1",
16
16
  "lodash": "^4.17.21",
17
17
  "lru-cache": "^7.14.0",
18
- "minimist": "^1.2.6",
19
- "sqlite3": "^5.1.1",
18
+ "minimist": "^1.2.7",
19
+ "sqlite3": "^5.1.2",
20
20
  "tough-cookie": "^4.1.2",
21
21
  "tough-cookie-file-store": "^2.0.3",
22
- "user-agents": "^1.0.1165"
22
+ "user-agents": "^1.0.1178"
23
23
  },
24
24
  "bin": {
25
25
  "get-cookie": "dist/cli.js"
@@ -30,7 +30,7 @@
30
30
  "@types/jsonwebtoken": "^8.5.9",
31
31
  "@types/lodash": "^4.14.186",
32
32
  "@types/minimist": "^1.2.2",
33
- "@types/node": "^18.8.2",
33
+ "@types/node": "^18.11.4",
34
34
  "@types/tough-cookie": "^4.0.2",
35
35
  "@types/user-agents": "^1.0.2",
36
36
  "parcel": "^2.7.0",
@@ -1837,9 +1837,9 @@
1837
1837
  "dev": true
1838
1838
  },
1839
1839
  "node_modules/@types/node": {
1840
- "version": "18.8.4",
1841
- "resolved": "https://registry.npmjs.org/@types/node/-/node-18.8.4.tgz",
1842
- "integrity": "sha512-WdlVphvfR/GJCLEMbNA8lJ0lhFNBj4SW3O+O5/cEGw9oYrv0al9zTwuQsq+myDUXgNx2jgBynoVgZ2MMJ6pbow==",
1840
+ "version": "18.11.4",
1841
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.4.tgz",
1842
+ "integrity": "sha512-BxcJpBu8D3kv/GZkx/gSMz6VnTJREBj/4lbzYOQueUOELkt8WrO6zAcSPmp9uRPEW/d+lUO8QK0W2xnS1hEU0A==",
1843
1843
  "dev": true
1844
1844
  },
1845
1845
  "node_modules/@types/parse-json": {
@@ -2325,9 +2325,9 @@
2325
2325
  }
2326
2326
  },
2327
2327
  "node_modules/destr": {
2328
- "version": "1.1.1",
2329
- "resolved": "https://registry.npmjs.org/destr/-/destr-1.1.1.tgz",
2330
- "integrity": "sha512-QqkneF8LrYmwATMdnuD2MLI3GHQIcBnG6qFC2q9bSH430VTCDAVjcspPmUaKhPGtAtPAftIUFqY1obQYQuwmbg=="
2328
+ "version": "1.2.0",
2329
+ "resolved": "https://registry.npmjs.org/destr/-/destr-1.2.0.tgz",
2330
+ "integrity": "sha512-JG+cG4ZPB1L27sl2C2URg8MIOmIUtTbE5wEx02BpmrTCqg/hXxFKXsYsnODl5PdpqNRaS1KQGUQ56V8jk8XpYQ=="
2331
2331
  },
2332
2332
  "node_modules/detect-indent": {
2333
2333
  "version": "6.0.0",
@@ -3266,9 +3266,12 @@
3266
3266
  }
3267
3267
  },
3268
3268
  "node_modules/minimist": {
3269
- "version": "1.2.6",
3270
- "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
3271
- "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q=="
3269
+ "version": "1.2.7",
3270
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz",
3271
+ "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==",
3272
+ "funding": {
3273
+ "url": "https://github.com/sponsors/ljharb"
3274
+ }
3272
3275
  },
3273
3276
  "node_modules/minipass": {
3274
3277
  "version": "3.1.6",
@@ -4319,9 +4322,9 @@
4319
4322
  }
4320
4323
  },
4321
4324
  "node_modules/user-agents": {
4322
- "version": "1.0.1166",
4323
- "resolved": "https://registry.npmjs.org/user-agents/-/user-agents-1.0.1166.tgz",
4324
- "integrity": "sha512-/8J171KFx2McruR5C7pVSReA5YVeve4bDizT+JL77C7R+v0/Hq9wTTfvxIGd5TDWP98TXnmOghifZtFbjUHMuA==",
4325
+ "version": "1.0.1178",
4326
+ "resolved": "https://registry.npmjs.org/user-agents/-/user-agents-1.0.1178.tgz",
4327
+ "integrity": "sha512-xcE6igv9dKy3ZrGwHr6ga1eDXyr0ln+BF/OhtoLxm86CHk1APqxo9HqvLYYNS3s80XwuVdl7vdEhMXCTXXCPpw==",
4325
4328
  "dependencies": {
4326
4329
  "dot-json": "^1.2.2",
4327
4330
  "lodash.clonedeep": "^4.5.0"
@@ -5643,9 +5646,9 @@
5643
5646
  "dev": true
5644
5647
  },
5645
5648
  "@types/node": {
5646
- "version": "18.8.4",
5647
- "resolved": "https://registry.npmjs.org/@types/node/-/node-18.8.4.tgz",
5648
- "integrity": "sha512-WdlVphvfR/GJCLEMbNA8lJ0lhFNBj4SW3O+O5/cEGw9oYrv0al9zTwuQsq+myDUXgNx2jgBynoVgZ2MMJ6pbow==",
5649
+ "version": "18.11.4",
5650
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.4.tgz",
5651
+ "integrity": "sha512-BxcJpBu8D3kv/GZkx/gSMz6VnTJREBj/4lbzYOQueUOELkt8WrO6zAcSPmp9uRPEW/d+lUO8QK0W2xnS1hEU0A==",
5649
5652
  "dev": true
5650
5653
  },
5651
5654
  "@types/parse-json": {
@@ -6012,9 +6015,9 @@
6012
6015
  "optional": true
6013
6016
  },
6014
6017
  "destr": {
6015
- "version": "1.1.1",
6016
- "resolved": "https://registry.npmjs.org/destr/-/destr-1.1.1.tgz",
6017
- "integrity": "sha512-QqkneF8LrYmwATMdnuD2MLI3GHQIcBnG6qFC2q9bSH430VTCDAVjcspPmUaKhPGtAtPAftIUFqY1obQYQuwmbg=="
6018
+ "version": "1.2.0",
6019
+ "resolved": "https://registry.npmjs.org/destr/-/destr-1.2.0.tgz",
6020
+ "integrity": "sha512-JG+cG4ZPB1L27sl2C2URg8MIOmIUtTbE5wEx02BpmrTCqg/hXxFKXsYsnODl5PdpqNRaS1KQGUQ56V8jk8XpYQ=="
6018
6021
  },
6019
6022
  "detect-indent": {
6020
6023
  "version": "6.0.0",
@@ -6670,9 +6673,9 @@
6670
6673
  }
6671
6674
  },
6672
6675
  "minimist": {
6673
- "version": "1.2.6",
6674
- "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
6675
- "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q=="
6676
+ "version": "1.2.7",
6677
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz",
6678
+ "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g=="
6676
6679
  },
6677
6680
  "minipass": {
6678
6681
  "version": "3.1.6",
@@ -7436,9 +7439,9 @@
7436
7439
  }
7437
7440
  },
7438
7441
  "user-agents": {
7439
- "version": "1.0.1166",
7440
- "resolved": "https://registry.npmjs.org/user-agents/-/user-agents-1.0.1166.tgz",
7441
- "integrity": "sha512-/8J171KFx2McruR5C7pVSReA5YVeve4bDizT+JL77C7R+v0/Hq9wTTfvxIGd5TDWP98TXnmOghifZtFbjUHMuA==",
7442
+ "version": "1.0.1178",
7443
+ "resolved": "https://registry.npmjs.org/user-agents/-/user-agents-1.0.1178.tgz",
7444
+ "integrity": "sha512-xcE6igv9dKy3ZrGwHr6ga1eDXyr0ln+BF/OhtoLxm86CHk1APqxo9HqvLYYNS3s80XwuVdl7vdEhMXCTXXCPpw==",
7442
7445
  "requires": {
7443
7446
  "dot-json": "^1.2.2",
7444
7447
  "lodash.clonedeep": "^4.5.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mherod/get-cookie",
3
- "version": "2.0.0-rc.13",
3
+ "version": "2.0.0-rc.15",
4
4
  "description": "Node.js module for querying a local user's Chrome cookie",
5
5
  "source": "src/index.ts",
6
6
  "bin": "dist/cli.js",
@@ -59,15 +59,15 @@
59
59
  "dependencies": {
60
60
  "colorette": "^2.0.19",
61
61
  "cross-fetch": "^3.1.5",
62
- "destr": "^1.1.1",
62
+ "destr": "^1.2.0",
63
63
  "jsonwebtoken": "^8.5.1",
64
64
  "lodash": "^4.17.21",
65
65
  "lru-cache": "^7.14.0",
66
- "minimist": "^1.2.6",
67
- "sqlite3": "^5.1.1",
66
+ "minimist": "^1.2.7",
67
+ "sqlite3": "^5.1.2",
68
68
  "tough-cookie": "^4.1.2",
69
69
  "tough-cookie-file-store": "^2.0.3",
70
- "user-agents": "^1.0.1165"
70
+ "user-agents": "^1.0.1178"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@parcel/packager-ts": "^2.7.0",
@@ -75,7 +75,7 @@
75
75
  "@types/jsonwebtoken": "^8.5.9",
76
76
  "@types/lodash": "^4.14.186",
77
77
  "@types/minimist": "^1.2.2",
78
- "@types/node": "^18.8.2",
78
+ "@types/node": "^18.11.4",
79
79
  "@types/tough-cookie": "^4.0.2",
80
80
  "@types/user-agents": "^1.0.2",
81
81
  "parcel": "^2.7.0",
@@ -19,7 +19,7 @@ export async function fetchWithCookies(
19
19
  options: RequestInit | undefined = {},
20
20
  fetch: Function = fetchImpl
21
21
  ): Promise<Response> {
22
- const headers = {
22
+ const headers: HeadersInit = {
23
23
  "User-Agent": userAgent,
24
24
  };
25
25
  const defaultOptions: RequestInit = {
@@ -29,18 +29,15 @@ export async function fetchWithCookies(
29
29
  const url2: string = `${url}`;
30
30
  const url1: URL = new URL(url2);
31
31
  const cookieSpecs: CookieSpec[] = cookieSpecsFromUrl(url1);
32
- const cookie = await getMergedRenderedCookies(cookieSpecs).catch(() => "");
33
- if (cookie.length > 0) {
34
- merge(headers, {
35
- Cookie: cookie,
36
- });
37
- }
32
+ headers["Cookie"] = await getMergedRenderedCookies(cookieSpecs).catch(
33
+ () => ""
34
+ );
38
35
  if (parsedArgs["dump-request-headers"]) {
39
36
  console.log(blue("Request headers:"), headers);
40
37
  }
41
- const newOptions1: RequestInit = merge(defaultOptions, options, { headers });
38
+ const newOptions1: RequestInit = merge(defaultOptions, { headers }, options);
42
39
  try {
43
- const res: Response = await fetch(url2, newOptions1);
40
+ const res: Response = await fetch(url1, newOptions1);
44
41
  const headers: [string, string][] = [];
45
42
  res.headers.forEach((value, key) => {
46
43
  headers.push([key, value]);
@@ -59,7 +56,8 @@ export async function fetchWithCookies(
59
56
  }
60
57
 
61
58
  const newUrl: string = res.headers.get("location") as string;
62
- if (res.status >= 300 && res.status < 400) {
59
+ if (res.status == 301 || res.status == 302) {
60
+ // const sameHost = new URL(newUrl).host === url1.host;
63
61
  if (newUrl && newUrl !== url2) {
64
62
  if (parsedArgs.verbose) {
65
63
  console.log(blue(`Redirected to `), yellow(newUrl));
@@ -71,8 +69,6 @@ export async function fetchWithCookies(
71
69
  fetch
72
70
  //
73
71
  );
74
- } else {
75
- throw new Error("Redirected but no new location");
76
72
  }
77
73
  }
78
74