Skip to content

feat: share and enforce SameSiteLevel types - #640

Open
Shubham-Padkonde wants to merge 4 commits into
salesforce:masterfrom
Shubham-Padkonde:feat/same-site-level-type
Open

Shubham-Padkonde wants to merge 4 commits into
salesforce:masterfrom
Shubham-Padkonde:feat/same-site-level-type

Conversation

@Shubham-Padkonde

@Shubham-Padkonde Shubham-Padkonde commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Implements #583, part of #581.

new Cookie({ sameSite: 'invalid' }) currently compiles, while request context options already accept only the three valid values. Export SameSiteLevel = 'strict' | 'lax' | 'none' and use it for Cookie.sameSite, CreateCookieOptions.sameSite, and both request context options.

This intentionally narrows the public TypeScript API as proposed in the issue. Callers using arbitrary string values will need to narrow them first. Runtime parsing, case normalization, and legacy JSON deserialization remain unchanged; the existing invalid-input behavior is preserved and tested. In particular, checkSameSiteContext retains runtime validation for JavaScript callers.

The new type assertions run in the existing _lint:types CI task, alongside the package entrypoint checks. API reports and generated documentation are updated.

Validation:

  • Both invalid-value type assertions fail as unused before the fix and pass after it. The assertions run through the shared _lint:types task.
  • Following the October 26 merge with current master, all 966 runtime tests pass with npm test -- run --testTimeout=20000. No timeout setting was changed in the repository.
  • Build, ESLint, formatting, API report generation, documentation generation, TypeScript checks, and package entrypoint validation pass.

Prepared with OpenAI Codex assistance.

@colincasey colincasey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Shubham-Padkonde this PR will require a bit of coordination + discussion with the other maintainers since it introduces changes to the public API.

Comment thread package.json Resolved
Comment thread tsconfig.type-tests.json Resolved
@colincasey colincasey added this to the v7 milestone Oct 15, 2026
@wjhsf
wjhsf requested a review from colincasey October 23, 2026 17:48

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants