fix oauth package name
This commit is contained in:
36
oauth/src/utils/pds.js
Normal file
36
oauth/src/utils/pds.js
Normal file
@ -0,0 +1,36 @@
|
||||
import { env } from '../config/env.js'
|
||||
|
||||
// PDS判定からAPI設定を取得
|
||||
export function getApiConfig(pds) {
|
||||
if (pds.includes(env.pds)) {
|
||||
return {
|
||||
pds: `https://${env.pds}`,
|
||||
bsky: `https://bsky.${env.pds}`,
|
||||
plc: `https://plc.${env.pds}`,
|
||||
web: `https://web.${env.pds}`
|
||||
}
|
||||
}
|
||||
return {
|
||||
pds: pds.startsWith('http') ? pds : `https://${pds}`,
|
||||
bsky: 'https://public.api.bsky.app',
|
||||
plc: 'https://plc.directory',
|
||||
web: 'https://bsky.app'
|
||||
}
|
||||
}
|
||||
|
||||
// handleがsyu.is系かどうか判定
|
||||
export function isSyuIsHandle(handle) {
|
||||
return env.handleList.includes(handle) || handle.endsWith(`.${env.pds}`)
|
||||
}
|
||||
|
||||
// handleからPDS取得
|
||||
export async function getPdsFromHandle(handle) {
|
||||
const initialPds = isSyuIsHandle(handle)
|
||||
? `https://${env.pds}`
|
||||
: 'https://bsky.social'
|
||||
|
||||
const data = await fetch(`${initialPds}/xrpc/com.atproto.repo.describeRepo?repo=${handle}`)
|
||||
.then(res => res.json())
|
||||
|
||||
return data.didDoc?.service?.[0]?.serviceEndpoint || initialPds
|
||||
}
|
Reference in New Issue
Block a user