fix oauth plc

This commit is contained in:
2025-06-17 12:48:55 +09:00
parent 820e47f634
commit 74e1014e77
4 changed files with 7 additions and 18 deletions

View File

@@ -41,6 +41,7 @@ class AtprotoOAuthService {
this.oauthClient = await BrowserOAuthClient.load({
clientId: clientId,
handleResolver: 'https://bsky.social', // Default resolver
plcDirectoryUrl: 'https://plc.directory', // Default PLC directory
});
@@ -286,6 +287,7 @@ class AtprotoOAuthService {
this.oauthClient = await BrowserOAuthClient.load({
clientId: this.getClientId(),
handleResolver: pdsUrl,
plcDirectoryUrl: pdsUrl === 'https://syu.is' ? 'https://plc.syu.is' : 'https://plc.directory',
});
// OAuth client initialized
@@ -296,22 +298,8 @@ class AtprotoOAuthService {
try {
// Starting OAuth authorization
// Try to authorize with DID instead of handle for syu.is PDS only
let authTarget = handle;
if (pdsUrl === 'https://syu.is') {
try {
const resolveResponse = await fetch(`${pdsUrl}/xrpc/com.atproto.identity.resolveHandle?handle=${encodeURIComponent(handle)}`);
if (resolveResponse.ok) {
const resolveData = await resolveResponse.json();
authTarget = resolveData.did;
// Using DID for syu.is OAuth workaround
}
} catch (e) {
// Could not resolve to DID, using handle
}
}
const authUrl = await this.oauthClient.authorize(authTarget, {
// Use handle directly since PLC directory is now correctly configured
const authUrl = await this.oauthClient.authorize(handle, {
scope: 'atproto transition:generic',
});