Browse Source

Remove uses of rxjs in CLI (#4028)

pull/4035/head
Justin Baur 3 years ago committed by GitHub
parent
commit
586ae4346c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      apps/cli/src/commands/export.command.ts
  2. 11
      libs/common/src/services/passwordGeneration.service.ts

5
apps/cli/src/commands/export.command.ts

@ -1,6 +1,5 @@ @@ -1,6 +1,5 @@
import * as program from "commander";
import * as inquirer from "inquirer";
import { firstValueFrom } from "rxjs";
import { ExportFormat, ExportService } from "@bitwarden/common/abstractions/export.service";
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
@ -16,9 +15,7 @@ export class ExportCommand { @@ -16,9 +15,7 @@ export class ExportCommand {
async run(options: program.OptionValues): Promise<Response> {
if (
options.organizationid == null &&
(await firstValueFrom(
this.policyService.policyAppliesToActiveUser$(PolicyType.DisablePersonalVaultExport)
))
(await this.policyService.policyAppliesToUser(PolicyType.DisablePersonalVaultExport))
) {
return Response.badRequest(
"One or more organization policies prevents you from exporting your personal vault."

11
libs/common/src/services/passwordGeneration.service.ts

@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@
import { firstValueFrom, map } from "rxjs";
import * as zxcvbn from "zxcvbn";
import { CryptoService } from "../abstractions/crypto.service";
@ -11,7 +10,6 @@ import { EncString } from "../models/domain/enc-string"; @@ -11,7 +10,6 @@ import { EncString } from "../models/domain/enc-string";
import { GeneratedPasswordHistory } from "../models/domain/generated-password-history";
import { PasswordGeneratorOptions } from "../models/domain/password-generator-options";
import { PasswordGeneratorPolicyOptions } from "../models/domain/password-generator-policy-options";
import { Policy } from "../models/domain/policy";
const DefaultOptions: PasswordGeneratorOptions = {
length: 14,
@ -257,14 +255,7 @@ export class PasswordGenerationService implements PasswordGenerationServiceAbstr @@ -257,14 +255,7 @@ export class PasswordGenerationService implements PasswordGenerationServiceAbstr
}
async getPasswordGeneratorPolicyOptions(): Promise<PasswordGeneratorPolicyOptions> {
const policies: Policy[] =
this.policyService == null
? null
: await firstValueFrom(
this.policyService.policies$.pipe(
map((p) => p.filter((policy) => policy.type === PolicyType.PasswordGenerator))
)
);
const policies = await this.policyService?.getAll(PolicyType.PasswordGenerator);
let enforcedOptions: PasswordGeneratorPolicyOptions = null;
if (policies == null || policies.length === 0) {

Loading…
Cancel
Save