diff --git a/src/abstractions/api.service.ts b/src/abstractions/api.service.ts index d931034139..0410fab49b 100644 --- a/src/abstractions/api.service.ts +++ b/src/abstractions/api.service.ts @@ -42,6 +42,7 @@ import { UpdateProfileRequest } from '../models/request/updateProfileRequest'; import { UpdateTwoFactorAuthenticatorRequest } from '../models/request/updateTwoFactorAuthenticatorRequest'; import { UpdateTwoFactorDuoRequest } from '../models/request/updateTwoFactorDuoRequest'; import { UpdateTwoFactorEmailRequest } from '../models/request/updateTwoFactorEmailRequest'; +import { UpdateTwoFactorU2fDeleteRequest } from '../models/request/updateTwoFactorU2fDeleteRequest'; import { UpdateTwoFactorU2fRequest } from '../models/request/updateTwoFactorU2fRequest'; import { UpdateTwoFactorYubioOtpRequest } from '../models/request/updateTwoFactorYubioOtpRequest'; import { VerifyBankRequest } from '../models/request/verifyBankRequest'; @@ -80,7 +81,10 @@ import { TwoFactorDuoResponse } from '../models/response/twoFactorDuoResponse'; import { TwoFactorEmailResponse } from '../models/response/twoFactorEmailResponse'; import { TwoFactorProviderResponse } from '../models/response/twoFactorProviderResponse'; import { TwoFactorRecoverResponse } from '../models/response/twoFactorRescoverResponse'; -import { TwoFactorU2fResponse } from '../models/response/twoFactorU2fResponse'; +import { + ChallengeResponse, + TwoFactorU2fResponse, +} from '../models/response/twoFactorU2fResponse'; import { TwoFactorYubiKeyResponse } from '../models/response/twoFactorYubiKeyResponse'; import { UserKeyResponse } from '../models/response/userKeyResponse'; @@ -195,6 +199,7 @@ export abstract class ApiService { request: PasswordVerificationRequest) => Promise; getTwoFactorYubiKey: (request: PasswordVerificationRequest) => Promise; getTwoFactorU2f: (request: PasswordVerificationRequest) => Promise; + getTwoFactorU2fChallenge: (request: PasswordVerificationRequest) => Promise; getTwoFactorRecover: (request: PasswordVerificationRequest) => Promise; putTwoFactorAuthenticator: ( request: UpdateTwoFactorAuthenticatorRequest) => Promise; @@ -204,6 +209,7 @@ export abstract class ApiService { request: UpdateTwoFactorDuoRequest) => Promise; putTwoFactorYubiKey: (request: UpdateTwoFactorYubioOtpRequest) => Promise; putTwoFactorU2f: (request: UpdateTwoFactorU2fRequest) => Promise; + deleteTwoFactorU2f: (request: UpdateTwoFactorU2fDeleteRequest) => Promise; putTwoFactorDisable: (request: TwoFactorProviderRequest) => Promise; putTwoFactorOrganizationDisable: (organizationId: string, request: TwoFactorProviderRequest) => Promise; diff --git a/src/models/request/updateTwoFactorU2fDeleteRequest.ts b/src/models/request/updateTwoFactorU2fDeleteRequest.ts new file mode 100644 index 0000000000..01066a301e --- /dev/null +++ b/src/models/request/updateTwoFactorU2fDeleteRequest.ts @@ -0,0 +1,5 @@ +import { PasswordVerificationRequest } from './passwordVerificationRequest'; + +export class UpdateTwoFactorU2fDeleteRequest extends PasswordVerificationRequest { + id: number; +} diff --git a/src/models/request/updateTwoFactorU2fRequest.ts b/src/models/request/updateTwoFactorU2fRequest.ts index a0e959bd18..0b3fb7c2be 100644 --- a/src/models/request/updateTwoFactorU2fRequest.ts +++ b/src/models/request/updateTwoFactorU2fRequest.ts @@ -2,4 +2,6 @@ import { PasswordVerificationRequest } from './passwordVerificationRequest'; export class UpdateTwoFactorU2fRequest extends PasswordVerificationRequest { deviceResponse: string; + name: string; + id: number; } diff --git a/src/models/response/twoFactorU2fResponse.ts b/src/models/response/twoFactorU2fResponse.ts index 7ab62cc627..62ae93d68c 100644 --- a/src/models/response/twoFactorU2fResponse.ts +++ b/src/models/response/twoFactorU2fResponse.ts @@ -1,10 +1,22 @@ export class TwoFactorU2fResponse { enabled: boolean; - challenge: ChallengeResponse; + keys: KeyResponse[]; constructor(response: any) { this.enabled = response.Enabled; - this.challenge = response.Challenge == null ? null : new ChallengeResponse(response.Challenge); + this.keys = response.Keys == null ? null : response.Keys.map((k: any) => new KeyResponse(k)); + } +} + +export class KeyResponse { + name: string; + id: number; + compromised: boolean; + + constructor(response: any) { + this.name = response.Name; + this.id = response.Id; + this.compromised = response.Compromised; } } diff --git a/src/services/api.service.ts b/src/services/api.service.ts index 5acfe6f99a..18fdd9935c 100644 --- a/src/services/api.service.ts +++ b/src/services/api.service.ts @@ -48,6 +48,7 @@ import { UpdateProfileRequest } from '../models/request/updateProfileRequest'; import { UpdateTwoFactorAuthenticatorRequest } from '../models/request/updateTwoFactorAuthenticatorRequest'; import { UpdateTwoFactorDuoRequest } from '../models/request/updateTwoFactorDuoRequest'; import { UpdateTwoFactorEmailRequest } from '../models/request/updateTwoFactorEmailRequest'; +import { UpdateTwoFactorU2fDeleteRequest } from '../models/request/updateTwoFactorU2fDeleteRequest'; import { UpdateTwoFactorU2fRequest } from '../models/request/updateTwoFactorU2fRequest'; import { UpdateTwoFactorYubioOtpRequest } from '../models/request/updateTwoFactorYubioOtpRequest'; import { VerifyBankRequest } from '../models/request/verifyBankRequest'; @@ -87,7 +88,10 @@ import { TwoFactorDuoResponse } from '../models/response/twoFactorDuoResponse'; import { TwoFactorEmailResponse } from '../models/response/twoFactorEmailResponse'; import { TwoFactorProviderResponse } from '../models/response/twoFactorProviderResponse'; import { TwoFactorRecoverResponse } from '../models/response/twoFactorRescoverResponse'; -import { TwoFactorU2fResponse } from '../models/response/twoFactorU2fResponse'; +import { + ChallengeResponse, + TwoFactorU2fResponse, +} from '../models/response/twoFactorU2fResponse'; import { TwoFactorYubiKeyResponse } from '../models/response/twoFactorYubiKeyResponse'; import { UserKeyResponse } from '../models/response/userKeyResponse'; @@ -618,6 +622,11 @@ export class ApiService implements ApiServiceAbstraction { return new TwoFactorU2fResponse(r); } + async getTwoFactorU2fChallenge(request: PasswordVerificationRequest): Promise { + const r = await this.send('POST', '/two-factor/get-u2f-challenge', request, true, true); + return new ChallengeResponse(r); + } + async getTwoFactorRecover(request: PasswordVerificationRequest): Promise { const r = await this.send('POST', '/two-factor/get-recover', request, true, true); return new TwoFactorRecoverResponse(r); @@ -655,6 +664,11 @@ export class ApiService implements ApiServiceAbstraction { return new TwoFactorU2fResponse(r); } + async deleteTwoFactorU2f(request: UpdateTwoFactorU2fDeleteRequest): Promise { + const r = await this.send('DELETE', '/two-factor/u2f', request, true, true); + return new TwoFactorU2fResponse(r); + } + async putTwoFactorDisable(request: TwoFactorProviderRequest): Promise { const r = await this.send('PUT', '/two-factor/disable', request, true, true); return new TwoFactorProviderResponse(r);