@@ -320,6 +320,11 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
320320 }
321321 const { importTssKey, registerExistingSFAKey } = params ;
322322 const tkeyServiceProvider = this . torusSp ;
323+
324+ if ( registerExistingSFAKey && importTssKey ) {
325+ throw CoreKitError . invalidConfig ( "Cannot import TSS key and register SFA key at the same time." ) ;
326+ }
327+
323328 if ( this . isRedirectMode && ( importTssKey || registerExistingSFAKey ) ) {
324329 throw CoreKitError . invalidConfig ( "key import is not supported in redirect mode" ) ;
325330 }
@@ -1025,11 +1030,8 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
10251030 throw CoreKitError . default ( "Unsupported key type" ) ;
10261031 }
10271032 }
1028- await this . handleNewUser ( importTssKey ) ;
1029- if ( importTssKey && isSfaKey ) {
1030- await this . tkey . addLocalMetadataTransitions ( { input : [ { message : ONE_KEY_DELETE_NONCE } ] , privKey : [ new BN ( this . state . postBoxKey , "hex" ) ] } ) ;
1031- if ( ! this . tkey ?. manualSync ) await this . tkey ?. syncLocalMetadataTransitions ( ) ;
1032- }
1033+
1034+ await this . handleNewUser ( importTssKey , isSfaKey ) ;
10331035 } else {
10341036 if ( importTssKey ) {
10351037 throw CoreKitError . tssKeyImportNotAllowed ( ) ;
@@ -1039,7 +1041,7 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
10391041 }
10401042
10411043 // mutation function
1042- private async handleNewUser ( importTssKey ?: string ) {
1044+ private async handleNewUser ( importTssKey ?: string , isSfaKey ?: boolean ) {
10431045 await this . atomicSync ( async ( ) => {
10441046 // Generate or use hash factor and initialize tkey with it.
10451047 let factorKey : BN ;
@@ -1082,6 +1084,12 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
10821084 updateMetadata : false ,
10831085 } ) ;
10841086 }
1087+ if ( importTssKey && isSfaKey ) {
1088+ await this . tkey . addLocalMetadataTransitions ( {
1089+ input : [ { message : ONE_KEY_DELETE_NONCE } ] ,
1090+ privKey : [ new BN ( this . state . postBoxKey , "hex" ) ] ,
1091+ } ) ;
1092+ }
10851093 } ) ;
10861094 }
10871095
0 commit comments