From 66740dea41f2772d46e1b13b91ef0e7b1a68bfff Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 6 Feb 2023 16:40:14 -0800 Subject: new pinpad component --- src/components/Feed.svelte | 4 +- src/components/Password.svelte | 6 +- src/components/Pin.svelte | 26 +-- src/components/Pinpad.svelte | 81 ++++++++ src/components/RegisterOrLogin.svelte | 207 +++++++++------------ src/components/index.js | 1 + src/lib/nostr.js | 2 +- src/lib/utils.js | 2 +- src/locales/en.json | 2 +- src/routes/(app)/[username]/(profile)/+page.svelte | 5 +- .../[username]/(profile)/messages/+page.svelte | 4 +- src/routes/(app)/[username]/dashboard/+page.svelte | 2 +- src/routes/(app)/[username]/generate/+page.svelte | 6 +- .../[username]/settings/[...tab]/+page.svelte | 8 +- .../(app)/[username]/settings/[...tab]/_pos.svelte | 2 +- .../[username]/settings/[...tab]/_security.svelte | 161 ++++++---------- src/routes/(app)/disable2fa/+server.js | 4 +- src/routes/(app)/otpsecret/+server.js | 2 +- src/routes/(app)/send/[...text]/+page.svelte | 4 +- 19 files changed, 277 insertions(+), 252 deletions(-) create mode 100644 src/components/Pinpad.svelte (limited to 'src') diff --git a/src/components/Feed.svelte b/src/components/Feed.svelte index ab757fa1..7de087a7 100644 --- a/src/components/Feed.svelte +++ b/src/components/Feed.svelte @@ -4,7 +4,7 @@ import { Event } from '$comp'; import { browser } from '$app/environment'; import VirtualScroll from 'svelte-virtual-scroll-list'; - import { failure } from '$lib/utils'; + import { fail } from '$lib/utils'; import { sign, send } from '$lib/nostr'; export let events; @@ -34,7 +34,7 @@ events = events; } catch (e) { console.log(e, e.stack); - failure('Problem posting event'); + fail('Problem posting event'); } }; diff --git a/src/components/Password.svelte b/src/components/Password.svelte index fd39441c..a84c0b16 100644 --- a/src/components/Password.svelte +++ b/src/components/Password.svelte @@ -1,6 +1,6 @@ @@ -51,7 +51,7 @@ diff --git a/src/components/Pin.svelte b/src/components/Pin.svelte index 7225ac37..0db831ff 100644 --- a/src/components/Pin.svelte +++ b/src/components/Pin.svelte @@ -1,24 +1,28 @@ -
-
-

Please enter your PIN

- +
+
+

{title}

+
diff --git a/src/components/Pinpad.svelte b/src/components/Pinpad.svelte new file mode 100644 index 00000000..bf3778f7 --- /dev/null +++ b/src/components/Pinpad.svelte @@ -0,0 +1,81 @@ + + +
+
+
+ {#if hide} + + {:else} + + {/if} + +
+ +
+ {#each numPad as value} + {#if value === arrow} + + {:else} + + {/if} + {/each} +
+
+
diff --git a/src/components/RegisterOrLogin.svelte b/src/components/RegisterOrLogin.svelte index 7ac2fbb3..6c099178 100644 --- a/src/components/RegisterOrLogin.svelte +++ b/src/components/RegisterOrLogin.svelte @@ -1,28 +1,32 @@ +{#if need2fa} + +{/if} +
diff --git a/src/components/index.js b/src/components/index.js index 18a821ff..ab54e09f 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -1,3 +1,4 @@ +export { default as Pinpad } from './Pinpad.svelte'; export { default as Balance } from './Balance.svelte'; export { default as Lnurlp } from './Lnurlp.svelte'; export { default as Lnurlw } from './Lnurlw.svelte'; diff --git a/src/lib/nostr.js b/src/lib/nostr.js index 35d843b2..de19b477 100644 --- a/src/lib/nostr.js +++ b/src/lib/nostr.js @@ -3,7 +3,7 @@ import * as ecc from 'tiny-secp256k1'; import { generateMnemonic, entropyToMnemonic, mnemonicToEntropy, mnemonicToSeedSync } from 'bip39'; import { Buffer } from 'buffer'; import { bech32m } from 'bech32'; -import { bip32, failure, wait, post, stretch } from '$lib/utils'; +import { bip32, fail, wait, post, stretch } from '$lib/utils'; import { calculateId, signId } from 'nostr'; import { password as pw, passwordPrompt, pin, loginRedirect } from '$lib/store'; import { goto, invalidate } from '$app/navigation'; diff --git a/src/lib/utils.js b/src/lib/utils.js index d0b0b1c2..3a644e1f 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -101,7 +101,7 @@ export const warning = (m) => { } }); }; -export const failure = (m) => { +export const fail = (m) => { toast.pop(); toast.push(m, { theme: { diff --git a/src/locales/en.json b/src/locales/en.json index eb0039ac..b39571f6 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -241,7 +241,7 @@ "autoLock": "Auto-Lock Timer", "autoLockDescription": "Your account will go into a secure mode, requiring you to re-enter your credentials after a specified time:", "twofa": "2-Factor Authentication", - "twofaDescription": "Add an extra level of security to your device by enableing 2-factor authentication.", + "twofaDescription": "Add an extra level of security to your device by enabling 2-factor authentication.", "twofaSetup": "Set up 2FA", "twofaDisable": "Disable 2FA", "select": "Select", diff --git a/src/routes/(app)/[username]/(profile)/+page.svelte b/src/routes/(app)/[username]/(profile)/+page.svelte index 40c73ea4..1cf525a0 100644 --- a/src/routes/(app)/[username]/(profile)/+page.svelte +++ b/src/routes/(app)/[username]/(profile)/+page.svelte @@ -4,8 +4,11 @@ export let data; let { events, subject, user } = data; + let v;
- + {#if user?.id === subject.id} + + {/if}
diff --git a/src/routes/(app)/[username]/(profile)/messages/+page.svelte b/src/routes/(app)/[username]/(profile)/messages/+page.svelte index 00960534..db7b1ced 100644 --- a/src/routes/(app)/[username]/(profile)/messages/+page.svelte +++ b/src/routes/(app)/[username]/(profile)/messages/+page.svelte @@ -5,7 +5,7 @@ import { scale } from 'svelte/transition'; import { enhance } from '$app/forms'; import { Icon } from '$comp'; - import { back, failure, focus } from '$lib/utils'; + import { back, fail, focus } from '$lib/utils'; import { sign, send, encrypt, decrypt } from '$lib/nostr'; import { messages, password } from '$lib/store'; import { tick, onMount } from 'svelte'; @@ -64,7 +64,7 @@ sent = true; } catch (e) { - failure('Failed to send message'); + fail('Failed to send message'); delete $messages[user.pubkey][subject.pubkey][event.id]; $messages = $messages; } diff --git a/src/routes/(app)/[username]/dashboard/+page.svelte b/src/routes/(app)/[username]/dashboard/+page.svelte index d136943e..499034e6 100644 --- a/src/routes/(app)/[username]/dashboard/+page.svelte +++ b/src/routes/(app)/[username]/dashboard/+page.svelte @@ -1,6 +1,6 @@ {#if loaded && user.haspin && $pin?.length !== 6} - + {/if}
import { Icon, LocaleSelector, Toggle } from '$comp'; import { t } from '$lib/translations'; - import { success, failure } from '$lib/utils'; + import { success, fail } from '$lib/utils'; import { page } from '$app/stores'; export let user, rates; diff --git a/src/routes/(app)/[username]/settings/[...tab]/_security.svelte b/src/routes/(app)/[username]/settings/[...tab]/_security.svelte index cf969f1c..eb3b405e 100644 --- a/src/routes/(app)/[username]/settings/[...tab]/_security.svelte +++ b/src/routes/(app)/[username]/settings/[...tab]/_security.svelte @@ -1,80 +1,52 @@ @@ -155,31 +147,10 @@

{$t('user.settings.securityPINDescription')}

- {#if settingPin} -
-
-
- - - - - - - - -
-
- - - - - - - - -
-
-
+ {#if verifying} + + {:else if settingPin} + {:else}
-
- {$t('user.settings.oneTimeCode')}
- - - - - - - - -
- {:else if disabling2fa} -
- {$t('user.settings.oneTimeCode')}
- - - - - - - - -
+ {:else if user.twofa} - {:else} - {/if} + + {#if confirming2fa || disabling2fa} + + {/if}
diff --git a/src/routes/(app)/disable2fa/+server.js b/src/routes/(app)/disable2fa/+server.js index 13fcb2b9..b2bb07ec 100644 --- a/src/routes/(app)/disable2fa/+server.js +++ b/src/routes/(app)/disable2fa/+server.js @@ -1,4 +1,4 @@ -import { error } from '@sveltejs/kit'; +import { error, json } from '@sveltejs/kit'; import { auth, post } from '$lib/utils'; export async function POST({ cookies, request }) { @@ -6,7 +6,7 @@ export async function POST({ cookies, request }) { let body = await request.json(); let res = await post('/disable2fa', body, auth(cookies)); - return new Response(JSON.stringify(res)); + return json(res); } catch (e) { throw error(500, 'Problem disabling 2fa'); } diff --git a/src/routes/(app)/otpsecret/+server.js b/src/routes/(app)/otpsecret/+server.js index 31dbcec1..7d5c1ad9 100644 --- a/src/routes/(app)/otpsecret/+server.js +++ b/src/routes/(app)/otpsecret/+server.js @@ -9,7 +9,7 @@ export async function POST({ cookies, request }) { let uri = `otpauth://totp/coinos:${username}?secret=${secret}&period=30&digits=6&algorithm=SHA1&issuer=coinos`; return new Response(JSON.stringify({ secret, uri, qr: Qr.drawImg(uri, { size: 600 }) })); } catch (e) { - console.log(e); + if (e.message.includes('pin')) throw e; throw new error(500, 'Problem saving secret'); } } diff --git a/src/routes/(app)/send/[...text]/+page.svelte b/src/routes/(app)/send/[...text]/+page.svelte index e3d8091f..46f5e56a 100644 --- a/src/routes/(app)/send/[...text]/+page.svelte +++ b/src/routes/(app)/send/[...text]/+page.svelte @@ -6,7 +6,7 @@ import { browser } from '$app/environment'; import { t } from '$lib/translations'; import { AppHeader, Avatar, Icon, Spinner } from '$comp'; - import { back, failure } from '$lib/utils'; + import { back, fail } from '$lib/utils'; import { format, parseISO } from 'date-fns'; export let data; @@ -90,7 +90,7 @@

{$t('user.send.contacts')}

{#each contacts as c} - +
-- cgit v1.2.3 From c43ec91c41e75a3dc61611c1f56a5f151860350b Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 6 Feb 2023 22:11:04 -0800 Subject: z index for avatar --- src/components/AppHeader.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/components/AppHeader.svelte b/src/components/AppHeader.svelte index 29e96ce1..d3a9b300 100644 --- a/src/components/AppHeader.svelte +++ b/src/components/AppHeader.svelte @@ -128,7 +128,7 @@ {/if}
-- cgit v1.2.3 From b5b7fe81ba245f85ecc1a67318eeb92a34949861 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 6 Feb 2023 22:52:37 -0800 Subject: fix internal sends --- .../(app)/[username]/(profile)/+layout.svelte | 2 +- src/routes/(app)/pin/+server.js | 7 ++++ src/routes/(app)/send/+layout.svelte | 24 +++++++++++- src/routes/(app)/send/[...text]/+page.svelte | 2 +- .../user/[username]/[...amount]/+page.server.js | 6 +-- .../send/user/[username]/[...amount]/+page.svelte | 45 +++++++--------------- 6 files changed, 48 insertions(+), 38 deletions(-) create mode 100644 src/routes/(app)/pin/+server.js (limited to 'src') diff --git a/src/routes/(app)/[username]/(profile)/+layout.svelte b/src/routes/(app)/[username]/(profile)/+layout.svelte index b318d777..6dacf2ce 100644 --- a/src/routes/(app)/[username]/(profile)/+layout.svelte +++ b/src/routes/(app)/[username]/(profile)/+layout.svelte @@ -123,7 +123,7 @@ {/if} {#if !subject.anon && subject.username !== user?.username}
- + + {#if form?.message}
@@ -63,20 +54,12 @@
{#if amount} -
-

- {fiat ? f(amountFiat, currency) : s(amount)} - {#if !fiat} - sats - {/if} -

- -

to

- -
- -

{recipient.username}

-
+

Sending

+
+

+ {f(amountFiat, currency)} +

+

{sat(amount)}

{:else} @@ -84,7 +67,7 @@ - + -- cgit v1.2.3