Something went wrong. Try again.
Monorepo for Tangled
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445import type { OAuthUserAgent } from "@atcute/oauth-browser-client";import { mintServiceAuth, serviceDidForHost } from "$lib/auth/agent";import type { BobbinContext, XrpcRequestInit } from "./client";import { jsonGet } from "./_request";import type * as ShTangledFeedGetTimeline from "./lexicons/types/sh/tangled/feed/getTimeline";
export const TIMELINE_NSID = "sh.tangled.feed.getTimeline";export const TIMELINE_LIMIT = 50;
export interface TimelineOptions { followingOnly?: boolean; limit?: number; cursor?: string;}
export const getTimeline = ( ctx: BobbinContext, { followingOnly, limit, cursor }: TimelineOptions = {}, init?: XrpcRequestInit) => jsonGet<ShTangledFeedGetTimeline.$output>( ctx, TIMELINE_NSID, { followingOnly, limit, cursor }, init );
// the viewer is the verified `iss` of a service-auth token now, not a query param, so an// authenticated timeline can only be fetched from the browser where the oauth session lives.export const getTimelineAs = async ( ctx: BobbinContext, agent: OAuthUserAgent, options: TimelineOptions = {}, init?: XrpcRequestInit) => { const token = await mintServiceAuth(agent, { aud: serviceDidForHost(new URL(ctx.serviceUrl).host), lxm: TIMELINE_NSID }); return getTimeline(ctx, options, { ...init, headers: { ...init?.headers, authorization: `Bearer ${token}` } });};