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: implement webauthn to encrypt the private keys #266

Merged
merged 32 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0bece19
build(yarn): update react-icons package to v5.2.1
kieranroneill Jul 6, 2024
283adf0
feat: add passkey service to get and fetch a passkey
kieranroneill Jul 6, 2024
d544292
feat: add functionaility to fetch key material from passkey
kieranroneill Jul 6, 2024
6df3b18
chore: squash
kieranroneill Jul 6, 2024
59f34b1
feat: add functionality to save, remove and fetch passkey credential …
kieranroneill Jul 6, 2024
7a7901e
feat: add functionality to decrypt/encrypt bytes from passkey input k…
kieranroneill Jul 6, 2024
22eb908
feat: add passkeys store
kieranroneill Jul 6, 2024
3bc51dd
feat: add passkeys selectors and fetch from storage on load
kieranroneill Jul 6, 2024
a1582d2
feat: update settings link item to allow for badges
kieranroneill Jul 7, 2024
f5608f9
feat: add passkey ui to handle creating, removing and viewing passkey
kieranroneill Jul 7, 2024
3254f62
chore: squash
kieranroneill Jul 7, 2024
31da019
feat: add new password service to handle password related functionality
kieranroneill Jul 8, 2024
48de53e
refactor: move private key service encyption to password and utility …
kieranroneill Jul 8, 2024
5b6deda
feat: add change password loading modal with progress
kieranroneill Jul 8, 2024
3a0ac86
refactor: overhaul of private key stroage to use private key (seed) i…
kieranroneill Jul 9, 2024
b7521cd
feat: add functionality to encrypt private keys with new passkey
kieranroneill Jul 9, 2024
5344328
feat: add modal to remove passkey and re-encypt using password
kieranroneill Jul 9, 2024
7ee5511
feat: add user id to passkey credential and close modals after succes…
kieranroneill Jul 9, 2024
53b0431
feat: add encryption method to provate key items
kieranroneill Jul 10, 2024
2c8107a
chore: merge origin/beta
kieranroneill Jul 11, 2024
ad6ed25
feat: create new authentication modal that handles password and passk…
kieranroneill Jul 11, 2024
397e7c0
chore: squash
kieranroneill Jul 11, 2024
f1df7f8
chore: squash
kieranroneill Jul 11, 2024
1fc20d1
chore: squash
kieranroneill Jul 14, 2024
27d35f1
chore: squash
kieranroneill Jul 14, 2024
ae626fc
chore: squash
kieranroneill Jul 14, 2024
319c60c
chore: squash
kieranroneill Jul 16, 2024
2816e7a
fix: close authentication and password modals
kieranroneill Jul 16, 2024
373fe5f
feat: update captions for add passkey and remove passkey
kieranroneill Jul 16, 2024
5fce108
fix: when changing password avoid re-encrypting keys when passkey is …
kieranroneill Jul 16, 2024
6798443
feat: add new circular progress component and add to transaction
kieranroneill Jul 17, 2024
de5652f
chore: squash
kieranroneill Jul 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"react-confetti": "^6.1.0",
"react-dom": "^18.2.0",
"react-i18next": "^12.2.0",
"react-icons": "^4.7.1",
"react-icons": "^5.2.1",
"react-loader-spinner": "^5.3.4",
"react-redux": "^8.0.5",
"react-router-dom": "^6.8.2",
Expand Down
9 changes: 9 additions & 0 deletions src/common/types/IAuthenticationExtensionsClientOutputs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// types
import IPRFExtensionOutput from './IPRFExtensionOutput';

interface IAuthenticationExtensionsClientOutputs
extends AuthenticationExtensionsClientOutputs {
prf?: IPRFExtensionOutput;
}

export default IAuthenticationExtensionsClientOutputs;
9 changes: 9 additions & 0 deletions src/common/types/IPRFExtensionOutput.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// types
import IPRFExtensionResults from './IPRFExtensionResults';

interface IPRFExtensionOutput {
enabled?: boolean;
results?: IPRFExtensionResults;
}

export default IPRFExtensionOutput;
5 changes: 5 additions & 0 deletions src/common/types/IPRFExtensionResults.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
interface IPRFExtensionResults {
first: ArrayBuffer;
}

export default IPRFExtensionResults;
3 changes: 3 additions & 0 deletions src/common/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
export type { default as IAuthenticationExtensionsClientOutputs } from './IAuthenticationExtensionsClientOutputs';
export type { default as IBaseOptions } from './IBaseOptions';
export type { default as IClientInformation } from './IClientInformation';
export type { default as IClientRequestMessage } from './IClientRequestMessage';
export type { default as IClientResponseMessage } from './IClientResponseMessage';
export type { default as ILogger } from './ILogger';
export type { default as ILogLevel } from './ILogLevel';
export type { default as IPRFExtensionOutput } from './IPRFExtensionOutput';
export type { default as IPRFExtensionResults } from './IPRFExtensionResults';
export type { default as TProviderMessages } from './TProviderMessages';
2 changes: 2 additions & 0 deletions src/extension/apps/background/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { reducer as eventsReducer } from '@extension/features/events';
import { reducer as layoutReducer } from '@extension/features/layout';
import { reducer as messagesReducer } from '@extension/features/messages';
import { reducer as networksReducer } from '@extension/features/networks';
import { reducer as passkeysReducer } from '@extension/features/passkeys';
import { reducer as passwordLockReducer } from '@extension/features/password-lock';
import { reducer as sessionsReducer } from '@extension/features/sessions';
import { reducer as settingsReducer } from '@extension/features/settings';
Expand All @@ -35,6 +36,7 @@ const App: FC<IAppProps> = ({ i18next, initialColorMode }: IAppProps) => {
layout: layoutReducer,
messages: messagesReducer,
networks: networksReducer,
passkeys: passkeysReducer,
passwordLock: passwordLockReducer,
sessions: sessionsReducer,
settings: settingsReducer,
Expand Down
2 changes: 2 additions & 0 deletions src/extension/apps/background/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import LoadingPage from '@extension/components/LoadingPage';
import { fetchAccountsFromStorageThunk } from '@extension/features/accounts';
import { handleNewEventByIdThunk } from '@extension/features/events';
import { closeCurrentWindowThunk } from '@extension/features/layout';
import { fetchFromStorageThunk as fetchPasskeyCredentialFromStorageThunk } from '@extension/features/passkeys';
import { fetchSessionsThunk } from '@extension/features/sessions';
import { fetchSettingsFromStorageThunk } from '@extension/features/settings';
import { fetchStandardAssetsFromStorageThunk } from '@extension/features/standard-assets';
Expand Down Expand Up @@ -47,6 +48,7 @@ const Root: FC = () => {
return;
}

dispatch(fetchPasskeyCredentialFromStorageThunk());
dispatch(fetchSystemInfoFromStorageThunk());
dispatch(fetchSettingsFromStorageThunk());
dispatch(fetchSessionsThunk());
Expand Down
11 changes: 7 additions & 4 deletions src/extension/apps/main/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { reducer as messagesReducer } from '@extension/features/messages';
import { reducer as networksReducer } from '@extension/features/networks';
import { reducer as newsReducer } from '@extension/features/news';
import { reducer as notificationsReducer } from '@extension/features/notifications';
import { reducer as passkeysReducer } from '@extension/features/passkeys';
import { reducer as passwordLockReducer } from '@extension/features/password-lock';
import { reducer as reKeyAccountReducer } from '@extension/features/re-key-account';
import { reducer as removeAssetsReducer } from '@extension/features/remove-assets';
Expand Down Expand Up @@ -68,6 +69,7 @@ import type {
IAppThunkDispatch,
IMainRootState,
ISettings,
TEncryptionCredentials,
} from '@extension/types';

// utils
Expand Down Expand Up @@ -143,17 +145,17 @@ const createRouter = ({ dispatch, getState }: Store<IMainRootState>) => {
],
element: <Root />,
loader: async () => {
let password: string | null;
let credentials: TEncryptionCredentials | null;
let settings: ISettings;

try {
settings = await (dispatch as IAppThunkDispatch)(
fetchSettingsFromStorageThunk()
).unwrap(); // fetch the settings from storage
password = getState().passwordLock.password;
credentials = getState().passwordLock.credentials;

// if the password lock is on, we need the password
if (settings.security.enablePasswordLock && !password) {
// if the password lock is on, we need the passkey/password
if (settings.security.enablePasswordLock && !credentials) {
return redirect(PASSWORD_LOCK_ROUTE);
}
} catch (error) {
Expand Down Expand Up @@ -187,6 +189,7 @@ const App: FC<IAppProps> = ({ i18next, initialColorMode }: IAppProps) => {
networks: networksReducer,
news: newsReducer,
notifications: notificationsReducer,
passkeys: passkeysReducer,
passwordLock: passwordLockReducer,
reKeyAccount: reKeyAccountReducer,
removeAssets: removeAssetsReducer,
Expand Down
7 changes: 5 additions & 2 deletions src/extension/apps/main/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
} from '@extension/features/networks';
import { fetchFromStorageThunk as fetchNewsFromStorageThunk } from '@extension/features/news';
import { setShowingConfetti } from '@extension/features/notifications';
import { fetchFromStorageThunk as fetchPasskeyCredentialFromStorageThunk } from '@extension/features/passkeys';
import { reset as resetReKeyAccount } from '@extension/features/re-key-account';
import { reset as resetRemoveAssets } from '@extension/features/remove-assets';
import { reset as resetSendAsset } from '@extension/features/send-assets';
Expand All @@ -50,6 +51,7 @@
import AddAssetsModal, {
AddAssetsForWatchAccountModal,
} from '@extension/modals/AddAssetsModal';
import AddPasskeyModal from '@extension/modals/AddPasskeyModal';

Check warning on line 54 in src/extension/apps/main/Root.tsx

View workflow job for this annotation

GitHub Actions / Lint

'AddPasskeyModal' is defined but never used
import ARC0300KeyRegistrationTransactionSendEventModal from '@extension/modals/ARC0300KeyRegistrationTransactionSendEventModal';
import ConfirmModal from '@extension/modals/ConfirmModal';
import EnableModal from '@extension/modals/EnableModal';
Expand All @@ -65,7 +67,7 @@
// selectors
import {
useSelectAccounts,
useSelectPasswordLockPassword,
useSelectPasswordLockCredentials,
useSelectNotificationsShowingConfetti,
useSelectSelectedNetwork,
useSelectSettings,
Expand All @@ -79,7 +81,7 @@
const navigate = useNavigate();
// selectors
const accounts = useSelectAccounts();
const passwordLockPassword = useSelectPasswordLockPassword();
const passwordLockPassword = useSelectPasswordLockCredentials();
const selectedNetwork = useSelectSelectedNetwork();
const settings = useSelectSettings();
const showingConfetti = useSelectNotificationsShowingConfetti();
Expand All @@ -98,6 +100,7 @@
useEffect(() => {
dispatch(fetchSystemInfoFromStorageThunk());
dispatch(fetchSettingsFromStorageThunk());
dispatch(fetchPasskeyCredentialFromStorageThunk());
dispatch(fetchSessionsThunk());
dispatch(fetchStandardAssetsFromStorageThunk());
dispatch(fetchARC0072AssetsFromStorageThunk());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import ModalSkeletonItem from '@extension/components/ModalSkeletonItem';
import ModalItem from '@extension/components/ModalItem';
import ModalTextItem from '@extension/components/ModalTextItem';
import ModalSubHeading from '@extension/components/ModalSubHeading';
import WatchAccountBadge from '@extension/components/WatchAccountBadge';

// constants
import {
Expand Down Expand Up @@ -56,7 +57,7 @@ import {
} from '@extension/selectors';

// services
import AccountService from '@extension/services/AccountService';
import PrivateKeyService from '@extension/services/PrivateKeyService';
import QuestsService from '@extension/services/QuestsService';

// theme
Expand All @@ -72,8 +73,8 @@ import type {
} from '@extension/types';

// utils
import convertPublicKeyToAVMAddress from '@extension/utils/convertPublicKeyToAVMAddress';
import ellipseAddress from '@extension/utils/ellipseAddress';
import WatchAccountBadge from '@extension/components/WatchAccountBadge';

const ARC0300AccountImportWithAddressModalContent: FC<
IARC0300ModalContentProps<
Expand Down Expand Up @@ -158,8 +159,8 @@ const ARC0300AccountImportWithAddressModalContent: FC<
ephemeral: true,
description: t<string>('captions.addedAccount', {
address: ellipseAddress(
AccountService.convertPublicKeyToAlgorandAddress(
account.publicKey
convertPublicKeyToAVMAddress(
PrivateKeyService.decode(account.publicKey)
)
),
}),
Expand All @@ -174,7 +175,9 @@ const ARC0300AccountImportWithAddressModalContent: FC<

// track the action
await questsService.importAccountViaQRCodeQuest(
AccountService.convertPublicKeyToAlgorandAddress(account.publicKey)
convertPublicKeyToAVMAddress(
PrivateKeyService.decode(account.publicKey)
)
);

// go to the account and the assets tab
Expand Down
Loading
Loading