appview-less bluesky client
27
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: properly resume oauth session

dusk 1731f8cd 431f3f26

+12 -14
+1 -1
src/components/BskyPost.svelte
··· 51 51 isOnPostComposer = false /* replyBacklinks */ 52 52 }: Props = $props(); 53 53 54 - const selectedDid = $derived(client.didDoc?.did ?? null); 54 + const selectedDid = $derived(client.user?.did ?? null); 55 55 56 56 const aturi: CanonicalResourceUri = `at://${did}/app.bsky.feed.post/${rkey}`; 57 57 const color = generateColorForDid(did);
+2 -2
src/components/PostComposer.svelte
··· 23 23 }: Props = $props(); 24 24 25 25 let color = $derived( 26 - client.didDoc?.did ? generateColorForDid(client.didDoc?.did) : 'var(--nucleus-accent2)' 26 + client.user?.did ? generateColorForDid(client.user?.did) : 'var(--nucleus-accent2)' 27 27 ); 28 28 29 29 const post = async (text: string): Promise<Result<PostWithUri, string>> => { ··· 53 53 const res = await client.atcute?.post('com.atproto.repo.createRecord', { 54 54 input: { 55 55 collection: 'app.bsky.feed.post', 56 - repo: client.didDoc!.did, 56 + repo: client.user!.did, 57 57 record 58 58 } 59 59 });
+8 -10
src/lib/at/client.ts
··· 71 71 72 72 export class AtpClient { 73 73 public atcute: AtcuteClient | null = null; 74 - public didDoc: MiniDoc | null = null; 74 + public user: { did: Did; handle: Handle } | null = null; 75 75 76 76 async login(identifier: ActorIdentifier, agent: OAuthUserAgent): Promise<Result<null, string>> { 77 - if ((agent.session.token.expires_at ?? 0) < Date.now()) { 78 - return err('token expired, relogin'); 79 - } 80 - 81 - const didDoc = await this.resolveDidDoc(identifier); 82 - if (!didDoc.ok) return err(didDoc.error); 83 - this.didDoc = didDoc.value; 84 - 85 77 try { 86 78 const rpc = new AtcuteClient({ handler: agent }); 79 + const res = await rpc.get('com.atproto.server.getSession'); 80 + if (!res.ok) throw res.data.error; 81 + this.user = { 82 + did: res.data.did, 83 + handle: res.data.handle 84 + }; 87 85 this.atcute = rpc; 88 86 } catch (error) { 89 87 return err(`failed to login: ${error}`); ··· 156 154 } 157 155 158 156 async getProfile(repo?: ActorIdentifier): Promise<Result<AppBskyActorProfile.Main, string>> { 159 - repo = repo ?? this.didDoc?.did; 157 + repo = repo ?? this.user?.did; 160 158 if (!repo) return err('not authenticated'); 161 159 return map(await this.getRecord(AppBskyActorProfile.mainSchema, repo, 'self'), (d) => d.record); 162 160 }
+1 -1
src/routes/+page.svelte
··· 239 239 if ($accounts.length > 0) { 240 240 loaderState.status = 'LOADING'; 241 241 if (loadData.client.ok && loadData.client.value) { 242 - const loggedInDid = loadData.client.value.didDoc!.did as AtprotoDid; 242 + const loggedInDid = loadData.client.value.user!.did as AtprotoDid; 243 243 selectedDid = loggedInDid; 244 244 clients.set(loggedInDid, loadData.client.value); 245 245 }