account.proto 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. syntax = "proto3";
  2. package chatto.api.v1;
  3. import "google/protobuf/field_mask.proto";
  4. import "google/protobuf/timestamp.proto";
  5. import "buf/validate/validate.proto";
  6. import "chatto/api/v1/external_identities.proto";
  7. import "chatto/api/v1/presence.proto";
  8. import "chatto/api/v1/user_status.proto";
  9. import "chatto/api/v1/users.proto";
  10. import "chatto/api/v1/viewer.proto";
  11. // Request to update or add the authenticated user's password.
  12. message ChangePasswordRequest {
  13. // New password. The server applies the same password policy as registration
  14. // and password reset.
  15. string password = 1 [(buf.validate.field).string = {
  16. min_len: 8
  17. max_len: 128
  18. }];
  19. // Current password. Required when the account already has a password; omitted
  20. // when adding the first password to a passwordless account.
  21. string current_password = 2 [(buf.validate.field).string.max_len = 128];
  22. }
  23. // Result of updating or adding the authenticated account password.
  24. message ChangePasswordResponse {
  25. // Current authenticated user profile after the password update.
  26. User user = 1;
  27. }
  28. // One email address that the authenticated user has proved they control.
  29. message VerifiedEmail {
  30. // Normalized email address.
  31. string email = 1;
  32. // Time at which the address was verified.
  33. google.protobuf.Timestamp verified_at = 2;
  34. // Whether account-directed email is sent to this address.
  35. bool primary = 3;
  36. }
  37. // Request the authenticated user's verified email addresses. expected_user_id
  38. // binds the request to the account state that the client currently displays.
  39. // The server returns FAILED_PRECONDITION if the authenticated account changed.
  40. message ListVerifiedEmailsRequest {
  41. // User ID that the client expects to be authenticated.
  42. string expected_user_id = 1 [(buf.validate.field).string.min_len = 1];
  43. }
  44. // Verified email addresses for the authenticated user.
  45. message ListVerifiedEmailsResponse {
  46. repeated VerifiedEmail verified_emails = 1;
  47. }
  48. // Request a short-lived verification code for an email address.
  49. message RequestEmailVerificationRequest {
  50. // New address to verify and add to the authenticated user's account.
  51. string email = 1 [(buf.validate.field).string = {email: true, max_len: 254}];
  52. // User ID that the client expects to be authenticated.
  53. string expected_user_id = 2 [(buf.validate.field).string.min_len = 1];
  54. }
  55. // Result of requesting an email verification code.
  56. message RequestEmailVerificationResponse {}
  57. // Confirm control of an email address with a verification code.
  58. message ConfirmEmailVerificationRequest {
  59. // Address that received the verification code.
  60. string email = 1 [(buf.validate.field).string = {email: true, max_len: 254}];
  61. // Six-digit code that the server sent to the address.
  62. string code = 2 [(buf.validate.field).string = {min_len: 1, max_len: 32}];
  63. // User ID that the client expects to be authenticated.
  64. string expected_user_id = 3 [(buf.validate.field).string.min_len = 1];
  65. }
  66. // Verified email addresses after a successful confirmation.
  67. message ConfirmEmailVerificationResponse {
  68. repeated VerifiedEmail verified_emails = 1;
  69. }
  70. // Select a verified email for account-directed email.
  71. message SetPrimaryEmailRequest {
  72. // Verified address to select as primary.
  73. string email = 1 [(buf.validate.field).string = {email: true, max_len: 254}];
  74. // User ID that the client expects to be authenticated.
  75. string expected_user_id = 2 [(buf.validate.field).string.min_len = 1];
  76. }
  77. // Verified email addresses after the primary address changes.
  78. message SetPrimaryEmailResponse {
  79. repeated VerifiedEmail verified_emails = 1;
  80. }
  81. // Request the authenticated user's display preferences. Human and bot accounts
  82. // use the same operation; no target account ID is accepted.
  83. message GetSettingsRequest {}
  84. // Current display preferences, with defaults for settings not yet saved.
  85. message GetSettingsResponse {
  86. // The same settings resource returned by UpdateSettings and GetViewer.
  87. UserSettings settings = 1;
  88. }
  89. // Request to patch the authenticated user's display preferences. update_mask
  90. // selects fields to apply or reset. Resetting timezone clears the override.
  91. message UpdateSettingsRequest {
  92. // IANA timezone override. Empty clears the override.
  93. optional string timezone = 1;
  94. // Preferred time format. UNSPECIFIED restores the automatic format.
  95. optional TimeFormat time_format = 2 [(buf.validate.field).enum.defined_only = true];
  96. // Whether the stored time zone may appear on the user's public profile.
  97. optional bool share_timezone = 3;
  98. // Editable fields to apply or reset: timezone, time_format, share_timezone.
  99. // Omit to infer populated fields; * selects all editable fields. An explicit
  100. // empty mask is invalid. Unselected values are ignored. Selected absent values
  101. // reset the field to its default, subject to field validation.
  102. google.protobuf.FieldMask update_mask = 4;
  103. }
  104. // Result of updating display preferences.
  105. message UpdateSettingsResponse {
  106. // Stored settings after merging the request.
  107. UserSettings settings = 1;
  108. }
  109. // Request a short-lived confirmation token for deleting the authenticated
  110. // account.
  111. message RequestAccountDeletionRequest {}
  112. // Result of issuing an account deletion confirmation token.
  113. message RequestAccountDeletionResponse {
  114. // Confirmation token. Clients must pass this to DeleteMyAccount.
  115. string confirmation_token = 1;
  116. }
  117. // Request to permanently delete the authenticated account.
  118. message DeleteMyAccountRequest {
  119. // Confirmation token obtained from RequestAccountDeletion.
  120. string confirmation_token = 1;
  121. }
  122. // Result of deleting the authenticated account.
  123. message DeleteMyAccountResponse {
  124. reserved 1;
  125. reserved "deleted";
  126. }
  127. // Self-service account, display preference, presence, custom-status,
  128. // external identity, and account lifecycle commands for the authenticated
  129. // user. Public profile and avatar changes use UserService.
  130. service MyAccountService {
  131. // Updates or adds the authenticated user's password.
  132. rpc ChangePassword(ChangePasswordRequest) returns (ChangePasswordResponse);
  133. // Lists the authenticated user's verified email addresses and primary choice.
  134. // Returns FAILED_PRECONDITION when the authenticated account does not match
  135. // expected_user_id.
  136. rpc ListVerifiedEmails(ListVerifiedEmailsRequest) returns (ListVerifiedEmailsResponse) {
  137. option idempotency_level = NO_SIDE_EFFECTS;
  138. }
  139. // Sends a six-digit code to an email address that the authenticated user
  140. // wants to add. The code expires after the server-configured email OTP
  141. // lifetime. The client can request a new code after expiry. The server must
  142. // have transactional email enabled. Returns ALREADY_EXISTS when the address
  143. // is already verified for the user, RESOURCE_EXHAUSTED after too many code
  144. // requests or attempts, and UNAVAILABLE when email delivery is disabled or
  145. // fails. Returns FAILED_PRECONDITION when the authenticated account does not
  146. // match expected_user_id.
  147. rpc RequestEmailVerification(RequestEmailVerificationRequest) returns (RequestEmailVerificationResponse);
  148. // Confirms a verification code and adds the address to the account. Returns
  149. // INVALID_ARGUMENT when the code is invalid or expired, and ALREADY_EXISTS
  150. // when another user already controls the address. Returns FAILED_PRECONDITION
  151. // when the authenticated account does not match expected_user_id.
  152. rpc ConfirmEmailVerification(ConfirmEmailVerificationRequest) returns (ConfirmEmailVerificationResponse);
  153. // Selects one verified address for future account-directed email. Returns
  154. // NOT_FOUND when the address is not verified for the authenticated user, and
  155. // FAILED_PRECONDITION when the authenticated account does not match
  156. // expected_user_id.
  157. rpc SetPrimaryEmail(SetPrimaryEmailRequest) returns (SetPrimaryEmailResponse);
  158. // Reads the authenticated user's display preferences without changing them.
  159. // Returns default settings when none have been saved.
  160. rpc GetSettings(GetSettingsRequest) returns (GetSettingsResponse);
  161. // Updates the authenticated user's display preferences.
  162. rpc UpdateSettings(UpdateSettingsRequest) returns (UpdateSettingsResponse);
  163. // Lists configured external identity providers and identities linked to the
  164. // authenticated account.
  165. rpc ListExternalIdentities(ListExternalIdentitiesRequest) returns (ListExternalIdentitiesResponse);
  166. // Creates a short-lived browser handoff URL for linking a provider identity
  167. // to the authenticated account. The provider callback completes through
  168. // chatto.auth.v1.ExternalIdentityAuthService.ConfirmExternalIdentityLink.
  169. rpc StartExternalIdentityLink(StartExternalIdentityLinkRequest) returns (StartExternalIdentityLinkResponse);
  170. // Disconnects a provider identity from the authenticated account.
  171. rpc DisconnectExternalIdentity(DisconnectExternalIdentityRequest) returns (DisconnectExternalIdentityResponse);
  172. // Legacy live presence report, expiring after 60 seconds without refresh.
  173. // A saved private choice overrides this report, including user_selected.
  174. // New clients use SetPresencePreference for choices and RefreshPresence
  175. // every 30 seconds for liveness.
  176. rpc SetPresence(SetPresenceRequest) returns (SetPresenceResponse);
  177. // Reads the authenticated account's private saved availability choice.
  178. rpc GetPresencePreference(GetPresencePreferenceRequest) returns (GetPresencePreferenceResponse);
  179. // Saves a choice for all devices on this server. A stale revision returns ABORTED.
  180. // OFFLINE suppresses public presence and typing; the choice survives disconnects.
  181. rpc SetPresencePreference(SetPresencePreferenceRequest) returns (SetPresencePreferenceResponse);
  182. // Refreshes connection liveness without changing the saved choice. Clients call
  183. // every 30 seconds; liveness expires after 60 seconds without a refresh.
  184. // Accounts with a saved OFFLINE choice may refresh without public presence signals.
  185. rpc RefreshPresence(RefreshPresenceRequest) returns (RefreshPresenceResponse);
  186. // Sets the current user's complete custom status. Emoji and text are required.
  187. // Omit expires_at for no expiry, or supply a future time.
  188. rpc SetCustomStatus(SetCustomStatusRequest) returns (SetCustomStatusResponse);
  189. // Deletes the current user's custom status. The call is idempotent and returns
  190. // the resulting empty status state.
  191. rpc DeleteCustomStatus(DeleteCustomStatusRequest) returns (DeleteCustomStatusResponse) {
  192. option idempotency_level = IDEMPOTENT;
  193. }
  194. // Issues a short-lived token used to confirm self-deletion. Requires
  195. // user.delete-self.
  196. rpc RequestAccountDeletion(RequestAccountDeletionRequest) returns (RequestAccountDeletionResponse);
  197. // Permanently deletes the authenticated account after token validation.
  198. // Requires user.delete-self.
  199. rpc DeleteMyAccount(DeleteMyAccountRequest) returns (DeleteMyAccountResponse);
  200. }