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

lil labels shuffle

use atcute xrpc to call and tweak the ui a bit

Changed files
+92 -89
+92 -89
index.html
··· 33 }; 34 window.isXrpcErr = e => e instanceof ClientResponseError; 35 36 window.dnsResolver = new DohJsonHandleResolver({ 37 dohUrl: 'https://mozilla.cloudflare-dns.com/dns-query', 38 }); ··· 275 }); 276 this.status = data.status; 277 } catch(e) { 278 - if (relay.missingApis['com.atproto.sync.getHostStatus']) { 279 this.error = 'Can\'t check'; 280 - this.expectedErrorInfo = relay.missingApis['com.atproto.sync.getHostStatus']; 281 } else if (window.isXrpcErr(e)) { 282 this.error = e.error; 283 } else { ··· 456 params: { did }, 457 }); 458 } catch(e) { 459 - if (relay.missingApis['com.atproto.sync.getRepoStatus']) { 460 this.error = 'Can\'t check'; 461 - this.expectedErrorInfo = relay.missingApis['com.atproto.sync.getRepoStatus']; 462 } else if (window.isXrpcErr(e)) { 463 this.error = e.error; 464 } else { ··· 482 } 483 })); 484 485 Alpine.data('pdsHistory', (did, currentPds) => ({ 486 loading: false, 487 error: null, ··· 567 this.loading = false; 568 }, 569 })); 570 - 571 - Alpine.data('modLabels', (did) => ({ 572 - loading: false, 573 - error: null, 574 - labels: [], 575 - 576 - async init() { 577 - this.loading = true; 578 - this.error = null; 579 - this.labels = []; 580 - try { 581 - const res = await fetch(`https://mod.bsky.app/xrpc/com.atproto.label.queryLabels?uriPatterns=${did}`); 582 - if (res.ok) { 583 - const response = await res.json(); 584 - if (response.labels && response.labels.length > 0) { 585 - this.labels = response.labels; 586 - } 587 - } else { 588 - this.error = `${res.status}: ${await res.text()}`; 589 - } 590 - } catch (e) { 591 - this.error = 'failed to get labels from mod.bsky.app'; 592 - console.error(e); 593 - } 594 - this.loading = false; 595 - }, 596 - })); 597 }) 598 </script> 599 </head> ··· 974 </table> 975 </div> 976 977 <template x-if="did.startsWith('did:plc:')"> 978 <div x-data="pdsHistory(did, pds)"> 979 <h3 class="text-lg mt-3"> ··· 1040 </template> 1041 </tr> 1042 </template> 1043 - </tbody> 1044 - </table> 1045 - </div> 1046 - </div> 1047 - </template> 1048 - 1049 - <template x-if="did != null"> 1050 - <div x-data="modLabels(did)"> 1051 - <h3 class="text-lg mt-3"> 1052 - Labels from Bluesky (mod.bsky.app) 1053 - </h3> 1054 - <div class="overflow-x-auto"> 1055 - <table class="table table-xs"> 1056 - <template x-if="!loading && !error && labels.length !== 0"> 1057 - <thead> 1058 - <tr> 1059 - <th>created</th> 1060 - <th>exp</th> 1061 - <th>label</th> 1062 - </tr> 1063 - </thead> 1064 - </template> 1065 - <tbody> 1066 - <template x-if="loading"> 1067 - <tr> 1068 - <td>Loading&hellip;</td> 1069 - </tr> 1070 - </template> 1071 - <template x-if="error"> 1072 - <tr> 1073 - <td>Error: <span x-text="error"></span></td> 1074 - </tr> 1075 - </template> 1076 - <template x-if="!loading && !error && labels.length === 0"> 1077 - <tr> 1078 - <td class="text-sm"> 1079 - <em>no labels applied by mod.bsky.app</em> 1080 - </td> 1081 - </tr> 1082 - </template> 1083 - <template x-for="label in labels"> 1084 - <tr> 1085 - <td> 1086 - <code x-text="label.cts.split('.')[0]"></code> 1087 - </td> 1088 - <td> 1089 - <code x-text="label.exp.split('.')[0]"></code> 1090 - </td> 1091 - 1092 - <td> 1093 - <span 1094 - x-text="label.val" 1095 - class="badge badge-sm badge-soft badge-warning" 1096 - ></span> 1097 - </td> 1098 - 1099 - </tr> 1100 - </template> 1101 </tbody> 1102 </table> 1103 </div>
··· 33 }; 34 window.isXrpcErr = e => e instanceof ClientResponseError; 35 36 + window.isBeforeNow = iso => new Date(iso) < new Date(); 37 + 38 window.dnsResolver = new DohJsonHandleResolver({ 39 dohUrl: 'https://mozilla.cloudflare-dns.com/dns-query', 40 }); ··· 277 }); 278 this.status = data.status; 279 } catch(e) { 280 + if (relay.missingApis?.['com.atproto.sync.getHostStatus']) { 281 this.error = 'Can\'t check'; 282 + this.expectedErrorInfo = relay.missingApis?.['com.atproto.sync.getHostStatus']; 283 } else if (window.isXrpcErr(e)) { 284 this.error = e.error; 285 } else { ··· 458 params: { did }, 459 }); 460 } catch(e) { 461 + if (relay.missingApis?.['com.atproto.sync.getRepoStatus']) { 462 this.error = 'Can\'t check'; 463 + this.expectedErrorInfo = relay.missingApis?.['com.atproto.sync.getRepoStatus']; 464 } else if (window.isXrpcErr(e)) { 465 this.error = e.error; 466 } else { ··· 484 } 485 })); 486 487 + Alpine.data('modLabels', did => ({ 488 + loading: false, 489 + error: null, 490 + labels: [], 491 + 492 + async init() { 493 + this.loading = true; 494 + this.error = null; 495 + this.labels = []; 496 + 497 + const query = window.SimpleQuery('https://mod.bsky.app'); 498 + 499 + try { 500 + const res = await query('com.atproto.label.queryLabels', { 501 + params: { uriPatterns: [did] }, 502 + }); 503 + this.labels = res.labels ?? []; 504 + // TODO: handle cursors? 505 + } catch (e) { 506 + if (window.isXrpcErr(e)) { 507 + this.error = e.error; 508 + } else { 509 + this.error = 'Failed to check (see console)'; 510 + console.error(e); 511 + } 512 + } 513 + this.loading = false; 514 + }, 515 + })); 516 + 517 Alpine.data('pdsHistory', (did, currentPds) => ({ 518 loading: false, 519 error: null, ··· 599 this.loading = false; 600 }, 601 })); 602 }) 603 </script> 604 </head> ··· 979 </table> 980 </div> 981 982 + <div x-data="modLabels(did)"> 983 + <h3 class="text-lg mt-3"> 984 + Labels 985 + </h3> 986 + <div class="overflow-x-auto"> 987 + <table class="table table-xs"> 988 + <tbody> 989 + <template x-if="loading"> 990 + <tr> 991 + <td>Loading&hellip;</td> 992 + </tr> 993 + </template> 994 + <template x-if="error"> 995 + <tr> 996 + <td>Error: <span x-text="error"></span></td> 997 + </tr> 998 + </template> 999 + <template x-if="!loading && !error && labels.length === 0"> 1000 + <tr> 1001 + <td class="text-sm"> 1002 + <em>no labels applied by mod.bsky.app</em> 1003 + </td> 1004 + </tr> 1005 + </template> 1006 + <template x-for="label in labels"> 1007 + <template x-if="!!label"> 1008 + <tr x-data="{ expired: isBeforeNow(label.exp) }"> 1009 + <td> 1010 + <code 1011 + x-text="label.cts.split('T')[0]" 1012 + :title="label.cts" 1013 + ></code> 1014 + </td> 1015 + <td> 1016 + <span x-text="expired ? 'expired' : 'expires'"></span> 1017 + <code 1018 + x-text="label.exp.split('T')[0]" 1019 + :title="label.exp" 1020 + ></code> 1021 + </td> 1022 + <td> 1023 + <code 1024 + x-text="label.val" 1025 + class="badge badge-sm badge-soft" 1026 + :class="expired ? 'badge-neutral line-through' : 'badge-warning'" 1027 + :title="expired ? 'Label expired' : ''" 1028 + ></code> 1029 + </td> 1030 + </tr> 1031 + </template> 1032 + </template> 1033 + </tbody> 1034 + </table> 1035 + </div> 1036 + </div> 1037 + 1038 <template x-if="did.startsWith('did:plc:')"> 1039 <div x-data="pdsHistory(did, pds)"> 1040 <h3 class="text-lg mt-3"> ··· 1101 </template> 1102 </tr> 1103 </template> 1104 </tbody> 1105 </table> 1106 </div>