1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 14:23:32 +00:00

[PS-1093] Move Organization Api Calls (#3243)

* Move organization api calls into seperate service

* Remove unneeded unknown

* Address PR feedback
This commit is contained in:
Justin Baur
2022-08-24 12:33:05 -04:00
committed by GitHub
parent 364d2f311e
commit 7145b13df1
39 changed files with 545 additions and 414 deletions

View File

@@ -4,7 +4,6 @@ import { EnvironmentService } from "../abstractions/environment.service";
import { PlatformUtilsService } from "../abstractions/platformUtils.service";
import { TokenService } from "../abstractions/token.service";
import { DeviceType } from "../enums/deviceType";
import { OrganizationApiKeyType } from "../enums/organizationApiKeyType";
import { OrganizationConnectionType } from "../enums/organizationConnectionType";
import { Utils } from "../misc/utils";
import { SetKeyConnectorKeyRequest } from "../models/request/account/setKeyConnectorKeyRequest";
@@ -36,23 +35,14 @@ import { PasswordTokenRequest } from "../models/request/identityToken/passwordTo
import { SsoTokenRequest } from "../models/request/identityToken/ssoTokenRequest";
import { TokenRequestTwoFactor } from "../models/request/identityToken/tokenRequestTwoFactor";
import { ImportCiphersRequest } from "../models/request/importCiphersRequest";
import { ImportDirectoryRequest } from "../models/request/importDirectoryRequest";
import { ImportOrganizationCiphersRequest } from "../models/request/importOrganizationCiphersRequest";
import { KdfRequest } from "../models/request/kdfRequest";
import { KeyConnectorUserKeyRequest } from "../models/request/keyConnectorUserKeyRequest";
import { KeysRequest } from "../models/request/keysRequest";
import { OrganizationSponsorshipCreateRequest } from "../models/request/organization/organizationSponsorshipCreateRequest";
import { OrganizationSponsorshipRedeemRequest } from "../models/request/organization/organizationSponsorshipRedeemRequest";
import { OrganizationSsoRequest } from "../models/request/organization/organizationSsoRequest";
import { OrganizationApiKeyRequest } from "../models/request/organizationApiKeyRequest";
import { OrganizationConnectionRequest } from "../models/request/organizationConnectionRequest";
import { OrganizationCreateRequest } from "../models/request/organizationCreateRequest";
import { OrganizationImportRequest } from "../models/request/organizationImportRequest";
import { OrganizationKeysRequest } from "../models/request/organizationKeysRequest";
import { OrganizationSubscriptionUpdateRequest } from "../models/request/organizationSubscriptionUpdateRequest";
import { OrganizationTaxInfoUpdateRequest } from "../models/request/organizationTaxInfoUpdateRequest";
import { OrganizationUpdateRequest } from "../models/request/organizationUpdateRequest";
import { OrganizationUpgradeRequest } from "../models/request/organizationUpgradeRequest";
import { OrganizationUserAcceptRequest } from "../models/request/organizationUserAcceptRequest";
import { OrganizationUserBulkConfirmRequest } from "../models/request/organizationUserBulkConfirmRequest";
import { OrganizationUserBulkRequest } from "../models/request/organizationUserBulkRequest";
@@ -77,7 +67,6 @@ import { ProviderUserConfirmRequest } from "../models/request/provider/providerU
import { ProviderUserInviteRequest } from "../models/request/provider/providerUserInviteRequest";
import { ProviderUserUpdateRequest } from "../models/request/provider/providerUserUpdateRequest";
import { RegisterRequest } from "../models/request/registerRequest";
import { SeatRequest } from "../models/request/seatRequest";
import { SecretVerificationRequest } from "../models/request/secretVerificationRequest";
import { SelectionReadOnlyRequest } from "../models/request/selectionReadOnlyRequest";
import { SendAccessRequest } from "../models/request/sendAccessRequest";
@@ -98,7 +87,6 @@ import { UpdateTwoFactorEmailRequest } from "../models/request/updateTwoFactorEm
import { UpdateTwoFactorWebAuthnDeleteRequest } from "../models/request/updateTwoFactorWebAuthnDeleteRequest";
import { UpdateTwoFactorWebAuthnRequest } from "../models/request/updateTwoFactorWebAuthnRequest";
import { UpdateTwoFactorYubioOtpRequest } from "../models/request/updateTwoFactorYubioOtpRequest";
import { VerifyBankRequest } from "../models/request/verifyBankRequest";
import { VerifyDeleteRecoverRequest } from "../models/request/verifyDeleteRecoverRequest";
import { VerifyEmailRequest } from "../models/request/verifyEmailRequest";
import { ApiKeyResponse } from "../models/response/apiKeyResponse";
@@ -106,7 +94,6 @@ import { AttachmentResponse } from "../models/response/attachmentResponse";
import { AttachmentUploadDataResponse } from "../models/response/attachmentUploadDataResponse";
import { BillingHistoryResponse } from "../models/response/billingHistoryResponse";
import { BillingPaymentResponse } from "../models/response/billingPaymentResponse";
import { BillingResponse } from "../models/response/billingResponse";
import { BreachAccountResponse } from "../models/response/breachAccountResponse";
import { CipherResponse } from "../models/response/cipherResponse";
import {
@@ -129,18 +116,12 @@ import { IdentityTokenResponse } from "../models/response/identityTokenResponse"
import { IdentityTwoFactorResponse } from "../models/response/identityTwoFactorResponse";
import { KeyConnectorUserKeyResponse } from "../models/response/keyConnectorUserKeyResponse";
import { ListResponse } from "../models/response/listResponse";
import { OrganizationSsoResponse } from "../models/response/organization/organizationSsoResponse";
import { OrganizationApiKeyInformationResponse } from "../models/response/organizationApiKeyInformationResponse";
import { OrganizationAutoEnrollStatusResponse } from "../models/response/organizationAutoEnrollStatusResponse";
import {
OrganizationConnectionConfigApis,
OrganizationConnectionResponse,
} from "../models/response/organizationConnectionResponse";
import { OrganizationExportResponse } from "../models/response/organizationExportResponse";
import { OrganizationKeysResponse } from "../models/response/organizationKeysResponse";
import { OrganizationResponse } from "../models/response/organizationResponse";
import { OrganizationSponsorshipSyncStatusResponse } from "../models/response/organizationSponsorshipSyncStatusResponse";
import { OrganizationSubscriptionResponse } from "../models/response/organizationSubscriptionResponse";
import { OrganizationUserBulkPublicKeyResponse } from "../models/response/organizationUserBulkPublicKeyResponse";
import { OrganizationUserBulkResponse } from "../models/response/organizationUserBulkResponse";
import {
@@ -391,7 +372,7 @@ export class ApiService implements ApiServiceAbstraction {
return new PaymentResponse(r);
}
postAccountPayment(request: PaymentRequest): Promise<any> {
postAccountPayment(request: PaymentRequest): Promise<void> {
return this.send("POST", "/accounts/payment", request, true, false);
}
@@ -431,7 +412,7 @@ export class ApiService implements ApiServiceAbstraction {
return this.send("POST", "/accounts/kdf", request, true, false);
}
async deleteSsoUser(organizationId: string): Promise<any> {
async deleteSsoUser(organizationId: string): Promise<void> {
return this.send("DELETE", "/accounts/sso/" + organizationId, null, true, false);
}
@@ -1067,19 +1048,6 @@ export class ApiService implements ApiServiceAbstraction {
return new OrganizationUserResetPasswordDetailsReponse(r);
}
async getOrganizationAutoEnrollStatus(
identifier: string
): Promise<OrganizationAutoEnrollStatusResponse> {
const r = await this.send(
"GET",
"/organizations/" + identifier + "/auto-enroll-status",
null,
true,
true
);
return new OrganizationAutoEnrollStatusResponse(r);
}
postOrganizationUserInvite(
organizationId: string,
request: OrganizationUserInviteRequest
@@ -1205,7 +1173,7 @@ export class ApiService implements ApiServiceAbstraction {
organizationId: string,
userId: string,
request: OrganizationUserResetPasswordEnrollmentRequest
): Promise<any> {
): Promise<void> {
return this.send(
"PUT",
"/organizations/" + organizationId + "/users/" + userId + "/reset-password-enrollment",
@@ -1308,10 +1276,6 @@ export class ApiService implements ApiServiceAbstraction {
return new ListResponse(r, PlanResponse);
}
async postImportDirectory(organizationId: string, request: ImportDirectoryRequest): Promise<any> {
return this.send("POST", "/organizations/" + organizationId + "/import", request, true, false);
}
async postPublicImportDirectory(request: OrganizationImportRequest): Promise<any> {
return this.send("POST", "/public/organization/import", request, true, false);
}
@@ -1614,21 +1578,6 @@ export class ApiService implements ApiServiceAbstraction {
// Organization APIs
async getOrganization(id: string): Promise<OrganizationResponse> {
const r = await this.send("GET", "/organizations/" + id, null, true, true);
return new OrganizationResponse(r);
}
async getOrganizationBilling(id: string): Promise<BillingResponse> {
const r = await this.send("GET", "/organizations/" + id + "/billing", null, true, true);
return new BillingResponse(r);
}
async getOrganizationSubscription(id: string): Promise<OrganizationSubscriptionResponse> {
const r = await this.send("GET", "/organizations/" + id + "/subscription", null, true, true);
return new OrganizationSubscriptionResponse(r);
}
async getCloudCommunicationsEnabled(): Promise<boolean> {
const r = await this.send("GET", "/organizations/connections/enabled", null, true, true);
return r as boolean;
@@ -1670,159 +1619,6 @@ export class ApiService implements ApiServiceAbstraction {
return this.send("DELETE", "/organizations/connections/" + id, null, true, false);
}
async getOrganizationLicense(id: string, installationId: string): Promise<any> {
return this.send(
"GET",
"/organizations/" + id + "/license?installationId=" + installationId,
null,
true,
true
);
}
async getOrganizationTaxInfo(id: string): Promise<TaxInfoResponse> {
const r = await this.send("GET", "/organizations/" + id + "/tax", null, true, true);
return new TaxInfoResponse(r);
}
async getOrganizationSso(id: string): Promise<OrganizationSsoResponse> {
const r = await this.send("GET", "/organizations/" + id + "/sso", null, true, true);
return new OrganizationSsoResponse(r);
}
async postOrganization(request: OrganizationCreateRequest): Promise<OrganizationResponse> {
const r = await this.send("POST", "/organizations", request, true, true);
return new OrganizationResponse(r);
}
async putOrganization(
id: string,
request: OrganizationUpdateRequest
): Promise<OrganizationResponse> {
const r = await this.send("PUT", "/organizations/" + id, request, true, true);
return new OrganizationResponse(r);
}
async putOrganizationTaxInfo(
id: string,
request: OrganizationTaxInfoUpdateRequest
): Promise<any> {
return this.send("PUT", "/organizations/" + id + "/tax", request, true, false);
}
postLeaveOrganization(id: string): Promise<any> {
return this.send("POST", "/organizations/" + id + "/leave", null, true, false);
}
async postOrganizationLicense(data: FormData): Promise<OrganizationResponse> {
const r = await this.send("POST", "/organizations/license", data, true, true);
return new OrganizationResponse(r);
}
async postOrganizationLicenseUpdate(id: string, data: FormData): Promise<any> {
return this.send("POST", "/organizations/" + id + "/license", data, true, false);
}
async postOrganizationApiKey(
id: string,
request: OrganizationApiKeyRequest
): Promise<ApiKeyResponse> {
const r = await this.send("POST", "/organizations/" + id + "/api-key", request, true, true);
return new ApiKeyResponse(r);
}
async getOrganizationApiKeyInformation(
id: string,
type: OrganizationApiKeyType = null
): Promise<ListResponse<OrganizationApiKeyInformationResponse>> {
const uri =
type === null
? "/organizations/" + id + "/api-key-information"
: "/organizations/" + id + "/api-key-information/" + type;
const r = await this.send("GET", uri, null, true, true);
return new ListResponse(r, OrganizationApiKeyInformationResponse);
}
async postOrganizationRotateApiKey(
id: string,
request: OrganizationApiKeyRequest
): Promise<ApiKeyResponse> {
const r = await this.send(
"POST",
"/organizations/" + id + "/rotate-api-key",
request,
true,
true
);
return new ApiKeyResponse(r);
}
async postOrganizationSso(
id: string,
request: OrganizationSsoRequest
): Promise<OrganizationSsoResponse> {
const r = await this.send("POST", "/organizations/" + id + "/sso", request, true, true);
return new OrganizationSsoResponse(r);
}
async postOrganizationUpgrade(
id: string,
request: OrganizationUpgradeRequest
): Promise<PaymentResponse> {
const r = await this.send("POST", "/organizations/" + id + "/upgrade", request, true, true);
return new PaymentResponse(r);
}
async postOrganizationUpdateSubscription(
id: string,
request: OrganizationSubscriptionUpdateRequest
): Promise<void> {
return this.send("POST", "/organizations/" + id + "/subscription", request, true, false);
}
async postOrganizationSeat(id: string, request: SeatRequest): Promise<PaymentResponse> {
const r = await this.send("POST", "/organizations/" + id + "/seat", request, true, true);
return new PaymentResponse(r);
}
async postOrganizationStorage(id: string, request: StorageRequest): Promise<PaymentResponse> {
const r = await this.send("POST", "/organizations/" + id + "/storage", request, true, true);
return new PaymentResponse(r);
}
postOrganizationPayment(id: string, request: PaymentRequest): Promise<any> {
return this.send("POST", "/organizations/" + id + "/payment", request, true, false);
}
postOrganizationVerifyBank(id: string, request: VerifyBankRequest): Promise<any> {
return this.send("POST", "/organizations/" + id + "/verify-bank", request, true, false);
}
postOrganizationCancel(id: string): Promise<any> {
return this.send("POST", "/organizations/" + id + "/cancel", null, true, false);
}
postOrganizationReinstate(id: string): Promise<any> {
return this.send("POST", "/organizations/" + id + "/reinstate", null, true, false);
}
deleteOrganization(id: string, request: SecretVerificationRequest): Promise<any> {
return this.send("DELETE", "/organizations/" + id, request, true, false);
}
async getOrganizationKeys(id: string): Promise<OrganizationKeysResponse> {
const r = await this.send("GET", "/organizations/" + id + "/keys", null, true, true);
return new OrganizationKeysResponse(r);
}
async postOrganizationKeys(
id: string,
request: OrganizationKeysRequest
): Promise<OrganizationKeysResponse> {
const r = await this.send("POST", "/organizations/" + id + "/keys", request, true, true);
return new OrganizationKeysResponse(r);
}
// Provider APIs
async postProviderSetup(id: string, request: ProviderSetupRequest) {