Skip to content

Conversation

@leandrohlsilva
Copy link
Contributor

Why is this PR necessary?

To support Chrome's CHIPS initiative
https://developers.google.com/privacy-sandbox/3pcd/chips

Tests

statehood feature/cookie-partition % npm run test

> @hapi/[email protected] test
> lab -a @hapi/code -t 100 -L



  ..................................................
  ..................................................
  ..........

110 tests complete
Test duration: 48 ms
Assertions count: 162 (verbosity: 1.47)
Leaks: No issues
Coverage: 100.00%
Lint: No issues

Copy link

@kanongil kanongil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this very nice PR.

The only minor implementation issue, is that I would prefer the options validation to fail, if isPartitioned: true without isSecure: true.

However, I'm not sure this is a suitable feature to implement, given the current state (expired) of the spec. Currently it is a Google-only feature, where support could potentially be dropped.

The main problem with not adding it, is that there is no way for users to add this property manually. As such, a better solution might be to add support for custom names and name/value pairs.

@kanongil
Copy link

Additional properties could be specified using an object:

{
    ,
    set: {
        Partitioned: true,
        OtherName: 'TheValue'
    }
}

@leandrohlsilva
Copy link
Contributor Author

Thanks for this very nice PR.

The only minor implementation issue, is that I would prefer the options validation to fail, if isPartitioned: true without isSecure: true.

However, I'm not sure this is a suitable feature to implement, given the current state (expired) of the spec. Currently it is a Google-only feature, where support could potentially be dropped.

The main problem with not adding it, is that there is no way for users to add this property manually. As such, a better solution might be to add support for custom names and name/value pairs.

Hi @kanongil,
thank you for replying.
As suggested, I've made Partition conditional to isSecure and SameSite=None.

As for the spec being expired, I don't know if this expiration date is being taken seriously as Google is rolling out this new policy already: https://developers.google.com/privacy-sandbox/3pcd
Currently, 1% of our Chrome users are having trouble using our systems, and soon to be 100% of them in Q3 2024.

I like the additional properties suggestion, but I wonder if it's necessary now as I'm not aware of other properties being proposed.

@leandrohlsilva
Copy link
Contributor Author

@kanongil , so what are the next steps to move this PR forward?
Thanks

@leandrohlsilva
Copy link
Contributor Author

Hi @kanongil
How can we make this PR ready to move forward?
I believe CHIPS support is essential to the well-functioning of Hapi in the future, so I'm following up with you.

Thank you

@legrego
Copy link

legrego commented May 13, 2024

I'm also interested in having support for the Partitioned attribute. What are our next steps for this, @kanongil?

@wzrdtales
Copy link

What is left to merge this? Hapijs is not capable delivering api's towards chrome users anymore

@wzrdtales
Copy link

/cc @Marsup @kanongil

Copy link

@kanongil kanongil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, other than my inline comment.

lib/index.js Outdated
segment = `${segment}; SameSite=${definition.isSameSite}`;
}

if (definition.isPartitioned && definition.isSecure && definition.isSameSite === 'None') {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silently ignoring an option is not how hapi usually works. I would much rather see it throw Boom.badImplementation() if it is not a valid combination.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @kanongil , thank you for reviewing.
I've applied your suggestion and updated tests.
I wasn't able to run tests though (I'm unable to run tests on master either).

I'll need your help to run tests before merging.

statehood feature/cookie-partition % npm run test

> @hapi/[email protected] test
> lab -a @hapi/code -t 100 -L

/Users/leandro/Projects/statehood/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2156
                const formattedValue = JSON.stringify(error.data);
                                            ^

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that the CI pipeline failed.
Not being able to run my tests locally is blocking me.

What I'm doing:

node -v
# v20.11.0
npm -v
# 10.2.4
git checkout master
rm -rf node_modules && rm package-lock.json
npm i
npm run test

Any thoughts on what I'm doing wrong?

@leandrohlsilva leandrohlsilva force-pushed the feature/cookie-partition branch from dd521f2 to fb986ce Compare February 26, 2025 16:40
@damusix
Copy link

damusix commented Feb 27, 2025

@leandrohlsilva tests failed

@leandrohlsilva
Copy link
Contributor Author

@leandrohlsilva tests failed

Thank you for letting me know.
I'm having a hard time running the tests locally, but I'll figure it out

@damusix
Copy link

damusix commented Feb 27, 2025

@leandrohlsilva If you're on the slack, ping one of the channels and I'll help you out

@leandrohlsilva leandrohlsilva force-pushed the feature/cookie-partition branch from fb986ce to 8678e8e Compare February 27, 2025 18:15
@leandrohlsilva
Copy link
Contributor Author

@kanongil @damusix two tests failed and I don't know why. Wondering if you'd be able to rerun the CI pipeline.
Also, I'm not able to merge the PR it seems. When would you merge it? Thank you.

@kanongil
Copy link

Don't worry about the tests. It seems to be an issue with the v23 node release line, which is tested for, but have no official support.

Merging is best handled by someone from @hapijs/tsc, who can also publish a new release.

@Marsup Marsup added the feature New functionality or improvement label Feb 28, 2025
@Marsup Marsup added this to the 8.2.0 milestone Feb 28, 2025
@Marsup Marsup merged commit 6cc769b into hapijs:master Feb 28, 2025
8 of 10 checks passed
Marsup added a commit to hapijs/hapi that referenced this pull request Mar 1, 2025
@Marsup
Copy link
Contributor

Marsup commented Mar 1, 2025

Thanks! It's released as 8.2, I've prepared a matching hapi PR to enforce that update for everyone.

Marsup added a commit to hapijs/hapi that referenced this pull request Mar 1, 2025
@leandrohlsilva leandrohlsilva deleted the feature/cookie-partition branch March 3, 2025 13:36
elena-shostak added a commit to elastic/kibana that referenced this pull request Aug 13, 2025
## Summary

Since direct option for partitioned cookie configuration has been merged
as part of hapijs/statehood#88. Cleaning up old
code.

__Closes: https://github.com/elastic/kibana/issues/188720__
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Aug 13, 2025
## Summary

Since direct option for partitioned cookie configuration has been merged
as part of hapijs/statehood#88. Cleaning up old
code.

__Closes: https://github.com/elastic/kibana/issues/188720__

(cherry picked from commit da5981e)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Aug 13, 2025
## Summary

Since direct option for partitioned cookie configuration has been merged
as part of hapijs/statehood#88. Cleaning up old
code.

__Closes: https://github.com/elastic/kibana/issues/188720__

(cherry picked from commit da5981e)
kibanamachine added a commit to elastic/kibana that referenced this pull request Aug 13, 2025
)

# Backport

This will backport the following commits from `main` to `9.1`:
- [[chore]: refactored CHIPS support configuration
(#231472)](#231472)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Elena
Shostak","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-08-13T11:00:38Z","message":"[chore]:
refactored CHIPS support configuration (#231472)\n\n## Summary\n\nSince
direct option for partitioned cookie configuration has been merged\nas
part of hapijs/statehood#88. Cleaning up
old\ncode.\n\n__Closes:
https://github.com/elastic/kibana/issues/188720__","sha":"da5981ebb938a9094fe3f8a5ef58b6114b348925","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["chore","Team:Security","release_note:skip","Feature:Security/Session
Management","backport:current-major","v9.2.0"],"title":"[chore]:
refactored CHIPS support
configuration","number":231472,"url":"https://github.com/elastic/kibana/pull/231472","mergeCommit":{"message":"[chore]:
refactored CHIPS support configuration (#231472)\n\n## Summary\n\nSince
direct option for partitioned cookie configuration has been merged\nas
part of hapijs/statehood#88. Cleaning up
old\ncode.\n\n__Closes:
https://github.com/elastic/kibana/issues/188720__","sha":"da5981ebb938a9094fe3f8a5ef58b6114b348925"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/231472","number":231472,"mergeCommit":{"message":"[chore]:
refactored CHIPS support configuration (#231472)\n\n## Summary\n\nSince
direct option for partitioned cookie configuration has been merged\nas
part of hapijs/statehood#88. Cleaning up
old\ncode.\n\n__Closes:
https://github.com/elastic/kibana/issues/188720__","sha":"da5981ebb938a9094fe3f8a5ef58b6114b348925"}}]}]
BACKPORT-->

Co-authored-by: Elena Shostak <[email protected]>
kibanamachine added a commit to elastic/kibana that referenced this pull request Aug 13, 2025
)

# Backport

This will backport the following commits from `main` to `9.0`:
- [[chore]: refactored CHIPS support configuration
(#231472)](#231472)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Elena
Shostak","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-08-13T11:00:38Z","message":"[chore]:
refactored CHIPS support configuration (#231472)\n\n## Summary\n\nSince
direct option for partitioned cookie configuration has been merged\nas
part of hapijs/statehood#88. Cleaning up
old\ncode.\n\n__Closes:
https://github.com/elastic/kibana/issues/188720__","sha":"da5981ebb938a9094fe3f8a5ef58b6114b348925","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["chore","Team:Security","release_note:skip","Feature:Security/Session
Management","backport:current-major","v9.2.0"],"title":"[chore]:
refactored CHIPS support
configuration","number":231472,"url":"https://github.com/elastic/kibana/pull/231472","mergeCommit":{"message":"[chore]:
refactored CHIPS support configuration (#231472)\n\n## Summary\n\nSince
direct option for partitioned cookie configuration has been merged\nas
part of hapijs/statehood#88. Cleaning up
old\ncode.\n\n__Closes:
https://github.com/elastic/kibana/issues/188720__","sha":"da5981ebb938a9094fe3f8a5ef58b6114b348925"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/231472","number":231472,"mergeCommit":{"message":"[chore]:
refactored CHIPS support configuration (#231472)\n\n## Summary\n\nSince
direct option for partitioned cookie configuration has been merged\nas
part of hapijs/statehood#88. Cleaning up
old\ncode.\n\n__Closes:
https://github.com/elastic/kibana/issues/188720__","sha":"da5981ebb938a9094fe3f8a5ef58b6114b348925"}}]}]
BACKPORT-->

Co-authored-by: Elena Shostak <[email protected]>
fkanout pushed a commit to fkanout/kibana that referenced this pull request Aug 14, 2025
## Summary

Since direct option for partitioned cookie configuration has been merged
as part of hapijs/statehood#88. Cleaning up old
code.

__Closes: https://github.com/elastic/kibana/issues/188720__
NicholasPeretti pushed a commit to NicholasPeretti/kibana that referenced this pull request Aug 18, 2025
## Summary

Since direct option for partitioned cookie configuration has been merged
as part of hapijs/statehood#88. Cleaning up old
code.

__Closes: https://github.com/elastic/kibana/issues/188720__
paulinashakirova pushed a commit to paulinashakirova/kibana that referenced this pull request Aug 26, 2025
## Summary

Since direct option for partitioned cookie configuration has been merged
as part of hapijs/statehood#88. Cleaning up old
code.

__Closes: https://github.com/elastic/kibana/issues/188720__
qn895 pushed a commit to qn895/kibana that referenced this pull request Aug 26, 2025
## Summary

Since direct option for partitioned cookie configuration has been merged
as part of hapijs/statehood#88. Cleaning up old
code.

__Closes: https://github.com/elastic/kibana/issues/188720__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New functionality or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants