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:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user