push_notifications.proto 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. syntax = "proto3";
  2. package chatto.api.v1;
  3. import "buf/validate/validate.proto";
  4. import "google/protobuf/descriptor.proto";
  5. // Browser Web Push subscription commands for the authenticated user.
  6. service PushNotificationService {
  7. // Stores or updates the caller's browser push subscription.
  8. //
  9. // The server must have Web Push configured. Clients normally call this after
  10. // the browser grants notification permission and returns a PushSubscription.
  11. rpc Subscribe(SubscribePushRequest) returns (SubscribePushResponse);
  12. // Removes the caller's browser push subscription by endpoint.
  13. //
  14. // The call is idempotent: removing an unknown endpoint still succeeds.
  15. rpc Unsubscribe(UnsubscribePushRequest) returns (UnsubscribePushResponse) {
  16. option idempotency_level = IDEMPOTENT;
  17. }
  18. // Sends a test notification to the caller's registered browser subscriptions.
  19. // Calls are rate-limited per account. Delivery failures return a generic
  20. // unavailable error without exposing the push provider's response body.
  21. rpc SendTestNotification(SendTestPushNotificationRequest) returns (SendTestPushNotificationResponse);
  22. }
  23. // Request to store a PushSubscription returned by the browser Push API.
  24. message SubscribePushRequest {
  25. // Absolute HTTPS push service endpoint URL. The server rejects redirects and
  26. // destinations that resolve to private or other special-use addresses.
  27. string endpoint = 1 [(buf.validate.field).string = {
  28. min_len: 1
  29. max_len: 4096
  30. }];
  31. // Client P-256 ECDH public key from PushSubscription.keys.p256dh.
  32. string p256dh = 2 [(buf.validate.field).string = {
  33. min_len: 1
  34. max_len: 256
  35. }];
  36. // Authentication secret from PushSubscription.keys.auth.
  37. string auth = 3 [(buf.validate.field).string = {
  38. min_len: 1
  39. max_len: 128
  40. }];
  41. // Optional browser user-agent string for device identification.
  42. optional string user_agent = 4 [(buf.validate.field).string.max_len = 512];
  43. // URL host of the Chatto server that supplied the installed web app. The
  44. // sending server combines this with its own hostname to reconstruct the
  45. // client route. A host can include a port but no scheme, path, or user info.
  46. string client_host = 5 [(buf.validate.field).string = {
  47. min_len: 1
  48. max_len: 255
  49. }];
  50. // Random per-save capability generated by the client. A cancelled save can
  51. // later remove only the record carrying this exact token, even when the same
  52. // browser PushSubscription has since moved to another account.
  53. string cleanup_token = 6 [(buf.validate.field).string = {
  54. min_len: 32
  55. max_len: 128
  56. }];
  57. }
  58. // Response from storing a browser push subscription.
  59. message SubscribePushResponse {
  60. // True when the subscription was stored.
  61. bool subscribed = 1;
  62. }
  63. // Request to remove a browser push subscription.
  64. message UnsubscribePushRequest {
  65. // Push service endpoint URL to remove.
  66. string endpoint = 1 [(buf.validate.field).string = {
  67. min_len: 1
  68. max_len: 4096
  69. }];
  70. }
  71. // Response from removing a browser push subscription.
  72. message UnsubscribePushResponse {
  73. // True when the request completed.
  74. bool unsubscribed = 1;
  75. }
  76. // Request to test the current user's registered browser push subscriptions.
  77. message SendTestPushNotificationRequest {}
  78. // Result of sending a test Web Push notification.
  79. message SendTestPushNotificationResponse {
  80. // True when the push provider accepted the notification.
  81. bool sent = 1;
  82. }