Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

universal-cookie

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

universal-cookie - npm Package Compare versions

Comparing version 4.0.4 to 5.0.0

0

cjs/Cookies.d.ts

@@ -0,0 +0,0 @@ import { Cookie, CookieChangeListener, CookieGetOptions, CookieParseOptions, CookieSetOptions } from './types';

204

cjs/Cookies.js

@@ -7,35 +7,17 @@ "use strict";

exports["default"] = void 0;
var cookie = _interopRequireWildcard(require("cookie"));
var _utils = require("./utils");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var __assign = void 0 && (void 0).__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
var Cookies =
/** @class */
function () {
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
var Cookies = /*#__PURE__*/function () {
function Cookies(cookies, options) {
var _this = this;
_classCallCheck(this, Cookies);
this.changeListeners = [];

@@ -48,100 +30,88 @@ this.HAS_DOCUMENT_COOKIE = false;

}
Cookies.prototype._updateBrowserValues = function (parseOptions) {
if (!this.HAS_DOCUMENT_COOKIE) {
return;
_createClass(Cookies, [{
key: "_updateBrowserValues",
value: function _updateBrowserValues(parseOptions) {
if (!this.HAS_DOCUMENT_COOKIE) {
return;
}
this.cookies = cookie.parse(document.cookie, parseOptions);
}
this.cookies = cookie.parse(document.cookie, parseOptions);
};
Cookies.prototype._emitChange = function (params) {
for (var i = 0; i < this.changeListeners.length; ++i) {
this.changeListeners[i](params);
}, {
key: "_emitChange",
value: function _emitChange(params) {
for (var i = 0; i < this.changeListeners.length; ++i) {
this.changeListeners[i](params);
}
}
};
Cookies.prototype.get = function (name, options, parseOptions) {
if (options === void 0) {
options = {};
}, {
key: "get",
value: function get(name) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var parseOptions = arguments.length > 2 ? arguments[2] : undefined;
this._updateBrowserValues(parseOptions);
return (0, _utils.readCookie)(this.cookies[name], options);
}
this._updateBrowserValues(parseOptions);
return (0, _utils.readCookie)(this.cookies[name], options);
};
Cookies.prototype.getAll = function (options, parseOptions) {
if (options === void 0) {
options = {};
}, {
key: "getAll",
value: function getAll() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var parseOptions = arguments.length > 1 ? arguments[1] : undefined;
this._updateBrowserValues(parseOptions);
var result = {};
for (var name in this.cookies) {
result[name] = (0, _utils.readCookie)(this.cookies[name], options);
}
return result;
}
this._updateBrowserValues(parseOptions);
var result = {};
for (var name_1 in this.cookies) {
result[name_1] = (0, _utils.readCookie)(this.cookies[name_1], options);
}, {
key: "set",
value: function set(name, value, options) {
if (_typeof(value) === 'object') {
value = JSON.stringify(value);
}
this.cookies = Object.assign(Object.assign({}, this.cookies), _defineProperty({}, name, value));
if (this.HAS_DOCUMENT_COOKIE) {
document.cookie = cookie.serialize(name, value, options);
}
this._emitChange({
name: name,
value: value,
options: options
});
}
return result;
};
Cookies.prototype.set = function (name, value, options) {
var _a;
if (_typeof(value) === 'object') {
value = JSON.stringify(value);
}, {
key: "remove",
value: function remove(name, options) {
var finalOptions = options = Object.assign(Object.assign({}, options), {
expires: new Date(1970, 1, 1, 0, 0, 1),
maxAge: 0
});
this.cookies = Object.assign({}, this.cookies);
delete this.cookies[name];
if (this.HAS_DOCUMENT_COOKIE) {
document.cookie = cookie.serialize(name, '', finalOptions);
}
this._emitChange({
name: name,
value: undefined,
options: options
});
}
this.cookies = __assign(__assign({}, this.cookies), (_a = {}, _a[name] = value, _a));
if (this.HAS_DOCUMENT_COOKIE) {
document.cookie = cookie.serialize(name, value, options);
}, {
key: "addChangeListener",
value: function addChangeListener(callback) {
this.changeListeners.push(callback);
}
this._emitChange({
name: name,
value: value,
options: options
});
};
Cookies.prototype.remove = function (name, options) {
var finalOptions = options = __assign(__assign({}, options), {
expires: new Date(1970, 1, 1, 0, 0, 1),
maxAge: 0
});
this.cookies = __assign({}, this.cookies);
delete this.cookies[name];
if (this.HAS_DOCUMENT_COOKIE) {
document.cookie = cookie.serialize(name, '', finalOptions);
}, {
key: "removeChangeListener",
value: function removeChangeListener(callback) {
var idx = this.changeListeners.indexOf(callback);
if (idx >= 0) {
this.changeListeners.splice(idx, 1);
}
}
this._emitChange({
name: name,
value: undefined,
options: options
});
};
Cookies.prototype.addChangeListener = function (callback) {
this.changeListeners.push(callback);
};
Cookies.prototype.removeChangeListener = function (callback) {
var idx = this.changeListeners.indexOf(callback);
if (idx >= 0) {
this.changeListeners.splice(idx, 1);
}
};
}]);
return Cookies;
}();
var _default = Cookies;
exports["default"] = _default;
exports["default"] = Cookies;
module.exports = exports.default;
import Cookies from './Cookies';
export default Cookies;
export * from './types';

@@ -6,10 +6,19 @@ "use strict";

});
var _exportNames = {};
exports["default"] = void 0;
var _Cookies = _interopRequireDefault(require("./Cookies"));
var _types = require("./types");
Object.keys(_types).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _types[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _types[key];
}
});
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _default = _Cookies["default"];
exports["default"] = _default;
module.exports = exports.default;
exports["default"] = _default;

@@ -1,2 +0,2 @@

export declare type Cookie = any;
export type Cookie = any;
export interface CookieGetOptions {

@@ -23,2 +23,2 @@ doNotParse?: boolean;

}
export declare type CookieChangeListener = (options: CookieChangeOptions) => void;
export type CookieChangeListener = (options: CookieChangeOptions) => void;

@@ -1,1 +0,5 @@

"use strict";
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

@@ -0,0 +0,0 @@ import { Cookie, CookieGetOptions, CookieParseOptions } from './types';

@@ -6,16 +6,11 @@ "use strict";

});
exports.cleanCookies = cleanCookies;
exports.hasDocumentCookie = hasDocumentCookie;
exports.cleanCookies = cleanCookies;
exports.isParsingCookie = isParsingCookie;
exports.parseCookies = parseCookies;
exports.isParsingCookie = isParsingCookie;
exports.readCookie = readCookie;
var cookie = _interopRequireWildcard(require("cookie"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function hasDocumentCookie() {

@@ -25,3 +20,2 @@ // Can we get/set cookies on document.cookie?

}
function cleanCookies() {

@@ -32,3 +26,2 @@ document.cookie.split(';').forEach(function (c) {

}
function parseCookies(cookies, options) {

@@ -43,3 +36,2 @@ if (typeof cookies === 'string') {

}
function isParsingCookie(value, doNotParse) {

@@ -50,25 +42,18 @@ if (typeof doNotParse === 'undefined') {

}
return !doNotParse;
}
function readCookie(value, options) {
if (options === void 0) {
options = {};
}
function readCookie(value) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var cleanValue = cleanupCookieValue(value);
if (isParsingCookie(cleanValue, options.doNotParse)) {
try {
return JSON.parse(cleanValue);
} catch (e) {// At least we tried
} catch (e) {
// At least we tried
}
} // Ignore clean value if we failed the deserialization
}
// Ignore clean value if we failed the deserialization
// It is not relevant anymore to trim those values
return value;
}
function cleanupCookieValue(value) {

@@ -79,4 +64,3 @@ // express prepend j: before serializing a cookie

}
return value;
}

@@ -0,0 +0,0 @@ import { Cookie, CookieChangeListener, CookieGetOptions, CookieParseOptions, CookieSetOptions } from './types';

@@ -1,25 +0,13 @@

var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import * as cookie from 'cookie';
import { hasDocumentCookie, parseCookies, readCookie } from './utils';
var Cookies = /** @class */ (function () {
function Cookies(cookies, options) {
var _this = this;
export default class Cookies {
constructor(cookies, options) {
this.changeListeners = [];
this.HAS_DOCUMENT_COOKIE = false;
this.cookies = parseCookies(cookies, options);
new Promise(function () {
_this.HAS_DOCUMENT_COOKIE = hasDocumentCookie();
}).catch(function () { });
new Promise(() => {
this.HAS_DOCUMENT_COOKIE = hasDocumentCookie();
}).catch(() => { });
}
Cookies.prototype._updateBrowserValues = function (parseOptions) {
_updateBrowserValues(parseOptions) {
if (!this.HAS_DOCUMENT_COOKIE) {

@@ -29,36 +17,33 @@ return;

this.cookies = cookie.parse(document.cookie, parseOptions);
};
Cookies.prototype._emitChange = function (params) {
for (var i = 0; i < this.changeListeners.length; ++i) {
}
_emitChange(params) {
for (let i = 0; i < this.changeListeners.length; ++i) {
this.changeListeners[i](params);
}
};
Cookies.prototype.get = function (name, options, parseOptions) {
if (options === void 0) { options = {}; }
}
get(name, options = {}, parseOptions) {
this._updateBrowserValues(parseOptions);
return readCookie(this.cookies[name], options);
};
Cookies.prototype.getAll = function (options, parseOptions) {
if (options === void 0) { options = {}; }
}
getAll(options = {}, parseOptions) {
this._updateBrowserValues(parseOptions);
var result = {};
for (var name_1 in this.cookies) {
result[name_1] = readCookie(this.cookies[name_1], options);
const result = {};
for (let name in this.cookies) {
result[name] = readCookie(this.cookies[name], options);
}
return result;
};
Cookies.prototype.set = function (name, value, options) {
var _a;
}
set(name, value, options) {
if (typeof value === 'object') {
value = JSON.stringify(value);
}
this.cookies = __assign(__assign({}, this.cookies), (_a = {}, _a[name] = value, _a));
this.cookies = Object.assign(Object.assign({}, this.cookies), { [name]: value });
if (this.HAS_DOCUMENT_COOKIE) {
document.cookie = cookie.serialize(name, value, options);
}
this._emitChange({ name: name, value: value, options: options });
};
Cookies.prototype.remove = function (name, options) {
var finalOptions = (options = __assign(__assign({}, options), { expires: new Date(1970, 1, 1, 0, 0, 1), maxAge: 0 }));
this.cookies = __assign({}, this.cookies);
this._emitChange({ name, value, options });
}
remove(name, options) {
const finalOptions = (options = Object.assign(Object.assign({}, options), { expires: new Date(1970, 1, 1, 0, 0, 1), maxAge: 0 }));
this.cookies = Object.assign({}, this.cookies);
delete this.cookies[name];

@@ -68,15 +53,13 @@ if (this.HAS_DOCUMENT_COOKIE) {

}
this._emitChange({ name: name, value: undefined, options: options });
};
Cookies.prototype.addChangeListener = function (callback) {
this._emitChange({ name, value: undefined, options });
}
addChangeListener(callback) {
this.changeListeners.push(callback);
};
Cookies.prototype.removeChangeListener = function (callback) {
var idx = this.changeListeners.indexOf(callback);
}
removeChangeListener(callback) {
const idx = this.changeListeners.indexOf(callback);
if (idx >= 0) {
this.changeListeners.splice(idx, 1);
}
};
return Cookies;
}());
export default Cookies;
}
}
import Cookies from './Cookies';
export default Cookies;
export * from './types';
import Cookies from './Cookies';
export default Cookies;
export * from './types';

@@ -1,2 +0,2 @@

export declare type Cookie = any;
export type Cookie = any;
export interface CookieGetOptions {

@@ -23,2 +23,2 @@ doNotParse?: boolean;

}
export declare type CookieChangeListener = (options: CookieChangeOptions) => void;
export type CookieChangeListener = (options: CookieChangeOptions) => void;

@@ -0,0 +0,0 @@ import { Cookie, CookieGetOptions, CookieParseOptions } from './types';

@@ -32,5 +32,4 @@ import * as cookie from 'cookie';

}
export function readCookie(value, options) {
if (options === void 0) { options = {}; }
var cleanValue = cleanupCookieValue(value);
export function readCookie(value, options = {}) {
const cleanValue = cleanupCookieValue(value);
if (isParsingCookie(cleanValue, options.doNotParse)) {

@@ -37,0 +36,0 @@ try {

export * from './es6';

@@ -0,0 +0,0 @@ import { Cookie, CookieChangeListener, CookieGetOptions, CookieParseOptions, CookieSetOptions } from './types';

@@ -7,35 +7,17 @@ "use strict";

exports["default"] = void 0;
var cookie = _interopRequireWildcard(require("cookie"));
var _utils = require("./utils");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var __assign = void 0 && (void 0).__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
var Cookies =
/** @class */
function () {
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
var Cookies = /*#__PURE__*/function () {
function Cookies(cookies, options) {
var _this = this;
_classCallCheck(this, Cookies);
this.changeListeners = [];

@@ -48,100 +30,88 @@ this.HAS_DOCUMENT_COOKIE = false;

}
Cookies.prototype._updateBrowserValues = function (parseOptions) {
if (!this.HAS_DOCUMENT_COOKIE) {
return;
_createClass(Cookies, [{
key: "_updateBrowserValues",
value: function _updateBrowserValues(parseOptions) {
if (!this.HAS_DOCUMENT_COOKIE) {
return;
}
this.cookies = cookie.parse(document.cookie, parseOptions);
}
this.cookies = cookie.parse(document.cookie, parseOptions);
};
Cookies.prototype._emitChange = function (params) {
for (var i = 0; i < this.changeListeners.length; ++i) {
this.changeListeners[i](params);
}, {
key: "_emitChange",
value: function _emitChange(params) {
for (var i = 0; i < this.changeListeners.length; ++i) {
this.changeListeners[i](params);
}
}
};
Cookies.prototype.get = function (name, options, parseOptions) {
if (options === void 0) {
options = {};
}, {
key: "get",
value: function get(name) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var parseOptions = arguments.length > 2 ? arguments[2] : undefined;
this._updateBrowserValues(parseOptions);
return (0, _utils.readCookie)(this.cookies[name], options);
}
this._updateBrowserValues(parseOptions);
return (0, _utils.readCookie)(this.cookies[name], options);
};
Cookies.prototype.getAll = function (options, parseOptions) {
if (options === void 0) {
options = {};
}, {
key: "getAll",
value: function getAll() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var parseOptions = arguments.length > 1 ? arguments[1] : undefined;
this._updateBrowserValues(parseOptions);
var result = {};
for (var name in this.cookies) {
result[name] = (0, _utils.readCookie)(this.cookies[name], options);
}
return result;
}
this._updateBrowserValues(parseOptions);
var result = {};
for (var name_1 in this.cookies) {
result[name_1] = (0, _utils.readCookie)(this.cookies[name_1], options);
}, {
key: "set",
value: function set(name, value, options) {
if (_typeof(value) === 'object') {
value = JSON.stringify(value);
}
this.cookies = Object.assign(Object.assign({}, this.cookies), _defineProperty({}, name, value));
if (this.HAS_DOCUMENT_COOKIE) {
document.cookie = cookie.serialize(name, value, options);
}
this._emitChange({
name: name,
value: value,
options: options
});
}
return result;
};
Cookies.prototype.set = function (name, value, options) {
var _a;
if (_typeof(value) === 'object') {
value = JSON.stringify(value);
}, {
key: "remove",
value: function remove(name, options) {
var finalOptions = options = Object.assign(Object.assign({}, options), {
expires: new Date(1970, 1, 1, 0, 0, 1),
maxAge: 0
});
this.cookies = Object.assign({}, this.cookies);
delete this.cookies[name];
if (this.HAS_DOCUMENT_COOKIE) {
document.cookie = cookie.serialize(name, '', finalOptions);
}
this._emitChange({
name: name,
value: undefined,
options: options
});
}
this.cookies = __assign(__assign({}, this.cookies), (_a = {}, _a[name] = value, _a));
if (this.HAS_DOCUMENT_COOKIE) {
document.cookie = cookie.serialize(name, value, options);
}, {
key: "addChangeListener",
value: function addChangeListener(callback) {
this.changeListeners.push(callback);
}
this._emitChange({
name: name,
value: value,
options: options
});
};
Cookies.prototype.remove = function (name, options) {
var finalOptions = options = __assign(__assign({}, options), {
expires: new Date(1970, 1, 1, 0, 0, 1),
maxAge: 0
});
this.cookies = __assign({}, this.cookies);
delete this.cookies[name];
if (this.HAS_DOCUMENT_COOKIE) {
document.cookie = cookie.serialize(name, '', finalOptions);
}, {
key: "removeChangeListener",
value: function removeChangeListener(callback) {
var idx = this.changeListeners.indexOf(callback);
if (idx >= 0) {
this.changeListeners.splice(idx, 1);
}
}
this._emitChange({
name: name,
value: undefined,
options: options
});
};
Cookies.prototype.addChangeListener = function (callback) {
this.changeListeners.push(callback);
};
Cookies.prototype.removeChangeListener = function (callback) {
var idx = this.changeListeners.indexOf(callback);
if (idx >= 0) {
this.changeListeners.splice(idx, 1);
}
};
}]);
return Cookies;
}();
var _default = Cookies;
exports["default"] = _default;
exports["default"] = Cookies;
module.exports = exports.default;
import Cookies from './Cookies';
export default Cookies;
export * from './types';

@@ -6,10 +6,19 @@ "use strict";

});
var _exportNames = {};
exports["default"] = void 0;
var _Cookies = _interopRequireDefault(require("./Cookies"));
var _types = require("./types");
Object.keys(_types).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _types[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _types[key];
}
});
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _default = _Cookies["default"];
exports["default"] = _default;
module.exports = exports.default;
exports["default"] = _default;

@@ -1,2 +0,2 @@

export declare type Cookie = any;
export type Cookie = any;
export interface CookieGetOptions {

@@ -23,2 +23,2 @@ doNotParse?: boolean;

}
export declare type CookieChangeListener = (options: CookieChangeOptions) => void;
export type CookieChangeListener = (options: CookieChangeOptions) => void;

@@ -1,1 +0,5 @@

"use strict";
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

@@ -0,0 +0,0 @@ import { Cookie, CookieGetOptions, CookieParseOptions } from './types';

@@ -6,16 +6,11 @@ "use strict";

});
exports.cleanCookies = cleanCookies;
exports.hasDocumentCookie = hasDocumentCookie;
exports.cleanCookies = cleanCookies;
exports.isParsingCookie = isParsingCookie;
exports.parseCookies = parseCookies;
exports.isParsingCookie = isParsingCookie;
exports.readCookie = readCookie;
var cookie = _interopRequireWildcard(require("cookie"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function hasDocumentCookie() {

@@ -25,3 +20,2 @@ // Can we get/set cookies on document.cookie?

}
function cleanCookies() {

@@ -32,3 +26,2 @@ document.cookie.split(';').forEach(function (c) {

}
function parseCookies(cookies, options) {

@@ -43,3 +36,2 @@ if (typeof cookies === 'string') {

}
function isParsingCookie(value, doNotParse) {

@@ -50,25 +42,18 @@ if (typeof doNotParse === 'undefined') {

}
return !doNotParse;
}
function readCookie(value, options) {
if (options === void 0) {
options = {};
}
function readCookie(value) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var cleanValue = cleanupCookieValue(value);
if (isParsingCookie(cleanValue, options.doNotParse)) {
try {
return JSON.parse(cleanValue);
} catch (e) {// At least we tried
} catch (e) {
// At least we tried
}
} // Ignore clean value if we failed the deserialization
}
// Ignore clean value if we failed the deserialization
// It is not relevant anymore to trim those values
return value;
}
function cleanupCookieValue(value) {

@@ -79,4 +64,3 @@ // express prepend j: before serializing a cookie

}
return value;
}
{
"name": "universal-cookie",
"version": "4.0.4",
"version": "5.0.0",
"description": "Universal cookies for JavaScript",

@@ -38,11 +38,11 @@ "main": "cjs/index.js",

"dependencies": {
"@types/cookie": "^0.3.3",
"cookie": "^0.4.0"
"@types/cookie": "^0.5.1",
"cookie": "^0.5.0"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
"rimraf": "^3.0.0",
"rollup": "^1.16.4",
"typescript": "^3.0.1"
"@babel/cli": "^7.22.10",
"rimraf": "^3.0.2",
"rollup": "^3.28.0",
"typescript": "^5.1.6"
}
}

@@ -8,12 +8,10 @@ <h3 align="center">

<a href="https://badge.fury.io/js/universal-cookie"><img src="https://badge.fury.io/js/universal-cookie.svg" /></a>
![Test Status](https://github.com/github/docs/actions/workflows/test.yml/badge.svg)
</p>
[![Build Status](https://travis-ci.org/reactivestack/cookies.svg?branch=master)](https://travis-ci.org/reactivestack/cookies)
<br />
[![Sauce Test Status](https://saucelabs.com/browser-matrix/coookies.svg)](https://saucelabs.com/u/coookies)
## Integrations
- [`react-cookie`](https://www.npmjs.com/package/react-cookie) - Universal cookies for React
- [`universal-cookie-express`](https://www.npmjs.com/package/universal-cookie-express) - Hook cookies get/set on Express for server-rendering
- [`react-cookie`](https://www.npmjs.com/package/react-cookie) - Universal cookies for React
- [`universal-cookie-express`](https://www.npmjs.com/package/universal-cookie-express) - Hook cookies get/set on Express for server-rendering
## Getting started

@@ -23,6 +21,9 @@

or in the browser (global variable `UniversalCookie`):
or in the browser (global variable `UniversalCookie`):
```html
<script crossorigin src="https://unpkg.com/universal-cookie@3/umd/universalCookie.min.js"></script>
<script
crossorigin
src="https://unpkg.com/universal-cookie@3/umd/universalCookie.min.js"
></script>
```

@@ -33,18 +34,26 @@

### `constructor([cookieHeader])`
Create a cookies context
- cookieHeader (string|object): specify the cookie header or object
- cookieHeader (string|object): specify the cookie header or object
### `get(name, [options])`
Get a cookie value
- name (string): cookie name
- options (object):
- doNotParse (boolean): do not convert the cookie into an object no matter what
- name (string): cookie name
- options (object):
- doNotParse (boolean): do not convert the cookie into an object no matter what
### `getAll([options])`
Get all cookies
- options (object):
- doNotParse (boolean): do not convert the cookie into an object no matter what
- options (object):
- doNotParse (boolean): do not convert the cookie into an object no matter what
### `set(name, value, [options])`
Set a cookie value
- name (string): cookie name

@@ -58,7 +67,9 @@ - value (string|object): save the value and stringify the object if needed

- secure (boolean): Is only accessible through HTTPS?
- httpOnly (boolean): Is only the server can access the cookie?
- httpOnly (boolean): Is only the server can access the cookie? **Note: You cannot get or set httpOnly cookies from the browser, only the server.**
- sameSite (boolean|none|lax|strict): Strict or Lax enforcement
### `remove(name, [options])`
Remove a cookie
- name (string): cookie name

@@ -71,10 +82,13 @@ - options (object): Support all the cookie options from RFC 6265

- secure (boolean): Is only accessible through HTTPS?
- httpOnly (boolean): Is only the server can access the cookie?
- httpOnly (boolean): Is only the server can access the cookie? **Note: You cannot get or set httpOnly cookies from the browser, only the server.**
- sameSite (boolean|none|lax|strict): Strict or Lax enforcement
### `addChangeListener(callback)`
Add a listener to when a cookie is set or removed.
- callback (function): Call that will be called with the first argument containing `name`, `value` and `options` of the changed cookie.
- callback (function): Call that will be called with the first argument containing `name`, `value` and `options` of the changed cookie.
### `removeChangeListener(callback)`
Remove a listener from the change callback.

@@ -81,0 +95,0 @@

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = global || self, global.UniversalCookie = factory());
}(this, (function () { 'use strict';
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.UniversalCookie = factory());
})(this, (function () { 'use strict';
function unwrapExports (x) {
function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var cjs = {};
var Cookies = {exports: {}};
var cookie$1 = {};
/*!

@@ -27,4 +29,4 @@ * cookie

var parse_1 = parse;
var serialize_1 = serialize;
cookie$1.parse = parse;
cookie$1.serialize = serialize;

@@ -36,5 +38,3 @@ /**

var decode = decodeURIComponent;
var encode = encodeURIComponent;
var pairSplitRegExp = /; */;
var __toString = Object.prototype.toString;

@@ -70,26 +70,38 @@ /**

var opt = options || {};
var pairs = str.split(pairSplitRegExp);
var dec = opt.decode || decode;
for (var i = 0; i < pairs.length; i++) {
var pair = pairs[i];
var eq_idx = pair.indexOf('=');
var index = 0;
while (index < str.length) {
var eqIdx = str.indexOf('=', index);
// skip things that don't look like key=value
if (eq_idx < 0) {
continue;
// no more cookie pairs
if (eqIdx === -1) {
break
}
var key = pair.substr(0, eq_idx).trim();
var val = pair.substr(++eq_idx, pair.length).trim();
var endIdx = str.indexOf(';', index);
// quoted values
if ('"' == val[0]) {
val = val.slice(1, -1);
if (endIdx === -1) {
endIdx = str.length;
} else if (endIdx < eqIdx) {
// backtrack on prior semicolon
index = str.lastIndexOf(';', eqIdx - 1) + 1;
continue
}
var key = str.slice(index, eqIdx).trim();
// only assign once
if (undefined == obj[key]) {
if (undefined === obj[key]) {
var val = str.slice(eqIdx + 1, endIdx).trim();
// quoted values
if (val.charCodeAt(0) === 0x22) {
val = val.slice(1, -1);
}
obj[key] = tryDecode(val, dec);
}
index = endIdx + 1;
}

@@ -138,3 +150,7 @@

var maxAge = opt.maxAge - 0;
if (isNaN(maxAge)) throw new Error('maxAge should be a Number');
if (isNaN(maxAge) || !isFinite(maxAge)) {
throw new TypeError('option maxAge is invalid')
}
str += '; Max-Age=' + Math.floor(maxAge);

@@ -160,7 +176,9 @@ }

if (opt.expires) {
if (typeof opt.expires.toUTCString !== 'function') {
var expires = opt.expires;
if (!isDate(expires) || isNaN(expires.valueOf())) {
throw new TypeError('option expires is invalid');
}
str += '; Expires=' + opt.expires.toUTCString();
str += '; Expires=' + expires.toUTCString();
}

@@ -176,2 +194,22 @@

if (opt.priority) {
var priority = typeof opt.priority === 'string'
? opt.priority.toLowerCase()
: opt.priority;
switch (priority) {
case 'low':
str += '; Priority=Low';
break
case 'medium':
str += '; Priority=Medium';
break
case 'high':
str += '; Priority=High';
break
default:
throw new TypeError('option priority is invalid')
}
}
if (opt.sameSite) {

@@ -203,2 +241,38 @@ var sameSite = typeof opt.sameSite === 'string'

/**
* URL-decode string value. Optimized to skip native call when no %.
*
* @param {string} str
* @returns {string}
*/
function decode (str) {
return str.indexOf('%') !== -1
? decodeURIComponent(str)
: str
}
/**
* URL-encode value.
*
* @param {string} str
* @returns {string}
*/
function encode (val) {
return encodeURIComponent(val)
}
/**
* Determine if value is a Date.
*
* @param {*} val
* @private
*/
function isDate (val) {
return __toString.call(val) === '[object Date]' ||
val instanceof Date
}
/**
* Try decoding a string using a decoding function.

@@ -219,26 +293,16 @@ *

var cookie = {
parse: parse_1,
serialize: serialize_1
};
var utils = {};
var utils = createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
Object.defineProperty(utils, "__esModule", {
value: true
});
exports.hasDocumentCookie = hasDocumentCookie;
exports.cleanCookies = cleanCookies;
exports.parseCookies = parseCookies;
exports.isParsingCookie = isParsingCookie;
exports.readCookie = readCookie;
var cookie$1 = _interopRequireWildcard(cookie);
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
utils.cleanCookies = cleanCookies;
utils.hasDocumentCookie = hasDocumentCookie;
utils.isParsingCookie = isParsingCookie;
utils.parseCookies = parseCookies;
utils.readCookie = readCookie;
var cookie = _interopRequireWildcard(cookie$1);
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function hasDocumentCookie() {

@@ -248,3 +312,2 @@ // Can we get/set cookies on document.cookie?

}
function cleanCookies() {

@@ -255,6 +318,5 @@ document.cookie.split(';').forEach(function (c) {

}
function parseCookies(cookies, options) {
if (typeof cookies === 'string') {
return cookie$1.parse(cookies, options);
return cookie.parse(cookies, options);
} else if (_typeof(cookies) === 'object' && cookies !== null) {

@@ -266,3 +328,2 @@ return cookies;

}
function isParsingCookie(value, doNotParse) {

@@ -273,25 +334,18 @@ if (typeof doNotParse === 'undefined') {

}
return !doNotParse;
}
function readCookie(value, options) {
if (options === void 0) {
options = {};
}
function readCookie(value) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var cleanValue = cleanupCookieValue(value);
if (isParsingCookie(cleanValue, options.doNotParse)) {
try {
return JSON.parse(cleanValue);
} catch (e) {// At least we tried
} catch (e) {
// At least we tried
}
} // Ignore clean value if we failed the deserialization
}
// Ignore clean value if we failed the deserialization
// It is not relevant anymore to trim those values
return value;
}
function cleanupCookieValue(value) {

@@ -302,183 +356,159 @@ // express prepend j: before serializing a cookie

}
return value;
}
});
unwrapExports(utils);
var utils_1 = utils.hasDocumentCookie;
var utils_2 = utils.cleanCookies;
var utils_3 = utils.parseCookies;
var utils_4 = utils.isParsingCookie;
var utils_5 = utils.readCookie;
(function (module, exports) {
var Cookies_1 = createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var cookie = _interopRequireWildcard(cookie$1);
var _utils = utils;
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
var Cookies = /*#__PURE__*/function () {
function Cookies(cookies, options) {
var _this = this;
_classCallCheck(this, Cookies);
this.changeListeners = [];
this.HAS_DOCUMENT_COOKIE = false;
this.cookies = (0, _utils.parseCookies)(cookies, options);
new Promise(function () {
_this.HAS_DOCUMENT_COOKIE = (0, _utils.hasDocumentCookie)();
})["catch"](function () {});
}
_createClass(Cookies, [{
key: "_updateBrowserValues",
value: function _updateBrowserValues(parseOptions) {
if (!this.HAS_DOCUMENT_COOKIE) {
return;
}
this.cookies = cookie.parse(document.cookie, parseOptions);
}
}, {
key: "_emitChange",
value: function _emitChange(params) {
for (var i = 0; i < this.changeListeners.length; ++i) {
this.changeListeners[i](params);
}
}
}, {
key: "get",
value: function get(name) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var parseOptions = arguments.length > 2 ? arguments[2] : undefined;
this._updateBrowserValues(parseOptions);
return (0, _utils.readCookie)(this.cookies[name], options);
}
}, {
key: "getAll",
value: function getAll() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var parseOptions = arguments.length > 1 ? arguments[1] : undefined;
this._updateBrowserValues(parseOptions);
var result = {};
for (var name in this.cookies) {
result[name] = (0, _utils.readCookie)(this.cookies[name], options);
}
return result;
}
}, {
key: "set",
value: function set(name, value, options) {
if (_typeof(value) === 'object') {
value = JSON.stringify(value);
}
this.cookies = Object.assign(Object.assign({}, this.cookies), _defineProperty({}, name, value));
if (this.HAS_DOCUMENT_COOKIE) {
document.cookie = cookie.serialize(name, value, options);
}
this._emitChange({
name: name,
value: value,
options: options
});
}
}, {
key: "remove",
value: function remove(name, options) {
var finalOptions = options = Object.assign(Object.assign({}, options), {
expires: new Date(1970, 1, 1, 0, 0, 1),
maxAge: 0
});
this.cookies = Object.assign({}, this.cookies);
delete this.cookies[name];
if (this.HAS_DOCUMENT_COOKIE) {
document.cookie = cookie.serialize(name, '', finalOptions);
}
this._emitChange({
name: name,
value: undefined,
options: options
});
}
}, {
key: "addChangeListener",
value: function addChangeListener(callback) {
this.changeListeners.push(callback);
}
}, {
key: "removeChangeListener",
value: function removeChangeListener(callback) {
var idx = this.changeListeners.indexOf(callback);
if (idx >= 0) {
this.changeListeners.splice(idx, 1);
}
}
}]);
return Cookies;
}();
exports["default"] = Cookies;
module.exports = exports.default;
} (Cookies, Cookies.exports));
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var CookiesExports = Cookies.exports;
var cookie$1 = _interopRequireWildcard(cookie);
var types = {};
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var __assign = function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) {
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
}
return t;
};
return __assign.apply(this, arguments);
};
var Cookies =
/** @class */
function () {
function Cookies(cookies, options) {
var _this = this;
this.changeListeners = [];
this.HAS_DOCUMENT_COOKIE = false;
this.cookies = (0, utils.parseCookies)(cookies, options);
new Promise(function () {
_this.HAS_DOCUMENT_COOKIE = (0, utils.hasDocumentCookie)();
})["catch"](function () {});
}
Cookies.prototype._updateBrowserValues = function (parseOptions) {
if (!this.HAS_DOCUMENT_COOKIE) {
return;
}
this.cookies = cookie$1.parse(document.cookie, parseOptions);
};
Cookies.prototype._emitChange = function (params) {
for (var i = 0; i < this.changeListeners.length; ++i) {
this.changeListeners[i](params);
}
};
Cookies.prototype.get = function (name, options, parseOptions) {
if (options === void 0) {
options = {};
}
this._updateBrowserValues(parseOptions);
return (0, utils.readCookie)(this.cookies[name], options);
};
Cookies.prototype.getAll = function (options, parseOptions) {
if (options === void 0) {
options = {};
}
this._updateBrowserValues(parseOptions);
var result = {};
for (var name_1 in this.cookies) {
result[name_1] = (0, utils.readCookie)(this.cookies[name_1], options);
}
return result;
};
Cookies.prototype.set = function (name, value, options) {
var _a;
if (_typeof(value) === 'object') {
value = JSON.stringify(value);
}
this.cookies = __assign(__assign({}, this.cookies), (_a = {}, _a[name] = value, _a));
if (this.HAS_DOCUMENT_COOKIE) {
document.cookie = cookie$1.serialize(name, value, options);
}
this._emitChange({
name: name,
value: value,
options: options
});
};
Cookies.prototype.remove = function (name, options) {
var finalOptions = options = __assign(__assign({}, options), {
expires: new Date(1970, 1, 1, 0, 0, 1),
maxAge: 0
});
this.cookies = __assign({}, this.cookies);
delete this.cookies[name];
if (this.HAS_DOCUMENT_COOKIE) {
document.cookie = cookie$1.serialize(name, '', finalOptions);
}
this._emitChange({
name: name,
value: undefined,
options: options
});
};
Cookies.prototype.addChangeListener = function (callback) {
this.changeListeners.push(callback);
};
Cookies.prototype.removeChangeListener = function (callback) {
var idx = this.changeListeners.indexOf(callback);
if (idx >= 0) {
this.changeListeners.splice(idx, 1);
}
};
return Cookies;
}();
var _default = Cookies;
exports["default"] = _default;
module.exports = exports.default;
});
unwrapExports(Cookies_1);
var cjs = createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", {
Object.defineProperty(types, "__esModule", {
value: true
});
exports["default"] = void 0;
var _Cookies = _interopRequireDefault(Cookies_1);
(function (exports) {
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
Object.defineProperty(exports, "__esModule", {
value: true
});
var _exportNames = {};
exports["default"] = void 0;
var _Cookies = _interopRequireDefault(CookiesExports);
var _types = types;
Object.keys(_types).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _types[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _types[key];
}
});
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _default = _Cookies["default"];
exports["default"] = _default;
} (cjs));
var _default = _Cookies["default"];
exports["default"] = _default;
module.exports = exports.default;
});
var index = /*@__PURE__*/getDefaultExportFromCjs(cjs);
var index = unwrapExports(cjs);
return index;
})));
}));

@@ -1,1 +0,8 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).UniversalCookie=t()}(this,function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function t(e,t){return e(t={exports:{}},t.exports),t.exports}function o(e,t){if("string"!=typeof e)throw new TypeError("argument str must be a string");for(var o={},r=t||{},n=e.split(l),i=r.decode||p,a=0;a<n.length;a++){var s=n[a],u=s.indexOf("=");if(!(u<0)){var c=s.substr(0,u).trim(),f=s.substr(++u,s.length).trim();'"'==f[0]&&(f=f.slice(1,-1)),null==o[c]&&(o[c]=d(f,i))}}return o}function r(e,t,o){var r=o||{},n=r.encode||u;if("function"!=typeof n)throw new TypeError("option encode is invalid");if(!c.test(e))throw new TypeError("argument name is invalid");var i=n(t);if(i&&!c.test(i))throw new TypeError("argument val is invalid");var a=e+"="+i;if(null!=r.maxAge){var s=r.maxAge-0;if(isNaN(s))throw new Error("maxAge should be a Number");a+="; Max-Age="+Math.floor(s)}if(r.domain){if(!c.test(r.domain))throw new TypeError("option domain is invalid");a+="; Domain="+r.domain}if(r.path){if(!c.test(r.path))throw new TypeError("option path is invalid");a+="; Path="+r.path}if(r.expires){if("function"!=typeof r.expires.toUTCString)throw new TypeError("option expires is invalid");a+="; Expires="+r.expires.toUTCString()}if(r.httpOnly&&(a+="; HttpOnly"),r.secure&&(a+="; Secure"),r.sameSite){switch("string"==typeof r.sameSite?r.sameSite.toLowerCase():r.sameSite){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return a}var p=decodeURIComponent,u=encodeURIComponent,l=/; */,c=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function d(t,e){try{return e(t)}catch(e){return t}}var f={parse:o,serialize:r},y=t(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.hasDocumentCookie=function(){return"object"===("undefined"==typeof document?"undefined":s(document))&&"string"==typeof document.cookie},t.cleanCookies=function(){document.cookie.split(";").forEach(function(e){document.cookie=e.replace(/^ +/,"").replace(/=.*/,"=;expires="+(new Date).toUTCString()+";path=/")})},t.parseCookies=function(e,t){return"string"==typeof e?o.parse(e,t):"object"===s(e)&&null!==e?e:{}},t.isParsingCookie=r,t.readCookie=function(e,t){void 0===t&&(t={});var o=function(e){if(e&&"j"===e[0]&&":"===e[1])return e.substr(2);return e}(e);if(r(o,t.doNotParse))try{return JSON.parse(o)}catch(e){}return e};var o=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==s(e)&&"function"!=typeof e)return{default:e};var t=a();if(t&&t.has(e))return t.get(e);var o={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var i=r?Object.getOwnPropertyDescriptor(e,n):null;i&&(i.get||i.set)?Object.defineProperty(o,n,i):o[n]=e[n]}o.default=e,t&&t.set(e,o);return o}(f);function a(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return a=function(){return e},e}function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){return void 0===t&&(t=!e||"{"!==e[0]&&"["!==e[0]&&'"'!==e[0]),!t}});e(y);y.hasDocumentCookie,y.cleanCookies,y.parseCookies,y.isParsingCookie,y.readCookie;var n=t(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==s(e)&&"function"!=typeof e)return{default:e};var t=a();if(t&&t.has(e))return t.get(e);var o={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var i=r?Object.getOwnPropertyDescriptor(e,n):null;i&&(i.get||i.set)?Object.defineProperty(o,n,i):o[n]=e[n]}o.default=e,t&&t.set(e,o);return o}(f);function a(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return a=function(){return e},e}function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var i=function(){return(i=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function o(e,t){var o=this;this.changeListeners=[],this.HAS_DOCUMENT_COOKIE=!1,this.cookies=(0,y.parseCookies)(e,t),new Promise(function(){o.HAS_DOCUMENT_COOKIE=(0,y.hasDocumentCookie)()}).catch(function(){})}var r=(o.prototype._updateBrowserValues=function(e){this.HAS_DOCUMENT_COOKIE&&(this.cookies=n.parse(document.cookie,e))},o.prototype._emitChange=function(e){for(var t=0;t<this.changeListeners.length;++t)this.changeListeners[t](e)},o.prototype.get=function(e,t,o){return void 0===t&&(t={}),this._updateBrowserValues(o),(0,y.readCookie)(this.cookies[e],t)},o.prototype.getAll=function(e,t){void 0===e&&(e={}),this._updateBrowserValues(t);var o={};for(var r in this.cookies)o[r]=(0,y.readCookie)(this.cookies[r],e);return o},o.prototype.set=function(e,t,o){var r;"object"===s(t)&&(t=JSON.stringify(t)),this.cookies=i(i({},this.cookies),((r={})[e]=t,r)),this.HAS_DOCUMENT_COOKIE&&(document.cookie=n.serialize(e,t,o)),this._emitChange({name:e,value:t,options:o})},o.prototype.remove=function(e,t){var o=t=i(i({},t),{expires:new Date(1970,1,1,0,0,1),maxAge:0});this.cookies=i({},this.cookies),delete this.cookies[e],this.HAS_DOCUMENT_COOKIE&&(document.cookie=n.serialize(e,"",o)),this._emitChange({name:e,value:void 0,options:t})},o.prototype.addChangeListener=function(e){this.changeListeners.push(e)},o.prototype.removeChangeListener=function(e){var t=this.changeListeners.indexOf(e);0<=t&&this.changeListeners.splice(t,1)},o);t.default=r,e.exports=t.default});return e(n),e(t(function(e,t){var o;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=((o=n)&&o.__esModule?o:{default:o}).default;t.default=r,e.exports=t.default}))});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).UniversalCookie=t()}(this,(function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var t={},r={exports:{}},n={
/*!
* cookie
* Copyright(c) 2012-2014 Roman Shtylman
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/
parse:function(e,t){if("string"!=typeof e)throw new TypeError("argument str must be a string");var r={},n=(t||{}).decode||a,o=0;for(;o<e.length;){var i=e.indexOf("=",o);if(-1===i)break;var u=e.indexOf(";",o);if(-1===u)u=e.length;else if(u<i){o=e.lastIndexOf(";",i-1)+1;continue}var c=e.slice(o,i).trim();if(void 0===r[c]){var f=e.slice(i+1,u).trim();34===f.charCodeAt(0)&&(f=f.slice(1,-1)),r[c]=s(f,n)}o=u+1}return r},serialize:function(e,t,r){var n=r||{},a=n.encode||u;if("function"!=typeof a)throw new TypeError("option encode is invalid");if(!i.test(e))throw new TypeError("argument name is invalid");var s=a(t);if(s&&!i.test(s))throw new TypeError("argument val is invalid");var c=e+"="+s;if(null!=n.maxAge){var f=n.maxAge-0;if(isNaN(f)||!isFinite(f))throw new TypeError("option maxAge is invalid");c+="; Max-Age="+Math.floor(f)}if(n.domain){if(!i.test(n.domain))throw new TypeError("option domain is invalid");c+="; Domain="+n.domain}if(n.path){if(!i.test(n.path))throw new TypeError("option path is invalid");c+="; Path="+n.path}if(n.expires){var l=n.expires;if(!function(e){return"[object Date]"===o.call(e)||e instanceof Date}(l)||isNaN(l.valueOf()))throw new TypeError("option expires is invalid");c+="; Expires="+l.toUTCString()}n.httpOnly&&(c+="; HttpOnly");n.secure&&(c+="; Secure");if(n.priority){switch("string"==typeof n.priority?n.priority.toLowerCase():n.priority){case"low":c+="; Priority=Low";break;case"medium":c+="; Priority=Medium";break;case"high":c+="; Priority=High";break;default:throw new TypeError("option priority is invalid")}}if(n.sameSite){switch("string"==typeof n.sameSite?n.sameSite.toLowerCase():n.sameSite){case!0:c+="; SameSite=Strict";break;case"lax":c+="; SameSite=Lax";break;case"strict":c+="; SameSite=Strict";break;case"none":c+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return c}},o=Object.prototype.toString,i=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function a(e){return-1!==e.indexOf("%")?decodeURIComponent(e):e}function u(e){return encodeURIComponent(e)}function s(e,t){try{return t(e)}catch(t){return e}}var c={};Object.defineProperty(c,"__esModule",{value:!0}),c.cleanCookies=function(){document.cookie.split(";").forEach((function(e){document.cookie=e.replace(/^ +/,"").replace(/=.*/,"=;expires="+(new Date).toUTCString()+";path=/")}))},c.hasDocumentCookie=function(){return"object"===("undefined"==typeof document?"undefined":p(document))&&"string"==typeof document.cookie},c.isParsingCookie=d,c.parseCookies=function(e,t){return"string"==typeof e?f.parse(e,t):"object"===p(e)&&null!==e?e:{}},c.readCookie=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=function(e){if(e&&"j"===e[0]&&":"===e[1])return e.substr(2);return e}(e);if(d(r,t.doNotParse))try{return JSON.parse(r)}catch(e){}return e};var f=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==p(e)&&"function"!=typeof e)return{default:e};var r=l(t);if(r&&r.has(e))return r.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(n,i,a):n[i]=e[i]}n.default=e,r&&r.set(e,n);return n}(n);function l(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(l=function(e){return e?r:t})(e)}function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}function d(e,t){return void 0===t&&(t=!e||"{"!==e[0]&&"["!==e[0]&&'"'!==e[0]),!t}!function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==a(e)&&"function"!=typeof e)return{default:e};var r=i(t);if(r&&r.has(e))return r.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&Object.prototype.hasOwnProperty.call(e,u)){var s=o?Object.getOwnPropertyDescriptor(e,u):null;s&&(s.get||s.set)?Object.defineProperty(n,u,s):n[u]=e[u]}n.default=e,r&&r.set(e,n);return n}(n),o=c;function i(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(i=function(e){return e?r:t})(e)}function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,s(n.key),n)}}function s(e){var t=function(e,t){if("object"!==a(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==a(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===a(t)?t:String(t)}var f=function(){function e(t,r){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.changeListeners=[],this.HAS_DOCUMENT_COOKIE=!1,this.cookies=(0,o.parseCookies)(t,r),new Promise((function(){n.HAS_DOCUMENT_COOKIE=(0,o.hasDocumentCookie)()})).catch((function(){}))}var t,n,i;return t=e,n=[{key:"_updateBrowserValues",value:function(e){this.HAS_DOCUMENT_COOKIE&&(this.cookies=r.parse(document.cookie,e))}},{key:"_emitChange",value:function(e){for(var t=0;t<this.changeListeners.length;++t)this.changeListeners[t](e)}},{key:"get",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;return this._updateBrowserValues(r),(0,o.readCookie)(this.cookies[e],t)}},{key:"getAll",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;this._updateBrowserValues(t);var r={};for(var n in this.cookies)r[n]=(0,o.readCookie)(this.cookies[n],e);return r}},{key:"set",value:function(e,t,n){"object"===a(t)&&(t=JSON.stringify(t)),this.cookies=Object.assign(Object.assign({},this.cookies),function(e,t,r){return(t=s(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}({},e,t)),this.HAS_DOCUMENT_COOKIE&&(document.cookie=r.serialize(e,t,n)),this._emitChange({name:e,value:t,options:n})}},{key:"remove",value:function(e,t){var n=t=Object.assign(Object.assign({},t),{expires:new Date(1970,1,1,0,0,1),maxAge:0});this.cookies=Object.assign({},this.cookies),delete this.cookies[e],this.HAS_DOCUMENT_COOKIE&&(document.cookie=r.serialize(e,"",n)),this._emitChange({name:e,value:void 0,options:t})}},{key:"addChangeListener",value:function(e){this.changeListeners.push(e)}},{key:"removeChangeListener",value:function(e){var t=this.changeListeners.indexOf(e);t>=0&&this.changeListeners.splice(t,1)}}],n&&u(t.prototype,n),i&&u(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=f,e.exports=t.default}(r,r.exports);var y=r.exports,h={};return Object.defineProperty(h,"__esModule",{value:!0}),function(e){Object.defineProperty(e,"__esModule",{value:!0});var t={};e.default=void 0;var r,n=(r=y)&&r.__esModule?r:{default:r},o=h;Object.keys(o).forEach((function(r){"default"!==r&&"__esModule"!==r&&(Object.prototype.hasOwnProperty.call(t,r)||r in e&&e[r]===o[r]||Object.defineProperty(e,r,{enumerable:!0,get:function(){return o[r]}}))}));var i=n.default;e.default=i}(t),e(t)}));

Sorry, the diff of this file is not supported yet

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