// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.events.firebase.auth.v2;

import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";

option csharp_namespace = "Google.Events.Protobuf.Firebase.Auth.V2";
option php_namespace = "Google\\Events\\Firebase\\Auth\\V2";
option ruby_package = "Google::Events::Firebase::Auth::V2";
option java_package = "com.google.events.firebase.auth.v2";

// The data within all Firebase Auth events.
message AuthEventData {
  // This is not populated for delete events.
  User value = 1;

  // This is only populated for update and delete events.
  User old_value = 2;
}

// The user for this Firebase Auth event.
message User {
  // The user identifier in the Firebase app.
  string uid = 1;

  // The user's primary email, if set.
  string email = 2;

  // Whether or not the user's primary email is verified.
  bool email_verified = 3;

  // The user's display name.
  string display_name = 4;

  // The user's photo URL.
  string photo_url = 5 [json_name = "photoURL"];

  // Whether the user is disabled.
  bool disabled = 6;

  // Additional metadata about the user.
  UserMetadata metadata = 7;

  // User's info at the providers
  repeated UserInfo provider_data = 8;

  // The user's phone number.
  string phone_number = 9;

  // User's custom claims, typically used to define user roles and propagated
  // to an authenticated user's ID token.
  google.protobuf.Struct custom_claims = 10;
}

// Additional metadata about the user.
message UserMetadata {
  // The date the user was created.
  google.protobuf.Timestamp create_time = 1;

  // The date the user last signed in.
  google.protobuf.Timestamp last_sign_in_time = 2;
}

// User's info at the identity provider
message UserInfo {
  // The user identifier for the linked provider.
  string uid = 1;

  // The email for the linked provider.
  string email = 2;

  // The display name for the linked provider.
  string display_name = 3;

  // The photo URL for the linked provider.
  string photo_url = 4 [json_name = "photoURL"];

  // The linked provider ID (e.g. "google.com" for the Google provider).
  string provider_id = 5;
}
