beatufitull front end for ozone modration ,, wit catpucoin and ebergarden !
0
fork

Configure Feed

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

fix serber side

+6 -14
+6 -14
src/lib/oauth.client.ts
··· 1 - import { BrowserOAuthClient, buildAtprotoLoopbackClientMetadata } from '@atproto/oauth-client-browser' 2 - import type { OAuthSession } from '@atproto/oauth-client-browser' 1 + import type { OAuthSession, BrowserOAuthClient } from '@atproto/oauth-client-browser' 3 2 import { getPdsUrl, getPlcUrl } from './api/ozone' 4 3 5 - // Cache clients by metadata path to avoid mixing different client_ids 6 4 const oauthClientCache = new Map<string, BrowserOAuthClient>() 7 5 export let tempClient: BrowserOAuthClient | null = null 8 - // Store the current metadata path for this session 9 6 export let currentMetadataPath: string = "/client-metadata.json" 10 7 11 8 export async function getOAuthClient(metadata: string = "/client-metadata.json"): Promise<BrowserOAuthClient> { 12 - // Update the current metadata path 13 9 currentMetadataPath = metadata 14 - // Don't cache during callback processing to ensure params are captured 10 + 15 11 if (!window.location.search.includes('code') && oauthClientCache.has(metadata)) { 16 12 return oauthClientCache.get(metadata)! 17 13 } 14 + 15 + const { BrowserOAuthClient } = await import('@atproto/oauth-client-browser') 18 16 19 17 const client = await BrowserOAuthClient.load({ 20 18 clientId: window.location.origin + metadata, ··· 28 26 } 29 27 30 28 export async function initializeAuth(): Promise<OAuthSession | null> { 31 - // Check if we have a stored metadata path from a popup OAuth flow 32 29 let metadataPath = "/client-metadata.json" 33 30 if (typeof window !== 'undefined') { 34 31 const storedPath = sessionStorage.getItem('oauth-metadata-path') 35 32 if (storedPath) { 36 33 metadataPath = storedPath 37 - // Clear it after use 38 34 sessionStorage.removeItem('oauth-metadata-path') 39 35 } 40 36 } 41 - 37 + 42 38 const client = await getOAuthClient(metadataPath) 43 39 const result = await client.init() 44 - 45 40 console.log("got auth result", result) 46 - 47 41 if (result && result.session) { 48 42 return result.session 49 43 } 50 - 51 44 return null 52 45 } 53 46 ··· 57 50 } 58 51 59 52 export async function signInPopup(handle: string, metadata: string = "/client-metadata.json"): Promise<OAuthSession> { 60 - // Store metadata path in sessionStorage so callback can use the correct client 61 53 if (typeof window !== 'undefined') { 62 54 sessionStorage.setItem('oauth-metadata-path', metadata) 63 55 } ··· 67 59 68 60 export async function signOut(session: OAuthSession): Promise<void> { 69 61 await session.signOut() 70 - } 62 + }