Socket
Socket
Sign inDemoInstall

fetch-cookie

Package Overview
Dependencies
Maintainers
3
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-cookie - npm Package Compare versions

Comparing version 2.0.5 to 2.1.0

types/index.d.ts

6

CHANGELOG.md

@@ -9,2 +9,5 @@ # Changelog

## [2.1.0] - 2022-07-12
* Explicitly export `package.json` to be compatible with bundlers. ([#72])
## [2.0.5] - 2022-05-26

@@ -112,3 +115,4 @@ * Change order of `exports` `default` in `package.json`. ([#72])

[Unreleased]: https://github.com/valeriangalliat/fetch-cookie/compare/v2.0.5...HEAD
[Unreleased]: https://github.com/valeriangalliat/fetch-cookie/compare/v2.1.0...HEAD
[2.1.0]: https://github.com/valeriangalliat/fetch-cookie/compare/v2.0.5...v2.1.0
[2.0.5]: https://github.com/valeriangalliat/fetch-cookie/compare/v2.0.4...v2.0.5

@@ -115,0 +119,0 @@ [2.0.4]: https://github.com/valeriangalliat/fetch-cookie/compare/v2.0.3...v2.0.4

19

package.json
{
"name": "fetch-cookie",
"version": "2.0.5",
"version": "2.1.0",
"description": "Decorator for a `fetch` function to support automatic cookies.",

@@ -11,9 +11,12 @@ "license": "Unlicense",

"exports": {
"import": {
"types": "./esm/index.d.ts",
"default": "./esm/index.js"
},
"require": {
"types": "./cjs/index.d.ts",
"default": "./cjs/index-wrapper.js"
"./package.json": "./package.json",
".": {
"import": {
"types": "./esm/index.d.ts",
"default": "./esm/index.js"
},
"require": {
"types": "./cjs/index.d.ts",
"default": "./cjs/index-wrapper.js"
}
}

@@ -20,0 +23,0 @@ },

@@ -32,16 +32,18 @@ # 🍪 fetch-cookie [![npm version](https://img.shields.io/npm/v/fetch-cookie?style=flat-square)](https://www.npmjs.org/package/fetch-cookie) [![Build status](https://img.shields.io/github/workflow/status/valeriangalliat/fetch-cookie/Test?style=flat-square)](https://github.com/valeriangalliat/fetch-cookie/actions/workflows/test.yml)

With Node.js 18.3.0 and greater, using the native global `fetch`
function:
```js
import nodeFetch from 'node-fetch'
import fetchCookie from 'fetch-cookie'
import makeFetchCookie from 'fetch-cookie'
const fetch = fetchCookie(nodeFetch)
const fetchCookie = makeFetchCookie(fetch)
```
Or in the future when `node --experimental-fetch` allows to read the
`Set-Cookie` header:
Or with node-fetch:
```js
import makeFetchCookie from 'fetch-cookie'
import nodeFetch from 'node-fetch'
import fetchCookie from 'fetch-cookie'
const fetchCookie = makeFetchCookie(fetch)
const fetch = fetchCookie(nodeFetch)
```

@@ -55,6 +57,5 @@

```js
import nodeFetch from 'node-fetch'
import fetchCookie from 'fetch-cookie'
import makeFetchCookie from 'fetch-cookie'
const fetch = fetchCookie(nodeFetch, new fetchCookie.toughCookie.CookieJar())
const fetchCookie = makeFetchCookie(fetch, new makeFetchCookie.toughCookie.CookieJar())
```

@@ -84,2 +85,29 @@

### Custom cookie jar with options
If you don't want a custom store and just want to pass [tough-cookie
options](https://github.com/salesforce/tough-cookie#cookiejarstore-options),
e.g. to allow cookies on `localhost`:
```js
import makeFetchCookie from 'fetch-cookie'
const fetchCookie = makeFetchCookie(fetch, new makeFetchCookie.toughCookie.CookieJar(undefined, {
allowSpecialUseDomain: true
}))
```
Or with a custom store as well:
```js
import makeFetchCookie from 'fetch-cookie'
import FileCookieStore from 'file-cookie-store'
const store = new FileCookieStore('cookies.txt')
const fetchCookie = makeFetchCookie(fetch, new makeFetchCookie.toughCookie.CookieJar(store, {
allowSpecialUseDomain: true
}))
```
### Ignoring errors

@@ -91,6 +119,5 @@

```js
import nodeFetch from 'node-fetch'
import fetchCookie from 'fetch-cookie'
import makeFetchCookie from 'fetch-cookie'
const fetch = fetchCookie(nodeFetch, new fetchCookie.toughCookie.CookieJar(), false)
const fetchCookie = makeFetchCookie(fetch, new makeFetchCookie.toughCookie.CookieJar(), false)
```

@@ -113,8 +140,7 @@

```js
import nodeFetch from 'node-fetch'
import fetchCookie from 'fetch-cookie'
import makeFetchCookie from 'fetch-cookie'
const fetch = fetchCookie(nodeFetch)
const fetchCookie = makeFetchCookie(fetch)
await fetch(url, { maxRedirect: 10 })
await fetchCookie(url, { maxRedirect: 10 })
```

@@ -121,0 +147,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc