feat(clerk-js): Adds experimental support for registering a passkey - #2884
Conversation
🦋 Changeset detectedLatest commit: 50a04e6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
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 |
| /** | ||
| * Custom error class for representing Clerk runtime errors. | ||
| * | ||
| * @class ClerkRuntimeError | ||
| * @example | ||
| * throw new ClerkRuntimeError('An error occurred', { code: 'password_invalid' }); | ||
| */ | ||
| export class ClerkWebAuthnError extends ClerkRuntimeError { | ||
| /** | ||
| * A unique code identifying the error, used for localization | ||
| * | ||
| * @type {string} | ||
| * @memberof ClerkRuntimeError | ||
| */ | ||
| code: ClerkWebAuthnErrorCode; | ||
|
|
||
| constructor(message: string, { code }: { code: ClerkWebAuthnErrorCode }) { | ||
| super(message, { code }); | ||
|
|
||
| Object.setPrototypeOf(this, ClerkWebAuthnError.prototype); | ||
|
|
||
| this.code = code; | ||
| this.message = message; | ||
| this.clerkRuntimeError = true; | ||
| } | ||
| } |
There was a problem hiding this comment.
This could be removed, my goal was to improve typesafety for error codes regarding passkeys
| } | ||
|
|
||
| export interface PublicKeyCredentialCreationOptionsJSON { | ||
| rp: PublicKeyCredentialRpEntity; |
There was a problem hiding this comment.
This type comes from typescript, do you think we should ship our own ?
There was a problem hiding this comment.
I'd prefer keeping it as-is so when someone searches for it on Google they'll get relevant results. No reason to alias something if we don't add value
There was a problem hiding this comment.
I'm worrying about types changing in a feature version of typescript. Not sure how often they update their "web api" types.
|
|
||
| export class ClerkWebAuthnError extends ClerkRuntimeError { | ||
| /** | ||
| * A unique code identifying the error, used for localization |
There was a problem hiding this comment.
Nit: You updated the desc in the other file, since you seemed to have copied this over you'd need to adjust this, too 😅
- Remove prepare verification step - Update environment to handle passkey attribute
Description
Any TODO comments will be handled in follow up PRs that address those tickets.
For further information about the feature please check out internal documentation.
Includes tests for transforming payloads and responses from Base64Url strings to buffers and vice versa.
Checklist
npm testruns as expected.npm run buildruns as expected.Type of change