26 lines
746 B
JavaScript
26 lines
746 B
JavaScript
|
(async () => {
|
||
|
const status = document.querySelector('.js-status');
|
||
|
status.textContent = 'Looking up DID...';
|
||
|
|
||
|
let did = null;
|
||
|
|
||
|
try {
|
||
|
const response = await fetch(`${location.protocol}//${BSKY_HANDLE}/.well-known/atproto-did`);
|
||
|
did = await response.text();
|
||
|
} catch(ex) {
|
||
|
status.style.color = 'red';
|
||
|
status.textContent = `Could not find DID! ${ex}`;
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if(typeof did !== 'string' || !did.startsWith('did:')) {
|
||
|
status.style.color = 'red';
|
||
|
status.textContent = 'Look up result was not a valid DID.';
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
const url = BSKY_FORMAT.replace('%s', did);
|
||
|
status.textContent = `Redirecting to ${url}...`;
|
||
|
location.replace(url);
|
||
|
})();
|