From 1742228715bdd1161268e9252b7bdfb6f64012d7 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Mon, 21 Dec 2020 19:26:16 +0100 Subject: [PATCH] Make fingerprint optional for browser integration (#234) * Make fingerprint optional for browser integration * Force focus on biometrics * Add dependency --- package-lock.json | 83 +++++++++++++++++++++++++- package.json | 1 + src/electron/biometric.windows.main.ts | 16 +++-- src/electron/electronConstants.ts | 1 + src/globals.d.ts | 1 + 5 files changed, 94 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 32d7e58c5d..09edad89f2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -667,6 +667,12 @@ "readable-stream": "^2.0.6" } }, + "arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -975,6 +981,14 @@ "integrity": "sha1-RqoXUftqL5PuXmibsQh9SxTGwgU=", "dev": true }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "requires": { + "file-uri-to-path": "1.0.0" + } + }, "bl": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", @@ -1155,9 +1169,9 @@ "dev": true }, "browser-process-hrtime": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-0.1.3.tgz", - "integrity": "sha512-bRFnI4NnjO6cnyLmOV/7PVoDEMJChlcfN0z4s1YMBY989/SvlfMI1lgCnkFUs53e9gQF+w7qu7XdllSTiSl8Aw==" + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz", + "integrity": "sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==" }, "browser-resolve": { "version": "1.11.3", @@ -2437,6 +2451,12 @@ "sha.js": "^2.4.8" } }, + "create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "cross-spawn": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", @@ -3344,6 +3364,11 @@ "escape-string-regexp": "^1.0.5" } }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" + }, "fileset": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/fileset/-/fileset-2.0.3.tgz", @@ -3446,6 +3471,15 @@ "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", "dev": true }, + "forcefocus": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/forcefocus/-/forcefocus-1.1.0.tgz", + "integrity": "sha512-bnY7rul5kBLyNoCn0FHNiFAF+GGUZx6TvxWhurUS4PlmOzF+FMixGIigHH5UcyM3w1gp2TxAtP6MOUSXA15Sgw==", + "requires": { + "bindings": "^1.3.0", + "prebuild-install": "^5.0.0" + } + }, "forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -5049,6 +5083,12 @@ "pify": "^3.0.0" } }, + "make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, "map-cache": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", @@ -7545,6 +7585,16 @@ "urix": "^0.1.0" } }, + "source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, "source-map-url": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", @@ -8121,6 +8171,20 @@ "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", "dev": true }, + "ts-node": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-9.1.1.tgz", + "integrity": "sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg==", + "dev": true, + "requires": { + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "source-map-support": "^0.5.17", + "yn": "3.1.1" + } + }, "tslib": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", @@ -8561,6 +8625,13 @@ "integrity": "sha1-gqwr/2PZUOqeMYmlimViX+3xkEU=", "requires": { "browser-process-hrtime": "^0.1.2" + }, + "dependencies": { + "browser-process-hrtime": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-0.1.3.tgz", + "integrity": "sha512-bRFnI4NnjO6cnyLmOV/7PVoDEMJChlcfN0z4s1YMBY989/SvlfMI1lgCnkFUs53e9gQF+w7qu7XdllSTiSl8Aw==" + } } }, "w3c-xmlserializer": { @@ -8764,6 +8835,12 @@ "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=", "dev": true }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true + }, "zone.js": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.9.1.tgz", diff --git a/package.json b/package.json index 196274d87c..b42d22374a 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,7 @@ "electron-log": "2.2.17", "electron-store": "1.3.0", "electron-updater": "4.3.5", + "forcefocus": "^1.1.0", "form-data": "2.3.2", "https-proxy-agent": "4.0.0", "inquirer": "6.2.0", diff --git a/src/electron/biometric.windows.main.ts b/src/electron/biometric.windows.main.ts index 316110b5ec..a51b2e68db 100644 --- a/src/electron/biometric.windows.main.ts +++ b/src/electron/biometric.windows.main.ts @@ -1,16 +1,20 @@ -import { I18nService, StorageService } from '../abstractions'; - import { ipcMain } from 'electron'; -import { BiometricMain } from '../abstractions/biometric.main'; -import { ConstantsService } from '../services'; +import forceFocus from 'forcefocus'; + import { ElectronConstants } from './electronConstants'; +import { WindowMain } from './window.main'; + +import { BiometricMain } from '../abstractions/biometric.main'; +import { I18nService } from '../abstractions/i18n.service'; +import { StorageService } from '../abstractions/storage.service'; +import { ConstantsService } from '../services/constants.service'; export default class BiometricWindowsMain implements BiometricMain { isError: boolean = false; private windowsSecurityCredentialsUiModule: any; - constructor(private storageService: StorageService, private i18nservice: I18nService) { } + constructor(private storageService: StorageService, private i18nservice: I18nService, private windowMain: WindowMain) { } async init() { this.windowsSecurityCredentialsUiModule = this.getWindowsSecurityCredentialsUiModule(); @@ -89,6 +93,8 @@ export default class BiometricWindowsMain implements BiometricMain { } return resolve(result); }); + + forceFocus.focusWindow(this.windowMain.win); } catch (error) { this.isError = true; return reject(error); diff --git a/src/electron/electronConstants.ts b/src/electron/electronConstants.ts index 47510bb68b..1e3f95627c 100644 --- a/src/electron/electronConstants.ts +++ b/src/electron/electronConstants.ts @@ -7,6 +7,7 @@ export class ElectronConstants { static readonly minimizeOnCopyToClipboardKey: string = 'minimizeOnCopyToClipboardKey'; static readonly enableBiometric: string = 'enabledBiometric'; static readonly enableBrowserIntegration: string = 'enableBrowserIntegration'; + static readonly enableBrowserIntegrationFingerprint: string = 'enableBrowserIntegrationFingerprint' static readonly alwaysShowDock: string = 'alwaysShowDock'; static readonly openAtLogin: string = 'openAtLogin'; } diff --git a/src/globals.d.ts b/src/globals.d.ts index 8116ab173f..3d11d40e2c 100644 --- a/src/globals.d.ts +++ b/src/globals.d.ts @@ -1,3 +1,4 @@ declare function escape(s: string): string; declare function unescape(s: string): string; declare module 'duo_web_sdk'; +declare module 'forcefocus';