mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 21:33:27 +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:
@@ -5,6 +5,7 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { PolicyApiServiceAbstraction } from "@bitwarden/common/abstractions/policy/policy-api.service.abstraction";
|
||||
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
||||
@@ -34,7 +35,8 @@ export class AcceptOrganizationComponent extends BaseAcceptComponent {
|
||||
private cryptoService: CryptoService,
|
||||
private policyApiService: PolicyApiServiceAbstraction,
|
||||
private policyService: PolicyService,
|
||||
private logService: LogService
|
||||
private logService: LogService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {
|
||||
super(router, platformUtilsService, i18nService, route, stateService);
|
||||
}
|
||||
@@ -74,7 +76,7 @@ export class AcceptOrganizationComponent extends BaseAcceptComponent {
|
||||
request.token = qParams.token;
|
||||
|
||||
if (await this.performResetPasswordAutoEnroll(qParams)) {
|
||||
const response = await this.apiService.getOrganizationKeys(qParams.organizationId);
|
||||
const response = await this.organizationApiService.getKeys(qParams.organizationId);
|
||||
|
||||
if (response == null) {
|
||||
throw new Error(this.i18nService.t("resetPasswordOrgKeysError"));
|
||||
@@ -92,7 +94,7 @@ export class AcceptOrganizationComponent extends BaseAcceptComponent {
|
||||
return request;
|
||||
}
|
||||
|
||||
private async performResetPasswordAutoEnroll(qParams: any): Promise<boolean> {
|
||||
private async performResetPasswordAutoEnroll(qParams: Params): Promise<boolean> {
|
||||
let policyList: Policy[] = null;
|
||||
try {
|
||||
const policies = await this.policyApiService.getPoliciesByToken(
|
||||
|
||||
@@ -6,6 +6,7 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PasswordGenerationService } from "@bitwarden/common/abstractions/passwordGeneration.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { PolicyApiServiceAbstraction } from "@bitwarden/common/abstractions/policy/policy-api.service.abstraction";
|
||||
@@ -30,7 +31,8 @@ export class SetPasswordComponent extends BaseSetPasswordComponent {
|
||||
router: Router,
|
||||
syncService: SyncService,
|
||||
route: ActivatedRoute,
|
||||
stateService: StateService
|
||||
stateService: StateService,
|
||||
organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {
|
||||
super(
|
||||
i18nService,
|
||||
@@ -44,7 +46,8 @@ export class SetPasswordComponent extends BaseSetPasswordComponent {
|
||||
apiService,
|
||||
syncService,
|
||||
route,
|
||||
stateService
|
||||
stateService,
|
||||
organizationApiService
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
|
||||
import { OrganizationService } from "@bitwarden/common/abstractions/organization.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
||||
import { SyncService } from "@bitwarden/common/abstractions/sync.service";
|
||||
@@ -34,7 +35,8 @@ export class BillingComponent extends OrganizationPlansComponent {
|
||||
organizationService: OrganizationService,
|
||||
logService: LogService,
|
||||
messagingService: MessagingService,
|
||||
formBuilder: UntypedFormBuilder
|
||||
formBuilder: UntypedFormBuilder,
|
||||
organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {
|
||||
super(
|
||||
apiService,
|
||||
@@ -47,7 +49,8 @@ export class BillingComponent extends OrganizationPlansComponent {
|
||||
organizationService,
|
||||
logService,
|
||||
messagingService,
|
||||
formBuilder
|
||||
formBuilder,
|
||||
organizationApiService
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ export abstract class BasePeopleComponent<
|
||||
users: UserType[] = [];
|
||||
pagedUsers: UserType[] = [];
|
||||
searchText: string;
|
||||
actionPromise: Promise<any>;
|
||||
actionPromise: Promise<void>;
|
||||
|
||||
protected allUsers: UserType[] = [];
|
||||
protected activeUsers: UserType[] = [];
|
||||
@@ -111,11 +111,11 @@ export abstract class BasePeopleComponent<
|
||||
|
||||
abstract edit(user: UserType): void;
|
||||
abstract getUsers(): Promise<ListResponse<UserType>>;
|
||||
abstract deleteUser(id: string): Promise<any>;
|
||||
abstract revokeUser(id: string): Promise<any>;
|
||||
abstract restoreUser(id: string): Promise<any>;
|
||||
abstract reinviteUser(id: string): Promise<any>;
|
||||
abstract confirmUser(user: UserType, publicKey: Uint8Array): Promise<any>;
|
||||
abstract deleteUser(id: string): Promise<void>;
|
||||
abstract revokeUser(id: string): Promise<void>;
|
||||
abstract restoreUser(id: string): Promise<void>;
|
||||
abstract reinviteUser(id: string): Promise<void>;
|
||||
abstract confirmUser(user: UserType, publicKey: Uint8Array): Promise<void>;
|
||||
|
||||
async load() {
|
||||
const response = await this.getUsers();
|
||||
|
||||
@@ -11,6 +11,7 @@ import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { OrganizationService } from "@bitwarden/common/abstractions/organization.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { PolicyApiServiceAbstraction } from "@bitwarden/common/abstractions/policy/policy-api.service.abstraction";
|
||||
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
||||
@@ -92,7 +93,8 @@ export class PeopleComponent
|
||||
userNamePipe: UserNamePipe,
|
||||
private syncService: SyncService,
|
||||
stateService: StateService,
|
||||
private organizationService: OrganizationService
|
||||
private organizationService: OrganizationService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {
|
||||
super(
|
||||
apiService,
|
||||
@@ -125,7 +127,7 @@ export class PeopleComponent
|
||||
const orgShareKey = await this.cryptoService.getOrgKey(this.organizationId);
|
||||
const orgKeys = await this.cryptoService.makeKeyPair(orgShareKey);
|
||||
const request = new OrganizationKeysRequest(orgKeys[0], orgKeys[1].encryptedString);
|
||||
const response = await this.apiService.postOrganizationKeys(this.organizationId, request);
|
||||
const response = await this.organizationApiService.updateKeys(this.organizationId, request);
|
||||
if (response != null) {
|
||||
this.orgHasKeys = response.publicKey != null && response.privateKey != null;
|
||||
await this.syncService.fullSync(true); // Replace oganizations with new data
|
||||
@@ -161,26 +163,26 @@ export class PeopleComponent
|
||||
return this.apiService.getOrganizationUsers(this.organizationId);
|
||||
}
|
||||
|
||||
deleteUser(id: string): Promise<any> {
|
||||
deleteUser(id: string): Promise<void> {
|
||||
return this.apiService.deleteOrganizationUser(this.organizationId, id);
|
||||
}
|
||||
|
||||
revokeUser(id: string): Promise<any> {
|
||||
revokeUser(id: string): Promise<void> {
|
||||
return this.apiService.revokeOrganizationUser(this.organizationId, id);
|
||||
}
|
||||
|
||||
restoreUser(id: string): Promise<any> {
|
||||
restoreUser(id: string): Promise<void> {
|
||||
return this.apiService.restoreOrganizationUser(this.organizationId, id);
|
||||
}
|
||||
|
||||
reinviteUser(id: string): Promise<any> {
|
||||
reinviteUser(id: string): Promise<void> {
|
||||
return this.apiService.postOrganizationUserReinvite(this.organizationId, id);
|
||||
}
|
||||
|
||||
async confirmUser(
|
||||
user: OrganizationUserUserDetailsResponse,
|
||||
publicKey: Uint8Array
|
||||
): Promise<any> {
|
||||
): Promise<void> {
|
||||
const orgKey = await this.cryptoService.getOrgKey(this.organizationId);
|
||||
const key = await this.cryptoService.rsaEncrypt(orgKey.key, publicKey.buffer);
|
||||
const request = new OrganizationUserConfirmRequest();
|
||||
|
||||
@@ -7,6 +7,7 @@ import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { OrganizationService } from "@bitwarden/common/abstractions/organization.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { SyncService } from "@bitwarden/common/abstractions/sync.service";
|
||||
import { OrganizationKeysRequest } from "@bitwarden/common/models/request/organizationKeysRequest";
|
||||
@@ -39,8 +40,8 @@ export class AccountComponent {
|
||||
loading = true;
|
||||
canUseApi = false;
|
||||
org: OrganizationResponse;
|
||||
formPromise: Promise<any>;
|
||||
taxFormPromise: Promise<any>;
|
||||
formPromise: Promise<boolean>;
|
||||
taxFormPromise: Promise<unknown>;
|
||||
|
||||
private organizationId: string;
|
||||
|
||||
@@ -54,7 +55,8 @@ export class AccountComponent {
|
||||
private cryptoService: CryptoService,
|
||||
private logService: LogService,
|
||||
private router: Router,
|
||||
private organizationService: OrganizationService
|
||||
private organizationService: OrganizationService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
@@ -66,7 +68,7 @@ export class AccountComponent {
|
||||
await this.organizationService.get(this.organizationId)
|
||||
).canManageBilling;
|
||||
try {
|
||||
this.org = await this.apiService.getOrganization(this.organizationId);
|
||||
this.org = await this.organizationApiService.get(this.organizationId);
|
||||
this.canUseApi = this.org.useApi;
|
||||
} catch (e) {
|
||||
this.logService.error(e);
|
||||
@@ -90,7 +92,7 @@ export class AccountComponent {
|
||||
request.keys = new OrganizationKeysRequest(orgKeys[0], orgKeys[1].encryptedString);
|
||||
}
|
||||
|
||||
this.formPromise = this.apiService.putOrganization(this.organizationId, request).then(() => {
|
||||
this.formPromise = this.organizationApiService.save(this.organizationId, request).then(() => {
|
||||
return this.syncService.fullSync(true);
|
||||
});
|
||||
await this.formPromise;
|
||||
@@ -133,7 +135,9 @@ export class AccountComponent {
|
||||
await this.modalService.openViewRef(ApiKeyComponent, this.apiKeyModalRef, (comp) => {
|
||||
comp.keyType = "organization";
|
||||
comp.entityId = this.organizationId;
|
||||
comp.postKey = this.apiService.postOrganizationApiKey.bind(this.apiService);
|
||||
comp.postKey = this.organizationApiService.getOrCreateApiKey.bind(
|
||||
this.organizationApiService
|
||||
);
|
||||
comp.scope = "api.organization";
|
||||
comp.grantType = "client_credentials";
|
||||
comp.apiKeyTitle = "apiKey";
|
||||
@@ -147,7 +151,7 @@ export class AccountComponent {
|
||||
comp.keyType = "organization";
|
||||
comp.isRotation = true;
|
||||
comp.entityId = this.organizationId;
|
||||
comp.postKey = this.apiService.postOrganizationRotateApiKey.bind(this.apiService);
|
||||
comp.postKey = this.organizationApiService.rotateApiKey.bind(this.organizationApiService);
|
||||
comp.scope = "api.organization";
|
||||
comp.grantType = "client_credentials";
|
||||
comp.apiKeyTitle = "apiKey";
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Component, EventEmitter, Input, Output } from "@angular/core";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { OrganizationSubscriptionUpdateRequest } from "@bitwarden/common/models/request/organizationSubscriptionUpdateRequest";
|
||||
|
||||
@@ -18,16 +18,16 @@ export class AdjustSubscription {
|
||||
@Input() interval = "year";
|
||||
@Output() onAdjusted = new EventEmitter();
|
||||
|
||||
formPromise: Promise<any>;
|
||||
formPromise: Promise<void>;
|
||||
limitSubscription: boolean;
|
||||
newSeatCount: number;
|
||||
newMaxSeats: number;
|
||||
|
||||
constructor(
|
||||
private apiService: ApiService,
|
||||
private i18nService: I18nService,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private logService: LogService
|
||||
private logService: LogService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -40,7 +40,7 @@ export class AdjustSubscription {
|
||||
try {
|
||||
const seatAdjustment = this.newSeatCount - this.currentSeatCount;
|
||||
const request = new OrganizationSubscriptionUpdateRequest(seatAdjustment, this.newMaxSeats);
|
||||
this.formPromise = this.apiService.postOrganizationUpdateSubscription(
|
||||
this.formPromise = this.organizationApiService.updateSubscription(
|
||||
this.organizationId,
|
||||
request
|
||||
);
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Component } from "@angular/core";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||
import { OrganizationApiKeyType } from "@bitwarden/common/enums/organizationApiKeyType";
|
||||
@@ -28,7 +29,8 @@ export class BillingSyncApiKeyComponent {
|
||||
private userVerificationService: UserVerificationService,
|
||||
private apiService: ApiService,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private i18nService: I18nService
|
||||
private i18nService: I18nService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {}
|
||||
|
||||
copy() {
|
||||
@@ -41,7 +43,7 @@ export class BillingSyncApiKeyComponent {
|
||||
.buildRequest(this.masterPassword, OrganizationApiKeyRequest)
|
||||
.then((request) => {
|
||||
request.type = OrganizationApiKeyType.BillingSync;
|
||||
return this.apiService.postOrganizationRotateApiKey(this.organizationId, request);
|
||||
return this.organizationApiService.rotateApiKey(this.organizationId, request);
|
||||
});
|
||||
const response = await this.formPromise;
|
||||
await this.load(response);
|
||||
@@ -56,7 +58,7 @@ export class BillingSyncApiKeyComponent {
|
||||
.buildRequest(this.masterPassword, OrganizationApiKeyRequest)
|
||||
.then((request) => {
|
||||
request.type = OrganizationApiKeyType.BillingSync;
|
||||
return this.apiService.postOrganizationApiKey(this.organizationId, request);
|
||||
return this.organizationApiService.getOrCreateApiKey(this.organizationId, request);
|
||||
});
|
||||
const response = await this.formPromise;
|
||||
await this.load(response);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Component, EventEmitter, OnInit, Output } from "@angular/core";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { CipherService } from "@bitwarden/common/abstractions/cipher.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { OrganizationService } from "@bitwarden/common/abstractions/organization.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||
import { CipherType } from "@bitwarden/common/enums/cipherType";
|
||||
@@ -53,19 +53,19 @@ export class DeleteOrganizationComponent implements OnInit {
|
||||
deleteOrganizationRequestType: "InvalidFamiliesForEnterprise" | "RegularDelete" = "RegularDelete";
|
||||
organizationName: string;
|
||||
organizationContentSummary: OrganizationContentSummary = new OrganizationContentSummary();
|
||||
@Output() onSuccess: EventEmitter<unknown> = new EventEmitter();
|
||||
@Output() onSuccess: EventEmitter<void> = new EventEmitter();
|
||||
|
||||
masterPassword: Verification;
|
||||
formPromise: Promise<unknown>;
|
||||
formPromise: Promise<void>;
|
||||
|
||||
constructor(
|
||||
private apiService: ApiService,
|
||||
private i18nService: I18nService,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private userVerificationService: UserVerificationService,
|
||||
private logService: LogService,
|
||||
private cipherService: CipherService,
|
||||
private organizationService: OrganizationService
|
||||
private organizationService: OrganizationService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {}
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
@@ -76,7 +76,7 @@ export class DeleteOrganizationComponent implements OnInit {
|
||||
try {
|
||||
this.formPromise = this.userVerificationService
|
||||
.buildRequest(this.masterPassword)
|
||||
.then((request) => this.apiService.deleteOrganization(this.organizationId, request));
|
||||
.then((request) => this.organizationApiService.delete(this.organizationId, request));
|
||||
await this.formPromise;
|
||||
this.platformUtilsService.showToast(
|
||||
"success",
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Component, EventEmitter, Input, Output } from "@angular/core";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
|
||||
@Component({
|
||||
selector: "app-download-license",
|
||||
@@ -14,12 +14,12 @@ export class DownloadLicenseComponent {
|
||||
@Output() onCanceled = new EventEmitter();
|
||||
|
||||
installationId: string;
|
||||
formPromise: Promise<any>;
|
||||
formPromise: Promise<unknown>;
|
||||
|
||||
constructor(
|
||||
private apiService: ApiService,
|
||||
private fileDownloadService: FileDownloadService,
|
||||
private logService: LogService
|
||||
private logService: LogService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {}
|
||||
|
||||
async submit() {
|
||||
@@ -28,7 +28,7 @@ export class DownloadLicenseComponent {
|
||||
}
|
||||
|
||||
try {
|
||||
this.formPromise = this.apiService.getOrganizationLicense(
|
||||
this.formPromise = this.organizationApiService.getLicense(
|
||||
this.organizationId,
|
||||
this.installationId
|
||||
);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { PaymentMethodType } from "@bitwarden/common/enums/paymentMethodType";
|
||||
import { TransactionType } from "@bitwarden/common/enums/transactionType";
|
||||
@@ -26,16 +26,16 @@ export class OrganizationBillingComponent implements OnInit {
|
||||
verifyAmount1: number;
|
||||
verifyAmount2: number;
|
||||
|
||||
verifyBankPromise: Promise<any>;
|
||||
verifyBankPromise: Promise<void>;
|
||||
|
||||
// TODO - Make sure to properly split out the billing/invoice and payment method/account during org admin refresh
|
||||
|
||||
constructor(
|
||||
private apiService: ApiService,
|
||||
private i18nService: I18nService,
|
||||
private route: ActivatedRoute,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private logService: LogService
|
||||
private logService: LogService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
@@ -52,7 +52,7 @@ export class OrganizationBillingComponent implements OnInit {
|
||||
}
|
||||
this.loading = true;
|
||||
if (this.organizationId != null) {
|
||||
this.billing = await this.apiService.getOrganizationBilling(this.organizationId);
|
||||
this.billing = await this.organizationApiService.getBilling(this.organizationId);
|
||||
}
|
||||
this.loading = false;
|
||||
}
|
||||
@@ -66,10 +66,7 @@ export class OrganizationBillingComponent implements OnInit {
|
||||
const request = new VerifyBankRequest();
|
||||
request.amount1 = this.verifyAmount1;
|
||||
request.amount2 = this.verifyAmount2;
|
||||
this.verifyBankPromise = this.apiService.postOrganizationVerifyBank(
|
||||
this.organizationId,
|
||||
request
|
||||
);
|
||||
this.verifyBankPromise = this.organizationApiService.verifyBank(this.organizationId, request);
|
||||
await this.verifyBankPromise;
|
||||
this.platformUtilsService.showToast(
|
||||
"success",
|
||||
|
||||
@@ -8,6 +8,7 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
|
||||
import { OrganizationService } from "@bitwarden/common/abstractions/organization.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { OrganizationApiKeyType } from "@bitwarden/common/enums/organizationApiKeyType";
|
||||
import { OrganizationConnectionType } from "@bitwarden/common/enums/organizationConnectionType";
|
||||
@@ -48,9 +49,9 @@ export class OrganizationSubscriptionComponent implements OnInit {
|
||||
userOrg: Organization;
|
||||
existingBillingSyncConnection: OrganizationConnectionResponse<BillingSyncConfigApi>;
|
||||
|
||||
removeSponsorshipPromise: Promise<any>;
|
||||
cancelPromise: Promise<any>;
|
||||
reinstatePromise: Promise<any>;
|
||||
removeSponsorshipPromise: Promise<void>;
|
||||
cancelPromise: Promise<void>;
|
||||
reinstatePromise: Promise<void>;
|
||||
|
||||
@ViewChild("rotateBillingSyncKeyTemplate", { read: ViewContainerRef, static: true })
|
||||
billingSyncKeyViewContainerRef: ViewContainerRef;
|
||||
@@ -64,7 +65,8 @@ export class OrganizationSubscriptionComponent implements OnInit {
|
||||
private route: ActivatedRoute,
|
||||
private organizationService: OrganizationService,
|
||||
private logService: LogService,
|
||||
private modalService: ModalService
|
||||
private modalService: ModalService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {
|
||||
this.selfHosted = platformUtilsService.isSelfHost();
|
||||
}
|
||||
@@ -85,9 +87,9 @@ export class OrganizationSubscriptionComponent implements OnInit {
|
||||
this.loading = true;
|
||||
this.userOrg = await this.organizationService.get(this.organizationId);
|
||||
if (this.userOrg.canManageBilling) {
|
||||
this.sub = await this.apiService.getOrganizationSubscription(this.organizationId);
|
||||
this.sub = await this.organizationApiService.getSubscription(this.organizationId);
|
||||
}
|
||||
const apiKeyResponse = await this.apiService.getOrganizationApiKeyInformation(
|
||||
const apiKeyResponse = await this.organizationApiService.getApiKeyInformation(
|
||||
this.organizationId
|
||||
);
|
||||
this.hasBillingSyncToken = apiKeyResponse.data.some(
|
||||
@@ -125,7 +127,7 @@ export class OrganizationSubscriptionComponent implements OnInit {
|
||||
}
|
||||
|
||||
try {
|
||||
this.reinstatePromise = this.apiService.postOrganizationReinstate(this.organizationId);
|
||||
this.reinstatePromise = this.organizationApiService.reinstate(this.organizationId);
|
||||
await this.reinstatePromise;
|
||||
this.platformUtilsService.showToast("success", null, this.i18nService.t("reinstated"));
|
||||
this.load();
|
||||
@@ -151,7 +153,7 @@ export class OrganizationSubscriptionComponent implements OnInit {
|
||||
}
|
||||
|
||||
try {
|
||||
this.cancelPromise = this.apiService.postOrganizationCancel(this.organizationId);
|
||||
this.cancelPromise = this.organizationApiService.cancel(this.organizationId);
|
||||
await this.cancelPromise;
|
||||
this.platformUtilsService.showToast(
|
||||
"success",
|
||||
|
||||
@@ -6,6 +6,7 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { SyncService } from "@bitwarden/common/abstractions/sync.service";
|
||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||
@@ -33,7 +34,8 @@ export class EnrollMasterPasswordReset {
|
||||
private syncService: SyncService,
|
||||
private logService: LogService,
|
||||
private modalRef: ModalRef,
|
||||
config: ModalConfig
|
||||
config: ModalConfig,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {
|
||||
this.organization = config.data.organization;
|
||||
}
|
||||
@@ -48,7 +50,7 @@ export class EnrollMasterPasswordReset {
|
||||
let keyString: string = null;
|
||||
|
||||
// Retrieve Public Key
|
||||
const orgKeys = await this.apiService.getOrganizationKeys(this.organization.id);
|
||||
const orgKeys = await this.organizationApiService.getKeys(this.organization.id);
|
||||
if (orgKeys == null) {
|
||||
throw new Error(this.i18nService.t("resetPasswordOrgKeysError"));
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Component, EventEmitter, Input, Output, ViewChild } from "@angular/core
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { PaymentMethodType } from "@bitwarden/common/enums/paymentMethodType";
|
||||
import { PaymentRequest } from "@bitwarden/common/models/request/paymentRequest";
|
||||
@@ -24,13 +25,14 @@ export class AdjustPaymentComponent {
|
||||
@Output() onCanceled = new EventEmitter();
|
||||
|
||||
paymentMethodType = PaymentMethodType;
|
||||
formPromise: Promise<any>;
|
||||
formPromise: Promise<void>;
|
||||
|
||||
constructor(
|
||||
private apiService: ApiService,
|
||||
private i18nService: I18nService,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private logService: LogService
|
||||
private logService: LogService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {}
|
||||
|
||||
async submit() {
|
||||
@@ -50,7 +52,7 @@ export class AdjustPaymentComponent {
|
||||
request.line2 = this.taxInfoComponent.taxInfo.line2;
|
||||
request.city = this.taxInfoComponent.taxInfo.city;
|
||||
request.state = this.taxInfoComponent.taxInfo.state;
|
||||
return this.apiService.postOrganizationPayment(this.organizationId, request);
|
||||
return this.organizationApiService.updatePayment(this.organizationId, request);
|
||||
}
|
||||
});
|
||||
await this.formPromise;
|
||||
|
||||
@@ -4,6 +4,7 @@ import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { StorageRequest } from "@bitwarden/common/models/request/storageRequest";
|
||||
import { PaymentResponse } from "@bitwarden/common/models/response/paymentResponse";
|
||||
@@ -25,7 +26,7 @@ export class AdjustStorageComponent {
|
||||
@ViewChild(PaymentComponent, { static: true }) paymentComponent: PaymentComponent;
|
||||
|
||||
storageAdjustment = 0;
|
||||
formPromise: Promise<any>;
|
||||
formPromise: Promise<PaymentResponse | void>;
|
||||
|
||||
constructor(
|
||||
private apiService: ApiService,
|
||||
@@ -33,7 +34,8 @@ export class AdjustStorageComponent {
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private router: Router,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private logService: LogService
|
||||
private logService: LogService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {}
|
||||
|
||||
async submit() {
|
||||
@@ -50,7 +52,7 @@ export class AdjustStorageComponent {
|
||||
if (this.organizationId == null) {
|
||||
response = this.formPromise = this.apiService.postAccountStorage(request);
|
||||
} else {
|
||||
response = this.formPromise = this.apiService.postOrganizationStorage(
|
||||
response = this.formPromise = this.organizationApiService.updateStorage(
|
||||
this.organizationId,
|
||||
request
|
||||
);
|
||||
|
||||
@@ -11,6 +11,7 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { KeyConnectorService } from "@bitwarden/common/abstractions/keyConnector.service";
|
||||
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
|
||||
import { OrganizationService } from "@bitwarden/common/abstractions/organization.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PasswordGenerationService } from "@bitwarden/common/abstractions/passwordGeneration.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
||||
@@ -53,7 +54,8 @@ export class ChangePasswordComponent extends BaseChangePasswordComponent {
|
||||
private sendService: SendService,
|
||||
private organizationService: OrganizationService,
|
||||
private keyConnectorService: KeyConnectorService,
|
||||
private router: Router
|
||||
private router: Router,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {
|
||||
super(
|
||||
i18nService,
|
||||
@@ -267,7 +269,7 @@ export class ChangePasswordComponent extends BaseChangePasswordComponent {
|
||||
}
|
||||
|
||||
// Retrieve public key
|
||||
const response = await this.apiService.getOrganizationKeys(org.id);
|
||||
const response = await this.organizationApiService.getKeys(org.id);
|
||||
const publicKey = Utils.fromB64ToArray(response?.publicKey);
|
||||
|
||||
// Re-enroll - encrpyt user's encKey.key with organization public key
|
||||
|
||||
@@ -8,6 +8,7 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
|
||||
import { OrganizationService } from "@bitwarden/common/abstractions/organization.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
||||
import { SyncService } from "@bitwarden/common/abstractions/sync.service";
|
||||
@@ -26,6 +27,10 @@ import { PlanResponse } from "@bitwarden/common/models/response/planResponse";
|
||||
import { PaymentComponent } from "./payment.component";
|
||||
import { TaxInfoComponent } from "./tax-info.component";
|
||||
|
||||
interface OnSuccessArgs {
|
||||
organizationId: string;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: "app-organization-plans",
|
||||
templateUrl: "organization-plans.component.html",
|
||||
@@ -41,14 +46,14 @@ export class OrganizationPlansComponent implements OnInit {
|
||||
@Input() product: ProductType = ProductType.Free;
|
||||
@Input() plan: PlanType = PlanType.Free;
|
||||
@Input() providerId: string;
|
||||
@Output() onSuccess = new EventEmitter();
|
||||
@Output() onCanceled = new EventEmitter();
|
||||
@Output() onSuccess = new EventEmitter<OnSuccessArgs>();
|
||||
@Output() onCanceled = new EventEmitter<void>();
|
||||
@Output() onTrialBillingSuccess = new EventEmitter();
|
||||
|
||||
loading = true;
|
||||
selfHosted = false;
|
||||
productTypes = ProductType;
|
||||
formPromise: Promise<any>;
|
||||
formPromise: Promise<string>;
|
||||
singleOrgPolicyBlock = false;
|
||||
isInTrialFlow = false;
|
||||
discount = 0;
|
||||
@@ -79,7 +84,8 @@ export class OrganizationPlansComponent implements OnInit {
|
||||
private organizationService: OrganizationService,
|
||||
private logService: LogService,
|
||||
private messagingService: MessagingService,
|
||||
private formBuilder: UntypedFormBuilder
|
||||
private formBuilder: UntypedFormBuilder,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {
|
||||
this.selfHosted = platformUtilsService.isSelfHost();
|
||||
}
|
||||
@@ -372,7 +378,7 @@ export class OrganizationPlansComponent implements OnInit {
|
||||
request.keys = new OrganizationKeysRequest(orgKeys[0], orgKeys[1].encryptedString);
|
||||
}
|
||||
|
||||
const result = await this.apiService.postOrganizationUpgrade(this.organizationId, request);
|
||||
const result = await this.organizationApiService.upgrade(this.organizationId, request);
|
||||
if (!result.success && result.paymentIntentClientSecret != null) {
|
||||
await this.paymentComponent.handleStripeCardPayment(result.paymentIntentClientSecret, null);
|
||||
}
|
||||
@@ -434,7 +440,7 @@ export class OrganizationPlansComponent implements OnInit {
|
||||
|
||||
return orgId;
|
||||
} else {
|
||||
return (await this.apiService.postOrganization(request)).id;
|
||||
return (await this.organizationApiService.create(request)).id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,14 +455,14 @@ export class OrganizationPlansComponent implements OnInit {
|
||||
fd.append("license", files[0]);
|
||||
fd.append("key", key);
|
||||
fd.append("collectionName", collectionCt);
|
||||
const response = await this.apiService.postOrganizationLicense(fd);
|
||||
const response = await this.organizationApiService.createLicense(fd);
|
||||
const orgId = response.id;
|
||||
|
||||
await this.apiService.refreshIdentityToken();
|
||||
|
||||
// Org Keys live outside of the OrganizationLicense - add the keys to the org here
|
||||
const request = new OrganizationKeysRequest(orgKeys[0], orgKeys[1].encryptedString);
|
||||
await this.apiService.postOrganizationKeys(orgId, request);
|
||||
await this.organizationApiService.updateKeys(orgId, request);
|
||||
|
||||
return orgId;
|
||||
}
|
||||
|
||||
@@ -3,10 +3,17 @@ import { ActivatedRoute } from "@angular/router";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { OrganizationTaxInfoUpdateRequest } from "@bitwarden/common/models/request/organizationTaxInfoUpdateRequest";
|
||||
import { TaxInfoUpdateRequest } from "@bitwarden/common/models/request/taxInfoUpdateRequest";
|
||||
import { TaxInfoResponse } from "@bitwarden/common/models/response/taxInfoResponse";
|
||||
import { TaxRateResponse } from "@bitwarden/common/models/response/taxRateResponse";
|
||||
|
||||
type TaxInfoView = Omit<TaxInfoResponse, "taxIdType"> & {
|
||||
includeTaxId: boolean;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
|
||||
@Component({
|
||||
selector: "app-tax-info",
|
||||
templateUrl: "tax-info.component.html",
|
||||
@@ -17,7 +24,7 @@ export class TaxInfoComponent {
|
||||
|
||||
loading = true;
|
||||
organizationId: string;
|
||||
taxInfo: any = {
|
||||
taxInfo: TaxInfoView = {
|
||||
taxId: null,
|
||||
line1: null,
|
||||
line2: null,
|
||||
@@ -30,7 +37,7 @@ export class TaxInfoComponent {
|
||||
|
||||
taxRates: TaxRateResponse[];
|
||||
|
||||
private pristine: any = {
|
||||
private pristine: TaxInfoView = {
|
||||
taxId: null,
|
||||
line1: null,
|
||||
line2: null,
|
||||
@@ -44,7 +51,8 @@ export class TaxInfoComponent {
|
||||
constructor(
|
||||
private apiService: ApiService,
|
||||
private route: ActivatedRoute,
|
||||
private logService: LogService
|
||||
private logService: LogService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
@@ -52,7 +60,7 @@ export class TaxInfoComponent {
|
||||
this.organizationId = params.organizationId;
|
||||
if (this.organizationId) {
|
||||
try {
|
||||
const taxInfo = await this.apiService.getOrganizationTaxInfo(this.organizationId);
|
||||
const taxInfo = await this.organizationApiService.getTaxInfo(this.organizationId);
|
||||
if (taxInfo) {
|
||||
this.taxInfo.taxId = taxInfo.taxId;
|
||||
this.taxInfo.state = taxInfo.state;
|
||||
@@ -140,7 +148,7 @@ export class TaxInfoComponent {
|
||||
}
|
||||
const request = this.getTaxInfoRequest();
|
||||
return this.organizationId
|
||||
? this.apiService.putOrganizationTaxInfo(
|
||||
? this.organizationApiService.updateTaxInfo(
|
||||
this.organizationId,
|
||||
request as OrganizationTaxInfoUpdateRequest
|
||||
)
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Component, EventEmitter, Input, Output } from "@angular/core";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
|
||||
@Component({
|
||||
@@ -14,13 +15,14 @@ export class UpdateLicenseComponent {
|
||||
@Output() onUpdated = new EventEmitter();
|
||||
@Output() onCanceled = new EventEmitter();
|
||||
|
||||
formPromise: Promise<any>;
|
||||
formPromise: Promise<void>;
|
||||
|
||||
constructor(
|
||||
private apiService: ApiService,
|
||||
private i18nService: I18nService,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private logService: LogService
|
||||
private logService: LogService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {}
|
||||
|
||||
async submit() {
|
||||
@@ -39,11 +41,11 @@ export class UpdateLicenseComponent {
|
||||
const fd = new FormData();
|
||||
fd.append("license", files[0]);
|
||||
|
||||
let updatePromise: Promise<any> = null;
|
||||
let updatePromise: Promise<void | unknown> = null;
|
||||
if (this.organizationId == null) {
|
||||
updatePromise = this.apiService.postAccountLicense(fd);
|
||||
} else {
|
||||
updatePromise = this.apiService.postOrganizationLicenseUpdate(this.organizationId, fd);
|
||||
updatePromise = this.organizationApiService.updateLicense(this.organizationId, fd);
|
||||
}
|
||||
|
||||
this.formPromise = updatePromise.then(() => {
|
||||
|
||||
@@ -4,6 +4,7 @@ import { ModalService } from "@bitwarden/angular/services/modal.service";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { OrganizationApiServiceAbstraction } from "@bitwarden/common/abstractions/organization/organization-api.service.abstraction";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
||||
import { SyncService } from "@bitwarden/common/abstractions/sync.service";
|
||||
@@ -19,7 +20,7 @@ import { EnrollMasterPasswordReset } from "../../../organizations/users/enroll-m
|
||||
templateUrl: "organization-options.component.html",
|
||||
})
|
||||
export class OrganizationOptionsComponent {
|
||||
actionPromise: Promise<any>;
|
||||
actionPromise: Promise<void | boolean>;
|
||||
policies: Policy[];
|
||||
loaded = false;
|
||||
|
||||
@@ -32,7 +33,8 @@ export class OrganizationOptionsComponent {
|
||||
private syncService: SyncService,
|
||||
private policyService: PolicyService,
|
||||
private modalService: ModalService,
|
||||
private logService: LogService
|
||||
private logService: LogService,
|
||||
private organizationApiService: OrganizationApiServiceAbstraction
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
@@ -100,7 +102,7 @@ export class OrganizationOptionsComponent {
|
||||
}
|
||||
|
||||
try {
|
||||
this.actionPromise = this.apiService.postLeaveOrganization(org.id).then(() => {
|
||||
this.actionPromise = this.organizationApiService.leave(org.id).then(() => {
|
||||
return this.syncService.fullSync(true);
|
||||
});
|
||||
await this.actionPromise;
|
||||
|
||||
Reference in New Issue
Block a user