diff options
Diffstat (limited to '89.md')
| -rw-r--r-- | 89.md | 131 |
1 files changed, 131 insertions, 0 deletions
| @@ -0,0 +1,131 @@ | |||
| 1 | NIP-89 | ||
| 2 | ====== | ||
| 3 | |||
| 4 | Recommended Application Handlers | ||
| 5 | -------------------------------- | ||
| 6 | |||
| 7 | `draft` `optional` | ||
| 8 | |||
| 9 | This NIP describes `kind:31989` and `kind:31990`: a way to discover applications that can handle unknown event-kinds. | ||
| 10 | |||
| 11 | ## Rationale | ||
| 12 | |||
| 13 | Nostr's discoverability and transparent event interaction is one of its most interesting/novel mechanics. | ||
| 14 | This NIP provides a simple way for clients to discover applications that handle events of a specific kind to ensure smooth cross-client and cross-kind interactions. | ||
| 15 | |||
| 16 | ### Parties involved | ||
| 17 | |||
| 18 | There are three actors to this workflow: | ||
| 19 | |||
| 20 | * application that handles a specific event kind (note that an application doesn't necessarily need to be a distinct entity and it could just be the same pubkey as user A) | ||
| 21 | * Publishes `kind:31990`, detailing how apps should redirect to it | ||
| 22 | * user A, who recommends an app that handles a specific event kind | ||
| 23 | * Publishes `kind:31989` | ||
| 24 | * user B, who seeks a recommendation for an app that handles a specific event kind | ||
| 25 | * Queries for `kind:31989` and, based on results, queries for `kind:31990` | ||
| 26 | |||
| 27 | ## Events | ||
| 28 | |||
| 29 | ### Recommendation event | ||
| 30 | ```json | ||
| 31 | { | ||
| 32 | "kind": 31989, | ||
| 33 | "pubkey": <recommender-user-pubkey>, | ||
| 34 | "tags": [ | ||
| 35 | ["d", <supported-event-kind>], | ||
| 36 | ["a", "31990:app1-pubkey:<d-identifier>", "wss://relay1", "ios"], | ||
| 37 | ["a", "31990:app2-pubkey:<d-identifier>", "wss://relay2", "web"] | ||
| 38 | ] | ||
| 39 | } | ||
| 40 | ``` | ||
| 41 | |||
| 42 | The `d` tag in `kind:31989` is the supported event kind this event is recommending. | ||
| 43 | |||
| 44 | Multiple `a` tags can appear on the same `kind:31989`. | ||
| 45 | |||
| 46 | The second value of the tag SHOULD be a relay hint. | ||
| 47 | The third value of the tag SHOULD be the platform where this recommendation might apply. | ||
| 48 | |||
| 49 | ## Handler information | ||
| 50 | ```json | ||
| 51 | { | ||
| 52 | "kind": 31990, | ||
| 53 | "pubkey": "<application-pubkey>", | ||
| 54 | "content": "<optional-kind:0-style-metadata>", | ||
| 55 | "tags": [ | ||
| 56 | ["d", <random-id>], | ||
| 57 | ["k", <supported-event-kind>], | ||
| 58 | ["web", "https://..../a/<bech32>", "nevent"], | ||
| 59 | ["web", "https://..../p/<bech32>", "nprofile"], | ||
| 60 | ["web", "https://..../e/<bech32>"], | ||
| 61 | ["ios", ".../<bech32>"] | ||
| 62 | ] | ||
| 63 | } | ||
| 64 | ``` | ||
| 65 | |||
| 66 | * `content` is an optional `metadata`-like stringified JSON object, as described in NIP-01. This content is useful when the pubkey creating the `kind:31990` is not an application. If `content` is empty, the `kind:0` of the pubkey should be used to display application information (e.g. name, picture, web, LUD16, etc.) | ||
| 67 | * `k` tags' value is the event kind that is supported by this `kind:31990`. | ||
| 68 | Using a `k` tag(s) (instead of having the kind of the `d` tag) provides: | ||
| 69 | * Multiple `k` tags can exist in the same event if the application supports more than one event kind and their handler URLs are the same. | ||
| 70 | * The same pubkey can have multiple events with different apps that handle the same event kind. | ||
| 71 | * `bech32` in a URL MUST be replaced by clients with the NIP-19-encoded entity that should be loaded by the application. | ||
| 72 | |||
| 73 | Multiple tags might be registered by the app, following NIP-19 nomenclature as the second value of the array. | ||
| 74 | |||
| 75 | A tag without a second value in the array SHOULD be considered a generic handler for any NIP-19 entity that is not handled by a different tag. | ||
| 76 | |||
| 77 | # Client tag | ||
| 78 | When publishing events, clients MAY include a `client` tag. Identifying the client that published the note. This tag is a tuple of `name`, `address` identifying a handler event and, a relay `hint` for finding the handler event. This has privacy implications for users, so clients SHOULD allow users to opt-out of using this tag. | ||
| 79 | |||
| 80 | ```json | ||
| 81 | { | ||
| 82 | "kind": 1, | ||
| 83 | "tags": [ | ||
| 84 | ["client", "My Client", "31990:app1-pubkey:<d-identifier>", "wss://relay1"] | ||
| 85 | ] | ||
| 86 | ... | ||
| 87 | } | ||
| 88 | ``` | ||
| 89 | |||
| 90 | ## User flow | ||
| 91 | A user A who uses a non-`kind:1`-centric nostr app could choose to announce/recommend a certain kind-handler application. | ||
| 92 | |||
| 93 | When user B sees an unknown event kind, e.g. in a social-media centric nostr client, the client would allow user B to interact with the unknown-kind event (e.g. tapping on it). | ||
| 94 | |||
| 95 | The client MIGHT query for the user's and the user's follows handler. | ||
| 96 | |||
| 97 | ## Example | ||
| 98 | |||
| 99 | ### User A recommends a `kind:31337`-handler | ||
| 100 | User A might be a user of Zapstr, a `kind:31337`-centric client (tracks). Using Zapstr, user A publishes an event recommending Zapstr as a `kind:31337`-handler. | ||
| 101 | |||
| 102 | ```json | ||
| 103 | { | ||
| 104 | "kind": 31989, | ||
| 105 | "tags": [ | ||
| 106 | ["d", "31337"], | ||
| 107 | ["a", "31990:1743058db7078661b94aaf4286429d97ee5257d14a86d6bfa54cb0482b876fb0:abcd", <relay-url>, "web"] | ||
| 108 | ], | ||
| 109 | ... | ||
| 110 | } | ||
| 111 | ``` | ||
| 112 | |||
| 113 | ### User B interacts with a `kind:31337`-handler | ||
| 114 | User B might see in their timeline an event referring to a `kind:31337` event (e.g. a `kind:1` tagging a `kind:31337`). | ||
| 115 | |||
| 116 | User B's client, not knowing how to handle a `kind:31337` might display the event using its `alt` tag (as described in NIP-31). When the user clicks on the event, the application queries for a handler for this `kind`: | ||
| 117 | |||
| 118 | ```json | ||
| 119 | ["REQ", <id>, { "kinds": [31989], "#d": ["31337"], "authors": [<user>, <users-contact-list>] }] | ||
| 120 | ``` | ||
| 121 | |||
| 122 | User B, who follows User A, sees that `kind:31989` event and fetches the `a`-tagged event for the app and handler information. | ||
| 123 | |||
| 124 | User B's client sees the application's `kind:31990` which includes the information to redirect the user to the relevant URL with the desired entity replaced in the URL. | ||
| 125 | |||
| 126 | ### Alternative query bypassing `kind:31989` | ||
| 127 | Alternatively, users might choose to query directly for `kind:31990` for an event kind. Clients SHOULD be careful doing this and use spam-prevention mechanisms or querying high-quality restricted relays to avoid directing users to malicious handlers. | ||
| 128 | |||
| 129 | ```json | ||
| 130 | ["REQ", <id>, { "kinds": [31990], "#k": [<desired-event-kind>], "authors": [...] }] | ||
| 131 | ``` | ||