Skip to content

fix(backend): Fix getToken() from getAuth() return value in v5 - #2535

Closed
dimkl wants to merge 1 commit into
mainfrom
fix-get-auth-get-token
Closed

fix(backend): Fix getToken() from getAuth() return value in v5#2535
dimkl wants to merge 1 commit into
mainfrom
fix-get-auth-get-token

Conversation

@dimkl

@dimkl dimkl commented Jan 10, 2024

Copy link
Copy Markdown
Contributor

Description

Change SessionApi.getToken() to return consistent { data, errors } return value
and fix the getToken() from requestState to have the same return behavior as v4
(return Promise or throw error).
This change will fix issues in @clerk/nextjs / @clerk/remix with getToken():

Example:

import { getAuth } from '@clerk/remix';

const { getToken } = await getAuth(...);
const jwtString = await getToken(...);

Also a breaking change in the clerkClient.sessions.getToken() was introduced as the return value was changed. To keep the existing behavior use the following:

const { data, errors } = await clerkClient.sessions.getToken(...);
if (errors) {
  throw errors;
}
const jwt = data.jwt;

Checklist

  • npm test runs as expected.
  • npm run 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:

Packages affected

  • @clerk/backend
  • @clerk/chrome-extension
  • @clerk/clerk-js
  • @clerk/clerk-expo
  • @clerk/fastify
  • gatsby-plugin-clerk
  • @clerk/localizations
  • @clerk/nextjs
  • @clerk/clerk-react
  • @clerk/remix
  • @clerk/clerk-sdk-node
  • @clerk/shared
  • @clerk/themes
  • @clerk/types
  • build/tooling/chore

@dimkl dimkl added bug Something isn't working v5-release labels Jan 10, 2024
@dimkl dimkl self-assigned this Jan 10, 2024
@changeset-bot

changeset-bot Bot commented Jan 10, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: be47fb1

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

This PR includes changesets to release 7 packages
Name Type
@clerk/backend Major
@clerk/fastify Patch
gatsby-plugin-clerk Patch
@clerk/nextjs Patch
@clerk/remix Patch
@clerk/clerk-sdk-node Patch
@clerk/elements 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

@dimkl
dimkl marked this pull request as draft January 10, 2024 10:58
Comment thread packages/backend/src/tokens/authObjects.ts
@nikosdouvlis

Copy link
Copy Markdown
Member

!snapshot

@clerk-cookie

Copy link
Copy Markdown
Collaborator

Hey @nikosdouvlis - the snapshot version command generated the following package versions:

Package Version
@clerk/backend 1.0.1-snapshot.v298b880
@clerk/chrome-extension 1.0.1-snapshot.v298b880
@clerk/clerk-js 5.0.1-snapshot.v298b880
@clerk/elements 0.0.3-snapshot.v298b880
@clerk/clerk-expo 1.0.1-snapshot.v298b880
@clerk/fastify 1.0.1-snapshot.v298b880
gatsby-plugin-clerk 5.0.1-snapshot.v298b880
@clerk/localizations 2.0.1-snapshot.v298b880
@clerk/nextjs 5.0.1-snapshot.v298b880
@clerk/clerk-react 5.0.1-snapshot.v298b880
@clerk/remix 4.0.1-snapshot.v298b880
@clerk/clerk-sdk-node 5.0.1-snapshot.v298b880
@clerk/shared 2.0.1-snapshot.v298b880
@clerk/themes 2.0.1-snapshot.v298b880
@clerk/types 4.0.1-snapshot.v298b880

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/backend

npm i @clerk/backend@1.0.1-snapshot.v298b880 --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@1.0.1-snapshot.v298b880 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.0.1-snapshot.v298b880 --save-exact

@clerk/elements

npm i @clerk/elements@0.0.3-snapshot.v298b880 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@1.0.1-snapshot.v298b880 --save-exact

@clerk/fastify

npm i @clerk/fastify@1.0.1-snapshot.v298b880 --save-exact

gatsby-plugin-clerk

npm i gatsby-plugin-clerk@5.0.1-snapshot.v298b880 --save-exact

@clerk/localizations

npm i @clerk/localizations@2.0.1-snapshot.v298b880 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@5.0.1-snapshot.v298b880 --save-exact

@clerk/clerk-react

npm i @clerk/clerk-react@5.0.1-snapshot.v298b880 --save-exact

@clerk/remix

npm i @clerk/remix@4.0.1-snapshot.v298b880 --save-exact

@clerk/clerk-sdk-node

npm i @clerk/clerk-sdk-node@5.0.1-snapshot.v298b880 --save-exact

@clerk/shared

npm i @clerk/shared@2.0.1-snapshot.v298b880 --save-exact

@clerk/themes

npm i @clerk/themes@2.0.1-snapshot.v298b880 --save-exact

@clerk/types

npm i @clerk/types@4.0.1-snapshot.v298b880 --save-exact

@dimkl
dimkl force-pushed the fix-get-auth-get-token branch from 298b880 to be47fb1 Compare January 10, 2024 13:12
@dimkl dimkl closed this Jan 10, 2024
@dimkl
dimkl deleted the fix-get-auth-get-token branch January 10, 2024 15:32
@dimkl

dimkl commented Jan 10, 2024

Copy link
Copy Markdown
Contributor Author

Closed in favor of #2539

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

Labels

backend bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants