Skip to content

Commit 2c47af9

Browse files
author
Jon Staab
committed
Add NIP 9a for push notifications
1 parent f461065 commit 2c47af9

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

9a.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
NIP-9a
2+
======
3+
4+
Nostr Push Notifications
5+
------------------------
6+
7+
`draft` `optional`
8+
9+
This NIP defines a way for users to register with relays to facilitate push notifications.
10+
11+
Relays that implement this NIP MUST include `9a` in its [NIP 11](11.md) `supported_nips`, and MUST NOT serve `kind 10390` events to anyone except their author.
12+
13+
To register, users may create a `kind 10390` event with their notification preferences. This event MUST include the following tags:
14+
15+
- `p` - the relay's [NIP 11](11.md) `self` pubkey
16+
17+
All other tags MUST be encrypted and placed in the event's `content` field:
18+
19+
- `relay` - the normalized url of the relay the event was sent to
20+
- `filter` - a nostr filter for matching events (may appear multiple times)
21+
- `server` - a URL indicating a push server to forward events to
22+
- `vapid_endpoint` - a VAPID push notification endpoint (web push only)
23+
- `vapid_p256dh` - a VAPID p256dh key (web push only)
24+
- `vapid_auth` - a VAPID auth key (web push only)
25+
- `fcm_token` - a Firebase Cloud Messaging token (android only)
26+
- `apns_token` - an APNs token (ios only)
27+
- `ios_bundle_identifier` - a iOS app bundle identifier (ios only)
28+
- `silent` - whether silent push notifications should be used
29+
30+
If a relay does not intend to fulfill the subscription, it SHOULD respond with an `OK` message with `false` as the result and a human-readable message.
31+
32+
When a relay receives a new event, it SHOULD match it against all current registrations and forward the event to authorized users by sending an HTTP `POST` request to the `server` URL with `Content-Type: application/json`. The payload should be as follows:
33+
34+
```typescript
35+
{
36+
event: Event // The signed nostr event
37+
config: string[][] // The private tags provided by the user to the relay
38+
}
39+
```
40+
41+
If a relay receives a `kind 10390` event not p-tagged to itself, it SHOULD NOT store it. If a relay receives a `kind 10390` event whose `relay` tag does not match the relay's own URL, the relay SHOULD discard it. However, special purpose relays MAY choose to implement this behavior on behalf of other relays that do not support this NIP.
42+
43+
Relays SHOULD delete subscription events after 30 days. Clients MAY re-publish subscription events periodically if they wish to continue receiving push notifications. Clients MAY delete subscription events as specified in [NIP 09](09.md).

0 commit comments

Comments
 (0)