Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/orange-grapes-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/shared': patch
---

[Experimental] Fix method return types for new custom flow APIs.
41 changes: 21 additions & 20 deletions packages/shared/src/types/signInFuture.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ClerkError } from '../errors/clerkError';
import type { SetActiveNavigate } from './clerk';
import type { PhoneCodeChannel } from './phoneCodeChannel';
import type { SignInFirstFactor, SignInSecondFactor, SignInStatus, UserData } from './signInCommon';
Expand Down Expand Up @@ -340,12 +341,12 @@ export interface SignInFutureResource {
* > Once the sign-in process is complete, call the `signIn.finalize()` method to set the newly created session as
* > the active session.
*/
create: (params: SignInFutureCreateParams) => Promise<{ error: unknown }>;
create: (params: SignInFutureCreateParams) => Promise<{ error: ClerkError | null }>;

/**
* Used to submit a password to sign-in.
*/
password: (params: SignInFuturePasswordParams) => Promise<{ error: unknown }>;
password: (params: SignInFuturePasswordParams) => Promise<{ error: ClerkError | null }>;

/**
*
Expand All @@ -354,12 +355,12 @@ export interface SignInFutureResource {
/**
* Used to send an email code to sign-in
*/
sendCode: (params: SignInFutureEmailCodeSendParams) => Promise<{ error: unknown }>;
sendCode: (params: SignInFutureEmailCodeSendParams) => Promise<{ error: ClerkError | null }>;

/**
* Used to verify a code sent via email to sign-in
*/
verifyCode: (params: SignInFutureEmailCodeVerifyParams) => Promise<{ error: unknown }>;
verifyCode: (params: SignInFutureEmailCodeVerifyParams) => Promise<{ error: ClerkError | null }>;
};

/**
Expand All @@ -369,12 +370,12 @@ export interface SignInFutureResource {
/**
* Used to send an email link to sign-in
*/
sendLink: (params: SignInFutureEmailLinkSendParams) => Promise<{ error: unknown }>;
sendLink: (params: SignInFutureEmailLinkSendParams) => Promise<{ error: ClerkError | null }>;

/**
* Will wait for verification to complete or expire
*/
waitForVerification: () => Promise<{ error: unknown }>;
waitForVerification: () => Promise<{ error: ClerkError | null }>;

/**
* The verification status
Expand Down Expand Up @@ -404,12 +405,12 @@ export interface SignInFutureResource {
/**
* Used to send a phone code to sign-in
*/
sendCode: (params: SignInFuturePhoneCodeSendParams) => Promise<{ error: unknown }>;
sendCode: (params: SignInFuturePhoneCodeSendParams) => Promise<{ error: ClerkError | null }>;

/**
* Used to verify a code sent via phone to sign-in
*/
verifyCode: (params: SignInFuturePhoneCodeVerifyParams) => Promise<{ error: unknown }>;
verifyCode: (params: SignInFuturePhoneCodeVerifyParams) => Promise<{ error: ClerkError | null }>;
};

/**
Expand All @@ -419,23 +420,23 @@ export interface SignInFutureResource {
/**
* Used to send a password reset code to the first email address on the account
*/
sendCode: () => Promise<{ error: unknown }>;
sendCode: () => Promise<{ error: ClerkError | null }>;

/**
* Used to verify a password reset code sent via email. Will cause `signIn.status` to become `'needs_new_password'`.
*/
verifyCode: (params: SignInFutureEmailCodeVerifyParams) => Promise<{ error: unknown }>;
verifyCode: (params: SignInFutureEmailCodeVerifyParams) => Promise<{ error: ClerkError | null }>;

/**
* Used to submit a new password, and move the `signIn.status` to `'complete'`.
*/
submitPassword: (params: SignInFutureResetPasswordSubmitParams) => Promise<{ error: unknown }>;
submitPassword: (params: SignInFutureResetPasswordSubmitParams) => Promise<{ error: ClerkError | null }>;
};

/**
* Used to perform OAuth authentication.
*/
sso: (params: SignInFutureSSOParams) => Promise<{ error: unknown }>;
sso: (params: SignInFutureSSOParams) => Promise<{ error: ClerkError | null }>;

/**
*
Expand All @@ -444,45 +445,45 @@ export interface SignInFutureResource {
/**
* Used to send a phone code as a second factor to sign-in
*/
sendPhoneCode: () => Promise<{ error: unknown }>;
sendPhoneCode: () => Promise<{ error: ClerkError | null }>;

/**
* Used to verify a phone code sent as a second factor to sign-in
*/
verifyPhoneCode: (params: SignInFutureMFAPhoneCodeVerifyParams) => Promise<{ error: unknown }>;
verifyPhoneCode: (params: SignInFutureMFAPhoneCodeVerifyParams) => Promise<{ error: ClerkError | null }>;

/**
* Used to verify a TOTP code as a second factor to sign-in
*/
verifyTOTP: (params: SignInFutureTOTPVerifyParams) => Promise<{ error: unknown }>;
verifyTOTP: (params: SignInFutureTOTPVerifyParams) => Promise<{ error: ClerkError | null }>;

/**
* Used to verify a backup code as a second factor to sign-in
*/
verifyBackupCode: (params: SignInFutureBackupCodeVerifyParams) => Promise<{ error: unknown }>;
verifyBackupCode: (params: SignInFutureBackupCodeVerifyParams) => Promise<{ error: ClerkError | null }>;
};

/**
* Used to perform a ticket-based sign-in.
*/
ticket: (params?: SignInFutureTicketParams) => Promise<{ error: unknown }>;
ticket: (params?: SignInFutureTicketParams) => Promise<{ error: ClerkError | null }>;

/**
* Used to perform a Web3-based sign-in.
*/
web3: (params: SignInFutureWeb3Params) => Promise<{ error: unknown }>;
web3: (params: SignInFutureWeb3Params) => Promise<{ error: ClerkError | null }>;

/**
* Initiates a passkey-based authentication flow, enabling users to authenticate using a previously
* registered passkey. When called without parameters, this method requires a prior call to
* `SignIn.create({ strategy: 'passkey' })` to initialize the sign-in context. This pattern is particularly useful in
* scenarios where the authentication strategy needs to be determined dynamically at runtime.
*/
passkey: (params?: SignInFuturePasskeyParams) => Promise<{ error: unknown }>;
passkey: (params?: SignInFuturePasskeyParams) => Promise<{ error: ClerkError | null }>;

/**
* Used to convert a sign-in with `status === 'complete'` into an active session. Will cause anything observing the
* session state (such as the `useUser()` hook) to update automatically.
*/
finalize: (params?: SignInFutureFinalizeParams) => Promise<{ error: unknown }>;
finalize: (params?: SignInFutureFinalizeParams) => Promise<{ error: ClerkError | null }>;
}
23 changes: 12 additions & 11 deletions packages/shared/src/types/signUpFuture.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ClerkError } from '../errors/clerkError';
import type { SetActiveNavigate } from './clerk';
import type { PhoneCodeChannel } from './phoneCodeChannel';
import type { SignUpField, SignUpIdentificationField, SignUpStatus } from './signUpCommon';
Expand Down Expand Up @@ -398,12 +399,12 @@ export interface SignUpFutureResource {
* > Once the sign-up process is complete, call the `signUp.finalize()` method to set the newly created session as
* > the active session.
*/
create: (params: SignUpFutureCreateParams) => Promise<{ error: unknown }>;
create: (params: SignUpFutureCreateParams) => Promise<{ error: ClerkError | null }>;

/**
* Updates the current `SignUp`.
*/
update: (params: SignUpFutureUpdateParams) => Promise<{ error: unknown }>;
update: (params: SignUpFutureUpdateParams) => Promise<{ error: ClerkError | null }>;

/**
*
Expand All @@ -412,47 +413,47 @@ export interface SignUpFutureResource {
/**
* Used to send an email code to verify an email address.
*/
sendEmailCode: () => Promise<{ error: unknown }>;
sendEmailCode: () => Promise<{ error: ClerkError | null }>;

/**
* Used to verify a code sent via email.
*/
verifyEmailCode: (params: SignUpFutureEmailCodeVerifyParams) => Promise<{ error: unknown }>;
verifyEmailCode: (params: SignUpFutureEmailCodeVerifyParams) => Promise<{ error: ClerkError | null }>;

/**
* Used to send a phone code to verify a phone number.
*/
sendPhoneCode: (params: SignUpFuturePhoneCodeSendParams) => Promise<{ error: unknown }>;
sendPhoneCode: (params: SignUpFuturePhoneCodeSendParams) => Promise<{ error: ClerkError | null }>;

/**
* Used to verify a code sent via phone.
*/
verifyPhoneCode: (params: SignUpFuturePhoneCodeVerifyParams) => Promise<{ error: unknown }>;
verifyPhoneCode: (params: SignUpFuturePhoneCodeVerifyParams) => Promise<{ error: ClerkError | null }>;
};

/**
* Used to sign up using an email address and password.
*/
password: (params: SignUpFuturePasswordParams) => Promise<{ error: unknown }>;
password: (params: SignUpFuturePasswordParams) => Promise<{ error: ClerkError | null }>;

/**
* Used to create an account using an OAuth connection.
*/
sso: (params: SignUpFutureSSOParams) => Promise<{ error: unknown }>;
sso: (params: SignUpFutureSSOParams) => Promise<{ error: ClerkError | null }>;

/**
* Used to perform a ticket-based sign-up.
*/
ticket: (params?: SignUpFutureTicketParams) => Promise<{ error: unknown }>;
ticket: (params?: SignUpFutureTicketParams) => Promise<{ error: ClerkError | null }>;

/**
* Used to perform a Web3-based sign-up.
*/
web3: (params: SignUpFutureWeb3Params) => Promise<{ error: unknown }>;
web3: (params: SignUpFutureWeb3Params) => Promise<{ error: ClerkError | null }>;

/**
* Used to convert a sign-up with `status === 'complete'` into an active session. Will cause anything observing the
* session state (such as the `useUser()` hook) to update automatically.
*/
finalize: (params?: SignUpFutureFinalizeParams) => Promise<{ error: unknown }>;
finalize: (params?: SignUpFutureFinalizeParams) => Promise<{ error: ClerkError | null }>;
}
Loading