Skip to content

Commit

Permalink
fix automatic form inputs filling during autologin
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimiry committed Nov 24, 2018
1 parent d5a7fa6 commit 249a573
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@
"karma-mocha-reporter": "2.2.5",
"karma-sourcemap-loader": "0.3.7",
"karma-webpack": "4.0.0-rc.2",
"keysim": "2.1.0",
"less-loader": "4.1.0",
"lint-staged": "8.1.0",
"mini-css-extract-plugin": "0.4.5",
Expand Down
1 change: 0 additions & 1 deletion src/@types/keysim/index.d.ts

This file was deleted.

14 changes: 12 additions & 2 deletions src/electron-preload/webview/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {Keyboard} from "keysim";
import {concatMap, delay, retryWhen} from "rxjs/operators";
import {of, throwError} from "rxjs";

Expand Down Expand Up @@ -67,7 +66,7 @@ export function getLocationHref(): string {

export async function fillInputValue(input: HTMLInputElement, value: string) {
input.value = value;
Keyboard.US_ENGLISH.dispatchEventsForInput(value, input);
triggerChangeEvent(input);
}

export async function submitTotpToken(
Expand Down Expand Up @@ -160,3 +159,14 @@ export function buildDbPatchRetryPipeline<T>(
}),
));
}

function triggerChangeEvent(input: HTMLInputElement) {
// protonmail (angularjs)
const changeEvent = document.createEvent("HTMLEvents");
changeEvent.initEvent("change", true, false);
input.dispatchEvent(changeEvent);
// tutanota (mithril)
const inputEvent = document.createEvent("Event");
inputEvent.initEvent("input", true, false);
input.dispatchEvent(inputEvent);
}
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6747,11 +6747,6 @@ karma@3.1.1:
tmp "0.0.33"
useragent "2.2.1"

keysim@2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/keysim/-/keysim-2.1.0.tgz#5ff8d671618caea81472b3d80ed7e251cfde6dbf"
integrity sha512-QLrBscwDtm+xL4RXY1PIuaq7UJhZaSx0cp0pzl+vlMnQ+8tHCg4FqFi7vsfkaWeaOMs7iCKWaGXXnMe1Q92oVA==

keytar@4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/keytar/-/keytar-4.3.0.tgz#4a3afd64fdeec300716ccf3985fdcf1cfd6e77e9"
Expand Down

0 comments on commit 249a573

Please sign in to comment.