From 684500b8642f751cdfeca6e7ec6b62f7e1aad450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Andre=CC=81s=20Maccaroni?= Date: Wed, 25 May 2022 17:10:30 -0300 Subject: [PATCH] PS-589 Added get/put device verification settings api calls --- common/src/abstractions/api.service.ts | 4 ++++ .../src/models/request/deviceVerificationRequest.ts | 7 +++++++ .../models/response/deviceVerificationResponse.ts | 12 ++++++++++++ common/src/services/api.service.ts | 12 ++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 common/src/models/request/deviceVerificationRequest.ts create mode 100644 common/src/models/response/deviceVerificationResponse.ts diff --git a/common/src/abstractions/api.service.ts b/common/src/abstractions/api.service.ts index 5a99589210..4c6d0c38c3 100644 --- a/common/src/abstractions/api.service.ts +++ b/common/src/abstractions/api.service.ts @@ -1,7 +1,9 @@ import { OrganizationConnectionType } from "jslib-common/enums/organizationConnectionType"; +import { DeviceVerificationRequest } from "jslib-common/models/request/DeviceVerificationRequest"; import { OrganizationConnectionRequest } from "jslib-common/models/request/organizationConnectionRequest"; import { BillingHistoryResponse } from "jslib-common/models/response/billingHistoryResponse"; import { BillingPaymentResponse } from "jslib-common/models/response/billingPaymentResponse"; +import { DeviceVerificationResponse } from "jslib-common/models/response/deviceVerificationResponse"; import { OrganizationConnectionConfigApis, OrganizationConnectionResponse, @@ -493,6 +495,8 @@ export abstract class ApiService { postTwoFactorRecover: (request: TwoFactorRecoveryRequest) => Promise; postTwoFactorEmailSetup: (request: TwoFactorEmailRequest) => Promise; postTwoFactorEmail: (request: TwoFactorEmailRequest) => Promise; + getDeviceVerificationSettings: () => Promise; + putDeviceVerificationSettings: (request: DeviceVerificationRequest) => Promise; getEmergencyAccessTrusted: () => Promise>; getEmergencyAccessGranted: () => Promise>; diff --git a/common/src/models/request/deviceVerificationRequest.ts b/common/src/models/request/deviceVerificationRequest.ts new file mode 100644 index 0000000000..5e119efa19 --- /dev/null +++ b/common/src/models/request/deviceVerificationRequest.ts @@ -0,0 +1,7 @@ +export class DeviceVerificationRequest { + unknownDeviceVerificationEnabled: boolean; + + constructor(unknownDeviceVerificationEnabled: boolean) { + this.unknownDeviceVerificationEnabled = unknownDeviceVerificationEnabled; + } +} diff --git a/common/src/models/response/deviceVerificationResponse.ts b/common/src/models/response/deviceVerificationResponse.ts new file mode 100644 index 0000000000..989efaf607 --- /dev/null +++ b/common/src/models/response/deviceVerificationResponse.ts @@ -0,0 +1,12 @@ +import { BaseResponse } from "./baseResponse"; + +export class DeviceVerificationResponse extends BaseResponse { + isDeviceVerificationSectionEnabled: boolean; + unknownDeviceVerificationEnabled: boolean; + + constructor(response: any) { + super(response); + this.isDeviceVerificationSectionEnabled = this.getResponseProperty("IsDeviceVerificationSectionEnabled"); + this.unknownDeviceVerificationEnabled = this.getResponseProperty("UnknownDeviceVerificationEnabled"); + } +} diff --git a/common/src/services/api.service.ts b/common/src/services/api.service.ts index 17e98d733e..2bd34ab818 100644 --- a/common/src/services/api.service.ts +++ b/common/src/services/api.service.ts @@ -187,6 +187,8 @@ import { import { TwoFactorYubiKeyResponse } from "../models/response/twoFactorYubiKeyResponse"; import { UserKeyResponse } from "../models/response/userKeyResponse"; import { SendAccessView } from "../models/view/sendAccessView"; +import { DeviceVerificationResponse } from "../models/response/deviceVerificationResponse"; +import { DeviceVerificationRequest } from "../models/request/DeviceVerificationRequest"; export class ApiService implements ApiServiceAbstraction { private device: DeviceType; @@ -1571,6 +1573,16 @@ export class ApiService implements ApiServiceAbstraction { return this.send("POST", "/two-factor/send-email-login", request, false, false); } + async getDeviceVerificationSettings(): Promise { + const r = await this.send("GET", "/two-factor/get-device-verification-settings", null, true, true); + return new DeviceVerificationResponse(r); + } + + async putDeviceVerificationSettings(request: DeviceVerificationRequest): Promise { + const r = await this.send("PUT", "/two-factor/device-verification-settings", request, true, true); + return new DeviceVerificationResponse(r); + } + // Emergency Access APIs async getEmergencyAccessTrusted(): Promise> {