@@ -60,7 +60,7 @@ import {
6060 Web3AuthState ,
6161} from "./interfaces" ;
6262import { DefaultSessionSigGeneratorPlugin } from "./plugins/DefaultSessionSigGenerator" ;
63- import { ICustomDklsSignParams , ICustomFrostSignParams , IRemoteClientState } from "./plugins/IRemoteSigner " ;
63+ import { ICustomDklsSignParams , ICustomFrostSignParams , IRemoteClientState } from "./plugins/ICustomSigner " ;
6464import { ISessionSigGenerator } from "./plugins/ISessionSigGenerator" ;
6565import {
6666 deriveShareCoefficients ,
@@ -588,6 +588,13 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext {
588588 public async enableMFA ( enableMFAParams : EnableMFAParams , recoveryFactor = true ) : Promise < string > {
589589 this . checkReady ( ) ;
590590
591+ if ( ! this . state . factorKey ) {
592+ if ( this . state . remoteClient ?. remoteFactorPub ) {
593+ throw CoreKitError . notSupportedForRemoteFactor ( "Cannot enable MFA with remote factor." ) ;
594+ }
595+ throw CoreKitError . factorKeyNotPresent ( "Current factorKey not present in state when enabling MFA." ) ;
596+ }
597+
591598 const { postBoxKey } = this . state ;
592599 const hashedFactorKey = getHashedPrivateKey ( postBoxKey , this . options . hashedFactorNonce ) ;
593600 if ( ! ( await this . checkIfFactorKeyValid ( hashedFactorKey ) ) ) {
@@ -652,6 +659,14 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext {
652659 // mutation function
653660 public async createFactor ( createFactorParams : CreateFactorParams ) : Promise < string > {
654661 this . checkReady ( ) ;
662+
663+ if ( ! this . state . factorKey ) {
664+ if ( this . state . remoteClient ?. remoteFactorPub ) {
665+ throw CoreKitError . notSupportedForRemoteFactor ( "Cannot create a factor with remote factor." ) ;
666+ }
667+ throw CoreKitError . factorKeyNotPresent ( "Current factorKey not present in state when creating a factor." ) ;
668+ }
669+
655670 const { shareType } = createFactorParams ;
656671
657672 let { factorKey, shareDescription, additionalMetadata } = createFactorParams ;
@@ -905,7 +920,8 @@ export class Web3AuthMPCCoreKit implements ICoreKit, IMPCContext {
905920
906921 // mutation function
907922 async deleteFactor ( factorPub : Point , factorKey ?: BNString ) : Promise < void > {
908- if ( ! this . state . factorKey && ! this . state . remoteClient ) {
923+ if ( ! this . state . factorKey ) {
924+ if ( this . state . remoteClient ?. remoteFactorPub ) throw CoreKitError . notSupportedForRemoteFactor ( "Cannot delete a remote factor." ) ;
909925 throw CoreKitError . factorKeyNotPresent ( "factorKey not present in state when deleting a factor." ) ;
910926 }
911927 if ( ! this . tKey . metadata . factorPubs ) {
0 commit comments