Skip to content
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

feat(backend): Set cookies from the refresh token flow #4884

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

Conversation

BRKalow
Copy link
Member

@BRKalow BRKalow commented Jan 13, 2025

Description

Supports the format=cookies parameter for the session refresh endpoint. When this parameter is passed, the API will return an array of set-cookie header values to be passed along with the response.

SDKI-832

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:

Copy link

changeset-bot bot commented Jan 13, 2025

🦋 Changeset detected

Latest commit: 19d2ada

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

This PR includes changesets to release 10 packages
Name Type
@clerk/backend Minor
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/remix Patch
@clerk/tanstack-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

Copy link

vercel bot commented Jan 13, 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 Jan 14, 2025 3:58am

return HttpResponse.json(mockJwks);
}),
);
describe('refreshToken', async () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

I moved these tests into a separate describe block, consider looking at the diff without whitespace to see the actual changes: https://github.com/clerk/javascript/pull/4884/files?w=1

@BRKalow BRKalow marked this pull request as ready for review January 14, 2025 03:58
@BRKalow BRKalow requested a review from a team January 14, 2025 03:58
@@ -64,12 +67,17 @@ export class SessionAPI extends AbstractAPI {
});
}

public async refreshSession(sessionId: string, params: RefreshTokenParams) {
public async refreshSession(sessionId: string, params: RefreshTokenParams & { format: 'token ' }): Promise<Token>;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public async refreshSession(sessionId: string, params: RefreshTokenParams & { format: 'token ' }): Promise<Token>;
public async refreshSession(sessionId: string, params: RefreshTokenParams & { format: 'token' }): Promise<Token>;

@@ -273,14 +273,16 @@ ${error.getFullMessage()}`,

try {
// Perform the actual token refresh.
const tokenResponse = await options.apiClient.sessions.refreshSession(decodeResult.payload.sid, {
const response = await options.apiClient.sessions.refreshSession(decodeResult.payload.sid, {
format: 'cookie',
Copy link
Member

Choose a reason for hiding this comment

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

Do we want this to be set for every call ? Could this be configured and passed down from authenticateRequest ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants