Skip to content

feat(clerk-js): Adds experimental support for registering a passkey - #2884

Merged
panteliselef merged 9 commits into
mainfrom
elef/SDK-1399-user-register-passkey
Mar 4, 2024
Merged

feat(clerk-js): Adds experimental support for registering a passkey#2884
panteliselef merged 9 commits into
mainfrom
elef/SDK-1399-user-register-passkey

Conversation

@panteliselef

@panteliselef panteliselef commented Feb 28, 2024

Copy link
Copy Markdown
Contributor

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

@changeset-bot

changeset-bot Bot commented Feb 28, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 50a04e6

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

This PR includes changesets to release 11 packages
Name Type
@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

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 marked this pull request as ready for review February 28, 2024 13:04
Comment thread packages/clerk-js/src/utils/passkeys.ts
Comment thread packages/clerk-js/src/core/resources/Passkey.ts
Comment thread packages/clerk-js/src/core/resources/Passkey.ts Outdated
@panteliselef panteliselef self-assigned this Feb 28, 2024
Comment thread packages/clerk-js/src/utils/passkeys.ts Outdated
Comment on lines +152 to +177
/**
* 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;
}
}

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.

This could be removed, my goal was to improve typesafety for error codes regarding passkeys

}

export interface PublicKeyCredentialCreationOptionsJSON {
rp: PublicKeyCredentialRpEntity;

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.

This type comes from typescript, do you think we should ship our own ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

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.

I'm worrying about types changing in a feature version of typescript. Not sure how often they update their "web api" types.

@LekoArts LekoArts left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Comment thread packages/clerk-js/src/utils/passkeys.ts Outdated

export class ClerkWebAuthnError extends ClerkRuntimeError {
/**
* A unique code identifying the error, used for localization

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
@panteliselef
panteliselef added this pull request to the merge queue Mar 4, 2024
Merged via the queue into main with commit fafa76f Mar 4, 2024
@panteliselef
panteliselef deleted the elef/SDK-1399-user-register-passkey branch March 4, 2024 11:25
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.

4 participants