import "steammessages_unified_base.steamclient.proto";

option cc_generic_services = true;

message CTwoFactor_Status_Request {
	optional fixed64 steamid = 1 [(description) = "steamid to use"];
}

message CTwoFactor_Status_Response {
	optional uint32 state = 1 [(description) = "Authenticator state"];
	optional uint32 inactivation_reason = 2 [(description) = "Inactivation reason (if any)"];
	optional uint32 authenticator_type = 3 [(description) = "Type of authenticator"];
	optional bool authenticator_allowed = 4 [(description) = "Account allowed to have an authenticator?"];
	optional uint32 steamguard_scheme = 5 [(description) = "Steam Guard scheme in effect"];
	optional string token_gid = 6 [(description) = "String rep of token GID assigned by server"];
	optional bool email_validated = 7 [(description) = "Account has verified email capability"];
	optional string device_identifier = 8 [(description) = "Authenticator (phone) identifier"];
	optional uint32 time_created = 9 [(description) = "When the token was created"];
	optional uint32 revocation_attempts_remaining = 10 [(description) = "Number of revocation code attempts remaining"];
	optional string classified_agent = 11 [(description) = "Agent that added the authenticator (e.g., ios / android / other)"];
	optional bool allow_external_authenticator = 12 [(description) = "Allow a third-party authenticator (in addition to two-factor)"];
	optional uint32 time_transferred = 13 [(description) = "When the token was transferred from another device, if applicable"];
}

message CTwoFactor_AddAuthenticator_Request {
	optional fixed64 steamid = 1 [(description) = "steamid to use"];
	optional uint64 authenticator_time = 2 [(description) = "Current authenticator time"];
	optional fixed64 serial_number = 3 [(description) = "locally computed serial (deprecated)"];
	optional uint32 authenticator_type = 4 [(description) = "Authenticator type"];
	optional string device_identifier = 5 [(description) = "Authenticator identifier"];
	optional string sms_phone_id = 6 [(description) = "ID of phone to use for SMS verification"];
	repeated string http_headers = 7 [(description) = "HTTP headers alternating by K/V"];
}

message CTwoFactor_AddAuthenticator_Response {
	optional bytes shared_secret = 1 [(description) = "Shared secret between server and authenticator"];
	optional fixed64 serial_number = 2 [(description) = "Authenticator serial number (unique per token)"];
	optional string revocation_code = 3 [(description) = "code used to revoke authenticator"];
	optional string uri = 4 [(description) = "URI for QR code generation"];
	optional uint64 server_time = 5 [(description) = "Current server time"];
	optional string account_name = 6 [(description) = "Account name to display on token client"];
	optional string token_gid = 7 [(description) = "Token GID assigned by server"];
	optional bytes identity_secret = 8 [(description) = "Secret used for identity attestation (e.g., for eventing)"];
	optional bytes secret_1 = 9 [(description) = "Spare shared secret"];
	optional int32 status = 10 [(description) = "Result code"];
}

message CTwoFactor_SendEmail_Request {
	optional fixed64 steamid = 1 [(description) = "Steamid to use"];
	optional uint32 email_type = 2 [(description) = "Type of email to send (ETwoFactorEmailType::*)"];
	optional bool include_activation_code = 3 [(description) = "Include activation code in email parameters"];
}

message CTwoFactor_SendEmail_Response {
}

message CTwoFactor_FinalizeAddAuthenticator_Request {
	optional fixed64 steamid = 1 [(description) = "steamid to use"];
	optional string authenticator_code = 2 [(description) = "Current auth code"];
	optional uint64 authenticator_time = 3 [(description) = "Current authenticator time"];
	optional string activation_code = 4 [(description) = "Activation code from out-of-band message"];
	repeated string http_headers = 5 [(description) = "HTTP headers alternating by K/V"];
}

message CTwoFactor_FinalizeAddAuthenticator_Response {
	optional bool success = 1 [(description) = "True if succeeded, or want more tries"];
	optional bool want_more = 2 [(description) = "True if want more tries"];
	optional uint64 server_time = 3 [(description) = "Current server time"];
	optional int32 status = 4 [(description) = "Result code"];
}

message CTwoFactor_RemoveAuthenticator_Request {
	optional string revocation_code = 2 [(description) = "Password needed to remove token"];
	optional uint32 revocation_reason = 5 [(description) = "Reason the authenticator is being removed"];
	optional uint32 steamguard_scheme = 6 [(description) = "Type of Steam Guard to use once token is removed"];
	optional bool remove_all_steamguard_cookies = 7 [(description) = "Remove all steamguard cookies"];
}

message CTwoFactor_RemoveAuthenticator_Response {
	optional bool success = 1 [(description) = "True if request succeeeded. The mobile app checks this."];
	optional uint64 server_time = 3 [(description) = "Current server time"];
	optional uint32 revocation_attempts_remaining = 5 [(description) = "Number of revocation code attempts remaining"];
}

message CTwoFactor_CreateEmergencyCodes_Request {
	optional string code = 1;
}

message CTwoFactor_CreateEmergencyCodes_Response {
	repeated string codes = 1 [(description) = "Emergency codes"];
}

message CTwoFactor_DestroyEmergencyCodes_Request {
	optional fixed64 steamid = 1 [(description) = "steamid to use"];
}

message CTwoFactor_DestroyEmergencyCodes_Response {
}

message CTwoFactor_ValidateToken_Request {
	optional string code = 1 [(description) = "code to validate"];
}

message CTwoFactor_ValidateToken_Response {
	optional bool valid = 1 [(description) = "result of validation"];
}

service TwoFactor {
	option (service_description) = "Two Factor Authentication Service";

	rpc QueryStatus (.CTwoFactor_Status_Request) returns (.CTwoFactor_Status_Response) {
		option (method_description) = "Get two-factor authentication settings for the logged-in account";
	}

	rpc AddAuthenticator (.CTwoFactor_AddAuthenticator_Request) returns (.CTwoFactor_AddAuthenticator_Response) {
		option (method_description) = "Add two-factor authenticator to the logged-in account";
	}

	rpc SendEmail (.CTwoFactor_SendEmail_Request) returns (.CTwoFactor_SendEmail_Response) {
		option (method_description) = "Send email to the account";
	}

	rpc FinalizeAddAuthenticator (.CTwoFactor_FinalizeAddAuthenticator_Request) returns (.CTwoFactor_FinalizeAddAuthenticator_Response) {
		option (method_description) = "Finalize two-factor authentication addition to the logged-in account";
	}

	rpc RemoveAuthenticator (.CTwoFactor_RemoveAuthenticator_Request) returns (.CTwoFactor_RemoveAuthenticator_Response) {
		option (method_description) = "Remove two-factor authentication addition from the logged-in account";
	}

	rpc CreateEmergencyCodes (.CTwoFactor_CreateEmergencyCodes_Request) returns (.CTwoFactor_CreateEmergencyCodes_Response) {
		option (method_description) = "Generate emergency authenticator codes";
	}

	rpc DestroyEmergencyCodes (.CTwoFactor_DestroyEmergencyCodes_Request) returns (.CTwoFactor_DestroyEmergencyCodes_Response) {
		option (method_description) = "Destroy emergency authenticator codes for the account";
	}

	rpc ValidateToken (.CTwoFactor_ValidateToken_Request) returns (.CTwoFactor_ValidateToken_Response) {
		option (method_description) = "Validate (and consume) a token";
	}
}
