Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fastify/cookie

Package Overview
Dependencies
Maintainers
19
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fastify/cookie - npm Package Compare versions

Comparing version 8.1.0 to 8.2.0

4

package.json
{
"name": "@fastify/cookie",
"version": "8.1.0",
"version": "8.2.0",
"description": "Plugin for fastify to add support for cookies",

@@ -50,3 +50,3 @@ "main": "plugin.js",

"tap": "^16.0.0",
"tsd": "^0.22.0"
"tsd": "^0.24.1"
},

@@ -53,0 +53,0 @@ "dependencies": {

@@ -45,3 +45,3 @@ 'use strict'

function fastifyCookieClearCookie (reply, name, options) {
const opts = Object.assign({ path: '/' }, options || { }, {
const opts = Object.assign({ path: '/' }, options, {
expires: new Date(1),

@@ -139,4 +139,5 @@ signed: undefined,

function clearCookie (name, options) {
return fastifyCookieClearCookie(this, name, options)
function clearCookie (name, cookieOptions) {
const opts = Object.assign({}, options.parseOptions, cookieOptions)
return fastifyCookieClearCookie(this, name, opts)
}

@@ -143,0 +144,0 @@ }

@@ -945,1 +945,49 @@ 'use strict'

})
test('clearCookie should include parseOptions', (t) => {
t.plan(14)
const fastify = Fastify()
fastify.register(plugin, {
parseOptions: {
path: '/test',
domain: 'example.com'
}
})
const cookieOptions = {
path: '/test',
maxAge: 36000
}
fastify.get('/test1', (req, reply) => {
reply
.setCookie('foo', 'foo', cookieOptions)
.clearCookie('foo', cookieOptions)
.send({ hello: 'world' })
})
fastify.inject({
method: 'GET',
url: '/test1'
}, (err, res) => {
t.error(err)
t.equal(res.statusCode, 200)
t.same(JSON.parse(res.body), { hello: 'world' })
const cookies = res.cookies
t.equal(cookies.length, 2)
t.equal(cookies[0].name, 'foo')
t.equal(cookies[0].value, 'foo')
t.equal(cookies[0].maxAge, 36000)
t.equal(cookies[0].path, '/test')
t.equal(cookies[0].domain, 'example.com')
t.equal(cookies[1].name, 'foo')
t.equal(cookies[1].value, '')
t.equal(cookies[1].path, '/test')
t.equal(cookies[1].domain, 'example.com')
t.ok(new Date(cookies[1].expires) < new Date())
})
})

@@ -6,4 +6,3 @@ import cookie from '..';

import fastifyCookieDefault, { fastifyCookie as fastifyCookieNamed } from '..';
import fastify, { FastifyInstance, FastifyPluginCallback, FastifyReply, setCookieWrapper } from 'fastify';
import { Server } from 'http';
import fastify, { FastifyInstance, FastifyReply, setCookieWrapper } from 'fastify';

@@ -10,0 +9,0 @@ const fastifyCookieCjs = require('..');

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