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 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/six-ears-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/backend': minor
---

When redirecting for a handshake to FAPI, send signal that current version of @clerk/backend supports the handshake nonce
1 change: 1 addition & 0 deletions packages/backend/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const QueryParameters = {
LegacyDevBrowser: '__dev_session',
HandshakeReason: '__clerk_hs_reason',
HandshakeNonce: Cookies.HandshakeNonce,
HandshakeFormat: 'format',
} as const;

const Headers = {
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/tokens/__tests__/handshake.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ describe('HandshakeService', () => {
expect(url.searchParams.get('redirect_url')).toBe('https://example.com/');
expect(url.searchParams.get(constants.QueryParameters.SuffixedCookies)).toBe('true');
expect(url.searchParams.get(constants.QueryParameters.HandshakeReason)).toBe('test-reason');
expect(url.searchParams.get(constants.QueryParameters.HandshakeFormat)).toBe('nonce');
});

it('should include dev browser token in development mode', () => {
Expand All @@ -168,6 +169,7 @@ describe('HandshakeService', () => {
const url = new URL(location);

expect(url.searchParams.get(constants.QueryParameters.DevBrowser)).toBe('dev-token');
expect(url.searchParams.get(constants.QueryParameters.HandshakeFormat)).toBe('nonce');
});

it('should throw error if clerkUrl is missing', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/tokens/handshake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export class HandshakeService {
this.authenticateContext.usesSuffixedCookies().toString(),
);
url.searchParams.append(constants.QueryParameters.HandshakeReason, reason);
url.searchParams.append(constants.QueryParameters.HandshakeFormat, 'nonce');

if (this.authenticateContext.instanceType === 'development' && this.authenticateContext.devBrowserToken) {
url.searchParams.append(constants.QueryParameters.DevBrowser, this.authenticateContext.devBrowserToken);
Expand Down
Loading