From f62b6955d5ca8770964d631506d618902c264106 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 7 Dec 2023 17:06:18 -0500 Subject: [PATCH 01/15] feat: notification pagination & read state --- docs/specs/clients/notify/authentication.md | 77 +++++++++++++++++++- docs/specs/clients/notify/data-structures.md | 6 ++ 2 files changed, 81 insertions(+), 2 deletions(-) diff --git a/docs/specs/clients/notify/authentication.md b/docs/specs/clients/notify/authentication.md index 1ea739dd..981d7912 100644 --- a/docs/specs/clients/notify/authentication.md +++ b/docs/specs/clients/notify/authentication.md @@ -78,7 +78,7 @@ A non-ideal way to avoid the race condition is for the sender to set the message - iss - did:key of dapp authentication key - app - did:web of app domain that this request is associated with - Example: `did:web:app.example.com` -- msg - [Notify Message](./data-structures.md#notify-message) +- msg - [Notify Notification](./data-structures.md#notify-notification) ## wc_notifyMessage response @@ -118,8 +118,81 @@ A non-ideal way to avoid the race condition is for the sender to set the message ## wc_notifyDelete response -- act - `notify_delete_response`` +- act - `notify_delete_response` - iss - did:key of dapp authentication key - aud - did:key of client identity key - app - did:web of app domain that this request is associated with - Example: `did:web:app.example.com` + +## wc_notifyGetNotifications request + +Paginated list of notifications with the most recent first. + +- act - `notify_get_notifications` +- 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` +- lmt - the max number of notifications to return. Default value is 10, maximum value is 100. +- aft - the notification ID to start returning messages after. Null to start with the most recent notification + +## wc_notifyGetNotifications response + +- act - `notify_get_notifications_response` +- iss - did:key of client identity key +- aud - did:key of Notify Server authentication key +- nfs - array of [Notify Notifications](./data-structures.md#notify-notification) +- mre - true if there are more notifications, false otherwise + +## wc_notifyGetNotification request + +Paginated list of notifications with the most recent first. + +- 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 + +## wc_notifyGetNotification response + +- act - `notify_get_notification_response` +- iss - did:key of client identity key +- aud - did:key of Notify Server authentication key +- nfn - [Notify Notifications](./data-structures.md#notify-notification) + +## wc_notifyNotificationChanged request + +- act - `notify_notification_changed` +- iss - did:key of client identity key +- aud - did:key of Notify Server authentication key +- nfn - array of [Notify Notification](./data-structures.md#notify-notification) + +## wc_notifyNotificationChanged 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 +- aud - did:key of Notify Server authentication key + +## wc_notifyReadNotification request + +Paginated list of notifications with the most recent first. + +- 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` +- id - the notification ID to retrieve + +## wc_notifyReadNotification response + +- act - `notify_read_notification_response` +- iss - did:key of client identity key +- aud - did:key of Notify Server authentication key diff --git a/docs/specs/clients/notify/data-structures.md b/docs/specs/clients/notify/data-structures.md index df77b792..5a124bf3 100644 --- a/docs/specs/clients/notify/data-structures.md +++ b/docs/specs/clients/notify/data-structures.md @@ -20,6 +20,10 @@ ```typescript { + // ID of the notification + id: string, + // Timestamp when the notification was sent + sent_at: string, // Notification type which matches the scope of notify subscription type: string, // Short message used in the title of the notification @@ -30,6 +34,8 @@ icon: string, // Redirect URL for call-to-action related to notification. If empty, do not redirect url: string, + // If the notification was read or not + read: boolean, } ``` From ea0c01dbc2266c18a78a94ccc98461e02ea60fa9 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 8 Dec 2023 13:12:00 -0500 Subject: [PATCH 02/15] feat: document IRN tags --- docs/specs/clients/notify/authentication.md | 132 ++++++++++++++++++-- 1 file changed, 123 insertions(+), 9 deletions(-) diff --git a/docs/specs/clients/notify/authentication.md b/docs/specs/clients/notify/authentication.md index 981d7912..a24fdd34 100644 --- a/docs/specs/clients/notify/authentication.md +++ b/docs/specs/clients/notify/authentication.md @@ -124,7 +124,9 @@ A non-ideal way to avoid the race condition is for the sender to set the message - app - did:web of app domain that this request is associated with - Example: `did:web:app.example.com` -## wc_notifyGetNotifications request +## `wc_notifyGetNotifications` + +### Request Paginated list of notifications with the most recent first. @@ -137,7 +139,19 @@ Paginated list of notifications with the most recent first. - lmt - the max number of notifications to return. Default value is 10, maximum value is 100. - aft - the notification ID to start returning messages after. Null to start with the most recent notification -## wc_notifyGetNotifications response +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4014 | +| Topic | notify topic | + +### Response - act - `notify_get_notifications_response` - iss - did:key of client identity key @@ -145,7 +159,21 @@ Paginated list of notifications with the most recent first. - nfs - array of [Notify Notifications](./data-structures.md#notify-notification) - mre - true if there are more notifications, false otherwise -## wc_notifyGetNotification request +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4015 | +| Topic | notify topic | + +## `wc_notifyGetNotification` + +### Request Paginated list of notifications with the most recent first. @@ -157,21 +185,59 @@ Paginated list of notifications with the most recent first. - Example: `did:web:app.example.com` - id - the notification ID to retrieve -## wc_notifyGetNotification response +```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 Notify Server authentication key - nfn - [Notify Notifications](./data-structures.md#notify-notification) -## wc_notifyNotificationChanged request +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4017 | +| Topic | notify topic | + +## `wc_notifyNotificationChanged` + +### Request - act - `notify_notification_changed` - iss - did:key of client identity key - aud - did:key of Notify Server authentication key - nfn - array of [Notify Notification](./data-structures.md#notify-notification) -## wc_notifyNotificationChanged response +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4018 | +| Topic | notify topic | + +### Response - act - `notify_notification_changed_response` - iss - did:key of client identity key @@ -179,9 +245,23 @@ Paginated list of notifications with the most recent first. - aud - did:key of dapp authentication key - aud - did:key of Notify Server authentication key -## wc_notifyReadNotification request +```typescript +{ + auth: string, +} +``` -Paginated list of notifications with the most recent first. +| 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 @@ -191,8 +271,42 @@ Paginated list of notifications with the most recent first. - Example: `did:web:app.example.com` - id - the notification ID to retrieve -## wc_notifyReadNotification response +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4020 | +| Topic | notify topic | + +### Response - act - `notify_read_notification_response` - iss - did:key of client identity key - aud - did:key of Notify Server authentication key + +```typescript +{ + auth: string, +} +``` + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4020 | +| Topic | notify topic | + +## Noop + +Noop message sent by the Notify Server after subscription creation to mark a topic as long-lived. + +| IRN | | +| ------- | ------------ | +| TTL | 300 | +| Tag | 4050 | +| Topic | notify topic | From 943d4d328b2d9de1d0bd0070acff4a551a5c218e Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sat, 9 Dec 2023 11:42:22 -0500 Subject: [PATCH 03/15] feat: count unread notifications and other tweaks --- docs/specs/clients/notify/authentication.md | 64 ++++++++++++++++++--- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/docs/specs/clients/notify/authentication.md b/docs/specs/clients/notify/authentication.md index a24fdd34..3dc386f6 100644 --- a/docs/specs/clients/notify/authentication.md +++ b/docs/specs/clients/notify/authentication.md @@ -126,9 +126,9 @@ A non-ideal way to avoid the race condition is for the sender to set the message ## `wc_notifyGetNotifications` -### Request +Paginated list of notifications with the most recent first. Unread notifications may be dispersed throughout the list and on subsequent pages. -Paginated list of notifications with the most recent first. +### Request - act - `notify_get_notifications` - iss - did:key of client identity key @@ -136,7 +136,7 @@ Paginated list of notifications with the most recent first. - 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` -- lmt - the max number of notifications to return. Default value is 10, maximum value is 100. +- lmt - the max number of notifications to return. Default value is 10, maximum value is 50. - aft - the notification ID to start returning messages after. Null to start with the most recent notification ```typescript @@ -157,7 +157,8 @@ Paginated list of notifications with the most recent first. - iss - did:key of client identity key - aud - did:key of Notify Server authentication key - nfs - array of [Notify Notifications](./data-structures.md#notify-notification) -- mre - true if there are more notifications, false otherwise +- mre - true if there are more pages, false otherwise +- mur - true if there are more unread notifications on following pages, false otherwise ```typescript { @@ -173,9 +174,9 @@ Paginated list of notifications with the most recent first. ## `wc_notifyGetNotification` -### Request +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. -Paginated list of notifications with the most recent first. +### Request - act - `notify_get_notification` - iss - did:key of client identity key @@ -218,6 +219,8 @@ Paginated list of notifications with the most recent first. ## `wc_notifyNotificationChanged` +Emitted by the Notify Server when a notification changed state. For example if its read status changed. + ### Request - act - `notify_notification_changed` @@ -298,12 +301,57 @@ Marks a notification as read. | IRN | | | ------- | ------------ | | TTL | 300 | -| Tag | 4020 | +| Tag | 4021 | +| Topic | notify topic | + +## `wc_notifyCountUnreadNotifications` + +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_count_unread_notifications` +- 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_count_unread_notifications_response` +- iss - did:key of client identity key +- aud - did:key of Notify Server authentication key + +```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. +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. + +Content is empty string. | IRN | | | ------- | ------------ | From 04b075526990bfe99793db76264e2ca18189ee13 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sat, 9 Dec 2023 11:55:35 -0500 Subject: [PATCH 04/15] feat: client SDK --- docs/specs/clients/notify/authentication.md | 6 +-- docs/specs/clients/notify/client-sdk-api.md | 52 +++++++++++++++------ 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/docs/specs/clients/notify/authentication.md b/docs/specs/clients/notify/authentication.md index 3dc386f6..b00d2d3d 100644 --- a/docs/specs/clients/notify/authentication.md +++ b/docs/specs/clients/notify/authentication.md @@ -304,13 +304,13 @@ Marks a notification as read. | Tag | 4021 | | Topic | notify topic | -## `wc_notifyCountUnreadNotifications` +## `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_count_unread_notifications` +- 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 @@ -331,7 +331,7 @@ Returns a count of how many notifications are unread. Useful to implement unread ### Response -- act - `notify_count_unread_notifications_response` +- act - `notify_get_unread_notifications_count_response` - iss - did:key of client identity key - aud - did:key of Notify Server authentication key diff --git a/docs/specs/clients/notify/client-sdk-api.md b/docs/specs/clients/notify/client-sdk-api.md index ef8b26a4..1b23589e 100644 --- a/docs/specs/clients/notify/client-sdk-api.md +++ b/docs/specs/clients/notify/client-sdk-api.md @@ -14,7 +14,7 @@ abstract class Client { // Calls `wc_notifyWatchSubscriptions` for all previously registered accounts, // watches for future subscription updates, and subscribes to all notification topics public abstract init(): Promise; - + // send notify subscription public abstract subscribe(params: { appDomain: string, @@ -40,24 +40,43 @@ abstract class Client { // get all notifications for a subscription public abstract getNotificationHistory(params: { topic: string, - }): Promise> + // Default 10, max 50 + limit?: number, + starting_after?: string, + }): Promise<{ + notifications: Record, + has_more: boolean, + has_more_unread: boolean, + }> + + // get notification by ID + public abstract getNotification(params: { + topic: string, + id: string, + }): Promise + + // mark notification as read + public abstract readNotification(params: { + topic: string, + id: string, + }): Promise + + // returns how many notifications are unread + public abstract getUnreadNotificationsCount(params: { + topic: string, + }): Promise // delete active subscription public abstract deleteSubscription(params: { topic: string, }): Promise; - - // delete notification - public abstract deleteNotification(params: { - id: number, - }): Promise; - + // decrypt notify subscription message public abstract decryptNotification(params: { topic: string, encryptedMessage: string, }): Promise; - + // Generates and returns SIWE message along with // Cacao Payload with identity key public abstract prepareRegistration(params: { @@ -69,7 +88,7 @@ abstract class Client { registerParams: NotifyRegistrationParams, message: string }>; - + // "Logs in" this client to notifications for the specified account. This involves: // - Verifies signature by reconstructing formatted message using provided payload // - Expected payload comes from prepareRegistration @@ -80,7 +99,7 @@ abstract class Client { registerParams: NotifyRegistrationParams, signature: string; }): Promise; - + // Returns true if account has a valid and up to date registration, false otherwise public abstract isRegistered(params: { account: string @@ -102,10 +121,13 @@ abstract class Client { // for wallet to listen for notify subscription created public abstract on("notify_subscription", (result: NotifySubscription | Error) => {}): void; - - // for wallet to listen on notify notification - public abstract on("notify_notification", (message: NotifyNotificationRecord, metadata: Metadata) => {}): void; - + + // for wallet to listen on notify notification + public abstract on("notify_notification", (notification: NotifyNotificationRecord, metadata: Metadata) => {}): void; + + // Listen for when an existing notification has been changed + public abstract on("notify_notification_changed", (notification: NotifyNotificationRecord, metadata: Metadata) => {}): void; + // for wallet to listen for result of notify subscription update public abstract on("notify_update", (result: NotifySubscription | Error) => {}): void; From 34d7ac6db1aa6848660fefd69ba30410a2386246 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Mon, 11 Dec 2023 15:56:26 -0500 Subject: [PATCH 05/15] feat: flag to make unread first --- docs/specs/clients/notify/authentication.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/specs/clients/notify/authentication.md b/docs/specs/clients/notify/authentication.md index b00d2d3d..b039cf37 100644 --- a/docs/specs/clients/notify/authentication.md +++ b/docs/specs/clients/notify/authentication.md @@ -136,6 +136,7 @@ Paginated list of notifications with the most recent first. Unread notifications - 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` +- urf - unread first - lmt - the max number of notifications to return. Default value is 10, maximum value is 50. - aft - the notification ID to start returning messages after. Null to start with the most recent notification From 26883f760f0859ab57cdee92c3245bac31a6ad37 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 22 Dec 2023 01:46:24 +0900 Subject: [PATCH 06/15] fix: wrong aud/iss --- docs/specs/clients/notify/authentication.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/specs/clients/notify/authentication.md b/docs/specs/clients/notify/authentication.md index b039cf37..8b7c9d33 100644 --- a/docs/specs/clients/notify/authentication.md +++ b/docs/specs/clients/notify/authentication.md @@ -203,7 +203,7 @@ Get one notification by ID. Useful for URL links where you need to retrieve a sp - act - `notify_get_notification_response` - iss - did:key of client identity key -- aud - did:key of Notify Server authentication key +- aud - did:key of dapp authentication key - nfn - [Notify Notifications](./data-structures.md#notify-notification) ```typescript @@ -225,8 +225,8 @@ Emitted by the Notify Server when a notification changed state. For example if i ### Request - act - `notify_notification_changed` -- iss - did:key of client identity key -- aud - did:key of Notify Server authentication key +- 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 @@ -247,7 +247,6 @@ Emitted by the Notify Server when a notification changed state. For example if i - iss - did:key of client identity key - ksu - key server for identity key verification - aud - did:key of dapp authentication key -- aud - did:key of Notify Server authentication key ```typescript { @@ -290,8 +289,8 @@ Marks a notification as read. ### Response - act - `notify_read_notification_response` -- iss - did:key of client identity key -- aud - did:key of Notify Server authentication key +- iss - did:key of dapp authentication key +- aud - did:key of client identity key ```typescript { @@ -333,8 +332,8 @@ Returns a count of how many notifications are unread. Useful to implement unread ### Response - act - `notify_get_unread_notifications_count_response` -- iss - did:key of client identity key -- aud - did:key of Notify Server authentication key +- iss - did:key of dapp authentication key +- aud - did:key of client identity key ```typescript { From 64f2a77a62f25a466e6dda67cdfd6b61260d21c5 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 22 Dec 2023 01:51:48 +0900 Subject: [PATCH 07/15] chore: mark many notifications as read --- docs/specs/clients/notify/authentication.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/specs/clients/notify/authentication.md b/docs/specs/clients/notify/authentication.md index 7899fe0c..29e72090 100644 --- a/docs/specs/clients/notify/authentication.md +++ b/docs/specs/clients/notify/authentication.md @@ -208,7 +208,7 @@ Get one notification by ID. Useful for URL links where you need to retrieve a sp - act - `notify_get_notification_response` - iss - did:key of client identity key - aud - did:key of dapp authentication key -- nfn - [Notify Notifications](./data-structures.md#notify-notification) +- nfn - [Notify Notification](./data-structures.md#notify-notification) ```typescript { @@ -276,7 +276,7 @@ Marks a notification as read. - 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 +- ids - array of notification IDs to mark as read, max 1000 items ```typescript { From c551cfe9e4e0376cb88333ba72d09e0b2e591167 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 22 Dec 2023 01:52:41 +0900 Subject: [PATCH 08/15] fix: number of unread notifications --- docs/specs/clients/notify/authentication.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/specs/clients/notify/authentication.md b/docs/specs/clients/notify/authentication.md index 29e72090..ae04d577 100644 --- a/docs/specs/clients/notify/authentication.md +++ b/docs/specs/clients/notify/authentication.md @@ -338,6 +338,7 @@ Returns a count of how many notifications are unread. Useful to implement unread - 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 { From 49a37f0ce81e82c0a97244508df0133330416c15 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 22 Dec 2023 01:53:40 +0900 Subject: [PATCH 09/15] chore: read multiple notifications in client SDK --- docs/specs/clients/notify/client-sdk-api.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/specs/clients/notify/client-sdk-api.md b/docs/specs/clients/notify/client-sdk-api.md index 9ea5ab8f..c2ef26d6 100644 --- a/docs/specs/clients/notify/client-sdk-api.md +++ b/docs/specs/clients/notify/client-sdk-api.md @@ -56,9 +56,9 @@ abstract class Client { }): Promise // mark notification as read - public abstract readNotification(params: { + public abstract markNotificationsAsRead(params: { topic: string, - id: string, + ids: string[], }): Promise // returns how many notifications are unread From 7dd81b3b7da523360698b5d7544c21b8147b4ea0 Mon Sep 17 00:00:00 2001 From: Chris Smith <1979423+chris13524@users.noreply.github.com> Date: Thu, 4 Jan 2024 22:17:52 -0500 Subject: [PATCH 10/15] Apply suggestions from code review --- docs/specs/clients/notify/authentication.md | 2 +- docs/specs/clients/notify/client-sdk-api.md | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/specs/clients/notify/authentication.md b/docs/specs/clients/notify/authentication.md index ae04d577..7e5e823a 100644 --- a/docs/specs/clients/notify/authentication.md +++ b/docs/specs/clients/notify/authentication.md @@ -141,7 +141,7 @@ Paginated list of notifications with the most recent first. Unread notifications - app - did:web of app domain that this request is associated with - Example: `did:web:app.example.com` - urf - unread first -- lmt - the max number of notifications to return. Default value is 10, maximum value is 50. +- lmt - the max number of notifications to return. Maximum value is 50. - aft - the notification ID to start returning messages after. Null to start with the most recent notification ```typescript diff --git a/docs/specs/clients/notify/client-sdk-api.md b/docs/specs/clients/notify/client-sdk-api.md index c2ef26d6..5a3e8161 100644 --- a/docs/specs/clients/notify/client-sdk-api.md +++ b/docs/specs/clients/notify/client-sdk-api.md @@ -42,11 +42,13 @@ abstract class Client { topic: string, // Default 10, max 50 limit?: number, - starting_after?: string, + startingAfter?: string, + // Default false + unreadFirst?: string, }): Promise<{ notifications: Record, - has_more: boolean, - has_more_unread: boolean, + hasMore: boolean, + hasMoreUnread: boolean, }> // get notification by ID From e2d4fcdb31a658383b2b9d99ca893aaefd344ece Mon Sep 17 00:00:00 2001 From: Chris Smith <1979423+chris13524@users.noreply.github.com> Date: Wed, 10 Jan 2024 17:31:16 -0500 Subject: [PATCH 11/15] Apply suggestions from code review --- docs/specs/clients/notify/authentication.md | 2 +- docs/specs/clients/notify/client-sdk-api.md | 4 ++-- docs/specs/clients/notify/data-structures.md | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/specs/clients/notify/authentication.md b/docs/specs/clients/notify/authentication.md index 7e5e823a..b0efa071 100644 --- a/docs/specs/clients/notify/authentication.md +++ b/docs/specs/clients/notify/authentication.md @@ -130,7 +130,7 @@ A non-ideal way to avoid the race condition is for the sender to set the message ## `wc_notifyGetNotifications` -Paginated list of notifications with the most recent first. Unread notifications may be dispersed throughout the list and on subsequent pages. +Paginated list of notifications with the most recently sent first. Unread notifications may be dispersed throughout the list and on subsequent pages. ### Request diff --git a/docs/specs/clients/notify/client-sdk-api.md b/docs/specs/clients/notify/client-sdk-api.md index 5a3e8161..e17e41b2 100644 --- a/docs/specs/clients/notify/client-sdk-api.md +++ b/docs/specs/clients/notify/client-sdk-api.md @@ -37,7 +37,7 @@ abstract class Client { account: string, }): Promise>; - // get all notifications for a subscription + // Get a paginated list of notifications with the most recently sent first. public abstract getNotificationHistory(params: { topic: string, // Default 10, max 50 @@ -46,7 +46,7 @@ abstract class Client { // Default false unreadFirst?: string, }): Promise<{ - notifications: Record, + notifications: NotifyNotificationRecord[], hasMore: boolean, hasMoreUnread: boolean, }> diff --git a/docs/specs/clients/notify/data-structures.md b/docs/specs/clients/notify/data-structures.md index 5a124bf3..177c7534 100644 --- a/docs/specs/clients/notify/data-structures.md +++ b/docs/specs/clients/notify/data-structures.md @@ -22,8 +22,8 @@ { // ID of the notification id: string, - // Timestamp when the notification was sent - sent_at: string, + // Unix ms timestamp when the notification was sent + sent_at: number, // Notification type which matches the scope of notify subscription type: string, // Short message used in the title of the notification From e0c422d9172605268ddc14f5669d71aeb981eda6 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Wed, 10 Jan 2024 17:36:11 -0500 Subject: [PATCH 12/15] chore: extract into different PR --- docs/specs/clients/notify/authentication.md | 175 ------------------- docs/specs/clients/notify/client-sdk-api.md | 3 - docs/specs/clients/notify/data-structures.md | 2 - 3 files changed, 180 deletions(-) diff --git a/docs/specs/clients/notify/authentication.md b/docs/specs/clients/notify/authentication.md index b0efa071..d931f882 100644 --- a/docs/specs/clients/notify/authentication.md +++ b/docs/specs/clients/notify/authentication.md @@ -177,181 +177,6 @@ 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 e17e41b2..3ec0d020 100644 --- a/docs/specs/clients/notify/client-sdk-api.md +++ b/docs/specs/clients/notify/client-sdk-api.md @@ -43,12 +43,9 @@ 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 diff --git a/docs/specs/clients/notify/data-structures.md b/docs/specs/clients/notify/data-structures.md index 177c7534..afccf24f 100644 --- a/docs/specs/clients/notify/data-structures.md +++ b/docs/specs/clients/notify/data-structures.md @@ -34,8 +34,6 @@ icon: string, // Redirect URL for call-to-action related to notification. If empty, do not redirect url: string, - // If the notification was read or not - read: boolean, } ``` From ef96a0326cc92760979e930f4c82037564b570ef Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 12 Jan 2024 07:38:07 -0500 Subject: [PATCH 13/15] fix: remove read/unread flags --- docs/specs/clients/notify/authentication.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/specs/clients/notify/authentication.md b/docs/specs/clients/notify/authentication.md index d931f882..a67ca8b8 100644 --- a/docs/specs/clients/notify/authentication.md +++ b/docs/specs/clients/notify/authentication.md @@ -140,7 +140,6 @@ Paginated list of notifications with the most recently sent first. Unread notifi - 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` -- urf - unread first - lmt - the max number of notifications to return. Maximum value is 50. - aft - the notification ID to start returning messages after. Null to start with the most recent notification @@ -163,7 +162,6 @@ Paginated list of notifications with the most recently sent first. Unread notifi - aud - did:key of Notify Server authentication key - nfs - array of [Notify Notifications](./data-structures.md#notify-notification) - mre - true if there are more pages, false otherwise -- mur - true if there are more unread notifications on following pages, false otherwise ```typescript { From e6c0f285d2de95c2c70e858d9579b66ec22d2592 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Mon, 22 Jan 2024 09:47:29 -0500 Subject: [PATCH 14/15] fix: wc_notifyGetNotifications nullability --- docs/specs/clients/notify/authentication.md | 2 +- docs/specs/clients/notify/data-structures.md | 23 +++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/docs/specs/clients/notify/authentication.md b/docs/specs/clients/notify/authentication.md index a67ca8b8..afc79309 100644 --- a/docs/specs/clients/notify/authentication.md +++ b/docs/specs/clients/notify/authentication.md @@ -80,7 +80,7 @@ A non-ideal way to avoid the race condition is for the sender to set the message - iss - did:key of dapp authentication key - app - did:web of app domain that this request is associated with - Example: `did:web:app.example.com` -- msg - [Notify Notification](./data-structures.md#notify-notification) +- msg - [Notify Message](./data-structures.md#notify-message) ## wc_notifyMessage response diff --git a/docs/specs/clients/notify/data-structures.md b/docs/specs/clients/notify/data-structures.md index a1ccdca8..727129d9 100644 --- a/docs/specs/clients/notify/data-structures.md +++ b/docs/specs/clients/notify/data-structures.md @@ -18,6 +18,27 @@ ## Notify Notification +```typescript +{ + // ID of the notification + id: string, + // Unix ms timestamp when the notification was sent + sent_at: number, + // Notification type which matches the scope of notify subscription + type: string, + // Short message used in the title of the notification + title: string, + // Long messages used in the body of the notification + body: string, + // Image URL used to display with the notification. If null, the app's icon from Notify Config is used instead + icon: string | null, + // Redirect URL for call-to-action related to notification. If null, there is no link + url: string | null, +} +``` + +## Notify Message + ```typescript { // ID of the notification @@ -32,7 +53,7 @@ body: string, // Image URL used to display with the notification. If empty, the app's icon from Notify Config is used instead icon: string, - // Redirect URL for call-to-action related to notification. If empty, do not redirect + // Redirect URL for call-to-action related to notification. If empty, there is no link url: string, } ``` From d613de1871991262535425e41665f93a0f22519e Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Mon, 5 Feb 2024 14:46:47 -0500 Subject: [PATCH 15/15] chore: move unrelated functions out of this spec --- docs/specs/clients/notify/client-sdk-api.md | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/docs/specs/clients/notify/client-sdk-api.md b/docs/specs/clients/notify/client-sdk-api.md index e02d7bff..0c440c9e 100644 --- a/docs/specs/clients/notify/client-sdk-api.md +++ b/docs/specs/clients/notify/client-sdk-api.md @@ -48,23 +48,6 @@ abstract class Client { hasMore: boolean, }> - // get notification by ID - public abstract getNotification(params: { - topic: string, - id: string, - }): Promise - - // mark notification as read - public abstract markNotificationsAsRead(params: { - topic: string, - ids: string[], - }): Promise - - // returns how many notifications are unread - public abstract getUnreadNotificationsCount(params: { - topic: string, - }): Promise - // delete active subscription public abstract deleteSubscription(params: { topic: string, @@ -127,9 +110,6 @@ abstract class Client { // for wallet to listen on notify notification public abstract on("notify_notification", (notification: NotifyNotificationRecord, metadata: Metadata) => {}): void; - // Listen for when an existing notification has been changed - public abstract on("notify_notification_changed", (notification: NotifyNotificationRecord, metadata: Metadata) => {}): void; - // for wallet to listen for result of notify subscription update public abstract on("notify_update", (result: NotifySubscription | Error) => {}): void;