account.proto 12 KB

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