This repository has no description
0

Configure Feed

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

fix

+39 -9
+39 -9
app/src/lib/bluesky-api.ts
··· 73 73 74 74 console.log('[TOKEN REFRESH] Refreshing token for PDS:', pdsEndpoint); 75 75 76 - // CRITICAL FIX: For third-party PDS endpoints, use bsky.social for auth 77 - // Third-party PDS hosts don't implement OAuth endpoints themselves 76 + // CRITICAL FIX: Token refresh endpoint selection based on PDS type 78 77 let authServer = pdsEndpoint; 79 78 80 - // Check if this is a third-party PDS (not bsky.social) 81 - if (!pdsEndpoint.includes('bsky.social')) { 82 - console.log('[TOKEN REFRESH] Using bsky.social for OAuth on third-party PDS'); 79 + // For bsky.network PDSes, use bsky.social 80 + if (pdsEndpoint.includes('bsky.network')) { 81 + console.log('[TOKEN REFRESH] Using bsky.social for bsky.network PDS'); 83 82 authServer = 'https://bsky.social'; 83 + } else if (pdsEndpoint.includes('bsky.social')) { 84 + // Already using bsky.social 85 + console.log('[TOKEN REFRESH] Using bsky.social directly'); 86 + } else { 87 + // For third-party PDSes, use their own endpoint for token refresh 88 + console.log('[TOKEN REFRESH] Using third-party PDS\'s own endpoint for token refresh:', pdsEndpoint); 89 + // Keep authServer as the original PDS endpoint 84 90 } 85 91 86 92 // Endpoint for token refresh ··· 394 400 395 401 try { 396 402 // Try to refresh the token with enhanced error handling 397 - // Use bsky.social for token refresh with third-party PDS 403 + // Follow the same server selection logic as in refreshAccessToken 398 404 let refreshAuthServer = pdsEndpoint; 399 - if (!pdsEndpoint.includes('bsky.social')) { 400 - console.log('[AUTH CHECK] Using bsky.social for token refresh with third-party PDS'); 405 + 406 + // For bsky.network PDSes, use bsky.social 407 + if (pdsEndpoint.includes('bsky.network')) { 408 + console.log('[AUTH CHECK] Will use bsky.social for bsky.network PDS'); 401 409 refreshAuthServer = 'https://bsky.social'; 410 + } else if (pdsEndpoint.includes('bsky.social')) { 411 + // Already using bsky.social 412 + console.log('[AUTH CHECK] Will use bsky.social directly'); 413 + } else { 414 + // For third-party PDSes, use their own endpoint 415 + console.log('[AUTH CHECK] Will use third-party PDS\'s own endpoint:', pdsEndpoint); 416 + // Keep refreshAuthServer as the original PDS endpoint 402 417 } 403 418 404 419 const { accessToken: newAccessToken, refreshToken: newRefreshToken, dpopNonce: newNonce } = ··· 783 798 console.log('Authentication error (401), attempting token refresh...'); 784 799 785 800 try { 801 + // CRITICAL FIX: Follow the same server selection logic as in refreshAccessToken 802 + let refreshAuthServer = pdsEndpoint || 'https://bsky.social'; 803 + 804 + // For bsky.network PDSes, use bsky.social 805 + if (refreshAuthServer.includes('bsky.network')) { 806 + console.log('[CREATE STATUS] Using bsky.social for token refresh with bsky.network PDS'); 807 + refreshAuthServer = 'https://bsky.social'; 808 + } else if (refreshAuthServer.includes('bsky.social')) { 809 + // Already using bsky.social 810 + console.log('[CREATE STATUS] Using bsky.social directly for token refresh'); 811 + } else { 812 + // For third-party PDSes, use their own endpoint 813 + console.log('[CREATE STATUS] Using third-party PDS\'s own endpoint for token refresh:', refreshAuthServer); 814 + } 815 + 786 816 // Try to refresh the token 787 817 const { accessToken: newAccessToken, refreshToken: newRefreshToken, dpopNonce: newNonce } = 788 - await refreshAccessToken(refreshToken, keyPair, pdsEndpoint || 'https://bsky.social'); 818 + await refreshAccessToken(refreshToken, keyPair, refreshAuthServer); 789 819 790 820 // Update tokens in localStorage 791 821 if (typeof localStorage !== 'undefined') {