mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 23:33:31 +00:00
* Extract files only used in cli out of libs/node Move commands from libs/node to cli Move program from libs/node to cli Move services from libs/node to cli Move specs from libs/node to cli Naming changes based on ADR 12 Rename commands Rename models/request Rename models/response Remove entries from whitelist-capital-letters.txt * Merge lowDbStorageService into base class Move logic from extended lowdbStorage.service.ts into base-lowdb-storage.service.ts Delete lowdb-storage.service.ts Rename base-lowdb-storage.service.ts to lowdb-storage.service.ts * Merge login.command with base class program.ts - changed import temporarily to make it easier to review Remove passing in clientId, set "cli" when constructing ssoRedirectUri call Remove setting callbacks, use private methods instead Remove i18nService from constructor params Add syncService, keyConnectorService and logoutCallback to constructor Merge successCallback with handleSuccessResponse Remove validatedParams callback and added private method Move options(program.OptionValues) and set in run() Delete login.command.ts * Rename base-login.command.ts to login.command.ts * Merge base.program.ts with program.ts
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
import * as program from "commander";
|
|
|
|
import { EnvironmentService } from "@bitwarden/common/abstractions/environment.service";
|
|
|
|
import { Response } from "../models/response";
|
|
import { MessageResponse } from "../models/response/message.response";
|
|
import { StringResponse } from "../models/response/string.response";
|
|
|
|
export class ConfigCommand {
|
|
constructor(private environmentService: EnvironmentService) {}
|
|
|
|
async run(setting: string, value: string, options: program.OptionValues): Promise<Response> {
|
|
setting = setting.toLowerCase();
|
|
switch (setting) {
|
|
case "server":
|
|
return await this.getOrSetServer(value, options);
|
|
default:
|
|
return Response.badRequest("Unknown setting.");
|
|
}
|
|
}
|
|
|
|
private async getOrSetServer(url: string, options: program.OptionValues): Promise<Response> {
|
|
if (
|
|
(url == null || url.trim() === "") &&
|
|
!options.webVault &&
|
|
!options.api &&
|
|
!options.identity &&
|
|
!options.icons &&
|
|
!options.notifications &&
|
|
!options.events
|
|
) {
|
|
const stringRes = new StringResponse(
|
|
this.environmentService.hasBaseUrl()
|
|
? this.environmentService.getUrls().base
|
|
: "https://bitwarden.com"
|
|
);
|
|
return Response.success(stringRes);
|
|
}
|
|
|
|
url = url === "null" || url === "bitwarden.com" || url === "https://bitwarden.com" ? null : url;
|
|
await this.environmentService.setUrls({
|
|
base: url,
|
|
webVault: options.webVault || null,
|
|
api: options.api || null,
|
|
identity: options.identity || null,
|
|
icons: options.icons || null,
|
|
notifications: options.notifications || null,
|
|
events: options.events || null,
|
|
keyConnector: options.keyConnector || null,
|
|
});
|
|
const res = new MessageResponse("Saved setting `config`.", null);
|
|
return Response.success(res);
|
|
}
|
|
}
|