Diagnostics for atproto PDS hosts, DIDs, and handles: https://debug.hose.cam

empty identifier, did input, watch pds

Changed files
+42 -11
+42 -11
index.html
··· 84 this.pds = null; 85 this.did = null; 86 this.handle = null; 87 - if (this.identifier.startsWith('https://')) { 88 this.pds = this.identifier; 89 } else { 90 if (this.identifier.startsWith('at://')) { ··· 92 } 93 if (this.identifier.startsWith('did:')) { 94 this.did = this.identifier; 95 } else { 96 this.handle = this.identifier; 97 let data; ··· 117 })); 118 119 Alpine.data('pdsCheck', pds => ({ 120 - loading: false, 121 error: null, 122 description: null, 123 124 async init() { 125 - this.loading = true; 126 this.error = null; 127 this.description = null; 128 let query = window.SimpleQuery(pds); ··· 136 console.error(e); 137 } 138 } 139 - this.loading = false; 140 - } 141 })); 142 143 Alpine.data('relayCheckHost', (pds, relay) => ({ ··· 148 reqCrawlError: null, 149 150 async init() { 151 - await this.check(); 152 }, 153 154 - async check() { 155 this.loading = true; 156 this.error = null; 157 this.status = null; ··· 176 this.reqCrawlError = null; 177 }, 178 179 - async requestCrawl() { 180 this.reqCrawlStatus = "loading"; 181 const proc = window.SimpleProc(`https://${relay.hostname}`); 182 const hostname = pds.split('://')[1]; ··· 281 <span x-text="pds"></span> 282 </h2> 283 284 - <div x-data="pdsCheck(pds)"> 285 <h3 class="text-lg"> 286 Server 287 <span ··· 289 class="badge badge-sm badge-soft badge-success" 290 >online</span> 291 </h3> 292 <template x-if="description !== null"> 293 <div class="overflow-x-auto"> 294 <table class="table table-xs"> ··· 311 <table class="table table-xs"> 312 <tbody> 313 <template x-for="relay in window.relays"> 314 - <tr x-data="relayCheckHost(pds, relay)"> 315 <td x-text="relay.name" class="text-sm"></td> 316 <td> 317 <template x-if="loading"> ··· 337 x-show="reqCrawlStatus !== 'done'" 338 class="btn btn-xs btn-ghost whitespace-nowrap" 339 :disabled="reqCrawlStatus === 'loading'" 340 - @click="requestCrawl" 341 > 342 request crawl 343 </button>
··· 84 this.pds = null; 85 this.did = null; 86 this.handle = null; 87 + this.identifier = this.identifier.trim(); 88 + if (this.identifier === '') { 89 + // do nothing 90 + } else if (this.identifier.startsWith('https://')) { 91 this.pds = this.identifier; 92 } else { 93 if (this.identifier.startsWith('at://')) { ··· 95 } 96 if (this.identifier.startsWith('did:')) { 97 this.did = this.identifier; 98 + let data; 99 + try { 100 + data = await window.slingshot('com.bad-example.identity.resolveMiniDoc', { 101 + params: { identifier: this.identifier }, 102 + }); 103 + this.pds = data.pds; 104 + this.handle = data.handle; 105 + } catch (e) { 106 + if (window.isXrpcErr(e)) { 107 + this.identifierError = e.error; 108 + if (e.message) this.description += ` ${e.description}`; 109 + } else { 110 + this.identifierError = 'Failed to resolve identifier, see console for error.'; 111 + console.error(e); 112 + } 113 + } 114 } else { 115 this.handle = this.identifier; 116 let data; ··· 136 })); 137 138 Alpine.data('pdsCheck', pds => ({ 139 + loadingDesc: false, 140 error: null, 141 description: null, 142 143 async init() { 144 + await this.update(pds); 145 + }, 146 + 147 + async update(pds) { 148 + this.loadingDesc = true; 149 this.error = null; 150 this.description = null; 151 let query = window.SimpleQuery(pds); ··· 159 console.error(e); 160 } 161 } 162 + this.loadingDesc = false; 163 + }, 164 })); 165 166 Alpine.data('relayCheckHost', (pds, relay) => ({ ··· 171 reqCrawlError: null, 172 173 async init() { 174 + await this.check(pds, relay); 175 }, 176 177 + async check(pds, relay) { 178 this.loading = true; 179 this.error = null; 180 this.status = null; ··· 199 this.reqCrawlError = null; 200 }, 201 202 + async requestCrawl(pds, relay) { 203 this.reqCrawlStatus = "loading"; 204 const proc = window.SimpleProc(`https://${relay.hostname}`); 205 const hostname = pds.split('://')[1]; ··· 304 <span x-text="pds"></span> 305 </h2> 306 307 + <div 308 + x-data="pdsCheck(pds)" 309 + x-init="$watch('pds', v => update(v))" 310 + > 311 <h3 class="text-lg"> 312 Server 313 <span ··· 315 class="badge badge-sm badge-soft badge-success" 316 >online</span> 317 </h3> 318 + <p x-show="loadingDesc">Loading&hellip;</p> 319 + <p x-show="error" class="text-warning" x-text="error"></p> 320 <template x-if="description !== null"> 321 <div class="overflow-x-auto"> 322 <table class="table table-xs"> ··· 339 <table class="table table-xs"> 340 <tbody> 341 <template x-for="relay in window.relays"> 342 + <tr 343 + x-data="relayCheckHost(pds, relay)" 344 + x-init="$watch('pds', pds => check(pds, relay))" 345 + > 346 <td x-text="relay.name" class="text-sm"></td> 347 <td> 348 <template x-if="loading"> ··· 368 x-show="reqCrawlStatus !== 'done'" 369 class="btn btn-xs btn-ghost whitespace-nowrap" 370 :disabled="reqCrawlStatus === 'loading'" 371 + @click="requestCrawl(pds, relay)" 372 > 373 request crawl 374 </button>