Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support Windows hello #5917

Merged
merged 26 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"electron-log": "5.2.0",
"electron-store": "^8.2.0",
"electron-updater": "6.1.8",
"electron-windows-security": "0.0.2",
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
"keytar": "^7.9.0",
"node-fetch": "^2.6.7"
},
Expand Down
39 changes: 38 additions & 1 deletion apps/desktop/src-electron/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
import contextMenu from 'electron-context-menu';
import isDev from 'electron-is-dev';
import logger from 'electron-log/main';
import windowsSecurityCredentialsUiModule, {
UserConsentVerificationResult,
UserConsentVerifierAvailability,
} from 'electron-windows-security';

import {
ONEKEY_APP_DEEP_LINK_NAME,
Expand All @@ -28,7 +32,7 @@
IDesktopAppState,
IDesktopSubModuleInitParams,
IMediaType,
IPrefType,

Check warning on line 35 in apps/desktop/src-electron/app.ts

View workflow job for this annotation

GitHub Actions / lint (20.x)

'IPrefType' is defined but never used
} from '@onekeyhq/shared/types/desktop';

import appDevOnlyApi from './appDevOnlyApi';
Expand Down Expand Up @@ -512,7 +516,22 @@
}
});

ipcMain.on(ipcMessageKeys.TOUCH_ID_CAN_PROMPT, (event) => {
ipcMain.on(ipcMessageKeys.TOUCH_ID_CAN_PROMPT, async (event) => {
if (isWin) {
const result = await new Promise((resolve) => {
windowsSecurityCredentialsUiModule.UserConsentVerifier.checkAvailabilityAsync(
(error, status) => {
if (error) {
resolve(false);
} else {
resolve(status === UserConsentVerifierAvailability.available);
}
},
);
});
event.returnValue = result;
return;
}
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
const result = systemPreferences?.canPromptTouchID?.();
event.returnValue = !!result;
});
Expand Down Expand Up @@ -556,6 +575,24 @@
});

ipcMain.on(ipcMessageKeys.TOUCH_ID_PROMPT, async (event, msg: string) => {
if (isWin) {
windowsSecurityCredentialsUiModule.UserConsentVerifier.requestVerificationAsync(
msg,
(error, status) => {
if (error) {
event.reply(ipcMessageKeys.TOUCH_ID_PROMPT_RES, {
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
success: false,
error: error.message,
});
} else {
event.reply(ipcMessageKeys.TOUCH_ID_PROMPT_RES, {
success: status === UserConsentVerificationResult.verified,
});
}
},
);
return;
}
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
try {
await systemPreferences.promptTouchID(msg);
event.reply(ipcMessageKeys.TOUCH_ID_PROMPT_RES, { success: true });
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/primitives/Icon/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1930,6 +1930,7 @@ const icons = {
WhisperSolid: () => import("./react/solid/Whisper"),
WifiSolid: () => import("./react/solid/Wifi"),
WindSolid: () => import("./react/solid/Wind"),
WindowsHelloSolid: () => import("./react/solid/WindowsHello"),
WorldSolid: () => import("./react/solid/World"),
WreathSolid: () => import("./react/solid/Wreath"),
XBackspaceSolid: () => import("./react/solid/XBackspace"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Svg, { SvgProps, Path, Circle } from 'react-native-svg';
const SvgWindowsHello = (props: SvgProps) => (
<Svg viewBox="0 0 24 24" fill="none" accessibilityRole="image" {...props}>
<Path
d="M20 15.583c-.811 1.216-1.978 2.226-3.382 2.928A10.357 10.357 0 0 1 12 19.583c-1.621 0-3.214-.37-4.618-1.072C5.978 17.81 4.812 16.8 4 15.583"
stroke="currentColor"
strokeWidth={2}
strokeLinecap="round"
strokeLinejoin="round"
/>
<Circle cx={6.5} cy={6.5} r={2.5} fill="currentColor" />
<Circle cx={17.5} cy={6.5} r={2.5} fill="currentColor" />
</Svg>
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
);
export default SvgWindowsHello;
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,7 @@ export { default as Webcam } from './Webcam';
export { default as Whisper } from './Whisper';
export { default as Wifi } from './Wifi';
export { default as Wind } from './Wind';
export { default as WindowsHello } from './WindowsHello';
export { default as World } from './World';
export { default as Wreath } from './Wreath';
export { default as XBackspace } from './XBackspace';
Expand Down
5 changes: 5 additions & 0 deletions packages/components/svg/solid/windows-hello.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import backgroundApiProxy from '@onekeyhq/kit/src/background/instance/background
import { useSettingsPersistAtom } from '@onekeyhq/kit-bg/src/states/jotai/atoms';
import { usePasswordBiologyAuthInfoAtom } from '@onekeyhq/kit-bg/src/states/jotai/atoms/password';
import { ETranslations } from '@onekeyhq/shared/src/locale';
import platformEnv from '@onekeyhq/shared/src/platformEnv';

import BiologyAuthSwitch from '../components/BiologyAuthSwitch';

Expand All @@ -30,7 +31,9 @@ const BiologyAuthSwitchContainer = ({
} catch (e) {
Toast.error({
title: intl.formatMessage({
id: ETranslations.global_touch_id_set_error,
id: platformEnv.isDesktopWin
? ETranslations.global_windows_hello_set_error
: ETranslations.global_touch_id_set_error,
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
}),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type { IKeyOfIcons, IPropsWithTestId } from '@onekeyhq/components';
import { Form, Input, useForm } from '@onekeyhq/components';
import { usePasswordAtom } from '@onekeyhq/kit-bg/src/states/jotai/atoms';
import { ETranslations } from '@onekeyhq/shared/src/locale';
import platformEnv from '@onekeyhq/shared/src/platformEnv';
import { EPasswordVerifyStatus } from '@onekeyhq/shared/types/password';

import { useHandleAppStateActive } from '../../../hooks/useHandleAppStateActive';
Expand Down Expand Up @@ -80,13 +81,17 @@ const PasswordVerify = ({
loading?: boolean;
}>[] = [];
if (isEnable && !passwordInput) {
let iconName: IKeyOfIcons =
authType &&
(authType.includes(AuthenticationType.FACIAL_RECOGNITION) ||
authType.includes(AuthenticationType.IRIS))
? 'FaceIdOutline'
: 'TouchId2Outline';
if (platformEnv.isDesktopWin) {
iconName = 'WindowsHelloSolid';
}
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
actions.push({
iconName:
authType &&
(authType.includes(AuthenticationType.FACIAL_RECOGNITION) ||
authType.includes(AuthenticationType.IRIS))
? 'FaceIdOutline'
: 'TouchId2Outline',
iconName,
onPress: onBiologyAuth,
loading: status.value === EPasswordVerifyStatus.VERIFYING,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ const FaceIdItem = () => {
: ETranslations.global_face_id,
});
icon = 'FaceIdSolid';
} else if (platformEnv.isDesktopWin) {
title = intl.formatMessage({ id: ETranslations.global_windows_hello });
icon = 'WindowsHelloSolid';
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/enum/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,8 @@
form__approve_str = 'form__approve_str',
form__priority_fee = 'form__priority_fee',
form__sats__units = 'form__sats__units',
global_windows_hello = 'global.windows_hello',
global_windows_hello_set_error = 'global.windows_hello_set_error',
global_404_message = 'global.404_message',
global_Note = 'global.Note',
global_about = 'global.about',
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/json/bn.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@
"form__approve_str": "{amount} {symbol} অনুমোদন করুন",
"form__priority_fee": "অগ্রাধিকার ফি",
"form__sats__units": "sats",
"global.windows_hello": "Windows Hello",
"global.windows_hello_set_error": "Windows Hello সেট করুন ব্যর্থ",
"global.404_message": "দুঃখিত, কিছু ভুল হয়েছে!",
"global.Note": "নোট",
"global.about": "সম্পর্কে",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/json/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@
"form__approve_str": "Genehmigen Sie {amount} {symbol}",
"form__priority_fee": "Prioritätsgebühr",
"form__sats__units": "sats",
"global.windows_hello": "Windows Hello",
"global.windows_hello_set_error": "Windows Hello-Fehler festlegen",
"global.404_message": "Entschuldigung, etwas ist schief gelaufen!",
"global.Note": "Hinweis",
"global.about": "Über",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/json/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@
"form__approve_str": "Approve {amount} {symbol}",
"form__priority_fee": "Priority fee",
"form__sats__units": "sats",
"global.windows_hello": "Windows Hello",
"global.windows_hello_set_error": "Set Windows Hello to fail",
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
"global.404_message": "Sorry, something went wrong!",
"global.Note": "Note",
"global.about": "About",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/json/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@
"form__approve_str": "Approve {amount} {symbol}",
"form__priority_fee": "Priority fee",
"form__sats__units": "sats",
"global.windows_hello": "Windows Hello",
"global.windows_hello_set_error": "Set Windows Hello fail",
"global.404_message": "Sorry, something went wrong!",
"global.Note": "Note",
"global.about": "About",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/json/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@
"form__approve_str": "Aprobar {amount} {symbol}",
"form__priority_fee": "Tarifa Prioritaria",
"form__sats__units": "sats",
"global.windows_hello": "Windows Hello",
"global.windows_hello_set_error": "Error al configurar Windows Hello",
"global.404_message": "¡Lo siento, algo salió mal!",
"global.Note": "Nota",
"global.about": "Acerca de",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/json/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@
"form__approve_str": "Approuver {amount} {symbol}",
"form__priority_fee": "Frais de priorité",
"form__sats__units": "sats",
"global.windows_hello": "Windows Hello",
"global.windows_hello_set_error": "Échec de configuration de Windows Hello",
"global.404_message": "Désolé, quelque chose a mal tourné !",
"global.Note": "Note",
"global.about": "À propos",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/json/hi_IN.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@
"form__approve_str": "{amount} {symbol} को मंजूरी दें",
"form__priority_fee": "प्राथमिकता शुल्क",
"form__sats__units": "sats",
"global.windows_hello": "Windows Hello",
"global.windows_hello_set_error": "Windows Hello सेट करें विफल",
"global.404_message": "क्षमा करें, कुछ गलत हो गया!",
"global.Note": "नोट",
"global.about": "बारे में",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/json/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@
"form__approve_str": "Menyetujui {amount} {symbol}",
"form__priority_fee": "Biaya Prioritas",
"form__sats__units": "sats",
"global.windows_hello": "Windows Hello",
"global.windows_hello_set_error": "Gagal mengatur Windows Hello",
"global.404_message": "Maaf, ada yang salah!",
"global.Note": "Catatan",
"global.about": "Tentang",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/json/it_IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@
"form__approve_str": "Approva {amount} {symbol}",
"form__priority_fee": "Tariffa Prioritaria",
"form__sats__units": "sats",
"global.windows_hello": "Windows Hello",
"global.windows_hello_set_error": "Imposta il fallimento di Windows Hello",
"global.404_message": "Spiacente, qualcosa è andato storto!",
"global.Note": "Nota",
"global.about": "Informazioni",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/json/ja_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@
"form__approve_str": "{amount} {symbol}を承認する",
"form__priority_fee": "優先料金",
"form__sats__units": "sats",
"global.windows_hello": "Windows Hello",
"global.windows_hello_set_error": "Windows Hello の設定に失敗しました",
"global.404_message": "申し訳ありません、何か問題が発生しました!",
"global.Note": "注意",
"global.about": "約",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/json/ko_KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@
"form__approve_str": "{amount} {symbol} 승인",
"form__priority_fee": "우선 순위 요금",
"form__sats__units": "sats",
"global.windows_hello": "Windows Hello",
"global.windows_hello_set_error": "Windows Hello 설정 실패",
"global.404_message": "죄송합니다, 문제가 발생했습니다!",
"global.Note": "노트",
"global.about": "소개",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/json/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@
"form__approve_str": "Aprovar {amount} {symbol}",
"form__priority_fee": "Taxa de Prioridade",
"form__sats__units": "sats",
"global.windows_hello": "Windows Hello",
"global.windows_hello_set_error": "Configurar falha do Windows Hello",
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
"global.404_message": "Desculpe, algo deu errado!",
"global.Note": "Nota",
"global.about": "Sobre",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/json/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@
"form__approve_str": "Aprovar {amount} {symbol}",
"form__priority_fee": "Taxa Prioritária",
"form__sats__units": "sats",
"global.windows_hello": "Windows Hello",
"global.windows_hello_set_error": "Falha ao configurar o Windows Hello",
"global.404_message": "Desculpe, algo deu errado!",
"global.Note": "Nota",
"global.about": "Sobre",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/json/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@
"form__approve_str": "Одобрить {amount} {symbol}",
"form__priority_fee": "Приоритетная плата",
"form__sats__units": "sats",
"global.windows_hello": "Windows Hello",
"global.windows_hello_set_error": "Ошибка настройки Windows Hello",
"global.404_message": "Извините, что-то пошло не так!",
"global.Note": "Примечание",
"global.about": "О нас",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/json/th_TH.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@
"form__approve_str": "อนุมัติ {amount} {symbol}",
"form__priority_fee": "ค่าธรรมเนียมลำดับความสำคัญ",
"form__sats__units": "sats",
"global.windows_hello": "Windows Hello",
"global.windows_hello_set_error": "ตั้งค่า Windows Hello ล้มเหลว",
"global.404_message": "ขออภัย, มีบางอย่างผิดพลาด!",
"global.Note": "หมายเหตุ",
"global.about": "เกี่ยวกับ",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/json/uk_UA.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@
"form__approve_str": "Підтвердити {amount} {symbol}",
"form__priority_fee": "Приоритетний збір",
"form__sats__units": "sats",
"global.windows_hello": "Windows Hello",
"global.windows_hello_set_error": "Не вдалося налаштувати Windows Hello",
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
"global.404_message": "Вибачте, щось пішло не так!",
"global.Note": "Примітка",
"global.about": "Про",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/json/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@
"form__approve_str": "Phê duyệt {amount} {symbol}",
"form__priority_fee": "Phí Ưu Tiên",
"form__sats__units": "sats",
"global.windows_hello": "Windows Hello",
"global.windows_hello_set_error": "Thiết lập Windows Hello thất bại",
"global.404_message": "Xin lỗi, đã có lỗi xảy ra!",
"global.Note": "Ghi chú",
"global.about": "Về",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/json/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@
"form__approve_str": "授权 {amount} {symbol}",
"form__priority_fee": "矿工小费",
"form__sats__units": "聪",
"global.windows_hello": "Windows Hello",
"global.windows_hello_set_error": "设置 Windows Hello 失败",
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
"global.404_message": "对不起,出了点问题!",
"global.Note": "备注",
"global.about": "关于",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/json/zh_HK.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@
"form__approve_str": "授權 {amount} {symbol}",
"form__priority_fee": "礦工小費",
"form__sats__units": "聪",
"global.windows_hello": "Windows Hello",
"global.windows_hello_set_error": "設定 Windows Hello 失敗",
"global.404_message": "對不起,出了點問題!",
"global.Note": "備註",
"global.about": "關於",
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/locale/json/zh_TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@
"form__approve_str": "授權 {amount} {symbol}",
"form__priority_fee": "礦工小費",
"form__sats__units": "聰",
"global.windows_hello": "Windows Hello",
"global.windows_hello_set_error": "設定 Windows Hello 失敗",
"global.404_message": "對不起,出了些問題!",
"global.Note": "備註",
"global.about": "關於",
Expand Down
19 changes: 19 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6688,6 +6688,7 @@ __metadata:
electron-log: "npm:5.2.0"
electron-store: "npm:^8.2.0"
electron-updater: "npm:6.1.8"
electron-windows-security: "npm:0.0.2"
esbuild: "npm:0.15.18"
folderslint: "npm:^1.2.0"
glob: "npm:^7.2.0"
Expand Down Expand Up @@ -19691,6 +19692,15 @@ __metadata:
languageName: node
linkType: hard

"electron-windows-security@npm:0.0.2":
version: 0.0.2
resolution: "electron-windows-security@npm:0.0.2"
dependencies:
nan: "npm:2.20.0"
checksum: 10/bfd18d054932f3ba79b007a19c3d68e80715d01b354f15e9faff1ab54960d084f00198b344bfcc9c1cffdc06cb3d6b2eab513483f1376c22b51f0f40a47937f5
languageName: node
linkType: hard

"electron@npm:27.3.1":
version: 27.3.1
resolution: "electron@npm:27.3.1"
Expand Down Expand Up @@ -28666,6 +28676,15 @@ __metadata:
languageName: node
linkType: hard

"nan@npm:2.20.0":
version: 2.20.0
resolution: "nan@npm:2.20.0"
dependencies:
node-gyp: "npm:latest"
checksum: 10/5f16e4c9953075d9920229c703c1d781c0b74118ce3d9e926b448a4eef92b7d8be5ac6adc748a13a5fafb594436cbfe63250e3471aefdd78e3a0cd14603b9ba7
languageName: node
linkType: hard

"nan@npm:^2.13.2, nan@npm:^2.14.0, nan@npm:^2.2.1":
version: 2.18.0
resolution: "nan@npm:2.18.0"
Expand Down
Loading