diff --git a/docs/specs/clients/notify/authentication.md b/docs/specs/clients/notify/authentication.md index afc79309..19b53011 100644 --- a/docs/specs/clients/notify/authentication.md +++ b/docs/specs/clients/notify/authentication.md @@ -175,6 +175,181 @@ Paginated list of notifications with the most recently sent first. Unread notifi | Tag | 4015 | | Topic | notify topic | +## `wc_notifyGetNotification` + +Get one notification by ID. Useful for URL links where you need to retrieve a specific notification and display it without needing to go through `O(n)` round trips of pages to find the notification client-side. + +### Request + +- act - `notify_get_notification` +- iss - did:key of client identity key +- ksu - key server for identity key verification +- aud - did:key of dapp authentication key +- app - did:web of app domain that this request is associated with + - Example: `did:web:app.example.com` +- id - the notification ID to retrieve + +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4016 | +| Topic | notify topic | + +### Response + +- act - `notify_get_notification_response` +- iss - did:key of client identity key +- aud - did:key of dapp authentication key +- nfn - [Notify Notification](./data-structures.md#notify-notification) + +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4017 | +| Topic | notify topic | + +## `wc_notifyNotificationChanged` + +Emitted by the Notify Server when a notification changed state. For example if its read status changed. + +### Request + +- act - `notify_notification_changed` +- iss - did:key of dapp authentication key +- aud - did:key of client identity key +- nfn - array of [Notify Notification](./data-structures.md#notify-notification) + +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4018 | +| Topic | notify topic | + +### Response + +- act - `notify_notification_changed_response` +- iss - did:key of client identity key +- ksu - key server for identity key verification +- aud - did:key of dapp authentication key + +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4019 | +| Topic | notify topic | + +## `wc_notifyReadNotification` + +Marks a notification as read. + +### Request + +- act - `notify_read_notification` +- iss - did:key of client identity key +- ksu - key server for identity key verification +- aud - did:key of dapp authentication key +- app - did:web of app domain that this request is associated with + - Example: `did:web:app.example.com` +- ids - array of notification IDs to mark as read, max 1000 items + +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4020 | +| Topic | notify topic | + +### Response + +- act - `notify_read_notification_response` +- iss - did:key of dapp authentication key +- aud - did:key of client identity key + +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4021 | +| Topic | notify topic | + +## `wc_notifyGetUnreadNotificationsCount` + +Returns a count of how many notifications are unread. Useful to implement unread notification counters, without needing to go through `O(n)` round trips of pages to count the total client-side. + +### Request + +- act - `notify_get_unread_notifications_count` +- iss - did:key of client identity key +- ksu - key server for identity key verification +- aud - did:key of dapp authentication key +- app - did:web of app domain that this request is associated with + - Example: `did:web:app.example.com` + +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4022 | +| Topic | notify topic | + +### Response + +- act - `notify_get_unread_notifications_count_response` +- iss - did:key of dapp authentication key +- aud - did:key of client identity key +- cnt - number of unread notifications + +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4023 | +| Topic | notify topic | + ## Noop Noop message sent by the Notify Server after subscription creation to mark a topic as long-lived so the relay does not destroy it. Clients should ignore this message. diff --git a/docs/specs/clients/notify/client-sdk-api.md b/docs/specs/clients/notify/client-sdk-api.md index 0c440c9e..0a237575 100644 --- a/docs/specs/clients/notify/client-sdk-api.md +++ b/docs/specs/clients/notify/client-sdk-api.md @@ -43,11 +43,20 @@ abstract class Client { // Default 10, max 50 limit?: number, startingAfter?: string, + // Default false + unreadFirst?: string, }): Promise<{ notifications: NotifyNotificationRecord[], hasMore: boolean, + hasMoreUnread: boolean, }> + // get notification by ID + public abstract getNotification(params: { + topic: string, + id: string, + }): Promise + // delete active subscription public abstract deleteSubscription(params: { topic: string, diff --git a/docs/specs/clients/notify/data-structures.md b/docs/specs/clients/notify/data-structures.md index 727129d9..6de11910 100644 --- a/docs/specs/clients/notify/data-structures.md +++ b/docs/specs/clients/notify/data-structures.md @@ -55,6 +55,8 @@ icon: string, // Redirect URL for call-to-action related to notification. If empty, there is no link url: string, + // If the notification was read or not + read: boolean, } ```