Skip to content

feat(backend): Signal support for handshake nonce #5905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

jacekradko
Copy link
Member

@jacekradko jacekradko commented May 12, 2025

Description

Send query string param to signal support for handshake nonce flow from current version of @clerk/backend

Related: SDKI-979

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Added a new query parameter to handshake URLs to indicate support for handshake nonce during redirects.
  • Tests

    • Enhanced tests to verify the presence of the new handshake format parameter in generated URLs.

Copy link

vercel bot commented May 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 18, 2025 2:49pm

Copy link

changeset-bot bot commented May 12, 2025

🦋 Changeset detected

Latest commit: ef10516

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@clerk/backend Minor
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/remix Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jacekradko jacekradko requested a review from Copilot May 12, 2025 14:43
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for signaling the handshake nonce flow by including a query parameter.

  • In handshake.ts, the query parameter SupportsHandshakeNonce is appended to the URL.
  • In handshake.test.ts, corresponding tests ensure the parameter is correctly set in both regular and development modes.
  • In constants.ts, a new constant for SupportsHandshakeNonce is added to support the new query parameter.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/backend/src/tokens/handshake.ts Appends a new query parameter for handshake nonce support.
packages/backend/src/tokens/tests/handshake.test.ts Adds tests to validate the presence of the new query parameter.
packages/backend/src/constants.ts Introduces the SupportsHandshakeNonce constant to hold the parameter key.

@jfoshee
Copy link

jfoshee commented May 12, 2025

LGTM. So to be doubly clear: this indicates "nonce support", but FAPI still has the option to return 'optimized' payload in initial response, right?
I'll work on API definition update and FAPI implementation.

@jacekradko
Copy link
Member Author

@jfoshee Yeah, this is just to signal to the API that it COULD send a handshake nonce

@jacekradko jacekradko requested a review from a team May 12, 2025 20:27
Copy link

pkg-pr-new bot commented May 15, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@5905

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@5905

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@5905

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@5905

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@5905

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@5905

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@5905

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@5905

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@5905

@clerk/express

npm i https://pkg.pr.new/@clerk/express@5905

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@5905

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@5905

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@5905

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@5905

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@5905

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@5905

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@5905

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@5905

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@5905

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@5905

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@5905

@clerk/types

npm i https://pkg.pr.new/@clerk/types@5905

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@5905

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@5905

commit: ef10516

@jacekradko jacekradko requested a review from aeliox as a code owner June 18, 2025 14:48
Copy link
Contributor

coderabbitai bot commented Jun 18, 2025

📝 Walkthrough

Walkthrough

This change introduces a new query parameter, HandshakeFormat, with the value 'nonce', to the handshake URL generated by the buildRedirectToHandshake method in the HandshakeService class. The constant for this parameter is added to the QueryParameters object in constants.ts. Corresponding tests are updated to ensure that all handshake URLs include the HandshakeFormat=nonce parameter. Additionally, a changeset is added to document this minor update to the @clerk/backend package.

Assessment against linked issues

Objective Addressed Explanation
Send a shorter ID (nonce) in the handshake flow instead of the entire encoded payload (SDKI-979) The code adds a HandshakeFormat=nonce parameter, but it is unclear if the nonce-based flow is fully implemented.
Indicate handshake version/format support in the handshake redirect (SDKI-979)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes were found based on the objectives from the linked issues.

Possibly related PRs


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
packages/backend/src/constants.ts (1)

37-39: Query-param key format is extremely generic – consider a Clerk-specific prefix

Using the literal string "format" for HandshakeFormat breaks the naming pattern of the surrounding query parameters (all are Clerk-prefixed or otherwise very explicit) and could easily collide with existing parameters added by reverse proxies or middleware.
A more self-describing key such as handshake_format or even re-using the earlier suggestion handshake_mode would avoid ambiguity while remaining backward-compatible (the API can accept both).

-  HandshakeFormat: 'format',
+  HandshakeFormat: 'handshake_format',

If you agree, remember to update buildRedirectToHandshake and the tests accordingly.

🧹 Nitpick comments (1)
.changeset/six-ears-wash.md (1)

1-6: Consider mentioning the actual query-param name

For clarity to consumers reading the changelog, you might add something like “…by appending format=nonce to the handshake URL” so they immediately know what to look for.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 125255b and ef10516.

📒 Files selected for processing (4)
  • .changeset/six-ears-wash.md (1 hunks)
  • packages/backend/src/constants.ts (1 hunks)
  • packages/backend/src/tokens/__tests__/handshake.test.ts (2 hunks)
  • packages/backend/src/tokens/handshake.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
packages/backend/src/tokens/handshake.ts (1)

148-153: Unconditional inclusion is fine, but confirm API fallback

Appending the new parameter on every redirect is straightforward and keeps the client logic simple.
Please double-check that the backend will gracefully ignore format=nonce when it decides to return a classic token‐based handshake so that older environments remain functional.

packages/backend/src/tokens/__tests__/handshake.test.ts (2)

154-160: Good assertion for the new param

The extra expectation ensures we never regress on adding the nonce signal. 👍


170-173: Covers the dev-browser branch as well

Nicely catches the development-mode path; no issues spotted.

@jacekradko jacekradko changed the title feat(backend): signal support for handshake nonce feat(backend): Signal support for handshake nonce Jun 18, 2025
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.

5 participants