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

tough-cookie

Package Overview
Dependencies
Maintainers
2
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tough-cookie - npm Package Compare versions

Comparing version 5.0.0 to 5.1.0-rc.0

11

dist/cookie/cookie.d.ts

@@ -221,2 +221,13 @@ import type { SerializedCookie } from './constants';

/**
* Similar to {@link Cookie.expiryTime}, computes the absolute unix-epoch milliseconds that this cookie expires and returns it as a Date.
*
* The "Max-Age" attribute takes precedence over "Expires" (as per the RFC). The {@link Cookie.lastAccessed} attribute
* (or the `now` parameter if given) is used to offset the {@link Cookie.maxAge} attribute.
*
* If Expires ({@link Cookie.expires}) is set, that's returned.
*
* @param now - can be used to provide a time offset (instead of {@link Cookie.lastAccessed}) to use when calculating the "Max-Age" value
*/
expiryDate(now?: Date): Date | undefined;
/**
* Indicates if the cookie has been persisted to a store or not.

@@ -223,0 +234,0 @@ * @public

@@ -679,2 +679,32 @@ "use strict";

/**
* Similar to {@link Cookie.expiryTime}, computes the absolute unix-epoch milliseconds that this cookie expires and returns it as a Date.
*
* The "Max-Age" attribute takes precedence over "Expires" (as per the RFC). The {@link Cookie.lastAccessed} attribute
* (or the `now` parameter if given) is used to offset the {@link Cookie.maxAge} attribute.
*
* If Expires ({@link Cookie.expires}) is set, that's returned.
*
* @param now - can be used to provide a time offset (instead of {@link Cookie.lastAccessed}) to use when calculating the "Max-Age" value
*/
expiryDate(now) {
const millisec = this.expiryTime(now);
if (millisec == Infinity) {
// The 31-bit value of 2147483647000 was chosen to be the MAX_TIME representable
// in tough-cookie though MDN states that the actual maximum value for a Date is 8.64e15.
// I'm guessing this is due to the Y2038 problem that would affect systems that store
// unix time as 32-bit integers.
// See:
// - https://github.com/salesforce/tough-cookie/commit/0616f70bf725e00c63d442544ad230c4f8b23357
// - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#the_epoch_timestamps_and_invalid_date
// - https://en.wikipedia.org/wiki/Year_2038_problem
return new Date(2147483647000);
}
else if (millisec == -Infinity) {
return new Date(0);
}
else {
return millisec == undefined ? undefined : new Date(millisec);
}
}
/**
* Indicates if the cookie has been persisted to a store or not.

@@ -681,0 +711,0 @@ * @public

2

dist/cookie/cookieJar.d.ts

@@ -313,3 +313,3 @@ import { Store } from '../store';

*/
getCookies(url: string | URL, options?: GetCookiesOptions | undefined): Promise<Cookie[]>;
getCookies(url: string | URL, options?: GetCookiesOptions): Promise<Cookie[]>;
/**

@@ -316,0 +316,0 @@ * @internal No doc because this is an overload that supports the implementation

@@ -530,3 +530,3 @@ "use strict";

const expiryTime = c.expiryTime();
if (expireCheck && expiryTime && expiryTime <= now) {
if (expireCheck && expiryTime != undefined && expiryTime <= now) {
store.removeCookie(c.domain, c.path, c.key, () => { }); // result ignored

@@ -533,0 +533,0 @@ return false;

@@ -35,4 +35,3 @@ "use strict";

// is a %x2F ("/") character."
if (new RegExp(`^${cookiePath}`).test(reqPath) &&
reqPath[cookiePath.length] === '/') {
if (reqPath.startsWith(cookiePath) && reqPath[cookiePath.length] === '/') {
return true;

@@ -39,0 +38,0 @@ }

@@ -32,3 +32,4 @@ "use strict";

safeArrayToString(val, seenArrays)
: String(val);
: // eslint-disable-next-line @typescript-eslint/no-base-to-string
String(val);
}

@@ -35,0 +36,0 @@ else {

@@ -5,2 +5,2 @@ /**

*/
export declare const version = "5.0.0";
export declare const version = "5.1.0-rc.0";

@@ -8,2 +8,2 @@ "use strict";

*/
exports.version = '5.0.0';
exports.version = '5.1.0-rc.0';

@@ -78,3 +78,3 @@ {

],
"version": "5.0.0",
"version": "5.1.0-rc.0",
"homepage": "https://github.com/salesforce/tough-cookie",

@@ -96,17 +96,21 @@ "repository": {

"scripts": {
"api:dev": "npm run build && npm run api:extract -- --local && npm run api:docs",
"api:docs": "api-documenter markdown --input-folder ./tmp --output-folder ./api/docs",
"api:extract": "api-extractor run --verbose",
"build": "npm run clean && tsc",
"clean": "rm -rf dist",
"version": "genversion --template version-template.ejs --force lib/version.ts && git add lib/version.ts",
"test": "npm run test:ts && npm run test:legacy",
"test:ts": "jest",
"test:legacy": "npm run build -- --declaration false && ./test/scripts/vows.js test/*_test.js",
"typecheck": "tsc --noEmit",
"cover": "jest --coverage",
"lint": "eslint .",
"eslint": "eslint .",
"prettier": "prettier '**/*.{json,ts,yaml,md}'",
"format": "npm run eslint -- --fix"
"build": "npm run _build:clean && npm run _build:compile",
"lint": "npm run _lint:check",
"prepack": "npm run build",
"prepare-pr": "npm test && npm run _api:update && npm run _docs:generate && npm run _format:fix && npm run _lint:fix",
"test": "npm run build && npm run _test:ts && npm run _test:legacy",
"version": "npm run _version:generate && npm run prepare-pr && git add --renormalize .",
"_api:check": "api-extractor run --verbose",
"_api:update": "api-extractor run --verbose --local",
"_build:clean": "rm -rf dist",
"_build:compile": "tsc",
"_docs:generate": "api-documenter markdown --input-folder ./tmp --output-folder ./api/docs",
"_docs:fix": "prettier ./api/docs --write",
"_format:check": "prettier . --check",
"_format:fix": "prettier . --write",
"_lint:check": "eslint .",
"_lint:fix": "eslint . --fix",
"_test:legacy": "./test/scripts/vows.js test/*_test.js",
"_test:ts": "jest",
"_version:generate": "genversion --template version-template.ejs --force lib/version.ts"
},

@@ -113,0 +117,0 @@ "//": "We only support node 18+, but v16 still works. We won't block v16 until it becomes a burden.",

@@ -25,8 +25,12 @@ # Tough Cookie &middot; [![RFC6265][rfc6265-badge]][rfc6265-tracker] [![RFC6265bis][rfc6265bis-badge]][rfc6265bis-tracker] [![npm version][npm-badge]][npm-repo] [![CI on Github Actions: salesforce/tough-cookie][ci-badge]][ci-url] ![PRs Welcome][prs-welcome-badge]

// parse a `Cookie` request header
const reqCookies = 'ID=298zf09hf012fh2; csrf=u32t4o3tb3gg43; _gat=1'.split(';').map(Cookie.parse)
const reqCookies = 'ID=298zf09hf012fh2; csrf=u32t4o3tb3gg43; _gat=1'
.split(';')
.map(Cookie.parse)
// generate a `Cookie` request header
const cookieHeader = reqCookies.map(cookie => cookie.cookieString()).join(';')
const cookieHeader = reqCookies.map((cookie) => cookie.cookieString()).join(';')
// parse a Set-Cookie response header
const resCookie = Cookie.parse('foo=bar; Domain=example.com; Path=/; Expires=Tue, 21 Oct 2025 00:00:00 GMT')
const resCookie = Cookie.parse(
'foo=bar; Domain=example.com; Path=/; Expires=Tue, 21 Oct 2025 00:00:00 GMT',
)
// generate a Set-Cookie response header

@@ -62,4 +66,10 @@ const setCookieHeader = cookie.toString()

// storing cookies with various SameSite attributes
await cookieJar.setCookie('strict=authorized; SameSite=strict', 'http://example.com/index.html')
await cookieJar.setCookie('lax=okay; SameSite=lax', 'http://example.com/index.html')
await cookieJar.setCookie(
'strict=authorized; SameSite=strict',
'http://example.com/index.html',
)
await cookieJar.setCookie(
'lax=okay; SameSite=lax',
'http://example.com/index.html',
)
await cookieJar.setCookie('normal=whatever', 'http://example.com/index.html')

@@ -110,3 +120,3 @@

const cookieJar = new CookieJar(new MemoryCookieStore(), {
prefixSecurity: 'silent'
prefixSecurity: 'silent',
})

@@ -138,4 +148,4 @@

[npm-repo]: https://www.npmjs.com/package/tough-cookie
[ci-badge]: https://github.com/salesforce/tough-cookie/actions/workflows/integration.yaml/badge.svg
[ci-url]: https://github.com/salesforce/tough-cookie/actions/workflows/integration.yaml
[ci-badge]: https://github.com/salesforce/tough-cookie/actions/workflows/ci.yaml/badge.svg
[ci-url]: https://github.com/salesforce/tough-cookie/actions/workflows/ci.yaml
[rfc6265-badge]: https://img.shields.io/badge/RFC-6265-flat?labelColor=000000&color=666666

@@ -142,0 +152,0 @@ [rfc6265-tracker]: https://datatracker.ietf.org/doc/rfc6265/

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