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

chore(*): Improve @clerk/backend DX [Part 6 - token and jwt utils return values] #2377

Merged
merged 3 commits into from Dec 15, 2023

Conversation

dimkl
Copy link
Member

@dimkl dimkl commented Dec 15, 2023

Description

Change return values of signJwt, hasValidSignature, decodeJwt, verifyJwt, verifyToken
to return { data, error }. Example of keeping the same behaviour using those utilies:

import { signJwt, hasValidSignature, decodeJwt, verifyJwt } from '@clerk/backend/jwt';
import { verifyToken } from '@clerk/backend/jwt';

const { data, error } = await signJwt(...)
if (error) throw error;

const { data, error } = await hasValidSignature(...)
if (error) throw error;

const { data, error } = decodeJwt(...)
if (error) throw error;

const { data, error } = await verifyJwt(...)
if (error) throw error;

const { data, error } = await verifyToken(...)
if (error) throw error;

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

Copy link

changeset-bot bot commented Dec 15, 2023

🦋 Changeset detected

Latest commit: 23127d5

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 Major
@clerk/types Major
@clerk/nextjs Major
@clerk/fastify Patch
gatsby-plugin-clerk Patch
@clerk/remix Patch
@clerk/clerk-sdk-node Patch
@clerk/clerk-js Patch
@clerk/clerk-expo Patch
@clerk/clerk-react Patch
@clerk/chrome-extension 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

packages/backend/src/jwt/signJwt.ts Outdated Show resolved Hide resolved
packages/backend/src/jwt/verifyJwt.ts Outdated Show resolved Hide resolved
packages/types/src/utils.ts Outdated Show resolved Hide resolved
@dimkl dimkl force-pushed the sdk-974-improve-dx-backend-p6-verify-token branch 2 times, most recently from 156f4d4 to 9e9e0d1 Compare December 15, 2023 19:01
@dimkl dimkl force-pushed the sdk-974-improve-dx-backend-p6-verify-token branch from 9e9e0d1 to 88532d1 Compare December 15, 2023 19:18
@dimkl dimkl force-pushed the sdk-974-improve-dx-backend-p6-verify-token branch from 88532d1 to 23127d5 Compare December 15, 2023 19:27
@SokratisVidros SokratisVidros merged commit a9fe242 into main Dec 15, 2023
6 of 7 checks passed
@SokratisVidros SokratisVidros deleted the sdk-974-improve-dx-backend-p6-verify-token branch December 15, 2023 21:02
octoper pushed a commit that referenced this pull request Dec 16, 2023
…urn values] (#2377)

* chore(backend,types): Introduce ReturnWithError and use it as `verifyToken` return value

* chore(backend,types): Make /jwt subpath utilies to return `ReturnWithError` type

* chore(backend,types): Rename and move `ReturnWithError` move types to backend `JwtReturnType`
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.

None yet

3 participants