Skip to content

chore(clerk-js): Improve error handling of passkeys#3025

Merged
panteliselef merged 8 commits intomainfrom
elef/sdk-1533-error-handling-for-passkey-retrieval
Mar 25, 2024
Merged

chore(clerk-js): Improve error handling of passkeys#3025
panteliselef merged 8 commits intomainfrom
elef/sdk-1533-error-handling-for-passkey-retrieval

Conversation

@panteliselef
Copy link
Copy Markdown
Contributor

@panteliselef panteliselef commented Mar 21, 2024

Description

This PR improves the error codes from runtime errors that will be thrown when a creation or retrieval of a passkey fails.

Previous error when user exists from passkey selection.

Screenshot 2024-03-21 at 2 37 30 PM
Screenshot 2024-03-21 at 4 26 46 PM

After this PR

Screenshot 2024-03-21 at 2 37 16 PM

Screenshot 2024-03-21 at 2 37 05 PM
Screenshot 2024-03-21 at 4 26 27 PM

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:

@panteliselef panteliselef requested a review from a team March 21, 2024 13:03
@panteliselef panteliselef self-assigned this Mar 21, 2024
@panteliselef panteliselef requested review from dimkl and removed request for a team March 21, 2024 13:03
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 21, 2024

🦋 Changeset detected

Latest commit: 29b05e3

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

This PR includes changesets to release 13 packages
Name Type
@clerk/localizations Minor
@clerk/clerk-js Minor
@clerk/types Minor
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/backend Patch
@clerk/fastify Patch
gatsby-plugin-clerk Patch
@clerk/nextjs Patch
@clerk/clerk-react Patch
@clerk/remix Patch
@clerk/clerk-sdk-node Patch
@clerk/themes 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

@panteliselef panteliselef requested review from a team and removed request for dimkl March 21, 2024 13:04
@panteliselef panteliselef marked this pull request as draft March 21, 2024 13:28
@panteliselef panteliselef marked this pull request as ready for review March 21, 2024 14:39
@panteliselef panteliselef changed the title chore(clerk-js): Improve error handling in retrieval of passkeys chore(clerk-js): Improve error handling of passkeys Mar 21, 2024
@panteliselef
Copy link
Copy Markdown
Contributor Author

!snapshot

@clerk-cookie
Copy link
Copy Markdown
Collaborator

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

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

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

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/clerk-expo

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

@clerk/fastify

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

gatsby-plugin-clerk

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/clerk-react

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

@clerk/remix

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

@clerk/clerk-sdk-node

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

@clerk/shared

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

@clerk/themes

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

@clerk/types

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

Comment thread packages/clerk-js/src/core/errors.ts Outdated
Comment thread packages/clerk-js/src/core/resources/Passkey.ts Outdated
// Generic
| 'passkey_not_supported'
| 'passkeys_pa_not_supported'
| 'passkey_invalid_rpID_or_domain'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should this be all lower case? or is it aligning with a code sent back from FAPI?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

FAPI also uses a lower case / snake case format. But these have nothing to do with FAPI as they will be thrown when something goes wrong when interacting with WebAuthN which is client only.

Comment thread packages/localizations/src/en-US.ts Outdated
@panteliselef panteliselef requested a review from brkalow March 21, 2024 19:07
Comment on lines +118 to +120
throw new Error(
`${errorPrefix} Missing publicKey. When calling 'navigator.credentials.${name}()' it is required to pass a publicKey object.`,
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

❓ Maybe we should be more descriptive of what the publicKey refers to?

Copy link
Copy Markdown
Contributor

@LekoArts LekoArts Mar 22, 2024

Choose a reason for hiding this comment

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

Where this function is used @panteliselef wrote // This should never occur, just a fail-safe so I'm assuming this is for handling edge cases. If this would be surfaced to the user a CTA to contact us might be helpful since we ourselves don't think they'll ever get into that state

@@ -0,0 +1,2 @@
---
Copy link
Copy Markdown
Contributor

@LekoArts LekoArts Mar 22, 2024

Choose a reason for hiding this comment

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

You'll probably want to add a changeset

@panteliselef panteliselef enabled auto-merge (squash) March 25, 2024 12:06
@panteliselef panteliselef merged commit afec179 into main Mar 25, 2024
@panteliselef panteliselef deleted the elef/sdk-1533-error-handling-for-passkey-retrieval branch March 25, 2024 12:17
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.

5 participants