···7788## [Unreleased]
991010+## [1.1.0] - 2023-05-03
1111+1212+- use DID for profile url instead of domain name
1313+1014## [1.0.1] - 2023-04-30
11151216### Fixed
···44}
5566async function checkForDID(domain) {
77+ // We use Google's DNS over HTTPS API to resolve the TXT record
78 const response = await fetch(
89 `https://dns.google/resolve?name=_atproto.${domain}&type=TXT`
910 )
1011 const data = await response.json()
1212+1313+ // We use the TXT record type to avoid CORS issues
1114 const records = data?.Answer?.filter((record) => record.type === 16) || []
1212- return records.some((record) => record.data.includes("did=did:plc:"))
1515+1616+ // We filter out all records that are not TXT records
1717+ const didRecord = records.find((record) =>
1818+ record.data.includes("did=did:plc:")
1919+ )
2020+2121+ // We return the DID if we found one
2222+ return didRecord ? didRecord.data.replace("did=", "") : null
1323}
14242525+// We check for a DID on the current domain
1526;(async function () {
1627 const domain = getDomainName()
1717- const didFound = await checkForDID(domain)
2828+ const did = await checkForDID(domain)
18291919- if (didFound) {
2020- chrome.runtime.sendMessage({ type: "DID_FOUND" })
3030+ if (did) {
3131+ chrome.runtime.sendMessage({ type: "DID_FOUND", did })
2132 } else {
2233 chrome.runtime.sendMessage({ type: "DID_NOT_FOUND" })
2334 }
2435})()
25363737+// We listen for messages from the background script
2638chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
2727- if (message.type === "GET_DOMAIN") {
2828- sendResponse({ domain: getDomainName() })
3939+ if (message.type === "GET_DID") {
4040+ checkForDID(getDomainName())
4141+ .then((did) => sendResponse({ did }))
4242+ .catch(() => sendResponse({ did: null }))
4343+ return true // Indicate that the response will be sent asynchronously.
2944 }
3045})