{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.qauth.dev/interaction/v1-rc.0/steps/select_account.json",
  "title": "urn:qauth:ia:select_account:v1-rc.0",
  "description": "The account chooser for `prompt=select_account`, when the browser holds sessions for several accounts of the realm (ADR-019 Decision 3, ADR-020 §3). The list is personal data. \"Use another account\" answers the `identifier` step, offered beside this one: that starts a new interaction for the same authorization request, and the result is a redirect to its page (#592). Needs JavaScript, to read the list.",
  "x-qauth-transports": [
    "interaction"
  ],
  "type": "object",
  "properties": {
    "type": {
      "const": "urn:qauth:ia:select_account:v1-rc.0",
      "description": "The step name."
    },
    "params": {
      "$ref": "#/$defs/params"
    },
    "answer": {
      "$ref": "#/$defs/answer"
    },
    "personal": {
      "$ref": "#/$defs/personal"
    },
    "error": {
      "$ref": "#/$defs/error"
    },
    "amr": {
      "$ref": "#/$defs/amr"
    }
  },
  "required": [
    "type",
    "params",
    "answer",
    "personal",
    "amr"
  ],
  "examples": [
    {
      "type": "urn:qauth:ia:select_account:v1-rc.0",
      "params": {},
      "answer": {
        "account": "c2Vzc2lvbi1yZWYtMDAwMDAx"
      },
      "personal": {
        "accounts": [
          {
            "account": "c2Vzc2lvbi1yZWYtMDAwMDAx",
            "identifier": "alice@example.com",
            "current": true
          },
          {
            "account": "c2Vzc2lvbi1yZWYtMDAwMDAy",
            "identifier": "alice@work.example",
            "current": false
          }
        ]
      },
      "amr": []
    }
  ],
  "$defs": {
    "params": {
      "type": "object",
      "properties": {},
      "additionalProperties": false,
      "examples": [
        {}
      ]
    },
    "answer": {
      "type": "object",
      "properties": {
        "account": {
          "type": "string",
          "minLength": 22,
          "maxLength": 64,
          "pattern": "^[A-Za-z0-9_-]{22,64}$",
          "description": "The `account` reference of the chosen entry."
        }
      },
      "required": [
        "account"
      ],
      "additionalProperties": false,
      "examples": [
        {
          "account": "c2Vzc2lvbi1yZWYtMDAwMDAx"
        }
      ]
    },
    "personal": {
      "type": "object",
      "properties": {
        "accounts": {
          "type": "array",
          "description": "The accounts the browser holds a session for, the current one first.",
          "minItems": 1,
          "maxItems": 16,
          "items": {
            "type": "object",
            "properties": {
              "account": {
                "type": "string",
                "minLength": 22,
                "maxLength": 64,
                "pattern": "^[A-Za-z0-9_-]{22,64}$",
                "description": "An opaque reference to the account’s session, valid for this interaction only."
              },
              "identifier": {
                "type": "string",
                "minLength": 1,
                "maxLength": 254,
                "pattern": "^[^<>\\p{C}\\p{Z}\\u115F\\u1160\\u3164\\uFFA0](?:[^<>\\p{C}\\p{Zl}\\p{Zp}\\u115F\\u1160\\u3164\\uFFA0]*[^<>\\p{C}\\p{Z}\\u115F\\u1160\\u3164\\uFFA0])?$",
                "x-qauth-display": "account",
                "description": "The identifier of the account this transaction is for. Before a first factor succeeds it is the identifier exactly as the person gave it, after the one normalisation every input gets, whether or not an account holds it, so it tells nothing about which accounts exist; the form the account holds appears only after authentication. Personal data: only the personal-data read returns it."
              },
              "current": {
                "type": "boolean",
                "description": "Whether this is the account the browser last used."
              }
            },
            "required": [
              "account",
              "identifier",
              "current"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "accounts"
      ],
      "additionalProperties": false,
      "examples": [
        {
          "accounts": [
            {
              "account": "c2Vzc2lvbi1yZWYtMDAwMDAx",
              "identifier": "alice@example.com",
              "current": true
            },
            {
              "account": "c2Vzc2lvbi1yZWYtMDAwMDAy",
              "identifier": "alice@work.example",
              "current": false
            }
          ]
        }
      ]
    },
    "error": {
      "type": "string",
      "enum": [
        "account_unavailable"
      ],
      "description": "Why the last answer was refused. A closed set."
    },
    "amr": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "const": [],
      "description": "The RFC 8176 `amr` values a successful answer adds to the transaction: none, because the step proves no authenticator."
    }
  }
}
