🚀 Socket Launch Week 🚀 Day 2: Introducing Repository Labels and Security Policies.Learn More →

cookie-muncher

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cookie-muncher - npm Package Compare versions

Comparing version

to
0.4.6

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

declare const httpCookie: {
parse: (cookies: string) => Cookie[];
serialize: (cookie: Cookie, options?: HttpCookieOptions) => string;
};
declare const domCookie: {
getAll: () => Cookie[];
get: (name: string) => Cookie | null;
set: (cookie: Cookie, options?: DomCookieOptions) => void;
remove: (name: string, options?: RemoveDomCookieOptions) => void;
};
declare enum CookieMaxAge {
Now = -1,
OneHour = 3600,// 1 hour
SixHours = 21600,// 6 hours
TwlveHours = 43200,// 12 hours
OneDay = 86400,// 1 day
OneWeek = 604800,// 1 week
TwoWeeks = 1209600,// 2 weeks
OneMonth = 2592000,// 1 month
ThreeMonths = 7776000,// 3 months
SixMonths = 15552000,// 6 months
OneYear = 31536000
}
type Cookie = {

@@ -27,46 +53,2 @@ name: string;

/**
* Parse cookies from a string separated with semicolon.
*/
declare function parseCookies(cookies: string): Cookie[];
/**
* Format a string representing a cookie, useful to be able to set a cookie in a HTTP Set-Cookie header.
*/
declare function serializeCookie(cookie: Cookie, options?: HttpCookieOptions): string;
declare const httpCookie: {
parse: typeof parseCookies;
serialize: typeof serializeCookie;
};
declare function getAllCookies(): Cookie[];
declare function getCookie(name: string): Cookie | null;
declare function setCookie(cookie: Cookie, options?: DomCookieOptions): void;
declare function removeCookie(name: string, options?: RemoveDomCookieOptions): void;
declare const domCookie: {
getAll: typeof getAllCookies;
get: typeof getCookie;
set: typeof setCookie;
remove: typeof removeCookie;
};
declare enum CookieMaxAge {
Now = -1,
OneHour = 3600,// 1 hour
SixHours = 21600,// 6 hours
TwlveHours = 43200,// 12 hours
OneDay = 86400,// 1 day
OneWeek = 604800,// 1 week
TwoWeeks = 1209600,// 2 weeks
OneMonth = 2592000,// 1 month
ThreeMonths = 7776000,// 3 months
SixMonths = 15552000,// 6 months
OneYear = 31536000
}
export { type Cookie, CookieMaxAge, type DomCookieOptions, type HttpCookieOptions, type RemoveDomCookieOptions, domCookie, httpCookie };

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

"use strict";var f=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var b=(e,o)=>{for(var r in o)f(e,r,{get:o[r],enumerable:!0})},v=(e,o,r,p)=>{if(o&&typeof o=="object"||typeof o=="function")for(let m of x(o))!w.call(e,m)&&m!==r&&f(e,m,{get:()=>o[m],enumerable:!(p=y(o,m))||p.enumerable});return e};var z=e=>v(f({},"__esModule",{value:!0}),e);var $={};b($,{CookieMaxAge:()=>l,domCookie:()=>E,httpCookie:()=>O});module.exports=z($);function s(e){return e?e.split(";").filter(o=>/^\s*([\w!#$%&'*+\-.^_`|~]+)\s*=\s*([^;]*)\s*$/.test(o)===!0).map(o=>{let[r,p]=o.split("="),m=r.trim(),d=decodeURIComponent(p.trim());return{name:m,value:d}}):[]}function C(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function h(e){return new TextEncoder().encode(e).byteLength}function i(e,o={}){let r=[`${e.name}=${encodeURIComponent(e.value)}`];return o.maxAge&&r.push(`Max-Age=${o.maxAge}`),o.expires&&r.push(`Expires=${o.expires.toUTCString()}`),o.domain&&r.push(`Domain=${encodeURIComponent(o.domain)}`),r.push(`Path=${o.path||"/"}`),o.secure&&r.push("Secure"),o.httpOnly&&r.push("HttpOnly"),o.sameSite&&r.push(`SameSite=${C(o.sameSite)}`),r.join("; ")}var O={parse:s,serialize:i};function n(){if(!navigator.cookieEnabled)throw Error("Cookies are disabled by the browser")}function c(){return n(),s(document.cookie)}function u(e){return n(),s(document.cookie).find(o=>o.name===e)||null}function k(e,o={}){if(n(),document.cookie.split(";").length>=50)throw new Error("You have more than 50 cookies, most browsers limit the number of cookies to 50");let p=i(e,o);if(h(p)>4096)throw new Error("The size of this cookie is greater than 4096 bytes, most browsers limit the number of cookies to this size");document.cookie=i(e,o)}var l=(t=>(t[t.Now=-1]="Now",t[t.OneHour=3600]="OneHour",t[t.SixHours=21600]="SixHours",t[t.TwlveHours=43200]="TwlveHours",t[t.OneDay=86400]="OneDay",t[t.OneWeek=604800]="OneWeek",t[t.TwoWeeks=1209600]="TwoWeeks",t[t.OneMonth=2592e3]="OneMonth",t[t.ThreeMonths=7776e3]="ThreeMonths",t[t.SixMonths=15552e3]="SixMonths",t[t.OneYear=31536e3]="OneYear",t))(l||{});function a(e,o){n(),document.cookie=i({name:e,value:""},{...o,maxAge:-1})}var E={getAll:c,get:u,set:k,remove:a};0&&(module.exports={CookieMaxAge,domCookie,httpCookie});
var s=t=>t?t.split(";").filter(o=>/^\s*([\w!#$%&'*+\-.^_`|~]+)\s*=\s*([^;]*)\s*$/u.test(o)).map(o=>{let[r,m]=o.split("=");if(typeof r>"u"||typeof m>"u")throw Error("Invalid cookie format (this should not reachable, open an issue)");let l=r.trim(),C=decodeURIComponent(m.trim());return{name:l,value:C}}):[];var k=t=>`${t.charAt(0).toUpperCase()}${t.slice(1)}`,a=t=>new TextEncoder().encode(t).byteLength;var i=(t,o={})=>{let r=[`${t.name}=${encodeURIComponent(t.value)}`];return typeof o.maxAge<"u"&&r.push(`Max-Age=${String(o.maxAge)}`),typeof o.expires<"u"&&r.push(`Expires=${o.expires.toUTCString()}`),typeof o.domain<"u"&&r.push(`Domain=${encodeURIComponent(o.domain)}`),r.push(`Path=${o.path??"/"}`),typeof o.secure<"u"&&r.push("Secure"),typeof o.httpOnly<"u"&&r.push("HttpOnly"),typeof o.sameSite<"u"&&r.push(`SameSite=${k(o.sameSite)}`),r.join("; ")};var T={parse:s,serialize:i};var n=()=>{if(!navigator.cookieEnabled)throw Error("Cookies are disabled by the browser")};var p=()=>(n(),s(document.cookie));var f=t=>(n(),s(document.cookie).find(o=>o.name===t)??null);var c=(t,o={})=>{if(n(),document.cookie.split(";").length>=50)throw new Error("You have more than 50 cookies, most browsers limit the number of cookies to 50");let m=i(t,o);if(a(m)>4096)throw new Error("The size of this cookie is greater than 4096 bytes, most browsers limit the number of cookies to this size");document.cookie=i(t,o)};var d=(e=>(e[e.Now=-1]="Now",e[e.OneHour=3600]="OneHour",e[e.SixHours=21600]="SixHours",e[e.TwlveHours=43200]="TwlveHours",e[e.OneDay=86400]="OneDay",e[e.OneWeek=604800]="OneWeek",e[e.TwoWeeks=1209600]="TwoWeeks",e[e.OneMonth=2592e3]="OneMonth",e[e.ThreeMonths=7776e3]="ThreeMonths",e[e.SixMonths=15552e3]="SixMonths",e[e.OneYear=31536e3]="OneYear",e))(d||{});var u=(t,o)=>{n(),document.cookie=i({name:t,value:""},{...o,maxAge:-1})};var mo={getAll:p,get:f,set:c,remove:u};export{d as CookieMaxAge,mo as domCookie,T as httpCookie};
{
"name": "cookie-muncher",
"version": "0.4.5",
"description": "Effortless cookie management",
"description": "Effortless cookie management for server and browser",
"version": "0.4.6",
"license": "MIT",
"author": "Bluzzi",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.mjs",
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.js",
"types": "dist/index.d.ts",

@@ -19,6 +20,6 @@ "homepage": "https://github.com/Bluzzi/cookie-muncher#readme",

"devDependencies": {
"@bluzzi/eslint-config": "^1.2.1",
"@bluzzi/eslint-config": "^1.3.2",
"@types/node": "^22.10.2",
"@vitest/ui": "^2.1.8",
"eslint": "^8.56.0",
"eslint": "^9.17.0",
"jsdom": "^25.0.1",

@@ -29,8 +30,2 @@ "tsup": "^8.0.1",

},
"eslintConfig": {
"extends": "@bluzzi"
},
"tsup": {
"clean": true
},
"keywords": [

@@ -54,3 +49,3 @@ "cookie",

"scripts": {
"build": "tsup src/index.ts --minify --format cjs,esm --dts",
"build": "tsup src/index.ts --minify --format cjs,esm --clean --dts",
"test": "vitest --ui",

@@ -57,0 +52,0 @@ "lint": "eslint .",

@@ -9,11 +9,11 @@ import { defineConfig } from "vitest/config";

jsdom: {
url: "https://example.com"
}
}
url: "https://example.com",
},
},
},
resolve: {
alias: [
{ find: "#", replacement: resolve(__dirname, "src") }
]
}
});
{ find: "#", replacement: resolve(__dirname, "src") },
],
},
});

Sorry, the diff of this file is not supported yet