this repo has no description
0
fork

Configure Feed

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

Show the PDS

orta 24ee21ec 625781b0

+46 -16
+46 -16
apps/keytrace.dev/components/developers/VerificationProcess.vue
··· 135 135 result: VerificationResult; 136 136 }>(); 137 137 138 - // Extract PDS URL from the first claim's sig.src if available 139 - const pdsUrl = computed(() => { 140 - if (props.result.claims.length > 0 && props.result.claims[0].claim.sig?.src) { 141 - try { 142 - // Parse AT URI: at://did:plc:xxx/collection/rkey 143 - const atUri = props.result.claims[0].claim.sig.src; 144 - const parts = atUri.replace("at://", "").split("/"); 145 - const did = parts[0]; 146 - // We don't have the actual PDS URL in the result, so we show a placeholder 147 - // In reality, the verify package resolves this internally 148 - if (did.startsWith("did:plc:")) { 149 - return "https://bsky.social (or user's PDS)"; 138 + const pdsUrl = ref<string>("Resolving..."); 139 + 140 + // Resolve the PDS URL from the PLC directory 141 + async function resolvePds() { 142 + const did = props.result.did; 143 + if (!did) { 144 + pdsUrl.value = "Unknown"; 145 + return; 146 + } 147 + 148 + try { 149 + if (did.startsWith("did:plc:")) { 150 + const response = await fetch(`https://plc.directory/${did}`); 151 + if (response.ok) { 152 + const didDoc = await response.json(); 153 + const pdsService = didDoc.service?.find( 154 + (s: { id: string; type: string }) => s.id === "#atproto_pds" || s.type === "AtprotoPersonalDataServer" 155 + ); 156 + if (pdsService?.serviceEndpoint) { 157 + pdsUrl.value = pdsService.serviceEndpoint; 158 + return; 159 + } 160 + } 161 + } else if (did.startsWith("did:web:")) { 162 + const host = did.replace("did:web:", "").replaceAll(":", "/"); 163 + const response = await fetch(`https://${host}/.well-known/did.json`); 164 + if (response.ok) { 165 + const didDoc = await response.json(); 166 + const pdsService = didDoc.service?.find( 167 + (s: { id: string; type: string }) => s.id === "#atproto_pds" || s.type === "AtprotoPersonalDataServer" 168 + ); 169 + if (pdsService?.serviceEndpoint) { 170 + pdsUrl.value = pdsService.serviceEndpoint; 171 + return; 172 + } 150 173 } 151 - return "Resolved from DID document"; 152 - } catch { 153 - return "Resolved from DID document"; 154 174 } 175 + pdsUrl.value = "https://bsky.social"; 176 + } catch { 177 + pdsUrl.value = "https://bsky.social"; 155 178 } 156 - return "Resolved from DID document"; 179 + } 180 + 181 + onMounted(() => { 182 + resolvePds(); 183 + }); 184 + 185 + watch(() => props.result.did, () => { 186 + resolvePds(); 157 187 }); 158 188 </script>