From c4e97ca61a2ea68a93fca74971ce36480d7edd3c Mon Sep 17 00:00:00 2001 From: Punith Krishnamurthy Date: Sun, 14 May 2023 10:43:17 +0530 Subject: [PATCH 1/2] added support for partitioned key as per new Chrome regulations As per new Chrome regulations for third party cookie, which would be blocked, partitioned must be sent to ensure a separate cookie jar in maintained. --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 9c3d07d..991a9f8 100644 --- a/index.js +++ b/index.js @@ -213,6 +213,10 @@ function serialize(name, val, options) { throw new TypeError('option sameSite is invalid'); } } + + if (opt.partitioned) { + str += '; Partitioned'; + } return str; } From 41e962aeb93967b0450ce7dc6e7fbc45e8d7a518 Mon Sep 17 00:00:00 2001 From: Punith Krishnamurthy Date: Sun, 14 May 2023 10:57:25 +0530 Subject: [PATCH 2/2] added test for partitioned key --- test/serialize.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/serialize.js b/test/serialize.js index 6e34590..2bc734e 100644 --- a/test/serialize.js +++ b/test/serialize.js @@ -193,4 +193,14 @@ describe('cookie.serialize(name, value, options)', function () { assert.equal(cookie.serialize('foo', 'bar', { secure: false }), 'foo=bar') }) }) + + describe('with "partitioned" option', function () { + it('should include partitioned flag when true', function () { + assert.equal(cookie.serialize('foo', 'bar', { partitioned: true }), 'foo=bar; Partitioned') + }) + + it('should not include partitioned flag when false', function () { + assert.equal(cookie.serialize('foo', 'bar', { partitioned: false }), 'foo=bar') + }) + }) })