From 4e36b2d902c76f914bbf3f13a4e14fe18f2548e9 Mon Sep 17 00:00:00 2001 From: Ren Amamiya <123083837+reyamir@users.noreply.github.com> Date: Mon, 10 Jul 2023 13:39:53 +0700 Subject: [PATCH] add migrate page --- src/app.tsx | 2 + src/app/auth/create/step-2.tsx | 2 +- src/app/auth/import/step-2.tsx | 2 +- src/app/auth/migrate.tsx | 208 +++++++++++++++++++++++++++++++++ src/libs/storage.tsx | 9 ++ src/shared/protected.tsx | 4 + 6 files changed, 225 insertions(+), 2 deletions(-) create mode 100644 src/app/auth/migrate.tsx diff --git a/src/app.tsx b/src/app.tsx index e644b4b8..509838f4 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -10,6 +10,7 @@ import { AuthImportScreen } from '@app/auth/import'; import { ImportStep1Screen } from '@app/auth/import/step-1'; import { ImportStep2Screen } from '@app/auth/import/step-2'; import { ImportStep3Screen } from '@app/auth/import/step-3'; +import { MigrateScreen } from '@app/auth/migrate'; import { OnboardingScreen } from '@app/auth/onboarding'; import { UnlockScreen } from '@app/auth/unlock'; import { WelcomeScreen } from '@app/auth/welcome'; @@ -69,6 +70,7 @@ const router = createBrowserRouter([ ], }, { path: 'unlock', element: }, + { path: 'migrate', element: }, ], }, { diff --git a/src/app/auth/create/step-2.tsx b/src/app/auth/create/step-2.tsx index 57abe0f5..7ecf2fb4 100644 --- a/src/app/auth/create/step-2.tsx +++ b/src/app/auth/create/step-2.tsx @@ -124,7 +124,7 @@ export function CreateStep2Screen() { + )} + + + + +
+
+ + Set password to protect your key + +
+ + +
+ + {errors.password &&

{errors.password.message}

} +
+
+
+ {privkeyStep.done && ( + + )} +
+
+ + + + + ); +} diff --git a/src/libs/storage.tsx b/src/libs/storage.tsx index cb4284a7..00e69c1c 100644 --- a/src/libs/storage.tsx +++ b/src/libs/storage.tsx @@ -447,3 +447,12 @@ export async function getUserMetadata(pubkey: string) { return null; } } + +// delete privkey +export async function removePrivkey() { + const db = await connect(); + const activeAccount = await getActiveAccount(); + return await db.execute( + `UPDATE accounts SET privkey = "privkey is stored in secure storage" WHERE id = "${activeAccount.id}";` + ); +} diff --git a/src/shared/protected.tsx b/src/shared/protected.tsx index c538a9ad..9f9f7576 100644 --- a/src/shared/protected.tsx +++ b/src/shared/protected.tsx @@ -13,6 +13,10 @@ export function Protected({ children }: { children: ReactNode }) { return ; } + if (status === 'success' && account && account.privkey.length > 35) { + return ; + } + if (status === 'success' && account && !password) { return ; }