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 23 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.1",
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 {
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 Down Expand Up @@ -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;
}
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 @@ 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, {
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
7 changes: 7 additions & 0 deletions packages/shared/src/locale/enum/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@
earn_request_withdrawal_steth_desc = 'earn.request_withdrawal_steth_desc',
earn_request_withdrawal_stmatic_desc = 'earn.request_withdrawal_stmatic_desc',
earn_reward_tokens = 'earn.reward_tokens',
earn_reward_value = 'earn.reward_value',
earn_rewards = 'earn.rewards',
earn_rewards_automatically_restaked = 'earn.rewards_automatically_restaked',
earn_rewards_manually_restaked = 'earn.rewards_manually_restaked',
Expand Down Expand Up @@ -433,6 +434,9 @@
earn_token_is_pending = 'earn.token_is_pending',
earn_token_is_staked = 'earn.token_is_staked',
earn_total_staked_value = 'earn.total_staked_value',
earn_transaction_loss = 'earn.transaction_loss',
earn_transaction_loss_when_claim = 'earn.transaction_loss_when_claim',
earn_transaction_loss_when_stake = 'earn.transaction_loss_when_stake',
earn_tvl = 'earn.tvl',
earn_unlock_time = 'earn.unlock_time',
earn_unstake_all_due_to_min_withdrawal = 'earn.unstake_all_due_to_min_withdrawal',
Expand Down Expand Up @@ -683,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 Expand Up @@ -1696,6 +1702,7 @@
swap_page_button_refresh_quotes = 'swap_page.button_refresh_quotes',
swap_page_button_select_token = 'swap_page.button_select_token',
swap_page_button_wrap = 'swap_page.button_wrap',
swap_page_buy_sell_tax = 'swap_page.buy_sell_tax',
swap_page_from = 'swap_page.from',
swap_page_limit = 'swap_page.limit',
swap_page_limit_dialog_button = 'swap_page.limit_dialog_button',
Expand Down
7 changes: 7 additions & 0 deletions packages/shared/src/locale/json/bn.json
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@
"earn.request_withdrawal_steth_desc": "একটি উত্তোলন অনুরোধ প্রেরণ করে আপনার stETH/wstETH লক করুন। 1-4 দিনের মধ্যে, লককৃত stETH ধ্বংস হবে এবং আপনার ETH উত্তোলনের জন্য উপলব্ধ হবে।",
"earn.request_withdrawal_stmatic_desc": "উত্তোলন অনুরোধ প্রেরণ করার 1-4 দিনের মধ্যে, লক করা stMATIC ধ্বংস হবে এবং আপনার MATIC উত্তোলনের জন্য উপলব্ধ হবে।",
"earn.reward_tokens": "পুরস্কার টোকেন",
"earn.reward_value": "পুরস্কার মান",
"earn.rewards": "পুরস্কার",
"earn.rewards_automatically_restaked": "পুরস্কারগুলি {automatically} পুনরায় স্টেক করা হয়, যা আপনার স্টেকড বডির বৃদ্ধি করে",
"earn.rewards_manually_restaked": "পুরস্কারগুলি কে {manually} প্রত্যাহার এবং পুনরায় স্থাপন করা প্রয়োজন",
Expand Down Expand Up @@ -428,6 +429,9 @@
"earn.token_is_pending": "{token} অপেক্ষামান",
"earn.token_is_staked": "{token} স্টেক করা হয়েছে",
"earn.total_staked_value": "মোট স্টেকের মান",
"earn.transaction_loss": "লেনদেন ক্ষতি",
"earn.transaction_loss_when_claim": "আপনার পুরস্কারের চেয়ে নেটওয়ার্ক ফি বেশি হওয়ার কারণে, এই লেনদেনটি {number} ক্ষতির ফলাফল হবে।",
"earn.transaction_loss_when_stake": "বর্তমান আনুমানিক হারের ভিত্তিতে, আপনার উপার্জন ক্ষতি পূরণ করতে প্রায় {number} দিন সময় লাগবে।",
"earn.tvl": "TVL",
"earn.unlock_time": "আনলক সময়",
"earn.unstake_all_due_to_min_withdrawal": "ন্যূনতম প্রত্যাহার পরিমাণ {number} {symbol} এর কারণে, এই লেনদেনটি পরবর্তী প্রত্যাহারের জন্য অপর্যাপ্ত তহবিল এড়াতে সমস্ত সম্পদকে মুক্ত করবে৷",
Expand Down Expand Up @@ -678,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 Expand Up @@ -1691,6 +1697,7 @@
"swap_page.button_refresh_quotes": "উদ্ধৃতি রিফ্রেশ করুন",
"swap_page.button_select_token": "টোকেন নির্বাচন করুন",
"swap_page.button_wrap": "ওয়্যাপ চুক্তির মাধ্যমে অদলবদল করুন",
"swap_page.buy_sell_tax": "buy/sell tax",
"swap_page.from": "থেকে",
"swap_page.limit": "সীমা",
"swap_page.limit_dialog_button": "নিশ্চিত করুন",
Expand Down
7 changes: 7 additions & 0 deletions packages/shared/src/locale/json/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@
"earn.request_withdrawal_steth_desc": "Schließen Sie Ihre stETH/wstETH durch eine Auszahlungsanforderung ab. Nach 1-4 Tagen wird das gesperrte stETH zerstört und Ihr ETH steht zur Auszahlung bereit.",
"earn.request_withdrawal_stmatic_desc": "1-4 Tage nach der Ausstellung einer Auszahlungsanforderung wird das gesperrte stMATIC zerstört und Ihr MATIC wird zur Auszahlung verfügbar.",
"earn.reward_tokens": "Belohnungstoken",
"earn.reward_value": "Belohnungswert",
"earn.rewards": "Belohnungen",
"earn.rewards_automatically_restaked": "Belohnungen werden {automatically} neu gestaked, wodurch Ihr gestaked Body erhöht wird",
"earn.rewards_manually_restaked": "Belohnungen müssen {manually} abgehoben und erneut eingesetzt werden",
Expand Down Expand Up @@ -428,6 +429,9 @@
"earn.token_is_pending": "{token} steht aus",
"earn.token_is_staked": "{token} ist eingesetzt",
"earn.total_staked_value": "Gesamtwert des Stakings",
"earn.transaction_loss": "Transaktionsverlust",
"earn.transaction_loss_when_claim": "Da die geschätzte Netzwerkgebühr Ihre Belohnungen übersteigt, wird diese Transaktion zu einem Verlust von {number} führen.",
"earn.transaction_loss_when_stake": "Basierend auf der aktuellen geschätzten Rate wird es etwa {number} Tage dauern, bis Ihre Einnahmen die Verluste decken.",
"earn.tvl": "TVL",
"earn.unlock_time": "Entsperrzeit",
"earn.unstake_all_due_to_min_withdrawal": "Aufgrund des Mindestauszahlungsbetrags von {number} {symbol} werden bei dieser Transaktion alle Vermögenswerte aufgehoben, um zu vermeiden, dass bei der nächsten Auszahlung nicht genügend Geld vorhanden ist.",
Expand Down Expand Up @@ -678,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 Expand Up @@ -1691,6 +1697,7 @@
"swap_page.button_refresh_quotes": "Zitate aktualisieren",
"swap_page.button_select_token": "Token auswählen",
"swap_page.button_wrap": "Austausch über Wrap-Vertrag",
"swap_page.buy_sell_tax": "buy/sell tax",
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
"swap_page.from": "Von",
"swap_page.limit": "Grenze",
"swap_page.limit_dialog_button": "Bestätigen",
Expand Down
7 changes: 7 additions & 0 deletions packages/shared/src/locale/json/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@
"earn.request_withdrawal_steth_desc": "Lock your stETH/wstETH by issuing a withdrawal request. After 1-4 days, the locked stETH will be destroyed and your ETH will become available for withdrawal.",
"earn.request_withdrawal_stmatic_desc": "1-4 days after issuing a withdrawal request, the locked stMATIC will be destroyed and your MATIC will become available for withdrawal.",
"earn.reward_tokens": "Reward tokens",
"earn.reward_value": "Reward value",
"earn.rewards": "Rewards",
"earn.rewards_automatically_restaked": "Rewards are {automatically} restaked, increasing your staked body",
"earn.rewards_manually_restaked": "Rewards need to be {manually} withdrawn and restaked",
Expand Down Expand Up @@ -428,6 +429,9 @@
"earn.token_is_pending": "{token} is pending",
"earn.token_is_staked": "{token} is staked",
"earn.total_staked_value": "Total staked value",
"earn.transaction_loss": "Transaction loss",
"earn.transaction_loss_when_claim": "Due to the est network fee exceeding your rewards, this transaction will result in a loss of {number}.",
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
"earn.transaction_loss_when_stake": "Based on the current estimated rate, it will take about {number} days for your earnings to cover the losses.",
"earn.tvl": "TVL",
"earn.unlock_time": "Unlock time",
"earn.unstake_all_due_to_min_withdrawal": "Due to the minimum withdrawal amount of {number} {symbol}, this transaction will unstake all assets to avoid insufficient funds for the next withdrawal.",
Expand Down Expand Up @@ -678,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 Expand Up @@ -1691,6 +1697,7 @@
"swap_page.button_refresh_quotes": "Refresh quotes",
"swap_page.button_select_token": "Select token",
"swap_page.button_wrap": "Swap via Wrap Contract",
"swap_page.buy_sell_tax": "buy/sell tax",
huhuanming marked this conversation as resolved.
Show resolved Hide resolved
"swap_page.from": "From",
"swap_page.limit": "Limit",
"swap_page.limit_dialog_button": "Confirm",
Expand Down
7 changes: 7 additions & 0 deletions packages/shared/src/locale/json/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@
"earn.request_withdrawal_steth_desc": "Lock your stETH/wstETH by issuing a withdrawal request. After 1-4 days, the locked stETH will be destroyed and your ETH will become available for withdrawal.",
"earn.request_withdrawal_stmatic_desc": "1-4 days after issuing a withdrawal request, the locked stMATIC will be destroyed and your MATIC will become available for withdrawal.",
"earn.reward_tokens": "Reward tokens",
"earn.reward_value": "Reward value",
"earn.rewards": "Rewards",
"earn.rewards_automatically_restaked": "Rewards are {automatically} restaked, increasing your staked body",
"earn.rewards_manually_restaked": "Rewards need to be {manually} withdrawn and restaked",
Expand Down Expand Up @@ -428,6 +429,9 @@
"earn.token_is_pending": "{token} is pending",
"earn.token_is_staked": "{token} is staked",
"earn.total_staked_value": "Total staked value",
"earn.transaction_loss": "Transaction loss",
"earn.transaction_loss_when_claim": "Due to the est network fee exceeding your rewards, this transaction will result in a loss of {number}.",
"earn.transaction_loss_when_stake": "Based on the current estimated rate, it will take about {number} days for your earnings to cover the losses.",
"earn.tvl": "TVL",
"earn.unlock_time": "Unlock time",
"earn.unstake_all_due_to_min_withdrawal": "Due to the minimum withdrawal amount of {number} {symbol}, this transaction will unstake all assets to avoid insufficient funds for the next withdrawal.",
Expand Down Expand Up @@ -678,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 Expand Up @@ -1691,6 +1697,7 @@
"swap_page.button_refresh_quotes": "Refresh quotes",
"swap_page.button_select_token": "Select token",
"swap_page.button_wrap": "Swap via Wrap Contract",
"swap_page.buy_sell_tax": "buy/sell tax",
"swap_page.from": "From",
"swap_page.limit": "Limit",
"swap_page.limit_dialog_button": "Confirm",
Expand Down
Loading
Loading