mirror of
https://github.com/bitwarden/browser
synced 2026-01-28 23:33:27 +00:00
gate usage of send email field in create and edit behind SendEmailOTP feat flag
This commit is contained in:
@@ -6,6 +6,7 @@ import * as path from "path";
|
||||
import * as chalk from "chalk";
|
||||
import { program, Command, Option, OptionValues } from "commander";
|
||||
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||
import { SendType } from "@bitwarden/common/tools/send/types/send-type";
|
||||
|
||||
@@ -81,6 +82,16 @@ export class SendProgram extends BaseProgram {
|
||||
.addCommand(this.removePasswordCommand())
|
||||
.addCommand(this.deleteCommand())
|
||||
.action(async (data: string, options: OptionValues) => {
|
||||
if (options.email) {
|
||||
const emailFeatureEnabled = await this.serviceContainer.configService.getFeatureFlag(
|
||||
FeatureFlag.SendEmailOTP,
|
||||
);
|
||||
if (!emailFeatureEnabled) {
|
||||
this.processResponse(Response.error("The --email feature is not currently available."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const encodedJson = this.makeSendJson(data, options);
|
||||
|
||||
let response: Response;
|
||||
@@ -213,6 +224,17 @@ export class SendProgram extends BaseProgram {
|
||||
.action(async (encodedJson: string, options: OptionValues, args: { parent: Command }) => {
|
||||
// subcommands inherit flags from their parent; they cannot override them
|
||||
const { fullObject = false, email = undefined, password = undefined } = args.parent.opts();
|
||||
|
||||
if (email) {
|
||||
const emailFeatureEnabled = await this.serviceContainer.configService.getFeatureFlag(
|
||||
FeatureFlag.SendEmailOTP,
|
||||
);
|
||||
if (!emailFeatureEnabled) {
|
||||
this.processResponse(Response.error("The --email feature is not currently available."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const mergedOptions = {
|
||||
...options,
|
||||
fullObject: fullObject,
|
||||
@@ -241,6 +263,17 @@ export class SendProgram extends BaseProgram {
|
||||
})
|
||||
.action(async (encodedJson: string, options: OptionValues, args: { parent: Command }) => {
|
||||
await this.exitIfLocked();
|
||||
const { email = undefined, password = undefined } = args.parent.opts();
|
||||
if (email) {
|
||||
const emailFeatureEnabled = await this.serviceContainer.configService.getFeatureFlag(
|
||||
FeatureFlag.SendEmailOTP,
|
||||
);
|
||||
if (!emailFeatureEnabled) {
|
||||
this.processResponse(Response.error("The --email feature is not currently available."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const getCmd = new SendGetCommand(
|
||||
this.serviceContainer.sendService,
|
||||
this.serviceContainer.environmentService,
|
||||
@@ -257,8 +290,6 @@ export class SendProgram extends BaseProgram {
|
||||
this.serviceContainer.accountService,
|
||||
);
|
||||
|
||||
// subcommands inherit flags from their parent; they cannot override them
|
||||
const { email = undefined, password = undefined } = args.parent.opts();
|
||||
const mergedOptions = {
|
||||
...options,
|
||||
email,
|
||||
|
||||
@@ -11,7 +11,6 @@ export class SendData {
|
||||
id: string;
|
||||
accessId: string;
|
||||
type: SendType;
|
||||
authType: AuthType;
|
||||
name: string;
|
||||
notes: string;
|
||||
file: SendFileData;
|
||||
|
||||
@@ -26,7 +26,6 @@ describe("Send", () => {
|
||||
id: "id",
|
||||
accessId: "accessId",
|
||||
type: SendType.Text,
|
||||
authType: AuthType.None,
|
||||
name: "encName",
|
||||
notes: "encNotes",
|
||||
text: {
|
||||
@@ -82,7 +81,6 @@ describe("Send", () => {
|
||||
id: "id",
|
||||
accessId: "accessId",
|
||||
type: SendType.Text,
|
||||
authType: AuthType.None,
|
||||
name: { encryptedString: "encName", encryptionType: 0 },
|
||||
notes: { encryptedString: "encNotes", encryptionType: 0 },
|
||||
text: {
|
||||
@@ -153,7 +151,6 @@ describe("Send", () => {
|
||||
name: "name",
|
||||
notes: "notes",
|
||||
type: 0,
|
||||
authType: 2,
|
||||
key: expect.anything(),
|
||||
cryptoKey: "cryptoKey",
|
||||
file: expect.anything(),
|
||||
|
||||
@@ -20,7 +20,6 @@ export class Send extends Domain {
|
||||
id: string;
|
||||
accessId: string;
|
||||
type: SendType;
|
||||
authType: AuthType;
|
||||
name: EncString;
|
||||
notes: EncString;
|
||||
file: SendFile;
|
||||
|
||||
@@ -4,8 +4,6 @@ import { AuthType } from "@bitwarden/common/tools/send/types/auth-type";
|
||||
import { SendType } from "@bitwarden/common/tools/send/types/send-type";
|
||||
|
||||
import { BaseResponse } from "../../../../models/response/base.response";
|
||||
import { AuthType } from "../../types/auth-type";
|
||||
import { SendType } from "../../types/send-type";
|
||||
import { SendFileApi } from "../api/send-file.api";
|
||||
import { SendTextApi } from "../api/send-text.api";
|
||||
|
||||
@@ -13,7 +11,6 @@ export class SendResponse extends BaseResponse {
|
||||
id: string;
|
||||
accessId: string;
|
||||
type: SendType;
|
||||
authType: AuthType;
|
||||
name: string;
|
||||
notes: string;
|
||||
file: SendFileApi;
|
||||
|
||||
@@ -19,7 +19,6 @@ export class SendView implements View {
|
||||
key: Uint8Array;
|
||||
cryptoKey: SymmetricCryptoKey;
|
||||
type: SendType = null;
|
||||
authType: AuthType = null;
|
||||
text = new SendTextView();
|
||||
file = new SendFileView();
|
||||
maxAccessCount?: number = null;
|
||||
|
||||
Reference in New Issue
Block a user