From 5d29a8b1fc3167c6ec44420212a6f5e97857f5e6 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Mon, 7 Oct 2024 18:13:47 -0400 Subject: [PATCH] First version Push Notification API --- 97.md | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 97.md diff --git a/97.md b/97.md new file mode 100644 index 0000000..6edbf92 --- /dev/null +++ b/97.md @@ -0,0 +1,75 @@ +NIP-96 +====== + +Push Notification Server API +---------------------------- + +`draft` `optional` + +This NIP defines a common API to register push notification tokens into an event watcher server. The goal is to allow users to choose their push notification servers by simply adding an http address to their account. + +## Registration Call + +After receiving a `token` from the push system (Google Services, Unified Push, Apple Push Notification), clients should upload a list of signed NIP-98 events, one for each account in the device, in a `POST` to `/register` with the following body: + +```jsonc +{ + "events": [ + { + "id": "..", + "pubkey": "...", + "created_at": ..., + "kind": 22242, + "tags":[ + [ "relay","" ], + [ "relay","" ], + [ "challenge", ":" ] + ], + "content":"", + "sig":"..." + } + ] +} +``` + +where `system` is `google`, `apple` or `unifiedpush`. + +Servers will use the `system` information to select where to send new events from the relays marked as such. + +The server returns with an array of + +```jsonc + [ + { + "pubkey": "", + "result": "", + "error": "", + } + ] +``` + +Servers SHOULD accept multiple tokens per pubkey, but may limit the number of them. + +Servers SHOULD delete tokens after failure to deliver. + +## Sending Events + +Servers send new events via the user's preferred system. The event is [NIP-59 GiftWrapped](59.md) to the receiver, but no `p`-tag is added to the wrap event. In that way, the chosen system cannot know which key is receiving this event. + +Clients SHOULD try to decrypt the GiftWrap with all logged-in accounts. + +## Event Watcher Server list + +An Event Watcher Server list is a kind 10097 replaceable event meant to select one or more servers the user wants +to register for push notifications. Servers are listed as `server` tags: + +```json +{ + "kind": 10097, + "content": "", + "tags": [ + ["server", "https://push.amethyst.social"], + ["server", "https://server2.com"], + ] +} +```