Mastodon up! @you@your.domain

#Test case:

Sign-in to your Mastodon instance. Search for @mxurbano@happyhobbit.dev. What result do you get?*

Double the fun.  Search for @urbanx@antoine.patraldo.com, another alias of mine. What result do you get?*

#Problem:

Say you want to explore different servers, switching instances as you see fit. Today, it’s Mastodon.Social. Tomorrow, it’s Something.Else.

You have your own website https://your.domain. You’re thinking, “I’ll scrape the web for all the places where my @mastodon.social handle appears. I’ll change @me@mastodon.social to @me@something.else.”

You could have had a V-8.  You could have used your domain as your permanent, #portable, #interoperable (?) mastodon handle, even though you haven’t set up your own personal Mastodon server.

#Solution:

You can add an endpoint to https://your.domain/.well-known/webfinger that points to your latest Mastodon instance. Follow this guide by @maartenballiauw@mastodon.online Your mileage may vary.

My experience was pretty much problem free. I reworked the #Sveltekit code for a couple of domains that I host on a Linux Ubuntu server on Google Cloud Platform. I came across a github issue that offered different ideas. The one that worked for me was the simplest. I added a dot folder under static/ and then created a blank file named ‘webfinger’ and then I put the json output of the GET command in the blank file. That was on my local development machine.

Here’s how I get the json:

$ curl https://mastodon.mexicanbold.com/.well-known/webfinger?resource=acct:mxurbano@mastodon.mexicanbold.com | python3 -mjson.tool

That outputs the following:

{
“subject”: “acct:mxurbano@mastodon.mexicanbold.com”,
“aliases”: [
“https://mastodon.mexicanbold.com/@mxurbano”,
“https://mastodon.mexicanbold.com/users/mxurbano”
],
“links”: [
{
“rel”: “http://webfinger.net/rel/profile-page”,
“type”: “text/html”,
“href”: “https://mastodon.mexicanbold.com/@mxurbano”
},
{
“rel”: “self”,
“type”: “application/activity+json”,
“href”: “https://mastodon.mexicanbold.com/users/mxurbano”
},
{
“rel”: “http://ostatus.org/schema/1.0/subscribe”,
“template”: “https://mastodon.mexicanbold.com/authorize_interaction?uri={uri}”
}
]
}

Copy and paste into the blank webfinger file (static/.well-known/webfinger). There’s nothing else in that file. I tried adding the output from a second account thinking I could add the json from an indefinite number of accounts, but if that’s even possible it didn’t work for me.

My process for updating a #Sveltekit web site is manual and somewhat tedious but not terribly laborious. Yes, it is toil and I should automate it. Most of my commands are in history and so I usually just use control-r in bash and find the right command. In svelte.config.js I use adapter-node. I self-host on Google Cloud Platform and use Nginx with upstream directives serving each site on a different port. I run PM2 process manager. I should do a post on my tedious-not-too-laborious-toil-nonetheless #sveltekit deployment process.

Once deployed, visit it and add .well-known/webfinger to your path and you should see some output. In Mastodon, search for your account using your new alias.  Now give your alias to any prospective mastodon user (any activitypub user?). Someone who searches for you in the Mastodon using @you@your.domain should get a result that matches the instance name that you’ve put in the webfinger file. When you change instances, simply rerun the curl command and swap the output and re-build and re-deploy.

So Mastodon UP! Roam wide and far, high and low, from now until … we go extinct.

* both times the result should be the same: @mxurbano@mastodon.mexicanbold.com The reason is that I put the same webfinger file in the .well-known folder for each of my domains, happyhobbit.dev/.well-known/webfinger and antoine.patraldo.com/.well-known/webfinger.

By Christophe R

#introduction. Just your typical run-of-the-mill privileged white gay married cisgender sexagenarian age-old vegetarian American-Quebec-Canadian-Mexican male computer programmer cum writer with an occasional sense of humor.

Leave a comment

Your email address will not be published. Required fields are marked *