chromium/components/sync/protocol/autofill_specifics.proto

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Sync protocol datatype extension for autofill.

// If you change or add any fields in this file, update proto_visitors.h and
// potentially proto_enum_conversions.{h, cc}.

syntax = "proto2";

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

option optimize_for = LITE_RUNTIME;

package sync_pb;

// Properties of autofill sync objects.

// An AutofillProfile.
message AutofillProfileSpecifics {
  // Represents the validation status of value stored in the AutofillProfile.
  enum VerificationStatus {
    // No verification status assigned.
    VERIFICATION_STATUS_UNSPECIFIED = 0;
    // The value token was parsed from a parent token.
    // For example, the first name was derived by splitting a full name into
    // its components.
    PARSED = 1;
    // Value was built from its subcomponents.
    // For example, the full name was built from the first, middle and last
    // name.
    FORMATTED = 2;
    // The value was observed in a form transmission.
    // For example, the user filled a form that contained at NAME_FULL field.
    // The value of NAME_FULL will be stored as OBSERVED.
    OBSERVED = 3;
    // The user used the autofill settings to verify and store this token.
    // This is currently only applicable to the full name, since users cannot
    // edit individual components of their name.
    USER_VERIFIED = 4;
    // The token was parsed remotely.
    SERVER_PARSED = 5;
  }

  optional string guid = 15;
  // Starting from M115, Autofill ignores the origin and doesn't distinguish
  // between verified (meaning `deprecated_origin == kSettingsOrigin`) and
  // unverified profiles anymore. However, clients prior to this milestone only
  // accept updates to verified profiles through Sync if the remote profile is
  // verified as well. For this reason, M115 clients and above always set the
  // origin to kSettingsOrigin.
  // TODO(crbug.com/40266694): Remove in a few milestones.
  optional string deprecated_origin = 16;
  optional int64 use_count = 22;

  // The time_t value of the last time this profile was used. This
  // value makes sense wrt base::Time::To/FromTimeT, which measures
  // from the Windows epoch.
  optional int64 use_date = 23;

  // A label intended to be chosen by the user. This was however never
  // implemented and is currently unused.
  optional string profile_label = 62;

  // Contact info name fields.
  repeated string name_first = 2;
  repeated string name_middle = 3;
  repeated string name_last = 4;
  // Sometimes the last name is composed of two names as it is common for
  // Hispanic/Latinx names. In the unstructured representation of the last name,
  // there may be even a conjunction between the first and the second last
  // name. For example, the more-complete version of Pablo Picasso's surname is
  // "Ruiz y Picasso" containing a first last name, a conjunction (the y) and a
  // second last name.
  repeated string name_last_first = 27;
  repeated string name_last_conjunction = 28;
  repeated string name_last_second = 29;
  repeated string name_full = 21;

  reserved 60;
  reserved "name_full_with_honorific";

  // Validation status records for name fields.
  reserved 30;
  reserved "name_honorific_status";
  repeated VerificationStatus name_first_status = 31;
  repeated VerificationStatus name_middle_status = 32;
  repeated VerificationStatus name_last_status = 33;
  repeated VerificationStatus name_last_first_status = 34;
  repeated VerificationStatus name_last_conjunction_status = 35;
  repeated VerificationStatus name_last_second_status = 36;
  repeated VerificationStatus name_full_status = 37;
  reserved 61;
  reserved "name_full_with_honorific_status";

  // Contact info additional fields.
  repeated string email_address = 5;
  optional string company_name = 6;

  // Address field.
  // The address_home_line1/2 fields are deprecated and
  // address_home_street_address should be used instead by
  // joining address_home_line1/2 with a newline ("\n").
  // Full deprecation can not be achieved before all sync profiles have been
  // updated with a M86+ client.
  // TODO(crbug.com/40142711): Remove usages of address_home_line1/2 and mark
  // field as deprecated.
  optional string address_home_line1 = 7;
  optional string address_home_line2 = 8;
  optional string address_home_city = 9;
  optional string address_home_state = 10;
  optional string address_home_zip = 11;
  optional string address_home_country = 12;
  optional string address_home_admin_level_2 = 71;

  // Additional address fields for i18n.
  optional string address_home_street_address = 17;
  optional string address_home_sorting_code = 18;
  optional string address_home_dependent_locality = 19;
  optional string address_home_language_code = 20;
  optional string address_home_thoroughfare_name = 38;
  optional string address_home_thoroughfare_number = 39;
  optional string address_home_street_location = 73;
  optional string address_home_subpremise_name = 42;
  // All the information related to the apartment. Normally a combination of the
  // apartment type (address_home_apt_type) and number (address_home_apt_num).
  // E.g. "Apt 5".
  optional string address_home_apt = 85;
  // The raw number (or identifier) of an apartment (e.g. "5") but without a
  // prefix. The value "apt 5" would correspond to the address_home_apt.
  optional string address_home_apt_num = 56;
  // Information describing the type of apartment (e.g. Apt, Apartamento, Sala,
  // Departamento).
  optional string address_home_apt_type = 87;
  optional string address_home_floor = 57;
  optional string address_home_landmark = 67;
  // The type indicates that the address is at the intersection between two
  // streets. This is a common way of writing addresses in Mexico.
  optional string address_home_between_streets = 69;
  // The meaning of the field is similar to address_home_between_streets. The
  // type should be used for "Entre calle 1" in MX addresses which also
  // contain the "Entre calle 2" field.
  optional string address_home_between_streets_1 = 77;
  // The meaning of the field is similar to address_home_between_streets. The
  // type should be used for "Entre calle 2" in MX addresses which also
  // contain the "Entre calle 1" field.
  optional string address_home_between_streets_2 = 79;
  optional string address_home_overflow = 75;
  // Combination of types address_home_between_streets or address_home_landmark.
  // Note that some address forms require the combination of both in a single
  // field as opposed to each one separately.
  optional string address_home_between_streets_or_landmark = 81;
  // Combination of types address_home_overflow and address_home_landmark.
  // Note that some address forms require the combination of both in a single
  // field as opposed to each one separately.
  optional string address_home_overflow_and_landmark = 83;
  // Combination of types address_home_street_location and
  // address_home_dependent_locality. Note that some address forms require the
  // combination of both in a single field as opposed to each one separately.
  optional string address_home_street_location_and_locality = 89;
  // Combination of types address_home_thoroughfare_number and
  // address_home_apt. Note that some address forms require the combination of
  // both in a single field as opposed to each one separately.
  optional string address_home_thoroughfare_number_and_apt = 91;

  // Validation status records for address fields.
  optional VerificationStatus address_home_city_status = 43;
  optional VerificationStatus address_home_state_status = 44;
  optional VerificationStatus address_home_zip_status = 45;
  optional VerificationStatus address_home_country_status = 46;
  optional VerificationStatus address_home_landmark_status = 68;
  optional VerificationStatus address_home_between_streets_status = 70;
  optional VerificationStatus address_home_between_streets_1_status = 78;
  optional VerificationStatus address_home_between_streets_2_status = 80;
  optional VerificationStatus address_home_admin_level_2_status = 72;
  optional VerificationStatus address_home_overflow_status = 76;
  optional VerificationStatus address_home_between_streets_or_landmark_status =
      82;
  optional VerificationStatus address_home_overflow_and_landmark_status = 84;
  optional VerificationStatus address_home_street_location_and_locality_status =
      90;
  optional VerificationStatus address_home_thoroughfare_number_and_apt_status =
      92;
  optional VerificationStatus address_home_street_address_status = 47;
  optional VerificationStatus address_home_sorting_code_status = 48;
  optional VerificationStatus address_home_dependent_locality_status = 49;
  optional VerificationStatus address_home_language_code_status = 50;
  optional VerificationStatus address_home_thoroughfare_name_status = 51;
  optional VerificationStatus address_home_thoroughfare_number_status = 52;
  optional VerificationStatus address_home_street_location_status = 74;
  optional VerificationStatus address_home_subpremise_name_status = 55;
  optional VerificationStatus address_home_apt_status = 86;
  optional VerificationStatus address_home_apt_num_status = 58;
  optional VerificationStatus address_home_apt_type_status = 88;
  optional VerificationStatus address_home_floor_status = 59;

  // Phone.
  repeated string phone_home_whole_number = 13;

  reserved 63;
  reserved "disallow_settings_visible_updates";

  // Removed in M123.
  reserved 64;
  reserved "birthdate_day";
  reserved 65;
  reserved "birthdate_month";
  reserved 66;
  reserved "birthdate_year";

  // Deprecated.
  optional string deprecated_label = 1 [deprecated = true];
  optional string phone_fax_whole_number = 14 [deprecated = true];
  // The following validity-related fields have only been used in combination
  // with an experimental features that are disabled for all clients and have
  // been removed in M100.
  optional int64 validity_state_bitfield = 24 [deprecated = true];
  optional bool is_client_validity_states_updated = 25 [deprecated = true];
  // Removed in M118.
  reserved 40;
  reserved "address_home_dependent_thoroughfare_name";
  reserved 41;
  reserved "address_home_premise_name";
  reserved 53;
  reserved "address_home_dependent_thoroughfare_name_status";
  reserved 54;
  reserved "address_home_premise_name_status";
  // Removed in M122.
  reserved 26;
  reserved "name_honorific";
}

message AutofillSpecifics {
  // If any of these 3 fields are present, then all 3 should be, and it implies
  // that this entity represents a classic autofill object.  In this case,
  // none of the autofill++ objects below should be present.
  optional string name = 1;
  optional string value = 2;
  repeated int64 usage_timestamp = 3;

  // An autofill++ profile object.  If present, indicates this entity
  // represents an AutofillProfile exclusively, and no other fields (such as
  // name/value or credit_card) should be present.
  optional AutofillProfileSpecifics profile = 4;

  reserved 5;
  reserved "encrypted_credit_card";
  reserved 6;
  reserved "credit_card";
}

// TODO(crbug.com/40105930): Deprecated, remove this once dependent change is
// done. Use WalletCreditCardCloudTokenData instead.
message CloudTokenData {
  // Last 4-5 digits of the Cloud Primary Account Number (CPAN).
  optional string suffix = 1;

  // CPAN Month number 1-12.
  optional int32 exp_month = 2;

  // CPAN Four-digit year (e.g. 2017).
  optional int32 exp_year = 3;

  // URL of the card art to be displayed for CPAN.
  optional string art_fife_url = 4;

  // Opaque identifier for the cloud token associated with the payment
  // instrument.
  optional string instrument_token = 5;
}

// Next id: 8
message CardBenefit {
  // The unique identifier of the benefit. Generated originally in Chrome Sync
  // server.
  optional string benefit_id = 7;

  // The benefit description (Engligh only currently) to be shown in the UI.
  optional string benefit_description = 1;

  // When the benefit should be displayed, in UTC time.
  optional int64 start_time_unix_epoch_milliseconds = 2;
  optional int64 end_time_unix_epoch_milliseconds = 3;

  // Proto containing data specific to a flat rate benefit. Empty as flat rate
  // benefits don't have unique fields. The actual benefit (e.g. "2% cash back")
  // is already included in the `benefit_description`.
  message FlatRateBenefit {}

  // For category benefits, represents the category of purchases that the
  // benefit can be applied to.
  enum CategoryBenefitType {
    CATEGORY_BENEFIT_TYPE_UNKNOWN = 0;
    SUBSCRIPTION = 1;
    FLIGHTS = 2;
    DINING = 3;
    ENTERTAINMENT = 4;
    STREAMING = 5;
    GROCERY_STORES = 6;
  }

  // Proto containing data specific to a category benefit.
  message CategoryBenefit {
    // The type of category purchases the benefit is eligible on.
    optional CategoryBenefitType category_benefit_type = 1;
  }

  // Proto containing data specific to a merchant benefit.
  message MerchantBenefit {
    // The merchant domain that the benefit is eligible on.
    // Example: https://www.acme.com
    repeated string merchant_domain = 1;
  }

  // Proto data representing the actual data of the credit card benefit,
  // depending on the benefit type.
  oneof DomainSpecificBenefit {
    FlatRateBenefit flat_rate_benefit = 4;
    CategoryBenefit category_benefit = 5;
    MerchantBenefit merchant_benefit = 6;
  }
}

message CardIssuer {
  enum Issuer {
    ISSUER_UNKNOWN = 0;
    // Card where the issuer is Google.
    GOOGLE = 1;
    // Card where the issuer is external.
    EXTERNAL_ISSUER = 2;
  }
  optional Issuer issuer = 1;

  // Uniquely identifies the issuer of the card. This field is required when
  // Issuer is EXTERNAL_ISSUER.
  // Example: capitalone, amex.
  optional string issuer_id = 2;
}

message WalletMaskedCreditCard {
  reserved 9, 14;
  reserved "card_class";

  enum WalletCardStatus {
    VALID = 0;
    EXPIRED = 1;
  }

  enum WalletCardType {
    UNKNOWN = 0;
    AMEX = 1;
    DISCOVER = 2;
    JCB = 3;
    MAESTRO = 4;
    MASTER_CARD = 5;
    SOLO = 6;
    SWITCH = 7;
    VISA = 8;
    UNIONPAY = 9;
    ELO = 10;
    VERVE = 11;
  }

  enum VirtualCardEnrollmentState {
    UNSPECIFIED = 0;
    UNENROLLED = 1 [deprecated = true];
    ENROLLED = 2;
    UNENROLLED_AND_NOT_ELIGIBLE = 3;
    UNENROLLED_AND_ELIGIBLE = 4;
  }

  enum VirtualCardEnrollmentType {
    TYPE_UNSPECIFIED = 0;
    ISSUER = 1;
    NETWORK = 2;
  }

  // Server-generated unique ID string. This is opaque to the client.
  // This is the legacy version of |instrument_id|.
  optional string id = 1;

  // What the server thinks of this card.
  optional WalletCardStatus status = 2;

  optional string name_on_card = 3;

  optional WalletCardType type = 4;

  // Last 4 digits of the credit card number.
  optional string last_four = 5;

  // Month number 1-12.
  optional int32 exp_month = 6;

  // Four-digit year (e.g. 2017).
  optional int32 exp_year = 7;

  // The WalletPostalAddress.id of the billing address.
  optional string billing_address_id = 8;

  // Issuing Bank name which is internationalized (e.g. "Chase", "工商银行")
  optional string bank_name = 10;

  // TODO(crbug.com/40105930): Deprecated, remove this once dependent change is
  // done.
  // Use WalletCreditCardCloudTokenData instead. This field will be set if
  // a cloud token is available for the instrument.
  optional CloudTokenData cloud_token_data = 11;

  // The card's nickname, if it exists.
  optional string nickname = 12;

  // Issuer of the card.
  optional CardIssuer card_issuer = 13;

  // Server-generated unique ID. This is opaque to the client.
  // |id| is the legacy version of this.
  optional int64 instrument_id = 15;

  // The state of virtual card enrollment.
  optional VirtualCardEnrollmentState virtual_card_enrollment_state = 16;

  // The URL for the client to fetch the card art image.
  optional string card_art_url = 17;

  // The product description for the card. Used to be shown in the UI.
  optional string product_description = 18;

  // The type of virtual card enrollment. kTypeUnspecified indicates that the
  // card is unenrolled.
  optional VirtualCardEnrollmentType virtual_card_enrollment_type = 19;

  // The benefits (e.g. points or discounts) associated with purchases made
  // with the card.
  repeated CardBenefit card_benefit = 20;

  // Separate link from the card issuer which provides additional context or
  // terms and conditions regarding the credit card product and its benefits.
  optional string product_terms_url = 21;
}

// Unused by the client since M121.
// TODO(crbug.com/40273491): Some server-side code still relies on this message.
// To keep the protos in sync, it is kept until that code is cleaned up.
// Different than an AutofillProfile because this represents some known address
// on the server that is pulled down rather than synced between Chromes.
message WalletPostalAddress {
  optional string id = 1;

  optional string recipient_name = 12;
  optional string company_name = 2;

  // This is the street address, of which there may be multiple lines. This
  // corresponds to "address_home_line[1|2] in the AutofillProfileSpecifics
  // message above. In some locales there may be more than two lines.
  repeated string street_address = 3;

  // Also known as "administrative area". This is normally the state or
  // province in most countries.
  optional string address_1 = 4;

  // Also known as "locality". In the US this is the city.
  optional string address_2 = 5;

  // A sub-classification beneath the city, e.g. an inner-city district or
  // suburb. Also known as "dependent_locality"
  optional string address_3 = 6;

  // Used in certain countries. Also known as "sub_dependent_locality".
  optional string address_4 = 7;

  optional string postal_code = 8;

  // Similar to the zipcode column, but used for businesses or organizations
  // that might not be geographically contiguous. The canonical example is
  // CEDEX in France.
  optional string sorting_code = 9;

  optional string country_code = 10;
  optional string language_code = 11;

  // Phone number. The format is unspecified and will be explicitly ignored.
  optional string phone_number = 13;
}

// Contains information about a Payments Customer.
message PaymentsCustomerData {
  // The billable customer ID associated with the account.
  optional string id = 1;
}

// Contains information about the cloud token data of server credit cards.
message WalletCreditCardCloudTokenData {
  // Server-generated ID string for the card this cloud token data is related
  // to. This should match the id in WalletMaskedCreditCard for to fetch the
  // corresponding actual card data. Note this is not unique across all cloud
  // token data, which means one card can have multiple sets of cloud token data
  // with the same masked_card_id.
  optional string masked_card_id = 1;

  // Last 4-5 digits of the Cloud Primary Account Number (CPAN).
  optional string suffix = 2;

  // CPAN Month number 1-12.
  optional int32 exp_month = 3;

  // CPAN Four-digit year (e.g. 2017).
  optional int32 exp_year = 4;

  // URL of the card art to be displayed for CPAN.
  optional string art_fife_url = 5;

  // Opaque identifier for the cloud token.
  optional string instrument_token = 6;
}

// Contains information of payment instruments that can be used by the user.
message PaymentInstrument {
  // Opaque identifier for the account stored in Payments Platform.
  // This will be used to initiate the payment.
  optional int64 instrument_id = 1;

  // Supported payment infrastructures (rail) that allow users to send money
  // between the payer and the payee. https://en.wikipedia.org/wiki/Payment_rail
  enum SupportedRail {
    SUPPORTED_RAIL_UNKNOWN = 0;
    // Payment rails for Brazil Open Banking.
    PIX = 1;
    // International Bank Account Numbers.
    IBAN = 2;
    // This rail can be used for making payments to push payment targets
    // represented as payment hyperlinks that are supported by the instrument
    // issuer. The hyperlink will be specified in the href attribute within a
    // <link> tag in the DOM representing the payment page.
    // More details on payment links can be found at
    // https://github.com/aneeshali/paymentlink/blob/main/docs/explainer.md.
    PAYMENT_HYPERLINK = 3;
  }
  // The supported rails for which a payment can be made for the given account.
  // For example, Pix is the open-banking rail in Brazil, UPI is the
  // open-banking rail in India.
  repeated SupportedRail supported_rails = 2;

  // The URL for the image to be displayed when showing the account to the
  // user.
  optional string display_icon_url = 3;

  // Nickname for the instrument.
  optional string nickname = 4;

  // The backing source for the applicable rails.
  oneof instrument_details {
    BankAccountDetails bank_account = 5;
    WalletMaskedIban iban = 6;
    EwalletDetails ewallet_details = 7;
  }

  optional DeviceDetails device_details = 8;
}

// Contains information of server IBAN (International Bank Account Number).
message WalletMaskedIban {
  // Opaque identifier for the account stored in Payments Platform.
  optional string instrument_id = 1;

  // Prefix of the full IBAN value, if available.
  optional string prefix = 2;

  // Suffix of the full IBAN value, if available.
  optional string suffix = 3;

  // Length of the full IBAN value, if available.
  optional int32 length = 4;

  // Nickname for the IBAN, if available.
  optional string nickname = 5;
}

// Details of a bank account required to show it in the payment instrument
// selector.
message BankAccountDetails {
  // The name of the bank where the user has an account.
  optional string bank_name = 1;

  // The last four digits of the account number to help the user identify their
  // account.
  optional string account_number_suffix = 2;

  enum AccountType {
    ACCOUNT_TYPE_UNSPECIFIED = 0;
    CHECKING = 1;
    SAVINGS = 2;
    CURRENT = 3;
    SALARY = 4;
    TRANSACTING_ACCOUNT = 5;
  }
  // The type of bank account.
  optional AccountType account_type = 3;
}

// Details of an eWallet account required to show it in the payment instrument
// selector.
message EwalletDetails {
  // Name of the ewallet provider.
  optional string ewallet_name = 1;

  // Display name of the ewallet account.
  optional string account_display_name = 2;

  // Payment hyperlinks will be embedded in payment web pages. Chrome will match
  // the payment link against the list of payment link URI regexes below. If
  // there is a match, the payment flow will be initiated via the Payments
  // Server. The regex matching approach makes it possible to launch new payment
  // methods without requiring any client side changes. More details on payment
  // links can be found at
  // https://github.com/aneeshali/paymentlink/blob/main/docs/explainer.md.
  repeated string supported_payment_link_uris = 3;
}

// This field captures all of the information related to the instrument-device
// combo that is required for the payment flows.
message DeviceDetails {
  // Whether the device is enrolled in FIDO for this instrument. Depending on
  // the FIDO state, the Chrome client will show a different UI for the
  // user. For an unbound device, there will be some user-education content and
  // the user will be asked to complete FIDO binding. For an already-bound
  // device, the user will see a more simplified UI.
  optional bool is_fido_enrolled = 1;
}

message AutofillWalletSpecifics {
  enum WalletInfoType {
    UNKNOWN = 0;
    MASKED_CREDIT_CARD = 1;
    // POSTAL_ADDRESS is unused by the client since M121.
    POSTAL_ADDRESS = 2;
    CUSTOMER_DATA = 3;
    CREDIT_CARD_CLOUD_TOKEN_DATA = 4;
    PAYMENT_INSTRUMENT = 5;
    MASKED_IBAN = 6 [deprecated = true];
  }

  optional WalletInfoType type = 1;

  // This field exists if and only if the "type" field equals to
  // MASKED_CREDIT_CARD.
  optional WalletMaskedCreditCard masked_card = 2;

  // Unused by the client since M121.
  // This field exists if and only if the `type` equals POSTAL_ADDRESS.
  // TODO(crbug.com/40273491): Some server-side code still relies on this field.
  // To keep the protos in sync, it is kept until that code is cleaned up.
  optional WalletPostalAddress address = 3;

  // This field exists if and only if the "type" field equals to CUSTOMER_DATA.
  optional PaymentsCustomerData customer_data = 4;

  // This field exists if and only if the "type" field equals to
  // CREDIT_CARD_CLOUD_TOKEN_DATA.
  optional WalletCreditCardCloudTokenData cloud_token_data = 5;

  // This field exists if and only if the "type" field equals to
  // PAYMENT_INSTRUMENT.
  optional PaymentInstrument payment_instrument = 6;

  // This field exists if and only if the `type` field equals to
  // MASKED_IBAN.
  optional WalletMaskedIban masked_iban = 7 [deprecated = true];
}

// Wallet card usage information that can be synced.
message WalletMetadataSpecifics {
  enum Type {
    UNKNOWN = 0;
    CARD = 1;
    // Unused by the client since M121.
    // TODO(crbug.com/40273491): Some server-side code still relies on this.
    // To keep the protos in sync, it is kept until that code is cleaned up.
    ADDRESS = 2;
    IBAN = 3;
  }

  // The type of the Wallet metadata.
  optional Type type = 1;

  // Base64 encoding of the unique ID string of the corresponding
  // AutofillMetadata.
  // For Wallet cards, this value is WalletMaskedCreditCard::id.
  // For Wallet IBANs, this value is WalletMaskedIban::instrument_id.
  optional string id = 2;

  // The number of times that this Wallet card or address was used.
  optional int64 use_count = 3;

  // The last use date of this Wallet card or address. Measured in microseconds
  // since the Windows epoch (1601).
  optional int64 use_date = 4;

  // The id of the profile/address that represents the billing address of this
  // Wallet card.
  optional string card_billing_address_id = 5;

  // Unused by the client since M121.
  // TODO(crbug.com/40273491): Some server-side code still relies on this field.
  // To keep the protos in sync, it is kept until that code is cleaned up.
  optional bool address_has_converted = 6;
}