diff --git a/apps/desktop/package.json b/apps/desktop/package.json index 31e5aa8bb13..ef751f485a4 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -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", "keytar": "^7.9.0", "node-fetch": "^2.6.7" }, diff --git a/apps/desktop/src-electron/app.ts b/apps/desktop/src-electron/app.ts index 71f5ac080ad..8c7bf8d2f75 100644 --- a/apps/desktop/src-electron/app.ts +++ b/apps/desktop/src-electron/app.ts @@ -18,6 +18,10 @@ import { 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, @@ -512,7 +516,22 @@ function createMainWindow() { } }); - 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; + } const result = systemPreferences?.canPromptTouchID?.(); event.returnValue = !!result; }); @@ -556,6 +575,24 @@ function createMainWindow() { }); 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, { + success: false, + error: error.message, + }); + } else { + event.reply(ipcMessageKeys.TOUCH_ID_PROMPT_RES, { + success: status === UserConsentVerificationResult.verified, + }); + } + }, + ); + return; + } try { await systemPreferences.promptTouchID(msg); event.reply(ipcMessageKeys.TOUCH_ID_PROMPT_RES, { success: true }); diff --git a/packages/components/src/primitives/Icon/Icons.tsx b/packages/components/src/primitives/Icon/Icons.tsx index 066fcbcd434..53d87de5325 100644 --- a/packages/components/src/primitives/Icon/Icons.tsx +++ b/packages/components/src/primitives/Icon/Icons.tsx @@ -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"), diff --git a/packages/components/src/primitives/Icon/react/solid/WindowsHello.tsx b/packages/components/src/primitives/Icon/react/solid/WindowsHello.tsx new file mode 100644 index 00000000000..1cd9160483a --- /dev/null +++ b/packages/components/src/primitives/Icon/react/solid/WindowsHello.tsx @@ -0,0 +1,15 @@ +import Svg, { SvgProps, Path, Circle } from 'react-native-svg'; +const SvgWindowsHello = (props: SvgProps) => ( + + + + + +); +export default SvgWindowsHello; diff --git a/packages/components/src/primitives/Icon/react/solid/index.ts b/packages/components/src/primitives/Icon/react/solid/index.ts index 5bd610d16e5..5595b94b070 100644 --- a/packages/components/src/primitives/Icon/react/solid/index.ts +++ b/packages/components/src/primitives/Icon/react/solid/index.ts @@ -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'; diff --git a/packages/components/svg/solid/windows-hello.svg b/packages/components/svg/solid/windows-hello.svg new file mode 100644 index 00000000000..77f949dd559 --- /dev/null +++ b/packages/components/svg/solid/windows-hello.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/packages/kit/src/components/BiologyAuthComponent/container/BiologyAuthSwitchContainer.tsx b/packages/kit/src/components/BiologyAuthComponent/container/BiologyAuthSwitchContainer.tsx index 17e0878c25f..ed97ea508fd 100644 --- a/packages/kit/src/components/BiologyAuthComponent/container/BiologyAuthSwitchContainer.tsx +++ b/packages/kit/src/components/BiologyAuthComponent/container/BiologyAuthSwitchContainer.tsx @@ -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'; @@ -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, }), }); } diff --git a/packages/kit/src/components/Password/components/PasswordVerify.tsx b/packages/kit/src/components/Password/components/PasswordVerify.tsx index 6d51fed65d6..7db06975941 100644 --- a/packages/kit/src/components/Password/components/PasswordVerify.tsx +++ b/packages/kit/src/components/Password/components/PasswordVerify.tsx @@ -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'; @@ -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'; + } actions.push({ - iconName: - authType && - (authType.includes(AuthenticationType.FACIAL_RECOGNITION) || - authType.includes(AuthenticationType.IRIS)) - ? 'FaceIdOutline' - : 'TouchId2Outline', + iconName, onPress: onBiologyAuth, loading: status.value === EPasswordVerifyStatus.VERIFYING, }); diff --git a/packages/kit/src/views/Setting/pages/List/SecuritySection/index.tsx b/packages/kit/src/views/Setting/pages/List/SecuritySection/index.tsx index 0a7d415baf6..137181f6f95 100644 --- a/packages/kit/src/views/Setting/pages/List/SecuritySection/index.tsx +++ b/packages/kit/src/views/Setting/pages/List/SecuritySection/index.tsx @@ -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'; } } diff --git a/packages/shared/src/locale/enum/translations.ts b/packages/shared/src/locale/enum/translations.ts index 4345d6c591d..c6ad9ddc37e 100644 --- a/packages/shared/src/locale/enum/translations.ts +++ b/packages/shared/src/locale/enum/translations.ts @@ -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', diff --git a/packages/shared/src/locale/json/bn.json b/packages/shared/src/locale/json/bn.json index 4af2acad647..ee952b94ff5 100644 --- a/packages/shared/src/locale/json/bn.json +++ b/packages/shared/src/locale/json/bn.json @@ -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": "সম্পর্কে", diff --git a/packages/shared/src/locale/json/de.json b/packages/shared/src/locale/json/de.json index f70bd3bab56..2dac5c941a8 100644 --- a/packages/shared/src/locale/json/de.json +++ b/packages/shared/src/locale/json/de.json @@ -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", diff --git a/packages/shared/src/locale/json/en.json b/packages/shared/src/locale/json/en.json index 9661167fa68..9078e279c62 100644 --- a/packages/shared/src/locale/json/en.json +++ b/packages/shared/src/locale/json/en.json @@ -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", "global.404_message": "Sorry, something went wrong!", "global.Note": "Note", "global.about": "About", diff --git a/packages/shared/src/locale/json/en_US.json b/packages/shared/src/locale/json/en_US.json index aa77de8a6f7..d85d7e0976d 100644 --- a/packages/shared/src/locale/json/en_US.json +++ b/packages/shared/src/locale/json/en_US.json @@ -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", diff --git a/packages/shared/src/locale/json/es.json b/packages/shared/src/locale/json/es.json index afd1cf5b03c..2e10c1bcc08 100644 --- a/packages/shared/src/locale/json/es.json +++ b/packages/shared/src/locale/json/es.json @@ -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", diff --git a/packages/shared/src/locale/json/fr_FR.json b/packages/shared/src/locale/json/fr_FR.json index a8557e5383a..82551803f42 100644 --- a/packages/shared/src/locale/json/fr_FR.json +++ b/packages/shared/src/locale/json/fr_FR.json @@ -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", diff --git a/packages/shared/src/locale/json/hi_IN.json b/packages/shared/src/locale/json/hi_IN.json index 0b0d7ddeaef..183aa3271a1 100644 --- a/packages/shared/src/locale/json/hi_IN.json +++ b/packages/shared/src/locale/json/hi_IN.json @@ -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": "बारे में", diff --git a/packages/shared/src/locale/json/id.json b/packages/shared/src/locale/json/id.json index 700d57dda56..e3141cce232 100644 --- a/packages/shared/src/locale/json/id.json +++ b/packages/shared/src/locale/json/id.json @@ -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", diff --git a/packages/shared/src/locale/json/it_IT.json b/packages/shared/src/locale/json/it_IT.json index 4e9b0686323..fe3d13ce816 100644 --- a/packages/shared/src/locale/json/it_IT.json +++ b/packages/shared/src/locale/json/it_IT.json @@ -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", diff --git a/packages/shared/src/locale/json/ja_JP.json b/packages/shared/src/locale/json/ja_JP.json index 64ac81db59a..71b0d595390 100644 --- a/packages/shared/src/locale/json/ja_JP.json +++ b/packages/shared/src/locale/json/ja_JP.json @@ -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": "約", diff --git a/packages/shared/src/locale/json/ko_KR.json b/packages/shared/src/locale/json/ko_KR.json index c2084f75e7b..4ab66bfa296 100644 --- a/packages/shared/src/locale/json/ko_KR.json +++ b/packages/shared/src/locale/json/ko_KR.json @@ -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": "소개", diff --git a/packages/shared/src/locale/json/pt.json b/packages/shared/src/locale/json/pt.json index afadad864ec..b9fe6249f16 100644 --- a/packages/shared/src/locale/json/pt.json +++ b/packages/shared/src/locale/json/pt.json @@ -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", "global.404_message": "Desculpe, algo deu errado!", "global.Note": "Nota", "global.about": "Sobre", diff --git a/packages/shared/src/locale/json/pt_BR.json b/packages/shared/src/locale/json/pt_BR.json index 9d20f2e8f42..d82532ec085 100644 --- a/packages/shared/src/locale/json/pt_BR.json +++ b/packages/shared/src/locale/json/pt_BR.json @@ -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", diff --git a/packages/shared/src/locale/json/ru.json b/packages/shared/src/locale/json/ru.json index 5e7e4984945..e9d0c90adc4 100644 --- a/packages/shared/src/locale/json/ru.json +++ b/packages/shared/src/locale/json/ru.json @@ -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": "О нас", diff --git a/packages/shared/src/locale/json/th_TH.json b/packages/shared/src/locale/json/th_TH.json index f6a88b943f3..5dea504f84f 100644 --- a/packages/shared/src/locale/json/th_TH.json +++ b/packages/shared/src/locale/json/th_TH.json @@ -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": "เกี่ยวกับ", diff --git a/packages/shared/src/locale/json/uk_UA.json b/packages/shared/src/locale/json/uk_UA.json index 7a2de6249e7..b3d0c8dd0ee 100644 --- a/packages/shared/src/locale/json/uk_UA.json +++ b/packages/shared/src/locale/json/uk_UA.json @@ -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": "Про", diff --git a/packages/shared/src/locale/json/vi.json b/packages/shared/src/locale/json/vi.json index a20b3f6440a..80dc1bc951f 100644 --- a/packages/shared/src/locale/json/vi.json +++ b/packages/shared/src/locale/json/vi.json @@ -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ề", diff --git a/packages/shared/src/locale/json/zh_CN.json b/packages/shared/src/locale/json/zh_CN.json index 73a06a3f610..738761fffde 100644 --- a/packages/shared/src/locale/json/zh_CN.json +++ b/packages/shared/src/locale/json/zh_CN.json @@ -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": "关于", diff --git a/packages/shared/src/locale/json/zh_HK.json b/packages/shared/src/locale/json/zh_HK.json index 3bf8509aaee..37cf89ff1b3 100644 --- a/packages/shared/src/locale/json/zh_HK.json +++ b/packages/shared/src/locale/json/zh_HK.json @@ -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": "關於", diff --git a/packages/shared/src/locale/json/zh_TW.json b/packages/shared/src/locale/json/zh_TW.json index c354ead64f8..b829f189de8 100644 --- a/packages/shared/src/locale/json/zh_TW.json +++ b/packages/shared/src/locale/json/zh_TW.json @@ -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": "關於", diff --git a/yarn.lock b/yarn.lock index bb92535104c..70618bda1df 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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" @@ -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"