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

@dimkldimkl 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 }=awaitgetAuth(...);constjwtString=awaitgetToken(...);

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 }=awaitclerkClient.sessions.getToken(...);if(errors){throwerrors;}constjwt=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

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

changeset-botBot 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
NameType
@clerk/backendMajor
@clerk/fastifyPatch
gatsby-plugin-clerkPatch
@clerk/nextjsPatch
@clerk/remixPatch
@clerk/clerk-sdk-nodePatch
@clerk/elementsPatch

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 threadpackages/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:

PackageVersion
@clerk/backend1.0.1-snapshot.v298b880
@clerk/chrome-extension1.0.1-snapshot.v298b880
@clerk/clerk-js5.0.1-snapshot.v298b880
@clerk/elements0.0.3-snapshot.v298b880
@clerk/clerk-expo1.0.1-snapshot.v298b880
@clerk/fastify1.0.1-snapshot.v298b880
gatsby-plugin-clerk5.0.1-snapshot.v298b880
@clerk/localizations2.0.1-snapshot.v298b880
@clerk/nextjs5.0.1-snapshot.v298b880
@clerk/clerk-react5.0.1-snapshot.v298b880
@clerk/remix4.0.1-snapshot.v298b880
@clerk/clerk-sdk-node5.0.1-snapshot.v298b880
@clerk/shared2.0.1-snapshot.v298b880
@clerk/themes2.0.1-snapshot.v298b880
@clerk/types4.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
dimklforce-pushed the fix-get-auth-get-token branch from 298b880 to be47fb1CompareJanuary 10, 2024 13:12
@dimkldimkl closed this Jan 10, 2024
@dimkl
dimkl deleted the fix-get-auth-get-token branch January 10, 2024 15:32
@dimkl

Copy link
Copy Markdown
ContributorAuthor

Closed in favor of #2539

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

Labels

backendbugSomething isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@dimkl@nikosdouvlis@clerk-cookie@panteliselef