File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ export type CreateOrDeriveApiKeyError =
101101 | UnexpectedResponseError ;
102102
103103/**
104- * Derives an API key and falls back to creation when one does not exist yet .
104+ * Creates an API key and falls back to derivation when it already exists .
105105 *
106106 * @remarks
107107 * This is a low-level auth action that most SDK consumers will not need.
@@ -118,14 +118,6 @@ export async function createOrDeriveApiKey(
118118 client : Client ,
119119 request : L2AuthRequest ,
120120) : Promise < ApiKeyCreds > {
121- try {
122- return await deriveApiKey ( client , request ) ;
123- } catch ( error ) {
124- if ( ! ( error instanceof RequestRejectedError ) || error . status !== 400 ) {
125- throw error ;
126- }
127- }
128-
129121 try {
130122 return await createApiKey ( client , request ) ;
131123 } catch ( error ) {
Original file line number Diff line number Diff line change @@ -23,6 +23,20 @@ describe('clients', () => {
2323 await expect ( fetchApiKeys ( secureClient ) ) . resolves . toBeDefined ( ) ;
2424 } ) ;
2525
26+ it ( 'authenticates twice with the same nonce' , async ( ) => {
27+ const firstClient = await publicClient
28+ . beginAuthentication ( { nonce : 2 } )
29+ . then ( authenticateWith ( walletClient ) ) ;
30+
31+ await expect ( fetchApiKeys ( firstClient ) ) . resolves . toBeDefined ( ) ;
32+
33+ const secondClient = await publicClient
34+ . beginAuthentication ( { nonce : 2 } )
35+ . then ( authenticateWith ( walletClient ) ) ;
36+
37+ await expect ( fetchApiKeys ( secondClient ) ) . resolves . toBeDefined ( ) ;
38+ } ) ;
39+
2640 it ( 'reuses stored credentials during authentication when they remain valid' , async ( ) => {
2741 const initialClient = await publicClient
2842 . beginAuthentication ( )
You can’t perform that action at this time.
0 commit comments