chore: generate mfa secret in backend (#2930) [skip e2e]

* chore: get mfa secret from backend

* chore: remove unused code
This commit is contained in:
Antonella Sgarlatta
2025-09-12 14:34:51 -03:00
committed by GitHub
parent d6840ba41c
commit 2338449425
9 changed files with 52 additions and 32 deletions

View File

@@ -77,7 +77,7 @@ import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
import { Paths } from './Paths'
import { DiskStorageService } from '../Storage/DiskStorageService'
import { UuidString } from '../../Types/UuidString'
import { SettingsServerInterface } from '../Settings/SettingsServerInterface'
import { SettingsServerInterface, MfaSecretResponse } from '../Settings/SettingsServerInterface'
import { Strings } from '@Lib/Strings'
import { AnyFeatureDescription } from '@standardnotes/features'
@@ -563,11 +563,13 @@ export class LegacyApiService
settingName: string,
settingValue: string | null,
sensitive: boolean,
totpToken?: string,
): Promise<HttpResponse<UpdateSettingResponse>> {
const params = {
name: settingName,
value: settingValue,
sensitive: sensitive,
...(totpToken && { totpToken }),
}
return this.tokenRefreshableRequest<UpdateSettingResponse>({
verb: HttpVerb.Put,
@@ -637,6 +639,15 @@ export class LegacyApiService
})
}
async getMfaSecret(userUuid: UuidString): Promise<HttpResponse<MfaSecretResponse>> {
return this.tokenRefreshableRequest<MfaSecretResponse>({
verb: HttpVerb.Get,
url: joinPaths(this.host, Paths.v1.mfaSecret(userUuid)),
authentication: this.getSessionAccessToken(),
fallbackErrorMessage: 'Failed to get MFA secret.',
})
}
public downloadFeatureUrl(url: string): Promise<HttpResponse> {
return this.request({
verb: HttpVerb.Get,