push_notifications.proto 3.2 KB

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