File tree Expand file tree Collapse file tree 6 files changed +43
-2
lines changed
clerk-js/src/core/resources Expand file tree Collapse file tree 6 files changed +43
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @clerk/clerk-js ' : minor
3+ ' @clerk/types ' : minor
4+ ---
5+
6+ [ Experimental] Add support for ticket sign-ins and sign-ups
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ import type {
4444 SignInFutureResetPasswordSubmitParams ,
4545 SignInFutureResource ,
4646 SignInFutureSSOParams ,
47+ SignInFutureTicketParams ,
4748 SignInFutureTOTPVerifyParams ,
4849 SignInIdentifier ,
4950 SignInJSON ,
@@ -914,6 +915,11 @@ class SignInFuture implements SignInFutureResource {
914915 } ) ;
915916 }
916917
918+ async ticket ( params ?: SignInFutureTicketParams ) : Promise < { error : unknown } > {
919+ const ticket = params ?. ticket ?? getClerkQueryParam ( '__clerk_ticket' ) ;
920+ return this . create ( { ticket : ticket ?? undefined } ) ;
921+ }
922+
917923 async finalize ( params ?: SignInFutureFinalizeParams ) : Promise < { error : unknown } > {
918924 const { navigate } = params || { } ;
919925 return runAsyncResourceTask ( this . resource , async ( ) => {
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import type {
2525 SignUpFuturePhoneCodeVerifyParams ,
2626 SignUpFutureResource ,
2727 SignUpFutureSSOParams ,
28+ SignUpFutureTicketParams ,
2829 SignUpFutureUpdateParams ,
2930 SignUpIdentificationField ,
3031 SignUpJSON ,
@@ -44,6 +45,7 @@ import {
4445 generateSignatureWithMetamask ,
4546 generateSignatureWithOKXWallet ,
4647 getBaseIdentifier ,
48+ getClerkQueryParam ,
4749 getCoinbaseWalletIdentifier ,
4850 getMetamaskIdentifier ,
4951 getOKXWalletIdentifier ,
@@ -773,6 +775,11 @@ class SignUpFuture implements SignUpFutureResource {
773775 } ) ;
774776 }
775777
778+ async ticket ( params ?: SignUpFutureTicketParams ) : Promise < { error : unknown } > {
779+ const ticket = params ?. ticket ?? getClerkQueryParam ( '__clerk_ticket' ) ;
780+ return this . create ( { ...params , ticket : ticket ?? undefined } ) ;
781+ }
782+
776783 async finalize ( params ?: SignUpFutureFinalizeParams ) : Promise < { error : unknown } > {
777784 const { navigate } = params || { } ;
778785 return runAsyncResourceTask ( this . resource , async ( ) => {
Original file line number Diff line number Diff line change @@ -91,6 +91,7 @@ export class StateProxy implements State {
9191 'verifyTOTP' ,
9292 'verifyBackupCode' ,
9393 ] as const ) ,
94+ ticket : this . gateMethod ( target , 'ticket' ) ,
9495 } ,
9596 } ;
9697 }
@@ -119,6 +120,7 @@ export class StateProxy implements State {
119120 update : gateMethod ( target , 'update' ) ,
120121 sso : gateMethod ( target , 'sso' ) ,
121122 password : gateMethod ( target , 'password' ) ,
123+ ticket : gateMethod ( target , 'ticket' ) ,
122124 finalize : gateMethod ( target , 'finalize' ) ,
123125
124126 verifications : wrapMethods ( ( ) => target ( ) . verifications , [
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export interface SignInFutureCreateParams {
1010 redirectUrl ?: string ;
1111 actionCompleteRedirectUrl ?: string ;
1212 transfer ?: boolean ;
13+ ticket ?: string ;
1314}
1415
1516export type SignInFuturePasswordParams =
@@ -110,6 +111,10 @@ export interface SignInFutureBackupCodeVerifyParams {
110111 code : string ;
111112}
112113
114+ export interface SignInFutureTicketParams {
115+ ticket : string ;
116+ }
117+
113118export interface SignInFutureFinalizeParams {
114119 navigate ?: SetActiveNavigate ;
115120}
@@ -266,7 +271,12 @@ export interface SignInFutureResource {
266271 } ;
267272
268273 /**
269- * Used to convert a sign-in with `status === ‘complete’` into an active session. Will cause anything observing the
274+ * Used to perform a ticket-based sign-in.
275+ */
276+ ticket : ( params ?: SignInFutureTicketParams ) => Promise < { error : unknown } > ;
277+
278+ /**
279+ * Used to convert a sign-in with `status === 'complete'` into an active session. Will cause anything observing the
270280 * session state (such as the `useUser()` hook) to update automatically.
271281 */
272282 finalize : ( params ?: SignInFutureFinalizeParams ) => Promise < { error : unknown } > ;
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ interface SignUpFutureAdditionalParams {
1111
1212export interface SignUpFutureCreateParams extends SignUpFutureAdditionalParams {
1313 transfer ?: boolean ;
14+ ticket ?: string ;
1415}
1516
1617// This will likely get more properties
@@ -50,6 +51,10 @@ export interface SignUpFutureSSOParams {
5051 redirectCallbackUrl : string ;
5152}
5253
54+ export interface SignUpFutureTicketParams extends SignUpFutureAdditionalParams {
55+ ticket : string ;
56+ }
57+
5358export interface SignUpFutureFinalizeParams {
5459 navigate ?: SetActiveNavigate ;
5560}
@@ -116,7 +121,12 @@ export interface SignUpFutureResource {
116121 sso : ( params : SignUpFutureSSOParams ) => Promise < { error : unknown } > ;
117122
118123 /**
119- * Used to convert a sign-up with `status === ‘complete’` into an active session. Will cause anything observing the
124+ * Used to perform a ticket-based sign-up.
125+ */
126+ ticket : ( params ?: SignUpFutureTicketParams ) => Promise < { error : unknown } > ;
127+
128+ /**
129+ * Used to convert a sign-up with `status === 'complete'` into an active session. Will cause anything observing the
120130 * session state (such as the `useUser()` hook) to update automatically.
121131 */
122132 finalize : ( params ?: SignUpFutureFinalizeParams ) => Promise < { error : unknown } > ;
You can’t perform that action at this time.
0 commit comments