tough-cookie 6.0.1 → 6.1.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/dist/index.d.cts CHANGED
@@ -16,6 +16,16 @@ declare const PrefixSecurityEnum: {
16
16
  readonly STRICT: "strict";
17
17
  readonly DISABLED: "unsafe-disabled";
18
18
  };
19
+ /**
20
+ * Prefix security enforcement mode for a CookieJar per RFC 6265bis.
21
+ *
22
+ * - `'silent'` - Enable cookie prefix checking but silently ignores the cookie if conditions are not met. Default.
23
+ * - `'strict'` - Enables cookie prefix checking and will raise an error if conditions are not met.
24
+ * - `'unsafe-disabled'` - Disables cookie prefix checking.
25
+ *
26
+ * @public
27
+ */
28
+ type PrefixSecurityMode = (typeof PrefixSecurityEnum)[keyof typeof PrefixSecurityEnum];
19
29
  /**
20
30
  * A JSON representation of a {@link CookieJar}.
21
31
  * @public
@@ -212,6 +222,10 @@ declare class Cookie {
212
222
  *
213
223
  * @remarks
214
224
  * Works for a few things, but is by no means comprehensive.
225
+ * Checks that the cookie name is a non-empty token as defined in RFC 6265 Section 4.1.1.
226
+ * Nameless cookies (including those parsed in loose mode or created with `new Cookie({ value })`)
227
+ * and names containing characters outside the token grammar (such as `a b`) return `false`.
228
+ * Parsing and storage remain permissive; this check only applies to explicit validation.
215
229
  *
216
230
  * @beta
217
231
  */
@@ -370,6 +384,7 @@ declare class Cookie {
370
384
  static sameSiteCanonical: {
371
385
  readonly strict: "Strict";
372
386
  readonly lax: "Lax";
387
+ readonly none: "None";
373
388
  };
374
389
  /**
375
390
  * Cookie properties that will be serialized when using {@link Cookie.fromJSON} and {@link Cookie.toJSON}.
@@ -928,7 +943,7 @@ declare class ParameterError extends Error {
928
943
  * The version of `tough-cookie`
929
944
  * @public
930
945
  */
931
- declare const version = "6.0.1";
946
+ declare const version = "6.1.0";
932
947
 
933
948
  /**
934
949
  * Transforms a domain name into a canonical domain name. The canonical domain name is a domain name
@@ -1150,11 +1165,11 @@ interface CreateCookieJarOptions {
1150
1165
  */
1151
1166
  looseMode?: boolean | undefined;
1152
1167
  /**
1153
- * Controls how cookie prefixes are handled. See {@link PrefixSecurityEnum}.
1168
+ * Controls how cookie prefixes are handled. See {@link PrefixSecurityMode}.
1154
1169
  *
1155
1170
  * Defaults to `silent` if not specified.
1156
1171
  */
1157
- prefixSecurity?: 'strict' | 'silent' | 'unsafe-disabled' | undefined;
1172
+ prefixSecurity?: PrefixSecurityMode | undefined;
1158
1173
  /**
1159
1174
  * Accepts {@link https://datatracker.ietf.org/doc/html/rfc6761 | special-use domains } such as `local`.
1160
1175
  * This is not in the standard, but is used sometimes on the web and is accepted by most browsers. It is
@@ -1164,10 +1179,10 @@ interface CreateCookieJarOptions {
1164
1179
  */
1165
1180
  allowSpecialUseDomain?: boolean | undefined;
1166
1181
  /**
1167
- * Flag to indicate if localhost and loopback addresses with an unsecure scheme should store and retrieve `Secure` cookies.
1182
+ * Flag to indicate if localhost and loopback addresses with an insecure scheme should store and retrieve `Secure` cookies.
1168
1183
  *
1169
1184
  * If `true`, localhost, loopback addresses or similarly local addresses are treated as secure contexts
1170
- * and thus will store and retrieve `Secure` cookies even with an unsecure scheme.
1185
+ * and thus will store and retrieve `Secure` cookies even with an insecure scheme.
1171
1186
  *
1172
1187
  * If `false`, only secure schemes (`https` and `wss`) will store and retrieve `Secure` cookies.
1173
1188
  *
@@ -1176,6 +1191,24 @@ interface CreateCookieJarOptions {
1176
1191
  * algorithm is followed to determine if a URL is considered a secure context.
1177
1192
  */
1178
1193
  allowSecureOnLocal?: boolean | undefined;
1194
+ /**
1195
+ * Flag to indicate if `Secure` cookies set from an unsecure origin should be rejected.
1196
+ *
1197
+ * If `true`, a cookie with the `Secure` attribute is only stored when it is set from a secure context
1198
+ * (see {@link CreateCookieJarOptions.allowSecureOnLocal}). This applies to all `Secure` cookies, not just
1199
+ * those with a `__Secure-` or `__Host-` prefix, and is independent of {@link CreateCookieJarOptions.prefixSecurity}.
1200
+ *
1201
+ * If `false`, `Secure` cookies are stored regardless of the origin they were set from.
1202
+ *
1203
+ * This only affects storage. On retrieval, `Secure` cookies are only returned for secure contexts
1204
+ * regardless of this setting.
1205
+ *
1206
+ * Defaults to `true` if not specified.
1207
+ *
1208
+ * @remarks
1209
+ * See {@link https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-22#section-5.7-3.13.1 | RFC6265bis draft -22, Section 5.7 step 13}.
1210
+ */
1211
+ enforceSecureOriginOnStorage?: boolean | undefined;
1179
1212
  }
1180
1213
  /**
1181
1214
  * A CookieJar is for storage and retrieval of {@link Cookie} objects as defined in
@@ -1189,12 +1222,13 @@ declare class CookieJar {
1189
1222
  private readonly enableLooseMode;
1190
1223
  private readonly allowSpecialUseDomain;
1191
1224
  private readonly allowSecureOnLocal;
1225
+ private readonly enforceSecureOriginOnStorage;
1192
1226
  /**
1193
1227
  * The configured {@link Store} for the {@link CookieJar}.
1194
1228
  */
1195
1229
  readonly store: Store;
1196
1230
  /**
1197
- * The configured {@link PrefixSecurityEnum} value for the {@link CookieJar}.
1231
+ * The configured {@link PrefixSecurityMode} value for the {@link CookieJar}.
1198
1232
  */
1199
1233
  readonly prefixSecurity: string;
1200
1234
  /**
@@ -1291,19 +1325,7 @@ declare class CookieJar {
1291
1325
  * @param options - Configuration settings to use when storing the cookie.
1292
1326
  * @public
1293
1327
  */
1294
- setCookieSync(cookie: string | Cookie, url: string, options?: SetCookieOptions): Cookie | undefined;
1295
- /**
1296
- * Retrieve the list of cookies that can be sent in a Cookie header for the
1297
- * current URL.
1298
- *
1299
- * @remarks
1300
- * - The array of cookies returned will be sorted according to {@link cookieCompare}.
1301
- *
1302
- * - The {@link Cookie.lastAccessed} property will be updated on all returned cookies.
1303
- *
1304
- * @param url - The domain to store the cookie with.
1305
- */
1306
- getCookies(url: string): Promise<Cookie[]>;
1328
+ setCookieSync(cookie: string | Cookie, url: string | URL, options?: SetCookieOptions): Cookie | undefined;
1307
1329
  /**
1308
1330
  * Retrieve the list of cookies that can be sent in a Cookie header for the
1309
1331
  * current URL.
@@ -1316,7 +1338,7 @@ declare class CookieJar {
1316
1338
  * @param url - The domain to store the cookie with.
1317
1339
  * @param callback - A function to call after a cookie has been successfully retrieved.
1318
1340
  */
1319
- getCookies(url: string, callback: Callback<Cookie[]>): void;
1341
+ getCookies(url: string | URL, callback: Callback<Cookie[]>): void;
1320
1342
  /**
1321
1343
  * Retrieve the list of cookies that can be sent in a Cookie header for the
1322
1344
  * current URL.
@@ -1362,7 +1384,7 @@ declare class CookieJar {
1362
1384
  * @param url - The domain to store the cookie with.
1363
1385
  * @param options - Configuration settings to use when retrieving the cookies.
1364
1386
  */
1365
- getCookiesSync(url: string, options?: GetCookiesOptions): Cookie[];
1387
+ getCookiesSync(url: string | URL, options?: GetCookiesOptions): Cookie[];
1366
1388
  /**
1367
1389
  * Accepts the same options as `.getCookies()` but returns a string suitable for a
1368
1390
  * `Cookie` header rather than an Array.
@@ -1371,7 +1393,7 @@ declare class CookieJar {
1371
1393
  * @param options - Configuration settings to use when retrieving the cookies.
1372
1394
  * @param callback - A function to call after the `Cookie` header string has been created.
1373
1395
  */
1374
- getCookieString(url: string, options: GetCookiesOptions, callback: Callback<string | undefined>): void;
1396
+ getCookieString(url: string | URL, options: GetCookiesOptions, callback: Callback<string | undefined>): void;
1375
1397
  /**
1376
1398
  * Accepts the same options as `.getCookies()` but returns a string suitable for a
1377
1399
  * `Cookie` header rather than an Array.
@@ -1379,7 +1401,7 @@ declare class CookieJar {
1379
1401
  * @param url - The domain to store the cookie with.
1380
1402
  * @param callback - A function to call after the `Cookie` header string has been created.
1381
1403
  */
1382
- getCookieString(url: string, callback: Callback<string | undefined>): void;
1404
+ getCookieString(url: string | URL, callback: Callback<string | undefined>): void;
1383
1405
  /**
1384
1406
  * Accepts the same options as `.getCookies()` but returns a string suitable for a
1385
1407
  * `Cookie` header rather than an Array.
@@ -1387,11 +1409,11 @@ declare class CookieJar {
1387
1409
  * @param url - The domain to store the cookie with.
1388
1410
  * @param options - Configuration settings to use when retrieving the cookies.
1389
1411
  */
1390
- getCookieString(url: string, options?: GetCookiesOptions): Promise<string>;
1412
+ getCookieString(url: string | URL, options?: GetCookiesOptions): Promise<string>;
1391
1413
  /**
1392
1414
  * @internal No doc because this is an overload that supports the implementation
1393
1415
  */
1394
- getCookieString(url: string, options: GetCookiesOptions | Callback<string | undefined>, callback?: Callback<string | undefined>): unknown;
1416
+ getCookieString(url: string | URL, options: GetCookiesOptions | Callback<string | undefined>, callback?: Callback<string | undefined>): unknown;
1395
1417
  /**
1396
1418
  * Synchronous version of `.getCookieString()`. Accepts the same options as `.getCookies()` but returns a string suitable for a
1397
1419
  * `Cookie` header rather than an Array.
@@ -1401,7 +1423,7 @@ declare class CookieJar {
1401
1423
  * @param url - The domain to store the cookie with.
1402
1424
  * @param options - Configuration settings to use when retrieving the cookies.
1403
1425
  */
1404
- getCookieStringSync(url: string, options?: GetCookiesOptions): string;
1426
+ getCookieStringSync(url: string | URL, options?: GetCookiesOptions): string;
1405
1427
  /**
1406
1428
  * Returns an array of strings suitable for `Set-Cookie` headers. Accepts the same options
1407
1429
  * as `.getCookies()`.
@@ -1409,7 +1431,7 @@ declare class CookieJar {
1409
1431
  * @param url - The domain to store the cookie with.
1410
1432
  * @param callback - A function to call after the `Set-Cookie` header strings have been created.
1411
1433
  */
1412
- getSetCookieStrings(url: string, callback: Callback<string[] | undefined>): void;
1434
+ getSetCookieStrings(url: string | URL, callback: Callback<string[] | undefined>): void;
1413
1435
  /**
1414
1436
  * Returns an array of strings suitable for `Set-Cookie` headers. Accepts the same options
1415
1437
  * as `.getCookies()`.
@@ -1418,7 +1440,7 @@ declare class CookieJar {
1418
1440
  * @param options - Configuration settings to use when retrieving the cookies.
1419
1441
  * @param callback - A function to call after the `Set-Cookie` header strings have been created.
1420
1442
  */
1421
- getSetCookieStrings(url: string, options: GetCookiesOptions, callback: Callback<string[] | undefined>): void;
1443
+ getSetCookieStrings(url: string | URL, options: GetCookiesOptions, callback: Callback<string[] | undefined>): void;
1422
1444
  /**
1423
1445
  * Returns an array of strings suitable for `Set-Cookie` headers. Accepts the same options
1424
1446
  * as `.getCookies()`.
@@ -1426,11 +1448,11 @@ declare class CookieJar {
1426
1448
  * @param url - The domain to store the cookie with.
1427
1449
  * @param options - Configuration settings to use when retrieving the cookies.
1428
1450
  */
1429
- getSetCookieStrings(url: string, options?: GetCookiesOptions): Promise<string[] | undefined>;
1451
+ getSetCookieStrings(url: string | URL, options?: GetCookiesOptions): Promise<string[] | undefined>;
1430
1452
  /**
1431
1453
  * @internal No doc because this is an overload that supports the implementation
1432
1454
  */
1433
- getSetCookieStrings(url: string, options: GetCookiesOptions, callback?: Callback<string[] | undefined>): unknown;
1455
+ getSetCookieStrings(url: string | URL, options: GetCookiesOptions, callback?: Callback<string[] | undefined>): unknown;
1434
1456
  /**
1435
1457
  * Synchronous version of `.getSetCookieStrings()`. Returns an array of strings suitable for `Set-Cookie` headers.
1436
1458
  * Accepts the same options as `.getCookies()`.
@@ -1440,7 +1462,7 @@ declare class CookieJar {
1440
1462
  * @param url - The domain to store the cookie with.
1441
1463
  * @param options - Configuration settings to use when retrieving the cookies.
1442
1464
  */
1443
- getSetCookieStringsSync(url: string, options?: GetCookiesOptions): string[];
1465
+ getSetCookieStringsSync(url: string | URL, options?: GetCookiesOptions): string[];
1444
1466
  /**
1445
1467
  * Serialize the CookieJar if the underlying store supports `.getAllCookies`.
1446
1468
  * @param callback - A function to call after the CookieJar has been serialized
@@ -1699,6 +1721,10 @@ declare function defaultPath(path?: Nullable<string>): string;
1699
1721
  * but it helps to think of it as a "suffix match".
1700
1722
  *
1701
1723
  * @remarks
1724
+ * This implementation is compliant with RFC6265 Section 5.1.3 and compatible with
1725
+ * {@link https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-22#section-5.1.3 | draft-ietf-httpbis-rfc6265bis-22}
1726
+ * which adds a clarifying note that both inputs must be canonicalized but is otherwise identical.
1727
+ *
1702
1728
  * ### 5.1.3. Domain Matching
1703
1729
  *
1704
1730
  * A string domain-matches a given domain string if at least one of the
@@ -1799,4 +1825,5 @@ declare function parse(str: string, options?: ParseCookieOptions): Cookie | unde
1799
1825
  */
1800
1826
  declare function fromJSON(str: unknown): Cookie | undefined;
1801
1827
 
1802
- export { type Callback, Cookie, CookieJar, type CreateCookieJarOptions, type CreateCookieOptions, type ErrorCallback, type GetCookiesOptions, type GetPublicSuffixOptions, MemoryCookieStore, type MemoryCookieStoreIndex, type Nullable, ParameterError, type ParseCookieOptions, PrefixSecurityEnum, type SerializedCookie, type SerializedCookieJar, type SetCookieOptions, Store, canonicalDomain, cookieCompare, defaultPath, domainMatch, formatDate, fromJSON, getPublicSuffix, parse, parseDate, pathMatch, permuteDomain, permutePath, version };
1828
+ export { Cookie, CookieJar, MemoryCookieStore, ParameterError, PrefixSecurityEnum, Store, canonicalDomain, cookieCompare, defaultPath, domainMatch, formatDate, fromJSON, getPublicSuffix, parse, parseDate, pathMatch, permuteDomain, permutePath, version };
1829
+ export type { Callback, CreateCookieJarOptions, CreateCookieOptions, ErrorCallback, GetCookiesOptions, GetPublicSuffixOptions, MemoryCookieStoreIndex, Nullable, ParseCookieOptions, PrefixSecurityMode, SerializedCookie, SerializedCookieJar, SetCookieOptions };
package/dist/index.d.ts CHANGED
@@ -16,6 +16,16 @@ declare const PrefixSecurityEnum: {
16
16
  readonly STRICT: "strict";
17
17
  readonly DISABLED: "unsafe-disabled";
18
18
  };
19
+ /**
20
+ * Prefix security enforcement mode for a CookieJar per RFC 6265bis.
21
+ *
22
+ * - `'silent'` - Enable cookie prefix checking but silently ignores the cookie if conditions are not met. Default.
23
+ * - `'strict'` - Enables cookie prefix checking and will raise an error if conditions are not met.
24
+ * - `'unsafe-disabled'` - Disables cookie prefix checking.
25
+ *
26
+ * @public
27
+ */
28
+ type PrefixSecurityMode = (typeof PrefixSecurityEnum)[keyof typeof PrefixSecurityEnum];
19
29
  /**
20
30
  * A JSON representation of a {@link CookieJar}.
21
31
  * @public
@@ -212,6 +222,10 @@ declare class Cookie {
212
222
  *
213
223
  * @remarks
214
224
  * Works for a few things, but is by no means comprehensive.
225
+ * Checks that the cookie name is a non-empty token as defined in RFC 6265 Section 4.1.1.
226
+ * Nameless cookies (including those parsed in loose mode or created with `new Cookie({ value })`)
227
+ * and names containing characters outside the token grammar (such as `a b`) return `false`.
228
+ * Parsing and storage remain permissive; this check only applies to explicit validation.
215
229
  *
216
230
  * @beta
217
231
  */
@@ -370,6 +384,7 @@ declare class Cookie {
370
384
  static sameSiteCanonical: {
371
385
  readonly strict: "Strict";
372
386
  readonly lax: "Lax";
387
+ readonly none: "None";
373
388
  };
374
389
  /**
375
390
  * Cookie properties that will be serialized when using {@link Cookie.fromJSON} and {@link Cookie.toJSON}.
@@ -928,7 +943,7 @@ declare class ParameterError extends Error {
928
943
  * The version of `tough-cookie`
929
944
  * @public
930
945
  */
931
- declare const version = "6.0.1";
946
+ declare const version = "6.1.0";
932
947
 
933
948
  /**
934
949
  * Transforms a domain name into a canonical domain name. The canonical domain name is a domain name
@@ -1150,11 +1165,11 @@ interface CreateCookieJarOptions {
1150
1165
  */
1151
1166
  looseMode?: boolean | undefined;
1152
1167
  /**
1153
- * Controls how cookie prefixes are handled. See {@link PrefixSecurityEnum}.
1168
+ * Controls how cookie prefixes are handled. See {@link PrefixSecurityMode}.
1154
1169
  *
1155
1170
  * Defaults to `silent` if not specified.
1156
1171
  */
1157
- prefixSecurity?: 'strict' | 'silent' | 'unsafe-disabled' | undefined;
1172
+ prefixSecurity?: PrefixSecurityMode | undefined;
1158
1173
  /**
1159
1174
  * Accepts {@link https://datatracker.ietf.org/doc/html/rfc6761 | special-use domains } such as `local`.
1160
1175
  * This is not in the standard, but is used sometimes on the web and is accepted by most browsers. It is
@@ -1164,10 +1179,10 @@ interface CreateCookieJarOptions {
1164
1179
  */
1165
1180
  allowSpecialUseDomain?: boolean | undefined;
1166
1181
  /**
1167
- * Flag to indicate if localhost and loopback addresses with an unsecure scheme should store and retrieve `Secure` cookies.
1182
+ * Flag to indicate if localhost and loopback addresses with an insecure scheme should store and retrieve `Secure` cookies.
1168
1183
  *
1169
1184
  * If `true`, localhost, loopback addresses or similarly local addresses are treated as secure contexts
1170
- * and thus will store and retrieve `Secure` cookies even with an unsecure scheme.
1185
+ * and thus will store and retrieve `Secure` cookies even with an insecure scheme.
1171
1186
  *
1172
1187
  * If `false`, only secure schemes (`https` and `wss`) will store and retrieve `Secure` cookies.
1173
1188
  *
@@ -1176,6 +1191,24 @@ interface CreateCookieJarOptions {
1176
1191
  * algorithm is followed to determine if a URL is considered a secure context.
1177
1192
  */
1178
1193
  allowSecureOnLocal?: boolean | undefined;
1194
+ /**
1195
+ * Flag to indicate if `Secure` cookies set from an unsecure origin should be rejected.
1196
+ *
1197
+ * If `true`, a cookie with the `Secure` attribute is only stored when it is set from a secure context
1198
+ * (see {@link CreateCookieJarOptions.allowSecureOnLocal}). This applies to all `Secure` cookies, not just
1199
+ * those with a `__Secure-` or `__Host-` prefix, and is independent of {@link CreateCookieJarOptions.prefixSecurity}.
1200
+ *
1201
+ * If `false`, `Secure` cookies are stored regardless of the origin they were set from.
1202
+ *
1203
+ * This only affects storage. On retrieval, `Secure` cookies are only returned for secure contexts
1204
+ * regardless of this setting.
1205
+ *
1206
+ * Defaults to `true` if not specified.
1207
+ *
1208
+ * @remarks
1209
+ * See {@link https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-22#section-5.7-3.13.1 | RFC6265bis draft -22, Section 5.7 step 13}.
1210
+ */
1211
+ enforceSecureOriginOnStorage?: boolean | undefined;
1179
1212
  }
1180
1213
  /**
1181
1214
  * A CookieJar is for storage and retrieval of {@link Cookie} objects as defined in
@@ -1189,12 +1222,13 @@ declare class CookieJar {
1189
1222
  private readonly enableLooseMode;
1190
1223
  private readonly allowSpecialUseDomain;
1191
1224
  private readonly allowSecureOnLocal;
1225
+ private readonly enforceSecureOriginOnStorage;
1192
1226
  /**
1193
1227
  * The configured {@link Store} for the {@link CookieJar}.
1194
1228
  */
1195
1229
  readonly store: Store;
1196
1230
  /**
1197
- * The configured {@link PrefixSecurityEnum} value for the {@link CookieJar}.
1231
+ * The configured {@link PrefixSecurityMode} value for the {@link CookieJar}.
1198
1232
  */
1199
1233
  readonly prefixSecurity: string;
1200
1234
  /**
@@ -1291,19 +1325,7 @@ declare class CookieJar {
1291
1325
  * @param options - Configuration settings to use when storing the cookie.
1292
1326
  * @public
1293
1327
  */
1294
- setCookieSync(cookie: string | Cookie, url: string, options?: SetCookieOptions): Cookie | undefined;
1295
- /**
1296
- * Retrieve the list of cookies that can be sent in a Cookie header for the
1297
- * current URL.
1298
- *
1299
- * @remarks
1300
- * - The array of cookies returned will be sorted according to {@link cookieCompare}.
1301
- *
1302
- * - The {@link Cookie.lastAccessed} property will be updated on all returned cookies.
1303
- *
1304
- * @param url - The domain to store the cookie with.
1305
- */
1306
- getCookies(url: string): Promise<Cookie[]>;
1328
+ setCookieSync(cookie: string | Cookie, url: string | URL, options?: SetCookieOptions): Cookie | undefined;
1307
1329
  /**
1308
1330
  * Retrieve the list of cookies that can be sent in a Cookie header for the
1309
1331
  * current URL.
@@ -1316,7 +1338,7 @@ declare class CookieJar {
1316
1338
  * @param url - The domain to store the cookie with.
1317
1339
  * @param callback - A function to call after a cookie has been successfully retrieved.
1318
1340
  */
1319
- getCookies(url: string, callback: Callback<Cookie[]>): void;
1341
+ getCookies(url: string | URL, callback: Callback<Cookie[]>): void;
1320
1342
  /**
1321
1343
  * Retrieve the list of cookies that can be sent in a Cookie header for the
1322
1344
  * current URL.
@@ -1362,7 +1384,7 @@ declare class CookieJar {
1362
1384
  * @param url - The domain to store the cookie with.
1363
1385
  * @param options - Configuration settings to use when retrieving the cookies.
1364
1386
  */
1365
- getCookiesSync(url: string, options?: GetCookiesOptions): Cookie[];
1387
+ getCookiesSync(url: string | URL, options?: GetCookiesOptions): Cookie[];
1366
1388
  /**
1367
1389
  * Accepts the same options as `.getCookies()` but returns a string suitable for a
1368
1390
  * `Cookie` header rather than an Array.
@@ -1371,7 +1393,7 @@ declare class CookieJar {
1371
1393
  * @param options - Configuration settings to use when retrieving the cookies.
1372
1394
  * @param callback - A function to call after the `Cookie` header string has been created.
1373
1395
  */
1374
- getCookieString(url: string, options: GetCookiesOptions, callback: Callback<string | undefined>): void;
1396
+ getCookieString(url: string | URL, options: GetCookiesOptions, callback: Callback<string | undefined>): void;
1375
1397
  /**
1376
1398
  * Accepts the same options as `.getCookies()` but returns a string suitable for a
1377
1399
  * `Cookie` header rather than an Array.
@@ -1379,7 +1401,7 @@ declare class CookieJar {
1379
1401
  * @param url - The domain to store the cookie with.
1380
1402
  * @param callback - A function to call after the `Cookie` header string has been created.
1381
1403
  */
1382
- getCookieString(url: string, callback: Callback<string | undefined>): void;
1404
+ getCookieString(url: string | URL, callback: Callback<string | undefined>): void;
1383
1405
  /**
1384
1406
  * Accepts the same options as `.getCookies()` but returns a string suitable for a
1385
1407
  * `Cookie` header rather than an Array.
@@ -1387,11 +1409,11 @@ declare class CookieJar {
1387
1409
  * @param url - The domain to store the cookie with.
1388
1410
  * @param options - Configuration settings to use when retrieving the cookies.
1389
1411
  */
1390
- getCookieString(url: string, options?: GetCookiesOptions): Promise<string>;
1412
+ getCookieString(url: string | URL, options?: GetCookiesOptions): Promise<string>;
1391
1413
  /**
1392
1414
  * @internal No doc because this is an overload that supports the implementation
1393
1415
  */
1394
- getCookieString(url: string, options: GetCookiesOptions | Callback<string | undefined>, callback?: Callback<string | undefined>): unknown;
1416
+ getCookieString(url: string | URL, options: GetCookiesOptions | Callback<string | undefined>, callback?: Callback<string | undefined>): unknown;
1395
1417
  /**
1396
1418
  * Synchronous version of `.getCookieString()`. Accepts the same options as `.getCookies()` but returns a string suitable for a
1397
1419
  * `Cookie` header rather than an Array.
@@ -1401,7 +1423,7 @@ declare class CookieJar {
1401
1423
  * @param url - The domain to store the cookie with.
1402
1424
  * @param options - Configuration settings to use when retrieving the cookies.
1403
1425
  */
1404
- getCookieStringSync(url: string, options?: GetCookiesOptions): string;
1426
+ getCookieStringSync(url: string | URL, options?: GetCookiesOptions): string;
1405
1427
  /**
1406
1428
  * Returns an array of strings suitable for `Set-Cookie` headers. Accepts the same options
1407
1429
  * as `.getCookies()`.
@@ -1409,7 +1431,7 @@ declare class CookieJar {
1409
1431
  * @param url - The domain to store the cookie with.
1410
1432
  * @param callback - A function to call after the `Set-Cookie` header strings have been created.
1411
1433
  */
1412
- getSetCookieStrings(url: string, callback: Callback<string[] | undefined>): void;
1434
+ getSetCookieStrings(url: string | URL, callback: Callback<string[] | undefined>): void;
1413
1435
  /**
1414
1436
  * Returns an array of strings suitable for `Set-Cookie` headers. Accepts the same options
1415
1437
  * as `.getCookies()`.
@@ -1418,7 +1440,7 @@ declare class CookieJar {
1418
1440
  * @param options - Configuration settings to use when retrieving the cookies.
1419
1441
  * @param callback - A function to call after the `Set-Cookie` header strings have been created.
1420
1442
  */
1421
- getSetCookieStrings(url: string, options: GetCookiesOptions, callback: Callback<string[] | undefined>): void;
1443
+ getSetCookieStrings(url: string | URL, options: GetCookiesOptions, callback: Callback<string[] | undefined>): void;
1422
1444
  /**
1423
1445
  * Returns an array of strings suitable for `Set-Cookie` headers. Accepts the same options
1424
1446
  * as `.getCookies()`.
@@ -1426,11 +1448,11 @@ declare class CookieJar {
1426
1448
  * @param url - The domain to store the cookie with.
1427
1449
  * @param options - Configuration settings to use when retrieving the cookies.
1428
1450
  */
1429
- getSetCookieStrings(url: string, options?: GetCookiesOptions): Promise<string[] | undefined>;
1451
+ getSetCookieStrings(url: string | URL, options?: GetCookiesOptions): Promise<string[] | undefined>;
1430
1452
  /**
1431
1453
  * @internal No doc because this is an overload that supports the implementation
1432
1454
  */
1433
- getSetCookieStrings(url: string, options: GetCookiesOptions, callback?: Callback<string[] | undefined>): unknown;
1455
+ getSetCookieStrings(url: string | URL, options: GetCookiesOptions, callback?: Callback<string[] | undefined>): unknown;
1434
1456
  /**
1435
1457
  * Synchronous version of `.getSetCookieStrings()`. Returns an array of strings suitable for `Set-Cookie` headers.
1436
1458
  * Accepts the same options as `.getCookies()`.
@@ -1440,7 +1462,7 @@ declare class CookieJar {
1440
1462
  * @param url - The domain to store the cookie with.
1441
1463
  * @param options - Configuration settings to use when retrieving the cookies.
1442
1464
  */
1443
- getSetCookieStringsSync(url: string, options?: GetCookiesOptions): string[];
1465
+ getSetCookieStringsSync(url: string | URL, options?: GetCookiesOptions): string[];
1444
1466
  /**
1445
1467
  * Serialize the CookieJar if the underlying store supports `.getAllCookies`.
1446
1468
  * @param callback - A function to call after the CookieJar has been serialized
@@ -1699,6 +1721,10 @@ declare function defaultPath(path?: Nullable<string>): string;
1699
1721
  * but it helps to think of it as a "suffix match".
1700
1722
  *
1701
1723
  * @remarks
1724
+ * This implementation is compliant with RFC6265 Section 5.1.3 and compatible with
1725
+ * {@link https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-22#section-5.1.3 | draft-ietf-httpbis-rfc6265bis-22}
1726
+ * which adds a clarifying note that both inputs must be canonicalized but is otherwise identical.
1727
+ *
1702
1728
  * ### 5.1.3. Domain Matching
1703
1729
  *
1704
1730
  * A string domain-matches a given domain string if at least one of the
@@ -1799,4 +1825,5 @@ declare function parse(str: string, options?: ParseCookieOptions): Cookie | unde
1799
1825
  */
1800
1826
  declare function fromJSON(str: unknown): Cookie | undefined;
1801
1827
 
1802
- export { type Callback, Cookie, CookieJar, type CreateCookieJarOptions, type CreateCookieOptions, type ErrorCallback, type GetCookiesOptions, type GetPublicSuffixOptions, MemoryCookieStore, type MemoryCookieStoreIndex, type Nullable, ParameterError, type ParseCookieOptions, PrefixSecurityEnum, type SerializedCookie, type SerializedCookieJar, type SetCookieOptions, Store, canonicalDomain, cookieCompare, defaultPath, domainMatch, formatDate, fromJSON, getPublicSuffix, parse, parseDate, pathMatch, permuteDomain, permutePath, version };
1828
+ export { Cookie, CookieJar, MemoryCookieStore, ParameterError, PrefixSecurityEnum, Store, canonicalDomain, cookieCompare, defaultPath, domainMatch, formatDate, fromJSON, getPublicSuffix, parse, parseDate, pathMatch, permuteDomain, permutePath, version };
1829
+ export type { Callback, CreateCookieJarOptions, CreateCookieOptions, ErrorCallback, GetCookiesOptions, GetPublicSuffixOptions, MemoryCookieStoreIndex, Nullable, ParseCookieOptions, PrefixSecurityMode, SerializedCookie, SerializedCookieJar, SetCookieOptions };