/*
 * Copyright 2025 Signal Messenger, LLC
 * SPDX-License-Identifier: AGPL-3.0-only
 */

syntax = "proto3";

package signal;

option java_package = "org.signal.registration.proto";

message RegistrationData {
  // Should only be persisted in the app-layer a single time during registration
  AccountData accountData = 1;
  bool accountDataCommitted = 2;

  string accountEntropyPool = 3;
  string pin = 4;
  bool pinOptedOut = 5;
  bool registrationLockEnabled = 6;
  bytes profileKey = 7;
  bytes masterKeyForInitialDataRestore = 8;
  repeated SvrCredential svrCredentials = 9;
  ProvisioningData provisioningData = 10;
  string flowStateJson = 11;
  int64 lastUpdatedMillis = 12;
}

message AccountData {
  bytes aciIdentityKeyPair = 1;
  bytes pniIdentityKeyPair = 2;
  bytes aciSignedPreKey = 3;
  bytes pniSignedPreKey = 4;
  bytes aciLastResortKyberPreKey = 5;
  bytes pniLastResortKyberPreKey = 6;
  int32 aciRegistrationId = 7;
  int32 pniRegistrationId = 8;

  string aci = 9;
  string pni = 10;
  string e164 = 11;
  string servicePassword = 12;

  bytes unidentifiedAccessKey = 13;
  bool fetchesMessages = 14;

  LinkedDeviceData linkedDeviceData = 15;

  // Whether the service reported this registration as a re-registration of an existing account.
  bool reRegistration = 16;
}

message SvrCredential {
  string username = 1;
  string password = 2;
}

message ProvisioningData {
  enum Platform {
    UNKNOWN = 0;
    ANDROID = 1;
    IOS = 2;
  }

  enum Tier {
    TIER_UNKNOWN = 0;
    FREE = 1;
    PAID = 2;
  }

  string restoreMethodToken = 1;
  Platform platform = 2;
  Tier tier = 3;
  int64 backupTimestampMs = 4;
  int64 backupSizeBytes = 5;
  int64 backupVersion = 6;
}

message LinkedDeviceData {
  uint32 deviceId = 1;
  string deviceName = 2;
  optional bytes ephemeralBackupKey = 3;
  optional bytes mediaRootBackupKey = 4;
  optional bool readReceipts = 5;
}
