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

@edge-runtime/cookies

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@edge-runtime/cookies - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

4

dist/index.d.ts

@@ -138,3 +138,2 @@ // Type definitions for cookie 0.5

declare class RequestCookies {
#private;
constructor(requestHeaders: Headers);

@@ -160,2 +159,3 @@ [Symbol.iterator](): IterableIterator<[string, RequestCookie]>;

clear(): this;
toString(): string;
}

@@ -169,3 +169,2 @@

declare class ResponseCookies {
#private;
constructor(responseHeaders: Headers);

@@ -188,4 +187,5 @@ /**

delete(...args: [key: string] | [options: ResponseCookie]): this;
toString(): string;
}
export { CookieListItem, RequestCookie, RequestCookies, ResponseCookie, ResponseCookies };

@@ -19,20 +19,2 @@ "use strict";

var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __accessCheck = (obj, member, msg) => {
if (!member.has(obj))
throw TypeError("Cannot " + msg);
};
var __privateGet = (obj, member, getter) => {
__accessCheck(obj, member, "read from private field");
return getter ? getter.call(obj) : member.get(obj);
};
var __privateAdd = (obj, member, value) => {
if (member.has(obj))
throw TypeError("Cannot add the same private member more than once");
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
};
var __privateSet = (obj, member, value, setter) => {
__accessCheck(obj, member, "write to private field");
setter ? setter.call(obj, value) : member.set(obj, value);
return value;
};

@@ -107,8 +89,6 @@ // src/index.ts

// src/request-cookies.ts
var _headers, _parsed;
var RequestCookies = class {
constructor(requestHeaders) {
__privateAdd(this, _headers, void 0);
__privateAdd(this, _parsed, /* @__PURE__ */ new Map());
__privateSet(this, _headers, requestHeaders);
this._parsed = /* @__PURE__ */ new Map();
this._headers = requestHeaders;
const header = requestHeaders.get("cookie");

@@ -118,3 +98,3 @@ if (header) {

for (const [name, value] of parsed) {
__privateGet(this, _parsed).set(name, { name, value });
this._parsed.set(name, { name, value });
}

@@ -124,14 +104,14 @@ }

[Symbol.iterator]() {
return __privateGet(this, _parsed)[Symbol.iterator]();
return this._parsed[Symbol.iterator]();
}
get size() {
return __privateGet(this, _parsed).size;
return this._parsed.size;
}
get(...args) {
const name = typeof args[0] === "string" ? args[0] : args[0].name;
return __privateGet(this, _parsed).get(name);
return this._parsed.get(name);
}
getAll(...args) {
var _a;
const all = Array.from(__privateGet(this, _parsed));
const all = Array.from(this._parsed);
if (!args.length) {

@@ -144,9 +124,9 @@ return all.map(([_, value]) => value);

has(name) {
return __privateGet(this, _parsed).has(name);
return this._parsed.has(name);
}
set(...args) {
const [name, value] = args.length === 1 ? [args[0].name, args[0].value] : args;
const map = __privateGet(this, _parsed);
const map = this._parsed;
map.set(name, { name, value });
__privateGet(this, _headers).set(
this._headers.set(
"cookie",

@@ -158,5 +138,5 @@ Array.from(map).map(([_, value2]) => serialize(value2)).join("; ")

delete(names) {
const map = __privateGet(this, _parsed);
const map = this._parsed;
const result = !Array.isArray(names) ? map.delete(names) : names.map((name) => map.delete(name));
__privateGet(this, _headers).set(
this._headers.set(
"cookie",

@@ -168,24 +148,23 @@ Array.from(map).map(([_, value]) => serialize(value)).join("; ")

clear() {
this.delete(Array.from(__privateGet(this, _parsed).keys()));
this.delete(Array.from(this._parsed.keys()));
return this;
}
[Symbol.for("edge-runtime.inspect.custom")]() {
return `RequestCookies ${JSON.stringify(Object.fromEntries(__privateGet(this, _parsed)))}`;
return `RequestCookies ${JSON.stringify(Object.fromEntries(this._parsed))}`;
}
toString() {
return [...this._parsed.values()].map((v) => `${v.name}=${encodeURIComponent(v.value)}`).join("; ");
}
};
_headers = new WeakMap();
_parsed = new WeakMap();
// src/response-cookies.ts
var _headers2, _parsed2;
var ResponseCookies = class {
constructor(responseHeaders) {
__privateAdd(this, _headers2, void 0);
__privateAdd(this, _parsed2, /* @__PURE__ */ new Map());
__privateSet(this, _headers2, responseHeaders);
const headers = __privateGet(this, _headers2).getAll("set-cookie");
this._parsed = /* @__PURE__ */ new Map();
this._headers = responseHeaders;
const headers = this._headers.getAll("set-cookie");
for (const header of headers) {
const parsed = parseSetCookieString(header);
if (parsed) {
__privateGet(this, _parsed2).set(parsed.name, parsed);
this._parsed.set(parsed.name, parsed);
}

@@ -196,7 +175,7 @@ }

const key = typeof args[0] === "string" ? args[0] : args[0].name;
return __privateGet(this, _parsed2).get(key);
return this._parsed.get(key);
}
getAll(...args) {
var _a;
const all = Array.from(__privateGet(this, _parsed2).values());
const all = Array.from(this._parsed.values());
if (!args.length) {

@@ -210,5 +189,5 @@ return all;

const [name, value, cookie] = args.length === 1 ? [args[0].name, args[0].value, args[0]] : args;
const map = __privateGet(this, _parsed2);
const map = this._parsed;
map.set(name, normalizeCookie({ name, value, ...cookie }));
replace(map, __privateGet(this, _headers2));
replace(map, this._headers);
return this;

@@ -221,7 +200,8 @@ }

[Symbol.for("edge-runtime.inspect.custom")]() {
return `ResponseCookies ${JSON.stringify(Object.fromEntries(__privateGet(this, _parsed2)))}`;
return `ResponseCookies ${JSON.stringify(Object.fromEntries(this._parsed))}`;
}
toString() {
return [...this._parsed.values()].map(serialize).join("; ");
}
};
_headers2 = new WeakMap();
_parsed2 = new WeakMap();
function replace(bag, headers) {

@@ -228,0 +208,0 @@ headers.delete("set-cookie");

@@ -5,3 +5,3 @@ {

"homepage": "https://edge-runtime.vercel.app/packages/cookies",
"version": "3.0.0",
"version": "3.0.1",
"main": "dist/index.js",

@@ -24,3 +24,3 @@ "module": "dist/index.mjs",

"@edge-runtime/format": "1.1.0",
"@edge-runtime/jest-environment": "2.0.0",
"@edge-runtime/jest-environment": "2.0.2",
"@types/cookie": "0.5.1",

@@ -27,0 +27,0 @@ "tsup": "6"

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