Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.
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
11 changes: 9 additions & 2 deletions src/GoTrueClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,13 +623,20 @@ export default class GoTrueClient {
// we don't want to remove the authenticated session if the user is performing an email_change or phone_change verification
await this._removeSession()
}

let redirectTo = undefined
let captchaToken = undefined
if ('options' in params) {
redirectTo = params.options?.redirectTo
captchaToken = params.options?.captchaToken
}
const { data, error } = await _request(this.fetch, 'POST', `${this.url}/verify`, {
headers: this.headers,
body: {
...params,
gotrue_meta_security: { captcha_token: params.options?.captchaToken },
gotrue_meta_security: { captcha_token: captchaToken },
},
redirectTo: params.options?.redirectTo,
redirectTo,
xform: _sessionResponse,
})

Expand Down
16 changes: 14 additions & 2 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ export type SignInWithIdTokenCredentials = {
}
}

export type VerifyOtpParams = VerifyMobileOtpParams | VerifyEmailOtpParams
export type VerifyOtpParams = VerifyMobileOtpParams | VerifyEmailOtpParams | VerifyTokenHashParams
export interface VerifyMobileOtpParams {
/** The user's phone number. */
phone: string
Expand Down Expand Up @@ -539,11 +539,23 @@ export interface VerifyEmailOtpParams {
options?: {
/** A URL to send the user to after they are confirmed. */
redirectTo?: string
/** Verification token received when the user completes the captcha on the site. */

/** Verification token received when the user completes the captcha on the site.
*
* @deprecated
*/
captchaToken?: string
}
}

export interface VerifyTokenHashParams {
/** The token hash used in an email link */
token_hash: string

/** The user's verification type. */
type: EmailOtpType
}

export type MobileOtpType = 'sms' | 'phone_change'
export type EmailOtpType = 'signup' | 'invite' | 'magiclink' | 'recovery' | 'email_change' | 'email'

Expand Down