🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

persistore

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

persistore - npm Package Compare versions

Comparing version

to
1.8.0

6

dist/cjs/persistore.js

@@ -15,9 +15,9 @@ 'use strict';

const cookieLocation = () => (Access.variables().ci ? '' : 'Secure;') + 'Path=/;SameSite=strict';
const cookieLocation = (sameSite = 'strict') => `${Access.variables().ci ? '' : 'Secure;'}Path=/;SameSite=${sameSite}`;
const MAX_COOKIE_LENGTH = 4093;
const set = (name, value) => {
const set = (name, value, sameSite) => {
const encodedValue = encodeURIComponent(value);
const cookie = `${name}=${encodedValue};${cookieLocation()}`;
const cookie = `${name}=${encodedValue};${cookieLocation(sameSite)}`;
if (cookie.length > MAX_COOKIE_LENGTH) throw new Error(`Unable to set cookie. Cookie string is to long (${cookie.length} > ${MAX_COOKIE_LENGTH}).`);

@@ -24,0 +24,0 @@ Access.document().cookie = cookie;

@@ -11,9 +11,9 @@ const variables = {

const cookieLocation = () => (Access.variables().ci ? '' : 'Secure;') + 'Path=/;SameSite=strict';
const cookieLocation = (sameSite = 'strict') => `${Access.variables().ci ? '' : 'Secure;'}Path=/;SameSite=${sameSite}`;
const MAX_COOKIE_LENGTH = 4093;
const set = (name, value) => {
const set = (name, value, sameSite) => {
const encodedValue = encodeURIComponent(value);
const cookie = `${name}=${encodedValue};${cookieLocation()}`;
const cookie = `${name}=${encodedValue};${cookieLocation(sameSite)}`;
if (cookie.length > MAX_COOKIE_LENGTH) throw new Error(`Unable to set cookie. Cookie string is to long (${cookie.length} > ${MAX_COOKIE_LENGTH}).`);

@@ -20,0 +20,0 @@ Access.document().cookie = cookie;

{
"name": "persistore",
"version": "1.7.1",
"version": "1.8.0",
"description": "Automatically applying persistent storage with fallback strategies",

@@ -5,0 +5,0 @@ "main": "dist/cjs/persistore.js",

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

type SameSite = 'strict' | 'lax' | 'none';
// it is very important that deleting and setting cookies is performed
// on the same cookie location
const cookieLocation = () =>
(Access.variables().ci ? '' : 'Secure;') + 'Path=/;SameSite=strict';
const cookieLocation = (sameSite: SameSite = 'strict') =>
`${Access.variables().ci ? '' : 'Secure;'}Path=/;SameSite=${sameSite}`;
const MAX_COOKIE_LENGTH = 4093;
const set = (name: string, value: string): void => {
const set = (name: string, value: string, sameSite?: SameSite): void => {
const encodedValue = encodeURIComponent(value);
const cookie = `${name}=${encodedValue};${cookieLocation()}`;
const cookie = `${name}=${encodedValue};${cookieLocation(sameSite)}`;
if (cookie.length > MAX_COOKIE_LENGTH)

@@ -22,0 +23,0 @@ throw new Error(