New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-cookie

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-cookie - npm Package Compare versions

Comparing version 0.4.8 to 0.4.9

69

dist/react-cookie.js

@@ -41,2 +41,6 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

if (typeof doNotParse === 'undefined') {
doNotParse = !cookieVal || (cookieVal[0] !== '{' && cookieVal[0] !== '[');
}
if (!doNotParse) {

@@ -159,2 +163,4 @@ try {

'use strict';
/**

@@ -175,2 +181,3 @@ * Module exports.

var encode = encodeURIComponent;
var pairSplitRegExp = /; */;

@@ -206,11 +213,12 @@ /**

var opt = options || {};
var pairs = str.split(/; */);
var pairs = str.split(pairSplitRegExp);
var dec = opt.decode || decode;
pairs.forEach(function(pair) {
var eq_idx = pair.indexOf('=')
for (var i = 0; i < pairs.length; i++) {
var pair = pairs[i];
var eq_idx = pair.indexOf('=');
// skip things that don't look like key=value
if (eq_idx < 0) {
return;
continue;
}

@@ -230,3 +238,3 @@

}
});
}

@@ -256,2 +264,6 @@ return obj;

if (typeof enc !== 'function') {
throw new TypeError('option encode is invalid');
}
if (!fieldContentRegExp.test(name)) {

@@ -267,3 +279,3 @@ throw new TypeError('argument name is invalid');

var pairs = [name + '=' + value];
var str = name + '=' + value;

@@ -273,3 +285,3 @@ if (null != opt.maxAge) {

if (isNaN(maxAge)) throw new Error('maxAge should be a Number');
pairs.push('Max-Age=' + maxAge);
str += '; Max-Age=' + Math.floor(maxAge);
}

@@ -282,3 +294,3 @@

pairs.push('Domain=' + opt.domain);
str += '; Domain=' + opt.domain;
}

@@ -291,10 +303,41 @@

pairs.push('Path=' + opt.path);
str += '; Path=' + opt.path;
}
if (opt.expires) pairs.push('Expires=' + opt.expires.toUTCString());
if (opt.httpOnly) pairs.push('HttpOnly');
if (opt.secure) pairs.push('Secure');
if (opt.expires) {
if (typeof opt.expires.toUTCString !== 'function') {
throw new TypeError('option expires is invalid');
}
return pairs.join('; ');
str += '; Expires=' + opt.expires.toUTCString();
}
if (opt.httpOnly) {
str += '; HttpOnly';
}
if (opt.secure) {
str += '; Secure';
}
if (opt.sameSite) {
var sameSite = typeof opt.sameSite === 'string'
? opt.sameSite.toLowerCase() : opt.sameSite;
switch (sameSite) {
case true:
str += '; SameSite=Strict';
break;
case 'lax':
str += '; SameSite=Lax';
break;
case 'strict':
str += '; SameSite=Strict';
break;
default:
throw new TypeError('option sameSite is invalid');
}
}
return str;
}

@@ -301,0 +344,0 @@

2

dist/react-cookie.min.js

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

(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){var cookie=require("cookie");if(typeof Object.assign!="function"){Object.assign=function(target){"use strict";if(target==null){throw new TypeError("Cannot convert undefined or null to object")}target=Object(target);for(var index=1;index<arguments.length;index++){var source=arguments[index];if(source!=null){for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}}return target}}var _rawCookie={};var _res=undefined;function _isResWritable(){if(!_res)return false;if(_res.headersSent===true)return false;return true}function load(name,doNotParse){var cookies=typeof document==="undefined"?_rawCookie:cookie.parse(document.cookie);var cookieVal=cookies&&cookies[name];if(!doNotParse){try{cookieVal=JSON.parse(cookieVal)}catch(e){}}return cookieVal}function select(regex){var cookies=typeof document==="undefined"?_rawCookie:cookie.parse(document.cookie);if(!cookies)return{};if(!regex)return cookies;return Object.keys(cookies).reduce(function(accumulator,name){if(!regex.test(name))return accumulator;var newCookie={};newCookie[name]=cookies[name];return Object.assign({},accumulator,newCookie)},{})}function save(name,val,opt){_rawCookie[name]=val;if(typeof val==="object"){_rawCookie[name]=JSON.stringify(val)}if(typeof document!=="undefined"){document.cookie=cookie.serialize(name,_rawCookie[name],opt)}if(_isResWritable()&&_res.cookie){_res.cookie(name,val,opt)}}function remove(name,opt){delete _rawCookie[name];if(typeof opt==="undefined"){opt={}}else if(typeof opt==="string"){opt={path:opt}}else{opt=Object.assign({},opt)}if(typeof document!=="undefined"){opt.expires=new Date(1970,1,1,0,0,1);document.cookie=cookie.serialize(name,"",opt)}if(_isResWritable()&&_res.clearCookie){_res.clearCookie(name,opt)}}function setRawCookie(rawCookie){if(rawCookie){_rawCookie=cookie.parse(rawCookie)}else{_rawCookie={}}}function plugToRequest(req,res){if(req.cookie){_rawCookie=req.cookie}else if(req.cookies){_rawCookie=req.cookies}else if(req.headers&&req.headers.cookie){setRawCookie(req.headers.cookie)}else{_rawCookie={}}_res=res;return function unplug(){_res=null;_rawCookie={}}}var reactCookie={load:load,select:select,save:save,remove:remove,setRawCookie:setRawCookie,plugToRequest:plugToRequest};if(typeof window!=="undefined"){window["reactCookie"]=reactCookie}module.exports=reactCookie},{cookie:2}],2:[function(require,module,exports){exports.parse=parse;exports.serialize=serialize;var decode=decodeURIComponent;var encode=encodeURIComponent;var fieldContentRegExp=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function parse(str,options){if(typeof str!=="string"){throw new TypeError("argument str must be a string")}var obj={};var opt=options||{};var pairs=str.split(/; */);var dec=opt.decode||decode;pairs.forEach(function(pair){var eq_idx=pair.indexOf("=");if(eq_idx<0){return}var key=pair.substr(0,eq_idx).trim();var val=pair.substr(++eq_idx,pair.length).trim();if('"'==val[0]){val=val.slice(1,-1)}if(undefined==obj[key]){obj[key]=tryDecode(val,dec)}});return obj}function serialize(name,val,options){var opt=options||{};var enc=opt.encode||encode;if(!fieldContentRegExp.test(name)){throw new TypeError("argument name is invalid")}var value=enc(val);if(value&&!fieldContentRegExp.test(value)){throw new TypeError("argument val is invalid")}var pairs=[name+"="+value];if(null!=opt.maxAge){var maxAge=opt.maxAge-0;if(isNaN(maxAge))throw new Error("maxAge should be a Number");pairs.push("Max-Age="+maxAge)}if(opt.domain){if(!fieldContentRegExp.test(opt.domain)){throw new TypeError("option domain is invalid")}pairs.push("Domain="+opt.domain)}if(opt.path){if(!fieldContentRegExp.test(opt.path)){throw new TypeError("option path is invalid")}pairs.push("Path="+opt.path)}if(opt.expires)pairs.push("Expires="+opt.expires.toUTCString());if(opt.httpOnly)pairs.push("HttpOnly");if(opt.secure)pairs.push("Secure");return pairs.join("; ")}function tryDecode(str,decode){try{return decode(str)}catch(e){return str}}},{}]},{},[1]);
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){var cookie=require("cookie");if(typeof Object.assign!="function"){Object.assign=function(target){"use strict";if(target==null){throw new TypeError("Cannot convert undefined or null to object")}target=Object(target);for(var index=1;index<arguments.length;index++){var source=arguments[index];if(source!=null){for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}}return target}}var _rawCookie={};var _res=undefined;function _isResWritable(){if(!_res)return false;if(_res.headersSent===true)return false;return true}function load(name,doNotParse){var cookies=typeof document==="undefined"?_rawCookie:cookie.parse(document.cookie);var cookieVal=cookies&&cookies[name];if(typeof doNotParse==="undefined"){doNotParse=!cookieVal||cookieVal[0]!=="{"&&cookieVal[0]!=="["}if(!doNotParse){try{cookieVal=JSON.parse(cookieVal)}catch(e){}}return cookieVal}function select(regex){var cookies=typeof document==="undefined"?_rawCookie:cookie.parse(document.cookie);if(!cookies)return{};if(!regex)return cookies;return Object.keys(cookies).reduce(function(accumulator,name){if(!regex.test(name))return accumulator;var newCookie={};newCookie[name]=cookies[name];return Object.assign({},accumulator,newCookie)},{})}function save(name,val,opt){_rawCookie[name]=val;if(typeof val==="object"){_rawCookie[name]=JSON.stringify(val)}if(typeof document!=="undefined"){document.cookie=cookie.serialize(name,_rawCookie[name],opt)}if(_isResWritable()&&_res.cookie){_res.cookie(name,val,opt)}}function remove(name,opt){delete _rawCookie[name];if(typeof opt==="undefined"){opt={}}else if(typeof opt==="string"){opt={path:opt}}else{opt=Object.assign({},opt)}if(typeof document!=="undefined"){opt.expires=new Date(1970,1,1,0,0,1);document.cookie=cookie.serialize(name,"",opt)}if(_isResWritable()&&_res.clearCookie){_res.clearCookie(name,opt)}}function setRawCookie(rawCookie){if(rawCookie){_rawCookie=cookie.parse(rawCookie)}else{_rawCookie={}}}function plugToRequest(req,res){if(req.cookie){_rawCookie=req.cookie}else if(req.cookies){_rawCookie=req.cookies}else if(req.headers&&req.headers.cookie){setRawCookie(req.headers.cookie)}else{_rawCookie={}}_res=res;return function unplug(){_res=null;_rawCookie={}}}var reactCookie={load:load,select:select,save:save,remove:remove,setRawCookie:setRawCookie,plugToRequest:plugToRequest};if(typeof window!=="undefined"){window["reactCookie"]=reactCookie}module.exports=reactCookie},{cookie:2}],2:[function(require,module,exports){"use strict";exports.parse=parse;exports.serialize=serialize;var decode=decodeURIComponent;var encode=encodeURIComponent;var pairSplitRegExp=/; */;var fieldContentRegExp=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function parse(str,options){if(typeof str!=="string"){throw new TypeError("argument str must be a string")}var obj={};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("=");if(eq_idx<0){continue}var key=pair.substr(0,eq_idx).trim();var val=pair.substr(++eq_idx,pair.length).trim();if('"'==val[0]){val=val.slice(1,-1)}if(undefined==obj[key]){obj[key]=tryDecode(val,dec)}}return obj}function serialize(name,val,options){var opt=options||{};var enc=opt.encode||encode;if(typeof enc!=="function"){throw new TypeError("option encode is invalid")}if(!fieldContentRegExp.test(name)){throw new TypeError("argument name is invalid")}var value=enc(val);if(value&&!fieldContentRegExp.test(value)){throw new TypeError("argument val is invalid")}var str=name+"="+value;if(null!=opt.maxAge){var maxAge=opt.maxAge-0;if(isNaN(maxAge))throw new Error("maxAge should be a Number");str+="; Max-Age="+Math.floor(maxAge)}if(opt.domain){if(!fieldContentRegExp.test(opt.domain)){throw new TypeError("option domain is invalid")}str+="; Domain="+opt.domain}if(opt.path){if(!fieldContentRegExp.test(opt.path)){throw new TypeError("option path is invalid")}str+="; Path="+opt.path}if(opt.expires){if(typeof opt.expires.toUTCString!=="function"){throw new TypeError("option expires is invalid")}str+="; Expires="+opt.expires.toUTCString()}if(opt.httpOnly){str+="; HttpOnly"}if(opt.secure){str+="; Secure"}if(opt.sameSite){var sameSite=typeof opt.sameSite==="string"?opt.sameSite.toLowerCase():opt.sameSite;switch(sameSite){case true:str+="; SameSite=Strict";break;case"lax":str+="; SameSite=Lax";break;case"strict":str+="; SameSite=Strict";break;default:throw new TypeError("option sameSite is invalid")}}return str}function tryDecode(str,decode){try{return decode(str)}catch(e){return str}}},{}]},{},[1]);

@@ -40,2 +40,6 @@ var cookie = require('cookie');

if (typeof doNotParse === 'undefined') {
doNotParse = !cookieVal || (cookieVal[0] !== '{' && cookieVal[0] !== '[');
}
if (!doNotParse) {

@@ -101,2 +105,3 @@ try {

opt.expires = new Date(1970, 1, 1, 0, 0, 1);
opt.maxAge = 0;
document.cookie = cookie.serialize(name, '', opt);

@@ -103,0 +108,0 @@ }

{
"name": "react-cookie",
"version": "0.4.8",
"version": "0.4.9",
"description": "Load and save cookies within your React application",

@@ -31,3 +31,3 @@ "main": "index.js",

"dependencies": {
"cookie": "^0.1.2"
"cookie": "^0.3.1"
},

@@ -34,0 +34,0 @@ "devDependencies": {

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