Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
Svelte
12345678910111213141516171819202122232425262728293031323334353637383940414243444546<script lang="ts"> // story-only helper: injects a fake auth context so form stories can exercise // a real (failing) submission without a live session. the fake agent's fetch // handler always rejects, so putIssue/putComment land in the form's catch block. import { setContext, type Snippet } from "svelte"; import { AUTH_KEY, type Auth } from "$lib/auth.svelte";
interface Props { // message the fake agent rejects submissions with failWith?: string; // when false, injects a signed-out context (no agent / null did) so stories // can exercise the logged-out affordance signedIn?: boolean; children: Snippet; }
let { failWith = "MockAuthProvider: network request failed, this error is intentional.", signedIn = true, children }: Props = $props();
// props are fixed for this provider's lifetime, so a one-time snapshot is intended // svelte-ignore state_referenced_locally const agent = signedIn ? { sub: "did:plc:alice", handle: () => Promise.reject(new Error(failWith)) } : null;
// svelte-ignore state_referenced_locally const auth = (signedIn ? { agent, currentDid: "did:plc:alice", currentUser: { did: "did:plc:alice", handle: "alice.pds.tngl.boltless.dev" }, bobbinUrl: "https://bobbin.story" } : { agent: null, currentDid: null, currentUser: null }) as unknown as Auth;
setContext(AUTH_KEY, auth);</script>
{@render children()}