1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-06 11:43:51 +00:00

[PM-22789] Address PR comments

This commit is contained in:
Colton Hurst
2025-07-31 17:37:09 -04:00
parent b3eb2e7580
commit ed68c2343e
2 changed files with 13 additions and 8 deletions

View File

@@ -4,6 +4,7 @@ import { autotype } from "@bitwarden/desktop-napi";
import { LogService } from "@bitwarden/logging";
import { WindowMain } from "../../main/window.main";
import { stringIsNotUndefinedNullAndEmpty } from "../../utils";
export class MainDesktopAutotypeService {
keySequence: string = "Alt+CommandOrControl+I";
@@ -26,12 +27,8 @@ export class MainDesktopAutotypeService {
const { response } = data;
if (
response.username != undefined &&
response.username != null &&
response.username.length > 0 &&
response.password != undefined &&
response.password != null &&
response.password.length > 0
stringIsNotUndefinedNullAndEmpty(response.username) &&
stringIsNotUndefinedNullAndEmpty(response.password)
) {
this.doAutotype(response.username, response.password);
}
@@ -62,10 +59,10 @@ export class MainDesktopAutotypeService {
private doAutotype(username: string, password: string) {
const inputPattern = username + "\t" + password;
const inputArray = new Array<number>();
const inputArray = new Array<number>(inputPattern.length);
for (let i = 0; i < inputPattern.length; i++) {
inputArray.push(inputPattern.charCodeAt(i));
inputArray[i] = inputPattern.charCodeAt(i);
}
autotype.typeInput(inputArray);

View File

@@ -98,3 +98,11 @@ export function cleanUserAgent(userAgent: string): string {
.replace(userAgentItem("Bitwarden", " "), "")
.replace(userAgentItem("Electron", " "), "");
}
/**
* Returns `true` if the provided string is not undefined, not null, and not empty.
* Otherwise, returns `false`.
*/
export function stringIsNotUndefinedNullAndEmpty(str: string): boolean {
return str != undefined && str != null && str.length > 0;
}