2024-08-16 22:17:30 +00:00
|
|
|
<script lang="ts">
|
2026-01-16 18:06:25 +00:00
|
|
|
import type {ClientOptions} from "@pomade/core"
|
|
|
|
|
import type {Profile} from "@welshman/util"
|
|
|
|
|
import {makeProfile, makeSecret, getPubkey} from "@welshman/util"
|
|
|
|
|
import {loginWithNip01, loginWithPomade} from "@welshman/app"
|
2025-09-10 22:26:39 +00:00
|
|
|
import Key from "@assets/icons/key-minimalistic.svg?dataurl"
|
2025-12-18 02:43:13 +00:00
|
|
|
import Letter from "@assets/icons/letter.svg?dataurl"
|
2026-01-16 18:06:25 +00:00
|
|
|
import {getKey, setKey} from "@lib/implicit"
|
2024-08-16 22:17:30 +00:00
|
|
|
import Icon from "@lib/components/Icon.svelte"
|
|
|
|
|
import Button from "@lib/components/Button.svelte"
|
|
|
|
|
import LogIn from "@app/components/LogIn.svelte"
|
2024-10-17 17:34:13 +00:00
|
|
|
import InfoNostr from "@app/components/InfoNostr.svelte"
|
2026-01-16 18:06:25 +00:00
|
|
|
import SignUpKey from "@app/components/SignUpKey.svelte"
|
|
|
|
|
import SignUpEmail from "@app/components/SignUpEmail.svelte"
|
2025-08-18 22:02:17 +00:00
|
|
|
import SignUpProfile from "@app/components/SignUpProfile.svelte"
|
2026-01-16 18:06:25 +00:00
|
|
|
import SignUpComplete from "@app/components/SignUpComplete.svelte"
|
|
|
|
|
import {setChecked} from "@app/util/notifications"
|
|
|
|
|
import {pushModal, clearModals} from "@app/util/modal"
|
|
|
|
|
import {initProfile} from "@app/core/commands"
|
2025-12-18 02:43:13 +00:00
|
|
|
import {POMADE_SIGNERS, PLATFORM_NAME} from "@app/core/state"
|
2024-12-03 00:21:54 +00:00
|
|
|
|
2026-01-16 18:06:25 +00:00
|
|
|
setKey("signup.email", "")
|
|
|
|
|
setKey("signup.secret", makeSecret())
|
|
|
|
|
setKey("signup.profile", makeProfile())
|
|
|
|
|
setKey("signup.clientOptions", undefined)
|
|
|
|
|
|
2025-12-18 02:43:13 +00:00
|
|
|
const hasPomade = POMADE_SIGNERS.length >= 3
|
2024-12-03 00:21:54 +00:00
|
|
|
|
2025-12-18 02:43:13 +00:00
|
|
|
const login = () => pushModal(LogIn)
|
2024-08-16 22:17:30 +00:00
|
|
|
|
2026-01-16 18:06:25 +00:00
|
|
|
const flows = {
|
|
|
|
|
email: {
|
|
|
|
|
start: () => pushModal(SignUpEmail, {next: flows.email.profile}),
|
|
|
|
|
profile: () => pushModal(SignUpProfile, {next: flows.email.complete}),
|
|
|
|
|
complete: () => pushModal(SignUpComplete, {next: flows.email.finalize}),
|
|
|
|
|
finalize: () => {
|
|
|
|
|
const email = getKey<string>("signup.email")!
|
|
|
|
|
const secret = getKey<string>("signup.secret")!
|
|
|
|
|
const profile = getKey<Profile>("signup.profile")!
|
|
|
|
|
const clientOptions = getKey<ClientOptions>("signup.clientOptions")!
|
|
|
|
|
|
|
|
|
|
loginWithPomade(getPubkey(secret), email, clientOptions!)
|
|
|
|
|
initProfile(profile)
|
|
|
|
|
setChecked("*")
|
|
|
|
|
clearModals()
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
nostr: {
|
|
|
|
|
start: () => pushModal(SignUpProfile, {next: flows.nostr.key}),
|
|
|
|
|
key: () => pushModal(SignUpKey, {next: flows.nostr.complete}),
|
|
|
|
|
complete: () => pushModal(SignUpComplete, {next: flows.nostr.finalize}),
|
|
|
|
|
finalize: () => {
|
|
|
|
|
const secret = getKey<string>("signup.secret")!
|
|
|
|
|
const profile = getKey<Profile>("signup.profile")!
|
2025-02-14 18:53:36 +00:00
|
|
|
|
2026-01-16 18:06:25 +00:00
|
|
|
loginWithNip01(secret)
|
|
|
|
|
initProfile(profile)
|
|
|
|
|
setChecked("*")
|
|
|
|
|
clearModals()
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
2024-08-16 22:17:30 +00:00
|
|
|
</script>
|
|
|
|
|
|
2025-12-18 02:43:13 +00:00
|
|
|
<div class="column gap-4">
|
2024-08-16 22:17:30 +00:00
|
|
|
<h1 class="heading">Sign up with Nostr</h1>
|
|
|
|
|
<p class="m-auto max-w-sm text-center">
|
2024-10-22 18:04:40 +00:00
|
|
|
{PLATFORM_NAME} is built using the
|
2025-08-18 22:02:17 +00:00
|
|
|
<Button class="link" onclick={() => pushModal(InfoNostr)}>nostr protocol</Button>, which gives
|
|
|
|
|
users control over their digital identity using <strong>cryptographic key pairs</strong>.
|
2024-08-16 22:17:30 +00:00
|
|
|
</p>
|
2025-12-18 02:43:13 +00:00
|
|
|
{#if hasPomade}
|
2026-01-16 18:06:25 +00:00
|
|
|
<Button onclick={flows.email.start} class="btn btn-primary">
|
2025-12-18 02:43:13 +00:00
|
|
|
<Icon icon={Letter} />
|
|
|
|
|
Sign up with email
|
2024-11-27 00:39:49 +00:00
|
|
|
</Button>
|
|
|
|
|
{/if}
|
2026-01-16 18:06:25 +00:00
|
|
|
<Button onclick={flows.nostr.start} class="btn {hasPomade ? 'btn-neutral' : 'btn-primary'}">
|
2025-09-10 22:26:39 +00:00
|
|
|
<Icon icon={Key} />
|
2025-08-18 22:02:17 +00:00
|
|
|
Generate a key
|
|
|
|
|
</Button>
|
2024-10-17 17:34:13 +00:00
|
|
|
<div class="text-sm">
|
|
|
|
|
Already have an account?
|
2025-02-04 01:21:46 +00:00
|
|
|
<Button class="link" onclick={login}>Log in instead</Button>
|
2024-08-16 22:17:30 +00:00
|
|
|
</div>
|
2025-12-18 02:43:13 +00:00
|
|
|
</div>
|