First Factor
These are all methods on the SignIn
class that allow you to handle the first factor of a multi-factor authentication flow.
prepareFirstFactor()
function prepareFirstFactor(params: PrepareFirstFactorParams): Promise<SignIn>;
Begins the first factor verification process. This is a required step in order to complete a sign in, as users should be verified at least by one factor of authentication.
Common scenarios are one-time code (OTP) or social account (SSO) verification. This is determined by the accepted strategy
parameter values. Each authentication identifier supports different strategies.
PrepareFirstFactorParams
Name | Type | Description |
---|---|---|
strategy | string | The strategy value depends on the object's identifier value. Each authentication identifier supports different verification strategies. Possible strategy values are:
|
emailAddressId? | string | Unique identifier for the user's email address that will receive an email message with the one-time authentication code. This parameter will work only when the email_code strategy is specified. |
phoneNumberId? | string | Unique identifier for the user's phone number that will receive an SMS message with the one-time authentication code. This parameter will work only when the phone_code strategy is specified. |
web3WalletId? | string | Unique identifier for the user's web3 wallet public address. This parameter will work only when the web3_metamask_signature strategy is specified. |
redirectUrl? | string | The URL that the OAuth provider should redirect to, on successful authorization on their part. This parameter is required only if you set the strategy param to an OAuth strategy like oauth_<provider> . |
actionCompleteRedirectUrl? | string | The URL that the user will be redirected to, after successful authorization from the OAuth provider and Clerk sign in. This parameter is required only if you set the strategy param to an OAuth strategy like oauth_<provider> . |
Returns
Type | Description |
---|---|
Promise<SignIn> | This method returns a Promise which resolves with a SignIn object. Check the firstFactorVerification attribute for the status of the first factor verification process. |
attemptFirstFactor()
function attemptFirstFactor(params: AttemptFirstFactorParams): Promise<SignIn>;
Attempts to complete the first factor verification process. This is a required step in order to complete a sign in, as users should be verified at least by one factor of authentication.
Make sure that a SignIn
object already exists before you call this method, either by first calling SignIn.create
or SignIn.prepareFirstFactor
. The only strategy that does not require a verification to have already been prepared before attempting to complete it, is the password
strategy.
Depending on the strategy that was selected when the verification was prepared, the method parameters should be different.
AttemptFirstFactorParams
Name | Type | Description |
---|---|---|
strategy | string | The strategy value depends on the object's identifier value. Each authentication identifier supports different verification strategies. Possible strategy values are:
|
code? | string | The one-time code that was sent to the user as part of this verification step. This parameter is required only when strategy is set to email_code or phone_code . |
password? | string | The user's password string. This parameter is required only when strategy is set to password . |
signature? | string | Web3 wallet generated signature to be verified. This parameter is required only for web3 verification strategies. |