@@ -304,10 +304,82 @@ describe('store auth service', () => {
304304 expect ( presenter . openingBrowser ) . toHaveBeenCalledOnce ( )
305305 expect ( presenter . manualAuthUrl ) . toHaveBeenCalledWith (
306306 expect . stringContaining ( 'https://shop.myshopify.com/admin/oauth/authorize?' ) ,
307+ { sensitive : false } ,
307308 )
308309 expect ( presenter . success ) . toHaveBeenCalledWith ( result )
309310 } )
310311
312+ test ( 'authenticateStoreWithApp marks manual auth URL as sensitive when signup JWT is present' , async ( ) => {
313+ const openURL = vi . fn ( ) . mockResolvedValue ( false )
314+ const presenter = {
315+ openingBrowser : vi . fn ( ) ,
316+ manualAuthUrl : vi . fn ( ) ,
317+ success : vi . fn ( ) ,
318+ }
319+ const waitForStoreAuthCodeMock = vi . fn ( ) . mockImplementation ( async ( options ) => {
320+ await options . onListening ?.( )
321+ return 'abc123'
322+ } )
323+
324+ await expect (
325+ authenticateStoreWithApp (
326+ {
327+ store : 'shop.myshopify.com' ,
328+ scopes : 'read_products' ,
329+ signup : 'signed.signup.jwt' ,
330+ } ,
331+ {
332+ openURL,
333+ waitForStoreAuthCode : waitForStoreAuthCodeMock ,
334+ exchangeStoreAuthCodeForToken : vi . fn ( ) . mockResolvedValue ( {
335+ access_token : 'token' ,
336+ scope : 'read_products' ,
337+ expires_in : 86400 ,
338+ associated_user : { id : 42 , email : 'test@example.com' } ,
339+ } ) ,
340+ presenter,
341+ } ,
342+ ) ,
343+ ) . rejects . toThrow ( )
344+
345+ expect ( presenter . manualAuthUrl ) . toHaveBeenCalledWith ( expect . stringContaining ( 'signup=signed.signup.jwt' ) , {
346+ sensitive : true ,
347+ } )
348+ } )
349+
350+ test ( 'authenticateStoreWithApp fails immediately instead of waiting for a callback that cannot arrive' , async ( ) => {
351+ const openURL = vi . fn ( ) . mockResolvedValue ( false )
352+ const presenter = {
353+ openingBrowser : vi . fn ( ) ,
354+ manualAuthUrl : vi . fn ( ) ,
355+ success : vi . fn ( ) ,
356+ }
357+ const exchangeStoreAuthCodeForToken = vi . fn ( )
358+ const waitForStoreAuthCodeMock = vi . fn ( ) . mockImplementation ( async ( options ) => {
359+ await options . onListening ?.( )
360+ return 'abc123'
361+ } )
362+
363+ await expect (
364+ authenticateStoreWithApp (
365+ {
366+ store : 'shop.myshopify.com' ,
367+ scopes : 'read_products' ,
368+ signup : 'signed.signup.jwt' ,
369+ } ,
370+ {
371+ openURL,
372+ waitForStoreAuthCode : waitForStoreAuthCodeMock ,
373+ exchangeStoreAuthCodeForToken,
374+ presenter,
375+ } ,
376+ ) ,
377+ ) . rejects . toThrow ( "Authentication can't continue without a browser." )
378+
379+ expect ( exchangeStoreAuthCodeForToken ) . not . toHaveBeenCalled ( )
380+ expect ( presenter . success ) . not . toHaveBeenCalled ( )
381+ } )
382+
311383 test ( 'authenticateStoreWithApp records fqdn metadata before resolving existing scopes' , async ( ) => {
312384 await expect (
313385 authenticateStoreWithApp (
0 commit comments