Skip to content

Conversation

panteliselef
Copy link
Member

@panteliselef panteliselef commented Aug 26, 2024

Description

This PR introduces a new UI component called UserVerification as experimental. The new UI component allows for a user to "re-enter" their credentials (1fa/2fa) which results in them being reverified.

<UserVerification/> allows developers to easily build flows where verification is required before performing a sensitive action like updating other stored credentials or an application specific action like making a bank transfer.

Unit tests have been added which should make reviewers more confident. But more will follow (maybe some e2es) before the official launch.

APIs

clerk-js

export type __experimental_UserVerificationProps = RoutingOptions & {
  afterVerification?: () => void;
  afterVerificationUrl?: string;
  level?: 'L1.firstFactor' | 'L2.secondFactor' | 'L3.multiFactor' ;
  appearance?: UserVerificationTheme;
};

__experimental_openUserVerification: (props?: __experimental_UserVerificationModalProps) => void;
__experimental_closeUserVerification: () => void;
  
__experimental_mountUserVerification: (
    targetNode: HTMLDivElement,
    props?: __experimental_UserVerificationProps,
  ) => void;
__experimental_unmountUserVerification: (targetNode: HTMLDivElement) => void;

clerk-react

import {  __experimental_UserVerification } from '@clerk/clerk-react'

<__experimental_UserVerification />

2fa flow (the default)

default.mov

1fa flow

1fa.mov

multi factor flow (the above two combined)

mfa.mov

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:

Copy link

changeset-bot bot commented Aug 26, 2024

🦋 Changeset detected

Latest commit: 0e5d8d2

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

This PR includes changesets to release 18 packages
Name Type
@clerk/localizations Minor
@clerk/chrome-extension Minor
@clerk/nextjs Minor
@clerk/clerk-react Minor
@clerk/clerk-js Minor
@clerk/types Minor
@clerk/elements Patch
@clerk/clerk-expo Patch
@clerk/remix Patch
@clerk/tanstack-start Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/clerk-sdk-node Patch
@clerk/shared Patch
@clerk/testing 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 force-pushed the elef/user-607-userverification-ui-component branch 2 times, most recently from c2a8280 to efd5e79 Compare August 26, 2024 10:35
@panteliselef panteliselef force-pushed the elef/user-607-userverification-ui-component branch from efd5e79 to ee6706a Compare August 26, 2024 11:02
@panteliselef panteliselef self-assigned this Aug 27, 2024
@panteliselef panteliselef force-pushed the elef/user-607-userverification-ui-component branch from 28a6490 to 02aea2a Compare August 27, 2024 14:11
routing: 'virtual',
}}
>
{/*TODO: Used by InvisibleRootBox, can we simplify? */}
Copy link
Member Author

Choose a reason for hiding this comment

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

For reviewers: Carried from SignIn

@panteliselef panteliselef force-pushed the elef/user-607-userverification-ui-component branch from fb4b3ea to 8cb52f6 Compare August 27, 2024 20:37
Comment on lines 8 to 14
export function useAlternativeStrategies({
filterOutFactor,
supportedFirstFactors: _supportedFirstFactors,
}: {
filterOutFactor: SignInFactor | null | undefined;
supportedFirstFactors: SignInFirstFactor[] | null | undefined;
}) {
Copy link
Member Author

Choose a reason for hiding this comment

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

For reviewers: I made this change in order to share the functionality across SignIn and UserVerification. Simply having the caller doing const { supportedFirstFactors } = useCoreSignIn(); seems like a good trade off.

Comment on lines +63 to +69
{/*<input*/}
{/* readOnly*/}
{/* id='identifier-field'*/}
{/* name='identifier'*/}
{/* value={signIn.identifier || ''}*/}
{/* style={{ display: 'none' }}*/}
{/*/>*/}
Copy link
Member Author

Choose a reason for hiding this comment

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

@chanioxaris any ideas what we can use to solve this while the user is signed in ?

Copy link
Member

Choose a reason for hiding this comment

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

We can use the existing function that picks up the identifier based on the user attributes

getHelp: {
blockButton__emailSupport: 'Email support',
content:
'If you’re experiencing difficulty signing into your account, email us and we will work with you to restore access as soon as possible.',
Copy link
Member Author

Choose a reason for hiding this comment

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

All items are the same as sign in, except this one (2/2)

Comment on lines 562 to 563
content:
'If you’re experiencing difficulty verifying your account, email us and we will work with you to restore access as soon as possible.',
Copy link
Member Author

@panteliselef panteliselef Aug 27, 2024

Choose a reason for hiding this comment

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

All items are the same as sign in, except this one (2/4)

actionText: 'Don’t have any of these?',
blockButton__backupCode: 'Use a backup code',
blockButton__emailCode: 'Email code to {{identifier}}',
blockButton__password: 'Continue with your password',
Copy link
Member Author

@panteliselef panteliselef Aug 27, 2024

Choose a reason for hiding this comment

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

All items are the same as sign in, except this one (1/4)

@panteliselef panteliselef force-pushed the elef/user-607-userverification-ui-component branch from 388258a to c0fa2c3 Compare August 27, 2024 20:42
@panteliselef panteliselef marked this pull request as ready for review August 28, 2024 09:19
@panteliselef panteliselef requested a review from a team August 28, 2024 09:19
…-component

# Conflicts:
#	packages/clerk-js/bundlewatch.config.json
#	packages/clerk-js/src/ui/components/SignIn/SignInFactorOne.tsx
#	packages/clerk-js/src/ui/components/SignIn/SignInFactorOnePasswordCard.tsx
#	packages/clerk-js/src/ui/lazyModules/components.ts
'If you’re experiencing difficulty verifying your account, email us and we will work with you to restore access as soon as possible.',
title: 'Get help',
},
subtitle: 'Facing issues? You can use any of these methods for verification.',
Copy link
Member Author

Choose a reason for hiding this comment

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

All items are the same as sign in, except this one (3/4)

title: 'Check your email',
},
noAvailableMethods: {
message: "Cannot proceed with verification. There's no available authentication factor.",
Copy link
Member Author

Choose a reason for hiding this comment

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

All items are the same as sign in, except this one (4/4)

@panteliselef panteliselef changed the title Introduce UserVerification Introduce UserVerification as experimental Aug 28, 2024
@panteliselef panteliselef changed the title Introduce UserVerification as experimental feat(clerk-js,types,nextjs,localizations,clerk-react): Introduce UserVerification as experimental Aug 28, 2024
});
});

it.todo('renders the component for with strategy:phone_code');
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO ⚠️

Comment on lines +116 to +122
describe('Use another method', () => {
it.todo('should list enabled first factor methods without the current one');
});

describe('Get Help', () => {
it.todo('should render the get help component when clicking the "Get Help" button');
});
Copy link
Contributor

Choose a reason for hiding this comment

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

TODOs

Copy link
Member Author

Choose a reason for hiding this comment

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

These will be added in a future PR (soon)

@@ -0,0 +1,135 @@
import type { __experimental_SessionVerificationFirstFactor, SignInFactor } from '@clerk/types';
Copy link
Member

Choose a reason for hiding this comment

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

@panteliselef what do you think about renaming this file to something UVFactorOneAlternativeMethods so it can match UVFactorTwoAlternativeMethods?

Copy link
Member Author

Choose a reason for hiding this comment

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

I have no problem, there is a great chance that event the UV prefix will be replaced in the coming days as the component name is not final yet

Copy link
Member

@octoper octoper left a comment

Choose a reason for hiding this comment

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

🔥

@panteliselef panteliselef merged commit afad9af into main Aug 29, 2024
@panteliselef panteliselef deleted the elef/user-607-userverification-ui-component branch August 29, 2024 17:18
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.

6 participants