Socket
Socket
Sign inDemoInstall

@types/set-cookie-parser

Package Overview
Dependencies
2
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @types/set-cookie-parser

TypeScript definitions for set-cookie-parser


Version published
Weekly downloads
1.9M
decreased by-2.61%
Maintainers
1
Install size
2.00 MB
Created
Weekly downloads
 

Package description

What is @types/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.

What are @types/set-cookie-parser's main functionalities?

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);

Other packages similar to @types/set-cookie-parser

Readme

Source

Installation

npm install --save @types/set-cookie-parser

Summary

This package contains type definitions for set-cookie-parser (https://github.com/nfriedly/set-cookie-parser).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/set-cookie-parser.

Additional Details

  • Last updated: Mon, 20 Nov 2023 23:36:24 GMT
  • Dependencies: @types/node

Credits

These definitions were written by Nick Paddock, Singlebyted, and Piotr Błażejewicz.

FAQs

Last updated on 21 Nov 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc