1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-21 21:11:35 +01:00

create emergency access services

- move api calls to specific api service and refactor
This commit is contained in:
Jacob Fink 2023-10-03 16:46:23 -04:00
parent a78a17a89d
commit 76db4faffb
13 changed files with 209 additions and 147 deletions

View File

@ -1,10 +1,17 @@
import { NgModule, Optional, SkipSelf } from "@angular/core";
import { EmergencyAccessApiService } from "./services/emergency-access/emergency-access-api.service";
import { EmergencyAccessService } from "./services/emergency-access/emergency-access.service";
import { WebauthnLoginApiService } from "./services/webauthn-login/webauthn-login-api.service";
import { WebauthnLoginService } from "./services/webauthn-login/webauthn-login.service";
@NgModule({
providers: [WebauthnLoginService, WebauthnLoginApiService],
providers: [
WebauthnLoginService,
WebauthnLoginApiService,
EmergencyAccessService,
EmergencyAccessApiService,
],
})
export class CoreAuthModule {
constructor(@Optional() @SkipSelf() parentModule?: CoreAuthModule) {

View File

@ -0,0 +1,129 @@
import { Injectable } from "@angular/core";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { PolicyResponse } from "@bitwarden/common/admin-console/models/response/policy.response";
import { EmergencyAccessAcceptRequest } from "@bitwarden/common/auth/models/request/emergency-access-accept.request";
import { EmergencyAccessConfirmRequest } from "@bitwarden/common/auth/models/request/emergency-access-confirm.request";
import { EmergencyAccessInviteRequest } from "@bitwarden/common/auth/models/request/emergency-access-invite.request";
import { EmergencyAccessPasswordRequest } from "@bitwarden/common/auth/models/request/emergency-access-password.request";
import { EmergencyAccessUpdateRequest } from "@bitwarden/common/auth/models/request/emergency-access-update.request";
import {
EmergencyAccessGranteeDetailsResponse,
EmergencyAccessGrantorDetailsResponse,
EmergencyAccessTakeoverResponse,
EmergencyAccessViewResponse,
} from "@bitwarden/common/auth/models/response/emergency-access.response";
import { ListResponse } from "@bitwarden/common/models/response/list.response";
@Injectable()
export class EmergencyAccessApiService {
constructor(private apiService: ApiService) {}
async getEmergencyAccessTrusted(): Promise<ListResponse<EmergencyAccessGranteeDetailsResponse>> {
const r = await this.apiService.send("GET", "/emergency-access/trusted", null, true, true);
return new ListResponse(r, EmergencyAccessGranteeDetailsResponse);
}
async getEmergencyAccessGranted(): Promise<ListResponse<EmergencyAccessGrantorDetailsResponse>> {
const r = await this.apiService.send("GET", "/emergency-access/granted", null, true, true);
return new ListResponse(r, EmergencyAccessGrantorDetailsResponse);
}
async getEmergencyAccess(id: string): Promise<EmergencyAccessGranteeDetailsResponse> {
const r = await this.apiService.send("GET", "/emergency-access/" + id, null, true, true);
return new EmergencyAccessGranteeDetailsResponse(r);
}
async getEmergencyGrantorPolicies(id: string): Promise<ListResponse<PolicyResponse>> {
const r = await this.apiService.send(
"GET",
"/emergency-access/" + id + "/policies",
null,
true,
true
);
return new ListResponse(r, PolicyResponse);
}
putEmergencyAccess(id: string, request: EmergencyAccessUpdateRequest): Promise<any> {
return this.apiService.send("PUT", "/emergency-access/" + id, request, true, false);
}
deleteEmergencyAccess(id: string): Promise<any> {
return this.apiService.send("DELETE", "/emergency-access/" + id, null, true, false);
}
postEmergencyAccessInvite(request: EmergencyAccessInviteRequest): Promise<any> {
return this.apiService.send("POST", "/emergency-access/invite", request, true, false);
}
postEmergencyAccessReinvite(id: string): Promise<any> {
return this.apiService.send("POST", "/emergency-access/" + id + "/reinvite", null, true, false);
}
postEmergencyAccessAccept(id: string, request: EmergencyAccessAcceptRequest): Promise<any> {
return this.apiService.send(
"POST",
"/emergency-access/" + id + "/accept",
request,
true,
false
);
}
postEmergencyAccessConfirm(id: string, request: EmergencyAccessConfirmRequest): Promise<any> {
return this.apiService.send(
"POST",
"/emergency-access/" + id + "/confirm",
request,
true,
false
);
}
postEmergencyAccessInitiate(id: string): Promise<any> {
return this.apiService.send("POST", "/emergency-access/" + id + "/initiate", null, true, false);
}
postEmergencyAccessApprove(id: string): Promise<any> {
return this.apiService.send("POST", "/emergency-access/" + id + "/approve", null, true, false);
}
postEmergencyAccessReject(id: string): Promise<any> {
return this.apiService.send("POST", "/emergency-access/" + id + "/reject", null, true, false);
}
async postEmergencyAccessTakeover(id: string): Promise<EmergencyAccessTakeoverResponse> {
const r = await this.apiService.send(
"POST",
"/emergency-access/" + id + "/takeover",
null,
true,
true
);
return new EmergencyAccessTakeoverResponse(r);
}
async postEmergencyAccessPassword(
id: string,
request: EmergencyAccessPasswordRequest
): Promise<any> {
await this.apiService.send(
"POST",
"/emergency-access/" + id + "/password",
request,
true,
true
);
}
async postEmergencyAccessView(id: string): Promise<EmergencyAccessViewResponse> {
const r = await this.apiService.send(
"POST",
"/emergency-access/" + id + "/view",
null,
true,
true
);
return new EmergencyAccessViewResponse(r);
}
}

View File

@ -0,0 +1,22 @@
import { MockProxy } from "jest-mock-extended";
import { EmergencyAccessApiService } from "./emergency-access-api.service";
import { EmergencyAccessService } from "./emergency-access.service";
describe("EmergencyAccessService", () => {
let apiService!: MockProxy<EmergencyAccessApiService>;
let emergencyAccessService: EmergencyAccessService;
beforeAll(() => {
emergencyAccessService = new EmergencyAccessService();
});
// describe("createCredential", () => {
// it("should return undefined when navigator.credentials throws", async () => {
// credentials.create.mockRejectedValue(new Error("Mocked error"));
// const options = createCredentialCreateOptions();
// const result = await webauthnService.createCredential(options);
// expect(result).toBeUndefined();
// });
});

View File

@ -0,0 +1,6 @@
import { Injectable } from "@angular/core";
@Injectable()
export class EmergencyAccessService {
constructor() {}
}

View File

@ -35,6 +35,7 @@ import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
import { MigrateFromLegacyEncryptionService } from "./migrate-legacy-encryption.service";
import { EmergencyAccessApiService } from "../core/services/emergency-access/emergency-access-api.service";
describe("migrateFromLegacyEncryptionService", () => {
let migrateFromLegacyEncryptionService: MigrateFromLegacyEncryptionService;
@ -42,6 +43,7 @@ describe("migrateFromLegacyEncryptionService", () => {
const organizationService = mock<OrganizationService>();
const organizationApiService = mock<OrganizationApiService>();
const organizationUserService = mock<OrganizationUserService>();
const emergencyAccessApiService = mock<EmergencyAccessApiService>();
const apiService = mock<ApiService>();
const encryptService = mock<EncryptService>();
const cryptoService = mock<CryptoService>();
@ -60,6 +62,7 @@ describe("migrateFromLegacyEncryptionService", () => {
organizationService,
organizationApiService,
organizationUserService,
emergencyAccessApiService,
apiService,
cryptoService,
encryptService,
@ -211,7 +214,7 @@ describe("migrateFromLegacyEncryptionService", () => {
createMockEmergencyAccess("4", "EA 4", EmergencyAccessStatusType.RecoveryApproved),
],
} as ListResponse<EmergencyAccessGranteeDetailsResponse>;
apiService.getEmergencyAccessTrusted.mockResolvedValue(mockEmergencyAccess);
emergencyAccessApiService.getEmergencyAccessTrusted.mockResolvedValue(mockEmergencyAccess);
apiService.getUserPublicKey.mockResolvedValue({
userId: "mockUserId",
publicKey: "mockPublicKey",
@ -227,11 +230,11 @@ describe("migrateFromLegacyEncryptionService", () => {
it("Only updates emergency accesses with allowed statuses", async () => {
await migrateFromLegacyEncryptionService.updateEmergencyAccesses(mockUserKey);
expect(apiService.putEmergencyAccess).not.toHaveBeenCalledWith(
expect(emergencyAccessApiService.putEmergencyAccess).not.toHaveBeenCalledWith(
"0",
expect.any(EmergencyAccessUpdateRequest)
);
expect(apiService.putEmergencyAccess).not.toHaveBeenCalledWith(
expect(emergencyAccessApiService.putEmergencyAccess).not.toHaveBeenCalledWith(
"1",
expect.any(EmergencyAccessUpdateRequest)
);

View File

@ -22,6 +22,7 @@ import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folde
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { CipherWithIdRequest } from "@bitwarden/common/vault/models/request/cipher-with-id.request";
import { FolderWithIdRequest } from "@bitwarden/common/vault/models/request/folder-with-id.request";
import { EmergencyAccessApiService } from "../core/services/emergency-access/emergency-access-api.service";
// TODO: PM-3797 - This service should be expanded and used for user key rotations in change-password.component.ts
@Injectable()
@ -30,6 +31,7 @@ export class MigrateFromLegacyEncryptionService {
private organizationService: OrganizationService,
private organizationApiService: OrganizationApiServiceAbstraction,
private organizationUserService: OrganizationUserService,
private emergencyAccessApiService: EmergencyAccessApiService,
private apiService: ApiService,
private cryptoService: CryptoService,
private encryptService: EncryptService,
@ -103,7 +105,7 @@ export class MigrateFromLegacyEncryptionService {
* @param newUserKey The new user key
*/
async updateEmergencyAccesses(newUserKey: UserKey) {
const emergencyAccess = await this.apiService.getEmergencyAccessTrusted();
const emergencyAccess = await this.emergencyAccessApiService.getEmergencyAccessTrusted();
// Any Invited or Accepted requests won't have the key yet, so we don't need to update them
const allowedStatuses = new Set([
EmergencyAccessStatusType.Confirmed,
@ -125,7 +127,7 @@ export class MigrateFromLegacyEncryptionService {
updateRequest.waitTimeDays = details.waitTimeDays;
updateRequest.keyEncrypted = encryptedKey.encryptedString;
await this.apiService.putEmergencyAccess(details.id, updateRequest);
await this.emergencyAccessApiService.putEmergencyAccess(details.id, updateRequest);
}
}

View File

@ -39,6 +39,7 @@ import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.serv
import { CipherWithIdRequest } from "@bitwarden/common/vault/models/request/cipher-with-id.request";
import { FolderWithIdRequest } from "@bitwarden/common/vault/models/request/folder-with-id.request";
import { DialogService } from "@bitwarden/components";
import { EmergencyAccessApiService } from "../core/services/emergency-access/emergency-access-api.service";
@Component({
selector: "app-change-password",
@ -65,6 +66,7 @@ export class ChangePasswordComponent extends BaseChangePasswordComponent {
private folderService: FolderService,
private cipherService: CipherService,
private syncService: SyncService,
private emergencyAccessApiService: EmergencyAccessApiService,
private apiService: ApiService,
private sendService: SendService,
private organizationService: OrganizationService,
@ -273,7 +275,7 @@ export class ChangePasswordComponent extends BaseChangePasswordComponent {
}
private async updateEmergencyAccesses(encKey: SymmetricCryptoKey) {
const emergencyAccess = await this.apiService.getEmergencyAccessTrusted();
const emergencyAccess = await this.emergencyAccessApiService.getEmergencyAccessTrusted();
const allowedStatuses = [
EmergencyAccessStatusType.Confirmed,
EmergencyAccessStatusType.RecoveryInitiated,
@ -293,7 +295,7 @@ export class ChangePasswordComponent extends BaseChangePasswordComponent {
updateRequest.waitTimeDays = details.waitTimeDays;
updateRequest.keyEncrypted = encryptedKey.encryptedString;
await this.apiService.putEmergencyAccess(details.id, updateRequest);
await this.emergencyAccessApiService.putEmergencyAccess(details.id, updateRequest);
}
}

View File

@ -1,12 +1,12 @@
import { Component, EventEmitter, Input, OnInit, Output } from "@angular/core";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { EmergencyAccessType } from "@bitwarden/common/auth/enums/emergency-access-type";
import { EmergencyAccessInviteRequest } from "@bitwarden/common/auth/models/request/emergency-access-invite.request";
import { EmergencyAccessUpdateRequest } from "@bitwarden/common/auth/models/request/emergency-access-update.request";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { EmergencyAccessApiService } from "../../core/services/emergency-access/emergency-access-api.service";
@Component({
selector: "emergency-access-add-edit",
@ -32,7 +32,7 @@ export class EmergencyAccessAddEditComponent implements OnInit {
waitTime: number;
constructor(
private apiService: ApiService,
private emergencyAccessApiService: EmergencyAccessApiService,
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService,
private logService: LogService
@ -54,7 +54,9 @@ export class EmergencyAccessAddEditComponent implements OnInit {
this.editMode = true;
this.title = this.i18nService.t("editEmergencyContact");
try {
const emergencyAccess = await this.apiService.getEmergencyAccess(this.emergencyAccessId);
const emergencyAccess = await this.emergencyAccessApiService.getEmergencyAccess(
this.emergencyAccessId
);
this.type = emergencyAccess.type;
this.waitTime = emergencyAccess.waitTimeDays;
} catch (e) {
@ -75,14 +77,17 @@ export class EmergencyAccessAddEditComponent implements OnInit {
request.type = this.type;
request.waitTimeDays = this.waitTime;
this.formPromise = this.apiService.putEmergencyAccess(this.emergencyAccessId, request);
this.formPromise = this.emergencyAccessApiService.putEmergencyAccess(
this.emergencyAccessId,
request
);
} else {
const request = new EmergencyAccessInviteRequest();
request.email = this.email.trim();
request.type = this.type;
request.waitTimeDays = this.waitTime;
this.formPromise = this.apiService.postEmergencyAccessInvite(request);
this.formPromise = this.emergencyAccessApiService.postEmergencyAccessInvite(request);
}
await this.formPromise;

View File

@ -2,7 +2,6 @@ import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from "@angu
import { takeUntil } from "rxjs";
import { ChangePasswordComponent } from "@bitwarden/angular/auth/components/change-password.component";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
import { PolicyData } from "@bitwarden/common/admin-console/models/data/policy.data";
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
@ -22,6 +21,7 @@ import {
} from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
import { PasswordGenerationServiceAbstraction } from "@bitwarden/common/tools/generator/password";
import { DialogService } from "@bitwarden/components";
import { EmergencyAccessApiService } from "../../core/services/emergency-access/emergency-access-api.service";
@Component({
selector: "emergency-access-takeover",
@ -49,7 +49,7 @@ export class EmergencyAccessTakeoverComponent
passwordGenerationService: PasswordGenerationServiceAbstraction,
platformUtilsService: PlatformUtilsService,
policyService: PolicyService,
private apiService: ApiService,
private emergencyAccessApiService: EmergencyAccessApiService,
private logService: LogService,
dialogService: DialogService
) {
@ -66,7 +66,9 @@ export class EmergencyAccessTakeoverComponent
}
async ngOnInit() {
const response = await this.apiService.getEmergencyGrantorPolicies(this.emergencyAccessId);
const response = await this.emergencyAccessApiService.getEmergencyGrantorPolicies(
this.emergencyAccessId
);
if (response.data != null && response.data.length > 0) {
const policies = response.data.map(
(policyResponse: PolicyResponse) => new Policy(new PolicyData(policyResponse))
@ -89,7 +91,7 @@ export class EmergencyAccessTakeoverComponent
return;
}
const takeoverResponse = await this.apiService.postEmergencyAccessTakeover(
const takeoverResponse = await this.emergencyAccessApiService.postEmergencyAccessTakeover(
this.emergencyAccessId
);
@ -123,7 +125,7 @@ export class EmergencyAccessTakeoverComponent
request.newMasterPasswordHash = masterKeyHash;
request.key = encKey[1].encryptedString;
this.apiService.postEmergencyAccessPassword(this.emergencyAccessId, request);
this.emergencyAccessApiService.postEmergencyAccessPassword(this.emergencyAccessId, request);
try {
this.onDone.emit();

View File

@ -2,7 +2,6 @@ import { Component, OnInit, ViewChild, ViewContainerRef } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { EmergencyAccessViewResponse } from "@bitwarden/common/auth/models/response/emergency-access.response";
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
import {
@ -13,6 +12,7 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
import { CipherData } from "@bitwarden/common/vault/models/data/cipher.data";
import { Cipher } from "@bitwarden/common/vault/models/domain/cipher";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { EmergencyAccessApiService } from "../../core/services/emergency-access/emergency-access-api.service";
import { EmergencyAccessAttachmentsComponent } from "./emergency-access-attachments.component";
import { EmergencyAddEditComponent } from "./emergency-add-edit.component";
@ -38,7 +38,7 @@ export class EmergencyAccessViewComponent implements OnInit {
private modalService: ModalService,
private router: Router,
private route: ActivatedRoute,
private apiService: ApiService
private emergencyAccessApiService: EmergencyAccessApiService
) {}
ngOnInit() {
@ -69,7 +69,7 @@ export class EmergencyAccessViewComponent implements OnInit {
}
async load() {
const response = await this.apiService.postEmergencyAccessView(this.id);
const response = await this.emergencyAccessApiService.postEmergencyAccessView(this.id);
this.ciphers = await this.getAllCiphers(response);
this.loaded = true;
}

View File

@ -19,6 +19,7 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { DialogService } from "@bitwarden/components";
import { EmergencyAccessApiService } from "../../core/services/emergency-access/emergency-access-api.service";
import { EmergencyAccessAddEditComponent } from "./emergency-access-add-edit.component";
import { EmergencyAccessConfirmComponent } from "./emergency-access-confirm.component";
@ -46,6 +47,7 @@ export class EmergencyAccessComponent implements OnInit {
isOrganizationOwner: boolean;
constructor(
private emergencyAccessApiService: EmergencyAccessApiService,
private apiService: ApiService,
private i18nService: I18nService,
private modalService: ModalService,
@ -67,8 +69,8 @@ export class EmergencyAccessComponent implements OnInit {
}
async load() {
this.trustedContacts = (await this.apiService.getEmergencyAccessTrusted()).data;
this.grantedContacts = (await this.apiService.getEmergencyAccessGranted()).data;
this.trustedContacts = (await this.emergencyAccessApiService.getEmergencyAccessTrusted()).data;
this.grantedContacts = (await this.emergencyAccessApiService.getEmergencyAccessGranted()).data;
this.loaded = true;
}
@ -109,7 +111,7 @@ export class EmergencyAccessComponent implements OnInit {
if (this.actionPromise != null) {
return;
}
this.actionPromise = this.apiService.postEmergencyAccessReinvite(contact.id);
this.actionPromise = this.emergencyAccessApiService.postEmergencyAccessReinvite(contact.id);
await this.actionPromise;
this.platformUtilsService.showToast(
"success",
@ -182,7 +184,7 @@ export class EmergencyAccessComponent implements OnInit {
}
try {
await this.apiService.deleteEmergencyAccess(details.id);
await this.emergencyAccessApiService.deleteEmergencyAccess(details.id);
this.platformUtilsService.showToast(
"success",
null,
@ -214,7 +216,7 @@ export class EmergencyAccessComponent implements OnInit {
return false;
}
await this.apiService.postEmergencyAccessInitiate(details.id);
await this.emergencyAccessApiService.postEmergencyAccessInitiate(details.id);
details.status = EmergencyAccessStatusType.RecoveryInitiated;
this.platformUtilsService.showToast(
@ -243,7 +245,7 @@ export class EmergencyAccessComponent implements OnInit {
return false;
}
await this.apiService.postEmergencyAccessApprove(details.id);
await this.emergencyAccessApiService.postEmergencyAccessApprove(details.id);
details.status = EmergencyAccessStatusType.RecoveryApproved;
this.platformUtilsService.showToast(
@ -254,7 +256,7 @@ export class EmergencyAccessComponent implements OnInit {
}
async reject(details: EmergencyAccessGranteeDetailsResponse) {
await this.apiService.postEmergencyAccessReject(details.id);
await this.emergencyAccessApiService.postEmergencyAccessReject(details.id);
details.status = EmergencyAccessStatusType.Confirmed;
this.platformUtilsService.showToast(
@ -321,6 +323,6 @@ export class EmergencyAccessComponent implements OnInit {
const encryptedKey = await this.cryptoService.rsaEncrypt(userKey.key, publicKey);
const request = new EmergencyAccessConfirmRequest();
request.key = encryptedKey.encryptedString;
await this.apiService.postEmergencyAccessConfirm(details.id, request);
await this.emergencyAccessApiService.postEmergencyAccessConfirm(details.id, request);
}
}

View File

@ -19,7 +19,6 @@ import {
} from "../admin-console/models/response/organization-connection.response";
import { OrganizationExportResponse } from "../admin-console/models/response/organization-export.response";
import { OrganizationSponsorshipSyncStatusResponse } from "../admin-console/models/response/organization-sponsorship-sync-status.response";
import { PolicyResponse } from "../admin-console/models/response/policy.response";
import {
ProviderOrganizationOrganizationDetailsResponse,
ProviderOrganizationResponse,
@ -35,11 +34,6 @@ import { SelectionReadOnlyResponse } from "../admin-console/models/response/sele
import { DeviceVerificationRequest } from "../auth/models/request/device-verification.request";
import { EmailTokenRequest } from "../auth/models/request/email-token.request";
import { EmailRequest } from "../auth/models/request/email.request";
import { EmergencyAccessAcceptRequest } from "../auth/models/request/emergency-access-accept.request";
import { EmergencyAccessConfirmRequest } from "../auth/models/request/emergency-access-confirm.request";
import { EmergencyAccessInviteRequest } from "../auth/models/request/emergency-access-invite.request";
import { EmergencyAccessPasswordRequest } from "../auth/models/request/emergency-access-password.request";
import { EmergencyAccessUpdateRequest } from "../auth/models/request/emergency-access-update.request";
import { PasswordTokenRequest } from "../auth/models/request/identity-token/password-token.request";
import { SsoTokenRequest } from "../auth/models/request/identity-token/sso-token.request";
import { UserApiTokenRequest } from "../auth/models/request/identity-token/user-api-token.request";
@ -65,12 +59,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 {
EmergencyAccessGranteeDetailsResponse,
EmergencyAccessGrantorDetailsResponse,
EmergencyAccessTakeoverResponse,
EmergencyAccessViewResponse,
} from "../auth/models/response/emergency-access.response";
import { IdentityCaptchaResponse } from "../auth/models/response/identity-captcha.response";
import { IdentityTokenResponse } from "../auth/models/response/identity-token.response";
import { IdentityTwoFactorResponse } from "../auth/models/response/identity-two-factor.response";
@ -366,25 +354,6 @@ export abstract class ApiService {
request: DeviceVerificationRequest
) => Promise<DeviceVerificationResponse>;
getEmergencyAccessTrusted: () => Promise<ListResponse<EmergencyAccessGranteeDetailsResponse>>;
getEmergencyAccessGranted: () => Promise<ListResponse<EmergencyAccessGrantorDetailsResponse>>;
getEmergencyAccess: (id: string) => Promise<EmergencyAccessGranteeDetailsResponse>;
getEmergencyGrantorPolicies: (id: string) => Promise<ListResponse<PolicyResponse>>;
putEmergencyAccess: (id: string, request: EmergencyAccessUpdateRequest) => Promise<any>;
deleteEmergencyAccess: (id: string) => Promise<any>;
postEmergencyAccessInvite: (request: EmergencyAccessInviteRequest) => Promise<any>;
postEmergencyAccessReinvite: (id: string) => Promise<any>;
postEmergencyAccessAccept: (id: string, request: EmergencyAccessAcceptRequest) => Promise<any>;
postEmergencyAccessConfirm: (id: string, request: EmergencyAccessConfirmRequest) => Promise<any>;
postEmergencyAccessInitiate: (id: string) => Promise<any>;
postEmergencyAccessApprove: (id: string) => Promise<any>;
postEmergencyAccessReject: (id: string) => Promise<any>;
postEmergencyAccessTakeover: (id: string) => Promise<EmergencyAccessTakeoverResponse>;
postEmergencyAccessPassword: (
id: string,
request: EmergencyAccessPasswordRequest
) => Promise<any>;
postEmergencyAccessView: (id: string) => Promise<EmergencyAccessViewResponse>;
getCloudCommunicationsEnabled: () => Promise<boolean>;
abstract getOrganizationConnection<TConfig extends OrganizationConnectionConfigApis>(
id: string,

View File

@ -20,7 +20,6 @@ import {
} from "../admin-console/models/response/organization-connection.response";
import { OrganizationExportResponse } from "../admin-console/models/response/organization-export.response";
import { OrganizationSponsorshipSyncStatusResponse } from "../admin-console/models/response/organization-sponsorship-sync-status.response";
import { PolicyResponse } from "../admin-console/models/response/policy.response";
import {
ProviderOrganizationOrganizationDetailsResponse,
ProviderOrganizationResponse,
@ -37,11 +36,6 @@ import { TokenService } from "../auth/abstractions/token.service";
import { DeviceVerificationRequest } from "../auth/models/request/device-verification.request";
import { EmailTokenRequest } from "../auth/models/request/email-token.request";
import { EmailRequest } from "../auth/models/request/email.request";
import { EmergencyAccessAcceptRequest } from "../auth/models/request/emergency-access-accept.request";
import { EmergencyAccessConfirmRequest } from "../auth/models/request/emergency-access-confirm.request";
import { EmergencyAccessInviteRequest } from "../auth/models/request/emergency-access-invite.request";
import { EmergencyAccessPasswordRequest } from "../auth/models/request/emergency-access-password.request";
import { EmergencyAccessUpdateRequest } from "../auth/models/request/emergency-access-update.request";
import { DeviceRequest } from "../auth/models/request/identity-token/device.request";
import { PasswordTokenRequest } from "../auth/models/request/identity-token/password-token.request";
import { SsoTokenRequest } from "../auth/models/request/identity-token/sso-token.request";
@ -69,12 +63,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 {
EmergencyAccessGranteeDetailsResponse,
EmergencyAccessGrantorDetailsResponse,
EmergencyAccessTakeoverResponse,
EmergencyAccessViewResponse,
} from "../auth/models/response/emergency-access.response";
import { IdentityCaptchaResponse } from "../auth/models/response/identity-captcha.response";
import { IdentityTokenResponse } from "../auth/models/response/identity-token.response";
import { IdentityTwoFactorResponse } from "../auth/models/response/identity-two-factor.response";
@ -1123,81 +1111,6 @@ export class ApiService implements ApiServiceAbstraction {
return new DeviceVerificationResponse(r);
}
// Emergency Access APIs
async getEmergencyAccessTrusted(): Promise<ListResponse<EmergencyAccessGranteeDetailsResponse>> {
const r = await this.send("GET", "/emergency-access/trusted", null, true, true);
return new ListResponse(r, EmergencyAccessGranteeDetailsResponse);
}
async getEmergencyAccessGranted(): Promise<ListResponse<EmergencyAccessGrantorDetailsResponse>> {
const r = await this.send("GET", "/emergency-access/granted", null, true, true);
return new ListResponse(r, EmergencyAccessGrantorDetailsResponse);
}
async getEmergencyAccess(id: string): Promise<EmergencyAccessGranteeDetailsResponse> {
const r = await this.send("GET", "/emergency-access/" + id, null, true, true);
return new EmergencyAccessGranteeDetailsResponse(r);
}
async getEmergencyGrantorPolicies(id: string): Promise<ListResponse<PolicyResponse>> {
const r = await this.send("GET", "/emergency-access/" + id + "/policies", null, true, true);
return new ListResponse(r, PolicyResponse);
}
putEmergencyAccess(id: string, request: EmergencyAccessUpdateRequest): Promise<any> {
return this.send("PUT", "/emergency-access/" + id, request, true, false);
}
deleteEmergencyAccess(id: string): Promise<any> {
return this.send("DELETE", "/emergency-access/" + id, null, true, false);
}
postEmergencyAccessInvite(request: EmergencyAccessInviteRequest): Promise<any> {
return this.send("POST", "/emergency-access/invite", request, true, false);
}
postEmergencyAccessReinvite(id: string): Promise<any> {
return this.send("POST", "/emergency-access/" + id + "/reinvite", null, true, false);
}
postEmergencyAccessAccept(id: string, request: EmergencyAccessAcceptRequest): Promise<any> {
return this.send("POST", "/emergency-access/" + id + "/accept", request, true, false);
}
postEmergencyAccessConfirm(id: string, request: EmergencyAccessConfirmRequest): Promise<any> {
return this.send("POST", "/emergency-access/" + id + "/confirm", request, true, false);
}
postEmergencyAccessInitiate(id: string): Promise<any> {
return this.send("POST", "/emergency-access/" + id + "/initiate", null, true, false);
}
postEmergencyAccessApprove(id: string): Promise<any> {
return this.send("POST", "/emergency-access/" + id + "/approve", null, true, false);
}
postEmergencyAccessReject(id: string): Promise<any> {
return this.send("POST", "/emergency-access/" + id + "/reject", null, true, false);
}
async postEmergencyAccessTakeover(id: string): Promise<EmergencyAccessTakeoverResponse> {
const r = await this.send("POST", "/emergency-access/" + id + "/takeover", null, true, true);
return new EmergencyAccessTakeoverResponse(r);
}
async postEmergencyAccessPassword(
id: string,
request: EmergencyAccessPasswordRequest
): Promise<any> {
await this.send("POST", "/emergency-access/" + id + "/password", request, true, true);
}
async postEmergencyAccessView(id: string): Promise<EmergencyAccessViewResponse> {
const r = await this.send("POST", "/emergency-access/" + id + "/view", null, true, true);
return new EmergencyAccessViewResponse(r);
}
// Organization APIs
async getCloudCommunicationsEnabled(): Promise<boolean> {