upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/05.md
diff options
context:
space:
mode:
Diffstat (limited to '05.md')
-rw-r--r--05.md52
1 files changed, 52 insertions, 0 deletions
diff --git a/05.md b/05.md
new file mode 100644
index 0000000..a006ac1
--- /dev/null
+++ b/05.md
@@ -0,0 +1,52 @@
1NIP-05
2======
3
4Mapping Nostr keys to DNS-based internet identifiers
5----------------------------------------------------
6
7`draft` `optional` `author:fiatjaf`
8
9On events of type `0` (`set_metadata`) one can specify the key `"nip05"` with an [internet identifier](https://datatracker.ietf.org/doc/html/rfc5322#section-3.4.1) (an email-like address) as the value. Although there is a link to a very liberal "internet identifier" specification above, NIP-05 assumes the `<local-part>` part will be restricted to the characters `a-z0-9-_.`, case insensitive.
10
11Upon seeing that, the client splits the identifier into `<local-part>` and `<domain>` and use these values to make a GET request to `https://<domain>/.well-known/nostr.json?name=<local-part>`.
12
13The result should be a JSON document object with a key `"names"` that should then be a mapping of names to public keys. If the public key for the given `<name>` matches the `pubkey` from the `set_metadata` event, the client then concludes that the given pubkey can indeed be referenced by its identifier.
14
15### Example
16
17If a client sees an event like this:
18
19```json
20{
21 "pubkey": "b0635d6a9851d3aed0cd6c495b282167acf761729078d975fc341b22650b07b9",
22 "kind": 0,
23 "content": "{\"name\": \"bob\", \"nip05\": \"bob@example.com\"}"
24 ...
25}
26```
27
28It will make a GET request to `https://example.com/.well-known/nostr.json?name=bob` and get back a response that will look like
29
30```json
31{
32 "names": {
33 "bob": "b0635d6a9851d3aed0cd6c495b282167acf761729078d975fc341b22650b07b9"
34 }
35}
36```
37
38That will mean everything is alright.
39
40## Notes
41
42### User Discovery implementation suggestion
43
44A client can also use this to allow users to search other profiles. If a client has a search box or something like that, a user may be able to type "bob@example.com" there and the client would recognize that and do the proper queries to obtain a pubkey and suggest that to the user.
45
46### Showing just the domain as an identifier
47
48Clients may treat the identifier `_@domain` as the "root" identifier, and choose to display it as just the `<domain>`. For example, if Bob owns `bob.com`, he may not want an identifier like `bob@bob.com` as that is redundant. Instead Bob can use the identifier `_@bob.com` and expect Nostr clients to show and treat that as just `bob.com` for all purposes.
49
50### Reasoning for the `/.well-known/nostr.json?name=<local-part>` format
51
52By adding the `<local-part>` as a query string instead of as part of the path the protocol can support both dynamic servers that can generate JSON on-demand and static servers with a JSON file in it that may contain multiple names.