Repository navigation
feat: enhance passkey error handling by utilizing a dedicated error message function #65
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { passkeyErrorMessage } from './passkeyError'; | ||
|
|
||
| const t = (key: string) => `t:${key}`; | ||
|
|
||
| describe('passkeyErrorMessage', () => { | ||
| it('says nothing without an error', () => { | ||
| expect(passkeyErrorMessage(null, t)).toBeNull(); | ||
| expect(passkeyErrorMessage(undefined, t)).toBeNull(); | ||
| }); | ||
|
|
||
| it('says nothing when the user closed the prompt', () => { | ||
| expect( | ||
| passkeyErrorMessage( | ||
| { name: 'UserCancelledError', message: 'Cancelled' }, | ||
| t, | ||
| ), | ||
| ).toBeNull(); | ||
| }); | ||
|
|
||
| it('points to another device when this one already has a passkey', () => { | ||
| expect( | ||
| passkeyErrorMessage( | ||
| { | ||
| name: 'PasskeyExistsError', | ||
| message: 'This device is already registered as a passkey.', | ||
| }, | ||
| t, | ||
| ), | ||
| ).toBe( | ||
| 't:This device already has a passkey. Add one from another device or a password manager.', | ||
| ); | ||
| }); | ||
|
|
||
| it('passes any other error through', () => { | ||
| expect( | ||
| passkeyErrorMessage({ name: 'Error', message: 'Server error' }, t), | ||
| ).toBe('Server error'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /** | ||
| * What to tell the user when adding a passkey fails, or null to say nothing. | ||
| * | ||
| * Closing the browser's own prompt is a choice, not something to report. The | ||
| * package's "already registered" message is English only and says nothing about | ||
| * what to do next: the browser refuses a second passkey on the same authenticator. | ||
| */ | ||
| export function passkeyErrorMessage( | ||
| error: { name: string; message: string } | null | undefined, | ||
| t: (key: string) => string, | ||
| ): string | null { | ||
| if (!error || error.name === 'UserCancelledError') { | ||
| return null; | ||
| } | ||
|
|
||
| if (error.name === 'PasskeyExistsError') { | ||
| return t( | ||
| 'This device already has a passkey. Add one from another device or a password manager.', | ||
| ); | ||
| } | ||
|
|
||
| return error.message; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: saucebase-dev/auth
Length of output: 1254
Script executed:
Repository: saucebase-dev/auth
Length of output: 41550
Script executed:
Repository: saucebase-dev/auth
Length of output: 41480
Script executed:
Repository: saucebase-dev/auth
Length of output: 32391
Keep
EmptyStateavailable in existing installations.The v2.7.1 React and Vue barrels do not export
EmptyState; v2.8.0 adds the export. The module install and setup flow updates Composer and applies patches, but does not refresh the application's copied core UI. Therefore, an existing installation can still have the v2.7.x barrel after this module upgrades the dependency, and both frontend builds can fail.Restore the previous local empty-state markup in both framework pages, or add an upgrade migration that adds the component and barrel exports without overwriting user-owned UI files.