forked from coracle/flotilla
9df8cee501
Adopts the rewritten welshman API: the removed @welshman/util helpers (Profile/List/Room/Handler/Encryptable) are now Reader/Builder classes in @welshman/domain, and @welshman/app dropped its global singletons for an App instance + app.use(Plugin) registry. - src/app/welshman.ts is now the app bootstrap + session-state module (one shared App instance, multi-account sessions/login, app-wide reactive views) rather than a compat shim re-exporting the old globals. - Rewrote ~100 callers to use app.use(Plugin) directly (thunks, profiles, relays, rooms, zaps, tags, wot, feeds, sync); thunk helpers are now thunk methods. - Added @welshman/domain dependency. - Resolved residual gaps (storage hydration via plugin.onItem/wrapManager/Plaintext, relay-list mutators, search-relay list, outbox #d filter). Best-effort: no toolchain/linking available, so this is not build- or type-checked. Remaining judgment calls are flagged with TODO(welshman-migration). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BsMjvv7krpZeHK1Njeneru
124 lines
3.9 KiB
Svelte
124 lines
3.9 KiB
Svelte
<script lang="ts">
|
|
import {Client} from "@pomade/core"
|
|
import {session} from "@app/welshman"
|
|
// TODO(welshman-migration): `SessionPomade` was removed from @welshman/app; the
|
|
// new generic Session nests its descriptor under `.data` ({clientOptions, email}),
|
|
// whereas this code destructures `email` from the top level. Confirm whether
|
|
// flotilla's FlotillaSession still surfaces `email` at the top level and adjust.
|
|
// Local type kept loose to avoid a broken import.
|
|
type SessionPomade = {email: string}
|
|
import {preventDefault} from "@lib/html"
|
|
import Key from "@assets/icons/key.svg?dataurl"
|
|
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
|
import AltArrowRight from "@assets/icons/alt-arrow-right.svg?dataurl"
|
|
import Icon from "@lib/components/Icon.svelte"
|
|
import FieldInline from "@lib/components/FieldInline.svelte"
|
|
import Spinner from "@lib/components/Spinner.svelte"
|
|
import Button from "@lib/components/Button.svelte"
|
|
import Modal from "@lib/components/Modal.svelte"
|
|
import ModalBody from "@lib/components/ModalBody.svelte"
|
|
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
|
import ModalTitle from "@lib/components/ModalTitle.svelte"
|
|
import ModalSubtitle from "@lib/components/ModalSubtitle.svelte"
|
|
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
|
import {loginWithPomade, deleteCurrentPomadeSession} from "@app/pomade"
|
|
import {clearModals} from "@app/modal"
|
|
import {pushToast} from "@app/toast"
|
|
|
|
type Props = {
|
|
userSecret: string
|
|
}
|
|
|
|
const {userSecret}: Props = $props()
|
|
|
|
const {email} = $session as SessionPomade
|
|
|
|
const back = () => history.back()
|
|
|
|
const onSubmit = async () => {
|
|
if (password.trim().length < 12) {
|
|
return pushToast({
|
|
theme: "error",
|
|
message: "Password must be at least 12 characters long.",
|
|
})
|
|
}
|
|
|
|
loading = true
|
|
|
|
try {
|
|
pushToast({
|
|
timeout: 60_000,
|
|
message: "Registering your new password, please wait...",
|
|
})
|
|
|
|
const {clientOptions, ...registerRes} = await Client.register(2, 3, userSecret)
|
|
|
|
if (!registerRes.ok) {
|
|
return pushToast({
|
|
theme: "error",
|
|
message: "Failed to register your new password! Please try again.",
|
|
})
|
|
}
|
|
|
|
const setupRes = await new Client(clientOptions).setupRecovery(email, password)
|
|
|
|
if (!setupRes.ok) {
|
|
const message = setupRes.messages[0]?.res?.message || "Please try again."
|
|
|
|
return pushToast({
|
|
theme: "error",
|
|
message: `Failed to register your new password! ${message}.`,
|
|
})
|
|
}
|
|
|
|
await deleteCurrentPomadeSession()
|
|
|
|
pushToast({message: "Your password has been updated!"})
|
|
loginWithPomade(clientOptions, email)
|
|
clearModals()
|
|
} catch (e) {
|
|
console.error(e)
|
|
|
|
pushToast({
|
|
theme: "error",
|
|
message: "Failed to register your new password! Please try again.",
|
|
})
|
|
} finally {
|
|
loading = false
|
|
}
|
|
}
|
|
|
|
let password = $state("")
|
|
let loading = $state(false)
|
|
</script>
|
|
|
|
<Modal tag="form" onsubmit={preventDefault(onSubmit)}>
|
|
<ModalBody>
|
|
<ModalHeader>
|
|
<ModalTitle>Update your Password</ModalTitle>
|
|
<ModalSubtitle>Please provide your new password.</ModalSubtitle>
|
|
</ModalHeader>
|
|
<FieldInline>
|
|
{#snippet label()}
|
|
<p>New Password*</p>
|
|
{/snippet}
|
|
{#snippet input()}
|
|
<label class="input input-bordered flex w-full items-center gap-2">
|
|
<Icon icon={Key} />
|
|
<input type="password" bind:value={password} />
|
|
</label>
|
|
{/snippet}
|
|
</FieldInline>
|
|
</ModalBody>
|
|
<ModalFooter>
|
|
<Button class="btn btn-link" onclick={back}>
|
|
<Icon icon={AltArrowLeft} />
|
|
Go back
|
|
</Button>
|
|
<Button class="btn btn-primary" type="submit" disabled={loading || !password}>
|
|
<Spinner {loading}>Continue</Spinner>
|
|
<Icon icon={AltArrowRight} />
|
|
</Button>
|
|
</ModalFooter>
|
|
</Modal>
|