@@ -31,7 +31,7 @@ export type AuthMfaRequiredResponse = {
3131/**
3232 * Response returned when authentication succeeds but must be completed with
3333 * verification before issuing a token.
34- *
34+ *
3535 * @since 2.15.5
3636 */
3737export type AuthVerificationRequiredResponse = {
@@ -47,24 +47,11 @@ export type AuthVerificationRequiredResponse = {
4747
4848/**
4949 * Response returned from a registration attempt.
50- *
50+ *
5151 * @since 2.15.5
5252 */
5353export type AuthRegisterResponse = string | AuthVerificationRequiredResponse
5454
55- /**
56- * Options used when registering with an auth provider.
57- *
58- * @since 2.15.5
59- */
60- export type AuthRegisterOptions = {
61- /**
62- * Return verification state instead of throwing when registration
63- * requires verification before a token can be issued.
64- */
65- returnVerification ?: boolean
66- }
67-
6855/**
6956 * Response returned from an authentication attempt.
7057 */
@@ -202,7 +189,7 @@ export type AuthMfaVerifyChallengePayload = {
202189
203190/**
204191 * Payload used to request a verification token.
205- *
192+ *
206193 * @since 2.15.5
207194 */
208195export type AuthVerificationRequestPayload = {
@@ -218,7 +205,7 @@ export type AuthVerificationRequestPayload = {
218205
219206/**
220207 * Payload used to confirm a verification token.
221- *
208+ *
222209 * @since 2.15.5
223210 */
224211export type AuthVerificationConfirmPayload = {
@@ -230,7 +217,7 @@ export type AuthVerificationConfirmPayload = {
230217
231218/**
232219 * Response returned after requesting a verification token.
233- *
220+ *
234221 * @since 2.15.5
235222 */
236223export type AuthVerificationRequestResponse = {
@@ -242,7 +229,7 @@ export type AuthVerificationRequestResponse = {
242229
243230/**
244231 * Response returned after confirming verification.
245- *
232+ *
246233 * @since 2.15.5
247234 */
248235export type AuthVerificationConfirmResponse = {
@@ -471,7 +458,7 @@ export class Auth {
471458
472459 /**
473460 * Methods for requesting and confirming verification.
474- *
461+ *
475462 * @since 2.15.5
476463 */
477464 verification = {
@@ -563,11 +550,10 @@ export class Auth {
563550 * password: "supersecret"
564551 * })
565552 */
566- register = ( async (
553+ register = async (
567554 actor : string ,
568555 method : string ,
569- payload : HttpTypes . AdminSignUpWithEmailPassword | Record < string , unknown > ,
570- options ?: AuthRegisterOptions
556+ payload : HttpTypes . AdminSignUpWithEmailPassword | Record < string , unknown >
571557 ) : Promise < AuthRegisterResponse > => {
572558 const { token, verification_required, verification } =
573559 await this . client . fetch < AuthProviderResponse > (
@@ -579,36 +565,20 @@ export class Auth {
579565 )
580566
581567 if ( verification_required && verification ) {
582- if ( options ?. returnVerification ) {
583- return {
584- verification_required : true ,
585- verification,
586- }
568+ return {
569+ verification_required : true ,
570+ verification,
587571 }
588-
589- throw new Error ( "Unexpected registration response" )
590572 }
591573
592574 if ( ! token ) {
593575 throw new Error ( "Unexpected registration response" )
594576 }
595577
578+ // The reason we don't use setToken_ (i.e. start a session) here is because the token doesn't have any actor types attached to it yet.
579+ // The token should be sent in a separate request to create an actor type, after which we can initiate the session.
596580 this . client . setToken ( token )
597-
598581 return token
599- } ) as {
600- (
601- actor : string ,
602- method : string ,
603- payload : HttpTypes . AdminSignUpWithEmailPassword | Record < string , unknown > ,
604- options : AuthRegisterOptions & { returnVerification : true }
605- ) : Promise < AuthRegisterResponse >
606- (
607- actor : string ,
608- method : string ,
609- payload : HttpTypes . AdminSignUpWithEmailPassword | Record < string , unknown > ,
610- options ?: AuthRegisterOptions
611- ) : Promise < string >
612582 }
613583
614584 /**
0 commit comments