
Security News
Next.js Patches Critical Middleware Vulnerability (CVE-2025-29927)
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
@types/set-cookie-parser
Advanced tools
TypeScript definitions for set-cookie-parser
The @types/set-cookie-parser package provides TypeScript type definitions for the set-cookie-parser package, which is a library for parsing and splitting the Set-Cookie headers into individual cookie objects. It is useful for developers who use TypeScript and want to ensure type safety when working with cookies in HTTP responses.
Parsing Set-Cookie headers
This feature allows you to parse the content of Set-Cookie headers from an HTTP response and convert them into an array of cookie objects with TypeScript type definitions.
import setCookieParser from 'set-cookie-parser';
import { Cookie } from 'set-cookie-parser';
const setCookieHeader = 'sessionToken=abc123; Path=/; HttpOnly';
const cookies: Cookie[] = setCookieParser.parse(setCookieHeader);
Parsing Set-Cookie headers with options
This feature allows you to parse the Set-Cookie headers with additional options, such as mapping the resulting array into an object keyed by cookie names, while maintaining TypeScript type safety.
import setCookieParser from 'set-cookie-parser';
import { Cookie } from 'set-cookie-parser';
const setCookieHeader = 'sessionToken=abc123; Path=/; HttpOnly';
const options = { map: true };
const cookies: { [cookieName: string]: Cookie } = setCookieParser.parse(setCookieHeader, options);
Splitting Set-Cookie headers
This feature allows you to split a Set-Cookie header string or an array of Set-Cookie header strings into an array of individual cookie strings.
import setCookieParser from 'set-cookie-parser';
const setCookieHeaders = [
'sessionToken=abc123; Path=/; HttpOnly',
'userId=12345; Path=/; Secure'
];
const splitCookies: string[] = setCookieParser.splitCookiesString(setCookieHeaders);
The 'cookie' package is used for parsing and serializing cookie headers. It provides similar functionality for handling cookies but does not include TypeScript type definitions by default.
The 'tough-cookie' package is a more robust solution for handling cookies, including parsing, serialization, and cookie jar management. It is a more feature-rich library compared to set-cookie-parser but also does not include TypeScript type definitions by default.
The 'js-cookie' package is a simple, lightweight API for handling cookies in JavaScript. It is primarily designed for use in the browser and offers a fluent interface for cookie manipulation. Unlike set-cookie-parser, it does not focus on parsing Set-Cookie headers from HTTP responses.
npm install --save @types/set-cookie-parser
This package contains type definitions for set-cookie-parser (https://github.com/nfriedly/set-cookie-parser).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/set-cookie-parser.
These definitions were written by Nick Paddock, Singlebyted, and Piotr Błażejewicz.
FAQs
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.