syntax = "proto3";

import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
import "wix/spi/definitions.proto";
import "google/protobuf/wrappers.proto";
import "wix/api/validations.proto";
import "wix/api/entity.proto";
import "wix/api/annotations.proto";
import "google/protobuf/field_mask.proto";

package com.wixpress.appservice.api.upstream.wix.iam.identity.authentication.authenticator.v1;

message AuthenticatorConfig {
    option (.wix.api.decomposite_of) = "wix.iam.identity.authentication.authenticator.v1.AuthenticatorConfig";
  string base_uri = 1 [(.wix.spi.base_uri) = true]; // the base URI where all the methods are deployed.
  // Is the enrolment step required (eg. for saving the password, public key, etc.)
  bool require_user_enroll = 2;
  // Information required during the enrollment and authentication processes
  ExpectedInputs expected_inputs = 3;
}

message ExpectedInputs {
    option (.wix.api.decomposite_of) = "wix.iam.identity.authentication.authenticator.v1.ExpectedInputs";
  // Inputs that will be expected from the user at the start of the process of trying to enroll or authenticate
  repeated PredefinedExpectedInput expected_start_inputs = 1;
  // Inputs that may be required during a second step of enroll/authenticate, specified at runtime by sending a Verify response
  repeated PredefinedExpectedInput expected_verify_inputs = 2;
}

// Specifies an expected input that can be fully configured by the SPI implementor, perhaps with overrides by the admin, _before_ runtime.
// Notably, this does not include WebAuthn, as that input requires a unique, random challenge to be generated and persisted per request (ie at runtime)
// in order to be implemented correctly.
message PredefinedExpectedInput {
    option (.wix.api.decomposite_of) = "wix.iam.identity.authentication.authenticator.v1.PredefinedExpectedInput";
  // The key used to identify the value entered into the input in the user_start_inputs or user_verify_inputs map
  string key = 1;
  // The name of the input as it should be indicated to the user
  string display_name = 2;
  // The configuration for the input
  PredefinedExpectedInputConfiguration configuration = 3;
}

message PredefinedExpectedInputConfiguration {
    option (.wix.api.decomposite_of) = "wix.iam.identity.authentication.authenticator.v1.PredefinedExpectedInputConfiguration";
  oneof type {
    AdminConfigurableTextInput text_input = 1;
  }
}

message AdminConfigurableTextInput {
    option (.wix.api.decomposite_of) = "wix.iam.identity.authentication.authenticator.v1.AdminConfigurableTextInput";
  // The default settings for the text input
  TextInputSettings default_settings = 1;
  // Settings that must be have non-null values.
  // This must be a subset of admin_configurable_settings.
  google.protobuf.FieldMask required_settings = 2;
  // Settings that the admin may override.
  // This must be a valid FieldMask with respect to TextFieldSettings as the root object.
  google.protobuf.FieldMask admin_configurable_settings = 3;
}

message TextInputSettings {
    option (.wix.api.decomposite_of) = "wix.iam.identity.authentication.authenticator.v1.TextInputSettings";
  // The minimum length required for the user to enter
  google.protobuf.UInt32Value min_length = 1;
  // The maximum length allowed for the user to enter
  google.protobuf.UInt32Value max_length = 2;
  // A regex that the text entered by the user must match
  google.protobuf.StringValue regex = 3;
  // How should the field be displayed to the end user
  TextInputDisplayType display_type = 4;
}

enum TextInputDisplayType {
  // A regular text field
  TEXT = 0;
  // A password field (where the text is hidden visually)
  PASSWORD = 1;
  // A field optimized for one time codes
  CODE = 2;
}
