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.2 to 4.0.3

4

cjs/Cookies.d.ts

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

import { Cookie, CookieGetOptions, CookieSetOptions, CookieChangeListener } from './types';
import { Cookie, CookieChangeListener, CookieGetOptions, CookieParseOptions, CookieSetOptions } from './types';
export default class Cookies {

@@ -6,3 +6,3 @@ private cookies;

private HAS_DOCUMENT_COOKIE;
constructor(cookies?: string | object | null);
constructor(cookies?: string | object | null, options?: CookieParseOptions);
private _updateBrowserValues;

@@ -9,0 +9,0 @@ private _emitChange;

@@ -12,4 +12,6 @@ "use strict";

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
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); }

@@ -24,3 +26,3 @@

function () {
function Cookies(cookies) {
function Cookies(cookies, options) {
var _this = this;

@@ -30,3 +32,3 @@

this.HAS_DOCUMENT_COOKIE = false;
this.cookies = (0, _utils.parseCookies)(cookies);
this.cookies = (0, _utils.parseCookies)(cookies, options);
new Promise(function () {

@@ -37,3 +39,3 @@ _this.HAS_DOCUMENT_COOKIE = (0, _utils.hasDocumentCookie)();

Cookies.prototype._updateBrowserValues = function () {
Cookies.prototype._updateBrowserValues = function (parseOptions) {
if (!this.HAS_DOCUMENT_COOKIE) {

@@ -43,3 +45,3 @@ return;

this.cookies = cookie.parse(document.cookie);
this.cookies = cookie.parse(document.cookie, parseOptions);
};

@@ -53,3 +55,3 @@

Cookies.prototype.get = function (name, options) {
Cookies.prototype.get = function (name, options, parseOptions) {
if (options === void 0) {

@@ -59,3 +61,3 @@ options = {};

this._updateBrowserValues();
this._updateBrowserValues(parseOptions);

@@ -65,3 +67,3 @@ return (0, _utils.readCookie)(this.cookies[name], options);

Cookies.prototype.getAll = function (options) {
Cookies.prototype.getAll = function (options, parseOptions) {
if (options === void 0) {

@@ -71,3 +73,3 @@ options = {};

this._updateBrowserValues();
this._updateBrowserValues(parseOptions);

@@ -74,0 +76,0 @@ var result = {};

@@ -13,2 +13,3 @@ export declare type Cookie = any;

sameSite?: boolean | 'none' | 'lax' | 'strict';
encode?: (value: string) => string;
}

@@ -20,2 +21,5 @@ export interface CookieChangeOptions {

}
export interface CookieParseOptions {
decode: (value: string) => string;
}
export declare type CookieChangeListener = (options: CookieChangeOptions) => void;

@@ -1,6 +0,6 @@

import { Cookie, CookieGetOptions } from './types';
import { Cookie, CookieGetOptions, CookieParseOptions } from './types';
export declare function hasDocumentCookie(): boolean;
export declare function cleanCookies(): void;
export declare function parseCookies(cookies?: string | object | null): object;
export declare function parseCookies(cookies?: string | object | null, options?: CookieParseOptions): object;
export declare function isParsingCookie(value: Cookie, doNotParse?: boolean): boolean;
export declare function readCookie(value: Cookie, options?: CookieGetOptions): any;

@@ -14,24 +14,13 @@ "use strict";

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
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 hasDocumentCookie() {
// JSDOM does not support changing cookies, disable it for tests
if (isJsDom()) {
return false;
} // Can we get/set cookies on document.cookie?
// Can we get/set cookies on document.cookie?
return (typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object' && typeof document.cookie === 'string';
}
function isJsDom() {
if ((typeof navigator === "undefined" ? "undefined" : _typeof(navigator)) !== 'object' || typeof navigator.userAgent !== 'string') {
return false;
}
return navigator.userAgent.indexOf('Node.js') >= 0 || navigator.userAgent.indexOf('jsdom') >= 0;
}
function cleanCookies() {

@@ -43,5 +32,5 @@ document.cookie.split(';').forEach(function (c) {

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

@@ -48,0 +37,0 @@ return cookies;

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

import { Cookie, CookieGetOptions, CookieSetOptions, CookieChangeListener } from './types';
import { Cookie, CookieChangeListener, CookieGetOptions, CookieParseOptions, CookieSetOptions } from './types';
export default class Cookies {

@@ -6,3 +6,3 @@ private cookies;

private HAS_DOCUMENT_COOKIE;
constructor(cookies?: string | object | null);
constructor(cookies?: string | object | null, options?: CookieParseOptions);
private _updateBrowserValues;

@@ -9,0 +9,0 @@ private _emitChange;

import * as cookie from 'cookie';
import { parseCookies, readCookie, hasDocumentCookie } from './utils';
import { hasDocumentCookie, parseCookies, readCookie } from './utils';
// We can't please Rollup and TypeScript at the same time

@@ -7,7 +7,7 @@ // Only way to make both of them work

var Cookies = /** @class */ (function () {
function Cookies(cookies) {
function Cookies(cookies, options) {
var _this = this;
this.changeListeners = [];
this.HAS_DOCUMENT_COOKIE = false;
this.cookies = parseCookies(cookies);
this.cookies = parseCookies(cookies, options);
new Promise(function () {

@@ -17,7 +17,7 @@ _this.HAS_DOCUMENT_COOKIE = hasDocumentCookie();

}
Cookies.prototype._updateBrowserValues = function () {
Cookies.prototype._updateBrowserValues = function (parseOptions) {
if (!this.HAS_DOCUMENT_COOKIE) {
return;
}
this.cookies = cookie.parse(document.cookie);
this.cookies = cookie.parse(document.cookie, parseOptions);
};

@@ -29,10 +29,10 @@ Cookies.prototype._emitChange = function (params) {

};
Cookies.prototype.get = function (name, options) {
Cookies.prototype.get = function (name, options, parseOptions) {
if (options === void 0) { options = {}; }
this._updateBrowserValues();
this._updateBrowserValues(parseOptions);
return readCookie(this.cookies[name], options);
};
Cookies.prototype.getAll = function (options) {
Cookies.prototype.getAll = function (options, parseOptions) {
if (options === void 0) { options = {}; }
this._updateBrowserValues();
this._updateBrowserValues(parseOptions);
var result = {};

@@ -39,0 +39,0 @@ for (var name_1 in this.cookies) {

@@ -13,2 +13,3 @@ export declare type Cookie = any;

sameSite?: boolean | 'none' | 'lax' | 'strict';
encode?: (value: string) => string;
}

@@ -20,2 +21,5 @@ export interface CookieChangeOptions {

}
export interface CookieParseOptions {
decode: (value: string) => string;
}
export declare type CookieChangeListener = (options: CookieChangeOptions) => void;

@@ -1,6 +0,6 @@

import { Cookie, CookieGetOptions } from './types';
import { Cookie, CookieGetOptions, CookieParseOptions } from './types';
export declare function hasDocumentCookie(): boolean;
export declare function cleanCookies(): void;
export declare function parseCookies(cookies?: string | object | null): object;
export declare function parseCookies(cookies?: string | object | null, options?: CookieParseOptions): object;
export declare function isParsingCookie(value: Cookie, doNotParse?: boolean): boolean;
export declare function readCookie(value: Cookie, options?: CookieGetOptions): any;
import * as cookie from 'cookie';
export function hasDocumentCookie() {
// JSDOM does not support changing cookies, disable it for tests
if (isJsDom()) {
return false;
}
// Can we get/set cookies on document.cookie?
return typeof document === 'object' && typeof document.cookie === 'string';
}
function isJsDom() {
if (typeof navigator !== 'object' ||
typeof navigator.userAgent !== 'string') {
return false;
}
return (navigator.userAgent.indexOf('Node.js') >= 0 ||
navigator.userAgent.indexOf('jsdom') >= 0);
}
export function cleanCookies() {

@@ -25,5 +13,5 @@ document.cookie.split(';').forEach(function (c) {

}
export function parseCookies(cookies) {
export function parseCookies(cookies, options) {
if (typeof cookies === 'string') {
return cookie.parse(cookies);
return cookie.parse(cookies, options);
}

@@ -30,0 +18,0 @@ else if (typeof cookies === 'object' && cookies !== null) {

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

import { Cookie, CookieGetOptions, CookieSetOptions, CookieChangeListener } from './types';
import { Cookie, CookieChangeListener, CookieGetOptions, CookieParseOptions, CookieSetOptions } from './types';
export default class Cookies {

@@ -6,3 +6,3 @@ private cookies;

private HAS_DOCUMENT_COOKIE;
constructor(cookies?: string | object | null);
constructor(cookies?: string | object | null, options?: CookieParseOptions);
private _updateBrowserValues;

@@ -9,0 +9,0 @@ private _emitChange;

@@ -12,4 +12,6 @@ "use strict";

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
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); }

@@ -24,3 +26,3 @@

function () {
function Cookies(cookies) {
function Cookies(cookies, options) {
var _this = this;

@@ -30,3 +32,3 @@

this.HAS_DOCUMENT_COOKIE = false;
this.cookies = (0, _utils.parseCookies)(cookies);
this.cookies = (0, _utils.parseCookies)(cookies, options);
new Promise(function () {

@@ -37,3 +39,3 @@ _this.HAS_DOCUMENT_COOKIE = (0, _utils.hasDocumentCookie)();

Cookies.prototype._updateBrowserValues = function () {
Cookies.prototype._updateBrowserValues = function (parseOptions) {
if (!this.HAS_DOCUMENT_COOKIE) {

@@ -43,3 +45,3 @@ return;

this.cookies = cookie.parse(document.cookie);
this.cookies = cookie.parse(document.cookie, parseOptions);
};

@@ -53,3 +55,3 @@

Cookies.prototype.get = function (name, options) {
Cookies.prototype.get = function (name, options, parseOptions) {
if (options === void 0) {

@@ -59,3 +61,3 @@ options = {};

this._updateBrowserValues();
this._updateBrowserValues(parseOptions);

@@ -65,3 +67,3 @@ return (0, _utils.readCookie)(this.cookies[name], options);

Cookies.prototype.getAll = function (options) {
Cookies.prototype.getAll = function (options, parseOptions) {
if (options === void 0) {

@@ -71,3 +73,3 @@ options = {};

this._updateBrowserValues();
this._updateBrowserValues(parseOptions);

@@ -74,0 +76,0 @@ var result = {};

@@ -13,2 +13,3 @@ export declare type Cookie = any;

sameSite?: boolean | 'none' | 'lax' | 'strict';
encode?: (value: string) => string;
}

@@ -20,2 +21,5 @@ export interface CookieChangeOptions {

}
export interface CookieParseOptions {
decode: (value: string) => string;
}
export declare type CookieChangeListener = (options: CookieChangeOptions) => void;

@@ -1,6 +0,6 @@

import { Cookie, CookieGetOptions } from './types';
import { Cookie, CookieGetOptions, CookieParseOptions } from './types';
export declare function hasDocumentCookie(): boolean;
export declare function cleanCookies(): void;
export declare function parseCookies(cookies?: string | object | null): object;
export declare function parseCookies(cookies?: string | object | null, options?: CookieParseOptions): object;
export declare function isParsingCookie(value: Cookie, doNotParse?: boolean): boolean;
export declare function readCookie(value: Cookie, options?: CookieGetOptions): any;

@@ -14,24 +14,13 @@ "use strict";

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
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 hasDocumentCookie() {
// JSDOM does not support changing cookies, disable it for tests
if (isJsDom()) {
return false;
} // Can we get/set cookies on document.cookie?
// Can we get/set cookies on document.cookie?
return (typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object' && typeof document.cookie === 'string';
}
function isJsDom() {
if ((typeof navigator === "undefined" ? "undefined" : _typeof(navigator)) !== 'object' || typeof navigator.userAgent !== 'string') {
return false;
}
return navigator.userAgent.indexOf('Node.js') >= 0 || navigator.userAgent.indexOf('jsdom') >= 0;
}
function cleanCookies() {

@@ -43,5 +32,5 @@ document.cookie.split(';').forEach(function (c) {

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

@@ -48,0 +37,0 @@ return cookies;

{
"name": "universal-cookie",
"version": "4.0.2",
"version": "4.0.3",
"description": "Universal cookies for JavaScript",
"main": "cjs/index.js",
"module": "es6/index.js",
"sideEffects": false,
"files": [

@@ -44,3 +45,3 @@ "lib",

"@babel/cli": "^7.0.0",
"rimraf": "^2.6.1",
"rimraf": "^3.0.0",
"rollup": "^1.16.4",

@@ -47,0 +48,0 @@ "typescript": "^3.0.1"

@@ -52,3 +52,3 @@ <h3 align="center">

- expires (Date): absolute expiration date for the cookie
- maxAge (number): relative max age of the cookie from when the client receives it in second
- maxAge (number): relative max age of the cookie from when the client receives it in seconds
- domain (string): domain for the cookie (sub.domain.com or .allsubdomains.com)

@@ -65,3 +65,3 @@ - secure (boolean): Is only accessible through HTTPS?

- expires (Date): absolute expiration date for the cookie
- maxAge (number): relative max age of the cookie from when the client receives it in second
- maxAge (number): relative max age of the cookie from when the client receives it in seconds
- domain (string): domain for the cookie (sub.domain.com or .allsubdomains.com)

@@ -68,0 +68,0 @@ - secure (boolean): Is only accessible through HTTPS?

@@ -5,3 +5,3 @@ (function (global, factory) {

(global = global || self, global.UniversalCookie = factory());
}(this, function () { 'use strict';
}(this, (function () { 'use strict';

@@ -231,24 +231,13 @@ function unwrapExports (x) {

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
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 hasDocumentCookie() {
// JSDOM does not support changing cookies, disable it for tests
if (isJsDom()) {
return false;
} // Can we get/set cookies on document.cookie?
// Can we get/set cookies on document.cookie?
return (typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object' && typeof document.cookie === 'string';
}
function isJsDom() {
if ((typeof navigator === "undefined" ? "undefined" : _typeof(navigator)) !== 'object' || typeof navigator.userAgent !== 'string') {
return false;
}
return navigator.userAgent.indexOf('Node.js') >= 0 || navigator.userAgent.indexOf('jsdom') >= 0;
}
function cleanCookies() {

@@ -260,5 +249,5 @@ document.cookie.split(';').forEach(function (c) {

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

@@ -416,4 +405,6 @@ return cookies;

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } }
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); }

@@ -428,3 +419,3 @@

function () {
function Cookies(cookies) {
function Cookies(cookies, options) {
var _this = this;

@@ -434,3 +425,3 @@

this.HAS_DOCUMENT_COOKIE = false;
this.cookies = (0, utils.parseCookies)(cookies);
this.cookies = (0, utils.parseCookies)(cookies, options);
new Promise(function () {

@@ -441,3 +432,3 @@ _this.HAS_DOCUMENT_COOKIE = (0, utils.hasDocumentCookie)();

Cookies.prototype._updateBrowserValues = function () {
Cookies.prototype._updateBrowserValues = function (parseOptions) {
if (!this.HAS_DOCUMENT_COOKIE) {

@@ -447,3 +438,3 @@ return;

this.cookies = cookie$1.parse(document.cookie);
this.cookies = cookie$1.parse(document.cookie, parseOptions);
};

@@ -457,3 +448,3 @@

Cookies.prototype.get = function (name, options) {
Cookies.prototype.get = function (name, options, parseOptions) {
if (options === void 0) {

@@ -463,3 +454,3 @@ options = {};

this._updateBrowserValues();
this._updateBrowserValues(parseOptions);

@@ -469,3 +460,3 @@ return (0, utils.readCookie)(this.cookies[name], options);

Cookies.prototype.getAll = function (options) {
Cookies.prototype.getAll = function (options, parseOptions) {
if (options === void 0) {

@@ -475,3 +466,3 @@ options = {};

this._updateBrowserValues();
this._updateBrowserValues(parseOptions);

@@ -568,2 +559,2 @@ var result = {};

}));
})));

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

!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 a={parse:o,serialize:r},s=t(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.hasDocumentCookie=function(){if("object"===("undefined"==typeof navigator?"undefined":r(navigator))&&"string"==typeof navigator.userAgent&&(0<=navigator.userAgent.indexOf("Node.js")||0<=navigator.userAgent.indexOf("jsdom")))return!1;return"object"===("undefined"==typeof document?"undefined":r(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){return"string"==typeof e?o.parse(e):"object"===r(e)&&null!==e?e:{}},t.isParsingCookie=n,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(n(o,t.doNotParse))try{return JSON.parse(o)}catch(e){}return e};var o=function(e){{if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var r=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(e,o):{};r.get||r.set?Object.defineProperty(t,o,r):t[o]=e[o]}return t.default=e,t}}(a);function r(e){return(r="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 n(e,t){return void 0===t&&(t=!e||"{"!==e[0]&&"["!==e[0]&&'"'!==e[0]),!t}});e(s);s.hasDocumentCookie,s.cleanCookies,s.parseCookies,s.isParsingCookie,s.readCookie;var f=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable;var m=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},o=0;o<10;o++)t["_"+String.fromCharCode(o)]=o;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var o,r,n=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),i=1;i<arguments.length;i++){for(var a in o=Object(arguments[i]))y.call(o,a)&&(n[a]=o[a]);if(f){r=f(o);for(var s=0;s<r.length;s++)h.call(o,r[s])&&(n[r[s]]=o[r[s]])}}return n},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;var t={};if(null!=e)for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var r=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(e,o):{};r.get||r.set?Object.defineProperty(t,o,r):t[o]=e[o]}return t.default=e,t}}(a);function i(e){return(i="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 o(e){var t=this;this.changeListeners=[],this.HAS_DOCUMENT_COOKIE=!1,this.cookies=(0,s.parseCookies)(e),new Promise(function(){t.HAS_DOCUMENT_COOKIE=(0,s.hasDocumentCookie)()}).catch(function(){})}var r=(o.prototype._updateBrowserValues=function(){this.HAS_DOCUMENT_COOKIE&&(this.cookies=n.parse(document.cookie))},o.prototype._emitChange=function(e){for(var t=0;t<this.changeListeners.length;++t)this.changeListeners[t](e)},o.prototype.get=function(e,t){return void 0===t&&(t={}),this._updateBrowserValues(),(0,s.readCookie)(this.cookies[e],t)},o.prototype.getAll=function(e){void 0===e&&(e={}),this._updateBrowserValues();var t={};for(var o in this.cookies)t[o]=(0,s.readCookie)(this.cookies[o],e);return t},o.prototype.set=function(e,t,o){var r;"object"===i(t)&&(t=JSON.stringify(t)),this.cookies=m({},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=m({},t,{expires:new Date(1970,1,1,0,0,1),maxAge:0});this.cookies=m({},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=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 i={parse:o,serialize:r},f=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}(i);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(f);f.hasDocumentCookie,f.cleanCookies,f.parseCookies,f.isParsingCookie,f.readCookie;var y=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,m=Object.prototype.propertyIsEnumerable;var v=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},o=0;o<10;o++)t["_"+String.fromCharCode(o)]=o;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var o,r,n=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),i=1;i<arguments.length;i++){for(var a in o=Object(arguments[i]))h.call(o,a)&&(n[a]=o[a]);if(y){r=y(o);for(var s=0;s<r.length;s++)m.call(o,r[s])&&(n[r[s]]=o[r[s]])}}return n},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}(i);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 o(e,t){var o=this;this.changeListeners=[],this.HAS_DOCUMENT_COOKIE=!1,this.cookies=(0,f.parseCookies)(e,t),new Promise(function(){o.HAS_DOCUMENT_COOKIE=(0,f.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,f.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,f.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=v({},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=v({},t,{expires:new Date(1970,1,1,0,0,1),maxAge:0});this.cookies=v({},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}))});
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