@@ -43,6 +43,7 @@ import {
4343 JWTLoginParams ,
4444 MPCKeyDetails ,
4545 OAuthLoginParams ,
46+ PreSigningValidatorType ,
4647 Secp256k1PrecomputedClient ,
4748 SessionData ,
4849 SubVerifierDetailsParams ,
@@ -99,6 +100,8 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
99100
100101 private atomicCallStackCounter : number = 0 ;
101102
103+ private preSigningValidator ?: PreSigningValidatorType ;
104+
102105 constructor ( options : Web3AuthOptions ) {
103106 if ( ! options . web3AuthClientId ) {
104107 throw CoreKitError . clientIdInvalid ( ) ;
@@ -456,6 +459,10 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
456459 }
457460 }
458461
462+ setPreSigningValidator ( preSigningValidator : PreSigningValidatorType ) {
463+ this . preSigningValidator = preSigningValidator ;
464+ }
465+
459466 public async handleRedirectResult ( ) : Promise < void > {
460467 this . checkReady ( ) ;
461468
@@ -778,6 +785,12 @@ export class Web3AuthMPCCoreKit implements ICoreKit {
778785 }
779786
780787 public async sign ( data : Buffer , hashed : boolean = false , secp256k1Precompute ?: Secp256k1PrecomputedClient ) : Promise < Buffer > {
788+ if ( this . preSigningValidator ) {
789+ const result = await this . preSigningValidator ( { data, hashed } ) ;
790+ if ( ! result . success || result . error ) {
791+ throw Error ( result . error ) ;
792+ }
793+ }
781794 this . wasmLib = await this . loadTssWasm ( ) ;
782795 if ( this . keyType === KeyType . secp256k1 ) {
783796 const sig = await this . sign_ECDSA_secp256k1 ( data , hashed , secp256k1Precompute ) ;
0 commit comments