You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
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

to
4.0.0

15

dist/index.d.ts

@@ -195,16 +195,3 @@ // Type definitions for cookie 0.5

declare function parseSetCookie(setCookie: string): undefined | ResponseCookie;
/**
* @source https://github.com/nfriedly/set-cookie-parser/blob/master/lib/set-cookie.js
*
* Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
* that are within a single set-cookie field-value, such as in the Expires portion.
* This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
* Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
* React Native's fetch does this for *every* header, including set-cookie.
*
* Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
* Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
*/
declare function splitCookiesString(cookiesString: string): string[];
export { CookieListItem, RequestCookie, RequestCookies, ResponseCookie, ResponseCookies, parseCookie, parseSetCookie, splitCookiesString, stringifyCookie };
export { CookieListItem, RequestCookie, RequestCookies, ResponseCookie, ResponseCookies, parseCookie, parseSetCookie, stringifyCookie };

@@ -27,3 +27,2 @@ "use strict";

parseSetCookie: () => parseSetCookie,
splitCookiesString: () => splitCookiesString,
stringifyCookie: () => stringifyCookie

@@ -100,53 +99,2 @@ });

}
function splitCookiesString(cookiesString) {
if (!cookiesString)
return [];
var cookiesStrings = [];
var pos = 0;
var start;
var ch;
var lastComma;
var nextStart;
var cookiesSeparatorFound;
function skipWhitespace() {
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
pos += 1;
}
return pos < cookiesString.length;
}
function notSpecialChar() {
ch = cookiesString.charAt(pos);
return ch !== "=" && ch !== ";" && ch !== ",";
}
while (pos < cookiesString.length) {
start = pos;
cookiesSeparatorFound = false;
while (skipWhitespace()) {
ch = cookiesString.charAt(pos);
if (ch === ",") {
lastComma = pos;
pos += 1;
skipWhitespace();
nextStart = pos;
while (pos < cookiesString.length && notSpecialChar()) {
pos += 1;
}
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
cookiesSeparatorFound = true;
pos = nextStart;
cookiesStrings.push(cookiesString.substring(start, lastComma));
start = pos;
} else {
pos = lastComma + 1;
}
} else {
pos += 1;
}
}
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
}
}
return cookiesStrings;
}

@@ -237,11 +185,4 @@ // src/request-cookies.ts

this._parsed = /* @__PURE__ */ new Map();
var _a, _b;
this._headers = responseHeaders;
const setCookie = (_a = responseHeaders.getSetCookie) == null ? void 0 : _a.call(responseHeaders);
(_b = responseHeaders.get("set-cookie")) != null ? _b : [];
const cookieStrings = Array.isArray(setCookie) ? setCookie : (
// TODO: remove splitCookiesString when `getSetCookie` adoption is high enough in Node.js
// https://developer.mozilla.org/en-US/docs/Web/API/Headers/getSetCookie#browser_compatibility
splitCookiesString(setCookie)
);
const cookieStrings = responseHeaders.getSetCookie();
for (const cookieString of cookieStrings) {

@@ -324,4 +265,3 @@ const parsed = parseSetCookie(cookieString);

parseSetCookie,
splitCookiesString,
stringifyCookie
});

4

package.json

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

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

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

"@edge-runtime/format": "2.2.0",
"@edge-runtime/jest-environment": "2.3.1"
"@edge-runtime/jest-environment": "2.3.2"
},

@@ -35,0 +35,0 @@ "engines": {

Sorry, the diff of this file is not supported yet