refactor: remove application mfa helper functions (#2852)
This commit is contained in:
@@ -917,28 +917,6 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
|
||||
return service.canAttemptDecryptionOfItem(item)
|
||||
}
|
||||
|
||||
public async isMfaActivated(): Promise<boolean> {
|
||||
return this.mfa.isMfaActivated()
|
||||
}
|
||||
|
||||
public async generateMfaSecret(): Promise<string> {
|
||||
return this.mfa.generateMfaSecret()
|
||||
}
|
||||
|
||||
public async getOtpToken(secret: string): Promise<string> {
|
||||
return this.mfa.getOtpToken(secret)
|
||||
}
|
||||
|
||||
public async enableMfa(secret: string, otpToken: string): Promise<void> {
|
||||
return this.mfa.enableMfa(secret, otpToken)
|
||||
}
|
||||
|
||||
public async disableMfa(): Promise<void> {
|
||||
if (await this.protections.authorizeMfaDisable()) {
|
||||
return this.mfa.disableMfa()
|
||||
}
|
||||
}
|
||||
|
||||
async isUsingHomeServer(): Promise<boolean> {
|
||||
const homeServerService = this.dependencies.get<HomeServerServiceInterface>(TYPES.HomeServerService)
|
||||
|
||||
|
||||
@@ -148,6 +148,7 @@ import {
|
||||
SyncBackoffService,
|
||||
SyncBackoffServiceInterface,
|
||||
StorageServiceInterface,
|
||||
ProtectionsClientInterface,
|
||||
} from '@standardnotes/services'
|
||||
import { ItemManager } from '../../Services/Items/ItemManager'
|
||||
import { PayloadManager } from '../../Services/Payloads/PayloadManager'
|
||||
@@ -1229,6 +1230,7 @@ export class Dependencies {
|
||||
this.get<SettingsService>(TYPES.SettingsService),
|
||||
this.get<PureCryptoInterface>(TYPES.Crypto),
|
||||
this.get<FeaturesService>(TYPES.FeaturesService),
|
||||
this.get<ProtectionsClientInterface>(TYPES.ProtectionService),
|
||||
this.get<InternalEventBus>(TYPES.InternalEventBus),
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
import { SettingsService } from '../Settings'
|
||||
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
|
||||
import { FeaturesService } from '../Features/FeaturesService'
|
||||
import { AbstractService, InternalEventBusInterface, MfaServiceInterface, SignInStrings } from '@standardnotes/services'
|
||||
import {
|
||||
AbstractService,
|
||||
InternalEventBusInterface,
|
||||
MfaServiceInterface,
|
||||
ProtectionsClientInterface,
|
||||
SignInStrings,
|
||||
} from '@standardnotes/services'
|
||||
import { SettingName } from '@standardnotes/domain-core'
|
||||
|
||||
export class MfaService extends AbstractService implements MfaServiceInterface {
|
||||
@@ -9,6 +15,7 @@ export class MfaService extends AbstractService implements MfaServiceInterface {
|
||||
private settingsService: SettingsService,
|
||||
private crypto: PureCryptoInterface,
|
||||
private featuresService: FeaturesService,
|
||||
private protections: ProtectionsClientInterface,
|
||||
protected override internalEventBus: InternalEventBusInterface,
|
||||
) {
|
||||
super(internalEventBus)
|
||||
@@ -48,6 +55,10 @@ export class MfaService extends AbstractService implements MfaServiceInterface {
|
||||
}
|
||||
|
||||
async disableMfa(): Promise<void> {
|
||||
if (!(await this.protections.authorizeMfaDisable())) {
|
||||
return
|
||||
}
|
||||
|
||||
return await this.settingsService.deleteSetting(SettingName.create(SettingName.NAMES.MfaSecret).getValue())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user