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

// 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;

// LINT.IfChange(AutofillValuableSpecifics)
// This is a copy of google.protobuf.Any.
message Any {
  // A URL/resource name that uniquely identifies the type of the serialized
  // protocol buffer message.
  optional string type_url = 1;

  // Must be a valid serialized protocol buffer of the above specified type.
  optional bytes value = 2;
}

// Represents a date without a time zone. This is useful for dates on physical
// documents, like an issue date of a passport.
message NaiveDate {
  optional int32 day = 1;
  optional int32 month = 2;
  optional int32 year = 3;
}

// Represents a loyalty card from Google Wallet.
message LoyaltyCard {
  // The merchant name e.g. "Deutsche Bahn".
  optional string merchant_name = 1;

  // The program name e.g. "BahnBonus".
  optional string program_name = 2;

  // The logo URL.
  optional string program_logo = 3;

  // The loyalty card text code.
  optional string loyalty_card_number = 4;

  // Merchant domains associated to the loyalty card.
  repeated string merchant_domains = 5;
}

// Represents a vehicle registration from Google Wallet.
message VehicleRegistration {
  // The vehicle make e.g. "Ford".
  optional string vehicle_make = 1;

  // The vehicle model e.g. "Fiesta".
  optional string vehicle_model = 2;

  // The year when model was first made e.g. "2018".
  optional string vehicle_year = 3;

  // The Vehicle Identification Number (VIN).
  optional string vehicle_identification_number = 4;

  // The license plate number.
  optional string vehicle_license_plate = 5;

  // The region that issued the license plate.
  optional string license_plate_region = 6;

  // The country that issued the license plate, normalized to ISO 3166-1
  // alpha-2.
  optional string license_plate_country = 7;

  // The owner of the vehicle as it appears on their vehicle registration
  // documents.
  optional string owner_name = 8;

  // The name of the issuer of the vehicle registration, e.g. "DMV".
  // Note that this field is currently used on Android, not in Chrome.
  optional string issuer_name = 9;

  // The issue date of the vehicle registration in microseconds.
  // Note that this field is currently used on Android, not in Chrome.
  optional int64 issue_date_unix_epoch_micros = 10;

  // The expiration date of the vehicle registration in microseconds.
  // Note that this field is currently used on Android, not in Chrome.
  optional int64 expiration_date_unix_epoch_micros = 11;

  // The logo URL of the vehicle registration.
  // Note that this field is currently used on Android, not in Chrome.
  optional string logo_url = 12;

  // The address of the owner of the vehicle registration
  // Note that this field is currently used on Android, not in Chrome.
  optional string owner_address = 13;
}

// Represents a flight reservation from Google Wallet.
message FlightReservation {
  // The flight number.
  optional string flight_number = 1;

  // The flight ticket number.
  optional string flight_ticket_number = 2;

  // The flight confirmation code (normally ~6 digits made of alphanumeric
  // characters).
  optional string flight_confirmation_code = 3;

  // The passenger's full name.
  optional string passenger_name = 4;

  // The departure airport in IATA format e.g AMS for Amsterdam Schiphol.
  optional string departure_airport = 5;

  // The arrival airport in IATA format e.g LHR for London Heathrow.
  optional string arrival_airport = 6;

  // The departure date. This is a server-provided timestamp in microseconds.
  optional int64 departure_date_unix_epoch_micros = 7;

  // The arrival date. This is a server-provided timestamp with units in
  // microseconds.
  optional int64 arrival_date_unix_epoch_micros = 8;

  // The airline logo. This is a Google URI pointing to an image.
  optional string airline_logo = 9;

  // The carrier code e.g. BA for British Airways.
  optional string carrier_code = 10;

  // The UTC offset of the departure airport's time zone in seconds.
  optional int64 departure_airport_utc_offset_seconds = 11;

  // The UTC offset of the arrival airport's time zone in seconds.
  optional int64 arrival_airport_utc_offset_seconds = 12;

  // The name of the issuer of the flight reservation, e.g. "United Airlines".
  // Note that this field is currently used on Android, not in Chrome.
  optional string issuer_name = 13;

  // Domains associated with the flight reservation issuer.
  // Note that this field is currently used on Android, not in Chrome.
  repeated string issuer_domains = 14;
}

// Represents a passport information from Google Wallet.
message Passport {
  // The masked passport number (typically only the last 4 digits are provided).
  optional string masked_number = 1;

  // The owner of the passport.
  optional string owner_name = 2;

  // The country that issued the passport, normalized to ISO 3166-1 alpha-2.
  optional string country_code = 3;

  reserved 4;
  reserved "issue_date_unix_epoch_micros";
  reserved 5;
  reserved "expiration_date_unix_epoch_micros";

  // The issue date of the passport.
  optional NaiveDate issue_date = 6;

  // The expiration date of the passport.
  optional NaiveDate expiration_date = 7;
}

// Represents a driver's license from Google Wallet.
message DriverLicense {
  // The masked driver's license number (typically only the last 4 digits are
  // provided).
  optional string masked_number = 1;

  // The owner of the driver's license.
  optional string owner_name = 2;

  // The country that issued the driver's license, normalized to ISO 3166-1
  // alpha-2.
  optional string country_code = 3;

  // The region that issued the driver's license.
  optional string region = 4;

  reserved 5;
  reserved "issue_date_unix_epoch_micros";
  reserved 6;
  reserved "expiration_date_unix_epoch_micros";

  // The issue date of the driver's license.
  optional NaiveDate issue_date = 7;

  // The expiration date of the driver's license.
  optional NaiveDate expiration_date = 8;
}

// Represents a national ID card from Google Wallet.
message NationalIdCard {
  // The masked national ID card number (typically only the last 4 digits are
  // provided).
  optional string masked_number = 1;

  // The owner of the national ID card.
  optional string owner_name = 2;

  // The country that issued the national ID card, normalized to ISO 3166-1
  // alpha-2.
  optional string country_code = 3;

  reserved 4;
  reserved "issue_date_unix_epoch_micros";
  reserved 5;
  reserved "expiry_date_unix_epoch_micros";

  // The issue date of the national ID card.
  optional NaiveDate issue_date = 6;

  // The expiration date of the national ID card.
  optional NaiveDate expiration_date = 7;
}

// Represents a redress number from Google Wallet.
message RedressNumber {
  // The masked redress number (typically only the last 4 digits are provided).
  optional string masked_number = 1;

  // The owner of the redress number.
  optional string owner_name = 2;
}

// Represents a known traveler number from Google Wallet.
message KnownTravelerNumber {
  // The masked known traveler number (typically only the last 4 digits are
  // provided).
  optional string masked_number = 1;

  // The owner of the known traveler number.
  optional string owner_name = 2;

  reserved 3;
  reserved "expiry_date_unix_epoch_micros";

  // The expiration date of the known traveler number.
  optional NaiveDate expiration_date = 4;
}

// Represents an event ticket from Google Wallet. Note that this proto is
// currently used by Android but not used in Chrome.
message EventTicket {
  // Name of the person assigned to the event ticket. Not necessarily the person
  // who owns the ticket in Wallet.
  optional string ticket_holder_name = 1;

  // The name of the event, such as "LA Dodgers at SF Giants".
  optional string event_name = 2;

  // The name of the venue, such as "AT&T Park".
  optional string event_venue_name = 3;

  // The address of the venue, such as "24 Willie Mays Plaza".
  optional string event_venue_address = 4;

  // The ticket number of the event ticket.
  optional string ticket_number = 5;

  // The issuer of the event ticket.
  optional string issuer_name = 6;

  // The start time of the event in windows epoch microseconds.
  optional int64 event_start_time_windows_epoch_micros = 7;

  // The end time of the event in windows epoch microseconds.
  optional int64 event_end_time_windows_epoch_micros = 8;

  // The logo URL of the event ticket.
  optional string logo_url = 9;

  // Domains associated with the event ticket issuer.
  repeated string issuer_domains = 10;
}

// Represents a transit pass from Google Wallet. Note that this proto is
// currently used by Android but not used in Chrome.
message TransitPass {
  // The transit agency that the transit pass is for.
  optional string agency_name = 1;

  // The name of the passenger that the transit pass is for.
  optional string passenger_name = 2;

  // The number of the transit pass.
  optional string transit_pass_number = 3;

  // The url of the logo of the transit agency.
  optional string agency_logo_url = 4;

  // Domains associated with the transit pass agency.
  repeated string agency_domains = 5;
}

// Represents an offer from Google Wallet. This proto is currently used for
// Wallet Direct Offers in Chrome. Note that this is separately used by Android
// for a different promo offer type that does not sync to Chrome.
message Offer {
  // Localized displayable issuer name, like "Safeway".
  optional string issuer_name = 1;

  // User visible name of the provider, like "coupon.com".
  optional string provider_name = 2;

  // Short title of the offer, like "50% off".
  optional string offer_short_title = 3;

  // The expiration time of the offer in unix epoch microseconds.
  optional int64 expiration_time_unix_epoch_micros = 4;

  // The code of the offer, like "1234567890".
  optional string offer_code = 5;

  // The url of the title image of the offer.
  optional string offer_title_image_url = 6;

  // Domains associated with the offer issuer.
  repeated string issuer_domains = 7;

  // The description of the offer, like "50% off your next purchase".
  optional string description = 8;
}

// Represents an Order from Google Wallet.
message Order {
  // The alphanumeric ID generated by the retail merchant to identify the order.
  optional string id = 1;
  // The account that the order was made with. Typically an email address.
  optional string account = 2;
  // The date on which the order was placed.
  optional NaiveDate order_date = 3;
  // The name of the merchant (e.g. "Amazon").
  optional string merchant_name = 4;
  // The eTLD+1 of the merchant's domain (e.g. "amazon.co.uk").
  optional string merchant_domain = 5;
  // The names of all the products ordered.
  repeated string product_names = 6;
}

// Represents a Shipment from Google Wallet.
// Since multiple orders may be shipped together, this is a separate entity
// rather than a child of Order.
message Shipment {
  // The alphanumeric ID assigned by the courier, primarily used to monitor the
  // shipment's delivery status.
  optional string tracking_number = 1;
  // The zip code to which the shipment will be delivered.
  optional string delivery_zip_code = 2;
  // The date on which the shipment was dispatched.
  optional NaiveDate shipping_date = 3;
  // The name of the courier delivering the shipment (e.g. "FedEx").
  optional string carrier_name = 4;
  // The eTLD+1 of the courier's domain (e.g. "fedex.com").
  optional string carrier_domain = 5;
  // Attributes corresponding to the Order(s) associated with the Shipment.
  // They are duplicated from the Order fields of the same name and flattened
  // into Shipment. This avoids having to deal with cross-entity relations.
  optional string merchant_name = 7;
  repeated string product_names = 8;

  reserved 6;
  reserved "associated_order_ids";
}

// Valuables coming from Google Wallet.
message AutofillValuableSpecifics {
  // The valuable id.
  optional string id = 1;

  // True if the pass is editable by external clients.
  optional bool is_editable = 6;

  oneof valuable_data {
    LoyaltyCard loyalty_card = 2;
    VehicleRegistration vehicle_registration = 3;
    FlightReservation flight_reservation = 5;
    Passport passport = 7;
    DriverLicense driver_license = 8;
    NationalIdCard national_id_card = 9;
    RedressNumber redress_number = 10;
    KnownTravelerNumber known_traveler_number = 11;
    // Note that EventTicket is used by Android but not by Chrome.
    EventTicket event_ticket = 12;
    // Note that TransitPass is used by Android but not by Chrome.
    TransitPass transit_pass = 13;
    // Note that while Offer is used for Wallet Direct Offers in Chrome, this
    // proto is also separately used for promo offers in Android.
    Offer offer = 14;
    Order order = 15;
    Shipment shipment = 16;
    // add other valuable types here.
  }

  // Contains information that is used by Chrome and needs to be persisted
  // across clients.
  optional Any serialized_chrome_valuables_metadata = 4;
}
// LINT.ThenChange(//components/autofill/core/browser/webdata/valuables/valuables_sync_util.cc:TrimAutofillValuableSpecificsDataForCaching)
