diff options
| author | Pablo Fernandez <p@f7z.io> | 2023-06-08 22:32:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-08 22:32:17 +0200 |
| commit | 6baacf6fb1badf3ba2480a88519e357b3cbdaaac (patch) | |
| tree | b3d211bc3683b340d678c3574519f327e7b3858e /89.md | |
| parent | 964bc5b5ce946ab66aae945084549f26ffdef70f (diff) | |
| parent | 14a887d43b654f41de5d271e27ef69048f183fb4 (diff) | |
Merge branch 'master' into nip31
Diffstat (limited to '89.md')
| -rw-r--r-- | 89.md | 116 |
1 files changed, 116 insertions, 0 deletions
| @@ -0,0 +1,116 @@ | |||
| 1 | NIP-89 | ||
| 2 | ====== | ||
| 3 | |||
| 4 | Recommended Application Handlers | ||
| 5 | -------------------------------- | ||
| 6 | |||
| 7 | `draft` `optional` `author:pablof7z` | ||
| 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 | Nostr's discoverability and transparent event interaction is one of its most interesting/novel mechanics. | ||
| 13 | 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. | ||
| 14 | |||
| 15 | ### Parties involved | ||
| 16 | There are three actors to this workflow: | ||
| 17 | |||
| 18 | * 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) | ||
| 19 | * Publishes `kind:31990`, detailing how apps should redirect to it | ||
| 20 | * user A, who recommends an app that handles a specific event kind | ||
| 21 | * Publishes `kind:31989` | ||
| 22 | * user B, who seeks a recommendation for an app that handles a specific event kind | ||
| 23 | * Queries for `kind:31989` and, based on results, queries for `kind:31990` | ||
| 24 | |||
| 25 | # Events | ||
| 26 | |||
| 27 | ## Recommendation event | ||
| 28 | ```json | ||
| 29 | { | ||
| 30 | "kind": 31989, | ||
| 31 | "pubkey": <recommender-user-pubkey>, | ||
| 32 | "tags": [ | ||
| 33 | [ "d", <supported-event-kind> ], | ||
| 34 | [ "a", "31990:app1-pubkey:<d-identifier>", "wss://relay1", "ios" ], | ||
| 35 | [ "a", "31990:app2-pubkey:<d-identifier>", "wss://relay2", "web" ] | ||
| 36 | ] | ||
| 37 | } | ||
| 38 | ``` | ||
| 39 | |||
| 40 | The `d` tag in `kind:31989` is the supported event kind this event is recommending. | ||
| 41 | |||
| 42 | Multiple `a` tags can appear on the same `kind:31989`. | ||
| 43 | |||
| 44 | The second value of the tag SHOULD be a relay hint. | ||
| 45 | The third value of the tag SHOULD be the platform where this recommendation might apply. | ||
| 46 | |||
| 47 | ## Handler information | ||
| 48 | ```json | ||
| 49 | { | ||
| 50 | "kind": 31990, | ||
| 51 | "pubkey": <pubkey>, | ||
| 52 | "content": "<optional-kind:0-style-metadata>", | ||
| 53 | "tags": [ | ||
| 54 | [ "d", <random-id> ], | ||
| 55 | [ "k", <supported-event-kind> ], | ||
| 56 | [ "web", "https://..../a/<bech32>", "nevent" ], | ||
| 57 | [ "web", "https://..../p/<bech32>", "nprofile" ], | ||
| 58 | [ "web", "https://..../e/<bech32>" ], | ||
| 59 | [ "ios", ".../<bech32>" ] | ||
| 60 | ] | ||
| 61 | } | ||
| 62 | ``` | ||
| 63 | |||
| 64 | * `content` is an optional `set_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.) | ||
| 65 | |||
| 66 | * `k` tags' value is the event kind that is supported by this `kind:31990`. | ||
| 67 | Using a `k` tag(s) (instead of having the kind onf the NIP-33 `d` tag) provides: | ||
| 68 | * 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. | ||
| 69 | * The same pubkey can have multiple events with different apps that handle the same event kind. | ||
| 70 | |||
| 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 | # User flow | ||
| 78 | A user A who uses a non-`kind:1`-centric nostr app could choose to announce/recommend a certain kind-handler application. | ||
| 79 | |||
| 80 | 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). | ||
| 81 | |||
| 82 | The client MIGHT query for the user's and the user's follows handler. | ||
| 83 | |||
| 84 | # Example | ||
| 85 | |||
| 86 | ## User A recommends a `kind:31337`-handler | ||
| 87 | 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. | ||
| 88 | |||
| 89 | ```json | ||
| 90 | { | ||
| 91 | "kind": 31989, | ||
| 92 | "tags": [ | ||
| 93 | [ "d", "31337" ], | ||
| 94 | [ "a", "31990:1743058db7078661b94aaf4286429d97ee5257d14a86d6bfa54cb0482b876fb0:abcd", <relay-url>, "web" ] | ||
| 95 | ] | ||
| 96 | } | ||
| 97 | ``` | ||
| 98 | |||
| 99 | ## User B interacts with a `kind:31337`-handler | ||
| 100 | User B might see in their timeline an event referring to a `kind:31337` event | ||
| 101 | (e.g. a `kind:1` tagging a `kind:31337`). | ||
| 102 | |||
| 103 | User B's client, not knowing how to handle a `kind:31337` might display the event | ||
| 104 | using its `alt` tag (as described in NIP-31). When the user clicks on the event, | ||
| 105 | the application queries for a handler for this `kind`: | ||
| 106 | |||
| 107 | `["REQ", <id>, '[{ "kinds": [31989], "#d": ["31337"], 'authors': [<user>, <users-contact-list>] }]']` | ||
| 108 | |||
| 109 | User B, who follows User A, sees that `kind:31989` event and fetches the `a`-tagged event for the app and handler information. | ||
| 110 | |||
| 111 | 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. | ||
| 112 | |||
| 113 | ## Alternative query bypassing `kind:31989` | ||
| 114 | 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 to avoid directing users to malicious handlers. | ||
| 115 | |||
| 116 | `["REQ", <id>, '[{ "kinds": [31990], "#k": [<desired-event-kind>], 'authors': [...] }]']` \ No newline at end of file | ||