mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-06 18:57:56 +01:00
PM-1049 - Move newly created getDevices() method out of api.service into proper place in new devices-api.service.
This commit is contained in:
parent
e43da8044b
commit
ebeeb5cbb7
@ -2,7 +2,7 @@ import { Component } from "@angular/core";
|
||||
import { FormBuilder } from "@angular/forms";
|
||||
|
||||
import { BaseLoginDecryptionOptionsComponent } from "@bitwarden/angular/auth/components/base-login-decryption-options.component";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { DevicesApiServiceAbstraction } from "@bitwarden/common/abstractions/devices/devices-api.service.abstraction";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
|
||||
@ -13,10 +13,10 @@ import { PolicyService } from "@bitwarden/common/admin-console/abstractions/poli
|
||||
export class LoginDecryptionOptionsComponent extends BaseLoginDecryptionOptionsComponent {
|
||||
constructor(
|
||||
formBuilder: FormBuilder,
|
||||
apiService: ApiService,
|
||||
devicesApiService: DevicesApiServiceAbstraction,
|
||||
organizationService: OrganizationService,
|
||||
policyService: PolicyService
|
||||
) {
|
||||
super(formBuilder, apiService, organizationService, policyService);
|
||||
super(formBuilder, devicesApiService, organizationService, policyService);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import { Component } from "@angular/core";
|
||||
import { FormBuilder } from "@angular/forms";
|
||||
|
||||
import { BaseLoginDecryptionOptionsComponent } from "@bitwarden/angular/auth/components/base-login-decryption-options.component";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { DevicesApiServiceAbstraction } from "@bitwarden/common/abstractions/devices/devices-api.service.abstraction";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
|
||||
@ -13,10 +13,10 @@ import { PolicyService } from "@bitwarden/common/admin-console/abstractions/poli
|
||||
export class LoginDecryptionOptionsComponent extends BaseLoginDecryptionOptionsComponent {
|
||||
constructor(
|
||||
formBuilder: FormBuilder,
|
||||
apiService: ApiService,
|
||||
devicesApiService: DevicesApiServiceAbstraction,
|
||||
organizationService: OrganizationService,
|
||||
policyService: PolicyService
|
||||
) {
|
||||
super(formBuilder, apiService, organizationService, policyService);
|
||||
super(formBuilder, devicesApiService, organizationService, policyService);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import { Component } from "@angular/core";
|
||||
import { FormBuilder } from "@angular/forms";
|
||||
|
||||
import { BaseLoginDecryptionOptionsComponent } from "@bitwarden/angular/auth/components/base-login-decryption-options.component";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { DevicesApiServiceAbstraction } from "@bitwarden/common/abstractions/devices/devices-api.service.abstraction";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
|
||||
@ -13,10 +13,10 @@ import { PolicyService } from "@bitwarden/common/admin-console/abstractions/poli
|
||||
export class LoginDecryptionOptionsComponent extends BaseLoginDecryptionOptionsComponent {
|
||||
constructor(
|
||||
formBuilder: FormBuilder,
|
||||
apiService: ApiService,
|
||||
devicesApiService: DevicesApiServiceAbstraction,
|
||||
organizationService: OrganizationService,
|
||||
policyService: PolicyService
|
||||
) {
|
||||
super(formBuilder, apiService, organizationService, policyService);
|
||||
super(formBuilder, devicesApiService, organizationService, policyService);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import { Directive, OnDestroy, OnInit } from "@angular/core";
|
||||
import { FormBuilder } from "@angular/forms";
|
||||
import { Subject } from "rxjs";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { DevicesApiServiceAbstraction } from "@bitwarden/common/abstractions/devices/devices-api.service.abstraction";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
|
||||
@ -27,7 +27,7 @@ export class BaseLoginDecryptionOptionsComponent implements OnInit, OnDestroy {
|
||||
|
||||
constructor(
|
||||
protected formBuilder: FormBuilder,
|
||||
protected apiService: ApiService,
|
||||
protected devicesApiService: DevicesApiServiceAbstraction,
|
||||
protected organizationService: OrganizationService,
|
||||
protected policyService: PolicyService
|
||||
) {}
|
||||
@ -50,7 +50,7 @@ export class BaseLoginDecryptionOptionsComponent implements OnInit, OnDestroy {
|
||||
|
||||
// Determine if the user has any mobile or desktop devices
|
||||
// to determine if we should show the approve from other device button
|
||||
const devicesListResponse = await this.apiService.getDevices();
|
||||
const devicesListResponse = await this.devicesApiService.getDevices();
|
||||
for (const device of devicesListResponse.data) {
|
||||
if (
|
||||
device.type === DeviceType.Android ||
|
||||
|
@ -70,7 +70,6 @@ import { UpdateTwoFactorYubioOtpRequest } from "../auth/models/request/update-tw
|
||||
import { ApiKeyResponse } from "../auth/models/response/api-key.response";
|
||||
import { AuthRequestResponse } from "../auth/models/response/auth-request.response";
|
||||
import { DeviceVerificationResponse } from "../auth/models/response/device-verification.response";
|
||||
import { DeviceResponse } from "../auth/models/response/device.response";
|
||||
import {
|
||||
EmergencyAccessGranteeDetailsResponse,
|
||||
EmergencyAccessGrantorDetailsResponse,
|
||||
@ -363,8 +362,6 @@ export abstract class ApiService {
|
||||
request: DeviceVerificationRequest
|
||||
) => Promise<DeviceVerificationResponse>;
|
||||
|
||||
getDevices: () => Promise<ListResponse<DeviceResponse>>;
|
||||
|
||||
getEmergencyAccessTrusted: () => Promise<ListResponse<EmergencyAccessGranteeDetailsResponse>>;
|
||||
getEmergencyAccessGranted: () => Promise<ListResponse<EmergencyAccessGrantorDetailsResponse>>;
|
||||
getEmergencyAccess: (id: string) => Promise<EmergencyAccessGranteeDetailsResponse>;
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { ListResponse } from "../../models/response/list.response";
|
||||
|
||||
import { DeviceResponse } from "./responses/device.response";
|
||||
|
||||
export abstract class DevicesApiServiceAbstraction {
|
||||
@ -5,6 +7,8 @@ export abstract class DevicesApiServiceAbstraction {
|
||||
|
||||
getDeviceByIdentifier: (deviceIdentifier: string) => Promise<DeviceResponse>;
|
||||
|
||||
getDevices: () => Promise<ListResponse<DeviceResponse>>;
|
||||
|
||||
updateTrustedDeviceKeys: (
|
||||
deviceIdentifier: string,
|
||||
devicePublicKeyEncryptedUserSymKey: string,
|
||||
|
@ -77,7 +77,6 @@ import { UpdateTwoFactorYubioOtpRequest } from "../auth/models/request/update-tw
|
||||
import { ApiKeyResponse } from "../auth/models/response/api-key.response";
|
||||
import { AuthRequestResponse } from "../auth/models/response/auth-request.response";
|
||||
import { DeviceVerificationResponse } from "../auth/models/response/device-verification.response";
|
||||
import { DeviceResponse } from "../auth/models/response/device.response";
|
||||
import {
|
||||
EmergencyAccessGranteeDetailsResponse,
|
||||
EmergencyAccessGrantorDetailsResponse,
|
||||
@ -1111,12 +1110,6 @@ export class ApiService implements ApiServiceAbstraction {
|
||||
return new DeviceVerificationResponse(r);
|
||||
}
|
||||
|
||||
// TODO: move this method to new devices-api.service once it's merged to master
|
||||
async getDevices(): Promise<ListResponse<DeviceResponse>> {
|
||||
const r = await this.send("GET", "/devices", null, true, true, null);
|
||||
return new ListResponse(r, DeviceResponse);
|
||||
}
|
||||
|
||||
// Emergency Access APIs
|
||||
|
||||
async getEmergencyAccessTrusted(): Promise<ListResponse<EmergencyAccessGranteeDetailsResponse>> {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { DevicesApiServiceAbstraction } from "../../abstractions/devices/devices-api.service.abstraction";
|
||||
import { DeviceResponse } from "../../abstractions/devices/responses/device.response";
|
||||
import { Utils } from "../../misc/utils";
|
||||
import { ListResponse } from "../../models/response/list.response";
|
||||
import { ApiService } from "../api.service";
|
||||
|
||||
import { TrustedDeviceKeysRequest } from "./requests/trusted-device-keys.request";
|
||||
@ -39,6 +40,11 @@ export class DevicesApiServiceImplementation implements DevicesApiServiceAbstrac
|
||||
return new DeviceResponse(r);
|
||||
}
|
||||
|
||||
async getDevices(): Promise<ListResponse<DeviceResponse>> {
|
||||
const r = await this.apiService.send("GET", "/devices", null, true, true, null);
|
||||
return new ListResponse(r, DeviceResponse);
|
||||
}
|
||||
|
||||
async updateTrustedDeviceKeys(
|
||||
deviceIdentifier: string,
|
||||
devicePublicKeyEncryptedUserSymKey: string,
|
||||
|
Loading…
Reference in New Issue
Block a user