From 2e05eee9e7b36ba6d15bbaccba81832dbe85f41e Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Wed, 4 Dec 2024 10:10:41 -0800 Subject: [PATCH] Add eject flow --- src/app/commands.ts | 15 ++++ src/app/components/LogInPassword.svelte | 2 +- src/app/components/LogOut.svelte | 12 ++- src/app/components/ProfileEject.svelte | 103 +++++++++++++++++++++++- 4 files changed, 123 insertions(+), 9 deletions(-) diff --git a/src/app/commands.ts b/src/app/commands.ts index 928f92f..7a168ab 100644 --- a/src/app/commands.ts +++ b/src/app/commands.ts @@ -46,6 +46,8 @@ import { loadRelay, addSession, subscribe, + clearStorage, + dropSession, } from "@welshman/app" import { COMMENT, @@ -149,6 +151,19 @@ export const loginWithNip46 = async ({ return true } +// Log out + +export const logout = async () => { + const $pubkey = pubkey.get() + + if ($pubkey) { + dropSession($pubkey) + } + + await clearStorage() + localStorage.clear() +} + // Loaders export const loadUserData = ( diff --git a/src/app/components/LogInPassword.svelte b/src/app/components/LogInPassword.svelte index b2842b4..f654dc2 100644 --- a/src/app/components/LogInPassword.svelte +++ b/src/app/components/LogInPassword.svelte @@ -25,7 +25,7 @@ const abortController = new AbortController() - const relays = BURROW_URL.startsWith('http://') + const relays = BURROW_URL.startsWith("http://") ? [normalizeRelayUrl("ws://" + stripProtocol(BURROW_URL))] : [normalizeRelayUrl(BURROW_URL)] diff --git a/src/app/components/LogOut.svelte b/src/app/components/LogOut.svelte index 9222b96..abf210c 100644 --- a/src/app/components/LogOut.svelte +++ b/src/app/components/LogOut.svelte @@ -1,30 +1,28 @@ -
+
Are you sure you want
to log out?
diff --git a/src/app/components/ProfileEject.svelte b/src/app/components/ProfileEject.svelte index 45b983b..dff2adb 100644 --- a/src/app/components/ProfileEject.svelte +++ b/src/app/components/ProfileEject.svelte @@ -1 +1,102 @@ -hi + + +
+ +
Export your keys
+
+

Here's what the process looks like:

+
    +
  • When you're ready, enter your account password below to continue.
  • +
  • + {PLATFORM_NAME} will send an email to "{email}" with your encrypted private key in it. +
  • +
  • + Store your "ncryptsec" in a password manager like + Bitwarden. This is the key to + your social identity; keep it safe and secret. +
  • +
  • + Choose a signer app and import + your private key into it. Don't forget your account password; you'll need it to decrypt your key. +
  • +
+

+ Once you export your key, you'll be logged out and won't be able to log in using + your email and password any more. Going forward, you'll need to use your signer app instead. +

+ {#if !success} +
+ +

To confirm, please enter your password below:

+ +
+
+ {/if} + + + {#if success} + + {:else} + + {/if} + +