@@ -113,7 +113,7 @@ describe('AuthCodeHandler', () => {
113113 kind : 'google-pkce' ,
114114 metadata : { } ,
115115 target : '/test-target' ,
116- isSignUp : false ,
116+ type : 'reauth' ,
117117 signer : testWallet ,
118118 }
119119
@@ -247,20 +247,17 @@ describe('AuthCodeHandler', () => {
247247
248248 it ( 'Should create auth commitment and return OAuth URL' , async ( ) => {
249249 const target = '/test-target'
250- const isSignUp = true
251- const signer = testWallet
252250
253- const result = await authCodeHandler . commitAuth ( target , isSignUp , undefined , signer )
251+ const result = await authCodeHandler . commitAuth ( target , { type : 'auth' } )
254252
255253 // Verify commitment was saved
256254 expect ( mockAuthCommitmentsSet ) . toHaveBeenCalledOnce ( )
257255 const commitmentCall = mockAuthCommitmentsSet . mock . calls [ 0 ] ! [ 0 ] !
258256
259257 expect ( commitmentCall . kind ) . toBe ( 'google-pkce' )
260- expect ( commitmentCall . signer ) . toBe ( signer )
261258 expect ( commitmentCall . target ) . toBe ( target )
262259 expect ( commitmentCall . metadata ) . toEqual ( { } )
263- expect ( commitmentCall . isSignUp ) . toBe ( isSignUp )
260+ expect ( commitmentCall . type ) . toBe ( 'auth' )
264261 expect ( commitmentCall . id ) . toBeDefined ( )
265262 expect ( typeof commitmentCall . id ) . toBe ( 'string' )
266263
@@ -276,7 +273,11 @@ describe('AuthCodeHandler', () => {
276273 it ( 'Should use provided state parameter' , async ( ) => {
277274 const customState = 'custom-state-123'
278275
279- const result = await authCodeHandler . commitAuth ( '/target' , false , customState )
276+ const result = await authCodeHandler . commitAuth ( '/target' , {
277+ type : 'reauth' ,
278+ state : customState ,
279+ signer : testWallet ,
280+ } )
280281
281282 // Verify commitment uses custom state
282283 const commitmentCall = mockAuthCommitmentsSet . mock . calls [ 0 ] ! [ 0 ] !
@@ -285,7 +286,7 @@ describe('AuthCodeHandler', () => {
285286 } )
286287
287288 it ( 'Should generate random state when not provided' , async ( ) => {
288- await authCodeHandler . commitAuth ( '/target' , false )
289+ await authCodeHandler . commitAuth ( '/target' , { type : 'auth' } )
289290 const commitmentCall = mockAuthCommitmentsSet . mock . calls [ 0 ] ! [ 0 ] !
290291 expect ( commitmentCall . id ) . toBeDefined ( )
291292 expect ( typeof commitmentCall . id ) . toBe ( 'string' )
@@ -306,7 +307,7 @@ describe('AuthCodeHandler', () => {
306307 )
307308 appleHandler . setRedirectUri ( 'https://example.com/callback' )
308309
309- const result = await appleHandler . commitAuth ( '/target' , false )
310+ const result = await appleHandler . commitAuth ( '/target' , { type : 'auth' } )
310311
311312 expect ( result ) . toContain ( 'https://appleid.apple.com/auth/authorize?' )
312313 expect ( result ) . toContain ( 'client_id=apple-client-id' )
@@ -315,10 +316,10 @@ describe('AuthCodeHandler', () => {
315316 } )
316317
317318 it ( 'Should create commitment without signer' , async ( ) => {
318- await authCodeHandler . commitAuth ( '/target' , true )
319+ await authCodeHandler . commitAuth ( '/target' , { type : 'auth' } )
319320 const commitmentCall = mockAuthCommitmentsSet . mock . calls [ 0 ] ! [ 0 ] !
320321 expect ( commitmentCall . signer ) . toBeUndefined ( )
321- expect ( commitmentCall . isSignUp ) . toBe ( true )
322+ expect ( commitmentCall . type ) . toBe ( 'auth' )
322323 } )
323324 } )
324325
@@ -492,7 +493,7 @@ describe('AuthCodeHandler', () => {
492493
493494 const commitmentCall = mockAuthCommitmentsSet . mock . calls [ 0 ] ! [ 0 ] !
494495 expect ( commitmentCall . target ) . toBe ( window . location . pathname )
495- expect ( commitmentCall . isSignUp ) . toBe ( false )
496+ expect ( commitmentCall . type ) . toBe ( 'reauth' )
496497 expect ( commitmentCall . signer ) . toBe ( testWallet )
497498 } )
498499 } )
@@ -654,7 +655,7 @@ describe('AuthCodeHandler', () => {
654655 it ( 'Should handle auth commitments database errors' , async ( ) => {
655656 mockAuthCommitmentsSet . mockRejectedValueOnce ( new Error ( 'Database error' ) )
656657
657- await expect ( authCodeHandler . commitAuth ( '/target' , false ) ) . rejects . toThrow ( 'Database error' )
658+ await expect ( authCodeHandler . commitAuth ( '/target' , { type : 'auth' } ) ) . rejects . toThrow ( 'Database error' )
658659 } )
659660
660661 it ( 'Should handle auth keys database errors' , async ( ) => {
@@ -671,15 +672,19 @@ describe('AuthCodeHandler', () => {
671672 authCodeHandler . setRedirectUri ( 'https://example.com/callback' )
672673
673674 // Step 1: Commit auth
674- const commitUrl = await authCodeHandler . commitAuth ( '/test-target' , false , 'test-state' , testWallet )
675+ const commitUrl = await authCodeHandler . commitAuth ( '/test-target' , {
676+ type : 'reauth' ,
677+ state : 'test-state' ,
678+ signer : testWallet ,
679+ } )
675680
676681 expect ( commitUrl ) . toContain ( 'state=test-state' )
677682 expect ( mockAuthCommitmentsSet ) . toHaveBeenCalledWith (
678683 expect . objectContaining ( {
679684 id : 'test-state' ,
680685 kind : 'google-pkce' ,
681686 target : '/test-target' ,
682- isSignUp : false ,
687+ type : 'reauth' ,
683688 signer : testWallet ,
684689 } ) ,
685690 )
@@ -709,17 +714,17 @@ describe('AuthCodeHandler', () => {
709714 authCodeHandler . setRedirectUri ( 'https://example.com/callback' )
710715
711716 // Test signup flow
712- await authCodeHandler . commitAuth ( '/signup-target' , true , 'signup-state' )
717+ await authCodeHandler . commitAuth ( '/signup-target' , { type : 'auth' , state : 'signup-state' } )
713718
714719 const signupCall = mockAuthCommitmentsSet . mock . calls [ 0 ] ! [ 0 ] !
715- expect ( signupCall . isSignUp ) . toBe ( true )
720+ expect ( signupCall . type ) . toBe ( 'auth' )
716721 expect ( signupCall . target ) . toBe ( '/signup-target' )
717722
718723 // Test login flow
719- await authCodeHandler . commitAuth ( '/login-target' , false , 'login-state' )
724+ await authCodeHandler . commitAuth ( '/login-target' , { type : 'reauth' , state : 'login-state' , signer : testWallet } )
720725
721726 const loginCall = mockAuthCommitmentsSet . mock . calls [ 1 ] ! [ 0 ] !
722- expect ( loginCall . isSignUp ) . toBe ( false )
727+ expect ( loginCall . type ) . toBe ( 'reauth' )
723728 expect ( loginCall . target ) . toBe ( '/login-target' )
724729 } )
725730 } )
0 commit comments