@@ -24,7 +24,8 @@ export type Routes =
2424 | "/login/callback"
2525 | "/oauth/token"
2626 | "/v2/logout"
27- | "/userinfo" ;
27+ | "/userinfo"
28+ | "/passwordless/start" ;
2829
2930export type AuthSession = { username : string ; nonce : string } ;
3031
@@ -266,5 +267,53 @@ export const createAuth0Handlers = (
266267
267268 res . status ( 200 ) . json ( userinfo ) ;
268269 } ,
270+
271+ [ "/passwordless/start" ] : async function ( req , res , next ) {
272+ logger . log ( { "/passwordless/start" : { body : req . body } } ) ;
273+
274+ try {
275+ const { client_id, connection, email, phone_number, send } = req . body ;
276+
277+ // Validate required fields
278+ if ( ! client_id ) {
279+ return res . status ( 400 ) . json ( { error : "client_id is required" } ) ;
280+ }
281+
282+ if ( ! connection || ( connection !== "email" && connection !== "sms" ) ) {
283+ return res . status ( 400 ) . json ( {
284+ error : "connection must be 'email' or 'sms'" ,
285+ } ) ;
286+ }
287+
288+ if ( connection === "email" && ! email ) {
289+ return res . status ( 400 ) . json ( {
290+ error : "email is required when connection is 'email'" ,
291+ } ) ;
292+ }
293+
294+ if ( connection === "sms" && ! phone_number ) {
295+ return res . status ( 400 ) . json ( {
296+ error : "phone_number is required when connection is 'sms'" ,
297+ } ) ;
298+ }
299+
300+ // Return appropriate response based on connection type
301+ if ( connection === "email" ) {
302+ res . status ( 200 ) . json ( {
303+ _id : "000000000000000000000000" ,
304+ email : email ,
305+ email_verified : false ,
306+ } ) ;
307+ } else {
308+ res . status ( 200 ) . json ( {
309+ _id : "000000000000000000000000" ,
310+ phone_number : phone_number ,
311+ phone_verified : false ,
312+ } ) ;
313+ }
314+ } catch ( error ) {
315+ next ( error ) ;
316+ }
317+ } ,
269318 } ;
270319} ;
0 commit comments