Skip to content

Commit 7b8e86c

Browse files
authored
Merge pull request #303 from salesforce/v5
Merge `v5` into `master`
2 parents 4ff4d29 + b19eac4 commit 7b8e86c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+21204
-3394
lines changed

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist
2+
node_modules
3+
test
4+
jest.config.ts

.eslintrc.json

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
{
2-
"extends": ["plugin:prettier/recommended"],
2+
"root": true,
3+
"extends": [
4+
"eslint:recommended",
5+
"plugin:@typescript-eslint/recommended",
6+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
7+
"plugin:prettier/recommended"
8+
],
9+
"parser": "@typescript-eslint/parser",
310
"parserOptions": {
4-
"ecmaVersion": 6
11+
"tsconfigRootDir": "./",
12+
"project": ["tsconfig.json"]
513
},
14+
"reportUnusedDisableDirectives": true,
615
"rules": {
7-
"no-debugger": "error",
8-
"no-var": "error",
9-
"prefer-arrow-callback": "error",
10-
"prefer-const": "error",
11-
"prefer-template": "error",
12-
"no-restricted-modules": ["error",
13-
// we can't rely on node standard modules in "native" or "browser" environments
14-
// - exceptions:
15-
// "punycode": since it's a package.json dependency
16-
"assert", "buffer", "child_process", "cluster", "crypto", "dgram", "dns", "domain", "events", "freelist", "fs",
17-
"http", "https", "module", "net", "os", "path", "querystring", "readline", "repl", "smalloc", "stream",
18-
"string_decoder", "sys", "timers", "tls", "tracing", "tty", "url", "util", "vm", "zlib"
19-
]
16+
// this is only needed because `createPromiseCallback` uses arguments to support the callback-style api
17+
// we should strongly consider dropping the callback and sync api variants (in say v6) to reduce the
18+
// surface area and complexity of tough-cookie
19+
"prefer-rest-params": "warn",
20+
"max-lines": ["warn", 500]
2021
}
2122
}

.github/workflows/integration.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
1-
name: Actions-CI
1+
name: Actions-CI
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master, v5]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master, v5]
88

99
jobs:
1010
build:
11-
1211
runs-on: ubuntu-latest
1312

1413
strategy:
1514
matrix:
16-
node-version: [14.x, 16.x]
15+
node-version: [latest, lts/*, lts/-1]
1716

1817
steps:
1918
- uses: actions/checkout@v2
2019
- name: Use Node.js ${{ matrix.node-version }}
21-
uses: actions/setup-node@v2
20+
uses: actions/setup-node@v3
2221
with:
2322
node-version: ${{ matrix.node-version }}
23+
cache: npm
2424
- name: Install dependencies and test
2525
run: npm install
2626
- run: npm test
27+
- run: npm run eslint
28+
- run: npm run prettier

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ npm-debug.log
55
docker-compose.override.yml
66
.nyc_output
77
coverage
8-
package-lock.json
98
.npm
109
.config
1110
.bash_history
11+
dist/

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
lib/version.js
1+
dist
2+
test

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"trailingComma": "all"
5+
}

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22

33
All notable changes to this project can be found at on the [Releases](https://github.com/salesforce/tough-cookie/releases)
44
page.
5-

CODE_OF_CONDUCT.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ culture where everyone feels included.
88

99
Salesforce open-source projects are committed to providing a friendly, safe, and
1010
welcoming environment for all, regardless of gender identity and expression,
11-
sexual orientation, disability, physical appearance, body size, ethnicity, nationality,
12-
race, age, religion, level of experience, education, socioeconomic status, or
11+
sexual orientation, disability, physical appearance, body size, ethnicity, nationality,
12+
race, age, religion, level of experience, education, socioeconomic status, or
1313
other similar personal characteristics.
1414

1515
The goal of this code of conduct is to specify a baseline standard of behavior so
@@ -25,33 +25,33 @@ Open Source Conduct Committee at ossconduct@salesforce.com.
2525

2626
In the interest of fostering an open and welcoming environment, we as
2727
contributors and maintainers pledge to making participation in our project and
28-
our community a harassment-free experience for everyone, regardless of gender
29-
identity and expression, sexual orientation, disability, physical appearance,
30-
body size, ethnicity, nationality, race, age, religion, level of experience, education,
28+
our community a harassment-free experience for everyone, regardless of gender
29+
identity and expression, sexual orientation, disability, physical appearance,
30+
body size, ethnicity, nationality, race, age, religion, level of experience, education,
3131
socioeconomic status, or other similar personal characteristics.
3232

3333
## Our Standards
3434

3535
Examples of behavior that contributes to creating a positive environment
3636
include:
3737

38-
* Using welcoming and inclusive language
39-
* Being respectful of differing viewpoints and experiences
40-
* Gracefully accepting constructive criticism
41-
* Focusing on what is best for the community
42-
* Showing empathy toward other community members
38+
- Using welcoming and inclusive language
39+
- Being respectful of differing viewpoints and experiences
40+
- Gracefully accepting constructive criticism
41+
- Focusing on what is best for the community
42+
- Showing empathy toward other community members
4343

4444
Examples of unacceptable behavior by participants include:
4545

46-
* The use of sexualized language or imagery and unwelcome sexual attention or
47-
advances
48-
* Personal attacks, insulting/derogatory comments, or trolling
49-
* Public or private harassment
50-
* Publishing, or threatening to publish, others' private information—such as
51-
a physical or electronic address—without explicit permission
52-
* Other conduct which could reasonably be considered inappropriate in a
53-
professional setting
54-
* Advocating for or encouraging any of the above behaviors
46+
- The use of sexualized language or imagery and unwelcome sexual attention or
47+
advances
48+
- Personal attacks, insulting/derogatory comments, or trolling
49+
- Public or private harassment
50+
- Publishing, or threatening to publish, others' private information—such as
51+
a physical or electronic address—without explicit permission
52+
- Other conduct which could reasonably be considered inappropriate in a
53+
professional setting
54+
- Advocating for or encouraging any of the above behaviors
5555

5656
## Our Responsibilities
5757

@@ -77,28 +77,28 @@ further defined and clarified by project maintainers.
7777
## Enforcement
7878

7979
Instances of abusive, harassing, or otherwise unacceptable behavior may be
80-
reported by contacting the Salesforce Open Source Conduct Committee
81-
at ossconduct@salesforce.com. All complaints will be reviewed and investigated
82-
and will result in a response that is deemed necessary and appropriate to the
83-
circumstances. The committee is obligated to maintain confidentiality with
84-
regard to the reporter of an incident. Further details of specific enforcement
80+
reported by contacting the Salesforce Open Source Conduct Committee
81+
at ossconduct@salesforce.com. All complaints will be reviewed and investigated
82+
and will result in a response that is deemed necessary and appropriate to the
83+
circumstances. The committee is obligated to maintain confidentiality with
84+
regard to the reporter of an incident. Further details of specific enforcement
8585
policies may be posted separately.
8686

8787
Project maintainers who do not follow or enforce the Code of Conduct in good
8888
faith may face temporary or permanent repercussions as determined by other
89-
members of the project's leadership and the Salesforce Open Source Conduct
89+
members of the project's leadership and the Salesforce Open Source Conduct
9090
Committee.
9191

9292
## Attribution
9393

9494
This Code of Conduct is adapted from the [Contributor Covenant][contributor-covenant-home],
95-
version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html.
96-
It includes adaptions and additions from [Go Community Code of Conduct][golang-coc],
95+
version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html.
96+
It includes adaptions and additions from [Go Community Code of Conduct][golang-coc],
9797
[CNCF Code of Conduct][cncf-coc], and [Microsoft Open Source Code of Conduct][microsoft-coc].
9898

9999
This Code of Conduct is licensed under the [Creative Commons Attribution 3.0 License][cc-by-3-us].
100100

101-
[contributor-covenant-home]: https://www.contributor-covenant.org (https://www.contributor-covenant.org/)
101+
[contributor-covenant-home]: https://www.contributor-covenant.org 'https://www.contributor-covenant.org/'
102102
[golang-coc]: https://golang.org/conduct
103103
[cncf-coc]: https://github.com/cncf/foundation/blob/master/code-of-conduct.md
104104
[microsoft-coc]: https://opensource.microsoft.com/codeofconduct/

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,31 @@
99
## Synopsis
1010

1111
```javascript
12-
var tough = require("tough-cookie");
13-
var Cookie = tough.Cookie;
14-
var cookie = Cookie.parse(header);
15-
cookie.value = "somethingdifferent";
16-
header = cookie.toString();
17-
var cookiejar = new tough.CookieJar();
12+
var tough = require('tough-cookie')
13+
var Cookie = tough.Cookie
14+
var cookie = Cookie.parse(header)
15+
cookie.value = 'somethingdifferent'
16+
header = cookie.toString()
17+
var cookiejar = new tough.CookieJar()
1818

1919
// Asynchronous!
2020
var cookie = await cookiejar.setCookie(
2121
cookie,
22-
"https://currentdomain.example.com/path"
23-
);
24-
var cookies = await cookiejar.getCookies("https://example.com/otherpath");
22+
'https://currentdomain.example.com/path',
23+
)
24+
var cookies = await cookiejar.getCookies('https://example.com/otherpath')
2525

2626
// Or with callbacks!
2727
cookiejar.setCookie(
2828
cookie,
29-
"https://currentdomain.example.com/path",
29+
'https://currentdomain.example.com/path',
3030
function (err, cookie) {
3131
/* ... */
32-
}
33-
);
34-
cookiejar.getCookies("http://example.com/otherpath", function (err, cookies) {
32+
},
33+
)
34+
cookiejar.getCookies('http://example.com/otherpath', function (err, cookies) {
3535
/* ... */
36-
});
36+
})
3737
```
3838

3939
Why the name? NPM modules `cookie`, `cookies` and `cookiejar` were already taken.
@@ -113,8 +113,8 @@ For use with `.sort()`, sorts a list of cookies into the recommended order given
113113
```javascript
114114
var cookies = [
115115
/* unsorted array of Cookie objects */
116-
];
117-
cookies = cookies.sort(cookieCompare);
116+
]
117+
cookies = cookies.sort(cookieCompare)
118118
```
119119

120120
> **Note**: Since the JavaScript `Date` is limited to a 1-ms precision, cookies within the same millisecond are entirely possible. This is especially true when using the `now` option to `.setCookie()`. The `.creationIndex` property is a per-process global counter, assigned during construction with `new Cookie()`, which preserves the spirit of the RFC sorting: older cookies go first. This works great for `MemoryCookieStore` since `Set-Cookie` headers are parsed in order, but is not so great for distributed systems. Sophisticated `Store`s may wish to set this to some other _logical clock_ so that if cookies A and B are created in the same millisecond, but cookie A is created before cookie B, then `A.creationIndex < B.creationIndex`. If you want to alter the global counter, which you probably _shouldn't_ do, it's stored in `Cookie.cookiesCreated`.
@@ -144,9 +144,9 @@ If options is not an object it is ignored, which means it can be used with [`Arr
144144
To process the Set-Cookie header(s) on a node HTTP/HTTPS response:
145145

146146
```javascript
147-
if (Array.isArray(res.headers["set-cookie"]))
148-
cookies = res.headers["set-cookie"].map(Cookie.parse);
149-
else cookies = [Cookie.parse(res.headers["set-cookie"])];
147+
if (Array.isArray(res.headers['set-cookie']))
148+
cookies = res.headers['set-cookie'].map(Cookie.parse)
149+
else cookies = [Cookie.parse(res.headers['set-cookie'])]
150150
```
151151

152152
_Note:_ In version 2.3.3, tough-cookie limited the number of spaces before the `=` to 256 characters. This limitation was removed in version 2.3.4.

jest.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { JestConfigWithTsJest } from "ts-jest";
2+
3+
const config: JestConfigWithTsJest = {
4+
preset: 'ts-jest',
5+
testEnvironment: 'node',
6+
rootDir: './lib/',
7+
testPathIgnorePatterns: ['./lib/__tests__/data/'],
8+
}
9+
10+
export default config

0 commit comments

Comments
 (0)