@@ -345,6 +345,53 @@ describe('Generate Wallet Typed Routes Tests', function () {
345345 generateWalletStub . firstCall . args [ 0 ] . should . have . property ( 'commonKeychain' , commonKeychain ) ;
346346 } ) ;
347347
348+ it ( 'should successfully generate wallet with webauthnInfo' , async function ( ) {
349+ const coin = 'tbtc' ;
350+ const label = 'Test Wallet' ;
351+ const passphrase = 'mySecurePassphrase123' ;
352+ const webauthnInfo = {
353+ otpDeviceId : 'device-abc123' ,
354+ prfSalt : 'saltXYZ789' ,
355+ passphrase : 'prf-derived-passphrase' ,
356+ } ;
357+
358+ const mockWallet = {
359+ id : 'walletWebauthn' ,
360+ coin,
361+ label,
362+ toJSON : sinon . stub ( ) . returns ( { id : 'walletWebauthn' , coin, label } ) ,
363+ } ;
364+
365+ const walletResponse = {
366+ wallet : mockWallet ,
367+ userKeychain : { id : 'userKeyWebauthn' , pub : 'xpub...' , encryptedPrv : 'encrypted_prv' } ,
368+ backupKeychain : { id : 'backupKeyWebauthn' , pub : 'xpub...' } ,
369+ bitgoKeychain : { id : 'bitgoKeyWebauthn' , pub : 'xpub...' } ,
370+ } ;
371+
372+ const generateWalletStub = sinon . stub ( ) . resolves ( walletResponse ) ;
373+ const walletsStub = { generateWallet : generateWalletStub } as any ;
374+ const coinStub = { wallets : sinon . stub ( ) . returns ( walletsStub ) } as any ;
375+
376+ sinon . stub ( BitGo . prototype , 'coin' ) . returns ( coinStub ) ;
377+
378+ const res = await agent . post ( `/api/v2/${ coin } /wallet/generate` ) . send ( {
379+ label,
380+ passphrase,
381+ webauthnInfo,
382+ } ) ;
383+
384+ res . status . should . equal ( 200 ) ;
385+ res . body . should . have . property ( 'wallet' ) ;
386+
387+ generateWalletStub . should . have . been . calledOnce ( ) ;
388+ const calledWith = generateWalletStub . firstCall . args [ 0 ] ;
389+ calledWith . should . have . property ( 'webauthnInfo' ) ;
390+ calledWith . webauthnInfo . should . have . property ( 'otpDeviceId' , webauthnInfo . otpDeviceId ) ;
391+ calledWith . webauthnInfo . should . have . property ( 'prfSalt' , webauthnInfo . prfSalt ) ;
392+ calledWith . webauthnInfo . should . have . property ( 'passphrase' , webauthnInfo . passphrase ) ;
393+ } ) ;
394+
348395 it ( 'should successfully generate EVM keyring wallet with evmKeyRingReferenceWalletId' , async function ( ) {
349396 const coin = 'tpolygon' ;
350397 const label = 'EVM Keyring Child Wallet' ;
@@ -464,6 +511,57 @@ describe('Generate Wallet Typed Routes Tests', function () {
464511 res . body . error . should . match ( / b a c k u p X p u b P r o v i d e r / ) ;
465512 } ) ;
466513
514+ it ( 'should return 400 when webauthnInfo is missing otpDeviceId' , async function ( ) {
515+ const coin = 'tbtc' ;
516+
517+ const res = await agent . post ( `/api/v2/${ coin } /wallet/generate` ) . send ( {
518+ label : 'Test Wallet' ,
519+ passphrase : 'password' ,
520+ webauthnInfo : {
521+ prfSalt : 'salt-abc' ,
522+ passphrase : 'prf-passphrase' ,
523+ // missing otpDeviceId
524+ } ,
525+ } ) ;
526+
527+ res . status . should . equal ( 400 ) ;
528+ res . body . should . have . property ( 'error' ) ;
529+ } ) ;
530+
531+ it ( 'should return 400 when webauthnInfo is missing prfSalt' , async function ( ) {
532+ const coin = 'tbtc' ;
533+
534+ const res = await agent . post ( `/api/v2/${ coin } /wallet/generate` ) . send ( {
535+ label : 'Test Wallet' ,
536+ passphrase : 'password' ,
537+ webauthnInfo : {
538+ otpDeviceId : 'device-123' ,
539+ passphrase : 'prf-passphrase' ,
540+ // missing prfSalt
541+ } ,
542+ } ) ;
543+
544+ res . status . should . equal ( 400 ) ;
545+ res . body . should . have . property ( 'error' ) ;
546+ } ) ;
547+
548+ it ( 'should return 400 when webauthnInfo is missing passphrase' , async function ( ) {
549+ const coin = 'tbtc' ;
550+
551+ const res = await agent . post ( `/api/v2/${ coin } /wallet/generate` ) . send ( {
552+ label : 'Test Wallet' ,
553+ passphrase : 'password' ,
554+ webauthnInfo : {
555+ otpDeviceId : 'device-123' ,
556+ prfSalt : 'salt-abc' ,
557+ // missing passphrase
558+ } ,
559+ } ) ;
560+
561+ res . status . should . equal ( 400 ) ;
562+ res . body . should . have . property ( 'error' ) ;
563+ } ) ;
564+
467565 it ( 'should return 400 when disableTransactionNotifications is not boolean' , async function ( ) {
468566 const coin = 'tbtc' ;
469567
0 commit comments