-
@ yunginter.net
2023-07-22 22:18:17WHAT IS NOSTR ADDRESS
Nostr Address = NIP 05 identifier NIP = a Nostr Implementation Possible
“Mapping Nostr keys to DNS-based internet identifiers”
it Maps your PubKey to URLYou should first read the actual NIP 05 spec, hopefully the following can make sense of that for end users.
a Nostr Address is how you create a readable unique handle. anyone can be @dave and there can be multiple @dave's on nostr, only one person can be dave@dave.com
In some cases, it’s an added layer of verification. If your Nostr Address ID is @stephenasmith@espn.com that’s a pretty strong indicator that this is the real Stephen A Smith, the only way to accomplish this is to have access to edit espn.com.
Personally, I use a similar handle across the web, and wanted to vanity my nip in the same fashion, just like on legacy new media, I am the only one who will have this name.
My philosophy here is, you own your own private key for NOSTR, so why have an address that’s a po box?
If you aren’t ready to pay for a domain or hosting, github offers you the chance to learn how to do this without spending money. BenGWeeks has written this guide Using GitHub Pages for NIP-05 Identifiers.
This results in his nostr address being Ben@BenGWeeks.github.io This is a great free way to set up a nostr address if you are ok with having github.io in your identifier. (Don’t miss steps 3-6 in his guide, you have to Deploy it as Static HTML.)
There is nothing wrong with supporting a NIP 05 provider services, or choosing someone kind enough to add you to theirs for free. This might serve your purposes just fine. Since we are all here learning this new protocol, I think it’s nice to learn or revisit publishing with the Hypertext Transfer Protocol (HTTP).
LET’S GET STARTED
You are going to create a webpage with a file path that looks like this: https://example.com/.well-known/nostr.json https://bengweeks.gihub.io/.well-known/nostr.json
STEP 1: Create /.well-know/nostr.json/
on github:
add file > create new file > name it /.well-know/nostr.json/ this will create both a folder and a file named nostr.json
on a self hosted server:
your hosting provider most likely has a file editor that can accomplish creating folders and files and provides a text editor. If you did this on github first, you can download these files and upload them to your new host.
Copy the following to the newly create nostr.json file
{ "names": { "bob": "b0635d6a9851d3aed0cd6c495b282167acf761729078d975fc341b22650b07b9" } }
Replace “bob” with your name and replace the long string of characters with the hex version of your pubkey (convert your npub key at damus.io/key)
DOMAIN AS AN IDENTIFIER
My username is yunginternet and my domain is yunginter.net and I wanted my Nostr Address to be @yunginter.net not zach@yunginter.net so you replace the name with an underscore.
My nostr.json file looks like:
{ "names": { "_": "5fd693e61a7969ecf5c11dbf5ce20aedac1cea71721755b037955994bf6061bb" } }
This results in my Nostr Address identifier being: _@yunginter.net
When I go to metadata.nostr.com/ or another client that allows me to edit my Nostr Address (they might still call it NIP 05 identifer) I will enter: _@yunginter.net
However, one should “expect Nostr clients to show and treat that as just @yunginter.net for all purposes.”
I like this because as on legacy new media, it just has one at sign in the identifier, instead of users having to type @bob@bob.com which looks like an email, both to human readers and operating systems, not a handle like @yunginter.net
STEP 2: CORS
You have to turn on CORS for your site. CORS stands for Cross-Origin Resource Sharing. This makes the json “get”-able.
CORS ON GITHUB PAGES
If you are following this tutorial from ben, Github.io pages have CORS enabled by default.
CORS ON A SELF-HOSTED WEBSITE
I tried to set up github with a custom domain pointing at github, and that seemed to not pass the allow access file. I still wanted my custom domain so I went to move my github page to a hosting provider.
In addition to registering a domain, you will also have to rent or set up web hosting, and maintain an SSL cert.
Fundamentally you need to add this to a .htaccess file: I didn’t have a .htaccess file, so my hosting provider had me create one in their file browser in the root directory of my site.
Header set Access-Control-Allow-Origin "*"
It needs to be formatted based on the type of web server.
It’s easier to just ask your hosting provider “how do i properly add CORS to a .htaccess file” than to figure out how their server software wants it formatted. You can search their documentation or simply reach out to their customer support.
How this is formatted depends on the type of web server software your hosting provider is running, mine suggested i do it like the following because they are running apache:
<IfModule mod_headers.c> Header set Access-Control-Allow-Origin "*" </IfModule>
But yours might suggest you do it like the following because they are running jetty:
This is why it’s just easier to reach out to them.
<filter> <filter-name>cross-origin</filter-name> <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class> </filter> <filter-mapping> <filter-name>cross-origin</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
Once you save your .htaccess file you should be good to go.
STEP 3: UPDATE METADATA
Visit your https://example.com/.well-known/nostr.json page If you see this CORS json viewer like on this page you are all set.
Head to a client that allows you to input your Nostr Address (NIP 05 identifier) in your profile and you’re all set.