···1111}
12121313// Function to check for a DID in the domain's TXT records
1414-async function checkForDID(domain) {
1414+async function checkForDIDDNS(domain) {
1515 // We use Google's DNS over HTTPS API to resolve the TXT record
1616 const response = await fetch(
1717 `https://dns.google/resolve?name=_atproto.${domain}&type=TXT`
···3030 return didRecord ? didRecord.data.replace("did=", "") : null
3131}
32323333+// Function to check for a DID in the well-known (not .well-known) location
3434+async function checkForDIDHTTPS(domain) {
3535+ const response = await fetch(
3636+ `https://${domain}/xrpc/com.atproto.identity.resolveHandle`
3737+ )
3838+3939+ if (response.status === 200) {
4040+ try {
4141+ const data = await response.json()
4242+ return data.did
4343+ } catch (error) {
4444+ return null
4545+ }
4646+ }
4747+4848+ return null
4949+}
5050+3351// Main function to perform actions, but only if the privacy consent has been accepted
3452function performAction(privacyConsentAccepted) {
3553 // If the user has accepted the privacy consent
···3755 // We check for a DID on the current domain
3856 ;(async function () {
3957 const domain = getDomainName()
4040- const did = await checkForDID(domain)
5858+ const domainDID = await checkForDIDDNS(domain)
5959+ const httpsDID = await checkForDIDHTTPS(domain)
41604242- if (did) {
4343- runtime.sendMessage({ type: "DID_FOUND", did })
6161+ if (domainDID) {
6262+ runtime.sendMessage({ type: "DID_FOUND", did: domainDID })
6363+ } else if (httpsDID) {
6464+ runtime.sendMessage({ type: "DID_FOUND", did: httpsDID })
4465 } else {
4566 runtime.sendMessage({ type: "DID_NOT_FOUND" })
4667 }
···4970 // We listen for messages from the background script
5071 runtime.onMessage.addListener((message, sender, sendResponse) => {
5172 if (message.type === "GET_DID") {
5252- checkForDID(getDomainName())
7373+ checkForDIDDNS(getDomainName())
5374 .then((did) => sendResponse({ did }))
5475 .catch(() => sendResponse({ did: null }))
5576 return true // Indicate that the response will be sent asynchronously.