tough-cookie 6.0.0-rc.2 → 6.0.0
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/README.md +41 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -134,6 +134,44 @@ await cookieJar.setCookie(
|
|
|
134
134
|
> [!NOTE]
|
|
135
135
|
> It is highly recommended that you read [RFC6265bis - Section 4.1.3][cookie-prefixes-implementation] for more details on Cookie Prefixes.
|
|
136
136
|
|
|
137
|
+
### Potentially Trustworthy Origins are considered "Secure"
|
|
138
|
+
|
|
139
|
+
The definition of a "Secure" connection is not explicitly defined by [RFC6265bis][rfc6265bis-tracker] but the following text is
|
|
140
|
+
provided in [RFC6265bis - Section 5.8.3][secure-connection-note]:
|
|
141
|
+
|
|
142
|
+
> [!NOTE]
|
|
143
|
+
> Typically, user agents consider a connection secure if the connection makes use of transport-layer security, such as
|
|
144
|
+
> SSL or TLS, or if the host is trusted. For example, most user agents consider "https" to be a scheme that denotes a
|
|
145
|
+
> secure protocol and "localhost" to be trusted host.
|
|
146
|
+
|
|
147
|
+
As well as a note to [Appendix A. Changes from RFC6265][secure-connection-appendix-a] which refers to **"potentially trustworthy
|
|
148
|
+
origins"** which are defined in the [Secure Contexts - W3C Candidate Recommendation Draft][potentially-trustworthy-origin]:
|
|
149
|
+
|
|
150
|
+
> [!Note]
|
|
151
|
+
> Considers potentially trustworthy origins as "secure".
|
|
152
|
+
|
|
153
|
+
Since most web browsers treat `localhost` as a trustworthy origin, by default, so does `tough-cookie`. To disable this
|
|
154
|
+
behavior, the `CookieStore` must be configured with:
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
import { CookieJar, MemoryCookieStore } from 'tough-cookie'
|
|
158
|
+
|
|
159
|
+
const cookieJar = new CookieJar(new MemoryCookieStore(), {
|
|
160
|
+
// add configuration so localhost will not be considered trustworthy
|
|
161
|
+
// (fyi - this doesn't apply to https cookies on localhost as those use a secure protocol)
|
|
162
|
+
allowSecureOnLocal: false,
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
// this cookie will be persisted to storage
|
|
166
|
+
await cookieJar.setCookie(
|
|
167
|
+
'SID=12345; Domain=localhost; Secure;',
|
|
168
|
+
'http://localhost',
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
// but, on retrieval, it will not be returned
|
|
172
|
+
await cookieJar.getCookiesSync('http://localhost')
|
|
173
|
+
```
|
|
174
|
+
|
|
137
175
|
## Node.js Version Support
|
|
138
176
|
|
|
139
177
|
We follow the [Node.js release schedule](https://github.com/nodejs/Release#release-schedule) and support
|
|
@@ -150,5 +188,8 @@ for older versions of node, and we will do so in consultation with our community
|
|
|
150
188
|
[rfc6265bis-tracker]: https://datatracker.ietf.org/doc/draft-ietf-httpbis-rfc6265bis/
|
|
151
189
|
[samesite-implementation]: https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-02#section-8.8
|
|
152
190
|
[cookie-prefixes-implementation]: https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-02#section-4.1.3
|
|
191
|
+
[secure-connection-note]: https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-19#section-5.8.3-2.1.2.3.1
|
|
192
|
+
[secure-connection-appendix-a]: https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-19#appendix-A-1.7.1
|
|
193
|
+
[potentially-trustworthy-origin]: https://www.w3.org/TR/secure-contexts/#is-origin-trustworthy
|
|
153
194
|
[prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg
|
|
154
195
|
[yarn-repo]: https://yarnpkg.com/package?name=tough-cookie
|