this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #18 from aliceisjustplaying/main

authored by

Jesse J. Anderson and committed by
GitHub
192de8a5 d90863bd

+27 -6
+4
CHANGELOG.md
··· 9 9 10 10 ## [Unreleased] 11 11 12 + ### Added 13 + 14 + - Support for alternative HTTPS method for detecting DID 15 + 12 16 ## [1.2.0] - 2023-05-03 13 17 14 18 ### Added
+2 -1
README.md
··· 9 9 10 10 ![chrome_skyline_preview](https://user-images.githubusercontent.com/8367129/235382697-aedfda18-aab3-477b-b59c-c12cdd33bf9b.png) 11 11 12 - SkyLink works by detecting Decentralized Identifiers (DIDs) in a domain's TXT records and linking to the associated Bluesky profile. 12 + SkyLink works by detecting Decentralized Identifiers (DIDs) in a domain's TXT records as well as checking via the [alternative HTTPS method](https://psky.app/profile/emily.bsky.team/post/3juuaipn3q424) linking to the associated Bluesky profile. 13 13 14 14 When a profile is detected, the icon lights up blue and clicking it will take you to their profile. 15 15 ··· 22 22 **Contributors:** 23 23 24 24 [@danielhuckmann.com](https://staging.bsky.app/profile/danielhuckmann.com) - Firefox Support & Privacy Consent 25 + [@aliceisjustplaying](https://staging.bsky.app/profile/alice.bsky.sh) - HTTPS Method of DID Detection
+21 -5
content.js
··· 11 11 } 12 12 13 13 // Function to check for a DID in the domain's TXT records 14 - async function checkForDID(domain) { 14 + async function checkForDIDDNS(domain) { 15 15 // We use Google's DNS over HTTPS API to resolve the TXT record 16 16 const response = await fetch( 17 17 `https://dns.google/resolve?name=_atproto.${domain}&type=TXT` ··· 30 30 return didRecord ? didRecord.data.replace("did=", "") : null 31 31 } 32 32 33 + // Function to check for a DID in the well-known (not .well-known) location 34 + async function checkForDIDHTTPS(domain) { 35 + try { 36 + const response = await fetch( 37 + `https://${domain}/xrpc/com.atproto.identity.resolveHandle` 38 + ) 39 + const data = await response.json() 40 + return data.did 41 + } catch (error) { 42 + return null 43 + } 44 + } 45 + 33 46 // Main function to perform actions, but only if the privacy consent has been accepted 34 47 function performAction(privacyConsentAccepted) { 35 48 // If the user has accepted the privacy consent ··· 37 50 // We check for a DID on the current domain 38 51 ;(async function () { 39 52 const domain = getDomainName() 40 - const did = await checkForDID(domain) 53 + const domainDID = await checkForDIDDNS(domain) 54 + const httpsDID = await checkForDIDHTTPS(domain) 41 55 42 - if (did) { 43 - runtime.sendMessage({ type: "DID_FOUND", did }) 56 + if (domainDID) { 57 + runtime.sendMessage({ type: "DID_FOUND", did: domainDID }) 58 + } else if (httpsDID) { 59 + runtime.sendMessage({ type: "DID_FOUND", did: httpsDID }) 44 60 } else { 45 61 runtime.sendMessage({ type: "DID_NOT_FOUND" }) 46 62 } ··· 49 65 // We listen for messages from the background script 50 66 runtime.onMessage.addListener((message, sender, sendResponse) => { 51 67 if (message.type === "GET_DID") { 52 - checkForDID(getDomainName()) 68 + checkForDIDDNS(getDomainName()) 53 69 .then((did) => sendResponse({ did })) 54 70 .catch(() => sendResponse({ did: null })) 55 71 return true // Indicate that the response will be sent asynchronously.