@@ -117,41 +117,34 @@ function getAPIImplementation() {
117117 if ( flowType === "USER_INPUT_CODE" || flowType === "USER_INPUT_CODE_AND_MAGIC_LINK" ) {
118118 userInputCode = response . userInputCode ;
119119 }
120- try {
121- // we don't do something special for serverless env here
122- // cause we want to wait for service's reply since it can show
123- // a UI error message for if sending an SMS / email failed or not.
124- if (
125- input . options . config . contactMethod === "PHONE" ||
126- ( input . options . config . contactMethod === "EMAIL_OR_PHONE" && "phoneNumber" in input )
127- ) {
128- logger_1 . logDebugMessage ( `Sending passwordless login SMS to ${ input . phoneNumber } ` ) ;
129- yield input . options . smsDelivery . ingredientInterfaceImpl . sendSms ( {
130- type : "PASSWORDLESS_LOGIN" ,
131- codeLifetime : response . codeLifetime ,
132- phoneNumber : input . phoneNumber ,
133- preAuthSessionId : response . preAuthSessionId ,
134- urlWithLinkCode : magicLink ,
135- userInputCode,
136- userContext : input . userContext ,
137- } ) ;
138- } else {
139- logger_1 . logDebugMessage ( `Sending passwordless login email to ${ input . email } ` ) ;
140- yield input . options . emailDelivery . ingredientInterfaceImpl . sendEmail ( {
141- type : "PASSWORDLESS_LOGIN" ,
142- email : input . email ,
143- codeLifetime : response . codeLifetime ,
144- preAuthSessionId : response . preAuthSessionId ,
145- urlWithLinkCode : magicLink ,
146- userInputCode,
147- userContext : input . userContext ,
148- } ) ;
149- }
150- } catch ( err ) {
151- return {
152- status : "GENERAL_ERROR" ,
153- message : err . message ,
154- } ;
120+ // we don't do something special for serverless env here
121+ // cause we want to wait for service's reply since it can show
122+ // a UI error message for if sending an SMS / email failed or not.
123+ if (
124+ input . options . config . contactMethod === "PHONE" ||
125+ ( input . options . config . contactMethod === "EMAIL_OR_PHONE" && "phoneNumber" in input )
126+ ) {
127+ logger_1 . logDebugMessage ( `Sending passwordless login SMS to ${ input . phoneNumber } ` ) ;
128+ yield input . options . smsDelivery . ingredientInterfaceImpl . sendSms ( {
129+ type : "PASSWORDLESS_LOGIN" ,
130+ codeLifetime : response . codeLifetime ,
131+ phoneNumber : input . phoneNumber ,
132+ preAuthSessionId : response . preAuthSessionId ,
133+ urlWithLinkCode : magicLink ,
134+ userInputCode,
135+ userContext : input . userContext ,
136+ } ) ;
137+ } else {
138+ logger_1 . logDebugMessage ( `Sending passwordless login email to ${ input . email } ` ) ;
139+ yield input . options . emailDelivery . ingredientInterfaceImpl . sendEmail ( {
140+ type : "PASSWORDLESS_LOGIN" ,
141+ email : input . email ,
142+ codeLifetime : response . codeLifetime ,
143+ preAuthSessionId : response . preAuthSessionId ,
144+ urlWithLinkCode : magicLink ,
145+ userInputCode,
146+ userContext : input . userContext ,
147+ } ) ;
155148 }
156149 return {
157150 status : "OK" ,
@@ -251,42 +244,35 @@ function getAPIImplementation() {
251244 if ( flowType === "USER_INPUT_CODE" || flowType === "USER_INPUT_CODE_AND_MAGIC_LINK" ) {
252245 userInputCode = response . userInputCode ;
253246 }
254- try {
255- // we don't do something special for serverless env here
256- // cause we want to wait for service's reply since it can show
257- // a UI error message for if sending an SMS / email failed or not.
258- if (
259- input . options . config . contactMethod === "PHONE" ||
260- ( input . options . config . contactMethod === "EMAIL_OR_PHONE" &&
261- deviceInfo . phoneNumber !== undefined )
262- ) {
263- logger_1 . logDebugMessage ( `Sending passwordless login SMS to ${ input . phoneNumber } ` ) ;
264- yield input . options . smsDelivery . ingredientInterfaceImpl . sendSms ( {
265- type : "PASSWORDLESS_LOGIN" ,
266- codeLifetime : response . codeLifetime ,
267- phoneNumber : deviceInfo . phoneNumber ,
268- preAuthSessionId : response . preAuthSessionId ,
269- urlWithLinkCode : magicLink ,
270- userInputCode,
271- userContext : input . userContext ,
272- } ) ;
273- } else {
274- logger_1 . logDebugMessage ( `Sending passwordless login email to ${ input . email } ` ) ;
275- yield input . options . emailDelivery . ingredientInterfaceImpl . sendEmail ( {
276- type : "PASSWORDLESS_LOGIN" ,
277- email : input . email ,
278- codeLifetime : response . codeLifetime ,
279- preAuthSessionId : response . preAuthSessionId ,
280- urlWithLinkCode : magicLink ,
281- userInputCode,
282- userContext : input . userContext ,
283- } ) ;
284- }
285- } catch ( err ) {
286- return {
287- status : "GENERAL_ERROR" ,
288- message : err . message ,
289- } ;
247+ // we don't do something special for serverless env here
248+ // cause we want to wait for service's reply since it can show
249+ // a UI error message for if sending an SMS / email failed or not.
250+ if (
251+ input . options . config . contactMethod === "PHONE" ||
252+ ( input . options . config . contactMethod === "EMAIL_OR_PHONE" &&
253+ deviceInfo . phoneNumber !== undefined )
254+ ) {
255+ logger_1 . logDebugMessage ( `Sending passwordless login SMS to ${ input . phoneNumber } ` ) ;
256+ yield input . options . smsDelivery . ingredientInterfaceImpl . sendSms ( {
257+ type : "PASSWORDLESS_LOGIN" ,
258+ codeLifetime : response . codeLifetime ,
259+ phoneNumber : deviceInfo . phoneNumber ,
260+ preAuthSessionId : response . preAuthSessionId ,
261+ urlWithLinkCode : magicLink ,
262+ userInputCode,
263+ userContext : input . userContext ,
264+ } ) ;
265+ } else {
266+ logger_1 . logDebugMessage ( `Sending passwordless login email to ${ input . email } ` ) ;
267+ yield input . options . emailDelivery . ingredientInterfaceImpl . sendEmail ( {
268+ type : "PASSWORDLESS_LOGIN" ,
269+ email : input . email ,
270+ codeLifetime : response . codeLifetime ,
271+ preAuthSessionId : response . preAuthSessionId ,
272+ urlWithLinkCode : magicLink ,
273+ userInputCode,
274+ userContext : input . userContext ,
275+ } ) ;
290276 }
291277 }
292278 return {
0 commit comments