From b47e1a0e77b54f0de1314a3f0e33cac0d23d6322 Mon Sep 17 00:00:00 2001 From: Colin Casey Date: Mon, 22 Apr 2024 12:39:57 -0300 Subject: [PATCH] Fix warnings and un-ignore the docs folder --- api/.gitignore | 36 ----- api/docs/index.md | 29 ++++ api/docs/tough-cookie.callback.md | 13 ++ api/docs/tough-cookie.canonicaldomain.md | 2 +- api/docs/tough-cookie.cookiecompare.md | 2 +- .../tough-cookie.cookiejar._constructor_.md | 2 +- ...ugh-cookie.createcookieoptions.creation.md | 15 ++ ...tough-cookie.createcookieoptions.domain.md | 13 ++ ...ough-cookie.createcookieoptions.expires.md | 13 ++ ...h-cookie.createcookieoptions.extensions.md | 13 ++ ...ugh-cookie.createcookieoptions.hostonly.md | 13 ++ ...ugh-cookie.createcookieoptions.httponly.md | 13 ++ .../tough-cookie.createcookieoptions.key.md | 13 ++ ...cookie.createcookieoptions.lastaccessed.md | 13 ++ ...tough-cookie.createcookieoptions.maxage.md | 13 ++ .../tough-cookie.createcookieoptions.path.md | 13 ++ ...ookie.createcookieoptions.pathisdefault.md | 13 ++ ...ugh-cookie.createcookieoptions.samesite.md | 13 ++ ...tough-cookie.createcookieoptions.secure.md | 13 ++ .../tough-cookie.createcookieoptions.value.md | 13 ++ api/docs/tough-cookie.defaultpath.md | 2 +- api/docs/tough-cookie.domainmatch.md | 4 +- api/docs/tough-cookie.errorcallback.md | 13 ++ api/docs/tough-cookie.fromjson.md | 57 +++++++ ...tough-cookie.getcookiesoptions.allpaths.md | 20 +++ .../tough-cookie.getcookiesoptions.expire.md | 20 +++ .../tough-cookie.getcookiesoptions.http.md | 15 ++ api/docs/tough-cookie.getcookiesoptions.md | 147 +++++++++++++++++ ...ookie.getcookiesoptions.samesitecontext.md | 28 ++++ .../tough-cookie.getcookiesoptions.sort.md | 15 ++ ...blicsuffixoptions.allowspecialusedomain.md | 25 +++ ...okie.getpublicsuffixoptions.ignoreerror.md | 13 ++ api/docs/tough-cookie.md | 51 +++--- ...ugh-cookie.memorycookiestore.findcookie.md | 6 +- ...h-cookie.memorycookiestore.findcookie_1.md | 6 +- api/docs/tough-cookie.nullable.md | 13 ++ api/docs/tough-cookie.parse.md | 73 +++++++++ api/docs/tough-cookie.parsedate.md | 2 +- api/docs/tough-cookie.prefixsecurityenum.md | 25 +++ .../tough-cookie.setcookieoptions.http.md | 15 ++ ...ugh-cookie.setcookieoptions.ignoreerror.md | 15 ++ .../tough-cookie.setcookieoptions.loose.md | 15 ++ api/docs/tough-cookie.setcookieoptions.md | 151 ++++++++++++++++++ api/docs/tough-cookie.setcookieoptions.now.md | 15 ++ ...cookie.setcookieoptions.samesitecontext.md | 28 ++++ api/docs/tough-cookie.store.findcookie.md | 6 +- api/docs/tough-cookie.store.findcookie_1.md | 6 +- api/docs/tough-cookie.store.findcookies.md | 4 +- api/docs/tough-cookie.store.findcookies_1.md | 4 +- api/docs/tough-cookie.store.removecookie.md | 6 +- api/docs/tough-cookie.store.removecookie_1.md | 6 +- api/docs/tough-cookie.store.removecookies.md | 2 +- .../tough-cookie.store.removecookies_1.md | 2 +- api/tough-cookie.api.md | 24 ++- lib/cookie/cookieCompare.ts | 2 +- lib/cookie/cookieJar.ts | 2 + lib/cookie/index.ts | 26 ++- lib/memstore.ts | 4 + lib/store.ts | 2 + lib/utils.ts | 5 +- 60 files changed, 1043 insertions(+), 100 deletions(-) delete mode 100644 api/.gitignore create mode 100644 api/docs/index.md create mode 100644 api/docs/tough-cookie.callback.md create mode 100644 api/docs/tough-cookie.createcookieoptions.creation.md create mode 100644 api/docs/tough-cookie.createcookieoptions.domain.md create mode 100644 api/docs/tough-cookie.createcookieoptions.expires.md create mode 100644 api/docs/tough-cookie.createcookieoptions.extensions.md create mode 100644 api/docs/tough-cookie.createcookieoptions.hostonly.md create mode 100644 api/docs/tough-cookie.createcookieoptions.httponly.md create mode 100644 api/docs/tough-cookie.createcookieoptions.key.md create mode 100644 api/docs/tough-cookie.createcookieoptions.lastaccessed.md create mode 100644 api/docs/tough-cookie.createcookieoptions.maxage.md create mode 100644 api/docs/tough-cookie.createcookieoptions.path.md create mode 100644 api/docs/tough-cookie.createcookieoptions.pathisdefault.md create mode 100644 api/docs/tough-cookie.createcookieoptions.samesite.md create mode 100644 api/docs/tough-cookie.createcookieoptions.secure.md create mode 100644 api/docs/tough-cookie.createcookieoptions.value.md create mode 100644 api/docs/tough-cookie.errorcallback.md create mode 100644 api/docs/tough-cookie.fromjson.md create mode 100644 api/docs/tough-cookie.getcookiesoptions.allpaths.md create mode 100644 api/docs/tough-cookie.getcookiesoptions.expire.md create mode 100644 api/docs/tough-cookie.getcookiesoptions.http.md create mode 100644 api/docs/tough-cookie.getcookiesoptions.md create mode 100644 api/docs/tough-cookie.getcookiesoptions.samesitecontext.md create mode 100644 api/docs/tough-cookie.getcookiesoptions.sort.md create mode 100644 api/docs/tough-cookie.getpublicsuffixoptions.allowspecialusedomain.md create mode 100644 api/docs/tough-cookie.getpublicsuffixoptions.ignoreerror.md create mode 100644 api/docs/tough-cookie.nullable.md create mode 100644 api/docs/tough-cookie.parse.md create mode 100644 api/docs/tough-cookie.prefixsecurityenum.md create mode 100644 api/docs/tough-cookie.setcookieoptions.http.md create mode 100644 api/docs/tough-cookie.setcookieoptions.ignoreerror.md create mode 100644 api/docs/tough-cookie.setcookieoptions.loose.md create mode 100644 api/docs/tough-cookie.setcookieoptions.md create mode 100644 api/docs/tough-cookie.setcookieoptions.now.md create mode 100644 api/docs/tough-cookie.setcookieoptions.samesitecontext.md diff --git a/api/.gitignore b/api/.gitignore deleted file mode 100644 index 9928fedf..00000000 --- a/api/.gitignore +++ /dev/null @@ -1,36 +0,0 @@ -# ignoring all the generated docs initially -docs/*.md - -# subsequent PRs will un-ignore areas that are under review until -# all docs are complete and we can drop this ignore file entirely -!docs/tough-cookie.cookie.md -!docs/tough-cookie.cookie.*.md -!docs/tough-cookie.createcookieoptions.md -!docs/tough-cookie.parsecookieoptions.md -!docs/tough-cookie.parsecookieoptions.loose.md -!docs/tough-cookie.serializedcookie.md -!docs/tough-cookie.prefixsecurity.md -!docs/tough-cookie.md -!docs/tough-cookie.store.md -!docs/tough-cookie.store.* -!docs/tough-cookie.memorycookiestore.md -!docs/tough-cookie.memorycookiestore.* -!docs/tough-cookie.cookiejar.md -!docs/tough-cookie.cookiejar.* -!docs/tough-cookie.serializedcookiejar.md -!docs/tough-cookie.serializedcookiejar.* -!docs/tough-cookie.createcookiejaroptions.md -!docs/tough-cookie.createcookiejaroptions.* -!docs/tough-cookie.parametererror.md -!docs/tough-cookie.permutepath.md -!docs/tough-cookie.version.md -!docs/tough-cookie.parsedate.md -!docs/tough-cookie.formatdate.md -!docs/tough-cookie.domainmatch.md -!docs/tough-cookie.defaultpath.md -!docs/tough-cookie.cookiecompare.md -!docs/tough-cookie.permutedomain.md -!docs/tough-cookie.pathmatch.md -!docs/tough-cookie.canonicaldomain.md -!docs/tough-cookie.getpublicsuffix.md -!docs/tough-cookie.getpublicsuffixoptions.md diff --git a/api/docs/index.md b/api/docs/index.md new file mode 100644 index 00000000..71821947 --- /dev/null +++ b/api/docs/index.md @@ -0,0 +1,29 @@ + + +[Home](./index.md) + +## API Reference + +## Packages + + + +
+ +Package + + + + +Description + + +
+ +[tough-cookie](./tough-cookie.md) + + + + + +
diff --git a/api/docs/tough-cookie.callback.md b/api/docs/tough-cookie.callback.md new file mode 100644 index 00000000..a2447633 --- /dev/null +++ b/api/docs/tough-cookie.callback.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [Callback](./tough-cookie.callback.md) + +## Callback interface + +A callback function that accepts an error or a result. + +**Signature:** + +```typescript +export interface Callback +``` diff --git a/api/docs/tough-cookie.canonicaldomain.md b/api/docs/tough-cookie.canonicaldomain.md index d16ce2b8..a4274a19 100644 --- a/api/docs/tough-cookie.canonicaldomain.md +++ b/api/docs/tough-cookie.canonicaldomain.md @@ -37,7 +37,7 @@ domainName -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> diff --git a/api/docs/tough-cookie.cookiecompare.md b/api/docs/tough-cookie.cookiecompare.md index e3020d34..2965cc34 100644 --- a/api/docs/tough-cookie.cookiecompare.md +++ b/api/docs/tough-cookie.cookiecompare.md @@ -89,7 +89,7 @@ NOTE: Not all user agents sort the cookie-list in this order, but this order ref \#\#\# Custom Store Implementors -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 . The [Cookie.creationIndex](./tough-cookie.cookie.creationindex.md) 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](./tough-cookie.memorycookiestore.md) since `Set-Cookie` headers are parsed in order, but is not so great for distributed systems. +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 `CookieJar.setCookie(...)`. The [Cookie.creationIndex](./tough-cookie.cookie.creationindex.md) 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](./tough-cookie.memorycookiestore.md) since `Set-Cookie` headers are parsed in order, but is not so great for distributed systems. Sophisticated Stores 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`. diff --git a/api/docs/tough-cookie.cookiejar._constructor_.md b/api/docs/tough-cookie.cookiejar._constructor_.md index ded73145..4d1ac506 100644 --- a/api/docs/tough-cookie.cookiejar._constructor_.md +++ b/api/docs/tough-cookie.cookiejar._constructor_.md @@ -37,7 +37,7 @@ store -Nullable<[Store](./tough-cookie.store.md)> +[Nullable](./tough-cookie.nullable.md)<[Store](./tough-cookie.store.md)> diff --git a/api/docs/tough-cookie.createcookieoptions.creation.md b/api/docs/tough-cookie.createcookieoptions.creation.md new file mode 100644 index 00000000..44798f26 --- /dev/null +++ b/api/docs/tough-cookie.createcookieoptions.creation.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [CreateCookieOptions](./tough-cookie.createcookieoptions.md) > [creation](./tough-cookie.createcookieoptions.creation.md) + +## CreateCookieOptions.creation property + +Set to the date and time when a Cookie is initially stored or a matching cookie is received that replaces an existing cookie (See [RFC6265 Section 5.3](https://www.rfc-editor.org/rfc/rfc6265.html#section-5.3)). + +Also used to maintain ordering among cookies. Among cookies that have equal-length path fields, cookies with earlier creation-times are listed before cookies with later creation-times (See [RFC6265 Section 5.4](https://www.rfc-editor.org/rfc/rfc6265.html#section-5.4)). + +**Signature:** + +```typescript +creation?: Date | 'Infinity' | null; +``` diff --git a/api/docs/tough-cookie.createcookieoptions.domain.md b/api/docs/tough-cookie.createcookieoptions.domain.md new file mode 100644 index 00000000..6d765df3 --- /dev/null +++ b/api/docs/tough-cookie.createcookieoptions.domain.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [CreateCookieOptions](./tough-cookie.createcookieoptions.md) > [domain](./tough-cookie.createcookieoptions.domain.md) + +## CreateCookieOptions.domain property + +The 'Domain' attribute of the cookie represents the domain the cookie belongs to (See [RFC6265 Section 5.2.3](https://www.rfc-editor.org/rfc/rfc6265.html#section-5.2.3)). + +**Signature:** + +```typescript +domain?: string | null; +``` diff --git a/api/docs/tough-cookie.createcookieoptions.expires.md b/api/docs/tough-cookie.createcookieoptions.expires.md new file mode 100644 index 00000000..6bdc424a --- /dev/null +++ b/api/docs/tough-cookie.createcookieoptions.expires.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [CreateCookieOptions](./tough-cookie.createcookieoptions.md) > [expires](./tough-cookie.createcookieoptions.expires.md) + +## CreateCookieOptions.expires property + +The 'Expires' attribute of the cookie (See [RFC6265 Section 5.2.1](https://www.rfc-editor.org/rfc/rfc6265.html#section-5.2.1)). + +**Signature:** + +```typescript +expires?: Date | 'Infinity' | null; +``` diff --git a/api/docs/tough-cookie.createcookieoptions.extensions.md b/api/docs/tough-cookie.createcookieoptions.extensions.md new file mode 100644 index 00000000..8366f3fe --- /dev/null +++ b/api/docs/tough-cookie.createcookieoptions.extensions.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [CreateCookieOptions](./tough-cookie.createcookieoptions.md) > [extensions](./tough-cookie.createcookieoptions.extensions.md) + +## CreateCookieOptions.extensions property + +Contains attributes which are not part of the defined spec but match the `extension-av` syntax defined in Section 4.1.1 of RFC6265 (See [RFC6265 Section 4.1.1](https://www.rfc-editor.org/rfc/rfc6265.html#section-4.1.1)). + +**Signature:** + +```typescript +extensions?: string[] | null; +``` diff --git a/api/docs/tough-cookie.createcookieoptions.hostonly.md b/api/docs/tough-cookie.createcookieoptions.hostonly.md new file mode 100644 index 00000000..3e7e04f8 --- /dev/null +++ b/api/docs/tough-cookie.createcookieoptions.hostonly.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [CreateCookieOptions](./tough-cookie.createcookieoptions.md) > [hostOnly](./tough-cookie.createcookieoptions.hostonly.md) + +## CreateCookieOptions.hostOnly property + +A boolean flag indicating if a cookie is a host-only cookie (i.e.; when the request's host exactly matches the domain of the cookie) or not (See [RFC6265 Section 5.3](https://www.rfc-editor.org/rfc/rfc6265.html#section-5.3)). + +**Signature:** + +```typescript +hostOnly?: boolean | null; +``` diff --git a/api/docs/tough-cookie.createcookieoptions.httponly.md b/api/docs/tough-cookie.createcookieoptions.httponly.md new file mode 100644 index 00000000..c2a742de --- /dev/null +++ b/api/docs/tough-cookie.createcookieoptions.httponly.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [CreateCookieOptions](./tough-cookie.createcookieoptions.md) > [httpOnly](./tough-cookie.createcookieoptions.httponly.md) + +## CreateCookieOptions.httpOnly property + +The 'HttpOnly' flag of the cookie indicates if the cookie is inaccessible to client scripts or not (See [RFC6265 Section 5.2.6](https://www.rfc-editor.org/rfc/rfc6265.html#section-5.2.6)). + +**Signature:** + +```typescript +httpOnly?: boolean; +``` diff --git a/api/docs/tough-cookie.createcookieoptions.key.md b/api/docs/tough-cookie.createcookieoptions.key.md new file mode 100644 index 00000000..4fac3814 --- /dev/null +++ b/api/docs/tough-cookie.createcookieoptions.key.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [CreateCookieOptions](./tough-cookie.createcookieoptions.md) > [key](./tough-cookie.createcookieoptions.key.md) + +## CreateCookieOptions.key property + +The name or key of the cookie + +**Signature:** + +```typescript +key?: string; +``` diff --git a/api/docs/tough-cookie.createcookieoptions.lastaccessed.md b/api/docs/tough-cookie.createcookieoptions.lastaccessed.md new file mode 100644 index 00000000..085df608 --- /dev/null +++ b/api/docs/tough-cookie.createcookieoptions.lastaccessed.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [CreateCookieOptions](./tough-cookie.createcookieoptions.md) > [lastAccessed](./tough-cookie.createcookieoptions.lastaccessed.md) + +## CreateCookieOptions.lastAccessed property + +Set to the date and time when a cookie was initially stored ([RFC6265 Section 5.3](https://www.rfc-editor.org/rfc/rfc6265.html#section-5.3)) and updated whenever the cookie is retrieved from the [CookieJar](./tough-cookie.cookiejar.md) ([RFC6265 Section 5.4](https://www.rfc-editor.org/rfc/rfc6265.html#section-5.4)). + +**Signature:** + +```typescript +lastAccessed?: Date | 'Infinity' | null; +``` diff --git a/api/docs/tough-cookie.createcookieoptions.maxage.md b/api/docs/tough-cookie.createcookieoptions.maxage.md new file mode 100644 index 00000000..7b8e2177 --- /dev/null +++ b/api/docs/tough-cookie.createcookieoptions.maxage.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [CreateCookieOptions](./tough-cookie.createcookieoptions.md) > [maxAge](./tough-cookie.createcookieoptions.maxage.md) + +## CreateCookieOptions.maxAge property + +The 'Max-Age' attribute of the cookie (See [RFC6265 Section 5.2.2](https://www.rfc-editor.org/rfc/rfc6265.html#section-5.2.2)). + +**Signature:** + +```typescript +maxAge?: number | 'Infinity' | '-Infinity' | null; +``` diff --git a/api/docs/tough-cookie.createcookieoptions.path.md b/api/docs/tough-cookie.createcookieoptions.path.md new file mode 100644 index 00000000..64cbd3aa --- /dev/null +++ b/api/docs/tough-cookie.createcookieoptions.path.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [CreateCookieOptions](./tough-cookie.createcookieoptions.md) > [path](./tough-cookie.createcookieoptions.path.md) + +## CreateCookieOptions.path property + +The 'Path' attribute of the cookie represents the path of the cookie (See [RFC6265 Section 5.2.4](https://www.rfc-editor.org/rfc/rfc6265.html#section-5.2.4)). + +**Signature:** + +```typescript +path?: string | null; +``` diff --git a/api/docs/tough-cookie.createcookieoptions.pathisdefault.md b/api/docs/tough-cookie.createcookieoptions.pathisdefault.md new file mode 100644 index 00000000..e1f8632f --- /dev/null +++ b/api/docs/tough-cookie.createcookieoptions.pathisdefault.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [CreateCookieOptions](./tough-cookie.createcookieoptions.md) > [pathIsDefault](./tough-cookie.createcookieoptions.pathisdefault.md) + +## CreateCookieOptions.pathIsDefault property + +A boolean flag indicating if a cookie had no 'Path' attribute and the default path was used (See [RFC6265 Section 5.2.4](https://www.rfc-editor.org/rfc/rfc6265.html#section-5.2.4)). + +**Signature:** + +```typescript +pathIsDefault?: boolean | null; +``` diff --git a/api/docs/tough-cookie.createcookieoptions.samesite.md b/api/docs/tough-cookie.createcookieoptions.samesite.md new file mode 100644 index 00000000..47c48740 --- /dev/null +++ b/api/docs/tough-cookie.createcookieoptions.samesite.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [CreateCookieOptions](./tough-cookie.createcookieoptions.md) > [sameSite](./tough-cookie.createcookieoptions.samesite.md) + +## CreateCookieOptions.sameSite property + +The 'SameSite' attribute of a cookie as defined in RFC6265bis (See [RFC6265bis (v13) Section 5.2](https://www.ietf.org/archive/id/draft-ietf-httpbis-rfc6265bis-13.html#section-5.2)). + +**Signature:** + +```typescript +sameSite?: string | undefined; +``` diff --git a/api/docs/tough-cookie.createcookieoptions.secure.md b/api/docs/tough-cookie.createcookieoptions.secure.md new file mode 100644 index 00000000..a6ad7180 --- /dev/null +++ b/api/docs/tough-cookie.createcookieoptions.secure.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [CreateCookieOptions](./tough-cookie.createcookieoptions.md) > [secure](./tough-cookie.createcookieoptions.secure.md) + +## CreateCookieOptions.secure property + +The 'Secure' flag of the cookie indicates if the scope of the cookie is limited to secure channels (e.g.; HTTPS) or not (See [RFC6265 Section 5.2.5](https://www.rfc-editor.org/rfc/rfc6265.html#section-5.2.5)). + +**Signature:** + +```typescript +secure?: boolean; +``` diff --git a/api/docs/tough-cookie.createcookieoptions.value.md b/api/docs/tough-cookie.createcookieoptions.value.md new file mode 100644 index 00000000..70ad3a2d --- /dev/null +++ b/api/docs/tough-cookie.createcookieoptions.value.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [CreateCookieOptions](./tough-cookie.createcookieoptions.md) > [value](./tough-cookie.createcookieoptions.value.md) + +## CreateCookieOptions.value property + +The value of the cookie + +**Signature:** + +```typescript +value?: string; +``` diff --git a/api/docs/tough-cookie.defaultpath.md b/api/docs/tough-cookie.defaultpath.md index ca569406..69c721ad 100644 --- a/api/docs/tough-cookie.defaultpath.md +++ b/api/docs/tough-cookie.defaultpath.md @@ -37,7 +37,7 @@ path -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> diff --git a/api/docs/tough-cookie.domainmatch.md b/api/docs/tough-cookie.domainmatch.md index e00ba0fd..d5c0d336 100644 --- a/api/docs/tough-cookie.domainmatch.md +++ b/api/docs/tough-cookie.domainmatch.md @@ -37,7 +37,7 @@ domain -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> @@ -53,7 +53,7 @@ cookieDomain -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> diff --git a/api/docs/tough-cookie.errorcallback.md b/api/docs/tough-cookie.errorcallback.md new file mode 100644 index 00000000..0ff1a52e --- /dev/null +++ b/api/docs/tough-cookie.errorcallback.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [ErrorCallback](./tough-cookie.errorcallback.md) + +## ErrorCallback interface + +A callback function that only accepts an error. + +**Signature:** + +```typescript +export interface ErrorCallback +``` diff --git a/api/docs/tough-cookie.fromjson.md b/api/docs/tough-cookie.fromjson.md new file mode 100644 index 00000000..43fd7b3b --- /dev/null +++ b/api/docs/tough-cookie.fromjson.md @@ -0,0 +1,57 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [fromJSON](./tough-cookie.fromjson.md) + +## fromJSON() function + +Does the reverse of [Cookie.toJSON()](./tough-cookie.cookie.tojson.md). + +**Signature:** + +```typescript +export declare function fromJSON(str: unknown): Cookie | undefined; +``` + +## Parameters + + + +
+ +Parameter + + + + +Type + + + + +Description + + +
+ +str + + + + +unknown + + + + +An unparsed JSON string or a value that has already been parsed as JSON + + +
+**Returns:** + +[Cookie](./tough-cookie.cookie.md) \| undefined + +## Remarks + +Any Date properties (such as .expires, .creation, and .lastAccessed) are parsed via Date.parse, not tough-cookie's parseDate, since ISO timestamps are being handled at this layer. + diff --git a/api/docs/tough-cookie.getcookiesoptions.allpaths.md b/api/docs/tough-cookie.getcookiesoptions.allpaths.md new file mode 100644 index 00000000..fb724fef --- /dev/null +++ b/api/docs/tough-cookie.getcookiesoptions.allpaths.md @@ -0,0 +1,20 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [GetCookiesOptions](./tough-cookie.getcookiesoptions.md) > [allPaths](./tough-cookie.getcookiesoptions.allpaths.md) + +## GetCookiesOptions.allPaths property + +If `true`, do not scope cookies by path. If `false`, then RFC-compliant path scoping will be used. + +**Signature:** + +```typescript +allPaths?: boolean | undefined; +``` + +## Remarks + +- May not be supported by the underlying store (the default [MemoryCookieStore](./tough-cookie.memorycookiestore.md) supports it). + +Defaults to `false` if not provided. + diff --git a/api/docs/tough-cookie.getcookiesoptions.expire.md b/api/docs/tough-cookie.getcookiesoptions.expire.md new file mode 100644 index 00000000..76373aab --- /dev/null +++ b/api/docs/tough-cookie.getcookiesoptions.expire.md @@ -0,0 +1,20 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [GetCookiesOptions](./tough-cookie.getcookiesoptions.md) > [expire](./tough-cookie.getcookiesoptions.expire.md) + +## GetCookiesOptions.expire property + +Perform `expiry-time` checking of cookies and asynchronously remove expired cookies from the store. + +**Signature:** + +```typescript +expire?: boolean | undefined; +``` + +## Remarks + +- Using `false` returns expired cookies and does not remove them from the store which is potentially useful for replaying `Set-Cookie` headers. + +Defaults to `true` if not provided. + diff --git a/api/docs/tough-cookie.getcookiesoptions.http.md b/api/docs/tough-cookie.getcookiesoptions.http.md new file mode 100644 index 00000000..e8c27943 --- /dev/null +++ b/api/docs/tough-cookie.getcookiesoptions.http.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [GetCookiesOptions](./tough-cookie.getcookiesoptions.md) > [http](./tough-cookie.getcookiesoptions.http.md) + +## GetCookiesOptions.http property + +Indicates if this is an HTTP or non-HTTP API. Affects HttpOnly cookies. + +Defaults to `true` if not provided. + +**Signature:** + +```typescript +http?: boolean | undefined; +``` diff --git a/api/docs/tough-cookie.getcookiesoptions.md b/api/docs/tough-cookie.getcookiesoptions.md new file mode 100644 index 00000000..ae8d2dbe --- /dev/null +++ b/api/docs/tough-cookie.getcookiesoptions.md @@ -0,0 +1,147 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [GetCookiesOptions](./tough-cookie.getcookiesoptions.md) + +## GetCookiesOptions interface + +Configuration options used when calling `CookieJar.getCookies(...)`. + +**Signature:** + +```typescript +export interface GetCookiesOptions +``` + +## Properties + + + + + + + +
+ +Property + + + + +Modifiers + + + + +Type + + + + +Description + + +
+ +[allPaths?](./tough-cookie.getcookiesoptions.allpaths.md) + + + + + + + +boolean \| undefined + + + + +_(Optional)_ If `true`, do not scope cookies by path. If `false`, then RFC-compliant path scoping will be used. + + +
+ +[expire?](./tough-cookie.getcookiesoptions.expire.md) + + + + + + + +boolean \| undefined + + + + +_(Optional)_ Perform `expiry-time` checking of cookies and asynchronously remove expired cookies from the store. + + +
+ +[http?](./tough-cookie.getcookiesoptions.http.md) + + + + + + + +boolean \| undefined + + + + +_(Optional)_ Indicates if this is an HTTP or non-HTTP API. Affects HttpOnly cookies. + +Defaults to `true` if not provided. + + +
+ +[sameSiteContext?](./tough-cookie.getcookiesoptions.samesitecontext.md) + + + + + + + +'none' \| 'lax' \| 'strict' \| undefined + + + + +_(Optional)_ Set this to 'none', 'lax', or 'strict' to enforce SameSite cookies upon retrieval. + +- `'strict'` - If the request is on the same "site for cookies" (see the RFC draft for more information), pass this option to add a layer of defense against CSRF. + +- `'lax'` - If the request is from another site, but is directly because of navigation by the user, such as, `` or ``, then use `lax`. + +- `'none'` - This indicates a cross-origin request. + +- `undefined` - SameSite is not be enforced! This can be a valid use-case for when CSRF isn't in the threat model of the system being built. + +Defaults to `undefined` if not provided. + + +
+ +[sort?](./tough-cookie.getcookiesoptions.sort.md) + + + + + + + +boolean \| undefined + + + + +_(Optional)_ Flag to indicate if the returned cookies should be sorted or not. + +Defaults to `undefined` if not provided. + + +
diff --git a/api/docs/tough-cookie.getcookiesoptions.samesitecontext.md b/api/docs/tough-cookie.getcookiesoptions.samesitecontext.md new file mode 100644 index 00000000..d28ecf7c --- /dev/null +++ b/api/docs/tough-cookie.getcookiesoptions.samesitecontext.md @@ -0,0 +1,28 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [GetCookiesOptions](./tough-cookie.getcookiesoptions.md) > [sameSiteContext](./tough-cookie.getcookiesoptions.samesitecontext.md) + +## GetCookiesOptions.sameSiteContext property + +Set this to 'none', 'lax', or 'strict' to enforce SameSite cookies upon retrieval. + +- `'strict'` - If the request is on the same "site for cookies" (see the RFC draft for more information), pass this option to add a layer of defense against CSRF. + +- `'lax'` - If the request is from another site, but is directly because of navigation by the user, such as, `` or ``, then use `lax`. + +- `'none'` - This indicates a cross-origin request. + +- `undefined` - SameSite is not be enforced! This can be a valid use-case for when CSRF isn't in the threat model of the system being built. + +Defaults to `undefined` if not provided. + +**Signature:** + +```typescript +sameSiteContext?: 'none' | 'lax' | 'strict' | undefined; +``` + +## Remarks + +- It is highly recommended that you read [RFC6265bis - Section 8.8](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-02##section-8.8) which discusses security considerations and defence on SameSite cookies in depth. + diff --git a/api/docs/tough-cookie.getcookiesoptions.sort.md b/api/docs/tough-cookie.getcookiesoptions.sort.md new file mode 100644 index 00000000..a8e956e4 --- /dev/null +++ b/api/docs/tough-cookie.getcookiesoptions.sort.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [GetCookiesOptions](./tough-cookie.getcookiesoptions.md) > [sort](./tough-cookie.getcookiesoptions.sort.md) + +## GetCookiesOptions.sort property + +Flag to indicate if the returned cookies should be sorted or not. + +Defaults to `undefined` if not provided. + +**Signature:** + +```typescript +sort?: boolean | undefined; +``` diff --git a/api/docs/tough-cookie.getpublicsuffixoptions.allowspecialusedomain.md b/api/docs/tough-cookie.getpublicsuffixoptions.allowspecialusedomain.md new file mode 100644 index 00000000..4a5b25bd --- /dev/null +++ b/api/docs/tough-cookie.getpublicsuffixoptions.allowspecialusedomain.md @@ -0,0 +1,25 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [GetPublicSuffixOptions](./tough-cookie.getpublicsuffixoptions.md) > [allowSpecialUseDomain](./tough-cookie.getpublicsuffixoptions.allowspecialusedomain.md) + +## GetPublicSuffixOptions.allowSpecialUseDomain property + +If set to `true` then the following [Special Use Domains](https://www.rfc-editor.org/rfc/rfc6761.html) will be treated as if they were valid public suffixes ('local', 'example', 'invalid', 'localhost', 'test'). + +**Signature:** + +```typescript +allowSpecialUseDomain?: boolean | undefined; +``` + +## Remarks + +In testing scenarios it's common to configure the cookie store with so that `http://localhost` can be used as a domain: + +```json +{ + allowSpecialUseDomain: true, + rejectPublicSuffixes: false +} +``` + diff --git a/api/docs/tough-cookie.getpublicsuffixoptions.ignoreerror.md b/api/docs/tough-cookie.getpublicsuffixoptions.ignoreerror.md new file mode 100644 index 00000000..4d8e1a89 --- /dev/null +++ b/api/docs/tough-cookie.getpublicsuffixoptions.ignoreerror.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [GetPublicSuffixOptions](./tough-cookie.getpublicsuffixoptions.md) > [ignoreError](./tough-cookie.getpublicsuffixoptions.ignoreerror.md) + +## GetPublicSuffixOptions.ignoreError property + +If set to `true` then any errors that occur while executing [getPublicSuffix()](./tough-cookie.getpublicsuffix.md) will be silently ignored. + +**Signature:** + +```typescript +ignoreError?: boolean | undefined; +``` diff --git a/api/docs/tough-cookie.md b/api/docs/tough-cookie.md index 6668152f..b35f4dce 100644 --- a/api/docs/tough-cookie.md +++ b/api/docs/tough-cookie.md @@ -153,6 +153,17 @@ Answers "does this real domain match the domain in a cookie?". The `domain` is t Format a [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) into the [preferred Internet standard format](https://www.rfc-editor.org/rfc/rfc2616#section-3.3.1) defined in [RFC822](https://www.rfc-editor.org/rfc/rfc822#section-5) and updated in [RFC1123](https://www.rfc-editor.org/rfc/rfc1123#page-55). + + + +[fromJSON(str)](./tough-cookie.fromjson.md) + + + + +Does the reverse of [Cookie.toJSON()](./tough-cookie.cookie.tojson.md). + + @@ -164,6 +175,17 @@ Format a [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc Returns the public suffix of this hostname. The public suffix is the shortest domain name upon which a cookie can be set. + + + +[parse(str, options)](./tough-cookie.parse.md) + + + + +Parses a string into a Cookie object. + + @@ -340,24 +362,6 @@ Description -[fromJSON](./tough-cookie.fromjson.md) - - - - - - - - -[parse](./tough-cookie.parse.md) - - - - - - - - [PrefixSecurityEnum](./tough-cookie.prefixsecurityenum.md) @@ -403,6 +407,17 @@ Description +[Nullable](./tough-cookie.nullable.md) + + + + +The inverse of NonNullable. + + + + + [SerializedCookie](./tough-cookie.serializedcookie.md) diff --git a/api/docs/tough-cookie.memorycookiestore.findcookie.md b/api/docs/tough-cookie.memorycookiestore.findcookie.md index 76ceed8f..e445fcc0 100644 --- a/api/docs/tough-cookie.memorycookiestore.findcookie.md +++ b/api/docs/tough-cookie.memorycookiestore.findcookie.md @@ -37,7 +37,7 @@ domain -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> @@ -53,7 +53,7 @@ path -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> @@ -69,7 +69,7 @@ key -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> diff --git a/api/docs/tough-cookie.memorycookiestore.findcookie_1.md b/api/docs/tough-cookie.memorycookiestore.findcookie_1.md index db153e8f..754e6348 100644 --- a/api/docs/tough-cookie.memorycookiestore.findcookie_1.md +++ b/api/docs/tough-cookie.memorycookiestore.findcookie_1.md @@ -39,7 +39,7 @@ domain -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> @@ -55,7 +55,7 @@ path -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> @@ -71,7 +71,7 @@ key -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> diff --git a/api/docs/tough-cookie.nullable.md b/api/docs/tough-cookie.nullable.md new file mode 100644 index 00000000..2f48ba67 --- /dev/null +++ b/api/docs/tough-cookie.nullable.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [Nullable](./tough-cookie.nullable.md) + +## Nullable type + +The inverse of NonNullable. + +**Signature:** + +```typescript +export type Nullable = T | null | undefined; +``` diff --git a/api/docs/tough-cookie.parse.md b/api/docs/tough-cookie.parse.md new file mode 100644 index 00000000..74f816f0 --- /dev/null +++ b/api/docs/tough-cookie.parse.md @@ -0,0 +1,73 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [parse](./tough-cookie.parse.md) + +## parse() function + +Parses a string into a Cookie object. + +**Signature:** + +```typescript +export declare function parse(str: string, options?: ParseCookieOptions): Cookie | undefined; +``` + +## Parameters + + + + +
+ +Parameter + + + + +Type + + + + +Description + + +
+ +str + + + + +string + + + + +The `Set-Cookie` header or a Cookie string to parse. + + +
+ +options + + + + +[ParseCookieOptions](./tough-cookie.parsecookieoptions.md) + + + + +_(Optional)_ Configures `strict` or `loose` mode for cookie parsing + + +
+**Returns:** + +[Cookie](./tough-cookie.cookie.md) \| undefined + +## Remarks + +Note: when parsing a `Cookie` header it must be split by ';' before each Cookie string can be parsed. + diff --git a/api/docs/tough-cookie.parsedate.md b/api/docs/tough-cookie.parsedate.md index a24fb3dc..958b547c 100644 --- a/api/docs/tough-cookie.parsedate.md +++ b/api/docs/tough-cookie.parsedate.md @@ -37,7 +37,7 @@ cookieDate -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> diff --git a/api/docs/tough-cookie.prefixsecurityenum.md b/api/docs/tough-cookie.prefixsecurityenum.md new file mode 100644 index 00000000..399e9071 --- /dev/null +++ b/api/docs/tough-cookie.prefixsecurityenum.md @@ -0,0 +1,25 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [PrefixSecurityEnum](./tough-cookie.prefixsecurityenum.md) + +## PrefixSecurityEnum variable + +Cookie prefixes are a way to indicate that a given cookie was set with a set of attributes simply by inspecting the first few characters of the cookie's name. These are defined in [RFC6265bis - Section 4.1.3](https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-13#section-4.1.3). + +The following values can be used to configure how a [CookieJar](./tough-cookie.cookiejar.md) enforces attribute restrictions for Cookie prefixes: + +- `silent` - Enable cookie prefix checking but silently ignores the cookie if conditions are not met. This is the default configuration for a [CookieJar](./tough-cookie.cookiejar.md). + +- `strict` - Enables cookie prefix checking and will raise an error if conditions are not met. + +- `unsafe-disabled` - Disables cookie prefix checking. + +**Signature:** + +```typescript +PrefixSecurityEnum: Readonly<{ + SILENT: "silent"; + STRICT: "strict"; + DISABLED: "unsafe-disabled"; +}> +``` diff --git a/api/docs/tough-cookie.setcookieoptions.http.md b/api/docs/tough-cookie.setcookieoptions.http.md new file mode 100644 index 00000000..7bd236fa --- /dev/null +++ b/api/docs/tough-cookie.setcookieoptions.http.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [SetCookieOptions](./tough-cookie.setcookieoptions.md) > [http](./tough-cookie.setcookieoptions.http.md) + +## SetCookieOptions.http property + +Indicates if this is an HTTP or non-HTTP API. Affects HttpOnly cookies. + +Defaults to `true` if not provided. + +**Signature:** + +```typescript +http?: boolean | undefined; +``` diff --git a/api/docs/tough-cookie.setcookieoptions.ignoreerror.md b/api/docs/tough-cookie.setcookieoptions.ignoreerror.md new file mode 100644 index 00000000..34718231 --- /dev/null +++ b/api/docs/tough-cookie.setcookieoptions.ignoreerror.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [SetCookieOptions](./tough-cookie.setcookieoptions.md) > [ignoreError](./tough-cookie.setcookieoptions.ignoreerror.md) + +## SetCookieOptions.ignoreError property + +Silently ignore things like parse errors and invalid domains. Store errors aren't ignored by this option. + +Defaults to `false` if not provided. + +**Signature:** + +```typescript +ignoreError?: boolean | undefined; +``` diff --git a/api/docs/tough-cookie.setcookieoptions.loose.md b/api/docs/tough-cookie.setcookieoptions.loose.md new file mode 100644 index 00000000..09e13e0f --- /dev/null +++ b/api/docs/tough-cookie.setcookieoptions.loose.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [SetCookieOptions](./tough-cookie.setcookieoptions.md) > [loose](./tough-cookie.setcookieoptions.loose.md) + +## SetCookieOptions.loose property + +Controls if a cookie string should be parsed using `loose` mode or not. See [Cookie.parse()](./tough-cookie.cookie.parse.md) and [ParseCookieOptions](./tough-cookie.parsecookieoptions.md) for more details. + +Defaults to `false` if not provided. + +**Signature:** + +```typescript +loose?: boolean | undefined; +``` diff --git a/api/docs/tough-cookie.setcookieoptions.md b/api/docs/tough-cookie.setcookieoptions.md new file mode 100644 index 00000000..3622f564 --- /dev/null +++ b/api/docs/tough-cookie.setcookieoptions.md @@ -0,0 +1,151 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [SetCookieOptions](./tough-cookie.setcookieoptions.md) + +## SetCookieOptions interface + +Configuration options used when calling `CookieJar.setCookie(...)` + +**Signature:** + +```typescript +export interface SetCookieOptions +``` + +## Properties + + + + + + + +
+ +Property + + + + +Modifiers + + + + +Type + + + + +Description + + +
+ +[http?](./tough-cookie.setcookieoptions.http.md) + + + + + + + +boolean \| undefined + + + + +_(Optional)_ Indicates if this is an HTTP or non-HTTP API. Affects HttpOnly cookies. + +Defaults to `true` if not provided. + + +
+ +[ignoreError?](./tough-cookie.setcookieoptions.ignoreerror.md) + + + + + + + +boolean \| undefined + + + + +_(Optional)_ Silently ignore things like parse errors and invalid domains. Store errors aren't ignored by this option. + +Defaults to `false` if not provided. + + +
+ +[loose?](./tough-cookie.setcookieoptions.loose.md) + + + + + + + +boolean \| undefined + + + + +_(Optional)_ Controls if a cookie string should be parsed using `loose` mode or not. See [Cookie.parse()](./tough-cookie.cookie.parse.md) and [ParseCookieOptions](./tough-cookie.parsecookieoptions.md) for more details. + +Defaults to `false` if not provided. + + +
+ +[now?](./tough-cookie.setcookieoptions.now.md) + + + + + + + +Date \| undefined + + + + +_(Optional)_ Forces the cookie creation and access time of cookies to this value when stored. + +Defaults to `Date.now()` if not provided. + + +
+ +[sameSiteContext?](./tough-cookie.setcookieoptions.samesitecontext.md) + + + + + + + +'strict' \| 'lax' \| 'none' \| undefined + + + + +_(Optional)_ Set this to 'none', 'lax', or 'strict' to enforce SameSite cookies upon storage. + +- `'strict'` - If the request is on the same "site for cookies" (see the RFC draft for more information), pass this option to add a layer of defense against CSRF. + +- `'lax'` - If the request is from another site, but is directly because of navigation by the user, such as, `` or ``, then use `lax`. + +- `'none'` - This indicates a cross-origin request. + +- `undefined` - SameSite is not be enforced! This can be a valid use-case for when CSRF isn't in the threat model of the system being built. + +Defaults to `undefined` if not provided. + + +
diff --git a/api/docs/tough-cookie.setcookieoptions.now.md b/api/docs/tough-cookie.setcookieoptions.now.md new file mode 100644 index 00000000..cb453889 --- /dev/null +++ b/api/docs/tough-cookie.setcookieoptions.now.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [SetCookieOptions](./tough-cookie.setcookieoptions.md) > [now](./tough-cookie.setcookieoptions.now.md) + +## SetCookieOptions.now property + +Forces the cookie creation and access time of cookies to this value when stored. + +Defaults to `Date.now()` if not provided. + +**Signature:** + +```typescript +now?: Date | undefined; +``` diff --git a/api/docs/tough-cookie.setcookieoptions.samesitecontext.md b/api/docs/tough-cookie.setcookieoptions.samesitecontext.md new file mode 100644 index 00000000..3a882928 --- /dev/null +++ b/api/docs/tough-cookie.setcookieoptions.samesitecontext.md @@ -0,0 +1,28 @@ + + +[Home](./index.md) > [tough-cookie](./tough-cookie.md) > [SetCookieOptions](./tough-cookie.setcookieoptions.md) > [sameSiteContext](./tough-cookie.setcookieoptions.samesitecontext.md) + +## SetCookieOptions.sameSiteContext property + +Set this to 'none', 'lax', or 'strict' to enforce SameSite cookies upon storage. + +- `'strict'` - If the request is on the same "site for cookies" (see the RFC draft for more information), pass this option to add a layer of defense against CSRF. + +- `'lax'` - If the request is from another site, but is directly because of navigation by the user, such as, `` or `
`, then use `lax`. + +- `'none'` - This indicates a cross-origin request. + +- `undefined` - SameSite is not be enforced! This can be a valid use-case for when CSRF isn't in the threat model of the system being built. + +Defaults to `undefined` if not provided. + +**Signature:** + +```typescript +sameSiteContext?: 'strict' | 'lax' | 'none' | undefined; +``` + +## Remarks + +- It is highly recommended that you read [RFC6265bis - Section 8.8](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-02##section-8.8) which discusses security considerations and defence on SameSite cookies in depth. + diff --git a/api/docs/tough-cookie.store.findcookie.md b/api/docs/tough-cookie.store.findcookie.md index 0bb48099..5a8fa725 100644 --- a/api/docs/tough-cookie.store.findcookie.md +++ b/api/docs/tough-cookie.store.findcookie.md @@ -39,7 +39,7 @@ domain -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> @@ -55,7 +55,7 @@ path -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> @@ -71,7 +71,7 @@ key -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> diff --git a/api/docs/tough-cookie.store.findcookie_1.md b/api/docs/tough-cookie.store.findcookie_1.md index dcc8df9e..a4fc78c0 100644 --- a/api/docs/tough-cookie.store.findcookie_1.md +++ b/api/docs/tough-cookie.store.findcookie_1.md @@ -39,7 +39,7 @@ domain -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> @@ -55,7 +55,7 @@ path -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> @@ -71,7 +71,7 @@ key -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> diff --git a/api/docs/tough-cookie.store.findcookies.md b/api/docs/tough-cookie.store.findcookies.md index 45e3b688..85e19ed7 100644 --- a/api/docs/tough-cookie.store.findcookies.md +++ b/api/docs/tough-cookie.store.findcookies.md @@ -39,7 +39,7 @@ domain -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> @@ -55,7 +55,7 @@ path -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> diff --git a/api/docs/tough-cookie.store.findcookies_1.md b/api/docs/tough-cookie.store.findcookies_1.md index 9678f8ba..03f55489 100644 --- a/api/docs/tough-cookie.store.findcookies_1.md +++ b/api/docs/tough-cookie.store.findcookies_1.md @@ -39,7 +39,7 @@ domain -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> @@ -55,7 +55,7 @@ path -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> diff --git a/api/docs/tough-cookie.store.removecookie.md b/api/docs/tough-cookie.store.removecookie.md index ae4818f3..95b8b539 100644 --- a/api/docs/tough-cookie.store.removecookie.md +++ b/api/docs/tough-cookie.store.removecookie.md @@ -37,7 +37,7 @@ domain -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> @@ -53,7 +53,7 @@ path -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> @@ -69,7 +69,7 @@ key -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> diff --git a/api/docs/tough-cookie.store.removecookie_1.md b/api/docs/tough-cookie.store.removecookie_1.md index 810d5eb4..05907e8f 100644 --- a/api/docs/tough-cookie.store.removecookie_1.md +++ b/api/docs/tough-cookie.store.removecookie_1.md @@ -37,7 +37,7 @@ domain -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> @@ -53,7 +53,7 @@ path -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> @@ -69,7 +69,7 @@ key -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> diff --git a/api/docs/tough-cookie.store.removecookies.md b/api/docs/tough-cookie.store.removecookies.md index 7f06f901..6be4cb45 100644 --- a/api/docs/tough-cookie.store.removecookies.md +++ b/api/docs/tough-cookie.store.removecookies.md @@ -53,7 +53,7 @@ path -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> diff --git a/api/docs/tough-cookie.store.removecookies_1.md b/api/docs/tough-cookie.store.removecookies_1.md index 023dda30..ce13026a 100644 --- a/api/docs/tough-cookie.store.removecookies_1.md +++ b/api/docs/tough-cookie.store.removecookies_1.md @@ -53,7 +53,7 @@ path -Nullable<string> +[Nullable](./tough-cookie.nullable.md)<string> diff --git a/api/tough-cookie.api.md b/api/tough-cookie.api.md index b0e38a47..fccfc150 100644 --- a/api/tough-cookie.api.md +++ b/api/tough-cookie.api.md @@ -14,8 +14,6 @@ export interface Callback { (error: null, result: T): void; } -// Warning: (ae-forgotten-export) The symbol "Nullable" needs to be exported by the entry point index.d.ts -// // @public export function canonicalDomain(domainName: Nullable): string | undefined; @@ -165,8 +163,8 @@ export interface ErrorCallback { // @public export function formatDate(date: Date): string; -// @public (undocumented) -export const fromJSON: typeof Cookie.fromJSON; +// @public +export function fromJSON(str: unknown): Cookie | undefined; // @public export interface GetCookiesOptions { @@ -195,8 +193,6 @@ export class MemoryCookieStore extends Store { findCookies(domain: string, path: string, allowSpecialUseDomain?: boolean, callback?: Callback): void; getAllCookies(): Promise; getAllCookies(callback: Callback): void; - // Warning: (ae-forgotten-export) The symbol "MemoryCookieStoreIndex" needs to be exported by the entry point index.d.ts - // // @internal (undocumented) idx: MemoryCookieStoreIndex; putCookie(cookie: Cookie): Promise; @@ -212,12 +208,24 @@ export class MemoryCookieStore extends Store { updateCookie(oldCookie: Cookie, newCookie: Cookie, callback: ErrorCallback): void; } +// @internal +export type MemoryCookieStoreIndex = { + [domain: string]: { + [path: string]: { + [key: string]: Cookie; + }; + }; +}; + +// @public +export type Nullable = T | null | undefined; + // @public export class ParameterError extends Error { } -// @public (undocumented) -export const parse: typeof Cookie.parse; +// @public +export function parse(str: string, options?: ParseCookieOptions): Cookie | undefined; // @public export interface ParseCookieOptions { diff --git a/lib/cookie/cookieCompare.ts b/lib/cookie/cookieCompare.ts index 0714dfd0..cc0daaf6 100644 --- a/lib/cookie/cookieCompare.ts +++ b/lib/cookie/cookieCompare.ts @@ -39,7 +39,7 @@ const MAX_TIME = 2147483647000 * ### Custom Store Implementors * * 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 {@link Cookie.setCookie()}. The {@link Cookie.creationIndex} + * This is especially true when using the `now` option to `CookieJar.setCookie(...)`. The {@link Cookie.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 {@link MemoryCookieStore} since `Set-Cookie` headers * are parsed in order, but is not so great for distributed systems. diff --git a/lib/cookie/cookieJar.ts b/lib/cookie/cookieJar.ts index e87b111e..d34008af 100644 --- a/lib/cookie/cookieJar.ts +++ b/lib/cookie/cookieJar.ts @@ -38,6 +38,7 @@ const defaultSetCookieOptions: SetCookieOptions = { /** * Configuration options used when calling `CookieJar.setCookie(...)` + * @public */ export interface SetCookieOptions { /** @@ -98,6 +99,7 @@ const defaultGetCookieOptions: GetCookiesOptions = { /** * Configuration options used when calling `CookieJar.getCookies(...)`. + * @public */ export interface GetCookiesOptions { /** diff --git a/lib/cookie/index.ts b/lib/cookie/index.ts index 6e90808b..d6245054 100644 --- a/lib/cookie/index.ts +++ b/lib/cookie/index.ts @@ -1,11 +1,11 @@ -export { MemoryCookieStore } from '../memstore' +export { MemoryCookieStore, MemoryCookieStoreIndex } from '../memstore' export { pathMatch } from '../pathMatch' export { permuteDomain } from '../permuteDomain' export { getPublicSuffix, GetPublicSuffixOptions } from '../getPublicSuffix' export { Store } from '../store' export { ParameterError } from '../validators' export { version } from '../version' -export { Callback, ErrorCallback } from '../utils' +export { Callback, ErrorCallback, Nullable } from '../utils' export { canonicalDomain } from './canonicalDomain' export { PrefixSecurityEnum, @@ -26,7 +26,23 @@ export { formatDate } from './formatDate' export { parseDate } from './parseDate' export { permutePath } from './permutePath' -import { Cookie } from './cookie' +import { Cookie, ParseCookieOptions } from './cookie' -export const parse = Cookie.parse -export const fromJSON = Cookie.fromJSON +/** + * {@inheritDoc Cookie.parse} + * @public + */ +export function parse( + str: string, + options?: ParseCookieOptions, +): Cookie | undefined { + return Cookie.parse(str, options) +} + +/** + * {@inheritDoc Cookie.fromJSON} + * @public + */ +export function fromJSON(str: unknown): Cookie | undefined { + return Cookie.fromJSON(str) +} diff --git a/lib/memstore.ts b/lib/memstore.ts index 329f0757..40b95f49 100644 --- a/lib/memstore.ts +++ b/lib/memstore.ts @@ -9,6 +9,10 @@ import { Nullable, } from './utils' +/** + * The internal structure used in {@link MemoryCookieStore}. + * @internal + */ export type MemoryCookieStoreIndex = { [domain: string]: { [path: string]: { diff --git a/lib/store.ts b/lib/store.ts index d78d270a..b1c0c830 100644 --- a/lib/store.ts +++ b/lib/store.ts @@ -16,6 +16,8 @@ import type { Callback, ErrorCallback, Nullable } from './utils' * * - Stores are asynchronous by default, but if {@link Store.synchronous} is set to true, then the `*Sync` methods * of the containing {@link CookieJar} can be used. + * + * @public */ export class Store { /** diff --git a/lib/utils.ts b/lib/utils.ts index 88a0c9e8..8b330198 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -15,7 +15,10 @@ export interface ErrorCallback { (error: Error | null): void } -/** The inverse of NonNullable. */ +/** + * The inverse of NonNullable. + * @public + */ export type Nullable = T | null | undefined /** Wrapped `Object.prototype.toString`, so that you don't need to remember to use `.call()`. */