Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

http-cookie-agent

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-cookie-agent - npm Package Compare versions

Comparing version 4.0.0 to 4.0.1

dist/types/global_fetch.d.js

12

package.json
{
"name": "http-cookie-agent",
"version": "4.0.0",
"version": "4.0.1",
"description": "Allows cookies with every Node.js HTTP clients.",

@@ -69,8 +69,8 @@ "keywords": [

"devDependencies": {
"@3846masa/configs": "github:3846masa/configs#c9cb404fd4e6ead15044c605e014aecea1182124",
"@3846masa/configs": "github:3846masa/configs#3dc2811f758895f36ab07ffa6bfee681f3f31807",
"@babel/cli": "^7.17.10",
"@babel/core": "7.17.10",
"@babel/preset-env": "^7.17.10",
"@babel/preset-typescript": "^7.16.7",
"@hapi/wreck": "17.2.0",
"@babel/preset-typescript": "^7.17.12",
"@hapi/wreck": "18.0.0",
"@semantic-release/changelog": "6.0.1",

@@ -81,3 +81,3 @@ "@semantic-release/git": "10.0.1",

"@types/needle": "2.5.3",
"@types/node": "14.18.16",
"@types/node": "14.18.18",
"@types/request": "2.48.8",

@@ -105,3 +105,3 @@ "@types/semver": "^7.3.9",

"typescript": "4.6.4",
"undici": "5.1.1",
"undici": "5.2.0",
"urllib": "2.38.0"

@@ -108,0 +108,0 @@ },

@@ -9,3 +9,3 @@ # HTTP Cookie Agent

Allows cookies with every Node.js HTTP clients (e.g. undici, axios, node-fetch).
Allows cookies with every Node.js HTTP clients (e.g. Node.js global fetch, undici, axios, node-fetch).

@@ -17,3 +17,3 @@ ## Table of Contents

- [Supported libraries](#supported-libraries)
- [Using with HTTP clients](#using-with-http-clients)
- [Using with an asynchronous Cookie store](#using-with-an-asynchronous-cookie-store)
- [Using with another Agent library](#using-with-another-agent-library)

@@ -29,38 +29,36 @@ - [Contributing](#contributing)

## Usage
When you want to use Node.js global fetch (aka. `undici`), you should install `undici` additionally.
Pass `http-cookie-agent` to HTTP clients instead of http(s).Agent.
```bash
npm install undici
```
```js
import { CookieJar } from 'tough-cookie';
import { HttpCookieAgent, HttpsCookieAgent, MixedCookieAgent } from 'http-cookie-agent/http';
## Usage
const jar = new CookieJar();
### Supported libraries
const httpAgent = new HttpCookieAgent({ cookies: { jar } });
Node.js global fetch / `undici` / `node:http` / `node:https` / `axios` / `node-fetch` / `got`\*\* / `superagent`\*\* / `request`\*\* / `needle` / `phin` / `@hapi/wreck` / `urllib` etc.
// To access via HTTPS, use HttpsCookieAgent instead.
const httpsAgent = new HttpsCookieAgent({ cookies: { jar } });
\*\* The library supports cookies by default. You may not need `http-cookie-agent`.
// If the client library cannot switch Agents based on the protocol, use MixedCookieAgent instead.
const mixedAgent = new MixedCookieAgent({ cookies: { jar } });
See also [examples](./examples) for more details.
// Pass agent to HTTP client.
client.request('https://example.com', { agent: httpAgent });
```
#### Node.js global fetch
### Supported libraries
`http-cookie-agent` supports global fetch since Node.js v18.2.0.
`undici` / `node:http` / `node:https` / `axios` / `node-fetch` / `got`\*\* / `superagent`\*\* / `request`\*\* / `needle` / `phin` / `@hapi/wreck` / `urllib` etc.
```js
import { CookieJar } from 'tough-cookie';
import { CookieAgent } from 'http-cookie-agent/undici';
\*\* The library supports cookies by default. You may not need `http-cookie-agent`.
const jar = new CookieJar();
const agent = new CookieAgent({ cookies: { jar } });
### Using with HTTP clients
await fetch('https://example.com', { dispatcher: agent });
```
See also [examples](./examples) for more details.
#### `undici`
```js
import { fetch, setGlobalDispatcher } from 'undici';
import { fetch } from 'undici';
import { CookieJar } from 'tough-cookie';

@@ -72,5 +70,3 @@ import { CookieAgent } from 'http-cookie-agent/undici';

setGlobalDispatcher(agent);
await fetch('https://example.com');
await fetch('https://example.com', { dispatcher: agent });
```

@@ -308,3 +304,3 @@

```js
import { fetch, ProxyAgent, setGlobalDispatcher } from 'undici';
import { fetch, ProxyAgent } from 'undici';
import { CookieJar } from 'tough-cookie';

@@ -323,5 +319,3 @@ import { CookieClient } from 'http-cookie-agent/undici';

setGlobalDispatcher(agent);
await fetch('https://example.com');
await fetch('https://example.com', { dispatcher: agent });
```

@@ -332,3 +326,3 @@

```js
import { fetch, Agent, MockClient, setGlobalDispatcher } from 'undici';
import { fetch, Agent, MockClient } from 'undici';
import { CookieJar } from 'tough-cookie';

@@ -349,5 +343,3 @@ import { createCookieClient } from 'http-cookie-agent/undici';

setGlobalDispatcher(agent);
await fetch('https://example.com');
await fetch('https://example.com', { dispatcher: agent });
```

@@ -354,0 +346,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