{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://nkips.org/nkip-0003/challenge.schema.json",
  "title": "NKIP-0003 Sign-In with Monero v1",
  "description": "The decoded challenge query and the callback body. Rules a schema can't express (Unicode-category rules for handle, the 15-minute window, duplicate parameters) are in the spec.",
  "$defs": {
    "challenge": {
      "type": "object",
      "required": [
        "address",
        "nonce",
        "session",
        "origin",
        "handle",
        "dk",
        "issued_at",
        "expires_at",
        "return_url",
        "v"
      ],
      "additionalProperties": false,
      "properties": {
        "address": {
          "type": "string",
          "pattern": "^[48][1-9A-HJ-NP-Za-km-z]{94}$"
        },
        "nonce": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{22,128}$"
        },
        "session": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,128}$"
        },
        "origin": {
          "type": "string",
          "pattern": "^[a-z0-9.-]+(:[0-9]+)?$"
        },
        "purpose": {
          "type": "string",
          "pattern": "^[a-z0-9_-]{1,32}$",
          "default": "login",
          "description": "Absent means login; the schema default is an annotation only, so implementations apply it themselves."
        },
        "handle": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "dk": {
          "type": "string",
          "pattern": "^[0-9a-f]{16}$"
        },
        "issued_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,3})?Z$"
        },
        "expires_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,3})?Z$"
        },
        "return_url": {
          "type": "string",
          "pattern": "^(https://[^\\s@#]+|http://(localhost|127\\.0\\.0\\.1|\\[::1\\])([:/][^\\s@#]*)?)$"
        },
        "v": {
          "const": "1"
        }
      }
    },
    "callback": {
      "type": "object",
      "required": [
        "session",
        "address",
        "signature"
      ],
      "additionalProperties": false,
      "properties": {
        "session": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,128}$"
        },
        "address": {
          "type": "string",
          "pattern": "^[48][1-9A-HJ-NP-Za-km-z]{94}$"
        },
        "signature": {
          "type": "string",
          "pattern": "^SigV[12][1-9A-HJ-NP-Za-km-z]+$"
        }
      }
    }
  }
}
