Thinking through a “share with Mastodon” button that anyone could embed on a website. It’s a harder problem than a “share with Twitter” button, because there’s no one central host, and it would be ideal to avoid creating a central location to handle these requests. (Mastodon is decentralized, after all.)
As a bonus, I think it would work for indieweb or any other decentralized social platform. Maybe any social platform at all?
- User clicks button on page.
- JS on the page detects whether the
web+socialURI scheme has been registered (I wish this was easier, but you can do this by making an asynchronous request and waiting for it to succeed or fail).
- If it has, great! Just forward the user to that URI.
- If not, ask the user what the domain of their social profile is.
- JS (or a back-end server process) goes and fetches that base URL and looks for either a
microsharemetatag or an HTTP header of the form
Link: <. (Mastodon etc would need to support this endpoint and discovery of same.) ;; rel="microshare"
- If the endpoint exists, the browser opens a new tab and forwards the user to that URI with additional
urlURL string parameters populated with the name and the URL of the page being shared respectively.
- This new page contains a button to register the URI as the handler for the
web+socialURI scheme. It may also either prompt the user to log in, or, if they’re already logged in, share to that social platform, with the text and URL pre-filled into the form.
There are a few issues here that I’d like to iterate on: I wish URI scheme handling and detection was easier in a browser, for one. Secondly, there’s a potential phishing attack where a malicious website could show a fake login page and harvest someone’s login credentials.
I’m sure I’ve missed something important, but I wanted to kick this off as a first step. Let me know what you think!