37 lines
2.4 KiB
JavaScript
37 lines
2.4 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.IP_V6_REGEX_OBJECT = exports.PrefixSecurityEnum = void 0;
|
|
/**
|
|
* 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 {@link https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-13#section-4.1.3 | RFC6265bis - Section 4.1.3}.
|
|
*
|
|
* The following values can be used to configure how a {@link CookieJar} 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 {@link CookieJar}.
|
|
*
|
|
* - `strict` - Enables cookie prefix checking and will raise an error if conditions are not met.
|
|
*
|
|
* - `unsafe-disabled` - Disables cookie prefix checking.
|
|
* @public
|
|
*/
|
|
exports.PrefixSecurityEnum = Object.freeze({
|
|
SILENT: 'silent',
|
|
STRICT: 'strict',
|
|
DISABLED: 'unsafe-disabled',
|
|
});
|
|
const IP_V6_REGEX = `
|
|
\\[?(?:
|
|
(?:[a-fA-F\\d]{1,4}:){7}(?:[a-fA-F\\d]{1,4}|:)|
|
|
(?:[a-fA-F\\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|:[a-fA-F\\d]{1,4}|:)|
|
|
(?:[a-fA-F\\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,2}|:)|
|
|
(?:[a-fA-F\\d]{1,4}:){4}(?:(?::[a-fA-F\\d]{1,4}){0,1}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d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