@@ -88,6 +88,8 @@ async function performDeviceAuthorization(
8888 ctx : Context ,
8989 authClient : BaseClient ,
9090 shouldOpen : boolean ,
91+ vercel ?: boolean ,
92+ vercelOverride ?: string ,
9193) : Promise < string > {
9294 // Device authorization flow follows this guide: https://github.com/auth0/auth0-device-flow-cli-sample/blob/9f0f3b76a6cd56ea8d99e76769187ea5102d519d/cli.js
9395 // License: MIT License
@@ -132,8 +134,14 @@ async function performDeviceAuthorization(
132134 // Device Authorization Response - https://tools.ietf.org/html/rfc8628#section-3.2
133135 // Open authentication URL
134136 const { verification_uri_complete, user_code, expires_in } = handle ;
137+
138+ // Construct Vercel URL if --vercel flag is used
139+ const urlToOpen = vercel
140+ ? `https://vercel.com/sso/integrations/${ vercelOverride || "convex" } ?url=${ verification_uri_complete } `
141+ : verification_uri_complete ;
142+
135143 logMessage (
136- `Visit ${ verification_uri_complete } to finish logging in.\n` +
144+ `Visit ${ urlToOpen } to finish logging in.\n` +
137145 `You should see the following code which expires in ${
138146 expires_in % 60 === 0
139147 ? `${ expires_in / 60 } minutes`
@@ -148,25 +156,19 @@ async function performDeviceAuthorization(
148156 }
149157
150158 if ( shouldOpen ) {
151- showSpinner (
152- `Opening ${ verification_uri_complete } in your browser to log in...\n` ,
153- ) ;
159+ showSpinner ( `Opening ${ urlToOpen } in your browser to log in...\n` ) ;
154160 try {
155- const p = await open ( verification_uri_complete ) ;
161+ const p = await open ( urlToOpen ) ;
156162 p . once ( "error" , ( ) => {
157- changeSpinner (
158- `Manually open ${ verification_uri_complete } in your browser to log in.` ,
159- ) ;
163+ changeSpinner ( `Manually open ${ urlToOpen } in your browser to log in.` ) ;
160164 } ) ;
161165 changeSpinner ( "Waiting for the confirmation..." ) ;
162166 } catch {
163167 logError ( chalk . red ( `Unable to open browser.` ) ) ;
164- changeSpinner (
165- `Manually open ${ verification_uri_complete } in your browser to log in.` ,
166- ) ;
168+ changeSpinner ( `Manually open ${ urlToOpen } in your browser to log in.` ) ;
167169 }
168170 } else {
169- showSpinner ( `Open ${ verification_uri_complete } in your browser to log in.` ) ;
171+ showSpinner ( `Open ${ urlToOpen } in your browser to log in.` ) ;
170172 }
171173
172174 // Device Access Token Request - https://tools.ietf.org/html/rfc8628#section-3.4
@@ -280,6 +282,8 @@ export async function performLogin(
280282 dumpAccessToken,
281283 deviceName : deviceNameOverride ,
282284 anonymousId,
285+ vercel,
286+ vercelOverride,
283287 } : {
284288 overrideAuthUrl ?: string ;
285289 overrideAuthClient ?: string ;
@@ -294,6 +298,8 @@ export async function performLogin(
294298 dumpAccessToken ?: boolean ;
295299 deviceName ?: string ;
296300 anonymousId ?: string ;
301+ vercel ?: boolean ;
302+ vercelOverride ?: string ;
297303 } = { } ,
298304) {
299305 loginFlow = loginFlow || "auto" ;
@@ -366,6 +372,8 @@ export async function performLogin(
366372 ctx ,
367373 authClient ,
368374 open ?? true ,
375+ vercel ,
376+ vercelOverride ,
369377 ) ;
370378 }
371379 }
0 commit comments