From 623ba643091014d5a7bbcbc2987ba83c696ed273 Mon Sep 17 00:00:00 2001 From: Flemmli97 <34157027+Flemmli97@users.noreply.github.com> Date: Fri, 20 Dec 2024 13:29:06 +0100 Subject: [PATCH] feat(wasm): Import/export account (#893) --- .../components/settings/OrderedPhrase.svelte | 21 +- src/lib/elements/Input/FileInput.svelte | 4 +- src/lib/elements/Input/Input.svelte | 6 +- src/lib/lang/en.json | 18 ++ src/lib/layouts/login/Entrypoint.svelte | 8 +- src/lib/layouts/login/ImportAccount.svelte | 201 ++++++++++++++++++ src/lib/layouts/login/Unlock.svelte | 6 + src/lib/wasm/HandleWarpErrors.ts | 3 + src/lib/wasm/MultipassStore.ts | 24 +++ src/lib/wasm/TesseractStore.ts | 4 + src/lib/wasm/WarpStore.ts | 13 +- src/routes/auth/+page.svelte | 6 +- src/routes/settings/developer/+page.svelte | 2 +- src/routes/settings/profile/+page.svelte | 43 +++- 14 files changed, 344 insertions(+), 15 deletions(-) create mode 100644 src/lib/layouts/login/ImportAccount.svelte diff --git a/src/lib/components/settings/OrderedPhrase.svelte b/src/lib/components/settings/OrderedPhrase.svelte index 9b5dd7064..a782fbd19 100644 --- a/src/lib/components/settings/OrderedPhrase.svelte +++ b/src/lib/components/settings/OrderedPhrase.svelte @@ -2,10 +2,13 @@ import { fade } from "svelte/transition" import { animationDelay, animationDuration } from "$lib/globals/animations" import { Text, Loader } from "$lib/elements" + import Input from "$lib/elements/Input/Input.svelte" + import type { Writable } from "svelte/store" export let number: number = 0 export let word: string = "UNKNOWN" export let loading: boolean = false + export let editable: boolean = false
@@ -18,12 +21,16 @@
{/if} - + {#if loading} {:else}
- {word} + {#if editable} + + {:else} + {word} + {/if}
{/if}
@@ -64,6 +71,16 @@ display: inline-block; flex: 1; padding: var(--padding-minimal) var(--padding); + &.editable { + padding: 0; + } + } + + :global(.input-group > .input-container) { + border: none; + } + :global(.input-group > .input-container::selection) { + border: none; } } diff --git a/src/lib/elements/Input/FileInput.svelte b/src/lib/elements/Input/FileInput.svelte index 483e2f501..86446f0d1 100644 --- a/src/lib/elements/Input/FileInput.svelte +++ b/src/lib/elements/Input/FileInput.svelte @@ -3,6 +3,8 @@ export let hidden: boolean = false export let clss: string = "" + export let allowed: string | undefined = undefined + export let multiple: boolean = true const dispatch: EventDispatcher> = createEventDispatcher() @@ -24,4 +26,4 @@ } - + diff --git a/src/lib/elements/Input/Input.svelte b/src/lib/elements/Input/Input.svelte index 19f85d411..839a342e5 100644 --- a/src/lib/elements/Input/Input.svelte +++ b/src/lib/elements/Input/Input.svelte @@ -25,6 +25,7 @@ export let rich: boolean = false export let autoFocus: boolean = false export let rules: InputRules = new InputRules() + export let noCapitalize: boolean = false let errorMessage: string = "" @@ -179,6 +180,8 @@ + autofocus={isAndroidOriOS() ? isKeyboardOpened : autoFocus} + on:paste /> {#if errorMessage} diff --git a/src/lib/lang/en.json b/src/lib/lang/en.json index 65acbd084..6492f6148 100644 --- a/src/lib/lang/en.json +++ b/src/lib/lang/en.json @@ -276,6 +276,16 @@ "new": "Create New Account", "import": "Import Account", "profile": "Create new profile" + }, + "import": { + "title": "Import Account", + "description": "Import your account from remote or a backup file", + "passphrase": "Add passphrase", + "remote": "Import from remote", + "file": "Import from file", + "warning": "By continuing your old account will be overwritten!", + "fail": "Failed to import account", + "fail.null": "Failed to create identity during account import" } } }, @@ -370,6 +380,14 @@ "remove": "Your recovery phrase will not be stored anymore and will be removed. Make sure to save the phrase! This change is irreversible!", "remove.yes": "I understand", "remove.no": "Cancel" + }, + "export": { + "label": "Export", + "description": "Export your account manually to remote or a file", + "remote": "Remote", + "file": "File", + "fail": "Failed to export account", + "success": "Successfully exported account to remote" } }, "calling": { diff --git a/src/lib/layouts/login/Entrypoint.svelte b/src/lib/layouts/login/Entrypoint.svelte index 51bb5b7e7..3326a3de6 100644 --- a/src/lib/layouts/login/Entrypoint.svelte +++ b/src/lib/layouts/login/Entrypoint.svelte @@ -63,11 +63,9 @@ - {#if get(SettingsStore.state).devmode} - - {/if} + diff --git a/src/lib/layouts/login/ImportAccount.svelte b/src/lib/layouts/login/ImportAccount.svelte new file mode 100644 index 000000000..977d8b60d --- /dev/null +++ b/src/lib/layouts/login/ImportAccount.svelte @@ -0,0 +1,201 @@ + + +{#if pin.length == 0} + { + await setupTesseract(e.detail.pin) + e.detail.done() + }} /> +{:else} + +{/if} + + diff --git a/src/lib/layouts/login/Unlock.svelte b/src/lib/layouts/login/Unlock.svelte index 73c91bfc2..86ccc9fc1 100644 --- a/src/lib/layouts/login/Unlock.svelte +++ b/src/lib/layouts/login/Unlock.svelte @@ -18,6 +18,8 @@ import { ToastMessage } from "$lib/state/ui/toast" import { TesseractStoreInstance } from "$lib/wasm/TesseractStore" export let create: boolean = false + export let importing: boolean = false + const dispatch = createEventDispatcher() let loading = false @@ -119,6 +121,10 @@ {/if} + {#if importing} + {$_("pages.auth.import.warning")} + {/if} + {#if loading}