1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 09:13:33 +00:00

[deps] Autofill: Update prettier to v3 (#7014)

* [deps] Autofill: Update prettier to v3

* prettier formatting updates

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
This commit is contained in:
renovate[bot]
2023-11-29 16:15:20 -05:00
committed by GitHub
parent 4ff5f38e89
commit 28de9439be
1145 changed files with 5898 additions and 5612 deletions

View File

@@ -10,7 +10,7 @@ export class ConfirmCommand {
constructor(
private apiService: ApiService,
private cryptoService: CryptoService,
private organizationUserService: OrganizationUserService
private organizationUserService: OrganizationUserService,
) {}
async run(object: string, id: string, cmdOptions: Record<string, any>): Promise<Response> {
@@ -44,7 +44,7 @@ export class ConfirmCommand {
}
const orgUser = await this.organizationUserService.getOrganizationUser(
options.organizationId,
id
id,
);
if (orgUser == null) {
throw new Error("Member id does not exist for this organization.");
@@ -57,7 +57,7 @@ export class ConfirmCommand {
await this.organizationUserService.postOrganizationUserConfirm(
options.organizationId,
id,
req
req,
);
return Response.success();
} catch (e) {

View File

@@ -46,13 +46,13 @@ export class ShareCommand {
return Response.badRequest("This item already belongs to an organization.");
}
const cipherView = await cipher.decrypt(
await this.cipherService.getKeyForCipherKeyDecryption(cipher)
await this.cipherService.getKeyForCipherKeyDecryption(cipher),
);
try {
await this.cipherService.shareWithServer(cipherView, organizationId, req);
const updatedCipher = await this.cipherService.get(cipher.id);
const decCipher = await updatedCipher.decrypt(
await this.cipherService.getKeyForCipherKeyDecryption(updatedCipher)
await this.cipherService.getKeyForCipherKeyDecryption(updatedCipher),
);
const res = new CipherResponse(decCipher);
return Response.success(res);

View File

@@ -65,7 +65,7 @@ export class LoginCommand {
protected keyConnectorService: KeyConnectorService,
protected policyApiService: PolicyApiServiceAbstraction,
protected orgService: OrganizationService,
protected logoutCallback: () => Promise<void>
protected logoutCallback: () => Promise<void>,
) {}
async run(email: string, password: string, options: program.OptionValues) {
@@ -179,7 +179,7 @@ export class LoginCommand {
}
try {
response = await this.authService.logIn(
new UserApiLoginCredentials(clientId, clientSecret)
new UserApiLoginCredentials(clientId, clientSecret),
);
} catch (e) {
// handle API key login failures
@@ -201,17 +201,17 @@ export class LoginCommand {
ssoCodeVerifier,
this.ssoRedirectUri,
orgIdentifier,
twoFactor
)
twoFactor,
),
);
} else {
response = await this.authService.logIn(
new PasswordLoginCredentials(email, password, null, twoFactor)
new PasswordLoginCredentials(email, password, null, twoFactor),
);
}
if (response.requiresEncryptionKeyMigration) {
return Response.error(
"Encryption key migration required. Please login through the web vault to update your encryption key."
"Encryption key migration required. Please login through the web vault to update your encryption key.",
);
}
if (response.captchaSiteKey) {
@@ -294,7 +294,7 @@ export class LoginCommand {
response = await this.authService.logInTwoFactor(
new TokenTwoFactorRequest(selectedProvider.type, twoFactorToken),
null
null,
);
}
@@ -317,7 +317,7 @@ export class LoginCommand {
if (response.resetMasterPassword) {
return Response.error(
"In order to log in with SSO from the CLI, you must first log in" +
" through the web vault to set your master password."
" through the web vault to set your master password.",
);
}
@@ -358,7 +358,7 @@ export class LoginCommand {
) {
const res = new MessageResponse(
"You are logged in!",
"\n" + "To unlock your vault, use the `unlock` command. ex:\n" + "$ bw unlock"
"\n" + "To unlock your vault, use the `unlock` command. ex:\n" + "$ bw unlock",
);
return Response.success(res);
}
@@ -375,7 +375,7 @@ export class LoginCommand {
'"\n\n' +
"You can also pass the session key to any command with the `--session` option. ex:\n" +
"$ bw list items --session " +
process.env.BW_SESSION
process.env.BW_SESSION,
);
res.raw = process.env.BW_SESSION;
return Response.success(res);
@@ -389,7 +389,7 @@ export class LoginCommand {
const res = new MessageResponse(
"Your master password has been updated!",
"\n" + "You have been logged out and must log in again to access the vault."
"\n" + "You have been logged out and must log in again to access the vault.",
);
return Response.success(res);
@@ -405,14 +405,14 @@ export class LoginCommand {
return Response.error(
new MessageResponse(
"Your master password does not meet one or more of your organization policies. In order to access the vault, you must update your master password now via the web vault. You have been logged out.",
null
)
null,
),
);
}
try {
const { newPasswordHash, newUserKey, hint } = await this.collectNewMasterPasswordDetails(
"Your master password does not meet one or more of your organization policies. In order to access the vault, you must update your master password now."
"Your master password does not meet one or more of your organization policies. In order to access the vault, you must update your master password now.",
);
const request = new PasswordRequest();
@@ -443,14 +443,14 @@ export class LoginCommand {
return Response.error(
new MessageResponse(
"An organization administrator recently changed your master password. In order to access the vault, you must update your master password now via the web vault. You have been logged out.",
null
)
null,
),
);
}
try {
const { newPasswordHash, newUserKey, hint } = await this.collectNewMasterPasswordDetails(
"An organization administrator recently changed your master password. In order to access the vault, you must update your master password now."
"An organization administrator recently changed your master password. In order to access the vault, you must update your master password now.",
);
const request = new UpdateTempPasswordRequest();
@@ -479,7 +479,7 @@ export class LoginCommand {
*/
private async collectNewMasterPasswordDetails(
prompt: string,
error?: string
error?: string,
): Promise<{
newPasswordHash: string;
newUserKey: [SymmetricCryptoKey, EncString];
@@ -507,18 +507,18 @@ export class LoginCommand {
if (masterPassword.length < Utils.minimumPasswordLength) {
return this.collectNewMasterPasswordDetails(
prompt,
`Master password must be at least ${Utils.minimumPasswordLength} characters long.\n`
`Master password must be at least ${Utils.minimumPasswordLength} characters long.\n`,
);
}
// Strength & Policy Validation
const strengthResult = this.passwordStrengthService.getPasswordStrength(
masterPassword,
this.email
this.email,
);
const enforcedPolicyOptions = await firstValueFrom(
this.policyService.masterPasswordPolicyOptions$()
this.policyService.masterPasswordPolicyOptions$(),
);
// Verify master password meets policy requirements
@@ -527,12 +527,12 @@ export class LoginCommand {
!this.policyService.evaluateMasterPassword(
strengthResult.score,
masterPassword,
enforcedPolicyOptions
enforcedPolicyOptions,
)
) {
return this.collectNewMasterPasswordDetails(
prompt,
"Your new master password does not meet the policy requirements.\n"
"Your new master password does not meet the policy requirements.\n",
);
}
@@ -549,7 +549,7 @@ export class LoginCommand {
if (masterPassword !== masterPasswordRetype) {
return this.collectNewMasterPasswordDetails(
prompt,
"Master password confirmation does not match.\n"
"Master password confirmation does not match.\n",
);
}
@@ -568,7 +568,7 @@ export class LoginCommand {
masterPassword,
this.email.trim().toLowerCase(),
kdf,
kdfConfig
kdfConfig,
);
const newPasswordHash = await this.cryptoService.hashMasterKey(masterPassword, newMasterKey);
@@ -586,12 +586,12 @@ export class LoginCommand {
private async handleCaptchaRequired(
twoFactorRequest: TokenTwoFactorRequest,
credentials: PasswordLoginCredentials = null
credentials: PasswordLoginCredentials = null,
): Promise<AuthResult | Response> {
const badCaptcha = Response.badRequest(
"Your authentication request has been flagged and will require user interaction to proceed.\n" +
"Please use your API key to validate this request and ensure BW_CLIENTSECRET is correct, if set.\n" +
"(https://bitwarden.com/help/cli-auth-challenges)"
"(https://bitwarden.com/help/cli-auth-challenges)",
);
try {
@@ -608,7 +608,7 @@ export class LoginCommand {
} else {
authResultResponse = await this.authService.logInTwoFactor(
twoFactorRequest,
captchaClientSecret
captchaClientSecret,
);
}
@@ -685,7 +685,7 @@ export class LoginCommand {
private async openSsoPrompt(
codeChallenge: string,
state: string
state: string,
): Promise<{ ssoCode: string; orgIdentifier: string }> {
return new Promise((resolve, reject) => {
const callbackServer = http.createServer((req, res) => {
@@ -701,13 +701,13 @@ export class LoginCommand {
"<html><head><title>Success | Bitwarden CLI</title></head><body>" +
"<h1>Successfully authenticated with the Bitwarden CLI</h1>" +
"<p>You may now close this tab and return to the terminal.</p>" +
"</body></html>"
"</body></html>",
);
callbackServer.close(() =>
resolve({
ssoCode: code,
orgIdentifier: orgIdentifier,
})
}),
);
} else {
res.writeHead(400);
@@ -715,7 +715,7 @@ export class LoginCommand {
"<html><head><title>Failed | Bitwarden CLI</title></head><body>" +
"<h1>Something went wrong logging into the Bitwarden CLI</h1>" +
"<p>You may now close this tab and return to the terminal.</p>" +
"</body></html>"
"</body></html>",
);
callbackServer.close(() => reject());
}
@@ -735,7 +735,7 @@ export class LoginCommand {
"&state=" +
state +
"&codeChallenge=" +
codeChallenge
codeChallenge,
);
});
foundPort = true;

View File

@@ -8,7 +8,7 @@ export class LogoutCommand {
constructor(
private authService: AuthService,
private i18nService: I18nService,
private logoutCallback: () => Promise<void>
private logoutCallback: () => Promise<void>,
) {}
async run() {

View File

@@ -27,7 +27,7 @@ export class UnlockCommand {
private environmentService: EnvironmentService,
private syncService: SyncService,
private organizationApiService: OrganizationApiServiceAbstraction,
private logout: () => Promise<void>
private logout: () => Promise<void>,
) {}
async run(password: string, cmdOptions: Record<string, any>) {
@@ -55,7 +55,7 @@ export class UnlockCommand {
const serverKeyHash = await this.cryptoService.hashMasterKey(
password,
masterKey,
HashPurpose.ServerAuthorization
HashPurpose.ServerAuthorization,
);
const request = new SecretVerificationRequest();
request.masterPasswordHash = serverKeyHash;
@@ -65,7 +65,7 @@ export class UnlockCommand {
const localKeyHash = await this.cryptoService.hashMasterKey(
password,
masterKey,
HashPurpose.LocalAuthorization
HashPurpose.LocalAuthorization,
);
await this.cryptoService.setMasterKeyHash(localKeyHash);
} catch {
@@ -85,7 +85,7 @@ export class UnlockCommand {
this.environmentService,
this.syncService,
this.organizationApiService,
this.logout
this.logout,
);
const convertResponse = await convertToKeyConnectorCommand.run();
if (!convertResponse.success) {
@@ -117,7 +117,7 @@ export class UnlockCommand {
'"\n\n' +
"You can also pass the session key to any command with the `--session` option. ex:\n" +
"$ bw list items --session " +
process.env.BW_SESSION
process.env.BW_SESSION,
);
res.raw = process.env.BW_SESSION;
return Response.success(res);

View File

@@ -188,26 +188,26 @@ export class Main {
this.platformUtilsService = new CliPlatformUtilsService(ClientType.Cli, packageJson);
this.logService = new ConsoleLogService(
this.platformUtilsService.isDev(),
(level) => process.env.BITWARDENCLI_DEBUG !== "true" && level <= LogLevelType.Info
(level) => process.env.BITWARDENCLI_DEBUG !== "true" && level <= LogLevelType.Info,
);
this.cryptoFunctionService = new NodeCryptoFunctionService();
this.encryptService = new EncryptServiceImplementation(
this.cryptoFunctionService,
this.logService,
true
true,
);
this.storageService = new LowdbStorageService(this.logService, null, p, false, true);
this.secureStorageService = new NodeEnvSecureStorageService(
this.storageService,
this.logService,
() => this.cryptoService
() => this.cryptoService,
);
this.memoryStorageService = new MemoryStorageService();
this.globalStateProvider = new DefaultGlobalStateProvider(
this.memoryStorageService,
this.storageService
this.storageService,
);
this.messagingService = new NoopMessagingService();
@@ -215,7 +215,7 @@ export class Main {
this.accountService = new AccountServiceImplementation(
this.messagingService,
this.logService,
this.globalStateProvider
this.globalStateProvider,
);
this.stateService = new StateService(
@@ -224,7 +224,7 @@ export class Main {
this.memoryStorageService,
this.logService,
new StateFactory(GlobalState, Account),
this.accountService
this.accountService,
);
this.cryptoService = new CryptoService(
@@ -232,7 +232,7 @@ export class Main {
this.encryptService,
this.platformUtilsService,
this.logService,
this.stateService
this.stateService,
);
this.appIdService = new AppIdService(this.storageService);
@@ -251,7 +251,7 @@ export class Main {
this.environmentService,
this.appIdService,
async (expired: boolean) => await this.logout(),
customUserAgent
customUserAgent,
);
this.syncNotifierService = new SyncNotifierService();
@@ -268,18 +268,18 @@ export class Main {
this.cryptoService,
this.i18nService,
this.cryptoFunctionService,
this.stateService
this.stateService,
);
this.cipherFileUploadService = new CipherFileUploadService(
this.apiService,
this.fileUploadService
this.fileUploadService,
);
this.sendApiService = this.sendApiService = new SendApiService(
this.apiService,
this.fileUploadService,
this.sendService
this.sendService,
);
this.searchService = new SearchService(this.logService, this.i18nService);
@@ -289,7 +289,7 @@ export class Main {
this.collectionService = new CollectionService(
this.cryptoService,
this.i18nService,
this.stateService
this.stateService,
);
this.providerService = new ProviderService(this.stateService);
@@ -303,7 +303,7 @@ export class Main {
this.policyApiService = new PolicyApiService(
this.policyService,
this.apiService,
this.stateService
this.stateService,
);
this.keyConnectorService = new KeyConnectorService(
@@ -314,7 +314,7 @@ export class Main {
this.logService,
this.organizationService,
this.cryptoFunctionService,
async (expired: boolean) => await this.logout()
async (expired: boolean) => await this.logout(),
);
this.twoFactorService = new TwoFactorService(this.i18nService, this.platformUtilsService);
@@ -324,7 +324,7 @@ export class Main {
this.passwordGenerationService = new PasswordGenerationService(
this.cryptoService,
this.policyService,
this.stateService
this.stateService,
);
this.devicesApiService = new DevicesApiServiceImplementation(this.apiService);
@@ -336,7 +336,7 @@ export class Main {
this.appIdService,
this.devicesApiService,
this.i18nService,
this.platformUtilsService
this.platformUtilsService,
);
this.authRequestCryptoService = new AuthRequestCryptoServiceImplementation(this.cryptoService);
@@ -358,7 +358,7 @@ export class Main {
this.passwordStrengthService,
this.policyService,
this.deviceTrustCryptoService,
this.authRequestCryptoService
this.authRequestCryptoService,
);
this.configApiService = new ConfigApiService(this.apiService, this.authService);
@@ -369,7 +369,7 @@ export class Main {
this.authService,
this.environmentService,
this.logService,
true
true,
);
this.cipherService = new CipherService(
@@ -381,14 +381,14 @@ export class Main {
this.stateService,
this.encryptService,
this.cipherFileUploadService,
this.configService
this.configService,
);
this.folderService = new FolderService(
this.cryptoService,
this.i18nService,
this.cipherService,
this.stateService
this.stateService,
);
this.folderApiService = new FolderApiService(this.folderService, this.apiService);
@@ -400,7 +400,7 @@ export class Main {
this.stateService,
this.cryptoService,
this.i18nService,
this.userVerificationApiService
this.userVerificationApiService,
);
this.vaultTimeoutSettingsService = new VaultTimeoutSettingsService(
@@ -408,7 +408,7 @@ export class Main {
this.tokenService,
this.policyService,
this.stateService,
this.userVerificationService
this.userVerificationService,
);
this.vaultTimeoutService = new VaultTimeoutService(
@@ -423,7 +423,7 @@ export class Main {
this.authService,
this.vaultTimeoutSettingsService,
lockedCallback,
null
null,
);
this.syncService = new SyncService(
@@ -443,7 +443,7 @@ export class Main {
this.folderApiService,
this.organizationService,
this.sendApiService,
async (expired: boolean) => await this.logout()
async (expired: boolean) => await this.logout(),
);
this.totpService = new TotpService(this.cryptoFunctionService, this.logService);
@@ -456,7 +456,7 @@ export class Main {
this.importApiService,
this.i18nService,
this.collectionService,
this.cryptoService
this.cryptoService,
);
this.exportService = new VaultExportService(
this.folderService,
@@ -464,7 +464,7 @@ export class Main {
this.apiService,
this.cryptoService,
this.cryptoFunctionService,
this.stateService
this.stateService,
);
this.auditService = new AuditService(this.cryptoFunctionService, this.apiService);
@@ -477,14 +477,14 @@ export class Main {
this.eventUploadService = new EventUploadService(
this.apiService,
this.stateService,
this.logService
this.logService,
);
this.eventCollectionService = new EventCollectionService(
this.cipherService,
this.stateService,
this.organizationService,
this.eventUploadService
this.eventUploadService,
);
}

View File

@@ -69,7 +69,7 @@ export class CompletionCommand {
.concat(
`'(-h --help)'{-h,--help}'[output usage information]'`,
hasCommands ? '"1: :->cmnds"' : null,
'"*::arg:->args"'
'"*::arg:->args"',
)
.filter(Boolean);
@@ -100,7 +100,7 @@ export class CompletionCommand {
${commands
.map(({ _name }) => [`${_name})`, `_${name}_${_name}`, ";;"].join("\n "))
.join("\n ")}
esac`
esac`,
);
}
@@ -110,7 +110,7 @@ export class CompletionCommand {
if (hasCommands) {
commandBlocParts.push(
commands.map((c) => this.renderCommandBlock(`${name}_${c._name}`, c)).join("\n\n")
commands.map((c) => this.renderCommandBlock(`${name}_${c._name}`, c)).join("\n\n"),
);
}

View File

@@ -32,7 +32,7 @@ export class ConfigCommand {
const stringRes = new StringResponse(
this.environmentService.hasBaseUrl()
? this.environmentService.getUrls().base
: "https://bitwarden.com"
: "https://bitwarden.com",
);
return Response.success(stringRes);
}

View File

@@ -14,7 +14,7 @@ export class ConvertToKeyConnectorCommand {
private environmentService: EnvironmentService,
private syncService: SyncService,
private organizationApiService: OrganizationApiServiceAbstraction,
private logout: () => Promise<void>
private logout: () => Promise<void>,
) {}
async run(): Promise<Response> {
@@ -26,8 +26,8 @@ export class ConvertToKeyConnectorCommand {
new MessageResponse(
"An organization you are a member of is using Key Connector. " +
"In order to access the vault, you must opt-in to Key Connector now via the web vault. You have been logged out.",
null
)
null,
),
);
}

View File

@@ -15,12 +15,12 @@ export abstract class DownloadCommand {
url: string,
key: SymmetricCryptoKey,
fileName: string,
output?: string
output?: string,
) {
const response = await fet.default(new fet.Request(url, { headers: { cache: "no-cache" } }));
if (response.status !== 200) {
return Response.error(
"A " + response.status + " error occurred while downloading the attachment."
"A " + response.status + " error occurred while downloading the attachment.",
);
}

View File

@@ -23,14 +23,14 @@ export class EditCommand {
private folderService: FolderService,
private cryptoService: CryptoService,
private apiService: ApiService,
private folderApiService: FolderApiServiceAbstraction
private folderApiService: FolderApiServiceAbstraction,
) {}
async run(
object: string,
id: string,
requestJson: any,
cmdOptions: Record<string, any>
cmdOptions: Record<string, any>,
): Promise<Response> {
if (process.env.BW_SERVE !== "true" && (requestJson == null || requestJson === "")) {
requestJson = await CliUtils.readStdin();
@@ -78,7 +78,7 @@ export class EditCommand {
}
let cipherView = await cipher.decrypt(
await this.cipherService.getKeyForCipherKeyDecryption(cipher)
await this.cipherService.getKeyForCipherKeyDecryption(cipher),
);
if (cipherView.isDeleted) {
return Response.badRequest("You may not edit a deleted item. Use the restore command first.");
@@ -89,7 +89,7 @@ export class EditCommand {
await this.cipherService.updateWithServer(encCipher);
const updatedCipher = await this.cipherService.get(cipher.id);
const decCipher = await updatedCipher.decrypt(
await this.cipherService.getKeyForCipherKeyDecryption(updatedCipher)
await this.cipherService.getKeyForCipherKeyDecryption(updatedCipher),
);
const res = new CipherResponse(decCipher);
return Response.success(res);
@@ -105,7 +105,7 @@ export class EditCommand {
}
if (cipher.organizationId == null) {
return Response.badRequest(
"Item does not belong to an organization. Consider moving it first."
"Item does not belong to an organization. Consider moving it first.",
);
}
@@ -114,7 +114,7 @@ export class EditCommand {
await this.cipherService.saveCollectionsWithServer(cipher);
const updatedCipher = await this.cipherService.get(cipher.id);
const decCipher = await updatedCipher.decrypt(
await this.cipherService.getKeyForCipherKeyDecryption(updatedCipher)
await this.cipherService.getKeyForCipherKeyDecryption(updatedCipher),
);
const res = new CipherResponse(decCipher);
return Response.success(res);
@@ -146,7 +146,7 @@ export class EditCommand {
private async editOrganizationCollection(
id: string,
req: OrganizationCollectionRequest,
options: Options
options: Options,
) {
if (options.organizationId == null || options.organizationId === "") {
return Response.badRequest("`organizationid` option is required.");
@@ -170,7 +170,7 @@ export class EditCommand {
req.groups == null
? null
: req.groups.map(
(g) => new SelectionReadOnlyRequest(g.id, g.readOnly, g.hidePasswords, g.manage)
(g) => new SelectionReadOnlyRequest(g.id, g.readOnly, g.hidePasswords, g.manage),
);
const request = new CollectionRequest();
request.name = (await this.cryptoService.encrypt(req.name, orgKey)).encryptedString;

View File

@@ -56,7 +56,7 @@ export class GetCommand extends DownloadCommand {
private searchService: SearchService,
private apiService: ApiService,
private organizationService: OrganizationService,
private eventCollectionService: EventCollectionService
private eventCollectionService: EventCollectionService,
) {
super(cryptoService);
}
@@ -107,7 +107,7 @@ export class GetCommand extends DownloadCommand {
const cipher = await this.cipherService.get(id);
if (cipher != null) {
decCipher = await cipher.decrypt(
await this.cipherService.getKeyForCipherKeyDecryption(cipher)
await this.cipherService.getKeyForCipherKeyDecryption(cipher),
);
}
} else if (id.trim() !== "") {
@@ -145,7 +145,7 @@ export class GetCommand extends DownloadCommand {
EventType.Cipher_ClientViewed,
id,
true,
decCipher.organizationId
decCipher.organizationId,
);
const res = new CipherResponse(decCipher);
@@ -155,7 +155,7 @@ export class GetCommand extends DownloadCommand {
private async getUsername(id: string) {
const cipherResponse = await this.getCipher(
id,
(c) => c.type === CipherType.Login && !Utils.isNullOrWhitespace(c.login.username)
(c) => c.type === CipherType.Login && !Utils.isNullOrWhitespace(c.login.username),
);
if (!cipherResponse.success) {
return cipherResponse;
@@ -177,7 +177,7 @@ export class GetCommand extends DownloadCommand {
private async getPassword(id: string) {
const cipherResponse = await this.getCipher(
id,
(c) => c.type === CipherType.Login && !Utils.isNullOrWhitespace(c.login.password)
(c) => c.type === CipherType.Login && !Utils.isNullOrWhitespace(c.login.password),
);
if (!cipherResponse.success) {
return cipherResponse;
@@ -203,7 +203,7 @@ export class GetCommand extends DownloadCommand {
c.type === CipherType.Login &&
c.login.uris != null &&
c.login.uris.length > 0 &&
c.login.uris[0].uri !== ""
c.login.uris[0].uri !== "",
);
if (!cipherResponse.success) {
return cipherResponse;
@@ -229,7 +229,7 @@ export class GetCommand extends DownloadCommand {
private async getTotp(id: string) {
const cipherResponse = await this.getCipher(
id,
(c) => c.type === CipherType.Login && !Utils.isNullOrWhitespace(c.login.totp)
(c) => c.type === CipherType.Login && !Utils.isNullOrWhitespace(c.login.totp),
);
if (!cipherResponse.success) {
return cipherResponse;
@@ -287,7 +287,7 @@ export class GetCommand extends DownloadCommand {
}
const exposedNumber = await this.auditService.passwordLeaked(
(passwordResponse.data as StringResponse).data
(passwordResponse.data as StringResponse).data,
);
const res = new StringResponse(exposedNumber.toString());
return Response.success(res);
@@ -317,7 +317,7 @@ export class GetCommand extends DownloadCommand {
let attachments = cipher.attachments.filter(
(a) =>
a.id.toLowerCase() === id ||
(a.fileName != null && a.fileName.toLowerCase().indexOf(id) > -1)
(a.fileName != null && a.fileName.toLowerCase().indexOf(id) > -1),
);
if (attachments.length === 0) {
return Response.error("Attachment `" + id + "` was not found.");
@@ -343,7 +343,7 @@ export class GetCommand extends DownloadCommand {
try {
const attachmentDownloadResponse = await this.apiService.getAttachmentData(
cipher.id,
attachments[0].id
attachments[0].id,
);
url = attachmentDownloadResponse.url;
} catch (e) {
@@ -433,13 +433,13 @@ export class GetCommand extends DownloadCommand {
const decCollection = new CollectionView(response);
decCollection.name = await this.cryptoService.decryptToUtf8(
new EncString(response.name),
orgKey
orgKey,
);
const groups =
response.groups == null
? null
: response.groups.map(
(g) => new SelectionReadOnly(g.id, g.readOnly, g.hidePasswords, g.manage)
(g) => new SelectionReadOnly(g.id, g.readOnly, g.hidePasswords, g.manage),
);
const res = new OrganizationCollectionResponse(decCollection, groups);
return Response.success(res);

View File

@@ -35,7 +35,7 @@ export class ListCommand {
private searchService: SearchService,
private organizationUserService: OrganizationUserService,
private apiService: ApiService,
private eventCollectionService: EventCollectionService
private eventCollectionService: EventCollectionService,
) {}
async run(object: string, cmdOptions: Record<string, any>): Promise<Response> {
@@ -133,7 +133,7 @@ export class ListCommand {
EventType.Cipher_ClientViewed,
c.id,
index === ciphers.length - 1,
c.organizationId
c.organizationId,
);
});
@@ -229,7 +229,7 @@ export class ListCommand {
u.type = r.type;
u.twoFactorEnabled = r.twoFactorEnabled;
return u;
})
}),
);
return Response.success(res);
} catch (e) {

View File

@@ -67,7 +67,7 @@ export class ServeCommand {
this.main.searchService,
this.main.apiService,
this.main.organizationService,
this.main.eventCollectionService
this.main.eventCollectionService,
);
this.listCommand = new ListCommand(
this.main.cipherService,
@@ -77,7 +77,7 @@ export class ServeCommand {
this.main.searchService,
this.main.organizationUserService,
this.main.apiService,
this.main.eventCollectionService
this.main.eventCollectionService,
);
this.createCommand = new CreateCommand(
this.main.cipherService,
@@ -85,37 +85,37 @@ export class ServeCommand {
this.main.stateService,
this.main.cryptoService,
this.main.apiService,
this.main.folderApiService
this.main.folderApiService,
);
this.editCommand = new EditCommand(
this.main.cipherService,
this.main.folderService,
this.main.cryptoService,
this.main.apiService,
this.main.folderApiService
this.main.folderApiService,
);
this.generateCommand = new GenerateCommand(
this.main.passwordGenerationService,
this.main.stateService
this.main.stateService,
);
this.syncCommand = new SyncCommand(this.main.syncService);
this.statusCommand = new StatusCommand(
this.main.environmentService,
this.main.syncService,
this.main.stateService,
this.main.authService
this.main.authService,
);
this.deleteCommand = new DeleteCommand(
this.main.cipherService,
this.main.folderService,
this.main.stateService,
this.main.apiService,
this.main.folderApiService
this.main.folderApiService,
);
this.confirmCommand = new ConfirmCommand(
this.main.apiService,
this.main.cryptoService,
this.main.organizationUserService
this.main.organizationUserService,
);
this.restoreCommand = new RestoreCommand(this.main.cipherService);
this.shareCommand = new ShareCommand(this.main.cipherService);
@@ -130,36 +130,36 @@ export class ServeCommand {
this.main.environmentService,
this.main.syncService,
this.main.organizationApiService,
async () => await this.main.logout()
async () => await this.main.logout(),
);
this.sendCreateCommand = new SendCreateCommand(
this.main.sendService,
this.main.stateService,
this.main.environmentService,
this.main.sendApiService
this.main.sendApiService,
);
this.sendDeleteCommand = new SendDeleteCommand(this.main.sendService, this.main.sendApiService);
this.sendGetCommand = new SendGetCommand(
this.main.sendService,
this.main.environmentService,
this.main.searchService,
this.main.cryptoService
this.main.cryptoService,
);
this.sendEditCommand = new SendEditCommand(
this.main.sendService,
this.main.stateService,
this.sendGetCommand,
this.main.sendApiService
this.main.sendApiService,
);
this.sendListCommand = new SendListCommand(
this.main.sendService,
this.main.environmentService,
this.main.searchService
this.main.searchService,
);
this.sendRemovePasswordCommand = new SendRemovePasswordCommand(
this.main.sendService,
this.main.sendApiService
this.main.sendApiService,
);
}
@@ -170,7 +170,7 @@ export class ServeCommand {
this.main.logService.info(
`Starting server on ${hostname}:${port} with ${
protectOrigin ? "origin protection" : "no origin protection"
}`
}`,
);
const server = new koa();
@@ -187,7 +187,7 @@ export class ServeCommand {
Utils.isNullOrEmpty(ctx.headers.origin)
? "(Origin header value missing)"
: ctx.headers.origin
}"`
}"`,
);
return;
}
@@ -252,7 +252,7 @@ export class ServeCommand {
const response = await this.unlockCommand.run(
ctx.request.body.password == null ? null : (ctx.request.body.password as string),
ctx.request.query
ctx.request.query,
);
this.processResponse(ctx.response, response);
await next();
@@ -266,7 +266,7 @@ export class ServeCommand {
const response = await this.confirmCommand.run(
ctx.params.object,
ctx.params.id,
ctx.request.query
ctx.request.query,
);
this.processResponse(ctx.response, response);
await next();
@@ -290,7 +290,7 @@ export class ServeCommand {
const response = await this.shareCommand.run(
ctx.params.id,
ctx.params.organizationId,
ctx.request.body // TODO: Check the format of this body for an array of collection ids
ctx.request.body, // TODO: Check the format of this body for an array of collection ids
);
this.processResponse(ctx.response, response);
await next();
@@ -308,7 +308,7 @@ export class ServeCommand {
{
fileBuffer: ctx.request.file.buffer,
fileName: ctx.request.file.originalname,
}
},
);
this.processResponse(ctx.response, response);
await next();
@@ -336,7 +336,7 @@ export class ServeCommand {
response = await this.createCommand.run(
ctx.params.object,
ctx.request.body,
ctx.request.query
ctx.request.query,
);
}
this.processResponse(ctx.response, response);
@@ -357,7 +357,7 @@ export class ServeCommand {
ctx.params.object,
ctx.params.id,
ctx.request.body,
ctx.request.query
ctx.request.query,
);
}
this.processResponse(ctx.response, response);
@@ -391,7 +391,7 @@ export class ServeCommand {
response = await this.deleteCommand.run(
ctx.params.object,
ctx.params.id,
ctx.request.query
ctx.request.query,
);
}
this.processResponse(ctx.response, response);

View File

@@ -12,7 +12,7 @@ export class StatusCommand {
private envService: EnvironmentService,
private syncService: SyncService,
private stateService: StateService,
private authService: AuthService
private authService: AuthService,
) {}
async run(): Promise<Response> {
@@ -30,7 +30,7 @@ export class StatusCommand {
userEmail: email,
userId: userId,
status: status,
})
}),
);
} catch (e) {
return Response.error(e);

View File

@@ -11,8 +11,8 @@ export class Response {
error.message != null
? error.message
: error.toString() === "[object Object]"
? JSON.stringify(error)
: error.toString();
? JSON.stringify(error)
: error.toString();
}
res.data = data;
return res;

View File

@@ -11,7 +11,10 @@ export class CliPlatformUtilsService implements PlatformUtilsService {
private deviceCache: DeviceType = null;
constructor(clientType: ClientType, private packageJson: any) {
constructor(
clientType: ClientType,
private packageJson: any,
) {
this.clientType = clientType;
}
@@ -107,7 +110,7 @@ export class CliPlatformUtilsService implements PlatformUtilsService {
type: "error" | "success" | "warning" | "info",
title: string,
text: string | string[],
options?: any
options?: any,
): void {
throw new Error("Not implemented.");
}

View File

@@ -8,7 +8,7 @@ export class I18nService extends BaseI18nService {
super(systemLanguage, localesDirectory, (formattedLocale: string) => {
const filePath = path.join(
__dirname,
this.localesDirectory + "/" + formattedLocale + "/messages.json"
this.localesDirectory + "/" + formattedLocale + "/messages.json",
);
const localesJson = fs.readFileSync(filePath, "utf8");
const locales = JSON.parse(localesJson.replace(/^\uFEFF/, "")); // strip the BOM

View File

@@ -36,7 +36,7 @@ export class LowdbStorageService implements AbstractStorageService {
defaults?: any,
private dir?: string,
private allowCache = false,
private requireLock = false
private requireLock = false,
) {
this.defaults = defaults;
this.updates$ = this.updatesSubject.asObservable();
@@ -59,7 +59,7 @@ export class LowdbStorageService implements AbstractStorageService {
this.dataFilePath = path.join(this.dir, "data.json");
if (!fs.existsSync(this.dataFilePath)) {
this.logService.warning(
`Could not find data file, "${this.dataFilePath}"; creating it instead.`
`Could not find data file, "${this.dataFilePath}"; creating it instead.`,
);
fs.writeFileSync(this.dataFilePath, "", { mode: 0o600 });
fs.chmodSync(this.dataFilePath, 0o600);
@@ -78,14 +78,14 @@ export class LowdbStorageService implements AbstractStorageService {
} catch (e) {
if (e instanceof SyntaxError) {
this.logService.warning(
`Error creating lowdb storage adapter, "${e.message}"; emptying data file.`
`Error creating lowdb storage adapter, "${e.message}"; emptying data file.`,
);
if (fs.existsSync(this.dataFilePath)) {
const backupPath = this.dataFilePath + ".bak";
this.logService.warning(`Writing backup of data file to ${backupPath}`);
await fs.copyFile(this.dataFilePath, backupPath, () => {
this.logService.warning(
`Error while creating data file backup, "${e.message}". No backup may have been created.`
`Error while creating data file backup, "${e.message}". No backup may have been created.`,
);
});
}

View File

@@ -21,7 +21,7 @@ export class NodeApiService extends ApiService {
environmentService: EnvironmentService,
appIdService: AppIdService,
logoutCallback: (expired: boolean) => Promise<void>,
customUserAgent: string = null
customUserAgent: string = null,
) {
super(
tokenService,
@@ -29,7 +29,7 @@ export class NodeApiService extends ApiService {
environmentService,
appIdService,
logoutCallback,
customUserAgent
customUserAgent,
);
}

View File

@@ -11,7 +11,7 @@ export class NodeEnvSecureStorageService implements AbstractStorageService {
constructor(
private storageService: AbstractStorageService,
private logService: LogService,
private cryptoService: () => CryptoService
private cryptoService: () => CryptoService,
) {}
get valuesRequireDeserialization(): boolean {
@@ -20,7 +20,7 @@ export class NodeEnvSecureStorageService implements AbstractStorageService {
get updates$() {
return throwError(
() => new Error("Secure storage implementations cannot have their updates subscribed to.")
() => new Error("Secure storage implementations cannot have their updates subscribed to."),
);
}
@@ -61,7 +61,7 @@ export class NodeEnvSecureStorageService implements AbstractStorageService {
}
const encValue = await this.cryptoService().encryptToBytes(
Utils.fromB64ToArray(plainValue),
sessionKey
sessionKey,
);
if (encValue == null) {
throw new Error("Value didn't encrypt.");

View File

@@ -86,7 +86,7 @@ export class Program {
writeLn(' echo \'{"name":"My Folder"}\' | bw encode');
writeLn(" bw create folder eyJuYW1lIjoiTXkgRm9sZGVyIn0K");
writeLn(
" bw edit folder c7c7b60b-9c61-40f2-8ccd-36c49595ed72 eyJuYW1lIjoiTXkgRm9sZGVyMiJ9Cg=="
" bw edit folder c7c7b60b-9c61-40f2-8ccd-36c49595ed72 eyJuYW1lIjoiTXkgRm9sZGVyMiJ9Cg==",
);
writeLn(" bw delete item 99ee88d2-6046-4ea7-92c2-acac464b1412");
writeLn(" bw generate -lusn --length 18");
@@ -95,7 +95,7 @@ export class Program {
writeLn(' bw send "text to send"');
writeLn(' echo "text to send" | bw send');
writeLn(
" bw receive https://vault.bitwarden.com/#/send/rg3iuoS_Akm2gqy6ADRHmg/Ht7dYjsqjmgqUM3rjzZDSQ"
" bw receive https://vault.bitwarden.com/#/send/rg3iuoS_Akm2gqy6ADRHmg/Ht7dYjsqjmgqUM3rjzZDSQ",
);
writeLn("", true);
});
@@ -110,7 +110,7 @@ export class Program {
.option("--passwordenv <passwordenv>", "Environment variable storing your password")
.option(
"--passwordfile <passwordfile>",
"Path to a file containing your password as its first line"
"Path to a file containing your password as its first line",
)
.option("--check", "Check login status.", async () => {
const authed = await this.main.stateService.getIsAuthenticated();
@@ -154,7 +154,7 @@ export class Program {
this.main.keyConnectorService,
this.main.policyApiService,
this.main.organizationService,
async () => await this.main.logout()
async () => await this.main.logout(),
);
const response = await command.run(email, password, options);
this.processResponse(response, true);
@@ -175,7 +175,7 @@ export class Program {
const command = new LogoutCommand(
this.main.authService,
this.main.i18nService,
async () => await this.main.logout()
async () => await this.main.logout(),
);
const response = await command.run();
this.processResponse(response);
@@ -197,15 +197,15 @@ export class Program {
const logoutCommand = new LogoutCommand(
this.main.authService,
this.main.i18nService,
async () => await this.main.logout()
async () => await this.main.logout(),
);
await logoutCommand.run();
this.processResponse(
Response.error(
"You cannot lock your vault because you are using Key Connector. " +
"To protect your vault, you have been logged out."
"To protect your vault, you have been logged out.",
),
true
true,
);
return;
}
@@ -246,7 +246,7 @@ export class Program {
.option("--passwordenv <passwordenv>", "Environment variable storing your password")
.option(
"--passwordfile <passwordfile>",
"Path to a file containing your password as its first line"
"Path to a file containing your password as its first line",
)
.action(async (password, cmd) => {
if (!cmd.check) {
@@ -261,7 +261,7 @@ export class Program {
this.main.environmentService,
this.main.syncService,
this.main.organizationApiService,
async () => await this.main.logout()
async () => await this.main.logout(),
);
const response = await command.run(password, cmd);
this.processResponse(response);
@@ -326,7 +326,7 @@ export class Program {
.action(async (options) => {
const command = new GenerateCommand(
this.main.passwordGenerationService,
this.main.stateService
this.main.stateService,
);
const response = await command.run(options);
this.processResponse(response);
@@ -356,17 +356,17 @@ export class Program {
.description("Configure CLI settings.")
.option(
"--web-vault <url>",
"Provides a custom web vault URL that differs from the base URL."
"Provides a custom web vault URL that differs from the base URL.",
)
.option("--api <url>", "Provides a custom API URL that differs from the base URL.")
.option("--identity <url>", "Provides a custom identity URL that differs from the base URL.")
.option(
"--icons <url>",
"Provides a custom icons service URL that differs from the base URL."
"Provides a custom icons service URL that differs from the base URL.",
)
.option(
"--notifications <url>",
"Provides a custom notifications URL that differs from the base URL."
"Provides a custom notifications URL that differs from the base URL.",
)
.option("--events <url>", "Provides a custom events URL that differs from the base URL.")
.option("--key-connector <url>", "Provides the URL for your Key Connector server.")
@@ -381,7 +381,7 @@ export class Program {
writeLn(" bw config server https://bw.company.com");
writeLn(" bw config server bitwarden.com");
writeLn(
" bw config server --api http://localhost:4000 --identity http://localhost:33656"
" bw config server --api http://localhost:4000 --identity http://localhost:33656",
);
writeLn("", true);
})
@@ -462,7 +462,7 @@ export class Program {
this.main.environmentService,
this.main.syncService,
this.main.stateService,
this.main.authService
this.main.authService,
);
const response = await command.run();
this.processResponse(response);
@@ -475,7 +475,7 @@ export class Program {
.option("--port <port>", "The port to run your API webserver on.")
.option(
"--disable-origin-protection",
"If set, allows requests with origin header. Warning, this option exists for backwards compatibility reasons and exposes your environment to known CSRF attacks."
"If set, allows requests with origin header. Warning, this option exists for backwards compatibility reasons and exposes your environment to known CSRF attacks.",
)
.on("--help", () => {
writeLn("\n Notes:");
@@ -606,7 +606,7 @@ export class Program {
if (await this.main.keyConnectorService.getUsesKeyConnector()) {
const response = Response.error(
"Your vault is locked. You must unlock your vault using your session key.\n" +
"If you do not have your session key, you can get a new one by logging out and logging in again."
"If you do not have your session key, you can get a new one by logging out and logging in again.",
);
this.processResponse(response, true);
} else {
@@ -620,7 +620,7 @@ export class Program {
this.main.environmentService,
this.main.syncService,
this.main.organizationApiService,
this.main.logout
this.main.logout,
);
const response = await command.run(null, null);
if (!response.success) {

View File

@@ -19,7 +19,7 @@ export class ExportCommand {
constructor(
private exportService: VaultExportServiceAbstraction,
private policyService: PolicyService,
private eventCollectionService: EventCollectionService
private eventCollectionService: EventCollectionService,
) {}
async run(options: program.OptionValues): Promise<Response> {
@@ -28,7 +28,7 @@ export class ExportCommand {
(await this.policyService.policyAppliesToUser(PolicyType.DisablePersonalVaultExport))
) {
return Response.badRequest(
"One or more organization policies prevents you from exporting your personal vault."
"One or more organization policies prevents you from exporting your personal vault.",
);
}
@@ -36,8 +36,8 @@ export class ExportCommand {
if (!this.isSupportedExportFormat(format)) {
return Response.badRequest(
`'${format}' is not a supported export format. Supported formats: ${EXPORT_FORMATS.join(
", "
)}.`
", ",
)}.`,
);
}
@@ -76,7 +76,7 @@ export class ExportCommand {
private async saveFile(
exportContent: string,
options: program.OptionValues,
format: ExportFormat
format: ExportFormat,
): Promise<Response> {
try {
const fileName = this.getFileName(format, options.organizationid != null ? "org" : null);

View File

@@ -9,7 +9,7 @@ import { CliUtils } from "../utils";
export class GenerateCommand {
constructor(
private passwordGenerationService: PasswordGenerationServiceAbstraction,
private stateService: StateService
private stateService: StateService,
) {}
async run(cmdOptions: Record<string, any>): Promise<Response> {

View File

@@ -13,13 +13,13 @@ export class ImportCommand {
constructor(
private importService: ImportServiceAbstraction,
private organizationService: OrganizationService,
private syncService: SyncService
private syncService: SyncService,
) {}
async run(
format: ImportType,
filepath: string,
options: program.OptionValues
options: program.OptionValues,
): Promise<Response> {
const organizationId = options.organizationid;
if (organizationId != null) {
@@ -27,13 +27,13 @@ export class ImportCommand {
if (organization == null) {
return Response.badRequest(
`You do not belong to an organization with the ID of ${organizationId}. Check the organization ID and sync your vault.`
`You do not belong to an organization with the ID of ${organizationId}. Check the organization ID and sync your vault.`,
);
}
if (!organization.canAccessImportExport) {
return Response.badRequest(
"You are not authorized to import into the provided organization."
"You are not authorized to import into the provided organization.",
);
}
}
@@ -58,7 +58,7 @@ export class ImportCommand {
const importer = await this.importService.getImporter(
format,
promptForPassword_callback,
organizationId
organizationId,
);
if (importer === null) {
return Response.badRequest("Proper importer type required.");

View File

@@ -18,7 +18,7 @@ export class SendCreateCommand {
private sendService: SendService,
private stateService: StateService,
private environmentService: EnvironmentService,
private sendApiService: SendApiService
private sendApiService: SendApiService,
) {}
async run(requestJson: any, cmdOptions: Record<string, any>) {
@@ -78,7 +78,7 @@ export class SendCreateCommand {
case SendType.File:
if (process.env.BW_SERVE === "true") {
return Response.error(
"Creating a file-based Send is unsupported through the `serve` command at this time."
"Creating a file-based Send is unsupported through the `serve` command at this time.",
);
}
@@ -88,7 +88,7 @@ export class SendCreateCommand {
if (filePath == null) {
return Response.badRequest(
"Must specify a file to Send either with the --file option or in the request JSON."
"Must specify a file to Send either with the --file option or in the request JSON.",
);
}
@@ -97,7 +97,7 @@ export class SendCreateCommand {
case SendType.Text:
if (text == null) {
return Response.badRequest(
"Must specify text content to Send either with the --text option or in the request JSON."
"Must specify text content to Send either with the --text option or in the request JSON.",
);
}
req.text = new SendTextResponse();
@@ -106,7 +106,7 @@ export class SendCreateCommand {
break;
default:
return Response.badRequest(
"Unknown Send type " + SendType[req.type] + ". Valid types are: file, text"
"Unknown Send type " + SendType[req.type] + ". Valid types are: file, text",
);
}

View File

@@ -4,7 +4,10 @@ import { SendService } from "@bitwarden/common/tools/send/services/send.service.
import { Response } from "../../../models/response";
export class SendDeleteCommand {
constructor(private sendService: SendService, private sendApiService: SendApiService) {}
constructor(
private sendService: SendService,
private sendApiService: SendApiService,
) {}
async run(id: string) {
const send = await this.sendService.getFromState(id);

View File

@@ -14,7 +14,7 @@ export class SendEditCommand {
private sendService: SendService,
private stateService: StateService,
private getCommand: SendGetCommand,
private sendApiService: SendApiService
private sendApiService: SendApiService,
) {}
async run(requestJson: string, cmdOptions: Record<string, any>): Promise<Response> {

View File

@@ -16,7 +16,7 @@ export class SendGetCommand extends DownloadCommand {
private sendService: SendService,
private environmentService: EnvironmentService,
private searchService: SearchService,
cryptoService: CryptoService
cryptoService: CryptoService,
) {
super(cryptoService);
}

View File

@@ -10,7 +10,7 @@ export class SendListCommand {
constructor(
private sendService: SendService,
private environmentService: EnvironmentService,
private searchService: SearchService
private searchService: SearchService,
) {}
async run(cmdOptions: Record<string, any>): Promise<Response> {

View File

@@ -31,7 +31,7 @@ export class SendReceiveCommand extends DownloadCommand {
private cryptoFunctionService: CryptoFunctionService,
private platformUtilsService: PlatformUtilsService,
private environmentService: EnvironmentService,
private sendApiService: SendApiService
private sendApiService: SendApiService,
) {
super(cryptoService);
}
@@ -89,13 +89,13 @@ export class SendReceiveCommand extends DownloadCommand {
const downloadData = await this.sendApiService.getSendFileDownloadData(
response,
this.sendAccessRequest,
apiUrl
apiUrl,
);
return await this.saveAttachmentToFile(
downloadData.url,
this.decKey,
response?.file?.fileName,
options.output
options.output,
);
}
default:
@@ -126,7 +126,7 @@ export class SendReceiveCommand extends DownloadCommand {
password,
keyArray,
"sha256",
100000
100000,
);
return Utils.fromBufferToB64(passwordHash);
}
@@ -134,13 +134,13 @@ export class SendReceiveCommand extends DownloadCommand {
private async sendRequest(
url: string,
id: string,
key: Uint8Array
key: Uint8Array,
): Promise<Response | SendAccessView> {
try {
const sendResponse = await this.sendApiService.postSendAccess(
id,
this.sendAccessRequest,
url
url,
);
const sendAccess = new SendAccess(sendResponse);

View File

@@ -5,7 +5,10 @@ import { Response } from "../../../models/response";
import { SendResponse } from "../models/send.response";
export class SendRemovePasswordCommand {
constructor(private sendService: SendService, private sendApiService: SendApiService) {}
constructor(
private sendService: SendService,
private sendApiService: SendApiService,
) {}
async run(id: string) {
try {

View File

@@ -46,24 +46,24 @@ export class SendProgram extends Program {
"Work with Bitwarden sends. A Send can be quickly created using this command or subcommands can be used to fine-tune the Send",
{
data: "The data to Send. Specify as a filepath with the --file option",
}
},
)
.option("-f, --file", "Specifies that <data> is a filepath")
.option(
"-d, --deleteInDays <days>",
"The number of days in the future to set deletion date, defaults to 7",
"7"
"7",
)
.option("-a, --maxAccessCount <amount>", "The amount of max possible accesses.")
.option("--hidden", "Hide <data> in web by default. Valid only if --file is not set.")
.option(
"-n, --name <name>",
"The name of the Send. Defaults to a guid for text Sends and the filename for files."
"The name of the Send. Defaults to a guid for text Sends and the filename for files.",
)
.option("--notes <notes>", "Notes to add to the Send.")
.option(
"--fullObject",
"Specifies that the full Send object should be returned rather than just the access url."
"Specifies that the full Send object should be returned rather than just the access url.",
)
.addCommand(this.listCommand())
.addCommand(this.templateCommand())
@@ -95,14 +95,14 @@ export class SendProgram extends Program {
.option("--passwordenv <passwordenv>", "Environment variable storing the Send's password")
.option(
"--passwordfile <passwordfile>",
"Path to a file containing the Sends password as its first line"
"Path to a file containing the Sends password as its first line",
)
.option("--obj", "Return the Send's json object rather than the Send's content")
.option("--output <location>", "Specify a file path to save a File-type Send to")
.on("--help", () => {
writeLn("");
writeLn(
"If a password is required, the provided password is used or the user is prompted."
"If a password is required, the provided password is used or the user is prompted.",
);
writeLn("", true);
})
@@ -113,7 +113,7 @@ export class SendProgram extends Program {
this.main.cryptoFunctionService,
this.main.platformUtilsService,
this.main.environmentService,
this.main.sendApiService
this.main.sendApiService,
);
const response = await cmd.run(url, options);
this.processResponse(response);
@@ -132,7 +132,7 @@ export class SendProgram extends Program {
const cmd = new SendListCommand(
this.main.sendService,
this.main.environmentService,
this.main.searchService
this.main.searchService,
);
const response = await cmd.run(options);
this.processResponse(response);
@@ -157,7 +157,7 @@ export class SendProgram extends Program {
this.main.searchService,
this.main.apiService,
this.main.organizationService,
this.main.eventCollectionService
this.main.eventCollectionService,
);
const response = await cmd.run("template", object, null);
this.processResponse(response);
@@ -195,7 +195,7 @@ export class SendProgram extends Program {
this.main.sendService,
this.main.environmentService,
this.main.searchService,
this.main.cryptoService
this.main.cryptoService,
);
const response = await cmd.run(id, options);
this.processResponse(response);
@@ -213,7 +213,7 @@ export class SendProgram extends Program {
.option("--hidden", "text hidden flag. Valid only with the --text option.")
.option(
"--password <password>",
"optional password to access this Send. Can also be specified in JSON"
"optional password to access this Send. Can also be specified in JSON",
)
.on("--help", () => {
writeLn("");
@@ -225,7 +225,7 @@ export class SendProgram extends Program {
async (
encodedJson: string,
options: program.OptionValues,
args: { parent: program.Command }
args: { parent: program.Command },
) => {
// Work-around to support `--fullObject` option for `send create --fullObject`
// Calling `option('--fullObject', ...)` above won't work due to Commander doesn't like same option
@@ -238,7 +238,7 @@ export class SendProgram extends Program {
const response = await this.runCreate(encodedJson, mergedOptions);
this.processResponse(response);
}
},
);
}
@@ -262,13 +262,13 @@ export class SendProgram extends Program {
this.main.sendService,
this.main.environmentService,
this.main.searchService,
this.main.cryptoService
this.main.cryptoService,
);
const cmd = new SendEditCommand(
this.main.sendService,
this.main.stateService,
getCmd,
this.main.sendApiService
this.main.sendApiService,
);
const response = await cmd.run(encodedJson, options);
this.processResponse(response);
@@ -338,7 +338,7 @@ export class SendProgram extends Program {
this.main.sendService,
this.main.stateService,
this.main.environmentService,
this.main.sendApiService
this.main.sendApiService,
);
return await cmd.run(encodedJson, options);
}

View File

@@ -69,7 +69,7 @@ export class CliUtils {
},
(reason) => {
reject(reason);
}
},
);
});
});
@@ -216,7 +216,7 @@ export class CliUtils {
static async getPassword(
password: string,
options: { passwordFile?: string; passwordEnv?: string },
logService?: LogService
logService?: LogService,
): Promise<string | Response> {
if (Utils.isNullOrEmpty(password)) {
if (options?.passwordFile) {
@@ -243,7 +243,7 @@ export class CliUtils {
password = answer.password;
} else {
return Response.badRequest(
"Master password is required. Try again in interactive mode or provide a password file or environment variable."
"Master password is required. Try again in interactive mode or provide a password file or environment variable.",
);
}
}

View File

@@ -47,8 +47,8 @@ export class VaultProgram extends Program {
requestedObject +
'". Allowed objects are ' +
validObjects.join(", ") +
"."
)
".",
),
);
}
return success;
@@ -75,7 +75,7 @@ export class VaultProgram extends Program {
.option("--collectionid <collectionid>", "Filter items by collection id.")
.option(
"--organizationid <organizationid>",
"Filter items or collections by organization id."
"Filter items or collections by organization id.",
)
.option("--trash", "Filter items that are deleted and in the trash.")
.on("--help", () => {
@@ -90,13 +90,13 @@ export class VaultProgram extends Program {
writeLn(" bw list items");
writeLn(" bw list items --folderid 60556c31-e649-4b5d-8daf-fc1c391a1bf2");
writeLn(
" bw list items --search google --folderid 60556c31-e649-4b5d-8daf-fc1c391a1bf2"
" bw list items --search google --folderid 60556c31-e649-4b5d-8daf-fc1c391a1bf2",
);
writeLn(" bw list items --url https://google.com");
writeLn(" bw list items --folderid null");
writeLn(" bw list items --organizationid notnull");
writeLn(
" bw list items --folderid 60556c31-e649-4b5d-8daf-fc1c391a1bf2 --organizationid notnull"
" bw list items --folderid 60556c31-e649-4b5d-8daf-fc1c391a1bf2 --organizationid notnull",
);
writeLn(" bw list items --trash");
writeLn(" bw list folders --search email");
@@ -117,7 +117,7 @@ export class VaultProgram extends Program {
this.main.searchService,
this.main.organizationUserService,
this.main.apiService,
this.main.eventCollectionService
this.main.eventCollectionService,
);
const response = await command.run(object, cmd);
@@ -165,10 +165,10 @@ export class VaultProgram extends Program {
writeLn(" bw get exposed yahoo.com");
writeLn(
" bw get attachment b857igwl1dzrs2 --itemid 99ee88d2-6046-4ea7-92c2-acac464b1412 " +
"--output ./photo.jpg"
"--output ./photo.jpg",
);
writeLn(
" bw get attachment photo.jpg --itemid 99ee88d2-6046-4ea7-92c2-acac464b1412 --raw"
" bw get attachment photo.jpg --itemid 99ee88d2-6046-4ea7-92c2-acac464b1412 --raw",
);
writeLn(" bw get folder email");
writeLn(" bw get template folder");
@@ -191,7 +191,7 @@ export class VaultProgram extends Program {
this.main.searchService,
this.main.apiService,
this.main.organizationService,
this.main.eventCollectionService
this.main.eventCollectionService,
);
const response = await command.run(object, id, cmd);
this.processResponse(response);
@@ -216,7 +216,7 @@ export class VaultProgram extends Program {
writeLn(" echo 'eyJuYW1lIjoiTXkgRm9sZGVyIn0K' | bw create folder");
writeLn(
" bw create attachment --file ./myfile.csv " +
"--itemid 16b15b89-65b3-4639-ad2a-95052a6d8f66"
"--itemid 16b15b89-65b3-4639-ad2a-95052a6d8f66",
);
writeLn("", true);
})
@@ -232,7 +232,7 @@ export class VaultProgram extends Program {
this.main.stateService,
this.main.cryptoService,
this.main.apiService,
this.main.folderApiService
this.main.folderApiService,
);
const response = await command.run(object, encodedJson, cmd);
this.processResponse(response);
@@ -253,15 +253,15 @@ export class VaultProgram extends Program {
writeLn("\n Examples:");
writeLn("");
writeLn(
" bw edit folder 5cdfbd80-d99f-409b-915b-f4c5d0241b02 eyJuYW1lIjoiTXkgRm9sZGVyMiJ9Cg=="
" bw edit folder 5cdfbd80-d99f-409b-915b-f4c5d0241b02 eyJuYW1lIjoiTXkgRm9sZGVyMiJ9Cg==",
);
writeLn(
" echo 'eyJuYW1lIjoiTXkgRm9sZGVyMiJ9Cg==' | " +
"bw edit folder 5cdfbd80-d99f-409b-915b-f4c5d0241b02"
"bw edit folder 5cdfbd80-d99f-409b-915b-f4c5d0241b02",
);
writeLn(
" bw edit item-collections 78307355-fd25-416b-88b8-b33fd0e88c82 " +
"WyI5NzQwNTNkMC0zYjMzLTRiOTgtODg2ZS1mZWNmNWM4ZGJhOTYiXQ=="
"WyI5NzQwNTNkMC0zYjMzLTRiOTgtODg2ZS1mZWNmNWM4ZGJhOTYiXQ==",
);
writeLn("", true);
})
@@ -276,7 +276,7 @@ export class VaultProgram extends Program {
this.main.folderService,
this.main.cryptoService,
this.main.apiService,
this.main.folderApiService
this.main.folderApiService,
);
const response = await command.run(object, id, encodedJson, cmd);
this.processResponse(response);
@@ -295,7 +295,7 @@ export class VaultProgram extends Program {
.option("--organizationid <organizationid>", "Organization id for an organization object.")
.option(
"-p, --permanent",
"Permanently deletes the item instead of soft-deleting it (item only)."
"Permanently deletes the item instead of soft-deleting it (item only).",
)
.on("--help", () => {
writeLn("\n Examples:");
@@ -304,7 +304,7 @@ export class VaultProgram extends Program {
writeLn(" bw delete item 89c21cd2-fab0-4f69-8c6e-ab8a0168f69a --permanent");
writeLn(" bw delete folder 5cdfbd80-d99f-409b-915b-f4c5d0241b02");
writeLn(
" bw delete attachment b857igwl1dzrs2 --itemid 310d5ffd-e9a2-4451-af87-ea054dce0f78"
" bw delete attachment b857igwl1dzrs2 --itemid 310d5ffd-e9a2-4451-af87-ea054dce0f78",
);
writeLn("", true);
})
@@ -319,7 +319,7 @@ export class VaultProgram extends Program {
this.main.folderService,
this.main.stateService,
this.main.apiService,
this.main.folderApiService
this.main.folderApiService,
);
const response = await command.run(object, id, cmd);
this.processResponse(response);
@@ -367,13 +367,13 @@ export class VaultProgram extends Program {
" bw " +
commandName +
" 4af958ce-96a7-45d9-beed-1e70fabaa27a " +
"6d82949b-b44d-468a-adae-3f3bacb0ea32 WyI5NzQwNTNkMC0zYjMzLTRiOTgtODg2ZS1mZWNmNWM4ZGJhOTYiXQ=="
"6d82949b-b44d-468a-adae-3f3bacb0ea32 WyI5NzQwNTNkMC0zYjMzLTRiOTgtODg2ZS1mZWNmNWM4ZGJhOTYiXQ==",
);
writeLn(
" echo '[\"974053d0-3b33-4b98-886e-fecf5c8dba96\"]' | bw encode | " +
"bw " +
commandName +
" 4af958ce-96a7-45d9-beed-1e70fabaa27a 6d82949b-b44d-468a-adae-3f3bacb0ea32"
" 4af958ce-96a7-45d9-beed-1e70fabaa27a 6d82949b-b44d-468a-adae-3f3bacb0ea32",
);
if (deprecated) {
writeLn("");
@@ -403,7 +403,7 @@ export class VaultProgram extends Program {
writeLn("");
writeLn(
" bw confirm org-member 7063feab-4b10-472e-b64c-785e2b870b92 " +
"--organizationid 310d5ffd-e9a2-4451-af87-ea054dce0f78"
"--organizationid 310d5ffd-e9a2-4451-af87-ea054dce0f78",
);
writeLn("", true);
})
@@ -416,7 +416,7 @@ export class VaultProgram extends Program {
const command = new ConfirmCommand(
this.main.apiService,
this.main.cryptoService,
this.main.organizationUserService
this.main.organizationUserService,
);
const response = await command.run(object, id, cmd);
this.processResponse(response);
@@ -439,7 +439,7 @@ export class VaultProgram extends Program {
writeLn(" bw import bitwardencsv ./from/source.csv");
writeLn(" bw import keepass2xml keepass_backup.xml");
writeLn(
" bw import --organizationid cf14adc3-aca5-4573-890a-f6fa231436d9 keepass2xml keepass_backup.xml"
" bw import --organizationid cf14adc3-aca5-4573-890a-f6fa231436d9 keepass2xml keepass_backup.xml",
);
})
.action(async (format, filepath, options) => {
@@ -447,7 +447,7 @@ export class VaultProgram extends Program {
const command = new ImportCommand(
this.main.importService,
this.main.organizationService,
this.main.syncService
this.main.syncService,
);
const response = await command.run(format, filepath, options);
this.processResponse(response);
@@ -461,18 +461,18 @@ export class VaultProgram extends Program {
.option("--format <format>", "Export file format.")
.option(
"--password [password]",
"Use password to encrypt instead of your Bitwarden account encryption key. Only applies to the encrypted_json format."
"Use password to encrypt instead of your Bitwarden account encryption key. Only applies to the encrypted_json format.",
)
.option("--organizationid <organizationid>", "Organization id for an organization.")
.on("--help", () => {
writeLn("\n Notes:");
writeLn("");
writeLn(
" Valid formats are `csv`, `json`, and `encrypted_json`. Default format is `csv`."
" Valid formats are `csv`, `json`, and `encrypted_json`. Default format is `csv`.",
);
writeLn("");
writeLn(
" If --raw option is specified and no output filename or directory is given, the"
" If --raw option is specified and no output filename or directory is given, the",
);
writeLn(" result is written to stdout.");
writeLn("");
@@ -485,7 +485,7 @@ export class VaultProgram extends Program {
writeLn(" bw export --output ./exp/bw.csv");
writeLn(" bw export myPassword321 --output bw.json --format json");
writeLn(
" bw export myPassword321 --organizationid 7063feab-4b10-472e-b64c-785e2b870b92"
" bw export myPassword321 --organizationid 7063feab-4b10-472e-b64c-785e2b870b92",
);
writeLn("", true);
})
@@ -494,7 +494,7 @@ export class VaultProgram extends Program {
const command = new ExportCommand(
this.main.exportService,
this.main.policyService,
this.main.eventCollectionService
this.main.eventCollectionService,
);
const response = await command.run(options);
this.processResponse(response);

View File

@@ -29,14 +29,14 @@ export class CreateCommand {
private stateService: StateService,
private cryptoService: CryptoService,
private apiService: ApiService,
private folderApiService: FolderApiServiceAbstraction
private folderApiService: FolderApiServiceAbstraction,
) {}
async run(
object: string,
requestJson: string,
cmdOptions: Record<string, any>,
additionalData: any = null
additionalData: any = null,
): Promise<Response> {
let req: any = null;
if (object !== "attachment") {
@@ -81,7 +81,7 @@ export class CreateCommand {
await this.cipherService.createWithServer(cipher);
const newCipher = await this.cipherService.get(cipher.id);
const decCipher = await newCipher.decrypt(
await this.cipherService.getKeyForCipherKeyDecryption(newCipher)
await this.cipherService.getKeyForCipherKeyDecryption(newCipher),
);
const res = new CipherResponse(decCipher);
return Response.success(res);
@@ -132,7 +132,7 @@ export class CreateCommand {
if (userKey == null) {
return Response.error(
"You must update your encryption key before you can use this feature. " +
"See https://help.bitwarden.com/article/update-encryption-key/"
"See https://help.bitwarden.com/article/update-encryption-key/",
);
}
@@ -140,11 +140,11 @@ export class CreateCommand {
await this.cipherService.saveAttachmentRawWithServer(
cipher,
fileName,
new Uint8Array(fileBuf).buffer
new Uint8Array(fileBuf).buffer,
);
const updatedCipher = await this.cipherService.get(cipher.id);
const decCipher = await updatedCipher.decrypt(
await this.cipherService.getKeyForCipherKeyDecryption(updatedCipher)
await this.cipherService.getKeyForCipherKeyDecryption(updatedCipher),
);
return Response.success(new CipherResponse(decCipher));
} catch (e) {
@@ -185,7 +185,7 @@ export class CreateCommand {
req.groups == null
? null
: req.groups.map(
(g) => new SelectionReadOnlyRequest(g.id, g.readOnly, g.hidePasswords, g.manage)
(g) => new SelectionReadOnlyRequest(g.id, g.readOnly, g.hidePasswords, g.manage),
);
const request = new CollectionRequest();
request.name = (await this.cryptoService.encrypt(req.name, orgKey)).encryptedString;

View File

@@ -14,7 +14,7 @@ export class DeleteCommand {
private folderService: FolderService,
private stateService: StateService,
private apiService: ApiService,
private folderApiService: FolderApiServiceAbstraction
private folderApiService: FolderApiServiceAbstraction,
) {}
async run(object: string, id: string, cmdOptions: Record<string, any>): Promise<Response> {