New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@3846masa/axios-cookiejar-support

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@3846masa/axios-cookiejar-support - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

dist/index.d.ts

7

noop.js
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function noopEnableCookieJarSupport (instance) {
return instance;
function noop(axios) {
return axios;
}
module.exports = noopEnableCookieJarSupport;
exports.wrapper = noop;
{
"name": "@3846masa/axios-cookiejar-support",
"version": "2.0.0",
"description": "Add tough-cookie support to axios.",
"license": "MIT",
"author": "3846masa",
"author": "3846masa <3846masahiro+git@gmail.com>",
"homepage": "https://github.com/3846masa/axios-cookiejar-support#readme",

@@ -14,45 +15,36 @@ "repository": {

},
"version": "1.0.1",
"main": "./lib/index",
"browser": {
"./lib/index": "./noop.js"
},
"main": "dist/index.js",
"browser": "noop.js",
"files": [
"index.d.ts",
"lib",
"noop.js"
"dist",
"noop.js",
"!**/__tests__"
],
"scripts": {
"prebuild": "yarn clean",
"build": "babel lib -x .mjs --out-dir lib",
"clean": "rimraf lib/**/*.js",
"test": "mocha test.spec.js --require intelli-espower-loader"
"prebuild": "rimraf dist",
"build": "tsc",
"semantic-release": "semantic-release",
"pretest": "npm run build",
"test": "ava"
},
"types": "./index.d.ts",
"types": "dist/index.d.ts",
"dependencies": {
"is-redirect": "^1.0.0",
"pify": "^5.0.0"
"http-cookie-agent": "^1.0.0"
},
"peerDependencies": {
"@types/tough-cookie": ">=2.3.3",
"axios": ">=0.16.2",
"tough-cookie": ">=2.3.3"
"axios": "^0.20.0",
"tough-cookie": "^4.0.0"
},
"devDependencies": {
"@babel/cli": "7.12.1",
"@babel/core": "7.12.3",
"@babel/plugin-transform-modules-commonjs": "7.12.1",
"@types/tough-cookie": "^4.0.0",
"axios--0.16.x": "./axios/0.16.x",
"axios--0.17.x": "./axios/0.17.x",
"axios--0.18.x": "./axios/0.18.x",
"axios--0.19.x": "./axios/0.19.x",
"cookie": "^0.4.1",
"decache": "^4.6.0",
"intelli-espower-loader": "^1.0.1",
"mocha": "^8.2.0",
"nock": "^13.0.4",
"power-assert": "^1.6.1",
"rimraf": "3.0.2",
"tough-cookie": "^4.0.0"
"@ava/typescript": "2.0.0",
"@semantic-release/changelog": "5.0.1",
"@semantic-release/exec": "5.0.0",
"@semantic-release/git": "9.0.1",
"@types/node": "12.20.24",
"@types/tough-cookie": "4.0.1",
"ava": "3.15.0",
"axios": "0.21.4",
"semantic-release": "17.4.7",
"tough-cookie": "4.0.0",
"typescript": "4.4.3"
},

@@ -67,4 +59,18 @@ "keywords": [

"engines": {
"node": ">= 10.0.0"
"node": ">=12.0.0"
},
"publishConfig": {
"access": "public"
},
"ava": {
"files": [
"**/__tests__/*.spec.ts"
],
"typescript": {
"rewritePaths": {
"src/": "dist/"
},
"compile": false
}
}
}
# axios-cookiejar-support
Add [``tough-cookie``] support to [``axios``].
![axios-cookiejar-support](./docs/assets/ogp.jpg)
[``axios``]: https://github.com/mzabriskie/axios
[``tough-cookie``]: https://github.com/SalesforceEng/tough-cookie
[![npm](https://flat.badgen.net/npm/v/axios-cookiejar-support)](https://www.npmjs.com/package/axios-cookiejar-support)
[![license](https://flat.badgen.net/badge/license/MIT/blue)](LICENSE)
[![standard-readme compliant](https://flat.badgen.net/badge/readme%20style/standard/green)](https://github.com/RichardLitt/standard-readme)
---
Add `tough-cookie` support to axios.
[![NPM][npm-badge]][npm]
[![LICENSE][license-badge]][license]
[![CircleCI][circleci-badge]][circleci]
## Table of Contents
[![dependencies][dependencies-badge]][dependencies-david]
[![peerdependencies][peerdependencies-badge]][peerdependencies-david]
[![devdependencies][devdependencies-badge]][devdependencies-david]
- [Install](#install)
- [Usage](#usage)
- [Extended Request Config](#extended-request-config)
- [Contributing](#contributing)
- [License](#license)
[npm]: https://www.npmjs.com/package/axios-cookiejar-support
[license]: https://3846masa.mit-license.org
[circleci]: https://circleci.com/gh/3846masa/axios-cookiejar-support
[dependencies-david]: https://david-dm.org/3846masa/axios-cookiejar-support
[peerdependencies-david]: https://david-dm.org/3846masa/axios-cookiejar-support
[devdependencies-david]: https://david-dm.org/3846masa/axios-cookiejar-support
[npm-badge]: https://flat.badgen.net/npm/v/axios-cookiejar-support?icon=npm
[license-badge]: https://flat.badgen.net/badge/license/MIT/blue
[circleci-badge]: https://flat.badgen.net/circleci/github/3846masa/axios-cookiejar-support?icon=circleci
[dependencies-badge]: https://flat.badgen.net/david/dep/3846masa/axios-cookiejar-support
[peerdependencies-badge]: https://flat.badgen.net/david/peer/3846masa/axios-cookiejar-support
[devdependencies-badge]: https://flat.badgen.net/david/dev/3846masa/axios-cookiejar-support
## Install
```sh
$ npm i axios tough-cookie axios-cookiejar-support
```
**-- OR --**
```sh
$ npm i axios tough-cookie @3846masa/axios-cookiejar-support # Same as above
npm install axios tough-cookie axios-cookiejar-support
```
### TypeScript
If you want to use it with TypeScript, add `@types/tough-cookie`.
```sh
npm i @types/tough-cookie
```
## Usage
```js
const axios = require('axios').default;
const axiosCookieJarSupport = require('axios-cookiejar-support').default;
const tough = require('tough-cookie');
import axios from 'axios';
import { wrapper } from 'axios-cookiejar-support';
import { CookieJar } from 'tough-cookie';
axiosCookieJarSupport(axios);
const jar = new CookieJar();
const client = wrapper(axios.create({ jar }));
const cookieJar = new tough.CookieJar();
axios
.get('https://google.com', {
jar: cookieJar, // tough.CookieJar or boolean
withCredentials: true, // If true, send cookie stored in jar
})
.then(() => {
console.log(cookieJar);
});
await client.get('https://example.com');
```
See [examples](./example).
See [examples](./examples) for more details.
### Notice: Set default cookiejar
`axios@>=0.19.0` cannot assign `defaults.jar` via `axios.create()` before wrapping instance.
When you want to set `defaults.jar`, please set directly after wrapping instance.
```js
const axios = require('axios').default;
const axiosCookieJarSupport = require('axios-cookiejar-support').default;
const tough = require('tough-cookie');
const instance = axios.create({
// WARNING: This value will be ignored.
jar: new tough.CookieJar(),
});
// Set directly after wrapping instance.
axiosCookieJarSupport(instance);
instance.defaults.jar = new tough.CookieJar();
```
### Extended Request Config
c.f.) https://github.com/mzabriskie/axios#request-config
```ts
import type { CookieJar } from 'tough-cookie';
```js
{
// `jar` is tough.CookieJar instance or boolean.
// If true, axios create CookieJar automatically.
jar: undefined, // default
// Silently ignore things like parse cookie errors and invalid domains.
// See also https://github.com/salesforce/tough-cookie
ignoreCookieErrors: false // default
// **IMPORTANT**
// If false, axios DONOT send cookies from cookiejar.
withCredentials: false // default
declare module 'axios' {
interface AxiosRequestConfig {
jar?: CookieJar;
}
}
```
### Browser
See also https://github.com/axios/axios#request-config .
Running on browser, this library becomes noop (`config.jar` might be ignored).
## Contributing
## Contribution
PRs accepted.
1. [Fork it]
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
## License
[fork it]: http://github.com/3846masa/axios-cookiejar-support/fork
## LICENSE
[MIT License](https://3846masa.mit-license.org)
## Author
![3846masa icon][3846masa-icon]
[3846masa](https://github.com/3846masa)
[3846masa-icon]: https://www.gravatar.com/avatar/cfeae69aae4f4fc102960f01d35d2d86?s=50
---
## Donate
[Paypal.me](https://www.paypal.me/3846masa) (Onetime donate)
[MIT (c) 3846masa](./LICENSE)

Sorry, the diff of this file is not supported yet

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