chromium/components/sync/protocol/password_sharing_invitation_specifics.proto

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

syntax = "proto2";

option java_multiple_files = true;
option java_package = "org.chromium.components.sync.protocol";

option optimize_for = LITE_RUNTIME;

package sync_pb;

import "components/sync/protocol/nigori_specifics.proto";

message PasswordSharingInvitationData {
  // Contains password fields required for sending. See PasswordSpecificsData
  // for field descriptions.
  message PasswordGroupElementData {
    // See PasswordSpecificsData::Scheme for values.
    optional int32 scheme = 2;
    optional string signon_realm = 3;
    optional string origin = 4;
    optional string username_element = 5;
    optional string password_element = 7;
    optional string display_name = 8;
    optional string avatar_url = 9;
  }

  message PasswordGroupData {
    optional string username_value = 1;
    optional string password_value = 2;
    repeated PasswordGroupElementData element_data = 3;
  }

  reserved 1;

  optional PasswordGroupData password_group_data = 2;
}

// Contains user profile information.
message UserDisplayInfo {
  // Primary email address of the user.
  optional string email = 1;

  // The user's full name.
  optional string display_name = 2;

  // Portrait photo of the user.
  optional string profile_image_url = 3;
}

message UserInfo {
  // Obfuscated Gaia ID.
  optional string user_id = 1;

  optional UserDisplayInfo user_display_info = 2;

  // Latest user's public key registered on the server.
  optional CrossUserSharingPublicKey cross_user_sharing_public_key = 3;
}

// Incoming invitations for password sending.
message IncomingPasswordSharingInvitationSpecifics {
  // Unique client tag for the invitation. This does *not* have to be the same
  // GUID as for the outgoing invitation.
  optional string guid = 1;

  // Profile information about the sender of the password. Sender's public key
  // is used to authenticate the sender for `encrypted_key_for_recipient`.
  optional UserInfo sender_info = 2;

  // Encrypted PasswordSharingInvitationData using recipient's public key
  // corresponding to `recipient_key_version` and sender's private key to
  // authenticate the sender, see https://www.rfc-editor.org/rfc/rfc9180.html.
  optional bytes encrypted_password_sharing_invitation_data = 3;

  // An unsynced field for use internally on the client. This field should
  // never be set in any network-based communications because it contains
  // unencrypted material.
  optional PasswordSharingInvitationData client_only_unencrypted_data = 4;

  optional uint32 recipient_key_version = 6;

  reserved 5;
}

// Outgoing invitations for password sending.
message OutgoingPasswordSharingInvitationSpecifics {
  // Unique client tag for the invitation, generated by the client.
  optional string guid = 1;

  // Recipient's user identifier (obfuscated Gaia ID).
  optional string recipient_user_id = 2;

  // Encrypted PasswordSharingInvitationData using recipient's public key
  // corresponding to `recipient_key_version` and sender's private key to
  // authenticate the sender, see https://www.rfc-editor.org/rfc/rfc9180.html.
  optional bytes encrypted_password_sharing_invitation_data = 3;

  // An unsynced field for use internally on the client. This field should
  // never be set in any network-based communications because it contains
  // unencrypted material.
  optional PasswordSharingInvitationData client_only_unencrypted_data = 4;

  optional uint32 recipient_key_version = 6;

  // Version of Public key of the sender which is used to authenticate the
  // sender of the password. Must be equal to the latest committed version.
  optional uint32 sender_key_version = 7;

  reserved 5;
}

// Used for the server to return fine-grained commit errors back to the client.
message OutgoingPasswordSharingInvitationCommitError {
  // This enum is used in histograms. Entries should not be renumbered and
  // numeric values should never be reused. Also remember to update in
  // tools/metrics/histograms/enums.xml.
  // LINT.IfChange(OutgoingPasswordSharingInvitationCommitError)
  enum ErrorCode {
    UNKNOWN = 0;

    // Sender's public key version is different on the server.
    PUBLIC_KEY_VERSION_MISMATCH = 1;

    // The sender and the recipient are not in the same family according to the
    // Google family service.
    NOT_FAMILY_MEMBER = 2;
  }
  // LINT.ThenChange(/tools/metrics/histograms/metadata/sync/enums.xml:OutgoingPasswordSharingInvitationCommitError)

  optional ErrorCode error_code = 1;
}