Skip to content

Commit 84a1567

Browse files
pazguilledougwilson
authored andcommittedNov 7, 2023
Add partitioned option
closes #147 closes #151 closes #153
1 parent c67a478 commit 84a1567

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed
 

‎HISTORY.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
unreleased
2+
==========
3+
4+
* Add `partitioned` option
5+
16
0.5.0 / 2022-04-11
27
==================
38

‎README.md

+12
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ The given number will be converted to an integer by rounding down. By default, n
107107
`maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
108108
so if both are set, they should point to the same date and time.
109109

110+
##### partitioned
111+
112+
Specifies the `boolean` value for the [`Partitioned` `Set-Cookie`](rfc-cutler-httpbis-partitioned-cookies)
113+
attribute. When truthy, the `Partitioned` attribute is set, otherwise it is not. By default, the
114+
`Partitioned` attribute is not set.
115+
116+
**note** This is an attribute that has not yet been fully standardized, and may change in the future.
117+
This also means many clients may ignore this attribute until they understand it.
118+
119+
More information about can be found in [the proposal](https://github.com/privacycg/CHIPS).
120+
110121
##### path
111122

112123
Specifies the value for the [`Path` `Set-Cookie` attribute][rfc-6265-5.2.4]. By default, the path
@@ -275,6 +286,7 @@ $ npm run bench
275286
- [RFC 6265: HTTP State Management Mechanism][rfc-6265]
276287
- [Same-site Cookies][rfc-6265bis-09-5.4.7]
277288

289+
[rfc-cutler-httpbis-partitioned-cookies]: https://tools.ietf.org/html/draft-cutler-httpbis-partitioned-cookies/
278290
[rfc-west-cookie-priority-00-4.1]: https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1
279291
[rfc-6265bis-09-5.4.7]: https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7
280292
[rfc-6265]: https://tools.ietf.org/html/rfc6265

‎index.js

+4
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ function serialize(name, val, options) {
172172
str += '; Secure';
173173
}
174174

175+
if (opt.partitioned) {
176+
str += '; Partitioned'
177+
}
178+
175179
if (opt.priority) {
176180
var priority = typeof opt.priority === 'string'
177181
? opt.priority.toLowerCase()

‎test/serialize.js

+14
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,20 @@ describe('cookie.serialize(name, value, options)', function () {
113113
})
114114
})
115115

116+
describe('with "partitioned" option', function () {
117+
it('should include partitioned flag when true', function () {
118+
assert.equal(cookie.serialize('foo', 'bar', { partitioned: true }), 'foo=bar; Partitioned')
119+
})
120+
121+
it('should not include partitioned flag when false', function () {
122+
assert.equal(cookie.serialize('foo', 'bar', { partitioned: false }), 'foo=bar')
123+
})
124+
125+
it('should not include partitioned flag when not defined', function () {
126+
assert.equal(cookie.serialize('foo', 'bar', {}), 'foo=bar')
127+
})
128+
})
129+
116130
describe('with "path" option', function () {
117131
it('should serialize path', function () {
118132
assert.equal(cookie.serialize('foo', 'bar', { path: '/' }), 'foo=bar; Path=/')

0 commit comments

Comments
 (0)
Please sign in to comment.